]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/ofed/management/opensm/include/vendor/osm_vendor_ts.h
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / ofed / management / opensm / include / vendor / osm_vendor_ts.h
1 /*
2  * Copyright (c) 2004, 2005 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.
5  *
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:
11  *
12  *     Redistribution and use in source and binary forms, with or
13  *     without modification, are permitted provided that the following
14  *     conditions are met:
15  *
16  *      - Redistributions of source code must retain the above
17  *        copyright notice, this list of conditions and the following
18  *        disclaimer.
19  *
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.
24  *
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
32  * SOFTWARE.
33  *
34  */
35
36 /*
37  * Abstract:
38  *      Definition of interface for the TS Vendor
39  *         This object is part of the OpenSM family of objects.
40  */
41
42 #ifndef _OSM_VENDOR_TS_H_
43 #define _OSM_VENDOR_TS_H_
44
45 #undef IN
46 #undef OUT
47 #include <vapi_types.h>
48 #include <evapi.h>
49 #include <ib/ts_api_ng/useraccess/include/ts_ib_useraccess.h>
50 #define IN
51 #define OUT
52 #include "iba/ib_types.h"
53 #include "iba/ib_al.h"
54 #include <complib/cl_thread.h>
55 #include <complib/cl_types_osd.h>
56 #include <opensm/osm_base.h>
57 #include <opensm/osm_log.h>
58
59 #ifdef __cplusplus
60 #  define BEGIN_C_DECLS extern "C" {
61 #  define END_C_DECLS   }
62 #else                           /* !__cplusplus */
63 #  define BEGIN_C_DECLS
64 #  define END_C_DECLS
65 #endif                          /* __cplusplus */
66
67 BEGIN_C_DECLS
68 /****s* OpenSM: Vendor TS/osm_bind_handle_t
69  * NAME
70  *   osm_bind_handle_t
71  *
72  * DESCRIPTION
73  *      handle returned by the vendor transport bind call.
74  *
75  * SYNOPSIS
76  */
77 typedef void *osm_bind_handle_t;
78 /*
79 **********/
80 #define OSM_DEFAULT_RETRY_COUNT 3
81
82 /****s* OpenSM: Vendor osm_ts_bind_info_t
83  * NAME
84  *   osm_ts_bind_info_t
85  *
86  * DESCRIPTION
87  *      Handle to the result of binding a class callbacks .
88  *
89  * SYNOPSIS
90  */
91 typedef struct _osm_ts_bind_info {
92         int ul_dev_fd;
93         VAPI_hca_hndl_t hca_hndl;
94         struct _osm_vendor *p_vend;
95         void *client_context;
96         uint8_t port_num;
97         void *rcv_callback;
98         void *send_err_callback;
99         struct _osm_mad_pool *p_osm_pool;
100         cl_thread_t poller;
101 } osm_ts_bind_info_t;
102 /*
103  * FIELDS
104  *      ul_dev_file_hdl
105  *              the file handle to be used for sending the MADs
106  *
107  * hca_hndl
108  *     Handle to the HCA provided by the underlying VAPI
109  *
110  *      p_vend
111  *              Pointer to the vendor object.
112  *
113  *      client_context
114  *              User's context passed during osm_bind
115  *
116  *  hca_id
117  *     HCA Id we bind to.
118  *
119  *      port_num
120  *              Port number (within the HCA) of the bound port.
121  *
122  *      rcv_callback
123  *              OSM Callback function to be called on receive of MAD.
124  *
125  *  send_err_callback
126  *     OSM Callback to be called on send error.
127  *
128  *  p_osm_pool
129  *     Points to the MAD pool used by OSM
130  *
131  *  poller
132  *     A thread reading from the device file handle
133  *
134  * SEE ALSO
135  *********/
136
137 /****h* OpenSM/Vendor TS
138  * NAME
139  *      Vendor TS
140  *
141  * DESCRIPTION
142  *
143  *      The Vendor TS object is thread safe.
144  *
145  *      This object should be treated as opaque and should be
146  *      manipulated only through the provided functions.
147  *
148  *
149  * AUTHOR
150  *
151  *
152  *********/
153
154 /****s* OpenSM: Vendor TS/osm_ca_info_t
155  * NAME
156  *   osm_ca_info_t
157  *
158  * DESCRIPTION
159  *      Structure containing information about local Channle Adapters.
160  *
161  * SYNOPSIS
162  */
163 typedef struct _osm_ca_info {
164         ib_net64_t guid;
165         size_t attr_size;
166         ib_ca_attr_t *p_attr;
167
168 } osm_ca_info_t;
169
170 /*
171  * FIELDS
172  *      guid
173  *              Node GUID of the local CA.
174  *
175  *      attr_size
176  *              Size of the CA attributes for this CA.
177  *
178  *      p_attr
179  *              Pointer to dynamicly allocated CA Attribute structure.
180  *
181  * SEE ALSO
182  *********/
183
184 /***** OpenSM: Vendor TS/osm_vendor_t
185  * NAME
186  *  osm_vendor_t
187  *
188  * DESCRIPTION
189  *      The structure defining a TS vendor
190  *
191  * SYNOPSIS
192  */
193 typedef struct _osm_vendor {
194         osm_log_t *p_log;
195         uint32_t ca_count;
196         osm_ca_info_t *p_ca_info;
197         uint32_t timeout;
198         struct _osm_transaction_mgr *p_transaction_mgr;
199         osm_ts_bind_info_t smi_bind;
200         osm_ts_bind_info_t gsi_bind;
201 } osm_vendor_t;
202
203 /*
204  * FIELDS
205  *      h_al
206  *              Handle returned by TS open call .
207  *
208  *      p_log
209  *              Pointer to the log object.
210  *
211  *      ca_count
212  *              Number of CA's in the array pointed to by p_ca_info.
213  *
214  *      p_ca_info
215  *              Pointer to dynamically allocated array of CA info objects.
216  *
217  *      timeout
218  *              Transaction timeout time in milliseconds.
219  *
220  *  p_transaction_mgr
221  *     Pointer to Transaction Manager.
222  *
223  *  smi_bind
224  *     Bind information for handling SMI MADs
225  *
226  *  gsi_bind
227  *     Bind information for GSI MADs
228  *
229  * SEE ALSO
230  *********/
231
232 /****f* OpenSM: Vendor TS/CA Info/osm_ca_info_get_port_guid
233  * NAME
234  *      osm_ca_info_get_port_guid
235  *
236  * DESCRIPTION
237  *      Returns the port GUID of the specified port owned by this CA.
238  *
239  * SYNOPSIS
240  */
241 static inline ib_net64_t
242 osm_ca_info_get_port_guid(IN const osm_ca_info_t * const p_ca_info,
243                           IN const uint8_t index)
244 {
245         return (p_ca_info->p_attr->p_port_attr[index].port_guid);
246 }
247
248 /*
249  * PARAMETERS
250  *      p_ca_info
251  *              [in] Pointer to a CA Info object.
252  *
253  *      index
254  *              [in] Port "index" for which to retrieve the port GUID.
255  *              The index is the offset into the ca's internal array
256  *              of port attributes.
257  *
258  * RETURN VALUE
259  *      Returns the port GUID of the specified port owned by this CA.
260  *
261  * NOTES
262  *
263  * SEE ALSO
264  *********/
265
266 /****f* OpenSM: Vendor TS/CA Info/osm_ca_info_get_num_ports
267  * NAME
268  *      osm_ca_info_get_num_ports
269  *
270  * DESCRIPTION
271  *      Returns the number of ports of the given ca_info
272  *
273  * SYNOPSIS
274  */
275 static inline uint8_t
276 osm_ca_info_get_num_ports(IN const osm_ca_info_t * const p_ca_info)
277 {
278         return (p_ca_info->p_attr->num_ports);
279 }
280
281 /*
282  * PARAMETERS
283  *      p_ca_info
284  *              [in] Pointer to a CA Info object.
285  *
286  * RETURN VALUE
287  *      Returns the number of CA ports
288  *
289  * NOTES
290  *
291  * SEE ALSO
292  *********/
293
294 /****f* OpenSM: SM Vendor/osm_vendor_get_guid_ca_and_port
295  * NAME
296  *      osm_vendor_get_guid_ca_and_port
297  *
298  * DESCRIPTION
299  * Given the vendor obj and a guid
300  * return the ca id and port number that have that guid
301  *
302  * SYNOPSIS
303  */
304 ib_api_status_t
305 osm_vendor_get_guid_ca_and_port(IN osm_vendor_t * const p_vend,
306                                 IN ib_net64_t const guid,
307                                 OUT VAPI_hca_hndl_t * p_hca_hndl,
308                                 OUT VAPI_hca_id_t * p_hca_id,
309                                 OUT uint32_t * p_port_num);
310
311 /*
312  * PARAMETERS
313  *      p_vend
314  *              [in] Pointer to an osm_vendor_t object.
315  *
316  *      guid
317  *              [in] The guid to search for.
318  *
319  *      p_hca_id
320  *              [out] The HCA Id (VAPI_hca_id_t *) that the port is found on.
321  *
322  *      p_port_num
323  *              [out] Pointer to a port number arg to be filled with the port number with the given guid.
324  *
325  * RETURN VALUES
326  *      IB_SUCCESS on SUCCESS
327  *  IB_INVALID_GUID if the guid is notfound on any Local HCA Port
328  *
329  * NOTES
330  *
331  * SEE ALSO
332  *********/
333
334 /****f* OpenSM: Vendor TS/osm_vendor_get_all_port_attr
335  * NAME
336  *      osm_vendor_get_all_port_attr
337  *
338  * DESCRIPTION
339  * Fill in the array of port_attr with all available ports on ALL the
340  * avilable CAs on this machine.
341  * ALSO -
342  * UPDATE THE VENDOR OBJECT LIST OF CA_INFO STRUCTS
343  *
344  * SYNOPSIS
345  */
346 ib_api_status_t osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
347                                              IN ib_port_attr_t *
348                                              const p_attr_array,
349                                              IN uint32_t * const p_num_ports);
350
351 /*
352  * PARAMETERS
353  *      p_vend
354  *              [in] Pointer to an osm_vendor_t object.
355  *
356  *      p_attr_array
357  *              [out] Pre-allocated array of port attributes to be filled in
358  *
359  *      p_num_ports
360  *              [out] The size of the given array. Filled in by the actual numberof ports found.
361  *
362  * RETURN VALUES
363  *      IB_SUCCESS if OK
364  *  IB_INSUFFICIENT_MEMORY if not enough place for all ports was provided.
365  *
366  * NOTES
367  *
368  * SEE ALSO
369  *********/
370
371 #define OSM_BIND_INVALID_HANDLE 0
372
373 /****s* OpenSM: Vendor TS/osm_vend_wrap_t
374  * NAME
375  *   TS Vendor MAD Wrapper
376  *
377  * DESCRIPTION
378  *      TS specific MAD wrapper. TS transport layer uses this for
379  *      housekeeping.
380  *
381  * SYNOPSIS
382  *********/
383 typedef struct _osm_vend_wrap_t {
384         uint32_t size;
385         osm_bind_handle_t h_bind;
386         ib_mad_t *p_mad_buf;
387         void *p_resp_madw;
388 } osm_vend_wrap_t;
389
390 /*
391  * FIELDS
392  *      size
393  *              Size of the allocated MAD
394  *
395  *      h_bind
396  *              Bind handle used on this transaction
397  *
398  *      h_av
399  *              Address vector handle used for this transaction.
400  *
401  *      p_resp_madw
402  *              Pointer to the mad wrapper structure used to hold the pending
403  *              reponse to the mad, if any.  If a response is expected, the
404  *              wrapper for the reponse is allocated during the send call.
405  *
406  * SEE ALSO
407  *********/
408
409 END_C_DECLS
410 #endif                          /* _OSM_VENDOR_TS_H_ */