2 * Copyright (c) 2006 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.
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:
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
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.
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
38 * Declaration of osmtest_t.
39 * This object represents the OSMTest Test object.
43 #ifndef _OSMTEST_SUBNET_H_
44 #define _OSMTEST_SUBNET_H_
47 #include <complib/cl_qmap.h>
48 #include <opensm/osm_log.h>
49 #include <vendor/osm_vendor_api.h>
50 #include <opensm/osm_mad_pool.h>
51 #include <opensm/osm_helper.h>
53 /****s* Subnet Database/generic_t
58 * Subnet database object for fields common to all record types.
59 * All other database types must be castable to this type.
63 typedef struct _generic {
64 cl_map_item_t map_item; /* must be first element! */
65 uint32_t count; /* must be second element! */
74 /****s* Subnet Database/node_t
79 * Subnet database object for nodes.
80 * Must be castable to generic_t.
84 typedef struct _node {
85 cl_map_item_t map_item; /* must be first element! */
86 uint32_t count; /* must be second element! */
88 ib_node_record_t comp;
94 * Provides linkage for the qmap container.
97 * NodeRecord for this node as read from the database file.
100 * NodeRecord indicating which fields should be compared against rec.
101 * Bits set in the comp NodeRecord indicate that bit in the rec structure
102 * should be compared against real-time data from the SA.
105 * Utility counter used by the validation logic. Typically used to
106 * to indicate the number of times a matching node was received from
112 static inline node_t *node_new(void)
116 p_obj = malloc(sizeof(*p_obj));
118 memset(p_obj, 0, sizeof(*p_obj));
122 static inline void node_delete(IN node_t * p_obj)
127 /****s* Subnet Database/port_t
132 * Subnet database object for ports.
133 * Must be castable to generic_t.
137 typedef struct _port {
138 cl_map_item_t map_item; /* must be first element! */
139 uint32_t count; /* must be second element! */
140 /* Since there is no unique identifier for all ports we
141 must be able to have such a key by the lid and port num */
143 ib_portinfo_record_t rec;
144 ib_portinfo_record_t comp;
151 * Provides linkage for the qmap container.
154 * PortInfoRecord for this port as read from the database file.
157 * PortInfoRecord indicating which fields should be compared against rec.
158 * Bits set in the comp NodeRecord indicate that bit in the rec structure
159 * should be compared against real-time data from the SA.
162 * Utility counter used by the validation logic. Typically used to
163 * to indicate the number of times a matching node was received from
169 static inline port_t *port_new(void)
173 p_obj = malloc(sizeof(*p_obj));
175 memset(p_obj, 0, sizeof(*p_obj));
179 static inline void port_delete(IN port_t * p_obj)
184 static inline uint64_t
185 port_gen_id(IN ib_net16_t const lid, IN uint8_t const port_num)
187 return (lid << 8 | port_num);
191 port_ext_id(IN uint64_t id, IN ib_net16_t * p_lid, IN uint8_t * p_port_num)
193 CL_ASSERT((id & 0xFF) < 0x100);
194 *p_port_num = (uint8_t) (id & 0xFF);
195 CL_ASSERT(((id >> 8) & 0xFFFF) < 0x10000);
196 *p_lid = (uint16_t) ((id >> 8) & 0xFFFF);
200 port_set_id(IN port_t * p_obj,
201 IN ib_net16_t const lid, IN uint8_t const port_num)
203 p_obj->port_id = port_gen_id(lid, port_num);
207 port_get_id(IN port_t * p_obj, IN ib_net16_t * p_lid, IN uint8_t * p_port_num)
209 port_ext_id(p_obj->port_id, p_lid, p_port_num);
212 /****s* Subnet Database/path_t
217 * Subnet database object for paths.
218 * Must be castable to generic_t.
222 typedef struct _path {
223 cl_map_item_t map_item; /* must be first element! */
224 uint32_t count; /* must be second element! */
232 * Provides linkage for the qmap container.
235 * PathRecord for this path as read from the database file.
238 * PathRecord indicating which fields should be compared against rec.
239 * Bits set in the comp PathRecord indicate that bit in the rec structure
240 * should be compared against real-time data from the SA.
243 * Utility counter used by the validation logic. Typically used to
244 * to indicate the number of times a matching node was received from
250 static inline path_t *path_new(void)
254 p_obj = malloc(sizeof(*p_obj));
256 memset(p_obj, 0, sizeof(*p_obj));
260 static inline void path_delete(IN path_t * p_obj)
265 /****s* Subnet Database/subnet_t
270 * Subnet database object.
274 typedef struct _subnet {
275 cl_qmap_t node_lid_tbl;
276 cl_qmap_t node_guid_tbl;
277 cl_qmap_t mgrp_mlid_tbl;
278 /* cl_qmap_t port_lid_tbl; */
279 /* cl_qmap_t port_guid_tbl; */
280 cl_qmap_t port_key_tbl;
291 /****f* Subnet Database/subnet_construct
296 * This function constructs an subnet database object.
297 * This function cannot fail.
301 void subnet_construct(IN subnet_t * const p_subn);
309 /****f* Subnet Database/subnet_init
314 * This function initializes an subnet database object.
318 cl_status_t subnet_init(IN subnet_t * const p_subn);