[ofa-general] [PATCH 12/10] infiniband-diags: convert ibnetdiscover to "new" ibmad interface WAS: [PATCH 0/10] libibmad/infiniband-diags -- converting to "new" interface.

Ira Weiny weiny2 at llnl.gov
Fri Feb 20 14:45:29 PST 2009


On Fri, 20 Feb 2009 09:23:50 -0800
Ira Weiny <weiny2 at llnl.gov> wrote:

> On Fri, 20 Feb 2009 08:55:57 -0500
> Hal Rosenstock <hal.rosenstock at gmail.com> wrote:
> 
> > On Thu, Feb 19, 2009 at 10:05 PM, Ira Weiny <weiny2 at llnl.gov> wrote:
> > > Here is v2 of the patch series.
> > >
> > > I used __attribute__ ((deprecated)) on the functions which should aid others
> > > in realizing that these functions will go away.  (It sure helped me to convert
> > > all the diags.
> > >
> > > Also I did _not_ convert ibnetdiscover as my new libibnetdisc already uses the
> > > new interface and I am hoping it will be accepted soon.
> > 
> > A related issue is whether ibnetdiscover will support both the new
> > library and the old way until the library is more proven via some
> > build option. If it is to support both, then converting it should be
> > done.
> 
> The conversion is easy.  I will do it for now to remove the build warnings.
> And now that I think about it more leaving in the old and new code to be
> chosen via configure is probably not a bad idea.  I don't know what is going
> to happen once we standardize on the mad library for decoding strings.  There
> are some incompatibilities there (ie 1x vs 1X and 2.5Gbps vs SDR etc.)
> 
> I will say, however, that I tested the library extensively and the first
> version's output was identical to the old version with the sole exception of
> the order ports were printed in.  :-D  So my confidence is high it will be
> accepted sooner rather than later.
> 
> Ira


Patch below:

>From ad8cbf227a803d64c02872f74d7d542b815c6092 Mon Sep 17 00:00:00 2001
From: Ira Weiny <weiny2 at llnl.gov>
Date: Fri, 20 Feb 2009 14:43:48 -0800
Subject: [PATCH] infiniband-diags: convert ibnetdiscover to "new" ibmad interface


Signed-off-by: Ira Weiny <weiny2 at llnl.gov>
---
 infiniband-diags/src/ibnetdiscover.c |   23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/infiniband-diags/src/ibnetdiscover.c b/infiniband-diags/src/ibnetdiscover.c
index 466d522..8a840be 100644
--- a/infiniband-diags/src/ibnetdiscover.c
+++ b/infiniband-diags/src/ibnetdiscover.c
@@ -53,6 +53,8 @@
 #include "grouping.h"
 #include "ibdiag_common.h"
 
+struct ibmad_port *srcport;
+
 static char *node_type_str[] = {
 	"???",
 	"ca",
@@ -143,7 +145,8 @@ get_port(Port *port, int portnum, ib_portid_t *portid)
 
 	port->portnum = portnum;
 
-	if (!smp_query(pi, portid, IB_ATTR_PORT_INFO, portnum, timeout))
+	if (!smp_query_via(pi, portid, IB_ATTR_PORT_INFO, portnum, timeout,
+			srcport))
 		return -1;
 	decode_port_info(pi, port);
 
@@ -162,7 +165,7 @@ get_node(Node *node, Port *port, ib_portid_t *portid)
 	void *pi = portinfo, *ni = node->nodeinfo, *nd = node->nodedesc;
 	void *si = switchinfo;
 
-	if (!smp_query(ni, portid, IB_ATTR_NODE_INFO, 0, timeout))
+	if (!smp_query_via(ni, portid, IB_ATTR_NODE_INFO, 0, timeout, srcport))
 		return -1;
 
 	mad_decode_field(ni, IB_NODE_GUID_F, &node->nodeguid);
@@ -176,10 +179,10 @@ get_node(Node *node, Port *port, ib_portid_t *portid)
 	port->portnum = node->localport;
 	port->portguid = node->portguid;
 
-	if (!smp_query(nd, portid, IB_ATTR_NODE_DESC, 0, timeout))
+	if (!smp_query_via(nd, portid, IB_ATTR_NODE_DESC, 0, timeout, srcport))
 		return -1;
 
-	if (!smp_query(pi, portid, IB_ATTR_PORT_INFO, 0, timeout))
+	if (!smp_query_via(pi, portid, IB_ATTR_PORT_INFO, 0, timeout, srcport))
 		return -1;
 	decode_port_info(pi, port);
 
@@ -190,11 +193,12 @@ get_node(Node *node, Port *port, ib_portid_t *portid)
 	node->smalmc = port->lmc;
 
 	/* after we have the sma information find out the real PortInfo for this port */
-	if (!smp_query(pi, portid, IB_ATTR_PORT_INFO, node->localport, timeout))
+	if (!smp_query_via(pi, portid, IB_ATTR_PORT_INFO, node->localport,
+			timeout, srcport))
 	        return -1;
 	decode_port_info(pi, port);
 
-        if (!smp_query(si, portid, IB_ATTR_SWITCH_INFO, 0, timeout))
+        if (!smp_query_via(si, portid, IB_ATTR_SWITCH_INFO, 0, timeout, srcport))
                 node->smaenhsp0 = 0;	/* assume base SP0 */
 	else
         	mad_decode_field(si, IB_SW_ENHANCED_PORT0_F, &node->smaenhsp0);
@@ -985,7 +989,11 @@ int main(int argc, char **argv)
 	if (argc && !(f = fopen(argv[0], "w")))
 		IBERROR("can't open file %s for writing", argv[0]);
 
-	madrpc_init(ibd_ca, ibd_ca_port, mgmt_classes, 2);
+	srcport = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 2);
+	if (!srcport)
+		IBERROR("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
+	mad_rpc_set_timeout(ibd_timeout, srcport);
+
 	node_name_map = open_node_name_map(node_name_map_file);
 
 	if (discover(&my_portid) < 0)
@@ -1000,5 +1008,6 @@ int main(int argc, char **argv)
 		dump_topology(list, group);
 
 	close_node_name_map(node_name_map);
+	mad_rpc_close_port(srcport);
 	exit(0);
 }
-- 
1.5.4.5




More information about the general mailing list