[ofa-general] [PATCH 5/6] opensm/Unicast Routing Cache: integrate cache into opensm

Yevgeny Kliteynik kliteyn at dev.mellanox.co.il
Sun Oct 5 18:29:34 PDT 2008


Integrating unicast cache into the discovery and ucast manager.

Signed-off-by: Yevgeny Kliteynik <kliteyn at dev.mellanox.co.il>
---
 opensm/include/opensm/osm_ucast_mgr.h |    6 ++++
 opensm/opensm/osm_drop_mgr.c          |   13 ++++++++-
 opensm/opensm/osm_node_info_rcv.c     |    9 +++++-
 opensm/opensm/osm_port_info_rcv.c     |    9 +++++-
 opensm/opensm/osm_state_mgr.c         |   10 ++++++-
 opensm/opensm/osm_ucast_mgr.c         |   50 ++++++++++++++++++++++----------
 6 files changed, 77 insertions(+), 20 deletions(-)

diff --git a/opensm/include/opensm/osm_ucast_mgr.h b/opensm/include/opensm/osm_ucast_mgr.h
index 27e89e9..e4006bb 100644
--- a/opensm/include/opensm/osm_ucast_mgr.h
+++ b/opensm/include/opensm/osm_ucast_mgr.h
@@ -49,6 +49,7 @@
 #include <opensm/osm_subnet.h>
 #include <opensm/osm_switch.h>
 #include <opensm/osm_log.h>
+#include <opensm/osm_ucast_cache.h>

 #ifdef __cplusplus
 #  define BEGIN_C_DECLS extern "C" {
@@ -77,6 +78,7 @@ BEGIN_C_DECLS
 *
 *********/
 struct osm_sm;
+struct _osm_ucast_cache;
 /****s* OpenSM: Unicast Manager/osm_ucast_mgr_t
 * NAME
 *	osm_ucast_mgr_t
@@ -97,6 +99,7 @@ typedef struct osm_ucast_mgr {
 	cl_qlist_t port_order_list;
 	boolean_t is_dor;
 	boolean_t some_hop_count_set;
+	struct _osm_ucast_cache *p_cache;
 } osm_ucast_mgr_t;
 /*
 * FIELDS
@@ -128,6 +131,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.
+*
 * SEE ALSO
 *	Unicast Manager object
 *********/
diff --git a/opensm/opensm/osm_drop_mgr.c b/opensm/opensm/osm_drop_mgr.c
index e827c26..e8d3454 100644
--- a/opensm/opensm/osm_drop_mgr.c
+++ b/opensm/opensm/osm_drop_mgr.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2004-2007 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.
  * Copyright (c) 2008 Xsigo Systems Inc.  All rights reserved.
  *
@@ -61,6 +61,7 @@
 #include <opensm/osm_multicast.h>
 #include <opensm/osm_remote_sm.h>
 #include <opensm/osm_inform.h>
+#include <opensm/osm_ucast_mgr.h>

 /**********************************************************************
  **********************************************************************/
@@ -134,6 +135,13 @@ static void drop_mgr_clean_physp(osm_sm_t * sm, IN osm_physp_t * p_physp)
 				  (p_remote_physp->p_node)),
 			p_remote_physp->port_num);

+		if (sm->p_subn->opt.use_ucast_cache)
+			osm_ucast_cache_add_link(sm->ucast_mgr.p_cache,
+						 p_physp->p_node,
+						 p_physp->port_num,
+						 p_remote_physp->p_node,
+						 p_remote_physp->port_num);
+
 		osm_physp_unlink(p_physp, p_remote_physp);

 	}
@@ -307,6 +315,9 @@ __osm_drop_mgr_process_node(osm_sm_t * sm, IN osm_node_t * p_node)
 		"Unreachable node 0x%016" PRIx64 "\n",
 		cl_ntoh64(osm_node_get_node_guid(p_node)));

+	if (sm->p_subn->opt.use_ucast_cache)
+		osm_ucast_cache_add_node(sm->ucast_mgr.p_cache, p_node);
+
 	/*
 	   Delete all the logical and physical port objects
 	   associated with this node.
diff --git a/opensm/opensm/osm_node_info_rcv.c b/opensm/opensm/osm_node_info_rcv.c
index 86710d1..27b842f 100644
--- a/opensm/opensm/osm_node_info_rcv.c
+++ b/opensm/opensm/osm_node_info_rcv.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2004-2007 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
@@ -59,6 +59,7 @@
 #include <opensm/osm_helper.h>
 #include <opensm/osm_msgdef.h>
 #include <opensm/osm_opensm.h>
+#include <opensm/osm_ucast_mgr.h>

 static void
 report_duplicated_guid(IN osm_sm_t * sm,
@@ -240,6 +241,12 @@ __osm_ni_rcv_set_links(IN osm_sm_t * sm,
 		cl_ntoh64(osm_node_get_node_guid(p_node)), port_num,
 		cl_ntoh64(p_ni_context->node_guid), p_ni_context->port_num);

+	if (sm->p_subn->opt.use_ucast_cache)
+		osm_ucast_cache_check_new_link(sm->ucast_mgr.p_cache,
+					       p_node, port_num,
+					       p_neighbor_node,
+					       p_ni_context->port_num);
+
 	osm_node_link(p_node, port_num, p_neighbor_node,
 		      p_ni_context->port_num);

diff --git a/opensm/opensm/osm_port_info_rcv.c b/opensm/opensm/osm_port_info_rcv.c
index a820069..cac3c05 100644
--- a/opensm/opensm/osm_port_info_rcv.c
+++ b/opensm/opensm/osm_port_info_rcv.c
@@ -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
@@ -60,6 +60,7 @@
 #include <opensm/osm_pkey.h>
 #include <opensm/osm_remote_sm.h>
 #include <opensm/osm_opensm.h>
+#include <opensm/osm_ucast_mgr.h>

 /**********************************************************************
  **********************************************************************/
