Skip to contentSkip to conversation

Using multi-smps on the wire in libibnetdisc

PATCH Applied Ira Weiny 2 participants 15 messages Feb 18, 2010 – Apr 13, 2010 2 messages not in the archive InfiniBand

lore
Share & tools
lore

Ira Weiny

author
#0 lore raw

v3 cover Using multi-smps on the wire in libibnetdisc

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 [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#2 lore raw

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

Quoted 5 lines · On Thu, 18 Feb 2010 12:49:31 -0800 Ira Weiny…

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

Signature · 9 lines
Ira Weiny
Math Programmer/Computer Scientist
Lawrence Livermore National Lab
925-423-8008
[email protected]
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw

PATCH 1/1 tests/subnet_discover: verbose node discovery printout

In reply to a message not in the archive

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

---
 tests/subnet_discover.c |   25 ++++++++++++++++---------
 1 files changed, 16 insertions(+), 9 deletions(-)
tests/subnet_discover.c +16 -9
index 22b092a..44cd86e 100644
@@ -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:
Signature · 6 lines
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#6 lore raw
In reply to a message not in the archive
Quoted 1 line · Ira Weiny

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.

Quoted 1 line

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 [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw

PATCH 1/1 libibnetdisc: code cleanups

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

Fix indentations using osm_indent script.

---
 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(-)
infiniband-diags/libibnetdisc/src/chassis.c +1 -1
index c8f6b6c..1a839d9 100644
@@ -38,7 +38,7 @@
 /*========================================================*/
 
 #if HAVE_CONFIG_H
-#  include <config.h>
+#include <config.h>
 #endif				/* HAVE_CONFIG_H */
 
 #include <stdlib.h>
infiniband-diags/libibnetdisc/src/ibnetdisc.c +67 -83

325 lines not on this page · raw message

infiniband-diags/libibnetdisc/src/ibnetdisc_cache.c +4 -5
index d94b85a..26157d7 100644
@@ -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");
infiniband-diags/libibnetdisc/src/internal.h +11 -12
index 61b644d..179eac6 100644
@@ -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[]);
 
infiniband-diags/libibnetdisc/src/query_smp.c +30 -38

167 lines not on this page · raw message

Signature · 6 lines
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#8 lore raw

PATCH 1/1 libibnetdisc: restore show_progress functionality

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

---
 infiniband-diags/libibnetdisc/src/ibnetdisc.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
infiniband-diags/libibnetdisc/src/ibnetdisc.c +16 -0
index 4780810..b438d4f 100644
@@ -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 {
Signature · 6 lines
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#9 lore raw

PATCH 1/1 libibnetdisc: restore hops limited discovery

In reply to Sasha Khapyorsky

Restore hops limited discovery.

---
 infiniband-diags/libibnetdisc/src/ibnetdisc.c |   12 ++++++------
 infiniband-diags/libibnetdisc/src/internal.h  |    1 +
 2 files changed, 7 insertions(+), 6 deletions(-)
infiniband-diags/libibnetdisc/src/ibnetdisc.c +6 -6
index b438d4f..4012eff 100644
@@ -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);
 
infiniband-diags/libibnetdisc/src/internal.h +1 -0
index 179eac6..05e254d 100644
@@ -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;
Signature · 6 lines
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#10 lore raw

PATCH 1/1 libibnetdisc: keep total number of used SMPs

In reply to Sasha Khapyorsky

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).

---
 .../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(-)
infiniband-diags/libibnetdisc/include/infiniband/ibnetdisc.h +2 -1
index 556014e..8c38c94 100644
@@ -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];
infiniband-diags/libibnetdisc/src/ibnetdisc.c +2 -0
index 4012eff..65126dd 100644
@@ -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;
 
infiniband-diags/libibnetdisc/src/internal.h +1 -0
index 05e254d..d2d4826 100644
@@ -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,
infiniband-diags/libibnetdisc/src/query_smp.c +1 -0
index a6878b6..1ec9752 100644
@@ -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);
Signature · 6 lines
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#11 lore raw

