All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] infiniband-diags/ibroute.c: Dead code removal
@ 2012-04-13  1:09 Jim Foraker
       [not found] ` <1334279385-10792-1-git-send-email-foraker1-i2BcT+NCU+M@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Jim Foraker @ 2012-04-13  1:09 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA; +Cc: Jim Foraker

Program has already exited in the case where argc == 0

Signed-off-by: Jim Foraker <foraker1-i2BcT+NCU+M@public.gmane.org>
---
 src/ibroute.c |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/ibroute.c b/src/ibroute.c
index 7339218..1bf1fb0 100644
--- a/src/ibroute.c
+++ b/src/ibroute.c
@@ -432,10 +432,7 @@ int main(int argc, char **argv)
 	if (!srcport)
 		IBERROR("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
 
-	if (!argc) {
-		if (ib_resolve_self_via(&portid, 0, 0, srcport) < 0)
-			IBERROR("can't resolve self addr");
-	} else if (ib_resolve_portid_str_via(&portid, argv[0], ibd_dest_type,
+	if (ib_resolve_portid_str_via(&portid, argv[0], ibd_dest_type,
 					     ibd_sm_id, srcport) < 0)
 		IBERROR("can't resolve destination port %s", argv[1]);
 
-- 
1.7.9.2

--
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] 10+ messages in thread

* [PATCH 2/5] infiniband-diags/mcm_rereg_test.c: dead code removal
       [not found] ` <1334279385-10792-1-git-send-email-foraker1-i2BcT+NCU+M@public.gmane.org>
@ 2012-04-13  1:09   ` Jim Foraker
       [not found]     ` <1334279385-10792-2-git-send-email-foraker1-i2BcT+NCU+M@public.gmane.org>
  2012-04-13  1:09   ` [PATCH 3/5] infiniband-diags/mcm_rereg_test.c: Include ib_types.h Jim Foraker
                     ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Jim Foraker @ 2012-04-13  1:09 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA; +Cc: Jim Foraker

Remove old #if 0'd code

Signed-off-by: Jim Foraker <foraker1-i2BcT+NCU+M@public.gmane.org>
---
 src/mcm_rereg_test.c |   86 --------------------------------------------------
 1 file changed, 86 deletions(-)

diff --git a/src/mcm_rereg_test.c b/src/mcm_rereg_test.c
index a764d02..55b8add 100644
--- a/src/mcm_rereg_test.c
+++ b/src/mcm_rereg_test.c
@@ -195,34 +195,6 @@ static int rereg_send_all(int port, int agent, ib_portid_t * dport,
 	return 0;
 }
 
-#if 0
-static int rereg_mcm_rec_send(int port, int agent, ib_portid_t * dport, int cnt)
-{
-	ib_portid_t portid;
-	ibmad_gid_t port_gid;
-	uint8_t *umad;
-	int len, ret = 0;
-
-	ib_resolve_self(&portid, NULL, &port_gid);
-
-	len = umad_size() + 256;
-	umad = calloc(1, len);
-	if (!umad) {
-		err("cannot alloc mem for umad: %s\n", strerror(errno));
-		return -1;
-	}
-
-	while (cnt--) {
-		if (!rereg_port_gid(port, agent, dport, umad, len, port_gid))
-			ret += 2;
-	}
-
-	free(umad);
-
-	return ret;
-}
-#endif
-
 static int rereg_recv(int port, int agent, ib_portid_t * dport,
 		      uint8_t * umad, int length, int tmo)
 {
@@ -350,42 +322,6 @@ static int rereg_query_all(int port, int agent, ib_portid_t * dport,
 	return 0;
 }
 
-#if 0
-static int rereg_mcm_rec_recv(int port, int agent, int cnt)
-{
-	uint8_t *umad, *mad;
-	int len = umad_size() + 256;
-	int i;
-
-	umad = calloc(1, len);
-	if (!umad) {
-		err("cannot alloc mem for umad: %s\n", strerror(errno));
-		return -1;
-	}
-
-	for (i = 0; i < cnt; i++) {
-		int retry;
-		retry = 0;
-		while (umad_recv(port, umad, &len, TMO) < 0 &&
-		       errno == ETIMEDOUT)
-			if (retry++ > 3) {
-				err("umad_recv %d failed: %s\n",
-				    i, strerror(errno));
-				free(umad);
-				return -1;
-			}
-		dbg("umad_recv %d (retries %d), tid = 0x%016" PRIx64
-		    ": len = %d, status = %d\n", i, retry,
-		    mad_get_field64(umad_get_mad(umad), 0, IB_MAD_TRID_F), len,
-		    umad_status(umad));
-		mad = umad_get_mad(umad);
-	}
-
-	free(umad);
-	return 0;
-}
-#endif
-
 #define MAX_CLIENTS 50
 
 static int rereg_and_test_port(char *guid_file, int port, int agent,
@@ -451,12 +387,7 @@ int main(int argc, char **argv)
 	if (!srcport)
 		err("Failed to open port");
 
-#if 1
 	ib_resolve_smlid_via(&dport_id, TMO, srcport);
-#else
-	memset(&dport_id, 0, sizeof(dport_id));
-	dport_id.lid = 1;
-#endif
 	dport_id.qp = 1;
 	if (!dport_id.qkey)
 		dport_id.qkey = IB_DEFAULT_QP1_QKEY;
@@ -467,28 +398,11 @@ int main(int argc, char **argv)
 		err("cannot alloc mem for umad: %s\n", strerror(errno));
 		return -1;
 	}
-#if 1
 	port = mad_rpc_portid(srcport);
-#else
-	ret = umad_init();
-
-	port = umad_open_port(NULL, 0);
-	if (port < 0) {
-		err("umad_open_port failed: %s\n", strerror(errno));
-		return port;
-	}
-#endif
 
 	agent = umad_register(port, IB_SA_CLASS, 2, 0, NULL);
 
-#if 0
-	int cnt;
-	cnt = rereg_mcm_rec_send(port, agent, &dport_id, cnt);
-
-	rereg_recv_all(port, agent, &dport_id);
-#else
 	rereg_and_test_port(guid_file, port, agent, &dport_id, TMO);
-#endif
 	mad = umad_get_mad(umad);
 
 	free(umad);
-- 
1.7.9.2

--
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] 10+ messages in thread

* [PATCH 3/5] infiniband-diags/mcm_rereg_test.c: Include ib_types.h
       [not found] ` <1334279385-10792-1-git-send-email-foraker1-i2BcT+NCU+M@public.gmane.org>
  2012-04-13  1:09   ` [PATCH 2/5] infiniband-diags/mcm_rereg_test.c: dead " Jim Foraker
@ 2012-04-13  1:09   ` Jim Foraker
       [not found]     ` <1334279385-10792-3-git-send-email-foraker1-i2BcT+NCU+M@public.gmane.org>
  2012-04-13  1:09   ` [PATCH 4/5] infiniband-diags: Remove dependencies on ib_resolve_smlid/ib_resolve_self Jim Foraker
                     ` (2 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Jim Foraker @ 2012-04-13  1:09 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA; +Cc: Jim Foraker

Remove IB_MCM_COMPMASK defines, which should be pulled from
ib_types.h instead.  This is necessary in order to allow future
inclusion of ibdiag_common.h.

Signed-off-by: Jim Foraker <foraker1-i2BcT+NCU+M@public.gmane.org>
---
 src/mcm_rereg_test.c |   21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)

diff --git a/src/mcm_rereg_test.c b/src/mcm_rereg_test.c
index 55b8add..60ec421 100644
--- a/src/mcm_rereg_test.c
+++ b/src/mcm_rereg_test.c
@@ -42,6 +42,7 @@
 
 #include <infiniband/umad.h>
 #include <infiniband/mad.h>
+#include <infiniband/iba/ib_types.h>
 
 #define info(fmt, ...) fprintf(stderr, "INFO: " fmt, ## __VA_ARGS__ )
 #define err(fmt, ...) fprintf(stderr, "ERR: " fmt, ## __VA_ARGS__ )
@@ -53,26 +54,6 @@
 
 #define TMO 100
 
-/* Multicast Member Record Component Masks */
-#define IB_MCR_COMPMASK_MGID        (1ULL<<0)
-#define IB_MCR_COMPMASK_PORT_GID    (1ULL<<1)
-#define IB_MCR_COMPMASK_QKEY        (1ULL<<2)
-#define IB_MCR_COMPMASK_MLID        (1ULL<<3)
-#define IB_MCR_COMPMASK_MTU_SEL     (1ULL<<4)
-#define IB_MCR_COMPMASK_MTU         (1ULL<<5)
-#define IB_MCR_COMPMASK_TCLASS      (1ULL<<6)
-#define IB_MCR_COMPMASK_PKEY        (1ULL<<7)
-#define IB_MCR_COMPMASK_RATE_SEL    (1ULL<<8)
-#define IB_MCR_COMPMASK_RATE        (1ULL<<9)
-#define IB_MCR_COMPMASK_LIFE_SEL    (1ULL<<10)
-#define IB_MCR_COMPMASK_LIFE        (1ULL<<11)
-#define IB_MCR_COMPMASK_SL          (1ULL<<12)
-#define IB_MCR_COMPMASK_FLOW        (1ULL<<13)
-#define IB_MCR_COMPMASK_HOP         (1ULL<<14)
-#define IB_MCR_COMPMASK_SCOPE       (1ULL<<15)
-#define IB_MCR_COMPMASK_JOIN_STATE  (1ULL<<16)
-#define IB_MCR_COMPMASK_PROXY       (1ULL<<17)
-
 static ibmad_gid_t mgid_ipoib = {
 	0xff, 0x12, 0x40, 0x1b, 0xff, 0xff, 0x00, 0x00,
 	0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
-- 
1.7.9.2

--
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] 10+ messages in thread

* [PATCH 4/5] infiniband-diags: Remove dependencies on ib_resolve_smlid/ib_resolve_self
       [not found] ` <1334279385-10792-1-git-send-email-foraker1-i2BcT+NCU+M@public.gmane.org>
  2012-04-13  1:09   ` [PATCH 2/5] infiniband-diags/mcm_rereg_test.c: dead " Jim Foraker
  2012-04-13  1:09   ` [PATCH 3/5] infiniband-diags/mcm_rereg_test.c: Include ib_types.h Jim Foraker
