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 *    Implementation 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#if HAVE_CONFIG_H
44219820Sjeff#  include <config.h>
45219820Sjeff#endif				/* HAVE_CONFIG_H */
46219820Sjeff
47219820Sjeff#include <stdio.h>
48219820Sjeff#include <stdlib.h>
49219820Sjeff#include <string.h>
50219820Sjeff#include <complib/cl_dispatcher.h>
51219820Sjeff#include <complib/cl_passivelock.h>
52219820Sjeff#include <vendor/osm_vendor_api.h>
53219820Sjeff#include <opensm/osm_version.h>
54219820Sjeff#include <opensm/osm_base.h>
55219820Sjeff#include <opensm/osm_opensm.h>
56219820Sjeff#include <opensm/osm_log.h>
57219820Sjeff#include <opensm/osm_subnet.h>
58219820Sjeff#include <opensm/osm_sm.h>
59219820Sjeff#include <opensm/osm_vl15intf.h>
60219820Sjeff#include <opensm/osm_event_plugin.h>
61219820Sjeff
62219820Sjeffstruct routing_engine_module {
63219820Sjeff	const char *name;
64219820Sjeff	int (*setup) (struct osm_routing_engine *, osm_opensm_t *);
65219820Sjeff};
66219820Sjeff
67219820Sjeffextern int osm_ucast_minhop_setup(struct osm_routing_engine *, osm_opensm_t *);
68219820Sjeffextern int osm_ucast_updn_setup(struct osm_routing_engine *, osm_opensm_t *);
69219820Sjeffextern int osm_ucast_file_setup(struct osm_routing_engine *, osm_opensm_t *);
70219820Sjeffextern int osm_ucast_ftree_setup(struct osm_routing_engine *, osm_opensm_t *);
71219820Sjeffextern int osm_ucast_lash_setup(struct osm_routing_engine *, osm_opensm_t *);
72219820Sjeffextern int osm_ucast_dor_setup(struct osm_routing_engine *, osm_opensm_t *);
73219820Sjeff
74219820Sjeffconst static struct routing_engine_module routing_modules[] = {
75219820Sjeff	{"minhop", osm_ucast_minhop_setup},
76219820Sjeff	{"updn", osm_ucast_updn_setup},
77219820Sjeff	{"file", osm_ucast_file_setup},
78219820Sjeff	{"ftree", osm_ucast_ftree_setup},
79219820Sjeff	{"lash", osm_ucast_lash_setup},
80219820Sjeff	{"dor", osm_ucast_dor_setup},
81219820Sjeff	{NULL, NULL}
82219820Sjeff};
83219820Sjeff
84219820Sjeff/**********************************************************************
85219820Sjeff **********************************************************************/
86219820Sjeffconst char *osm_routing_engine_type_str(IN osm_routing_engine_type_t type)
87219820Sjeff{
88219820Sjeff	switch (type) {
89219820Sjeff	case OSM_ROUTING_ENGINE_TYPE_NONE:
90219820Sjeff		return "none";
91219820Sjeff	case OSM_ROUTING_ENGINE_TYPE_MINHOP:
92219820Sjeff		return "minhop";
93219820Sjeff	case OSM_ROUTING_ENGINE_TYPE_UPDN:
94219820Sjeff		return "updn";
95219820Sjeff	case OSM_ROUTING_ENGINE_TYPE_FILE:
96219820Sjeff		return "file";
97219820Sjeff	case OSM_ROUTING_ENGINE_TYPE_FTREE:
98219820Sjeff		return "ftree";
99219820Sjeff	case OSM_ROUTING_ENGINE_TYPE_LASH:
100219820Sjeff		return "lash";
101219820Sjeff	case OSM_ROUTING_ENGINE_TYPE_DOR:
102219820Sjeff		return "dor";
103219820Sjeff	default:
104219820Sjeff		break;
105219820Sjeff	}
106219820Sjeff	return "unknown";
107219820Sjeff}
108219820Sjeff
109219820Sjeff/**********************************************************************
110219820Sjeff **********************************************************************/
111219820Sjeffosm_routing_engine_type_t osm_routing_engine_type(IN const char *str)
112219820Sjeff{
113219820Sjeff	/* For legacy reasons, consider a NULL pointer and the string
114219820Sjeff	 * "null" as the minhop routing engine.
115219820Sjeff	 */
116219820Sjeff	if (!str || !strcasecmp(str, "null")
117219820Sjeff	    || !strcasecmp(str, "minhop"))
118219820Sjeff		return OSM_ROUTING_ENGINE_TYPE_MINHOP;
119219820Sjeff	else if (!strcasecmp(str, "none"))
120219820Sjeff		return OSM_ROUTING_ENGINE_TYPE_NONE;
121219820Sjeff	else if (!strcasecmp(str, "updn"))
122219820Sjeff		return OSM_ROUTING_ENGINE_TYPE_UPDN;
123219820Sjeff	else if (!strcasecmp(str, "file"))
124219820Sjeff		return OSM_ROUTING_ENGINE_TYPE_FILE;
125219820Sjeff	else if (!strcasecmp(str, "ftree"))
126219820Sjeff		return OSM_ROUTING_ENGINE_TYPE_FTREE;
127219820Sjeff	else if (!strcasecmp(str, "lash"))
128219820Sjeff		return OSM_ROUTING_ENGINE_TYPE_LASH;
129219820Sjeff	else if (!strcasecmp(str, "dor"))
130219820Sjeff		return OSM_ROUTING_ENGINE_TYPE_DOR;
131219820Sjeff	else
132219820Sjeff		return OSM_ROUTING_ENGINE_TYPE_UNKNOWN;
133219820Sjeff}
134219820Sjeff
135219820Sjeff/**********************************************************************
136219820Sjeff **********************************************************************/
137219820Sjeffstatic void append_routing_engine(osm_opensm_t *osm,
138219820Sjeff				  struct osm_routing_engine *routing_engine)
139219820Sjeff{
140219820Sjeff	struct osm_routing_engine *r;
141219820Sjeff
142219820Sjeff	routing_engine->next = NULL;
143219820Sjeff
144219820Sjeff	if (!osm->routing_engine_list) {
145219820Sjeff		osm->routing_engine_list = routing_engine;
146219820Sjeff		return;
147219820Sjeff	}
148219820Sjeff
149219820Sjeff	r = osm->routing_engine_list;
150219820Sjeff	while (r->next)
151219820Sjeff		r = r->next;
152219820Sjeff
153219820Sjeff	r->next = routing_engine;
154219820Sjeff}
155219820Sjeff
156219820Sjeffstatic void setup_routing_engine(osm_opensm_t *osm, const char *name)
157219820Sjeff{
158219820Sjeff	struct osm_routing_engine *re;
159219820Sjeff	const struct routing_engine_module *m;
160219820Sjeff
161219820Sjeff	for (m = routing_modules; m->name && *m->name; m++) {
162219820Sjeff		if (!strcmp(m->name, name)) {
163219820Sjeff			re = malloc(sizeof(struct osm_routing_engine));
164219820Sjeff			if (!re) {
165219820Sjeff				OSM_LOG(&osm->log, OSM_LOG_VERBOSE,
166219820Sjeff					"memory allocation failed\n");
167219820Sjeff				return;
168219820Sjeff			}
169219820Sjeff			memset(re, 0, sizeof(struct osm_routing_engine));
170219820Sjeff
171219820Sjeff			re->name = m->name;
172219820Sjeff			if (m->setup(re, osm)) {
173219820Sjeff				OSM_LOG(&osm->log, OSM_LOG_VERBOSE,
174219820Sjeff					"setup of routing"
175219820Sjeff					" engine \'%s\' failed\n", name);
176219820Sjeff				return;
177219820Sjeff			}
178219820Sjeff			OSM_LOG(&osm->log, OSM_LOG_DEBUG,
179219820Sjeff				"\'%s\' routing engine set up\n", re->name);
180219820Sjeff			append_routing_engine(osm, re);
181219820Sjeff			return;
182219820Sjeff		}
183219820Sjeff	}
184219820Sjeff
185219820Sjeff	OSM_LOG(&osm->log, OSM_LOG_ERROR,
186219820Sjeff		"cannot find or setup routing engine \'%s\'", name);
187219820Sjeff}
188219820Sjeff
189219820Sjeffstatic void setup_routing_engines(osm_opensm_t *osm, const char *engine_names)
190219820Sjeff{
191219820Sjeff	char *name, *str, *p;
192219820Sjeff
193219820Sjeff	if (!engine_names || !*engine_names) {
194219820Sjeff		setup_routing_engine(osm, "minhop");
195219820Sjeff		return;
196219820Sjeff	}
197219820Sjeff
198219820Sjeff	str = strdup(engine_names);
199219820Sjeff	name = strtok_r(str, ", \t\n", &p);
200219820Sjeff	while (name && *name) {
201219820Sjeff		setup_routing_engine(osm, name);
202219820Sjeff		name = strtok_r(NULL, ", \t\n", &p);
203219820Sjeff	}
204219820Sjeff	free(str);
205219820Sjeff
206219820Sjeff	if (!osm->routing_engine_list)
207219820Sjeff		setup_routing_engine(osm, "minhop");
208219820Sjeff}
209219820Sjeff
210219820Sjeff/**********************************************************************
211219820Sjeff **********************************************************************/
212219820Sjeffvoid osm_opensm_construct(IN osm_opensm_t * const p_osm)
213219820Sjeff{
214219820Sjeff	memset(p_osm, 0, sizeof(*p_osm));
215219820Sjeff	p_osm->osm_version = OSM_VERSION;
216219820Sjeff	osm_subn_construct(&p_osm->subn);
217219820Sjeff	osm_sm_construct(&p_osm->sm);
218219820Sjeff	osm_sa_construct(&p_osm->sa);
219219820Sjeff	osm_db_construct(&p_osm->db);
220219820Sjeff	osm_mad_pool_construct(&p_osm->mad_pool);
221219820Sjeff	osm_vl15_construct(&p_osm->vl15);
222219820Sjeff	osm_log_construct(&p_osm->log);
223219820Sjeff}
224219820Sjeff
225219820Sjeff/**********************************************************************
226219820Sjeff **********************************************************************/
227219820Sjeffstatic void destroy_routing_engines(osm_opensm_t *osm)
228219820Sjeff{
229219820Sjeff	struct osm_routing_engine *r, *next;
230219820Sjeff
231219820Sjeff	next = osm->routing_engine_list;
232219820Sjeff	while (next) {
233219820Sjeff		r = next;
234219820Sjeff		next = r->next;
235219820Sjeff		if (r->delete)
236219820Sjeff			r->delete(r->context);
237219820Sjeff		free(r);
238219820Sjeff	}
239219820Sjeff}
240219820Sjeff
241219820Sjeff/**********************************************************************
242219820Sjeff **********************************************************************/
243219820Sjeffstatic void destroy_plugins(osm_opensm_t *osm)
244219820Sjeff{
245219820Sjeff	osm_epi_plugin_t *p;
246219820Sjeff	/* remove from the list, and destroy it */
247219820Sjeff	while (!cl_is_qlist_empty(&osm->plugin_list)){
248219820Sjeff		p = (osm_epi_plugin_t *)cl_qlist_remove_head(&osm->plugin_list);
249219820Sjeff		/* plugin is responsible for freeing its own resources */
250219820Sjeff		osm_epi_destroy(p);
251219820Sjeff	}
252219820Sjeff}
253219820Sjeff
254219820Sjeffvoid osm_opensm_destroy(IN osm_opensm_t * const p_osm)
255219820Sjeff{
256219820Sjeff	/* in case of shutdown through exit proc - no ^C */
257219820Sjeff	osm_exit_flag = TRUE;
258219820Sjeff
259219820Sjeff	/*
260219820Sjeff	 * First of all, clear the is_sm bit.
261219820Sjeff	 */
262219820Sjeff	if (p_osm->sm.mad_ctrl.h_bind)
263219820Sjeff		osm_vendor_set_sm(p_osm->sm.mad_ctrl.h_bind, FALSE);
264219820Sjeff
265219820Sjeff#ifdef ENABLE_OSM_PERF_MGR
266219820Sjeff	/* Shutdown the PerfMgr */
267219820Sjeff	osm_perfmgr_shutdown(&p_osm->perfmgr);
268219820Sjeff#endif				/* ENABLE_OSM_PERF_MGR */
269219820Sjeff
270219820Sjeff	/* shut down the SA
271219820Sjeff	 * - unbind from QP1 messages
272219820Sjeff	 */
273219820Sjeff	osm_sa_shutdown(&p_osm->sa);
274219820Sjeff
275219820Sjeff	/* shut down the SM
276219820Sjeff	 * - make sure the SM sweeper thread exited
277219820Sjeff	 * - unbind from QP0 messages
278219820Sjeff	 */
279219820Sjeff	osm_sm_shutdown(&p_osm->sm);
280219820Sjeff
281219820Sjeff	/* cleanup all messages on VL15 fifo that were not sent yet */
282219820Sjeff	osm_vl15_shutdown(&p_osm->vl15, &p_osm->mad_pool);
283219820Sjeff
284219820Sjeff	/* shut down the dispatcher - so no new messages cross */
285219820Sjeff	cl_disp_shutdown(&p_osm->disp);
286219820Sjeff
287219820Sjeff	/* dump SA DB */
288219820Sjeff	osm_sa_db_file_dump(p_osm);
289219820Sjeff
290219820Sjeff	/* do the destruction in reverse order as init */
291219820Sjeff	destroy_plugins(p_osm);
292219820Sjeff	destroy_routing_engines(p_osm);
293219820Sjeff	osm_sa_destroy(&p_osm->sa);
294219820Sjeff	osm_sm_destroy(&p_osm->sm);
295219820Sjeff#ifdef ENABLE_OSM_PERF_MGR
296219820Sjeff	osm_perfmgr_destroy(&p_osm->perfmgr);
297219820Sjeff#endif				/* ENABLE_OSM_PERF_MGR */
298219820Sjeff	osm_db_destroy(&p_osm->db);
299219820Sjeff	osm_vl15_destroy(&p_osm->vl15, &p_osm->mad_pool);
300219820Sjeff	osm_mad_pool_destroy(&p_osm->mad_pool);
301219820Sjeff	osm_vendor_delete(&p_osm->p_vendor);
302219820Sjeff	osm_subn_destroy(&p_osm->subn);
303219820Sjeff	cl_disp_destroy(&p_osm->disp);
304219820Sjeff#ifdef HAVE_LIBPTHREAD
305219820Sjeff	pthread_cond_destroy(&p_osm->stats.cond);
306219820Sjeff	pthread_mutex_destroy(&p_osm->stats.mutex);
307219820Sjeff#else
308219820Sjeff	cl_event_destroy(&p_osm->stats.event);
309219820Sjeff#endif
310219820Sjeff	close_node_name_map(p_osm->node_name_map);
311219820Sjeff
312219820Sjeff	cl_plock_destroy(&p_osm->lock);
313219820Sjeff
314219820Sjeff	osm_log_destroy(&p_osm->log);
315219820Sjeff}
316219820Sjeff
317219820Sjeffstatic void load_plugins(osm_opensm_t *osm, const char *plugin_names)
318219820Sjeff{
319219820Sjeff	osm_epi_plugin_t *epi;
320219820Sjeff	char *p_names, *name, *p;
321219820Sjeff
322219820Sjeff	p_names = strdup(plugin_names);
323219820Sjeff	name = strtok_r(p_names, " \t\n", &p);
324219820Sjeff	while (name && *name) {
325219820Sjeff		epi = osm_epi_construct(osm, name);
326219820Sjeff		if (!epi)
327219820Sjeff			osm_log(&osm->log, OSM_LOG_ERROR,
328219820Sjeff				"cannot load plugin \'%s\'\n", name);
329219820Sjeff		else
330219820Sjeff			cl_qlist_insert_tail(&osm->plugin_list, &epi->list);
331219820Sjeff		name = strtok_r(NULL, " \t\n", &p);
332219820Sjeff	}
333219820Sjeff	free(p_names);
334219820Sjeff}
335219820Sjeff
336219820Sjeff/**********************************************************************
337219820Sjeff **********************************************************************/
338219820Sjeffib_api_status_t
339219820Sjeffosm_opensm_init(IN osm_opensm_t * const p_osm,
340219820Sjeff		IN const osm_subn_opt_t * const p_opt)
341219820Sjeff{
342219820Sjeff	ib_api_status_t status;
343219820Sjeff
344219820Sjeff	/* Can't use log macros here, since we're initializing the log */
345219820Sjeff	osm_opensm_construct(p_osm);
346219820Sjeff
347219820Sjeff	if (p_opt->daemon)
348219820Sjeff		p_osm->log.daemon = 1;
349219820Sjeff
350219820Sjeff	status = osm_log_init_v2(&p_osm->log, p_opt->force_log_flush,
351219820Sjeff				 p_opt->log_flags, p_opt->log_file,
352219820Sjeff				 p_opt->log_max_size, p_opt->accum_log_file);
353219820Sjeff	if (status != IB_SUCCESS)
354219820Sjeff		return (status);
355219820Sjeff
356219820Sjeff	/* If there is a log level defined - add the OSM_VERSION to it */
357219820Sjeff	osm_log(&p_osm->log,
358219820Sjeff		osm_log_get_level(&p_osm->log) & (OSM_LOG_SYS ^ 0xFF), "%s\n",
359219820Sjeff		p_osm->osm_version);
360219820Sjeff	/* Write the OSM_VERSION to the SYS_LOG */
361219820Sjeff	osm_log(&p_osm->log, OSM_LOG_SYS, "%s\n", p_osm->osm_version);	/* Format Waived */
362219820Sjeff
363219820Sjeff	OSM_LOG(&p_osm->log, OSM_LOG_FUNCS, "[\n");	/* Format Waived */
364219820Sjeff
365219820Sjeff	status = cl_plock_init(&p_osm->lock);
366219820Sjeff	if (status != IB_SUCCESS)
367219820Sjeff		goto Exit;
368219820Sjeff
369219820Sjeff#ifdef HAVE_LIBPTHREAD
370219820Sjeff	pthread_mutex_init(&p_osm->stats.mutex, NULL);
371219820Sjeff	pthread_cond_init(&p_osm->stats.cond, NULL);
372219820Sjeff#else
373219820Sjeff	status = cl_event_init(&p_osm->stats.event, FALSE);
374219820Sjeff	if (status != IB_SUCCESS)
375219820Sjeff		goto Exit;
376219820Sjeff#endif
377219820Sjeff
378219820Sjeff	if (p_opt->single_thread) {
379219820Sjeff		OSM_LOG(&p_osm->log, OSM_LOG_INFO,
380219820Sjeff			"Forcing single threaded dispatcher\n");
381219820Sjeff		status = cl_disp_init(&p_osm->disp, 1, "opensm");
382219820Sjeff	} else {
383219820Sjeff		/*
384219820Sjeff		 * Normal behavior is to initialize the dispatcher with
385219820Sjeff		 * one thread per CPU, as specified by a thread count of '0'.
386219820Sjeff		 */
387219820Sjeff		status = cl_disp_init(&p_osm->disp, 0, "opensm");
388219820Sjeff	}
389219820Sjeff	if (status != IB_SUCCESS)
390219820Sjeff		goto Exit;
391219820Sjeff
392219820Sjeff	status = osm_subn_init(&p_osm->subn, p_osm, p_opt);
393219820Sjeff	if (status != IB_SUCCESS)
394219820Sjeff		goto Exit;
395219820Sjeff
396219820Sjeff	p_osm->p_vendor =
397219820Sjeff	    osm_vendor_new(&p_osm->log, p_opt->transaction_timeout);
398219820Sjeff	if (p_osm->p_vendor == NULL) {
399219820Sjeff		status = IB_INSUFFICIENT_RESOURCES;
400219820Sjeff		goto Exit;
401219820Sjeff	}
402219820Sjeff
403219820Sjeff	status = osm_mad_pool_init(&p_osm->mad_pool);
404219820Sjeff	if (status != IB_SUCCESS)
405219820Sjeff		goto Exit;
406219820Sjeff
407219820Sjeff	status = osm_vl15_init(&p_osm->vl15, p_osm->p_vendor,
408219820Sjeff			       &p_osm->log, &p_osm->stats,
409219820Sjeff			       p_opt->max_wire_smps);
410219820Sjeff	if (status != IB_SUCCESS)
411219820Sjeff		goto Exit;
412219820Sjeff
413219820Sjeff	/* the DB is in use by the SM and SA so init before */
414219820Sjeff	status = osm_db_init(&p_osm->db, &p_osm->log);
415219820Sjeff	if (status != IB_SUCCESS)
416219820Sjeff		goto Exit;
417219820Sjeff
418219820Sjeff	status = osm_sm_init(&p_osm->sm, &p_osm->subn, &p_osm->db,
419219820Sjeff			     p_osm->p_vendor, &p_osm->mad_pool, &p_osm->vl15,
420219820Sjeff			     &p_osm->log, &p_osm->stats, &p_osm->disp,
421219820Sjeff			     &p_osm->lock);
422219820Sjeff
423219820Sjeff	if (status != IB_SUCCESS)
424219820Sjeff		goto Exit;
425219820Sjeff
426219820Sjeff	status = osm_sa_init(&p_osm->sm, &p_osm->sa, &p_osm->subn,
427219820Sjeff			     p_osm->p_vendor, &p_osm->mad_pool, &p_osm->log,
428219820Sjeff			     &p_osm->stats, &p_osm->disp, &p_osm->lock);
429219820Sjeff
430219820Sjeff	if (status != IB_SUCCESS)
431219820Sjeff		goto Exit;
432219820Sjeff
433219820Sjeff	cl_qlist_init(&p_osm->plugin_list);
434219820Sjeff
435219820Sjeff	if (p_opt->event_plugin_name)
436219820Sjeff		load_plugins(p_osm, p_opt->event_plugin_name);
437219820Sjeff
438219820Sjeff#ifdef ENABLE_OSM_PERF_MGR
439219820Sjeff	status = osm_perfmgr_init(&p_osm->perfmgr, p_osm, p_opt);
440219820Sjeff	if (status != IB_SUCCESS)
441219820Sjeff		goto Exit;
442219820Sjeff#endif				/* ENABLE_OSM_PERF_MGR */
443219820Sjeff
444219820Sjeff	setup_routing_engines(p_osm, p_opt->routing_engine_names);
445219820Sjeff
446219820Sjeff	p_osm->routing_engine_used = OSM_ROUTING_ENGINE_TYPE_NONE;
447219820Sjeff
448219820Sjeff	p_osm->node_name_map = open_node_name_map(p_opt->node_name_map_name);
449219820Sjeff
450219820SjeffExit:
451219820Sjeff	OSM_LOG(&p_osm->log, OSM_LOG_FUNCS, "]\n");	/* Format Waived */
452219820Sjeff	return (status);
453219820Sjeff}
454219820Sjeff
455219820Sjeff/**********************************************************************
456219820Sjeff **********************************************************************/
457219820Sjeffib_api_status_t
458219820Sjeffosm_opensm_bind(IN osm_opensm_t * const p_osm, IN const ib_net64_t guid)
459219820Sjeff{
460219820Sjeff	ib_api_status_t status;
461219820Sjeff
462219820Sjeff	OSM_LOG_ENTER(&p_osm->log);
463219820Sjeff
464219820Sjeff	status = osm_sm_bind(&p_osm->sm, guid);
465219820Sjeff	if (status != IB_SUCCESS)
466219820Sjeff		goto Exit;
467219820Sjeff
468219820Sjeff	status = osm_sa_bind(&p_osm->sa, guid);
469219820Sjeff	if (status != IB_SUCCESS)
470219820Sjeff		goto Exit;
471219820Sjeff
472219820Sjeff#ifdef ENABLE_OSM_PERF_MGR
473219820Sjeff	status = osm_perfmgr_bind(&p_osm->perfmgr, guid);
474219820Sjeff	if (status != IB_SUCCESS)
475219820Sjeff		goto Exit;
476219820Sjeff#endif				/* ENABLE_OSM_PERF_MGR */
477219820Sjeff
478219820SjeffExit:
479219820Sjeff	OSM_LOG_EXIT(&p_osm->log);
480219820Sjeff	return (status);
481219820Sjeff}
482219820Sjeff
483219820Sjeff/**********************************************************************
484219820Sjeff **********************************************************************/
485219820Sjeffvoid osm_opensm_report_event(osm_opensm_t *osm, osm_epi_event_id_t event_id,
486219820Sjeff			     void *event_data)
487219820Sjeff{
488219820Sjeff	cl_list_item_t *item;
489219820Sjeff
490219820Sjeff	for (item = cl_qlist_head(&osm->plugin_list);
491219820Sjeff	     item != cl_qlist_end(&osm->plugin_list);
492219820Sjeff	     item = cl_qlist_next(item)) {
493219820Sjeff		osm_epi_plugin_t *p = (osm_epi_plugin_t *)item;
494219820Sjeff		if (p->impl->report)
495219820Sjeff			p->impl->report(p->plugin_data, event_id, event_data);
496219820Sjeff	}
497219820Sjeff}
498