PATCH 1/1 infiniband-diags/ibnetdiscover: report number of used MADs

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

---
 infiniband-diags/src/ibnetdiscover.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
infiniband-diags/src/ibnetdiscover.c +3 -2
index 1ff8ef6..32776ad 100644
@@ -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,
Signature · 6 lines
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#12 lore raw

PATCH 1/1 libibnetdisc: no backward NodeInfo queries

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.

---
 infiniband-diags/libibnetdisc/src/ibnetdisc.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
infiniband-diags/libibnetdisc/src/ibnetdisc.c +2 -1
index 65126dd..03b678e 100644
@@ -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);
Signature · 6 lines
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#13 lore raw

PATCH 1/1 libibnetdisc: config struct for ibnd_discover_fabric()

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.

---
 .../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(-)
infiniband-diags/libibnetdisc/include/infiniband/ibnetdisc.h +10 -4
index 8c38c94..136282c 100644
@@ -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.
infiniband-diags/libibnetdisc/src/ibnetdisc.c +12 -37

93 lines not on this page · raw message

infiniband-diags/libibnetdisc/src/internal.h +1 -1
index d2d4826..57034f9 100644
@@ -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;
infiniband-diags/libibnetdisc/src/libibnetdisc.map +0 -3
index 30f7ab9..8a56fbb 100644
@@ -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: *;
 };
infiniband-diags/libibnetdisc/test/testleaks.c +10 -13
index cb5651e..da2fc0a 100644
@@ -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);
infiniband-diags/src/iblinkinfo.c +8 -14
index 5627dc9..029573f 100644
@@ -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;
infiniband-diags/src/ibnetdiscover.c +6 -11
index 32776ad..f40d0f9 100644
@@ -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");
 	}
 
infiniband-diags/src/ibqueryerrors.c +6 -11
index 725e098..e896254 100644
@@ -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;
Signature · 6 lines
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#14 lore raw

PATCH v2 1/1 libibnetdisc: config struct for ibnd_discover_fabric()

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.

---
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(-)
infiniband-diags/libibnetdisc/include/infiniband/ibnetdisc.h +10 -4
index 8c38c94..136282c 100644
@@ -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.
infiniband-diags/libibnetdisc/src/ibnetdisc.c +11 -37

92 lines not on this page · raw message

infiniband-diags/libibnetdisc/src/internal.h +1 -1
index d2d4826..57034f9 100644
@@ -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;
infiniband-diags/libibnetdisc/src/libibnetdisc.map +0 -3
index 30f7ab9..8a56fbb 100644
@@ -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: *;
 };
infiniband-diags/libibnetdisc/test/testleaks.c +10 -13
index cb5651e..da2fc0a 100644
@@ -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);
infiniband-diags/src/iblinkinfo.c +8 -14
index 5627dc9..029573f 100644
@@ -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;
infiniband-diags/src/ibnetdiscover.c +6 -11
index 32776ad..f40d0f9 100644
@@ -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");
 	}
 
infiniband-diags/src/ibqueryerrors.c +6 -11
index 725e098..e896254 100644
@@ -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;
Signature · 6 lines
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#15 lore raw

PATCH 1/1 libibnetdisc: add \n at end of error messages

In reply to Sasha Khapyorsky

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

---
 infiniband-diags/libibnetdisc/src/chassis.c   |    6 +++---
 infiniband-diags/libibnetdisc/src/query_smp.c |    6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)
infiniband-diags/libibnetdisc/src/chassis.c +3 -3
index 1a839d9..80e034b 100644
@@ -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;
 	}
infiniband-diags/libibnetdisc/src/query_smp.c +3 -3
index 1ec9752..b4322bc 100644
@@ -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;
 	}
 
Signature · 6 lines
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#16 lore raw

PATCH 1/1 libibmad: add explicit extern for ibdebug prototype

In reply to a message not in the archive

'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.

---
 libibmad/include/infiniband/mad.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
libibmad/include/infiniband/mad.h +1 -1
index 02ef551..0687c06 100644
@@ -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
Signature · 6 lines
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html