[ofa-general] Re: [PATCH 2/3] Add combined routing support to libibnetdisc

Ira Weiny weiny2 at llnl.gov
Wed May 6 09:33:47 PDT 2009


On Wed, 6 May 2009 13:07:44 +0300
Sasha Khapyorsky <sashak at voltaire.com> wrote:

> On 14:29 Thu 30 Apr     , Ira Weiny wrote:
> > From: Ira Weiny <weiny2 at llnl.gov>
> > Date: Wed, 29 Apr 2009 10:15:55 -0700
> > Subject: [PATCH] Add combined routing support to libibnetdisc
> > 
> >    Also allow a scan to start at a switch.
> > 
> > Signed-off-by: Ira Weiny <weiny2 at llnl.gov>
> > ---
> >  infiniband-diags/libibnetdisc/src/ibnetdisc.c |   28 ++++++++++++++++++------
> >  1 files changed, 21 insertions(+), 7 deletions(-)
> > 
> > diff --git a/infiniband-diags/libibnetdisc/src/ibnetdisc.c b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
> > index 0ff5134..fc19633 100644
> > --- a/infiniband-diags/libibnetdisc/src/ibnetdisc.c
> > +++ b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
> > @@ -177,11 +177,26 @@ add_port_to_dpath(ib_dr_path_t *path, int nextport)
> >  }
> >  
> >  static int
> > -extend_dpath(struct ibnd_fabric *f, ib_dr_path_t *path, int nextport)
> > +extend_dpath(struct ibnd_fabric *f, ib_portid_t *portid, int nextport)
> >  {
> > -	int rc = add_port_to_dpath(path, nextport);
> > -	if ((rc != -1) && (path->cnt > f->fabric.maxhops_discovered))
> > -		f->fabric.maxhops_discovered = path->cnt;
> > +	int rc = 0;
> > +
> > +	if (portid->lid && !portid->drpath.drslid) {
> > +		/* If we were LID routed
> > +		 * AND have not done so already
> > +		 * we need to set up the drslid
> > +		 */
> > +		ib_portid_t selfportid = { 0 };
> > +		if (ib_resolve_self_via(&selfportid, NULL, NULL, f->fabric.ibmad_port) < 0)
> > +			return -1;
> 
> And wouldn't it be better instead of resolving selfport on each
> extend_path() call to keep it already resolved somewhere in fabric
> structure?

This will only happen 1 time for each fabric being scan'ed because the path is
reused...

Oh wait a minute, I just reviewed the code...  For the current use case the
path is reused since I am only scanning 1 node.  However, in the general case
this is not true.  Sorry about that.  A new patch is below.

Ira


From: Ira Weiny <weiny2 at llnl.gov>
Date: Wed, 29 Apr 2009 10:15:55 -0700
Subject: [PATCH] Fix ibnd_discover when the specified ib_portid_t starts LID routed.

Signed-off-by: Ira Weiny <weiny2 at llnl.gov>
---
 infiniband-diags/libibnetdisc/src/ibnetdisc.c |   27 ++++++++++++++++++------
 infiniband-diags/libibnetdisc/src/internal.h  |    1 +
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/infiniband-diags/libibnetdisc/src/ibnetdisc.c b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
index 0ff5134..1e93ff8 100644
--- a/infiniband-diags/libibnetdisc/src/ibnetdisc.c
+++ b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
@@ -177,11 +177,25 @@ add_port_to_dpath(ib_dr_path_t *path, int nextport)
 }
 
 static int
-extend_dpath(struct ibnd_fabric *f, ib_dr_path_t *path, int nextport)
+extend_dpath(struct ibnd_fabric *f, ib_portid_t *portid, int nextport)
 {
-	int rc = add_port_to_dpath(path, nextport);
-	if ((rc != -1) && (path->cnt > f->fabric.maxhops_discovered))
-		f->fabric.maxhops_discovered = path->cnt;
+	int rc = 0;
+
+	if (portid->lid) {
+		/* If we were LID routed we need to set up the drslid */
+		if (!f->selfportid.lid)
+			if (ib_resolve_self_via(&f->selfportid, NULL, NULL,
+					f->fabric.ibmad_port) < 0)
+				return -1;
+
+		portid->drpath.drslid = f->selfportid.lid;
+		portid->drpath.drdlid = 0xFFFF;
+	}
+
+	rc = add_port_to_dpath(&portid->drpath, nextport);
+
+	if ((rc != -1) && (portid->drpath.cnt > f->fabric.maxhops_discovered))
+		f->fabric.maxhops_discovered = portid->drpath.cnt;
 	return (rc);
 }
 
@@ -447,7 +461,7 @@ get_remote_node(struct ibnd_fabric *fabric, struct ibnd_node *node, struct ibnd_
 			!= IB_PORT_PHYS_STATE_LINKUP)
 		return -1;
 
-	if (extend_dpath(fabric, &path->drpath, portnum) < 0)
+	if (extend_dpath(fabric, path, portnum) < 0)
 		return -1;
 
 	if (query_node(fabric, &node_buf, &port_buf, path)) {
@@ -546,8 +560,7 @@ ibnd_discover_fabric(struct ibmad_port *ibmad_port, int timeout_ms,
 	if (!port)
 		IBPANIC("out of memory");
 
-	if (node->node.type != IB_NODE_SWITCH &&
-	    get_remote_node(fabric, node, port, from,
+	if(get_remote_node(fabric, node, port, from,
 				mad_get_field(node->node.info, 0, IB_NODE_LOCAL_PORT_F),
 				0) < 0)
 		return ((ibnd_fabric_t *)fabric);
diff --git a/infiniband-diags/libibnetdisc/src/internal.h b/infiniband-diags/libibnetdisc/src/internal.h
index 4e6bb18..5785e33 100644
--- a/infiniband-diags/libibnetdisc/src/internal.h
+++ b/infiniband-diags/libibnetdisc/src/internal.h
@@ -88,6 +88,7 @@ struct ibnd_fabric {
 	struct ibnd_node *switches;
 	struct ibnd_node *ch_adapters;
 	struct ibnd_node *routers;
+	ib_portid_t selfportid;
 };
 #define CONV_FABRIC_INTERNAL(fabric) ((struct ibnd_fabric *)fabric)
 
-- 
1.5.4.5





More information about the general mailing list