[ofa-general] Re: [PATCH 2/10] infiniband-diags: Convert ibaddr to "new" ibmad interface

Ira Weiny weiny2 at llnl.gov
Fri Mar 6 10:48:08 PST 2009


On Fri, 6 Mar 2009 10:50:18 +0200
Sasha Khapyorsky <sashak at voltaire.com> wrote:

> On 16:06 Mon 02 Mar     , Ira Weiny wrote:
> > > > diff --git a/infiniband-diags/src/ibdiag_common.c b/infiniband-diags/src/ibdiag_common.c
> > > > index 5f2472d..609df69 100644
> > > > --- a/infiniband-diags/src/ibdiag_common.c
> > > > +++ b/infiniband-diags/src/ibdiag_common.c
> > > > @@ -179,7 +179,8 @@ static int process_opt(int ch, char *optarg)
> > > >  		ibd_timeout = val;
> > > >  		break;
> > > >  	case 's':
> > > > -		if (ib_resolve_portid_str(&sm_portid, optarg, IB_DEST_LID, 0) < 0)
> > > > +		if (ib_resolve_portid_str_via(&sm_portid, optarg, IB_DEST_LID,
> > > > +				0, NULL) < 0)
> > > 
> > > This may be not correct (not introduced by those patches) - then host is
> > > connected to multiple subnets we need to resolve SM LID on requested
> > > one, eg. using srcport...
> > > 
> > 
> > Would you accept adding srcport to ibdiag_process_opts?  Or would you prefer
> > something more generic?
> 
> More generic would be better :)
> 
> BTW it could be not so easy - when ibdiag_process_opts() is running
> srcport is not initialized yet.
> 

Actually, you don't need a srcport for this function.  When "resolving" via
LID nothing goes on the wire.  It only fills in ib_portid_t struct.  The
"resolve" name is a bit misleading in this case.  Because "-s" always
specifies a <lid> there is nothing to actually "resolve".

I have added a comment reflecting this.

New patch below,
Ira

From: Ira Weiny <weiny2 at llnl.gov>
Date: Thu, 19 Feb 2009 14:47:05 -0800
Subject: [PATCH] infiniband-diags: Convert ibaddr to "new" ibmad interface


Signed-off-by: Ira Weiny <weiny2 at llnl.gov>
---
 infiniband-diags/src/ibaddr.c        |   17 ++++++++++++-----
 infiniband-diags/src/ibdiag_common.c |    4 +++-
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/infiniband-diags/src/ibaddr.c b/infiniband-diags/src/ibaddr.c
index 9098699..bb22be9 100644
--- a/infiniband-diags/src/ibaddr.c
+++ b/infiniband-diags/src/ibaddr.c
@@ -45,6 +45,8 @@
 
 #include "ibdiag_common.h"
 
+struct ibmad_port *srcport;
+
 static int
 ib_resolve_addr(ib_portid_t *portid, int portnum, int show_lid, int show_gid)
 {
@@ -55,10 +57,10 @@ ib_resolve_addr(ib_portid_t *portid, int portnum, int show_lid, int show_gid)
 	ibmad_gid_t gid;
 	int lmc;
 
-	if (!smp_query(nodeinfo, portid, IB_ATTR_NODE_INFO, 0, 0))
+	if (!smp_query_via(nodeinfo, portid, IB_ATTR_NODE_INFO, 0, 0, srcport))
 		return -1;
 
-	if (!smp_query(portinfo, portid, IB_ATTR_PORT_INFO, portnum, 0))
+	if (!smp_query_via(portinfo, portid, IB_ATTR_PORT_INFO, portnum, 0, srcport))
 		return -1;
 
 	mad_decode_field(portinfo, IB_PORT_LID_F, &portid->lid);
@@ -137,17 +139,22 @@ int main(int argc, char **argv)
 	if (!show_lid && !show_gid)
 		show_lid = show_gid = 1;
 
-	madrpc_init(ibd_ca, ibd_ca_port, mgmt_classes, 3);
+	srcport = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 3);
+	if (!srcport)
+		IBERROR("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
 
 	if (argc) {
-		if (ib_resolve_portid_str(&portid, argv[0], ibd_dest_type, ibd_sm_id) < 0)
+		if (ib_resolve_portid_str_via(&portid, argv[0], ibd_dest_type,
+						ibd_sm_id, srcport) < 0)
 			IBERROR("can't resolve destination port %s", argv[0]);
 	} else {
-		if (ib_resolve_self(&portid, &port, 0) < 0)
+		if (ib_resolve_self_via(&portid, &port, 0, srcport) < 0)
 			IBERROR("can't resolve self port %s", argv[0]);
 	}
 
 	if (ib_resolve_addr(&portid, port, show_lid, show_gid) < 0)
 		IBERROR("can't resolve requested address");
+
+	mad_rpc_close_port(srcport);
 	exit(0);
 }
diff --git a/infiniband-diags/src/ibdiag_common.c b/infiniband-diags/src/ibdiag_common.c
index 5f2472d..c0421f6 100644
--- a/infiniband-diags/src/ibdiag_common.c
+++ b/infiniband-diags/src/ibdiag_common.c
@@ -179,7 +179,9 @@ static int process_opt(int ch, char *optarg)
 		ibd_timeout = val;
 		break;
 	case 's':
-		if (ib_resolve_portid_str(&sm_portid, optarg, IB_DEST_LID, 0) < 0)
+		/* srcport is not required when resolving via IB_DEST_LID */
+		if (ib_resolve_portid_str_via(&sm_portid, optarg, IB_DEST_LID,
+				0, NULL) < 0)
 			IBERROR("cannot resolve SM destination port %s", optarg);
 		ibd_sm_id = &sm_portid;
 		break;
-- 
1.5.4.5





More information about the general mailing list