DPDK patches and discussions
 help / color / mirror / Atom feed
From: <pbhagavatula@marvell.com>
To: Cristian Dumitrescu <cristian.dumitrescu@intel.com>,
	Marko Kovacevic <marko.kovacevic@intel.com>,
	Ori Kam <orika@mellanox.com>,
	Bruce Richardson <bruce.richardson@intel.com>,
	Radu Nicolau <radu.nicolau@intel.com>,
	"Akhil Goyal" <akhil.goyal@nxp.com>,
	Tomasz Kantecki <tomasz.kantecki@intel.com>,
	David Hunt <david.hunt@intel.com>,
	John McNamara <john.mcnamara@intel.com>,
	Harry van Haaren <harry.van.haaren@intel.com>,
	Xiaoyun Li <xiaoyun.li@intel.com>
Cc: <dev@dpdk.org>, Pavan Nikhilesh <pbhagavatula@marvell.com>
Subject: [dpdk-dev] [PATCH 2/3] examples: use RTE_DIM to calculate array size
Date: Mon, 28 Oct 2019 14:39:05 +0530	[thread overview]
Message-ID: <20191028090907.824-2-pbhagavatula@marvell.com> (raw)
In-Reply-To: <20191028090907.824-1-pbhagavatula@marvell.com>

From: Pavan Nikhilesh <pbhagavatula@marvell.com>

use RTE_DIM macro to calculate array size.

Suggested-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
 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(-)

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 */
--
2.23.0


  reply	other threads:[~2019-10-28  9:09 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-28  9:09 [dpdk-dev] [PATCH 1/3] app: " pbhagavatula
2019-10-28  9:09 ` pbhagavatula [this message]
2019-10-28  9:09 ` [dpdk-dev] [PATCH 3/3] lib: " pbhagavatula
2019-10-31  9:20 ` [dpdk-dev] [PATCH 1/3] app: " David Marchand
2019-11-07  2:12   ` [dpdk-dev] [EXT] " Pavan Nikhilesh Bhagavatula
2019-11-07  2:58 ` [dpdk-dev] [PATCH v2 " pbhagavatula
2019-11-07  2:58   ` [dpdk-dev] [PATCH v2 2/3] examples: " pbhagavatula
2019-11-07  2:58   ` [dpdk-dev] [PATCH v2 3/3] lib: " pbhagavatula
2019-11-07  9:08     ` Dumitrescu, Cristian
2019-12-10 13:10   ` [dpdk-dev] [PATCH v2 1/3] app: " David Marchand
2020-01-24  4:55   ` [dpdk-dev] [PATCH v3 " pbhagavatula
2020-01-24  4:55     ` [dpdk-dev] [PATCH v3 2/3] examples: " pbhagavatula
2020-01-24  4:55     ` [dpdk-dev] [PATCH v3 3/3] lib: " pbhagavatula
2020-01-24 10:37       ` Laatz, Kevin
2020-02-05 10:22     ` [dpdk-dev] [PATCH v3 1/3] app: " David Marchand
2020-02-05 13:40       ` David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191028090907.824-2-pbhagavatula@marvell.com \
    --to=pbhagavatula@marvell.com \
    --cc=akhil.goyal@nxp.com \
    --cc=bruce.richardson@intel.com \
    --cc=cristian.dumitrescu@intel.com \
    --cc=david.hunt@intel.com \
    --cc=dev@dpdk.org \
    --cc=harry.van.haaren@intel.com \
    --cc=john.mcnamara@intel.com \
    --cc=marko.kovacevic@intel.com \
    --cc=orika@mellanox.com \
    --cc=radu.nicolau@intel.com \
    --cc=tomasz.kantecki@intel.com \
    --cc=xiaoyun.li@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).