patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH 2/3] drivers: fix log level after loading
       [not found] <20210310140107.2730088-1-thomas@monjalon.net>
@ 2021-03-10 14:01 ` Thomas Monjalon
  2021-03-23 18:25   ` David Marchand
  2021-03-23 18:50   ` Ajit Khaparde
       [not found] ` <20210405100301.657768-1-thomas@monjalon.net>
       [not found] ` <20210406132204.1818522-1-thomas@monjalon.net>
  2 siblings, 2 replies; 5+ messages in thread
From: Thomas Monjalon @ 2021-03-10 14:01 UTC (permalink / raw)
  To: dev
  Cc: stable, Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko,
	Ajit Khaparde, Raveendra Padasalagi, Vikas Gupta, Jeff Guo,
	Haiyue Wang, Adam Dybkowski, Jerin Jacob, Akhil Goyal,
	Sachin Saxena

When compiled as a shared object, and loaded at runtime as a plugin,
the drivers should get the log level set earlier at EAL init
by the user through --log-level option.

The function for applying the log level setting is
rte_log_register_type_and_pick_level().
It is called by most drivers via RTE_LOG_REGISTER().

The drivers common/mlx5, bcmfs and e1000 were missing,
so the user-specified log level was not applied when
those drivers were loaded as plugins.
The macro RTE_LOG_REGISTER() is used for those drivers.

The unnecessary protection for double registration
is removed from e1000.

Fixes: 9c99878aa1b1 ("log: introduce logtype register macro")
Fixes: c8e79da7c676 ("crypto/bcmfs: introduce BCMFS driver")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 drivers/common/mlx5/mlx5_common.c |  9 +-----
 drivers/crypto/bcmfs/bcmfs_logs.c | 17 ++---------
 drivers/net/e1000/e1000_logs.c    | 49 ++++---------------------------
 drivers/net/e1000/em_ethdev.c     |  6 ----
 drivers/net/e1000/igb_ethdev.c    |  6 ----
 5 files changed, 8 insertions(+), 79 deletions(-)

diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c
index c26a2cfa30..f92f05bda5 100644
--- a/drivers/common/mlx5/mlx5_common.c
+++ b/drivers/common/mlx5/mlx5_common.c
@@ -14,8 +14,6 @@
 #include "mlx5_common_utils.h"
 #include "mlx5_common_pci.h"
 
-int mlx5_common_logtype;
-
 uint8_t haswell_broadwell_cpu;
 
 /* In case this is an x86_64 intel processor to check if
@@ -41,12 +39,7 @@ static inline void mlx5_cpu_id(unsigned int level,
 }
 #endif
 
-RTE_INIT_PRIO(mlx5_log_init, LOG)
-{
-	mlx5_common_logtype = rte_log_register("pmd.common.mlx5");
-	if (mlx5_common_logtype >= 0)
-		rte_log_set_level(mlx5_common_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(mlx5_common_logtype, pmd.common.mlx5, NOTICE)
 
 static bool mlx5_common_initialized;
 
diff --git a/drivers/crypto/bcmfs/bcmfs_logs.c b/drivers/crypto/bcmfs/bcmfs_logs.c
index 86f4ff3b53..701da9ecf3 100644
--- a/drivers/crypto/bcmfs/bcmfs_logs.c
+++ b/drivers/crypto/bcmfs/bcmfs_logs.c
@@ -8,9 +8,6 @@
 
 #include "bcmfs_logs.h"
 
-int bcmfs_conf_logtype;
-int bcmfs_dp_logtype;
-
 int
 bcmfs_hexdump_log(uint32_t level, uint32_t logtype, const char *title,
 		const void *buf, unsigned int len)
@@ -24,15 +21,5 @@ bcmfs_hexdump_log(uint32_t level, uint32_t logtype, const char *title,
 	return 0;
 }
 
-RTE_INIT(bcmfs_device_init_log)
-{
-	/* Configuration and general logs */
-	bcmfs_conf_logtype = rte_log_register("pmd.bcmfs_config");
-	if (bcmfs_conf_logtype >= 0)
-		rte_log_set_level(bcmfs_conf_logtype, RTE_LOG_NOTICE);
-
-	/* data-path logs */
-	bcmfs_dp_logtype = rte_log_register("pmd.bcmfs_fp");
-	if (bcmfs_dp_logtype >= 0)
-		rte_log_set_level(bcmfs_dp_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(bcmfs_conf_logtype, pmd.bcmfs_config, NOTICE)
+RTE_LOG_REGISTER(bcmfs_dp_logtype, pmd.bcmfs_fp, NOTICE)
diff --git a/drivers/net/e1000/e1000_logs.c b/drivers/net/e1000/e1000_logs.c
index 231f5c03ef..d9b8a4672f 100644
--- a/drivers/net/e1000/e1000_logs.c
+++ b/drivers/net/e1000/e1000_logs.c
@@ -4,53 +4,14 @@
 
 #include "e1000_logs.h"
 
-/* declared as extern in e1000_logs.h */
-int e1000_logtype_init;
-int e1000_logtype_driver;
-
+RTE_LOG_REGISTER(e1000_logtype_init, pmd.net.e1000.init, NOTICE)
+RTE_LOG_REGISTER(e1000_logtype_driver, pmd.net.e1000.driver, NOTICE)
 #ifdef RTE_LIBRTE_E1000_DEBUG_RX
-int e1000_logtype_rx;
+RTE_LOG_REGISTER(e1000_logtype_rx, pmd.net.e1000.rx, DEBUG)
 #endif
 #ifdef RTE_LIBRTE_E1000_DEBUG_TX
-int e1000_logtype_tx;
+RTE_LOG_REGISTER(e1000_logtype_tx, pmd.net.e1000.tx, DEBUG)
 #endif
 #ifdef RTE_LIBRTE_E1000_DEBUG_TX_FREE
-int e1000_logtype_tx_free;
+RTE_LOG_REGISTER(e1000_logtype_tx_free, pmd.net.e1000.tx_free, DEBUG)
 #endif
-
-/* avoids double registering of logs if EM and IGB drivers are in use */
-static int e1000_log_initialized;
-
-void
-e1000_igb_init_log(void)
-{
-	if (e1000_log_initialized)
-		return;
-
-	e1000_logtype_init = rte_log_register("pmd.net.e1000.init");
-	if (e1000_logtype_init >= 0)
-		rte_log_set_level(e1000_logtype_init, RTE_LOG_NOTICE);
-	e1000_logtype_driver = rte_log_register("pmd.net.e1000.driver");
-	if (e1000_logtype_driver >= 0)
-		rte_log_set_level(e1000_logtype_driver, RTE_LOG_NOTICE);
-
-#ifdef RTE_LIBRTE_E1000_DEBUG_RX
-	e1000_logtype_rx = rte_log_register("pmd.net.e1000.rx");
-	if (e1000_logtype_rx >= 0)
-		rte_log_set_level(e1000_logtype_rx, RTE_LOG_DEBUG);
-#endif
-
-#ifdef RTE_LIBRTE_E1000_DEBUG_TX
-	e1000_logtype_tx = rte_log_register("pmd.net.e1000.tx");
-	if (e1000_logtype_tx >= 0)
-		rte_log_set_level(e1000_logtype_tx, RTE_LOG_DEBUG);
-#endif
-
-#ifdef RTE_LIBRTE_E1000_DEBUG_TX_FREE
-	e1000_logtype_tx_free = rte_log_register("pmd.net.e1000.tx_free");
-	if (e1000_logtype_tx_free >= 0)
-		rte_log_set_level(e1000_logtype_tx_free, RTE_LOG_DEBUG);
-#endif
-
-	e1000_log_initialized = 1;
-}
diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
index 9b8c4a7de5..79a6d8f461 100644
--- a/drivers/net/e1000/em_ethdev.c
+++ b/drivers/net/e1000/em_ethdev.c
@@ -1846,9 +1846,3 @@ eth_em_set_mc_addr_list(struct rte_eth_dev *dev,
 RTE_PMD_REGISTER_PCI(net_e1000_em, rte_em_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_e1000_em, pci_id_em_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_e1000_em, "* igb_uio | uio_pci_generic | vfio-pci");
-
-/* see e1000_logs.c */
-RTE_INIT(igb_init_log)
-{
-	e1000_igb_init_log();
-}
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 5323504e98..395dc3f5aa 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -5434,9 +5434,3 @@ RTE_PMD_REGISTER_KMOD_DEP(net_e1000_igb, "* igb_uio | uio_pci_generic | vfio-pci
 RTE_PMD_REGISTER_PCI(net_e1000_igb_vf, rte_igbvf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_e1000_igb_vf, pci_id_igbvf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_e1000_igb_vf, "* igb_uio | vfio-pci");
-
-/* see e1000_logs.c */
-RTE_INIT(e1000_init_log)
-{
-	e1000_igb_init_log();
-}
-- 
2.30.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-stable] [PATCH 2/3] drivers: fix log level after loading
  2021-03-10 14:01 ` [dpdk-stable] [PATCH 2/3] drivers: fix log level after loading Thomas Monjalon
