Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 1 | /* |
Sean Hefty | 07d357d | 2005-10-17 15:37:43 -0700 | [diff] [blame] | 2 | * Copyright (c) 2004, 2005 Intel Corporation. All rights reserved. |
Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 3 | * Copyright (c) 2004 Topspin Corporation. All rights reserved. |
| 4 | * Copyright (c) 2004 Voltaire Corporation. All rights reserved. |
| 5 | * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. |
| 6 | * |
| 7 | * This software is available to you under a choice of one of two |
| 8 | * licenses. You may choose to be licensed under the terms of the GNU |
| 9 | * General Public License (GPL) Version 2, available from the file |
| 10 | * COPYING in the main directory of this source tree, or the |
| 11 | * OpenIB.org BSD license below: |
| 12 | * |
| 13 | * Redistribution and use in source and binary forms, with or |
| 14 | * without modification, are permitted provided that the following |
| 15 | * conditions are met: |
| 16 | * |
| 17 | * - Redistributions of source code must retain the above |
| 18 | * copyright notice, this list of conditions and the following |
| 19 | * disclaimer. |
| 20 | * |
| 21 | * - Redistributions in binary form must reproduce the above |
| 22 | * copyright notice, this list of conditions and the following |
| 23 | * disclaimer in the documentation and/or other materials |
| 24 | * provided with the distribution. |
| 25 | * |
| 26 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 27 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 28 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 29 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 30 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 31 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 32 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 33 | * SOFTWARE. |
Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 34 | */ |
| 35 | #if !defined(IB_CM_H) |
| 36 | #define IB_CM_H |
| 37 | |
Roland Dreier | a4d61e8 | 2005-08-25 13:40:04 -0700 | [diff] [blame] | 38 | #include <rdma/ib_mad.h> |
| 39 | #include <rdma/ib_sa.h> |
Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 40 | |
Sean Hefty | c89d1be | 2011-12-06 21:13:10 +0000 | [diff] [blame] | 41 | /* ib_cm and ib_user_cm modules share /sys/class/infiniband_cm */ |
| 42 | extern struct class cm_class; |
| 43 | |
Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 44 | enum ib_cm_state { |
| 45 | IB_CM_IDLE, |
| 46 | IB_CM_LISTEN, |
| 47 | IB_CM_REQ_SENT, |
| 48 | IB_CM_REQ_RCVD, |
| 49 | IB_CM_MRA_REQ_SENT, |
| 50 | IB_CM_MRA_REQ_RCVD, |
| 51 | IB_CM_REP_SENT, |
| 52 | IB_CM_REP_RCVD, |
| 53 | IB_CM_MRA_REP_SENT, |
| 54 | IB_CM_MRA_REP_RCVD, |
| 55 | IB_CM_ESTABLISHED, |
| 56 | IB_CM_DREQ_SENT, |
| 57 | IB_CM_DREQ_RCVD, |
| 58 | IB_CM_TIMEWAIT, |
| 59 | IB_CM_SIDR_REQ_SENT, |
| 60 | IB_CM_SIDR_REQ_RCVD |
| 61 | }; |
| 62 | |
| 63 | enum ib_cm_lap_state { |
Sean Hefty | e1444b5 | 2006-11-28 14:57:13 -0800 | [diff] [blame] | 64 | IB_CM_LAP_UNINIT, |
Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 65 | IB_CM_LAP_IDLE, |
| 66 | IB_CM_LAP_SENT, |
| 67 | IB_CM_LAP_RCVD, |
| 68 | IB_CM_MRA_LAP_SENT, |
| 69 | IB_CM_MRA_LAP_RCVD, |
| 70 | }; |
| 71 | |
| 72 | enum ib_cm_event_type { |
| 73 | IB_CM_REQ_ERROR, |
| 74 | IB_CM_REQ_RECEIVED, |
| 75 | IB_CM_REP_ERROR, |
| 76 | IB_CM_REP_RECEIVED, |
| 77 | IB_CM_RTU_RECEIVED, |
| 78 | IB_CM_USER_ESTABLISHED, |
| 79 | IB_CM_DREQ_ERROR, |
| 80 | IB_CM_DREQ_RECEIVED, |
| 81 | IB_CM_DREP_RECEIVED, |
| 82 | IB_CM_TIMEWAIT_EXIT, |
| 83 | IB_CM_MRA_RECEIVED, |
| 84 | IB_CM_REJ_RECEIVED, |
| 85 | IB_CM_LAP_ERROR, |
| 86 | IB_CM_LAP_RECEIVED, |
| 87 | IB_CM_APR_RECEIVED, |
| 88 | IB_CM_SIDR_REQ_ERROR, |
| 89 | IB_CM_SIDR_REQ_RECEIVED, |
| 90 | IB_CM_SIDR_REP_RECEIVED |
| 91 | }; |
| 92 | |
| 93 | enum ib_cm_data_size { |
| 94 | IB_CM_REQ_PRIVATE_DATA_SIZE = 92, |
| 95 | IB_CM_MRA_PRIVATE_DATA_SIZE = 222, |
| 96 | IB_CM_REJ_PRIVATE_DATA_SIZE = 148, |
| 97 | IB_CM_REP_PRIVATE_DATA_SIZE = 196, |
| 98 | IB_CM_RTU_PRIVATE_DATA_SIZE = 224, |
| 99 | IB_CM_DREQ_PRIVATE_DATA_SIZE = 220, |
| 100 | IB_CM_DREP_PRIVATE_DATA_SIZE = 224, |
| 101 | IB_CM_REJ_ARI_LENGTH = 72, |
| 102 | IB_CM_LAP_PRIVATE_DATA_SIZE = 168, |
| 103 | IB_CM_APR_PRIVATE_DATA_SIZE = 148, |
| 104 | IB_CM_APR_INFO_LENGTH = 72, |
| 105 | IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE = 216, |
| 106 | IB_CM_SIDR_REP_PRIVATE_DATA_SIZE = 136, |
Sean Hefty | 6e61d04 | 2006-06-17 20:37:28 -0700 | [diff] [blame] | 107 | IB_CM_SIDR_REP_INFO_LENGTH = 72, |
| 108 | IB_CM_COMPARE_SIZE = 64 |
Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 109 | }; |
| 110 | |
| 111 | struct ib_cm_id; |
| 112 | |
| 113 | struct ib_cm_req_event_param { |
| 114 | struct ib_cm_id *listen_id; |
Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 115 | u8 port; |
| 116 | |
| 117 | struct ib_sa_path_rec *primary_path; |
| 118 | struct ib_sa_path_rec *alternate_path; |
| 119 | |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 120 | __be64 remote_ca_guid; |
Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 121 | u32 remote_qkey; |
| 122 | u32 remote_qpn; |
| 123 | enum ib_qp_type qp_type; |
| 124 | |
| 125 | u32 starting_psn; |
| 126 | u8 responder_resources; |
| 127 | u8 initiator_depth; |
| 128 | unsigned int local_cm_response_timeout:5; |
| 129 | unsigned int flow_control:1; |
| 130 | unsigned int remote_cm_response_timeout:5; |
| 131 | unsigned int retry_count:3; |
| 132 | unsigned int rnr_retry_count:3; |
| 133 | unsigned int srq:1; |
| 134 | }; |
| 135 | |
| 136 | struct ib_cm_rep_event_param { |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 137 | __be64 remote_ca_guid; |
Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 138 | u32 remote_qkey; |
| 139 | u32 remote_qpn; |
| 140 | u32 starting_psn; |
| 141 | u8 responder_resources; |
| 142 | u8 initiator_depth; |
| 143 | unsigned int target_ack_delay:5; |
| 144 | unsigned int failover_accepted:2; |
| 145 | unsigned int flow_control:1; |
| 146 | unsigned int rnr_retry_count:3; |
| 147 | unsigned int srq:1; |
| 148 | }; |
| 149 | |
| 150 | enum ib_cm_rej_reason { |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 151 | IB_CM_REJ_NO_QP = 1, |
| 152 | IB_CM_REJ_NO_EEC = 2, |
| 153 | IB_CM_REJ_NO_RESOURCES = 3, |
| 154 | IB_CM_REJ_TIMEOUT = 4, |
| 155 | IB_CM_REJ_UNSUPPORTED = 5, |
| 156 | IB_CM_REJ_INVALID_COMM_ID = 6, |
| 157 | IB_CM_REJ_INVALID_COMM_INSTANCE = 7, |
| 158 | IB_CM_REJ_INVALID_SERVICE_ID = 8, |
| 159 | IB_CM_REJ_INVALID_TRANSPORT_TYPE = 9, |
| 160 | IB_CM_REJ_STALE_CONN = 10, |
| 161 | IB_CM_REJ_RDC_NOT_EXIST = 11, |
| 162 | IB_CM_REJ_INVALID_GID = 12, |
| 163 | IB_CM_REJ_INVALID_LID = 13, |
| 164 | IB_CM_REJ_INVALID_SL = 14, |
| 165 | IB_CM_REJ_INVALID_TRAFFIC_CLASS = 15, |
| 166 | IB_CM_REJ_INVALID_HOP_LIMIT = 16, |
| 167 | IB_CM_REJ_INVALID_PACKET_RATE = 17, |
| 168 | IB_CM_REJ_INVALID_ALT_GID = 18, |
| 169 | IB_CM_REJ_INVALID_ALT_LID = 19, |
| 170 | IB_CM_REJ_INVALID_ALT_SL = 20, |
| 171 | IB_CM_REJ_INVALID_ALT_TRAFFIC_CLASS = 21, |
| 172 | IB_CM_REJ_INVALID_ALT_HOP_LIMIT = 22, |
| 173 | IB_CM_REJ_INVALID_ALT_PACKET_RATE = 23, |
| 174 | IB_CM_REJ_PORT_CM_REDIRECT = 24, |
| 175 | IB_CM_REJ_PORT_REDIRECT = 25, |
| 176 | IB_CM_REJ_INVALID_MTU = 26, |
| 177 | IB_CM_REJ_INSUFFICIENT_RESP_RESOURCES = 27, |
| 178 | IB_CM_REJ_CONSUMER_DEFINED = 28, |
| 179 | IB_CM_REJ_INVALID_RNR_RETRY = 29, |
| 180 | IB_CM_REJ_DUPLICATE_LOCAL_COMM_ID = 30, |
| 181 | IB_CM_REJ_INVALID_CLASS_VERSION = 31, |
| 182 | IB_CM_REJ_INVALID_FLOW_LABEL = 32, |
| 183 | IB_CM_REJ_INVALID_ALT_FLOW_LABEL = 33 |
Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 184 | }; |
| 185 | |
| 186 | struct ib_cm_rej_event_param { |
| 187 | enum ib_cm_rej_reason reason; |
| 188 | void *ari; |
| 189 | u8 ari_length; |
| 190 | }; |
| 191 | |
| 192 | struct ib_cm_mra_event_param { |
| 193 | u8 service_timeout; |
| 194 | }; |
| 195 | |
| 196 | struct ib_cm_lap_event_param { |
| 197 | struct ib_sa_path_rec *alternate_path; |
| 198 | }; |
| 199 | |
| 200 | enum ib_cm_apr_status { |
| 201 | IB_CM_APR_SUCCESS, |
| 202 | IB_CM_APR_INVALID_COMM_ID, |
| 203 | IB_CM_APR_UNSUPPORTED, |
| 204 | IB_CM_APR_REJECT, |
| 205 | IB_CM_APR_REDIRECT, |
| 206 | IB_CM_APR_IS_CURRENT, |
| 207 | IB_CM_APR_INVALID_QPN_EECN, |
| 208 | IB_CM_APR_INVALID_LID, |
| 209 | IB_CM_APR_INVALID_GID, |
| 210 | IB_CM_APR_INVALID_FLOW_LABEL, |
| 211 | IB_CM_APR_INVALID_TCLASS, |
| 212 | IB_CM_APR_INVALID_HOP_LIMIT, |
| 213 | IB_CM_APR_INVALID_PACKET_RATE, |
| 214 | IB_CM_APR_INVALID_SL |
| 215 | }; |
| 216 | |
| 217 | struct ib_cm_apr_event_param { |
| 218 | enum ib_cm_apr_status ap_status; |
| 219 | void *apr_info; |
| 220 | u8 info_len; |
| 221 | }; |
| 222 | |
| 223 | struct ib_cm_sidr_req_event_param { |
| 224 | struct ib_cm_id *listen_id; |
Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 225 | u8 port; |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 226 | u16 pkey; |
Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 227 | }; |
| 228 | |
| 229 | enum ib_cm_sidr_status { |
| 230 | IB_SIDR_SUCCESS, |
| 231 | IB_SIDR_UNSUPPORTED, |
| 232 | IB_SIDR_REJECT, |
| 233 | IB_SIDR_NO_QP, |
| 234 | IB_SIDR_REDIRECT, |
| 235 | IB_SIDR_UNSUPPORTED_VERSION |
| 236 | }; |
| 237 | |
| 238 | struct ib_cm_sidr_rep_event_param { |
| 239 | enum ib_cm_sidr_status status; |
| 240 | u32 qkey; |
| 241 | u32 qpn; |
| 242 | void *info; |
| 243 | u8 info_len; |
Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 244 | }; |
| 245 | |
| 246 | struct ib_cm_event { |
| 247 | enum ib_cm_event_type event; |
| 248 | union { |
| 249 | struct ib_cm_req_event_param req_rcvd; |
| 250 | struct ib_cm_rep_event_param rep_rcvd; |
| 251 | /* No data for RTU received events. */ |
| 252 | struct ib_cm_rej_event_param rej_rcvd; |
| 253 | struct ib_cm_mra_event_param mra_rcvd; |
| 254 | struct ib_cm_lap_event_param lap_rcvd; |
| 255 | struct ib_cm_apr_event_param apr_rcvd; |
| 256 | /* No data for DREQ/DREP received events. */ |
| 257 | struct ib_cm_sidr_req_event_param sidr_req_rcvd; |
| 258 | struct ib_cm_sidr_rep_event_param sidr_rep_rcvd; |
| 259 | enum ib_wc_status send_status; |
| 260 | } param; |
| 261 | |
| 262 | void *private_data; |
| 263 | }; |
| 264 | |
| 265 | /** |
| 266 | * ib_cm_handler - User-defined callback to process communication events. |
| 267 | * @cm_id: Communication identifier associated with the reported event. |
| 268 | * @event: Information about the communication event. |
| 269 | * |
| 270 | * IB_CM_REQ_RECEIVED and IB_CM_SIDR_REQ_RECEIVED communication events |
| 271 | * generated as a result of listen requests result in the allocation of a |
| 272 | * new @cm_id. The new @cm_id is returned to the user through this callback. |
| 273 | * Clients are responsible for destroying the new @cm_id. For peer-to-peer |
| 274 | * IB_CM_REQ_RECEIVED and all other events, the returned @cm_id corresponds |
| 275 | * to a user's existing communication identifier. |
| 276 | * |
| 277 | * Users may not call ib_destroy_cm_id while in the context of this callback; |
| 278 | * however, returning a non-zero value instructs the communication manager to |
| 279 | * destroy the @cm_id after the callback completes. |
| 280 | */ |
| 281 | typedef int (*ib_cm_handler)(struct ib_cm_id *cm_id, |
| 282 | struct ib_cm_event *event); |
| 283 | |
| 284 | struct ib_cm_id { |
| 285 | ib_cm_handler cm_handler; |
| 286 | void *context; |
Sean Hefty | 07d357d | 2005-10-17 15:37:43 -0700 | [diff] [blame] | 287 | struct ib_device *device; |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 288 | __be64 service_id; |
| 289 | __be64 service_mask; |
Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 290 | enum ib_cm_state state; /* internal CM/debug use */ |
| 291 | enum ib_cm_lap_state lap_state; /* internal CM/debug use */ |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 292 | __be32 local_id; |
| 293 | __be32 remote_id; |
John Kingman | 354ba39 | 2005-09-09 18:23:32 -0700 | [diff] [blame] | 294 | u32 remote_cm_qpn; /* 1 unless redirected */ |
Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 295 | }; |
| 296 | |
| 297 | /** |
| 298 | * ib_create_cm_id - Allocate a communication identifier. |
Sean Hefty | 07d357d | 2005-10-17 15:37:43 -0700 | [diff] [blame] | 299 | * @device: Device associated with the cm_id. All related communication will |
| 300 | * be associated with the specified device. |
Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 301 | * @cm_handler: Callback invoked to notify the user of CM events. |
| 302 | * @context: User specified context associated with the communication |
| 303 | * identifier. |
| 304 | * |
| 305 | * Communication identifiers are used to track connection states, service |
| 306 | * ID resolution requests, and listen requests. |
| 307 | */ |
Sean Hefty | 07d357d | 2005-10-17 15:37:43 -0700 | [diff] [blame] | 308 | struct ib_cm_id *ib_create_cm_id(struct ib_device *device, |
| 309 | ib_cm_handler cm_handler, |
Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 310 | void *context); |
| 311 | |
| 312 | /** |
| 313 | * ib_destroy_cm_id - Destroy a connection identifier. |
| 314 | * @cm_id: Connection identifier to destroy. |
| 315 | * |
| 316 | * This call blocks until the connection identifier is destroyed. |
| 317 | */ |
| 318 | void ib_destroy_cm_id(struct ib_cm_id *cm_id); |
| 319 | |
Harvey Harrison | 9c3da09 | 2009-01-17 17:11:57 -0800 | [diff] [blame] | 320 | #define IB_SERVICE_ID_AGN_MASK cpu_to_be64(0xFF00000000000000ULL) |
| 321 | #define IB_CM_ASSIGN_SERVICE_ID cpu_to_be64(0x0200000000000000ULL) |
| 322 | #define IB_CMA_SERVICE_ID cpu_to_be64(0x0000000001000000ULL) |
| 323 | #define IB_CMA_SERVICE_ID_MASK cpu_to_be64(0xFFFFFFFFFF000000ULL) |
| 324 | #define IB_SDP_SERVICE_ID cpu_to_be64(0x0000000000010000ULL) |
| 325 | #define IB_SDP_SERVICE_ID_MASK cpu_to_be64(0xFFFFFFFFFFFF0000ULL) |
Sean Hefty | 6e61d04 | 2006-06-17 20:37:28 -0700 | [diff] [blame] | 326 | |
| 327 | struct ib_cm_compare_data { |
| 328 | u8 data[IB_CM_COMPARE_SIZE]; |
| 329 | u8 mask[IB_CM_COMPARE_SIZE]; |
| 330 | }; |
Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 331 | |
| 332 | /** |
| 333 | * ib_cm_listen - Initiates listening on the specified service ID for |
| 334 | * connection and service ID resolution requests. |
| 335 | * @cm_id: Connection identifier associated with the listen request. |
| 336 | * @service_id: Service identifier matched against incoming connection |
| 337 | * and service ID resolution requests. The service ID should be specified |
| 338 | * network-byte order. If set to IB_CM_ASSIGN_SERVICE_ID, the CM will |
| 339 | * assign a service ID to the caller. |
| 340 | * @service_mask: Mask applied to service ID used to listen across a |
| 341 | * range of service IDs. If set to 0, the service ID is matched |
| 342 | * exactly. This parameter is ignored if %service_id is set to |
| 343 | * IB_CM_ASSIGN_SERVICE_ID. |
Sean Hefty | 6e61d04 | 2006-06-17 20:37:28 -0700 | [diff] [blame] | 344 | * @compare_data: This parameter is optional. It specifies data that must |
| 345 | * appear in the private data of a connection request for the specified |
| 346 | * listen request. |
Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 347 | */ |
Sean Hefty | 6e61d04 | 2006-06-17 20:37:28 -0700 | [diff] [blame] | 348 | int ib_cm_listen(struct ib_cm_id *cm_id, __be64 service_id, __be64 service_mask, |
| 349 | struct ib_cm_compare_data *compare_data); |
Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 350 | |
| 351 | struct ib_cm_req_param { |
| 352 | struct ib_sa_path_rec *primary_path; |
| 353 | struct ib_sa_path_rec *alternate_path; |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 354 | __be64 service_id; |
Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 355 | u32 qp_num; |
| 356 | enum ib_qp_type qp_type; |
| 357 | u32 starting_psn; |
| 358 | const void *private_data; |
| 359 | u8 private_data_len; |
| 360 | u8 peer_to_peer; |
| 361 | u8 responder_resources; |
| 362 | u8 initiator_depth; |
| 363 | u8 remote_cm_response_timeout; |
| 364 | u8 flow_control; |
| 365 | u8 local_cm_response_timeout; |
| 366 | u8 retry_count; |
| 367 | u8 rnr_retry_count; |
| 368 | u8 max_cm_retries; |
| 369 | u8 srq; |
| 370 | }; |
| 371 | |
| 372 | /** |
| 373 | * ib_send_cm_req - Sends a connection request to the remote node. |
| 374 | * @cm_id: Connection identifier that will be associated with the |
| 375 | * connection request. |
| 376 | * @param: Connection request information needed to establish the |
| 377 | * connection. |
| 378 | */ |
| 379 | int ib_send_cm_req(struct ib_cm_id *cm_id, |
| 380 | struct ib_cm_req_param *param); |
| 381 | |
| 382 | struct ib_cm_rep_param { |
| 383 | u32 qp_num; |
| 384 | u32 starting_psn; |
| 385 | const void *private_data; |
| 386 | u8 private_data_len; |
| 387 | u8 responder_resources; |
| 388 | u8 initiator_depth; |
Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 389 | u8 failover_accepted; |
| 390 | u8 flow_control; |
| 391 | u8 rnr_retry_count; |
| 392 | u8 srq; |
| 393 | }; |
| 394 | |
| 395 | /** |
| 396 | * ib_send_cm_rep - Sends a connection reply in response to a connection |
| 397 | * request. |
| 398 | * @cm_id: Connection identifier that will be associated with the |
| 399 | * connection request. |
| 400 | * @param: Connection reply information needed to establish the |
| 401 | * connection. |
| 402 | */ |
| 403 | int ib_send_cm_rep(struct ib_cm_id *cm_id, |
| 404 | struct ib_cm_rep_param *param); |
| 405 | |
| 406 | /** |
| 407 | * ib_send_cm_rtu - Sends a connection ready to use message in response |
| 408 | * to a connection reply message. |
| 409 | * @cm_id: Connection identifier associated with the connection request. |
| 410 | * @private_data: Optional user-defined private data sent with the |
| 411 | * ready to use message. |
| 412 | * @private_data_len: Size of the private data buffer, in bytes. |
| 413 | */ |
| 414 | int ib_send_cm_rtu(struct ib_cm_id *cm_id, |
| 415 | const void *private_data, |
| 416 | u8 private_data_len); |
| 417 | |
| 418 | /** |
| 419 | * ib_send_cm_dreq - Sends a disconnection request for an existing |
| 420 | * connection. |
| 421 | * @cm_id: Connection identifier associated with the connection being |
| 422 | * released. |
| 423 | * @private_data: Optional user-defined private data sent with the |
| 424 | * disconnection request message. |
| 425 | * @private_data_len: Size of the private data buffer, in bytes. |
| 426 | */ |
| 427 | int ib_send_cm_dreq(struct ib_cm_id *cm_id, |
| 428 | const void *private_data, |
| 429 | u8 private_data_len); |
| 430 | |
| 431 | /** |
| 432 | * ib_send_cm_drep - Sends a disconnection reply to a disconnection request. |
| 433 | * @cm_id: Connection identifier associated with the connection being |
| 434 | * released. |
| 435 | * @private_data: Optional user-defined private data sent with the |
| 436 | * disconnection reply message. |
| 437 | * @private_data_len: Size of the private data buffer, in bytes. |
| 438 | * |
| 439 | * If the cm_id is in the correct state, the CM will transition the connection |
| 440 | * to the timewait state, even if an error occurs sending the DREP message. |
| 441 | */ |
| 442 | int ib_send_cm_drep(struct ib_cm_id *cm_id, |
| 443 | const void *private_data, |
| 444 | u8 private_data_len); |
| 445 | |
| 446 | /** |
Sean Hefty | e1444b5 | 2006-11-28 14:57:13 -0800 | [diff] [blame] | 447 | * ib_cm_notify - Notifies the CM of an event reported to the consumer. |
Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 448 | * @cm_id: Connection identifier to transition to established. |
Sean Hefty | e1444b5 | 2006-11-28 14:57:13 -0800 | [diff] [blame] | 449 | * @event: Type of event. |
Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 450 | * |
Sean Hefty | e1444b5 | 2006-11-28 14:57:13 -0800 | [diff] [blame] | 451 | * This routine should be invoked by users to notify the CM of relevant |
| 452 | * communication events. Events that should be reported to the CM and |
| 453 | * when to report them are: |
| 454 | * |
| 455 | * IB_EVENT_COMM_EST - Used when a message is received on a connected |
| 456 | * QP before an RTU has been received. |
| 457 | * IB_EVENT_PATH_MIG - Notifies the CM that the connection has failed over |
| 458 | * to the alternate path. |
Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 459 | */ |
Sean Hefty | e1444b5 | 2006-11-28 14:57:13 -0800 | [diff] [blame] | 460 | int ib_cm_notify(struct ib_cm_id *cm_id, enum ib_event_type event); |
Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 461 | |
| 462 | /** |
| 463 | * ib_send_cm_rej - Sends a connection rejection message to the |
| 464 | * remote node. |
| 465 | * @cm_id: Connection identifier associated with the connection being |
| 466 | * rejected. |
| 467 | * @reason: Reason for the connection request rejection. |
| 468 | * @ari: Optional additional rejection information. |
| 469 | * @ari_length: Size of the additional rejection information, in bytes. |
| 470 | * @private_data: Optional user-defined private data sent with the |
| 471 | * rejection message. |
| 472 | * @private_data_len: Size of the private data buffer, in bytes. |
| 473 | */ |
| 474 | int ib_send_cm_rej(struct ib_cm_id *cm_id, |
| 475 | enum ib_cm_rej_reason reason, |
| 476 | void *ari, |
| 477 | u8 ari_length, |
| 478 | const void *private_data, |
| 479 | u8 private_data_len); |
| 480 | |
Sean Hefty | de98b69 | 2007-08-01 13:49:53 -0700 | [diff] [blame] | 481 | #define IB_CM_MRA_FLAG_DELAY 0x80 /* Send MRA only after a duplicate msg */ |
| 482 | |
Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 483 | /** |
| 484 | * ib_send_cm_mra - Sends a message receipt acknowledgement to a connection |
| 485 | * message. |
| 486 | * @cm_id: Connection identifier associated with the connection message. |
Sean Hefty | de98b69 | 2007-08-01 13:49:53 -0700 | [diff] [blame] | 487 | * @service_timeout: The lower 5-bits specify the maximum time required for |
Anand Gadiyar | fd589a8 | 2009-07-16 17:13:03 +0200 | [diff] [blame] | 488 | * the sender to reply to the connection message. The upper 3-bits |
Sean Hefty | de98b69 | 2007-08-01 13:49:53 -0700 | [diff] [blame] | 489 | * specify additional control flags. |
Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 490 | * @private_data: Optional user-defined private data sent with the |
| 491 | * message receipt acknowledgement. |
| 492 | * @private_data_len: Size of the private data buffer, in bytes. |
| 493 | */ |
| 494 | int ib_send_cm_mra(struct ib_cm_id *cm_id, |
| 495 | u8 service_timeout, |
| 496 | const void *private_data, |
| 497 | u8 private_data_len); |
| 498 | |
| 499 | /** |
| 500 | * ib_send_cm_lap - Sends a load alternate path request. |
| 501 | * @cm_id: Connection identifier associated with the load alternate path |
| 502 | * message. |
| 503 | * @alternate_path: A path record that identifies the alternate path to |
| 504 | * load. |
| 505 | * @private_data: Optional user-defined private data sent with the |
| 506 | * load alternate path message. |
| 507 | * @private_data_len: Size of the private data buffer, in bytes. |
| 508 | */ |
| 509 | int ib_send_cm_lap(struct ib_cm_id *cm_id, |
| 510 | struct ib_sa_path_rec *alternate_path, |
| 511 | const void *private_data, |
| 512 | u8 private_data_len); |
| 513 | |
| 514 | /** |
| 515 | * ib_cm_init_qp_attr - Initializes the QP attributes for use in transitioning |
| 516 | * to a specified QP state. |
| 517 | * @cm_id: Communication identifier associated with the QP attributes to |
| 518 | * initialize. |
| 519 | * @qp_attr: On input, specifies the desired QP state. On output, the |
| 520 | * mandatory and desired optional attributes will be set in order to |
| 521 | * modify the QP to the specified state. |
| 522 | * @qp_attr_mask: The QP attribute mask that may be used to transition the |
| 523 | * QP to the specified state. |
| 524 | * |
| 525 | * Users must set the @qp_attr->qp_state to the desired QP state. This call |
| 526 | * will set all required attributes for the given transition, along with |
| 527 | * known optional attributes. Users may override the attributes returned from |
| 528 | * this call before calling ib_modify_qp. |
| 529 | */ |
| 530 | int ib_cm_init_qp_attr(struct ib_cm_id *cm_id, |
| 531 | struct ib_qp_attr *qp_attr, |
| 532 | int *qp_attr_mask); |
| 533 | |
| 534 | /** |
| 535 | * ib_send_cm_apr - Sends an alternate path response message in response to |
| 536 | * a load alternate path request. |
| 537 | * @cm_id: Connection identifier associated with the alternate path response. |
| 538 | * @status: Reply status sent with the alternate path response. |
| 539 | * @info: Optional additional information sent with the alternate path |
| 540 | * response. |
| 541 | * @info_length: Size of the additional information, in bytes. |
| 542 | * @private_data: Optional user-defined private data sent with the |
| 543 | * alternate path response message. |
| 544 | * @private_data_len: Size of the private data buffer, in bytes. |
| 545 | */ |
| 546 | int ib_send_cm_apr(struct ib_cm_id *cm_id, |
| 547 | enum ib_cm_apr_status status, |
| 548 | void *info, |
| 549 | u8 info_length, |
| 550 | const void *private_data, |
| 551 | u8 private_data_len); |
| 552 | |
| 553 | struct ib_cm_sidr_req_param { |
| 554 | struct ib_sa_path_rec *path; |
Sean Hefty | 97f52eb | 2005-08-13 21:05:57 -0700 | [diff] [blame] | 555 | __be64 service_id; |
Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 556 | int timeout_ms; |
| 557 | const void *private_data; |
| 558 | u8 private_data_len; |
| 559 | u8 max_cm_retries; |
Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 560 | }; |
| 561 | |
| 562 | /** |
| 563 | * ib_send_cm_sidr_req - Sends a service ID resolution request to the |
| 564 | * remote node. |
| 565 | * @cm_id: Communication identifier that will be associated with the |
| 566 | * service ID resolution request. |
| 567 | * @param: Service ID resolution request information. |
| 568 | */ |
| 569 | int ib_send_cm_sidr_req(struct ib_cm_id *cm_id, |
| 570 | struct ib_cm_sidr_req_param *param); |
| 571 | |
| 572 | struct ib_cm_sidr_rep_param { |
| 573 | u32 qp_num; |
| 574 | u32 qkey; |
| 575 | enum ib_cm_sidr_status status; |
| 576 | const void *info; |
| 577 | u8 info_length; |
| 578 | const void *private_data; |
| 579 | u8 private_data_len; |
| 580 | }; |
| 581 | |
| 582 | /** |
Sean Hefty | 75af908 | 2006-06-17 20:37:39 -0700 | [diff] [blame] | 583 | * ib_send_cm_sidr_rep - Sends a service ID resolution reply to the |
Hal Rosenstock | c3e0164 | 2005-07-27 11:45:39 -0700 | [diff] [blame] | 584 | * remote node. |
| 585 | * @cm_id: Communication identifier associated with the received service ID |
| 586 | * resolution request. |
| 587 | * @param: Service ID resolution reply information. |
| 588 | */ |
| 589 | int ib_send_cm_sidr_rep(struct ib_cm_id *cm_id, |
| 590 | struct ib_cm_sidr_rep_param *param); |
| 591 | |
| 592 | #endif /* IB_CM_H */ |