xref: /onnv-gate/usr/src/uts/common/sys/ib/mgt/ibmf/ibmf_saa.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 2003 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_SAA_H
28*0Sstevel@tonic-gate #define	_SYS_IB_MGT_IBMF_IBMF_SAA_H
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate #ifdef	__cplusplus
33*0Sstevel@tonic-gate extern "C" {
34*0Sstevel@tonic-gate #endif
35*0Sstevel@tonic-gate 
36*0Sstevel@tonic-gate #include <sys/ib/ib_types.h>
37*0Sstevel@tonic-gate #include <sys/ib/mgt/sa_recs.h>
38*0Sstevel@tonic-gate 
39*0Sstevel@tonic-gate /*
40*0Sstevel@tonic-gate  * SA Access Interface: Interfaces to enable access to the SA
41*0Sstevel@tonic-gate  */
42*0Sstevel@tonic-gate 
43*0Sstevel@tonic-gate #define	IBMF_SAA_PKEY_WC	0	/* partition key wildcard */
44*0Sstevel@tonic-gate #define	IBMF_SAA_MTU_WC		0	/* mtu wilcard for gid_to_pathrecords */
45*0Sstevel@tonic-gate 
46*0Sstevel@tonic-gate typedef enum _ibmf_saa_access_type_t {
47*0Sstevel@tonic-gate 	IBMF_SAA_RETRIEVE,
48*0Sstevel@tonic-gate 	IBMF_SAA_UPDATE,
49*0Sstevel@tonic-gate 	IBMF_SAA_DELETE
50*0Sstevel@tonic-gate } ibmf_saa_access_type_t;
51*0Sstevel@tonic-gate 
52*0Sstevel@tonic-gate /*
53*0Sstevel@tonic-gate  * ibmf_saa_handle
54*0Sstevel@tonic-gate  *	Opaque handle to identify the consumer
55*0Sstevel@tonic-gate  */
56*0Sstevel@tonic-gate typedef struct ibmf_saa_handle *ibmf_saa_handle_t;
57*0Sstevel@tonic-gate 
58*0Sstevel@tonic-gate /*
59*0Sstevel@tonic-gate  * ibmf_saa_cb_t
60*0Sstevel@tonic-gate  * ibmf_saa's callback to clients to inform them that the response to an
61*0Sstevel@tonic-gate  * asynchronous request has arrived or that the request timed out.
62*0Sstevel@tonic-gate  *
63*0Sstevel@tonic-gate  * Input Arguments
64*0Sstevel@tonic-gate  * clnt_private - opaque handle to client specific data (sq_callback_arg)
65*0Sstevel@tonic-gate  * length - size of response returned
66*0Sstevel@tonic-gate  * result - pointer to buffer of response.  Data will be in host-endian format
67*0Sstevel@tonic-gate  * and unpacked.  Client can just cast to a pointer to the structure
68*0Sstevel@tonic-gate  * status - ibmf status.  Status can be any of the values returned by a
69*0Sstevel@tonic-gate  * synchronous ibmf_sa_access() call.
70*0Sstevel@tonic-gate  *
71*0Sstevel@tonic-gate  * Output Arguments
72*0Sstevel@tonic-gate  * none
73*0Sstevel@tonic-gate  *
74*0Sstevel@tonic-gate  * Returns
75*0Sstevel@tonic-gate  * none
76*0Sstevel@tonic-gate  */
77*0Sstevel@tonic-gate typedef void (*ibmf_saa_cb_t) (
78*0Sstevel@tonic-gate     void 	*callback_arg,
79*0Sstevel@tonic-gate     size_t	length,
80*0Sstevel@tonic-gate     char	*result,
81*0Sstevel@tonic-gate     int		status);
82*0Sstevel@tonic-gate 
83*0Sstevel@tonic-gate /*
84*0Sstevel@tonic-gate  * structure to provide parameters to ibmf_sa_access call
85*0Sstevel@tonic-gate  */
86*0Sstevel@tonic-gate typedef struct ibmf_saa_access_args_s {
87*0Sstevel@tonic-gate 	/* MAD attribute ID */
88*0Sstevel@tonic-gate 	uint16_t		sq_attr_id;
89*0Sstevel@tonic-gate 
90*0Sstevel@tonic-gate 	/* retrieve, update, or delete */
91*0Sstevel@tonic-gate 	ibmf_saa_access_type_t 	sq_access_type;
92*0Sstevel@tonic-gate 
93*0Sstevel@tonic-gate 	/* SA MAD component mask indicating fields in template to query on */
94*0Sstevel@tonic-gate 	uint64_t		sq_component_mask;
95*0Sstevel@tonic-gate 
96*0Sstevel@tonic-gate 	/* pointer to template */
97*0Sstevel@tonic-gate 	void			*sq_template;
98*0Sstevel@tonic-gate 
99*0Sstevel@tonic-gate 	/*
100*0Sstevel@tonic-gate 	 * length, in bytes, of template size for attributes which ibmf does
101*0Sstevel@tonic-gate 	 * not know about; ignored for known attribute id's.  length should be
102*0Sstevel@tonic-gate 	 * wire length and template for unknown attributes should be in wire
103*0Sstevel@tonic-gate 	 * format as ibmf will not be able to pack data.
104*0Sstevel@tonic-gate 	 */
105*0Sstevel@tonic-gate 	size_t			sq_template_length;
106*0Sstevel@tonic-gate 
107*0Sstevel@tonic-gate 	/* callback and argument when asynchronous request returns */
108*0Sstevel@tonic-gate 	ibmf_saa_cb_t		sq_callback;
109*0Sstevel@tonic-gate 	void			*sq_callback_arg;
110*0Sstevel@tonic-gate } ibmf_saa_access_args_t;
111*0Sstevel@tonic-gate 
112*0Sstevel@tonic-gate /*
113*0Sstevel@tonic-gate  * enumeration of subnet events
114*0Sstevel@tonic-gate  *
115*0Sstevel@tonic-gate  * IBMF_SAA_EVENT_GID_AVAILABLE
116*0Sstevel@tonic-gate  *              the identified gid is available
117*0Sstevel@tonic-gate  * IBMF_SAA_EVENT_GID_UNAVAILABLE
118*0Sstevel@tonic-gate  *              the identified gid is unavailable
119*0Sstevel@tonic-gate  * IBMF_SAA_EVENT_MCG_CREATED
120*0Sstevel@tonic-gate  *              MC group identified by mgid is created
121*0Sstevel@tonic-gate  * IBMF_SAA_EVENT_MCG_DELETED
122*0Sstevel@tonic-gate  *              MC group identified by mgid is deleted
123*0Sstevel@tonic-gate  * IBMF_SAA_EVENT_CAP_MASK_CHG
124*0Sstevel@tonic-gate  *              Portinfo.CapabilityMask changed
125*0Sstevel@tonic-gate  * IBMF_SAA_EVENT_SYS_IMG_GUID_CHG
126*0Sstevel@tonic-gate  *              System Image GUID changed
127*0Sstevel@tonic-gate  * IBMF_SAA_EVENT_SUBSCRIBER_STATUS_CHG
128*0Sstevel@tonic-gate  *		Status of ibmf subscriptions changed
129*0Sstevel@tonic-gate  */
130*0Sstevel@tonic-gate typedef enum ibmf_saa_subnet_event_e {
131*0Sstevel@tonic-gate 
132*0Sstevel@tonic-gate 	IBMF_SAA_EVENT_GID_AVAILABLE,
133*0Sstevel@tonic-gate 	IBMF_SAA_EVENT_GID_UNAVAILABLE,
134*0Sstevel@tonic-gate 	IBMF_SAA_EVENT_MCG_CREATED,
135*0Sstevel@tonic-gate 	IBMF_SAA_EVENT_MCG_DELETED,
136*0Sstevel@tonic-gate 	IBMF_SAA_EVENT_CAP_MASK_CHG,
137*0Sstevel@tonic-gate 	IBMF_SAA_EVENT_SYS_IMG_GUID_CHG,
138*0Sstevel@tonic-gate 	IBMF_SAA_EVENT_SUBSCRIBER_STATUS_CHG
139*0Sstevel@tonic-gate 
140*0Sstevel@tonic-gate } ibmf_saa_subnet_event_t;
141*0Sstevel@tonic-gate 
142*0Sstevel@tonic-gate /*
143*0Sstevel@tonic-gate  * ibmf must subscribe with the Subnet Administrator to provide the subnet
144*0Sstevel@tonic-gate  * events for its clients.  It registers for the four trap producer types: CA,
145*0Sstevel@tonic-gate  * switch, router, and subnet management.  If any of these registrations fails
146*0Sstevel@tonic-gate  * the ibmf will notify each client that registered for events.  Clients are
147*0Sstevel@tonic-gate  * notified by ibmf through their registered callback and the
148*0Sstevel@tonic-gate  * SUBSCRIBER_STATUS_CHG event.
149*0Sstevel@tonic-gate  *
150*0Sstevel@tonic-gate  * For this event, the event_details producer_type_status_mask will be set.
151*0Sstevel@tonic-gate  * Each bit in the mask corresponds to a different producer type.  When the bit
152*0Sstevel@tonic-gate  * is on the ibmf was able to successfully subscribe for events from that
153*0Sstevel@tonic-gate  * producer.  When the bit is off, ibmf was unable to subscribe and clients may
154*0Sstevel@tonic-gate  * not receive events from that producer type.
155*0Sstevel@tonic-gate  *
156*0Sstevel@tonic-gate  * For example, if the status_mask is 0xb then events will be received that
157*0Sstevel@tonic-gate  * correspond to CA's, switches, and subnet management traps.  However, traps
158*0Sstevel@tonic-gate  * generated by routers may not be received.
159*0Sstevel@tonic-gate  *
160*0Sstevel@tonic-gate  * The ibmf re-registers for events when the port transitions to active.  If the
161*0Sstevel@tonic-gate  * event status mask changes the ibmf will generate another
162*0Sstevel@tonic-gate  * SUBSCRIBER_STATUS_CHG event with the new producer type status mask.  When
163*0Sstevel@tonic-gate  * clients register they should only expect to receive a SUBSCRIBER_STATUS_CHG
164*0Sstevel@tonic-gate  * event if one of the registrations failed.  If all four registrations
165*0Sstevel@tonic-gate  * succeeded no event will be generated.
166*0Sstevel@tonic-gate  *
167*0Sstevel@tonic-gate  * If the port goes down, a SUBSCRIBER_STATUS_CHG event is not generated.
168*0Sstevel@tonic-gate  * Clients should realize that events will not be forwarded.  If the port
169*0Sstevel@tonic-gate  * transitions back to active ibmf_saa will resubscribe on behalf of the client.
170*0Sstevel@tonic-gate  * If this subscription fails a SUBSCRIBER_STATUS_CHG event will be generated.
171*0Sstevel@tonic-gate  *
172*0Sstevel@tonic-gate  */
173*0Sstevel@tonic-gate 
174*0Sstevel@tonic-gate #define	IBMF_SAA_EVENT_STATUS_MASK_PRODUCER_CA		(1 << 0)
175*0Sstevel@tonic-gate #define	IBMF_SAA_EVENT_STATUS_MASK_PRODUCER_SWITCH	(1 << 1)
176*0Sstevel@tonic-gate #define	IBMF_SAA_EVENT_STATUS_MASK_PRODUCER_ROUTER	(1 << 2)
177*0Sstevel@tonic-gate #define	IBMF_SAA_EVENT_STATUS_MASK_PRODUCER_SM		(1 << 3)
178*0Sstevel@tonic-gate 
179*0Sstevel@tonic-gate /*
180*0Sstevel@tonic-gate  * structure passed as event_details argument of ibmf_saa subnet event
181*0Sstevel@tonic-gate  * callback.
182*0Sstevel@tonic-gate  *
183*0Sstevel@tonic-gate  * Only some of the structure members are valid for a given event as given
184*0Sstevel@tonic-gate  * below:
185*0Sstevel@tonic-gate  *
186*0Sstevel@tonic-gate  * member              		event type
187*0Sstevel@tonic-gate  * ------              		----------
188*0Sstevel@tonic-gate  * ie_gid               	IBMF_SAA_EVENT_GID_AVAILABLE,
189*0Sstevel@tonic-gate  *					IBMF_SAA_EVENT_GID_UNAVAILABLE,
190*0Sstevel@tonic-gate  *                              	IBMF_SAA_EVENT_MCG_CREATED, and
191*0Sstevel@tonic-gate  *                              	IBMF_SAA_EVENT_MCG_DELETED
192*0Sstevel@tonic-gate  * ie_lid               	IBMF_SAA_EVENT_CAP_MASK_CHG and
193*0Sstevel@tonic-gate  *                              	IBMF_SAA_EVENT_SYS_IMG_GUID_CHG
194*0Sstevel@tonic-gate  * ie_capability_mask   	IBMF_SAA_EVENT_CAP_MASK_CHG
195*0Sstevel@tonic-gate  * ie_sysimg_guid       	IBMF_SAA_EVENT_SYS_IMG_GUID_CHG
196*0Sstevel@tonic-gate  * ie_producer_type_status_mask	IBMF_SAA_EVENT_SUBSCRIBER_STATUS_CHG
197*0Sstevel@tonic-gate  *
198*0Sstevel@tonic-gate  */
199*0Sstevel@tonic-gate typedef struct ibmf_saa_event_details_s {
200*0Sstevel@tonic-gate 	ib_gid_t	ie_gid;
201*0Sstevel@tonic-gate 	ib_guid_t	ie_sysimg_guid;
202*0Sstevel@tonic-gate 	uint32_t	ie_capability_mask; /* values defined in sm_attr.h */
203*0Sstevel@tonic-gate 	ib_lid_t	ie_lid;
204*0Sstevel@tonic-gate 	uint8_t		ie_producer_event_status_mask;
205*0Sstevel@tonic-gate } ibmf_saa_event_details_t;
206*0Sstevel@tonic-gate 
207*0Sstevel@tonic-gate /*
208*0Sstevel@tonic-gate  * Callback invoked when one of the events the client subscribed for
209*0Sstevel@tonic-gate  * at ibmf_sa_session_open() time happens.
210*0Sstevel@tonic-gate  *
211*0Sstevel@tonic-gate  * This callback can occur before ibmf_sa_session_open() returns.
212*0Sstevel@tonic-gate  *
213*0Sstevel@tonic-gate  * Each callback is on a separate thread.  ibmf clients may block in the event
214*0Sstevel@tonic-gate  * callback.  However, under heavy system load ibmf may not be able to generate
215*0Sstevel@tonic-gate  * event callbacks.  Also, event callbacks, including SUBSCRIBER_STATUS_CHG,
216*0Sstevel@tonic-gate  * could be dispatched out-of-order.
217*0Sstevel@tonic-gate  *
218*0Sstevel@tonic-gate  * Arguments:
219*0Sstevel@tonic-gate  * ibmf_saa_handle              - Client's ibmf_saa_handle
220*0Sstevel@tonic-gate  * ibmf_saa_event               - event that caused the callback
221*0Sstevel@tonic-gate  * event_details                - additional data for the event
222*0Sstevel@tonic-gate  * callback_arg                 - event_callback_arg member of
223*0Sstevel@tonic-gate  *                                ibmf_saa_subnet_event_args_t
224*0Sstevel@tonic-gate  */
225*0Sstevel@tonic-gate typedef void (*ibmf_saa_subnet_event_cb_t)(
226*0Sstevel@tonic-gate 	ibmf_saa_handle_t		ibmf_saa_handle,
227*0Sstevel@tonic-gate 	ibmf_saa_subnet_event_t		ibmf_saa_event,
228*0Sstevel@tonic-gate 	ibmf_saa_event_details_t	*event_details,
229*0Sstevel@tonic-gate 	void				*callback_arg);
230*0Sstevel@tonic-gate 
231*0Sstevel@tonic-gate typedef struct ibmf_saa_subnet_event_args_s {
232*0Sstevel@tonic-gate 
233*0Sstevel@tonic-gate 	/* func to be called when a subnet event happens */
234*0Sstevel@tonic-gate 	ibmf_saa_subnet_event_cb_t	is_event_callback;
235*0Sstevel@tonic-gate 
236*0Sstevel@tonic-gate 	/* call back arg */
237*0Sstevel@tonic-gate 	void				*is_event_callback_arg;
238*0Sstevel@tonic-gate 
239*0Sstevel@tonic-gate } ibmf_saa_subnet_event_args_t;
240*0Sstevel@tonic-gate 
241*0Sstevel@tonic-gate /*
242*0Sstevel@tonic-gate  * ibmf_sa_session_open():
243*0Sstevel@tonic-gate  *
244*0Sstevel@tonic-gate  * Before using the ibmf_saa interface, consumers should register with the
245*0Sstevel@tonic-gate  * ibmf_saa interface by calling ibmf_sa_session_open(). Upon a successful
246*0Sstevel@tonic-gate  * registration, a handle is returned for use in subsequent interaction with the
247*0Sstevel@tonic-gate  * ibmf_saa interface; this handle is also provided as an argument to subnet
248*0Sstevel@tonic-gate  * event notification function.
249*0Sstevel@tonic-gate  *
250*0Sstevel@tonic-gate  * Consumers can register to be notified of subnet events such as GID
251*0Sstevel@tonic-gate  * being available/unavailable.  Clients which provide a non-NULL event args
252*0Sstevel@tonic-gate  * structure will have the is_event_callback function called when an event is
253*0Sstevel@tonic-gate  * received or there is a failure in subscribing for events.  This callback may
254*0Sstevel@tonic-gate  * be generated before the ibmf_sa_session_open() call returns.
255*0Sstevel@tonic-gate  *
256*0Sstevel@tonic-gate  * This interface blocks allocating memory, but not waiting for any packet
257*0Sstevel@tonic-gate  * responses.
258*0Sstevel@tonic-gate  *
259*0Sstevel@tonic-gate  * Arguments:
260*0Sstevel@tonic-gate  * port_guid            - GUID of the port.
261*0Sstevel@tonic-gate  * event_args		- subnet event registration details
262*0Sstevel@tonic-gate  * sm_key               - only filled in if the consumer is an SM
263*0Sstevel@tonic-gate  * ibmf_version         - version of the interface (IBMF_VERSION)
264*0Sstevel@tonic-gate  * flags                - unused
265*0Sstevel@tonic-gate  *
266*0Sstevel@tonic-gate  * Return values:
267*0Sstevel@tonic-gate  * IBMF_SUCCESS         - registration succeeded
268*0Sstevel@tonic-gate  * IBMF_BAD_PORT	- registration failed; active port not found
269*0Sstevel@tonic-gate  * IBMF_BAD_PORT_STATE  - registration failed; port found but not active or
270*0Sstevel@tonic-gate  * 			previous registration failed
271*0Sstevel@tonic-gate  * IBMF_NO_MEMORY	- registration failed; could not allocate memory
272*0Sstevel@tonic-gate  * IBMF_NO_RESOURCES    - registration failed due to a resource issue
273*0Sstevel@tonic-gate  * IBMF_BUSY            - registration failed; too many clients registered
274*0Sstevel@tonic-gate  *                      for this port
275*0Sstevel@tonic-gate  * IBMF_TRANSPORT_FAILURE - failure with underlying transport framework
276*0Sstevel@tonic-gate  * IBMF_INVALID_ARG     - ibmf_saa_handle arg was NULL
277*0Sstevel@tonic-gate  */
278*0Sstevel@tonic-gate int ibmf_sa_session_open(
279*0Sstevel@tonic-gate 		ib_guid_t			port_guid,
280*0Sstevel@tonic-gate 		ib_smkey_t			sm_key,
281*0Sstevel@tonic-gate 		ibmf_saa_subnet_event_args_t	*event_args,
282*0Sstevel@tonic-gate 		uint_t				ibmf_version,
283*0Sstevel@tonic-gate 		uint_t				flags,
284*0Sstevel@tonic-gate 		ibmf_saa_handle_t		*ibmf_saa_handle);
285*0Sstevel@tonic-gate 
286*0Sstevel@tonic-gate /*
287*0Sstevel@tonic-gate  * ibmf_sa_session_close()
288*0Sstevel@tonic-gate  *
289*0Sstevel@tonic-gate  * Unregister a consumer of the SA_Access interface
290*0Sstevel@tonic-gate  *
291*0Sstevel@tonic-gate  * This interface blocks.
292*0Sstevel@tonic-gate  *
293*0Sstevel@tonic-gate  * Arguments:
294*0Sstevel@tonic-gate  * ibmf_saa_handle	- handle returned from sa_session_open()
295*0Sstevel@tonic-gate  * flags		- unused
296*0Sstevel@tonic-gate  *
297*0Sstevel@tonic-gate  * Return values:
298*0Sstevel@tonic-gate  * IBMF_SUCCESS		- unregistration succeeded
299*0Sstevel@tonic-gate  * IBMF_BAD_HANDLE	- unregistration failed; handle is not valid or
300*0Sstevel@tonic-gate  *			  session_close has already been called
301*0Sstevel@tonic-gate  * IBMF_INVALID_ARG	- ibmf_saa_handle arg was NULL
302*0Sstevel@tonic-gate  *
303*0Sstevel@tonic-gate  * All outstanding callbacks will be canceled before this function returns.
304*0Sstevel@tonic-gate  */
305*0Sstevel@tonic-gate int	ibmf_sa_session_close(
306*0Sstevel@tonic-gate 		ibmf_saa_handle_t	*ibmf_saa_handle,
307*0Sstevel@tonic-gate 		uint_t			flags);
308*0Sstevel@tonic-gate 
309*0Sstevel@tonic-gate /*
310*0Sstevel@tonic-gate  * ibmf_sa_access
311*0Sstevel@tonic-gate  *
312*0Sstevel@tonic-gate  * Retrieve records from the SA given an AttributeID, ComponentMask,
313*0Sstevel@tonic-gate  * and a template
314*0Sstevel@tonic-gate  *
315*0Sstevel@tonic-gate  * This interface blocks if the callback parameter is NULL.
316*0Sstevel@tonic-gate  *
317*0Sstevel@tonic-gate  * Input Arguments:
318*0Sstevel@tonic-gate  * ibmf_saa_handle	- handle returned from ibmf_sa_session_open()
319*0Sstevel@tonic-gate  * access_args 		- structure containing various parameters for the query
320*0Sstevel@tonic-gate  * flags 		- unsused
321*0Sstevel@tonic-gate  *
322*0Sstevel@tonic-gate  * Output Arguments:
323*0Sstevel@tonic-gate  * length		- size of buffer returned
324*0Sstevel@tonic-gate  * result		- pointer to buffer of records returned in response.
325*0Sstevel@tonic-gate  *			  Buffer is host-endian, unpacked can be cast to one of
326*0Sstevel@tonic-gate  *			  the record types in sa_recs.h
327*0Sstevel@tonic-gate  *
328*0Sstevel@tonic-gate  * Return values:
329*0Sstevel@tonic-gate  * IBMF_SUCCESS 	- query succeeded
330*0Sstevel@tonic-gate  * IBMF_BAD_HANDLE	- sa session handle is invalid
331*0Sstevel@tonic-gate  * IBMF_BAD_PORT_STATE	- port in incorrect state
332*0Sstevel@tonic-gate  * IBMF_INVALID_ARG	- one of the pointer parameters was NULL
333*0Sstevel@tonic-gate  * IBMF_NO_RESOURCES	- ibmf could not allocate ib resources or SA returned
334*0Sstevel@tonic-gate  *			  ERR_NO_RESOURCES
335*0Sstevel@tonic-gate  * IBMF_TRANS_TIMEOUT	- transaction timed out
336*0Sstevel@tonic-gate  * IBMF_TRANS_FAILURE	- transaction failure
337*0Sstevel@tonic-gate  * IBMF_NO_MEMORY	- ibmf could not allocate memory
338*0Sstevel@tonic-gate  * IBMF_REQ_INVALID	- send and recv buffer the same for a sequenced
339*0Sstevel@tonic-gate  *			  transaction or the SA returned an ERR_REQ_INVALID
340*0Sstevel@tonic-gate  * IBMF_NO_RECORDS	- no records matched query
341*0Sstevel@tonic-gate  * IBMF_TOO_MANY_RECORDS- SA returned SA_ERR_TOO_MANY_RECORDS
342*0Sstevel@tonic-gate  * IBMF_INVALID_GID	- SA returned SA_INVALID_GID
343*0Sstevel@tonic-gate  * IBMF_INSUFF_COMPS	- SA returned SA_ERR_INSUFFICIENT_COMPS
344*0Sstevel@tonic-gate  * IBMF_UNSUPP_METHOD	- SA returned MAD_STATUS_UNSUPP_METHOD
345*0Sstevel@tonic-gate  * IBMF_UNSUPP_METHOD_ATTR - SA returned MAD_STATUS_UNSUPP_METHOD_ATTR
346*0Sstevel@tonic-gate  * IBMF_INVALID_FIELD	- SA returned MAD_STATUS_INVALID_FIELD
347*0Sstevel@tonic-gate  * IBMF_NO_ACTIVE_PORTS - no active ports found
348*0Sstevel@tonic-gate  *
349*0Sstevel@tonic-gate  * Upon successful completion, result points to a buffer containing the records.
350*0Sstevel@tonic-gate  * length is the size in bytes of the buffer returned in result.  If there are
351*0Sstevel@tonic-gate  * no records or the call failed the length is 0.
352*0Sstevel@tonic-gate  *
353*0Sstevel@tonic-gate  * The consumer is responsible for freeing the memory associated with result.
354*0Sstevel@tonic-gate  */
355*0Sstevel@tonic-gate int	ibmf_sa_access(
356*0Sstevel@tonic-gate 		ibmf_saa_handle_t	ibmf_saa_handle,
357*0Sstevel@tonic-gate 		ibmf_saa_access_args_t	*access_args,
358*0Sstevel@tonic-gate 		uint_t			flags,
359*0Sstevel@tonic-gate 		size_t			*length,
360*0Sstevel@tonic-gate 		void			**result);
361*0Sstevel@tonic-gate 
362*0Sstevel@tonic-gate /*
363*0Sstevel@tonic-gate  * Helper Functions.
364*0Sstevel@tonic-gate  *	Ease of use functions so that the consumer doesn't
365*0Sstevel@tonic-gate  * 	have to do the overhead of calling ibmf_sa_access() for
366*0Sstevel@tonic-gate  *	commonly used queries
367*0Sstevel@tonic-gate  */
368*0Sstevel@tonic-gate 
369*0Sstevel@tonic-gate /*
370*0Sstevel@tonic-gate  * ibmf_saa_gid_to_pathrecords
371*0Sstevel@tonic-gate  * 	Given a source gid and a destination gid, return paths
372*0Sstevel@tonic-gate  *	between the gids.
373*0Sstevel@tonic-gate  *
374*0Sstevel@tonic-gate  * This interface blocks.
375*0Sstevel@tonic-gate  *
376*0Sstevel@tonic-gate  * Input Arguments:
377*0Sstevel@tonic-gate  * ibmf_saa_handle	- handle returned from ibmf_sa_session_open()
378*0Sstevel@tonic-gate  * sgid 		- source gid of path
379*0Sstevel@tonic-gate  * dgid			- destination gid of path
380*0Sstevel@tonic-gate  * p_key		- partition of path.  This value may be wildcarded with
381*0Sstevel@tonic-gate  *			  IBMF_SAA_PKEY_WC.
382*0Sstevel@tonic-gate  * mtu 			- preferred MTU of the path.  This argument may be
383*0Sstevel@tonic-gate  *			  wildcarded with IBMF_SAA_MTU_WC.
384*0Sstevel@tonic-gate  * reversible		- if B_TRUE, ibmf will query only reversible paths
385*0Sstevel@tonic-gate  *			  see Infiniband Specification table 171
386*0Sstevel@tonic-gate  * num_paths		- maximum number of paths to return
387*0Sstevel@tonic-gate  *			  numpaths should be checked for the actual number of
388*0Sstevel@tonic-gate  *			  records returned.
389*0Sstevel@tonic-gate  * flags		- unused
390*0Sstevel@tonic-gate  *
391*0Sstevel@tonic-gate  * Output Arguments:
392*0Sstevel@tonic-gate  * num_paths		- actual number of paths returned
393*0Sstevel@tonic-gate  * length		- size of buffer returned
394*0Sstevel@tonic-gate  * result		- pointer to buffer of path records returned in response
395*0Sstevel@tonic-gate  *
396*0Sstevel@tonic-gate  * Return values:
397*0Sstevel@tonic-gate  * Error codes are the same as ibmf_sa_access() return values
398*0Sstevel@tonic-gate  *
399*0Sstevel@tonic-gate  * Upon successful completion, result points to a buffer containing the records.
400*0Sstevel@tonic-gate  * length is the size in bytes of the buffer returned in result.  If there are
401*0Sstevel@tonic-gate  * no records or the call failed the length is 0.
402*0Sstevel@tonic-gate  *
403*0Sstevel@tonic-gate  * The consumer is responsible for freeing the memory associated with result.
404*0Sstevel@tonic-gate  */
405*0Sstevel@tonic-gate int	ibmf_saa_gid_to_pathrecords(
406*0Sstevel@tonic-gate 		ibmf_saa_handle_t	ibmf_saa_handle,
407*0Sstevel@tonic-gate 		ib_gid_t		sgid,
408*0Sstevel@tonic-gate 		ib_gid_t		dgid,
409*0Sstevel@tonic-gate 		ib_pkey_t		p_key,
410*0Sstevel@tonic-gate 		ib_mtu_t		mtu,
411*0Sstevel@tonic-gate 		boolean_t		reversible,
412*0Sstevel@tonic-gate 		uint8_t			*num_paths,
413*0Sstevel@tonic-gate 		uint_t			flags,
414*0Sstevel@tonic-gate 		size_t			*length,
415*0Sstevel@tonic-gate 		sa_path_record_t	**result);
416*0Sstevel@tonic-gate /*
417*0Sstevel@tonic-gate  * ibmf_saa_paths_from_gid
418*0Sstevel@tonic-gate  *      Given a source GID, return a path from the source gid
419*0Sstevel@tonic-gate  *	to every other port on the subnet.  It is assumed that the
420*0Sstevel@tonic-gate  *	subnet is fully connected.  Only one path per port on the subnet
421*0Sstevel@tonic-gate  *	is returned.
422*0Sstevel@tonic-gate  *
423*0Sstevel@tonic-gate  * This interface blocks.
424*0Sstevel@tonic-gate  *
425*0Sstevel@tonic-gate  * Arguments:
426*0Sstevel@tonic-gate  * ibmf_saa_handle	- handle returned from ibmf_sa_session_open()
427*0Sstevel@tonic-gate  * sgid 		- source gid of path
428*0Sstevel@tonic-gate  * pkey			- paritition of path.  This value may be wildcarded with
429*0Sstevel@tonic-gate  *			  IBMF_SAA_PKEY_WC.
430*0Sstevel@tonic-gate  * reversible		- if B_TRUE, ibmf will query only reversible paths;
431*0Sstevel@tonic-gate  *			  see Infiniband Specification table 171
432*0Sstevel@tonic-gate  * flags		- unused
433*0Sstevel@tonic-gate  *
434*0Sstevel@tonic-gate  * Output Arguments:
435*0Sstevel@tonic-gate  * num_paths		- number of paths returned
436*0Sstevel@tonic-gate  * length		- size of buffer returned
437*0Sstevel@tonic-gate  * result		- pointer to buffer of path records returned in response
438*0Sstevel@tonic-gate  *
439*0Sstevel@tonic-gate  * Return values:
440*0Sstevel@tonic-gate  * Error codes are the same as ibmf_sa_access() return values
441*0Sstevel@tonic-gate  *
442*0Sstevel@tonic-gate  * Upon successful completion, result points to a buffer containing the records.
443*0Sstevel@tonic-gate  * and num_paths is the number of path records returned.  length is the size
444*0Sstevel@tonic-gate  * in bytes of the buffer returned in result.  If there are no records or the
445*0Sstevel@tonic-gate  * call failed the length is 0.
446*0Sstevel@tonic-gate  *
447*0Sstevel@tonic-gate  * The consumer is responsible for freeing the memory associated with result.
448*0Sstevel@tonic-gate  */
449*0Sstevel@tonic-gate int	ibmf_saa_paths_from_gid(
450*0Sstevel@tonic-gate 		ibmf_saa_handle_t	ibmf_saa_handle,
451*0Sstevel@tonic-gate 		ib_gid_t		sgid,
452*0Sstevel@tonic-gate 		ib_pkey_t		pkey,
453*0Sstevel@tonic-gate 		boolean_t		reversible,
454*0Sstevel@tonic-gate 		uint_t			flags,
455*0Sstevel@tonic-gate 		uint_t			*num_paths,
456*0Sstevel@tonic-gate 		size_t			*length,
457*0Sstevel@tonic-gate 		sa_path_record_t	**result);
458*0Sstevel@tonic-gate 
459*0Sstevel@tonic-gate /*
460*0Sstevel@tonic-gate  * ibmf_saa_name_to_service_record:
461*0Sstevel@tonic-gate  *	Given a service name, return the service records associated
462*0Sstevel@tonic-gate  *	with it.
463*0Sstevel@tonic-gate  *
464*0Sstevel@tonic-gate  * This interface blocks.
465*0Sstevel@tonic-gate  *
466*0Sstevel@tonic-gate  * Input Arguments:
467*0Sstevel@tonic-gate  * ibmf_saa_handle	- handle returned from ibmf_sa_session_open()
468*0Sstevel@tonic-gate  * name			- service name, a null terminated string
469*0Sstevel@tonic-gate  * p_key		- partition that the service is requested on.  This
470*0Sstevel@tonic-gate  *			  value may be wildcarded with IBMF_SAA_PKEY_WC.
471*0Sstevel@tonic-gate  * flags		- unused
472*0Sstevel@tonic-gate  *
473*0Sstevel@tonic-gate  * Output Arguments:
474*0Sstevel@tonic-gate  * num_records		- number of service records returned
475*0Sstevel@tonic-gate  * length		- size of buffer returned
476*0Sstevel@tonic-gate  * result		- pointer to buffer of service records returned in
477*0Sstevel@tonic-gate  *			  response
478*0Sstevel@tonic-gate  *
479*0Sstevel@tonic-gate  * Return values:
480*0Sstevel@tonic-gate  * Error codes are the same as ibmf_sa_access() return values
481*0Sstevel@tonic-gate  *
482*0Sstevel@tonic-gate  * Upon successful completion, result points to a buffer containing the records.
483*0Sstevel@tonic-gate  * and num_records is the number of service records returned.  length is the
484*0Sstevel@tonic-gate  * size in bytes of the buffer returned in result.  If there are no records or
485*0Sstevel@tonic-gate  * the call failed the length is 0.
486*0Sstevel@tonic-gate  *
487*0Sstevel@tonic-gate  * The consumer is responsible for freeing the memory associated with result.
488*0Sstevel@tonic-gate  */
489*0Sstevel@tonic-gate int	ibmf_saa_name_to_service_record(
490*0Sstevel@tonic-gate 		ibmf_saa_handle_t	ibmf_saa_handle,
491*0Sstevel@tonic-gate 		char			*service_name,
492*0Sstevel@tonic-gate 		ib_pkey_t		p_key,
493*0Sstevel@tonic-gate 		uint_t			flags,
494*0Sstevel@tonic-gate 		uint_t			*num_records,
495*0Sstevel@tonic-gate 		size_t			*length,
496*0Sstevel@tonic-gate 		sa_service_record_t	**result);
497*0Sstevel@tonic-gate 
498*0Sstevel@tonic-gate /*
499*0Sstevel@tonic-gate  * ibmf_saa_id_to_service_record:
500*0Sstevel@tonic-gate  *      Given a service id, return the service records associated
501*0Sstevel@tonic-gate  *      with it.
502*0Sstevel@tonic-gate  *
503*0Sstevel@tonic-gate  * This interface blocks.
504*0Sstevel@tonic-gate  *
505*0Sstevel@tonic-gate  * Input Arguments:
506*0Sstevel@tonic-gate  * ibmf_saa_handle	- handle returned from ibmf_sa_session_open()
507*0Sstevel@tonic-gate  * id			- service id
508*0Sstevel@tonic-gate  * p_key		- partition that the service is requested on.  This
509*0Sstevel@tonic-gate  *			  value may be wildcarded with IBMF_SAA_PKEY_WC.
510*0Sstevel@tonic-gate  * flags		- unused
511*0Sstevel@tonic-gate  *
512*0Sstevel@tonic-gate  * Output Arguments:
513*0Sstevel@tonic-gate  * num_records		- number of service records returned
514*0Sstevel@tonic-gate  * length		- size of buffer returned
515*0Sstevel@tonic-gate  * result		- pointer to buffer of service records returned in
516*0Sstevel@tonic-gate  *			  response
517*0Sstevel@tonic-gate  *
518*0Sstevel@tonic-gate  * Return values:
519*0Sstevel@tonic-gate  * Error codes are the same as ibmf_sa_access() return values
520*0Sstevel@tonic-gate  *
521*0Sstevel@tonic-gate  * Upon successful completion, result points to a buffer containing the records.
522*0Sstevel@tonic-gate  * and num_records is the number of service records returned.  length is the
523*0Sstevel@tonic-gate  * size in bytes of the buffer returned in result.  If there are no records or
524*0Sstevel@tonic-gate  * the call failed the length is 0.
525*0Sstevel@tonic-gate  *
526*0Sstevel@tonic-gate  * The consumer is responsible for freeing the memory associated with result.
527*0Sstevel@tonic-gate  */
528*0Sstevel@tonic-gate int	ibmf_saa_id_to_service_record(
529*0Sstevel@tonic-gate 		ibmf_saa_handle_t	ibmf_saa_handle,
530*0Sstevel@tonic-gate 		ib_svc_id_t		service_id,
531*0Sstevel@tonic-gate 		ib_pkey_t		p_key,
532*0Sstevel@tonic-gate 		uint_t			flags,
533*0Sstevel@tonic-gate 		uint_t			*num_records,
534*0Sstevel@tonic-gate 		size_t			*length,
535*0Sstevel@tonic-gate 		sa_service_record_t	**result);
536*0Sstevel@tonic-gate 
537*0Sstevel@tonic-gate /*
538*0Sstevel@tonic-gate  * ibmf_saa_update_service_record
539*0Sstevel@tonic-gate  *	Given a pointer to a service record, either insert or delete it
540*0Sstevel@tonic-gate  *
541*0Sstevel@tonic-gate  * This interface blocks.
542*0Sstevel@tonic-gate  *
543*0Sstevel@tonic-gate  * Input Arguments:
544*0Sstevel@tonic-gate  * ibmf_saa_handle	- handle returned from ibmf_sa_session_open()
545*0Sstevel@tonic-gate  * service_record	- service record is to be inserted or deleted.  To
546*0Sstevel@tonic-gate  *			  delete a service record the GID, ID, P_Key, and
547*0Sstevel@tonic-gate  *			  Service Key must match what is in the SA.
548*0Sstevel@tonic-gate  * access_type		- indicates whether this is an insertion or deletion.
549*0Sstevel@tonic-gate  *			  valid values are IBMF_SAA_UPDATE or IBMF_SAA_DELETE
550*0Sstevel@tonic-gate  * flags		- unused
551*0Sstevel@tonic-gate  *
552*0Sstevel@tonic-gate  * Ouptut Arguments
553*0Sstevel@tonic-gate  * none
554*0Sstevel@tonic-gate  *
555*0Sstevel@tonic-gate  * Return values:
556*0Sstevel@tonic-gate  * Error codes are the same as ibmf_sa_access() return values
557*0Sstevel@tonic-gate  */
558*0Sstevel@tonic-gate int	ibmf_saa_update_service_record(
559*0Sstevel@tonic-gate 		ibmf_saa_handle_t	ibmf_saa_handle,
560*0Sstevel@tonic-gate 		sa_service_record_t	*service_record,
561*0Sstevel@tonic-gate 		ibmf_saa_access_type_t	access_type,
562*0Sstevel@tonic-gate 		uint_t			flags);
563*0Sstevel@tonic-gate 
564*0Sstevel@tonic-gate #ifdef __cplusplus
565*0Sstevel@tonic-gate }
566*0Sstevel@tonic-gate #endif
567*0Sstevel@tonic-gate 
568*0Sstevel@tonic-gate #endif	/* _SYS_IB_MGT_IBMF_IBMF_SAA_H */
569