net/thunderx: implement dynamic logging
authorPavan Nikhilesh <pbhagavatula@caviumnetworks.com>
Tue, 19 Dec 2017 12:25:06 +0000 (17:55 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 16 Jan 2018 17:47:49 +0000 (18:47 +0100)
Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
Acked-by: Santosh Shukla <santosh.shukla@caviumnetworks.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
config/common_base
drivers/net/thunderx/nicvf_ethdev.c
drivers/net/thunderx/nicvf_logs.h

index 071bd0e..ba16458 100644 (file)
@@ -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
index 72dc8ae..d03619f 100644 (file)
 #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)
index f7174a4..3c455b4 100644 (file)
@@ -7,49 +7,38 @@
 
 #include <assert.h>
 
-#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__ */