1219820Sjeff/* 2219820Sjeff * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved. 3219820Sjeff * Copyright (c) 2002-2006 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_opensm_t. 39219820Sjeff * This object represents the OpenSM super object. 40219820Sjeff * This object is part of the OpenSM family of objects. 41219820Sjeff */ 42219820Sjeff 43219820Sjeff#ifndef _OSM_OPENSM_H_ 44219820Sjeff#define _OSM_OPENSM_H_ 45219820Sjeff 46219820Sjeff#include <stdio.h> 47219820Sjeff#include <complib/cl_qlist.h> 48219820Sjeff#include <complib/cl_dispatcher.h> 49219820Sjeff#include <complib/cl_passivelock.h> 50219820Sjeff#include <complib/cl_atomic.h> 51219820Sjeff#include <complib/cl_nodenamemap.h> 52219820Sjeff#include <opensm/osm_console_io.h> 53219820Sjeff#include <opensm/osm_stats.h> 54219820Sjeff#include <opensm/osm_log.h> 55219820Sjeff#include <opensm/osm_sm.h> 56219820Sjeff#include <opensm/osm_sa.h> 57219820Sjeff#include <opensm/osm_perfmgr.h> 58219820Sjeff#include <opensm/osm_event_plugin.h> 59219820Sjeff#include <opensm/osm_db.h> 60219820Sjeff#include <opensm/osm_subnet.h> 61219820Sjeff#include <opensm/osm_mad_pool.h> 62219820Sjeff#include <opensm/osm_vl15intf.h> 63219820Sjeff 64219820Sjeff#ifdef __cplusplus 65219820Sjeff# define BEGIN_C_DECLS extern "C" { 66219820Sjeff# define END_C_DECLS } 67219820Sjeff#else /* !__cplusplus */ 68219820Sjeff# define BEGIN_C_DECLS 69219820Sjeff# define END_C_DECLS 70219820Sjeff#endif /* __cplusplus */ 71219820Sjeff 72219820SjeffBEGIN_C_DECLS 73219820Sjeff/****h* OpenSM/OpenSM 74219820Sjeff* NAME 75219820Sjeff* OpenSM 76219820Sjeff* 77219820Sjeff* DESCRIPTION 78219820Sjeff* The OpenSM object encapsulates the information needed by the 79219820Sjeff* OpenSM to govern itself. The OpenSM is one OpenSM object. 80219820Sjeff* 81219820Sjeff* The OpenSM object is thread safe. 82219820Sjeff* 83219820Sjeff* This object should be treated as opaque and should 84219820Sjeff* be manipulated only through the provided functions. 85219820Sjeff* 86219820Sjeff* AUTHOR 87219820Sjeff* Steve King, Intel 88219820Sjeff* 89219820Sjeff*********/ 90219820Sjeff/****d* OpenSM: OpenSM/osm_routing_engine_type_t 91219820Sjeff* NAME 92219820Sjeff* osm_routing_engine_type_t 93219820Sjeff* 94219820Sjeff* DESCRIPTION 95219820Sjeff* Enumerates the possible routing engines that 96219820Sjeff* could be used to route a subnet. 97219820Sjeff* 98219820Sjeff* SYNOPSIS 99219820Sjeff*/ 100219820Sjefftypedef enum _osm_routing_engine_type { 101219820Sjeff OSM_ROUTING_ENGINE_TYPE_NONE = 0, 102219820Sjeff OSM_ROUTING_ENGINE_TYPE_MINHOP, 103219820Sjeff OSM_ROUTING_ENGINE_TYPE_UPDN, 104219820Sjeff OSM_ROUTING_ENGINE_TYPE_FILE, 105219820Sjeff OSM_ROUTING_ENGINE_TYPE_FTREE, 106219820Sjeff OSM_ROUTING_ENGINE_TYPE_LASH, 107219820Sjeff OSM_ROUTING_ENGINE_TYPE_DOR, 108219820Sjeff OSM_ROUTING_ENGINE_TYPE_UNKNOWN 109219820Sjeff} osm_routing_engine_type_t; 110219820Sjeff/***********/ 111219820Sjeff 112219820Sjeff/****s* OpenSM: OpenSM/osm_routing_engine 113219820Sjeff* NAME 114219820Sjeff* struct osm_routing_engine 115219820Sjeff* 116219820Sjeff* DESCRIPTION 117219820Sjeff* OpenSM routing engine module definition. 118219820Sjeff* NOTES 119219820Sjeff* routing engine structure - multicast callbacks may be 120219820Sjeff* added later. 121219820Sjeff*/ 122219820Sjeffstruct osm_routing_engine { 123219820Sjeff const char *name; 124219820Sjeff void *context; 125219820Sjeff int (*build_lid_matrices) (void *context); 126219820Sjeff int (*ucast_build_fwd_tables) (void *context); 127219820Sjeff void (*ucast_dump_tables) (void *context); 128219820Sjeff void (*delete) (void *context); 129219820Sjeff struct osm_routing_engine *next; 130219820Sjeff}; 131219820Sjeff/* 132219820Sjeff* FIELDS 133219820Sjeff* name 134219820Sjeff* The routing engine name (will be used in logs). 135219820Sjeff* 136219820Sjeff* context 137219820Sjeff* The routing engine context. Will be passed as parameter 138219820Sjeff* to the callback functions. 139219820Sjeff* 140219820Sjeff* build_lid_matrices 141219820Sjeff* The callback for lid matrices generation. 142219820Sjeff* 143219820Sjeff* ucast_build_fwd_tables 144219820Sjeff* The callback for unicast forwarding table generation. 145219820Sjeff* 146219820Sjeff* ucast_dump_tables 147219820Sjeff* The callback for dumping unicast routing tables. 148219820Sjeff* 149219820Sjeff* delete 150219820Sjeff* The delete method, may be used for routing engine 151219820Sjeff* internals cleanup. 152219820Sjeff* 153219820Sjeff* next 154219820Sjeff* Pointer to next routing engine in the list. 155219820Sjeff*/ 156219820Sjeff 157219820Sjeff/****s* OpenSM: OpenSM/osm_opensm_t 158219820Sjeff* NAME 159219820Sjeff* osm_opensm_t 160219820Sjeff* 161219820Sjeff* DESCRIPTION 162219820Sjeff* OpenSM structure. 163219820Sjeff* 164219820Sjeff* This object should be treated as opaque and should 165219820Sjeff* be manipulated only through the provided functions. 166219820Sjeff* 167219820Sjeff* SYNOPSIS 168219820Sjeff*/ 169219820Sjefftypedef struct osm_opensm { 170219820Sjeff const char *osm_version; 171219820Sjeff osm_subn_t subn; 172219820Sjeff osm_sm_t sm; 173219820Sjeff osm_sa_t sa; 174219820Sjeff#ifdef ENABLE_OSM_PERF_MGR 175219820Sjeff osm_perfmgr_t perfmgr; 176219820Sjeff#endif /* ENABLE_OSM_PERF_MGR */ 177219820Sjeff cl_qlist_t plugin_list; 178219820Sjeff osm_db_t db; 179219820Sjeff osm_mad_pool_t mad_pool; 180219820Sjeff osm_vendor_t *p_vendor; 181219820Sjeff osm_vl15_t vl15; 182219820Sjeff osm_log_t log; 183219820Sjeff cl_dispatcher_t disp; 184219820Sjeff cl_plock_t lock; 185219820Sjeff struct osm_routing_engine *routing_engine_list; 186219820Sjeff osm_routing_engine_type_t routing_engine_used; 187219820Sjeff osm_stats_t stats; 188219820Sjeff osm_console_t console; 189219820Sjeff nn_map_t *node_name_map; 190219820Sjeff} osm_opensm_t; 191219820Sjeff/* 192219820Sjeff* FIELDS 193219820Sjeff* osm_version 194219820Sjeff* OpenSM version (as generated in osm_version.h) 195219820Sjeff* 196219820Sjeff* subn 197219820Sjeff* Subnet object for this subnet. 198219820Sjeff* 199219820Sjeff* sm 200219820Sjeff* The Subnet Manager (SM) object for this subnet. 201219820Sjeff* 202219820Sjeff* sa 203219820Sjeff* The Subnet Administration (SA) object for this subnet. 204219820Sjeff* 205219820Sjeff* db 206219820Sjeff* Persistant storage of some data required between sessions. 207219820Sjeff* 208219820Sjeff* mad_pool 209219820Sjeff* Pool of Management Datagram (MAD) objects. 210219820Sjeff* 211219820Sjeff* p_vendor 212219820Sjeff* Pointer to the Vendor specific adapter for various 213219820Sjeff* transport interfaces, such as UMADT, AL, etc. The 214219820Sjeff* particular interface is set at compile time. 215219820Sjeff* 216219820Sjeff* vl15 217219820Sjeff* The VL15 interface. 218219820Sjeff* 219219820Sjeff* log 220219820Sjeff* Log facility used by all OpenSM components. 221219820Sjeff* 222219820Sjeff* disp 223219820Sjeff* Central dispatcher containing the OpenSM worker threads. 224219820Sjeff* 225219820Sjeff* lock 226219820Sjeff* Shared lock guarding most OpenSM structures. 227219820Sjeff* 228219820Sjeff* routing_engine_list 229219820Sjeff* List of routing engines that should be tried for use. 230219820Sjeff* 231219820Sjeff* routing_engine_used 232219820Sjeff* Indicates which routing engine was used to route a subnet. 233219820Sjeff* 234219820Sjeff* stats 235219820Sjeff* Open SM statistics block 236219820Sjeff* 237219820Sjeff* SEE ALSO 238219820Sjeff*********/ 239219820Sjeff 240219820Sjeff/****f* OpenSM: OpenSM/osm_opensm_construct 241219820Sjeff* NAME 242219820Sjeff* osm_opensm_construct 243219820Sjeff* 244219820Sjeff* DESCRIPTION 245219820Sjeff* This function constructs an OpenSM object. 246219820Sjeff* 247219820Sjeff* SYNOPSIS 248219820Sjeff*/ 249219820Sjeffvoid osm_opensm_construct(IN osm_opensm_t * const p_osm); 250219820Sjeff/* 251219820Sjeff* PARAMETERS 252219820Sjeff* p_osm 253219820Sjeff* [in] Pointer to a OpenSM object to construct. 254219820Sjeff* 255219820Sjeff* RETURN VALUE 256219820Sjeff* This function does not return a value. 257219820Sjeff* 258219820Sjeff* NOTES 259219820Sjeff* Allows calling osm_opensm_init, osm_opensm_destroy 260219820Sjeff* 261219820Sjeff* Calling osm_opensm_construct is a prerequisite to calling any other 262219820Sjeff* method except osm_opensm_init. 263219820Sjeff* 264219820Sjeff* SEE ALSO 265219820Sjeff* SM object, osm_opensm_init, osm_opensm_destroy 266219820Sjeff*********/ 267219820Sjeff 268219820Sjeff/****f* OpenSM: OpenSM/osm_opensm_destroy 269219820Sjeff* NAME 270219820Sjeff* osm_opensm_destroy 271219820Sjeff* 272219820Sjeff* DESCRIPTION 273219820Sjeff* The osm_opensm_destroy function destroys an SM, releasing 274219820Sjeff* all resources. 275219820Sjeff* 276219820Sjeff* SYNOPSIS 277219820Sjeff*/ 278219820Sjeffvoid osm_opensm_destroy(IN osm_opensm_t * const p_osm); 279219820Sjeff/* 280219820Sjeff* PARAMETERS 281219820Sjeff* p_osm 282219820Sjeff* [in] Pointer to a OpenSM object to destroy. 283219820Sjeff* 284219820Sjeff* RETURN VALUE 285219820Sjeff* This function does not return a value. 286219820Sjeff* 287219820Sjeff* NOTES 288219820Sjeff* Performs any necessary cleanup of the specified OpenSM object. 289219820Sjeff* Further operations should not be attempted on the destroyed object. 290219820Sjeff* This function should only be called after a call to osm_opensm_construct or 291219820Sjeff* osm_opensm_init. 292219820Sjeff* 293219820Sjeff* SEE ALSO 294219820Sjeff* SM object, osm_opensm_construct, osm_opensm_init 295219820Sjeff*********/ 296219820Sjeff 297219820Sjeff/****f* OpenSM: OpenSM/osm_opensm_init 298219820Sjeff* NAME 299219820Sjeff* osm_opensm_init 300219820Sjeff* 301219820Sjeff* DESCRIPTION 302219820Sjeff* The osm_opensm_init function initializes a OpenSM object for use. 303219820Sjeff* 304219820Sjeff* SYNOPSIS 305219820Sjeff*/ 306219820Sjeffib_api_status_t 307219820Sjeffosm_opensm_init(IN osm_opensm_t * const p_osm, 308219820Sjeff IN const osm_subn_opt_t * const p_opt); 309219820Sjeff/* 310219820Sjeff* PARAMETERS 311219820Sjeff* p_osm 312219820Sjeff* [in] Pointer to an osm_opensm_t object to initialize. 313219820Sjeff* 314219820Sjeff* p_opt 315219820Sjeff* [in] Pointer to the subnet options structure. 316219820Sjeff* 317219820Sjeff* RETURN VALUES 318219820Sjeff* IB_SUCCESS if the OpenSM object was initialized successfully. 319219820Sjeff* 320219820Sjeff* NOTES 321219820Sjeff* Allows calling other OpenSM methods. 322219820Sjeff* 323219820Sjeff* SEE ALSO 324219820Sjeff* SM object, osm_opensm_construct, osm_opensm_destroy 325219820Sjeff*********/ 326219820Sjeff 327219820Sjeff/****f* OpenSM: OpenSM/osm_opensm_sweep 328219820Sjeff* NAME 329219820Sjeff* osm_opensm_sweep 330219820Sjeff* 331219820Sjeff* DESCRIPTION 332219820Sjeff* Initiates a subnet sweep. 333219820Sjeff* 334219820Sjeff* SYNOPSIS 335219820Sjeff*/ 336219820Sjeffstatic inline void osm_opensm_sweep(IN osm_opensm_t * const p_osm) 337219820Sjeff{ 338219820Sjeff osm_sm_sweep(&p_osm->sm); 339219820Sjeff} 340219820Sjeff 341219820Sjeff/* 342219820Sjeff* PARAMETERS 343219820Sjeff* p_osm 344219820Sjeff* [in] Pointer to an osm_opensm_t object on which to 345219820Sjeff* initiate a sweep. 346219820Sjeff* 347219820Sjeff* RETURN VALUES 348219820Sjeff* None 349219820Sjeff* 350219820Sjeff* NOTES 351219820Sjeff* If the OpenSM object is not bound to a port, this function 352219820Sjeff* does nothing. 353219820Sjeff* 354219820Sjeff* SEE ALSO 355219820Sjeff*********/ 356219820Sjeff 357219820Sjeff/****f* OpenSM: OpenSM/osm_opensm_set_log_flags 358219820Sjeff* NAME 359219820Sjeff* osm_opensm_set_log_flags 360219820Sjeff* 361219820Sjeff* DESCRIPTION 362219820Sjeff* Sets the log level. 363219820Sjeff* 364219820Sjeff* SYNOPSIS 365219820Sjeff*/ 366219820Sjeffstatic inline void 367219820Sjeffosm_opensm_set_log_flags(IN osm_opensm_t * const p_osm, 368219820Sjeff IN const osm_log_level_t log_flags) 369219820Sjeff{ 370219820Sjeff osm_log_set_level(&p_osm->log, log_flags); 371219820Sjeff} 372219820Sjeff 373219820Sjeff/* 374219820Sjeff* PARAMETERS 375219820Sjeff* p_osm 376219820Sjeff* [in] Pointer to an osm_opensm_t object. 377219820Sjeff* 378219820Sjeff* log_flags 379219820Sjeff* [in] Log level flags to set. 380219820Sjeff* 381219820Sjeff* RETURN VALUES 382219820Sjeff* None 383219820Sjeff* 384219820Sjeff* NOTES 385219820Sjeff* 386219820Sjeff* SEE ALSO 387219820Sjeff*********/ 388219820Sjeff 389219820Sjeff/****f* OpenSM: OpenSM/osm_opensm_bind 390219820Sjeff* NAME 391219820Sjeff* osm_opensm_bind 392219820Sjeff* 393219820Sjeff* DESCRIPTION 394219820Sjeff* Binds the opensm object to a port guid. 395219820Sjeff* 396219820Sjeff* SYNOPSIS 397219820Sjeff*/ 398219820Sjeffib_api_status_t 399219820Sjeffosm_opensm_bind(IN osm_opensm_t * const p_osm, IN const ib_net64_t guid); 400219820Sjeff/* 401219820Sjeff* PARAMETERS 402219820Sjeff* p_osm 403219820Sjeff* [in] Pointer to an osm_opensm_t object to bind. 404219820Sjeff* 405219820Sjeff* guid 406219820Sjeff* [in] Local port GUID with which to bind. 407219820Sjeff* 408219820Sjeff* RETURN VALUES 409219820Sjeff* None 410219820Sjeff* 411219820Sjeff* NOTES 412219820Sjeff* A given opensm object can only be bound to one port at a time. 413219820Sjeff* 414219820Sjeff* SEE ALSO 415219820Sjeff*********/ 416219820Sjeff 417219820Sjeff/****f* OpenSM: OpenSM/osm_opensm_wait_for_subnet_up 418219820Sjeff* NAME 419219820Sjeff* osm_opensm_wait_for_subnet_up 420219820Sjeff* 421219820Sjeff* DESCRIPTION 422219820Sjeff* Blocks the calling thread until the subnet is up. 423219820Sjeff* 424219820Sjeff* SYNOPSIS 425219820Sjeff*/ 426219820Sjeffstatic inline cl_status_t 427219820Sjeffosm_opensm_wait_for_subnet_up(IN osm_opensm_t * const p_osm, 428219820Sjeff IN uint32_t const wait_us, 429219820Sjeff IN boolean_t const interruptible) 430219820Sjeff{ 431219820Sjeff return (osm_sm_wait_for_subnet_up(&p_osm->sm, wait_us, interruptible)); 432219820Sjeff} 433219820Sjeff 434219820Sjeff/* 435219820Sjeff* PARAMETERS 436219820Sjeff* p_osm 437219820Sjeff* [in] Pointer to an osm_opensm_t object. 438219820Sjeff* 439219820Sjeff* wait_us 440219820Sjeff* [in] Number of microseconds to wait. 441219820Sjeff* 442219820Sjeff* interruptible 443219820Sjeff* [in] Indicates whether the wait operation can be interrupted 444219820Sjeff* by external signals. 445219820Sjeff* 446219820Sjeff* RETURN VALUES 447219820Sjeff* CL_SUCCESS if the wait operation succeeded in response to the event 448219820Sjeff* being set. 449219820Sjeff* 450219820Sjeff* CL_TIMEOUT if the specified time period elapses. 451219820Sjeff* 452219820Sjeff* CL_NOT_DONE if the wait was interrupted by an external signal. 453219820Sjeff* 454219820Sjeff* CL_ERROR if the wait operation failed. 455219820Sjeff* 456219820Sjeff* NOTES 457219820Sjeff* 458219820Sjeff* SEE ALSO 459219820Sjeff*********/ 460219820Sjeff 461219820Sjeff/****f* OpenSM: OpenSM/osm_routing_engine_type_str 462219820Sjeff* NAME 463219820Sjeff* osm_routing_engine_type_str 464219820Sjeff* 465219820Sjeff* DESCRIPTION 466219820Sjeff* Returns a string for the specified routing engine type. 467219820Sjeff* 468219820Sjeff* SYNOPSIS 469219820Sjeff*/ 470219820Sjeffconst char *osm_routing_engine_type_str(IN osm_routing_engine_type_t type); 471219820Sjeff/* 472219820Sjeff* PARAMETERS 473219820Sjeff* type 474219820Sjeff* [in] routing engine type. 475219820Sjeff* 476219820Sjeff* RETURN VALUES 477219820Sjeff* Pointer to routing engine name. 478219820Sjeff* 479219820Sjeff* NOTES 480219820Sjeff* 481219820Sjeff* SEE ALSO 482219820Sjeff*********/ 483219820Sjeff 484219820Sjeff/****f* OpenSM: OpenSM/osm_routing_engine_type 485219820Sjeff* NAME 486219820Sjeff* osm_routing_engine_type 487219820Sjeff* 488219820Sjeff* DESCRIPTION 489219820Sjeff* Returns a routing engine type specified routing engine name string. 490219820Sjeff* 491219820Sjeff* SYNOPSIS 492219820Sjeff*/ 493219820Sjeffosm_routing_engine_type_t osm_routing_engine_type(IN const char *str); 494219820Sjeff/* 495219820Sjeff* PARAMETERS 496219820Sjeff* str 497219820Sjeff* [in] routing engine name string. 498219820Sjeff* 499219820Sjeff* RETURN VALUES 500219820Sjeff* Routing engine type. 501219820Sjeff* 502219820Sjeff* NOTES 503219820Sjeff* 504219820Sjeff* SEE ALSO 505219820Sjeff*********/ 506219820Sjeff 507219820Sjeffvoid osm_opensm_report_event(osm_opensm_t *osm, osm_epi_event_id_t event_id, 508219820Sjeff void *event_data); 509219820Sjeff 510219820Sjeff/* dump helpers */ 511219820Sjeffvoid osm_dump_mcast_routes(osm_opensm_t * osm); 512219820Sjeffvoid osm_dump_all(osm_opensm_t * osm); 513219820Sjeffvoid osm_dump_qmap_to_file(osm_opensm_t * p_osm, const char *file_name, 514219820Sjeff cl_qmap_t * map, 515219820Sjeff void (*func) (cl_map_item_t *, FILE *, void *), 516219820Sjeff void *cxt); 517219820Sjeff 518219820Sjeff/****v* OpenSM/osm_exit_flag 519219820Sjeff*/ 520219820Sjeffextern volatile unsigned int osm_exit_flag; 521219820Sjeff/* 522219820Sjeff* DESCRIPTION 523219820Sjeff* Set to one to cause all threads to leave 524219820Sjeff*********/ 525219820Sjeff 526219820SjeffEND_C_DECLS 527219820Sjeff#endif /* _OSM_OPENSM_H_ */ 528