@ 2012-04-13  1:09   ` Jim Foraker
       [not found]     ` <1334279385-10792-4-git-send-email-foraker1-i2BcT+NCU+M@public.gmane.org>
  2012-04-13  1:09   ` [PATCH 5/5] infiniband-diags: migrate resolve_portid_str in from libibmad Jim Foraker
  2012-04-14  1:38   ` [PATCH 1/5] infiniband-diags/ibroute.c: Dead code removal Ira Weiny
  4 siblings, 1 reply; 10+ messages in thread
From: Jim Foraker @ 2012-04-13  1:09 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA; +Cc: Jim Foraker

ib_resolve_smlid() and ib_resolve_self() issue SMP queries to the local
interface for data that can be acquired thru other means.
resolve_sm_portid() (originally defined in 3179ae8c and made public here)
and the new function resolve_self() replace these functions, pulling
information from the umad layer instead.

Signed-off-by: Jim Foraker <foraker1-i2BcT+NCU+M@public.gmane.org>
---
 include/ibdiag_common.h |    3 +++
 src/ibaddr.c            |    2 +-
 src/ibdiag_common.c     |   37 +++++++++++++++++++++++++++++++++++++
 src/ibportstate.c       |    4 ++--
 src/ibsendtrap.c        |    4 ++--
 src/mcm_rereg_test.c    |    4 +++-
 src/perfquery.c         |    2 +-
 src/sminfo.c            |    2 +-
 src/vendstat.c          |    2 +-
 9 files changed, 51 insertions(+), 9 deletions(-)

diff --git a/include/ibdiag_common.h b/include/ibdiag_common.h
index 0131193..4388834 100644
--- a/include/ibdiag_common.h
+++ b/include/ibdiag_common.h
@@ -144,4 +144,7 @@ void sa_report_err(int status);
 void get_max_msg(char *width_msg, char *speed_msg, int msg_size,
 		 ibnd_port_t * port);
 
+int resolve_sm_portid(char *ca_name, uint8_t portnum, ib_portid_t *sm_id);
+int resolve_self(char *ca_name, uint8_t ca_port, ib_portid_t *portid,
+                 int *port, ibmad_gid_t *gid);
 #endif				/* _IBDIAG_COMMON_H_ */
diff --git a/src/ibaddr.c b/src/ibaddr.c
index 397ef77..10dfae8 100644
--- a/src/ibaddr.c
+++ b/src/ibaddr.c
@@ -154,7 +154,7 @@ int main(int argc, char **argv)
 					      ibd_sm_id, srcport) < 0)
 			IBERROR("can't resolve destination port %s", argv[0]);
 	} else {
-		if (ib_resolve_self_via(&portid, &port, 0, srcport) < 0)
+		if (resolve_self(ibd_ca, ibd_ca_port, &portid, &port, NULL) < 0)
 			IBERROR("can't resolve self port %s", argv[0]);
 	}
 
diff --git a/src/ibdiag_common.c b/src/ibdiag_common.c
index b22ed60..6605362 100644
--- a/src/ibdiag_common.c
+++ b/src/ibdiag_common.c
@@ -507,6 +507,43 @@ int resolve_sm_portid(char *ca_name, uint8_t portnum, ib_portid_t *sm_id)
 	return 0;
 }
 
+/** =========================================================================
+ * Resolve local CA characteristics using the umad layer rather than using
+ * ib_resolve_self_via which requires SMP queries on the local port.
+ */
+int resolve_self(char *ca_name, uint8_t ca_port, ib_portid_t *portid,
+		 int *portnum, ibmad_gid_t *gid)
+{
+	umad_port_t port;
+	uint64_t prefix, guid;
+	int rc;
+
+	if (!(portid || portnum || gid))
+		return (-1);
+
+	if ((rc = umad_get_port(ca_name, ca_port, &port)) < 0)
+		return rc;
+
+	if (portid) {
+		memset(portid, 0, sizeof(*portid));
+		portid->lid = port.base_lid;
+		portid->sl = port.sm_sl;
+	}
+	if (portnum)
+		*portnum = port.portnum;
+	if (gid) {
+		memset(gid, 0, sizeof(*gid));
+		prefix = cl_hton64(port.gid_prefix);
+		guid = cl_hton64(port.port_guid);
+		mad_encode_field(*gid, IB_GID_PREFIX_F, &prefix);
+		mad_encode_field(*gid, IB_GID_GUID_F, &guid);
+	}
+
+	umad_release_port(&port);
+
+	return 0;
+}
+
 /* define a common SA query structure
  * This is by no means optimal but it moves the saquery functionality out of
  * the saquery tool and provides it to other utilities.
diff --git a/src/ibportstate.c b/src/ibportstate.c
index ec6b823..ac74dfd 100644
--- a/src/ibportstate.c
+++ b/src/ibportstate.c
@@ -574,8 +574,8 @@ int main(int argc, char **argv)
 			peerportid.drpath.p[1] = (uint8_t) portnum;
 
 			/* Set DrSLID to local lid */
-			if (ib_resolve_self_via(&selfportid,
-						&selfport, 0, srcport) < 0)
+			if (resolve_self(ibd_ca, ibd_ca_port, &selfportid,
+						&selfport, 0) < 0)
 				IBERROR("could not resolve self");
 			peerportid.drpath.drslid = (uint16_t) selfportid.lid;
 			peerportid.drpath.drdlid = 0xffff;
diff --git a/src/ibsendtrap.c b/src/ibsendtrap.c
index 618706b..2d63e35 100644
--- a/src/ibsendtrap.c
+++ b/src/ibsendtrap.c
@@ -130,10 +130,10 @@ static int send_trap(const char *name,
 	ib_rpc_t trap_rpc;
 	ib_mad_notice_attr_t notice;
 
-	if (ib_resolve_self_via(&selfportid, &selfport, NULL, srcport))
+	if (resolve_self(ibd_ca, ibd_ca_port, &selfportid, &selfport, NULL))
 		IBERROR("can't resolve self");
 
-	if (ib_resolve_smlid_via(&sm_port, 0, srcport))
+	if (resolve_sm_portid(ibd_ca, ibd_ca_port, &sm_port))
 		IBERROR("can't resolve SM destination port");
 
 	memset(&trap_rpc, 0, sizeof(trap_rpc));
diff --git a/src/mcm_rereg_test.c b/src/mcm_rereg_test.c
index 60ec421..ec979d7 100644
--- a/src/mcm_rereg_test.c
+++ b/src/mcm_rereg_test.c
@@ -44,6 +44,8 @@
 #include <infiniband/mad.h>
 #include <infiniband/iba/ib_types.h>
 
+#include "ibdiag_common.h"
+
 #define info(fmt, ...) fprintf(stderr, "INFO: " fmt, ## __VA_ARGS__ )
 #define err(fmt, ...) fprintf(stderr, "ERR: " fmt, ## __VA_ARGS__ )
 #ifdef NOISY_DEBUG
@@ -368,7 +370,7 @@ int main(int argc, char **argv)
 	if (!srcport)
 		err("Failed to open port");
 
-	ib_resolve_smlid_via(&dport_id, TMO, srcport);
+	resolve_sm_portid(NULL, 0, &dport_id);
 	dport_id.qp = 1;
 	if (!dport_id.qkey)
 		dport_id.qkey = IB_DEFAULT_QP1_QKEY;
diff --git a/src/perfquery.c b/src/perfquery.c
index c747d11..7361c06 100644
--- a/src/perfquery.c
+++ b/src/perfquery.c
@@ -734,7 +734,7 @@ int main(int argc, char **argv)
 					      ibd_sm_id, srcport) < 0)
 			IBERROR("can't resolve destination port %s", argv[0]);
 	} else {
-		if (ib_resolve_self_via(&portid, &port, 0, srcport) < 0)
+		if (resolve_self(ibd_ca, ibd_ca_port, &portid, &port, 0) < 0)
 			IBERROR("can't resolve self port %s", argv[0]);
 	}
 
diff --git a/src/sminfo.c b/src/sminfo.c
index b02906f..dfe0681 100644
--- a/src/sminfo.c
+++ b/src/sminfo.c
@@ -127,7 +127,7 @@ int main(int argc, char **argv)
 					      0, srcport) < 0)
 			IBERROR("can't resolve destination port %s", argv[0]);
 	} else {
-		if (ib_resolve_smlid_via(&portid, ibd_timeout, srcport) < 0)
+		if (resolve_sm_portid(ibd_ca, ibd_ca_port, &portid) < 0)
 			IBERROR("can't resolve sm port %s", argv[0]);
 	}
 
diff --git a/src/vendstat.c b/src/vendstat.c
index 8dbd1ee..059ceab 100644
--- a/src/vendstat.c
+++ b/src/vendstat.c
@@ -331,7 +331,7 @@ int main(int argc, char **argv)
 					      ibd_sm_id, srcport) < 0)
 			IBERROR("can't resolve destination port %s", argv[0]);
 	} else {
-		if (ib_resolve_self_via(&portid, &port, 0, srcport) < 0)
+		if (resolve_self(ibd_ca, ibd_ca_port, &portid, &port, 0) < 0)
 			IBERROR("can't resolve self port %s", argv[0]);
 	}
 
-- 
1.7.9.2

--
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] 10+ messages in thread

* [PATCH 5/5] infiniband-diags: migrate resolve_portid_str in from libibmad
       [not found] ` <1334279385-10792-1-git-send-email-foraker1-i2BcT+NCU+M@public.gmane.org>
                     ` (2 preceding siblings ...)
  2012-04-13  1:09   ` [PATCH 4/5] infiniband-diags: Remove dependencies on ib_resolve_smlid/ib_resolve_self Jim Foraker
@ 2012-04-13  1:09   ` Jim Foraker
       [not found]     ` <1334279385-10792-5-git-send-email-foraker1-i2BcT+NCU+M@public.gmane.org>
  2012-04-14  1:38   ` [PATCH 1/5] infiniband-diags/ibroute.c: Dead code removal Ira Weiny
  4 siblings, 1 reply; 10+ messages in thread
From: Jim Foraker @ 2012-04-13  1:09 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA; +Cc: Jim Foraker

ib_resolve_portid_str_via() is replaced with resolve_portid_str(),
which operates identically but does not issue any SMPs.  Data is
pulled from the umad layer, which necessitates it taking 2 new
arguments.

