From c563443c646449179f04ab981fafdad8cbc01252 Mon Sep 17 00:00:00 2001 From: Pavan Nikhilesh Date: Tue, 19 Dec 2017 17:55:06 +0530 Subject: [PATCH] net/thunderx: implement dynamic logging Signed-off-by: Pavan Nikhilesh Acked-by: Santosh Shukla Acked-by: Stephen Hemminger --- config/common_base | 3 -- drivers/net/thunderx/nicvf_ethdev.c | 21 ++++++++++++++ drivers/net/thunderx/nicvf_logs.h | 43 +++++++++++------------------ 3 files changed, 37 insertions(+), 30 deletions(-) diff --git a/config/common_base b/config/common_base index 071bd0ec10..ba164584c3 100644 --- a/config/common_base +++ b/config/common_base @@ -301,11 +301,8 @@ CONFIG_RTE_LIBRTE_PMD_SZEDATA2_AS=0 # Compile burst-oriented Cavium Thunderx NICVF PMD driver # CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD=y -CONFIG_RTE_LIBRTE_THUNDERX_NICVF_DEBUG_INIT=n CONFIG_RTE_LIBRTE_THUNDERX_NICVF_DEBUG_RX=n CONFIG_RTE_LIBRTE_THUNDERX_NICVF_DEBUG_TX=n -CONFIG_RTE_LIBRTE_THUNDERX_NICVF_DEBUG_DRIVER=n -CONFIG_RTE_LIBRTE_THUNDERX_NICVF_DEBUG_MBOX=n # # Compile burst-oriented Cavium LiquidIO PMD driver diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c index 72dc8ae24b..d03619f1d2 100644 --- a/drivers/net/thunderx/nicvf_ethdev.c +++ b/drivers/net/thunderx/nicvf_ethdev.c @@ -43,11 +43,32 @@ #include "nicvf_svf.h" #include "nicvf_logs.h" +int nicvf_logtype_mbox; +int nicvf_logtype_init; +int nicvf_logtype_driver; + static void nicvf_dev_stop(struct rte_eth_dev *dev); static void nicvf_dev_stop_cleanup(struct rte_eth_dev *dev, bool cleanup); static void nicvf_vf_stop(struct rte_eth_dev *dev, struct nicvf *nic, bool cleanup); +RTE_INIT(nicvf_init_log); +static void +nicvf_init_log(void) +{ + nicvf_logtype_mbox = rte_log_register("pmd.nicvf.mbox"); + if (nicvf_logtype_mbox >= 0) + rte_log_set_level(nicvf_logtype_mbox, RTE_LOG_NOTICE); + + nicvf_logtype_init = rte_log_register("pmd.nicvf.init"); + if (nicvf_logtype_init >= 0) + rte_log_set_level(nicvf_logtype_init, RTE_LOG_NOTICE); + + nicvf_logtype_driver = rte_log_register("pmd.nicvf.driver"); + if (nicvf_logtype_driver >= 0) + rte_log_set_level(nicvf_logtype_driver, RTE_LOG_NOTICE); +} + static inline int nicvf_atomic_write_link_status(struct rte_eth_dev *dev, struct rte_eth_link *link) diff --git a/drivers/net/thunderx/nicvf_logs.h b/drivers/net/thunderx/nicvf_logs.h index f7174a403b..3c455b4288 100644 --- a/drivers/net/thunderx/nicvf_logs.h +++ b/drivers/net/thunderx/nicvf_logs.h @@ -7,49 +7,38 @@ #include -#define PMD_INIT_LOG(level, fmt, args...) \ - RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args) - -#ifdef RTE_LIBRTE_THUNDERX_NICVF_DEBUG_INIT -#define PMD_INIT_FUNC_TRACE() PMD_INIT_LOG(DEBUG, ">>") -#else -#define PMD_INIT_FUNC_TRACE() do { } while (0) -#endif - #ifdef RTE_LIBRTE_THUNDERX_NICVF_DEBUG_RX -#define PMD_RX_LOG(level, fmt, args...) \ - RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args) #define NICVF_RX_ASSERT(x) assert(x) #else -#define PMD_RX_LOG(level, fmt, args...) do { } while (0) #define NICVF_RX_ASSERT(x) do { } while (0) #endif #ifdef RTE_LIBRTE_THUNDERX_NICVF_DEBUG_TX -#define PMD_TX_LOG(level, fmt, args...) \ - RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args) #define NICVF_TX_ASSERT(x) assert(x) #else -#define PMD_TX_LOG(level, fmt, args...) do { } while (0) #define NICVF_TX_ASSERT(x) do { } while (0) #endif -#ifdef RTE_LIBRTE_THUNDERX_NICVF_DEBUG_DRIVER +#define PMD_INIT_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, nicvf_logtype_init, \ + "%s(): " fmt "\n", __func__, ## args) +#define PMD_INIT_FUNC_TRACE() PMD_INIT_LOG(DEBUG, ">>") + #define PMD_DRV_LOG(level, fmt, args...) \ - RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args) + rte_log(RTE_LOG_ ## level, nicvf_logtype_driver, \ + "%s(): " fmt "\n", __func__, ## args) #define PMD_DRV_FUNC_TRACE() PMD_DRV_LOG(DEBUG, ">>") -#else -#define PMD_DRV_LOG(level, fmt, args...) do { } while (0) -#define PMD_DRV_FUNC_TRACE() do { } while (0) -#endif -#ifdef RTE_LIBRTE_THUNDERX_NICVF_DEBUG_MBOX #define PMD_MBOX_LOG(level, fmt, args...) \ - RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args) + rte_log(RTE_LOG_ ## level, nicvf_logtype_mbox, \ + "%s(): " fmt "\n", __func__, ## args) #define PMD_MBOX_FUNC_TRACE() PMD_DRV_LOG(DEBUG, ">>") -#else -#define PMD_MBOX_LOG(level, fmt, args...) do { } while (0) -#define PMD_MBOX_FUNC_TRACE() do { } while (0) -#endif + +#define PMD_RX_LOG PMD_DRV_LOG +#define PMD_TX_LOG PMD_DRV_LOG + +extern int nicvf_logtype_init; +extern int nicvf_logtype_driver; +extern int nicvf_logtype_mbox; #endif /* __THUNDERX_NICVF_LOGS__ */ -- 2.20.1