xref: /illumos-gate/usr/src/uts/common/sys/ib/ibtl/ibti_cm.h (revision 179c3dac)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_IB_IBTL_IBTI_CM_H
27 #define	_SYS_IB_IBTL_IBTI_CM_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 /*
32  * ibti_cm.h
33  *
34  * This file contains the data structure definitions for the IBTI
35  * communication manager (CM). It is only included in ibti.h
36  */
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 /*
43  * Defines.
44  */
45 #define	IBT_MAX_PRIV_DATA_SZ		224
46 #define	IBT_DREP_PRIV_DATA_SZ		224
47 #define	IBT_RTU_PRIV_DATA_SZ		224
48 #define	IBT_MRA_PRIV_DATA_SZ		222
49 #define	IBT_DREQ_PRIV_DATA_SZ		220
50 #define	IBT_REP_PRIV_DATA_SZ		196
51 #define	IBT_LAP_PRIV_DATA_SZ		168
52 #define	IBT_APR_PRIV_DATA_SZ		148
53 #define	IBT_REJ_PRIV_DATA_SZ		148
54 #define	IBT_REQ_PRIV_DATA_SZ		92
55 #define	IBT_SIDR_REQ_PRIV_DATA_SZ	216
56 #define	IBT_SIDR_REP_PRIV_DATA_SZ	136
57 #define	IBT_IP_HDR_PRIV_DATA_SZ		36
58 
59 #define	IBT_CM_ADDL_REJ_LEN	72	/* Additional Rej Info len */
60 					/* This is the max consumer addl */
61 					/* reject info len */
62 #define	IBT_CM_SIDR_CP_LEN	72	/* SIDR REP Class Port Info len */
63 #define	IBT_CM_APR_ADDL_LEN	72	/* Additional Info len in APR message */
64 
65 typedef	uint8_t	ibt_priv_data_len_t;
66 
67 /*
68  * CM channel handler reject reasons.
69  *
70  * Refer to InfiniBand Architecture Release Volume 1 Rev 1.0a:
71  * Section 12.6.7.2 Rejection Reason, and RDMA IP CM Service Annex
72  *
73  * Note:
74  *	When a REJ happens for an RDMA-aware ULP, a consumer reject code
75  *	indicating an IP CM Service reject or a RDMA-Aware ULP reject can
76  *	be returned. In the IBTA spec both use the consumer reject code, but
77  *	are distinguished by the REJ layer byte (table 3 of the annex 11).
78  *	The IBTF CM can thus tell what type of reject has been returned. When
79  *	a RDMA ULP issues a consumer REJ to an RDMA REQ then the CM will
80  *	return an IBT_CM_CONSUMER ibt_cm_reason_t. The ARI data is returned
81  *	in an ibt_ari_con_t struct accessed by the 'ari_consumer' member of
82  *	the ibt_arej_info_t. However the consumer reject data begins at
83  *	'ari_consumer.rej_ari[1]', and is of length
84  *	'ari_consumer.rej_ari_len - 1' (the first byte is the REJ layer byte),
85  *	where as for a non RDMA-aware ULP consumer REJ, the ARI data begins
86  *	at 'ari_consumer.rej_ari[0]' and is of length 'ari_consumer.rej_ari_len'
87  *
88  *	If an RDMA-aware ULP REQ is rejected by the IP CM Service layer, the
89  *	CM will return the new IBT_CM_RDMA_IP ibt_cm_reason_t, and the
90  *	private data is returned in an ibt_ari_ip_t struct accessed via the
91  *	'ari_ip' member of the ibt_arej_info_t struct.
92  *
93  *	If an RDMA IP CM REQ is sent to a non RDMA-aware ULP consumer, then
94  *	the REQ is Rejected with an IBT_CM_INVALID_SID ibt_cm_reason_t.
95  */
96 typedef enum ibt_cm_reason_e {
97 	IBT_CM_SUCCESS		= 0,	/* Success */
98 	IBT_CM_NO_CHAN		= 1,	/* Remote unable to allocate a CHAN */
99 	IBT_CM_NO_EEC		= 2,	/* Remote unable to allocate an EEC */
100 	IBT_CM_NO_RESC		= 3,	/* Remote unable to allocate resource */
101 	IBT_CM_TIMEOUT		= 4,	/* CM protocol timed out waiting for */
102 					/* a msg */
103 	IBT_CM_NOT_SUPPORTED 	= 5,	/* Request not supported */
104 	IBT_CM_INVALID_CID 	= 6,	/* Local CID or Remote CID invalid */
105 	IBT_CM_INVALID_COMM_INS	= 7,	/* Local CID, Remote CID, Channel */
106 					/* does not refer to a valid */
107 					/* communication Instance. */
108 	IBT_CM_INVALID_SID 	= 8,	/* Service not supported or not */
109 					/* recognized */
110 	IBT_CM_INVALID_SRV_TYPE	= 9,	/* Invalid transport service type */
111 	IBT_CM_CONN_STALE 	= 10,	/* Stale connection */
112 	IBT_CM_INVALID_RDC 	= 11,	/* RDC does not exist */
113 	IBT_CM_PRIM_GID 	= 12,	/* Primary remote port gid rejected. */
114 	IBT_CM_PRIM_LID 	= 13,	/* Primary remote port lid rejected. */
115 	IBT_CM_INVALID_PRIM_SL 	= 14,	/* Primary Requested SL not supported */
116 	IBT_CM_INVALID_PRIM_TC 	= 15,	/* Primary Requested traffic class */
117 					/* not supported */
118 	IBT_CM_INVALID_PRIM_HOP	= 16,	/* Primary Requested hop limit not */
119 					/* accepted */
120 	IBT_CM_INVALID_PRIM_RATE = 17,	/* Primary Packet rate not accepted */
121 	IBT_CM_ALT_GID 		= 18,	/* Alternate remote port gid rejected */
122 	IBT_CM_ALT_LID 		= 19,	/* Alternate remote port lid rejected */
123 	IBT_CM_INVALID_ALT_SL 	= 20,	/* Alternate Requested SL not */
124 					/* supported */
125 	IBT_CM_INVALID_ALT_TC 	= 21,	/* Alternate Requested traffic class */
126 					/* not supported */
127 	IBT_CM_INVALID_ALT_HOP 	= 22,	/* Alternate Requested hop limit */
128 					/* accepted */
129 	IBT_CM_INVALID_ALT_RATE = 23,	/* Alternate Packet rate not accepted */
130 	IBT_CM_REDIRECT_CM 	= 24,	/* Port & CM redirected */
131 	IBT_CM_PORT_REDIRECT 	= 25,	/* Port redirected */
132 	IBT_CM_INVALID_MTU 	= 26,	/* Path MTU not supported */
133 	IBT_CM_INSUFF_RESOURCE	= 27,	/* Insufficient responder resources */
134 	IBT_CM_CONSUMER 	= 28,	/* Consumer rejected connection */
135 	IBT_CM_RNR_RETRY_CNT_REJ = 29,	/* RNR NAK retry count rejected */
136 	IBT_CM_DUP_COM_ID	= 30,	/* Local CID in REQ is duplicated */
137 	IBT_CM_CLASS_NO_SUPPORT	= 31,	/* Class version not supported */
138 	IBT_CM_INVALID_PRIM_FLOW = 32,	/* Invalid primary flow label */
139 	IBT_CM_INVALID_ALT_FLOW = 33,	/* Invalid alternate flow label */
140 	IBT_CM_DUP_CONN_REQ	= 1000, /* Duplicate connection request */
141 	IBT_CM_ABORT		= 1001,	/* Connection aborted */
142 	IBT_CM_CI_FAILURE	= 1002,	/* A call to CI failed, could be */
143 					/* query/modify channel */
144 	IBT_CM_CHAN_INVALID_STATE = 1003, /* Passive's QP is not in Init */
145 					/* state */
146 	IBT_CM_RDMA_IP		= 1004 /* RDMA IP CM reject */
147 } ibt_cm_reason_t;
148 
149 /*
150  * CM flags.
151  */
152 typedef uint8_t ibt_cm_flags_t;
153 
154 #define	IBT_CM_NO_FLAGS		0x0
155 #define	IBT_CM_FLOW_CONTROL	0x1
156 #define	IBT_CM_SRQ_EXISTS	0x2
157 
158 
159 /*
160  * The CM Handler function return values.
161  */
162 typedef enum ibt_cm_status_e {
163 	IBT_CM_ACCEPT		= 0,
164 	IBT_CM_REJECT		= 1,
165 	IBT_CM_REDIRECT_PORT	= 2,	/* Redirect port */
166 	IBT_CM_REDIRECT		= 3,	/* Redirect port and CM */
167 	IBT_CM_NO_CHANNEL	= 4,	/* Unable to allocate a channel */
168 	IBT_CM_NO_RESOURCE	= 5,	/* Unable to allocate a resource */
169 	IBT_CM_DEFAULT		= 6,	/* Do the default action */
170 	IBT_CM_DEFER		= 7	/* Can't complete processing now */
171 } ibt_cm_status_t;			/* will call ibt_cm_proceed() */
172 					/* later */
173 
174 /*
175  * SIDR_REP status type
176  */
177 typedef enum ibt_sidr_status_e {
178 	IBT_CM_SREP_CHAN_VALID	= 0,
179 	IBT_CM_SREP_SID_INVALID	= 1,	/* Service ID not supported */
180 	IBT_CM_SREP_REJ		= 2,	/* Service provider reject */
181 	IBT_CM_SREP_NO_CHAN	= 3,	/* No channel available */
182 	IBT_CM_SREP_REDIRECT	= 4,	/* Redirect request */
183 	IBT_CM_SREP_CL_INVALID	= 5,	/* Class Version is invalid */
184 	IBT_CM_SREP_TIMEOUT	= 1000	/* No SIDR_REP received */
185 } ibt_sidr_status_t;
186 
187 /*
188  * Alternate path status type
189  * The implementation defined status codes begin from 20. The status codes
190  * below 20 are based on apr_status in the APR mad.
191  */
192 typedef enum ibt_ap_status_e {
193 	IBT_CM_AP_LOADED	= 0,	/* AP loaded successfully */
194 	IBT_CM_AP_INVALID_COMMID = 1,	/* Invalid communication instance */
195 	IBT_CM_AP_NOT_SUPPORTED	= 2,	/* Alternate paths not supported */
196 	IBT_CM_AP_REJECT	= 3,	/* Failover port rejected */
197 	IBT_CM_AP_REDIRECT	= 4,	/* Reject - redirect */
198 	IBT_CM_AP_MATCH_PRIM	= 5,	/* AP matches primary path */
199 	IBT_CM_AP_QPNEECN_INVALID = 6,	/* AP QPN/EECN does not match */
200 	IBT_CM_AP_RLID_REJECTED	= 7,	/* AP remote port lid rejected */
201 	IBT_CM_AP_RGID_REJECTED	= 8,	/* AP remote port gid rejected */
202 	IBT_CM_AP_FLOW_REJECTED	= 9,	/* AP flow label rejected */
203 	IBT_CM_AP_TCLASS_REJECTED = 10,	/* AP traffic class rejected */
204 	IBT_CM_AP_HOP_REJECTED	= 11,	/* AP hop limit rejected */
205 	IBT_CM_AP_RATE_REJECTED	= 12,	/* AP static packet rate rejected */
206 	IBT_CM_AP_SL_REJECTED	= 13,	/* AP service level rejected */
207 	IBT_CM_AP_TIMEOUT	= 1000,	/* LAP timed out */
208 	IBT_CM_AP_ABORT		= 1001	/* ibt_set_alternate_path returned */
209 					/* earlier because of connection */
210 					/* getting closed */
211 } ibt_ap_status_t;
212 
213 /*
214  * Communication event types.
215  */
216 typedef enum ibt_cm_event_type_e {
217 	IBT_CM_EVENT_REQ_RCV	= 0x1,
218 	IBT_CM_EVENT_REP_RCV,
219 	IBT_CM_EVENT_MRA_RCV,
220 	IBT_CM_EVENT_LAP_RCV,
221 	IBT_CM_EVENT_APR_RCV,
222 	IBT_CM_EVENT_CONN_EST,		/* RTU has been sent/recvd and it is */
223 					/* OK to use the connection */
224 	IBT_CM_EVENT_CONN_CLOSED,	/* Connection has been closed and it */
225 					/* is OK to free resources associated */
226 					/* with the connection. */
227 	IBT_CM_EVENT_FAILURE		/* The CM Failure see cf_code in the */
228 					/* ibt_cm_conn_failed_t struct for */
229 					/* details of the failure */
230 } ibt_cm_event_type_t;
231 
232 /*
233  * CM and Port redirect information.
234  */
235 typedef struct ibt_redirect_info_s {
236 	ib_gid_t	rdi_gid;
237 	uint8_t		rdi_tclass;
238 	uint8_t		rdi_sl:4;
239 	uint_t		rdi_flow:20;
240 	ib_lid_t	rdi_dlid;
241 	ib_qpn_t	rdi_qpn;
242 	ib_qkey_t	rdi_qkey;
243 	ib_pkey_t	rdi_pkey;
244 } ibt_redirect_info_t;
245 
246 /*
247  * Values for rep_failover_status.
248  */
249 #define	IBT_CM_FAILOVER_ACCEPT		0x00 /* Failover port accepted */
250 #define	IBT_CM_FAILOVER_REJ_NOTSUPP	0x01 /* Failover not supported */
251 #define	IBT_CM_FAILOVER_REJ		0x02 /* Failover port rejected */
252 
253 /*
254  * CM REP_RCV event structure.
255  */
256 typedef struct ibt_cm_rep_rcv_s {
257 	uint8_t		rep_rdma_ra_in;		/* Arbitrated responder */
258 						/* resources (rdma_ra_in) */
259 	uint8_t		rep_rdma_ra_out;	/* Arbitrated initiator */
260 						/* depth (rdma_ra_out) */
261 	clock_t		rep_service_time;	/* time in clock ticks */
262 						/* Time to complete */
263 						/* processing of REP event */
264 	uint8_t		rep_failover_status;	/* Failover Port status */
265 	ibt_cm_flags_t	rep_flags;		/* EE flow control, SRQ etc */
266 } ibt_cm_rep_rcv_t;
267 
268 
269 /*
270  * Values for mra_msg_type.
271  */
272 #define	IBT_CM_MRA_TYPE_REQ	0x00	/* mra_msg values */
273 #define	IBT_CM_MRA_TYPE_REP	0x01
274 #define	IBT_CM_MRA_TYPE_LAP	0x02
275 
276 /*
277  * CM MRA_RCV event structure.
278  */
279 typedef struct ibt_cm_mra_rcv_s {
280 	uint8_t		mra_msg_type;	/* The message being MRA'd */
281 	clock_t		mra_service_time;	/* timeout in microseconds */
282 } ibt_cm_mra_rcv_t;
283 
284 /*
285  * CM LAP_RCV event structure.
286  */
287 typedef struct ibt_cm_lap_rcv_s {
288 	ibt_adds_vect_t	lap_alternate_path;
289 	clock_t		lap_timeout;		/* timeout in microseconds */
290 						/* This is the time that the */
291 						/* Service handler has to */
292 						/* return to the CM */
293 } ibt_cm_lap_rcv_t;
294 
295 #define	IBT_CM_IP_MAJ_VER	0
296 #define	IBT_CM_IP_MIN_VER	0
297 #define	IBT_CM_IP_IPV_V4	0x4
298 #define	IBT_CM_IP_IPV_V6	0x6
299 
300 /*
301  * Consumer defined Additional reject information.
302  */
303 typedef struct ibt_ari_con_s {
304 	uint8_t		rej_ari_len;			/* Length */
305 	uint8_t		rej_ari[IBT_CM_ADDL_REJ_LEN];	/* Buffer */
306 } ibt_ari_con_t;
307 
308 /*
309  * Consumer defined Additional reject information.
310  * For RDMA IP CM Service.
311  */
312 typedef uint8_t ibt_ari_ip_reason_t;
313 #define	IBT_ARI_IP_UNSPECIFIED		0x0
314 #define	IBT_ARI_IP_MAJOR_VERSION	0x1
315 #define	IBT_ARI_IP_MINOR_VERSION	0x2
316 #define	IBT_ARI_IP_IPV			0x3
317 #define	IBT_ARI_IP_SRC_ADDR		0x4
318 #define	IBT_ARI_IP_DST_ADDR		0x5
319 #define	IBT_ARI_IP_UNKNOWN_ADDR		0x6
320 
321 typedef struct ibt_ari_ip_s {
322 	ibt_ip_addr_t		ip_suggested_addr;	/* IP_UNKNOWN_ADDR */
323 	boolean_t		ip_suggested;	/* suggested valid */
324 	ibt_ari_ip_reason_t	ip_reason;
325 	uint8_t			ip_suggested_version:4;	/* IP_MAJOR_VERSION */
326 							/* IP_MINOR_VERSION */
327 							/* IP_IPV, */
328 							/* IP_SRC_ADDR, */
329 							/* IP_DST_ADDR */
330 } ibt_ari_ip_t;
331 
332 /*
333  * Additional reject information.
334  */
335 typedef union ibt_arej_info_u {
336 	ibt_ari_con_t		ari_consumer;	/* IBT_CM_CONSUMER */
337 	ib_gid_t		ari_gid;	/* IBT_CM_PRIM_GID, */
338 						/* IBT_CM_ALT_GID, */
339 						/* IBT_CM_PORT_REDIRECT */
340 	ib_lid_t		ari_lid;	/* IBT_CM_PRIM_LID, */
341 						/* IBT_CM_ALT_LID */
342 	uint8_t			ari_sl:4;	/* IBT_CM_INVALID_PRIM_SL, */
343 						/* IBT_CM_INVALID_ALT_SL */
344 	uint8_t			ari_tclass;	/* IBT_CM_INVALID_PRIM_TC, */
345 						/* IBT_CM_INVALID_ALT_TC */
346 	uint8_t			ari_hop;	/* IBT_CM_INVALID_PRIM_HOP, */
347 						/* IBT_CM_INVALID_ALT_HOP */
348 	uint_t			ari_flow:20;	/* IBT_CM_INVALID_PRIM_FLOW, */
349 						/* IBT_CM_INVALID_ALT_FLOW */
350 	ibt_srate_t		ari_rate;	/* IBT_CM_INVALID_PRIM_RATE, */
351 						/* IBT_CM_INVALID_ALT_RATE */
352 	ib_mtu_t		ari_mtu;	/* IBT_CM_INVALID_MTU */
353 	ibt_redirect_info_t	ari_redirect;	/* IBT_CM_REDIRECT_CM */
354 	ibt_ari_ip_t		ari_ip;		/* IBT_CM_RDMA_IP */
355 } ibt_arej_info_t;
356 
357 /*
358  * CM APR_RCV event structure.
359  */
360 typedef struct ibt_cm_apr_rcv_s {
361 	ibt_ap_status_t		apr_status;
362 	boolean_t		apr_arej_info_valid;
363 	ibt_arej_info_t		apr_arej_info;
364 } ibt_cm_apr_rcv_t;
365 
366 
367 /*
368  * Connection Failed Message type (values of cf_msg).
369  * Identifies the CM message that either timed out or is being rejected.
370  */
371 #define	IBT_CM_FAILURE_REQ	0x00
372 #define	IBT_CM_FAILURE_REP	0x01
373 #define	IBT_CM_FAILURE_UNKNOWN	0x02
374 #define	IBT_CM_FAILURE_LAP	0x03
375 
376 /*
377  * CM Failure code (values of cf_code).
378  * Identifies the reason for failure.
379  */
380 #define	IBT_CM_FAILURE_REJ_SENT	0x00
381 #define	IBT_CM_FAILURE_REJ_RCV	0x01
382 #define	IBT_CM_FAILURE_TIMEOUT	0x02
383 #define	IBT_CM_FAILURE_DUP	0x03
384 #define	IBT_CM_FAILURE_STALE	0x04
385 
386 /*
387  * IBT_CM_EVENT_FAILURE event struct.
388  */
389 typedef struct ibt_cm_conn_failed_s {
390 	uint8_t		cf_code;	/* Failure Code */
391 	uint8_t		cf_msg;		/* The message that timed out or is */
392 					/* being rejected */
393 	boolean_t	cf_arej_info_valid;	/* Is cf_additional valid? */
394 	ibt_cm_reason_t	cf_reason;	/* Reject reason */
395 	ibt_arej_info_t	cf_additional;	/* Additional Reject info */
396 } ibt_cm_conn_failed_t;
397 
398 
399 /*
400  * CM REQ_RCV event structure.
401  *
402  * The req_cm_opaque is an IBTF CM opaque (to the client) value, that should
403  * be returned to the IBTF CM if the client/server CM handler wishes to call
404  * ibt_cm_delay().
405  *
406  *	prim_addr->av_dgid		Is the GID of the requester.
407  *	prim_addr->av_sgid		Is the local GID to which the
408  *					requester is attempting to establish
409  *					a connection to.
410  *	hca_guid			Is the HCA GUID that contains the
411  *					prim_addr->av_sgid
412  *	prim_hca_port			Is the port on the hca_guid that
413  *					prim_addr->av_sgid is on.
414  */
415 typedef struct ibt_cm_req_rcv_s {
416 	ib_svc_id_t	req_service_id;
417 	ibt_tran_srv_t	req_transport;
418 	ib_guid_t	req_hca_guid;
419 	uint8_t		req_prim_hca_port;
420 	uint8_t		req_alt_hca_port;
421 	ibt_adds_vect_t	req_prim_addr;
422 	ibt_adds_vect_t	req_alt_addr;
423 	uint8_t		req_rdma_ra_in;   	/* Offered responder */
424 						/* resources. */
425 	uint8_t		req_rdma_ra_out; 	/* Offered initiator depth */
426 	clock_t		req_timeout;		/* timeout in microseconds */
427 						/* This is the time that the */
428 						/* Service handler has to */
429 						/* return to the CM */
430 	ib_qpn_t	req_remote_qpn;
431 	ib_qkey_t	req_remote_qkey;
432 	ib_pkey_t	req_pkey;
433 	ibt_cm_flags_t	req_flags;		/* EE flow control etc */
434 	uint8_t		req_retry_cnt:3;
435 	ibt_rnr_retry_cnt_t	req_rnr_retry_cnt;
436 	ib_eecn_t	req_opaque1;
437 	ib_eecn_t	req_opaque2;
438 } ibt_cm_req_rcv_t;
439 
440 /*
441  * The IBT_CM_EVENT_CONN_CLOSED event is generated by the CM when a connection
442  * has been closed. The reason the connection was closed is given in the
443  * "closed" member of the cm_event as one of:
444  *
445  * A client can only call ibt_free_channel() to free channel resources on
446  * receipt of the IBT_CM_EVENT_CONN_CLOSED event.
447  */
448 #define	IBT_CM_CLOSED_DREP_RCVD		0x01
449 #define	IBT_CM_CLOSED_DREQ_RCVD		0x02
450 #define	IBT_CM_CLOSED_REJ_RCVD		0x03
451 #define	IBT_CM_CLOSED_DREQ_TIMEOUT	0x04
452 #define	IBT_CM_CLOSED_DUP		0x05
453 #define	IBT_CM_CLOSED_ABORT		0x06
454 #define	IBT_CM_CLOSED_STALE		0x07
455 #define	IBT_CM_CLOSED_ALREADY		0x08
456 
457 /*
458  * Operation type in ibt_cm_event_type_t.
459  *
460  * Note:
461  * 	The IBT_CM_EVENT_CONN_EST event has no associated "cm_event"
462  *	field in the ibt_cm_event_t structure.
463  *
464  *	The cm_session_id is a CM opaque (to the client) value, that
465  *	should be returned to the CM if the client/server CM handler wishes
466  *	to call ibt_cm_delay() or ibt_cm_proceed().
467  *
468  */
469 typedef struct ibt_cm_event_s {
470 	ibt_cm_event_type_t	cm_type;	/* Describes the event */
471 	void			*cm_session_id;	/* Used by the CM */
472 	ibt_channel_hdl_t	cm_channel;	/* Event channel. Not valid */
473 						/* for ibt_cm_req_rcv_t */
474 	ibt_eec_hdl_t		cm_opaque;
475 	ibt_priv_data_len_t	cm_priv_data_len;	/* 0 if no private */
476 	void			*cm_priv_data;		/* data returned */
477 	union {
478 		ibt_cm_rep_rcv_t		rep;
479 		ibt_cm_req_rcv_t 		req;
480 		ibt_cm_lap_rcv_t		lap;
481 		ibt_cm_apr_rcv_t		apr;
482 		ibt_cm_mra_rcv_t		mra;
483 		ibt_cm_conn_failed_t		failed;
484 		uint8_t				closed;
485 	} cm_event;	/* operation specific */
486 } ibt_cm_event_t;
487 
488 /*
489  * CM Return structure for an incoming REQ
490  * Server handler that wishes to accept the connection, fills all the
491  * values before returning to CM
492  */
493 typedef struct ibt_cm_ret_rep_s {
494 	ibt_channel_hdl_t	cm_channel;	/* The channel overwhich the */
495 						/* connection will be */
496 						/* established */
497 						/* can be returned NULL */
498 						/* if no resources available */
499 	uint8_t			cm_rdma_ra_out; /* max RDMA-R/Atomic sent */
500 						/* Number of RDMA RD's & */
501 						/* Atomics outstanding */
502 	uint8_t			cm_rdma_ra_in;	/* Incoming RDMA-R/Atomic */
503 						/* Responder resources for */
504 						/* handling incoming */
505 						/* RDMA RD's & Atomics */
506 	ibt_rnr_retry_cnt_t	cm_rnr_retry_cnt;
507 } ibt_cm_ret_rep_t;
508 
509 /*
510  * Define an ibt_cm_proceed() argument union.
511  *
512  * rep is valid when an IBT client cm handler has decided to continue a
513  * REQ_RCV, accepting the connection.
514  *
515  * rej is valid when an IBT client cm handler has decided to continue a
516  * REQ_RCV or REP_RCV, rejecting the message.
517  *
518  * apr is valid when an IBT client cm handler has decided to continue a
519  * LAP_RCV, redirecting the lap request.
520  */
521 typedef union ibt_cm_proceed_reply_s {
522 	ibt_cm_ret_rep_t	rep;	/* Return for REP */
523 	ibt_arej_info_t		rej;	/* Return for REJ */
524 	ibt_redirect_info_t	apr;	/* Return for APR */
525 } ibt_cm_proceed_reply_t;
526 
527 
528 /*
529  * Define a CM handler return arguments structure.
530  *
531  * cm_ret.rep is returned to the CM when an IBT client cm handler has
532  * decided to accept a connection in response to a CM REQ_RCV event.
533  *
534  * cm_ret.rej is returned to the CM when an IBT client cm handler
535  * has decided to reject the connection in response to a CM REQ_RCV event.
536  *
537  * cm_ret.apr is returned to the CM when an IBT client cm handler
538  * has decided to redirect the lap request in response to a CM LAP RCV event.
539  *
540  * The client/server should update cm_ret_len with number of private data
541  * bytes filled in priv_data arg of the cm handler.
542  */
543 typedef struct ibt_cm_return_args_s {
544 	ibt_priv_data_len_t	cm_ret_len;
545 	union {
546 		ibt_cm_ret_rep_t	rep;	/* Return for REP */
547 		ibt_arej_info_t		rej;	/* Return for REJ */
548 		ibt_redirect_info_t	apr;	/* Return for APR */
549 	} cm_ret;	/* reply specific */
550 } ibt_cm_return_args_t;
551 
552 
553 /*
554  * Communication Manager UD event types.
555  */
556 typedef enum ibt_cm_ud_event_type_e {
557 	IBT_CM_UD_EVENT_SIDR_REQ	= 1,
558 	IBT_CM_UD_EVENT_SIDR_REP	= 2
559 } ibt_cm_ud_event_type_t;
560 
561 /*
562  * CM SIDR_REQ event structure.
563  */
564 typedef struct ibt_cm_sidr_req_s {
565 	ib_guid_t	sreq_hca_guid;
566 	uint8_t		sreq_hca_port;
567 	ib_pkey_t	sreq_pkey;
568 	ib_svc_id_t	sreq_service_id;
569 } ibt_cm_sidr_req_t;
570 
571 /*
572  * CM SIDR_REP event structure.
573  */
574 typedef struct ibt_cm_sidr_rep_s {
575 	ibt_sidr_status_t	srep_status;
576 	ib_svc_id_t		srep_service_id;
577 	ib_qkey_t		srep_remote_qkey;
578 	ib_qpn_t		srep_remote_qpn;
579 	ibt_redirect_info_t	srep_redirect;	/* Only valid if redirect */
580 } ibt_cm_sidr_rep_t;
581 
582 /*
583  * Operation type in ibt_cm_ud_event_type_t.
584  *
585  * The cm_session_id is a CM opaque (to the client) value, that
586  * should be returned to the CM if the client/server CM handler
587  * wishes to call ibt_cm_ud_proceed().
588  */
589 typedef struct ibt_cm_ud_event_s {
590 	ibt_cm_ud_event_type_t	cm_type;	/* Describes the event record */
591 	void			*cm_session_id;	/* Used by the CM */
592 	ibt_priv_data_len_t	cm_priv_data_len;
593 	void			*cm_priv_data;
594 	union {
595 		ibt_cm_sidr_rep_t	sidr_rep;
596 		ibt_cm_sidr_req_t	sidr_req;
597 	} cm_event;				/* operation specific */
598 } ibt_cm_ud_event_t;
599 
600 
601 /*
602  * Define a CM UD handler return arguments structure.
603  *
604  * The information here is returned to the CM when an IBT client CM UD
605  * handler has decided to communicate (via UD messages) with the requester
606  * of the SIDR_REQ_RCV event.
607  *
608  * The ud_channel encodes the QPN and Q_Key to be placed in the SIDR_REP.
609  *
610  * CM sets ud_ret_len to 0 before calling the UD CM handler.  If the CM UD
611  * handler wishes to send private data back, it needs to update ud_ret_len
612  * with the actual number of bytes to be sent back in the SIDR_REP MAD.  It
613  * copies said data to the buffer pointed to by the ret_priv_data argument.
614  *
615  * The ud_redirect structure should only be updated if the UD CM handler is
616  * Redirecting a CM request.
617  */
618 typedef struct ibt_cm_ud_return_args_s {
619 	ibt_priv_data_len_t	ud_ret_len;
620 	ibt_channel_hdl_t	ud_channel;
621 	ibt_redirect_info_t	ud_redirect;
622 } ibt_cm_ud_return_args_t;
623 
624 
625 /*
626  * IBT Client CM Callback function typedefs.
627  *
628  * ibt_cm_handler_t:
629  *
630  * The CM event handler function. An IBT client callback that handles
631  * CM events. If the handler will exceed the event service timeout
632  * then it should call ibt_cm_delay(), specifying the maximum time it
633  * will take to complete processing the CM event.
634  *
635  * Clients are advised not to issue blocking calls from a cm handler, as this
636  * would block the CM threads, and could delay or block other client
637  * connections.
638  *
639  * Clients are allowed to make resource clean up/free calls in the CM handler
640  * such as ibt_free_cq, ibt_free_rc/ud_channel, etc. on connection failure
641  * or tear down.
642  *
643  * Clients should not call ibt_close_rc_channel in the cm handler for connection
644  * failure or tear down events, as these events already perform the processing
645  * necessary to close the channel.
646  *
647  * Clients can call ibt_close_rc_channel only in the non-blocking mode from
648  * the cm handler for connection abort.
649  */
650 typedef ibt_cm_status_t (*ibt_cm_handler_t)(void *cm_private,
651     ibt_cm_event_t *event, ibt_cm_return_args_t *ret_args,
652     void *ret_priv_data, ibt_priv_data_len_t ret_len_max);
653 
654 /*
655  * ibt_cm_ud_handler_t	- Pointer to the CM UD event handler function.
656  *			  This function should handle the following CM
657  *			  events:
658  *				IBT_CM_UD_EVENT_SIDR_REQ
659  *				IBT_CM_UD_EVENT_SIDR_REP
660  */
661 typedef ibt_cm_status_t (*ibt_cm_ud_handler_t)(void *ud_cm_private,
662     ibt_cm_ud_event_t *event, ibt_cm_ud_return_args_t *ret_args,
663     void *ret_priv_data, ibt_priv_data_len_t ret_len_max);
664 
665 #ifdef __cplusplus
666 }
667 #endif
668 
669 #endif /* _SYS_IB_IBTL_IBTI_CM_H */
670