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