@ 2021-03-23 18:25   ` David Marchand
  2021-03-23 18:50   ` Ajit Khaparde
  1 sibling, 0 replies; 5+ messages in thread
From: David Marchand @ 2021-03-23 18:25 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: dev, dpdk stable, Matan Azrad, Shahaf Shuler,
	Viacheslav Ovsiienko, Ajit Khaparde, Raveendra Padasalagi,
	Vikas Gupta, Jeff Guo, Haiyue Wang, Adam Dybkowski, Jerin Jacob,
	Akhil Goyal, Sachin Saxena

On Wed, Mar 10, 2021 at 3:01 PM Thomas Monjalon <thomas@monjalon.net> wrote:
>
> When compiled as a shared object, and loaded at runtime as a plugin,
> the drivers should get the log level set earlier at EAL init
> by the user through --log-level option.
>
> The function for applying the log level setting is
> rte_log_register_type_and_pick_level().
> It is called by most drivers via RTE_LOG_REGISTER().
>
> The drivers common/mlx5, bcmfs and e1000 were missing,
> so the user-specified log level was not applied when
> those drivers were loaded as plugins.
> The macro RTE_LOG_REGISTER() is used for those drivers.
>
> The unnecessary protection for double registration
> is removed from e1000.
>
> Fixes: 9c99878aa1b1 ("log: introduce logtype register macro")
> Fixes: c8e79da7c676 ("crypto/bcmfs: introduce BCMFS driver")
> Cc: stable@dpdk.org
>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>

