[ofa-general] [PATCH 1/4] opensm: use only switches min hop vectors

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


Use only switch base LIDs min hop vectors in the best port lookup
routines - osm_switch_recommend*_path().

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
 osm/include/opensm/osm_switch.h |   11 ++++++--
 osm/opensm/osm_mcast_mgr.c      |   11 +++----
 osm/opensm/osm_switch.c         |   53 ++++++++++++++++++++++++++++----------
 osm/opensm/osm_ucast_mgr.c      |   18 +++++++++---
 4 files changed, 65 insertions(+), 28 deletions(-)

diff --git a/osm/include/opensm/osm_switch.h b/osm/include/opensm/osm_switch.h
index 7edacc4..0bb4ca3 100644
--- a/osm/include/opensm/osm_switch.h
+++ b/osm/include/opensm/osm_switch.h
@@ -935,6 +935,7 @@ osm_switch_get_mft_max_position(
 uint8_t
 osm_switch_recommend_path(
 	IN const osm_switch_t* const p_sw,
+	IN osm_port_t *p_port,
 	IN const uint16_t lid_ho,
 	IN const boolean_t ignore_existing,
 	IN OUT uint64_t *remote_sys_guids,
@@ -946,6 +947,10 @@ osm_switch_recommend_path(
 *	p_sw
 *		[in] Pointer to the switch object.
 *
+*	p_port
+*		[in] Pointer to the port object for which to get a path
+*		advisory.
+*
 *	lid_ho
 *		[in] LID value (host order) for which to get a path advisory.
 *
@@ -991,7 +996,7 @@ osm_switch_recommend_path(
 uint8_t
 osm_switch_recommend_mcast_path(
 	IN osm_switch_t* const p_sw,
-	IN const uint16_t lid_ho,
+	IN osm_port_t *p_port,
 	IN const uint16_t mlid_ho,
 	IN const boolean_t ignore_existing );
 /*
@@ -999,8 +1004,8 @@ osm_switch_recommend_mcast_path(
 *	p_sw
 *		[in] Pointer to the switch object.
 *
-*	lid_ho
-*		[in] LID value (host order) for of the node for with to get
+*	p_port
+*		[in] Pointer to the port object for which to get
 *		the multicast path.
 *
 *	mlid_ho
diff --git a/osm/opensm/osm_mcast_mgr.c b/osm/opensm/osm_mcast_mgr.c
index 28c4dcd..4464689 100644
--- a/osm/opensm/osm_mcast_mgr.c
+++ b/osm/opensm/osm_mcast_mgr.c
@@ -531,7 +531,6 @@ __osm_mcast_mgr_subdivide(
 {
   uint8_t                  port_num;
   uint16_t                 mlid_ho;
-  uint16_t                 lid_ho;
   boolean_t                ignore_existing;
   osm_mcast_work_obj_t*    p_wobj;
 
@@ -553,10 +552,8 @@ __osm_mcast_mgr_subdivide(
   while( (p_wobj = (osm_mcast_work_obj_t*)cl_qlist_remove_head( p_list )) !=
          (osm_mcast_work_obj_t*)cl_qlist_end( p_list ) )
   {
-    lid_ho = cl_ntoh16( osm_port_get_base_lid( p_wobj->p_port ) );
-
     port_num = osm_switch_recommend_mcast_path(
-      p_sw, lid_ho, mlid_ho, ignore_existing );
+      p_sw, p_wobj->p_port, mlid_ho, ignore_existing );
 
     if( port_num == OSM_NO_PATH )
     {
@@ -571,7 +568,8 @@ __osm_mcast_mgr_subdivide(
                "Error routing MLID 0x%X through switch 0x%" PRIx64 "\n"
                "\t\t\t\tNo multicast paths from this switch for port "
                "with LID 0x%X\n",
-               mlid_ho, node_guid_ho, lid_ho );
+               mlid_ho, node_guid_ho,
+               cl_ntoh16(osm_port_get_base_lid(p_wobj->p_port)) );
 
       __osm_mcast_work_obj_delete( p_wobj );
       continue;
@@ -585,7 +583,8 @@ __osm_mcast_mgr_subdivide(
                "Error routing MLID 0x%X through switch 0x%" PRIx64 "\n"
                "\t\t\t\tNo multicast paths from this switch to port "
                "with LID 0x%X\n",
-               mlid_ho, node_guid_ho, lid_ho );
+               mlid_ho, node_guid_ho,
+               cl_ntoh16(osm_port_get_base_lid(p_wobj->p_port)) );
 
       __osm_mcast_work_obj_delete( p_wobj );
 
diff --git a/osm/opensm/osm_switch.c b/osm/opensm/osm_switch.c
index 913f34b..1707f9f 100644
--- a/osm/opensm/osm_switch.c
+++ b/osm/opensm/osm_switch.c
@@ -233,6 +233,7 @@ osm_switch_get_fwd_tbl_block(
 uint8_t
 osm_switch_recommend_path(
   IN const osm_switch_t* const p_sw,
+  IN osm_port_t *p_port,
   IN const uint16_t lid_ho,
   IN const boolean_t ignore_existing,
   IN OUT uint64_t *remote_sys_guids,
@@ -254,6 +255,7 @@ osm_switch_recommend_path(
   boolean_t routing_for_lmc = remote_sys_guids && remote_node_guids &&
     p_num_used_sys && p_num_used_nodes;
   boolean_t sys_used, node_used;
+  uint16_t base_lid;
   uint16_t i;
   uint8_t hops;
   uint8_t least_hops;
@@ -281,9 +283,24 @@ osm_switch_recommend_path(
 
   CL_ASSERT( lid_ho > 0 );
 
+  if (p_port->p_node->sw) {
+    if (p_port->p_node->sw == p_sw)
+      return 0;
+    base_lid = osm_port_get_base_lid(p_port);
+  } else {
+    p_physp = osm_port_get_default_phys_ptr(p_port);
+    if (!p_physp || !p_physp->p_remote_physp ||
+        !p_physp->p_remote_physp->p_node->sw)
+      return OSM_NO_PATH;
+    if (p_physp->p_remote_physp->p_node->sw == p_sw)
+      return p_physp->p_remote_physp->port_num;
+    base_lid = osm_node_get_base_lid(p_physp->p_remote_physp->p_node, 0);
+  }
+  base_lid = cl_ntoh16(base_lid);
+
   num_ports = p_sw->num_ports;
 
-  least_hops = osm_switch_get_least_hops( p_sw, lid_ho );
+  least_hops = osm_switch_get_least_hops( p_sw, base_lid );
   if ( least_hops == OSM_NO_PATH )
     return (OSM_NO_PATH);
 
@@ -312,7 +329,7 @@ osm_switch_recommend_path(
           osm_physp_is_healthy(p_physp) &&
           osm_physp_get_remote(p_physp) )
       {
-        hops = osm_switch_get_hop_count( p_sw, lid_ho, port_num );
+        hops = osm_switch_get_hop_count( p_sw, base_lid, port_num );
         /* 
            If we aren't using pre-defined user routes function, then
            we need to make sure that the current path is the minimum one.
@@ -330,9 +347,6 @@ osm_switch_recommend_path(
     }
   }
 
-  if ( osm_node_get_base_lid(p_sw->p_node, 0) == cl_hton16(lid_ho) )
-    return 0;
-
   /*
     This algorithm selects a port based on a static load balanced
     selection across equal hop-count ports.
@@ -350,7 +364,7 @@ osm_switch_recommend_path(
   /* port number starts with zero and num_ports is 1 + num phys ports */
   for ( port_num = 1; port_num < num_ports; port_num++ )
   {
-    if ( osm_switch_get_hop_count( p_sw, lid_ho, port_num ) == least_hops)
+    if ( osm_switch_get_hop_count( p_sw, base_lid, port_num ) == least_hops)
     {
       /* let us make sure it is not down or unhealthy */
       p_physp = osm_node_get_physp_ptr(p_sw->p_node, port_num);
@@ -533,18 +547,32 @@ osm_switch_prepare_path_rebuild(
 uint8_t
 osm_switch_recommend_mcast_path(
   IN osm_switch_t*         const p_sw,
-  IN uint16_t              const lid_ho,
+  IN osm_port_t*           p_port,
   IN uint16_t              const mlid_ho,
   IN boolean_t             const ignore_existing )
 {
+  uint16_t                 base_lid;
   uint8_t                  hops;
   uint8_t                  port_num;
   uint8_t                  num_ports;
   uint8_t                  least_hops;
 
-  CL_ASSERT( lid_ho > 0 );
   CL_ASSERT( mlid_ho >= IB_LID_MCAST_START_HO );
 
+  if (p_port->p_node->sw) {
+    if (p_port->p_node->sw == p_sw)
+      return 0;
+    base_lid = osm_port_get_base_lid(p_port);
+  } else {
+    osm_physp_t *p_physp = osm_port_get_default_phys_ptr(p_port);
+    if (!p_physp || !p_physp->p_remote_physp ||
+        !p_physp->p_remote_physp->p_node->sw)
+      return OSM_NO_PATH;
+    if (p_physp->p_remote_physp->p_node->sw == p_sw)
+      return p_physp->p_remote_physp->port_num;
+    base_lid = osm_node_get_base_lid(p_physp->p_remote_physp->p_node, 0);
+  }
+  base_lid = cl_ntoh16(base_lid);
   num_ports = p_sw->num_ports;
 
   /*
@@ -565,7 +593,7 @@ osm_switch_recommend_mcast_path(
           Don't be too trusting of the current forwarding table!
           Verify that the LID is reachable through this port.
         */
-        hops = osm_switch_get_hop_count( p_sw, lid_ho, port_num );
+        hops = osm_switch_get_hop_count( p_sw, base_lid, port_num );
         if( hops != OSM_NO_PATH )
         {
           return( port_num );
@@ -574,9 +602,6 @@ osm_switch_recommend_mcast_path(
     }
   }
 
-  if (osm_node_get_base_lid(p_sw->p_node, 0) == cl_hton16(lid_ho))
-    return 0;
-
   /*
     Either no existing mcast paths reach this port or we are
     ignoring existing paths.
@@ -591,10 +616,10 @@ osm_switch_recommend_mcast_path(
     multicast packet will go around and around, inevitably creating
     a black hole that will destroy the Earth in a firey conflagration.
   */
-  least_hops = osm_switch_get_least_hops( p_sw, lid_ho );
+  least_hops = osm_switch_get_least_hops( p_sw, base_lid );
   for( port_num = 1; port_num < num_ports; port_num++ )
   {
-    if( osm_switch_get_hop_count( p_sw, lid_ho, port_num ) == least_hops )
+    if( osm_switch_get_hop_count( p_sw, base_lid, port_num ) == least_hops )
       break;
   }
 
diff --git a/osm/opensm/osm_ucast_mgr.c b/osm/opensm/osm_ucast_mgr.c
index ee6b3f9..c674d6d 100644
--- a/osm/opensm/osm_ucast_mgr.c
+++ b/osm/opensm/osm_ucast_mgr.c
@@ -248,6 +248,7 @@ __osm_ucast_mgr_dump_ucast_routes(
   IN void *cxt )
 {
   const osm_node_t*        p_node;
+  osm_port_t *             p_port;
   uint8_t                  port_num;
   uint8_t                  num_hops;
   uint8_t                  best_hops;
@@ -272,6 +273,13 @@ __osm_ucast_mgr_dump_ucast_routes(
   {
     fprintf(file, "0x%04X : ", lid_ho);
 
+    p_port = cl_ptr_vector_get(&p_mgr->p_subn->port_lid_tbl, lid_ho);
+    if (!p_port)
+    {
+      fprintf( file, "UNREACHABLE\n" );
+      continue;
+    }
+
     port_num = osm_switch_get_port_by_lid( p_sw, lid_ho );
     if( port_num == OSM_NO_PATH )
     {
@@ -305,7 +313,7 @@ __osm_ucast_mgr_dump_ucast_routes(
     else
     {
       best_port = osm_switch_recommend_path(
-        p_sw, lid_ho, TRUE,
+        p_sw, p_port, lid_ho, TRUE,
         NULL, NULL, NULL, NULL ); /* No LMC Optimization */
       fprintf( file, "No %u hop path possible via port %u!",
                best_hops, best_port );
@@ -689,7 +697,7 @@ static void
 __osm_ucast_mgr_process_port(
   IN osm_ucast_mgr_t* const p_mgr,
   IN osm_switch_t* const p_sw,
-  IN const osm_port_t* const p_port )
+  IN osm_port_t* const p_port )
 {
   uint16_t min_lid_ho;
   uint16_t max_lid_ho;
@@ -775,12 +783,12 @@ __osm_ucast_mgr_process_port(
   {
     /* Use the enhanced algorithm only for LMC > 0 */
     if (lids_per_port > 1)
-      port = osm_switch_recommend_path( p_sw, lid_ho,
+      port = osm_switch_recommend_path( p_sw, p_port, lid_ho,
                                         p_mgr->p_subn->ignore_existing_lfts,
                                         remote_sys_guids, &num_used_sys,
                                         remote_node_guids, &num_used_nodes );
     else
-      port = osm_switch_recommend_path( p_sw, lid_ho,
+      port = osm_switch_recommend_path( p_sw, p_port, lid_ho,
                                         p_mgr->p_subn->ignore_existing_lfts,
                                         NULL, NULL, NULL, NULL );
 
@@ -1009,7 +1017,7 @@ __osm_ucast_mgr_process_tbl(
   osm_switch_t* const p_sw = (osm_switch_t*)p_map_item;
   osm_ucast_mgr_t* const p_mgr = (osm_ucast_mgr_t*)context;
   osm_node_t *p_node;
-  const osm_port_t *p_port;
+  osm_port_t *p_port;
   const cl_qmap_t* p_port_tbl;
 
   OSM_LOG_ENTER( p_mgr->p_log, __osm_ucast_mgr_process_tbl );
-- 
1.5.0.3.307.gcf89




More information about the general mailing list