[ofa-general] ***SPAM*** Re: [PATCH v3 1/2] opensm: setup routing engine when in use and delete when fail
Eli Dorfman (Voltaire)
dorfman.eli at gmail.com
Thu Mar 19 06:37:56 PDT 2009
setup routing engine when in use and delete when fail
setup routing engine and allocate resources before use.
delete resources when routing algorithm fails.
this will save allocation for routing algorithms that are not used.
Signed-off-by: Eli Dorfman <elid at voltaire.com>
---
opensm/include/opensm/osm_opensm.h | 6 ++++++
opensm/opensm/osm_opensm.c | 10 ++--------
opensm/opensm/osm_ucast_mgr.c | 17 +++++++++++++++++
3 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/opensm/include/opensm/osm_opensm.h b/opensm/include/opensm/osm_opensm.h
index c121be4..8d1b276 100644
--- a/opensm/include/opensm/osm_opensm.h
+++ b/opensm/include/opensm/osm_opensm.h
@@ -109,6 +109,9 @@ typedef enum _osm_routing_engine_type {
} osm_routing_engine_type_t;
/***********/
+struct osm_routing_engine;
+struct osm_opensm;
+
/****s* OpenSM: OpenSM/osm_routing_engine
* NAME
* struct osm_routing_engine
@@ -122,6 +125,7 @@ typedef enum _osm_routing_engine_type {
struct osm_routing_engine {
const char *name;
void *context;
+ int (*setup) (struct osm_routing_engine *re, struct osm_opensm *p_osm);
int (*build_lid_matrices) (void *context);
int (*ucast_build_fwd_tables) (void *context);
void (*ucast_dump_tables) (void *context);
@@ -523,5 +527,7 @@ extern volatile unsigned int osm_exit_flag;
* Set to one to cause all threads to leave
*********/
+void osm_update_routing_engines(osm_opensm_t *osm, const char *engine_names);
+
END_C_DECLS
#endif /* _OSM_OPENSM_H_ */
diff --git a/opensm/opensm/osm_opensm.c b/opensm/opensm/osm_opensm.c
index 50d1349..9739122 100644
--- a/opensm/opensm/osm_opensm.c
+++ b/opensm/opensm/osm_opensm.c
@@ -169,14 +169,7 @@ static void setup_routing_engine(osm_opensm_t *osm, const char *name)
memset(re, 0, sizeof(struct osm_routing_engine));
re->name = m->name;
- if (m->setup(re, osm)) {
- OSM_LOG(&osm->log, OSM_LOG_VERBOSE,
- "setup of routing"
- " engine \'%s\' failed\n", name);
- return;
- }
- OSM_LOG(&osm->log, OSM_LOG_DEBUG,
- "\'%s\' routing engine set up\n", re->name);
+ re->setup = m->setup;
append_routing_engine(osm, re);
return;
}
@@ -236,6 +229,7 @@ static void destroy_routing_engines(osm_opensm_t *osm)
r->delete(r->context);
free(r);
}
+ osm->routing_engine_list = NULL;
}
/**********************************************************************
diff --git a/opensm/opensm/osm_ucast_mgr.c b/opensm/opensm/osm_ucast_mgr.c
index fe0a446..102ffc6 100644
--- a/opensm/opensm/osm_ucast_mgr.c
+++ b/opensm/opensm/osm_ucast_mgr.c
@@ -970,8 +970,25 @@ int osm_ucast_mgr_process(IN osm_ucast_mgr_t * const p_mgr)
p_osm->routing_engine_used = OSM_ROUTING_ENGINE_TYPE_NONE;
while (p_routing_eng) {
+ if (!p_routing_eng->context &&
+ p_routing_eng->setup(p_routing_eng, p_osm)) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR 3A0F: setup of routing engine \'%s\' failed\n",
+ p_routing_eng->name);
+ p_routing_eng = p_routing_eng->next;
+ continue;
+ }
+ OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
+ "\'%s\' routing engine set up\n", p_routing_eng->name);
+
if (!ucast_mgr_route(p_routing_eng, p_osm))
break;
+
+ /* delete unused routing engine */
+ if (p_routing_eng->delete)
+ p_routing_eng->delete(p_routing_eng->context);
+
+ p_routing_eng->context = NULL;
p_routing_eng = p_routing_eng->next;
}
--
1.5.5
More information about the general
mailing list