1219820Sjeff/* 2219820Sjeff * Copyright (c) 2006 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 osmtest_t. 39219820Sjeff * This object represents the OSMTest Test object. 40219820Sjeff * 41219820Sjeff */ 42219820Sjeff 43219820Sjeff#ifndef _OSMTEST_SUBNET_H_ 44219820Sjeff#define _OSMTEST_SUBNET_H_ 45219820Sjeff 46219820Sjeff#include <stdlib.h> 47219820Sjeff#include <complib/cl_qmap.h> 48219820Sjeff#include <opensm/osm_log.h> 49219820Sjeff#include <vendor/osm_vendor_api.h> 50219820Sjeff#include <opensm/osm_mad_pool.h> 51219820Sjeff#include <opensm/osm_helper.h> 52219820Sjeff 53219820Sjeff/****s* Subnet Database/generic_t 54219820Sjeff* NAME 55219820Sjeff* generic_t 56219820Sjeff* 57219820Sjeff* DESCRIPTION 58219820Sjeff* Subnet database object for fields common to all record types. 59219820Sjeff* All other database types must be castable to this type. 60219820Sjeff* 61219820Sjeff* SYNOPSIS 62219820Sjeff*/ 63219820Sjefftypedef struct _generic { 64219820Sjeff cl_map_item_t map_item; /* must be first element! */ 65219820Sjeff uint32_t count; /* must be second element! */ 66219820Sjeff} generic_t; 67219820Sjeff 68219820Sjeff/* 69219820Sjeff* FIELDS 70219820Sjeff* 71219820Sjeff* SEE ALSO 72219820Sjeff*********/ 73219820Sjeff 74219820Sjeff/****s* Subnet Database/node_t 75219820Sjeff* NAME 76219820Sjeff* node_t 77219820Sjeff* 78219820Sjeff* DESCRIPTION 79219820Sjeff* Subnet database object for nodes. 80219820Sjeff* Must be castable to generic_t. 81219820Sjeff* 82219820Sjeff* SYNOPSIS 83219820Sjeff*/ 84219820Sjefftypedef struct _node { 85219820Sjeff cl_map_item_t map_item; /* must be first element! */ 86219820Sjeff uint32_t count; /* must be second element! */ 87219820Sjeff ib_node_record_t rec; 88219820Sjeff ib_node_record_t comp; 89219820Sjeff} node_t; 90219820Sjeff 91219820Sjeff/* 92219820Sjeff* FIELDS 93219820Sjeff* map_item 94219820Sjeff* Provides linkage for the qmap container. 95219820Sjeff* 96219820Sjeff* rec 97219820Sjeff* NodeRecord for this node as read from the database file. 98219820Sjeff* 99219820Sjeff* comp 100219820Sjeff* NodeRecord indicating which fields should be compared against rec. 101219820Sjeff* Bits set in the comp NodeRecord indicate that bit in the rec structure 102219820Sjeff* should be compared against real-time data from the SA. 103219820Sjeff* 104219820Sjeff* count 105219820Sjeff* Utility counter used by the validation logic. Typically used to 106219820Sjeff* to indicate the number of times a matching node was received from 107219820Sjeff* the SA. 108219820Sjeff* 109219820Sjeff* SEE ALSO 110219820Sjeff*********/ 111219820Sjeff 112219820Sjeffstatic inline node_t *node_new(void) 113219820Sjeff{ 114219820Sjeff node_t *p_obj; 115219820Sjeff 116219820Sjeff p_obj = malloc(sizeof(*p_obj)); 117219820Sjeff if (p_obj) 118219820Sjeff memset(p_obj, 0, sizeof(*p_obj)); 119219820Sjeff return (p_obj); 120219820Sjeff} 121219820Sjeff 122219820Sjeffstatic inline void node_delete(IN node_t * p_obj) 123219820Sjeff{ 124219820Sjeff free(p_obj); 125219820Sjeff} 126219820Sjeff 127219820Sjeff/****s* Subnet Database/port_t 128219820Sjeff* NAME 129219820Sjeff* port_t 130219820Sjeff* 131219820Sjeff* DESCRIPTION 132219820Sjeff* Subnet database object for ports. 133219820Sjeff* Must be castable to generic_t. 134219820Sjeff* 135219820Sjeff* SYNOPSIS 136219820Sjeff*/ 137219820Sjefftypedef struct _port { 138219820Sjeff cl_map_item_t map_item; /* must be first element! */ 139219820Sjeff uint32_t count; /* must be second element! */ 140219820Sjeff /* Since there is no unique identifier for all ports we 141219820Sjeff must be able to have such a key by the lid and port num */ 142219820Sjeff uint64_t port_id; 143219820Sjeff ib_portinfo_record_t rec; 144219820Sjeff ib_portinfo_record_t comp; 145219820Sjeff} port_t; 146219820Sjeff 147219820Sjeff/* 148219820Sjeff* FIELDS 149219820Sjeff* 150219820Sjeff* map_item 151219820Sjeff* Provides linkage for the qmap container. 152219820Sjeff* 153219820Sjeff* rec 154219820Sjeff* PortInfoRecord for this port as read from the database file. 155219820Sjeff* 156219820Sjeff* comp 157219820Sjeff* PortInfoRecord indicating which fields should be compared against rec. 158219820Sjeff* Bits set in the comp NodeRecord indicate that bit in the rec structure 159219820Sjeff* should be compared against real-time data from the SA. 160219820Sjeff* 161219820Sjeff* count 162219820Sjeff* Utility counter used by the validation logic. Typically used to 163219820Sjeff* to indicate the number of times a matching node was received from 164219820Sjeff* the SA. 165219820Sjeff* 166219820Sjeff* SEE ALSO 167219820Sjeff*********/ 168219820Sjeff 169219820Sjeffstatic inline port_t *port_new(void) 170219820Sjeff{ 171219820Sjeff port_t *p_obj; 172219820Sjeff 173219820Sjeff p_obj = malloc(sizeof(*p_obj)); 174219820Sjeff if (p_obj) 175219820Sjeff memset(p_obj, 0, sizeof(*p_obj)); 176219820Sjeff return (p_obj); 177219820Sjeff} 178219820Sjeff 179219820Sjeffstatic inline void port_delete(IN port_t * p_obj) 180219820Sjeff{ 181219820Sjeff free(p_obj); 182219820Sjeff} 183219820Sjeff 184219820Sjeffstatic inline uint64_t 185219820Sjeffport_gen_id(IN ib_net16_t const lid, IN uint8_t const port_num) 186219820Sjeff{ 187219820Sjeff return (lid << 8 | port_num); 188219820Sjeff} 189219820Sjeff 190219820Sjeffstatic inline void 191219820Sjeffport_ext_id(IN uint64_t id, IN ib_net16_t * p_lid, IN uint8_t * p_port_num) 192219820Sjeff{ 193219820Sjeff CL_ASSERT((id & 0xFF) < 0x100); 194219820Sjeff *p_port_num = (uint8_t) (id & 0xFF); 195219820Sjeff CL_ASSERT(((id >> 8) & 0xFFFF) < 0x10000); 196219820Sjeff *p_lid = (uint16_t) ((id >> 8) & 0xFFFF); 197219820Sjeff} 198219820Sjeff 199219820Sjeffstatic inline void 200219820Sjeffport_set_id(IN port_t * p_obj, 201219820Sjeff IN ib_net16_t const lid, IN uint8_t const port_num) 202219820Sjeff{ 203219820Sjeff p_obj->port_id = port_gen_id(lid, port_num); 204219820Sjeff} 205219820Sjeff 206219820Sjeffstatic inline void 207219820Sjeffport_get_id(IN port_t * p_obj, IN ib_net16_t * p_lid, IN uint8_t * p_port_num) 208219820Sjeff{ 209219820Sjeff port_ext_id(p_obj->port_id, p_lid, p_port_num); 210219820Sjeff} 211219820Sjeff 212219820Sjeff/****s* Subnet Database/path_t 213219820Sjeff* NAME 214219820Sjeff* node_t 215219820Sjeff* 216219820Sjeff* DESCRIPTION 217219820Sjeff* Subnet database object for paths. 218219820Sjeff* Must be castable to generic_t. 219219820Sjeff* 220219820Sjeff* SYNOPSIS 221219820Sjeff*/ 222219820Sjefftypedef struct _path { 223219820Sjeff cl_map_item_t map_item; /* must be first element! */ 224219820Sjeff uint32_t count; /* must be second element! */ 225219820Sjeff ib_path_rec_t rec; 226219820Sjeff ib_path_rec_t comp; 227219820Sjeff} path_t; 228219820Sjeff 229219820Sjeff/* 230219820Sjeff* FIELDS 231219820Sjeff* map_item 232219820Sjeff* Provides linkage for the qmap container. 233219820Sjeff* 234219820Sjeff* rec 235219820Sjeff* PathRecord for this path as read from the database file. 236219820Sjeff* 237219820Sjeff* comp 238219820Sjeff* PathRecord indicating which fields should be compared against rec. 239219820Sjeff* Bits set in the comp PathRecord indicate that bit in the rec structure 240219820Sjeff* should be compared against real-time data from the SA. 241219820Sjeff* 242219820Sjeff* count 243219820Sjeff* Utility counter used by the validation logic. Typically used to 244219820Sjeff* to indicate the number of times a matching node was received from 245219820Sjeff* the SA. 246219820Sjeff* 247219820Sjeff* SEE ALSO 248219820Sjeff*********/ 249219820Sjeff 250219820Sjeffstatic inline path_t *path_new(void) 251219820Sjeff{ 252219820Sjeff path_t *p_obj; 253219820Sjeff 254219820Sjeff p_obj = malloc(sizeof(*p_obj)); 255219820Sjeff if (p_obj) 256219820Sjeff memset(p_obj, 0, sizeof(*p_obj)); 257219820Sjeff return (p_obj); 258219820Sjeff} 259219820Sjeff 260219820Sjeffstatic inline void path_delete(IN path_t * p_obj) 261219820Sjeff{ 262219820Sjeff free(p_obj); 263219820Sjeff} 264219820Sjeff 265219820Sjeff/****s* Subnet Database/subnet_t 266219820Sjeff* NAME 267219820Sjeff* subnet_t 268219820Sjeff* 269219820Sjeff* DESCRIPTION 270219820Sjeff* Subnet database object. 271219820Sjeff* 272219820Sjeff* SYNOPSIS 273219820Sjeff*/ 274219820Sjefftypedef struct _subnet { 275219820Sjeff cl_qmap_t node_lid_tbl; 276219820Sjeff cl_qmap_t node_guid_tbl; 277219820Sjeff cl_qmap_t mgrp_mlid_tbl; 278219820Sjeff /* cl_qmap_t port_lid_tbl; */ 279219820Sjeff /* cl_qmap_t port_guid_tbl; */ 280219820Sjeff cl_qmap_t port_key_tbl; 281219820Sjeff cl_qmap_t link_tbl; 282219820Sjeff cl_qmap_t path_tbl; 283219820Sjeff} subnet_t; 284219820Sjeff 285219820Sjeff/* 286219820Sjeff* FIELDS 287219820Sjeff* 288219820Sjeff* SEE ALSO 289219820Sjeff*********/ 290219820Sjeff 291219820Sjeff/****f* Subnet Database/subnet_construct 292219820Sjeff* NAME 293219820Sjeff* subnet_construct 294219820Sjeff* 295219820Sjeff* DESCRIPTION 296219820Sjeff* This function constructs an subnet database object. 297219820Sjeff* This function cannot fail. 298219820Sjeff* 299219820Sjeff* SYNOPSIS 300219820Sjeff*/ 301219820Sjeffvoid subnet_construct(IN subnet_t * const p_subn); 302219820Sjeff 303219820Sjeff/* 304219820Sjeff* FIELDS 305219820Sjeff* 306219820Sjeff* SEE ALSO 307219820Sjeff*********/ 308219820Sjeff 309219820Sjeff/****f* Subnet Database/subnet_init 310219820Sjeff* NAME 311219820Sjeff* subnet_init 312219820Sjeff* 313219820Sjeff* DESCRIPTION 314219820Sjeff* This function initializes an subnet database object. 315219820Sjeff* 316219820Sjeff* SYNOPSIS 317219820Sjeff*/ 318219820Sjeffcl_status_t subnet_init(IN subnet_t * const p_subn); 319219820Sjeff 320219820Sjeff/* 321219820Sjeff* FIELDS 322219820Sjeff* 323219820Sjeff* SEE ALSO 324219820Sjeff*********/ 325219820Sjeff 326219820Sjeff#endif 327