[openib-general] [PATCH 3/3] OpenSM: Utilize base router object

Hal Rosenstock halr at voltaire.com
Tue Jan 2 14:06:16 PST 2007


OpenSM: Utilize base router object 

In osm_node_info_rcv.c and osm_drop_mgr.c, utilize base router object

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

diff --git a/osm/opensm/osm_drop_mgr.c b/osm/opensm/osm_drop_mgr.c
index 5031f3b..ca5b8ac 100644
--- a/osm/opensm/osm_drop_mgr.c
+++ b/osm/opensm/osm_drop_mgr.c
@@ -58,6 +58,7 @@
 #include <complib/cl_debug.h>
 #include <complib/cl_ptr_vector.h>
 #include <opensm/osm_drop_mgr.h>
+#include <opensm/osm_router.h>
 #include <opensm/osm_switch.h>
 #include <opensm/osm_node.h>
 #include <opensm/osm_helper.h>
@@ -117,6 +118,28 @@ osm_drop_mgr_init(
 /**********************************************************************
  **********************************************************************/
 static void
+__osm_drop_mgr_remove_router(
+  IN const osm_drop_mgr_t* const p_mgr,
+  IN const ib_net64_t portguid )
+{
+  osm_router_t *p_rtr;
+  cl_qmap_t* p_rtr_guid_tbl;
+
+  p_rtr_guid_tbl = &p_mgr->p_subn->rtr_guid_tbl;
+  p_rtr = (osm_router_t*)cl_qmap_remove( p_rtr_guid_tbl, portguid );
+  if( p_rtr != (osm_router_t*)cl_qmap_end( p_rtr_guid_tbl ) )
+  {
+    osm_log( p_mgr->p_log, OSM_LOG_VERBOSE,
+             "__osm_drop_mgr_remove_router: "
+             "Cleaned router for port guid 0x%016" PRIx64 "\n",
+             cl_ntoh64( portguid ) );
+    osm_router_delete( &p_rtr );
+  }
+}
+
+/**********************************************************************
+ **********************************************************************/
+static void
 __osm_drop_mgr_remove_port(
   IN const osm_drop_mgr_t* const p_mgr,
   IN osm_port_t* p_port )
@@ -195,6 +218,8 @@ __osm_drop_mgr_remove_port(
     free(p_sm);
   }
 
+  __osm_drop_mgr_remove_router( p_mgr, port_guid );
+
   osm_port_get_lid_range_ho( p_port, &min_lid_ho, &max_lid_ho );
 
   osm_log( p_mgr->p_log, OSM_LOG_VERBOSE,
diff --git a/osm/opensm/osm_node_info_rcv.c b/osm/opensm/osm_node_info_rcv.c
index ebec592..11b7cb8 100644
--- a/osm/opensm/osm_node_info_rcv.c
+++ b/osm/opensm/osm_node_info_rcv.c
@@ -61,6 +61,7 @@
 #include <opensm/osm_log.h>
 #include <opensm/osm_node.h>
 #include <opensm/osm_subnet.h>
+#include <opensm/osm_router.h>
 #include <opensm/osm_mad_pool.h>
 #include <opensm/osm_helper.h>
 #include <opensm/osm_msgdef.h>
@@ -713,8 +714,11 @@ __osm_ni_rcv_process_new(
   osm_node_t *p_node_check;
   osm_port_t *p_port;
   osm_port_t *p_port_check;
+  osm_router_t *p_rtr = NULL;
+  osm_router_t *p_rtr_check;
   cl_qmap_t *p_node_guid_tbl;
   cl_qmap_t *p_port_guid_tbl;
+  cl_qmap_t *p_rtr_guid_tbl;
   ib_node_info_t *p_ni;
   ib_smp_t *p_smp;
   osm_ni_context_t *p_ni_context;
@@ -761,6 +765,19 @@ __osm_ni_rcv_process_new(
     goto Exit;
   }
 
+  /* If there were RouterInfo or other router attribute,
+     this would be elsewhere */
+  if ( p_ni->node_type == IB_NODE_TYPE_ROUTER )
+  {
+    p_rtr = osm_router_new( p_port );
+    if ( p_rtr == NULL )
+    {
+      osm_log( p_rcv->p_log, OSM_LOG_ERROR,
+               "__osm_ni_rcv_process_new: ERR 0D1A: "
+               "Unable to create new router object\n" );
+    }
+  }
+
   /*
     Add the new port object to the database.
   */
@@ -786,6 +803,8 @@ __osm_ni_rcv_process_new(
                      osm_physp_get_dr_path_ptr(
                        osm_port_get_default_phys_ptr ( p_port_check) ),
                      OSM_LOG_ERROR);
+    if ( p_rtr )
+      osm_router_delete( &p_rtr );
     osm_port_delete( &p_port );
     osm_node_delete( &p_node );
     goto Exit;
@@ -807,6 +826,8 @@ __osm_ni_rcv_process_new(
                "__osm_ni_rcv_process_new: ERR 0D05: "
                "Error %s adding to new_ports_list\n",
                CL_STATUS_MSG( status ) );
+      if ( p_rtr )
+        osm_router_delete( &p_rtr );
       osm_port_delete( &p_port );
       osm_node_delete( &p_node );
       goto Exit;
@@ -820,6 +841,21 @@ __osm_ni_rcv_process_new(
     }
   }
 
+  if ( p_rtr && p_ni->node_type == IB_NODE_TYPE_ROUTER )
+  {
+    p_rtr_guid_tbl = &p_rcv->p_subn->rtr_guid_tbl;
+    p_rtr_check = (osm_router_t*)cl_qmap_insert( p_rtr_guid_tbl,
+                                                 p_ni->port_guid,
+                                                 &p_rtr->map_item );
+    if( p_rtr_check != p_rtr )
+    {
+      osm_log( p_rcv->p_log, OSM_LOG_ERROR,
+               "__osm_ni_rcv_process_new: ERR 0D1B: "
+               "Unable to add port GUID:0x%016" PRIx64 " to router table\n",
+               cl_ntoh64( p_ni->port_guid ) );
+    }
+  }
+
   p_node_guid_tbl = &p_rcv->p_subn->node_guid_tbl;
   p_node_check = (osm_node_t*)cl_qmap_insert( p_node_guid_tbl,
                                               p_ni->node_guid,







More information about the general mailing list