blob: c10f4b5ea8ab5298beaba7070f588408532d9f61 [file] [log] [blame]
Hal Rosenstockc3e01642005-07-27 11:45:39 -07001/*
Sean Hefty07d357d2005-10-17 15:37:43 -07002 * Copyright (c) 2004, 2005 Intel Corporation. All rights reserved.
Hal Rosenstockc3e01642005-07-27 11:45:39 -07003 * 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 Rosenstockc3e01642005-07-27 11:45:39 -070034 */
35#if !defined(IB_CM_H)
36#define IB_CM_H
37
Roland Dreiera4d61e82005-08-25 13:40:04 -070038#include <rdma/ib_mad.h>
39#include <rdma/ib_sa.h>
Hal Rosenstockc3e01642005-07-27 11:45:39 -070040
Sean Heftyc89d1be2011-12-06 21:13:10 +000041/* ib_cm and ib_user_cm modules share /sys/class/infiniband_cm */
42extern struct class cm_class;
43
Hal Rosenstockc3e01642005-07-27 11:45:39 -070044enum 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
63enum ib_cm_lap_state {
Sean Heftye1444b52006-11-28 14:57:13 -080064 IB_CM_LAP_UNINIT,
Hal Rosenstockc3e01642005-07-27 11:45:39 -070065 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
72enum 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
93enum 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 Hefty6e61d042006-06-17 20:37:28 -0700107 IB_CM_SIDR_REP_INFO_LENGTH = 72,
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700108};
109
110struct ib_cm_id;
111
112struct ib_cm_req_event_param {
113 struct ib_cm_id *listen_id;
Haggai Eran24cad9a2015-07-30 17:50:21 +0300114
115 /* P_Key that was used by the GMP's BTH header */
116 u16 bth_pkey;
117
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700118 u8 port;
119
Dasaratharaman Chandramoulic2f8fc42017-04-27 19:05:58 -0400120 struct sa_path_rec *primary_path;
121 struct sa_path_rec *alternate_path;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700122
Parav Panditcee10432018-07-16 11:50:11 +0300123 /*
124 * SGID attribute of the primary path. Currently only
125 * useful for RoCE. Alternate path GID attributes
126 * are not yet supported.
127 */
128 const struct ib_gid_attr *ppath_sgid_attr;
129
Sean Hefty97f52eb2005-08-13 21:05:57 -0700130 __be64 remote_ca_guid;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700131 u32 remote_qkey;
132 u32 remote_qpn;
133 enum ib_qp_type qp_type;
134
135 u32 starting_psn;
136 u8 responder_resources;
137 u8 initiator_depth;
138 unsigned int local_cm_response_timeout:5;
139 unsigned int flow_control:1;
140 unsigned int remote_cm_response_timeout:5;
141 unsigned int retry_count:3;
142 unsigned int rnr_retry_count:3;
143 unsigned int srq:1;
144};
145
146struct ib_cm_rep_event_param {
Sean Hefty97f52eb2005-08-13 21:05:57 -0700147 __be64 remote_ca_guid;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700148 u32 remote_qkey;
149 u32 remote_qpn;
150 u32 starting_psn;
151 u8 responder_resources;
152 u8 initiator_depth;
153 unsigned int target_ack_delay:5;
154 unsigned int failover_accepted:2;
155 unsigned int flow_control:1;
156 unsigned int rnr_retry_count:3;
157 unsigned int srq:1;
158};
159
160enum ib_cm_rej_reason {
Sean Hefty97f52eb2005-08-13 21:05:57 -0700161 IB_CM_REJ_NO_QP = 1,
162 IB_CM_REJ_NO_EEC = 2,
163 IB_CM_REJ_NO_RESOURCES = 3,
164 IB_CM_REJ_TIMEOUT = 4,
165 IB_CM_REJ_UNSUPPORTED = 5,
166 IB_CM_REJ_INVALID_COMM_ID = 6,
167 IB_CM_REJ_INVALID_COMM_INSTANCE = 7,
168 IB_CM_REJ_INVALID_SERVICE_ID = 8,
169 IB_CM_REJ_INVALID_TRANSPORT_TYPE = 9,
170 IB_CM_REJ_STALE_CONN = 10,
171 IB_CM_REJ_RDC_NOT_EXIST = 11,
172 IB_CM_REJ_INVALID_GID = 12,
173 IB_CM_REJ_INVALID_LID = 13,
174 IB_CM_REJ_INVALID_SL = 14,
175 IB_CM_REJ_INVALID_TRAFFIC_CLASS = 15,
176 IB_CM_REJ_INVALID_HOP_LIMIT = 16,
177 IB_CM_REJ_INVALID_PACKET_RATE = 17,
178 IB_CM_REJ_INVALID_ALT_GID = 18,
179 IB_CM_REJ_INVALID_ALT_LID = 19,
180 IB_CM_REJ_INVALID_ALT_SL = 20,
181 IB_CM_REJ_INVALID_ALT_TRAFFIC_CLASS = 21,
182 IB_CM_REJ_INVALID_ALT_HOP_LIMIT = 22,
183 IB_CM_REJ_INVALID_ALT_PACKET_RATE = 23,
184 IB_CM_REJ_PORT_CM_REDIRECT = 24,
185 IB_CM_REJ_PORT_REDIRECT = 25,
186 IB_CM_REJ_INVALID_MTU = 26,
187 IB_CM_REJ_INSUFFICIENT_RESP_RESOURCES = 27,
188 IB_CM_REJ_CONSUMER_DEFINED = 28,
189 IB_CM_REJ_INVALID_RNR_RETRY = 29,
190 IB_CM_REJ_DUPLICATE_LOCAL_COMM_ID = 30,
191 IB_CM_REJ_INVALID_CLASS_VERSION = 31,
192 IB_CM_REJ_INVALID_FLOW_LABEL = 32,
193 IB_CM_REJ_INVALID_ALT_FLOW_LABEL = 33
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700194};
195
196struct ib_cm_rej_event_param {
197 enum ib_cm_rej_reason reason;
198 void *ari;
199 u8 ari_length;
200};
201
202struct ib_cm_mra_event_param {
203 u8 service_timeout;
204};
205
206struct ib_cm_lap_event_param {
Dasaratharaman Chandramoulic2f8fc42017-04-27 19:05:58 -0400207 struct sa_path_rec *alternate_path;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700208};
209
210enum ib_cm_apr_status {
211 IB_CM_APR_SUCCESS,
212 IB_CM_APR_INVALID_COMM_ID,
213 IB_CM_APR_UNSUPPORTED,
214 IB_CM_APR_REJECT,
215 IB_CM_APR_REDIRECT,
216 IB_CM_APR_IS_CURRENT,
217 IB_CM_APR_INVALID_QPN_EECN,
218 IB_CM_APR_INVALID_LID,
219 IB_CM_APR_INVALID_GID,
220 IB_CM_APR_INVALID_FLOW_LABEL,
221 IB_CM_APR_INVALID_TCLASS,
222 IB_CM_APR_INVALID_HOP_LIMIT,
223 IB_CM_APR_INVALID_PACKET_RATE,
224 IB_CM_APR_INVALID_SL
225};
226
227struct ib_cm_apr_event_param {
228 enum ib_cm_apr_status ap_status;
229 void *apr_info;
230 u8 info_len;
231};
232
233struct ib_cm_sidr_req_event_param {
234 struct ib_cm_id *listen_id;
Haggai Eran15865e7d2015-07-30 17:50:17 +0300235 __be64 service_id;
Parav Panditcee10432018-07-16 11:50:11 +0300236
237 /*
238 * SGID attribute of the request. Currently only
239 * useful for RoCE.
240 */
241 const struct ib_gid_attr *sgid_attr;
Haggai Eran24cad9a2015-07-30 17:50:21 +0300242 /* P_Key that was used by the GMP's BTH header */
243 u16 bth_pkey;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700244 u8 port;
Sean Hefty97f52eb2005-08-13 21:05:57 -0700245 u16 pkey;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700246};
247
248enum ib_cm_sidr_status {
249 IB_SIDR_SUCCESS,
250 IB_SIDR_UNSUPPORTED,
251 IB_SIDR_REJECT,
252 IB_SIDR_NO_QP,
253 IB_SIDR_REDIRECT,
254 IB_SIDR_UNSUPPORTED_VERSION
255};
256
257struct ib_cm_sidr_rep_event_param {
258 enum ib_cm_sidr_status status;
259 u32 qkey;
260 u32 qpn;
261 void *info;
Parav Pandit815d4562018-06-19 10:59:18 +0300262 const struct ib_gid_attr *sgid_attr;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700263 u8 info_len;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700264};
265
266struct ib_cm_event {
267 enum ib_cm_event_type event;
268 union {
269 struct ib_cm_req_event_param req_rcvd;
270 struct ib_cm_rep_event_param rep_rcvd;
271 /* No data for RTU received events. */
272 struct ib_cm_rej_event_param rej_rcvd;
273 struct ib_cm_mra_event_param mra_rcvd;
274 struct ib_cm_lap_event_param lap_rcvd;
275 struct ib_cm_apr_event_param apr_rcvd;
276 /* No data for DREQ/DREP received events. */
277 struct ib_cm_sidr_req_event_param sidr_req_rcvd;
278 struct ib_cm_sidr_rep_event_param sidr_rep_rcvd;
279 enum ib_wc_status send_status;
280 } param;
281
282 void *private_data;
283};
284
Jack Morgenstein3045f092012-06-19 11:21:39 +0300285#define CM_REQ_ATTR_ID cpu_to_be16(0x0010)
286#define CM_MRA_ATTR_ID cpu_to_be16(0x0011)
287#define CM_REJ_ATTR_ID cpu_to_be16(0x0012)
288#define CM_REP_ATTR_ID cpu_to_be16(0x0013)
289#define CM_RTU_ATTR_ID cpu_to_be16(0x0014)
290#define CM_DREQ_ATTR_ID cpu_to_be16(0x0015)
291#define CM_DREP_ATTR_ID cpu_to_be16(0x0016)
292#define CM_SIDR_REQ_ATTR_ID cpu_to_be16(0x0017)
293#define CM_SIDR_REP_ATTR_ID cpu_to_be16(0x0018)
294#define CM_LAP_ATTR_ID cpu_to_be16(0x0019)
295#define CM_APR_ATTR_ID cpu_to_be16(0x001A)
296
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700297/**
298 * ib_cm_handler - User-defined callback to process communication events.
299 * @cm_id: Communication identifier associated with the reported event.
300 * @event: Information about the communication event.
301 *
302 * IB_CM_REQ_RECEIVED and IB_CM_SIDR_REQ_RECEIVED communication events
303 * generated as a result of listen requests result in the allocation of a
304 * new @cm_id. The new @cm_id is returned to the user through this callback.
305 * Clients are responsible for destroying the new @cm_id. For peer-to-peer
306 * IB_CM_REQ_RECEIVED and all other events, the returned @cm_id corresponds
307 * to a user's existing communication identifier.
308 *
309 * Users may not call ib_destroy_cm_id while in the context of this callback;
310 * however, returning a non-zero value instructs the communication manager to
311 * destroy the @cm_id after the callback completes.
312 */
313typedef int (*ib_cm_handler)(struct ib_cm_id *cm_id,
Parav Pandite7ff98a2018-07-29 11:53:11 +0300314 const struct ib_cm_event *event);
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700315
316struct ib_cm_id {
317 ib_cm_handler cm_handler;
318 void *context;
Sean Hefty07d357d2005-10-17 15:37:43 -0700319 struct ib_device *device;
Sean Hefty97f52eb2005-08-13 21:05:57 -0700320 __be64 service_id;
321 __be64 service_mask;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700322 enum ib_cm_state state; /* internal CM/debug use */
323 enum ib_cm_lap_state lap_state; /* internal CM/debug use */
Sean Hefty97f52eb2005-08-13 21:05:57 -0700324 __be32 local_id;
325 __be32 remote_id;
John Kingman354ba392005-09-09 18:23:32 -0700326 u32 remote_cm_qpn; /* 1 unless redirected */
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700327};
328
329/**
330 * ib_create_cm_id - Allocate a communication identifier.
Sean Hefty07d357d2005-10-17 15:37:43 -0700331 * @device: Device associated with the cm_id. All related communication will
332 * be associated with the specified device.
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700333 * @cm_handler: Callback invoked to notify the user of CM events.
334 * @context: User specified context associated with the communication
335 * identifier.
336 *
337 * Communication identifiers are used to track connection states, service
338 * ID resolution requests, and listen requests.
339 */
Sean Hefty07d357d2005-10-17 15:37:43 -0700340struct ib_cm_id *ib_create_cm_id(struct ib_device *device,
341 ib_cm_handler cm_handler,
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700342 void *context);
343
344/**
345 * ib_destroy_cm_id - Destroy a connection identifier.
346 * @cm_id: Connection identifier to destroy.
347 *
348 * This call blocks until the connection identifier is destroyed.
349 */
350void ib_destroy_cm_id(struct ib_cm_id *cm_id);
351
Harvey Harrison9c3da092009-01-17 17:11:57 -0800352#define IB_SERVICE_ID_AGN_MASK cpu_to_be64(0xFF00000000000000ULL)
353#define IB_CM_ASSIGN_SERVICE_ID cpu_to_be64(0x0200000000000000ULL)
354#define IB_CMA_SERVICE_ID cpu_to_be64(0x0000000001000000ULL)
355#define IB_CMA_SERVICE_ID_MASK cpu_to_be64(0xFFFFFFFFFF000000ULL)
356#define IB_SDP_SERVICE_ID cpu_to_be64(0x0000000000010000ULL)
357#define IB_SDP_SERVICE_ID_MASK cpu_to_be64(0xFFFFFFFFFFFF0000ULL)
Sean Hefty6e61d042006-06-17 20:37:28 -0700358
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700359/**
360 * ib_cm_listen - Initiates listening on the specified service ID for
361 * connection and service ID resolution requests.
362 * @cm_id: Connection identifier associated with the listen request.
363 * @service_id: Service identifier matched against incoming connection
364 * and service ID resolution requests. The service ID should be specified
365 * network-byte order. If set to IB_CM_ASSIGN_SERVICE_ID, the CM will
366 * assign a service ID to the caller.
367 * @service_mask: Mask applied to service ID used to listen across a
368 * range of service IDs. If set to 0, the service ID is matched
369 * exactly. This parameter is ignored if %service_id is set to
370 * IB_CM_ASSIGN_SERVICE_ID.
371 */
Haggai Eran73fec7f2015-07-30 17:50:26 +0300372int ib_cm_listen(struct ib_cm_id *cm_id, __be64 service_id,
373 __be64 service_mask);
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700374
Haggai Eran067b1712015-07-30 17:50:18 +0300375struct ib_cm_id *ib_cm_insert_listen(struct ib_device *device,
376 ib_cm_handler cm_handler,
377 __be64 service_id);
378
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700379struct ib_cm_req_param {
Dasaratharaman Chandramoulic2f8fc42017-04-27 19:05:58 -0400380 struct sa_path_rec *primary_path;
381 struct sa_path_rec *alternate_path;
Parav Pandit815d4562018-06-19 10:59:18 +0300382 const struct ib_gid_attr *ppath_sgid_attr;
Sean Hefty97f52eb2005-08-13 21:05:57 -0700383 __be64 service_id;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700384 u32 qp_num;
385 enum ib_qp_type qp_type;
386 u32 starting_psn;
387 const void *private_data;
388 u8 private_data_len;
389 u8 peer_to_peer;
390 u8 responder_resources;
391 u8 initiator_depth;
392 u8 remote_cm_response_timeout;
393 u8 flow_control;
394 u8 local_cm_response_timeout;
395 u8 retry_count;
396 u8 rnr_retry_count;
397 u8 max_cm_retries;
398 u8 srq;
399};
400
401/**
402 * ib_send_cm_req - Sends a connection request to the remote node.
403 * @cm_id: Connection identifier that will be associated with the
404 * connection request.
405 * @param: Connection request information needed to establish the
406 * connection.
407 */
408int ib_send_cm_req(struct ib_cm_id *cm_id,
409 struct ib_cm_req_param *param);
410
411struct ib_cm_rep_param {
412 u32 qp_num;
413 u32 starting_psn;
414 const void *private_data;
415 u8 private_data_len;
416 u8 responder_resources;
417 u8 initiator_depth;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700418 u8 failover_accepted;
419 u8 flow_control;
420 u8 rnr_retry_count;
421 u8 srq;
422};
423
424/**
425 * ib_send_cm_rep - Sends a connection reply in response to a connection
426 * request.
427 * @cm_id: Connection identifier that will be associated with the
428 * connection request.
429 * @param: Connection reply information needed to establish the
430 * connection.
431 */
432int ib_send_cm_rep(struct ib_cm_id *cm_id,
433 struct ib_cm_rep_param *param);
434
435/**
436 * ib_send_cm_rtu - Sends a connection ready to use message in response
437 * to a connection reply message.
438 * @cm_id: Connection identifier associated with the connection request.
439 * @private_data: Optional user-defined private data sent with the
440 * ready to use message.
441 * @private_data_len: Size of the private data buffer, in bytes.
442 */
443int ib_send_cm_rtu(struct ib_cm_id *cm_id,
444 const void *private_data,
445 u8 private_data_len);
446
447/**
448 * ib_send_cm_dreq - Sends a disconnection request for an existing
449 * connection.
450 * @cm_id: Connection identifier associated with the connection being
451 * released.
452 * @private_data: Optional user-defined private data sent with the
453 * disconnection request message.
454 * @private_data_len: Size of the private data buffer, in bytes.
455 */
456int ib_send_cm_dreq(struct ib_cm_id *cm_id,
457 const void *private_data,
458 u8 private_data_len);
459
460/**
461 * ib_send_cm_drep - Sends a disconnection reply to a disconnection request.
462 * @cm_id: Connection identifier associated with the connection being
463 * released.
464 * @private_data: Optional user-defined private data sent with the
465 * disconnection reply message.
466 * @private_data_len: Size of the private data buffer, in bytes.
467 *
468 * If the cm_id is in the correct state, the CM will transition the connection
469 * to the timewait state, even if an error occurs sending the DREP message.
470 */
471int ib_send_cm_drep(struct ib_cm_id *cm_id,
472 const void *private_data,
473 u8 private_data_len);
474
475/**
Sean Heftye1444b52006-11-28 14:57:13 -0800476 * ib_cm_notify - Notifies the CM of an event reported to the consumer.
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700477 * @cm_id: Connection identifier to transition to established.
Sean Heftye1444b52006-11-28 14:57:13 -0800478 * @event: Type of event.
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700479 *
Sean Heftye1444b52006-11-28 14:57:13 -0800480 * This routine should be invoked by users to notify the CM of relevant
481 * communication events. Events that should be reported to the CM and
482 * when to report them are:
483 *
484 * IB_EVENT_COMM_EST - Used when a message is received on a connected
485 * QP before an RTU has been received.
486 * IB_EVENT_PATH_MIG - Notifies the CM that the connection has failed over
487 * to the alternate path.
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700488 */
Sean Heftye1444b52006-11-28 14:57:13 -0800489int ib_cm_notify(struct ib_cm_id *cm_id, enum ib_event_type event);
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700490
491/**
492 * ib_send_cm_rej - Sends a connection rejection message to the
493 * remote node.
494 * @cm_id: Connection identifier associated with the connection being
495 * rejected.
496 * @reason: Reason for the connection request rejection.
497 * @ari: Optional additional rejection information.
498 * @ari_length: Size of the additional rejection information, in bytes.
499 * @private_data: Optional user-defined private data sent with the
500 * rejection message.
501 * @private_data_len: Size of the private data buffer, in bytes.
502 */
503int ib_send_cm_rej(struct ib_cm_id *cm_id,
504 enum ib_cm_rej_reason reason,
505 void *ari,
506 u8 ari_length,
507 const void *private_data,
508 u8 private_data_len);
509
Sean Heftyde98b692007-08-01 13:49:53 -0700510#define IB_CM_MRA_FLAG_DELAY 0x80 /* Send MRA only after a duplicate msg */
511
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700512/**
513 * ib_send_cm_mra - Sends a message receipt acknowledgement to a connection
514 * message.
515 * @cm_id: Connection identifier associated with the connection message.
Sean Heftyde98b692007-08-01 13:49:53 -0700516 * @service_timeout: The lower 5-bits specify the maximum time required for
Anand Gadiyarfd589a82009-07-16 17:13:03 +0200517 * the sender to reply to the connection message. The upper 3-bits
Sean Heftyde98b692007-08-01 13:49:53 -0700518 * specify additional control flags.
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700519 * @private_data: Optional user-defined private data sent with the
520 * message receipt acknowledgement.
521 * @private_data_len: Size of the private data buffer, in bytes.
522 */
523int ib_send_cm_mra(struct ib_cm_id *cm_id,
524 u8 service_timeout,
525 const void *private_data,
526 u8 private_data_len);
527
528/**
529 * ib_send_cm_lap - Sends a load alternate path request.
530 * @cm_id: Connection identifier associated with the load alternate path
531 * message.
532 * @alternate_path: A path record that identifies the alternate path to
533 * load.
534 * @private_data: Optional user-defined private data sent with the
535 * load alternate path message.
536 * @private_data_len: Size of the private data buffer, in bytes.
537 */
538int ib_send_cm_lap(struct ib_cm_id *cm_id,
Dasaratharaman Chandramoulic2f8fc42017-04-27 19:05:58 -0400539 struct sa_path_rec *alternate_path,
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700540 const void *private_data,
541 u8 private_data_len);
542
543/**
544 * ib_cm_init_qp_attr - Initializes the QP attributes for use in transitioning
545 * to a specified QP state.
546 * @cm_id: Communication identifier associated with the QP attributes to
547 * initialize.
548 * @qp_attr: On input, specifies the desired QP state. On output, the
549 * mandatory and desired optional attributes will be set in order to
550 * modify the QP to the specified state.
551 * @qp_attr_mask: The QP attribute mask that may be used to transition the
552 * QP to the specified state.
553 *
554 * Users must set the @qp_attr->qp_state to the desired QP state. This call
555 * will set all required attributes for the given transition, along with
556 * known optional attributes. Users may override the attributes returned from
557 * this call before calling ib_modify_qp.
558 */
559int ib_cm_init_qp_attr(struct ib_cm_id *cm_id,
560 struct ib_qp_attr *qp_attr,
561 int *qp_attr_mask);
562
563/**
564 * ib_send_cm_apr - Sends an alternate path response message in response to
565 * a load alternate path request.
566 * @cm_id: Connection identifier associated with the alternate path response.
567 * @status: Reply status sent with the alternate path response.
568 * @info: Optional additional information sent with the alternate path
569 * response.
570 * @info_length: Size of the additional information, in bytes.
571 * @private_data: Optional user-defined private data sent with the
572 * alternate path response message.
573 * @private_data_len: Size of the private data buffer, in bytes.
574 */
575int ib_send_cm_apr(struct ib_cm_id *cm_id,
576 enum ib_cm_apr_status status,
577 void *info,
578 u8 info_length,
579 const void *private_data,
580 u8 private_data_len);
581
582struct ib_cm_sidr_req_param {
Dasaratharaman Chandramoulic2f8fc42017-04-27 19:05:58 -0400583 struct sa_path_rec *path;
Parav Pandit815d4562018-06-19 10:59:18 +0300584 const struct ib_gid_attr *sgid_attr;
Sean Hefty97f52eb2005-08-13 21:05:57 -0700585 __be64 service_id;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700586 int timeout_ms;
587 const void *private_data;
588 u8 private_data_len;
589 u8 max_cm_retries;
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700590};
591
592/**
593 * ib_send_cm_sidr_req - Sends a service ID resolution request to the
594 * remote node.
595 * @cm_id: Communication identifier that will be associated with the
596 * service ID resolution request.
597 * @param: Service ID resolution request information.
598 */
599int ib_send_cm_sidr_req(struct ib_cm_id *cm_id,
600 struct ib_cm_sidr_req_param *param);
601
602struct ib_cm_sidr_rep_param {
603 u32 qp_num;
604 u32 qkey;
605 enum ib_cm_sidr_status status;
606 const void *info;
607 u8 info_length;
608 const void *private_data;
609 u8 private_data_len;
610};
611
612/**
Sean Hefty75af9082006-06-17 20:37:39 -0700613 * ib_send_cm_sidr_rep - Sends a service ID resolution reply to the
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700614 * remote node.
615 * @cm_id: Communication identifier associated with the received service ID
616 * resolution request.
617 * @param: Service ID resolution reply information.
618 */
619int ib_send_cm_sidr_rep(struct ib_cm_id *cm_id,
620 struct ib_cm_sidr_rep_param *param);
621
Steve Wise77a5db12016-10-26 12:36:40 -0700622/**
623 * ibcm_reject_msg - return a pointer to a reject message string.
624 * @reason: Value returned in the REJECT event status field.
625 */
626const char *__attribute_const__ ibcm_reject_msg(int reason);
627
Hal Rosenstockc3e01642005-07-27 11:45:39 -0700628#endif /* IB_CM_H */