2 * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
3 * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
4 * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
38 * Specification of the OpenSM SA Client API. This API uses the basic osm
39 * vendor API to provide SA Client interface.
42 #ifndef _OSM_VENDOR_SA_API_H_
43 #define _OSM_VENDOR_SA_API_H_
45 #include <iba/ib_types.h>
48 # define BEGIN_C_DECLS extern "C" {
49 # define END_C_DECLS }
50 #else /* !__cplusplus */
51 # define BEGIN_C_DECLS
53 #endif /* __cplusplus */
56 /****d* OpenSM Vendor SA Client/osmv_flags_t
61 * Access layer flags used to direct the operation of various calls.
65 typedef uint32_t osmv_flags_t;
66 #define OSM_SA_FLAGS_SYNC 0x00000001
70 * Indicates that the given operation should be performed synchronously.
71 * The call will block until it completes. Callbacks will still be
78 /****d* OpenSM Vendor SA Client/osmv_query_type_t
83 * Abstracted queries supported by the access layer.
87 typedef enum _osmv_query_type {
88 OSMV_QUERY_USER_DEFINED,
90 OSMV_QUERY_ALL_SVC_RECS,
91 OSMV_QUERY_SVC_REC_BY_NAME,
92 OSMV_QUERY_SVC_REC_BY_ID,
94 OSMV_QUERY_CLASS_PORT_INFO,
96 OSMV_QUERY_NODE_REC_BY_NODE_GUID,
97 OSMV_QUERY_PORT_REC_BY_LID,
98 OSMV_QUERY_PORT_REC_BY_LID_AND_NUM,
100 OSMV_QUERY_VLARB_BY_LID_PORT_BLOCK,
101 OSMV_QUERY_SLVL_BY_LID_AND_PORTS,
103 OSMV_QUERY_PATH_REC_BY_PORT_GUIDS,
104 OSMV_QUERY_PATH_REC_BY_GIDS,
105 OSMV_QUERY_PATH_REC_BY_LIDS,
107 OSMV_QUERY_UD_MULTICAST_SET,
108 OSMV_QUERY_UD_MULTICAST_DELETE,
110 OSMV_QUERY_MULTIPATH_REC,
115 * OSMV_QUERY_USER_DEFINED
116 * Query the SA based on user-defined input. Queries of this type
117 * should reference an osmv_user_query_t structure as input to the
120 * OSMV_QUERY_SVC_REC_BY_NAME
121 * Query for service records based on the service name. Queries of
122 * this type should reference an ib_svc_name_t structure as input
125 * OSMV_QUERY_SVC_REC_BY_ID
126 * Query for service records based on the service ID. Queries of
127 * this type should reference an ib_net64_t value that indicates
128 * the ID of the service being requested.
130 * OSMV_QUERY_NODE_REC_BY_NODE_GUID
131 * Query for node information based on the node's GUID. Queries of
132 * this type should reference an ib_net64_t value that indicates
133 * the GUID of the node being requested.
135 * OSMV_QUERY_PORT_REC_BY_LID
136 * Query for port information based on the port's base LID. Queries
137 * of this type should reference an ib_net16_t value that indicates
138 * the base LID of the port being requested.
140 * OSMV_QUERY_PORT_REC_BY_LID_AND_NUM
141 * Query for port information based on the port's LID and port num.
142 * Queries of this type should reference an osmv_user_query_t
143 * structure as input to the query. The port num and lid should
146 * OSMV_QUERY_PATH_REC_BY_PORT_GUIDS
147 * Query for path records between the specified pair of port GUIDs.
148 * Queries of this type should reference an osmv_guid_pair_t
149 * structure that indicates the GUIDs of the path being requested.
151 * OSMV_QUERY_PATH_REC_BY_GIDS
152 * Query for path records between the specified pair of port GIDs.
153 * Queries of this type should reference an osmv_gid_pair_t
154 * structure that indicates the GIDs of the path being requested.
156 * OSMV_QUERY_PATH_REC_BY_LIDS
157 * Query for path records between the specified pair of port LIDs.
158 * Queries of this type should reference an osmv_lid_pair_t
159 * structure that indicates the LIDs of the path being requested.
162 * This enum is used to define abstracted queries provided by the access
163 * layer. Users may issue queries not listed here by sending MADs directly
164 * to subnet administration or a class manager. These queries are
165 * intended to represent those most often used by clients.
168 * osmv_query, osmv_query_req_t, osmv_user_query_t, osmv_gid_pair_t,
169 * osmv_lid_pair_t osmv_guid_pair_t
172 /****s* OpenSM Vendor SA Client/osmv_user_query_t
177 * User-defined query information.
181 typedef struct _osmv_user_query {
184 ib_net16_t attr_offset;
186 ib_net64_t comp_mask;
196 * Attribute identifier of query data.
199 * Size of the query attribute, in 8-byte words. Users can set
200 * this value by passing in the sizeof( attribute ) into the
201 * ib_get_attr_offset() routine.
204 * Attribute modifier for query request.
207 * Indicates the attribute components that are specified for the
211 * References the attribute structure used as input into the query.
212 * This field is ignored if comp_mask is set to 0.
215 * This structure is used to describe a user-defined query. The attribute
216 * ID, attribute offset, component mask, and attribute structure must match
217 * those defined by the IBA specification. Users should refer to chapter
218 * 15 of the IBA specification for additional details.
221 * osmv_query_type_t, ib_get_attr_offset, ib_get_attr_size, osmv_query_sa
224 /****s* OpenSM Vendor SA Client/osmv_gid_pair_t
229 * Source and destination GIDs.
233 typedef struct _osmv_gid_pair {
240 * Source GID of a path.
243 * Destination GID of a path.
246 * This structure is used to describe the endpoints of a path.
252 /****s* OpenSM Vendor SA Client/osmv_lid_pair_t
257 * Source and destination LIDs.
261 typedef struct _osmv_lid_pair {
268 * Source LID of a path.
271 * Destination LID of a path.
274 * This structure is used to describe the endpoints of a path.
277 /****s* OpenSM Vendor SA Client/osmv_guid_pair_t
282 * Source and destination GUIDs. These may be port or channel adapter
283 * GUIDs, depending on the context in which this structure is used.
287 typedef struct _osmv_guid_pair {
289 ib_net64_t dest_guid;
294 * Source GUID of a path.
297 * Destination GUID of a path.
300 * This structure is used to describe the endpoints of a path. The given
301 * GUID pair may belong to either ports or channel adapters.
307 /****s* OpenSM Vendor SA Client/osmv_multipath_req_t
309 * osmv_multipath_req_t
312 * Fields from which to generate a MultiPathRecord request.
316 typedef struct _osmv_multipath_req_t {
317 ib_net64_t comp_mask;
319 boolean_t reversible;
322 uint8_t independence;
325 ib_gid_t gids[IB_MULTIPATH_MAX_GIDS];
326 } osmv_multipath_req_t;
331 * This structure is used to describe a multipath request.
336 /****s* OpenSM Vendor SA Client/osmv_query_res_t
341 * Contains the results of a subnet administration query.
345 typedef struct _osmv_query_res {
346 const void *query_context;
347 ib_api_status_t status;
348 osmv_query_type_t query_type;
350 osm_madw_t *p_result_madw;
355 * User-defined context information associated with the query
356 * through the osm_vendor_query_sa call.
359 * Indicates the success of the query operation.
362 * Indicates the type of query for which the results are being
363 * returned. This matches the query_type specified through the
364 * osm_vendor_query_sa call.
367 * The number of result structures that were returned by the query.
370 * For queries returning IB_SUCCESS or IB_REMOTE_ERROR, this
371 * references the MAD wrapper returned by subnet administration
372 * containing the list of results or the returned error code.
375 * A query result structure is returned to a client through their
376 * osmv_pfn_query_cb_t routine to notify them of the results of a subnet
377 * administration query. If the query was successful or received an error
378 * from subnet administration, p_result_madw will reference a MAD wrapper
379 * containing the results. The MAD referenced by p_result_madw is owned by
380 * the user and remains available even after their callback returns. Users
381 * must call osm_mad_pool_put() to return the MAD wrapper back to the
382 * mad pool when they are done accessing the results.
384 * To retrieve individual result structures from the p_result_madw, users
385 * may call osmv_get_query_result().
388 * osmv_query_sa, osmv_pfn_query_cb_t, ib_api_status_t,
389 * osmv_query_status_t, osmv_query_type_t,
390 * osmv_get_query_result
393 /****f* OpenSM Vendor SA Client/osmv_get_query_result
395 * osmv_get_query_result
398 * Retrieves a result structure from a MADW returned by a call to
403 static inline void *osmv_get_query_result(IN osm_madw_t * p_result_madw,
404 IN uint32_t result_index)
406 ib_sa_mad_t *p_sa_mad;
408 CL_ASSERT(p_result_madw);
409 p_sa_mad = (ib_sa_mad_t *) osm_madw_get_mad_ptr(p_result_madw);
411 CL_ASSERT(ib_get_attr_size(p_sa_mad->attr_offset) * (result_index + 1) +
412 IB_SA_MAD_HDR_SIZE <= p_result_madw->mad_size);
414 return (p_sa_mad->data +
415 (ib_get_attr_size(p_sa_mad->attr_offset) * result_index));
421 * [in] This is a reference to the MAD returned as a result of the
425 * [in] A zero-based index indicating which result to return.
428 * This call returns a pointer to the start of a result structure from a
429 * call to osmv_query_sa(). The type of result structure must be known to
430 * the user either through the user's context or the query_type returned as
431 * part of the osmv_query_res_t structure.
434 * osmv_query_res_t, osm_madw_t
437 /****f* OpenSM Vendor SA Client/osmv_get_query_path_rec
439 * osmv_get_query_path_rec
442 * Retrieves a path record result from a MAD returned by a call to
447 static inline ib_path_rec_t *osmv_get_query_path_rec(IN osm_madw_t *
449 IN uint32_t result_index)
451 ib_sa_mad_t *p_sa_mad;
453 CL_ASSERT(p_result_madw);
454 p_sa_mad = (ib_sa_mad_t *) osm_madw_get_mad_ptr(p_result_madw);
455 CL_ASSERT(p_sa_mad && p_sa_mad->attr_id == IB_MAD_ATTR_PATH_RECORD);
457 return ((ib_path_rec_t *)
458 osmv_get_query_result(p_result_madw, result_index));
464 * [in] This is a reference to the MAD returned as a result of the
468 * [in] A zero-based index indicating which result to return.
471 * This call returns a pointer to the start of a path record result from
472 * a call to osmv_query_sa().
475 * osmv_query_res_t, osm_madw_t, osmv_get_query_result, ib_path_rec_t
478 /****f* OpenSM Vendor SA Client/osmv_get_query_portinfo_rec
480 * osmv_get_query_portinfo_rec
483 * Retrieves a port info record result from a MAD returned by a call to
488 static inline ib_portinfo_record_t *osmv_get_query_portinfo_rec(IN osm_madw_t *
493 ib_sa_mad_t *p_sa_mad;
495 CL_ASSERT(p_result_madw);
496 p_sa_mad = (ib_sa_mad_t *) osm_madw_get_mad_ptr(p_result_madw);
497 CL_ASSERT(p_sa_mad && p_sa_mad->attr_id == IB_MAD_ATTR_PORTINFO_RECORD);
499 return ((ib_portinfo_record_t *) osmv_get_query_result(p_result_madw,
506 * [in] This is a reference to the MAD returned as a result of the
510 * [in] A zero-based index indicating which result to return.
513 * This call returns a pointer to the start of a port info record result
514 * from a call to osmv_query_sa().
517 * osmv_query_res_t, osm_madw_t, osmv_get_query_result, ib_portinfo_record_t
520 /****f* OpenSM Vendor SA Client/osmv_get_query_node_rec
522 * osmv_get_query_node_rec
525 * Retrieves a node record result from a MAD returned by a call to
530 static inline ib_node_record_t *osmv_get_query_node_rec(IN osm_madw_t *
535 ib_sa_mad_t *p_sa_mad;
537 CL_ASSERT(p_result_madw);
538 p_sa_mad = (ib_sa_mad_t *) osm_madw_get_mad_ptr(p_result_madw);
539 CL_ASSERT(p_sa_mad && p_sa_mad->attr_id == IB_MAD_ATTR_NODE_RECORD);
541 return ((ib_node_record_t *) osmv_get_query_result(p_result_madw,
548 * [in] This is a reference to the MAD returned as a result of the
552 * [in] A zero-based index indicating which result to return.
555 * This call returns a pointer to the start of a node record result from
556 * a call to osmv_query_sa().
559 * osmv_query_res_t, osm_madw_t, osmv_get_query_result, ib_node_record_t
562 /****f* OpenSM Vendor SA Client/osmv_get_query_svc_rec
564 * osmv_get_query_svc_rec
567 * Retrieves a service record result from a MAD returned by a call to
572 static inline ib_service_record_t *osmv_get_query_svc_rec(IN osm_madw_t *
577 ib_sa_mad_t *p_sa_mad;
579 CL_ASSERT(p_result_madw);
580 p_sa_mad = (ib_sa_mad_t *) osm_madw_get_mad_ptr(p_result_madw);
581 CL_ASSERT(p_sa_mad && p_sa_mad->attr_id == IB_MAD_ATTR_SERVICE_RECORD);
583 return ((ib_service_record_t *) osmv_get_query_result(p_result_madw,
590 * [in] This is a reference to the MAD returned as a result of the
594 * [in] A zero-based index indicating which result to return.
597 * This call returns a pointer to the start of a service record result from
598 * a call to osmv_query_sa().
601 * osmv_query_res_t, osm_madw_t, osmv_get_query_result, ib_service_record_t
604 /****f* OpenSM Vendor SA Client/osmv_get_query_mc_rec
606 * osmv_get_query_mc_rec
609 * Retrieves a multicast record result from a MAD returned by a call to
614 static inline ib_member_rec_t *osmv_get_query_mc_rec(IN osm_madw_t *
616 IN uint32_t result_index)
618 ib_sa_mad_t *p_sa_mad;
620 CL_ASSERT(p_result_madw);
621 p_sa_mad = (ib_sa_mad_t *) osm_madw_get_mad_ptr(p_result_madw);
622 CL_ASSERT(p_sa_mad && p_sa_mad->attr_id == IB_MAD_ATTR_MCMEMBER_RECORD);
624 return ((ib_member_rec_t *) osmv_get_query_result(p_result_madw,
631 * [in] This is a reference to the MAD returned as a result of the
635 * [in] A zero-based index indicating which result to return.
638 * This call returns a pointer to the start of a service record result from
639 * a call to osmv_query_sa().
642 * osmv_query_res_t, osm_madw_t, osmv_get_query_result, ib_member_rec_t
645 /****f* OpenSM Vendor SA Client/osmv_get_query_inform_info_rec
647 * osmv_get_query_inform_info_rec
650 * Retrieves an InformInfo record result from a MAD returned by
651 * a call to osmv_query_sa().
655 static inline ib_inform_info_record_t *osmv_get_query_inform_info_rec(IN
663 ib_sa_mad_t *p_sa_mad;
665 CL_ASSERT(p_result_madw);
666 p_sa_mad = (ib_sa_mad_t *) osm_madw_get_mad_ptr(p_result_madw);
668 && p_sa_mad->attr_id == IB_MAD_ATTR_INFORM_INFO_RECORD);
670 return ((ib_inform_info_record_t *) osmv_get_query_result(p_result_madw,
677 * [in] This is a reference to the MAD returned as a result of the
681 * [in] A zero-based index indicating which result to return.
684 * This call returns a pointer to the start of a service record result from
685 * a call to osmv_query_sa().
688 * osmv_query_res_t, osm_madw_t, osmv_get_query_result, ib_inform_info_record_t
691 /****f* OpenSM Vendor SA Client/osmv_pfn_query_cb_t
693 * osmv_pfn_query_cb_t
696 * User-defined callback invoked on completion of subnet administration
702 (*osmv_pfn_query_cb_t) (IN osmv_query_res_t * p_query_res);
706 * [in] This is a reference to a structure containing the result of
710 * This routine is invoked to notify a client of the result of a subnet
711 * administration query. The p_query_rec parameter references the result
712 * of the query and, in the case of a successful query, any information
713 * returned by subnet administration.
715 * In the kernel, this callback is usually invoked using a tasklet,
716 * dependent on the implementation of the underlying verbs provider driver.
722 /****s* OpenSM Vendor SA Client/osmv_query_req_t
727 * Information used to request an access layer provided query of subnet
732 typedef struct _osmv_query_req {
733 osmv_query_type_t query_type;
734 const void *p_query_input;
741 const void *query_context;
742 osmv_pfn_query_cb_t pfn_query_cb;
747 * Indicates the type of query that the access layer should
751 * A pointer to the input for the query. The data referenced by
752 * this structure is dependent on the type of query being requested
753 * and is determined by the specified query_type.
756 * The M_Key to be provided with the SA MAD for authentication.
757 * Normally 0 is used.
760 * Specifies the number of milliseconds to wait for a response for
761 * this query until retrying or timing out the request.
764 * Specifies the number of times that the query will be retried
765 * before failing the request.
768 * Used to describe the mode of operation. Set to IB_FLAGS_SYNC to
769 * process the called routine synchronously.
772 * User-defined context information associated with this query.
773 * The context data is returned to the user as a part of their
777 * A user-defined callback that is invoked upon completion of the
781 * This structure is used when requesting an osm vendor provided query
782 * of subnet administration. Clients specify the type of query through
783 * the query_type field. Based on the type of query, the p_query_input
784 * field is set to reference the appropriate data structure.
786 * The information referenced by the p_query_input field is one of the
789 * -- a NULL terminated service name
792 * -- a pair of GUIDs specified through an osmv_guid_pair_t structure
793 * -- a pair of GIDs specified through an osmv_gid_pair_t structure
796 * osmv_query_type_t, osmv_pfn_query_cb_t, osmv_guid_pair_t,
800 /****f* OpenSM Vendor SA Client/osmv_bind_sa
805 * Bind to the SA service and return a handle to be used for later
812 osmv_bind_sa(IN osm_vendor_t * const p_vend,
813 IN osm_mad_pool_t * const p_mad_pool, IN ib_net64_t port_guid);
817 * [in] an osm_vendor object to work with
820 * [in] mad pool to obtain madw from
823 * [in] the port guid to attach to.
826 * Bind handle to be used for later SA queries or OSM_BIND_INVALID_HANDLE
834 /****f* OpenSM Vendor SA Client/osmv_query_sa
839 * Query the SA given an SA query request (similar to IBAL ib_query).
844 osmv_query_sa(IN osm_bind_handle_t h_bind,
845 IN const osmv_query_req_t * const p_query_req);
849 * [in] bind handle for this port. Should be previously
850 * obtained by calling osmv_bind_sa
853 * [in] an SA query request structure.
856 * IB_SUCCESS if completed successfuly (or in ASYNC mode
857 * if the request was sent).
866 #endif /* _OSM_VENDOR_SA_API_H_ */