Signed-off-by: Jim Foraker <foraker1-i2BcT+NCU+M@public.gmane.org>
---
 include/ibdiag_common.h |    3 ++
 src/ibaddr.c            |    4 +-
 src/ibccconfig.c        |    4 +-
 src/ibccquery.c         |    4 +-
 src/ibdiag_common.c     |  118 ++++++++++++++++++++++++++++++++++++++++++++++-
 src/iblinkinfo.c        |   10 ++--
 src/ibping.c            |    4 +-
 src/ibportstate.c       |    4 +-
 src/ibqueryerrors.c     |    8 ++--
 src/ibroute.c           |    4 +-
 src/ibsysstat.c         |    4 +-
 src/ibtracert.c         |    8 ++--
 src/perfquery.c         |    4 +-
 src/sminfo.c            |    4 +-
 src/smpquery.c          |    8 ++--
 src/vendstat.c          |    4 +-
 16 files changed, 156 insertions(+), 39 deletions(-)

diff --git a/include/ibdiag_common.h b/include/ibdiag_common.h
index 4388834..09dc319 100644
--- a/include/ibdiag_common.h
+++ b/include/ibdiag_common.h
@@ -147,4 +147,7 @@ void get_max_msg(char *width_msg, char *speed_msg, int msg_size,
 int resolve_sm_portid(char *ca_name, uint8_t portnum, ib_portid_t *sm_id);
 int resolve_self(char *ca_name, uint8_t ca_port, ib_portid_t *portid,
                  int *port, ibmad_gid_t *gid);
+int resolve_portid_str(char *ca_name, uint8_t ca_port, ib_portid_t * portid,
+		       char *addr_str, enum MAD_DEST dest_type,
+		       ib_portid_t *sm_id, const struct ibmad_port *srcport);
 #endif				/* _IBDIAG_COMMON_H_ */
diff --git a/src/ibaddr.c b/src/ibaddr.c
index 10dfae8..455d941 100644
--- a/src/ibaddr.c
+++ b/src/ibaddr.c
@@ -150,8 +150,8 @@ int main(int argc, char **argv)
 		IBERROR("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
 
 	if (argc) {
-		if (ib_resolve_portid_str_via(&portid, argv[0], ibd_dest_type,
-					      ibd_sm_id, srcport) < 0)
+		if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[0],
+				       ibd_dest_type, ibd_sm_id, srcport) < 0)
 			IBERROR("can't resolve destination port %s", argv[0]);
 	} else {
 		if (resolve_self(ibd_ca, ibd_ca_port, &portid, &port, NULL) < 0)
diff --git a/src/ibccconfig.c b/src/ibccconfig.c
index c81b7fa..71d408a 100644
--- a/src/ibccconfig.c
+++ b/src/ibccconfig.c
@@ -636,8 +636,8 @@ int main(int argc, char **argv)
 	if (!srcport)
 		IBERROR("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
 
-	if (ib_resolve_portid_str_via(&portid, argv[1], ibd_dest_type,
-				      ibd_sm_id, srcport) < 0)
+	if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[1],
+			       ibd_dest_type, ibd_sm_id, srcport) < 0)
 		IBERROR("can't resolve destination %s", argv[1]);
 	if ((err = fn(&portid, argv + 2, argc - 2)))
 		IBERROR("operation %s: %s", argv[0], err);
diff --git a/src/ibccquery.c b/src/ibccquery.c
index cf8b35a..2bf62fa 100644
--- a/src/ibccquery.c
+++ b/src/ibccquery.c
@@ -416,8 +416,8 @@ int main(int argc, char **argv)
 	if (!srcport)
 		IBERROR("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
 
-	if (ib_resolve_portid_str_via(&portid, argv[1], ibd_dest_type,
-				      ibd_sm_id, srcport) < 0)
+	if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[1],
+			       ibd_dest_type, ibd_sm_id, srcport) < 0)
 		IBERROR("can't resolve destination %s", argv[1]);
 	if ((err = fn(&portid, argv + 2, argc - 2)))
 		IBERROR("operation %s: %s", argv[0], err);
diff --git a/src/ibdiag_common.c b/src/ibdiag_common.c
index 6605362..5752f95 100644
--- a/src/ibdiag_common.c
+++ b/src/ibdiag_common.c
@@ -255,8 +255,8 @@ static int process_opt(int ch, char *optarg)
 		break;
 	case 's':
 		/* srcport is not required when resolving via IB_DEST_LID */
-		if (ib_resolve_portid_str_via(&sm_portid, optarg, IB_DEST_LID,
-					      0, NULL) < 0)
+		if (resolve_portid_str(ibd_ca, ibd_ca_port, &sm_portid, optarg,
+				IB_DEST_LID, 0, NULL) < 0)
 			IBERROR("cannot resolve SM destination port %s",
 				optarg);
 		ibd_sm_id = &sm_portid;
@@ -544,6 +544,120 @@ int resolve_self(char *ca_name, uint8_t ca_port, ib_portid_t *portid,
 	return 0;
 }
 
+int resolve_gid(char *ca_name, uint8_t ca_port, ib_portid_t * portid,
+		ibmad_gid_t gid, ib_portid_t * sm_id,
+		const struct ibmad_port *srcport)
+{
+	ib_portid_t sm_portid;
+	char buf[IB_SA_DATA_SIZE] = { 0 };
+
+	if (!sm_id) {
+		sm_id = &sm_portid;
+		if (resolve_sm_portid(ca_name, ca_port, sm_id) < 0)
+			return -1;
+	}
+
+	if ((portid->lid =
+	     ib_path_query_via(srcport, gid, gid, sm_id, buf)) < 0)
+		return -1;
+
+	return 0;
+}
+
+int resolve_guid(char *ca_name, uint8_t ca_port, ib_portid_t *portid,
+		 uint64_t *guid, ib_portid_t *sm_id,
+		 const struct ibmad_port *srcport)
+{
+	ib_portid_t sm_portid;
+	uint8_t buf[IB_SA_DATA_SIZE] = { 0 };
+	uint64_t prefix;
+	ibmad_gid_t selfgid;
+
+	if (!sm_id) {
+		sm_id = &sm_portid;
+		if (resolve_sm_portid(ca_name, ca_port, sm_id) < 0)
+			return -1;
+	}
+
+	if (resolve_self(ca_name, ca_port, NULL, NULL, &selfgid) < 0)
+		return -1;
+
+	memcpy(&prefix, portid->gid, sizeof(prefix));
+	if (!prefix)
+		mad_set_field64(portid->gid, 0, IB_GID_PREFIX_F,
+				IB_DEFAULT_SUBN_PREFIX);
+	if (guid)
+		mad_set_field64(portid->gid, 0, IB_GID_GUID_F, *guid);
+
+	if ((portid->lid =
+	     ib_path_query_via(srcport, selfgid, portid->gid, sm_id, buf)) < 0)
+		return -1;
+
+	mad_decode_field(buf, IB_SA_PR_SL_F, &portid->sl);
+	return 0;
+}
+
+int resolve_portid_str(char *ca_name, uint8_t ca_port, ib_portid_t * portid,
+		       char *addr_str, enum MAD_DEST dest_type,
+		       ib_portid_t *sm_id, const struct ibmad_port *srcport)
+{
+	ibmad_gid_t gid;
+	uint64_t guid;
+	int lid;
+	char *routepath;
+	ib_portid_t selfportid = { 0 };
+	int selfport = 0;
+
+	memset(portid, 0, sizeof *portid);
+
+	switch (dest_type) {
+	case IB_DEST_LID:
+		lid = strtol(addr_str, 0, 0);
+		if (!IB_LID_VALID(lid))
+			return -1;
+		return ib_portid_set(portid, lid, 0, 0);
+
+	case IB_DEST_DRPATH:
+		if (str2drpath(&portid->drpath, addr_str, 0, 0) < 0)
+			return -1;
+		return 0;
+
+	case IB_DEST_GUID:
+		if (!(guid = strtoull(addr_str, 0, 0)))
+			return -1;
+
+		/* keep guid in portid? */
+		return resolve_guid(ca_name, ca_port, portid, &guid, sm_id,
+				    srcport);
+
+	case IB_DEST_DRSLID:
+		lid = strtol(addr_str, &routepath, 0);
+		routepath++;
+		if (!IB_LID_VALID(lid))
+			return -1;
+		ib_portid_set(portid, lid, 0, 0);
+
+		/* handle DR parsing and set DrSLID to local lid */
+		if (resolve_self(ca_name, ca_port, &selfportid, &selfport,
+				 NULL) < 0)
+			return -1;
+		if (str2drpath(&portid->drpath, routepath, selfportid.lid, 0) <
+		    0)
+			return -1;
+		return 0;
+
+	case IB_DEST_GID:
+		if (inet_pton(AF_INET6, addr_str, &gid) <= 0)
+			return -1;
+		return resolve_gid(ca_name, ca_port, portid, gid, sm_id,
+				   srcport);
+	default:
+		IBWARN("bad dest_type %d", dest_type);
+	}
+
+	return -1;
+}
+
 /* define a common SA query structure
  * This is by no means optimal but it moves the saquery functionality out of
  * the saquery tool and provides it to other utilities.
diff --git a/src/iblinkinfo.c b/src/iblinkinfo.c
index 575be0a..36aa6d1 100644
--- a/src/iblinkinfo.c
+++ b/src/iblinkinfo.c
@@ -649,15 +649,15 @@ int main(int argc, char **argv)
 	if (dr_path) {
 		/* only scan part of the fabric */
 		if ((resolved =
-		     ib_resolve_portid_str_via(&port_id, dr_path,
-					       IB_DEST_DRPATH, NULL,
-					       ibmad_port)) < 0)
+		     resolve_portid_str(ibd_ca, ibd_ca_port, &port_id, dr_path,
+					IB_DEST_DRPATH, NULL, ibmad_port)) < 0)
 			IBWARN("Failed to resolve %s; attempting full scan",
 			       dr_path);
 	} else if (guid_str) {
 		if ((resolved =
-		     ib_resolve_portid_str_via(&port_id, guid_str, IB_DEST_GUID,
-					       NULL, ibmad_port)) < 0)
+		     resolve_portid_str(ibd_ca, ibd_ca_port, &port_id,
+				        guid_str, IB_DEST_GUID, NULL,
+					ibmad_port)) < 0)
 			IBWARN("Failed to resolve %s; attempting full scan\n",
 			       guid_str);
 	}
diff --git a/src/ibping.c b/src/ibping.c
index 16ffb34..9d5c54b 100644
--- a/src/ibping.c
+++ b/src/ibping.c
@@ -232,8 +232,8 @@ int main(int argc, char **argv)
 		IBERROR("can't register ping class %d on this port",
 			ping_class);
 
