[ofa-general] [PATCH] opensm/osm_ucast_ftree.c: some refactoring

Yevgeny Kliteynik kliteyn at dev.mellanox.co.il
Thu Mar 12 02:34:53 PDT 2009


Hi Sasha,

Some code refactoring: setting entry in the lid matrices should
no longer be done per link, but per group, which means that lid
matrix should be updated for all the ports that are connected to
the same remote node.

Signed-off-by: Yevgeny Kliteynik <kliteyn at dev.mellanox.co.il>
---
 opensm/opensm/osm_ucast_ftree.c |   85 ++++++++++++++++-----------------------
 1 files changed, 35 insertions(+), 50 deletions(-)

diff --git a/opensm/opensm/osm_ucast_ftree.c b/opensm/opensm/osm_ucast_ftree.c
index 4e52d4b..10b3dcc 100644
--- a/opensm/opensm/osm_ucast_ftree.c
+++ b/opensm/opensm/osm_ucast_ftree.c
@@ -560,6 +560,9 @@ static ftree_sw_t *sw_create(IN ftree_fabric_t * p_ftree,
 	/* initialize lft buffer */
 	memset(p_osm_sw->new_lft, OSM_NO_PATH, IB_LID_UCAST_END_HO + 1);

+	/* set min hop table of the switch to itself */
+	osm_switch_set_hops(p_osm_sw, cl_ntoh16(p_sw->base_lid), 0, 0);
+
 	return p_sw;
 } /* sw_create() */

@@ -710,13 +713,23 @@ sw_add_port(IN ftree_sw_t * p_sw,

 /***************************************************/

-static inline cl_status_t
+static int
 sw_set_hops(IN ftree_sw_t * p_sw,
-	    IN uint16_t lid_ho, IN uint8_t port_num,
+	    IN uint16_t lid_ho,
+	    IN ftree_port_group_t * p_group,
 	    IN uint8_t hops)
 {
-	/* set local min hop table(LID) */
-	return osm_switch_set_hops(p_sw->p_osm_sw, lid_ho, port_num, hops);
+	ftree_port_t * p_port;
+	uint8_t i, ports_num;
+
+	ports_num = (uint8_t) cl_ptr_vector_get_size(&p_group->ports);
+	for (i = 0; i < ports_num; i++) {
+		cl_ptr_vector_at(&p_group->ports, i, (void *)&p_port);
+		if (osm_switch_set_hops(p_sw->p_osm_sw, lid_ho,
+					p_port->port_num, hops))
+			return -1;
+	}
+	return 0;
 }

 /***************************************************
@@ -2027,19 +2040,11 @@ fabric_route_upgoing_by_going_down(IN ftree_fabric_t * p_ftree,

 			/* On the remote switch that is pointed by the p_group,
 			   set hops for ALL the ports in the remote group. */
-
-			for (j = 0; j < ports_num; j++) {
-				cl_ptr_vector_at(&p_group->ports, j,
-						 (void *)&p_port);
-
-				sw_set_hops(p_remote_sw,
-					cl_ntoh16(target_lid),
-					p_port->remote_port_num,
-					((target_rank - highest_rank_in_route) +
-					 (p_remote_sw->rank - highest_rank_in_route)
-					 + reverse_hops * 2));
-			}
-
+			sw_set_hops(p_remote_sw,
+				cl_ntoh16(target_lid), p_group,
+				((target_rank - highest_rank_in_route) +
+				 (p_remote_sw->rank - highest_rank_in_route) +
+				 reverse_hops * 2));
 		}

 		/* The number of upgoing routes is tracked in the
@@ -2255,19 +2260,10 @@ fabric_route_downgoing_by_going_up(IN ftree_fabric_t * p_ftree,
 			}
 			/* On the remote switch that is pointed by the min_group,
 			   set hops for ALL the ports in the remote group. */
