All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] Using multi-smps on the wire in libibnetdisc
@ 2010-02-18 20:49 Ira Weiny
       [not found] ` <20100218124931.4d6ef34b.weiny2-i2BcT+NCU+M@public.gmane.org>
  0 siblings, 1 reply; 15+ messages in thread
From: Ira Weiny @ 2010-02-18 20:49 UTC (permalink / raw)
  To: Sasha Khapyorsky; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Hal Rosenstock

After the discussion with Hal I decided it would be safer to just limit the number of outstanding MAD's to 2.  This v3 version changes that.  Patch 2/2 remains the same but I am just sending it to be complete.

Thanks,
Ira

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v3 0/2] Using multi-smps on the wire in libibnetdisc
       [not found] ` <20100218124931.4d6ef34b.weiny2-i2BcT+NCU+M@public.gmane.org>
@ 2010-04-03  0:23   ` Ira Weiny
       [not found]     ` <20100402172330.819b8ef6.weiny2-i2BcT+NCU+M@public.gmane.org>
  2010-04-09 23:56   ` [PATCH] tests/subnet_discover: verbose node discovery printout Sasha Khapyorsky
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 15+ messages in thread
From: Ira Weiny @ 2010-04-03  0:23 UTC (permalink / raw)
  To: Ira Weiny
  Cc: Sasha Khapyorsky, linux-rdma-u79uwXL29TY76Z2rM5mHXA, Hal Rosenstock

Sasha,

Have you had a chance to look at this yet?  If you want I can resend the latest version of the patches.

Thanks,
Ira

On Thu, 18 Feb 2010 12:49:31 -0800
Ira Weiny <weiny2-i2BcT+NCU+M@public.gmane.org> wrote:

> After the discussion with Hal I decided it would be safer to just limit the number of outstanding MAD's to 2.  This v3 version changes that.  Patch 2/2 remains the same but I am just sending it to be complete.
> 
> Thanks,
> Ira
> 


-- 
Ira Weiny
Math Programmer/Computer Scientist
Lawrence Livermore National Lab
925-423-8008
weiny2-i2BcT+NCU+M@public.gmane.org
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v3 0/2] Using multi-smps on the wire in libibnetdisc
       [not found]     ` <20100402172330.819b8ef6.weiny2-i2BcT+NCU+M@public.gmane.org>
@ 2010-04-09 23:21       ` Sasha Khapyorsky
  0 siblings, 0 replies; 15+ messages in thread
From: Sasha Khapyorsky @ 2010-04-09 23:21 UTC (permalink / raw)
  To: Ira Weiny; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Hal Rosenstock

Hi Ira,

On 17:23 Fri 02 Apr     , Ira Weiny wrote:
> 
> Have you had a chance to look at this yet?  If you want I can resend the latest version of the patches.

No needs. I'm looking at this right now...

Sasha
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH] tests/subnet_discover: verbose node discovery printout
       [not found] ` <20100218124931.4d6ef34b.weiny2-i2BcT+NCU+M@public.gmane.org>
  2010-04-03  0:23   ` Ira Weiny
@ 2010-04-09 23:56   ` Sasha Khapyorsky
  2010-04-10  0:52   ` [PATCH v3 0/2] Using multi-smps on the wire in libibnetdisc Sasha Khapyorsky
  2010-04-10 13:18   ` [PATCH] libibmad: add explicit extern for ibdebug prototype Sasha Khapyorsky
  3 siblings, 0 replies; 15+ messages in thread
From: Sasha Khapyorsky @ 2010-04-09 23:56 UTC (permalink / raw)
  To: Ira Weiny; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA


Improve verbosity levels: with '-v' print nodes as they are discovered,
more 'v' - more noise.

Signed-off-by: Sasha Khapyorsky <sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org>
---
 tests/subnet_discover.c |   25 ++++++++++++++++---------
 1 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/tests/subnet_discover.c b/tests/subnet_discover.c
index 22b092a..44cd86e 100644
--- a/tests/subnet_discover.c
+++ b/tests/subnet_discover.c
@@ -52,7 +52,9 @@ static unsigned max_hops = 0;
 
 #define ERROR(fmt, ...) fprintf(stderr, "ERR: " fmt, ##__VA_ARGS__)
 #define VERBOSE(fmt, ...) if (verbose) fprintf(stderr, fmt, ##__VA_ARGS__)
-#define NOISE(fmt, ...) if (verbose > 1) fprintf(stderr, fmt, ##__VA_ARGS__)
+#define VERBOSE1(fmt, ...) if (verbose > 1) fprintf(stderr, fmt, ##__VA_ARGS__)
+#define VERBOSE2(fmt, ...) if (verbose > 2) fprintf(stderr, fmt, ##__VA_ARGS__)
+#define NOISE(fmt, ...) VERBOSE2(fmt, ##__VA_ARGS__)
 
 static const char *print_path(uint8_t path[], size_t path_cnt)
 {
@@ -116,8 +118,8 @@ static int send_request(int fd, int agent, uint64_t trid, uint8_t * path,
 		return -1;
 	}
 
-	VERBOSE("send %016" PRIx64 ": attr %x, mod %x to %s\n", trid, attr_id,
-		attr_mod, print_path(path, path_cnt));
+	VERBOSE1("send %016" PRIx64 ": attr %x, mod %x to %s\n", trid, attr_id,
+		 attr_mod, print_path(path, path_cnt));
 
 	return ret;
 }
@@ -239,8 +241,8 @@ static int send_query(int fd, int agent, unsigned node_id, uint8_t path[],
 		return -1;
 	}
 
-	VERBOSE("queue %016" PRIx64 ": attr %x, mod %x to %s\n", trid, attr_id,
-		attr_mod, print_path(path, path_cnt));
+	VERBOSE1("queue %016" PRIx64 ": attr %x, mod %x to %s\n", trid, attr_id,
+		 attr_mod, print_path(path, path_cnt));
 
 	run_request_queue(fd, agent);
 
@@ -384,8 +386,8 @@ static void connect_ports(unsigned node1_id, unsigned port1_num,
 {
 	struct port *port1 = &node_array[node1_id]->ports[port1_num];
 	struct port *port2 = &node_array[node2_id]->ports[port2_num];
-	VERBOSE("connecting %u:%u <--> %u:%u\n",
-		node1_id, port1_num, node2_id, port2_num);
+	VERBOSE1("connecting %u:%u <--> %u:%u\n",
+		 node1_id, port1_num, node2_id, port2_num);
 	port1->remote = port2;
 	port2->remote = port1;
 }
@@ -410,6 +412,11 @@ static int process_node(void *umad, unsigned remote_id, int fd, int agent,
 
 	node = node_array[id];
 
+	VERBOSE("%-5s %-6s with guid 0x%" PRIx64 " discovered at %s\n",
+		node_is_new ? "new" : "known",
+		node->is_switch ? "Switch" : "Ca", node->guid,
+		print_path(path, path_cnt));
+
 	node->ports[port_num].guid =
 	    mad_get_field64(node_info, 0, IB_NODE_PORT_GUID_F);
 
@@ -472,8 +479,8 @@ static int recv_smp_resp(int fd, int agent, uint8_t * umad, uint8_t path[])
 
 	node_id = trid & 0xffff;
 
-	VERBOSE("recv %016" PRIx64 ": attr %x, mod %x from %s\n", trid, attr_id,
-		attr_mod, print_path(path, path_cnt));
+	VERBOSE1("recv %016" PRIx64 ": attr %x, mod %x from %s\n", trid,
+		 attr_id, attr_mod, print_path(path, path_cnt));
 
 	switch (attr_id) {
 	case IB_ATTR_NODE_INFO:
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH v3 0/2] Using multi-smps on the wire in libibnetdisc
       [not found] ` <20100218124931.4d6ef34b.weiny2-i2BcT+NCU+M@public.gmane.org>
  2010-04-03  0:23   ` Ira Weiny
  2010-04-09 23:56   ` [PATCH] tests/subnet_discover: verbose node discovery printout Sasha Khapyorsky
@ 2010-04-10  0:52   ` Sasha Khapyorsky
  2010-04-10  0:55     ` [PATCH] libibnetdisc: code cleanups Sasha Khapyorsky
  2010-04-13 14:56     ` [PATCH] libibnetdisc: add \n at end of error messages Sasha Khapyorsky
  2010-04-10 13:18   ` [PATCH] libibmad: add explicit extern for ibdebug prototype Sasha Khapyorsky
  3 siblings, 2 replies; 15+ messages in thread
From: Sasha Khapyorsky @ 2010-04-10  0:52 UTC (permalink / raw)
  To: Ira Weiny; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Hal Rosenstock

On 12:49 Thu 18 Feb     , Ira Weiny wrote:
> After the discussion with Hal I decided it would be safer to just limit the number of outstanding MAD's to 2.  This v3 version changes that.

I don't think that diagnostic tools (something used for investigations)
should have "less" priority then regular program like OpenSM, but
doesn't matter - number 'X' is fine to begin with.

> Patch 2/2 remains the same but I am just sending it to be complete.

I'm applying the whole series with few additions (will post here) - this
is a good start.

Sasha
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH] libibnetdisc: code cleanups
  2010-04-10  0:52   ` [PATCH v3 0/2] Using multi-smps on the wire in libibnetdisc Sasha Khapyorsky
@ 2010-04-10  0:55     ` Sasha Khapyorsky
  2010-04-10  0:56       ` [PATCH] libibnetdisc: restore show_progress functionality Sasha Khapyorsky
                         ` (2 more replies)
  2010-04-13 14:56     ` [PATCH] libibnetdisc: add \n at end of error messages Sasha Khapyorsky
  1 sibling, 3 replies; 15+ messages in thread
From: Sasha Khapyorsky @ 2010-04-10  0:55 UTC (permalink / raw)
  To: Ira Weiny; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Hal Rosenstock


Make newly introduced local functions to be static. Remove not needed
braces. Simplify some expressions.

Fix indentations using osm_indent script.

Signed-off-by: Sasha Khapyorsky <sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org>
---
 infiniband-diags/libibnetdisc/src/chassis.c        |    2 +-
 infiniband-diags/libibnetdisc/src/ibnetdisc.c      |  150 +++++++++-----------
 .../libibnetdisc/src/ibnetdisc_cache.c             |    9 +-
 infiniband-diags/libibnetdisc/src/internal.h       |   23 ++--
 infiniband-diags/libibnetdisc/src/query_smp.c      |   68 ++++-----
 5 files changed, 113 insertions(+), 139 deletions(-)

diff --git a/infiniband-diags/libibnetdisc/src/chassis.c b/infiniband-diags/libibnetdisc/src/chassis.c
index c8f6b6c..1a839d9 100644
--- a/infiniband-diags/libibnetdisc/src/chassis.c
+++ b/infiniband-diags/libibnetdisc/src/chassis.c
@@ -38,7 +38,7 @@
 /*========================================================*/
 
 #if HAVE_CONFIG_H
-#  include <config.h>
+#include <config.h>
 #endif				/* HAVE_CONFIG_H */
 
 #include <stdlib.h>
diff --git a/infiniband-diags/libibnetdisc/src/ibnetdisc.c b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
index b084373..4780810 100644
--- a/infiniband-diags/libibnetdisc/src/ibnetdisc.c
+++ b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
@@ -34,7 +34,7 @@
  */
 
 #if HAVE_CONFIG_H
-#  include <config.h>
+#include <config.h>
 #endif				/* HAVE_CONFIG_H */
 
 #define _GNU_SOURCE
@@ -59,54 +59,41 @@ static int max_smps_on_wire = DEFAULT_MAX_SMP_ON_WIRE;
 int ibdebug;
 
 /* forward declare */
-int query_node_info(smp_engine_t * engine, ib_portid_t * portid,
-		    ibnd_node_t * node);
+static int query_node_info(smp_engine_t * engine, ib_portid_t * portid,
+			   ibnd_node_t * node);
 
-
-static int recv_switch_info(smp_engine_t *engine, ibnd_smp_t * smp,
-			    uint8_t *mad, void *cb_data)
+static int recv_switch_info(smp_engine_t * engine, ibnd_smp_t * smp,
+			    uint8_t * mad, void *cb_data)
 {
 	uint8_t *switch_info = mad + IB_SMP_DATA_OFFS;
-	ibnd_node_t * node = (ibnd_node_t *)cb_data;
+	ibnd_node_t *node = cb_data;
 	memcpy(node->switchinfo, switch_info, sizeof(node->switchinfo));
 	mad_decode_field(node->switchinfo, IB_SW_ENHANCED_PORT0_F,
 			 &node->smaenhsp0);
 	return 0;
 }
+
 static int query_switch_info(smp_engine_t * engine, ib_portid_t * portid,
-		      ibnd_node_t *node)
+			     ibnd_node_t * node)
 {
 	node->smaenhsp0 = 0;	/* assume base SP0 */
-	return (issue_smp(engine, portid, IB_ATTR_SWITCH_INFO, 0, recv_switch_info,
-			  (void *)node));
+	return issue_smp(engine, portid, IB_ATTR_SWITCH_INFO, 0,
+			 recv_switch_info, node);
 }
 
 static int add_port_to_dpath(ib_dr_path_t * path, int nextport)
 {
-	if (path->cnt + 2 >= sizeof(path->p)) {
+	if (path->cnt > sizeof(path->p) - 1)
 		return -1;
-	}
 	++path->cnt;
 	path->p[path->cnt] = (uint8_t) nextport;
 	return path->cnt;
 }
 
-#if 0
-static void retract_dpath(ib_portid_t * path)
-{
-	path->drpath.cnt--;	/* restore path */
-	if (path->drpath.cnt == 0 && path->lid) {
-		/* return to lid based routing on this path */
-		path->drpath.drslid = 0;
-		path->drpath.drdlid = 0;
-	}
-}
-#endif
-
-static int extend_dpath(smp_engine_t * engine, ib_portid_t * portid, int nextport)
+static int extend_dpath(smp_engine_t * engine, ib_portid_t * portid,
+			int nextport)
 {
-	int rc = 0;
-	ibnd_scan_t *scan = (ibnd_scan_t *)engine->user_data;
+	ibnd_scan_t *scan = engine->user_data;
 	ibnd_fabric_t *fabric = scan->fabric;
 
 	if (portid->lid) {
@@ -117,37 +104,39 @@ static int extend_dpath(smp_engine_t * engine, ib_portid_t * portid, int nextpor
 				IBND_ERROR("Failed to resolve self\n");
 				return -1;
 			}
-
 		portid->drpath.drslid = (uint16_t) scan->selfportid.lid;
 		portid->drpath.drdlid = 0xFFFF;
 	}
 
-	rc = add_port_to_dpath(&portid->drpath, nextport);
-	if (rc < 0)
+	if (add_port_to_dpath(&portid->drpath, nextport) < 0) {
 		IBND_ERROR("add port %d to DR path failed; %s\n", nextport,
 			   portid2str(portid));
+		return -1;
+	}
 
-	if (rc != -1 && portid->drpath.cnt > fabric->maxhops_discovered)
+	if (portid->drpath.cnt > fabric->maxhops_discovered)
 		fabric->maxhops_discovered = portid->drpath.cnt;
-	return rc;
+
+	return 1;
 }
 
 static int recv_node_desc(smp_engine_t * engine, ibnd_smp_t * smp,
-			  uint8_t *mad, void *cb_data)
+			  uint8_t * mad, void *cb_data)
 {
 	uint8_t *node_desc = mad + IB_SMP_DATA_OFFS;
-	ibnd_node_t *node = (ibnd_node_t *)cb_data;
+	ibnd_node_t *node = cb_data;
 	memcpy(node->nodedesc, node_desc, sizeof(node->nodedesc));
 	return 0;
 }
 
