1321936Shselasky/*
2321936Shselasky * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
3321936Shselasky * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
4321936Shselasky * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
5321936Shselasky *
6321936Shselasky * This software is available to you under a choice of one of two
7321936Shselasky * licenses.  You may choose to be licensed under the terms of the GNU
8321936Shselasky * General Public License (GPL) Version 2, available from the file
9321936Shselasky * COPYING in the main directory of this source tree, or the
10321936Shselasky * OpenIB.org BSD license below:
11321936Shselasky *
12321936Shselasky *     Redistribution and use in source and binary forms, with or
13321936Shselasky *     without modification, are permitted provided that the following
14321936Shselasky *     conditions are met:
15321936Shselasky *
16321936Shselasky *      - Redistributions of source code must retain the above
17321936Shselasky *        copyright notice, this list of conditions and the following
18321936Shselasky *        disclaimer.
19321936Shselasky *
20321936Shselasky *      - Redistributions in binary form must reproduce the above
21321936Shselasky *        copyright notice, this list of conditions and the following
22321936Shselasky *        disclaimer in the documentation and/or other materials
23321936Shselasky *        provided with the distribution.
24321936Shselasky *
25321936Shselasky * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26321936Shselasky * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27321936Shselasky * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28321936Shselasky * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29321936Shselasky * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30321936Shselasky * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31321936Shselasky * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32321936Shselasky * SOFTWARE.
33321936Shselasky *
34321936Shselasky */
35321936Shselasky
36321936Shselasky/*
37321936Shselasky * Abstract:
38321936Shselasky * 	Definition of interface for the MTL Vendor
39321936Shselasky *	   This object is part of the OpenSM family of objects.
40321936Shselasky */
41321936Shselasky
42321936Shselasky#ifndef _OSM_VENDOR_MTL_H_
43321936Shselasky#define _OSM_VENDOR_MTL_H_
44321936Shselasky
45321936Shselasky#undef IN
46321936Shselasky#undef OUT
47321936Shselasky#include <vapi_types.h>
48321936Shselasky#include <evapi.h>
49321936Shselasky#include <ib_mgt.h>
50321936Shselasky#define IN
51321936Shselasky#define OUT
52321936Shselasky#include "iba/ib_types.h"
53321936Shselasky#include "iba/ib_al.h"
54321936Shselasky#include <complib/cl_thread.h>
55321936Shselasky#include <complib/cl_types_osd.h>
56321936Shselasky#include <opensm/osm_base.h>
57321936Shselasky
58321936Shselasky#ifdef __cplusplus
59321936Shselasky#  define BEGIN_C_DECLS extern "C" {
60321936Shselasky#  define END_C_DECLS   }
61321936Shselasky#else				/* !__cplusplus */
62321936Shselasky#  define BEGIN_C_DECLS
63321936Shselasky#  define END_C_DECLS
64321936Shselasky#endif				/* __cplusplus */
65321936Shselasky
66321936ShselaskyBEGIN_C_DECLS
67321936Shselasky/****h* OpenSM/Vendor MTL
68321936Shselasky* NAME
69321936Shselasky*	Vendor MTL
70321936Shselasky*
71321936Shselasky* DESCRIPTION
72321936Shselasky*
73321936Shselasky*	The Vendor MTL object is thread safe.
74321936Shselasky*
75321936Shselasky*	This object should be treated as opaque and should be
76321936Shselasky*	manipulated only through the provided functions.
77321936Shselasky*
78321936Shselasky*
79321936Shselasky* AUTHOR
80321936Shselasky*
81321936Shselasky*
82321936Shselasky*********/
83321936Shselasky/****s* OpenSM: Vendor MTL/osm_ca_info_t
84321936Shselasky* NAME
85321936Shselasky*   osm_ca_info_t
86321936Shselasky*
87321936Shselasky* DESCRIPTION
88321936Shselasky* 	Structure containing information about local Channle Adapters.
89321936Shselasky*
90321936Shselasky* SYNOPSIS
91321936Shselasky*/
92321936Shselaskytypedef struct _osm_ca_info {
93321936Shselasky	ib_net64_t guid;
94321936Shselasky	size_t attr_size;
95321936Shselasky	ib_ca_attr_t *p_attr;
96321936Shselasky
97321936Shselasky} osm_ca_info_t;
98321936Shselasky
99321936Shselasky/*
100321936Shselasky* FIELDS
101321936Shselasky*	guid
102321936Shselasky*		Node GUID of the local CA.
103321936Shselasky*
104321936Shselasky*	attr_size
105321936Shselasky*		Size of the CA attributes for this CA.
106321936Shselasky*
107321936Shselasky*	p_attr
108321936Shselasky*		Pointer to dynamicly allocated CA Attribute structure.
109321936Shselasky*
110321936Shselasky* SEE ALSO
111321936Shselasky*********/
112321936Shselasky
113321936Shselasky#define OSM_DEFAULT_RETRY_COUNT 3
114321936Shselasky
115321936Shselasky/***** OpenSM: Vendor MTL/osm_vendor_t
116321936Shselasky* NAME
117321936Shselasky*  osm_vendor_t
118321936Shselasky*
119321936Shselasky* DESCRIPTION
120321936Shselasky* 	The structure defining a vendor
121321936Shselasky*
122321936Shselasky* SYNOPSIS
123321936Shselasky*/
124321936Shselaskytypedef struct _osm_vendor {
125321936Shselasky	ib_al_handle_t h_al;
126321936Shselasky	osm_log_t *p_log;
127321936Shselasky	uint32_t ca_count;
128321936Shselasky	osm_ca_info_t *p_ca_info;
129321936Shselasky	uint32_t timeout;
130321936Shselasky	struct osm_transaction_mgr_t *p_transaction_mgr;
131321936Shselasky} osm_vendor_t;
132321936Shselasky
133321936Shselasky/*
134321936Shselasky* FIELDS
135321936Shselasky*	h_al
136321936Shselasky*		Handle returned by MTL open call (ib_open_al).
137321936Shselasky*
138321936Shselasky*	p_log
139321936Shselasky*		Pointer to the log object.
140321936Shselasky*
141321936Shselasky*	ca_count
142321936Shselasky*		Number of CA's in the array pointed to by p_ca_info.
143321936Shselasky*
144321936Shselasky*	p_ca_info
145321936Shselasky*		Pointer to dynamically allocated array of CA info objects.
146321936Shselasky*
147321936Shselasky*	timeout
148321936Shselasky*		Transaction timeout time in milliseconds.
149321936Shselasky*
150321936Shselasky*  p_transaction_mgr
151321936Shselasky*     Pointer to Transaction Manager.
152321936Shselasky*
153321936Shselasky* SEE ALSO
154321936Shselasky*********/
155321936Shselasky
156321936Shselasky/****f* OpenSM: Vendor MTL/CA Info/osm_ca_info_get_port_guid
157321936Shselasky* NAME
158321936Shselasky*	osm_ca_info_get_port_guid
159321936Shselasky*
160321936Shselasky* DESCRIPTION
161321936Shselasky*	Returns the port GUID of the specified port owned by this CA.
162321936Shselasky*
163321936Shselasky* SYNOPSIS
164321936Shselasky*/
165321936Shselaskystatic inline ib_net64_t
166321936Shselaskyosm_ca_info_get_port_guid(IN const osm_ca_info_t * const p_ca_info,
167321936Shselasky			  IN const uint8_t index)
168321936Shselasky{
169321936Shselasky	return (p_ca_info->p_attr->p_port_attr[index].port_guid);
170321936Shselasky}
171321936Shselasky
172321936Shselasky/*
173321936Shselasky* PARAMETERS
174321936Shselasky*	p_ca_info
175321936Shselasky*		[in] Pointer to a CA Info object.
176321936Shselasky*
177321936Shselasky*	index
178321936Shselasky*		[in] Port "index" for which to retrieve the port GUID.
179321936Shselasky*		The index is the offset into the ca's internal array
180321936Shselasky*		of port attributes.
181321936Shselasky*
182321936Shselasky* RETURN VALUE
183321936Shselasky*	Returns the port GUID of the specified port owned by this CA.
184321936Shselasky*
185321936Shselasky* NOTES
186321936Shselasky*
187321936Shselasky* SEE ALSO
188321936Shselasky*********/
189321936Shselasky
190321936Shselasky/****f* OpenSM: Vendor MTL/CA Info/osm_ca_info_get_num_ports
191321936Shselasky* NAME
192321936Shselasky*	osm_ca_info_get_num_ports
193321936Shselasky*
194321936Shselasky* DESCRIPTION
195321936Shselasky*	Returns the number of ports of the given ca_info
196321936Shselasky*
197321936Shselasky* SYNOPSIS
198321936Shselasky*/
199321936Shselaskystatic inline uint8_t
200321936Shselaskyosm_ca_info_get_num_ports(IN const osm_ca_info_t * const p_ca_info)
201321936Shselasky{
202321936Shselasky	return (p_ca_info->p_attr->num_ports);
203321936Shselasky}
204321936Shselasky
205321936Shselasky/*
206321936Shselasky* PARAMETERS
207321936Shselasky*	p_ca_info
208321936Shselasky*		[in] Pointer to a CA Info object.
209321936Shselasky*
210321936Shselasky* RETURN VALUE
211321936Shselasky*	Returns the number of CA ports
212321936Shselasky*
213321936Shselasky* NOTES
214321936Shselasky*
215321936Shselasky* SEE ALSO
216321936Shselasky*********/
217321936Shselasky
218321936Shselasky/****f* OpenSM: SM Vendor/osm_vendor_get_guid_ca_and_port
219321936Shselasky * NAME
220321936Shselasky *	osm_vendor_get_guid_ca_and_port
221321936Shselasky *
222321936Shselasky * DESCRIPTION
223321936Shselasky * Given the vendor obj and a guid
224321936Shselasky * return the ca id and port number that have that guid
225321936Shselasky *
226321936Shselasky * SYNOPSIS
227321936Shselasky */
228321936Shselaskyib_api_status_t
229321936Shselaskyosm_vendor_get_guid_ca_and_port(IN osm_vendor_t * const p_vend,
230321936Shselasky				IN ib_net64_t const guid,
231321936Shselasky				OUT VAPI_hca_hndl_t * p_hca_hndl,
232321936Shselasky				OUT VAPI_hca_id_t * p_hca_id,
233321936Shselasky				OUT uint32_t * p_port_num);
234321936Shselasky
235321936Shselasky/*
236321936Shselasky* PARAMETERS
237321936Shselasky*	p_vend
238321936Shselasky*		[in] Pointer to an osm_vendor_t object.
239321936Shselasky*
240321936Shselasky*	guid
241321936Shselasky*		[in] The guid to search for.
242321936Shselasky*
243321936Shselasky*	p_hca_id
244321936Shselasky*		[out] The HCA Id (VAPI_hca_id_t *) that the port is found on.
245321936Shselasky*
246321936Shselasky*	p_port_num
247321936Shselasky*		[out] Pointer to a port number arg to be filled with the port number with the given guid.
248321936Shselasky*
249321936Shselasky* RETURN VALUES
250321936Shselasky*	IB_SUCCESS on SUCCESS
251321936Shselasky*  IB_INVALID_GUID if the guid is notfound on any Local HCA Port
252321936Shselasky*
253321936Shselasky* NOTES
254321936Shselasky*
255321936Shselasky* SEE ALSO
256321936Shselasky*********/
257321936Shselasky
258321936Shselasky/****f* OpenSM: Vendor MTL/osm_vendor_get_all_port_attr
259321936Shselasky * NAME
260321936Shselasky *	osm_vendor_get_all_port_attr
261321936Shselasky *
262321936Shselasky * DESCRIPTION
263321936Shselasky * Fill in the array of port_attr with all available ports on ALL the
264321936Shselasky * avilable CAs on this machine.
265321936Shselasky * ALSO -
266321936Shselasky * UPDATE THE VENDOR OBJECT LIST OF CA_INFO STRUCTS
267321936Shselasky *
268321936Shselasky * SYNOPSIS
269321936Shselasky */
270321936Shselaskyib_api_status_t osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
271321936Shselasky					     IN ib_port_attr_t *
272321936Shselasky					     const p_attr_array,
273321936Shselasky					     IN uint32_t * const p_num_ports);
274321936Shselasky
275321936Shselasky/*
276321936Shselasky* PARAMETERS
277321936Shselasky*	p_vend
278321936Shselasky*		[in] Pointer to an osm_vendor_t object.
279321936Shselasky*
280321936Shselasky*	p_attr_array
281321936Shselasky*		[out] Pre-allocated array of port attributes to be filled in
282321936Shselasky*
283321936Shselasky*	p_num_ports
284321936Shselasky*		[out] The size of the given array. Filled in by the actual numberof ports found.
285321936Shselasky*
286321936Shselasky* RETURN VALUES
287321936Shselasky*	IB_SUCCESS if OK
288321936Shselasky*  IB_INSUFFICIENT_MEMORY if not enough place for all ports was provided.
289321936Shselasky*
290321936Shselasky* NOTES
291321936Shselasky*
292321936Shselasky* SEE ALSO
293321936Shselasky*********/
294321936Shselasky
295321936Shselasky#define OSM_BIND_INVALID_HANDLE 0
296321936Shselasky
297321936Shselasky/****s* OpenSM: Vendor MTL/osm_bind_handle_t
298321936Shselasky* NAME
299321936Shselasky*   osm_bind_handle_t
300321936Shselasky*
301321936Shselasky* DESCRIPTION
302321936Shselasky* 	handle returned by the vendor transport bind call.
303321936Shselasky*
304321936Shselasky* SYNOPSIS
305321936Shselasky*/
306321936Shselaskytypedef void *osm_bind_handle_t;
307321936Shselasky
308321936Shselasky/***********/
309321936Shselasky
310321936Shselasky/****s* OpenSM: Vendor MTL/osm_vend_wrap_t
311321936Shselasky* NAME
312321936Shselasky*   MTL Vendor MAD Wrapper
313321936Shselasky*
314321936Shselasky* DESCRIPTION
315321936Shselasky*	MTL specific MAD wrapper. MTL transport layer uses this for
316321936Shselasky*	housekeeping.
317321936Shselasky*
318321936Shselasky* SYNOPSIS
319321936Shselasky*********/
320321936Shselaskytypedef struct _osm_vend_wrap_t {
321321936Shselasky	uint32_t size;
322321936Shselasky	osm_bind_handle_t h_bind;
323321936Shselasky	// ib_av_handle_t         h_av;
324321936Shselasky	ib_mad_t *mad_buf_p;
325321936Shselasky	void *p_resp_madw;
326321936Shselasky} osm_vend_wrap_t;
327321936Shselasky
328321936Shselasky/*
329321936Shselasky* FIELDS
330321936Shselasky*	size
331321936Shselasky*		Size of the allocated MAD
332321936Shselasky*
333321936Shselasky*	h_bind
334321936Shselasky*		Bind handle used on this transaction
335321936Shselasky*
336321936Shselasky*	h_av
337321936Shselasky*		Address vector handle used for this transaction.
338321936Shselasky*
339321936Shselasky*	p_resp_madw
340321936Shselasky*		Pointer to the mad wrapper structure used to hold the pending
341321936Shselasky*		reponse to the mad, if any.  If a response is expected, the
342321936Shselasky*		wrapper for the reponse is allocated during the send call.
343321936Shselasky*
344321936Shselasky* SEE ALSO
345321936Shselasky*********/
346321936Shselasky
347321936ShselaskyEND_C_DECLS
348321936Shselasky#endif				/* _OSM_VENDOR_MTL_H_ */
349