net/fm10k: implement dynamic logging
authorStephen Hemminger <stephen@networkplumber.org>
Tue, 19 Dec 2017 06:38:37 +0000 (22:38 -0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 16 Jan 2018 17:47:49 +0000 (18:47 +0100)
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
config/common_base
drivers/net/fm10k/fm10k_ethdev.c
drivers/net/fm10k/fm10k_logs.h

index 3aad34b..0cdaade 100644 (file)
@@ -213,11 +213,9 @@ CONFIG_RTE_LIBRTE_I40E_ITR_INTERVAL=-1
 # Compile burst-oriented FM10K PMD
 #
 CONFIG_RTE_LIBRTE_FM10K_PMD=y
-CONFIG_RTE_LIBRTE_FM10K_DEBUG_INIT=n
 CONFIG_RTE_LIBRTE_FM10K_DEBUG_RX=n
 CONFIG_RTE_LIBRTE_FM10K_DEBUG_TX=n
 CONFIG_RTE_LIBRTE_FM10K_DEBUG_TX_FREE=n
-CONFIG_RTE_LIBRTE_FM10K_DEBUG_DRIVER=n
 CONFIG_RTE_LIBRTE_FM10K_RX_OLFLAGS_ENABLE=y
 CONFIG_RTE_LIBRTE_FM10K_INC_VECTOR=y
 
index c823372..3db21ad 100644 (file)
@@ -40,6 +40,9 @@
 #define GLORT_FD_MASK    GLORT_PF_MASK
 #define GLORT_FD_INDEX   GLORT_FD_Q_BASE
 
+int fm10k_logtype_init;
+int fm10k_logtype_driver;
+
 static void fm10k_close_mbx_service(struct fm10k_hw *hw);
 static void fm10k_dev_promiscuous_enable(struct rte_eth_dev *dev);
 static void fm10k_dev_promiscuous_disable(struct rte_eth_dev *dev);
@@ -3233,3 +3236,15 @@ static struct rte_pci_driver rte_pmd_fm10k = {
 RTE_PMD_REGISTER_PCI(net_fm10k, rte_pmd_fm10k);
 RTE_PMD_REGISTER_PCI_TABLE(net_fm10k, pci_id_fm10k_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_fm10k, "* igb_uio | uio_pci_generic | vfio-pci");
+
+RTE_INIT(fm10k_init_log);
+static void
+fm10k_init_log(void)
+{
+       fm10k_logtype_init = rte_log_register("pmd.fm10k.init");
+       if (fm10k_logtype_init >= 0)
+               rte_log_set_level(fm10k_logtype_init, RTE_LOG_NOTICE);
+       fm10k_logtype_driver = rte_log_register("pmd.fm10k.driver");
+       if (fm10k_logtype_driver >= 0)
+               rte_log_set_level(fm10k_logtype_driver, RTE_LOG_NOTICE);
+}
index ab8303c..df56a51 100644 (file)
@@ -7,14 +7,12 @@
 
 #include <rte_log.h>
 
+extern int fm10k_logtype_init;
 #define PMD_INIT_LOG(level, fmt, args...) \
-       RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ##args)
+       rte_log(RTE_LOG_ ## level, fm10k_logtype_init, \
+               "%s(): " fmt "\n", __func__, ##args)
 
-#ifdef RTE_LIBRTE_FM10K_DEBUG_INIT
 #define PMD_INIT_FUNC_TRACE() PMD_INIT_LOG(DEBUG, " >>")
-#else
-#define PMD_INIT_FUNC_TRACE() do { } while (0)
-#endif
 
 #ifdef RTE_LIBRTE_FM10K_DEBUG_RX
 #define PMD_RX_LOG(level, fmt, args...) \
 #define PMD_TX_FREE_LOG(level, fmt, args...) do { } while (0)
 #endif
 
-#ifdef RTE_LIBRTE_FM10K_DEBUG_DRIVER
+extern int fm10k_logtype_driver;
 #define PMD_DRV_LOG_RAW(level, fmt, args...) \
-       RTE_LOG(level, PMD, "%s(): " fmt, __func__, ## args)
-#else
-#define PMD_DRV_LOG_RAW(level, fmt, args...) do { } while (0)
-#endif
+       rte_log(RTE_LOG_ ## level, fm10k_logtype_driver, "%s(): " fmt, \
+               __func__, ## args)
 
 #define PMD_DRV_LOG(level, fmt, args...) \
        PMD_DRV_LOG_RAW(level, fmt "\n", ## args)