@@ -244,6 +245,12 @@ __osm_pi_rcv_process_switch_port(IN osm_sm_t * sm,
 						  (p_remote_node)),
 					remote_port_num);

+				if (sm->p_subn->opt.use_ucast_cache)
+					osm_ucast_cache_add_link(sm->ucast_mgr.p_cache,
+								 p_node, port_num,
+								 p_remote_node,
+								 remote_port_num);
+
 				osm_node_unlink(p_node, (uint8_t) port_num,
 						p_remote_node,
 						(uint8_t) remote_port_num);
diff --git a/opensm/opensm/osm_state_mgr.c b/opensm/opensm/osm_state_mgr.c
index b4eb87b..88d8bf9 100644
--- a/opensm/opensm/osm_state_mgr.c
+++ b/opensm/opensm/osm_state_mgr.c
@@ -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
@@ -1075,6 +1075,10 @@ static void do_sweep(osm_sm_t * sm)
 		/* Re-program the switches fully */
 		sm->p_subn->ignore_existing_lfts = TRUE;

+		/* we want to re-route, so cache should be invalidated */
+		if (sm->p_subn->opt.use_ucast_cache)
+			osm_ucast_cache_invalidate(sm->ucast_mgr.p_cache);
+
 		osm_ucast_mgr_process(&sm->ucast_mgr);

 		/* Reset flag */
@@ -1229,6 +1233,10 @@ _repeat_discovery:
 	/*
 	 * Proceed with unicast forwarding table configuration.
 	 */
+
+	if (sm->p_subn->opt.use_ucast_cache)
+		osm_ucast_cache_validate(sm->ucast_mgr.p_cache);
+
 	osm_ucast_mgr_process(&sm->ucast_mgr);
 	if (wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
 		return;
diff --git a/opensm/opensm/osm_ucast_mgr.c b/opensm/opensm/osm_ucast_mgr.c
index 12a8b58..97b4fb9 100644
--- a/opensm/opensm/osm_ucast_mgr.c
+++ b/opensm/opensm/osm_ucast_mgr.c
@@ -73,6 +73,8 @@ void osm_ucast_mgr_destroy(IN osm_ucast_mgr_t * const p_mgr)
 	CL_ASSERT(p_mgr);

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

@@ -92,6 +94,12 @@ osm_ucast_mgr_init(IN osm_ucast_mgr_t * const p_mgr, IN osm_sm_t * sm)
 	p_mgr->p_subn = sm->p_subn;
 	p_mgr->p_lock = sm->p_lock;

+	if (sm->p_subn->opt.use_ucast_cache){
+		p_mgr->p_cache = osm_ucast_cache_construct(p_mgr);
+		if (!p_mgr->p_cache)
+			status = IB_INSUFFICIENT_MEMORY;
+	}
+
 	OSM_LOG_EXIT(p_mgr->p_log);
 	return (status);
 }
@@ -818,27 +826,37 @@ int osm_ucast_mgr_process(IN osm_ucast_mgr_t * const p_mgr)
 	/*
 	   If there are no switches in the subnet, we are done.
 	 */
-	if (cl_qmap_count(p_sw_guid_tbl) == 0 ||
-	    ucast_mgr_setup_all_switches(p_mgr->p_subn) < 0)
+	if (cl_qmap_count(p_sw_guid_tbl) == 0)
 		goto Exit;

 	p_osm->routing_engine_used = OSM_ROUTING_ENGINE_TYPE_NONE;
-	while (p_routing_eng) {
-		if (!ucast_mgr_route(p_routing_eng, p_osm))
-			break;
-		p_routing_eng = p_routing_eng->next;
-	}
+	if (p_mgr->p_subn->opt.use_ucast_cache &&
+	    osm_ucast_cache_is_valid(p_mgr->p_cache)) {
+		OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
+			"Configuring switch tables using cached routing\n");
+		osm_ucast_cache_apply(p_mgr->p_cache);

-	if (p_osm->routing_engine_used == OSM_ROUTING_ENGINE_TYPE_NONE) {
-		/* If configured routing algorithm failed, use default MinHop */
-		osm_ucast_mgr_build_lid_matrices(p_mgr);
-		ucast_mgr_build_lfts(p_mgr);
-		p_osm->routing_engine_used = OSM_ROUTING_ENGINE_TYPE_MINHOP;
-	}
+	} else {
+
+		if (ucast_mgr_setup_all_switches(p_mgr->p_subn) < 0)
+			goto Exit;

-	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));
+		while (p_routing_eng) {
+			if (!ucast_mgr_route(p_routing_eng, p_osm))
+				break;
+			p_routing_eng = p_routing_eng->next;
+		}
+
+		if (p_osm->routing_engine_used == OSM_ROUTING_ENGINE_TYPE_NONE) {
+			/* If configured routing algorithm failed, use default MinHop */
+			osm_ucast_mgr_build_lid_matrices(p_mgr);
+			ucast_mgr_build_lfts(p_mgr);
+			p_osm->routing_engine_used = OSM_ROUTING_ENGINE_TYPE_MINHOP;
+		}
+
+		if (p_mgr->p_subn->opt.use_ucast_cache)
+			osm_ucast_cache_mark_valid(p_mgr->p_cache);
+	}

 Exit:
 	CL_PLOCK_RELEASE(p_mgr->p_lock);
-- 
1.5.1.4




More information about the general mailing list