DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: shepard.siegel@atomicrules.com, ed.czeck@atomicrules.com,
	john.miller@atomicrules.com
Cc: dev@dpdk.org, Stephen Hemminger <stephen@networkplumber.org>
Subject: [dpdk-dev] [PATCH] net/ark: implement dynamic log type
Date: Tue, 16 Jul 2019 11:55:30 -0700	[thread overview]
Message-ID: <20190716185530.20508-1-stephen@networkplumber.org> (raw)

The generic RTE_LOGTYPE_PMD is a historical relic and should
will be deprecated in near future. Every driver must register its own logtype.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/ark/ark_ethdev.c |  9 +++++++++
 drivers/net/ark/ark_logs.h   | 25 ++++++++++++++-----------
 2 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c
index 86e500ecb30c..630f78118355 100644
--- a/drivers/net/ark/ark_ethdev.c
+++ b/drivers/net/ark/ark_ethdev.c
@@ -78,6 +78,8 @@ static int  eth_ark_set_mtu(struct rte_eth_dev *dev, uint16_t size);
 #define ARK_TX_MAX_QUEUE (4096 * 4)
 #define ARK_TX_MIN_QUEUE (256)
 
+int ark_logtype;
+
 static const char * const valid_arguments[] = {
 	ARK_PKTGEN_ARG,
 	ARK_PKTCHKR_ARG,
@@ -1007,3 +1009,10 @@ RTE_PMD_REGISTER_PARAM_STRING(net_ark,
 			      ARK_PKTGEN_ARG "=<filename> "
 			      ARK_PKTCHKR_ARG "=<filename> "
 			      ARK_PKTDIR_ARG "=<bitmap>");
+
+RTE_INIT(ark_init_log)
+{
+	ark_logtype = rte_log_register("pmd.net.ark");
+	if (ark_logtype >= 0)
+		rte_log_set_level(ark_logtype, RTE_LOG_NOTICE);
+}
diff --git a/drivers/net/ark/ark_logs.h b/drivers/net/ark/ark_logs.h
index b90e9f0ac9ad..44aac6102ffa 100644
--- a/drivers/net/ark/ark_logs.h
+++ b/drivers/net/ark/ark_logs.h
@@ -26,29 +26,32 @@
 #define ARK_SU64X "\n\t%-20s    %#20" PRIx64
 #define ARK_SPTR  "\n\t%-20s    %20p"
 
-
+extern int ark_logtype;
 
 #define PMD_DRV_LOG(level, fmt, args...)	\
-	RTE_LOG(level, PMD, fmt, ## args)
+	rte_log(RTE_LOG_ ##level, ark_logtype, fmt, ## args)
 
 /* Conditional trace definitions */
-#define ARK_TRACE_ON(level, fmt, ...)		\
-	RTE_LOG(level, PMD, fmt, ##__VA_ARGS__)
+#define ARK_TRACE_ON(level, fmt, args...) \
+	PMD_DRV_LOG(level, fmt, ## args)
 
 /* This pattern allows compiler check arguments even if disabled  */
-#define ARK_TRACE_OFF(level, fmt, ...)					\
-	do {if (0) RTE_LOG(level, PMD, fmt, ##__VA_ARGS__); }		\
-	while (0)
-
+#define ARK_TRACE_OFF(level, fmt, args...)			\
+	do {							\
+		if (0)						\
+			PMD_DRV_LOG(level, fmt, ## args);	\
+	} while (0)
 
 /* tracing including the function name */
 #define ARK_FUNC_ON(level, fmt, args...) \
-	RTE_LOG(level, PMD, "%s(): " fmt, __func__, ## args)
+	PMD_DRV_LOG(level, "%s(): " fmt, __func__, ## args)
 
 /* tracing including the function name */
 #define ARK_FUNC_OFF(level, fmt, args...)				\
-	do { if (0) RTE_LOG(level, PMD, "%s(): " fmt, __func__, ## args); } \
-	while (0)
+	do {								\
+		if (0)							\
+			PMD_DRV_LOG(level, "%s(): " fmt, __func__, ## args); \
+	} while (0)
 
 
 /* Debug macro for tracing full behavior, function tracing and messages*/
-- 
2.20.1


             reply	other threads:[~2019-07-16 18:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-16 18:55 Stephen Hemminger [this message]
2019-08-27  8:45 ` Ferruh Yigit

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=20190716185530.20508-1-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=ed.czeck@atomicrules.com \
    --cc=john.miller@atomicrules.com \
    --cc=shepard.siegel@atomicrules.com \
    /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;
as well as URLs for NNTP newsgroup(s).