[openib-general] [PATCH] opensm: switch pointer field for osm_node_t structure

Sasha Khapyorsky sashak at voltaire.com
Tue Jan 2 14:35:01 PST 2007


This introduces new field for osm_node_t structure. For switch nodes
this field keeps pointer to corresponded osm_switch_t object, for non
switch nodes it is initialized as NULL. This new field is useful for
fast switch object access and for node type detection.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
 osm/include/opensm/osm_node.h        |   20 +++++++++----
 osm/opensm/osm_drop_mgr.c            |   23 ++-------------
 osm/opensm/osm_lid_mgr.c             |   51 ++++++---------------------------
 osm/opensm/osm_link_mgr.c            |    6 +--
 osm/opensm/osm_mcast_mgr.c           |    9 ++----
 osm/opensm/osm_node_info_rcv.c       |    9 +----
 osm/opensm/osm_pkey_mgr.c            |   17 ++---------
 osm/opensm/osm_port.c                |   17 +----------
 osm/opensm/osm_port_info_rcv.c       |   34 ++++++----------------
 osm/opensm/osm_qos.c                 |   15 +++------
 osm/opensm/osm_sa_multipath_record.c |   46 ++++--------------------------
 osm/opensm/osm_sa_path_record.c      |   48 ++++---------------------------
 osm/opensm/osm_sa_portinfo_record.c  |   11 ++-----
 osm/opensm/osm_sw_info_rcv.c         |   12 +++----
 osm/opensm/osm_ucast_mgr.c           |   25 ++--------------
 osm/opensm/osm_ucast_updn.c          |   19 ++++--------
 16 files changed, 85 insertions(+), 277 deletions(-)

diff --git a/osm/include/opensm/osm_node.h b/osm/include/opensm/osm_node.h
index d595abb..8417f10 100644
--- a/osm/include/opensm/osm_node.h
+++ b/osm/include/opensm/osm_node.h
@@ -65,6 +65,8 @@
 
 BEGIN_C_DECLS
 
+struct _osm_switch;
+
 /****h* OpenSM/Node
 * NAME
 *	Node
@@ -99,18 +101,24 @@ BEGIN_C_DECLS
 */
 typedef struct _osm_node
 {
-	cl_map_item_t				map_item;
-	ib_node_info_t				node_info;
-	ib_node_desc_t				node_desc;
-	uint32_t				discovery_count;
-	uint32_t				physp_tbl_size;
-	osm_physp_t				physp_table[1];
+	cl_map_item_t	map_item;
+	struct _osm_switch *sw;
+	ib_node_info_t	node_info;
+	ib_node_desc_t	node_desc;
+	uint32_t	discovery_count;
+	uint32_t	physp_tbl_size;
+	osm_physp_t	physp_table[1];
 } osm_node_t;
 /*
 * FIELDS
 *	map_item
 *		Linkage structure for cl_qmap.  MUST BE FIRST MEMBER!
 *
+*	sw
+*		For switch node contains pointer to appropriate osm_switch
+*		structure. NULL for non-switch nodes. Can be used for fast
+*		access to switch object and for simple node type detection
+*
 *	node_info
 *		The IBA defined NodeInfo data for this node.
 *
diff --git a/osm/opensm/osm_drop_mgr.c b/osm/opensm/osm_drop_mgr.c
index 5031f3b..8f605a7 100644
--- a/osm/opensm/osm_drop_mgr.c
+++ b/osm/opensm/osm_drop_mgr.c
@@ -387,6 +387,7 @@ __osm_drop_mgr_remove_switch(
   }
   else
   {
+    p_node->sw = NULL;
     osm_switch_delete( &p_sw );
   }
 
@@ -440,24 +441,8 @@ __osm_drop_mgr_process_node(
 
   return_val = TRUE;
 
-  switch( osm_node_get_type( p_node ) )
-  {
-  case IB_NODE_TYPE_CA:
-  case IB_NODE_TYPE_ROUTER:
-    break;
-
-  case IB_NODE_TYPE_SWITCH:
+  if (p_node->sw)
     __osm_drop_mgr_remove_switch( p_mgr, p_node );
-    break;
-
-  default:
-    osm_log( p_mgr->p_log, OSM_LOG_ERROR,
-             "__osm_drop_mgr_process_node: ERR 0104: "
-             "Node 0x%016" PRIx64 " unknown node type: %u\n",
-             cl_ntoh64( osm_node_get_node_guid( p_node ) ),
-             osm_node_get_type( p_node ) );
-    break;
-  }
 
   p_node_guid_tbl = &p_mgr->p_subn->node_guid_tbl;
   p_node_check = (osm_node_t*)cl_qmap_remove( p_node_guid_tbl,
@@ -484,7 +469,6 @@ __osm_drop_mgr_check_node(
   IN const osm_drop_mgr_t* const p_mgr,
   IN osm_node_t* p_node )
 {
-  osm_switch_t *p_sw;
   ib_net64_t node_guid;
   osm_physp_t *p_physp;
   osm_port_t *p_port;
@@ -505,8 +489,7 @@ __osm_drop_mgr_check_node(
   }
 
   /* Make sure we have a switch object for this node */
