move is_dor out of osm_ucast_mgr_t into dor routing engine.  Makes a
common function called osm_ucast_minhop_and_dor_build_fwd_tables()
which takes some flags so appropriate routing engines can specify
behavior they'd like.

Al

-- 
Albert Chu
[EMAIL PROTECTED]
925-422-5311
Computer Scientist
High Performance Systems Division
Lawrence Livermore National Laboratory
>From de0e941be39340ee3f06353a21613a1bf2a5f3b9 Mon Sep 17 00:00:00 2001
From: Albert Chu <[EMAIL PROTECTED]>
Date: Fri, 12 Sep 2008 14:19:17 -0700
Subject: [PATCH] move dor recognition from flag to callback


Signed-off-by: Albert Chu <[EMAIL PROTECTED]>
---
 opensm/include/opensm/osm_ucast_mgr.h    |    4 ---
 opensm/include/opensm/osm_ucast_minhop.h |   23 +++++++++++++++++
 opensm/opensm/osm_ucast_dor.c            |    8 +++++-
 opensm/opensm/osm_ucast_mgr.c            |    3 --
 opensm/opensm/osm_ucast_minhop.c         |   40 +++++++++++++++++++++++++----
 5 files changed, 64 insertions(+), 14 deletions(-)

diff --git a/opensm/include/opensm/osm_ucast_mgr.h b/opensm/include/opensm/osm_ucast_mgr.h
index 8b9f115..ac4fe27 100644
--- a/opensm/include/opensm/osm_ucast_mgr.h
+++ b/opensm/include/opensm/osm_ucast_mgr.h
@@ -97,7 +97,6 @@ typedef struct osm_ucast_mgr {
 	osm_log_t *p_log;
 	cl_plock_t *p_lock;
 	cl_qlist_t port_order_list;
-	boolean_t is_dor;
 	boolean_t any_change;
 	boolean_t some_hop_count_set;
 	uint8_t *lft_buf;
@@ -116,9 +115,6 @@ typedef struct osm_ucast_mgr {
 *	p_lock
 *		Pointer to the serializing lock.
 *
-*	is_dor
-*		Dimension Order Routing (DOR) will be done
-*
 *	port_order_list
 *		List of ports ordered for routing.
 *
diff --git a/opensm/include/opensm/osm_ucast_minhop.h b/opensm/include/opensm/osm_ucast_minhop.h
index 1eb3086..3c0d8a5 100644
--- a/opensm/include/opensm/osm_ucast_minhop.h
+++ b/opensm/include/opensm/osm_ucast_minhop.h
@@ -68,6 +68,29 @@ int osm_ucast_minhop_build_lid_matrices(IN osm_ucast_mgr_t * const p_mgr);
 *	This function builds lid matrices for min hop table calculation.
 *********/
 
+/****f* OpenSM: Unicast Minhop/ucast_minhop_and_dor_build_fwd_tables
+* NAME
+*	osm_ucast_minhop_and_dor_build_fwd_tables
+*
+* DESCRIPTION
+*	Common build forwarding tables function for minhop and dor routing.
+*
+* SYNOPSIS
+*/
+int osm_ucast_minhop_and_dor_build_fwd_tables(IN osm_ucast_mgr_t * const p_mgr,
+					      IN boolean_t dor);
+/*
+* PARAMETERS
+*	p_mgr
+*		[in] Pointer to an osm_ucast_mgr_t object.
+*
+*	dor
+*		[in] indicates dor routing
+*
+* NOTES
+*	This function configures switches' min hop tables.
+*********/
+
 /****f* OpenSM: Unicast Minhop/ucast_minhop_build_fwd_tables
 * NAME
 *	osm_ucast_minhop_build_fwd_tables
diff --git a/opensm/opensm/osm_ucast_dor.c b/opensm/opensm/osm_ucast_dor.c
index f354a26..df037d5 100644
--- a/opensm/opensm/osm_ucast_dor.c
+++ b/opensm/opensm/osm_ucast_dor.c
@@ -38,12 +38,18 @@
 #include <stdlib.h>
 #include <string.h>
 #include <opensm/osm_opensm.h>
+#include <opensm/osm_ucast_minhop.h>
 #include <opensm/osm_log.h>
 
+int osm_ucast_dor_build_fwd_tables(osm_opensm_t * const p_osm)
+{
+        return osm_ucast_minhop_and_dor_build_fwd_tables(&p_osm->subn.ucast_mgr, TRUE);
+}
+
 int osm_ucast_dor_setup(osm_opensm_t * p_osm)
 {
 	p_osm->routing_engine.context = (void *)p_osm;
 	p_osm->routing_engine.build_lid_matrices = NULL;
-	p_osm->routing_engine.ucast_build_fwd_tables = NULL;
+	p_osm->routing_engine.ucast_build_fwd_tables = osm_ucast_dor_build_fwd_tables;
 	return 0;
 }
diff --git a/opensm/opensm/osm_ucast_mgr.c b/opensm/opensm/osm_ucast_mgr.c
index 2193c15..7e636ff 100644
--- a/opensm/opensm/osm_ucast_mgr.c
+++ b/opensm/opensm/osm_ucast_mgr.c
@@ -260,9 +260,6 @@ osm_signal_t osm_ucast_mgr_process(IN osm_ucast_mgr_t * const p_mgr)
 	p_osm = p_mgr->p_subn->p_osm;
 	p_routing_eng = &p_osm->routing_engine;
 
-	p_mgr->is_dor = p_routing_eng->name
-	    && (strcmp(p_routing_eng->name, "dor") == 0);
-
 	CL_PLOCK_EXCL_ACQUIRE(p_mgr->p_lock);
 
 	/*
diff --git a/opensm/opensm/osm_ucast_minhop.c b/opensm/opensm/osm_ucast_minhop.c
index fb57590..7e40437 100644
--- a/opensm/opensm/osm_ucast_minhop.c
+++ b/opensm/opensm/osm_ucast_minhop.c
@@ -54,6 +54,11 @@
 #include <opensm/osm_msgdef.h>
 #include <opensm/osm_opensm.h>
 
+struct osm_minhop_build_fwd_tables_data {
+	osm_ucast_mgr_t *p_mgr;
+	boolean_t dor;
+};
+
 /**********************************************************************
  Add each switch's own and neighbor LIDs to its LID matrix
 **********************************************************************/
@@ -158,7 +163,8 @@ static void
 __osm_ucast_minhop_process_port(IN osm_ucast_mgr_t * const p_mgr,
 				IN osm_switch_t * const p_sw,
 				IN osm_port_t * const p_port,
-				IN unsigned lid_offset)
+				IN unsigned lid_offset,
+				IN boolean_t dor)
 {
 	uint16_t min_lid_ho;
 	uint16_t max_lid_ho;
@@ -213,7 +219,7 @@ __osm_ucast_minhop_process_port(IN osm_ucast_mgr_t * const p_mgr,
 	 */
 	port = osm_switch_recommend_path(p_sw, p_port, lid_ho, start_from,
 					 p_mgr->p_subn->ignore_existing_lfts,
-					 p_mgr->is_dor);
+					 dor);
 
 	if (port == OSM_NO_PATH) {
 		/* do not try to overwrite the ppro of non existing port ... */
@@ -321,9 +327,15 @@ static void
 __osm_ucast_minhop_process_tbl(IN cl_map_item_t * const p_map_item,
 			       IN void *context)
 {
-	osm_ucast_mgr_t *p_mgr = context;
+	struct osm_minhop_build_fwd_tables_data *p_minhop_fwd_data;
+	osm_ucast_mgr_t *p_mgr;
 	osm_switch_t *const p_sw = (osm_switch_t *) p_map_item;
 	unsigned i, lids_per_port;
+	boolean_t dor;
+
+	p_minhop_fwd_data = context;
+	p_mgr = p_minhop_fwd_data->p_mgr;
+	dor = p_minhop_fwd_data->dor;	
 
 	OSM_LOG_ENTER(p_mgr->p_log);
 
@@ -350,7 +362,11 @@ __osm_ucast_minhop_process_tbl(IN cl_map_item_t * const p_map_item,
 		for (item = cl_qlist_head(list); item != cl_qlist_end(list);
 		     item = cl_qlist_next(item)) {
 			osm_port_t *port = cl_item_obj(item, port, list_item);
-			__osm_ucast_minhop_process_port(p_mgr, p_sw, port, i);
+			__osm_ucast_minhop_process_port(p_mgr, 
+							p_sw, 
+							port, 
+							i,
+							dor);
 		}
 	}
 
@@ -566,8 +582,11 @@ static void clear_prof_ignore_flag(cl_map_item_t * const p_map_item, void *ctx)
 	}
 }
 
-int osm_ucast_minhop_build_fwd_tables(osm_ucast_mgr_t * const p_mgr)
+int osm_ucast_minhop_and_dor_build_fwd_tables(osm_ucast_mgr_t * const p_mgr,
+					      boolean_t dor)
 {
+	struct osm_minhop_build_fwd_tables_data minhop_fwd_data;
+
 	cl_qlist_init(&p_mgr->port_order_list);
 
 	if (p_mgr->p_subn->opt.guid_routing_order_file) {
@@ -596,14 +615,23 @@ int osm_ucast_minhop_build_fwd_tables(osm_ucast_mgr_t * const p_mgr)
 	cl_qmap_apply_func(&p_mgr->p_subn->port_guid_tbl,
 			   add_port_to_order_list, p_mgr);
 
+	minhop_fwd_data.p_mgr = p_mgr;
+	minhop_fwd_data.dor = dor;
+
 	cl_qmap_apply_func(&p_mgr->p_subn->sw_guid_tbl,
-			   __osm_ucast_minhop_process_tbl, p_mgr);
+			   __osm_ucast_minhop_process_tbl,
+			   &minhop_fwd_data);
 
 	cl_qlist_remove_all(&p_mgr->port_order_list);
 
 	return 0;
 }
 
+int osm_ucast_minhop_build_fwd_tables(osm_ucast_mgr_t * const p_mgr)
+{
+	return osm_ucast_minhop_and_dor_build_fwd_tables(p_mgr, FALSE);
+}
+
 int osm_ucast_minhop_setup(osm_opensm_t * p_osm)
 {
 	p_osm->routing_engine.context = (void *)p_osm;
-- 
1.5.4.5

_______________________________________________
general mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to