-	if (ib_resolve_portid_str_via(&portid, argv[0], ibd_dest_type,
-				      ibd_sm_id, srcport) < 0)
+	if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[0],
+			       ibd_dest_type, ibd_sm_id, srcport) < 0)
 		IBERROR("can't resolve destination port %s", argv[0]);
 
 	signal(SIGINT, report);
diff --git a/src/ibportstate.c b/src/ibportstate.c
index ac74dfd..5559d18 100644
--- a/src/ibportstate.c
+++ b/src/ibportstate.c
@@ -376,8 +376,8 @@ int main(int argc, char **argv)
 	if (!srcport)
 		IBERROR("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
 
-	if (ib_resolve_portid_str_via(&portid, argv[0], ibd_dest_type,
-				      ibd_sm_id, srcport) < 0)
+	if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[0],
+			       ibd_dest_type, ibd_sm_id, srcport) < 0)
 		IBERROR("can't resolve destination port %s", argv[0]);
 
 	if (argc > 1)
diff --git a/src/ibqueryerrors.c b/src/ibqueryerrors.c
index f877527..4fec240 100644
--- a/src/ibqueryerrors.c
+++ b/src/ibqueryerrors.c
@@ -931,14 +931,14 @@ int main(int argc, char **argv)
 	/* limit the scan the fabric around the target */
 	if (dr_path) {
 		if ((resolved =
-		     ib_resolve_portid_str_via(&portid, dr_path, IB_DEST_DRPATH,
-					       NULL, ibmad_port)) < 0)
+		     resolve_portid_str(ibd_ca, ibd_ca_port, &portid, dr_path,
+					IB_DEST_DRPATH, NULL, ibmad_port)) < 0)
 			IBWARN("Failed to resolve %s; attempting full scan",
 			       dr_path);
 	} else if (port_guid_str) {
 		if ((resolved =
-		     ib_resolve_portid_str_via(&portid, port_guid_str,
-					       IB_DEST_GUID, ibd_sm_id,
+		     resolve_portid_str(ibd_ca, ibd_ca_port, &portid,
+					port_guid_str, IB_DEST_GUID, ibd_sm_id,
 					       ibmad_port)) < 0)
 			IBWARN("Failed to resolve %s; attempting full scan",
 			       port_guid_str);
diff --git a/src/ibroute.c b/src/ibroute.c
index 1bf1fb0..faff34d 100644
--- a/src/ibroute.c
+++ b/src/ibroute.c
@@ -432,8 +432,8 @@ int main(int argc, char **argv)
 	if (!srcport)
 		IBERROR("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
 
-	if (ib_resolve_portid_str_via(&portid, argv[0], ibd_dest_type,
-					     ibd_sm_id, srcport) < 0)
+	if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[0],
+			       ibd_dest_type, ibd_sm_id, srcport) < 0)
 		IBERROR("can't resolve destination port %s", argv[1]);
 
 	if (multicast)
diff --git a/src/ibsysstat.c b/src/ibsysstat.c
index f007aa3..2b11a06 100644
--- a/src/ibsysstat.c
+++ b/src/ibsysstat.c
@@ -358,8 +358,8 @@ int main(int argc, char **argv)
 	if (mad_register_client_via(sysstat_class, 1, srcport) < 0)
 		IBERROR("can't register to sysstat class %d", sysstat_class);
 
-	if (ib_resolve_portid_str_via(&portid, argv[0], ibd_dest_type,
-				      ibd_sm_id, srcport) < 0)
+	if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[0],
+			       ibd_dest_type, ibd_sm_id, srcport) < 0)
 		IBERROR("can't resolve destination port %s", argv[0]);
 
 	if ((err = ibsystat(&portid, attr)))
diff --git a/src/ibtracert.c b/src/ibtracert.c
index c9f511b..e8fedf3 100644
--- a/src/ibtracert.c
+++ b/src/ibtracert.c
@@ -776,12 +776,12 @@ int main(int argc, char **argv)
 
 	node_name_map = open_node_name_map(node_name_map_file);
 
-	if (ib_resolve_portid_str_via(&src_portid, argv[0], ibd_dest_type,
-				      ibd_sm_id, srcport) < 0)
+	if (resolve_portid_str(ibd_ca, ibd_ca_port, &src_portid, argv[0],
+			       ibd_dest_type, ibd_sm_id, srcport) < 0)
 		IBERROR("can't resolve source port %s", argv[0]);
 
-	if (ib_resolve_portid_str_via(&dest_portid, argv[1], ibd_dest_type,
-				      ibd_sm_id, srcport) < 0)
+	if (resolve_portid_str(ibd_ca, ibd_ca_port, &dest_portid, argv[1],
+			       ibd_dest_type, ibd_sm_id, srcport) < 0)
 		IBERROR("can't resolve destination port %s", argv[1]);
 
 	if (ibd_dest_type == IB_DEST_DRPATH) {
diff --git a/src/perfquery.c b/src/perfquery.c
index 7361c06..8835d3d 100644
--- a/src/perfquery.c
+++ b/src/perfquery.c
@@ -730,8 +730,8 @@ int main(int argc, char **argv)
 		IBERROR("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
 
 	if (argc) {
-		if (ib_resolve_portid_str_via(&portid, argv[0], ibd_dest_type,
-					      ibd_sm_id, srcport) < 0)
+		if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[0],
+				       ibd_dest_type, ibd_sm_id, srcport) < 0)
 			IBERROR("can't resolve destination port %s", argv[0]);
 	} else {
 		if (resolve_self(ibd_ca, ibd_ca_port, &portid, &port, 0) < 0)
diff --git a/src/sminfo.c b/src/sminfo.c
index dfe0681..f1abc6a 100644
--- a/src/sminfo.c
+++ b/src/sminfo.c
@@ -123,8 +123,8 @@ int main(int argc, char **argv)
 		IBERROR("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
 
 	if (argc) {
-		if (ib_resolve_portid_str_via(&portid, argv[0], ibd_dest_type,
-					      0, srcport) < 0)
+		if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[0],
+				       ibd_dest_type, 0, srcport) < 0)
 			IBERROR("can't resolve destination port %s", argv[0]);
 	} else {
 		if (resolve_sm_portid(ibd_ca, ibd_ca_port, &portid) < 0)
diff --git a/src/smpquery.c b/src/smpquery.c
index cecfa68..533b2c3 100644
--- a/src/smpquery.c
+++ b/src/smpquery.c
@@ -483,8 +483,8 @@ int main(int argc, char **argv)
 	node_name_map = open_node_name_map(node_name_map_file);
 
 	if (ibd_dest_type != IB_DEST_DRSLID) {
-		if (ib_resolve_portid_str_via(&portid, argv[1], ibd_dest_type,
-					      ibd_sm_id, srcport) < 0)
+		if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[1],
+				       ibd_dest_type, ibd_sm_id, srcport) < 0)
 			IBERROR("can't resolve destination port %s", argv[1]);
 		if ((err = fn(&portid, argv + 2, argc - 2)))
 			IBERROR("operation %s: %s", argv[0], err);
@@ -493,8 +493,8 @@ int main(int argc, char **argv)
 
 		memset(concat, 0, 64);
 		snprintf(concat, sizeof(concat), "%s %s", argv[1], argv[2]);
-		if (ib_resolve_portid_str_via(&portid, concat, ibd_dest_type,
-					      ibd_sm_id, srcport) < 0)
+		if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, concat,
+				       ibd_dest_type, ibd_sm_id, srcport) < 0)
 			IBERROR("can't resolve destination port %s", concat);
 		if ((err = fn(&portid, argv + 3, argc - 3)))
 			IBERROR("operation %s: %s", argv[0], err);
diff --git a/src/vendstat.c b/src/vendstat.c
index 059ceab..1d3d78c 100644
--- a/src/vendstat.c
+++ b/src/vendstat.c
@@ -327,8 +327,8 @@ int main(int argc, char **argv)
 		IBERROR("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
 
 	if (argc) {
-		if (ib_resolve_portid_str_via(&portid, argv[0], ibd_dest_type,
-					      ibd_sm_id, srcport) < 0)
+		if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[0],
+				       ibd_dest_type, ibd_sm_id, srcport) < 0)
 			IBERROR("can't resolve destination port %s", argv[0]);
 	} else {
 		if (resolve_self(ibd_ca, ibd_ca_port, &portid, &port, 0) < 0)
-- 
1.7.9.2

--
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] 10+ messages in thread

* Re: [PATCH 1/5] infiniband-diags/ibroute.c: Dead code removal
       [not found] ` <1334279385-10792-1-git-send-email-foraker1-i2BcT+NCU+M@public.gmane.org>
                     ` (3 preceding siblings ...)
  2012-04-13  1:09   ` [PATCH 5/5] infiniband-diags: migrate resolve_portid_str in from libibmad Jim Foraker
@ 2012-04-14  1:38   ` Ira Weiny
  4 siblings, 0 replies; 10+ messages in thread
From: Ira Weiny @ 2012-04-14  1:38 UTC (permalink / raw)
  To: Jim Foraker; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA

On Thu, 12 Apr 2012 18:09:41 -0700
Jim Foraker <foraker1-i2BcT+NCU+M@public.gmane.org> wrote:

> Program has already exited in the case where argc == 0
> 
> Signed-off-by: Jim Foraker <foraker1-i2BcT+NCU+M@public.gmane.org>

Thanks applied,
Ira

