1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-O 1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ 2 /* 2 /* 3 * Copyright (c) 2004, 2005 Intel Corporation. 3 * Copyright (c) 2004, 2005 Intel Corporation. All rights reserved. 4 * Copyright (c) 2004 Topspin Corporation. Al 4 * Copyright (c) 2004 Topspin Corporation. All rights reserved. 5 * Copyright (c) 2004 Voltaire Corporation. A 5 * Copyright (c) 2004 Voltaire Corporation. All rights reserved. 6 * Copyright (c) 2005 Sun Microsystems, Inc. A 6 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. 7 * Copyright (c) 2019, Mellanox Technologies i 7 * Copyright (c) 2019, Mellanox Technologies inc. All rights reserved. 8 */ 8 */ 9 9 10 #ifndef IB_CM_H 10 #ifndef IB_CM_H 11 #define IB_CM_H 11 #define IB_CM_H 12 12 13 #include <rdma/ib_mad.h> 13 #include <rdma/ib_mad.h> 14 #include <rdma/ib_sa.h> 14 #include <rdma/ib_sa.h> 15 #include <rdma/rdma_cm.h> 15 #include <rdma/rdma_cm.h> 16 16 17 enum ib_cm_state { 17 enum ib_cm_state { 18 IB_CM_IDLE, 18 IB_CM_IDLE, 19 IB_CM_LISTEN, 19 IB_CM_LISTEN, 20 IB_CM_REQ_SENT, 20 IB_CM_REQ_SENT, 21 IB_CM_REQ_RCVD, 21 IB_CM_REQ_RCVD, 22 IB_CM_MRA_REQ_SENT, 22 IB_CM_MRA_REQ_SENT, 23 IB_CM_MRA_REQ_RCVD, 23 IB_CM_MRA_REQ_RCVD, 24 IB_CM_REP_SENT, 24 IB_CM_REP_SENT, 25 IB_CM_REP_RCVD, 25 IB_CM_REP_RCVD, 26 IB_CM_MRA_REP_SENT, 26 IB_CM_MRA_REP_SENT, 27 IB_CM_MRA_REP_RCVD, 27 IB_CM_MRA_REP_RCVD, 28 IB_CM_ESTABLISHED, 28 IB_CM_ESTABLISHED, 29 IB_CM_DREQ_SENT, 29 IB_CM_DREQ_SENT, 30 IB_CM_DREQ_RCVD, 30 IB_CM_DREQ_RCVD, 31 IB_CM_TIMEWAIT, 31 IB_CM_TIMEWAIT, 32 IB_CM_SIDR_REQ_SENT, 32 IB_CM_SIDR_REQ_SENT, 33 IB_CM_SIDR_REQ_RCVD 33 IB_CM_SIDR_REQ_RCVD 34 }; 34 }; 35 35 36 enum ib_cm_lap_state { 36 enum ib_cm_lap_state { 37 IB_CM_LAP_UNINIT, 37 IB_CM_LAP_UNINIT, 38 IB_CM_LAP_IDLE, 38 IB_CM_LAP_IDLE, 39 IB_CM_LAP_SENT, 39 IB_CM_LAP_SENT, 40 IB_CM_LAP_RCVD, 40 IB_CM_LAP_RCVD, 41 IB_CM_MRA_LAP_SENT, 41 IB_CM_MRA_LAP_SENT, 42 IB_CM_MRA_LAP_RCVD, 42 IB_CM_MRA_LAP_RCVD, 43 }; 43 }; 44 44 45 enum ib_cm_event_type { 45 enum ib_cm_event_type { 46 IB_CM_REQ_ERROR, 46 IB_CM_REQ_ERROR, 47 IB_CM_REQ_RECEIVED, 47 IB_CM_REQ_RECEIVED, 48 IB_CM_REP_ERROR, 48 IB_CM_REP_ERROR, 49 IB_CM_REP_RECEIVED, 49 IB_CM_REP_RECEIVED, 50 IB_CM_RTU_RECEIVED, 50 IB_CM_RTU_RECEIVED, 51 IB_CM_USER_ESTABLISHED, 51 IB_CM_USER_ESTABLISHED, 52 IB_CM_DREQ_ERROR, 52 IB_CM_DREQ_ERROR, 53 IB_CM_DREQ_RECEIVED, 53 IB_CM_DREQ_RECEIVED, 54 IB_CM_DREP_RECEIVED, 54 IB_CM_DREP_RECEIVED, 55 IB_CM_TIMEWAIT_EXIT, 55 IB_CM_TIMEWAIT_EXIT, 56 IB_CM_MRA_RECEIVED, 56 IB_CM_MRA_RECEIVED, 57 IB_CM_REJ_RECEIVED, 57 IB_CM_REJ_RECEIVED, 58 IB_CM_LAP_ERROR, 58 IB_CM_LAP_ERROR, 59 IB_CM_LAP_RECEIVED, 59 IB_CM_LAP_RECEIVED, 60 IB_CM_APR_RECEIVED, 60 IB_CM_APR_RECEIVED, 61 IB_CM_SIDR_REQ_ERROR, 61 IB_CM_SIDR_REQ_ERROR, 62 IB_CM_SIDR_REQ_RECEIVED, 62 IB_CM_SIDR_REQ_RECEIVED, 63 IB_CM_SIDR_REP_RECEIVED 63 IB_CM_SIDR_REP_RECEIVED 64 }; 64 }; 65 65 66 enum ib_cm_data_size { 66 enum ib_cm_data_size { 67 IB_CM_REQ_PRIVATE_DATA_SIZE = 92, 67 IB_CM_REQ_PRIVATE_DATA_SIZE = 92, 68 IB_CM_MRA_PRIVATE_DATA_SIZE = 222 68 IB_CM_MRA_PRIVATE_DATA_SIZE = 222, 69 IB_CM_REJ_PRIVATE_DATA_SIZE = 148 69 IB_CM_REJ_PRIVATE_DATA_SIZE = 148, 70 IB_CM_REP_PRIVATE_DATA_SIZE = 196 70 IB_CM_REP_PRIVATE_DATA_SIZE = 196, 71 IB_CM_RTU_PRIVATE_DATA_SIZE = 224 71 IB_CM_RTU_PRIVATE_DATA_SIZE = 224, 72 IB_CM_DREQ_PRIVATE_DATA_SIZE = 220 72 IB_CM_DREQ_PRIVATE_DATA_SIZE = 220, 73 IB_CM_DREP_PRIVATE_DATA_SIZE = 224 73 IB_CM_DREP_PRIVATE_DATA_SIZE = 224, 74 IB_CM_REJ_ARI_LENGTH = 72, 74 IB_CM_REJ_ARI_LENGTH = 72, 75 IB_CM_LAP_PRIVATE_DATA_SIZE = 168 75 IB_CM_LAP_PRIVATE_DATA_SIZE = 168, 76 IB_CM_APR_PRIVATE_DATA_SIZE = 148 76 IB_CM_APR_PRIVATE_DATA_SIZE = 148, 77 IB_CM_APR_INFO_LENGTH = 72, 77 IB_CM_APR_INFO_LENGTH = 72, 78 IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE = 216 78 IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE = 216, 79 IB_CM_SIDR_REP_PRIVATE_DATA_SIZE = 136 79 IB_CM_SIDR_REP_PRIVATE_DATA_SIZE = 136, 80 IB_CM_SIDR_REP_INFO_LENGTH = 72, 80 IB_CM_SIDR_REP_INFO_LENGTH = 72, 81 }; 81 }; 82 82 83 struct ib_cm_id; 83 struct ib_cm_id; 84 84 85 struct ib_cm_req_event_param { 85 struct ib_cm_req_event_param { 86 struct ib_cm_id *listen_id; 86 struct ib_cm_id *listen_id; 87 87 88 /* P_Key that was used by the GMP's BT 88 /* P_Key that was used by the GMP's BTH header */ 89 u16 bth_pkey; 89 u16 bth_pkey; 90 90 91 u8 port; 91 u8 port; 92 92 93 struct sa_path_rec *primary_path; 93 struct sa_path_rec *primary_path; 94 struct sa_path_rec *alternate_pat 94 struct sa_path_rec *alternate_path; 95 95 96 /* 96 /* 97 * SGID attribute of the primary path. 97 * SGID attribute of the primary path. Currently only 98 * useful for RoCE. Alternate path GID 98 * useful for RoCE. Alternate path GID attributes 99 * are not yet supported. 99 * are not yet supported. 100 */ 100 */ 101 const struct ib_gid_attr *ppath_sgid_a 101 const struct ib_gid_attr *ppath_sgid_attr; 102 102 103 __be64 remote_ca_guid 103 __be64 remote_ca_guid; 104 u32 remote_qkey; 104 u32 remote_qkey; 105 u32 remote_qpn; 105 u32 remote_qpn; 106 enum ib_qp_type qp_type; 106 enum ib_qp_type qp_type; 107 107 108 u32 starting_psn; 108 u32 starting_psn; 109 u8 responder_reso 109 u8 responder_resources; 110 u8 initiator_dept 110 u8 initiator_depth; 111 unsigned int local_cm_respo 111 unsigned int local_cm_response_timeout:5; 112 unsigned int flow_control:1 112 unsigned int flow_control:1; 113 unsigned int remote_cm_resp 113 unsigned int remote_cm_response_timeout:5; 114 unsigned int retry_count:3; 114 unsigned int retry_count:3; 115 unsigned int rnr_retry_coun 115 unsigned int rnr_retry_count:3; 116 unsigned int srq:1; 116 unsigned int srq:1; 117 struct rdma_ucm_ece ece; 117 struct rdma_ucm_ece ece; 118 }; 118 }; 119 119 120 struct ib_cm_rep_event_param { 120 struct ib_cm_rep_event_param { 121 __be64 remote_ca_guid 121 __be64 remote_ca_guid; 122 u32 remote_qkey; 122 u32 remote_qkey; 123 u32 remote_qpn; 123 u32 remote_qpn; 124 u32 starting_psn; 124 u32 starting_psn; 125 u8 responder_reso 125 u8 responder_resources; 126 u8 initiator_dept 126 u8 initiator_depth; 127 unsigned int target_ack_del 127 unsigned int target_ack_delay:5; 128 unsigned int failover_accep 128 unsigned int failover_accepted:2; 129 unsigned int flow_control:1 129 unsigned int flow_control:1; 130 unsigned int rnr_retry_coun 130 unsigned int rnr_retry_count:3; 131 unsigned int srq:1; 131 unsigned int srq:1; 132 struct rdma_ucm_ece ece; 132 struct rdma_ucm_ece ece; 133 }; 133 }; 134 134 135 enum ib_cm_rej_reason { 135 enum ib_cm_rej_reason { 136 IB_CM_REJ_NO_QP 136 IB_CM_REJ_NO_QP = 1, 137 IB_CM_REJ_NO_EEC 137 IB_CM_REJ_NO_EEC = 2, 138 IB_CM_REJ_NO_RESOURCES 138 IB_CM_REJ_NO_RESOURCES = 3, 139 IB_CM_REJ_TIMEOUT 139 IB_CM_REJ_TIMEOUT = 4, 140 IB_CM_REJ_UNSUPPORTED 140 IB_CM_REJ_UNSUPPORTED = 5, 141 IB_CM_REJ_INVALID_COMM_ID 141 IB_CM_REJ_INVALID_COMM_ID = 6, 142 IB_CM_REJ_INVALID_COMM_INSTANCE 142 IB_CM_REJ_INVALID_COMM_INSTANCE = 7, 143 IB_CM_REJ_INVALID_SERVICE_ID 143 IB_CM_REJ_INVALID_SERVICE_ID = 8, 144 IB_CM_REJ_INVALID_TRANSPORT_TYPE 144 IB_CM_REJ_INVALID_TRANSPORT_TYPE = 9, 145 IB_CM_REJ_STALE_CONN 145 IB_CM_REJ_STALE_CONN = 10, 146 IB_CM_REJ_RDC_NOT_EXIST 146 IB_CM_REJ_RDC_NOT_EXIST = 11, 147 IB_CM_REJ_INVALID_GID 147 IB_CM_REJ_INVALID_GID = 12, 148 IB_CM_REJ_INVALID_LID 148 IB_CM_REJ_INVALID_LID = 13, 149 IB_CM_REJ_INVALID_SL 149 IB_CM_REJ_INVALID_SL = 14, 150 IB_CM_REJ_INVALID_TRAFFIC_CLASS 150 IB_CM_REJ_INVALID_TRAFFIC_CLASS = 15, 151 IB_CM_REJ_INVALID_HOP_LIMIT 151 IB_CM_REJ_INVALID_HOP_LIMIT = 16, 152 IB_CM_REJ_INVALID_PACKET_RATE 152 IB_CM_REJ_INVALID_PACKET_RATE = 17, 153 IB_CM_REJ_INVALID_ALT_GID 153 IB_CM_REJ_INVALID_ALT_GID = 18, 154 IB_CM_REJ_INVALID_ALT_LID 154 IB_CM_REJ_INVALID_ALT_LID = 19, 155 IB_CM_REJ_INVALID_ALT_SL 155 IB_CM_REJ_INVALID_ALT_SL = 20, 156 IB_CM_REJ_INVALID_ALT_TRAFFIC_CLASS 156 IB_CM_REJ_INVALID_ALT_TRAFFIC_CLASS = 21, 157 IB_CM_REJ_INVALID_ALT_HOP_LIMIT 157 IB_CM_REJ_INVALID_ALT_HOP_LIMIT = 22, 158 IB_CM_REJ_INVALID_ALT_PACKET_RATE 158 IB_CM_REJ_INVALID_ALT_PACKET_RATE = 23, 159 IB_CM_REJ_PORT_CM_REDIRECT 159 IB_CM_REJ_PORT_CM_REDIRECT = 24, 160 IB_CM_REJ_PORT_REDIRECT 160 IB_CM_REJ_PORT_REDIRECT = 25, 161 IB_CM_REJ_INVALID_MTU 161 IB_CM_REJ_INVALID_MTU = 26, 162 IB_CM_REJ_INSUFFICIENT_RESP_RESOURCES 162 IB_CM_REJ_INSUFFICIENT_RESP_RESOURCES = 27, 163 IB_CM_REJ_CONSUMER_DEFINED 163 IB_CM_REJ_CONSUMER_DEFINED = 28, 164 IB_CM_REJ_INVALID_RNR_RETRY 164 IB_CM_REJ_INVALID_RNR_RETRY = 29, 165 IB_CM_REJ_DUPLICATE_LOCAL_COMM_ID 165 IB_CM_REJ_DUPLICATE_LOCAL_COMM_ID = 30, 166 IB_CM_REJ_INVALID_CLASS_VERSION 166 IB_CM_REJ_INVALID_CLASS_VERSION = 31, 167 IB_CM_REJ_INVALID_FLOW_LABEL 167 IB_CM_REJ_INVALID_FLOW_LABEL = 32, 168 IB_CM_REJ_INVALID_ALT_FLOW_LABEL 168 IB_CM_REJ_INVALID_ALT_FLOW_LABEL = 33, 169 IB_CM_REJ_VENDOR_OPTION_NOT_SUPPORTED 169 IB_CM_REJ_VENDOR_OPTION_NOT_SUPPORTED = 35, 170 }; 170 }; 171 171 172 struct ib_cm_rej_event_param { 172 struct ib_cm_rej_event_param { 173 enum ib_cm_rej_reason reason; 173 enum ib_cm_rej_reason reason; 174 void *ari; 174 void *ari; 175 u8 ari_length; 175 u8 ari_length; 176 }; 176 }; 177 177 178 struct ib_cm_mra_event_param { 178 struct ib_cm_mra_event_param { 179 u8 service_timeout; 179 u8 service_timeout; 180 }; 180 }; 181 181 182 struct ib_cm_lap_event_param { 182 struct ib_cm_lap_event_param { 183 struct sa_path_rec *alternate_pat 183 struct sa_path_rec *alternate_path; 184 }; 184 }; 185 185 186 enum ib_cm_apr_status { 186 enum ib_cm_apr_status { 187 IB_CM_APR_SUCCESS, 187 IB_CM_APR_SUCCESS, 188 IB_CM_APR_INVALID_COMM_ID, 188 IB_CM_APR_INVALID_COMM_ID, 189 IB_CM_APR_UNSUPPORTED, 189 IB_CM_APR_UNSUPPORTED, 190 IB_CM_APR_REJECT, 190 IB_CM_APR_REJECT, 191 IB_CM_APR_REDIRECT, 191 IB_CM_APR_REDIRECT, 192 IB_CM_APR_IS_CURRENT, 192 IB_CM_APR_IS_CURRENT, 193 IB_CM_APR_INVALID_QPN_EECN, 193 IB_CM_APR_INVALID_QPN_EECN, 194 IB_CM_APR_INVALID_LID, 194 IB_CM_APR_INVALID_LID, 195 IB_CM_APR_INVALID_GID, 195 IB_CM_APR_INVALID_GID, 196 IB_CM_APR_INVALID_FLOW_LABEL, 196 IB_CM_APR_INVALID_FLOW_LABEL, 197 IB_CM_APR_INVALID_TCLASS, 197 IB_CM_APR_INVALID_TCLASS, 198 IB_CM_APR_INVALID_HOP_LIMIT, 198 IB_CM_APR_INVALID_HOP_LIMIT, 199 IB_CM_APR_INVALID_PACKET_RATE, 199 IB_CM_APR_INVALID_PACKET_RATE, 200 IB_CM_APR_INVALID_SL 200 IB_CM_APR_INVALID_SL 201 }; 201 }; 202 202 203 struct ib_cm_apr_event_param { 203 struct ib_cm_apr_event_param { 204 enum ib_cm_apr_status ap_status; 204 enum ib_cm_apr_status ap_status; 205 void *apr_info; 205 void *apr_info; 206 u8 info_len; 206 u8 info_len; 207 }; 207 }; 208 208 209 struct ib_cm_sidr_req_event_param { 209 struct ib_cm_sidr_req_event_param { 210 struct ib_cm_id *listen_id; 210 struct ib_cm_id *listen_id; 211 __be64 service_id; 211 __be64 service_id; 212 212 213 /* 213 /* 214 * SGID attribute of the request. Curr 214 * SGID attribute of the request. Currently only 215 * useful for RoCE. 215 * useful for RoCE. 216 */ 216 */ 217 const struct ib_gid_attr *sgid_attr; 217 const struct ib_gid_attr *sgid_attr; 218 /* P_Key that was used by the GMP's BT 218 /* P_Key that was used by the GMP's BTH header */ 219 u16 bth_pkey; 219 u16 bth_pkey; 220 u8 port; 220 u8 port; 221 u16 pkey; 221 u16 pkey; 222 }; 222 }; 223 223 224 enum ib_cm_sidr_status { 224 enum ib_cm_sidr_status { 225 IB_SIDR_SUCCESS, 225 IB_SIDR_SUCCESS, 226 IB_SIDR_UNSUPPORTED, 226 IB_SIDR_UNSUPPORTED, 227 IB_SIDR_REJECT, 227 IB_SIDR_REJECT, 228 IB_SIDR_NO_QP, 228 IB_SIDR_NO_QP, 229 IB_SIDR_REDIRECT, 229 IB_SIDR_REDIRECT, 230 IB_SIDR_UNSUPPORTED_VERSION 230 IB_SIDR_UNSUPPORTED_VERSION 231 }; 231 }; 232 232 233 struct ib_cm_sidr_rep_event_param { 233 struct ib_cm_sidr_rep_event_param { 234 enum ib_cm_sidr_status status; 234 enum ib_cm_sidr_status status; 235 u32 qkey; 235 u32 qkey; 236 u32 qpn; 236 u32 qpn; 237 void *info; 237 void *info; 238 const struct ib_gid_attr *sgid_attr; 238 const struct ib_gid_attr *sgid_attr; 239 u8 info_len; 239 u8 info_len; 240 }; 240 }; 241 241 242 struct ib_cm_event { 242 struct ib_cm_event { 243 enum ib_cm_event_type event; 243 enum ib_cm_event_type event; 244 union { 244 union { 245 struct ib_cm_req_event_param 245 struct ib_cm_req_event_param req_rcvd; 246 struct ib_cm_rep_event_param 246 struct ib_cm_rep_event_param rep_rcvd; 247 /* No data for RTU received ev 247 /* No data for RTU received events. */ 248 struct ib_cm_rej_event_param 248 struct ib_cm_rej_event_param rej_rcvd; 249 struct ib_cm_mra_event_param 249 struct ib_cm_mra_event_param mra_rcvd; 250 struct ib_cm_lap_event_param 250 struct ib_cm_lap_event_param lap_rcvd; 251 struct ib_cm_apr_event_param 251 struct ib_cm_apr_event_param apr_rcvd; 252 /* No data for DREQ/DREP recei 252 /* No data for DREQ/DREP received events. */ 253 struct ib_cm_sidr_req_event_pa 253 struct ib_cm_sidr_req_event_param sidr_req_rcvd; 254 struct ib_cm_sidr_rep_event_pa 254 struct ib_cm_sidr_rep_event_param sidr_rep_rcvd; 255 enum ib_wc_status 255 enum ib_wc_status send_status; 256 } param; 256 } param; 257 257 258 void *private_data; 258 void *private_data; 259 }; 259 }; 260 260 261 #define CM_REQ_ATTR_ID cpu_to_be16(0x 261 #define CM_REQ_ATTR_ID cpu_to_be16(0x0010) 262 #define CM_MRA_ATTR_ID cpu_to_be16(0x 262 #define CM_MRA_ATTR_ID cpu_to_be16(0x0011) 263 #define CM_REJ_ATTR_ID cpu_to_be16(0x 263 #define CM_REJ_ATTR_ID cpu_to_be16(0x0012) 264 #define CM_REP_ATTR_ID cpu_to_be16(0x 264 #define CM_REP_ATTR_ID cpu_to_be16(0x0013) 265 #define CM_RTU_ATTR_ID cpu_to_be16(0x 265 #define CM_RTU_ATTR_ID cpu_to_be16(0x0014) 266 #define CM_DREQ_ATTR_ID cpu_to_be16(0x 266 #define CM_DREQ_ATTR_ID cpu_to_be16(0x0015) 267 #define CM_DREP_ATTR_ID cpu_to_be16(0x 267 #define CM_DREP_ATTR_ID cpu_to_be16(0x0016) 268 #define CM_SIDR_REQ_ATTR_ID cpu_to_be16(0x 268 #define CM_SIDR_REQ_ATTR_ID cpu_to_be16(0x0017) 269 #define CM_SIDR_REP_ATTR_ID cpu_to_be16(0x 269 #define CM_SIDR_REP_ATTR_ID cpu_to_be16(0x0018) 270 #define CM_LAP_ATTR_ID cpu_to_be16(0x 270 #define CM_LAP_ATTR_ID cpu_to_be16(0x0019) 271 #define CM_APR_ATTR_ID cpu_to_be16(0x 271 #define CM_APR_ATTR_ID cpu_to_be16(0x001A) 272 272 273 /** 273 /** 274 * ib_cm_handler - User-defined callback to pr 274 * ib_cm_handler - User-defined callback to process communication events. 275 * @cm_id: Communication identifier associated 275 * @cm_id: Communication identifier associated with the reported event. 276 * @event: Information about the communication 276 * @event: Information about the communication event. 277 * 277 * 278 * IB_CM_REQ_RECEIVED and IB_CM_SIDR_REQ_RECEI 278 * IB_CM_REQ_RECEIVED and IB_CM_SIDR_REQ_RECEIVED communication events 279 * generated as a result of listen requests re 279 * generated as a result of listen requests result in the allocation of a 280 * new @cm_id. The new @cm_id is returned to 280 * new @cm_id. The new @cm_id is returned to the user through this callback. 281 * Clients are responsible for destroying the 281 * Clients are responsible for destroying the new @cm_id. For peer-to-peer 282 * IB_CM_REQ_RECEIVED and all other events, th 282 * IB_CM_REQ_RECEIVED and all other events, the returned @cm_id corresponds 283 * to a user's existing communication identifi 283 * to a user's existing communication identifier. 284 * 284 * 285 * Users may not call ib_destroy_cm_id while i 285 * Users may not call ib_destroy_cm_id while in the context of this callback; 286 * however, returning a non-zero value instruc 286 * however, returning a non-zero value instructs the communication manager to 287 * destroy the @cm_id after the callback compl 287 * destroy the @cm_id after the callback completes. 288 */ 288 */ 289 typedef int (*ib_cm_handler)(struct ib_cm_id * 289 typedef int (*ib_cm_handler)(struct ib_cm_id *cm_id, 290 const struct ib_c 290 const struct ib_cm_event *event); 291 291 292 struct ib_cm_id { 292 struct ib_cm_id { 293 ib_cm_handler cm_handler; 293 ib_cm_handler cm_handler; 294 void *context; 294 void *context; 295 struct ib_device *device; 295 struct ib_device *device; 296 __be64 service_id; 296 __be64 service_id; >> 297 __be64 service_mask; 297 enum ib_cm_state state; 298 enum ib_cm_state state; /* internal CM/debug use */ 298 enum ib_cm_lap_state lap_state; 299 enum ib_cm_lap_state lap_state; /* internal CM/debug use */ 299 __be32 local_id; 300 __be32 local_id; 300 __be32 remote_id; 301 __be32 remote_id; 301 u32 remote_cm_qpn; 302 u32 remote_cm_qpn; /* 1 unless redirected */ 302 }; 303 }; 303 304 304 /** 305 /** 305 * ib_create_cm_id - Allocate a communication 306 * ib_create_cm_id - Allocate a communication identifier. 306 * @device: Device associated with the cm_id. 307 * @device: Device associated with the cm_id. All related communication will 307 * be associated with the specified device. 308 * be associated with the specified device. 308 * @cm_handler: Callback invoked to notify the 309 * @cm_handler: Callback invoked to notify the user of CM events. 309 * @context: User specified context associated 310 * @context: User specified context associated with the communication 310 * identifier. 311 * identifier. 311 * 312 * 312 * Communication identifiers are used to track 313 * Communication identifiers are used to track connection states, service 313 * ID resolution requests, and listen requests 314 * ID resolution requests, and listen requests. 314 */ 315 */ 315 struct ib_cm_id *ib_create_cm_id(struct ib_dev 316 struct ib_cm_id *ib_create_cm_id(struct ib_device *device, 316 ib_cm_handler 317 ib_cm_handler cm_handler, 317 void *context 318 void *context); 318 319 319 /** 320 /** 320 * ib_destroy_cm_id - Destroy a connection ide 321 * ib_destroy_cm_id - Destroy a connection identifier. 321 * @cm_id: Connection identifier to destroy. 322 * @cm_id: Connection identifier to destroy. 322 * 323 * 323 * This call blocks until the connection ident 324 * This call blocks until the connection identifier is destroyed. 324 */ 325 */ 325 void ib_destroy_cm_id(struct ib_cm_id *cm_id); 326 void ib_destroy_cm_id(struct ib_cm_id *cm_id); 326 327 327 #define IB_SERVICE_ID_AGN_MASK cpu_to_be64(0x 328 #define IB_SERVICE_ID_AGN_MASK cpu_to_be64(0xFF00000000000000ULL) 328 #define IB_CM_ASSIGN_SERVICE_ID cpu_to_be64(0x 329 #define IB_CM_ASSIGN_SERVICE_ID cpu_to_be64(0x0200000000000000ULL) 329 #define IB_CMA_SERVICE_ID cpu_to_be64(0x 330 #define IB_CMA_SERVICE_ID cpu_to_be64(0x0000000001000000ULL) 330 #define IB_CMA_SERVICE_ID_MASK cpu_to_be64(0x 331 #define IB_CMA_SERVICE_ID_MASK cpu_to_be64(0xFFFFFFFFFF000000ULL) 331 #define IB_SDP_SERVICE_ID cpu_to_be64(0x 332 #define IB_SDP_SERVICE_ID cpu_to_be64(0x0000000000010000ULL) 332 #define IB_SDP_SERVICE_ID_MASK cpu_to_be64(0x 333 #define IB_SDP_SERVICE_ID_MASK cpu_to_be64(0xFFFFFFFFFFFF0000ULL) 333 334 334 /** 335 /** 335 * ib_cm_listen - Initiates listening on the s 336 * ib_cm_listen - Initiates listening on the specified service ID for 336 * connection and service ID resolution requ 337 * connection and service ID resolution requests. 337 * @cm_id: Connection identifier associated wi 338 * @cm_id: Connection identifier associated with the listen request. 338 * @service_id: Service identifier matched aga 339 * @service_id: Service identifier matched against incoming connection 339 * and service ID resolution requests. The 340 * and service ID resolution requests. The service ID should be specified 340 * network-byte order. If set to IB_CM_ASSI 341 * network-byte order. If set to IB_CM_ASSIGN_SERVICE_ID, the CM will 341 * assign a service ID to the caller. 342 * assign a service ID to the caller. >> 343 * @service_mask: Mask applied to service ID used to listen across a >> 344 * range of service IDs. If set to 0, the service ID is matched >> 345 * exactly. This parameter is ignored if %service_id is set to >> 346 * IB_CM_ASSIGN_SERVICE_ID. 342 */ 347 */ 343 int ib_cm_listen(struct ib_cm_id *cm_id, __be6 !! 348 int ib_cm_listen(struct ib_cm_id *cm_id, __be64 service_id, >> 349 __be64 service_mask); 344 350 345 struct ib_cm_id *ib_cm_insert_listen(struct ib 351 struct ib_cm_id *ib_cm_insert_listen(struct ib_device *device, 346 ib_cm_han 352 ib_cm_handler cm_handler, 347 __be64 se 353 __be64 service_id); 348 354 349 struct ib_cm_req_param { 355 struct ib_cm_req_param { 350 struct sa_path_rec *primary_path; 356 struct sa_path_rec *primary_path; 351 struct sa_path_rec *primary_path_ << 352 struct sa_path_rec *primary_path_ << 353 struct sa_path_rec *alternate_pat 357 struct sa_path_rec *alternate_path; 354 const struct ib_gid_attr *ppath_sgid_a 358 const struct ib_gid_attr *ppath_sgid_attr; 355 __be64 service_id; 359 __be64 service_id; 356 u32 qp_num; 360 u32 qp_num; 357 enum ib_qp_type qp_type; 361 enum ib_qp_type qp_type; 358 u32 starting_psn; 362 u32 starting_psn; 359 const void *private_data; 363 const void *private_data; 360 u8 private_data_l 364 u8 private_data_len; 361 u8 responder_reso 365 u8 responder_resources; 362 u8 initiator_dept 366 u8 initiator_depth; 363 u8 remote_cm_resp 367 u8 remote_cm_response_timeout; 364 u8 flow_control; 368 u8 flow_control; 365 u8 local_cm_respo 369 u8 local_cm_response_timeout; 366 u8 retry_count; 370 u8 retry_count; 367 u8 rnr_retry_coun 371 u8 rnr_retry_count; 368 u8 max_cm_retries 372 u8 max_cm_retries; 369 u8 srq; 373 u8 srq; 370 struct rdma_ucm_ece ece; 374 struct rdma_ucm_ece ece; 371 }; 375 }; 372 376 373 /** 377 /** 374 * ib_send_cm_req - Sends a connection request 378 * ib_send_cm_req - Sends a connection request to the remote node. 375 * @cm_id: Connection identifier that will be 379 * @cm_id: Connection identifier that will be associated with the 376 * connection request. 380 * connection request. 377 * @param: Connection request information need 381 * @param: Connection request information needed to establish the 378 * connection. 382 * connection. 379 */ 383 */ 380 int ib_send_cm_req(struct ib_cm_id *cm_id, 384 int ib_send_cm_req(struct ib_cm_id *cm_id, 381 struct ib_cm_req_param *par 385 struct ib_cm_req_param *param); 382 386 383 struct ib_cm_rep_param { 387 struct ib_cm_rep_param { 384 u32 qp_num; 388 u32 qp_num; 385 u32 starting_psn; 389 u32 starting_psn; 386 const void *private_data; 390 const void *private_data; 387 u8 private_data_len; 391 u8 private_data_len; 388 u8 responder_resources; 392 u8 responder_resources; 389 u8 initiator_depth; 393 u8 initiator_depth; 390 u8 failover_accepted; 394 u8 failover_accepted; 391 u8 flow_control; 395 u8 flow_control; 392 u8 rnr_retry_count; 396 u8 rnr_retry_count; 393 u8 srq; 397 u8 srq; 394 struct rdma_ucm_ece ece; 398 struct rdma_ucm_ece ece; 395 }; 399 }; 396 400 397 /** 401 /** 398 * ib_send_cm_rep - Sends a connection reply i 402 * ib_send_cm_rep - Sends a connection reply in response to a connection 399 * request. 403 * request. 400 * @cm_id: Connection identifier that will be 404 * @cm_id: Connection identifier that will be associated with the 401 * connection request. 405 * connection request. 402 * @param: Connection reply information needed 406 * @param: Connection reply information needed to establish the 403 * connection. 407 * connection. 404 */ 408 */ 405 int ib_send_cm_rep(struct ib_cm_id *cm_id, 409 int ib_send_cm_rep(struct ib_cm_id *cm_id, 406 struct ib_cm_rep_param *par 410 struct ib_cm_rep_param *param); 407 411 408 /** 412 /** 409 * ib_send_cm_rtu - Sends a connection ready t 413 * ib_send_cm_rtu - Sends a connection ready to use message in response 410 * to a connection reply message. 414 * to a connection reply message. 411 * @cm_id: Connection identifier associated wi 415 * @cm_id: Connection identifier associated with the connection request. 412 * @private_data: Optional user-defined privat 416 * @private_data: Optional user-defined private data sent with the 413 * ready to use message. 417 * ready to use message. 414 * @private_data_len: Size of the private data 418 * @private_data_len: Size of the private data buffer, in bytes. 415 */ 419 */ 416 int ib_send_cm_rtu(struct ib_cm_id *cm_id, 420 int ib_send_cm_rtu(struct ib_cm_id *cm_id, 417 const void *private_data, 421 const void *private_data, 418 u8 private_data_len); 422 u8 private_data_len); 419 423 420 /** 424 /** 421 * ib_send_cm_dreq - Sends a disconnection req 425 * ib_send_cm_dreq - Sends a disconnection request for an existing 422 * connection. 426 * connection. 423 * @cm_id: Connection identifier associated wi 427 * @cm_id: Connection identifier associated with the connection being 424 * released. 428 * released. 425 * @private_data: Optional user-defined privat 429 * @private_data: Optional user-defined private data sent with the 426 * disconnection request message. 430 * disconnection request message. 427 * @private_data_len: Size of the private data 431 * @private_data_len: Size of the private data buffer, in bytes. 428 */ 432 */ 429 int ib_send_cm_dreq(struct ib_cm_id *cm_id, 433 int ib_send_cm_dreq(struct ib_cm_id *cm_id, 430 const void *private_data, 434 const void *private_data, 431 u8 private_data_len); 435 u8 private_data_len); 432 436 433 /** 437 /** 434 * ib_send_cm_drep - Sends a disconnection rep 438 * ib_send_cm_drep - Sends a disconnection reply to a disconnection request. 435 * @cm_id: Connection identifier associated wi 439 * @cm_id: Connection identifier associated with the connection being 436 * released. 440 * released. 437 * @private_data: Optional user-defined privat 441 * @private_data: Optional user-defined private data sent with the 438 * disconnection reply message. 442 * disconnection reply message. 439 * @private_data_len: Size of the private data 443 * @private_data_len: Size of the private data buffer, in bytes. 440 * 444 * 441 * If the cm_id is in the correct state, the C 445 * If the cm_id is in the correct state, the CM will transition the connection 442 * to the timewait state, even if an error occ 446 * to the timewait state, even if an error occurs sending the DREP message. 443 */ 447 */ 444 int ib_send_cm_drep(struct ib_cm_id *cm_id, 448 int ib_send_cm_drep(struct ib_cm_id *cm_id, 445 const void *private_data, 449 const void *private_data, 446 u8 private_data_len); 450 u8 private_data_len); 447 451 448 /** 452 /** 449 * ib_cm_notify - Notifies the CM of an event 453 * ib_cm_notify - Notifies the CM of an event reported to the consumer. 450 * @cm_id: Connection identifier to transition 454 * @cm_id: Connection identifier to transition to established. 451 * @event: Type of event. 455 * @event: Type of event. 452 * 456 * 453 * This routine should be invoked by users to 457 * This routine should be invoked by users to notify the CM of relevant 454 * communication events. Events that should b 458 * communication events. Events that should be reported to the CM and 455 * when to report them are: 459 * when to report them are: 456 * 460 * 457 * IB_EVENT_COMM_EST - Used when a message is 461 * IB_EVENT_COMM_EST - Used when a message is received on a connected 458 * QP before an RTU has been received. 462 * QP before an RTU has been received. 459 * IB_EVENT_PATH_MIG - Notifies the CM that th 463 * IB_EVENT_PATH_MIG - Notifies the CM that the connection has failed over 460 * to the alternate path. 464 * to the alternate path. 461 */ 465 */ 462 int ib_cm_notify(struct ib_cm_id *cm_id, enum 466 int ib_cm_notify(struct ib_cm_id *cm_id, enum ib_event_type event); 463 467 464 /** 468 /** 465 * ib_send_cm_rej - Sends a connection rejecti 469 * ib_send_cm_rej - Sends a connection rejection message to the 466 * remote node. 470 * remote node. 467 * @cm_id: Connection identifier associated wi 471 * @cm_id: Connection identifier associated with the connection being 468 * rejected. 472 * rejected. 469 * @reason: Reason for the connection request 473 * @reason: Reason for the connection request rejection. 470 * @ari: Optional additional rejection informa 474 * @ari: Optional additional rejection information. 471 * @ari_length: Size of the additional rejecti 475 * @ari_length: Size of the additional rejection information, in bytes. 472 * @private_data: Optional user-defined privat 476 * @private_data: Optional user-defined private data sent with the 473 * rejection message. 477 * rejection message. 474 * @private_data_len: Size of the private data 478 * @private_data_len: Size of the private data buffer, in bytes. 475 */ 479 */ 476 int ib_send_cm_rej(struct ib_cm_id *cm_id, 480 int ib_send_cm_rej(struct ib_cm_id *cm_id, 477 enum ib_cm_rej_reason reaso 481 enum ib_cm_rej_reason reason, 478 void *ari, 482 void *ari, 479 u8 ari_length, 483 u8 ari_length, 480 const void *private_data, 484 const void *private_data, 481 u8 private_data_len); 485 u8 private_data_len); 482 486 483 #define IB_CM_MRA_FLAG_DELAY 0x80 /* Send MRA 487 #define IB_CM_MRA_FLAG_DELAY 0x80 /* Send MRA only after a duplicate msg */ 484 488 485 /** 489 /** 486 * ib_send_cm_mra - Sends a message receipt ac 490 * ib_send_cm_mra - Sends a message receipt acknowledgement to a connection 487 * message. 491 * message. 488 * @cm_id: Connection identifier associated wi 492 * @cm_id: Connection identifier associated with the connection message. 489 * @service_timeout: The lower 5-bits specify 493 * @service_timeout: The lower 5-bits specify the maximum time required for 490 * the sender to reply to the connection mes 494 * the sender to reply to the connection message. The upper 3-bits 491 * specify additional control flags. 495 * specify additional control flags. 492 * @private_data: Optional user-defined privat 496 * @private_data: Optional user-defined private data sent with the 493 * message receipt acknowledgement. 497 * message receipt acknowledgement. 494 * @private_data_len: Size of the private data 498 * @private_data_len: Size of the private data buffer, in bytes. 495 */ 499 */ 496 int ib_send_cm_mra(struct ib_cm_id *cm_id, 500 int ib_send_cm_mra(struct ib_cm_id *cm_id, 497 u8 service_timeout, 501 u8 service_timeout, 498 const void *private_data, 502 const void *private_data, 499 u8 private_data_len); 503 u8 private_data_len); 500 504 501 /** 505 /** 502 * ib_cm_init_qp_attr - Initializes the QP att 506 * ib_cm_init_qp_attr - Initializes the QP attributes for use in transitioning 503 * to a specified QP state. 507 * to a specified QP state. 504 * @cm_id: Communication identifier associated 508 * @cm_id: Communication identifier associated with the QP attributes to 505 * initialize. 509 * initialize. 506 * @qp_attr: On input, specifies the desired Q 510 * @qp_attr: On input, specifies the desired QP state. On output, the 507 * mandatory and desired optional attributes 511 * mandatory and desired optional attributes will be set in order to 508 * modify the QP to the specified state. 512 * modify the QP to the specified state. 509 * @qp_attr_mask: The QP attribute mask that m 513 * @qp_attr_mask: The QP attribute mask that may be used to transition the 510 * QP to the specified state. 514 * QP to the specified state. 511 * 515 * 512 * Users must set the @qp_attr->qp_state to th 516 * Users must set the @qp_attr->qp_state to the desired QP state. This call 513 * will set all required attributes for the gi 517 * will set all required attributes for the given transition, along with 514 * known optional attributes. Users may overr 518 * known optional attributes. Users may override the attributes returned from 515 * this call before calling ib_modify_qp. 519 * this call before calling ib_modify_qp. 516 */ 520 */ 517 int ib_cm_init_qp_attr(struct ib_cm_id *cm_id, 521 int ib_cm_init_qp_attr(struct ib_cm_id *cm_id, 518 struct ib_qp_attr *qp_a 522 struct ib_qp_attr *qp_attr, 519 int *qp_attr_mask); 523 int *qp_attr_mask); 520 524 521 struct ib_cm_sidr_req_param { 525 struct ib_cm_sidr_req_param { 522 struct sa_path_rec *path; 526 struct sa_path_rec *path; 523 const struct ib_gid_attr *sgid_attr; 527 const struct ib_gid_attr *sgid_attr; 524 __be64 service_id; 528 __be64 service_id; 525 unsigned long timeout_ms; 529 unsigned long timeout_ms; 526 const void *private_data; 530 const void *private_data; 527 u8 private_data_l 531 u8 private_data_len; 528 u8 max_cm_retries 532 u8 max_cm_retries; 529 }; 533 }; 530 534 531 /** 535 /** 532 * ib_send_cm_sidr_req - Sends a service ID re 536 * ib_send_cm_sidr_req - Sends a service ID resolution request to the 533 * remote node. 537 * remote node. 534 * @cm_id: Communication identifier that will 538 * @cm_id: Communication identifier that will be associated with the 535 * service ID resolution request. 539 * service ID resolution request. 536 * @param: Service ID resolution request infor 540 * @param: Service ID resolution request information. 537 */ 541 */ 538 int ib_send_cm_sidr_req(struct ib_cm_id *cm_id 542 int ib_send_cm_sidr_req(struct ib_cm_id *cm_id, 539 struct ib_cm_sidr_req_ 543 struct ib_cm_sidr_req_param *param); 540 544 541 struct ib_cm_sidr_rep_param { 545 struct ib_cm_sidr_rep_param { 542 u32 qp_num; 546 u32 qp_num; 543 u32 qkey; 547 u32 qkey; 544 enum ib_cm_sidr_status status; 548 enum ib_cm_sidr_status status; 545 const void *info; 549 const void *info; 546 u8 info_length; 550 u8 info_length; 547 const void *private_data; 551 const void *private_data; 548 u8 private_data_l 552 u8 private_data_len; 549 struct rdma_ucm_ece ece; 553 struct rdma_ucm_ece ece; 550 }; 554 }; 551 555 552 /** 556 /** 553 * ib_send_cm_sidr_rep - Sends a service ID re 557 * ib_send_cm_sidr_rep - Sends a service ID resolution reply to the 554 * remote node. 558 * remote node. 555 * @cm_id: Communication identifier associated 559 * @cm_id: Communication identifier associated with the received service ID 556 * resolution request. 560 * resolution request. 557 * @param: Service ID resolution reply informa 561 * @param: Service ID resolution reply information. 558 */ 562 */ 559 int ib_send_cm_sidr_rep(struct ib_cm_id *cm_id 563 int ib_send_cm_sidr_rep(struct ib_cm_id *cm_id, 560 struct ib_cm_sidr_rep_ 564 struct ib_cm_sidr_rep_param *param); 561 565 562 /** 566 /** 563 * ibcm_reject_msg - return a pointer to a rej 567 * ibcm_reject_msg - return a pointer to a reject message string. 564 * @reason: Value returned in the REJECT event 568 * @reason: Value returned in the REJECT event status field. 565 */ 569 */ 566 const char *__attribute_const__ ibcm_reject_ms 570 const char *__attribute_const__ ibcm_reject_msg(int reason); 567 571 568 #endif /* IB_CM_H */ 572 #endif /* IB_CM_H */ 569 573
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.