All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] opensm/osm_get_port_by_lid(): use faster cl_ptr_vector_get()
@ 2009-09-29 11:02 Sasha Khapyorsky
  2009-09-29 11:02 ` [PATCH] opensm/osm_get_port_by_lid(): speedup a port lookup Sasha Khapyorsky
  0 siblings, 1 reply; 3+ messages in thread
From: Sasha Khapyorsky @ 2009-09-29 11:02 UTC (permalink / raw)
  To: OpenIB, linux-rdma; +Cc: Hal Rosenstock


Use faster cl_ptr_vector_get() call instead of cl_ptr_vector_at(). In
this way eliminate 'stat' variable needs.

Signed-off-by: Sasha Khapyorsky <sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org>
---
 opensm/opensm/osm_subnet.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/opensm/opensm/osm_subnet.c b/opensm/opensm/osm_subnet.c
index b475031..67bc7e1 100644
--- a/opensm/opensm/osm_subnet.c
+++ b/opensm/opensm/osm_subnet.c
@@ -646,22 +646,22 @@ osm_port_t *osm_get_port_by_guid(IN osm_subn_t const *p_subn, IN ib_net64_t guid
 osm_port_t *osm_get_port_by_lid(IN osm_subn_t const * subn, IN ib_net16_t lid)
 {
 	osm_port_t *port = NULL;
-	ib_api_status_t stat;
 	uint16_t base_lid;
 	uint8_t lmc;
 
 	lid = cl_ntoh16(lid);
+	if (lid >= cl_ptr_vector_get_size(&subn->port_lid_tbl))
+		return NULL;
 
 	/* Loop on lmc from 0 up through max LMC possible */
 	for (lmc = 0; lmc <= IB_PORT_LMC_MAX; lmc++) {
 		/* Calculate a base LID assuming this is the real LMC */
 		base_lid = lid & ~((1 << lmc) - 1);
 
-		stat = cl_ptr_vector_at(&subn->port_lid_tbl, base_lid,
-					(void *)&port);
+		port = cl_ptr_vector_get(&subn->port_lid_tbl, base_lid);
 		/* Determine if base LID "tested" is the real base LID */
 		/* This is true if the LMC "tested" is the port's actual LMC */
-		if (stat == CL_SUCCESS && port && lmc == osm_port_get_lmc(port))
+		if (port && lmc == osm_port_get_lmc(port))
 			return port;
 	}
 
-- 
1.6.5.rc1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-09-29 11:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-29 11:02 [PATCH] opensm/osm_get_port_by_lid(): use faster cl_ptr_vector_get() Sasha Khapyorsky
2009-09-29 11:02 ` [PATCH] opensm/osm_get_port_by_lid(): speedup a port lookup Sasha Khapyorsky
2009-09-29 11:03   ` [PATCH] opensm/osm_get_port_by_lid(): don't bother with lmc Sasha Khapyorsky

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.