> ---
>  src/ibroute.c |    5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/src/ibroute.c b/src/ibroute.c
> index 7339218..1bf1fb0 100644
> --- a/src/ibroute.c
> +++ b/src/ibroute.c
> @@ -432,10 +432,7 @@ int main(int argc, char **argv)
>  	if (!srcport)
>  		IBERROR("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
>  
> -	if (!argc) {
> -		if (ib_resolve_self_via(&portid, 0, 0, srcport) < 0)
> -			IBERROR("can't resolve self addr");
> -	} else if (ib_resolve_portid_str_via(&portid, argv[0], ibd_dest_type,
> +	if (ib_resolve_portid_str_via(&portid, argv[0], ibd_dest_type,
>  					     ibd_sm_id, srcport) < 0)
>  		IBERROR("can't resolve destination port %s", argv[1]);
>  
> -- 
> 1.7.9.2
> 
> --
> 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


-- 
Ira Weiny
Member of Technical Staff
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] 10+ messages in thread

* Re: [PATCH 2/5] infiniband-diags/mcm_rereg_test.c: dead code removal
       [not found]     ` <1334279385-10792-2-git-send-email-foraker1-i2BcT+NCU+M@public.gmane.org>
@ 2012-04-14  1:40       ` Ira Weiny
  0 siblings, 0 replies; 10+ messages in thread
From: Ira Weiny @ 2012-04-14  1:40 UTC (permalink / raw)
  To: Jim Foraker; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA

On Thu, 12 Apr 2012 18:09:42 -0700
Jim Foraker <foraker1-i2BcT+NCU+M@public.gmane.org> wrote:

> Remove old #if 0'd code
> 
> Signed-off-by: Jim Foraker <foraker1-i2BcT+NCU+M@public.gmane.org>

Thanks applied,
Ira

> ---
>  src/mcm_rereg_test.c |   86 --------------------------------------------------
>  1 file changed, 86 deletions(-)
> 
> diff --git a/src/mcm_rereg_test.c b/src/mcm_rereg_test.c
> index a764d02..55b8add 100644
> --- a/src/mcm_rereg_test.c
> +++ b/src/mcm_rereg_test.c
> @@ -195,34 +195,6 @@ static int rereg_send_all(int port, int agent, ib_portid_t * dport,
>  	return 0;
>  }
>  
> -#if 0
> -static int rereg_mcm_rec_send(int port, int agent, ib_portid_t * dport, int cnt)
> -{
> -	ib_portid_t portid;
> -	ibmad_gid_t port_gid;
> -	uint8_t *umad;
> -	int len, ret = 0;
> -
> -	ib_resolve_self(&portid, NULL, &port_gid);
> -
> -	len = umad_size() + 256;
> -	umad = calloc(1, len);
> -	if (!umad) {
> -		err("cannot alloc mem for umad: %s\n", strerror(errno));
> -		return -1;
> -	}
> -
> -	while (cnt--) {
> -		if (!rereg_port_gid(port, agent, dport, umad, len, port_gid))
> -			ret += 2;
> -	}
> -
> -	free(umad);
> -
> -	return ret;
> -}
> -#endif
> -
>  static int rereg_recv(int port, int agent, ib_portid_t * dport,
>  		      uint8_t * umad, int length, int tmo)
>  {
> @@ -350,42 +322,6 @@ static int rereg_query_all(int port, int agent, ib_portid_t * dport,
>  	return 0;
>  }
>  
> -#if 0
> -static int rereg_mcm_rec_recv(int port, int agent, int cnt)
> -{
> -	uint8_t *umad, *mad;
> -	int len = umad_size() + 256;
> -	int i;
> -
> -	umad = calloc(1, len);
> -	if (!umad) {
> -		err("cannot alloc mem for umad: %s\n", strerror(errno));
> -		return -1;
> -	}
> -
> -	for (i = 0; i < cnt; i++) {
> -		int retry;
> -		retry = 0;
> -		while (umad_recv(port, umad, &len, TMO) < 0 &&
> -		       errno == ETIMEDOUT)
> -			if (retry++ > 3) {
> -				err("umad_recv %d failed: %s\n",
> -				    i, strerror(errno));
> -				free(umad);
> -				return -1;
> -			}
> -		dbg("umad_recv %d (retries %d), tid = 0x%016" PRIx64
> -		    ": len = %d, status = %d\n", i, retry,
> -		    mad_get_field64(umad_get_mad(umad), 0, IB_MAD_TRID_F), len,
> -		    umad_status(umad));
> -		mad = umad_get_mad(umad);
> -	}
> -
> -	free(umad);
> -	return 0;
> -}
> -#endif
> -
>  #define MAX_CLIENTS 50
>  
>  static int rereg_and_test_port(char *guid_file, int port, int agent,
> @@ -451,12 +387,7 @@ int main(int argc, char **argv)
>  	if (!srcport)
>  		err("Failed to open port");
>  
> -#if 1
>  	ib_resolve_smlid_via(&dport_id, TMO, srcport);
> -#else
> -	memset(&dport_id, 0, sizeof(dport_id));
> -	dport_id.lid = 1;
> -#endif
>  	dport_id.qp = 1;
>  	if (!dport_id.qkey)
>  		dport_id.qkey = IB_DEFAULT_QP1_QKEY;
> @@ -467,28 +398,11 @@ int main(int argc, char **argv)
>  		err("cannot alloc mem for umad: %s\n", strerror(errno));
>  		return -1;
>  	}
> -#if 1
>  	port = mad_rpc_portid(srcport);
> -#else
> -	ret = umad_init();
> -
> -	port = umad_open_port(NULL, 0);
> -	if (port < 0) {
> -		err("umad_open_port failed: %s\n", strerror(errno));
> -		return port;
> -	}
> -#endif
>  
>  	agent = umad_register(port, IB_SA_CLASS, 2, 0, NULL);
>  
> -#if 0
> -	int cnt;
> -	cnt = rereg_mcm_rec_send(port, agent, &dport_id, cnt);
> -
> -	rereg_recv_all(port, agent, &dport_id);
> -#else
>  	rereg_and_test_port(guid_file, port, agent, &dport_id, TMO);
> -#endif
>  	mad = umad_get_mad(umad);
>  
>  	free(umad);
> -- 
> 1.7.9.2
> 
> --
> 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


-- 
Ira Weiny
Member of Technical Staff
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] 10+ messages in thread

* Re: [PATCH 3/5] infiniband-diags/mcm_rereg_test.c: Include ib_types.h
       [not found]     ` <1334279385-10792-3-git-send-email-foraker1-i2BcT+NCU+M@public.gmane.org>
@ 2012-04-14  1:41       ` Ira Weiny
  0 siblings, 0 replies; 10+ messages in thread
From: Ira Weiny @ 2012-04-14  1:41 UTC (permalink / raw)
  To: Jim Foraker; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA

On Thu, 12 Apr 2012 18:09:43 -0700
Jim Foraker <foraker1-i2BcT+NCU+M@public.gmane.org> wrote:

> Remove IB_MCM_COMPMASK defines, which should be pulled from
> ib_types.h instead.  This is necessary in order to allow future
> inclusion of ibdiag_common.h.
> 
> Signed-off-by: Jim Foraker <foraker1-i2BcT+NCU+M@public.gmane.org>

Thanks applied,
Ira

> ---
>  src/mcm_rereg_test.c |   21 +--------------------
>  1 file changed, 1 insertion(+), 20 deletions(-)
> 
> diff --git a/src/mcm_rereg_test.c b/src/mcm_rereg_test.c
> index 55b8add..60ec421 100644
> --- a/src/mcm_rereg_test.c
> +++ b/src/mcm_rereg_test.c
> @@ -42,6 +42,7 @@
>  
>  #include <infiniband/umad.h>
>  #include <infiniband/mad.h>
> +#include <infiniband/iba/ib_types.h>
>  
>  #define info(fmt, ...) fprintf(stderr, "INFO: " fmt, ## __VA_ARGS__ )
>  #define err(fmt, ...) fprintf(stderr, "ERR: " fmt, ## __VA_ARGS__ )
> @@ -53,26 +54,6 @@
>  
>  #define TMO 100
>  
> -/* Multicast Member Record Component Masks */
> -#define IB_MCR_COMPMASK_MGID        (1ULL<<0)
> -#define IB_MCR_COMPMASK_PORT_GID    (1ULL<<1)
> -#define IB_MCR_COMPMASK_QKEY        (1ULL<<2)
> -#define IB_MCR_COMPMASK_MLID        (1ULL<<3)
> -#define IB_MCR_COMPMASK_MTU_SEL     (1ULL<<4)
> -#define IB_MCR_COMPMASK_MTU         (1ULL<<5)
> -#define IB_MCR_COMPMASK_TCLASS      (1ULL<<6)
> -#define IB_MCR_COMPMASK_PKEY        (1ULL<<7)
> -#define IB_MCR_COMPMASK_RATE_SEL    (1ULL<<8)
> -#define IB_MCR_COMPMASK_RATE        (1ULL<<9)
> -#define IB_MCR_COMPMASK_LIFE_SEL    (1ULL<<10)
> -#define IB_MCR_COMPMASK_LIFE        (1ULL<<11)
> -#define IB_MCR_COMPMASK_SL          (1ULL<<12)
> -#define IB_MCR_COMPMASK_FLOW        (1ULL<<13)
> -#define IB_MCR_COMPMASK_HOP         (1ULL<<14)
> -#define IB_MCR_COMPMASK_SCOPE       (1ULL<<15)
> -#define IB_MCR_COMPMASK_JOIN_STATE  (1ULL<<16)
> -#define IB_MCR_COMPMASK_PROXY       (1ULL<<17)
> -
>  static ibmad_gid_t mgid_ipoib = {
>  	0xff, 0x12, 0x40, 0x1b, 0xff, 0xff, 0x00, 0x00,
>  	0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
> -- 
> 1.7.9.2
> 
> --
> 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


-- 
Ira Weiny
Member of Technical Staff
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] 10+ messages in thread

* Re: [PATCH 4/5] infiniband-diags: Remove dependencies on ib_resolve_smlid/ib_resolve_self
       [not found]     ` <1334279385-10792-4-git-send-email-foraker1-i2BcT+NCU+M@public.gmane.org>
@ 2012-04-14  1:49       ` Ira Weiny
  0 siblings, 0 replies; 10+ messages in thread
From: Ira Weiny @ 2012-04-14  1:49 UTC (permalink / raw)
  To: Jim Foraker; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA

On Thu, 12 Apr 2012 18:09:44 -0700
Jim Foraker <foraker1-i2BcT+NCU+M@public.gmane.org> wrote:

> ib_resolve_smlid() and ib_resolve_self() issue SMP queries to the local
> interface for data that can be acquired thru other means.
> resolve_sm_portid() (originally defined in 3179ae8c and made public here)
> and the new function resolve_self() replace these functions, pulling
> information from the umad layer instead.
> 
> Signed-off-by: Jim Foraker <foraker1-i2BcT+NCU+M@public.gmane.org>

Thanks applied,
Ira

> ---
>  include/ibdiag_common.h |    3 +++
>  src/ibaddr.c            |    2 +-
>  src/ibdiag_common.c     |   37 +++++++++++++++++++++++++++++++++++++
>  src/ibportstate.c       |    4 ++--
>  src/ibsendtrap.c        |    4 ++--
>  src/mcm_rereg_test.c    |    4 +++-
>  src/perfquery.c         |    2 +-
>  src/sminfo.c            |    2 +-
>  src/vendstat.c          |    2 +-
>  9 files changed, 51 insertions(+), 9 deletions(-)
> 
> diff --git a/include/ibdiag_common.h b/include/ibdiag_common.h
> index 0131193..4388834 100644
> --- a/include/ibdiag_common.h
> +++ b/include/ibdiag_common.h
> @@ -144,4 +144,7 @@ void sa_report_err(int status);
>  void get_max_msg(char *width_msg, char *speed_msg, int msg_size,
>  		 ibnd_port_t * port);
>  
> +int resolve_sm_portid(char *ca_name, uint8_t portnum, ib_portid_t *sm_id);
> +int resolve_self(char *ca_name, uint8_t ca_port, ib_portid_t *portid,
> +                 int *port, ibmad_gid_t *gid);
>  #endif				/* _IBDIAG_COMMON_H_ */
> diff --git a/src/ibaddr.c b/src/ibaddr.c
> index 397ef77..10dfae8 100644
> --- a/src/ibaddr.c
> +++ b/src/ibaddr.c
> @@ -154,7 +154,7 @@ int main(int argc, char **argv)
>  					      ibd_sm_id, srcport) < 0)
>  			IBERROR("can't resolve destination port %s", argv[0]);
>  	} else {
> -		if (ib_resolve_self_via(&portid, &port, 0, srcport) < 0)
> +		if (resolve_self(ibd_ca, ibd_ca_port, &portid, &port, NULL) < 0)
>  			IBERROR("can't resolve self port %s", argv[0]);
>  	}
>  
> diff --git a/src/ibdiag_common.c b/src/ibdiag_common.c
> index b22ed60..6605362 100644
> --- a/src/ibdiag_common.c
> +++ b/src/ibdiag_common.c
> @@ -507,6 +507,43 @@ int resolve_sm_portid(char *ca_name, uint8_t portnum, ib_portid_t *sm_id)
>  	return 0;
>  }
>  
> +/** =========================================================================
> + * Resolve local CA characteristics using the umad layer rather than using
> + * ib_resolve_self_via which requires SMP queries on the local port.
> + */
> +int resolve_self(char *ca_name, uint8_t ca_port, ib_portid_t *portid,
> +		 int *portnum, ibmad_gid_t *gid)
> +{
> +	umad_port_t port;
> +	uint64_t prefix, guid;
> +	int rc;
> +
> +	if (!(portid || portnum || gid))
> +		return (-1);
> +
> +	if ((rc = umad_get_port(ca_name, ca_port, &port)) < 0)
> +		return rc;
> +
> +	if (portid) {
> +		memset(portid, 0, sizeof(*portid));
> +		portid->lid = port.base_lid;
> +		portid->sl = port.sm_sl;
> +	}
> +	if (portnum)
> +		*portnum = port.portnum;
> +	if (gid) {
> +		memset(gid, 0, sizeof(*gid));
> +		prefix = cl_hton64(port.gid_prefix);
> +		guid = cl_hton64(port.port_guid);
> +		mad_encode_field(*gid, IB_GID_PREFIX_F, &prefix);
> +		mad_encode_field(*gid, IB_GID_GUID_F, &guid);
> +	}
> +
> +	umad_release_port(&port);
> +
> +	return 0;
> +}
> +
>  /* define a common SA query structure
>   * This is by no means optimal but it moves the saquery functionality out of
>   * the saquery tool and provides it to other utilities.
> diff --git a/src/ibportstate.c b/src/ibportstate.c
> index ec6b823..ac74dfd 100644
> --- a/src/ibportstate.c
> +++ b/src/ibportstate.c
> @@ -574,8 +574,8 @@ int main(int argc, char **argv)
>  			peerportid.drpath.p[1] = (uint8_t) portnum;
>  
>  			/* Set DrSLID to local lid */
> -			if (ib_resolve_self_via(&selfportid,
> -						&selfport, 0, srcport) < 0)
> +			if (resolve_self(ibd_ca, ibd_ca_port, &selfportid,
> +						&selfport, 0) < 0)
>  				IBERROR("could not resolve self");
>  			peerportid.drpath.drslid = (uint16_t) selfportid.lid;
>  			peerportid.drpath.drdlid = 0xffff;
> diff --git a/src/ibsendtrap.c b/src/ibsendtrap.c
> index 618706b..2d63e35 100644
> --- a/src/ibsendtrap.c
> +++ b/src/ibsendtrap.c
> @@ -130,10 +130,10 @@ static int send_trap(const char *name,
>  	ib_rpc_t trap_rpc;
>  	ib_mad_notice_attr_t notice;
>  
> -	if (ib_resolve_self_via(&selfportid, &selfport, NULL, srcport))
> +	if (resolve_self(ibd_ca, ibd_ca_port, &selfportid, &selfport, NULL))
>  		IBERROR("can't resolve self");
>  
> -	if (ib_resolve_smlid_via(&sm_port, 0, srcport))
> +	if (resolve_sm_portid(ibd_ca, ibd_ca_port, &sm_port))
>  		IBERROR("can't resolve SM destination port");
>  
>  	memset(&trap_rpc, 0, sizeof(trap_rpc));
> diff --git a/src/mcm_rereg_test.c b/src/mcm_rereg_test.c
> index 60ec421..ec979d7 100644
> --- a/src/mcm_rereg_test.c
> +++ b/src/mcm_rereg_test.c
> @@ -44,6 +44,8 @@
>  #include <infiniband/mad.h>
>  #include <infiniband/iba/ib_types.h>
>  
> +#include "ibdiag_common.h"
> +
>  #define info(fmt, ...) fprintf(stderr, "INFO: " fmt, ## __VA_ARGS__ )
>  #define err(fmt, ...) fprintf(stderr, "ERR: " fmt, ## __VA_ARGS__ )
>  #ifdef NOISY_DEBUG
> @@ -368,7 +370,7 @@ int main(int argc, char **argv)
>  	if (!srcport)
>  		err("Failed to open port");
>  
> -	ib_resolve_smlid_via(&dport_id, TMO, srcport);
> +	resolve_sm_portid(NULL, 0, &dport_id);
>  	dport_id.qp = 1;
>  	if (!dport_id.qkey)
>  		dport_id.qkey = IB_DEFAULT_QP1_QKEY;
> diff --git a/src/perfquery.c b/src/perfquery.c
> index c747d11..7361c06 100644
> --- a/src/perfquery.c
> +++ b/src/perfquery.c
> @@ -734,7 +734,7 @@ int main(int argc, char **argv)
>  					      ibd_sm_id, srcport) < 0)
>  			IBERROR("can't resolve destination port %s", argv[0]);
>  	} else {
> -		if (ib_resolve_self_via(&portid, &port, 0, srcport) < 0)
> +		if (resolve_self(ibd_ca, ibd_ca_port, &portid, &port, 0) < 0)
>  			IBERROR("can't resolve self port %s", argv[0]);
>  	}
>  
> diff --git a/src/sminfo.c b/src/sminfo.c
> index b02906f..dfe0681 100644
> --- a/src/sminfo.c
> +++ b/src/sminfo.c
> @@ -127,7 +127,7 @@ int main(int argc, char **argv)
>  					      0, srcport) < 0)
>  			IBERROR("can't resolve destination port %s", argv[0]);
>  	} else {
> -		if (ib_resolve_smlid_via(&portid, ibd_timeout, srcport) < 0)
> +		if (resolve_sm_portid(ibd_ca, ibd_ca_port, &portid) < 0)
>  			IBERROR("can't resolve sm port %s", argv[0]);
>  	}
>  
> diff --git a/src/vendstat.c b/src/vendstat.c
> index 8dbd1ee..059ceab 100644
> --- a/src/vendstat.c
> +++ b/src/vendstat.c
> @@ -331,7 +331,7 @@ int main(int argc, char **argv)
>  					      ibd_sm_id, srcport) < 0)
>  			IBERROR("can't resolve destination port %s", argv[0]);
>  	} else {
> -		if (ib_resolve_self_via(&portid, &port, 0, srcport) < 0)
> +		if (resolve_self(ibd_ca, ibd_ca_port, &portid, &port, 0) < 0)
>  			IBERROR("can't resolve self port %s", argv[0]);
>  	}
>  
> -- 
> 1.7.9.2
> 
> --
> 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