Reviewed-by: David Marchand <david.marchand@redhat.com>


-- 
David Marchand


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-stable] [PATCH 2/3] drivers: fix log level after loading
  2021-03-10 14:01 ` [dpdk-stable] [PATCH 2/3] drivers: fix log level after loading Thomas Monjalon
  2021-03-23 18:25   ` David Marchand
@ 2021-03-23 18:50   ` Ajit Khaparde
  1 sibling, 0 replies; 5+ messages in thread
From: Ajit Khaparde @ 2021-03-23 18:50 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: dpdk-dev, dpdk stable, Matan Azrad, Shahaf Shuler,
	Viacheslav Ovsiienko, Raveendra Padasalagi, Vikas Gupta,
	Jeff Guo, Haiyue Wang, Adam Dybkowski, Jerin Jacob, Akhil Goyal,
	Sachin Saxena

[-- Attachment #1: Type: text/plain, Size: 6756 bytes --]

On Wed, Mar 10, 2021 at 6:01 AM Thomas Monjalon <thomas@monjalon.net> wrote:
>
> When compiled as a shared object, and loaded at runtime as a plugin,
> the drivers should get the log level set earlier at EAL init
> by the user through --log-level option.
>
> The function for applying the log level setting is
> rte_log_register_type_and_pick_level().
> It is called by most drivers via RTE_LOG_REGISTER().
>
> The drivers common/mlx5, bcmfs and e1000 were missing,
> so the user-specified log level was not applied when
> those drivers were loaded as plugins.
> The macro RTE_LOG_REGISTER() is used for those drivers.
>
> The unnecessary protection for double registration
> is removed from e1000.
>
> Fixes: 9c99878aa1b1 ("log: introduce logtype register macro")
> Fixes: c8e79da7c676 ("crypto/bcmfs: introduce BCMFS driver")
> Cc: stable@dpdk.org
>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
>  drivers/common/mlx5/mlx5_common.c |  9 +-----
>  drivers/crypto/bcmfs/bcmfs_logs.c | 17 ++---------
For bcmfs,
Acked-by: Ajit Khaparde <ajit.khaparde@broadcom.com>

>  drivers/net/e1000/e1000_logs.c    | 49 ++++---------------------------
>  drivers/net/e1000/em_ethdev.c     |  6 ----
>  drivers/net/e1000/igb_ethdev.c    |  6 ----
>  5 files changed, 8 insertions(+), 79 deletions(-)
>
> diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c
> index c26a2cfa30..f92f05bda5 100644
> --- a/drivers/common/mlx5/mlx5_common.c
> +++ b/drivers/common/mlx5/mlx5_common.c
> @@ -14,8 +14,6 @@
>  #include "mlx5_common_utils.h"
>  #include "mlx5_common_pci.h"
>
> -int mlx5_common_logtype;
> -
>  uint8_t haswell_broadwell_cpu;
>
>  /* In case this is an x86_64 intel processor to check if
> @@ -41,12 +39,7 @@ static inline void mlx5_cpu_id(unsigned int level,
>  }
>  #endif
>
> -RTE_INIT_PRIO(mlx5_log_init, LOG)
> -{
> -       mlx5_common_logtype = rte_log_register("pmd.common.mlx5");
> -       if (mlx5_common_logtype >= 0)
> -               rte_log_set_level(mlx5_common_logtype, RTE_LOG_NOTICE);
> -}
> +RTE_LOG_REGISTER(mlx5_common_logtype, pmd.common.mlx5, NOTICE)
>
>  static bool mlx5_common_initialized;
>
> diff --git a/drivers/crypto/bcmfs/bcmfs_logs.c b/drivers/crypto/bcmfs/bcmfs_logs.c
> index 86f4ff3b53..701da9ecf3 100644
> --- a/drivers/crypto/bcmfs/bcmfs_logs.c
> +++ b/drivers/crypto/bcmfs/bcmfs_logs.c
> @@ -8,9 +8,6 @@
>
>  #include "bcmfs_logs.h"
>
> -int bcmfs_conf_logtype;
> -int bcmfs_dp_logtype;
> -
>  int
>  bcmfs_hexdump_log(uint32_t level, uint32_t logtype, const char *title,
>                 const void *buf, unsigned int len)
> @@ -24,15 +21,5 @@ bcmfs_hexdump_log(uint32_t level, uint32_t logtype, const char *title,
>         return 0;
>  }
>
> -RTE_INIT(bcmfs_device_init_log)
> -{
> -       /* Configuration and general logs */
> -       bcmfs_conf_logtype = rte_log_register("pmd.bcmfs_config");
> -       if (bcmfs_conf_logtype >= 0)
> -               rte_log_set_level(bcmfs_conf_logtype, RTE_LOG_NOTICE);
> -
> -       /* data-path logs */
> -       bcmfs_dp_logtype = rte_log_register("pmd.bcmfs_fp");
> -       if (bcmfs_dp_logtype >= 0)
> -               rte_log_set_level(bcmfs_dp_logtype, RTE_LOG_NOTICE);
> -}
> +RTE_LOG_REGISTER(bcmfs_conf_logtype, pmd.bcmfs_config, NOTICE)
> +RTE_LOG_REGISTER(bcmfs_dp_logtype, pmd.bcmfs_fp, NOTICE)
> diff --git a/drivers/net/e1000/e1000_logs.c b/drivers/net/e1000/e1000_logs.c
> index 231f5c03ef..d9b8a4672f 100644
> --- a/drivers/net/e1000/e1000_logs.c
> +++ b/drivers/net/e1000/e1000_logs.c
> @@ -4,53 +4,14 @@
>
>  #include "e1000_logs.h"
>
> -/* declared as extern in e1000_logs.h */
> -int e1000_logtype_init;
> -int e1000_logtype_driver;
> -
> +RTE_LOG_REGISTER(e1000_logtype_init, pmd.net.e1000.init, NOTICE)
> +RTE_LOG_REGISTER(e1000_logtype_driver, pmd.net.e1000.driver, NOTICE)
>  #ifdef RTE_LIBRTE_E1000_DEBUG_RX
> -int e1000_logtype_rx;
> +RTE_LOG_REGISTER(e1000_logtype_rx, pmd.net.e1000.rx, DEBUG)
>  #endif
>  #ifdef RTE_LIBRTE_E1000_DEBUG_TX
> -int e1000_logtype_tx;
> +RTE_LOG_REGISTER(e1000_logtype_tx, pmd.net.e1000.tx, DEBUG)
>  #endif
>  #ifdef RTE_LIBRTE_E1000_DEBUG_TX_FREE
> -int e1000_logtype_tx_free;
> +RTE_LOG_REGISTER(e1000_logtype_tx_free, pmd.net.e1000.tx_free, DEBUG)
>  #endif
> -
> -/* avoids double registering of logs if EM and IGB drivers are in use */
> -static int e1000_log_initialized;
> -
> -void
> -e1000_igb_init_log(void)
> -{
> -       if (e1000_log_initialized)
> -               return;
> -
> -       e1000_logtype_init = rte_log_register("pmd.net.e1000.init");
> -       if (e1000_logtype_init >= 0)
> -               rte_log_set_level(e1000_logtype_init, RTE_LOG_NOTICE);
> -       e1000_logtype_driver = rte_log_register("pmd.net.e1000.driver");
> -       if (e1000_logtype_driver >= 0)
> -               rte_log_set_level(e1000_logtype_driver, RTE_LOG_NOTICE);
> -
> -#ifdef RTE_LIBRTE_E1000_DEBUG_RX
> -       e1000_logtype_rx = rte_log_register("pmd.net.e1000.rx");
> -       if (e1000_logtype_rx >= 0)
> -               rte_log_set_level(e1000_logtype_rx, RTE_LOG_DEBUG);
> -#endif
> -
> -#ifdef RTE_LIBRTE_E1000_DEBUG_TX
> -       e1000_logtype_tx = rte_log_register("pmd.net.e1000.tx");
> -       if (e1000_logtype_tx >= 0)
> -               rte_log_set_level(e1000_logtype_tx, RTE_LOG_DEBUG);
> -#endif
> -
> -#ifdef RTE_LIBRTE_E1000_DEBUG_TX_FREE
> -       e1000_logtype_tx_free = rte_log_register("pmd.net.e1000.tx_free");
> -       if (e1000_logtype_tx_free >= 0)
> -               rte_log_set_level(e1000_logtype_tx_free, RTE_LOG_DEBUG);
> -#endif
> -
> -       e1000_log_initialized = 1;
> -}
> diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
> index 9b8c4a7de5..79a6d8f461 100644
> --- a/drivers/net/e1000/em_ethdev.c
> +++ b/drivers/net/e1000/em_ethdev.c
> @@ -1846,9 +1846,3 @@ eth_em_set_mc_addr_list(struct rte_eth_dev *dev,
>  RTE_PMD_REGISTER_PCI(net_e1000_em, rte_em_pmd);
>  RTE_PMD_REGISTER_PCI_TABLE(net_e1000_em, pci_id_em_map);
>  RTE_PMD_REGISTER_KMOD_DEP(net_e1000_em, "* igb_uio | uio_pci_generic | vfio-pci");
> -
> -/* see e1000_logs.c */
> -RTE_INIT(igb_init_log)
> -{
> -       e1000_igb_init_log();
> -}
> diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
> index 5323504e98..395dc3f5aa 100644
> --- a/drivers/net/e1000/igb_ethdev.c
> +++ b/drivers/net/e1000/igb_ethdev.c
> @@ -5434,9 +5434,3 @@ RTE_PMD_REGISTER_KMOD_DEP(net_e1000_igb, "* igb_uio | uio_pci_generic | vfio-pci
>  RTE_PMD_REGISTER_PCI(net_e1000_igb_vf, rte_igbvf_pmd);
>  RTE_PMD_REGISTER_PCI_TABLE(net_e1000_igb_vf, pci_id_igbvf_map);
>  RTE_PMD_REGISTER_KMOD_DEP(net_e1000_igb_vf, "* igb_uio | vfio-pci");
> -
> -/* see e1000_logs.c */
> -RTE_INIT(e1000_init_log)
> -{
> -       e1000_igb_init_log();
> -}
> --
> 2.30.1
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dpdk-stable] [PATCH v2 2/3] drivers: fix log level after loading
       [not found] ` <20210405100301.657768-1-thomas@monjalon.net>
