[ofa-general] [PATCH v3 1/3] Create a new library libibnetdisc

Ira Weiny weiny2 at llnl.gov
Thu Apr 23 15:09:43 PDT 2009


On Thu, 23 Apr 2009 14:29:54 -0700
"Sean Hefty" <sean.hefty at intel.com> wrote:

> >There is also an ibdebug defined in libibmad.
> >
> >extern int ibdebug;
> >
> >This is the one it is using...  :-/  I think there should be a wrapper
> >function.  Perhaps madrpc_show_errors?
> 
> Yes - that's the one it picks up.  Adding a wrapper makes sense to me.  (I don't
> think that declaring a variable as extern is sufficient to share it across
> library boundaries in windows.)
> 

Patch below.

From: Ira Weiny <weiny2 at llnl.gov>
Date: Thu, 23 Apr 2009 15:08:28 -0700
Subject: [PATCH] libibmad: create a wrapper for ibdebug and make libibnetdisc

use it

Signed-off-by: Ira Weiny <weiny2 at llnl.gov>
---
 infiniband-diags/libibnetdisc/src/ibnetdisc.c |    7 +++++--
 infiniband-diags/libibnetdisc/src/internal.h  |    2 +-
 libibmad/include/infiniband/mad.h             |    3 +--
 libibmad/src/gs.c                             |    1 +
 libibmad/src/libibmad.map                     |    1 +
 libibmad/src/mad_internal.h                   |    2 ++
 libibmad/src/portid.c                         |    1 +
 libibmad/src/rpc.c                            |    5 +++++
 8 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/infiniband-diags/libibnetdisc/src/ibnetdisc.c b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
index 410e2dd..cee4c95 100644
--- a/infiniband-diags/libibnetdisc/src/ibnetdisc.c
+++ b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
@@ -59,6 +59,7 @@
 
 static int timeout_ms = 2000;
 static int show_progress = 0;
+static int ibnd_debug_flg = 0;
 
 void
 decode_port_info(ibnd_port_t *port)
@@ -638,11 +639,13 @@ void
 ibnd_debug(int i)
 {
 	if (i) {
-		ibdebug++;
+		ibnd_debug_flg = 1;
+		madrpc_show_debug(1);
 		madrpc_show_errors(1);
 		umad_debug(i);
 	} else {
-		ibdebug = 0;
+		ibnd_debug_flg = 0;
+		madrpc_show_debug(0);
 		madrpc_show_errors(0);
 		umad_debug(0);
 	}
diff --git a/infiniband-diags/libibnetdisc/src/internal.h b/infiniband-diags/libibnetdisc/src/internal.h
index 4e6bb18..58ba2a8 100644
--- a/infiniband-diags/libibnetdisc/src/internal.h
+++ b/infiniband-diags/libibnetdisc/src/internal.h
@@ -43,7 +43,7 @@
 #define MAXHOPS		63
 
 #define	IBND_DEBUG(fmt, ...) \
-	if (ibdebug) { \
+	if (ibnd_debug_flg) { \
 		printf("%s:%u; " fmt, __FILE__, __LINE__, ## __VA_ARGS__); \
 	}
 #define	IBND_ERROR(fmt, ...) \
diff --git a/libibmad/include/infiniband/mad.h b/libibmad/include/infiniband/mad.h
index b6f4b60..1fbbf1c 100644
--- a/libibmad/include/infiniband/mad.h
+++ b/libibmad/include/infiniband/mad.h
@@ -733,6 +733,7 @@ MAD_EXPORT int mad_build_pkt(void *umad, ib_rpc_t * rpc, ib_portid_t * dport,
 
 /* New interface */
 MAD_EXPORT void madrpc_show_errors(int set);
+MAD_EXPORT void madrpc_show_debug(int set);
 MAD_EXPORT int madrpc_set_retries(int retries);
 MAD_EXPORT int madrpc_set_timeout(int timeout);
 MAD_EXPORT struct ibmad_port *mad_rpc_open_port(char *dev_name, int dev_port,
@@ -892,8 +893,6 @@ MAD_EXPORT ib_mad_dump_fn
     mad_dump_switchinfo, mad_dump_perfcounters, mad_dump_perfcounters_ext,
     mad_dump_perfcounters_xmt_sl, mad_dump_perfcounters_rcv_sl;
 
-extern int ibdebug;
-
 #if __BYTE_ORDER == __LITTLE_ENDIAN
 #ifndef ntohll
 static inline uint64_t ntohll(uint64_t x)
diff --git a/libibmad/src/gs.c b/libibmad/src/gs.c
index dbca9e9..eea4a29 100644
--- a/libibmad/src/gs.c
+++ b/libibmad/src/gs.c
@@ -41,6 +41,7 @@
 
 #include <infiniband/umad.h>
 #include <infiniband/mad.h>
+#include "mad_internal.h"
 
 #undef DEBUG
 #define DEBUG 	if (ibdebug)	IBWARN
diff --git a/libibmad/src/libibmad.map b/libibmad/src/libibmad.map
index 6b77784..67c32bb 100644
--- a/libibmad/src/libibmad.map
+++ b/libibmad/src/libibmad.map
@@ -80,6 +80,7 @@ IBMAD_1.3 {
 		madrpc_set_retries;
 		madrpc_set_timeout;
 		madrpc_show_errors;
+		madrpc_show_debug;
 		ib_path_query;
 		sa_call;
 		sa_rpc_call;
diff --git a/libibmad/src/mad_internal.h b/libibmad/src/mad_internal.h
index 24418cc..0038197 100644
--- a/libibmad/src/mad_internal.h
+++ b/libibmad/src/mad_internal.h
@@ -44,4 +44,6 @@ struct ibmad_port {
 
 extern struct ibmad_port *ibmp;
 
+extern int ibdebug;
+
 #endif /* _MAD_INTERNAL_H_ */
diff --git a/libibmad/src/portid.c b/libibmad/src/portid.c
index de9e2d3..773fa5b 100644
--- a/libibmad/src/portid.c
+++ b/libibmad/src/portid.c
@@ -40,6 +40,7 @@
 #include <string.h>
 
 #include <infiniband/mad.h>
+#include "mad_internal.h"
 
 #undef DEBUG
 #define DEBUG	if (ibdebug)	IBWARN
diff --git a/libibmad/src/rpc.c b/libibmad/src/rpc.c
index ebeb835..78e68a8 100644
--- a/libibmad/src/rpc.c
+++ b/libibmad/src/rpc.c
@@ -72,6 +72,11 @@ void madrpc_show_errors(int set)
 	iberrs = set;
 }
 
+void madrpc_show_debug(int set)
+{
+	ibdebug = set;
+}
+
 void madrpc_save_mad(void *madbuf, int len)
 {
 	save_mad = madbuf;
-- 
1.5.4.5




More information about the general mailing list