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