@ 2021-04-05 10:03   ` Thomas Monjalon
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Monjalon @ 2021-04-05 10:03 UTC (permalink / raw)
  To: dev
  Cc: stable, David Marchand, Ajit Khaparde, Matan Azrad,
	Shahaf Shuler, Viacheslav Ovsiienko, Raveendra Padasalagi,
	Vikas Gupta, Jeff Guo, Haiyue Wang, Jerin Jacob, Adam Dybkowski,
	Sachin Saxena, Akhil Goyal

When compiled as a shared object, and loaded at runtime as a plugin,
the drivers should get the log level set earlier at EAL init
by the user through --log-level option.

The function for applying the log level setting is
rte_log_register_type_and_pick_level().
It is called by most drivers via RTE_LOG_REGISTER().

The drivers common/mlx5, bcmfs and e1000 were missing,
so the user-specified log level was not applied when
those drivers were loaded as plugins.
The macro RTE_LOG_REGISTER() is used for those drivers.

The unnecessary protection for double registration
is removed from e1000.

Fixes: 9c99878aa1b1 ("log: introduce logtype register macro")
Fixes: c8e79da7c676 ("crypto/bcmfs: introduce BCMFS driver")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Reviewed-by: David Marchand <david.marchand@redhat.com>
Acked-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/common/mlx5/mlx5_common.c |  9 +-----
 drivers/crypto/bcmfs/bcmfs_logs.c | 17 ++---------
 drivers/net/e1000/e1000_logs.c    | 49 ++++---------------------------
 drivers/net/e1000/em_ethdev.c     |  6 ----
 drivers/net/e1000/igb_ethdev.c    |  6 ----
 5 files changed, 8 insertions(+), 79 deletions(-)

diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c
index c26a2cfa30..f92f05bda5 100644
--- a/drivers/common/mlx5/mlx5_common.c
+++ b/drivers/common/mlx5/mlx5_common.c
@@ -14,8 +14,6 @@
 #include "mlx5_common_utils.h"
 #include "mlx5_common_pci.h"
 
-int mlx5_common_logtype;
-
 uint8_t haswell_broadwell_cpu;
 
 /* In case this is an x86_64 intel processor to check if
@@ -41,12 +39,7 @@ static inline void mlx5_cpu_id(unsigned int level,
 }
 #endif
 
-RTE_INIT_PRIO(mlx5_log_init, LOG)
-{
-	mlx5_common_logtype = rte_log_register("pmd.common.mlx5");
-	if (mlx5_common_logtype >= 0)
-		rte_log_set_level(mlx5_common_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(mlx5_common_logtype, pmd.common.mlx5, NOTICE)
 
 static bool mlx5_common_initialized;
 
diff --git a/drivers/crypto/bcmfs/bcmfs_logs.c b/drivers/crypto/bcmfs/bcmfs_logs.c
index 86f4ff3b53..701da9ecf3 100644
--- a/drivers/crypto/bcmfs/bcmfs_logs.c
+++ b/drivers/crypto/bcmfs/bcmfs_logs.c
@@ -8,9 +8,6 @@
 
 #include "bcmfs_logs.h"
 
-int bcmfs_conf_logtype;
-int bcmfs_dp_logtype;
-
 int
 bcmfs_hexdump_log(uint32_t level, uint32_t logtype, const char *title,
 		const void *buf, unsigned int len)
@@ -24,15 +21,5 @@ bcmfs_hexdump_log(uint32_t level, uint32_t logtype, const char *title,
 	return 0;
 }
 
-RTE_INIT(bcmfs_device_init_log)
-{
-	/* Configuration and general logs */
-	bcmfs_conf_logtype = rte_log_register("pmd.bcmfs_config");
-	if (bcmfs_conf_logtype >= 0)
-		rte_log_set_level(bcmfs_conf_logtype, RTE_LOG_NOTICE);
-
-	/* data-path logs */
-	bcmfs_dp_logtype = rte_log_register("pmd.bcmfs_fp");
-	if (bcmfs_dp_logtype >= 0)
-		rte_log_set_level(bcmfs_dp_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(bcmfs_conf_logtype, pmd.bcmfs_config, NOTICE)
+RTE_LOG_REGISTER(bcmfs_dp_logtype, pmd.bcmfs_fp, NOTICE)
diff --git a/drivers/net/e1000/e1000_logs.c b/drivers/net/e1000/e1000_logs.c
index 231f5c03ef..d9b8a4672f 100644
--- a/drivers/net/e1000/e1000_logs.c
+++ b/drivers/net/e1000/e1000_logs.c
@@ -4,53 +4,14 @@
 
 #include "e1000_logs.h"
 
-/* declared as extern in e1000_logs.h */
-int e1000_logtype_init;
-int e1000_logtype_driver;
-
+RTE_LOG_REGISTER(e1000_logtype_init, pmd.net.e1000.init, NOTICE)
+RTE_LOG_REGISTER(e1000_logtype_driver, pmd.net.e1000.driver, NOTICE)
 #ifdef RTE_LIBRTE_E1000_DEBUG_RX
-int e1000_logtype_rx;
+RTE_LOG_REGISTER(e1000_logtype_rx, pmd.net.e1000.rx, DEBUG)
 #endif
 #ifdef RTE_LIBRTE_E1000_DEBUG_TX
-int e1000_logtype_tx;
+RTE_LOG_REGISTER(e1000_logtype_tx, pmd.net.e1000.tx, DEBUG)
 #endif
 #ifdef RTE_LIBRTE_E1000_DEBUG_TX_FREE
-int e1000_logtype_tx_free;
+RTE_LOG_REGISTER(e1000_logtype_tx_free, pmd.net.e1000.tx_free, DEBUG)
 #endif
-
-/* avoids double registering of logs if EM and IGB drivers are in use */
-static int e1000_log_initialized;
-
-void
-e1000_igb_init_log(void)
-{
-	if (e1000_log_initialized)
-		return;
-
-	e1000_logtype_init = rte_log_register("pmd.net.e1000.init");
-	if (e1000_logtype_init >= 0)
-		rte_log_set_level(e1000_logtype_init, RTE_LOG_NOTICE);
-	e1000_logtype_driver = rte_log_register("pmd.net.e1000.driver");
-	if (e1000_logtype_driver >= 0)
-		rte_log_set_level(e1000_logtype_driver, RTE_LOG_NOTICE);
-
-#ifdef RTE_LIBRTE_E1000_DEBUG_RX
-	e1000_logtype_rx = rte_log_register("pmd.net.e1000.rx");
-	if (e1000_logtype_rx >= 0)
-		rte_log_set_level(e1000_logtype_rx, RTE_LOG_DEBUG);
-#endif
-
-#ifdef RTE_LIBRTE_E1000_DEBUG_TX
-	e1000_logtype_tx = rte_log_register("pmd.net.e1000.tx");
-	if (e1000_logtype_tx >= 0)
-		rte_log_set_level(e1000_logtype_tx, RTE_LOG_DEBUG);
-#endif
-
-#ifdef RTE_LIBRTE_E1000_DEBUG_TX_FREE
-	e1000_logtype_tx_free = rte_log_register("pmd.net.e1000.tx_free");
-	if (e1000_logtype_tx_free >= 0)
-		rte_log_set_level(e1000_logtype_tx_free, RTE_LOG_DEBUG);
-#endif
-
-	e1000_log_initialized = 1;
-}
diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
index 3c6f643c19..3e7ccdbf09 100644
--- a/drivers/net/e1000/em_ethdev.c
+++ b/drivers/net/e1000/em_ethdev.c
@@ -1850,9 +1850,3 @@ eth_em_set_mc_addr_list(struct rte_eth_dev *dev,
 RTE_PMD_REGISTER_PCI(net_e1000_em, rte_em_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_e1000_em, pci_id_em_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_e1000_em, "* igb_uio | uio_pci_generic | vfio-pci");
-
-/* see e1000_logs.c */
-RTE_INIT(igb_init_log)
-{
-	e1000_igb_init_log();
-}
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 17ee6e91a0..a1a72339ba 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -5421,9 +5421,3 @@ RTE_PMD_REGISTER_KMOD_DEP(net_e1000_igb, "* igb_uio | uio_pci_generic | vfio-pci
 RTE_PMD_REGISTER_PCI(net_e1000_igb_vf, rte_igbvf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_e1000_igb_vf, pci_id_igbvf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_e1000_igb_vf, "* igb_uio | vfio-pci");
-
-/* see e1000_logs.c */
-RTE_INIT(e1000_init_log)
-{
-	e1000_igb_init_log();
-}
-- 
2.31.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dpdk-stable] [PATCH v3 2/3] drivers: fix log level after loading
       [not found] ` <20210406132204.1818522-1-thomas@monjalon.net>
