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