From 4d35a276c1dd7a1a131bb0d321e28b6802160b12 Mon Sep 17 00:00:00 2001 From: Pavan Nikhilesh Date: Tue, 19 Dec 2017 17:55:07 +0530 Subject: [PATCH] net/octeontx: implement dynamic logging Signed-off-by: Pavan Nikhilesh Acked-by: Santosh Shukla Acked-by: Stephen Hemminger --- config/common_base | 5 --- drivers/net/octeontx/octeontx_ethdev.c | 21 ++++++++++++ drivers/net/octeontx/octeontx_logs.h | 44 ++++++++------------------ 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/config/common_base b/config/common_base index ba164584c3..e58f041f9c 100644 --- a/config/common_base +++ b/config/common_base @@ -322,11 +322,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 e4753c6846..7b73817e57 100644 --- a/drivers/net/octeontx/octeontx_ethdev.c +++ b/drivers/net/octeontx/octeontx_ethdev.c @@ -38,6 +38,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 7040f4f9ad..ccb8a1b0ab 100644 --- a/drivers/net/octeontx/octeontx_logs.h +++ b/drivers/net/octeontx/octeontx_logs.h @@ -6,44 +6,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__*/ -- 2.20.1