1219820Sjeff/*
2219820Sjeff * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
3219820Sjeff * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
4219820Sjeff * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
5219820Sjeff *
6219820Sjeff * This software is available to you under a choice of one of two
7219820Sjeff * licenses.  You may choose to be licensed under the terms of the GNU
8219820Sjeff * General Public License (GPL) Version 2, available from the file
9219820Sjeff * COPYING in the main directory of this source tree, or the
10219820Sjeff * OpenIB.org BSD license below:
11219820Sjeff *
12219820Sjeff *     Redistribution and use in source and binary forms, with or
13219820Sjeff *     without modification, are permitted provided that the following
14219820Sjeff *     conditions are met:
15219820Sjeff *
16219820Sjeff *      - Redistributions of source code must retain the above
17219820Sjeff *        copyright notice, this list of conditions and the following
18219820Sjeff *        disclaimer.
19219820Sjeff *
20219820Sjeff *      - Redistributions in binary form must reproduce the above
21219820Sjeff *        copyright notice, this list of conditions and the following
22219820Sjeff *        disclaimer in the documentation and/or other materials
23219820Sjeff *        provided with the distribution.
24219820Sjeff *
25219820Sjeff * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26219820Sjeff * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27219820Sjeff * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28219820Sjeff * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29219820Sjeff * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30219820Sjeff * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31219820Sjeff * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32219820Sjeff * SOFTWARE.
33219820Sjeff *
34219820Sjeff */
35219820Sjeff
36219820Sjeff/*
37219820Sjeff * Abstract:
38219820Sjeff * 	Declaration of osm_mad_wrapper_t.
39219820Sjeff *	This object represents the context wrapper for OpenSM MAD processing.
40219820Sjeff *	This object is part of the OpenSM family of objects.
41219820Sjeff */
42219820Sjeff
43219820Sjeff#ifndef _OSM_VENDOR_AL_H_
44219820Sjeff#define _OSM_VENDOR_AL_H_
45219820Sjeff
46219820Sjeff#include <iba/ib_types.h>
47219820Sjeff#include <iba/ib_al.h>
48219820Sjeff#include <complib/cl_qlist.h>
49219820Sjeff#include <complib/cl_thread.h>
50219820Sjeff#include <opensm/osm_base.h>
51219820Sjeff#include <opensm/osm_log.h>
52219820Sjeff
53219820Sjeff#ifdef __cplusplus
54219820Sjeff#  define BEGIN_C_DECLS extern "C" {
55219820Sjeff#  define END_C_DECLS   }
56219820Sjeff#else				/* !__cplusplus */
57219820Sjeff#  define BEGIN_C_DECLS
58219820Sjeff#  define END_C_DECLS
59219820Sjeff#endif				/* __cplusplus */
60219820Sjeff
61219820SjeffBEGIN_C_DECLS
62219820Sjeff/****h* OpenSM/Vendor AL
63219820Sjeff* NAME
64219820Sjeff*	Vendor AL
65219820Sjeff*
66219820Sjeff* DESCRIPTION
67219820Sjeff*
68219820Sjeff*	The Vendor AL object is thread safe.
69219820Sjeff*
70219820Sjeff*	This object should be treated as opaque and should be
71219820Sjeff*	manipulated only through the provided functions.
72219820Sjeff*
73219820Sjeff*	Enable various hacks to compensate for bugs in external code...
74219820Sjeff*
75219820Sjeff*
76219820Sjeff* AUTHOR
77219820Sjeff*
78219820Sjeff*
79219820Sjeff*********/
80219820Sjeff/****h* OpenSM/Vendor Access Layer (AL)
81219820Sjeff* NAME
82219820Sjeff*	Vendor AL
83219820Sjeff*
84219820Sjeff* DESCRIPTION
85219820Sjeff*	This file is the vendor specific file for the AL Infiniband API.
86219820Sjeff*
87219820Sjeff* AUTHOR
88219820Sjeff*	Steve King, Intel
89219820Sjeff*
90219820Sjeff*********/
91219820Sjeff#define OSM_AL_SQ_SGE 256
92219820Sjeff#define OSM_AL_RQ_SGE 256
93219820Sjeff#define OSM_DEFAULT_RETRY_COUNT 3
94219820Sjeff/* AL supports RMPP */
95219820Sjeff#define VENDOR_RMPP_SUPPORT 1
96219820Sjeff/****s* OpenSM: Vendor AL/osm_ca_info_t
97219820Sjeff* NAME
98219820Sjeff*   osm_ca_info_t
99219820Sjeff*
100219820Sjeff* DESCRIPTION
101219820Sjeff* 	Structure containing information about local Channle Adapters.
102219820Sjeff*
103219820Sjeff* SYNOPSIS
104219820Sjeff*/
105219820Sjefftypedef struct _osm_ca_info {
106219820Sjeff	ib_net64_t guid;
107219820Sjeff	size_t attr_size;
108219820Sjeff	ib_ca_attr_t *p_attr;
109219820Sjeff
110219820Sjeff} osm_ca_info_t;
111219820Sjeff/*
112219820Sjeff* FIELDS
113219820Sjeff*	guid
114219820Sjeff*		Node GUID of the local CA.
115219820Sjeff*
116219820Sjeff*	attr_size
117219820Sjeff*		Size of the CA attributes for this CA.
118219820Sjeff*
119219820Sjeff*	p_attr
120219820Sjeff*		Pointer to dynamicly allocated CA Attribute structure.
121219820Sjeff*
122219820Sjeff* SEE ALSO
123219820Sjeff*********/
124219820Sjeff
125219820Sjeff/****f* OpenSM: CA Info/osm_ca_info_get_num_ports
126219820Sjeff* NAME
127219820Sjeff*	osm_ca_info_get_num_ports
128219820Sjeff*
129219820Sjeff* DESCRIPTION
130219820Sjeff*	Returns the number of ports owned by this CA.
131219820Sjeff*
132219820Sjeff* SYNOPSIS
133219820Sjeff*/
134219820Sjeffstatic inline uint8_t
135219820Sjeffosm_ca_info_get_num_ports(IN const osm_ca_info_t * const p_ca_info)
136219820Sjeff{
137219820Sjeff	return (p_ca_info->p_attr->num_ports);
138219820Sjeff}
139219820Sjeff
140219820Sjeff/*
141219820Sjeff* PARAMETERS
142219820Sjeff*	p_ca_info
143219820Sjeff*		[in] Pointer to a CA Info object.
144219820Sjeff*
145219820Sjeff* RETURN VALUE
146219820Sjeff*	Returns the number of ports owned by this CA.
147219820Sjeff*
148219820Sjeff* NOTES
149219820Sjeff*
150219820Sjeff* SEE ALSO
151219820Sjeff*********/
152219820Sjeff
153219820Sjeff/****f* OpenSM: CA Info/osm_ca_info_get_port_guid
154219820Sjeff* NAME
155219820Sjeff*	osm_ca_info_get_port_guid
156219820Sjeff*
157219820Sjeff* DESCRIPTION
158219820Sjeff*	Returns the port GUID of the specified port owned by this CA.
159219820Sjeff*
160219820Sjeff* SYNOPSIS
161219820Sjeff*/
162219820Sjeffstatic inline ib_net64_t
163219820Sjeffosm_ca_info_get_port_guid(IN const osm_ca_info_t * const p_ca_info,
164219820Sjeff			  IN const uint8_t index)
165219820Sjeff{
166219820Sjeff	return (p_ca_info->p_attr->p_port_attr[index].port_guid);
167219820Sjeff}
168219820Sjeff
169219820Sjeff/*
170219820Sjeff* PARAMETERS
171219820Sjeff*	p_ca_info
172219820Sjeff*		[in] Pointer to a CA Info object.
173219820Sjeff*
174219820Sjeff*	index
175219820Sjeff*		[in] Port "index" for which to retrieve the port GUID.
176219820Sjeff*		The index is the offset into the ca's internal array
177219820Sjeff*		of port attributes.
178219820Sjeff*
179219820Sjeff* RETURN VALUE
180219820Sjeff*	Returns the port GUID of the specified port owned by this CA.
181219820Sjeff*
182219820Sjeff* NOTES
183219820Sjeff*
184219820Sjeff* SEE ALSO
185219820Sjeff*********/
186219820Sjeff
187219820Sjeff/****f* OpenSM: CA Info/osm_ca_info_get_port_num
188219820Sjeff* NAME
189219820Sjeff*	osm_ca_info_get_port_num
190219820Sjeff*
191219820Sjeff* DESCRIPTION
192219820Sjeff*	Returns the port number of the specified port owned by this CA.
193219820Sjeff*	Port numbers start with 1 for HCA's.
194219820Sjeff*
195219820Sjeff* SYNOPSIS
196219820Sjeff*/
197219820Sjeffstatic inline uint8_t
198219820Sjeffosm_ca_info_get_port_num(IN const osm_ca_info_t * const p_ca_info,
199219820Sjeff			 IN const uint8_t index)
200219820Sjeff{
201219820Sjeff	return (p_ca_info->p_attr->p_port_attr[index].port_num);
202219820Sjeff}
203219820Sjeff
204219820Sjeff/*
205219820Sjeff* PARAMETERS
206219820Sjeff*	p_ca_info
207219820Sjeff*		[in] Pointer to a CA Info object.
208219820Sjeff*
209219820Sjeff*	index
210219820Sjeff*		[in] Port "index" for which to retrieve the port GUID.
211219820Sjeff*		The index is the offset into the ca's internal array
212219820Sjeff*		of port attributes.
213219820Sjeff*
214219820Sjeff* RETURN VALUE
215219820Sjeff*	Returns the port GUID of the specified port owned by this CA.
216219820Sjeff*
217219820Sjeff* NOTES
218219820Sjeff*
219219820Sjeff* SEE ALSO
220219820Sjeff*********/
221219820Sjeff
222219820Sjeff/****f* OpenSM: CA Info/osm_ca_info_get_ca_guid
223219820Sjeff* NAME
224219820Sjeff*	osm_ca_info_get_ca_guid
225219820Sjeff*
226219820Sjeff* DESCRIPTION
227219820Sjeff*	Returns the GUID of the specified CA.
228219820Sjeff*
229219820Sjeff* SYNOPSIS
230219820Sjeff*/
231219820Sjeffstatic inline ib_net64_t
232219820Sjeffosm_ca_info_get_ca_guid(IN const osm_ca_info_t * const p_ca_info)
233219820Sjeff{
234219820Sjeff	return (p_ca_info->p_attr->ca_guid);
235219820Sjeff}
236219820Sjeff
237219820Sjeff/*
238219820Sjeff* PARAMETERS
239219820Sjeff*	p_ca_info
240219820Sjeff*		[in] Pointer to a CA Info object.
241219820Sjeff*
242219820Sjeff* RETURN VALUE
243219820Sjeff*	Returns the GUID of the specified CA.
244219820Sjeff*
245219820Sjeff* NOTES
246219820Sjeff*
247219820Sjeff* SEE ALSO
248219820Sjeff*********/
249219820Sjeff
250219820Sjeff/****s* OpenSM: Vendor AL/osm_bind_handle_t
251219820Sjeff* NAME
252219820Sjeff*   osm_bind_handle_t
253219820Sjeff*
254219820Sjeff* DESCRIPTION
255219820Sjeff* 	handle returned by the vendor transport bind call.
256219820Sjeff*
257219820Sjeff* SYNOPSIS
258219820Sjeff*/
259219820Sjefftypedef struct _osm_vendor {
260219820Sjeff	ib_al_handle_t h_al;
261219820Sjeff	osm_log_t *p_log;
262219820Sjeff	uint32_t ca_count;
263219820Sjeff	osm_ca_info_t *p_ca_info;
264219820Sjeff	uint32_t timeout;
265219820Sjeff	ib_ca_handle_t h_ca;
266219820Sjeff	ib_pd_handle_t h_pd;
267219820Sjeff
268219820Sjeff} osm_vendor_t;
269219820Sjeff/*
270219820Sjeff* FIELDS
271219820Sjeff*	h_al
272219820Sjeff*		Handle returned by AL open call (ib_open_al).
273219820Sjeff*
274219820Sjeff*	p_log
275219820Sjeff*		Pointer to the log object.
276219820Sjeff*
277219820Sjeff*	ca_count
278219820Sjeff*		Number of CA's in the array pointed to by p_ca_info.
279219820Sjeff*
280219820Sjeff*	p_ca_info
281219820Sjeff*		Pointer to dynamically allocated array of CA info objects.
282219820Sjeff*
283219820Sjeff*	h_pool
284219820Sjeff*		MAD Pool handle returned by ib_create_mad_pool at init time.
285219820Sjeff*
286219820Sjeff*	timeout
287219820Sjeff*		Transaction timeout time in milliseconds.
288219820Sjeff*
289219820Sjeff* SEE ALSO
290219820Sjeff*********/
291219820Sjeff
292219820Sjeff#define OSM_BIND_INVALID_HANDLE 0
293219820Sjeff
294219820Sjeff/****s* OpenSM: Vendor AL/osm_bind_handle_t
295219820Sjeff* NAME
296219820Sjeff*   osm_bind_handle_t
297219820Sjeff*
298219820Sjeff* DESCRIPTION
299219820Sjeff* 	handle returned by the vendor transport bind call.
300219820Sjeff*
301219820Sjeff* SYNOPSIS
302219820Sjeff*/
303219820Sjefftypedef void *osm_bind_handle_t;
304219820Sjeff/***********/
305219820Sjeff
306219820Sjeff/****s* OpenSM/osm_vend_wrap_t
307219820Sjeff* NAME
308219820Sjeff*   AL Vendor MAD Wrapper
309219820Sjeff*
310219820Sjeff* DESCRIPTION
311219820Sjeff*	AL specific MAD wrapper. AL transport layer uses this for
312219820Sjeff*	housekeeping.
313219820Sjeff*
314219820Sjeff* SYNOPSIS
315219820Sjeff*********/
316219820Sjefftypedef struct _osm_vend_wrap_t {
317219820Sjeff	uint32_t size;
318219820Sjeff	osm_bind_handle_t h_bind;
319219820Sjeff	ib_mad_element_t *p_elem;
320219820Sjeff	ib_av_handle_t h_av;
321219820Sjeff	void *p_resp_madw;
322219820Sjeff
323219820Sjeff} osm_vend_wrap_t;
324219820Sjeff/*
325219820Sjeff* FIELDS
326219820Sjeff*	size
327219820Sjeff*		Size of the allocated MAD
328219820Sjeff*
329219820Sjeff*	h_bind
330219820Sjeff*		Bind handle used on this transaction
331219820Sjeff*
332219820Sjeff*	p_elem
333219820Sjeff*		Pointer to the mad element structure associated with
334219820Sjeff*		this mad.
335219820Sjeff*
336219820Sjeff*	h_av
337219820Sjeff*		Address vector handle used for this transaction.
338219820Sjeff*
339219820Sjeff*	p_resp_madw
340219820Sjeff*		Pointer to the mad wrapper structure used to hold the pending
341219820Sjeff*		reponse to the mad, if any.  If a response is expected, the
342219820Sjeff*		wrapper for the reponse is allocated during the send call.
343219820Sjeff*
344219820Sjeff* SEE ALSO
345219820Sjeff*********/
346219820Sjeff
347219820SjeffEND_C_DECLS
348219820Sjeff#endif				/* _OSM_VENDOR_AL_H_ */
349