[ofa-general] [PATCH 4/4] opensm/osm_ucast_mgr.{c, h}: integrate ucast cache

Yevgeny Kliteynik kliteyn at dev.mellanox.co.il
Sun May 4 03:03:14 PDT 2008


Integrating unicast routing cache into the unicast manager.

The cache is used the following way:
 - SM is executed - it starts first routing calculation
 - calculated routing is stored in the cache
 - at some point new heavy sweep is triggered
 - unicast manager checks whether the cache can be used instead
   of new routing calculation.
   In one of the following cases we can use cached routing
    + there is no topology change
    + one or more CAs disappeared (they exist in the cached topology
      model, but missing in the newly discovered fabric)
    + one or more leaf switches disappeared
   In these cases cached routing is written to the switches as is
   (unless the switch doesn't exist).
   If there is any other topology change:
     - existing cache is invalidated
     - topology is cached
     - routing is calculated as usual
     - routing is cached

Signed-off-by: Yevgeny Kliteynik <kliteyn at dev.mellanox.co.il>
---
 opensm/include/opensm/osm_ucast_mgr.h |    7 +++-
 opensm/opensm/osm_ucast_mgr.c         |   79 ++++++++++++++++++++++-----------
 2 files changed, 59 insertions(+), 27 deletions(-)

diff --git a/opensm/include/opensm/osm_ucast_mgr.h b/opensm/include/opensm/osm_ucast_mgr.h
index 0317c93..33e164b 100644
--- a/opensm/include/opensm/osm_ucast_mgr.h
+++ b/opensm/include/opensm/osm_ucast_mgr.h
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 2002-2008 Mellanox Technologies LTD. All rights reserved.
  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
  *
  * This software is available to you under a choice of one of two
@@ -53,6 +53,7 @@
 #include <opensm/osm_madw.h>
 #include <opensm/osm_subnet.h>
 #include <opensm/osm_switch.h>
+#include <opensm/osm_ucast_cache.h>
 #include <opensm/osm_log.h>

 #ifdef __cplusplus
@@ -103,6 +104,7 @@ typedef struct _osm_ucast_mgr {
 	boolean_t is_dor;
 	boolean_t any_change;
 	boolean_t some_hop_count_set;
+	osm_ucast_cache_t * p_cache;
 	uint8_t *lft_buf;
 } osm_ucast_mgr_t;
 /*
@@ -132,6 +134,9 @@ typedef struct _osm_ucast_mgr {
 *		tables calculation iteration cycle, set to TRUE to indicate
 *		that some hop count changes were done.
 *
+*	p_cache
+*		Pointer to the unicast cache object.
+*
 *	lft_buf
 *		LFT buffer - used during LFT calculation/setup.
 *
diff --git a/opensm/opensm/osm_ucast_mgr.c b/opensm/opensm/osm_ucast_mgr.c
index 938db84..d854fa9 100644
--- a/opensm/opensm/osm_ucast_mgr.c
+++ b/opensm/opensm/osm_ucast_mgr.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 2002-2008 Mellanox Technologies LTD. All rights reserved.
  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
  *
  * This software is available to you under a choice of one of two
@@ -81,6 +81,9 @@ void osm_ucast_mgr_destroy(IN osm_ucast_mgr_t * const p_mgr)
 	if (p_mgr->lft_buf)
 		free(p_mgr->lft_buf);

+	if (p_mgr->p_cache)
+		osm_ucast_cache_destroy(p_mgr->p_cache);
+
 	OSM_LOG_EXIT(p_mgr->p_log);
 }

@@ -104,6 +107,9 @@ osm_ucast_mgr_init(IN osm_ucast_mgr_t * const p_mgr, IN osm_sm_t * sm)
 	if (!p_mgr->lft_buf)
 		return IB_INSUFFICIENT_MEMORY;

+	if (p_mgr->p_subn->opt.use_ucast_cache)
+		p_mgr->p_cache = osm_ucast_cache_construct(p_mgr);
+
 	OSM_LOG_EXIT(p_mgr->p_log);
 	return (status);
 }
@@ -375,6 +381,10 @@ osm_ucast_mgr_set_fwd_table(IN osm_ucast_mgr_t * const p_mgr,

 	CL_ASSERT(p_path);

+	if (p_mgr->p_cache && p_mgr->p_cache->need_update)
+		osm_ucast_cache_set_sw_fwd_table(p_mgr->p_cache,
+						 p_mgr->lft_buf, p_sw);
+
 	/*
 	   Set the top of the unicast forwarding table.
 	 */
@@ -688,33 +698,50 @@ osm_signal_t osm_ucast_mgr_process(IN osm_ucast_mgr_t * const p_mgr)

 	p_mgr->any_change = FALSE;

-	if (!p_routing_eng->build_lid_matrices ||
-	    (blm = p_routing_eng->build_lid_matrices(p_routing_eng->context)))
-		osm_ucast_mgr_build_lid_matrices(p_mgr);
+	if (p_mgr->p_cache && (osm_ucast_cache_apply(p_mgr->p_cache) == 0))
+		OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
+			"configured switch tables using cached routing\n");
+	else {
+		if (p_mgr->p_cache) {
+			/* ucast cache is enabled - refresh
+			   topology and mark routing for update */
+			p_mgr->p_cache->need_update = TRUE;
+			osm_ucast_cache_refresh_topo(p_mgr->p_cache);
+		}
+
+		if (!p_routing_eng->build_lid_matrices ||
+		    (blm = p_routing_eng->build_lid_matrices(p_routing_eng->context)))
+			osm_ucast_mgr_build_lid_matrices(p_mgr);

-	/*
-	   Now that the lid matrices have been built, we can
-	   build and download the switch forwarding tables.
-	 */
-	if (!p_routing_eng->ucast_build_fwd_tables ||
-	    (ubft =
-	     p_routing_eng->ucast_build_fwd_tables(p_routing_eng->context)))
-		cl_qmap_apply_func(p_sw_guid_tbl, __osm_ucast_mgr_process_tbl,
-				   p_mgr);
-
-	/* 'file' routing engine has one unique logic corner case */
-	if (p_routing_eng->name && (strcmp(p_routing_eng->name, "file") == 0)
-	    && (!blm || !ubft))
-		p_osm->routing_engine_used = OSM_ROUTING_ENGINE_TYPE_FILE;
-	else if (!blm && !ubft)
-		p_osm->routing_engine_used =
-		    osm_routing_engine_type(p_routing_eng->name);
-	else
-		p_osm->routing_engine_used = OSM_ROUTING_ENGINE_TYPE_MINHOP;
+		/*
+		   Now that the lid matrices have been built, we can
+		   build and download the switch forwarding tables.
+		 */
+		if (!p_routing_eng->ucast_build_fwd_tables ||
+		    (ubft =
+		     p_routing_eng->ucast_build_fwd_tables(p_routing_eng->context)))
+			cl_qmap_apply_func(p_sw_guid_tbl, __osm_ucast_mgr_process_tbl,
+					   p_mgr);
+
+		/* 'file' routing engine has one unique logic corner case */
+		if (p_routing_eng->name && (strcmp(p_routing_eng->name, "file") == 0)
+		    && (!blm || !ubft))
+			p_osm->routing_engine_used = OSM_ROUTING_ENGINE_TYPE_FILE;
+		else if (!blm && !ubft)
+			p_osm->routing_engine_used =
+			    osm_routing_engine_type(p_routing_eng->name);
+		else
+			p_osm->routing_engine_used = OSM_ROUTING_ENGINE_TYPE_MINHOP;
+
+		OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
+			"%s tables configured on all switches\n",
+			osm_routing_engine_type_str(p_osm->routing_engine_used));

-	OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
-		"%s tables configured on all switches\n",
-		osm_routing_engine_type_str(p_osm->routing_engine_used));
+		if (p_mgr->p_cache) {
+			osm_ucast_cache_refresh_lid_matrices(p_mgr->p_cache);
+			p_mgr->p_cache->need_update = FALSE;
+		}
+	}

 	if (p_mgr->any_change) {
 		signal = OSM_SIGNAL_DONE_PENDING;
-- 
1.5.1.4




More information about the general mailing list