[openib-general] [PATCH 1/5] opensm: build_lid_matrices() routing engine method

Sasha Khapyorsky sashak at voltaire.com
Thu Oct 19 13:35:21 PDT 2006


This adds new method named build_lid_matrices() to OpenSM routing engine
structure. When defined this method will be used by ucast_mgr_process()
for switch min hop tables (aka lid matrices) preparation. In case of
failure default lid matrix creation algorithm will be used.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
 osm/include/opensm/osm_opensm.h |    4 +
 osm/opensm/osm_ucast_mgr.c      |  142 ++++++++++++++++++++++-----------------
 2 files changed, 84 insertions(+), 62 deletions(-)

diff --git a/osm/include/opensm/osm_opensm.h b/osm/include/opensm/osm_opensm.h
index 5557dbd..80e4ad7 100644
--- a/osm/include/opensm/osm_opensm.h
+++ b/osm/include/opensm/osm_opensm.h
@@ -104,6 +104,7 @@ BEGIN_C_DECLS
 struct osm_routing_engine {
 	const char *name;
 	void *context;
+	int (*build_lid_matrices)(void *context);
 	int (*ucast_build_fwd_tables)(void *context);
 	int (*ucast_fdb_assign)(void *context);
 	void (*delete)(void *context);
@@ -117,6 +118,9 @@ struct osm_routing_engine {
 *		The routing engine context. Will be passed as parameter
 *		to the callback functions.
 *
+*	build_lid_matrices
+*		The callback for lid matrices generation.
+*
 *	ucast_build_fwd_tables
 *		The callback for unicast forwarding table generation.
 *
diff --git a/osm/opensm/osm_ucast_mgr.c b/osm/opensm/osm_ucast_mgr.c
index 39d6899..2c5f1d1 100644
--- a/osm/opensm/osm_ucast_mgr.c
+++ b/osm/opensm/osm_ucast_mgr.c
@@ -1078,25 +1078,18 @@ __osm_ucast_mgr_process_neighbors(
 
 /**********************************************************************
  **********************************************************************/
-osm_signal_t
-osm_ucast_mgr_process(
+static void
+ucast_mgr_build_lid_matrices(
   IN osm_ucast_mgr_t* const p_mgr )
 {
   uint32_t i;
   uint32_t iteration_max;
-  struct osm_routing_engine *p_routing_eng;
-  osm_signal_t signal;
   cl_qmap_t *p_sw_guid_tbl;
 
-  OSM_LOG_ENTER( p_mgr->p_log, osm_ucast_mgr_process );
-
   p_sw_guid_tbl = &p_mgr->p_subn->sw_guid_tbl;
-  p_routing_eng = &p_mgr->p_subn->p_osm->routing_engine;
-
-  CL_PLOCK_EXCL_ACQUIRE( p_mgr->p_lock );
 
   osm_log(p_mgr->p_log, OSM_LOG_VERBOSE,
-          "osm_ucast_mgr_process: "
+          "ucast_mgr_build_lid_matrices: "
           "Starting switches Min Hop Table Assignment\n");
   
   /*
@@ -1126,7 +1119,7 @@ osm_ucast_mgr_process(
     Note that there may not be any switches in the subnet if
     we are in simple p2p configuration.
   */
-  iteration_max = cl_qmap_count( &p_mgr->p_subn->sw_guid_tbl );
+  iteration_max = cl_qmap_count( p_sw_guid_tbl );
 
   /*
     If there are switches in the subnet, iterate until the lid
@@ -1152,78 +1145,103 @@ osm_ucast_mgr_process(
                           __osm_ucast_mgr_process_neighbors, p_mgr );
     }
     osm_log( p_mgr->p_log, OSM_LOG_DEBUG,
-             "osm_ucast_mgr_process: "
-             "Min-hop propagated in %d steps\n",
-             i
-             );
+             "ucast_mgr_build_lid_matrices: "
+             "Min-hop propagated in %d steps\n", i );
+  }
+}
 
-    if (p_routing_eng->ucast_build_fwd_tables &&
-        p_routing_eng->ucast_build_fwd_tables(p_routing_eng->context) == 0)
-    {
-      cl_qmap_apply_func( p_sw_guid_tbl,
-                          __osm_ucast_mgr_set_table_cb, p_mgr );
-    } /* fallback on the regular path in case of failures */
-    else
-    {
-    /*
-      This is the place where we can load pre-defined routes
-      into the switches fwd_tbl structures.
+/**********************************************************************
+ **********************************************************************/
+osm_signal_t
+osm_ucast_mgr_process(
+  IN osm_ucast_mgr_t* const p_mgr )
+{
+  struct osm_routing_engine *p_routing_eng;
+  osm_signal_t signal = OSM_SIGNAL_DONE;
+  cl_qmap_t *p_sw_guid_tbl;
 
-      Later code will use these values if not configured for
-      reassignment.
-    */
-      if (p_routing_eng->ucast_fdb_assign)
-      {
-        if( osm_log_is_active( p_mgr->p_log, OSM_LOG_DEBUG ) )
-        {
-          osm_log( p_mgr->p_log, OSM_LOG_DEBUG,
-                   "osm_ucast_mgr_process: "
-                   "Invoking \'%s\' function ucast_fdb_assign\n",
-                   p_routing_eng->name );
-        }
+  OSM_LOG_ENTER( p_mgr->p_log, osm_ucast_mgr_process );
 
-        p_routing_eng->ucast_fdb_assign(p_routing_eng->context);
+  p_sw_guid_tbl = &p_mgr->p_subn->sw_guid_tbl;
+  p_routing_eng = &p_mgr->p_subn->p_osm->routing_engine;
 
-      }
-      else
+  CL_PLOCK_EXCL_ACQUIRE( p_mgr->p_lock );
+
+  /*
+    If there are no switches in the subnet, we are done.
+  */
+  if (cl_qmap_count( p_sw_guid_tbl ) == 0)
+    goto Exit;
+
+  if (!p_routing_eng->build_lid_matrices ||
+      p_routing_eng->build_lid_matrices(p_routing_eng->context) != 0)
+    ucast_mgr_build_lid_matrices(p_mgr);
+
+  if (p_routing_eng->ucast_build_fwd_tables &&
+      p_routing_eng->ucast_build_fwd_tables(p_routing_eng->context) == 0)
+  {
+    cl_qmap_apply_func( p_sw_guid_tbl,
+                        __osm_ucast_mgr_set_table_cb, p_mgr );
+  } /* fallback on the regular path in case of failures */
+  else
+  {
+  /*
+    This is the place where we can load pre-defined routes
+    into the switches fwd_tbl structures.
+
+    Later code will use these values if not configured for
+    reassignment.
+  */
+    if (p_routing_eng->ucast_fdb_assign)
+    {
+      if( osm_log_is_active( p_mgr->p_log, OSM_LOG_DEBUG ) )
       {
         osm_log( p_mgr->p_log, OSM_LOG_DEBUG,
                  "osm_ucast_mgr_process: "
-                 "UI pfn was not invoked\n" );
+                 "Invoking \'%s\' function ucast_fdb_assign\n",
+                 p_routing_eng->name );
       }
 
-      osm_log( p_mgr->p_log, OSM_LOG_INFO,
-               "osm_ucast_mgr_process: "
-               "Min Hop Tables configured on all switches\n" );
+      p_routing_eng->ucast_fdb_assign(p_routing_eng->context);
 
-      /*
-        Now that the lid matrices have been built, we can
-        build and download the switch forwarding tables.
-      */
-
-      cl_qmap_apply_func( p_sw_guid_tbl,
-                          __osm_ucast_mgr_process_tbl, p_mgr );
+    }
+    else
+    {
+      osm_log( p_mgr->p_log, OSM_LOG_DEBUG,
+               "osm_ucast_mgr_process: "
+               "UI pfn was not invoked\n" );
     }
 
-    /* dump fdb into file: */
-    if ( osm_log_is_active( p_mgr->p_log, OSM_LOG_ROUTING ) )
-      __osm_ucast_mgr_dump_tables( p_mgr );
+    osm_log( p_mgr->p_log, OSM_LOG_INFO,
+             "osm_ucast_mgr_process: "
+             "Min Hop Tables configured on all switches\n" );
 
     /*
-      For now don't bother checking if the switch forwarding tables
-      actually needed updating.  The current code will always update
-      them, and thus leave transactions pending on the wire.
-      Therefore, return OSM_SIGNAL_DONE_PENDING.
+      Now that the lid matrices have been built, we can
+      build and download the switch forwarding tables.
     */
-    signal = OSM_SIGNAL_DONE_PENDING;
+
+    cl_qmap_apply_func( p_sw_guid_tbl,
+                        __osm_ucast_mgr_process_tbl, p_mgr );
   }
-  else
-    signal = OSM_SIGNAL_DONE;
+
+  /* dump fdb into file: */
+  if ( osm_log_is_active( p_mgr->p_log, OSM_LOG_ROUTING ) )
+    __osm_ucast_mgr_dump_tables( p_mgr );
+
+  /*
+    For now don't bother checking if the switch forwarding tables
+    actually needed updating.  The current code will always update
+    them, and thus leave transactions pending on the wire.
+    Therefore, return OSM_SIGNAL_DONE_PENDING.
+  */
+  signal = OSM_SIGNAL_DONE_PENDING;
 
   osm_log(p_mgr->p_log, OSM_LOG_VERBOSE,
           "osm_ucast_mgr_process: "
           "LFT Tables configured on all switches\n");
 
+ Exit:
   CL_PLOCK_RELEASE( p_mgr->p_lock );
   OSM_LOG_EXIT( p_mgr->p_log );
   return( signal );
-- 
1.4.3.g7768





More information about the general mailing list