1/*
2 * Copyright (c) 2004-2008 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#ifndef _OSM_VENDOR_UMAD_H_
37#define _OSM_VENDOR_UMAD_H_
38
39#include <iba/ib_types.h>
40#include <complib/cl_qlist.h>
41#include <opensm/osm_base.h>
42#include <opensm/osm_log.h>
43
44#include <infiniband/umad.h>
45
46#ifdef __cplusplus
47#  define BEGIN_C_DECLS extern "C" {
48#  define END_C_DECLS   }
49#else				/* !__cplusplus */
50#  define BEGIN_C_DECLS
51#  define END_C_DECLS
52#endif				/* __cplusplus */
53
54BEGIN_C_DECLS
55/****h* OpenSM/Vendor Access Layer (UMAD)
56* NAME
57*	Vendor UMAD
58*
59* DESCRIPTION
60*	This file is the vendor specific file for the UMAD Infiniband API.
61*
62* AUTHOR
63*
64*
65*********/
66#define OSM_DEFAULT_RETRY_COUNT 3
67#define OSM_UMAD_MAX_CAS	UMAD_MAX_DEVICES
68#define OSM_UMAD_MAX_PORTS_PER_CA	2
69#define OSM_UMAD_MAX_AGENTS	32
70
71/****s* OpenSM: Vendor UMAD/osm_ca_info_t
72* NAME
73*   osm_ca_info_t
74*
75* DESCRIPTION
76* 	Structure containing information about local Channel Adapters.
77*
78* SYNOPSIS
79*/
80typedef struct _osm_ca_info {
81	ib_net64_t guid;
82	size_t attr_size;
83	ib_ca_attr_t *p_attr;
84} osm_ca_info_t;
85/*
86* FIELDS
87*	guid
88*		Node GUID of the local CA.
89*
90*	attr_size
91*		Size of the CA attributes for this CA.
92*
93*	p_attr
94*		Pointer to dynamicly allocated CA Attribute structure.
95*
96* SEE ALSO
97*********/
98
99/****f* OpenSM: CA Info/osm_ca_info_get_num_ports
100* NAME
101*	osm_ca_info_get_num_ports
102*
103* DESCRIPTION
104*	Returns the number of ports owned by this CA.
105*
106* SYNOPSIS
107*/
108static inline uint8_t
109osm_ca_info_get_num_ports(IN const osm_ca_info_t * const p_ca_info)
110{
111	return (p_ca_info->p_attr->num_ports);
112}
113
114/*
115* PARAMETERS
116*	p_ca_info
117*		[in] Pointer to a CA Info object.
118*
119* RETURN VUMADUE
120*	Returns the number of ports owned by this CA.
121*
122* NOTES
123*
124* SEE ALSO
125*********/
126
127/****s* OpenSM: Vendor UMAD/osm_bind_handle_t
128* NAME
129*   osm_bind_handle_t
130*
131* DESCRIPTION
132* 	handle returned by the vendor transport bind call.
133*
134* SYNOPSIS
135*/
136typedef void *osm_bind_handle_t;
137/***********/
138
139typedef struct _umad_match {
140	ib_net64_t tid;
141	void *v;
142	uint32_t version;
143	uint8_t mgmt_class;
144} umad_match_t;
145
146#define DEFAULT_OSM_UMAD_MAX_PENDING	1000
147
148typedef struct vendor_match_tbl {
149	uint32_t last_version;
150	int max;
151	umad_match_t *tbl;
152} vendor_match_tbl_t;
153
154typedef struct _osm_vendor {
155	osm_log_t *p_log;
156	uint32_t ca_count;
157	osm_ca_info_t *p_ca_info;
158	uint32_t timeout;
159	int max_retries;
160	osm_bind_handle_t agents[OSM_UMAD_MAX_AGENTS];
161	char ca_names[OSM_UMAD_MAX_CAS][UMAD_CA_NAME_LEN];
162	vendor_match_tbl_t mtbl;
163	umad_port_t umad_port;
164	pthread_mutex_t cb_mutex;
165	pthread_mutex_t match_tbl_mutex;
166	int umad_port_id;
167	void *receiver;
168	int issmfd;
169	char issm_path[256];
170} osm_vendor_t;
171
172#define OSM_BIND_INVALID_HANDLE 0
173
174typedef struct _osm_vend_wrap {
175	int agent;
176	int size;
177	int retries;
178	void *umad;
179	osm_bind_handle_t h_bind;
180} osm_vend_wrap_t;
181
182END_C_DECLS
183#endif				/* _OSM_VENDOR_UMAD_H_ */
184