From patchwork Mon Oct 28 09:09:05 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: 62099 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 E752B1BF42; Mon, 28 Oct 2019 10:09:21 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 419141BF33 for ; Mon, 28 Oct 2019 10:09:20 +0100 (CET) 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 x9S95qGI001845; Mon, 28 Oct 2019 02:09:19 -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=xmzDAzARDdX25puAsWRTnJgmcUXyUv8IOZ1iADQiwJY=; b=D0RGnhKBLEfb42ZyawuHBvWhHhiviFmBdMg55n9mhzf/42WHYY7+skM64tgCNblj7/dT pmTdDluuJN0O4NNcnSs5mUVr1AKgBYn9Werqw6EL1Lw4486WUJY0hHDyUstaghSoBqmq RdmdtCcCx7wX8k8//eX6h8YsAqqd8+E3ecbnr3vGB91to127ted1mIiO2s6yZxgmzt9q EkY5DybI/icsghD4qgdRoqJcJiQPeb5o4tg1oNGG3e1srk2OheG+BNrU6Nobv6RoZRnz wKAkHSdUFHpGDNJIEsO4MeJXw8P6OH8vBy4IZnwFrEyDpbLnjgK0KuIXwigiLK+5y82o 1A== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0b-0016f401.pphosted.com with ESMTP id 2vvnnnvv05-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 28 Oct 2019 02:09:19 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 28 Oct 2019 02:09:18 -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:18 -0700 Received: from BG-LT7430.marvell.com (unknown [10.28.17.14]) by maili.marvell.com (Postfix) with ESMTP id DA8973F7040; Mon, 28 Oct 2019 02:09:13 -0700 (PDT) From: To: Cristian Dumitrescu , Marko Kovacevic , Ori Kam , Bruce Richardson , Radu Nicolau , "Akhil Goyal" , Tomasz Kantecki , David Hunt , John McNamara , Harry van Haaren , Xiaoyun Li CC: , Pavan Nikhilesh Date: Mon, 28 Oct 2019 14:39:05 +0530 Message-ID: <20191028090907.824-2-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 2/3] examples: 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 macro to calculate array size. Suggested-by: David Marchand Signed-off-by: Pavan Nikhilesh --- examples/ip_pipeline/parser.c | 2 +- examples/ipv4_multicast/main.c | 3 +-- examples/l3fwd-power/main.c | 12 ++++-------- examples/l3fwd/l3fwd_em.c | 6 ++---- examples/l3fwd/l3fwd_lpm.c | 6 ++---- examples/vmdq/main.c | 2 +- examples/vmdq_dcb/main.c | 2 +- 7 files changed, 12 insertions(+), 21 deletions(-) -- 2.23.0 diff --git a/examples/ip_pipeline/parser.c b/examples/ip_pipeline/parser.c index 3fffeb586..fb0769fe3 100644 --- a/examples/ip_pipeline/parser.c +++ b/examples/ip_pipeline/parser.c @@ -528,7 +528,7 @@ my_ether_aton(const char *a) if (errno != 0 || end == a || (end[0] != ':' && end[0] != 0)) return NULL; a = end + 1; - } while (++i != sizeof(o) / sizeof(o[0]) && end[0] != 0); + } while (++i != RTE_DIM(o) && end[0] != 0); /* Junk at the end of line */ if (end[0] != 0) diff --git a/examples/ipv4_multicast/main.c b/examples/ipv4_multicast/main.c index 63333b5b6..cd2851c1c 100644 --- a/examples/ipv4_multicast/main.c +++ b/examples/ipv4_multicast/main.c @@ -155,8 +155,7 @@ static struct mcast_group_params mcast_group_table[] = { {RTE_IPV4(224,0,0,115), 0xF}, }; -#define N_MCAST_GROUPS \ - (sizeof (mcast_group_table) / sizeof (mcast_group_table[0])) +#define N_MCAST_GROUPS RTE_DIM(mcast_group_table) /* Send burst of packets on an output interface */ diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c index d049d8a5d..2a56bfa8c 100644 --- a/examples/l3fwd-power/main.c +++ b/examples/l3fwd-power/main.c @@ -238,8 +238,7 @@ static struct lcore_params lcore_params_array_default[] = { }; struct lcore_params *lcore_params = lcore_params_array_default; -uint16_t nb_lcore_params = sizeof(lcore_params_array_default) / - sizeof(lcore_params_array_default[0]); +uint16_t nb_lcore_params = RTE_DIM(lcore_params_array_default); static struct rte_eth_conf port_conf = { .rxmode = { @@ -326,11 +325,9 @@ static lookup_struct_t *ipv6_l3fwd_lookup_struct[NB_SOCKETS]; #define L3FWD_HASH_ENTRIES 1024 -#define IPV4_L3FWD_NUM_ROUTES \ - (sizeof(ipv4_l3fwd_route_array) / sizeof(ipv4_l3fwd_route_array[0])) +#define IPV4_L3FWD_NUM_ROUTES RTE_DIM(ipv4_l3fwd_route_array) -#define IPV6_L3FWD_NUM_ROUTES \ - (sizeof(ipv6_l3fwd_route_array) / sizeof(ipv6_l3fwd_route_array[0])) +#define IPV6_L3FWD_NUM_ROUTES RTE_DIM(ipv6_l3fwd_route_array) static uint16_t ipv4_l3fwd_out_if[L3FWD_HASH_ENTRIES] __rte_cache_aligned; static uint16_t ipv6_l3fwd_out_if[L3FWD_HASH_ENTRIES] __rte_cache_aligned; @@ -354,8 +351,7 @@ static struct ipv4_l3fwd_route ipv4_l3fwd_route_array[] = { {RTE_IPV4(8,1,1,0), 24, 7}, }; -#define IPV4_L3FWD_NUM_ROUTES \ - (sizeof(ipv4_l3fwd_route_array) / sizeof(ipv4_l3fwd_route_array[0])) +#define IPV4_L3FWD_NUM_ROUTES RTE_DIM(ipv4_l3fwd_route_array) #define IPV4_L3FWD_LPM_MAX_RULES 1024 diff --git a/examples/l3fwd/l3fwd_em.c b/examples/l3fwd/l3fwd_em.c index 74a7c8fa4..1b1cce47d 100644 --- a/examples/l3fwd/l3fwd_em.c +++ b/examples/l3fwd/l3fwd_em.c @@ -203,11 +203,9 @@ ipv6_hash_crc(const void *data, __rte_unused uint32_t data_len, return init_val; } -#define IPV4_L3FWD_EM_NUM_ROUTES \ - (sizeof(ipv4_l3fwd_em_route_array) / sizeof(ipv4_l3fwd_em_route_array[0])) +#define IPV4_L3FWD_EM_NUM_ROUTES RTE_DIM(ipv4_l3fwd_em_route_array) -#define IPV6_L3FWD_EM_NUM_ROUTES \ - (sizeof(ipv6_l3fwd_em_route_array) / sizeof(ipv6_l3fwd_em_route_array[0])) +#define IPV6_L3FWD_EM_NUM_ROUTES RTE_DIM(ipv6_l3fwd_em_route_array) static uint8_t ipv4_l3fwd_out_if[L3FWD_HASH_ENTRIES] __rte_cache_aligned; static uint8_t ipv6_l3fwd_out_if[L3FWD_HASH_ENTRIES] __rte_cache_aligned; diff --git a/examples/l3fwd/l3fwd_lpm.c b/examples/l3fwd/l3fwd_lpm.c index a3a65f7fc..848b8135b 100644 --- a/examples/l3fwd/l3fwd_lpm.c +++ b/examples/l3fwd/l3fwd_lpm.c @@ -65,10 +65,8 @@ static struct ipv6_l3fwd_lpm_route ipv6_l3fwd_lpm_route_array[] = { {{32, 1, 2, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0}, 48, 7}, }; -#define IPV4_L3FWD_LPM_NUM_ROUTES \ - (sizeof(ipv4_l3fwd_lpm_route_array) / sizeof(ipv4_l3fwd_lpm_route_array[0])) -#define IPV6_L3FWD_LPM_NUM_ROUTES \ - (sizeof(ipv6_l3fwd_lpm_route_array) / sizeof(ipv6_l3fwd_lpm_route_array[0])) +#define IPV4_L3FWD_LPM_NUM_ROUTES RTE_DIM(ipv4_l3fwd_lpm_route_array) +#define IPV6_L3FWD_LPM_NUM_ROUTES RTE_DIM(ipv6_l3fwd_lpm_route_array) #define IPV4_L3FWD_LPM_MAX_RULES 1024 #define IPV4_L3FWD_LPM_NUMBER_TBL8S (1 << 8) diff --git a/examples/vmdq/main.c b/examples/vmdq/main.c index 6e6fc91ec..011110920 100644 --- a/examples/vmdq/main.c +++ b/examples/vmdq/main.c @@ -503,7 +503,7 @@ lcore_main(__attribute__((__unused__)) void *dummy) for (;;) { struct rte_mbuf *buf[MAX_PKT_BURST]; - const uint16_t buf_size = sizeof(buf) / sizeof(buf[0]); + const uint16_t buf_size = RTE_DIM(buf); for (p = 0; p < num_ports; p++) { const uint8_t sport = ports[p]; diff --git a/examples/vmdq_dcb/main.c b/examples/vmdq_dcb/main.c index 594c4f195..f417b2fd9 100644 --- a/examples/vmdq_dcb/main.c +++ b/examples/vmdq_dcb/main.c @@ -582,7 +582,7 @@ lcore_main(void *arg) for (;;) { struct rte_mbuf *buf[MAX_PKT_BURST]; - const uint16_t buf_size = sizeof(buf) / sizeof(buf[0]); + const uint16_t buf_size = RTE_DIM(buf); for (p = 0; p < num_ports; p++) { const uint8_t src = ports[p]; const uint8_t dst = ports[p ^ 1]; /* 0 <-> 1, 2 <-> 3 etc */