[ofa-general] [infiniband-diags] [PATCH] [4/4] libibnetdisc cleanup patches round 2

Al Chu chu11 at llnl.gov
Thu Jul 9 13:21:23 PDT 2009


Remove timeout_ms parameter to ibnd_discover_fabric, timeout parameter
should be specified via the ibmad_port. Remove extraneous use of global
timeout_ms in library. Adjust ibnetdiscover, ibqueryerrors, iblinkinfo,
and test code appropriately for adjustment.

Al

-- 
Albert Chu
chu11 at llnl.gov
Computer Scientist
High Performance Systems Division
Lawrence Livermore National Laboratory
-------------- next part --------------
>From 65ce1d297e46737fe74c0544da901ed96d72401f Mon Sep 17 00:00:00 2001
From: Albert Chu <chu11 at llnl.gov>
Date: Wed, 8 Jul 2009 17:36:37 -0700
Subject: [PATCH] Remove timeout_ms parameter to ibnd_discover_fabric, timeout parameter should be specified via the ibmad_port. Remove extraneous use of global timeout_ms in library. Adjust ibnetdiscover, ibqueryerrors, iblinkinfo, and test code appropriately for adjustment.

Signed-off-by: Albert Chu <chu11 at llnl.gov>
Signed-off-by: Ira Weiny <weiny2 at llnl.gov>
---
 .../libibnetdisc/include/infiniband/ibnetdisc.h    |    4 ---
 infiniband-diags/libibnetdisc/src/ibnetdisc.c      |   21 +++++++++----------
 infiniband-diags/libibnetdisc/test/testleaks.c     |    6 +++-
 infiniband-diags/src/iblinkinfo.c                  |    7 ++++-
 infiniband-diags/src/ibnetdiscover.c               |    8 +++---
 infiniband-diags/src/ibqueryerrors.c               |    7 ++++-
 6 files changed, 28 insertions(+), 25 deletions(-)

diff --git a/infiniband-diags/libibnetdisc/include/infiniband/ibnetdisc.h b/infiniband-diags/libibnetdisc/include/infiniband/ibnetdisc.h
index e01ca6a..5fb5d7b 100644
--- a/infiniband-diags/libibnetdisc/include/infiniband/ibnetdisc.h
+++ b/infiniband-diags/libibnetdisc/include/infiniband/ibnetdisc.h
@@ -140,13 +140,9 @@ MAD_EXPORT void ibnd_debug(int i);
 MAD_EXPORT void ibnd_show_progress(int i);
 
 MAD_EXPORT ibnd_fabric_t *ibnd_discover_fabric(struct ibmad_port *ibmad_port,
-					       int timeout_ms,
 					       ib_portid_t *from, int hops);
 	/**
 	 * open: (required) ibmad_port object from libibmad
-	 * timeout_ms: (required) gives the timeout for a _SINGLE_ query on
-	 *             the fabric.  So if there are multiple nodes not
-	 *             responding this may result in a lengthy delay.
 	 * from: (optional) specify the node to start scanning from.
 	 *       If NULL start from the node we are running on.
 	 * hops: (optional) Specify how much of the fabric to traverse.
diff --git a/infiniband-diags/libibnetdisc/src/ibnetdisc.c b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
index 88fb7df..d33f5ad 100644
--- a/infiniband-diags/libibnetdisc/src/ibnetdisc.c
+++ b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
@@ -57,7 +57,6 @@
 #include "internal.h"
 #include "chassis.h"
 
-static int timeout_ms = 2000;
 static int show_progress = 0;
 int ibdebug;
 
@@ -80,7 +79,7 @@ get_port_info(struct ibmad_port *ibmad_port, struct ibnd_fabric_int *fabric,
 	iwidth = mad_get_field(port->port.info, 0, IB_PORT_LINK_WIDTH_ACTIVE_F);
 	ispeed = mad_get_field(port->port.info, 0, IB_PORT_LINK_SPEED_ACTIVE_F);
 
-	if (!smp_query_via(port->port.info, portid, IB_ATTR_PORT_INFO, portnum, timeout_ms,
+	if (!smp_query_via(port->port.info, portid, IB_ATTR_PORT_INFO, portnum, 0,
 			ibmad_port))
 		return -1;
 
@@ -102,7 +101,7 @@ static int
 query_node_info(struct ibmad_port *ibmad_port, struct ibnd_fabric_int *fabric,
 		struct ibnd_node_int *node, ib_portid_t *portid)
 {
-	if (!smp_query_via(&(node->node.info), portid, IB_ATTR_NODE_INFO, 0, timeout_ms,
+	if (!smp_query_via(&(node->node.info), portid, IB_ATTR_NODE_INFO, 0, 0,
 			ibmad_port))
 		return -1;
 
@@ -132,11 +131,11 @@ query_node(struct ibmad_port *ibmad_port, struct ibnd_fabric_int *fabric,
 	port->portnum = mad_get_field(node->info, 0, IB_NODE_LOCAL_PORT_F);
 	port->guid = mad_get_field64(node->info, 0, IB_NODE_PORT_GUID_F);
 
-	if (!smp_query_via(nd, portid, IB_ATTR_NODE_DESC, 0, timeout_ms,
+	if (!smp_query_via(nd, portid, IB_ATTR_NODE_DESC, 0, 0,
 			ibmad_port))
 		return -1;
 
-	if (!smp_query_via(port->info, portid, IB_ATTR_PORT_INFO, 0, timeout_ms,
+	if (!smp_query_via(port->info, portid, IB_ATTR_PORT_INFO, 0, 0,
 			ibmad_port))
 		return -1;
 	decode_port_info(port);
@@ -148,7 +147,7 @@ query_node(struct ibmad_port *ibmad_port, struct ibnd_fabric_int *fabric,
 	node->smalmc = port->lmc;
 
 	/* after we have the sma information find out the real PortInfo for this port */
