From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9806BA04A5; Wed, 17 Jun 2020 08:30:37 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DF7A31B75C; Wed, 17 Jun 2020 08:30:32 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id DC6265B3A for ; Wed, 17 Jun 2020 08:30:31 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 05H6Pnxg010482; Tue, 16 Jun 2020 23:30:29 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0818; bh=kT1IUReVUt41FH2rSd/pUJ3oYCtDPtaN6XzZPeZVTb8=; b=VPR9xgc0VCdi1PPPtzfX2GOflG4Q2Vt6PcN3bfZmoliOnM8v2lUJ8yhZYxQbDpOu9FXh yoRFLo8ESYW/XBetR2SBzad2TUir+pGPMRVfCGuVySkQGExsBcNAha5OC6zaaoKyRDOb Y2vEgeZeaqHPjG56vncxPG0fSufdu+J/kh9f+zaK4/RMnXHGnUdhTmpsURv1bXQmkVmE /0vsun3apPuJjfdQjYAvZZhLnhVgY2j84Y2ATkQ81/jOKoDQe+LR+fKqaxjhe26bKB/V fCgCBnI6dgDLPF4GwvLVBz4rc1/YqBXHjyfM9myB0G0SWGc6jSh03uVHQwd0+vujBjKi Ug== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0b-0016f401.pphosted.com with ESMTP id 31q658jmrq-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 16 Jun 2020 23:30:28 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 16 Jun 2020 23:30:27 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 16 Jun 2020 23:30:27 -0700 Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id C7D883F7043; Tue, 16 Jun 2020 23:30:19 -0700 (PDT) From: To: , 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: Date: Wed, 17 Jun 2020 12:00:36 +0530 Message-ID: <20200617063047.1555518-3-jerinj@marvell.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200617063047.1555518-1-jerinj@marvell.com> References: <20200617063047.1555518-1-jerinj@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.687 definitions=2020-06-16_13:2020-06-16, 2020-06-16 signatures=0 Subject: [dpdk-dev] [PATCH 02/13] lib: use log register macro X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Jerin Jacob Use log register macro to avoid the code duplication in the log registration process. Signed-off-by: Jerin Jacob --- 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 #include -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