xref: /illumos-gate/usr/src/uts/common/sys/ib/ibtl/ibti_common.h (revision 355b4669e025ff377602b6fc7caaf30dbc218371)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_IB_IBTL_IBTI_COMMON_H
28 #define	_SYS_IB_IBTL_IBTI_COMMON_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * ibti_common.h
34  *
35  * This file contains the shared/common transport data types and function
36  * prototypes.
37  */
38 #include <sys/ib/ibtl/ibtl_types.h>
39 #include <sys/ib/ibtl/ibti_cm.h>
40 #include <sys/isa_defs.h>
41 #include <sys/byteorder.h>
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 /*
48  * Endian Macros
49  *    h2b - host endian to big endian protocol
50  *    b2h - big endian protocol to host endian
51  *    h2l - host endian to little endian protocol
52  *    l2h - little endian protocol to host endian
53  */
54 #if defined(_LITTLE_ENDIAN)
55 #define	h2b16(x)	(htons(x))
56 #define	h2b32(x)	(htonl(x))
57 #define	h2b64(x)	(ddi_swap64(x))
58 #define	b2h16(x)	(ntohs(x))
59 #define	b2h32(x)	(ntohl(x))
60 #define	b2h64(x)	(ddi_swap64(x))
61 
62 #define	h2l16(x)	(x)
63 #define	h2l32(x)	(x)
64 #define	h2l64(x)	(x)
65 #define	l2h16(x)	(x)
66 #define	l2h32(x)	(x)
67 #define	l2h64(x)	(x)
68 
69 #elif defined(_BIG_ENDIAN)
70 #define	h2b16(x)	(x)
71 #define	h2b32(x)	(x)
72 #define	h2b64(x)	(x)
73 #define	b2h16(x)	(x)
74 #define	b2h32(x)	(x)
75 #define	b2h64(x)	(x)
76 
77 #define	h2l16(x)	(ddi_swap16(x))
78 #define	h2l32(x)	(ddi_swap32(x))
79 #define	h2l64(x)	(ddi_swap64(x))
80 #define	l2h16(x)	(ddi_swap16(x))
81 #define	l2h32(x)	(ddi_swap32(x))
82 #define	l2h64(x)	(ddi_swap64(x))
83 
84 #else
85 #error	"what endian is this machine?"
86 #endif
87 
88 /*
89  * Max number of paths that can be requested in an ibt_get_paths() call,
90  * if IBT_PATH_PERF or IBT_PATH_AVAIL flag (ibt_path_flags_t) is set.
91  */
92 #define	IBT_MAX_SPECIAL_PATHS	2
93 
94 /*
95  * The name of DDI Event, generated when the properties of IOC device
96  * node properties were modified.
97  */
98 #define	IB_PROP_UPDATE_EVENT	"SUNW,IB:IB_PROP_UPDATE"
99 
100 
101 /* Transport Interface version */
102 typedef enum ibt_version_e {
103 	IBTI_V1 = 1,
104 	IBTI_V2 = 2		/* FMR Support */
105 } ibt_version_t;
106 
107 /*
108  * Driver class type. Identifies a type of client driver so that
109  * "IBTF Policy" decisions can be made on a driver class basis.
110  * The last class should always be IBT_CLNT_NUM, and any new classes added
111  * must be defined before IBT_CLNT_NUM. The class values must be above 0.
112  * Any class values below or equal to 0 shall be invalid
113  */
114 typedef enum ibt_clnt_class_e {
115 	IBT_STORAGE_DEV = 0x1,	/* SCSI, FC, etc.. */
116 	IBT_NETWORK_DEV,	/* Network driver with associated client H/W */
117 	IBT_GENERIC_DEV,	/* Generic client H/W device driver */
118 	IBT_NETWORK,		/* Network driver with no associated */
119 				/* client H/W, e.g., IPoIB */
120 	IBT_GENERIC,		/* A generic IB driver not */
121 				/* associated with client H/W */
122 	IBT_USER,		/* A user application IBT interface driver */
123 	IBT_IBMA,		/* The IBMA Module */
124 	IBT_CM,			/* The CM Module */
125 	IBT_DM,			/* The DM Module */
126 	IBT_CLASS_NUM		/* Place holder for class count */
127 } ibt_clnt_class_t;
128 
129 #define	IBT_TEST_DEV	999	/* Place holder for modules that test IBTL */
130 
131 #define	IBT_CLNT_DEVICE_CLASS(class)	((class) == IBT_STORAGE_DEV || \
132 					(class) == IBT_NETWORK_DEV || \
133 					(class) == IBT_GENERIC_DEV)
134 
135 #define	IBT_CLNT_GENERAL_CLASS(class)	((class) == IBT_NETWORK || \
136 					(class) == IBT_GENERIC || \
137 					(class) == IBT_USER)
138 
139 #define	IBT_CLNT_MGMT_CLASS(class)	((class) == IBT_IBMA || \
140 					(class) == IBT_CM || \
141 					(class) == IBT_DM || \
142 					(class) == IBT_TEST_DEV)
143 /*
144  * Event record & status returns for asynchronous events and errors.
145  */
146 typedef struct ibt_async_event_s {
147 	uint64_t		ev_fma_ena;		/* FMA Error data */
148 	ibt_channel_hdl_t	ev_chan_hdl;		/* Channel handle */
149 	ibt_cq_hdl_t		ev_cq_hdl;		/* CQ handle */
150 	ib_guid_t		ev_hca_guid;		/* HCA node GUID */
151 	uint8_t			ev_port;		/* HCA port */
152 	ibt_srq_hdl_t		ev_srq_hdl;		/* SRQ handle */
153 } ibt_async_event_t;
154 
155 /*
156  * IBT Client Callback function typedefs.
157  *
158  * ibt_async_handler_t
159  *	Pointer to an async event/error handler function.  This function is
160  *	called when an async event/error is detected on a HCA that is being
161  *	used by the IBT client driver that registered the function.
162  */
163 typedef void (*ibt_async_handler_t)(void *clnt_private,
164     ibt_hca_hdl_t hca_hdl, ibt_async_code_t code, ibt_async_event_t *event);
165 
166 /*
167  * IBT Client Memory Error Callback function typedefs.
168  *
169  * ibt_memory_handler_t
170  *	Pointer to an memory event/error handler function.
171  */
172 typedef void (*ibt_memory_handler_t)(void *clnt_private,
173     ibt_hca_hdl_t hca_hdl, ibt_mem_code_t code, ibt_mem_data_t *data);
174 
175 /*
176  * Define a client module information structure. All clients MUST
177  * define a global of type ibt_clnt_modinfo_t. A pointer to this global
178  * is passed into the IBTF by a client when calling ibt_attach().
179  * This struct must persist during the life of the client.
180  *
181  * The client's mi_async_handler is called when an async event/error is
182  * detected on a HCA that is being used by this client.
183  */
184 typedef struct ibt_clnt_modinfo_s {
185 	ibt_version_t		mi_ibt_version;		/* TI version */
186 	ibt_clnt_class_t	mi_clnt_class;		/* Type of client */
187 	ibt_async_handler_t	mi_async_handler;	/* Async Handler */
188 	ibt_memory_handler_t	mi_reserved;		/* Memory handler */
189 	char			*mi_clnt_name;		/* Client Name. */
190 } ibt_clnt_modinfo_t;
191 
192 
193 /*
194  * Definitions for use with ibt_register_subnet_notices()
195  */
196 typedef enum ibt_subnet_event_code_e {
197 	IBT_SM_EVENT_MCG_CREATED = 1,
198 	IBT_SM_EVENT_MCG_DELETED = 2,
199 	IBT_SM_EVENT_AVAILABLE	 = 3,
200 	IBT_SM_EVENT_UNAVAILABLE = 4,
201 	IBT_SM_EVENT_GID_AVAIL	 = 5,
202 	IBT_SM_EVENT_GID_UNAVAIL = 6
203 } ibt_subnet_event_code_t;
204 
205 typedef struct ibt_subnet_event_s {
206 	ib_gid_t sm_notice_gid;
207 } ibt_subnet_event_t;
208 
209 typedef void (*ibt_sm_notice_handler_t)(void *private, ib_gid_t gid,
210     ibt_subnet_event_code_t code, ibt_subnet_event_t *event);
211 
212 
213 /*
214  * MTU Request type.
215  */
216 typedef struct ibt_mtu_req_s {
217 	ib_mtu_t	r_mtu;		/* Requested MTU */
218 	ibt_selector_t	r_selector;	/* Qualifier for r_mtu */
219 } ibt_mtu_req_t;
220 
221 
222 /*
223  * Qflags, used by ibt_resize_queues().
224  */
225 typedef enum ibt_qflags_e {
226 	IBT_SEND_Q	= 1 << 0,	/* Op applies to the Send Q */
227 	IBT_RECV_Q	= 1 << 1	/* Op applies to the Recv Q */
228 } ibt_qflags_t;
229 
230 /*
231  * CQ priorities
232  * The IBTF will attempt to implement a coarse 3 level priority scheme
233  * (IBT_CQ_LOW, IBT_CQ_MEDIUM, IBT_CQ_HIGH) based on the class of client
234  * driver. The requested priority is not guaranteed. If a CI implementation
235  * has the ability to implement priority CQs, then the IBTF will take advantage
236  * of that when calling the CI to create a CQ by passing a priority indicator
237  * to the CI.
238  */
239 typedef enum ibt_cq_priority_e {
240 	IBT_CQ_DEFAULT		= 0x0,
241 	IBT_CQ_LOW		= 0x1,
242 	IBT_CQ_MEDIUM		= 0x2,
243 	IBT_CQ_HIGH		= 0x3,
244 	IBT_CQ_OPAQUE_1		= 0x4,
245 	IBT_CQ_OPAQUE_2		= 0x5,
246 	IBT_CQ_OPAQUE_3		= 0x6,
247 	IBT_CQ_OPAQUE_4		= 0x7,
248 	IBT_CQ_OPAQUE_5		= 0x8,
249 	IBT_CQ_OPAQUE_6		= 0x9,
250 	IBT_CQ_OPAQUE_7		= 0xA,
251 	IBT_CQ_OPAQUE_8		= 0xB,
252 	IBT_CQ_OPAQUE_9		= 0xC,
253 	IBT_CQ_OPAQUE_10	= 0xD,
254 	IBT_CQ_OPAQUE_11	= 0xE,
255 	IBT_CQ_OPAQUE_12	= 0xF,
256 	IBT_CQ_OPAQUE_13	= 0x10,
257 	IBT_CQ_OPAQUE_14	= 0x11,
258 	IBT_CQ_OPAQUE_15	= 0x12,
259 	IBT_CQ_OPAQUE_16	= 0x13
260 } ibt_cq_priority_t;
261 
262 /*
263  * Attributes when creating a Completion Queue Scheduling Handle.
264  */
265 typedef struct ibt_cq_sched_attr_s {
266 	ibt_cq_sched_flags_t	cqs_flags;
267 	ibt_cq_priority_t	cqs_priority;
268 	uint_t			cqs_load;
269 	ibt_sched_hdl_t		cqs_affinity_hdl;
270 } ibt_cq_sched_attr_t;
271 
272 
273 /*
274  * ibt_cq_handler_t
275  *	Pointer to a work request completion handler function.  This function
276  *	is called when a WR completes on a CQ that is being used by the IBTF
277  *	client driver that registered the function.
278  */
279 typedef void (*ibt_cq_handler_t)(ibt_cq_hdl_t ibt_cq, void *arg);
280 
281 /*
282  * Service Data and flags.
283  *	(IBTA Spec Release 1.1, Vol-1 Ref: 15.2.5.14.4)
284  *
285  * The ServiceData8.1 (sb_data8[0]) through ServiceData64.2 (sb_data64[1])
286  * components together constitutes a 64-byte area in which any data may be
287  * placed. It is intended to be a convenient way for a service to provide its
288  * clients with some initial data.
289  *
290  * In addition, this 64-byte area is formally divided into a total of 30
291  * components, 16 8-bit (uint8_t) components, then 8 16-bit (uint16_t)
292  * components, then 6 32-bit (uint32_t) components, then 2 64-bit (uint64_t)
293  * components,  thereby assigning ComponentMask bits (ibt_srv_data_flags_t) to
294  * variously-sized segments of the data. All data are in host endian format.
295  * This allows query operations (ibt_get_paths()) to be used which match
296  * parts of the Service Data, making it possible, for example, for
297  * service-specific parts of the ServiceData to serve as a binary-coded
298  * extension to the ServiceName for purposes of lookup.
299  */
300 typedef enum ibt_srv_data_flags_e {
301 	IBT_NO_SDATA	= 0,
302 
303 	IBT_SDATA8_0	= (1 << 0),
304 	IBT_SDATA8_1	= (1 << 1),
305 	IBT_SDATA8_2	= (1 << 2),
306 	IBT_SDATA8_3	= (1 << 3),
307 	IBT_SDATA8_4	= (1 << 4),
308 	IBT_SDATA8_5	= (1 << 5),
309 	IBT_SDATA8_6	= (1 << 6),
310 	IBT_SDATA8_7	= (1 << 7),
311 	IBT_SDATA8_8	= (1 << 8),
312 	IBT_SDATA8_9	= (1 << 9),
313 	IBT_SDATA8_10	= (1 << 10),
314 	IBT_SDATA8_11	= (1 << 11),
315 	IBT_SDATA8_12	= (1 << 12),
316 	IBT_SDATA8_13	= (1 << 13),
317 	IBT_SDATA8_14	= (1 << 14),
318 	IBT_SDATA8_15	= (1 << 15),
319 
320 	IBT_SDATA16_0	= (1 << 16),
321 	IBT_SDATA16_1	= (1 << 17),
322 	IBT_SDATA16_2	= (1 << 18),
323 	IBT_SDATA16_3	= (1 << 19),
324 	IBT_SDATA16_4	= (1 << 20),
325 	IBT_SDATA16_5	= (1 << 21),
326 	IBT_SDATA16_6	= (1 << 22),
327 	IBT_SDATA16_7	= (1 << 23),
328 
329 	IBT_SDATA32_0	= (1 << 24),
330 	IBT_SDATA32_1	= (1 << 25),
331 	IBT_SDATA32_2	= (1 << 26),
332 	IBT_SDATA32_3	= (1 << 27),
333 
334 	IBT_SDATA64_0	= (1 << 28),
335 	IBT_SDATA64_1	= (1 << 29),
336 
337 	IBT_SDATA_ALL	= 0x3FFFFFFF
338 } ibt_srv_data_flags_t;
339 
340 typedef struct ibt_srv_data_s {
341 	uint8_t		s_data8[16];	/* 8-bit service data fields. */
342 	uint16_t	s_data16[8];	/* 16-bit service data fields. */
343 	uint32_t	s_data32[4];	/* 32-bit service data fields. */
344 	uint64_t	s_data64[2];	/* 64-bit service data fields. */
345 } ibt_srv_data_t;
346 
347 /*
348  * Path flags, used in ibt_get_paths()
349  */
350 typedef enum ibt_path_flags_e {
351 	IBT_PATH_NO_FLAGS	= 0,
352 	IBT_PATH_APM		= 1 << 0,	/* APM is desired. */
353 	IBT_PATH_AVAIL		= 1 << 2,
354 	IBT_PATH_PERF		= 1 << 3,
355 	IBT_PATH_MULTI_SVC_DEST	= 1 << 4,	/* Multiple ServiceRecords */
356 	IBT_PATH_HOP		= 1 << 5,	/* pa_hop is specified. */
357 	IBT_PATH_PKEY		= 1 << 6	/* pa_pkey is specified. */
358 } ibt_path_flags_t;
359 
360 /*
361  * Path attributes.
362  *
363  * The ibt_path_attr_t structure is used to specify required attributes in a
364  * path from the requesting (source) node to a specified destination node.
365  * Attributes that are don't care should be set to NULL or '0'.
366  * A destination must be specified, where a destination can be defined as
367  * one of the following:
368  *
369  *	o Service Name
370  *	o Service ID (SID)
371  *	o Array of DGIDs.
372  *	o Service Name and Array of DGIDs.
373  */
374 typedef struct ibt_path_attr_s {
375 	ib_gid_t		*pa_dgids;	/* Array of DGIDs */
376 	ib_gid_t		pa_sgid;
377 	ib_guid_t		pa_hca_guid;
378 	char			*pa_sname;	/* ASCII Service name  */
379 						/* NULL Terminated */
380 	ib_svc_id_t		pa_sid;		/* Service ID */
381 	ibt_srv_data_flags_t	pa_sd_flags;	/* Service Data flags. */
382 	ibt_srv_data_t		pa_sdata;	/* Service Data */
383 	uint8_t			pa_hca_port_num;
384 	uint8_t			pa_num_dgids;	/* size of pa_dgids array */
385 	uint8_t			pa_sl:4;
386 	ibt_mtu_req_t		pa_mtu;
387 	ibt_srate_req_t		pa_srate;
388 	ibt_pkt_lt_req_t	pa_pkt_lt;	/* Packet Life Time Request */
389 	uint_t			pa_flow:20;
390 	uint8_t			pa_hop;		/* IBT_PATH_HOP */
391 	uint8_t			pa_tclass;
392 	ib_pkey_t		pa_pkey;	/* IBT_PATH_PKEY */
393 } ibt_path_attr_t;
394 
395 /*
396  * Path Information.
397  *
398  * The ibt_get_paths() performs SA Path record lookups to select a path(s) to
399  * a given destination(s), details of selected path(s) are returned in this
400  * structure.
401  *
402  * The ibt_path_info_t contains all the attributes of the best path(s), as
403  * as determined by IBTL, to the specified destination(s), including the
404  * local HCA and HCA port to use to access the fabric.
405  *
406  * The Service ID (pi_sid) and Service Data (pi_sdata) are returned only for
407  * lookups based on Service ID or/and Service Name.
408  */
409 typedef struct ibt_path_info_s {
410 	ib_guid_t	pi_hca_guid;		/* Local HCA GUID; 0 implies */
411 						/* this record is invalid */
412 	ib_svc_id_t	pi_sid;			/* Service ID */
413 	ibt_srv_data_t	pi_sdata;		/* Service Data */
414 
415 	ibt_cep_path_t	pi_prim_cep_path;	/* Contains CEP adds info */
416 	ibt_cep_path_t	pi_alt_cep_path;	/* RC & UC Only, valid if */
417 						/* cep_hca_port_num is not */
418 						/* '0' */
419 	ib_mtu_t	pi_path_mtu;		/* Common path MTU */
420 	ib_time_t	pi_prim_pkt_lt;
421 	ib_time_t	pi_alt_pkt_lt;
422 } ibt_path_info_t;
423 
424 /*
425  * Optional Alternate Path attributes.
426  *
427  * The ibt_alt_path_attr_t structure is used to specify additional optional
428  * attributes when requesting an alternate path for an existing channel.
429  *
430  * Attributes that are don't care should be set to NULL or '0'.
431  */
432 typedef struct ibt_alt_path_attr_s {
433 	ib_gid_t		apa_sgid;
434 	ib_gid_t		apa_dgid;
435 	ibt_srate_req_t		apa_srate;
436 	ibt_pkt_lt_req_t	apa_pkt_lt;	/* Packet Life Time Request */
437 	uint_t			apa_flow:20;
438 	uint8_t			apa_sl:4;
439 	uint8_t			apa_hop;
440 	uint8_t			apa_tclass;
441 } ibt_alt_path_attr_t;
442 
443 /*
444  * Path Information for Alternate Path - input to ibt_set_alt_path().
445  */
446 typedef struct ibt_alt_path_info_s {
447 	ibt_cep_path_t	ap_alt_cep_path;	/* RC & UC Only, valid if */
448 						/* cep_hca_port_num is not */
449 						/* '0' */
450 	ib_time_t	ap_alt_pkt_lt;
451 } ibt_alt_path_info_t;
452 
453 /*
454  * Open Channel flags, Used in ibt_open_rc_channel call
455  */
456 typedef enum ibt_chan_open_flags_e {
457 	IBT_OCHAN_NO_FLAGS		= 0,
458 	IBT_OCHAN_REDIRECTED		= 1 << 0,
459 	IBT_OCHAN_PORT_REDIRECTED	= 1 << 1,
460 	IBT_OCHAN_DUP			= 1 << 2,
461 	IBT_OCHAN_PORT_FIXED		= 1 << 3,
462 	IBT_OCHAN_OPAQUE1		= 1 << 4,
463 	IBT_OCHAN_OPAQUE2		= 1 << 5,
464 	IBT_OCHAN_OPAQUE3		= 1 << 6,
465 	IBT_OCHAN_OPAQUE4		= 1 << 7,
466 	IBT_OCHAN_OPAQUE5		= 1 << 8
467 } ibt_chan_open_flags_t;
468 
469 /*
470  * Arguments for ibt_open_rc_channel().
471  *
472  * oc_priv_data should be NULL or point to a buffer allocated by the caller,
473  * the size of which should be in oc_priv_data_len, where oc_priv_data_len <=
474  * IBT_REQ_PRIV_DATA_SZ.
475  *
476  * When ibt_open_rc_channel returns with ibt_cm_reason_t of
477  * IBT_CM_REDIRECT_PORT, the client can re-issue ibt_open_rc_channel setting
478  * new fields as follows:
479  *
480  * Set (ibt_chan_args_t)->oc_cm_cep_path  =
481  *    original (ibt_chan_open_args_t)->oc_path->pi_prim_cep_path.
482  * Set (ibt_chan_args_t)->oc_cm_pkt_lt  =
483  *    original (ibt_chan_open_args_t)->oc_prim_pkt_lt.
484  * Update (ibt_chan_args_t)->oc_path based on path information returned
485  * from ibt_get_paths using the gid in the return data below:
486  * 	(ibt_rc_returns_t)->rc_arej_info.ari_redirect_info.ari_gid.
487  * Set flags to IBT_OCHAN_PORT_REDIRECTED.
488  *
489  * Note : oc_cm_path is not used for any other scenario, and must be set for
490  * IBT_OCHAN_PORT_REDIRECTED.
491  *
492  * When ibt_open_rc_channel returns with ibt_cm_reason_t of
493  * IBT_CM_REDIRECT_CM, the client can re-issue ibt_open_rc_channel setting
494  * new fields as follows:
495  *
496  * Update (ibt_chan_args_t)->oc_path based on path information returned
497  * from ibt_get_paths using the return data in
498  * (ibt_rc_returns_t)->rc_arej_info.ari_redirect_info.
499  *
500  * Set (ibt_chan_args_t)->oc_cm_redirect_info =
501  *    Returned (ibt_rc_returns_t)->rc_arej_info.ari_redirect_info.
502  * Set flags to IBT_OCHAN_REDIRECTED.
503  *
504  * Note:
505  *
506  * IBT_OCHAN_PORT_REDIRECTED flag cannot be used to specify a remote CM MAD
507  * address, that is on a different subnet than the RC connection itself.
508  *
509  * Not specified attributes should be set to "NULL" or "0".
510  */
511 typedef struct ibt_chan_open_args_s {
512 	ibt_path_info_t 	*oc_path;	/* Primary & Alternate */
513 	ibt_cm_handler_t 	oc_cm_handler;	/* cm_handler - required */
514 	void			*oc_cm_clnt_private;	/* First argument to */
515 							/* cm_handler */
516 	ibt_rnr_retry_cnt_t	oc_path_rnr_retry_cnt;
517 	uint8_t			oc_path_retry_cnt:3;
518 	uint8_t			oc_rdma_ra_out;
519 	uint8_t			oc_rdma_ra_in;
520 	ibt_priv_data_len_t	oc_priv_data_len;	/* Number of bytes of */
521 							/* REQ Private data */
522 	void			*oc_priv_data;		/* REQ private data */
523 	ibt_channel_hdl_t	oc_dup_channel; 	/* IBT_OCHAN_DUP */
524 	ibt_redirect_info_t	*oc_cm_redirect_info;	/* Redirect params */
525 							/* for port and CM */
526 							/* redirection */
527 	ibt_cep_path_t		*oc_cm_cep_path;	/* Optional Path for */
528 							/* CM MADs on */
529 							/* port redirection */
530 	ib_time_t		oc_cm_pkt_lt;		/* Pkt life time for */
531 							/* CM MADs */
532 	uint32_t		oc_opaque1:4;
533 	uint32_t		oc_opaque2:24;
534 	uint32_t		oc_opaque3;
535 	uint32_t		oc_opaque4;
536 } ibt_chan_open_args_t;
537 
538 
539 /*
540  * Define an optional RC return arguments structure. This contains return
541  * parameters from ibt_open_rc_channel() when called in BLOCKING mode.
542  *
543  * rc_priv_data should be NULL or point to a buffer allocated by the caller,
544  * the size of which should be in rc_priv_data_len, where rc_priv_data_len <=
545  * IBT_REP_PRIV_DATA_SZ.
546  */
547 typedef struct ibt_rc_returns_s {
548 	uint8_t			rc_rdma_ra_in;	/* Arbitrated resp resources */
549 	uint8_t			rc_rdma_ra_out;	/* Arbitrated initiator depth */
550 	ibt_arej_info_t		rc_arej_info;
551 	ibt_cm_reason_t		rc_status;
552 	uint8_t			rc_failover_status;	/* Failover status */
553 	ibt_priv_data_len_t	rc_priv_data_len;
554 	void			*rc_priv_data;
555 } ibt_rc_returns_t;
556 
557 /*
558  * Define a callback function that can be used in Non-Blocking calls to
559  * ibt_recycle_rc().
560  */
561 
562 typedef	void	(*ibt_recycle_handler_t)(ibt_status_t ibt_status, void *arg);
563 
564 /*
565  * Define an optional return arguments structure from ibt_set_alt_path()
566  * This contains return parameters, when called in BLOCKING mode.
567  *
568  * ap_priv_data should be NULL or point to a buffer allocated by the caller,
569  * the size of which should be in ap_priv_data_len, where ap_priv_data_len <=
570  * IBT_APR_PRIV_DATA_SZ.
571  * The private data from APR is returned in ap_priv_data.
572  * The caller specifies amount of APR private data to be returned in
573  * ap_priv_data_len.
574  */
575 typedef struct ibt_ap_returns_s {
576 	ibt_ap_status_t		ap_status;
577 	boolean_t		ap_arej_info_valid;
578 	ibt_arej_info_t		ap_arej_info;	/* Only valid if redirect */
579 	ibt_priv_data_len_t	ap_priv_data_len;
580 	void			*ap_priv_data;
581 } ibt_ap_returns_t;
582 
583 /*
584  * UD remote destination attributes.
585  *
586  * ud_sid, ud_addr, ud_pkt_lt and ud_pkey_ix must be specified.
587  * These values can be as returned in an ibt_path_info_t struct from an
588  * ibt_get_paths() call.
589  *
590  * ud_priv_data should be NULL or point to a buffer allocated by the caller,
591  * the size of which is in ud_priv_data_len, where ud_priv_data_len <=
592  * IBT_SIDR_REQ_PRIV_DATA_SZ.
593  */
594 typedef struct ibt_ud_dest_attr_s {
595 	ib_svc_id_t		ud_sid;		/* Service ID */
596 	ibt_adds_vect_t		*ud_addr;	/* Address Info */
597 	uint16_t		ud_pkey_ix;	/* Pkey Index */
598 	ib_time_t		ud_pkt_lt;
599 	ibt_cm_ud_handler_t	ud_cm_handler;	/* An optional CM UD event */
600 						/* which must be NULL */
601 						/* if not specified. */
602 	void			*ud_cm_private; /* First arg to ud_cm_handler */
603 	ibt_priv_data_len_t	ud_priv_data_len;
604 	void			*ud_priv_data;	/* SIDR REQ private data */
605 } ibt_ud_dest_attr_t;
606 
607 /*
608  * Define an optional UD return arguments structure.
609  *
610  * ud_priv_data should be NULL or point to a buffer allocated by the caller,
611  * the size of which should be in ud_priv_data_len, where ud_priv_data_len <=
612  * IBT_SIDR_REP_PRIV_DATA_SZ.
613  */
614 typedef struct ibt_ud_returns_s {
615 	ibt_sidr_status_t	ud_status;
616 	ibt_redirect_info_t	ud_redirect;
617 	ib_qpn_t		ud_dqpn;	/* Returned destination QPN */
618 	ib_qkey_t		ud_qkey;	/* Q_Key for destination QPN */
619 	ibt_priv_data_len_t	ud_priv_data_len;
620 	void			*ud_priv_data;
621 } ibt_ud_returns_t;
622 
623 /*
624  * Multicast group attributes
625  * Not specified attributes should be set to "NULL" or "0".
626  * Used by ibt_join_mcg()/ibt_query_mcg().
627  *
628  * mc_qkey, mc_pkey, mc_flow, mc_tclass, mc_sl, mc_join_state are required for
629  * create - ibt_join_mcg().
630  */
631 typedef struct ibt_mcg_attr_s {
632 	ib_gid_t		mc_mgid;	/* MGID */
633 	ib_gid_t		mc_pgid;	/* SGID of the end port being */
634 						/* added to the MCG. */
635 	ib_qkey_t		mc_qkey;	/* Q_Key */
636 	ib_pkey_t		mc_pkey;	/* Partition key for this MCG */
637 	ibt_mtu_req_t		mc_mtu_req;	/* MTU */
638 	ibt_srate_req_t		mc_rate_req;	/* Static rate */
639 	ibt_pkt_lt_req_t	mc_pkt_lt_req;	/* Packet Life Time Request */
640 	uint_t			mc_flow:20;	/* FlowLabel. */
641 	uint8_t			mc_hop;		/* HopLimit */
642 	uint8_t			mc_tclass;	/* Traffic Class. */
643 	uint8_t			mc_sl:4;	/* Service Level */
644 	uint8_t			mc_scope:4,	/* Multicast Address Scope */
645 				mc_join_state:4; /* FULL For create */
646 	ib_lid_t		mc_opaque1;
647 } ibt_mcg_attr_t;
648 
649 /*
650  * Multicast group attributes.
651  * returned by ibt_join_mcg()/ibt_query_mcg().
652  */
653 typedef struct ibt_mcg_info_s {
654 	ibt_adds_vect_t		mc_adds_vect;   /* Address information */
655 	ib_mtu_t		mc_mtu;		/* MTU */
656 	ib_qkey_t		mc_qkey;	/* Q_Key */
657 	uint16_t		mc_pkey_ix;	/* Pkey Index */
658 	uint8_t			mc_scope:4;	/* Multicast Address Scope */
659 	clock_t			mc_opaque2;
660 } ibt_mcg_info_t;
661 
662 /*
663  * Define a callback function that can be used in Non-Blocking calls to
664  * ibt_join_mcg().
665  */
666 typedef void (*ibt_mcg_handler_t)(void *arg, ibt_status_t retval,
667     ibt_mcg_info_t *mcg_info_p);
668 
669 
670 /*
671  * Service Flags - sd_flags
672  *
673  *    IBT_SRV_PEER_TYPE_SID	Peer-to-peer Service IDs.
674  */
675 
676 typedef enum ibt_service_flags_e {
677 	IBT_SRV_NO_FLAGS	= 0x0,
678 	IBT_SRV_PEER_TYPE_SID	= 0x1
679 } ibt_service_flags_t;
680 
681 /*
682  * Define a Service ID Registration structure.
683  */
684 typedef struct ibt_srv_desc_s {
685 	ibt_cm_ud_handler_t	sd_ud_handler;	/* UD Service Handler */
686 	ibt_cm_handler_t	sd_handler;	/* Non-UD Service Handler */
687 	ibt_service_flags_t	sd_flags;	/* Flags */
688 } ibt_srv_desc_t;
689 
690 /*
691  * Flag to indicate ibt_bind_service() to or NOT-to clean-up Stale matching
692  * Local Service Records with SA prior to binding the new request.
693  */
694 #define	IBT_SBIND_NO_FLAGS	0
695 #define	IBT_SBIND_NO_CLEANUP	1
696 
697 /*
698  * Define a Service ID Binding structure (data for service records).
699  */
700 typedef struct ibt_srv_bind_s {
701 	uint64_t	sb_key[2];	/* Service Key */
702 	char		*sb_name;	/* Service Name (up to 63 chars) */
703 	uint32_t	sb_lease;	/* Service Lease period (in seconds) */
704 	ib_pkey_t	sb_pkey;	/* Service P_Key */
705 	ibt_srv_data_t	sb_data;	/* Service Data */
706 	uint_t		sb_flag;	/* indicates to/not-to clean-up stale */
707 					/* matching local service records. */
708 } ibt_srv_bind_t;
709 
710 /*
711  * ibt_cm_delay() flags.
712  *
713  * Refer to InfiniBand Architecture Release Volume 1 Rev 1.0a:
714  * Section 12.6.6 MRA
715  */
716 typedef enum ibt_cmdelay_flags_e {
717 	IBT_CM_DELAY_REQ	= 0,
718 	IBT_CM_DELAY_REP	= 1,
719 	IBT_CM_DELAY_LAP	= 2
720 } ibt_cmdelay_flags_t;
721 
722 /*
723  * The payload for DDI events passed on IB_PROP_UPDATE_EVENT.
724  * This is passed as the bus nexus data to event_handler(9e).
725  */
726 typedef struct ibt_prop_update_payload_s {
727 	union {
728 		struct {
729 			uint32_t	srv_updated:1;
730 			uint32_t	gid_updated:1;
731 		} _ib_prop_update_struct;
732 		uint32_t	prop_updated;
733 	} _ib_prop_update_union;
734 	ibt_status_t		ib_reprobe_status;
735 
736 #define	ib_srv_prop_updated	\
737     _ib_prop_update_union._ib_prop_update_struct.srv_updated
738 #define	ib_gid_prop_updated	\
739     _ib_prop_update_union._ib_prop_update_struct.gid_updated
740 #define	ib_prop_updated		\
741     _ib_prop_update_union.prop_updated
742 } ibt_prop_update_payload_t;
743 
744 
745 /*
746  * FUNCTION PROTOTYPES.
747  */
748 
749 /*
750  * ibt_attach() and ibt_detach():
751  *	These are the calls into IBTF used during client driver attach() and
752  *	detach().
753  *
754  *	The IBTF returns an ibt_clnt_hdl_t to the client. This handle is used
755  *	to identify this client device in all subsequent calls into the IBTF.
756  *
757  *	The ibt_detach() routine is called from a client driver's detach()
758  *	routine to deregister itself from the IBTF.
759  */
760 ibt_status_t ibt_attach(ibt_clnt_modinfo_t *mod_infop, dev_info_t *arg,
761     void *clnt_private, ibt_clnt_hdl_t *ibt_hdl_p);
762 
763 ibt_status_t ibt_detach(ibt_clnt_hdl_t ibt_hdl);
764 
765 /*
766  * HCA FUNCTIONS
767  */
768 
769 /*
770  * ibt_get_hca_list()
771  *	Returns the number of HCAs in a system and their node GUIDS.
772  *
773  *	If hca_list_p is not NULL then the memory for the array of GUIDs is
774  *	allocated by the IBTF and should be freed by the caller using
775  *	ibt_free_hca_list(). If hca_list_p is NULL then no memory is allocated
776  *	by ibt_get_hca_list and only the number of HCAs in a system is returned.
777  *
778  *	It is assumed that the caller can block in kmem_alloc.
779  *
780  * ibt_free_hca_list()
781  *	Free the memory allocated by ibt_get_hca_list().
782  */
783 uint_t ibt_get_hca_list(ib_guid_t **hca_list_p);
784 
785 void ibt_free_hca_list(ib_guid_t *hca_list, uint_t entries);
786 
787 /*
788  * ibt_open_hca()	- Open/Close a HCA. HCA can only be opened/closed
789  * ibt_close_hca()	  once. ibt_open_hca() takes a client's ibt handle
790  *			  and a GUID and returns a unique IBT client HCA
791  *			  handle.
792  *
793  * These routines can not be called from interrupt context.
794  */
795 ibt_status_t ibt_open_hca(ibt_clnt_hdl_t ibt_hdl, ib_guid_t hca_guid,
796     ibt_hca_hdl_t *hca_hdl);
797 
798 ibt_status_t ibt_close_hca(ibt_hca_hdl_t hca_hdl);
799 
800 
801 /*
802  * ibt_query_hca()
803  * ibt_query_hca_byguid()
804  * 	Returns the static attributes of the specified HCA
805  */
806 ibt_status_t ibt_query_hca(ibt_hca_hdl_t hca_hdl, ibt_hca_attr_t *hca_attrs);
807 
808 ibt_status_t ibt_query_hca_byguid(ib_guid_t hca_guid,
809     ibt_hca_attr_t *hca_attrs);
810 
811 
812 /*
813  * ibt_query_hca_ports()
814  * ibt_query_hca_ports_byguid()
815  *	Returns HCA port/ports attributes for the specified HCA port/ports.
816  *	ibt_query_hca_ports() allocates the memory required for the
817  *	ibt_hca_portinfo_t struct as well as the memory required for the SGID
818  *	and P_Key tables contained within that struct.
819  *
820  * ibt_free_portinfo()
821  *	Frees the memory allocated for a specified ibt_hca_portinfo_t struct.
822  */
823 ibt_status_t ibt_query_hca_ports(ibt_hca_hdl_t hca_hdl, uint8_t port,
824     ibt_hca_portinfo_t **port_info_p, uint_t *ports_p, uint_t *size_p);
825 
826 ibt_status_t ibt_query_hca_ports_byguid(ib_guid_t hca_guid, uint8_t port,
827     ibt_hca_portinfo_t **port_info_p, uint_t *ports_p, uint_t *size_p);
828 
829 void ibt_free_portinfo(ibt_hca_portinfo_t *port_info, uint_t size);
830 
831 /*
832  * ibt_set_hca_private()	- Set/get the client private data.
833  * ibt_get_hca_private()
834  */
835 void ibt_set_hca_private(ibt_hca_hdl_t hca_hdl, void *clnt_private);
836 void *ibt_get_hca_private(ibt_hca_hdl_t hca_hdl);
837 
838 /*
839  * ibt_hca_handle_to_guid()
840  *	A helper function to retrieve HCA GUID for the specified handle.
841  *	Returns HCA GUID on which the specified Channel is allocated. Valid
842  *	if it is non-NULL on return.
843  */
844 ib_guid_t ibt_hca_handle_to_guid(ibt_hca_hdl_t hca);
845 
846 /*
847  * ibt_hca_guid_to_handle()
848  *	A helper function to retrieve a hca handle from a HCA GUID.
849  */
850 ibt_status_t ibt_hca_guid_to_handle(ibt_clnt_hdl_t ibt_hdl, ib_guid_t hca_guid,
851     ibt_hca_hdl_t *hca_hdl);
852 
853 /*
854  * CONNECTION ESTABLISHMENT/TEAR DOWN FUNCTIONS.
855  */
856 
857 /*
858  * ibt_get_paths
859  *	Finds the best path to a specified destination (as determined by the
860  *	IBTL) that satisfies the requirements specified in an ibt_path_attr_t
861  *	struct.
862  */
863 ibt_status_t ibt_get_paths(ibt_clnt_hdl_t ibt_hdl, ibt_path_flags_t flags,
864     ibt_path_attr_t *attr, uint8_t max_paths, ibt_path_info_t *paths,
865     uint8_t *num_paths_p);
866 
867 
868 /*
869  * Callback function that can be used in ibt_aget_paths(), a Non-Blocking
870  * version of ibt_get_paths().
871  */
872 typedef void (*ibt_path_handler_t)(void *arg, ibt_status_t retval,
873     ibt_path_info_t *paths, uint8_t num_paths);
874 
875 /*
876  * Find path(s) to a given destination or service asynchronously.
877  * ibt_aget_paths() is a Non-Blocking version of ibt_get_paths().
878  */
879 ibt_status_t ibt_aget_paths(ibt_clnt_hdl_t ibt_hdl, ibt_path_flags_t flags,
880     ibt_path_attr_t *attr, uint8_t max_paths, ibt_path_handler_t func,
881     void  *arg);
882 
883 /*
884  * ibt_get_alt_path
885  *	Finds the best alternate path to a specified channel (as determined by
886  *	the IBTL) that satisfies the requirements specified in an
887  *	ibt_alt_path_attr_t struct.  The specified channel must have been
888  *	previously opened successfully using ibt_open_rc_channel.
889  */
890 ibt_status_t ibt_get_alt_path(ibt_channel_hdl_t chan, ibt_path_flags_t flags,
891     ibt_alt_path_attr_t *attr, ibt_alt_path_info_t *alt_path);
892 
893 /*
894  * ibt_open_rc_channel
895  * 	ibt_open_rc_channel() opens a previously allocated RC communication
896  *	channel. The IBTL initiates the channel establishment protocol.
897  */
898 ibt_status_t ibt_open_rc_channel(ibt_channel_hdl_t rc_chan,
899     ibt_chan_open_flags_t flags, ibt_execution_mode_t mode,
900     ibt_chan_open_args_t *args, ibt_rc_returns_t *returns);
901 
902 /*
903  * ibt_close_rc_channel
904  *	Close the specified channel. Outstanding work requests are flushed
905  *	so that the client can do the associated clean up. After that, the
906  *	client will usually deregister the previously registered memory,
907  *	then free the channel by calling ibt_free_rc_channel().
908  *
909  *	This function will reuse CM event Handler provided in
910  *	ibt_open_rc_channel().
911  */
912 ibt_status_t ibt_close_rc_channel(ibt_channel_hdl_t rc_chan,
913     ibt_execution_mode_t mode, void *priv_data,
914     ibt_priv_data_len_t priv_data_len, uint8_t *ret_status,
915     void *ret_priv_data, ibt_priv_data_len_t *ret_priv_data_len_p);
916 
917 /*
918  * ibt_prime_close_rc_channel
919  *
920  *	Allocates resources required for a close rc channel operation.
921  *	Calling ibt_prime_close_rc_channel() allows a channel to be
922  *	subsequently closed in interrupt context.
923  *
924  *	A call is first made to ibt_prime_close_rc_channel in non-interrupt
925  *	context, followed by ibt_close_rc_channel in non-blocking mode from
926  *	interrupt context
927  *
928  *	ibt_prime_close_rc_channel() can only be called on a previously opened
929  *	channel.
930  */
931 ibt_status_t ibt_prime_close_rc_channel(ibt_channel_hdl_t rc_chan);
932 
933 /*
934  * ibt_recycle_rc
935  *
936  *      Recycle a RC channel which has transitioned to Error state. The
937  *      ibt_recycle_rc() function transitions the channel from Error
938  *      state (IBT_STATE_ERROR) to the state ready for use by
939  *      ibt_open_rc_channel. Basically, this function is very similar to
940  *      ibt_alloc_rc_channel, but reuses an existing RC channel.
941  *
942  * Clients are allowed to make resource clean up/free calls in the CM handler
943  *
944  * Client(s) must not invoke blocking version (ie., func specified as NULL) of
945  * ibt_recycle_rc from cm callback for IBT_CM_EVENT_CONN_CLOSED
946  *
947  * Clients are strongly advised not to issue blocking calls from  func, as this
948  * would block the CM threads, and could delay or block other client connections
949  * and ibtl related API invocations.
950  */
951 ibt_status_t ibt_recycle_rc(ibt_channel_hdl_t rc_chan, ibt_cep_flags_t control,
952     uint8_t hca_port_num, ibt_recycle_handler_t func, void *arg);
953 
954 /*
955  * ibt_recycle_ud
956  *
957  *      Recycle a UD channel which has transitioned to Error state. The
958  *      ibt_recycle_ud() function transitions the channel from Error
959  *      state (IBT_STATE_ERROR) to a usable state (IBT_STATE_RTS).
960  *      Basically, this function is very similar to ibt_alloc_ud_channel,
961  *	but reuses an existing UD channel.
962  */
963 ibt_status_t ibt_recycle_ud(ibt_channel_hdl_t ud_chan, uint8_t hca_port_num,
964     uint16_t pkey_ix, ib_qkey_t qkey);
965 
966 /*
967  * MODIFY CHANNEL ATTRIBUTE FUNCTIONs.
968  */
969 
970 /*
971  * ibt_pause_sendq
972  * ibt_unpause_sendq
973  *	Place the send queue of the specified channel into the send queue
974  *	drained state.
975  *	Applicable for both RC and UD channels.
976  */
977 ibt_status_t ibt_pause_sendq(ibt_channel_hdl_t chan,
978     ibt_cep_modify_flags_t modify_flags);
979 
980 ibt_status_t ibt_unpause_sendq(ibt_channel_hdl_t chan);
981 
982 /*
983  * ibt_resize_queues()
984  *	Resize the SendQ/RecvQ sizes of a channel.
985  *
986  *	Applicable for both RC and UD channels.
987  */
988 ibt_status_t ibt_resize_queues(ibt_channel_hdl_t chan, ibt_qflags_t flags,
989     ibt_queue_sizes_t *request_sz, ibt_queue_sizes_t *actual_sz);
990 
991 /*
992  * ibt_query_queues()
993  *
994  *	Query the SendQ/RecvQ sizes of a channel.
995  *	Applicable for both RC and UD channels.
996  */
997 ibt_status_t ibt_query_queues(ibt_channel_hdl_t chan,
998     ibt_queue_sizes_t *actual_sz);
999 
1000 /*
1001  * ibt_modify_rdma
1002  *	Enable/disable RDMA operations.
1003  *
1004  *	Applicable for RC channels only.
1005  */
1006 ibt_status_t ibt_modify_rdma(ibt_channel_hdl_t rc_chan,
1007     ibt_cep_modify_flags_t modify_flags, ibt_cep_flags_t flags);
1008 
1009 
1010 /*
1011  * ibt_set_rdma_resource
1012  *	Change the number of resources to be used for incoming and outgoing
1013  *	RDMA reads & Atomics.
1014  */
1015 ibt_status_t ibt_set_rdma_resource(ibt_channel_hdl_t rc_chan,
1016     ibt_cep_modify_flags_t modify_flags, uint8_t rdma_ra_out,
1017     uint8_t rdma_ra_in);
1018 
1019 /*
1020  * ibt_change_port
1021  *	Change the primary physical port of an RC channel. (This is done only
1022  *	if HCA supports this capability).  Can only be called on a paused
1023  *	channel.
1024  *	Applicable for RC channels only.
1025  */
1026 ibt_status_t ibt_change_port(ibt_channel_hdl_t rc_chan, uint8_t port_num);
1027 
1028 
1029 /*
1030  * SERVICE REGISTRATION FUNCTIONS
1031  */
1032 
1033 /*
1034  * ibt_register_service()
1035  * ibt_deregister_service()
1036  *	Register/deregister a Service (range of Service IDs) with the IBTF.
1037  *
1038  * ibt_bind_service()
1039  * ibt_unbind_service()
1040  * ibt_unbind_all_services()
1041  *	Bind a Service to a given port (GID), and optionally create
1042  *	service record(s) with the SA for ibt_get_paths() to find.
1043  */
1044 ibt_status_t ibt_register_service(ibt_clnt_hdl_t ibt_hdl,
1045     ibt_srv_desc_t *service, ib_svc_id_t sid, int num_sids,
1046     ibt_srv_hdl_t *srv_hdl_p, ib_svc_id_t *ret_sid_p);
1047 
1048 ibt_status_t ibt_deregister_service(ibt_clnt_hdl_t ibt_hdl,
1049     ibt_srv_hdl_t srv_hdl);
1050 
1051 ibt_status_t ibt_bind_service(ibt_srv_hdl_t srv_hdl, ib_gid_t gid,
1052     ibt_srv_bind_t *srv_bind, void *cm_private, ibt_sbind_hdl_t *sb_hdl_p);
1053 
1054 ibt_status_t ibt_unbind_service(ibt_srv_hdl_t srv_hdl, ibt_sbind_hdl_t sb_hdl);
1055 ibt_status_t ibt_unbind_all_services(ibt_srv_hdl_t srv_hdl);
1056 
1057 /*
1058  * ibt_cm_delay
1059  *	A client CM handler/srv_handler function can call this function to
1060  *	extend its response time to a CM event.
1061  *	Applicable for RC channels only.
1062  */
1063 ibt_status_t ibt_cm_delay(ibt_cmdelay_flags_t flags, void *cm_session_id,
1064     clock_t service_time, void *priv_data, ibt_priv_data_len_t priv_data_len);
1065 
1066 /*
1067  * ibt_cm_proceed
1068  *
1069  * An IBT client calls ibt_cm_proceed() to proceed with a connection that
1070  * previously deferred by the client returning IBT_CM_DEFER on a CM handler
1071  * callback. CM events that can be deferred and continued with ibt_cm_proceed()
1072  * are REQ_RCV, REP_RCV, LAP_RCV, and DREQ_RCV.
1073  *
1074  * NOTE :
1075  *
1076  * Typically CM completes processing of a client's CM handler return, with
1077  * IBT_CM_DEFER status, before  processing of the corresponding ibt_cm_proceed()
1078  * is started. However a race exists where by CM may not have completed the
1079  * client's handler return processing when ibt_cm_proceed() is called by a
1080  * client. In this case ibt_cm_proceed() will block until processing of the
1081  * client's CM handler return is complete.
1082  *
1083  * A client that returns IBT_CM_DEFER from the cm handler must
1084  * subsequently make a call to ibt_cm_proceed(). It is illegal to call
1085  * ibt_cm_proceed() on a channel that has not had the connection
1086  * establishment deferred.
1087  *
1088  * Client cannot call ibt_cm_proceed from the cm handler.
1089  */
1090 ibt_status_t ibt_cm_proceed(ibt_cm_event_type_t event, void *session_id,
1091     ibt_cm_status_t status, ibt_cm_proceed_reply_t *cm_event_data,
1092     void *priv_data, ibt_priv_data_len_t priv_data_len);
1093 
1094 /*
1095  * ibt_cm_ud_proceed
1096  *
1097  * An IBT client calls ibt_cm_ud_proceed() to proceed with an
1098  * IBT_CM_UD_EVENT_SIDR_REQ  UD event that was previously deferred by the
1099  * client returning IBT_CM_DEFER on a CM UD handler callback.
1100  * NOTE :
1101  *
1102  * Typically CM completes processing of a client's CM handler return, with
1103  * IBT_CM_DEFER status, before  processing of the corresponding
1104  * ibt_cm_ud_proceed() is started. However a race exists where by CM may not
1105  * have completed the client's handler return processing when
1106  * ibt_cm_ud_proceed() is called by a client. In this case ibt_cm_ud_proceed()
1107  * will block until processing of the client's CM handler return is complete.
1108  *
1109  * A client that returns IBT_CM_DEFER from the cm handler must
1110  * subsequently make a call to ibt_cm_ud_proceed(). It is illegal to call
1111  * ibt_cm_ud_proceed() on a channel that has not had the connection
1112  * establishment deferred.
1113  *
1114  * Client cannot call ibt_cm_ud_proceed from the cm handler.
1115  */
1116 ibt_status_t ibt_cm_ud_proceed(void *session_id, ibt_channel_hdl_t ud_channel,
1117     ibt_cm_status_t status, ibt_redirect_info_t *redirect_infop,
1118     void *priv_data, ibt_priv_data_len_t priv_data_len);
1119 
1120 
1121 /*
1122  * COMPLETION QUEUES.
1123  *
1124  * ibt_alloc_cq_sched()
1125  *	Reserve CQ scheduling class resources
1126  *
1127  * ibt_free_cq_sched()
1128  *	Free CQ scheduling class resources
1129  */
1130 ibt_status_t ibt_alloc_cq_sched(ibt_hca_hdl_t hca_hdl,
1131     ibt_cq_sched_attr_t *attr, ibt_sched_hdl_t *sched_hdl_p);
1132 
1133 ibt_status_t ibt_free_cq_sched(ibt_hca_hdl_t hca_hdl,
1134     ibt_sched_hdl_t sched_hdl, uint_t load);
1135 
1136 /*
1137  * ibt_alloc_cq()
1138  *	Allocate a completion queue.
1139  */
1140 ibt_status_t ibt_alloc_cq(ibt_hca_hdl_t hca_hdl, ibt_cq_attr_t *cq_attr,
1141     ibt_cq_hdl_t *ibt_cq_p, uint_t *real_size);
1142 
1143 /*
1144  * ibt_free_cq()
1145  *	Free allocated CQ resources.
1146  */
1147 ibt_status_t ibt_free_cq(ibt_cq_hdl_t ibt_cq);
1148 
1149 
1150 /*
1151  * ibt_enable_cq_notify()
1152  *	Enable notification requests on the specified CQ.
1153  *	Applicable for both RC and UD channels.
1154  *
1155  *	Completion notifications are disabled by setting the completion
1156  *	handler to NULL by calling ibt_set_cq_handler().
1157  */
1158 ibt_status_t ibt_enable_cq_notify(ibt_cq_hdl_t ibt_cq,
1159     ibt_cq_notify_flags_t notify_type);
1160 
1161 /*
1162  * ibt_set_cq_handler()
1163  *	Register a work request completion handler with the IBTF.
1164  *	Applicable for both RC and UD channels.
1165  *
1166  *	Completion notifications are disabled by setting the completion
1167  *	handler to NULL. When setting the handler to NULL, no additional
1168  *	calls to the CQ handler will be initiated.
1169  *
1170  *	This function does not otherwise change the state of previous
1171  *	calls to ibt_enable_cq_notify().
1172  */
1173 void ibt_set_cq_handler(ibt_cq_hdl_t ibt_cq,
1174     ibt_cq_handler_t completion_handler, void *arg);
1175 
1176 /*
1177  * ibt_poll_cq()
1178  *	Poll the specified CQ for the completion of work requests (WRs).
1179  *	If the CQ contains completed WRs, up to num_wc of them are returned.
1180  *	Applicable for both RC and UD channels.
1181  */
1182 ibt_status_t ibt_poll_cq(ibt_cq_hdl_t ibt_cq, ibt_wc_t *work_completions,
1183     uint_t num_wc, uint_t *num_polled);
1184 
1185 /*
1186  * ibt_query_cq()
1187  *	Return the total number of entries in the CQ.
1188  */
1189 ibt_status_t ibt_query_cq(ibt_cq_hdl_t ibt_cq, uint_t *entries);
1190 
1191 /*
1192  * ibt_resize_cq()
1193  *	Change the size of a CQ.
1194  */
1195 ibt_status_t ibt_resize_cq(ibt_cq_hdl_t ibt_cq, uint_t new_sz, uint_t *real_sz);
1196 
1197 /*
1198  * ibt_set_cq_private()
1199  * ibt_get_cq_private()
1200  *	Set/get the client private data.
1201  */
1202 void ibt_set_cq_private(ibt_cq_hdl_t ibt_cq, void *clnt_private);
1203 void *ibt_get_cq_private(ibt_cq_hdl_t ibt_cq);
1204 
1205 
1206 /*
1207  * Memory Management Functions.
1208  *	Applicable for both RC and UD channels.
1209  *
1210  * ibt_register_mr()
1211  * 	Prepares a virtually addressed memory region for use by a HCA. A
1212  *	description of the registered memory suitable for use in Work Requests
1213  *	(WRs) is returned in the ibt_mr_desc_t parameter.
1214  *
1215  * ibt_register_buf()
1216  * 	Prepares a memory region described by a buf(9S) struct for use by a
1217  *	HCA. A description of the registered memory suitable for use in
1218  *	Work Requests (WRs) is returned in the ibt_mr_desc_t parameter.
1219  *
1220  * ibt_query_mr()
1221  *	Retrieves information about a specified memory region.
1222  *
1223  * ibt_deregister_mr()
1224  *	Remove a memory region from a HCA translation table, and free all
1225  *	resources associated with the memory region.
1226  *
1227  * ibt_reregister_mr()
1228  * ibt_reregister_buf()
1229  *	Modify the attributes of an existing memory region.
1230  *
1231  * ibt_register_shared_mr()
1232  *	Given an existing memory region, a new memory region associated with
1233  *	the same physical locations is created.
1234  *
1235  * ibt_sync_mr()
1236  *	Sync a memory region for either RDMA reads or RDMA writes
1237  *
1238  * ibt_alloc_mw()
1239  *	Allocate a memory window.
1240  *
1241  * ibt_query_mw()
1242  *	Retrieves information about a specified memory window.
1243  *
1244  * ibt_free_mw()
1245  *	De-allocate the Memory Window.
1246  */
1247 ibt_status_t ibt_register_mr(ibt_hca_hdl_t hca_hdl, ibt_pd_hdl_t pd,
1248     ibt_mr_attr_t *mem_attr, ibt_mr_hdl_t *mr_hdl_p, ibt_mr_desc_t *mem_desc);
1249 
1250 ibt_status_t ibt_register_buf(ibt_hca_hdl_t hca_hdl, ibt_pd_hdl_t pd,
1251     ibt_smr_attr_t *mem_bpattr, struct buf *bp, ibt_mr_hdl_t *mr_hdl_p,
1252     ibt_mr_desc_t *mem_desc);
1253 
1254 ibt_status_t ibt_query_mr(ibt_hca_hdl_t hca_hdl, ibt_mr_hdl_t mr_hdl,
1255     ibt_mr_query_attr_t *attr);
1256 
1257 ibt_status_t ibt_deregister_mr(ibt_hca_hdl_t hca_hdl, ibt_mr_hdl_t mr_hdl);
1258 
1259 ibt_status_t ibt_reregister_mr(ibt_hca_hdl_t hca_hdl, ibt_mr_hdl_t mr_hdl,
1260     ibt_pd_hdl_t pd, ibt_mr_attr_t *mem_attr, ibt_mr_hdl_t *mr_hdl_p,
1261     ibt_mr_desc_t *mem_desc);
1262 
1263 ibt_status_t ibt_reregister_buf(ibt_hca_hdl_t hca_hdl, ibt_mr_hdl_t mr_hdl,
1264     ibt_pd_hdl_t pd, ibt_smr_attr_t *mem_bpattr, struct buf *bp,
1265     ibt_mr_hdl_t *mr_hdl_p, ibt_mr_desc_t *mem_desc);
1266 
1267 ibt_status_t ibt_register_shared_mr(ibt_hca_hdl_t hca_hdl, ibt_mr_hdl_t mr_hdl,
1268     ibt_pd_hdl_t pd, ibt_smr_attr_t *mem_sattr, ibt_mr_hdl_t *mr_hdl_p,
1269     ibt_mr_desc_t *mem_desc);
1270 
1271 ibt_status_t ibt_sync_mr(ibt_hca_hdl_t hca_hdl, ibt_mr_sync_t *mr_segments,
1272     size_t num_segments);
1273 
1274 ibt_status_t ibt_alloc_mw(ibt_hca_hdl_t hca_hdl, ibt_pd_hdl_t pd,
1275     ibt_mw_flags_t flags, ibt_mw_hdl_t *mw_hdl_p, ibt_rkey_t *rkey);
1276 
1277 ibt_status_t ibt_query_mw(ibt_hca_hdl_t hca_hdl, ibt_mw_hdl_t mw_hdl,
1278     ibt_mw_query_attr_t *mw_attr_p);
1279 
1280 ibt_status_t ibt_free_mw(ibt_hca_hdl_t hca_hdl, ibt_mw_hdl_t mw_hdl);
1281 
1282 /*
1283  * ibt_alloc_lkey()
1284  * 	Allocates physical buffer list resources for use in memory
1285  *	registrations.
1286  *
1287  *	Applicable for both RC and UD channels.
1288  */
1289 ibt_status_t ibt_alloc_lkey(ibt_hca_hdl_t hca_hdl, ibt_pd_hdl_t pd,
1290     ibt_lkey_flags_t flags, uint_t phys_buf_list_sz, ibt_mr_hdl_t *mr_p,
1291     ibt_pmr_desc_t *mem_desc_p);
1292 
1293 
1294 /*
1295  * Physical Memory Management Functions.
1296  *	Applicable for both RC and UD channels.
1297  *
1298  * ibt_register_phys_mr()
1299  *	Prepares a physically addressed memory region for use by a HCA.
1300  *
1301  * ibt_reregister_phys_mr()
1302  *	Modify the attributes of an existing memory region.
1303  */
1304 ibt_status_t ibt_register_phys_mr(ibt_hca_hdl_t hca_hdl, ibt_pd_hdl_t pd,
1305     ibt_pmr_attr_t *mem_pattr, ibt_mr_hdl_t *mr_hdl_p,
1306     ibt_pmr_desc_t *mem_desc_p);
1307 
1308 ibt_status_t ibt_reregister_phys_mr(ibt_hca_hdl_t hca_hdl, ibt_mr_hdl_t mr_hdl,
1309     ibt_pd_hdl_t pd, ibt_pmr_attr_t *mem_pattr, ibt_mr_hdl_t *mr_hdl_p,
1310     ibt_pmr_desc_t *mem_desc_p);
1311 
1312 
1313 /*
1314  * Address Translation.
1315  */
1316 
1317 /*
1318  * ibt_map_mem_area()
1319  *	Translate a kernel virtual address range into HCA physical addresses.
1320  *	A set of physical addresses, that can be used with "Reserved L_Key",
1321  *	register physical,  and "Fast Registration Work Request" operations
1322  *	is returned.
1323  */
1324 ibt_status_t ibt_map_mem_area(ibt_hca_hdl_t hca_hdl, ibt_va_attr_t *va_attrs,
1325     uint_t paddr_list_len, ibt_phys_buf_t *paddr_list_p, uint_t *num_paddr_p,
1326     size_t *paddr_bufsz_p, ib_memlen_t *paddr_offset_p, ibt_ma_hdl_t *ma_hdl_p);
1327 
1328 /*
1329  * ibt_unmap_mem_area()
1330  *	Un pin physical pages pinned during an ibt_map_mem_area() call.
1331  */
1332 ibt_status_t ibt_unmap_mem_area(ibt_hca_hdl_t hca_hdl, ibt_ma_hdl_t ma_hdl);
1333 
1334 /*
1335  * Work Request Functions
1336  *	Applicable for RC and UD channels.
1337  *
1338  * ibt_post_send()
1339  *	Post send work requests to the specified channel.
1340  *
1341  * ibt_post_recv()
1342  * ibt_post_srq()
1343  *	Post receive work requests to the specified channel.
1344  */
1345 ibt_status_t ibt_post_send(ibt_channel_hdl_t chan, ibt_send_wr_t *wr_list,
1346     uint_t num_wr, uint_t *posted);
1347 
1348 ibt_status_t ibt_post_recv(ibt_channel_hdl_t chan, ibt_recv_wr_t *wr_list,
1349     uint_t num_wr, uint_t *posted);
1350 
1351 ibt_status_t ibt_post_srq(ibt_srq_hdl_t srq, ibt_recv_wr_t *wr_list,
1352     uint_t num_wr, uint_t *posted);
1353 
1354 
1355 /*
1356  * Alternate Path Migration Functions.
1357  *	Applicable for RC channels only.
1358  *
1359  *
1360  * ibt_get_alt_path()
1361  *	Finds the best alternate path to a specified channel (as determined by
1362  *	the IBTL) that satisfies the requirements specified in an
1363  *	ibt_alt_path_attr_t struct.  The specified channel must have been
1364  *	previously opened successfully using ibt_open_rc_channel.
1365  *	This function also ensures that the service being accessed by the
1366  *	channel is available at the selected alternate port.
1367  *
1368  *	Note: The apa_dgid must be on the same destination channel adapter,
1369  *	if specified.
1370  *
1371  *
1372  * ibt_set_alt_path()
1373  *	Load the specified alternate path. Causes the CM to send an LAP message
1374  *	to the remote node. If successful, the local channel is updated with
1375  *	the new alternate path and the channel migration state is set to REARM.
1376  *	Can only be called on a previously opened RC channel. The channel must
1377  *	be either in RTS or paused state.
1378  *
1379  *
1380  * ibt_migrate_path()
1381  *	Force the CI to use the alternate path. The alternate path becomes
1382  *	the primary path. A new alternate path should be loaded and enabled.
1383  */
1384 ibt_status_t ibt_get_alt_path(ibt_channel_hdl_t rc_chan, ibt_path_flags_t flags,
1385     ibt_alt_path_attr_t *attr, ibt_alt_path_info_t *alt_pathp);
1386 
1387 ibt_status_t ibt_set_alt_path(ibt_channel_hdl_t rc_chan,
1388     ibt_execution_mode_t mode, ibt_alt_path_info_t *alt_pinfo, void *priv_data,
1389     ibt_priv_data_len_t priv_data_len, ibt_ap_returns_t *ret_args);
1390 
1391 ibt_status_t ibt_migrate_path(ibt_channel_hdl_t rc_chan);
1392 
1393 
1394 /*
1395  * Multicast group Functions.
1396  *	Applicable for UD channels only.
1397  */
1398 
1399 /*
1400  * ibt_attach_mcg()
1401  *	Attaches a UD channel to the specified multicast group. On successful
1402  *	completion, this channel will be provided with a copy of every
1403  *	multicast message addressed to the group specified by the MGID
1404  *	(mcg_info->mc_adds_vect.av_dgid) and received on the HCA port with
1405  *	which the channel is associated.
1406  */
1407 ibt_status_t ibt_attach_mcg(ibt_channel_hdl_t ud_chan,
1408     ibt_mcg_info_t *mcg_info);
1409 
1410 /*
1411  * ibt_detach_mcg()
1412  *	Detach the specified UD channel from the specified multicast group.
1413  */
1414 ibt_status_t ibt_detach_mcg(ibt_channel_hdl_t ud_chan,
1415     ibt_mcg_info_t *mcg_info);
1416 
1417 /*
1418  * ibt_join_mcg()
1419  *	Join a multicast group.  The first full member "join" causes the MCG
1420  *	to be created.
1421  */
1422 ibt_status_t ibt_join_mcg(ib_gid_t rgid, ibt_mcg_attr_t *mcg_attr,
1423     ibt_mcg_info_t *mcg_info_p,  ibt_mcg_handler_t func, void  *arg);
1424 
1425 /*
1426  * ibt_leave_mcg()
1427  *	The port associated with the port GID shall be removed from the
1428  *	multicast group specified by MGID (mc_gid) or from all the multicast
1429  *	groups of which it is a member if the MGID (mc_gid) is not specified
1430  *	(i.e. mc_gid.mgid_prefix must have 8-bits of 11111111 at the start of
1431  *	the GID to identify this as being a multicast GID).
1432  *
1433  *	The last full member to leave causes the destruction of the Multicast
1434  *	Group.
1435  */
1436 ibt_status_t ibt_leave_mcg(ib_gid_t rgid, ib_gid_t mc_gid, ib_gid_t port_gid,
1437     uint8_t mc_join_state);
1438 
1439 /*
1440  * ibt_query_mcg()
1441  *	Request information on multicast groups that match the parameters
1442  *	specified in mcg_attr. Information on each multicast group is returned
1443  *	to the caller in the form of an array of ibt_mcg_info_t.
1444  *	ibt_query_mcg() allocates the memory for this array and returns a
1445  *	pointer to the array (mcgs_p) and the number of entries in the array
1446  *	(entries_p). This memory should be freed by the client using
1447  *	ibt_free_mcg_info().
1448  */
1449 ibt_status_t ibt_query_mcg(ib_gid_t rgid, ibt_mcg_attr_t *mcg_attr,
1450     uint_t mcgs_max_num, ibt_mcg_info_t **mcgs_info_p, uint_t *entries_p);
1451 
1452 /*
1453  * ibt_free_mcg_info()
1454  *	Free the memory allocated by successful ibt_query_mcg()
1455  */
1456 void ibt_free_mcg_info(ibt_mcg_info_t *mcgs_info, uint_t entries);
1457 
1458 
1459 /*
1460  * ibt_register_subnet_notices()
1461  *	Register a handler to be called for subnet notifications.
1462  */
1463 void ibt_register_subnet_notices(ibt_clnt_hdl_t ibt_hdl,
1464     ibt_sm_notice_handler_t sm_notice_handler, void *private);
1465 
1466 
1467 /*
1468  * Protection Domain Functions.
1469  *
1470  * ibt_alloc_pd()
1471  * ibt_free_pd()
1472  * 	Allocate/Release a protection domain
1473  */
1474 ibt_status_t ibt_alloc_pd(ibt_hca_hdl_t hca_hdl, ibt_pd_flags_t flags,
1475     ibt_pd_hdl_t *pd);
1476 ibt_status_t ibt_free_pd(ibt_hca_hdl_t hca_hdl, ibt_pd_hdl_t pd);
1477 
1478 /*
1479  * P_Key to P_Key Index conversion Functions.
1480  *
1481  * ibt_pkey2index_byguid
1482  * ibt_pkey2index	Convert a P_Key into a P_Key index.
1483  *
1484  * ibt_index2pkey_byguid
1485  * ibt_index2pkey	Convert a P_Key Index into a P_Key.
1486  */
1487 ibt_status_t ibt_pkey2index(ibt_hca_hdl_t hca_hdl, uint8_t port_num,
1488     ib_pkey_t pkey, uint16_t *pkey_ix);
1489 
1490 ibt_status_t ibt_index2pkey(ibt_hca_hdl_t hca_hdl, uint8_t port_num,
1491     uint16_t pkey_ix, ib_pkey_t *pkey);
1492 
1493 ibt_status_t ibt_pkey2index_byguid(ib_guid_t hca_guid, uint8_t port_num,
1494     ib_pkey_t pkey, uint16_t *pkey_ix);
1495 
1496 ibt_status_t ibt_index2pkey_byguid(ib_guid_t hca_guid, uint8_t port_num,
1497     uint16_t pkey_ix, ib_pkey_t *pkey);
1498 
1499 /*
1500  *  ibt_ci_data_in()
1501  *
1502  *  Pass CI specific userland data for CI objects to the CI.
1503  */
1504 ibt_status_t ibt_ci_data_in(ibt_hca_hdl_t hca, ibt_ci_data_flags_t flags,
1505     ibt_object_type_t object, void *ibt_object_handle, void *data_p,
1506     size_t data_sz);
1507 
1508 /*
1509  *  ibt_ci_data_out()
1510  *
1511  *  Obtain CI specific userland data for CI objects.
1512  */
1513 ibt_status_t ibt_ci_data_out(ibt_hca_hdl_t hca, ibt_ci_data_flags_t flags,
1514     ibt_object_type_t object, void *ibt_object_handle, void *data_p,
1515     size_t data_sz);
1516 
1517 
1518 /*
1519  * Node Information.
1520  */
1521 
1522 /* Node type : n_node_type */
1523 #define	IBT_NODE_TYPE_CHANNEL_ADAPTER	1	/* HCA or TCA */
1524 #define	IBT_NODE_TYPE_SWITCH		2
1525 #define	IBT_NODE_TYPE_ROUTER		3
1526 
1527 typedef struct ibt_node_info_s {
1528 	ib_guid_t	n_sys_img_guid;	/* System Image GUID */
1529 	ib_guid_t	n_node_guid;	/* Node GUID */
1530 	ib_guid_t	n_port_guid;	/* Port GUID */
1531 	uint16_t	n_dev_id;	/* Device ID */
1532 	uint32_t	n_revision;	/* Device Revision */
1533 	uint32_t	n_vendor_id:24;	/* Device Vendor ID */
1534 	uint8_t		n_num_ports;	/* Number of ports on this node. */
1535 	uint8_t		n_port_num;	/* Port number. */
1536 	uint8_t		n_node_type;	/* Node type */
1537 	char		n_description[64]; /* NULL terminated ASCII string */
1538 } ibt_node_info_t;
1539 
1540 
1541 /*
1542  * ibt_gid_to_node_info()
1543  *	Retrieve node information for the specified GID.
1544  */
1545 ibt_status_t ibt_gid_to_node_info(ib_gid_t gid, ibt_node_info_t *node_info_p);
1546 
1547 /*
1548  * ibt_reprobe_dev
1549  *	Reprobe properties for IOC device node.
1550  */
1551 ibt_status_t	ibt_reprobe_dev(dev_info_t *dip);
1552 
1553 /*
1554  * ibt_get_companion_port_gids()
1555  *
1556  *	Get list of GID's available on a companion port(s) of the specified
1557  *	GID or list of GIDs available on a specified Node GUID/System Image
1558  *	GUID.
1559  */
1560 ibt_status_t ibt_get_companion_port_gids(ib_gid_t gid, ib_guid_t hca_guid,
1561     ib_guid_t sysimg_guid, ib_gid_t **gids_p, uint_t *num_gids_p);
1562 
1563 /*
1564  * SHARED RECEIVE QUEUE
1565  */
1566 
1567 
1568 /*
1569  * ibt_alloc_srq()
1570  *	Allocate a shared receive queue.
1571  */
1572 ibt_status_t ibt_alloc_srq(ibt_hca_hdl_t hca_hdl, ibt_srq_flags_t flags,
1573     ibt_pd_hdl_t pd, ibt_srq_sizes_t *sizes, ibt_srq_hdl_t *ibt_srq_p,
1574     ibt_srq_sizes_t *real_size_p);
1575 
1576 /*
1577  * ibt_free_srq()
1578  *	Free allocated SRQ resources.
1579  */
1580 ibt_status_t ibt_free_srq(ibt_srq_hdl_t ibt_srq);
1581 
1582 /*
1583  * ibt_query_srq()
1584  *	Query a shared receive queue.
1585  */
1586 ibt_status_t ibt_query_srq(ibt_srq_hdl_t ibt_srq, ibt_pd_hdl_t *pd_p,
1587     ibt_srq_sizes_t *sizes_p, uint_t *limit_p);
1588 
1589 /*
1590  * ibt_modify_srq()
1591  *	Modify a shared receive queue.
1592  */
1593 ibt_status_t ibt_modify_srq(ibt_srq_hdl_t ibt_srq, ibt_srq_modify_flags_t flags,
1594     uint_t size, uint_t limit, uint_t *real_size_p);
1595 
1596 /*
1597  * ibt_set_srq_private()
1598  * ibt_get_srq_private()
1599  *	Set/get the SRQ client private data.
1600  */
1601 void ibt_set_srq_private(ibt_srq_hdl_t ibt_srq, void *clnt_private);
1602 void *ibt_get_srq_private(ibt_srq_hdl_t ibt_srq);
1603 
1604 /*
1605  * ibt_check_failure()
1606  * 	Function to test for special case failures
1607  */
1608 ibt_failure_type_t ibt_check_failure(ibt_status_t status, uint64_t *reserved_p);
1609 
1610 
1611 /*
1612  * ibt_hw_is_present() returns 0 when there is no IB hardware actively
1613  * running.  This is primarily useful for modules like rpcmod which needs a
1614  * quick check to decide whether or not it should try to use InfiniBand.
1615  */
1616 int ibt_hw_is_present();
1617 
1618 
1619 /*
1620  * CONTRACT PRIVATE ONLY INTERFACES
1621  *
1622  * DO NOT USE THE FOLLOWING FUNCTIONS WITHOUT SIGNING THE CONTRACT
1623  * WITH IBTF GROUP.
1624  */
1625 
1626 /* Define an Address Record structure (data for ATS service records). */
1627 typedef struct ibt_ar_s {
1628 	ib_gid_t	ar_gid;		/* GID of local HCA port */
1629 	ib_pkey_t	ar_pkey;	/* P_Key valid on port of ar_gid */
1630 	uint8_t		ar_data[16];	/* Data affiliated with GID/P_Key */
1631 } ibt_ar_t;
1632 
1633 /*
1634  * ibt_register_ar()
1635  * ibt_deregister_ar()
1636  *	Register/deregister an Address Record with the SA.
1637  * ibt_query_ar()
1638  *	Query the SA for Address Records matching either GID/P_Key or Data.
1639  */
1640 ibt_status_t ibt_register_ar(ibt_clnt_hdl_t ibt_hdl, ibt_ar_t *arp);
1641 
1642 ibt_status_t ibt_deregister_ar(ibt_clnt_hdl_t ibt_hdl, ibt_ar_t *arp);
1643 
1644 ibt_status_t ibt_query_ar(ib_gid_t *sgid, ibt_ar_t *queryp, ibt_ar_t *resultp);
1645 
1646 
1647 /*
1648  * ibt_modify_system_image()
1649  * ibt_modify_system_image_byguid()
1650  *	Modify specified HCA's system image GUID.
1651  */
1652 ibt_status_t ibt_modify_system_image(ibt_hca_hdl_t hca_hdl, ib_guid_t sys_guid);
1653 
1654 ibt_status_t ibt_modify_system_image_byguid(ib_guid_t hca_guid,
1655     ib_guid_t sys_guid);
1656 
1657 
1658 /*
1659  * ibt_modify_port()
1660  * ibt_modify_port_byguid()
1661  *	Modify the specified port, or all ports attribute(s).
1662  */
1663 ibt_status_t ibt_modify_port(ibt_hca_hdl_t hca_hdl, uint8_t port,
1664     ibt_port_modify_flags_t flags, uint8_t init_type);
1665 
1666 ibt_status_t ibt_modify_port_byguid(ib_guid_t hca_guid, uint8_t port,
1667     ibt_port_modify_flags_t flags, uint8_t init_type);
1668 
1669 
1670 /*
1671  * ibt_get_port_state()
1672  * ibt_get_port_state_byguid()
1673  *	Return the most commonly requested attributes of an HCA port.
1674  *	If the link state is not IBT_PORT_ACTIVE, the other returned values
1675  *	are undefined.
1676  */
1677 ibt_status_t ibt_get_port_state(ibt_hca_hdl_t hca_hdl, uint8_t port,
1678     ib_gid_t *sgid_p, ib_lid_t *base_lid_p);
1679 
1680 ibt_status_t ibt_get_port_state_byguid(ib_guid_t hca_guid, uint8_t port,
1681     ib_gid_t *sgid_p, ib_lid_t *base_lid_p);
1682 
1683 
1684 /*
1685  * Fast Memory Registration (FMR).
1686  *
1687  * ibt_create_fmr_pool
1688  *	Not fast-path.
1689  *	ibt_create_fmr_pool() verifies that the HCA supports FMR and allocates
1690  *	and initializes an "FMR pool".  This pool contains state specific to
1691  *	this registration, including the watermark setting to determine when
1692  *	to sync, and the total number of FMR regions available within this pool.
1693  *
1694  * ibt_destroy_fmr_pool
1695  *	ibt_destroy_fmr_pool() deallocates all of the FMR regions in a specific
1696  *	pool.  All state and information regarding the pool are destroyed and
1697  *	returned as free space once again.  No more use of FMR regions in this
1698  *	pool are possible without a subsequent call to ibt_create_fmr_pool().
1699  *
1700  * ibt_flush_fmr_pool
1701  *	ibt_flush_fmr_pool forces a flush to occur.  At the client's request,
1702  *	any unmapped FMR regions (See 'ibt_deregister_mr())') are returned to
1703  *	a free state.  This function allows for an asynchronous cleanup of
1704  *	formerly used FMR regions.  Sync operation is also performed internally
1705  *	by HCA driver, when 'watermark' settings for the number of free FMR
1706  *	regions left in the "pool" is reached.
1707  *
1708  * ibt_register_physical_fmr
1709  *	ibt_register_physical_fmr() assigns a "free" entry from the FMR Pool.
1710  *	It first consults the "FMR cache" to see if this is a duplicate memory
1711  *	registration to something already in use.  If not, then a free entry
1712  *	in the "pool" is marked used.
1713  *
1714  * ibt_deregister_fmr
1715  *	The ibt_deregister_fmr un-maps the resources reserved from the FMR
1716  *	pool by ibt_register_physical_fmr().   The ibt_deregister_fmr() will
1717  *	mark the region as free in the FMR Pool.
1718  */
1719 ibt_status_t ibt_create_fmr_pool(ibt_hca_hdl_t hca_hdl, ibt_pd_hdl_t pd,
1720     ibt_fmr_pool_attr_t *fmr_params, ibt_fmr_pool_hdl_t *fmr_pool_p);
1721 
1722 ibt_status_t ibt_destroy_fmr_pool(ibt_hca_hdl_t hca_hdl,
1723     ibt_fmr_pool_hdl_t fmr_pool);
1724 
1725 ibt_status_t ibt_flush_fmr_pool(ibt_hca_hdl_t hca_hdl,
1726     ibt_fmr_pool_hdl_t fmr_pool);
1727 
1728 ibt_status_t ibt_register_physical_fmr(ibt_hca_hdl_t hca_hdl,
1729     ibt_fmr_pool_hdl_t fmr_pool, ibt_pmr_attr_t *mem_pattr,
1730     ibt_mr_hdl_t *mr_hdl_p, ibt_pmr_desc_t *mem_desc_p);
1731 
1732 ibt_status_t ibt_deregister_fmr(ibt_hca_hdl_t hca, ibt_mr_hdl_t mr_hdl);
1733 
1734 #ifdef __cplusplus
1735 }
1736 #endif
1737 
1738 #endif /* _SYS_IB_IBTL_IBTI_COMMON_H */
1739