[v3,02/13] lib: use log register macro
diff mbox series

Message ID 20200701064828.4097247-3-jerinj@marvell.com
State Superseded
Delegated to: Thomas Monjalon
Headers show
Series
  • rte_log registration usage improvement
Related show

Checks

Context Check Description
ci/Intel-compilation fail apply issues
ci/checkpatch success coding style OK

Commit Message

Jerin Jacob Kollanukkaran July 1, 2020, 6:48 a.m. UTC
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(-)

Patch
diff mbox series

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