diff mbox

[dpdk-dev,2/5] net/octeontx: implement dynamic logging

Message ID 20171219122510.15004-3-pbhagavatula@caviumnetworks.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Pavan Nikhilesh Dec. 19, 2017, 12:25 p.m. UTC
Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
---
 config/common_base                     |  5 ----
 drivers/net/octeontx/octeontx_ethdev.c | 21 +++++++++++++++++
 drivers/net/octeontx/octeontx_logs.h   | 42 +++++++++++-----------------------
 3 files changed, 34 insertions(+), 34 deletions(-)

Comments

Santosh Shukla Jan. 1, 2018, 4:37 a.m. UTC | #1
On Tuesday 19 December 2017 05:55 PM, Pavan Nikhilesh wrote:
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
> ---

nits:
s / otx_net_init_log / octeontx_net_init_log

Rest LGTM,
Acked-by: Santosh Shukla <santosh.shukla@caviumnetworks.com>
diff mbox

Patch

diff --git a/config/common_base b/config/common_base
index 65d51d6da..fc6b6d157 100644
--- a/config/common_base
+++ b/config/common_base
@@ -333,11 +333,6 @@  CONFIG_RTE_LIBRTE_DPAA_PMD=n
 # Compile burst-oriented Cavium OCTEONTX network PMD driver
 #
 CONFIG_RTE_LIBRTE_OCTEONTX_PMD=y
-CONFIG_RTE_LIBRTE_OCTEONTX_DEBUG_INIT=n
-CONFIG_RTE_LIBRTE_OCTEONTX_DEBUG_RX=n
-CONFIG_RTE_LIBRTE_OCTEONTX_DEBUG_TX=n
-CONFIG_RTE_LIBRTE_OCTEONTX_DEBUG_DRIVER=n
-CONFIG_RTE_LIBRTE_OCTEONTX_DEBUG_MBOX=n
 
 #
 # Compile NXP DPAA2 FSL-MC Bus
diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c
index bd24ec330..a5f8451ab 100644
--- a/drivers/net/octeontx/octeontx_ethdev.c
+++ b/drivers/net/octeontx/octeontx_ethdev.c
@@ -65,6 +65,27 @@  enum octeontx_link_speed {
 	OCTEONTX_LINK_SPEED_RESERVE2
 };
 
+int otx_net_logtype_mbox;
+int otx_net_logtype_init;
+int otx_net_logtype_driver;
+
+RTE_INIT(otx_net_init_log);
+static void
+otx_net_init_log(void)
+{
+	otx_net_logtype_mbox = rte_log_register("pmd.otx.ethdev.mbox");
+	if (otx_net_logtype_mbox >= 0)
+		rte_log_set_level(otx_net_logtype_mbox, RTE_LOG_NOTICE);
+
+	otx_net_logtype_init = rte_log_register("pmd.otx.ethdev.init");
+	if (otx_net_logtype_init >= 0)
+		rte_log_set_level(otx_net_logtype_init, RTE_LOG_NOTICE);
+
+	otx_net_logtype_driver = rte_log_register("pmd.otx.ethdev.driver");
+	if (otx_net_logtype_driver >= 0)
+		rte_log_set_level(otx_net_logtype_driver, RTE_LOG_NOTICE);
+}
+
 /* Parse integer from integer argument */
 static int
 parse_integer_arg(const char *key __rte_unused,
diff --git a/drivers/net/octeontx/octeontx_logs.h b/drivers/net/octeontx/octeontx_logs.h
index d5da73311..533746d69 100644
--- a/drivers/net/octeontx/octeontx_logs.h
+++ b/drivers/net/octeontx/octeontx_logs.h
@@ -33,44 +33,28 @@ 
 #define __OCTEONTX_LOGS_H__
 
 #define PMD_INIT_LOG(level, fmt, args...) \
-	RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args)
+	rte_log(RTE_LOG_ ## level, otx_net_logtype_init, \
+			"%s(): " fmt "\n", __func__, ## args)
 
-#ifdef RTE_LIBRTE_OCTEONTX_DEBUG_INIT
 #define PMD_INIT_FUNC_TRACE() PMD_INIT_LOG(DEBUG, ">>")
-#else
-#define PMD_INIT_FUNC_TRACE() do { } while (0)
-#endif
 
-#ifdef RTE_LIBRTE_OCTEONTX_DEBUG_RX
-#define PMD_RX_LOG(level, fmt, args...) \
-	RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args)
-#else
-#define PMD_RX_LOG(level, fmt, args...) do { } while (0)
-#endif
-
-#ifdef RTE_LIBRTE_OCTEONTX_DEBUG_TX
-#define PMD_TX_LOG(level, fmt, args...) \
-	RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args)
-#else
-#define PMD_TX_LOG(level, fmt, args...) do { } while (0)
-#endif
-
-#ifdef RTE_LIBRTE_OCTEONTX_DEBUG_DRIVER
 #define PMD_DRV_LOG(level, fmt, args...) \
-	RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args)
-#else
-#define PMD_DRV_LOG(level, fmt, args...) do { } while (0)
-#endif
+	rte_log(RTE_LOG_ ## level, otx_net_logtype_driver, \
+			"%s(): " fmt "\n", __func__, ## args)
 
-#ifdef RTE_LIBRTE_OCTEONTX_DEBUG_MBOX
 #define PMD_MBOX_LOG(level, fmt, args...) \
-	RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args)
-#else
-#define PMD_MBOX_LOG(level, fmt, args...) do { } while (0)
-#endif
+	rte_log(RTE_LOG_ ## level, otx_net_logtype_mbox, \
+			"%s(): " fmt "\n", __func__, ## args)
 
 #define octeontx_log_err(s, ...) PMD_INIT_LOG(ERR, s, ##__VA_ARGS__)
 #define octeontx_log_dbg(s, ...) PMD_DRV_LOG(DEBUG, s, ##__VA_ARGS__)
 #define octeontx_mbox_log(s, ...) PMD_MBOX_LOG(DEBUG, s, ##__VA_ARGS__)
 
+#define PMD_RX_LOG	PMD_DRV_LOG
+#define PMD_TX_LOG	PMD_DRV_LOG
+
+extern int otx_net_logtype_init;
+extern int otx_net_logtype_driver;
+extern int otx_net_logtype_mbox;
+
 #endif /* __OCTEONTX_LOGS_H__*/