-- 
Ira Weiny
Member of Technical Staff
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] 10+ messages in thread

* Re: [PATCH 5/5] infiniband-diags: migrate resolve_portid_str in from libibmad
       [not found]     ` <1334279385-10792-5-git-send-email-foraker1-i2BcT+NCU+M@public.gmane.org>
@ 2012-04-14  1:50       ` Ira Weiny
  0 siblings, 0 replies; 10+ messages in thread
From: Ira Weiny @ 2012-04-14  1:50 UTC (permalink / raw)
  To: Jim Foraker; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA

On Thu, 12 Apr 2012 18:09:45 -0700
Jim Foraker <foraker1-i2BcT+NCU+M@public.gmane.org> wrote:

> ib_resolve_portid_str_via() is replaced with resolve_portid_str(),
> which operates identically but does not issue any SMPs.  Data is
> pulled from the umad layer, which necessitates it taking 2 new
> arguments.
> 
> Signed-off-by: Jim Foraker <foraker1-i2BcT+NCU+M@public.gmane.org>

Thanks applied,
Ira

> ---
>  include/ibdiag_common.h |    3 ++
>  src/ibaddr.c            |    4 +-
>  src/ibccconfig.c        |    4 +-
>  src/ibccquery.c         |    4 +-
>  src/ibdiag_common.c     |  118 ++++++++++++++++++++++++++++++++++++++++++++++-
>  src/iblinkinfo.c        |   10 ++--
>  src/ibping.c            |    4 +-
>  src/ibportstate.c       |    4 +-
>  src/ibqueryerrors.c     |    8 ++--
>  src/ibroute.c           |    4 +-
>  src/ibsysstat.c         |    4 +-
>  src/ibtracert.c         |    8 ++--
>  src/perfquery.c         |    4 +-
>  src/sminfo.c            |    4 +-
>  src/smpquery.c          |    8 ++--
>  src/vendstat.c          |    4 +-
>  16 files changed, 156 insertions(+), 39 deletions(-)
> 
> diff --git a/include/ibdiag_common.h b/include/ibdiag_common.h
> index 4388834..09dc319 100644
> --- a/include/ibdiag_common.h
> +++ b/include/ibdiag_common.h
> @@ -147,4 +147,7 @@ void get_max_msg(char *width_msg, char *speed_msg, int msg_size,
>  int resolve_sm_portid(char *ca_name, uint8_t portnum, ib_portid_t *sm_id);
>  int resolve_self(char *ca_name, uint8_t ca_port, ib_portid_t *portid,
>                   int *port, ibmad_gid_t *gid);
> +int resolve_portid_str(char *ca_name, uint8_t ca_port, ib_portid_t * portid,
> +		       char *addr_str, enum MAD_DEST dest_type,
> +		       ib_portid_t *sm_id, const struct ibmad_port *srcport);
>  #endif				/* _IBDIAG_COMMON_H_ */
> diff --git a/src/ibaddr.c b/src/ibaddr.c
> index 10dfae8..455d941 100644
> --- a/src/ibaddr.c
> +++ b/src/ibaddr.c
> @@ -150,8 +150,8 @@ int main(int argc, char **argv)
>  		IBERROR("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
>  
>  	if (argc) {
> -		if (ib_resolve_portid_str_via(&portid, argv[0], ibd_dest_type,
> -					      ibd_sm_id, srcport) < 0)
> +		if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[0],
> +				       ibd_dest_type, ibd_sm_id, srcport) < 0)
>  			IBERROR("can't resolve destination port %s", argv[0]);
>  	} else {
>  		if (resolve_self(ibd_ca, ibd_ca_port, &portid, &port, NULL) < 0)
> diff --git a/src/ibccconfig.c b/src/ibccconfig.c
> index c81b7fa..71d408a 100644
> --- a/src/ibccconfig.c
> +++ b/src/ibccconfig.c
> @@ -636,8 +636,8 @@ int main(int argc, char **argv)
>  	if (!srcport)
>  		IBERROR("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
>  
> -	if (ib_resolve_portid_str_via(&portid, argv[1], ibd_dest_type,
> -				      ibd_sm_id, srcport) < 0)
> +	if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[1],
> +			       ibd_dest_type, ibd_sm_id, srcport) < 0)
>  		IBERROR("can't resolve destination %s", argv[1]);
>  	if ((err = fn(&portid, argv + 2, argc - 2)))
>  		IBERROR("operation %s: %s", argv[0], err);
> diff --git a/src/ibccquery.c b/src/ibccquery.c
> index cf8b35a..2bf62fa 100644
> --- a/src/ibccquery.c
> +++ b/src/ibccquery.c
> @@ -416,8 +416,8 @@ int main(int argc, char **argv)
>  	if (!srcport)
>  		IBERROR("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
>  
> -	if (ib_resolve_portid_str_via(&portid, argv[1], ibd_dest_type,
> -				      ibd_sm_id, srcport) < 0)
> +	if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[1],
> +			       ibd_dest_type, ibd_sm_id, srcport) < 0)
>  		IBERROR("can't resolve destination %s", argv[1]);
>  	if ((err = fn(&portid, argv + 2, argc - 2)))
>  		IBERROR("operation %s: %s", argv[0], err);
> diff --git a/src/ibdiag_common.c b/src/ibdiag_common.c
> index 6605362..5752f95 100644
> --- a/src/ibdiag_common.c
> +++ b/src/ibdiag_common.c
> @@ -255,8 +255,8 @@ static int process_opt(int ch, char *optarg)
>  		break;
>  	case 's':
>  		/* srcport is not required when resolving via IB_DEST_LID */
> -		if (ib_resolve_portid_str_via(&sm_portid, optarg, IB_DEST_LID,
> -					      0, NULL) < 0)
> +		if (resolve_portid_str(ibd_ca, ibd_ca_port, &sm_portid, optarg,
> +				IB_DEST_LID, 0, NULL) < 0)
>  			IBERROR("cannot resolve SM destination port %s",
>  				optarg);
>  		ibd_sm_id = &sm_portid;
> @@ -544,6 +544,120 @@ int resolve_self(char *ca_name, uint8_t ca_port, ib_portid_t *portid,
>  	return 0;
>  }
>  
> +int resolve_gid(char *ca_name, uint8_t ca_port, ib_portid_t * portid,
> +		ibmad_gid_t gid, ib_portid_t * sm_id,
> +		const struct ibmad_port *srcport)
> +{
> +	ib_portid_t sm_portid;
> +	char buf[IB_SA_DATA_SIZE] = { 0 };
> +
> +	if (!sm_id) {
> +		sm_id = &sm_portid;
> +		if (resolve_sm_portid(ca_name, ca_port, sm_id) < 0)
> +			return -1;
> +	}
> +
> +	if ((portid->lid =
> +	     ib_path_query_via(srcport, gid, gid, sm_id, buf)) < 0)
> +		return -1;
> +
> +	return 0;
> +}
> +
> +int resolve_guid(char *ca_name, uint8_t ca_port, ib_portid_t *portid,
> +		 uint64_t *guid, ib_portid_t *sm_id,
> +		 const struct ibmad_port *srcport)
> +{
> +	ib_portid_t sm_portid;
> +	uint8_t buf[IB_SA_DATA_SIZE] = { 0 };
> +	uint64_t prefix;
> +	ibmad_gid_t selfgid;
> +
> +	if (!sm_id) {
> +		sm_id = &sm_portid;
> +		if (resolve_sm_portid(ca_name, ca_port, sm_id) < 0)
> +			return -1;
> +	}
> +
> +	if (resolve_self(ca_name, ca_port, NULL, NULL, &selfgid) < 0)
> +		return -1;
> +
> +	memcpy(&prefix, portid->gid, sizeof(prefix));
> +	if (!prefix)
> +		mad_set_field64(portid->gid, 0, IB_GID_PREFIX_F,
> +				IB_DEFAULT_SUBN_PREFIX);
> +	if (guid)
> +		mad_set_field64(portid->gid, 0, IB_GID_GUID_F, *guid);
> +
> +	if ((portid->lid =
> +	     ib_path_query_via(srcport, selfgid, portid->gid, sm_id, buf)) < 0)
> +		return -1;
> +
> +	mad_decode_field(buf, IB_SA_PR_SL_F, &portid->sl);
> +	return 0;
> +}
> +
> +int resolve_portid_str(char *ca_name, uint8_t ca_port, ib_portid_t * portid,
> +		       char *addr_str, enum MAD_DEST dest_type,
> +		       ib_portid_t *sm_id, const struct ibmad_port *srcport)
> +{
> +	ibmad_gid_t gid;
> +	uint64_t guid;
> +	int lid;
> +	char *routepath;
> +	ib_portid_t selfportid = { 0 };
> +	int selfport = 0;
> +
> +	memset(portid, 0, sizeof *portid);
> +
> +	switch (dest_type) {
> +	case IB_DEST_LID:
> +		lid = strtol(addr_str, 0, 0);
> +		if (!IB_LID_VALID(lid))
> +			return -1;
> +		return ib_portid_set(portid, lid, 0, 0);
> +
> +	case IB_DEST_DRPATH:
> +		if (str2drpath(&portid->drpath, addr_str, 0, 0) < 0)
> +			return -1;
> +		return 0;
> +
> +	case IB_DEST_GUID:
> +		if (!(guid = strtoull(addr_str, 0, 0)))
> +			return -1;
> +
> +		/* keep guid in portid? */
> +		return resolve_guid(ca_name, ca_port, portid, &guid, sm_id,
> +				    srcport);
> +
> +	case IB_DEST_DRSLID:
> +		lid = strtol(addr_str, &routepath, 0);
> +		routepath++;
> +		if (!IB_LID_VALID(lid))
> +			return -1;
> +		ib_portid_set(portid, lid, 0, 0);
> +
> +		/* handle DR parsing and set DrSLID to local lid */
> +		if (resolve_self(ca_name, ca_port, &selfportid, &selfport,
> +				 NULL) < 0)
> +			return -1;
> +		if (str2drpath(&portid->drpath, routepath, selfportid.lid, 0) <
> +		    0)
> +			return -1;
> +		return 0;
> +
> +	case IB_DEST_GID:
> +		if (inet_pton(AF_INET6, addr_str, &gid) <= 0)
> +			return -1;
> +		return resolve_gid(ca_name, ca_port, portid, gid, sm_id,
> +				   srcport);
> +	default:
> +		IBWARN("bad dest_type %d", dest_type);
> +	}
> +
> +	return -1;
> +}
> +
>  /* define a common SA query structure
>   * This is by no means optimal but it moves the saquery functionality out of
>   * the saquery tool and provides it to other utilities.
> diff --git a/src/iblinkinfo.c b/src/iblinkinfo.c
> index 575be0a..36aa6d1 100644
> --- a/src/iblinkinfo.c
> +++ b/src/iblinkinfo.c
> @@ -649,15 +649,15 @@ int main(int argc, char **argv)
>  	if (dr_path) {
>  		/* only scan part of the fabric */
>  		if ((resolved =
> -		     ib_resolve_portid_str_via(&port_id, dr_path,
> -					       IB_DEST_DRPATH, NULL,
> -					       ibmad_port)) < 0)
> +		     resolve_portid_str(ibd_ca, ibd_ca_port, &port_id, dr_path,
> +					IB_DEST_DRPATH, NULL, ibmad_port)) < 0)
>  			IBWARN("Failed to resolve %s; attempting full scan",
>  			       dr_path);
>  	} else if (guid_str) {
>  		if ((resolved =
> -		     ib_resolve_portid_str_via(&port_id, guid_str, IB_DEST_GUID,
> -					       NULL, ibmad_port)) < 0)
> +		     resolve_portid_str(ibd_ca, ibd_ca_port, &port_id,
> +				        guid_str, IB_DEST_GUID, NULL,
> +					ibmad_port)) < 0)
>  			IBWARN("Failed to resolve %s; attempting full scan\n",
>  			       guid_str);
>  	}
> diff --git a/src/ibping.c b/src/ibping.c
> index 16ffb34..9d5c54b 100644
> --- a/src/ibping.c
> +++ b/src/ibping.c
> @@ -232,8 +232,8 @@ int main(int argc, char **argv)
>  		IBERROR("can't register ping class %d on this port",
>  			ping_class);
>  
> -	if (ib_resolve_portid_str_via(&portid, argv[0], ibd_dest_type,
> -				      ibd_sm_id, srcport) < 0)
> +	if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[0],
> +			       ibd_dest_type, ibd_sm_id, srcport) < 0)
>  		IBERROR("can't resolve destination port %s", argv[0]);
>  
>  	signal(SIGINT, report);
> diff --git a/src/ibportstate.c b/src/ibportstate.c
> index ac74dfd..5559d18 100644
> --- a/src/ibportstate.c
> +++ b/src/ibportstate.c
> @@ -376,8 +376,8 @@ int main(int argc, char **argv)
>  	if (!srcport)
>  		IBERROR("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
>  
> -	if (ib_resolve_portid_str_via(&portid, argv[0], ibd_dest_type,
> -				      ibd_sm_id, srcport) < 0)
> +	if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[0],
> +			       ibd_dest_type, ibd_sm_id, srcport) < 0)
>  		IBERROR("can't resolve destination port %s", argv[0]);
>  
>  	if (argc > 1)
> diff --git a/src/ibqueryerrors.c b/src/ibqueryerrors.c
> index f877527..4fec240 100644
> --- a/src/ibqueryerrors.c
> +++ b/src/ibqueryerrors.c
> @@ -931,14 +931,14 @@ int main(int argc, char **argv)
>  	/* limit the scan the fabric around the target */
>  	if (dr_path) {
>  		if ((resolved =
> -		     ib_resolve_portid_str_via(&portid, dr_path, IB_DEST_DRPATH,
> -					       NULL, ibmad_port)) < 0)
> +		     resolve_portid_str(ibd_ca, ibd_ca_port, &portid, dr_path,
> +					IB_DEST_DRPATH, NULL, ibmad_port)) < 0)
>  			IBWARN("Failed to resolve %s; attempting full scan",
>  			       dr_path);
>  	} else if (port_guid_str) {
>  		if ((resolved =
> -		     ib_resolve_portid_str_via(&portid, port_guid_str,
> -					       IB_DEST_GUID, ibd_sm_id,
> +		     resolve_portid_str(ibd_ca, ibd_ca_port, &portid,
> +					port_guid_str, IB_DEST_GUID, ibd_sm_id,
>  					       ibmad_port)) < 0)
>  			IBWARN("Failed to resolve %s; attempting full scan",
>  			       port_guid_str);
> diff --git a/src/ibroute.c b/src/ibroute.c
> index 1bf1fb0..faff34d 100644
> --- a/src/ibroute.c
> +++ b/src/ibroute.c
> @@ -432,8 +432,8 @@ int main(int argc, char **argv)
>  	if (!srcport)
>  		IBERROR("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
>  
> -	if (ib_resolve_portid_str_via(&portid, argv[0], ibd_dest_type,
> -					     ibd_sm_id, srcport) < 0)
> +	if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[0],
> +			       ibd_dest_type, ibd_sm_id, srcport) < 0)
>  		IBERROR("can't resolve destination port %s", argv[1]);
>  
>  	if (multicast)
> diff --git a/src/ibsysstat.c b/src/ibsysstat.c
> index f007aa3..2b11a06 100644
> --- a/src/ibsysstat.c
> +++ b/src/ibsysstat.c
> @@ -358,8 +358,8 @@ int main(int argc, char **argv)
>  	if (mad_register_client_via(sysstat_class, 1, srcport) < 0)
>  		IBERROR("can't register to sysstat class %d", sysstat_class);
>  
> -	if (ib_resolve_portid_str_via(&portid, argv[0], ibd_dest_type,
> -				      ibd_sm_id, srcport) < 0)
> +	if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[0],
> +			       ibd_dest_type, ibd_sm_id, srcport) < 0)
>  		IBERROR("can't resolve destination port %s", argv[0]);
>  
>  	if ((err = ibsystat(&portid, attr)))
> diff --git a/src/ibtracert.c b/src/ibtracert.c
> index c9f511b..e8fedf3 100644
> --- a/src/ibtracert.c
> +++ b/src/ibtracert.c
> @@ -776,12 +776,12 @@ int main(int argc, char **argv)
>  
>  	node_name_map = open_node_name_map(node_name_map_file);
>  
> -	if (ib_resolve_portid_str_via(&src_portid, argv[0], ibd_dest_type,
> -				      ibd_sm_id, srcport) < 0)
> +	if (resolve_portid_str(ibd_ca, ibd_ca_port, &src_portid, argv[0],
> +			       ibd_dest_type, ibd_sm_id, srcport) < 0)
>  		IBERROR("can't resolve source port %s", argv[0]);
>  
> -	if (ib_resolve_portid_str_via(&dest_portid, argv[1], ibd_dest_type,
> -				      ibd_sm_id, srcport) < 0)
> +	if (resolve_portid_str(ibd_ca, ibd_ca_port, &dest_portid, argv[1],
> +			       ibd_dest_type, ibd_sm_id, srcport) < 0)
>  		IBERROR("can't resolve destination port %s", argv[1]);
>  
>  	if (ibd_dest_type == IB_DEST_DRPATH) {
> diff --git a/src/perfquery.c b/src/perfquery.c
> index 7361c06..8835d3d 100644
> --- a/src/perfquery.c
> +++ b/src/perfquery.c
> @@ -730,8 +730,8 @@ int main(int argc, char **argv)
>  		IBERROR("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
>  
>  	if (argc) {
> -		if (ib_resolve_portid_str_via(&portid, argv[0], ibd_dest_type,
> -					      ibd_sm_id, srcport) < 0)
> +		if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[0],
> +				       ibd_dest_type, ibd_sm_id, srcport) < 0)
>  			IBERROR("can't resolve destination port %s", argv[0]);
>  	} else {
>  		if (resolve_self(ibd_ca, ibd_ca_port, &portid, &port, 0) < 0)
> diff --git a/src/sminfo.c b/src/sminfo.c
> index dfe0681..f1abc6a 100644
> --- a/src/sminfo.c
> +++ b/src/sminfo.c
> @@ -123,8 +123,8 @@ int main(int argc, char **argv)
>  		IBERROR("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
>  
>  	if (argc) {
> -		if (ib_resolve_portid_str_via(&portid, argv[0], ibd_dest_type,
> -					      0, srcport) < 0)
> +		if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[0],
> +				       ibd_dest_type, 0, srcport) < 0)
>  			IBERROR("can't resolve destination port %s", argv[0]);
>  	} else {
>  		if (resolve_sm_portid(ibd_ca, ibd_ca_port, &portid) < 0)
> diff --git a/src/smpquery.c b/src/smpquery.c
> index cecfa68..533b2c3 100644
> --- a/src/smpquery.c
> +++ b/src/smpquery.c
> @@ -483,8 +483,8 @@ int main(int argc, char **argv)
>  	node_name_map = open_node_name_map(node_name_map_file);
>  
>  	if (ibd_dest_type != IB_DEST_DRSLID) {
> -		if (ib_resolve_portid_str_via(&portid, argv[1], ibd_dest_type,
> -					      ibd_sm_id, srcport) < 0)
> +		if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[1],
> +				       ibd_dest_type, ibd_sm_id, srcport) < 0)
>  			IBERROR("can't resolve destination port %s", argv[1]);
>  		if ((err = fn(&portid, argv + 2, argc - 2)))
>  			IBERROR("operation %s: %s", argv[0], err);
> @@ -493,8 +493,8 @@ int main(int argc, char **argv)
>  
>  		memset(concat, 0, 64);
>  		snprintf(concat, sizeof(concat), "%s %s", argv[1], argv[2]);
> -		if (ib_resolve_portid_str_via(&portid, concat, ibd_dest_type,
> -					      ibd_sm_id, srcport) < 0)
> +		if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, concat,
> +				       ibd_dest_type, ibd_sm_id, srcport) < 0)
>  			IBERROR("can't resolve destination port %s", concat);
>  		if ((err = fn(&portid, argv + 3, argc - 3)))
>  			IBERROR("operation %s: %s", argv[0], err);
> diff --git a/src/vendstat.c b/src/vendstat.c
> index 059ceab..1d3d78c 100644
> --- a/src/vendstat.c
> +++ b/src/vendstat.c
> @@ -327,8 +327,8 @@ int main(int argc, char **argv)
>  		IBERROR("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
>  
>  	if (argc) {
> -		if (ib_resolve_portid_str_via(&portid, argv[0], ibd_dest_type,
> -					      ibd_sm_id, srcport) < 0)
> +		if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[0],
> +				       ibd_dest_type, ibd_sm_id, srcport) < 0)
>  			IBERROR("can't resolve destination port %s", argv[0]);
>  	} else {
>  		if (resolve_self(ibd_ca, ibd_ca_port, &portid, &port, 0) < 0)
> -- 
> 1.7.9.2
> 
> --
> 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


-- 
Ira Weiny
Member of Technical Staff
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] 10+ messages in thread

