[ofa-general] [PATCH] opensm: support for multiple event plugins

Sasha Khapyorsky sashak at voltaire.com
Sat Jun 14 05:57:37 PDT 2008


More than one event plugin can be passed to OpenSM via config file as
space separated list:

  event_plugin  name1 name2 name3

Each name will be resolved as usual - lib<nameX>.so.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---

Ira, I didn't check this with opensmskumme plugin, but guess it should
not be affected.

 opensm/include/opensm/osm_event_plugin.h |    4 ++-
 opensm/include/opensm/osm_opensm.h       |    4 +-
 opensm/opensm/osm_console.c              |   13 ++++++++---
 opensm/opensm/osm_opensm.c               |   34 +++++++++++++++++++++++++----
 4 files changed, 43 insertions(+), 12 deletions(-)

diff --git a/opensm/include/opensm/osm_event_plugin.h b/opensm/include/opensm/osm_event_plugin.h
index a7cad32..7467694 100644
--- a/opensm/include/opensm/osm_event_plugin.h
+++ b/opensm/include/opensm/osm_event_plugin.h
@@ -35,8 +35,9 @@
 #define _OSM_EVENT_PLUGIN_H_
 
 #include <time.h>
-#include <opensm/osm_log.h>
 #include <iba/ib_types.h>
+#include <complib/cl_qlist.h>
+#include <opensm/osm_log.h>
 
 #ifdef __cplusplus
 #  define BEGIN_C_DECLS extern "C" {
@@ -161,6 +162,7 @@ typedef struct osm_event_plugin {
  * The plugin structure should be considered opaque
  */
 typedef struct osm_epi_plugin {
+	cl_list_item_t list;
 	void *handle;
 	osm_event_plugin_t *impl;
 	void *plugin_data;
diff --git a/opensm/include/opensm/osm_opensm.h b/opensm/include/opensm/osm_opensm.h
index 63d2247..1b758bd 100644
--- a/opensm/include/opensm/osm_opensm.h
+++ b/opensm/include/opensm/osm_opensm.h
@@ -44,6 +44,7 @@
 #define _OSM_OPENSM_H_
 
 #include <stdio.h>
+#include <complib/cl_qlist.h>
 #include <complib/cl_dispatcher.h>
 #include <complib/cl_passivelock.h>
 #include <complib/cl_atomic.h>
@@ -54,7 +55,6 @@
 #include <opensm/osm_sm.h>
 #include <opensm/osm_sa.h>
 #include <opensm/osm_perfmgr.h>
-#include <opensm/osm_event_plugin.h>
 #include <opensm/osm_db.h>
 #include <opensm/osm_subnet.h>
 #include <opensm/osm_mad_pool.h>
@@ -168,7 +168,7 @@ typedef struct _osm_opensm_t {
 #ifdef ENABLE_OSM_PERF_MGR
 	osm_perfmgr_t perfmgr;
 #endif				/* ENABLE_OSM_PERF_MGR */
-	osm_epi_plugin_t *event_plugin;
+	cl_qlist_t plugin_list;
 	osm_db_t db;
 	osm_mad_pool_t mad_pool;
 	osm_vendor_t *p_vendor;
diff --git a/opensm/opensm/osm_console.c b/opensm/opensm/osm_console.c
index f74465e..ca4982f 100644
--- a/opensm/opensm/osm_console.c
+++ b/opensm/opensm/osm_console.c
@@ -1110,19 +1110,24 @@ static void perfmgr_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
 			fprintf(out, "\"%s\" option not found\n", p_cmd);
 		}
 	} else {
+		cl_list_item_t *item;
 		fprintf(out, "Performance Manager status:\n"
 			"state                   : %s\n"
 			"sweep state             : %s\n"
 			"sweep time              : %us\n"
 			"outstanding queries/max : %d/%u\n"
-			"loaded event plugin     : %s\n",
+			"loaded event plugin     :",
 			osm_perfmgr_get_state_str(&(p_osm->perfmgr)),
 			osm_perfmgr_get_sweep_state_str(&(p_osm->perfmgr)),
 			osm_perfmgr_get_sweep_time_s(&(p_osm->perfmgr)),
 			p_osm->perfmgr.outstanding_queries,
-			p_osm->perfmgr.max_outstanding_queries,
-			p_osm->event_plugin ?
-			p_osm->event_plugin->plugin_name : "NONE");
+			p_osm->perfmgr.max_outstanding_queries);
+		for (item = cl_qlist_head(&p_osm->plugin_list);
+		     item != cl_qlist_end(&p_osm->plugin_list);
+		     item = cl_qlist_next(item))
+			fprintf(out, " %s",
+				((osm_epi_plugin_t *)item)->plugin_name);
+		fprintf(out, "\n");
 	}
 }
 #endif				/* ENABLE_OSM_PERF_MGR */
diff --git a/opensm/opensm/osm_opensm.c b/opensm/opensm/osm_opensm.c
index a85bcb7..a1d4aa9 100644
--- a/opensm/opensm/osm_opensm.c
+++ b/opensm/opensm/osm_opensm.c
@@ -243,6 +243,23 @@ void osm_opensm_destroy(IN osm_opensm_t * const p_osm)
 	osm_log_destroy(&p_osm->log);
 }
 
+static void load_plugins(osm_opensm_t *osm, char *plugin_names)
+{
+	osm_epi_plugin_t *epi;
+	char *name, *p;
+
+	name = strtok_r(plugin_names, " \t\n", &p);
+	while (name && *name) {
+		epi = osm_epi_construct(&osm->log, name);
+		if (!epi)
+			osm_log(&osm->log, OSM_LOG_ERROR,
+				"cannot load plugin \'%s\'\n", name);
+		else
+			cl_qlist_insert_tail(&osm->plugin_list, &epi->list);
+		name = strtok_r(NULL, " \t\n", &p);
+	}
+}
+
 /**********************************************************************
  **********************************************************************/
 ib_api_status_t
@@ -348,8 +365,9 @@ osm_opensm_init(IN osm_opensm_t * const p_osm,
 	if (status != IB_SUCCESS)
 		goto Exit;
 
-	p_osm->event_plugin = osm_epi_construct(&p_osm->log,
-						p_opt->event_plugin_name);
+	cl_qlist_init(&p_osm->plugin_list);
+
+	load_plugins(p_osm, p_opt->event_plugin_name);
 
 #ifdef ENABLE_OSM_PERF_MGR
 	status = osm_perfmgr_init(&p_osm->perfmgr, p_osm, p_opt);
@@ -406,7 +424,13 @@ Exit:
 void osm_opensm_report_event(osm_opensm_t *osm, osm_epi_event_id_t event_id,
 			     void *event_data)
 {
-	if (osm->event_plugin && osm->event_plugin->impl->report)
-		osm->event_plugin->impl->report(osm->event_plugin->plugin_data,
-						event_id, event_data);
+	cl_list_item_t *item;
+
+	for (item = cl_qlist_head(&osm->plugin_list);
+	     item != cl_qlist_end(&osm->plugin_list);
+	     item = cl_qlist_next(item)) {
+		osm_epi_plugin_t *p = (osm_epi_plugin_t *)item;
+		if (p->impl->report)
+			p->impl->report(p->plugin_data, event_id, event_data);
+	}
 }
-- 
1.5.5.1.178.g1f811




More information about the general mailing list