[ofa-general] [PATCH] opensm: cleanup osm_physp_is_valid() use

Sasha Khapyorsky sashak at voltaire.com
Sun Jan 27 07:40:44 PST 2008


osm_node_get_physp_ptr() will return only pointer to initialized
osm_physp_t or NULL otherwise. This simplifies many flows in OpenSM.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
 opensm/include/opensm/osm_node.h        |   10 +++---
 opensm/include/opensm/osm_port.h        |    2 +-
 opensm/opensm/osm_console.c             |    2 +-
 opensm/opensm/osm_drop_mgr.c            |    6 ++--
 opensm/opensm/osm_dump.c                |    9 +++---
 opensm/opensm/osm_lid_mgr.c             |    8 ++---
 opensm/opensm/osm_link_mgr.c            |    8 +----
 opensm/opensm/osm_mcast_mgr.c           |   23 +--------------
 opensm/opensm/osm_node.c                |    9 +++---
 opensm/opensm/osm_perfmgr.c             |    4 +-
 opensm/opensm/osm_pkey_mgr.c            |    8 +++---
 opensm/opensm/osm_pkey_rcv.c            |    2 +-
 opensm/opensm/osm_port.c                |   23 +++++++---------
 opensm/opensm/osm_port_info_rcv.c       |    9 +++---
 opensm/opensm/osm_qos.c                 |    4 +-
 opensm/opensm/osm_qos_parser.y          |    5 +--
 opensm/opensm/osm_sa_guidinfo_record.c  |    7 ++---
 opensm/opensm/osm_sa_link_record.c      |   44 +++++++-----------------------
 opensm/opensm/osm_sa_multipath_record.c |    3 --
 opensm/opensm/osm_sa_node_record.c      |    7 ++---
 opensm/opensm/osm_sa_path_record.c      |    3 --
 opensm/opensm/osm_sa_pkey_record.c      |    4 +-
 opensm/opensm/osm_sa_portinfo_record.c  |    8 +++---
 opensm/opensm/osm_sa_slvl_record.c      |    4 +-
 opensm/opensm/osm_sa_vlarb_record.c     |    4 +-
 opensm/opensm/osm_slvl_map_rcv.c        |    4 +--
 opensm/opensm/osm_state_mgr.c           |    5 +--
 opensm/opensm/osm_sw_info_rcv.c         |    6 ----
 opensm/opensm/osm_switch.c              |    6 +---
 opensm/opensm/osm_trap_rcv.c            |   27 ++++++++----------
 opensm/opensm/osm_ucast_ftree.c         |   22 +++------------
 opensm/opensm/osm_ucast_lash.c          |   14 +++------
 opensm/opensm/osm_ucast_updn.c          |    7 +---
 opensm/opensm/osm_vl_arb_rcv.c          |    4 +--
 34 files changed, 107 insertions(+), 204 deletions(-)

diff --git a/opensm/include/opensm/osm_node.h b/opensm/include/opensm/osm_node.h
index a900e03..56e4dbb 100644
--- a/opensm/include/opensm/osm_node.h
+++ b/opensm/include/opensm/osm_node.h
@@ -213,13 +213,13 @@ osm_node_t *osm_node_new(IN const osm_madw_t * const p_madw);
 *
 * SYNOPSIS
 */
