public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Boris Chiu <boris.chiu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
To: Ira Weiny <iweiny-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
	Boris Chiu <boris.chiu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Brendan Doyle -Oracle Ireland
	<brendan.doyle-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>,
	Pramod Gunjikar
	<Pramod.Gunjikar-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>,
	"Ted H. Kim" <ted.h.kim-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>,
	David Brean <david.brean-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>,
	Eric Schlesinger
	<Eric.Schlesinger-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>,
	Lii Chen <lii.chen-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Subject: libibmad : submitting six patches on behalf of Oracle IB development
Date: Fri, 01 Mar 2013 12:34:48 -0800	[thread overview]
Message-ID: <513110E8.909@oracle.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 144 bytes --]

Hi Ira,

We (Oracle IB development) are submitting six patches against

libibmad

Please review our submission of changes.

Many thanks,
Boris


[-- Attachment #2: 0001-libibmad-Conversion-specifier-m-is-not-supported-on-.patch --]
[-- Type: text/plain, Size: 2311 bytes --]

From 02fc55c756819cee8bdcfe6c192780bcbdbbfe5d Mon Sep 17 00:00:00 2001
From: Brendan Doyle <brendan.doyle@oracle.com>
Date: Fri, 1 Mar 2013 12:08:33 -0800
Subject: [PATCH] libibmad: Conversion specifier; %m is not supported on Solaris

Signed-off-by: Brendan Doyle <brendan.doyle@oracle.com>
---
 src/rpc.c  |    4 ++--
 src/serv.c |    7 ++++---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/rpc.c b/src/rpc.c
index 6312d42..4fb5a21 100644
--- a/src/rpc.c
+++ b/src/rpc.c
@@ -153,7 +153,7 @@ _do_madrpc(int port_id, void *sndbuf, void *rcvbuf, int agentid, int len,
 
 		length = len;
 		if (umad_send(port_id, agentid, sndbuf, length, timeout, 0) < 0) {
-			IBWARN("send failed; %m");
+			IBWARN("send failed; %s", strerror(errno));
 			return -1;
 		}
 
@@ -162,7 +162,7 @@ _do_madrpc(int port_id, void *sndbuf, void *rcvbuf, int agentid, int len,
 		do {
 			length = len;
 			if (umad_recv(port_id, rcvbuf, &length, timeout) < 0) {
-				IBWARN("recv failed: %m");
+				IBWARN("recv failed: %s", strerror(errno));
 				return -1;
 			}
 
diff --git a/src/serv.c b/src/serv.c
index 2e3b7ef..ae5fd6c 100644
--- a/src/serv.c
+++ b/src/serv.c
@@ -38,6 +38,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <errno.h>
 
 #include <infiniband/umad.h>
 #include <infiniband/mad.h>
@@ -75,7 +76,7 @@ int mad_send_via(ib_rpc_t * rpc, ib_portid_t * dport, ib_rmpp_hdr_t * rmpp,
 	if (umad_send(srcport->port_id, srcport->class_agents[rpc->mgtclass & 0xff],
 		      umad, IB_MAD_SIZE, mad_get_timeout(srcport, rpc->timeout),
 		      0) < 0) {
-		IBWARN("send failed; %m");
+		IBWARN("send failed; %s", strerror(errno));
 		return -1;
 	}
 
@@ -157,7 +158,7 @@ int mad_respond_via(void *umad, ib_portid_t * portid, uint32_t rstatus,
 	if (umad_send
 	    (srcport->port_id, srcport->class_agents[rpc.mgtclass], umad,
 	     IB_MAD_SIZE, mad_get_timeout(srcport, rpc.timeout), 0) < 0) {
-		DEBUG("send failed; %m");
+		DEBUG("send failed; %s", strerror(errno));
 		return -1;
 	}
 
@@ -179,7 +180,7 @@ void *mad_receive_via(void *umad, int timeout, struct ibmad_port *srcport)
 			       mad_get_timeout(srcport, timeout))) < 0) {
 		if (!umad)
 			umad_free(mad);
-		DEBUG("recv failed: %m");
+		DEBUG("recv failed: %s", strerror(errno));
 		return 0;
 	}
 
-- 
1.7.1


[-- Attachment #3: 0001-libibmad-Fixes-for-failures-when-not-all-ports-of-HC.patch --]
[-- Type: text/plain, Size: 2988 bytes --]

From a049380678565212ffa6519e80c187820cb0db08 Mon Sep 17 00:00:00 2001
From: Brendan Doyle <brendan.doyle@oracle.com>
Date: Fri, 1 Mar 2013 11:56:38 -0800
Subject: [PATCH] libibmad: Fixes for failures when not all ports of HCA are connected

Signed-off-by: Brendan Doyle <brendan.doyle@oracle.com>
---
 src/resolve.c |   22 ++++++++++++++++++----
 src/rpc.c     |    1 +
 src/sa.c      |    2 ++
 3 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/resolve.c b/src/resolve.c
index f866bf4..ab24c79 100644
--- a/src/resolve.c
+++ b/src/resolve.c
@@ -40,6 +40,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <arpa/inet.h>
+#include <errno.h>
 
 #include <infiniband/umad.h>
 #include <infiniband/mad.h>
@@ -57,10 +58,18 @@ int ib_resolve_smlid_via(ib_portid_t * sm_id, int timeout,
 
 	memset(sm_id, 0, sizeof(*sm_id));
 
-	if (!smp_query_via(portinfo, &self, IB_ATTR_PORT_INFO, 0, 0, srcport))
+	if (!smp_query_via(portinfo, &self, IB_ATTR_PORT_INFO, 0, 0, srcport)) {
+		if (!errno)
+			errno = EIO;
 		return -1;
+	}
 
 	mad_decode_field(portinfo, IB_PORT_SMLID_F, &lid);
+	if (lid == 0) {
+		if (!errno)
+			errno = EIO;
+		return -1;
+	}
 	mad_decode_field(portinfo, IB_PORT_SMSL_F, &sm_id->sl);
 
 	return ib_portid_set(sm_id, lid, 0, 0);
@@ -95,21 +104,26 @@ int ib_resolve_guid_via(ib_portid_t * portid, uint64_t * guid,
 			ib_portid_t * sm_id, int timeout,
 			const struct ibmad_port *srcport)
 {
-	ib_portid_t sm_portid;
+	ib_portid_t sm_portid = { 0 };
 	uint8_t buf[IB_SA_DATA_SIZE] = { 0 };
 	ib_portid_t self = { 0 };
 	uint64_t selfguid, prefix;
 	ibmad_gid_t selfgid;
 	uint8_t nodeinfo[64];
 
-	if (!sm_id) {
+	if (!sm_id)
 		sm_id = &sm_portid;
+
+	if (!sm_id->lid) {
 		if (ib_resolve_smlid_via(sm_id, timeout, srcport) < 0)
 			return -1;
 	}
 
-	if (!smp_query_via(nodeinfo, &self, IB_ATTR_NODE_INFO, 0, 0, srcport))
+	if (!smp_query_via(nodeinfo, &self, IB_ATTR_NODE_INFO, 0, 0, srcport)) {
+		if (!errno)
+			errno = EIO;
 		return -1;
+	}
 	mad_decode_field(nodeinfo, IB_NODE_PORT_GUID_F, &selfguid);
 	mad_set_field64(selfgid, 0, IB_GID_PREFIX_F, IB_DEFAULT_SUBN_PREFIX);
 	mad_set_field64(selfgid, 0, IB_GID_GUID_F, selfguid);
diff --git a/src/rpc.c b/src/rpc.c
index 6312d42..cf2b60d 100644
--- a/src/rpc.c
+++ b/src/rpc.c
@@ -178,6 +178,7 @@ _do_madrpc(int port_id, void *sndbuf, void *rcvbuf, int agentid, int len,
 					 IB_MAD_TRID_F) != trid);
 
 		status = umad_status(rcvbuf);
+		errno = status;
 		if (!status)
 			return length;	/* done */
 		if (status == ENOMEM)
diff --git a/src/sa.c b/src/sa.c
index 352ed9f..367da2a 100644
--- a/src/sa.c
+++ b/src/sa.c
@@ -38,6 +38,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <errno.h>
 
 #include <infiniband/mad.h>
 #include "mad_internal.h"
@@ -56,6 +57,7 @@ uint8_t *sa_rpc_call(const struct ibmad_port *ibmad_port, void *rcvbuf,
 
 	if (portid->lid <= 0) {
 		IBWARN("only lid routes are supported");
+		errno = EIO;
 		return NULL;
 	}
 
-- 
1.7.1


[-- Attachment #4: 0001-libibmad-To-fix-big-endian-problem-for-both-32-bit-6.patch --]
[-- Type: text/plain, Size: 4468 bytes --]

From 10777e75ff9f01f70ed2537667a4797c3b30cc1d Mon Sep 17 00:00:00 2001
From: Brendan Doyle <brendan.doyle@oracle.com>
Date: Fri, 1 Mar 2013 11:32:45 -0800
Subject: [PATCH] libibmad: To fix big endian problem for both 32-bit & 64-bit SPARC

Signed-off-by: Brendan Doyle <brendan.doyle@oracle.com>
---
 src/dump.c |   66 +++++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 57 insertions(+), 9 deletions(-)

diff --git a/src/dump.c b/src/dump.c
index 7f3ef7d..e83c363 100644
--- a/src/dump.c
+++ b/src/dump.c
@@ -46,12 +46,24 @@
 
 void mad_dump_int(char *buf, int bufsz, void *val, int valsz)
 {
+	/*
+	 * the val pointer passed to the dump routines are always 32 bit
+	 * integers for valsz <= 4 and 64 bit integer for the rest. It is never
+	 * uint8_t or uint16_t. This is because mad_decode_field always returns
+	 * the values as 32 bit integer even if they are 8 bit or 16 bit fields.
+	 */
 	switch (valsz) {
 	case 1:
-		snprintf(buf, bufsz, "%d", *(uint32_t *) val & 0xff);
+#if defined(_BIG_ENDIAN)
+		val = ((uint8_t *)val) + 3;
+#endif /* _BIG_ENDIAN */
+		snprintf(buf, bufsz, "%d", *(uint8_t *) val & 0xff);
 		break;
 	case 2:
-		snprintf(buf, bufsz, "%d", *(uint32_t *) val & 0xffff);
+#if defined(_BIG_ENDIAN)
+		val = ((uint16_t *)val) + 1;
+#endif /* _BIG_ENDIAN */
+		snprintf(buf, bufsz, "%d", *(uint16_t *) val & 0xffff);
 		break;
 	case 3:
 	case 4:
@@ -71,12 +83,24 @@ void mad_dump_int(char *buf, int bufsz, void *val, int valsz)
 
 void mad_dump_uint(char *buf, int bufsz, void *val, int valsz)
 {
+	/*
+	 * the val pointer passed to the dump routines are always 32 bit
+	 * integers for valsz <= 4 and 64 bit integer for the rest. It is never
+	 * uint8_t or uint16_t. This is because mad_decode_field always returns
+	 * the values as 32 bit integer even if they are 8 bit or 16 bit fields.
+	 */
 	switch (valsz) {
 	case 1:
-		snprintf(buf, bufsz, "%u", *(uint32_t *) val & 0xff);
+#if defined(_BIG_ENDIAN)
+		val = ((uint8_t *)val) + 3;
+#endif /* _BIG_ENDIAN */
+		snprintf(buf, bufsz, "%u", *(uint8_t *) val & 0xff);
 		break;
 	case 2:
-		snprintf(buf, bufsz, "%u", *(uint32_t *) val & 0xffff);
+#if defined(_BIG_ENDIAN)
+		val = ((uint16_t *)val) + 1;
+#endif /* _BIG_ENDIAN */
+		snprintf(buf, bufsz, "%u", *(uint16_t *) val & 0xffff);
 		break;
 	case 3:
 	case 4:
@@ -96,15 +120,27 @@ void mad_dump_uint(char *buf, int bufsz, void *val, int valsz)
 
 void mad_dump_hex(char *buf, int bufsz, void *val, int valsz)
 {
+	/*
+	 * the val pointer passed to the dump routines are always 32 bit
+	 * integers for valsz <= 4 and 64 bit integer for the rest. It is never
+	 * uint8_t or uint16_t. This is because mad_decode_field always returns
+	 * the values as 32 bit integer even if they are 8 bit or 16 bit fields.
+	 */
 	switch (valsz) {
 	case 1:
-		snprintf(buf, bufsz, "0x%02x", *(uint32_t *) val & 0xff);
+#if defined(_BIG_ENDIAN)
+		val = ((uint8_t *)val) + 3;
+#endif /* _BIG_ENDIAN */
+		snprintf(buf, bufsz, "0x%02x", *(uint8_t *) val & 0xff);
 		break;
 	case 2:
-		snprintf(buf, bufsz, "0x%04x", *(uint32_t *) val & 0xffff);
+#if defined(_BIG_ENDIAN)
+		val = ((uint16_t *)val) + 1;
+#endif /* _BIG_ENDIAN */
+		snprintf(buf, bufsz, "0x%04x", *(uint16_t *) val & 0xffff);
 		break;
 	case 3:
-		snprintf(buf, bufsz, "0x%06x", *(uint32_t *) val & 0xffffff);
+		snprintf(buf, bufsz, "0x%x", *(uint32_t *) val & 0xffffff);
 		break;
 	case 4:
 		snprintf(buf, bufsz, "0x%08x", *(uint32_t *) val);
@@ -132,12 +168,24 @@ void mad_dump_hex(char *buf, int bufsz, void *val, int valsz)
 
 void mad_dump_rhex(char *buf, int bufsz, void *val, int valsz)
 {
+	/*
+	 * the val pointer passed to the dump routines are always 32 bit
+	 * integers for valsz <= 4 and 64 bit integer for the rest. It is never
+	 * uint8_t or uint16_t. This is because mad_decode_field always returns
+	 * the values as 32 bit integer even if they are 8 bit or 16 bit fields.
+	 */
 	switch (valsz) {
 	case 1:
-		snprintf(buf, bufsz, "%02x", *(uint32_t *) val & 0xff);
+#if defined(_BIG_ENDIAN)
+		val = ((uint8_t *)val) + 3;
+#endif /* _BIG_ENDIAN */
+		snprintf(buf, bufsz, "%02x", *(uint8_t *) val & 0xff);
 		break;
 	case 2:
-		snprintf(buf, bufsz, "%04x", *(uint32_t *) val & 0xffff);
+#if defined(_BIG_ENDIAN)
+		val = ((uint16_t *)val) + 1;
+#endif /* _BIG_ENDIAN */
+		snprintf(buf, bufsz, "%04x", *(uint16_t *) val & 0xffff);
 		break;
 	case 3:
 		snprintf(buf, bufsz, "%06x", *(uint32_t *) val & 0xffffff);
-- 
1.7.1


[-- Attachment #5: 0001-libibmad-To-fix-compilation-warning-need-typecasts.patch --]
[-- Type: text/plain, Size: 2466 bytes --]

From 752534aab51380d72d77bcab6f38673ab01dda20 Mon Sep 17 00:00:00 2001
From: Brendan Doyle <brendan.doyle@oracle.com>
Date: Fri, 1 Mar 2013 12:18:45 -0800
Subject: [PATCH] libibmad: To fix compilation warning: need typecasts

Signed-off-by: Brendan Doyle <brendan.doyle@oracle.com>
---
 include/infiniband/mad.h |   12 ++++++++----
 src/fields.c             |    8 ++++----
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/include/infiniband/mad.h b/include/infiniband/mad.h
index 02b2353..cefcc54 100644
--- a/include/infiniband/mad.h
+++ b/include/infiniband/mad.h
@@ -1655,14 +1655,18 @@ static inline uint64_t htonll(uint64_t x)
 #define ALIGN(l, size) (((l) + ((size) - 1)) / (size) * (size))
 
 /** printf style warning MACRO, includes name of function and pid */
-#define IBWARN(fmt, ...) fprintf(stderr, "ibwarn: [%d] %s: " fmt "\n", getpid(), __func__, ## __VA_ARGS__)
+#define IBWARN(fmt, ...) fprintf(stderr, "ibwarn: [%d] %s: " fmt "\n", \
+(int)getpid(), __func__, ## __VA_ARGS__)
 
-#define IBDEBUG(fmt, ...) fprintf(stdout, "ibdebug: [%d] %s: " fmt "\n", getpid(), __func__, ## __VA_ARGS__)
+#define IBDEBUG(fmt, ...) fprintf(stdout, "ibdebug: [%d] %s: " fmt "\n", \
+(int)getpid(), __func__, ## __VA_ARGS__)
 
-#define IBVERBOSE(fmt, ...) fprintf(stdout, "[%d] %s: " fmt "\n", getpid(), __func__, ## __VA_ARGS__)
+#define IBVERBOSE(fmt, ...) fprintf(stdout, "[%d] %s: " fmt "\n", \
+(int)getpid(), __func__, ## __VA_ARGS__)
 
 #define IBPANIC(fmt, ...) do { \
-	fprintf(stderr, "ibpanic: [%d] %s: " fmt ": %m\n", getpid(), __func__, ## __VA_ARGS__); \
+	fprintf(stderr, "ibpanic: [%d] %s: " fmt ": %m\n", \
+	(int)getpid(), __func__, ## __VA_ARGS__); \
 	exit(-1); \
 } while(0)
 
diff --git a/src/fields.c b/src/fields.c
index d2b6792..33a6364 100644
--- a/src/fields.c
+++ b/src/fields.c
@@ -959,15 +959,15 @@ static void _set_field64(void *buf, int base_offs, const ib_field_t * f,
 	uint64_t nval;
 
 	nval = htonll(val);
-	memcpy((char *)buf + base_offs + f->bitoffs / 8, &nval,
-	       sizeof(uint64_t));
+	memcpy(((void *)(char *)buf + base_offs + f->bitoffs / 8),
+		(void *)&nval, sizeof(uint64_t));
 }
 
 static uint64_t _get_field64(void *buf, int base_offs, const ib_field_t * f)
 {
 	uint64_t val;
-	memcpy(&val, ((char *)buf + base_offs + f->bitoffs / 8),
-	       sizeof(uint64_t));
+	memcpy((void *)&val, (void *)((char *)buf + base_offs + f->bitoffs / 8),
+		sizeof(uint64_t));
 	return ntohll(val);
 }
 
-- 
1.7.1


[-- Attachment #6: 0001-libibmad-To-handle-null-dev_name-in-madrpc_init.patch --]
[-- Type: text/plain, Size: 899 bytes --]

From 6d84f42e0865bca646060d23ba0f3c70295d2a7e Mon Sep 17 00:00:00 2001
From: Brendan Doyle <brendan.doyle@oracle.com>
Date: Fri, 1 Mar 2013 12:12:43 -0800
Subject: [PATCH] libibmad: To handle null dev_name in madrpc_init

Signed-off-by: Brendan Doyle <brendan.doyle@oracle.com>
---
 src/rpc.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/rpc.c b/src/rpc.c
index 6312d42..cb224fd 100644
--- a/src/rpc.c
+++ b/src/rpc.c
@@ -360,7 +360,8 @@ madrpc_init(char *dev_name, int dev_port, int *mgmt_classes, int num_classes)
 		IBPANIC("can't init UMAD library");
 
 	if ((fd = umad_open_port(dev_name, dev_port)) < 0)
-		IBPANIC("can't open UMAD port (%s:%d)", dev_name, dev_port);
+		IBPANIC("can't open UMAD port (%s:%d)",
+		dev_name ? dev_name : "(nil)", dev_port);
 
 	if (num_classes >= MAX_CLASS)
 		IBPANIC("too many classes %d requested", num_classes);
-- 
1.7.1


[-- Attachment #7: 0001-libibmad-To-reserve-upper-8-bits-of-tid-used-by-sola.patch --]
[-- Type: text/plain, Size: 679 bytes --]

From 42b18c6c33e774b399753504a447b0022f0315df Mon Sep 17 00:00:00 2001
From: Brendan Doyle <brendan.doyle@oracle.com>
Date: Fri, 1 Mar 2013 12:16:09 -0800
Subject: [PATCH] libibmad: To reserve upper 8 bits of tid used by solaris SRIOV driver

Signed-off-by: Brendan Doyle <brendan.doyle@oracle.com>
---
 src/mad.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/mad.c b/src/mad.c
index 70a69dd..fb5f5eb 100644
--- a/src/mad.c
+++ b/src/mad.c
@@ -62,6 +62,9 @@ uint64_t mad_trid(void)
 		trid = random();
 	}
 	next = ++trid | (base << 32);
+#if defined(__SVR4) && defined(__sun)
+	next &= 0x00ffffffffffffff;
+#endif
 	return next;
 }
 
-- 
1.7.1


             reply	other threads:[~2013-03-01 20:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-01 20:34 Boris Chiu [this message]
  -- strict thread matches above, loose matches on Subject: below --
2013-02-27 21:23 libibmad : submitting six patches on behalf of Oracle IB development Boris Chiu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=513110E8.909@oracle.com \
    --to=boris.chiu-qhclzuegtsvqt0dzr+alfa@public.gmane.org \
    --cc=Eric.Schlesinger-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
    --cc=Pramod.Gunjikar-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
    --cc=brendan.doyle-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
    --cc=david.brean-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
    --cc=ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=iweiny-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=lii.chen-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=ted.h.kim-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox