public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
To: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Subject: [PATCH 07/16] ibacm: convert logging in acm_util.c to acm_log
Date: Thu, 27 Mar 2014 22:50:01 -0700	[thread overview]
Message-ID: <1395985810-23822-8-git-send-email-sean.hefty@intel.com> (raw)
In-Reply-To: <1395985810-23822-1-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

From: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

ib_acme build defines ACME_PRINTS which overrides acm_log to printf

Signed-off-by: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 Makefile.am    |    2 +-
 src/acm.c      |    6 ++----
 src/acm_util.c |   21 +++++++++------------
 src/acm_util.h |   12 ++++++++++++
 4 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 539ef83..703030d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -8,7 +8,7 @@ svc_ibacm_SOURCES = src/acm.c
 util_ib_acme_SOURCES = src/acme.c linux/acme_linux.c src/libacm.c linux/libacm_linux.c \
 			src/parse.c src/acm_util.c
 svc_ibacm_CFLAGS = $(AM_CFLAGS)
-util_ib_acme_CFLAGS = $(AM_CFLAGS)
+util_ib_acme_CFLAGS = $(AM_CFLAGS) -DACME_PRINTS
 
 ibacmincludedir = $(includedir)/infiniband
 
diff --git a/src/acm.c b/src/acm.c
index 82f9431..5dc2684 100644
--- a/src/acm.c
+++ b/src/acm.c
@@ -47,6 +47,7 @@
 #include <dlist.h>
 #include <search.h>
 #include "acm_mad.h"
+#include "acm_util.h"
 
 #define src_out     data[0]
 
@@ -245,10 +246,7 @@ static uint8_t min_rate = IBV_RATE_10_GBPS;
 static enum acm_route_preload route_preload;
 static enum acm_addr_preload addr_preload;
 
-#define acm_log(level, format, ...) \
-	acm_write(level, "%s: "format, __func__, ## __VA_ARGS__)
-
-static void acm_write(int level, const char *format, ...)
+void acm_write(int level, const char *format, ...)
 {
 	va_list args;
 	struct timeval tv;
diff --git a/src/acm_util.c b/src/acm_util.c
index 922eceb..7a84ac7 100644
--- a/src/acm_util.c
+++ b/src/acm_util.c
@@ -52,7 +52,7 @@ int acm_if_is_ib(char *ifname)
 	snprintf(buf, sizeof buf, "//sys//class//net//%s//type", ifname);
 	f = fopen(buf, "r");
 	if (!f) {
-		printf("failed to open %s\n", buf);
+		acm_log(0, "failed to open %s\n", buf);
 		return 0;
 	}
 
@@ -60,6 +60,7 @@ int acm_if_is_ib(char *ifname)
 		type = strtol(buf, NULL, 0);
 		ret = (type == ARPHRD_INFINIBAND);
 	} else {
+		acm_log(0, "failed to read interface type\n");
 		ret = 0;
 	}
 
@@ -76,7 +77,7 @@ int acm_if_get_pkey(char *ifname, uint16_t *pkey)
 	snprintf(buf, sizeof buf, "//sys//class//net//%s//pkey", ifname);
 	f = fopen(buf, "r");
 	if (!f) {
-		printf("failed to open %s\n", buf);
+		acm_log(0, "failed to open %s\n", buf);
 		return -1;
 	}
 
@@ -84,7 +85,7 @@ int acm_if_get_pkey(char *ifname, uint16_t *pkey)
 		*pkey = strtol(buf, &end, 16);
 		ret = 0;
 	} else {
-		printf("failed to read pkey\n");
+		acm_log(0, "failed to read pkey\n");
 		ret = -1;
 	}
 
@@ -101,7 +102,7 @@ int acm_if_get_sgid(char *ifname, union ibv_gid *sgid)
 	snprintf(buf, sizeof buf, "//sys//class//net//%s//address", ifname);
 	f = fopen(buf, "r");
 	if (!f) {
-		printf("failed to open %s\n", buf);
+		acm_log(0, "failed to open %s\n", buf);
 		return -1;
 	}
 
@@ -112,7 +113,7 @@ int acm_if_get_sgid(char *ifname, union ibv_gid *sgid)
 		}
 		ret = 0;
 	} else {
-		printf("failed to read sgid\n");
+		acm_log(0, "failed to read sgid\n");
 		ret = -1;
 	}
 
@@ -146,7 +147,7 @@ int acm_if_iter_sys(acm_if_iter_cb cb, void *ctx)
 
 	ret = ioctl(s, SIOCGIFCONF, ifc);
 	if (ret < 0) {
-		printf("ioctl ifconf error %d\n", ret);
+		acm_log(0, "ioctl ifconf error %d\n", ret);
 		goto out2;
 	}
 