-static inline osm_physp_t *osm_node_get_physp_ptr(IN const osm_node_t *
-						  const p_node,
+static inline osm_physp_t *osm_node_get_physp_ptr(IN osm_node_t * const p_node,
 						  IN const uint32_t port_num)
 {
 
 	CL_ASSERT(port_num < p_node->physp_tbl_size);
-	return ((osm_physp_t *) & p_node->physp_table[port_num]);
+	return osm_physp_is_valid(&p_node->physp_table[port_num]) ?
+		&p_node->physp_table[port_num] : NULL;
 }
 
 /*
@@ -383,7 +383,7 @@ static inline uint8_t osm_node_get_num_physp(IN const osm_node_t * const p_node)
 *
 * SYNOPSIS
 */
-osm_node_t *osm_node_get_remote_node(IN const osm_node_t * const p_node,
+osm_node_t *osm_node_get_remote_node(IN osm_node_t * const p_node,
 				     IN const uint8_t port_num,
 				     OUT uint8_t * p_remote_port_num);
 /*
@@ -457,7 +457,7 @@ osm_node_get_base_lid(IN const osm_node_t * const p_node,
 * SYNOPSIS
 */
 ib_net16_t
-osm_node_get_remote_base_lid(IN const osm_node_t * const p_node,
+osm_node_get_remote_base_lid(IN osm_node_t * const p_node,
 			     IN const uint32_t port_num);
 /*
 * PARAMETERS
diff --git a/opensm/include/opensm/osm_port.h b/opensm/include/opensm/osm_port.h
index 1bf737c..963e13b 100644
--- a/opensm/include/opensm/osm_port.h
+++ b/opensm/include/opensm/osm_port.h
@@ -1252,7 +1252,7 @@ void osm_port_delete(IN OUT osm_port_t ** const pp_port);
 * SYNOPSIS
 */
 osm_port_t *osm_port_new(IN const ib_node_info_t * p_ni,
-			 IN const struct _osm_node *const p_parent_node);
+			 IN struct _osm_node *const p_parent_node);
 /*
 * PARAMETERS
 *	p_ni
diff --git a/opensm/opensm/osm_console.c b/opensm/opensm/osm_console.c
index ced02e3..c0e7886 100644
--- a/opensm/opensm/osm_console.c
+++ b/opensm/opensm/osm_console.c
@@ -630,7 +630,7 @@ static void __get_stats(cl_map_item_t * const p_map_item, void *context)
 		uint8_t port_state = ib_port_info_get_port_state(pi);
 		uint8_t port_phys_state = ib_port_info_get_port_phys_state(pi);
 
-		if (!osm_physp_is_valid(phys))
+		if (!phys)
 			continue;
 
 		if ((enabled_width ^ active_width) > active_width) {
diff --git a/opensm/opensm/osm_drop_mgr.c b/opensm/opensm/osm_drop_mgr.c
index 39ceaa1..2b8966c 100644
--- a/opensm/opensm/osm_drop_mgr.c
+++ b/opensm/opensm/osm_drop_mgr.c
@@ -136,7 +136,7 @@ drop_mgr_clean_physp(IN const osm_drop_mgr_t * const p_mgr,
 	osm_port_t *p_remote_port;
 
 	p_remote_physp = osm_physp_get_remote(p_physp);
-	if (p_remote_physp && osm_physp_is_valid(p_remote_physp)) {
+	if (p_remote_physp) {
 		p_remote_port = osm_get_port_by_guid(p_mgr->p_subn,
 						     p_remote_physp->port_guid);
 
@@ -383,7 +383,7 @@ __osm_drop_mgr_process_node(IN const osm_drop_mgr_t * const p_mgr,
 	max_ports = osm_node_get_num_physp(p_node);
 	for (port_num = 0; port_num < max_ports; port_num++) {
 		p_physp = osm_node_get_physp_ptr(p_node, port_num);
-		if (osm_physp_is_valid(p_physp)) {
+		if (p_physp) {
 			port_guid = osm_physp_get_port_guid(p_physp);
 
 			p_port = osm_get_port_by_guid(p_mgr->p_subn, port_guid);
@@ -454,7 +454,7 @@ __osm_drop_mgr_check_node(IN const osm_drop_mgr_t * const p_mgr,
 
 	/* Make sure we have a port object for port zero */
 	p_physp = osm_node_get_physp_ptr(p_node, 0);
-	if (!osm_physp_is_valid(p_physp)) {
+	if (!p_physp) {
 		osm_log(p_mgr->p_log, OSM_LOG_VERBOSE,
 			"__osm_drop_mgr_check_node: "
 			"Node 0x%016" PRIx64 " no valid physical port 0\n",
diff --git a/opensm/opensm/osm_dump.c b/opensm/opensm/osm_dump.c
index 43ae05e..f47c992 100644
--- a/opensm/opensm/osm_dump.c
+++ b/opensm/opensm/osm_dump.c
@@ -394,11 +394,11 @@ static void dump_topology_node(cl_map_item_t * p_map_item, void *cxt)
 		uint8_t port_state;
 
 		p_physp = osm_node_get_physp_ptr(p_node, cPort);
-		if (!osm_physp_is_valid(p_physp))
+		if (!p_physp)
 			continue;
 
 		p_rphysp = p_physp->p_remote_physp;
-		if (!p_rphysp || !osm_physp_is_valid(p_rphysp))
+		if (!p_rphysp)
 			continue;
 
 		CL_ASSERT(cPort == p_physp->port_num);
@@ -503,7 +503,7 @@ static void print_node_report(cl_map_item_t * p_map_item, void *cxt)
 	port_num = node_type == IB_NODE_TYPE_SWITCH ? 0 : 1;
 	for (; port_num < num_ports; port_num++) {
 		p_physp = osm_node_get_physp_ptr(p_node, port_num);
-		if (!osm_physp_is_valid(p_physp))
+		if (!p_physp)
 			continue;
 
 		osm_log_printf(log, OSM_LOG_VERBOSE, "%-11s : %s : %02X :",
@@ -563,8 +563,7 @@ static void print_node_report(cl_map_item_t * p_map_item, void *cxt)
 		if (port_num
 		    && (ib_port_info_get_port_state(p_pi) != IB_LINK_DOWN)) {
 			p_remote_physp = osm_physp_get_remote(p_physp);
-			if (p_remote_physp
-			    && osm_physp_is_valid(p_remote_physp))
+			if (p_remote_physp)
 				osm_log_printf(log, OSM_LOG_VERBOSE,
 					       " %016" PRIx64 " (%02X)",
 					       cl_ntoh64
diff --git a/opensm/opensm/osm_lid_mgr.c b/opensm/opensm/osm_lid_mgr.c
index f248676..3ceb145 100644
--- a/opensm/opensm/osm_lid_mgr.c
+++ b/opensm/opensm/osm_lid_mgr.c
@@ -883,10 +883,8 @@ __osm_lid_mgr_set_remote_pi_state_to_init(IN osm_lid_mgr_t * const p_mgr,
 	if (p_rem_physp == NULL)
 		return;
 
-	if (osm_physp_is_valid(p_rem_physp))
-		/* but in some rare cases the remote side might be irresponsive */
-		ib_port_info_set_port_state(&p_rem_physp->port_info,
-					    IB_LINK_INIT);
+	/* but in some rare cases the remote side might be irresponsive */
+	ib_port_info_set_port_state(&p_rem_physp->port_info, IB_LINK_INIT);
 }
 
 /**********************************************************************
@@ -914,7 +912,7 @@ __osm_lid_mgr_set_physp_pi(IN osm_lid_mgr_t * const p_mgr,
 	   Don't bother doing anything if this Physical Port is not valid.
 	   This allows simplified code in the caller.
 	 */
-	if (p_physp == NULL || !osm_physp_is_valid(p_physp))
+	if (!p_physp)
 		goto Exit;
 
 	port_num = osm_physp_get_port_num(p_physp);
diff --git a/opensm/opensm/osm_link_mgr.c b/opensm/opensm/osm_link_mgr.c
index 3d38362..19cb27d 100644
--- a/opensm/opensm/osm_link_mgr.c
+++ b/opensm/opensm/osm_link_mgr.c
@@ -116,9 +116,6 @@ __osm_link_mgr_set_physp_pi(IN osm_link_mgr_t * const p_mgr,
 
 	OSM_LOG_ENTER(p_mgr->p_log, __osm_link_mgr_set_physp_pi);
 
-	CL_ASSERT(p_physp);
-	CL_ASSERT(osm_physp_is_valid(p_physp));
-
 	p_node = osm_physp_get_node_ptr(p_physp);
 
 	port_num = osm_physp_get_port_num(p_physp);
@@ -241,8 +238,7 @@ __osm_link_mgr_set_physp_pi(IN osm_link_mgr_t * const p_mgr,
 		   Several timeout mechanisms:
 		 */
 		p_remote_physp = osm_physp_get_remote(p_physp);
-		if (port_num != 0 && p_remote_physp &&
-		    osm_physp_is_valid(p_remote_physp)) {
+		if (port_num != 0 && p_remote_physp) {
 			if (osm_node_get_type(osm_physp_get_node_ptr(p_physp))
 			    == IB_NODE_TYPE_ROUTER) {
 				ib_port_info_set_hoq_lifetime(p_pi,
@@ -418,7 +414,7 @@ __osm_link_mgr_process_node(IN osm_link_mgr_t * const p_mgr,
 		   specified state.
 		 */
 		p_physp = osm_node_get_physp_ptr(p_node, (uint8_t) i);
-		if (!osm_physp_is_valid(p_physp))
+		if (!p_physp)
 			continue;
 
 		current_state = osm_physp_get_port_state(p_physp);
diff --git a/opensm/opensm/osm_mcast_mgr.c b/opensm/opensm/osm_mcast_mgr.c
index 0c0ab25..1178522 100644
--- a/opensm/opensm/osm_mcast_mgr.c
+++ b/opensm/opensm/osm_mcast_mgr.c
@@ -720,7 +720,7 @@ static osm_mtree_node_t *__osm_mcast_mgr_branch(osm_mcast_mgr_t * const p_mgr,
 	for (i = 0; i < max_children; i++) {
 		const osm_physp_t *p_physp;
 		const osm_physp_t *p_remote_physp;
-		const osm_node_t *p_node;
+		osm_node_t *p_node;
 		const osm_node_t *p_remote_node;
 
 		p_port_list = &list_array[i];
@@ -767,11 +767,10 @@ static osm_mtree_node_t *__osm_mcast_mgr_branch(osm_mcast_mgr_t * const p_mgr,
 			CL_ASSERT(p_remote_node->sw);
 
 			p_physp = osm_node_get_physp_ptr(p_node, i);
-			CL_ASSERT(osm_physp_is_valid(p_physp));
+			CL_ASSERT(p_physp);
 
 			p_remote_physp = osm_physp_get_remote(p_physp);
 			CL_ASSERT(p_remote_physp);
-			CL_ASSERT(osm_physp_is_valid(p_remote_physp));
 
 			p_mtn->child_array[i] =
 			    __osm_mcast_mgr_branch(p_mgr, p_mgrp,
@@ -1068,15 +1067,6 @@ osm_mcast_mgr_process_single(IN osm_mcast_mgr_t * const p_mgr,
 		goto Exit;
 	}
 
-	if (!osm_physp_is_valid(p_physp)) {
-		osm_log(p_mgr->p_log, OSM_LOG_ERROR,
-			"osm_mcast_mgr_process_single: ERR 0A07: "
-			"Unable to acquire valid physical port object "
-			"for 0x%" PRIx64 "\n", cl_ntoh64(port_guid));
-		status = IB_ERROR;
-		goto Exit;
-	}
-
 	p_remote_physp = osm_physp_get_remote(p_physp);
 	if (p_remote_physp == NULL) {
 		osm_log(p_mgr->p_log, OSM_LOG_ERROR,
@@ -1087,15 +1077,6 @@ osm_mcast_mgr_process_single(IN osm_mcast_mgr_t * const p_mgr,
 		goto Exit;
 	}
 
-	if (!osm_physp_is_valid(p_remote_physp)) {
-		osm_log(p_mgr->p_log, OSM_LOG_ERROR,
-			"osm_mcast_mgr_process_single: ERR 0A21: "
-			"Unable to acquire valid remote physical port object "
-			"for 0x%" PRIx64 "\n", cl_ntoh64(port_guid));
-		status = IB_ERROR;
-		goto Exit;
-	}
-
 	p_remote_node = osm_physp_get_node_ptr(p_remote_physp);
 
 	CL_ASSERT(p_remote_node);
diff --git a/opensm/opensm/osm_node.c b/opensm/opensm/osm_node.c
index 4586ff5..85ea3c9 100644
--- a/opensm/opensm/osm_node.c
+++ b/opensm/opensm/osm_node.c
@@ -261,8 +261,7 @@ osm_node_link_has_valid_ports(IN osm_node_t * const p_node,
 	p_physp = osm_node_get_physp_ptr(p_node, port_num);
 	p_remote_physp = osm_node_get_physp_ptr(p_remote_node, remote_port_num);
 
-	return (osm_physp_is_valid(p_physp) &&
-		osm_physp_is_valid(p_remote_physp));
+	return (p_physp && p_remote_physp);
 }
 
 /**********************************************************************
@@ -278,7 +277,7 @@ osm_node_has_any_link(IN osm_node_t * const p_node, IN const uint8_t port_num)
 
 /**********************************************************************
  **********************************************************************/
-osm_node_t *osm_node_get_remote_node(IN const osm_node_t * const p_node,
+osm_node_t *osm_node_get_remote_node(IN osm_node_t * const p_node,
 				     IN const uint8_t port_num,
 				     OUT uint8_t * p_remote_port_num)
 {
@@ -301,7 +300,7 @@ osm_node_t *osm_node_get_remote_node(IN const osm_node_t * const p_node,
  The lock must be held before calling this function.
 **********************************************************************/
 ib_net16_t
-osm_node_get_remote_base_lid(IN const osm_node_t * const p_node,
+osm_node_get_remote_base_lid(IN osm_node_t * const p_node,
 			     IN const uint32_t port_num)
 {
 	osm_physp_t *p_physp;
@@ -309,7 +308,7 @@ osm_node_get_remote_base_lid(IN const osm_node_t * const p_node,
 	CL_ASSERT(port_num < p_node->physp_tbl_size);
 
 	p_physp = osm_node_get_physp_ptr(p_node, port_num);
-	if (osm_physp_is_valid(p_physp)) {
+	if (p_physp) {
 		p_remote_physp = osm_physp_get_remote(p_physp);
 		return (osm_physp_get_base_lid(p_remote_physp));
 	}
diff --git a/opensm/opensm/osm_perfmgr.c b/opensm/opensm/osm_perfmgr.c
index 860a20d..091b46a 100644
--- a/opensm/opensm/osm_perfmgr.c
+++ b/opensm/opensm/osm_perfmgr.c
@@ -515,7 +515,7 @@ __osm_perfmgr_query_counters(cl_map_item_t * const p_map_item, void *context)
 	for (port = startport; port < num_ports; port++) {
 		ib_net16_t lid;
 
-		if (!osm_physp_is_valid(osm_node_get_physp_ptr(node, port)))
+		if (!osm_node_get_physp_ptr(node, port))
 			continue;
 
 		lid = get_lid(node, port, mon_node);
@@ -592,7 +592,7 @@ static int sweep_hop_1(osm_sm_t * sm)
 
 	p_physp = osm_node_get_physp_ptr(p_node, port_num);
 
-	CL_ASSERT(osm_physp_is_valid(p_physp));
+	CL_ASSERT(p_physp);
 
 	p_dr_path = osm_physp_get_dr_path_ptr(p_physp);
 	h_bind = osm_dr_path_get_bind_handle(p_dr_path);
diff --git a/opensm/opensm/osm_pkey_mgr.c b/opensm/opensm/osm_pkey_mgr.c
index e098d9b..df17549 100644
--- a/opensm/opensm/osm_pkey_mgr.c
+++ b/opensm/opensm/osm_pkey_mgr.c
@@ -167,7 +167,7 @@ pkey_mgr_process_partition_table(osm_log_t * p_log, osm_sm_t * sm,
 		i = i_next;
 		i_next = cl_map_next(i);
 		p_physp = cl_map_obj(i);
-		if (p_physp && osm_physp_is_valid(p_physp))
+		if (p_physp)
 			pkey_mgr_process_physical_port(p_log, sm, pkey,
 						       p_physp);
 	}
@@ -290,7 +290,7 @@ static boolean_t pkey_mgr_update_port(osm_log_t * p_log, osm_sm_t * sm,
 	memset(&empty_block, 0, sizeof(ib_pkey_table_t));
 
 	p_physp = p_port->p_physp;
-	if (!osm_physp_is_valid(p_physp))
+	if (!p_physp)
 		return FALSE;
 
 	p_node = osm_physp_get_node_ptr(p_physp);
@@ -424,10 +424,10 @@ pkey_mgr_update_peer_port(osm_log_t * p_log, osm_sm_t * sm,
 	memset(&empty_block, 0, sizeof(ib_pkey_table_t));
 
 	p_physp = p_port->p_physp;
-	if (!osm_physp_is_valid(p_physp))
+	if (!p_physp)
 		return FALSE;
 	peer = osm_physp_get_remote(p_physp);
-	if (!peer || !osm_physp_is_valid(peer))
+	if (!peer)
 		return FALSE;
 	p_node = osm_physp_get_node_ptr(peer);
 	if (!p_node->sw || !p_node->sw->switch_info.enforce_cap)
diff --git a/opensm/opensm/osm_pkey_rcv.c b/opensm/opensm/osm_pkey_rcv.c
index c510ab5..a827e28 100644
--- a/opensm/opensm/osm_pkey_rcv.c
+++ b/opensm/opensm/osm_pkey_rcv.c
@@ -129,7 +129,7 @@ void osm_pkey_rcv_process(IN void *context, IN void *data)
 	   Determine if we encountered a new Physical Port.
 	   If so, ignore it.
 	 */
-	if (!osm_physp_is_valid(p_physp)) {
+	if (!p_physp) {
 		osm_log(sm->p_log, OSM_LOG_ERROR,
 			"osm_pkey_rcv_process: ERR 4807: "
 			"Got invalid port number 0x%X\n", port_num);
diff --git a/opensm/opensm/osm_port.c b/opensm/opensm/osm_port.c
index ffc4fb0..653212a 100644
--- a/opensm/opensm/osm_port.c
+++ b/opensm/opensm/osm_port.c
@@ -151,7 +151,7 @@ void osm_port_delete(IN OUT osm_port_t ** const pp_port)
 static void
 osm_port_init(IN osm_port_t * const p_port,
 	      IN const ib_node_info_t * p_ni,
-	      IN const osm_node_t * const p_parent_node)
+	      IN osm_node_t * const p_parent_node)
 {
 	ib_net64_t port_guid;
 	osm_physp_t *p_physp;
@@ -183,7 +183,7 @@ osm_port_init(IN osm_port_t * const p_port,
 /**********************************************************************
  **********************************************************************/
 osm_port_t *osm_port_new(IN const ib_node_info_t * p_ni,
-			 IN const osm_node_t * const p_parent_node)
+			 IN osm_node_t * const p_parent_node)
 {
 	osm_port_t *p_port;
 
@@ -318,7 +318,7 @@ osm_physp_calc_link_mtu(IN osm_log_t * p_log, IN const osm_physp_t * p_physp)
 	OSM_LOG_ENTER(p_log, osm_physp_calc_link_mtu);
 
 	p_remote_physp = osm_physp_get_remote(p_physp);
-	if (p_remote_physp && osm_physp_is_valid(p_remote_physp)) {
+	if (p_remote_physp) {
 		/* use the available MTU */
 		mtu = ib_port_info_get_mtu_cap(&p_physp->port_info);
 
@@ -383,7 +383,7 @@ osm_physp_calc_link_op_vls(IN osm_log_t * p_log,
 	OSM_LOG_ENTER(p_log, osm_physp_calc_link_op_vls);
 
 	p_remote_physp = osm_physp_get_remote(p_physp);
-	if (p_remote_physp && osm_physp_is_valid(p_remote_physp)) {
+	if (p_remote_physp) {
 		/* use the available VLCap */
 		op_vls = ib_port_info_get_vl_cap(&p_physp->port_info);
 
@@ -508,7 +508,7 @@ __osm_physp_get_dr_physp_set(IN osm_log_t * p_log,
 			p_path->path[hop]);
 
 		/* make sure we got a valid port and it has a remote port */
-		if (!osm_physp_is_valid(p_physp)) {
+		if (!p_physp) {
 			osm_log(p_log, OSM_LOG_ERROR,
 				"__osm_physp_get_dr_nodes_set: ERR 4104: "
 				"DR Traversal stopped on invalid port at hop:%u\n",
@@ -643,7 +643,6 @@ osm_physp_replace_dr_path_with_alternate_dr_path(IN osm_log_t * p_log,
 	p_physp = p_port->p_physp;
 
 	CL_ASSERT(p_physp);
-	CL_ASSERT(osm_physp_is_valid(p_physp));
 
 	cl_list_insert_tail(p_nextPortsList, p_physp);
 
@@ -675,12 +674,11 @@ osm_physp_replace_dr_path_with_alternate_dr_path(IN osm_log_t * p_log,
 				/*
 				   make sure that all of the following occurred:
 				   1. The port isn't NULL
-				   2. The port is a valid port
-				   3. This is not the port we came from
-				   4. The port is not in the physp_map
-				   5. This port haven't been visited before
+				   2. This is not the port we came from
+				   3. The port is not in the physp_map
+				   4. This port haven't been visited before
 				 */
-				if (osm_physp_is_valid(p_remote_physp) &&
+				if (p_remote_physp &&
 				    p_remote_physp != p_physp &&
 				    cl_map_get(&physp_map,
 					       __osm_ptr_to_key(p_remote_physp))
@@ -749,7 +747,7 @@ boolean_t osm_link_is_healthy(IN const osm_physp_t * const p_physp)
 
 	CL_ASSERT(p_physp);
 	p_remote_physp = p_physp->p_remote_physp;
-	if (p_remote_physp != NULL && osm_physp_is_valid(p_remote_physp))
+	if (p_remote_physp != NULL)
 		return ((p_physp->healthy) & (p_remote_physp->healthy));
 	/* the other side is not known - consider the link as healthy */
 	return (TRUE);
@@ -766,7 +764,6 @@ osm_physp_set_pkey_tbl(IN osm_log_t * p_log,
 	uint16_t max_blocks;
 
 	CL_ASSERT(p_pkey_tbl);
-	CL_ASSERT(osm_physp_is_valid(p_physp));
 	/*
 	   (14.2.5.7) - the block number valid values are 0-2047, and are further
 	   limited by the size of the P_Key table specified by the PartitionCap on the
diff --git a/opensm/opensm/osm_port_info_rcv.c b/opensm/opensm/osm_port_info_rcv.c
index b91d1a5..e56ba51 100644
--- a/opensm/opensm/osm_port_info_rcv.c
+++ b/opensm/opensm/osm_port_info_rcv.c
@@ -241,8 +241,7 @@ __osm_pi_rcv_process_switch_port(IN osm_sm_t * sm,
 		switch (ib_port_info_get_port_state(p_pi)) {
 		case IB_LINK_DOWN:
 			p_remote_physp = osm_physp_get_remote(p_physp);
-			if (p_remote_physp
-			    && osm_physp_is_valid(p_remote_physp)) {
+			if (p_remote_physp) {
 				p_remote_node =
 				    osm_physp_get_node_ptr(p_remote_physp);
 				remote_port_num =
@@ -475,7 +474,7 @@ osm_pi_rcv_process_set(IN osm_sm_t * sm, IN osm_node_t * const p_node,
 	CL_ASSERT(p_node);
 
 	p_physp = osm_node_get_physp_ptr(p_node, port_num);
-	CL_ASSERT(osm_physp_is_valid(p_physp));
+	CL_ASSERT(p_physp);
 
 	port_guid = osm_physp_get_port_guid(p_physp);
 
@@ -639,13 +638,13 @@ void osm_pi_rcv_process(IN void *context, IN void *data)
 		   If so, initialize the new Physical Port then
 		   continue processing as normal.
 		 */
-		if (!osm_physp_is_valid(p_physp)) {
+		if (!p_physp) {
 			if (osm_log_is_active(sm->p_log, OSM_LOG_VERBOSE))
 				osm_log(sm->p_log, OSM_LOG_VERBOSE,
 					"osm_pi_rcv_process: "
 					"Initializing port number 0x%X\n",
 					port_num);
-
+			p_physp = &p_node->physp_table[port_num];
 			osm_physp_init(p_physp,
 				       port_guid,
 				       port_num,
diff --git a/opensm/opensm/osm_qos.c b/opensm/opensm/osm_qos.c
index c437028..1a6cc05 100644
--- a/opensm/opensm/osm_qos.c
+++ b/opensm/opensm/osm_qos.c
@@ -311,7 +311,7 @@ osm_signal_t osm_qos_setup(osm_opensm_t * p_osm)
 			num_physp = osm_node_get_num_physp(p_node);
 			for (i = 1; i < num_physp; i++) {
 				p_physp = osm_node_get_physp_ptr(p_node, i);
-				if (!osm_physp_is_valid(p_physp))
+				if (!p_physp)
 					continue;
 				force_update = p_physp->need_update ||
 				    p_osm->subn.need_update;
@@ -332,7 +332,7 @@ osm_signal_t osm_qos_setup(osm_opensm_t * p_osm)
 			cfg = &ca_config;
 
 		p_physp = p_port->p_physp;
-		if (!osm_physp_is_valid(p_physp))
+		if (!p_physp)
 			continue;
 
 		force_update = p_physp->need_update || p_osm->subn.need_update;
diff --git a/opensm/opensm/osm_qos_parser.y b/opensm/opensm/osm_qos_parser.y
index 8cae5f3..50cac63 100644
--- a/opensm/opensm/osm_qos_parser.y
+++ b/opensm/opensm/osm_qos_parser.y
@@ -2884,9 +2884,8 @@ static void __parser_add_port_to_port_map(
     cl_qmap_t   * p_map,
     osm_physp_t * p_physp)
 {
-    if (p_physp && osm_physp_is_valid(p_physp) &&
-        cl_qmap_get(p_map, cl_ntoh64(
-           osm_physp_get_port_guid(p_physp))) == cl_qmap_end(p_map))
+    if (cl_qmap_get(p_map, cl_ntoh64(osm_physp_get_port_guid(p_physp))) ==
+        cl_qmap_end(p_map))
     {
         osm_qos_port_t * p_port = osm_qos_policy_port_create(p_physp);
         if (p_port)
diff --git a/opensm/opensm/osm_sa_guidinfo_record.c b/opensm/opensm/osm_sa_guidinfo_record.c
index a2c47bb..af8ba6e 100644
--- a/opensm/opensm/osm_sa_guidinfo_record.c
+++ b/opensm/opensm/osm_sa_guidinfo_record.c
@@ -125,7 +125,7 @@ __osm_gir_rcv_new_gir(IN osm_sa_t * sa,
  **********************************************************************/
 static void
 __osm_sa_gir_create_gir(IN osm_sa_t * sa,
-			IN const osm_node_t * const p_node,
+			IN osm_node_t * const p_node,
 			IN cl_qlist_t * const p_list,
 			IN ib_net64_t const match_port_guid,
 			IN ib_net16_t const match_lid,
@@ -164,8 +164,7 @@ __osm_sa_gir_create_gir(IN osm_sa_t * sa,
 
 	for (port_num = 0; port_num < num_ports; port_num++) {
 		p_physp = osm_node_get_physp_ptr(p_node, port_num);
-
-		if (!osm_physp_is_valid(p_physp))
+		if (!p_physp)
 			continue;
 
 		/* Check to see if the found p_physp and the requester physp
@@ -240,7 +239,7 @@ __osm_sa_gir_by_comp_mask_cb(IN cl_map_item_t * const p_map_item,
 {
 	const osm_gir_search_ctxt_t *const p_ctxt =
 	    (osm_gir_search_ctxt_t *) context;
-	const osm_node_t *const p_node = (osm_node_t *) p_map_item;
+	osm_node_t *const p_node = (osm_node_t *) p_map_item;
 	const ib_guidinfo_record_t *const p_rcvd_rec = p_ctxt->p_rcvd_rec;
 	const osm_physp_t *const p_req_physp = p_ctxt->p_req_physp;
 	osm_sa_t *sa = p_ctxt->sa;
diff --git a/opensm/opensm/osm_sa_link_record.c b/opensm/opensm/osm_sa_link_record.c
index 1b833eb..8c7e2e7 100644
--- a/opensm/opensm/osm_sa_link_record.c
+++ b/opensm/opensm/osm_sa_link_record.c
@@ -135,12 +135,7 @@ __osm_lr_rcv_get_physp_link(IN osm_sa_t * sa,
 	   the other side.
 	 */
 	if (p_src_physp) {
-		if (!osm_physp_is_valid(p_src_physp))
-			goto Exit;
-
 		if (p_dest_physp) {
-			if (!osm_physp_is_valid(p_dest_physp))
-				goto Exit;
 			/*
 			   Ensure the two physp's are actually connected.
 			   If not, bail out.
@@ -149,31 +144,18 @@ __osm_lr_rcv_get_physp_link(IN osm_sa_t * sa,
 				goto Exit;
 		} else {
 			p_dest_physp = osm_physp_get_remote(p_src_physp);
-
 			if (p_dest_physp == NULL)
 				goto Exit;
-
-			if (!osm_physp_is_valid(p_dest_physp))
-				goto Exit;
 		}
 	} else {
 		if (p_dest_physp) {
-			if (!osm_physp_is_valid(p_dest_physp))
-				goto Exit;
-
 			p_src_physp = osm_physp_get_remote(p_dest_physp);
-
 			if (p_src_physp == NULL)
 				goto Exit;
 		} else
 			goto Exit;	/* no physp's, so nothing to do */
 	}
 
-	CL_ASSERT(p_src_physp);
-	CL_ASSERT(p_dest_physp);
-	CL_ASSERT(osm_physp_is_valid(p_src_physp));
-	CL_ASSERT(osm_physp_is_valid(p_dest_physp));
-
 	/* Check that the p_src_physp, p_dest_physp and p_req_physp
 	   all share a pkey (doesn't have to be the same p_key). */
 	if (!osm_physp_share_pkey(sa->p_log, p_src_physp, p_dest_physp)) {
@@ -284,8 +266,7 @@ __osm_lr_rcv_get_port_links(IN osm_sa_t * sa,
 								   p_node,
 								   dest_port_num);
 					/* both physical ports should be with data */
-					if (osm_physp_is_valid(p_src_physp) &&
-					    osm_physp_is_valid(p_dest_physp))
+					if (p_src_physp && p_dest_physp)
 						__osm_lr_rcv_get_physp_link
 						    (sa, p_lr, p_src_physp,
 						     p_dest_physp, comp_mask,
@@ -306,7 +287,7 @@ __osm_lr_rcv_get_port_links(IN osm_sa_t * sa,
 					    osm_node_get_physp_ptr(p_src_port->
 								   p_node,
 								   port_num);
-					if (osm_physp_is_valid(p_src_physp))
+					if (p_src_physp)
 						__osm_lr_rcv_get_physp_link
 						    (sa, p_lr, p_src_physp,
 						     NULL, comp_mask, p_list,
@@ -321,7 +302,7 @@ __osm_lr_rcv_get_port_links(IN osm_sa_t * sa,
 					    osm_node_get_physp_ptr(p_src_port->
 								   p_node,
 								   port_num);
-					if (osm_physp_is_valid(p_src_physp))
+					if (p_src_physp)
 						__osm_lr_rcv_get_physp_link
 						    (sa, p_lr, p_src_physp,
 						     NULL, comp_mask, p_list,
@@ -344,7 +325,7 @@ __osm_lr_rcv_get_port_links(IN osm_sa_t * sa,
 					    osm_node_get_physp_ptr(p_dest_port->
 								   p_node,
 								   port_num);
-					if (osm_physp_is_valid(p_dest_physp))
+					if (p_dest_physp)
 						__osm_lr_rcv_get_physp_link
 						    (sa, p_lr, NULL,
 						     p_dest_physp, comp_mask,
@@ -359,7 +340,7 @@ __osm_lr_rcv_get_port_links(IN osm_sa_t * sa,
 					    osm_node_get_physp_ptr(p_dest_port->
 								   p_node,
 								   port_num);
-					if (osm_physp_is_valid(p_dest_physp))
+					if (p_dest_physp)
 						__osm_lr_rcv_get_physp_link
 						    (sa, p_lr, NULL,
 						     p_dest_physp, comp_mask,
@@ -380,15 +361,12 @@ __osm_lr_rcv_get_port_links(IN osm_sa_t * sa,
 				   scan all the ports of this node anyway.
 				 */
 				p_src_physp = osm_node_get_any_physp_ptr(p_node);
-				if (osm_physp_is_valid(p_src_physp)) {
-					p_src_port = (osm_port_t *)
-					    cl_qmap_get(&sa->p_subn->port_guid_tbl,
-					        osm_physp_get_port_guid(p_src_physp));
-					__osm_lr_rcv_get_port_links(sa, p_lr,
-								    p_src_port, NULL,
-								    comp_mask, p_list,
-								    p_req_physp);
-				}
+				p_src_port = osm_get_port_by_guid(sa->p_subn,
+				        osm_physp_get_port_guid(p_src_physp));
+				__osm_lr_rcv_get_port_links(sa, p_lr,
+							    p_src_port, NULL,
+							    comp_mask, p_list,
+							    p_req_physp);
 				p_node = (osm_node_t *) cl_qmap_next(&p_node->
 								     map_item);
 			}
diff --git a/opensm/opensm/osm_sa_multipath_record.c b/opensm/opensm/osm_sa_multipath_record.c
index 1fa81d6..032c297 100644
--- a/opensm/opensm/osm_sa_multipath_record.c
+++ b/opensm/opensm/osm_sa_multipath_record.c
@@ -354,7 +354,6 @@ __osm_mpr_rcv_get_path_parms(IN osm_sa_t * sa,
 		   Continue with the egress port on this switch.
 		 */
 		p_physp = osm_switch_get_route_by_lid(p_node->sw, dest_lid);
-
 		if (p_physp == 0) {
 			osm_log(sa->p_log, OSM_LOG_ERROR,
 				"__osm_mpr_rcv_get_path_parms: ERR 4516: "
@@ -365,8 +364,6 @@ __osm_mpr_rcv_get_path_parms(IN osm_sa_t * sa,
 			goto Exit;
 		}
 
-		CL_ASSERT(osm_physp_is_valid(p_physp));
-
 		p_pi = &p_physp->port_info;
 
 		if (mtu > ib_port_info_get_mtu_cap(p_pi))
diff --git a/opensm/opensm/osm_sa_node_record.c b/opensm/opensm/osm_sa_node_record.c
index a9a3708..4af8e58 100644
--- a/opensm/opensm/osm_sa_node_record.c
+++ b/opensm/opensm/osm_sa_node_record.c
@@ -122,7 +122,7 @@ __osm_nr_rcv_new_nr(IN osm_sa_t * sa,
  **********************************************************************/
 static void
 __osm_nr_rcv_create_nr(IN osm_sa_t * sa,
-		       IN const osm_node_t * const p_node,
+		       IN osm_node_t * const p_node,
 		       IN cl_qlist_t * const p_list,
 		       IN ib_net64_t const match_port_guid,
 		       IN ib_net16_t const match_lid,
@@ -160,8 +160,7 @@ __osm_nr_rcv_create_nr(IN osm_sa_t * sa,
 
 	for (port_num = 0; port_num < num_ports; port_num++) {
 		p_physp = osm_node_get_physp_ptr(p_node, port_num);
-
-		if (!osm_physp_is_valid(p_physp))
+		if (!p_physp)
 			continue;
 
 		/* Check to see if the found p_physp and the requester physp
@@ -210,7 +209,7 @@ __osm_nr_rcv_by_comp_mask(IN cl_map_item_t * const p_map_item, IN void *context)
 {
 	const osm_nr_search_ctxt_t *const p_ctxt =
 	    (osm_nr_search_ctxt_t *) context;
-	const osm_node_t *const p_node = (osm_node_t *) p_map_item;
+	osm_node_t *const p_node = (osm_node_t *) p_map_item;
 	const ib_node_record_t *const p_rcvd_rec = p_ctxt->p_rcvd_rec;
 	const osm_physp_t *const p_req_physp = p_ctxt->p_req_physp;
 	osm_sa_t *sa = p_ctxt->sa;
diff --git a/opensm/opensm/osm_sa_path_record.c b/opensm/opensm/osm_sa_path_record.c
index 816e8e2..cc87bc7 100644
--- a/opensm/opensm/osm_sa_path_record.c
+++ b/opensm/opensm/osm_sa_path_record.c
@@ -360,7 +360,6 @@ __osm_pr_rcv_get_path_parms(IN osm_sa_t * sa,
 		   Continue with the egress port on this switch.
 		 */
 		p_physp = osm_switch_get_route_by_lid(p_node->sw, dest_lid);
-
 		if (p_physp == 0) {
 			osm_log(sa->p_log, OSM_LOG_ERROR,
 				"__osm_pr_rcv_get_path_parms: ERR 1F07: "
@@ -371,8 +370,6 @@ __osm_pr_rcv_get_path_parms(IN osm_sa_t * sa,
 			goto Exit;
 		}
 
-		CL_ASSERT(osm_physp_is_valid(p_physp));
-
 		p_pi = &p_physp->port_info;
 
 		if (mtu > ib_port_info_get_mtu_cap(p_pi))
diff --git a/opensm/opensm/osm_sa_pkey_record.c b/opensm/opensm/osm_sa_pkey_record.c
index e7547df..e21c8a8 100644
--- a/opensm/opensm/osm_sa_pkey_record.c
+++ b/opensm/opensm/osm_sa_pkey_record.c
@@ -181,7 +181,7 @@ __osm_sa_pkey_by_comp_mask(IN osm_sa_t * sa,
 			    osm_node_get_physp_ptr(p_port->p_node, port_num);
 			/* Check that the p_physp is valid, and that is shares a pkey
 			   with the p_req_physp. */
-			if (osm_physp_is_valid(p_physp) &&
+			if (p_physp &&
 			    (osm_physp_share_pkey
 			     (sa->p_log, p_req_physp, p_physp)))
 				__osm_sa_pkey_check_physp(sa, p_physp,
@@ -199,7 +199,7 @@ __osm_sa_pkey_by_comp_mask(IN osm_sa_t * sa,
 		for (port_num = 0; port_num < num_ports; port_num++) {
 			p_physp =
 			    osm_node_get_physp_ptr(p_port->p_node, port_num);
-			if (!osm_physp_is_valid(p_physp))
+			if (p_physp)
 				continue;
 
 			/* if the requester and the p_physp don't share a pkey -
diff --git a/opensm/opensm/osm_sa_portinfo_record.c b/opensm/opensm/osm_sa_portinfo_record.c
index 16dd852..0cac69c 100644
--- a/opensm/opensm/osm_sa_portinfo_record.c
+++ b/opensm/opensm/osm_sa_portinfo_record.c
@@ -407,7 +407,7 @@ __osm_sa_pir_check_physp(IN osm_sa_t * sa,
  **********************************************************************/
 static void
 __osm_sa_pir_by_comp_mask(IN osm_sa_t * sa,
-			  IN const osm_node_t * const p_node,
+			  IN osm_node_t * const p_node,
 			  osm_pir_search_ctxt_t * const p_ctxt)
 {
 	const ib_portinfo_record_t *p_rcvd_rec;
@@ -432,7 +432,7 @@ __osm_sa_pir_by_comp_mask(IN osm_sa_t * sa,
 						   p_rcvd_rec->port_num);
 			/* Check that the p_physp is valid, and that the p_physp and the
 			   p_req_physp share a pkey. */
-			if (osm_physp_is_valid(p_physp) &&
+			if (p_physp &&
 			    osm_physp_share_pkey(sa->p_log, p_req_physp,
 						 p_physp))
 				__osm_sa_pir_check_physp(sa, p_physp,
@@ -442,7 +442,7 @@ __osm_sa_pir_by_comp_mask(IN osm_sa_t * sa,
 		for (port_num = 0; port_num < num_ports; port_num++) {
 			p_physp =
 			    osm_node_get_physp_ptr(p_node, port_num);
-			if (!osm_physp_is_valid(p_physp))
+			if (!p_physp)
 				continue;
 
 			/* if the requester and the p_physp don't share a pkey -
@@ -464,7 +464,7 @@ static void
 __osm_sa_pir_by_comp_mask_cb(IN cl_map_item_t * const p_map_item,
 			     IN void *context)
 {
-	const osm_node_t *const p_node = (osm_node_t *) p_map_item;
+	osm_node_t *const p_node = (osm_node_t *) p_map_item;
 	osm_pir_search_ctxt_t *const p_ctxt = (osm_pir_search_ctxt_t *) context;
 
 	__osm_sa_pir_by_comp_mask(p_ctxt->sa, p_node, p_ctxt);
diff --git a/opensm/opensm/osm_sa_slvl_record.c b/opensm/opensm/osm_sa_slvl_record.c
index cc21765..ba13010 100644
--- a/opensm/opensm/osm_sa_slvl_record.c
+++ b/opensm/opensm/osm_sa_slvl_record.c
@@ -176,7 +176,7 @@ __osm_sa_slvl_by_comp_mask(IN osm_sa_t * sa,
 			p_out_physp =
 			    osm_node_get_physp_ptr(p_port->p_node,
 						   out_port_num);
-			if (!osm_physp_is_valid(p_out_physp))
+			if (!p_out_physp)
 				continue;
 
 			for (in_port_num = in_port_start;
@@ -189,7 +189,7 @@ __osm_sa_slvl_by_comp_mask(IN osm_sa_t * sa,
 				p_in_physp =
 				    osm_node_get_physp_ptr(p_port->p_node,
 							   in_port_num);
-				if (!osm_physp_is_valid(p_in_physp))
+				if (!p_in_physp)
 					continue;
 
 				/* if the requester and the p_out_physp don't share a pkey -
diff --git a/opensm/opensm/osm_sa_vlarb_record.c b/opensm/opensm/osm_sa_vlarb_record.c
index 51bc517..3ada071 100644
--- a/opensm/opensm/osm_sa_vlarb_record.c
+++ b/opensm/opensm/osm_sa_vlarb_record.c
@@ -187,7 +187,7 @@ __osm_sa_vl_arb_by_comp_mask(IN osm_sa_t * sa,
 			    osm_node_get_physp_ptr(p_port->p_node, port_num);
 			/* check that the p_physp is valid, and that the requester
 			   and the p_physp share a pkey. */
-			if (osm_physp_is_valid(p_physp) &&
+			if (p_physp &&
 			    osm_physp_share_pkey(sa->p_log, p_req_physp,
 						 p_physp))
 				__osm_sa_vl_arb_check_physp(sa, p_physp,
@@ -205,7 +205,7 @@ __osm_sa_vl_arb_by_comp_mask(IN osm_sa_t * sa,
 		for (port_num = 0; port_num < num_ports; port_num++) {
 			p_physp =
 			    osm_node_get_physp_ptr(p_port->p_node, port_num);
-			if (!osm_physp_is_valid(p_physp))
+			if (!p_physp)
 				continue;
 
 			/* if the requester and the p_physp don't share a pkey -
diff --git a/opensm/opensm/osm_slvl_map_rcv.c b/opensm/opensm/osm_slvl_map_rcv.c
index 3f9c88a..2af9be2 100644
--- a/opensm/opensm/osm_slvl_map_rcv.c
+++ b/opensm/opensm/osm_slvl_map_rcv.c
@@ -125,8 +125,6 @@ void osm_slvl_rcv_process(IN void *context, IN void *p_data)
 		in_port_num = 0;
 	}
 
-	CL_ASSERT(p_physp);
-
 	/*
 	   We do not mind if this is a result of a set or get - all we want is to update
 	   the subnet.
@@ -145,7 +143,7 @@ void osm_slvl_rcv_process(IN void *context, IN void *p_data)
 	   Determine if we encountered a new Physical Port.
 	   If so, Ignore it.
 	 */
-	if (!osm_physp_is_valid(p_physp)) {
+	if (!p_physp) {
 		osm_log(sm->p_log, OSM_LOG_ERROR,
 			"osm_slvl_rcv_process: "
 			"Got invalid port number 0x%X\n", out_port_num);
diff --git a/opensm/opensm/osm_state_mgr.c b/opensm/opensm/osm_state_mgr.c
index e4130cc..4b7dcac 100644
--- a/opensm/opensm/osm_state_mgr.c
+++ b/opensm/opensm/osm_state_mgr.c
@@ -720,7 +720,6 @@ static boolean_t __osm_state_mgr_is_sm_port_down(IN osm_state_mgr_t *
 	p_physp = p_port->p_physp;
 
 	CL_ASSERT(p_physp);
-	CL_ASSERT(osm_physp_is_valid(p_physp));
 
 	state = osm_physp_get_port_state(p_physp);
 	CL_PLOCK_RELEASE(p_mgr->p_lock);
@@ -789,7 +788,7 @@ static ib_api_status_t __osm_state_mgr_sweep_hop_1(IN osm_state_mgr_t *
 
 	p_physp = osm_node_get_physp_ptr(p_node, port_num);
 
-	CL_ASSERT(osm_physp_is_valid(p_physp));
+	CL_ASSERT(p_physp);
 
 	p_dr_path = osm_physp_get_dr_path_ptr(p_physp);
 	h_bind = osm_dr_path_get_bind_handle(p_dr_path);
@@ -911,7 +910,7 @@ static ib_api_status_t __osm_state_mgr_light_sweep_start(IN osm_state_mgr_t *
 			     port_num++) {
 				p_physp =
 				    osm_node_get_physp_ptr(p_node, port_num);
-				if (osm_physp_is_valid(p_physp)
+				if (p_physp
 				    && (osm_physp_get_port_state(p_physp) !=
 					IB_LINK_DOWN)
 				    && !osm_physp_get_remote(p_physp)) {
diff --git a/opensm/opensm/osm_sw_info_rcv.c b/opensm/opensm/osm_sw_info_rcv.c
index 962f6c7..dbf8b8c 100644
--- a/opensm/opensm/osm_sw_info_rcv.c
+++ b/opensm/opensm/osm_sw_info_rcv.c
@@ -96,8 +96,6 @@ __osm_si_rcv_get_port_info(IN osm_sm_t * sm,
 	 */
 	p_physp = osm_node_get_any_physp_ptr(p_node);
 
-	CL_ASSERT(osm_physp_is_valid(p_physp));
-
 	context.pi_context.node_guid = osm_node_get_node_guid(p_node);
 	context.pi_context.port_guid = osm_physp_get_port_guid(p_physp);
 	context.pi_context.set_method = FALSE;
@@ -152,8 +150,6 @@ __osm_si_rcv_get_fwd_tbl(IN osm_sm_t * sm,
 
 	p_physp = osm_node_get_any_physp_ptr(p_node);
 
-	CL_ASSERT(osm_physp_is_valid(p_physp));
-
 	context.lft_context.node_guid = osm_node_get_node_guid(p_node);
 	context.lft_context.set_method = FALSE;
 
@@ -223,8 +219,6 @@ __osm_si_rcv_get_mcast_fwd_tbl(IN osm_sm_t * sm,
 	p_physp = osm_node_get_any_physp_ptr(p_node);
 	p_tbl = osm_switch_get_mcast_tbl_ptr(p_sw);
 
-	CL_ASSERT(osm_physp_is_valid(p_physp));
-
 	context.mft_context.node_guid = osm_node_get_node_guid(p_node);
 	context.mft_context.set_method = FALSE;
 
diff --git a/opensm/opensm/osm_switch.c b/opensm/opensm/osm_switch.c
index 4cb6272..23429c7 100644
--- a/opensm/opensm/osm_switch.c
+++ b/opensm/opensm/osm_switch.c
@@ -316,8 +316,7 @@ osm_switch_recommend_path(IN const osm_switch_t * const p_sw,
 			   Verify that the port number is legal and that the
 			   LID is reachable through this port.
 			 */
-			if (osm_physp_is_valid(p_physp) &&
-			    osm_physp_is_healthy(p_physp) &&
+			if (p_physp && osm_physp_is_healthy(p_physp) &&
 			    osm_physp_get_remote(p_physp)) {
 				hops =
 				    osm_switch_get_hop_count(p_sw, base_lid,
@@ -359,8 +358,7 @@ osm_switch_recommend_path(IN const osm_switch_t * const p_sw,
 
 		/* let us make sure it is not down or unhealthy */
 		p_physp = osm_node_get_physp_ptr(p_sw->p_node, port_num);
-		if (!osm_physp_is_valid(p_physp) ||
-		    !osm_physp_is_healthy(p_physp) ||
+		if (!p_physp || !osm_physp_is_healthy(p_physp) ||
 		    /*
 		       we require all - non sma ports to be linked
 		       to be routed through
diff --git a/opensm/opensm/osm_trap_rcv.c b/opensm/opensm/osm_trap_rcv.c
index b7a8c40..53269b4 100644
--- a/opensm/opensm/osm_trap_rcv.c
+++ b/opensm/opensm/osm_trap_rcv.c
@@ -90,12 +90,11 @@ typedef struct _osm_trap_aging_tracker_context {
 
 /**********************************************************************
  **********************************************************************/
-static osm_physp_t *__get_physp_by_lid_and_num(IN osm_sm_t * sm,
-					       IN uint16_t lid, IN uint8_t num)
+static osm_physp_t *get_physp_by_lid_and_num(IN osm_sm_t * sm,
+					     IN uint16_t lid, IN uint8_t num)
 {
 	cl_ptr_vector_t *p_vec = &(sm->p_subn->port_lid_tbl);
 	osm_port_t *p_port;
-	osm_physp_t *p_physp;
 
 	if (lid > cl_ptr_vector_get_size(p_vec))
 		return NULL;
@@ -107,9 +106,7 @@ static osm_physp_t *__get_physp_by_lid_and_num(IN osm_sm_t * sm,
 	if (osm_node_get_num_physp(p_port->p_node) < num)
 		return NULL;
 
-	p_physp = osm_node_get_physp_ptr(p_port->p_node, num);
-
-	return osm_physp_is_valid(p_physp) ? p_physp : NULL;
+	return osm_node_get_physp_ptr(p_port->p_node, num);
 }
 
 /**********************************************************************
@@ -132,7 +129,7 @@ osm_trap_rcv_aging_tracker_callback(IN uint64_t key,
 	lid = cl_ntoh16((uint16_t) ((key & 0x0000FFFF00000000ULL) >> 32));
 	port_num = (uint8_t) ((key & 0x00FF000000000000ULL) >> 48);
 
-	p_physp = __get_physp_by_lid_and_num(sm, lid, port_num);
+	p_physp = get_physp_by_lid_and_num(sm, lid, port_num);
 	if (!p_physp)
 		osm_log(sm->p_log, OSM_LOG_VERBOSE,
 			"osm_trap_rcv_aging_tracker_callback: "
@@ -140,7 +137,7 @@ osm_trap_rcv_aging_tracker_callback(IN uint64_t key,
 			port_num, lid);
 	/* make sure the physp is still valid */
 	/* If the health port was false - set it to true */
-	else if (osm_physp_is_valid(p_physp) && !osm_physp_is_healthy(p_physp)) {
+	else if (!osm_physp_is_healthy(p_physp)) {
 		osm_log(sm->p_log, OSM_LOG_VERBOSE,
 			"osm_trap_rcv_aging_tracker_callback: "
 			"Clearing health bit of port num:%u with lid:%u\n",
@@ -450,13 +447,13 @@ __osm_trap_rcv_process_request(IN osm_sm_t * sm,
 			 */
 			if (physp_change_trap == TRUE) {
 				/* get the port */
-				p_physp = __get_physp_by_lid_and_num(sm,
-								     cl_ntoh16
-								     (p_ntci->
-								      data_details.
-								      ntc_129_131.
-								      lid),
-								     port_num);
+				p_physp = get_physp_by_lid_and_num(sm,
+								   cl_ntoh16
+								   (p_ntci->
+								    data_details.
+								    ntc_129_131.
+								    lid),
+								   port_num);
 
 				if (!p_physp)
 					osm_log(sm->p_log, OSM_LOG_ERROR,
diff --git a/opensm/opensm/osm_ucast_ftree.c b/opensm/opensm/osm_ucast_ftree.c
index dcbdc44..e9e00a4 100644
--- a/opensm/opensm/osm_ucast_ftree.c
+++ b/opensm/opensm/osm_ucast_ftree.c
@@ -2829,9 +2829,7 @@ __osm_ftree_rank_switches_from_leafs(IN ftree_fabric_t * p_ftree,
 		/* note: skipping port 0 on switches */
 		for (i = 1; i < osm_node_get_num_physp(p_node); i++) {
 			p_osm_port = osm_node_get_physp_ptr(p_node, i);
-			if (!osm_physp_is_valid(p_osm_port))
-				continue;
-			if (!osm_link_is_healthy(p_osm_port))
+			if (!p_osm_port || !osm_link_is_healthy(p_osm_port))
 				continue;
 
 			p_remote_node =
@@ -2883,9 +2881,7 @@ __osm_ftree_rank_leaf_switches(IN ftree_fabric_t * p_ftree,
 
 	for (i = 0; i < osm_node_get_num_physp(p_osm_node); i++) {
 		p_osm_port = osm_node_get_physp_ptr(p_osm_node, i);
-		if (!osm_physp_is_valid(p_osm_port))
-			continue;
-		if (!osm_link_is_healthy(p_osm_port))
+		if (!p_osm_port || !osm_link_is_healthy(p_osm_port))
 			continue;
 
 		p_remote_osm_node =
@@ -2989,10 +2985,7 @@ __osm_ftree_fabric_construct_hca_ports(IN ftree_fabric_t * p_ftree,
 
 	for (i = 0; i < osm_node_get_num_physp(p_node); i++) {
 		osm_physp_t *p_osm_port = osm_node_get_physp_ptr(p_node, i);
-
-		if (!osm_physp_is_valid(p_osm_port))
-			continue;
-		if (!osm_link_is_healthy(p_osm_port))
+		if (!p_osm_port && !osm_link_is_healthy(p_osm_port))
 			continue;
 
 		p_remote_osm_port = osm_physp_get_remote(p_osm_port);
@@ -3115,10 +3108,7 @@ static int __osm_ftree_fabric_construct_sw_ports(IN ftree_fabric_t * p_ftree,
 
 	for (i = 0; i < osm_node_get_num_physp(p_node); i++) {
 		osm_physp_t *p_osm_port = osm_node_get_physp_ptr(p_node, i);
-
-		if (!osm_physp_is_valid(p_osm_port))
-			continue;
-		if (!osm_link_is_healthy(p_osm_port))
+		if (!p_osm_port || !osm_link_is_healthy(p_osm_port))
 			continue;
 
 		p_remote_osm_port = osm_physp_get_remote(p_osm_port);
@@ -3291,9 +3281,7 @@ static int __osm_ftree_fabric_rank_from_roots(IN ftree_fabric_t * p_ftree)
 		/* note: skipping port 0 on switches */
 		for (i = 1; i < osm_node_get_num_physp(p_osm_node); i++) {
 			p_osm_physp = osm_node_get_physp_ptr(p_osm_node, i);
-			if (!osm_physp_is_valid(p_osm_physp))
-				continue;
-			if (!osm_link_is_healthy(p_osm_physp))
+			if (!p_osm_physp  || !osm_link_is_healthy(p_osm_physp))
 				continue;
 
 			p_remote_osm_node =
diff --git a/opensm/opensm/osm_ucast_lash.c b/opensm/opensm/osm_ucast_lash.c
index cf9d701..65f688e 100644
--- a/opensm/opensm/osm_ucast_lash.c
+++ b/opensm/opensm/osm_ucast_lash.c
@@ -187,13 +187,12 @@ static uint8_t find_port_from_lid(IN const ib_net16_t lid_no,
 	for (i = 1; i < port_count; i++) {
 
 		p_current_physp = osm_node_get_physp_ptr(p_sw->p_node, i);
-
-		if (!osm_physp_is_valid(p_current_physp))
+		if (!p_current_physp)
 			continue;
 
 		p_remote_physp = p_current_physp->p_remote_physp;
 
-		if (p_remote_physp && osm_physp_is_valid(p_remote_physp)) {
+		if (p_remote_physp) {
 			osm_node_t *p_opposite_node =
 			    osm_physp_get_node_ptr(p_remote_physp);
 
@@ -1216,12 +1215,9 @@ static void osm_lash_process_switch(lash_t * p_lash, osm_switch_t * p_sw)
 	for (i = 1; i < port_count; i++) {
 
 		p_current_physp = osm_node_get_physp_ptr(p_sw->p_node, i);
-
-		if (osm_physp_is_valid(p_current_physp)) {
+		if (p_current_physp) {
 			p_remote_physp = p_current_physp->p_remote_physp;
-
-			if (p_remote_physp && osm_physp_is_valid(p_remote_physp)
-			    && p_remote_physp->p_node->sw) {
+			if (p_remote_physp && p_remote_physp->p_node->sw) {
 				int physical_port_a_num =
 				    osm_physp_get_port_num(p_current_physp);
 				int physical_port_b_num =
@@ -1315,7 +1311,7 @@ static int discover_network_properties(lash_t * p_lash)
 			osm_physp_t *p_current_physp =
 			    osm_node_get_physp_ptr(p_sw->p_node, i);
 
-			if (osm_physp_is_valid(p_current_physp)
+			if (p_current_physp
 			    && p_current_physp->p_remote_physp) {
 
 				ib_port_info_t *p_port_info =
diff --git a/opensm/opensm/osm_ucast_updn.c b/opensm/opensm/osm_ucast_updn.c
index c77188f..411e15b 100644
--- a/opensm/opensm/osm_ucast_updn.c
+++ b/opensm/opensm/osm_ucast_updn.c
@@ -390,12 +390,9 @@ updn_subn_rank(IN unsigned num_guids,
 			/*
 			   make sure that all the following occur on p_remote_physp:
 			   1. The port isn't NULL
-			   2. The port is a valid port
-			   3. It is a switch
+			   2. It is a switch
 			 */
-			if (p_remote_physp &&
-			    osm_physp_is_valid(p_remote_physp) &&
-			    p_remote_physp->p_node->sw) {
+			if (p_remote_physp && p_remote_physp->p_node->sw) {
 				remote_u = p_remote_physp->p_node->sw->priv;
 				port_guid = p_remote_physp->port_guid;
 
diff --git a/opensm/opensm/osm_vl_arb_rcv.c b/opensm/opensm/osm_vl_arb_rcv.c
index a88bf70..8a5b8b4 100644
--- a/opensm/opensm/osm_vl_arb_rcv.c
+++ b/opensm/opensm/osm_vl_arb_rcv.c
@@ -122,8 +122,6 @@ void osm_vla_rcv_process(IN void *context, IN void *data)
 		port_num = p_physp->port_num;
 	}
 
-	CL_ASSERT(p_physp);
-
 	/*
 	   We do not mind if this is a result of a set or get - all we want is to update
 	   the subnet.
@@ -141,7 +139,7 @@ void osm_vla_rcv_process(IN void *context, IN void *data)
 	   Determine if we encountered a new Physical Port.
 	   If so, Ignore it.
 	 */
-	if (!osm_physp_is_valid(p_physp)) {
+	if (!p_physp) {
 		osm_log(sm->p_log, OSM_LOG_ERROR,
 			"osm_vla_rcv_process: "
 			"Got invalid port number 0x%X\n", port_num);
-- 
1.5.4.rc5




More information about the general mailing list