]> git.openfabrics.org - ~shefty/rdma-win.git/commitdiff
[OpenSM] Fix in lid mgr to avoid inifinite loop.
authoreitan <eitan@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Sun, 13 Nov 2005 10:06:18 +0000 (10:06 +0000)
committereitan <eitan@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Sun, 13 Nov 2005 10:06:18 +0000 (10:06 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1@150 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

trunk/ulp/opensm/user/opensm/osm_lid_mgr.c

index f06fae3f662dfb57ca32173e4f13baec3ec28df7..46d630d63927b2bf8dd433d017ac6887a70cc6d6 100644 (file)
@@ -56,7 +56,7 @@
  * 1. During initialization:
  *   1.1 initialize the guid2lid database domain.
  *   1.2 if reassign_lid is not set:
- *   1.2.1 read the persistant data for the domain.
+ *   1.2.1 read the persistent data for the domain.
  *   1.2.2 validate no duplicate use of lids and lids are 2^(lmc-1)
  *
  * 2. During SM port lid assignment:
@@ -288,7 +288,7 @@ osm_lid_mgr_init(
   {
     osm_log( p_mgr->p_log, OSM_LOG_ERROR,
              "osm_lid_mgr_init: ERR 0316: " 
-             "Error initializing Guid-to-Lid persistant database.\n");
+             "Error initializing Guid-to-Lid persistent database.\n");
     status = IB_ERROR;
     goto Exit;
   }
@@ -303,7 +303,7 @@ osm_lid_mgr_init(
     {
       osm_log( p_mgr->p_log, OSM_LOG_ERROR,
                "osm_lid_mgr_init: ERR 0317: " 
-               "Error restoring Guid-to-Lid persistant database.\n");
+               "Error restoring Guid-to-Lid persistent database.\n");
       status = IB_ERROR;
       goto Exit;
     }
@@ -313,7 +313,7 @@ osm_lid_mgr_init(
     __osm_lid_mgr_validate_db(p_mgr);
   }
 
-Exit:
+ Exit:
   OSM_LOG_EXIT( p_mgr->p_log );
   return( status );
 }
