[openib-general] [PATCH] OpenSM/osm_node_info_rcv.c: Consolidate IB router handling with CA handling
Hal Rosenstock
halr at voltaire.com
Tue Nov 7 09:56:13 PST 2006
OpenSM/osm_node_info_rcv.c: Consolidate IB router handling with CA
handling
From: Rolf Manderscheid <rvm at obsidianresearch.com>
Signed-off-by: Hal Rosenstock <halr at voltaire.com>
Index: opensm/osm_node_info_rcv.c
===================================================================
--- opensm/osm_node_info_rcv.c (revision 10056)
+++ opensm/osm_node_info_rcv.c (working copy)
@@ -408,12 +408,12 @@ __osm_ni_rcv_get_node_desc(
The plock must be held before calling this function.
**********************************************************************/
static void
-__osm_ni_rcv_process_new_ca(
+__osm_ni_rcv_process_new_ca_or_router(
IN const osm_ni_rcv_t* const p_rcv,
IN osm_node_t* const p_node,
IN const osm_madw_t* const p_madw )
{
- OSM_LOG_ENTER( p_rcv->p_log, __osm_ni_rcv_process_new_ca );
+ OSM_LOG_ENTER( p_rcv->p_log, __osm_ni_rcv_process_new_ca_or_router );
__osm_ni_rcv_process_new_node( p_rcv, p_node, p_madw );
@@ -434,7 +434,7 @@ __osm_ni_rcv_process_new_ca(
The plock must be held before calling this function.
**********************************************************************/
static void
-__osm_ni_rcv_process_existing_ca(
+__osm_ni_rcv_process_existing_ca_or_router(
IN const osm_ni_rcv_t* const p_rcv,
IN osm_node_t* const p_node,
IN const osm_madw_t* const p_madw )
@@ -452,7 +452,7 @@ __osm_ni_rcv_process_existing_ca(
osm_bind_handle_t h_bind;
cl_status_t cl_status;
- OSM_LOG_ENTER( p_rcv->p_log, __osm_ni_rcv_process_existing_ca );
+ OSM_LOG_ENTER( p_rcv->p_log, __osm_ni_rcv_process_existing_ca_or_router );
p_smp = osm_madw_get_smp_ptr( p_madw );
p_ni = (ib_node_info_t*)ib_smp_get_payload_ptr( p_smp );
@@ -470,7 +470,7 @@ __osm_ni_rcv_process_existing_ca(
if( p_port == (osm_port_t*)cl_qmap_end( p_guid_tbl ) )
{
osm_log( p_rcv->p_log, OSM_LOG_VERBOSE,
- "__osm_ni_rcv_process_existing_ca: "
+ "__osm_ni_rcv_process_existing_ca_or_router: "
"Creating new port object with GUID = 0x%" PRIx64 "\n",
cl_ntoh64( p_ni->port_guid ) );
@@ -480,7 +480,7 @@ __osm_ni_rcv_process_existing_ca(
if( p_port == NULL )
{
osm_log( p_rcv->p_log, OSM_LOG_ERROR,
- "__osm_ni_rcv_process_existing_ca: ERR 0D04: "
+ "__osm_ni_rcv_process_existing_ca_or_router: ERR 0D04: "
"Unable to create new port object\n" );
goto Exit;
}
@@ -497,7 +497,7 @@ __osm_ni_rcv_process_existing_ca(
Somehow, this port GUID already exists in the table.
*/
osm_log( p_rcv->p_log, OSM_LOG_ERROR,
- "__osm_ni_rcv_process_existing_ca: ERR 0D12: "
+ "__osm_ni_rcv_process_existing_ca_or_router: ERR 0D12: "
"Port 0x%" PRIx64 " already in the database!\n",
cl_ntoh64( p_ni->port_guid ) );
@@ -518,7 +518,7 @@ __osm_ni_rcv_process_existing_ca(
if( cl_status != CL_SUCCESS )
{
osm_log( p_rcv->p_log, OSM_LOG_ERROR,
- "__osm_ni_rcv_process_existing_ca: ERR 0D08: "
+ "__osm_ni_rcv_process_existing_ca_or_router: ERR 0D08: "
"Error %s adding to list\n",
CL_STATUS_MSG( cl_status ) );
osm_port_delete( &p_port );
@@ -527,7 +527,7 @@ __osm_ni_rcv_process_existing_ca(
else
{
osm_log( p_rcv->p_log, OSM_LOG_DEBUG,
- "__osm_ni_rcv_process_existing_ca: "
+ "__osm_ni_rcv_process_existing_ca_or_router: "
"Adding port GUID:0x%016" PRIx64 " to new_ports_list\n",
cl_ntoh64(osm_node_get_node_guid( p_port->p_node )) );
}
@@ -544,7 +544,7 @@ __osm_ni_rcv_process_existing_ca(
if ( !osm_physp_is_valid( p_physp ) )
{
osm_log( p_rcv->p_log, OSM_LOG_ERROR,
- "__osm_ni_rcv_process_existing_ca: ERR 0D19: "
+ "__osm_ni_rcv_process_existing_ca_or_router: ERR 0D19: "
"Invalid physical port. Aborting discovery\n");
goto Exit;
}
@@ -576,189 +576,7 @@ __osm_ni_rcv_process_existing_ca(
if( status != IB_SUCCESS )
{
osm_log( p_rcv->p_log, OSM_LOG_ERROR,
- "__osm_ni_rcv_process_existing_ca: ERR 0D13: "
- "Failure initiating PortInfo request (%s)\n",
- ib_get_err_str(status));
- }
-
- Exit:
- OSM_LOG_EXIT( p_rcv->p_log );
-}
-
-/**********************************************************************
- The plock must be held before calling this function.
-**********************************************************************/
-static void
-__osm_ni_rcv_process_new_router(
- IN const osm_ni_rcv_t* const p_rcv,
- IN osm_node_t* const p_node,
- IN const osm_madw_t* const p_madw )
-{
- OSM_LOG_ENTER( p_rcv->p_log, __osm_ni_rcv_process_new_router );
-
- __osm_ni_rcv_process_new_node( p_rcv, p_node, p_madw );
-
- /*
- A node guid of 0 is the corner case that indicates
- we discovered our own node. Initialize the subnet
- object with the SM's own port guid.
- */
- if( osm_madw_get_ni_context_ptr( p_madw )->node_guid == 0 )
- {
- p_rcv->p_subn->sm_port_guid = p_node->node_info.port_guid;
- }
-
- OSM_LOG_EXIT( p_rcv->p_log );
-}
-
-/**********************************************************************
- The plock must be held before calling this function.
-**********************************************************************/
-static void
-__osm_ni_rcv_process_existing_router(
- IN const osm_ni_rcv_t* const p_rcv,
- IN osm_node_t* const p_node,
- IN const osm_madw_t* const p_madw )
-{
- ib_node_info_t *p_ni;
- ib_smp_t *p_smp;
- osm_port_t *p_port;
- osm_port_t *p_port_check;
- cl_qmap_t *p_guid_tbl;
- osm_madw_context_t context;
- uint8_t port_num;
- osm_physp_t *p_physp;
- ib_api_status_t status;
- osm_dr_path_t *p_dr_path;
- osm_bind_handle_t h_bind;
- cl_status_t cl_status;
-
- OSM_LOG_ENTER( p_rcv->p_log, __osm_ni_rcv_process_existing_router );
-
- p_smp = osm_madw_get_smp_ptr( p_madw );
- p_ni = (ib_node_info_t*)ib_smp_get_payload_ptr( p_smp );
- port_num = ib_node_info_get_local_port_num( p_ni );
- p_guid_tbl = &p_rcv->p_subn->port_guid_tbl;
- h_bind = osm_madw_get_bind_handle( p_madw );
-
- /*
- Determine if we have encountered this node through a
- previously undiscovered port. If so, build the new
- port object.
- */
- p_port = (osm_port_t*)cl_qmap_get( p_guid_tbl, p_ni->port_guid );
-
- if( p_port == (osm_port_t*)cl_qmap_end( p_guid_tbl ) )
- {
- osm_log( p_rcv->p_log, OSM_LOG_VERBOSE,
- "__osm_ni_rcv_process_existing_router: "
- "Creating new port object with GUID = 0x%" PRIx64 "\n",
- cl_ntoh64( p_ni->port_guid ) );
-
- osm_node_init_physp( p_node, p_madw );
-
- p_port = osm_port_new( p_ni, p_node );
- if( p_port == NULL )
- {
- osm_log( p_rcv->p_log, OSM_LOG_ERROR,
- "__osm_ni_rcv_process_existing_router: ERR 0D24: "
- "Unable to create new port object\n" );
- goto Exit;
- }
-
- /*
- Add the new port object to the database.
- */
- p_port_check = (osm_port_t*)cl_qmap_insert( p_guid_tbl,
- p_ni->port_guid, &p_port->map_item );
- if( p_port_check != p_port )
- {
- /*
- We should never be here!
- Somehow, this port GUID already exists in the table.
- */
- osm_log( p_rcv->p_log, OSM_LOG_ERROR,
- "__osm_ni_rcv_process_existing_router: ERR 0D22: "
- "Port 0x%" PRIx64 " already in the database!\n",
- cl_ntoh64( p_ni->port_guid ) );
-
- osm_port_delete( &p_port );
-
- goto Exit;
- }
-
- /* If we are a master, then this means the port is new on the subnet.
- Add it to the new_ports_list - need to send trap 64 on these ports.
- The condition that we are master is true, since if we are in discovering
- state (meaning we woke up from standby or we are just initializing),
- then these ports may be new to us, but are not new on the subnet.
- If we are master, then the subnet as we know it is the updated one,
- and any new ports we encounter should cause trap 64. C14-72.1.1 */
- if ( p_rcv->p_subn->sm_state == IB_SMINFO_STATE_MASTER )
- {
- cl_status = cl_list_insert_tail( &p_rcv->p_subn->new_ports_list, p_port );
- if( cl_status != CL_SUCCESS )
- {
- osm_log( p_rcv->p_log, OSM_LOG_ERROR,
- "__osm_ni_rcv_process_existing_router: ERR 0D28: "
- "Error %s adding to list\n",
- CL_STATUS_MSG( cl_status ) );
- osm_port_delete( &p_port );
- goto Exit;
- }
- else
- {
- osm_log( p_rcv->p_log, OSM_LOG_DEBUG,
- "__osm_ni_rcv_process_existing_router: "
- "Adding port GUID:0x%016" PRIx64 " to new_ports_list\n",
- cl_ntoh64(osm_node_get_node_guid( p_port->p_node )) );
- }
- }
-
- p_physp = osm_node_get_physp_ptr( p_node, port_num );
- }
- else
- {
- p_physp = osm_node_get_physp_ptr( p_node, port_num );
-
- CL_ASSERT( p_physp );
-
- if ( !osm_physp_is_valid( p_physp ) )
- {
- osm_log( p_rcv->p_log, OSM_LOG_ERROR,
- "__osm_ni_rcv_process_existing_router: ERR 0D29: "
- "Invalid physical port. Aborting discovery\n");
- goto Exit;
- }
-
- /*
- Update the DR Path to the port,
- in case the old one is no longer available.
- */
- p_dr_path = osm_physp_get_dr_path_ptr( p_physp );
-
- osm_dr_path_init( p_dr_path, h_bind, p_smp->hop_count,
- p_smp->initial_path );
- }
-
- context.pi_context.node_guid = p_ni->node_guid;
- context.pi_context.port_guid = p_ni->port_guid;
- context.pi_context.set_method = FALSE;
- context.pi_context.update_master_sm_base_lid = FALSE;
- context.pi_context.ignore_errors = FALSE;
- context.pi_context.light_sweep = FALSE;
-
- status = osm_req_get( p_rcv->p_gen_req,
- osm_physp_get_dr_path_ptr( p_physp ),
- IB_MAD_ATTR_PORT_INFO,
- cl_hton32( port_num ),
- CL_DISP_MSGID_NONE,
- &context );
-
- if( status != IB_SUCCESS )
- {
- osm_log( p_rcv->p_log, OSM_LOG_ERROR,
- "__osm_ni_rcv_process_existing_router: ERR 0D23: "
+ "__osm_ni_rcv_process_existing_ca_or_router: ERR 0D13: "
"Failure initiating PortInfo request (%s)\n",
ib_get_err_str(status));
}
@@ -1037,14 +855,12 @@ __osm_ni_rcv_process_new(
switch( p_ni->node_type )
{
case IB_NODE_TYPE_CA:
- __osm_ni_rcv_process_new_ca( p_rcv, p_node, p_madw );
+ case IB_NODE_TYPE_ROUTER:
+ __osm_ni_rcv_process_new_ca_or_router( p_rcv, p_node, p_madw );
break;
case IB_NODE_TYPE_SWITCH:
__osm_ni_rcv_process_new_switch( p_rcv, p_node, p_madw );
break;
- case IB_NODE_TYPE_ROUTER:
- __osm_ni_rcv_process_new_router( p_rcv, p_node, p_madw );
- break;
default:
osm_log( p_rcv->p_log, OSM_LOG_ERROR,
"__osm_ni_rcv_process_new: ERR 0D16: "
@@ -1099,12 +915,9 @@ __osm_ni_rcv_process_existing(
switch( p_ni->node_type )
{
- case IB_NODE_TYPE_ROUTER:
- __osm_ni_rcv_process_existing_router( p_rcv, p_node, p_madw );
- break;
-
case IB_NODE_TYPE_CA:
- __osm_ni_rcv_process_existing_ca( p_rcv, p_node, p_madw );
+ case IB_NODE_TYPE_ROUTER:
+ __osm_ni_rcv_process_existing_ca_or_router( p_rcv, p_node, p_madw );
break;
case IB_NODE_TYPE_SWITCH:
More information about the general
mailing list