-int query_node_desc(smp_engine_t * engine, ib_portid_t * portid, ibnd_node_t *node)
+static int query_node_desc(smp_engine_t * engine, ib_portid_t * portid,
+			   ibnd_node_t * node)
 {
-	return (issue_smp(engine, portid, IB_ATTR_NODE_DESC, 0, recv_node_desc,
-			  (void *)node));
+	return issue_smp(engine, portid, IB_ATTR_NODE_DESC, 0,
+			 recv_node_desc, node);
 }
 
-static void debug_port(ib_portid_t *portid, ibnd_port_t * port)
+static void debug_port(ib_portid_t * portid, ibnd_port_t * port)
 {
 	char width[64], speed[64];
 	int iwidth;
@@ -164,11 +153,11 @@ static void debug_port(ib_portid_t *portid, ibnd_port_t * port)
 	     mad_dump_val(IB_PORT_LINK_SPEED_ACTIVE_F, speed, 64, &ispeed));
 }
 
-static int recv_port_info(smp_engine_t *engine, ibnd_smp_t * smp,
-			  uint8_t *mad, void *cb_data)
+static int recv_port_info(smp_engine_t * engine, ibnd_smp_t * smp,
+			  uint8_t * mad, void *cb_data)
 {
-	ibnd_fabric_t *fabric = ((ibnd_scan_t *)engine->user_data)->fabric;
-	ibnd_node_t *node = (ibnd_node_t *)cb_data;
+	ibnd_fabric_t *fabric = ((ibnd_scan_t *) engine->user_data)->fabric;
+	ibnd_node_t *node = cb_data;
 	ibnd_port_t *port;
 	uint8_t *port_info = mad + IB_SMP_DATA_OFFS;
 	uint8_t port_num, local_port;
@@ -205,12 +194,9 @@ static int recv_port_info(smp_engine_t *engine, ibnd_smp_t * smp,
 
 	debug_port(&smp->path, port);
 
-	if (port_num &&
-	    (mad_get_field(port->info, 0, IB_PORT_PHYS_STATE_F)
-	    == IB_PORT_PHYS_STATE_LINKUP)
-		&&
-	    (node->type == IB_NODE_SWITCH || node == fabric->from_node)) {
-
+	if (port_num && mad_get_field(port->info, 0, IB_PORT_PHYS_STATE_F)
+	    == IB_PORT_PHYS_STATE_LINKUP
+	    && (node->type == IB_NODE_SWITCH || node == fabric->from_node)) {
 		ib_portid_t path = smp->path;
 		if (extend_dpath(engine, &path, port_num) != -1)
 			query_node_info(engine, &path, node);
@@ -218,19 +204,20 @@ static int recv_port_info(smp_engine_t *engine, ibnd_smp_t * smp,
 
 	return 0;
 }
-int query_port_info(smp_engine_t * engine, ib_portid_t * portid,
-		    ibnd_node_t *node, int portnum)
+
+static int query_port_info(smp_engine_t * engine, ib_portid_t * portid,
+			   ibnd_node_t * node, int portnum)
 {
 	IBND_DEBUG("Query Port Info; %s (%lx):%d\n", portid2str(portid),
 		   node->guid, portnum);
-	return (issue_smp(engine, portid, IB_ATTR_PORT_INFO, portnum, recv_port_info,
-			  (void *)node));
+	return issue_smp(engine, portid, IB_ATTR_PORT_INFO, portnum,
+			 recv_port_info, node);
 }
 
 static ibnd_node_t *create_node(smp_engine_t * engine, ib_portid_t * path,
-				uint8_t *node_info)
+				uint8_t * node_info)
 {
-	ibnd_fabric_t *fabric = ((ibnd_scan_t *)engine->user_data)->fabric;
+	ibnd_fabric_t *fabric = ((ibnd_scan_t *) engine->user_data)->fabric;
 	ibnd_node_t *rc = calloc(1, sizeof(*rc));
 	if (!rc) {
 		IBND_ERROR("OOM: node creation failed\n");
@@ -238,9 +225,9 @@ static ibnd_node_t *create_node(smp_engine_t * engine, ib_portid_t * path,
 	}
 
 	/* decode just a couple of fields for quicker reference. */
-	mad_decode_field(node_info, IB_NODE_GUID_F, &(rc->guid));
-	mad_decode_field(node_info, IB_NODE_TYPE_F, &(rc->type));
-	mad_decode_field(node_info, IB_NODE_NPORTS_F, &(rc->numports));
+	mad_decode_field(node_info, IB_NODE_GUID_F, &rc->guid);
+	mad_decode_field(node_info, IB_NODE_TYPE_F, &rc->type);
+	mad_decode_field(node_info, IB_NODE_NPORTS_F, &rc->numports);
 
 	rc->ports = calloc(rc->numports + 1, sizeof(*rc->ports));
 	if (!rc->ports) {
@@ -265,8 +252,9 @@ static ibnd_node_t *create_node(smp_engine_t * engine, ib_portid_t * path,
 
 static int get_last_port(ib_portid_t * path)
 {
-	return (path->drpath.p[path->drpath.cnt]);
+	return path->drpath.p[path->drpath.cnt];
 }
+
 static void link_ports(ibnd_node_t * node, ibnd_port_t * port,
 		       ibnd_node_t * remotenode, ibnd_port_t * remoteport)
 {
@@ -278,17 +266,17 @@ static void link_ports(ibnd_node_t * node, ibnd_port_t * port,
 		port->remoteport->remoteport = NULL;
 	if (remoteport->remoteport)
 		remoteport->remoteport->remoteport = NULL;
-	port->remoteport = (ibnd_port_t *) remoteport;
-	remoteport->remoteport = (ibnd_port_t *) port;
+	port->remoteport = remoteport;
+	remoteport->remoteport = port;
 }
 
-static int recv_node_info(smp_engine_t *engine, ibnd_smp_t * smp,
-			  uint8_t *mad, void *cb_data)
+static int recv_node_info(smp_engine_t * engine, ibnd_smp_t * smp,
+			  uint8_t * mad, void *cb_data)
 {
-	ibnd_fabric_t *fabric = ((ibnd_scan_t *)engine->user_data)->fabric;
+	ibnd_fabric_t *fabric = ((ibnd_scan_t *) engine->user_data)->fabric;
 	int i = 0;
 	uint8_t *node_info = mad + IB_SMP_DATA_OFFS;
-	ibnd_node_t * rem_node = (ibnd_node_t *)cb_data;
+	ibnd_node_t *rem_node = cb_data;
 	ibnd_node_t *node;
 	int node_is_new = 0;
 	uint64_t node_guid = mad_get_field64(node_info, 0, IB_NODE_GUID_F);
@@ -303,9 +291,8 @@ static int recv_node_info(smp_engine_t *engine, ibnd_smp_t * smp,
 			return -1;
 		node_is_new = 1;
 	}
-	IBND_DEBUG("Found %s node GUID %lx (%s)\n",
-		   (node_is_new) ? "new": "old", node->guid,
-		   portid2str(&smp->path));
+	IBND_DEBUG("Found %s node GUID %lx (%s)\n", node_is_new ? "new" : "old",
+		   node->guid, portid2str(&smp->path));
 
 	port = node->ports[port_num];
 	if (!port) {
@@ -316,7 +303,7 @@ static int recv_node_info(smp_engine_t *engine, ibnd_smp_t * smp,
 	}
 	port->guid = port_guid;
 
-	if (rem_node == NULL) /* this is the start node */
+	if (rem_node == NULL)	/* this is the start node */
 		fabric->from_node = node;
 	else {
 		/* link ports... */
@@ -326,7 +313,7 @@ static int recv_node_info(smp_engine_t *engine, ibnd_smp_t * smp,
 			IBND_ERROR("Internal Error; "
 				   "Node(%p) %lx Port %d no port created!?!?!?\n\n",
 				   rem_node, rem_node->guid, rem_port_num);
-			return (-1);
+			return -1;
 		}
 
 		link_ports(node, port, rem_node, rem_node->ports[rem_port_num]);
@@ -342,19 +329,19 @@ static int recv_node_info(smp_engine_t *engine, ibnd_smp_t * smp,
 
 	/* process all the ports on this node */
 	for (i = (node->type == IB_NODE_SWITCH) ? 0 : 1;
-		i <= node->numports; i++) {
-			query_port_info(engine, &smp->path, node, i);
+	     i <= node->numports; i++) {
+		query_port_info(engine, &smp->path, node, i);
 	}
 
 	return 0;
 }
 
-int query_node_info(smp_engine_t * engine, ib_portid_t * portid,
-		    ibnd_node_t * node)
+static int query_node_info(smp_engine_t * engine, ib_portid_t * portid,
+			   ibnd_node_t * node)
 {
 	IBND_DEBUG("Query Node Info; %s\n", portid2str(portid));
-	return (issue_smp(engine, portid, IB_ATTR_NODE_INFO, 0, recv_node_info,
-			  (void *)node));
+	return issue_smp(engine, portid, IB_ATTR_NODE_INFO, 0,
+			 recv_node_info, node);
 }
 
 ibnd_node_t *ibnd_find_node_guid(ibnd_fabric_t * fabric, uint64_t guid)
@@ -402,9 +389,8 @@ ibnd_node_t *ibnd_find_node_dr(ibnd_fabric_t * fabric, char *dr_str)
 
 	rc = fabric->from_node;
 
-	if (str2drpath(&path, dr_str, 0, 0) == -1) {
+	if (str2drpath(&path, dr_str, 0, 0) == -1)
 		return NULL;
-	}
 
 	for (i = 0; i <= path.cnt; i++) {
 		ibnd_port_t *remote_port = NULL;
@@ -464,7 +450,7 @@ int ibnd_set_max_smps_on_wire(int i)
 	return rc;
 }
 
-ibnd_fabric_t *ibnd_discover_fabric(struct ibmad_port *ibmad_port,
+ibnd_fabric_t *ibnd_discover_fabric(struct ibmad_port * ibmad_port,
 				    ib_portid_t * from, int hops)
 {
 	ibnd_fabric_t *fabric = NULL;
@@ -477,9 +463,8 @@ ibnd_fabric_t *ibnd_discover_fabric(struct ibmad_port *ibmad_port,
 		return NULL;
 
 	/* if not everything how much? */
-	if (hops >= 0) {
+	if (hops >= 0)
 		max_hops = hops;
-	}
 
 	/* If not specified start from "my" port */
 	if (!from)
@@ -493,17 +478,16 @@ ibnd_fabric_t *ibnd_discover_fabric(struct ibmad_port *ibmad_port,
 
 	memset(fabric, 0, sizeof(*fabric));
 
-	memset(&(scan.selfportid), 0, sizeof(scan.selfportid));
+	memset(&scan.selfportid, 0, sizeof(scan.selfportid));
 	scan.fabric = fabric;
 
 	smp_engine_init(&engine, ibmad_port, &scan, max_smps_on_wire);
 
 	IBND_DEBUG("from %s\n", portid2str(from));
 
-	if (!query_node_info(&engine, from, NULL)) {
+	if (!query_node_info(&engine, from, NULL))
 		if (process_mads(&engine) != 0)
 			goto error;
-	}
 
 	if (group_nodes(fabric))
 		goto error;
diff --git a/infiniband-diags/libibnetdisc/src/ibnetdisc_cache.c b/infiniband-diags/libibnetdisc/src/ibnetdisc_cache.c
index d94b85a..26157d7 100644
--- a/infiniband-diags/libibnetdisc/src/ibnetdisc_cache.c
+++ b/infiniband-diags/libibnetdisc/src/ibnetdisc_cache.c
@@ -34,7 +34,7 @@
  */
 
 #if HAVE_CONFIG_H
-#  include <config.h>
+#include <config.h>
 #endif				/* HAVE_CONFIG_H */
 
 #define _GNU_SOURCE
@@ -377,8 +377,8 @@ static int _load_node(int fd, ibnd_fabric_cache_t * fabric_cache)
 					  &node_cache->port_cache_keys[i].guid);
 			offset +=
 			    _unmarshall8(buf + offset,
-					 &node_cache->port_cache_keys[i].
-					 portnum);
+					 &node_cache->
+					 port_cache_keys[i].portnum);
 		}
 	}
 
@@ -573,8 +573,7 @@ static int _rebuild_ports(ibnd_fabric_cache_t * fabric_cache)
 
 		if (port_cache->remoteport_flag) {
 			if (!(remoteport_cache = _find_port(fabric_cache,
-							    &port_cache->
-							    remoteport_cache_key)))
+							    &port_cache->remoteport_cache_key)))
 			{
 				IBND_DEBUG
 				    ("Cache invalid: cannot find remote port\n");
diff --git a/infiniband-diags/libibnetdisc/src/internal.h b/infiniband-diags/libibnetdisc/src/internal.h
index 61b644d..179eac6 100644
--- a/infiniband-diags/libibnetdisc/src/internal.h
+++ b/infiniband-diags/libibnetdisc/src/internal.h
@@ -60,36 +60,35 @@ typedef struct ibnd_scan {
 	ibnd_fabric_t *fabric;
 } ibnd_scan_t;
 
-
 typedef struct ibnd_smp ibnd_smp_t;
 typedef struct smp_engine smp_engine_t;
-typedef int (*smp_comp_cb_t)(smp_engine_t *engine, ibnd_smp_t * smp,
-			     uint8_t *mad_resp, void *cb_data);
+typedef int (*smp_comp_cb_t) (smp_engine_t * engine, ibnd_smp_t * smp,
+			      uint8_t * mad_resp, void *cb_data);
 struct ibnd_smp {
 	cl_map_item_t on_wire;
-	struct ibnd_smp * qnext;
+	struct ibnd_smp *qnext;
 	smp_comp_cb_t cb;
-	void * cb_data;
+	void *cb_data;
 	ib_portid_t path;
 	ib_rpc_t rpc;
 };
+
 struct smp_engine {
 	struct ibmad_port *ibmad_port;
 	ibnd_smp_t *smp_queue_head;
 	ibnd_smp_t *smp_queue_tail;
-	void * user_data;
+	void *user_data;
 	cl_qmap_t smps_on_wire;
 	int num_smps_outstanding;
 	int max_smps_on_wire;
 };
 
 void smp_engine_init(smp_engine_t * engine, struct ibmad_port *ibmad_port,
-		     void * user_data, int max_smps_on_wire);
-int issue_smp(smp_engine_t *engine, ib_portid_t * portid,
-	      unsigned attrid, unsigned mod,
-	      smp_comp_cb_t cb, void * cb_data);
-int process_mads(smp_engine_t *engine);
-void smp_engine_destroy(smp_engine_t *engine);
+		     void *user_data, int max_smps_on_wire);
+int issue_smp(smp_engine_t * engine, ib_portid_t * portid,
+	      unsigned attrid, unsigned mod, smp_comp_cb_t cb, void *cb_data);
+int process_mads(smp_engine_t * engine);
+void smp_engine_destroy(smp_engine_t * engine);
 
 void add_to_nodeguid_hash(ibnd_node_t * node, ibnd_node_t * hash[]);
 
diff --git a/infiniband-diags/libibnetdisc/src/query_smp.c b/infiniband-diags/libibnetdisc/src/query_smp.c
index 1ace05e..a6878b6 100644
--- a/infiniband-diags/libibnetdisc/src/query_smp.c
+++ b/infiniband-diags/libibnetdisc/src/query_smp.c
@@ -36,8 +36,7 @@
 #include <infiniband/umad.h>
 #include "internal.h"
 
-void
-queue_smp(smp_engine_t *engine, ibnd_smp_t *smp)
+static void queue_smp(smp_engine_t * engine, ibnd_smp_t * smp)
 {
 	smp->qnext = NULL;
 	if (!engine->smp_queue_head) {
@@ -49,8 +48,7 @@ queue_smp(smp_engine_t *engine, ibnd_smp_t *smp)
 	}
 }
 
-ibnd_smp_t *
-get_smp(smp_engine_t *engine)
+static ibnd_smp_t *get_smp(smp_engine_t * engine)
 {
 	ibnd_smp_t *head = engine->smp_queue_head;
 	ibnd_smp_t *tail = engine->smp_queue_tail;
@@ -63,7 +61,7 @@ get_smp(smp_engine_t *engine)
 	return rc;
 }
 
-int send_smp(ibnd_smp_t * smp, struct ibmad_port *srcport)
+static int send_smp(ibnd_smp_t * smp, struct ibmad_port *srcport)
 {
 	int rc = 0;
 	uint8_t umad[1024];
@@ -89,7 +87,7 @@ int send_smp(ibnd_smp_t * smp, struct ibmad_port *srcport)
 	return 0;
 }
 
-static int process_smp_queue(smp_engine_t *engine)
+static int process_smp_queue(smp_engine_t * engine)
 {
 	int rc = 0;
 	ibnd_smp_t *smp;
@@ -98,17 +96,16 @@ static int process_smp_queue(smp_engine_t *engine)
 		if (!smp)
 			return 0;
 
-		cl_qmap_insert(&engine->smps_on_wire, (uint32_t)smp->rpc.trid,
-			       (cl_map_item_t *)smp);
+		cl_qmap_insert(&engine->smps_on_wire, (uint32_t) smp->rpc.trid,
+			       (cl_map_item_t *) smp);
 		if ((rc = send_smp(smp, engine->ibmad_port)) != 0)
 			return rc;
 	}
 	return 0;
 }
 
-int issue_smp(smp_engine_t *engine, ib_portid_t * portid,
-	      unsigned attrid, unsigned mod,
-	      smp_comp_cb_t cb, void * cb_data)
+int issue_smp(smp_engine_t * engine, ib_portid_t * portid,
+	      unsigned attrid, unsigned mod, smp_comp_cb_t cb, void *cb_data)
 {
 	ibnd_smp_t *smp = calloc(1, sizeof *smp);
 	if (!smp) {
@@ -127,22 +124,21 @@ int issue_smp(smp_engine_t *engine, ib_portid_t * portid,
 	smp->rpc.dataoffs = IB_SMP_DATA_OFFS;
 	smp->rpc.trid = mad_trid();
 
-	if ((portid->lid <= 0) ||
-	    (portid->drpath.drslid == 0xffff) ||
-	    (portid->drpath.drdlid == 0xffff))
-		smp->rpc.mgtclass = IB_SMI_DIRECT_CLASS; /* direct SMI */
+	if (portid->lid <= 0 || portid->drpath.drslid == 0xffff ||
+	    portid->drpath.drdlid == 0xffff)
+		smp->rpc.mgtclass = IB_SMI_DIRECT_CLASS;	/* direct SMI */
 	else
-		smp->rpc.mgtclass = IB_SMI_CLASS; /* Lid routed SMI */
+		smp->rpc.mgtclass = IB_SMI_CLASS;	/* Lid routed SMI */
 
 	portid->sl = 0;
 	portid->qp = 0;
 
 	engine->num_smps_outstanding++;
 	queue_smp(engine, smp);
-	return (process_smp_queue(engine));
+	return process_smp_queue(engine);
 }
 
-int process_one_recv(smp_engine_t *engine)
+static int process_one_recv(smp_engine_t * engine)
 {
 	int rc = 0;
 	int status = 0;
@@ -166,12 +162,11 @@ int process_one_recv(smp_engine_t *engine)
 	rc = process_smp_queue(engine);
 
 	mad = umad_get_mad(umad);
-	trid = (uint32_t)mad_get_field64(mad, 0, IB_MAD_TRID_F);
+	trid = (uint32_t) mad_get_field64(mad, 0, IB_MAD_TRID_F);
 
-	smp = (ibnd_smp_t *)cl_qmap_remove(&engine->smps_on_wire, trid);
-	if ((cl_map_item_t *)smp == cl_qmap_end(&engine->smps_on_wire)) {
-		IBND_ERROR("Failed to find matching smp for trid (%x)\n",
-			   trid);
+	smp = (ibnd_smp_t *) cl_qmap_remove(&engine->smps_on_wire, trid);
+	if ((cl_map_item_t *) smp == cl_qmap_end(&engine->smps_on_wire)) {
+		IBND_ERROR("Failed to find matching smp for trid (%x)\n", trid);
 		return -1;
 	}
 
@@ -180,27 +175,25 @@ int process_one_recv(smp_engine_t *engine)
 
 	if ((status = umad_status(umad))) {
 		IBND_ERROR("umad (%s Attr 0x%x:%u) bad status %d; %s\n",
-			portid2str(&smp->path),
-			smp->rpc.attr.id, smp->rpc.attr.mod,
-			status, strerror(status));
+			   portid2str(&smp->path), smp->rpc.attr.id,
+			   smp->rpc.attr.mod, status, strerror(status));
 	} else if ((status = mad_get_field(mad, 0, IB_DRSMP_STATUS_F))) {
-			IBND_ERROR("mad (%s Attr 0x%x:%u) bad status 0x%x\n",
-				   portid2str(&smp->path),
-				   smp->rpc.attr.id, smp->rpc.attr.mod,
-				   status);
+		IBND_ERROR("mad (%s Attr 0x%x:%u) bad status 0x%x\n",
+			   portid2str(&smp->path), smp->rpc.attr.id,
+			   smp->rpc.attr.mod, status);
 	} else
 		rc = smp->cb(engine, smp, mad, smp->cb_data);
 
 error:
 	free(smp);
 	engine->num_smps_outstanding--;
-	return (rc);
+	return rc;
 }
 
 void smp_engine_init(smp_engine_t * engine, struct ibmad_port *ibmad_port,
-		     void * user_data, int max_smps_on_wire)
+		     void *user_data, int max_smps_on_wire)
 {
-	memset(engine, '\0', sizeof(*engine));
+	memset(engine, 0, sizeof(*engine));
 	engine->ibmad_port = ibmad_port;
 	engine->user_data = user_data;
 	cl_qmap_init(&engine->smps_on_wire);
@@ -208,7 +201,7 @@ void smp_engine_init(smp_engine_t * engine, struct ibmad_port *ibmad_port,
 	engine->max_smps_on_wire = max_smps_on_wire;
 }
 
-void smp_engine_destroy(smp_engine_t *engine)
+void smp_engine_destroy(smp_engine_t * engine)
 {
 	cl_map_item_t *item;
 	ibnd_smp_t *smp;
@@ -217,15 +210,14 @@ void smp_engine_destroy(smp_engine_t *engine)
 	smp = get_smp(engine);
 	if (smp)
 		IBND_ERROR("outstanding SMP's\n");
-	for (/* */; smp; smp = get_smp(engine)) {
+	for ( /* */ ; smp; smp = get_smp(engine))
 		free(smp);
-	}
 
 	/* remove smps from the wire queue */
 	item = cl_qmap_head(&engine->smps_on_wire);
 	if (item != cl_qmap_end(&engine->smps_on_wire))
 		IBND_ERROR("outstanding SMP's on wire\n");
-	for (/* */; item != cl_qmap_end(&engine->smps_on_wire);
+	for ( /* */ ; item != cl_qmap_end(&engine->smps_on_wire);
 	     item = cl_qmap_head(&engine->smps_on_wire)) {
 		cl_qmap_remove_item(&engine->smps_on_wire, item);
 		free(item);
@@ -234,7 +226,7 @@ void smp_engine_destroy(smp_engine_t *engine)
 	engine->num_smps_outstanding = 0;
 }
 
-int process_mads(smp_engine_t *engine)
+int process_mads(smp_engine_t * engine)
 {
 	int rc = 0;
 	while (engine->num_smps_outstanding > 0) {
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH] libibnetdisc: restore show_progress functionality
  2010-04-10  0:55     ` [PATCH] libibnetdisc: code cleanups Sasha Khapyorsky
@ 2010-04-10  0:56       ` Sasha Khapyorsky
  2010-04-10  0:57       ` [PATCH] libibnetdisc: restore hops limited discovery Sasha Khapyorsky
  2010-04-10  0:57       ` [PATCH] libibnetdisc: keep total number of used SMPs Sasha Khapyorsky
  2 siblings, 0 replies; 15+ messages in thread
From: Sasha Khapyorsky @ 2010-04-10  0:56 UTC (permalink / raw)
  To: Ira Weiny; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Hal Rosenstock


Restore show_progress functionality. This output is used by scripts like
'dump_lfts.sh -D', also sometimes useful for debug.

Signed-off-by: Sasha Khapyorsky <sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org>
---
 infiniband-diags/libibnetdisc/src/ibnetdisc.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/infiniband-diags/libibnetdisc/src/ibnetdisc.c b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
index 4780810..b438d4f 100644
--- a/infiniband-diags/libibnetdisc/src/ibnetdisc.c
+++ b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
@@ -270,6 +270,18 @@ static void link_ports(ibnd_node_t * node, ibnd_port_t * port,
 	remoteport->remoteport = port;
 }
 
+static void dump_endnode(ib_portid_t * path, char *prompt,
+			 ibnd_node_t * node, ibnd_port_t * port)
+{
+	char type[64];
+	mad_dump_node_type(type, sizeof(type), &node->type, sizeof(int));
+	printf("%s -> %s %s {%016" PRIx64 "} portnum %d lid %d-%d \"%s\"\n",
+	       portid2str(path), prompt, type, node->guid,
+	       node->type == IB_NODE_SWITCH ? 0 : port->portnum,
+	       port->base_lid, port->base_lid + (1 << port->lmc) - 1,
+	       node->nodedesc);
+}
+
 static int recv_node_info(smp_engine_t * engine, ibnd_smp_t * smp,
 			  uint8_t * mad, void *cb_data)
 {
@@ -303,6 +315,10 @@ static int recv_node_info(smp_engine_t * engine, ibnd_smp_t * smp,
 	}
 	port->guid = port_guid;
 
+	if (show_progress)
+		dump_endnode(&smp->path, node_is_new ? "new" : "known",
+			     node, port);
+
 	if (rem_node == NULL)	/* this is the start node */
 		fabric->from_node = node;
 	else {
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH] libibnetdisc: restore hops limited discovery
  2010-04-10  0:55     ` [PATCH] libibnetdisc: code cleanups Sasha Khapyorsky
  2010-04-10  0:56       ` [PATCH] libibnetdisc: restore show_progress functionality Sasha Khapyorsky
@ 2010-04-10  0:57       ` Sasha Khapyorsky
  2010-04-10  0:57       ` [PATCH] libibnetdisc: keep total number of used SMPs Sasha Khapyorsky
  2 siblings, 0 replies; 15+ messages in thread
From: Sasha Khapyorsky @ 2010-04-10  0:57 UTC (permalink / raw)
  To: Ira Weiny; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Hal Rosenstock


Restore hops limited discovery.

Signed-off-by: Sasha Khapyorsky <sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org>
---
 infiniband-diags/libibnetdisc/src/ibnetdisc.c |   12 ++++++------
 infiniband-diags/libibnetdisc/src/internal.h  |    1 +
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/infiniband-diags/libibnetdisc/src/ibnetdisc.c b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
index b438d4f..4012eff 100644
--- a/infiniband-diags/libibnetdisc/src/ibnetdisc.c
+++ b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
@@ -96,6 +96,9 @@ static int extend_dpath(smp_engine_t * engine, ib_portid_t * portid,
 	ibnd_scan_t *scan = engine->user_data;
 	ibnd_fabric_t *fabric = scan->fabric;
 
+	if (scan->max_hops && fabric->maxhops_discovered >= scan->max_hops)
+		return 0;
+
 	if (portid->lid) {
 		/* If we were LID routed we need to set up the drslid */
 		if (!scan->selfportid.lid)
@@ -198,7 +201,7 @@ static int recv_port_info(smp_engine_t * engine, ibnd_smp_t * smp,
 	    == IB_PORT_PHYS_STATE_LINKUP
 	    && (node->type == IB_NODE_SWITCH || node == fabric->from_node)) {
 		ib_portid_t path = smp->path;
-		if (extend_dpath(engine, &path, port_num) != -1)
+		if (extend_dpath(engine, &path, port_num) > 0)
 			query_node_info(engine, &path, node);
 	}
 
@@ -471,17 +474,12 @@ ibnd_fabric_t *ibnd_discover_fabric(struct ibmad_port * ibmad_port,
 {
 	ibnd_fabric_t *fabric = NULL;
 	ib_portid_t my_portid = { 0 };
-	int max_hops = MAXHOPS - 1;	/* default find everything */
 	smp_engine_t engine;
 	ibnd_scan_t scan;
 
 	if (_check_ibmad_port(ibmad_port) < 0)
 		return NULL;
 
-	/* if not everything how much? */
-	if (hops >= 0)
-		max_hops = hops;
-
 	/* If not specified start from "my" port */
 	if (!from)
 		from = &my_portid;
@@ -496,6 +494,8 @@ ibnd_fabric_t *ibnd_discover_fabric(struct ibmad_port * ibmad_port,
 
 	memset(&scan.selfportid, 0, sizeof(scan.selfportid));
 	scan.fabric = fabric;
+	if (hops >= 0)
+		scan.max_hops = hops;
 
 	smp_engine_init(&engine, ibmad_port, &scan, max_smps_on_wire);
 
diff --git a/infiniband-diags/libibnetdisc/src/internal.h b/infiniband-diags/libibnetdisc/src/internal.h
index 179eac6..05e254d 100644
--- a/infiniband-diags/libibnetdisc/src/internal.h
+++ b/infiniband-diags/libibnetdisc/src/internal.h
@@ -58,6 +58,7 @@
 typedef struct ibnd_scan {
 	ib_portid_t selfportid;
 	ibnd_fabric_t *fabric;
+	unsigned max_hops;
 } ibnd_scan_t;
 
 typedef struct ibnd_smp ibnd_smp_t;
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH] libibnetdisc: keep total number of used SMPs
  2010-04-10  0:55     ` [PATCH] libibnetdisc: code cleanups Sasha Khapyorsky
  2010-04-10  0:56       ` [PATCH] libibnetdisc: restore show_progress functionality Sasha Khapyorsky
  2010-04-10  0:57       ` [PATCH] libibnetdisc: restore hops limited discovery Sasha Khapyorsky
@ 2010-04-10  0:57       ` Sasha Khapyorsky
  2010-04-10  0:58         ` [PATCH] infiniband-diags/ibnetdiscover: report number of used MADs Sasha Khapyorsky
  2 siblings, 1 reply; 15+ messages in thread
From: Sasha Khapyorsky @ 2010-04-10  0:57 UTC (permalink / raw)
  To: Ira Weiny; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Hal Rosenstock


Keep and track total number of used SMPs in smp engine structure
(total_smps field) and for statistic purpose return it with fabric
object (total_mads_used field).

Signed-off-by: Sasha Khapyorsky <sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org>
---
 .../libibnetdisc/include/infiniband/ibnetdisc.h    |    3 ++-
 infiniband-diags/libibnetdisc/src/ibnetdisc.c      |    2 ++
 infiniband-diags/libibnetdisc/src/internal.h       |    1 +
 infiniband-diags/libibnetdisc/src/query_smp.c      |    1 +
 4 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/infiniband-diags/libibnetdisc/include/infiniband/ibnetdisc.h b/infiniband-diags/libibnetdisc/include/infiniband/ibnetdisc.h
index 556014e..8c38c94 100644
--- a/infiniband-diags/libibnetdisc/include/infiniband/ibnetdisc.h
+++ b/infiniband-diags/libibnetdisc/include/infiniband/ibnetdisc.h
@@ -143,7 +143,8 @@ typedef struct ibnd_fabric {
 	ibnd_node_t *nodes;
 	/* NULL terminated list of all chassis found in the fabric */
 	ibnd_chassis_t *chassis;
-	int maxhops_discovered;
+	unsigned maxhops_discovered;
+	unsigned total_mads_used;
 
 	/* internal use only */
 	ibnd_node_t *nodestbl[HTSZ];
diff --git a/infiniband-diags/libibnetdisc/src/ibnetdisc.c b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
index 4012eff..65126dd 100644
--- a/infiniband-diags/libibnetdisc/src/ibnetdisc.c
+++ b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
@@ -505,6 +505,8 @@ ibnd_fabric_t *ibnd_discover_fabric(struct ibmad_port * ibmad_port,
 		if (process_mads(&engine) != 0)
 			goto error;
 
+	fabric->total_mads_used = engine.total_smps;
+
 	if (group_nodes(fabric))
 		goto error;
 
diff --git a/infiniband-diags/libibnetdisc/src/internal.h b/infiniband-diags/libibnetdisc/src/internal.h
index 05e254d..d2d4826 100644
--- a/infiniband-diags/libibnetdisc/src/internal.h
+++ b/infiniband-diags/libibnetdisc/src/internal.h
@@ -82,6 +82,7 @@ struct smp_engine {
 	cl_qmap_t smps_on_wire;
 	int num_smps_outstanding;
 	int max_smps_on_wire;
+	unsigned total_smps;
 };
 
 void smp_engine_init(smp_engine_t * engine, struct ibmad_port *ibmad_port,
diff --git a/infiniband-diags/libibnetdisc/src/query_smp.c b/infiniband-diags/libibnetdisc/src/query_smp.c
index a6878b6..1ec9752 100644
--- a/infiniband-diags/libibnetdisc/src/query_smp.c
+++ b/infiniband-diags/libibnetdisc/src/query_smp.c
@@ -133,6 +133,7 @@ int issue_smp(smp_engine_t * engine, ib_portid_t * portid,
 	portid->sl = 0;
 	portid->qp = 0;
 
+	engine->total_smps++;
 	engine->num_smps_outstanding++;
 	queue_smp(engine, smp);
 	return process_smp_queue(engine);
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH] infiniband-diags/ibnetdiscover: report number of used MADs
  2010-04-10  0:57       ` [PATCH] libibnetdisc: keep total number of used SMPs Sasha Khapyorsky
@ 2010-04-10  0:58         ` Sasha Khapyorsky
  2010-04-10  0:58           ` [PATCH] libibnetdisc: no backward NodeInfo queries Sasha Khapyorsky
  0 siblings, 1 reply; 15+ messages in thread
From: Sasha Khapyorsky @ 2010-04-10  0:58 UTC (permalink / raw)
  To: Ira Weiny; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Hal Rosenstock


When '--max_hops,-m' option is specified report (in comment) a total
number of used MADs for discovery aside of number of hops.

Signed-off-by: Sasha Khapyorsky <sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org>
---
 infiniband-diags/src/ibnetdiscover.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/infiniband-diags/src/ibnetdiscover.c b/infiniband-diags/src/ibnetdiscover.c
index 1ff8ef6..32776ad 100644
--- a/infiniband-diags/src/ibnetdiscover.c
+++ b/infiniband-diags/src/ibnetdiscover.c
@@ -444,8 +444,9 @@ int dump_topology(int group, ibnd_fabric_t * fabric)
 
 	fprintf(f, "#\n# Topology file: generated on %s#\n", ctime(&t));
 	if (report_max_hops)
-		fprintf(f, "# Reported max hops discovered: %d\n",
-			fabric->maxhops_discovered);
+		fprintf(f, "# Reported max hops discovered: %u\n"
+			"# Total MADs used: %u\n",
+			fabric->maxhops_discovered, fabric->total_mads_used);
 	fprintf(f, "# Initiated from node %016" PRIx64 " port %016" PRIx64 "\n",
 		fabric->from_node->guid,
 		mad_get_field64(fabric->from_node->info, 0,
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH] libibnetdisc: no backward NodeInfo queries
  2010-04-10  0:58         ` [PATCH] infiniband-diags/ibnetdiscover: report number of used MADs Sasha Khapyorsky
@ 2010-04-10  0:58           ` Sasha Khapyorsky
  2010-04-10  1:00             ` [PATCH] libibnetdisc: config struct for ibnd_discover_fabric() Sasha Khapyorsky
  0 siblings, 1 reply; 15+ messages in thread
From: Sasha Khapyorsky @ 2010-04-10  0:58 UTC (permalink / raw)
  To: Ira Weiny; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Hal Rosenstock


Then switch is reached via port N we don't need to query back via this
port - source node is discovered already. Finally this saves some amount
of unnecessary MADs.

Signed-off-by: Sasha Khapyorsky <sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org>
---
 infiniband-diags/libibnetdisc/src/ibnetdisc.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/infiniband-diags/libibnetdisc/src/ibnetdisc.c b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
index 65126dd..03b678e 100644
--- a/infiniband-diags/libibnetdisc/src/ibnetdisc.c
+++ b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
@@ -199,7 +199,8 @@ static int recv_port_info(smp_engine_t * engine, ibnd_smp_t * smp,
 
 	if (port_num && mad_get_field(port->info, 0, IB_PORT_PHYS_STATE_F)
 	    == IB_PORT_PHYS_STATE_LINKUP
-	    && (node->type == IB_NODE_SWITCH || node == fabric->from_node)) {
+	    && ((node->type == IB_NODE_SWITCH && port_num != local_port) ||
+		 node == fabric->from_node)) {
 		ib_portid_t path = smp->path;
 		if (extend_dpath(engine, &path, port_num) > 0)
 			query_node_info(engine, &path, node);
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH] libibnetdisc: config struct for ibnd_discover_fabric()
  2010-04-10  0:58           ` [PATCH] libibnetdisc: no backward NodeInfo queries Sasha Khapyorsky
@ 2010-04-10  1:00             ` Sasha Khapyorsky
  2010-04-10  1:41               ` [PATCH v2] " Sasha Khapyorsky
  0 siblings, 1 reply; 15+ messages in thread
From: Sasha Khapyorsky @ 2010-04-10  1:00 UTC (permalink / raw)
  To: Ira Weiny; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Hal Rosenstock


Instead of using static configuration parameters/flags and to have API
functions to set up each one (and so add new API when any new flag is
added) use just single configuration structure which is reenterently
passed by to ibnd_fabric_discover() function.

In order to not change API a lot we will keep some "padding" space in
this configuration structure, so it will be extendable for future
parameters/flags.

Remove old config related functions.

Signed-off-by: Sasha Khapyorsky <sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org>
---
 .../libibnetdisc/include/infiniband/ibnetdisc.h    |   14 ++++--
 infiniband-diags/libibnetdisc/src/ibnetdisc.c      |   49 +++++---------------
 infiniband-diags/libibnetdisc/src/internal.h       |    2 +-
 infiniband-diags/libibnetdisc/src/libibnetdisc.map |    3 -
 infiniband-diags/libibnetdisc/test/testleaks.c     |   23 ++++-----
 infiniband-diags/src/iblinkinfo.c                  |   22 +++------
 infiniband-diags/src/ibnetdiscover.c               |   17 ++----
 infiniband-diags/src/ibqueryerrors.c               |   17 ++----
 8 files changed, 53 insertions(+), 94 deletions(-)

diff --git a/infiniband-diags/libibnetdisc/include/infiniband/ibnetdisc.h b/infiniband-diags/libibnetdisc/include/infiniband/ibnetdisc.h
index 8c38c94..136282c 100644
--- a/infiniband-diags/libibnetdisc/include/infiniband/ibnetdisc.h
+++ b/infiniband-diags/libibnetdisc/include/infiniband/ibnetdisc.h
@@ -129,6 +129,14 @@ typedef struct ibnd_chassis {
 
 #define HTSZ 137
 
+typedef struct ibnd_config {
+	unsigned max_smps;
+	unsigned show_progress;
+	unsigned max_hops;
+	unsigned debug;
+	uint8_t pad[64];
+} ibnd_config_t;
+
 /** =========================================================================
  * Fabric
  * Main fabric object which is returned and represents the data discovered
@@ -157,12 +165,10 @@ typedef struct ibnd_fabric {
 /** =========================================================================
  * Initialization (fabric operations)
  */
-MAD_EXPORT void ibnd_debug(int i);
-MAD_EXPORT void ibnd_show_progress(int i);
-MAD_EXPORT int ibnd_set_max_smps_on_wire(int i);
 
 MAD_EXPORT ibnd_fabric_t *ibnd_discover_fabric(struct ibmad_port *ibmad_port,
-					       ib_portid_t * from, int hops);
+					       ib_portid_t * from,
+					       struct ibnd_config *config);
 	/**
 	 * open: (required) ibmad_port object from libibmad
 	 * from: (optional) specify the node to start scanning from.
diff --git a/infiniband-diags/libibnetdisc/src/ibnetdisc.c b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
index 03b678e..6b02c2b 100644
--- a/infiniband-diags/libibnetdisc/src/ibnetdisc.c
+++ b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
@@ -54,10 +54,6 @@
 #include "internal.h"
 #include "chassis.h"
 
-static int show_progress = 0;
-static int max_smps_on_wire = DEFAULT_MAX_SMP_ON_WIRE;
-int ibdebug;
-
 /* forward declare */
 static int query_node_info(smp_engine_t * engine, ib_portid_t * portid,
 			   ibnd_node_t * node);
@@ -96,7 +92,8 @@ static int extend_dpath(smp_engine_t * engine, ib_portid_t * portid,
 	ibnd_scan_t *scan = engine->user_data;
 	ibnd_fabric_t *fabric = scan->fabric;
 
-	if (scan->max_hops && fabric->maxhops_discovered >= scan->max_hops)
+	if (scan->cfg->max_hops &&
+	    fabric->maxhops_discovered >= scan->cfg->max_hops)
 		return 0;
 
 	if (portid->lid) {
@@ -289,7 +286,8 @@ static void dump_endnode(ib_portid_t * path, char *prompt,
 static int recv_node_info(smp_engine_t * engine, ibnd_smp_t * smp,
 			  uint8_t * mad, void *cb_data)
 {
-	ibnd_fabric_t *fabric = ((ibnd_scan_t *) engine->user_data)->fabric;
+	ibnd_scan_t *scan = engine->user_data;
+	ibnd_fabric_t *fabric = scan->fabric;
 	int i = 0;
 	uint8_t *node_info = mad + IB_SMP_DATA_OFFS;
 	ibnd_node_t *rem_node = cb_data;
@@ -319,7 +317,7 @@ static int recv_node_info(smp_engine_t * engine, ibnd_smp_t * smp,
 	}
 	port->guid = port_guid;
 
-	if (show_progress)
+	if (scan->cfg->show_progress)
 		dump_endnode(&smp->path, node_is_new ? "new" : "known",
 			     node, port);
 
@@ -463,16 +461,10 @@ void add_to_type_list(ibnd_node_t * node, ibnd_fabric_t * fabric)
 	}
 }
 
-int ibnd_set_max_smps_on_wire(int i)
-{
-	int rc = max_smps_on_wire;
-	max_smps_on_wire = i;
-	return rc;
-}
-
-ibnd_fabric_t *ibnd_discover_fabric(struct ibmad_port * ibmad_port,
-				    ib_portid_t * from, int hops)
+ibnd_fabric_t *ibnd_discover_fabric(struct ibmad_port *ibmad_port,
+				    ib_portid_t * from, struct ibnd_config *cfg)
 {
+	struct ibnd_config default_config = { 0 };
 	ibnd_fabric_t *fabric = NULL;
 	ib_portid_t my_portid = { 0 };
 	smp_engine_t engine;
@@ -495,10 +487,11 @@ ibnd_fabric_t *ibnd_discover_fabric(struct ibmad_port * ibmad_port,
 
 	memset(&scan.selfportid, 0, sizeof(scan.selfportid));
 	scan.fabric = fabric;
-	if (hops >= 0)
-		scan.max_hops = hops;
+	if (!cfg)
+		scan.cfg = &default_config;
 
-	smp_engine_init(&engine, ibmad_port, &scan, max_smps_on_wire);
+	smp_engine_init(&engine, ibmad_port, &scan, cfg->max_smps ?
+			cfg->max_smps : DEFAULT_MAX_SMP_ON_WIRE);
 
 	IBND_DEBUG("from %s\n", portid2str(from));
 
@@ -555,24 +548,6 @@ void ibnd_destroy_fabric(ibnd_fabric_t * fabric)
 	free(fabric);
 }
 
-void ibnd_debug(int i)
-{
-	if (i) {
-		ibdebug++;
-		madrpc_show_errors(1);
-		umad_debug(i);
-	} else {
-		ibdebug = 0;
-		madrpc_show_errors(0);
-		umad_debug(0);
-	}
-}
-
-void ibnd_show_progress(int i)
-{
-	show_progress = i;
-}
-
 void ibnd_iter_nodes(ibnd_fabric_t * fabric, ibnd_iter_node_func_t func,
 		     void *user_data)
 {
diff --git a/infiniband-diags/libibnetdisc/src/internal.h b/infiniband-diags/libibnetdisc/src/internal.h
index d2d4826..57034f9 100644
--- a/infiniband-diags/libibnetdisc/src/internal.h
+++ b/infiniband-diags/libibnetdisc/src/internal.h
@@ -58,7 +58,7 @@
 typedef struct ibnd_scan {
 	ib_portid_t selfportid;
 	ibnd_fabric_t *fabric;
-	unsigned max_hops;
+	struct ibnd_config *cfg;
 } ibnd_scan_t;
 
 typedef struct ibnd_smp ibnd_smp_t;
diff --git a/infiniband-diags/libibnetdisc/src/libibnetdisc.map b/infiniband-diags/libibnetdisc/src/libibnetdisc.map
index 30f7ab9..8a56fbb 100644
--- a/infiniband-diags/libibnetdisc/src/libibnetdisc.map
+++ b/infiniband-diags/libibnetdisc/src/libibnetdisc.map
@@ -1,7 +1,5 @@
 IBNETDISC_1.0 {
 	global:
-		ibnd_debug;
-		ibnd_show_progress;
 		ibnd_discover_fabric;
 		ibnd_destroy_fabric;
 		ibnd_load_fabric;
@@ -16,6 +14,5 @@ IBNETDISC_1.0 {
 		ibnd_get_chassis_slot_str;
 		ibnd_iter_nodes;
 		ibnd_iter_nodes_type;
-		ibnd_set_max_smps_on_wire;
 	local: *;
 };
diff --git a/infiniband-diags/libibnetdisc/test/testleaks.c b/infiniband-diags/libibnetdisc/test/testleaks.c
index cb5651e..da2fc0a 100644
--- a/infiniband-diags/libibnetdisc/test/testleaks.c
+++ b/infiniband-diags/libibnetdisc/test/testleaks.c
@@ -77,6 +77,7 @@ void usage(void)
 
 int main(int argc, char **argv)
 {
+	struct ibnd_config config = { 0 };
 	int rc = 0;
 	char *ca = 0;
 	int ca_port = 0;
@@ -84,7 +85,6 @@ int main(int argc, char **argv)
 	uint64_t guid = 0;
 	char *dr_path = NULL;
 	char *from = NULL;
-	int hops = 0;
 	ib_portid_t port_id;
 	int iters = -1;
 
@@ -118,7 +118,7 @@ int main(int argc, char **argv)
 			break;
 		switch (ch) {
 		case 2:
-			ibnd_debug(1);
+			config.debug++;
 			break;
 		case 'f':
 			from = strdup(optarg);
@@ -133,7 +133,7 @@ int main(int argc, char **argv)
 			dr_path = strdup(optarg);
 			break;
 		case 'n':
-			hops = (int)strtol(optarg, NULL, 0);
+			config.max_hops = strtoul(optarg, NULL, 0);
 			break;
 		case 'i':
 			iters = (int)strtol(optarg, NULL, 0);
@@ -161,21 +161,18 @@ int main(int argc, char **argv)
 			/* only scan part of the fabric */
 			str2drpath(&(port_id.drpath), from, 0, 0);
 			if ((fabric = ibnd_discover_fabric(ibmad_port,
-							   &port_id,
-							   hops)) == NULL) {
+							   &port_id, &config))
+			    == NULL) {
 				fprintf(stderr, "discover failed\n");
 				rc = 1;
 				goto close_port;
 			}
 			guid = 0;
-		} else {
-			if ((fabric =
-			     ibnd_discover_fabric(ibmad_port, NULL,
-						  -1)) == NULL) {
-				fprintf(stderr, "discover failed\n");
-				rc = 1;
-				goto close_port;
-			}
+		} else if ((fabric = ibnd_discover_fabric(ibmad_port, NULL,
+							  &config)) == NULL) {
+			fprintf(stderr, "discover failed\n");
+			rc = 1;
+			goto close_port;
 		}
 
 		ibnd_destroy_fabric(fabric);
diff --git a/infiniband-diags/src/iblinkinfo.c b/infiniband-diags/src/iblinkinfo.c
index 5627dc9..029573f 100644
--- a/infiniband-diags/src/iblinkinfo.c
+++ b/infiniband-diags/src/iblinkinfo.c
@@ -61,13 +61,11 @@ static uint64_t guid = 0;
 static char *guid_str = NULL;
 static char *dr_path = NULL;
 static int all = 0;
-static int hops = 0;
 
 static int down_links_only = 0;
 static int line_mode = 0;
 static int add_sw_settings = 0;
 static int print_port_guids = 0;
-static int outstanding_smps = 0; /* use default from lib */
 
 static unsigned int get_max(unsigned int num)
 {
@@ -242,6 +240,7 @@ void print_switch(ibnd_node_t * node, void *user_data)
 
 static int process_opt(void *context, int ch, char *optarg)
 {
+	struct ibnd_config *cfg = context;
 	switch (ch) {
 	case 1:
 		node_name_map_file = strdup(optarg);
@@ -260,7 +259,7 @@ static int process_opt(void *context, int ch, char *optarg)
 		all = 1;
 		break;
 	case 'n':
-		hops = (int)strtol(optarg, NULL, 0);
+		cfg->max_hops = strtoul(optarg, NULL, 0);
 		break;
 	case 'd':
 		down_links_only = 1;
@@ -277,7 +276,7 @@ static int process_opt(void *context, int ch, char *optarg)
 	case 'R':		/* nop */
 		break;
 	case 'o':
-		outstanding_smps = atoi(optarg);
+		cfg->max_smps = strtoul(optarg, NULL, 0);
 		break;
 	default:
 		return -1;
@@ -288,6 +287,7 @@ static int process_opt(void *context, int ch, char *optarg)
 
 int main(int argc, char **argv)
 {
+	struct ibnd_config config = { 0 };
 	int rc = 0;
 	int resolved = -1;
 	ibnd_fabric_t *fabric = NULL;
@@ -324,15 +324,12 @@ int main(int argc, char **argv)
 	};
 	char usage_args[] = "";
 
-	ibdiag_process_opts(argc, argv, NULL, "SDandlpgRGL", opts, process_opt,
-			    usage_args, NULL);
+	ibdiag_process_opts(argc, argv, &config, "SDandlpgRGL", opts,
+			    process_opt, usage_args, NULL);
 
 	argc -= optind;
 	argv += optind;
 
-	if (ibverbose)
-		ibnd_debug(1);
-
 	ibmad_port = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 3);
 	if (!ibmad_port) {
 		fprintf(stderr, "Failed to open %s port %d", ibd_ca,
@@ -345,9 +342,6 @@ int main(int argc, char **argv)
 
 	node_name_map = open_node_name_map(node_name_map_file);
 
-	if (outstanding_smps)
-		ibnd_set_max_smps_on_wire(outstanding_smps);
-
 	if (dr_path && load_cache_file) {
 		fprintf(stderr, "Cannot specify cache and direct route path\n");
 		exit(1);
@@ -377,12 +371,12 @@ int main(int argc, char **argv)
 	} else {
 		if (resolved >= 0 &&
 		    !(fabric =
-		      ibnd_discover_fabric(ibmad_port, &port_id, hops)))
+		      ibnd_discover_fabric(ibmad_port, &port_id, &config)))
 			IBWARN("Single node discover failed;"
 			       " attempting full scan\n");
 
 		if (!fabric &&
-		    !(fabric = ibnd_discover_fabric(ibmad_port, NULL, -1))) {
+		    !(fabric = ibnd_discover_fabric(ibmad_port, NULL, &config))) {
 			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 32776ad..f40d0f9 100644
--- a/infiniband-diags/src/ibnetdiscover.c
+++ b/infiniband-diags/src/ibnetdiscover.c
@@ -67,7 +67,6 @@ static char *cache_file = NULL;
 static char *load_cache_file = NULL;
 
 static int report_max_hops = 0;
-static int outstanding_smps = 0; /* use default from lib */
 
 /**
  * Define our own conversion functions to maintain compatibility with the old
@@ -616,6 +615,7 @@ static int list, group, ports_report;
 
 static int process_opt(void *context, int ch, char *optarg)
 {
+	struct ibnd_config *cfg = context;
 	switch (ch) {
 	case 1:
 		node_name_map_file = strdup(optarg);
@@ -627,7 +627,7 @@ static int process_opt(void *context, int ch, char *optarg)
 		load_cache_file = strdup(optarg);
 		break;
 	case 's':
-		ibnd_show_progress(1);
+		cfg->show_progress = 1;
 		break;
 	case 'l':
 		list = LIST_CA_NODE | LIST_SWITCH_NODE | LIST_ROUTER_NODE;
@@ -651,7 +651,7 @@ static int process_opt(void *context, int ch, char *optarg)
 		report_max_hops = 1;
 		break;
 	case 'o':
-		outstanding_smps = atoi(optarg);
+		cfg->max_smps = strtoul(optarg, NULL, 0);
 		break;
 	default:
 		return -1;
@@ -662,6 +662,7 @@ static int process_opt(void *context, int ch, char *optarg)
 
 int main(int argc, char **argv)
 {
+	struct ibnd_config config = { 0 };
 	ibnd_fabric_t *fabric = NULL;
 
 	struct ibmad_port *ibmad_port;
@@ -689,7 +690,7 @@ int main(int argc, char **argv)
 	};
 	char usage_args[] = "[topology-file]";
 
-	ibdiag_process_opts(argc, argv, NULL, "sGDL", opts, process_opt,
+	ibdiag_process_opts(argc, argv, &config, "sGDL", opts, process_opt,
 			    usage_args, NULL);
 
 	f = stdout;
@@ -697,9 +698,6 @@ int main(int argc, char **argv)
 	argc -= optind;
 	argv += optind;
 
-	if (ibverbose)
-		ibnd_debug(1);
-
 	ibmad_port = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 2);
 	if (!ibmad_port)
 		IBERROR("Failed to open %s port %d", ibd_ca, ibd_ca_port);
@@ -712,15 +710,12 @@ int main(int argc, char **argv)
 
 	node_name_map = open_node_name_map(node_name_map_file);
 
-	if (outstanding_smps)
-		ibnd_set_max_smps_on_wire(outstanding_smps);
-
 	if (load_cache_file) {
 		if ((fabric = ibnd_load_fabric(load_cache_file, 0)) == NULL)
 			IBERROR("loading cached fabric failed\n");
 	} else {
 		if ((fabric =
-		     ibnd_discover_fabric(ibmad_port, NULL, -1)) == NULL)
+		     ibnd_discover_fabric(ibmad_port, NULL, &config)) == NULL)
 			IBERROR("discover failed\n");
 	}
 
diff --git a/infiniband-diags/src/ibqueryerrors.c b/infiniband-diags/src/ibqueryerrors.c
index 725e098..e896254 100644
--- a/infiniband-diags/src/ibqueryerrors.c
+++ b/infiniband-diags/src/ibqueryerrors.c
@@ -70,7 +70,6 @@ enum MAD_FIELDS suppressed_fields[SUP_MAX];
 char *dr_path = NULL;
 uint8_t node_type_to_print = 0;
 unsigned clear_errors = 0, clear_counts = 0, details = 0;
-static int outstanding_smps = 0; /* use default from lib */
 
 #define PRINT_SWITCH 0x1
 #define PRINT_CA     0x2
@@ -483,6 +482,7 @@ static void calculate_suppressed_fields(char *str)
 
 static int process_opt(void *context, int ch, char *optarg)
 {
+	struct ibnd_config *cfg = context;
 	switch (ch) {
 	case 's':
 		calculate_suppressed_fields(optarg);
@@ -532,7 +532,7 @@ static int process_opt(void *context, int ch, char *optarg)
 		clear_counts = 1;
 		break;
 	case 'o':
-		outstanding_smps = atoi(optarg);
+		cfg->max_smps = strtoul(optarg, NULL, 0);
 		break;
 	default:
 		return -1;
@@ -543,6 +543,7 @@ static int process_opt(void *context, int ch, char *optarg)
 
 int main(int argc, char **argv)
 {
+	struct ibnd_config config = { 0 };
 	int resolved = -1;
 	ib_portid_t portid = { 0 };
 	int rc = 0;
@@ -586,7 +587,7 @@ int main(int argc, char **argv)
 	char usage_args[] = "";
 
 	memset(suppressed_fields, 0, sizeof suppressed_fields);
-	ibdiag_process_opts(argc, argv, NULL, "scnSrRDGL", opts, process_opt,
+	ibdiag_process_opts(argc, argv, &config, "scnSrRDGL", opts, process_opt,
 			    usage_args, NULL);
 
 	argc -= optind;
@@ -595,9 +596,6 @@ int main(int argc, char **argv)
 	if (!node_type_to_print)
 		node_type_to_print = PRINT_ALL;
 
-	if (ibverbose)
-		ibnd_debug(1);
-
 	ibmad_port = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 4);
 	if (!ibmad_port)
 		IBERROR("Failed to open port; %s:%d\n", ibd_ca, ibd_ca_port);
@@ -607,9 +605,6 @@ int main(int argc, char **argv)
 
 	node_name_map = open_node_name_map(node_name_map_file);
 
-	if (outstanding_smps)
-		ibnd_set_max_smps_on_wire(outstanding_smps);
-
 	if (dr_path && load_cache_file) {
 		fprintf(stderr, "Cannot specify cache and direct route path\n");
 		exit(1);
@@ -642,8 +637,8 @@ int main(int argc, char **argv)
 			IBWARN("Single node discover failed;"
 			       " attempting full scan");
 
-		if (!fabric &&
-		    !(fabric = ibnd_discover_fabric(ibmad_port, NULL, -1))) {
+		if (!fabric && !(fabric = ibnd_discover_fabric(ibmad_port, NULL,
+							       &config))) {
 			fprintf(stderr, "discover failed\n");
 			rc = 1;
 			goto close_port;
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v2] libibnetdisc: config struct for ibnd_discover_fabric()
  2010-04-10  1:00             ` [PATCH] libibnetdisc: config struct for ibnd_discover_fabric() Sasha Khapyorsky
@ 2010-04-10  1:41               ` Sasha Khapyorsky
  0 siblings, 0 replies; 15+ messages in thread
From: Sasha Khapyorsky @ 2010-04-10  1:41 UTC (permalink / raw)
  To: Ira Weiny; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Hal Rosenstock


Instead of using static configuration parameters/flags and to have API
functions to set up each one (and so add new API when any new flag is
added) use just single configuration structure which is reenterently
passed by to ibnd_fabric_discover() function.

In order to not change API a lot we will keep some "padding" space in
this configuration structure, so it will be extendable for future
parameters/flags.

Remove old config related functions.

Signed-off-by: Sasha Khapyorsky <sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org>
---
v2 - proper scan.cfg initialization (in ibnd_discover_fabric())

 .../libibnetdisc/include/infiniband/ibnetdisc.h    |   14 ++++--
 infiniband-diags/libibnetdisc/src/ibnetdisc.c      |   48 +++++---------------
 infiniband-diags/libibnetdisc/src/internal.h       |    2 +-
 infiniband-diags/libibnetdisc/src/libibnetdisc.map |    3 -
 infiniband-diags/libibnetdisc/test/testleaks.c     |   23 ++++-----
 infiniband-diags/src/iblinkinfo.c                  |   22 +++------
 infiniband-diags/src/ibnetdiscover.c               |   17 +++-----
 infiniband-diags/src/ibqueryerrors.c               |   17 +++-----
 8 files changed, 52 insertions(+), 94 deletions(-)

diff --git a/infiniband-diags/libibnetdisc/include/infiniband/ibnetdisc.h b/infiniband-diags/libibnetdisc/include/infiniband/ibnetdisc.h
index 8c38c94..136282c 100644
--- a/infiniband-diags/libibnetdisc/include/infiniband/ibnetdisc.h
+++ b/infiniband-diags/libibnetdisc/include/infiniband/ibnetdisc.h
@@ -129,6 +129,14 @@ typedef struct ibnd_chassis {
 
 #define HTSZ 137
 
+typedef struct ibnd_config {
+	unsigned max_smps;
+	unsigned show_progress;
+	unsigned max_hops;
+	unsigned debug;
+	uint8_t pad[64];
+} ibnd_config_t;
+
 /** =========================================================================
  * Fabric
  * Main fabric object which is returned and represents the data discovered
@@ -157,12 +165,10 @@ typedef struct ibnd_fabric {
 /** =========================================================================
  * Initialization (fabric operations)
  */
-MAD_EXPORT void ibnd_debug(int i);
-MAD_EXPORT void ibnd_show_progress(int i);
-MAD_EXPORT int ibnd_set_max_smps_on_wire(int i);
 
 MAD_EXPORT ibnd_fabric_t *ibnd_discover_fabric(struct ibmad_port *ibmad_port,
-					       ib_portid_t * from, int hops);
+					       ib_portid_t * from,
+					       struct ibnd_config *config);
 	/**
 	 * open: (required) ibmad_port object from libibmad
 	 * from: (optional) specify the node to start scanning from.
diff --git a/infiniband-diags/libibnetdisc/src/ibnetdisc.c b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
index 03b678e..0762867 100644
--- a/infiniband-diags/libibnetdisc/src/ibnetdisc.c
+++ b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
@@ -54,10 +54,6 @@
 #include "internal.h"
 #include "chassis.h"
 
-static int show_progress = 0;
-static int max_smps_on_wire = DEFAULT_MAX_SMP_ON_WIRE;
-int ibdebug;
-
 /* forward declare */
 static int query_node_info(smp_engine_t * engine, ib_portid_t * portid,
 			   ibnd_node_t * node);
@@ -96,7 +92,8 @@ static int extend_dpath(smp_engine_t * engine, ib_portid_t * portid,
 	ibnd_scan_t *scan = engine->user_data;
 	ibnd_fabric_t *fabric = scan->fabric;
 
-	if (scan->max_hops && fabric->maxhops_discovered >= scan->max_hops)
+	if (scan->cfg->max_hops &&
+	    fabric->maxhops_discovered >= scan->cfg->max_hops)
 		return 0;
 
 	if (portid->lid) {
@@ -289,7 +286,8 @@ static void dump_endnode(ib_portid_t * path, char *prompt,
 static int recv_node_info(smp_engine_t * engine, ibnd_smp_t * smp,
 			  uint8_t * mad, void *cb_data)
 {
-	ibnd_fabric_t *fabric = ((ibnd_scan_t *) engine->user_data)->fabric;
+	ibnd_scan_t *scan = engine->user_data;
+	ibnd_fabric_t *fabric = scan->fabric;
 	int i = 0;
 	uint8_t *node_info = mad + IB_SMP_DATA_OFFS;
 	ibnd_node_t *rem_node = cb_data;
@@ -319,7 +317,7 @@ static int recv_node_info(smp_engine_t * engine, ibnd_smp_t * smp,
 	}
 	port->guid = port_guid;
 
-	if (show_progress)
+	if (scan->cfg->show_progress)
 		dump_endnode(&smp->path, node_is_new ? "new" : "known",
 			     node, port);
 
@@ -463,16 +461,10 @@ void add_to_type_list(ibnd_node_t * node, ibnd_fabric_t * fabric)
 	}
 }
 
-int ibnd_set_max_smps_on_wire(int i)
-{
-	int rc = max_smps_on_wire;
-	max_smps_on_wire = i;
-	return rc;
-}
-
-ibnd_fabric_t *ibnd_discover_fabric(struct ibmad_port * ibmad_port,
-				    ib_portid_t * from, int hops)
+ibnd_fabric_t *ibnd_discover_fabric(struct ibmad_port *ibmad_port,
+				    ib_portid_t * from, struct ibnd_config *cfg)
 {
+	struct ibnd_config default_config = { 0 };
 	ibnd_fabric_t *fabric = NULL;
 	ib_portid_t my_portid = { 0 };
 	smp_engine_t engine;
@@ -495,10 +487,10 @@ ibnd_fabric_t *ibnd_discover_fabric(struct ibmad_port * ibmad_port,
 
 	memset(&scan.selfportid, 0, sizeof(scan.selfportid));
 	scan.fabric = fabric;
-	if (hops >= 0)
-		scan.max_hops = hops;
+	scan.cfg = cfg ? cfg : &default_config;
 
-	smp_engine_init(&engine, ibmad_port, &scan, max_smps_on_wire);
+	smp_engine_init(&engine, ibmad_port, &scan, cfg->max_smps ?
+			cfg->max_smps : DEFAULT_MAX_SMP_ON_WIRE);
 
 	IBND_DEBUG("from %s\n", portid2str(from));
 
@@ -555,24 +547,6 @@ void ibnd_destroy_fabric(ibnd_fabric_t * fabric)
 	free(fabric);
 }
 
-void ibnd_debug(int i)
-{
-	if (i) {
-		ibdebug++;
-		madrpc_show_errors(1);
-		umad_debug(i);
-	} else {
-		ibdebug = 0;
-		madrpc_show_errors(0);
-		umad_debug(0);
-	}
-}
-
-void ibnd_show_progress(int i)
-{
-	show_progress = i;
-}
-
 void ibnd_iter_nodes(ibnd_fabric_t * fabric, ibnd_iter_node_func_t func,
 		     void *user_data)
 {
diff --git a/infiniband-diags/libibnetdisc/src/internal.h b/infiniband-diags/libibnetdisc/src/internal.h
index d2d4826..57034f9 100644
--- a/infiniband-diags/libibnetdisc/src/internal.h
+++ b/infiniband-diags/libibnetdisc/src/internal.h
@@ -58,7 +58,7 @@
 typedef struct ibnd_scan {
 	ib_portid_t selfportid;
 	ibnd_fabric_t *fabric;
-	unsigned max_hops;
+	struct ibnd_config *cfg;
 } ibnd_scan_t;
 
 typedef struct ibnd_smp ibnd_smp_t;
diff --git a/infiniband-diags/libibnetdisc/src/libibnetdisc.map b/infiniband-diags/libibnetdisc/src/libibnetdisc.map
index 30f7ab9..8a56fbb 100644
--- a/infiniband-diags/libibnetdisc/src/libibnetdisc.map
+++ b/infiniband-diags/libibnetdisc/src/libibnetdisc.map
@@ -1,7 +1,5 @@
 IBNETDISC_1.0 {
 	global:
-		ibnd_debug;
-		ibnd_show_progress;
 		ibnd_discover_fabric;
 		ibnd_destroy_fabric;
 		ibnd_load_fabric;
@@ -16,6 +14,5 @@ IBNETDISC_1.0 {
 		ibnd_get_chassis_slot_str;
 		ibnd_iter_nodes;
 		ibnd_iter_nodes_type;
-		ibnd_set_max_smps_on_wire;
 	local: *;
 };
diff --git a/infiniband-diags/libibnetdisc/test/testleaks.c b/infiniband-diags/libibnetdisc/test/testleaks.c
index cb5651e..da2fc0a 100644
--- a/infiniband-diags/libibnetdisc/test/testleaks.c
+++ b/infiniband-diags/libibnetdisc/test/testleaks.c
@@ -77,6 +77,7 @@ void usage(void)
 
 int main(int argc, char **argv)
 {
+	struct ibnd_config config = { 0 };
 	int rc = 0;
 	char *ca = 0;
 	int ca_port = 0;
@@ -84,7 +85,6 @@ int main(int argc, char **argv)
 	uint64_t guid = 0;
 	char *dr_path = NULL;
 	char *from = NULL;
-	int hops = 0;
 	ib_portid_t port_id;
 	int iters = -1;
 
@@ -118,7 +118,7 @@ int main(int argc, char **argv)
 			break;
 		switch (ch) {
 		case 2:
-			ibnd_debug(1);
+			config.debug++;
 			break;
 		case 'f':
 			from = strdup(optarg);
@@ -133,7 +133,7 @@ int main(int argc, char **argv)
 			dr_path = strdup(optarg);
 			break;
 		case 'n':
-			hops = (int)strtol(optarg, NULL, 0);
+			config.max_hops = strtoul(optarg, NULL, 0);
 			break;
 		case 'i':
 			iters = (int)strtol(optarg, NULL, 0);
@@ -161,21 +161,18 @@ int main(int argc, char **argv)
 			/* only scan part of the fabric */
 			str2drpath(&(port_id.drpath), from, 0, 0);
 			if ((fabric = ibnd_discover_fabric(ibmad_port,
-							   &port_id,
-							   hops)) == NULL) {
+							   &port_id, &config))
+			    == NULL) {
 				fprintf(stderr, "discover failed\n");
 				rc = 1;
 				goto close_port;
 			}
 			guid = 0;
-		} else {
-			if ((fabric =
-			     ibnd_discover_fabric(ibmad_port, NULL,
-						  -1)) == NULL) {
-				fprintf(stderr, "discover failed\n");
-				rc = 1;
-				goto close_port;
-			}
+		} else if ((fabric = ibnd_discover_fabric(ibmad_port, NULL,
+							  &config)) == NULL) {
+			fprintf(stderr, "discover failed\n");
+			rc = 1;
+			goto close_port;
 		}
 
 		ibnd_destroy_fabric(fabric);
diff --git a/infiniband-diags/src/iblinkinfo.c b/infiniband-diags/src/iblinkinfo.c
index 5627dc9..029573f 100644
--- a/infiniband-diags/src/iblinkinfo.c
+++ b/infiniband-diags/src/iblinkinfo.c
@@ -61,13 +61,11 @@ static uint64_t guid = 0;
 static char *guid_str = NULL;
 static char *dr_path = NULL;
 static int all = 0;
-static int hops = 0;
 
 static int down_links_only = 0;
 static int line_mode = 0;
 static int add_sw_settings = 0;
 static int print_port_guids = 0;
-static int outstanding_smps = 0; /* use default from lib */
 
 static unsigned int get_max(unsigned int num)
 {
@@ -242,6 +240,7 @@ void print_switch(ibnd_node_t * node, void *user_data)
 
 static int process_opt(void *context, int ch, char *optarg)
 {
+	struct ibnd_config *cfg = context;
 	switch (ch) {
 	case 1:
 		node_name_map_file = strdup(optarg);
@@ -260,7 +259,7 @@ static int process_opt(void *context, int ch, char *optarg)
 		all = 1;
 		break;
 	case 'n':
-		hops = (int)strtol(optarg, NULL, 0);
+		cfg->max_hops = strtoul(optarg, NULL, 0);
 		break;
 	case 'd':
 		down_links_only = 1;
@@ -277,7 +276,7 @@ static int process_opt(void *context, int ch, char *optarg)
 	case 'R':		/* nop */
 		break;
 	case 'o':
-		outstanding_smps = atoi(optarg);
+		cfg->max_smps = strtoul(optarg, NULL, 0);
 		break;
 	default:
 		return -1;
@@ -288,6 +287,7 @@ static int process_opt(void *context, int ch, char *optarg)
 
 int main(int argc, char **argv)
 {
+	struct ibnd_config config = { 0 };
 	int rc = 0;
 	int resolved = -1;
 	ibnd_fabric_t *fabric = NULL;
@@ -324,15 +324,12 @@ int main(int argc, char **argv)
 	};
 	char usage_args[] = "";
 
-	ibdiag_process_opts(argc, argv, NULL, "SDandlpgRGL", opts, process_opt,
-			    usage_args, NULL);
+	ibdiag_process_opts(argc, argv, &config, "SDandlpgRGL", opts,
+			    process_opt, usage_args, NULL);
 
 	argc -= optind;
 	argv += optind;
 
-	if (ibverbose)
-		ibnd_debug(1);
-
 	ibmad_port = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 3);
 	if (!ibmad_port) {
 		fprintf(stderr, "Failed to open %s port %d", ibd_ca,
@@ -345,9 +342,6 @@ int main(int argc, char **argv)
 
 	node_name_map = open_node_name_map(node_name_map_file);
 
-	if (outstanding_smps)
-		ibnd_set_max_smps_on_wire(outstanding_smps);
-
 	if (dr_path && load_cache_file) {
 		fprintf(stderr, "Cannot specify cache and direct route path\n");
 		exit(1);
@@ -377,12 +371,12 @@ int main(int argc, char **argv)
 	} else {
 		if (resolved >= 0 &&
 		    !(fabric =
-		      ibnd_discover_fabric(ibmad_port, &port_id, hops)))
+		      ibnd_discover_fabric(ibmad_port, &port_id, &config)))
 			IBWARN("Single node discover failed;"
 			       " attempting full scan\n");
 
 		if (!fabric &&
-		    !(fabric = ibnd_discover_fabric(ibmad_port, NULL, -1))) {
+		    !(fabric = ibnd_discover_fabric(ibmad_port, NULL, &config))) {
 			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 32776ad..f40d0f9 100644
--- a/infiniband-diags/src/ibnetdiscover.c
+++ b/infiniband-diags/src/ibnetdiscover.c
@@ -67,7 +67,6 @@ static char *cache_file = NULL;
 static char *load_cache_file = NULL;
 
 static int report_max_hops = 0;
-static int outstanding_smps = 0; /* use default from lib */
 
 /**
  * Define our own conversion functions to maintain compatibility with the old
@@ -616,6 +615,7 @@ static int list, group, ports_report;
 
 static int process_opt(void *context, int ch, char *optarg)
 {
+	struct ibnd_config *cfg = context;
 	switch (ch) {
 	case 1:
 		node_name_map_file = strdup(optarg);
@@ -627,7 +627,7 @@ static int process_opt(void *context, int ch, char *optarg)
 		load_cache_file = strdup(optarg);
 		break;
 	case 's':
-		ibnd_show_progress(1);
+		cfg->show_progress = 1;
 		break;
 	case 'l':
 		list = LIST_CA_NODE | LIST_SWITCH_NODE | LIST_ROUTER_NODE;
@@ -651,7 +651,7 @@ static int process_opt(void *context, int ch, char *optarg)
 		report_max_hops = 1;
 		break;
 	case 'o':
-		outstanding_smps = atoi(optarg);
+		cfg->max_smps = strtoul(optarg, NULL, 0);
 		break;
 	default:
 		return -1;
@@ -662,6 +662,7 @@ static int process_opt(void *context, int ch, char *optarg)
 
 int main(int argc, char **argv)
 {
+	struct ibnd_config config = { 0 };
 	ibnd_fabric_t *fabric = NULL;
 
 	struct ibmad_port *ibmad_port;
@@ -689,7 +690,7 @@ int main(int argc, char **argv)
 	};
 	char usage_args[] = "[topology-file]";
 
-	ibdiag_process_opts(argc, argv, NULL, "sGDL", opts, process_opt,
+	ibdiag_process_opts(argc, argv, &config, "sGDL", opts, process_opt,
 			    usage_args, NULL);
 
 	f = stdout;
@@ -697,9 +698,6 @@ int main(int argc, char **argv)
 	argc -= optind;
 	argv += optind;
 
-	if (ibverbose)
-		ibnd_debug(1);
-
 	ibmad_port = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 2);
 	if (!ibmad_port)
 		IBERROR("Failed to open %s port %d", ibd_ca, ibd_ca_port);
@@ -712,15 +710,12 @@ int main(int argc, char **argv)
 
 	node_name_map = open_node_name_map(node_name_map_file);
 
-	if (outstanding_smps)
-		ibnd_set_max_smps_on_wire(outstanding_smps);
-
 	if (load_cache_file) {
 		if ((fabric = ibnd_load_fabric(load_cache_file, 0)) == NULL)
 			IBERROR("loading cached fabric failed\n");
 	} else {
 		if ((fabric =
-		     ibnd_discover_fabric(ibmad_port, NULL, -1)) == NULL)
+		     ibnd_discover_fabric(ibmad_port, NULL, &config)) == NULL)
 			IBERROR("discover failed\n");
 	}
 
diff --git a/infiniband-diags/src/ibqueryerrors.c b/infiniband-diags/src/ibqueryerrors.c
index 725e098..e896254 100644
--- a/infiniband-diags/src/ibqueryerrors.c
+++ b/infiniband-diags/src/ibqueryerrors.c
@@ -70,7 +70,6 @@ enum MAD_FIELDS suppressed_fields[SUP_MAX];
 char *dr_path = NULL;
 uint8_t node_type_to_print = 0;
 unsigned clear_errors = 0, clear_counts = 0, details = 0;
-static int outstanding_smps = 0; /* use default from lib */
 
 #define PRINT_SWITCH 0x1
 #define PRINT_CA     0x2
@@ -483,6 +482,7 @@ static void calculate_suppressed_fields(char *str)
 
 static int process_opt(void *context, int ch, char *optarg)
 {
+	struct ibnd_config *cfg = context;
 	switch (ch) {
 	case 's':
 		calculate_suppressed_fields(optarg);
@@ -532,7 +532,7 @@ static int process_opt(void *context, int ch, char *optarg)
 		clear_counts = 1;
 		break;
 	case 'o':
-		outstanding_smps = atoi(optarg);
+		cfg->max_smps = strtoul(optarg, NULL, 0);
 		break;
 	default:
 		return -1;
@@ -543,6 +543,7 @@ static int process_opt(void *context, int ch, char *optarg)
 
 int main(int argc, char **argv)
 {
+	struct ibnd_config config = { 0 };
 	int resolved = -1;
 	ib_portid_t portid = { 0 };
 	int rc = 0;
@@ -586,7 +587,7 @@ int main(int argc, char **argv)
 	char usage_args[] = "";
 
 	memset(suppressed_fields, 0, sizeof suppressed_fields);
-	ibdiag_process_opts(argc, argv, NULL, "scnSrRDGL", opts, process_opt,
+	ibdiag_process_opts(argc, argv, &config, "scnSrRDGL", opts, process_opt,
 			    usage_args, NULL);
 
 	argc -= optind;
@@ -595,9 +596,6 @@ int main(int argc, char **argv)
 	if (!node_type_to_print)
 		node_type_to_print = PRINT_ALL;
 
-	if (ibverbose)
-		ibnd_debug(1);
-
 	ibmad_port = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 4);
 	if (!ibmad_port)
 		IBERROR("Failed to open port; %s:%d\n", ibd_ca, ibd_ca_port);
@@ -607,9 +605,6 @@ int main(int argc, char **argv)
 
 	node_name_map = open_node_name_map(node_name_map_file);
 
-	if (outstanding_smps)
-		ibnd_set_max_smps_on_wire(outstanding_smps);
-
 	if (dr_path && load_cache_file) {
 		fprintf(stderr, "Cannot specify cache and direct route path\n");
 		exit(1);
@@ -642,8 +637,8 @@ int main(int argc, char **argv)
 			IBWARN("Single node discover failed;"
 			       " attempting full scan");
 
-		if (!fabric &&
-		    !(fabric = ibnd_discover_fabric(ibmad_port, NULL, -1))) {
+		if (!fabric && !(fabric = ibnd_discover_fabric(ibmad_port, NULL,
+							       &config))) {
 			fprintf(stderr, "discover failed\n");
 			rc = 1;
 			goto close_port;
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH] libibmad: add explicit extern for ibdebug prototype
       [not found] ` <20100218124931.4d6ef34b.weiny2-i2BcT+NCU+M@public.gmane.org>
                     ` (2 preceding siblings ...)
  2010-04-10  0:52   ` [PATCH v3 0/2] Using multi-smps on the wire in libibnetdisc Sasha Khapyorsky
@ 2010-04-10 13:18   ` Sasha Khapyorsky
  3 siblings, 0 replies; 15+ messages in thread
From: Sasha Khapyorsky @ 2010-04-10 13:18 UTC (permalink / raw)
  To: Ira Weiny; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Hal Rosenstock


'ibdebug' variable was not declared as 'extern', as result includers
(libraries and programs) may have its own copy of this variable. As
example libibnetdisc and ibnetdiscover.

Signed-off-by: Sasha Khapyorsky <sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org>
---
 libibmad/include/infiniband/mad.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libibmad/include/infiniband/mad.h b/libibmad/include/infiniband/mad.h
index 02ef551..0687c06 100644
--- a/libibmad/include/infiniband/mad.h
+++ b/libibmad/include/infiniband/mad.h
@@ -1031,7 +1031,7 @@ MAD_EXPORT ib_mad_dump_fn
     mad_dump_perfcounters_xmt_disc, mad_dump_perfcounters_rcv_err,
     mad_dump_portsamples_control;
 
-MAD_EXPORT int ibdebug;
+MAD_EXPORT extern int ibdebug;
 
 #if __BYTE_ORDER == __LITTLE_ENDIAN
 #ifndef ntohll
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH] libibnetdisc: add \n at end of error messages
  2010-04-10  0:52   ` [PATCH v3 0/2] Using multi-smps on the wire in libibnetdisc Sasha Khapyorsky
  2010-04-10  0:55     ` [PATCH] libibnetdisc: code cleanups Sasha Khapyorsky
@ 2010-04-13 14:56     ` Sasha Khapyorsky
  1 sibling, 0 replies; 15+ messages in thread
From: Sasha Khapyorsky @ 2010-04-13 14:56 UTC (permalink / raw)
  To: Ira Weiny; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Hal Rosenstock


Add '\n' new line character at end of error messages printouts.

Signed-off-by: Sasha Khapyorsky <sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org>
---
 infiniband-diags/libibnetdisc/src/chassis.c   |    6 +++---
 infiniband-diags/libibnetdisc/src/query_smp.c |    6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/infiniband-diags/libibnetdisc/src/chassis.c b/infiniband-diags/libibnetdisc/src/chassis.c
index 1a839d9..80e034b 100644
--- a/infiniband-diags/libibnetdisc/src/chassis.c
+++ b/infiniband-diags/libibnetdisc/src/chassis.c
@@ -378,7 +378,7 @@ static int get_sfb_slot(ibnd_node_t * n, ibnd_port_t * lineport)
 		n->ch_slotnum = spine4_slot_2_slb[lineport->portnum];
 		n->ch_anafanum = anafa_spine4_slot_2_slb[lineport->portnum];
 	} else {
-		IBND_ERROR("Unexpected node found: guid 0x%016" PRIx64,
+		IBND_ERROR("Unexpected node found: guid 0x%016" PRIx64 "\n",
 			   n->guid);
 		return -1;
 	}
@@ -419,7 +419,7 @@ static int get_router_slot(ibnd_node_t * n, ibnd_port_t * spineport)
 		n->ch_slotnum = line_slot_2_sfb4[spineport->portnum];
 		n->ch_anafanum = ipr_slot_2_sfb4_port[spineport->portnum];
 	} else {
-		IBND_ERROR("Unexpected node found: guid 0x%016" PRIx64,
+		IBND_ERROR("Unexpected node found: guid 0x%016" PRIx64 "\n",
 			   spineport->node->guid);
 		return -1;
 	}
@@ -446,7 +446,7 @@ static int get_slb_slot(ibnd_node_t * n, ibnd_port_t * spineport)
 		n->ch_slotnum = line_slot_2_sfb4[spineport->portnum];
 		n->ch_anafanum = anafa_line_slot_2_sfb4[spineport->portnum];
 	} else {
-		IBND_ERROR("Unexpected node found: guid 0x%016" PRIx64,
+		IBND_ERROR("Unexpected node found: guid 0x%016" PRIx64 "\n",
 			   spineport->node->guid);
 		return -1;
 	}
diff --git a/infiniband-diags/libibnetdisc/src/query_smp.c b/infiniband-diags/libibnetdisc/src/query_smp.c
index 1ec9752..b4322bc 100644
--- a/infiniband-diags/libibnetdisc/src/query_smp.c
+++ b/infiniband-diags/libibnetdisc/src/query_smp.c
@@ -71,7 +71,7 @@ static int send_smp(ibnd_smp_t * smp, struct ibmad_port *srcport)
 
 	if ((rc = mad_build_pkt(umad, &smp->rpc, &smp->path, NULL, NULL))
 	    < 0) {
-		IBND_ERROR("mad_build_pkt failed; %d", rc);
+		IBND_ERROR("mad_build_pkt failed; %d\n", rc);
 		return rc;
 	}
 
@@ -80,7 +80,7 @@ static int send_smp(ibnd_smp_t * smp, struct ibmad_port *srcport)
 			    umad, IB_MAD_SIZE,
 			    mad_get_timeout(srcport, rpc->timeout),
 			    mad_get_retries(srcport))) < 0) {
-		IBND_ERROR("send failed; %d", rc);
+		IBND_ERROR("send failed; %d\n", rc);
 		return rc;
 	}
 
@@ -109,7 +109,7 @@ int issue_smp(smp_engine_t * engine, ib_portid_t * portid,
 {
 	ibnd_smp_t *smp = calloc(1, sizeof *smp);
 	if (!smp) {
-		IBND_ERROR("OOM");
+		IBND_ERROR("OOM\n");
 		return -ENOMEM;
 	}
 
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2010-04-13 14:56 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-18 20:49 [PATCH v3 0/2] Using multi-smps on the wire in libibnetdisc Ira Weiny
     [not found] ` <20100218124931.4d6ef34b.weiny2-i2BcT+NCU+M@public.gmane.org>
2010-04-03  0:23   ` Ira Weiny
     [not found]     ` <20100402172330.819b8ef6.weiny2-i2BcT+NCU+M@public.gmane.org>
2010-04-09 23:21       ` Sasha Khapyorsky
2010-04-09 23:56   ` [PATCH] tests/subnet_discover: verbose node discovery printout Sasha Khapyorsky
2010-04-10  0:52   ` [PATCH v3 0/2] Using multi-smps on the wire in libibnetdisc Sasha Khapyorsky
2010-04-10  0:55     ` [PATCH] libibnetdisc: code cleanups Sasha Khapyorsky
2010-04-10  0:56       ` [PATCH] libibnetdisc: restore show_progress functionality Sasha Khapyorsky
2010-04-10  0:57       ` [PATCH] libibnetdisc: restore hops limited discovery Sasha Khapyorsky
2010-04-10  0:57       ` [PATCH] libibnetdisc: keep total number of used SMPs Sasha Khapyorsky
2010-04-10  0:58         ` [PATCH] infiniband-diags/ibnetdiscover: report number of used MADs Sasha Khapyorsky
2010-04-10  0:58           ` [PATCH] libibnetdisc: no backward NodeInfo queries Sasha Khapyorsky
2010-04-10  1:00             ` [PATCH] libibnetdisc: config struct for ibnd_discover_fabric() Sasha Khapyorsky
2010-04-10  1:41               ` [PATCH v2] " Sasha Khapyorsky
2010-04-13 14:56     ` [PATCH] libibnetdisc: add \n at end of error messages Sasha Khapyorsky
2010-04-10 13:18   ` [PATCH] libibmad: add explicit extern for ibdebug prototype Sasha Khapyorsky

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.