xref: /onnv-gate/usr/src/uts/common/sys/ib/mgt/ibmf/ibmf.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #ifndef _SYS_IB_MGT_IBMF_IBMF_H
28*0Sstevel@tonic-gate #define	_SYS_IB_MGT_IBMF_IBMF_H
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate /*
33*0Sstevel@tonic-gate  * This file defines the IBMF client interface.
34*0Sstevel@tonic-gate  */
35*0Sstevel@tonic-gate 
36*0Sstevel@tonic-gate #ifdef __cplusplus
37*0Sstevel@tonic-gate extern "C" {
38*0Sstevel@tonic-gate #endif
39*0Sstevel@tonic-gate 
40*0Sstevel@tonic-gate #include <sys/note.h>
41*0Sstevel@tonic-gate #include <sys/ib/ib_types.h>
42*0Sstevel@tonic-gate #include <sys/ib/ib_pkt_hdrs.h>
43*0Sstevel@tonic-gate #include <sys/ib/mgt/ib_mad.h>
44*0Sstevel@tonic-gate #include <sys/ib/mgt/ibmf/ibmf_msg.h>
45*0Sstevel@tonic-gate #include <sys/ib/mgt/ibmf/ibmf_saa.h>
46*0Sstevel@tonic-gate #include <sys/ib/mgt/ibmf/ibmf_utils.h>
47*0Sstevel@tonic-gate 
48*0Sstevel@tonic-gate /* IBMF API function return values */
49*0Sstevel@tonic-gate #define	IBMF_SUCCESS			0	/* successful call */
50*0Sstevel@tonic-gate #define	IBMF_FAILURE			-1	/* ibmf internal error */
51*0Sstevel@tonic-gate #define	IBMF_PORT_IN_USE 		-2	/* class already registered */
52*0Sstevel@tonic-gate #define	IBMF_BAD_CLASS			-3	/* bad class specified */
53*0Sstevel@tonic-gate #define	IBMF_BAD_HANDLE			-4	/* bad ibmf handle */
54*0Sstevel@tonic-gate #define	IBMF_BAD_QP_HANDLE		-5	/* bad QP handle */
55*0Sstevel@tonic-gate #define	IBMF_BAD_NODE			-6	/* bad node specified to reg */
56*0Sstevel@tonic-gate #define	IBMF_BAD_PORT			-7	/* bad port specified to reg */
57*0Sstevel@tonic-gate #define	IBMF_BAD_PORT_STATE		-8	/* port in incorrect state */
58*0Sstevel@tonic-gate #define	IBMF_BAD_VERSION		-9	/* bad IBMF version */
59*0Sstevel@tonic-gate #define	IBMF_BAD_FLAGS			-10	/* bad IBMF flags */
60*0Sstevel@tonic-gate #define	IBMF_BAD_SIZE			-11	/* bad data size in message */
61*0Sstevel@tonic-gate #define	IBMF_BAD_RMPP_OPT		-12	/* more than one class used */
62*0Sstevel@tonic-gate #define	IBMF_BUSY			-13	/* resources held by client */
63*0Sstevel@tonic-gate #define	IBMF_NO_RESOURCES		-14	/* no resources */
64*0Sstevel@tonic-gate #define	IBMF_NOT_SUPPORTED		-15	/* function not supported */
65*0Sstevel@tonic-gate #define	IBMF_PARTIAL_TRANSFER		-16	/* excess response data */
66*0Sstevel@tonic-gate #define	IBMF_UNEXP_TRANS_RECVD		-17	/* unexpected trans received */
67*0Sstevel@tonic-gate #define	IBMF_TRANS_TIMEOUT		-18	/* transaction timed out */
68*0Sstevel@tonic-gate #define	IBMF_TRANS_FAILURE		-19	/* transaction failure */
69*0Sstevel@tonic-gate #define	IBMF_NO_MEMORY			-20	/* could not alloc memory */
70*0Sstevel@tonic-gate #define	IBMF_REQ_INVALID		-21	/* request was invalid */
71*0Sstevel@tonic-gate #define	IBMF_NO_RECORDS			-22	/* no records match query */
72*0Sstevel@tonic-gate #define	IBMF_TOO_MANY_RECORDS		-23	/* too many recs match query */
73*0Sstevel@tonic-gate #define	IBMF_INVALID_GID		-24	/* invalid gid in sa request */
74*0Sstevel@tonic-gate #define	IBMF_INSUFF_COMPS		-25	/* insufficient components */
75*0Sstevel@tonic-gate #define	IBMF_UNSUPP_METHOD		-26	/* unsupported method */
76*0Sstevel@tonic-gate #define	IBMF_UNSUPP_METHOD_ATTR		-27	/* unsupp. method/attrbute */
77*0Sstevel@tonic-gate #define	IBMF_INVALID_FIELD		-28	/* invalid field in MAD */
78*0Sstevel@tonic-gate #define	IBMF_INVALID_ARG		-29	/* invalid function argument */
79*0Sstevel@tonic-gate #define	IBMF_CB_REGISTERED		-30	/* callback already regd */
80*0Sstevel@tonic-gate #define	IBMF_CB_NOT_REGISTERED		-31	/* callback not registered */
81*0Sstevel@tonic-gate #define	IBMF_TRANSPORT_FAILURE		-32	/* a transport call failed */
82*0Sstevel@tonic-gate #define	IBMF_TID_IN_USE			-33	/* client's TID in use */
83*0Sstevel@tonic-gate 
84*0Sstevel@tonic-gate /* flags to ibmf_alloc_msg() */
85*0Sstevel@tonic-gate #define	IBMF_ALLOC_SLEEP		0
86*0Sstevel@tonic-gate #define	IBMF_ALLOC_NOSLEEP		1
87*0Sstevel@tonic-gate 
88*0Sstevel@tonic-gate /*
89*0Sstevel@tonic-gate  * IBMF version
90*0Sstevel@tonic-gate  */
91*0Sstevel@tonic-gate #define	IBMF_VERSION			1
92*0Sstevel@tonic-gate 
93*0Sstevel@tonic-gate typedef struct _ibmf_handle_dummy	*ibmf_handle_t;
94*0Sstevel@tonic-gate 
95*0Sstevel@tonic-gate typedef struct _ibmf_qp_dummy		*ibmf_qp_handle_t;
96*0Sstevel@tonic-gate 
97*0Sstevel@tonic-gate /*
98*0Sstevel@tonic-gate  * IBMF default QP handles
99*0Sstevel@tonic-gate  */
100*0Sstevel@tonic-gate #define	IBMF_QP_HANDLE_DEFAULT		(ibmf_qp_handle_t)0
101*0Sstevel@tonic-gate 
102*0Sstevel@tonic-gate /*
103*0Sstevel@tonic-gate  * ir_client_type
104*0Sstevel@tonic-gate  */
105*0Sstevel@tonic-gate typedef	enum _ibmf_client_type_t {
106*0Sstevel@tonic-gate 	SUBN_AGENT				= 0x00010001,
107*0Sstevel@tonic-gate 	SUBN_MANAGER				= 0x00020001,
108*0Sstevel@tonic-gate 	SUBN_ADM_AGENT				= 0x00010003,
109*0Sstevel@tonic-gate 	SUBN_ADM_MANAGER			= 0x00020003,
110*0Sstevel@tonic-gate 	PERF_AGENT				= 0x00010004,
111*0Sstevel@tonic-gate 	PERF_MANAGER				= 0x00020004,
112*0Sstevel@tonic-gate 	BM_AGENT				= 0x00010005,
113*0Sstevel@tonic-gate 	BM_MANAGER				= 0x00020005,
114*0Sstevel@tonic-gate 	DEV_MGT_AGENT				= 0x00010006,
115*0Sstevel@tonic-gate 	DEV_MGT_MANAGER				= 0x00020006,
116*0Sstevel@tonic-gate 	COMM_MGT_MANAGER_AGENT			= 0x00030007,
117*0Sstevel@tonic-gate 	SNMP_MANAGER_AGENT			= 0x00030008,
118*0Sstevel@tonic-gate 	VENDOR_09_MANAGER_AGENT			= 0x00030009,
119*0Sstevel@tonic-gate 	VENDOR_0A_MANAGER_AGENT			= 0x0003000A,
120*0Sstevel@tonic-gate 	VENDOR_0B_MANAGER_AGENT			= 0x0003000B,
121*0Sstevel@tonic-gate 	VENDOR_0C_MANAGER_AGENT			= 0x0003000C,
122*0Sstevel@tonic-gate 	VENDOR_0D_MANAGER_AGENT			= 0x0003000D,
123*0Sstevel@tonic-gate 	VENDOR_0E_MANAGER_AGENT			= 0x0003000E,
124*0Sstevel@tonic-gate 	VENDOR_0F_MANAGER_AGENT			= 0x0003000F,
125*0Sstevel@tonic-gate 	VENDOR_30_MANAGER_AGENT			= 0x00030030,
126*0Sstevel@tonic-gate 	VENDOR_31_MANAGER_AGENT			= 0x00030031,
127*0Sstevel@tonic-gate 	VENDOR_32_MANAGER_AGENT			= 0x00030032,
128*0Sstevel@tonic-gate 	VENDOR_33_MANAGER_AGENT			= 0x00030033,
129*0Sstevel@tonic-gate 	VENDOR_34_MANAGER_AGENT			= 0x00030034,
130*0Sstevel@tonic-gate 	VENDOR_35_MANAGER_AGENT			= 0x00030035,
131*0Sstevel@tonic-gate 	VENDOR_36_MANAGER_AGENT			= 0x00030036,
132*0Sstevel@tonic-gate 	VENDOR_37_MANAGER_AGENT			= 0x00030037,
133*0Sstevel@tonic-gate 	VENDOR_38_MANAGER_AGENT			= 0x00030038,
134*0Sstevel@tonic-gate 	VENDOR_39_MANAGER_AGENT			= 0x00030039,
135*0Sstevel@tonic-gate 	VENDOR_3A_MANAGER_AGENT			= 0x0003003A,
136*0Sstevel@tonic-gate 	VENDOR_3B_MANAGER_AGENT			= 0x0003003B,
137*0Sstevel@tonic-gate 	VENDOR_3C_MANAGER_AGENT			= 0x0003003C,
138*0Sstevel@tonic-gate 	VENDOR_3D_MANAGER_AGENT			= 0x0003003D,
139*0Sstevel@tonic-gate 	VENDOR_3E_MANAGER_AGENT			= 0x0003003E,
140*0Sstevel@tonic-gate 	VENDOR_3F_MANAGER_AGENT			= 0x0003003F,
141*0Sstevel@tonic-gate 	VENDOR_40_MANAGER_AGENT			= 0x00030040,
142*0Sstevel@tonic-gate 	VENDOR_41_MANAGER_AGENT			= 0x00030041,
143*0Sstevel@tonic-gate 	VENDOR_42_MANAGER_AGENT			= 0x00030042,
144*0Sstevel@tonic-gate 	VENDOR_43_MANAGER_AGENT			= 0x00030043,
145*0Sstevel@tonic-gate 	VENDOR_44_MANAGER_AGENT			= 0x00030044,
146*0Sstevel@tonic-gate 	VENDOR_45_MANAGER_AGENT			= 0x00030045,
147*0Sstevel@tonic-gate 	VENDOR_46_MANAGER_AGENT			= 0x00030046,
148*0Sstevel@tonic-gate 	VENDOR_47_MANAGER_AGENT			= 0x00030047,
149*0Sstevel@tonic-gate 	VENDOR_48_MANAGER_AGENT			= 0x00030048,
150*0Sstevel@tonic-gate 	VENDOR_49_MANAGER_AGENT			= 0x00030049,
151*0Sstevel@tonic-gate 	VENDOR_4A_MANAGER_AGENT			= 0x0003004A,
152*0Sstevel@tonic-gate 	VENDOR_4B_MANAGER_AGENT			= 0x0003004B,
153*0Sstevel@tonic-gate 	VENDOR_4C_MANAGER_AGENT			= 0x0003004C,
154*0Sstevel@tonic-gate 	VENDOR_4D_MANAGER_AGENT			= 0x0003004D,
155*0Sstevel@tonic-gate 	VENDOR_4E_MANAGER_AGENT			= 0x0003004E,
156*0Sstevel@tonic-gate 	VENDOR_4F_MANAGER_AGENT			= 0x0003004F,
157*0Sstevel@tonic-gate 	APPLICATION_10_MANAGER_AGENT		= 0x00030010,
158*0Sstevel@tonic-gate 	APPLICATION_11_MANAGER_AGENT		= 0x00030011,
159*0Sstevel@tonic-gate 	APPLICATION_12_MANAGER_AGENT		= 0x00030012,
160*0Sstevel@tonic-gate 	APPLICATION_13_MANAGER_AGENT		= 0x00030013,
161*0Sstevel@tonic-gate 	APPLICATION_14_MANAGER_AGENT		= 0x00030014,
162*0Sstevel@tonic-gate 	APPLICATION_15_MANAGER_AGENT		= 0x00030015,
163*0Sstevel@tonic-gate 	APPLICATION_16_MANAGER_AGENT		= 0x00030016,
164*0Sstevel@tonic-gate 	APPLICATION_17_MANAGER_AGENT		= 0x00030017,
165*0Sstevel@tonic-gate 	APPLICATION_18_MANAGER_AGENT		= 0x00030018,
166*0Sstevel@tonic-gate 	APPLICATION_19_MANAGER_AGENT		= 0x00030019,
167*0Sstevel@tonic-gate 	APPLICATION_1A_MANAGER_AGENT		= 0x0003001A,
168*0Sstevel@tonic-gate 	APPLICATION_1B_MANAGER_AGENT		= 0x0003001B,
169*0Sstevel@tonic-gate 	APPLICATION_1C_MANAGER_AGENT		= 0x0003001C,
170*0Sstevel@tonic-gate 	APPLICATION_1D_MANAGER_AGENT		= 0x0003001D,
171*0Sstevel@tonic-gate 	APPLICATION_1E_MANAGER_AGENT		= 0x0003001E,
172*0Sstevel@tonic-gate 	APPLICATION_1F_MANAGER_AGENT		= 0x0003001F,
173*0Sstevel@tonic-gate 	APPLICATION_20_MANAGER_AGENT		= 0x00030020,
174*0Sstevel@tonic-gate 	APPLICATION_21_MANAGER_AGENT		= 0x00030021,
175*0Sstevel@tonic-gate 	APPLICATION_22_MANAGER_AGENT		= 0x00030022,
176*0Sstevel@tonic-gate 	APPLICATION_23_MANAGER_AGENT		= 0x00030023,
177*0Sstevel@tonic-gate 	APPLICATION_24_MANAGER_AGENT		= 0x00030024,
178*0Sstevel@tonic-gate 	APPLICATION_25_MANAGER_AGENT		= 0x00030025,
179*0Sstevel@tonic-gate 	APPLICATION_26_MANAGER_AGENT		= 0x00030026,
180*0Sstevel@tonic-gate 	APPLICATION_27_MANAGER_AGENT		= 0x00030027,
181*0Sstevel@tonic-gate 	APPLICATION_28_MANAGER_AGENT		= 0x00030028,
182*0Sstevel@tonic-gate 	APPLICATION_29_MANAGER_AGENT		= 0x00030029,
183*0Sstevel@tonic-gate 	APPLICATION_2A_MANAGER_AGENT		= 0x0003002A,
184*0Sstevel@tonic-gate 	APPLICATION_2B_MANAGER_AGENT		= 0x0003002B,
185*0Sstevel@tonic-gate 	APPLICATION_2C_MANAGER_AGENT		= 0x0003002C,
186*0Sstevel@tonic-gate 	APPLICATION_2D_MANAGER_AGENT		= 0x0003002D,
187*0Sstevel@tonic-gate 	APPLICATION_2E_MANAGER_AGENT		= 0x0003002E,
188*0Sstevel@tonic-gate 	APPLICATION_2F_MANAGER_AGENT		= 0x0003002F,
189*0Sstevel@tonic-gate 	UNIVERSAL_CLASS				= 0x00040001
190*0Sstevel@tonic-gate } ibmf_client_type_t;
191*0Sstevel@tonic-gate 
192*0Sstevel@tonic-gate /*
193*0Sstevel@tonic-gate  * ibmf_retrans_t data type is used to specify the maximum values
194*0Sstevel@tonic-gate  * of the retransmission parameters, number of retries,
195*0Sstevel@tonic-gate  * response time value, round trip travel time, and transaction timeout.
196*0Sstevel@tonic-gate  *
197*0Sstevel@tonic-gate  * The retries value must be provided by the client
198*0Sstevel@tonic-gate  * for all the transaction types enumerated by ibmf_trans_t.
199*0Sstevel@tonic-gate  * The retries value will be used to retry any section of
200*0Sstevel@tonic-gate  * the underlying transmission and reception protocol that
201*0Sstevel@tonic-gate  * are time bound by timers.
202*0Sstevel@tonic-gate  *
203*0Sstevel@tonic-gate  * The response time value must be specified for all transaction types except an
204*0Sstevel@tonic-gate  * unsequenced, non-RMPP send (see the table below).
205*0Sstevel@tonic-gate  * The response time value is the length of processing time for the
206*0Sstevel@tonic-gate  * responder to process the requested transaction, from the point of receiving
207*0Sstevel@tonic-gate  * the last request packet, to the point of returning the first response packet.
208*0Sstevel@tonic-gate  * This value is interpreted in microseconds.
209*0Sstevel@tonic-gate  * If the response time value is zero, an implementation default is used.
210*0Sstevel@tonic-gate  *
211*0Sstevel@tonic-gate  * The round trip time must be specified for all transaction types except an
212*0Sstevel@tonic-gate  * unsequenced, non-RMPP send (see the table below).
213*0Sstevel@tonic-gate  * The round trip travel time is the maximum time it should take a packet
214*0Sstevel@tonic-gate  * to travel from the requester to the responder and back to the requester.
215*0Sstevel@tonic-gate  * This value does not include the processing time at the responder.
216*0Sstevel@tonic-gate  * This value is interpreted in microseconds.
217*0Sstevel@tonic-gate  * If the round trip time value is zero, an implementation default is used.
218*0Sstevel@tonic-gate  *
219*0Sstevel@tonic-gate  * The transaction timeout should be specified for all transactions
220*0Sstevel@tonic-gate  * using RMPP to receive a message.
221*0Sstevel@tonic-gate  * Since, it is not possible for the client to know the size of the
222*0Sstevel@tonic-gate  * response, IBMF will calculate a reasonable transaction timeout after
223*0Sstevel@tonic-gate  * receiving the first RMPP data packet of the response at which time the
224*0Sstevel@tonic-gate  * size of the message will be known.  If this value is greater than the
225*0Sstevel@tonic-gate  * client's transaction timeout parameter the client's value will be used.
226*0Sstevel@tonic-gate  * If the client's transaction timeout parameter is 0 the calculated value will
227*0Sstevel@tonic-gate  * be used.
228*0Sstevel@tonic-gate  * This value is interpreted in microseconds.
229*0Sstevel@tonic-gate  * If the transaction timeout value is zero, an implementation default is used.
230*0Sstevel@tonic-gate  *
231*0Sstevel@tonic-gate  * See Section 13.6.3.1, of the InfiniBand Architecture Specification,
232*0Sstevel@tonic-gate  * Volume 1, Release 1.1 for details on how to deduce this value.
233*0Sstevel@tonic-gate  *
234*0Sstevel@tonic-gate  * The following table describes the retrans parameters needed for
235*0Sstevel@tonic-gate  * the various ibmf_msg_transport() flag combinations.
236*0Sstevel@tonic-gate  *
237*0Sstevel@tonic-gate  * ibmf_msg_transport() flags   retries      rtv/rttv      trans_to
238*0Sstevel@tonic-gate  * No Flags                     ignored      ignored       ignored
239*0Sstevel@tonic-gate  * Sequenced Flag               required     required      required
240*0Sstevel@tonic-gate  * RMPP Flag                    required     required      ignored
241*0Sstevel@tonic-gate  * RMPP + Sequenced Flags       required     required      optional
242*0Sstevel@tonic-gate  */
243*0Sstevel@tonic-gate typedef struct _ibmf_retrans_t {
244*0Sstevel@tonic-gate 	uint32_t	retrans_retries;	/* number of retries */
245*0Sstevel@tonic-gate 	uint32_t	retrans_rtv;		/* response time value */
246*0Sstevel@tonic-gate 	uint32_t	retrans_rttv; 		/* round trip travel time */
247*0Sstevel@tonic-gate 	uint32_t	retrans_trans_to;	/* transaction timeout */
248*0Sstevel@tonic-gate } ibmf_retrans_t;
249*0Sstevel@tonic-gate 
250*0Sstevel@tonic-gate typedef struct _ibmf_register_info {
251*0Sstevel@tonic-gate 	ib_guid_t		ir_ci_guid;
252*0Sstevel@tonic-gate 	uint_t			ir_port_num;
253*0Sstevel@tonic-gate 	ibmf_client_type_t	ir_client_class;
254*0Sstevel@tonic-gate } ibmf_register_info_t;
255*0Sstevel@tonic-gate 
256*0Sstevel@tonic-gate typedef enum _ibmf_impl_caps {
257*0Sstevel@tonic-gate 	IBMF_DEF_QP_HDL_P_KEY_ANY		= 0x0001,
258*0Sstevel@tonic-gate 	IBMF_DEF_QP_HDL_Q_KEY_ANY		= 0x0002,
259*0Sstevel@tonic-gate 	IBMF_NON_DEF_QP_HDL_P_KEY_ANY		= 0x0004,
260*0Sstevel@tonic-gate 	IBMF_NON_DEF_QP_HDL_Q_KEY_ANY		= 0x0008
261*0Sstevel@tonic-gate } ibmf_impl_caps_t;
262*0Sstevel@tonic-gate 
263*0Sstevel@tonic-gate 
264*0Sstevel@tonic-gate /*
265*0Sstevel@tonic-gate  * Defines for channel interface events.
266*0Sstevel@tonic-gate  * IBMF_CI_OFFLINE :
267*0Sstevel@tonic-gate  *      Indication to the client that it must cease all ibmf activity
268*0Sstevel@tonic-gate  *      (after any current activity has terminated). The client must
269*0Sstevel@tonic-gate  *      release all ibmf resources and unregister from ibmf prior to
270*0Sstevel@tonic-gate  *      returning from the callback.
271*0Sstevel@tonic-gate  *
272*0Sstevel@tonic-gate  *      NOTE1: It is expected that there will exist some higher level
273*0Sstevel@tonic-gate  *      management entity that will "wake up" the ibmf client once
274*0Sstevel@tonic-gate  *      the CI is available. The ibmf client may then register with the
275*0Sstevel@tonic-gate  *      available CI's nodeguid and portnumber.
276*0Sstevel@tonic-gate  *
277*0Sstevel@tonic-gate  *	NOTE2: callback implementors must handle the case where the
278*0Sstevel@tonic-gate  *	callback is invoked AFTER the ibmf resources have been freed by
279*0Sstevel@tonic-gate  *	another thread.
280*0Sstevel@tonic-gate  */
281*0Sstevel@tonic-gate typedef enum ibmf_async_event_e {
282*0Sstevel@tonic-gate 	IBMF_CI_OFFLINE		= 0x1
283*0Sstevel@tonic-gate } ibmf_async_event_t;
284*0Sstevel@tonic-gate 
285*0Sstevel@tonic-gate /*
286*0Sstevel@tonic-gate  * ibmf_async_event_cb_t():
287*0Sstevel@tonic-gate  * IBMF's callback to clients to inform them of events such as
288*0Sstevel@tonic-gate  * the ibmf services temporarily suspending or resuming.
289*0Sstevel@tonic-gate  * This notification mechanism covers all asynchronous events
290*0Sstevel@tonic-gate  * of interest that are not related to IB messages.
291*0Sstevel@tonic-gate  *
292*0Sstevel@tonic-gate  * NOTE:
293*0Sstevel@tonic-gate  * It is possible for the callback function to be called before
294*0Sstevel@tonic-gate  * ibmf_register() returns. When this happens, the entity doing the
295*0Sstevel@tonic-gate  * ibmf_register() may see an ibmf_handle being passed to the
296*0Sstevel@tonic-gate  * callback function that it does not recognize.
297*0Sstevel@tonic-gate  *
298*0Sstevel@tonic-gate  * Input arguments:
299*0Sstevel@tonic-gate  *	ibmf_handle - Handle to the IBMF interface
300*0Sstevel@tonic-gate  *      clnt_private - is an opaque handle to client specific data
301*0Sstevel@tonic-gate  *      event_type - specifies the event type the client is being notified of
302*0Sstevel@tonic-gate  *
303*0Sstevel@tonic-gate  * Output arguments:
304*0Sstevel@tonic-gate  *      None
305*0Sstevel@tonic-gate  *
306*0Sstevel@tonic-gate  * Return values:
307*0Sstevel@tonic-gate  *      None
308*0Sstevel@tonic-gate  */
309*0Sstevel@tonic-gate typedef void (*ibmf_async_event_cb_t)(
310*0Sstevel@tonic-gate 	ibmf_handle_t		ibmf_handle,
311*0Sstevel@tonic-gate 	void			*clnt_private,
312*0Sstevel@tonic-gate 	ibmf_async_event_t	event_type);
313*0Sstevel@tonic-gate 
314*0Sstevel@tonic-gate /*
315*0Sstevel@tonic-gate  * ibmf_msg_cb_t():
316*0Sstevel@tonic-gate  *
317*0Sstevel@tonic-gate  * This routine type is called by IBMF when an unsolicited message that
318*0Sstevel@tonic-gate  * corresponds to one of the class registrants is received. An unsolicited
319*0Sstevel@tonic-gate  * message is one that was not allocated by this client for the purpose
320*0Sstevel@tonic-gate  * of executing a transaction using the ibmf_msg_transport() call.
321*0Sstevel@tonic-gate  * Examples of unsolicited messages are traps, and requests from other
322*0Sstevel@tonic-gate  * management entities.
323*0Sstevel@tonic-gate  *
324*0Sstevel@tonic-gate  * This routine type is also called by IBMF at the end of a transaction
325*0Sstevel@tonic-gate  * specified in a call to ibmf_msg_transport().
326*0Sstevel@tonic-gate  *
327*0Sstevel@tonic-gate  * When it is called as result of an incoming message:
328*0Sstevel@tonic-gate  *
329*0Sstevel@tonic-gate  *	The recipient is expected to free the ibmf_msg_t passed in by
330*0Sstevel@tonic-gate  *	calling ibmf_free_msg(); this freeing should be done before the
331*0Sstevel@tonic-gate  *	client unregisters.
332*0Sstevel@tonic-gate  *
333*0Sstevel@tonic-gate  *	The recipient is expected to not call any routines in the callback
334*0Sstevel@tonic-gate  *	that may block.
335*0Sstevel@tonic-gate  *
336*0Sstevel@tonic-gate  * 	Blocking within the callback is not allowed, but ibmf doesn't enforce
337*0Sstevel@tonic-gate  *	this.
338*0Sstevel@tonic-gate  *
339*0Sstevel@tonic-gate  *	This routine may be called before ibmf_setup_async_cb() returns.
340*0Sstevel@tonic-gate  *
341*0Sstevel@tonic-gate  *
342*0Sstevel@tonic-gate  * Input arguments:
343*0Sstevel@tonic-gate  *	Handle to the IBMF interface
344*0Sstevel@tonic-gate  *	Pointer to the Message sent or received
345*0Sstevel@tonic-gate  *	Callback arguments, specified at registration time (for async callbacks)
346*0Sstevel@tonic-gate  *		or specified to ibmf_msg_transport()
347*0Sstevel@tonic-gate  *
348*0Sstevel@tonic-gate  * Output arguments:
349*0Sstevel@tonic-gate  *	None
350*0Sstevel@tonic-gate  *
351*0Sstevel@tonic-gate  * Return values:
352*0Sstevel@tonic-gate  *	None
353*0Sstevel@tonic-gate  */
354*0Sstevel@tonic-gate typedef void (*ibmf_msg_cb_t)(
355*0Sstevel@tonic-gate 	ibmf_handle_t		ibmf_handle,
356*0Sstevel@tonic-gate 	ibmf_msg_t		*msgp,
357*0Sstevel@tonic-gate 	void			*args);
358*0Sstevel@tonic-gate 
359*0Sstevel@tonic-gate /* defines for im_msg_flags */
360*0Sstevel@tonic-gate #define	IBMF_MSG_FLAGS_GLOBAL_ADDRESS	0x00000010	/* has global addr */
361*0Sstevel@tonic-gate 
362*0Sstevel@tonic-gate /*
363*0Sstevel@tonic-gate  * ibmf_register():
364*0Sstevel@tonic-gate  *
365*0Sstevel@tonic-gate  * An agent needs to register before it can receive any management packets
366*0Sstevel@tonic-gate  * and a manager needs to register before it can send/receive any management
367*0Sstevel@tonic-gate  * packets. The registration is on a per port of the node basis.
368*0Sstevel@tonic-gate  *
369*0Sstevel@tonic-gate  * A client can register for one class per call to ibmf_register().
370*0Sstevel@tonic-gate  * The client should set ir_client_class component of the client_info argument
371*0Sstevel@tonic-gate  * to the class it wants to register for.
372*0Sstevel@tonic-gate  * ibmf_register() will fail if the class is already registered for,
373*0Sstevel@tonic-gate  * with the error code IBMF_PORT_IN_USE.
374*0Sstevel@tonic-gate  *
375*0Sstevel@tonic-gate  * Note that for some classes, the client can register as agent or manager only
376*0Sstevel@tonic-gate  * and agent+manager only. An exception to this rule is the UNIVERSAL_CLASS
377*0Sstevel@tonic-gate  * described below.
378*0Sstevel@tonic-gate  *
379*0Sstevel@tonic-gate  * Clients that require to send/receive general UD traffic,
380*0Sstevel@tonic-gate  * not limited to MADs, over a UD QP may do so by registering
381*0Sstevel@tonic-gate  * with the UNIVERSAL_CLASS client type.
382*0Sstevel@tonic-gate  * Unlike the other IBMF client types, any number of clients may
383*0Sstevel@tonic-gate  * be simultaneously registered for the UNIVERSAL_CLASS on a port.
384*0Sstevel@tonic-gate  * When registered with the UNIVERSAL_CLASS, a client should only use the
385*0Sstevel@tonic-gate  * alternate QPs, and never use the default QP handle.
386*0Sstevel@tonic-gate  * However, a client registered for any other client type may also use
387*0Sstevel@tonic-gate  * the alternate QPs in addition to using the default QP handle.
388*0Sstevel@tonic-gate  * IBMF implementations that do not support registration for the UNIVERSAL class
389*0Sstevel@tonic-gate  * will return IBMF_NOT_SUPPORTED.
390*0Sstevel@tonic-gate  *
391*0Sstevel@tonic-gate  * NOTE on usage of qp handles:
392*0Sstevel@tonic-gate  *
393*0Sstevel@tonic-gate  * Some implementations support specifying any Q_Key and P_Key
394*0Sstevel@tonic-gate  * combination when ibmf_qp_handle_t arg is set to IBMF_QP_HANDLE_DEFAULT
395*0Sstevel@tonic-gate  * in the call to ibmf_msg_transport() and some implementations allow only
396*0Sstevel@tonic-gate  * the default values of Q_Key (0x8001_0000) and P_Key (0xFFFF/0x7FFFF)
397*0Sstevel@tonic-gate  * when ibmf_qp_handle_t arg is IBMF_QP_HANDLE_DEFAULT. The client can know
398*0Sstevel@tonic-gate  * the behavior supported via ibmf_impl_caps_t arg on successful return from
399*0Sstevel@tonic-gate  * ibmf_register(). ibmf_impl_caps_t arg points to a bit mask of the
400*0Sstevel@tonic-gate  * capabilities of the platform. If the implementation supports any
401*0Sstevel@tonic-gate  * P_Key and/or Q_Key value with IBMF_QP_HANDLE_DEFAULT, then
402*0Sstevel@tonic-gate  * IBMF_DEF_QP_HDL_P_KEY_ANY and/or IBMF_DEF_QP_HDL_Q_KEY_ANY will be set in
403*0Sstevel@tonic-gate  * ibmf_impl_caps_t.
404*0Sstevel@tonic-gate  *
405*0Sstevel@tonic-gate  * Some implementations support specifying any P_Key and Q_Key combination on
406*0Sstevel@tonic-gate  * a per-request basis when ibmf_qp_handle_t is set to an explicitly allocated
407*0Sstevel@tonic-gate  * qp handle (the client specifies the P_Key/Q_Key value in ibmf_addr_info_t
408*0Sstevel@tonic-gate  * argument). IBMA indicates this behavior by setting
409*0Sstevel@tonic-gate  * IBMF_NON_DEF_QP_HDL_P_KEY_ANY and/or IBMF_NON_DEF_QP_HDL_Q_KEY_ANY in the
410*0Sstevel@tonic-gate  * ibmf_impl_caps_t arg. In such an implementation, ibmf_modify_qp() does not
411*0Sstevel@tonic-gate  * change anything in the transport and always returns IBMF_SUCCESS.
412*0Sstevel@tonic-gate  *
413*0Sstevel@tonic-gate  * When the implementation supports IBMF_DEF_QP_HDL_P_KEY_ANY and/or
414*0Sstevel@tonic-gate  * IBMF_DEF_QP_HDL_Q_KEY_ANY, it may map IBMF_QP_HANDLE_DEFAULT to any qp
415*0Sstevel@tonic-gate  * number(s) supported by the
416*0Sstevel@tonic-gate  * underlying transport. The client can not not make any assumptions on this
417*0Sstevel@tonic-gate  * mapping nor can it query ibmf for the qp num being used with
418*0Sstevel@tonic-gate  * IBMF_QP_HANDLE_DEFAULT. There are cases where the client needs to have
419*0Sstevel@tonic-gate  * explicit control over the qp number being used by ibmf (eg., agent
420*0Sstevel@tonic-gate  * redirection). The client should explicitly allocate a qp using
421*0Sstevel@tonic-gate  * ibmf_alloc_qp() in such cases.
422*0Sstevel@tonic-gate  *
423*0Sstevel@tonic-gate  * Also, IBMF_QP_HANDLE_DEFAULT can only be used when the class of the MAD
424*0Sstevel@tonic-gate  * being sent using ibmf_msg_transport() is the same as the class the client
425*0Sstevel@tonic-gate  * registered for. If a client wishes to send a MAD class other than the
426*0Sstevel@tonic-gate  * one it registered for, it should explicitly allocate a qp and use that
427*0Sstevel@tonic-gate  * qp while sending MADs.
428*0Sstevel@tonic-gate  *
429*0Sstevel@tonic-gate  * If the implementation supports
430*0Sstevel@tonic-gate  * IBMF_DEF_QP_HDL_P_KEY_ANY/IBMF_DEF_QP_HDL_Q_KEY_ANY and/or
431*0Sstevel@tonic-gate  * IBMF_NON_DEF_QP_HDL_P_KEY_ANY/IBMF_NON_DEF_QP_HDL_Q_KEY_ANY, it is the
432*0Sstevel@tonic-gate  * implementation's responsibility to ensure that the
433*0Sstevel@tonic-gate  * requested P_Key and Q_Key can be used by, with in resource limitations,
434*0Sstevel@tonic-gate  * concurrent sends.
435*0Sstevel@tonic-gate  *
436*0Sstevel@tonic-gate  * Clients registering for classes that include an RMPP header in their
437*0Sstevel@tonic-gate  * MADs must set the IBMF_REG_FLAG_RMPP flag when registering with IBMF.
438*0Sstevel@tonic-gate  * This must be done regardless of whether the client intends to use
439*0Sstevel@tonic-gate  * the RMPP protocol or not. The flag is an indicator to IBMF of the
440*0Sstevel@tonic-gate  * presence of the RMPP header in the MAD.
441*0Sstevel@tonic-gate  *
442*0Sstevel@tonic-gate  * IBMF will always insure that receive buffer pointers are offsets into a
443*0Sstevel@tonic-gate  * single contiguous buffer of memory. The im_msgbufs_recv.im_bufs_mad_hdr,
444*0Sstevel@tonic-gate  * points to the start of the buffer. The other two pointers,
445*0Sstevel@tonic-gate  * im_msgbufs_recv.im_bufs_cl_hdr, and im_msgbufs_recv.im_bufs_cl_data,
446*0Sstevel@tonic-gate  * will point to class specific offsets within the buffer.
447*0Sstevel@tonic-gate  *
448*0Sstevel@tonic-gate  * Clients may provide a pointer to a callback function in the client_cb
449*0Sstevel@tonic-gate  * argument. Implementations of ibmf that require the client_cb to
450*0Sstevel@tonic-gate  * be specified should return IBMF_INVALID_ARG if the client_cb argument
451*0Sstevel@tonic-gate  * is NULL.
452*0Sstevel@tonic-gate  *
453*0Sstevel@tonic-gate  * This interface may block
454*0Sstevel@tonic-gate  *
455*0Sstevel@tonic-gate  * Input arguments:
456*0Sstevel@tonic-gate  *	Pointer to client registration information
457*0Sstevel@tonic-gate  *	Version of the interface (IBMF_VERSION)
458*0Sstevel@tonic-gate  *	flags - set IBMF_REG_FLAG_RMPP if client supports RMPP MAD
459*0Sstevel@tonic-gate  *		set IBMF_REG_FLAG_NO_OFFLOAD for requiring that processing
460*0Sstevel@tonic-gate  *			not be offloaded onto a non-interrupt context thread
461*0Sstevel@tonic-gate  *			on send completions and receive completions.
462*0Sstevel@tonic-gate  *			(Processsing will be done in the interrupt context)
463*0Sstevel@tonic-gate  *			The default is to offload the processing to a
464*0Sstevel@tonic-gate  *			non-interrupt context thread(s).
465*0Sstevel@tonic-gate  *		set IBMF_REG_FLAG_SINGLE_OFFLOAD for requiring single
466*0Sstevel@tonic-gate  *			threaded processing if IBMF_REG_FLAG_NO_OFFLOAD
467*0Sstevel@tonic-gate  *			is not specified. The default is multi-threaded
468*0Sstevel@tonic-gate  *			processing. It is an error to set this flag if
469*0Sstevel@tonic-gate  *			IBMF_REG_FLAG_NO_OFFLOAD is set.
470*0Sstevel@tonic-gate  *      client_cb - callback to be called for asynchronous events that
471*0Sstevel@tonic-gate  *                  are not related to IB messages
472*0Sstevel@tonic-gate  *      client_cb_args - opaque pointer to client private data area
473*0Sstevel@tonic-gate  *
474*0Sstevel@tonic-gate  * Output arguments:
475*0Sstevel@tonic-gate  *	Handle to the IBMF interface; used in subsequent interactions
476*0Sstevel@tonic-gate  *	Pointer to ibmf_impl_caps_t; gives capabilities of the platform
477*0Sstevel@tonic-gate  *
478*0Sstevel@tonic-gate  * Return values:
479*0Sstevel@tonic-gate  *	IBMF_SUCCESS		- registration successful
480*0Sstevel@tonic-gate  *	IBMF_BAD_VERSION	- registration failed due to invalid version
481*0Sstevel@tonic-gate  *	IBMF_PORT_IN_USE	- registration failed - some entity already
482*0Sstevel@tonic-gate  *				  registered for the class on the node/port
483*0Sstevel@tonic-gate  *				  specified.
484*0Sstevel@tonic-gate  *	IBMF_BAD_CLASS		- registration failed - invalid class
485*0Sstevel@tonic-gate  *	IBMF_BAD_PORT		- registration failed - non existent port
486*0Sstevel@tonic-gate  *	IBMF_BAD_NODE		- registration failed - non existent node
487*0Sstevel@tonic-gate  *	IBMF_BAD_FLAGS		- IBMF_REG_FLAG_NO_OFFLOAD is specified with
488*0Sstevel@tonic-gate  *					IBMF_REG_FLAG_SINGLE_OFFLOAD
489*0Sstevel@tonic-gate  *	IBMF_INVALID_ARG	- registration failed - invalid argument
490*0Sstevel@tonic-gate  *	IBMF_FAILURE		- registration failed - ibmf internal error
491*0Sstevel@tonic-gate  *	IBMF_NO_RESOURCES	- registration failed - not enough resources
492*0Sstevel@tonic-gate  *	IBMF_TRANSPORT_FAILURE	- registration failed - transport call failed
493*0Sstevel@tonic-gate  *
494*0Sstevel@tonic-gate  */
495*0Sstevel@tonic-gate int	ibmf_register(
496*0Sstevel@tonic-gate 		ibmf_register_info_t	*client_info,
497*0Sstevel@tonic-gate 		uint_t			ibmf_version,
498*0Sstevel@tonic-gate 		uint_t			flags,
499*0Sstevel@tonic-gate 		ibmf_async_event_cb_t   client_cb,
500*0Sstevel@tonic-gate 		void			*client_cb_args,
501*0Sstevel@tonic-gate 		ibmf_handle_t		*ibmf_handle,
502*0Sstevel@tonic-gate 		ibmf_impl_caps_t	*ibmf_impl_features);
503*0Sstevel@tonic-gate 
504*0Sstevel@tonic-gate #define	IBMF_REG_FLAG_RMPP		0x1
505*0Sstevel@tonic-gate #define	IBMF_REG_FLAG_NO_OFFLOAD	0x2
506*0Sstevel@tonic-gate #define	IBMF_REG_FLAG_SINGLE_OFFLOAD	0x4
507*0Sstevel@tonic-gate 
508*0Sstevel@tonic-gate /*
509*0Sstevel@tonic-gate  * ibmf_unregister():
510*0Sstevel@tonic-gate  *
511*0Sstevel@tonic-gate  * Unregister a previously established registration.
512*0Sstevel@tonic-gate  *
513*0Sstevel@tonic-gate  * This interface may block.
514*0Sstevel@tonic-gate  *
515*0Sstevel@tonic-gate  * The client should free any and all ibmf_msg_t's passed in all
516*0Sstevel@tonic-gate  * "receive msg callbacks" before unregistering. Also, the client should
517*0Sstevel@tonic-gate  * ensure that it is not trying to send any messages before calling this
518*0Sstevel@tonic-gate  * routine.
519*0Sstevel@tonic-gate  *
520*0Sstevel@tonic-gate  * After successfully returning from this call, ibmf_handle should not be used
521*0Sstevel@tonic-gate  * for any further interactions with the IBMF.
522*0Sstevel@tonic-gate  *
523*0Sstevel@tonic-gate  * Input arguments:
524*0Sstevel@tonic-gate  *	Handle to the IBMF interface
525*0Sstevel@tonic-gate  *	flags - unused (should be 0)
526*0Sstevel@tonic-gate  *
527*0Sstevel@tonic-gate  * Output arguments:
528*0Sstevel@tonic-gate  *	Handle to the IBMF interface; will be invalidated following
529*0Sstevel@tonic-gate  *		this call.
530*0Sstevel@tonic-gate  *
531*0Sstevel@tonic-gate  * Return values:
532*0Sstevel@tonic-gate  *	IBMF_SUCCESS		- unregistration successful
533*0Sstevel@tonic-gate  *	IBMF_BAD_HANDLE		- unregistration failed - invalid handle
534*0Sstevel@tonic-gate  *				  passed in.
535*0Sstevel@tonic-gate  *	IBMF_BUSY		- unregistration failed - client has not
536*0Sstevel@tonic-gate  *				  freed all the resources (ibmf_msg_t's etc)
537*0Sstevel@tonic-gate  *				  allocated by the IBMF, the client
538*0Sstevel@tonic-gate  *				  has not removed all recv callbacks.
539*0Sstevel@tonic-gate  *	IBMF_INVALID_ARG	- invalid argument
540*0Sstevel@tonic-gate  *	IBMF_FAILURE		- ibmf internal error
541*0Sstevel@tonic-gate  *	IBMF_NO_RESOURCES	- not enough resources
542*0Sstevel@tonic-gate  *	IBMF_TRANSPORT_FAILURE	- transport call failed
543*0Sstevel@tonic-gate  */
544*0Sstevel@tonic-gate int	ibmf_unregister(
545*0Sstevel@tonic-gate 		ibmf_handle_t		*ibmf_handle,
546*0Sstevel@tonic-gate 		uint_t			flags);
547*0Sstevel@tonic-gate 
548*0Sstevel@tonic-gate /*
549*0Sstevel@tonic-gate  * ibmf_setup_async_cb():
550*0Sstevel@tonic-gate  *
551*0Sstevel@tonic-gate  * This routine establishes a callback that the IBMF invokes when a message
552*0Sstevel@tonic-gate  * corresponding to the class corresponding to ibmf_handle is received.
553*0Sstevel@tonic-gate  * It is an error to call this routine twice without an intervening
554*0Sstevel@tonic-gate  * call to ibmf_tear_down_async_cb() for the same ibmf_qp_handle/ibmf_handle
555*0Sstevel@tonic-gate  * combination. Only unsolicited message reception will result in this
556*0Sstevel@tonic-gate  * callback being invoked.
557*0Sstevel@tonic-gate  *
558*0Sstevel@tonic-gate  * This interface may block.
559*0Sstevel@tonic-gate  *
560*0Sstevel@tonic-gate  * The callback routine could be invoked before this function returns.
561*0Sstevel@tonic-gate  *
562*0Sstevel@tonic-gate  * Input arguments:
563*0Sstevel@tonic-gate  *	Handle to the IBMF interface
564*0Sstevel@tonic-gate  *	IBMF QP handle (either allocated via ibmf_alloc_qp() or
565*0Sstevel@tonic-gate  *	    IBMF_QP_HANDLE_DEFAULT)
566*0Sstevel@tonic-gate  *	Callback routine
567*0Sstevel@tonic-gate  *	Argument to be passed when the callback is invoked
568*0Sstevel@tonic-gate  *	flags - unused (should be 0)
569*0Sstevel@tonic-gate  *
570*0Sstevel@tonic-gate  * Output arguments:
571*0Sstevel@tonic-gate  *	None
572*0Sstevel@tonic-gate  *
573*0Sstevel@tonic-gate  * Return values:
574*0Sstevel@tonic-gate  *	IBMF_SUCCESS		- Callback established successfully
575*0Sstevel@tonic-gate  *	IBMF_BAD_HANDLE		- failure - invalid handle
576*0Sstevel@tonic-gate  *	IBMF_BAD_QP_HANDLE	- failure - invalid qp handle
577*0Sstevel@tonic-gate  *	IBMF_CB_REGISTERED	- failure - callback is already established
578*0Sstevel@tonic-gate  *	IBMF_INVALID_ARG	- failure - invalid argument
579*0Sstevel@tonic-gate  */
580*0Sstevel@tonic-gate int	ibmf_setup_async_cb(
581*0Sstevel@tonic-gate 		ibmf_handle_t		ibmf_handle,
582*0Sstevel@tonic-gate 		ibmf_qp_handle_t	ibmf_qp_handle,
583*0Sstevel@tonic-gate 		ibmf_msg_cb_t		async_msg_cb,
584*0Sstevel@tonic-gate 		void			*async_msg_cb_args,
585*0Sstevel@tonic-gate 		uint_t			flags);
586*0Sstevel@tonic-gate 
587*0Sstevel@tonic-gate /*
588*0Sstevel@tonic-gate  * ibmf_tear_down_async_cb():
589*0Sstevel@tonic-gate  *
590*0Sstevel@tonic-gate  * This routine removes the callback set up using ibmf_setup_async_cb.
591*0Sstevel@tonic-gate  * There will not be any callbacks if messages are received after successful
592*0Sstevel@tonic-gate  * return from this routine. There could be message received callbacks during
593*0Sstevel@tonic-gate  * the execution of this routine.
594*0Sstevel@tonic-gate  *
595*0Sstevel@tonic-gate  * This interface may block.
596*0Sstevel@tonic-gate  *
597*0Sstevel@tonic-gate  * Input arguments:
598*0Sstevel@tonic-gate  *	Handle to the IBMF interface
599*0Sstevel@tonic-gate  *	IBMF QP handle (either allocated via ibmf_alloc_qp() or
600*0Sstevel@tonic-gate  *	    IBMF_QP_HANDLE_DEFAULT)
601*0Sstevel@tonic-gate  *	flags - unused (should be 0)
602*0Sstevel@tonic-gate  *
603*0Sstevel@tonic-gate  * Output arguments:
604*0Sstevel@tonic-gate  *	None
605*0Sstevel@tonic-gate  *
606*0Sstevel@tonic-gate  * Return values:
607*0Sstevel@tonic-gate  *	IBMF_SUCCESS		- call successful
608*0Sstevel@tonic-gate  *	IBMF_BAD_HANDLE		- failure - invalid ibmf handle or qp handle
609*0Sstevel@tonic-gate  *	IBMF_BAD_QP_HANDLE	- failure - invalid qp handle
610*0Sstevel@tonic-gate  *	IBMF_CB_NOT_REGISTERED	- No callback currently registered
611*0Sstevel@tonic-gate  *	IBMF_INVALID_ARG	- failure - invalid argument
612*0Sstevel@tonic-gate  */
613*0Sstevel@tonic-gate int	ibmf_tear_down_async_cb(
614*0Sstevel@tonic-gate 		ibmf_handle_t		ibmf_handle,
615*0Sstevel@tonic-gate 		ibmf_qp_handle_t	ibmf_qp_handle,
616*0Sstevel@tonic-gate 		uint_t			flags);
617*0Sstevel@tonic-gate 
618*0Sstevel@tonic-gate /*
619*0Sstevel@tonic-gate  * ibmf_msg_transport():
620*0Sstevel@tonic-gate  *
621*0Sstevel@tonic-gate  * This interface does not block if a callback is specified.
622*0Sstevel@tonic-gate  *
623*0Sstevel@tonic-gate  * IBMF makes some preliminary checks and returns failure if the
624*0Sstevel@tonic-gate  * checks fail. The callback, if any, is not called in this case. If the
625*0Sstevel@tonic-gate  * checks pass, the message specified in msgp->im_msgbufs_send is relayed
626*0Sstevel@tonic-gate  * down into the transport layer over as many MAD packets as necessary
627*0Sstevel@tonic-gate  * to accommodate the entire message. The IBMF_MSG_TRANS_FLAG_RMPP flag is set
628*0Sstevel@tonic-gate  * when the RMPP protocol should be used when sending out the message.
629*0Sstevel@tonic-gate  * The IBMF_MSG_TRANS_FLAG_SEQ is set when the the transaction is a
630*0Sstevel@tonic-gate  * sequenced transaction (send and receive) where the client expects a reply.
631*0Sstevel@tonic-gate  * The transaction completion callback will be invoked when IBMF
632*0Sstevel@tonic-gate  * is done processing the send operation and after having received the
633*0Sstevel@tonic-gate  * complete response if one is due, with or without errors.
634*0Sstevel@tonic-gate  * If no callback is specified, the routine blocks till the underlying
635*0Sstevel@tonic-gate  * transport is done processing the send request and received the complete
636*0Sstevel@tonic-gate  * response, with or without errors
637*0Sstevel@tonic-gate  *
638*0Sstevel@tonic-gate  * When sending non-MAD traffic over the alternate QPs,
639*0Sstevel@tonic-gate  * if the message data exceeds the maximum MTU supported, the call will fail
640*0Sstevel@tonic-gate  * with the status IBMF_BAD_SIZE.
641*0Sstevel@tonic-gate  *
642*0Sstevel@tonic-gate  * NOTE: If the call is asynchronous, the callback may be invoked before
643*0Sstevel@tonic-gate  * the call returns. The client should be prepared to handle this possibility.
644*0Sstevel@tonic-gate  *
645*0Sstevel@tonic-gate  * The message is sent to the address specified by msgp->im_local_addr and
646*0Sstevel@tonic-gate  * msgp->im_global_addr (global address invalid for SMPs and is ignored).
647*0Sstevel@tonic-gate  * Note that the desired Q_Key and P_Key can be specified via
648*0Sstevel@tonic-gate  * msgp->im_local_addr. If the ibmf implementation does not support any
649*0Sstevel@tonic-gate  * value of Q_Key/P_Key with IBMF_QP_HANDLE_DEFAULT, it is an error to specify
650*0Sstevel@tonic-gate  * a Q_Key other than 0x8001_0000 and a P_Key other than 0xFFFF/0x7FFF when
651*0Sstevel@tonic-gate  * ibmf_qp_handle_t arg is set IBMF_QP_HANDLE_DEFAULT. (See the NOTE in
652*0Sstevel@tonic-gate  * ibmf_register() on what the platform supports.) In this case, when a q_key
653*0Sstevel@tonic-gate  * value other than 0x8001_0000 and/or P_Key value other than
654*0Sstevel@tonic-gate  * 0xFFFF/0x7FFF is desired, the client should allocate its own qp handle
655*0Sstevel@tonic-gate  * with the desired values and use that in the ibmf_msg_transport() call.
656*0Sstevel@tonic-gate  * ibmf_msg_transport() returns IBMF_BAD_HANDLE to flag the error.
657*0Sstevel@tonic-gate  *
658*0Sstevel@tonic-gate  * NOTE: If the qp handle is not the default handle (ie., not
659*0Sstevel@tonic-gate  * IBMF_QP_HANDLE_DEFAULT), it is possible for some other thread to modify
660*0Sstevel@tonic-gate  * P_Key and Q_Key value associated with the qp_handle while this function
661*0Sstevel@tonic-gate  * is executing; this routine may return IBMF_BAD_HANDLE if that
662*0Sstevel@tonic-gate  * happens. It is possible that the modification happens after this routine
663*0Sstevel@tonic-gate  * validates the values, in which case no error may be flagged.
664*0Sstevel@tonic-gate  *
665*0Sstevel@tonic-gate  * NOTE: if the class of the MAD being sent is not the same as what the
666*0Sstevel@tonic-gate  * ibmf_handle (obtained via ibmf_register()) corresponds to, ibmf_qp_handle
667*0Sstevel@tonic-gate  * can not be set to IBMF_QP_HANDLE_DEFAULT.
668*0Sstevel@tonic-gate  *
669*0Sstevel@tonic-gate  * NOTE on notation: A message structure allocated by an ibmf_alloc_msg()
670*0Sstevel@tonic-gate  * call or one returned in an unsolicted callback will be referred to as
671*0Sstevel@tonic-gate  * "Message". When referring to a message in the general sense of the word,
672*0Sstevel@tonic-gate  * it will be referred to as "message".
673*0Sstevel@tonic-gate  * NOTE: Rules for reusing an IBMF Message:
674*0Sstevel@tonic-gate  * Clients may reuse a Message, either provided by IBMF in an unsolicited
675*0Sstevel@tonic-gate  * request, or one obtained through the ibmf_alloc_msg() call, for a
676*0Sstevel@tonic-gate  * subsequent request from the client itself. The client may reuse a Message
677*0Sstevel@tonic-gate  * to avoid the overhead of allocating a new Message and new send buffers.
678*0Sstevel@tonic-gate  * To safely reuse Messages, the client must follow the rules listed below.
679*0Sstevel@tonic-gate  * 1) Using the receive buffers to send the message header and data:
680*0Sstevel@tonic-gate  * If the Message has been provided by IBMF in an unsolicited request,
681*0Sstevel@tonic-gate  * it will have its receive buffers already allocated and pointed to by
682*0Sstevel@tonic-gate  * im_msgbufs_recv pointers by IBMF. In such a case, a client may set
683*0Sstevel@tonic-gate  * the im_msgbufs_send pointers to the values in the im_msgbufs_recv
684*0Sstevel@tonic-gate  * thus reusing the buffer allocated by IBMF for the incoming Message.
685*0Sstevel@tonic-gate  * However, this may be done only when the request from the client is
686*0Sstevel@tonic-gate  * a non-sequenced operation i.e. IBMF_MSG_TRANS_FLAG_SEQ flag is not set.
687*0Sstevel@tonic-gate  * An attempt to reuse the receive buffer for any other operation will
688*0Sstevel@tonic-gate  * result in the failure of the ibmf_msg_transport() call with the error
689*0Sstevel@tonic-gate  * status IBMF_REQ_INVALID.
690*0Sstevel@tonic-gate  * 2) Providing send buffers to send the message header and data:
691*0Sstevel@tonic-gate  * If the client provides its own send buffers for the message header and data,
692*0Sstevel@tonic-gate  * the IBMF Message may be reused for both sequenced and non-sequenced
693*0Sstevel@tonic-gate  * transactions. Any receive buffers that were allocated by IBMF from a
694*0Sstevel@tonic-gate  * previous transaction, will be freed up once the Message is reused in an
695*0Sstevel@tonic-gate  * ibmf_msg_transport() call. New receive buffers will be provided by IBMF
696*0Sstevel@tonic-gate  * if the new transaction is a sequenced transaction.
697*0Sstevel@tonic-gate  *
698*0Sstevel@tonic-gate  * Input arguments:
699*0Sstevel@tonic-gate  *	Handle to the IBMF interface
700*0Sstevel@tonic-gate  *	IBMF QP handle (either allocated via ibmf_alloc_qp() or
701*0Sstevel@tonic-gate  *	    IBMF_QP_HANDLE_DEFAULT [see the NOTE above regarding MAD class])
702*0Sstevel@tonic-gate  *	Pointer to ibmf_msg_t to be sent
703*0Sstevel@tonic-gate  *	A pointer to ibmf_retrans_t to specify retries and timeout
704*0Sstevel@tonic-gate  *	values to use during the transaction.
705*0Sstevel@tonic-gate  *	Function to be called when the operation is done.
706*0Sstevel@tonic-gate  *		(the routine is blocking if this function is NULL).
707*0Sstevel@tonic-gate  *	Argument to be passed when the callback is invoked
708*0Sstevel@tonic-gate  *	flags - set IBMF_MSG_TRANS_FLAG_RMPP if send should use RMPP
709*0Sstevel@tonic-gate  *		set IBMF_MSG_TRANS_FLAG_SEQ if transaction is sequenced
710*0Sstevel@tonic-gate  *
711*0Sstevel@tonic-gate  * Output arguments:
712*0Sstevel@tonic-gate  *	None
713*0Sstevel@tonic-gate  *
714*0Sstevel@tonic-gate  * Return values:
715*0Sstevel@tonic-gate  *	IBMF_SUCCESS		- If blocking call, the operation was
716*0Sstevel@tonic-gate  *				  completed by the transport. For
717*0Sstevel@tonic-gate  *				  non blocking call, the request passed basic
718*0Sstevel@tonic-gate  *				  checks and the callback should be expected.
719*0Sstevel@tonic-gate  *	IBMF_BAD_HANDLE		- operation failure - invalid ibmf handle
720*0Sstevel@tonic-gate  *	IBMF_BAD_QP_HANDLE	- operation failure - invalid qp handle or
721*0Sstevel@tonic-gate  *				  q_key/p_key in msgp->ip_local_addr is
722*0Sstevel@tonic-gate  *				  inconsistent with ibmf_qp_handle (for eg.,
723*0Sstevel@tonic-gate  *				  handle is IBMF_QP_HANDLE_DEFAULT and
724*0Sstevel@tonic-gate  *				  Q_Key/P_Key is non-default and platform
725*0Sstevel@tonic-gate  *				  doesn't support non-default keys on this
726*0Sstevel@tonic-gate  *				  qp_handle or handle is IBMF_QP_HANDLE_DEFAULT
727*0Sstevel@tonic-gate  *				  but MAD class is not the one specified to
728*0Sstevel@tonic-gate  *				  ibmf_register())
729*0Sstevel@tonic-gate  *	IBMF_BAD_PORT_STATE	- operation failure - port in incorrect state
730*0Sstevel@tonic-gate  *				  for packet transmission
731*0Sstevel@tonic-gate  *	IBMF_NO_RESOURCES	- operation failure - temporarily out of
732*0Sstevel@tonic-gate  *				  resources and call may succeed on a retry
733*0Sstevel@tonic-gate  *	IBMF_FAILURE		- operation failure - unspecified error
734*0Sstevel@tonic-gate  *	IBMF_BAD_SIZE		- data size in message to long for single UD pkt
735*0Sstevel@tonic-gate  *	IBMF_BAD_RMPP_OPT	- the class or QP does not support RMPP
736*0Sstevel@tonic-gate  *	IBMF_PARTIAL_TRANSFER	- only part of the received data was returned
737*0Sstevel@tonic-gate  *				  to the client up to the message size limit.
738*0Sstevel@tonic-gate  *	IBMF_TRANS_TIMEOUT	- transaction timed out
739*0Sstevel@tonic-gate  *	IBMF_TRANS_FAILURE	- transaction failure
740*0Sstevel@tonic-gate  *	IBMF_REQ_INVALID	- tried to reuse receive buffer for sending
741*0Sstevel@tonic-gate  *				  message data in a sequenced operation.
742*0Sstevel@tonic-gate  *	IBMF_BUSY		- message already being processed
743*0Sstevel@tonic-gate  *	IBMF_INVALID_ARG	- invalid argument
744*0Sstevel@tonic-gate  *	IBMF_FAILURE		- ibmf internal error
745*0Sstevel@tonic-gate  *	IBMF_NO_RESOURCES	- not enough resources
746*0Sstevel@tonic-gate  *	IBMF_TRANSPORT_FAILURE	- transport call failed
747*0Sstevel@tonic-gate  *	IBMF_BAD_SIZE		- if msgp->im_msgbufs_send.im_bufs_mad_hdr
748*0Sstevel@tonic-gate  *				  is NULL when ibmf_qp_handle is the default
749*0Sstevel@tonic-gate  *				  QP handle, OR, if
750*0Sstevel@tonic-gate  *				  msgp->im_msgbufs_send.im_bufs_mad_hdr
751*0Sstevel@tonic-gate  *				  is NULL when ibmf_qp_handle is not the default
752*0Sstevel@tonic-gate  *				  QP handle and the alternate QP is not being
753*0Sstevel@tonic-gate  *				  used for RAW data traffic.
754*0Sstevel@tonic-gate  */
755*0Sstevel@tonic-gate int	ibmf_msg_transport(
756*0Sstevel@tonic-gate 		ibmf_handle_t		ibmf_handle,
757*0Sstevel@tonic-gate 		ibmf_qp_handle_t	ibmf_qp_handle,
758*0Sstevel@tonic-gate 		ibmf_msg_t		*msgp,
759*0Sstevel@tonic-gate 		ibmf_retrans_t		*retrans,
760*0Sstevel@tonic-gate 		ibmf_msg_cb_t		msg_cb,
761*0Sstevel@tonic-gate 		void			*msg_cb_args,
762*0Sstevel@tonic-gate 		uint_t			flags);
763*0Sstevel@tonic-gate 
764*0Sstevel@tonic-gate #define	IBMF_MSG_TRANS_FLAG_RMPP	0x1
765*0Sstevel@tonic-gate #define	IBMF_MSG_TRANS_FLAG_SEQ		0x2
766*0Sstevel@tonic-gate 
767*0Sstevel@tonic-gate /*
768*0Sstevel@tonic-gate  * ibmf_alloc_msg():
769*0Sstevel@tonic-gate  *
770*0Sstevel@tonic-gate  * Alloc memory to hold the message being sent out or being received.
771*0Sstevel@tonic-gate  * The IBMF client must provide the buffers in im_msgbufs_send before
772*0Sstevel@tonic-gate  * calling ibmf_msg_transport(). If this message is used in a sequenced
773*0Sstevel@tonic-gate  * transaction response or an unsolicited transaction, IBMF will provide
774*0Sstevel@tonic-gate  * the buffers in im_msgbufs_recv with the response, once the
775*0Sstevel@tonic-gate  * transaction is complete.
776*0Sstevel@tonic-gate  * The client is responsible for freeing the buffers pointed to in
777*0Sstevel@tonic-gate  * im_msgbufs_send when they are no longer needed. IBMF will free the buffers
778*0Sstevel@tonic-gate  * in im_msgbufs_send once ibmf_free_msg() is called by the client.
779*0Sstevel@tonic-gate  *
780*0Sstevel@tonic-gate  * This interface may block if IBMF_ALLOC_SLEEP is specified.
781*0Sstevel@tonic-gate  *
782*0Sstevel@tonic-gate  * Input arguments:
783*0Sstevel@tonic-gate  *	Handle to the IBMF interface
784*0Sstevel@tonic-gate  *	sleep flag - IBMF_ALLOC_SLEEP/IBMF_ALLOC_NOSLEEP
785*0Sstevel@tonic-gate  *
786*0Sstevel@tonic-gate  * Output arguments:
787*0Sstevel@tonic-gate  *	Pointer to the buffer allocated; may be NULL if system runs out
788*0Sstevel@tonic-gate  *		of memory and IBMF_ALLOC_NOSLEEP is specified.
789*0Sstevel@tonic-gate  *
790*0Sstevel@tonic-gate  * Return values:
791*0Sstevel@tonic-gate  *	IBMF_SUCCESS		- allocation successful
792*0Sstevel@tonic-gate  *	IBMF_BAD_HANDLE		- alloc failed - Invalid IBMF handle passed in
793*0Sstevel@tonic-gate  *	IBMF_BAD_FLAGS		- allocation failed - invalid flags
794*0Sstevel@tonic-gate  *	IBMF_INVALID_ARG	- allocation failed - invalid argument
795*0Sstevel@tonic-gate  *	IBMF_FAILURE		- ibmf internal error
796*0Sstevel@tonic-gate  *	IBMF_NO_RESOURCES	- not enough resources
797*0Sstevel@tonic-gate  *	IBMF_TRANSPORT_FAILURE	- transport call failed
798*0Sstevel@tonic-gate  */
799*0Sstevel@tonic-gate int	ibmf_alloc_msg(
800*0Sstevel@tonic-gate 		ibmf_handle_t		ibmf_handle,
801*0Sstevel@tonic-gate 		int			flag,
802*0Sstevel@tonic-gate 		ibmf_msg_t		**ibmf_msgpp);
803*0Sstevel@tonic-gate 
804*0Sstevel@tonic-gate 
805*0Sstevel@tonic-gate /*
806*0Sstevel@tonic-gate  * ibmf_free_msg():
807*0Sstevel@tonic-gate  *
808*0Sstevel@tonic-gate  * Free message context. This message context is either allocated when
809*0Sstevel@tonic-gate  * the client calls ibmf_alloc_msg() or is allocated by IBMF automatically in
810*0Sstevel@tonic-gate  * response to incoming unsolicited messages. For all incoming messages,
811*0Sstevel@tonic-gate  * solicited or unsolicited, IBMF will provide the buffers pointed to
812*0Sstevel@tonic-gate  * in im_msgbufs_recv. In addition to freeing the message context,
813*0Sstevel@tonic-gate  * IBMF is responsible for freeing any buffers allocated by itself,
814*0Sstevel@tonic-gate  * and pointed to in im_msgbufs_recv when the client calls ibmf_free_msg().
815*0Sstevel@tonic-gate  *
816*0Sstevel@tonic-gate  * This interface does not block
817*0Sstevel@tonic-gate  *
818*0Sstevel@tonic-gate  * Input arguments:
819*0Sstevel@tonic-gate  *	Handle to the IBMF interface
820*0Sstevel@tonic-gate  *	Pointer to the buffer to be freed
821*0Sstevel@tonic-gate  *
822*0Sstevel@tonic-gate  * Output arguments:
823*0Sstevel@tonic-gate  *	None
824*0Sstevel@tonic-gate  *
825*0Sstevel@tonic-gate  * Return values:
826*0Sstevel@tonic-gate  *	IBMF_SUCCESS		- free successful
827*0Sstevel@tonic-gate  *	IBMF_BAD_HANDLE		- free failed - Invalid IBMF handle passed in
828*0Sstevel@tonic-gate  *	IBMF_BUSY		- free failed - message in use
829*0Sstevel@tonic-gate  *	IBMF_INVALID_ARG	- free failed - invalid argument
830*0Sstevel@tonic-gate  *	IBMF_FAILURE		- ibmf internal error
831*0Sstevel@tonic-gate  *	IBMF_NO_RESOURCES	- not enough resources
832*0Sstevel@tonic-gate  *	IBMF_TRANSPORT_FAILURE	- transport call failed
833*0Sstevel@tonic-gate  */
834*0Sstevel@tonic-gate int	ibmf_free_msg(
835*0Sstevel@tonic-gate 		ibmf_handle_t		ibmf_handle,
836*0Sstevel@tonic-gate 		ibmf_msg_t		**ibmf_msgpp);
837*0Sstevel@tonic-gate 
838*0Sstevel@tonic-gate 
839*0Sstevel@tonic-gate /*
840*0Sstevel@tonic-gate  * ibmf_alloc_qp():
841*0Sstevel@tonic-gate  *
842*0Sstevel@tonic-gate  * Alloc a qp with the specified P_key and Q_key values. A pointer to
843*0Sstevel@tonic-gate  * ibmf_qp_handle_t is returned if the call is successful. The qp is
844*0Sstevel@tonic-gate  * associated with the port that ibmf_handle corresponds to.
845*0Sstevel@tonic-gate  *
846*0Sstevel@tonic-gate  * Non-special QPs may be tagged to send and receive
847*0Sstevel@tonic-gate  * one of the three types of traffic, either non-MAD UD, or MADs with
848*0Sstevel@tonic-gate  * RMPP or MADs without RMPP.
849*0Sstevel@tonic-gate  * The tagging should be done when calling ibmf_alloc_qp()
850*0Sstevel@tonic-gate  * by setting the flags argument in the ibmf_alloc_qp() interface
851*0Sstevel@tonic-gate  * function call to specifically defined values.
852*0Sstevel@tonic-gate  * Only one, and at least one, of these flags must be specified.
853*0Sstevel@tonic-gate  *
854*0Sstevel@tonic-gate  * A client may specify the IBMF_ALT_QP_RAW_ONLY flag to limit
855*0Sstevel@tonic-gate  * the QP to non-MAD UD traffic. If this flag is specified, and the
856*0Sstevel@tonic-gate  * IBMF implementation supports this flag, the client may send
857*0Sstevel@tonic-gate  * and receive MADs up to the maximum MTU supported on the link
858*0Sstevel@tonic-gate  * connected to the chosen port.
859*0Sstevel@tonic-gate  *
860*0Sstevel@tonic-gate  * If any of the flag options are not supported by the IBMF implementation,
861*0Sstevel@tonic-gate  * IBMF will return IBMF_NOT_SUPPORTED.
862*0Sstevel@tonic-gate  *
863*0Sstevel@tonic-gate  * This interface may block
864*0Sstevel@tonic-gate  *
865*0Sstevel@tonic-gate  * Input arguments:
866*0Sstevel@tonic-gate  *	Handle to the IBMF interface
867*0Sstevel@tonic-gate  *	P_Key
868*0Sstevel@tonic-gate  *	Q_Key
869*0Sstevel@tonic-gate  *	flags - IBMF_ALT_QP_MAD_NO_RMPP = MAD traffic only,
870*0Sstevel@tonic-gate  *		IBMF_ALT_QP_MAD_RMPP = RMPP MADs only,
871*0Sstevel@tonic-gate  *		IBMF_ALT_QP_RAW_ONLY = Non-MAD UD traffic only
872*0Sstevel@tonic-gate  *
873*0Sstevel@tonic-gate  * Output arguments:
874*0Sstevel@tonic-gate  *	Pointer to the qp handle
875*0Sstevel@tonic-gate  *
876*0Sstevel@tonic-gate  * Return values:
877*0Sstevel@tonic-gate  *	IBMF_SUCCESS		- allocation successful
878*0Sstevel@tonic-gate  *	IBMF_BAD_HANDLE		- alloc failed - Invalid IBMF handle passed in
879*0Sstevel@tonic-gate  *	IBMF_NO_RESOURCES	- alloc failed - no resources for qp allocation
880*0Sstevel@tonic-gate  *	IBMF_BAD_FLAGS		- allocation failed - bad flag combination
881*0Sstevel@tonic-gate  *	IBMF_NOT_SUPPORTED	- allocation failed - unsupported traffic
882*0Sstevel@tonic-gate  *	IBMF_INVALID_ARG	- allocation failed - invalid argument
883*0Sstevel@tonic-gate  *	IBMF_NO_RESOURCES	- not enough resources
884*0Sstevel@tonic-gate  *	IBMF_TRANSPORT_FAILURE	- transport call failed
885*0Sstevel@tonic-gate  *
886*0Sstevel@tonic-gate  */
887*0Sstevel@tonic-gate int	ibmf_alloc_qp(
888*0Sstevel@tonic-gate 		ibmf_handle_t		ibmf_handle,
889*0Sstevel@tonic-gate 		ib_pkey_t		p_key,
890*0Sstevel@tonic-gate 		ib_qkey_t		q_key,
891*0Sstevel@tonic-gate 		uint_t			flags,
892*0Sstevel@tonic-gate 		ibmf_qp_handle_t	*ibmf_qp_handlep);
893*0Sstevel@tonic-gate 
894*0Sstevel@tonic-gate /* Flags values for ibmf_alloc_qp() flags argument */
895*0Sstevel@tonic-gate #define	IBMF_ALT_QP_MAD_NO_RMPP		0x1
896*0Sstevel@tonic-gate #define	IBMF_ALT_QP_MAD_RMPP		0x2
897*0Sstevel@tonic-gate #define	IBMF_ALT_QP_RAW_ONLY		0x4
898*0Sstevel@tonic-gate 
899*0Sstevel@tonic-gate /*
900*0Sstevel@tonic-gate  * ibmf_query_qp():
901*0Sstevel@tonic-gate  *
902*0Sstevel@tonic-gate  * This function returns the P_Key, Q_Key, qp num and the port num that the
903*0Sstevel@tonic-gate  * qp_handle corresponds to. It is possible that some other thread is
904*0Sstevel@tonic-gate  * modifying the p_key and q_key for the qp_handle while this function is
905*0Sstevel@tonic-gate  * executing or some other thread modifies the p_key/q_key values after the
906*0Sstevel@tonic-gate  * function returns.
907*0Sstevel@tonic-gate  * It is the callers responsibility to deal with these cases.
908*0Sstevel@tonic-gate  *
909*0Sstevel@tonic-gate  * This interface does not block.
910*0Sstevel@tonic-gate  *
911*0Sstevel@tonic-gate  * Input arguments:
912*0Sstevel@tonic-gate  *	Handle to the IBMF interface
913*0Sstevel@tonic-gate  *	IBMF qp handle (this can not be IBMF_QP_HANDLE_DEFAULT)
914*0Sstevel@tonic-gate  *	flags - unused (should be 0)
915*0Sstevel@tonic-gate  *
916*0Sstevel@tonic-gate  * Output arguments:
917*0Sstevel@tonic-gate  *	Pointer to QP num
918*0Sstevel@tonic-gate  *	Pointer to P_key
919*0Sstevel@tonic-gate  *	Pointer to Q_key
920*0Sstevel@tonic-gate  *	Pointer to the port num
921*0Sstevel@tonic-gate  *
922*0Sstevel@tonic-gate  * Return values:
923*0Sstevel@tonic-gate  *	IBMF_SUCCESS		- call successful
924*0Sstevel@tonic-gate  *	IBMF_BAD_HANDLE		- failure - Invalid IBMF handle
925*0Sstevel@tonic-gate  *	IBMF_BAD_QP_HANDLE	- failure - Invalid qp handle
926*0Sstevel@tonic-gate  *	IBMF_INVALID_ARG	- failure - invalid argument
927*0Sstevel@tonic-gate  *	IBMF_TRANSPORT_FAILURE	- transport call failed
928*0Sstevel@tonic-gate  */
929*0Sstevel@tonic-gate int	ibmf_query_qp(
930*0Sstevel@tonic-gate 		ibmf_handle_t		ibmf_handle,
931*0Sstevel@tonic-gate 		ibmf_qp_handle_t	ibmf_qp_handle,
932*0Sstevel@tonic-gate 		uint_t			*qp_num,
933*0Sstevel@tonic-gate 		ib_pkey_t		*p_key,
934*0Sstevel@tonic-gate 		ib_qkey_t		*q_key,
935*0Sstevel@tonic-gate 		uint8_t			*portnum,
936*0Sstevel@tonic-gate 		uint_t			flags);
937*0Sstevel@tonic-gate 
938*0Sstevel@tonic-gate /*
939*0Sstevel@tonic-gate  * ibmf_modify_qp():
940*0Sstevel@tonic-gate  *
941*0Sstevel@tonic-gate  * This function sets the p_key and q_key associated with the qp handle to the
942*0Sstevel@tonic-gate  * values specified.
943*0Sstevel@tonic-gate  *
944*0Sstevel@tonic-gate  * This interface may block.
945*0Sstevel@tonic-gate  *
946*0Sstevel@tonic-gate  * Input arguments:
947*0Sstevel@tonic-gate  *	Handle to the IBMF interface
948*0Sstevel@tonic-gate  *	IBMF qp handle (this can not be IBMF_QP_HANDLE_DEFAULT)
949*0Sstevel@tonic-gate  *	P_key
950*0Sstevel@tonic-gate  *	Q_key
951*0Sstevel@tonic-gate  *	flags - unused (should be 0)
952*0Sstevel@tonic-gate  *
953*0Sstevel@tonic-gate  * Output arguments:
954*0Sstevel@tonic-gate  *	None
955*0Sstevel@tonic-gate  *
956*0Sstevel@tonic-gate  * Return values:
957*0Sstevel@tonic-gate  *	IBMF_SUCCESS		- call successful
958*0Sstevel@tonic-gate  *	IBMF_BAD_HANDLE		- failure - Invalid IBMF handle or qp handle
959*0Sstevel@tonic-gate  *	IBMF_BAD_QP_HANDLE	- failure - Invalid qp handle
960*0Sstevel@tonic-gate  *	IBMF_INVALID_ARG	- failure - invalid argument
961*0Sstevel@tonic-gate  *	IBMF_TRANSPORT_FAILURE	- transport call failed
962*0Sstevel@tonic-gate  */
963*0Sstevel@tonic-gate int	ibmf_modify_qp(
964*0Sstevel@tonic-gate 		ibmf_handle_t		ibmf_handle,
965*0Sstevel@tonic-gate 		ibmf_qp_handle_t	ibmf_qp_handle,
966*0Sstevel@tonic-gate 		ib_pkey_t		p_key,
967*0Sstevel@tonic-gate 		ib_qkey_t		q_key,
968*0Sstevel@tonic-gate 		uint_t			flags);
969*0Sstevel@tonic-gate 
970*0Sstevel@tonic-gate /*
971*0Sstevel@tonic-gate  * ibmf_free_qp():
972*0Sstevel@tonic-gate  *
973*0Sstevel@tonic-gate  * This function frees a qp allocated by ibmf_alloc_qp().
974*0Sstevel@tonic-gate  * The ibmf handle argument must be the same ibmf handle used in the
975*0Sstevel@tonic-gate  * corresponding ibmf_alloc_qp() call. ibmf_unregister() for the ibmf
976*0Sstevel@tonic-gate  * handle will not be allowed until all associated qps are freed.
977*0Sstevel@tonic-gate  * The client must have already invoked ibmf_tear_down_recv_cb()
978*0Sstevel@tonic-gate  * for this qp handle prior to calling ibmf_free_qp(), else IBMF_BUSY
979*0Sstevel@tonic-gate  * will be returned.
980*0Sstevel@tonic-gate  *
981*0Sstevel@tonic-gate  * This interface may block.
982*0Sstevel@tonic-gate  *
983*0Sstevel@tonic-gate  * Input arguments:
984*0Sstevel@tonic-gate  *	Handle to the IBMF interface
985*0Sstevel@tonic-gate  *	IBMF qp handle pointer (this can not be IBMF_QP_HANDLE_DEFAULT)
986*0Sstevel@tonic-gate  *	flags - unused (should be 0)
987*0Sstevel@tonic-gate  *
988*0Sstevel@tonic-gate  * Output arguments:
989*0Sstevel@tonic-gate  *	IBMF qp handle; will be invalidated following successful return from
990*0Sstevel@tonic-gate  *	this call
991*0Sstevel@tonic-gate  *
992*0Sstevel@tonic-gate  * Return values:
993*0Sstevel@tonic-gate  *	IBMF_SUCCESS		- call successful
994*0Sstevel@tonic-gate  *	IBMF_BAD_HANDLE		- failure - Invalid IBMF handle or qp handle
995*0Sstevel@tonic-gate  *	IBMF_BAD_QP_HANDLE	- failure - Invalid qp handle
996*0Sstevel@tonic-gate  *	IBMF_BUSY		- failure - callback is active
997*0Sstevel@tonic-gate  *	IBMF_INVALID_ARG	- failure - invalid argument
998*0Sstevel@tonic-gate  *	IBMF_TRANSPORT_FAILURE	- transport call failed
999*0Sstevel@tonic-gate  */
1000*0Sstevel@tonic-gate int	ibmf_free_qp(
1001*0Sstevel@tonic-gate 		ibmf_handle_t		ibmf_handle,
1002*0Sstevel@tonic-gate 		ibmf_qp_handle_t	*ibmf_qp_handle,
1003*0Sstevel@tonic-gate 		uint_t			flags);
1004*0Sstevel@tonic-gate 
1005*0Sstevel@tonic-gate #ifdef __cplusplus
1006*0Sstevel@tonic-gate }
1007*0Sstevel@tonic-gate #endif
1008*0Sstevel@tonic-gate 
1009*0Sstevel@tonic-gate #endif /* _SYS_IB_MGT_IBMF_IBMF_H */
1010