-
-			ports_num =
-			    (uint16_t) cl_ptr_vector_get_size(&p_min_group->
-							      ports);
-			for (j = 0; j < ports_num; j++) {
-				cl_ptr_vector_at(&p_min_group->ports, j,
-						 (void *)&p_port);
-				sw_set_hops(p_remote_sw,
-					    cl_ntoh16(target_lid),
-					    p_port->remote_port_num,
-					    target_rank - p_remote_sw->rank +
-					    2 * reverse_hops);
-			}
+			sw_set_hops(p_remote_sw,
+				cl_ntoh16(target_lid), p_min_group,
+				target_rank - p_remote_sw->rank +
+				2 * reverse_hops);
 		}

 		/* Recursion step:
@@ -2348,17 +2344,9 @@ fabric_route_downgoing_by_going_up(IN ftree_fabric_t * p_ftree,

 		/* On the remote switch that is pointed by the p_group,
 		   set hops for ALL the ports in the remote group. */
-
-		ports_num = (uint16_t) cl_ptr_vector_get_size(&p_group->ports);
-		for (j = 0; j < ports_num; j++) {
-			cl_ptr_vector_at(&p_group->ports, j, (void *)&p_port);
-
-			sw_set_hops(p_remote_sw,
-				    cl_ntoh16(target_lid),
-				    p_port->remote_port_num,
-				    target_rank - p_remote_sw->rank +
-				    2 * reverse_hops);
-		}
+		sw_set_hops(p_remote_sw,
+			cl_ntoh16(target_lid), p_group,
+			target_rank - p_remote_sw->rank + 2 * reverse_hops);

 		/* Recursion step:
 		   Assign downgoing ports by stepping up, starting on REMOTE switch. */
@@ -2475,7 +2463,7 @@ static void fabric_route_to_cns(IN ftree_fabric_t * p_ftree)

 			/* set local min hop table(LID) to route to the CA */
 			sw_set_hops(p_sw, cl_ntoh16(hca_lid),
-				    p_port->port_num, 1);
+				    p_leaf_port_group, 1);

 			/* Assign downgoing ports by stepping up.
 			   Since we're routing here only CNs, we're routing it as REAL
@@ -2550,6 +2538,7 @@ static void fabric_route_to_non_cns(IN ftree_fabric_t * p_ftree)
 	ftree_hca_t *p_next_hca;
 	ftree_port_t *p_hca_port;
 	ftree_port_group_t *p_hca_port_group;
+	ftree_port_group_t *p_sw_port_group;
 	ib_net16_t hca_lid;
 	unsigned port_num_on_switch;
 	unsigned i;
@@ -2587,10 +2576,12 @@ static void fabric_route_to_non_cns(IN ftree_fabric_t * p_ftree)
 				tuple_to_str(p_sw->tuple),
 				cl_ntoh16(hca_lid), port_num_on_switch);

+			p_sw_port_group = sw_get_port_group_by_remote_lid(
+				p_sw, hca_lid, FTREE_DIRECTION_DOWN);
+
 			/* set local min hop table(LID) to route to the CA */
 			sw_set_hops(p_sw, cl_ntoh16(hca_lid),
-				    port_num_on_switch,	/* port num */
-				    1);	/* hops */
+						p_sw_port_group, 1);

 			/* Assign downgoing ports by stepping up.
 			   We're routing REAL targets. They are not CNs and not included
@@ -2618,7 +2609,6 @@ static void fabric_route_to_non_cns(IN ftree_fabric_t * p_ftree)
  * Pseudo code:
  *    foreach switch in fabric
  *       obtain its LID
- *       set local LFT(LID) to port 0
  *       call assign-down-going-port-by-ascending-up(TRUE,FALSE) on CURRENT switch
  *
  * Routing to switch is similar to routing a REAL hca lid on SECONDARY path:
@@ -2646,11 +2636,6 @@ static void fabric_route_to_switches(IN ftree_fabric_t * p_ftree)
 			tuple_to_str(p_sw->tuple),
 			cl_ntoh16(p_sw->base_lid));

-		/* set min hop table of the switch to itself */
-		sw_set_hops(p_sw, cl_ntoh16(p_sw->base_lid),
-			    0,	/* port_num */
-			    0);	/* hops     */
-
 		fabric_route_downgoing_by_going_up(
 			p_ftree, p_sw,	/* local switch - used as a route-downgoing alg. start point */
 			NULL,	/* prev. position switch */
-- 
1.5.1.4




More information about the general mailing list