[ofa-general] [PATCH 3/4] opensm: build min hop tables only for switches base LIDs

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


up/down and default min hop builder will calculate min hop matrices
only for switches base LIDs - don't bother with CA or router ports and
LMC.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
 osm/opensm/osm_ucast_mgr.c  |  280 ++++++------------------------------------
 osm/opensm/osm_ucast_updn.c |   96 ---------------
 2 files changed, 40 insertions(+), 336 deletions(-)

diff --git a/osm/opensm/osm_ucast_mgr.c b/osm/opensm/osm_ucast_mgr.c
index c674d6d..4746d19 100644
--- a/osm/opensm/osm_ucast_mgr.c
+++ b/osm/opensm/osm_ucast_mgr.c
@@ -412,59 +412,35 @@ static void __osm_ucast_mgr_dump_tables(osm_ucast_mgr_t *p_mgr)
 }
 
 /**********************************************************************
- Add each switch's own LID(s) to its LID matrix
+ Add each switch's own and neighbor LIDs to its LID matrix
 **********************************************************************/
 static void
-__osm_ucast_mgr_process_hop_0(
+__osm_ucast_mgr_process_hop_0_1(
   IN cl_map_item_t* const  p_map_item,
   IN void* context )
 {
   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;
-  uint16_t lid_ho, base_lid_ho, max_lid_ho;
-  cl_status_t status;
-  uint8_t lmc;
-
-  OSM_LOG_ENTER( p_mgr->p_log, __osm_ucast_mgr_process_hop_0 );
-
-  p_node = p_sw->p_node;
-
-  CL_ASSERT( p_node );
-  CL_ASSERT( osm_node_get_type( p_node ) == IB_NODE_TYPE_SWITCH );
+  osm_node_t *p_remote_node;
+  uint16_t lid, remote_lid;
+  uint8_t i, remote_port;
 
-  base_lid_ho = cl_ntoh16( osm_node_get_base_lid( p_node, 0 ) );
-  if (osm_switch_sp0_is_lmc_capable( p_sw, p_mgr->p_subn ))
-    lmc = osm_node_get_lmc( p_node, 0 );
-  else
-    lmc = 0;
-  max_lid_ho = (uint16_t)( base_lid_ho + (1 << lmc) - 1 );
+  lid = osm_node_get_base_lid(p_sw->p_node, 0);
+  lid = cl_ntoh16(lid);
+  osm_switch_set_hops(p_sw, lid, 0, 0);
 
-  for (lid_ho = base_lid_ho; lid_ho <= max_lid_ho; lid_ho++)
+  for( i = 1; i < p_sw->num_ports; i++ )
   {
-    if( osm_log_is_active( p_mgr->p_log, OSM_LOG_DEBUG ) )
-    {
-      osm_log( p_mgr->p_log, OSM_LOG_DEBUG,
-               "__osm_ucast_mgr_process_hop_0: "
-               "Processing switch GUID 0x%" PRIx64 ", LID 0x%X\n",
-               cl_ntoh64( osm_node_get_node_guid( p_node ) ),
-               lid_ho );
-    }
+    p_remote_node = osm_node_get_remote_node( p_sw->p_node, i, &remote_port );
 
-    status = osm_switch_set_hops( p_sw, lid_ho, 0, 0 );
-    if( status != CL_SUCCESS )
+    if( p_remote_node && p_remote_node->sw &&
+        (p_remote_node != p_sw->p_node ) )
     {
-      osm_log( p_mgr->p_log, OSM_LOG_ERROR,
-               "__osm_ucast_mgr_process_hop_0: ERR 3A02: "
-               "Setting hop count failed (%s) for "
-               "switch GUID 0x%" PRIx64 ", LID 0x%X\n",
-               CL_STATUS_MSG( status ),
-               cl_ntoh64( osm_node_get_node_guid( p_node ) ),
-               lid_ho );
+      remote_lid = osm_node_get_base_lid(p_remote_node, 0);
+      remote_lid = cl_ntoh16(remote_lid);
+      osm_switch_set_hops( p_sw, remote_lid, i, 1 );
+      osm_switch_set_hops( p_remote_node->sw, lid, remote_port, 1 );
     }
   }
-
-  OSM_LOG_EXIT( p_mgr->p_log );
 }
 
 /**********************************************************************
@@ -472,219 +448,47 @@ __osm_ucast_mgr_process_hop_0(
 static void
 __osm_ucast_mgr_process_neighbor(
   IN osm_ucast_mgr_t* const p_mgr,
-  IN osm_switch_t* const p_sw,
+  IN osm_switch_t* const p_this_sw,
   IN osm_switch_t* const p_remote_sw,
   IN const uint8_t port_num,
   IN const uint8_t remote_port_num )
 {
+  osm_switch_t *p_sw, *p_next_sw;
   uint16_t lid_ho;
-  uint16_t max_lid_ho;
-  osm_node_t* p_node;
-  const osm_node_t* p_remote_node;
   uint8_t hops;
-  cl_status_t status;
 
   OSM_LOG_ENTER( p_mgr->p_log, __osm_ucast_mgr_process_neighbor );
 
-  CL_ASSERT( p_sw );
-  CL_ASSERT( p_remote_sw );
-  CL_ASSERT( port_num );
-  CL_ASSERT( remote_port_num );
-
-  p_node = p_sw->p_node;
-  p_remote_node = p_remote_sw->p_node;
-
-  CL_ASSERT( p_node );
-  CL_ASSERT( p_remote_node );
-
-  CL_ASSERT( osm_node_get_type( p_node ) == IB_NODE_TYPE_SWITCH );
-  CL_ASSERT( osm_node_get_type( p_remote_node ) == IB_NODE_TYPE_SWITCH );
-
   if( osm_log_is_active( p_mgr->p_log, OSM_LOG_DEBUG ) )
   {
     osm_log( p_mgr->p_log, OSM_LOG_DEBUG,
              "__osm_ucast_mgr_process_neighbor: "
              "Node 0x%" PRIx64 ", remote node 0x%" PRIx64
              ", port 0x%X, remote port 0x%X\n",
-             cl_ntoh64( osm_node_get_node_guid( p_node ) ),
-             cl_ntoh64( osm_node_get_node_guid( p_remote_node ) ),
+             cl_ntoh64( osm_node_get_node_guid( p_this_sw->p_node ) ),
+             cl_ntoh64( osm_node_get_node_guid( p_remote_sw->p_node ) ),
              port_num, remote_port_num );
   }
 
-  /*
-    Iterate through all the LIDs in the neighbor switch.
-  */
-  max_lid_ho = p_remote_sw->max_lid_ho;
-
-  hops = OSM_NO_PATH;
-  for( lid_ho = 1; lid_ho <= max_lid_ho; lid_ho++ )
-  {
-    /*
-      Find the lowest hop count value to this LID.
-    */
-      hops = osm_switch_get_least_hops( p_remote_sw, lid_ho );
-
-      if( hops != OSM_NO_PATH )
-      {
-        /*
-          Increment hop count of the neighbor by 1, since it
-          takes 1 hop to get to the neighbor.
-        */
-        hops++;
-
-        CL_ASSERT( hops <= osm_switch_get_hop_count( p_sw, lid_ho,
-                                                     port_num ) );
-        if( osm_switch_get_hop_count( p_sw, lid_ho,
-                                      port_num ) > hops )
-        {
-          if( osm_log_is_active( p_mgr->p_log, OSM_LOG_DEBUG ) )
-          {
-            osm_log( p_mgr->p_log, OSM_LOG_DEBUG,
-                     "__osm_ucast_mgr_process_neighbor: "
-                     "New best path is %u hops for LID 0x%X\n",
-                     hops, lid_ho );
-          }
-
-          /* mark the fact we have got to change anything */
-          __some_hop_count_set = TRUE;
-
-          status = osm_switch_set_hops( p_sw, lid_ho,
-                                        port_num, hops );
-          if( status != CL_SUCCESS )
-          {
-            osm_log( p_mgr->p_log, OSM_LOG_ERROR,
-                     "__osm_ucast_mgr_process_neighbor: ERR 3A03: "
-                     "Setting hop count failed (%s)\n",
-                     CL_STATUS_MSG( status ) );
-          }
-        }
-      }
-  }
-
-  OSM_LOG_EXIT( p_mgr->p_log );
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_ucast_mgr_process_leaf(
-  IN osm_ucast_mgr_t* const p_mgr,
-  IN osm_switch_t* const p_sw,
-  IN osm_node_t* const p_node,
-  IN const uint8_t port_num,
-  IN osm_node_t* const p_remote_node,
-  IN const uint8_t remote_port_num )
-{
-  uint16_t i;
-  uint16_t base_lid_ho;
-  uint16_t max_lid_ho;
-  uint8_t lmc;
-
-  OSM_LOG_ENTER( p_mgr->p_log, __osm_ucast_mgr_process_leaf );
-
-  CL_ASSERT( p_node );
-  CL_ASSERT( p_remote_node );
-  CL_ASSERT( port_num );
-  CL_ASSERT( remote_port_num );
-
-  switch( osm_node_get_type( p_remote_node ) )
+  p_next_sw = (osm_switch_t*)cl_qmap_head( &p_mgr->p_subn->sw_guid_tbl );
+  while( p_next_sw != (osm_switch_t*)cl_qmap_end( &p_mgr->p_subn->sw_guid_tbl ) )
   {
-  case IB_NODE_TYPE_CA:
-  case IB_NODE_TYPE_ROUTER:
-    base_lid_ho = cl_ntoh16( osm_node_get_base_lid(
-                               p_remote_node, remote_port_num ) );
-    lmc = osm_node_get_lmc( p_remote_node, remote_port_num );
-    break;
-#if 0
-  case IB_NODE_TYPE_SWITCH:
-    base_lid_ho = cl_ntoh16( osm_node_get_base_lid(
-                               p_remote_node, 0 ) );
-    lmc = 0;
-    break;
-#endif
-
-  default:
-    osm_log( p_mgr->p_log, OSM_LOG_ERROR,
-             "__osm_ucast_mgr_process_leaf: ERR 3A01: "
-             "Bad node type %u, GUID 0x%" PRIx64 "\n",
-             osm_node_get_type( p_remote_node ),
-             cl_ntoh64( osm_node_get_node_guid( p_node ) ));
-    goto Exit;
-  }
-
-  max_lid_ho = (uint16_t)(base_lid_ho + (1 << lmc) - 1 );
-
-  if( osm_log_is_active( p_mgr->p_log, OSM_LOG_DEBUG ) )
-  {
-    osm_log( p_mgr->p_log, OSM_LOG_DEBUG,
-             "__osm_ucast_mgr_process_leaf: "
-             "Discovered LIDs [0x%X,0x%X]\n"
-             "\t\t\t\tport number 0x%X, node 0x%" PRIx64 "\n",
-             base_lid_ho, max_lid_ho,
-             port_num, cl_ntoh64( osm_node_get_node_guid( p_node ) ));
-  }
-
-  for( i = base_lid_ho; i <= max_lid_ho; i++ )
-    osm_switch_set_hops( p_sw, i, port_num, 1 );
-
- Exit:
-  OSM_LOG_EXIT( p_mgr->p_log );
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_ucast_mgr_process_leaves(
-  IN cl_map_item_t* const  p_map_item,
-  IN void* context )
-{
-  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;
-  osm_node_t *p_remote_node;
-  uint32_t port_num;
-  uint8_t remote_port_num;
-  uint32_t num_ports;
-
-  OSM_LOG_ENTER( p_mgr->p_log, __osm_ucast_mgr_process_leaves );
-
-  p_node = p_sw->p_node;
-
-  CL_ASSERT( p_node );
-  CL_ASSERT( osm_node_get_type( p_node ) == IB_NODE_TYPE_SWITCH );
-
-  if( osm_log_is_active( p_mgr->p_log, OSM_LOG_DEBUG ) )
-  {
-    osm_log( p_mgr->p_log, OSM_LOG_DEBUG,
-             "__osm_ucast_mgr_process_leaves: "
-             "Processing switch 0x%" PRIx64 "\n",
-             cl_ntoh64( osm_node_get_node_guid( p_node ) ));
-  }
-
-  /*
-    Add the LIDs of all leaves of this switch to the LID matrix.
-    Don't bother processing loopback paths from one port of
-    this switch to the another port.
-    Don't process neighbor switches yet.
-    Start with port 1 to skip the switch's management port.
-  */
-  num_ports = osm_node_get_num_physp( p_node );
-
-  for( port_num = 1; port_num < num_ports; port_num++ )
-  {
-    p_remote_node = osm_node_get_remote_node( p_node,
-                                              (uint8_t)port_num, &remote_port_num );
-
-    if( p_remote_node && (p_remote_node != p_node )
-        && (osm_node_get_type( p_remote_node ) != IB_NODE_TYPE_SWITCH ) )
-    {
-      __osm_ucast_mgr_process_leaf(
-        p_mgr,
-        p_sw,
-        p_node,
-        (uint8_t)port_num,
-        p_remote_node,
-        remote_port_num );
+    p_sw = p_next_sw;
+    p_next_sw = (osm_switch_t*)cl_qmap_next( &p_sw->map_item );
+    lid_ho = osm_node_get_base_lid(p_sw->p_node, 0);
+    lid_ho = cl_ntoh16(lid_ho);
+    hops = osm_switch_get_least_hops(p_remote_sw, lid_ho);
+    if (hops == OSM_NO_PATH)
+      continue;
+    hops++;
+    if (hops < osm_switch_get_hop_count(p_this_sw, lid_ho, port_num)) {
+      if (osm_switch_set_hops(p_this_sw, lid_ho, port_num, hops) != 0)
+        osm_log( p_mgr->p_log, OSM_LOG_ERROR,
+                 "__osm_ucast_mgr_process_neighbor: "
+                 "cannot set hops for lid %u at switch 0x%" PRIx64 "\n",
+                 lid_ho, 
+                 cl_ntoh64(osm_node_get_node_guid(p_this_sw->p_node)));
+      __some_hop_count_set = TRUE;
     }
   }
 
@@ -1098,8 +902,7 @@ __osm_ucast_mgr_process_neighbors(
     p_remote_node = osm_node_get_remote_node( p_node,
                                               (uint8_t)port_num, &remote_port_num );
 
-    if( p_remote_node && (p_remote_node != p_node )
-        && p_remote_node->sw )
+    if( p_remote_node && p_remote_node->sw && (p_remote_node != p_node ) )
     {
       /* make sure the link is healthy. If it is not - don't 
          propagate through it. */
@@ -1137,10 +940,7 @@ osm_ucast_mgr_build_lid_matrices(
     then set the lid matrices for the each switch's leaf nodes.
   */
   cl_qmap_apply_func( p_sw_guid_tbl,
-                      __osm_ucast_mgr_process_hop_0, p_mgr );
-
-  cl_qmap_apply_func( p_sw_guid_tbl,
-                      __osm_ucast_mgr_process_leaves, p_mgr );
+                      __osm_ucast_mgr_process_hop_0_1, p_mgr );
 
   /*
     Get the switch matrices for each switch's neighbors.
diff --git a/osm/opensm/osm_ucast_updn.c b/osm/opensm/osm_ucast_updn.c
index 1ec9017..b15fe5e 100644
--- a/osm/opensm/osm_ucast_updn.c
+++ b/osm/opensm/osm_ucast_updn.c
@@ -509,54 +509,6 @@ updn_subn_rank(
 /**********************************************************************
  **********************************************************************/
 static int
-populate_min_hops_for_cas(
-  osm_subn_t *p_subn,
-  osm_switch_t *p_sw )
-{
-  osm_port_t *p_next_port,*p_port;
-  osm_physp_t *p_physp;
-  uint16_t lid, sw_lid;
-  uint8_t i, hops;
-
-  p_next_port = (osm_port_t*)cl_qmap_head( &p_subn->port_guid_tbl );
-  while( p_next_port != (osm_port_t*)cl_qmap_end( &p_subn->port_guid_tbl ) )
-  {
-    p_port = p_next_port;
-    p_next_port = (osm_port_t*)cl_qmap_next( &p_port->map_item );
-
-    if (p_port->p_node->sw)
-      continue;
-    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)
-      continue;
-
-    lid = osm_physp_get_base_lid(p_physp);
-    lid = cl_ntoh16(lid);
-
-    if (p_physp->p_remote_physp->p_node->sw == p_sw)
-    {
-      osm_switch_set_hops(p_sw, lid, p_physp->p_remote_physp->port_num, 1);
-      continue;
-    }
-
-    sw_lid = osm_node_get_base_lid(p_physp->p_remote_physp->p_node, 0);
-    sw_lid = cl_ntoh16(sw_lid);
-
-    for (i = 1 ; i < p_sw->num_ports ; i++)
-    {
-      hops = osm_switch_get_hop_count(p_sw, sw_lid, i);
-      if (hops == OSM_NO_PATH)
-        continue;
-      osm_switch_set_hops(p_sw, lid, i, hops + 1);
-    }
-  }
-  return 0;
-}
-
-/**********************************************************************
- **********************************************************************/
-static int
 __osm_subn_set_up_down_min_hop_table(
   IN updn_t* p_updn )
 {
@@ -598,14 +550,6 @@ __osm_subn_set_up_down_min_hop_table(
     __updn_bfs_by_node(p_log, p_subn, p_sw);
   }
 
-  p_next_sw = (osm_switch_t*)cl_qmap_head( &p_subn->sw_guid_tbl );
-  while( p_next_sw != (osm_switch_t*)cl_qmap_end( &p_subn->sw_guid_tbl ) )
-  {
-    p_sw = p_next_sw;
-    p_next_sw = (osm_switch_t*)cl_qmap_next( &p_sw->map_item );
-    populate_min_hops_for_cas(p_subn, p_sw);
-  }
-
   osm_log( p_log, OSM_LOG_VERBOSE,
            "__osm_subn_set_up_down_min_hop_table: "
            "BFS through all port guids in the subnet ]\n" );
@@ -668,44 +612,6 @@ __osm_subn_calc_up_down_min_hop_table(
 
 /**********************************************************************
  **********************************************************************/
-static void
-expand_lid_matrices_for_lmc(
-  osm_subn_t *p_subn )
-{
-  cl_map_item_t *p_next_port, *p_next_sw;
-  osm_port_t *p_port;
-  osm_switch_t *p_sw;
-  uint16_t lid, min_lid, max_lid;
-  uint8_t port, num_ports, hops;
-
-  p_next_port = cl_qmap_head( &p_subn->port_guid_tbl );
-  while (p_next_port != cl_qmap_end(&p_subn->port_guid_tbl))
-  {
-    p_port = (osm_port_t *)p_next_port;
-    p_next_port = cl_qmap_next(p_next_port);
-    if (p_port->p_node->sw &&
-        !osm_switch_sp0_is_lmc_capable(p_port->p_node->sw, p_subn))
-      continue;
-    osm_port_get_lid_range_ho(p_port, &min_lid, &max_lid);
-    if (!min_lid || min_lid == max_lid)
-      continue;
-    p_next_sw = cl_qmap_head(&p_subn->sw_guid_tbl);
-    while (p_next_sw != cl_qmap_end(&p_subn->sw_guid_tbl))
-    {
-      p_sw = (osm_switch_t *)p_next_sw;
-      p_next_sw = cl_qmap_next(p_next_sw);
-      num_ports = p_sw->num_ports;
-      for (port = 0; port < num_ports; port++) {
-        hops = osm_switch_get_hop_count(p_sw, min_lid, port);
-        for (lid = min_lid + 1 ; lid <= max_lid; lid++)
-          osm_switch_set_hops(p_sw, lid, port, hops);
-      }
-    }
-  }
-}
-
-/**********************************************************************
- **********************************************************************/
 static struct updn_node *
 create_updn_node(
   osm_switch_t *sw )
@@ -774,8 +680,6 @@ __osm_updn_call(
     __osm_subn_calc_up_down_min_hop_table( p_updn->updn_ucast_reg_inputs.num_guids,
                                            p_updn->updn_ucast_reg_inputs.guid_list,
                                            p_updn );
-    if (p_updn->p_osm->subn.opt.lmc)
-      expand_lid_matrices_for_lmc(&p_updn->p_osm->subn);
   }
   else
     osm_log( &p_updn->p_osm->log, OSM_LOG_INFO,
-- 
1.5.0.3.307.gcf89




More information about the general mailing list