[ofa-general] [PATCH] opensm: initialize all switch ports

Sasha Khapyorsky sashak at voltaire.com
Sat Feb 28 09:34:00 PST 2009


Initialize all switch port when NodeInfo is received. This addresses the
issue described in 8a2d2ddee7 where link could leave uninitialized
when SwitchInfo and PortInfo receiving races during discovery and also
simplify OpenSM discovery process implementation slightly.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
 opensm/include/opensm/osm_node.h  |    5 ++---
 opensm/opensm/osm_node.c          |   32 ++++++++------------------------
 opensm/opensm/osm_node_info_rcv.c |    4 ++--
 3 files changed, 12 insertions(+), 29 deletions(-)

diff --git a/opensm/include/opensm/osm_node.h b/opensm/include/opensm/osm_node.h
index fec24ba..c7befff 100644
--- a/opensm/include/opensm/osm_node.h
+++ b/opensm/include/opensm/osm_node.h
@@ -443,9 +443,8 @@ osm_node_get_lmc(IN const osm_node_t * const p_node, IN const uint32_t port_num)
 *
 * SYNOPSIS
 */
-void
-osm_node_init_physp(IN osm_node_t * const p_node,
-		    IN const osm_madw_t * const p_madw);
+void osm_node_init_physp(IN osm_node_t * const p_node, uint8_t port_num,
+			 IN const osm_madw_t * const p_madw);
 /*
 * PARAMETERS
 *	p_node
diff --git a/opensm/opensm/osm_node.c b/opensm/opensm/osm_node.c
index 07371a2..a97477a 100644
--- a/opensm/opensm/osm_node.c
+++ b/opensm/opensm/osm_node.c
@@ -51,20 +51,17 @@
 
 /**********************************************************************
  **********************************************************************/
-void
-osm_node_init_physp(IN osm_node_t * const p_node,
-		    IN const osm_madw_t * const p_madw)
+void osm_node_init_physp(IN osm_node_t * const p_node, uint8_t port_num,
+			 IN const osm_madw_t * const p_madw)
 {
 	ib_net64_t port_guid;
 	ib_smp_t *p_smp;
 	ib_node_info_t *p_ni;
-	uint8_t port_num;
 
 	p_smp = osm_madw_get_smp_ptr(p_madw);
 
 	p_ni = (ib_node_info_t *) ib_smp_get_payload_ptr(p_smp);
 	port_guid = p_ni->port_guid;
-	port_num = ib_node_info_get_local_port_num(p_ni);
 
 	CL_ASSERT(port_num < p_node->physp_tbl_size);
 
@@ -76,23 +73,6 @@ osm_node_init_physp(IN osm_node_t * const p_node,
 
 /**********************************************************************
  **********************************************************************/
-static void node_init_physp0(IN osm_node_t * const p_node,
-			     IN const osm_madw_t * const p_madw)
-{
-	ib_smp_t *p_smp;
-	ib_node_info_t *p_ni;
-
-	p_smp = osm_madw_get_smp_ptr(p_madw);
-	p_ni = (ib_node_info_t *) ib_smp_get_payload_ptr(p_smp);
-
-	osm_physp_init(&p_node->physp_table[0],
-		       p_ni->port_guid, 0, p_node,
-		       osm_madw_get_bind_handle(p_madw),
-		       p_smp->hop_count, p_smp->initial_path);
-}
-
-/**********************************************************************
- **********************************************************************/
 osm_node_t *osm_node_new(IN const osm_madw_t * const p_madw)
 {
 	osm_node_t *p_node;
@@ -133,9 +113,13 @@ osm_node_t *osm_node_new(IN const osm_madw_t * const p_madw)
 	for (i = 0; i < p_node->physp_tbl_size; i++)
 		osm_physp_construct(&p_node->physp_table[i]);
 
-	osm_node_init_physp(p_node, p_madw);
 	if (p_ni->node_type == IB_NODE_TYPE_SWITCH)
-		node_init_physp0(p_node, p_madw);
+		for (i = 0; i <= p_ni->num_ports; i++)
+			osm_node_init_physp(p_node, i, p_madw);
+	else
+		osm_node_init_physp(p_node,
+				    ib_node_info_get_local_port_num(p_ni),
+				    p_madw);
 	p_node->print_desc = strdup(OSM_NODE_DESC_UNKNOWN);
 
 	return (p_node);
diff --git a/opensm/opensm/osm_node_info_rcv.c b/opensm/opensm/osm_node_info_rcv.c
index a37630a..9de68f9 100644
--- a/opensm/opensm/osm_node_info_rcv.c
+++ b/opensm/opensm/osm_node_info_rcv.c
@@ -414,7 +414,7 @@ __osm_ni_rcv_process_existing_ca_or_router(IN osm_sm_t * sm,
 			"Creating new port object with GUID 0x%" PRIx64 "\n",
 			cl_ntoh64(p_ni->port_guid));
 
-		osm_node_init_physp(p_node, p_madw);
+		osm_node_init_physp(p_node, port_num, p_madw);
 
 		p_port = osm_port_new(p_ni, p_node);
 		if (p_port == NULL) {
@@ -545,7 +545,7 @@ __osm_ni_rcv_process_existing_switch(IN osm_sm_t * sm,
 			PRIx64 ", port %u\n",
 			cl_ntoh64(osm_node_get_node_guid(p_node)),
 			port_num);
-		osm_node_init_physp(p_node, p_madw);
+		osm_node_init_physp(p_node, port_num, p_madw);
 	}
 
 	/*
-- 
1.6.1.2.319.gbd9e




More information about the general mailing list