@ 2021-04-06 13:22   ` Thomas Monjalon
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Monjalon @ 2021-04-06 13:22 UTC (permalink / raw)
  To: dev
  Cc: david.marchand, stable, Ajit Khaparde, Matan Azrad,
	Shahaf Shuler, Viacheslav Ovsiienko, Raveendra Padasalagi,
	Vikas Gupta, Jeff Guo, Haiyue Wang, Akhil Goyal, Sachin Saxena,
	Adam Dybkowski, Jerin Jacob

When compiled as a shared object, and loaded at runtime as a plugin,
the drivers should get the log level set earlier at EAL init
by the user through --log-level option.

The function for applying the log level setting is
rte_log_register_type_and_pick_level().
It is called by most drivers via RTE_LOG_REGISTER().

The drivers common/mlx5, bcmfs and e1000 were missing,
so the user-specified log level was not applied when
those drivers were loaded as plugins.
The macro RTE_LOG_REGISTER() is used for those drivers.

The unnecessary protection for double registration
is removed from e1000.

Fixes: 9c99878aa1b1 ("log: introduce logtype register macro")
Fixes: c8e79da7c676 ("crypto/bcmfs: introduce BCMFS driver")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Reviewed-by: David Marchand <david.marchand@redhat.com>
Acked-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/common/mlx5/mlx5_common.c |  9 +-----
 drivers/crypto/bcmfs/bcmfs_logs.c | 17 ++---------
 drivers/net/e1000/e1000_logs.c    | 49 ++++---------------------------
 drivers/net/e1000/em_ethdev.c     |  6 ----
 drivers/net/e1000/igb_ethdev.c    |  6 ----
 5 files changed, 8 insertions(+), 79 deletions(-)

diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c
index c26a2cfa30..f92f05bda5 100644
--- a/drivers/common/mlx5/mlx5_common.c
+++ b/drivers/common/mlx5/mlx5_common.c
@@ -14,8 +14,6 @@
 #include "mlx5_common_utils.h"
 #include "mlx5_common_pci.h"
 
-int mlx5_common_logtype;
-
 uint8_t haswell_broadwell_cpu;
 
 /* In case this is an x86_64 intel processor to check if
@@ -41,12 +39,7 @@ static inline void mlx5_cpu_id(unsigned int level,
 }
 #endif
 
-RTE_INIT_PRIO(mlx5_log_init, LOG)
-{
-	mlx5_common_logtype = rte_log_register("pmd.common.mlx5");
-	if (mlx5_common_logtype >= 0)
-		rte_log_set_level(mlx5_common_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(mlx5_common_logtype, pmd.common.mlx5, NOTICE)
 
 static bool mlx5_common_initialized;
 
diff --git a/drivers/crypto/bcmfs/bcmfs_logs.c b/drivers/crypto/bcmfs/bcmfs_logs.c
index 86f4ff3b53..701da9ecf3 100644
--- a/drivers/crypto/bcmfs/bcmfs_logs.c
+++ b/drivers/crypto/bcmfs/bcmfs_logs.c
@@ -8,9 +8,6 @@
 
 #include "bcmfs_logs.h"
 
-int bcmfs_conf_logtype;
-int bcmfs_dp_logtype;
-
 int
 bcmfs_hexdump_log(uint32_t level, uint32_t logtype, const char *title,
 		const void *buf, unsigned int len)
@@ -24,15 +21,5 @@ bcmfs_hexdump_log(uint32_t level, uint32_t logtype, const char *title,
 	return 0;
 }
 
-RTE_INIT(bcmfs_device_init_log)
-{
-	/* Configuration and general logs */
-	bcmfs_conf_logtype = rte_log_register("pmd.bcmfs_config");
-	if (bcmfs_conf_logtype >= 0)
-		rte_log_set_level(bcmfs_conf_logtype, RTE_LOG_NOTICE);
-
-	/* data-path logs */
-	bcmfs_dp_logtype = rte_log_register("pmd.bcmfs_fp");
-	if (bcmfs_dp_logtype >= 0)
-		rte_log_set_level(bcmfs_dp_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(bcmfs_conf_logtype, pmd.bcmfs_config, NOTICE)
+RTE_LOG_REGISTER(bcmfs_dp_logtype, pmd.bcmfs_fp, NOTICE)
diff --git a/drivers/net/e1000/e1000_logs.c b/drivers/net/e1000/e1000_logs.c
index 231f5c03ef..d9b8a4672f 100644
--- a/drivers/net/e1000/e1000_logs.c
+++ b/drivers/net/e1000/e1000_logs.c
@@ -4,53 +4,14 @@
 
 #include "e1000_logs.h"
 
-/* declared as extern in e1000_logs.h */
-int e1000_logtype_init;
-int e1000_logtype_driver;
-
+RTE_LOG_REGISTER(e1000_logtype_init, pmd.net.e1000.init, NOTICE)
+RTE_LOG_REGISTER(e1000_logtype_driver, pmd.net.e1000.driver, NOTICE)
 #ifdef RTE_LIBRTE_E1000_DEBUG_RX
-int e1000_logtype_rx;
+RTE_LOG_REGISTER(e1000_logtype_rx, pmd.net.e1000.rx, DEBUG)
 #endif
 #ifdef RTE_LIBRTE_E1000_DEBUG_TX
-int e1000_logtype_tx;
+RTE_LOG_REGISTER(e1000_logtype_tx, pmd.net.e1000.tx, DEBUG)
 #endif
 #ifdef RTE_LIBRTE_E1000_DEBUG_TX_FREE
-int e1000_logtype_tx_free;
+RTE_LOG_REGISTER(e1000_logtype_tx_free, pmd.net.e1000.tx_free, DEBUG)
 #endif
-
-/* avoids double registering of logs if EM and IGB drivers are in use */
-static int e1000_log_initialized;
-
-void
-e1000_igb_init_log(void)
-{
-	if (e1000_log_initialized)
-		return;
-
-	e1000_logtype_init = rte_log_register("pmd.net.e1000.init");
-	if (e1000_logtype_init >= 0)
-		rte_log_set_level(e1000_logtype_init, RTE_LOG_NOTICE);
-	e1000_logtype_driver = rte_log_register("pmd.net.e1000.driver");
-	if (e1000_logtype_driver >= 0)
-		rte_log_set_level(e1000_logtype_driver, RTE_LOG_NOTICE);
-
-#ifdef RTE_LIBRTE_E1000_DEBUG_RX
-	e1000_logtype_rx = rte_log_register("pmd.net.e1000.rx");
-	if (e1000_logtype_rx >= 0)
-		rte_log_set_level(e1000_logtype_rx, RTE_LOG_DEBUG);
-#endif
-
-#ifdef RTE_LIBRTE_E1000_DEBUG_TX
-	e1000_logtype_tx = rte_log_register("pmd.net.e1000.tx");
-	if (e1000_logtype_tx >= 0)
-		rte_log_set_level(e1000_logtype_tx, RTE_LOG_DEBUG);
-#endif
-
-#ifdef RTE_LIBRTE_E1000_DEBUG_TX_FREE
-	e1000_logtype_tx_free = rte_log_register("pmd.net.e1000.tx_free");
-	if (e1000_logtype_tx_free >= 0)
-		rte_log_set_level(e1000_logtype_tx_free, RTE_LOG_DEBUG);
-#endif
-
-	e1000_log_initialized = 1;
-}
diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
index 3c6f643c19..3e7ccdbf09 100644
--- a/drivers/net/e1000/em_ethdev.c
+++ b/drivers/net/e1000/em_ethdev.c
@@ -1850,9 +1850,3 @@ eth_em_set_mc_addr_list(struct rte_eth_dev *dev,
 RTE_PMD_REGISTER_PCI(net_e1000_em, rte_em_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_e1000_em, pci_id_em_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_e1000_em, "* igb_uio | uio_pci_generic | vfio-pci");
-
-/* see e1000_logs.c */
-RTE_INIT(igb_init_log)
-{
-	e1000_igb_init_log();
-}
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 17ee6e91a0..a1a72339ba 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -5421,9 +5421,3 @@ RTE_PMD_REGISTER_KMOD_DEP(net_e1000_igb, "* igb_uio | uio_pci_generic | vfio-pci
 RTE_PMD_REGISTER_PCI(net_e1000_igb_vf, rte_igbvf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_e1000_igb_vf, pci_id_igbvf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_e1000_igb_vf, "* igb_uio | vfio-pci");
-
-/* see e1000_logs.c */
-RTE_INIT(e1000_init_log)
-{
-	e1000_igb_init_log();
-}
-- 
2.31.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-04-06 13:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20210310140107.2730088-1-thomas@monjalon.net>
2021-03-10 14:01 ` [dpdk-stable] [PATCH 2/3] drivers: fix log level after loading Thomas Monjalon
2021-03-23 18:25   ` David Marchand
2021-03-23 18:50   ` Ajit Khaparde
     [not found] ` <20210405100301.657768-1-thomas@monjalon.net>
2021-04-05 10:03   ` [dpdk-stable] [PATCH v2 " Thomas Monjalon
     [not found] ` <20210406132204.1818522-1-thomas@monjalon.net>
2021-04-06 13:22   ` [dpdk-stable] [PATCH v3 " Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).