From patchwork Mon Oct 28 09:09:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavan Nikhilesh Bhagavatula X-Patchwork-Id: 62100 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 65D541BF49; Mon, 28 Oct 2019 10:09:24 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 6A9DD1BF49 for ; Mon, 28 Oct 2019 10:09:23 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x9S95Ym8010250; Mon, 28 Oct 2019 02:09:22 -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=+9VCD4pxG69WWo/MUIsNK71jqhfUwQkey/GOCkplmhA=; b=lGUgj8XrXX7CE/XZ/33GdkVMRhn0yDVi76vd+5CvI1Ih6r8w0zjzK/BTB2ykxViH3Dfa H3h2b/0EBcFRoyZEDWij9EJu3l+f5EQqtLzKrycgkkolLGHSSewAnzRsoG6H6SxF+RiB /zl+yrDFX3GWE1BBuDGXi/ZE4JiGf9Uf2u/6q08nBrWJ7f4bwogyw3Y4VxjZrYVnVt2D 857T4SGxL2/Aa595mU4ri6vFOerm5E+nNcmnC6HrS1BC7GV68EpjQs4EcQh4R7iyV2jL kd/HLvRuz2iEbP1OMDwTS59rqjgXiWLigD//ym2WIkcajLbaP6X3OZSKYXPV6ok8Wo+r fw== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0a-0016f401.pphosted.com with ESMTP id 2vvkgq5cf4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 28 Oct 2019 02:09:22 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 28 Oct 2019 02:09:21 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 28 Oct 2019 02:09:21 -0700 Received: from BG-LT7430.marvell.com (unknown [10.28.17.14]) by maili.marvell.com (Postfix) with ESMTP id D9FA03F703F; Mon, 28 Oct 2019 02:09:18 -0700 (PDT) From: To: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Konstantin Ananyev , Cristian Dumitrescu CC: , Pavan Nikhilesh Date: Mon, 28 Oct 2019 14:39:06 +0530 Message-ID: <20191028090907.824-3-pbhagavatula@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191028090907.824-1-pbhagavatula@marvell.com> References: <20191028090907.824-1-pbhagavatula@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-10-28_04:2019-10-25,2019-10-28 signatures=0 Subject: [dpdk-dev] [PATCH 3/3] lib: use RTE_DIM to calculate array size 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: Pavan Nikhilesh use RTE_DIM to calculate array size. Suggested-by: David Marchand Signed-off-by: Pavan Nikhilesh --- lib/librte_ethdev/rte_ethdev.c | 8 +++----- lib/librte_ip_frag/ip_frag_internal.c | 5 ++--- lib/librte_port/rte_port_eventdev.c | 4 ++-- lib/librte_port/rte_port_eventdev.h | 4 ---- 4 files changed, 7 insertions(+), 14 deletions(-) -- 2.23.0 diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 7743205d3..721ee694b 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -86,7 +86,7 @@ static const struct rte_eth_xstats_name_off rte_stats_strings[] = { rx_nombuf)}, }; -#define RTE_NB_STATS (sizeof(rte_stats_strings) / sizeof(rte_stats_strings[0])) +#define RTE_NB_STATS RTE_DIM(rte_stats_strings) static const struct rte_eth_xstats_name_off rte_rxq_stats_strings[] = { {"packets", offsetof(struct rte_eth_stats, q_ipackets)}, @@ -94,15 +94,13 @@ static const struct rte_eth_xstats_name_off rte_rxq_stats_strings[] = { {"errors", offsetof(struct rte_eth_stats, q_errors)}, }; -#define RTE_NB_RXQ_STATS (sizeof(rte_rxq_stats_strings) / \ - sizeof(rte_rxq_stats_strings[0])) +#define RTE_NB_RXQ_STATS RTE_DIM(rte_rxq_stats_strings) static const struct rte_eth_xstats_name_off rte_txq_stats_strings[] = { {"packets", offsetof(struct rte_eth_stats, q_opackets)}, {"bytes", offsetof(struct rte_eth_stats, q_obytes)}, }; -#define RTE_NB_TXQ_STATS (sizeof(rte_txq_stats_strings) / \ - sizeof(rte_txq_stats_strings[0])) +#define RTE_NB_TXQ_STATS RTE_DIM(rte_txq_stats_strings) #define RTE_RX_OFFLOAD_BIT2STR(_name) \ { DEV_RX_OFFLOAD_##_name, #_name } diff --git a/lib/librte_ip_frag/ip_frag_internal.c b/lib/librte_ip_frag/ip_frag_internal.c index 97470a872..b436a4c93 100644 --- a/lib/librte_ip_frag/ip_frag_internal.c +++ b/lib/librte_ip_frag/ip_frag_internal.c @@ -107,8 +107,7 @@ ip_frag_process(struct ip_frag_pkt *fp, struct rte_ip_frag_death_row *dr, IP_LAST_FRAG_IDX : UINT32_MAX; /* this is the intermediate fragment. */ - } else if ((idx = fp->last_idx) < - sizeof (fp->frags) / sizeof (fp->frags[0])) { + } else if ((idx = fp->last_idx) < RTE_DIM(fp->frags)) { fp->last_idx++; } @@ -116,7 +115,7 @@ ip_frag_process(struct ip_frag_pkt *fp, struct rte_ip_frag_death_row *dr, * erroneous packet: either exceed max allowed number of fragments, * or duplicate first/last fragment encountered. */ - if (idx >= sizeof (fp->frags) / sizeof (fp->frags[0])) { + if (idx >= RTE_DIM(fp->frags)) { /* report an error. */ if (fp->key.key_len == IPV4_KEYLEN) diff --git a/lib/librte_port/rte_port_eventdev.c b/lib/librte_port/rte_port_eventdev.c index aa93bd3a2..fd7dac9a5 100644 --- a/lib/librte_port/rte_port_eventdev.c +++ b/lib/librte_port/rte_port_eventdev.c @@ -179,7 +179,7 @@ rte_port_eventdev_writer_create(void *params, int socket_id) port->evt_op = conf->evt_op; memset(&port->ev, 0, sizeof(port->ev)); - for (i = 0; i < ARRAY_SIZE(port->ev); i++) { + for (i = 0; i < RTE_DIM(port->ev); i++) { port->ev[i].queue_id = port->queue_id; port->ev[i].sched_type = port->sched_type; port->ev[i].op = port->evt_op; @@ -386,7 +386,7 @@ rte_port_eventdev_writer_nodrop_create(void *params, int socket_id) port->evt_op = conf->evt_op; memset(&port->ev, 0, sizeof(port->ev)); - for (i = 0; i < ARRAY_SIZE(port->ev); i++) { + for (i = 0; i < RTE_DIM(port->ev); i++) { port->ev[i].queue_id = port->queue_id; port->ev[i].sched_type = port->sched_type; port->ev[i].op = port->evt_op; diff --git a/lib/librte_port/rte_port_eventdev.h b/lib/librte_port/rte_port_eventdev.h index acf88f4e9..966e9cdaf 100644 --- a/lib/librte_port/rte_port_eventdev.h +++ b/lib/librte_port/rte_port_eventdev.h @@ -9,10 +9,6 @@ extern "C" { #endif -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -#endif - /** * @file * RTE Port Eventdev Interface