net/cxgbe: implement dynamic log type
authorStephen Hemminger <stephen@networkplumber.org>
Tue, 16 Jul 2019 18:53:31 +0000 (11:53 -0700)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 27 Aug 2019 08:29:50 +0000 (10:29 +0200)
The generic RTE_LOGTYPE_PMD is a historical relic and should
be deprecated. Every driver must register its own logtype.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
drivers/net/cxgbe/cxgbe_compat.h
drivers/net/cxgbe/cxgbe_ethdev.c

index cce51c2..93df0a7 100644 (file)
 #include <rte_io.h>
 #include <rte_net.h>
 
+extern int cxgbe_logtype;
+
 #define dev_printf(level, fmt, ...) \
-       RTE_LOG(level, PMD, "rte_cxgbe_pmd: " fmt, ##__VA_ARGS__)
+       rte_log(RTE_LOG_ ## level, cxgbe_logtype, \
+               "rte_cxgbe_pmd: " fmt, ##__VA_ARGS__)
 
 #define dev_err(x, fmt, ...) dev_printf(ERR, fmt, ##__VA_ARGS__)
 #define dev_info(x, fmt, ...) dev_printf(INFO, fmt, ##__VA_ARGS__)
@@ -63,7 +66,7 @@
 
 #ifdef RTE_LIBRTE_CXGBE_DEBUG
 #define CXGBE_FUNC_TRACE() \
-       RTE_LOG(DEBUG, PMD, "CXGBE trace: %s\n", __func__)
+       dev_printf(DEBUG, "CXGBE trace: %s\n", __func__)
 #else
 #define CXGBE_FUNC_TRACE() do { } while (0)
 #endif
index 3a373ec..efb458d 100644 (file)
@@ -38,6 +38,8 @@
 #include "cxgbe_pfvf.h"
 #include "cxgbe_flow.h"
 
+int cxgbe_logtype;
+
 /*
  * Macros needed to support the PCI Device ID Table ...
  */
@@ -1218,3 +1220,10 @@ RTE_PMD_REGISTER_KMOD_DEP(net_cxgbe, "* igb_uio | uio_pci_generic | vfio-pci");
 RTE_PMD_REGISTER_PARAM_STRING(net_cxgbe,
                              CXGBE_DEVARG_KEEP_OVLAN "=<0|1> "
                              CXGBE_DEVARG_FORCE_LINK_UP "=<0|1> ");
+
+RTE_INIT(cxgbe_init_log)
+{
+       cxgbe_logtype = rte_log_register("pmd.net.cxgbe");
+       if (cxgbe_logtype >= 0)
+               rte_log_set_level(cxgbe_logtype, RTE_LOG_NOTICE);
+}