[openib-general] [PATCH 5/5] opensm: updates file and up/down routing engines

Sasha Khapyorsky sashak at voltaire.com
Sun Nov 26 14:30:04 PST 2006


This updates "file" and "updn" (up/down) routing engines which should
work properly now with changed LFT setup mechanism.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
 osm/include/opensm/osm_switch.h    |   41 --------------------------
 osm/include/opensm/osm_ucast_mgr.h |   26 ++++++++++++++++
 osm/opensm/osm_ucast_file.c        |   32 ++++++--------------
 osm/opensm/osm_ucast_mgr.c         |   57 ++++++++++++++---------------------
 osm/opensm/osm_ucast_updn.c        |    8 +----
 5 files changed, 60 insertions(+), 104 deletions(-)

diff --git a/osm/include/opensm/osm_switch.h b/osm/include/opensm/osm_switch.h
index 4c8e1aa..386c857 100644
--- a/osm/include/opensm/osm_switch.h
+++ b/osm/include/opensm/osm_switch.h
@@ -937,47 +937,6 @@ osm_switch_set_switch_info(
 * SEE ALSO
 *********/
 
-/****f* OpenSM: Switch/osm_switch_set_path
-* NAME
-*	osm_switch_set_path
-*
-* DESCRIPTION
-*	Sets the port to route the specified LID.
-*
-* SYNOPSIS
-*/
-static inline void
-osm_switch_set_path(
-	IN osm_switch_t* const p_sw,
-	IN const uint16_t lid_ho,
-	IN const uint8_t port,
-	IN const boolean_t ignore_port_prof
-	)
-{
-	CL_ASSERT( p_sw );
-	osm_fwd_tbl_set( &p_sw->fwd_tbl, lid_ho, port );
-	if (! ignore_port_prof)
-	  osm_port_prof_path_count_inc( &p_sw->p_prof[port] );
-}
-/*
-* PARAMETERS
-*	p_sw
-*		[in] Pointer to the switch object.
-*
-*	lid_ho
-*		[in] LID value (host order) for which to set the route.
-*
-*	port
-*		[in] Port to route the specified LID value.
-*
-* RETURN VALUE
-*	None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
 /****f* OpenSM: Switch/osm_switch_count_path
 * NAME
 *	osm_switch_count_path
diff --git a/osm/include/opensm/osm_ucast_mgr.h b/osm/include/opensm/osm_ucast_mgr.h
index b2a3a82..ed347b0 100644
--- a/osm/include/opensm/osm_ucast_mgr.h
+++ b/osm/include/opensm/osm_ucast_mgr.h
@@ -55,6 +55,7 @@
 #include <opensm/osm_madw.h>
 #include <opensm/osm_req.h>
 #include <opensm/osm_subnet.h>
+#include <opensm/osm_switch.h>
 #include <opensm/osm_log.h>
 
 #ifdef __cplusplus
@@ -238,6 +239,31 @@ osm_ucast_mgr_init(
 *	osm_ucast_mgr_destroy
 *********/
 
+/****f* OpenSM: Unicast Manager/osm_ucast_mgr_set_fwd_table
+* NAME
+*	osm_ucast_mgr_set_fwd_table
+*
+* DESCRIPTION
+*	Setup forwarding table for the switch (from prepared lft_buf).
+*
+* SYNOPSIS
+*/
+void
+osm_ucast_mgr_set_fwd_table(
+	IN osm_ucast_mgr_t* const p_mgr,
+	IN osm_switch_t* const p_sw );
+/*
+* PARAMETERS
+*	p_mgr
+*		[in] Pointer to an osm_ucast_mgr_t object.
+*
+*	p_mgr
+*		[in] Pointer to an osm_switch_t object.
+*
+* SEE ALSO
+*	Unicast Manager
+*********/
+
 /****f* OpenSM: Unicast Manager/osm_ucast_mgr_build_lid_matrices
 * NAME
 *	osm_ucast_mgr_build_lid_matrices
diff --git a/osm/opensm/osm_ucast_file.c b/osm/opensm/osm_ucast_file.c
index e844faa..7290bd2 100644
--- a/osm/opensm/osm_ucast_file.c
+++ b/osm/opensm/osm_ucast_file.c
@@ -98,7 +98,10 @@ static void add_path(osm_opensm_t * p_os
 				  (osm_switch_get_node_ptr(p_sw))), new_lid);
 	}
 
-	osm_switch_set_path(p_sw, new_lid, port_num, TRUE);
+	p_osm->sm.ucast_mgr.lft_buf[new_lid] = port_num;
+	if (!(p_osm->subn.opt.port_profile_switch_nodes && port_guid &&
+	      osm_get_switch_by_guid(&p_osm->subn, port_guid)))
+		osm_switch_count_path(p_sw, port_num);
 
 	osm_log(&p_osm->log, OSM_LOG_DEBUG,
 		"add_path: route 0x%04x(was 0x%04x) %u 0x%016" PRIx64
@@ -123,23 +126,6 @@ static void add_lid_hops(osm_opensm_t *p
 		osm_switch_set_hops(p_sw, lid, i, hops[i]);
 }
 
-static void clean_sw_lid_matrix(cl_map_item_t* const p_map_item, void *context)
-{
-	osm_switch_t * const p_sw = (osm_switch_t *)p_map_item;
-
-	osm_lid_matrix_clear(&p_sw->lmx);
-}
-
-static void clean_sw_fwd_table(cl_map_item_t* const p_map_item, void *context)
-{
-	osm_switch_t * const p_sw = (osm_switch_t *)p_map_item;
-	uint16_t lid, max_lid;
-
-	max_lid = osm_switch_get_max_lid_ho(p_sw);
-	for (lid = 1; lid <= max_lid; lid++)
-		osm_switch_set_path(p_sw, lid, OSM_NO_PATH, TRUE);
-}
-
 static int do_ucast_file_load(void *context)
 {
 	char line[1024];
@@ -170,8 +156,6 @@ static int do_ucast_file_load(void *cont
 		return -1;
 	}
 
-	cl_qmap_apply_func(&p_osm->subn.sw_guid_tbl, clean_sw_fwd_table, NULL);
-
 	lineno = 0;
 	p_sw = NULL;
 
@@ -193,6 +177,8 @@ static int do_ucast_file_load(void *cont
 				"skipping parsing. Using default "
 				"routing algorithm\n");
 		} else if (!strncmp(p, "Unicast lids", 12)) {
+			if (p_sw)
+				osm_ucast_mgr_set_fwd_table(&p_osm->sm.ucast_mgr, p_sw);
 			q = strstr(p, " guid 0x");
 			if (!q) {
 				osm_log(&p_osm->log, OSM_LOG_ERROR,
@@ -223,6 +209,7 @@ static int do_ucast_file_load(void *cont
 					cl_ntoh64(sw_guid));
 				continue;
 			}
+			memset(p_osm->sm.ucast_mgr.lft_buf, 0xff, 0xc000);
 		} else if (p_sw && !strncmp(p, "0x", 2)) {
 			p += 2;
 			lid = (uint16_t)strtoul(p, &q, 16);
@@ -272,6 +259,9 @@ static int do_ucast_file_load(void *cont
 		}
 	}
 
+	if (p_sw)
+		osm_ucast_mgr_set_fwd_table(&p_osm->sm.ucast_mgr, p_sw);
+
 	fclose(file);
 	return 0;
 }
@@ -307,8 +297,6 @@ static int do_lid_matrix_file_load(void
 		return -1;
 	}
 
-	cl_qmap_apply_func(&p_osm->subn.sw_guid_tbl, clean_sw_lid_matrix, NULL);
-
 	lineno = 0;
 	p_sw = NULL;
 
diff --git a/osm/opensm/osm_ucast_mgr.c b/osm/opensm/osm_ucast_mgr.c
index 2263a4d..1bda180 100644
--- a/osm/opensm/osm_ucast_mgr.c
+++ b/osm/opensm/osm_ucast_mgr.c
@@ -410,6 +410,17 @@ static void __osm_ucast_mgr_dump_tables(
 }
 
 /**********************************************************************
+ Starting a rebuild, so notify the switch so it can clear tables, etc...
+**********************************************************************/
+static void
+__osm_ucast_mgr_clean_switch(
+  IN cl_map_item_t* const  p_map_item,
+  IN void* context )
+{
+  osm_switch_prepare_path_rebuild((osm_switch_t *)p_map_item);
+}
+
+/**********************************************************************
  Add each switch's own LID(s) to its LID matrix.
 **********************************************************************/
 static void
@@ -431,12 +442,6 @@ __osm_ucast_mgr_process_hop_0(
   CL_ASSERT( p_node );
   CL_ASSERT( osm_node_get_type( p_node ) == IB_NODE_TYPE_SWITCH );
 
-  /*
-    Starting a rebuild, so notify the switch so it can
-    clear tables, etc...
-  */
-  osm_switch_prepare_path_rebuild( p_sw );
-
   base_lid_ho = cl_ntoh16( osm_node_get_base_lid( p_node, 0 ) );
   if (osm_switch_sp0_is_lmc_capable( p_sw, p_mgr->p_subn ))
     lmc = osm_node_get_lmc( p_node, 0 );
@@ -870,8 +875,8 @@ __osm_ucast_mgr_process_port(
 
 /**********************************************************************
  **********************************************************************/
-static void
-__osm_ucast_mgr_set_table(
+void
+osm_ucast_mgr_set_fwd_table(
   IN osm_ucast_mgr_t* const p_mgr,
   IN osm_switch_t* const p_sw )
 {
@@ -885,7 +890,7 @@ __osm_ucast_mgr_set_table(
 
   CL_ASSERT( p_mgr );
 
-  OSM_LOG_ENTER( p_mgr->p_log, __osm_ucast_mgr_set_table );
+  OSM_LOG_ENTER( p_mgr->p_log, osm_ucast_mgr_set_fwd_table );
 
   CL_ASSERT( p_sw );
 
@@ -914,7 +919,7 @@ __osm_ucast_mgr_set_table(
   if( osm_log_is_active( p_mgr->p_log, OSM_LOG_DEBUG ) )
   {
     osm_log( p_mgr->p_log, OSM_LOG_DEBUG,
-             "__osm_ucast_mgr_set_table: "
+             "osm_ucast_mgr_set_fwd_table: "
              "Setting switch FT top to LID 0x%X\n",
              osm_switch_get_max_lid_ho( p_sw ) );
   }
@@ -935,7 +940,7 @@ __osm_ucast_mgr_set_table(
   if( status != IB_SUCCESS )
   {
     osm_log( p_mgr->p_log, OSM_LOG_ERROR,
-             "__osm_ucast_mgr_set_table: ERR 3A06: "
+             "osm_ucast_mgr_set_fwd_table: ERR 3A06: "
              "Sending SwitchInfo attribute failed (%s)\n",
              ib_get_err_str( status ) );
   }
@@ -959,7 +964,7 @@ __osm_ucast_mgr_set_table(
     if( osm_log_is_active( p_mgr->p_log, OSM_LOG_DEBUG ) )
     {
       osm_log( p_mgr->p_log, OSM_LOG_DEBUG,
-               "__osm_ucast_mgr_set_table: "
+               "osm_ucast_mgr_set_fwd_table: "
                "Writing FT block %u\n", block_id_ho );
     }
 
@@ -975,7 +980,7 @@ __osm_ucast_mgr_set_table(
     if( status != IB_SUCCESS )
     {
       osm_log( p_mgr->p_log, OSM_LOG_ERROR,
-               "__osm_ucast_mgr_set_table: ERR 3A05: "
+               "osm_ucast_mgr_set_fwd_table: ERR 3A05: "
                "Sending linear fwd. tbl. block failed (%s)\n",
                ib_get_err_str( status ) );
     }
@@ -1028,7 +1033,7 @@ __osm_ucast_mgr_process_tbl(
     __osm_ucast_mgr_process_port( p_mgr, p_sw, p_port );
   }
 
-  __osm_ucast_mgr_set_table( p_mgr, p_sw );
+  osm_ucast_mgr_set_fwd_table( p_mgr, p_sw );
 
   OSM_LOG_EXIT( p_mgr->p_log );
 }
@@ -1036,19 +1041,6 @@ __osm_ucast_mgr_process_tbl(
 /**********************************************************************
  **********************************************************************/
 static void
-__osm_ucast_mgr_set_table_cb(
-  IN cl_map_item_t* const  p_map_item,
-  IN void* context )
-{
-  osm_switch_t* const p_sw = (osm_switch_t*)p_map_item;
-  osm_ucast_mgr_t* const p_mgr = (osm_ucast_mgr_t*)context;
-
-  __osm_ucast_mgr_set_table( p_mgr, p_sw );
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
 __osm_ucast_mgr_process_neighbors(
   IN cl_map_item_t* const  p_map_item,
   IN void* context )
@@ -1222,6 +1214,8 @@ osm_ucast_mgr_process(
   if (cl_qmap_count( p_sw_guid_tbl ) == 0)
     goto Exit;
 
+  cl_qmap_apply_func(p_sw_guid_tbl, __osm_ucast_mgr_clean_switch, NULL);
+
   if (!p_routing_eng->build_lid_matrices ||
       p_routing_eng->build_lid_matrices(p_routing_eng->context) != 0)
     osm_ucast_mgr_build_lid_matrices(p_mgr);
@@ -1235,13 +1229,8 @@ osm_ucast_mgr_process(
     build and download the switch forwarding tables.
   */
 
-  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
+  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_process_tbl, p_mgr );
diff --git a/osm/opensm/osm_ucast_updn.c b/osm/opensm/osm_ucast_updn.c
index 0bc359b..e139a91 100644
--- a/osm/opensm/osm_ucast_updn.c
+++ b/osm/opensm/osm_ucast_updn.c
@@ -883,16 +883,10 @@ __osm_subn_set_up_down_min_hop_table(
   p_next_sw = (osm_switch_t*)cl_qmap_head( &p_subn->sw_guid_tbl );
   while( p_next_sw != (osm_switch_t*)cl_qmap_end( &p_subn->sw_guid_tbl ) )
   {
-    uint16_t max_lid_ho, lid_ho;
-
     p_sw = p_next_sw;
     p_next_sw = (osm_switch_t*)cl_qmap_next( &p_sw->map_item );
-    /* Clear Min Hop Table && FWD Tbls - This should caused opensm to
-       rebuild its FWD tables , post setting Min Hop Tables */
+    /* Clear Min Hop Table */
     osm_lid_matrix_clear(&(p_sw->lmx));
-    max_lid_ho = osm_switch_get_max_lid_ho(p_sw);
-    for (lid_ho = 1; lid_ho <= max_lid_ho; lid_ho++)
-      osm_switch_set_path(p_sw, lid_ho, OSM_NO_PATH, TRUE);
   }
 
   osm_log(p_log, OSM_LOG_VERBOSE,
-- 
1.4.4





More information about the general mailing list