[openib-general] [PATCHv3] OpenSM/osm_lid_mgr.c: Support enhanced switch port 0 for LMC > 0

Hal Rosenstock halr at voltaire.com
Fri Jun 30 03:11:52 PDT 2006


OpenSM/osm_lid_mgr.c: Support enhanced switch port 0 for LMC > 0

Base port 0 is constrained to have an of LMC of 0 whereas enhanced
switch port 0 is not. Support for enhanced switch port 0 is more like CA
and router ports in terms of LMC.

Signed-off-by: Hal Rosenstock <halr at voltaire.com>

Index: include/opensm/osm_switch.h
===================================================================
--- include/opensm/osm_switch.h	(revision 8296)
+++ include/opensm/osm_switch.h	(working copy)
@@ -702,6 +702,42 @@ osm_switch_get_si_ptr(
 *	Switch object
 *********/
 
+/****f* OpenSM: Switch/osm_switch_is_sp0_enhanced
+* NAME
+*	osm_switch_is_sp0_enhanced	
+*
+* DESCRIPTION
+*	Returns whether switch port 0 (SP0) is enhanced or base
+*
+*/
+static inline uint16_t 
+osm_switch_is_sp0_enhanced(
+	IN const osm_switch_t* const p_sw )
+{
+	ib_switch_info_t    *p_si;
+
+	if (p_sw && (p_si = osm_switch_get_si_ptr(p_sw)) &&
+	    ib_switch_info_is_enhanced_port0(p_si))
+	{
+		return 1;	/* enhanced SP0 */
+        }
+
+	return 0;		/* base SP 0 */
+}
+/*
+* PARAMETERS
+*	p_sw
+*		[in] Pointer to an osm_switch_t object.
+*
+* RETURN VALUES
+*	TRUE if SP0 is enhanced. FALSE otherwise.
+*       
+* NOTES
+*
+* SEE ALSO
+*	Switch object
+*********/
+
 /****f* OpenSM: Switch/osm_switch_get_max_block_id
 * NAME
 *	osm_switch_get_max_block_id
Index: opensm/osm_lid_mgr.c
===================================================================
--- opensm/osm_lid_mgr.c	(revision 8296)
+++ opensm/osm_lid_mgr.c	(working copy)
@@ -94,6 +94,7 @@
 #include <opensm/osm_lid_mgr.h>
 #include <opensm/osm_log.h>
 #include <opensm/osm_node.h>
+#include <opensm/osm_switch.h>
 #include <opensm/osm_helper.h>
 #include <opensm/osm_msgdef.h>
 #include <vendor/osm_vendor_api.h>
@@ -351,6 +352,7 @@ __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;
@@ -436,7 +438,19 @@ __osm_lid_mgr_init_sweep(
            IB_NODE_TYPE_SWITCH )
         num_lids = lmc_num_lids;
       else
-        num_lids = 1;
+      {
+        /* 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_is_sp0_enhanced(p_sw))
+        {
+          num_lids = lmc_num_lids;
+        }
+        else
+        {
+          num_lids = 1;
+        }
+      }
 
       if ((num_lids != 1) &&
           (((db_min_lid & lmc_mask) != db_min_lid) ||
@@ -539,7 +553,17 @@ __osm_lid_mgr_init_sweep(
           }
           else
           {
-            num_lids = 1;
+            /* 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_is_sp0_enhanced(p_sw))
+            {
+              num_lids = lmc_num_lids;
+            }
+            else
+            {
+              num_lids = 1;
+            }
           }
 
           /* Make sure the lid is aligned */
@@ -798,6 +822,7 @@ __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 );
 
@@ -809,10 +834,18 @@ __osm_lid_mgr_get_port_lid(
   /* get the lid from the guid2lid */
   guid = cl_ntoh64( osm_port_get_guid( p_port ) );
 
-  /* if the port is a switch then we only need one lid */
+  /* if the port is a switch with 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 )
-    num_lids = 1;
+  {
+    /* 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_is_sp0_enhanced(p_sw))
+    {
+      num_lids = 1;
+    }
+  }
 
   /* if the port matches the guid2lid */
   if (!osm_db_guid2lid_get( p_mgr->p_g2l, guid, &min_lid, &max_lid))







More information about the general mailing list