From: Stephen Hemminger Date: Tue, 19 Dec 2017 06:38:32 +0000 (-0800) Subject: net/vmxnet3: implement dynamic logging X-Git-Tag: spdx-start~505 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=79daffdcb6ac086e14704fc97e78d79b50dcb73f;p=dpdk.git net/vmxnet3: implement dynamic logging Replace compile time configuration with runtime. Signed-off-by: Stephen Hemminger --- diff --git a/config/common_base b/config/common_base index 5d40feded7..1dcccb3db4 100644 --- a/config/common_base +++ b/config/common_base @@ -379,11 +379,9 @@ CONFIG_RTE_VIRTIO_USER=n # Compile burst-oriented VMXNET3 PMD driver # CONFIG_RTE_LIBRTE_VMXNET3_PMD=y -CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_INIT=n CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_RX=n CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_TX=n CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_TX_FREE=n -CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_DRIVER=n # # Compile example software rings based PMD diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c index c2f12cdf2a..537e8ddd3a 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethdev.c +++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c @@ -77,6 +77,9 @@ static void vmxnet3_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr); static void vmxnet3_interrupt_handler(void *param); +int vmxnet3_logtype_init; +int vmxnet3_logtype_driver; + /* * The set of PCI devices this driver supports */ @@ -1345,3 +1348,15 @@ vmxnet3_interrupt_handler(void *param) RTE_PMD_REGISTER_PCI(net_vmxnet3, rte_vmxnet3_pmd); RTE_PMD_REGISTER_PCI_TABLE(net_vmxnet3, pci_id_vmxnet3_map); RTE_PMD_REGISTER_KMOD_DEP(net_vmxnet3, "* igb_uio | uio_pci_generic | vfio-pci"); + +RTE_INIT(vmxnet3_init_log); +static void +vmxnet3_init_log(void) +{ + vmxnet3_logtype_init = rte_log_register("pmd.vmxnet3.init"); + if (vmxnet3_logtype_init >= 0) + rte_log_set_level(vmxnet3_logtype_init, RTE_LOG_NOTICE); + vmxnet3_logtype_driver = rte_log_register("pmd.vmxnet3.driver"); + if (vmxnet3_logtype_driver >= 0) + rte_log_set_level(vmxnet3_logtype_driver, RTE_LOG_NOTICE); +} diff --git a/drivers/net/vmxnet3/vmxnet3_logs.h b/drivers/net/vmxnet3/vmxnet3_logs.h index 95252a9335..74154e3a1a 100644 --- a/drivers/net/vmxnet3/vmxnet3_logs.h +++ b/drivers/net/vmxnet3/vmxnet3_logs.h @@ -5,14 +5,11 @@ #ifndef _VMXNET3_LOGS_H_ #define _VMXNET3_LOGS_H_ -#ifdef RTE_LIBRTE_VMXNET3_DEBUG_INIT +extern int vmxnet3_logtype_init; #define PMD_INIT_LOG(level, fmt, args...) \ - RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args) + rte_log(RTE_LOG_ ## level, vmxnet3_logtype_driver, \ + "%s(): " fmt "\n", __func__, ## args) #define PMD_INIT_FUNC_TRACE() PMD_INIT_LOG(DEBUG, " >>") -#else -#define PMD_INIT_LOG(level, fmt, args...) do { } while(0) -#define PMD_INIT_FUNC_TRACE() do { } while(0) -#endif #ifdef RTE_LIBRTE_VMXNET3_DEBUG_RX #define PMD_RX_LOG(level, fmt, args...) \ @@ -35,11 +32,9 @@ #define PMD_TX_FREE_LOG(level, fmt, args...) do { } while(0) #endif -#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER +extern int vmxnet3_logtype_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, vmxnet3_logtype_driver, \ + "%s(): " fmt "\n", __func__, ## args) #endif /* _VMXNET3_LOGS_H_ */