@@ -169,16 +170,12 @@ int acm_if_iter_sys(acm_if_iter_cb cb, void *ctx)
 			continue;
 
 		ret = acm_if_get_sgid(ifr[i].ifr_name, &sgid);
-		if (ret) {
-			printf("unable to get sgid\n");
+		if (ret)
 			continue;
-		}
 
 		ret = acm_if_get_pkey(ifr[i].ifr_name, &pkey);
-		if (ret) {
-			printf("unable to get pkey\n");
+		if (ret)
 			continue;
-		}
 
 		cb(ifr[i].ifr_name, &sgid, pkey, 0, NULL, 0, ip, ctx);
 	}
diff --git a/src/acm_util.h b/src/acm_util.h
index ea86133..4f111b6 100644
--- a/src/acm_util.h
+++ b/src/acm_util.h
@@ -32,6 +32,18 @@
 
 #include <infiniband/verbs.h>
 
+#ifdef ACME_PRINTS
+
+#define acm_log(level, format, ...) \
+	printf(format, ## __VA_ARGS__)
+
+#else /* !ACME_PRINTS */
+#define acm_log(level, format, ...) \
+	acm_write(level, "%s: "format, __func__, ## __VA_ARGS__)
+
+void acm_write(int level, const char *format, ...);
+#endif /* ACME_PRINTS */
+
 int acm_if_is_ib(char *ifname);
 int acm_if_get_pkey(char *ifname, uint16_t *pkey);
 int acm_if_get_sgid(char *ifname, union ibv_gid *sgid);
-- 
1.7.3

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

  parent reply	other threads:[~2014-03-28  5:50 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-28  5:49 [PATCH 00/16] ibacm: Implement dynamic IP support sean.hefty-ral2JQCrhuEAvxtiuMwx3w
     [not found] ` <1395985810-23822-1-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-03-28  5:49   ` [PATCH 01/16] ibacm: get_devaddr remove unused variable from signature sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-28  5:49   ` [PATCH 02/16] ibacm: pass interface name rather than 'struct ifreq' to get_devaddr, get_sgid, and get_pkey sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-28  5:49   ` [PATCH 03/16] ibacm: use sysfs (in acm_if_is_ib) rather than ioctl(... SIOCGIFHWADDR ...) to read interface type sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-28  5:49   ` [PATCH 04/16] ibacm: move sysfs helper functions to acm_util 'module' sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-28  5:49   ` [PATCH 05/16] ibacm: Move calling of helper functions out of get_devaddr sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-28  5:50   ` [PATCH 06/16] ibacm: move acm_if_iter_sys to acm_util.c sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-28  5:50   ` sean.hefty-ral2JQCrhuEAvxtiuMwx3w [this message]
2014-03-28  5:50   ` [PATCH 08/16] ibacm: add separate acm_ep_insert_addr function sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-28  5:50   ` [PATCH 09/16] ibacm: read system IP's into endpoints at startup sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-28  5:50   ` [PATCH 10/16] ibacm: add locking around end point address arrays sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-28  5:50   ` [PATCH 11/16] ibacm: Add thread to monitor IP address changes sean.hefty-ral2JQCrhuEAvxtiuMwx3w
     [not found]     ` <1395985810-23822-12-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-03-28  6:43       ` Bart Van Assche
     [not found]         ` <53351A0D.1010007-HInyCGIudOg@public.gmane.org>
2014-03-28 15:51           ` Weiny, Ira
     [not found]             ` <2807E5FD2F6FDA4886F6618EAC48510E04B34C7A-8k97q/ur5Z2krb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-03-28 16:23               ` Bart Van Assche
2014-03-28  5:50   ` [PATCH 12/16] ibacm: add/remove addr's in EP's when added/removed from the system sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-28  5:50   ` [PATCH 13/16] ibacm: fix handling of aliased IPoIB devices sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-28  5:50   ` [PATCH 14/16] ibacm: ib_acme remove IP addresses from ibacm_addr.cfg file generation sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-28  5:50   ` [PATCH 15/16] ibacm: remove acm_if_iter_sys function sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-28  5:50   ` [PATCH 16/16] ibacm: remove processing of IP's from ibacm_addr.cfg sean.hefty-ral2JQCrhuEAvxtiuMwx3w
     [not found]     ` <1395985810-23822-17-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-03-28 16:37       ` Hefty, Sean

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=1395985810-23822-8-git-send-email-sean.hefty@intel.com \
    --to=sean.hefty-ral2jqcrhueavxtiumwx3w@public.gmane.org \
    --cc=ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@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