@@ -357,7 +357,7 @@ __osm_lid_mgr_init_sweep(
     lmc_mask = 0xffff;
 
   /* if we came out of standby we need to discard any previous guid 2 lid
-     info we might had */
+     info we might have */
   if ( p_mgr->p_subn->coming_out_of_standby == TRUE )
   {
     osm_db_clear( p_mgr->p_g2l );
@@ -377,7 +377,7 @@ __osm_lid_mgr_init_sweep(
   for (lid = 0; lid < cl_ptr_vector_get_size(p_discovered_vec); lid++)
     cl_ptr_vector_set(p_discovered_vec, lid, NULL);
 
-  /* we if are on the first sweep and in re-assign lids mode 
+  /* we if are in the first sweep and in re-assign lids mode 
      we should ignore all the available info and simply define one 
      huge empty range */
   if ((p_mgr->p_subn->first_time_master_sweep == TRUE) &&
@@ -392,7 +392,7 @@ __osm_lid_mgr_init_sweep(
     goto AfterScanningLids;
   }
 
-  /* go over all discvered ports and mark their entries */
+  /* go over all discovered ports and mark their entries */
   p_port_guid_tbl = &p_mgr->p_subn->port_guid_tbl;
 
   for( p_port = (osm_port_t*)cl_qmap_head( p_port_guid_tbl );
@@ -417,7 +417,7 @@ __osm_lid_mgr_init_sweep(
           (((db_min_lid & lmc_mask) != db_min_lid) ||
            (db_max_lid - db_min_lid + 1 < num_lids)) )
       {
-        /* Not alligned, or not wide enough - remove the entry */
+        /* Not aligned, or not wide enough - remove the entry */
         osm_log( p_mgr->p_log, OSM_LOG_DEBUG,
                  "__osm_lid_mgr_init_sweep: "
                  "Cleaning persistent entry for guid:0x%016" PRIx64
@@ -437,7 +437,7 @@ __osm_lid_mgr_init_sweep(
      A lid can be used if
      1. a persistent assignment exists
      2. the lid is used by a discovered port that does not have a persistent 
-        assignment.
+     assignment.
      
      scan through all lid values of both the persistent table and
      discovered table. 
@@ -481,19 +481,19 @@ __osm_lid_mgr_init_sweep(
       {
         /* we have a port. Now lets see if we can preserve its lid range. */
         /* For that - we need to make sure:
-           1. The port has a (legal) persistancy entry. Then the local lid
-              is free (we will use the persistancy value).
+           1. The port has a (legal) persistency entry. Then the local lid
+           is free (we will use the persistency value).
            2. Can the port keep its local assignment?
-              a. Make sure the lid a alligned.
-              b. Make sure all needed lids (for the lmc) are free according
-                 to persistancy table.
+           a. Make sure the lid a aligned.
+           b. Make sure all needed lids (for the lmc) are free according
+           to persistency table.
         */
-      /* qualify the guid of the port is not persistently mapped to 
-         another range */
-      if (!osm_db_guid2lid_get( p_mgr->p_g2l,
-                                cl_ntoh64(osm_port_get_guid(p_port)),
-                                &db_min_lid, &db_max_lid))
-      {
+        /* qualify the guid of the port is not persistently mapped to 
+           another range */
+        if (!osm_db_guid2lid_get( p_mgr->p_g2l,
+                                  cl_ntoh64(osm_port_get_guid(p_port)),
+                                  &db_min_lid, &db_max_lid))
+        {
           osm_log( p_mgr->p_log, OSM_LOG_DEBUG,
                    "__osm_lid_mgr_init_sweep: "
                    "0x%04x is free as it was discovered "
@@ -511,45 +511,48 @@ __osm_lid_mgr_init_sweep(
           {
             disc_max_lid = disc_min_lid + lmc_num_lids - 1;
             num_lids = lmc_num_lids;
-        }
-        else
-        {
+          }
+          else
+          {
             num_lids = 1;
           }
-          /* Make sure the lid is alligned */
+          /* Make sure the lid is aligned */
           if ((num_lids != 1) && ((disc_min_lid & lmc_mask) != disc_min_lid))
           {
             /* The lid cannot be used */
-          osm_log( p_mgr->p_log, OSM_LOG_DEBUG,
-                   "__osm_lid_mgr_init_sweep: "
+            osm_log( p_mgr->p_log, OSM_LOG_DEBUG,
+                     "__osm_lid_mgr_init_sweep: "
                      "0x%04x is free as it was discovered "
-                     "but not alligned. \n",
+                     "but not aligned. \n",
                      lid );
-      }
-      else
-      {
-            /* check that all needed lids are not persistantly mapped */
+          }
+          else
+          {
+            /* check that all needed lids are not persistently mapped */
             is_free = FALSE;
             for ( req_lid = disc_min_lid + 1 ; req_lid <= disc_max_lid ; req_lid++ )
             {
               if ((req_lid <= max_persistent_lid) && cl_ptr_vector_get(p_persistent_vec, req_lid))
               {
-        osm_log( p_mgr->p_log, OSM_LOG_DEBUG,
-                 "__osm_lid_mgr_init_sweep: "
+                osm_log( p_mgr->p_log, OSM_LOG_DEBUG,
+                         "__osm_lid_mgr_init_sweep: "
                          "0x%04x is free as it was discovered "
                          "but mapped. \n",
-                 lid);
+                         lid);
                 is_free = TRUE;
                 break;
               }
-      }
-      if (is_free == FALSE)
-      {
+            }
+            if (is_free == FALSE)
+            {
               /* This port will use its local lid, and consume the entire required lid range.
                  Thus we can skip that range. */
-        lid = disc_max_lid;
-      }
-    }
+              /* If the disc_max_lid is greater then lid - we can skip right to it, 
+                 since we've done all neccessary checks on the lids in between. */
+              if (disc_max_lid > lid)
+                lid = disc_max_lid;
+            }
+          }
         }
       }
     }
@@ -590,7 +593,14 @@ __osm_lid_mgr_init_sweep(
   {
     p_range =
       (osm_lid_mgr_range_t *)cl_malloc(sizeof(osm_lid_mgr_range_t));
-    p_range->min_lid = 1;
+    /* 
+       The p_range can be NULL in one of 2 cases:
+       1. If max_defined_lid == 0. In this case, we want the entire range.
+       2. If all lids discovered in the loop where mapped. In this case
+          no free range exists, and we want to define it after the last 
+          mapped lid.
+    */
+    p_range->min_lid = lid;
   }
   p_range->max_lid = p_mgr->p_subn->max_unicast_lid_ho - 1;
   cl_qlist_insert_tail( &p_mgr->free_ranges, &p_range->item );
@@ -725,9 +735,9 @@ __osm_lid_mgr_find_free_lid_range(
 /**********************************************************************
  **********************************************************************/
 void
- __osm_lid_mgr_cleanup_discovered_port_lid_range(
-   IN osm_lid_mgr_t* p_mgr,
-   IN osm_port_t *p_port )
+__osm_lid_mgr_cleanup_discovered_port_lid_range(
+  IN osm_lid_mgr_t* p_mgr,
+  IN osm_port_t *p_port )
 {
   cl_ptr_vector_t *p_discovered_vec = &p_mgr->p_subn->port_lid_tbl;
   uint16_t         lid, min_lid, max_lid;
@@ -919,7 +929,7 @@ __osm_lid_mgr_set_physp_pi(
       (port_num != 0) )
   {
     /*
-      Switches ports that are not 0 - should not be set with the
+      Switch ports that are not numbered 0 - should not be set with the
       following attributes set later (during NO_CHANGE state in link mgr).
     */
     if( osm_log_is_active( p_mgr->p_log, OSM_LOG_DEBUG ) )
@@ -1252,7 +1262,7 @@ osm_lid_mgr_process_sm(
   CL_PLOCK_EXCL_ACQUIRE( p_mgr->p_lock );
 
   /* initialize the port_lid_tbl and empty ranges list following the
-     persistant db */
+     persistent db */
   __osm_lid_mgr_init_sweep( p_mgr );
 
   if (p_mgr->p_subn->opt.pfn_ui_pre_lid_assign)
@@ -1359,7 +1369,7 @@ osm_lid_mgr_process_subnet(
     }
   } /* all ports */
 
-  /* store the guid to lid table in persistant db */
+  /* store the guid to lid table in persistent db */
   osm_db_store( p_mgr->p_g2l );
 
   if ( p_mgr->send_set_reqs == FALSE )