Skip to contentSkip to conversation

opensm/osm_get_port_by_lid(): use faster cl_ptr_vector_get()

PATCH New Sasha Khapyorsky 1 participant 3 messages Sep 29, 2009 InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 opensm/osm_get_port_by_lid(): use faster cl_ptr_vector_get()

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

---
 opensm/opensm/osm_subnet.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
opensm/opensm/osm_subnet.c +4 -4
index b475031..67bc7e1 100644
@@ -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;
 	}
 
Signature · 6 lines
1.6.5.rc1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw

PATCH 1/1 opensm/osm_get_port_by_lid(): speedup a port lookup

Speedup a port lookup over LMC array - it is not necessary to match LMC exactly for found port because base lid should be equal to requested lid masked value, so '<=' comparison should be enough and we don't need to loop up to an actual port's lmc value match.

---
 opensm/opensm/osm_subnet.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
opensm/opensm/osm_subnet.c +1 -1
index 67bc7e1..30f8af5 100644
@@ -661,7 +661,7 @@ osm_port_t *osm_get_port_by_lid(IN osm_subn_t const * subn, IN ib_net16_t lid)
 		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 (port && lmc == osm_port_get_lmc(port))
+		if (port && lmc <= osm_port_get_lmc(port))
 			return port;
 	}
 
Signature · 6 lines
1.6.5.rc1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw

PATCH 1/1 opensm/osm_get_port_by_lid(): don't bother with lmc

Since subn->port_lid_tbl vector is filled for all port's LIDs in accordance with its LMC value, so we don't need to bother with LMC tracking and instead can just return a pointer indexed by requested lid. Obviously it speeds this helper up significantly.

---
 opensm/opensm/osm_subnet.c |   21 ++-------------------
 1 files changed, 2 insertions(+), 19 deletions(-)
opensm/opensm/osm_subnet.c +2 -19
index 30f8af5..97b62c2 100644
@@ -645,26 +645,9 @@ 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;
-	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);
-
-		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 (port && lmc <= osm_port_get_lmc(port))
-			return port;
-	}
-
+	if (lid < cl_ptr_vector_get_size(&subn->port_lid_tbl))
+		return cl_ptr_vector_get(&subn->port_lid_tbl, lid);
 	return NULL;
 }
 
Signature · 6 lines
1.6.5.rc1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html