end of thread, other threads:[~2012-04-14  1:50 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-13  1:09 [PATCH 1/5] infiniband-diags/ibroute.c: Dead code removal Jim Foraker
     [not found] ` <1334279385-10792-1-git-send-email-foraker1-i2BcT+NCU+M@public.gmane.org>
2012-04-13  1:09   ` [PATCH 2/5] infiniband-diags/mcm_rereg_test.c: dead " Jim Foraker
     [not found]     ` <1334279385-10792-2-git-send-email-foraker1-i2BcT+NCU+M@public.gmane.org>
2012-04-14  1:40       ` Ira Weiny
2012-04-13  1:09   ` [PATCH 3/5] infiniband-diags/mcm_rereg_test.c: Include ib_types.h Jim Foraker
     [not found]     ` <1334279385-10792-3-git-send-email-foraker1-i2BcT+NCU+M@public.gmane.org>
2012-04-14  1:41       ` Ira Weiny
2012-04-13  1:09   ` [PATCH 4/5] infiniband-diags: Remove dependencies on ib_resolve_smlid/ib_resolve_self Jim Foraker
     [not found]     ` <1334279385-10792-4-git-send-email-foraker1-i2BcT+NCU+M@public.gmane.org>
2012-04-14  1:49       ` Ira Weiny
2012-04-13  1:09   ` [PATCH 5/5] infiniband-diags: migrate resolve_portid_str in from libibmad Jim Foraker
     [not found]     ` <1334279385-10792-5-git-send-email-foraker1-i2BcT+NCU+M@public.gmane.org>
2012-04-14  1:50       ` Ira Weiny
2012-04-14  1:38   ` [PATCH 1/5] infiniband-diags/ibroute.c: Dead code removal Ira Weiny

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.