2 * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
3 * Copyright (c) 2002-2006 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 osm_opensm_t.
39 * This object represents the OpenSM super object.
40 * This object is part of the OpenSM family of objects.
43 #ifndef _OSM_OPENSM_H_
44 #define _OSM_OPENSM_H_
47 #include <complib/cl_qlist.h>
48 #include <complib/cl_dispatcher.h>
49 #include <complib/cl_passivelock.h>
50 #include <complib/cl_atomic.h>
51 #include <complib/cl_nodenamemap.h>
52 #include <opensm/osm_console_io.h>
53 #include <opensm/osm_stats.h>
54 #include <opensm/osm_log.h>
55 #include <opensm/osm_sm.h>
56 #include <opensm/osm_sa.h>
57 #include <opensm/osm_perfmgr.h>
58 #include <opensm/osm_event_plugin.h>
59 #include <opensm/osm_db.h>
60 #include <opensm/osm_subnet.h>
61 #include <opensm/osm_mad_pool.h>
62 #include <opensm/osm_vl15intf.h>
65 # define BEGIN_C_DECLS extern "C" {
66 # define END_C_DECLS }
67 #else /* !__cplusplus */
68 # define BEGIN_C_DECLS
70 #endif /* __cplusplus */
78 * The OpenSM object encapsulates the information needed by the
79 * OpenSM to govern itself. The OpenSM is one OpenSM object.
81 * The OpenSM object is thread safe.
83 * This object should be treated as opaque and should
84 * be manipulated only through the provided functions.
90 /****d* OpenSM: OpenSM/osm_routing_engine_type_t
92 * osm_routing_engine_type_t
95 * Enumerates the possible routing engines that
96 * could be used to route a subnet.
100 typedef enum _osm_routing_engine_type {
101 OSM_ROUTING_ENGINE_TYPE_NONE = 0,
102 OSM_ROUTING_ENGINE_TYPE_MINHOP,
103 OSM_ROUTING_ENGINE_TYPE_UPDN,
104 OSM_ROUTING_ENGINE_TYPE_FILE,
105 OSM_ROUTING_ENGINE_TYPE_FTREE,
106 OSM_ROUTING_ENGINE_TYPE_LASH,
107 OSM_ROUTING_ENGINE_TYPE_DOR,
108 OSM_ROUTING_ENGINE_TYPE_UNKNOWN
109 } osm_routing_engine_type_t;
112 /****s* OpenSM: OpenSM/osm_routing_engine
114 * struct osm_routing_engine
117 * OpenSM routing engine module definition.
119 * routing engine structure - multicast callbacks may be
122 struct osm_routing_engine {
125 int (*build_lid_matrices) (void *context);
126 int (*ucast_build_fwd_tables) (void *context);
127 void (*ucast_dump_tables) (void *context);
128 void (*delete) (void *context);
129 struct osm_routing_engine *next;
134 * The routing engine name (will be used in logs).
137 * The routing engine context. Will be passed as parameter
138 * to the callback functions.
141 * The callback for lid matrices generation.
143 * ucast_build_fwd_tables
144 * The callback for unicast forwarding table generation.
147 * The callback for dumping unicast routing tables.
150 * The delete method, may be used for routing engine
154 * Pointer to next routing engine in the list.
157 /****s* OpenSM: OpenSM/osm_opensm_t
164 * This object should be treated as opaque and should
165 * be manipulated only through the provided functions.
169 typedef struct osm_opensm {
170 const char *osm_version;
174 #ifdef ENABLE_OSM_PERF_MGR
175 osm_perfmgr_t perfmgr;
176 #endif /* ENABLE_OSM_PERF_MGR */
177 cl_qlist_t plugin_list;
179 osm_mad_pool_t mad_pool;
180 osm_vendor_t *p_vendor;
183 cl_dispatcher_t disp;
185 struct osm_routing_engine *routing_engine_list;
186 osm_routing_engine_type_t routing_engine_used;
188 osm_console_t console;
189 nn_map_t *node_name_map;
194 * OpenSM version (as generated in osm_version.h)
197 * Subnet object for this subnet.
200 * The Subnet Manager (SM) object for this subnet.
203 * The Subnet Administration (SA) object for this subnet.
206 * Persistant storage of some data required between sessions.
209 * Pool of Management Datagram (MAD) objects.
212 * Pointer to the Vendor specific adapter for various
213 * transport interfaces, such as UMADT, AL, etc. The
214 * particular interface is set at compile time.
217 * The VL15 interface.
220 * Log facility used by all OpenSM components.
223 * Central dispatcher containing the OpenSM worker threads.
226 * Shared lock guarding most OpenSM structures.
228 * routing_engine_list
229 * List of routing engines that should be tried for use.
231 * routing_engine_used
232 * Indicates which routing engine was used to route a subnet.
235 * Open SM statistics block
240 /****f* OpenSM: OpenSM/osm_opensm_construct
242 * osm_opensm_construct
245 * This function constructs an OpenSM object.
249 void osm_opensm_construct(IN osm_opensm_t * const p_osm);
253 * [in] Pointer to a OpenSM object to construct.
256 * This function does not return a value.
259 * Allows calling osm_opensm_init, osm_opensm_destroy
261 * Calling osm_opensm_construct is a prerequisite to calling any other
262 * method except osm_opensm_init.
265 * SM object, osm_opensm_init, osm_opensm_destroy
268 /****f* OpenSM: OpenSM/osm_opensm_destroy
273 * The osm_opensm_destroy function destroys an SM, releasing
278 void osm_opensm_destroy(IN osm_opensm_t * const p_osm);
282 * [in] Pointer to a OpenSM object to destroy.
285 * This function does not return a value.
288 * Performs any necessary cleanup of the specified OpenSM object.
289 * Further operations should not be attempted on the destroyed object.
290 * This function should only be called after a call to osm_opensm_construct or
294 * SM object, osm_opensm_construct, osm_opensm_init
297 /****f* OpenSM: OpenSM/osm_opensm_init
302 * The osm_opensm_init function initializes a OpenSM object for use.
307 osm_opensm_init(IN osm_opensm_t * const p_osm,
308 IN const osm_subn_opt_t * const p_opt);
312 * [in] Pointer to an osm_opensm_t object to initialize.
315 * [in] Pointer to the subnet options structure.
318 * IB_SUCCESS if the OpenSM object was initialized successfully.
321 * Allows calling other OpenSM methods.
324 * SM object, osm_opensm_construct, osm_opensm_destroy
327 /****f* OpenSM: OpenSM/osm_opensm_sweep
332 * Initiates a subnet sweep.
336 static inline void osm_opensm_sweep(IN osm_opensm_t * const p_osm)
338 osm_sm_sweep(&p_osm->sm);
344 * [in] Pointer to an osm_opensm_t object on which to
351 * If the OpenSM object is not bound to a port, this function
357 /****f* OpenSM: OpenSM/osm_opensm_set_log_flags
359 * osm_opensm_set_log_flags
362 * Sets the log level.
367 osm_opensm_set_log_flags(IN osm_opensm_t * const p_osm,
368 IN const osm_log_level_t log_flags)
370 osm_log_set_level(&p_osm->log, log_flags);
376 * [in] Pointer to an osm_opensm_t object.
379 * [in] Log level flags to set.
389 /****f* OpenSM: OpenSM/osm_opensm_bind
394 * Binds the opensm object to a port guid.
399 osm_opensm_bind(IN osm_opensm_t * const p_osm, IN const ib_net64_t guid);
403 * [in] Pointer to an osm_opensm_t object to bind.
406 * [in] Local port GUID with which to bind.
412 * A given opensm object can only be bound to one port at a time.
417 /****f* OpenSM: OpenSM/osm_opensm_wait_for_subnet_up
419 * osm_opensm_wait_for_subnet_up
422 * Blocks the calling thread until the subnet is up.
426 static inline cl_status_t
427 osm_opensm_wait_for_subnet_up(IN osm_opensm_t * const p_osm,
428 IN uint32_t const wait_us,
429 IN boolean_t const interruptible)
431 return (osm_sm_wait_for_subnet_up(&p_osm->sm, wait_us, interruptible));
437 * [in] Pointer to an osm_opensm_t object.
440 * [in] Number of microseconds to wait.
443 * [in] Indicates whether the wait operation can be interrupted
444 * by external signals.
447 * CL_SUCCESS if the wait operation succeeded in response to the event
450 * CL_TIMEOUT if the specified time period elapses.
452 * CL_NOT_DONE if the wait was interrupted by an external signal.
454 * CL_ERROR if the wait operation failed.
461 /****f* OpenSM: OpenSM/osm_routing_engine_type_str
463 * osm_routing_engine_type_str
466 * Returns a string for the specified routing engine type.
470 const char *osm_routing_engine_type_str(IN osm_routing_engine_type_t type);
474 * [in] routing engine type.
477 * Pointer to routing engine name.
484 /****f* OpenSM: OpenSM/osm_routing_engine_type
486 * osm_routing_engine_type
489 * Returns a routing engine type specified routing engine name string.
493 osm_routing_engine_type_t osm_routing_engine_type(IN const char *str);
497 * [in] routing engine name string.
500 * Routing engine type.
507 void osm_opensm_report_event(osm_opensm_t *osm, osm_epi_event_id_t event_id,
511 void osm_dump_mcast_routes(osm_opensm_t * osm);
512 void osm_dump_all(osm_opensm_t * osm);
513 void osm_dump_qmap_to_file(osm_opensm_t * p_osm, const char *file_name,
515 void (*func) (cl_map_item_t *, FILE *, void *),
518 /****v* OpenSM/osm_exit_flag
520 extern volatile unsigned int osm_exit_flag;
523 * Set to one to cause all threads to leave
527 #endif /* _OSM_OPENSM_H_ */