[ofa-general] [PATCH 2/4] opensm: mcast_mgr uses osm_switch_get_port_least_hops()

Sasha Khapyorsky sashak at voltaire.com
Thu Mar 8 05:45:04 PST 2007


Instead of the direct accessing min hop tables mcast_mgr uses function
osm_switch_get_port_least_hops() which will evaluate only switches' base
LID min hop vectors.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
 osm/include/opensm/osm_switch.h |   33 +++++++++++++++++++++++++++++++++
 osm/opensm/osm_mcast_mgr.c      |    8 ++------
 osm/opensm/osm_switch.c         |   26 ++++++++++++++++++++++++++
 3 files changed, 61 insertions(+), 6 deletions(-)

diff --git a/osm/include/opensm/osm_switch.h b/osm/include/opensm/osm_switch.h
index 0bb4ca3..f224468 100644
--- a/osm/include/opensm/osm_switch.h
+++ b/osm/include/opensm/osm_switch.h
@@ -373,6 +373,39 @@ osm_switch_get_least_hops(
 *	Switch object
 *********/
 
+/****f* OpenSM: Switch/osm_switch_get_port_least_hops
+* NAME
+*	osm_switch_get_port_least_hops
+*
+* DESCRIPTION
+*	Returns the number of hops in the short path to this port from
+*	any port on the switch.
+*
+* SYNOPSIS
+*/
+uint8_t
+osm_switch_get_port_least_hops(
+	IN const osm_switch_t* const p_sw,
+	IN const osm_port_t *p_port );
+/*
+* PARAMETERS
+*	p_sw
+*		[in] Pointer to an osm_switch_t object.
+*
+*	p_port
+*		[in] Pointer to an osm_port_t object for which to
+*		retrieve the shortest hop count.
+*
+* RETURN VALUES
+*	Returns the number of hops in the short path to this lid from
+*	any port on the switch.
+*
+* NOTES
+*
+* SEE ALSO
+*	Switch object
+*********/
+
 /****f* OpenSM: Switch/osm_switch_get_port_by_lid
 * NAME
 *	osm_switch_get_port_by_lid
diff --git a/osm/opensm/osm_mcast_mgr.c b/osm/opensm/osm_mcast_mgr.c
index 4464689..0cdcc0e 100644
--- a/osm/opensm/osm_mcast_mgr.c
+++ b/osm/opensm/osm_mcast_mgr.c
@@ -156,7 +156,6 @@ osm_mcast_mgr_compute_avg_hops(
   float avg_hops = 0;
   uint32_t hops = 0;
   uint32_t num_ports = 0;
-  uint16_t base_lid_ho;
   const osm_port_t* p_port;
   const osm_mcm_port_t* p_mcm_port;
   const cl_qmap_t* p_mcm_tbl;
@@ -191,8 +190,7 @@ osm_mcast_mgr_compute_avg_hops(
       continue;
     }
 
-    base_lid_ho = cl_ntoh16( osm_port_get_base_lid( p_port ) );
-    hops += osm_switch_get_least_hops( p_sw, base_lid_ho );
+    hops += osm_switch_get_port_least_hops( p_sw, p_port );
     num_ports++;
   }
 
@@ -220,7 +218,6 @@ osm_mcast_mgr_compute_max_hops(
 {
   uint32_t max_hops = 0;
   uint32_t hops = 0;
-  uint16_t base_lid_ho;
   const osm_port_t* p_port;
   const osm_mcm_port_t* p_mcm_port;
   const cl_qmap_t* p_mcm_tbl;
@@ -256,8 +253,7 @@ osm_mcast_mgr_compute_max_hops(
       continue;
     }
 
-    base_lid_ho = cl_ntoh16( osm_port_get_base_lid( p_port ) );
-    hops = osm_switch_get_least_hops( p_sw, base_lid_ho );
+    hops = osm_switch_get_port_least_hops( p_sw, p_port );
     if (hops > max_hops)
       max_hops = hops;
   }
diff --git a/osm/opensm/osm_switch.c b/osm/opensm/osm_switch.c
index 1707f9f..b11abe4 100644
--- a/osm/opensm/osm_switch.c
+++ b/osm/opensm/osm_switch.c
@@ -545,6 +545,32 @@ osm_switch_prepare_path_rebuild(
 /**********************************************************************
  **********************************************************************/
 uint8_t
+osm_switch_get_port_least_hops(
+	IN const osm_switch_t* const p_sw,
+	IN const osm_port_t *p_port )
+{
+	uint16_t lid;
+	if (p_port->p_node->sw) {
+		if (p_port->p_node->sw == p_sw)
+			return 0;
+		lid = osm_node_get_base_lid(p_port->p_node, 0);
+		return osm_switch_get_least_hops(p_sw, cl_ntoh16(lid));
+	} else {
+		osm_physp_t *p = osm_port_get_default_phys_ptr(p_port);
+		uint8_t hops;
+		if (!p || !p->p_remote_physp || !p->p_remote_physp->p_node->sw)
+			return OSM_NO_PATH;
+		if (p->p_remote_physp->p_node->sw == p_sw)
+			return 1;
+		lid = osm_node_get_base_lid(p->p_remote_physp->p_node, 0);
+		hops = osm_switch_get_least_hops(p_sw, cl_ntoh16(lid));
+		return hops != OSM_NO_PATH ? hops + 1 : OSM_NO_PATH;
+	}
+}
+
+/**********************************************************************
+ **********************************************************************/
+uint8_t
 osm_switch_recommend_mcast_path(
   IN osm_switch_t*         const p_sw,
   IN osm_port_t*           p_port,
-- 
1.5.0.3.307.gcf89




More information about the general mailing list