DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev]  [PATCH 00/13] rte_log registration usage improvement
@ 2020-06-17  6:30 jerinj
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 01/13] eal/log: introduce log register macro jerinj
                   ` (14 more replies)
  0 siblings, 15 replies; 98+ messages in thread
From: jerinj @ 2020-06-17  6:30 UTC (permalink / raw)
  To: dev; +Cc: thomas, olivier.matz, david.marchand, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

This patch series improves the rte_log registration code snippet by
avoiding duplication of the code around registration by
introducing RTE_LOG_REGISTER macro.

Pending stuff
~~~~~~~~~~~~~
I have converted all existing rte_log_register() to new macro, except
the following (as it has different usage style)
1) drivers/common/mlx5/mlx5_common.c
2) drivers/net/e1000/e1000_logs.c
3) drivers/net/sfc/sfc_ethdev.c

Example usage of new macro
~~~~~~~~~~~~~~~~~~~~~~~~~~
-/**
- * @internal
- */
-int otx2_logtype_base;
-/**
- * @internal
- */
-int otx2_logtype_mbox;
-/**
- * @internal
- */
-int otx2_logtype_npa;
-/**
- * @internal
- */
-int otx2_logtype_nix;
-/**
- * @internal
- */
-int otx2_logtype_npc;
-/**
- * @internal
- */
-int otx2_logtype_tm;
-/**
- * @internal
- */
-int otx2_logtype_sso;
-/**
- * @internal
- */
-int otx2_logtype_tim;
-/**
- * @internal
- */
-int otx2_logtype_dpi;
-/**
- * @internal
- */
-int otx2_logtype_ep;
-
-RTE_INIT(otx2_log_init);
-static void
-otx2_log_init(void)
-{
-       otx2_logtype_base = rte_log_register("pmd.octeontx2.base");
-       if (otx2_logtype_base >= 0)
-               rte_log_set_level(otx2_logtype_base, RTE_LOG_NOTICE);
-
-       otx2_logtype_mbox = rte_log_register("pmd.octeontx2.mbox");
-       if (otx2_logtype_mbox >= 0)
-               rte_log_set_level(otx2_logtype_mbox, RTE_LOG_NOTICE);
-
-       otx2_logtype_npa = rte_log_register("pmd.mempool.octeontx2");
-       if (otx2_logtype_npa >= 0)
-               rte_log_set_level(otx2_logtype_npa, RTE_LOG_NOTICE);
-
-       otx2_logtype_nix = rte_log_register("pmd.net.octeontx2");
-       if (otx2_logtype_nix >= 0)
-               rte_log_set_level(otx2_logtype_nix, RTE_LOG_NOTICE);
-
-       otx2_logtype_npc = rte_log_register("pmd.net.octeontx2.flow");
-       if (otx2_logtype_npc >= 0)
-               rte_log_set_level(otx2_logtype_npc, RTE_LOG_NOTICE);
-
-       otx2_logtype_tm = rte_log_register("pmd.net.octeontx2.tm");
-       if (otx2_logtype_tm >= 0)
-               rte_log_set_level(otx2_logtype_tm, RTE_LOG_NOTICE);
-
-       otx2_logtype_sso = rte_log_register("pmd.event.octeontx2");
-       if (otx2_logtype_sso >= 0)
-               rte_log_set_level(otx2_logtype_sso, RTE_LOG_NOTICE);
-
-       otx2_logtype_tim =
        rte_log_register("pmd.event.octeontx2.timer");
-       if (otx2_logtype_tim >= 0)
-               rte_log_set_level(otx2_logtype_tim, RTE_LOG_NOTICE);
-
-       otx2_logtype_dpi = rte_log_register("pmd.raw.octeontx2.dpi");
-       if (otx2_logtype_dpi >= 0)
-               rte_log_set_level(otx2_logtype_dpi, RTE_LOG_NOTICE);
-
-       otx2_logtype_ep = rte_log_register("pmd.raw.octeontx2.ep");
-       if (otx2_logtype_ep >= 0)
-               rte_log_set_level(otx2_logtype_ep, RTE_LOG_NOTICE);
-
-}
+RTE_LOG_REGISTER(otx2_logtype_base, pmd.octeontx2.base, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_mbox, pmd.octeontx2.mbox, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_npa, pmd.mempool.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_nix, pmd.net.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_npc, pmd.net.octeontx2.flow, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_tm, pmd.net.octeontx2.tm, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_sso, pmd.event.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_tim, pmd.event.octeontx2.timer, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_dpi, pmd.raw.octeontx2.dpi, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_ep, pmd.raw.octeontx2.ep, NOTICE);



Jerin Jacob (13):
  eal/log: introduce log register macro
  lib: use log register macro
  drivers/vdpa: use log register macro
  drivers/raw: use log register macro
  drivers/net: use log register macro
  drivers/mempool: use log register macro
  drivers/event: use log register macro
  drivers/crypto: use log register macro
  drivers/compress: use log register macro
  drivers/common: use log register macro
  drivers/bus: use log register macro
  drivers/baseband: use log register macro
  app/test: use log register macro

 app/test/test_efd.c                           |  6 +-
 app/test/test_hash.c                          |  7 +-
 app/test/test_timer_racecond.c                |  7 +-
 .../fpga_5gnr_fec/rte_fpga_5gnr_fec.c         | 17 +---
 drivers/baseband/fpga_lte_fec/fpga_lte_fec.c  | 18 +---
 drivers/baseband/null/bbdev_null.c            |  9 +-
 .../baseband/turbo_sw/bbdev_turbo_software.c  |  9 +-
 drivers/bus/dpaa/dpaa_bus.c                   | 10 +-
 drivers/bus/fslmc/fslmc_bus.c                 | 11 +--
 drivers/bus/ifpga/ifpga_bus.c                 |  9 +-
 drivers/bus/vdev/vdev.c                       | 10 +-
 drivers/bus/vmbus/vmbus_common.c              |  9 +-
 drivers/common/dpaax/dpaax_iova_table.c       | 10 +-
 drivers/common/iavf/iavf_impl.c               |  9 +-
 drivers/common/octeontx/octeontx_mbox.c       |  9 +-
 drivers/common/octeontx2/otx2_common.c        | 96 ++-----------------
 drivers/common/qat/qat_logs.c                 | 17 +---
 drivers/compress/isal/isal_compress_pmd.c     | 10 +-
 drivers/compress/octeontx/otx_zip_pmd.c       | 10 +-
 drivers/compress/zlib/zlib_pmd.c              | 10 +-
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c      |  8 +-
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c    |  8 +-
 drivers/crypto/caam_jr/caam_jr.c              |  8 +-
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c   | 11 +--
 drivers/crypto/dpaa_sec/dpaa_sec.c            | 10 +-
 drivers/crypto/kasumi/rte_kasumi_pmd.c        |  6 +-
 drivers/crypto/mvsam/rte_mrvl_pmd.c           |  7 +-
 drivers/crypto/nitrox/nitrox_logs.c           |  9 +-
 drivers/crypto/null/null_crypto_pmd.c         |  7 +-
 drivers/crypto/octeontx/otx_cryptodev.c       | 10 +-
 drivers/crypto/octeontx2/otx2_cryptodev.c     | 12 +--
 drivers/crypto/openssl/rte_openssl_pmd.c      |  7 +-
 .../scheduler/rte_cryptodev_scheduler.c       |  8 +-
 drivers/crypto/snow3g/rte_snow3g_pmd.c        |  7 +-
 drivers/crypto/virtio/virtio_cryptodev.c      | 39 ++------
 drivers/crypto/zuc/rte_zuc_pmd.c              |  7 +-
 drivers/event/dpaa/dpaa_eventdev.c            |  8 +-
 drivers/event/dpaa2/dpaa2_eventdev.c          | 10 +-
 drivers/event/octeontx/ssovf_evdev.c          |  8 +-
 drivers/event/octeontx/timvf_evdev.c          |  9 +-
 drivers/event/opdl/opdl_evdev.c               |  8 +-
 drivers/event/opdl/opdl_ring.c                |  2 -
 drivers/event/sw/sw_evdev.c                   | 11 +--
 drivers/mempool/dpaa/dpaa_mempool.c           | 10 +-
 drivers/mempool/dpaa2/dpaa2_hw_mempool.c      | 10 +-
 drivers/mempool/octeontx/octeontx_fpavf.c     | 10 +-
 drivers/net/af_packet/rte_eth_af_packet.c     |  8 +-
 drivers/net/af_xdp/rte_eth_af_xdp.c           |  8 +-
 drivers/net/ark/ark_ethdev.c                  | 10 +-
 drivers/net/atlantic/atl_ethdev.c             | 15 +--
 drivers/net/avp/avp_ethdev.c                  | 10 +-
 drivers/net/axgbe/axgbe_ethdev.c              | 15 +--
 drivers/net/bnx2x/bnx2x_ethdev.c              | 15 +--
 drivers/net/bnxt/bnxt_ethdev.c                |  9 +-
 drivers/net/bonding/rte_eth_bond_pmd.c        |  9 +-
 drivers/net/cxgbe/cxgbe_ethdev.c              | 15 +--
 drivers/net/dpaa/dpaa_ethdev.c                |  9 +-
 drivers/net/dpaa2/dpaa2_ethdev.c              |  9 +-
 drivers/net/ena/ena_ethdev.c                  | 48 ++--------
 drivers/net/enetc/enetc_ethdev.c              | 10 +-
 drivers/net/enic/enic_ethdev.c                |  9 +-
 drivers/net/failsafe/failsafe.c               | 10 +-
 drivers/net/fm10k/fm10k_ethdev.c              | 40 +-------
 drivers/net/hinic/hinic_pmd_ethdev.c          | 11 +--
 drivers/net/hns3/hns3_ethdev.c                | 15 +--
 drivers/net/i40e/i40e_ethdev.c                | 38 +-------
 drivers/net/iavf/iavf_ethdev.c                | 40 +-------
 drivers/net/ice/ice_ethdev.c                  | 38 +-------
 drivers/net/igc/igc_logs.c                    | 16 +---
 drivers/net/ionic/ionic_ethdev.c              | 10 +-
 drivers/net/ipn3ke/ipn3ke_ethdev.c            | 10 +-
 drivers/net/ixgbe/ixgbe_ethdev.c              | 39 ++------
 drivers/net/kni/rte_eth_kni.c                 |  9 +-
 drivers/net/liquidio/lio_ethdev.c             | 15 +--
 drivers/net/memif/rte_eth_memif.c             |  9 +-
 drivers/net/mlx4/mlx4.c                       | 11 +--
 drivers/net/mlx5/mlx5.c                       | 11 +--
 drivers/net/mvneta/mvneta_ethdev.c            | 10 +-
 drivers/net/mvpp2/mrvl_ethdev.c               | 10 +-
 drivers/net/netvsc/hn_ethdev.c                | 15 +--
 drivers/net/nfp/nfp_net.c                     | 15 +--
 drivers/net/null/rte_eth_null.c               |  8 +-
 drivers/net/octeontx/octeontx_ethdev.c        | 21 +---
 drivers/net/pcap/rte_eth_pcap.c               |  8 +-
 drivers/net/pfe/pfe_ethdev.c                  | 10 +-
 drivers/net/qede/qede_ethdev.c                | 16 +---
 drivers/net/ring/rte_eth_ring.c               |  8 +-
 drivers/net/softnic/rte_eth_softnic.c         | 10 +-
 drivers/net/szedata2/rte_eth_szedata2.c       | 15 +--
 drivers/net/tap/rte_eth_tap.c                 |  9 +-
 drivers/net/thunderx/nicvf_ethdev.c           | 21 +---
 drivers/net/vdev_netvsc/vdev_netvsc.c         | 13 +--
 drivers/net/vhost/rte_eth_vhost.c             |  8 +-
 drivers/net/virtio/virtio_ethdev.c            | 15 +--
 drivers/net/vmxnet3/vmxnet3_ethdev.c          | 15 +--
 drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c         | 11 +--
 drivers/raw/dpaa2_qdma/dpaa2_qdma.c           | 11 +--
 drivers/raw/ifpga/ifpga_rawdev.c              | 10 +-
 drivers/raw/ioat/ioat_rawdev.c                | 12 +--
 drivers/raw/ioat/rte_ioat_rawdev.h            |  2 -
 drivers/raw/ntb/ntb.c                         | 10 +-
 drivers/raw/skeleton/skeleton_rawdev.c        | 11 +--
 drivers/vdpa/ifc/ifcvf_vdpa.c                 | 10 +-
 drivers/vdpa/mlx5/mlx5_vdpa.c                 |  7 +-
 lib/librte_bbdev/rte_bbdev.c                  |  8 +-
 lib/librte_bpf/bpf.c                          |  9 +-
 lib/librte_cfgfile/rte_cfgfile.c              |  8 +-
 lib/librte_compressdev/rte_compressdev.c      |  7 +-
 lib/librte_compressdev/rte_compressdev_pmd.c  |  2 -
 lib/librte_eal/include/rte_log.h              | 25 +++++
 lib/librte_ethdev/rte_ethdev.c                |  9 +-
 lib/librte_eventdev/rte_event_timer_adapter.c | 21 +---
 lib/librte_flow_classify/rte_flow_classify.c  | 10 +-
 lib/librte_graph/graph.c                      |  7 +-
 lib/librte_member/rte_member.c                |  9 +-
 lib/librte_metrics/rte_metrics_telemetry.c    |  5 +-
 lib/librte_node/log.c                         |  9 +-
 lib/librte_pdump/rte_pdump.c                  |  9 +-
 lib/librte_rawdev/rte_rawdev.c                |  7 +-
 lib/librte_rcu/rte_rcu_qsbr.c                 |  9 +-
 lib/librte_stack/rte_stack.c                  |  7 +-
 lib/librte_vhost/vhost.c                      | 15 +--
 122 files changed, 229 insertions(+), 1322 deletions(-)

-- 
2.26.2


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

* [dpdk-dev]  [PATCH 01/13] eal/log: introduce log register macro
  2020-06-17  6:30 [dpdk-dev] [PATCH 00/13] rte_log registration usage improvement jerinj
@ 2020-06-17  6:30 ` jerinj
  2020-06-17 10:00   ` Thomas Monjalon
                     ` (2 more replies)
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 02/13] lib: use " jerinj
                   ` (13 subsequent siblings)
  14 siblings, 3 replies; 98+ messages in thread
From: jerinj @ 2020-06-17  6:30 UTC (permalink / raw)
  To: dev; +Cc: thomas, olivier.matz, david.marchand, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Introducing the RTE_LOG_REGISTER macro to avoid the code duplication
in the log registration process.

It is a wrapper macro for declaring the logtype, register the log and sets
it's level in the constructor context.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
---
 lib/librte_eal/include/rte_log.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/lib/librte_eal/include/rte_log.h b/lib/librte_eal/include/rte_log.h
index 1789ede56..4dc357074 100644
--- a/lib/librte_eal/include/rte_log.h
+++ b/lib/librte_eal/include/rte_log.h
@@ -376,6 +376,31 @@ int rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap)
 		 RTE_LOGTYPE_ ## t, # t ": " __VA_ARGS__) :	\
 	 0)
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Register a dynamic log type in constructor context with its name and level.
+ *
+ * It is a wrapper macro for declaring the logtype, register the log and sets
+ * it's level in the constructor context.
+ *
+ * @param type
+ *   The log type identifier
+ * @param name
+ *    Name for the log type to be registered
+ * @param level
+ *   Log level. A value between EMERG (1) and DEBUG (8).
+ */
+#define RTE_LOG_REGISTER(type, name, level)			\
+int type;							\
+RTE_INIT(__##type)						\
+{								\
+	type = rte_log_register(RTE_STR(name));			\
+	if (type >= 0)						\
+		rte_log_set_level(type, RTE_LOG_##level);	\
+}
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.26.2


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

* [dpdk-dev]  [PATCH 02/13] lib: use log register macro
  2020-06-17  6:30 [dpdk-dev] [PATCH 00/13] rte_log registration usage improvement jerinj
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 01/13] eal/log: introduce log register macro jerinj
@ 2020-06-17  6:30 ` jerinj
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 03/13] drivers/vdpa: " jerinj
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-06-17  6:30 UTC (permalink / raw)
  To: dev, Nicolas Chautru, Konstantin Ananyev, Cristian Dumitrescu,
	Fiona Trahe, Ashish Gupta, Thomas Monjalon, Ferruh Yigit,
	Andrew Rybchenko, Erik Gabriel Carrillo, Jerin Jacob,
	Bernard Iremonger, Kiran Kumar K, Nithin Dabilpuram, Yipeng Wang,
	Sameh Gobriel, Pavan Nikhilesh, Reshma Pattan, Nipun Gupta,
	Hemant Agrawal, Honnappa Nagarahalli, Gage Eads, Olivier Matz,
	Maxime Coquelin, Zhihong Wang, Xiaolong Ye
  Cc: david.marchand

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
---
 lib/librte_bbdev/rte_bbdev.c                  |  8 +------
 lib/librte_bpf/bpf.c                          |  9 +-------
 lib/librte_cfgfile/rte_cfgfile.c              |  8 +------
 lib/librte_compressdev/rte_compressdev.c      |  7 +------
 lib/librte_compressdev/rte_compressdev_pmd.c  |  2 --
 lib/librte_ethdev/rte_ethdev.c                |  9 +++-----
 lib/librte_eventdev/rte_event_timer_adapter.c | 21 +++----------------
 lib/librte_flow_classify/rte_flow_classify.c  | 10 +--------
 lib/librte_graph/graph.c                      |  7 +------
 lib/librte_member/rte_member.c                |  9 +-------
 lib/librte_metrics/rte_metrics_telemetry.c    |  5 ++---
 lib/librte_node/log.c                         |  9 +-------
 lib/librte_pdump/rte_pdump.c                  |  9 ++------
 lib/librte_rawdev/rte_rawdev.c                |  7 +++----
 lib/librte_rcu/rte_rcu_qsbr.c                 |  9 +-------
 lib/librte_stack/rte_stack.c                  |  7 +------
 lib/librte_vhost/vhost.c                      | 15 ++-----------
 17 files changed, 25 insertions(+), 126 deletions(-)

diff --git a/lib/librte_bbdev/rte_bbdev.c b/lib/librte_bbdev/rte_bbdev.c
index f6fe05aca..578f44484 100644
--- a/lib/librte_bbdev/rte_bbdev.c
+++ b/lib/librte_bbdev/rte_bbdev.c
@@ -29,7 +29,7 @@
 
 
 /* BBDev library logging ID */
-static int bbdev_logtype;
+RTE_LOG_REGISTER(bbdev_logtype, lib.bbdev, NOTICE);
 
 /* Helper macro for logging */
 #define rte_bbdev_log(level, fmt, ...) \
@@ -1134,9 +1134,3 @@ rte_bbdev_op_type_str(enum rte_bbdev_op_type op_type)
 	return NULL;
 }
 
-RTE_INIT(rte_bbdev_init_log)
-{
-	bbdev_logtype = rte_log_register("lib.bbdev");
-	if (bbdev_logtype >= 0)
-		rte_log_set_level(bbdev_logtype, RTE_LOG_NOTICE);
-}
diff --git a/lib/librte_bpf/bpf.c b/lib/librte_bpf/bpf.c
index 7e1879ffa..8d15885bc 100644
--- a/lib/librte_bpf/bpf.c
+++ b/lib/librte_bpf/bpf.c
@@ -14,8 +14,6 @@
 
 #include "bpf_impl.h"
 
-int rte_bpf_logtype;
-
 void
 rte_bpf_destroy(struct rte_bpf *bpf)
 {
@@ -55,9 +53,4 @@ bpf_jit(struct rte_bpf *bpf)
 	return rc;
 }
 
-RTE_INIT(rte_bpf_init_log)
-{
-	rte_bpf_logtype = rte_log_register("lib.bpf");
-	if (rte_bpf_logtype >= 0)
-		rte_log_set_level(rte_bpf_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(rte_bpf_logtype, lib.bpf, INFO);
diff --git a/lib/librte_cfgfile/rte_cfgfile.c b/lib/librte_cfgfile/rte_cfgfile.c
index 9049fd9c2..caa2677b5 100644
--- a/lib/librte_cfgfile/rte_cfgfile.c
+++ b/lib/librte_cfgfile/rte_cfgfile.c
@@ -27,7 +27,7 @@ struct rte_cfgfile {
 	struct rte_cfgfile_section *sections;
 };
 
-static int cfgfile_logtype;
+RTE_LOG_REGISTER(cfgfile_logtype, lib.cfgfile, INFO);
 
 #define CFG_LOG(level, fmt, args...)					\
 	rte_log(RTE_LOG_ ## level, cfgfile_logtype, "%s(): " fmt "\n",	\
@@ -563,9 +563,3 @@ rte_cfgfile_has_entry(struct rte_cfgfile *cfg, const char *sectionname,
 	return rte_cfgfile_get_entry(cfg, sectionname, entryname) != NULL;
 }
 
-RTE_INIT(cfgfile_init)
-{
-	cfgfile_logtype = rte_log_register("lib.cfgfile");
-	if (cfgfile_logtype >= 0)
-		rte_log_set_level(cfgfile_logtype, RTE_LOG_INFO);
-}
diff --git a/lib/librte_compressdev/rte_compressdev.c b/lib/librte_compressdev/rte_compressdev.c
index b3c5651dc..49a342f40 100644
--- a/lib/librte_compressdev/rte_compressdev.c
+++ b/lib/librte_compressdev/rte_compressdev.c
@@ -763,9 +763,4 @@ rte_compressdev_name_get(uint8_t dev_id)
 	return dev->data->name;
 }
 
-RTE_INIT(rte_compressdev_log)
-{
-	compressdev_logtype = rte_log_register("lib.compressdev");
-	if (compressdev_logtype >= 0)
-		rte_log_set_level(compressdev_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(compressdev_logtype, lib.compressdev, NOTICE);
diff --git a/lib/librte_compressdev/rte_compressdev_pmd.c b/lib/librte_compressdev/rte_compressdev_pmd.c
index 46b25565a..7f500d76d 100644
--- a/lib/librte_compressdev/rte_compressdev_pmd.c
+++ b/lib/librte_compressdev/rte_compressdev_pmd.c
@@ -10,8 +10,6 @@
 #include "rte_compressdev_internal.h"
 #include "rte_compressdev_pmd.h"
 
-int compressdev_logtype;
-
 /**
  * Parse name from argument
  */
diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 8e10a6fc3..d06b7f9b1 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -46,8 +46,6 @@
 #include "ethdev_profile.h"
 #include "ethdev_private.h"
 
-int rte_eth_dev_logtype;
-
 static const char *MZ_RTE_ETH_DEV_DATA = "rte_eth_dev_data";
 struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS];
 
@@ -5295,11 +5293,10 @@ handle_port_link_status(const char *cmd __rte_unused,
 	return 0;
 }
 
-RTE_INIT(ethdev_init_log)
+RTE_LOG_REGISTER(rte_eth_dev_logtype, lib.ethdev, INFO);
+
+RTE_INIT(ethdev_init_telemetry)
 {
-	rte_eth_dev_logtype = rte_log_register("lib.ethdev");
-	if (rte_eth_dev_logtype >= 0)
-		rte_log_set_level(rte_eth_dev_logtype, RTE_LOG_INFO);
 	rte_telemetry_register_cmd("/ethdev/list", handle_port_list,
 			"Returns list of available ethdev ports. Takes no parameters");
 	rte_telemetry_register_cmd("/ethdev/xstats", handle_port_xstats,
diff --git a/lib/librte_eventdev/rte_event_timer_adapter.c b/lib/librte_eventdev/rte_event_timer_adapter.c
index 005459f7d..ae68b4566 100644
--- a/lib/librte_eventdev/rte_event_timer_adapter.c
+++ b/lib/librte_eventdev/rte_event_timer_adapter.c
@@ -29,9 +29,9 @@
 #define DATA_MZ_NAME_MAX_LEN 64
 #define DATA_MZ_NAME_FORMAT "rte_event_timer_adapter_data_%d"
 
-static int evtim_logtype;
-static int evtim_svc_logtype;
-static int evtim_buffer_logtype;
+RTE_LOG_REGISTER(evtim_logtype, lib.eventdev.adapter.timer, NOTICE);
+RTE_LOG_REGISTER(evtim_buffer_logtype, lib.eventdev.adapter.timer, NOTICE);
+RTE_LOG_REGISTER(evtim_svc_logtype, lib.eventdev.adapter.timer.svc, NOTICE);
 
 static struct rte_event_timer_adapter adapters[RTE_EVENT_TIMER_ADAPTER_NUM_MAX];
 
@@ -1188,18 +1188,3 @@ static const struct rte_event_timer_adapter_ops swtim_ops = {
 	.cancel_burst		= swtim_cancel_burst,
 };
 
-RTE_INIT(event_timer_adapter_init_log)
-{
-	evtim_logtype = rte_log_register("lib.eventdev.adapter.timer");
-	if (evtim_logtype >= 0)
-		rte_log_set_level(evtim_logtype, RTE_LOG_NOTICE);
-
-	evtim_buffer_logtype = rte_log_register("lib.eventdev.adapter.timer."
-						"buffer");
-	if (evtim_buffer_logtype >= 0)
-		rte_log_set_level(evtim_buffer_logtype, RTE_LOG_NOTICE);
-
-	evtim_svc_logtype = rte_log_register("lib.eventdev.adapter.timer.svc");
-	if (evtim_svc_logtype >= 0)
-		rte_log_set_level(evtim_svc_logtype, RTE_LOG_NOTICE);
-}
diff --git a/lib/librte_flow_classify/rte_flow_classify.c b/lib/librte_flow_classify/rte_flow_classify.c
index 6022064d8..639b0051f 100644
--- a/lib/librte_flow_classify/rte_flow_classify.c
+++ b/lib/librte_flow_classify/rte_flow_classify.c
@@ -10,8 +10,6 @@
 #include <rte_table_acl.h>
 #include <stdbool.h>
 
-int librte_flow_classify_logtype;
-
 static uint32_t unique_id = 1;
 
 enum rte_flow_classify_table_type table_type
@@ -669,10 +667,4 @@ rte_flow_classifier_query(struct rte_flow_classifier *cls,
 	return ret;
 }
 
-RTE_INIT(librte_flow_classify_init_log)
-{
-	librte_flow_classify_logtype =
-		rte_log_register("lib.flow_classify");
-	if (librte_flow_classify_logtype >= 0)
-		rte_log_set_level(librte_flow_classify_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(librte_flow_classify_logtype, lib.flow_classify, INFO);
diff --git a/lib/librte_graph/graph.c b/lib/librte_graph/graph.c
index 0ea83df3d..baa383cd7 100644
--- a/lib/librte_graph/graph.c
+++ b/lib/librte_graph/graph.c
@@ -579,9 +579,4 @@ rte_graph_max_count(void)
 	return graph_id;
 }
 
-RTE_INIT(rte_graph_init_log)
-{
-	rte_graph_logtype = rte_log_register("lib.graph");
-	if (rte_graph_logtype >= 0)
-		rte_log_set_level(rte_graph_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(rte_graph_logtype, lib.graph, INFO);
diff --git a/lib/librte_member/rte_member.c b/lib/librte_member/rte_member.c
index e0e7f127e..4696c0f17 100644
--- a/lib/librte_member/rte_member.c
+++ b/lib/librte_member/rte_member.c
@@ -16,8 +16,6 @@
 #include "rte_member_ht.h"
 #include "rte_member_vbf.h"
 
-int librte_member_logtype;
-
 TAILQ_HEAD(rte_member_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_member_tailq = {
 	.name = "RTE_MEMBER",
@@ -299,9 +297,4 @@ rte_member_reset(const struct rte_member_setsum *setsum)
 	}
 }
 
-RTE_INIT(librte_member_init_log)
-{
-	librte_member_logtype = rte_log_register("lib.member");
-	if (librte_member_logtype >= 0)
-		rte_log_set_level(librte_member_logtype, RTE_LOG_DEBUG);
-}
+RTE_LOG_REGISTER(librte_member_logtype, lib.member, DEBUG);
diff --git a/lib/librte_metrics/rte_metrics_telemetry.c b/lib/librte_metrics/rte_metrics_telemetry.c
index 040e87d18..289ebae0b 100644
--- a/lib/librte_metrics/rte_metrics_telemetry.c
+++ b/lib/librte_metrics/rte_metrics_telemetry.c
@@ -525,6 +525,8 @@ handle_ports_stats_values_by_name(const char *cmd __rte_unused,
 	return used;
 }
 
+RTE_LOG_REGISTER(metrics_log_level, lib.metrics, ERR);
+
 RTE_INIT(metrics_ctor)
 {
 #ifdef RTE_LIBRTE_TELEMETRY
@@ -535,7 +537,4 @@ RTE_INIT(metrics_ctor)
 	rte_telemetry_legacy_register("ports_stats_values_by_name", DATA_REQ,
 			handle_ports_stats_values_by_name);
 #endif
-	metrics_log_level = rte_log_register("lib.metrics");
-	if (metrics_log_level >= 0)
-		rte_log_set_level(metrics_log_level, RTE_LOG_ERR);
 }
diff --git a/lib/librte_node/log.c b/lib/librte_node/log.c
index f035f91e8..f14199f07 100644
--- a/lib/librte_node/log.c
+++ b/lib/librte_node/log.c
@@ -4,11 +4,4 @@
 
 #include "node_private.h"
 
-int rte_node_logtype;
-
-RTE_INIT(rte_node_init_log)
-{
-	rte_node_logtype = rte_log_register("lib.node");
-	if (rte_node_logtype >= 0)
-		rte_log_set_level(rte_node_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(rte_node_logtype, lib.node, INFO);
diff --git a/lib/librte_pdump/rte_pdump.c b/lib/librte_pdump/rte_pdump.c
index f96709f95..5016e9dd2 100644
--- a/lib/librte_pdump/rte_pdump.c
+++ b/lib/librte_pdump/rte_pdump.c
@@ -14,8 +14,9 @@
 
 #define DEVICE_ID_SIZE 64
 
+RTE_LOG_REGISTER(pdump_logtype, lib.pdump, NOTICE);
+
 /* Macro for printing using RTE_LOG */
-static int pdump_logtype;
 #define PDUMP_LOG(level, fmt, args...)				\
 	rte_log(RTE_LOG_ ## level, pdump_logtype, "%s(): " fmt,	\
 		__func__, ## args)
@@ -561,9 +562,3 @@ rte_pdump_disable_by_deviceid(char *device_id, uint16_t queue,
 	return ret;
 }
 
-RTE_INIT(pdump_log)
-{
-	pdump_logtype = rte_log_register("lib.pdump");
-	if (pdump_logtype >= 0)
-		rte_log_set_level(pdump_logtype, RTE_LOG_NOTICE);
-}
diff --git a/lib/librte_rawdev/rte_rawdev.c b/lib/librte_rawdev/rte_rawdev.c
index c332a7648..aec61f425 100644
--- a/lib/librte_rawdev/rte_rawdev.c
+++ b/lib/librte_rawdev/rte_rawdev.c
@@ -613,11 +613,10 @@ handle_dev_xstats(const char *cmd __rte_unused,
 	return 0;
 }
 
-RTE_INIT(librawdev_init_log)
+RTE_LOG_REGISTER(librawdev_logtype, lib.rawdev, INFO);
+
+RTE_INIT(librawdev_init_telemetry)
 {
-	librawdev_logtype = rte_log_register("lib.rawdev");
-	if (librawdev_logtype >= 0)
-		rte_log_set_level(librawdev_logtype, RTE_LOG_INFO);
 	rte_telemetry_register_cmd("/rawdev/list", handle_dev_list,
 			"Returns list of available rawdev ports. Takes no parameters");
 	rte_telemetry_register_cmd("/rawdev/xstats", handle_dev_xstats,
diff --git a/lib/librte_rcu/rte_rcu_qsbr.c b/lib/librte_rcu/rte_rcu_qsbr.c
index 6a429d8b3..aebfdb0da 100644
--- a/lib/librte_rcu/rte_rcu_qsbr.c
+++ b/lib/librte_rcu/rte_rcu_qsbr.c
@@ -495,11 +495,4 @@ rte_rcu_qsbr_dq_delete(struct rte_rcu_qsbr_dq *dq)
 	return 0;
 }
 
-int rte_rcu_log_type;
-
-RTE_INIT(rte_rcu_register)
-{
-	rte_rcu_log_type = rte_log_register("lib.rcu");
-	if (rte_rcu_log_type >= 0)
-		rte_log_set_level(rte_rcu_log_type, RTE_LOG_ERR);
-}
+RTE_LOG_REGISTER(rte_rcu_log_type, lib.rcu, ERR);
diff --git a/lib/librte_stack/rte_stack.c b/lib/librte_stack/rte_stack.c
index d19824f00..b39e23e63 100644
--- a/lib/librte_stack/rte_stack.c
+++ b/lib/librte_stack/rte_stack.c
@@ -189,9 +189,4 @@ rte_stack_lookup(const char *name)
 	return r;
 }
 
-RTE_INIT(librte_stack_init_log)
-{
-	stack_logtype = rte_log_register("lib.stack");
-	if (stack_logtype >= 0)
-		rte_log_set_level(stack_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(stack_logtype, lib.stack, NOTICE);
diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
index 026631844..872d57f61 100644
--- a/lib/librte_vhost/vhost.c
+++ b/lib/librte_vhost/vhost.c
@@ -27,9 +27,6 @@
 
 struct virtio_net *vhost_devices[MAX_VHOST_DEVICE];
 
-int vhost_config_log_level;
-int vhost_data_log_level;
-
 /* Called with iotlb_lock read-locked */
 uint64_t
 __vhost_iova_to_vva(struct virtio_net *dev, struct vhost_virtqueue *vq,
@@ -1517,13 +1514,5 @@ int rte_vhost_extern_callback_register(int vid,
 	return 0;
 }
 
-RTE_INIT(vhost_log_init)
-{
-	vhost_config_log_level = rte_log_register("lib.vhost.config");
-	if (vhost_config_log_level >= 0)
-		rte_log_set_level(vhost_config_log_level, RTE_LOG_INFO);
-
-	vhost_data_log_level = rte_log_register("lib.vhost.data");
-	if (vhost_data_log_level >= 0)
-		rte_log_set_level(vhost_data_log_level, RTE_LOG_WARNING);
-}
+RTE_LOG_REGISTER(vhost_config_log_level, lib.vhost.config, INFO);
+RTE_LOG_REGISTER(vhost_data_log_level, lib.vhost.data, WARNING);
-- 
2.26.2


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

* [dpdk-dev]  [PATCH 03/13] drivers/vdpa: use log register macro
  2020-06-17  6:30 [dpdk-dev] [PATCH 00/13] rte_log registration usage improvement jerinj
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 01/13] eal/log: introduce log register macro jerinj
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 02/13] lib: use " jerinj
@ 2020-06-17  6:30 ` jerinj
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 04/13] drivers/raw: " jerinj
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-06-17  6:30 UTC (permalink / raw)
  To: dev, Xiao Wang, Matan Azrad, Viacheslav Ovsiienko
  Cc: thomas, olivier.matz, david.marchand, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
---
 drivers/vdpa/ifc/ifcvf_vdpa.c | 10 +---------
 drivers/vdpa/mlx5/mlx5_vdpa.c |  7 +++----
 2 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
index ec97178dc..78299fa67 100644
--- a/drivers/vdpa/ifc/ifcvf_vdpa.c
+++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
@@ -24,6 +24,7 @@
 
 #include "base/ifcvf.h"
 
+RTE_LOG_REGISTER(ifcvf_vdpa_logtype, pmd.net.ifcvf_vdpa, NOTICE);
 #define DRV_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, ifcvf_vdpa_logtype, \
 		"IFCVF %s(): " fmt "\n", __func__, ##args)
@@ -44,8 +45,6 @@ static const char * const ifcvf_valid_arguments[] = {
 	NULL
 };
 
-static int ifcvf_vdpa_logtype;
-
 struct ifcvf_internal {
 	struct rte_vdpa_dev_addr dev_addr;
 	struct rte_pci_device *pdev;
@@ -1271,10 +1270,3 @@ static struct rte_pci_driver rte_ifcvf_vdpa = {
 RTE_PMD_REGISTER_PCI(net_ifcvf, rte_ifcvf_vdpa);
 RTE_PMD_REGISTER_PCI_TABLE(net_ifcvf, pci_id_ifcvf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_ifcvf, "* vfio-pci");
-
-RTE_INIT(ifcvf_vdpa_init_log)
-{
-	ifcvf_vdpa_logtype = rte_log_register("pmd.net.ifcvf_vdpa");
-	if (ifcvf_vdpa_logtype >= 0)
-		rte_log_set_level(ifcvf_vdpa_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c
index 1113d6cef..b166207c4 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa.c
@@ -608,15 +608,14 @@ static struct rte_pci_driver mlx5_vdpa_driver = {
 	.drv_flags = 0,
 };
 
+
+RTE_LOG_REGISTER(mlx5_vdpa_logtype, pmd.vdpa.mlx5, NOTICE);
+
 /**
  * Driver initialization routine.
  */
 RTE_INIT(rte_mlx5_vdpa_init)
 {
-	/* Initialize common log type. */
-	mlx5_vdpa_logtype = rte_log_register("pmd.vdpa.mlx5");
-	if (mlx5_vdpa_logtype >= 0)
-		rte_log_set_level(mlx5_vdpa_logtype, RTE_LOG_NOTICE);
 	if (mlx5_glue)
 		rte_pci_register(&mlx5_vdpa_driver);
 }
-- 
2.26.2


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

* [dpdk-dev]  [PATCH 04/13] drivers/raw: use log register macro
  2020-06-17  6:30 [dpdk-dev] [PATCH 00/13] rte_log registration usage improvement jerinj
                   ` (2 preceding siblings ...)
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 03/13] drivers/vdpa: " jerinj
@ 2020-06-17  6:30 ` jerinj
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 05/13] drivers/net: " jerinj
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-06-17  6:30 UTC (permalink / raw)
  To: dev, Nipun Gupta, Rosen Xu, Tianfei zhang, Bruce Richardson,
	Xiaoyun Li, Jingjing Wu, Hemant Agrawal
  Cc: thomas, olivier.matz, david.marchand, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
---
 drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c  | 11 +----------
 drivers/raw/dpaa2_qdma/dpaa2_qdma.c    | 11 +----------
 drivers/raw/ifpga/ifpga_rawdev.c       | 10 +---------
 drivers/raw/ioat/ioat_rawdev.c         | 12 ++----------
 drivers/raw/ioat/rte_ioat_rawdev.h     |  2 --
 drivers/raw/ntb/ntb.c                  | 10 +---------
 drivers/raw/skeleton/skeleton_rawdev.c | 11 +----------
 7 files changed, 7 insertions(+), 60 deletions(-)

diff --git a/drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c b/drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c
index 7c21c6a52..c7bddbc6c 100644
--- a/drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c
+++ b/drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c
@@ -20,9 +20,6 @@
 #include "dpaa2_cmdif_logs.h"
 #include "rte_pmd_dpaa2_cmdif.h"
 
-/* Dynamic log type identifier */
-int dpaa2_cmdif_logtype;
-
 /* CMDIF driver name */
 #define DPAA2_CMDIF_PMD_NAME dpaa2_dpci
 
@@ -291,10 +288,4 @@ static struct rte_vdev_driver dpaa2_cmdif_drv = {
 };
 
 RTE_PMD_REGISTER_VDEV(DPAA2_CMDIF_PMD_NAME, dpaa2_cmdif_drv);
-
-RTE_INIT(dpaa2_cmdif_init_log)
-{
-	dpaa2_cmdif_logtype = rte_log_register("pmd.raw.dpaa2.cmdif");
-	if (dpaa2_cmdif_logtype >= 0)
-		rte_log_set_level(dpaa2_cmdif_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(dpaa2_cmdif_logtype, pmd.raw.dpaa2.cmdif, INFO);
diff --git a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
index 1be1b6ddf..0b9c4e3d7 100644
--- a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
+++ b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
@@ -26,9 +26,6 @@
 
 #define DPAA2_QDMA_NO_PREFETCH "no_prefetch"
 
-/* Dynamic log type identifier */
-int dpaa2_qdma_logtype;
-
 uint32_t dpaa2_coherent_no_alloc_cache;
 uint32_t dpaa2_coherent_alloc_cache;
 
@@ -1495,10 +1492,4 @@ static struct rte_dpaa2_driver rte_dpaa2_qdma_pmd = {
 RTE_PMD_REGISTER_DPAA2(dpaa2_qdma, rte_dpaa2_qdma_pmd);
 RTE_PMD_REGISTER_PARAM_STRING(dpaa2_qdma,
 	"no_prefetch=<int> ");
-
-RTE_INIT(dpaa2_qdma_init_log)
-{
-	dpaa2_qdma_logtype = rte_log_register("pmd.raw.dpaa2.qdma");
-	if (dpaa2_qdma_logtype >= 0)
-		rte_log_set_level(dpaa2_qdma_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(dpaa2_qdma_logtype, pmd.raw.dpaa2.qdma, INFO);
diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c
index b8701e155..cc25c662b 100644
--- a/drivers/raw/ifpga/ifpga_rawdev.c
+++ b/drivers/raw/ifpga/ifpga_rawdev.c
@@ -47,8 +47,6 @@
 #define RTE_PCI_EXT_CAP_ID(header)       (int)(header & 0x0000ffff)
 #define RTE_PCI_EXT_CAP_NEXT(header)     ((header >> 20) & 0xffc)
 
-int ifpga_rawdev_logtype;
-
 #define PCI_VENDOR_ID_INTEL          0x8086
 /* PCI Device ID */
 #define PCIE_DEVICE_ID_PF_INT_5_X    0xBCBD
@@ -1597,13 +1595,7 @@ static struct rte_pci_driver rte_ifpga_rawdev_pmd = {
 RTE_PMD_REGISTER_PCI(ifpga_rawdev_pci_driver, rte_ifpga_rawdev_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(ifpga_rawdev_pci_driver, rte_ifpga_rawdev_pmd);
 RTE_PMD_REGISTER_KMOD_DEP(ifpga_rawdev_pci_driver, "* igb_uio | uio_pci_generic | vfio-pci");
-
-RTE_INIT(ifpga_rawdev_init_log)
-{
-	ifpga_rawdev_logtype = rte_log_register("driver.raw.init");
-	if (ifpga_rawdev_logtype >= 0)
-		rte_log_set_level(ifpga_rawdev_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(ifpga_rawdev_logtype, driver.raw.init, NOTICE);
 
 static const char * const valid_args[] = {
 #define IFPGA_ARG_NAME         "ifpga"
diff --git a/drivers/raw/ioat/ioat_rawdev.c b/drivers/raw/ioat/ioat_rawdev.c
index a8a48f90a..30d9f597e 100644
--- a/drivers/raw/ioat/ioat_rawdev.c
+++ b/drivers/raw/ioat/ioat_rawdev.c
@@ -9,9 +9,6 @@
 
 #include "rte_ioat_rawdev.h"
 
-/* Dynamic log type identifier */
-int ioat_pmd_logtype;
-
 static struct rte_pci_driver ioat_pmd_drv;
 
 #define IOAT_VENDOR_ID		0x8086
@@ -28,6 +25,8 @@ static struct rte_pci_driver ioat_pmd_drv;
 #define IOAT_DEVICE_ID_BDXF	0x6f2F
 #define IOAT_DEVICE_ID_ICX	0x0b00
 
+RTE_LOG_REGISTER(ioat_pmd_logtype,  rawdev.ioat, INFO);
+
 #define IOAT_PMD_LOG(level, fmt, args...) rte_log(RTE_LOG_ ## level, \
 	ioat_pmd_logtype, "%s(): " fmt "\n", __func__, ##args)
 
@@ -386,10 +385,3 @@ static struct rte_pci_driver ioat_pmd_drv = {
 RTE_PMD_REGISTER_PCI(IOAT_PMD_RAWDEV_NAME, ioat_pmd_drv);
 RTE_PMD_REGISTER_PCI_TABLE(IOAT_PMD_RAWDEV_NAME, pci_id_ioat_map);
 RTE_PMD_REGISTER_KMOD_DEP(IOAT_PMD_RAWDEV_NAME, "* igb_uio | uio_pci_generic");
-
-RTE_INIT(ioat_pmd_init_log)
-{
-	ioat_pmd_logtype = rte_log_register(IOAT_PMD_LOG_NAME);
-	if (ioat_pmd_logtype >= 0)
-		rte_log_set_level(ioat_pmd_logtype, RTE_LOG_INFO);
-}
diff --git a/drivers/raw/ioat/rte_ioat_rawdev.h b/drivers/raw/ioat/rte_ioat_rawdev.h
index 4b271f174..f765a6557 100644
--- a/drivers/raw/ioat/rte_ioat_rawdev.h
+++ b/drivers/raw/ioat/rte_ioat_rawdev.h
@@ -25,8 +25,6 @@
 #define IOAT_PMD_RAWDEV_NAME rawdev_ioat
 /** String reported as the device driver name by rte_rawdev_info_get() */
 #define IOAT_PMD_RAWDEV_NAME_STR "rawdev_ioat"
-/** Name used to adjust the log level for this driver */
-#define IOAT_PMD_LOG_NAME "rawdev.ioat"
 
 /**
  * Configuration structure for an ioat rawdev instance
diff --git a/drivers/raw/ntb/ntb.c b/drivers/raw/ntb/ntb.c
index dd0b72f8c..e40412bb7 100644
--- a/drivers/raw/ntb/ntb.c
+++ b/drivers/raw/ntb/ntb.c
@@ -23,8 +23,6 @@
 #include "rte_pmd_ntb.h"
 #include "ntb.h"
 
-int ntb_logtype;
-
 static const struct rte_pci_id pci_id_ntb_map[] = {
 	{ RTE_PCI_DEVICE(NTB_INTEL_VENDOR_ID, NTB_INTEL_DEV_ID_B2B_SKX) },
 	{ .vendor_id = 0, /* sentinel */ },
@@ -1504,10 +1502,4 @@ static struct rte_pci_driver rte_ntb_pmd = {
 RTE_PMD_REGISTER_PCI(raw_ntb, rte_ntb_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(raw_ntb, pci_id_ntb_map);
 RTE_PMD_REGISTER_KMOD_DEP(raw_ntb, "* igb_uio | uio_pci_generic | vfio-pci");
-
-RTE_INIT(ntb_init_log)
-{
-	ntb_logtype = rte_log_register("pmd.raw.ntb");
-	if (ntb_logtype >= 0)
-		rte_log_set_level(ntb_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(ntb_logtype, pmd.raw.ntb, INFO);
diff --git a/drivers/raw/skeleton/skeleton_rawdev.c b/drivers/raw/skeleton/skeleton_rawdev.c
index 586183a5b..72ece887a 100644
--- a/drivers/raw/skeleton/skeleton_rawdev.c
+++ b/drivers/raw/skeleton/skeleton_rawdev.c
@@ -28,9 +28,6 @@
 
 #include "skeleton_rawdev.h"
 
-/* Dynamic log type identifier */
-int skeleton_pmd_logtype;
-
 /* Count of instances */
 static uint16_t skeldev_init_once;
 
@@ -759,10 +756,4 @@ static struct rte_vdev_driver skeleton_pmd_drv = {
 };
 
 RTE_PMD_REGISTER_VDEV(SKELETON_PMD_RAWDEV_NAME, skeleton_pmd_drv);
-
-RTE_INIT(skeleton_pmd_init_log)
-{
-	skeleton_pmd_logtype = rte_log_register("rawdev.skeleton");
-	if (skeleton_pmd_logtype >= 0)
-		rte_log_set_level(skeleton_pmd_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(skeleton_pmd_logtype, rawdev.skeleton, INFO);
-- 
2.26.2


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

* [dpdk-dev]  [PATCH 05/13] drivers/net: use log register macro
  2020-06-17  6:30 [dpdk-dev] [PATCH 00/13] rte_log registration usage improvement jerinj
                   ` (3 preceding siblings ...)
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 04/13] drivers/raw: " jerinj
@ 2020-06-17  6:30 ` jerinj
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 06/13] drivers/mempool: " jerinj
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-06-17  6:30 UTC (permalink / raw)
  To: dev, John W. Linville, Xiaolong Ye, Qi Zhang, Shepard Siegel,
	Ed Czeck, John Miller, Igor Russkikh, Pavel Belous,
	Steven Webster, Matt Peters, Somalapuram Amaranath, Rasesh Mody,
	Shahed Shaikh, Ajit Khaparde, Somnath Kotur, Chas Williams,
	Wei Hu (Xavier),
	Rahul Lakkireddy, Hemant Agrawal, Sachin Saxena, Marcin Wojtas,
	Michal Krawczyk, Guy Tzalik, Evgeny Schemeilin, Igor Chauskin,
	Gagandeep Singh, John Daley, Hyong Youb Kim, Gaetan Rivet,
	Xiao Wang, Ziyang Xuan, Xiaoyun Wang, Guoyang Zhou,
	Min Hu (Connor),
	Yisen Zhuang, Beilei Xing, Jeff Guo, Jingjing Wu, Qiming Yang,
	Wei Zhao, Alfredo Cardigliano, Rosen Xu, Ferruh Yigit,
	Shijith Thotton, Srisivasubramanian Srinivasan, Jakub Grajciar,
	Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko, Zyta Szpak,
	Liron Himi, Stephen Hemminger, K. Y. Srinivasan, Haiyang Zhang,
	Heinrich Kuhn, Tetsuya Mukawa, Harman Kalra, Akhil Goyal,
	Bruce Richardson, Jasvinder Singh, Cristian Dumitrescu,
	Martin Zizka, Jakub Neruda, Keith Wiles, Jerin Jacob,
	Maciej Czekaj, Maxime Coquelin, Zhihong Wang, Yong Wang
  Cc: thomas, olivier.matz, david.marchand

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
---
 drivers/net/af_packet/rte_eth_af_packet.c |  8 +---
 drivers/net/af_xdp/rte_eth_af_xdp.c       |  8 +---
 drivers/net/ark/ark_ethdev.c              | 10 +----
 drivers/net/atlantic/atl_ethdev.c         | 15 +------
 drivers/net/avp/avp_ethdev.c              | 10 +----
 drivers/net/axgbe/axgbe_ethdev.c          | 15 +------
 drivers/net/bnx2x/bnx2x_ethdev.c          | 15 +------
 drivers/net/bnxt/bnxt_ethdev.c            |  9 +----
 drivers/net/bonding/rte_eth_bond_pmd.c    |  9 +----
 drivers/net/cxgbe/cxgbe_ethdev.c          | 15 +------
 drivers/net/dpaa/dpaa_ethdev.c            |  9 +----
 drivers/net/dpaa2/dpaa2_ethdev.c          |  9 +----
 drivers/net/ena/ena_ethdev.c              | 48 +++--------------------
 drivers/net/enetc/enetc_ethdev.c          | 10 +----
 drivers/net/enic/enic_ethdev.c            |  9 +----
 drivers/net/failsafe/failsafe.c           | 10 +----
 drivers/net/fm10k/fm10k_ethdev.c          | 40 +++----------------
 drivers/net/hinic/hinic_pmd_ethdev.c      | 11 +-----
 drivers/net/hns3/hns3_ethdev.c            | 15 +------
 drivers/net/i40e/i40e_ethdev.c            | 38 +++---------------
 drivers/net/iavf/iavf_ethdev.c            | 40 +++----------------
 drivers/net/ice/ice_ethdev.c              | 38 +++---------------
 drivers/net/igc/igc_logs.c                | 16 +-------
 drivers/net/ionic/ionic_ethdev.c          | 10 +----
 drivers/net/ipn3ke/ipn3ke_ethdev.c        | 10 +----
 drivers/net/ixgbe/ixgbe_ethdev.c          | 39 +++---------------
 drivers/net/kni/rte_eth_kni.c             |  9 +----
 drivers/net/liquidio/lio_ethdev.c         | 15 +------
 drivers/net/memif/rte_eth_memif.c         |  9 +----
 drivers/net/mlx4/mlx4.c                   | 11 ++----
 drivers/net/mlx5/mlx5.c                   | 11 ++----
 drivers/net/mvneta/mvneta_ethdev.c        | 10 +----
 drivers/net/mvpp2/mrvl_ethdev.c           | 10 +----
 drivers/net/netvsc/hn_ethdev.c            | 15 +------
 drivers/net/nfp/nfp_net.c                 | 15 +------
 drivers/net/null/rte_eth_null.c           |  8 +---
 drivers/net/octeontx/octeontx_ethdev.c    | 21 ++--------
 drivers/net/pcap/rte_eth_pcap.c           |  8 +---
 drivers/net/pfe/pfe_ethdev.c              | 10 +----
 drivers/net/qede/qede_ethdev.c            | 16 +-------
 drivers/net/ring/rte_eth_ring.c           |  8 +---
 drivers/net/softnic/rte_eth_softnic.c     | 10 +----
 drivers/net/szedata2/rte_eth_szedata2.c   | 15 +------
 drivers/net/tap/rte_eth_tap.c             |  9 +----
 drivers/net/thunderx/nicvf_ethdev.c       | 21 ++--------
 drivers/net/vdev_netvsc/vdev_netvsc.c     | 13 +-----
 drivers/net/vhost/rte_eth_vhost.c         |  8 +---
 drivers/net/virtio/virtio_ethdev.c        | 15 +------
 drivers/net/vmxnet3/vmxnet3_ethdev.c      | 15 +------
 49 files changed, 97 insertions(+), 651 deletions(-)

diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index 22feb72e3..300039bbf 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -97,7 +97,7 @@ static struct rte_eth_link pmd_link = {
 	.link_autoneg = ETH_LINK_FIXED,
 };
 
-static int af_packet_logtype;
+RTE_LOG_REGISTER(af_packet_logtype, pmd.net.packet, NOTICE);
 
 #define PMD_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, af_packet_logtype, \
@@ -1082,9 +1082,3 @@ RTE_PMD_REGISTER_PARAM_STRING(net_af_packet,
 	"framecnt=<int> "
 	"qdisc_bypass=<0|1>");
 
-RTE_INIT(af_packet_init_log)
-{
-	af_packet_logtype = rte_log_register("pmd.net.packet");
-	if (af_packet_logtype >= 0)
-		rte_log_set_level(af_packet_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 06124ba78..98b9cff38 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -50,7 +50,7 @@
 #define PF_XDP AF_XDP
 #endif
 
-static int af_xdp_logtype;
+RTE_LOG_REGISTER(af_xdp_logtype, pmd.net.af_xdp, NOTICE);
 
 #define AF_XDP_LOG(level, fmt, args...)			\
 	rte_log(RTE_LOG_ ## level, af_xdp_logtype,	\
@@ -1374,9 +1374,3 @@ RTE_PMD_REGISTER_PARAM_STRING(net_af_xdp,
 			      "start_queue=<int> "
 			      "queue_count=<int> ");
 
-RTE_INIT(af_xdp_init_log)
-{
-	af_xdp_logtype = rte_log_register("pmd.net.af_xdp");
-	if (af_xdp_logtype >= 0)
-		rte_log_set_level(af_xdp_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c
index c3642012d..b32ccd867 100644
--- a/drivers/net/ark/ark_ethdev.c
+++ b/drivers/net/ark/ark_ethdev.c
@@ -78,8 +78,6 @@ static int  eth_ark_set_mtu(struct rte_eth_dev *dev, uint16_t size);
 #define ARK_TX_MAX_QUEUE (4096 * 4)
 #define ARK_TX_MIN_QUEUE (256)
 
-int ark_logtype;
-
 static const char * const valid_arguments[] = {
 	ARK_PKTGEN_ARG,
 	ARK_PKTCHKR_ARG,
@@ -1018,10 +1016,4 @@ RTE_PMD_REGISTER_PARAM_STRING(net_ark,
 			      ARK_PKTGEN_ARG "=<filename> "
 			      ARK_PKTCHKR_ARG "=<filename> "
 			      ARK_PKTDIR_ARG "=<bitmap>");
-
-RTE_INIT(ark_init_log)
-{
-	ark_logtype = rte_log_register("pmd.net.ark");
-	if (ark_logtype >= 0)
-		rte_log_set_level(ark_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(ark_logtype, pmd.net.ark, NOTICE);
diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_ethdev.c
index b2b3bd36c..d3b00ab29 100644
--- a/drivers/net/atlantic/atl_ethdev.c
+++ b/drivers/net/atlantic/atl_ethdev.c
@@ -120,9 +120,6 @@ static int eth_atl_pci_remove(struct rte_pci_device *pci_dev);
 static int atl_dev_info_get(struct rte_eth_dev *dev,
 				struct rte_eth_dev_info *dev_info);
 
-int atl_logtype_init;
-int atl_logtype_driver;
-
 /*
  * The set of PCI devices this driver supports
  */
@@ -1929,13 +1926,5 @@ is_atlantic_supported(struct rte_eth_dev *dev)
 RTE_PMD_REGISTER_PCI(net_atlantic, rte_atl_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_atlantic, pci_id_atl_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_atlantic, "* igb_uio | uio_pci_generic");
-
-RTE_INIT(atl_init_log)
-{
-	atl_logtype_init = rte_log_register("pmd.net.atlantic.init");
-	if (atl_logtype_init >= 0)
-		rte_log_set_level(atl_logtype_init, RTE_LOG_NOTICE);
-	atl_logtype_driver = rte_log_register("pmd.net.atlantic.driver");
-	if (atl_logtype_driver >= 0)
-		rte_log_set_level(atl_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(atl_logtype_init, pmd.net.atlantic.init, NOTICE);
+RTE_LOG_REGISTER(atl_logtype_driver, pmd.net.atlantic.driver, NOTICE);
diff --git a/drivers/net/avp/avp_ethdev.c b/drivers/net/avp/avp_ethdev.c
index 1abe96ce5..5b47f0924 100644
--- a/drivers/net/avp/avp_ethdev.c
+++ b/drivers/net/avp/avp_ethdev.c
@@ -32,8 +32,6 @@
 
 #include "avp_logs.h"
 
-int avp_logtype_driver;
-
 static int avp_dev_create(struct rte_pci_device *pci_dev,
 			  struct rte_eth_dev *eth_dev);
 
@@ -2306,10 +2304,4 @@ avp_dev_stats_reset(struct rte_eth_dev *eth_dev)
 
 RTE_PMD_REGISTER_PCI(net_avp, rte_avp_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_avp, pci_id_avp_map);
-
-RTE_INIT(avp_init_log)
-{
-	avp_logtype_driver = rte_log_register("pmd.net.avp.driver");
-	if (avp_logtype_driver >= 0)
-		rte_log_set_level(avp_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(avp_logtype_driver, pmd.net.avp.driver, NOTICE);
diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c
index db86b9813..0c25739f8 100644
--- a/drivers/net/axgbe/axgbe_ethdev.c
+++ b/drivers/net/axgbe/axgbe_ethdev.c
@@ -143,9 +143,6 @@ static const struct axgbe_xstats axgbe_xstats_strings[] = {
 #define AMD_PCI_AXGBE_DEVICE_V2A 0x1458
 #define AMD_PCI_AXGBE_DEVICE_V2B 0x1459
 
-int axgbe_logtype_init;
-int axgbe_logtype_driver;
-
 static const struct rte_pci_id pci_id_axgbe_map[] = {
 	{RTE_PCI_DEVICE(AMD_PCI_VENDOR_ID, AMD_PCI_AXGBE_DEVICE_V2A)},
 	{RTE_PCI_DEVICE(AMD_PCI_VENDOR_ID, AMD_PCI_AXGBE_DEVICE_V2B)},
@@ -1842,13 +1839,5 @@ static struct rte_pci_driver rte_axgbe_pmd = {
 RTE_PMD_REGISTER_PCI(net_axgbe, rte_axgbe_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_axgbe, pci_id_axgbe_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_axgbe, "* igb_uio | uio_pci_generic | vfio-pci");
-
-RTE_INIT(axgbe_init_log)
-{
-	axgbe_logtype_init = rte_log_register("pmd.net.axgbe.init");
-	if (axgbe_logtype_init >= 0)
-		rte_log_set_level(axgbe_logtype_init, RTE_LOG_NOTICE);
-	axgbe_logtype_driver = rte_log_register("pmd.net.axgbe.driver");
-	if (axgbe_logtype_driver >= 0)
-		rte_log_set_level(axgbe_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(axgbe_logtype_init, pmd.net.axgbe.init, NOTICE);
+RTE_LOG_REGISTER(axgbe_logtype_driver, pmd.net.axgbe.driver, NOTICE);
diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c
index adc3690fc..b2ea5fafa 100644
--- a/drivers/net/bnx2x/bnx2x_ethdev.c
+++ b/drivers/net/bnx2x/bnx2x_ethdev.c
@@ -13,9 +13,6 @@
 #include <rte_ethdev_pci.h>
 #include <rte_alarm.h>
 
-int bnx2x_logtype_init;
-int bnx2x_logtype_driver;
-
 /*
  * The set of PCI devices this driver supports
  */
@@ -805,13 +802,5 @@ RTE_PMD_REGISTER_KMOD_DEP(net_bnx2x, "* igb_uio | uio_pci_generic | vfio-pci");
 RTE_PMD_REGISTER_PCI(net_bnx2xvf, rte_bnx2xvf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_bnx2xvf, pci_id_bnx2xvf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_bnx2xvf, "* igb_uio | vfio-pci");
-
-RTE_INIT(bnx2x_init_log)
-{
-	bnx2x_logtype_init = rte_log_register("pmd.net.bnx2x.init");
-	if (bnx2x_logtype_init >= 0)
-		rte_log_set_level(bnx2x_logtype_init, RTE_LOG_NOTICE);
-	bnx2x_logtype_driver = rte_log_register("pmd.net.bnx2x.driver");
-	if (bnx2x_logtype_driver >= 0)
-		rte_log_set_level(bnx2x_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(bnx2x_logtype_init, pmd.net.bnx2x.init, NOTICE);
+RTE_LOG_REGISTER(bnx2x_logtype_driver, pmd.net.bnx2x.driver, NOTICE);
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index e8b4c058a..59c318076 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -31,7 +31,6 @@
 #define DRV_MODULE_NAME		"bnxt"
 static const char bnxt_version[] =
 	"Broadcom NetXtreme driver " DRV_MODULE_NAME;
-int bnxt_logtype_driver;
 
 /*
  * The set of PCI devices this driver supports
@@ -5668,13 +5667,7 @@ bool is_bnxt_supported(struct rte_eth_dev *dev)
 	return is_device_supported(dev, &bnxt_rte_pmd);
 }
 
-RTE_INIT(bnxt_init_log)
-{
-	bnxt_logtype_driver = rte_log_register("pmd.net.bnxt.driver");
-	if (bnxt_logtype_driver >= 0)
-		rte_log_set_level(bnxt_logtype_driver, RTE_LOG_NOTICE);
-}
-
+RTE_LOG_REGISTER(bnxt_logtype_driver, pmd.net.bnxt.driver, NOTICE);
 RTE_PMD_REGISTER_PCI(net_bnxt, bnxt_rte_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_bnxt, bnxt_pci_id_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_bnxt, "* igb_uio | uio_pci_generic | vfio-pci");
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 612a64599..044a1cfbc 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -3750,11 +3750,4 @@ RTE_PMD_REGISTER_PARAM_STRING(net_bonding,
 	"up_delay=<int> "
 	"down_delay=<int>");
 
-int bond_logtype;
-
-RTE_INIT(bond_init_log)
-{
-	bond_logtype = rte_log_register("pmd.net.bond");
-	if (bond_logtype >= 0)
-		rte_log_set_level(bond_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(bond_logtype, pmd.net.bond, NOTICE);
diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index 1deee2f5c..7c6016d5c 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -38,9 +38,6 @@
 #include "cxgbe_pfvf.h"
 #include "cxgbe_flow.h"
 
-int cxgbe_logtype;
-int cxgbe_mbox_logtype;
-
 /*
  * Macros needed to support the PCI Device ID Table ...
  */
@@ -1247,13 +1244,5 @@ RTE_PMD_REGISTER_PARAM_STRING(net_cxgbe,
 			      CXGBE_DEVARG_CMN_TX_MODE_LATENCY "=<0|1> "
 			      CXGBE_DEVARG_PF_FILTER_MODE "=<uint32> "
 			      CXGBE_DEVARG_PF_FILTER_MASK "=<uint32> ");
-
-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);
-	cxgbe_mbox_logtype = rte_log_register("pmd.net.cxgbe.mbox");
-	if (cxgbe_mbox_logtype >= 0)
-		rte_log_set_level(cxgbe_mbox_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(cxgbe_logtype, pmd.net.cxgbe, NOTICE);
+RTE_LOG_REGISTER(cxgbe_mbox_logtype, pmd.net.cxgbe.mbox, NOTICE);
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 13d1c6a1f..f1c9a7151 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -46,8 +46,6 @@
 #include <fsl_bman.h>
 #include <fsl_fman.h>
 
-int dpaa_logtype_pmd;
-
 /* Supported Rx offloads */
 static uint64_t dev_rx_offloads_sup =
 		DEV_RX_OFFLOAD_JUMBO_FRAME |
@@ -1666,9 +1664,4 @@ static struct rte_dpaa_driver rte_dpaa_pmd = {
 };
 
 RTE_PMD_REGISTER_DPAA(net_dpaa, rte_dpaa_pmd);
-RTE_INIT(dpaa_net_init_log)
-{
-	dpaa_logtype_pmd = rte_log_register("pmd.net.dpaa");
-	if (dpaa_logtype_pmd >= 0)
-		rte_log_set_level(dpaa_logtype_pmd, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa_logtype_pmd, pmd.net.dpaa, NOTICE);
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 2f031ec5c..a1f19194d 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -106,8 +106,6 @@ static int dpaa2_dev_set_link_up(struct rte_eth_dev *dev);
 static int dpaa2_dev_set_link_down(struct rte_eth_dev *dev);
 static int dpaa2_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
 
-int dpaa2_logtype_pmd;
-
 void
 rte_pmd_dpaa2_set_timestamp(enum pmd_dpaa2_ts enable)
 {
@@ -2694,9 +2692,4 @@ RTE_PMD_REGISTER_DPAA2(net_dpaa2, rte_dpaa2_pmd);
 RTE_PMD_REGISTER_PARAM_STRING(net_dpaa2,
 		DRIVER_LOOPBACK_MODE "=<int> "
 		DRIVER_NO_PREFETCH_MODE "=<int>");
-RTE_INIT(dpaa2_pmd_init_log)
-{
-	dpaa2_logtype_pmd = rte_log_register("pmd.net.dpaa2");
-	if (dpaa2_logtype_pmd >= 0)
-		rte_log_set_level(dpaa2_logtype_pmd, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa2_logtype_pmd, pmd.net.dpaa2, NOTICE);
diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index fbddc79f7..da8c8ad92 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -141,22 +141,6 @@ static const struct ena_stats ena_stats_rx_strings[] = {
 #define	ENA_TX_OFFLOAD_NOTSUP_MASK	\
 	(PKT_TX_OFFLOAD_MASK ^ ENA_TX_OFFLOAD_MASK)
 
-int ena_logtype_init;
-int ena_logtype_driver;
-
-#ifdef RTE_LIBRTE_ENA_DEBUG_RX
-int ena_logtype_rx;
-#endif
-#ifdef RTE_LIBRTE_ENA_DEBUG_TX
-int ena_logtype_tx;
-#endif
-#ifdef RTE_LIBRTE_ENA_DEBUG_TX_FREE
-int ena_logtype_tx_free;
-#endif
-#ifdef RTE_LIBRTE_ENA_COM_DEBUG
-int ena_logtype_com;
-#endif
-
 static const struct rte_pci_id pci_id_ena_map[] = {
 	{ RTE_PCI_DEVICE(PCI_VENDOR_ID_AMAZON, PCI_DEVICE_ID_ENA_VF) },
 	{ RTE_PCI_DEVICE(PCI_VENDOR_ID_AMAZON, PCI_DEVICE_ID_ENA_LLQ_VF) },
@@ -2849,40 +2833,20 @@ RTE_PMD_REGISTER_PCI(net_ena, rte_ena_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_ena, pci_id_ena_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_ena, "* igb_uio | uio_pci_generic | vfio-pci");
 RTE_PMD_REGISTER_PARAM_STRING(net_ena, ENA_DEVARG_LARGE_LLQ_HDR "=<0|1>");
-
-RTE_INIT(ena_init_log)
-{
-	ena_logtype_init = rte_log_register("pmd.net.ena.init");
-	if (ena_logtype_init >= 0)
-		rte_log_set_level(ena_logtype_init, RTE_LOG_NOTICE);
-	ena_logtype_driver = rte_log_register("pmd.net.ena.driver");
-	if (ena_logtype_driver >= 0)
-		rte_log_set_level(ena_logtype_driver, RTE_LOG_NOTICE);
-
+RTE_LOG_REGISTER(ena_logtype_init, pmd.net.ena.init, NOTICE);
+RTE_LOG_REGISTER(ena_logtype_driver, pmd.net.ena.driver, NOTICE);
 #ifdef RTE_LIBRTE_ENA_DEBUG_RX
-	ena_logtype_rx = rte_log_register("pmd.net.ena.rx");
-	if (ena_logtype_rx >= 0)
-		rte_log_set_level(ena_logtype_rx, RTE_LOG_NOTICE);
+RTE_LOG_REGISTER(ena_logtype_rx, pmd.net.ena.rx, NOTICE);
 #endif
-
 #ifdef RTE_LIBRTE_ENA_DEBUG_TX
-	ena_logtype_tx = rte_log_register("pmd.net.ena.tx");
-	if (ena_logtype_tx >= 0)
-		rte_log_set_level(ena_logtype_tx, RTE_LOG_NOTICE);
+RTE_LOG_REGISTER(ena_logtype_tx, pmd.net.ena.tx, NOTICE);
 #endif
-
 #ifdef RTE_LIBRTE_ENA_DEBUG_TX_FREE
-	ena_logtype_tx_free = rte_log_register("pmd.net.ena.tx_free");
-	if (ena_logtype_tx_free >= 0)
-		rte_log_set_level(ena_logtype_tx_free, RTE_LOG_NOTICE);
+RTE_LOG_REGISTER(ena_logtype_tx_free, pmd.net.ena.tx_free, NOTICE);
 #endif
-
 #ifdef RTE_LIBRTE_ENA_COM_DEBUG
-	ena_logtype_com = rte_log_register("pmd.net.ena.com");
-	if (ena_logtype_com >= 0)
-		rte_log_set_level(ena_logtype_com, RTE_LOG_NOTICE);
+RTE_LOG_REGISTER(ena_logtype_com, pmd.net.ena.com, NOTICE);
 #endif
-}
 
 /******************************************************************************
  ******************************** AENQ Handlers *******************************
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 1716e11dd..c6fb42740 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -10,8 +10,6 @@
 #include "enetc_logs.h"
 #include "enetc.h"
 
-int enetc_logtype_pmd;
-
 static int
 enetc_dev_start(struct rte_eth_dev *dev)
 {
@@ -951,10 +949,4 @@ static struct rte_pci_driver rte_enetc_pmd = {
 RTE_PMD_REGISTER_PCI(net_enetc, rte_enetc_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_enetc, pci_id_enetc_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_enetc, "* vfio-pci");
-
-RTE_INIT(enetc_pmd_init_log)
-{
-	enetc_logtype_pmd = rte_log_register("pmd.net.enetc");
-	if (enetc_logtype_pmd >= 0)
-		rte_log_set_level(enetc_logtype_pmd, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(enetc_logtype_pmd, pmd.net.enetc, NOTICE);
diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c
index 32d5397f8..6a3580fef 100644
--- a/drivers/net/enic/enic_ethdev.c
+++ b/drivers/net/enic/enic_ethdev.c
@@ -21,8 +21,6 @@
 #include "vnic_enet.h"
 #include "enic.h"
 
-int enic_pmd_logtype;
-
 /*
  * The set of PCI devices this driver supports
  */
@@ -71,12 +69,7 @@ static const struct vic_speed_capa {
 #define ENIC_DEVARG_GENEVE_OPT "geneve-opt"
 #define ENIC_DEVARG_IG_VLAN_REWRITE "ig-vlan-rewrite"
 
-RTE_INIT(enicpmd_init_log)
-{
-	enic_pmd_logtype = rte_log_register("pmd.net.enic");
-	if (enic_pmd_logtype >= 0)
-		rte_log_set_level(enic_pmd_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(enic_pmd_logtype, pmd.net.enic, INFO);
 
 static int
 enicpmd_fdir_ctrl_func(struct rte_eth_dev *eth_dev,
diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsafe.c
index 72362f35d..4a4b7ceab 100644
--- a/drivers/net/failsafe/failsafe.c
+++ b/drivers/net/failsafe/failsafe.c
@@ -15,8 +15,6 @@
 
 #include "failsafe_private.h"
 
-int failsafe_logtype;
-
 const char pmd_failsafe_driver_name[] = FAILSAFE_DRIVER_NAME;
 static const struct rte_eth_link eth_link = {
 	.link_speed = ETH_SPEED_NUM_10G,
@@ -410,10 +408,4 @@ static struct rte_vdev_driver failsafe_drv = {
 
 RTE_PMD_REGISTER_VDEV(net_failsafe, failsafe_drv);
 RTE_PMD_REGISTER_PARAM_STRING(net_failsafe, PMD_FAILSAFE_PARAM_STRING);
-
-RTE_INIT(failsafe_init_log)
-{
-	failsafe_logtype = rte_log_register("pmd.net.failsafe");
-	if (failsafe_logtype >= 0)
-		rte_log_set_level(failsafe_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(failsafe_logtype, pmd.net.failsafe, NOTICE)
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index f537ab286..cb0dd3bae 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -40,19 +40,6 @@
 #define GLORT_FD_MASK    GLORT_PF_MASK
 #define GLORT_FD_INDEX   GLORT_FD_Q_BASE
 
-int fm10k_logtype_init;
-int fm10k_logtype_driver;
-
-#ifdef RTE_LIBRTE_FM10K_DEBUG_RX
-int fm10k_logtype_rx;
-#endif
-#ifdef RTE_LIBRTE_FM10K_DEBUG_TX
-int fm10k_logtype_tx;
-#endif
-#ifdef RTE_LIBRTE_FM10K_DEBUG_TX_FREE
-int fm10k_logtype_tx_free;
-#endif
-
 static void fm10k_close_mbx_service(struct fm10k_hw *hw);
 static int fm10k_dev_promiscuous_enable(struct rte_eth_dev *dev);
 static int fm10k_dev_promiscuous_disable(struct rte_eth_dev *dev);
@@ -3318,31 +3305,14 @@ 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)
-{
-	fm10k_logtype_init = rte_log_register("pmd.net.fm10k.init");
-	if (fm10k_logtype_init >= 0)
-		rte_log_set_level(fm10k_logtype_init, RTE_LOG_NOTICE);
-	fm10k_logtype_driver = rte_log_register("pmd.net.fm10k.driver");
-	if (fm10k_logtype_driver >= 0)
-		rte_log_set_level(fm10k_logtype_driver, RTE_LOG_NOTICE);
-
+RTE_LOG_REGISTER(fm10k_logtype_init, pmd.net.fm10k.init, NOTICE);
+RTE_LOG_REGISTER(fm10k_logtype_driver, pmd.net.fm10k.driver, NOTICE);
 #ifdef RTE_LIBRTE_FM10K_DEBUG_RX
-	fm10k_logtype_rx = rte_log_register("pmd.net.fm10k.rx");
-	if (fm10k_logtype_rx >= 0)
-		rte_log_set_level(fm10k_logtype_rx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(fm10k_logtype_rx, pmd.net.fm10k.rx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_FM10K_DEBUG_TX
-	fm10k_logtype_tx = rte_log_register("pmd.net.fm10k.tx");
-	if (fm10k_logtype_tx >= 0)
-		rte_log_set_level(fm10k_logtype_tx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(fm10k_logtype_tx, pmd.net.fm10k.tx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_FM10K_DEBUG_TX_FREE
-	fm10k_logtype_tx_free = rte_log_register("pmd.net.fm10k.tx_free");
-	if (fm10k_logtype_tx_free >= 0)
-		rte_log_set_level(fm10k_logtype_tx_free, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(fm10k_logtype_tx_free, pmd.net.fm10k.tx_free, DEBUG);
 #endif
-}
diff --git a/drivers/net/hinic/hinic_pmd_ethdev.c b/drivers/net/hinic/hinic_pmd_ethdev.c
index 0c3e1c0cd..8f81e2230 100644
--- a/drivers/net/hinic/hinic_pmd_ethdev.c
+++ b/drivers/net/hinic/hinic_pmd_ethdev.c
@@ -78,9 +78,6 @@
 /* lro numer limit for one packet */
 #define HINIC_LRO_WQE_NUM_DEFAULT	8
 
-/* Driver-specific log messages type */
-int hinic_logtype;
-
 struct hinic_xstats_name_off {
 	char name[RTE_ETH_XSTATS_NAME_SIZE];
 	u32  offset;
@@ -3250,10 +3247,4 @@ static struct rte_pci_driver rte_hinic_pmd = {
 
 RTE_PMD_REGISTER_PCI(net_hinic, rte_hinic_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_hinic, pci_id_hinic_map);
-
-RTE_INIT(hinic_init_log)
-{
-	hinic_logtype = rte_log_register("pmd.net.hinic");
-	if (hinic_logtype >= 0)
-		rte_log_set_level(hinic_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(hinic_logtype, pmd.net.hinic, INFO);
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 62d87582d..309d0483e 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -60,9 +60,6 @@
 #define HNS3_RESET_WAIT_MS	100
 #define HNS3_RESET_WAIT_CNT	200
 
-int hns3_logtype_init;
-int hns3_logtype_driver;
-
 enum hns3_evt_cause {
 	HNS3_VECTOR0_EVENT_RST,
 	HNS3_VECTOR0_EVENT_MBX,
@@ -5525,13 +5522,5 @@ static struct rte_pci_driver rte_hns3_pmd = {
 RTE_PMD_REGISTER_PCI(net_hns3, rte_hns3_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_hns3, pci_id_hns3_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_hns3, "* igb_uio | vfio-pci");
-
-RTE_INIT(hns3_init_log)
-{
-	hns3_logtype_init = rte_log_register("pmd.net.hns3.init");
-	if (hns3_logtype_init >= 0)
-		rte_log_set_level(hns3_logtype_init, RTE_LOG_NOTICE);
-	hns3_logtype_driver = rte_log_register("pmd.net.hns3.driver");
-	if (hns3_logtype_driver >= 0)
-		rte_log_set_level(hns3_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(hns3_logtype_init, pmd.net.hns3.init, NOTICE);
+RTE_LOG_REGISTER(hns3_logtype_driver, pmd.net.hns3.driver, NOTICE);
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 970a31cb2..472ce2a9e 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -398,18 +398,6 @@ static void i40e_tunnel_filter_restore(struct i40e_pf *pf);
 static void i40e_filter_restore(struct i40e_pf *pf);
 static void i40e_notify_all_vfs_link_status(struct rte_eth_dev *dev);
 
-int i40e_logtype_init;
-int i40e_logtype_driver;
-#ifdef RTE_LIBRTE_I40E_DEBUG_RX
-int i40e_logtype_rx;
-#endif
-#ifdef RTE_LIBRTE_I40E_DEBUG_TX
-int i40e_logtype_tx;
-#endif
-#ifdef RTE_LIBRTE_I40E_DEBUG_TX_FREE
-int i40e_logtype_tx_free;
-#endif
-
 static const char *const valid_keys[] = {
 	ETH_I40E_FLOATING_VEB_ARG,
 	ETH_I40E_FLOATING_VEB_LIST_ARG,
@@ -13411,33 +13399,17 @@ i40e_config_rss_filter(struct i40e_pf *pf,
 	return 0;
 }
 
-RTE_INIT(i40e_init_log)
-{
-	i40e_logtype_init = rte_log_register("pmd.net.i40e.init");
-	if (i40e_logtype_init >= 0)
-		rte_log_set_level(i40e_logtype_init, RTE_LOG_NOTICE);
-	i40e_logtype_driver = rte_log_register("pmd.net.i40e.driver");
-	if (i40e_logtype_driver >= 0)
-		rte_log_set_level(i40e_logtype_driver, RTE_LOG_NOTICE);
-
+RTE_LOG_REGISTER(i40e_logtype_init, pmd.net.i40e.init, NOTICE);
+RTE_LOG_REGISTER(i40e_logtype_driver, pmd.net.i40e.driver, NOTICE);
 #ifdef RTE_LIBRTE_I40E_DEBUG_RX
-	i40e_logtype_rx = rte_log_register("pmd.net.i40e.rx");
-	if (i40e_logtype_rx >= 0)
-		rte_log_set_level(i40e_logtype_rx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(i40e_logtype_rx, pmd.net.i40e.rx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_I40E_DEBUG_TX
-	i40e_logtype_tx = rte_log_register("pmd.net.i40e.tx");
-	if (i40e_logtype_tx >= 0)
-		rte_log_set_level(i40e_logtype_tx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(i40e_logtype_tx, pmd.net.i40e.tx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_I40E_DEBUG_TX_FREE
-	i40e_logtype_tx_free = rte_log_register("pmd.net.i40e.tx_free");
-	if (i40e_logtype_tx_free >= 0)
-		rte_log_set_level(i40e_logtype_tx_free, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(i40e_logtype_tx_free, pmd.net.i40e.tx_free, DEBUG);
 #endif
-}
 
 RTE_PMD_REGISTER_PARAM_STRING(net_i40e,
 			      ETH_I40E_FLOATING_VEB_ARG "=1"
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 2b1066b0a..d69e5284e 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -74,20 +74,6 @@ static int iavf_dev_filter_ctrl(struct rte_eth_dev *dev,
 		     enum rte_filter_op filter_op,
 		     void *arg);
 
-
-int iavf_logtype_init;
-int iavf_logtype_driver;
-
-#ifdef RTE_LIBRTE_IAVF_DEBUG_RX
-int iavf_logtype_rx;
-#endif
-#ifdef RTE_LIBRTE_IAVF_DEBUG_TX
-int iavf_logtype_tx;
-#endif
-#ifdef RTE_LIBRTE_IAVF_DEBUG_TX_FREE
-int iavf_logtype_tx_free;
-#endif
-
 static const struct rte_pci_id pci_id_iavf_map[] = {
 	{ RTE_PCI_DEVICE(IAVF_INTEL_VENDOR_ID, IAVF_DEV_ID_ADAPTIVE_VF) },
 	{ .vendor_id = 0, /* sentinel */ },
@@ -1556,30 +1542,14 @@ RTE_PMD_REGISTER_PCI(net_iavf, rte_iavf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_iavf, pci_id_iavf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_iavf, "* igb_uio | vfio-pci");
 RTE_PMD_REGISTER_PARAM_STRING(net_iavf, "cap=dcf");
-RTE_INIT(iavf_init_log)
-{
-	iavf_logtype_init = rte_log_register("pmd.net.iavf.init");
-	if (iavf_logtype_init >= 0)
-		rte_log_set_level(iavf_logtype_init, RTE_LOG_NOTICE);
-	iavf_logtype_driver = rte_log_register("pmd.net.iavf.driver");
-	if (iavf_logtype_driver >= 0)
-		rte_log_set_level(iavf_logtype_driver, RTE_LOG_NOTICE);
-
+RTE_LOG_REGISTER(iavf_logtype_init, pmd.net.iavf.init, NOTICE);
+RTE_LOG_REGISTER(iavf_logtype_driver, pmd.net.iavf.driver, NOTICE);
 #ifdef RTE_LIBRTE_IAVF_DEBUG_RX
-	iavf_logtype_rx = rte_log_register("pmd.net.iavf.rx");
-	if (iavf_logtype_rx >= 0)
-		rte_log_set_level(iavf_logtype_rx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(iavf_logtype_rx, pmd.net.iavf.rx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_IAVF_DEBUG_TX
-	iavf_logtype_tx = rte_log_register("pmd.net.iavf.tx");
-	if (iavf_logtype_tx >= 0)
-		rte_log_set_level(iavf_logtype_tx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(iavf_logtype_tx, pmd.net.iavf.tx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_IAVF_DEBUG_TX_FREE
-	iavf_logtype_tx_free = rte_log_register("pmd.net.iavf.tx_free");
-	if (iavf_logtype_tx_free >= 0)
-		rte_log_set_level(iavf_logtype_tx_free, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(iavf_logtype_tx_free, pmd.net.iavf.tx_free, DEBUG);
 #endif
-}
diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index d5110c439..ac18f1060 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -71,18 +71,6 @@ static struct proto_xtr_ol_flag ice_proto_xtr_ol_flag_params[] = {
 #define ICE_COMMS_PKG_NAME			"ICE COMMS Package"
 #define ICE_MAX_RES_DESC_NUM        1024
 
-int ice_logtype_init;
-int ice_logtype_driver;
-#ifdef RTE_LIBRTE_ICE_DEBUG_RX
-int ice_logtype_rx;
-#endif
-#ifdef RTE_LIBRTE_ICE_DEBUG_TX
-int ice_logtype_tx;
-#endif
-#ifdef RTE_LIBRTE_ICE_DEBUG_TX_FREE
-int ice_logtype_tx_free;
-#endif
-
 static int ice_dev_configure(struct rte_eth_dev *dev);
 static int ice_dev_start(struct rte_eth_dev *dev);
 static void ice_dev_stop(struct rte_eth_dev *dev);
@@ -4571,30 +4559,14 @@ RTE_PMD_REGISTER_PARAM_STRING(net_ice,
 			      ICE_PIPELINE_MODE_SUPPORT_ARG "=<0|1>"
 			      ICE_FLOW_MARK_SUPPORT_ARG "=<0|1>");
 
-RTE_INIT(ice_init_log)
-{
-	ice_logtype_init = rte_log_register("pmd.net.ice.init");
-	if (ice_logtype_init >= 0)
-		rte_log_set_level(ice_logtype_init, RTE_LOG_NOTICE);
-	ice_logtype_driver = rte_log_register("pmd.net.ice.driver");
-	if (ice_logtype_driver >= 0)
-		rte_log_set_level(ice_logtype_driver, RTE_LOG_NOTICE);
-
+RTE_LOG_REGISTER(ice_logtype_init, pmd.net.ice.init, NOTICE);
+RTE_LOG_REGISTER(ice_logtype_driver, pmd.net.ice.driver, NOTICE);
 #ifdef RTE_LIBRTE_ICE_DEBUG_RX
-	ice_logtype_rx = rte_log_register("pmd.net.ice.rx");
-	if (ice_logtype_rx >= 0)
-		rte_log_set_level(ice_logtype_rx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(ice_logtype_rx, pmd.net.ice.rx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_ICE_DEBUG_TX
-	ice_logtype_tx = rte_log_register("pmd.net.ice.tx");
-	if (ice_logtype_tx >= 0)
-		rte_log_set_level(ice_logtype_tx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(ice_logtype_tx, pmd.net.ice.tx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_ICE_DEBUG_TX_FREE
-	ice_logtype_tx_free = rte_log_register("pmd.net.ice.tx_free");
-	if (ice_logtype_tx_free >= 0)
-		rte_log_set_level(ice_logtype_tx_free, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(ice_logtype_tx_free, pmd.net.ice.tx_free, DEBUG);
 #endif
-}
diff --git a/drivers/net/igc/igc_logs.c b/drivers/net/igc/igc_logs.c
index eff7640b1..2d458d7fb 100644
--- a/drivers/net/igc/igc_logs.c
+++ b/drivers/net/igc/igc_logs.c
@@ -6,17 +6,5 @@
 
 #include "igc_logs.h"
 
-/* declared as extern in igc_logs.h */
-int igc_logtype_init;
-int igc_logtype_driver;
-
-RTE_INIT(igc_init_log)
-{
-	igc_logtype_init = rte_log_register("pmd.net.igc.init");
-	if (igc_logtype_init >= 0)
-		rte_log_set_level(igc_logtype_init, RTE_LOG_INFO);
-
-	igc_logtype_driver = rte_log_register("pmd.net.igc.driver");
-	if (igc_logtype_driver >= 0)
-		rte_log_set_level(igc_logtype_driver, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(igc_logtype_init, pmd.net.igc.init, INFO);
+RTE_LOG_REGISTER(igc_logtype_driver, pmd.net.igc.driver, INFO);
diff --git a/drivers/net/ionic/ionic_ethdev.c b/drivers/net/ionic/ionic_ethdev.c
index 363f0cf00..800f6e5d6 100644
--- a/drivers/net/ionic/ionic_ethdev.c
+++ b/drivers/net/ionic/ionic_ethdev.c
@@ -59,8 +59,6 @@ static int  ionic_dev_xstats_get_names_by_id(struct rte_eth_dev *dev,
 static int  ionic_dev_fw_version_get(struct rte_eth_dev *eth_dev,
 	char *fw_version, size_t fw_size);
 
-int ionic_logtype;
-
 static const struct rte_pci_id pci_id_ionic_map[] = {
 	{ RTE_PCI_DEVICE(IONIC_PENSANDO_VENDOR_ID, IONIC_DEV_ID_ETH_PF) },
 	{ RTE_PCI_DEVICE(IONIC_PENSANDO_VENDOR_ID, IONIC_DEV_ID_ETH_VF) },
@@ -1318,10 +1316,4 @@ static struct rte_pci_driver rte_ionic_pmd = {
 RTE_PMD_REGISTER_PCI(net_ionic, rte_ionic_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_ionic, pci_id_ionic_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_ionic, "* igb_uio | uio_pci_generic | vfio-pci");
-
-RTE_INIT(ionic_init_log)
-{
-	ionic_logtype = rte_log_register("pmd.net.ionic");
-	if (ionic_logtype >= 0)
-		rte_log_set_level(ionic_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(ionic_logtype, pmd.net.ionic, NOTICE);
diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.c b/drivers/net/ipn3ke/ipn3ke_ethdev.c
index 5b5510f08..027be29bd 100644
--- a/drivers/net/ipn3ke/ipn3ke_ethdev.c
+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.c
@@ -26,8 +26,6 @@
 #include "ipn3ke_logs.h"
 #include "ipn3ke_ethdev.h"
 
-int ipn3ke_afu_logtype;
-
 static const struct rte_afu_uuid afu_uuid_ipn3ke_map[] = {
 	{ MAP_UUID_10G_LOW,  MAP_UUID_10G_HIGH },
 	{ IPN3KE_UUID_10G_LOW, IPN3KE_UUID_10G_HIGH },
@@ -587,10 +585,4 @@ static struct rte_afu_driver afu_ipn3ke_driver = {
 };
 
 RTE_PMD_REGISTER_AFU(net_ipn3ke_afu, afu_ipn3ke_driver);
-
-RTE_INIT(ipn3ke_afu_init_log)
-{
-	ipn3ke_afu_logtype = rte_log_register("pmd.afu.ipn3ke");
-	if (ipn3ke_afu_logtype >= 0)
-		rte_log_set_level(ipn3ke_afu_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(ipn3ke_afu_logtype, pmd.afu.ipn3ke, NOTICE);
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index f8a84c565..248f21d14 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -419,19 +419,6 @@ static int ixgbe_wait_for_link_up(struct ixgbe_hw *hw);
 		(r) = (h)->bitmap[idx] >> bit & 1;\
 	} while (0)
 
-int ixgbe_logtype_init;
-int ixgbe_logtype_driver;
-
-#ifdef RTE_LIBRTE_IXGBE_DEBUG_RX
-int ixgbe_logtype_rx;
-#endif
-#ifdef RTE_LIBRTE_IXGBE_DEBUG_TX
-int ixgbe_logtype_tx;
-#endif
-#ifdef RTE_LIBRTE_IXGBE_DEBUG_TX_FREE
-int ixgbe_logtype_tx_free;
-#endif
-
 /*
  * The set of PCI devices this driver supports
  */
@@ -9117,29 +9104,15 @@ RTE_PMD_REGISTER_KMOD_DEP(net_ixgbe_vf, "* igb_uio | vfio-pci");
 RTE_PMD_REGISTER_PARAM_STRING(net_ixgbe_vf,
 			      IXGBEVF_DEVARG_PFLINK_FULLCHK "=<0|1>");
 
-RTE_INIT(ixgbe_init_log)
-{
-	ixgbe_logtype_init = rte_log_register("pmd.net.ixgbe.init");
-	if (ixgbe_logtype_init >= 0)
-		rte_log_set_level(ixgbe_logtype_init, RTE_LOG_NOTICE);
-	ixgbe_logtype_driver = rte_log_register("pmd.net.ixgbe.driver");
-	if (ixgbe_logtype_driver >= 0)
-		rte_log_set_level(ixgbe_logtype_driver, RTE_LOG_NOTICE);
+RTE_LOG_REGISTER(ixgbe_logtype_init, pmd.net.ixgbe.init, NOTICE);
+RTE_LOG_REGISTER(ixgbe_logtype_driver, pmd.net.ixgbe.driver, NOTICE);
+
 #ifdef RTE_LIBRTE_IXGBE_DEBUG_RX
-	ixgbe_logtype_rx = rte_log_register("pmd.net.ixgbe.rx");
-	if (ixgbe_logtype_rx >= 0)
-		rte_log_set_level(ixgbe_logtype_rx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(ixgbe_logtype_rx, pmd.net.ixgbe.rx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_IXGBE_DEBUG_TX
-	ixgbe_logtype_tx = rte_log_register("pmd.net.ixgbe.tx");
-	if (ixgbe_logtype_tx >= 0)
-		rte_log_set_level(ixgbe_logtype_tx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(ixgbe_logtype_tx, pmd.net.ixgbe.tx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_IXGBE_DEBUG_TX_FREE
-	ixgbe_logtype_tx_free = rte_log_register("pmd.net.ixgbe.tx_free");
-	if (ixgbe_logtype_tx_free >= 0)
-		rte_log_set_level(ixgbe_logtype_tx_free, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(ixgbe_logtype_tx_free, pmd.net.ixgbe.tx_free, DEBUG);
 #endif
-}
diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c
index d88cb1778..cde98f0bb 100644
--- a/drivers/net/kni/rte_eth_kni.c
+++ b/drivers/net/kni/rte_eth_kni.c
@@ -67,7 +67,7 @@ static const struct rte_eth_link pmd_link = {
 };
 static int is_kni_initialized;
 
-static int eth_kni_logtype;
+RTE_LOG_REGISTER(eth_kni_logtype, pmd.net.kni, NOTICE);
 
 #define PMD_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, eth_kni_logtype, \
@@ -508,10 +508,3 @@ static struct rte_vdev_driver eth_kni_drv = {
 
 RTE_PMD_REGISTER_VDEV(net_kni, eth_kni_drv);
 RTE_PMD_REGISTER_PARAM_STRING(net_kni, ETH_KNI_NO_REQUEST_THREAD_ARG "=<int>");
-
-RTE_INIT(eth_kni_init_log)
-{
-	eth_kni_logtype = rte_log_register("pmd.net.kni");
-	if (eth_kni_logtype >= 0)
-		rte_log_set_level(eth_kni_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c
index ad4a51ecd..2258838c4 100644
--- a/drivers/net/liquidio/lio_ethdev.c
+++ b/drivers/net/liquidio/lio_ethdev.c
@@ -15,9 +15,6 @@
 #include "lio_ethdev.h"
 #include "lio_rxtx.h"
 
-int lio_logtype_init;
-int lio_logtype_driver;
-
 /* Default RSS key in use */
 static uint8_t lio_rss_key[40] = {
 	0x6D, 0x5A, 0x56, 0xDA, 0x25, 0x5B, 0x0E, 0xC2,
@@ -2161,13 +2158,5 @@ static struct rte_pci_driver rte_liovf_pmd = {
 RTE_PMD_REGISTER_PCI(net_liovf, rte_liovf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_liovf, pci_id_liovf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_liovf, "* igb_uio | vfio-pci");
-
-RTE_INIT(lio_init_log)
-{
-	lio_logtype_init = rte_log_register("pmd.net.liquidio.init");
-	if (lio_logtype_init >= 0)
-		rte_log_set_level(lio_logtype_init, RTE_LOG_NOTICE);
-	lio_logtype_driver = rte_log_register("pmd.net.liquidio.driver");
-	if (lio_logtype_driver >= 0)
-		rte_log_set_level(lio_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(lio_logtype_init, pmd.net.liquidio.init, NOTICE);
+RTE_LOG_REGISTER(lio_logtype_driver, pmd.net.liquidio.driver, NOTICE);
diff --git a/drivers/net/memif/rte_eth_memif.c b/drivers/net/memif/rte_eth_memif.c
index b6da9a8b4..c1c7e9f8d 100644
--- a/drivers/net/memif/rte_eth_memif.c
+++ b/drivers/net/memif/rte_eth_memif.c
@@ -1806,11 +1806,4 @@ RTE_PMD_REGISTER_PARAM_STRING(net_memif,
 			      ETH_MEMIF_ZC_ARG "=yes|no"
 			      ETH_MEMIF_SECRET_ARG "=<string>");
 
-int memif_logtype;
-
-RTE_INIT(memif_init_log)
-{
-	memif_logtype = rte_log_register("pmd.net.memif");
-	if (memif_logtype >= 0)
-		rte_log_set_level(memif_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(memif_logtype, pmd.net.memif, NOTICE);
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index 5d7202720..456a365c9 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -64,9 +64,6 @@ static rte_spinlock_t mlx4_shared_data_lock = RTE_SPINLOCK_INITIALIZER;
 /* Process local data for secondary processes. */
 static struct mlx4_local_data mlx4_local_data;
 
-/** Driver-specific log messages type. */
-int mlx4_logtype;
-
 /** Configuration structure for device arguments. */
 struct mlx4_conf {
 	struct {
@@ -1281,16 +1278,14 @@ mlx4_glue_init(void)
 
 #endif
 
+/* Initialize driver log type. */
+RTE_LOG_REGISTER(mlx4_logtype, pmd.net.mlx4, RTE_LOG_NOTICE);
+
 /**
  * Driver initialization routine.
  */
 RTE_INIT(rte_mlx4_pmd_init)
 {
-	/* Initialize driver log type. */
-	mlx4_logtype = rte_log_register("pmd.net.mlx4");
-	if (mlx4_logtype >= 0)
-		rte_log_set_level(mlx4_logtype, RTE_LOG_NOTICE);
-
 	/*
 	 * MLX4_DEVICE_FATAL_CLEANUP tells ibv_destroy functions we
 	 * want to get success errno value in case of calling them
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 95a0f337f..8dab34c49 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -184,9 +184,6 @@ static rte_spinlock_t mlx5_shared_data_lock = RTE_SPINLOCK_INITIALIZER;
 /* Process local data for secondary processes. */
 static struct mlx5_local_data mlx5_local_data;
 
-/** Driver-specific log messages type. */
-int mlx5_logtype;
-
 /** Data associated with devices to spawn. */
 struct mlx5_dev_spawn_data {
 	uint32_t ifindex; /**< Network interface index. */
@@ -3895,16 +3892,14 @@ static struct rte_pci_driver mlx5_driver = {
 		     RTE_PCI_DRV_PROBE_AGAIN,
 };
 
+/* Initialize driver log type. */
+RTE_LOG_REGISTER(mlx5_logtype, pmd.net.mlx5, NOTICE);
+
 /**
  * Driver initialization routine.
  */
 RTE_INIT(rte_mlx5_pmd_init)
 {
-	/* Initialize driver log type. */
-	mlx5_logtype = rte_log_register("pmd.net.mlx5");
-	if (mlx5_logtype >= 0)
-		rte_log_set_level(mlx5_logtype, RTE_LOG_NOTICE);
-
 	/* Build the static tables for Verbs conversion. */
 	mlx5_set_ptype_table();
 	mlx5_set_cksum_table();
diff --git a/drivers/net/mvneta/mvneta_ethdev.c b/drivers/net/mvneta/mvneta_ethdev.c
index 4aea87648..673a8e2b3 100644
--- a/drivers/net/mvneta/mvneta_ethdev.c
+++ b/drivers/net/mvneta/mvneta_ethdev.c
@@ -34,8 +34,6 @@
 /** Maximum length of a match string */
 #define MVNETA_MATCH_LEN 16
 
-int mvneta_logtype;
-
 static const char * const valid_args[] = {
 	MVNETA_IFACE_NAME_ARG,
 	NULL
@@ -982,10 +980,4 @@ static struct rte_vdev_driver pmd_mvneta_drv = {
 
 RTE_PMD_REGISTER_VDEV(net_mvneta, pmd_mvneta_drv);
 RTE_PMD_REGISTER_PARAM_STRING(net_mvneta, "iface=<ifc>");
-
-RTE_INIT(mvneta_init_log)
-{
-	mvneta_logtype = rte_log_register("pmd.net.mvneta");
-	if (mvneta_logtype >= 0)
-		rte_log_set_level(mvneta_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(mvneta_logtype, pmd.net.mvneta, NOTICE);
diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c
index b98b1fd66..75589f18e 100644
--- a/drivers/net/mvpp2/mrvl_ethdev.c
+++ b/drivers/net/mvpp2/mrvl_ethdev.c
@@ -84,8 +84,6 @@ static struct pp2_bpool *mrvl_port_to_bpool_lookup[RTE_MAX_ETHPORTS];
 static int mrvl_port_bpool_size[PP2_NUM_PKT_PROC][PP2_BPOOL_NUM_POOLS][RTE_MAX_LCORE];
 static uint64_t cookie_addr_high = MRVL_COOKIE_ADDR_INVALID;
 
-int mrvl_logtype;
-
 struct mrvl_ifnames {
 	const char *names[PP2_NUM_ETH_PPIO * PP2_NUM_PKT_PROC];
 	int idx;
@@ -3040,10 +3038,4 @@ static struct rte_vdev_driver pmd_mrvl_drv = {
 
 RTE_PMD_REGISTER_VDEV(net_mvpp2, pmd_mrvl_drv);
 RTE_PMD_REGISTER_ALIAS(net_mvpp2, eth_mvpp2);
-
-RTE_INIT(mrvl_init_log)
-{
-	mrvl_logtype = rte_log_register("pmd.net.mvpp2");
-	if (mrvl_logtype >= 0)
-		rte_log_set_level(mrvl_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(mrvl_logtype, pmd.net.mvpp2, NOTICE);
diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c
index ac182a548..fd91c0e49 100644
--- a/drivers/net/netvsc/hn_ethdev.c
+++ b/drivers/net/netvsc/hn_ethdev.c
@@ -45,9 +45,6 @@
 			    DEV_RX_OFFLOAD_VLAN_STRIP | \
 			    DEV_RX_OFFLOAD_RSS_HASH)
 
-int hn_logtype_init;
-int hn_logtype_driver;
-
 struct hn_xstats_name_off {
 	char name[RTE_ETH_XSTATS_NAME_SIZE];
 	unsigned int offset;
@@ -1121,13 +1118,5 @@ static struct rte_vmbus_driver rte_netvsc_pmd = {
 
 RTE_PMD_REGISTER_VMBUS(net_netvsc, rte_netvsc_pmd);
 RTE_PMD_REGISTER_KMOD_DEP(net_netvsc, "* uio_hv_generic");
-
-RTE_INIT(hn_init_log)
-{
-	hn_logtype_init = rte_log_register("pmd.net.netvsc.init");
-	if (hn_logtype_init >= 0)
-		rte_log_set_level(hn_logtype_init, RTE_LOG_NOTICE);
-	hn_logtype_driver = rte_log_register("pmd.net.netvsc.driver");
-	if (hn_logtype_driver >= 0)
-		rte_log_set_level(hn_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(hn_logtype_init, pmd.net.netvsc.init, NOTICE);
+RTE_LOG_REGISTER(hn_logtype_driver, pmd.net.netvsc.driver, NOTICE);
diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
index 2460ee199..88e3f01d6 100644
--- a/drivers/net/nfp/nfp_net.c
+++ b/drivers/net/nfp/nfp_net.c
@@ -3683,9 +3683,6 @@ static int nfp_pf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	return ret;
 }
 
-int nfp_logtype_init;
-int nfp_logtype_driver;
-
 static const struct rte_pci_id pci_id_nfp_pf_net_map[] = {
 	{
 		RTE_PCI_DEVICE(PCI_VENDOR_ID_NETRONOME,
@@ -3769,16 +3766,8 @@ RTE_PMD_REGISTER_PCI_TABLE(net_nfp_pf, pci_id_nfp_pf_net_map);
 RTE_PMD_REGISTER_PCI_TABLE(net_nfp_vf, pci_id_nfp_vf_net_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_nfp_pf, "* igb_uio | uio_pci_generic | vfio");
 RTE_PMD_REGISTER_KMOD_DEP(net_nfp_vf, "* igb_uio | uio_pci_generic | vfio");
-
-RTE_INIT(nfp_init_log)
-{
-	nfp_logtype_init = rte_log_register("pmd.net.nfp.init");
-	if (nfp_logtype_init >= 0)
-		rte_log_set_level(nfp_logtype_init, RTE_LOG_NOTICE);
-	nfp_logtype_driver = rte_log_register("pmd.net.nfp.driver");
-	if (nfp_logtype_driver >= 0)
-		rte_log_set_level(nfp_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(nfp_logtype_init, pmd.net.nfp.init, NOTICE);
+RTE_LOG_REGISTER(nfp_logtype_driver, pmd.net.nfp.driver, NOTICE);
 /*
  * Local variables:
  * c-file-style: "Linux"
diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index 11258ccea..8c779be7f 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c
@@ -73,7 +73,7 @@ static struct rte_eth_link pmd_link = {
 	.link_autoneg = ETH_LINK_FIXED,
 };
 
-static int eth_null_logtype;
+RTE_LOG_REGISTER(eth_null_logtype, pmd.net.null, NOTICE);
 
 #define PMD_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, eth_null_logtype, \
@@ -730,9 +730,3 @@ RTE_PMD_REGISTER_PARAM_STRING(net_null,
 	"copy=<int> "
 	ETH_NULL_PACKET_NO_RX_ARG "=0|1");
 
-RTE_INIT(eth_null_init_log)
-{
-	eth_null_logtype = rte_log_register("pmd.net.null");
-	if (eth_null_logtype >= 0)
-		rte_log_set_level(eth_null_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c
index d5371ae07..76c69294d 100644
--- a/drivers/net/octeontx/octeontx_ethdev.c
+++ b/drivers/net/octeontx/octeontx_ethdev.c
@@ -47,24 +47,9 @@ enum octeontx_link_speed {
 	OCTEONTX_LINK_SPEED_RESERVE2
 };
 
-int otx_net_logtype_mbox;
-int otx_net_logtype_init;
-int otx_net_logtype_driver;
-
-RTE_INIT(otx_net_init_log)
-{
-	otx_net_logtype_mbox = rte_log_register("pmd.net.octeontx.mbox");
-	if (otx_net_logtype_mbox >= 0)
-		rte_log_set_level(otx_net_logtype_mbox, RTE_LOG_NOTICE);
-
-	otx_net_logtype_init = rte_log_register("pmd.net.octeontx.init");
-	if (otx_net_logtype_init >= 0)
-		rte_log_set_level(otx_net_logtype_init, RTE_LOG_NOTICE);
-
-	otx_net_logtype_driver = rte_log_register("pmd.net.octeontx.driver");
-	if (otx_net_logtype_driver >= 0)
-		rte_log_set_level(otx_net_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(otx_net_logtype_mbox, pmd.net.octeontx.mbox, NOTICE);
+RTE_LOG_REGISTER(otx_net_logtype_init, pmd.net.octeontx.init, NOTICE);
+RTE_LOG_REGISTER(otx_net_logtype_driver, pmd.net.octeontx.driver, NOTICE);
 
 /* Parse integer from integer argument */
 static int
diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index b4c79d174..293707481 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -135,7 +135,7 @@ static struct rte_eth_link pmd_link = {
 		.link_autoneg = ETH_LINK_FIXED,
 };
 
-static int eth_pcap_logtype;
+RTE_LOG_REGISTER(eth_pcap_logtype, pmd.net.pcap, NOTICE);
 
 #define PMD_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, eth_pcap_logtype, \
@@ -1580,9 +1580,3 @@ RTE_PMD_REGISTER_PARAM_STRING(net_pcap,
 	ETH_PCAP_PHY_MAC_ARG "=<int>"
 	ETH_PCAP_INFINITE_RX_ARG "=<0|1>");
 
-RTE_INIT(eth_pcap_init_log)
-{
-	eth_pcap_logtype = rte_log_register("pmd.net.pcap");
-	if (eth_pcap_logtype >= 0)
-		rte_log_set_level(eth_pcap_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/pfe/pfe_ethdev.c b/drivers/net/pfe/pfe_ethdev.c
index b1de866d3..368acfa55 100644
--- a/drivers/net/pfe/pfe_ethdev.c
+++ b/drivers/net/pfe/pfe_ethdev.c
@@ -40,8 +40,6 @@ unsigned int pfe_svr = SVR_LS1012A_REV1;
 static void *cbus_emac_base[3];
 static void *cbus_gpi_base[3];
 
-int pfe_logtype_pmd;
-
 /* pfe_gemac_init
  */
 static int
@@ -1181,10 +1179,4 @@ struct rte_vdev_driver pmd_pfe_drv = {
 
 RTE_PMD_REGISTER_VDEV(PFE_NAME_PMD, pmd_pfe_drv);
 RTE_PMD_REGISTER_PARAM_STRING(PFE_NAME_PMD, PFE_VDEV_GEM_ID_ARG "=<int> ");
-
-RTE_INIT(pfe_pmd_init_log)
-{
-	pfe_logtype_pmd = rte_log_register("pmd.net.pfe");
-	if (pfe_logtype_pmd >= 0)
-		rte_log_set_level(pfe_logtype_pmd, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(pfe_logtype_pmd, pmd.net.pfe, NOTICE);
diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c
index c4f8f1258..6107d583e 100644
--- a/drivers/net/qede/qede_ethdev.c
+++ b/drivers/net/qede/qede_ethdev.c
@@ -10,10 +10,6 @@
 #include <rte_version.h>
 #include <rte_kvargs.h>
 
-/* Globals */
-int qede_logtype_init;
-int qede_logtype_driver;
-
 static const struct qed_eth_ops *qed_ops;
 static int qede_eth_dev_uninit(struct rte_eth_dev *eth_dev);
 static int qede_eth_dev_init(struct rte_eth_dev *eth_dev);
@@ -2870,13 +2866,5 @@ RTE_PMD_REGISTER_KMOD_DEP(net_qede, "* igb_uio | uio_pci_generic | vfio-pci");
 RTE_PMD_REGISTER_PCI(net_qede_vf, rte_qedevf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_qede_vf, pci_id_qedevf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_qede_vf, "* igb_uio | vfio-pci");
-
-RTE_INIT(qede_init_log)
-{
-	qede_logtype_init = rte_log_register("pmd.net.qede.init");
-	if (qede_logtype_init >= 0)
-		rte_log_set_level(qede_logtype_init, RTE_LOG_NOTICE);
-	qede_logtype_driver = rte_log_register("pmd.net.qede.driver");
-	if (qede_logtype_driver >= 0)
-		rte_log_set_level(qede_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(qede_logtype_init, pmd.net.qede.init, NOTICE);
+RTE_LOG_REGISTER(qede_logtype_driver, pmd.net.qede.driver, NOTICE);
diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index f0fafa0c0..078df605a 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -61,7 +61,7 @@ static struct rte_eth_link pmd_link = {
 	.link_autoneg = ETH_LINK_FIXED,
 };
 
-static int eth_ring_logtype;
+RTE_LOG_REGISTER(eth_ring_logtype, pmd.net.ring, NOTICE);
 
 #define PMD_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, eth_ring_logtype, \
@@ -703,9 +703,3 @@ RTE_PMD_REGISTER_ALIAS(net_ring, eth_ring);
 RTE_PMD_REGISTER_PARAM_STRING(net_ring,
 	ETH_RING_NUMA_NODE_ACTION_ARG "=name:node:action(ATTACH|CREATE)");
 
-RTE_INIT(eth_ring_init_log)
-{
-	eth_ring_logtype = rte_log_register("pmd.net.ring");
-	if (eth_ring_logtype >= 0)
-		rte_log_set_level(eth_ring_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/softnic/rte_eth_softnic.c b/drivers/net/softnic/rte_eth_softnic.c
index 11723778f..866d17a93 100644
--- a/drivers/net/softnic/rte_eth_softnic.c
+++ b/drivers/net/softnic/rte_eth_softnic.c
@@ -80,7 +80,7 @@ static const struct softnic_conn_params conn_params_default = {
 	.msg_handle_arg = NULL,
 };
 
-static int pmd_softnic_logtype;
+RTE_LOG_REGISTER(pmd_softnic_logtype, pmd.net.softnic, NOTICE);
 
 #define PMD_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, pmd_softnic_logtype, \
@@ -690,14 +690,6 @@ RTE_PMD_REGISTER_PARAM_STRING(net_softnic,
 	PMD_PARAM_TM_QSIZE12 "=<uint32>"
 );
 
-
-RTE_INIT(pmd_softnic_init_log)
-{
-	pmd_softnic_logtype = rte_log_register("pmd.net.softnic");
-	if (pmd_softnic_logtype >= 0)
-		rte_log_set_level(pmd_softnic_logtype, RTE_LOG_NOTICE);
-}
-
 int
 rte_pmd_softnic_manage(uint16_t port_id)
 {
diff --git a/drivers/net/szedata2/rte_eth_szedata2.c b/drivers/net/szedata2/rte_eth_szedata2.c
index 821bb346c..30c888cd9 100644
--- a/drivers/net/szedata2/rte_eth_szedata2.c
+++ b/drivers/net/szedata2/rte_eth_szedata2.c
@@ -102,9 +102,6 @@ struct szedata2_tx_queue {
 	volatile uint64_t err_pkts;
 };
 
-int szedata2_logtype_init;
-int szedata2_logtype_driver;
-
 static struct rte_ether_addr eth_addr = {
 	.addr_bytes = { 0x00, 0x11, 0x17, 0x00, 0x00, 0x00 }
 };
@@ -1941,13 +1938,5 @@ RTE_PMD_REGISTER_PCI(RTE_SZEDATA2_DRIVER_NAME, szedata2_eth_driver);
 RTE_PMD_REGISTER_PCI_TABLE(RTE_SZEDATA2_DRIVER_NAME, rte_szedata2_pci_id_table);
 RTE_PMD_REGISTER_KMOD_DEP(RTE_SZEDATA2_DRIVER_NAME,
 	"* combo6core & combov3 & szedata2 & ( szedata2_cv3 | szedata2_cv3_fdt )");
-
-RTE_INIT(szedata2_init_log)
-{
-	szedata2_logtype_init = rte_log_register("pmd.net.szedata2.init");
-	if (szedata2_logtype_init >= 0)
-		rte_log_set_level(szedata2_logtype_init, RTE_LOG_NOTICE);
-	szedata2_logtype_driver = rte_log_register("pmd.net.szedata2.driver");
-	if (szedata2_logtype_driver >= 0)
-		rte_log_set_level(szedata2_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(szedata2_logtype_init, pmd.net.szedata2.init, NOTICE);
+RTE_LOG_REGISTER(szedata2_logtype_driver, pmd.net.szedata2.driver, NOTICE);
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 7081ae23e..339f24bf8 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -2494,11 +2494,4 @@ RTE_PMD_REGISTER_PARAM_STRING(net_tap,
 			      ETH_TAP_IFACE_ARG "=<string> "
 			      ETH_TAP_MAC_ARG "=" ETH_TAP_MAC_ARG_FMT " "
 			      ETH_TAP_REMOTE_ARG "=<string>");
-int tap_logtype;
-
-RTE_INIT(tap_init_log)
-{
-	tap_logtype = rte_log_register("pmd.net.tap");
-	if (tap_logtype >= 0)
-		rte_log_set_level(tap_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(tap_logtype, pmd.net.tap, NOTICE);
diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c
index bfda0ab0e..d955a7ee2 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -44,10 +44,6 @@
 #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,
@@ -55,20 +51,9 @@ static void nicvf_vf_stop(struct rte_eth_dev *dev, struct nicvf *nic,
 static int nicvf_vlan_offload_config(struct rte_eth_dev *dev, int mask);
 static int nicvf_vlan_offload_set(struct rte_eth_dev *dev, int mask);
 
-RTE_INIT(nicvf_init_log)
-{
-	nicvf_logtype_mbox = rte_log_register("pmd.net.thunderx.mbox");
-	if (nicvf_logtype_mbox >= 0)
-		rte_log_set_level(nicvf_logtype_mbox, RTE_LOG_NOTICE);
-
-	nicvf_logtype_init = rte_log_register("pmd.net.thunderx.init");
-	if (nicvf_logtype_init >= 0)
-		rte_log_set_level(nicvf_logtype_init, RTE_LOG_NOTICE);
-
-	nicvf_logtype_driver = rte_log_register("pmd.net.thunderx.driver");
-	if (nicvf_logtype_driver >= 0)
-		rte_log_set_level(nicvf_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(nicvf_logtype_mbox, pmd.net.thunderx.mbox, NOTICE);
+RTE_LOG_REGISTER(nicvf_logtype_init, pmd.net.thunderx.init, NOTICE);
+RTE_LOG_REGISTER(nicvf_logtype_driver, pmd.net.thunderx.driver, NOTICE);
 
 static void
 nicvf_link_status_update(struct nicvf *nic,
diff --git a/drivers/net/vdev_netvsc/vdev_netvsc.c b/drivers/net/vdev_netvsc/vdev_netvsc.c
index 9ed74a1d6..1ecb0b3e6 100644
--- a/drivers/net/vdev_netvsc/vdev_netvsc.c
+++ b/drivers/net/vdev_netvsc/vdev_netvsc.c
@@ -48,6 +48,8 @@
 #define NETVSC_CLASS_ID "{f8615163-df3e-46c5-913f-f2d2f965ed0e}"
 #define NETVSC_MAX_ROUTE_LINE_SIZE 300
 
+RTE_LOG_REGISTER(vdev_netvsc_logtype, pmd.net.vdev_netvsc, NOTICE);
+
 #define DRV_LOG(level, ...) \
 	rte_log(RTE_LOG_ ## level, \
 		vdev_netvsc_logtype, \
@@ -55,9 +57,6 @@
 			RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
 		RTE_FMT_TAIL(__VA_ARGS__,)))
 
-/** Driver-specific log messages type. */
-static int vdev_netvsc_logtype;
-
 /** Context structure for a vdev_netvsc instance. */
 struct vdev_netvsc_ctx {
 	LIST_ENTRY(vdev_netvsc_ctx) entry; /**< Next entry in list. */
@@ -774,14 +773,6 @@ RTE_PMD_REGISTER_PARAM_STRING(net_vdev_netvsc,
 			      VDEV_NETVSC_ARG_FORCE "=<int> "
 			      VDEV_NETVSC_ARG_IGNORE "=<int>");
 
-/** Initialize driver log type. */
-RTE_INIT(vdev_netvsc_init_log)
-{
-	vdev_netvsc_logtype = rte_log_register("pmd.net.vdev_netvsc");
-	if (vdev_netvsc_logtype >= 0)
-		rte_log_set_level(vdev_netvsc_logtype, RTE_LOG_NOTICE);
-}
-
 /** Compare function for vdev find device operation. */
 static int
 vdev_netvsc_cmp_rte_device(const struct rte_device *dev1,
diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index 808e670f1..bfacdcb98 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -18,7 +18,7 @@
 
 #include "rte_eth_vhost.h"
 
-static int vhost_logtype;
+RTE_LOG_REGISTER(vhost_logtype, pmd.net.vhost, NOTICE);
 
 #define VHOST_LOG(level, ...) \
 	rte_log(RTE_LOG_ ## level, vhost_logtype, __VA_ARGS__)
@@ -1571,9 +1571,3 @@ RTE_PMD_REGISTER_PARAM_STRING(net_vhost,
 	"linear-buffer=<0|1> "
 	"ext-buffer=<0|1>");
 
-RTE_INIT(vhost_init_log)
-{
-	vhost_logtype = rte_log_register("pmd.net.vhost");
-	if (vhost_logtype >= 0)
-		rte_log_set_level(vhost_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 312871cb4..dc0093bdf 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -85,9 +85,6 @@ static int virtio_dev_queue_stats_mapping_set(
 	uint8_t stat_idx,
 	uint8_t is_rx);
 
-int virtio_logtype_init;
-int virtio_logtype_driver;
-
 static void virtio_notify_peers(struct rte_eth_dev *dev);
 static void virtio_ack_link_announce(struct rte_eth_dev *dev);
 
@@ -2659,13 +2656,5 @@ __rte_unused uint8_t is_rx)
 RTE_PMD_EXPORT_NAME(net_virtio, __COUNTER__);
 RTE_PMD_REGISTER_PCI_TABLE(net_virtio, pci_id_virtio_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_virtio, "* igb_uio | uio_pci_generic | vfio-pci");
-
-RTE_INIT(virtio_init_log)
-{
-	virtio_logtype_init = rte_log_register("pmd.net.virtio.init");
-	if (virtio_logtype_init >= 0)
-		rte_log_set_level(virtio_logtype_init, RTE_LOG_NOTICE);
-	virtio_logtype_driver = rte_log_register("pmd.net.virtio.driver");
-	if (virtio_logtype_driver >= 0)
-		rte_log_set_level(virtio_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(virtio_logtype_init, pmd.net.virtio.init, NOTICE);
+RTE_LOG_REGISTER(virtio_logtype_driver, pmd.net.virtio.driver, NOTICE);
diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c
index c6e11ad2d..815fba2f5 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethdev.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c
@@ -95,9 +95,6 @@ static int vmxnet3_mac_addr_set(struct rte_eth_dev *dev,
 				 struct rte_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
  */
@@ -1464,13 +1461,5 @@ 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)
-{
-	vmxnet3_logtype_init = rte_log_register("pmd.net.vmxnet3.init");
-	if (vmxnet3_logtype_init >= 0)
-		rte_log_set_level(vmxnet3_logtype_init, RTE_LOG_NOTICE);
-	vmxnet3_logtype_driver = rte_log_register("pmd.net.vmxnet3.driver");
-	if (vmxnet3_logtype_driver >= 0)
-		rte_log_set_level(vmxnet3_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(vmxnet3_logtype_init, pmd.net.vmxnet3.init, NOTICE);
+RTE_LOG_REGISTER(vmxnet3_logtype_driver, pmd.net.vmxnet3.driver, NOTICE);
-- 
2.26.2


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

* [dpdk-dev]  [PATCH 06/13] drivers/mempool: use log register macro
  2020-06-17  6:30 [dpdk-dev] [PATCH 00/13] rte_log registration usage improvement jerinj
                   ` (4 preceding siblings ...)
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 05/13] drivers/net: " jerinj
@ 2020-06-17  6:30 ` jerinj
  2020-06-21  9:46   ` Sachin Saxena (OSS)
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 07/13] drivers/event: " jerinj
                   ` (8 subsequent siblings)
  14 siblings, 1 reply; 98+ messages in thread
From: jerinj @ 2020-06-17  6:30 UTC (permalink / raw)
  To: dev, Hemant Agrawal, Sachin Saxena, Harman Kalra
  Cc: thomas, olivier.matz, david.marchand, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
---
 drivers/mempool/dpaa/dpaa_mempool.c       | 10 ++--------
 drivers/mempool/dpaa2/dpaa2_hw_mempool.c  | 10 +---------
 drivers/mempool/octeontx/octeontx_fpavf.c | 10 +---------
 3 files changed, 4 insertions(+), 26 deletions(-)

diff --git a/drivers/mempool/dpaa/dpaa_mempool.c b/drivers/mempool/dpaa/dpaa_mempool.c
index 451e2d5d5..8d1da8028 100644
--- a/drivers/mempool/dpaa/dpaa_mempool.c
+++ b/drivers/mempool/dpaa/dpaa_mempool.c
@@ -36,7 +36,8 @@ struct dpaa_memseg_list rte_dpaa_memsegs
 	= TAILQ_HEAD_INITIALIZER(rte_dpaa_memsegs);
 
 struct dpaa_bp_info *rte_dpaa_bpid_info;
-int dpaa_logtype_mempool;
+
+RTE_LOG_REGISTER(dpaa_logtype_mempool, mempool.dpaa, NOTICE);
 
 static int
 dpaa_mbuf_create_pool(struct rte_mempool *mp)
@@ -357,10 +358,3 @@ static const struct rte_mempool_ops dpaa_mpool_ops = {
 };
 
 MEMPOOL_REGISTER_OPS(dpaa_mpool_ops);
-
-RTE_INIT(dpaa_mp_init_log)
-{
-	dpaa_logtype_mempool = rte_log_register("mempool.dpaa");
-	if (dpaa_logtype_mempool >= 0)
-		rte_log_set_level(dpaa_logtype_mempool, RTE_LOG_NOTICE);
-}
diff --git a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
index fa9b53e64..97ce08d78 100644
--- a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
+++ b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
@@ -36,9 +36,6 @@
 struct dpaa2_bp_info *rte_dpaa2_bpid_info;
 static struct dpaa2_bp_list *h_bp_list;
 
-/* Dynamic logging identified for mempool */
-int dpaa2_logtype_mempool;
-
 static int
 rte_hw_mbuf_create_pool(struct rte_mempool *mp)
 {
@@ -454,9 +451,4 @@ static const struct rte_mempool_ops dpaa2_mpool_ops = {
 
 MEMPOOL_REGISTER_OPS(dpaa2_mpool_ops);
 
-RTE_INIT(dpaa2_mempool_init_log)
-{
-	dpaa2_logtype_mempool = rte_log_register("mempool.dpaa2");
-	if (dpaa2_logtype_mempool >= 0)
-		rte_log_set_level(dpaa2_logtype_mempool, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa2_logtype_mempool, mempool.dpaa2, NOTICE);
diff --git a/drivers/mempool/octeontx/octeontx_fpavf.c b/drivers/mempool/octeontx/octeontx_fpavf.c
index 0ff234913..339da7824 100644
--- a/drivers/mempool/octeontx/octeontx_fpavf.c
+++ b/drivers/mempool/octeontx/octeontx_fpavf.c
@@ -105,15 +105,7 @@ struct octeontx_fpadev {
 
 static struct octeontx_fpadev fpadev;
 
-int octeontx_logtype_fpavf;
-int octeontx_logtype_fpavf_mbox;
-
-RTE_INIT(otx_pool_init_log)
-{
-	octeontx_logtype_fpavf = rte_log_register("pmd.mempool.octeontx");
-	if (octeontx_logtype_fpavf >= 0)
-		rte_log_set_level(octeontx_logtype_fpavf, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(octeontx_logtype_fpavf, pmd.mempool.octeontx, NOTICE);
 
 /* lock is taken by caller */
 static int
-- 
2.26.2


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

* [dpdk-dev]  [PATCH 07/13] drivers/event: use log register macro
  2020-06-17  6:30 [dpdk-dev] [PATCH 00/13] rte_log registration usage improvement jerinj
                   ` (5 preceding siblings ...)
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 06/13] drivers/mempool: " jerinj
@ 2020-06-17  6:30 ` jerinj
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 08/13] drivers/crypto: " jerinj
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-06-17  6:30 UTC (permalink / raw)
  To: dev, Hemant Agrawal, Nipun Gupta, Jerin Jacob, Pavan Nikhilesh,
	Liang Ma, Peter Mccarthy, Harry van Haaren
  Cc: thomas, olivier.matz, david.marchand

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
---
 drivers/event/dpaa/dpaa_eventdev.c   |  8 +-------
 drivers/event/dpaa2/dpaa2_eventdev.c | 10 +---------
 drivers/event/octeontx/ssovf_evdev.c |  8 +-------
 drivers/event/octeontx/timvf_evdev.c |  9 +--------
 drivers/event/opdl/opdl_evdev.c      |  8 +-------
 drivers/event/opdl/opdl_ring.c       |  2 --
 drivers/event/sw/sw_evdev.c          | 11 +----------
 7 files changed, 6 insertions(+), 50 deletions(-)

diff --git a/drivers/event/dpaa/dpaa_eventdev.c b/drivers/event/dpaa/dpaa_eventdev.c
index 5a018d487..e78728b7e 100644
--- a/drivers/event/dpaa/dpaa_eventdev.c
+++ b/drivers/event/dpaa/dpaa_eventdev.c
@@ -46,7 +46,7 @@
  * Eventqueue = Channel Instance
  * 1 Eventdev can have N Eventqueue
  */
-int dpaa_logtype_eventdev;
+RTE_LOG_REGISTER(dpaa_logtype_eventdev, pmd.event.dpaa, NOTICE);
 
 #define DISABLE_INTR_MODE "disable_intr"
 
@@ -1069,9 +1069,3 @@ static struct rte_vdev_driver vdev_eventdev_dpaa_pmd = {
 RTE_PMD_REGISTER_VDEV(EVENTDEV_NAME_DPAA_PMD, vdev_eventdev_dpaa_pmd);
 RTE_PMD_REGISTER_PARAM_STRING(EVENTDEV_NAME_DPAA_PMD,
 		DISABLE_INTR_MODE "=<int>");
-RTE_INIT(dpaa_event_init_log)
-{
-	dpaa_logtype_eventdev = rte_log_register("pmd.event.dpaa");
-	if (dpaa_logtype_eventdev >= 0)
-		rte_log_set_level(dpaa_logtype_eventdev, RTE_LOG_NOTICE);
-}
diff --git a/drivers/event/dpaa2/dpaa2_eventdev.c b/drivers/event/dpaa2/dpaa2_eventdev.c
index a196ad4c6..a545baf34 100644
--- a/drivers/event/dpaa2/dpaa2_eventdev.c
+++ b/drivers/event/dpaa2/dpaa2_eventdev.c
@@ -48,8 +48,6 @@
  * Soft Event Flow is DPCI Instance
  */
 
-/* Dynamic logging identified for mempool */
-int dpaa2_logtype_event;
 #define DPAA2_EV_TX_RETRY_COUNT 10000
 
 static uint16_t
@@ -1205,10 +1203,4 @@ static struct rte_vdev_driver vdev_eventdev_dpaa2_pmd = {
 };
 
 RTE_PMD_REGISTER_VDEV(EVENTDEV_NAME_DPAA2_PMD, vdev_eventdev_dpaa2_pmd);
-
-RTE_INIT(dpaa2_eventdev_init_log)
-{
-	dpaa2_logtype_event = rte_log_register("pmd.event.dpaa2");
-	if (dpaa2_logtype_event >= 0)
-		rte_log_set_level(dpaa2_logtype_event, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa2_logtype_event, pmd.event.dpaa2, NOTICE);
diff --git a/drivers/event/octeontx/ssovf_evdev.c b/drivers/event/octeontx/ssovf_evdev.c
index 1b1a5d939..4fc4e8f7e 100644
--- a/drivers/event/octeontx/ssovf_evdev.c
+++ b/drivers/event/octeontx/ssovf_evdev.c
@@ -20,15 +20,9 @@
 #include "ssovf_evdev.h"
 #include "timvf_evdev.h"
 
-int otx_logtype_ssovf;
 static uint8_t timvf_enable_stats;
 
-RTE_INIT(otx_ssovf_init_log)
-{
-	otx_logtype_ssovf = rte_log_register("pmd.event.octeontx");
-	if (otx_logtype_ssovf >= 0)
-		rte_log_set_level(otx_logtype_ssovf, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(otx_logtype_ssovf, pmd.event.octeontx, NOTICE);
 
 /* SSOPF Mailbox messages */
 
diff --git a/drivers/event/octeontx/timvf_evdev.c b/drivers/event/octeontx/timvf_evdev.c
index caa129087..c61aacacc 100644
--- a/drivers/event/octeontx/timvf_evdev.c
+++ b/drivers/event/octeontx/timvf_evdev.c
@@ -4,14 +4,7 @@
 
 #include "timvf_evdev.h"
 
-int otx_logtype_timvf;
-
-RTE_INIT(otx_timvf_init_log)
-{
-	otx_logtype_timvf = rte_log_register("pmd.event.octeontx.timer");
-	if (otx_logtype_timvf >= 0)
-		rte_log_set_level(otx_logtype_timvf, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(otx_logtype_timvf, pmd.event.octeontx.timer, NOTICE);
 
 struct __rte_packed timvf_mbox_dev_info {
 	uint64_t ring_active[4];
diff --git a/drivers/event/opdl/opdl_evdev.c b/drivers/event/opdl/opdl_evdev.c
index 3beca8957..9b2f75fe3 100644
--- a/drivers/event/opdl/opdl_evdev.c
+++ b/drivers/event/opdl/opdl_evdev.c
@@ -754,13 +754,7 @@ static struct rte_vdev_driver evdev_opdl_pmd_drv = {
 	.remove = opdl_remove
 };
 
-RTE_INIT(opdl_init_log)
-{
-	opdl_logtype_driver = rte_log_register("pmd.event.opdl.driver");
-	if (opdl_logtype_driver >= 0)
-		rte_log_set_level(opdl_logtype_driver, RTE_LOG_INFO);
-}
-
+RTE_LOG_REGISTER(opdl_logtype_driver, pmd.event.opdl.driver, INFO);
 
 RTE_PMD_REGISTER_VDEV(EVENTDEV_NAME_OPDL_PMD, evdev_opdl_pmd_drv);
 RTE_PMD_REGISTER_PARAM_STRING(event_opdl, NUMA_NODE_ARG "=<int>"
diff --git a/drivers/event/opdl/opdl_ring.c b/drivers/event/opdl/opdl_ring.c
index c8d19fef5..69392b56b 100644
--- a/drivers/event/opdl/opdl_ring.c
+++ b/drivers/event/opdl/opdl_ring.c
@@ -31,8 +31,6 @@
 #define OPDL_OPA_MASK    (0xFF)
 #define OPDL_OPA_OFFSET  (0x38)
 
-int opdl_logtype_driver;
-
 /* Types of dependency between stages */
 enum dep_type {
 	DEP_NONE = 0,  /* no dependency */
diff --git a/drivers/event/sw/sw_evdev.c b/drivers/event/sw/sw_evdev.c
index fb8e8bebb..98dae7164 100644
--- a/drivers/event/sw/sw_evdev.c
+++ b/drivers/event/sw/sw_evdev.c
@@ -1083,13 +1083,4 @@ static struct rte_vdev_driver evdev_sw_pmd_drv = {
 RTE_PMD_REGISTER_VDEV(EVENTDEV_NAME_SW_PMD, evdev_sw_pmd_drv);
 RTE_PMD_REGISTER_PARAM_STRING(event_sw, NUMA_NODE_ARG "=<int> "
 		SCHED_QUANTA_ARG "=<int>" CREDIT_QUANTA_ARG "=<int>");
-
-/* declared extern in header, for access from other .c files */
-int eventdev_sw_log_level;
-
-RTE_INIT(evdev_sw_init_log)
-{
-	eventdev_sw_log_level = rte_log_register("pmd.event.sw");
-	if (eventdev_sw_log_level >= 0)
-		rte_log_set_level(eventdev_sw_log_level, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(eventdev_sw_log_level, pmd.event.sw, NOTICE);
-- 
2.26.2


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

* [dpdk-dev]  [PATCH 08/13] drivers/crypto: use log register macro
  2020-06-17  6:30 [dpdk-dev] [PATCH 00/13] rte_log registration usage improvement jerinj
                   ` (6 preceding siblings ...)
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 07/13] drivers/event: " jerinj
@ 2020-06-17  6:30 ` jerinj
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 09/13] drivers/compress: " jerinj
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-06-17  6:30 UTC (permalink / raw)
  To: dev, Declan Doherty, Pablo de Lara, Gagandeep Singh,
	Hemant Agrawal, Akhil Goyal, Michael Shamis, Liron Himi,
	Nagadheeraj Rottela, Srikanth Jampala, Anoob Joseph,
	Ankur Dwivedi, Fan Zhang, Jay Zhou
  Cc: thomas, olivier.matz, david.marchand, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
---
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c      |  8 +---
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c    |  8 +---
 drivers/crypto/caam_jr/caam_jr.c              |  8 +---
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c   | 11 +-----
 drivers/crypto/dpaa_sec/dpaa_sec.c            | 10 +----
 drivers/crypto/kasumi/rte_kasumi_pmd.c        |  6 +--
 drivers/crypto/mvsam/rte_mrvl_pmd.c           |  7 +---
 drivers/crypto/nitrox/nitrox_logs.c           |  9 +----
 drivers/crypto/null/null_crypto_pmd.c         |  7 +---
 drivers/crypto/octeontx/otx_cryptodev.c       | 10 +----
 drivers/crypto/octeontx2/otx2_cryptodev.c     | 12 +-----
 drivers/crypto/openssl/rte_openssl_pmd.c      |  7 +---
 .../scheduler/rte_cryptodev_scheduler.c       |  8 +---
 drivers/crypto/snow3g/rte_snow3g_pmd.c        |  7 +---
 drivers/crypto/virtio/virtio_cryptodev.c      | 39 ++++---------------
 drivers/crypto/zuc/rte_zuc_pmd.c              |  7 +---
 16 files changed, 23 insertions(+), 141 deletions(-)

diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
index d213d05b9..1d2a0ce00 100644
--- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
+++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
@@ -13,8 +13,6 @@
 
 #include "aesni_gcm_pmd_private.h"
 
-int aesni_gcm_logtype_driver;
-
 static uint8_t cryptodev_driver_id;
 
 /* setup session handlers */
@@ -889,8 +887,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_AESNI_GCM_PMD,
 	"socket_id=<int>");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(aesni_gcm_crypto_drv, aesni_gcm_pmd_drv.driver,
 		cryptodev_driver_id);
-
-RTE_INIT(aesni_gcm_init_log)
-{
-	aesni_gcm_logtype_driver = rte_log_register("pmd.crypto.aesni_gcm");
-}
+RTE_LOG_REGISTER(aesni_gcm_logtype_driver, pmd.crypto.aesni_gcm, NOTICE);
diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
index 2d688f4d3..9d0d9f4d7 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
@@ -15,8 +15,6 @@
 
 #include "aesni_mb_pmd_private.h"
 
-int aesni_mb_logtype_driver;
-
 #define AES_CCM_DIGEST_MIN_LEN 4
 #define AES_CCM_DIGEST_MAX_LEN 16
 #define HMAC_MAX_BLOCK_SIZE 128
@@ -1744,8 +1742,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_AESNI_MB_PMD,
 RTE_PMD_REGISTER_CRYPTO_DRIVER(aesni_mb_crypto_drv,
 		cryptodev_aesni_mb_pmd_drv.driver,
 		cryptodev_driver_id);
-
-RTE_INIT(aesni_mb_init_log)
-{
-	aesni_mb_logtype_driver = rte_log_register("pmd.crypto.aesni_mb");
-}
+RTE_LOG_REGISTER(aesni_mb_logtype_driver, pmd.crypto.aesni_mb, NOTICE);
diff --git a/drivers/crypto/caam_jr/caam_jr.c b/drivers/crypto/caam_jr/caam_jr.c
index caf238677..49a35d614 100644
--- a/drivers/crypto/caam_jr/caam_jr.c
+++ b/drivers/crypto/caam_jr/caam_jr.c
@@ -35,7 +35,6 @@
 #endif
 #define CRYPTODEV_NAME_CAAM_JR_PMD	crypto_caam_jr
 static uint8_t cryptodev_driver_id;
-int caam_jr_logtype;
 
 /* Lists the states possible for the SEC user space driver. */
 enum sec_driver_state_e {
@@ -2477,9 +2476,4 @@ RTE_INIT(caam_jr_init)
 	sec_job_rings_init();
 }
 
-RTE_INIT(caam_jr_init_log)
-{
-	caam_jr_logtype = rte_log_register("pmd.crypto.caam");
-	if (caam_jr_logtype >= 0)
-		rte_log_set_level(caam_jr_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(caam_jr_logtype, pmd.crypto.caam, NOTICE);
diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index 63e7d930a..12f833136 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
@@ -58,8 +58,6 @@
 
 static uint8_t cryptodev_driver_id;
 
-int dpaa2_logtype_sec;
-
 #ifdef RTE_LIBRTE_SECURITY
 static inline int
 build_proto_compound_sg_fd(dpaa2_sec_session *sess,
@@ -3918,11 +3916,4 @@ static struct cryptodev_driver dpaa2_sec_crypto_drv;
 RTE_PMD_REGISTER_DPAA2(CRYPTODEV_NAME_DPAA2_SEC_PMD, rte_dpaa2_sec_driver);
 RTE_PMD_REGISTER_CRYPTO_DRIVER(dpaa2_sec_crypto_drv,
 		rte_dpaa2_sec_driver.driver, cryptodev_driver_id);
-
-RTE_INIT(dpaa2_sec_init_log)
-{
-	/* Bus level logs */
-	dpaa2_logtype_sec = rte_log_register("pmd.crypto.dpaa2");
-	if (dpaa2_logtype_sec >= 0)
-		rte_log_set_level(dpaa2_logtype_sec, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa2_logtype_sec, pmd.crypto.dpaa2, NOTICE);
diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c
index 66ee0ba0c..d9fa8bb36 100644
--- a/drivers/crypto/dpaa_sec/dpaa_sec.c
+++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
@@ -43,8 +43,6 @@
 #include <dpaa_sec_log.h>
 #include <dpaax_iova_table.h>
 
-int dpaa_logtype_sec;
-
 static uint8_t cryptodev_driver_id;
 
 static __thread struct rte_crypto_op **dpaa_sec_ops;
@@ -3520,10 +3518,4 @@ static struct cryptodev_driver dpaa_sec_crypto_drv;
 RTE_PMD_REGISTER_DPAA(CRYPTODEV_NAME_DPAA_SEC_PMD, rte_dpaa_sec_driver);
 RTE_PMD_REGISTER_CRYPTO_DRIVER(dpaa_sec_crypto_drv, rte_dpaa_sec_driver.driver,
 		cryptodev_driver_id);
-
-RTE_INIT(dpaa_sec_init_log)
-{
-	dpaa_logtype_sec = rte_log_register("pmd.crypto.dpaa");
-	if (dpaa_logtype_sec >= 0)
-		rte_log_set_level(dpaa_logtype_sec, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa_logtype_sec, pmd.crypto.dpaa, NOTICE);
diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd.c b/drivers/crypto/kasumi/rte_kasumi_pmd.c
index 73077e3d9..c3f0dfc2f 100644
--- a/drivers/crypto/kasumi/rte_kasumi_pmd.c
+++ b/drivers/crypto/kasumi/rte_kasumi_pmd.c
@@ -17,7 +17,6 @@
 #define KASUMI_MAX_BURST 4
 #define BYTE_LEN 8
 
-int kasumi_logtype_driver;
 static uint8_t cryptodev_driver_id;
 
 /** Get xform chain order. */
@@ -639,7 +638,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_KASUMI_PMD,
 RTE_PMD_REGISTER_CRYPTO_DRIVER(kasumi_crypto_drv,
 		cryptodev_kasumi_pmd_drv.driver, cryptodev_driver_id);
 
-RTE_INIT(kasumi_init_log)
-{
-	kasumi_logtype_driver = rte_log_register("pmd.crypto.kasumi");
-}
+RTE_LOG_REGISTER(kasumi_logtype_driver, pmd.crypto.kasumi, NOTICE);
diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd.c b/drivers/crypto/mvsam/rte_mrvl_pmd.c
index 63782ce97..aaa40dced 100644
--- a/drivers/crypto/mvsam/rte_mrvl_pmd.c
+++ b/drivers/crypto/mvsam/rte_mrvl_pmd.c
@@ -19,7 +19,6 @@
 #define MRVL_PMD_MAX_NB_SESS_ARG		("max_nb_sessions")
 #define MRVL_PMD_DEFAULT_MAX_NB_SESSIONS	2048
 
-int mrvl_logtype_driver;
 static uint8_t cryptodev_driver_id;
 
 struct mrvl_pmd_init_params {
@@ -1020,8 +1019,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_MRVL_PMD,
 	"socket_id=<int>");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(mrvl_crypto_drv, cryptodev_mrvl_pmd_drv.driver,
 		cryptodev_driver_id);
-
-RTE_INIT(crypto_mrvl_init_log)
-{
-	mrvl_logtype_driver = rte_log_register("pmd.crypto.mvsam");
-}
+RTE_LOG_REGISTER(mrvl_logtype_driver, pmd.crypto.mvsam, NOTICE);
diff --git a/drivers/crypto/nitrox/nitrox_logs.c b/drivers/crypto/nitrox/nitrox_logs.c
index 007056cb4..26395159a 100644
--- a/drivers/crypto/nitrox/nitrox_logs.c
+++ b/drivers/crypto/nitrox/nitrox_logs.c
@@ -4,11 +4,4 @@
 
 #include <rte_log.h>
 
-int nitrox_logtype;
-
-RTE_INIT(nitrox_init_log)
-{
-	nitrox_logtype = rte_log_register("pmd.crypto.nitrox");
-	if (nitrox_logtype >= 0)
-		rte_log_set_level(nitrox_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(nitrox_logtype, pmd.crypto.nitrox, NOTICE);
diff --git a/drivers/crypto/null/null_crypto_pmd.c b/drivers/crypto/null/null_crypto_pmd.c
index 7b0b9d42b..e04042e75 100644
--- a/drivers/crypto/null/null_crypto_pmd.c
+++ b/drivers/crypto/null/null_crypto_pmd.c
@@ -10,7 +10,6 @@
 #include "null_crypto_pmd_private.h"
 
 static uint8_t cryptodev_driver_id;
-int null_logtype_driver;
 
 /** verify and set session parameters */
 int
@@ -249,8 +248,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_NULL_PMD,
 	"socket_id=<int>");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(null_crypto_drv, cryptodev_null_pmd_drv.driver,
 		cryptodev_driver_id);
-
-RTE_INIT(null_init_log)
-{
-	null_logtype_driver = rte_log_register("pmd.crypto.null");
-}
+RTE_LOG_REGISTER(null_logtype_driver, pmd.crypto.null, INFO);
diff --git a/drivers/crypto/octeontx/otx_cryptodev.c b/drivers/crypto/octeontx/otx_cryptodev.c
index ddece1311..5ce1cf82f 100644
--- a/drivers/crypto/octeontx/otx_cryptodev.c
+++ b/drivers/crypto/octeontx/otx_cryptodev.c
@@ -15,7 +15,6 @@
 #include "cpt_pmd_logs.h"
 
 uint8_t otx_cryptodev_driver_id;
-int otx_cpt_logtype;
 
 static struct rte_pci_id pci_id_cpt_table[] = {
 	{
@@ -112,11 +111,4 @@ RTE_PMD_REGISTER_PCI_TABLE(CRYPTODEV_NAME_OCTEONTX_PMD, pci_id_cpt_table);
 RTE_PMD_REGISTER_KMOD_DEP(CRYPTODEV_NAME_OCTEONTX_PMD, "vfio-pci");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(otx_cryptodev_drv, otx_cryptodev_pmd.driver,
 		otx_cryptodev_driver_id);
-
-RTE_INIT(otx_cpt_init_log)
-{
-	/* Bus level logs */
-	otx_cpt_logtype = rte_log_register("pmd.crypto.octeontx");
-	if (otx_cpt_logtype >= 0)
-		rte_log_set_level(otx_cpt_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(otx_cpt_logtype, pmd.crypto.octeontx, NOTICE);
diff --git a/drivers/crypto/octeontx2/otx2_cryptodev.c b/drivers/crypto/octeontx2/otx2_cryptodev.c
index 6ffbc2eb7..50cbb13d8 100644
--- a/drivers/crypto/octeontx2/otx2_cryptodev.c
+++ b/drivers/crypto/octeontx2/otx2_cryptodev.c
@@ -22,8 +22,6 @@
 #include "cpt_common.h"
 #include "cpt_pmd_logs.h"
 
-int otx2_cpt_logtype;
-
 uint8_t otx2_cryptodev_driver_id;
 
 static struct rte_pci_id pci_id_cpt_table[] = {
@@ -146,17 +144,9 @@ static struct rte_pci_driver otx2_cryptodev_pmd = {
 
 static struct cryptodev_driver otx2_cryptodev_drv;
 
-RTE_INIT(otx2_cpt_init_log);
 RTE_PMD_REGISTER_PCI(CRYPTODEV_NAME_OCTEONTX2_PMD, otx2_cryptodev_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(CRYPTODEV_NAME_OCTEONTX2_PMD, pci_id_cpt_table);
 RTE_PMD_REGISTER_KMOD_DEP(CRYPTODEV_NAME_OCTEONTX2_PMD, "vfio-pci");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(otx2_cryptodev_drv, otx2_cryptodev_pmd.driver,
 		otx2_cryptodev_driver_id);
-
-RTE_INIT(otx2_cpt_init_log)
-{
-	/* Bus level logs */
-	otx2_cpt_logtype = rte_log_register("pmd.crypto.octeontx2");
-	if (otx2_cpt_logtype >= 0)
-		rte_log_set_level(otx2_cpt_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(otx2_cpt_logtype, pmd.crypto.octeontx2, NOTICE);
diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c
index bb9fb877a..7d3959f55 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd.c
@@ -18,7 +18,6 @@
 
 #define DES_BLOCK_SIZE 8
 
-int openssl_logtype_driver;
 static uint8_t cryptodev_driver_id;
 
 #if (OPENSSL_VERSION_NUMBER < 0x10100000L)
@@ -2279,8 +2278,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_OPENSSL_PMD,
 	"socket_id=<int>");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(openssl_crypto_drv,
 		cryptodev_openssl_pmd_drv.driver, cryptodev_driver_id);
-
-RTE_INIT(openssl_init_log)
-{
-	openssl_logtype_driver = rte_log_register("pmd.crypto.openssl");
-}
+RTE_LOG_REGISTER(openssl_logtype_driver, pmd.crypto.openssl, INFO);
diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
index 1fef88f11..730504dab 100644
--- a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
+++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
@@ -10,8 +10,6 @@
 #include "rte_cryptodev_scheduler.h"
 #include "scheduler_pmd_private.h"
 
-int scheduler_logtype_driver;
-
 /** update the scheduler pmd's capability with attaching device's
  *  capability.
  *  For each device to be attached, the scheduler's capability should be
@@ -578,7 +576,5 @@ rte_cryptodev_scheduler_option_get(uint8_t scheduler_id,
 	return (*sched_ctx->ops.option_get)(dev, option_type, option);
 }
 
-RTE_INIT(scheduler_init_log)
-{
-	scheduler_logtype_driver = rte_log_register("pmd.crypto.scheduler");
-}
+
+RTE_LOG_REGISTER(scheduler_logtype_driver, pmd.crypto.scheduler, INFO);
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index c939064d5..558e01e70 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -16,7 +16,6 @@
 #define SNOW3G_MAX_BURST 8
 #define BYTE_LEN 8
 
-int snow3g_logtype_driver;
 static uint8_t cryptodev_driver_id;
 
 /** Get xform chain order. */
@@ -653,8 +652,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_SNOW3G_PMD,
 	"socket_id=<int>");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(snow3g_crypto_drv,
 		cryptodev_snow3g_pmd_drv.driver, cryptodev_driver_id);
-
-RTE_INIT(snow3g_init_log)
-{
-	snow3g_logtype_driver = rte_log_register("pmd.crypto.snow3g");
-}
+RTE_LOG_REGISTER(snow3g_logtype_driver, pmd.crypto.snow3g, INFO);
diff --git a/drivers/crypto/virtio/virtio_cryptodev.c b/drivers/crypto/virtio/virtio_cryptodev.c
index cdf43b0e0..31a5f1072 100644
--- a/drivers/crypto/virtio/virtio_cryptodev.c
+++ b/drivers/crypto/virtio/virtio_cryptodev.c
@@ -17,12 +17,6 @@
 #include "virtio_crypto_algs.h"
 #include "virtio_crypto_capabilities.h"
 
-int virtio_crypto_logtype_init;
-int virtio_crypto_logtype_session;
-int virtio_crypto_logtype_rx;
-int virtio_crypto_logtype_tx;
-int virtio_crypto_logtype_driver;
-
 static int virtio_crypto_dev_configure(struct rte_cryptodev *dev,
 		struct rte_cryptodev_config *config);
 static int virtio_crypto_dev_start(struct rte_cryptodev *dev);
@@ -1489,29 +1483,10 @@ RTE_PMD_REGISTER_PCI(CRYPTODEV_NAME_VIRTIO_PMD, rte_virtio_crypto_driver);
 RTE_PMD_REGISTER_CRYPTO_DRIVER(virtio_crypto_drv,
 	rte_virtio_crypto_driver.driver,
 	cryptodev_virtio_driver_id);
-
-RTE_INIT(virtio_crypto_init_log)
-{
-	virtio_crypto_logtype_init = rte_log_register("pmd.crypto.virtio.init");
-	if (virtio_crypto_logtype_init >= 0)
-		rte_log_set_level(virtio_crypto_logtype_init, RTE_LOG_NOTICE);
-
-	virtio_crypto_logtype_session =
-		rte_log_register("pmd.crypto.virtio.session");
-	if (virtio_crypto_logtype_session >= 0)
-		rte_log_set_level(virtio_crypto_logtype_session,
-				RTE_LOG_NOTICE);
-
-	virtio_crypto_logtype_rx = rte_log_register("pmd.crypto.virtio.rx");
-	if (virtio_crypto_logtype_rx >= 0)
-		rte_log_set_level(virtio_crypto_logtype_rx, RTE_LOG_NOTICE);
-
-	virtio_crypto_logtype_tx = rte_log_register("pmd.crypto.virtio.tx");
-	if (virtio_crypto_logtype_tx >= 0)
-		rte_log_set_level(virtio_crypto_logtype_tx, RTE_LOG_NOTICE);
-
-	virtio_crypto_logtype_driver =
-		rte_log_register("pmd.crypto.virtio.driver");
-	if (virtio_crypto_logtype_driver >= 0)
-		rte_log_set_level(virtio_crypto_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(virtio_crypto_logtype_init, pmd.crypto.virtio.init, NOTICE);
+RTE_LOG_REGISTER(virtio_crypto_logtype_session, pmd.crypto.virtio.session,
+		 NOTICE);
+RTE_LOG_REGISTER(virtio_crypto_logtype_rx, pmd.crypto.virtio.rx, NOTICE);
+RTE_LOG_REGISTER(virtio_crypto_logtype_tx, pmd.crypto.virtio.tx, NOTICE);
+RTE_LOG_REGISTER(virtio_crypto_logtype_driver, pmd.crypto.virtio.driver,
+		 NOTICE);
diff --git a/drivers/crypto/zuc/rte_zuc_pmd.c b/drivers/crypto/zuc/rte_zuc_pmd.c
index df8d6f6bb..20cb5a160 100644
--- a/drivers/crypto/zuc/rte_zuc_pmd.c
+++ b/drivers/crypto/zuc/rte_zuc_pmd.c
@@ -14,7 +14,6 @@
 #define ZUC_MAX_BURST 16
 #define BYTE_LEN 8
 
-int zuc_logtype_driver;
 static uint8_t cryptodev_driver_id;
 
 /** Get xform chain order. */
@@ -580,8 +579,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_ZUC_PMD,
 	"socket_id=<int>");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(zuc_crypto_drv, cryptodev_zuc_pmd_drv.driver,
 		cryptodev_driver_id);
-
-RTE_INIT(zuc_init_log)
-{
-	zuc_logtype_driver = rte_log_register("pmd.crypto.zuc");
-}
+RTE_LOG_REGISTER(zuc_logtype_driver, pmd.crypto.zuc, INFO);
-- 
2.26.2


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

* [dpdk-dev] [PATCH 09/13] drivers/compress: use log register macro
  2020-06-17  6:30 [dpdk-dev] [PATCH 00/13] rte_log registration usage improvement jerinj
                   ` (7 preceding siblings ...)
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 08/13] drivers/crypto: " jerinj
@ 2020-06-17  6:30 ` jerinj
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 10/13] drivers/common: " jerinj
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-06-17  6:30 UTC (permalink / raw)
  To: dev, Lee Daly, Fiona Trahe, Ashish Gupta, Sunila Sahu
  Cc: thomas, olivier.matz, david.marchand, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
---
 drivers/compress/isal/isal_compress_pmd.c | 10 +---------
 drivers/compress/octeontx/otx_zip_pmd.c   | 10 +---------
 drivers/compress/zlib/zlib_pmd.c          | 10 +---------
 3 files changed, 3 insertions(+), 27 deletions(-)

diff --git a/drivers/compress/isal/isal_compress_pmd.c b/drivers/compress/isal/isal_compress_pmd.c
index 7d2b05c91..0ecca12a8 100644
--- a/drivers/compress/isal/isal_compress_pmd.c
+++ b/drivers/compress/isal/isal_compress_pmd.c
@@ -25,8 +25,6 @@
 #define ISAL_VERSION_STRING \
 	ISAL_TOSTRING(ISAL_MAJOR_VERSION, ISAL_MINOR_VERSION, ISAL_PATCH_VERSION)
 
-int isal_logtype_driver;
-
 /* Verify and set private xform parameters */
 int
 isal_comp_set_priv_xform_parameters(struct isal_priv_xform *priv_xform,
@@ -752,10 +750,4 @@ static struct rte_vdev_driver compdev_isal_pmd_drv = {
 RTE_PMD_REGISTER_VDEV(COMPDEV_NAME_ISAL_PMD, compdev_isal_pmd_drv);
 RTE_PMD_REGISTER_PARAM_STRING(COMPDEV_NAME_ISAL_PMD,
 	"socket_id=<int>");
-
-RTE_INIT(isal_init_log)
-{
-	isal_logtype_driver = rte_log_register("pmd.compress.isal");
-	if (isal_logtype_driver >= 0)
-		rte_log_set_level(isal_logtype_driver, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(isal_logtype_driver, pmd.compress.isal, INFO);
diff --git a/drivers/compress/octeontx/otx_zip_pmd.c b/drivers/compress/octeontx/otx_zip_pmd.c
index bff8ef035..bee90fc7c 100644
--- a/drivers/compress/octeontx/otx_zip_pmd.c
+++ b/drivers/compress/octeontx/otx_zip_pmd.c
@@ -11,8 +11,6 @@
 
 #include "otx_zip.h"
 
-int octtx_zip_logtype_driver;
-
 static const struct rte_compressdev_capabilities
 				octtx_zip_pmd_capabilities[] = {
 	{	.algo = RTE_COMP_ALGO_DEFLATE,
@@ -648,10 +646,4 @@ static struct rte_pci_driver octtx_zip_pmd = {
 
 RTE_PMD_REGISTER_PCI(COMPRESSDEV_NAME_ZIP_PMD, octtx_zip_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(COMPRESSDEV_NAME_ZIP_PMD, pci_id_octtx_zipvf_table);
-
-RTE_INIT(octtx_zip_init_log)
-{
-	octtx_zip_logtype_driver = rte_log_register("pmd.compress.octeontx");
-	if (octtx_zip_logtype_driver >= 0)
-		rte_log_set_level(octtx_zip_logtype_driver, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(octtx_zip_logtype_driver, pmd.compress.octeontx, INFO);
diff --git a/drivers/compress/zlib/zlib_pmd.c b/drivers/compress/zlib/zlib_pmd.c
index e39be2ed8..8a79d15c9 100644
--- a/drivers/compress/zlib/zlib_pmd.c
+++ b/drivers/compress/zlib/zlib_pmd.c
@@ -7,8 +7,6 @@
 
 #include "zlib_pmd_private.h"
 
-int zlib_logtype_driver;
-
 /** Compute next mbuf in the list, assign data buffer and length,
  *  returns 0 if mbuf is NULL
  */
@@ -428,10 +426,4 @@ static struct rte_vdev_driver zlib_pmd_drv = {
 };
 
 RTE_PMD_REGISTER_VDEV(COMPRESSDEV_NAME_ZLIB_PMD, zlib_pmd_drv);
-
-RTE_INIT(zlib_init_log)
-{
-	zlib_logtype_driver = rte_log_register("pmd.compress.zlib");
-	if (zlib_logtype_driver >= 0)
-		rte_log_set_level(zlib_logtype_driver, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(zlib_logtype_driver, pmd.compress.zlib, INFO);
-- 
2.26.2


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

* [dpdk-dev]  [PATCH 10/13] drivers/common: use log register macro
  2020-06-17  6:30 [dpdk-dev] [PATCH 00/13] rte_log registration usage improvement jerinj
                   ` (8 preceding siblings ...)
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 09/13] drivers/compress: " jerinj
@ 2020-06-17  6:30 ` jerinj
  2020-06-21  9:48   ` Sachin Saxena (OSS)
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 11/13] drivers/bus: " jerinj
                   ` (4 subsequent siblings)
  14 siblings, 1 reply; 98+ messages in thread
From: jerinj @ 2020-06-17  6:30 UTC (permalink / raw)
  To: dev, Hemant Agrawal, Sachin Saxena, Jingjing Wu, Beilei Xing,
	Harman Kalra, Jerin Jacob, Nithin Dabilpuram, John Griffin,
	Fiona Trahe, Deepak Kumar Jain
  Cc: thomas, olivier.matz, david.marchand

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
---
 drivers/common/dpaax/dpaax_iova_table.c | 10 +--
 drivers/common/iavf/iavf_impl.c         |  9 +--
 drivers/common/octeontx/octeontx_mbox.c |  9 +--
 drivers/common/octeontx2/otx2_common.c  | 96 +++----------------------
 drivers/common/qat/qat_logs.c           | 17 +----
 5 files changed, 15 insertions(+), 126 deletions(-)

diff --git a/drivers/common/dpaax/dpaax_iova_table.c b/drivers/common/dpaax/dpaax_iova_table.c
index 98b076e09..5ba8ed193 100644
--- a/drivers/common/dpaax/dpaax_iova_table.c
+++ b/drivers/common/dpaax/dpaax_iova_table.c
@@ -7,9 +7,6 @@
 #include "dpaax_iova_table.h"
 #include "dpaax_logs.h"
 
-/* Global dpaax logger identifier */
-int dpaax_logger;
-
 /* Global table reference */
 struct dpaax_iova_table *dpaax_iova_table_p;
 
@@ -463,9 +460,4 @@ dpaax_handle_memevents(void)
 					       dpaax_memevent_cb, NULL);
 }
 
-RTE_INIT(dpaax_log)
-{
-	dpaax_logger = rte_log_register("pmd.common.dpaax");
-	if (dpaax_logger >= 0)
-		rte_log_set_level(dpaax_logger, RTE_LOG_ERR);
-}
+RTE_LOG_REGISTER(dpaax_logger, pmd.common.dpaax, ERR);
diff --git a/drivers/common/iavf/iavf_impl.c b/drivers/common/iavf/iavf_impl.c
index 6174a9144..fc0da3175 100644
--- a/drivers/common/iavf/iavf_impl.c
+++ b/drivers/common/iavf/iavf_impl.c
@@ -13,8 +13,6 @@
 #include "iavf_type.h"
 #include "iavf_prototype.h"
 
-int iavf_common_logger;
-
 enum iavf_status
 iavf_allocate_dma_mem_d(__rte_unused struct iavf_hw *hw,
 			struct iavf_dma_mem *mem,
@@ -87,9 +85,4 @@ iavf_free_virt_mem_d(__rte_unused struct iavf_hw *hw,
 	return IAVF_SUCCESS;
 }
 
-RTE_INIT(iavf_common_init_log)
-{
-	iavf_common_logger = rte_log_register("pmd.common.iavf");
-	if (iavf_common_logger >= 0)
-		rte_log_set_level(iavf_common_logger, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(iavf_common_logger, pmd.common.iavf, NOTICE);
diff --git a/drivers/common/octeontx/octeontx_mbox.c b/drivers/common/octeontx/octeontx_mbox.c
index effe0b267..f414267e4 100644
--- a/drivers/common/octeontx/octeontx_mbox.c
+++ b/drivers/common/octeontx/octeontx_mbox.c
@@ -68,14 +68,7 @@ struct mbox_intf_ver {
 	uint32_t minor:10;
 };
 
-int octeontx_logtype_mbox;
-
-RTE_INIT(otx_init_log)
-{
-	octeontx_logtype_mbox = rte_log_register("pmd.octeontx.mbox");
-	if (octeontx_logtype_mbox >= 0)
-		rte_log_set_level(octeontx_logtype_mbox, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(octeontx_logtype_mbox, pmd.octeontx.mbox, NOTICE);
 
 static inline void
 mbox_msgcpy(volatile uint8_t *d, volatile const uint8_t *s, uint16_t size)
diff --git a/drivers/common/octeontx2/otx2_common.c b/drivers/common/octeontx2/otx2_common.c
index 5e7272f69..b292e999a 100644
--- a/drivers/common/octeontx2/otx2_common.c
+++ b/drivers/common/octeontx2/otx2_common.c
@@ -203,89 +203,13 @@ void otx2_parse_common_devargs(struct rte_kvargs *kvlist)
 	idev->npa_lock_mask = npa_lock_mask;
 }
 
-/**
- * @internal
- */
-int otx2_logtype_base;
-/**
- * @internal
- */
-int otx2_logtype_mbox;
-/**
- * @internal
- */
-int otx2_logtype_npa;
-/**
- * @internal
- */
-int otx2_logtype_nix;
-/**
- * @internal
- */
-int otx2_logtype_npc;
-/**
- * @internal
- */
-int otx2_logtype_tm;
-/**
- * @internal
- */
-int otx2_logtype_sso;
-/**
- * @internal
- */
-int otx2_logtype_tim;
-/**
- * @internal
- */
-int otx2_logtype_dpi;
-/**
- * @internal
- */
-int otx2_logtype_ep;
-
-RTE_INIT(otx2_log_init);
-static void
-otx2_log_init(void)
-{
-	otx2_logtype_base = rte_log_register("pmd.octeontx2.base");
-	if (otx2_logtype_base >= 0)
-		rte_log_set_level(otx2_logtype_base, RTE_LOG_NOTICE);
-
-	otx2_logtype_mbox = rte_log_register("pmd.octeontx2.mbox");
-	if (otx2_logtype_mbox >= 0)
-		rte_log_set_level(otx2_logtype_mbox, RTE_LOG_NOTICE);
-
-	otx2_logtype_npa = rte_log_register("pmd.mempool.octeontx2");
-	if (otx2_logtype_npa >= 0)
-		rte_log_set_level(otx2_logtype_npa, RTE_LOG_NOTICE);
-
-	otx2_logtype_nix = rte_log_register("pmd.net.octeontx2");
-	if (otx2_logtype_nix >= 0)
-		rte_log_set_level(otx2_logtype_nix, RTE_LOG_NOTICE);
-
-	otx2_logtype_npc = rte_log_register("pmd.net.octeontx2.flow");
-	if (otx2_logtype_npc >= 0)
-		rte_log_set_level(otx2_logtype_npc, RTE_LOG_NOTICE);
-
-	otx2_logtype_tm = rte_log_register("pmd.net.octeontx2.tm");
-	if (otx2_logtype_tm >= 0)
-		rte_log_set_level(otx2_logtype_tm, RTE_LOG_NOTICE);
-
-	otx2_logtype_sso = rte_log_register("pmd.event.octeontx2");
-	if (otx2_logtype_sso >= 0)
-		rte_log_set_level(otx2_logtype_sso, RTE_LOG_NOTICE);
-
-	otx2_logtype_tim = rte_log_register("pmd.event.octeontx2.timer");
-	if (otx2_logtype_tim >= 0)
-		rte_log_set_level(otx2_logtype_tim, RTE_LOG_NOTICE);
-
-	otx2_logtype_dpi = rte_log_register("pmd.raw.octeontx2.dpi");
-	if (otx2_logtype_dpi >= 0)
-		rte_log_set_level(otx2_logtype_dpi, RTE_LOG_NOTICE);
-
-	otx2_logtype_ep = rte_log_register("pmd.raw.octeontx2.ep");
-	if (otx2_logtype_ep >= 0)
-		rte_log_set_level(otx2_logtype_ep, RTE_LOG_NOTICE);
-
-}
+RTE_LOG_REGISTER(otx2_logtype_base, pmd.octeontx2.base, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_mbox, pmd.octeontx2.mbox, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_npa, pmd.mempool.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_nix, pmd.net.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_npc, pmd.net.octeontx2.flow, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_tm, pmd.net.octeontx2.tm, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_sso, pmd.event.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_tim, pmd.event.octeontx2.timer, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_dpi, pmd.raw.octeontx2.dpi, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_ep, pmd.raw.octeontx2.ep, NOTICE);
diff --git a/drivers/common/qat/qat_logs.c b/drivers/common/qat/qat_logs.c
index dfd0cbe5d..fa48be53c 100644
--- a/drivers/common/qat/qat_logs.c
+++ b/drivers/common/qat/qat_logs.c
@@ -7,9 +7,6 @@
 
 #include "qat_logs.h"
 
-int qat_gen_logtype;
-int qat_dp_logtype;
-
 int
 qat_hexdump_log(uint32_t level, uint32_t logtype, const char *title,
 		const void *buf, unsigned int len)
@@ -20,15 +17,5 @@ qat_hexdump_log(uint32_t level, uint32_t logtype, const char *title,
 	return 0;
 }
 
-RTE_INIT(qat_pci_init_log)
-{
-	/* Non-data-path logging for pci device and all services */
-	qat_gen_logtype = rte_log_register("pmd.qat_general");
-	if (qat_gen_logtype >= 0)
-		rte_log_set_level(qat_gen_logtype, RTE_LOG_NOTICE);
-
-	/* data-path logging for all services */
-	qat_dp_logtype = rte_log_register("pmd.qat_dp");
-	if (qat_dp_logtype >= 0)
-		rte_log_set_level(qat_dp_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(qat_gen_logtype, pmd.qat_general, NOTICE);
+RTE_LOG_REGISTER(qat_dp_logtype, pmd.qat_dp, NOTICE);
-- 
2.26.2


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

* [dpdk-dev]  [PATCH 11/13] drivers/bus: use log register macro
  2020-06-17  6:30 [dpdk-dev] [PATCH 00/13] rte_log registration usage improvement jerinj
                   ` (9 preceding siblings ...)
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 10/13] drivers/common: " jerinj
@ 2020-06-17  6:30 ` jerinj
  2020-06-21  9:52   ` Sachin Saxena (OSS)
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 12/13] drivers/baseband: " jerinj
                   ` (3 subsequent siblings)
  14 siblings, 1 reply; 98+ messages in thread
From: jerinj @ 2020-06-17  6:30 UTC (permalink / raw)
  To: dev, Hemant Agrawal, Sachin Saxena, Rosen Xu, Stephen Hemminger
  Cc: thomas, olivier.matz, david.marchand, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
---
 drivers/bus/dpaa/dpaa_bus.c      | 10 +---------
 drivers/bus/fslmc/fslmc_bus.c    | 11 +----------
 drivers/bus/ifpga/ifpga_bus.c    |  9 +--------
 drivers/bus/vdev/vdev.c          | 10 +---------
 drivers/bus/vmbus/vmbus_common.c |  9 +--------
 5 files changed, 5 insertions(+), 44 deletions(-)

diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c
index d53fe6083..0d8b13e5f 100644
--- a/drivers/bus/dpaa/dpaa_bus.c
+++ b/drivers/bus/dpaa/dpaa_bus.c
@@ -42,8 +42,6 @@
 #include <fsl_bman.h>
 #include <netcfg.h>
 
-int dpaa_logtype_bus;
-
 static struct rte_dpaa_bus rte_dpaa_bus;
 struct netcfg_info *dpaa_netcfg;
 
@@ -749,10 +747,4 @@ static struct rte_dpaa_bus rte_dpaa_bus = {
 };
 
 RTE_REGISTER_BUS(FSL_DPAA_BUS_NAME, rte_dpaa_bus.bus);
-
-RTE_INIT(dpaa_init_log)
-{
-	dpaa_logtype_bus = rte_log_register("bus.dpaa");
-	if (dpaa_logtype_bus >= 0)
-		rte_log_set_level(dpaa_logtype_bus, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa_logtype_bus, bus.dpaa, NOTICE);
diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
index afbd82e8d..d9f403bd9 100644
--- a/drivers/bus/fslmc/fslmc_bus.c
+++ b/drivers/bus/fslmc/fslmc_bus.c
@@ -21,8 +21,6 @@
 
 #include <dpaax_iova_table.h>
 
-int dpaa2_logtype_bus;
-
 #define VFIO_IOMMU_GROUP_PATH "/sys/kernel/iommu_groups"
 #define FSLMC_BUS_NAME	fslmc
 
@@ -649,11 +647,4 @@ struct rte_fslmc_bus rte_fslmc_bus = {
 };
 
 RTE_REGISTER_BUS(FSLMC_BUS_NAME, rte_fslmc_bus.bus);
-
-RTE_INIT(fslmc_init_log)
-{
-	/* Bus level logs */
-	dpaa2_logtype_bus = rte_log_register("bus.fslmc");
-	if (dpaa2_logtype_bus >= 0)
-		rte_log_set_level(dpaa2_logtype_bus, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa2_logtype_bus, bus.fslmc, NOTICE);
diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c
index addbc3e86..103915d43 100644
--- a/drivers/bus/ifpga/ifpga_bus.c
+++ b/drivers/bus/ifpga/ifpga_bus.c
@@ -32,7 +32,6 @@
 #include "ifpga_logs.h"
 #include "ifpga_common.h"
 
-int ifpga_bus_logtype;
 
 /* Forward declaration to access Intel FPGA bus
  * on which iFPGA devices are connected
@@ -474,10 +473,4 @@ static struct rte_bus rte_ifpga_bus = {
 };
 
 RTE_REGISTER_BUS(IFPGA_BUS_NAME, rte_ifpga_bus);
-
-RTE_INIT(ifpga_init_log)
-{
-	ifpga_bus_logtype = rte_log_register("bus.ifpga");
-	if (ifpga_bus_logtype >= 0)
-		rte_log_set_level(ifpga_bus_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(ifpga_bus_logtype, bus.ifpga, NOTICE);
diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index a89ea2353..d746149a2 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -27,8 +27,6 @@
 
 #define VDEV_MP_KEY	"bus_vdev_mp"
 
-int vdev_logtype_bus;
-
 /* Forward declare to access virtual bus name */
 static struct rte_bus rte_vdev_bus;
 
@@ -557,10 +555,4 @@ static struct rte_bus rte_vdev_bus = {
 };
 
 RTE_REGISTER_BUS(vdev, rte_vdev_bus);
-
-RTE_INIT(vdev_init_log)
-{
-	vdev_logtype_bus = rte_log_register("bus.vdev");
-	if (vdev_logtype_bus >= 0)
-		rte_log_set_level(vdev_logtype_bus, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(vdev_logtype_bus, bus.vdev, NOTICE);
diff --git a/drivers/bus/vmbus/vmbus_common.c b/drivers/bus/vmbus/vmbus_common.c
index 3adef01c9..4c9ac33ac 100644
--- a/drivers/bus/vmbus/vmbus_common.c
+++ b/drivers/bus/vmbus/vmbus_common.c
@@ -22,7 +22,6 @@
 
 #include "private.h"
 
-int vmbus_logtype_bus;
 extern struct rte_vmbus_bus rte_vmbus_bus;
 
 /* map a particular resource from a file */
@@ -298,10 +297,4 @@ struct rte_vmbus_bus rte_vmbus_bus = {
 };
 
 RTE_REGISTER_BUS(vmbus, rte_vmbus_bus.bus);
-
-RTE_INIT(vmbus_init_log)
-{
-	vmbus_logtype_bus = rte_log_register("bus.vmbus");
-	if (vmbus_logtype_bus >= 0)
-		rte_log_set_level(vmbus_logtype_bus, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(vmbus_logtype_bus, bus.vmbus, NOTICE);
-- 
2.26.2


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

* [dpdk-dev] [PATCH 12/13] drivers/baseband: use log register macro
  2020-06-17  6:30 [dpdk-dev] [PATCH 00/13] rte_log registration usage improvement jerinj
                   ` (10 preceding siblings ...)
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 11/13] drivers/bus: " jerinj
@ 2020-06-17  6:30 ` jerinj
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 13/13] app/test: " jerinj
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-06-17  6:30 UTC (permalink / raw)
  To: dev, Nicolas Chautru; +Cc: thomas, olivier.matz, david.marchand, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
---
 .../baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 17 +++++------------
 drivers/baseband/fpga_lte_fec/fpga_lte_fec.c   | 18 +++++-------------
 drivers/baseband/null/bbdev_null.c             |  9 +--------
 .../baseband/turbo_sw/bbdev_turbo_software.c   |  9 +--------
 4 files changed, 12 insertions(+), 41 deletions(-)

diff --git a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
index e152b206e..aca0ca999 100644
--- a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
+++ b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
@@ -23,8 +23,11 @@
 #include "fpga_5gnr_fec.h"
 #include "rte_pmd_fpga_5gnr_fec.h"
 
-/* 5GNR SW PMD logging ID */
-static int fpga_5gnr_fec_logtype;
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+RTE_LOG_REGISTER(fpga_5gnr_fec_logtype, pmd.bb.fpga_5gnr_fec, DEBUG);
+#else
+RTE_LOG_REGISTER(fpga_5gnr_fec_logtype, pmd.bb.fpga_5gnr_fec, NOTICE);
+#endif
 
 #ifdef RTE_LIBRTE_BBDEV_DEBUG
 
@@ -2175,13 +2178,3 @@ RTE_PMD_REGISTER_PCI(FPGA_5GNR_FEC_VF_DRIVER_NAME, fpga_5gnr_fec_pci_vf_driver);
 RTE_PMD_REGISTER_PCI_TABLE(FPGA_5GNR_FEC_VF_DRIVER_NAME,
 		pci_id_fpga_5gnr_fec_vf_map);
 
-RTE_INIT(fpga_5gnr_fec_init_log)
-{
-	fpga_5gnr_fec_logtype = rte_log_register("pmd.bb.fpga_5gnr_fec");
-	if (fpga_5gnr_fec_logtype >= 0)
-#ifdef RTE_LIBRTE_BBDEV_DEBUG
-		rte_log_set_level(fpga_5gnr_fec_logtype, RTE_LOG_DEBUG);
-#else
-		rte_log_set_level(fpga_5gnr_fec_logtype, RTE_LOG_NOTICE);
-#endif
-}
diff --git a/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c b/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c
index abc5a1bf6..6be9131e7 100644
--- a/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c
+++ b/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c
@@ -22,8 +22,11 @@
 
 #include "fpga_lte_fec.h"
 
-/* Turbo SW PMD logging ID */
-static int fpga_lte_fec_logtype;
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+RTE_LOG_REGISTER(fpga_lte_fec_logtype, pmd.bb.fpga_lte_fec, DEBUG);
+#else
+RTE_LOG_REGISTER(fpga_lte_fec_logtype, pmd.bb.fpga_lte_fec, NOTICE);
+#endif
 
 /* Helper macro for logging */
 #define rte_bbdev_log(level, fmt, ...) \
@@ -2662,14 +2665,3 @@ RTE_PMD_REGISTER_PCI_TABLE(FPGA_LTE_FEC_PF_DRIVER_NAME,
 RTE_PMD_REGISTER_PCI(FPGA_LTE_FEC_VF_DRIVER_NAME, fpga_lte_fec_pci_vf_driver);
 RTE_PMD_REGISTER_PCI_TABLE(FPGA_LTE_FEC_VF_DRIVER_NAME,
 		pci_id_fpga_lte_fec_vf_map);
-
-RTE_INIT(fpga_lte_fec_init_log)
-{
-	fpga_lte_fec_logtype = rte_log_register("pmd.bb.fpga_lte_fec");
-	if (fpga_lte_fec_logtype >= 0)
-#ifdef RTE_LIBRTE_BBDEV_DEBUG
-		rte_log_set_level(fpga_lte_fec_logtype, RTE_LOG_DEBUG);
-#else
-		rte_log_set_level(fpga_lte_fec_logtype, RTE_LOG_NOTICE);
-#endif
-}
diff --git a/drivers/baseband/null/bbdev_null.c b/drivers/baseband/null/bbdev_null.c
index 2f2515101..dd11cd31c 100644
--- a/drivers/baseband/null/bbdev_null.c
+++ b/drivers/baseband/null/bbdev_null.c
@@ -15,8 +15,7 @@
 
 #define DRIVER_NAME baseband_null
 
-/* NULL BBDev logging ID */
-static int bbdev_null_logtype;
+RTE_LOG_REGISTER(bbdev_null_logtype, pmd.bb.null, NOTICE);
 
 /* Helper macro for logging */
 #define rte_bbdev_log(level, fmt, ...) \
@@ -348,9 +347,3 @@ RTE_PMD_REGISTER_PARAM_STRING(DRIVER_NAME,
 	BBDEV_NULL_SOCKET_ID_ARG"=<int>");
 RTE_PMD_REGISTER_ALIAS(DRIVER_NAME, bbdev_null);
 
-RTE_INIT(null_bbdev_init_log)
-{
-	bbdev_null_logtype = rte_log_register("pmd.bb.null");
-	if (bbdev_null_logtype >= 0)
-		rte_log_set_level(bbdev_null_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/baseband/turbo_sw/bbdev_turbo_software.c b/drivers/baseband/turbo_sw/bbdev_turbo_software.c
index bb62276b9..daecfd21a 100644
--- a/drivers/baseband/turbo_sw/bbdev_turbo_software.c
+++ b/drivers/baseband/turbo_sw/bbdev_turbo_software.c
@@ -34,8 +34,7 @@
 
 #define DRIVER_NAME baseband_turbo_sw
 
-/* Turbo SW PMD logging ID */
-static int bbdev_turbo_sw_logtype;
+RTE_LOG_REGISTER(bbdev_turbo_sw_logtype, pmd.bb.turbo_sw, NOTICE);
 
 /* Helper macro for logging */
 #define rte_bbdev_log(level, fmt, ...) \
@@ -1991,9 +1990,3 @@ RTE_PMD_REGISTER_PARAM_STRING(DRIVER_NAME,
 	TURBO_SW_SOCKET_ID_ARG"=<int>");
 RTE_PMD_REGISTER_ALIAS(DRIVER_NAME, turbo_sw);
 
-RTE_INIT(turbo_sw_bbdev_init_log)
-{
-	bbdev_turbo_sw_logtype = rte_log_register("pmd.bb.turbo_sw");
-	if (bbdev_turbo_sw_logtype >= 0)
-		rte_log_set_level(bbdev_turbo_sw_logtype, RTE_LOG_NOTICE);
-}
-- 
2.26.2


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

* [dpdk-dev]  [PATCH 13/13] app/test: use log register macro
  2020-06-17  6:30 [dpdk-dev] [PATCH 00/13] rte_log registration usage improvement jerinj
                   ` (11 preceding siblings ...)
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 12/13] drivers/baseband: " jerinj
@ 2020-06-17  6:30 ` jerinj
  2020-06-25 16:18 ` [dpdk-dev] [PATCH 00/13] rte_log registration usage improvement Dybkowski, AdamX
  2020-07-01  3:58 ` [dpdk-dev] [PATCH v2 " jerinj
  14 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-06-17  6:30 UTC (permalink / raw)
  To: dev, Byron Marohn, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Robert Sanford, Erik Gabriel Carrillo
  Cc: thomas, olivier.matz, david.marchand, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
---
 app/test/test_efd.c            | 6 +-----
 app/test/test_hash.c           | 7 +------
 app/test/test_timer_racecond.c | 7 +------
 3 files changed, 3 insertions(+), 17 deletions(-)

diff --git a/app/test/test_efd.c b/app/test/test_efd.c
index e3e5e30ea..3d9aa8a57 100644
--- a/app/test/test_efd.c
+++ b/app/test/test_efd.c
@@ -32,12 +32,8 @@ struct flow_key {
 	uint8_t proto;
 } __rte_packed;
 
-int efd_logtype_test;
 
-RTE_INIT(test_efd_init_log)
-{
-	efd_logtype_test = rte_log_register("test.efd");
-}
+RTE_LOG_REGISTER(efd_logtype_test, test.efd, INFO);
 
 /*
  * Print out result of unit test efd operation.
diff --git a/app/test/test_hash.c b/app/test/test_hash.c
index afa3a1a3c..990a1815f 100644
--- a/app/test/test_hash.c
+++ b/app/test/test_hash.c
@@ -69,8 +69,6 @@ struct flow_key {
 	uint8_t proto;
 } __rte_packed;
 
-int hash_logtype_test;
-
 /*
  * Hash function that always returns the same value, to easily test what
  * happens when a bucket is full.
@@ -82,10 +80,7 @@ static uint32_t pseudo_hash(__rte_unused const void *keys,
 	return 3;
 }
 
-RTE_INIT(test_hash_init_log)
-{
-	hash_logtype_test = rte_log_register("test.hash");
-}
+RTE_LOG_REGISTER(hash_logtype_test, test.hash, INFO);
 
 /*
  * Print out result of unit test hash operation.
diff --git a/app/test/test_timer_racecond.c b/app/test/test_timer_racecond.c
index 4fc917995..28af9ca76 100644
--- a/app/test/test_timer_racecond.c
+++ b/app/test/test_timer_racecond.c
@@ -61,12 +61,7 @@ static volatile unsigned stop_slaves;
 
 static int reload_timer(struct rte_timer *tim);
 
-int timer_logtype_test;
-
-RTE_INIT(test_timer_init_log)
-{
-	timer_logtype_test = rte_log_register("test.timer");
-}
+RTE_LOG_REGISTER(timer_logtype_test, test.timer, INFO);
 
 static void
 timer_cb(struct rte_timer *tim, void *arg __rte_unused)
-- 
2.26.2


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

* Re: [dpdk-dev] [PATCH 01/13] eal/log: introduce log register macro
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 01/13] eal/log: introduce log register macro jerinj
@ 2020-06-17 10:00   ` Thomas Monjalon
  2020-06-17 10:26     ` Andrew Rybchenko
  2020-06-17 10:02   ` David Marchand
  2020-06-21  9:30   ` Sachin Saxena (OSS)
  2 siblings, 1 reply; 98+ messages in thread
From: Thomas Monjalon @ 2020-06-17 10:00 UTC (permalink / raw)
  To: Jerin Jacob; +Cc: dev, olivier.matz, david.marchand, arybchenko

17/06/2020 08:30, jerinj@marvell.com:
> From: Jerin Jacob <jerinj@marvell.com>
> 
> Introducing the RTE_LOG_REGISTER macro to avoid the code duplication
> in the log registration process.
> 
> It is a wrapper macro for declaring the logtype, register the log and sets
> it's level in the constructor context.
> 
> Signed-off-by: Jerin Jacob <jerinj@marvell.com>
> ---
> --- a/lib/librte_eal/include/rte_log.h
> +++ b/lib/librte_eal/include/rte_log.h
> +#define RTE_LOG_REGISTER(type, name, level)			\
> +int type;							\
> +RTE_INIT(__##type)						\
> +{								\
> +	type = rte_log_register(RTE_STR(name));			\
> +	if (type >= 0)						\
> +		rte_log_set_level(type, RTE_LOG_##level);	\
> +}

It should use rte_log_register_type_and_pick_level()
which works for drivers loaded later in the init sequence.

rte_log_register() should be deprecated.




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

* Re: [dpdk-dev] [PATCH 01/13] eal/log: introduce log register macro
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 01/13] eal/log: introduce log register macro jerinj
  2020-06-17 10:00   ` Thomas Monjalon
@ 2020-06-17 10:02   ` David Marchand
  2020-06-17 10:21     ` Andrew Rybchenko
  2020-06-21  9:30   ` Sachin Saxena (OSS)
  2 siblings, 1 reply; 98+ messages in thread
From: David Marchand @ 2020-06-17 10:02 UTC (permalink / raw)
  To: Jerin Jacob Kollanukkaran; +Cc: dev, Thomas Monjalon, Olivier Matz

On Wed, Jun 17, 2020 at 8:30 AM <jerinj@marvell.com> wrote:
>
> From: Jerin Jacob <jerinj@marvell.com>
>
> Introducing the RTE_LOG_REGISTER macro to avoid the code duplication
> in the log registration process.
>
> It is a wrapper macro for declaring the logtype, register the log and sets

Having the logtype variable declared as part of the macro will force
us to have global symbols (for the cases where it is needed).
I'd rather leave the declaration to the caller, and only handle the
registering part in this macro.

> it's level in the constructor context.
>


-- 
David Marchand


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

* Re: [dpdk-dev] [PATCH 01/13] eal/log: introduce log register macro
  2020-06-17 10:02   ` David Marchand
@ 2020-06-17 10:21     ` Andrew Rybchenko
  2020-06-24 13:11       ` Jerin Jacob
  0 siblings, 1 reply; 98+ messages in thread
From: Andrew Rybchenko @ 2020-06-17 10:21 UTC (permalink / raw)
  To: David Marchand, Jerin Jacob Kollanukkaran
  Cc: dev, Thomas Monjalon, Olivier Matz

On 6/17/20 1:02 PM, David Marchand wrote:
> On Wed, Jun 17, 2020 at 8:30 AM <jerinj@marvell.com> wrote:
>>
>> From: Jerin Jacob <jerinj@marvell.com>
>>
>> Introducing the RTE_LOG_REGISTER macro to avoid the code duplication
>> in the log registration process.
>>
>> It is a wrapper macro for declaring the logtype, register the log and sets
> 
> Having the logtype variable declared as part of the macro will force
> us to have global symbols (for the cases where it is needed).
> I'd rather leave the declaration to the caller, and only handle the
> registering part in this macro.

I agree with David that it is important to avoid global symbols
when it is not needed.

>> it's level in the constructor context.
>>
> 
> 


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

* Re: [dpdk-dev] [PATCH 01/13] eal/log: introduce log register macro
  2020-06-17 10:00   ` Thomas Monjalon
@ 2020-06-17 10:26     ` Andrew Rybchenko
  2020-06-24 13:08       ` Jerin Jacob
  0 siblings, 1 reply; 98+ messages in thread
From: Andrew Rybchenko @ 2020-06-17 10:26 UTC (permalink / raw)
  To: Thomas Monjalon, Jerin Jacob; +Cc: dev, olivier.matz, david.marchand

On 6/17/20 1:00 PM, Thomas Monjalon wrote:
> 17/06/2020 08:30, jerinj@marvell.com:
>> From: Jerin Jacob <jerinj@marvell.com>
>>
>> Introducing the RTE_LOG_REGISTER macro to avoid the code duplication
>> in the log registration process.
>>
>> It is a wrapper macro for declaring the logtype, register the log and sets
>> it's level in the constructor context.
>>
>> Signed-off-by: Jerin Jacob <jerinj@marvell.com>
>> ---
>> --- a/lib/librte_eal/include/rte_log.h
>> +++ b/lib/librte_eal/include/rte_log.h
>> +#define RTE_LOG_REGISTER(type, name, level)			\
>> +int type;							\
>> +RTE_INIT(__##type)						\
>> +{								\
>> +	type = rte_log_register(RTE_STR(name));			\
>> +	if (type >= 0)						\
>> +		rte_log_set_level(type, RTE_LOG_##level);	\
>> +}
> 
> It should use rte_log_register_type_and_pick_level()
> which works for drivers loaded later in the init sequence.

Yes, rte_log_register_type_and_pick_level() should be used.
Otherwise, if a driver is loaded (the constructor is called)
after --log-level options processing, the level set using
the option is not applied.

> rte_log_register() should be deprecated.

+1


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

* Re: [dpdk-dev] [PATCH 01/13] eal/log: introduce log register macro
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 01/13] eal/log: introduce log register macro jerinj
  2020-06-17 10:00   ` Thomas Monjalon
  2020-06-17 10:02   ` David Marchand
@ 2020-06-21  9:30   ` Sachin Saxena (OSS)
  2 siblings, 0 replies; 98+ messages in thread
From: Sachin Saxena (OSS) @ 2020-06-21  9:30 UTC (permalink / raw)
  To: jerinj, dev; +Cc: thomas, olivier.matz, david.marchand

On 17-Jun-20 12:00 PM, jerinj@marvell.com wrote:
> From: Jerin Jacob <jerinj@marvell.com>
>
> Introducing the RTE_LOG_REGISTER macro to avoid the code duplication
> in the log registration process.
>
> It is a wrapper macro for declaring the logtype, register the log and sets
> it's level in the constructor context.
>
> Signed-off-by: Jerin Jacob <jerinj@marvell.com>
> ---
>   lib/librte_eal/include/rte_log.h | 25 +++++++++++++++++++++++++
>   1 file changed, 25 insertions(+)
>
> diff --git a/lib/librte_eal/include/rte_log.h b/lib/librte_eal/include/rte_log.h
> index 1789ede56..4dc357074 100644
> --- a/lib/librte_eal/include/rte_log.h
> +++ b/lib/librte_eal/include/rte_log.h
> @@ -376,6 +376,31 @@ int rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap)
>   		 RTE_LOGTYPE_ ## t, # t ": " __VA_ARGS__) :	\
>   	 0)
>   
> +/**
> + * @warning
> + * @b EXPERIMENTAL: this API may change without prior notice
> + *
> + * Register a dynamic log type in constructor context with its name and level.
> + *
> + * It is a wrapper macro for declaring the logtype, register the log and sets
> + * it's level in the constructor context.
> + *
> + * @param type
> + *   The log type identifier
> + * @param name
> + *    Name for the log type to be registered
> + * @param level
> + *   Log level. A value between EMERG (1) and DEBUG (8).
> + */
> +#define RTE_LOG_REGISTER(type, name, level)			\
> +int type;							\
> +RTE_INIT(__##type)						\
> +{								\
> +	type = rte_log_register(RTE_STR(name));			\
> +	if (type >= 0)						\
> +		rte_log_set_level(type, RTE_LOG_##level);	\
> +}
> +
>   #ifdef __cplusplus
>   }
>   #endif
Do we like to add some way of notifying the driver (may be simple print) 
regarding failure case of "rte_log_*" API?

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

* Re: [dpdk-dev] [PATCH 06/13] drivers/mempool: use log register macro
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 06/13] drivers/mempool: " jerinj
@ 2020-06-21  9:46   ` Sachin Saxena (OSS)
  0 siblings, 0 replies; 98+ messages in thread
From: Sachin Saxena (OSS) @ 2020-06-21  9:46 UTC (permalink / raw)
  To: jerinj, dev

Acked-by: Sachin Saxena<sachin.saxena@oss.nxp.com>


On 17-Jun-20 12:00 PM, jerinj@marvell.com wrote:
> From: Jerin Jacob <jerinj@marvell.com>
>
> Use log register macro to avoid the code duplication
> in the log registration process.
>
> Signed-off-by: Jerin Jacob <jerinj@marvell.com>
> ---
>   drivers/mempool/dpaa/dpaa_mempool.c       | 10 ++--------
>   drivers/mempool/dpaa2/dpaa2_hw_mempool.c  | 10 +---------
>   drivers/mempool/octeontx/octeontx_fpavf.c | 10 +---------
>   3 files changed, 4 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/mempool/dpaa/dpaa_mempool.c b/drivers/mempool/dpaa/dpaa_mempool.c
> index 451e2d5d5..8d1da8028 100644
> --- a/drivers/mempool/dpaa/dpaa_mempool.c
> +++ b/drivers/mempool/dpaa/dpaa_mempool.c
> @@ -36,7 +36,8 @@ struct dpaa_memseg_list rte_dpaa_memsegs
>   	= TAILQ_HEAD_INITIALIZER(rte_dpaa_memsegs);
>   
>   struct dpaa_bp_info *rte_dpaa_bpid_info;
> -int dpaa_logtype_mempool;
> +
> +RTE_LOG_REGISTER(dpaa_logtype_mempool, mempool.dpaa, NOTICE);
>   
>   static int
>   dpaa_mbuf_create_pool(struct rte_mempool *mp)
> @@ -357,10 +358,3 @@ static const struct rte_mempool_ops dpaa_mpool_ops = {
>   };
>   
>   MEMPOOL_REGISTER_OPS(dpaa_mpool_ops);
> -
> -RTE_INIT(dpaa_mp_init_log)
> -{
> -	dpaa_logtype_mempool = rte_log_register("mempool.dpaa");
> -	if (dpaa_logtype_mempool >= 0)
> -		rte_log_set_level(dpaa_logtype_mempool, RTE_LOG_NOTICE);
> -}
> diff --git a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
> index fa9b53e64..97ce08d78 100644
> --- a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
> +++ b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
> @@ -36,9 +36,6 @@
>   struct dpaa2_bp_info *rte_dpaa2_bpid_info;
>   static struct dpaa2_bp_list *h_bp_list;
>   
> -/* Dynamic logging identified for mempool */
> -int dpaa2_logtype_mempool;
> -
>   static int
>   rte_hw_mbuf_create_pool(struct rte_mempool *mp)
>   {
> @@ -454,9 +451,4 @@ static const struct rte_mempool_ops dpaa2_mpool_ops = {
>   
>   MEMPOOL_REGISTER_OPS(dpaa2_mpool_ops);
>   
> -RTE_INIT(dpaa2_mempool_init_log)
> -{
> -	dpaa2_logtype_mempool = rte_log_register("mempool.dpaa2");
> -	if (dpaa2_logtype_mempool >= 0)
> -		rte_log_set_level(dpaa2_logtype_mempool, RTE_LOG_NOTICE);
> -}
> +RTE_LOG_REGISTER(dpaa2_logtype_mempool, mempool.dpaa2, NOTICE);
> diff --git a/drivers/mempool/octeontx/octeontx_fpavf.c b/drivers/mempool/octeontx/octeontx_fpavf.c
> index 0ff234913..339da7824 100644
> --- a/drivers/mempool/octeontx/octeontx_fpavf.c
> +++ b/drivers/mempool/octeontx/octeontx_fpavf.c
> @@ -105,15 +105,7 @@ struct octeontx_fpadev {
>   
>   static struct octeontx_fpadev fpadev;
>   
> -int octeontx_logtype_fpavf;
> -int octeontx_logtype_fpavf_mbox;
> -
> -RTE_INIT(otx_pool_init_log)
> -{
> -	octeontx_logtype_fpavf = rte_log_register("pmd.mempool.octeontx");
> -	if (octeontx_logtype_fpavf >= 0)
> -		rte_log_set_level(octeontx_logtype_fpavf, RTE_LOG_NOTICE);
> -}
> +RTE_LOG_REGISTER(octeontx_logtype_fpavf, pmd.mempool.octeontx, NOTICE);
>   
>   /* lock is taken by caller */
>   static int


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

* Re: [dpdk-dev] [PATCH 10/13] drivers/common: use log register macro
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 10/13] drivers/common: " jerinj
@ 2020-06-21  9:48   ` Sachin Saxena (OSS)
  0 siblings, 0 replies; 98+ messages in thread
From: Sachin Saxena (OSS) @ 2020-06-21  9:48 UTC (permalink / raw)
  To: jerinj, dev, Hemant Agrawal

Acked-by: Sachin Saxena<sachin.saxena@oss.nxp.com>


On 17-Jun-20 12:00 PM, jerinj@marvell.com wrote:
> From: Jerin Jacob <jerinj@marvell.com>
>
> Use log register macro to avoid the code duplication
> in the log registration process.
>
> Signed-off-by: Jerin Jacob <jerinj@marvell.com>
> ---
>   drivers/common/dpaax/dpaax_iova_table.c | 10 +--
>   drivers/common/iavf/iavf_impl.c         |  9 +--
>   drivers/common/octeontx/octeontx_mbox.c |  9 +--
>   drivers/common/octeontx2/otx2_common.c  | 96 +++----------------------
>   drivers/common/qat/qat_logs.c           | 17 +----
>   5 files changed, 15 insertions(+), 126 deletions(-)
>
> diff --git a/drivers/common/dpaax/dpaax_iova_table.c b/drivers/common/dpaax/dpaax_iova_table.c
> index 98b076e09..5ba8ed193 100644
> --- a/drivers/common/dpaax/dpaax_iova_table.c
> +++ b/drivers/common/dpaax/dpaax_iova_table.c
> @@ -7,9 +7,6 @@
>   #include "dpaax_iova_table.h"
>   #include "dpaax_logs.h"
>   
> -/* Global dpaax logger identifier */
> -int dpaax_logger;
> -
>   /* Global table reference */
>   struct dpaax_iova_table *dpaax_iova_table_p;
>   
> @@ -463,9 +460,4 @@ dpaax_handle_memevents(void)
>   					       dpaax_memevent_cb, NULL);
>   }
>   
> -RTE_INIT(dpaax_log)
> -{
> -	dpaax_logger = rte_log_register("pmd.common.dpaax");
> -	if (dpaax_logger >= 0)
> -		rte_log_set_level(dpaax_logger, RTE_LOG_ERR);
> -}
> +RTE_LOG_REGISTER(dpaax_logger, pmd.common.dpaax, ERR);
> diff --git a/drivers/common/iavf/iavf_impl.c b/drivers/common/iavf/iavf_impl.c
> index 6174a9144..fc0da3175 100644
> --- a/drivers/common/iavf/iavf_impl.c
> +++ b/drivers/common/iavf/iavf_impl.c
> @@ -13,8 +13,6 @@
>   #include "iavf_type.h"
>   #include "iavf_prototype.h"
>   
> -int iavf_common_logger;
> -
>   enum iavf_status
>   iavf_allocate_dma_mem_d(__rte_unused struct iavf_hw *hw,
>   			struct iavf_dma_mem *mem,
> @@ -87,9 +85,4 @@ iavf_free_virt_mem_d(__rte_unused struct iavf_hw *hw,
>   	return IAVF_SUCCESS;
>   }
>   
> -RTE_INIT(iavf_common_init_log)
> -{
> -	iavf_common_logger = rte_log_register("pmd.common.iavf");
> -	if (iavf_common_logger >= 0)
> -		rte_log_set_level(iavf_common_logger, RTE_LOG_NOTICE);
> -}
> +RTE_LOG_REGISTER(iavf_common_logger, pmd.common.iavf, NOTICE);
> diff --git a/drivers/common/octeontx/octeontx_mbox.c b/drivers/common/octeontx/octeontx_mbox.c
> index effe0b267..f414267e4 100644
> --- a/drivers/common/octeontx/octeontx_mbox.c
> +++ b/drivers/common/octeontx/octeontx_mbox.c
> @@ -68,14 +68,7 @@ struct mbox_intf_ver {
>   	uint32_t minor:10;
>   };
>   
> -int octeontx_logtype_mbox;
> -
> -RTE_INIT(otx_init_log)
> -{
> -	octeontx_logtype_mbox = rte_log_register("pmd.octeontx.mbox");
> -	if (octeontx_logtype_mbox >= 0)
> -		rte_log_set_level(octeontx_logtype_mbox, RTE_LOG_NOTICE);
> -}
> +RTE_LOG_REGISTER(octeontx_logtype_mbox, pmd.octeontx.mbox, NOTICE);
>   
>   static inline void
>   mbox_msgcpy(volatile uint8_t *d, volatile const uint8_t *s, uint16_t size)
> diff --git a/drivers/common/octeontx2/otx2_common.c b/drivers/common/octeontx2/otx2_common.c
> index 5e7272f69..b292e999a 100644
> --- a/drivers/common/octeontx2/otx2_common.c
> +++ b/drivers/common/octeontx2/otx2_common.c
> @@ -203,89 +203,13 @@ void otx2_parse_common_devargs(struct rte_kvargs *kvlist)
>   	idev->npa_lock_mask = npa_lock_mask;
>   }
>   
> -/**
> - * @internal
> - */
> -int otx2_logtype_base;
> -/**
> - * @internal
> - */
> -int otx2_logtype_mbox;
> -/**
> - * @internal
> - */
> -int otx2_logtype_npa;
> -/**
> - * @internal
> - */
> -int otx2_logtype_nix;
> -/**
> - * @internal
> - */
> -int otx2_logtype_npc;
> -/**
> - * @internal
> - */
> -int otx2_logtype_tm;
> -/**
> - * @internal
> - */
> -int otx2_logtype_sso;
> -/**
> - * @internal
> - */
> -int otx2_logtype_tim;
> -/**
> - * @internal
> - */
> -int otx2_logtype_dpi;
> -/**
> - * @internal
> - */
> -int otx2_logtype_ep;
> -
> -RTE_INIT(otx2_log_init);
> -static void
> -otx2_log_init(void)
> -{
> -	otx2_logtype_base = rte_log_register("pmd.octeontx2.base");
> -	if (otx2_logtype_base >= 0)
> -		rte_log_set_level(otx2_logtype_base, RTE_LOG_NOTICE);
> -
> -	otx2_logtype_mbox = rte_log_register("pmd.octeontx2.mbox");
> -	if (otx2_logtype_mbox >= 0)
> -		rte_log_set_level(otx2_logtype_mbox, RTE_LOG_NOTICE);
> -
> -	otx2_logtype_npa = rte_log_register("pmd.mempool.octeontx2");
> -	if (otx2_logtype_npa >= 0)
> -		rte_log_set_level(otx2_logtype_npa, RTE_LOG_NOTICE);
> -
> -	otx2_logtype_nix = rte_log_register("pmd.net.octeontx2");
> -	if (otx2_logtype_nix >= 0)
> -		rte_log_set_level(otx2_logtype_nix, RTE_LOG_NOTICE);
> -
> -	otx2_logtype_npc = rte_log_register("pmd.net.octeontx2.flow");
> -	if (otx2_logtype_npc >= 0)
> -		rte_log_set_level(otx2_logtype_npc, RTE_LOG_NOTICE);
> -
> -	otx2_logtype_tm = rte_log_register("pmd.net.octeontx2.tm");
> -	if (otx2_logtype_tm >= 0)
> -		rte_log_set_level(otx2_logtype_tm, RTE_LOG_NOTICE);
> -
> -	otx2_logtype_sso = rte_log_register("pmd.event.octeontx2");
> -	if (otx2_logtype_sso >= 0)
> -		rte_log_set_level(otx2_logtype_sso, RTE_LOG_NOTICE);
> -
> -	otx2_logtype_tim = rte_log_register("pmd.event.octeontx2.timer");
> -	if (otx2_logtype_tim >= 0)
> -		rte_log_set_level(otx2_logtype_tim, RTE_LOG_NOTICE);
> -
> -	otx2_logtype_dpi = rte_log_register("pmd.raw.octeontx2.dpi");
> -	if (otx2_logtype_dpi >= 0)
> -		rte_log_set_level(otx2_logtype_dpi, RTE_LOG_NOTICE);
> -
> -	otx2_logtype_ep = rte_log_register("pmd.raw.octeontx2.ep");
> -	if (otx2_logtype_ep >= 0)
> -		rte_log_set_level(otx2_logtype_ep, RTE_LOG_NOTICE);
> -
> -}
> +RTE_LOG_REGISTER(otx2_logtype_base, pmd.octeontx2.base, NOTICE);
> +RTE_LOG_REGISTER(otx2_logtype_mbox, pmd.octeontx2.mbox, NOTICE);
> +RTE_LOG_REGISTER(otx2_logtype_npa, pmd.mempool.octeontx2, NOTICE);
> +RTE_LOG_REGISTER(otx2_logtype_nix, pmd.net.octeontx2, NOTICE);
> +RTE_LOG_REGISTER(otx2_logtype_npc, pmd.net.octeontx2.flow, NOTICE);
> +RTE_LOG_REGISTER(otx2_logtype_tm, pmd.net.octeontx2.tm, NOTICE);
> +RTE_LOG_REGISTER(otx2_logtype_sso, pmd.event.octeontx2, NOTICE);
> +RTE_LOG_REGISTER(otx2_logtype_tim, pmd.event.octeontx2.timer, NOTICE);
> +RTE_LOG_REGISTER(otx2_logtype_dpi, pmd.raw.octeontx2.dpi, NOTICE);
> +RTE_LOG_REGISTER(otx2_logtype_ep, pmd.raw.octeontx2.ep, NOTICE);
> diff --git a/drivers/common/qat/qat_logs.c b/drivers/common/qat/qat_logs.c
> index dfd0cbe5d..fa48be53c 100644
> --- a/drivers/common/qat/qat_logs.c
> +++ b/drivers/common/qat/qat_logs.c
> @@ -7,9 +7,6 @@
>   
>   #include "qat_logs.h"
>   
> -int qat_gen_logtype;
> -int qat_dp_logtype;
> -
>   int
>   qat_hexdump_log(uint32_t level, uint32_t logtype, const char *title,
>   		const void *buf, unsigned int len)
> @@ -20,15 +17,5 @@ qat_hexdump_log(uint32_t level, uint32_t logtype, const char *title,
>   	return 0;
>   }
>   
> -RTE_INIT(qat_pci_init_log)
> -{
> -	/* Non-data-path logging for pci device and all services */
> -	qat_gen_logtype = rte_log_register("pmd.qat_general");
> -	if (qat_gen_logtype >= 0)
> -		rte_log_set_level(qat_gen_logtype, RTE_LOG_NOTICE);
> -
> -	/* data-path logging for all services */
> -	qat_dp_logtype = rte_log_register("pmd.qat_dp");
> -	if (qat_dp_logtype >= 0)
> -		rte_log_set_level(qat_dp_logtype, RTE_LOG_NOTICE);
> -}
> +RTE_LOG_REGISTER(qat_gen_logtype, pmd.qat_general, NOTICE);
> +RTE_LOG_REGISTER(qat_dp_logtype, pmd.qat_dp, NOTICE);


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

* Re: [dpdk-dev] [PATCH 11/13] drivers/bus: use log register macro
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 11/13] drivers/bus: " jerinj
@ 2020-06-21  9:52   ` Sachin Saxena (OSS)
  0 siblings, 0 replies; 98+ messages in thread
From: Sachin Saxena (OSS) @ 2020-06-21  9:52 UTC (permalink / raw)
  To: jerinj, dev, Hemant Agrawal

Acked-by: Sachin Saxena<sachin.saxena@oss.nxp.com>


On 17-Jun-20 12:00 PM, jerinj@marvell.com wrote:
> From: Jerin Jacob <jerinj@marvell.com>
>
> Use log register macro to avoid the code duplication
> in the log registration process.
>
> Signed-off-by: Jerin Jacob <jerinj@marvell.com>
> ---
>   drivers/bus/dpaa/dpaa_bus.c      | 10 +---------
>   drivers/bus/fslmc/fslmc_bus.c    | 11 +----------
>   drivers/bus/ifpga/ifpga_bus.c    |  9 +--------
>   drivers/bus/vdev/vdev.c          | 10 +---------
>   drivers/bus/vmbus/vmbus_common.c |  9 +--------
>   5 files changed, 5 insertions(+), 44 deletions(-)
>
> diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c
> index d53fe6083..0d8b13e5f 100644
> --- a/drivers/bus/dpaa/dpaa_bus.c
> +++ b/drivers/bus/dpaa/dpaa_bus.c
> @@ -42,8 +42,6 @@
>   #include <fsl_bman.h>
>   #include <netcfg.h>
>   
> -int dpaa_logtype_bus;
> -
>   static struct rte_dpaa_bus rte_dpaa_bus;
>   struct netcfg_info *dpaa_netcfg;
>   
> @@ -749,10 +747,4 @@ static struct rte_dpaa_bus rte_dpaa_bus = {
>   };
>   
>   RTE_REGISTER_BUS(FSL_DPAA_BUS_NAME, rte_dpaa_bus.bus);
> -
> -RTE_INIT(dpaa_init_log)
> -{
> -	dpaa_logtype_bus = rte_log_register("bus.dpaa");
> -	if (dpaa_logtype_bus >= 0)
> -		rte_log_set_level(dpaa_logtype_bus, RTE_LOG_NOTICE);
> -}
> +RTE_LOG_REGISTER(dpaa_logtype_bus, bus.dpaa, NOTICE);
> diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
> index afbd82e8d..d9f403bd9 100644
> --- a/drivers/bus/fslmc/fslmc_bus.c
> +++ b/drivers/bus/fslmc/fslmc_bus.c
> @@ -21,8 +21,6 @@
>   
>   #include <dpaax_iova_table.h>
>   
> -int dpaa2_logtype_bus;
> -
>   #define VFIO_IOMMU_GROUP_PATH "/sys/kernel/iommu_groups"
>   #define FSLMC_BUS_NAME	fslmc
>   
> @@ -649,11 +647,4 @@ struct rte_fslmc_bus rte_fslmc_bus = {
>   };
>   
>   RTE_REGISTER_BUS(FSLMC_BUS_NAME, rte_fslmc_bus.bus);
> -
> -RTE_INIT(fslmc_init_log)
> -{
> -	/* Bus level logs */
> -	dpaa2_logtype_bus = rte_log_register("bus.fslmc");
> -	if (dpaa2_logtype_bus >= 0)
> -		rte_log_set_level(dpaa2_logtype_bus, RTE_LOG_NOTICE);
> -}
> +RTE_LOG_REGISTER(dpaa2_logtype_bus, bus.fslmc, NOTICE);
> diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c
> index addbc3e86..103915d43 100644
> --- a/drivers/bus/ifpga/ifpga_bus.c
> +++ b/drivers/bus/ifpga/ifpga_bus.c
> @@ -32,7 +32,6 @@
>   #include "ifpga_logs.h"
>   #include "ifpga_common.h"
>   
> -int ifpga_bus_logtype;
>   
>   /* Forward declaration to access Intel FPGA bus
>    * on which iFPGA devices are connected
> @@ -474,10 +473,4 @@ static struct rte_bus rte_ifpga_bus = {
>   };
>   
>   RTE_REGISTER_BUS(IFPGA_BUS_NAME, rte_ifpga_bus);
> -
> -RTE_INIT(ifpga_init_log)
> -{
> -	ifpga_bus_logtype = rte_log_register("bus.ifpga");
> -	if (ifpga_bus_logtype >= 0)
> -		rte_log_set_level(ifpga_bus_logtype, RTE_LOG_NOTICE);
> -}
> +RTE_LOG_REGISTER(ifpga_bus_logtype, bus.ifpga, NOTICE);
> diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
> index a89ea2353..d746149a2 100644
> --- a/drivers/bus/vdev/vdev.c
> +++ b/drivers/bus/vdev/vdev.c
> @@ -27,8 +27,6 @@
>   
>   #define VDEV_MP_KEY	"bus_vdev_mp"
>   
> -int vdev_logtype_bus;
> -
>   /* Forward declare to access virtual bus name */
>   static struct rte_bus rte_vdev_bus;
>   
> @@ -557,10 +555,4 @@ static struct rte_bus rte_vdev_bus = {
>   };
>   
>   RTE_REGISTER_BUS(vdev, rte_vdev_bus);
> -
> -RTE_INIT(vdev_init_log)
> -{
> -	vdev_logtype_bus = rte_log_register("bus.vdev");
> -	if (vdev_logtype_bus >= 0)
> -		rte_log_set_level(vdev_logtype_bus, RTE_LOG_NOTICE);
> -}
> +RTE_LOG_REGISTER(vdev_logtype_bus, bus.vdev, NOTICE);
> diff --git a/drivers/bus/vmbus/vmbus_common.c b/drivers/bus/vmbus/vmbus_common.c
> index 3adef01c9..4c9ac33ac 100644
> --- a/drivers/bus/vmbus/vmbus_common.c
> +++ b/drivers/bus/vmbus/vmbus_common.c
> @@ -22,7 +22,6 @@
>   
>   #include "private.h"
>   
> -int vmbus_logtype_bus;
>   extern struct rte_vmbus_bus rte_vmbus_bus;
>   
>   /* map a particular resource from a file */
> @@ -298,10 +297,4 @@ struct rte_vmbus_bus rte_vmbus_bus = {
>   };
>   
>   RTE_REGISTER_BUS(vmbus, rte_vmbus_bus.bus);
> -
> -RTE_INIT(vmbus_init_log)
> -{
> -	vmbus_logtype_bus = rte_log_register("bus.vmbus");
> -	if (vmbus_logtype_bus >= 0)
> -		rte_log_set_level(vmbus_logtype_bus, RTE_LOG_NOTICE);
> -}
> +RTE_LOG_REGISTER(vmbus_logtype_bus, bus.vmbus, NOTICE);


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

* Re: [dpdk-dev] [PATCH 01/13] eal/log: introduce log register macro
  2020-06-17 10:26     ` Andrew Rybchenko
@ 2020-06-24 13:08       ` Jerin Jacob
  0 siblings, 0 replies; 98+ messages in thread
From: Jerin Jacob @ 2020-06-24 13:08 UTC (permalink / raw)
  To: Andrew Rybchenko
  Cc: Thomas Monjalon, Jerin Jacob, dpdk-dev, Olivier Matz, David Marchand

On Wed, Jun 17, 2020 at 3:56 PM Andrew Rybchenko
<arybchenko@solarflare.com> wrote:
>
> On 6/17/20 1:00 PM, Thomas Monjalon wrote:
> > 17/06/2020 08:30, jerinj@marvell.com:
> >> From: Jerin Jacob <jerinj@marvell.com>
> >>
> >> Introducing the RTE_LOG_REGISTER macro to avoid the code duplication
> >> in the log registration process.
> >>
> >> It is a wrapper macro for declaring the logtype, register the log and sets
> >> it's level in the constructor context.
> >>
> >> Signed-off-by: Jerin Jacob <jerinj@marvell.com>
> >> ---
> >> --- a/lib/librte_eal/include/rte_log.h
> >> +++ b/lib/librte_eal/include/rte_log.h
> >> +#define RTE_LOG_REGISTER(type, name, level)                 \
> >> +int type;                                                   \
> >> +RTE_INIT(__##type)                                          \
> >> +{                                                           \
> >> +    type = rte_log_register(RTE_STR(name));                 \
> >> +    if (type >= 0)                                          \
> >> +            rte_log_set_level(type, RTE_LOG_##level);       \
> >> +}
> >
> > It should use rte_log_register_type_and_pick_level()
> > which works for drivers loaded later in the init sequence.
>
> Yes, rte_log_register_type_and_pick_level() should be used.
> Otherwise, if a driver is loaded (the constructor is called)
> after --log-level options processing, the level set using
> the option is not applied.

OK. I will change it in v2.

>
> > rte_log_register() should be deprecated.
>
> +1
>

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

* Re: [dpdk-dev] [PATCH 01/13] eal/log: introduce log register macro
  2020-06-17 10:21     ` Andrew Rybchenko
@ 2020-06-24 13:11       ` Jerin Jacob
  2020-06-24 15:26         ` Andrew Rybchenko
  0 siblings, 1 reply; 98+ messages in thread
From: Jerin Jacob @ 2020-06-24 13:11 UTC (permalink / raw)
  To: Andrew Rybchenko
  Cc: David Marchand, Jerin Jacob Kollanukkaran, dev, Thomas Monjalon,
	Olivier Matz

On Wed, Jun 17, 2020 at 3:51 PM Andrew Rybchenko
<arybchenko@solarflare.com> wrote:
>
> On 6/17/20 1:02 PM, David Marchand wrote:
> > On Wed, Jun 17, 2020 at 8:30 AM <jerinj@marvell.com> wrote:
> >>
> >> From: Jerin Jacob <jerinj@marvell.com>
> >>
> >> Introducing the RTE_LOG_REGISTER macro to avoid the code duplication
> >> in the log registration process.
> >>
> >> It is a wrapper macro for declaring the logtype, register the log and sets
> >
> > Having the logtype variable declared as part of the macro will force
> > us to have global symbols (for the cases where it is needed).
> > I'd rather leave the declaration to the caller, and only handle the
> > registering part in this macro.
>
> I agree with David that it is important to avoid global symbols
> when it is not needed.

David, Andrew,

Since it is executed in "constructor" context, it will be always from
the global variable. Right?
i.e DPDK is not yet initialized in when "constructor" being called.
In addition to that, It will be adding more lines of code in the
consumer of this MACRO.
Thoughts?


>
> >> it's level in the constructor context.
> >>
> >
> >
>

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

* Re: [dpdk-dev] [PATCH 01/13] eal/log: introduce log register macro
  2020-06-24 13:11       ` Jerin Jacob
@ 2020-06-24 15:26         ` Andrew Rybchenko
  2020-06-24 15:32           ` Jerin Jacob
  0 siblings, 1 reply; 98+ messages in thread
From: Andrew Rybchenko @ 2020-06-24 15:26 UTC (permalink / raw)
  To: Jerin Jacob
  Cc: David Marchand, Jerin Jacob Kollanukkaran, dev, Thomas Monjalon,
	Olivier Matz

On 6/24/20 4:11 PM, Jerin Jacob wrote:
> On Wed, Jun 17, 2020 at 3:51 PM Andrew Rybchenko
> <arybchenko@solarflare.com> wrote:
>>
>> On 6/17/20 1:02 PM, David Marchand wrote:
>>> On Wed, Jun 17, 2020 at 8:30 AM <jerinj@marvell.com> wrote:
>>>>
>>>> From: Jerin Jacob <jerinj@marvell.com>
>>>>
>>>> Introducing the RTE_LOG_REGISTER macro to avoid the code duplication
>>>> in the log registration process.
>>>>
>>>> It is a wrapper macro for declaring the logtype, register the log and sets
>>>
>>> Having the logtype variable declared as part of the macro will force
>>> us to have global symbols (for the cases where it is needed).
>>> I'd rather leave the declaration to the caller, and only handle the
>>> registering part in this macro.
>>
>> I agree with David that it is important to avoid global symbols
>> when it is not needed.
> 
> David, Andrew,
> 
> Since it is executed in "constructor" context, it will be always from
> the global variable. Right?
> i.e DPDK is not yet initialized in when "constructor" being called.
> In addition to that, It will be adding more lines of code in the
> consumer of this MACRO.
> Thoughts?

The problem is rather 'extern' vs 'static'. Before the patch
many variables are static, but become externally visible after
the patch.

>>
>>>> it's level in the constructor context.
>>>>
>>>
>>>
>>


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

* Re: [dpdk-dev] [PATCH 01/13] eal/log: introduce log register macro
  2020-06-24 15:26         ` Andrew Rybchenko
@ 2020-06-24 15:32           ` Jerin Jacob
  2020-06-24 15:43             ` Andrew Rybchenko
  0 siblings, 1 reply; 98+ messages in thread
From: Jerin Jacob @ 2020-06-24 15:32 UTC (permalink / raw)
  To: Andrew Rybchenko
  Cc: David Marchand, Jerin Jacob Kollanukkaran, dev, Thomas Monjalon,
	Olivier Matz

On Wed, Jun 24, 2020 at 8:56 PM Andrew Rybchenko
<arybchenko@solarflare.com> wrote:
>
> On 6/24/20 4:11 PM, Jerin Jacob wrote:
> > On Wed, Jun 17, 2020 at 3:51 PM Andrew Rybchenko
> > <arybchenko@solarflare.com> wrote:
> >>
> >> On 6/17/20 1:02 PM, David Marchand wrote:
> >>> On Wed, Jun 17, 2020 at 8:30 AM <jerinj@marvell.com> wrote:
> >>>>
> >>>> From: Jerin Jacob <jerinj@marvell.com>
> >>>>
> >>>> Introducing the RTE_LOG_REGISTER macro to avoid the code duplication
> >>>> in the log registration process.
> >>>>
> >>>> It is a wrapper macro for declaring the logtype, register the log and sets
> >>>
> >>> Having the logtype variable declared as part of the macro will force
> >>> us to have global symbols (for the cases where it is needed).
> >>> I'd rather leave the declaration to the caller, and only handle the
> >>> registering part in this macro.
> >>
> >> I agree with David that it is important to avoid global symbols
> >> when it is not needed.
> >
> > David, Andrew,
> >
> > Since it is executed in "constructor" context, it will be always from
> > the global variable. Right?
> > i.e DPDK is not yet initialized in when "constructor" being called.
> > In addition to that, It will be adding more lines of code in the
> > consumer of this MACRO.
> > Thoughts?
>
> The problem is rather 'extern' vs 'static'. Before the patch
> many variables are static, but become externally visible after
> the patch.

OK. How about RTE_LOG_REGISTER_EXTERN or RTE_LOG_REGISTER_STATIC then?
It will allow less code in the consumer of this macro.
May be default we an make it as static so RTE_LOG_REGISTER and
RTE_LOG_REGISTER_EXTERN
for the different needs.

Thoughts?


>
> >>
> >>>> it's level in the constructor context.
> >>>>
> >>>
> >>>
> >>
>

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

* Re: [dpdk-dev] [PATCH 01/13] eal/log: introduce log register macro
  2020-06-24 15:32           ` Jerin Jacob
@ 2020-06-24 15:43             ` Andrew Rybchenko
  2020-06-24 18:10               ` Jerin Jacob
  0 siblings, 1 reply; 98+ messages in thread
From: Andrew Rybchenko @ 2020-06-24 15:43 UTC (permalink / raw)
  To: Jerin Jacob
  Cc: David Marchand, Jerin Jacob Kollanukkaran, dev, Thomas Monjalon,
	Olivier Matz

On 6/24/20 6:32 PM, Jerin Jacob wrote:
> On Wed, Jun 24, 2020 at 8:56 PM Andrew Rybchenko
> <arybchenko@solarflare.com> wrote:
>>
>> On 6/24/20 4:11 PM, Jerin Jacob wrote:
>>> On Wed, Jun 17, 2020 at 3:51 PM Andrew Rybchenko
>>> <arybchenko@solarflare.com> wrote:
>>>>
>>>> On 6/17/20 1:02 PM, David Marchand wrote:
>>>>> On Wed, Jun 17, 2020 at 8:30 AM <jerinj@marvell.com> wrote:
>>>>>>
>>>>>> From: Jerin Jacob <jerinj@marvell.com>
>>>>>>
>>>>>> Introducing the RTE_LOG_REGISTER macro to avoid the code duplication
>>>>>> in the log registration process.
>>>>>>
>>>>>> It is a wrapper macro for declaring the logtype, register the log and sets
>>>>>
>>>>> Having the logtype variable declared as part of the macro will force
>>>>> us to have global symbols (for the cases where it is needed).
>>>>> I'd rather leave the declaration to the caller, and only handle the
>>>>> registering part in this macro.
>>>>
>>>> I agree with David that it is important to avoid global symbols
>>>> when it is not needed.
>>>
>>> David, Andrew,
>>>
>>> Since it is executed in "constructor" context, it will be always from
>>> the global variable. Right?
>>> i.e DPDK is not yet initialized in when "constructor" being called.
>>> In addition to that, It will be adding more lines of code in the
>>> consumer of this MACRO.
>>> Thoughts?
>>
>> The problem is rather 'extern' vs 'static'. Before the patch
>> many variables are static, but become externally visible after
>> the patch.
> 
> OK. How about RTE_LOG_REGISTER_EXTERN or RTE_LOG_REGISTER_STATIC then?
> It will allow less code in the consumer of this macro.
> May be default we an make it as static so RTE_LOG_REGISTER and
> RTE_LOG_REGISTER_EXTERN
> for the different needs.
> 
> Thoughts?

Yes, I think it is a possible solution to use static in
RTE_LOG_REGISTER and use RTE_LOG_REGISTER_EXTERN
for non-static version. If we go this way, I'd prefer
the option.

Alternative is to keep variable declaration outside,
as David suggested, and I tend to agree that it is a
bit better. Macro name says 'register'. It is not
'declare and register'. Also it avoids static-vs-extern
problem completely. The solution allows to keep the
variable declaration untouched and put constructor (macro)
at the end of fine where constructors typically reside.

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

* Re: [dpdk-dev] [PATCH 01/13] eal/log: introduce log register macro
  2020-06-24 15:43             ` Andrew Rybchenko
@ 2020-06-24 18:10               ` Jerin Jacob
  2020-06-26 11:16                 ` Jerin Jacob
  0 siblings, 1 reply; 98+ messages in thread
From: Jerin Jacob @ 2020-06-24 18:10 UTC (permalink / raw)
  To: Andrew Rybchenko
  Cc: David Marchand, Jerin Jacob Kollanukkaran, dev, Thomas Monjalon,
	Olivier Matz

On Wed, Jun 24, 2020 at 9:13 PM Andrew Rybchenko
<arybchenko@solarflare.com> wrote:
>
> On 6/24/20 6:32 PM, Jerin Jacob wrote:
> > On Wed, Jun 24, 2020 at 8:56 PM Andrew Rybchenko
> > <arybchenko@solarflare.com> wrote:
> >>
> >> On 6/24/20 4:11 PM, Jerin Jacob wrote:
> >>> On Wed, Jun 17, 2020 at 3:51 PM Andrew Rybchenko
> >>> <arybchenko@solarflare.com> wrote:
> >>>>
> >>>> On 6/17/20 1:02 PM, David Marchand wrote:
> >>>>> On Wed, Jun 17, 2020 at 8:30 AM <jerinj@marvell.com> wrote:
> >>>>>>
> >>>>>> From: Jerin Jacob <jerinj@marvell.com>
> >>>>>>
> >>>>>> Introducing the RTE_LOG_REGISTER macro to avoid the code duplication
> >>>>>> in the log registration process.
> >>>>>>
> >>>>>> It is a wrapper macro for declaring the logtype, register the log and sets
> >>>>>
> >>>>> Having the logtype variable declared as part of the macro will force
> >>>>> us to have global symbols (for the cases where it is needed).
> >>>>> I'd rather leave the declaration to the caller, and only handle the
> >>>>> registering part in this macro.
> >>>>
> >>>> I agree with David that it is important to avoid global symbols
> >>>> when it is not needed.
> >>>
> >>> David, Andrew,
> >>>
> >>> Since it is executed in "constructor" context, it will be always from
> >>> the global variable. Right?
> >>> i.e DPDK is not yet initialized in when "constructor" being called.
> >>> In addition to that, It will be adding more lines of code in the
> >>> consumer of this MACRO.
> >>> Thoughts?
> >>
> >> The problem is rather 'extern' vs 'static'. Before the patch
> >> many variables are static, but become externally visible after
> >> the patch.
> >
> > OK. How about RTE_LOG_REGISTER_EXTERN or RTE_LOG_REGISTER_STATIC then?
> > It will allow less code in the consumer of this macro.
> > May be default we an make it as static so RTE_LOG_REGISTER and
> > RTE_LOG_REGISTER_EXTERN
> > for the different needs.
> >
> > Thoughts?
>
> Yes, I think it is a possible solution to use static in
> RTE_LOG_REGISTER and use RTE_LOG_REGISTER_EXTERN
> for non-static version. If we go this way, I'd prefer
> the option.

OK.

>
> Alternative is to keep variable declaration outside,
> as David suggested, and I tend to agree that it is a
> bit better. Macro name says 'register'. It is not
> 'declare and register'. Also it avoids static-vs-extern
> problem completely. The solution allows to keep the
> variable declaration untouched and put constructor (macro)
> at the end of fine where constructors typically reside.

My only concern with that approach is that, We can not save a lot of
code duplication
with that scheme. ie. it is [1] vs [2]. We can change the MACRO name
accordingly if that is a concern. Any suggestions?

Let me know your preference on [1] vs [2], I will stick with for the
next version.

[1]

RTE_LOG_REGISTER(otx2_logtype_base, pmd.octeontx2.base, NOTICE);
RTE_LOG_REGISTER(otx2_logtype_mbox, pmd.octeontx2.mbox, NOTICE);
RTE_LOG_REGISTER(otx2_logtype_npa, pmd.mempool.octeontx2, NOTICE);
RTE_LOG_REGISTER(otx2_logtype_nix, pmd.net.octeontx2, NOTICE);
RTE_LOG_REGISTER(otx2_logtype_npc, pmd.net.octeontx2.flow, NOTICE);
RTE_LOG_REGISTER(otx2_logtype_tm, pmd.net.octeontx2.tm, NOTICE);
RTE_LOG_REGISTER(otx2_logtype_sso, pmd.event.octeontx2, NOTICE);
RTE_LOG_REGISTER(otx2_logtype_tim, pmd.event.octeontx2.timer, NOTICE);
RTE_LOG_REGISTER(otx2_logtype_dpi, pmd.raw.octeontx2.dpi, NOTICE);
RTE_LOG_REGISTER(otx2_logtype_ep, pmd.raw.octeontx2.ep, NOTICE)

[2]


int otx2_logtype_base;
int otx2_logtype_mbox;
int otx2_logtype_npa;
int otx2_logtype_nix;
int otx2_logtype_npc;
int otx2_logtype_tm;
int otx2_logtype_sso;
int otx2_logtype_tim;
int otx2_logtype_dpi;
int otx2_logtype_ep;

RTE_LOG_REGISTER(otx2_logtype_base, pmd.octeontx2.base, NOTICE);
RTE_LOG_REGISTER(otx2_logtype_mbox, pmd.octeontx2.mbox, NOTICE);
RTE_LOG_REGISTER(otx2_logtype_npa, pmd.mempool.octeontx2, NOTICE);
RTE_LOG_REGISTER(otx2_logtype_nix, pmd.net.octeontx2, NOTICE);
RTE_LOG_REGISTER(otx2_logtype_npc, pmd.net.octeontx2.flow, NOTICE);
RTE_LOG_REGISTER(otx2_logtype_tm, pmd.net.octeontx2.tm, NOTICE);
RTE_LOG_REGISTER(otx2_logtype_sso, pmd.event.octeontx2, NOTICE);
RTE_LOG_REGISTER(otx2_logtype_tim, pmd.event.octeontx2.timer, NOTICE);
RTE_LOG_REGISTER(otx2_logtype_dpi, pmd.raw.octeontx2.dpi, NOTICE);
RTE_LOG_REGISTER(otx2_logtype_ep, pmd.raw.octeontx2.ep, NOTICE)

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

* Re: [dpdk-dev] [PATCH 00/13] rte_log registration usage improvement
  2020-06-17  6:30 [dpdk-dev] [PATCH 00/13] rte_log registration usage improvement jerinj
                   ` (12 preceding siblings ...)
  2020-06-17  6:30 ` [dpdk-dev] [PATCH 13/13] app/test: " jerinj
@ 2020-06-25 16:18 ` Dybkowski, AdamX
  2020-06-25 16:20   ` Dybkowski, AdamX
  2020-07-01  3:58 ` [dpdk-dev] [PATCH v2 " jerinj
  14 siblings, 1 reply; 98+ messages in thread
From: Dybkowski, AdamX @ 2020-06-25 16:18 UTC (permalink / raw)
  To: jerinj, dev; +Cc: thomas, olivier.matz, david.marchand

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of jerinj@marvell.com
> Sent: Wednesday, 17 June, 2020 08:31
> To: dev@dpdk.org
> Cc: thomas@monjalon.net; olivier.matz@6wind.com;
> david.marchand@redhat.com; Jerin Jacob <jerinj@marvell.com>
> Subject: [dpdk-dev] [PATCH 00/13] rte_log registration usage improvement
> 
> From: Jerin Jacob <jerinj@marvell.com>
> 
> This patch series improves the rte_log registration code snippet by avoiding
> duplication of the code around registration by introducing
> RTE_LOG_REGISTER macro.

Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>

I've checked the patch series with QAT PMD (and QAT hardware) and it works fine.


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

* Re: [dpdk-dev] [PATCH 00/13] rte_log registration usage improvement
  2020-06-25 16:18 ` [dpdk-dev] [PATCH 00/13] rte_log registration usage improvement Dybkowski, AdamX
@ 2020-06-25 16:20   ` Dybkowski, AdamX
  0 siblings, 0 replies; 98+ messages in thread
From: Dybkowski, AdamX @ 2020-06-25 16:20 UTC (permalink / raw)
  To: Dybkowski, AdamX, jerinj, dev; +Cc: thomas, olivier.matz, david.marchand

> > -----Original Message-----
> > From: dev <dev-bounces@dpdk.org> On Behalf Of jerinj@marvell.com
> > Sent: Wednesday, 17 June, 2020 08:31
> > To: dev@dpdk.org
> > Cc: thomas@monjalon.net; olivier.matz@6wind.com;
> > david.marchand@redhat.com; Jerin Jacob <jerinj@marvell.com>
> > Subject: [dpdk-dev] [PATCH 00/13] rte_log registration usage
> > improvement
> >
> > From: Jerin Jacob <jerinj@marvell.com>
> >
> > This patch series improves the rte_log registration code snippet by
> > avoiding duplication of the code around registration by introducing
> > RTE_LOG_REGISTER macro.

Series Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>


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

* Re: [dpdk-dev] [PATCH 01/13] eal/log: introduce log register macro
  2020-06-24 18:10               ` Jerin Jacob
@ 2020-06-26 11:16                 ` Jerin Jacob
  2020-06-26 11:42                   ` David Marchand
  0 siblings, 1 reply; 98+ messages in thread
From: Jerin Jacob @ 2020-06-26 11:16 UTC (permalink / raw)
  To: Andrew Rybchenko
  Cc: David Marchand, Jerin Jacob Kollanukkaran, dev, Thomas Monjalon,
	Olivier Matz

On Wed, Jun 24, 2020 at 11:40 PM Jerin Jacob <jerinjacobk@gmail.com> wrote:
>
> On Wed, Jun 24, 2020 at 9:13 PM Andrew Rybchenko
> <arybchenko@solarflare.com> wrote:
> >
> > On 6/24/20 6:32 PM, Jerin Jacob wrote:
> > > On Wed, Jun 24, 2020 at 8:56 PM Andrew Rybchenko
> > > <arybchenko@solarflare.com> wrote:
> > >>
> > >> On 6/24/20 4:11 PM, Jerin Jacob wrote:
> > >>> On Wed, Jun 17, 2020 at 3:51 PM Andrew Rybchenko
> > >>> <arybchenko@solarflare.com> wrote:
> > >>>>
> > >>>> On 6/17/20 1:02 PM, David Marchand wrote:
> > >>>>> On Wed, Jun 17, 2020 at 8:30 AM <jerinj@marvell.com> wrote:
> > >>>>>>
> > >>>>>> From: Jerin Jacob <jerinj@marvell.com>
> > >>>>>>
> > >>>>>> Introducing the RTE_LOG_REGISTER macro to avoid the code duplication
> > >>>>>> in the log registration process.
> > >>>>>>
> > >>>>>> It is a wrapper macro for declaring the logtype, register the log and sets
> > >>>>>
> > >>>>> Having the logtype variable declared as part of the macro will force
> > >>>>> us to have global symbols (for the cases where it is needed).
> > >>>>> I'd rather leave the declaration to the caller, and only handle the
> > >>>>> registering part in this macro.
> > >>>>
> > >>>> I agree with David that it is important to avoid global symbols
> > >>>> when it is not needed.
> > >>>
> > >>> David, Andrew,
> > >>>
> > >>> Since it is executed in "constructor" context, it will be always from
> > >>> the global variable. Right?
> > >>> i.e DPDK is not yet initialized in when "constructor" being called.
> > >>> In addition to that, It will be adding more lines of code in the
> > >>> consumer of this MACRO.
> > >>> Thoughts?
> > >>
> > >> The problem is rather 'extern' vs 'static'. Before the patch
> > >> many variables are static, but become externally visible after
> > >> the patch.
> > >
> > > OK. How about RTE_LOG_REGISTER_EXTERN or RTE_LOG_REGISTER_STATIC then?
> > > It will allow less code in the consumer of this macro.
> > > May be default we an make it as static so RTE_LOG_REGISTER and
> > > RTE_LOG_REGISTER_EXTERN
> > > for the different needs.
> > >
> > > Thoughts?
> >
> > Yes, I think it is a possible solution to use static in
> > RTE_LOG_REGISTER and use RTE_LOG_REGISTER_EXTERN
> > for non-static version. If we go this way, I'd prefer
> > the option.
>
> OK.
>
> >
> > Alternative is to keep variable declaration outside,
> > as David suggested, and I tend to agree that it is a
> > bit better. Macro name says 'register'. It is not
> > 'declare and register'. Also it avoids static-vs-extern
> > problem completely. The solution allows to keep the
> > variable declaration untouched and put constructor (macro)
> > at the end of fine where constructors typically reside.
>
> My only concern with that approach is that, We can not save a lot of
> code duplication
> with that scheme. ie. it is [1] vs [2]. We can change the MACRO name
> accordingly if that is a concern. Any suggestions?
>
> Let me know your preference on [1] vs [2], I will stick with for the
> next version.

If there are no other comments, I change RTE_LOG_REGISTER to static version
and RTE_LOG_REGISTER_EXTERN for a non-static version and send the next version.



>
> [1]
>
> RTE_LOG_REGISTER(otx2_logtype_base, pmd.octeontx2.base, NOTICE);
> RTE_LOG_REGISTER(otx2_logtype_mbox, pmd.octeontx2.mbox, NOTICE);
> RTE_LOG_REGISTER(otx2_logtype_npa, pmd.mempool.octeontx2, NOTICE);
> RTE_LOG_REGISTER(otx2_logtype_nix, pmd.net.octeontx2, NOTICE);
> RTE_LOG_REGISTER(otx2_logtype_npc, pmd.net.octeontx2.flow, NOTICE);
> RTE_LOG_REGISTER(otx2_logtype_tm, pmd.net.octeontx2.tm, NOTICE);
> RTE_LOG_REGISTER(otx2_logtype_sso, pmd.event.octeontx2, NOTICE);
> RTE_LOG_REGISTER(otx2_logtype_tim, pmd.event.octeontx2.timer, NOTICE);
> RTE_LOG_REGISTER(otx2_logtype_dpi, pmd.raw.octeontx2.dpi, NOTICE);
> RTE_LOG_REGISTER(otx2_logtype_ep, pmd.raw.octeontx2.ep, NOTICE)
>
> [2]
>
>
> int otx2_logtype_base;
> int otx2_logtype_mbox;
> int otx2_logtype_npa;
> int otx2_logtype_nix;
> int otx2_logtype_npc;
> int otx2_logtype_tm;
> int otx2_logtype_sso;
> int otx2_logtype_tim;
> int otx2_logtype_dpi;
> int otx2_logtype_ep;
>
> RTE_LOG_REGISTER(otx2_logtype_base, pmd.octeontx2.base, NOTICE);
> RTE_LOG_REGISTER(otx2_logtype_mbox, pmd.octeontx2.mbox, NOTICE);
> RTE_LOG_REGISTER(otx2_logtype_npa, pmd.mempool.octeontx2, NOTICE);
> RTE_LOG_REGISTER(otx2_logtype_nix, pmd.net.octeontx2, NOTICE);
> RTE_LOG_REGISTER(otx2_logtype_npc, pmd.net.octeontx2.flow, NOTICE);
> RTE_LOG_REGISTER(otx2_logtype_tm, pmd.net.octeontx2.tm, NOTICE);
> RTE_LOG_REGISTER(otx2_logtype_sso, pmd.event.octeontx2, NOTICE);
> RTE_LOG_REGISTER(otx2_logtype_tim, pmd.event.octeontx2.timer, NOTICE);
> RTE_LOG_REGISTER(otx2_logtype_dpi, pmd.raw.octeontx2.dpi, NOTICE);
> RTE_LOG_REGISTER(otx2_logtype_ep, pmd.raw.octeontx2.ep, NOTICE)

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

* Re: [dpdk-dev] [PATCH 01/13] eal/log: introduce log register macro
  2020-06-26 11:16                 ` Jerin Jacob
@ 2020-06-26 11:42                   ` David Marchand
  2020-06-26 12:06                     ` Jerin Jacob
  0 siblings, 1 reply; 98+ messages in thread
From: David Marchand @ 2020-06-26 11:42 UTC (permalink / raw)
  To: Jerin Jacob
  Cc: Andrew Rybchenko, Jerin Jacob Kollanukkaran, dev,
	Thomas Monjalon, Olivier Matz

On Fri, Jun 26, 2020 at 1:16 PM Jerin Jacob <jerinjacobk@gmail.com> wrote:
> > > Alternative is to keep variable declaration outside,
> > > as David suggested, and I tend to agree that it is a
> > > bit better. Macro name says 'register'. It is not
> > > 'declare and register'. Also it avoids static-vs-extern
> > > problem completely. The solution allows to keep the
> > > variable declaration untouched and put constructor (macro)
> > > at the end of fine where constructors typically reside.
> >
> > My only concern with that approach is that, We can not save a lot of
> > code duplication
> > with that scheme. ie. it is [1] vs [2]. We can change the MACRO name
> > accordingly if that is a concern. Any suggestions?
> >
> > Let me know your preference on [1] vs [2], I will stick with for the
> > next version.
>
> If there are no other comments, I change RTE_LOG_REGISTER to static version
> and RTE_LOG_REGISTER_EXTERN for a non-static version and send the next version.

- Having a macro that does more than what its name tells is inconvenient.
The trace framework differentiates declaration and registration.
Why merge things in the log framework?

Saving one line is not worth it.


- Having components set log levels at init time in the macro is a bug to me.
This has been worked around with
rte_log_register/rte_log_register_and_pick_level but the initial
problem is that rte_log_set_level* should only be called by the user.

There should be a default level for all dpdk components (which means a
common interpretation of each level), then the user chooses which logs
he wants to see.

At the moment, let's say I am looking at a live system, by default, we have:

id 0: lib.eal, level is info
id 1: lib.malloc, level is info
id 2: lib.ring, level is info
id 3: lib.mempool, level is info
id 4: lib.timer, level is info
id 5: pmd, level is info
...
id 32: lib.bbdev, level is notice
id 33: lib.bpf, level is info
id 34: bus.dpaa, level is notice
id 35: bus.fslmc, level is notice
id 36: bus.ifpga, level is notice
id 37: bus.vdev, level is notice
id 38: bus.vmbus, level is notice
id 39: lib.cfgfile, level is info
id 40: pmd.common.dpaax, level is error
...

I enable the logs for a component, set it to debug, I get my logs.
If now I want to reset the logs to the initial state, err... well
unless I took note of it, I don't know what the default level is.
But I should not have to care.

Restarting dpdk sure is something you can do with testpmd but not with
real systems.


-- 
David Marchand


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

* Re: [dpdk-dev] [PATCH 01/13] eal/log: introduce log register macro
  2020-06-26 11:42                   ` David Marchand
@ 2020-06-26 12:06                     ` Jerin Jacob
  2020-06-26 12:13                       ` David Marchand
  2020-06-26 12:16                       ` David Marchand
  0 siblings, 2 replies; 98+ messages in thread
From: Jerin Jacob @ 2020-06-26 12:06 UTC (permalink / raw)
  To: David Marchand
  Cc: Andrew Rybchenko, Jerin Jacob Kollanukkaran, dev,
	Thomas Monjalon, Olivier Matz

On Fri, Jun 26, 2020 at 5:13 PM David Marchand
<david.marchand@redhat.com> wrote:
>
> On Fri, Jun 26, 2020 at 1:16 PM Jerin Jacob <jerinjacobk@gmail.com> wrote:
> > > > Alternative is to keep variable declaration outside,
> > > > as David suggested, and I tend to agree that it is a
> > > > bit better. Macro name says 'register'. It is not
> > > > 'declare and register'. Also it avoids static-vs-extern
> > > > problem completely. The solution allows to keep the
> > > > variable declaration untouched and put constructor (macro)
> > > > at the end of fine where constructors typically reside.
> > >
> > > My only concern with that approach is that, We can not save a lot of
> > > code duplication
> > > with that scheme. ie. it is [1] vs [2]. We can change the MACRO name
> > > accordingly if that is a concern. Any suggestions?
> > >
> > > Let me know your preference on [1] vs [2], I will stick with for the
> > > next version.
> >
> > If there are no other comments, I change RTE_LOG_REGISTER to static version
> > and RTE_LOG_REGISTER_EXTERN for a non-static version and send the next version.
>
> - Having a macro that does more than what its name tells is inconvenient.

I agree. What could be that name if we want to declare and register?
RTE_LOG_DECLARE_AND_REGISTER_EXTERN?

> The trace framework differentiates declaration and registration.
> Why merge things in the log framework?

Not merging both at the functional level. it has just helper macro to
avoid duplicating the code usage pattern.

>
> Saving one line is not worth it.

It is one line per log registration.

Please check the patch change status, at
,http://mails.dpdk.org/archives/dev/2020-June/170531.html
It is:
 122 files changed, 229 insertions(+), 1322 deletions(-)

Why to add yet another 229 lines, if we can change the name.

>
>
> - Having components set log levels at init time in the macro is a bug to me.
> This has been worked around with
> rte_log_register/rte_log_register_and_pick_level but the initial
> problem is that rte_log_set_level* should only be called by the user.

I agree with the below stuff, That's is not introduced by this patch.
It is already there.
Be it macro or no macro code.

I think this patch helps to change to new scheme as it takes care of
changing the
registration part to commonplace so that we can set to the same level
in the future if
everyone agrees to it


>
> There should be a default level for all dpdk components (which means a
> common interpretation of each level), then the user chooses which logs
> he wants to see.
>
> At the moment, let's say I am looking at a live system, by default, we have:
>
> id 0: lib.eal, level is info
> id 1: lib.malloc, level is info
> id 2: lib.ring, level is info
> id 3: lib.mempool, level is info
> id 4: lib.timer, level is info
> id 5: pmd, level is info
> ...
> id 32: lib.bbdev, level is notice
> id 33: lib.bpf, level is info
> id 34: bus.dpaa, level is notice
> id 35: bus.fslmc, level is notice
> id 36: bus.ifpga, level is notice
> id 37: bus.vdev, level is notice
> id 38: bus.vmbus, level is notice
> id 39: lib.cfgfile, level is info
> id 40: pmd.common.dpaax, level is error
> ...
>
> I enable the logs for a component, set it to debug, I get my logs.
> If now I want to reset the logs to the initial state, err... well
> unless I took note of it, I don't know what the default level is.
> But I should not have to care.
>
> Restarting dpdk sure is something you can do with testpmd but not with
> real systems.
>
>
> --
> David Marchand
>

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

* Re: [dpdk-dev] [PATCH 01/13] eal/log: introduce log register macro
  2020-06-26 12:06                     ` Jerin Jacob
@ 2020-06-26 12:13                       ` David Marchand
  2020-06-26 12:16                       ` David Marchand
  1 sibling, 0 replies; 98+ messages in thread
From: David Marchand @ 2020-06-26 12:13 UTC (permalink / raw)
  To: Jerin Jacob
  Cc: Andrew Rybchenko, Jerin Jacob Kollanukkaran, dev,
	Thomas Monjalon, Olivier Matz

On Fri, Jun 26, 2020 at 2:06 PM Jerin Jacob <jerinjacobk@gmail.com> wrote:
>
> On Fri, Jun 26, 2020 at 5:13 PM David Marchand
> <david.marchand@redhat.com> wrote:
> >
> > On Fri, Jun 26, 2020 at 1:16 PM Jerin Jacob <jerinjacobk@gmail.com> wrote:
> > > > > Alternative is to keep variable declaration outside,
> > > > > as David suggested, and I tend to agree that it is a
> > > > > bit better. Macro name says 'register'. It is not
> > > > > 'declare and register'. Also it avoids static-vs-extern
> > > > > problem completely. The solution allows to keep the
> > > > > variable declaration untouched and put constructor (macro)
> > > > > at the end of fine where constructors typically reside.
> > > >
> > > > My only concern with that approach is that, We can not save a lot of
> > > > code duplication
> > > > with that scheme. ie. it is [1] vs [2]. We can change the MACRO name
> > > > accordingly if that is a concern. Any suggestions?
> > > >
> > > > Let me know your preference on [1] vs [2], I will stick with for the
> > > > next version.
> > >
> > > If there are no other comments, I change RTE_LOG_REGISTER to static version
> > > and RTE_LOG_REGISTER_EXTERN for a non-static version and send the next version.
> >
> > - Having a macro that does more than what its name tells is inconvenient.
>
> I agree. What could be that name if we want to declare and register?
> RTE_LOG_DECLARE_AND_REGISTER_EXTERN?

No declaration in macro.


-- 
David Marchand


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

* Re: [dpdk-dev] [PATCH 01/13] eal/log: introduce log register macro
  2020-06-26 12:06                     ` Jerin Jacob
  2020-06-26 12:13                       ` David Marchand
@ 2020-06-26 12:16                       ` David Marchand
  2020-06-26 12:37                         ` Jerin Jacob
  1 sibling, 1 reply; 98+ messages in thread
From: David Marchand @ 2020-06-26 12:16 UTC (permalink / raw)
  To: Jerin Jacob
  Cc: Andrew Rybchenko, Jerin Jacob Kollanukkaran, dev,
	Thomas Monjalon, Olivier Matz

On Fri, Jun 26, 2020 at 2:06 PM Jerin Jacob <jerinjacobk@gmail.com> wrote:
>
> On Fri, Jun 26, 2020 at 5:13 PM David Marchand
> <david.marchand@redhat.com> wrote:
> >
> > On Fri, Jun 26, 2020 at 1:16 PM Jerin Jacob <jerinjacobk@gmail.com> wrote:
> > > > > Alternative is to keep variable declaration outside,
> > > > > as David suggested, and I tend to agree that it is a
> > > > > bit better. Macro name says 'register'. It is not
> > > > > 'declare and register'. Also it avoids static-vs-extern
> > > > > problem completely. The solution allows to keep the
> > > > > variable declaration untouched and put constructor (macro)
> > > > > at the end of fine where constructors typically reside.
> > > >
> > > > My only concern with that approach is that, We can not save a lot of
> > > > code duplication
> > > > with that scheme. ie. it is [1] vs [2]. We can change the MACRO name
> > > > accordingly if that is a concern. Any suggestions?
> > > >
> > > > Let me know your preference on [1] vs [2], I will stick with for the
> > > > next version.
> > >
> > > If there are no other comments, I change RTE_LOG_REGISTER to static version
> > > and RTE_LOG_REGISTER_EXTERN for a non-static version and send the next version.
> >
> > - Having a macro that does more than what its name tells is inconvenient.
>
> I agree. What could be that name if we want to declare and register?
> RTE_LOG_DECLARE_AND_REGISTER_EXTERN?

(sorry, gmail ctrl+enter ...)

Or no declaration in macro and leave code as it is.


> > - Having components set log levels at init time in the macro is a bug to me.
> > This has been worked around with
> > rte_log_register/rte_log_register_and_pick_level but the initial
> > problem is that rte_log_set_level* should only be called by the user.
>
> I agree with the below stuff, That's is not introduced by this patch.
> It is already there.
> Be it macro or no macro code.
>
> I think this patch helps to change to new scheme as it takes care of
> changing the
> registration part to commonplace so that we can set to the same level
> in the future if
> everyone agrees to it

We will still expose this macro meaning that we will have an API breakage later.
So if we go with introducing this, let's make it good from the start.


-- 
David Marchand


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

* Re: [dpdk-dev] [PATCH 01/13] eal/log: introduce log register macro
  2020-06-26 12:16                       ` David Marchand
@ 2020-06-26 12:37                         ` Jerin Jacob
  2020-06-29 13:39                           ` Jerin Jacob
  2020-06-30 13:39                           ` David Marchand
  0 siblings, 2 replies; 98+ messages in thread
From: Jerin Jacob @ 2020-06-26 12:37 UTC (permalink / raw)
  To: David Marchand
  Cc: Andrew Rybchenko, Jerin Jacob Kollanukkaran, dev,
	Thomas Monjalon, Olivier Matz

On Fri, Jun 26, 2020 at 5:46 PM David Marchand
<david.marchand@redhat.com> wrote:
>
> On Fri, Jun 26, 2020 at 2:06 PM Jerin Jacob <jerinjacobk@gmail.com> wrote:
> >
> > On Fri, Jun 26, 2020 at 5:13 PM David Marchand
> > <david.marchand@redhat.com> wrote:
> > >
> > > On Fri, Jun 26, 2020 at 1:16 PM Jerin Jacob <jerinjacobk@gmail.com> wrote:
> > > > > > Alternative is to keep variable declaration outside,
> > > > > > as David suggested, and I tend to agree that it is a
> > > > > > bit better. Macro name says 'register'. It is not
> > > > > > 'declare and register'. Also it avoids static-vs-extern
> > > > > > problem completely. The solution allows to keep the
> > > > > > variable declaration untouched and put constructor (macro)
> > > > > > at the end of fine where constructors typically reside.
> > > > >
> > > > > My only concern with that approach is that, We can not save a lot of
> > > > > code duplication
> > > > > with that scheme. ie. it is [1] vs [2]. We can change the MACRO name
> > > > > accordingly if that is a concern. Any suggestions?
> > > > >
> > > > > Let me know your preference on [1] vs [2], I will stick with for the
> > > > > next version.
> > > >
> > > > If there are no other comments, I change RTE_LOG_REGISTER to static version
> > > > and RTE_LOG_REGISTER_EXTERN for a non-static version and send the next version.
> > >
> > > - Having a macro that does more than what its name tells is inconvenient.
> >
> > I agree. What could be that name if we want to declare and register?
> > RTE_LOG_DECLARE_AND_REGISTER_EXTERN?
>
> (sorry, gmail ctrl+enter ...)
>
> Or no declaration in macro and leave code as it is.

Just to understand, Is it some general coding standard? or Just a preference.
I dont see something like that in the Linux kernel.
In this patch, http://patches.dpdk.org/patch/69681/, You are proposing
the declaration in macro.
See: RTE_TRACE_POINT_REGISTER

I dont see anything wrong with that. Do you have technical rationale
for the above rule?


>
>
> > > - Having components set log levels at init time in the macro is a bug to me.
> > > This has been worked around with
> > > rte_log_register/rte_log_register_and_pick_level but the initial
> > > problem is that rte_log_set_level* should only be called by the user.
> >
> > I agree with the below stuff, That's is not introduced by this patch.
> > It is already there.
> > Be it macro or no macro code.
> >
> > I think this patch helps to change to new scheme as it takes care of
> > changing the
> > registration part to commonplace so that we can set to the same level
> > in the future if
> > everyone agrees to it
>
> We will still expose this macro meaning that we will have an API breakage later.
> So if we go with introducing this, let's make it good from the start.

But Is everyone OK with removing the "level" from the register before
we think about
breaking the API later?. I see PMD uses multiple levels in the same
PMD for different
purposes.


>
>
> --
> David Marchand
>

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

* Re: [dpdk-dev] [PATCH 01/13] eal/log: introduce log register macro
  2020-06-26 12:37                         ` Jerin Jacob
@ 2020-06-29 13:39                           ` Jerin Jacob
  2020-06-30 13:39                           ` David Marchand
  1 sibling, 0 replies; 98+ messages in thread
From: Jerin Jacob @ 2020-06-29 13:39 UTC (permalink / raw)
  To: David Marchand
  Cc: Andrew Rybchenko, Jerin Jacob Kollanukkaran, dev,
	Thomas Monjalon, Olivier Matz

On Fri, Jun 26, 2020 at 6:07 PM Jerin Jacob <jerinjacobk@gmail.com> wrote:
>
> On Fri, Jun 26, 2020 at 5:46 PM David Marchand
> <david.marchand@redhat.com> wrote:
> >
> > On Fri, Jun 26, 2020 at 2:06 PM Jerin Jacob <jerinjacobk@gmail.com> wrote:
> > >
> > > On Fri, Jun 26, 2020 at 5:13 PM David Marchand
> > > <david.marchand@redhat.com> wrote:
> > > >
> > > > On Fri, Jun 26, 2020 at 1:16 PM Jerin Jacob <jerinjacobk@gmail.com> wrote:
> > > > > > > Alternative is to keep variable declaration outside,
> > > > > > > as David suggested, and I tend to agree that it is a
> > > > > > > bit better. Macro name says 'register'. It is not
> > > > > > > 'declare and register'. Also it avoids static-vs-extern
> > > > > > > problem completely. The solution allows to keep the
> > > > > > > variable declaration untouched and put constructor (macro)
> > > > > > > at the end of fine where constructors typically reside.
> > > > > >
> > > > > > My only concern with that approach is that, We can not save a lot of
> > > > > > code duplication
> > > > > > with that scheme. ie. it is [1] vs [2]. We can change the MACRO name
> > > > > > accordingly if that is a concern. Any suggestions?
> > > > > >
> > > > > > Let me know your preference on [1] vs [2], I will stick with for the
> > > > > > next version.
> > > > >
> > > > > If there are no other comments, I change RTE_LOG_REGISTER to static version
> > > > > and RTE_LOG_REGISTER_EXTERN for a non-static version and send the next version.
> > > >
> > > > - Having a macro that does more than what its name tells is inconvenient.
> > >
> > > I agree. What could be that name if we want to declare and register?
> > > RTE_LOG_DECLARE_AND_REGISTER_EXTERN?
> >
> > (sorry, gmail ctrl+enter ...)
> >
> > Or no declaration in macro and leave code as it is.
>
> Just to understand, Is it some general coding standard? or Just a preference.
> I dont see something like that in the Linux kernel.
> In this patch, http://patches.dpdk.org/patch/69681/, You are proposing
> the declaration in macro.
> See: RTE_TRACE_POINT_REGISTER
>
> I dont see anything wrong with that. Do you have technical rationale
> for the above rule?

David,

Waiting for your feedback on this to send the next version.
If you have a strong preference for keeping declaration out macro then
I will respin the v2 based on that. Let me know.



>
>
> >
> >
> > > > - Having components set log levels at init time in the macro is a bug to me.
> > > > This has been worked around with
> > > > rte_log_register/rte_log_register_and_pick_level but the initial
> > > > problem is that rte_log_set_level* should only be called by the user.
> > >
> > > I agree with the below stuff, That's is not introduced by this patch.
> > > It is already there.
> > > Be it macro or no macro code.
> > >
> > > I think this patch helps to change to new scheme as it takes care of
> > > changing the
> > > registration part to commonplace so that we can set to the same level
> > > in the future if
> > > everyone agrees to it
> >
> > We will still expose this macro meaning that we will have an API breakage later.
> > So if we go with introducing this, let's make it good from the start.
>
> But Is everyone OK with removing the "level" from the register before
> we think about
> breaking the API later?. I see PMD uses multiple levels in the same
> PMD for different
> purposes.
>
>
> >
> >
> > --
> > David Marchand
> >

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

* Re: [dpdk-dev] [PATCH 01/13] eal/log: introduce log register macro
  2020-06-26 12:37                         ` Jerin Jacob
  2020-06-29 13:39                           ` Jerin Jacob
@ 2020-06-30 13:39                           ` David Marchand
  2020-06-30 14:42                             ` Jerin Jacob
  1 sibling, 1 reply; 98+ messages in thread
From: David Marchand @ 2020-06-30 13:39 UTC (permalink / raw)
  To: Jerin Jacob
  Cc: Andrew Rybchenko, Jerin Jacob Kollanukkaran, dev,
	Thomas Monjalon, Olivier Matz

On Fri, Jun 26, 2020 at 2:38 PM Jerin Jacob <jerinjacobk@gmail.com> wrote:
> > Or no declaration in macro and leave code as it is.
>
> I dont see anything wrong with that. Do you have technical rationale
> for the above rule?

Avoid global symbols when unneeded.
Global symbols can be hidden with shared build, but that's not the
case with static build.

This is why we try to maintain a namespace for DPDK api.

For logtypes, a lot of those are already global and nobody complained
about them (lucky ?).

With this patch, the static ones, that we would convert to global
symbols, are the following:
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c:static int
fpga_5gnr_fec_logtype;
drivers/baseband/fpga_lte_fec/fpga_lte_fec.c:static int fpga_lte_fec_logtype;
drivers/baseband/null/bbdev_null.c:static int bbdev_null_logtype;
drivers/baseband/turbo_sw/bbdev_turbo_software.c:static int
bbdev_turbo_sw_logtype;
drivers/net/af_packet/rte_eth_af_packet.c:static int af_packet_logtype;
drivers/net/af_xdp/rte_eth_af_xdp.c:static int af_xdp_logtype;
drivers/net/kni/rte_eth_kni.c:static int eth_kni_logtype;
drivers/net/null/rte_eth_null.c:static int eth_null_logtype;
drivers/net/pcap/rte_eth_pcap.c:static int eth_pcap_logtype;
drivers/net/ring/rte_eth_ring.c:static int eth_ring_logtype;
drivers/net/softnic/rte_eth_softnic.c:static int pmd_softnic_logtype;
drivers/net/vdev_netvsc/vdev_netvsc.c:static int vdev_netvsc_logtype;
drivers/net/vhost/rte_eth_vhost.c:static int vhost_logtype;
drivers/vdpa/ifc/ifcvf_vdpa.c:static int ifcvf_vdpa_logtype;
lib/librte_bbdev/rte_bbdev.c:static int bbdev_logtype;
lib/librte_cfgfile/rte_cfgfile.c:static int cfgfile_logtype;
lib/librte_eventdev/rte_event_timer_adapter.c:static int evtim_logtype;
lib/librte_eventdev/rte_event_timer_adapter.c:static int evtim_buffer_logtype;
lib/librte_eventdev/rte_event_timer_adapter.c:static int evtim_svc_logtype;
lib/librte_pdump/rte_pdump.c:static int pdump_logtype;

All of them follow some kind of convention of finishing with _logtype.
Is this enough and we won't trigger link issues in existing applications?
Probably not possible to tell.

There was a similar discussion with Gaetan in the pci bus code, and so
far we are still in this status quo for global symbols.

So ok, let's go with this embedded global symbol.
If we hit an issue with static linking, we will need a tree-wide cleanup.


> > > > - Having components set log levels at init time in the macro is a bug to me.
> > > > This has been worked around with
> > > > rte_log_register/rte_log_register_and_pick_level but the initial
> > > > problem is that rte_log_set_level* should only be called by the user.
> > >
> > > I agree with the below stuff, That's is not introduced by this patch.
> > > It is already there.
> > > Be it macro or no macro code.
> > >
> > > I think this patch helps to change to new scheme as it takes care of
> > > changing the
> > > registration part to commonplace so that we can set to the same level
> > > in the future if
> > > everyone agrees to it
> >
> > We will still expose this macro meaning that we will have an API breakage later.
> > So if we go with introducing this, let's make it good from the start.
>
> But Is everyone OK with removing the "level" from the register before
> we think about
> breaking the API later?. I see PMD uses multiple levels in the same
> PMD for different
> purposes.

It is an API fix to me, as there should be no place for "level" interpretation.


Just a note, a v2 would be necessary for the
rte_log_register_type_and_pick_level use in any case.

-- 
David Marchand


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

* Re: [dpdk-dev] [PATCH 01/13] eal/log: introduce log register macro
  2020-06-30 13:39                           ` David Marchand
@ 2020-06-30 14:42                             ` Jerin Jacob
  0 siblings, 0 replies; 98+ messages in thread
From: Jerin Jacob @ 2020-06-30 14:42 UTC (permalink / raw)
  To: David Marchand
  Cc: Andrew Rybchenko, Jerin Jacob Kollanukkaran, dev,
	Thomas Monjalon, Olivier Matz

On Tue, Jun 30, 2020 at 7:09 PM David Marchand
<david.marchand@redhat.com> wrote:
>
> On Fri, Jun 26, 2020 at 2:38 PM Jerin Jacob <jerinjacobk@gmail.com> wrote:
> > > Or no declaration in macro and leave code as it is.
> >
> > I dont see anything wrong with that. Do you have technical rationale
> > for the above rule?
>
> Avoid global symbols when unneeded.
> Global symbols can be hidden with shared build, but that's not the
> case with static build.
>
> This is why we try to maintain a namespace for DPDK api.
>
> For logtypes, a lot of those are already global and nobody complained
> about them (lucky ?).
>
> With this patch, the static ones, that we would convert to global
> symbols, are the following:
> drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c:static int
> fpga_5gnr_fec_logtype;
> drivers/baseband/fpga_lte_fec/fpga_lte_fec.c:static int fpga_lte_fec_logtype;
> drivers/baseband/null/bbdev_null.c:static int bbdev_null_logtype;
> drivers/baseband/turbo_sw/bbdev_turbo_software.c:static int
> bbdev_turbo_sw_logtype;
> drivers/net/af_packet/rte_eth_af_packet.c:static int af_packet_logtype;
> drivers/net/af_xdp/rte_eth_af_xdp.c:static int af_xdp_logtype;
> drivers/net/kni/rte_eth_kni.c:static int eth_kni_logtype;
> drivers/net/null/rte_eth_null.c:static int eth_null_logtype;
> drivers/net/pcap/rte_eth_pcap.c:static int eth_pcap_logtype;
> drivers/net/ring/rte_eth_ring.c:static int eth_ring_logtype;
> drivers/net/softnic/rte_eth_softnic.c:static int pmd_softnic_logtype;
> drivers/net/vdev_netvsc/vdev_netvsc.c:static int vdev_netvsc_logtype;
> drivers/net/vhost/rte_eth_vhost.c:static int vhost_logtype;
> drivers/vdpa/ifc/ifcvf_vdpa.c:static int ifcvf_vdpa_logtype;
> lib/librte_bbdev/rte_bbdev.c:static int bbdev_logtype;
> lib/librte_cfgfile/rte_cfgfile.c:static int cfgfile_logtype;
> lib/librte_eventdev/rte_event_timer_adapter.c:static int evtim_logtype;
> lib/librte_eventdev/rte_event_timer_adapter.c:static int evtim_buffer_logtype;
> lib/librte_eventdev/rte_event_timer_adapter.c:static int evtim_svc_logtype;
> lib/librte_pdump/rte_pdump.c:static int pdump_logtype;
>
> All of them follow some kind of convention of finishing with _logtype.
> Is this enough and we won't trigger link issues in existing applications?
> Probably not possible to tell.
>
> There was a similar discussion with Gaetan in the pci bus code, and so
> far we are still in this status quo for global symbols.
>
> So ok, let's go with this embedded global symbol.

OK.

> If we hit an issue with static linking, we will need a tree-wide cleanup.
>
>
> > > > > - Having components set log levels at init time in the macro is a bug to me.
> > > > > This has been worked around with
> > > > > rte_log_register/rte_log_register_and_pick_level but the initial
> > > > > problem is that rte_log_set_level* should only be called by the user.
> > > >
> > > > I agree with the below stuff, That's is not introduced by this patch.
> > > > It is already there.
> > > > Be it macro or no macro code.
> > > >
> > > > I think this patch helps to change to new scheme as it takes care of
> > > > changing the
> > > > registration part to commonplace so that we can set to the same level
> > > > in the future if
> > > > everyone agrees to it
> > >
> > > We will still expose this macro meaning that we will have an API breakage later.
> > > So if we go with introducing this, let's make it good from the start.
> >
> > But Is everyone OK with removing the "level" from the register before
> > we think about
> > breaking the API later?. I see PMD uses multiple levels in the same
> > PMD for different
> > purposes.
>
> It is an API fix to me, as there should be no place for "level" interpretation.
>
>
> Just a note, a v2 would be necessary for the
> rte_log_register_type_and_pick_level use in any case.

I will send v2 with rte_log_register_type_and_pick_level change and
rebase to ToT.

>
> --
> David Marchand
>

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

* [dpdk-dev] [PATCH v2 00/13] rte_log registration usage improvement
  2020-06-17  6:30 [dpdk-dev] [PATCH 00/13] rte_log registration usage improvement jerinj
                   ` (13 preceding siblings ...)
  2020-06-25 16:18 ` [dpdk-dev] [PATCH 00/13] rte_log registration usage improvement Dybkowski, AdamX
@ 2020-07-01  3:58 ` jerinj
  2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 01/13] eal/log: introduce log register macro jerinj
                     ` (13 more replies)
  14 siblings, 14 replies; 98+ messages in thread
From: jerinj @ 2020-07-01  3:58 UTC (permalink / raw)
  To: dev
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

This patch series improves the rte_log registration code snippet by
avoiding duplication of the code around registration by
introducing RTE_LOG_REGISTER macro.


v2:
- RTE_LOG_REGISTER implemented using rte_log_register_type_and_pick_level()
- Added Sachin Saxena <sachin.saxena@oss.nxp.com> and  Adam Dybkowski
<adamx.dybkowski@intel.com> Acks.
- Rebase to ToT


Drivers not adapated to new macro
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I have converted all existing rte_log_register() to new macro, except
the following (as it has different usage style)
1) drivers/common/mlx5/mlx5_common.c
2) drivers/net/e1000/e1000_logs.c
3) drivers/net/sfc/sfc_ethdev.c

Example usage of new macro
~~~~~~~~~~~~~~~~~~~~~~~~~~
-/**
- * @internal
- */
-int otx2_logtype_base;
-/**
- * @internal
- */
-int otx2_logtype_mbox;
-/**
- * @internal
- */
-int otx2_logtype_npa;
-/**
- * @internal
- */
-int otx2_logtype_nix;
-/**
- * @internal
- */
-int otx2_logtype_npc;
-/**
- * @internal
- */
-int otx2_logtype_tm;
-/**
- * @internal
- */
-int otx2_logtype_sso;
-/**
- * @internal
- */
-int otx2_logtype_tim;
-/**
- * @internal
- */
-int otx2_logtype_dpi;
-/**
- * @internal
- */
-int otx2_logtype_ep;
-
-RTE_INIT(otx2_log_init);
-static void
-otx2_log_init(void)
-{
-       otx2_logtype_base = rte_log_register("pmd.octeontx2.base");
-       if (otx2_logtype_base >= 0)
-               rte_log_set_level(otx2_logtype_base, RTE_LOG_NOTICE);
-
-       otx2_logtype_mbox = rte_log_register("pmd.octeontx2.mbox");
-       if (otx2_logtype_mbox >= 0)
-               rte_log_set_level(otx2_logtype_mbox, RTE_LOG_NOTICE);
-
-       otx2_logtype_npa = rte_log_register("pmd.mempool.octeontx2");
-       if (otx2_logtype_npa >= 0)
-               rte_log_set_level(otx2_logtype_npa, RTE_LOG_NOTICE);
-
-       otx2_logtype_nix = rte_log_register("pmd.net.octeontx2");
-       if (otx2_logtype_nix >= 0)
-               rte_log_set_level(otx2_logtype_nix, RTE_LOG_NOTICE);
-
-       otx2_logtype_npc = rte_log_register("pmd.net.octeontx2.flow");
-       if (otx2_logtype_npc >= 0)
-               rte_log_set_level(otx2_logtype_npc, RTE_LOG_NOTICE);
-
-       otx2_logtype_tm = rte_log_register("pmd.net.octeontx2.tm");
-       if (otx2_logtype_tm >= 0)
-               rte_log_set_level(otx2_logtype_tm, RTE_LOG_NOTICE);
-
-       otx2_logtype_sso = rte_log_register("pmd.event.octeontx2");
-       if (otx2_logtype_sso >= 0)
-               rte_log_set_level(otx2_logtype_sso, RTE_LOG_NOTICE);
-
-       otx2_logtype_tim =
        rte_log_register("pmd.event.octeontx2.timer");
-       if (otx2_logtype_tim >= 0)
-               rte_log_set_level(otx2_logtype_tim, RTE_LOG_NOTICE);
-
-       otx2_logtype_dpi = rte_log_register("pmd.raw.octeontx2.dpi");
-       if (otx2_logtype_dpi >= 0)
-               rte_log_set_level(otx2_logtype_dpi, RTE_LOG_NOTICE);
-
-       otx2_logtype_ep = rte_log_register("pmd.raw.octeontx2.ep");
-       if (otx2_logtype_ep >= 0)
-               rte_log_set_level(otx2_logtype_ep, RTE_LOG_NOTICE);
-
-}
+RTE_LOG_REGISTER(otx2_logtype_base, pmd.octeontx2.base, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_mbox, pmd.octeontx2.mbox, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_npa, pmd.mempool.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_nix, pmd.net.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_npc, pmd.net.octeontx2.flow, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_tm, pmd.net.octeontx2.tm, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_sso, pmd.event.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_tim, pmd.event.octeontx2.timer, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_dpi, pmd.raw.octeontx2.dpi, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_ep, pmd.raw.octeontx2.ep, NOTICE);

Jerin Jacob (13):
  eal/log: introduce log register macro
  lib: use log register macro
  drivers/vdpa: use log register macro
  drivers/raw: use log register macro
  drivers/net: use log register macro
  drivers/mempool: use log register macro
  drivers/event: use log register macro
  drivers/crypto: use log register macro
  drivers/compress: use log register macro
  drivers/common: use log register macro
  drivers/bus: use log register macro
  drivers/baseband: use log register macro
  app/test: use log register macro

 app/test/test_efd.c                           |  6 +-
 app/test/test_hash.c                          |  7 +-
 app/test/test_timer_racecond.c                |  7 +-
 .../fpga_5gnr_fec/rte_fpga_5gnr_fec.c         | 17 +---
 drivers/baseband/fpga_lte_fec/fpga_lte_fec.c  | 18 +---
 drivers/baseband/null/bbdev_null.c            |  9 +-
 .../baseband/turbo_sw/bbdev_turbo_software.c  |  9 +-
 drivers/bus/dpaa/dpaa_bus.c                   | 10 +-
 drivers/bus/fslmc/fslmc_bus.c                 | 11 +--
 drivers/bus/ifpga/ifpga_bus.c                 |  9 +-
 drivers/bus/vdev/vdev.c                       | 10 +-
 drivers/bus/vmbus/vmbus_common.c              |  9 +-
 drivers/common/dpaax/dpaax_iova_table.c       | 10 +-
 drivers/common/iavf/iavf_impl.c               |  9 +-
 drivers/common/octeontx/octeontx_mbox.c       |  9 +-
 drivers/common/octeontx2/otx2_common.c        | 96 ++-----------------
 drivers/common/qat/qat_logs.c                 | 17 +---
 drivers/compress/isal/isal_compress_pmd.c     | 10 +-
 drivers/compress/octeontx/otx_zip_pmd.c       | 10 +-
 drivers/compress/zlib/zlib_pmd.c              | 10 +-
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c      |  8 +-
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c    |  8 +-
 drivers/crypto/caam_jr/caam_jr.c              |  8 +-
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c   | 11 +--
 drivers/crypto/dpaa_sec/dpaa_sec.c            | 10 +-
 drivers/crypto/kasumi/rte_kasumi_pmd.c        |  6 +-
 drivers/crypto/mvsam/rte_mrvl_pmd.c           |  7 +-
 drivers/crypto/nitrox/nitrox_logs.c           |  9 +-
 drivers/crypto/null/null_crypto_pmd.c         |  7 +-
 drivers/crypto/octeontx/otx_cryptodev.c       | 10 +-
 drivers/crypto/octeontx2/otx2_cryptodev.c     | 12 +--
 drivers/crypto/openssl/rte_openssl_pmd.c      |  7 +-
 .../scheduler/rte_cryptodev_scheduler.c       |  8 +-
 drivers/crypto/snow3g/rte_snow3g_pmd.c        |  7 +-
 drivers/crypto/virtio/virtio_cryptodev.c      | 39 ++------
 drivers/crypto/zuc/rte_zuc_pmd.c              |  7 +-
 drivers/event/dpaa/dpaa_eventdev.c            |  8 +-
 drivers/event/dpaa2/dpaa2_eventdev.c          | 10 +-
 drivers/event/octeontx/ssovf_evdev.c          |  8 +-
 drivers/event/octeontx/timvf_evdev.c          |  9 +-
 drivers/event/opdl/opdl_evdev.c               |  8 +-
 drivers/event/opdl/opdl_ring.c                |  2 -
 drivers/event/sw/sw_evdev.c                   | 11 +--
 drivers/mempool/dpaa/dpaa_mempool.c           | 10 +-
 drivers/mempool/dpaa2/dpaa2_hw_mempool.c      | 10 +-
 drivers/mempool/octeontx/octeontx_fpavf.c     | 10 +-
 drivers/net/af_packet/rte_eth_af_packet.c     |  8 +-
 drivers/net/af_xdp/rte_eth_af_xdp.c           |  8 +-
 drivers/net/ark/ark_ethdev.c                  | 10 +-
 drivers/net/atlantic/atl_ethdev.c             | 15 +--
 drivers/net/avp/avp_ethdev.c                  | 10 +-
 drivers/net/axgbe/axgbe_ethdev.c              | 15 +--
 drivers/net/bnx2x/bnx2x_ethdev.c              | 15 +--
 drivers/net/bnxt/bnxt_ethdev.c                |  9 +-
 drivers/net/bonding/rte_eth_bond_pmd.c        |  9 +-
 drivers/net/cxgbe/cxgbe_ethdev.c              | 15 +--
 drivers/net/dpaa/dpaa_ethdev.c                |  9 +-
 drivers/net/dpaa2/dpaa2_ethdev.c              |  9 +-
 drivers/net/ena/ena_ethdev.c                  | 48 ++--------
 drivers/net/enetc/enetc_ethdev.c              | 10 +-
 drivers/net/enic/enic_ethdev.c                |  9 +-
 drivers/net/failsafe/failsafe.c               | 10 +-
 drivers/net/fm10k/fm10k_ethdev.c              | 40 +-------
 drivers/net/hinic/hinic_pmd_ethdev.c          | 11 +--
 drivers/net/hns3/hns3_ethdev.c                | 15 +--
 drivers/net/i40e/i40e_ethdev.c                | 38 +-------
 drivers/net/iavf/iavf_ethdev.c                | 40 +-------
 drivers/net/ice/ice_ethdev.c                  | 38 +-------
 drivers/net/igc/igc_logs.c                    | 16 +---
 drivers/net/ionic/ionic_ethdev.c              | 10 +-
 drivers/net/ipn3ke/ipn3ke_ethdev.c            | 10 +-
 drivers/net/ixgbe/ixgbe_ethdev.c              | 39 ++------
 drivers/net/kni/rte_eth_kni.c                 |  9 +-
 drivers/net/liquidio/lio_ethdev.c             | 15 +--
 drivers/net/memif/rte_eth_memif.c             |  9 +-
 drivers/net/mlx4/mlx4.c                       | 11 +--
 drivers/net/mlx5/mlx5.c                       | 10 +-
 drivers/net/mvneta/mvneta_ethdev.c            | 10 +-
 drivers/net/mvpp2/mrvl_ethdev.c               | 10 +-
 drivers/net/netvsc/hn_ethdev.c                | 15 +--
 drivers/net/nfp/nfp_net.c                     | 15 +--
 drivers/net/null/rte_eth_null.c               |  8 +-
 drivers/net/octeontx/octeontx_ethdev.c        | 21 +---
 drivers/net/pcap/rte_eth_pcap.c               |  8 +-
 drivers/net/pfe/pfe_ethdev.c                  | 10 +-
 drivers/net/qede/qede_ethdev.c                | 16 +---
 drivers/net/ring/rte_eth_ring.c               |  8 +-
 drivers/net/softnic/rte_eth_softnic.c         | 10 +-
 drivers/net/szedata2/rte_eth_szedata2.c       | 15 +--
 drivers/net/tap/rte_eth_tap.c                 |  9 +-
 drivers/net/thunderx/nicvf_ethdev.c           | 21 +---
 drivers/net/vdev_netvsc/vdev_netvsc.c         | 13 +--
 drivers/net/vhost/rte_eth_vhost.c             |  8 +-
 drivers/net/virtio/virtio_ethdev.c            | 15 +--
 drivers/net/vmxnet3/vmxnet3_ethdev.c          | 15 +--
 drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c         | 11 +--
 drivers/raw/dpaa2_qdma/dpaa2_qdma.c           | 11 +--
 drivers/raw/ifpga/ifpga_rawdev.c              | 10 +-
 drivers/raw/ioat/ioat_rawdev.c                | 12 +--
 drivers/raw/ioat/rte_ioat_rawdev.h            |  2 -
 drivers/raw/ntb/ntb.c                         | 10 +-
 drivers/raw/skeleton/skeleton_rawdev.c        | 11 +--
 drivers/vdpa/ifc/ifcvf_vdpa.c                 | 10 +-
 drivers/vdpa/mlx5/mlx5_vdpa.c                 |  7 +-
 lib/librte_bbdev/rte_bbdev.c                  |  8 +-
 lib/librte_bpf/bpf.c                          |  9 +-
 lib/librte_cfgfile/rte_cfgfile.c              |  8 +-
 lib/librte_compressdev/rte_compressdev.c      |  7 +-
 lib/librte_compressdev/rte_compressdev_pmd.c  |  2 -
 lib/librte_eal/include/rte_log.h              | 24 +++++
 lib/librte_ethdev/rte_ethdev.c                |  9 +-
 lib/librte_eventdev/rte_event_timer_adapter.c | 21 +---
 lib/librte_flow_classify/rte_flow_classify.c  | 10 +-
 lib/librte_graph/graph.c                      |  7 +-
 lib/librte_member/rte_member.c                |  9 +-
 lib/librte_metrics/rte_metrics_telemetry.c    |  5 +-
 lib/librte_node/log.c                         |  9 +-
 lib/librte_pdump/rte_pdump.c                  |  9 +-
 lib/librte_rawdev/rte_rawdev.c                |  7 +-
 lib/librte_rcu/rte_rcu_qsbr.c                 |  9 +-
 lib/librte_stack/rte_stack.c                  |  7 +-
 lib/librte_vhost/vhost.c                      | 15 +--
 122 files changed, 228 insertions(+), 1321 deletions(-)

-- 
2.27.0


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

* [dpdk-dev] [PATCH v2 01/13] eal/log: introduce log register macro
  2020-07-01  3:58 ` [dpdk-dev] [PATCH v2 " jerinj
@ 2020-07-01  3:58   ` jerinj
  2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 02/13] lib: use " jerinj
                     ` (12 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01  3:58 UTC (permalink / raw)
  To: dev
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Introducing the RTE_LOG_REGISTER macro to avoid the code duplication
in the log registration process.

It is a wrapper macro for declaring the logtype, register the log and sets
it's level in the constructor context.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 lib/librte_eal/include/rte_log.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/lib/librte_eal/include/rte_log.h b/lib/librte_eal/include/rte_log.h
index 1789ede56..eaf66e4f6 100644
--- a/lib/librte_eal/include/rte_log.h
+++ b/lib/librte_eal/include/rte_log.h
@@ -376,6 +376,30 @@ int rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap)
 		 RTE_LOGTYPE_ ## t, # t ": " __VA_ARGS__) :	\
 	 0)
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Register a dynamic log type in constructor context with its name and level.
+ *
+ * It is a wrapper macro for declaring the logtype, register the log and
+ * sets it's level in the constructor context.
+ *
+ * @param type
+ *   The log type identifier
+ * @param name
+ *    Name for the log type to be registered
+ * @param level
+ *   Log level. A value between EMERG (1) and DEBUG (8).
+ */
+#define RTE_LOG_REGISTER(type, name, level)				\
+int type;								\
+RTE_INIT(__##type)							\
+{									\
+	type = rte_log_register_type_and_pick_level(RTE_STR(name),	\
+						    RTE_LOG_##level);	\
+}
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.27.0


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

* [dpdk-dev]  [PATCH v2 02/13] lib: use log register macro
  2020-07-01  3:58 ` [dpdk-dev] [PATCH v2 " jerinj
  2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 01/13] eal/log: introduce log register macro jerinj
@ 2020-07-01  3:58   ` jerinj
  2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 03/13] drivers/vdpa: " jerinj
                     ` (11 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01  3:58 UTC (permalink / raw)
  To: dev, Nicolas Chautru, Konstantin Ananyev, Cristian Dumitrescu,
	Fiona Trahe, Ashish Gupta, Thomas Monjalon, Ferruh Yigit,
	Andrew Rybchenko, Erik Gabriel Carrillo, Jerin Jacob,
	Bernard Iremonger, Kiran Kumar K, Nithin Dabilpuram, Yipeng Wang,
	Sameh Gobriel, Pavan Nikhilesh, Reshma Pattan, Nipun Gupta,
	Hemant Agrawal, Honnappa Nagarahalli, Gage Eads, Olivier Matz,
	Maxime Coquelin, Zhihong Wang, Xiaolong Ye
  Cc: david.marchand, sachin.saxena, adamx.dybkowski

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 lib/librte_bbdev/rte_bbdev.c                  |  8 +------
 lib/librte_bpf/bpf.c                          |  9 +-------
 lib/librte_cfgfile/rte_cfgfile.c              |  8 +------
 lib/librte_compressdev/rte_compressdev.c      |  7 +------
 lib/librte_compressdev/rte_compressdev_pmd.c  |  2 --
 lib/librte_ethdev/rte_ethdev.c                |  9 +++-----
 lib/librte_eventdev/rte_event_timer_adapter.c | 21 +++----------------
 lib/librte_flow_classify/rte_flow_classify.c  | 10 +--------
 lib/librte_graph/graph.c                      |  7 +------
 lib/librte_member/rte_member.c                |  9 +-------
 lib/librte_metrics/rte_metrics_telemetry.c    |  5 ++---
 lib/librte_node/log.c                         |  9 +-------
 lib/librte_pdump/rte_pdump.c                  |  9 ++------
 lib/librte_rawdev/rte_rawdev.c                |  7 +++----
 lib/librte_rcu/rte_rcu_qsbr.c                 |  9 +-------
 lib/librte_stack/rte_stack.c                  |  7 +------
 lib/librte_vhost/vhost.c                      | 15 ++-----------
 17 files changed, 25 insertions(+), 126 deletions(-)

diff --git a/lib/librte_bbdev/rte_bbdev.c b/lib/librte_bbdev/rte_bbdev.c
index f6fe05aca..578f44484 100644
--- a/lib/librte_bbdev/rte_bbdev.c
+++ b/lib/librte_bbdev/rte_bbdev.c
@@ -29,7 +29,7 @@
 
 
 /* BBDev library logging ID */
-static int bbdev_logtype;
+RTE_LOG_REGISTER(bbdev_logtype, lib.bbdev, NOTICE);
 
 /* Helper macro for logging */
 #define rte_bbdev_log(level, fmt, ...) \
@@ -1134,9 +1134,3 @@ rte_bbdev_op_type_str(enum rte_bbdev_op_type op_type)
 	return NULL;
 }
 
-RTE_INIT(rte_bbdev_init_log)
-{
-	bbdev_logtype = rte_log_register("lib.bbdev");
-	if (bbdev_logtype >= 0)
-		rte_log_set_level(bbdev_logtype, RTE_LOG_NOTICE);
-}
diff --git a/lib/librte_bpf/bpf.c b/lib/librte_bpf/bpf.c
index 7e1879ffa..8d15885bc 100644
--- a/lib/librte_bpf/bpf.c
+++ b/lib/librte_bpf/bpf.c
@@ -14,8 +14,6 @@
 
 #include "bpf_impl.h"
 
-int rte_bpf_logtype;
-
 void
 rte_bpf_destroy(struct rte_bpf *bpf)
 {
@@ -55,9 +53,4 @@ bpf_jit(struct rte_bpf *bpf)
 	return rc;
 }
 
-RTE_INIT(rte_bpf_init_log)
-{
-	rte_bpf_logtype = rte_log_register("lib.bpf");
-	if (rte_bpf_logtype >= 0)
-		rte_log_set_level(rte_bpf_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(rte_bpf_logtype, lib.bpf, INFO);
diff --git a/lib/librte_cfgfile/rte_cfgfile.c b/lib/librte_cfgfile/rte_cfgfile.c
index 714717dd9..876c10d17 100644
--- a/lib/librte_cfgfile/rte_cfgfile.c
+++ b/lib/librte_cfgfile/rte_cfgfile.c
@@ -27,7 +27,7 @@ struct rte_cfgfile {
 	struct rte_cfgfile_section *sections;
 };
 
-static int cfgfile_logtype;
+RTE_LOG_REGISTER(cfgfile_logtype, lib.cfgfile, INFO);
 
 #define CFG_LOG(level, fmt, args...)					\
 	rte_log(RTE_LOG_ ## level, cfgfile_logtype, "%s(): " fmt "\n",	\
@@ -567,9 +567,3 @@ rte_cfgfile_has_entry(struct rte_cfgfile *cfg, const char *sectionname,
 	return rte_cfgfile_get_entry(cfg, sectionname, entryname) != NULL;
 }
 
-RTE_INIT(cfgfile_init)
-{
-	cfgfile_logtype = rte_log_register("lib.cfgfile");
-	if (cfgfile_logtype >= 0)
-		rte_log_set_level(cfgfile_logtype, RTE_LOG_INFO);
-}
diff --git a/lib/librte_compressdev/rte_compressdev.c b/lib/librte_compressdev/rte_compressdev.c
index b3c5651dc..49a342f40 100644
--- a/lib/librte_compressdev/rte_compressdev.c
+++ b/lib/librte_compressdev/rte_compressdev.c
@@ -763,9 +763,4 @@ rte_compressdev_name_get(uint8_t dev_id)
 	return dev->data->name;
 }
 
-RTE_INIT(rte_compressdev_log)
-{
-	compressdev_logtype = rte_log_register("lib.compressdev");
-	if (compressdev_logtype >= 0)
-		rte_log_set_level(compressdev_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(compressdev_logtype, lib.compressdev, NOTICE);
diff --git a/lib/librte_compressdev/rte_compressdev_pmd.c b/lib/librte_compressdev/rte_compressdev_pmd.c
index 46b25565a..7f500d76d 100644
--- a/lib/librte_compressdev/rte_compressdev_pmd.c
+++ b/lib/librte_compressdev/rte_compressdev_pmd.c
@@ -10,8 +10,6 @@
 #include "rte_compressdev_internal.h"
 #include "rte_compressdev_pmd.h"
 
-int compressdev_logtype;
-
 /**
  * Parse name from argument
  */
diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 8e10a6fc3..d06b7f9b1 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -46,8 +46,6 @@
 #include "ethdev_profile.h"
 #include "ethdev_private.h"
 
-int rte_eth_dev_logtype;
-
 static const char *MZ_RTE_ETH_DEV_DATA = "rte_eth_dev_data";
 struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS];
 
@@ -5295,11 +5293,10 @@ handle_port_link_status(const char *cmd __rte_unused,
 	return 0;
 }
 
-RTE_INIT(ethdev_init_log)
+RTE_LOG_REGISTER(rte_eth_dev_logtype, lib.ethdev, INFO);
+
+RTE_INIT(ethdev_init_telemetry)
 {
-	rte_eth_dev_logtype = rte_log_register("lib.ethdev");
-	if (rte_eth_dev_logtype >= 0)
-		rte_log_set_level(rte_eth_dev_logtype, RTE_LOG_INFO);
 	rte_telemetry_register_cmd("/ethdev/list", handle_port_list,
 			"Returns list of available ethdev ports. Takes no parameters");
 	rte_telemetry_register_cmd("/ethdev/xstats", handle_port_xstats,
diff --git a/lib/librte_eventdev/rte_event_timer_adapter.c b/lib/librte_eventdev/rte_event_timer_adapter.c
index 005459f7d..ae68b4566 100644
--- a/lib/librte_eventdev/rte_event_timer_adapter.c
+++ b/lib/librte_eventdev/rte_event_timer_adapter.c
@@ -29,9 +29,9 @@
 #define DATA_MZ_NAME_MAX_LEN 64
 #define DATA_MZ_NAME_FORMAT "rte_event_timer_adapter_data_%d"
 
-static int evtim_logtype;
-static int evtim_svc_logtype;
-static int evtim_buffer_logtype;
+RTE_LOG_REGISTER(evtim_logtype, lib.eventdev.adapter.timer, NOTICE);
+RTE_LOG_REGISTER(evtim_buffer_logtype, lib.eventdev.adapter.timer, NOTICE);
+RTE_LOG_REGISTER(evtim_svc_logtype, lib.eventdev.adapter.timer.svc, NOTICE);
 
 static struct rte_event_timer_adapter adapters[RTE_EVENT_TIMER_ADAPTER_NUM_MAX];
 
@@ -1188,18 +1188,3 @@ static const struct rte_event_timer_adapter_ops swtim_ops = {
 	.cancel_burst		= swtim_cancel_burst,
 };
 
-RTE_INIT(event_timer_adapter_init_log)
-{
-	evtim_logtype = rte_log_register("lib.eventdev.adapter.timer");
-	if (evtim_logtype >= 0)
-		rte_log_set_level(evtim_logtype, RTE_LOG_NOTICE);
-
-	evtim_buffer_logtype = rte_log_register("lib.eventdev.adapter.timer."
-						"buffer");
-	if (evtim_buffer_logtype >= 0)
-		rte_log_set_level(evtim_buffer_logtype, RTE_LOG_NOTICE);
-
-	evtim_svc_logtype = rte_log_register("lib.eventdev.adapter.timer.svc");
-	if (evtim_svc_logtype >= 0)
-		rte_log_set_level(evtim_svc_logtype, RTE_LOG_NOTICE);
-}
diff --git a/lib/librte_flow_classify/rte_flow_classify.c b/lib/librte_flow_classify/rte_flow_classify.c
index 6022064d8..639b0051f 100644
--- a/lib/librte_flow_classify/rte_flow_classify.c
+++ b/lib/librte_flow_classify/rte_flow_classify.c
@@ -10,8 +10,6 @@
 #include <rte_table_acl.h>
 #include <stdbool.h>
 
-int librte_flow_classify_logtype;
-
 static uint32_t unique_id = 1;
 
 enum rte_flow_classify_table_type table_type
@@ -669,10 +667,4 @@ rte_flow_classifier_query(struct rte_flow_classifier *cls,
 	return ret;
 }
 
-RTE_INIT(librte_flow_classify_init_log)
-{
-	librte_flow_classify_logtype =
-		rte_log_register("lib.flow_classify");
-	if (librte_flow_classify_logtype >= 0)
-		rte_log_set_level(librte_flow_classify_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(librte_flow_classify_logtype, lib.flow_classify, INFO);
diff --git a/lib/librte_graph/graph.c b/lib/librte_graph/graph.c
index 0ea83df3d..baa383cd7 100644
--- a/lib/librte_graph/graph.c
+++ b/lib/librte_graph/graph.c
@@ -579,9 +579,4 @@ rte_graph_max_count(void)
 	return graph_id;
 }
 
-RTE_INIT(rte_graph_init_log)
-{
-	rte_graph_logtype = rte_log_register("lib.graph");
-	if (rte_graph_logtype >= 0)
-		rte_log_set_level(rte_graph_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(rte_graph_logtype, lib.graph, INFO);
diff --git a/lib/librte_member/rte_member.c b/lib/librte_member/rte_member.c
index e0e7f127e..4696c0f17 100644
--- a/lib/librte_member/rte_member.c
+++ b/lib/librte_member/rte_member.c
@@ -16,8 +16,6 @@
 #include "rte_member_ht.h"
 #include "rte_member_vbf.h"
 
-int librte_member_logtype;
-
 TAILQ_HEAD(rte_member_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_member_tailq = {
 	.name = "RTE_MEMBER",
@@ -299,9 +297,4 @@ rte_member_reset(const struct rte_member_setsum *setsum)
 	}
 }
 
-RTE_INIT(librte_member_init_log)
-{
-	librte_member_logtype = rte_log_register("lib.member");
-	if (librte_member_logtype >= 0)
-		rte_log_set_level(librte_member_logtype, RTE_LOG_DEBUG);
-}
+RTE_LOG_REGISTER(librte_member_logtype, lib.member, DEBUG);
diff --git a/lib/librte_metrics/rte_metrics_telemetry.c b/lib/librte_metrics/rte_metrics_telemetry.c
index 040e87d18..289ebae0b 100644
--- a/lib/librte_metrics/rte_metrics_telemetry.c
+++ b/lib/librte_metrics/rte_metrics_telemetry.c
@@ -525,6 +525,8 @@ handle_ports_stats_values_by_name(const char *cmd __rte_unused,
 	return used;
 }
 
+RTE_LOG_REGISTER(metrics_log_level, lib.metrics, ERR);
+
 RTE_INIT(metrics_ctor)
 {
 #ifdef RTE_LIBRTE_TELEMETRY
@@ -535,7 +537,4 @@ RTE_INIT(metrics_ctor)
 	rte_telemetry_legacy_register("ports_stats_values_by_name", DATA_REQ,
 			handle_ports_stats_values_by_name);
 #endif
-	metrics_log_level = rte_log_register("lib.metrics");
-	if (metrics_log_level >= 0)
-		rte_log_set_level(metrics_log_level, RTE_LOG_ERR);
 }
diff --git a/lib/librte_node/log.c b/lib/librte_node/log.c
index f035f91e8..f14199f07 100644
--- a/lib/librte_node/log.c
+++ b/lib/librte_node/log.c
@@ -4,11 +4,4 @@
 
 #include "node_private.h"
 
-int rte_node_logtype;
-
-RTE_INIT(rte_node_init_log)
-{
-	rte_node_logtype = rte_log_register("lib.node");
-	if (rte_node_logtype >= 0)
-		rte_log_set_level(rte_node_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(rte_node_logtype, lib.node, INFO);
diff --git a/lib/librte_pdump/rte_pdump.c b/lib/librte_pdump/rte_pdump.c
index f96709f95..5016e9dd2 100644
--- a/lib/librte_pdump/rte_pdump.c
+++ b/lib/librte_pdump/rte_pdump.c
@@ -14,8 +14,9 @@
 
 #define DEVICE_ID_SIZE 64
 
+RTE_LOG_REGISTER(pdump_logtype, lib.pdump, NOTICE);
+
 /* Macro for printing using RTE_LOG */
-static int pdump_logtype;
 #define PDUMP_LOG(level, fmt, args...)				\
 	rte_log(RTE_LOG_ ## level, pdump_logtype, "%s(): " fmt,	\
 		__func__, ## args)
@@ -561,9 +562,3 @@ rte_pdump_disable_by_deviceid(char *device_id, uint16_t queue,
 	return ret;
 }
 
-RTE_INIT(pdump_log)
-{
-	pdump_logtype = rte_log_register("lib.pdump");
-	if (pdump_logtype >= 0)
-		rte_log_set_level(pdump_logtype, RTE_LOG_NOTICE);
-}
diff --git a/lib/librte_rawdev/rte_rawdev.c b/lib/librte_rawdev/rte_rawdev.c
index c332a7648..aec61f425 100644
--- a/lib/librte_rawdev/rte_rawdev.c
+++ b/lib/librte_rawdev/rte_rawdev.c
@@ -613,11 +613,10 @@ handle_dev_xstats(const char *cmd __rte_unused,
 	return 0;
 }
 
-RTE_INIT(librawdev_init_log)
+RTE_LOG_REGISTER(librawdev_logtype, lib.rawdev, INFO);
+
+RTE_INIT(librawdev_init_telemetry)
 {
-	librawdev_logtype = rte_log_register("lib.rawdev");
-	if (librawdev_logtype >= 0)
-		rte_log_set_level(librawdev_logtype, RTE_LOG_INFO);
 	rte_telemetry_register_cmd("/rawdev/list", handle_dev_list,
 			"Returns list of available rawdev ports. Takes no parameters");
 	rte_telemetry_register_cmd("/rawdev/xstats", handle_dev_xstats,
diff --git a/lib/librte_rcu/rte_rcu_qsbr.c b/lib/librte_rcu/rte_rcu_qsbr.c
index 6a429d8b3..aebfdb0da 100644
--- a/lib/librte_rcu/rte_rcu_qsbr.c
+++ b/lib/librte_rcu/rte_rcu_qsbr.c
@@ -495,11 +495,4 @@ rte_rcu_qsbr_dq_delete(struct rte_rcu_qsbr_dq *dq)
 	return 0;
 }
 
-int rte_rcu_log_type;
-
-RTE_INIT(rte_rcu_register)
-{
-	rte_rcu_log_type = rte_log_register("lib.rcu");
-	if (rte_rcu_log_type >= 0)
-		rte_log_set_level(rte_rcu_log_type, RTE_LOG_ERR);
-}
+RTE_LOG_REGISTER(rte_rcu_log_type, lib.rcu, ERR);
diff --git a/lib/librte_stack/rte_stack.c b/lib/librte_stack/rte_stack.c
index e58fa545f..e4c0ce131 100644
--- a/lib/librte_stack/rte_stack.c
+++ b/lib/librte_stack/rte_stack.c
@@ -194,9 +194,4 @@ rte_stack_lookup(const char *name)
 	return r;
 }
 
-RTE_INIT(librte_stack_init_log)
-{
-	stack_logtype = rte_log_register("lib.stack");
-	if (stack_logtype >= 0)
-		rte_log_set_level(stack_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(stack_logtype, lib.stack, NOTICE);
diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
index 026631844..872d57f61 100644
--- a/lib/librte_vhost/vhost.c
+++ b/lib/librte_vhost/vhost.c
@@ -27,9 +27,6 @@
 
 struct virtio_net *vhost_devices[MAX_VHOST_DEVICE];
 
-int vhost_config_log_level;
-int vhost_data_log_level;
-
 /* Called with iotlb_lock read-locked */
 uint64_t
 __vhost_iova_to_vva(struct virtio_net *dev, struct vhost_virtqueue *vq,
@@ -1517,13 +1514,5 @@ int rte_vhost_extern_callback_register(int vid,
 	return 0;
 }
 
-RTE_INIT(vhost_log_init)
-{
-	vhost_config_log_level = rte_log_register("lib.vhost.config");
-	if (vhost_config_log_level >= 0)
-		rte_log_set_level(vhost_config_log_level, RTE_LOG_INFO);
-
-	vhost_data_log_level = rte_log_register("lib.vhost.data");
-	if (vhost_data_log_level >= 0)
-		rte_log_set_level(vhost_data_log_level, RTE_LOG_WARNING);
-}
+RTE_LOG_REGISTER(vhost_config_log_level, lib.vhost.config, INFO);
+RTE_LOG_REGISTER(vhost_data_log_level, lib.vhost.data, WARNING);
-- 
2.27.0


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

* [dpdk-dev]  [PATCH v2 03/13] drivers/vdpa: use log register macro
  2020-07-01  3:58 ` [dpdk-dev] [PATCH v2 " jerinj
  2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 01/13] eal/log: introduce log register macro jerinj
  2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 02/13] lib: use " jerinj
@ 2020-07-01  3:58   ` jerinj
  2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 04/13] drivers/raw: " jerinj
                     ` (10 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01  3:58 UTC (permalink / raw)
  To: dev, Xiao Wang, Matan Azrad, Viacheslav Ovsiienko
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/vdpa/ifc/ifcvf_vdpa.c | 10 +---------
 drivers/vdpa/mlx5/mlx5_vdpa.c |  7 +++----
 2 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
index ec97178dc..78299fa67 100644
--- a/drivers/vdpa/ifc/ifcvf_vdpa.c
+++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
@@ -24,6 +24,7 @@
 
 #include "base/ifcvf.h"
 
+RTE_LOG_REGISTER(ifcvf_vdpa_logtype, pmd.net.ifcvf_vdpa, NOTICE);
 #define DRV_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, ifcvf_vdpa_logtype, \
 		"IFCVF %s(): " fmt "\n", __func__, ##args)
@@ -44,8 +45,6 @@ static const char * const ifcvf_valid_arguments[] = {
 	NULL
 };
 
-static int ifcvf_vdpa_logtype;
-
 struct ifcvf_internal {
 	struct rte_vdpa_dev_addr dev_addr;
 	struct rte_pci_device *pdev;
@@ -1271,10 +1270,3 @@ static struct rte_pci_driver rte_ifcvf_vdpa = {
 RTE_PMD_REGISTER_PCI(net_ifcvf, rte_ifcvf_vdpa);
 RTE_PMD_REGISTER_PCI_TABLE(net_ifcvf, pci_id_ifcvf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_ifcvf, "* vfio-pci");
-
-RTE_INIT(ifcvf_vdpa_init_log)
-{
-	ifcvf_vdpa_logtype = rte_log_register("pmd.net.ifcvf_vdpa");
-	if (ifcvf_vdpa_logtype >= 0)
-		rte_log_set_level(ifcvf_vdpa_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c
index 1113d6cef..b166207c4 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa.c
@@ -608,15 +608,14 @@ static struct rte_pci_driver mlx5_vdpa_driver = {
 	.drv_flags = 0,
 };
 
+
+RTE_LOG_REGISTER(mlx5_vdpa_logtype, pmd.vdpa.mlx5, NOTICE);
+
 /**
  * Driver initialization routine.
  */
 RTE_INIT(rte_mlx5_vdpa_init)
 {
-	/* Initialize common log type. */
-	mlx5_vdpa_logtype = rte_log_register("pmd.vdpa.mlx5");
-	if (mlx5_vdpa_logtype >= 0)
-		rte_log_set_level(mlx5_vdpa_logtype, RTE_LOG_NOTICE);
 	if (mlx5_glue)
 		rte_pci_register(&mlx5_vdpa_driver);
 }
-- 
2.27.0


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

* [dpdk-dev]  [PATCH v2 04/13] drivers/raw: use log register macro
  2020-07-01  3:58 ` [dpdk-dev] [PATCH v2 " jerinj
                     ` (2 preceding siblings ...)
  2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 03/13] drivers/vdpa: " jerinj
@ 2020-07-01  3:58   ` jerinj
  2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 05/13] drivers/net: " jerinj
                     ` (9 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01  3:58 UTC (permalink / raw)
  To: dev, Nipun Gupta, Rosen Xu, Tianfei zhang, Bruce Richardson,
	Xiaoyun Li, Jingjing Wu, Hemant Agrawal
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c  | 11 +----------
 drivers/raw/dpaa2_qdma/dpaa2_qdma.c    | 11 +----------
 drivers/raw/ifpga/ifpga_rawdev.c       | 10 +---------
 drivers/raw/ioat/ioat_rawdev.c         | 12 ++----------
 drivers/raw/ioat/rte_ioat_rawdev.h     |  2 --
 drivers/raw/ntb/ntb.c                  | 10 +---------
 drivers/raw/skeleton/skeleton_rawdev.c | 11 +----------
 7 files changed, 7 insertions(+), 60 deletions(-)

diff --git a/drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c b/drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c
index 7c21c6a52..c7bddbc6c 100644
--- a/drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c
+++ b/drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c
@@ -20,9 +20,6 @@
 #include "dpaa2_cmdif_logs.h"
 #include "rte_pmd_dpaa2_cmdif.h"
 
-/* Dynamic log type identifier */
-int dpaa2_cmdif_logtype;
-
 /* CMDIF driver name */
 #define DPAA2_CMDIF_PMD_NAME dpaa2_dpci
 
@@ -291,10 +288,4 @@ static struct rte_vdev_driver dpaa2_cmdif_drv = {
 };
 
 RTE_PMD_REGISTER_VDEV(DPAA2_CMDIF_PMD_NAME, dpaa2_cmdif_drv);
-
-RTE_INIT(dpaa2_cmdif_init_log)
-{
-	dpaa2_cmdif_logtype = rte_log_register("pmd.raw.dpaa2.cmdif");
-	if (dpaa2_cmdif_logtype >= 0)
-		rte_log_set_level(dpaa2_cmdif_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(dpaa2_cmdif_logtype, pmd.raw.dpaa2.cmdif, INFO);
diff --git a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
index 1be1b6ddf..0b9c4e3d7 100644
--- a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
+++ b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
@@ -26,9 +26,6 @@
 
 #define DPAA2_QDMA_NO_PREFETCH "no_prefetch"
 
-/* Dynamic log type identifier */
-int dpaa2_qdma_logtype;
-
 uint32_t dpaa2_coherent_no_alloc_cache;
 uint32_t dpaa2_coherent_alloc_cache;
 
@@ -1495,10 +1492,4 @@ static struct rte_dpaa2_driver rte_dpaa2_qdma_pmd = {
 RTE_PMD_REGISTER_DPAA2(dpaa2_qdma, rte_dpaa2_qdma_pmd);
 RTE_PMD_REGISTER_PARAM_STRING(dpaa2_qdma,
 	"no_prefetch=<int> ");
-
-RTE_INIT(dpaa2_qdma_init_log)
-{
-	dpaa2_qdma_logtype = rte_log_register("pmd.raw.dpaa2.qdma");
-	if (dpaa2_qdma_logtype >= 0)
-		rte_log_set_level(dpaa2_qdma_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(dpaa2_qdma_logtype, pmd.raw.dpaa2.qdma, INFO);
diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c
index b8701e155..cc25c662b 100644
--- a/drivers/raw/ifpga/ifpga_rawdev.c
+++ b/drivers/raw/ifpga/ifpga_rawdev.c
@@ -47,8 +47,6 @@
 #define RTE_PCI_EXT_CAP_ID(header)       (int)(header & 0x0000ffff)
 #define RTE_PCI_EXT_CAP_NEXT(header)     ((header >> 20) & 0xffc)
 
-int ifpga_rawdev_logtype;
-
 #define PCI_VENDOR_ID_INTEL          0x8086
 /* PCI Device ID */
 #define PCIE_DEVICE_ID_PF_INT_5_X    0xBCBD
@@ -1597,13 +1595,7 @@ static struct rte_pci_driver rte_ifpga_rawdev_pmd = {
 RTE_PMD_REGISTER_PCI(ifpga_rawdev_pci_driver, rte_ifpga_rawdev_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(ifpga_rawdev_pci_driver, rte_ifpga_rawdev_pmd);
 RTE_PMD_REGISTER_KMOD_DEP(ifpga_rawdev_pci_driver, "* igb_uio | uio_pci_generic | vfio-pci");
-
-RTE_INIT(ifpga_rawdev_init_log)
-{
-	ifpga_rawdev_logtype = rte_log_register("driver.raw.init");
-	if (ifpga_rawdev_logtype >= 0)
-		rte_log_set_level(ifpga_rawdev_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(ifpga_rawdev_logtype, driver.raw.init, NOTICE);
 
 static const char * const valid_args[] = {
 #define IFPGA_ARG_NAME         "ifpga"
diff --git a/drivers/raw/ioat/ioat_rawdev.c b/drivers/raw/ioat/ioat_rawdev.c
index a8a48f90a..30d9f597e 100644
--- a/drivers/raw/ioat/ioat_rawdev.c
+++ b/drivers/raw/ioat/ioat_rawdev.c
@@ -9,9 +9,6 @@
 
 #include "rte_ioat_rawdev.h"
 
-/* Dynamic log type identifier */
-int ioat_pmd_logtype;
-
 static struct rte_pci_driver ioat_pmd_drv;
 
 #define IOAT_VENDOR_ID		0x8086
@@ -28,6 +25,8 @@ static struct rte_pci_driver ioat_pmd_drv;
 #define IOAT_DEVICE_ID_BDXF	0x6f2F
 #define IOAT_DEVICE_ID_ICX	0x0b00
 
+RTE_LOG_REGISTER(ioat_pmd_logtype,  rawdev.ioat, INFO);
+
 #define IOAT_PMD_LOG(level, fmt, args...) rte_log(RTE_LOG_ ## level, \
 	ioat_pmd_logtype, "%s(): " fmt "\n", __func__, ##args)
 
@@ -386,10 +385,3 @@ static struct rte_pci_driver ioat_pmd_drv = {
 RTE_PMD_REGISTER_PCI(IOAT_PMD_RAWDEV_NAME, ioat_pmd_drv);
 RTE_PMD_REGISTER_PCI_TABLE(IOAT_PMD_RAWDEV_NAME, pci_id_ioat_map);
 RTE_PMD_REGISTER_KMOD_DEP(IOAT_PMD_RAWDEV_NAME, "* igb_uio | uio_pci_generic");
-
-RTE_INIT(ioat_pmd_init_log)
-{
-	ioat_pmd_logtype = rte_log_register(IOAT_PMD_LOG_NAME);
-	if (ioat_pmd_logtype >= 0)
-		rte_log_set_level(ioat_pmd_logtype, RTE_LOG_INFO);
-}
diff --git a/drivers/raw/ioat/rte_ioat_rawdev.h b/drivers/raw/ioat/rte_ioat_rawdev.h
index 4b271f174..f765a6557 100644
--- a/drivers/raw/ioat/rte_ioat_rawdev.h
+++ b/drivers/raw/ioat/rte_ioat_rawdev.h
@@ -25,8 +25,6 @@
 #define IOAT_PMD_RAWDEV_NAME rawdev_ioat
 /** String reported as the device driver name by rte_rawdev_info_get() */
 #define IOAT_PMD_RAWDEV_NAME_STR "rawdev_ioat"
-/** Name used to adjust the log level for this driver */
-#define IOAT_PMD_LOG_NAME "rawdev.ioat"
 
 /**
  * Configuration structure for an ioat rawdev instance
diff --git a/drivers/raw/ntb/ntb.c b/drivers/raw/ntb/ntb.c
index dd0b72f8c..e40412bb7 100644
--- a/drivers/raw/ntb/ntb.c
+++ b/drivers/raw/ntb/ntb.c
@@ -23,8 +23,6 @@
 #include "rte_pmd_ntb.h"
 #include "ntb.h"
 
-int ntb_logtype;
-
 static const struct rte_pci_id pci_id_ntb_map[] = {
 	{ RTE_PCI_DEVICE(NTB_INTEL_VENDOR_ID, NTB_INTEL_DEV_ID_B2B_SKX) },
 	{ .vendor_id = 0, /* sentinel */ },
@@ -1504,10 +1502,4 @@ static struct rte_pci_driver rte_ntb_pmd = {
 RTE_PMD_REGISTER_PCI(raw_ntb, rte_ntb_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(raw_ntb, pci_id_ntb_map);
 RTE_PMD_REGISTER_KMOD_DEP(raw_ntb, "* igb_uio | uio_pci_generic | vfio-pci");
-
-RTE_INIT(ntb_init_log)
-{
-	ntb_logtype = rte_log_register("pmd.raw.ntb");
-	if (ntb_logtype >= 0)
-		rte_log_set_level(ntb_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(ntb_logtype, pmd.raw.ntb, INFO);
diff --git a/drivers/raw/skeleton/skeleton_rawdev.c b/drivers/raw/skeleton/skeleton_rawdev.c
index 586183a5b..72ece887a 100644
--- a/drivers/raw/skeleton/skeleton_rawdev.c
+++ b/drivers/raw/skeleton/skeleton_rawdev.c
@@ -28,9 +28,6 @@
 
 #include "skeleton_rawdev.h"
 
-/* Dynamic log type identifier */
-int skeleton_pmd_logtype;
-
 /* Count of instances */
 static uint16_t skeldev_init_once;
 
@@ -759,10 +756,4 @@ static struct rte_vdev_driver skeleton_pmd_drv = {
 };
 
 RTE_PMD_REGISTER_VDEV(SKELETON_PMD_RAWDEV_NAME, skeleton_pmd_drv);
-
-RTE_INIT(skeleton_pmd_init_log)
-{
-	skeleton_pmd_logtype = rte_log_register("rawdev.skeleton");
-	if (skeleton_pmd_logtype >= 0)
-		rte_log_set_level(skeleton_pmd_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(skeleton_pmd_logtype, rawdev.skeleton, INFO);
-- 
2.27.0


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

* [dpdk-dev]  [PATCH v2 05/13] drivers/net: use log register macro
  2020-07-01  3:58 ` [dpdk-dev] [PATCH v2 " jerinj
                     ` (3 preceding siblings ...)
  2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 04/13] drivers/raw: " jerinj
@ 2020-07-01  3:58   ` jerinj
  2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 06/13] drivers/mempool: " jerinj
                     ` (8 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01  3:58 UTC (permalink / raw)
  To: dev, John W. Linville, Xiaolong Ye, Qi Zhang, Shepard Siegel,
	Ed Czeck, John Miller, Igor Russkikh, Pavel Belous,
	Steven Webster, Matt Peters, Somalapuram Amaranath, Rasesh Mody,
	Shahed Shaikh, Ajit Khaparde, Somnath Kotur, Chas Williams,
	Wei Hu (Xavier),
	Rahul Lakkireddy, Hemant Agrawal, Sachin Saxena, Marcin Wojtas,
	Michal Krawczyk, Guy Tzalik, Evgeny Schemeilin, Igor Chauskin,
	Gagandeep Singh, John Daley, Hyong Youb Kim, Gaetan Rivet,
	Xiao Wang, Ziyang Xuan, Xiaoyun Wang, Guoyang Zhou,
	Min Hu (Connor),
	Yisen Zhuang, Beilei Xing, Jeff Guo, Jingjing Wu, Qiming Yang,
	Wei Zhao, Alfredo Cardigliano, Rosen Xu, Ferruh Yigit,
	Shijith Thotton, Srisivasubramanian Srinivasan, Jakub Grajciar,
	Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko, Zyta Szpak,
	Liron Himi, Stephen Hemminger, K. Y. Srinivasan, Haiyang Zhang,
	Heinrich Kuhn, Tetsuya Mukawa, Harman Kalra, Akhil Goyal,
	Bruce Richardson, Jasvinder Singh, Cristian Dumitrescu,
	Martin Zizka, Jakub Neruda, Keith Wiles, Jerin Jacob,
	Maciej Czekaj, Maxime Coquelin, Zhihong Wang, Yong Wang
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena, adamx.dybkowski

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/net/af_packet/rte_eth_af_packet.c |  8 +---
 drivers/net/af_xdp/rte_eth_af_xdp.c       |  8 +---
 drivers/net/ark/ark_ethdev.c              | 10 +----
 drivers/net/atlantic/atl_ethdev.c         | 15 +------
 drivers/net/avp/avp_ethdev.c              | 10 +----
 drivers/net/axgbe/axgbe_ethdev.c          | 15 +------
 drivers/net/bnx2x/bnx2x_ethdev.c          | 15 +------
 drivers/net/bnxt/bnxt_ethdev.c            |  9 +----
 drivers/net/bonding/rte_eth_bond_pmd.c    |  9 +----
 drivers/net/cxgbe/cxgbe_ethdev.c          | 15 +------
 drivers/net/dpaa/dpaa_ethdev.c            |  9 +----
 drivers/net/dpaa2/dpaa2_ethdev.c          |  9 +----
 drivers/net/ena/ena_ethdev.c              | 48 +++--------------------
 drivers/net/enetc/enetc_ethdev.c          | 10 +----
 drivers/net/enic/enic_ethdev.c            |  9 +----
 drivers/net/failsafe/failsafe.c           | 10 +----
 drivers/net/fm10k/fm10k_ethdev.c          | 40 +++----------------
 drivers/net/hinic/hinic_pmd_ethdev.c      | 11 +-----
 drivers/net/hns3/hns3_ethdev.c            | 15 +------
 drivers/net/i40e/i40e_ethdev.c            | 38 +++---------------
 drivers/net/iavf/iavf_ethdev.c            | 40 +++----------------
 drivers/net/ice/ice_ethdev.c              | 38 +++---------------
 drivers/net/igc/igc_logs.c                | 16 +-------
 drivers/net/ionic/ionic_ethdev.c          | 10 +----
 drivers/net/ipn3ke/ipn3ke_ethdev.c        | 10 +----
 drivers/net/ixgbe/ixgbe_ethdev.c          | 39 +++---------------
 drivers/net/kni/rte_eth_kni.c             |  9 +----
 drivers/net/liquidio/lio_ethdev.c         | 15 +------
 drivers/net/memif/rte_eth_memif.c         |  9 +----
 drivers/net/mlx4/mlx4.c                   | 11 ++----
 drivers/net/mlx5/mlx5.c                   | 10 ++---
 drivers/net/mvneta/mvneta_ethdev.c        | 10 +----
 drivers/net/mvpp2/mrvl_ethdev.c           | 10 +----
 drivers/net/netvsc/hn_ethdev.c            | 15 +------
 drivers/net/nfp/nfp_net.c                 | 15 +------
 drivers/net/null/rte_eth_null.c           |  8 +---
 drivers/net/octeontx/octeontx_ethdev.c    | 21 ++--------
 drivers/net/pcap/rte_eth_pcap.c           |  8 +---
 drivers/net/pfe/pfe_ethdev.c              | 10 +----
 drivers/net/qede/qede_ethdev.c            | 16 +-------
 drivers/net/ring/rte_eth_ring.c           |  8 +---
 drivers/net/softnic/rte_eth_softnic.c     | 10 +----
 drivers/net/szedata2/rte_eth_szedata2.c   | 15 +------
 drivers/net/tap/rte_eth_tap.c             |  9 +----
 drivers/net/thunderx/nicvf_ethdev.c       | 21 ++--------
 drivers/net/vdev_netvsc/vdev_netvsc.c     | 13 +-----
 drivers/net/vhost/rte_eth_vhost.c         |  8 +---
 drivers/net/virtio/virtio_ethdev.c        | 15 +------
 drivers/net/vmxnet3/vmxnet3_ethdev.c      | 15 +------
 49 files changed, 97 insertions(+), 650 deletions(-)

diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index 22feb72e3..300039bbf 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -97,7 +97,7 @@ static struct rte_eth_link pmd_link = {
 	.link_autoneg = ETH_LINK_FIXED,
 };
 
-static int af_packet_logtype;
+RTE_LOG_REGISTER(af_packet_logtype, pmd.net.packet, NOTICE);
 
 #define PMD_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, af_packet_logtype, \
@@ -1082,9 +1082,3 @@ RTE_PMD_REGISTER_PARAM_STRING(net_af_packet,
 	"framecnt=<int> "
 	"qdisc_bypass=<0|1>");
 
-RTE_INIT(af_packet_init_log)
-{
-	af_packet_logtype = rte_log_register("pmd.net.packet");
-	if (af_packet_logtype >= 0)
-		rte_log_set_level(af_packet_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 06124ba78..98b9cff38 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -50,7 +50,7 @@
 #define PF_XDP AF_XDP
 #endif
 
-static int af_xdp_logtype;
+RTE_LOG_REGISTER(af_xdp_logtype, pmd.net.af_xdp, NOTICE);
 
 #define AF_XDP_LOG(level, fmt, args...)			\
 	rte_log(RTE_LOG_ ## level, af_xdp_logtype,	\
@@ -1374,9 +1374,3 @@ RTE_PMD_REGISTER_PARAM_STRING(net_af_xdp,
 			      "start_queue=<int> "
 			      "queue_count=<int> ");
 
-RTE_INIT(af_xdp_init_log)
-{
-	af_xdp_logtype = rte_log_register("pmd.net.af_xdp");
-	if (af_xdp_logtype >= 0)
-		rte_log_set_level(af_xdp_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c
index c3642012d..b32ccd867 100644
--- a/drivers/net/ark/ark_ethdev.c
+++ b/drivers/net/ark/ark_ethdev.c
@@ -78,8 +78,6 @@ static int  eth_ark_set_mtu(struct rte_eth_dev *dev, uint16_t size);
 #define ARK_TX_MAX_QUEUE (4096 * 4)
 #define ARK_TX_MIN_QUEUE (256)
 
-int ark_logtype;
-
 static const char * const valid_arguments[] = {
 	ARK_PKTGEN_ARG,
 	ARK_PKTCHKR_ARG,
@@ -1018,10 +1016,4 @@ RTE_PMD_REGISTER_PARAM_STRING(net_ark,
 			      ARK_PKTGEN_ARG "=<filename> "
 			      ARK_PKTCHKR_ARG "=<filename> "
 			      ARK_PKTDIR_ARG "=<bitmap>");
-
-RTE_INIT(ark_init_log)
-{
-	ark_logtype = rte_log_register("pmd.net.ark");
-	if (ark_logtype >= 0)
-		rte_log_set_level(ark_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(ark_logtype, pmd.net.ark, NOTICE);
diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_ethdev.c
index b2b3bd36c..d3b00ab29 100644
--- a/drivers/net/atlantic/atl_ethdev.c
+++ b/drivers/net/atlantic/atl_ethdev.c
@@ -120,9 +120,6 @@ static int eth_atl_pci_remove(struct rte_pci_device *pci_dev);
 static int atl_dev_info_get(struct rte_eth_dev *dev,
 				struct rte_eth_dev_info *dev_info);
 
-int atl_logtype_init;
-int atl_logtype_driver;
-
 /*
  * The set of PCI devices this driver supports
  */
@@ -1929,13 +1926,5 @@ is_atlantic_supported(struct rte_eth_dev *dev)
 RTE_PMD_REGISTER_PCI(net_atlantic, rte_atl_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_atlantic, pci_id_atl_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_atlantic, "* igb_uio | uio_pci_generic");
-
-RTE_INIT(atl_init_log)
-{
-	atl_logtype_init = rte_log_register("pmd.net.atlantic.init");
-	if (atl_logtype_init >= 0)
-		rte_log_set_level(atl_logtype_init, RTE_LOG_NOTICE);
-	atl_logtype_driver = rte_log_register("pmd.net.atlantic.driver");
-	if (atl_logtype_driver >= 0)
-		rte_log_set_level(atl_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(atl_logtype_init, pmd.net.atlantic.init, NOTICE);
+RTE_LOG_REGISTER(atl_logtype_driver, pmd.net.atlantic.driver, NOTICE);
diff --git a/drivers/net/avp/avp_ethdev.c b/drivers/net/avp/avp_ethdev.c
index 1abe96ce5..5b47f0924 100644
--- a/drivers/net/avp/avp_ethdev.c
+++ b/drivers/net/avp/avp_ethdev.c
@@ -32,8 +32,6 @@
 
 #include "avp_logs.h"
 
-int avp_logtype_driver;
-
 static int avp_dev_create(struct rte_pci_device *pci_dev,
 			  struct rte_eth_dev *eth_dev);
 
@@ -2306,10 +2304,4 @@ avp_dev_stats_reset(struct rte_eth_dev *eth_dev)
 
 RTE_PMD_REGISTER_PCI(net_avp, rte_avp_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_avp, pci_id_avp_map);
-
-RTE_INIT(avp_init_log)
-{
-	avp_logtype_driver = rte_log_register("pmd.net.avp.driver");
-	if (avp_logtype_driver >= 0)
-		rte_log_set_level(avp_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(avp_logtype_driver, pmd.net.avp.driver, NOTICE);
diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c
index db86b9813..0c25739f8 100644
--- a/drivers/net/axgbe/axgbe_ethdev.c
+++ b/drivers/net/axgbe/axgbe_ethdev.c
@@ -143,9 +143,6 @@ static const struct axgbe_xstats axgbe_xstats_strings[] = {
 #define AMD_PCI_AXGBE_DEVICE_V2A 0x1458
 #define AMD_PCI_AXGBE_DEVICE_V2B 0x1459
 
-int axgbe_logtype_init;
-int axgbe_logtype_driver;
-
 static const struct rte_pci_id pci_id_axgbe_map[] = {
 	{RTE_PCI_DEVICE(AMD_PCI_VENDOR_ID, AMD_PCI_AXGBE_DEVICE_V2A)},
 	{RTE_PCI_DEVICE(AMD_PCI_VENDOR_ID, AMD_PCI_AXGBE_DEVICE_V2B)},
@@ -1842,13 +1839,5 @@ static struct rte_pci_driver rte_axgbe_pmd = {
 RTE_PMD_REGISTER_PCI(net_axgbe, rte_axgbe_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_axgbe, pci_id_axgbe_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_axgbe, "* igb_uio | uio_pci_generic | vfio-pci");
-
-RTE_INIT(axgbe_init_log)
-{
-	axgbe_logtype_init = rte_log_register("pmd.net.axgbe.init");
-	if (axgbe_logtype_init >= 0)
-		rte_log_set_level(axgbe_logtype_init, RTE_LOG_NOTICE);
-	axgbe_logtype_driver = rte_log_register("pmd.net.axgbe.driver");
-	if (axgbe_logtype_driver >= 0)
-		rte_log_set_level(axgbe_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(axgbe_logtype_init, pmd.net.axgbe.init, NOTICE);
+RTE_LOG_REGISTER(axgbe_logtype_driver, pmd.net.axgbe.driver, NOTICE);
diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c
index adc3690fc..b2ea5fafa 100644
--- a/drivers/net/bnx2x/bnx2x_ethdev.c
+++ b/drivers/net/bnx2x/bnx2x_ethdev.c
@@ -13,9 +13,6 @@
 #include <rte_ethdev_pci.h>
 #include <rte_alarm.h>
 
-int bnx2x_logtype_init;
-int bnx2x_logtype_driver;
-
 /*
  * The set of PCI devices this driver supports
  */
@@ -805,13 +802,5 @@ RTE_PMD_REGISTER_KMOD_DEP(net_bnx2x, "* igb_uio | uio_pci_generic | vfio-pci");
 RTE_PMD_REGISTER_PCI(net_bnx2xvf, rte_bnx2xvf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_bnx2xvf, pci_id_bnx2xvf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_bnx2xvf, "* igb_uio | vfio-pci");
-
-RTE_INIT(bnx2x_init_log)
-{
-	bnx2x_logtype_init = rte_log_register("pmd.net.bnx2x.init");
-	if (bnx2x_logtype_init >= 0)
-		rte_log_set_level(bnx2x_logtype_init, RTE_LOG_NOTICE);
-	bnx2x_logtype_driver = rte_log_register("pmd.net.bnx2x.driver");
-	if (bnx2x_logtype_driver >= 0)
-		rte_log_set_level(bnx2x_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(bnx2x_logtype_init, pmd.net.bnx2x.init, NOTICE);
+RTE_LOG_REGISTER(bnx2x_logtype_driver, pmd.net.bnx2x.driver, NOTICE);
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index e8b4c058a..59c318076 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -31,7 +31,6 @@
 #define DRV_MODULE_NAME		"bnxt"
 static const char bnxt_version[] =
 	"Broadcom NetXtreme driver " DRV_MODULE_NAME;
-int bnxt_logtype_driver;
 
 /*
  * The set of PCI devices this driver supports
@@ -5668,13 +5667,7 @@ bool is_bnxt_supported(struct rte_eth_dev *dev)
 	return is_device_supported(dev, &bnxt_rte_pmd);
 }
 
-RTE_INIT(bnxt_init_log)
-{
-	bnxt_logtype_driver = rte_log_register("pmd.net.bnxt.driver");
-	if (bnxt_logtype_driver >= 0)
-		rte_log_set_level(bnxt_logtype_driver, RTE_LOG_NOTICE);
-}
-
+RTE_LOG_REGISTER(bnxt_logtype_driver, pmd.net.bnxt.driver, NOTICE);
 RTE_PMD_REGISTER_PCI(net_bnxt, bnxt_rte_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_bnxt, bnxt_pci_id_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_bnxt, "* igb_uio | uio_pci_generic | vfio-pci");
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 612a64599..044a1cfbc 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -3750,11 +3750,4 @@ RTE_PMD_REGISTER_PARAM_STRING(net_bonding,
 	"up_delay=<int> "
 	"down_delay=<int>");
 
-int bond_logtype;
-
-RTE_INIT(bond_init_log)
-{
-	bond_logtype = rte_log_register("pmd.net.bond");
-	if (bond_logtype >= 0)
-		rte_log_set_level(bond_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(bond_logtype, pmd.net.bond, NOTICE);
diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index 1deee2f5c..7c6016d5c 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -38,9 +38,6 @@
 #include "cxgbe_pfvf.h"
 #include "cxgbe_flow.h"
 
-int cxgbe_logtype;
-int cxgbe_mbox_logtype;
-
 /*
  * Macros needed to support the PCI Device ID Table ...
  */
@@ -1247,13 +1244,5 @@ RTE_PMD_REGISTER_PARAM_STRING(net_cxgbe,
 			      CXGBE_DEVARG_CMN_TX_MODE_LATENCY "=<0|1> "
 			      CXGBE_DEVARG_PF_FILTER_MODE "=<uint32> "
 			      CXGBE_DEVARG_PF_FILTER_MASK "=<uint32> ");
-
-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);
-	cxgbe_mbox_logtype = rte_log_register("pmd.net.cxgbe.mbox");
-	if (cxgbe_mbox_logtype >= 0)
-		rte_log_set_level(cxgbe_mbox_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(cxgbe_logtype, pmd.net.cxgbe, NOTICE);
+RTE_LOG_REGISTER(cxgbe_mbox_logtype, pmd.net.cxgbe.mbox, NOTICE);
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 13d1c6a1f..f1c9a7151 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -46,8 +46,6 @@
 #include <fsl_bman.h>
 #include <fsl_fman.h>
 
-int dpaa_logtype_pmd;
-
 /* Supported Rx offloads */
 static uint64_t dev_rx_offloads_sup =
 		DEV_RX_OFFLOAD_JUMBO_FRAME |
@@ -1666,9 +1664,4 @@ static struct rte_dpaa_driver rte_dpaa_pmd = {
 };
 
 RTE_PMD_REGISTER_DPAA(net_dpaa, rte_dpaa_pmd);
-RTE_INIT(dpaa_net_init_log)
-{
-	dpaa_logtype_pmd = rte_log_register("pmd.net.dpaa");
-	if (dpaa_logtype_pmd >= 0)
-		rte_log_set_level(dpaa_logtype_pmd, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa_logtype_pmd, pmd.net.dpaa, NOTICE);
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 2f031ec5c..a1f19194d 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -106,8 +106,6 @@ static int dpaa2_dev_set_link_up(struct rte_eth_dev *dev);
 static int dpaa2_dev_set_link_down(struct rte_eth_dev *dev);
 static int dpaa2_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
 
-int dpaa2_logtype_pmd;
-
 void
 rte_pmd_dpaa2_set_timestamp(enum pmd_dpaa2_ts enable)
 {
@@ -2694,9 +2692,4 @@ RTE_PMD_REGISTER_DPAA2(net_dpaa2, rte_dpaa2_pmd);
 RTE_PMD_REGISTER_PARAM_STRING(net_dpaa2,
 		DRIVER_LOOPBACK_MODE "=<int> "
 		DRIVER_NO_PREFETCH_MODE "=<int>");
-RTE_INIT(dpaa2_pmd_init_log)
-{
-	dpaa2_logtype_pmd = rte_log_register("pmd.net.dpaa2");
-	if (dpaa2_logtype_pmd >= 0)
-		rte_log_set_level(dpaa2_logtype_pmd, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa2_logtype_pmd, pmd.net.dpaa2, NOTICE);
diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index fbddc79f7..da8c8ad92 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -141,22 +141,6 @@ static const struct ena_stats ena_stats_rx_strings[] = {
 #define	ENA_TX_OFFLOAD_NOTSUP_MASK	\
 	(PKT_TX_OFFLOAD_MASK ^ ENA_TX_OFFLOAD_MASK)
 
-int ena_logtype_init;
-int ena_logtype_driver;
-
-#ifdef RTE_LIBRTE_ENA_DEBUG_RX
-int ena_logtype_rx;
-#endif
-#ifdef RTE_LIBRTE_ENA_DEBUG_TX
-int ena_logtype_tx;
-#endif
-#ifdef RTE_LIBRTE_ENA_DEBUG_TX_FREE
-int ena_logtype_tx_free;
-#endif
-#ifdef RTE_LIBRTE_ENA_COM_DEBUG
-int ena_logtype_com;
-#endif
-
 static const struct rte_pci_id pci_id_ena_map[] = {
 	{ RTE_PCI_DEVICE(PCI_VENDOR_ID_AMAZON, PCI_DEVICE_ID_ENA_VF) },
 	{ RTE_PCI_DEVICE(PCI_VENDOR_ID_AMAZON, PCI_DEVICE_ID_ENA_LLQ_VF) },
@@ -2849,40 +2833,20 @@ RTE_PMD_REGISTER_PCI(net_ena, rte_ena_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_ena, pci_id_ena_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_ena, "* igb_uio | uio_pci_generic | vfio-pci");
 RTE_PMD_REGISTER_PARAM_STRING(net_ena, ENA_DEVARG_LARGE_LLQ_HDR "=<0|1>");
-
-RTE_INIT(ena_init_log)
-{
-	ena_logtype_init = rte_log_register("pmd.net.ena.init");
-	if (ena_logtype_init >= 0)
-		rte_log_set_level(ena_logtype_init, RTE_LOG_NOTICE);
-	ena_logtype_driver = rte_log_register("pmd.net.ena.driver");
-	if (ena_logtype_driver >= 0)
-		rte_log_set_level(ena_logtype_driver, RTE_LOG_NOTICE);
-
+RTE_LOG_REGISTER(ena_logtype_init, pmd.net.ena.init, NOTICE);
+RTE_LOG_REGISTER(ena_logtype_driver, pmd.net.ena.driver, NOTICE);
 #ifdef RTE_LIBRTE_ENA_DEBUG_RX
-	ena_logtype_rx = rte_log_register("pmd.net.ena.rx");
-	if (ena_logtype_rx >= 0)
-		rte_log_set_level(ena_logtype_rx, RTE_LOG_NOTICE);
+RTE_LOG_REGISTER(ena_logtype_rx, pmd.net.ena.rx, NOTICE);
 #endif
-
 #ifdef RTE_LIBRTE_ENA_DEBUG_TX
-	ena_logtype_tx = rte_log_register("pmd.net.ena.tx");
-	if (ena_logtype_tx >= 0)
-		rte_log_set_level(ena_logtype_tx, RTE_LOG_NOTICE);
+RTE_LOG_REGISTER(ena_logtype_tx, pmd.net.ena.tx, NOTICE);
 #endif
-
 #ifdef RTE_LIBRTE_ENA_DEBUG_TX_FREE
-	ena_logtype_tx_free = rte_log_register("pmd.net.ena.tx_free");
-	if (ena_logtype_tx_free >= 0)
-		rte_log_set_level(ena_logtype_tx_free, RTE_LOG_NOTICE);
+RTE_LOG_REGISTER(ena_logtype_tx_free, pmd.net.ena.tx_free, NOTICE);
 #endif
-
 #ifdef RTE_LIBRTE_ENA_COM_DEBUG
-	ena_logtype_com = rte_log_register("pmd.net.ena.com");
-	if (ena_logtype_com >= 0)
-		rte_log_set_level(ena_logtype_com, RTE_LOG_NOTICE);
+RTE_LOG_REGISTER(ena_logtype_com, pmd.net.ena.com, NOTICE);
 #endif
-}
 
 /******************************************************************************
  ******************************** AENQ Handlers *******************************
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 1716e11dd..c6fb42740 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -10,8 +10,6 @@
 #include "enetc_logs.h"
 #include "enetc.h"
 
-int enetc_logtype_pmd;
-
 static int
 enetc_dev_start(struct rte_eth_dev *dev)
 {
@@ -951,10 +949,4 @@ static struct rte_pci_driver rte_enetc_pmd = {
 RTE_PMD_REGISTER_PCI(net_enetc, rte_enetc_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_enetc, pci_id_enetc_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_enetc, "* vfio-pci");
-
-RTE_INIT(enetc_pmd_init_log)
-{
-	enetc_logtype_pmd = rte_log_register("pmd.net.enetc");
-	if (enetc_logtype_pmd >= 0)
-		rte_log_set_level(enetc_logtype_pmd, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(enetc_logtype_pmd, pmd.net.enetc, NOTICE);
diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c
index 32d5397f8..6a3580fef 100644
--- a/drivers/net/enic/enic_ethdev.c
+++ b/drivers/net/enic/enic_ethdev.c
@@ -21,8 +21,6 @@
 #include "vnic_enet.h"
 #include "enic.h"
 
-int enic_pmd_logtype;
-
 /*
  * The set of PCI devices this driver supports
  */
@@ -71,12 +69,7 @@ static const struct vic_speed_capa {
 #define ENIC_DEVARG_GENEVE_OPT "geneve-opt"
 #define ENIC_DEVARG_IG_VLAN_REWRITE "ig-vlan-rewrite"
 
-RTE_INIT(enicpmd_init_log)
-{
-	enic_pmd_logtype = rte_log_register("pmd.net.enic");
-	if (enic_pmd_logtype >= 0)
-		rte_log_set_level(enic_pmd_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(enic_pmd_logtype, pmd.net.enic, INFO);
 
 static int
 enicpmd_fdir_ctrl_func(struct rte_eth_dev *eth_dev,
diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsafe.c
index 72362f35d..4a4b7ceab 100644
--- a/drivers/net/failsafe/failsafe.c
+++ b/drivers/net/failsafe/failsafe.c
@@ -15,8 +15,6 @@
 
 #include "failsafe_private.h"
 
-int failsafe_logtype;
-
 const char pmd_failsafe_driver_name[] = FAILSAFE_DRIVER_NAME;
 static const struct rte_eth_link eth_link = {
 	.link_speed = ETH_SPEED_NUM_10G,
@@ -410,10 +408,4 @@ static struct rte_vdev_driver failsafe_drv = {
 
 RTE_PMD_REGISTER_VDEV(net_failsafe, failsafe_drv);
 RTE_PMD_REGISTER_PARAM_STRING(net_failsafe, PMD_FAILSAFE_PARAM_STRING);
-
-RTE_INIT(failsafe_init_log)
-{
-	failsafe_logtype = rte_log_register("pmd.net.failsafe");
-	if (failsafe_logtype >= 0)
-		rte_log_set_level(failsafe_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(failsafe_logtype, pmd.net.failsafe, NOTICE)
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index f537ab286..cb0dd3bae 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -40,19 +40,6 @@
 #define GLORT_FD_MASK    GLORT_PF_MASK
 #define GLORT_FD_INDEX   GLORT_FD_Q_BASE
 
-int fm10k_logtype_init;
-int fm10k_logtype_driver;
-
-#ifdef RTE_LIBRTE_FM10K_DEBUG_RX
-int fm10k_logtype_rx;
-#endif
-#ifdef RTE_LIBRTE_FM10K_DEBUG_TX
-int fm10k_logtype_tx;
-#endif
-#ifdef RTE_LIBRTE_FM10K_DEBUG_TX_FREE
-int fm10k_logtype_tx_free;
-#endif
-
 static void fm10k_close_mbx_service(struct fm10k_hw *hw);
 static int fm10k_dev_promiscuous_enable(struct rte_eth_dev *dev);
 static int fm10k_dev_promiscuous_disable(struct rte_eth_dev *dev);
@@ -3318,31 +3305,14 @@ 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)
-{
-	fm10k_logtype_init = rte_log_register("pmd.net.fm10k.init");
-	if (fm10k_logtype_init >= 0)
-		rte_log_set_level(fm10k_logtype_init, RTE_LOG_NOTICE);
-	fm10k_logtype_driver = rte_log_register("pmd.net.fm10k.driver");
-	if (fm10k_logtype_driver >= 0)
-		rte_log_set_level(fm10k_logtype_driver, RTE_LOG_NOTICE);
-
+RTE_LOG_REGISTER(fm10k_logtype_init, pmd.net.fm10k.init, NOTICE);
+RTE_LOG_REGISTER(fm10k_logtype_driver, pmd.net.fm10k.driver, NOTICE);
 #ifdef RTE_LIBRTE_FM10K_DEBUG_RX
-	fm10k_logtype_rx = rte_log_register("pmd.net.fm10k.rx");
-	if (fm10k_logtype_rx >= 0)
-		rte_log_set_level(fm10k_logtype_rx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(fm10k_logtype_rx, pmd.net.fm10k.rx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_FM10K_DEBUG_TX
-	fm10k_logtype_tx = rte_log_register("pmd.net.fm10k.tx");
-	if (fm10k_logtype_tx >= 0)
-		rte_log_set_level(fm10k_logtype_tx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(fm10k_logtype_tx, pmd.net.fm10k.tx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_FM10K_DEBUG_TX_FREE
-	fm10k_logtype_tx_free = rte_log_register("pmd.net.fm10k.tx_free");
-	if (fm10k_logtype_tx_free >= 0)
-		rte_log_set_level(fm10k_logtype_tx_free, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(fm10k_logtype_tx_free, pmd.net.fm10k.tx_free, DEBUG);
 #endif
-}
diff --git a/drivers/net/hinic/hinic_pmd_ethdev.c b/drivers/net/hinic/hinic_pmd_ethdev.c
index 0c3e1c0cd..8f81e2230 100644
--- a/drivers/net/hinic/hinic_pmd_ethdev.c
+++ b/drivers/net/hinic/hinic_pmd_ethdev.c
@@ -78,9 +78,6 @@
 /* lro numer limit for one packet */
 #define HINIC_LRO_WQE_NUM_DEFAULT	8
 
-/* Driver-specific log messages type */
-int hinic_logtype;
-
 struct hinic_xstats_name_off {
 	char name[RTE_ETH_XSTATS_NAME_SIZE];
 	u32  offset;
@@ -3250,10 +3247,4 @@ static struct rte_pci_driver rte_hinic_pmd = {
 
 RTE_PMD_REGISTER_PCI(net_hinic, rte_hinic_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_hinic, pci_id_hinic_map);
-
-RTE_INIT(hinic_init_log)
-{
-	hinic_logtype = rte_log_register("pmd.net.hinic");
-	if (hinic_logtype >= 0)
-		rte_log_set_level(hinic_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(hinic_logtype, pmd.net.hinic, INFO);
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 62d87582d..309d0483e 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -60,9 +60,6 @@
 #define HNS3_RESET_WAIT_MS	100
 #define HNS3_RESET_WAIT_CNT	200
 
-int hns3_logtype_init;
-int hns3_logtype_driver;
-
 enum hns3_evt_cause {
 	HNS3_VECTOR0_EVENT_RST,
 	HNS3_VECTOR0_EVENT_MBX,
@@ -5525,13 +5522,5 @@ static struct rte_pci_driver rte_hns3_pmd = {
 RTE_PMD_REGISTER_PCI(net_hns3, rte_hns3_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_hns3, pci_id_hns3_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_hns3, "* igb_uio | vfio-pci");
-
-RTE_INIT(hns3_init_log)
-{
-	hns3_logtype_init = rte_log_register("pmd.net.hns3.init");
-	if (hns3_logtype_init >= 0)
-		rte_log_set_level(hns3_logtype_init, RTE_LOG_NOTICE);
-	hns3_logtype_driver = rte_log_register("pmd.net.hns3.driver");
-	if (hns3_logtype_driver >= 0)
-		rte_log_set_level(hns3_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(hns3_logtype_init, pmd.net.hns3.init, NOTICE);
+RTE_LOG_REGISTER(hns3_logtype_driver, pmd.net.hns3.driver, NOTICE);
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 970a31cb2..472ce2a9e 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -398,18 +398,6 @@ static void i40e_tunnel_filter_restore(struct i40e_pf *pf);
 static void i40e_filter_restore(struct i40e_pf *pf);
 static void i40e_notify_all_vfs_link_status(struct rte_eth_dev *dev);
 
-int i40e_logtype_init;
-int i40e_logtype_driver;
-#ifdef RTE_LIBRTE_I40E_DEBUG_RX
-int i40e_logtype_rx;
-#endif
-#ifdef RTE_LIBRTE_I40E_DEBUG_TX
-int i40e_logtype_tx;
-#endif
-#ifdef RTE_LIBRTE_I40E_DEBUG_TX_FREE
-int i40e_logtype_tx_free;
-#endif
-
 static const char *const valid_keys[] = {
 	ETH_I40E_FLOATING_VEB_ARG,
 	ETH_I40E_FLOATING_VEB_LIST_ARG,
@@ -13411,33 +13399,17 @@ i40e_config_rss_filter(struct i40e_pf *pf,
 	return 0;
 }
 
-RTE_INIT(i40e_init_log)
-{
-	i40e_logtype_init = rte_log_register("pmd.net.i40e.init");
-	if (i40e_logtype_init >= 0)
-		rte_log_set_level(i40e_logtype_init, RTE_LOG_NOTICE);
-	i40e_logtype_driver = rte_log_register("pmd.net.i40e.driver");
-	if (i40e_logtype_driver >= 0)
-		rte_log_set_level(i40e_logtype_driver, RTE_LOG_NOTICE);
-
+RTE_LOG_REGISTER(i40e_logtype_init, pmd.net.i40e.init, NOTICE);
+RTE_LOG_REGISTER(i40e_logtype_driver, pmd.net.i40e.driver, NOTICE);
 #ifdef RTE_LIBRTE_I40E_DEBUG_RX
-	i40e_logtype_rx = rte_log_register("pmd.net.i40e.rx");
-	if (i40e_logtype_rx >= 0)
-		rte_log_set_level(i40e_logtype_rx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(i40e_logtype_rx, pmd.net.i40e.rx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_I40E_DEBUG_TX
-	i40e_logtype_tx = rte_log_register("pmd.net.i40e.tx");
-	if (i40e_logtype_tx >= 0)
-		rte_log_set_level(i40e_logtype_tx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(i40e_logtype_tx, pmd.net.i40e.tx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_I40E_DEBUG_TX_FREE
-	i40e_logtype_tx_free = rte_log_register("pmd.net.i40e.tx_free");
-	if (i40e_logtype_tx_free >= 0)
-		rte_log_set_level(i40e_logtype_tx_free, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(i40e_logtype_tx_free, pmd.net.i40e.tx_free, DEBUG);
 #endif
-}
 
 RTE_PMD_REGISTER_PARAM_STRING(net_i40e,
 			      ETH_I40E_FLOATING_VEB_ARG "=1"
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 2b1066b0a..d69e5284e 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -74,20 +74,6 @@ static int iavf_dev_filter_ctrl(struct rte_eth_dev *dev,
 		     enum rte_filter_op filter_op,
 		     void *arg);
 
-
-int iavf_logtype_init;
-int iavf_logtype_driver;
-
-#ifdef RTE_LIBRTE_IAVF_DEBUG_RX
-int iavf_logtype_rx;
-#endif
-#ifdef RTE_LIBRTE_IAVF_DEBUG_TX
-int iavf_logtype_tx;
-#endif
-#ifdef RTE_LIBRTE_IAVF_DEBUG_TX_FREE
-int iavf_logtype_tx_free;
-#endif
-
 static const struct rte_pci_id pci_id_iavf_map[] = {
 	{ RTE_PCI_DEVICE(IAVF_INTEL_VENDOR_ID, IAVF_DEV_ID_ADAPTIVE_VF) },
 	{ .vendor_id = 0, /* sentinel */ },
@@ -1556,30 +1542,14 @@ RTE_PMD_REGISTER_PCI(net_iavf, rte_iavf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_iavf, pci_id_iavf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_iavf, "* igb_uio | vfio-pci");
 RTE_PMD_REGISTER_PARAM_STRING(net_iavf, "cap=dcf");
-RTE_INIT(iavf_init_log)
-{
-	iavf_logtype_init = rte_log_register("pmd.net.iavf.init");
-	if (iavf_logtype_init >= 0)
-		rte_log_set_level(iavf_logtype_init, RTE_LOG_NOTICE);
-	iavf_logtype_driver = rte_log_register("pmd.net.iavf.driver");
-	if (iavf_logtype_driver >= 0)
-		rte_log_set_level(iavf_logtype_driver, RTE_LOG_NOTICE);
-
+RTE_LOG_REGISTER(iavf_logtype_init, pmd.net.iavf.init, NOTICE);
+RTE_LOG_REGISTER(iavf_logtype_driver, pmd.net.iavf.driver, NOTICE);
 #ifdef RTE_LIBRTE_IAVF_DEBUG_RX
-	iavf_logtype_rx = rte_log_register("pmd.net.iavf.rx");
-	if (iavf_logtype_rx >= 0)
-		rte_log_set_level(iavf_logtype_rx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(iavf_logtype_rx, pmd.net.iavf.rx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_IAVF_DEBUG_TX
-	iavf_logtype_tx = rte_log_register("pmd.net.iavf.tx");
-	if (iavf_logtype_tx >= 0)
-		rte_log_set_level(iavf_logtype_tx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(iavf_logtype_tx, pmd.net.iavf.tx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_IAVF_DEBUG_TX_FREE
-	iavf_logtype_tx_free = rte_log_register("pmd.net.iavf.tx_free");
-	if (iavf_logtype_tx_free >= 0)
-		rte_log_set_level(iavf_logtype_tx_free, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(iavf_logtype_tx_free, pmd.net.iavf.tx_free, DEBUG);
 #endif
-}
diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 5a89a1955..3386960df 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -71,18 +71,6 @@ static struct proto_xtr_ol_flag ice_proto_xtr_ol_flag_params[] = {
 #define ICE_COMMS_PKG_NAME			"ICE COMMS Package"
 #define ICE_MAX_RES_DESC_NUM        1024
 
-int ice_logtype_init;
-int ice_logtype_driver;
-#ifdef RTE_LIBRTE_ICE_DEBUG_RX
-int ice_logtype_rx;
-#endif
-#ifdef RTE_LIBRTE_ICE_DEBUG_TX
-int ice_logtype_tx;
-#endif
-#ifdef RTE_LIBRTE_ICE_DEBUG_TX_FREE
-int ice_logtype_tx_free;
-#endif
-
 static int ice_dev_configure(struct rte_eth_dev *dev);
 static int ice_dev_start(struct rte_eth_dev *dev);
 static void ice_dev_stop(struct rte_eth_dev *dev);
@@ -4576,30 +4564,14 @@ RTE_PMD_REGISTER_PARAM_STRING(net_ice,
 			      ICE_PIPELINE_MODE_SUPPORT_ARG "=<0|1>"
 			      ICE_FLOW_MARK_SUPPORT_ARG "=<0|1>");
 
-RTE_INIT(ice_init_log)
-{
-	ice_logtype_init = rte_log_register("pmd.net.ice.init");
-	if (ice_logtype_init >= 0)
-		rte_log_set_level(ice_logtype_init, RTE_LOG_NOTICE);
-	ice_logtype_driver = rte_log_register("pmd.net.ice.driver");
-	if (ice_logtype_driver >= 0)
-		rte_log_set_level(ice_logtype_driver, RTE_LOG_NOTICE);
-
+RTE_LOG_REGISTER(ice_logtype_init, pmd.net.ice.init, NOTICE);
+RTE_LOG_REGISTER(ice_logtype_driver, pmd.net.ice.driver, NOTICE);
 #ifdef RTE_LIBRTE_ICE_DEBUG_RX
-	ice_logtype_rx = rte_log_register("pmd.net.ice.rx");
-	if (ice_logtype_rx >= 0)
-		rte_log_set_level(ice_logtype_rx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(ice_logtype_rx, pmd.net.ice.rx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_ICE_DEBUG_TX
-	ice_logtype_tx = rte_log_register("pmd.net.ice.tx");
-	if (ice_logtype_tx >= 0)
-		rte_log_set_level(ice_logtype_tx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(ice_logtype_tx, pmd.net.ice.tx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_ICE_DEBUG_TX_FREE
-	ice_logtype_tx_free = rte_log_register("pmd.net.ice.tx_free");
-	if (ice_logtype_tx_free >= 0)
-		rte_log_set_level(ice_logtype_tx_free, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(ice_logtype_tx_free, pmd.net.ice.tx_free, DEBUG);
 #endif
-}
diff --git a/drivers/net/igc/igc_logs.c b/drivers/net/igc/igc_logs.c
index eff7640b1..2d458d7fb 100644
--- a/drivers/net/igc/igc_logs.c
+++ b/drivers/net/igc/igc_logs.c
@@ -6,17 +6,5 @@
 
 #include "igc_logs.h"
 
-/* declared as extern in igc_logs.h */
-int igc_logtype_init;
-int igc_logtype_driver;
-
-RTE_INIT(igc_init_log)
-{
-	igc_logtype_init = rte_log_register("pmd.net.igc.init");
-	if (igc_logtype_init >= 0)
-		rte_log_set_level(igc_logtype_init, RTE_LOG_INFO);
-
-	igc_logtype_driver = rte_log_register("pmd.net.igc.driver");
-	if (igc_logtype_driver >= 0)
-		rte_log_set_level(igc_logtype_driver, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(igc_logtype_init, pmd.net.igc.init, INFO);
+RTE_LOG_REGISTER(igc_logtype_driver, pmd.net.igc.driver, INFO);
diff --git a/drivers/net/ionic/ionic_ethdev.c b/drivers/net/ionic/ionic_ethdev.c
index 363f0cf00..800f6e5d6 100644
--- a/drivers/net/ionic/ionic_ethdev.c
+++ b/drivers/net/ionic/ionic_ethdev.c
@@ -59,8 +59,6 @@ static int  ionic_dev_xstats_get_names_by_id(struct rte_eth_dev *dev,
 static int  ionic_dev_fw_version_get(struct rte_eth_dev *eth_dev,
 	char *fw_version, size_t fw_size);
 
-int ionic_logtype;
-
 static const struct rte_pci_id pci_id_ionic_map[] = {
 	{ RTE_PCI_DEVICE(IONIC_PENSANDO_VENDOR_ID, IONIC_DEV_ID_ETH_PF) },
 	{ RTE_PCI_DEVICE(IONIC_PENSANDO_VENDOR_ID, IONIC_DEV_ID_ETH_VF) },
@@ -1318,10 +1316,4 @@ static struct rte_pci_driver rte_ionic_pmd = {
 RTE_PMD_REGISTER_PCI(net_ionic, rte_ionic_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_ionic, pci_id_ionic_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_ionic, "* igb_uio | uio_pci_generic | vfio-pci");
-
-RTE_INIT(ionic_init_log)
-{
-	ionic_logtype = rte_log_register("pmd.net.ionic");
-	if (ionic_logtype >= 0)
-		rte_log_set_level(ionic_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(ionic_logtype, pmd.net.ionic, NOTICE);
diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.c b/drivers/net/ipn3ke/ipn3ke_ethdev.c
index 5b5510f08..027be29bd 100644
--- a/drivers/net/ipn3ke/ipn3ke_ethdev.c
+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.c
@@ -26,8 +26,6 @@
 #include "ipn3ke_logs.h"
 #include "ipn3ke_ethdev.h"
 
-int ipn3ke_afu_logtype;
-
 static const struct rte_afu_uuid afu_uuid_ipn3ke_map[] = {
 	{ MAP_UUID_10G_LOW,  MAP_UUID_10G_HIGH },
 	{ IPN3KE_UUID_10G_LOW, IPN3KE_UUID_10G_HIGH },
@@ -587,10 +585,4 @@ static struct rte_afu_driver afu_ipn3ke_driver = {
 };
 
 RTE_PMD_REGISTER_AFU(net_ipn3ke_afu, afu_ipn3ke_driver);
-
-RTE_INIT(ipn3ke_afu_init_log)
-{
-	ipn3ke_afu_logtype = rte_log_register("pmd.afu.ipn3ke");
-	if (ipn3ke_afu_logtype >= 0)
-		rte_log_set_level(ipn3ke_afu_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(ipn3ke_afu_logtype, pmd.afu.ipn3ke, NOTICE);
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index f8a84c565..248f21d14 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -419,19 +419,6 @@ static int ixgbe_wait_for_link_up(struct ixgbe_hw *hw);
 		(r) = (h)->bitmap[idx] >> bit & 1;\
 	} while (0)
 
-int ixgbe_logtype_init;
-int ixgbe_logtype_driver;
-
-#ifdef RTE_LIBRTE_IXGBE_DEBUG_RX
-int ixgbe_logtype_rx;
-#endif
-#ifdef RTE_LIBRTE_IXGBE_DEBUG_TX
-int ixgbe_logtype_tx;
-#endif
-#ifdef RTE_LIBRTE_IXGBE_DEBUG_TX_FREE
-int ixgbe_logtype_tx_free;
-#endif
-
 /*
  * The set of PCI devices this driver supports
  */
@@ -9117,29 +9104,15 @@ RTE_PMD_REGISTER_KMOD_DEP(net_ixgbe_vf, "* igb_uio | vfio-pci");
 RTE_PMD_REGISTER_PARAM_STRING(net_ixgbe_vf,
 			      IXGBEVF_DEVARG_PFLINK_FULLCHK "=<0|1>");
 
-RTE_INIT(ixgbe_init_log)
-{
-	ixgbe_logtype_init = rte_log_register("pmd.net.ixgbe.init");
-	if (ixgbe_logtype_init >= 0)
-		rte_log_set_level(ixgbe_logtype_init, RTE_LOG_NOTICE);
-	ixgbe_logtype_driver = rte_log_register("pmd.net.ixgbe.driver");
-	if (ixgbe_logtype_driver >= 0)
-		rte_log_set_level(ixgbe_logtype_driver, RTE_LOG_NOTICE);
+RTE_LOG_REGISTER(ixgbe_logtype_init, pmd.net.ixgbe.init, NOTICE);
+RTE_LOG_REGISTER(ixgbe_logtype_driver, pmd.net.ixgbe.driver, NOTICE);
+
 #ifdef RTE_LIBRTE_IXGBE_DEBUG_RX
-	ixgbe_logtype_rx = rte_log_register("pmd.net.ixgbe.rx");
-	if (ixgbe_logtype_rx >= 0)
-		rte_log_set_level(ixgbe_logtype_rx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(ixgbe_logtype_rx, pmd.net.ixgbe.rx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_IXGBE_DEBUG_TX
-	ixgbe_logtype_tx = rte_log_register("pmd.net.ixgbe.tx");
-	if (ixgbe_logtype_tx >= 0)
-		rte_log_set_level(ixgbe_logtype_tx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(ixgbe_logtype_tx, pmd.net.ixgbe.tx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_IXGBE_DEBUG_TX_FREE
-	ixgbe_logtype_tx_free = rte_log_register("pmd.net.ixgbe.tx_free");
-	if (ixgbe_logtype_tx_free >= 0)
-		rte_log_set_level(ixgbe_logtype_tx_free, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(ixgbe_logtype_tx_free, pmd.net.ixgbe.tx_free, DEBUG);
 #endif
-}
diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c
index d88cb1778..cde98f0bb 100644
--- a/drivers/net/kni/rte_eth_kni.c
+++ b/drivers/net/kni/rte_eth_kni.c
@@ -67,7 +67,7 @@ static const struct rte_eth_link pmd_link = {
 };
 static int is_kni_initialized;
 
-static int eth_kni_logtype;
+RTE_LOG_REGISTER(eth_kni_logtype, pmd.net.kni, NOTICE);
 
 #define PMD_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, eth_kni_logtype, \
@@ -508,10 +508,3 @@ static struct rte_vdev_driver eth_kni_drv = {
 
 RTE_PMD_REGISTER_VDEV(net_kni, eth_kni_drv);
 RTE_PMD_REGISTER_PARAM_STRING(net_kni, ETH_KNI_NO_REQUEST_THREAD_ARG "=<int>");
-
-RTE_INIT(eth_kni_init_log)
-{
-	eth_kni_logtype = rte_log_register("pmd.net.kni");
-	if (eth_kni_logtype >= 0)
-		rte_log_set_level(eth_kni_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c
index ad4a51ecd..2258838c4 100644
--- a/drivers/net/liquidio/lio_ethdev.c
+++ b/drivers/net/liquidio/lio_ethdev.c
@@ -15,9 +15,6 @@
 #include "lio_ethdev.h"
 #include "lio_rxtx.h"
 
-int lio_logtype_init;
-int lio_logtype_driver;
-
 /* Default RSS key in use */
 static uint8_t lio_rss_key[40] = {
 	0x6D, 0x5A, 0x56, 0xDA, 0x25, 0x5B, 0x0E, 0xC2,
@@ -2161,13 +2158,5 @@ static struct rte_pci_driver rte_liovf_pmd = {
 RTE_PMD_REGISTER_PCI(net_liovf, rte_liovf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_liovf, pci_id_liovf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_liovf, "* igb_uio | vfio-pci");
-
-RTE_INIT(lio_init_log)
-{
-	lio_logtype_init = rte_log_register("pmd.net.liquidio.init");
-	if (lio_logtype_init >= 0)
-		rte_log_set_level(lio_logtype_init, RTE_LOG_NOTICE);
-	lio_logtype_driver = rte_log_register("pmd.net.liquidio.driver");
-	if (lio_logtype_driver >= 0)
-		rte_log_set_level(lio_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(lio_logtype_init, pmd.net.liquidio.init, NOTICE);
+RTE_LOG_REGISTER(lio_logtype_driver, pmd.net.liquidio.driver, NOTICE);
diff --git a/drivers/net/memif/rte_eth_memif.c b/drivers/net/memif/rte_eth_memif.c
index b6da9a8b4..c1c7e9f8d 100644
--- a/drivers/net/memif/rte_eth_memif.c
+++ b/drivers/net/memif/rte_eth_memif.c
@@ -1806,11 +1806,4 @@ RTE_PMD_REGISTER_PARAM_STRING(net_memif,
 			      ETH_MEMIF_ZC_ARG "=yes|no"
 			      ETH_MEMIF_SECRET_ARG "=<string>");
 
-int memif_logtype;
-
-RTE_INIT(memif_init_log)
-{
-	memif_logtype = rte_log_register("pmd.net.memif");
-	if (memif_logtype >= 0)
-		rte_log_set_level(memif_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(memif_logtype, pmd.net.memif, NOTICE);
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index 5d7202720..456a365c9 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -64,9 +64,6 @@ static rte_spinlock_t mlx4_shared_data_lock = RTE_SPINLOCK_INITIALIZER;
 /* Process local data for secondary processes. */
 static struct mlx4_local_data mlx4_local_data;
 
-/** Driver-specific log messages type. */
-int mlx4_logtype;
-
 /** Configuration structure for device arguments. */
 struct mlx4_conf {
 	struct {
@@ -1281,16 +1278,14 @@ mlx4_glue_init(void)
 
 #endif
 
+/* Initialize driver log type. */
+RTE_LOG_REGISTER(mlx4_logtype, pmd.net.mlx4, RTE_LOG_NOTICE);
+
 /**
  * Driver initialization routine.
  */
 RTE_INIT(rte_mlx4_pmd_init)
 {
-	/* Initialize driver log type. */
-	mlx4_logtype = rte_log_register("pmd.net.mlx4");
-	if (mlx4_logtype >= 0)
-		rte_log_set_level(mlx4_logtype, RTE_LOG_NOTICE);
-
 	/*
 	 * MLX4_DEVICE_FATAL_CLEANUP tells ibv_destroy functions we
 	 * want to get success errno value in case of calling them
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 5c86f6fb9..f433195ee 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -173,8 +173,6 @@ static rte_spinlock_t mlx5_shared_data_lock = RTE_SPINLOCK_INITIALIZER;
 
 /* Process local data for secondary processes. */
 static struct mlx5_local_data mlx5_local_data;
-/** Driver-specific log messages type. */
-int mlx5_logtype;
 
 static LIST_HEAD(, mlx5_dev_ctx_shared) mlx5_dev_ctx_list =
 						LIST_HEAD_INITIALIZER();
@@ -1999,16 +1997,14 @@ struct rte_pci_driver mlx5_driver = {
 	.drv_flags = PCI_DRV_FLAGS,
 };
 
+/* Initialize driver log type. */
+RTE_LOG_REGISTER(mlx5_logtype, pmd.net.mlx5, NOTICE);
+
 /**
  * Driver initialization routine.
  */
 RTE_INIT(rte_mlx5_pmd_init)
 {
-	/* Initialize driver log type. */
-	mlx5_logtype = rte_log_register("pmd.net.mlx5");
-	if (mlx5_logtype >= 0)
-		rte_log_set_level(mlx5_logtype, RTE_LOG_NOTICE);
-
 	/* Build the static tables for Verbs conversion. */
 	mlx5_set_ptype_table();
 	mlx5_set_cksum_table();
diff --git a/drivers/net/mvneta/mvneta_ethdev.c b/drivers/net/mvneta/mvneta_ethdev.c
index 4aea87648..673a8e2b3 100644
--- a/drivers/net/mvneta/mvneta_ethdev.c
+++ b/drivers/net/mvneta/mvneta_ethdev.c
@@ -34,8 +34,6 @@
 /** Maximum length of a match string */
 #define MVNETA_MATCH_LEN 16
 
-int mvneta_logtype;
-
 static const char * const valid_args[] = {
 	MVNETA_IFACE_NAME_ARG,
 	NULL
@@ -982,10 +980,4 @@ static struct rte_vdev_driver pmd_mvneta_drv = {
 
 RTE_PMD_REGISTER_VDEV(net_mvneta, pmd_mvneta_drv);
 RTE_PMD_REGISTER_PARAM_STRING(net_mvneta, "iface=<ifc>");
-
-RTE_INIT(mvneta_init_log)
-{
-	mvneta_logtype = rte_log_register("pmd.net.mvneta");
-	if (mvneta_logtype >= 0)
-		rte_log_set_level(mvneta_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(mvneta_logtype, pmd.net.mvneta, NOTICE);
diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c
index b98b1fd66..75589f18e 100644
--- a/drivers/net/mvpp2/mrvl_ethdev.c
+++ b/drivers/net/mvpp2/mrvl_ethdev.c
@@ -84,8 +84,6 @@ static struct pp2_bpool *mrvl_port_to_bpool_lookup[RTE_MAX_ETHPORTS];
 static int mrvl_port_bpool_size[PP2_NUM_PKT_PROC][PP2_BPOOL_NUM_POOLS][RTE_MAX_LCORE];
 static uint64_t cookie_addr_high = MRVL_COOKIE_ADDR_INVALID;
 
-int mrvl_logtype;
-
 struct mrvl_ifnames {
 	const char *names[PP2_NUM_ETH_PPIO * PP2_NUM_PKT_PROC];
 	int idx;
@@ -3040,10 +3038,4 @@ static struct rte_vdev_driver pmd_mrvl_drv = {
 
 RTE_PMD_REGISTER_VDEV(net_mvpp2, pmd_mrvl_drv);
 RTE_PMD_REGISTER_ALIAS(net_mvpp2, eth_mvpp2);
-
-RTE_INIT(mrvl_init_log)
-{
-	mrvl_logtype = rte_log_register("pmd.net.mvpp2");
-	if (mrvl_logtype >= 0)
-		rte_log_set_level(mrvl_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(mrvl_logtype, pmd.net.mvpp2, NOTICE);
diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c
index ac182a548..fd91c0e49 100644
--- a/drivers/net/netvsc/hn_ethdev.c
+++ b/drivers/net/netvsc/hn_ethdev.c
@@ -45,9 +45,6 @@
 			    DEV_RX_OFFLOAD_VLAN_STRIP | \
 			    DEV_RX_OFFLOAD_RSS_HASH)
 
-int hn_logtype_init;
-int hn_logtype_driver;
-
 struct hn_xstats_name_off {
 	char name[RTE_ETH_XSTATS_NAME_SIZE];
 	unsigned int offset;
@@ -1121,13 +1118,5 @@ static struct rte_vmbus_driver rte_netvsc_pmd = {
 
 RTE_PMD_REGISTER_VMBUS(net_netvsc, rte_netvsc_pmd);
 RTE_PMD_REGISTER_KMOD_DEP(net_netvsc, "* uio_hv_generic");
-
-RTE_INIT(hn_init_log)
-{
-	hn_logtype_init = rte_log_register("pmd.net.netvsc.init");
-	if (hn_logtype_init >= 0)
-		rte_log_set_level(hn_logtype_init, RTE_LOG_NOTICE);
-	hn_logtype_driver = rte_log_register("pmd.net.netvsc.driver");
-	if (hn_logtype_driver >= 0)
-		rte_log_set_level(hn_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(hn_logtype_init, pmd.net.netvsc.init, NOTICE);
+RTE_LOG_REGISTER(hn_logtype_driver, pmd.net.netvsc.driver, NOTICE);
diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
index 2460ee199..88e3f01d6 100644
--- a/drivers/net/nfp/nfp_net.c
+++ b/drivers/net/nfp/nfp_net.c
@@ -3683,9 +3683,6 @@ static int nfp_pf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	return ret;
 }
 
-int nfp_logtype_init;
-int nfp_logtype_driver;
-
 static const struct rte_pci_id pci_id_nfp_pf_net_map[] = {
 	{
 		RTE_PCI_DEVICE(PCI_VENDOR_ID_NETRONOME,
@@ -3769,16 +3766,8 @@ RTE_PMD_REGISTER_PCI_TABLE(net_nfp_pf, pci_id_nfp_pf_net_map);
 RTE_PMD_REGISTER_PCI_TABLE(net_nfp_vf, pci_id_nfp_vf_net_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_nfp_pf, "* igb_uio | uio_pci_generic | vfio");
 RTE_PMD_REGISTER_KMOD_DEP(net_nfp_vf, "* igb_uio | uio_pci_generic | vfio");
-
-RTE_INIT(nfp_init_log)
-{
-	nfp_logtype_init = rte_log_register("pmd.net.nfp.init");
-	if (nfp_logtype_init >= 0)
-		rte_log_set_level(nfp_logtype_init, RTE_LOG_NOTICE);
-	nfp_logtype_driver = rte_log_register("pmd.net.nfp.driver");
-	if (nfp_logtype_driver >= 0)
-		rte_log_set_level(nfp_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(nfp_logtype_init, pmd.net.nfp.init, NOTICE);
+RTE_LOG_REGISTER(nfp_logtype_driver, pmd.net.nfp.driver, NOTICE);
 /*
  * Local variables:
  * c-file-style: "Linux"
diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index 11258ccea..8c779be7f 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c
@@ -73,7 +73,7 @@ static struct rte_eth_link pmd_link = {
 	.link_autoneg = ETH_LINK_FIXED,
 };
 
-static int eth_null_logtype;
+RTE_LOG_REGISTER(eth_null_logtype, pmd.net.null, NOTICE);
 
 #define PMD_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, eth_null_logtype, \
@@ -730,9 +730,3 @@ RTE_PMD_REGISTER_PARAM_STRING(net_null,
 	"copy=<int> "
 	ETH_NULL_PACKET_NO_RX_ARG "=0|1");
 
-RTE_INIT(eth_null_init_log)
-{
-	eth_null_logtype = rte_log_register("pmd.net.null");
-	if (eth_null_logtype >= 0)
-		rte_log_set_level(eth_null_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c
index d5371ae07..76c69294d 100644
--- a/drivers/net/octeontx/octeontx_ethdev.c
+++ b/drivers/net/octeontx/octeontx_ethdev.c
@@ -47,24 +47,9 @@ enum octeontx_link_speed {
 	OCTEONTX_LINK_SPEED_RESERVE2
 };
 
-int otx_net_logtype_mbox;
-int otx_net_logtype_init;
-int otx_net_logtype_driver;
-
-RTE_INIT(otx_net_init_log)
-{
-	otx_net_logtype_mbox = rte_log_register("pmd.net.octeontx.mbox");
-	if (otx_net_logtype_mbox >= 0)
-		rte_log_set_level(otx_net_logtype_mbox, RTE_LOG_NOTICE);
-
-	otx_net_logtype_init = rte_log_register("pmd.net.octeontx.init");
-	if (otx_net_logtype_init >= 0)
-		rte_log_set_level(otx_net_logtype_init, RTE_LOG_NOTICE);
-
-	otx_net_logtype_driver = rte_log_register("pmd.net.octeontx.driver");
-	if (otx_net_logtype_driver >= 0)
-		rte_log_set_level(otx_net_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(otx_net_logtype_mbox, pmd.net.octeontx.mbox, NOTICE);
+RTE_LOG_REGISTER(otx_net_logtype_init, pmd.net.octeontx.init, NOTICE);
+RTE_LOG_REGISTER(otx_net_logtype_driver, pmd.net.octeontx.driver, NOTICE);
 
 /* Parse integer from integer argument */
 static int
diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index 13a3d0ac7..60e393c92 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -135,7 +135,7 @@ static struct rte_eth_link pmd_link = {
 		.link_autoneg = ETH_LINK_FIXED,
 };
 
-static int eth_pcap_logtype;
+RTE_LOG_REGISTER(eth_pcap_logtype, pmd.net.pcap, NOTICE);
 
 #define PMD_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, eth_pcap_logtype, \
@@ -1589,9 +1589,3 @@ RTE_PMD_REGISTER_PARAM_STRING(net_pcap,
 	ETH_PCAP_PHY_MAC_ARG "=<int>"
 	ETH_PCAP_INFINITE_RX_ARG "=<0|1>");
 
-RTE_INIT(eth_pcap_init_log)
-{
-	eth_pcap_logtype = rte_log_register("pmd.net.pcap");
-	if (eth_pcap_logtype >= 0)
-		rte_log_set_level(eth_pcap_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/pfe/pfe_ethdev.c b/drivers/net/pfe/pfe_ethdev.c
index b1de866d3..368acfa55 100644
--- a/drivers/net/pfe/pfe_ethdev.c
+++ b/drivers/net/pfe/pfe_ethdev.c
@@ -40,8 +40,6 @@ unsigned int pfe_svr = SVR_LS1012A_REV1;
 static void *cbus_emac_base[3];
 static void *cbus_gpi_base[3];
 
-int pfe_logtype_pmd;
-
 /* pfe_gemac_init
  */
 static int
@@ -1181,10 +1179,4 @@ struct rte_vdev_driver pmd_pfe_drv = {
 
 RTE_PMD_REGISTER_VDEV(PFE_NAME_PMD, pmd_pfe_drv);
 RTE_PMD_REGISTER_PARAM_STRING(PFE_NAME_PMD, PFE_VDEV_GEM_ID_ARG "=<int> ");
-
-RTE_INIT(pfe_pmd_init_log)
-{
-	pfe_logtype_pmd = rte_log_register("pmd.net.pfe");
-	if (pfe_logtype_pmd >= 0)
-		rte_log_set_level(pfe_logtype_pmd, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(pfe_logtype_pmd, pmd.net.pfe, NOTICE);
diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c
index c4f8f1258..6107d583e 100644
--- a/drivers/net/qede/qede_ethdev.c
+++ b/drivers/net/qede/qede_ethdev.c
@@ -10,10 +10,6 @@
 #include <rte_version.h>
 #include <rte_kvargs.h>
 
-/* Globals */
-int qede_logtype_init;
-int qede_logtype_driver;
-
 static const struct qed_eth_ops *qed_ops;
 static int qede_eth_dev_uninit(struct rte_eth_dev *eth_dev);
 static int qede_eth_dev_init(struct rte_eth_dev *eth_dev);
@@ -2870,13 +2866,5 @@ RTE_PMD_REGISTER_KMOD_DEP(net_qede, "* igb_uio | uio_pci_generic | vfio-pci");
 RTE_PMD_REGISTER_PCI(net_qede_vf, rte_qedevf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_qede_vf, pci_id_qedevf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_qede_vf, "* igb_uio | vfio-pci");
-
-RTE_INIT(qede_init_log)
-{
-	qede_logtype_init = rte_log_register("pmd.net.qede.init");
-	if (qede_logtype_init >= 0)
-		rte_log_set_level(qede_logtype_init, RTE_LOG_NOTICE);
-	qede_logtype_driver = rte_log_register("pmd.net.qede.driver");
-	if (qede_logtype_driver >= 0)
-		rte_log_set_level(qede_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(qede_logtype_init, pmd.net.qede.init, NOTICE);
+RTE_LOG_REGISTER(qede_logtype_driver, pmd.net.qede.driver, NOTICE);
diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index f0fafa0c0..078df605a 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -61,7 +61,7 @@ static struct rte_eth_link pmd_link = {
 	.link_autoneg = ETH_LINK_FIXED,
 };
 
-static int eth_ring_logtype;
+RTE_LOG_REGISTER(eth_ring_logtype, pmd.net.ring, NOTICE);
 
 #define PMD_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, eth_ring_logtype, \
@@ -703,9 +703,3 @@ RTE_PMD_REGISTER_ALIAS(net_ring, eth_ring);
 RTE_PMD_REGISTER_PARAM_STRING(net_ring,
 	ETH_RING_NUMA_NODE_ACTION_ARG "=name:node:action(ATTACH|CREATE)");
 
-RTE_INIT(eth_ring_init_log)
-{
-	eth_ring_logtype = rte_log_register("pmd.net.ring");
-	if (eth_ring_logtype >= 0)
-		rte_log_set_level(eth_ring_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/softnic/rte_eth_softnic.c b/drivers/net/softnic/rte_eth_softnic.c
index 11723778f..866d17a93 100644
--- a/drivers/net/softnic/rte_eth_softnic.c
+++ b/drivers/net/softnic/rte_eth_softnic.c
@@ -80,7 +80,7 @@ static const struct softnic_conn_params conn_params_default = {
 	.msg_handle_arg = NULL,
 };
 
-static int pmd_softnic_logtype;
+RTE_LOG_REGISTER(pmd_softnic_logtype, pmd.net.softnic, NOTICE);
 
 #define PMD_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, pmd_softnic_logtype, \
@@ -690,14 +690,6 @@ RTE_PMD_REGISTER_PARAM_STRING(net_softnic,
 	PMD_PARAM_TM_QSIZE12 "=<uint32>"
 );
 
-
-RTE_INIT(pmd_softnic_init_log)
-{
-	pmd_softnic_logtype = rte_log_register("pmd.net.softnic");
-	if (pmd_softnic_logtype >= 0)
-		rte_log_set_level(pmd_softnic_logtype, RTE_LOG_NOTICE);
-}
-
 int
 rte_pmd_softnic_manage(uint16_t port_id)
 {
diff --git a/drivers/net/szedata2/rte_eth_szedata2.c b/drivers/net/szedata2/rte_eth_szedata2.c
index 821bb346c..30c888cd9 100644
--- a/drivers/net/szedata2/rte_eth_szedata2.c
+++ b/drivers/net/szedata2/rte_eth_szedata2.c
@@ -102,9 +102,6 @@ struct szedata2_tx_queue {
 	volatile uint64_t err_pkts;
 };
 
-int szedata2_logtype_init;
-int szedata2_logtype_driver;
-
 static struct rte_ether_addr eth_addr = {
 	.addr_bytes = { 0x00, 0x11, 0x17, 0x00, 0x00, 0x00 }
 };
@@ -1941,13 +1938,5 @@ RTE_PMD_REGISTER_PCI(RTE_SZEDATA2_DRIVER_NAME, szedata2_eth_driver);
 RTE_PMD_REGISTER_PCI_TABLE(RTE_SZEDATA2_DRIVER_NAME, rte_szedata2_pci_id_table);
 RTE_PMD_REGISTER_KMOD_DEP(RTE_SZEDATA2_DRIVER_NAME,
 	"* combo6core & combov3 & szedata2 & ( szedata2_cv3 | szedata2_cv3_fdt )");
-
-RTE_INIT(szedata2_init_log)
-{
-	szedata2_logtype_init = rte_log_register("pmd.net.szedata2.init");
-	if (szedata2_logtype_init >= 0)
-		rte_log_set_level(szedata2_logtype_init, RTE_LOG_NOTICE);
-	szedata2_logtype_driver = rte_log_register("pmd.net.szedata2.driver");
-	if (szedata2_logtype_driver >= 0)
-		rte_log_set_level(szedata2_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(szedata2_logtype_init, pmd.net.szedata2.init, NOTICE);
+RTE_LOG_REGISTER(szedata2_logtype_driver, pmd.net.szedata2.driver, NOTICE);
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 7081ae23e..339f24bf8 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -2494,11 +2494,4 @@ RTE_PMD_REGISTER_PARAM_STRING(net_tap,
 			      ETH_TAP_IFACE_ARG "=<string> "
 			      ETH_TAP_MAC_ARG "=" ETH_TAP_MAC_ARG_FMT " "
 			      ETH_TAP_REMOTE_ARG "=<string>");
-int tap_logtype;
-
-RTE_INIT(tap_init_log)
-{
-	tap_logtype = rte_log_register("pmd.net.tap");
-	if (tap_logtype >= 0)
-		rte_log_set_level(tap_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(tap_logtype, pmd.net.tap, NOTICE);
diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c
index bfda0ab0e..d955a7ee2 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -44,10 +44,6 @@
 #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,
@@ -55,20 +51,9 @@ static void nicvf_vf_stop(struct rte_eth_dev *dev, struct nicvf *nic,
 static int nicvf_vlan_offload_config(struct rte_eth_dev *dev, int mask);
 static int nicvf_vlan_offload_set(struct rte_eth_dev *dev, int mask);
 
-RTE_INIT(nicvf_init_log)
-{
-	nicvf_logtype_mbox = rte_log_register("pmd.net.thunderx.mbox");
-	if (nicvf_logtype_mbox >= 0)
-		rte_log_set_level(nicvf_logtype_mbox, RTE_LOG_NOTICE);
-
-	nicvf_logtype_init = rte_log_register("pmd.net.thunderx.init");
-	if (nicvf_logtype_init >= 0)
-		rte_log_set_level(nicvf_logtype_init, RTE_LOG_NOTICE);
-
-	nicvf_logtype_driver = rte_log_register("pmd.net.thunderx.driver");
-	if (nicvf_logtype_driver >= 0)
-		rte_log_set_level(nicvf_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(nicvf_logtype_mbox, pmd.net.thunderx.mbox, NOTICE);
+RTE_LOG_REGISTER(nicvf_logtype_init, pmd.net.thunderx.init, NOTICE);
+RTE_LOG_REGISTER(nicvf_logtype_driver, pmd.net.thunderx.driver, NOTICE);
 
 static void
 nicvf_link_status_update(struct nicvf *nic,
diff --git a/drivers/net/vdev_netvsc/vdev_netvsc.c b/drivers/net/vdev_netvsc/vdev_netvsc.c
index 9ed74a1d6..1ecb0b3e6 100644
--- a/drivers/net/vdev_netvsc/vdev_netvsc.c
+++ b/drivers/net/vdev_netvsc/vdev_netvsc.c
@@ -48,6 +48,8 @@
 #define NETVSC_CLASS_ID "{f8615163-df3e-46c5-913f-f2d2f965ed0e}"
 #define NETVSC_MAX_ROUTE_LINE_SIZE 300
 
+RTE_LOG_REGISTER(vdev_netvsc_logtype, pmd.net.vdev_netvsc, NOTICE);
+
 #define DRV_LOG(level, ...) \
 	rte_log(RTE_LOG_ ## level, \
 		vdev_netvsc_logtype, \
@@ -55,9 +57,6 @@
 			RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
 		RTE_FMT_TAIL(__VA_ARGS__,)))
 
-/** Driver-specific log messages type. */
-static int vdev_netvsc_logtype;
-
 /** Context structure for a vdev_netvsc instance. */
 struct vdev_netvsc_ctx {
 	LIST_ENTRY(vdev_netvsc_ctx) entry; /**< Next entry in list. */
@@ -774,14 +773,6 @@ RTE_PMD_REGISTER_PARAM_STRING(net_vdev_netvsc,
 			      VDEV_NETVSC_ARG_FORCE "=<int> "
 			      VDEV_NETVSC_ARG_IGNORE "=<int>");
 
-/** Initialize driver log type. */
-RTE_INIT(vdev_netvsc_init_log)
-{
-	vdev_netvsc_logtype = rte_log_register("pmd.net.vdev_netvsc");
-	if (vdev_netvsc_logtype >= 0)
-		rte_log_set_level(vdev_netvsc_logtype, RTE_LOG_NOTICE);
-}
-
 /** Compare function for vdev find device operation. */
 static int
 vdev_netvsc_cmp_rte_device(const struct rte_device *dev1,
diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index 808e670f1..bfacdcb98 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -18,7 +18,7 @@
 
 #include "rte_eth_vhost.h"
 
-static int vhost_logtype;
+RTE_LOG_REGISTER(vhost_logtype, pmd.net.vhost, NOTICE);
 
 #define VHOST_LOG(level, ...) \
 	rte_log(RTE_LOG_ ## level, vhost_logtype, __VA_ARGS__)
@@ -1571,9 +1571,3 @@ RTE_PMD_REGISTER_PARAM_STRING(net_vhost,
 	"linear-buffer=<0|1> "
 	"ext-buffer=<0|1>");
 
-RTE_INIT(vhost_init_log)
-{
-	vhost_logtype = rte_log_register("pmd.net.vhost");
-	if (vhost_logtype >= 0)
-		rte_log_set_level(vhost_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 312871cb4..dc0093bdf 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -85,9 +85,6 @@ static int virtio_dev_queue_stats_mapping_set(
 	uint8_t stat_idx,
 	uint8_t is_rx);
 
-int virtio_logtype_init;
-int virtio_logtype_driver;
-
 static void virtio_notify_peers(struct rte_eth_dev *dev);
 static void virtio_ack_link_announce(struct rte_eth_dev *dev);
 
@@ -2659,13 +2656,5 @@ __rte_unused uint8_t is_rx)
 RTE_PMD_EXPORT_NAME(net_virtio, __COUNTER__);
 RTE_PMD_REGISTER_PCI_TABLE(net_virtio, pci_id_virtio_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_virtio, "* igb_uio | uio_pci_generic | vfio-pci");
-
-RTE_INIT(virtio_init_log)
-{
-	virtio_logtype_init = rte_log_register("pmd.net.virtio.init");
-	if (virtio_logtype_init >= 0)
-		rte_log_set_level(virtio_logtype_init, RTE_LOG_NOTICE);
-	virtio_logtype_driver = rte_log_register("pmd.net.virtio.driver");
-	if (virtio_logtype_driver >= 0)
-		rte_log_set_level(virtio_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(virtio_logtype_init, pmd.net.virtio.init, NOTICE);
+RTE_LOG_REGISTER(virtio_logtype_driver, pmd.net.virtio.driver, NOTICE);
diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c
index c6e11ad2d..815fba2f5 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethdev.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c
@@ -95,9 +95,6 @@ static int vmxnet3_mac_addr_set(struct rte_eth_dev *dev,
 				 struct rte_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
  */
@@ -1464,13 +1461,5 @@ 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)
-{
-	vmxnet3_logtype_init = rte_log_register("pmd.net.vmxnet3.init");
-	if (vmxnet3_logtype_init >= 0)
-		rte_log_set_level(vmxnet3_logtype_init, RTE_LOG_NOTICE);
-	vmxnet3_logtype_driver = rte_log_register("pmd.net.vmxnet3.driver");
-	if (vmxnet3_logtype_driver >= 0)
-		rte_log_set_level(vmxnet3_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(vmxnet3_logtype_init, pmd.net.vmxnet3.init, NOTICE);
+RTE_LOG_REGISTER(vmxnet3_logtype_driver, pmd.net.vmxnet3.driver, NOTICE);
-- 
2.27.0


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

* [dpdk-dev] [PATCH v2 06/13] drivers/mempool: use log register macro
  2020-07-01  3:58 ` [dpdk-dev] [PATCH v2 " jerinj
                     ` (4 preceding siblings ...)
  2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 05/13] drivers/net: " jerinj
@ 2020-07-01  3:58   ` jerinj
  2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 07/13] drivers/event: " jerinj
                     ` (7 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01  3:58 UTC (permalink / raw)
  To: dev, Hemant Agrawal, Sachin Saxena, Harman Kalra
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Sachin Saxena <sachin.saxena@oss.nxp.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/mempool/dpaa/dpaa_mempool.c       | 10 ++--------
 drivers/mempool/dpaa2/dpaa2_hw_mempool.c  | 10 +---------
 drivers/mempool/octeontx/octeontx_fpavf.c | 10 +---------
 3 files changed, 4 insertions(+), 26 deletions(-)

diff --git a/drivers/mempool/dpaa/dpaa_mempool.c b/drivers/mempool/dpaa/dpaa_mempool.c
index 451e2d5d5..8d1da8028 100644
--- a/drivers/mempool/dpaa/dpaa_mempool.c
+++ b/drivers/mempool/dpaa/dpaa_mempool.c
@@ -36,7 +36,8 @@ struct dpaa_memseg_list rte_dpaa_memsegs
 	= TAILQ_HEAD_INITIALIZER(rte_dpaa_memsegs);
 
 struct dpaa_bp_info *rte_dpaa_bpid_info;
-int dpaa_logtype_mempool;
+
+RTE_LOG_REGISTER(dpaa_logtype_mempool, mempool.dpaa, NOTICE);
 
 static int
 dpaa_mbuf_create_pool(struct rte_mempool *mp)
@@ -357,10 +358,3 @@ static const struct rte_mempool_ops dpaa_mpool_ops = {
 };
 
 MEMPOOL_REGISTER_OPS(dpaa_mpool_ops);
-
-RTE_INIT(dpaa_mp_init_log)
-{
-	dpaa_logtype_mempool = rte_log_register("mempool.dpaa");
-	if (dpaa_logtype_mempool >= 0)
-		rte_log_set_level(dpaa_logtype_mempool, RTE_LOG_NOTICE);
-}
diff --git a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
index fa9b53e64..97ce08d78 100644
--- a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
+++ b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
@@ -36,9 +36,6 @@
 struct dpaa2_bp_info *rte_dpaa2_bpid_info;
 static struct dpaa2_bp_list *h_bp_list;
 
-/* Dynamic logging identified for mempool */
-int dpaa2_logtype_mempool;
-
 static int
 rte_hw_mbuf_create_pool(struct rte_mempool *mp)
 {
@@ -454,9 +451,4 @@ static const struct rte_mempool_ops dpaa2_mpool_ops = {
 
 MEMPOOL_REGISTER_OPS(dpaa2_mpool_ops);
 
-RTE_INIT(dpaa2_mempool_init_log)
-{
-	dpaa2_logtype_mempool = rte_log_register("mempool.dpaa2");
-	if (dpaa2_logtype_mempool >= 0)
-		rte_log_set_level(dpaa2_logtype_mempool, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa2_logtype_mempool, mempool.dpaa2, NOTICE);
diff --git a/drivers/mempool/octeontx/octeontx_fpavf.c b/drivers/mempool/octeontx/octeontx_fpavf.c
index 0ff234913..339da7824 100644
--- a/drivers/mempool/octeontx/octeontx_fpavf.c
+++ b/drivers/mempool/octeontx/octeontx_fpavf.c
@@ -105,15 +105,7 @@ struct octeontx_fpadev {
 
 static struct octeontx_fpadev fpadev;
 
-int octeontx_logtype_fpavf;
-int octeontx_logtype_fpavf_mbox;
-
-RTE_INIT(otx_pool_init_log)
-{
-	octeontx_logtype_fpavf = rte_log_register("pmd.mempool.octeontx");
-	if (octeontx_logtype_fpavf >= 0)
-		rte_log_set_level(octeontx_logtype_fpavf, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(octeontx_logtype_fpavf, pmd.mempool.octeontx, NOTICE);
 
 /* lock is taken by caller */
 static int
-- 
2.27.0


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

* [dpdk-dev] [PATCH v2 07/13] drivers/event: use log register macro
  2020-07-01  3:58 ` [dpdk-dev] [PATCH v2 " jerinj
                     ` (5 preceding siblings ...)
  2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 06/13] drivers/mempool: " jerinj
@ 2020-07-01  3:58   ` jerinj
  2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 08/13] drivers/crypto: " jerinj
                     ` (6 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01  3:58 UTC (permalink / raw)
  To: dev, Hemant Agrawal, Nipun Gupta, Jerin Jacob, Pavan Nikhilesh,
	Liang Ma, Peter Mccarthy, Harry van Haaren
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena, adamx.dybkowski

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/event/dpaa/dpaa_eventdev.c   |  8 +-------
 drivers/event/dpaa2/dpaa2_eventdev.c | 10 +---------
 drivers/event/octeontx/ssovf_evdev.c |  8 +-------
 drivers/event/octeontx/timvf_evdev.c |  9 +--------
 drivers/event/opdl/opdl_evdev.c      |  8 +-------
 drivers/event/opdl/opdl_ring.c       |  2 --
 drivers/event/sw/sw_evdev.c          | 11 +----------
 7 files changed, 6 insertions(+), 50 deletions(-)

diff --git a/drivers/event/dpaa/dpaa_eventdev.c b/drivers/event/dpaa/dpaa_eventdev.c
index 5a018d487..e78728b7e 100644
--- a/drivers/event/dpaa/dpaa_eventdev.c
+++ b/drivers/event/dpaa/dpaa_eventdev.c
@@ -46,7 +46,7 @@
  * Eventqueue = Channel Instance
  * 1 Eventdev can have N Eventqueue
  */
-int dpaa_logtype_eventdev;
+RTE_LOG_REGISTER(dpaa_logtype_eventdev, pmd.event.dpaa, NOTICE);
 
 #define DISABLE_INTR_MODE "disable_intr"
 
@@ -1069,9 +1069,3 @@ static struct rte_vdev_driver vdev_eventdev_dpaa_pmd = {
 RTE_PMD_REGISTER_VDEV(EVENTDEV_NAME_DPAA_PMD, vdev_eventdev_dpaa_pmd);
 RTE_PMD_REGISTER_PARAM_STRING(EVENTDEV_NAME_DPAA_PMD,
 		DISABLE_INTR_MODE "=<int>");
-RTE_INIT(dpaa_event_init_log)
-{
-	dpaa_logtype_eventdev = rte_log_register("pmd.event.dpaa");
-	if (dpaa_logtype_eventdev >= 0)
-		rte_log_set_level(dpaa_logtype_eventdev, RTE_LOG_NOTICE);
-}
diff --git a/drivers/event/dpaa2/dpaa2_eventdev.c b/drivers/event/dpaa2/dpaa2_eventdev.c
index a196ad4c6..a545baf34 100644
--- a/drivers/event/dpaa2/dpaa2_eventdev.c
+++ b/drivers/event/dpaa2/dpaa2_eventdev.c
@@ -48,8 +48,6 @@
  * Soft Event Flow is DPCI Instance
  */
 
-/* Dynamic logging identified for mempool */
-int dpaa2_logtype_event;
 #define DPAA2_EV_TX_RETRY_COUNT 10000
 
 static uint16_t
@@ -1205,10 +1203,4 @@ static struct rte_vdev_driver vdev_eventdev_dpaa2_pmd = {
 };
 
 RTE_PMD_REGISTER_VDEV(EVENTDEV_NAME_DPAA2_PMD, vdev_eventdev_dpaa2_pmd);
-
-RTE_INIT(dpaa2_eventdev_init_log)
-{
-	dpaa2_logtype_event = rte_log_register("pmd.event.dpaa2");
-	if (dpaa2_logtype_event >= 0)
-		rte_log_set_level(dpaa2_logtype_event, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa2_logtype_event, pmd.event.dpaa2, NOTICE);
diff --git a/drivers/event/octeontx/ssovf_evdev.c b/drivers/event/octeontx/ssovf_evdev.c
index 1b1a5d939..4fc4e8f7e 100644
--- a/drivers/event/octeontx/ssovf_evdev.c
+++ b/drivers/event/octeontx/ssovf_evdev.c
@@ -20,15 +20,9 @@
 #include "ssovf_evdev.h"
 #include "timvf_evdev.h"
 
-int otx_logtype_ssovf;
 static uint8_t timvf_enable_stats;
 
-RTE_INIT(otx_ssovf_init_log)
-{
-	otx_logtype_ssovf = rte_log_register("pmd.event.octeontx");
-	if (otx_logtype_ssovf >= 0)
-		rte_log_set_level(otx_logtype_ssovf, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(otx_logtype_ssovf, pmd.event.octeontx, NOTICE);
 
 /* SSOPF Mailbox messages */
 
diff --git a/drivers/event/octeontx/timvf_evdev.c b/drivers/event/octeontx/timvf_evdev.c
index caa129087..c61aacacc 100644
--- a/drivers/event/octeontx/timvf_evdev.c
+++ b/drivers/event/octeontx/timvf_evdev.c
@@ -4,14 +4,7 @@
 
 #include "timvf_evdev.h"
 
-int otx_logtype_timvf;
-
-RTE_INIT(otx_timvf_init_log)
-{
-	otx_logtype_timvf = rte_log_register("pmd.event.octeontx.timer");
-	if (otx_logtype_timvf >= 0)
-		rte_log_set_level(otx_logtype_timvf, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(otx_logtype_timvf, pmd.event.octeontx.timer, NOTICE);
 
 struct __rte_packed timvf_mbox_dev_info {
 	uint64_t ring_active[4];
diff --git a/drivers/event/opdl/opdl_evdev.c b/drivers/event/opdl/opdl_evdev.c
index 3beca8957..9b2f75fe3 100644
--- a/drivers/event/opdl/opdl_evdev.c
+++ b/drivers/event/opdl/opdl_evdev.c
@@ -754,13 +754,7 @@ static struct rte_vdev_driver evdev_opdl_pmd_drv = {
 	.remove = opdl_remove
 };
 
-RTE_INIT(opdl_init_log)
-{
-	opdl_logtype_driver = rte_log_register("pmd.event.opdl.driver");
-	if (opdl_logtype_driver >= 0)
-		rte_log_set_level(opdl_logtype_driver, RTE_LOG_INFO);
-}
-
+RTE_LOG_REGISTER(opdl_logtype_driver, pmd.event.opdl.driver, INFO);
 
 RTE_PMD_REGISTER_VDEV(EVENTDEV_NAME_OPDL_PMD, evdev_opdl_pmd_drv);
 RTE_PMD_REGISTER_PARAM_STRING(event_opdl, NUMA_NODE_ARG "=<int>"
diff --git a/drivers/event/opdl/opdl_ring.c b/drivers/event/opdl/opdl_ring.c
index c8d19fef5..69392b56b 100644
--- a/drivers/event/opdl/opdl_ring.c
+++ b/drivers/event/opdl/opdl_ring.c
@@ -31,8 +31,6 @@
 #define OPDL_OPA_MASK    (0xFF)
 #define OPDL_OPA_OFFSET  (0x38)
 
-int opdl_logtype_driver;
-
 /* Types of dependency between stages */
 enum dep_type {
 	DEP_NONE = 0,  /* no dependency */
diff --git a/drivers/event/sw/sw_evdev.c b/drivers/event/sw/sw_evdev.c
index fb8e8bebb..98dae7164 100644
--- a/drivers/event/sw/sw_evdev.c
+++ b/drivers/event/sw/sw_evdev.c
@@ -1083,13 +1083,4 @@ static struct rte_vdev_driver evdev_sw_pmd_drv = {
 RTE_PMD_REGISTER_VDEV(EVENTDEV_NAME_SW_PMD, evdev_sw_pmd_drv);
 RTE_PMD_REGISTER_PARAM_STRING(event_sw, NUMA_NODE_ARG "=<int> "
 		SCHED_QUANTA_ARG "=<int>" CREDIT_QUANTA_ARG "=<int>");
-
-/* declared extern in header, for access from other .c files */
-int eventdev_sw_log_level;
-
-RTE_INIT(evdev_sw_init_log)
-{
-	eventdev_sw_log_level = rte_log_register("pmd.event.sw");
-	if (eventdev_sw_log_level >= 0)
-		rte_log_set_level(eventdev_sw_log_level, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(eventdev_sw_log_level, pmd.event.sw, NOTICE);
-- 
2.27.0


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

* [dpdk-dev] [PATCH v2 08/13] drivers/crypto: use log register macro
  2020-07-01  3:58 ` [dpdk-dev] [PATCH v2 " jerinj
                     ` (6 preceding siblings ...)
  2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 07/13] drivers/event: " jerinj
@ 2020-07-01  3:58   ` jerinj
  2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 09/13] drivers/compress: " jerinj
                     ` (5 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01  3:58 UTC (permalink / raw)
  To: dev, Declan Doherty, Pablo de Lara, Gagandeep Singh,
	Hemant Agrawal, Akhil Goyal, Michael Shamis, Liron Himi,
	Nagadheeraj Rottela, Srikanth Jampala, Anoob Joseph,
	Ankur Dwivedi, Fan Zhang, Jay Zhou
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c      |  8 +---
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c    |  8 +---
 drivers/crypto/caam_jr/caam_jr.c              |  8 +---
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c   | 11 +-----
 drivers/crypto/dpaa_sec/dpaa_sec.c            | 10 +----
 drivers/crypto/kasumi/rte_kasumi_pmd.c        |  6 +--
 drivers/crypto/mvsam/rte_mrvl_pmd.c           |  7 +---
 drivers/crypto/nitrox/nitrox_logs.c           |  9 +----
 drivers/crypto/null/null_crypto_pmd.c         |  7 +---
 drivers/crypto/octeontx/otx_cryptodev.c       | 10 +----
 drivers/crypto/octeontx2/otx2_cryptodev.c     | 12 +-----
 drivers/crypto/openssl/rte_openssl_pmd.c      |  7 +---
 .../scheduler/rte_cryptodev_scheduler.c       |  8 +---
 drivers/crypto/snow3g/rte_snow3g_pmd.c        |  7 +---
 drivers/crypto/virtio/virtio_cryptodev.c      | 39 ++++---------------
 drivers/crypto/zuc/rte_zuc_pmd.c              |  7 +---
 16 files changed, 23 insertions(+), 141 deletions(-)

diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
index d213d05b9..1d2a0ce00 100644
--- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
+++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
@@ -13,8 +13,6 @@
 
 #include "aesni_gcm_pmd_private.h"
 
-int aesni_gcm_logtype_driver;
-
 static uint8_t cryptodev_driver_id;
 
 /* setup session handlers */
@@ -889,8 +887,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_AESNI_GCM_PMD,
 	"socket_id=<int>");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(aesni_gcm_crypto_drv, aesni_gcm_pmd_drv.driver,
 		cryptodev_driver_id);
-
-RTE_INIT(aesni_gcm_init_log)
-{
-	aesni_gcm_logtype_driver = rte_log_register("pmd.crypto.aesni_gcm");
-}
+RTE_LOG_REGISTER(aesni_gcm_logtype_driver, pmd.crypto.aesni_gcm, NOTICE);
diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
index 2d688f4d3..9d0d9f4d7 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
@@ -15,8 +15,6 @@
 
 #include "aesni_mb_pmd_private.h"
 
-int aesni_mb_logtype_driver;
-
 #define AES_CCM_DIGEST_MIN_LEN 4
 #define AES_CCM_DIGEST_MAX_LEN 16
 #define HMAC_MAX_BLOCK_SIZE 128
@@ -1744,8 +1742,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_AESNI_MB_PMD,
 RTE_PMD_REGISTER_CRYPTO_DRIVER(aesni_mb_crypto_drv,
 		cryptodev_aesni_mb_pmd_drv.driver,
 		cryptodev_driver_id);
-
-RTE_INIT(aesni_mb_init_log)
-{
-	aesni_mb_logtype_driver = rte_log_register("pmd.crypto.aesni_mb");
-}
+RTE_LOG_REGISTER(aesni_mb_logtype_driver, pmd.crypto.aesni_mb, NOTICE);
diff --git a/drivers/crypto/caam_jr/caam_jr.c b/drivers/crypto/caam_jr/caam_jr.c
index caf238677..49a35d614 100644
--- a/drivers/crypto/caam_jr/caam_jr.c
+++ b/drivers/crypto/caam_jr/caam_jr.c
@@ -35,7 +35,6 @@
 #endif
 #define CRYPTODEV_NAME_CAAM_JR_PMD	crypto_caam_jr
 static uint8_t cryptodev_driver_id;
-int caam_jr_logtype;
 
 /* Lists the states possible for the SEC user space driver. */
 enum sec_driver_state_e {
@@ -2477,9 +2476,4 @@ RTE_INIT(caam_jr_init)
 	sec_job_rings_init();
 }
 
-RTE_INIT(caam_jr_init_log)
-{
-	caam_jr_logtype = rte_log_register("pmd.crypto.caam");
-	if (caam_jr_logtype >= 0)
-		rte_log_set_level(caam_jr_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(caam_jr_logtype, pmd.crypto.caam, NOTICE);
diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index 63e7d930a..12f833136 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
@@ -58,8 +58,6 @@
 
 static uint8_t cryptodev_driver_id;
 
-int dpaa2_logtype_sec;
-
 #ifdef RTE_LIBRTE_SECURITY
 static inline int
 build_proto_compound_sg_fd(dpaa2_sec_session *sess,
@@ -3918,11 +3916,4 @@ static struct cryptodev_driver dpaa2_sec_crypto_drv;
 RTE_PMD_REGISTER_DPAA2(CRYPTODEV_NAME_DPAA2_SEC_PMD, rte_dpaa2_sec_driver);
 RTE_PMD_REGISTER_CRYPTO_DRIVER(dpaa2_sec_crypto_drv,
 		rte_dpaa2_sec_driver.driver, cryptodev_driver_id);
-
-RTE_INIT(dpaa2_sec_init_log)
-{
-	/* Bus level logs */
-	dpaa2_logtype_sec = rte_log_register("pmd.crypto.dpaa2");
-	if (dpaa2_logtype_sec >= 0)
-		rte_log_set_level(dpaa2_logtype_sec, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa2_logtype_sec, pmd.crypto.dpaa2, NOTICE);
diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c
index 66ee0ba0c..d9fa8bb36 100644
--- a/drivers/crypto/dpaa_sec/dpaa_sec.c
+++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
@@ -43,8 +43,6 @@
 #include <dpaa_sec_log.h>
 #include <dpaax_iova_table.h>
 
-int dpaa_logtype_sec;
-
 static uint8_t cryptodev_driver_id;
 
 static __thread struct rte_crypto_op **dpaa_sec_ops;
@@ -3520,10 +3518,4 @@ static struct cryptodev_driver dpaa_sec_crypto_drv;
 RTE_PMD_REGISTER_DPAA(CRYPTODEV_NAME_DPAA_SEC_PMD, rte_dpaa_sec_driver);
 RTE_PMD_REGISTER_CRYPTO_DRIVER(dpaa_sec_crypto_drv, rte_dpaa_sec_driver.driver,
 		cryptodev_driver_id);
-
-RTE_INIT(dpaa_sec_init_log)
-{
-	dpaa_logtype_sec = rte_log_register("pmd.crypto.dpaa");
-	if (dpaa_logtype_sec >= 0)
-		rte_log_set_level(dpaa_logtype_sec, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa_logtype_sec, pmd.crypto.dpaa, NOTICE);
diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd.c b/drivers/crypto/kasumi/rte_kasumi_pmd.c
index 73077e3d9..c3f0dfc2f 100644
--- a/drivers/crypto/kasumi/rte_kasumi_pmd.c
+++ b/drivers/crypto/kasumi/rte_kasumi_pmd.c
@@ -17,7 +17,6 @@
 #define KASUMI_MAX_BURST 4
 #define BYTE_LEN 8
 
-int kasumi_logtype_driver;
 static uint8_t cryptodev_driver_id;
 
 /** Get xform chain order. */
@@ -639,7 +638,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_KASUMI_PMD,
 RTE_PMD_REGISTER_CRYPTO_DRIVER(kasumi_crypto_drv,
 		cryptodev_kasumi_pmd_drv.driver, cryptodev_driver_id);
 
-RTE_INIT(kasumi_init_log)
-{
-	kasumi_logtype_driver = rte_log_register("pmd.crypto.kasumi");
-}
+RTE_LOG_REGISTER(kasumi_logtype_driver, pmd.crypto.kasumi, NOTICE);
diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd.c b/drivers/crypto/mvsam/rte_mrvl_pmd.c
index 63782ce97..aaa40dced 100644
--- a/drivers/crypto/mvsam/rte_mrvl_pmd.c
+++ b/drivers/crypto/mvsam/rte_mrvl_pmd.c
@@ -19,7 +19,6 @@
 #define MRVL_PMD_MAX_NB_SESS_ARG		("max_nb_sessions")
 #define MRVL_PMD_DEFAULT_MAX_NB_SESSIONS	2048
 
-int mrvl_logtype_driver;
 static uint8_t cryptodev_driver_id;
 
 struct mrvl_pmd_init_params {
@@ -1020,8 +1019,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_MRVL_PMD,
 	"socket_id=<int>");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(mrvl_crypto_drv, cryptodev_mrvl_pmd_drv.driver,
 		cryptodev_driver_id);
-
-RTE_INIT(crypto_mrvl_init_log)
-{
-	mrvl_logtype_driver = rte_log_register("pmd.crypto.mvsam");
-}
+RTE_LOG_REGISTER(mrvl_logtype_driver, pmd.crypto.mvsam, NOTICE);
diff --git a/drivers/crypto/nitrox/nitrox_logs.c b/drivers/crypto/nitrox/nitrox_logs.c
index 007056cb4..26395159a 100644
--- a/drivers/crypto/nitrox/nitrox_logs.c
+++ b/drivers/crypto/nitrox/nitrox_logs.c
@@ -4,11 +4,4 @@
 
 #include <rte_log.h>
 
-int nitrox_logtype;
-
-RTE_INIT(nitrox_init_log)
-{
-	nitrox_logtype = rte_log_register("pmd.crypto.nitrox");
-	if (nitrox_logtype >= 0)
-		rte_log_set_level(nitrox_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(nitrox_logtype, pmd.crypto.nitrox, NOTICE);
diff --git a/drivers/crypto/null/null_crypto_pmd.c b/drivers/crypto/null/null_crypto_pmd.c
index 7b0b9d42b..e04042e75 100644
--- a/drivers/crypto/null/null_crypto_pmd.c
+++ b/drivers/crypto/null/null_crypto_pmd.c
@@ -10,7 +10,6 @@
 #include "null_crypto_pmd_private.h"
 
 static uint8_t cryptodev_driver_id;
-int null_logtype_driver;
 
 /** verify and set session parameters */
 int
@@ -249,8 +248,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_NULL_PMD,
 	"socket_id=<int>");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(null_crypto_drv, cryptodev_null_pmd_drv.driver,
 		cryptodev_driver_id);
-
-RTE_INIT(null_init_log)
-{
-	null_logtype_driver = rte_log_register("pmd.crypto.null");
-}
+RTE_LOG_REGISTER(null_logtype_driver, pmd.crypto.null, INFO);
diff --git a/drivers/crypto/octeontx/otx_cryptodev.c b/drivers/crypto/octeontx/otx_cryptodev.c
index ddece1311..5ce1cf82f 100644
--- a/drivers/crypto/octeontx/otx_cryptodev.c
+++ b/drivers/crypto/octeontx/otx_cryptodev.c
@@ -15,7 +15,6 @@
 #include "cpt_pmd_logs.h"
 
 uint8_t otx_cryptodev_driver_id;
-int otx_cpt_logtype;
 
 static struct rte_pci_id pci_id_cpt_table[] = {
 	{
@@ -112,11 +111,4 @@ RTE_PMD_REGISTER_PCI_TABLE(CRYPTODEV_NAME_OCTEONTX_PMD, pci_id_cpt_table);
 RTE_PMD_REGISTER_KMOD_DEP(CRYPTODEV_NAME_OCTEONTX_PMD, "vfio-pci");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(otx_cryptodev_drv, otx_cryptodev_pmd.driver,
 		otx_cryptodev_driver_id);
-
-RTE_INIT(otx_cpt_init_log)
-{
-	/* Bus level logs */
-	otx_cpt_logtype = rte_log_register("pmd.crypto.octeontx");
-	if (otx_cpt_logtype >= 0)
-		rte_log_set_level(otx_cpt_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(otx_cpt_logtype, pmd.crypto.octeontx, NOTICE);
diff --git a/drivers/crypto/octeontx2/otx2_cryptodev.c b/drivers/crypto/octeontx2/otx2_cryptodev.c
index 6ffbc2eb7..50cbb13d8 100644
--- a/drivers/crypto/octeontx2/otx2_cryptodev.c
+++ b/drivers/crypto/octeontx2/otx2_cryptodev.c
@@ -22,8 +22,6 @@
 #include "cpt_common.h"
 #include "cpt_pmd_logs.h"
 
-int otx2_cpt_logtype;
-
 uint8_t otx2_cryptodev_driver_id;
 
 static struct rte_pci_id pci_id_cpt_table[] = {
@@ -146,17 +144,9 @@ static struct rte_pci_driver otx2_cryptodev_pmd = {
 
 static struct cryptodev_driver otx2_cryptodev_drv;
 
-RTE_INIT(otx2_cpt_init_log);
 RTE_PMD_REGISTER_PCI(CRYPTODEV_NAME_OCTEONTX2_PMD, otx2_cryptodev_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(CRYPTODEV_NAME_OCTEONTX2_PMD, pci_id_cpt_table);
 RTE_PMD_REGISTER_KMOD_DEP(CRYPTODEV_NAME_OCTEONTX2_PMD, "vfio-pci");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(otx2_cryptodev_drv, otx2_cryptodev_pmd.driver,
 		otx2_cryptodev_driver_id);
-
-RTE_INIT(otx2_cpt_init_log)
-{
-	/* Bus level logs */
-	otx2_cpt_logtype = rte_log_register("pmd.crypto.octeontx2");
-	if (otx2_cpt_logtype >= 0)
-		rte_log_set_level(otx2_cpt_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(otx2_cpt_logtype, pmd.crypto.octeontx2, NOTICE);
diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c
index bb9fb877a..7d3959f55 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd.c
@@ -18,7 +18,6 @@
 
 #define DES_BLOCK_SIZE 8
 
-int openssl_logtype_driver;
 static uint8_t cryptodev_driver_id;
 
 #if (OPENSSL_VERSION_NUMBER < 0x10100000L)
@@ -2279,8 +2278,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_OPENSSL_PMD,
 	"socket_id=<int>");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(openssl_crypto_drv,
 		cryptodev_openssl_pmd_drv.driver, cryptodev_driver_id);
-
-RTE_INIT(openssl_init_log)
-{
-	openssl_logtype_driver = rte_log_register("pmd.crypto.openssl");
-}
+RTE_LOG_REGISTER(openssl_logtype_driver, pmd.crypto.openssl, INFO);
diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
index 1fef88f11..730504dab 100644
--- a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
+++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
@@ -10,8 +10,6 @@
 #include "rte_cryptodev_scheduler.h"
 #include "scheduler_pmd_private.h"
 
-int scheduler_logtype_driver;
-
 /** update the scheduler pmd's capability with attaching device's
  *  capability.
  *  For each device to be attached, the scheduler's capability should be
@@ -578,7 +576,5 @@ rte_cryptodev_scheduler_option_get(uint8_t scheduler_id,
 	return (*sched_ctx->ops.option_get)(dev, option_type, option);
 }
 
-RTE_INIT(scheduler_init_log)
-{
-	scheduler_logtype_driver = rte_log_register("pmd.crypto.scheduler");
-}
+
+RTE_LOG_REGISTER(scheduler_logtype_driver, pmd.crypto.scheduler, INFO);
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index c939064d5..558e01e70 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -16,7 +16,6 @@
 #define SNOW3G_MAX_BURST 8
 #define BYTE_LEN 8
 
-int snow3g_logtype_driver;
 static uint8_t cryptodev_driver_id;
 
 /** Get xform chain order. */
@@ -653,8 +652,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_SNOW3G_PMD,
 	"socket_id=<int>");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(snow3g_crypto_drv,
 		cryptodev_snow3g_pmd_drv.driver, cryptodev_driver_id);
-
-RTE_INIT(snow3g_init_log)
-{
-	snow3g_logtype_driver = rte_log_register("pmd.crypto.snow3g");
-}
+RTE_LOG_REGISTER(snow3g_logtype_driver, pmd.crypto.snow3g, INFO);
diff --git a/drivers/crypto/virtio/virtio_cryptodev.c b/drivers/crypto/virtio/virtio_cryptodev.c
index cdf43b0e0..31a5f1072 100644
--- a/drivers/crypto/virtio/virtio_cryptodev.c
+++ b/drivers/crypto/virtio/virtio_cryptodev.c
@@ -17,12 +17,6 @@
 #include "virtio_crypto_algs.h"
 #include "virtio_crypto_capabilities.h"
 
-int virtio_crypto_logtype_init;
-int virtio_crypto_logtype_session;
-int virtio_crypto_logtype_rx;
-int virtio_crypto_logtype_tx;
-int virtio_crypto_logtype_driver;
-
 static int virtio_crypto_dev_configure(struct rte_cryptodev *dev,
 		struct rte_cryptodev_config *config);
 static int virtio_crypto_dev_start(struct rte_cryptodev *dev);
@@ -1489,29 +1483,10 @@ RTE_PMD_REGISTER_PCI(CRYPTODEV_NAME_VIRTIO_PMD, rte_virtio_crypto_driver);
 RTE_PMD_REGISTER_CRYPTO_DRIVER(virtio_crypto_drv,
 	rte_virtio_crypto_driver.driver,
 	cryptodev_virtio_driver_id);
-
-RTE_INIT(virtio_crypto_init_log)
-{
-	virtio_crypto_logtype_init = rte_log_register("pmd.crypto.virtio.init");
-	if (virtio_crypto_logtype_init >= 0)
-		rte_log_set_level(virtio_crypto_logtype_init, RTE_LOG_NOTICE);
-
-	virtio_crypto_logtype_session =
-		rte_log_register("pmd.crypto.virtio.session");
-	if (virtio_crypto_logtype_session >= 0)
-		rte_log_set_level(virtio_crypto_logtype_session,
-				RTE_LOG_NOTICE);
-
-	virtio_crypto_logtype_rx = rte_log_register("pmd.crypto.virtio.rx");
-	if (virtio_crypto_logtype_rx >= 0)
-		rte_log_set_level(virtio_crypto_logtype_rx, RTE_LOG_NOTICE);
-
-	virtio_crypto_logtype_tx = rte_log_register("pmd.crypto.virtio.tx");
-	if (virtio_crypto_logtype_tx >= 0)
-		rte_log_set_level(virtio_crypto_logtype_tx, RTE_LOG_NOTICE);
-
-	virtio_crypto_logtype_driver =
-		rte_log_register("pmd.crypto.virtio.driver");
-	if (virtio_crypto_logtype_driver >= 0)
-		rte_log_set_level(virtio_crypto_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(virtio_crypto_logtype_init, pmd.crypto.virtio.init, NOTICE);
+RTE_LOG_REGISTER(virtio_crypto_logtype_session, pmd.crypto.virtio.session,
+		 NOTICE);
+RTE_LOG_REGISTER(virtio_crypto_logtype_rx, pmd.crypto.virtio.rx, NOTICE);
+RTE_LOG_REGISTER(virtio_crypto_logtype_tx, pmd.crypto.virtio.tx, NOTICE);
+RTE_LOG_REGISTER(virtio_crypto_logtype_driver, pmd.crypto.virtio.driver,
+		 NOTICE);
diff --git a/drivers/crypto/zuc/rte_zuc_pmd.c b/drivers/crypto/zuc/rte_zuc_pmd.c
index df8d6f6bb..20cb5a160 100644
--- a/drivers/crypto/zuc/rte_zuc_pmd.c
+++ b/drivers/crypto/zuc/rte_zuc_pmd.c
@@ -14,7 +14,6 @@
 #define ZUC_MAX_BURST 16
 #define BYTE_LEN 8
 
-int zuc_logtype_driver;
 static uint8_t cryptodev_driver_id;
 
 /** Get xform chain order. */
@@ -580,8 +579,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_ZUC_PMD,
 	"socket_id=<int>");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(zuc_crypto_drv, cryptodev_zuc_pmd_drv.driver,
 		cryptodev_driver_id);
-
-RTE_INIT(zuc_init_log)
-{
-	zuc_logtype_driver = rte_log_register("pmd.crypto.zuc");
-}
+RTE_LOG_REGISTER(zuc_logtype_driver, pmd.crypto.zuc, INFO);
-- 
2.27.0


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

* [dpdk-dev] [PATCH v2 09/13] drivers/compress: use log register macro
  2020-07-01  3:58 ` [dpdk-dev] [PATCH v2 " jerinj
                     ` (7 preceding siblings ...)
  2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 08/13] drivers/crypto: " jerinj
@ 2020-07-01  3:58   ` jerinj
  2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 10/13] drivers/common: " jerinj
                     ` (4 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01  3:58 UTC (permalink / raw)
  To: dev, Lee Daly, Fiona Trahe, Ashish Gupta, Sunila Sahu
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/compress/isal/isal_compress_pmd.c | 10 +---------
 drivers/compress/octeontx/otx_zip_pmd.c   | 10 +---------
 drivers/compress/zlib/zlib_pmd.c          | 10 +---------
 3 files changed, 3 insertions(+), 27 deletions(-)

diff --git a/drivers/compress/isal/isal_compress_pmd.c b/drivers/compress/isal/isal_compress_pmd.c
index 7d2b05c91..0ecca12a8 100644
--- a/drivers/compress/isal/isal_compress_pmd.c
+++ b/drivers/compress/isal/isal_compress_pmd.c
@@ -25,8 +25,6 @@
 #define ISAL_VERSION_STRING \
 	ISAL_TOSTRING(ISAL_MAJOR_VERSION, ISAL_MINOR_VERSION, ISAL_PATCH_VERSION)
 
-int isal_logtype_driver;
-
 /* Verify and set private xform parameters */
 int
 isal_comp_set_priv_xform_parameters(struct isal_priv_xform *priv_xform,
@@ -752,10 +750,4 @@ static struct rte_vdev_driver compdev_isal_pmd_drv = {
 RTE_PMD_REGISTER_VDEV(COMPDEV_NAME_ISAL_PMD, compdev_isal_pmd_drv);
 RTE_PMD_REGISTER_PARAM_STRING(COMPDEV_NAME_ISAL_PMD,
 	"socket_id=<int>");
-
-RTE_INIT(isal_init_log)
-{
-	isal_logtype_driver = rte_log_register("pmd.compress.isal");
-	if (isal_logtype_driver >= 0)
-		rte_log_set_level(isal_logtype_driver, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(isal_logtype_driver, pmd.compress.isal, INFO);
diff --git a/drivers/compress/octeontx/otx_zip_pmd.c b/drivers/compress/octeontx/otx_zip_pmd.c
index bff8ef035..bee90fc7c 100644
--- a/drivers/compress/octeontx/otx_zip_pmd.c
+++ b/drivers/compress/octeontx/otx_zip_pmd.c
@@ -11,8 +11,6 @@
 
 #include "otx_zip.h"
 
-int octtx_zip_logtype_driver;
-
 static const struct rte_compressdev_capabilities
 				octtx_zip_pmd_capabilities[] = {
 	{	.algo = RTE_COMP_ALGO_DEFLATE,
@@ -648,10 +646,4 @@ static struct rte_pci_driver octtx_zip_pmd = {
 
 RTE_PMD_REGISTER_PCI(COMPRESSDEV_NAME_ZIP_PMD, octtx_zip_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(COMPRESSDEV_NAME_ZIP_PMD, pci_id_octtx_zipvf_table);
-
-RTE_INIT(octtx_zip_init_log)
-{
-	octtx_zip_logtype_driver = rte_log_register("pmd.compress.octeontx");
-	if (octtx_zip_logtype_driver >= 0)
-		rte_log_set_level(octtx_zip_logtype_driver, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(octtx_zip_logtype_driver, pmd.compress.octeontx, INFO);
diff --git a/drivers/compress/zlib/zlib_pmd.c b/drivers/compress/zlib/zlib_pmd.c
index e39be2ed8..8a79d15c9 100644
--- a/drivers/compress/zlib/zlib_pmd.c
+++ b/drivers/compress/zlib/zlib_pmd.c
@@ -7,8 +7,6 @@
 
 #include "zlib_pmd_private.h"
 
-int zlib_logtype_driver;
-
 /** Compute next mbuf in the list, assign data buffer and length,
  *  returns 0 if mbuf is NULL
  */
@@ -428,10 +426,4 @@ static struct rte_vdev_driver zlib_pmd_drv = {
 };
 
 RTE_PMD_REGISTER_VDEV(COMPRESSDEV_NAME_ZLIB_PMD, zlib_pmd_drv);
-
-RTE_INIT(zlib_init_log)
-{
-	zlib_logtype_driver = rte_log_register("pmd.compress.zlib");
-	if (zlib_logtype_driver >= 0)
-		rte_log_set_level(zlib_logtype_driver, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(zlib_logtype_driver, pmd.compress.zlib, INFO);
-- 
2.27.0


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

* [dpdk-dev] [PATCH v2 10/13] drivers/common: use log register macro
  2020-07-01  3:58 ` [dpdk-dev] [PATCH v2 " jerinj
                     ` (8 preceding siblings ...)
  2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 09/13] drivers/compress: " jerinj
@ 2020-07-01  3:58   ` jerinj
  2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 11/13] drivers/bus: " jerinj
                     ` (3 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01  3:58 UTC (permalink / raw)
  To: dev, Hemant Agrawal, Sachin Saxena, Jingjing Wu, Beilei Xing,
	Harman Kalra, Jerin Jacob, Nithin Dabilpuram, John Griffin,
	Fiona Trahe, Deepak Kumar Jain
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena, adamx.dybkowski

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Sachin Saxena <sachin.saxena@oss.nxp.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/common/dpaax/dpaax_iova_table.c | 10 +--
 drivers/common/iavf/iavf_impl.c         |  9 +--
 drivers/common/octeontx/octeontx_mbox.c |  9 +--
 drivers/common/octeontx2/otx2_common.c  | 96 +++----------------------
 drivers/common/qat/qat_logs.c           | 17 +----
 5 files changed, 15 insertions(+), 126 deletions(-)

diff --git a/drivers/common/dpaax/dpaax_iova_table.c b/drivers/common/dpaax/dpaax_iova_table.c
index 98b076e09..5ba8ed193 100644
--- a/drivers/common/dpaax/dpaax_iova_table.c
+++ b/drivers/common/dpaax/dpaax_iova_table.c
@@ -7,9 +7,6 @@
 #include "dpaax_iova_table.h"
 #include "dpaax_logs.h"
 
-/* Global dpaax logger identifier */
-int dpaax_logger;
-
 /* Global table reference */
 struct dpaax_iova_table *dpaax_iova_table_p;
 
@@ -463,9 +460,4 @@ dpaax_handle_memevents(void)
 					       dpaax_memevent_cb, NULL);
 }
 
-RTE_INIT(dpaax_log)
-{
-	dpaax_logger = rte_log_register("pmd.common.dpaax");
-	if (dpaax_logger >= 0)
-		rte_log_set_level(dpaax_logger, RTE_LOG_ERR);
-}
+RTE_LOG_REGISTER(dpaax_logger, pmd.common.dpaax, ERR);
diff --git a/drivers/common/iavf/iavf_impl.c b/drivers/common/iavf/iavf_impl.c
index 6174a9144..fc0da3175 100644
--- a/drivers/common/iavf/iavf_impl.c
+++ b/drivers/common/iavf/iavf_impl.c
@@ -13,8 +13,6 @@
 #include "iavf_type.h"
 #include "iavf_prototype.h"
 
-int iavf_common_logger;
-
 enum iavf_status
 iavf_allocate_dma_mem_d(__rte_unused struct iavf_hw *hw,
 			struct iavf_dma_mem *mem,
@@ -87,9 +85,4 @@ iavf_free_virt_mem_d(__rte_unused struct iavf_hw *hw,
 	return IAVF_SUCCESS;
 }
 
-RTE_INIT(iavf_common_init_log)
-{
-	iavf_common_logger = rte_log_register("pmd.common.iavf");
-	if (iavf_common_logger >= 0)
-		rte_log_set_level(iavf_common_logger, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(iavf_common_logger, pmd.common.iavf, NOTICE);
diff --git a/drivers/common/octeontx/octeontx_mbox.c b/drivers/common/octeontx/octeontx_mbox.c
index effe0b267..f414267e4 100644
--- a/drivers/common/octeontx/octeontx_mbox.c
+++ b/drivers/common/octeontx/octeontx_mbox.c
@@ -68,14 +68,7 @@ struct mbox_intf_ver {
 	uint32_t minor:10;
 };
 
-int octeontx_logtype_mbox;
-
-RTE_INIT(otx_init_log)
-{
-	octeontx_logtype_mbox = rte_log_register("pmd.octeontx.mbox");
-	if (octeontx_logtype_mbox >= 0)
-		rte_log_set_level(octeontx_logtype_mbox, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(octeontx_logtype_mbox, pmd.octeontx.mbox, NOTICE);
 
 static inline void
 mbox_msgcpy(volatile uint8_t *d, volatile const uint8_t *s, uint16_t size)
diff --git a/drivers/common/octeontx2/otx2_common.c b/drivers/common/octeontx2/otx2_common.c
index 5e7272f69..b292e999a 100644
--- a/drivers/common/octeontx2/otx2_common.c
+++ b/drivers/common/octeontx2/otx2_common.c
@@ -203,89 +203,13 @@ void otx2_parse_common_devargs(struct rte_kvargs *kvlist)
 	idev->npa_lock_mask = npa_lock_mask;
 }
 
-/**
- * @internal
- */
-int otx2_logtype_base;
-/**
- * @internal
- */
-int otx2_logtype_mbox;
-/**
- * @internal
- */
-int otx2_logtype_npa;
-/**
- * @internal
- */
-int otx2_logtype_nix;
-/**
- * @internal
- */
-int otx2_logtype_npc;
-/**
- * @internal
- */
-int otx2_logtype_tm;
-/**
- * @internal
- */
-int otx2_logtype_sso;
-/**
- * @internal
- */
-int otx2_logtype_tim;
-/**
- * @internal
- */
-int otx2_logtype_dpi;
-/**
- * @internal
- */
-int otx2_logtype_ep;
-
-RTE_INIT(otx2_log_init);
-static void
-otx2_log_init(void)
-{
-	otx2_logtype_base = rte_log_register("pmd.octeontx2.base");
-	if (otx2_logtype_base >= 0)
-		rte_log_set_level(otx2_logtype_base, RTE_LOG_NOTICE);
-
-	otx2_logtype_mbox = rte_log_register("pmd.octeontx2.mbox");
-	if (otx2_logtype_mbox >= 0)
-		rte_log_set_level(otx2_logtype_mbox, RTE_LOG_NOTICE);
-
-	otx2_logtype_npa = rte_log_register("pmd.mempool.octeontx2");
-	if (otx2_logtype_npa >= 0)
-		rte_log_set_level(otx2_logtype_npa, RTE_LOG_NOTICE);
-
-	otx2_logtype_nix = rte_log_register("pmd.net.octeontx2");
-	if (otx2_logtype_nix >= 0)
-		rte_log_set_level(otx2_logtype_nix, RTE_LOG_NOTICE);
-
-	otx2_logtype_npc = rte_log_register("pmd.net.octeontx2.flow");
-	if (otx2_logtype_npc >= 0)
-		rte_log_set_level(otx2_logtype_npc, RTE_LOG_NOTICE);
-
-	otx2_logtype_tm = rte_log_register("pmd.net.octeontx2.tm");
-	if (otx2_logtype_tm >= 0)
-		rte_log_set_level(otx2_logtype_tm, RTE_LOG_NOTICE);
-
-	otx2_logtype_sso = rte_log_register("pmd.event.octeontx2");
-	if (otx2_logtype_sso >= 0)
-		rte_log_set_level(otx2_logtype_sso, RTE_LOG_NOTICE);
-
-	otx2_logtype_tim = rte_log_register("pmd.event.octeontx2.timer");
-	if (otx2_logtype_tim >= 0)
-		rte_log_set_level(otx2_logtype_tim, RTE_LOG_NOTICE);
-
-	otx2_logtype_dpi = rte_log_register("pmd.raw.octeontx2.dpi");
-	if (otx2_logtype_dpi >= 0)
-		rte_log_set_level(otx2_logtype_dpi, RTE_LOG_NOTICE);
-
-	otx2_logtype_ep = rte_log_register("pmd.raw.octeontx2.ep");
-	if (otx2_logtype_ep >= 0)
-		rte_log_set_level(otx2_logtype_ep, RTE_LOG_NOTICE);
-
-}
+RTE_LOG_REGISTER(otx2_logtype_base, pmd.octeontx2.base, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_mbox, pmd.octeontx2.mbox, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_npa, pmd.mempool.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_nix, pmd.net.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_npc, pmd.net.octeontx2.flow, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_tm, pmd.net.octeontx2.tm, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_sso, pmd.event.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_tim, pmd.event.octeontx2.timer, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_dpi, pmd.raw.octeontx2.dpi, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_ep, pmd.raw.octeontx2.ep, NOTICE);
diff --git a/drivers/common/qat/qat_logs.c b/drivers/common/qat/qat_logs.c
index dfd0cbe5d..fa48be53c 100644
--- a/drivers/common/qat/qat_logs.c
+++ b/drivers/common/qat/qat_logs.c
@@ -7,9 +7,6 @@
 
 #include "qat_logs.h"
 
-int qat_gen_logtype;
-int qat_dp_logtype;
-
 int
 qat_hexdump_log(uint32_t level, uint32_t logtype, const char *title,
 		const void *buf, unsigned int len)
@@ -20,15 +17,5 @@ qat_hexdump_log(uint32_t level, uint32_t logtype, const char *title,
 	return 0;
 }
 
-RTE_INIT(qat_pci_init_log)
-{
-	/* Non-data-path logging for pci device and all services */
-	qat_gen_logtype = rte_log_register("pmd.qat_general");
-	if (qat_gen_logtype >= 0)
-		rte_log_set_level(qat_gen_logtype, RTE_LOG_NOTICE);
-
-	/* data-path logging for all services */
-	qat_dp_logtype = rte_log_register("pmd.qat_dp");
-	if (qat_dp_logtype >= 0)
-		rte_log_set_level(qat_dp_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(qat_gen_logtype, pmd.qat_general, NOTICE);
+RTE_LOG_REGISTER(qat_dp_logtype, pmd.qat_dp, NOTICE);
-- 
2.27.0


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

* [dpdk-dev]  [PATCH v2 11/13] drivers/bus: use log register macro
  2020-07-01  3:58 ` [dpdk-dev] [PATCH v2 " jerinj
                     ` (9 preceding siblings ...)
  2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 10/13] drivers/common: " jerinj
@ 2020-07-01  3:58   ` jerinj
  2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 12/13] drivers/baseband: " jerinj
                     ` (2 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01  3:58 UTC (permalink / raw)
  To: dev, Hemant Agrawal, Sachin Saxena, Rosen Xu, Stephen Hemminger
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Sachin Saxena <sachin.saxena@oss.nxp.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/bus/dpaa/dpaa_bus.c      | 10 +---------
 drivers/bus/fslmc/fslmc_bus.c    | 11 +----------
 drivers/bus/ifpga/ifpga_bus.c    |  9 +--------
 drivers/bus/vdev/vdev.c          | 10 +---------
 drivers/bus/vmbus/vmbus_common.c |  9 +--------
 5 files changed, 5 insertions(+), 44 deletions(-)

diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c
index d53fe6083..0d8b13e5f 100644
--- a/drivers/bus/dpaa/dpaa_bus.c
+++ b/drivers/bus/dpaa/dpaa_bus.c
@@ -42,8 +42,6 @@
 #include <fsl_bman.h>
 #include <netcfg.h>
 
-int dpaa_logtype_bus;
-
 static struct rte_dpaa_bus rte_dpaa_bus;
 struct netcfg_info *dpaa_netcfg;
 
@@ -749,10 +747,4 @@ static struct rte_dpaa_bus rte_dpaa_bus = {
 };
 
 RTE_REGISTER_BUS(FSL_DPAA_BUS_NAME, rte_dpaa_bus.bus);
-
-RTE_INIT(dpaa_init_log)
-{
-	dpaa_logtype_bus = rte_log_register("bus.dpaa");
-	if (dpaa_logtype_bus >= 0)
-		rte_log_set_level(dpaa_logtype_bus, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa_logtype_bus, bus.dpaa, NOTICE);
diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
index afbd82e8d..d9f403bd9 100644
--- a/drivers/bus/fslmc/fslmc_bus.c
+++ b/drivers/bus/fslmc/fslmc_bus.c
@@ -21,8 +21,6 @@
 
 #include <dpaax_iova_table.h>
 
-int dpaa2_logtype_bus;
-
 #define VFIO_IOMMU_GROUP_PATH "/sys/kernel/iommu_groups"
 #define FSLMC_BUS_NAME	fslmc
 
@@ -649,11 +647,4 @@ struct rte_fslmc_bus rte_fslmc_bus = {
 };
 
 RTE_REGISTER_BUS(FSLMC_BUS_NAME, rte_fslmc_bus.bus);
-
-RTE_INIT(fslmc_init_log)
-{
-	/* Bus level logs */
-	dpaa2_logtype_bus = rte_log_register("bus.fslmc");
-	if (dpaa2_logtype_bus >= 0)
-		rte_log_set_level(dpaa2_logtype_bus, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa2_logtype_bus, bus.fslmc, NOTICE);
diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c
index addbc3e86..103915d43 100644
--- a/drivers/bus/ifpga/ifpga_bus.c
+++ b/drivers/bus/ifpga/ifpga_bus.c
@@ -32,7 +32,6 @@
 #include "ifpga_logs.h"
 #include "ifpga_common.h"
 
-int ifpga_bus_logtype;
 
 /* Forward declaration to access Intel FPGA bus
  * on which iFPGA devices are connected
@@ -474,10 +473,4 @@ static struct rte_bus rte_ifpga_bus = {
 };
 
 RTE_REGISTER_BUS(IFPGA_BUS_NAME, rte_ifpga_bus);
-
-RTE_INIT(ifpga_init_log)
-{
-	ifpga_bus_logtype = rte_log_register("bus.ifpga");
-	if (ifpga_bus_logtype >= 0)
-		rte_log_set_level(ifpga_bus_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(ifpga_bus_logtype, bus.ifpga, NOTICE);
diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index a89ea2353..d746149a2 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -27,8 +27,6 @@
 
 #define VDEV_MP_KEY	"bus_vdev_mp"
 
-int vdev_logtype_bus;
-
 /* Forward declare to access virtual bus name */
 static struct rte_bus rte_vdev_bus;
 
@@ -557,10 +555,4 @@ static struct rte_bus rte_vdev_bus = {
 };
 
 RTE_REGISTER_BUS(vdev, rte_vdev_bus);
-
-RTE_INIT(vdev_init_log)
-{
-	vdev_logtype_bus = rte_log_register("bus.vdev");
-	if (vdev_logtype_bus >= 0)
-		rte_log_set_level(vdev_logtype_bus, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(vdev_logtype_bus, bus.vdev, NOTICE);
diff --git a/drivers/bus/vmbus/vmbus_common.c b/drivers/bus/vmbus/vmbus_common.c
index 3adef01c9..4c9ac33ac 100644
--- a/drivers/bus/vmbus/vmbus_common.c
+++ b/drivers/bus/vmbus/vmbus_common.c
@@ -22,7 +22,6 @@
 
 #include "private.h"
 
-int vmbus_logtype_bus;
 extern struct rte_vmbus_bus rte_vmbus_bus;
 
 /* map a particular resource from a file */
@@ -298,10 +297,4 @@ struct rte_vmbus_bus rte_vmbus_bus = {
 };
 
 RTE_REGISTER_BUS(vmbus, rte_vmbus_bus.bus);
-
-RTE_INIT(vmbus_init_log)
-{
-	vmbus_logtype_bus = rte_log_register("bus.vmbus");
-	if (vmbus_logtype_bus >= 0)
-		rte_log_set_level(vmbus_logtype_bus, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(vmbus_logtype_bus, bus.vmbus, NOTICE);
-- 
2.27.0


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

* [dpdk-dev] [PATCH v2 12/13] drivers/baseband: use log register macro
  2020-07-01  3:58 ` [dpdk-dev] [PATCH v2 " jerinj
                     ` (10 preceding siblings ...)
  2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 11/13] drivers/bus: " jerinj
@ 2020-07-01  3:58   ` jerinj
  2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 13/13] app/test: " jerinj
  2020-07-01  6:48   ` [dpdk-dev] [PATCH v3 00/13] rte_log registration usage improvement jerinj
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01  3:58 UTC (permalink / raw)
  To: dev, Nicolas Chautru
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 .../baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 17 +++++------------
 drivers/baseband/fpga_lte_fec/fpga_lte_fec.c   | 18 +++++-------------
 drivers/baseband/null/bbdev_null.c             |  9 +--------
 .../baseband/turbo_sw/bbdev_turbo_software.c   |  9 +--------
 4 files changed, 12 insertions(+), 41 deletions(-)

diff --git a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
index e152b206e..aca0ca999 100644
--- a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
+++ b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
@@ -23,8 +23,11 @@
 #include "fpga_5gnr_fec.h"
 #include "rte_pmd_fpga_5gnr_fec.h"
 
-/* 5GNR SW PMD logging ID */
-static int fpga_5gnr_fec_logtype;
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+RTE_LOG_REGISTER(fpga_5gnr_fec_logtype, pmd.bb.fpga_5gnr_fec, DEBUG);
+#else
+RTE_LOG_REGISTER(fpga_5gnr_fec_logtype, pmd.bb.fpga_5gnr_fec, NOTICE);
+#endif
 
 #ifdef RTE_LIBRTE_BBDEV_DEBUG
 
@@ -2175,13 +2178,3 @@ RTE_PMD_REGISTER_PCI(FPGA_5GNR_FEC_VF_DRIVER_NAME, fpga_5gnr_fec_pci_vf_driver);
 RTE_PMD_REGISTER_PCI_TABLE(FPGA_5GNR_FEC_VF_DRIVER_NAME,
 		pci_id_fpga_5gnr_fec_vf_map);
 
-RTE_INIT(fpga_5gnr_fec_init_log)
-{
-	fpga_5gnr_fec_logtype = rte_log_register("pmd.bb.fpga_5gnr_fec");
-	if (fpga_5gnr_fec_logtype >= 0)
-#ifdef RTE_LIBRTE_BBDEV_DEBUG
-		rte_log_set_level(fpga_5gnr_fec_logtype, RTE_LOG_DEBUG);
-#else
-		rte_log_set_level(fpga_5gnr_fec_logtype, RTE_LOG_NOTICE);
-#endif
-}
diff --git a/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c b/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c
index abc5a1bf6..6be9131e7 100644
--- a/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c
+++ b/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c
@@ -22,8 +22,11 @@
 
 #include "fpga_lte_fec.h"
 
-/* Turbo SW PMD logging ID */
-static int fpga_lte_fec_logtype;
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+RTE_LOG_REGISTER(fpga_lte_fec_logtype, pmd.bb.fpga_lte_fec, DEBUG);
+#else
+RTE_LOG_REGISTER(fpga_lte_fec_logtype, pmd.bb.fpga_lte_fec, NOTICE);
+#endif
 
 /* Helper macro for logging */
 #define rte_bbdev_log(level, fmt, ...) \
@@ -2662,14 +2665,3 @@ RTE_PMD_REGISTER_PCI_TABLE(FPGA_LTE_FEC_PF_DRIVER_NAME,
 RTE_PMD_REGISTER_PCI(FPGA_LTE_FEC_VF_DRIVER_NAME, fpga_lte_fec_pci_vf_driver);
 RTE_PMD_REGISTER_PCI_TABLE(FPGA_LTE_FEC_VF_DRIVER_NAME,
 		pci_id_fpga_lte_fec_vf_map);
-
-RTE_INIT(fpga_lte_fec_init_log)
-{
-	fpga_lte_fec_logtype = rte_log_register("pmd.bb.fpga_lte_fec");
-	if (fpga_lte_fec_logtype >= 0)
-#ifdef RTE_LIBRTE_BBDEV_DEBUG
-		rte_log_set_level(fpga_lte_fec_logtype, RTE_LOG_DEBUG);
-#else
-		rte_log_set_level(fpga_lte_fec_logtype, RTE_LOG_NOTICE);
-#endif
-}
diff --git a/drivers/baseband/null/bbdev_null.c b/drivers/baseband/null/bbdev_null.c
index 2f2515101..dd11cd31c 100644
--- a/drivers/baseband/null/bbdev_null.c
+++ b/drivers/baseband/null/bbdev_null.c
@@ -15,8 +15,7 @@
 
 #define DRIVER_NAME baseband_null
 
-/* NULL BBDev logging ID */
-static int bbdev_null_logtype;
+RTE_LOG_REGISTER(bbdev_null_logtype, pmd.bb.null, NOTICE);
 
 /* Helper macro for logging */
 #define rte_bbdev_log(level, fmt, ...) \
@@ -348,9 +347,3 @@ RTE_PMD_REGISTER_PARAM_STRING(DRIVER_NAME,
 	BBDEV_NULL_SOCKET_ID_ARG"=<int>");
 RTE_PMD_REGISTER_ALIAS(DRIVER_NAME, bbdev_null);
 
-RTE_INIT(null_bbdev_init_log)
-{
-	bbdev_null_logtype = rte_log_register("pmd.bb.null");
-	if (bbdev_null_logtype >= 0)
-		rte_log_set_level(bbdev_null_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/baseband/turbo_sw/bbdev_turbo_software.c b/drivers/baseband/turbo_sw/bbdev_turbo_software.c
index bb62276b9..daecfd21a 100644
--- a/drivers/baseband/turbo_sw/bbdev_turbo_software.c
+++ b/drivers/baseband/turbo_sw/bbdev_turbo_software.c
@@ -34,8 +34,7 @@
 
 #define DRIVER_NAME baseband_turbo_sw
 
-/* Turbo SW PMD logging ID */
-static int bbdev_turbo_sw_logtype;
+RTE_LOG_REGISTER(bbdev_turbo_sw_logtype, pmd.bb.turbo_sw, NOTICE);
 
 /* Helper macro for logging */
 #define rte_bbdev_log(level, fmt, ...) \
@@ -1991,9 +1990,3 @@ RTE_PMD_REGISTER_PARAM_STRING(DRIVER_NAME,
 	TURBO_SW_SOCKET_ID_ARG"=<int>");
 RTE_PMD_REGISTER_ALIAS(DRIVER_NAME, turbo_sw);
 
-RTE_INIT(turbo_sw_bbdev_init_log)
-{
-	bbdev_turbo_sw_logtype = rte_log_register("pmd.bb.turbo_sw");
-	if (bbdev_turbo_sw_logtype >= 0)
-		rte_log_set_level(bbdev_turbo_sw_logtype, RTE_LOG_NOTICE);
-}
-- 
2.27.0


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

* [dpdk-dev]  [PATCH v2 13/13] app/test: use log register macro
  2020-07-01  3:58 ` [dpdk-dev] [PATCH v2 " jerinj
                     ` (11 preceding siblings ...)
  2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 12/13] drivers/baseband: " jerinj
@ 2020-07-01  3:58   ` jerinj
  2020-07-01  6:48   ` [dpdk-dev] [PATCH v3 00/13] rte_log registration usage improvement jerinj
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01  3:58 UTC (permalink / raw)
  To: dev, Byron Marohn, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Robert Sanford, Erik Gabriel Carrillo
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 app/test/test_efd.c            | 6 +-----
 app/test/test_hash.c           | 7 +------
 app/test/test_timer_racecond.c | 7 +------
 3 files changed, 3 insertions(+), 17 deletions(-)

diff --git a/app/test/test_efd.c b/app/test/test_efd.c
index e3e5e30ea..3d9aa8a57 100644
--- a/app/test/test_efd.c
+++ b/app/test/test_efd.c
@@ -32,12 +32,8 @@ struct flow_key {
 	uint8_t proto;
 } __rte_packed;
 
-int efd_logtype_test;
 
-RTE_INIT(test_efd_init_log)
-{
-	efd_logtype_test = rte_log_register("test.efd");
-}
+RTE_LOG_REGISTER(efd_logtype_test, test.efd, INFO);
 
 /*
  * Print out result of unit test efd operation.
diff --git a/app/test/test_hash.c b/app/test/test_hash.c
index afa3a1a3c..990a1815f 100644
--- a/app/test/test_hash.c
+++ b/app/test/test_hash.c
@@ -69,8 +69,6 @@ struct flow_key {
 	uint8_t proto;
 } __rte_packed;
 
-int hash_logtype_test;
-
 /*
  * Hash function that always returns the same value, to easily test what
  * happens when a bucket is full.
@@ -82,10 +80,7 @@ static uint32_t pseudo_hash(__rte_unused const void *keys,
 	return 3;
 }
 
-RTE_INIT(test_hash_init_log)
-{
-	hash_logtype_test = rte_log_register("test.hash");
-}
+RTE_LOG_REGISTER(hash_logtype_test, test.hash, INFO);
 
 /*
  * Print out result of unit test hash operation.
diff --git a/app/test/test_timer_racecond.c b/app/test/test_timer_racecond.c
index 4fc917995..28af9ca76 100644
--- a/app/test/test_timer_racecond.c
+++ b/app/test/test_timer_racecond.c
@@ -61,12 +61,7 @@ static volatile unsigned stop_slaves;
 
 static int reload_timer(struct rte_timer *tim);
 
-int timer_logtype_test;
-
-RTE_INIT(test_timer_init_log)
-{
-	timer_logtype_test = rte_log_register("test.timer");
-}
+RTE_LOG_REGISTER(timer_logtype_test, test.timer, INFO);
 
 static void
 timer_cb(struct rte_timer *tim, void *arg __rte_unused)
-- 
2.27.0


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

* [dpdk-dev] [PATCH v3 00/13] rte_log registration usage improvement
  2020-07-01  3:58 ` [dpdk-dev] [PATCH v2 " jerinj
                     ` (12 preceding siblings ...)
  2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 13/13] app/test: " jerinj
@ 2020-07-01  6:48   ` jerinj
  2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 01/13] eal/log: introduce log register macro jerinj
                       ` (13 more replies)
  13 siblings, 14 replies; 98+ messages in thread
From: jerinj @ 2020-07-01  6:48 UTC (permalink / raw)
  To: dev
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

This patch series improves the rte_log registration code snippet by
avoiding duplication of the code around registration by
introducing RTE_LOG_REGISTER macro.

v3:
- Fix the build issue reported at
  https://travis-ci.com/github/ovsrobot/dpdk/jobs/356167611

v2:
- RTE_LOG_REGISTER implemented using rte_log_register_type_and_pick_level()
- Added Sachin Saxena <sachin.saxena@oss.nxp.com> and  Adam Dybkowski
<adamx.dybkowski@intel.com> Acks.
- Rebase to ToT


Drivers not adapated to new macro
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I have converted all existing rte_log_register() to new macro, except
the following (as it has different usage style)
1) drivers/common/mlx5/mlx5_common.c
2) drivers/net/e1000/e1000_logs.c
3) drivers/net/sfc/sfc_ethdev.c

Example usage of new macro
~~~~~~~~~~~~~~~~~~~~~~~~~~
-/**
- * @internal
- */
-int otx2_logtype_base;
-/**
- * @internal
- */
-int otx2_logtype_mbox;
-/**
- * @internal
- */
-int otx2_logtype_npa;
-/**
- * @internal
- */
-int otx2_logtype_nix;
-/**
- * @internal
- */
-int otx2_logtype_npc;
-/**
- * @internal
- */
-int otx2_logtype_tm;
-/**
- * @internal
- */
-int otx2_logtype_sso;
-/**
- * @internal
- */
-int otx2_logtype_tim;
-/**
- * @internal
- */
-int otx2_logtype_dpi;
-/**
- * @internal
- */
-int otx2_logtype_ep;
-
-RTE_INIT(otx2_log_init);
-static void
-otx2_log_init(void)
-{
-       otx2_logtype_base = rte_log_register("pmd.octeontx2.base");
-       if (otx2_logtype_base >= 0)
-               rte_log_set_level(otx2_logtype_base, RTE_LOG_NOTICE);
-
-       otx2_logtype_mbox = rte_log_register("pmd.octeontx2.mbox");
-       if (otx2_logtype_mbox >= 0)
-               rte_log_set_level(otx2_logtype_mbox, RTE_LOG_NOTICE);
-
-       otx2_logtype_npa = rte_log_register("pmd.mempool.octeontx2");
-       if (otx2_logtype_npa >= 0)
-               rte_log_set_level(otx2_logtype_npa, RTE_LOG_NOTICE);
-
-       otx2_logtype_nix = rte_log_register("pmd.net.octeontx2");
-       if (otx2_logtype_nix >= 0)
-               rte_log_set_level(otx2_logtype_nix, RTE_LOG_NOTICE);
-
-       otx2_logtype_npc = rte_log_register("pmd.net.octeontx2.flow");
-       if (otx2_logtype_npc >= 0)
-               rte_log_set_level(otx2_logtype_npc, RTE_LOG_NOTICE);
-
-       otx2_logtype_tm = rte_log_register("pmd.net.octeontx2.tm");
-       if (otx2_logtype_tm >= 0)
-               rte_log_set_level(otx2_logtype_tm, RTE_LOG_NOTICE);
-
-       otx2_logtype_sso = rte_log_register("pmd.event.octeontx2");
-       if (otx2_logtype_sso >= 0)
-               rte_log_set_level(otx2_logtype_sso, RTE_LOG_NOTICE);
-
-       otx2_logtype_tim =
        rte_log_register("pmd.event.octeontx2.timer");
-       if (otx2_logtype_tim >= 0)
-               rte_log_set_level(otx2_logtype_tim, RTE_LOG_NOTICE);
-
-       otx2_logtype_dpi = rte_log_register("pmd.raw.octeontx2.dpi");
-       if (otx2_logtype_dpi >= 0)
-               rte_log_set_level(otx2_logtype_dpi, RTE_LOG_NOTICE);
-
-       otx2_logtype_ep = rte_log_register("pmd.raw.octeontx2.ep");
-       if (otx2_logtype_ep >= 0)
-               rte_log_set_level(otx2_logtype_ep, RTE_LOG_NOTICE);
-
-}
+RTE_LOG_REGISTER(otx2_logtype_base, pmd.octeontx2.base, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_mbox, pmd.octeontx2.mbox, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_npa, pmd.mempool.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_nix, pmd.net.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_npc, pmd.net.octeontx2.flow, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_tm, pmd.net.octeontx2.tm, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_sso, pmd.event.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_tim, pmd.event.octeontx2.timer, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_dpi, pmd.raw.octeontx2.dpi, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_ep, pmd.raw.octeontx2.ep, NOTICE);

Jerin Jacob (13):
  eal/log: introduce log register macro
  lib: use log register macro
  drivers/vdpa: use log register macro
  drivers/raw: use log register macro
  drivers/net: use log register macro
  drivers/mempool: use log register macro
  drivers/event: use log register macro
  drivers/crypto: use log register macro
  drivers/compress: use log register macro
  drivers/common: use log register macro
  drivers/bus: use log register macro
  drivers/baseband: use log register macro
  app/test: use log register macro

 app/test/test_efd.c                           |  6 +-
 app/test/test_hash.c                          |  7 +-
 app/test/test_timer_racecond.c                |  7 +-
 .../fpga_5gnr_fec/rte_fpga_5gnr_fec.c         | 17 +---
 drivers/baseband/fpga_lte_fec/fpga_lte_fec.c  | 18 +---
 drivers/baseband/null/bbdev_null.c            |  9 +-
 .../baseband/turbo_sw/bbdev_turbo_software.c  |  9 +-
 drivers/bus/dpaa/dpaa_bus.c                   | 10 +-
 drivers/bus/fslmc/fslmc_bus.c                 | 11 +--
 drivers/bus/ifpga/ifpga_bus.c                 |  9 +-
 drivers/bus/vdev/vdev.c                       | 10 +-
 drivers/bus/vmbus/vmbus_common.c              |  9 +-
 drivers/common/dpaax/dpaax_iova_table.c       | 10 +-
 drivers/common/iavf/iavf_impl.c               |  9 +-
 drivers/common/octeontx/octeontx_mbox.c       |  9 +-
 drivers/common/octeontx2/otx2_common.c        | 96 ++-----------------
 drivers/common/qat/qat_logs.c                 | 17 +---
 drivers/compress/isal/isal_compress_pmd.c     | 10 +-
 drivers/compress/octeontx/otx_zip_pmd.c       | 10 +-
 drivers/compress/zlib/zlib_pmd.c              | 10 +-
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c      |  8 +-
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c    |  8 +-
 drivers/crypto/caam_jr/caam_jr.c              |  8 +-
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c   | 11 +--
 drivers/crypto/dpaa_sec/dpaa_sec.c            | 10 +-
 drivers/crypto/kasumi/rte_kasumi_pmd.c        |  6 +-
 drivers/crypto/mvsam/rte_mrvl_pmd.c           |  7 +-
 drivers/crypto/nitrox/nitrox_logs.c           |  9 +-
 drivers/crypto/null/null_crypto_pmd.c         |  7 +-
 drivers/crypto/octeontx/otx_cryptodev.c       | 10 +-
 drivers/crypto/octeontx2/otx2_cryptodev.c     | 12 +--
 drivers/crypto/openssl/rte_openssl_pmd.c      |  7 +-
 .../scheduler/rte_cryptodev_scheduler.c       |  8 +-
 drivers/crypto/snow3g/rte_snow3g_pmd.c        |  7 +-
 drivers/crypto/virtio/virtio_cryptodev.c      | 39 ++------
 drivers/crypto/zuc/rte_zuc_pmd.c              |  7 +-
 drivers/event/dpaa/dpaa_eventdev.c            |  8 +-
 drivers/event/dpaa2/dpaa2_eventdev.c          | 10 +-
 drivers/event/octeontx/ssovf_evdev.c          |  8 +-
 drivers/event/octeontx/timvf_evdev.c          |  9 +-
 drivers/event/opdl/opdl_evdev.c               |  8 +-
 drivers/event/opdl/opdl_ring.c                |  2 -
 drivers/event/sw/sw_evdev.c                   | 11 +--
 drivers/mempool/dpaa/dpaa_mempool.c           | 10 +-
 drivers/mempool/dpaa2/dpaa2_hw_mempool.c      | 10 +-
 drivers/mempool/octeontx/octeontx_fpavf.c     | 10 +-
 drivers/net/af_packet/rte_eth_af_packet.c     |  8 +-
 drivers/net/af_xdp/rte_eth_af_xdp.c           |  8 +-
 drivers/net/ark/ark_ethdev.c                  | 10 +-
 drivers/net/atlantic/atl_ethdev.c             | 15 +--
 drivers/net/avp/avp_ethdev.c                  | 10 +-
 drivers/net/axgbe/axgbe_ethdev.c              | 15 +--
 drivers/net/bnx2x/bnx2x_ethdev.c              | 15 +--
 drivers/net/bnxt/bnxt_ethdev.c                |  9 +-
 drivers/net/bonding/rte_eth_bond_pmd.c        |  9 +-
 drivers/net/cxgbe/cxgbe_ethdev.c              | 15 +--
 drivers/net/dpaa/dpaa_ethdev.c                |  9 +-
 drivers/net/dpaa2/dpaa2_ethdev.c              |  9 +-
 drivers/net/ena/ena_ethdev.c                  | 48 ++--------
 drivers/net/enetc/enetc_ethdev.c              | 10 +-
 drivers/net/enic/enic_ethdev.c                |  9 +-
 drivers/net/failsafe/failsafe.c               | 10 +-
 drivers/net/fm10k/fm10k_ethdev.c              | 40 +-------
 drivers/net/hinic/hinic_pmd_ethdev.c          | 11 +--
 drivers/net/hns3/hns3_ethdev.c                | 15 +--
 drivers/net/i40e/i40e_ethdev.c                | 38 +-------
 drivers/net/iavf/iavf_ethdev.c                | 40 +-------
 drivers/net/ice/ice_ethdev.c                  | 38 +-------
 drivers/net/igc/igc_logs.c                    | 16 +---
 drivers/net/ionic/ionic_ethdev.c              | 10 +-
 drivers/net/ipn3ke/ipn3ke_ethdev.c            | 10 +-
 drivers/net/ixgbe/ixgbe_ethdev.c              | 39 ++------
 drivers/net/kni/rte_eth_kni.c                 |  9 +-
 drivers/net/liquidio/lio_ethdev.c             | 15 +--
 drivers/net/memif/rte_eth_memif.c             |  9 +-
 drivers/net/mlx4/mlx4.c                       | 11 +--
 drivers/net/mlx5/mlx5.c                       | 10 +-
 drivers/net/mvneta/mvneta_ethdev.c            | 10 +-
 drivers/net/mvpp2/mrvl_ethdev.c               | 10 +-
 drivers/net/netvsc/hn_ethdev.c                | 15 +--
 drivers/net/nfp/nfp_net.c                     | 15 +--
 drivers/net/null/rte_eth_null.c               |  8 +-
 drivers/net/octeontx/octeontx_ethdev.c        | 21 +---
 drivers/net/pcap/rte_eth_pcap.c               |  8 +-
 drivers/net/pfe/pfe_ethdev.c                  | 10 +-
 drivers/net/qede/qede_ethdev.c                | 16 +---
 drivers/net/ring/rte_eth_ring.c               |  8 +-
 drivers/net/softnic/rte_eth_softnic.c         | 10 +-
 drivers/net/szedata2/rte_eth_szedata2.c       | 15 +--
 drivers/net/tap/rte_eth_tap.c                 |  9 +-
 drivers/net/thunderx/nicvf_ethdev.c           | 21 +---
 drivers/net/vdev_netvsc/vdev_netvsc.c         | 13 +--
 drivers/net/vhost/rte_eth_vhost.c             |  8 +-
 drivers/net/virtio/virtio_ethdev.c            | 15 +--
 drivers/net/vmxnet3/vmxnet3_ethdev.c          | 15 +--
 drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c         | 11 +--
 drivers/raw/dpaa2_qdma/dpaa2_qdma.c           | 11 +--
 drivers/raw/ifpga/ifpga_rawdev.c              | 10 +-
 drivers/raw/ioat/ioat_rawdev.c                | 12 +--
 drivers/raw/ioat/rte_ioat_rawdev.h            |  2 -
 drivers/raw/ntb/ntb.c                         | 10 +-
 drivers/raw/skeleton/skeleton_rawdev.c        | 11 +--
 drivers/vdpa/ifc/ifcvf_vdpa.c                 | 10 +-
 drivers/vdpa/mlx5/mlx5_vdpa.c                 |  7 +-
 lib/librte_bbdev/rte_bbdev.c                  |  8 +-
 lib/librte_bpf/bpf.c                          |  9 +-
 lib/librte_cfgfile/rte_cfgfile.c              |  8 +-
 lib/librte_compressdev/rte_compressdev.c      |  7 +-
 lib/librte_compressdev/rte_compressdev_pmd.c  |  2 -
 lib/librte_eal/include/rte_log.h              | 24 +++++
 lib/librte_ethdev/rte_ethdev.c                |  9 +-
 lib/librte_eventdev/rte_event_timer_adapter.c | 21 +---
 lib/librte_flow_classify/rte_flow_classify.c  | 10 +-
 lib/librte_graph/graph.c                      |  7 +-
 lib/librte_member/rte_member.c                |  9 +-
 lib/librte_metrics/rte_metrics_telemetry.c    |  5 +-
 lib/librte_node/log.c                         |  9 +-
 lib/librte_pdump/rte_pdump.c                  |  9 +-
 lib/librte_rawdev/rte_rawdev.c                |  7 +-
 lib/librte_rcu/rte_rcu_qsbr.c                 |  9 +-
 lib/librte_stack/rte_stack.c                  |  7 +-
 lib/librte_vhost/vhost.c                      | 15 +--
 122 files changed, 228 insertions(+), 1321 deletions(-)

-- 
2.27.0


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

* [dpdk-dev] [PATCH v3 01/13] eal/log: introduce log register macro
  2020-07-01  6:48   ` [dpdk-dev] [PATCH v3 00/13] rte_log registration usage improvement jerinj
@ 2020-07-01  6:48     ` jerinj
  2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 02/13] lib: use " jerinj
                       ` (12 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01  6:48 UTC (permalink / raw)
  To: dev
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Introducing the RTE_LOG_REGISTER macro to avoid the code duplication
in the log registration process.

It is a wrapper macro for declaring the logtype, register the log and sets
it's level in the constructor context.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 lib/librte_eal/include/rte_log.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/lib/librte_eal/include/rte_log.h b/lib/librte_eal/include/rte_log.h
index 1789ede56..eaf66e4f6 100644
--- a/lib/librte_eal/include/rte_log.h
+++ b/lib/librte_eal/include/rte_log.h
@@ -376,6 +376,30 @@ int rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap)
 		 RTE_LOGTYPE_ ## t, # t ": " __VA_ARGS__) :	\
 	 0)
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Register a dynamic log type in constructor context with its name and level.
+ *
+ * It is a wrapper macro for declaring the logtype, register the log and
+ * sets it's level in the constructor context.
+ *
+ * @param type
+ *   The log type identifier
+ * @param name
+ *    Name for the log type to be registered
+ * @param level
+ *   Log level. A value between EMERG (1) and DEBUG (8).
+ */
+#define RTE_LOG_REGISTER(type, name, level)				\
+int type;								\
+RTE_INIT(__##type)							\
+{									\
+	type = rte_log_register_type_and_pick_level(RTE_STR(name),	\
+						    RTE_LOG_##level);	\
+}
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.27.0


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

* [dpdk-dev]  [PATCH v3 02/13] lib: use log register macro
  2020-07-01  6:48   ` [dpdk-dev] [PATCH v3 00/13] rte_log registration usage improvement jerinj
  2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 01/13] eal/log: introduce log register macro jerinj
@ 2020-07-01  6:48     ` jerinj
  2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 03/13] drivers/vdpa: " jerinj
                       ` (11 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01  6:48 UTC (permalink / raw)
  To: dev, Nicolas Chautru, Konstantin Ananyev, Cristian Dumitrescu,
	Fiona Trahe, Ashish Gupta, Thomas Monjalon, Ferruh Yigit,
	Andrew Rybchenko, Erik Gabriel Carrillo, Jerin Jacob,
	Bernard Iremonger, Kiran Kumar K, Nithin Dabilpuram, Yipeng Wang,
	Sameh Gobriel, Pavan Nikhilesh, Reshma Pattan, Nipun Gupta,
	Hemant Agrawal, Honnappa Nagarahalli, Gage Eads, Olivier Matz,
	Maxime Coquelin, Zhihong Wang, Xiaolong Ye
  Cc: david.marchand, sachin.saxena, adamx.dybkowski

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 lib/librte_bbdev/rte_bbdev.c                  |  8 +------
 lib/librte_bpf/bpf.c                          |  9 +-------
 lib/librte_cfgfile/rte_cfgfile.c              |  8 +------
 lib/librte_compressdev/rte_compressdev.c      |  7 +------
 lib/librte_compressdev/rte_compressdev_pmd.c  |  2 --
 lib/librte_ethdev/rte_ethdev.c                |  9 +++-----
 lib/librte_eventdev/rte_event_timer_adapter.c | 21 +++----------------
 lib/librte_flow_classify/rte_flow_classify.c  | 10 +--------
 lib/librte_graph/graph.c                      |  7 +------
 lib/librte_member/rte_member.c                |  9 +-------
 lib/librte_metrics/rte_metrics_telemetry.c    |  5 ++---
 lib/librte_node/log.c                         |  9 +-------
 lib/librte_pdump/rte_pdump.c                  |  9 ++------
 lib/librte_rawdev/rte_rawdev.c                |  7 +++----
 lib/librte_rcu/rte_rcu_qsbr.c                 |  9 +-------
 lib/librte_stack/rte_stack.c                  |  7 +------
 lib/librte_vhost/vhost.c                      | 15 ++-----------
 17 files changed, 25 insertions(+), 126 deletions(-)

diff --git a/lib/librte_bbdev/rte_bbdev.c b/lib/librte_bbdev/rte_bbdev.c
index f6fe05aca..578f44484 100644
--- a/lib/librte_bbdev/rte_bbdev.c
+++ b/lib/librte_bbdev/rte_bbdev.c
@@ -29,7 +29,7 @@
 
 
 /* BBDev library logging ID */
-static int bbdev_logtype;
+RTE_LOG_REGISTER(bbdev_logtype, lib.bbdev, NOTICE);
 
 /* Helper macro for logging */
 #define rte_bbdev_log(level, fmt, ...) \
@@ -1134,9 +1134,3 @@ rte_bbdev_op_type_str(enum rte_bbdev_op_type op_type)
 	return NULL;
 }
 
-RTE_INIT(rte_bbdev_init_log)
-{
-	bbdev_logtype = rte_log_register("lib.bbdev");
-	if (bbdev_logtype >= 0)
-		rte_log_set_level(bbdev_logtype, RTE_LOG_NOTICE);
-}
diff --git a/lib/librte_bpf/bpf.c b/lib/librte_bpf/bpf.c
index 7e1879ffa..8d15885bc 100644
--- a/lib/librte_bpf/bpf.c
+++ b/lib/librte_bpf/bpf.c
@@ -14,8 +14,6 @@
 
 #include "bpf_impl.h"
 
-int rte_bpf_logtype;
-
 void
 rte_bpf_destroy(struct rte_bpf *bpf)
 {
@@ -55,9 +53,4 @@ bpf_jit(struct rte_bpf *bpf)
 	return rc;
 }
 
-RTE_INIT(rte_bpf_init_log)
-{
-	rte_bpf_logtype = rte_log_register("lib.bpf");
-	if (rte_bpf_logtype >= 0)
-		rte_log_set_level(rte_bpf_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(rte_bpf_logtype, lib.bpf, INFO);
diff --git a/lib/librte_cfgfile/rte_cfgfile.c b/lib/librte_cfgfile/rte_cfgfile.c
index 714717dd9..876c10d17 100644
--- a/lib/librte_cfgfile/rte_cfgfile.c
+++ b/lib/librte_cfgfile/rte_cfgfile.c
@@ -27,7 +27,7 @@ struct rte_cfgfile {
 	struct rte_cfgfile_section *sections;
 };
 
-static int cfgfile_logtype;
+RTE_LOG_REGISTER(cfgfile_logtype, lib.cfgfile, INFO);
 
 #define CFG_LOG(level, fmt, args...)					\
 	rte_log(RTE_LOG_ ## level, cfgfile_logtype, "%s(): " fmt "\n",	\
@@ -567,9 +567,3 @@ rte_cfgfile_has_entry(struct rte_cfgfile *cfg, const char *sectionname,
 	return rte_cfgfile_get_entry(cfg, sectionname, entryname) != NULL;
 }
 
-RTE_INIT(cfgfile_init)
-{
-	cfgfile_logtype = rte_log_register("lib.cfgfile");
-	if (cfgfile_logtype >= 0)
-		rte_log_set_level(cfgfile_logtype, RTE_LOG_INFO);
-}
diff --git a/lib/librte_compressdev/rte_compressdev.c b/lib/librte_compressdev/rte_compressdev.c
index b3c5651dc..49a342f40 100644
--- a/lib/librte_compressdev/rte_compressdev.c
+++ b/lib/librte_compressdev/rte_compressdev.c
@@ -763,9 +763,4 @@ rte_compressdev_name_get(uint8_t dev_id)
 	return dev->data->name;
 }
 
-RTE_INIT(rte_compressdev_log)
-{
-	compressdev_logtype = rte_log_register("lib.compressdev");
-	if (compressdev_logtype >= 0)
-		rte_log_set_level(compressdev_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(compressdev_logtype, lib.compressdev, NOTICE);
diff --git a/lib/librte_compressdev/rte_compressdev_pmd.c b/lib/librte_compressdev/rte_compressdev_pmd.c
index 46b25565a..7f500d76d 100644
--- a/lib/librte_compressdev/rte_compressdev_pmd.c
+++ b/lib/librte_compressdev/rte_compressdev_pmd.c
@@ -10,8 +10,6 @@
 #include "rte_compressdev_internal.h"
 #include "rte_compressdev_pmd.h"
 
-int compressdev_logtype;
-
 /**
  * Parse name from argument
  */
diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 8e10a6fc3..d06b7f9b1 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -46,8 +46,6 @@
 #include "ethdev_profile.h"
 #include "ethdev_private.h"
 
-int rte_eth_dev_logtype;
-
 static const char *MZ_RTE_ETH_DEV_DATA = "rte_eth_dev_data";
 struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS];
 
@@ -5295,11 +5293,10 @@ handle_port_link_status(const char *cmd __rte_unused,
 	return 0;
 }
 
-RTE_INIT(ethdev_init_log)
+RTE_LOG_REGISTER(rte_eth_dev_logtype, lib.ethdev, INFO);
+
+RTE_INIT(ethdev_init_telemetry)
 {
-	rte_eth_dev_logtype = rte_log_register("lib.ethdev");
-	if (rte_eth_dev_logtype >= 0)
-		rte_log_set_level(rte_eth_dev_logtype, RTE_LOG_INFO);
 	rte_telemetry_register_cmd("/ethdev/list", handle_port_list,
 			"Returns list of available ethdev ports. Takes no parameters");
 	rte_telemetry_register_cmd("/ethdev/xstats", handle_port_xstats,
diff --git a/lib/librte_eventdev/rte_event_timer_adapter.c b/lib/librte_eventdev/rte_event_timer_adapter.c
index 005459f7d..ae68b4566 100644
--- a/lib/librte_eventdev/rte_event_timer_adapter.c
+++ b/lib/librte_eventdev/rte_event_timer_adapter.c
@@ -29,9 +29,9 @@
 #define DATA_MZ_NAME_MAX_LEN 64
 #define DATA_MZ_NAME_FORMAT "rte_event_timer_adapter_data_%d"
 
-static int evtim_logtype;
-static int evtim_svc_logtype;
-static int evtim_buffer_logtype;
+RTE_LOG_REGISTER(evtim_logtype, lib.eventdev.adapter.timer, NOTICE);
+RTE_LOG_REGISTER(evtim_buffer_logtype, lib.eventdev.adapter.timer, NOTICE);
+RTE_LOG_REGISTER(evtim_svc_logtype, lib.eventdev.adapter.timer.svc, NOTICE);
 
 static struct rte_event_timer_adapter adapters[RTE_EVENT_TIMER_ADAPTER_NUM_MAX];
 
@@ -1188,18 +1188,3 @@ static const struct rte_event_timer_adapter_ops swtim_ops = {
 	.cancel_burst		= swtim_cancel_burst,
 };
 
-RTE_INIT(event_timer_adapter_init_log)
-{
-	evtim_logtype = rte_log_register("lib.eventdev.adapter.timer");
-	if (evtim_logtype >= 0)
-		rte_log_set_level(evtim_logtype, RTE_LOG_NOTICE);
-
-	evtim_buffer_logtype = rte_log_register("lib.eventdev.adapter.timer."
-						"buffer");
-	if (evtim_buffer_logtype >= 0)
-		rte_log_set_level(evtim_buffer_logtype, RTE_LOG_NOTICE);
-
-	evtim_svc_logtype = rte_log_register("lib.eventdev.adapter.timer.svc");
-	if (evtim_svc_logtype >= 0)
-		rte_log_set_level(evtim_svc_logtype, RTE_LOG_NOTICE);
-}
diff --git a/lib/librte_flow_classify/rte_flow_classify.c b/lib/librte_flow_classify/rte_flow_classify.c
index 6022064d8..639b0051f 100644
--- a/lib/librte_flow_classify/rte_flow_classify.c
+++ b/lib/librte_flow_classify/rte_flow_classify.c
@@ -10,8 +10,6 @@
 #include <rte_table_acl.h>
 #include <stdbool.h>
 
-int librte_flow_classify_logtype;
-
 static uint32_t unique_id = 1;
 
 enum rte_flow_classify_table_type table_type
@@ -669,10 +667,4 @@ rte_flow_classifier_query(struct rte_flow_classifier *cls,
 	return ret;
 }
 
-RTE_INIT(librte_flow_classify_init_log)
-{
-	librte_flow_classify_logtype =
-		rte_log_register("lib.flow_classify");
-	if (librte_flow_classify_logtype >= 0)
-		rte_log_set_level(librte_flow_classify_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(librte_flow_classify_logtype, lib.flow_classify, INFO);
diff --git a/lib/librte_graph/graph.c b/lib/librte_graph/graph.c
index 0ea83df3d..baa383cd7 100644
--- a/lib/librte_graph/graph.c
+++ b/lib/librte_graph/graph.c
@@ -579,9 +579,4 @@ rte_graph_max_count(void)
 	return graph_id;
 }
 
-RTE_INIT(rte_graph_init_log)
-{
-	rte_graph_logtype = rte_log_register("lib.graph");
-	if (rte_graph_logtype >= 0)
-		rte_log_set_level(rte_graph_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(rte_graph_logtype, lib.graph, INFO);
diff --git a/lib/librte_member/rte_member.c b/lib/librte_member/rte_member.c
index e0e7f127e..4696c0f17 100644
--- a/lib/librte_member/rte_member.c
+++ b/lib/librte_member/rte_member.c
@@ -16,8 +16,6 @@
 #include "rte_member_ht.h"
 #include "rte_member_vbf.h"
 
-int librte_member_logtype;
-
 TAILQ_HEAD(rte_member_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_member_tailq = {
 	.name = "RTE_MEMBER",
@@ -299,9 +297,4 @@ rte_member_reset(const struct rte_member_setsum *setsum)
 	}
 }
 
-RTE_INIT(librte_member_init_log)
-{
-	librte_member_logtype = rte_log_register("lib.member");
-	if (librte_member_logtype >= 0)
-		rte_log_set_level(librte_member_logtype, RTE_LOG_DEBUG);
-}
+RTE_LOG_REGISTER(librte_member_logtype, lib.member, DEBUG);
diff --git a/lib/librte_metrics/rte_metrics_telemetry.c b/lib/librte_metrics/rte_metrics_telemetry.c
index 040e87d18..289ebae0b 100644
--- a/lib/librte_metrics/rte_metrics_telemetry.c
+++ b/lib/librte_metrics/rte_metrics_telemetry.c
@@ -525,6 +525,8 @@ handle_ports_stats_values_by_name(const char *cmd __rte_unused,
 	return used;
 }
 
+RTE_LOG_REGISTER(metrics_log_level, lib.metrics, ERR);
+
 RTE_INIT(metrics_ctor)
 {
 #ifdef RTE_LIBRTE_TELEMETRY
@@ -535,7 +537,4 @@ RTE_INIT(metrics_ctor)
 	rte_telemetry_legacy_register("ports_stats_values_by_name", DATA_REQ,
 			handle_ports_stats_values_by_name);
 #endif
-	metrics_log_level = rte_log_register("lib.metrics");
-	if (metrics_log_level >= 0)
-		rte_log_set_level(metrics_log_level, RTE_LOG_ERR);
 }
diff --git a/lib/librte_node/log.c b/lib/librte_node/log.c
index f035f91e8..f14199f07 100644
--- a/lib/librte_node/log.c
+++ b/lib/librte_node/log.c
@@ -4,11 +4,4 @@
 
 #include "node_private.h"
 
-int rte_node_logtype;
-
-RTE_INIT(rte_node_init_log)
-{
-	rte_node_logtype = rte_log_register("lib.node");
-	if (rte_node_logtype >= 0)
-		rte_log_set_level(rte_node_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(rte_node_logtype, lib.node, INFO);
diff --git a/lib/librte_pdump/rte_pdump.c b/lib/librte_pdump/rte_pdump.c
index f96709f95..5016e9dd2 100644
--- a/lib/librte_pdump/rte_pdump.c
+++ b/lib/librte_pdump/rte_pdump.c
@@ -14,8 +14,9 @@
 
 #define DEVICE_ID_SIZE 64
 
+RTE_LOG_REGISTER(pdump_logtype, lib.pdump, NOTICE);
+
 /* Macro for printing using RTE_LOG */
-static int pdump_logtype;
 #define PDUMP_LOG(level, fmt, args...)				\
 	rte_log(RTE_LOG_ ## level, pdump_logtype, "%s(): " fmt,	\
 		__func__, ## args)
@@ -561,9 +562,3 @@ rte_pdump_disable_by_deviceid(char *device_id, uint16_t queue,
 	return ret;
 }
 
-RTE_INIT(pdump_log)
-{
-	pdump_logtype = rte_log_register("lib.pdump");
-	if (pdump_logtype >= 0)
-		rte_log_set_level(pdump_logtype, RTE_LOG_NOTICE);
-}
diff --git a/lib/librte_rawdev/rte_rawdev.c b/lib/librte_rawdev/rte_rawdev.c
index c332a7648..aec61f425 100644
--- a/lib/librte_rawdev/rte_rawdev.c
+++ b/lib/librte_rawdev/rte_rawdev.c
@@ -613,11 +613,10 @@ handle_dev_xstats(const char *cmd __rte_unused,
 	return 0;
 }
 
-RTE_INIT(librawdev_init_log)
+RTE_LOG_REGISTER(librawdev_logtype, lib.rawdev, INFO);
+
+RTE_INIT(librawdev_init_telemetry)
 {
-	librawdev_logtype = rte_log_register("lib.rawdev");
-	if (librawdev_logtype >= 0)
-		rte_log_set_level(librawdev_logtype, RTE_LOG_INFO);
 	rte_telemetry_register_cmd("/rawdev/list", handle_dev_list,
 			"Returns list of available rawdev ports. Takes no parameters");
 	rte_telemetry_register_cmd("/rawdev/xstats", handle_dev_xstats,
diff --git a/lib/librte_rcu/rte_rcu_qsbr.c b/lib/librte_rcu/rte_rcu_qsbr.c
index 6a429d8b3..aebfdb0da 100644
--- a/lib/librte_rcu/rte_rcu_qsbr.c
+++ b/lib/librte_rcu/rte_rcu_qsbr.c
@@ -495,11 +495,4 @@ rte_rcu_qsbr_dq_delete(struct rte_rcu_qsbr_dq *dq)
 	return 0;
 }
 
-int rte_rcu_log_type;
-
-RTE_INIT(rte_rcu_register)
-{
-	rte_rcu_log_type = rte_log_register("lib.rcu");
-	if (rte_rcu_log_type >= 0)
-		rte_log_set_level(rte_rcu_log_type, RTE_LOG_ERR);
-}
+RTE_LOG_REGISTER(rte_rcu_log_type, lib.rcu, ERR);
diff --git a/lib/librte_stack/rte_stack.c b/lib/librte_stack/rte_stack.c
index e58fa545f..e4c0ce131 100644
--- a/lib/librte_stack/rte_stack.c
+++ b/lib/librte_stack/rte_stack.c
@@ -194,9 +194,4 @@ rte_stack_lookup(const char *name)
 	return r;
 }
 
-RTE_INIT(librte_stack_init_log)
-{
-	stack_logtype = rte_log_register("lib.stack");
-	if (stack_logtype >= 0)
-		rte_log_set_level(stack_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(stack_logtype, lib.stack, NOTICE);
diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
index 026631844..872d57f61 100644
--- a/lib/librte_vhost/vhost.c
+++ b/lib/librte_vhost/vhost.c
@@ -27,9 +27,6 @@
 
 struct virtio_net *vhost_devices[MAX_VHOST_DEVICE];
 
-int vhost_config_log_level;
-int vhost_data_log_level;
-
 /* Called with iotlb_lock read-locked */
 uint64_t
 __vhost_iova_to_vva(struct virtio_net *dev, struct vhost_virtqueue *vq,
@@ -1517,13 +1514,5 @@ int rte_vhost_extern_callback_register(int vid,
 	return 0;
 }
 
-RTE_INIT(vhost_log_init)
-{
-	vhost_config_log_level = rte_log_register("lib.vhost.config");
-	if (vhost_config_log_level >= 0)
-		rte_log_set_level(vhost_config_log_level, RTE_LOG_INFO);
-
-	vhost_data_log_level = rte_log_register("lib.vhost.data");
-	if (vhost_data_log_level >= 0)
-		rte_log_set_level(vhost_data_log_level, RTE_LOG_WARNING);
-}
+RTE_LOG_REGISTER(vhost_config_log_level, lib.vhost.config, INFO);
+RTE_LOG_REGISTER(vhost_data_log_level, lib.vhost.data, WARNING);
-- 
2.27.0


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

* [dpdk-dev]  [PATCH v3 03/13] drivers/vdpa: use log register macro
  2020-07-01  6:48   ` [dpdk-dev] [PATCH v3 00/13] rte_log registration usage improvement jerinj
  2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 01/13] eal/log: introduce log register macro jerinj
  2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 02/13] lib: use " jerinj
@ 2020-07-01  6:48     ` jerinj
  2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 04/13] drivers/raw: " jerinj
                       ` (10 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01  6:48 UTC (permalink / raw)
  To: dev, Xiao Wang, Matan Azrad, Viacheslav Ovsiienko
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/vdpa/ifc/ifcvf_vdpa.c | 10 +---------
 drivers/vdpa/mlx5/mlx5_vdpa.c |  7 +++----
 2 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
index ec97178dc..78299fa67 100644
--- a/drivers/vdpa/ifc/ifcvf_vdpa.c
+++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
@@ -24,6 +24,7 @@
 
 #include "base/ifcvf.h"
 
+RTE_LOG_REGISTER(ifcvf_vdpa_logtype, pmd.net.ifcvf_vdpa, NOTICE);
 #define DRV_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, ifcvf_vdpa_logtype, \
 		"IFCVF %s(): " fmt "\n", __func__, ##args)
@@ -44,8 +45,6 @@ static const char * const ifcvf_valid_arguments[] = {
 	NULL
 };
 
-static int ifcvf_vdpa_logtype;
-
 struct ifcvf_internal {
 	struct rte_vdpa_dev_addr dev_addr;
 	struct rte_pci_device *pdev;
@@ -1271,10 +1270,3 @@ static struct rte_pci_driver rte_ifcvf_vdpa = {
 RTE_PMD_REGISTER_PCI(net_ifcvf, rte_ifcvf_vdpa);
 RTE_PMD_REGISTER_PCI_TABLE(net_ifcvf, pci_id_ifcvf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_ifcvf, "* vfio-pci");
-
-RTE_INIT(ifcvf_vdpa_init_log)
-{
-	ifcvf_vdpa_logtype = rte_log_register("pmd.net.ifcvf_vdpa");
-	if (ifcvf_vdpa_logtype >= 0)
-		rte_log_set_level(ifcvf_vdpa_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c
index 1113d6cef..b166207c4 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa.c
@@ -608,15 +608,14 @@ static struct rte_pci_driver mlx5_vdpa_driver = {
 	.drv_flags = 0,
 };
 
+
+RTE_LOG_REGISTER(mlx5_vdpa_logtype, pmd.vdpa.mlx5, NOTICE);
+
 /**
  * Driver initialization routine.
  */
 RTE_INIT(rte_mlx5_vdpa_init)
 {
-	/* Initialize common log type. */
-	mlx5_vdpa_logtype = rte_log_register("pmd.vdpa.mlx5");
-	if (mlx5_vdpa_logtype >= 0)
-		rte_log_set_level(mlx5_vdpa_logtype, RTE_LOG_NOTICE);
 	if (mlx5_glue)
 		rte_pci_register(&mlx5_vdpa_driver);
 }
-- 
2.27.0


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

* [dpdk-dev]  [PATCH v3 04/13] drivers/raw: use log register macro
  2020-07-01  6:48   ` [dpdk-dev] [PATCH v3 00/13] rte_log registration usage improvement jerinj
                       ` (2 preceding siblings ...)
  2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 03/13] drivers/vdpa: " jerinj
@ 2020-07-01  6:48     ` jerinj
  2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 05/13] drivers/net: " jerinj
                       ` (9 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01  6:48 UTC (permalink / raw)
  To: dev, Nipun Gupta, Rosen Xu, Tianfei zhang, Bruce Richardson,
	Xiaoyun Li, Jingjing Wu, Hemant Agrawal
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c  | 11 +----------
 drivers/raw/dpaa2_qdma/dpaa2_qdma.c    | 11 +----------
 drivers/raw/ifpga/ifpga_rawdev.c       | 10 +---------
 drivers/raw/ioat/ioat_rawdev.c         | 12 ++----------
 drivers/raw/ioat/rte_ioat_rawdev.h     |  2 --
 drivers/raw/ntb/ntb.c                  | 10 +---------
 drivers/raw/skeleton/skeleton_rawdev.c | 11 +----------
 7 files changed, 7 insertions(+), 60 deletions(-)

diff --git a/drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c b/drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c
index 7c21c6a52..c7bddbc6c 100644
--- a/drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c
+++ b/drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c
@@ -20,9 +20,6 @@
 #include "dpaa2_cmdif_logs.h"
 #include "rte_pmd_dpaa2_cmdif.h"
 
-/* Dynamic log type identifier */
-int dpaa2_cmdif_logtype;
-
 /* CMDIF driver name */
 #define DPAA2_CMDIF_PMD_NAME dpaa2_dpci
 
@@ -291,10 +288,4 @@ static struct rte_vdev_driver dpaa2_cmdif_drv = {
 };
 
 RTE_PMD_REGISTER_VDEV(DPAA2_CMDIF_PMD_NAME, dpaa2_cmdif_drv);
-
-RTE_INIT(dpaa2_cmdif_init_log)
-{
-	dpaa2_cmdif_logtype = rte_log_register("pmd.raw.dpaa2.cmdif");
-	if (dpaa2_cmdif_logtype >= 0)
-		rte_log_set_level(dpaa2_cmdif_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(dpaa2_cmdif_logtype, pmd.raw.dpaa2.cmdif, INFO);
diff --git a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
index 1be1b6ddf..0b9c4e3d7 100644
--- a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
+++ b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
@@ -26,9 +26,6 @@
 
 #define DPAA2_QDMA_NO_PREFETCH "no_prefetch"
 
-/* Dynamic log type identifier */
-int dpaa2_qdma_logtype;
-
 uint32_t dpaa2_coherent_no_alloc_cache;
 uint32_t dpaa2_coherent_alloc_cache;
 
@@ -1495,10 +1492,4 @@ static struct rte_dpaa2_driver rte_dpaa2_qdma_pmd = {
 RTE_PMD_REGISTER_DPAA2(dpaa2_qdma, rte_dpaa2_qdma_pmd);
 RTE_PMD_REGISTER_PARAM_STRING(dpaa2_qdma,
 	"no_prefetch=<int> ");
-
-RTE_INIT(dpaa2_qdma_init_log)
-{
-	dpaa2_qdma_logtype = rte_log_register("pmd.raw.dpaa2.qdma");
-	if (dpaa2_qdma_logtype >= 0)
-		rte_log_set_level(dpaa2_qdma_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(dpaa2_qdma_logtype, pmd.raw.dpaa2.qdma, INFO);
diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c
index b8701e155..cc25c662b 100644
--- a/drivers/raw/ifpga/ifpga_rawdev.c
+++ b/drivers/raw/ifpga/ifpga_rawdev.c
@@ -47,8 +47,6 @@
 #define RTE_PCI_EXT_CAP_ID(header)       (int)(header & 0x0000ffff)
 #define RTE_PCI_EXT_CAP_NEXT(header)     ((header >> 20) & 0xffc)
 
-int ifpga_rawdev_logtype;
-
 #define PCI_VENDOR_ID_INTEL          0x8086
 /* PCI Device ID */
 #define PCIE_DEVICE_ID_PF_INT_5_X    0xBCBD
@@ -1597,13 +1595,7 @@ static struct rte_pci_driver rte_ifpga_rawdev_pmd = {
 RTE_PMD_REGISTER_PCI(ifpga_rawdev_pci_driver, rte_ifpga_rawdev_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(ifpga_rawdev_pci_driver, rte_ifpga_rawdev_pmd);
 RTE_PMD_REGISTER_KMOD_DEP(ifpga_rawdev_pci_driver, "* igb_uio | uio_pci_generic | vfio-pci");
-
-RTE_INIT(ifpga_rawdev_init_log)
-{
-	ifpga_rawdev_logtype = rte_log_register("driver.raw.init");
-	if (ifpga_rawdev_logtype >= 0)
-		rte_log_set_level(ifpga_rawdev_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(ifpga_rawdev_logtype, driver.raw.init, NOTICE);
 
 static const char * const valid_args[] = {
 #define IFPGA_ARG_NAME         "ifpga"
diff --git a/drivers/raw/ioat/ioat_rawdev.c b/drivers/raw/ioat/ioat_rawdev.c
index a8a48f90a..30d9f597e 100644
--- a/drivers/raw/ioat/ioat_rawdev.c
+++ b/drivers/raw/ioat/ioat_rawdev.c
@@ -9,9 +9,6 @@
 
 #include "rte_ioat_rawdev.h"
 
-/* Dynamic log type identifier */
-int ioat_pmd_logtype;
-
 static struct rte_pci_driver ioat_pmd_drv;
 
 #define IOAT_VENDOR_ID		0x8086
@@ -28,6 +25,8 @@ static struct rte_pci_driver ioat_pmd_drv;
 #define IOAT_DEVICE_ID_BDXF	0x6f2F
 #define IOAT_DEVICE_ID_ICX	0x0b00
 
+RTE_LOG_REGISTER(ioat_pmd_logtype,  rawdev.ioat, INFO);
+
 #define IOAT_PMD_LOG(level, fmt, args...) rte_log(RTE_LOG_ ## level, \
 	ioat_pmd_logtype, "%s(): " fmt "\n", __func__, ##args)
 
@@ -386,10 +385,3 @@ static struct rte_pci_driver ioat_pmd_drv = {
 RTE_PMD_REGISTER_PCI(IOAT_PMD_RAWDEV_NAME, ioat_pmd_drv);
 RTE_PMD_REGISTER_PCI_TABLE(IOAT_PMD_RAWDEV_NAME, pci_id_ioat_map);
 RTE_PMD_REGISTER_KMOD_DEP(IOAT_PMD_RAWDEV_NAME, "* igb_uio | uio_pci_generic");
-
-RTE_INIT(ioat_pmd_init_log)
-{
-	ioat_pmd_logtype = rte_log_register(IOAT_PMD_LOG_NAME);
-	if (ioat_pmd_logtype >= 0)
-		rte_log_set_level(ioat_pmd_logtype, RTE_LOG_INFO);
-}
diff --git a/drivers/raw/ioat/rte_ioat_rawdev.h b/drivers/raw/ioat/rte_ioat_rawdev.h
index 4b271f174..f765a6557 100644
--- a/drivers/raw/ioat/rte_ioat_rawdev.h
+++ b/drivers/raw/ioat/rte_ioat_rawdev.h
@@ -25,8 +25,6 @@
 #define IOAT_PMD_RAWDEV_NAME rawdev_ioat
 /** String reported as the device driver name by rte_rawdev_info_get() */
 #define IOAT_PMD_RAWDEV_NAME_STR "rawdev_ioat"
-/** Name used to adjust the log level for this driver */
-#define IOAT_PMD_LOG_NAME "rawdev.ioat"
 
 /**
  * Configuration structure for an ioat rawdev instance
diff --git a/drivers/raw/ntb/ntb.c b/drivers/raw/ntb/ntb.c
index dd0b72f8c..e40412bb7 100644
--- a/drivers/raw/ntb/ntb.c
+++ b/drivers/raw/ntb/ntb.c
@@ -23,8 +23,6 @@
 #include "rte_pmd_ntb.h"
 #include "ntb.h"
 
-int ntb_logtype;
-
 static const struct rte_pci_id pci_id_ntb_map[] = {
 	{ RTE_PCI_DEVICE(NTB_INTEL_VENDOR_ID, NTB_INTEL_DEV_ID_B2B_SKX) },
 	{ .vendor_id = 0, /* sentinel */ },
@@ -1504,10 +1502,4 @@ static struct rte_pci_driver rte_ntb_pmd = {
 RTE_PMD_REGISTER_PCI(raw_ntb, rte_ntb_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(raw_ntb, pci_id_ntb_map);
 RTE_PMD_REGISTER_KMOD_DEP(raw_ntb, "* igb_uio | uio_pci_generic | vfio-pci");
-
-RTE_INIT(ntb_init_log)
-{
-	ntb_logtype = rte_log_register("pmd.raw.ntb");
-	if (ntb_logtype >= 0)
-		rte_log_set_level(ntb_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(ntb_logtype, pmd.raw.ntb, INFO);
diff --git a/drivers/raw/skeleton/skeleton_rawdev.c b/drivers/raw/skeleton/skeleton_rawdev.c
index 586183a5b..72ece887a 100644
--- a/drivers/raw/skeleton/skeleton_rawdev.c
+++ b/drivers/raw/skeleton/skeleton_rawdev.c
@@ -28,9 +28,6 @@
 
 #include "skeleton_rawdev.h"
 
-/* Dynamic log type identifier */
-int skeleton_pmd_logtype;
-
 /* Count of instances */
 static uint16_t skeldev_init_once;
 
@@ -759,10 +756,4 @@ static struct rte_vdev_driver skeleton_pmd_drv = {
 };
 
 RTE_PMD_REGISTER_VDEV(SKELETON_PMD_RAWDEV_NAME, skeleton_pmd_drv);
-
-RTE_INIT(skeleton_pmd_init_log)
-{
-	skeleton_pmd_logtype = rte_log_register("rawdev.skeleton");
-	if (skeleton_pmd_logtype >= 0)
-		rte_log_set_level(skeleton_pmd_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(skeleton_pmd_logtype, rawdev.skeleton, INFO);
-- 
2.27.0


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

* [dpdk-dev]  [PATCH v3 05/13] drivers/net: use log register macro
  2020-07-01  6:48   ` [dpdk-dev] [PATCH v3 00/13] rte_log registration usage improvement jerinj
                       ` (3 preceding siblings ...)
  2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 04/13] drivers/raw: " jerinj
@ 2020-07-01  6:48     ` jerinj
  2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 06/13] drivers/mempool: " jerinj
                       ` (8 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01  6:48 UTC (permalink / raw)
  To: dev, John W. Linville, Xiaolong Ye, Qi Zhang, Shepard Siegel,
	Ed Czeck, John Miller, Igor Russkikh, Pavel Belous,
	Steven Webster, Matt Peters, Somalapuram Amaranath, Rasesh Mody,
	Shahed Shaikh, Ajit Khaparde, Somnath Kotur, Chas Williams,
	Wei Hu (Xavier),
	Rahul Lakkireddy, Hemant Agrawal, Sachin Saxena, Marcin Wojtas,
	Michal Krawczyk, Guy Tzalik, Evgeny Schemeilin, Igor Chauskin,
	Gagandeep Singh, John Daley, Hyong Youb Kim, Gaetan Rivet,
	Xiao Wang, Ziyang Xuan, Xiaoyun Wang, Guoyang Zhou,
	Min Hu (Connor),
	Yisen Zhuang, Beilei Xing, Jeff Guo, Jingjing Wu, Qiming Yang,
	Wei Zhao, Alfredo Cardigliano, Rosen Xu, Ferruh Yigit,
	Shijith Thotton, Srisivasubramanian Srinivasan, Jakub Grajciar,
	Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko, Zyta Szpak,
	Liron Himi, Stephen Hemminger, K. Y. Srinivasan, Haiyang Zhang,
	Heinrich Kuhn, Tetsuya Mukawa, Harman Kalra, Akhil Goyal,
	Bruce Richardson, Jasvinder Singh, Cristian Dumitrescu,
	Martin Zizka, Jakub Neruda, Keith Wiles, Jerin Jacob,
	Maciej Czekaj, Maxime Coquelin, Zhihong Wang, Yong Wang
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena, adamx.dybkowski

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/net/af_packet/rte_eth_af_packet.c |  8 +---
 drivers/net/af_xdp/rte_eth_af_xdp.c       |  8 +---
 drivers/net/ark/ark_ethdev.c              | 10 +----
 drivers/net/atlantic/atl_ethdev.c         | 15 +------
 drivers/net/avp/avp_ethdev.c              | 10 +----
 drivers/net/axgbe/axgbe_ethdev.c          | 15 +------
 drivers/net/bnx2x/bnx2x_ethdev.c          | 15 +------
 drivers/net/bnxt/bnxt_ethdev.c            |  9 +----
 drivers/net/bonding/rte_eth_bond_pmd.c    |  9 +----
 drivers/net/cxgbe/cxgbe_ethdev.c          | 15 +------
 drivers/net/dpaa/dpaa_ethdev.c            |  9 +----
 drivers/net/dpaa2/dpaa2_ethdev.c          |  9 +----
 drivers/net/ena/ena_ethdev.c              | 48 +++--------------------
 drivers/net/enetc/enetc_ethdev.c          | 10 +----
 drivers/net/enic/enic_ethdev.c            |  9 +----
 drivers/net/failsafe/failsafe.c           | 10 +----
 drivers/net/fm10k/fm10k_ethdev.c          | 40 +++----------------
 drivers/net/hinic/hinic_pmd_ethdev.c      | 11 +-----
 drivers/net/hns3/hns3_ethdev.c            | 15 +------
 drivers/net/i40e/i40e_ethdev.c            | 38 +++---------------
 drivers/net/iavf/iavf_ethdev.c            | 40 +++----------------
 drivers/net/ice/ice_ethdev.c              | 38 +++---------------
 drivers/net/igc/igc_logs.c                | 16 +-------
 drivers/net/ionic/ionic_ethdev.c          | 10 +----
 drivers/net/ipn3ke/ipn3ke_ethdev.c        | 10 +----
 drivers/net/ixgbe/ixgbe_ethdev.c          | 39 +++---------------
 drivers/net/kni/rte_eth_kni.c             |  9 +----
 drivers/net/liquidio/lio_ethdev.c         | 15 +------
 drivers/net/memif/rte_eth_memif.c         |  9 +----
 drivers/net/mlx4/mlx4.c                   | 11 ++----
 drivers/net/mlx5/mlx5.c                   | 10 ++---
 drivers/net/mvneta/mvneta_ethdev.c        | 10 +----
 drivers/net/mvpp2/mrvl_ethdev.c           | 10 +----
 drivers/net/netvsc/hn_ethdev.c            | 15 +------
 drivers/net/nfp/nfp_net.c                 | 15 +------
 drivers/net/null/rte_eth_null.c           |  8 +---
 drivers/net/octeontx/octeontx_ethdev.c    | 21 ++--------
 drivers/net/pcap/rte_eth_pcap.c           |  8 +---
 drivers/net/pfe/pfe_ethdev.c              | 10 +----
 drivers/net/qede/qede_ethdev.c            | 16 +-------
 drivers/net/ring/rte_eth_ring.c           |  8 +---
 drivers/net/softnic/rte_eth_softnic.c     | 10 +----
 drivers/net/szedata2/rte_eth_szedata2.c   | 15 +------
 drivers/net/tap/rte_eth_tap.c             |  9 +----
 drivers/net/thunderx/nicvf_ethdev.c       | 21 ++--------
 drivers/net/vdev_netvsc/vdev_netvsc.c     | 13 +-----
 drivers/net/vhost/rte_eth_vhost.c         |  8 +---
 drivers/net/virtio/virtio_ethdev.c        | 15 +------
 drivers/net/vmxnet3/vmxnet3_ethdev.c      | 15 +------
 49 files changed, 97 insertions(+), 650 deletions(-)

diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index 22feb72e3..300039bbf 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -97,7 +97,7 @@ static struct rte_eth_link pmd_link = {
 	.link_autoneg = ETH_LINK_FIXED,
 };
 
-static int af_packet_logtype;
+RTE_LOG_REGISTER(af_packet_logtype, pmd.net.packet, NOTICE);
 
 #define PMD_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, af_packet_logtype, \
@@ -1082,9 +1082,3 @@ RTE_PMD_REGISTER_PARAM_STRING(net_af_packet,
 	"framecnt=<int> "
 	"qdisc_bypass=<0|1>");
 
-RTE_INIT(af_packet_init_log)
-{
-	af_packet_logtype = rte_log_register("pmd.net.packet");
-	if (af_packet_logtype >= 0)
-		rte_log_set_level(af_packet_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 06124ba78..98b9cff38 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -50,7 +50,7 @@
 #define PF_XDP AF_XDP
 #endif
 
-static int af_xdp_logtype;
+RTE_LOG_REGISTER(af_xdp_logtype, pmd.net.af_xdp, NOTICE);
 
 #define AF_XDP_LOG(level, fmt, args...)			\
 	rte_log(RTE_LOG_ ## level, af_xdp_logtype,	\
@@ -1374,9 +1374,3 @@ RTE_PMD_REGISTER_PARAM_STRING(net_af_xdp,
 			      "start_queue=<int> "
 			      "queue_count=<int> ");
 
-RTE_INIT(af_xdp_init_log)
-{
-	af_xdp_logtype = rte_log_register("pmd.net.af_xdp");
-	if (af_xdp_logtype >= 0)
-		rte_log_set_level(af_xdp_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c
index c3642012d..b32ccd867 100644
--- a/drivers/net/ark/ark_ethdev.c
+++ b/drivers/net/ark/ark_ethdev.c
@@ -78,8 +78,6 @@ static int  eth_ark_set_mtu(struct rte_eth_dev *dev, uint16_t size);
 #define ARK_TX_MAX_QUEUE (4096 * 4)
 #define ARK_TX_MIN_QUEUE (256)
 
-int ark_logtype;
-
 static const char * const valid_arguments[] = {
 	ARK_PKTGEN_ARG,
 	ARK_PKTCHKR_ARG,
@@ -1018,10 +1016,4 @@ RTE_PMD_REGISTER_PARAM_STRING(net_ark,
 			      ARK_PKTGEN_ARG "=<filename> "
 			      ARK_PKTCHKR_ARG "=<filename> "
 			      ARK_PKTDIR_ARG "=<bitmap>");
-
-RTE_INIT(ark_init_log)
-{
-	ark_logtype = rte_log_register("pmd.net.ark");
-	if (ark_logtype >= 0)
-		rte_log_set_level(ark_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(ark_logtype, pmd.net.ark, NOTICE);
diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_ethdev.c
index b2b3bd36c..d3b00ab29 100644
--- a/drivers/net/atlantic/atl_ethdev.c
+++ b/drivers/net/atlantic/atl_ethdev.c
@@ -120,9 +120,6 @@ static int eth_atl_pci_remove(struct rte_pci_device *pci_dev);
 static int atl_dev_info_get(struct rte_eth_dev *dev,
 				struct rte_eth_dev_info *dev_info);
 
-int atl_logtype_init;
-int atl_logtype_driver;
-
 /*
  * The set of PCI devices this driver supports
  */
@@ -1929,13 +1926,5 @@ is_atlantic_supported(struct rte_eth_dev *dev)
 RTE_PMD_REGISTER_PCI(net_atlantic, rte_atl_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_atlantic, pci_id_atl_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_atlantic, "* igb_uio | uio_pci_generic");
-
-RTE_INIT(atl_init_log)
-{
-	atl_logtype_init = rte_log_register("pmd.net.atlantic.init");
-	if (atl_logtype_init >= 0)
-		rte_log_set_level(atl_logtype_init, RTE_LOG_NOTICE);
-	atl_logtype_driver = rte_log_register("pmd.net.atlantic.driver");
-	if (atl_logtype_driver >= 0)
-		rte_log_set_level(atl_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(atl_logtype_init, pmd.net.atlantic.init, NOTICE);
+RTE_LOG_REGISTER(atl_logtype_driver, pmd.net.atlantic.driver, NOTICE);
diff --git a/drivers/net/avp/avp_ethdev.c b/drivers/net/avp/avp_ethdev.c
index 1abe96ce5..5b47f0924 100644
--- a/drivers/net/avp/avp_ethdev.c
+++ b/drivers/net/avp/avp_ethdev.c
@@ -32,8 +32,6 @@
 
 #include "avp_logs.h"
 
-int avp_logtype_driver;
-
 static int avp_dev_create(struct rte_pci_device *pci_dev,
 			  struct rte_eth_dev *eth_dev);
 
@@ -2306,10 +2304,4 @@ avp_dev_stats_reset(struct rte_eth_dev *eth_dev)
 
 RTE_PMD_REGISTER_PCI(net_avp, rte_avp_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_avp, pci_id_avp_map);
-
-RTE_INIT(avp_init_log)
-{
-	avp_logtype_driver = rte_log_register("pmd.net.avp.driver");
-	if (avp_logtype_driver >= 0)
-		rte_log_set_level(avp_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(avp_logtype_driver, pmd.net.avp.driver, NOTICE);
diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c
index db86b9813..0c25739f8 100644
--- a/drivers/net/axgbe/axgbe_ethdev.c
+++ b/drivers/net/axgbe/axgbe_ethdev.c
@@ -143,9 +143,6 @@ static const struct axgbe_xstats axgbe_xstats_strings[] = {
 #define AMD_PCI_AXGBE_DEVICE_V2A 0x1458
 #define AMD_PCI_AXGBE_DEVICE_V2B 0x1459
 
-int axgbe_logtype_init;
-int axgbe_logtype_driver;
-
 static const struct rte_pci_id pci_id_axgbe_map[] = {
 	{RTE_PCI_DEVICE(AMD_PCI_VENDOR_ID, AMD_PCI_AXGBE_DEVICE_V2A)},
 	{RTE_PCI_DEVICE(AMD_PCI_VENDOR_ID, AMD_PCI_AXGBE_DEVICE_V2B)},
@@ -1842,13 +1839,5 @@ static struct rte_pci_driver rte_axgbe_pmd = {
 RTE_PMD_REGISTER_PCI(net_axgbe, rte_axgbe_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_axgbe, pci_id_axgbe_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_axgbe, "* igb_uio | uio_pci_generic | vfio-pci");
-
-RTE_INIT(axgbe_init_log)
-{
-	axgbe_logtype_init = rte_log_register("pmd.net.axgbe.init");
-	if (axgbe_logtype_init >= 0)
-		rte_log_set_level(axgbe_logtype_init, RTE_LOG_NOTICE);
-	axgbe_logtype_driver = rte_log_register("pmd.net.axgbe.driver");
-	if (axgbe_logtype_driver >= 0)
-		rte_log_set_level(axgbe_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(axgbe_logtype_init, pmd.net.axgbe.init, NOTICE);
+RTE_LOG_REGISTER(axgbe_logtype_driver, pmd.net.axgbe.driver, NOTICE);
diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c
index adc3690fc..b2ea5fafa 100644
--- a/drivers/net/bnx2x/bnx2x_ethdev.c
+++ b/drivers/net/bnx2x/bnx2x_ethdev.c
@@ -13,9 +13,6 @@
 #include <rte_ethdev_pci.h>
 #include <rte_alarm.h>
 
-int bnx2x_logtype_init;
-int bnx2x_logtype_driver;
-
 /*
  * The set of PCI devices this driver supports
  */
@@ -805,13 +802,5 @@ RTE_PMD_REGISTER_KMOD_DEP(net_bnx2x, "* igb_uio | uio_pci_generic | vfio-pci");
 RTE_PMD_REGISTER_PCI(net_bnx2xvf, rte_bnx2xvf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_bnx2xvf, pci_id_bnx2xvf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_bnx2xvf, "* igb_uio | vfio-pci");
-
-RTE_INIT(bnx2x_init_log)
-{
-	bnx2x_logtype_init = rte_log_register("pmd.net.bnx2x.init");
-	if (bnx2x_logtype_init >= 0)
-		rte_log_set_level(bnx2x_logtype_init, RTE_LOG_NOTICE);
-	bnx2x_logtype_driver = rte_log_register("pmd.net.bnx2x.driver");
-	if (bnx2x_logtype_driver >= 0)
-		rte_log_set_level(bnx2x_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(bnx2x_logtype_init, pmd.net.bnx2x.init, NOTICE);
+RTE_LOG_REGISTER(bnx2x_logtype_driver, pmd.net.bnx2x.driver, NOTICE);
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index e8b4c058a..59c318076 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -31,7 +31,6 @@
 #define DRV_MODULE_NAME		"bnxt"
 static const char bnxt_version[] =
 	"Broadcom NetXtreme driver " DRV_MODULE_NAME;
-int bnxt_logtype_driver;
 
 /*
  * The set of PCI devices this driver supports
@@ -5668,13 +5667,7 @@ bool is_bnxt_supported(struct rte_eth_dev *dev)
 	return is_device_supported(dev, &bnxt_rte_pmd);
 }
 
-RTE_INIT(bnxt_init_log)
-{
-	bnxt_logtype_driver = rte_log_register("pmd.net.bnxt.driver");
-	if (bnxt_logtype_driver >= 0)
-		rte_log_set_level(bnxt_logtype_driver, RTE_LOG_NOTICE);
-}
-
+RTE_LOG_REGISTER(bnxt_logtype_driver, pmd.net.bnxt.driver, NOTICE);
 RTE_PMD_REGISTER_PCI(net_bnxt, bnxt_rte_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_bnxt, bnxt_pci_id_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_bnxt, "* igb_uio | uio_pci_generic | vfio-pci");
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 612a64599..044a1cfbc 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -3750,11 +3750,4 @@ RTE_PMD_REGISTER_PARAM_STRING(net_bonding,
 	"up_delay=<int> "
 	"down_delay=<int>");
 
-int bond_logtype;
-
-RTE_INIT(bond_init_log)
-{
-	bond_logtype = rte_log_register("pmd.net.bond");
-	if (bond_logtype >= 0)
-		rte_log_set_level(bond_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(bond_logtype, pmd.net.bond, NOTICE);
diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index 1deee2f5c..7c6016d5c 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -38,9 +38,6 @@
 #include "cxgbe_pfvf.h"
 #include "cxgbe_flow.h"
 
-int cxgbe_logtype;
-int cxgbe_mbox_logtype;
-
 /*
  * Macros needed to support the PCI Device ID Table ...
  */
@@ -1247,13 +1244,5 @@ RTE_PMD_REGISTER_PARAM_STRING(net_cxgbe,
 			      CXGBE_DEVARG_CMN_TX_MODE_LATENCY "=<0|1> "
 			      CXGBE_DEVARG_PF_FILTER_MODE "=<uint32> "
 			      CXGBE_DEVARG_PF_FILTER_MASK "=<uint32> ");
-
-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);
-	cxgbe_mbox_logtype = rte_log_register("pmd.net.cxgbe.mbox");
-	if (cxgbe_mbox_logtype >= 0)
-		rte_log_set_level(cxgbe_mbox_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(cxgbe_logtype, pmd.net.cxgbe, NOTICE);
+RTE_LOG_REGISTER(cxgbe_mbox_logtype, pmd.net.cxgbe.mbox, NOTICE);
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 13d1c6a1f..f1c9a7151 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -46,8 +46,6 @@
 #include <fsl_bman.h>
 #include <fsl_fman.h>
 
-int dpaa_logtype_pmd;
-
 /* Supported Rx offloads */
 static uint64_t dev_rx_offloads_sup =
 		DEV_RX_OFFLOAD_JUMBO_FRAME |
@@ -1666,9 +1664,4 @@ static struct rte_dpaa_driver rte_dpaa_pmd = {
 };
 
 RTE_PMD_REGISTER_DPAA(net_dpaa, rte_dpaa_pmd);
-RTE_INIT(dpaa_net_init_log)
-{
-	dpaa_logtype_pmd = rte_log_register("pmd.net.dpaa");
-	if (dpaa_logtype_pmd >= 0)
-		rte_log_set_level(dpaa_logtype_pmd, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa_logtype_pmd, pmd.net.dpaa, NOTICE);
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 2f031ec5c..a1f19194d 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -106,8 +106,6 @@ static int dpaa2_dev_set_link_up(struct rte_eth_dev *dev);
 static int dpaa2_dev_set_link_down(struct rte_eth_dev *dev);
 static int dpaa2_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
 
-int dpaa2_logtype_pmd;
-
 void
 rte_pmd_dpaa2_set_timestamp(enum pmd_dpaa2_ts enable)
 {
@@ -2694,9 +2692,4 @@ RTE_PMD_REGISTER_DPAA2(net_dpaa2, rte_dpaa2_pmd);
 RTE_PMD_REGISTER_PARAM_STRING(net_dpaa2,
 		DRIVER_LOOPBACK_MODE "=<int> "
 		DRIVER_NO_PREFETCH_MODE "=<int>");
-RTE_INIT(dpaa2_pmd_init_log)
-{
-	dpaa2_logtype_pmd = rte_log_register("pmd.net.dpaa2");
-	if (dpaa2_logtype_pmd >= 0)
-		rte_log_set_level(dpaa2_logtype_pmd, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa2_logtype_pmd, pmd.net.dpaa2, NOTICE);
diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index fbddc79f7..da8c8ad92 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -141,22 +141,6 @@ static const struct ena_stats ena_stats_rx_strings[] = {
 #define	ENA_TX_OFFLOAD_NOTSUP_MASK	\
 	(PKT_TX_OFFLOAD_MASK ^ ENA_TX_OFFLOAD_MASK)
 
-int ena_logtype_init;
-int ena_logtype_driver;
-
-#ifdef RTE_LIBRTE_ENA_DEBUG_RX
-int ena_logtype_rx;
-#endif
-#ifdef RTE_LIBRTE_ENA_DEBUG_TX
-int ena_logtype_tx;
-#endif
-#ifdef RTE_LIBRTE_ENA_DEBUG_TX_FREE
-int ena_logtype_tx_free;
-#endif
-#ifdef RTE_LIBRTE_ENA_COM_DEBUG
-int ena_logtype_com;
-#endif
-
 static const struct rte_pci_id pci_id_ena_map[] = {
 	{ RTE_PCI_DEVICE(PCI_VENDOR_ID_AMAZON, PCI_DEVICE_ID_ENA_VF) },
 	{ RTE_PCI_DEVICE(PCI_VENDOR_ID_AMAZON, PCI_DEVICE_ID_ENA_LLQ_VF) },
@@ -2849,40 +2833,20 @@ RTE_PMD_REGISTER_PCI(net_ena, rte_ena_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_ena, pci_id_ena_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_ena, "* igb_uio | uio_pci_generic | vfio-pci");
 RTE_PMD_REGISTER_PARAM_STRING(net_ena, ENA_DEVARG_LARGE_LLQ_HDR "=<0|1>");
-
-RTE_INIT(ena_init_log)
-{
-	ena_logtype_init = rte_log_register("pmd.net.ena.init");
-	if (ena_logtype_init >= 0)
-		rte_log_set_level(ena_logtype_init, RTE_LOG_NOTICE);
-	ena_logtype_driver = rte_log_register("pmd.net.ena.driver");
-	if (ena_logtype_driver >= 0)
-		rte_log_set_level(ena_logtype_driver, RTE_LOG_NOTICE);
-
+RTE_LOG_REGISTER(ena_logtype_init, pmd.net.ena.init, NOTICE);
+RTE_LOG_REGISTER(ena_logtype_driver, pmd.net.ena.driver, NOTICE);
 #ifdef RTE_LIBRTE_ENA_DEBUG_RX
-	ena_logtype_rx = rte_log_register("pmd.net.ena.rx");
-	if (ena_logtype_rx >= 0)
-		rte_log_set_level(ena_logtype_rx, RTE_LOG_NOTICE);
+RTE_LOG_REGISTER(ena_logtype_rx, pmd.net.ena.rx, NOTICE);
 #endif
-
 #ifdef RTE_LIBRTE_ENA_DEBUG_TX
-	ena_logtype_tx = rte_log_register("pmd.net.ena.tx");
-	if (ena_logtype_tx >= 0)
-		rte_log_set_level(ena_logtype_tx, RTE_LOG_NOTICE);
+RTE_LOG_REGISTER(ena_logtype_tx, pmd.net.ena.tx, NOTICE);
 #endif
-
 #ifdef RTE_LIBRTE_ENA_DEBUG_TX_FREE
-	ena_logtype_tx_free = rte_log_register("pmd.net.ena.tx_free");
-	if (ena_logtype_tx_free >= 0)
-		rte_log_set_level(ena_logtype_tx_free, RTE_LOG_NOTICE);
+RTE_LOG_REGISTER(ena_logtype_tx_free, pmd.net.ena.tx_free, NOTICE);
 #endif
-
 #ifdef RTE_LIBRTE_ENA_COM_DEBUG
-	ena_logtype_com = rte_log_register("pmd.net.ena.com");
-	if (ena_logtype_com >= 0)
-		rte_log_set_level(ena_logtype_com, RTE_LOG_NOTICE);
+RTE_LOG_REGISTER(ena_logtype_com, pmd.net.ena.com, NOTICE);
 #endif
-}
 
 /******************************************************************************
  ******************************** AENQ Handlers *******************************
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 1716e11dd..c6fb42740 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -10,8 +10,6 @@
 #include "enetc_logs.h"
 #include "enetc.h"
 
-int enetc_logtype_pmd;
-
 static int
 enetc_dev_start(struct rte_eth_dev *dev)
 {
@@ -951,10 +949,4 @@ static struct rte_pci_driver rte_enetc_pmd = {
 RTE_PMD_REGISTER_PCI(net_enetc, rte_enetc_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_enetc, pci_id_enetc_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_enetc, "* vfio-pci");
-
-RTE_INIT(enetc_pmd_init_log)
-{
-	enetc_logtype_pmd = rte_log_register("pmd.net.enetc");
-	if (enetc_logtype_pmd >= 0)
-		rte_log_set_level(enetc_logtype_pmd, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(enetc_logtype_pmd, pmd.net.enetc, NOTICE);
diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c
index 32d5397f8..6a3580fef 100644
--- a/drivers/net/enic/enic_ethdev.c
+++ b/drivers/net/enic/enic_ethdev.c
@@ -21,8 +21,6 @@
 #include "vnic_enet.h"
 #include "enic.h"
 
-int enic_pmd_logtype;
-
 /*
  * The set of PCI devices this driver supports
  */
@@ -71,12 +69,7 @@ static const struct vic_speed_capa {
 #define ENIC_DEVARG_GENEVE_OPT "geneve-opt"
 #define ENIC_DEVARG_IG_VLAN_REWRITE "ig-vlan-rewrite"
 
-RTE_INIT(enicpmd_init_log)
-{
-	enic_pmd_logtype = rte_log_register("pmd.net.enic");
-	if (enic_pmd_logtype >= 0)
-		rte_log_set_level(enic_pmd_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(enic_pmd_logtype, pmd.net.enic, INFO);
 
 static int
 enicpmd_fdir_ctrl_func(struct rte_eth_dev *eth_dev,
diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsafe.c
index 72362f35d..4a4b7ceab 100644
--- a/drivers/net/failsafe/failsafe.c
+++ b/drivers/net/failsafe/failsafe.c
@@ -15,8 +15,6 @@
 
 #include "failsafe_private.h"
 
-int failsafe_logtype;
-
 const char pmd_failsafe_driver_name[] = FAILSAFE_DRIVER_NAME;
 static const struct rte_eth_link eth_link = {
 	.link_speed = ETH_SPEED_NUM_10G,
@@ -410,10 +408,4 @@ static struct rte_vdev_driver failsafe_drv = {
 
 RTE_PMD_REGISTER_VDEV(net_failsafe, failsafe_drv);
 RTE_PMD_REGISTER_PARAM_STRING(net_failsafe, PMD_FAILSAFE_PARAM_STRING);
-
-RTE_INIT(failsafe_init_log)
-{
-	failsafe_logtype = rte_log_register("pmd.net.failsafe");
-	if (failsafe_logtype >= 0)
-		rte_log_set_level(failsafe_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(failsafe_logtype, pmd.net.failsafe, NOTICE)
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index f537ab286..cb0dd3bae 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -40,19 +40,6 @@
 #define GLORT_FD_MASK    GLORT_PF_MASK
 #define GLORT_FD_INDEX   GLORT_FD_Q_BASE
 
-int fm10k_logtype_init;
-int fm10k_logtype_driver;
-
-#ifdef RTE_LIBRTE_FM10K_DEBUG_RX
-int fm10k_logtype_rx;
-#endif
-#ifdef RTE_LIBRTE_FM10K_DEBUG_TX
-int fm10k_logtype_tx;
-#endif
-#ifdef RTE_LIBRTE_FM10K_DEBUG_TX_FREE
-int fm10k_logtype_tx_free;
-#endif
-
 static void fm10k_close_mbx_service(struct fm10k_hw *hw);
 static int fm10k_dev_promiscuous_enable(struct rte_eth_dev *dev);
 static int fm10k_dev_promiscuous_disable(struct rte_eth_dev *dev);
@@ -3318,31 +3305,14 @@ 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)
-{
-	fm10k_logtype_init = rte_log_register("pmd.net.fm10k.init");
-	if (fm10k_logtype_init >= 0)
-		rte_log_set_level(fm10k_logtype_init, RTE_LOG_NOTICE);
-	fm10k_logtype_driver = rte_log_register("pmd.net.fm10k.driver");
-	if (fm10k_logtype_driver >= 0)
-		rte_log_set_level(fm10k_logtype_driver, RTE_LOG_NOTICE);
-
+RTE_LOG_REGISTER(fm10k_logtype_init, pmd.net.fm10k.init, NOTICE);
+RTE_LOG_REGISTER(fm10k_logtype_driver, pmd.net.fm10k.driver, NOTICE);
 #ifdef RTE_LIBRTE_FM10K_DEBUG_RX
-	fm10k_logtype_rx = rte_log_register("pmd.net.fm10k.rx");
-	if (fm10k_logtype_rx >= 0)
-		rte_log_set_level(fm10k_logtype_rx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(fm10k_logtype_rx, pmd.net.fm10k.rx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_FM10K_DEBUG_TX
-	fm10k_logtype_tx = rte_log_register("pmd.net.fm10k.tx");
-	if (fm10k_logtype_tx >= 0)
-		rte_log_set_level(fm10k_logtype_tx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(fm10k_logtype_tx, pmd.net.fm10k.tx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_FM10K_DEBUG_TX_FREE
-	fm10k_logtype_tx_free = rte_log_register("pmd.net.fm10k.tx_free");
-	if (fm10k_logtype_tx_free >= 0)
-		rte_log_set_level(fm10k_logtype_tx_free, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(fm10k_logtype_tx_free, pmd.net.fm10k.tx_free, DEBUG);
 #endif
-}
diff --git a/drivers/net/hinic/hinic_pmd_ethdev.c b/drivers/net/hinic/hinic_pmd_ethdev.c
index 0c3e1c0cd..8f81e2230 100644
--- a/drivers/net/hinic/hinic_pmd_ethdev.c
+++ b/drivers/net/hinic/hinic_pmd_ethdev.c
@@ -78,9 +78,6 @@
 /* lro numer limit for one packet */
 #define HINIC_LRO_WQE_NUM_DEFAULT	8
 
-/* Driver-specific log messages type */
-int hinic_logtype;
-
 struct hinic_xstats_name_off {
 	char name[RTE_ETH_XSTATS_NAME_SIZE];
 	u32  offset;
@@ -3250,10 +3247,4 @@ static struct rte_pci_driver rte_hinic_pmd = {
 
 RTE_PMD_REGISTER_PCI(net_hinic, rte_hinic_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_hinic, pci_id_hinic_map);
-
-RTE_INIT(hinic_init_log)
-{
-	hinic_logtype = rte_log_register("pmd.net.hinic");
-	if (hinic_logtype >= 0)
-		rte_log_set_level(hinic_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(hinic_logtype, pmd.net.hinic, INFO);
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 62d87582d..309d0483e 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -60,9 +60,6 @@
 #define HNS3_RESET_WAIT_MS	100
 #define HNS3_RESET_WAIT_CNT	200
 
-int hns3_logtype_init;
-int hns3_logtype_driver;
-
 enum hns3_evt_cause {
 	HNS3_VECTOR0_EVENT_RST,
 	HNS3_VECTOR0_EVENT_MBX,
@@ -5525,13 +5522,5 @@ static struct rte_pci_driver rte_hns3_pmd = {
 RTE_PMD_REGISTER_PCI(net_hns3, rte_hns3_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_hns3, pci_id_hns3_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_hns3, "* igb_uio | vfio-pci");
-
-RTE_INIT(hns3_init_log)
-{
-	hns3_logtype_init = rte_log_register("pmd.net.hns3.init");
-	if (hns3_logtype_init >= 0)
-		rte_log_set_level(hns3_logtype_init, RTE_LOG_NOTICE);
-	hns3_logtype_driver = rte_log_register("pmd.net.hns3.driver");
-	if (hns3_logtype_driver >= 0)
-		rte_log_set_level(hns3_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(hns3_logtype_init, pmd.net.hns3.init, NOTICE);
+RTE_LOG_REGISTER(hns3_logtype_driver, pmd.net.hns3.driver, NOTICE);
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 970a31cb2..472ce2a9e 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -398,18 +398,6 @@ static void i40e_tunnel_filter_restore(struct i40e_pf *pf);
 static void i40e_filter_restore(struct i40e_pf *pf);
 static void i40e_notify_all_vfs_link_status(struct rte_eth_dev *dev);
 
-int i40e_logtype_init;
-int i40e_logtype_driver;
-#ifdef RTE_LIBRTE_I40E_DEBUG_RX
-int i40e_logtype_rx;
-#endif
-#ifdef RTE_LIBRTE_I40E_DEBUG_TX
-int i40e_logtype_tx;
-#endif
-#ifdef RTE_LIBRTE_I40E_DEBUG_TX_FREE
-int i40e_logtype_tx_free;
-#endif
-
 static const char *const valid_keys[] = {
 	ETH_I40E_FLOATING_VEB_ARG,
 	ETH_I40E_FLOATING_VEB_LIST_ARG,
@@ -13411,33 +13399,17 @@ i40e_config_rss_filter(struct i40e_pf *pf,
 	return 0;
 }
 
-RTE_INIT(i40e_init_log)
-{
-	i40e_logtype_init = rte_log_register("pmd.net.i40e.init");
-	if (i40e_logtype_init >= 0)
-		rte_log_set_level(i40e_logtype_init, RTE_LOG_NOTICE);
-	i40e_logtype_driver = rte_log_register("pmd.net.i40e.driver");
-	if (i40e_logtype_driver >= 0)
-		rte_log_set_level(i40e_logtype_driver, RTE_LOG_NOTICE);
-
+RTE_LOG_REGISTER(i40e_logtype_init, pmd.net.i40e.init, NOTICE);
+RTE_LOG_REGISTER(i40e_logtype_driver, pmd.net.i40e.driver, NOTICE);
 #ifdef RTE_LIBRTE_I40E_DEBUG_RX
-	i40e_logtype_rx = rte_log_register("pmd.net.i40e.rx");
-	if (i40e_logtype_rx >= 0)
-		rte_log_set_level(i40e_logtype_rx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(i40e_logtype_rx, pmd.net.i40e.rx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_I40E_DEBUG_TX
-	i40e_logtype_tx = rte_log_register("pmd.net.i40e.tx");
-	if (i40e_logtype_tx >= 0)
-		rte_log_set_level(i40e_logtype_tx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(i40e_logtype_tx, pmd.net.i40e.tx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_I40E_DEBUG_TX_FREE
-	i40e_logtype_tx_free = rte_log_register("pmd.net.i40e.tx_free");
-	if (i40e_logtype_tx_free >= 0)
-		rte_log_set_level(i40e_logtype_tx_free, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(i40e_logtype_tx_free, pmd.net.i40e.tx_free, DEBUG);
 #endif
-}
 
 RTE_PMD_REGISTER_PARAM_STRING(net_i40e,
 			      ETH_I40E_FLOATING_VEB_ARG "=1"
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 2b1066b0a..d69e5284e 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -74,20 +74,6 @@ static int iavf_dev_filter_ctrl(struct rte_eth_dev *dev,
 		     enum rte_filter_op filter_op,
 		     void *arg);
 
-
-int iavf_logtype_init;
-int iavf_logtype_driver;
-
-#ifdef RTE_LIBRTE_IAVF_DEBUG_RX
-int iavf_logtype_rx;
-#endif
-#ifdef RTE_LIBRTE_IAVF_DEBUG_TX
-int iavf_logtype_tx;
-#endif
-#ifdef RTE_LIBRTE_IAVF_DEBUG_TX_FREE
-int iavf_logtype_tx_free;
-#endif
-
 static const struct rte_pci_id pci_id_iavf_map[] = {
 	{ RTE_PCI_DEVICE(IAVF_INTEL_VENDOR_ID, IAVF_DEV_ID_ADAPTIVE_VF) },
 	{ .vendor_id = 0, /* sentinel */ },
@@ -1556,30 +1542,14 @@ RTE_PMD_REGISTER_PCI(net_iavf, rte_iavf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_iavf, pci_id_iavf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_iavf, "* igb_uio | vfio-pci");
 RTE_PMD_REGISTER_PARAM_STRING(net_iavf, "cap=dcf");
-RTE_INIT(iavf_init_log)
-{
-	iavf_logtype_init = rte_log_register("pmd.net.iavf.init");
-	if (iavf_logtype_init >= 0)
-		rte_log_set_level(iavf_logtype_init, RTE_LOG_NOTICE);
-	iavf_logtype_driver = rte_log_register("pmd.net.iavf.driver");
-	if (iavf_logtype_driver >= 0)
-		rte_log_set_level(iavf_logtype_driver, RTE_LOG_NOTICE);
-
+RTE_LOG_REGISTER(iavf_logtype_init, pmd.net.iavf.init, NOTICE);
+RTE_LOG_REGISTER(iavf_logtype_driver, pmd.net.iavf.driver, NOTICE);
 #ifdef RTE_LIBRTE_IAVF_DEBUG_RX
-	iavf_logtype_rx = rte_log_register("pmd.net.iavf.rx");
-	if (iavf_logtype_rx >= 0)
-		rte_log_set_level(iavf_logtype_rx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(iavf_logtype_rx, pmd.net.iavf.rx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_IAVF_DEBUG_TX
-	iavf_logtype_tx = rte_log_register("pmd.net.iavf.tx");
-	if (iavf_logtype_tx >= 0)
-		rte_log_set_level(iavf_logtype_tx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(iavf_logtype_tx, pmd.net.iavf.tx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_IAVF_DEBUG_TX_FREE
-	iavf_logtype_tx_free = rte_log_register("pmd.net.iavf.tx_free");
-	if (iavf_logtype_tx_free >= 0)
-		rte_log_set_level(iavf_logtype_tx_free, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(iavf_logtype_tx_free, pmd.net.iavf.tx_free, DEBUG);
 #endif
-}
diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 5a89a1955..3386960df 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -71,18 +71,6 @@ static struct proto_xtr_ol_flag ice_proto_xtr_ol_flag_params[] = {
 #define ICE_COMMS_PKG_NAME			"ICE COMMS Package"
 #define ICE_MAX_RES_DESC_NUM        1024
 
-int ice_logtype_init;
-int ice_logtype_driver;
-#ifdef RTE_LIBRTE_ICE_DEBUG_RX
-int ice_logtype_rx;
-#endif
-#ifdef RTE_LIBRTE_ICE_DEBUG_TX
-int ice_logtype_tx;
-#endif
-#ifdef RTE_LIBRTE_ICE_DEBUG_TX_FREE
-int ice_logtype_tx_free;
-#endif
-
 static int ice_dev_configure(struct rte_eth_dev *dev);
 static int ice_dev_start(struct rte_eth_dev *dev);
 static void ice_dev_stop(struct rte_eth_dev *dev);
@@ -4576,30 +4564,14 @@ RTE_PMD_REGISTER_PARAM_STRING(net_ice,
 			      ICE_PIPELINE_MODE_SUPPORT_ARG "=<0|1>"
 			      ICE_FLOW_MARK_SUPPORT_ARG "=<0|1>");
 
-RTE_INIT(ice_init_log)
-{
-	ice_logtype_init = rte_log_register("pmd.net.ice.init");
-	if (ice_logtype_init >= 0)
-		rte_log_set_level(ice_logtype_init, RTE_LOG_NOTICE);
-	ice_logtype_driver = rte_log_register("pmd.net.ice.driver");
-	if (ice_logtype_driver >= 0)
-		rte_log_set_level(ice_logtype_driver, RTE_LOG_NOTICE);
-
+RTE_LOG_REGISTER(ice_logtype_init, pmd.net.ice.init, NOTICE);
+RTE_LOG_REGISTER(ice_logtype_driver, pmd.net.ice.driver, NOTICE);
 #ifdef RTE_LIBRTE_ICE_DEBUG_RX
-	ice_logtype_rx = rte_log_register("pmd.net.ice.rx");
-	if (ice_logtype_rx >= 0)
-		rte_log_set_level(ice_logtype_rx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(ice_logtype_rx, pmd.net.ice.rx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_ICE_DEBUG_TX
-	ice_logtype_tx = rte_log_register("pmd.net.ice.tx");
-	if (ice_logtype_tx >= 0)
-		rte_log_set_level(ice_logtype_tx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(ice_logtype_tx, pmd.net.ice.tx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_ICE_DEBUG_TX_FREE
-	ice_logtype_tx_free = rte_log_register("pmd.net.ice.tx_free");
-	if (ice_logtype_tx_free >= 0)
-		rte_log_set_level(ice_logtype_tx_free, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(ice_logtype_tx_free, pmd.net.ice.tx_free, DEBUG);
 #endif
-}
diff --git a/drivers/net/igc/igc_logs.c b/drivers/net/igc/igc_logs.c
index eff7640b1..2d458d7fb 100644
--- a/drivers/net/igc/igc_logs.c
+++ b/drivers/net/igc/igc_logs.c
@@ -6,17 +6,5 @@
 
 #include "igc_logs.h"
 
-/* declared as extern in igc_logs.h */
-int igc_logtype_init;
-int igc_logtype_driver;
-
-RTE_INIT(igc_init_log)
-{
-	igc_logtype_init = rte_log_register("pmd.net.igc.init");
-	if (igc_logtype_init >= 0)
-		rte_log_set_level(igc_logtype_init, RTE_LOG_INFO);
-
-	igc_logtype_driver = rte_log_register("pmd.net.igc.driver");
-	if (igc_logtype_driver >= 0)
-		rte_log_set_level(igc_logtype_driver, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(igc_logtype_init, pmd.net.igc.init, INFO);
+RTE_LOG_REGISTER(igc_logtype_driver, pmd.net.igc.driver, INFO);
diff --git a/drivers/net/ionic/ionic_ethdev.c b/drivers/net/ionic/ionic_ethdev.c
index 363f0cf00..800f6e5d6 100644
--- a/drivers/net/ionic/ionic_ethdev.c
+++ b/drivers/net/ionic/ionic_ethdev.c
@@ -59,8 +59,6 @@ static int  ionic_dev_xstats_get_names_by_id(struct rte_eth_dev *dev,
 static int  ionic_dev_fw_version_get(struct rte_eth_dev *eth_dev,
 	char *fw_version, size_t fw_size);
 
-int ionic_logtype;
-
 static const struct rte_pci_id pci_id_ionic_map[] = {
 	{ RTE_PCI_DEVICE(IONIC_PENSANDO_VENDOR_ID, IONIC_DEV_ID_ETH_PF) },
 	{ RTE_PCI_DEVICE(IONIC_PENSANDO_VENDOR_ID, IONIC_DEV_ID_ETH_VF) },
@@ -1318,10 +1316,4 @@ static struct rte_pci_driver rte_ionic_pmd = {
 RTE_PMD_REGISTER_PCI(net_ionic, rte_ionic_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_ionic, pci_id_ionic_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_ionic, "* igb_uio | uio_pci_generic | vfio-pci");
-
-RTE_INIT(ionic_init_log)
-{
-	ionic_logtype = rte_log_register("pmd.net.ionic");
-	if (ionic_logtype >= 0)
-		rte_log_set_level(ionic_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(ionic_logtype, pmd.net.ionic, NOTICE);
diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.c b/drivers/net/ipn3ke/ipn3ke_ethdev.c
index 5b5510f08..027be29bd 100644
--- a/drivers/net/ipn3ke/ipn3ke_ethdev.c
+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.c
@@ -26,8 +26,6 @@
 #include "ipn3ke_logs.h"
 #include "ipn3ke_ethdev.h"
 
-int ipn3ke_afu_logtype;
-
 static const struct rte_afu_uuid afu_uuid_ipn3ke_map[] = {
 	{ MAP_UUID_10G_LOW,  MAP_UUID_10G_HIGH },
 	{ IPN3KE_UUID_10G_LOW, IPN3KE_UUID_10G_HIGH },
@@ -587,10 +585,4 @@ static struct rte_afu_driver afu_ipn3ke_driver = {
 };
 
 RTE_PMD_REGISTER_AFU(net_ipn3ke_afu, afu_ipn3ke_driver);
-
-RTE_INIT(ipn3ke_afu_init_log)
-{
-	ipn3ke_afu_logtype = rte_log_register("pmd.afu.ipn3ke");
-	if (ipn3ke_afu_logtype >= 0)
-		rte_log_set_level(ipn3ke_afu_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(ipn3ke_afu_logtype, pmd.afu.ipn3ke, NOTICE);
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index f8a84c565..248f21d14 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -419,19 +419,6 @@ static int ixgbe_wait_for_link_up(struct ixgbe_hw *hw);
 		(r) = (h)->bitmap[idx] >> bit & 1;\
 	} while (0)
 
-int ixgbe_logtype_init;
-int ixgbe_logtype_driver;
-
-#ifdef RTE_LIBRTE_IXGBE_DEBUG_RX
-int ixgbe_logtype_rx;
-#endif
-#ifdef RTE_LIBRTE_IXGBE_DEBUG_TX
-int ixgbe_logtype_tx;
-#endif
-#ifdef RTE_LIBRTE_IXGBE_DEBUG_TX_FREE
-int ixgbe_logtype_tx_free;
-#endif
-
 /*
  * The set of PCI devices this driver supports
  */
@@ -9117,29 +9104,15 @@ RTE_PMD_REGISTER_KMOD_DEP(net_ixgbe_vf, "* igb_uio | vfio-pci");
 RTE_PMD_REGISTER_PARAM_STRING(net_ixgbe_vf,
 			      IXGBEVF_DEVARG_PFLINK_FULLCHK "=<0|1>");
 
-RTE_INIT(ixgbe_init_log)
-{
-	ixgbe_logtype_init = rte_log_register("pmd.net.ixgbe.init");
-	if (ixgbe_logtype_init >= 0)
-		rte_log_set_level(ixgbe_logtype_init, RTE_LOG_NOTICE);
-	ixgbe_logtype_driver = rte_log_register("pmd.net.ixgbe.driver");
-	if (ixgbe_logtype_driver >= 0)
-		rte_log_set_level(ixgbe_logtype_driver, RTE_LOG_NOTICE);
+RTE_LOG_REGISTER(ixgbe_logtype_init, pmd.net.ixgbe.init, NOTICE);
+RTE_LOG_REGISTER(ixgbe_logtype_driver, pmd.net.ixgbe.driver, NOTICE);
+
 #ifdef RTE_LIBRTE_IXGBE_DEBUG_RX
-	ixgbe_logtype_rx = rte_log_register("pmd.net.ixgbe.rx");
-	if (ixgbe_logtype_rx >= 0)
-		rte_log_set_level(ixgbe_logtype_rx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(ixgbe_logtype_rx, pmd.net.ixgbe.rx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_IXGBE_DEBUG_TX
-	ixgbe_logtype_tx = rte_log_register("pmd.net.ixgbe.tx");
-	if (ixgbe_logtype_tx >= 0)
-		rte_log_set_level(ixgbe_logtype_tx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(ixgbe_logtype_tx, pmd.net.ixgbe.tx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_IXGBE_DEBUG_TX_FREE
-	ixgbe_logtype_tx_free = rte_log_register("pmd.net.ixgbe.tx_free");
-	if (ixgbe_logtype_tx_free >= 0)
-		rte_log_set_level(ixgbe_logtype_tx_free, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(ixgbe_logtype_tx_free, pmd.net.ixgbe.tx_free, DEBUG);
 #endif
-}
diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c
index d88cb1778..cde98f0bb 100644
--- a/drivers/net/kni/rte_eth_kni.c
+++ b/drivers/net/kni/rte_eth_kni.c
@@ -67,7 +67,7 @@ static const struct rte_eth_link pmd_link = {
 };
 static int is_kni_initialized;
 
-static int eth_kni_logtype;
+RTE_LOG_REGISTER(eth_kni_logtype, pmd.net.kni, NOTICE);
 
 #define PMD_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, eth_kni_logtype, \
@@ -508,10 +508,3 @@ static struct rte_vdev_driver eth_kni_drv = {
 
 RTE_PMD_REGISTER_VDEV(net_kni, eth_kni_drv);
 RTE_PMD_REGISTER_PARAM_STRING(net_kni, ETH_KNI_NO_REQUEST_THREAD_ARG "=<int>");
-
-RTE_INIT(eth_kni_init_log)
-{
-	eth_kni_logtype = rte_log_register("pmd.net.kni");
-	if (eth_kni_logtype >= 0)
-		rte_log_set_level(eth_kni_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c
index ad4a51ecd..2258838c4 100644
--- a/drivers/net/liquidio/lio_ethdev.c
+++ b/drivers/net/liquidio/lio_ethdev.c
@@ -15,9 +15,6 @@
 #include "lio_ethdev.h"
 #include "lio_rxtx.h"
 
-int lio_logtype_init;
-int lio_logtype_driver;
-
 /* Default RSS key in use */
 static uint8_t lio_rss_key[40] = {
 	0x6D, 0x5A, 0x56, 0xDA, 0x25, 0x5B, 0x0E, 0xC2,
@@ -2161,13 +2158,5 @@ static struct rte_pci_driver rte_liovf_pmd = {
 RTE_PMD_REGISTER_PCI(net_liovf, rte_liovf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_liovf, pci_id_liovf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_liovf, "* igb_uio | vfio-pci");
-
-RTE_INIT(lio_init_log)
-{
-	lio_logtype_init = rte_log_register("pmd.net.liquidio.init");
-	if (lio_logtype_init >= 0)
-		rte_log_set_level(lio_logtype_init, RTE_LOG_NOTICE);
-	lio_logtype_driver = rte_log_register("pmd.net.liquidio.driver");
-	if (lio_logtype_driver >= 0)
-		rte_log_set_level(lio_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(lio_logtype_init, pmd.net.liquidio.init, NOTICE);
+RTE_LOG_REGISTER(lio_logtype_driver, pmd.net.liquidio.driver, NOTICE);
diff --git a/drivers/net/memif/rte_eth_memif.c b/drivers/net/memif/rte_eth_memif.c
index b6da9a8b4..c1c7e9f8d 100644
--- a/drivers/net/memif/rte_eth_memif.c
+++ b/drivers/net/memif/rte_eth_memif.c
@@ -1806,11 +1806,4 @@ RTE_PMD_REGISTER_PARAM_STRING(net_memif,
 			      ETH_MEMIF_ZC_ARG "=yes|no"
 			      ETH_MEMIF_SECRET_ARG "=<string>");
 
-int memif_logtype;
-
-RTE_INIT(memif_init_log)
-{
-	memif_logtype = rte_log_register("pmd.net.memif");
-	if (memif_logtype >= 0)
-		rte_log_set_level(memif_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(memif_logtype, pmd.net.memif, NOTICE);
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index 5d7202720..5414bcc1f 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -64,9 +64,6 @@ static rte_spinlock_t mlx4_shared_data_lock = RTE_SPINLOCK_INITIALIZER;
 /* Process local data for secondary processes. */
 static struct mlx4_local_data mlx4_local_data;
 
-/** Driver-specific log messages type. */
-int mlx4_logtype;
-
 /** Configuration structure for device arguments. */
 struct mlx4_conf {
 	struct {
@@ -1281,16 +1278,14 @@ mlx4_glue_init(void)
 
 #endif
 
+/* Initialize driver log type. */
+RTE_LOG_REGISTER(mlx4_logtype, pmd.net.mlx4, NOTICE);
+
 /**
  * Driver initialization routine.
  */
 RTE_INIT(rte_mlx4_pmd_init)
 {
-	/* Initialize driver log type. */
-	mlx4_logtype = rte_log_register("pmd.net.mlx4");
-	if (mlx4_logtype >= 0)
-		rte_log_set_level(mlx4_logtype, RTE_LOG_NOTICE);
-
 	/*
 	 * MLX4_DEVICE_FATAL_CLEANUP tells ibv_destroy functions we
 	 * want to get success errno value in case of calling them
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 5c86f6fb9..f433195ee 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -173,8 +173,6 @@ static rte_spinlock_t mlx5_shared_data_lock = RTE_SPINLOCK_INITIALIZER;
 
 /* Process local data for secondary processes. */
 static struct mlx5_local_data mlx5_local_data;
-/** Driver-specific log messages type. */
-int mlx5_logtype;
 
 static LIST_HEAD(, mlx5_dev_ctx_shared) mlx5_dev_ctx_list =
 						LIST_HEAD_INITIALIZER();
@@ -1999,16 +1997,14 @@ struct rte_pci_driver mlx5_driver = {
 	.drv_flags = PCI_DRV_FLAGS,
 };
 
+/* Initialize driver log type. */
+RTE_LOG_REGISTER(mlx5_logtype, pmd.net.mlx5, NOTICE);
+
 /**
  * Driver initialization routine.
  */
 RTE_INIT(rte_mlx5_pmd_init)
 {
-	/* Initialize driver log type. */
-	mlx5_logtype = rte_log_register("pmd.net.mlx5");
-	if (mlx5_logtype >= 0)
-		rte_log_set_level(mlx5_logtype, RTE_LOG_NOTICE);
-
 	/* Build the static tables for Verbs conversion. */
 	mlx5_set_ptype_table();
 	mlx5_set_cksum_table();
diff --git a/drivers/net/mvneta/mvneta_ethdev.c b/drivers/net/mvneta/mvneta_ethdev.c
index 4aea87648..673a8e2b3 100644
--- a/drivers/net/mvneta/mvneta_ethdev.c
+++ b/drivers/net/mvneta/mvneta_ethdev.c
@@ -34,8 +34,6 @@
 /** Maximum length of a match string */
 #define MVNETA_MATCH_LEN 16
 
-int mvneta_logtype;
-
 static const char * const valid_args[] = {
 	MVNETA_IFACE_NAME_ARG,
 	NULL
@@ -982,10 +980,4 @@ static struct rte_vdev_driver pmd_mvneta_drv = {
 
 RTE_PMD_REGISTER_VDEV(net_mvneta, pmd_mvneta_drv);
 RTE_PMD_REGISTER_PARAM_STRING(net_mvneta, "iface=<ifc>");
-
-RTE_INIT(mvneta_init_log)
-{
-	mvneta_logtype = rte_log_register("pmd.net.mvneta");
-	if (mvneta_logtype >= 0)
-		rte_log_set_level(mvneta_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(mvneta_logtype, pmd.net.mvneta, NOTICE);
diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c
index b98b1fd66..75589f18e 100644
--- a/drivers/net/mvpp2/mrvl_ethdev.c
+++ b/drivers/net/mvpp2/mrvl_ethdev.c
@@ -84,8 +84,6 @@ static struct pp2_bpool *mrvl_port_to_bpool_lookup[RTE_MAX_ETHPORTS];
 static int mrvl_port_bpool_size[PP2_NUM_PKT_PROC][PP2_BPOOL_NUM_POOLS][RTE_MAX_LCORE];
 static uint64_t cookie_addr_high = MRVL_COOKIE_ADDR_INVALID;
 
-int mrvl_logtype;
-
 struct mrvl_ifnames {
 	const char *names[PP2_NUM_ETH_PPIO * PP2_NUM_PKT_PROC];
 	int idx;
@@ -3040,10 +3038,4 @@ static struct rte_vdev_driver pmd_mrvl_drv = {
 
 RTE_PMD_REGISTER_VDEV(net_mvpp2, pmd_mrvl_drv);
 RTE_PMD_REGISTER_ALIAS(net_mvpp2, eth_mvpp2);
-
-RTE_INIT(mrvl_init_log)
-{
-	mrvl_logtype = rte_log_register("pmd.net.mvpp2");
-	if (mrvl_logtype >= 0)
-		rte_log_set_level(mrvl_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(mrvl_logtype, pmd.net.mvpp2, NOTICE);
diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c
index ac182a548..fd91c0e49 100644
--- a/drivers/net/netvsc/hn_ethdev.c
+++ b/drivers/net/netvsc/hn_ethdev.c
@@ -45,9 +45,6 @@
 			    DEV_RX_OFFLOAD_VLAN_STRIP | \
 			    DEV_RX_OFFLOAD_RSS_HASH)
 
-int hn_logtype_init;
-int hn_logtype_driver;
-
 struct hn_xstats_name_off {
 	char name[RTE_ETH_XSTATS_NAME_SIZE];
 	unsigned int offset;
@@ -1121,13 +1118,5 @@ static struct rte_vmbus_driver rte_netvsc_pmd = {
 
 RTE_PMD_REGISTER_VMBUS(net_netvsc, rte_netvsc_pmd);
 RTE_PMD_REGISTER_KMOD_DEP(net_netvsc, "* uio_hv_generic");
-
-RTE_INIT(hn_init_log)
-{
-	hn_logtype_init = rte_log_register("pmd.net.netvsc.init");
-	if (hn_logtype_init >= 0)
-		rte_log_set_level(hn_logtype_init, RTE_LOG_NOTICE);
-	hn_logtype_driver = rte_log_register("pmd.net.netvsc.driver");
-	if (hn_logtype_driver >= 0)
-		rte_log_set_level(hn_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(hn_logtype_init, pmd.net.netvsc.init, NOTICE);
+RTE_LOG_REGISTER(hn_logtype_driver, pmd.net.netvsc.driver, NOTICE);
diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
index 2460ee199..88e3f01d6 100644
--- a/drivers/net/nfp/nfp_net.c
+++ b/drivers/net/nfp/nfp_net.c
@@ -3683,9 +3683,6 @@ static int nfp_pf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	return ret;
 }
 
-int nfp_logtype_init;
-int nfp_logtype_driver;
-
 static const struct rte_pci_id pci_id_nfp_pf_net_map[] = {
 	{
 		RTE_PCI_DEVICE(PCI_VENDOR_ID_NETRONOME,
@@ -3769,16 +3766,8 @@ RTE_PMD_REGISTER_PCI_TABLE(net_nfp_pf, pci_id_nfp_pf_net_map);
 RTE_PMD_REGISTER_PCI_TABLE(net_nfp_vf, pci_id_nfp_vf_net_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_nfp_pf, "* igb_uio | uio_pci_generic | vfio");
 RTE_PMD_REGISTER_KMOD_DEP(net_nfp_vf, "* igb_uio | uio_pci_generic | vfio");
-
-RTE_INIT(nfp_init_log)
-{
-	nfp_logtype_init = rte_log_register("pmd.net.nfp.init");
-	if (nfp_logtype_init >= 0)
-		rte_log_set_level(nfp_logtype_init, RTE_LOG_NOTICE);
-	nfp_logtype_driver = rte_log_register("pmd.net.nfp.driver");
-	if (nfp_logtype_driver >= 0)
-		rte_log_set_level(nfp_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(nfp_logtype_init, pmd.net.nfp.init, NOTICE);
+RTE_LOG_REGISTER(nfp_logtype_driver, pmd.net.nfp.driver, NOTICE);
 /*
  * Local variables:
  * c-file-style: "Linux"
diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index 11258ccea..8c779be7f 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c
@@ -73,7 +73,7 @@ static struct rte_eth_link pmd_link = {
 	.link_autoneg = ETH_LINK_FIXED,
 };
 
-static int eth_null_logtype;
+RTE_LOG_REGISTER(eth_null_logtype, pmd.net.null, NOTICE);
 
 #define PMD_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, eth_null_logtype, \
@@ -730,9 +730,3 @@ RTE_PMD_REGISTER_PARAM_STRING(net_null,
 	"copy=<int> "
 	ETH_NULL_PACKET_NO_RX_ARG "=0|1");
 
-RTE_INIT(eth_null_init_log)
-{
-	eth_null_logtype = rte_log_register("pmd.net.null");
-	if (eth_null_logtype >= 0)
-		rte_log_set_level(eth_null_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c
index d5371ae07..76c69294d 100644
--- a/drivers/net/octeontx/octeontx_ethdev.c
+++ b/drivers/net/octeontx/octeontx_ethdev.c
@@ -47,24 +47,9 @@ enum octeontx_link_speed {
 	OCTEONTX_LINK_SPEED_RESERVE2
 };
 
-int otx_net_logtype_mbox;
-int otx_net_logtype_init;
-int otx_net_logtype_driver;
-
-RTE_INIT(otx_net_init_log)
-{
-	otx_net_logtype_mbox = rte_log_register("pmd.net.octeontx.mbox");
-	if (otx_net_logtype_mbox >= 0)
-		rte_log_set_level(otx_net_logtype_mbox, RTE_LOG_NOTICE);
-
-	otx_net_logtype_init = rte_log_register("pmd.net.octeontx.init");
-	if (otx_net_logtype_init >= 0)
-		rte_log_set_level(otx_net_logtype_init, RTE_LOG_NOTICE);
-
-	otx_net_logtype_driver = rte_log_register("pmd.net.octeontx.driver");
-	if (otx_net_logtype_driver >= 0)
-		rte_log_set_level(otx_net_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(otx_net_logtype_mbox, pmd.net.octeontx.mbox, NOTICE);
+RTE_LOG_REGISTER(otx_net_logtype_init, pmd.net.octeontx.init, NOTICE);
+RTE_LOG_REGISTER(otx_net_logtype_driver, pmd.net.octeontx.driver, NOTICE);
 
 /* Parse integer from integer argument */
 static int
diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index 13a3d0ac7..60e393c92 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -135,7 +135,7 @@ static struct rte_eth_link pmd_link = {
 		.link_autoneg = ETH_LINK_FIXED,
 };
 
-static int eth_pcap_logtype;
+RTE_LOG_REGISTER(eth_pcap_logtype, pmd.net.pcap, NOTICE);
 
 #define PMD_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, eth_pcap_logtype, \
@@ -1589,9 +1589,3 @@ RTE_PMD_REGISTER_PARAM_STRING(net_pcap,
 	ETH_PCAP_PHY_MAC_ARG "=<int>"
 	ETH_PCAP_INFINITE_RX_ARG "=<0|1>");
 
-RTE_INIT(eth_pcap_init_log)
-{
-	eth_pcap_logtype = rte_log_register("pmd.net.pcap");
-	if (eth_pcap_logtype >= 0)
-		rte_log_set_level(eth_pcap_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/pfe/pfe_ethdev.c b/drivers/net/pfe/pfe_ethdev.c
index b1de866d3..368acfa55 100644
--- a/drivers/net/pfe/pfe_ethdev.c
+++ b/drivers/net/pfe/pfe_ethdev.c
@@ -40,8 +40,6 @@ unsigned int pfe_svr = SVR_LS1012A_REV1;
 static void *cbus_emac_base[3];
 static void *cbus_gpi_base[3];
 
-int pfe_logtype_pmd;
-
 /* pfe_gemac_init
  */
 static int
@@ -1181,10 +1179,4 @@ struct rte_vdev_driver pmd_pfe_drv = {
 
 RTE_PMD_REGISTER_VDEV(PFE_NAME_PMD, pmd_pfe_drv);
 RTE_PMD_REGISTER_PARAM_STRING(PFE_NAME_PMD, PFE_VDEV_GEM_ID_ARG "=<int> ");
-
-RTE_INIT(pfe_pmd_init_log)
-{
-	pfe_logtype_pmd = rte_log_register("pmd.net.pfe");
-	if (pfe_logtype_pmd >= 0)
-		rte_log_set_level(pfe_logtype_pmd, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(pfe_logtype_pmd, pmd.net.pfe, NOTICE);
diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c
index c4f8f1258..6107d583e 100644
--- a/drivers/net/qede/qede_ethdev.c
+++ b/drivers/net/qede/qede_ethdev.c
@@ -10,10 +10,6 @@
 #include <rte_version.h>
 #include <rte_kvargs.h>
 
-/* Globals */
-int qede_logtype_init;
-int qede_logtype_driver;
-
 static const struct qed_eth_ops *qed_ops;
 static int qede_eth_dev_uninit(struct rte_eth_dev *eth_dev);
 static int qede_eth_dev_init(struct rte_eth_dev *eth_dev);
@@ -2870,13 +2866,5 @@ RTE_PMD_REGISTER_KMOD_DEP(net_qede, "* igb_uio | uio_pci_generic | vfio-pci");
 RTE_PMD_REGISTER_PCI(net_qede_vf, rte_qedevf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_qede_vf, pci_id_qedevf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_qede_vf, "* igb_uio | vfio-pci");
-
-RTE_INIT(qede_init_log)
-{
-	qede_logtype_init = rte_log_register("pmd.net.qede.init");
-	if (qede_logtype_init >= 0)
-		rte_log_set_level(qede_logtype_init, RTE_LOG_NOTICE);
-	qede_logtype_driver = rte_log_register("pmd.net.qede.driver");
-	if (qede_logtype_driver >= 0)
-		rte_log_set_level(qede_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(qede_logtype_init, pmd.net.qede.init, NOTICE);
+RTE_LOG_REGISTER(qede_logtype_driver, pmd.net.qede.driver, NOTICE);
diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index f0fafa0c0..078df605a 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -61,7 +61,7 @@ static struct rte_eth_link pmd_link = {
 	.link_autoneg = ETH_LINK_FIXED,
 };
 
-static int eth_ring_logtype;
+RTE_LOG_REGISTER(eth_ring_logtype, pmd.net.ring, NOTICE);
 
 #define PMD_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, eth_ring_logtype, \
@@ -703,9 +703,3 @@ RTE_PMD_REGISTER_ALIAS(net_ring, eth_ring);
 RTE_PMD_REGISTER_PARAM_STRING(net_ring,
 	ETH_RING_NUMA_NODE_ACTION_ARG "=name:node:action(ATTACH|CREATE)");
 
-RTE_INIT(eth_ring_init_log)
-{
-	eth_ring_logtype = rte_log_register("pmd.net.ring");
-	if (eth_ring_logtype >= 0)
-		rte_log_set_level(eth_ring_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/softnic/rte_eth_softnic.c b/drivers/net/softnic/rte_eth_softnic.c
index 11723778f..866d17a93 100644
--- a/drivers/net/softnic/rte_eth_softnic.c
+++ b/drivers/net/softnic/rte_eth_softnic.c
@@ -80,7 +80,7 @@ static const struct softnic_conn_params conn_params_default = {
 	.msg_handle_arg = NULL,
 };
 
-static int pmd_softnic_logtype;
+RTE_LOG_REGISTER(pmd_softnic_logtype, pmd.net.softnic, NOTICE);
 
 #define PMD_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, pmd_softnic_logtype, \
@@ -690,14 +690,6 @@ RTE_PMD_REGISTER_PARAM_STRING(net_softnic,
 	PMD_PARAM_TM_QSIZE12 "=<uint32>"
 );
 
-
-RTE_INIT(pmd_softnic_init_log)
-{
-	pmd_softnic_logtype = rte_log_register("pmd.net.softnic");
-	if (pmd_softnic_logtype >= 0)
-		rte_log_set_level(pmd_softnic_logtype, RTE_LOG_NOTICE);
-}
-
 int
 rte_pmd_softnic_manage(uint16_t port_id)
 {
diff --git a/drivers/net/szedata2/rte_eth_szedata2.c b/drivers/net/szedata2/rte_eth_szedata2.c
index 821bb346c..30c888cd9 100644
--- a/drivers/net/szedata2/rte_eth_szedata2.c
+++ b/drivers/net/szedata2/rte_eth_szedata2.c
@@ -102,9 +102,6 @@ struct szedata2_tx_queue {
 	volatile uint64_t err_pkts;
 };
 
-int szedata2_logtype_init;
-int szedata2_logtype_driver;
-
 static struct rte_ether_addr eth_addr = {
 	.addr_bytes = { 0x00, 0x11, 0x17, 0x00, 0x00, 0x00 }
 };
@@ -1941,13 +1938,5 @@ RTE_PMD_REGISTER_PCI(RTE_SZEDATA2_DRIVER_NAME, szedata2_eth_driver);
 RTE_PMD_REGISTER_PCI_TABLE(RTE_SZEDATA2_DRIVER_NAME, rte_szedata2_pci_id_table);
 RTE_PMD_REGISTER_KMOD_DEP(RTE_SZEDATA2_DRIVER_NAME,
 	"* combo6core & combov3 & szedata2 & ( szedata2_cv3 | szedata2_cv3_fdt )");
-
-RTE_INIT(szedata2_init_log)
-{
-	szedata2_logtype_init = rte_log_register("pmd.net.szedata2.init");
-	if (szedata2_logtype_init >= 0)
-		rte_log_set_level(szedata2_logtype_init, RTE_LOG_NOTICE);
-	szedata2_logtype_driver = rte_log_register("pmd.net.szedata2.driver");
-	if (szedata2_logtype_driver >= 0)
-		rte_log_set_level(szedata2_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(szedata2_logtype_init, pmd.net.szedata2.init, NOTICE);
+RTE_LOG_REGISTER(szedata2_logtype_driver, pmd.net.szedata2.driver, NOTICE);
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 7081ae23e..339f24bf8 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -2494,11 +2494,4 @@ RTE_PMD_REGISTER_PARAM_STRING(net_tap,
 			      ETH_TAP_IFACE_ARG "=<string> "
 			      ETH_TAP_MAC_ARG "=" ETH_TAP_MAC_ARG_FMT " "
 			      ETH_TAP_REMOTE_ARG "=<string>");
-int tap_logtype;
-
-RTE_INIT(tap_init_log)
-{
-	tap_logtype = rte_log_register("pmd.net.tap");
-	if (tap_logtype >= 0)
-		rte_log_set_level(tap_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(tap_logtype, pmd.net.tap, NOTICE);
diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c
index bfda0ab0e..d955a7ee2 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -44,10 +44,6 @@
 #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,
@@ -55,20 +51,9 @@ static void nicvf_vf_stop(struct rte_eth_dev *dev, struct nicvf *nic,
 static int nicvf_vlan_offload_config(struct rte_eth_dev *dev, int mask);
 static int nicvf_vlan_offload_set(struct rte_eth_dev *dev, int mask);
 
-RTE_INIT(nicvf_init_log)
-{
-	nicvf_logtype_mbox = rte_log_register("pmd.net.thunderx.mbox");
-	if (nicvf_logtype_mbox >= 0)
-		rte_log_set_level(nicvf_logtype_mbox, RTE_LOG_NOTICE);
-
-	nicvf_logtype_init = rte_log_register("pmd.net.thunderx.init");
-	if (nicvf_logtype_init >= 0)
-		rte_log_set_level(nicvf_logtype_init, RTE_LOG_NOTICE);
-
-	nicvf_logtype_driver = rte_log_register("pmd.net.thunderx.driver");
-	if (nicvf_logtype_driver >= 0)
-		rte_log_set_level(nicvf_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(nicvf_logtype_mbox, pmd.net.thunderx.mbox, NOTICE);
+RTE_LOG_REGISTER(nicvf_logtype_init, pmd.net.thunderx.init, NOTICE);
+RTE_LOG_REGISTER(nicvf_logtype_driver, pmd.net.thunderx.driver, NOTICE);
 
 static void
 nicvf_link_status_update(struct nicvf *nic,
diff --git a/drivers/net/vdev_netvsc/vdev_netvsc.c b/drivers/net/vdev_netvsc/vdev_netvsc.c
index 9ed74a1d6..1ecb0b3e6 100644
--- a/drivers/net/vdev_netvsc/vdev_netvsc.c
+++ b/drivers/net/vdev_netvsc/vdev_netvsc.c
@@ -48,6 +48,8 @@
 #define NETVSC_CLASS_ID "{f8615163-df3e-46c5-913f-f2d2f965ed0e}"
 #define NETVSC_MAX_ROUTE_LINE_SIZE 300
 
+RTE_LOG_REGISTER(vdev_netvsc_logtype, pmd.net.vdev_netvsc, NOTICE);
+
 #define DRV_LOG(level, ...) \
 	rte_log(RTE_LOG_ ## level, \
 		vdev_netvsc_logtype, \
@@ -55,9 +57,6 @@
 			RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
 		RTE_FMT_TAIL(__VA_ARGS__,)))
 
-/** Driver-specific log messages type. */
-static int vdev_netvsc_logtype;
-
 /** Context structure for a vdev_netvsc instance. */
 struct vdev_netvsc_ctx {
 	LIST_ENTRY(vdev_netvsc_ctx) entry; /**< Next entry in list. */
@@ -774,14 +773,6 @@ RTE_PMD_REGISTER_PARAM_STRING(net_vdev_netvsc,
 			      VDEV_NETVSC_ARG_FORCE "=<int> "
 			      VDEV_NETVSC_ARG_IGNORE "=<int>");
 
-/** Initialize driver log type. */
-RTE_INIT(vdev_netvsc_init_log)
-{
-	vdev_netvsc_logtype = rte_log_register("pmd.net.vdev_netvsc");
-	if (vdev_netvsc_logtype >= 0)
-		rte_log_set_level(vdev_netvsc_logtype, RTE_LOG_NOTICE);
-}
-
 /** Compare function for vdev find device operation. */
 static int
 vdev_netvsc_cmp_rte_device(const struct rte_device *dev1,
diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index 808e670f1..bfacdcb98 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -18,7 +18,7 @@
 
 #include "rte_eth_vhost.h"
 
-static int vhost_logtype;
+RTE_LOG_REGISTER(vhost_logtype, pmd.net.vhost, NOTICE);
 
 #define VHOST_LOG(level, ...) \
 	rte_log(RTE_LOG_ ## level, vhost_logtype, __VA_ARGS__)
@@ -1571,9 +1571,3 @@ RTE_PMD_REGISTER_PARAM_STRING(net_vhost,
 	"linear-buffer=<0|1> "
 	"ext-buffer=<0|1>");
 
-RTE_INIT(vhost_init_log)
-{
-	vhost_logtype = rte_log_register("pmd.net.vhost");
-	if (vhost_logtype >= 0)
-		rte_log_set_level(vhost_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 312871cb4..dc0093bdf 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -85,9 +85,6 @@ static int virtio_dev_queue_stats_mapping_set(
 	uint8_t stat_idx,
 	uint8_t is_rx);
 
-int virtio_logtype_init;
-int virtio_logtype_driver;
-
 static void virtio_notify_peers(struct rte_eth_dev *dev);
 static void virtio_ack_link_announce(struct rte_eth_dev *dev);
 
@@ -2659,13 +2656,5 @@ __rte_unused uint8_t is_rx)
 RTE_PMD_EXPORT_NAME(net_virtio, __COUNTER__);
 RTE_PMD_REGISTER_PCI_TABLE(net_virtio, pci_id_virtio_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_virtio, "* igb_uio | uio_pci_generic | vfio-pci");
-
-RTE_INIT(virtio_init_log)
-{
-	virtio_logtype_init = rte_log_register("pmd.net.virtio.init");
-	if (virtio_logtype_init >= 0)
-		rte_log_set_level(virtio_logtype_init, RTE_LOG_NOTICE);
-	virtio_logtype_driver = rte_log_register("pmd.net.virtio.driver");
-	if (virtio_logtype_driver >= 0)
-		rte_log_set_level(virtio_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(virtio_logtype_init, pmd.net.virtio.init, NOTICE);
+RTE_LOG_REGISTER(virtio_logtype_driver, pmd.net.virtio.driver, NOTICE);
diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c
index c6e11ad2d..815fba2f5 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethdev.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c
@@ -95,9 +95,6 @@ static int vmxnet3_mac_addr_set(struct rte_eth_dev *dev,
 				 struct rte_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
  */
@@ -1464,13 +1461,5 @@ 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)
-{
-	vmxnet3_logtype_init = rte_log_register("pmd.net.vmxnet3.init");
-	if (vmxnet3_logtype_init >= 0)
-		rte_log_set_level(vmxnet3_logtype_init, RTE_LOG_NOTICE);
-	vmxnet3_logtype_driver = rte_log_register("pmd.net.vmxnet3.driver");
-	if (vmxnet3_logtype_driver >= 0)
-		rte_log_set_level(vmxnet3_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(vmxnet3_logtype_init, pmd.net.vmxnet3.init, NOTICE);
+RTE_LOG_REGISTER(vmxnet3_logtype_driver, pmd.net.vmxnet3.driver, NOTICE);
-- 
2.27.0


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

* [dpdk-dev] [PATCH v3 06/13] drivers/mempool: use log register macro
  2020-07-01  6:48   ` [dpdk-dev] [PATCH v3 00/13] rte_log registration usage improvement jerinj
                       ` (4 preceding siblings ...)
  2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 05/13] drivers/net: " jerinj
@ 2020-07-01  6:48     ` jerinj
  2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 07/13] drivers/event: " jerinj
                       ` (7 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01  6:48 UTC (permalink / raw)
  To: dev, Hemant Agrawal, Sachin Saxena, Harman Kalra
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Sachin Saxena <sachin.saxena@oss.nxp.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/mempool/dpaa/dpaa_mempool.c       | 10 ++--------
 drivers/mempool/dpaa2/dpaa2_hw_mempool.c  | 10 +---------
 drivers/mempool/octeontx/octeontx_fpavf.c | 10 +---------
 3 files changed, 4 insertions(+), 26 deletions(-)

diff --git a/drivers/mempool/dpaa/dpaa_mempool.c b/drivers/mempool/dpaa/dpaa_mempool.c
index 451e2d5d5..8d1da8028 100644
--- a/drivers/mempool/dpaa/dpaa_mempool.c
+++ b/drivers/mempool/dpaa/dpaa_mempool.c
@@ -36,7 +36,8 @@ struct dpaa_memseg_list rte_dpaa_memsegs
 	= TAILQ_HEAD_INITIALIZER(rte_dpaa_memsegs);
 
 struct dpaa_bp_info *rte_dpaa_bpid_info;
-int dpaa_logtype_mempool;
+
+RTE_LOG_REGISTER(dpaa_logtype_mempool, mempool.dpaa, NOTICE);
 
 static int
 dpaa_mbuf_create_pool(struct rte_mempool *mp)
@@ -357,10 +358,3 @@ static const struct rte_mempool_ops dpaa_mpool_ops = {
 };
 
 MEMPOOL_REGISTER_OPS(dpaa_mpool_ops);
-
-RTE_INIT(dpaa_mp_init_log)
-{
-	dpaa_logtype_mempool = rte_log_register("mempool.dpaa");
-	if (dpaa_logtype_mempool >= 0)
-		rte_log_set_level(dpaa_logtype_mempool, RTE_LOG_NOTICE);
-}
diff --git a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
index fa9b53e64..97ce08d78 100644
--- a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
+++ b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
@@ -36,9 +36,6 @@
 struct dpaa2_bp_info *rte_dpaa2_bpid_info;
 static struct dpaa2_bp_list *h_bp_list;
 
-/* Dynamic logging identified for mempool */
-int dpaa2_logtype_mempool;
-
 static int
 rte_hw_mbuf_create_pool(struct rte_mempool *mp)
 {
@@ -454,9 +451,4 @@ static const struct rte_mempool_ops dpaa2_mpool_ops = {
 
 MEMPOOL_REGISTER_OPS(dpaa2_mpool_ops);
 
-RTE_INIT(dpaa2_mempool_init_log)
-{
-	dpaa2_logtype_mempool = rte_log_register("mempool.dpaa2");
-	if (dpaa2_logtype_mempool >= 0)
-		rte_log_set_level(dpaa2_logtype_mempool, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa2_logtype_mempool, mempool.dpaa2, NOTICE);
diff --git a/drivers/mempool/octeontx/octeontx_fpavf.c b/drivers/mempool/octeontx/octeontx_fpavf.c
index 0ff234913..339da7824 100644
--- a/drivers/mempool/octeontx/octeontx_fpavf.c
+++ b/drivers/mempool/octeontx/octeontx_fpavf.c
@@ -105,15 +105,7 @@ struct octeontx_fpadev {
 
 static struct octeontx_fpadev fpadev;
 
-int octeontx_logtype_fpavf;
-int octeontx_logtype_fpavf_mbox;
-
-RTE_INIT(otx_pool_init_log)
-{
-	octeontx_logtype_fpavf = rte_log_register("pmd.mempool.octeontx");
-	if (octeontx_logtype_fpavf >= 0)
-		rte_log_set_level(octeontx_logtype_fpavf, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(octeontx_logtype_fpavf, pmd.mempool.octeontx, NOTICE);
 
 /* lock is taken by caller */
 static int
-- 
2.27.0


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

* [dpdk-dev] [PATCH v3 07/13] drivers/event: use log register macro
  2020-07-01  6:48   ` [dpdk-dev] [PATCH v3 00/13] rte_log registration usage improvement jerinj
                       ` (5 preceding siblings ...)
  2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 06/13] drivers/mempool: " jerinj
@ 2020-07-01  6:48     ` jerinj
  2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 08/13] drivers/crypto: " jerinj
                       ` (6 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01  6:48 UTC (permalink / raw)
  To: dev, Hemant Agrawal, Nipun Gupta, Jerin Jacob, Pavan Nikhilesh,
	Liang Ma, Peter Mccarthy, Harry van Haaren
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena, adamx.dybkowski

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/event/dpaa/dpaa_eventdev.c   |  8 +-------
 drivers/event/dpaa2/dpaa2_eventdev.c | 10 +---------
 drivers/event/octeontx/ssovf_evdev.c |  8 +-------
 drivers/event/octeontx/timvf_evdev.c |  9 +--------
 drivers/event/opdl/opdl_evdev.c      |  8 +-------
 drivers/event/opdl/opdl_ring.c       |  2 --
 drivers/event/sw/sw_evdev.c          | 11 +----------
 7 files changed, 6 insertions(+), 50 deletions(-)

diff --git a/drivers/event/dpaa/dpaa_eventdev.c b/drivers/event/dpaa/dpaa_eventdev.c
index 5a018d487..e78728b7e 100644
--- a/drivers/event/dpaa/dpaa_eventdev.c
+++ b/drivers/event/dpaa/dpaa_eventdev.c
@@ -46,7 +46,7 @@
  * Eventqueue = Channel Instance
  * 1 Eventdev can have N Eventqueue
  */
-int dpaa_logtype_eventdev;
+RTE_LOG_REGISTER(dpaa_logtype_eventdev, pmd.event.dpaa, NOTICE);
 
 #define DISABLE_INTR_MODE "disable_intr"
 
@@ -1069,9 +1069,3 @@ static struct rte_vdev_driver vdev_eventdev_dpaa_pmd = {
 RTE_PMD_REGISTER_VDEV(EVENTDEV_NAME_DPAA_PMD, vdev_eventdev_dpaa_pmd);
 RTE_PMD_REGISTER_PARAM_STRING(EVENTDEV_NAME_DPAA_PMD,
 		DISABLE_INTR_MODE "=<int>");
-RTE_INIT(dpaa_event_init_log)
-{
-	dpaa_logtype_eventdev = rte_log_register("pmd.event.dpaa");
-	if (dpaa_logtype_eventdev >= 0)
-		rte_log_set_level(dpaa_logtype_eventdev, RTE_LOG_NOTICE);
-}
diff --git a/drivers/event/dpaa2/dpaa2_eventdev.c b/drivers/event/dpaa2/dpaa2_eventdev.c
index a196ad4c6..a545baf34 100644
--- a/drivers/event/dpaa2/dpaa2_eventdev.c
+++ b/drivers/event/dpaa2/dpaa2_eventdev.c
@@ -48,8 +48,6 @@
  * Soft Event Flow is DPCI Instance
  */
 
-/* Dynamic logging identified for mempool */
-int dpaa2_logtype_event;
 #define DPAA2_EV_TX_RETRY_COUNT 10000
 
 static uint16_t
@@ -1205,10 +1203,4 @@ static struct rte_vdev_driver vdev_eventdev_dpaa2_pmd = {
 };
 
 RTE_PMD_REGISTER_VDEV(EVENTDEV_NAME_DPAA2_PMD, vdev_eventdev_dpaa2_pmd);
-
-RTE_INIT(dpaa2_eventdev_init_log)
-{
-	dpaa2_logtype_event = rte_log_register("pmd.event.dpaa2");
-	if (dpaa2_logtype_event >= 0)
-		rte_log_set_level(dpaa2_logtype_event, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa2_logtype_event, pmd.event.dpaa2, NOTICE);
diff --git a/drivers/event/octeontx/ssovf_evdev.c b/drivers/event/octeontx/ssovf_evdev.c
index 1b1a5d939..4fc4e8f7e 100644
--- a/drivers/event/octeontx/ssovf_evdev.c
+++ b/drivers/event/octeontx/ssovf_evdev.c
@@ -20,15 +20,9 @@
 #include "ssovf_evdev.h"
 #include "timvf_evdev.h"
 
-int otx_logtype_ssovf;
 static uint8_t timvf_enable_stats;
 
-RTE_INIT(otx_ssovf_init_log)
-{
-	otx_logtype_ssovf = rte_log_register("pmd.event.octeontx");
-	if (otx_logtype_ssovf >= 0)
-		rte_log_set_level(otx_logtype_ssovf, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(otx_logtype_ssovf, pmd.event.octeontx, NOTICE);
 
 /* SSOPF Mailbox messages */
 
diff --git a/drivers/event/octeontx/timvf_evdev.c b/drivers/event/octeontx/timvf_evdev.c
index caa129087..c61aacacc 100644
--- a/drivers/event/octeontx/timvf_evdev.c
+++ b/drivers/event/octeontx/timvf_evdev.c
@@ -4,14 +4,7 @@
 
 #include "timvf_evdev.h"
 
-int otx_logtype_timvf;
-
-RTE_INIT(otx_timvf_init_log)
-{
-	otx_logtype_timvf = rte_log_register("pmd.event.octeontx.timer");
-	if (otx_logtype_timvf >= 0)
-		rte_log_set_level(otx_logtype_timvf, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(otx_logtype_timvf, pmd.event.octeontx.timer, NOTICE);
 
 struct __rte_packed timvf_mbox_dev_info {
 	uint64_t ring_active[4];
diff --git a/drivers/event/opdl/opdl_evdev.c b/drivers/event/opdl/opdl_evdev.c
index 3beca8957..9b2f75fe3 100644
--- a/drivers/event/opdl/opdl_evdev.c
+++ b/drivers/event/opdl/opdl_evdev.c
@@ -754,13 +754,7 @@ static struct rte_vdev_driver evdev_opdl_pmd_drv = {
 	.remove = opdl_remove
 };
 
-RTE_INIT(opdl_init_log)
-{
-	opdl_logtype_driver = rte_log_register("pmd.event.opdl.driver");
-	if (opdl_logtype_driver >= 0)
-		rte_log_set_level(opdl_logtype_driver, RTE_LOG_INFO);
-}
-
+RTE_LOG_REGISTER(opdl_logtype_driver, pmd.event.opdl.driver, INFO);
 
 RTE_PMD_REGISTER_VDEV(EVENTDEV_NAME_OPDL_PMD, evdev_opdl_pmd_drv);
 RTE_PMD_REGISTER_PARAM_STRING(event_opdl, NUMA_NODE_ARG "=<int>"
diff --git a/drivers/event/opdl/opdl_ring.c b/drivers/event/opdl/opdl_ring.c
index c8d19fef5..69392b56b 100644
--- a/drivers/event/opdl/opdl_ring.c
+++ b/drivers/event/opdl/opdl_ring.c
@@ -31,8 +31,6 @@
 #define OPDL_OPA_MASK    (0xFF)
 #define OPDL_OPA_OFFSET  (0x38)
 
-int opdl_logtype_driver;
-
 /* Types of dependency between stages */
 enum dep_type {
 	DEP_NONE = 0,  /* no dependency */
diff --git a/drivers/event/sw/sw_evdev.c b/drivers/event/sw/sw_evdev.c
index fb8e8bebb..98dae7164 100644
--- a/drivers/event/sw/sw_evdev.c
+++ b/drivers/event/sw/sw_evdev.c
@@ -1083,13 +1083,4 @@ static struct rte_vdev_driver evdev_sw_pmd_drv = {
 RTE_PMD_REGISTER_VDEV(EVENTDEV_NAME_SW_PMD, evdev_sw_pmd_drv);
 RTE_PMD_REGISTER_PARAM_STRING(event_sw, NUMA_NODE_ARG "=<int> "
 		SCHED_QUANTA_ARG "=<int>" CREDIT_QUANTA_ARG "=<int>");
-
-/* declared extern in header, for access from other .c files */
-int eventdev_sw_log_level;
-
-RTE_INIT(evdev_sw_init_log)
-{
-	eventdev_sw_log_level = rte_log_register("pmd.event.sw");
-	if (eventdev_sw_log_level >= 0)
-		rte_log_set_level(eventdev_sw_log_level, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(eventdev_sw_log_level, pmd.event.sw, NOTICE);
-- 
2.27.0


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

* [dpdk-dev] [PATCH v3 08/13] drivers/crypto: use log register macro
  2020-07-01  6:48   ` [dpdk-dev] [PATCH v3 00/13] rte_log registration usage improvement jerinj
                       ` (6 preceding siblings ...)
  2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 07/13] drivers/event: " jerinj
@ 2020-07-01  6:48     ` jerinj
  2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 09/13] drivers/compress: " jerinj
                       ` (5 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01  6:48 UTC (permalink / raw)
  To: dev, Declan Doherty, Pablo de Lara, Gagandeep Singh,
	Hemant Agrawal, Akhil Goyal, Michael Shamis, Liron Himi,
	Nagadheeraj Rottela, Srikanth Jampala, Anoob Joseph,
	Ankur Dwivedi, Fan Zhang, Jay Zhou
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c      |  8 +---
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c    |  8 +---
 drivers/crypto/caam_jr/caam_jr.c              |  8 +---
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c   | 11 +-----
 drivers/crypto/dpaa_sec/dpaa_sec.c            | 10 +----
 drivers/crypto/kasumi/rte_kasumi_pmd.c        |  6 +--
 drivers/crypto/mvsam/rte_mrvl_pmd.c           |  7 +---
 drivers/crypto/nitrox/nitrox_logs.c           |  9 +----
 drivers/crypto/null/null_crypto_pmd.c         |  7 +---
 drivers/crypto/octeontx/otx_cryptodev.c       | 10 +----
 drivers/crypto/octeontx2/otx2_cryptodev.c     | 12 +-----
 drivers/crypto/openssl/rte_openssl_pmd.c      |  7 +---
 .../scheduler/rte_cryptodev_scheduler.c       |  8 +---
 drivers/crypto/snow3g/rte_snow3g_pmd.c        |  7 +---
 drivers/crypto/virtio/virtio_cryptodev.c      | 39 ++++---------------
 drivers/crypto/zuc/rte_zuc_pmd.c              |  7 +---
 16 files changed, 23 insertions(+), 141 deletions(-)

diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
index d213d05b9..1d2a0ce00 100644
--- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
+++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
@@ -13,8 +13,6 @@
 
 #include "aesni_gcm_pmd_private.h"
 
-int aesni_gcm_logtype_driver;
-
 static uint8_t cryptodev_driver_id;
 
 /* setup session handlers */
@@ -889,8 +887,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_AESNI_GCM_PMD,
 	"socket_id=<int>");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(aesni_gcm_crypto_drv, aesni_gcm_pmd_drv.driver,
 		cryptodev_driver_id);
-
-RTE_INIT(aesni_gcm_init_log)
-{
-	aesni_gcm_logtype_driver = rte_log_register("pmd.crypto.aesni_gcm");
-}
+RTE_LOG_REGISTER(aesni_gcm_logtype_driver, pmd.crypto.aesni_gcm, NOTICE);
diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
index 2d688f4d3..9d0d9f4d7 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
@@ -15,8 +15,6 @@
 
 #include "aesni_mb_pmd_private.h"
 
-int aesni_mb_logtype_driver;
-
 #define AES_CCM_DIGEST_MIN_LEN 4
 #define AES_CCM_DIGEST_MAX_LEN 16
 #define HMAC_MAX_BLOCK_SIZE 128
@@ -1744,8 +1742,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_AESNI_MB_PMD,
 RTE_PMD_REGISTER_CRYPTO_DRIVER(aesni_mb_crypto_drv,
 		cryptodev_aesni_mb_pmd_drv.driver,
 		cryptodev_driver_id);
-
-RTE_INIT(aesni_mb_init_log)
-{
-	aesni_mb_logtype_driver = rte_log_register("pmd.crypto.aesni_mb");
-}
+RTE_LOG_REGISTER(aesni_mb_logtype_driver, pmd.crypto.aesni_mb, NOTICE);
diff --git a/drivers/crypto/caam_jr/caam_jr.c b/drivers/crypto/caam_jr/caam_jr.c
index caf238677..49a35d614 100644
--- a/drivers/crypto/caam_jr/caam_jr.c
+++ b/drivers/crypto/caam_jr/caam_jr.c
@@ -35,7 +35,6 @@
 #endif
 #define CRYPTODEV_NAME_CAAM_JR_PMD	crypto_caam_jr
 static uint8_t cryptodev_driver_id;
-int caam_jr_logtype;
 
 /* Lists the states possible for the SEC user space driver. */
 enum sec_driver_state_e {
@@ -2477,9 +2476,4 @@ RTE_INIT(caam_jr_init)
 	sec_job_rings_init();
 }
 
-RTE_INIT(caam_jr_init_log)
-{
-	caam_jr_logtype = rte_log_register("pmd.crypto.caam");
-	if (caam_jr_logtype >= 0)
-		rte_log_set_level(caam_jr_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(caam_jr_logtype, pmd.crypto.caam, NOTICE);
diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index 63e7d930a..12f833136 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
@@ -58,8 +58,6 @@
 
 static uint8_t cryptodev_driver_id;
 
-int dpaa2_logtype_sec;
-
 #ifdef RTE_LIBRTE_SECURITY
 static inline int
 build_proto_compound_sg_fd(dpaa2_sec_session *sess,
@@ -3918,11 +3916,4 @@ static struct cryptodev_driver dpaa2_sec_crypto_drv;
 RTE_PMD_REGISTER_DPAA2(CRYPTODEV_NAME_DPAA2_SEC_PMD, rte_dpaa2_sec_driver);
 RTE_PMD_REGISTER_CRYPTO_DRIVER(dpaa2_sec_crypto_drv,
 		rte_dpaa2_sec_driver.driver, cryptodev_driver_id);
-
-RTE_INIT(dpaa2_sec_init_log)
-{
-	/* Bus level logs */
-	dpaa2_logtype_sec = rte_log_register("pmd.crypto.dpaa2");
-	if (dpaa2_logtype_sec >= 0)
-		rte_log_set_level(dpaa2_logtype_sec, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa2_logtype_sec, pmd.crypto.dpaa2, NOTICE);
diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c
index 66ee0ba0c..d9fa8bb36 100644
--- a/drivers/crypto/dpaa_sec/dpaa_sec.c
+++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
@@ -43,8 +43,6 @@
 #include <dpaa_sec_log.h>
 #include <dpaax_iova_table.h>
 
-int dpaa_logtype_sec;
-
 static uint8_t cryptodev_driver_id;
 
 static __thread struct rte_crypto_op **dpaa_sec_ops;
@@ -3520,10 +3518,4 @@ static struct cryptodev_driver dpaa_sec_crypto_drv;
 RTE_PMD_REGISTER_DPAA(CRYPTODEV_NAME_DPAA_SEC_PMD, rte_dpaa_sec_driver);
 RTE_PMD_REGISTER_CRYPTO_DRIVER(dpaa_sec_crypto_drv, rte_dpaa_sec_driver.driver,
 		cryptodev_driver_id);
-
-RTE_INIT(dpaa_sec_init_log)
-{
-	dpaa_logtype_sec = rte_log_register("pmd.crypto.dpaa");
-	if (dpaa_logtype_sec >= 0)
-		rte_log_set_level(dpaa_logtype_sec, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa_logtype_sec, pmd.crypto.dpaa, NOTICE);
diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd.c b/drivers/crypto/kasumi/rte_kasumi_pmd.c
index 73077e3d9..c3f0dfc2f 100644
--- a/drivers/crypto/kasumi/rte_kasumi_pmd.c
+++ b/drivers/crypto/kasumi/rte_kasumi_pmd.c
@@ -17,7 +17,6 @@
 #define KASUMI_MAX_BURST 4
 #define BYTE_LEN 8
 
-int kasumi_logtype_driver;
 static uint8_t cryptodev_driver_id;
 
 /** Get xform chain order. */
@@ -639,7 +638,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_KASUMI_PMD,
 RTE_PMD_REGISTER_CRYPTO_DRIVER(kasumi_crypto_drv,
 		cryptodev_kasumi_pmd_drv.driver, cryptodev_driver_id);
 
-RTE_INIT(kasumi_init_log)
-{
-	kasumi_logtype_driver = rte_log_register("pmd.crypto.kasumi");
-}
+RTE_LOG_REGISTER(kasumi_logtype_driver, pmd.crypto.kasumi, NOTICE);
diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd.c b/drivers/crypto/mvsam/rte_mrvl_pmd.c
index 63782ce97..aaa40dced 100644
--- a/drivers/crypto/mvsam/rte_mrvl_pmd.c
+++ b/drivers/crypto/mvsam/rte_mrvl_pmd.c
@@ -19,7 +19,6 @@
 #define MRVL_PMD_MAX_NB_SESS_ARG		("max_nb_sessions")
 #define MRVL_PMD_DEFAULT_MAX_NB_SESSIONS	2048
 
-int mrvl_logtype_driver;
 static uint8_t cryptodev_driver_id;
 
 struct mrvl_pmd_init_params {
@@ -1020,8 +1019,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_MRVL_PMD,
 	"socket_id=<int>");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(mrvl_crypto_drv, cryptodev_mrvl_pmd_drv.driver,
 		cryptodev_driver_id);
-
-RTE_INIT(crypto_mrvl_init_log)
-{
-	mrvl_logtype_driver = rte_log_register("pmd.crypto.mvsam");
-}
+RTE_LOG_REGISTER(mrvl_logtype_driver, pmd.crypto.mvsam, NOTICE);
diff --git a/drivers/crypto/nitrox/nitrox_logs.c b/drivers/crypto/nitrox/nitrox_logs.c
index 007056cb4..26395159a 100644
--- a/drivers/crypto/nitrox/nitrox_logs.c
+++ b/drivers/crypto/nitrox/nitrox_logs.c
@@ -4,11 +4,4 @@
 
 #include <rte_log.h>
 
-int nitrox_logtype;
-
-RTE_INIT(nitrox_init_log)
-{
-	nitrox_logtype = rte_log_register("pmd.crypto.nitrox");
-	if (nitrox_logtype >= 0)
-		rte_log_set_level(nitrox_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(nitrox_logtype, pmd.crypto.nitrox, NOTICE);
diff --git a/drivers/crypto/null/null_crypto_pmd.c b/drivers/crypto/null/null_crypto_pmd.c
index 7b0b9d42b..e04042e75 100644
--- a/drivers/crypto/null/null_crypto_pmd.c
+++ b/drivers/crypto/null/null_crypto_pmd.c
@@ -10,7 +10,6 @@
 #include "null_crypto_pmd_private.h"
 
 static uint8_t cryptodev_driver_id;
-int null_logtype_driver;
 
 /** verify and set session parameters */
 int
@@ -249,8 +248,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_NULL_PMD,
 	"socket_id=<int>");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(null_crypto_drv, cryptodev_null_pmd_drv.driver,
 		cryptodev_driver_id);
-
-RTE_INIT(null_init_log)
-{
-	null_logtype_driver = rte_log_register("pmd.crypto.null");
-}
+RTE_LOG_REGISTER(null_logtype_driver, pmd.crypto.null, INFO);
diff --git a/drivers/crypto/octeontx/otx_cryptodev.c b/drivers/crypto/octeontx/otx_cryptodev.c
index ddece1311..5ce1cf82f 100644
--- a/drivers/crypto/octeontx/otx_cryptodev.c
+++ b/drivers/crypto/octeontx/otx_cryptodev.c
@@ -15,7 +15,6 @@
 #include "cpt_pmd_logs.h"
 
 uint8_t otx_cryptodev_driver_id;
-int otx_cpt_logtype;
 
 static struct rte_pci_id pci_id_cpt_table[] = {
 	{
@@ -112,11 +111,4 @@ RTE_PMD_REGISTER_PCI_TABLE(CRYPTODEV_NAME_OCTEONTX_PMD, pci_id_cpt_table);
 RTE_PMD_REGISTER_KMOD_DEP(CRYPTODEV_NAME_OCTEONTX_PMD, "vfio-pci");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(otx_cryptodev_drv, otx_cryptodev_pmd.driver,
 		otx_cryptodev_driver_id);
-
-RTE_INIT(otx_cpt_init_log)
-{
-	/* Bus level logs */
-	otx_cpt_logtype = rte_log_register("pmd.crypto.octeontx");
-	if (otx_cpt_logtype >= 0)
-		rte_log_set_level(otx_cpt_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(otx_cpt_logtype, pmd.crypto.octeontx, NOTICE);
diff --git a/drivers/crypto/octeontx2/otx2_cryptodev.c b/drivers/crypto/octeontx2/otx2_cryptodev.c
index 6ffbc2eb7..50cbb13d8 100644
--- a/drivers/crypto/octeontx2/otx2_cryptodev.c
+++ b/drivers/crypto/octeontx2/otx2_cryptodev.c
@@ -22,8 +22,6 @@
 #include "cpt_common.h"
 #include "cpt_pmd_logs.h"
 
-int otx2_cpt_logtype;
-
 uint8_t otx2_cryptodev_driver_id;
 
 static struct rte_pci_id pci_id_cpt_table[] = {
@@ -146,17 +144,9 @@ static struct rte_pci_driver otx2_cryptodev_pmd = {
 
 static struct cryptodev_driver otx2_cryptodev_drv;
 
-RTE_INIT(otx2_cpt_init_log);
 RTE_PMD_REGISTER_PCI(CRYPTODEV_NAME_OCTEONTX2_PMD, otx2_cryptodev_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(CRYPTODEV_NAME_OCTEONTX2_PMD, pci_id_cpt_table);
 RTE_PMD_REGISTER_KMOD_DEP(CRYPTODEV_NAME_OCTEONTX2_PMD, "vfio-pci");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(otx2_cryptodev_drv, otx2_cryptodev_pmd.driver,
 		otx2_cryptodev_driver_id);
-
-RTE_INIT(otx2_cpt_init_log)
-{
-	/* Bus level logs */
-	otx2_cpt_logtype = rte_log_register("pmd.crypto.octeontx2");
-	if (otx2_cpt_logtype >= 0)
-		rte_log_set_level(otx2_cpt_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(otx2_cpt_logtype, pmd.crypto.octeontx2, NOTICE);
diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c
index bb9fb877a..7d3959f55 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd.c
@@ -18,7 +18,6 @@
 
 #define DES_BLOCK_SIZE 8
 
-int openssl_logtype_driver;
 static uint8_t cryptodev_driver_id;
 
 #if (OPENSSL_VERSION_NUMBER < 0x10100000L)
@@ -2279,8 +2278,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_OPENSSL_PMD,
 	"socket_id=<int>");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(openssl_crypto_drv,
 		cryptodev_openssl_pmd_drv.driver, cryptodev_driver_id);
-
-RTE_INIT(openssl_init_log)
-{
-	openssl_logtype_driver = rte_log_register("pmd.crypto.openssl");
-}
+RTE_LOG_REGISTER(openssl_logtype_driver, pmd.crypto.openssl, INFO);
diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
index 1fef88f11..730504dab 100644
--- a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
+++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
@@ -10,8 +10,6 @@
 #include "rte_cryptodev_scheduler.h"
 #include "scheduler_pmd_private.h"
 
-int scheduler_logtype_driver;
-
 /** update the scheduler pmd's capability with attaching device's
  *  capability.
  *  For each device to be attached, the scheduler's capability should be
@@ -578,7 +576,5 @@ rte_cryptodev_scheduler_option_get(uint8_t scheduler_id,
 	return (*sched_ctx->ops.option_get)(dev, option_type, option);
 }
 
-RTE_INIT(scheduler_init_log)
-{
-	scheduler_logtype_driver = rte_log_register("pmd.crypto.scheduler");
-}
+
+RTE_LOG_REGISTER(scheduler_logtype_driver, pmd.crypto.scheduler, INFO);
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index c939064d5..558e01e70 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -16,7 +16,6 @@
 #define SNOW3G_MAX_BURST 8
 #define BYTE_LEN 8
 
-int snow3g_logtype_driver;
 static uint8_t cryptodev_driver_id;
 
 /** Get xform chain order. */
@@ -653,8 +652,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_SNOW3G_PMD,
 	"socket_id=<int>");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(snow3g_crypto_drv,
 		cryptodev_snow3g_pmd_drv.driver, cryptodev_driver_id);
-
-RTE_INIT(snow3g_init_log)
-{
-	snow3g_logtype_driver = rte_log_register("pmd.crypto.snow3g");
-}
+RTE_LOG_REGISTER(snow3g_logtype_driver, pmd.crypto.snow3g, INFO);
diff --git a/drivers/crypto/virtio/virtio_cryptodev.c b/drivers/crypto/virtio/virtio_cryptodev.c
index cdf43b0e0..31a5f1072 100644
--- a/drivers/crypto/virtio/virtio_cryptodev.c
+++ b/drivers/crypto/virtio/virtio_cryptodev.c
@@ -17,12 +17,6 @@
 #include "virtio_crypto_algs.h"
 #include "virtio_crypto_capabilities.h"
 
-int virtio_crypto_logtype_init;
-int virtio_crypto_logtype_session;
-int virtio_crypto_logtype_rx;
-int virtio_crypto_logtype_tx;
-int virtio_crypto_logtype_driver;
-
 static int virtio_crypto_dev_configure(struct rte_cryptodev *dev,
 		struct rte_cryptodev_config *config);
 static int virtio_crypto_dev_start(struct rte_cryptodev *dev);
@@ -1489,29 +1483,10 @@ RTE_PMD_REGISTER_PCI(CRYPTODEV_NAME_VIRTIO_PMD, rte_virtio_crypto_driver);
 RTE_PMD_REGISTER_CRYPTO_DRIVER(virtio_crypto_drv,
 	rte_virtio_crypto_driver.driver,
 	cryptodev_virtio_driver_id);
-
-RTE_INIT(virtio_crypto_init_log)
-{
-	virtio_crypto_logtype_init = rte_log_register("pmd.crypto.virtio.init");
-	if (virtio_crypto_logtype_init >= 0)
-		rte_log_set_level(virtio_crypto_logtype_init, RTE_LOG_NOTICE);
-
-	virtio_crypto_logtype_session =
-		rte_log_register("pmd.crypto.virtio.session");
-	if (virtio_crypto_logtype_session >= 0)
-		rte_log_set_level(virtio_crypto_logtype_session,
-				RTE_LOG_NOTICE);
-
-	virtio_crypto_logtype_rx = rte_log_register("pmd.crypto.virtio.rx");
-	if (virtio_crypto_logtype_rx >= 0)
-		rte_log_set_level(virtio_crypto_logtype_rx, RTE_LOG_NOTICE);
-
-	virtio_crypto_logtype_tx = rte_log_register("pmd.crypto.virtio.tx");
-	if (virtio_crypto_logtype_tx >= 0)
-		rte_log_set_level(virtio_crypto_logtype_tx, RTE_LOG_NOTICE);
-
-	virtio_crypto_logtype_driver =
-		rte_log_register("pmd.crypto.virtio.driver");
-	if (virtio_crypto_logtype_driver >= 0)
-		rte_log_set_level(virtio_crypto_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(virtio_crypto_logtype_init, pmd.crypto.virtio.init, NOTICE);
+RTE_LOG_REGISTER(virtio_crypto_logtype_session, pmd.crypto.virtio.session,
+		 NOTICE);
+RTE_LOG_REGISTER(virtio_crypto_logtype_rx, pmd.crypto.virtio.rx, NOTICE);
+RTE_LOG_REGISTER(virtio_crypto_logtype_tx, pmd.crypto.virtio.tx, NOTICE);
+RTE_LOG_REGISTER(virtio_crypto_logtype_driver, pmd.crypto.virtio.driver,
+		 NOTICE);
diff --git a/drivers/crypto/zuc/rte_zuc_pmd.c b/drivers/crypto/zuc/rte_zuc_pmd.c
index df8d6f6bb..20cb5a160 100644
--- a/drivers/crypto/zuc/rte_zuc_pmd.c
+++ b/drivers/crypto/zuc/rte_zuc_pmd.c
@@ -14,7 +14,6 @@
 #define ZUC_MAX_BURST 16
 #define BYTE_LEN 8
 
-int zuc_logtype_driver;
 static uint8_t cryptodev_driver_id;
 
 /** Get xform chain order. */
@@ -580,8 +579,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_ZUC_PMD,
 	"socket_id=<int>");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(zuc_crypto_drv, cryptodev_zuc_pmd_drv.driver,
 		cryptodev_driver_id);
-
-RTE_INIT(zuc_init_log)
-{
-	zuc_logtype_driver = rte_log_register("pmd.crypto.zuc");
-}
+RTE_LOG_REGISTER(zuc_logtype_driver, pmd.crypto.zuc, INFO);
-- 
2.27.0


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

* [dpdk-dev] [PATCH v3 09/13] drivers/compress: use log register macro
  2020-07-01  6:48   ` [dpdk-dev] [PATCH v3 00/13] rte_log registration usage improvement jerinj
                       ` (7 preceding siblings ...)
  2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 08/13] drivers/crypto: " jerinj
@ 2020-07-01  6:48     ` jerinj
  2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 10/13] drivers/common: " jerinj
                       ` (4 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01  6:48 UTC (permalink / raw)
  To: dev, Lee Daly, Fiona Trahe, Ashish Gupta, Sunila Sahu
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/compress/isal/isal_compress_pmd.c | 10 +---------
 drivers/compress/octeontx/otx_zip_pmd.c   | 10 +---------
 drivers/compress/zlib/zlib_pmd.c          | 10 +---------
 3 files changed, 3 insertions(+), 27 deletions(-)

diff --git a/drivers/compress/isal/isal_compress_pmd.c b/drivers/compress/isal/isal_compress_pmd.c
index 7d2b05c91..0ecca12a8 100644
--- a/drivers/compress/isal/isal_compress_pmd.c
+++ b/drivers/compress/isal/isal_compress_pmd.c
@@ -25,8 +25,6 @@
 #define ISAL_VERSION_STRING \
 	ISAL_TOSTRING(ISAL_MAJOR_VERSION, ISAL_MINOR_VERSION, ISAL_PATCH_VERSION)
 
-int isal_logtype_driver;
-
 /* Verify and set private xform parameters */
 int
 isal_comp_set_priv_xform_parameters(struct isal_priv_xform *priv_xform,
@@ -752,10 +750,4 @@ static struct rte_vdev_driver compdev_isal_pmd_drv = {
 RTE_PMD_REGISTER_VDEV(COMPDEV_NAME_ISAL_PMD, compdev_isal_pmd_drv);
 RTE_PMD_REGISTER_PARAM_STRING(COMPDEV_NAME_ISAL_PMD,
 	"socket_id=<int>");
-
-RTE_INIT(isal_init_log)
-{
-	isal_logtype_driver = rte_log_register("pmd.compress.isal");
-	if (isal_logtype_driver >= 0)
-		rte_log_set_level(isal_logtype_driver, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(isal_logtype_driver, pmd.compress.isal, INFO);
diff --git a/drivers/compress/octeontx/otx_zip_pmd.c b/drivers/compress/octeontx/otx_zip_pmd.c
index bff8ef035..bee90fc7c 100644
--- a/drivers/compress/octeontx/otx_zip_pmd.c
+++ b/drivers/compress/octeontx/otx_zip_pmd.c
@@ -11,8 +11,6 @@
 
 #include "otx_zip.h"
 
-int octtx_zip_logtype_driver;
-
 static const struct rte_compressdev_capabilities
 				octtx_zip_pmd_capabilities[] = {
 	{	.algo = RTE_COMP_ALGO_DEFLATE,
@@ -648,10 +646,4 @@ static struct rte_pci_driver octtx_zip_pmd = {
 
 RTE_PMD_REGISTER_PCI(COMPRESSDEV_NAME_ZIP_PMD, octtx_zip_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(COMPRESSDEV_NAME_ZIP_PMD, pci_id_octtx_zipvf_table);
-
-RTE_INIT(octtx_zip_init_log)
-{
-	octtx_zip_logtype_driver = rte_log_register("pmd.compress.octeontx");
-	if (octtx_zip_logtype_driver >= 0)
-		rte_log_set_level(octtx_zip_logtype_driver, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(octtx_zip_logtype_driver, pmd.compress.octeontx, INFO);
diff --git a/drivers/compress/zlib/zlib_pmd.c b/drivers/compress/zlib/zlib_pmd.c
index e39be2ed8..8a79d15c9 100644
--- a/drivers/compress/zlib/zlib_pmd.c
+++ b/drivers/compress/zlib/zlib_pmd.c
@@ -7,8 +7,6 @@
 
 #include "zlib_pmd_private.h"
 
-int zlib_logtype_driver;
-
 /** Compute next mbuf in the list, assign data buffer and length,
  *  returns 0 if mbuf is NULL
  */
@@ -428,10 +426,4 @@ static struct rte_vdev_driver zlib_pmd_drv = {
 };
 
 RTE_PMD_REGISTER_VDEV(COMPRESSDEV_NAME_ZLIB_PMD, zlib_pmd_drv);
-
-RTE_INIT(zlib_init_log)
-{
-	zlib_logtype_driver = rte_log_register("pmd.compress.zlib");
-	if (zlib_logtype_driver >= 0)
-		rte_log_set_level(zlib_logtype_driver, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(zlib_logtype_driver, pmd.compress.zlib, INFO);
-- 
2.27.0


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

* [dpdk-dev] [PATCH v3 10/13] drivers/common: use log register macro
  2020-07-01  6:48   ` [dpdk-dev] [PATCH v3 00/13] rte_log registration usage improvement jerinj
                       ` (8 preceding siblings ...)
  2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 09/13] drivers/compress: " jerinj
@ 2020-07-01  6:48     ` jerinj
  2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 11/13] drivers/bus: " jerinj
                       ` (3 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01  6:48 UTC (permalink / raw)
  To: dev, Hemant Agrawal, Sachin Saxena, Jingjing Wu, Beilei Xing,
	Harman Kalra, Jerin Jacob, Nithin Dabilpuram, John Griffin,
	Fiona Trahe, Deepak Kumar Jain
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena, adamx.dybkowski

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Sachin Saxena <sachin.saxena@oss.nxp.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/common/dpaax/dpaax_iova_table.c | 10 +--
 drivers/common/iavf/iavf_impl.c         |  9 +--
 drivers/common/octeontx/octeontx_mbox.c |  9 +--
 drivers/common/octeontx2/otx2_common.c  | 96 +++----------------------
 drivers/common/qat/qat_logs.c           | 17 +----
 5 files changed, 15 insertions(+), 126 deletions(-)

diff --git a/drivers/common/dpaax/dpaax_iova_table.c b/drivers/common/dpaax/dpaax_iova_table.c
index 98b076e09..5ba8ed193 100644
--- a/drivers/common/dpaax/dpaax_iova_table.c
+++ b/drivers/common/dpaax/dpaax_iova_table.c
@@ -7,9 +7,6 @@
 #include "dpaax_iova_table.h"
 #include "dpaax_logs.h"
 
-/* Global dpaax logger identifier */
-int dpaax_logger;
-
 /* Global table reference */
 struct dpaax_iova_table *dpaax_iova_table_p;
 
@@ -463,9 +460,4 @@ dpaax_handle_memevents(void)
 					       dpaax_memevent_cb, NULL);
 }
 
-RTE_INIT(dpaax_log)
-{
-	dpaax_logger = rte_log_register("pmd.common.dpaax");
-	if (dpaax_logger >= 0)
-		rte_log_set_level(dpaax_logger, RTE_LOG_ERR);
-}
+RTE_LOG_REGISTER(dpaax_logger, pmd.common.dpaax, ERR);
diff --git a/drivers/common/iavf/iavf_impl.c b/drivers/common/iavf/iavf_impl.c
index 6174a9144..fc0da3175 100644
--- a/drivers/common/iavf/iavf_impl.c
+++ b/drivers/common/iavf/iavf_impl.c
@@ -13,8 +13,6 @@
 #include "iavf_type.h"
 #include "iavf_prototype.h"
 
-int iavf_common_logger;
-
 enum iavf_status
 iavf_allocate_dma_mem_d(__rte_unused struct iavf_hw *hw,
 			struct iavf_dma_mem *mem,
@@ -87,9 +85,4 @@ iavf_free_virt_mem_d(__rte_unused struct iavf_hw *hw,
 	return IAVF_SUCCESS;
 }
 
-RTE_INIT(iavf_common_init_log)
-{
-	iavf_common_logger = rte_log_register("pmd.common.iavf");
-	if (iavf_common_logger >= 0)
-		rte_log_set_level(iavf_common_logger, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(iavf_common_logger, pmd.common.iavf, NOTICE);
diff --git a/drivers/common/octeontx/octeontx_mbox.c b/drivers/common/octeontx/octeontx_mbox.c
index effe0b267..f414267e4 100644
--- a/drivers/common/octeontx/octeontx_mbox.c
+++ b/drivers/common/octeontx/octeontx_mbox.c
@@ -68,14 +68,7 @@ struct mbox_intf_ver {
 	uint32_t minor:10;
 };
 
-int octeontx_logtype_mbox;
-
-RTE_INIT(otx_init_log)
-{
-	octeontx_logtype_mbox = rte_log_register("pmd.octeontx.mbox");
-	if (octeontx_logtype_mbox >= 0)
-		rte_log_set_level(octeontx_logtype_mbox, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(octeontx_logtype_mbox, pmd.octeontx.mbox, NOTICE);
 
 static inline void
 mbox_msgcpy(volatile uint8_t *d, volatile const uint8_t *s, uint16_t size)
diff --git a/drivers/common/octeontx2/otx2_common.c b/drivers/common/octeontx2/otx2_common.c
index 5e7272f69..b292e999a 100644
--- a/drivers/common/octeontx2/otx2_common.c
+++ b/drivers/common/octeontx2/otx2_common.c
@@ -203,89 +203,13 @@ void otx2_parse_common_devargs(struct rte_kvargs *kvlist)
 	idev->npa_lock_mask = npa_lock_mask;
 }
 
-/**
- * @internal
- */
-int otx2_logtype_base;
-/**
- * @internal
- */
-int otx2_logtype_mbox;
-/**
- * @internal
- */
-int otx2_logtype_npa;
-/**
- * @internal
- */
-int otx2_logtype_nix;
-/**
- * @internal
- */
-int otx2_logtype_npc;
-/**
- * @internal
- */
-int otx2_logtype_tm;
-/**
- * @internal
- */
-int otx2_logtype_sso;
-/**
- * @internal
- */
-int otx2_logtype_tim;
-/**
- * @internal
- */
-int otx2_logtype_dpi;
-/**
- * @internal
- */
-int otx2_logtype_ep;
-
-RTE_INIT(otx2_log_init);
-static void
-otx2_log_init(void)
-{
-	otx2_logtype_base = rte_log_register("pmd.octeontx2.base");
-	if (otx2_logtype_base >= 0)
-		rte_log_set_level(otx2_logtype_base, RTE_LOG_NOTICE);
-
-	otx2_logtype_mbox = rte_log_register("pmd.octeontx2.mbox");
-	if (otx2_logtype_mbox >= 0)
-		rte_log_set_level(otx2_logtype_mbox, RTE_LOG_NOTICE);
-
-	otx2_logtype_npa = rte_log_register("pmd.mempool.octeontx2");
-	if (otx2_logtype_npa >= 0)
-		rte_log_set_level(otx2_logtype_npa, RTE_LOG_NOTICE);
-
-	otx2_logtype_nix = rte_log_register("pmd.net.octeontx2");
-	if (otx2_logtype_nix >= 0)
-		rte_log_set_level(otx2_logtype_nix, RTE_LOG_NOTICE);
-
-	otx2_logtype_npc = rte_log_register("pmd.net.octeontx2.flow");
-	if (otx2_logtype_npc >= 0)
-		rte_log_set_level(otx2_logtype_npc, RTE_LOG_NOTICE);
-
-	otx2_logtype_tm = rte_log_register("pmd.net.octeontx2.tm");
-	if (otx2_logtype_tm >= 0)
-		rte_log_set_level(otx2_logtype_tm, RTE_LOG_NOTICE);
-
-	otx2_logtype_sso = rte_log_register("pmd.event.octeontx2");
-	if (otx2_logtype_sso >= 0)
-		rte_log_set_level(otx2_logtype_sso, RTE_LOG_NOTICE);
-
-	otx2_logtype_tim = rte_log_register("pmd.event.octeontx2.timer");
-	if (otx2_logtype_tim >= 0)
-		rte_log_set_level(otx2_logtype_tim, RTE_LOG_NOTICE);
-
-	otx2_logtype_dpi = rte_log_register("pmd.raw.octeontx2.dpi");
-	if (otx2_logtype_dpi >= 0)
-		rte_log_set_level(otx2_logtype_dpi, RTE_LOG_NOTICE);
-
-	otx2_logtype_ep = rte_log_register("pmd.raw.octeontx2.ep");
-	if (otx2_logtype_ep >= 0)
-		rte_log_set_level(otx2_logtype_ep, RTE_LOG_NOTICE);
-
-}
+RTE_LOG_REGISTER(otx2_logtype_base, pmd.octeontx2.base, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_mbox, pmd.octeontx2.mbox, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_npa, pmd.mempool.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_nix, pmd.net.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_npc, pmd.net.octeontx2.flow, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_tm, pmd.net.octeontx2.tm, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_sso, pmd.event.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_tim, pmd.event.octeontx2.timer, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_dpi, pmd.raw.octeontx2.dpi, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_ep, pmd.raw.octeontx2.ep, NOTICE);
diff --git a/drivers/common/qat/qat_logs.c b/drivers/common/qat/qat_logs.c
index dfd0cbe5d..fa48be53c 100644
--- a/drivers/common/qat/qat_logs.c
+++ b/drivers/common/qat/qat_logs.c
@@ -7,9 +7,6 @@
 
 #include "qat_logs.h"
 
-int qat_gen_logtype;
-int qat_dp_logtype;
-
 int
 qat_hexdump_log(uint32_t level, uint32_t logtype, const char *title,
 		const void *buf, unsigned int len)
@@ -20,15 +17,5 @@ qat_hexdump_log(uint32_t level, uint32_t logtype, const char *title,
 	return 0;
 }
 
-RTE_INIT(qat_pci_init_log)
-{
-	/* Non-data-path logging for pci device and all services */
-	qat_gen_logtype = rte_log_register("pmd.qat_general");
-	if (qat_gen_logtype >= 0)
-		rte_log_set_level(qat_gen_logtype, RTE_LOG_NOTICE);
-
-	/* data-path logging for all services */
-	qat_dp_logtype = rte_log_register("pmd.qat_dp");
-	if (qat_dp_logtype >= 0)
-		rte_log_set_level(qat_dp_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(qat_gen_logtype, pmd.qat_general, NOTICE);
+RTE_LOG_REGISTER(qat_dp_logtype, pmd.qat_dp, NOTICE);
-- 
2.27.0


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

* [dpdk-dev]  [PATCH v3 11/13] drivers/bus: use log register macro
  2020-07-01  6:48   ` [dpdk-dev] [PATCH v3 00/13] rte_log registration usage improvement jerinj
                       ` (9 preceding siblings ...)
  2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 10/13] drivers/common: " jerinj
@ 2020-07-01  6:48     ` jerinj
  2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 12/13] drivers/baseband: " jerinj
                       ` (2 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01  6:48 UTC (permalink / raw)
  To: dev, Hemant Agrawal, Sachin Saxena, Rosen Xu, Stephen Hemminger
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Sachin Saxena <sachin.saxena@oss.nxp.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/bus/dpaa/dpaa_bus.c      | 10 +---------
 drivers/bus/fslmc/fslmc_bus.c    | 11 +----------
 drivers/bus/ifpga/ifpga_bus.c    |  9 +--------
 drivers/bus/vdev/vdev.c          | 10 +---------
 drivers/bus/vmbus/vmbus_common.c |  9 +--------
 5 files changed, 5 insertions(+), 44 deletions(-)

diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c
index d53fe6083..0d8b13e5f 100644
--- a/drivers/bus/dpaa/dpaa_bus.c
+++ b/drivers/bus/dpaa/dpaa_bus.c
@@ -42,8 +42,6 @@
 #include <fsl_bman.h>
 #include <netcfg.h>
 
-int dpaa_logtype_bus;
-
 static struct rte_dpaa_bus rte_dpaa_bus;
 struct netcfg_info *dpaa_netcfg;
 
@@ -749,10 +747,4 @@ static struct rte_dpaa_bus rte_dpaa_bus = {
 };
 
 RTE_REGISTER_BUS(FSL_DPAA_BUS_NAME, rte_dpaa_bus.bus);
-
-RTE_INIT(dpaa_init_log)
-{
-	dpaa_logtype_bus = rte_log_register("bus.dpaa");
-	if (dpaa_logtype_bus >= 0)
-		rte_log_set_level(dpaa_logtype_bus, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa_logtype_bus, bus.dpaa, NOTICE);
diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
index afbd82e8d..d9f403bd9 100644
--- a/drivers/bus/fslmc/fslmc_bus.c
+++ b/drivers/bus/fslmc/fslmc_bus.c
@@ -21,8 +21,6 @@
 
 #include <dpaax_iova_table.h>
 
-int dpaa2_logtype_bus;
-
 #define VFIO_IOMMU_GROUP_PATH "/sys/kernel/iommu_groups"
 #define FSLMC_BUS_NAME	fslmc
 
@@ -649,11 +647,4 @@ struct rte_fslmc_bus rte_fslmc_bus = {
 };
 
 RTE_REGISTER_BUS(FSLMC_BUS_NAME, rte_fslmc_bus.bus);
-
-RTE_INIT(fslmc_init_log)
-{
-	/* Bus level logs */
-	dpaa2_logtype_bus = rte_log_register("bus.fslmc");
-	if (dpaa2_logtype_bus >= 0)
-		rte_log_set_level(dpaa2_logtype_bus, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa2_logtype_bus, bus.fslmc, NOTICE);
diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c
index addbc3e86..103915d43 100644
--- a/drivers/bus/ifpga/ifpga_bus.c
+++ b/drivers/bus/ifpga/ifpga_bus.c
@@ -32,7 +32,6 @@
 #include "ifpga_logs.h"
 #include "ifpga_common.h"
 
-int ifpga_bus_logtype;
 
 /* Forward declaration to access Intel FPGA bus
  * on which iFPGA devices are connected
@@ -474,10 +473,4 @@ static struct rte_bus rte_ifpga_bus = {
 };
 
 RTE_REGISTER_BUS(IFPGA_BUS_NAME, rte_ifpga_bus);
-
-RTE_INIT(ifpga_init_log)
-{
-	ifpga_bus_logtype = rte_log_register("bus.ifpga");
-	if (ifpga_bus_logtype >= 0)
-		rte_log_set_level(ifpga_bus_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(ifpga_bus_logtype, bus.ifpga, NOTICE);
diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index a89ea2353..d746149a2 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -27,8 +27,6 @@
 
 #define VDEV_MP_KEY	"bus_vdev_mp"
 
-int vdev_logtype_bus;
-
 /* Forward declare to access virtual bus name */
 static struct rte_bus rte_vdev_bus;
 
@@ -557,10 +555,4 @@ static struct rte_bus rte_vdev_bus = {
 };
 
 RTE_REGISTER_BUS(vdev, rte_vdev_bus);
-
-RTE_INIT(vdev_init_log)
-{
-	vdev_logtype_bus = rte_log_register("bus.vdev");
-	if (vdev_logtype_bus >= 0)
-		rte_log_set_level(vdev_logtype_bus, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(vdev_logtype_bus, bus.vdev, NOTICE);
diff --git a/drivers/bus/vmbus/vmbus_common.c b/drivers/bus/vmbus/vmbus_common.c
index 3adef01c9..4c9ac33ac 100644
--- a/drivers/bus/vmbus/vmbus_common.c
+++ b/drivers/bus/vmbus/vmbus_common.c
@@ -22,7 +22,6 @@
 
 #include "private.h"
 
-int vmbus_logtype_bus;
 extern struct rte_vmbus_bus rte_vmbus_bus;
 
 /* map a particular resource from a file */
@@ -298,10 +297,4 @@ struct rte_vmbus_bus rte_vmbus_bus = {
 };
 
 RTE_REGISTER_BUS(vmbus, rte_vmbus_bus.bus);
-
-RTE_INIT(vmbus_init_log)
-{
-	vmbus_logtype_bus = rte_log_register("bus.vmbus");
-	if (vmbus_logtype_bus >= 0)
-		rte_log_set_level(vmbus_logtype_bus, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(vmbus_logtype_bus, bus.vmbus, NOTICE);
-- 
2.27.0


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

* [dpdk-dev] [PATCH v3 12/13] drivers/baseband: use log register macro
  2020-07-01  6:48   ` [dpdk-dev] [PATCH v3 00/13] rte_log registration usage improvement jerinj
                       ` (10 preceding siblings ...)
  2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 11/13] drivers/bus: " jerinj
@ 2020-07-01  6:48     ` jerinj
  2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 13/13] app/test: " jerinj
  2020-07-01 10:44     ` [dpdk-dev] [PATCH v4 00/13] rte_log registration usage improvement jerinj
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01  6:48 UTC (permalink / raw)
  To: dev, Nicolas Chautru
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 .../baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 17 +++++------------
 drivers/baseband/fpga_lte_fec/fpga_lte_fec.c   | 18 +++++-------------
 drivers/baseband/null/bbdev_null.c             |  9 +--------
 .../baseband/turbo_sw/bbdev_turbo_software.c   |  9 +--------
 4 files changed, 12 insertions(+), 41 deletions(-)

diff --git a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
index e152b206e..aca0ca999 100644
--- a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
+++ b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
@@ -23,8 +23,11 @@
 #include "fpga_5gnr_fec.h"
 #include "rte_pmd_fpga_5gnr_fec.h"
 
-/* 5GNR SW PMD logging ID */
-static int fpga_5gnr_fec_logtype;
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+RTE_LOG_REGISTER(fpga_5gnr_fec_logtype, pmd.bb.fpga_5gnr_fec, DEBUG);
+#else
+RTE_LOG_REGISTER(fpga_5gnr_fec_logtype, pmd.bb.fpga_5gnr_fec, NOTICE);
+#endif
 
 #ifdef RTE_LIBRTE_BBDEV_DEBUG
 
@@ -2175,13 +2178,3 @@ RTE_PMD_REGISTER_PCI(FPGA_5GNR_FEC_VF_DRIVER_NAME, fpga_5gnr_fec_pci_vf_driver);
 RTE_PMD_REGISTER_PCI_TABLE(FPGA_5GNR_FEC_VF_DRIVER_NAME,
 		pci_id_fpga_5gnr_fec_vf_map);
 
-RTE_INIT(fpga_5gnr_fec_init_log)
-{
-	fpga_5gnr_fec_logtype = rte_log_register("pmd.bb.fpga_5gnr_fec");
-	if (fpga_5gnr_fec_logtype >= 0)
-#ifdef RTE_LIBRTE_BBDEV_DEBUG
-		rte_log_set_level(fpga_5gnr_fec_logtype, RTE_LOG_DEBUG);
-#else
-		rte_log_set_level(fpga_5gnr_fec_logtype, RTE_LOG_NOTICE);
-#endif
-}
diff --git a/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c b/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c
index abc5a1bf6..6be9131e7 100644
--- a/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c
+++ b/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c
@@ -22,8 +22,11 @@
 
 #include "fpga_lte_fec.h"
 
-/* Turbo SW PMD logging ID */
-static int fpga_lte_fec_logtype;
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+RTE_LOG_REGISTER(fpga_lte_fec_logtype, pmd.bb.fpga_lte_fec, DEBUG);
+#else
+RTE_LOG_REGISTER(fpga_lte_fec_logtype, pmd.bb.fpga_lte_fec, NOTICE);
+#endif
 
 /* Helper macro for logging */
 #define rte_bbdev_log(level, fmt, ...) \
@@ -2662,14 +2665,3 @@ RTE_PMD_REGISTER_PCI_TABLE(FPGA_LTE_FEC_PF_DRIVER_NAME,
 RTE_PMD_REGISTER_PCI(FPGA_LTE_FEC_VF_DRIVER_NAME, fpga_lte_fec_pci_vf_driver);
 RTE_PMD_REGISTER_PCI_TABLE(FPGA_LTE_FEC_VF_DRIVER_NAME,
 		pci_id_fpga_lte_fec_vf_map);
-
-RTE_INIT(fpga_lte_fec_init_log)
-{
-	fpga_lte_fec_logtype = rte_log_register("pmd.bb.fpga_lte_fec");
-	if (fpga_lte_fec_logtype >= 0)
-#ifdef RTE_LIBRTE_BBDEV_DEBUG
-		rte_log_set_level(fpga_lte_fec_logtype, RTE_LOG_DEBUG);
-#else
-		rte_log_set_level(fpga_lte_fec_logtype, RTE_LOG_NOTICE);
-#endif
-}
diff --git a/drivers/baseband/null/bbdev_null.c b/drivers/baseband/null/bbdev_null.c
index 2f2515101..dd11cd31c 100644
--- a/drivers/baseband/null/bbdev_null.c
+++ b/drivers/baseband/null/bbdev_null.c
@@ -15,8 +15,7 @@
 
 #define DRIVER_NAME baseband_null
 
-/* NULL BBDev logging ID */
-static int bbdev_null_logtype;
+RTE_LOG_REGISTER(bbdev_null_logtype, pmd.bb.null, NOTICE);
 
 /* Helper macro for logging */
 #define rte_bbdev_log(level, fmt, ...) \
@@ -348,9 +347,3 @@ RTE_PMD_REGISTER_PARAM_STRING(DRIVER_NAME,
 	BBDEV_NULL_SOCKET_ID_ARG"=<int>");
 RTE_PMD_REGISTER_ALIAS(DRIVER_NAME, bbdev_null);
 
-RTE_INIT(null_bbdev_init_log)
-{
-	bbdev_null_logtype = rte_log_register("pmd.bb.null");
-	if (bbdev_null_logtype >= 0)
-		rte_log_set_level(bbdev_null_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/baseband/turbo_sw/bbdev_turbo_software.c b/drivers/baseband/turbo_sw/bbdev_turbo_software.c
index bb62276b9..daecfd21a 100644
--- a/drivers/baseband/turbo_sw/bbdev_turbo_software.c
+++ b/drivers/baseband/turbo_sw/bbdev_turbo_software.c
@@ -34,8 +34,7 @@
 
 #define DRIVER_NAME baseband_turbo_sw
 
-/* Turbo SW PMD logging ID */
-static int bbdev_turbo_sw_logtype;
+RTE_LOG_REGISTER(bbdev_turbo_sw_logtype, pmd.bb.turbo_sw, NOTICE);
 
 /* Helper macro for logging */
 #define rte_bbdev_log(level, fmt, ...) \
@@ -1991,9 +1990,3 @@ RTE_PMD_REGISTER_PARAM_STRING(DRIVER_NAME,
 	TURBO_SW_SOCKET_ID_ARG"=<int>");
 RTE_PMD_REGISTER_ALIAS(DRIVER_NAME, turbo_sw);
 
-RTE_INIT(turbo_sw_bbdev_init_log)
-{
-	bbdev_turbo_sw_logtype = rte_log_register("pmd.bb.turbo_sw");
-	if (bbdev_turbo_sw_logtype >= 0)
-		rte_log_set_level(bbdev_turbo_sw_logtype, RTE_LOG_NOTICE);
-}
-- 
2.27.0


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

* [dpdk-dev]  [PATCH v3 13/13] app/test: use log register macro
  2020-07-01  6:48   ` [dpdk-dev] [PATCH v3 00/13] rte_log registration usage improvement jerinj
                       ` (11 preceding siblings ...)
  2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 12/13] drivers/baseband: " jerinj
@ 2020-07-01  6:48     ` jerinj
  2020-07-01 10:44     ` [dpdk-dev] [PATCH v4 00/13] rte_log registration usage improvement jerinj
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01  6:48 UTC (permalink / raw)
  To: dev, Byron Marohn, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Robert Sanford, Erik Gabriel Carrillo
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 app/test/test_efd.c            | 6 +-----
 app/test/test_hash.c           | 7 +------
 app/test/test_timer_racecond.c | 7 +------
 3 files changed, 3 insertions(+), 17 deletions(-)

diff --git a/app/test/test_efd.c b/app/test/test_efd.c
index e3e5e30ea..3d9aa8a57 100644
--- a/app/test/test_efd.c
+++ b/app/test/test_efd.c
@@ -32,12 +32,8 @@ struct flow_key {
 	uint8_t proto;
 } __rte_packed;
 
-int efd_logtype_test;
 
-RTE_INIT(test_efd_init_log)
-{
-	efd_logtype_test = rte_log_register("test.efd");
-}
+RTE_LOG_REGISTER(efd_logtype_test, test.efd, INFO);
 
 /*
  * Print out result of unit test efd operation.
diff --git a/app/test/test_hash.c b/app/test/test_hash.c
index afa3a1a3c..990a1815f 100644
--- a/app/test/test_hash.c
+++ b/app/test/test_hash.c
@@ -69,8 +69,6 @@ struct flow_key {
 	uint8_t proto;
 } __rte_packed;
 
-int hash_logtype_test;
-
 /*
  * Hash function that always returns the same value, to easily test what
  * happens when a bucket is full.
@@ -82,10 +80,7 @@ static uint32_t pseudo_hash(__rte_unused const void *keys,
 	return 3;
 }
 
-RTE_INIT(test_hash_init_log)
-{
-	hash_logtype_test = rte_log_register("test.hash");
-}
+RTE_LOG_REGISTER(hash_logtype_test, test.hash, INFO);
 
 /*
  * Print out result of unit test hash operation.
diff --git a/app/test/test_timer_racecond.c b/app/test/test_timer_racecond.c
index 4fc917995..28af9ca76 100644
--- a/app/test/test_timer_racecond.c
+++ b/app/test/test_timer_racecond.c
@@ -61,12 +61,7 @@ static volatile unsigned stop_slaves;
 
 static int reload_timer(struct rte_timer *tim);
 
-int timer_logtype_test;
-
-RTE_INIT(test_timer_init_log)
-{
-	timer_logtype_test = rte_log_register("test.timer");
-}
+RTE_LOG_REGISTER(timer_logtype_test, test.timer, INFO);
 
 static void
 timer_cb(struct rte_timer *tim, void *arg __rte_unused)
-- 
2.27.0


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

* [dpdk-dev] [PATCH v4 00/13] rte_log registration usage improvement
  2020-07-01  6:48   ` [dpdk-dev] [PATCH v3 00/13] rte_log registration usage improvement jerinj
                       ` (12 preceding siblings ...)
  2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 13/13] app/test: " jerinj
@ 2020-07-01 10:44     ` jerinj
  2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 01/13] eal/log: introduce log register macro jerinj
                         ` (13 more replies)
  13 siblings, 14 replies; 98+ messages in thread
From: jerinj @ 2020-07-01 10:44 UTC (permalink / raw)
  To: dev
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

This patch series improves the rte_log registration code snippet by
avoiding duplication of the code around registration by
introducing RTE_LOG_REGISTER macro.

v4:
- Fix the build issue reported at
  https://travis-ci.com/github/ovsrobot/dpdk/builds/173792541

v3:
- Fix the build issue reported at
  https://travis-ci.com/github/ovsrobot/dpdk/jobs/356167611

v2:
- RTE_LOG_REGISTER implemented using rte_log_register_type_and_pick_level()
- Added Sachin Saxena <sachin.saxena@oss.nxp.com> and  Adam Dybkowski
<adamx.dybkowski@intel.com> Acks.
- Rebase to ToT


Drivers not adapated to new macro
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I have converted all existing rte_log_register() to new macro, except
the following (as it has different usage style)
1) drivers/common/mlx5/mlx5_common.c
2) drivers/net/e1000/e1000_logs.c
3) drivers/net/sfc/sfc_ethdev.c

Example usage of new macro
~~~~~~~~~~~~~~~~~~~~~~~~~~
-/**
- * @internal
- */
-int otx2_logtype_base;
-/**
- * @internal
- */
-int otx2_logtype_mbox;
-/**
- * @internal
- */
-int otx2_logtype_npa;
-/**
- * @internal
- */
-int otx2_logtype_nix;
-/**
- * @internal
- */
-int otx2_logtype_npc;
-/**
- * @internal
- */
-int otx2_logtype_tm;
-/**
- * @internal
- */
-int otx2_logtype_sso;
-/**
- * @internal
- */
-int otx2_logtype_tim;
-/**
- * @internal
- */
-int otx2_logtype_dpi;
-/**
- * @internal
- */
-int otx2_logtype_ep;
-
-RTE_INIT(otx2_log_init);
-static void
-otx2_log_init(void)
-{
-       otx2_logtype_base = rte_log_register("pmd.octeontx2.base");
-       if (otx2_logtype_base >= 0)
-               rte_log_set_level(otx2_logtype_base, RTE_LOG_NOTICE);
-
-       otx2_logtype_mbox = rte_log_register("pmd.octeontx2.mbox");
-       if (otx2_logtype_mbox >= 0)
-               rte_log_set_level(otx2_logtype_mbox, RTE_LOG_NOTICE);
-
-       otx2_logtype_npa = rte_log_register("pmd.mempool.octeontx2");
-       if (otx2_logtype_npa >= 0)
-               rte_log_set_level(otx2_logtype_npa, RTE_LOG_NOTICE);
-
-       otx2_logtype_nix = rte_log_register("pmd.net.octeontx2");
-       if (otx2_logtype_nix >= 0)
-               rte_log_set_level(otx2_logtype_nix, RTE_LOG_NOTICE);
-
-       otx2_logtype_npc = rte_log_register("pmd.net.octeontx2.flow");
-       if (otx2_logtype_npc >= 0)
-               rte_log_set_level(otx2_logtype_npc, RTE_LOG_NOTICE);
-
-       otx2_logtype_tm = rte_log_register("pmd.net.octeontx2.tm");
-       if (otx2_logtype_tm >= 0)
-               rte_log_set_level(otx2_logtype_tm, RTE_LOG_NOTICE);
-
-       otx2_logtype_sso = rte_log_register("pmd.event.octeontx2");
-       if (otx2_logtype_sso >= 0)
-               rte_log_set_level(otx2_logtype_sso, RTE_LOG_NOTICE);
-
-       otx2_logtype_tim =
        rte_log_register("pmd.event.octeontx2.timer");
-       if (otx2_logtype_tim >= 0)
-               rte_log_set_level(otx2_logtype_tim, RTE_LOG_NOTICE);
-
-       otx2_logtype_dpi = rte_log_register("pmd.raw.octeontx2.dpi");
-       if (otx2_logtype_dpi >= 0)
-               rte_log_set_level(otx2_logtype_dpi, RTE_LOG_NOTICE);
-
-       otx2_logtype_ep = rte_log_register("pmd.raw.octeontx2.ep");
-       if (otx2_logtype_ep >= 0)
-               rte_log_set_level(otx2_logtype_ep, RTE_LOG_NOTICE);
-
-}
+RTE_LOG_REGISTER(otx2_logtype_base, pmd.octeontx2.base, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_mbox, pmd.octeontx2.mbox, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_npa, pmd.mempool.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_nix, pmd.net.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_npc, pmd.net.octeontx2.flow, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_tm, pmd.net.octeontx2.tm, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_sso, pmd.event.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_tim, pmd.event.octeontx2.timer, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_dpi, pmd.raw.octeontx2.dpi, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_ep, pmd.raw.octeontx2.ep, NOTICE);


Jerin Jacob (13):
  eal/log: introduce log register macro
  lib: use log register macro
  drivers/vdpa: use log register macro
  drivers/raw: use log register macro
  drivers/net: use log register macro
  drivers/mempool: use log register macro
  drivers/event: use log register macro
  drivers/crypto: use log register macro
  drivers/compress: use log register macro
  drivers/common: use log register macro
  drivers/bus: use log register macro
  drivers/baseband: use log register macro
  app/test: use log register macro

 app/test/test_efd.c                           |  6 +-
 app/test/test_hash.c                          |  7 +-
 app/test/test_timer_racecond.c                |  7 +-
 .../fpga_5gnr_fec/rte_fpga_5gnr_fec.c         | 17 +---
 drivers/baseband/fpga_lte_fec/fpga_lte_fec.c  | 18 +---
 drivers/baseband/null/bbdev_null.c            |  9 +-
 .../baseband/turbo_sw/bbdev_turbo_software.c  |  9 +-
 drivers/bus/dpaa/dpaa_bus.c                   | 10 +-
 drivers/bus/fslmc/fslmc_bus.c                 | 11 +--
 drivers/bus/ifpga/ifpga_bus.c                 |  9 +-
 drivers/bus/vdev/vdev.c                       | 10 +-
 drivers/bus/vmbus/vmbus_common.c              |  9 +-
 drivers/common/dpaax/dpaax_iova_table.c       | 10 +-
 drivers/common/iavf/iavf_impl.c               |  9 +-
 drivers/common/octeontx/octeontx_mbox.c       |  9 +-
 drivers/common/octeontx2/otx2_common.c        | 96 ++-----------------
 drivers/common/qat/qat_logs.c                 | 17 +---
 drivers/compress/isal/isal_compress_pmd.c     | 10 +-
 drivers/compress/octeontx/otx_zip_pmd.c       | 10 +-
 drivers/compress/zlib/zlib_pmd.c              | 10 +-
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c      |  8 +-
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c    |  8 +-
 drivers/crypto/caam_jr/caam_jr.c              |  8 +-
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c   | 11 +--
 drivers/crypto/dpaa_sec/dpaa_sec.c            | 10 +-
 drivers/crypto/kasumi/rte_kasumi_pmd.c        |  6 +-
 drivers/crypto/mvsam/rte_mrvl_pmd.c           |  7 +-
 drivers/crypto/nitrox/nitrox_logs.c           |  9 +-
 drivers/crypto/null/null_crypto_pmd.c         |  7 +-
 drivers/crypto/octeontx/otx_cryptodev.c       | 10 +-
 drivers/crypto/octeontx2/otx2_cryptodev.c     | 12 +--
 drivers/crypto/openssl/rte_openssl_pmd.c      |  7 +-
 .../scheduler/rte_cryptodev_scheduler.c       |  8 +-
 drivers/crypto/snow3g/rte_snow3g_pmd.c        |  7 +-
 drivers/crypto/virtio/virtio_cryptodev.c      | 39 ++------
 drivers/crypto/zuc/rte_zuc_pmd.c              |  7 +-
 drivers/event/dpaa/dpaa_eventdev.c            |  8 +-
 drivers/event/dpaa2/dpaa2_eventdev.c          | 10 +-
 drivers/event/octeontx/ssovf_evdev.c          |  8 +-
 drivers/event/octeontx/timvf_evdev.c          |  9 +-
 drivers/event/opdl/opdl_evdev.c               |  8 +-
 drivers/event/opdl/opdl_ring.c                |  2 -
 drivers/event/sw/sw_evdev.c                   | 11 +--
 drivers/mempool/dpaa/dpaa_mempool.c           | 10 +-
 drivers/mempool/dpaa2/dpaa2_hw_mempool.c      | 10 +-
 drivers/mempool/octeontx/octeontx_fpavf.c     | 10 +-
 drivers/net/af_packet/rte_eth_af_packet.c     |  8 +-
 drivers/net/af_xdp/rte_eth_af_xdp.c           |  8 +-
 drivers/net/ark/ark_ethdev.c                  | 10 +-
 drivers/net/atlantic/atl_ethdev.c             | 15 +--
 drivers/net/avp/avp_ethdev.c                  | 10 +-
 drivers/net/axgbe/axgbe_ethdev.c              | 15 +--
 drivers/net/bnx2x/bnx2x_ethdev.c              | 15 +--
 drivers/net/bnxt/bnxt_ethdev.c                |  9 +-
 drivers/net/bonding/rte_eth_bond_pmd.c        |  9 +-
 drivers/net/cxgbe/cxgbe_ethdev.c              | 15 +--
 drivers/net/dpaa/dpaa_ethdev.c                |  9 +-
 drivers/net/dpaa2/dpaa2_ethdev.c              |  9 +-
 drivers/net/ena/ena_ethdev.c                  | 48 ++--------
 drivers/net/enetc/enetc_ethdev.c              | 10 +-
 drivers/net/enic/enic_ethdev.c                |  9 +-
 drivers/net/failsafe/failsafe.c               | 10 +-
 drivers/net/fm10k/fm10k_ethdev.c              | 40 +-------
 drivers/net/hinic/hinic_pmd_ethdev.c          | 11 +--
 drivers/net/hns3/hns3_ethdev.c                | 15 +--
 drivers/net/i40e/i40e_ethdev.c                | 38 +-------
 drivers/net/iavf/iavf_ethdev.c                | 40 +-------
 drivers/net/ice/ice_ethdev.c                  | 38 +-------
 drivers/net/igc/igc_logs.c                    | 16 +---
 drivers/net/ionic/ionic_ethdev.c              | 10 +-
 drivers/net/ipn3ke/ipn3ke_ethdev.c            | 10 +-
 drivers/net/ixgbe/ixgbe_ethdev.c              | 39 ++------
 drivers/net/kni/rte_eth_kni.c                 |  9 +-
 drivers/net/liquidio/lio_ethdev.c             | 15 +--
 drivers/net/memif/rte_eth_memif.c             |  9 +-
 drivers/net/mlx4/mlx4.c                       | 11 +--
 drivers/net/mlx5/mlx5.c                       | 10 +-
 drivers/net/mvneta/mvneta_ethdev.c            | 10 +-
 drivers/net/mvpp2/mrvl_ethdev.c               | 10 +-
 drivers/net/netvsc/hn_ethdev.c                | 15 +--
 drivers/net/nfp/nfp_net.c                     | 15 +--
 drivers/net/null/rte_eth_null.c               |  8 +-
 drivers/net/octeontx/octeontx_ethdev.c        | 21 +---
 drivers/net/pcap/rte_eth_pcap.c               |  8 +-
 drivers/net/pfe/pfe_ethdev.c                  | 10 +-
 drivers/net/qede/qede_ethdev.c                | 16 +---
 drivers/net/ring/rte_eth_ring.c               |  8 +-
 drivers/net/softnic/rte_eth_softnic.c         | 10 +-
 drivers/net/szedata2/rte_eth_szedata2.c       | 15 +--
 drivers/net/tap/rte_eth_tap.c                 |  9 +-
 drivers/net/thunderx/nicvf_ethdev.c           | 21 +---
 drivers/net/vdev_netvsc/vdev_netvsc.c         | 13 +--
 drivers/net/vhost/rte_eth_vhost.c             |  8 +-
 drivers/net/virtio/virtio_ethdev.c            | 15 +--
 drivers/net/vmxnet3/vmxnet3_ethdev.c          | 15 +--
 drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c         | 11 +--
 drivers/raw/dpaa2_qdma/dpaa2_qdma.c           | 11 +--
 drivers/raw/ifpga/ifpga_rawdev.c              | 10 +-
 drivers/raw/ioat/ioat_rawdev.c                | 12 +--
 drivers/raw/ioat/rte_ioat_rawdev.h            |  2 -
 drivers/raw/ntb/ntb.c                         | 10 +-
 drivers/raw/skeleton/skeleton_rawdev.c        | 11 +--
 drivers/vdpa/ifc/ifcvf_vdpa.c                 | 10 +-
 drivers/vdpa/mlx5/mlx5_vdpa.c                 |  7 +-
 lib/librte_bbdev/rte_bbdev.c                  |  8 +-
 lib/librte_bpf/bpf.c                          |  9 +-
 lib/librte_cfgfile/rte_cfgfile.c              |  8 +-
 lib/librte_compressdev/rte_compressdev.c      |  7 +-
 lib/librte_compressdev/rte_compressdev_pmd.c  |  2 -
 lib/librte_eal/include/rte_log.h              | 24 +++++
 lib/librte_ethdev/rte_ethdev.c                |  9 +-
 lib/librte_eventdev/rte_event_timer_adapter.c | 21 +---
 lib/librte_flow_classify/rte_flow_classify.c  | 10 +-
 lib/librte_graph/graph.c                      |  7 +-
 lib/librte_member/rte_member.c                |  9 +-
 lib/librte_metrics/rte_metrics_telemetry.c    |  5 +-
 lib/librte_node/log.c                         |  9 +-
 lib/librte_pdump/rte_pdump.c                  |  9 +-
 lib/librte_rawdev/rte_rawdev.c                |  7 +-
 lib/librte_rcu/rte_rcu_qsbr.c                 |  9 +-
 lib/librte_stack/rte_stack.c                  |  7 +-
 lib/librte_vhost/vhost.c                      | 15 +--
 122 files changed, 228 insertions(+), 1321 deletions(-)

-- 
2.27.0


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

* [dpdk-dev] [PATCH v4 01/13] eal/log: introduce log register macro
  2020-07-01 10:44     ` [dpdk-dev] [PATCH v4 00/13] rte_log registration usage improvement jerinj
@ 2020-07-01 10:44       ` jerinj
  2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 02/13] lib: use " jerinj
                         ` (12 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01 10:44 UTC (permalink / raw)
  To: dev
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Introducing the RTE_LOG_REGISTER macro to avoid the code duplication
in the log registration process.

It is a wrapper macro for declaring the logtype, register the log and sets
it's level in the constructor context.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 lib/librte_eal/include/rte_log.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/lib/librte_eal/include/rte_log.h b/lib/librte_eal/include/rte_log.h
index 1789ede56..eaf66e4f6 100644
--- a/lib/librte_eal/include/rte_log.h
+++ b/lib/librte_eal/include/rte_log.h
@@ -376,6 +376,30 @@ int rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap)
 		 RTE_LOGTYPE_ ## t, # t ": " __VA_ARGS__) :	\
 	 0)
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Register a dynamic log type in constructor context with its name and level.
+ *
+ * It is a wrapper macro for declaring the logtype, register the log and
+ * sets it's level in the constructor context.
+ *
+ * @param type
+ *   The log type identifier
+ * @param name
+ *    Name for the log type to be registered
+ * @param level
+ *   Log level. A value between EMERG (1) and DEBUG (8).
+ */
+#define RTE_LOG_REGISTER(type, name, level)				\
+int type;								\
+RTE_INIT(__##type)							\
+{									\
+	type = rte_log_register_type_and_pick_level(RTE_STR(name),	\
+						    RTE_LOG_##level);	\
+}
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.27.0


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

* [dpdk-dev]  [PATCH v4 02/13] lib: use log register macro
  2020-07-01 10:44     ` [dpdk-dev] [PATCH v4 00/13] rte_log registration usage improvement jerinj
  2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 01/13] eal/log: introduce log register macro jerinj
@ 2020-07-01 10:44       ` jerinj
  2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 03/13] drivers/vdpa: " jerinj
                         ` (11 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01 10:44 UTC (permalink / raw)
  To: dev, Nicolas Chautru, Konstantin Ananyev, Cristian Dumitrescu,
	Fiona Trahe, Ashish Gupta, Thomas Monjalon, Ferruh Yigit,
	Andrew Rybchenko, Erik Gabriel Carrillo, Jerin Jacob,
	Bernard Iremonger, Kiran Kumar K, Nithin Dabilpuram, Yipeng Wang,
	Sameh Gobriel, Pavan Nikhilesh, Reshma Pattan, Nipun Gupta,
	Hemant Agrawal, Honnappa Nagarahalli, Gage Eads, Olivier Matz,
	Maxime Coquelin, Zhihong Wang, Xiaolong Ye
  Cc: david.marchand, sachin.saxena, adamx.dybkowski

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 lib/librte_bbdev/rte_bbdev.c                  |  8 +------
 lib/librte_bpf/bpf.c                          |  9 +-------
 lib/librte_cfgfile/rte_cfgfile.c              |  8 +------
 lib/librte_compressdev/rte_compressdev.c      |  7 +------
 lib/librte_compressdev/rte_compressdev_pmd.c  |  2 --
 lib/librte_ethdev/rte_ethdev.c                |  9 +++-----
 lib/librte_eventdev/rte_event_timer_adapter.c | 21 +++----------------
 lib/librte_flow_classify/rte_flow_classify.c  | 10 +--------
 lib/librte_graph/graph.c                      |  7 +------
 lib/librte_member/rte_member.c                |  9 +-------
 lib/librte_metrics/rte_metrics_telemetry.c    |  5 ++---
 lib/librte_node/log.c                         |  9 +-------
 lib/librte_pdump/rte_pdump.c                  |  9 ++------
 lib/librte_rawdev/rte_rawdev.c                |  7 +++----
 lib/librte_rcu/rte_rcu_qsbr.c                 |  9 +-------
 lib/librte_stack/rte_stack.c                  |  7 +------
 lib/librte_vhost/vhost.c                      | 15 ++-----------
 17 files changed, 25 insertions(+), 126 deletions(-)

diff --git a/lib/librte_bbdev/rte_bbdev.c b/lib/librte_bbdev/rte_bbdev.c
index f6fe05aca..578f44484 100644
--- a/lib/librte_bbdev/rte_bbdev.c
+++ b/lib/librte_bbdev/rte_bbdev.c
@@ -29,7 +29,7 @@
 
 
 /* BBDev library logging ID */
-static int bbdev_logtype;
+RTE_LOG_REGISTER(bbdev_logtype, lib.bbdev, NOTICE);
 
 /* Helper macro for logging */
 #define rte_bbdev_log(level, fmt, ...) \
@@ -1134,9 +1134,3 @@ rte_bbdev_op_type_str(enum rte_bbdev_op_type op_type)
 	return NULL;
 }
 
-RTE_INIT(rte_bbdev_init_log)
-{
-	bbdev_logtype = rte_log_register("lib.bbdev");
-	if (bbdev_logtype >= 0)
-		rte_log_set_level(bbdev_logtype, RTE_LOG_NOTICE);
-}
diff --git a/lib/librte_bpf/bpf.c b/lib/librte_bpf/bpf.c
index 7e1879ffa..8d15885bc 100644
--- a/lib/librte_bpf/bpf.c
+++ b/lib/librte_bpf/bpf.c
@@ -14,8 +14,6 @@
 
 #include "bpf_impl.h"
 
-int rte_bpf_logtype;
-
 void
 rte_bpf_destroy(struct rte_bpf *bpf)
 {
@@ -55,9 +53,4 @@ bpf_jit(struct rte_bpf *bpf)
 	return rc;
 }
 
-RTE_INIT(rte_bpf_init_log)
-{
-	rte_bpf_logtype = rte_log_register("lib.bpf");
-	if (rte_bpf_logtype >= 0)
-		rte_log_set_level(rte_bpf_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(rte_bpf_logtype, lib.bpf, INFO);
diff --git a/lib/librte_cfgfile/rte_cfgfile.c b/lib/librte_cfgfile/rte_cfgfile.c
index 714717dd9..876c10d17 100644
--- a/lib/librte_cfgfile/rte_cfgfile.c
+++ b/lib/librte_cfgfile/rte_cfgfile.c
@@ -27,7 +27,7 @@ struct rte_cfgfile {
 	struct rte_cfgfile_section *sections;
 };
 
-static int cfgfile_logtype;
+RTE_LOG_REGISTER(cfgfile_logtype, lib.cfgfile, INFO);
 
 #define CFG_LOG(level, fmt, args...)					\
 	rte_log(RTE_LOG_ ## level, cfgfile_logtype, "%s(): " fmt "\n",	\
@@ -567,9 +567,3 @@ rte_cfgfile_has_entry(struct rte_cfgfile *cfg, const char *sectionname,
 	return rte_cfgfile_get_entry(cfg, sectionname, entryname) != NULL;
 }
 
-RTE_INIT(cfgfile_init)
-{
-	cfgfile_logtype = rte_log_register("lib.cfgfile");
-	if (cfgfile_logtype >= 0)
-		rte_log_set_level(cfgfile_logtype, RTE_LOG_INFO);
-}
diff --git a/lib/librte_compressdev/rte_compressdev.c b/lib/librte_compressdev/rte_compressdev.c
index b3c5651dc..49a342f40 100644
--- a/lib/librte_compressdev/rte_compressdev.c
+++ b/lib/librte_compressdev/rte_compressdev.c
@@ -763,9 +763,4 @@ rte_compressdev_name_get(uint8_t dev_id)
 	return dev->data->name;
 }
 
-RTE_INIT(rte_compressdev_log)
-{
-	compressdev_logtype = rte_log_register("lib.compressdev");
-	if (compressdev_logtype >= 0)
-		rte_log_set_level(compressdev_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(compressdev_logtype, lib.compressdev, NOTICE);
diff --git a/lib/librte_compressdev/rte_compressdev_pmd.c b/lib/librte_compressdev/rte_compressdev_pmd.c
index 46b25565a..7f500d76d 100644
--- a/lib/librte_compressdev/rte_compressdev_pmd.c
+++ b/lib/librte_compressdev/rte_compressdev_pmd.c
@@ -10,8 +10,6 @@
 #include "rte_compressdev_internal.h"
 #include "rte_compressdev_pmd.h"
 
-int compressdev_logtype;
-
 /**
  * Parse name from argument
  */
diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 8e10a6fc3..d06b7f9b1 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -46,8 +46,6 @@
 #include "ethdev_profile.h"
 #include "ethdev_private.h"
 
-int rte_eth_dev_logtype;
-
 static const char *MZ_RTE_ETH_DEV_DATA = "rte_eth_dev_data";
 struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS];
 
@@ -5295,11 +5293,10 @@ handle_port_link_status(const char *cmd __rte_unused,
 	return 0;
 }
 
-RTE_INIT(ethdev_init_log)
+RTE_LOG_REGISTER(rte_eth_dev_logtype, lib.ethdev, INFO);
+
+RTE_INIT(ethdev_init_telemetry)
 {
-	rte_eth_dev_logtype = rte_log_register("lib.ethdev");
-	if (rte_eth_dev_logtype >= 0)
-		rte_log_set_level(rte_eth_dev_logtype, RTE_LOG_INFO);
 	rte_telemetry_register_cmd("/ethdev/list", handle_port_list,
 			"Returns list of available ethdev ports. Takes no parameters");
 	rte_telemetry_register_cmd("/ethdev/xstats", handle_port_xstats,
diff --git a/lib/librte_eventdev/rte_event_timer_adapter.c b/lib/librte_eventdev/rte_event_timer_adapter.c
index 005459f7d..ae68b4566 100644
--- a/lib/librte_eventdev/rte_event_timer_adapter.c
+++ b/lib/librte_eventdev/rte_event_timer_adapter.c
@@ -29,9 +29,9 @@
 #define DATA_MZ_NAME_MAX_LEN 64
 #define DATA_MZ_NAME_FORMAT "rte_event_timer_adapter_data_%d"
 
-static int evtim_logtype;
-static int evtim_svc_logtype;
-static int evtim_buffer_logtype;
+RTE_LOG_REGISTER(evtim_logtype, lib.eventdev.adapter.timer, NOTICE);
+RTE_LOG_REGISTER(evtim_buffer_logtype, lib.eventdev.adapter.timer, NOTICE);
+RTE_LOG_REGISTER(evtim_svc_logtype, lib.eventdev.adapter.timer.svc, NOTICE);
 
 static struct rte_event_timer_adapter adapters[RTE_EVENT_TIMER_ADAPTER_NUM_MAX];
 
@@ -1188,18 +1188,3 @@ static const struct rte_event_timer_adapter_ops swtim_ops = {
 	.cancel_burst		= swtim_cancel_burst,
 };
 
-RTE_INIT(event_timer_adapter_init_log)
-{
-	evtim_logtype = rte_log_register("lib.eventdev.adapter.timer");
-	if (evtim_logtype >= 0)
-		rte_log_set_level(evtim_logtype, RTE_LOG_NOTICE);
-
-	evtim_buffer_logtype = rte_log_register("lib.eventdev.adapter.timer."
-						"buffer");
-	if (evtim_buffer_logtype >= 0)
-		rte_log_set_level(evtim_buffer_logtype, RTE_LOG_NOTICE);
-
-	evtim_svc_logtype = rte_log_register("lib.eventdev.adapter.timer.svc");
-	if (evtim_svc_logtype >= 0)
-		rte_log_set_level(evtim_svc_logtype, RTE_LOG_NOTICE);
-}
diff --git a/lib/librte_flow_classify/rte_flow_classify.c b/lib/librte_flow_classify/rte_flow_classify.c
index 6022064d8..639b0051f 100644
--- a/lib/librte_flow_classify/rte_flow_classify.c
+++ b/lib/librte_flow_classify/rte_flow_classify.c
@@ -10,8 +10,6 @@
 #include <rte_table_acl.h>
 #include <stdbool.h>
 
-int librte_flow_classify_logtype;
-
 static uint32_t unique_id = 1;
 
 enum rte_flow_classify_table_type table_type
@@ -669,10 +667,4 @@ rte_flow_classifier_query(struct rte_flow_classifier *cls,
 	return ret;
 }
 
-RTE_INIT(librte_flow_classify_init_log)
-{
-	librte_flow_classify_logtype =
-		rte_log_register("lib.flow_classify");
-	if (librte_flow_classify_logtype >= 0)
-		rte_log_set_level(librte_flow_classify_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(librte_flow_classify_logtype, lib.flow_classify, INFO);
diff --git a/lib/librte_graph/graph.c b/lib/librte_graph/graph.c
index 0ea83df3d..baa383cd7 100644
--- a/lib/librte_graph/graph.c
+++ b/lib/librte_graph/graph.c
@@ -579,9 +579,4 @@ rte_graph_max_count(void)
 	return graph_id;
 }
 
-RTE_INIT(rte_graph_init_log)
-{
-	rte_graph_logtype = rte_log_register("lib.graph");
-	if (rte_graph_logtype >= 0)
-		rte_log_set_level(rte_graph_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(rte_graph_logtype, lib.graph, INFO);
diff --git a/lib/librte_member/rte_member.c b/lib/librte_member/rte_member.c
index e0e7f127e..4696c0f17 100644
--- a/lib/librte_member/rte_member.c
+++ b/lib/librte_member/rte_member.c
@@ -16,8 +16,6 @@
 #include "rte_member_ht.h"
 #include "rte_member_vbf.h"
 
-int librte_member_logtype;
-
 TAILQ_HEAD(rte_member_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_member_tailq = {
 	.name = "RTE_MEMBER",
@@ -299,9 +297,4 @@ rte_member_reset(const struct rte_member_setsum *setsum)
 	}
 }
 
-RTE_INIT(librte_member_init_log)
-{
-	librte_member_logtype = rte_log_register("lib.member");
-	if (librte_member_logtype >= 0)
-		rte_log_set_level(librte_member_logtype, RTE_LOG_DEBUG);
-}
+RTE_LOG_REGISTER(librte_member_logtype, lib.member, DEBUG);
diff --git a/lib/librte_metrics/rte_metrics_telemetry.c b/lib/librte_metrics/rte_metrics_telemetry.c
index 040e87d18..289ebae0b 100644
--- a/lib/librte_metrics/rte_metrics_telemetry.c
+++ b/lib/librte_metrics/rte_metrics_telemetry.c
@@ -525,6 +525,8 @@ handle_ports_stats_values_by_name(const char *cmd __rte_unused,
 	return used;
 }
 
+RTE_LOG_REGISTER(metrics_log_level, lib.metrics, ERR);
+
 RTE_INIT(metrics_ctor)
 {
 #ifdef RTE_LIBRTE_TELEMETRY
@@ -535,7 +537,4 @@ RTE_INIT(metrics_ctor)
 	rte_telemetry_legacy_register("ports_stats_values_by_name", DATA_REQ,
 			handle_ports_stats_values_by_name);
 #endif
-	metrics_log_level = rte_log_register("lib.metrics");
-	if (metrics_log_level >= 0)
-		rte_log_set_level(metrics_log_level, RTE_LOG_ERR);
 }
diff --git a/lib/librte_node/log.c b/lib/librte_node/log.c
index f035f91e8..f14199f07 100644
--- a/lib/librte_node/log.c
+++ b/lib/librte_node/log.c
@@ -4,11 +4,4 @@
 
 #include "node_private.h"
 
-int rte_node_logtype;
-
-RTE_INIT(rte_node_init_log)
-{
-	rte_node_logtype = rte_log_register("lib.node");
-	if (rte_node_logtype >= 0)
-		rte_log_set_level(rte_node_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(rte_node_logtype, lib.node, INFO);
diff --git a/lib/librte_pdump/rte_pdump.c b/lib/librte_pdump/rte_pdump.c
index f96709f95..5016e9dd2 100644
--- a/lib/librte_pdump/rte_pdump.c
+++ b/lib/librte_pdump/rte_pdump.c
@@ -14,8 +14,9 @@
 
 #define DEVICE_ID_SIZE 64
 
+RTE_LOG_REGISTER(pdump_logtype, lib.pdump, NOTICE);
+
 /* Macro for printing using RTE_LOG */
-static int pdump_logtype;
 #define PDUMP_LOG(level, fmt, args...)				\
 	rte_log(RTE_LOG_ ## level, pdump_logtype, "%s(): " fmt,	\
 		__func__, ## args)
@@ -561,9 +562,3 @@ rte_pdump_disable_by_deviceid(char *device_id, uint16_t queue,
 	return ret;
 }
 
-RTE_INIT(pdump_log)
-{
-	pdump_logtype = rte_log_register("lib.pdump");
-	if (pdump_logtype >= 0)
-		rte_log_set_level(pdump_logtype, RTE_LOG_NOTICE);
-}
diff --git a/lib/librte_rawdev/rte_rawdev.c b/lib/librte_rawdev/rte_rawdev.c
index c332a7648..aec61f425 100644
--- a/lib/librte_rawdev/rte_rawdev.c
+++ b/lib/librte_rawdev/rte_rawdev.c
@@ -613,11 +613,10 @@ handle_dev_xstats(const char *cmd __rte_unused,
 	return 0;
 }
 
-RTE_INIT(librawdev_init_log)
+RTE_LOG_REGISTER(librawdev_logtype, lib.rawdev, INFO);
+
+RTE_INIT(librawdev_init_telemetry)
 {
-	librawdev_logtype = rte_log_register("lib.rawdev");
-	if (librawdev_logtype >= 0)
-		rte_log_set_level(librawdev_logtype, RTE_LOG_INFO);
 	rte_telemetry_register_cmd("/rawdev/list", handle_dev_list,
 			"Returns list of available rawdev ports. Takes no parameters");
 	rte_telemetry_register_cmd("/rawdev/xstats", handle_dev_xstats,
diff --git a/lib/librte_rcu/rte_rcu_qsbr.c b/lib/librte_rcu/rte_rcu_qsbr.c
index 6a429d8b3..aebfdb0da 100644
--- a/lib/librte_rcu/rte_rcu_qsbr.c
+++ b/lib/librte_rcu/rte_rcu_qsbr.c
@@ -495,11 +495,4 @@ rte_rcu_qsbr_dq_delete(struct rte_rcu_qsbr_dq *dq)
 	return 0;
 }
 
-int rte_rcu_log_type;
-
-RTE_INIT(rte_rcu_register)
-{
-	rte_rcu_log_type = rte_log_register("lib.rcu");
-	if (rte_rcu_log_type >= 0)
-		rte_log_set_level(rte_rcu_log_type, RTE_LOG_ERR);
-}
+RTE_LOG_REGISTER(rte_rcu_log_type, lib.rcu, ERR);
diff --git a/lib/librte_stack/rte_stack.c b/lib/librte_stack/rte_stack.c
index e58fa545f..e4c0ce131 100644
--- a/lib/librte_stack/rte_stack.c
+++ b/lib/librte_stack/rte_stack.c
@@ -194,9 +194,4 @@ rte_stack_lookup(const char *name)
 	return r;
 }
 
-RTE_INIT(librte_stack_init_log)
-{
-	stack_logtype = rte_log_register("lib.stack");
-	if (stack_logtype >= 0)
-		rte_log_set_level(stack_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(stack_logtype, lib.stack, NOTICE);
diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
index 026631844..872d57f61 100644
--- a/lib/librte_vhost/vhost.c
+++ b/lib/librte_vhost/vhost.c
@@ -27,9 +27,6 @@
 
 struct virtio_net *vhost_devices[MAX_VHOST_DEVICE];
 
-int vhost_config_log_level;
-int vhost_data_log_level;
-
 /* Called with iotlb_lock read-locked */
 uint64_t
 __vhost_iova_to_vva(struct virtio_net *dev, struct vhost_virtqueue *vq,
@@ -1517,13 +1514,5 @@ int rte_vhost_extern_callback_register(int vid,
 	return 0;
 }
 
-RTE_INIT(vhost_log_init)
-{
-	vhost_config_log_level = rte_log_register("lib.vhost.config");
-	if (vhost_config_log_level >= 0)
-		rte_log_set_level(vhost_config_log_level, RTE_LOG_INFO);
-
-	vhost_data_log_level = rte_log_register("lib.vhost.data");
-	if (vhost_data_log_level >= 0)
-		rte_log_set_level(vhost_data_log_level, RTE_LOG_WARNING);
-}
+RTE_LOG_REGISTER(vhost_config_log_level, lib.vhost.config, INFO);
+RTE_LOG_REGISTER(vhost_data_log_level, lib.vhost.data, WARNING);
-- 
2.27.0


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

* [dpdk-dev]  [PATCH v4 03/13] drivers/vdpa: use log register macro
  2020-07-01 10:44     ` [dpdk-dev] [PATCH v4 00/13] rte_log registration usage improvement jerinj
  2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 01/13] eal/log: introduce log register macro jerinj
  2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 02/13] lib: use " jerinj
@ 2020-07-01 10:44       ` jerinj
  2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 04/13] drivers/raw: " jerinj
                         ` (10 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01 10:44 UTC (permalink / raw)
  To: dev, Xiao Wang, Matan Azrad, Viacheslav Ovsiienko
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/vdpa/ifc/ifcvf_vdpa.c | 10 +---------
 drivers/vdpa/mlx5/mlx5_vdpa.c |  7 +++----
 2 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
index ec97178dc..78299fa67 100644
--- a/drivers/vdpa/ifc/ifcvf_vdpa.c
+++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
@@ -24,6 +24,7 @@
 
 #include "base/ifcvf.h"
 
+RTE_LOG_REGISTER(ifcvf_vdpa_logtype, pmd.net.ifcvf_vdpa, NOTICE);
 #define DRV_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, ifcvf_vdpa_logtype, \
 		"IFCVF %s(): " fmt "\n", __func__, ##args)
@@ -44,8 +45,6 @@ static const char * const ifcvf_valid_arguments[] = {
 	NULL
 };
 
-static int ifcvf_vdpa_logtype;
-
 struct ifcvf_internal {
 	struct rte_vdpa_dev_addr dev_addr;
 	struct rte_pci_device *pdev;
@@ -1271,10 +1270,3 @@ static struct rte_pci_driver rte_ifcvf_vdpa = {
 RTE_PMD_REGISTER_PCI(net_ifcvf, rte_ifcvf_vdpa);
 RTE_PMD_REGISTER_PCI_TABLE(net_ifcvf, pci_id_ifcvf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_ifcvf, "* vfio-pci");
-
-RTE_INIT(ifcvf_vdpa_init_log)
-{
-	ifcvf_vdpa_logtype = rte_log_register("pmd.net.ifcvf_vdpa");
-	if (ifcvf_vdpa_logtype >= 0)
-		rte_log_set_level(ifcvf_vdpa_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c
index 1113d6cef..b166207c4 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa.c
@@ -608,15 +608,14 @@ static struct rte_pci_driver mlx5_vdpa_driver = {
 	.drv_flags = 0,
 };
 
+
+RTE_LOG_REGISTER(mlx5_vdpa_logtype, pmd.vdpa.mlx5, NOTICE);
+
 /**
  * Driver initialization routine.
  */
 RTE_INIT(rte_mlx5_vdpa_init)
 {
-	/* Initialize common log type. */
-	mlx5_vdpa_logtype = rte_log_register("pmd.vdpa.mlx5");
-	if (mlx5_vdpa_logtype >= 0)
-		rte_log_set_level(mlx5_vdpa_logtype, RTE_LOG_NOTICE);
 	if (mlx5_glue)
 		rte_pci_register(&mlx5_vdpa_driver);
 }
-- 
2.27.0


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

* [dpdk-dev]  [PATCH v4 04/13] drivers/raw: use log register macro
  2020-07-01 10:44     ` [dpdk-dev] [PATCH v4 00/13] rte_log registration usage improvement jerinj
                         ` (2 preceding siblings ...)
  2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 03/13] drivers/vdpa: " jerinj
@ 2020-07-01 10:44       ` jerinj
  2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 05/13] drivers/net: " jerinj
                         ` (9 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01 10:44 UTC (permalink / raw)
  To: dev, Nipun Gupta, Rosen Xu, Tianfei zhang, Bruce Richardson,
	Xiaoyun Li, Jingjing Wu, Hemant Agrawal
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c  | 11 +----------
 drivers/raw/dpaa2_qdma/dpaa2_qdma.c    | 11 +----------
 drivers/raw/ifpga/ifpga_rawdev.c       | 10 +---------
 drivers/raw/ioat/ioat_rawdev.c         | 12 ++----------
 drivers/raw/ioat/rte_ioat_rawdev.h     |  2 --
 drivers/raw/ntb/ntb.c                  | 10 +---------
 drivers/raw/skeleton/skeleton_rawdev.c | 11 +----------
 7 files changed, 7 insertions(+), 60 deletions(-)

diff --git a/drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c b/drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c
index 7c21c6a52..c7bddbc6c 100644
--- a/drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c
+++ b/drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c
@@ -20,9 +20,6 @@
 #include "dpaa2_cmdif_logs.h"
 #include "rte_pmd_dpaa2_cmdif.h"
 
-/* Dynamic log type identifier */
-int dpaa2_cmdif_logtype;
-
 /* CMDIF driver name */
 #define DPAA2_CMDIF_PMD_NAME dpaa2_dpci
 
@@ -291,10 +288,4 @@ static struct rte_vdev_driver dpaa2_cmdif_drv = {
 };
 
 RTE_PMD_REGISTER_VDEV(DPAA2_CMDIF_PMD_NAME, dpaa2_cmdif_drv);
-
-RTE_INIT(dpaa2_cmdif_init_log)
-{
-	dpaa2_cmdif_logtype = rte_log_register("pmd.raw.dpaa2.cmdif");
-	if (dpaa2_cmdif_logtype >= 0)
-		rte_log_set_level(dpaa2_cmdif_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(dpaa2_cmdif_logtype, pmd.raw.dpaa2.cmdif, INFO);
diff --git a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
index 1be1b6ddf..0b9c4e3d7 100644
--- a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
+++ b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
@@ -26,9 +26,6 @@
 
 #define DPAA2_QDMA_NO_PREFETCH "no_prefetch"
 
-/* Dynamic log type identifier */
-int dpaa2_qdma_logtype;
-
 uint32_t dpaa2_coherent_no_alloc_cache;
 uint32_t dpaa2_coherent_alloc_cache;
 
@@ -1495,10 +1492,4 @@ static struct rte_dpaa2_driver rte_dpaa2_qdma_pmd = {
 RTE_PMD_REGISTER_DPAA2(dpaa2_qdma, rte_dpaa2_qdma_pmd);
 RTE_PMD_REGISTER_PARAM_STRING(dpaa2_qdma,
 	"no_prefetch=<int> ");
-
-RTE_INIT(dpaa2_qdma_init_log)
-{
-	dpaa2_qdma_logtype = rte_log_register("pmd.raw.dpaa2.qdma");
-	if (dpaa2_qdma_logtype >= 0)
-		rte_log_set_level(dpaa2_qdma_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(dpaa2_qdma_logtype, pmd.raw.dpaa2.qdma, INFO);
diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c
index b8701e155..cc25c662b 100644
--- a/drivers/raw/ifpga/ifpga_rawdev.c
+++ b/drivers/raw/ifpga/ifpga_rawdev.c
@@ -47,8 +47,6 @@
 #define RTE_PCI_EXT_CAP_ID(header)       (int)(header & 0x0000ffff)
 #define RTE_PCI_EXT_CAP_NEXT(header)     ((header >> 20) & 0xffc)
 
-int ifpga_rawdev_logtype;
-
 #define PCI_VENDOR_ID_INTEL          0x8086
 /* PCI Device ID */
 #define PCIE_DEVICE_ID_PF_INT_5_X    0xBCBD
@@ -1597,13 +1595,7 @@ static struct rte_pci_driver rte_ifpga_rawdev_pmd = {
 RTE_PMD_REGISTER_PCI(ifpga_rawdev_pci_driver, rte_ifpga_rawdev_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(ifpga_rawdev_pci_driver, rte_ifpga_rawdev_pmd);
 RTE_PMD_REGISTER_KMOD_DEP(ifpga_rawdev_pci_driver, "* igb_uio | uio_pci_generic | vfio-pci");
-
-RTE_INIT(ifpga_rawdev_init_log)
-{
-	ifpga_rawdev_logtype = rte_log_register("driver.raw.init");
-	if (ifpga_rawdev_logtype >= 0)
-		rte_log_set_level(ifpga_rawdev_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(ifpga_rawdev_logtype, driver.raw.init, NOTICE);
 
 static const char * const valid_args[] = {
 #define IFPGA_ARG_NAME         "ifpga"
diff --git a/drivers/raw/ioat/ioat_rawdev.c b/drivers/raw/ioat/ioat_rawdev.c
index a8a48f90a..30d9f597e 100644
--- a/drivers/raw/ioat/ioat_rawdev.c
+++ b/drivers/raw/ioat/ioat_rawdev.c
@@ -9,9 +9,6 @@
 
 #include "rte_ioat_rawdev.h"
 
-/* Dynamic log type identifier */
-int ioat_pmd_logtype;
-
 static struct rte_pci_driver ioat_pmd_drv;
 
 #define IOAT_VENDOR_ID		0x8086
@@ -28,6 +25,8 @@ static struct rte_pci_driver ioat_pmd_drv;
 #define IOAT_DEVICE_ID_BDXF	0x6f2F
 #define IOAT_DEVICE_ID_ICX	0x0b00
 
+RTE_LOG_REGISTER(ioat_pmd_logtype,  rawdev.ioat, INFO);
+
 #define IOAT_PMD_LOG(level, fmt, args...) rte_log(RTE_LOG_ ## level, \
 	ioat_pmd_logtype, "%s(): " fmt "\n", __func__, ##args)
 
@@ -386,10 +385,3 @@ static struct rte_pci_driver ioat_pmd_drv = {
 RTE_PMD_REGISTER_PCI(IOAT_PMD_RAWDEV_NAME, ioat_pmd_drv);
 RTE_PMD_REGISTER_PCI_TABLE(IOAT_PMD_RAWDEV_NAME, pci_id_ioat_map);
 RTE_PMD_REGISTER_KMOD_DEP(IOAT_PMD_RAWDEV_NAME, "* igb_uio | uio_pci_generic");
-
-RTE_INIT(ioat_pmd_init_log)
-{
-	ioat_pmd_logtype = rte_log_register(IOAT_PMD_LOG_NAME);
-	if (ioat_pmd_logtype >= 0)
-		rte_log_set_level(ioat_pmd_logtype, RTE_LOG_INFO);
-}
diff --git a/drivers/raw/ioat/rte_ioat_rawdev.h b/drivers/raw/ioat/rte_ioat_rawdev.h
index 4b271f174..f765a6557 100644
--- a/drivers/raw/ioat/rte_ioat_rawdev.h
+++ b/drivers/raw/ioat/rte_ioat_rawdev.h
@@ -25,8 +25,6 @@
 #define IOAT_PMD_RAWDEV_NAME rawdev_ioat
 /** String reported as the device driver name by rte_rawdev_info_get() */
 #define IOAT_PMD_RAWDEV_NAME_STR "rawdev_ioat"
-/** Name used to adjust the log level for this driver */
-#define IOAT_PMD_LOG_NAME "rawdev.ioat"
 
 /**
  * Configuration structure for an ioat rawdev instance
diff --git a/drivers/raw/ntb/ntb.c b/drivers/raw/ntb/ntb.c
index dd0b72f8c..e40412bb7 100644
--- a/drivers/raw/ntb/ntb.c
+++ b/drivers/raw/ntb/ntb.c
@@ -23,8 +23,6 @@
 #include "rte_pmd_ntb.h"
 #include "ntb.h"
 
-int ntb_logtype;
-
 static const struct rte_pci_id pci_id_ntb_map[] = {
 	{ RTE_PCI_DEVICE(NTB_INTEL_VENDOR_ID, NTB_INTEL_DEV_ID_B2B_SKX) },
 	{ .vendor_id = 0, /* sentinel */ },
@@ -1504,10 +1502,4 @@ static struct rte_pci_driver rte_ntb_pmd = {
 RTE_PMD_REGISTER_PCI(raw_ntb, rte_ntb_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(raw_ntb, pci_id_ntb_map);
 RTE_PMD_REGISTER_KMOD_DEP(raw_ntb, "* igb_uio | uio_pci_generic | vfio-pci");
-
-RTE_INIT(ntb_init_log)
-{
-	ntb_logtype = rte_log_register("pmd.raw.ntb");
-	if (ntb_logtype >= 0)
-		rte_log_set_level(ntb_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(ntb_logtype, pmd.raw.ntb, INFO);
diff --git a/drivers/raw/skeleton/skeleton_rawdev.c b/drivers/raw/skeleton/skeleton_rawdev.c
index 586183a5b..72ece887a 100644
--- a/drivers/raw/skeleton/skeleton_rawdev.c
+++ b/drivers/raw/skeleton/skeleton_rawdev.c
@@ -28,9 +28,6 @@
 
 #include "skeleton_rawdev.h"
 
-/* Dynamic log type identifier */
-int skeleton_pmd_logtype;
-
 /* Count of instances */
 static uint16_t skeldev_init_once;
 
@@ -759,10 +756,4 @@ static struct rte_vdev_driver skeleton_pmd_drv = {
 };
 
 RTE_PMD_REGISTER_VDEV(SKELETON_PMD_RAWDEV_NAME, skeleton_pmd_drv);
-
-RTE_INIT(skeleton_pmd_init_log)
-{
-	skeleton_pmd_logtype = rte_log_register("rawdev.skeleton");
-	if (skeleton_pmd_logtype >= 0)
-		rte_log_set_level(skeleton_pmd_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(skeleton_pmd_logtype, rawdev.skeleton, INFO);
-- 
2.27.0


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

* [dpdk-dev]  [PATCH v4 05/13] drivers/net: use log register macro
  2020-07-01 10:44     ` [dpdk-dev] [PATCH v4 00/13] rte_log registration usage improvement jerinj
                         ` (3 preceding siblings ...)
  2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 04/13] drivers/raw: " jerinj
@ 2020-07-01 10:44       ` jerinj
  2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 06/13] drivers/mempool: " jerinj
                         ` (8 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01 10:44 UTC (permalink / raw)
  To: dev, John W. Linville, Xiaolong Ye, Qi Zhang, Shepard Siegel,
	Ed Czeck, John Miller, Igor Russkikh, Pavel Belous,
	Steven Webster, Matt Peters, Somalapuram Amaranath, Rasesh Mody,
	Shahed Shaikh, Ajit Khaparde, Somnath Kotur, Chas Williams,
	Wei Hu (Xavier),
	Rahul Lakkireddy, Hemant Agrawal, Sachin Saxena, Marcin Wojtas,
	Michal Krawczyk, Guy Tzalik, Evgeny Schemeilin, Igor Chauskin,
	Gagandeep Singh, John Daley, Hyong Youb Kim, Gaetan Rivet,
	Xiao Wang, Ziyang Xuan, Xiaoyun Wang, Guoyang Zhou,
	Min Hu (Connor),
	Yisen Zhuang, Beilei Xing, Jeff Guo, Jingjing Wu, Qiming Yang,
	Wei Zhao, Alfredo Cardigliano, Rosen Xu, Ferruh Yigit,
	Shijith Thotton, Srisivasubramanian Srinivasan, Jakub Grajciar,
	Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko, Zyta Szpak,
	Liron Himi, Stephen Hemminger, K. Y. Srinivasan, Haiyang Zhang,
	Heinrich Kuhn, Tetsuya Mukawa, Harman Kalra, Akhil Goyal,
	Bruce Richardson, Jasvinder Singh, Cristian Dumitrescu,
	Martin Zizka, Jakub Neruda, Keith Wiles, Jerin Jacob,
	Maciej Czekaj, Maxime Coquelin, Zhihong Wang, Yong Wang
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena, adamx.dybkowski

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/net/af_packet/rte_eth_af_packet.c |  8 +---
 drivers/net/af_xdp/rte_eth_af_xdp.c       |  8 +---
 drivers/net/ark/ark_ethdev.c              | 10 +----
 drivers/net/atlantic/atl_ethdev.c         | 15 +------
 drivers/net/avp/avp_ethdev.c              | 10 +----
 drivers/net/axgbe/axgbe_ethdev.c          | 15 +------
 drivers/net/bnx2x/bnx2x_ethdev.c          | 15 +------
 drivers/net/bnxt/bnxt_ethdev.c            |  9 +----
 drivers/net/bonding/rte_eth_bond_pmd.c    |  9 +----
 drivers/net/cxgbe/cxgbe_ethdev.c          | 15 +------
 drivers/net/dpaa/dpaa_ethdev.c            |  9 +----
 drivers/net/dpaa2/dpaa2_ethdev.c          |  9 +----
 drivers/net/ena/ena_ethdev.c              | 48 +++--------------------
 drivers/net/enetc/enetc_ethdev.c          | 10 +----
 drivers/net/enic/enic_ethdev.c            |  9 +----
 drivers/net/failsafe/failsafe.c           | 10 +----
 drivers/net/fm10k/fm10k_ethdev.c          | 40 +++----------------
 drivers/net/hinic/hinic_pmd_ethdev.c      | 11 +-----
 drivers/net/hns3/hns3_ethdev.c            | 15 +------
 drivers/net/i40e/i40e_ethdev.c            | 38 +++---------------
 drivers/net/iavf/iavf_ethdev.c            | 40 +++----------------
 drivers/net/ice/ice_ethdev.c              | 38 +++---------------
 drivers/net/igc/igc_logs.c                | 16 +-------
 drivers/net/ionic/ionic_ethdev.c          | 10 +----
 drivers/net/ipn3ke/ipn3ke_ethdev.c        | 10 +----
 drivers/net/ixgbe/ixgbe_ethdev.c          | 39 +++---------------
 drivers/net/kni/rte_eth_kni.c             |  9 +----
 drivers/net/liquidio/lio_ethdev.c         | 15 +------
 drivers/net/memif/rte_eth_memif.c         |  9 +----
 drivers/net/mlx4/mlx4.c                   | 11 ++----
 drivers/net/mlx5/mlx5.c                   | 10 ++---
 drivers/net/mvneta/mvneta_ethdev.c        | 10 +----
 drivers/net/mvpp2/mrvl_ethdev.c           | 10 +----
 drivers/net/netvsc/hn_ethdev.c            | 15 +------
 drivers/net/nfp/nfp_net.c                 | 15 +------
 drivers/net/null/rte_eth_null.c           |  8 +---
 drivers/net/octeontx/octeontx_ethdev.c    | 21 ++--------
 drivers/net/pcap/rte_eth_pcap.c           |  8 +---
 drivers/net/pfe/pfe_ethdev.c              | 10 +----
 drivers/net/qede/qede_ethdev.c            | 16 +-------
 drivers/net/ring/rte_eth_ring.c           |  8 +---
 drivers/net/softnic/rte_eth_softnic.c     | 10 +----
 drivers/net/szedata2/rte_eth_szedata2.c   | 15 +------
 drivers/net/tap/rte_eth_tap.c             |  9 +----
 drivers/net/thunderx/nicvf_ethdev.c       | 21 ++--------
 drivers/net/vdev_netvsc/vdev_netvsc.c     | 13 +-----
 drivers/net/vhost/rte_eth_vhost.c         |  8 +---
 drivers/net/virtio/virtio_ethdev.c        | 15 +------
 drivers/net/vmxnet3/vmxnet3_ethdev.c      | 15 +------
 49 files changed, 97 insertions(+), 650 deletions(-)

diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index 22feb72e3..300039bbf 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -97,7 +97,7 @@ static struct rte_eth_link pmd_link = {
 	.link_autoneg = ETH_LINK_FIXED,
 };
 
-static int af_packet_logtype;
+RTE_LOG_REGISTER(af_packet_logtype, pmd.net.packet, NOTICE);
 
 #define PMD_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, af_packet_logtype, \
@@ -1082,9 +1082,3 @@ RTE_PMD_REGISTER_PARAM_STRING(net_af_packet,
 	"framecnt=<int> "
 	"qdisc_bypass=<0|1>");
 
-RTE_INIT(af_packet_init_log)
-{
-	af_packet_logtype = rte_log_register("pmd.net.packet");
-	if (af_packet_logtype >= 0)
-		rte_log_set_level(af_packet_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 06124ba78..98b9cff38 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -50,7 +50,7 @@
 #define PF_XDP AF_XDP
 #endif
 
-static int af_xdp_logtype;
+RTE_LOG_REGISTER(af_xdp_logtype, pmd.net.af_xdp, NOTICE);
 
 #define AF_XDP_LOG(level, fmt, args...)			\
 	rte_log(RTE_LOG_ ## level, af_xdp_logtype,	\
@@ -1374,9 +1374,3 @@ RTE_PMD_REGISTER_PARAM_STRING(net_af_xdp,
 			      "start_queue=<int> "
 			      "queue_count=<int> ");
 
-RTE_INIT(af_xdp_init_log)
-{
-	af_xdp_logtype = rte_log_register("pmd.net.af_xdp");
-	if (af_xdp_logtype >= 0)
-		rte_log_set_level(af_xdp_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c
index c3642012d..b32ccd867 100644
--- a/drivers/net/ark/ark_ethdev.c
+++ b/drivers/net/ark/ark_ethdev.c
@@ -78,8 +78,6 @@ static int  eth_ark_set_mtu(struct rte_eth_dev *dev, uint16_t size);
 #define ARK_TX_MAX_QUEUE (4096 * 4)
 #define ARK_TX_MIN_QUEUE (256)
 
-int ark_logtype;
-
 static const char * const valid_arguments[] = {
 	ARK_PKTGEN_ARG,
 	ARK_PKTCHKR_ARG,
@@ -1018,10 +1016,4 @@ RTE_PMD_REGISTER_PARAM_STRING(net_ark,
 			      ARK_PKTGEN_ARG "=<filename> "
 			      ARK_PKTCHKR_ARG "=<filename> "
 			      ARK_PKTDIR_ARG "=<bitmap>");
-
-RTE_INIT(ark_init_log)
-{
-	ark_logtype = rte_log_register("pmd.net.ark");
-	if (ark_logtype >= 0)
-		rte_log_set_level(ark_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(ark_logtype, pmd.net.ark, NOTICE);
diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_ethdev.c
index b2b3bd36c..d3b00ab29 100644
--- a/drivers/net/atlantic/atl_ethdev.c
+++ b/drivers/net/atlantic/atl_ethdev.c
@@ -120,9 +120,6 @@ static int eth_atl_pci_remove(struct rte_pci_device *pci_dev);
 static int atl_dev_info_get(struct rte_eth_dev *dev,
 				struct rte_eth_dev_info *dev_info);
 
-int atl_logtype_init;
-int atl_logtype_driver;
-
 /*
  * The set of PCI devices this driver supports
  */
@@ -1929,13 +1926,5 @@ is_atlantic_supported(struct rte_eth_dev *dev)
 RTE_PMD_REGISTER_PCI(net_atlantic, rte_atl_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_atlantic, pci_id_atl_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_atlantic, "* igb_uio | uio_pci_generic");
-
-RTE_INIT(atl_init_log)
-{
-	atl_logtype_init = rte_log_register("pmd.net.atlantic.init");
-	if (atl_logtype_init >= 0)
-		rte_log_set_level(atl_logtype_init, RTE_LOG_NOTICE);
-	atl_logtype_driver = rte_log_register("pmd.net.atlantic.driver");
-	if (atl_logtype_driver >= 0)
-		rte_log_set_level(atl_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(atl_logtype_init, pmd.net.atlantic.init, NOTICE);
+RTE_LOG_REGISTER(atl_logtype_driver, pmd.net.atlantic.driver, NOTICE);
diff --git a/drivers/net/avp/avp_ethdev.c b/drivers/net/avp/avp_ethdev.c
index 1abe96ce5..5b47f0924 100644
--- a/drivers/net/avp/avp_ethdev.c
+++ b/drivers/net/avp/avp_ethdev.c
@@ -32,8 +32,6 @@
 
 #include "avp_logs.h"
 
-int avp_logtype_driver;
-
 static int avp_dev_create(struct rte_pci_device *pci_dev,
 			  struct rte_eth_dev *eth_dev);
 
@@ -2306,10 +2304,4 @@ avp_dev_stats_reset(struct rte_eth_dev *eth_dev)
 
 RTE_PMD_REGISTER_PCI(net_avp, rte_avp_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_avp, pci_id_avp_map);
-
-RTE_INIT(avp_init_log)
-{
-	avp_logtype_driver = rte_log_register("pmd.net.avp.driver");
-	if (avp_logtype_driver >= 0)
-		rte_log_set_level(avp_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(avp_logtype_driver, pmd.net.avp.driver, NOTICE);
diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c
index db86b9813..0c25739f8 100644
--- a/drivers/net/axgbe/axgbe_ethdev.c
+++ b/drivers/net/axgbe/axgbe_ethdev.c
@@ -143,9 +143,6 @@ static const struct axgbe_xstats axgbe_xstats_strings[] = {
 #define AMD_PCI_AXGBE_DEVICE_V2A 0x1458
 #define AMD_PCI_AXGBE_DEVICE_V2B 0x1459
 
-int axgbe_logtype_init;
-int axgbe_logtype_driver;
-
 static const struct rte_pci_id pci_id_axgbe_map[] = {
 	{RTE_PCI_DEVICE(AMD_PCI_VENDOR_ID, AMD_PCI_AXGBE_DEVICE_V2A)},
 	{RTE_PCI_DEVICE(AMD_PCI_VENDOR_ID, AMD_PCI_AXGBE_DEVICE_V2B)},
@@ -1842,13 +1839,5 @@ static struct rte_pci_driver rte_axgbe_pmd = {
 RTE_PMD_REGISTER_PCI(net_axgbe, rte_axgbe_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_axgbe, pci_id_axgbe_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_axgbe, "* igb_uio | uio_pci_generic | vfio-pci");
-
-RTE_INIT(axgbe_init_log)
-{
-	axgbe_logtype_init = rte_log_register("pmd.net.axgbe.init");
-	if (axgbe_logtype_init >= 0)
-		rte_log_set_level(axgbe_logtype_init, RTE_LOG_NOTICE);
-	axgbe_logtype_driver = rte_log_register("pmd.net.axgbe.driver");
-	if (axgbe_logtype_driver >= 0)
-		rte_log_set_level(axgbe_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(axgbe_logtype_init, pmd.net.axgbe.init, NOTICE);
+RTE_LOG_REGISTER(axgbe_logtype_driver, pmd.net.axgbe.driver, NOTICE);
diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c
index adc3690fc..b2ea5fafa 100644
--- a/drivers/net/bnx2x/bnx2x_ethdev.c
+++ b/drivers/net/bnx2x/bnx2x_ethdev.c
@@ -13,9 +13,6 @@
 #include <rte_ethdev_pci.h>
 #include <rte_alarm.h>
 
-int bnx2x_logtype_init;
-int bnx2x_logtype_driver;
-
 /*
  * The set of PCI devices this driver supports
  */
@@ -805,13 +802,5 @@ RTE_PMD_REGISTER_KMOD_DEP(net_bnx2x, "* igb_uio | uio_pci_generic | vfio-pci");
 RTE_PMD_REGISTER_PCI(net_bnx2xvf, rte_bnx2xvf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_bnx2xvf, pci_id_bnx2xvf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_bnx2xvf, "* igb_uio | vfio-pci");
-
-RTE_INIT(bnx2x_init_log)
-{
-	bnx2x_logtype_init = rte_log_register("pmd.net.bnx2x.init");
-	if (bnx2x_logtype_init >= 0)
-		rte_log_set_level(bnx2x_logtype_init, RTE_LOG_NOTICE);
-	bnx2x_logtype_driver = rte_log_register("pmd.net.bnx2x.driver");
-	if (bnx2x_logtype_driver >= 0)
-		rte_log_set_level(bnx2x_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(bnx2x_logtype_init, pmd.net.bnx2x.init, NOTICE);
+RTE_LOG_REGISTER(bnx2x_logtype_driver, pmd.net.bnx2x.driver, NOTICE);
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index e8b4c058a..59c318076 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -31,7 +31,6 @@
 #define DRV_MODULE_NAME		"bnxt"
 static const char bnxt_version[] =
 	"Broadcom NetXtreme driver " DRV_MODULE_NAME;
-int bnxt_logtype_driver;
 
 /*
  * The set of PCI devices this driver supports
@@ -5668,13 +5667,7 @@ bool is_bnxt_supported(struct rte_eth_dev *dev)
 	return is_device_supported(dev, &bnxt_rte_pmd);
 }
 
-RTE_INIT(bnxt_init_log)
-{
-	bnxt_logtype_driver = rte_log_register("pmd.net.bnxt.driver");
-	if (bnxt_logtype_driver >= 0)
-		rte_log_set_level(bnxt_logtype_driver, RTE_LOG_NOTICE);
-}
-
+RTE_LOG_REGISTER(bnxt_logtype_driver, pmd.net.bnxt.driver, NOTICE);
 RTE_PMD_REGISTER_PCI(net_bnxt, bnxt_rte_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_bnxt, bnxt_pci_id_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_bnxt, "* igb_uio | uio_pci_generic | vfio-pci");
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 612a64599..044a1cfbc 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -3750,11 +3750,4 @@ RTE_PMD_REGISTER_PARAM_STRING(net_bonding,
 	"up_delay=<int> "
 	"down_delay=<int>");
 
-int bond_logtype;
-
-RTE_INIT(bond_init_log)
-{
-	bond_logtype = rte_log_register("pmd.net.bond");
-	if (bond_logtype >= 0)
-		rte_log_set_level(bond_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(bond_logtype, pmd.net.bond, NOTICE);
diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index 1deee2f5c..7c6016d5c 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -38,9 +38,6 @@
 #include "cxgbe_pfvf.h"
 #include "cxgbe_flow.h"
 
-int cxgbe_logtype;
-int cxgbe_mbox_logtype;
-
 /*
  * Macros needed to support the PCI Device ID Table ...
  */
@@ -1247,13 +1244,5 @@ RTE_PMD_REGISTER_PARAM_STRING(net_cxgbe,
 			      CXGBE_DEVARG_CMN_TX_MODE_LATENCY "=<0|1> "
 			      CXGBE_DEVARG_PF_FILTER_MODE "=<uint32> "
 			      CXGBE_DEVARG_PF_FILTER_MASK "=<uint32> ");
-
-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);
-	cxgbe_mbox_logtype = rte_log_register("pmd.net.cxgbe.mbox");
-	if (cxgbe_mbox_logtype >= 0)
-		rte_log_set_level(cxgbe_mbox_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(cxgbe_logtype, pmd.net.cxgbe, NOTICE);
+RTE_LOG_REGISTER(cxgbe_mbox_logtype, pmd.net.cxgbe.mbox, NOTICE);
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 13d1c6a1f..f1c9a7151 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -46,8 +46,6 @@
 #include <fsl_bman.h>
 #include <fsl_fman.h>
 
-int dpaa_logtype_pmd;
-
 /* Supported Rx offloads */
 static uint64_t dev_rx_offloads_sup =
 		DEV_RX_OFFLOAD_JUMBO_FRAME |
@@ -1666,9 +1664,4 @@ static struct rte_dpaa_driver rte_dpaa_pmd = {
 };
 
 RTE_PMD_REGISTER_DPAA(net_dpaa, rte_dpaa_pmd);
-RTE_INIT(dpaa_net_init_log)
-{
-	dpaa_logtype_pmd = rte_log_register("pmd.net.dpaa");
-	if (dpaa_logtype_pmd >= 0)
-		rte_log_set_level(dpaa_logtype_pmd, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa_logtype_pmd, pmd.net.dpaa, NOTICE);
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 2f031ec5c..a1f19194d 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -106,8 +106,6 @@ static int dpaa2_dev_set_link_up(struct rte_eth_dev *dev);
 static int dpaa2_dev_set_link_down(struct rte_eth_dev *dev);
 static int dpaa2_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
 
-int dpaa2_logtype_pmd;
-
 void
 rte_pmd_dpaa2_set_timestamp(enum pmd_dpaa2_ts enable)
 {
@@ -2694,9 +2692,4 @@ RTE_PMD_REGISTER_DPAA2(net_dpaa2, rte_dpaa2_pmd);
 RTE_PMD_REGISTER_PARAM_STRING(net_dpaa2,
 		DRIVER_LOOPBACK_MODE "=<int> "
 		DRIVER_NO_PREFETCH_MODE "=<int>");
-RTE_INIT(dpaa2_pmd_init_log)
-{
-	dpaa2_logtype_pmd = rte_log_register("pmd.net.dpaa2");
-	if (dpaa2_logtype_pmd >= 0)
-		rte_log_set_level(dpaa2_logtype_pmd, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa2_logtype_pmd, pmd.net.dpaa2, NOTICE);
diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index fbddc79f7..da8c8ad92 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -141,22 +141,6 @@ static const struct ena_stats ena_stats_rx_strings[] = {
 #define	ENA_TX_OFFLOAD_NOTSUP_MASK	\
 	(PKT_TX_OFFLOAD_MASK ^ ENA_TX_OFFLOAD_MASK)
 
-int ena_logtype_init;
-int ena_logtype_driver;
-
-#ifdef RTE_LIBRTE_ENA_DEBUG_RX
-int ena_logtype_rx;
-#endif
-#ifdef RTE_LIBRTE_ENA_DEBUG_TX
-int ena_logtype_tx;
-#endif
-#ifdef RTE_LIBRTE_ENA_DEBUG_TX_FREE
-int ena_logtype_tx_free;
-#endif
-#ifdef RTE_LIBRTE_ENA_COM_DEBUG
-int ena_logtype_com;
-#endif
-
 static const struct rte_pci_id pci_id_ena_map[] = {
 	{ RTE_PCI_DEVICE(PCI_VENDOR_ID_AMAZON, PCI_DEVICE_ID_ENA_VF) },
 	{ RTE_PCI_DEVICE(PCI_VENDOR_ID_AMAZON, PCI_DEVICE_ID_ENA_LLQ_VF) },
@@ -2849,40 +2833,20 @@ RTE_PMD_REGISTER_PCI(net_ena, rte_ena_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_ena, pci_id_ena_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_ena, "* igb_uio | uio_pci_generic | vfio-pci");
 RTE_PMD_REGISTER_PARAM_STRING(net_ena, ENA_DEVARG_LARGE_LLQ_HDR "=<0|1>");
-
-RTE_INIT(ena_init_log)
-{
-	ena_logtype_init = rte_log_register("pmd.net.ena.init");
-	if (ena_logtype_init >= 0)
-		rte_log_set_level(ena_logtype_init, RTE_LOG_NOTICE);
-	ena_logtype_driver = rte_log_register("pmd.net.ena.driver");
-	if (ena_logtype_driver >= 0)
-		rte_log_set_level(ena_logtype_driver, RTE_LOG_NOTICE);
-
+RTE_LOG_REGISTER(ena_logtype_init, pmd.net.ena.init, NOTICE);
+RTE_LOG_REGISTER(ena_logtype_driver, pmd.net.ena.driver, NOTICE);
 #ifdef RTE_LIBRTE_ENA_DEBUG_RX
-	ena_logtype_rx = rte_log_register("pmd.net.ena.rx");
-	if (ena_logtype_rx >= 0)
-		rte_log_set_level(ena_logtype_rx, RTE_LOG_NOTICE);
+RTE_LOG_REGISTER(ena_logtype_rx, pmd.net.ena.rx, NOTICE);
 #endif
-
 #ifdef RTE_LIBRTE_ENA_DEBUG_TX
-	ena_logtype_tx = rte_log_register("pmd.net.ena.tx");
-	if (ena_logtype_tx >= 0)
-		rte_log_set_level(ena_logtype_tx, RTE_LOG_NOTICE);
+RTE_LOG_REGISTER(ena_logtype_tx, pmd.net.ena.tx, NOTICE);
 #endif
-
 #ifdef RTE_LIBRTE_ENA_DEBUG_TX_FREE
-	ena_logtype_tx_free = rte_log_register("pmd.net.ena.tx_free");
-	if (ena_logtype_tx_free >= 0)
-		rte_log_set_level(ena_logtype_tx_free, RTE_LOG_NOTICE);
+RTE_LOG_REGISTER(ena_logtype_tx_free, pmd.net.ena.tx_free, NOTICE);
 #endif
-
 #ifdef RTE_LIBRTE_ENA_COM_DEBUG
-	ena_logtype_com = rte_log_register("pmd.net.ena.com");
-	if (ena_logtype_com >= 0)
-		rte_log_set_level(ena_logtype_com, RTE_LOG_NOTICE);
+RTE_LOG_REGISTER(ena_logtype_com, pmd.net.ena.com, NOTICE);
 #endif
-}
 
 /******************************************************************************
  ******************************** AENQ Handlers *******************************
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 1716e11dd..c6fb42740 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -10,8 +10,6 @@
 #include "enetc_logs.h"
 #include "enetc.h"
 
-int enetc_logtype_pmd;
-
 static int
 enetc_dev_start(struct rte_eth_dev *dev)
 {
@@ -951,10 +949,4 @@ static struct rte_pci_driver rte_enetc_pmd = {
 RTE_PMD_REGISTER_PCI(net_enetc, rte_enetc_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_enetc, pci_id_enetc_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_enetc, "* vfio-pci");
-
-RTE_INIT(enetc_pmd_init_log)
-{
-	enetc_logtype_pmd = rte_log_register("pmd.net.enetc");
-	if (enetc_logtype_pmd >= 0)
-		rte_log_set_level(enetc_logtype_pmd, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(enetc_logtype_pmd, pmd.net.enetc, NOTICE);
diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c
index 32d5397f8..6a3580fef 100644
--- a/drivers/net/enic/enic_ethdev.c
+++ b/drivers/net/enic/enic_ethdev.c
@@ -21,8 +21,6 @@
 #include "vnic_enet.h"
 #include "enic.h"
 
-int enic_pmd_logtype;
-
 /*
  * The set of PCI devices this driver supports
  */
@@ -71,12 +69,7 @@ static const struct vic_speed_capa {
 #define ENIC_DEVARG_GENEVE_OPT "geneve-opt"
 #define ENIC_DEVARG_IG_VLAN_REWRITE "ig-vlan-rewrite"
 
-RTE_INIT(enicpmd_init_log)
-{
-	enic_pmd_logtype = rte_log_register("pmd.net.enic");
-	if (enic_pmd_logtype >= 0)
-		rte_log_set_level(enic_pmd_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(enic_pmd_logtype, pmd.net.enic, INFO);
 
 static int
 enicpmd_fdir_ctrl_func(struct rte_eth_dev *eth_dev,
diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsafe.c
index 72362f35d..4a4b7ceab 100644
--- a/drivers/net/failsafe/failsafe.c
+++ b/drivers/net/failsafe/failsafe.c
@@ -15,8 +15,6 @@
 
 #include "failsafe_private.h"
 
-int failsafe_logtype;
-
 const char pmd_failsafe_driver_name[] = FAILSAFE_DRIVER_NAME;
 static const struct rte_eth_link eth_link = {
 	.link_speed = ETH_SPEED_NUM_10G,
@@ -410,10 +408,4 @@ static struct rte_vdev_driver failsafe_drv = {
 
 RTE_PMD_REGISTER_VDEV(net_failsafe, failsafe_drv);
 RTE_PMD_REGISTER_PARAM_STRING(net_failsafe, PMD_FAILSAFE_PARAM_STRING);
-
-RTE_INIT(failsafe_init_log)
-{
-	failsafe_logtype = rte_log_register("pmd.net.failsafe");
-	if (failsafe_logtype >= 0)
-		rte_log_set_level(failsafe_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(failsafe_logtype, pmd.net.failsafe, NOTICE)
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index f537ab286..cb0dd3bae 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -40,19 +40,6 @@
 #define GLORT_FD_MASK    GLORT_PF_MASK
 #define GLORT_FD_INDEX   GLORT_FD_Q_BASE
 
-int fm10k_logtype_init;
-int fm10k_logtype_driver;
-
-#ifdef RTE_LIBRTE_FM10K_DEBUG_RX
-int fm10k_logtype_rx;
-#endif
-#ifdef RTE_LIBRTE_FM10K_DEBUG_TX
-int fm10k_logtype_tx;
-#endif
-#ifdef RTE_LIBRTE_FM10K_DEBUG_TX_FREE
-int fm10k_logtype_tx_free;
-#endif
-
 static void fm10k_close_mbx_service(struct fm10k_hw *hw);
 static int fm10k_dev_promiscuous_enable(struct rte_eth_dev *dev);
 static int fm10k_dev_promiscuous_disable(struct rte_eth_dev *dev);
@@ -3318,31 +3305,14 @@ 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)
-{
-	fm10k_logtype_init = rte_log_register("pmd.net.fm10k.init");
-	if (fm10k_logtype_init >= 0)
-		rte_log_set_level(fm10k_logtype_init, RTE_LOG_NOTICE);
-	fm10k_logtype_driver = rte_log_register("pmd.net.fm10k.driver");
-	if (fm10k_logtype_driver >= 0)
-		rte_log_set_level(fm10k_logtype_driver, RTE_LOG_NOTICE);
-
+RTE_LOG_REGISTER(fm10k_logtype_init, pmd.net.fm10k.init, NOTICE);
+RTE_LOG_REGISTER(fm10k_logtype_driver, pmd.net.fm10k.driver, NOTICE);
 #ifdef RTE_LIBRTE_FM10K_DEBUG_RX
-	fm10k_logtype_rx = rte_log_register("pmd.net.fm10k.rx");
-	if (fm10k_logtype_rx >= 0)
-		rte_log_set_level(fm10k_logtype_rx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(fm10k_logtype_rx, pmd.net.fm10k.rx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_FM10K_DEBUG_TX
-	fm10k_logtype_tx = rte_log_register("pmd.net.fm10k.tx");
-	if (fm10k_logtype_tx >= 0)
-		rte_log_set_level(fm10k_logtype_tx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(fm10k_logtype_tx, pmd.net.fm10k.tx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_FM10K_DEBUG_TX_FREE
-	fm10k_logtype_tx_free = rte_log_register("pmd.net.fm10k.tx_free");
-	if (fm10k_logtype_tx_free >= 0)
-		rte_log_set_level(fm10k_logtype_tx_free, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(fm10k_logtype_tx_free, pmd.net.fm10k.tx_free, DEBUG);
 #endif
-}
diff --git a/drivers/net/hinic/hinic_pmd_ethdev.c b/drivers/net/hinic/hinic_pmd_ethdev.c
index 0c3e1c0cd..8f81e2230 100644
--- a/drivers/net/hinic/hinic_pmd_ethdev.c
+++ b/drivers/net/hinic/hinic_pmd_ethdev.c
@@ -78,9 +78,6 @@
 /* lro numer limit for one packet */
 #define HINIC_LRO_WQE_NUM_DEFAULT	8
 
-/* Driver-specific log messages type */
-int hinic_logtype;
-
 struct hinic_xstats_name_off {
 	char name[RTE_ETH_XSTATS_NAME_SIZE];
 	u32  offset;
@@ -3250,10 +3247,4 @@ static struct rte_pci_driver rte_hinic_pmd = {
 
 RTE_PMD_REGISTER_PCI(net_hinic, rte_hinic_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_hinic, pci_id_hinic_map);
-
-RTE_INIT(hinic_init_log)
-{
-	hinic_logtype = rte_log_register("pmd.net.hinic");
-	if (hinic_logtype >= 0)
-		rte_log_set_level(hinic_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(hinic_logtype, pmd.net.hinic, INFO);
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 62d87582d..309d0483e 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -60,9 +60,6 @@
 #define HNS3_RESET_WAIT_MS	100
 #define HNS3_RESET_WAIT_CNT	200
 
-int hns3_logtype_init;
-int hns3_logtype_driver;
-
 enum hns3_evt_cause {
 	HNS3_VECTOR0_EVENT_RST,
 	HNS3_VECTOR0_EVENT_MBX,
@@ -5525,13 +5522,5 @@ static struct rte_pci_driver rte_hns3_pmd = {
 RTE_PMD_REGISTER_PCI(net_hns3, rte_hns3_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_hns3, pci_id_hns3_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_hns3, "* igb_uio | vfio-pci");
-
-RTE_INIT(hns3_init_log)
-{
-	hns3_logtype_init = rte_log_register("pmd.net.hns3.init");
-	if (hns3_logtype_init >= 0)
-		rte_log_set_level(hns3_logtype_init, RTE_LOG_NOTICE);
-	hns3_logtype_driver = rte_log_register("pmd.net.hns3.driver");
-	if (hns3_logtype_driver >= 0)
-		rte_log_set_level(hns3_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(hns3_logtype_init, pmd.net.hns3.init, NOTICE);
+RTE_LOG_REGISTER(hns3_logtype_driver, pmd.net.hns3.driver, NOTICE);
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 970a31cb2..472ce2a9e 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -398,18 +398,6 @@ static void i40e_tunnel_filter_restore(struct i40e_pf *pf);
 static void i40e_filter_restore(struct i40e_pf *pf);
 static void i40e_notify_all_vfs_link_status(struct rte_eth_dev *dev);
 
-int i40e_logtype_init;
-int i40e_logtype_driver;
-#ifdef RTE_LIBRTE_I40E_DEBUG_RX
-int i40e_logtype_rx;
-#endif
-#ifdef RTE_LIBRTE_I40E_DEBUG_TX
-int i40e_logtype_tx;
-#endif
-#ifdef RTE_LIBRTE_I40E_DEBUG_TX_FREE
-int i40e_logtype_tx_free;
-#endif
-
 static const char *const valid_keys[] = {
 	ETH_I40E_FLOATING_VEB_ARG,
 	ETH_I40E_FLOATING_VEB_LIST_ARG,
@@ -13411,33 +13399,17 @@ i40e_config_rss_filter(struct i40e_pf *pf,
 	return 0;
 }
 
-RTE_INIT(i40e_init_log)
-{
-	i40e_logtype_init = rte_log_register("pmd.net.i40e.init");
-	if (i40e_logtype_init >= 0)
-		rte_log_set_level(i40e_logtype_init, RTE_LOG_NOTICE);
-	i40e_logtype_driver = rte_log_register("pmd.net.i40e.driver");
-	if (i40e_logtype_driver >= 0)
-		rte_log_set_level(i40e_logtype_driver, RTE_LOG_NOTICE);
-
+RTE_LOG_REGISTER(i40e_logtype_init, pmd.net.i40e.init, NOTICE);
+RTE_LOG_REGISTER(i40e_logtype_driver, pmd.net.i40e.driver, NOTICE);
 #ifdef RTE_LIBRTE_I40E_DEBUG_RX
-	i40e_logtype_rx = rte_log_register("pmd.net.i40e.rx");
-	if (i40e_logtype_rx >= 0)
-		rte_log_set_level(i40e_logtype_rx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(i40e_logtype_rx, pmd.net.i40e.rx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_I40E_DEBUG_TX
-	i40e_logtype_tx = rte_log_register("pmd.net.i40e.tx");
-	if (i40e_logtype_tx >= 0)
-		rte_log_set_level(i40e_logtype_tx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(i40e_logtype_tx, pmd.net.i40e.tx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_I40E_DEBUG_TX_FREE
-	i40e_logtype_tx_free = rte_log_register("pmd.net.i40e.tx_free");
-	if (i40e_logtype_tx_free >= 0)
-		rte_log_set_level(i40e_logtype_tx_free, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(i40e_logtype_tx_free, pmd.net.i40e.tx_free, DEBUG);
 #endif
-}
 
 RTE_PMD_REGISTER_PARAM_STRING(net_i40e,
 			      ETH_I40E_FLOATING_VEB_ARG "=1"
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 2b1066b0a..d69e5284e 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -74,20 +74,6 @@ static int iavf_dev_filter_ctrl(struct rte_eth_dev *dev,
 		     enum rte_filter_op filter_op,
 		     void *arg);
 
-
-int iavf_logtype_init;
-int iavf_logtype_driver;
-
-#ifdef RTE_LIBRTE_IAVF_DEBUG_RX
-int iavf_logtype_rx;
-#endif
-#ifdef RTE_LIBRTE_IAVF_DEBUG_TX
-int iavf_logtype_tx;
-#endif
-#ifdef RTE_LIBRTE_IAVF_DEBUG_TX_FREE
-int iavf_logtype_tx_free;
-#endif
-
 static const struct rte_pci_id pci_id_iavf_map[] = {
 	{ RTE_PCI_DEVICE(IAVF_INTEL_VENDOR_ID, IAVF_DEV_ID_ADAPTIVE_VF) },
 	{ .vendor_id = 0, /* sentinel */ },
@@ -1556,30 +1542,14 @@ RTE_PMD_REGISTER_PCI(net_iavf, rte_iavf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_iavf, pci_id_iavf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_iavf, "* igb_uio | vfio-pci");
 RTE_PMD_REGISTER_PARAM_STRING(net_iavf, "cap=dcf");
-RTE_INIT(iavf_init_log)
-{
-	iavf_logtype_init = rte_log_register("pmd.net.iavf.init");
-	if (iavf_logtype_init >= 0)
-		rte_log_set_level(iavf_logtype_init, RTE_LOG_NOTICE);
-	iavf_logtype_driver = rte_log_register("pmd.net.iavf.driver");
-	if (iavf_logtype_driver >= 0)
-		rte_log_set_level(iavf_logtype_driver, RTE_LOG_NOTICE);
-
+RTE_LOG_REGISTER(iavf_logtype_init, pmd.net.iavf.init, NOTICE);
+RTE_LOG_REGISTER(iavf_logtype_driver, pmd.net.iavf.driver, NOTICE);
 #ifdef RTE_LIBRTE_IAVF_DEBUG_RX
-	iavf_logtype_rx = rte_log_register("pmd.net.iavf.rx");
-	if (iavf_logtype_rx >= 0)
-		rte_log_set_level(iavf_logtype_rx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(iavf_logtype_rx, pmd.net.iavf.rx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_IAVF_DEBUG_TX
-	iavf_logtype_tx = rte_log_register("pmd.net.iavf.tx");
-	if (iavf_logtype_tx >= 0)
-		rte_log_set_level(iavf_logtype_tx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(iavf_logtype_tx, pmd.net.iavf.tx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_IAVF_DEBUG_TX_FREE
-	iavf_logtype_tx_free = rte_log_register("pmd.net.iavf.tx_free");
-	if (iavf_logtype_tx_free >= 0)
-		rte_log_set_level(iavf_logtype_tx_free, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(iavf_logtype_tx_free, pmd.net.iavf.tx_free, DEBUG);
 #endif
-}
diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 5a89a1955..3386960df 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -71,18 +71,6 @@ static struct proto_xtr_ol_flag ice_proto_xtr_ol_flag_params[] = {
 #define ICE_COMMS_PKG_NAME			"ICE COMMS Package"
 #define ICE_MAX_RES_DESC_NUM        1024
 
-int ice_logtype_init;
-int ice_logtype_driver;
-#ifdef RTE_LIBRTE_ICE_DEBUG_RX
-int ice_logtype_rx;
-#endif
-#ifdef RTE_LIBRTE_ICE_DEBUG_TX
-int ice_logtype_tx;
-#endif
-#ifdef RTE_LIBRTE_ICE_DEBUG_TX_FREE
-int ice_logtype_tx_free;
-#endif
-
 static int ice_dev_configure(struct rte_eth_dev *dev);
 static int ice_dev_start(struct rte_eth_dev *dev);
 static void ice_dev_stop(struct rte_eth_dev *dev);
@@ -4576,30 +4564,14 @@ RTE_PMD_REGISTER_PARAM_STRING(net_ice,
 			      ICE_PIPELINE_MODE_SUPPORT_ARG "=<0|1>"
 			      ICE_FLOW_MARK_SUPPORT_ARG "=<0|1>");
 
-RTE_INIT(ice_init_log)
-{
-	ice_logtype_init = rte_log_register("pmd.net.ice.init");
-	if (ice_logtype_init >= 0)
-		rte_log_set_level(ice_logtype_init, RTE_LOG_NOTICE);
-	ice_logtype_driver = rte_log_register("pmd.net.ice.driver");
-	if (ice_logtype_driver >= 0)
-		rte_log_set_level(ice_logtype_driver, RTE_LOG_NOTICE);
-
+RTE_LOG_REGISTER(ice_logtype_init, pmd.net.ice.init, NOTICE);
+RTE_LOG_REGISTER(ice_logtype_driver, pmd.net.ice.driver, NOTICE);
 #ifdef RTE_LIBRTE_ICE_DEBUG_RX
-	ice_logtype_rx = rte_log_register("pmd.net.ice.rx");
-	if (ice_logtype_rx >= 0)
-		rte_log_set_level(ice_logtype_rx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(ice_logtype_rx, pmd.net.ice.rx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_ICE_DEBUG_TX
-	ice_logtype_tx = rte_log_register("pmd.net.ice.tx");
-	if (ice_logtype_tx >= 0)
-		rte_log_set_level(ice_logtype_tx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(ice_logtype_tx, pmd.net.ice.tx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_ICE_DEBUG_TX_FREE
-	ice_logtype_tx_free = rte_log_register("pmd.net.ice.tx_free");
-	if (ice_logtype_tx_free >= 0)
-		rte_log_set_level(ice_logtype_tx_free, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(ice_logtype_tx_free, pmd.net.ice.tx_free, DEBUG);
 #endif
-}
diff --git a/drivers/net/igc/igc_logs.c b/drivers/net/igc/igc_logs.c
index eff7640b1..2d458d7fb 100644
--- a/drivers/net/igc/igc_logs.c
+++ b/drivers/net/igc/igc_logs.c
@@ -6,17 +6,5 @@
 
 #include "igc_logs.h"
 
-/* declared as extern in igc_logs.h */
-int igc_logtype_init;
-int igc_logtype_driver;
-
-RTE_INIT(igc_init_log)
-{
-	igc_logtype_init = rte_log_register("pmd.net.igc.init");
-	if (igc_logtype_init >= 0)
-		rte_log_set_level(igc_logtype_init, RTE_LOG_INFO);
-
-	igc_logtype_driver = rte_log_register("pmd.net.igc.driver");
-	if (igc_logtype_driver >= 0)
-		rte_log_set_level(igc_logtype_driver, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(igc_logtype_init, pmd.net.igc.init, INFO);
+RTE_LOG_REGISTER(igc_logtype_driver, pmd.net.igc.driver, INFO);
diff --git a/drivers/net/ionic/ionic_ethdev.c b/drivers/net/ionic/ionic_ethdev.c
index 363f0cf00..800f6e5d6 100644
--- a/drivers/net/ionic/ionic_ethdev.c
+++ b/drivers/net/ionic/ionic_ethdev.c
@@ -59,8 +59,6 @@ static int  ionic_dev_xstats_get_names_by_id(struct rte_eth_dev *dev,
 static int  ionic_dev_fw_version_get(struct rte_eth_dev *eth_dev,
 	char *fw_version, size_t fw_size);
 
-int ionic_logtype;
-
 static const struct rte_pci_id pci_id_ionic_map[] = {
 	{ RTE_PCI_DEVICE(IONIC_PENSANDO_VENDOR_ID, IONIC_DEV_ID_ETH_PF) },
 	{ RTE_PCI_DEVICE(IONIC_PENSANDO_VENDOR_ID, IONIC_DEV_ID_ETH_VF) },
@@ -1318,10 +1316,4 @@ static struct rte_pci_driver rte_ionic_pmd = {
 RTE_PMD_REGISTER_PCI(net_ionic, rte_ionic_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_ionic, pci_id_ionic_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_ionic, "* igb_uio | uio_pci_generic | vfio-pci");
-
-RTE_INIT(ionic_init_log)
-{
-	ionic_logtype = rte_log_register("pmd.net.ionic");
-	if (ionic_logtype >= 0)
-		rte_log_set_level(ionic_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(ionic_logtype, pmd.net.ionic, NOTICE);
diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.c b/drivers/net/ipn3ke/ipn3ke_ethdev.c
index 5b5510f08..027be29bd 100644
--- a/drivers/net/ipn3ke/ipn3ke_ethdev.c
+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.c
@@ -26,8 +26,6 @@
 #include "ipn3ke_logs.h"
 #include "ipn3ke_ethdev.h"
 
-int ipn3ke_afu_logtype;
-
 static const struct rte_afu_uuid afu_uuid_ipn3ke_map[] = {
 	{ MAP_UUID_10G_LOW,  MAP_UUID_10G_HIGH },
 	{ IPN3KE_UUID_10G_LOW, IPN3KE_UUID_10G_HIGH },
@@ -587,10 +585,4 @@ static struct rte_afu_driver afu_ipn3ke_driver = {
 };
 
 RTE_PMD_REGISTER_AFU(net_ipn3ke_afu, afu_ipn3ke_driver);
-
-RTE_INIT(ipn3ke_afu_init_log)
-{
-	ipn3ke_afu_logtype = rte_log_register("pmd.afu.ipn3ke");
-	if (ipn3ke_afu_logtype >= 0)
-		rte_log_set_level(ipn3ke_afu_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(ipn3ke_afu_logtype, pmd.afu.ipn3ke, NOTICE);
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index f8a84c565..248f21d14 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -419,19 +419,6 @@ static int ixgbe_wait_for_link_up(struct ixgbe_hw *hw);
 		(r) = (h)->bitmap[idx] >> bit & 1;\
 	} while (0)
 
-int ixgbe_logtype_init;
-int ixgbe_logtype_driver;
-
-#ifdef RTE_LIBRTE_IXGBE_DEBUG_RX
-int ixgbe_logtype_rx;
-#endif
-#ifdef RTE_LIBRTE_IXGBE_DEBUG_TX
-int ixgbe_logtype_tx;
-#endif
-#ifdef RTE_LIBRTE_IXGBE_DEBUG_TX_FREE
-int ixgbe_logtype_tx_free;
-#endif
-
 /*
  * The set of PCI devices this driver supports
  */
@@ -9117,29 +9104,15 @@ RTE_PMD_REGISTER_KMOD_DEP(net_ixgbe_vf, "* igb_uio | vfio-pci");
 RTE_PMD_REGISTER_PARAM_STRING(net_ixgbe_vf,
 			      IXGBEVF_DEVARG_PFLINK_FULLCHK "=<0|1>");
 
-RTE_INIT(ixgbe_init_log)
-{
-	ixgbe_logtype_init = rte_log_register("pmd.net.ixgbe.init");
-	if (ixgbe_logtype_init >= 0)
-		rte_log_set_level(ixgbe_logtype_init, RTE_LOG_NOTICE);
-	ixgbe_logtype_driver = rte_log_register("pmd.net.ixgbe.driver");
-	if (ixgbe_logtype_driver >= 0)
-		rte_log_set_level(ixgbe_logtype_driver, RTE_LOG_NOTICE);
+RTE_LOG_REGISTER(ixgbe_logtype_init, pmd.net.ixgbe.init, NOTICE);
+RTE_LOG_REGISTER(ixgbe_logtype_driver, pmd.net.ixgbe.driver, NOTICE);
+
 #ifdef RTE_LIBRTE_IXGBE_DEBUG_RX
-	ixgbe_logtype_rx = rte_log_register("pmd.net.ixgbe.rx");
-	if (ixgbe_logtype_rx >= 0)
-		rte_log_set_level(ixgbe_logtype_rx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(ixgbe_logtype_rx, pmd.net.ixgbe.rx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_IXGBE_DEBUG_TX
-	ixgbe_logtype_tx = rte_log_register("pmd.net.ixgbe.tx");
-	if (ixgbe_logtype_tx >= 0)
-		rte_log_set_level(ixgbe_logtype_tx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(ixgbe_logtype_tx, pmd.net.ixgbe.tx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_IXGBE_DEBUG_TX_FREE
-	ixgbe_logtype_tx_free = rte_log_register("pmd.net.ixgbe.tx_free");
-	if (ixgbe_logtype_tx_free >= 0)
-		rte_log_set_level(ixgbe_logtype_tx_free, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(ixgbe_logtype_tx_free, pmd.net.ixgbe.tx_free, DEBUG);
 #endif
-}
diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c
index d88cb1778..cde98f0bb 100644
--- a/drivers/net/kni/rte_eth_kni.c
+++ b/drivers/net/kni/rte_eth_kni.c
@@ -67,7 +67,7 @@ static const struct rte_eth_link pmd_link = {
 };
 static int is_kni_initialized;
 
-static int eth_kni_logtype;
+RTE_LOG_REGISTER(eth_kni_logtype, pmd.net.kni, NOTICE);
 
 #define PMD_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, eth_kni_logtype, \
@@ -508,10 +508,3 @@ static struct rte_vdev_driver eth_kni_drv = {
 
 RTE_PMD_REGISTER_VDEV(net_kni, eth_kni_drv);
 RTE_PMD_REGISTER_PARAM_STRING(net_kni, ETH_KNI_NO_REQUEST_THREAD_ARG "=<int>");
-
-RTE_INIT(eth_kni_init_log)
-{
-	eth_kni_logtype = rte_log_register("pmd.net.kni");
-	if (eth_kni_logtype >= 0)
-		rte_log_set_level(eth_kni_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c
index ad4a51ecd..2258838c4 100644
--- a/drivers/net/liquidio/lio_ethdev.c
+++ b/drivers/net/liquidio/lio_ethdev.c
@@ -15,9 +15,6 @@
 #include "lio_ethdev.h"
 #include "lio_rxtx.h"
 
-int lio_logtype_init;
-int lio_logtype_driver;
-
 /* Default RSS key in use */
 static uint8_t lio_rss_key[40] = {
 	0x6D, 0x5A, 0x56, 0xDA, 0x25, 0x5B, 0x0E, 0xC2,
@@ -2161,13 +2158,5 @@ static struct rte_pci_driver rte_liovf_pmd = {
 RTE_PMD_REGISTER_PCI(net_liovf, rte_liovf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_liovf, pci_id_liovf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_liovf, "* igb_uio | vfio-pci");
-
-RTE_INIT(lio_init_log)
-{
-	lio_logtype_init = rte_log_register("pmd.net.liquidio.init");
-	if (lio_logtype_init >= 0)
-		rte_log_set_level(lio_logtype_init, RTE_LOG_NOTICE);
-	lio_logtype_driver = rte_log_register("pmd.net.liquidio.driver");
-	if (lio_logtype_driver >= 0)
-		rte_log_set_level(lio_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(lio_logtype_init, pmd.net.liquidio.init, NOTICE);
+RTE_LOG_REGISTER(lio_logtype_driver, pmd.net.liquidio.driver, NOTICE);
diff --git a/drivers/net/memif/rte_eth_memif.c b/drivers/net/memif/rte_eth_memif.c
index b6da9a8b4..c1c7e9f8d 100644
--- a/drivers/net/memif/rte_eth_memif.c
+++ b/drivers/net/memif/rte_eth_memif.c
@@ -1806,11 +1806,4 @@ RTE_PMD_REGISTER_PARAM_STRING(net_memif,
 			      ETH_MEMIF_ZC_ARG "=yes|no"
 			      ETH_MEMIF_SECRET_ARG "=<string>");
 
-int memif_logtype;
-
-RTE_INIT(memif_init_log)
-{
-	memif_logtype = rte_log_register("pmd.net.memif");
-	if (memif_logtype >= 0)
-		rte_log_set_level(memif_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(memif_logtype, pmd.net.memif, NOTICE);
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index 5d7202720..927222c81 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -64,9 +64,6 @@ static rte_spinlock_t mlx4_shared_data_lock = RTE_SPINLOCK_INITIALIZER;
 /* Process local data for secondary processes. */
 static struct mlx4_local_data mlx4_local_data;
 
-/** Driver-specific log messages type. */
-int mlx4_logtype;
-
 /** Configuration structure for device arguments. */
 struct mlx4_conf {
 	struct {
@@ -1281,16 +1278,14 @@ mlx4_glue_init(void)
 
 #endif
 
+/* Initialize driver log type. */
+RTE_LOG_REGISTER(mlx4_logtype, pmd.net.mlx4, NOTICE)
+
 /**
  * Driver initialization routine.
  */
 RTE_INIT(rte_mlx4_pmd_init)
 {
-	/* Initialize driver log type. */
-	mlx4_logtype = rte_log_register("pmd.net.mlx4");
-	if (mlx4_logtype >= 0)
-		rte_log_set_level(mlx4_logtype, RTE_LOG_NOTICE);
-
 	/*
 	 * MLX4_DEVICE_FATAL_CLEANUP tells ibv_destroy functions we
 	 * want to get success errno value in case of calling them
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 5c86f6fb9..16257a63a 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -173,8 +173,6 @@ static rte_spinlock_t mlx5_shared_data_lock = RTE_SPINLOCK_INITIALIZER;
 
 /* Process local data for secondary processes. */
 static struct mlx5_local_data mlx5_local_data;
-/** Driver-specific log messages type. */
-int mlx5_logtype;
 
 static LIST_HEAD(, mlx5_dev_ctx_shared) mlx5_dev_ctx_list =
 						LIST_HEAD_INITIALIZER();
@@ -1999,16 +1997,14 @@ struct rte_pci_driver mlx5_driver = {
 	.drv_flags = PCI_DRV_FLAGS,
 };
 
+/* Initialize driver log type. */
+RTE_LOG_REGISTER(mlx5_logtype, pmd.net.mlx5, NOTICE)
+
 /**
  * Driver initialization routine.
  */
 RTE_INIT(rte_mlx5_pmd_init)
 {
-	/* Initialize driver log type. */
-	mlx5_logtype = rte_log_register("pmd.net.mlx5");
-	if (mlx5_logtype >= 0)
-		rte_log_set_level(mlx5_logtype, RTE_LOG_NOTICE);
-
 	/* Build the static tables for Verbs conversion. */
 	mlx5_set_ptype_table();
 	mlx5_set_cksum_table();
diff --git a/drivers/net/mvneta/mvneta_ethdev.c b/drivers/net/mvneta/mvneta_ethdev.c
index 4aea87648..673a8e2b3 100644
--- a/drivers/net/mvneta/mvneta_ethdev.c
+++ b/drivers/net/mvneta/mvneta_ethdev.c
@@ -34,8 +34,6 @@
 /** Maximum length of a match string */
 #define MVNETA_MATCH_LEN 16
 
-int mvneta_logtype;
-
 static const char * const valid_args[] = {
 	MVNETA_IFACE_NAME_ARG,
 	NULL
@@ -982,10 +980,4 @@ static struct rte_vdev_driver pmd_mvneta_drv = {
 
 RTE_PMD_REGISTER_VDEV(net_mvneta, pmd_mvneta_drv);
 RTE_PMD_REGISTER_PARAM_STRING(net_mvneta, "iface=<ifc>");
-
-RTE_INIT(mvneta_init_log)
-{
-	mvneta_logtype = rte_log_register("pmd.net.mvneta");
-	if (mvneta_logtype >= 0)
-		rte_log_set_level(mvneta_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(mvneta_logtype, pmd.net.mvneta, NOTICE);
diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c
index b98b1fd66..75589f18e 100644
--- a/drivers/net/mvpp2/mrvl_ethdev.c
+++ b/drivers/net/mvpp2/mrvl_ethdev.c
@@ -84,8 +84,6 @@ static struct pp2_bpool *mrvl_port_to_bpool_lookup[RTE_MAX_ETHPORTS];
 static int mrvl_port_bpool_size[PP2_NUM_PKT_PROC][PP2_BPOOL_NUM_POOLS][RTE_MAX_LCORE];
 static uint64_t cookie_addr_high = MRVL_COOKIE_ADDR_INVALID;
 
-int mrvl_logtype;
-
 struct mrvl_ifnames {
 	const char *names[PP2_NUM_ETH_PPIO * PP2_NUM_PKT_PROC];
 	int idx;
@@ -3040,10 +3038,4 @@ static struct rte_vdev_driver pmd_mrvl_drv = {
 
 RTE_PMD_REGISTER_VDEV(net_mvpp2, pmd_mrvl_drv);
 RTE_PMD_REGISTER_ALIAS(net_mvpp2, eth_mvpp2);
-
-RTE_INIT(mrvl_init_log)
-{
-	mrvl_logtype = rte_log_register("pmd.net.mvpp2");
-	if (mrvl_logtype >= 0)
-		rte_log_set_level(mrvl_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(mrvl_logtype, pmd.net.mvpp2, NOTICE);
diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c
index ac182a548..fd91c0e49 100644
--- a/drivers/net/netvsc/hn_ethdev.c
+++ b/drivers/net/netvsc/hn_ethdev.c
@@ -45,9 +45,6 @@
 			    DEV_RX_OFFLOAD_VLAN_STRIP | \
 			    DEV_RX_OFFLOAD_RSS_HASH)
 
-int hn_logtype_init;
-int hn_logtype_driver;
-
 struct hn_xstats_name_off {
 	char name[RTE_ETH_XSTATS_NAME_SIZE];
 	unsigned int offset;
@@ -1121,13 +1118,5 @@ static struct rte_vmbus_driver rte_netvsc_pmd = {
 
 RTE_PMD_REGISTER_VMBUS(net_netvsc, rte_netvsc_pmd);
 RTE_PMD_REGISTER_KMOD_DEP(net_netvsc, "* uio_hv_generic");
-
-RTE_INIT(hn_init_log)
-{
-	hn_logtype_init = rte_log_register("pmd.net.netvsc.init");
-	if (hn_logtype_init >= 0)
-		rte_log_set_level(hn_logtype_init, RTE_LOG_NOTICE);
-	hn_logtype_driver = rte_log_register("pmd.net.netvsc.driver");
-	if (hn_logtype_driver >= 0)
-		rte_log_set_level(hn_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(hn_logtype_init, pmd.net.netvsc.init, NOTICE);
+RTE_LOG_REGISTER(hn_logtype_driver, pmd.net.netvsc.driver, NOTICE);
diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
index 2460ee199..88e3f01d6 100644
--- a/drivers/net/nfp/nfp_net.c
+++ b/drivers/net/nfp/nfp_net.c
@@ -3683,9 +3683,6 @@ static int nfp_pf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	return ret;
 }
 
-int nfp_logtype_init;
-int nfp_logtype_driver;
-
 static const struct rte_pci_id pci_id_nfp_pf_net_map[] = {
 	{
 		RTE_PCI_DEVICE(PCI_VENDOR_ID_NETRONOME,
@@ -3769,16 +3766,8 @@ RTE_PMD_REGISTER_PCI_TABLE(net_nfp_pf, pci_id_nfp_pf_net_map);
 RTE_PMD_REGISTER_PCI_TABLE(net_nfp_vf, pci_id_nfp_vf_net_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_nfp_pf, "* igb_uio | uio_pci_generic | vfio");
 RTE_PMD_REGISTER_KMOD_DEP(net_nfp_vf, "* igb_uio | uio_pci_generic | vfio");
-
-RTE_INIT(nfp_init_log)
-{
-	nfp_logtype_init = rte_log_register("pmd.net.nfp.init");
-	if (nfp_logtype_init >= 0)
-		rte_log_set_level(nfp_logtype_init, RTE_LOG_NOTICE);
-	nfp_logtype_driver = rte_log_register("pmd.net.nfp.driver");
-	if (nfp_logtype_driver >= 0)
-		rte_log_set_level(nfp_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(nfp_logtype_init, pmd.net.nfp.init, NOTICE);
+RTE_LOG_REGISTER(nfp_logtype_driver, pmd.net.nfp.driver, NOTICE);
 /*
  * Local variables:
  * c-file-style: "Linux"
diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index 11258ccea..8c779be7f 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c
@@ -73,7 +73,7 @@ static struct rte_eth_link pmd_link = {
 	.link_autoneg = ETH_LINK_FIXED,
 };
 
-static int eth_null_logtype;
+RTE_LOG_REGISTER(eth_null_logtype, pmd.net.null, NOTICE);
 
 #define PMD_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, eth_null_logtype, \
@@ -730,9 +730,3 @@ RTE_PMD_REGISTER_PARAM_STRING(net_null,
 	"copy=<int> "
 	ETH_NULL_PACKET_NO_RX_ARG "=0|1");
 
-RTE_INIT(eth_null_init_log)
-{
-	eth_null_logtype = rte_log_register("pmd.net.null");
-	if (eth_null_logtype >= 0)
-		rte_log_set_level(eth_null_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c
index d5371ae07..76c69294d 100644
--- a/drivers/net/octeontx/octeontx_ethdev.c
+++ b/drivers/net/octeontx/octeontx_ethdev.c
@@ -47,24 +47,9 @@ enum octeontx_link_speed {
 	OCTEONTX_LINK_SPEED_RESERVE2
 };
 
-int otx_net_logtype_mbox;
-int otx_net_logtype_init;
-int otx_net_logtype_driver;
-
-RTE_INIT(otx_net_init_log)
-{
-	otx_net_logtype_mbox = rte_log_register("pmd.net.octeontx.mbox");
-	if (otx_net_logtype_mbox >= 0)
-		rte_log_set_level(otx_net_logtype_mbox, RTE_LOG_NOTICE);
-
-	otx_net_logtype_init = rte_log_register("pmd.net.octeontx.init");
-	if (otx_net_logtype_init >= 0)
-		rte_log_set_level(otx_net_logtype_init, RTE_LOG_NOTICE);
-
-	otx_net_logtype_driver = rte_log_register("pmd.net.octeontx.driver");
-	if (otx_net_logtype_driver >= 0)
-		rte_log_set_level(otx_net_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(otx_net_logtype_mbox, pmd.net.octeontx.mbox, NOTICE);
+RTE_LOG_REGISTER(otx_net_logtype_init, pmd.net.octeontx.init, NOTICE);
+RTE_LOG_REGISTER(otx_net_logtype_driver, pmd.net.octeontx.driver, NOTICE);
 
 /* Parse integer from integer argument */
 static int
diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index 13a3d0ac7..60e393c92 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -135,7 +135,7 @@ static struct rte_eth_link pmd_link = {
 		.link_autoneg = ETH_LINK_FIXED,
 };
 
-static int eth_pcap_logtype;
+RTE_LOG_REGISTER(eth_pcap_logtype, pmd.net.pcap, NOTICE);
 
 #define PMD_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, eth_pcap_logtype, \
@@ -1589,9 +1589,3 @@ RTE_PMD_REGISTER_PARAM_STRING(net_pcap,
 	ETH_PCAP_PHY_MAC_ARG "=<int>"
 	ETH_PCAP_INFINITE_RX_ARG "=<0|1>");
 
-RTE_INIT(eth_pcap_init_log)
-{
-	eth_pcap_logtype = rte_log_register("pmd.net.pcap");
-	if (eth_pcap_logtype >= 0)
-		rte_log_set_level(eth_pcap_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/pfe/pfe_ethdev.c b/drivers/net/pfe/pfe_ethdev.c
index b1de866d3..368acfa55 100644
--- a/drivers/net/pfe/pfe_ethdev.c
+++ b/drivers/net/pfe/pfe_ethdev.c
@@ -40,8 +40,6 @@ unsigned int pfe_svr = SVR_LS1012A_REV1;
 static void *cbus_emac_base[3];
 static void *cbus_gpi_base[3];
 
-int pfe_logtype_pmd;
-
 /* pfe_gemac_init
  */
 static int
@@ -1181,10 +1179,4 @@ struct rte_vdev_driver pmd_pfe_drv = {
 
 RTE_PMD_REGISTER_VDEV(PFE_NAME_PMD, pmd_pfe_drv);
 RTE_PMD_REGISTER_PARAM_STRING(PFE_NAME_PMD, PFE_VDEV_GEM_ID_ARG "=<int> ");
-
-RTE_INIT(pfe_pmd_init_log)
-{
-	pfe_logtype_pmd = rte_log_register("pmd.net.pfe");
-	if (pfe_logtype_pmd >= 0)
-		rte_log_set_level(pfe_logtype_pmd, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(pfe_logtype_pmd, pmd.net.pfe, NOTICE);
diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c
index c4f8f1258..6107d583e 100644
--- a/drivers/net/qede/qede_ethdev.c
+++ b/drivers/net/qede/qede_ethdev.c
@@ -10,10 +10,6 @@
 #include <rte_version.h>
 #include <rte_kvargs.h>
 
-/* Globals */
-int qede_logtype_init;
-int qede_logtype_driver;
-
 static const struct qed_eth_ops *qed_ops;
 static int qede_eth_dev_uninit(struct rte_eth_dev *eth_dev);
 static int qede_eth_dev_init(struct rte_eth_dev *eth_dev);
@@ -2870,13 +2866,5 @@ RTE_PMD_REGISTER_KMOD_DEP(net_qede, "* igb_uio | uio_pci_generic | vfio-pci");
 RTE_PMD_REGISTER_PCI(net_qede_vf, rte_qedevf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_qede_vf, pci_id_qedevf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_qede_vf, "* igb_uio | vfio-pci");
-
-RTE_INIT(qede_init_log)
-{
-	qede_logtype_init = rte_log_register("pmd.net.qede.init");
-	if (qede_logtype_init >= 0)
-		rte_log_set_level(qede_logtype_init, RTE_LOG_NOTICE);
-	qede_logtype_driver = rte_log_register("pmd.net.qede.driver");
-	if (qede_logtype_driver >= 0)
-		rte_log_set_level(qede_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(qede_logtype_init, pmd.net.qede.init, NOTICE);
+RTE_LOG_REGISTER(qede_logtype_driver, pmd.net.qede.driver, NOTICE);
diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index f0fafa0c0..078df605a 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -61,7 +61,7 @@ static struct rte_eth_link pmd_link = {
 	.link_autoneg = ETH_LINK_FIXED,
 };
 
-static int eth_ring_logtype;
+RTE_LOG_REGISTER(eth_ring_logtype, pmd.net.ring, NOTICE);
 
 #define PMD_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, eth_ring_logtype, \
@@ -703,9 +703,3 @@ RTE_PMD_REGISTER_ALIAS(net_ring, eth_ring);
 RTE_PMD_REGISTER_PARAM_STRING(net_ring,
 	ETH_RING_NUMA_NODE_ACTION_ARG "=name:node:action(ATTACH|CREATE)");
 
-RTE_INIT(eth_ring_init_log)
-{
-	eth_ring_logtype = rte_log_register("pmd.net.ring");
-	if (eth_ring_logtype >= 0)
-		rte_log_set_level(eth_ring_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/softnic/rte_eth_softnic.c b/drivers/net/softnic/rte_eth_softnic.c
index 11723778f..866d17a93 100644
--- a/drivers/net/softnic/rte_eth_softnic.c
+++ b/drivers/net/softnic/rte_eth_softnic.c
@@ -80,7 +80,7 @@ static const struct softnic_conn_params conn_params_default = {
 	.msg_handle_arg = NULL,
 };
 
-static int pmd_softnic_logtype;
+RTE_LOG_REGISTER(pmd_softnic_logtype, pmd.net.softnic, NOTICE);
 
 #define PMD_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, pmd_softnic_logtype, \
@@ -690,14 +690,6 @@ RTE_PMD_REGISTER_PARAM_STRING(net_softnic,
 	PMD_PARAM_TM_QSIZE12 "=<uint32>"
 );
 
-
-RTE_INIT(pmd_softnic_init_log)
-{
-	pmd_softnic_logtype = rte_log_register("pmd.net.softnic");
-	if (pmd_softnic_logtype >= 0)
-		rte_log_set_level(pmd_softnic_logtype, RTE_LOG_NOTICE);
-}
-
 int
 rte_pmd_softnic_manage(uint16_t port_id)
 {
diff --git a/drivers/net/szedata2/rte_eth_szedata2.c b/drivers/net/szedata2/rte_eth_szedata2.c
index 821bb346c..30c888cd9 100644
--- a/drivers/net/szedata2/rte_eth_szedata2.c
+++ b/drivers/net/szedata2/rte_eth_szedata2.c
@@ -102,9 +102,6 @@ struct szedata2_tx_queue {
 	volatile uint64_t err_pkts;
 };
 
-int szedata2_logtype_init;
-int szedata2_logtype_driver;
-
 static struct rte_ether_addr eth_addr = {
 	.addr_bytes = { 0x00, 0x11, 0x17, 0x00, 0x00, 0x00 }
 };
@@ -1941,13 +1938,5 @@ RTE_PMD_REGISTER_PCI(RTE_SZEDATA2_DRIVER_NAME, szedata2_eth_driver);
 RTE_PMD_REGISTER_PCI_TABLE(RTE_SZEDATA2_DRIVER_NAME, rte_szedata2_pci_id_table);
 RTE_PMD_REGISTER_KMOD_DEP(RTE_SZEDATA2_DRIVER_NAME,
 	"* combo6core & combov3 & szedata2 & ( szedata2_cv3 | szedata2_cv3_fdt )");
-
-RTE_INIT(szedata2_init_log)
-{
-	szedata2_logtype_init = rte_log_register("pmd.net.szedata2.init");
-	if (szedata2_logtype_init >= 0)
-		rte_log_set_level(szedata2_logtype_init, RTE_LOG_NOTICE);
-	szedata2_logtype_driver = rte_log_register("pmd.net.szedata2.driver");
-	if (szedata2_logtype_driver >= 0)
-		rte_log_set_level(szedata2_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(szedata2_logtype_init, pmd.net.szedata2.init, NOTICE);
+RTE_LOG_REGISTER(szedata2_logtype_driver, pmd.net.szedata2.driver, NOTICE);
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 7081ae23e..339f24bf8 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -2494,11 +2494,4 @@ RTE_PMD_REGISTER_PARAM_STRING(net_tap,
 			      ETH_TAP_IFACE_ARG "=<string> "
 			      ETH_TAP_MAC_ARG "=" ETH_TAP_MAC_ARG_FMT " "
 			      ETH_TAP_REMOTE_ARG "=<string>");
-int tap_logtype;
-
-RTE_INIT(tap_init_log)
-{
-	tap_logtype = rte_log_register("pmd.net.tap");
-	if (tap_logtype >= 0)
-		rte_log_set_level(tap_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(tap_logtype, pmd.net.tap, NOTICE);
diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c
index bfda0ab0e..d955a7ee2 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -44,10 +44,6 @@
 #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,
@@ -55,20 +51,9 @@ static void nicvf_vf_stop(struct rte_eth_dev *dev, struct nicvf *nic,
 static int nicvf_vlan_offload_config(struct rte_eth_dev *dev, int mask);
 static int nicvf_vlan_offload_set(struct rte_eth_dev *dev, int mask);
 
-RTE_INIT(nicvf_init_log)
-{
-	nicvf_logtype_mbox = rte_log_register("pmd.net.thunderx.mbox");
-	if (nicvf_logtype_mbox >= 0)
-		rte_log_set_level(nicvf_logtype_mbox, RTE_LOG_NOTICE);
-
-	nicvf_logtype_init = rte_log_register("pmd.net.thunderx.init");
-	if (nicvf_logtype_init >= 0)
-		rte_log_set_level(nicvf_logtype_init, RTE_LOG_NOTICE);
-
-	nicvf_logtype_driver = rte_log_register("pmd.net.thunderx.driver");
-	if (nicvf_logtype_driver >= 0)
-		rte_log_set_level(nicvf_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(nicvf_logtype_mbox, pmd.net.thunderx.mbox, NOTICE);
+RTE_LOG_REGISTER(nicvf_logtype_init, pmd.net.thunderx.init, NOTICE);
+RTE_LOG_REGISTER(nicvf_logtype_driver, pmd.net.thunderx.driver, NOTICE);
 
 static void
 nicvf_link_status_update(struct nicvf *nic,
diff --git a/drivers/net/vdev_netvsc/vdev_netvsc.c b/drivers/net/vdev_netvsc/vdev_netvsc.c
index 9ed74a1d6..1ecb0b3e6 100644
--- a/drivers/net/vdev_netvsc/vdev_netvsc.c
+++ b/drivers/net/vdev_netvsc/vdev_netvsc.c
@@ -48,6 +48,8 @@
 #define NETVSC_CLASS_ID "{f8615163-df3e-46c5-913f-f2d2f965ed0e}"
 #define NETVSC_MAX_ROUTE_LINE_SIZE 300
 
+RTE_LOG_REGISTER(vdev_netvsc_logtype, pmd.net.vdev_netvsc, NOTICE);
+
 #define DRV_LOG(level, ...) \
 	rte_log(RTE_LOG_ ## level, \
 		vdev_netvsc_logtype, \
@@ -55,9 +57,6 @@
 			RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
 		RTE_FMT_TAIL(__VA_ARGS__,)))
 
-/** Driver-specific log messages type. */
-static int vdev_netvsc_logtype;
-
 /** Context structure for a vdev_netvsc instance. */
 struct vdev_netvsc_ctx {
 	LIST_ENTRY(vdev_netvsc_ctx) entry; /**< Next entry in list. */
@@ -774,14 +773,6 @@ RTE_PMD_REGISTER_PARAM_STRING(net_vdev_netvsc,
 			      VDEV_NETVSC_ARG_FORCE "=<int> "
 			      VDEV_NETVSC_ARG_IGNORE "=<int>");
 
-/** Initialize driver log type. */
-RTE_INIT(vdev_netvsc_init_log)
-{
-	vdev_netvsc_logtype = rte_log_register("pmd.net.vdev_netvsc");
-	if (vdev_netvsc_logtype >= 0)
-		rte_log_set_level(vdev_netvsc_logtype, RTE_LOG_NOTICE);
-}
-
 /** Compare function for vdev find device operation. */
 static int
 vdev_netvsc_cmp_rte_device(const struct rte_device *dev1,
diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index 808e670f1..bfacdcb98 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -18,7 +18,7 @@
 
 #include "rte_eth_vhost.h"
 
-static int vhost_logtype;
+RTE_LOG_REGISTER(vhost_logtype, pmd.net.vhost, NOTICE);
 
 #define VHOST_LOG(level, ...) \
 	rte_log(RTE_LOG_ ## level, vhost_logtype, __VA_ARGS__)
@@ -1571,9 +1571,3 @@ RTE_PMD_REGISTER_PARAM_STRING(net_vhost,
 	"linear-buffer=<0|1> "
 	"ext-buffer=<0|1>");
 
-RTE_INIT(vhost_init_log)
-{
-	vhost_logtype = rte_log_register("pmd.net.vhost");
-	if (vhost_logtype >= 0)
-		rte_log_set_level(vhost_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 312871cb4..dc0093bdf 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -85,9 +85,6 @@ static int virtio_dev_queue_stats_mapping_set(
 	uint8_t stat_idx,
 	uint8_t is_rx);
 
-int virtio_logtype_init;
-int virtio_logtype_driver;
-
 static void virtio_notify_peers(struct rte_eth_dev *dev);
 static void virtio_ack_link_announce(struct rte_eth_dev *dev);
 
@@ -2659,13 +2656,5 @@ __rte_unused uint8_t is_rx)
 RTE_PMD_EXPORT_NAME(net_virtio, __COUNTER__);
 RTE_PMD_REGISTER_PCI_TABLE(net_virtio, pci_id_virtio_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_virtio, "* igb_uio | uio_pci_generic | vfio-pci");
-
-RTE_INIT(virtio_init_log)
-{
-	virtio_logtype_init = rte_log_register("pmd.net.virtio.init");
-	if (virtio_logtype_init >= 0)
-		rte_log_set_level(virtio_logtype_init, RTE_LOG_NOTICE);
-	virtio_logtype_driver = rte_log_register("pmd.net.virtio.driver");
-	if (virtio_logtype_driver >= 0)
-		rte_log_set_level(virtio_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(virtio_logtype_init, pmd.net.virtio.init, NOTICE);
+RTE_LOG_REGISTER(virtio_logtype_driver, pmd.net.virtio.driver, NOTICE);
diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c
index c6e11ad2d..815fba2f5 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethdev.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c
@@ -95,9 +95,6 @@ static int vmxnet3_mac_addr_set(struct rte_eth_dev *dev,
 				 struct rte_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
  */
@@ -1464,13 +1461,5 @@ 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)
-{
-	vmxnet3_logtype_init = rte_log_register("pmd.net.vmxnet3.init");
-	if (vmxnet3_logtype_init >= 0)
-		rte_log_set_level(vmxnet3_logtype_init, RTE_LOG_NOTICE);
-	vmxnet3_logtype_driver = rte_log_register("pmd.net.vmxnet3.driver");
-	if (vmxnet3_logtype_driver >= 0)
-		rte_log_set_level(vmxnet3_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(vmxnet3_logtype_init, pmd.net.vmxnet3.init, NOTICE);
+RTE_LOG_REGISTER(vmxnet3_logtype_driver, pmd.net.vmxnet3.driver, NOTICE);
-- 
2.27.0


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

* [dpdk-dev] [PATCH v4 06/13] drivers/mempool: use log register macro
  2020-07-01 10:44     ` [dpdk-dev] [PATCH v4 00/13] rte_log registration usage improvement jerinj
                         ` (4 preceding siblings ...)
  2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 05/13] drivers/net: " jerinj
@ 2020-07-01 10:44       ` jerinj
  2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 07/13] drivers/event: " jerinj
                         ` (7 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01 10:44 UTC (permalink / raw)
  To: dev, Hemant Agrawal, Sachin Saxena, Harman Kalra
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Sachin Saxena <sachin.saxena@oss.nxp.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/mempool/dpaa/dpaa_mempool.c       | 10 ++--------
 drivers/mempool/dpaa2/dpaa2_hw_mempool.c  | 10 +---------
 drivers/mempool/octeontx/octeontx_fpavf.c | 10 +---------
 3 files changed, 4 insertions(+), 26 deletions(-)

diff --git a/drivers/mempool/dpaa/dpaa_mempool.c b/drivers/mempool/dpaa/dpaa_mempool.c
index 451e2d5d5..8d1da8028 100644
--- a/drivers/mempool/dpaa/dpaa_mempool.c
+++ b/drivers/mempool/dpaa/dpaa_mempool.c
@@ -36,7 +36,8 @@ struct dpaa_memseg_list rte_dpaa_memsegs
 	= TAILQ_HEAD_INITIALIZER(rte_dpaa_memsegs);
 
 struct dpaa_bp_info *rte_dpaa_bpid_info;
-int dpaa_logtype_mempool;
+
+RTE_LOG_REGISTER(dpaa_logtype_mempool, mempool.dpaa, NOTICE);
 
 static int
 dpaa_mbuf_create_pool(struct rte_mempool *mp)
@@ -357,10 +358,3 @@ static const struct rte_mempool_ops dpaa_mpool_ops = {
 };
 
 MEMPOOL_REGISTER_OPS(dpaa_mpool_ops);
-
-RTE_INIT(dpaa_mp_init_log)
-{
-	dpaa_logtype_mempool = rte_log_register("mempool.dpaa");
-	if (dpaa_logtype_mempool >= 0)
-		rte_log_set_level(dpaa_logtype_mempool, RTE_LOG_NOTICE);
-}
diff --git a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
index fa9b53e64..97ce08d78 100644
--- a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
+++ b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
@@ -36,9 +36,6 @@
 struct dpaa2_bp_info *rte_dpaa2_bpid_info;
 static struct dpaa2_bp_list *h_bp_list;
 
-/* Dynamic logging identified for mempool */
-int dpaa2_logtype_mempool;
-
 static int
 rte_hw_mbuf_create_pool(struct rte_mempool *mp)
 {
@@ -454,9 +451,4 @@ static const struct rte_mempool_ops dpaa2_mpool_ops = {
 
 MEMPOOL_REGISTER_OPS(dpaa2_mpool_ops);
 
-RTE_INIT(dpaa2_mempool_init_log)
-{
-	dpaa2_logtype_mempool = rte_log_register("mempool.dpaa2");
-	if (dpaa2_logtype_mempool >= 0)
-		rte_log_set_level(dpaa2_logtype_mempool, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa2_logtype_mempool, mempool.dpaa2, NOTICE);
diff --git a/drivers/mempool/octeontx/octeontx_fpavf.c b/drivers/mempool/octeontx/octeontx_fpavf.c
index 0ff234913..339da7824 100644
--- a/drivers/mempool/octeontx/octeontx_fpavf.c
+++ b/drivers/mempool/octeontx/octeontx_fpavf.c
@@ -105,15 +105,7 @@ struct octeontx_fpadev {
 
 static struct octeontx_fpadev fpadev;
 
-int octeontx_logtype_fpavf;
-int octeontx_logtype_fpavf_mbox;
-
-RTE_INIT(otx_pool_init_log)
-{
-	octeontx_logtype_fpavf = rte_log_register("pmd.mempool.octeontx");
-	if (octeontx_logtype_fpavf >= 0)
-		rte_log_set_level(octeontx_logtype_fpavf, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(octeontx_logtype_fpavf, pmd.mempool.octeontx, NOTICE);
 
 /* lock is taken by caller */
 static int
-- 
2.27.0


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

* [dpdk-dev] [PATCH v4 07/13] drivers/event: use log register macro
  2020-07-01 10:44     ` [dpdk-dev] [PATCH v4 00/13] rte_log registration usage improvement jerinj
                         ` (5 preceding siblings ...)
  2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 06/13] drivers/mempool: " jerinj
@ 2020-07-01 10:44       ` jerinj
  2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 08/13] drivers/crypto: " jerinj
                         ` (6 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01 10:44 UTC (permalink / raw)
  To: dev, Hemant Agrawal, Nipun Gupta, Jerin Jacob, Pavan Nikhilesh,
	Liang Ma, Peter Mccarthy, Harry van Haaren
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena, adamx.dybkowski

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/event/dpaa/dpaa_eventdev.c   |  8 +-------
 drivers/event/dpaa2/dpaa2_eventdev.c | 10 +---------
 drivers/event/octeontx/ssovf_evdev.c |  8 +-------
 drivers/event/octeontx/timvf_evdev.c |  9 +--------
 drivers/event/opdl/opdl_evdev.c      |  8 +-------
 drivers/event/opdl/opdl_ring.c       |  2 --
 drivers/event/sw/sw_evdev.c          | 11 +----------
 7 files changed, 6 insertions(+), 50 deletions(-)

diff --git a/drivers/event/dpaa/dpaa_eventdev.c b/drivers/event/dpaa/dpaa_eventdev.c
index 5a018d487..e78728b7e 100644
--- a/drivers/event/dpaa/dpaa_eventdev.c
+++ b/drivers/event/dpaa/dpaa_eventdev.c
@@ -46,7 +46,7 @@
  * Eventqueue = Channel Instance
  * 1 Eventdev can have N Eventqueue
  */
-int dpaa_logtype_eventdev;
+RTE_LOG_REGISTER(dpaa_logtype_eventdev, pmd.event.dpaa, NOTICE);
 
 #define DISABLE_INTR_MODE "disable_intr"
 
@@ -1069,9 +1069,3 @@ static struct rte_vdev_driver vdev_eventdev_dpaa_pmd = {
 RTE_PMD_REGISTER_VDEV(EVENTDEV_NAME_DPAA_PMD, vdev_eventdev_dpaa_pmd);
 RTE_PMD_REGISTER_PARAM_STRING(EVENTDEV_NAME_DPAA_PMD,
 		DISABLE_INTR_MODE "=<int>");
-RTE_INIT(dpaa_event_init_log)
-{
-	dpaa_logtype_eventdev = rte_log_register("pmd.event.dpaa");
-	if (dpaa_logtype_eventdev >= 0)
-		rte_log_set_level(dpaa_logtype_eventdev, RTE_LOG_NOTICE);
-}
diff --git a/drivers/event/dpaa2/dpaa2_eventdev.c b/drivers/event/dpaa2/dpaa2_eventdev.c
index a196ad4c6..a545baf34 100644
--- a/drivers/event/dpaa2/dpaa2_eventdev.c
+++ b/drivers/event/dpaa2/dpaa2_eventdev.c
@@ -48,8 +48,6 @@
  * Soft Event Flow is DPCI Instance
  */
 
-/* Dynamic logging identified for mempool */
-int dpaa2_logtype_event;
 #define DPAA2_EV_TX_RETRY_COUNT 10000
 
 static uint16_t
@@ -1205,10 +1203,4 @@ static struct rte_vdev_driver vdev_eventdev_dpaa2_pmd = {
 };
 
 RTE_PMD_REGISTER_VDEV(EVENTDEV_NAME_DPAA2_PMD, vdev_eventdev_dpaa2_pmd);
-
-RTE_INIT(dpaa2_eventdev_init_log)
-{
-	dpaa2_logtype_event = rte_log_register("pmd.event.dpaa2");
-	if (dpaa2_logtype_event >= 0)
-		rte_log_set_level(dpaa2_logtype_event, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa2_logtype_event, pmd.event.dpaa2, NOTICE);
diff --git a/drivers/event/octeontx/ssovf_evdev.c b/drivers/event/octeontx/ssovf_evdev.c
index 1b1a5d939..4fc4e8f7e 100644
--- a/drivers/event/octeontx/ssovf_evdev.c
+++ b/drivers/event/octeontx/ssovf_evdev.c
@@ -20,15 +20,9 @@
 #include "ssovf_evdev.h"
 #include "timvf_evdev.h"
 
-int otx_logtype_ssovf;
 static uint8_t timvf_enable_stats;
 
-RTE_INIT(otx_ssovf_init_log)
-{
-	otx_logtype_ssovf = rte_log_register("pmd.event.octeontx");
-	if (otx_logtype_ssovf >= 0)
-		rte_log_set_level(otx_logtype_ssovf, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(otx_logtype_ssovf, pmd.event.octeontx, NOTICE);
 
 /* SSOPF Mailbox messages */
 
diff --git a/drivers/event/octeontx/timvf_evdev.c b/drivers/event/octeontx/timvf_evdev.c
index caa129087..c61aacacc 100644
--- a/drivers/event/octeontx/timvf_evdev.c
+++ b/drivers/event/octeontx/timvf_evdev.c
@@ -4,14 +4,7 @@
 
 #include "timvf_evdev.h"
 
-int otx_logtype_timvf;
-
-RTE_INIT(otx_timvf_init_log)
-{
-	otx_logtype_timvf = rte_log_register("pmd.event.octeontx.timer");
-	if (otx_logtype_timvf >= 0)
-		rte_log_set_level(otx_logtype_timvf, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(otx_logtype_timvf, pmd.event.octeontx.timer, NOTICE);
 
 struct __rte_packed timvf_mbox_dev_info {
 	uint64_t ring_active[4];
diff --git a/drivers/event/opdl/opdl_evdev.c b/drivers/event/opdl/opdl_evdev.c
index 3beca8957..9b2f75fe3 100644
--- a/drivers/event/opdl/opdl_evdev.c
+++ b/drivers/event/opdl/opdl_evdev.c
@@ -754,13 +754,7 @@ static struct rte_vdev_driver evdev_opdl_pmd_drv = {
 	.remove = opdl_remove
 };
 
-RTE_INIT(opdl_init_log)
-{
-	opdl_logtype_driver = rte_log_register("pmd.event.opdl.driver");
-	if (opdl_logtype_driver >= 0)
-		rte_log_set_level(opdl_logtype_driver, RTE_LOG_INFO);
-}
-
+RTE_LOG_REGISTER(opdl_logtype_driver, pmd.event.opdl.driver, INFO);
 
 RTE_PMD_REGISTER_VDEV(EVENTDEV_NAME_OPDL_PMD, evdev_opdl_pmd_drv);
 RTE_PMD_REGISTER_PARAM_STRING(event_opdl, NUMA_NODE_ARG "=<int>"
diff --git a/drivers/event/opdl/opdl_ring.c b/drivers/event/opdl/opdl_ring.c
index c8d19fef5..69392b56b 100644
--- a/drivers/event/opdl/opdl_ring.c
+++ b/drivers/event/opdl/opdl_ring.c
@@ -31,8 +31,6 @@
 #define OPDL_OPA_MASK    (0xFF)
 #define OPDL_OPA_OFFSET  (0x38)
 
-int opdl_logtype_driver;
-
 /* Types of dependency between stages */
 enum dep_type {
 	DEP_NONE = 0,  /* no dependency */
diff --git a/drivers/event/sw/sw_evdev.c b/drivers/event/sw/sw_evdev.c
index fb8e8bebb..98dae7164 100644
--- a/drivers/event/sw/sw_evdev.c
+++ b/drivers/event/sw/sw_evdev.c
@@ -1083,13 +1083,4 @@ static struct rte_vdev_driver evdev_sw_pmd_drv = {
 RTE_PMD_REGISTER_VDEV(EVENTDEV_NAME_SW_PMD, evdev_sw_pmd_drv);
 RTE_PMD_REGISTER_PARAM_STRING(event_sw, NUMA_NODE_ARG "=<int> "
 		SCHED_QUANTA_ARG "=<int>" CREDIT_QUANTA_ARG "=<int>");
-
-/* declared extern in header, for access from other .c files */
-int eventdev_sw_log_level;
-
-RTE_INIT(evdev_sw_init_log)
-{
-	eventdev_sw_log_level = rte_log_register("pmd.event.sw");
-	if (eventdev_sw_log_level >= 0)
-		rte_log_set_level(eventdev_sw_log_level, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(eventdev_sw_log_level, pmd.event.sw, NOTICE);
-- 
2.27.0


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

* [dpdk-dev] [PATCH v4 08/13] drivers/crypto: use log register macro
  2020-07-01 10:44     ` [dpdk-dev] [PATCH v4 00/13] rte_log registration usage improvement jerinj
                         ` (6 preceding siblings ...)
  2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 07/13] drivers/event: " jerinj
@ 2020-07-01 10:44       ` jerinj
  2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 09/13] drivers/compress: " jerinj
                         ` (5 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01 10:44 UTC (permalink / raw)
  To: dev, Declan Doherty, Pablo de Lara, Gagandeep Singh,
	Hemant Agrawal, Akhil Goyal, Michael Shamis, Liron Himi,
	Nagadheeraj Rottela, Srikanth Jampala, Anoob Joseph,
	Ankur Dwivedi, Fan Zhang, Jay Zhou
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c      |  8 +---
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c    |  8 +---
 drivers/crypto/caam_jr/caam_jr.c              |  8 +---
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c   | 11 +-----
 drivers/crypto/dpaa_sec/dpaa_sec.c            | 10 +----
 drivers/crypto/kasumi/rte_kasumi_pmd.c        |  6 +--
 drivers/crypto/mvsam/rte_mrvl_pmd.c           |  7 +---
 drivers/crypto/nitrox/nitrox_logs.c           |  9 +----
 drivers/crypto/null/null_crypto_pmd.c         |  7 +---
 drivers/crypto/octeontx/otx_cryptodev.c       | 10 +----
 drivers/crypto/octeontx2/otx2_cryptodev.c     | 12 +-----
 drivers/crypto/openssl/rte_openssl_pmd.c      |  7 +---
 .../scheduler/rte_cryptodev_scheduler.c       |  8 +---
 drivers/crypto/snow3g/rte_snow3g_pmd.c        |  7 +---
 drivers/crypto/virtio/virtio_cryptodev.c      | 39 ++++---------------
 drivers/crypto/zuc/rte_zuc_pmd.c              |  7 +---
 16 files changed, 23 insertions(+), 141 deletions(-)

diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
index d213d05b9..1d2a0ce00 100644
--- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
+++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
@@ -13,8 +13,6 @@
 
 #include "aesni_gcm_pmd_private.h"
 
-int aesni_gcm_logtype_driver;
-
 static uint8_t cryptodev_driver_id;
 
 /* setup session handlers */
@@ -889,8 +887,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_AESNI_GCM_PMD,
 	"socket_id=<int>");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(aesni_gcm_crypto_drv, aesni_gcm_pmd_drv.driver,
 		cryptodev_driver_id);
-
-RTE_INIT(aesni_gcm_init_log)
-{
-	aesni_gcm_logtype_driver = rte_log_register("pmd.crypto.aesni_gcm");
-}
+RTE_LOG_REGISTER(aesni_gcm_logtype_driver, pmd.crypto.aesni_gcm, NOTICE);
diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
index 2d688f4d3..9d0d9f4d7 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
@@ -15,8 +15,6 @@
 
 #include "aesni_mb_pmd_private.h"
 
-int aesni_mb_logtype_driver;
-
 #define AES_CCM_DIGEST_MIN_LEN 4
 #define AES_CCM_DIGEST_MAX_LEN 16
 #define HMAC_MAX_BLOCK_SIZE 128
@@ -1744,8 +1742,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_AESNI_MB_PMD,
 RTE_PMD_REGISTER_CRYPTO_DRIVER(aesni_mb_crypto_drv,
 		cryptodev_aesni_mb_pmd_drv.driver,
 		cryptodev_driver_id);
-
-RTE_INIT(aesni_mb_init_log)
-{
-	aesni_mb_logtype_driver = rte_log_register("pmd.crypto.aesni_mb");
-}
+RTE_LOG_REGISTER(aesni_mb_logtype_driver, pmd.crypto.aesni_mb, NOTICE);
diff --git a/drivers/crypto/caam_jr/caam_jr.c b/drivers/crypto/caam_jr/caam_jr.c
index caf238677..49a35d614 100644
--- a/drivers/crypto/caam_jr/caam_jr.c
+++ b/drivers/crypto/caam_jr/caam_jr.c
@@ -35,7 +35,6 @@
 #endif
 #define CRYPTODEV_NAME_CAAM_JR_PMD	crypto_caam_jr
 static uint8_t cryptodev_driver_id;
-int caam_jr_logtype;
 
 /* Lists the states possible for the SEC user space driver. */
 enum sec_driver_state_e {
@@ -2477,9 +2476,4 @@ RTE_INIT(caam_jr_init)
 	sec_job_rings_init();
 }
 
-RTE_INIT(caam_jr_init_log)
-{
-	caam_jr_logtype = rte_log_register("pmd.crypto.caam");
-	if (caam_jr_logtype >= 0)
-		rte_log_set_level(caam_jr_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(caam_jr_logtype, pmd.crypto.caam, NOTICE);
diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index 63e7d930a..12f833136 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
@@ -58,8 +58,6 @@
 
 static uint8_t cryptodev_driver_id;
 
-int dpaa2_logtype_sec;
-
 #ifdef RTE_LIBRTE_SECURITY
 static inline int
 build_proto_compound_sg_fd(dpaa2_sec_session *sess,
@@ -3918,11 +3916,4 @@ static struct cryptodev_driver dpaa2_sec_crypto_drv;
 RTE_PMD_REGISTER_DPAA2(CRYPTODEV_NAME_DPAA2_SEC_PMD, rte_dpaa2_sec_driver);
 RTE_PMD_REGISTER_CRYPTO_DRIVER(dpaa2_sec_crypto_drv,
 		rte_dpaa2_sec_driver.driver, cryptodev_driver_id);
-
-RTE_INIT(dpaa2_sec_init_log)
-{
-	/* Bus level logs */
-	dpaa2_logtype_sec = rte_log_register("pmd.crypto.dpaa2");
-	if (dpaa2_logtype_sec >= 0)
-		rte_log_set_level(dpaa2_logtype_sec, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa2_logtype_sec, pmd.crypto.dpaa2, NOTICE);
diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c
index 66ee0ba0c..d9fa8bb36 100644
--- a/drivers/crypto/dpaa_sec/dpaa_sec.c
+++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
@@ -43,8 +43,6 @@
 #include <dpaa_sec_log.h>
 #include <dpaax_iova_table.h>
 
-int dpaa_logtype_sec;
-
 static uint8_t cryptodev_driver_id;
 
 static __thread struct rte_crypto_op **dpaa_sec_ops;
@@ -3520,10 +3518,4 @@ static struct cryptodev_driver dpaa_sec_crypto_drv;
 RTE_PMD_REGISTER_DPAA(CRYPTODEV_NAME_DPAA_SEC_PMD, rte_dpaa_sec_driver);
 RTE_PMD_REGISTER_CRYPTO_DRIVER(dpaa_sec_crypto_drv, rte_dpaa_sec_driver.driver,
 		cryptodev_driver_id);
-
-RTE_INIT(dpaa_sec_init_log)
-{
-	dpaa_logtype_sec = rte_log_register("pmd.crypto.dpaa");
-	if (dpaa_logtype_sec >= 0)
-		rte_log_set_level(dpaa_logtype_sec, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa_logtype_sec, pmd.crypto.dpaa, NOTICE);
diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd.c b/drivers/crypto/kasumi/rte_kasumi_pmd.c
index 73077e3d9..c3f0dfc2f 100644
--- a/drivers/crypto/kasumi/rte_kasumi_pmd.c
+++ b/drivers/crypto/kasumi/rte_kasumi_pmd.c
@@ -17,7 +17,6 @@
 #define KASUMI_MAX_BURST 4
 #define BYTE_LEN 8
 
-int kasumi_logtype_driver;
 static uint8_t cryptodev_driver_id;
 
 /** Get xform chain order. */
@@ -639,7 +638,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_KASUMI_PMD,
 RTE_PMD_REGISTER_CRYPTO_DRIVER(kasumi_crypto_drv,
 		cryptodev_kasumi_pmd_drv.driver, cryptodev_driver_id);
 
-RTE_INIT(kasumi_init_log)
-{
-	kasumi_logtype_driver = rte_log_register("pmd.crypto.kasumi");
-}
+RTE_LOG_REGISTER(kasumi_logtype_driver, pmd.crypto.kasumi, NOTICE);
diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd.c b/drivers/crypto/mvsam/rte_mrvl_pmd.c
index 63782ce97..aaa40dced 100644
--- a/drivers/crypto/mvsam/rte_mrvl_pmd.c
+++ b/drivers/crypto/mvsam/rte_mrvl_pmd.c
@@ -19,7 +19,6 @@
 #define MRVL_PMD_MAX_NB_SESS_ARG		("max_nb_sessions")
 #define MRVL_PMD_DEFAULT_MAX_NB_SESSIONS	2048
 
-int mrvl_logtype_driver;
 static uint8_t cryptodev_driver_id;
 
 struct mrvl_pmd_init_params {
@@ -1020,8 +1019,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_MRVL_PMD,
 	"socket_id=<int>");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(mrvl_crypto_drv, cryptodev_mrvl_pmd_drv.driver,
 		cryptodev_driver_id);
-
-RTE_INIT(crypto_mrvl_init_log)
-{
-	mrvl_logtype_driver = rte_log_register("pmd.crypto.mvsam");
-}
+RTE_LOG_REGISTER(mrvl_logtype_driver, pmd.crypto.mvsam, NOTICE);
diff --git a/drivers/crypto/nitrox/nitrox_logs.c b/drivers/crypto/nitrox/nitrox_logs.c
index 007056cb4..26395159a 100644
--- a/drivers/crypto/nitrox/nitrox_logs.c
+++ b/drivers/crypto/nitrox/nitrox_logs.c
@@ -4,11 +4,4 @@
 
 #include <rte_log.h>
 
-int nitrox_logtype;
-
-RTE_INIT(nitrox_init_log)
-{
-	nitrox_logtype = rte_log_register("pmd.crypto.nitrox");
-	if (nitrox_logtype >= 0)
-		rte_log_set_level(nitrox_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(nitrox_logtype, pmd.crypto.nitrox, NOTICE);
diff --git a/drivers/crypto/null/null_crypto_pmd.c b/drivers/crypto/null/null_crypto_pmd.c
index 7b0b9d42b..e04042e75 100644
--- a/drivers/crypto/null/null_crypto_pmd.c
+++ b/drivers/crypto/null/null_crypto_pmd.c
@@ -10,7 +10,6 @@
 #include "null_crypto_pmd_private.h"
 
 static uint8_t cryptodev_driver_id;
-int null_logtype_driver;
 
 /** verify and set session parameters */
 int
@@ -249,8 +248,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_NULL_PMD,
 	"socket_id=<int>");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(null_crypto_drv, cryptodev_null_pmd_drv.driver,
 		cryptodev_driver_id);
-
-RTE_INIT(null_init_log)
-{
-	null_logtype_driver = rte_log_register("pmd.crypto.null");
-}
+RTE_LOG_REGISTER(null_logtype_driver, pmd.crypto.null, INFO);
diff --git a/drivers/crypto/octeontx/otx_cryptodev.c b/drivers/crypto/octeontx/otx_cryptodev.c
index ddece1311..5ce1cf82f 100644
--- a/drivers/crypto/octeontx/otx_cryptodev.c
+++ b/drivers/crypto/octeontx/otx_cryptodev.c
@@ -15,7 +15,6 @@
 #include "cpt_pmd_logs.h"
 
 uint8_t otx_cryptodev_driver_id;
-int otx_cpt_logtype;
 
 static struct rte_pci_id pci_id_cpt_table[] = {
 	{
@@ -112,11 +111,4 @@ RTE_PMD_REGISTER_PCI_TABLE(CRYPTODEV_NAME_OCTEONTX_PMD, pci_id_cpt_table);
 RTE_PMD_REGISTER_KMOD_DEP(CRYPTODEV_NAME_OCTEONTX_PMD, "vfio-pci");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(otx_cryptodev_drv, otx_cryptodev_pmd.driver,
 		otx_cryptodev_driver_id);
-
-RTE_INIT(otx_cpt_init_log)
-{
-	/* Bus level logs */
-	otx_cpt_logtype = rte_log_register("pmd.crypto.octeontx");
-	if (otx_cpt_logtype >= 0)
-		rte_log_set_level(otx_cpt_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(otx_cpt_logtype, pmd.crypto.octeontx, NOTICE);
diff --git a/drivers/crypto/octeontx2/otx2_cryptodev.c b/drivers/crypto/octeontx2/otx2_cryptodev.c
index 6ffbc2eb7..50cbb13d8 100644
--- a/drivers/crypto/octeontx2/otx2_cryptodev.c
+++ b/drivers/crypto/octeontx2/otx2_cryptodev.c
@@ -22,8 +22,6 @@
 #include "cpt_common.h"
 #include "cpt_pmd_logs.h"
 
-int otx2_cpt_logtype;
-
 uint8_t otx2_cryptodev_driver_id;
 
 static struct rte_pci_id pci_id_cpt_table[] = {
@@ -146,17 +144,9 @@ static struct rte_pci_driver otx2_cryptodev_pmd = {
 
 static struct cryptodev_driver otx2_cryptodev_drv;
 
-RTE_INIT(otx2_cpt_init_log);
 RTE_PMD_REGISTER_PCI(CRYPTODEV_NAME_OCTEONTX2_PMD, otx2_cryptodev_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(CRYPTODEV_NAME_OCTEONTX2_PMD, pci_id_cpt_table);
 RTE_PMD_REGISTER_KMOD_DEP(CRYPTODEV_NAME_OCTEONTX2_PMD, "vfio-pci");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(otx2_cryptodev_drv, otx2_cryptodev_pmd.driver,
 		otx2_cryptodev_driver_id);
-
-RTE_INIT(otx2_cpt_init_log)
-{
-	/* Bus level logs */
-	otx2_cpt_logtype = rte_log_register("pmd.crypto.octeontx2");
-	if (otx2_cpt_logtype >= 0)
-		rte_log_set_level(otx2_cpt_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(otx2_cpt_logtype, pmd.crypto.octeontx2, NOTICE);
diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c
index bb9fb877a..7d3959f55 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd.c
@@ -18,7 +18,6 @@
 
 #define DES_BLOCK_SIZE 8
 
-int openssl_logtype_driver;
 static uint8_t cryptodev_driver_id;
 
 #if (OPENSSL_VERSION_NUMBER < 0x10100000L)
@@ -2279,8 +2278,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_OPENSSL_PMD,
 	"socket_id=<int>");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(openssl_crypto_drv,
 		cryptodev_openssl_pmd_drv.driver, cryptodev_driver_id);
-
-RTE_INIT(openssl_init_log)
-{
-	openssl_logtype_driver = rte_log_register("pmd.crypto.openssl");
-}
+RTE_LOG_REGISTER(openssl_logtype_driver, pmd.crypto.openssl, INFO);
diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
index 1fef88f11..730504dab 100644
--- a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
+++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
@@ -10,8 +10,6 @@
 #include "rte_cryptodev_scheduler.h"
 #include "scheduler_pmd_private.h"
 
-int scheduler_logtype_driver;
-
 /** update the scheduler pmd's capability with attaching device's
  *  capability.
  *  For each device to be attached, the scheduler's capability should be
@@ -578,7 +576,5 @@ rte_cryptodev_scheduler_option_get(uint8_t scheduler_id,
 	return (*sched_ctx->ops.option_get)(dev, option_type, option);
 }
 
-RTE_INIT(scheduler_init_log)
-{
-	scheduler_logtype_driver = rte_log_register("pmd.crypto.scheduler");
-}
+
+RTE_LOG_REGISTER(scheduler_logtype_driver, pmd.crypto.scheduler, INFO);
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index c939064d5..558e01e70 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -16,7 +16,6 @@
 #define SNOW3G_MAX_BURST 8
 #define BYTE_LEN 8
 
-int snow3g_logtype_driver;
 static uint8_t cryptodev_driver_id;
 
 /** Get xform chain order. */
@@ -653,8 +652,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_SNOW3G_PMD,
 	"socket_id=<int>");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(snow3g_crypto_drv,
 		cryptodev_snow3g_pmd_drv.driver, cryptodev_driver_id);
-
-RTE_INIT(snow3g_init_log)
-{
-	snow3g_logtype_driver = rte_log_register("pmd.crypto.snow3g");
-}
+RTE_LOG_REGISTER(snow3g_logtype_driver, pmd.crypto.snow3g, INFO);
diff --git a/drivers/crypto/virtio/virtio_cryptodev.c b/drivers/crypto/virtio/virtio_cryptodev.c
index cdf43b0e0..31a5f1072 100644
--- a/drivers/crypto/virtio/virtio_cryptodev.c
+++ b/drivers/crypto/virtio/virtio_cryptodev.c
@@ -17,12 +17,6 @@
 #include "virtio_crypto_algs.h"
 #include "virtio_crypto_capabilities.h"
 
-int virtio_crypto_logtype_init;
-int virtio_crypto_logtype_session;
-int virtio_crypto_logtype_rx;
-int virtio_crypto_logtype_tx;
-int virtio_crypto_logtype_driver;
-
 static int virtio_crypto_dev_configure(struct rte_cryptodev *dev,
 		struct rte_cryptodev_config *config);
 static int virtio_crypto_dev_start(struct rte_cryptodev *dev);
@@ -1489,29 +1483,10 @@ RTE_PMD_REGISTER_PCI(CRYPTODEV_NAME_VIRTIO_PMD, rte_virtio_crypto_driver);
 RTE_PMD_REGISTER_CRYPTO_DRIVER(virtio_crypto_drv,
 	rte_virtio_crypto_driver.driver,
 	cryptodev_virtio_driver_id);
-
-RTE_INIT(virtio_crypto_init_log)
-{
-	virtio_crypto_logtype_init = rte_log_register("pmd.crypto.virtio.init");
-	if (virtio_crypto_logtype_init >= 0)
-		rte_log_set_level(virtio_crypto_logtype_init, RTE_LOG_NOTICE);
-
-	virtio_crypto_logtype_session =
-		rte_log_register("pmd.crypto.virtio.session");
-	if (virtio_crypto_logtype_session >= 0)
-		rte_log_set_level(virtio_crypto_logtype_session,
-				RTE_LOG_NOTICE);
-
-	virtio_crypto_logtype_rx = rte_log_register("pmd.crypto.virtio.rx");
-	if (virtio_crypto_logtype_rx >= 0)
-		rte_log_set_level(virtio_crypto_logtype_rx, RTE_LOG_NOTICE);
-
-	virtio_crypto_logtype_tx = rte_log_register("pmd.crypto.virtio.tx");
-	if (virtio_crypto_logtype_tx >= 0)
-		rte_log_set_level(virtio_crypto_logtype_tx, RTE_LOG_NOTICE);
-
-	virtio_crypto_logtype_driver =
-		rte_log_register("pmd.crypto.virtio.driver");
-	if (virtio_crypto_logtype_driver >= 0)
-		rte_log_set_level(virtio_crypto_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(virtio_crypto_logtype_init, pmd.crypto.virtio.init, NOTICE);
+RTE_LOG_REGISTER(virtio_crypto_logtype_session, pmd.crypto.virtio.session,
+		 NOTICE);
+RTE_LOG_REGISTER(virtio_crypto_logtype_rx, pmd.crypto.virtio.rx, NOTICE);
+RTE_LOG_REGISTER(virtio_crypto_logtype_tx, pmd.crypto.virtio.tx, NOTICE);
+RTE_LOG_REGISTER(virtio_crypto_logtype_driver, pmd.crypto.virtio.driver,
+		 NOTICE);
diff --git a/drivers/crypto/zuc/rte_zuc_pmd.c b/drivers/crypto/zuc/rte_zuc_pmd.c
index df8d6f6bb..20cb5a160 100644
--- a/drivers/crypto/zuc/rte_zuc_pmd.c
+++ b/drivers/crypto/zuc/rte_zuc_pmd.c
@@ -14,7 +14,6 @@
 #define ZUC_MAX_BURST 16
 #define BYTE_LEN 8
 
-int zuc_logtype_driver;
 static uint8_t cryptodev_driver_id;
 
 /** Get xform chain order. */
@@ -580,8 +579,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_ZUC_PMD,
 	"socket_id=<int>");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(zuc_crypto_drv, cryptodev_zuc_pmd_drv.driver,
 		cryptodev_driver_id);
-
-RTE_INIT(zuc_init_log)
-{
-	zuc_logtype_driver = rte_log_register("pmd.crypto.zuc");
-}
+RTE_LOG_REGISTER(zuc_logtype_driver, pmd.crypto.zuc, INFO);
-- 
2.27.0


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

* [dpdk-dev] [PATCH v4 09/13] drivers/compress: use log register macro
  2020-07-01 10:44     ` [dpdk-dev] [PATCH v4 00/13] rte_log registration usage improvement jerinj
                         ` (7 preceding siblings ...)
  2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 08/13] drivers/crypto: " jerinj
@ 2020-07-01 10:44       ` jerinj
  2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 10/13] drivers/common: " jerinj
                         ` (4 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01 10:44 UTC (permalink / raw)
  To: dev, Lee Daly, Fiona Trahe, Ashish Gupta, Sunila Sahu
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/compress/isal/isal_compress_pmd.c | 10 +---------
 drivers/compress/octeontx/otx_zip_pmd.c   | 10 +---------
 drivers/compress/zlib/zlib_pmd.c          | 10 +---------
 3 files changed, 3 insertions(+), 27 deletions(-)

diff --git a/drivers/compress/isal/isal_compress_pmd.c b/drivers/compress/isal/isal_compress_pmd.c
index 7d2b05c91..0ecca12a8 100644
--- a/drivers/compress/isal/isal_compress_pmd.c
+++ b/drivers/compress/isal/isal_compress_pmd.c
@@ -25,8 +25,6 @@
 #define ISAL_VERSION_STRING \
 	ISAL_TOSTRING(ISAL_MAJOR_VERSION, ISAL_MINOR_VERSION, ISAL_PATCH_VERSION)
 
-int isal_logtype_driver;
-
 /* Verify and set private xform parameters */
 int
 isal_comp_set_priv_xform_parameters(struct isal_priv_xform *priv_xform,
@@ -752,10 +750,4 @@ static struct rte_vdev_driver compdev_isal_pmd_drv = {
 RTE_PMD_REGISTER_VDEV(COMPDEV_NAME_ISAL_PMD, compdev_isal_pmd_drv);
 RTE_PMD_REGISTER_PARAM_STRING(COMPDEV_NAME_ISAL_PMD,
 	"socket_id=<int>");
-
-RTE_INIT(isal_init_log)
-{
-	isal_logtype_driver = rte_log_register("pmd.compress.isal");
-	if (isal_logtype_driver >= 0)
-		rte_log_set_level(isal_logtype_driver, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(isal_logtype_driver, pmd.compress.isal, INFO);
diff --git a/drivers/compress/octeontx/otx_zip_pmd.c b/drivers/compress/octeontx/otx_zip_pmd.c
index bff8ef035..bee90fc7c 100644
--- a/drivers/compress/octeontx/otx_zip_pmd.c
+++ b/drivers/compress/octeontx/otx_zip_pmd.c
@@ -11,8 +11,6 @@
 
 #include "otx_zip.h"
 
-int octtx_zip_logtype_driver;
-
 static const struct rte_compressdev_capabilities
 				octtx_zip_pmd_capabilities[] = {
 	{	.algo = RTE_COMP_ALGO_DEFLATE,
@@ -648,10 +646,4 @@ static struct rte_pci_driver octtx_zip_pmd = {
 
 RTE_PMD_REGISTER_PCI(COMPRESSDEV_NAME_ZIP_PMD, octtx_zip_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(COMPRESSDEV_NAME_ZIP_PMD, pci_id_octtx_zipvf_table);
-
-RTE_INIT(octtx_zip_init_log)
-{
-	octtx_zip_logtype_driver = rte_log_register("pmd.compress.octeontx");
-	if (octtx_zip_logtype_driver >= 0)
-		rte_log_set_level(octtx_zip_logtype_driver, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(octtx_zip_logtype_driver, pmd.compress.octeontx, INFO);
diff --git a/drivers/compress/zlib/zlib_pmd.c b/drivers/compress/zlib/zlib_pmd.c
index e39be2ed8..8a79d15c9 100644
--- a/drivers/compress/zlib/zlib_pmd.c
+++ b/drivers/compress/zlib/zlib_pmd.c
@@ -7,8 +7,6 @@
 
 #include "zlib_pmd_private.h"
 
-int zlib_logtype_driver;
-
 /** Compute next mbuf in the list, assign data buffer and length,
  *  returns 0 if mbuf is NULL
  */
@@ -428,10 +426,4 @@ static struct rte_vdev_driver zlib_pmd_drv = {
 };
 
 RTE_PMD_REGISTER_VDEV(COMPRESSDEV_NAME_ZLIB_PMD, zlib_pmd_drv);
-
-RTE_INIT(zlib_init_log)
-{
-	zlib_logtype_driver = rte_log_register("pmd.compress.zlib");
-	if (zlib_logtype_driver >= 0)
-		rte_log_set_level(zlib_logtype_driver, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(zlib_logtype_driver, pmd.compress.zlib, INFO);
-- 
2.27.0


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

* [dpdk-dev] [PATCH v4 10/13] drivers/common: use log register macro
  2020-07-01 10:44     ` [dpdk-dev] [PATCH v4 00/13] rte_log registration usage improvement jerinj
                         ` (8 preceding siblings ...)
  2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 09/13] drivers/compress: " jerinj
@ 2020-07-01 10:44       ` jerinj
  2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 11/13] drivers/bus: " jerinj
                         ` (3 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01 10:44 UTC (permalink / raw)
  To: dev, Hemant Agrawal, Sachin Saxena, Jingjing Wu, Beilei Xing,
	Harman Kalra, Jerin Jacob, Nithin Dabilpuram, John Griffin,
	Fiona Trahe, Deepak Kumar Jain
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena, adamx.dybkowski

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Sachin Saxena <sachin.saxena@oss.nxp.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/common/dpaax/dpaax_iova_table.c | 10 +--
 drivers/common/iavf/iavf_impl.c         |  9 +--
 drivers/common/octeontx/octeontx_mbox.c |  9 +--
 drivers/common/octeontx2/otx2_common.c  | 96 +++----------------------
 drivers/common/qat/qat_logs.c           | 17 +----
 5 files changed, 15 insertions(+), 126 deletions(-)

diff --git a/drivers/common/dpaax/dpaax_iova_table.c b/drivers/common/dpaax/dpaax_iova_table.c
index 98b076e09..5ba8ed193 100644
--- a/drivers/common/dpaax/dpaax_iova_table.c
+++ b/drivers/common/dpaax/dpaax_iova_table.c
@@ -7,9 +7,6 @@
 #include "dpaax_iova_table.h"
 #include "dpaax_logs.h"
 
-/* Global dpaax logger identifier */
-int dpaax_logger;
-
 /* Global table reference */
 struct dpaax_iova_table *dpaax_iova_table_p;
 
@@ -463,9 +460,4 @@ dpaax_handle_memevents(void)
 					       dpaax_memevent_cb, NULL);
 }
 
-RTE_INIT(dpaax_log)
-{
-	dpaax_logger = rte_log_register("pmd.common.dpaax");
-	if (dpaax_logger >= 0)
-		rte_log_set_level(dpaax_logger, RTE_LOG_ERR);
-}
+RTE_LOG_REGISTER(dpaax_logger, pmd.common.dpaax, ERR);
diff --git a/drivers/common/iavf/iavf_impl.c b/drivers/common/iavf/iavf_impl.c
index 6174a9144..fc0da3175 100644
--- a/drivers/common/iavf/iavf_impl.c
+++ b/drivers/common/iavf/iavf_impl.c
@@ -13,8 +13,6 @@
 #include "iavf_type.h"
 #include "iavf_prototype.h"
 
-int iavf_common_logger;
-
 enum iavf_status
 iavf_allocate_dma_mem_d(__rte_unused struct iavf_hw *hw,
 			struct iavf_dma_mem *mem,
@@ -87,9 +85,4 @@ iavf_free_virt_mem_d(__rte_unused struct iavf_hw *hw,
 	return IAVF_SUCCESS;
 }
 
-RTE_INIT(iavf_common_init_log)
-{
-	iavf_common_logger = rte_log_register("pmd.common.iavf");
-	if (iavf_common_logger >= 0)
-		rte_log_set_level(iavf_common_logger, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(iavf_common_logger, pmd.common.iavf, NOTICE);
diff --git a/drivers/common/octeontx/octeontx_mbox.c b/drivers/common/octeontx/octeontx_mbox.c
index effe0b267..f414267e4 100644
--- a/drivers/common/octeontx/octeontx_mbox.c
+++ b/drivers/common/octeontx/octeontx_mbox.c
@@ -68,14 +68,7 @@ struct mbox_intf_ver {
 	uint32_t minor:10;
 };
 
-int octeontx_logtype_mbox;
-
-RTE_INIT(otx_init_log)
-{
-	octeontx_logtype_mbox = rte_log_register("pmd.octeontx.mbox");
-	if (octeontx_logtype_mbox >= 0)
-		rte_log_set_level(octeontx_logtype_mbox, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(octeontx_logtype_mbox, pmd.octeontx.mbox, NOTICE);
 
 static inline void
 mbox_msgcpy(volatile uint8_t *d, volatile const uint8_t *s, uint16_t size)
diff --git a/drivers/common/octeontx2/otx2_common.c b/drivers/common/octeontx2/otx2_common.c
index 5e7272f69..b292e999a 100644
--- a/drivers/common/octeontx2/otx2_common.c
+++ b/drivers/common/octeontx2/otx2_common.c
@@ -203,89 +203,13 @@ void otx2_parse_common_devargs(struct rte_kvargs *kvlist)
 	idev->npa_lock_mask = npa_lock_mask;
 }
 
-/**
- * @internal
- */
-int otx2_logtype_base;
-/**
- * @internal
- */
-int otx2_logtype_mbox;
-/**
- * @internal
- */
-int otx2_logtype_npa;
-/**
- * @internal
- */
-int otx2_logtype_nix;
-/**
- * @internal
- */
-int otx2_logtype_npc;
-/**
- * @internal
- */
-int otx2_logtype_tm;
-/**
- * @internal
- */
-int otx2_logtype_sso;
-/**
- * @internal
- */
-int otx2_logtype_tim;
-/**
- * @internal
- */
-int otx2_logtype_dpi;
-/**
- * @internal
- */
-int otx2_logtype_ep;
-
-RTE_INIT(otx2_log_init);
-static void
-otx2_log_init(void)
-{
-	otx2_logtype_base = rte_log_register("pmd.octeontx2.base");
-	if (otx2_logtype_base >= 0)
-		rte_log_set_level(otx2_logtype_base, RTE_LOG_NOTICE);
-
-	otx2_logtype_mbox = rte_log_register("pmd.octeontx2.mbox");
-	if (otx2_logtype_mbox >= 0)
-		rte_log_set_level(otx2_logtype_mbox, RTE_LOG_NOTICE);
-
-	otx2_logtype_npa = rte_log_register("pmd.mempool.octeontx2");
-	if (otx2_logtype_npa >= 0)
-		rte_log_set_level(otx2_logtype_npa, RTE_LOG_NOTICE);
-
-	otx2_logtype_nix = rte_log_register("pmd.net.octeontx2");
-	if (otx2_logtype_nix >= 0)
-		rte_log_set_level(otx2_logtype_nix, RTE_LOG_NOTICE);
-
-	otx2_logtype_npc = rte_log_register("pmd.net.octeontx2.flow");
-	if (otx2_logtype_npc >= 0)
-		rte_log_set_level(otx2_logtype_npc, RTE_LOG_NOTICE);
-
-	otx2_logtype_tm = rte_log_register("pmd.net.octeontx2.tm");
-	if (otx2_logtype_tm >= 0)
-		rte_log_set_level(otx2_logtype_tm, RTE_LOG_NOTICE);
-
-	otx2_logtype_sso = rte_log_register("pmd.event.octeontx2");
-	if (otx2_logtype_sso >= 0)
-		rte_log_set_level(otx2_logtype_sso, RTE_LOG_NOTICE);
-
-	otx2_logtype_tim = rte_log_register("pmd.event.octeontx2.timer");
-	if (otx2_logtype_tim >= 0)
-		rte_log_set_level(otx2_logtype_tim, RTE_LOG_NOTICE);
-
-	otx2_logtype_dpi = rte_log_register("pmd.raw.octeontx2.dpi");
-	if (otx2_logtype_dpi >= 0)
-		rte_log_set_level(otx2_logtype_dpi, RTE_LOG_NOTICE);
-
-	otx2_logtype_ep = rte_log_register("pmd.raw.octeontx2.ep");
-	if (otx2_logtype_ep >= 0)
-		rte_log_set_level(otx2_logtype_ep, RTE_LOG_NOTICE);
-
-}
+RTE_LOG_REGISTER(otx2_logtype_base, pmd.octeontx2.base, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_mbox, pmd.octeontx2.mbox, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_npa, pmd.mempool.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_nix, pmd.net.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_npc, pmd.net.octeontx2.flow, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_tm, pmd.net.octeontx2.tm, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_sso, pmd.event.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_tim, pmd.event.octeontx2.timer, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_dpi, pmd.raw.octeontx2.dpi, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_ep, pmd.raw.octeontx2.ep, NOTICE);
diff --git a/drivers/common/qat/qat_logs.c b/drivers/common/qat/qat_logs.c
index dfd0cbe5d..fa48be53c 100644
--- a/drivers/common/qat/qat_logs.c
+++ b/drivers/common/qat/qat_logs.c
@@ -7,9 +7,6 @@
 
 #include "qat_logs.h"
 
-int qat_gen_logtype;
-int qat_dp_logtype;
-
 int
 qat_hexdump_log(uint32_t level, uint32_t logtype, const char *title,
 		const void *buf, unsigned int len)
@@ -20,15 +17,5 @@ qat_hexdump_log(uint32_t level, uint32_t logtype, const char *title,
 	return 0;
 }
 
-RTE_INIT(qat_pci_init_log)
-{
-	/* Non-data-path logging for pci device and all services */
-	qat_gen_logtype = rte_log_register("pmd.qat_general");
-	if (qat_gen_logtype >= 0)
-		rte_log_set_level(qat_gen_logtype, RTE_LOG_NOTICE);
-
-	/* data-path logging for all services */
-	qat_dp_logtype = rte_log_register("pmd.qat_dp");
-	if (qat_dp_logtype >= 0)
-		rte_log_set_level(qat_dp_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(qat_gen_logtype, pmd.qat_general, NOTICE);
+RTE_LOG_REGISTER(qat_dp_logtype, pmd.qat_dp, NOTICE);
-- 
2.27.0


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

* [dpdk-dev]  [PATCH v4 11/13] drivers/bus: use log register macro
  2020-07-01 10:44     ` [dpdk-dev] [PATCH v4 00/13] rte_log registration usage improvement jerinj
                         ` (9 preceding siblings ...)
  2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 10/13] drivers/common: " jerinj
@ 2020-07-01 10:44       ` jerinj
  2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 12/13] drivers/baseband: " jerinj
                         ` (2 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01 10:44 UTC (permalink / raw)
  To: dev, Hemant Agrawal, Sachin Saxena, Rosen Xu, Stephen Hemminger
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Sachin Saxena <sachin.saxena@oss.nxp.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/bus/dpaa/dpaa_bus.c      | 10 +---------
 drivers/bus/fslmc/fslmc_bus.c    | 11 +----------
 drivers/bus/ifpga/ifpga_bus.c    |  9 +--------
 drivers/bus/vdev/vdev.c          | 10 +---------
 drivers/bus/vmbus/vmbus_common.c |  9 +--------
 5 files changed, 5 insertions(+), 44 deletions(-)

diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c
index d53fe6083..0d8b13e5f 100644
--- a/drivers/bus/dpaa/dpaa_bus.c
+++ b/drivers/bus/dpaa/dpaa_bus.c
@@ -42,8 +42,6 @@
 #include <fsl_bman.h>
 #include <netcfg.h>
 
-int dpaa_logtype_bus;
-
 static struct rte_dpaa_bus rte_dpaa_bus;
 struct netcfg_info *dpaa_netcfg;
 
@@ -749,10 +747,4 @@ static struct rte_dpaa_bus rte_dpaa_bus = {
 };
 
 RTE_REGISTER_BUS(FSL_DPAA_BUS_NAME, rte_dpaa_bus.bus);
-
-RTE_INIT(dpaa_init_log)
-{
-	dpaa_logtype_bus = rte_log_register("bus.dpaa");
-	if (dpaa_logtype_bus >= 0)
-		rte_log_set_level(dpaa_logtype_bus, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa_logtype_bus, bus.dpaa, NOTICE);
diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
index afbd82e8d..d9f403bd9 100644
--- a/drivers/bus/fslmc/fslmc_bus.c
+++ b/drivers/bus/fslmc/fslmc_bus.c
@@ -21,8 +21,6 @@
 
 #include <dpaax_iova_table.h>
 
-int dpaa2_logtype_bus;
-
 #define VFIO_IOMMU_GROUP_PATH "/sys/kernel/iommu_groups"
 #define FSLMC_BUS_NAME	fslmc
 
@@ -649,11 +647,4 @@ struct rte_fslmc_bus rte_fslmc_bus = {
 };
 
 RTE_REGISTER_BUS(FSLMC_BUS_NAME, rte_fslmc_bus.bus);
-
-RTE_INIT(fslmc_init_log)
-{
-	/* Bus level logs */
-	dpaa2_logtype_bus = rte_log_register("bus.fslmc");
-	if (dpaa2_logtype_bus >= 0)
-		rte_log_set_level(dpaa2_logtype_bus, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa2_logtype_bus, bus.fslmc, NOTICE);
diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c
index addbc3e86..103915d43 100644
--- a/drivers/bus/ifpga/ifpga_bus.c
+++ b/drivers/bus/ifpga/ifpga_bus.c
@@ -32,7 +32,6 @@
 #include "ifpga_logs.h"
 #include "ifpga_common.h"
 
-int ifpga_bus_logtype;
 
 /* Forward declaration to access Intel FPGA bus
  * on which iFPGA devices are connected
@@ -474,10 +473,4 @@ static struct rte_bus rte_ifpga_bus = {
 };
 
 RTE_REGISTER_BUS(IFPGA_BUS_NAME, rte_ifpga_bus);
-
-RTE_INIT(ifpga_init_log)
-{
-	ifpga_bus_logtype = rte_log_register("bus.ifpga");
-	if (ifpga_bus_logtype >= 0)
-		rte_log_set_level(ifpga_bus_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(ifpga_bus_logtype, bus.ifpga, NOTICE);
diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index a89ea2353..d746149a2 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -27,8 +27,6 @@
 
 #define VDEV_MP_KEY	"bus_vdev_mp"
 
-int vdev_logtype_bus;
-
 /* Forward declare to access virtual bus name */
 static struct rte_bus rte_vdev_bus;
 
@@ -557,10 +555,4 @@ static struct rte_bus rte_vdev_bus = {
 };
 
 RTE_REGISTER_BUS(vdev, rte_vdev_bus);
-
-RTE_INIT(vdev_init_log)
-{
-	vdev_logtype_bus = rte_log_register("bus.vdev");
-	if (vdev_logtype_bus >= 0)
-		rte_log_set_level(vdev_logtype_bus, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(vdev_logtype_bus, bus.vdev, NOTICE);
diff --git a/drivers/bus/vmbus/vmbus_common.c b/drivers/bus/vmbus/vmbus_common.c
index 3adef01c9..4c9ac33ac 100644
--- a/drivers/bus/vmbus/vmbus_common.c
+++ b/drivers/bus/vmbus/vmbus_common.c
@@ -22,7 +22,6 @@
 
 #include "private.h"
 
-int vmbus_logtype_bus;
 extern struct rte_vmbus_bus rte_vmbus_bus;
 
 /* map a particular resource from a file */
@@ -298,10 +297,4 @@ struct rte_vmbus_bus rte_vmbus_bus = {
 };
 
 RTE_REGISTER_BUS(vmbus, rte_vmbus_bus.bus);
-
-RTE_INIT(vmbus_init_log)
-{
-	vmbus_logtype_bus = rte_log_register("bus.vmbus");
-	if (vmbus_logtype_bus >= 0)
-		rte_log_set_level(vmbus_logtype_bus, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(vmbus_logtype_bus, bus.vmbus, NOTICE);
-- 
2.27.0


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

* [dpdk-dev] [PATCH v4 12/13] drivers/baseband: use log register macro
  2020-07-01 10:44     ` [dpdk-dev] [PATCH v4 00/13] rte_log registration usage improvement jerinj
                         ` (10 preceding siblings ...)
  2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 11/13] drivers/bus: " jerinj
@ 2020-07-01 10:44       ` jerinj
  2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 13/13] app/test: " jerinj
  2020-07-01 12:33       ` [dpdk-dev] [PATCH v5 00/13] rte_log registration usage improvement jerinj
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01 10:44 UTC (permalink / raw)
  To: dev, Nicolas Chautru
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 .../baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 17 +++++------------
 drivers/baseband/fpga_lte_fec/fpga_lte_fec.c   | 18 +++++-------------
 drivers/baseband/null/bbdev_null.c             |  9 +--------
 .../baseband/turbo_sw/bbdev_turbo_software.c   |  9 +--------
 4 files changed, 12 insertions(+), 41 deletions(-)

diff --git a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
index e152b206e..aca0ca999 100644
--- a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
+++ b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
@@ -23,8 +23,11 @@
 #include "fpga_5gnr_fec.h"
 #include "rte_pmd_fpga_5gnr_fec.h"
 
-/* 5GNR SW PMD logging ID */
-static int fpga_5gnr_fec_logtype;
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+RTE_LOG_REGISTER(fpga_5gnr_fec_logtype, pmd.bb.fpga_5gnr_fec, DEBUG);
+#else
+RTE_LOG_REGISTER(fpga_5gnr_fec_logtype, pmd.bb.fpga_5gnr_fec, NOTICE);
+#endif
 
 #ifdef RTE_LIBRTE_BBDEV_DEBUG
 
@@ -2175,13 +2178,3 @@ RTE_PMD_REGISTER_PCI(FPGA_5GNR_FEC_VF_DRIVER_NAME, fpga_5gnr_fec_pci_vf_driver);
 RTE_PMD_REGISTER_PCI_TABLE(FPGA_5GNR_FEC_VF_DRIVER_NAME,
 		pci_id_fpga_5gnr_fec_vf_map);
 
-RTE_INIT(fpga_5gnr_fec_init_log)
-{
-	fpga_5gnr_fec_logtype = rte_log_register("pmd.bb.fpga_5gnr_fec");
-	if (fpga_5gnr_fec_logtype >= 0)
-#ifdef RTE_LIBRTE_BBDEV_DEBUG
-		rte_log_set_level(fpga_5gnr_fec_logtype, RTE_LOG_DEBUG);
-#else
-		rte_log_set_level(fpga_5gnr_fec_logtype, RTE_LOG_NOTICE);
-#endif
-}
diff --git a/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c b/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c
index abc5a1bf6..6be9131e7 100644
--- a/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c
+++ b/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c
@@ -22,8 +22,11 @@
 
 #include "fpga_lte_fec.h"
 
-/* Turbo SW PMD logging ID */
-static int fpga_lte_fec_logtype;
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+RTE_LOG_REGISTER(fpga_lte_fec_logtype, pmd.bb.fpga_lte_fec, DEBUG);
+#else
+RTE_LOG_REGISTER(fpga_lte_fec_logtype, pmd.bb.fpga_lte_fec, NOTICE);
+#endif
 
 /* Helper macro for logging */
 #define rte_bbdev_log(level, fmt, ...) \
@@ -2662,14 +2665,3 @@ RTE_PMD_REGISTER_PCI_TABLE(FPGA_LTE_FEC_PF_DRIVER_NAME,
 RTE_PMD_REGISTER_PCI(FPGA_LTE_FEC_VF_DRIVER_NAME, fpga_lte_fec_pci_vf_driver);
 RTE_PMD_REGISTER_PCI_TABLE(FPGA_LTE_FEC_VF_DRIVER_NAME,
 		pci_id_fpga_lte_fec_vf_map);
-
-RTE_INIT(fpga_lte_fec_init_log)
-{
-	fpga_lte_fec_logtype = rte_log_register("pmd.bb.fpga_lte_fec");
-	if (fpga_lte_fec_logtype >= 0)
-#ifdef RTE_LIBRTE_BBDEV_DEBUG
-		rte_log_set_level(fpga_lte_fec_logtype, RTE_LOG_DEBUG);
-#else
-		rte_log_set_level(fpga_lte_fec_logtype, RTE_LOG_NOTICE);
-#endif
-}
diff --git a/drivers/baseband/null/bbdev_null.c b/drivers/baseband/null/bbdev_null.c
index 2f2515101..dd11cd31c 100644
--- a/drivers/baseband/null/bbdev_null.c
+++ b/drivers/baseband/null/bbdev_null.c
@@ -15,8 +15,7 @@
 
 #define DRIVER_NAME baseband_null
 
-/* NULL BBDev logging ID */
-static int bbdev_null_logtype;
+RTE_LOG_REGISTER(bbdev_null_logtype, pmd.bb.null, NOTICE);
 
 /* Helper macro for logging */
 #define rte_bbdev_log(level, fmt, ...) \
@@ -348,9 +347,3 @@ RTE_PMD_REGISTER_PARAM_STRING(DRIVER_NAME,
 	BBDEV_NULL_SOCKET_ID_ARG"=<int>");
 RTE_PMD_REGISTER_ALIAS(DRIVER_NAME, bbdev_null);
 
-RTE_INIT(null_bbdev_init_log)
-{
-	bbdev_null_logtype = rte_log_register("pmd.bb.null");
-	if (bbdev_null_logtype >= 0)
-		rte_log_set_level(bbdev_null_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/baseband/turbo_sw/bbdev_turbo_software.c b/drivers/baseband/turbo_sw/bbdev_turbo_software.c
index bb62276b9..daecfd21a 100644
--- a/drivers/baseband/turbo_sw/bbdev_turbo_software.c
+++ b/drivers/baseband/turbo_sw/bbdev_turbo_software.c
@@ -34,8 +34,7 @@
 
 #define DRIVER_NAME baseband_turbo_sw
 
-/* Turbo SW PMD logging ID */
-static int bbdev_turbo_sw_logtype;
+RTE_LOG_REGISTER(bbdev_turbo_sw_logtype, pmd.bb.turbo_sw, NOTICE);
 
 /* Helper macro for logging */
 #define rte_bbdev_log(level, fmt, ...) \
@@ -1991,9 +1990,3 @@ RTE_PMD_REGISTER_PARAM_STRING(DRIVER_NAME,
 	TURBO_SW_SOCKET_ID_ARG"=<int>");
 RTE_PMD_REGISTER_ALIAS(DRIVER_NAME, turbo_sw);
 
-RTE_INIT(turbo_sw_bbdev_init_log)
-{
-	bbdev_turbo_sw_logtype = rte_log_register("pmd.bb.turbo_sw");
-	if (bbdev_turbo_sw_logtype >= 0)
-		rte_log_set_level(bbdev_turbo_sw_logtype, RTE_LOG_NOTICE);
-}
-- 
2.27.0


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

* [dpdk-dev]  [PATCH v4 13/13] app/test: use log register macro
  2020-07-01 10:44     ` [dpdk-dev] [PATCH v4 00/13] rte_log registration usage improvement jerinj
                         ` (11 preceding siblings ...)
  2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 12/13] drivers/baseband: " jerinj
@ 2020-07-01 10:44       ` jerinj
  2020-07-01 12:33       ` [dpdk-dev] [PATCH v5 00/13] rte_log registration usage improvement jerinj
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01 10:44 UTC (permalink / raw)
  To: dev, Byron Marohn, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Robert Sanford, Erik Gabriel Carrillo
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 app/test/test_efd.c            | 6 +-----
 app/test/test_hash.c           | 7 +------
 app/test/test_timer_racecond.c | 7 +------
 3 files changed, 3 insertions(+), 17 deletions(-)

diff --git a/app/test/test_efd.c b/app/test/test_efd.c
index e3e5e30ea..3d9aa8a57 100644
--- a/app/test/test_efd.c
+++ b/app/test/test_efd.c
@@ -32,12 +32,8 @@ struct flow_key {
 	uint8_t proto;
 } __rte_packed;
 
-int efd_logtype_test;
 
-RTE_INIT(test_efd_init_log)
-{
-	efd_logtype_test = rte_log_register("test.efd");
-}
+RTE_LOG_REGISTER(efd_logtype_test, test.efd, INFO);
 
 /*
  * Print out result of unit test efd operation.
diff --git a/app/test/test_hash.c b/app/test/test_hash.c
index afa3a1a3c..990a1815f 100644
--- a/app/test/test_hash.c
+++ b/app/test/test_hash.c
@@ -69,8 +69,6 @@ struct flow_key {
 	uint8_t proto;
 } __rte_packed;
 
-int hash_logtype_test;
-
 /*
  * Hash function that always returns the same value, to easily test what
  * happens when a bucket is full.
@@ -82,10 +80,7 @@ static uint32_t pseudo_hash(__rte_unused const void *keys,
 	return 3;
 }
 
-RTE_INIT(test_hash_init_log)
-{
-	hash_logtype_test = rte_log_register("test.hash");
-}
+RTE_LOG_REGISTER(hash_logtype_test, test.hash, INFO);
 
 /*
  * Print out result of unit test hash operation.
diff --git a/app/test/test_timer_racecond.c b/app/test/test_timer_racecond.c
index 4fc917995..28af9ca76 100644
--- a/app/test/test_timer_racecond.c
+++ b/app/test/test_timer_racecond.c
@@ -61,12 +61,7 @@ static volatile unsigned stop_slaves;
 
 static int reload_timer(struct rte_timer *tim);
 
-int timer_logtype_test;
-
-RTE_INIT(test_timer_init_log)
-{
-	timer_logtype_test = rte_log_register("test.timer");
-}
+RTE_LOG_REGISTER(timer_logtype_test, test.timer, INFO);
 
 static void
 timer_cb(struct rte_timer *tim, void *arg __rte_unused)
-- 
2.27.0


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

* [dpdk-dev] [PATCH v5 00/13] rte_log registration usage improvement
  2020-07-01 10:44     ` [dpdk-dev] [PATCH v4 00/13] rte_log registration usage improvement jerinj
                         ` (12 preceding siblings ...)
  2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 13/13] app/test: " jerinj
@ 2020-07-01 12:33       ` jerinj
  2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 01/13] eal/log: introduce log register macro jerinj
                           ` (13 more replies)
  13 siblings, 14 replies; 98+ messages in thread
From: jerinj @ 2020-07-01 12:33 UTC (permalink / raw)
  To: dev
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

This patch series improves the rte_log registration code snippet by
avoiding duplication of the code around registration by
introducing RTE_LOG_REGISTER macro.

v5:
- Fix the build issue reported at
  https://travis-ci.com/github/ovsrobot/dpdk/jobs/356344958

v4:
- Fix the build issue reported at
  https://travis-ci.com/github/ovsrobot/dpdk/builds/173792541

v3:
- Fix the build issue reported at
  https://travis-ci.com/github/ovsrobot/dpdk/jobs/356167611

v2:
- RTE_LOG_REGISTER implemented using rte_log_register_type_and_pick_level()
- Added Sachin Saxena <sachin.saxena@oss.nxp.com> and  Adam Dybkowski
<adamx.dybkowski@intel.com> Acks.
- Rebase to ToT


Drivers not adapated to new macro
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I have converted all existing rte_log_register() to new macro, except
the following (as it has different usage style)
1) drivers/common/mlx5/mlx5_common.c
2) drivers/net/e1000/e1000_logs.c
3) drivers/net/sfc/sfc_ethdev.c

Example usage of new macro
~~~~~~~~~~~~~~~~~~~~~~~~~~
-/**
- * @internal
- */
-int otx2_logtype_base;
-/**
- * @internal
- */
-int otx2_logtype_mbox;
-/**
- * @internal
- */
-int otx2_logtype_npa;
-/**
- * @internal
- */
-int otx2_logtype_nix;
-/**
- * @internal
- */
-int otx2_logtype_npc;
-/**
- * @internal
- */
-int otx2_logtype_tm;
-/**
- * @internal
- */
-int otx2_logtype_sso;
-/**
- * @internal
- */
-int otx2_logtype_tim;
-/**
- * @internal
- */
-int otx2_logtype_dpi;
-/**
- * @internal
- */
-int otx2_logtype_ep;
-
-RTE_INIT(otx2_log_init);
-static void
-otx2_log_init(void)
-{
-       otx2_logtype_base = rte_log_register("pmd.octeontx2.base");
-       if (otx2_logtype_base >= 0)
-               rte_log_set_level(otx2_logtype_base, RTE_LOG_NOTICE);
-
-       otx2_logtype_mbox = rte_log_register("pmd.octeontx2.mbox");
-       if (otx2_logtype_mbox >= 0)
-               rte_log_set_level(otx2_logtype_mbox, RTE_LOG_NOTICE);
-
-       otx2_logtype_npa = rte_log_register("pmd.mempool.octeontx2");
-       if (otx2_logtype_npa >= 0)
-               rte_log_set_level(otx2_logtype_npa, RTE_LOG_NOTICE);
-
-       otx2_logtype_nix = rte_log_register("pmd.net.octeontx2");
-       if (otx2_logtype_nix >= 0)
-               rte_log_set_level(otx2_logtype_nix, RTE_LOG_NOTICE);
-
-       otx2_logtype_npc = rte_log_register("pmd.net.octeontx2.flow");
-       if (otx2_logtype_npc >= 0)
-               rte_log_set_level(otx2_logtype_npc, RTE_LOG_NOTICE);
-
-       otx2_logtype_tm = rte_log_register("pmd.net.octeontx2.tm");
-       if (otx2_logtype_tm >= 0)
-               rte_log_set_level(otx2_logtype_tm, RTE_LOG_NOTICE);
-
-       otx2_logtype_sso = rte_log_register("pmd.event.octeontx2");
-       if (otx2_logtype_sso >= 0)
-               rte_log_set_level(otx2_logtype_sso, RTE_LOG_NOTICE);
-
-       otx2_logtype_tim =
        rte_log_register("pmd.event.octeontx2.timer");
-       if (otx2_logtype_tim >= 0)
-               rte_log_set_level(otx2_logtype_tim, RTE_LOG_NOTICE);
-
-       otx2_logtype_dpi = rte_log_register("pmd.raw.octeontx2.dpi");
-       if (otx2_logtype_dpi >= 0)
-               rte_log_set_level(otx2_logtype_dpi, RTE_LOG_NOTICE);
-
-       otx2_logtype_ep = rte_log_register("pmd.raw.octeontx2.ep");
-       if (otx2_logtype_ep >= 0)
-               rte_log_set_level(otx2_logtype_ep, RTE_LOG_NOTICE);
-
-}
+RTE_LOG_REGISTER(otx2_logtype_base, pmd.octeontx2.base, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_mbox, pmd.octeontx2.mbox, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_npa, pmd.mempool.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_nix, pmd.net.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_npc, pmd.net.octeontx2.flow, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_tm, pmd.net.octeontx2.tm, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_sso, pmd.event.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_tim, pmd.event.octeontx2.timer, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_dpi, pmd.raw.octeontx2.dpi, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_ep, pmd.raw.octeontx2.ep, NOTICE);


Jerin Jacob (13):
  eal/log: introduce log register macro
  lib: use log register macro
  drivers/vdpa: use log register macro
  drivers/raw: use log register macro
  drivers/net: use log register macro
  drivers/mempool: use log register macro
  drivers/event: use log register macro
  drivers/crypto: use log register macro
  drivers/compress: use log register macro
  drivers/common: use log register macro
  drivers/bus: use log register macro
  drivers/baseband: use log register macro
  app/test: use log register macro

 app/test/test_efd.c                           |  6 +-
 app/test/test_hash.c                          |  7 +-
 app/test/test_timer_racecond.c                |  7 +-
 .../fpga_5gnr_fec/rte_fpga_5gnr_fec.c         | 17 +---
 drivers/baseband/fpga_lte_fec/fpga_lte_fec.c  | 18 +---
 drivers/baseband/null/bbdev_null.c            |  9 +-
 .../baseband/turbo_sw/bbdev_turbo_software.c  |  9 +-
 drivers/bus/dpaa/dpaa_bus.c                   | 10 +-
 drivers/bus/fslmc/fslmc_bus.c                 | 11 +--
 drivers/bus/ifpga/ifpga_bus.c                 |  9 +-
 drivers/bus/vdev/vdev.c                       | 10 +-
 drivers/bus/vmbus/vmbus_common.c              |  9 +-
 drivers/common/dpaax/dpaax_iova_table.c       | 10 +-
 drivers/common/iavf/iavf_impl.c               |  9 +-
 drivers/common/octeontx/octeontx_mbox.c       |  9 +-
 drivers/common/octeontx2/otx2_common.c        | 96 ++-----------------
 drivers/common/qat/qat_logs.c                 | 17 +---
 drivers/compress/isal/isal_compress_pmd.c     | 10 +-
 drivers/compress/octeontx/otx_zip_pmd.c       | 10 +-
 drivers/compress/zlib/zlib_pmd.c              | 10 +-
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c      |  8 +-
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c    |  8 +-
 drivers/crypto/caam_jr/caam_jr.c              |  8 +-
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c   | 11 +--
 drivers/crypto/dpaa_sec/dpaa_sec.c            | 10 +-
 drivers/crypto/kasumi/rte_kasumi_pmd.c        |  6 +-
 drivers/crypto/mvsam/rte_mrvl_pmd.c           |  7 +-
 drivers/crypto/nitrox/nitrox_logs.c           |  9 +-
 drivers/crypto/null/null_crypto_pmd.c         |  7 +-
 drivers/crypto/octeontx/otx_cryptodev.c       | 10 +-
 drivers/crypto/octeontx2/otx2_cryptodev.c     | 12 +--
 drivers/crypto/openssl/rte_openssl_pmd.c      |  7 +-
 .../scheduler/rte_cryptodev_scheduler.c       |  8 +-
 drivers/crypto/snow3g/rte_snow3g_pmd.c        |  7 +-
 drivers/crypto/virtio/virtio_cryptodev.c      | 39 ++------
 drivers/crypto/zuc/rte_zuc_pmd.c              |  7 +-
 drivers/event/dpaa/dpaa_eventdev.c            |  8 +-
 drivers/event/dpaa2/dpaa2_eventdev.c          | 10 +-
 drivers/event/octeontx/ssovf_evdev.c          |  8 +-
 drivers/event/octeontx/timvf_evdev.c          |  9 +-
 drivers/event/opdl/opdl_evdev.c               |  8 +-
 drivers/event/opdl/opdl_ring.c                |  2 -
 drivers/event/sw/sw_evdev.c                   | 11 +--
 drivers/mempool/dpaa/dpaa_mempool.c           | 10 +-
 drivers/mempool/dpaa2/dpaa2_hw_mempool.c      | 10 +-
 drivers/mempool/octeontx/octeontx_fpavf.c     | 10 +-
 drivers/net/af_packet/rte_eth_af_packet.c     |  8 +-
 drivers/net/af_xdp/rte_eth_af_xdp.c           |  8 +-
 drivers/net/ark/ark_ethdev.c                  | 10 +-
 drivers/net/atlantic/atl_ethdev.c             | 15 +--
 drivers/net/avp/avp_ethdev.c                  | 10 +-
 drivers/net/axgbe/axgbe_ethdev.c              | 15 +--
 drivers/net/bnx2x/bnx2x_ethdev.c              | 15 +--
 drivers/net/bnxt/bnxt_ethdev.c                |  9 +-
 drivers/net/bonding/rte_eth_bond_pmd.c        |  9 +-
 drivers/net/cxgbe/cxgbe_ethdev.c              | 15 +--
 drivers/net/dpaa/dpaa_ethdev.c                |  9 +-
 drivers/net/dpaa2/dpaa2_ethdev.c              |  9 +-
 drivers/net/ena/ena_ethdev.c                  | 48 ++--------
 drivers/net/enetc/enetc_ethdev.c              | 10 +-
 drivers/net/enic/enic_ethdev.c                |  9 +-
 drivers/net/failsafe/failsafe.c               | 10 +-
 drivers/net/fm10k/fm10k_ethdev.c              | 40 +-------
 drivers/net/hinic/hinic_pmd_ethdev.c          | 11 +--
 drivers/net/hns3/hns3_ethdev.c                | 15 +--
 drivers/net/i40e/i40e_ethdev.c                | 38 +-------
 drivers/net/iavf/iavf_ethdev.c                | 40 +-------
 drivers/net/ice/ice_ethdev.c                  | 38 +-------
 drivers/net/igc/igc_logs.c                    | 16 +---
 drivers/net/ionic/ionic_ethdev.c              | 10 +-
 drivers/net/ipn3ke/ipn3ke_ethdev.c            | 10 +-
 drivers/net/ixgbe/ixgbe_ethdev.c              | 39 ++------
 drivers/net/kni/rte_eth_kni.c                 |  9 +-
 drivers/net/liquidio/lio_ethdev.c             | 15 +--
 drivers/net/memif/rte_eth_memif.c             |  9 +-
 drivers/net/mlx4/mlx4.c                       | 11 +--
 drivers/net/mlx5/mlx5.c                       | 10 +-
 drivers/net/mvneta/mvneta_ethdev.c            | 10 +-
 drivers/net/mvpp2/mrvl_ethdev.c               | 10 +-
 drivers/net/netvsc/hn_ethdev.c                | 15 +--
 drivers/net/nfp/nfp_net.c                     | 15 +--
 drivers/net/null/rte_eth_null.c               |  8 +-
 drivers/net/octeontx/octeontx_ethdev.c        | 21 +---
 drivers/net/pcap/rte_eth_pcap.c               |  8 +-
 drivers/net/pfe/pfe_ethdev.c                  | 10 +-
 drivers/net/qede/qede_ethdev.c                | 16 +---
 drivers/net/ring/rte_eth_ring.c               |  8 +-
 drivers/net/softnic/rte_eth_softnic.c         | 10 +-
 drivers/net/szedata2/rte_eth_szedata2.c       | 15 +--
 drivers/net/tap/rte_eth_tap.c                 |  9 +-
 drivers/net/thunderx/nicvf_ethdev.c           | 21 +---
 drivers/net/vdev_netvsc/vdev_netvsc.c         | 13 +--
 drivers/net/vhost/rte_eth_vhost.c             |  8 +-
 drivers/net/virtio/virtio_ethdev.c            | 15 +--
 drivers/net/vmxnet3/vmxnet3_ethdev.c          | 15 +--
 drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c         | 11 +--
 drivers/raw/dpaa2_qdma/dpaa2_qdma.c           | 11 +--
 drivers/raw/ifpga/ifpga_rawdev.c              | 10 +-
 drivers/raw/ioat/ioat_rawdev.c                | 12 +--
 drivers/raw/ioat/rte_ioat_rawdev.h            |  2 -
 drivers/raw/ntb/ntb.c                         | 10 +-
 drivers/raw/skeleton/skeleton_rawdev.c        | 11 +--
 drivers/vdpa/ifc/ifcvf_vdpa.c                 | 10 +-
 drivers/vdpa/mlx5/mlx5_vdpa.c                 |  7 +-
 lib/librte_bbdev/rte_bbdev.c                  |  8 +-
 lib/librte_bpf/bpf.c                          |  9 +-
 lib/librte_cfgfile/rte_cfgfile.c              |  8 +-
 lib/librte_compressdev/rte_compressdev.c      |  7 +-
 lib/librte_compressdev/rte_compressdev_pmd.c  |  2 -
 lib/librte_eal/include/rte_log.h              | 24 +++++
 lib/librte_ethdev/rte_ethdev.c                |  9 +-
 lib/librte_eventdev/rte_event_timer_adapter.c | 21 +---
 lib/librte_flow_classify/rte_flow_classify.c  | 10 +-
 lib/librte_graph/graph.c                      |  7 +-
 lib/librte_member/rte_member.c                |  9 +-
 lib/librte_metrics/rte_metrics_telemetry.c    |  5 +-
 lib/librte_node/log.c                         |  9 +-
 lib/librte_pdump/rte_pdump.c                  |  9 +-
 lib/librte_rawdev/rte_rawdev.c                |  7 +-
 lib/librte_rcu/rte_rcu_qsbr.c                 |  9 +-
 lib/librte_stack/rte_stack.c                  |  7 +-
 lib/librte_vhost/vhost.c                      | 15 +--
 122 files changed, 228 insertions(+), 1321 deletions(-)

-- 
2.27.0


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

* [dpdk-dev] [PATCH v5 01/13] eal/log: introduce log register macro
  2020-07-01 12:33       ` [dpdk-dev] [PATCH v5 00/13] rte_log registration usage improvement jerinj
@ 2020-07-01 12:33         ` jerinj
  2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 02/13] lib: use " jerinj
                           ` (12 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01 12:33 UTC (permalink / raw)
  To: dev
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Introducing the RTE_LOG_REGISTER macro to avoid the code duplication
in the log registration process.

It is a wrapper macro for declaring the logtype, register the log and sets
it's level in the constructor context.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 lib/librte_eal/include/rte_log.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/lib/librte_eal/include/rte_log.h b/lib/librte_eal/include/rte_log.h
index 1789ede56..eaf66e4f6 100644
--- a/lib/librte_eal/include/rte_log.h
+++ b/lib/librte_eal/include/rte_log.h
@@ -376,6 +376,30 @@ int rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap)
 		 RTE_LOGTYPE_ ## t, # t ": " __VA_ARGS__) :	\
 	 0)
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Register a dynamic log type in constructor context with its name and level.
+ *
+ * It is a wrapper macro for declaring the logtype, register the log and
+ * sets it's level in the constructor context.
+ *
+ * @param type
+ *   The log type identifier
+ * @param name
+ *    Name for the log type to be registered
+ * @param level
+ *   Log level. A value between EMERG (1) and DEBUG (8).
+ */
+#define RTE_LOG_REGISTER(type, name, level)				\
+int type;								\
+RTE_INIT(__##type)							\
+{									\
+	type = rte_log_register_type_and_pick_level(RTE_STR(name),	\
+						    RTE_LOG_##level);	\
+}
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.27.0


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

* [dpdk-dev]  [PATCH v5 02/13] lib: use log register macro
  2020-07-01 12:33       ` [dpdk-dev] [PATCH v5 00/13] rte_log registration usage improvement jerinj
  2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 01/13] eal/log: introduce log register macro jerinj
@ 2020-07-01 12:33         ` jerinj
  2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 03/13] drivers/vdpa: " jerinj
                           ` (11 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01 12:33 UTC (permalink / raw)
  To: dev, Nicolas Chautru, Konstantin Ananyev, Cristian Dumitrescu,
	Fiona Trahe, Ashish Gupta, Thomas Monjalon, Ferruh Yigit,
	Andrew Rybchenko, Erik Gabriel Carrillo, Jerin Jacob,
	Bernard Iremonger, Kiran Kumar K, Nithin Dabilpuram, Yipeng Wang,
	Sameh Gobriel, Pavan Nikhilesh, Reshma Pattan, Nipun Gupta,
	Hemant Agrawal, Honnappa Nagarahalli, Gage Eads, Olivier Matz,
	Maxime Coquelin, Zhihong Wang, Xiaolong Ye
  Cc: david.marchand, sachin.saxena, adamx.dybkowski

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 lib/librte_bbdev/rte_bbdev.c                  |  8 +------
 lib/librte_bpf/bpf.c                          |  9 +-------
 lib/librte_cfgfile/rte_cfgfile.c              |  8 +------
 lib/librte_compressdev/rte_compressdev.c      |  7 +------
 lib/librte_compressdev/rte_compressdev_pmd.c  |  2 --
 lib/librte_ethdev/rte_ethdev.c                |  9 +++-----
 lib/librte_eventdev/rte_event_timer_adapter.c | 21 +++----------------
 lib/librte_flow_classify/rte_flow_classify.c  | 10 +--------
 lib/librte_graph/graph.c                      |  7 +------
 lib/librte_member/rte_member.c                |  9 +-------
 lib/librte_metrics/rte_metrics_telemetry.c    |  5 ++---
 lib/librte_node/log.c                         |  9 +-------
 lib/librte_pdump/rte_pdump.c                  |  9 ++------
 lib/librte_rawdev/rte_rawdev.c                |  7 +++----
 lib/librte_rcu/rte_rcu_qsbr.c                 |  9 +-------
 lib/librte_stack/rte_stack.c                  |  7 +------
 lib/librte_vhost/vhost.c                      | 15 ++-----------
 17 files changed, 25 insertions(+), 126 deletions(-)

diff --git a/lib/librte_bbdev/rte_bbdev.c b/lib/librte_bbdev/rte_bbdev.c
index f6fe05aca..578f44484 100644
--- a/lib/librte_bbdev/rte_bbdev.c
+++ b/lib/librte_bbdev/rte_bbdev.c
@@ -29,7 +29,7 @@
 
 
 /* BBDev library logging ID */
-static int bbdev_logtype;
+RTE_LOG_REGISTER(bbdev_logtype, lib.bbdev, NOTICE);
 
 /* Helper macro for logging */
 #define rte_bbdev_log(level, fmt, ...) \
@@ -1134,9 +1134,3 @@ rte_bbdev_op_type_str(enum rte_bbdev_op_type op_type)
 	return NULL;
 }
 
-RTE_INIT(rte_bbdev_init_log)
-{
-	bbdev_logtype = rte_log_register("lib.bbdev");
-	if (bbdev_logtype >= 0)
-		rte_log_set_level(bbdev_logtype, RTE_LOG_NOTICE);
-}
diff --git a/lib/librte_bpf/bpf.c b/lib/librte_bpf/bpf.c
index 7e1879ffa..8d15885bc 100644
--- a/lib/librte_bpf/bpf.c
+++ b/lib/librte_bpf/bpf.c
@@ -14,8 +14,6 @@
 
 #include "bpf_impl.h"
 
-int rte_bpf_logtype;
-
 void
 rte_bpf_destroy(struct rte_bpf *bpf)
 {
@@ -55,9 +53,4 @@ bpf_jit(struct rte_bpf *bpf)
 	return rc;
 }
 
-RTE_INIT(rte_bpf_init_log)
-{
-	rte_bpf_logtype = rte_log_register("lib.bpf");
-	if (rte_bpf_logtype >= 0)
-		rte_log_set_level(rte_bpf_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(rte_bpf_logtype, lib.bpf, INFO);
diff --git a/lib/librte_cfgfile/rte_cfgfile.c b/lib/librte_cfgfile/rte_cfgfile.c
index 714717dd9..876c10d17 100644
--- a/lib/librte_cfgfile/rte_cfgfile.c
+++ b/lib/librte_cfgfile/rte_cfgfile.c
@@ -27,7 +27,7 @@ struct rte_cfgfile {
 	struct rte_cfgfile_section *sections;
 };
 
-static int cfgfile_logtype;
+RTE_LOG_REGISTER(cfgfile_logtype, lib.cfgfile, INFO);
 
 #define CFG_LOG(level, fmt, args...)					\
 	rte_log(RTE_LOG_ ## level, cfgfile_logtype, "%s(): " fmt "\n",	\
@@ -567,9 +567,3 @@ rte_cfgfile_has_entry(struct rte_cfgfile *cfg, const char *sectionname,
 	return rte_cfgfile_get_entry(cfg, sectionname, entryname) != NULL;
 }
 
-RTE_INIT(cfgfile_init)
-{
-	cfgfile_logtype = rte_log_register("lib.cfgfile");
-	if (cfgfile_logtype >= 0)
-		rte_log_set_level(cfgfile_logtype, RTE_LOG_INFO);
-}
diff --git a/lib/librte_compressdev/rte_compressdev.c b/lib/librte_compressdev/rte_compressdev.c
index b3c5651dc..49a342f40 100644
--- a/lib/librte_compressdev/rte_compressdev.c
+++ b/lib/librte_compressdev/rte_compressdev.c
@@ -763,9 +763,4 @@ rte_compressdev_name_get(uint8_t dev_id)
 	return dev->data->name;
 }
 
-RTE_INIT(rte_compressdev_log)
-{
-	compressdev_logtype = rte_log_register("lib.compressdev");
-	if (compressdev_logtype >= 0)
-		rte_log_set_level(compressdev_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(compressdev_logtype, lib.compressdev, NOTICE);
diff --git a/lib/librte_compressdev/rte_compressdev_pmd.c b/lib/librte_compressdev/rte_compressdev_pmd.c
index 46b25565a..7f500d76d 100644
--- a/lib/librte_compressdev/rte_compressdev_pmd.c
+++ b/lib/librte_compressdev/rte_compressdev_pmd.c
@@ -10,8 +10,6 @@
 #include "rte_compressdev_internal.h"
 #include "rte_compressdev_pmd.h"
 
-int compressdev_logtype;
-
 /**
  * Parse name from argument
  */
diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 8e10a6fc3..d06b7f9b1 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -46,8 +46,6 @@
 #include "ethdev_profile.h"
 #include "ethdev_private.h"
 
-int rte_eth_dev_logtype;
-
 static const char *MZ_RTE_ETH_DEV_DATA = "rte_eth_dev_data";
 struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS];
 
@@ -5295,11 +5293,10 @@ handle_port_link_status(const char *cmd __rte_unused,
 	return 0;
 }
 
-RTE_INIT(ethdev_init_log)
+RTE_LOG_REGISTER(rte_eth_dev_logtype, lib.ethdev, INFO);
+
+RTE_INIT(ethdev_init_telemetry)
 {
-	rte_eth_dev_logtype = rte_log_register("lib.ethdev");
-	if (rte_eth_dev_logtype >= 0)
-		rte_log_set_level(rte_eth_dev_logtype, RTE_LOG_INFO);
 	rte_telemetry_register_cmd("/ethdev/list", handle_port_list,
 			"Returns list of available ethdev ports. Takes no parameters");
 	rte_telemetry_register_cmd("/ethdev/xstats", handle_port_xstats,
diff --git a/lib/librte_eventdev/rte_event_timer_adapter.c b/lib/librte_eventdev/rte_event_timer_adapter.c
index 005459f7d..ae68b4566 100644
--- a/lib/librte_eventdev/rte_event_timer_adapter.c
+++ b/lib/librte_eventdev/rte_event_timer_adapter.c
@@ -29,9 +29,9 @@
 #define DATA_MZ_NAME_MAX_LEN 64
 #define DATA_MZ_NAME_FORMAT "rte_event_timer_adapter_data_%d"
 
-static int evtim_logtype;
-static int evtim_svc_logtype;
-static int evtim_buffer_logtype;
+RTE_LOG_REGISTER(evtim_logtype, lib.eventdev.adapter.timer, NOTICE);
+RTE_LOG_REGISTER(evtim_buffer_logtype, lib.eventdev.adapter.timer, NOTICE);
+RTE_LOG_REGISTER(evtim_svc_logtype, lib.eventdev.adapter.timer.svc, NOTICE);
 
 static struct rte_event_timer_adapter adapters[RTE_EVENT_TIMER_ADAPTER_NUM_MAX];
 
@@ -1188,18 +1188,3 @@ static const struct rte_event_timer_adapter_ops swtim_ops = {
 	.cancel_burst		= swtim_cancel_burst,
 };
 
-RTE_INIT(event_timer_adapter_init_log)
-{
-	evtim_logtype = rte_log_register("lib.eventdev.adapter.timer");
-	if (evtim_logtype >= 0)
-		rte_log_set_level(evtim_logtype, RTE_LOG_NOTICE);
-
-	evtim_buffer_logtype = rte_log_register("lib.eventdev.adapter.timer."
-						"buffer");
-	if (evtim_buffer_logtype >= 0)
-		rte_log_set_level(evtim_buffer_logtype, RTE_LOG_NOTICE);
-
-	evtim_svc_logtype = rte_log_register("lib.eventdev.adapter.timer.svc");
-	if (evtim_svc_logtype >= 0)
-		rte_log_set_level(evtim_svc_logtype, RTE_LOG_NOTICE);
-}
diff --git a/lib/librte_flow_classify/rte_flow_classify.c b/lib/librte_flow_classify/rte_flow_classify.c
index 6022064d8..639b0051f 100644
--- a/lib/librte_flow_classify/rte_flow_classify.c
+++ b/lib/librte_flow_classify/rte_flow_classify.c
@@ -10,8 +10,6 @@
 #include <rte_table_acl.h>
 #include <stdbool.h>
 
-int librte_flow_classify_logtype;
-
 static uint32_t unique_id = 1;
 
 enum rte_flow_classify_table_type table_type
@@ -669,10 +667,4 @@ rte_flow_classifier_query(struct rte_flow_classifier *cls,
 	return ret;
 }
 
-RTE_INIT(librte_flow_classify_init_log)
-{
-	librte_flow_classify_logtype =
-		rte_log_register("lib.flow_classify");
-	if (librte_flow_classify_logtype >= 0)
-		rte_log_set_level(librte_flow_classify_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(librte_flow_classify_logtype, lib.flow_classify, INFO);
diff --git a/lib/librte_graph/graph.c b/lib/librte_graph/graph.c
index 0ea83df3d..baa383cd7 100644
--- a/lib/librte_graph/graph.c
+++ b/lib/librte_graph/graph.c
@@ -579,9 +579,4 @@ rte_graph_max_count(void)
 	return graph_id;
 }
 
-RTE_INIT(rte_graph_init_log)
-{
-	rte_graph_logtype = rte_log_register("lib.graph");
-	if (rte_graph_logtype >= 0)
-		rte_log_set_level(rte_graph_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(rte_graph_logtype, lib.graph, INFO);
diff --git a/lib/librte_member/rte_member.c b/lib/librte_member/rte_member.c
index e0e7f127e..4696c0f17 100644
--- a/lib/librte_member/rte_member.c
+++ b/lib/librte_member/rte_member.c
@@ -16,8 +16,6 @@
 #include "rte_member_ht.h"
 #include "rte_member_vbf.h"
 
-int librte_member_logtype;
-
 TAILQ_HEAD(rte_member_list, rte_tailq_entry);
 static struct rte_tailq_elem rte_member_tailq = {
 	.name = "RTE_MEMBER",
@@ -299,9 +297,4 @@ rte_member_reset(const struct rte_member_setsum *setsum)
 	}
 }
 
-RTE_INIT(librte_member_init_log)
-{
-	librte_member_logtype = rte_log_register("lib.member");
-	if (librte_member_logtype >= 0)
-		rte_log_set_level(librte_member_logtype, RTE_LOG_DEBUG);
-}
+RTE_LOG_REGISTER(librte_member_logtype, lib.member, DEBUG);
diff --git a/lib/librte_metrics/rte_metrics_telemetry.c b/lib/librte_metrics/rte_metrics_telemetry.c
index 040e87d18..289ebae0b 100644
--- a/lib/librte_metrics/rte_metrics_telemetry.c
+++ b/lib/librte_metrics/rte_metrics_telemetry.c
@@ -525,6 +525,8 @@ handle_ports_stats_values_by_name(const char *cmd __rte_unused,
 	return used;
 }
 
+RTE_LOG_REGISTER(metrics_log_level, lib.metrics, ERR);
+
 RTE_INIT(metrics_ctor)
 {
 #ifdef RTE_LIBRTE_TELEMETRY
@@ -535,7 +537,4 @@ RTE_INIT(metrics_ctor)
 	rte_telemetry_legacy_register("ports_stats_values_by_name", DATA_REQ,
 			handle_ports_stats_values_by_name);
 #endif
-	metrics_log_level = rte_log_register("lib.metrics");
-	if (metrics_log_level >= 0)
-		rte_log_set_level(metrics_log_level, RTE_LOG_ERR);
 }
diff --git a/lib/librte_node/log.c b/lib/librte_node/log.c
index f035f91e8..f14199f07 100644
--- a/lib/librte_node/log.c
+++ b/lib/librte_node/log.c
@@ -4,11 +4,4 @@
 
 #include "node_private.h"
 
-int rte_node_logtype;
-
-RTE_INIT(rte_node_init_log)
-{
-	rte_node_logtype = rte_log_register("lib.node");
-	if (rte_node_logtype >= 0)
-		rte_log_set_level(rte_node_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(rte_node_logtype, lib.node, INFO);
diff --git a/lib/librte_pdump/rte_pdump.c b/lib/librte_pdump/rte_pdump.c
index f96709f95..5016e9dd2 100644
--- a/lib/librte_pdump/rte_pdump.c
+++ b/lib/librte_pdump/rte_pdump.c
@@ -14,8 +14,9 @@
 
 #define DEVICE_ID_SIZE 64
 
+RTE_LOG_REGISTER(pdump_logtype, lib.pdump, NOTICE);
+
 /* Macro for printing using RTE_LOG */
-static int pdump_logtype;
 #define PDUMP_LOG(level, fmt, args...)				\
 	rte_log(RTE_LOG_ ## level, pdump_logtype, "%s(): " fmt,	\
 		__func__, ## args)
@@ -561,9 +562,3 @@ rte_pdump_disable_by_deviceid(char *device_id, uint16_t queue,
 	return ret;
 }
 
-RTE_INIT(pdump_log)
-{
-	pdump_logtype = rte_log_register("lib.pdump");
-	if (pdump_logtype >= 0)
-		rte_log_set_level(pdump_logtype, RTE_LOG_NOTICE);
-}
diff --git a/lib/librte_rawdev/rte_rawdev.c b/lib/librte_rawdev/rte_rawdev.c
index c332a7648..aec61f425 100644
--- a/lib/librte_rawdev/rte_rawdev.c
+++ b/lib/librte_rawdev/rte_rawdev.c
@@ -613,11 +613,10 @@ handle_dev_xstats(const char *cmd __rte_unused,
 	return 0;
 }
 
-RTE_INIT(librawdev_init_log)
+RTE_LOG_REGISTER(librawdev_logtype, lib.rawdev, INFO);
+
+RTE_INIT(librawdev_init_telemetry)
 {
-	librawdev_logtype = rte_log_register("lib.rawdev");
-	if (librawdev_logtype >= 0)
-		rte_log_set_level(librawdev_logtype, RTE_LOG_INFO);
 	rte_telemetry_register_cmd("/rawdev/list", handle_dev_list,
 			"Returns list of available rawdev ports. Takes no parameters");
 	rte_telemetry_register_cmd("/rawdev/xstats", handle_dev_xstats,
diff --git a/lib/librte_rcu/rte_rcu_qsbr.c b/lib/librte_rcu/rte_rcu_qsbr.c
index 6a429d8b3..aebfdb0da 100644
--- a/lib/librte_rcu/rte_rcu_qsbr.c
+++ b/lib/librte_rcu/rte_rcu_qsbr.c
@@ -495,11 +495,4 @@ rte_rcu_qsbr_dq_delete(struct rte_rcu_qsbr_dq *dq)
 	return 0;
 }
 
-int rte_rcu_log_type;
-
-RTE_INIT(rte_rcu_register)
-{
-	rte_rcu_log_type = rte_log_register("lib.rcu");
-	if (rte_rcu_log_type >= 0)
-		rte_log_set_level(rte_rcu_log_type, RTE_LOG_ERR);
-}
+RTE_LOG_REGISTER(rte_rcu_log_type, lib.rcu, ERR);
diff --git a/lib/librte_stack/rte_stack.c b/lib/librte_stack/rte_stack.c
index e58fa545f..e4c0ce131 100644
--- a/lib/librte_stack/rte_stack.c
+++ b/lib/librte_stack/rte_stack.c
@@ -194,9 +194,4 @@ rte_stack_lookup(const char *name)
 	return r;
 }
 
-RTE_INIT(librte_stack_init_log)
-{
-	stack_logtype = rte_log_register("lib.stack");
-	if (stack_logtype >= 0)
-		rte_log_set_level(stack_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(stack_logtype, lib.stack, NOTICE);
diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
index 026631844..872d57f61 100644
--- a/lib/librte_vhost/vhost.c
+++ b/lib/librte_vhost/vhost.c
@@ -27,9 +27,6 @@
 
 struct virtio_net *vhost_devices[MAX_VHOST_DEVICE];
 
-int vhost_config_log_level;
-int vhost_data_log_level;
-
 /* Called with iotlb_lock read-locked */
 uint64_t
 __vhost_iova_to_vva(struct virtio_net *dev, struct vhost_virtqueue *vq,
@@ -1517,13 +1514,5 @@ int rte_vhost_extern_callback_register(int vid,
 	return 0;
 }
 
-RTE_INIT(vhost_log_init)
-{
-	vhost_config_log_level = rte_log_register("lib.vhost.config");
-	if (vhost_config_log_level >= 0)
-		rte_log_set_level(vhost_config_log_level, RTE_LOG_INFO);
-
-	vhost_data_log_level = rte_log_register("lib.vhost.data");
-	if (vhost_data_log_level >= 0)
-		rte_log_set_level(vhost_data_log_level, RTE_LOG_WARNING);
-}
+RTE_LOG_REGISTER(vhost_config_log_level, lib.vhost.config, INFO);
+RTE_LOG_REGISTER(vhost_data_log_level, lib.vhost.data, WARNING);
-- 
2.27.0


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

* [dpdk-dev]  [PATCH v5 03/13] drivers/vdpa: use log register macro
  2020-07-01 12:33       ` [dpdk-dev] [PATCH v5 00/13] rte_log registration usage improvement jerinj
  2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 01/13] eal/log: introduce log register macro jerinj
  2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 02/13] lib: use " jerinj
@ 2020-07-01 12:33         ` jerinj
  2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 04/13] drivers/raw: " jerinj
                           ` (10 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01 12:33 UTC (permalink / raw)
  To: dev, Xiao Wang, Matan Azrad, Viacheslav Ovsiienko
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/vdpa/ifc/ifcvf_vdpa.c | 10 +---------
 drivers/vdpa/mlx5/mlx5_vdpa.c |  7 +++----
 2 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
index ec97178dc..78299fa67 100644
--- a/drivers/vdpa/ifc/ifcvf_vdpa.c
+++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
@@ -24,6 +24,7 @@
 
 #include "base/ifcvf.h"
 
+RTE_LOG_REGISTER(ifcvf_vdpa_logtype, pmd.net.ifcvf_vdpa, NOTICE);
 #define DRV_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, ifcvf_vdpa_logtype, \
 		"IFCVF %s(): " fmt "\n", __func__, ##args)
@@ -44,8 +45,6 @@ static const char * const ifcvf_valid_arguments[] = {
 	NULL
 };
 
-static int ifcvf_vdpa_logtype;
-
 struct ifcvf_internal {
 	struct rte_vdpa_dev_addr dev_addr;
 	struct rte_pci_device *pdev;
@@ -1271,10 +1270,3 @@ static struct rte_pci_driver rte_ifcvf_vdpa = {
 RTE_PMD_REGISTER_PCI(net_ifcvf, rte_ifcvf_vdpa);
 RTE_PMD_REGISTER_PCI_TABLE(net_ifcvf, pci_id_ifcvf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_ifcvf, "* vfio-pci");
-
-RTE_INIT(ifcvf_vdpa_init_log)
-{
-	ifcvf_vdpa_logtype = rte_log_register("pmd.net.ifcvf_vdpa");
-	if (ifcvf_vdpa_logtype >= 0)
-		rte_log_set_level(ifcvf_vdpa_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c
index 1113d6cef..feb6148bb 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa.c
@@ -608,15 +608,14 @@ static struct rte_pci_driver mlx5_vdpa_driver = {
 	.drv_flags = 0,
 };
 
+
+RTE_LOG_REGISTER(mlx5_vdpa_logtype, pmd.vdpa.mlx5, NOTICE)
+
 /**
  * Driver initialization routine.
  */
 RTE_INIT(rte_mlx5_vdpa_init)
 {
-	/* Initialize common log type. */
-	mlx5_vdpa_logtype = rte_log_register("pmd.vdpa.mlx5");
-	if (mlx5_vdpa_logtype >= 0)
-		rte_log_set_level(mlx5_vdpa_logtype, RTE_LOG_NOTICE);
 	if (mlx5_glue)
 		rte_pci_register(&mlx5_vdpa_driver);
 }
-- 
2.27.0


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

* [dpdk-dev]  [PATCH v5 04/13] drivers/raw: use log register macro
  2020-07-01 12:33       ` [dpdk-dev] [PATCH v5 00/13] rte_log registration usage improvement jerinj
                           ` (2 preceding siblings ...)
  2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 03/13] drivers/vdpa: " jerinj
@ 2020-07-01 12:33         ` jerinj
  2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 05/13] drivers/net: " jerinj
                           ` (9 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01 12:33 UTC (permalink / raw)
  To: dev, Nipun Gupta, Rosen Xu, Tianfei zhang, Bruce Richardson,
	Xiaoyun Li, Jingjing Wu, Hemant Agrawal
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c  | 11 +----------
 drivers/raw/dpaa2_qdma/dpaa2_qdma.c    | 11 +----------
 drivers/raw/ifpga/ifpga_rawdev.c       | 10 +---------
 drivers/raw/ioat/ioat_rawdev.c         | 12 ++----------
 drivers/raw/ioat/rte_ioat_rawdev.h     |  2 --
 drivers/raw/ntb/ntb.c                  | 10 +---------
 drivers/raw/skeleton/skeleton_rawdev.c | 11 +----------
 7 files changed, 7 insertions(+), 60 deletions(-)

diff --git a/drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c b/drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c
index 7c21c6a52..c7bddbc6c 100644
--- a/drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c
+++ b/drivers/raw/dpaa2_cmdif/dpaa2_cmdif.c
@@ -20,9 +20,6 @@
 #include "dpaa2_cmdif_logs.h"
 #include "rte_pmd_dpaa2_cmdif.h"
 
-/* Dynamic log type identifier */
-int dpaa2_cmdif_logtype;
-
 /* CMDIF driver name */
 #define DPAA2_CMDIF_PMD_NAME dpaa2_dpci
 
@@ -291,10 +288,4 @@ static struct rte_vdev_driver dpaa2_cmdif_drv = {
 };
 
 RTE_PMD_REGISTER_VDEV(DPAA2_CMDIF_PMD_NAME, dpaa2_cmdif_drv);
-
-RTE_INIT(dpaa2_cmdif_init_log)
-{
-	dpaa2_cmdif_logtype = rte_log_register("pmd.raw.dpaa2.cmdif");
-	if (dpaa2_cmdif_logtype >= 0)
-		rte_log_set_level(dpaa2_cmdif_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(dpaa2_cmdif_logtype, pmd.raw.dpaa2.cmdif, INFO);
diff --git a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
index 1be1b6ddf..0b9c4e3d7 100644
--- a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
+++ b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
@@ -26,9 +26,6 @@
 
 #define DPAA2_QDMA_NO_PREFETCH "no_prefetch"
 
-/* Dynamic log type identifier */
-int dpaa2_qdma_logtype;
-
 uint32_t dpaa2_coherent_no_alloc_cache;
 uint32_t dpaa2_coherent_alloc_cache;
 
@@ -1495,10 +1492,4 @@ static struct rte_dpaa2_driver rte_dpaa2_qdma_pmd = {
 RTE_PMD_REGISTER_DPAA2(dpaa2_qdma, rte_dpaa2_qdma_pmd);
 RTE_PMD_REGISTER_PARAM_STRING(dpaa2_qdma,
 	"no_prefetch=<int> ");
-
-RTE_INIT(dpaa2_qdma_init_log)
-{
-	dpaa2_qdma_logtype = rte_log_register("pmd.raw.dpaa2.qdma");
-	if (dpaa2_qdma_logtype >= 0)
-		rte_log_set_level(dpaa2_qdma_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(dpaa2_qdma_logtype, pmd.raw.dpaa2.qdma, INFO);
diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c
index b8701e155..cc25c662b 100644
--- a/drivers/raw/ifpga/ifpga_rawdev.c
+++ b/drivers/raw/ifpga/ifpga_rawdev.c
@@ -47,8 +47,6 @@
 #define RTE_PCI_EXT_CAP_ID(header)       (int)(header & 0x0000ffff)
 #define RTE_PCI_EXT_CAP_NEXT(header)     ((header >> 20) & 0xffc)
 
-int ifpga_rawdev_logtype;
-
 #define PCI_VENDOR_ID_INTEL          0x8086
 /* PCI Device ID */
 #define PCIE_DEVICE_ID_PF_INT_5_X    0xBCBD
@@ -1597,13 +1595,7 @@ static struct rte_pci_driver rte_ifpga_rawdev_pmd = {
 RTE_PMD_REGISTER_PCI(ifpga_rawdev_pci_driver, rte_ifpga_rawdev_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(ifpga_rawdev_pci_driver, rte_ifpga_rawdev_pmd);
 RTE_PMD_REGISTER_KMOD_DEP(ifpga_rawdev_pci_driver, "* igb_uio | uio_pci_generic | vfio-pci");
-
-RTE_INIT(ifpga_rawdev_init_log)
-{
-	ifpga_rawdev_logtype = rte_log_register("driver.raw.init");
-	if (ifpga_rawdev_logtype >= 0)
-		rte_log_set_level(ifpga_rawdev_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(ifpga_rawdev_logtype, driver.raw.init, NOTICE);
 
 static const char * const valid_args[] = {
 #define IFPGA_ARG_NAME         "ifpga"
diff --git a/drivers/raw/ioat/ioat_rawdev.c b/drivers/raw/ioat/ioat_rawdev.c
index a8a48f90a..30d9f597e 100644
--- a/drivers/raw/ioat/ioat_rawdev.c
+++ b/drivers/raw/ioat/ioat_rawdev.c
@@ -9,9 +9,6 @@
 
 #include "rte_ioat_rawdev.h"
 
-/* Dynamic log type identifier */
-int ioat_pmd_logtype;
-
 static struct rte_pci_driver ioat_pmd_drv;
 
 #define IOAT_VENDOR_ID		0x8086
@@ -28,6 +25,8 @@ static struct rte_pci_driver ioat_pmd_drv;
 #define IOAT_DEVICE_ID_BDXF	0x6f2F
 #define IOAT_DEVICE_ID_ICX	0x0b00
 
+RTE_LOG_REGISTER(ioat_pmd_logtype,  rawdev.ioat, INFO);
+
 #define IOAT_PMD_LOG(level, fmt, args...) rte_log(RTE_LOG_ ## level, \
 	ioat_pmd_logtype, "%s(): " fmt "\n", __func__, ##args)
 
@@ -386,10 +385,3 @@ static struct rte_pci_driver ioat_pmd_drv = {
 RTE_PMD_REGISTER_PCI(IOAT_PMD_RAWDEV_NAME, ioat_pmd_drv);
 RTE_PMD_REGISTER_PCI_TABLE(IOAT_PMD_RAWDEV_NAME, pci_id_ioat_map);
 RTE_PMD_REGISTER_KMOD_DEP(IOAT_PMD_RAWDEV_NAME, "* igb_uio | uio_pci_generic");
-
-RTE_INIT(ioat_pmd_init_log)
-{
-	ioat_pmd_logtype = rte_log_register(IOAT_PMD_LOG_NAME);
-	if (ioat_pmd_logtype >= 0)
-		rte_log_set_level(ioat_pmd_logtype, RTE_LOG_INFO);
-}
diff --git a/drivers/raw/ioat/rte_ioat_rawdev.h b/drivers/raw/ioat/rte_ioat_rawdev.h
index 4b271f174..f765a6557 100644
--- a/drivers/raw/ioat/rte_ioat_rawdev.h
+++ b/drivers/raw/ioat/rte_ioat_rawdev.h
@@ -25,8 +25,6 @@
 #define IOAT_PMD_RAWDEV_NAME rawdev_ioat
 /** String reported as the device driver name by rte_rawdev_info_get() */
 #define IOAT_PMD_RAWDEV_NAME_STR "rawdev_ioat"
-/** Name used to adjust the log level for this driver */
-#define IOAT_PMD_LOG_NAME "rawdev.ioat"
 
 /**
  * Configuration structure for an ioat rawdev instance
diff --git a/drivers/raw/ntb/ntb.c b/drivers/raw/ntb/ntb.c
index dd0b72f8c..e40412bb7 100644
--- a/drivers/raw/ntb/ntb.c
+++ b/drivers/raw/ntb/ntb.c
@@ -23,8 +23,6 @@
 #include "rte_pmd_ntb.h"
 #include "ntb.h"
 
-int ntb_logtype;
-
 static const struct rte_pci_id pci_id_ntb_map[] = {
 	{ RTE_PCI_DEVICE(NTB_INTEL_VENDOR_ID, NTB_INTEL_DEV_ID_B2B_SKX) },
 	{ .vendor_id = 0, /* sentinel */ },
@@ -1504,10 +1502,4 @@ static struct rte_pci_driver rte_ntb_pmd = {
 RTE_PMD_REGISTER_PCI(raw_ntb, rte_ntb_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(raw_ntb, pci_id_ntb_map);
 RTE_PMD_REGISTER_KMOD_DEP(raw_ntb, "* igb_uio | uio_pci_generic | vfio-pci");
-
-RTE_INIT(ntb_init_log)
-{
-	ntb_logtype = rte_log_register("pmd.raw.ntb");
-	if (ntb_logtype >= 0)
-		rte_log_set_level(ntb_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(ntb_logtype, pmd.raw.ntb, INFO);
diff --git a/drivers/raw/skeleton/skeleton_rawdev.c b/drivers/raw/skeleton/skeleton_rawdev.c
index 586183a5b..72ece887a 100644
--- a/drivers/raw/skeleton/skeleton_rawdev.c
+++ b/drivers/raw/skeleton/skeleton_rawdev.c
@@ -28,9 +28,6 @@
 
 #include "skeleton_rawdev.h"
 
-/* Dynamic log type identifier */
-int skeleton_pmd_logtype;
-
 /* Count of instances */
 static uint16_t skeldev_init_once;
 
@@ -759,10 +756,4 @@ static struct rte_vdev_driver skeleton_pmd_drv = {
 };
 
 RTE_PMD_REGISTER_VDEV(SKELETON_PMD_RAWDEV_NAME, skeleton_pmd_drv);
-
-RTE_INIT(skeleton_pmd_init_log)
-{
-	skeleton_pmd_logtype = rte_log_register("rawdev.skeleton");
-	if (skeleton_pmd_logtype >= 0)
-		rte_log_set_level(skeleton_pmd_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(skeleton_pmd_logtype, rawdev.skeleton, INFO);
-- 
2.27.0


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

* [dpdk-dev]  [PATCH v5 05/13] drivers/net: use log register macro
  2020-07-01 12:33       ` [dpdk-dev] [PATCH v5 00/13] rte_log registration usage improvement jerinj
                           ` (3 preceding siblings ...)
  2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 04/13] drivers/raw: " jerinj
@ 2020-07-01 12:33         ` jerinj
  2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 06/13] drivers/mempool: " jerinj
                           ` (8 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01 12:33 UTC (permalink / raw)
  To: dev, John W. Linville, Xiaolong Ye, Qi Zhang, Shepard Siegel,
	Ed Czeck, John Miller, Igor Russkikh, Pavel Belous,
	Steven Webster, Matt Peters, Somalapuram Amaranath, Rasesh Mody,
	Shahed Shaikh, Ajit Khaparde, Somnath Kotur, Chas Williams,
	Wei Hu (Xavier),
	Rahul Lakkireddy, Hemant Agrawal, Sachin Saxena, Marcin Wojtas,
	Michal Krawczyk, Guy Tzalik, Evgeny Schemeilin, Igor Chauskin,
	Gagandeep Singh, John Daley, Hyong Youb Kim, Gaetan Rivet,
	Xiao Wang, Ziyang Xuan, Xiaoyun Wang, Guoyang Zhou,
	Min Hu (Connor),
	Yisen Zhuang, Beilei Xing, Jeff Guo, Jingjing Wu, Qiming Yang,
	Wei Zhao, Alfredo Cardigliano, Rosen Xu, Ferruh Yigit,
	Shijith Thotton, Srisivasubramanian Srinivasan, Jakub Grajciar,
	Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko, Zyta Szpak,
	Liron Himi, Stephen Hemminger, K. Y. Srinivasan, Haiyang Zhang,
	Heinrich Kuhn, Tetsuya Mukawa, Harman Kalra, Akhil Goyal,
	Bruce Richardson, Jasvinder Singh, Cristian Dumitrescu,
	Martin Zizka, Jakub Neruda, Keith Wiles, Jerin Jacob,
	Maciej Czekaj, Maxime Coquelin, Zhihong Wang, Yong Wang
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena, adamx.dybkowski

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/net/af_packet/rte_eth_af_packet.c |  8 +---
 drivers/net/af_xdp/rte_eth_af_xdp.c       |  8 +---
 drivers/net/ark/ark_ethdev.c              | 10 +----
 drivers/net/atlantic/atl_ethdev.c         | 15 +------
 drivers/net/avp/avp_ethdev.c              | 10 +----
 drivers/net/axgbe/axgbe_ethdev.c          | 15 +------
 drivers/net/bnx2x/bnx2x_ethdev.c          | 15 +------
 drivers/net/bnxt/bnxt_ethdev.c            |  9 +----
 drivers/net/bonding/rte_eth_bond_pmd.c    |  9 +----
 drivers/net/cxgbe/cxgbe_ethdev.c          | 15 +------
 drivers/net/dpaa/dpaa_ethdev.c            |  9 +----
 drivers/net/dpaa2/dpaa2_ethdev.c          |  9 +----
 drivers/net/ena/ena_ethdev.c              | 48 +++--------------------
 drivers/net/enetc/enetc_ethdev.c          | 10 +----
 drivers/net/enic/enic_ethdev.c            |  9 +----
 drivers/net/failsafe/failsafe.c           | 10 +----
 drivers/net/fm10k/fm10k_ethdev.c          | 40 +++----------------
 drivers/net/hinic/hinic_pmd_ethdev.c      | 11 +-----
 drivers/net/hns3/hns3_ethdev.c            | 15 +------
 drivers/net/i40e/i40e_ethdev.c            | 38 +++---------------
 drivers/net/iavf/iavf_ethdev.c            | 40 +++----------------
 drivers/net/ice/ice_ethdev.c              | 38 +++---------------
 drivers/net/igc/igc_logs.c                | 16 +-------
 drivers/net/ionic/ionic_ethdev.c          | 10 +----
 drivers/net/ipn3ke/ipn3ke_ethdev.c        | 10 +----
 drivers/net/ixgbe/ixgbe_ethdev.c          | 39 +++---------------
 drivers/net/kni/rte_eth_kni.c             |  9 +----
 drivers/net/liquidio/lio_ethdev.c         | 15 +------
 drivers/net/memif/rte_eth_memif.c         |  9 +----
 drivers/net/mlx4/mlx4.c                   | 11 ++----
 drivers/net/mlx5/mlx5.c                   | 10 ++---
 drivers/net/mvneta/mvneta_ethdev.c        | 10 +----
 drivers/net/mvpp2/mrvl_ethdev.c           | 10 +----
 drivers/net/netvsc/hn_ethdev.c            | 15 +------
 drivers/net/nfp/nfp_net.c                 | 15 +------
 drivers/net/null/rte_eth_null.c           |  8 +---
 drivers/net/octeontx/octeontx_ethdev.c    | 21 ++--------
 drivers/net/pcap/rte_eth_pcap.c           |  8 +---
 drivers/net/pfe/pfe_ethdev.c              | 10 +----
 drivers/net/qede/qede_ethdev.c            | 16 +-------
 drivers/net/ring/rte_eth_ring.c           |  8 +---
 drivers/net/softnic/rte_eth_softnic.c     | 10 +----
 drivers/net/szedata2/rte_eth_szedata2.c   | 15 +------
 drivers/net/tap/rte_eth_tap.c             |  9 +----
 drivers/net/thunderx/nicvf_ethdev.c       | 21 ++--------
 drivers/net/vdev_netvsc/vdev_netvsc.c     | 13 +-----
 drivers/net/vhost/rte_eth_vhost.c         |  8 +---
 drivers/net/virtio/virtio_ethdev.c        | 15 +------
 drivers/net/vmxnet3/vmxnet3_ethdev.c      | 15 +------
 49 files changed, 97 insertions(+), 650 deletions(-)

diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index 22feb72e3..300039bbf 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -97,7 +97,7 @@ static struct rte_eth_link pmd_link = {
 	.link_autoneg = ETH_LINK_FIXED,
 };
 
-static int af_packet_logtype;
+RTE_LOG_REGISTER(af_packet_logtype, pmd.net.packet, NOTICE);
 
 #define PMD_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, af_packet_logtype, \
@@ -1082,9 +1082,3 @@ RTE_PMD_REGISTER_PARAM_STRING(net_af_packet,
 	"framecnt=<int> "
 	"qdisc_bypass=<0|1>");
 
-RTE_INIT(af_packet_init_log)
-{
-	af_packet_logtype = rte_log_register("pmd.net.packet");
-	if (af_packet_logtype >= 0)
-		rte_log_set_level(af_packet_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 06124ba78..98b9cff38 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -50,7 +50,7 @@
 #define PF_XDP AF_XDP
 #endif
 
-static int af_xdp_logtype;
+RTE_LOG_REGISTER(af_xdp_logtype, pmd.net.af_xdp, NOTICE);
 
 #define AF_XDP_LOG(level, fmt, args...)			\
 	rte_log(RTE_LOG_ ## level, af_xdp_logtype,	\
@@ -1374,9 +1374,3 @@ RTE_PMD_REGISTER_PARAM_STRING(net_af_xdp,
 			      "start_queue=<int> "
 			      "queue_count=<int> ");
 
-RTE_INIT(af_xdp_init_log)
-{
-	af_xdp_logtype = rte_log_register("pmd.net.af_xdp");
-	if (af_xdp_logtype >= 0)
-		rte_log_set_level(af_xdp_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c
index c3642012d..b32ccd867 100644
--- a/drivers/net/ark/ark_ethdev.c
+++ b/drivers/net/ark/ark_ethdev.c
@@ -78,8 +78,6 @@ static int  eth_ark_set_mtu(struct rte_eth_dev *dev, uint16_t size);
 #define ARK_TX_MAX_QUEUE (4096 * 4)
 #define ARK_TX_MIN_QUEUE (256)
 
-int ark_logtype;
-
 static const char * const valid_arguments[] = {
 	ARK_PKTGEN_ARG,
 	ARK_PKTCHKR_ARG,
@@ -1018,10 +1016,4 @@ RTE_PMD_REGISTER_PARAM_STRING(net_ark,
 			      ARK_PKTGEN_ARG "=<filename> "
 			      ARK_PKTCHKR_ARG "=<filename> "
 			      ARK_PKTDIR_ARG "=<bitmap>");
-
-RTE_INIT(ark_init_log)
-{
-	ark_logtype = rte_log_register("pmd.net.ark");
-	if (ark_logtype >= 0)
-		rte_log_set_level(ark_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(ark_logtype, pmd.net.ark, NOTICE);
diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_ethdev.c
index b2b3bd36c..d3b00ab29 100644
--- a/drivers/net/atlantic/atl_ethdev.c
+++ b/drivers/net/atlantic/atl_ethdev.c
@@ -120,9 +120,6 @@ static int eth_atl_pci_remove(struct rte_pci_device *pci_dev);
 static int atl_dev_info_get(struct rte_eth_dev *dev,
 				struct rte_eth_dev_info *dev_info);
 
-int atl_logtype_init;
-int atl_logtype_driver;
-
 /*
  * The set of PCI devices this driver supports
  */
@@ -1929,13 +1926,5 @@ is_atlantic_supported(struct rte_eth_dev *dev)
 RTE_PMD_REGISTER_PCI(net_atlantic, rte_atl_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_atlantic, pci_id_atl_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_atlantic, "* igb_uio | uio_pci_generic");
-
-RTE_INIT(atl_init_log)
-{
-	atl_logtype_init = rte_log_register("pmd.net.atlantic.init");
-	if (atl_logtype_init >= 0)
-		rte_log_set_level(atl_logtype_init, RTE_LOG_NOTICE);
-	atl_logtype_driver = rte_log_register("pmd.net.atlantic.driver");
-	if (atl_logtype_driver >= 0)
-		rte_log_set_level(atl_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(atl_logtype_init, pmd.net.atlantic.init, NOTICE);
+RTE_LOG_REGISTER(atl_logtype_driver, pmd.net.atlantic.driver, NOTICE);
diff --git a/drivers/net/avp/avp_ethdev.c b/drivers/net/avp/avp_ethdev.c
index 1abe96ce5..5b47f0924 100644
--- a/drivers/net/avp/avp_ethdev.c
+++ b/drivers/net/avp/avp_ethdev.c
@@ -32,8 +32,6 @@
 
 #include "avp_logs.h"
 
-int avp_logtype_driver;
-
 static int avp_dev_create(struct rte_pci_device *pci_dev,
 			  struct rte_eth_dev *eth_dev);
 
@@ -2306,10 +2304,4 @@ avp_dev_stats_reset(struct rte_eth_dev *eth_dev)
 
 RTE_PMD_REGISTER_PCI(net_avp, rte_avp_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_avp, pci_id_avp_map);
-
-RTE_INIT(avp_init_log)
-{
-	avp_logtype_driver = rte_log_register("pmd.net.avp.driver");
-	if (avp_logtype_driver >= 0)
-		rte_log_set_level(avp_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(avp_logtype_driver, pmd.net.avp.driver, NOTICE);
diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c
index db86b9813..0c25739f8 100644
--- a/drivers/net/axgbe/axgbe_ethdev.c
+++ b/drivers/net/axgbe/axgbe_ethdev.c
@@ -143,9 +143,6 @@ static const struct axgbe_xstats axgbe_xstats_strings[] = {
 #define AMD_PCI_AXGBE_DEVICE_V2A 0x1458
 #define AMD_PCI_AXGBE_DEVICE_V2B 0x1459
 
-int axgbe_logtype_init;
-int axgbe_logtype_driver;
-
 static const struct rte_pci_id pci_id_axgbe_map[] = {
 	{RTE_PCI_DEVICE(AMD_PCI_VENDOR_ID, AMD_PCI_AXGBE_DEVICE_V2A)},
 	{RTE_PCI_DEVICE(AMD_PCI_VENDOR_ID, AMD_PCI_AXGBE_DEVICE_V2B)},
@@ -1842,13 +1839,5 @@ static struct rte_pci_driver rte_axgbe_pmd = {
 RTE_PMD_REGISTER_PCI(net_axgbe, rte_axgbe_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_axgbe, pci_id_axgbe_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_axgbe, "* igb_uio | uio_pci_generic | vfio-pci");
-
-RTE_INIT(axgbe_init_log)
-{
-	axgbe_logtype_init = rte_log_register("pmd.net.axgbe.init");
-	if (axgbe_logtype_init >= 0)
-		rte_log_set_level(axgbe_logtype_init, RTE_LOG_NOTICE);
-	axgbe_logtype_driver = rte_log_register("pmd.net.axgbe.driver");
-	if (axgbe_logtype_driver >= 0)
-		rte_log_set_level(axgbe_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(axgbe_logtype_init, pmd.net.axgbe.init, NOTICE);
+RTE_LOG_REGISTER(axgbe_logtype_driver, pmd.net.axgbe.driver, NOTICE);
diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c
index adc3690fc..b2ea5fafa 100644
--- a/drivers/net/bnx2x/bnx2x_ethdev.c
+++ b/drivers/net/bnx2x/bnx2x_ethdev.c
@@ -13,9 +13,6 @@
 #include <rte_ethdev_pci.h>
 #include <rte_alarm.h>
 
-int bnx2x_logtype_init;
-int bnx2x_logtype_driver;
-
 /*
  * The set of PCI devices this driver supports
  */
@@ -805,13 +802,5 @@ RTE_PMD_REGISTER_KMOD_DEP(net_bnx2x, "* igb_uio | uio_pci_generic | vfio-pci");
 RTE_PMD_REGISTER_PCI(net_bnx2xvf, rte_bnx2xvf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_bnx2xvf, pci_id_bnx2xvf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_bnx2xvf, "* igb_uio | vfio-pci");
-
-RTE_INIT(bnx2x_init_log)
-{
-	bnx2x_logtype_init = rte_log_register("pmd.net.bnx2x.init");
-	if (bnx2x_logtype_init >= 0)
-		rte_log_set_level(bnx2x_logtype_init, RTE_LOG_NOTICE);
-	bnx2x_logtype_driver = rte_log_register("pmd.net.bnx2x.driver");
-	if (bnx2x_logtype_driver >= 0)
-		rte_log_set_level(bnx2x_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(bnx2x_logtype_init, pmd.net.bnx2x.init, NOTICE);
+RTE_LOG_REGISTER(bnx2x_logtype_driver, pmd.net.bnx2x.driver, NOTICE);
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index e8b4c058a..59c318076 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -31,7 +31,6 @@
 #define DRV_MODULE_NAME		"bnxt"
 static const char bnxt_version[] =
 	"Broadcom NetXtreme driver " DRV_MODULE_NAME;
-int bnxt_logtype_driver;
 
 /*
  * The set of PCI devices this driver supports
@@ -5668,13 +5667,7 @@ bool is_bnxt_supported(struct rte_eth_dev *dev)
 	return is_device_supported(dev, &bnxt_rte_pmd);
 }
 
-RTE_INIT(bnxt_init_log)
-{
-	bnxt_logtype_driver = rte_log_register("pmd.net.bnxt.driver");
-	if (bnxt_logtype_driver >= 0)
-		rte_log_set_level(bnxt_logtype_driver, RTE_LOG_NOTICE);
-}
-
+RTE_LOG_REGISTER(bnxt_logtype_driver, pmd.net.bnxt.driver, NOTICE);
 RTE_PMD_REGISTER_PCI(net_bnxt, bnxt_rte_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_bnxt, bnxt_pci_id_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_bnxt, "* igb_uio | uio_pci_generic | vfio-pci");
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 612a64599..044a1cfbc 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -3750,11 +3750,4 @@ RTE_PMD_REGISTER_PARAM_STRING(net_bonding,
 	"up_delay=<int> "
 	"down_delay=<int>");
 
-int bond_logtype;
-
-RTE_INIT(bond_init_log)
-{
-	bond_logtype = rte_log_register("pmd.net.bond");
-	if (bond_logtype >= 0)
-		rte_log_set_level(bond_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(bond_logtype, pmd.net.bond, NOTICE);
diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index 1deee2f5c..7c6016d5c 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -38,9 +38,6 @@
 #include "cxgbe_pfvf.h"
 #include "cxgbe_flow.h"
 
-int cxgbe_logtype;
-int cxgbe_mbox_logtype;
-
 /*
  * Macros needed to support the PCI Device ID Table ...
  */
@@ -1247,13 +1244,5 @@ RTE_PMD_REGISTER_PARAM_STRING(net_cxgbe,
 			      CXGBE_DEVARG_CMN_TX_MODE_LATENCY "=<0|1> "
 			      CXGBE_DEVARG_PF_FILTER_MODE "=<uint32> "
 			      CXGBE_DEVARG_PF_FILTER_MASK "=<uint32> ");
-
-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);
-	cxgbe_mbox_logtype = rte_log_register("pmd.net.cxgbe.mbox");
-	if (cxgbe_mbox_logtype >= 0)
-		rte_log_set_level(cxgbe_mbox_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(cxgbe_logtype, pmd.net.cxgbe, NOTICE);
+RTE_LOG_REGISTER(cxgbe_mbox_logtype, pmd.net.cxgbe.mbox, NOTICE);
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 13d1c6a1f..f1c9a7151 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -46,8 +46,6 @@
 #include <fsl_bman.h>
 #include <fsl_fman.h>
 
-int dpaa_logtype_pmd;
-
 /* Supported Rx offloads */
 static uint64_t dev_rx_offloads_sup =
 		DEV_RX_OFFLOAD_JUMBO_FRAME |
@@ -1666,9 +1664,4 @@ static struct rte_dpaa_driver rte_dpaa_pmd = {
 };
 
 RTE_PMD_REGISTER_DPAA(net_dpaa, rte_dpaa_pmd);
-RTE_INIT(dpaa_net_init_log)
-{
-	dpaa_logtype_pmd = rte_log_register("pmd.net.dpaa");
-	if (dpaa_logtype_pmd >= 0)
-		rte_log_set_level(dpaa_logtype_pmd, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa_logtype_pmd, pmd.net.dpaa, NOTICE);
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 2f031ec5c..a1f19194d 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -106,8 +106,6 @@ static int dpaa2_dev_set_link_up(struct rte_eth_dev *dev);
 static int dpaa2_dev_set_link_down(struct rte_eth_dev *dev);
 static int dpaa2_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
 
-int dpaa2_logtype_pmd;
-
 void
 rte_pmd_dpaa2_set_timestamp(enum pmd_dpaa2_ts enable)
 {
@@ -2694,9 +2692,4 @@ RTE_PMD_REGISTER_DPAA2(net_dpaa2, rte_dpaa2_pmd);
 RTE_PMD_REGISTER_PARAM_STRING(net_dpaa2,
 		DRIVER_LOOPBACK_MODE "=<int> "
 		DRIVER_NO_PREFETCH_MODE "=<int>");
-RTE_INIT(dpaa2_pmd_init_log)
-{
-	dpaa2_logtype_pmd = rte_log_register("pmd.net.dpaa2");
-	if (dpaa2_logtype_pmd >= 0)
-		rte_log_set_level(dpaa2_logtype_pmd, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa2_logtype_pmd, pmd.net.dpaa2, NOTICE);
diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index fbddc79f7..da8c8ad92 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -141,22 +141,6 @@ static const struct ena_stats ena_stats_rx_strings[] = {
 #define	ENA_TX_OFFLOAD_NOTSUP_MASK	\
 	(PKT_TX_OFFLOAD_MASK ^ ENA_TX_OFFLOAD_MASK)
 
-int ena_logtype_init;
-int ena_logtype_driver;
-
-#ifdef RTE_LIBRTE_ENA_DEBUG_RX
-int ena_logtype_rx;
-#endif
-#ifdef RTE_LIBRTE_ENA_DEBUG_TX
-int ena_logtype_tx;
-#endif
-#ifdef RTE_LIBRTE_ENA_DEBUG_TX_FREE
-int ena_logtype_tx_free;
-#endif
-#ifdef RTE_LIBRTE_ENA_COM_DEBUG
-int ena_logtype_com;
-#endif
-
 static const struct rte_pci_id pci_id_ena_map[] = {
 	{ RTE_PCI_DEVICE(PCI_VENDOR_ID_AMAZON, PCI_DEVICE_ID_ENA_VF) },
 	{ RTE_PCI_DEVICE(PCI_VENDOR_ID_AMAZON, PCI_DEVICE_ID_ENA_LLQ_VF) },
@@ -2849,40 +2833,20 @@ RTE_PMD_REGISTER_PCI(net_ena, rte_ena_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_ena, pci_id_ena_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_ena, "* igb_uio | uio_pci_generic | vfio-pci");
 RTE_PMD_REGISTER_PARAM_STRING(net_ena, ENA_DEVARG_LARGE_LLQ_HDR "=<0|1>");
-
-RTE_INIT(ena_init_log)
-{
-	ena_logtype_init = rte_log_register("pmd.net.ena.init");
-	if (ena_logtype_init >= 0)
-		rte_log_set_level(ena_logtype_init, RTE_LOG_NOTICE);
-	ena_logtype_driver = rte_log_register("pmd.net.ena.driver");
-	if (ena_logtype_driver >= 0)
-		rte_log_set_level(ena_logtype_driver, RTE_LOG_NOTICE);
-
+RTE_LOG_REGISTER(ena_logtype_init, pmd.net.ena.init, NOTICE);
+RTE_LOG_REGISTER(ena_logtype_driver, pmd.net.ena.driver, NOTICE);
 #ifdef RTE_LIBRTE_ENA_DEBUG_RX
-	ena_logtype_rx = rte_log_register("pmd.net.ena.rx");
-	if (ena_logtype_rx >= 0)
-		rte_log_set_level(ena_logtype_rx, RTE_LOG_NOTICE);
+RTE_LOG_REGISTER(ena_logtype_rx, pmd.net.ena.rx, NOTICE);
 #endif
-
 #ifdef RTE_LIBRTE_ENA_DEBUG_TX
-	ena_logtype_tx = rte_log_register("pmd.net.ena.tx");
-	if (ena_logtype_tx >= 0)
-		rte_log_set_level(ena_logtype_tx, RTE_LOG_NOTICE);
+RTE_LOG_REGISTER(ena_logtype_tx, pmd.net.ena.tx, NOTICE);
 #endif
-
 #ifdef RTE_LIBRTE_ENA_DEBUG_TX_FREE
-	ena_logtype_tx_free = rte_log_register("pmd.net.ena.tx_free");
-	if (ena_logtype_tx_free >= 0)
-		rte_log_set_level(ena_logtype_tx_free, RTE_LOG_NOTICE);
+RTE_LOG_REGISTER(ena_logtype_tx_free, pmd.net.ena.tx_free, NOTICE);
 #endif
-
 #ifdef RTE_LIBRTE_ENA_COM_DEBUG
-	ena_logtype_com = rte_log_register("pmd.net.ena.com");
-	if (ena_logtype_com >= 0)
-		rte_log_set_level(ena_logtype_com, RTE_LOG_NOTICE);
+RTE_LOG_REGISTER(ena_logtype_com, pmd.net.ena.com, NOTICE);
 #endif
-}
 
 /******************************************************************************
  ******************************** AENQ Handlers *******************************
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index 1716e11dd..c6fb42740 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -10,8 +10,6 @@
 #include "enetc_logs.h"
 #include "enetc.h"
 
-int enetc_logtype_pmd;
-
 static int
 enetc_dev_start(struct rte_eth_dev *dev)
 {
@@ -951,10 +949,4 @@ static struct rte_pci_driver rte_enetc_pmd = {
 RTE_PMD_REGISTER_PCI(net_enetc, rte_enetc_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_enetc, pci_id_enetc_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_enetc, "* vfio-pci");
-
-RTE_INIT(enetc_pmd_init_log)
-{
-	enetc_logtype_pmd = rte_log_register("pmd.net.enetc");
-	if (enetc_logtype_pmd >= 0)
-		rte_log_set_level(enetc_logtype_pmd, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(enetc_logtype_pmd, pmd.net.enetc, NOTICE);
diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c
index 32d5397f8..6a3580fef 100644
--- a/drivers/net/enic/enic_ethdev.c
+++ b/drivers/net/enic/enic_ethdev.c
@@ -21,8 +21,6 @@
 #include "vnic_enet.h"
 #include "enic.h"
 
-int enic_pmd_logtype;
-
 /*
  * The set of PCI devices this driver supports
  */
@@ -71,12 +69,7 @@ static const struct vic_speed_capa {
 #define ENIC_DEVARG_GENEVE_OPT "geneve-opt"
 #define ENIC_DEVARG_IG_VLAN_REWRITE "ig-vlan-rewrite"
 
-RTE_INIT(enicpmd_init_log)
-{
-	enic_pmd_logtype = rte_log_register("pmd.net.enic");
-	if (enic_pmd_logtype >= 0)
-		rte_log_set_level(enic_pmd_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(enic_pmd_logtype, pmd.net.enic, INFO);
 
 static int
 enicpmd_fdir_ctrl_func(struct rte_eth_dev *eth_dev,
diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsafe.c
index 72362f35d..4a4b7ceab 100644
--- a/drivers/net/failsafe/failsafe.c
+++ b/drivers/net/failsafe/failsafe.c
@@ -15,8 +15,6 @@
 
 #include "failsafe_private.h"
 
-int failsafe_logtype;
-
 const char pmd_failsafe_driver_name[] = FAILSAFE_DRIVER_NAME;
 static const struct rte_eth_link eth_link = {
 	.link_speed = ETH_SPEED_NUM_10G,
@@ -410,10 +408,4 @@ static struct rte_vdev_driver failsafe_drv = {
 
 RTE_PMD_REGISTER_VDEV(net_failsafe, failsafe_drv);
 RTE_PMD_REGISTER_PARAM_STRING(net_failsafe, PMD_FAILSAFE_PARAM_STRING);
-
-RTE_INIT(failsafe_init_log)
-{
-	failsafe_logtype = rte_log_register("pmd.net.failsafe");
-	if (failsafe_logtype >= 0)
-		rte_log_set_level(failsafe_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(failsafe_logtype, pmd.net.failsafe, NOTICE)
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index f537ab286..cb0dd3bae 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -40,19 +40,6 @@
 #define GLORT_FD_MASK    GLORT_PF_MASK
 #define GLORT_FD_INDEX   GLORT_FD_Q_BASE
 
-int fm10k_logtype_init;
-int fm10k_logtype_driver;
-
-#ifdef RTE_LIBRTE_FM10K_DEBUG_RX
-int fm10k_logtype_rx;
-#endif
-#ifdef RTE_LIBRTE_FM10K_DEBUG_TX
-int fm10k_logtype_tx;
-#endif
-#ifdef RTE_LIBRTE_FM10K_DEBUG_TX_FREE
-int fm10k_logtype_tx_free;
-#endif
-
 static void fm10k_close_mbx_service(struct fm10k_hw *hw);
 static int fm10k_dev_promiscuous_enable(struct rte_eth_dev *dev);
 static int fm10k_dev_promiscuous_disable(struct rte_eth_dev *dev);
@@ -3318,31 +3305,14 @@ 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)
-{
-	fm10k_logtype_init = rte_log_register("pmd.net.fm10k.init");
-	if (fm10k_logtype_init >= 0)
-		rte_log_set_level(fm10k_logtype_init, RTE_LOG_NOTICE);
-	fm10k_logtype_driver = rte_log_register("pmd.net.fm10k.driver");
-	if (fm10k_logtype_driver >= 0)
-		rte_log_set_level(fm10k_logtype_driver, RTE_LOG_NOTICE);
-
+RTE_LOG_REGISTER(fm10k_logtype_init, pmd.net.fm10k.init, NOTICE);
+RTE_LOG_REGISTER(fm10k_logtype_driver, pmd.net.fm10k.driver, NOTICE);
 #ifdef RTE_LIBRTE_FM10K_DEBUG_RX
-	fm10k_logtype_rx = rte_log_register("pmd.net.fm10k.rx");
-	if (fm10k_logtype_rx >= 0)
-		rte_log_set_level(fm10k_logtype_rx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(fm10k_logtype_rx, pmd.net.fm10k.rx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_FM10K_DEBUG_TX
-	fm10k_logtype_tx = rte_log_register("pmd.net.fm10k.tx");
-	if (fm10k_logtype_tx >= 0)
-		rte_log_set_level(fm10k_logtype_tx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(fm10k_logtype_tx, pmd.net.fm10k.tx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_FM10K_DEBUG_TX_FREE
-	fm10k_logtype_tx_free = rte_log_register("pmd.net.fm10k.tx_free");
-	if (fm10k_logtype_tx_free >= 0)
-		rte_log_set_level(fm10k_logtype_tx_free, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(fm10k_logtype_tx_free, pmd.net.fm10k.tx_free, DEBUG);
 #endif
-}
diff --git a/drivers/net/hinic/hinic_pmd_ethdev.c b/drivers/net/hinic/hinic_pmd_ethdev.c
index 0c3e1c0cd..8f81e2230 100644
--- a/drivers/net/hinic/hinic_pmd_ethdev.c
+++ b/drivers/net/hinic/hinic_pmd_ethdev.c
@@ -78,9 +78,6 @@
 /* lro numer limit for one packet */
 #define HINIC_LRO_WQE_NUM_DEFAULT	8
 
-/* Driver-specific log messages type */
-int hinic_logtype;
-
 struct hinic_xstats_name_off {
 	char name[RTE_ETH_XSTATS_NAME_SIZE];
 	u32  offset;
@@ -3250,10 +3247,4 @@ static struct rte_pci_driver rte_hinic_pmd = {
 
 RTE_PMD_REGISTER_PCI(net_hinic, rte_hinic_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_hinic, pci_id_hinic_map);
-
-RTE_INIT(hinic_init_log)
-{
-	hinic_logtype = rte_log_register("pmd.net.hinic");
-	if (hinic_logtype >= 0)
-		rte_log_set_level(hinic_logtype, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(hinic_logtype, pmd.net.hinic, INFO);
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 62d87582d..309d0483e 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -60,9 +60,6 @@
 #define HNS3_RESET_WAIT_MS	100
 #define HNS3_RESET_WAIT_CNT	200
 
-int hns3_logtype_init;
-int hns3_logtype_driver;
-
 enum hns3_evt_cause {
 	HNS3_VECTOR0_EVENT_RST,
 	HNS3_VECTOR0_EVENT_MBX,
@@ -5525,13 +5522,5 @@ static struct rte_pci_driver rte_hns3_pmd = {
 RTE_PMD_REGISTER_PCI(net_hns3, rte_hns3_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_hns3, pci_id_hns3_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_hns3, "* igb_uio | vfio-pci");
-
-RTE_INIT(hns3_init_log)
-{
-	hns3_logtype_init = rte_log_register("pmd.net.hns3.init");
-	if (hns3_logtype_init >= 0)
-		rte_log_set_level(hns3_logtype_init, RTE_LOG_NOTICE);
-	hns3_logtype_driver = rte_log_register("pmd.net.hns3.driver");
-	if (hns3_logtype_driver >= 0)
-		rte_log_set_level(hns3_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(hns3_logtype_init, pmd.net.hns3.init, NOTICE);
+RTE_LOG_REGISTER(hns3_logtype_driver, pmd.net.hns3.driver, NOTICE);
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 970a31cb2..472ce2a9e 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -398,18 +398,6 @@ static void i40e_tunnel_filter_restore(struct i40e_pf *pf);
 static void i40e_filter_restore(struct i40e_pf *pf);
 static void i40e_notify_all_vfs_link_status(struct rte_eth_dev *dev);
 
-int i40e_logtype_init;
-int i40e_logtype_driver;
-#ifdef RTE_LIBRTE_I40E_DEBUG_RX
-int i40e_logtype_rx;
-#endif
-#ifdef RTE_LIBRTE_I40E_DEBUG_TX
-int i40e_logtype_tx;
-#endif
-#ifdef RTE_LIBRTE_I40E_DEBUG_TX_FREE
-int i40e_logtype_tx_free;
-#endif
-
 static const char *const valid_keys[] = {
 	ETH_I40E_FLOATING_VEB_ARG,
 	ETH_I40E_FLOATING_VEB_LIST_ARG,
@@ -13411,33 +13399,17 @@ i40e_config_rss_filter(struct i40e_pf *pf,
 	return 0;
 }
 
-RTE_INIT(i40e_init_log)
-{
-	i40e_logtype_init = rte_log_register("pmd.net.i40e.init");
-	if (i40e_logtype_init >= 0)
-		rte_log_set_level(i40e_logtype_init, RTE_LOG_NOTICE);
-	i40e_logtype_driver = rte_log_register("pmd.net.i40e.driver");
-	if (i40e_logtype_driver >= 0)
-		rte_log_set_level(i40e_logtype_driver, RTE_LOG_NOTICE);
-
+RTE_LOG_REGISTER(i40e_logtype_init, pmd.net.i40e.init, NOTICE);
+RTE_LOG_REGISTER(i40e_logtype_driver, pmd.net.i40e.driver, NOTICE);
 #ifdef RTE_LIBRTE_I40E_DEBUG_RX
-	i40e_logtype_rx = rte_log_register("pmd.net.i40e.rx");
-	if (i40e_logtype_rx >= 0)
-		rte_log_set_level(i40e_logtype_rx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(i40e_logtype_rx, pmd.net.i40e.rx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_I40E_DEBUG_TX
-	i40e_logtype_tx = rte_log_register("pmd.net.i40e.tx");
-	if (i40e_logtype_tx >= 0)
-		rte_log_set_level(i40e_logtype_tx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(i40e_logtype_tx, pmd.net.i40e.tx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_I40E_DEBUG_TX_FREE
-	i40e_logtype_tx_free = rte_log_register("pmd.net.i40e.tx_free");
-	if (i40e_logtype_tx_free >= 0)
-		rte_log_set_level(i40e_logtype_tx_free, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(i40e_logtype_tx_free, pmd.net.i40e.tx_free, DEBUG);
 #endif
-}
 
 RTE_PMD_REGISTER_PARAM_STRING(net_i40e,
 			      ETH_I40E_FLOATING_VEB_ARG "=1"
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 2b1066b0a..d69e5284e 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -74,20 +74,6 @@ static int iavf_dev_filter_ctrl(struct rte_eth_dev *dev,
 		     enum rte_filter_op filter_op,
 		     void *arg);
 
-
-int iavf_logtype_init;
-int iavf_logtype_driver;
-
-#ifdef RTE_LIBRTE_IAVF_DEBUG_RX
-int iavf_logtype_rx;
-#endif
-#ifdef RTE_LIBRTE_IAVF_DEBUG_TX
-int iavf_logtype_tx;
-#endif
-#ifdef RTE_LIBRTE_IAVF_DEBUG_TX_FREE
-int iavf_logtype_tx_free;
-#endif
-
 static const struct rte_pci_id pci_id_iavf_map[] = {
 	{ RTE_PCI_DEVICE(IAVF_INTEL_VENDOR_ID, IAVF_DEV_ID_ADAPTIVE_VF) },
 	{ .vendor_id = 0, /* sentinel */ },
@@ -1556,30 +1542,14 @@ RTE_PMD_REGISTER_PCI(net_iavf, rte_iavf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_iavf, pci_id_iavf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_iavf, "* igb_uio | vfio-pci");
 RTE_PMD_REGISTER_PARAM_STRING(net_iavf, "cap=dcf");
-RTE_INIT(iavf_init_log)
-{
-	iavf_logtype_init = rte_log_register("pmd.net.iavf.init");
-	if (iavf_logtype_init >= 0)
-		rte_log_set_level(iavf_logtype_init, RTE_LOG_NOTICE);
-	iavf_logtype_driver = rte_log_register("pmd.net.iavf.driver");
-	if (iavf_logtype_driver >= 0)
-		rte_log_set_level(iavf_logtype_driver, RTE_LOG_NOTICE);
-
+RTE_LOG_REGISTER(iavf_logtype_init, pmd.net.iavf.init, NOTICE);
+RTE_LOG_REGISTER(iavf_logtype_driver, pmd.net.iavf.driver, NOTICE);
 #ifdef RTE_LIBRTE_IAVF_DEBUG_RX
-	iavf_logtype_rx = rte_log_register("pmd.net.iavf.rx");
-	if (iavf_logtype_rx >= 0)
-		rte_log_set_level(iavf_logtype_rx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(iavf_logtype_rx, pmd.net.iavf.rx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_IAVF_DEBUG_TX
-	iavf_logtype_tx = rte_log_register("pmd.net.iavf.tx");
-	if (iavf_logtype_tx >= 0)
-		rte_log_set_level(iavf_logtype_tx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(iavf_logtype_tx, pmd.net.iavf.tx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_IAVF_DEBUG_TX_FREE
-	iavf_logtype_tx_free = rte_log_register("pmd.net.iavf.tx_free");
-	if (iavf_logtype_tx_free >= 0)
-		rte_log_set_level(iavf_logtype_tx_free, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(iavf_logtype_tx_free, pmd.net.iavf.tx_free, DEBUG);
 #endif
-}
diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 5a89a1955..3386960df 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -71,18 +71,6 @@ static struct proto_xtr_ol_flag ice_proto_xtr_ol_flag_params[] = {
 #define ICE_COMMS_PKG_NAME			"ICE COMMS Package"
 #define ICE_MAX_RES_DESC_NUM        1024
 
-int ice_logtype_init;
-int ice_logtype_driver;
-#ifdef RTE_LIBRTE_ICE_DEBUG_RX
-int ice_logtype_rx;
-#endif
-#ifdef RTE_LIBRTE_ICE_DEBUG_TX
-int ice_logtype_tx;
-#endif
-#ifdef RTE_LIBRTE_ICE_DEBUG_TX_FREE
-int ice_logtype_tx_free;
-#endif
-
 static int ice_dev_configure(struct rte_eth_dev *dev);
 static int ice_dev_start(struct rte_eth_dev *dev);
 static void ice_dev_stop(struct rte_eth_dev *dev);
@@ -4576,30 +4564,14 @@ RTE_PMD_REGISTER_PARAM_STRING(net_ice,
 			      ICE_PIPELINE_MODE_SUPPORT_ARG "=<0|1>"
 			      ICE_FLOW_MARK_SUPPORT_ARG "=<0|1>");
 
-RTE_INIT(ice_init_log)
-{
-	ice_logtype_init = rte_log_register("pmd.net.ice.init");
-	if (ice_logtype_init >= 0)
-		rte_log_set_level(ice_logtype_init, RTE_LOG_NOTICE);
-	ice_logtype_driver = rte_log_register("pmd.net.ice.driver");
-	if (ice_logtype_driver >= 0)
-		rte_log_set_level(ice_logtype_driver, RTE_LOG_NOTICE);
-
+RTE_LOG_REGISTER(ice_logtype_init, pmd.net.ice.init, NOTICE);
+RTE_LOG_REGISTER(ice_logtype_driver, pmd.net.ice.driver, NOTICE);
 #ifdef RTE_LIBRTE_ICE_DEBUG_RX
-	ice_logtype_rx = rte_log_register("pmd.net.ice.rx");
-	if (ice_logtype_rx >= 0)
-		rte_log_set_level(ice_logtype_rx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(ice_logtype_rx, pmd.net.ice.rx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_ICE_DEBUG_TX
-	ice_logtype_tx = rte_log_register("pmd.net.ice.tx");
-	if (ice_logtype_tx >= 0)
-		rte_log_set_level(ice_logtype_tx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(ice_logtype_tx, pmd.net.ice.tx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_ICE_DEBUG_TX_FREE
-	ice_logtype_tx_free = rte_log_register("pmd.net.ice.tx_free");
-	if (ice_logtype_tx_free >= 0)
-		rte_log_set_level(ice_logtype_tx_free, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(ice_logtype_tx_free, pmd.net.ice.tx_free, DEBUG);
 #endif
-}
diff --git a/drivers/net/igc/igc_logs.c b/drivers/net/igc/igc_logs.c
index eff7640b1..2d458d7fb 100644
--- a/drivers/net/igc/igc_logs.c
+++ b/drivers/net/igc/igc_logs.c
@@ -6,17 +6,5 @@
 
 #include "igc_logs.h"
 
-/* declared as extern in igc_logs.h */
-int igc_logtype_init;
-int igc_logtype_driver;
-
-RTE_INIT(igc_init_log)
-{
-	igc_logtype_init = rte_log_register("pmd.net.igc.init");
-	if (igc_logtype_init >= 0)
-		rte_log_set_level(igc_logtype_init, RTE_LOG_INFO);
-
-	igc_logtype_driver = rte_log_register("pmd.net.igc.driver");
-	if (igc_logtype_driver >= 0)
-		rte_log_set_level(igc_logtype_driver, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(igc_logtype_init, pmd.net.igc.init, INFO);
+RTE_LOG_REGISTER(igc_logtype_driver, pmd.net.igc.driver, INFO);
diff --git a/drivers/net/ionic/ionic_ethdev.c b/drivers/net/ionic/ionic_ethdev.c
index 363f0cf00..800f6e5d6 100644
--- a/drivers/net/ionic/ionic_ethdev.c
+++ b/drivers/net/ionic/ionic_ethdev.c
@@ -59,8 +59,6 @@ static int  ionic_dev_xstats_get_names_by_id(struct rte_eth_dev *dev,
 static int  ionic_dev_fw_version_get(struct rte_eth_dev *eth_dev,
 	char *fw_version, size_t fw_size);
 
-int ionic_logtype;
-
 static const struct rte_pci_id pci_id_ionic_map[] = {
 	{ RTE_PCI_DEVICE(IONIC_PENSANDO_VENDOR_ID, IONIC_DEV_ID_ETH_PF) },
 	{ RTE_PCI_DEVICE(IONIC_PENSANDO_VENDOR_ID, IONIC_DEV_ID_ETH_VF) },
@@ -1318,10 +1316,4 @@ static struct rte_pci_driver rte_ionic_pmd = {
 RTE_PMD_REGISTER_PCI(net_ionic, rte_ionic_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_ionic, pci_id_ionic_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_ionic, "* igb_uio | uio_pci_generic | vfio-pci");
-
-RTE_INIT(ionic_init_log)
-{
-	ionic_logtype = rte_log_register("pmd.net.ionic");
-	if (ionic_logtype >= 0)
-		rte_log_set_level(ionic_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(ionic_logtype, pmd.net.ionic, NOTICE);
diff --git a/drivers/net/ipn3ke/ipn3ke_ethdev.c b/drivers/net/ipn3ke/ipn3ke_ethdev.c
index 5b5510f08..027be29bd 100644
--- a/drivers/net/ipn3ke/ipn3ke_ethdev.c
+++ b/drivers/net/ipn3ke/ipn3ke_ethdev.c
@@ -26,8 +26,6 @@
 #include "ipn3ke_logs.h"
 #include "ipn3ke_ethdev.h"
 
-int ipn3ke_afu_logtype;
-
 static const struct rte_afu_uuid afu_uuid_ipn3ke_map[] = {
 	{ MAP_UUID_10G_LOW,  MAP_UUID_10G_HIGH },
 	{ IPN3KE_UUID_10G_LOW, IPN3KE_UUID_10G_HIGH },
@@ -587,10 +585,4 @@ static struct rte_afu_driver afu_ipn3ke_driver = {
 };
 
 RTE_PMD_REGISTER_AFU(net_ipn3ke_afu, afu_ipn3ke_driver);
-
-RTE_INIT(ipn3ke_afu_init_log)
-{
-	ipn3ke_afu_logtype = rte_log_register("pmd.afu.ipn3ke");
-	if (ipn3ke_afu_logtype >= 0)
-		rte_log_set_level(ipn3ke_afu_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(ipn3ke_afu_logtype, pmd.afu.ipn3ke, NOTICE);
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index f8a84c565..248f21d14 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -419,19 +419,6 @@ static int ixgbe_wait_for_link_up(struct ixgbe_hw *hw);
 		(r) = (h)->bitmap[idx] >> bit & 1;\
 	} while (0)
 
-int ixgbe_logtype_init;
-int ixgbe_logtype_driver;
-
-#ifdef RTE_LIBRTE_IXGBE_DEBUG_RX
-int ixgbe_logtype_rx;
-#endif
-#ifdef RTE_LIBRTE_IXGBE_DEBUG_TX
-int ixgbe_logtype_tx;
-#endif
-#ifdef RTE_LIBRTE_IXGBE_DEBUG_TX_FREE
-int ixgbe_logtype_tx_free;
-#endif
-
 /*
  * The set of PCI devices this driver supports
  */
@@ -9117,29 +9104,15 @@ RTE_PMD_REGISTER_KMOD_DEP(net_ixgbe_vf, "* igb_uio | vfio-pci");
 RTE_PMD_REGISTER_PARAM_STRING(net_ixgbe_vf,
 			      IXGBEVF_DEVARG_PFLINK_FULLCHK "=<0|1>");
 
-RTE_INIT(ixgbe_init_log)
-{
-	ixgbe_logtype_init = rte_log_register("pmd.net.ixgbe.init");
-	if (ixgbe_logtype_init >= 0)
-		rte_log_set_level(ixgbe_logtype_init, RTE_LOG_NOTICE);
-	ixgbe_logtype_driver = rte_log_register("pmd.net.ixgbe.driver");
-	if (ixgbe_logtype_driver >= 0)
-		rte_log_set_level(ixgbe_logtype_driver, RTE_LOG_NOTICE);
+RTE_LOG_REGISTER(ixgbe_logtype_init, pmd.net.ixgbe.init, NOTICE);
+RTE_LOG_REGISTER(ixgbe_logtype_driver, pmd.net.ixgbe.driver, NOTICE);
+
 #ifdef RTE_LIBRTE_IXGBE_DEBUG_RX
-	ixgbe_logtype_rx = rte_log_register("pmd.net.ixgbe.rx");
-	if (ixgbe_logtype_rx >= 0)
-		rte_log_set_level(ixgbe_logtype_rx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(ixgbe_logtype_rx, pmd.net.ixgbe.rx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_IXGBE_DEBUG_TX
-	ixgbe_logtype_tx = rte_log_register("pmd.net.ixgbe.tx");
-	if (ixgbe_logtype_tx >= 0)
-		rte_log_set_level(ixgbe_logtype_tx, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(ixgbe_logtype_tx, pmd.net.ixgbe.tx, DEBUG);
 #endif
-
 #ifdef RTE_LIBRTE_IXGBE_DEBUG_TX_FREE
-	ixgbe_logtype_tx_free = rte_log_register("pmd.net.ixgbe.tx_free");
-	if (ixgbe_logtype_tx_free >= 0)
-		rte_log_set_level(ixgbe_logtype_tx_free, RTE_LOG_DEBUG);
+RTE_LOG_REGISTER(ixgbe_logtype_tx_free, pmd.net.ixgbe.tx_free, DEBUG);
 #endif
-}
diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c
index d88cb1778..cde98f0bb 100644
--- a/drivers/net/kni/rte_eth_kni.c
+++ b/drivers/net/kni/rte_eth_kni.c
@@ -67,7 +67,7 @@ static const struct rte_eth_link pmd_link = {
 };
 static int is_kni_initialized;
 
-static int eth_kni_logtype;
+RTE_LOG_REGISTER(eth_kni_logtype, pmd.net.kni, NOTICE);
 
 #define PMD_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, eth_kni_logtype, \
@@ -508,10 +508,3 @@ static struct rte_vdev_driver eth_kni_drv = {
 
 RTE_PMD_REGISTER_VDEV(net_kni, eth_kni_drv);
 RTE_PMD_REGISTER_PARAM_STRING(net_kni, ETH_KNI_NO_REQUEST_THREAD_ARG "=<int>");
-
-RTE_INIT(eth_kni_init_log)
-{
-	eth_kni_logtype = rte_log_register("pmd.net.kni");
-	if (eth_kni_logtype >= 0)
-		rte_log_set_level(eth_kni_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c
index ad4a51ecd..2258838c4 100644
--- a/drivers/net/liquidio/lio_ethdev.c
+++ b/drivers/net/liquidio/lio_ethdev.c
@@ -15,9 +15,6 @@
 #include "lio_ethdev.h"
 #include "lio_rxtx.h"
 
-int lio_logtype_init;
-int lio_logtype_driver;
-
 /* Default RSS key in use */
 static uint8_t lio_rss_key[40] = {
 	0x6D, 0x5A, 0x56, 0xDA, 0x25, 0x5B, 0x0E, 0xC2,
@@ -2161,13 +2158,5 @@ static struct rte_pci_driver rte_liovf_pmd = {
 RTE_PMD_REGISTER_PCI(net_liovf, rte_liovf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_liovf, pci_id_liovf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_liovf, "* igb_uio | vfio-pci");
-
-RTE_INIT(lio_init_log)
-{
-	lio_logtype_init = rte_log_register("pmd.net.liquidio.init");
-	if (lio_logtype_init >= 0)
-		rte_log_set_level(lio_logtype_init, RTE_LOG_NOTICE);
-	lio_logtype_driver = rte_log_register("pmd.net.liquidio.driver");
-	if (lio_logtype_driver >= 0)
-		rte_log_set_level(lio_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(lio_logtype_init, pmd.net.liquidio.init, NOTICE);
+RTE_LOG_REGISTER(lio_logtype_driver, pmd.net.liquidio.driver, NOTICE);
diff --git a/drivers/net/memif/rte_eth_memif.c b/drivers/net/memif/rte_eth_memif.c
index b6da9a8b4..c1c7e9f8d 100644
--- a/drivers/net/memif/rte_eth_memif.c
+++ b/drivers/net/memif/rte_eth_memif.c
@@ -1806,11 +1806,4 @@ RTE_PMD_REGISTER_PARAM_STRING(net_memif,
 			      ETH_MEMIF_ZC_ARG "=yes|no"
 			      ETH_MEMIF_SECRET_ARG "=<string>");
 
-int memif_logtype;
-
-RTE_INIT(memif_init_log)
-{
-	memif_logtype = rte_log_register("pmd.net.memif");
-	if (memif_logtype >= 0)
-		rte_log_set_level(memif_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(memif_logtype, pmd.net.memif, NOTICE);
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index 5d7202720..927222c81 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -64,9 +64,6 @@ static rte_spinlock_t mlx4_shared_data_lock = RTE_SPINLOCK_INITIALIZER;
 /* Process local data for secondary processes. */
 static struct mlx4_local_data mlx4_local_data;
 
-/** Driver-specific log messages type. */
-int mlx4_logtype;
-
 /** Configuration structure for device arguments. */
 struct mlx4_conf {
 	struct {
@@ -1281,16 +1278,14 @@ mlx4_glue_init(void)
 
 #endif
 
+/* Initialize driver log type. */
+RTE_LOG_REGISTER(mlx4_logtype, pmd.net.mlx4, NOTICE)
+
 /**
  * Driver initialization routine.
  */
 RTE_INIT(rte_mlx4_pmd_init)
 {
-	/* Initialize driver log type. */
-	mlx4_logtype = rte_log_register("pmd.net.mlx4");
-	if (mlx4_logtype >= 0)
-		rte_log_set_level(mlx4_logtype, RTE_LOG_NOTICE);
-
 	/*
 	 * MLX4_DEVICE_FATAL_CLEANUP tells ibv_destroy functions we
 	 * want to get success errno value in case of calling them
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 5c86f6fb9..16257a63a 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -173,8 +173,6 @@ static rte_spinlock_t mlx5_shared_data_lock = RTE_SPINLOCK_INITIALIZER;
 
 /* Process local data for secondary processes. */
 static struct mlx5_local_data mlx5_local_data;
-/** Driver-specific log messages type. */
-int mlx5_logtype;
 
 static LIST_HEAD(, mlx5_dev_ctx_shared) mlx5_dev_ctx_list =
 						LIST_HEAD_INITIALIZER();
@@ -1999,16 +1997,14 @@ struct rte_pci_driver mlx5_driver = {
 	.drv_flags = PCI_DRV_FLAGS,
 };
 
+/* Initialize driver log type. */
+RTE_LOG_REGISTER(mlx5_logtype, pmd.net.mlx5, NOTICE)
+
 /**
  * Driver initialization routine.
  */
 RTE_INIT(rte_mlx5_pmd_init)
 {
-	/* Initialize driver log type. */
-	mlx5_logtype = rte_log_register("pmd.net.mlx5");
-	if (mlx5_logtype >= 0)
-		rte_log_set_level(mlx5_logtype, RTE_LOG_NOTICE);
-
 	/* Build the static tables for Verbs conversion. */
 	mlx5_set_ptype_table();
 	mlx5_set_cksum_table();
diff --git a/drivers/net/mvneta/mvneta_ethdev.c b/drivers/net/mvneta/mvneta_ethdev.c
index 4aea87648..673a8e2b3 100644
--- a/drivers/net/mvneta/mvneta_ethdev.c
+++ b/drivers/net/mvneta/mvneta_ethdev.c
@@ -34,8 +34,6 @@
 /** Maximum length of a match string */
 #define MVNETA_MATCH_LEN 16
 
-int mvneta_logtype;
-
 static const char * const valid_args[] = {
 	MVNETA_IFACE_NAME_ARG,
 	NULL
@@ -982,10 +980,4 @@ static struct rte_vdev_driver pmd_mvneta_drv = {
 
 RTE_PMD_REGISTER_VDEV(net_mvneta, pmd_mvneta_drv);
 RTE_PMD_REGISTER_PARAM_STRING(net_mvneta, "iface=<ifc>");
-
-RTE_INIT(mvneta_init_log)
-{
-	mvneta_logtype = rte_log_register("pmd.net.mvneta");
-	if (mvneta_logtype >= 0)
-		rte_log_set_level(mvneta_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(mvneta_logtype, pmd.net.mvneta, NOTICE);
diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c
index b98b1fd66..75589f18e 100644
--- a/drivers/net/mvpp2/mrvl_ethdev.c
+++ b/drivers/net/mvpp2/mrvl_ethdev.c
@@ -84,8 +84,6 @@ static struct pp2_bpool *mrvl_port_to_bpool_lookup[RTE_MAX_ETHPORTS];
 static int mrvl_port_bpool_size[PP2_NUM_PKT_PROC][PP2_BPOOL_NUM_POOLS][RTE_MAX_LCORE];
 static uint64_t cookie_addr_high = MRVL_COOKIE_ADDR_INVALID;
 
-int mrvl_logtype;
-
 struct mrvl_ifnames {
 	const char *names[PP2_NUM_ETH_PPIO * PP2_NUM_PKT_PROC];
 	int idx;
@@ -3040,10 +3038,4 @@ static struct rte_vdev_driver pmd_mrvl_drv = {
 
 RTE_PMD_REGISTER_VDEV(net_mvpp2, pmd_mrvl_drv);
 RTE_PMD_REGISTER_ALIAS(net_mvpp2, eth_mvpp2);
-
-RTE_INIT(mrvl_init_log)
-{
-	mrvl_logtype = rte_log_register("pmd.net.mvpp2");
-	if (mrvl_logtype >= 0)
-		rte_log_set_level(mrvl_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(mrvl_logtype, pmd.net.mvpp2, NOTICE);
diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c
index ac182a548..fd91c0e49 100644
--- a/drivers/net/netvsc/hn_ethdev.c
+++ b/drivers/net/netvsc/hn_ethdev.c
@@ -45,9 +45,6 @@
 			    DEV_RX_OFFLOAD_VLAN_STRIP | \
 			    DEV_RX_OFFLOAD_RSS_HASH)
 
-int hn_logtype_init;
-int hn_logtype_driver;
-
 struct hn_xstats_name_off {
 	char name[RTE_ETH_XSTATS_NAME_SIZE];
 	unsigned int offset;
@@ -1121,13 +1118,5 @@ static struct rte_vmbus_driver rte_netvsc_pmd = {
 
 RTE_PMD_REGISTER_VMBUS(net_netvsc, rte_netvsc_pmd);
 RTE_PMD_REGISTER_KMOD_DEP(net_netvsc, "* uio_hv_generic");
-
-RTE_INIT(hn_init_log)
-{
-	hn_logtype_init = rte_log_register("pmd.net.netvsc.init");
-	if (hn_logtype_init >= 0)
-		rte_log_set_level(hn_logtype_init, RTE_LOG_NOTICE);
-	hn_logtype_driver = rte_log_register("pmd.net.netvsc.driver");
-	if (hn_logtype_driver >= 0)
-		rte_log_set_level(hn_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(hn_logtype_init, pmd.net.netvsc.init, NOTICE);
+RTE_LOG_REGISTER(hn_logtype_driver, pmd.net.netvsc.driver, NOTICE);
diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
index 2460ee199..88e3f01d6 100644
--- a/drivers/net/nfp/nfp_net.c
+++ b/drivers/net/nfp/nfp_net.c
@@ -3683,9 +3683,6 @@ static int nfp_pf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	return ret;
 }
 
-int nfp_logtype_init;
-int nfp_logtype_driver;
-
 static const struct rte_pci_id pci_id_nfp_pf_net_map[] = {
 	{
 		RTE_PCI_DEVICE(PCI_VENDOR_ID_NETRONOME,
@@ -3769,16 +3766,8 @@ RTE_PMD_REGISTER_PCI_TABLE(net_nfp_pf, pci_id_nfp_pf_net_map);
 RTE_PMD_REGISTER_PCI_TABLE(net_nfp_vf, pci_id_nfp_vf_net_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_nfp_pf, "* igb_uio | uio_pci_generic | vfio");
 RTE_PMD_REGISTER_KMOD_DEP(net_nfp_vf, "* igb_uio | uio_pci_generic | vfio");
-
-RTE_INIT(nfp_init_log)
-{
-	nfp_logtype_init = rte_log_register("pmd.net.nfp.init");
-	if (nfp_logtype_init >= 0)
-		rte_log_set_level(nfp_logtype_init, RTE_LOG_NOTICE);
-	nfp_logtype_driver = rte_log_register("pmd.net.nfp.driver");
-	if (nfp_logtype_driver >= 0)
-		rte_log_set_level(nfp_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(nfp_logtype_init, pmd.net.nfp.init, NOTICE);
+RTE_LOG_REGISTER(nfp_logtype_driver, pmd.net.nfp.driver, NOTICE);
 /*
  * Local variables:
  * c-file-style: "Linux"
diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index 11258ccea..8c779be7f 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c
@@ -73,7 +73,7 @@ static struct rte_eth_link pmd_link = {
 	.link_autoneg = ETH_LINK_FIXED,
 };
 
-static int eth_null_logtype;
+RTE_LOG_REGISTER(eth_null_logtype, pmd.net.null, NOTICE);
 
 #define PMD_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, eth_null_logtype, \
@@ -730,9 +730,3 @@ RTE_PMD_REGISTER_PARAM_STRING(net_null,
 	"copy=<int> "
 	ETH_NULL_PACKET_NO_RX_ARG "=0|1");
 
-RTE_INIT(eth_null_init_log)
-{
-	eth_null_logtype = rte_log_register("pmd.net.null");
-	if (eth_null_logtype >= 0)
-		rte_log_set_level(eth_null_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c
index d5371ae07..76c69294d 100644
--- a/drivers/net/octeontx/octeontx_ethdev.c
+++ b/drivers/net/octeontx/octeontx_ethdev.c
@@ -47,24 +47,9 @@ enum octeontx_link_speed {
 	OCTEONTX_LINK_SPEED_RESERVE2
 };
 
-int otx_net_logtype_mbox;
-int otx_net_logtype_init;
-int otx_net_logtype_driver;
-
-RTE_INIT(otx_net_init_log)
-{
-	otx_net_logtype_mbox = rte_log_register("pmd.net.octeontx.mbox");
-	if (otx_net_logtype_mbox >= 0)
-		rte_log_set_level(otx_net_logtype_mbox, RTE_LOG_NOTICE);
-
-	otx_net_logtype_init = rte_log_register("pmd.net.octeontx.init");
-	if (otx_net_logtype_init >= 0)
-		rte_log_set_level(otx_net_logtype_init, RTE_LOG_NOTICE);
-
-	otx_net_logtype_driver = rte_log_register("pmd.net.octeontx.driver");
-	if (otx_net_logtype_driver >= 0)
-		rte_log_set_level(otx_net_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(otx_net_logtype_mbox, pmd.net.octeontx.mbox, NOTICE);
+RTE_LOG_REGISTER(otx_net_logtype_init, pmd.net.octeontx.init, NOTICE);
+RTE_LOG_REGISTER(otx_net_logtype_driver, pmd.net.octeontx.driver, NOTICE);
 
 /* Parse integer from integer argument */
 static int
diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index 13a3d0ac7..60e393c92 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -135,7 +135,7 @@ static struct rte_eth_link pmd_link = {
 		.link_autoneg = ETH_LINK_FIXED,
 };
 
-static int eth_pcap_logtype;
+RTE_LOG_REGISTER(eth_pcap_logtype, pmd.net.pcap, NOTICE);
 
 #define PMD_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, eth_pcap_logtype, \
@@ -1589,9 +1589,3 @@ RTE_PMD_REGISTER_PARAM_STRING(net_pcap,
 	ETH_PCAP_PHY_MAC_ARG "=<int>"
 	ETH_PCAP_INFINITE_RX_ARG "=<0|1>");
 
-RTE_INIT(eth_pcap_init_log)
-{
-	eth_pcap_logtype = rte_log_register("pmd.net.pcap");
-	if (eth_pcap_logtype >= 0)
-		rte_log_set_level(eth_pcap_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/pfe/pfe_ethdev.c b/drivers/net/pfe/pfe_ethdev.c
index b1de866d3..368acfa55 100644
--- a/drivers/net/pfe/pfe_ethdev.c
+++ b/drivers/net/pfe/pfe_ethdev.c
@@ -40,8 +40,6 @@ unsigned int pfe_svr = SVR_LS1012A_REV1;
 static void *cbus_emac_base[3];
 static void *cbus_gpi_base[3];
 
-int pfe_logtype_pmd;
-
 /* pfe_gemac_init
  */
 static int
@@ -1181,10 +1179,4 @@ struct rte_vdev_driver pmd_pfe_drv = {
 
 RTE_PMD_REGISTER_VDEV(PFE_NAME_PMD, pmd_pfe_drv);
 RTE_PMD_REGISTER_PARAM_STRING(PFE_NAME_PMD, PFE_VDEV_GEM_ID_ARG "=<int> ");
-
-RTE_INIT(pfe_pmd_init_log)
-{
-	pfe_logtype_pmd = rte_log_register("pmd.net.pfe");
-	if (pfe_logtype_pmd >= 0)
-		rte_log_set_level(pfe_logtype_pmd, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(pfe_logtype_pmd, pmd.net.pfe, NOTICE);
diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c
index c4f8f1258..6107d583e 100644
--- a/drivers/net/qede/qede_ethdev.c
+++ b/drivers/net/qede/qede_ethdev.c
@@ -10,10 +10,6 @@
 #include <rte_version.h>
 #include <rte_kvargs.h>
 
-/* Globals */
-int qede_logtype_init;
-int qede_logtype_driver;
-
 static const struct qed_eth_ops *qed_ops;
 static int qede_eth_dev_uninit(struct rte_eth_dev *eth_dev);
 static int qede_eth_dev_init(struct rte_eth_dev *eth_dev);
@@ -2870,13 +2866,5 @@ RTE_PMD_REGISTER_KMOD_DEP(net_qede, "* igb_uio | uio_pci_generic | vfio-pci");
 RTE_PMD_REGISTER_PCI(net_qede_vf, rte_qedevf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_qede_vf, pci_id_qedevf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_qede_vf, "* igb_uio | vfio-pci");
-
-RTE_INIT(qede_init_log)
-{
-	qede_logtype_init = rte_log_register("pmd.net.qede.init");
-	if (qede_logtype_init >= 0)
-		rte_log_set_level(qede_logtype_init, RTE_LOG_NOTICE);
-	qede_logtype_driver = rte_log_register("pmd.net.qede.driver");
-	if (qede_logtype_driver >= 0)
-		rte_log_set_level(qede_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(qede_logtype_init, pmd.net.qede.init, NOTICE);
+RTE_LOG_REGISTER(qede_logtype_driver, pmd.net.qede.driver, NOTICE);
diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index f0fafa0c0..078df605a 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -61,7 +61,7 @@ static struct rte_eth_link pmd_link = {
 	.link_autoneg = ETH_LINK_FIXED,
 };
 
-static int eth_ring_logtype;
+RTE_LOG_REGISTER(eth_ring_logtype, pmd.net.ring, NOTICE);
 
 #define PMD_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, eth_ring_logtype, \
@@ -703,9 +703,3 @@ RTE_PMD_REGISTER_ALIAS(net_ring, eth_ring);
 RTE_PMD_REGISTER_PARAM_STRING(net_ring,
 	ETH_RING_NUMA_NODE_ACTION_ARG "=name:node:action(ATTACH|CREATE)");
 
-RTE_INIT(eth_ring_init_log)
-{
-	eth_ring_logtype = rte_log_register("pmd.net.ring");
-	if (eth_ring_logtype >= 0)
-		rte_log_set_level(eth_ring_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/softnic/rte_eth_softnic.c b/drivers/net/softnic/rte_eth_softnic.c
index 11723778f..866d17a93 100644
--- a/drivers/net/softnic/rte_eth_softnic.c
+++ b/drivers/net/softnic/rte_eth_softnic.c
@@ -80,7 +80,7 @@ static const struct softnic_conn_params conn_params_default = {
 	.msg_handle_arg = NULL,
 };
 
-static int pmd_softnic_logtype;
+RTE_LOG_REGISTER(pmd_softnic_logtype, pmd.net.softnic, NOTICE);
 
 #define PMD_LOG(level, fmt, args...) \
 	rte_log(RTE_LOG_ ## level, pmd_softnic_logtype, \
@@ -690,14 +690,6 @@ RTE_PMD_REGISTER_PARAM_STRING(net_softnic,
 	PMD_PARAM_TM_QSIZE12 "=<uint32>"
 );
 
-
-RTE_INIT(pmd_softnic_init_log)
-{
-	pmd_softnic_logtype = rte_log_register("pmd.net.softnic");
-	if (pmd_softnic_logtype >= 0)
-		rte_log_set_level(pmd_softnic_logtype, RTE_LOG_NOTICE);
-}
-
 int
 rte_pmd_softnic_manage(uint16_t port_id)
 {
diff --git a/drivers/net/szedata2/rte_eth_szedata2.c b/drivers/net/szedata2/rte_eth_szedata2.c
index 821bb346c..30c888cd9 100644
--- a/drivers/net/szedata2/rte_eth_szedata2.c
+++ b/drivers/net/szedata2/rte_eth_szedata2.c
@@ -102,9 +102,6 @@ struct szedata2_tx_queue {
 	volatile uint64_t err_pkts;
 };
 
-int szedata2_logtype_init;
-int szedata2_logtype_driver;
-
 static struct rte_ether_addr eth_addr = {
 	.addr_bytes = { 0x00, 0x11, 0x17, 0x00, 0x00, 0x00 }
 };
@@ -1941,13 +1938,5 @@ RTE_PMD_REGISTER_PCI(RTE_SZEDATA2_DRIVER_NAME, szedata2_eth_driver);
 RTE_PMD_REGISTER_PCI_TABLE(RTE_SZEDATA2_DRIVER_NAME, rte_szedata2_pci_id_table);
 RTE_PMD_REGISTER_KMOD_DEP(RTE_SZEDATA2_DRIVER_NAME,
 	"* combo6core & combov3 & szedata2 & ( szedata2_cv3 | szedata2_cv3_fdt )");
-
-RTE_INIT(szedata2_init_log)
-{
-	szedata2_logtype_init = rte_log_register("pmd.net.szedata2.init");
-	if (szedata2_logtype_init >= 0)
-		rte_log_set_level(szedata2_logtype_init, RTE_LOG_NOTICE);
-	szedata2_logtype_driver = rte_log_register("pmd.net.szedata2.driver");
-	if (szedata2_logtype_driver >= 0)
-		rte_log_set_level(szedata2_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(szedata2_logtype_init, pmd.net.szedata2.init, NOTICE);
+RTE_LOG_REGISTER(szedata2_logtype_driver, pmd.net.szedata2.driver, NOTICE);
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 7081ae23e..339f24bf8 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -2494,11 +2494,4 @@ RTE_PMD_REGISTER_PARAM_STRING(net_tap,
 			      ETH_TAP_IFACE_ARG "=<string> "
 			      ETH_TAP_MAC_ARG "=" ETH_TAP_MAC_ARG_FMT " "
 			      ETH_TAP_REMOTE_ARG "=<string>");
-int tap_logtype;
-
-RTE_INIT(tap_init_log)
-{
-	tap_logtype = rte_log_register("pmd.net.tap");
-	if (tap_logtype >= 0)
-		rte_log_set_level(tap_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(tap_logtype, pmd.net.tap, NOTICE);
diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c
index bfda0ab0e..d955a7ee2 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -44,10 +44,6 @@
 #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,
@@ -55,20 +51,9 @@ static void nicvf_vf_stop(struct rte_eth_dev *dev, struct nicvf *nic,
 static int nicvf_vlan_offload_config(struct rte_eth_dev *dev, int mask);
 static int nicvf_vlan_offload_set(struct rte_eth_dev *dev, int mask);
 
-RTE_INIT(nicvf_init_log)
-{
-	nicvf_logtype_mbox = rte_log_register("pmd.net.thunderx.mbox");
-	if (nicvf_logtype_mbox >= 0)
-		rte_log_set_level(nicvf_logtype_mbox, RTE_LOG_NOTICE);
-
-	nicvf_logtype_init = rte_log_register("pmd.net.thunderx.init");
-	if (nicvf_logtype_init >= 0)
-		rte_log_set_level(nicvf_logtype_init, RTE_LOG_NOTICE);
-
-	nicvf_logtype_driver = rte_log_register("pmd.net.thunderx.driver");
-	if (nicvf_logtype_driver >= 0)
-		rte_log_set_level(nicvf_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(nicvf_logtype_mbox, pmd.net.thunderx.mbox, NOTICE);
+RTE_LOG_REGISTER(nicvf_logtype_init, pmd.net.thunderx.init, NOTICE);
+RTE_LOG_REGISTER(nicvf_logtype_driver, pmd.net.thunderx.driver, NOTICE);
 
 static void
 nicvf_link_status_update(struct nicvf *nic,
diff --git a/drivers/net/vdev_netvsc/vdev_netvsc.c b/drivers/net/vdev_netvsc/vdev_netvsc.c
index 9ed74a1d6..1ecb0b3e6 100644
--- a/drivers/net/vdev_netvsc/vdev_netvsc.c
+++ b/drivers/net/vdev_netvsc/vdev_netvsc.c
@@ -48,6 +48,8 @@
 #define NETVSC_CLASS_ID "{f8615163-df3e-46c5-913f-f2d2f965ed0e}"
 #define NETVSC_MAX_ROUTE_LINE_SIZE 300
 
+RTE_LOG_REGISTER(vdev_netvsc_logtype, pmd.net.vdev_netvsc, NOTICE);
+
 #define DRV_LOG(level, ...) \
 	rte_log(RTE_LOG_ ## level, \
 		vdev_netvsc_logtype, \
@@ -55,9 +57,6 @@
 			RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
 		RTE_FMT_TAIL(__VA_ARGS__,)))
 
-/** Driver-specific log messages type. */
-static int vdev_netvsc_logtype;
-
 /** Context structure for a vdev_netvsc instance. */
 struct vdev_netvsc_ctx {
 	LIST_ENTRY(vdev_netvsc_ctx) entry; /**< Next entry in list. */
@@ -774,14 +773,6 @@ RTE_PMD_REGISTER_PARAM_STRING(net_vdev_netvsc,
 			      VDEV_NETVSC_ARG_FORCE "=<int> "
 			      VDEV_NETVSC_ARG_IGNORE "=<int>");
 
-/** Initialize driver log type. */
-RTE_INIT(vdev_netvsc_init_log)
-{
-	vdev_netvsc_logtype = rte_log_register("pmd.net.vdev_netvsc");
-	if (vdev_netvsc_logtype >= 0)
-		rte_log_set_level(vdev_netvsc_logtype, RTE_LOG_NOTICE);
-}
-
 /** Compare function for vdev find device operation. */
 static int
 vdev_netvsc_cmp_rte_device(const struct rte_device *dev1,
diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index 808e670f1..bfacdcb98 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -18,7 +18,7 @@
 
 #include "rte_eth_vhost.h"
 
-static int vhost_logtype;
+RTE_LOG_REGISTER(vhost_logtype, pmd.net.vhost, NOTICE);
 
 #define VHOST_LOG(level, ...) \
 	rte_log(RTE_LOG_ ## level, vhost_logtype, __VA_ARGS__)
@@ -1571,9 +1571,3 @@ RTE_PMD_REGISTER_PARAM_STRING(net_vhost,
 	"linear-buffer=<0|1> "
 	"ext-buffer=<0|1>");
 
-RTE_INIT(vhost_init_log)
-{
-	vhost_logtype = rte_log_register("pmd.net.vhost");
-	if (vhost_logtype >= 0)
-		rte_log_set_level(vhost_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 312871cb4..dc0093bdf 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -85,9 +85,6 @@ static int virtio_dev_queue_stats_mapping_set(
 	uint8_t stat_idx,
 	uint8_t is_rx);
 
-int virtio_logtype_init;
-int virtio_logtype_driver;
-
 static void virtio_notify_peers(struct rte_eth_dev *dev);
 static void virtio_ack_link_announce(struct rte_eth_dev *dev);
 
@@ -2659,13 +2656,5 @@ __rte_unused uint8_t is_rx)
 RTE_PMD_EXPORT_NAME(net_virtio, __COUNTER__);
 RTE_PMD_REGISTER_PCI_TABLE(net_virtio, pci_id_virtio_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_virtio, "* igb_uio | uio_pci_generic | vfio-pci");
-
-RTE_INIT(virtio_init_log)
-{
-	virtio_logtype_init = rte_log_register("pmd.net.virtio.init");
-	if (virtio_logtype_init >= 0)
-		rte_log_set_level(virtio_logtype_init, RTE_LOG_NOTICE);
-	virtio_logtype_driver = rte_log_register("pmd.net.virtio.driver");
-	if (virtio_logtype_driver >= 0)
-		rte_log_set_level(virtio_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(virtio_logtype_init, pmd.net.virtio.init, NOTICE);
+RTE_LOG_REGISTER(virtio_logtype_driver, pmd.net.virtio.driver, NOTICE);
diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c
index c6e11ad2d..815fba2f5 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethdev.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c
@@ -95,9 +95,6 @@ static int vmxnet3_mac_addr_set(struct rte_eth_dev *dev,
 				 struct rte_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
  */
@@ -1464,13 +1461,5 @@ 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)
-{
-	vmxnet3_logtype_init = rte_log_register("pmd.net.vmxnet3.init");
-	if (vmxnet3_logtype_init >= 0)
-		rte_log_set_level(vmxnet3_logtype_init, RTE_LOG_NOTICE);
-	vmxnet3_logtype_driver = rte_log_register("pmd.net.vmxnet3.driver");
-	if (vmxnet3_logtype_driver >= 0)
-		rte_log_set_level(vmxnet3_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(vmxnet3_logtype_init, pmd.net.vmxnet3.init, NOTICE);
+RTE_LOG_REGISTER(vmxnet3_logtype_driver, pmd.net.vmxnet3.driver, NOTICE);
-- 
2.27.0


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

* [dpdk-dev] [PATCH v5 06/13] drivers/mempool: use log register macro
  2020-07-01 12:33       ` [dpdk-dev] [PATCH v5 00/13] rte_log registration usage improvement jerinj
                           ` (4 preceding siblings ...)
  2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 05/13] drivers/net: " jerinj
@ 2020-07-01 12:33         ` jerinj
  2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 07/13] drivers/event: " jerinj
                           ` (7 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01 12:33 UTC (permalink / raw)
  To: dev, Hemant Agrawal, Sachin Saxena, Harman Kalra
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Sachin Saxena <sachin.saxena@oss.nxp.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/mempool/dpaa/dpaa_mempool.c       | 10 ++--------
 drivers/mempool/dpaa2/dpaa2_hw_mempool.c  | 10 +---------
 drivers/mempool/octeontx/octeontx_fpavf.c | 10 +---------
 3 files changed, 4 insertions(+), 26 deletions(-)

diff --git a/drivers/mempool/dpaa/dpaa_mempool.c b/drivers/mempool/dpaa/dpaa_mempool.c
index 451e2d5d5..8d1da8028 100644
--- a/drivers/mempool/dpaa/dpaa_mempool.c
+++ b/drivers/mempool/dpaa/dpaa_mempool.c
@@ -36,7 +36,8 @@ struct dpaa_memseg_list rte_dpaa_memsegs
 	= TAILQ_HEAD_INITIALIZER(rte_dpaa_memsegs);
 
 struct dpaa_bp_info *rte_dpaa_bpid_info;
-int dpaa_logtype_mempool;
+
+RTE_LOG_REGISTER(dpaa_logtype_mempool, mempool.dpaa, NOTICE);
 
 static int
 dpaa_mbuf_create_pool(struct rte_mempool *mp)
@@ -357,10 +358,3 @@ static const struct rte_mempool_ops dpaa_mpool_ops = {
 };
 
 MEMPOOL_REGISTER_OPS(dpaa_mpool_ops);
-
-RTE_INIT(dpaa_mp_init_log)
-{
-	dpaa_logtype_mempool = rte_log_register("mempool.dpaa");
-	if (dpaa_logtype_mempool >= 0)
-		rte_log_set_level(dpaa_logtype_mempool, RTE_LOG_NOTICE);
-}
diff --git a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
index fa9b53e64..97ce08d78 100644
--- a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
+++ b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
@@ -36,9 +36,6 @@
 struct dpaa2_bp_info *rte_dpaa2_bpid_info;
 static struct dpaa2_bp_list *h_bp_list;
 
-/* Dynamic logging identified for mempool */
-int dpaa2_logtype_mempool;
-
 static int
 rte_hw_mbuf_create_pool(struct rte_mempool *mp)
 {
@@ -454,9 +451,4 @@ static const struct rte_mempool_ops dpaa2_mpool_ops = {
 
 MEMPOOL_REGISTER_OPS(dpaa2_mpool_ops);
 
-RTE_INIT(dpaa2_mempool_init_log)
-{
-	dpaa2_logtype_mempool = rte_log_register("mempool.dpaa2");
-	if (dpaa2_logtype_mempool >= 0)
-		rte_log_set_level(dpaa2_logtype_mempool, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa2_logtype_mempool, mempool.dpaa2, NOTICE);
diff --git a/drivers/mempool/octeontx/octeontx_fpavf.c b/drivers/mempool/octeontx/octeontx_fpavf.c
index 0ff234913..339da7824 100644
--- a/drivers/mempool/octeontx/octeontx_fpavf.c
+++ b/drivers/mempool/octeontx/octeontx_fpavf.c
@@ -105,15 +105,7 @@ struct octeontx_fpadev {
 
 static struct octeontx_fpadev fpadev;
 
-int octeontx_logtype_fpavf;
-int octeontx_logtype_fpavf_mbox;
-
-RTE_INIT(otx_pool_init_log)
-{
-	octeontx_logtype_fpavf = rte_log_register("pmd.mempool.octeontx");
-	if (octeontx_logtype_fpavf >= 0)
-		rte_log_set_level(octeontx_logtype_fpavf, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(octeontx_logtype_fpavf, pmd.mempool.octeontx, NOTICE);
 
 /* lock is taken by caller */
 static int
-- 
2.27.0


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

* [dpdk-dev] [PATCH v5 07/13] drivers/event: use log register macro
  2020-07-01 12:33       ` [dpdk-dev] [PATCH v5 00/13] rte_log registration usage improvement jerinj
                           ` (5 preceding siblings ...)
  2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 06/13] drivers/mempool: " jerinj
@ 2020-07-01 12:33         ` jerinj
  2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 08/13] drivers/crypto: " jerinj
                           ` (6 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01 12:33 UTC (permalink / raw)
  To: dev, Hemant Agrawal, Nipun Gupta, Jerin Jacob, Pavan Nikhilesh,
	Liang Ma, Peter Mccarthy, Harry van Haaren
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena, adamx.dybkowski

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/event/dpaa/dpaa_eventdev.c   |  8 +-------
 drivers/event/dpaa2/dpaa2_eventdev.c | 10 +---------
 drivers/event/octeontx/ssovf_evdev.c |  8 +-------
 drivers/event/octeontx/timvf_evdev.c |  9 +--------
 drivers/event/opdl/opdl_evdev.c      |  8 +-------
 drivers/event/opdl/opdl_ring.c       |  2 --
 drivers/event/sw/sw_evdev.c          | 11 +----------
 7 files changed, 6 insertions(+), 50 deletions(-)

diff --git a/drivers/event/dpaa/dpaa_eventdev.c b/drivers/event/dpaa/dpaa_eventdev.c
index 5a018d487..e78728b7e 100644
--- a/drivers/event/dpaa/dpaa_eventdev.c
+++ b/drivers/event/dpaa/dpaa_eventdev.c
@@ -46,7 +46,7 @@
  * Eventqueue = Channel Instance
  * 1 Eventdev can have N Eventqueue
  */
-int dpaa_logtype_eventdev;
+RTE_LOG_REGISTER(dpaa_logtype_eventdev, pmd.event.dpaa, NOTICE);
 
 #define DISABLE_INTR_MODE "disable_intr"
 
@@ -1069,9 +1069,3 @@ static struct rte_vdev_driver vdev_eventdev_dpaa_pmd = {
 RTE_PMD_REGISTER_VDEV(EVENTDEV_NAME_DPAA_PMD, vdev_eventdev_dpaa_pmd);
 RTE_PMD_REGISTER_PARAM_STRING(EVENTDEV_NAME_DPAA_PMD,
 		DISABLE_INTR_MODE "=<int>");
-RTE_INIT(dpaa_event_init_log)
-{
-	dpaa_logtype_eventdev = rte_log_register("pmd.event.dpaa");
-	if (dpaa_logtype_eventdev >= 0)
-		rte_log_set_level(dpaa_logtype_eventdev, RTE_LOG_NOTICE);
-}
diff --git a/drivers/event/dpaa2/dpaa2_eventdev.c b/drivers/event/dpaa2/dpaa2_eventdev.c
index a196ad4c6..a545baf34 100644
--- a/drivers/event/dpaa2/dpaa2_eventdev.c
+++ b/drivers/event/dpaa2/dpaa2_eventdev.c
@@ -48,8 +48,6 @@
  * Soft Event Flow is DPCI Instance
  */
 
-/* Dynamic logging identified for mempool */
-int dpaa2_logtype_event;
 #define DPAA2_EV_TX_RETRY_COUNT 10000
 
 static uint16_t
@@ -1205,10 +1203,4 @@ static struct rte_vdev_driver vdev_eventdev_dpaa2_pmd = {
 };
 
 RTE_PMD_REGISTER_VDEV(EVENTDEV_NAME_DPAA2_PMD, vdev_eventdev_dpaa2_pmd);
-
-RTE_INIT(dpaa2_eventdev_init_log)
-{
-	dpaa2_logtype_event = rte_log_register("pmd.event.dpaa2");
-	if (dpaa2_logtype_event >= 0)
-		rte_log_set_level(dpaa2_logtype_event, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa2_logtype_event, pmd.event.dpaa2, NOTICE);
diff --git a/drivers/event/octeontx/ssovf_evdev.c b/drivers/event/octeontx/ssovf_evdev.c
index 1b1a5d939..4fc4e8f7e 100644
--- a/drivers/event/octeontx/ssovf_evdev.c
+++ b/drivers/event/octeontx/ssovf_evdev.c
@@ -20,15 +20,9 @@
 #include "ssovf_evdev.h"
 #include "timvf_evdev.h"
 
-int otx_logtype_ssovf;
 static uint8_t timvf_enable_stats;
 
-RTE_INIT(otx_ssovf_init_log)
-{
-	otx_logtype_ssovf = rte_log_register("pmd.event.octeontx");
-	if (otx_logtype_ssovf >= 0)
-		rte_log_set_level(otx_logtype_ssovf, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(otx_logtype_ssovf, pmd.event.octeontx, NOTICE);
 
 /* SSOPF Mailbox messages */
 
diff --git a/drivers/event/octeontx/timvf_evdev.c b/drivers/event/octeontx/timvf_evdev.c
index caa129087..c61aacacc 100644
--- a/drivers/event/octeontx/timvf_evdev.c
+++ b/drivers/event/octeontx/timvf_evdev.c
@@ -4,14 +4,7 @@
 
 #include "timvf_evdev.h"
 
-int otx_logtype_timvf;
-
-RTE_INIT(otx_timvf_init_log)
-{
-	otx_logtype_timvf = rte_log_register("pmd.event.octeontx.timer");
-	if (otx_logtype_timvf >= 0)
-		rte_log_set_level(otx_logtype_timvf, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(otx_logtype_timvf, pmd.event.octeontx.timer, NOTICE);
 
 struct __rte_packed timvf_mbox_dev_info {
 	uint64_t ring_active[4];
diff --git a/drivers/event/opdl/opdl_evdev.c b/drivers/event/opdl/opdl_evdev.c
index 3beca8957..9b2f75fe3 100644
--- a/drivers/event/opdl/opdl_evdev.c
+++ b/drivers/event/opdl/opdl_evdev.c
@@ -754,13 +754,7 @@ static struct rte_vdev_driver evdev_opdl_pmd_drv = {
 	.remove = opdl_remove
 };
 
-RTE_INIT(opdl_init_log)
-{
-	opdl_logtype_driver = rte_log_register("pmd.event.opdl.driver");
-	if (opdl_logtype_driver >= 0)
-		rte_log_set_level(opdl_logtype_driver, RTE_LOG_INFO);
-}
-
+RTE_LOG_REGISTER(opdl_logtype_driver, pmd.event.opdl.driver, INFO);
 
 RTE_PMD_REGISTER_VDEV(EVENTDEV_NAME_OPDL_PMD, evdev_opdl_pmd_drv);
 RTE_PMD_REGISTER_PARAM_STRING(event_opdl, NUMA_NODE_ARG "=<int>"
diff --git a/drivers/event/opdl/opdl_ring.c b/drivers/event/opdl/opdl_ring.c
index c8d19fef5..69392b56b 100644
--- a/drivers/event/opdl/opdl_ring.c
+++ b/drivers/event/opdl/opdl_ring.c
@@ -31,8 +31,6 @@
 #define OPDL_OPA_MASK    (0xFF)
 #define OPDL_OPA_OFFSET  (0x38)
 
-int opdl_logtype_driver;
-
 /* Types of dependency between stages */
 enum dep_type {
 	DEP_NONE = 0,  /* no dependency */
diff --git a/drivers/event/sw/sw_evdev.c b/drivers/event/sw/sw_evdev.c
index fb8e8bebb..98dae7164 100644
--- a/drivers/event/sw/sw_evdev.c
+++ b/drivers/event/sw/sw_evdev.c
@@ -1083,13 +1083,4 @@ static struct rte_vdev_driver evdev_sw_pmd_drv = {
 RTE_PMD_REGISTER_VDEV(EVENTDEV_NAME_SW_PMD, evdev_sw_pmd_drv);
 RTE_PMD_REGISTER_PARAM_STRING(event_sw, NUMA_NODE_ARG "=<int> "
 		SCHED_QUANTA_ARG "=<int>" CREDIT_QUANTA_ARG "=<int>");
-
-/* declared extern in header, for access from other .c files */
-int eventdev_sw_log_level;
-
-RTE_INIT(evdev_sw_init_log)
-{
-	eventdev_sw_log_level = rte_log_register("pmd.event.sw");
-	if (eventdev_sw_log_level >= 0)
-		rte_log_set_level(eventdev_sw_log_level, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(eventdev_sw_log_level, pmd.event.sw, NOTICE);
-- 
2.27.0


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

* [dpdk-dev] [PATCH v5 08/13] drivers/crypto: use log register macro
  2020-07-01 12:33       ` [dpdk-dev] [PATCH v5 00/13] rte_log registration usage improvement jerinj
                           ` (6 preceding siblings ...)
  2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 07/13] drivers/event: " jerinj
@ 2020-07-01 12:33         ` jerinj
  2020-07-02 17:59           ` Akhil Goyal
  2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 09/13] drivers/compress: " jerinj
                           ` (5 subsequent siblings)
  13 siblings, 1 reply; 98+ messages in thread
From: jerinj @ 2020-07-01 12:33 UTC (permalink / raw)
  To: dev, Declan Doherty, Pablo de Lara, Gagandeep Singh,
	Hemant Agrawal, Akhil Goyal, Michael Shamis, Liron Himi,
	Nagadheeraj Rottela, Srikanth Jampala, Anoob Joseph,
	Ankur Dwivedi, Fan Zhang, Jay Zhou
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c      |  8 +---
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c    |  8 +---
 drivers/crypto/caam_jr/caam_jr.c              |  8 +---
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c   | 11 +-----
 drivers/crypto/dpaa_sec/dpaa_sec.c            | 10 +----
 drivers/crypto/kasumi/rte_kasumi_pmd.c        |  6 +--
 drivers/crypto/mvsam/rte_mrvl_pmd.c           |  7 +---
 drivers/crypto/nitrox/nitrox_logs.c           |  9 +----
 drivers/crypto/null/null_crypto_pmd.c         |  7 +---
 drivers/crypto/octeontx/otx_cryptodev.c       | 10 +----
 drivers/crypto/octeontx2/otx2_cryptodev.c     | 12 +-----
 drivers/crypto/openssl/rte_openssl_pmd.c      |  7 +---
 .../scheduler/rte_cryptodev_scheduler.c       |  8 +---
 drivers/crypto/snow3g/rte_snow3g_pmd.c        |  7 +---
 drivers/crypto/virtio/virtio_cryptodev.c      | 39 ++++---------------
 drivers/crypto/zuc/rte_zuc_pmd.c              |  7 +---
 16 files changed, 23 insertions(+), 141 deletions(-)

diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
index d213d05b9..1d2a0ce00 100644
--- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
+++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
@@ -13,8 +13,6 @@
 
 #include "aesni_gcm_pmd_private.h"
 
-int aesni_gcm_logtype_driver;
-
 static uint8_t cryptodev_driver_id;
 
 /* setup session handlers */
@@ -889,8 +887,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_AESNI_GCM_PMD,
 	"socket_id=<int>");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(aesni_gcm_crypto_drv, aesni_gcm_pmd_drv.driver,
 		cryptodev_driver_id);
-
-RTE_INIT(aesni_gcm_init_log)
-{
-	aesni_gcm_logtype_driver = rte_log_register("pmd.crypto.aesni_gcm");
-}
+RTE_LOG_REGISTER(aesni_gcm_logtype_driver, pmd.crypto.aesni_gcm, NOTICE);
diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
index 2d688f4d3..9d0d9f4d7 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
@@ -15,8 +15,6 @@
 
 #include "aesni_mb_pmd_private.h"
 
-int aesni_mb_logtype_driver;
-
 #define AES_CCM_DIGEST_MIN_LEN 4
 #define AES_CCM_DIGEST_MAX_LEN 16
 #define HMAC_MAX_BLOCK_SIZE 128
@@ -1744,8 +1742,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_AESNI_MB_PMD,
 RTE_PMD_REGISTER_CRYPTO_DRIVER(aesni_mb_crypto_drv,
 		cryptodev_aesni_mb_pmd_drv.driver,
 		cryptodev_driver_id);
-
-RTE_INIT(aesni_mb_init_log)
-{
-	aesni_mb_logtype_driver = rte_log_register("pmd.crypto.aesni_mb");
-}
+RTE_LOG_REGISTER(aesni_mb_logtype_driver, pmd.crypto.aesni_mb, NOTICE);
diff --git a/drivers/crypto/caam_jr/caam_jr.c b/drivers/crypto/caam_jr/caam_jr.c
index caf238677..49a35d614 100644
--- a/drivers/crypto/caam_jr/caam_jr.c
+++ b/drivers/crypto/caam_jr/caam_jr.c
@@ -35,7 +35,6 @@
 #endif
 #define CRYPTODEV_NAME_CAAM_JR_PMD	crypto_caam_jr
 static uint8_t cryptodev_driver_id;
-int caam_jr_logtype;
 
 /* Lists the states possible for the SEC user space driver. */
 enum sec_driver_state_e {
@@ -2477,9 +2476,4 @@ RTE_INIT(caam_jr_init)
 	sec_job_rings_init();
 }
 
-RTE_INIT(caam_jr_init_log)
-{
-	caam_jr_logtype = rte_log_register("pmd.crypto.caam");
-	if (caam_jr_logtype >= 0)
-		rte_log_set_level(caam_jr_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(caam_jr_logtype, pmd.crypto.caam, NOTICE);
diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index 63e7d930a..12f833136 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
@@ -58,8 +58,6 @@
 
 static uint8_t cryptodev_driver_id;
 
-int dpaa2_logtype_sec;
-
 #ifdef RTE_LIBRTE_SECURITY
 static inline int
 build_proto_compound_sg_fd(dpaa2_sec_session *sess,
@@ -3918,11 +3916,4 @@ static struct cryptodev_driver dpaa2_sec_crypto_drv;
 RTE_PMD_REGISTER_DPAA2(CRYPTODEV_NAME_DPAA2_SEC_PMD, rte_dpaa2_sec_driver);
 RTE_PMD_REGISTER_CRYPTO_DRIVER(dpaa2_sec_crypto_drv,
 		rte_dpaa2_sec_driver.driver, cryptodev_driver_id);
-
-RTE_INIT(dpaa2_sec_init_log)
-{
-	/* Bus level logs */
-	dpaa2_logtype_sec = rte_log_register("pmd.crypto.dpaa2");
-	if (dpaa2_logtype_sec >= 0)
-		rte_log_set_level(dpaa2_logtype_sec, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa2_logtype_sec, pmd.crypto.dpaa2, NOTICE);
diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c
index 66ee0ba0c..d9fa8bb36 100644
--- a/drivers/crypto/dpaa_sec/dpaa_sec.c
+++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
@@ -43,8 +43,6 @@
 #include <dpaa_sec_log.h>
 #include <dpaax_iova_table.h>
 
-int dpaa_logtype_sec;
-
 static uint8_t cryptodev_driver_id;
 
 static __thread struct rte_crypto_op **dpaa_sec_ops;
@@ -3520,10 +3518,4 @@ static struct cryptodev_driver dpaa_sec_crypto_drv;
 RTE_PMD_REGISTER_DPAA(CRYPTODEV_NAME_DPAA_SEC_PMD, rte_dpaa_sec_driver);
 RTE_PMD_REGISTER_CRYPTO_DRIVER(dpaa_sec_crypto_drv, rte_dpaa_sec_driver.driver,
 		cryptodev_driver_id);
-
-RTE_INIT(dpaa_sec_init_log)
-{
-	dpaa_logtype_sec = rte_log_register("pmd.crypto.dpaa");
-	if (dpaa_logtype_sec >= 0)
-		rte_log_set_level(dpaa_logtype_sec, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa_logtype_sec, pmd.crypto.dpaa, NOTICE);
diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd.c b/drivers/crypto/kasumi/rte_kasumi_pmd.c
index 73077e3d9..c3f0dfc2f 100644
--- a/drivers/crypto/kasumi/rte_kasumi_pmd.c
+++ b/drivers/crypto/kasumi/rte_kasumi_pmd.c
@@ -17,7 +17,6 @@
 #define KASUMI_MAX_BURST 4
 #define BYTE_LEN 8
 
-int kasumi_logtype_driver;
 static uint8_t cryptodev_driver_id;
 
 /** Get xform chain order. */
@@ -639,7 +638,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_KASUMI_PMD,
 RTE_PMD_REGISTER_CRYPTO_DRIVER(kasumi_crypto_drv,
 		cryptodev_kasumi_pmd_drv.driver, cryptodev_driver_id);
 
-RTE_INIT(kasumi_init_log)
-{
-	kasumi_logtype_driver = rte_log_register("pmd.crypto.kasumi");
-}
+RTE_LOG_REGISTER(kasumi_logtype_driver, pmd.crypto.kasumi, NOTICE);
diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd.c b/drivers/crypto/mvsam/rte_mrvl_pmd.c
index 63782ce97..aaa40dced 100644
--- a/drivers/crypto/mvsam/rte_mrvl_pmd.c
+++ b/drivers/crypto/mvsam/rte_mrvl_pmd.c
@@ -19,7 +19,6 @@
 #define MRVL_PMD_MAX_NB_SESS_ARG		("max_nb_sessions")
 #define MRVL_PMD_DEFAULT_MAX_NB_SESSIONS	2048
 
-int mrvl_logtype_driver;
 static uint8_t cryptodev_driver_id;
 
 struct mrvl_pmd_init_params {
@@ -1020,8 +1019,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_MRVL_PMD,
 	"socket_id=<int>");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(mrvl_crypto_drv, cryptodev_mrvl_pmd_drv.driver,
 		cryptodev_driver_id);
-
-RTE_INIT(crypto_mrvl_init_log)
-{
-	mrvl_logtype_driver = rte_log_register("pmd.crypto.mvsam");
-}
+RTE_LOG_REGISTER(mrvl_logtype_driver, pmd.crypto.mvsam, NOTICE);
diff --git a/drivers/crypto/nitrox/nitrox_logs.c b/drivers/crypto/nitrox/nitrox_logs.c
index 007056cb4..26395159a 100644
--- a/drivers/crypto/nitrox/nitrox_logs.c
+++ b/drivers/crypto/nitrox/nitrox_logs.c
@@ -4,11 +4,4 @@
 
 #include <rte_log.h>
 
-int nitrox_logtype;
-
-RTE_INIT(nitrox_init_log)
-{
-	nitrox_logtype = rte_log_register("pmd.crypto.nitrox");
-	if (nitrox_logtype >= 0)
-		rte_log_set_level(nitrox_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(nitrox_logtype, pmd.crypto.nitrox, NOTICE);
diff --git a/drivers/crypto/null/null_crypto_pmd.c b/drivers/crypto/null/null_crypto_pmd.c
index 7b0b9d42b..e04042e75 100644
--- a/drivers/crypto/null/null_crypto_pmd.c
+++ b/drivers/crypto/null/null_crypto_pmd.c
@@ -10,7 +10,6 @@
 #include "null_crypto_pmd_private.h"
 
 static uint8_t cryptodev_driver_id;
-int null_logtype_driver;
 
 /** verify and set session parameters */
 int
@@ -249,8 +248,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_NULL_PMD,
 	"socket_id=<int>");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(null_crypto_drv, cryptodev_null_pmd_drv.driver,
 		cryptodev_driver_id);
-
-RTE_INIT(null_init_log)
-{
-	null_logtype_driver = rte_log_register("pmd.crypto.null");
-}
+RTE_LOG_REGISTER(null_logtype_driver, pmd.crypto.null, INFO);
diff --git a/drivers/crypto/octeontx/otx_cryptodev.c b/drivers/crypto/octeontx/otx_cryptodev.c
index ddece1311..5ce1cf82f 100644
--- a/drivers/crypto/octeontx/otx_cryptodev.c
+++ b/drivers/crypto/octeontx/otx_cryptodev.c
@@ -15,7 +15,6 @@
 #include "cpt_pmd_logs.h"
 
 uint8_t otx_cryptodev_driver_id;
-int otx_cpt_logtype;
 
 static struct rte_pci_id pci_id_cpt_table[] = {
 	{
@@ -112,11 +111,4 @@ RTE_PMD_REGISTER_PCI_TABLE(CRYPTODEV_NAME_OCTEONTX_PMD, pci_id_cpt_table);
 RTE_PMD_REGISTER_KMOD_DEP(CRYPTODEV_NAME_OCTEONTX_PMD, "vfio-pci");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(otx_cryptodev_drv, otx_cryptodev_pmd.driver,
 		otx_cryptodev_driver_id);
-
-RTE_INIT(otx_cpt_init_log)
-{
-	/* Bus level logs */
-	otx_cpt_logtype = rte_log_register("pmd.crypto.octeontx");
-	if (otx_cpt_logtype >= 0)
-		rte_log_set_level(otx_cpt_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(otx_cpt_logtype, pmd.crypto.octeontx, NOTICE);
diff --git a/drivers/crypto/octeontx2/otx2_cryptodev.c b/drivers/crypto/octeontx2/otx2_cryptodev.c
index 6ffbc2eb7..50cbb13d8 100644
--- a/drivers/crypto/octeontx2/otx2_cryptodev.c
+++ b/drivers/crypto/octeontx2/otx2_cryptodev.c
@@ -22,8 +22,6 @@
 #include "cpt_common.h"
 #include "cpt_pmd_logs.h"
 
-int otx2_cpt_logtype;
-
 uint8_t otx2_cryptodev_driver_id;
 
 static struct rte_pci_id pci_id_cpt_table[] = {
@@ -146,17 +144,9 @@ static struct rte_pci_driver otx2_cryptodev_pmd = {
 
 static struct cryptodev_driver otx2_cryptodev_drv;
 
-RTE_INIT(otx2_cpt_init_log);
 RTE_PMD_REGISTER_PCI(CRYPTODEV_NAME_OCTEONTX2_PMD, otx2_cryptodev_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(CRYPTODEV_NAME_OCTEONTX2_PMD, pci_id_cpt_table);
 RTE_PMD_REGISTER_KMOD_DEP(CRYPTODEV_NAME_OCTEONTX2_PMD, "vfio-pci");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(otx2_cryptodev_drv, otx2_cryptodev_pmd.driver,
 		otx2_cryptodev_driver_id);
-
-RTE_INIT(otx2_cpt_init_log)
-{
-	/* Bus level logs */
-	otx2_cpt_logtype = rte_log_register("pmd.crypto.octeontx2");
-	if (otx2_cpt_logtype >= 0)
-		rte_log_set_level(otx2_cpt_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(otx2_cpt_logtype, pmd.crypto.octeontx2, NOTICE);
diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c
index bb9fb877a..7d3959f55 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd.c
@@ -18,7 +18,6 @@
 
 #define DES_BLOCK_SIZE 8
 
-int openssl_logtype_driver;
 static uint8_t cryptodev_driver_id;
 
 #if (OPENSSL_VERSION_NUMBER < 0x10100000L)
@@ -2279,8 +2278,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_OPENSSL_PMD,
 	"socket_id=<int>");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(openssl_crypto_drv,
 		cryptodev_openssl_pmd_drv.driver, cryptodev_driver_id);
-
-RTE_INIT(openssl_init_log)
-{
-	openssl_logtype_driver = rte_log_register("pmd.crypto.openssl");
-}
+RTE_LOG_REGISTER(openssl_logtype_driver, pmd.crypto.openssl, INFO);
diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
index 1fef88f11..730504dab 100644
--- a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
+++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
@@ -10,8 +10,6 @@
 #include "rte_cryptodev_scheduler.h"
 #include "scheduler_pmd_private.h"
 
-int scheduler_logtype_driver;
-
 /** update the scheduler pmd's capability with attaching device's
  *  capability.
  *  For each device to be attached, the scheduler's capability should be
@@ -578,7 +576,5 @@ rte_cryptodev_scheduler_option_get(uint8_t scheduler_id,
 	return (*sched_ctx->ops.option_get)(dev, option_type, option);
 }
 
-RTE_INIT(scheduler_init_log)
-{
-	scheduler_logtype_driver = rte_log_register("pmd.crypto.scheduler");
-}
+
+RTE_LOG_REGISTER(scheduler_logtype_driver, pmd.crypto.scheduler, INFO);
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index c939064d5..558e01e70 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -16,7 +16,6 @@
 #define SNOW3G_MAX_BURST 8
 #define BYTE_LEN 8
 
-int snow3g_logtype_driver;
 static uint8_t cryptodev_driver_id;
 
 /** Get xform chain order. */
@@ -653,8 +652,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_SNOW3G_PMD,
 	"socket_id=<int>");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(snow3g_crypto_drv,
 		cryptodev_snow3g_pmd_drv.driver, cryptodev_driver_id);
-
-RTE_INIT(snow3g_init_log)
-{
-	snow3g_logtype_driver = rte_log_register("pmd.crypto.snow3g");
-}
+RTE_LOG_REGISTER(snow3g_logtype_driver, pmd.crypto.snow3g, INFO);
diff --git a/drivers/crypto/virtio/virtio_cryptodev.c b/drivers/crypto/virtio/virtio_cryptodev.c
index cdf43b0e0..31a5f1072 100644
--- a/drivers/crypto/virtio/virtio_cryptodev.c
+++ b/drivers/crypto/virtio/virtio_cryptodev.c
@@ -17,12 +17,6 @@
 #include "virtio_crypto_algs.h"
 #include "virtio_crypto_capabilities.h"
 
-int virtio_crypto_logtype_init;
-int virtio_crypto_logtype_session;
-int virtio_crypto_logtype_rx;
-int virtio_crypto_logtype_tx;
-int virtio_crypto_logtype_driver;
-
 static int virtio_crypto_dev_configure(struct rte_cryptodev *dev,
 		struct rte_cryptodev_config *config);
 static int virtio_crypto_dev_start(struct rte_cryptodev *dev);
@@ -1489,29 +1483,10 @@ RTE_PMD_REGISTER_PCI(CRYPTODEV_NAME_VIRTIO_PMD, rte_virtio_crypto_driver);
 RTE_PMD_REGISTER_CRYPTO_DRIVER(virtio_crypto_drv,
 	rte_virtio_crypto_driver.driver,
 	cryptodev_virtio_driver_id);
-
-RTE_INIT(virtio_crypto_init_log)
-{
-	virtio_crypto_logtype_init = rte_log_register("pmd.crypto.virtio.init");
-	if (virtio_crypto_logtype_init >= 0)
-		rte_log_set_level(virtio_crypto_logtype_init, RTE_LOG_NOTICE);
-
-	virtio_crypto_logtype_session =
-		rte_log_register("pmd.crypto.virtio.session");
-	if (virtio_crypto_logtype_session >= 0)
-		rte_log_set_level(virtio_crypto_logtype_session,
-				RTE_LOG_NOTICE);
-
-	virtio_crypto_logtype_rx = rte_log_register("pmd.crypto.virtio.rx");
-	if (virtio_crypto_logtype_rx >= 0)
-		rte_log_set_level(virtio_crypto_logtype_rx, RTE_LOG_NOTICE);
-
-	virtio_crypto_logtype_tx = rte_log_register("pmd.crypto.virtio.tx");
-	if (virtio_crypto_logtype_tx >= 0)
-		rte_log_set_level(virtio_crypto_logtype_tx, RTE_LOG_NOTICE);
-
-	virtio_crypto_logtype_driver =
-		rte_log_register("pmd.crypto.virtio.driver");
-	if (virtio_crypto_logtype_driver >= 0)
-		rte_log_set_level(virtio_crypto_logtype_driver, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(virtio_crypto_logtype_init, pmd.crypto.virtio.init, NOTICE);
+RTE_LOG_REGISTER(virtio_crypto_logtype_session, pmd.crypto.virtio.session,
+		 NOTICE);
+RTE_LOG_REGISTER(virtio_crypto_logtype_rx, pmd.crypto.virtio.rx, NOTICE);
+RTE_LOG_REGISTER(virtio_crypto_logtype_tx, pmd.crypto.virtio.tx, NOTICE);
+RTE_LOG_REGISTER(virtio_crypto_logtype_driver, pmd.crypto.virtio.driver,
+		 NOTICE);
diff --git a/drivers/crypto/zuc/rte_zuc_pmd.c b/drivers/crypto/zuc/rte_zuc_pmd.c
index df8d6f6bb..20cb5a160 100644
--- a/drivers/crypto/zuc/rte_zuc_pmd.c
+++ b/drivers/crypto/zuc/rte_zuc_pmd.c
@@ -14,7 +14,6 @@
 #define ZUC_MAX_BURST 16
 #define BYTE_LEN 8
 
-int zuc_logtype_driver;
 static uint8_t cryptodev_driver_id;
 
 /** Get xform chain order. */
@@ -580,8 +579,4 @@ RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_ZUC_PMD,
 	"socket_id=<int>");
 RTE_PMD_REGISTER_CRYPTO_DRIVER(zuc_crypto_drv, cryptodev_zuc_pmd_drv.driver,
 		cryptodev_driver_id);
-
-RTE_INIT(zuc_init_log)
-{
-	zuc_logtype_driver = rte_log_register("pmd.crypto.zuc");
-}
+RTE_LOG_REGISTER(zuc_logtype_driver, pmd.crypto.zuc, INFO);
-- 
2.27.0


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

* [dpdk-dev] [PATCH v5 09/13] drivers/compress: use log register macro
  2020-07-01 12:33       ` [dpdk-dev] [PATCH v5 00/13] rte_log registration usage improvement jerinj
                           ` (7 preceding siblings ...)
  2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 08/13] drivers/crypto: " jerinj
@ 2020-07-01 12:33         ` jerinj
  2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 10/13] drivers/common: " jerinj
                           ` (4 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01 12:33 UTC (permalink / raw)
  To: dev, Lee Daly, Fiona Trahe, Ashish Gupta, Sunila Sahu
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/compress/isal/isal_compress_pmd.c | 10 +---------
 drivers/compress/octeontx/otx_zip_pmd.c   | 10 +---------
 drivers/compress/zlib/zlib_pmd.c          | 10 +---------
 3 files changed, 3 insertions(+), 27 deletions(-)

diff --git a/drivers/compress/isal/isal_compress_pmd.c b/drivers/compress/isal/isal_compress_pmd.c
index 7d2b05c91..0ecca12a8 100644
--- a/drivers/compress/isal/isal_compress_pmd.c
+++ b/drivers/compress/isal/isal_compress_pmd.c
@@ -25,8 +25,6 @@
 #define ISAL_VERSION_STRING \
 	ISAL_TOSTRING(ISAL_MAJOR_VERSION, ISAL_MINOR_VERSION, ISAL_PATCH_VERSION)
 
-int isal_logtype_driver;
-
 /* Verify and set private xform parameters */
 int
 isal_comp_set_priv_xform_parameters(struct isal_priv_xform *priv_xform,
@@ -752,10 +750,4 @@ static struct rte_vdev_driver compdev_isal_pmd_drv = {
 RTE_PMD_REGISTER_VDEV(COMPDEV_NAME_ISAL_PMD, compdev_isal_pmd_drv);
 RTE_PMD_REGISTER_PARAM_STRING(COMPDEV_NAME_ISAL_PMD,
 	"socket_id=<int>");
-
-RTE_INIT(isal_init_log)
-{
-	isal_logtype_driver = rte_log_register("pmd.compress.isal");
-	if (isal_logtype_driver >= 0)
-		rte_log_set_level(isal_logtype_driver, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(isal_logtype_driver, pmd.compress.isal, INFO);
diff --git a/drivers/compress/octeontx/otx_zip_pmd.c b/drivers/compress/octeontx/otx_zip_pmd.c
index bff8ef035..bee90fc7c 100644
--- a/drivers/compress/octeontx/otx_zip_pmd.c
+++ b/drivers/compress/octeontx/otx_zip_pmd.c
@@ -11,8 +11,6 @@
 
 #include "otx_zip.h"
 
-int octtx_zip_logtype_driver;
-
 static const struct rte_compressdev_capabilities
 				octtx_zip_pmd_capabilities[] = {
 	{	.algo = RTE_COMP_ALGO_DEFLATE,
@@ -648,10 +646,4 @@ static struct rte_pci_driver octtx_zip_pmd = {
 
 RTE_PMD_REGISTER_PCI(COMPRESSDEV_NAME_ZIP_PMD, octtx_zip_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(COMPRESSDEV_NAME_ZIP_PMD, pci_id_octtx_zipvf_table);
-
-RTE_INIT(octtx_zip_init_log)
-{
-	octtx_zip_logtype_driver = rte_log_register("pmd.compress.octeontx");
-	if (octtx_zip_logtype_driver >= 0)
-		rte_log_set_level(octtx_zip_logtype_driver, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(octtx_zip_logtype_driver, pmd.compress.octeontx, INFO);
diff --git a/drivers/compress/zlib/zlib_pmd.c b/drivers/compress/zlib/zlib_pmd.c
index e39be2ed8..8a79d15c9 100644
--- a/drivers/compress/zlib/zlib_pmd.c
+++ b/drivers/compress/zlib/zlib_pmd.c
@@ -7,8 +7,6 @@
 
 #include "zlib_pmd_private.h"
 
-int zlib_logtype_driver;
-
 /** Compute next mbuf in the list, assign data buffer and length,
  *  returns 0 if mbuf is NULL
  */
@@ -428,10 +426,4 @@ static struct rte_vdev_driver zlib_pmd_drv = {
 };
 
 RTE_PMD_REGISTER_VDEV(COMPRESSDEV_NAME_ZLIB_PMD, zlib_pmd_drv);
-
-RTE_INIT(zlib_init_log)
-{
-	zlib_logtype_driver = rte_log_register("pmd.compress.zlib");
-	if (zlib_logtype_driver >= 0)
-		rte_log_set_level(zlib_logtype_driver, RTE_LOG_INFO);
-}
+RTE_LOG_REGISTER(zlib_logtype_driver, pmd.compress.zlib, INFO);
-- 
2.27.0


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

* [dpdk-dev] [PATCH v5 10/13] drivers/common: use log register macro
  2020-07-01 12:33       ` [dpdk-dev] [PATCH v5 00/13] rte_log registration usage improvement jerinj
                           ` (8 preceding siblings ...)
  2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 09/13] drivers/compress: " jerinj
@ 2020-07-01 12:33         ` jerinj
  2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 11/13] drivers/bus: " jerinj
                           ` (3 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01 12:33 UTC (permalink / raw)
  To: dev, Hemant Agrawal, Sachin Saxena, Jingjing Wu, Beilei Xing,
	Harman Kalra, Jerin Jacob, Nithin Dabilpuram, John Griffin,
	Fiona Trahe, Deepak Kumar Jain
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena, adamx.dybkowski

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Sachin Saxena <sachin.saxena@oss.nxp.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/common/dpaax/dpaax_iova_table.c | 10 +--
 drivers/common/iavf/iavf_impl.c         |  9 +--
 drivers/common/octeontx/octeontx_mbox.c |  9 +--
 drivers/common/octeontx2/otx2_common.c  | 96 +++----------------------
 drivers/common/qat/qat_logs.c           | 17 +----
 5 files changed, 15 insertions(+), 126 deletions(-)

diff --git a/drivers/common/dpaax/dpaax_iova_table.c b/drivers/common/dpaax/dpaax_iova_table.c
index 98b076e09..5ba8ed193 100644
--- a/drivers/common/dpaax/dpaax_iova_table.c
+++ b/drivers/common/dpaax/dpaax_iova_table.c
@@ -7,9 +7,6 @@
 #include "dpaax_iova_table.h"
 #include "dpaax_logs.h"
 
-/* Global dpaax logger identifier */
-int dpaax_logger;
-
 /* Global table reference */
 struct dpaax_iova_table *dpaax_iova_table_p;
 
@@ -463,9 +460,4 @@ dpaax_handle_memevents(void)
 					       dpaax_memevent_cb, NULL);
 }
 
-RTE_INIT(dpaax_log)
-{
-	dpaax_logger = rte_log_register("pmd.common.dpaax");
-	if (dpaax_logger >= 0)
-		rte_log_set_level(dpaax_logger, RTE_LOG_ERR);
-}
+RTE_LOG_REGISTER(dpaax_logger, pmd.common.dpaax, ERR);
diff --git a/drivers/common/iavf/iavf_impl.c b/drivers/common/iavf/iavf_impl.c
index 6174a9144..fc0da3175 100644
--- a/drivers/common/iavf/iavf_impl.c
+++ b/drivers/common/iavf/iavf_impl.c
@@ -13,8 +13,6 @@
 #include "iavf_type.h"
 #include "iavf_prototype.h"
 
-int iavf_common_logger;
-
 enum iavf_status
 iavf_allocate_dma_mem_d(__rte_unused struct iavf_hw *hw,
 			struct iavf_dma_mem *mem,
@@ -87,9 +85,4 @@ iavf_free_virt_mem_d(__rte_unused struct iavf_hw *hw,
 	return IAVF_SUCCESS;
 }
 
-RTE_INIT(iavf_common_init_log)
-{
-	iavf_common_logger = rte_log_register("pmd.common.iavf");
-	if (iavf_common_logger >= 0)
-		rte_log_set_level(iavf_common_logger, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(iavf_common_logger, pmd.common.iavf, NOTICE);
diff --git a/drivers/common/octeontx/octeontx_mbox.c b/drivers/common/octeontx/octeontx_mbox.c
index effe0b267..f414267e4 100644
--- a/drivers/common/octeontx/octeontx_mbox.c
+++ b/drivers/common/octeontx/octeontx_mbox.c
@@ -68,14 +68,7 @@ struct mbox_intf_ver {
 	uint32_t minor:10;
 };
 
-int octeontx_logtype_mbox;
-
-RTE_INIT(otx_init_log)
-{
-	octeontx_logtype_mbox = rte_log_register("pmd.octeontx.mbox");
-	if (octeontx_logtype_mbox >= 0)
-		rte_log_set_level(octeontx_logtype_mbox, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(octeontx_logtype_mbox, pmd.octeontx.mbox, NOTICE);
 
 static inline void
 mbox_msgcpy(volatile uint8_t *d, volatile const uint8_t *s, uint16_t size)
diff --git a/drivers/common/octeontx2/otx2_common.c b/drivers/common/octeontx2/otx2_common.c
index 5e7272f69..b292e999a 100644
--- a/drivers/common/octeontx2/otx2_common.c
+++ b/drivers/common/octeontx2/otx2_common.c
@@ -203,89 +203,13 @@ void otx2_parse_common_devargs(struct rte_kvargs *kvlist)
 	idev->npa_lock_mask = npa_lock_mask;
 }
 
-/**
- * @internal
- */
-int otx2_logtype_base;
-/**
- * @internal
- */
-int otx2_logtype_mbox;
-/**
- * @internal
- */
-int otx2_logtype_npa;
-/**
- * @internal
- */
-int otx2_logtype_nix;
-/**
- * @internal
- */
-int otx2_logtype_npc;
-/**
- * @internal
- */
-int otx2_logtype_tm;
-/**
- * @internal
- */
-int otx2_logtype_sso;
-/**
- * @internal
- */
-int otx2_logtype_tim;
-/**
- * @internal
- */
-int otx2_logtype_dpi;
-/**
- * @internal
- */
-int otx2_logtype_ep;
-
-RTE_INIT(otx2_log_init);
-static void
-otx2_log_init(void)
-{
-	otx2_logtype_base = rte_log_register("pmd.octeontx2.base");
-	if (otx2_logtype_base >= 0)
-		rte_log_set_level(otx2_logtype_base, RTE_LOG_NOTICE);
-
-	otx2_logtype_mbox = rte_log_register("pmd.octeontx2.mbox");
-	if (otx2_logtype_mbox >= 0)
-		rte_log_set_level(otx2_logtype_mbox, RTE_LOG_NOTICE);
-
-	otx2_logtype_npa = rte_log_register("pmd.mempool.octeontx2");
-	if (otx2_logtype_npa >= 0)
-		rte_log_set_level(otx2_logtype_npa, RTE_LOG_NOTICE);
-
-	otx2_logtype_nix = rte_log_register("pmd.net.octeontx2");
-	if (otx2_logtype_nix >= 0)
-		rte_log_set_level(otx2_logtype_nix, RTE_LOG_NOTICE);
-
-	otx2_logtype_npc = rte_log_register("pmd.net.octeontx2.flow");
-	if (otx2_logtype_npc >= 0)
-		rte_log_set_level(otx2_logtype_npc, RTE_LOG_NOTICE);
-
-	otx2_logtype_tm = rte_log_register("pmd.net.octeontx2.tm");
-	if (otx2_logtype_tm >= 0)
-		rte_log_set_level(otx2_logtype_tm, RTE_LOG_NOTICE);
-
-	otx2_logtype_sso = rte_log_register("pmd.event.octeontx2");
-	if (otx2_logtype_sso >= 0)
-		rte_log_set_level(otx2_logtype_sso, RTE_LOG_NOTICE);
-
-	otx2_logtype_tim = rte_log_register("pmd.event.octeontx2.timer");
-	if (otx2_logtype_tim >= 0)
-		rte_log_set_level(otx2_logtype_tim, RTE_LOG_NOTICE);
-
-	otx2_logtype_dpi = rte_log_register("pmd.raw.octeontx2.dpi");
-	if (otx2_logtype_dpi >= 0)
-		rte_log_set_level(otx2_logtype_dpi, RTE_LOG_NOTICE);
-
-	otx2_logtype_ep = rte_log_register("pmd.raw.octeontx2.ep");
-	if (otx2_logtype_ep >= 0)
-		rte_log_set_level(otx2_logtype_ep, RTE_LOG_NOTICE);
-
-}
+RTE_LOG_REGISTER(otx2_logtype_base, pmd.octeontx2.base, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_mbox, pmd.octeontx2.mbox, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_npa, pmd.mempool.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_nix, pmd.net.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_npc, pmd.net.octeontx2.flow, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_tm, pmd.net.octeontx2.tm, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_sso, pmd.event.octeontx2, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_tim, pmd.event.octeontx2.timer, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_dpi, pmd.raw.octeontx2.dpi, NOTICE);
+RTE_LOG_REGISTER(otx2_logtype_ep, pmd.raw.octeontx2.ep, NOTICE);
diff --git a/drivers/common/qat/qat_logs.c b/drivers/common/qat/qat_logs.c
index dfd0cbe5d..fa48be53c 100644
--- a/drivers/common/qat/qat_logs.c
+++ b/drivers/common/qat/qat_logs.c
@@ -7,9 +7,6 @@
 
 #include "qat_logs.h"
 
-int qat_gen_logtype;
-int qat_dp_logtype;
-
 int
 qat_hexdump_log(uint32_t level, uint32_t logtype, const char *title,
 		const void *buf, unsigned int len)
@@ -20,15 +17,5 @@ qat_hexdump_log(uint32_t level, uint32_t logtype, const char *title,
 	return 0;
 }
 
-RTE_INIT(qat_pci_init_log)
-{
-	/* Non-data-path logging for pci device and all services */
-	qat_gen_logtype = rte_log_register("pmd.qat_general");
-	if (qat_gen_logtype >= 0)
-		rte_log_set_level(qat_gen_logtype, RTE_LOG_NOTICE);
-
-	/* data-path logging for all services */
-	qat_dp_logtype = rte_log_register("pmd.qat_dp");
-	if (qat_dp_logtype >= 0)
-		rte_log_set_level(qat_dp_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(qat_gen_logtype, pmd.qat_general, NOTICE);
+RTE_LOG_REGISTER(qat_dp_logtype, pmd.qat_dp, NOTICE);
-- 
2.27.0


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

* [dpdk-dev]  [PATCH v5 11/13] drivers/bus: use log register macro
  2020-07-01 12:33       ` [dpdk-dev] [PATCH v5 00/13] rte_log registration usage improvement jerinj
                           ` (9 preceding siblings ...)
  2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 10/13] drivers/common: " jerinj
@ 2020-07-01 12:33         ` jerinj
  2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 12/13] drivers/baseband: " jerinj
                           ` (2 subsequent siblings)
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01 12:33 UTC (permalink / raw)
  To: dev, Hemant Agrawal, Sachin Saxena, Rosen Xu, Stephen Hemminger
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Sachin Saxena <sachin.saxena@oss.nxp.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 drivers/bus/dpaa/dpaa_bus.c      | 10 +---------
 drivers/bus/fslmc/fslmc_bus.c    | 11 +----------
 drivers/bus/ifpga/ifpga_bus.c    |  9 +--------
 drivers/bus/vdev/vdev.c          | 10 +---------
 drivers/bus/vmbus/vmbus_common.c |  9 +--------
 5 files changed, 5 insertions(+), 44 deletions(-)

diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c
index d53fe6083..0d8b13e5f 100644
--- a/drivers/bus/dpaa/dpaa_bus.c
+++ b/drivers/bus/dpaa/dpaa_bus.c
@@ -42,8 +42,6 @@
 #include <fsl_bman.h>
 #include <netcfg.h>
 
-int dpaa_logtype_bus;
-
 static struct rte_dpaa_bus rte_dpaa_bus;
 struct netcfg_info *dpaa_netcfg;
 
@@ -749,10 +747,4 @@ static struct rte_dpaa_bus rte_dpaa_bus = {
 };
 
 RTE_REGISTER_BUS(FSL_DPAA_BUS_NAME, rte_dpaa_bus.bus);
-
-RTE_INIT(dpaa_init_log)
-{
-	dpaa_logtype_bus = rte_log_register("bus.dpaa");
-	if (dpaa_logtype_bus >= 0)
-		rte_log_set_level(dpaa_logtype_bus, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa_logtype_bus, bus.dpaa, NOTICE);
diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
index afbd82e8d..d9f403bd9 100644
--- a/drivers/bus/fslmc/fslmc_bus.c
+++ b/drivers/bus/fslmc/fslmc_bus.c
@@ -21,8 +21,6 @@
 
 #include <dpaax_iova_table.h>
 
-int dpaa2_logtype_bus;
-
 #define VFIO_IOMMU_GROUP_PATH "/sys/kernel/iommu_groups"
 #define FSLMC_BUS_NAME	fslmc
 
@@ -649,11 +647,4 @@ struct rte_fslmc_bus rte_fslmc_bus = {
 };
 
 RTE_REGISTER_BUS(FSLMC_BUS_NAME, rte_fslmc_bus.bus);
-
-RTE_INIT(fslmc_init_log)
-{
-	/* Bus level logs */
-	dpaa2_logtype_bus = rte_log_register("bus.fslmc");
-	if (dpaa2_logtype_bus >= 0)
-		rte_log_set_level(dpaa2_logtype_bus, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(dpaa2_logtype_bus, bus.fslmc, NOTICE);
diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c
index addbc3e86..103915d43 100644
--- a/drivers/bus/ifpga/ifpga_bus.c
+++ b/drivers/bus/ifpga/ifpga_bus.c
@@ -32,7 +32,6 @@
 #include "ifpga_logs.h"
 #include "ifpga_common.h"
 
-int ifpga_bus_logtype;
 
 /* Forward declaration to access Intel FPGA bus
  * on which iFPGA devices are connected
@@ -474,10 +473,4 @@ static struct rte_bus rte_ifpga_bus = {
 };
 
 RTE_REGISTER_BUS(IFPGA_BUS_NAME, rte_ifpga_bus);
-
-RTE_INIT(ifpga_init_log)
-{
-	ifpga_bus_logtype = rte_log_register("bus.ifpga");
-	if (ifpga_bus_logtype >= 0)
-		rte_log_set_level(ifpga_bus_logtype, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(ifpga_bus_logtype, bus.ifpga, NOTICE);
diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index a89ea2353..d746149a2 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -27,8 +27,6 @@
 
 #define VDEV_MP_KEY	"bus_vdev_mp"
 
-int vdev_logtype_bus;
-
 /* Forward declare to access virtual bus name */
 static struct rte_bus rte_vdev_bus;
 
@@ -557,10 +555,4 @@ static struct rte_bus rte_vdev_bus = {
 };
 
 RTE_REGISTER_BUS(vdev, rte_vdev_bus);
-
-RTE_INIT(vdev_init_log)
-{
-	vdev_logtype_bus = rte_log_register("bus.vdev");
-	if (vdev_logtype_bus >= 0)
-		rte_log_set_level(vdev_logtype_bus, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(vdev_logtype_bus, bus.vdev, NOTICE);
diff --git a/drivers/bus/vmbus/vmbus_common.c b/drivers/bus/vmbus/vmbus_common.c
index 3adef01c9..4c9ac33ac 100644
--- a/drivers/bus/vmbus/vmbus_common.c
+++ b/drivers/bus/vmbus/vmbus_common.c
@@ -22,7 +22,6 @@
 
 #include "private.h"
 
-int vmbus_logtype_bus;
 extern struct rte_vmbus_bus rte_vmbus_bus;
 
 /* map a particular resource from a file */
@@ -298,10 +297,4 @@ struct rte_vmbus_bus rte_vmbus_bus = {
 };
 
 RTE_REGISTER_BUS(vmbus, rte_vmbus_bus.bus);
-
-RTE_INIT(vmbus_init_log)
-{
-	vmbus_logtype_bus = rte_log_register("bus.vmbus");
-	if (vmbus_logtype_bus >= 0)
-		rte_log_set_level(vmbus_logtype_bus, RTE_LOG_NOTICE);
-}
+RTE_LOG_REGISTER(vmbus_logtype_bus, bus.vmbus, NOTICE);
-- 
2.27.0


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

* [dpdk-dev] [PATCH v5 12/13] drivers/baseband: use log register macro
  2020-07-01 12:33       ` [dpdk-dev] [PATCH v5 00/13] rte_log registration usage improvement jerinj
                           ` (10 preceding siblings ...)
  2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 11/13] drivers/bus: " jerinj
@ 2020-07-01 12:33         ` jerinj
  2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 13/13] app/test: " jerinj
  2020-07-03 13:55         ` [dpdk-dev] [PATCH v5 00/13] rte_log registration usage improvement David Marchand
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01 12:33 UTC (permalink / raw)
  To: dev, Nicolas Chautru
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 .../baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 17 +++++------------
 drivers/baseband/fpga_lte_fec/fpga_lte_fec.c   | 18 +++++-------------
 drivers/baseband/null/bbdev_null.c             |  9 +--------
 .../baseband/turbo_sw/bbdev_turbo_software.c   |  9 +--------
 4 files changed, 12 insertions(+), 41 deletions(-)

diff --git a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
index e152b206e..aca0ca999 100644
--- a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
+++ b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
@@ -23,8 +23,11 @@
 #include "fpga_5gnr_fec.h"
 #include "rte_pmd_fpga_5gnr_fec.h"
 
-/* 5GNR SW PMD logging ID */
-static int fpga_5gnr_fec_logtype;
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+RTE_LOG_REGISTER(fpga_5gnr_fec_logtype, pmd.bb.fpga_5gnr_fec, DEBUG);
+#else
+RTE_LOG_REGISTER(fpga_5gnr_fec_logtype, pmd.bb.fpga_5gnr_fec, NOTICE);
+#endif
 
 #ifdef RTE_LIBRTE_BBDEV_DEBUG
 
@@ -2175,13 +2178,3 @@ RTE_PMD_REGISTER_PCI(FPGA_5GNR_FEC_VF_DRIVER_NAME, fpga_5gnr_fec_pci_vf_driver);
 RTE_PMD_REGISTER_PCI_TABLE(FPGA_5GNR_FEC_VF_DRIVER_NAME,
 		pci_id_fpga_5gnr_fec_vf_map);
 
-RTE_INIT(fpga_5gnr_fec_init_log)
-{
-	fpga_5gnr_fec_logtype = rte_log_register("pmd.bb.fpga_5gnr_fec");
-	if (fpga_5gnr_fec_logtype >= 0)
-#ifdef RTE_LIBRTE_BBDEV_DEBUG
-		rte_log_set_level(fpga_5gnr_fec_logtype, RTE_LOG_DEBUG);
-#else
-		rte_log_set_level(fpga_5gnr_fec_logtype, RTE_LOG_NOTICE);
-#endif
-}
diff --git a/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c b/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c
index abc5a1bf6..6be9131e7 100644
--- a/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c
+++ b/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c
@@ -22,8 +22,11 @@
 
 #include "fpga_lte_fec.h"
 
-/* Turbo SW PMD logging ID */
-static int fpga_lte_fec_logtype;
+#ifdef RTE_LIBRTE_BBDEV_DEBUG
+RTE_LOG_REGISTER(fpga_lte_fec_logtype, pmd.bb.fpga_lte_fec, DEBUG);
+#else
+RTE_LOG_REGISTER(fpga_lte_fec_logtype, pmd.bb.fpga_lte_fec, NOTICE);
+#endif
 
 /* Helper macro for logging */
 #define rte_bbdev_log(level, fmt, ...) \
@@ -2662,14 +2665,3 @@ RTE_PMD_REGISTER_PCI_TABLE(FPGA_LTE_FEC_PF_DRIVER_NAME,
 RTE_PMD_REGISTER_PCI(FPGA_LTE_FEC_VF_DRIVER_NAME, fpga_lte_fec_pci_vf_driver);
 RTE_PMD_REGISTER_PCI_TABLE(FPGA_LTE_FEC_VF_DRIVER_NAME,
 		pci_id_fpga_lte_fec_vf_map);
-
-RTE_INIT(fpga_lte_fec_init_log)
-{
-	fpga_lte_fec_logtype = rte_log_register("pmd.bb.fpga_lte_fec");
-	if (fpga_lte_fec_logtype >= 0)
-#ifdef RTE_LIBRTE_BBDEV_DEBUG
-		rte_log_set_level(fpga_lte_fec_logtype, RTE_LOG_DEBUG);
-#else
-		rte_log_set_level(fpga_lte_fec_logtype, RTE_LOG_NOTICE);
-#endif
-}
diff --git a/drivers/baseband/null/bbdev_null.c b/drivers/baseband/null/bbdev_null.c
index 2f2515101..dd11cd31c 100644
--- a/drivers/baseband/null/bbdev_null.c
+++ b/drivers/baseband/null/bbdev_null.c
@@ -15,8 +15,7 @@
 
 #define DRIVER_NAME baseband_null
 
-/* NULL BBDev logging ID */
-static int bbdev_null_logtype;
+RTE_LOG_REGISTER(bbdev_null_logtype, pmd.bb.null, NOTICE);
 
 /* Helper macro for logging */
 #define rte_bbdev_log(level, fmt, ...) \
@@ -348,9 +347,3 @@ RTE_PMD_REGISTER_PARAM_STRING(DRIVER_NAME,
 	BBDEV_NULL_SOCKET_ID_ARG"=<int>");
 RTE_PMD_REGISTER_ALIAS(DRIVER_NAME, bbdev_null);
 
-RTE_INIT(null_bbdev_init_log)
-{
-	bbdev_null_logtype = rte_log_register("pmd.bb.null");
-	if (bbdev_null_logtype >= 0)
-		rte_log_set_level(bbdev_null_logtype, RTE_LOG_NOTICE);
-}
diff --git a/drivers/baseband/turbo_sw/bbdev_turbo_software.c b/drivers/baseband/turbo_sw/bbdev_turbo_software.c
index bb62276b9..daecfd21a 100644
--- a/drivers/baseband/turbo_sw/bbdev_turbo_software.c
+++ b/drivers/baseband/turbo_sw/bbdev_turbo_software.c
@@ -34,8 +34,7 @@
 
 #define DRIVER_NAME baseband_turbo_sw
 
-/* Turbo SW PMD logging ID */
-static int bbdev_turbo_sw_logtype;
+RTE_LOG_REGISTER(bbdev_turbo_sw_logtype, pmd.bb.turbo_sw, NOTICE);
 
 /* Helper macro for logging */
 #define rte_bbdev_log(level, fmt, ...) \
@@ -1991,9 +1990,3 @@ RTE_PMD_REGISTER_PARAM_STRING(DRIVER_NAME,
 	TURBO_SW_SOCKET_ID_ARG"=<int>");
 RTE_PMD_REGISTER_ALIAS(DRIVER_NAME, turbo_sw);
 
-RTE_INIT(turbo_sw_bbdev_init_log)
-{
-	bbdev_turbo_sw_logtype = rte_log_register("pmd.bb.turbo_sw");
-	if (bbdev_turbo_sw_logtype >= 0)
-		rte_log_set_level(bbdev_turbo_sw_logtype, RTE_LOG_NOTICE);
-}
-- 
2.27.0


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

* [dpdk-dev]  [PATCH v5 13/13] app/test: use log register macro
  2020-07-01 12:33       ` [dpdk-dev] [PATCH v5 00/13] rte_log registration usage improvement jerinj
                           ` (11 preceding siblings ...)
  2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 12/13] drivers/baseband: " jerinj
@ 2020-07-01 12:33         ` jerinj
  2020-07-03 13:55         ` [dpdk-dev] [PATCH v5 00/13] rte_log registration usage improvement David Marchand
  13 siblings, 0 replies; 98+ messages in thread
From: jerinj @ 2020-07-01 12:33 UTC (permalink / raw)
  To: dev, Byron Marohn, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Robert Sanford, Erik Gabriel Carrillo
  Cc: thomas, olivier.matz, david.marchand, sachin.saxena,
	adamx.dybkowski, Jerin Jacob

From: Jerin Jacob <jerinj@marvell.com>

Use log register macro to avoid the code duplication
in the log registration process.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
 app/test/test_efd.c            | 6 +-----
 app/test/test_hash.c           | 7 +------
 app/test/test_timer_racecond.c | 7 +------
 3 files changed, 3 insertions(+), 17 deletions(-)

diff --git a/app/test/test_efd.c b/app/test/test_efd.c
index e3e5e30ea..3d9aa8a57 100644
--- a/app/test/test_efd.c
+++ b/app/test/test_efd.c
@@ -32,12 +32,8 @@ struct flow_key {
 	uint8_t proto;
 } __rte_packed;
 
-int efd_logtype_test;
 
-RTE_INIT(test_efd_init_log)
-{
-	efd_logtype_test = rte_log_register("test.efd");
-}
+RTE_LOG_REGISTER(efd_logtype_test, test.efd, INFO);
 
 /*
  * Print out result of unit test efd operation.
diff --git a/app/test/test_hash.c b/app/test/test_hash.c
index afa3a1a3c..990a1815f 100644
--- a/app/test/test_hash.c
+++ b/app/test/test_hash.c
@@ -69,8 +69,6 @@ struct flow_key {
 	uint8_t proto;
 } __rte_packed;
 
-int hash_logtype_test;
-
 /*
  * Hash function that always returns the same value, to easily test what
  * happens when a bucket is full.
@@ -82,10 +80,7 @@ static uint32_t pseudo_hash(__rte_unused const void *keys,
 	return 3;
 }
 
-RTE_INIT(test_hash_init_log)
-{
-	hash_logtype_test = rte_log_register("test.hash");
-}
+RTE_LOG_REGISTER(hash_logtype_test, test.hash, INFO);
 
 /*
  * Print out result of unit test hash operation.
diff --git a/app/test/test_timer_racecond.c b/app/test/test_timer_racecond.c
index 4fc917995..28af9ca76 100644
--- a/app/test/test_timer_racecond.c
+++ b/app/test/test_timer_racecond.c
@@ -61,12 +61,7 @@ static volatile unsigned stop_slaves;
 
 static int reload_timer(struct rte_timer *tim);
 
-int timer_logtype_test;
-
-RTE_INIT(test_timer_init_log)
-{
-	timer_logtype_test = rte_log_register("test.timer");
-}
+RTE_LOG_REGISTER(timer_logtype_test, test.timer, INFO);
 
 static void
 timer_cb(struct rte_timer *tim, void *arg __rte_unused)
-- 
2.27.0


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

* Re: [dpdk-dev] [PATCH v5 08/13] drivers/crypto: use log register macro
  2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 08/13] drivers/crypto: " jerinj
@ 2020-07-02 17:59           ` Akhil Goyal
  0 siblings, 0 replies; 98+ messages in thread
From: Akhil Goyal @ 2020-07-02 17:59 UTC (permalink / raw)
  To: jerinj, dev, Declan Doherty, Pablo de Lara, Gagandeep Singh,
	Hemant Agrawal, Michael Shamis, Liron Himi, Nagadheeraj Rottela,
	Srikanth Jampala, Anoob Joseph, Ankur Dwivedi, Fan Zhang,
	Jay Zhou
  Cc: thomas, olivier.matz, david.marchand, Sachin Saxena (OSS),
	adamx.dybkowski

> From: Jerin Jacob <jerinj@marvell.com>
> 
> Use log register macro to avoid the code duplication
> in the log registration process.
> 
> Signed-off-by: Jerin Jacob <jerinj@marvell.com>
> Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
Acked-by: Akhil Goyal <akhil.goyal@nxp.com>


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

* Re: [dpdk-dev] [PATCH v5 00/13] rte_log registration usage improvement
  2020-07-01 12:33       ` [dpdk-dev] [PATCH v5 00/13] rte_log registration usage improvement jerinj
                           ` (12 preceding siblings ...)
  2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 13/13] app/test: " jerinj
@ 2020-07-03 13:55         ` David Marchand
  2020-07-06  9:31           ` Jerin Jacob
  13 siblings, 1 reply; 98+ messages in thread
From: David Marchand @ 2020-07-03 13:55 UTC (permalink / raw)
  To: Jerin Jacob Kollanukkaran
  Cc: dev, Thomas Monjalon, Olivier Matz, sachin.saxena, adamx.dybkowski

On Wed, Jul 1, 2020 at 2:34 PM <jerinj@marvell.com> wrote:
>
> From: Jerin Jacob <jerinj@marvell.com>
>
> This patch series improves the rte_log registration code snippet by
> avoiding duplication of the code around registration by
> introducing RTE_LOG_REGISTER macro.
>
> Drivers not adapted to new macro
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> I have converted all existing rte_log_register() to new macro, except
> the following (as it has different usage style)
> 1) drivers/common/mlx5/mlx5_common.c
> 2) drivers/net/e1000/e1000_logs.c
> 3) drivers/net/sfc/sfc_ethdev.c
>
> Example usage of new macro
> ~~~~~~~~~~~~~~~~~~~~~~~~~~
> -/**
> - * @internal
> - */
> -int otx2_logtype_base;
> -/**
> - * @internal
> - */
> -int otx2_logtype_mbox;
> -/**
> - * @internal
> - */
> -int otx2_logtype_npa;
> -/**
> - * @internal
> - */
> -int otx2_logtype_nix;
> -/**
> - * @internal
> - */
> -int otx2_logtype_npc;
> -/**
> - * @internal
> - */
> -int otx2_logtype_tm;
> -/**
> - * @internal
> - */
> -int otx2_logtype_sso;
> -/**
> - * @internal
> - */
> -int otx2_logtype_tim;
> -/**
> - * @internal
> - */
> -int otx2_logtype_dpi;
> -/**
> - * @internal
> - */
> -int otx2_logtype_ep;
> -
> -RTE_INIT(otx2_log_init);
> -static void
> -otx2_log_init(void)
> -{
> -       otx2_logtype_base = rte_log_register("pmd.octeontx2.base");
> -       if (otx2_logtype_base >= 0)
> -               rte_log_set_level(otx2_logtype_base, RTE_LOG_NOTICE);
> -
> -       otx2_logtype_mbox = rte_log_register("pmd.octeontx2.mbox");
> -       if (otx2_logtype_mbox >= 0)
> -               rte_log_set_level(otx2_logtype_mbox, RTE_LOG_NOTICE);
> -
> -       otx2_logtype_npa = rte_log_register("pmd.mempool.octeontx2");
> -       if (otx2_logtype_npa >= 0)
> -               rte_log_set_level(otx2_logtype_npa, RTE_LOG_NOTICE);
> -
> -       otx2_logtype_nix = rte_log_register("pmd.net.octeontx2");
> -       if (otx2_logtype_nix >= 0)
> -               rte_log_set_level(otx2_logtype_nix, RTE_LOG_NOTICE);
> -
> -       otx2_logtype_npc = rte_log_register("pmd.net.octeontx2.flow");
> -       if (otx2_logtype_npc >= 0)
> -               rte_log_set_level(otx2_logtype_npc, RTE_LOG_NOTICE);
> -
> -       otx2_logtype_tm = rte_log_register("pmd.net.octeontx2.tm");
> -       if (otx2_logtype_tm >= 0)
> -               rte_log_set_level(otx2_logtype_tm, RTE_LOG_NOTICE);
> -
> -       otx2_logtype_sso = rte_log_register("pmd.event.octeontx2");
> -       if (otx2_logtype_sso >= 0)
> -               rte_log_set_level(otx2_logtype_sso, RTE_LOG_NOTICE);
> -
> -       otx2_logtype_tim =
>         rte_log_register("pmd.event.octeontx2.timer");
> -       if (otx2_logtype_tim >= 0)
> -               rte_log_set_level(otx2_logtype_tim, RTE_LOG_NOTICE);
> -
> -       otx2_logtype_dpi = rte_log_register("pmd.raw.octeontx2.dpi");
> -       if (otx2_logtype_dpi >= 0)
> -               rte_log_set_level(otx2_logtype_dpi, RTE_LOG_NOTICE);
> -
> -       otx2_logtype_ep = rte_log_register("pmd.raw.octeontx2.ep");
> -       if (otx2_logtype_ep >= 0)
> -               rte_log_set_level(otx2_logtype_ep, RTE_LOG_NOTICE);
> -
> -}
> +RTE_LOG_REGISTER(otx2_logtype_base, pmd.octeontx2.base, NOTICE);
> +RTE_LOG_REGISTER(otx2_logtype_mbox, pmd.octeontx2.mbox, NOTICE);
> +RTE_LOG_REGISTER(otx2_logtype_npa, pmd.mempool.octeontx2, NOTICE);
> +RTE_LOG_REGISTER(otx2_logtype_nix, pmd.net.octeontx2, NOTICE);
> +RTE_LOG_REGISTER(otx2_logtype_npc, pmd.net.octeontx2.flow, NOTICE);
> +RTE_LOG_REGISTER(otx2_logtype_tm, pmd.net.octeontx2.tm, NOTICE);
> +RTE_LOG_REGISTER(otx2_logtype_sso, pmd.event.octeontx2, NOTICE);
> +RTE_LOG_REGISTER(otx2_logtype_tim, pmd.event.octeontx2.timer, NOTICE);
> +RTE_LOG_REGISTER(otx2_logtype_dpi, pmd.raw.octeontx2.dpi, NOTICE);
> +RTE_LOG_REGISTER(otx2_logtype_ep, pmd.raw.octeontx2.ep, NOTICE);

Squashed as a single commit since the conversion patches do not give
more insight than the first change.
Removed unnecessary some double empty lines or at the end of files.
And applied.

Note: I spotted some left behind logtype declarations for
mlx5_vdpa_logtype, rte_graph_logtype, librawdev_logtype and
stack_logtype.
Could you send a followup patch if there are unneeded?

Thanks for the cleanup.


-- 
David Marchand


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

* Re: [dpdk-dev] [PATCH v5 00/13] rte_log registration usage improvement
  2020-07-03 13:55         ` [dpdk-dev] [PATCH v5 00/13] rte_log registration usage improvement David Marchand
@ 2020-07-06  9:31           ` Jerin Jacob
  0 siblings, 0 replies; 98+ messages in thread
From: Jerin Jacob @ 2020-07-06  9:31 UTC (permalink / raw)
  To: David Marchand
  Cc: Jerin Jacob Kollanukkaran, dev, Thomas Monjalon, Olivier Matz,
	sachin.saxena, Dybkowski, AdamX

On Fri, Jul 3, 2020 at 7:26 PM David Marchand <david.marchand@redhat.com> wrote:
>
> On Wed, Jul 1, 2020 at 2:34 PM <jerinj@marvell.com> wrote:
> >
> > From: Jerin Jacob <jerinj@marvell.com>
> >
> > This patch series improves the rte_log registration code snippet by
> > avoiding duplication of the code around registration by
> > introducing RTE_LOG_REGISTER macro.
> >

>
> Squashed as a single commit since the conversion patches do not give
> more insight than the first change.
> Removed unnecessary some double empty lines or at the end of files.
> And applied.
>
> Note: I spotted some left behind logtype declarations for
> mlx5_vdpa_logtype, rte_graph_logtype, librawdev_logtype and
> stack_logtype.
> Could you send a followup patch if there are unneeded?

Yes. I will send it. Thanks for check.

>
> Thanks for the cleanup.
>
>
> --
> David Marchand
>

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

end of thread, other threads:[~2020-07-06  9:31 UTC | newest]

Thread overview: 98+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-17  6:30 [dpdk-dev] [PATCH 00/13] rte_log registration usage improvement jerinj
2020-06-17  6:30 ` [dpdk-dev] [PATCH 01/13] eal/log: introduce log register macro jerinj
2020-06-17 10:00   ` Thomas Monjalon
2020-06-17 10:26     ` Andrew Rybchenko
2020-06-24 13:08       ` Jerin Jacob
2020-06-17 10:02   ` David Marchand
2020-06-17 10:21     ` Andrew Rybchenko
2020-06-24 13:11       ` Jerin Jacob
2020-06-24 15:26         ` Andrew Rybchenko
2020-06-24 15:32           ` Jerin Jacob
2020-06-24 15:43             ` Andrew Rybchenko
2020-06-24 18:10               ` Jerin Jacob
2020-06-26 11:16                 ` Jerin Jacob
2020-06-26 11:42                   ` David Marchand
2020-06-26 12:06                     ` Jerin Jacob
2020-06-26 12:13                       ` David Marchand
2020-06-26 12:16                       ` David Marchand
2020-06-26 12:37                         ` Jerin Jacob
2020-06-29 13:39                           ` Jerin Jacob
2020-06-30 13:39                           ` David Marchand
2020-06-30 14:42                             ` Jerin Jacob
2020-06-21  9:30   ` Sachin Saxena (OSS)
2020-06-17  6:30 ` [dpdk-dev] [PATCH 02/13] lib: use " jerinj
2020-06-17  6:30 ` [dpdk-dev] [PATCH 03/13] drivers/vdpa: " jerinj
2020-06-17  6:30 ` [dpdk-dev] [PATCH 04/13] drivers/raw: " jerinj
2020-06-17  6:30 ` [dpdk-dev] [PATCH 05/13] drivers/net: " jerinj
2020-06-17  6:30 ` [dpdk-dev] [PATCH 06/13] drivers/mempool: " jerinj
2020-06-21  9:46   ` Sachin Saxena (OSS)
2020-06-17  6:30 ` [dpdk-dev] [PATCH 07/13] drivers/event: " jerinj
2020-06-17  6:30 ` [dpdk-dev] [PATCH 08/13] drivers/crypto: " jerinj
2020-06-17  6:30 ` [dpdk-dev] [PATCH 09/13] drivers/compress: " jerinj
2020-06-17  6:30 ` [dpdk-dev] [PATCH 10/13] drivers/common: " jerinj
2020-06-21  9:48   ` Sachin Saxena (OSS)
2020-06-17  6:30 ` [dpdk-dev] [PATCH 11/13] drivers/bus: " jerinj
2020-06-21  9:52   ` Sachin Saxena (OSS)
2020-06-17  6:30 ` [dpdk-dev] [PATCH 12/13] drivers/baseband: " jerinj
2020-06-17  6:30 ` [dpdk-dev] [PATCH 13/13] app/test: " jerinj
2020-06-25 16:18 ` [dpdk-dev] [PATCH 00/13] rte_log registration usage improvement Dybkowski, AdamX
2020-06-25 16:20   ` Dybkowski, AdamX
2020-07-01  3:58 ` [dpdk-dev] [PATCH v2 " jerinj
2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 01/13] eal/log: introduce log register macro jerinj
2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 02/13] lib: use " jerinj
2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 03/13] drivers/vdpa: " jerinj
2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 04/13] drivers/raw: " jerinj
2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 05/13] drivers/net: " jerinj
2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 06/13] drivers/mempool: " jerinj
2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 07/13] drivers/event: " jerinj
2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 08/13] drivers/crypto: " jerinj
2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 09/13] drivers/compress: " jerinj
2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 10/13] drivers/common: " jerinj
2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 11/13] drivers/bus: " jerinj
2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 12/13] drivers/baseband: " jerinj
2020-07-01  3:58   ` [dpdk-dev] [PATCH v2 13/13] app/test: " jerinj
2020-07-01  6:48   ` [dpdk-dev] [PATCH v3 00/13] rte_log registration usage improvement jerinj
2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 01/13] eal/log: introduce log register macro jerinj
2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 02/13] lib: use " jerinj
2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 03/13] drivers/vdpa: " jerinj
2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 04/13] drivers/raw: " jerinj
2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 05/13] drivers/net: " jerinj
2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 06/13] drivers/mempool: " jerinj
2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 07/13] drivers/event: " jerinj
2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 08/13] drivers/crypto: " jerinj
2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 09/13] drivers/compress: " jerinj
2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 10/13] drivers/common: " jerinj
2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 11/13] drivers/bus: " jerinj
2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 12/13] drivers/baseband: " jerinj
2020-07-01  6:48     ` [dpdk-dev] [PATCH v3 13/13] app/test: " jerinj
2020-07-01 10:44     ` [dpdk-dev] [PATCH v4 00/13] rte_log registration usage improvement jerinj
2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 01/13] eal/log: introduce log register macro jerinj
2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 02/13] lib: use " jerinj
2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 03/13] drivers/vdpa: " jerinj
2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 04/13] drivers/raw: " jerinj
2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 05/13] drivers/net: " jerinj
2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 06/13] drivers/mempool: " jerinj
2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 07/13] drivers/event: " jerinj
2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 08/13] drivers/crypto: " jerinj
2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 09/13] drivers/compress: " jerinj
2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 10/13] drivers/common: " jerinj
2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 11/13] drivers/bus: " jerinj
2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 12/13] drivers/baseband: " jerinj
2020-07-01 10:44       ` [dpdk-dev] [PATCH v4 13/13] app/test: " jerinj
2020-07-01 12:33       ` [dpdk-dev] [PATCH v5 00/13] rte_log registration usage improvement jerinj
2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 01/13] eal/log: introduce log register macro jerinj
2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 02/13] lib: use " jerinj
2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 03/13] drivers/vdpa: " jerinj
2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 04/13] drivers/raw: " jerinj
2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 05/13] drivers/net: " jerinj
2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 06/13] drivers/mempool: " jerinj
2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 07/13] drivers/event: " jerinj
2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 08/13] drivers/crypto: " jerinj
2020-07-02 17:59           ` Akhil Goyal
2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 09/13] drivers/compress: " jerinj
2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 10/13] drivers/common: " jerinj
2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 11/13] drivers/bus: " jerinj
2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 12/13] drivers/baseband: " jerinj
2020-07-01 12:33         ` [dpdk-dev] [PATCH v5 13/13] app/test: " jerinj
2020-07-03 13:55         ` [dpdk-dev] [PATCH v5 00/13] rte_log registration usage improvement David Marchand
2020-07-06  9:31           ` Jerin Jacob

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).