File: osmtest_subnet.h

package info (click to toggle)
opensm 3.3.23-3.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,932 kB
  • sloc: ansic: 97,383; yacc: 2,227; sh: 685; lex: 404; makefile: 391; perl: 143
file content (326 lines) | stat: -rw-r--r-- 7,274 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
/*
 * Copyright (c) 2006 Voltaire, Inc. All rights reserved.
 * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
 * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
 *
 * This software is available to you under a choice of one of two
 * licenses.  You may choose to be licensed under the terms of the GNU
 * General Public License (GPL) Version 2, available from the file
 * COPYING in the main directory of this source tree, or the
 * OpenIB.org BSD license below:
 *
 *     Redistribution and use in source and binary forms, with or
 *     without modification, are permitted provided that the following
 *     conditions are met:
 *
 *      - Redistributions of source code must retain the above
 *        copyright notice, this list of conditions and the following
 *        disclaimer.
 *
 *      - Redistributions in binary form must reproduce the above
 *        copyright notice, this list of conditions and the following
 *        disclaimer in the documentation and/or other materials
 *        provided with the distribution.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *
 */

/*
 * Abstract:
 * 	Declaration of osmtest_t.
 *	This object represents the OSMTest Test object.
 *
 */

#ifndef _OSMTEST_SUBNET_H_
#define _OSMTEST_SUBNET_H_

#include <stdlib.h>
#include <complib/cl_qmap.h>
#include <opensm/osm_log.h>
#include <vendor/osm_vendor_api.h>
#include <opensm/osm_mad_pool.h>
#include <opensm/osm_helper.h>

/****s* Subnet Database/generic_t
* NAME
*	generic_t
*
* DESCRIPTION
*	Subnet database object for fields common to all record types.
*	All other database types must be castable to this type.
*
* SYNOPSIS
*/
typedef struct _generic {
	cl_map_item_t map_item;	/* must be first element! */
	uint32_t count;		/* must be second element! */
} generic_t;

/*
* FIELDS
*
* SEE ALSO
*********/

/****s* Subnet Database/node_t
* NAME
*	node_t
*
* DESCRIPTION
*	Subnet database object for nodes.
*	Must be castable to generic_t.
*
* SYNOPSIS
*/
typedef struct _node {
	cl_map_item_t map_item;	/* must be first element! */
	uint32_t count;		/* must be second element! */
	ib_node_record_t rec;
	ib_node_record_t comp;
} node_t;

/*
* FIELDS
* map_item
*	Provides linkage for the qmap container.
*
* rec
*	NodeRecord for this node as read from the database file.
*
* comp
*	NodeRecord indicating which fields should be compared against rec.
*	Bits set in the comp NodeRecord indicate that bit in the rec structure
*	should be compared against real-time data from the SA.
*
* count
*	Utility counter used by the validation logic.  Typically used to
*	to indicate the number of times a matching node was received from
*	the SA.
*
* SEE ALSO
*********/

static inline node_t *node_new(void)
{
	node_t *p_obj;

	p_obj = malloc(sizeof(*p_obj));
	if (p_obj)
		memset(p_obj, 0, sizeof(*p_obj));
	return (p_obj);
}

static inline void node_delete(IN node_t * p_obj)
{
	free(p_obj);
}

/****s* Subnet Database/port_t
* NAME
*	port_t
*
* DESCRIPTION
*	Subnet database object for ports.
*	Must be castable to generic_t.
*
* SYNOPSIS
*/
typedef struct _port {
	cl_map_item_t map_item;	/* must be first element! */
	uint32_t count;		/* must be second element! */
	/* Since there is no unique identifier for all ports we
	   must be able to have such a key by the lid and port num */
	uint64_t port_id;
	ib_portinfo_record_t rec;
	ib_portinfo_record_t comp;
} port_t;

/*
* FIELDS
*
* map_item
*	Provides linkage for the qmap container.
*
* rec
*	PortInfoRecord for this port as read from the database file.
*
* comp
*	PortInfoRecord indicating which fields should be compared against rec.
*	Bits set in the comp NodeRecord indicate that bit in the rec structure
*	should be compared against real-time data from the SA.
*
* count
*	Utility counter used by the validation logic.  Typically used to
*	to indicate the number of times a matching node was received from
*	the SA.
*
* SEE ALSO
*********/