-	if (!smp_query_via(port->info, portid, IB_ATTR_PORT_INFO, port->portnum, timeout_ms,
+	if (!smp_query_via(port->info, portid, IB_ATTR_PORT_INFO, port->portnum, 0,
 			ibmad_port))
 		return -1;
 	decode_port_info(port);
@@ -156,7 +155,7 @@ query_node(struct ibmad_port *ibmad_port, struct ibnd_fabric_int *fabric,
 	port->base_lid = (uint16_t) node->smalid;  /* LID is still defined by port 0 */
 	port->lmc = (uint8_t) node->smalmc;
 
-        if (!smp_query_via(node->switchinfo, portid, IB_ATTR_SWITCH_INFO, 0, timeout_ms,
+        if (!smp_query_via(node->switchinfo, portid, IB_ATTR_SWITCH_INFO, 0, 0,
 			ibmad_port))
 		node->smaenhsp0 = 0;	/* assume base SP0 */
 	else
@@ -293,7 +292,7 @@ ibnd_update_node(struct ibmad_port *ibmad_port, ibnd_fabric_t *fabric, ibnd_node
 	if (query_node_info(ibmad_port, f, n, &(n->node.path_portid)))
 		return (NULL);
 
-	if (!smp_query_via(nd, &(n->node.path_portid), IB_ATTR_NODE_DESC, 0, timeout_ms,
+	if (!smp_query_via(nd, &(n->node.path_portid), IB_ATTR_NODE_DESC, 0, 0,
 			ibmad_port))
 		return (NULL);
 
@@ -306,14 +305,14 @@ ibnd_update_node(struct ibmad_port *ibmad_port, ibnd_fabric_t *fabric, ibnd_node
 	if (n->node.type != IB_NODE_SWITCH)
 		goto done;
 
-	if (!smp_query_via(portinfo_port0, &(n->node.path_portid), IB_ATTR_PORT_INFO, 0, timeout_ms,
+	if (!smp_query_via(portinfo_port0, &(n->node.path_portid), IB_ATTR_PORT_INFO, 0, 0,
 			ibmad_port))
 		return (NULL);
 
 	n->node.smalid = mad_get_field(portinfo_port0, 0, IB_PORT_LID_F);
 	n->node.smalmc = mad_get_field(portinfo_port0, 0, IB_PORT_LMC_F);
 
-        if (!smp_query_via(node->switchinfo, &(n->node.path_portid), IB_ATTR_SWITCH_INFO, 0, timeout_ms,
+        if (!smp_query_via(node->switchinfo, &(n->node.path_portid), IB_ATTR_SWITCH_INFO, 0, 0,
 			ibmad_port))
                 node->smaenhsp0 = 0;	/* assume base SP0 */
 	else
@@ -536,7 +535,7 @@ get_remote_node(struct ibmad_port *ibmad_port, struct ibnd_fabric_int *fabric,
 }
 
 ibnd_fabric_t *
-ibnd_discover_fabric(struct ibmad_port *ibmad_port, int timeout_ms,
+ibnd_discover_fabric(struct ibmad_port *ibmad_port,
 			ib_portid_t *from, int hops)
 {
 	struct ibnd_fabric_int *fabric = NULL;
diff --git a/infiniband-diags/libibnetdisc/test/testleaks.c b/infiniband-diags/libibnetdisc/test/testleaks.c
index 0d009c3..a8f5300 100644
--- a/infiniband-diags/libibnetdisc/test/testleaks.c
+++ b/infiniband-diags/libibnetdisc/test/testleaks.c
@@ -161,11 +161,13 @@ main(int argc, char **argv)
 
 	ibmad_port = mad_rpc_open_port(ca, ca_port, mgmt_classes, 2);
 
+	mad_rpc_set_timeout(ibmad_port, timeout_ms);
+
 	while (iters == -1 || iters-- > 0) {
 		if (from) {
 			/* only scan part of the fabric */
 			str2drpath(&(port_id.drpath), from, 0, 0);
-			if ((fabric = ibnd_discover_fabric(ibmad_port, timeout_ms,
+			if ((fabric = ibnd_discover_fabric(ibmad_port,
 					&port_id, hops)) == NULL) {
 				fprintf(stderr, "discover failed\n");
 				rc = 1;
@@ -173,7 +175,7 @@ main(int argc, char **argv)
 			}
 			guid = 0;
 		} else {
-			if ((fabric = ibnd_discover_fabric(ibmad_port, timeout_ms, NULL, -1)) == NULL) {
+			if ((fabric = ibnd_discover_fabric(ibmad_port, NULL, -1)) == NULL) {
 				fprintf(stderr, "discover failed\n");
 				rc = 1;
 				goto close_port;
diff --git a/infiniband-diags/src/iblinkinfo.c b/infiniband-diags/src/iblinkinfo.c
index bba5c5c..5dfadee 100644
--- a/infiniband-diags/src/iblinkinfo.c
+++ b/infiniband-diags/src/iblinkinfo.c
@@ -308,6 +308,9 @@ main(int argc, char **argv)
 		exit(1);
 	}
 
+	if (ibd_timeout)
+		mad_rpc_set_timeout(ibmad_port, ibd_timeout);
+
 	node_name_map = open_node_name_map(node_name_map_file);
 
 	if (dr_path) {
@@ -324,12 +327,12 @@ main(int argc, char **argv)
 	}
 
 	if (resolved >= 0)
-		if ((fabric = ibnd_discover_fabric(ibmad_port, ibd_timeout, &port_id,
+		if ((fabric = ibnd_discover_fabric(ibmad_port, &port_id,
 				hops)) == NULL)
 			IBWARN("Single node discover failed; attempting full scan\n");
 
 	if (!fabric)
-		if ((fabric = ibnd_discover_fabric(ibmad_port, ibd_timeout, NULL, -1)) == NULL) {
+		if ((fabric = ibnd_discover_fabric(ibmad_port, NULL, -1)) == NULL) {
 			fprintf(stderr, "discover failed\n");
 			rc = 1;
 			goto close_port;
diff --git a/infiniband-diags/src/ibnetdiscover.c b/infiniband-diags/src/ibnetdiscover.c
index 1339485..37f769c 100644
--- a/infiniband-diags/src/ibnetdiscover.c
+++ b/infiniband-diags/src/ibnetdiscover.c
@@ -670,9 +670,6 @@ int main(int argc, char **argv)
 	argc -= optind;
 	argv += optind;
 
-	if (ibd_timeout)
-		timeout = ibd_timeout;
-
 	if (ibverbose)
 		ibnd_debug(1);
 
@@ -680,12 +677,15 @@ int main(int argc, char **argv)
 	if (!ibmad_port)
 		IBERROR("Failed to open %s port %d", ibd_ca, ibd_ca_port);
 
+	if (ibd_timeout)
+		mad_rpc_set_timeout(ibmad_port, ibd_timeout);
+
 	if (argc && !(f = fopen(argv[0], "w")))
 		IBERROR("can't open file %s for writing", argv[0]);
 
 	node_name_map = open_node_name_map(node_name_map_file);
 
-	if ((fabric = ibnd_discover_fabric(ibmad_port, ibd_timeout, NULL, -1)) == NULL)
+	if ((fabric = ibnd_discover_fabric(ibmad_port, NULL, -1)) == NULL)
 		IBERROR("discover failed\n");
 
 	if (ports_report)
diff --git a/infiniband-diags/src/ibqueryerrors.c b/infiniband-diags/src/ibqueryerrors.c
index 09f57c5..2c85423 100644
--- a/infiniband-diags/src/ibqueryerrors.c
+++ b/infiniband-diags/src/ibqueryerrors.c
@@ -422,6 +422,9 @@ main(int argc, char **argv)
 	if (!ibmad_port)
 		IBERROR("Failed to open port; %s:%d\n", ibd_ca, ibd_ca_port);
 
+	if (ibd_timeout)
+		mad_rpc_set_timeout(ibmad_port, ibd_timeout);
+
 	node_name_map = open_node_name_map(node_name_map_file);
 
 	/* limit the scan the fabric around the target */
@@ -437,12 +440,12 @@ main(int argc, char **argv)
 	}
 
 	if (resolved >= 0)
-		if ((fabric = ibnd_discover_fabric(ibmad_port, ibd_timeout, &portid,
+		if ((fabric = ibnd_discover_fabric(ibmad_port, &portid,
 				0)) == NULL)
 			IBWARN("Single node discover failed; attempting full scan\n");
 
 	if (!fabric) /* do a full scan */
-		if ((fabric = ibnd_discover_fabric(ibmad_port, ibd_timeout, NULL, -1)) == NULL) {
+		if ((fabric = ibnd_discover_fabric(ibmad_port, NULL, -1)) == NULL) {
 			fprintf(stderr, "discover failed\n");
 			rc = 1;
 			goto close_port;
-- 
1.5.4.5



More information about the general mailing list