-  p_sw = osm_get_switch_by_guid( p_mgr->p_subn, node_guid );
-  if (!p_sw)
+  if (!p_node->sw)
   {
     /* We do not have switch info for this node */
     osm_log( p_mgr->p_log, OSM_LOG_VERBOSE,
diff --git a/osm/opensm/osm_lid_mgr.c b/osm/opensm/osm_lid_mgr.c
index 3f0b131..aba243a 100644
--- a/osm/opensm/osm_lid_mgr.c
+++ b/osm/opensm/osm_lid_mgr.c
@@ -361,7 +361,6 @@ __osm_lid_mgr_init_sweep(
   osm_lid_mgr_range_t *p_range = NULL;
   osm_port_t          *p_port;
   cl_qmap_t           *p_port_guid_tbl;
-  osm_switch_t        *p_sw;
   uint8_t              lmc_num_lids = (uint8_t)(1 << p_mgr->p_subn->opt.lmc);
   uint16_t             lmc_mask;
   uint16_t             req_lid, num_lids;
@@ -445,19 +444,11 @@ __osm_lid_mgr_init_sweep(
                               cl_ntoh64(osm_port_get_guid(p_port)),
                               &db_min_lid, &db_max_lid))
     {
-      if ( osm_node_get_type( osm_port_get_parent_node( p_port ) ) !=
-           IB_NODE_TYPE_SWITCH )
+      if ( !p_port->p_node->sw ||
+           osm_switch_sp0_is_lmc_capable(p_port->p_node->sw, p_mgr->p_subn))
         num_lids = lmc_num_lids;
       else
-      {
-        /* Determine if enhanced switch port 0 */
-        p_sw = osm_get_switch_by_guid(p_mgr->p_subn,
-                                      osm_node_get_node_guid(osm_port_get_parent_node(p_port)));
-        if (osm_switch_sp0_is_lmc_capable(p_sw, p_mgr->p_subn))
-          num_lids = lmc_num_lids;
-        else
-          num_lids = 1;
-      }
+        num_lids = 1;
 
       if ((num_lids != 1) &&
           (((db_min_lid & lmc_mask) != db_min_lid) ||
@@ -552,27 +543,14 @@ __osm_lid_mgr_init_sweep(
           /* get the lid range of that port, and the required number
              of lids we are about to assign to it */
           osm_port_get_lid_range_ho(p_port, &disc_min_lid, &disc_max_lid);
-          if ( osm_node_get_type( osm_port_get_parent_node( p_port ) ) !=
-               IB_NODE_TYPE_SWITCH )
+          if ( !p_port->p_node->sw ||
+               osm_switch_sp0_is_lmc_capable(p_port->p_node->sw, p_mgr->p_subn))
           {
             disc_max_lid = disc_min_lid + lmc_num_lids - 1;
             num_lids = lmc_num_lids;
           }
           else
-          {
-            /* Determine if enhanced switch port 0 */
-            p_sw = osm_get_switch_by_guid(p_mgr->p_subn,
-                                          osm_node_get_node_guid(osm_port_get_parent_node(p_port)));
-            if (osm_switch_sp0_is_lmc_capable(p_sw, p_mgr->p_subn))
-            {
-              disc_max_lid = disc_min_lid + lmc_num_lids - 1;
-              num_lids = lmc_num_lids;
-            }
-            else
-            {
-              num_lids = 1;
-            }
-          }
+            num_lids = 1;
 
           /* Make sure the lid is aligned */
           if ((num_lids != 1) && ((disc_min_lid & lmc_mask) != disc_min_lid))
@@ -832,7 +810,6 @@ __osm_lid_mgr_get_port_lid(
   uint8_t  num_lids = (1 << p_mgr->p_subn->opt.lmc);
   int      lid_changed = 0;
   uint16_t lmc_mask;
-  osm_switch_t        *p_sw;
 
   OSM_LOG_ENTER( p_mgr->p_log, __osm_lid_mgr_get_port_lid );
 
@@ -845,15 +822,9 @@ __osm_lid_mgr_get_port_lid(
   guid = cl_ntoh64( osm_port_get_guid( p_port ) );
 
   /* if the port is a base switch port 0 then we only need one lid */
-  if( osm_node_get_type( osm_port_get_parent_node( p_port ) ) ==
-      IB_NODE_TYPE_SWITCH )
-  {
-    /* Determine if base switch port 0 */
-    p_sw = osm_get_switch_by_guid(p_mgr->p_subn,
-                                  osm_node_get_node_guid(osm_port_get_parent_node(p_port)));
-    if (!osm_switch_sp0_is_lmc_capable(p_sw, p_mgr->p_subn))
-      num_lids = 1;
-  }
+  if( p_port->p_node->sw &&
+      !osm_switch_sp0_is_lmc_capable(p_port->p_node->sw, p_mgr->p_subn))
+    num_lids = 1;
 
   /* if the port matches the guid2lid */
   if (!osm_db_guid2lid_get( p_mgr->p_g2l, guid, &min_lid, &max_lid))
@@ -995,7 +966,6 @@ __osm_lid_mgr_set_physp_pi(
   const ib_port_info_t* p_old_pi;
   osm_madw_context_t    context;
   osm_node_t*           p_node;
-  osm_switch_t*         p_sw;
   ib_api_status_t       status;
   uint8_t               mtu;
   uint8_t               op_vls;
@@ -1236,8 +1206,7 @@ __osm_lid_mgr_set_physp_pi(
              ib_port_info_get_neighbor_mtu( p_pi ) );
 
     /* Determine if enhanced switch port 0 and if so set LMC */
-    p_sw = osm_get_switch_by_guid( p_mgr->p_subn, p_node->node_info.node_guid );
-    if (osm_switch_sp0_is_lmc_capable(p_sw, p_mgr->p_subn))
+    if (osm_switch_sp0_is_lmc_capable(p_node->sw, p_mgr->p_subn))
     {
       /* M_KeyProtectBits are always zero */
       p_pi->mkey_lmc = p_mgr->p_subn->opt.lmc;
diff --git a/osm/opensm/osm_link_mgr.c b/osm/opensm/osm_link_mgr.c
index b696d91..0f15f2b 100644
--- a/osm/opensm/osm_link_mgr.c
+++ b/osm/opensm/osm_link_mgr.c
@@ -140,7 +140,6 @@ __osm_link_mgr_set_physp_pi(
 
   if( port_num == 0 )
   {
-    osm_switch_t *p_switch;
     ib_switch_info_t* p_sw_info;
 
     /*
@@ -148,8 +147,7 @@ __osm_link_mgr_set_physp_pi(
       we need to check if this is enhanced port 0 or base port 0.
       For base port 0 the following parameters are not valid. (p824, table 145)
     */
-    p_switch = osm_get_switch_by_guid( p_mgr->p_subn, p_node->node_info.node_guid );
-    if (! p_switch )
+    if (!p_node->sw)
     {
       osm_log( p_mgr->p_log, OSM_LOG_ERROR,
                "__osm_link_mgr_set_physp_pi: ERR 4201: "
@@ -158,7 +156,7 @@ __osm_link_mgr_set_physp_pi(
       goto Exit;
     }
      
-    p_sw_info = osm_switch_get_si_ptr( p_switch );
+    p_sw_info = osm_switch_get_si_ptr(p_node->sw);
     if (ib_switch_info_is_enhanced_port0( p_sw_info ) == FALSE)
     {
       /* This means the switch doesn't support enhanced port zero. 
diff --git a/osm/opensm/osm_mcast_mgr.c b/osm/opensm/osm_mcast_mgr.c
index aab9c01..d5aa021 100644
--- a/osm/opensm/osm_mcast_mgr.c
+++ b/osm/opensm/osm_mcast_mgr.c
@@ -789,7 +789,6 @@ __osm_mcast_mgr_branch(
     const osm_physp_t      *p_remote_physp;
     const osm_node_t    *p_node;
     const osm_node_t    *p_remote_node;
-    osm_switch_t        *p_remote_sw;
 
     p_port_list = &list_array[i];
 
@@ -832,9 +831,7 @@ __osm_mcast_mgr_branch(
       /*
         Acquire a pointer to the remote switch then recurse.
       */
-      p_remote_sw = osm_get_switch_by_guid(p_mgr->p_subn,
-                                osm_node_get_node_guid( p_remote_node ) );
-      CL_ASSERT( p_remote_sw );
+      CL_ASSERT( p_remote_node->sw );
 
       p_physp = osm_node_get_physp_ptr( p_node, i );
       CL_ASSERT( p_physp );
@@ -845,7 +842,7 @@ __osm_mcast_mgr_branch(
       CL_ASSERT( osm_physp_is_valid( p_remote_physp ) );
 
       p_mtn->child_array[i] = __osm_mcast_mgr_branch(
-        p_mgr, p_mgrp, p_remote_sw,
+        p_mgr, p_mgrp, p_remote_node->sw,
         p_port_list, depth,
         osm_physp_get_port_num( p_remote_physp),
         p_max_depth );
@@ -1209,7 +1206,7 @@ osm_mcast_mgr_process_single(
     goto Exit;
   }
 
-  p_sw = osm_get_switch_by_guid( p_mgr->p_subn, sw_guid );
+  p_sw = p_remote_node->sw;
   if( !p_sw )
   {
     osm_log( p_mgr->p_log, OSM_LOG_ERROR,
diff --git a/osm/opensm/osm_node_info_rcv.c b/osm/opensm/osm_node_info_rcv.c
index ebec592..23c3b18 100644
--- a/osm/opensm/osm_node_info_rcv.c
+++ b/osm/opensm/osm_node_info_rcv.c
@@ -641,9 +641,6 @@ __osm_ni_rcv_process_existing_switch(
   IN osm_node_t* const p_node,
   IN const osm_madw_t* const p_madw )
 {
-  ib_net64_t node_guid;
-  osm_switch_t *p_sw;
-
   OSM_LOG_ENTER( p_rcv->p_log, __osm_ni_rcv_process_existing_switch );
 
   /*
@@ -659,15 +656,13 @@ __osm_ni_rcv_process_existing_switch(
   else
   {
     /* Make sure we have SwitchInfo on this node */
-    node_guid = osm_node_get_node_guid( p_node );
-    p_sw = osm_get_switch_by_guid( p_rcv->p_subn, node_guid );
-    if( !p_sw || osm_switch_discovery_count_get( p_sw ) == 0 )
+    if( !p_node->sw || osm_switch_discovery_count_get( p_node->sw ) == 0 )
     {
       /* we don't have the SwitchInfo - retry to get it */
       osm_log( p_rcv->p_log, OSM_LOG_DEBUG,
                "__osm_ni_rcv_process_existing_switch: "
                "Retry to get SwitchInfo on node GUID:0x%"
-               PRIx64 "\n", cl_ntoh64(node_guid) );
+               PRIx64 "\n", cl_ntoh64(osm_node_get_node_guid(p_node)) );
       __osm_ni_rcv_process_switch( p_rcv, p_node, p_madw );
     }
   }
diff --git a/osm/opensm/osm_pkey_mgr.c b/osm/opensm/osm_pkey_mgr.c
index 7502933..9e3e35a 100644
--- a/osm/opensm/osm_pkey_mgr.c
+++ b/osm/opensm/osm_pkey_mgr.c
@@ -72,18 +72,13 @@ pkey_mgr_get_physp_max_blocks(
   IN const osm_physp_t *p_physp )
 {
   osm_node_t *p_node = osm_physp_get_node_ptr( p_physp );
-  osm_switch_t *p_sw;
   uint16_t num_pkeys = 0;
 
-  if ( ( osm_node_get_type( p_node ) != IB_NODE_TYPE_SWITCH ) ||
+  if ( !p_node->sw ||
        ( osm_physp_get_port_num( p_physp ) == 0 ) )
     num_pkeys = cl_ntoh16( p_node->node_info.partition_cap );
   else
-  {
-    p_sw = osm_get_switch_by_guid( p_subn, osm_node_get_node_guid( p_node ) );
-    if (p_sw)
-      num_pkeys = cl_ntoh16( p_sw->switch_info.enforce_cap );
-  }
+    num_pkeys = cl_ntoh16( p_node->sw->switch_info.enforce_cap );
   return((num_pkeys + 31) / 32);
 }
 
@@ -455,8 +450,6 @@ pkey_mgr_update_peer_port(
   ib_pkey_table_t *block, *peer_block;
   const osm_pkey_tbl_t *p_pkey_tbl;
   osm_pkey_tbl_t *p_peer_pkey_tbl;
-  osm_switch_t *p_sw;
-  ib_switch_info_t *p_si;
   uint16_t block_index;
   uint16_t num_of_blocks;
   uint16_t peer_max_blocks;
@@ -474,11 +467,7 @@ pkey_mgr_update_peer_port(
   if ( !peer || !osm_physp_is_valid( peer ) )
     return FALSE;
   p_node = osm_physp_get_node_ptr( peer );
-  if ( osm_node_get_type( p_node ) != IB_NODE_TYPE_SWITCH )
-    return FALSE;
-
-  p_sw = osm_get_switch_by_guid( p_subn, osm_node_get_node_guid( p_node ) );
-  if (!p_sw || !(p_si = osm_switch_get_si_ptr( p_sw )) || !p_si->enforce_cap)
+  if ( !p_node->sw || !p_node->sw->switch_info.enforce_cap )
     return FALSE;
 
   p_pkey_tbl = osm_physp_get_pkey_tbl( p_physp );
diff --git a/osm/opensm/osm_port.c b/osm/opensm/osm_port.c
index 4f51e9d..2f427d2 100644
--- a/osm/opensm/osm_port.c
+++ b/osm/opensm/osm_port.c
@@ -891,7 +891,6 @@ osm_physp_set_pkey_tbl(
   IN uint16_t block_num ) 
 {
   uint16_t max_blocks;
-  osm_switch_t* p_switch;
 
   CL_ASSERT( p_pkey_tbl );
   CL_ASSERT( osm_physp_is_valid( p_physp ) );
@@ -900,8 +899,7 @@ osm_physp_set_pkey_tbl(
     limited by the size of the P_Key table specified by the PartitionCap on the 
     node.
   */
-  if (osm_node_get_type( p_physp->p_node ) != IB_NODE_TYPE_SWITCH ||
-      p_physp->port_num == 0 )
+  if (!p_physp->p_node->sw || p_physp->port_num == 0 )
   {
     /* 
        The maximum blocks is defined in the node info: partition cap for CA,
@@ -917,19 +915,8 @@ osm_physp_set_pkey_tbl(
       This is a switch, and not a management port. The maximum blocks is defined
       in the switch info: partition enforcement cap.
     */
-    p_switch = 
-      osm_get_switch_by_guid(p_subn, p_physp->p_node->node_info.node_guid);
-    if (! p_switch)
-    {
-      osm_log( p_log, OSM_LOG_ERROR,
-               "osm_physp_set_pkey_tbl: ERR 4107: "
-               "Cannot find switch by guid: %" PRIx64 "\n",
-               cl_ntoh64(p_physp->p_node->node_info.node_guid) );
-      return;
-    }
-    
     max_blocks = 
-      (cl_ntoh16(p_switch->switch_info.enforce_cap) + 
+      (cl_ntoh16(p_physp->p_node->sw->switch_info.enforce_cap) +
        IB_NUM_PKEY_ELEMENTS_IN_BLOCK - 1) / IB_NUM_PKEY_ELEMENTS_IN_BLOCK;
   }
 
diff --git a/osm/opensm/osm_port_info_rcv.c b/osm/opensm/osm_port_info_rcv.c
index 2b273d2..ced745d 100644
--- a/osm/opensm/osm_port_info_rcv.c
+++ b/osm/opensm/osm_port_info_rcv.c
@@ -238,8 +238,6 @@ __osm_pi_rcv_process_switch_port(
   uint8_t port_num;
   uint8_t remote_port_num;
   osm_dr_path_t path;
-  osm_switch_t *p_sw;
-  ib_switch_info_t *p_si;
 
   OSM_LOG_ENTER( p_rcv->p_log, __osm_pi_rcv_process_switch_port );
 
@@ -352,10 +350,8 @@ __osm_pi_rcv_process_switch_port(
 			 "Invalid base LID 0x%x corrected\n",
 			 cl_ntoh16( orig_lid ) );
 	/* Determine if base switch port 0 */
-	p_sw = osm_get_switch_by_guid(p_rcv->p_subn,
-				      osm_node_get_node_guid( p_node )); 
-	if (p_sw && (p_si = osm_switch_get_si_ptr(p_sw)) && 
-	    !ib_switch_info_is_enhanced_port0(p_si))
+	if (p_node->sw &&
+	    !ib_switch_info_is_enhanced_port0(&p_node->sw->switch_info))
         {
 		/* PortState is not used on BSP0 but just in case it is DOWN */
 		p_physp->port_info = *p_pi;
@@ -441,7 +437,6 @@ void osm_pkey_get_tables(
   uint8_t  port_num;
   uint16_t block_num, max_blocks;
   uint32_t attr_mod_ho;
-  osm_switch_t* p_switch;
 
   OSM_LOG_ENTER( p_log, osm_pkey_get_tables );
 
@@ -455,8 +450,7 @@ void osm_pkey_get_tables(
 
   port_num = p_physp->port_num;
 
-  if (osm_node_get_type( p_node ) != IB_NODE_TYPE_SWITCH ||
-      port_num == 0 )
+  if (!p_node->sw || port_num == 0)
   {
     /* The maximum blocks is defined by the node info partition cap for CA,
        router, and switch management ports. */
@@ -465,29 +459,19 @@ void osm_pkey_get_tables(
   }
   else
   {
-    /* This is a switch, and not a management port. The maximum blocks is defined
-       in the switch info partition enforcement cap. */
-    p_switch = osm_get_switch_by_guid(p_subn, p_node->node_info.node_guid);
-
-    if (! p_switch)
-    {
-      osm_log( p_log, OSM_LOG_ERROR,
-               "osm_physp_has_pkey: ERR 0F11: "
-               "Cannot find switch by guid: %" PRIx64 "\n",
-               cl_ntoh64(p_node->node_info.node_guid) );
-      goto Exit;
-    }
+    /* This is a switch, and not a management port. The maximum blocks
+       is defined in the switch info partition enforcement cap. */
 
     /* Check for IBM eHCA firmware defect in reporting partition enforcement cap */
     if (cl_ntoh32(ib_node_info_get_vendor_id(&p_node->node_info)) == IBM_VENDOR_ID)
-      p_switch->switch_info.enforce_cap = 0;
+      p_node->sw->switch_info.enforce_cap = 0;
 
     /* Bail out if this is a switch with no partition enforcement capability */
-    if (cl_ntoh16(p_switch->switch_info.enforce_cap) == 0)
+    if (cl_ntoh16(p_node->sw->switch_info.enforce_cap) == 0)
       goto Exit;
 
-    max_blocks = (cl_ntoh16(p_switch->switch_info.enforce_cap)+IB_NUM_PKEY_ELEMENTS_IN_BLOCK -1)
-      / IB_NUM_PKEY_ELEMENTS_IN_BLOCK ;
+    max_blocks = (cl_ntoh16(p_node->sw->switch_info.enforce_cap) +
+                  IB_NUM_PKEY_ELEMENTS_IN_BLOCK -1) / IB_NUM_PKEY_ELEMENTS_IN_BLOCK ;
   }
 
   for (block_num = 0 ; block_num < max_blocks  ; block_num++)
diff --git a/osm/opensm/osm_qos.c b/osm/opensm/osm_qos.c
index fceb304..0dd5dc7 100644
--- a/osm/opensm/osm_qos.c
+++ b/osm/opensm/osm_qos.c
@@ -318,14 +318,12 @@ osm_signal_t osm_qos_setup(osm_opensm_t * p_osm)
 {
 	struct qos_config ca_config, sw0_config, swe_config, rtr_config;
 	struct qos_config *cfg;
-	osm_switch_t *p_sw;
-	ib_switch_info_t *p_si;
 	cl_qmap_t *p_tbl;
 	cl_map_item_t *p_next;
 	osm_port_t *p_port;
 	uint32_t num_physp;
 	osm_physp_t *p_physp;
-	uint8_t node_type;
+	osm_node_t *p_node;
 	ib_api_status_t status;
 	uint8_t i;
 
@@ -351,8 +349,8 @@ osm_signal_t osm_qos_setup(osm_opensm_t * p_osm)
 		p_port = (osm_port_t *) p_next;
 		p_next = cl_qmap_next(p_next);
 
-		node_type = osm_node_get_type(osm_port_get_parent_node(p_port));
-		if (node_type == IB_NODE_TYPE_SWITCH) {
+		p_node = p_port->p_node;
+		if (p_node->sw) {
 			num_physp = osm_port_get_num_physp(p_port);
 			for (i = 1; i < num_physp; i++) {
 				p_physp = osm_port_get_phys_ptr(p_port, i);
@@ -363,14 +361,11 @@ osm_signal_t osm_qos_setup(osm_opensm_t * p_osm)
 						    p_port, p_physp, i, &swe_config);
 			}
 			/* skip base port 0 */
-			p_sw = osm_get_switch_by_guid(&p_osm->subn,
-						      osm_port_get_guid(p_port));
-			if (!p_sw || !(p_si = osm_switch_get_si_ptr(p_sw)) ||
-				!ib_switch_info_is_enhanced_port0(p_si))
+			if (!ib_switch_info_is_enhanced_port0(&p_node->sw->switch_info))
 				continue;
 
 			cfg = &sw0_config;
-		} else if (node_type == IB_NODE_TYPE_ROUTER)
+		} else if (osm_node_get_type(p_node) == IB_NODE_TYPE_ROUTER)
 			cfg = &rtr_config;
 		else
 			cfg = &ca_config;
diff --git a/osm/opensm/osm_sa_multipath_record.c b/osm/opensm/osm_sa_multipath_record.c
index 1d2d203..60a4930 100644
--- a/osm/opensm/osm_sa_multipath_record.c
+++ b/osm/opensm/osm_sa_multipath_record.c
@@ -231,11 +231,9 @@ __osm_mpr_rcv_get_path_parms(
   IN const ib_net64_t		comp_mask,
   OUT osm_path_parms_t*		const p_parms )
 {
-  ib_net64_t			node_guid;
   const osm_node_t*		p_node;
   const osm_physp_t*		p_physp;
   const osm_physp_t*		p_dest_physp;
-  const osm_switch_t*		p_sw;
   const osm_prtn_t*		p_prtn;
   const ib_port_info_t*		p_pi;
   ib_slvl_table_t*		p_slvl_tbl;
@@ -349,21 +347,14 @@ __osm_mpr_rcv_get_path_parms(
 
   p_node = osm_physp_get_node_ptr( p_physp );
 
-  if ( osm_node_get_type( p_node ) == IB_NODE_TYPE_SWITCH )
+  if ( p_node->sw )
   {
-    p_sw = osm_get_switch_by_guid( p_rcv->p_subn,
-				   osm_node_get_node_guid( p_node ) );
-    if( !p_sw )
-    {
-      status = IB_ERROR;
-      goto Exit;
-    }
 
     /*
      * If the dest_lid_ho is equal to the lid of the switch pointed by
      * p_sw then p_physp will be the physical port of the switch port zero.
      */
-    p_physp = osm_switch_get_route_by_lid( p_sw, cl_ntoh16( dest_lid_ho ) );
+    p_physp = osm_switch_get_route_by_lid( p_node->sw, cl_ntoh16( dest_lid_ho ) );
     if ( p_physp == 0 )
     {
       osm_log( p_rcv->p_log, OSM_LOG_ERROR,
@@ -381,17 +372,10 @@ __osm_mpr_rcv_get_path_parms(
    */
   p_node = osm_physp_get_node_ptr( p_dest_physp );
 	
-  if ( osm_node_get_type( p_node ) == IB_NODE_TYPE_SWITCH )
+  if ( p_node->sw )
   {
-    p_sw = osm_get_switch_by_guid( p_rcv->p_subn,
-				   osm_node_get_node_guid( p_node ) );
-    if( !p_sw )
-    {
-      status = IB_ERROR;
-      goto Exit;
-    }
 
-    p_dest_physp = osm_switch_get_route_by_lid( p_sw, cl_ntoh16( dest_lid_ho ) );
+    p_dest_physp = osm_switch_get_route_by_lid( p_node->sw, cl_ntoh16( dest_lid_ho ) );
 
     if ( p_dest_physp == 0 )
     {
@@ -431,7 +415,7 @@ __osm_mpr_rcv_get_path_parms(
 
     p_node = osm_physp_get_node_ptr( p_physp );
 
-    if ( osm_node_get_type( p_node ) != IB_NODE_TYPE_SWITCH )
+    if ( !p_node->sw )
     {
       /*
         There is some sort of problem in the subnet object!
@@ -445,22 +429,6 @@ __osm_mpr_rcv_get_path_parms(
       goto Exit;
     }
 
-    node_guid = osm_node_get_node_guid( p_node );
-    p_sw = osm_get_switch_by_guid( p_rcv->p_subn, node_guid );
-
-    if( !p_sw )
-    {
-      /*
-        There is some sort of problem in the subnet object!
-      */
-      osm_log( p_rcv->p_log, OSM_LOG_ERROR,
-	       "__osm_mpr_rcv_get_path_parms: ERR 4504: "
-	       "Internal error, no switch for GUID 0x%016" PRIx64 "\n",
-	       cl_ntoh64( node_guid ) );
-      status = IB_ERROR;
-      goto Exit;
-    }
-
     /*
       Check parameters for the ingress port in this switch.
     */
@@ -499,7 +467,7 @@ __osm_mpr_rcv_get_path_parms(
     /*
       Continue with the egress port on this switch.
     */
-    p_physp = osm_switch_get_route_by_lid( p_sw, dest_lid );
+    p_physp = osm_switch_get_route_by_lid( p_node->sw, dest_lid );
 
     if ( p_physp == 0 )
     {
@@ -507,7 +475,7 @@ __osm_mpr_rcv_get_path_parms(
                "__osm_mpr_rcv_get_path_parms: ERR 4516: "
                "Dead end on path to LID 0x%X from switch for GUID 0x%016" PRIx64 "\n",
                dest_lid_ho,
-               cl_ntoh64( node_guid ) );
+               cl_ntoh64( osm_node_get_node_guid( p_node ) ) );
       status = IB_ERROR;
       goto Exit;
     }
diff --git a/osm/opensm/osm_sa_path_record.c b/osm/opensm/osm_sa_path_record.c
index 0500a74..11058ab 100644
--- a/osm/opensm/osm_sa_path_record.c
+++ b/osm/opensm/osm_sa_path_record.c
@@ -233,11 +233,9 @@ __osm_pr_rcv_get_path_parms(
   IN const ib_net64_t      comp_mask,
   OUT osm_path_parms_t*    const p_parms )
 {
-  ib_net64_t               node_guid;
   const osm_node_t*        p_node;
   const osm_physp_t*       p_physp;
   const osm_physp_t*       p_dest_physp;
-  const osm_switch_t*      p_sw;
   const osm_prtn_t*        p_prtn;
   const ib_port_info_t*    p_pi;
   ib_api_status_t          status = IB_SUCCESS;
@@ -289,21 +287,13 @@ __osm_pr_rcv_get_path_parms(
 
   p_node = osm_physp_get_node_ptr( p_physp );
 
-  if( osm_node_get_type( p_node ) == IB_NODE_TYPE_SWITCH )
+  if( p_node->sw )
   {
-    p_sw = osm_get_switch_by_guid(p_rcv->p_subn,
-                                  osm_node_get_node_guid( p_node ) );
-    if( !p_sw )
-    {
-      status = IB_ERROR;
-      goto Exit;
-    }
-
     /*
      * If the dest_lid_ho is equal to the lid of the switch pointed by
      * p_sw then p_physp will be the physical port of the switch port zero.
      */
-    p_physp = osm_switch_get_route_by_lid(p_sw, cl_ntoh16( dest_lid_ho ) );
+    p_physp = osm_switch_get_route_by_lid(p_node->sw, cl_ntoh16( dest_lid_ho ) );
     if ( p_physp == 0 )
     {
       osm_log( p_rcv->p_log, OSM_LOG_ERROR,
@@ -321,17 +311,9 @@ __osm_pr_rcv_get_path_parms(
    */
   p_node = osm_physp_get_node_ptr( p_dest_physp );
 
-  if( osm_node_get_type( p_node ) == IB_NODE_TYPE_SWITCH )
+  if( p_node->sw )
   {
-    p_sw = osm_get_switch_by_guid(p_rcv->p_subn,
-                                  osm_node_get_node_guid( p_node ) );
-    if( !p_sw )
-    {
-      status = IB_ERROR;
-      goto Exit;
-    }
-
-    p_dest_physp = osm_switch_get_route_by_lid( p_sw, cl_ntoh16( dest_lid_ho ) );
+    p_dest_physp = osm_switch_get_route_by_lid( p_node->sw, cl_ntoh16( dest_lid_ho ) );
 
     if ( p_dest_physp == 0 )
     {
@@ -369,7 +351,7 @@ __osm_pr_rcv_get_path_parms(
 
     p_node = osm_physp_get_node_ptr( p_physp );
 
-    if( osm_node_get_type( p_node ) != IB_NODE_TYPE_SWITCH )
+    if( !p_node->sw )
     {
       /*
         There is some sort of problem in the subnet object!
@@ -383,22 +365,6 @@ __osm_pr_rcv_get_path_parms(
       goto Exit;
     }
 
-    node_guid = osm_node_get_node_guid( p_node );
-    p_sw = osm_get_switch_by_guid(p_rcv->p_subn, node_guid );
-
-    if( !p_sw )
-    {
-      /*
-        There is some sort of problem in the subnet object!
-      */
-      osm_log( p_rcv->p_log, OSM_LOG_ERROR,
-               "__osm_pr_rcv_get_path_parms: ERR 1F04: "
-               "Internal error, no switch for GUID 0x%016" PRIx64 "\n",
-               cl_ntoh64( node_guid ) );
-      status = IB_ERROR;
-      goto Exit;
-    }
-
     /*
       Check parameters for the ingress port in this switch.
     */
@@ -437,7 +403,7 @@ __osm_pr_rcv_get_path_parms(
     /*
       Continue with the egress port on this switch.
     */
-    p_physp = osm_switch_get_route_by_lid( p_sw, dest_lid );
+    p_physp = osm_switch_get_route_by_lid( p_node->sw, dest_lid );
 
     if ( p_physp == 0 )
     {
@@ -445,7 +411,7 @@ __osm_pr_rcv_get_path_parms(
                "__osm_pr_rcv_get_path_parms: ERR 1F07: "
                "Dead end on path to LID 0x%X from switch for GUID 0x%016" PRIx64 "\n",
                dest_lid_ho,
-               cl_ntoh64( node_guid ) );
+               cl_ntoh64( osm_node_get_node_guid( p_node ) ) );
       status = IB_ERROR;
       goto Exit;
     }
diff --git a/osm/opensm/osm_sa_portinfo_record.c b/osm/opensm/osm_sa_portinfo_record.c
index d904945..054ff1f 100644
--- a/osm/opensm/osm_sa_portinfo_record.c
+++ b/osm/opensm/osm_sa_portinfo_record.c
@@ -198,20 +198,15 @@ __osm_sa_pir_create(
   uint16_t                    base_lid_ho;
   uint16_t                    match_lid_ho;
   osm_physp_t                *p_node_physp;
-  osm_switch_t               *p_sw;
 
   OSM_LOG_ENTER( p_rcv->p_log, __osm_sa_pir_create );
 
-  if (p_physp->p_node->node_info.node_type == IB_NODE_TYPE_SWITCH)
+  if (p_physp->p_node->sw)
   {
     p_node_physp = osm_node_get_physp_ptr( p_physp->p_node, 0 );
     base_lid_ho = cl_ntoh16( osm_physp_get_base_lid( p_node_physp ) );
-    p_sw = osm_get_switch_by_guid( p_rcv->p_subn, 
-             osm_physp_get_port_guid( p_node_physp ) );
-    if (osm_switch_sp0_is_lmc_capable(p_sw, p_rcv->p_subn))
-      lmc = osm_physp_get_lmc( p_node_physp );
-    else
-      lmc = 0;
+    lmc = osm_switch_sp0_is_lmc_capable(p_physp->p_node->sw, p_rcv->p_subn) ?
+      osm_physp_get_lmc( p_node_physp ) : 0;
   }
   else
   {
diff --git a/osm/opensm/osm_sw_info_rcv.c b/osm/opensm/osm_sw_info_rcv.c
index 136fc05..6647d16 100644
--- a/osm/opensm/osm_sw_info_rcv.c
+++ b/osm/opensm/osm_sw_info_rcv.c
@@ -386,6 +386,8 @@ __osm_si_rcv_process_new(
     goto Exit;
   }
 
+  p_node->sw = p_sw;
+
   /*
     Update the switch info according to the
     info we just received.
@@ -428,9 +430,9 @@ static boolean_t
 __osm_si_rcv_process_existing(
   IN const osm_si_rcv_t* const p_rcv,
   IN osm_node_t* const p_node,
-  IN osm_switch_t* const p_sw,
   IN const osm_madw_t* const p_madw )
 {
+  osm_switch_t *p_sw = p_node->sw;
   ib_switch_info_t *p_si;
   osm_si_context_t *p_si_context;
   ib_smp_t         *p_smp;
@@ -438,8 +440,6 @@ __osm_si_rcv_process_existing(
 
   OSM_LOG_ENTER( p_rcv->p_log, __osm_si_rcv_process_existing );
 
-  CL_ASSERT( p_node );
-  CL_ASSERT( p_sw );
   CL_ASSERT( p_madw );
 
   p_smp = osm_madw_get_smp_ptr( p_madw );
@@ -588,7 +588,6 @@ osm_si_rcv_process(
   ib_switch_info_t *p_si;
   ib_smp_t *p_smp;
   osm_node_t *p_node;
-  osm_switch_t *p_sw;
   ib_net64_t node_guid;
   osm_si_context_t *p_context;
 
@@ -654,8 +653,7 @@ osm_si_rcv_process(
     /*
       Acquire the switch object for this switch.
     */
-    p_sw = osm_get_switch_by_guid( p_rcv->p_subn, node_guid );
-    if( !p_sw )
+    if( !p_node->sw )
     {
       __osm_si_rcv_process_new( p_rcv, p_node, p_madw );
       /*
@@ -667,7 +665,7 @@ osm_si_rcv_process(
     else
     {
       /* we might get back a request for signaling change was detected */
-      if (__osm_si_rcv_process_existing( p_rcv, p_node, p_sw, p_madw ))
+      if (__osm_si_rcv_process_existing( p_rcv, p_node, p_madw ))
       {
         CL_PLOCK_RELEASE( p_rcv->p_lock );
         osm_state_mgr_process( p_rcv->p_state_mgr,
diff --git a/osm/opensm/osm_ucast_mgr.c b/osm/opensm/osm_ucast_mgr.c
index f546c5f..c1e530e 100644
--- a/osm/opensm/osm_ucast_mgr.c
+++ b/osm/opensm/osm_ucast_mgr.c
@@ -1078,8 +1078,6 @@ __osm_ucast_mgr_process_neighbors(
   osm_ucast_mgr_t* const p_mgr = (osm_ucast_mgr_t*)context;
   osm_node_t *p_node;
   osm_node_t *p_remote_node;
-  ib_net64_t remote_node_guid;
-  osm_switch_t *p_remote_sw;
   uint32_t port_num;
   uint8_t remote_port_num;
   uint32_t num_ports;
@@ -1111,32 +1109,15 @@ __osm_ucast_mgr_process_neighbors(
                                               (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 ) )
+        && p_remote_node->sw )
     {
       /* make sure the link is healthy. If it is not - don't 
          propagate through it. */
       p_physp = osm_node_get_physp_ptr( p_node, port_num );
       if (!osm_link_is_healthy( p_physp ) ) continue;
 
-      remote_node_guid = osm_node_get_node_guid( p_remote_node );
-
-      p_remote_sw = osm_get_switch_by_guid( p_mgr->p_subn, remote_node_guid );
-      if( !p_remote_sw )
-      {
-        osm_log( p_mgr->p_log, OSM_LOG_ERROR,
-                 "__osm_ucast_mgr_process_neighbors: ERR 3A07: "
-                 "No switch object for Node GUID 0x%" PRIx64 "\n",
-                 cl_ntoh64( remote_node_guid ) );
-      }
-      else
-      {
-        __osm_ucast_mgr_process_neighbor(
-          p_mgr,
-          p_sw,
-          p_remote_sw,
-          (uint8_t)port_num,
-          remote_port_num );
-      }
+      __osm_ucast_mgr_process_neighbor(p_mgr, p_sw, p_remote_node->sw,
+                                       (uint8_t)port_num, remote_port_num );
     }
   }
 
diff --git a/osm/opensm/osm_ucast_updn.c b/osm/opensm/osm_ucast_updn.c
index d6c5dbc..c860427 100644
--- a/osm/opensm/osm_ucast_updn.c
+++ b/osm/opensm/osm_ucast_updn.c
@@ -225,11 +225,10 @@ static int
 __updn_bfs_by_node(
   IN updn_t *p_updn,
   IN osm_subn_t *p_subn,
-  IN ib_net64_t guid_index,
+  IN osm_port_t *p_port,
   IN cl_qmap_t *p_guid_rank_tbl )
 {
   /* Init local vars */
-  osm_port_t *p_port;
   osm_switch_t *p_self_node = NULL;
   uint8_t pn, pn_rem;
   osm_physp_t   *p_physp, *p_remote_physp;
@@ -247,8 +246,6 @@ __updn_bfs_by_node(
   cl_list_init( p_nextList, 10 );
   p_currList = p_nextList;
 
-  p_port = (osm_port_t*) cl_qmap_get(&(p_subn->port_guid_tbl),guid_index);
-  /* TODO : check if p_port is not NULL */
   p_physp = osm_port_get_default_phys_ptr(p_port);
   /* Check valid pointer */
   if (!p_physp || !osm_physp_is_valid(p_physp ))
@@ -263,9 +260,9 @@ __updn_bfs_by_node(
            "__updn_bfs_by_node:"
            "Starting lid : 0x%x \n", root_lid );
 
-  if (osm_node_get_type( p_port->p_node ) == IB_NODE_TYPE_SWITCH)
+  if (p_port->p_node->sw)
   {
-    p_self_node = osm_get_switch_by_guid(p_subn, guid_index);
+    p_self_node = p_port->p_node->sw;
     /* Update its Min Hop Table */
     osm_log( p_log, OSM_LOG_DEBUG,
              "__updn_bfs_by_node:"
@@ -286,7 +283,7 @@ __updn_bfs_by_node(
     {
       /* Check if the remote port is a switch, if it is update root_lid,
          Min Hop Table */
-      if (osm_node_get_type(p_remote_physp->p_node) != IB_NODE_TYPE_SWITCH)
+      if (!p_remote_physp->p_node->sw)
       {
         osm_log( p_log, OSM_LOG_ERROR,
                  "__updn_bfs_by_node: ERR AA07: "
@@ -296,9 +293,7 @@ __updn_bfs_by_node(
       }
       else
       {
-        p_self_node = osm_get_switch_by_guid(p_subn,
-                                             osm_physp_get_port_guid
-                                             (p_remote_physp));
+        p_self_node = p_remote_physp->p_node->sw;
         max_sw_lid = osm_switch_get_max_lid_ho(p_self_node);
         if ((1 <= root_lid) && (root_lid <= max_sw_lid))
           /* Update its Min Hop Table */
@@ -396,7 +391,7 @@ __updn_bfs_by_node(
         remote_guid = osm_node_get_node_guid(p_remote_node);
         /* printf ("-V- Current guid : 0x%" PRIx64 " Remote guid : 0x%" PRIx64 "\n", */
         /* cl_ntoh64(current_guid), cl_ntoh64(remote_guid)); */
-        p_remote_sw = osm_get_switch_by_guid(p_subn, remote_guid);
+        p_remote_sw = p_remote_node->sw;
         p_rem_rank = (updn_rank_t*)cl_qmap_get(p_guid_rank_tbl, remote_guid);
         p_cur_rank = (updn_rank_t*)cl_qmap_get(p_guid_rank_tbl, current_guid);
         /* Decide which direction to mark it (UP/DOWN) */
@@ -901,7 +896,7 @@ __osm_subn_set_up_down_min_hop_table(
              "__osm_subn_set_up_down_min_hop_table: "
              "BFS through port GUID 0x%" PRIx64 "\n",
              cl_ntoh64(port_guid) );
-    if(__updn_bfs_by_node(p_updn, p_subn, port_guid,
+    if(__updn_bfs_by_node(p_updn, p_subn, p_port,
                           &p_updn->guid_rank_tbl))
     {
       OSM_LOG_EXIT( p_log );
-- 
1.4.4.2.gfc82d





More information about the general mailing list