[ofa-general] [PATCH 2/2] opensm routing engine update

Eli Dorfman (Voltaire) dorfman.eli at gmail.com
Thu Feb 26 07:49:02 PST 2009


 support routing engine update.
 save active routing engine list as prev routing engine list.
 this is used to cleanup used routing engine allocation if needed
 and only after new routing engine was configured.

Signed-off-by: Eli Dorfman <elid at voltaire.com>
---
 opensm/opensm/osm_opensm.c    |    9 +++++++++
 opensm/opensm/osm_subnet.c    |   10 +++++++++-
 opensm/opensm/osm_ucast_mgr.c |   22 +++++++++++++++++++++-
 3 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/opensm/opensm/osm_opensm.c b/opensm/opensm/osm_opensm.c
index a2620d5..6ab28be 100644
--- a/opensm/opensm/osm_opensm.c
+++ b/opensm/opensm/osm_opensm.c
@@ -230,6 +230,15 @@ static void destroy_routing_engines(struct osm_routing_engine **re)
 	*re = NULL;
 }
 
+void update_routing_engines(osm_opensm_t *osm, const char *engine_names)
+{
+	/* cleanup prev routing engine list and replace with current list */
+	destroy_routing_engines(&osm->prev_routing_engine_list);
+	osm->prev_routing_engine_list = osm->routing_engine_list;
+	osm->routing_engine_list = NULL;
+	setup_routing_engines(osm, engine_names);
+}
+
 /**********************************************************************
  **********************************************************************/
 static void destroy_plugins(osm_opensm_t *osm)
diff --git a/opensm/opensm/osm_subnet.c b/opensm/opensm/osm_subnet.c
index b3100a4..1ba5c91 100644
--- a/opensm/opensm/osm_subnet.c
+++ b/opensm/opensm/osm_subnet.c
@@ -151,6 +151,14 @@ static void opts_setup_sm_priority(osm_subn_t *p_subn, void *p_val)
 	osm_set_sm_priority(p_sm, sm_priority);
 }
 
+static void opts_setup_routing_engine(osm_subn_t *p_subn, void *p_val)
+{
+	osm_opensm_t *p_osm = p_subn->p_osm;
+	char *engines = (char *) p_val;
+
+	update_routing_engines(p_osm, engines);
+}
+
 static void opts_parse_net64(IN osm_subn_t *p_subn, IN char *p_key,
 			     IN char *p_val_str, void *p_v1, void *p_v2,
 			     void (*pfn)(osm_subn_t *, void *))
@@ -324,7 +332,7 @@ static const opt_rec_t opt_tbl[] = {
 	{ "port_prof_ignore_file", OPT_OFFSET(port_prof_ignore_file), opts_parse_charp, NULL, 0 },
 	{ "port_profile_switch_nodes", OPT_OFFSET(port_profile_switch_nodes), opts_parse_boolean, NULL, 1 },
 	{ "sweep_on_trap", OPT_OFFSET(sweep_on_trap), opts_parse_boolean, NULL, 1 },
-	{ "routing_engine", OPT_OFFSET(routing_engine_names), opts_parse_charp, NULL, 0 },
+	{ "routing_engine", OPT_OFFSET(routing_engine_names), opts_parse_charp, opts_setup_routing_engine, 1 },
 	{ "connect_roots", OPT_OFFSET(connect_roots), opts_parse_boolean, NULL, 1 },
 	{ "use_ucast_cache", OPT_OFFSET(use_ucast_cache), opts_parse_boolean, NULL, 1 },
 	{ "log_file", OPT_OFFSET(log_file), opts_parse_charp, NULL, 0 },
diff --git a/opensm/opensm/osm_ucast_mgr.c b/opensm/opensm/osm_ucast_mgr.c
index 7175926..cda9f34 100644
--- a/opensm/opensm/osm_ucast_mgr.c
+++ b/opensm/opensm/osm_ucast_mgr.c
@@ -879,7 +879,7 @@ static int ucast_mgr_route(struct osm_routing_engine *r, osm_opensm_t *osm)
 int osm_ucast_mgr_process(IN osm_ucast_mgr_t * const p_mgr)
 {
 	osm_opensm_t *p_osm;
-	struct osm_routing_engine *p_routing_eng;
+	struct osm_routing_engine *p_routing_eng, *r;
 	cl_qmap_t *p_sw_guid_tbl;
 
 	OSM_LOG_ENTER(p_mgr->p_log);
@@ -896,6 +896,26 @@ int osm_ucast_mgr_process(IN osm_ucast_mgr_t * const p_mgr)
 	    ucast_mgr_setup_all_switches(p_mgr->p_subn) < 0)
 		goto Exit;
 
+	/* find used routing engine in previous list */
+	r = p_osm->prev_routing_engine_list;
+	while (r) {
+		if (p_osm->routing_engine_used == 
+			osm_routing_engine_type(r->name))
+		{
+			p_routing_eng = p_osm->routing_engine_list;
+			while (p_routing_eng) {
+				if (p_osm->routing_engine_used == 
+					osm_routing_engine_type(p_routing_eng->name)) {
+					memcpy(p_routing_eng, r, sizeof(*p_routing_eng));
+					break;
+				}
+				p_routing_eng = p_routing_eng->next;
+			}
+			break;
+		}
+		r = r->next;
+	}
+
 	/* update the entry in active list */
 
 	p_osm->routing_engine_used = OSM_ROUTING_ENGINE_TYPE_NONE;
-- 
1.5.5




More information about the general mailing list