static inline port_t *port_new(void)
{
	port_t *p_obj;

	p_obj = malloc(sizeof(*p_obj));
	if (p_obj)
		memset(p_obj, 0, sizeof(*p_obj));
	return (p_obj);
}

static inline void port_delete(IN port_t * p_obj)
{
	free(p_obj);
}

static inline uint64_t
port_gen_id(IN ib_net16_t const lid, IN uint8_t const port_num)
{
	return (lid << 8 | port_num);
}

static inline void
port_ext_id(IN uint64_t id, IN ib_net16_t * p_lid, IN uint8_t * p_port_num)
{
	CL_ASSERT((id & 0xFF) < 0x100);
	*p_port_num = (uint8_t) (id & 0xFF);
	CL_ASSERT(((id >> 8) & 0xFFFF) < 0x10000);
	*p_lid = (uint16_t) ((id >> 8) & 0xFFFF);
}

static inline void
port_set_id(IN port_t * p_obj,
	    IN ib_net16_t const lid, IN uint8_t const port_num)
{
	p_obj->port_id = port_gen_id(lid, port_num);
}

static inline void
port_get_id(IN port_t * p_obj, IN ib_net16_t * p_lid, IN uint8_t * p_port_num)
{
	port_ext_id(p_obj->port_id, p_lid, p_port_num);
}

/****s* Subnet Database/path_t
* NAME
*	node_t
*
* DESCRIPTION
*	Subnet database object for paths.
*	Must be castable to generic_t.
*
* SYNOPSIS
*/
typedef struct _path {
	cl_map_item_t map_item;	/* must be first element! */
	uint32_t count;		/* must be second element! */
	ib_path_rec_t rec;
	ib_path_rec_t comp;
} path_t;

/*
* FIELDS
* map_item
*	Provides linkage for the qmap container.
*
* rec
*	PathRecord for this path as read from the database file.
*
* comp
*	PathRecord indicating which fields should be compared against rec.
*	Bits set in the comp PathRecord indicate that bit in the rec structure
*	should be compared against real-time data from the SA.
*
* count
*	Utility counter used by the validation logic.  Typically used to
*	to indicate the number of times a matching node was received from
*	the SA.
*
* SEE ALSO
*********/

static inline path_t *path_new(void)
{
	path_t *p_obj;

	p_obj = malloc(sizeof(*p_obj));
	if (p_obj)
		memset(p_obj, 0, sizeof(*p_obj));
	return (p_obj);
}

static inline void path_delete(IN path_t * p_obj)
{
	free(p_obj);
}

/****s* Subnet Database/subnet_t
* NAME
*	subnet_t
*
* DESCRIPTION
*	Subnet database object.
*
* SYNOPSIS
*/
typedef struct _subnet {
	cl_qmap_t node_lid_tbl;
	cl_qmap_t node_guid_tbl;
	cl_qmap_t mgrp_mlid_tbl;
	/* cl_qmap_t port_lid_tbl; */
	/* cl_qmap_t port_guid_tbl; */
	cl_qmap_t port_key_tbl;
	cl_qmap_t link_tbl;
	cl_qmap_t path_tbl;
} subnet_t;

/*
* FIELDS
*
* SEE ALSO
*********/

/****f* Subnet Database/subnet_construct
* NAME
*	subnet_construct
*
* DESCRIPTION
*	This function constructs an subnet database object.
*	This function cannot fail.
*
* SYNOPSIS
*/
void subnet_construct(IN subnet_t * const p_subn);

/*
* FIELDS
*
* SEE ALSO
*********/

/****f* Subnet Database/subnet_init
* NAME
*	subnet_init
*
* DESCRIPTION
*	This function initializes an subnet database object.
*
* SYNOPSIS
*/
cl_status_t subnet_init(IN subnet_t * const p_subn);

/*
* FIELDS
*
* SEE ALSO
*********/

#endif