DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	Wisam Jaddo <wisamm@nvidia.com>,
	Thomas Monjalon <thomas@monjalon.net>,
	Ferruh Yigit <ferruh.yigit@amd.com>,
	Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,
	Akhil Goyal <gakhil@marvell.com>,
	Anoob Joseph <anoobj@marvell.com>
Subject: [PATCH 2/5] app: use RTE_DIM
Date: Tue, 16 Apr 2024 08:19:28 -0700	[thread overview]
Message-ID: <20240416152124.69590-3-stephen@networkplumber.org> (raw)
In-Reply-To: <20240416152124.69590-1-stephen@networkplumber.org>

Use RTE_DIM instead of computing directly with sizeof.
Patch automatically generated via cocci/rte_dim.cocci.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test-flow-perf/main.c              |  4 +--
 app/test/test_ethdev_link.c            |  3 +-
 app/test/test_security_inline_macsec.c | 47 +++++++++++++-------------
 3 files changed, 25 insertions(+), 29 deletions(-)

diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c
index e224ef6798..e9ef1ae04c 100644
--- a/app/test-flow-perf/main.c
+++ b/app/test-flow-perf/main.c
@@ -965,9 +965,7 @@ args_parse(int argc, char **argv)
 						"meter-profile") == 0) {
 				i = 0;
 				token = strsep(&optarg, ",\0");
-				while (token != NULL && i < sizeof(
-						meter_profile_values) /
-						sizeof(uint64_t)) {
+				while (token != NULL && i < RTE_DIM(meter_profile_values)) {
 					meter_profile_values[i++] = atol(token);
 					token = strsep(&optarg, ",\0");
 				}
diff --git a/app/test/test_ethdev_link.c b/app/test/test_ethdev_link.c
index f063a5fe26..e305df71be 100644
--- a/app/test/test_ethdev_link.c
+++ b/app/test/test_ethdev_link.c
@@ -135,8 +135,7 @@ test_link_speed_all_values(void)
 		{ "Invalid",   50505 }
 	};
 
-	for (i = 0; i < sizeof(speed_str_map) / sizeof(struct link_speed_t);
-			i++) {
+	for (i = 0; i < RTE_DIM(speed_str_map); i++) {
 		speed = rte_eth_link_speed_to_str(speed_str_map[i].link_speed);
 		TEST_ASSERT_BUFFERS_ARE_EQUAL(speed_str_map[i].value,
 			speed, strlen(speed_str_map[i].value),
diff --git a/app/test/test_security_inline_macsec.c b/app/test/test_security_inline_macsec.c
index f11e9da8c3..26f7504dc2 100644
--- a/app/test/test_security_inline_macsec.c
+++ b/app/test/test_security_inline_macsec.c
@@ -1294,7 +1294,7 @@ test_inline_macsec_encap_all(void)
 	opts.sectag_insert_mode = 1;
 	opts.mtu = RTE_ETHER_MTU;
 
-	size = (sizeof(list_mcs_cipher_vectors) / sizeof((list_mcs_cipher_vectors)[0]));
+	size = RTE_DIM(list_mcs_cipher_vectors);
 	for (i = 0; i < size; i++) {
 		cur_td = &list_mcs_cipher_vectors[i];
 		err = test_macsec(&cur_td, MCS_ENCAP, &opts);
@@ -1332,7 +1332,7 @@ test_inline_macsec_decap_all(void)
 	opts.sectag_insert_mode = 1;
 	opts.mtu = RTE_ETHER_MTU;
 
-	size = (sizeof(list_mcs_cipher_vectors) / sizeof((list_mcs_cipher_vectors)[0]));
+	size = RTE_DIM(list_mcs_cipher_vectors);
 	for (i = 0; i < size; i++) {
 		cur_td = &list_mcs_cipher_vectors[i];
 		err = test_macsec(&cur_td, MCS_DECAP, &opts);
@@ -1371,7 +1371,7 @@ test_inline_macsec_auth_only_all(void)
 	opts.sectag_insert_mode = 1;
 	opts.mtu = RTE_ETHER_MTU;
 
-	size = (sizeof(list_mcs_integrity_vectors) / sizeof((list_mcs_integrity_vectors)[0]));
+	size = RTE_DIM(list_mcs_integrity_vectors);
 
 	for (i = 0; i < size; i++) {
 		cur_td = &list_mcs_integrity_vectors[i];
@@ -1410,7 +1410,7 @@ test_inline_macsec_verify_only_all(void)
 	opts.sectag_insert_mode = 1;
 	opts.mtu = RTE_ETHER_MTU;
 
-	size = (sizeof(list_mcs_integrity_vectors) / sizeof((list_mcs_integrity_vectors)[0]));
+	size = RTE_DIM(list_mcs_integrity_vectors);
 
 	for (i = 0; i < size; i++) {
 		cur_td = &list_mcs_integrity_vectors[i];
@@ -1451,7 +1451,7 @@ test_inline_macsec_encap_decap_all(void)
 	opts.sectag_insert_mode = 1;
 	opts.mtu = RTE_ETHER_MTU;
 
-	size = (sizeof(list_mcs_cipher_vectors) / sizeof((list_mcs_cipher_vectors)[0]));
+	size = RTE_DIM(list_mcs_cipher_vectors);
 
 	for (i = 0; i < size; i++) {
 		cur_td = &list_mcs_cipher_vectors[i];
@@ -1492,7 +1492,7 @@ test_inline_macsec_auth_verify_all(void)
 	opts.sectag_insert_mode = 1;
 	opts.mtu = RTE_ETHER_MTU;
 
-	size = (sizeof(list_mcs_integrity_vectors) / sizeof((list_mcs_integrity_vectors)[0]));
+	size = RTE_DIM(list_mcs_integrity_vectors);
 
 	for (i = 0; i < size; i++) {
 		cur_td = &list_mcs_integrity_vectors[i];
@@ -1578,7 +1578,7 @@ test_inline_macsec_with_vlan(void)
 	opts.nb_td = 1;
 	opts.mtu = RTE_ETHER_MTU;
 
-	size = (sizeof(list_mcs_vlan_vectors) / sizeof((list_mcs_vlan_vectors)[0]));
+	size = RTE_DIM(list_mcs_vlan_vectors);
 
 	for (i = 0; i < size; i++) {
 		cur_td = &list_mcs_vlan_vectors[i];
@@ -1653,7 +1653,7 @@ test_inline_macsec_pkt_drop(void)
 	opts.sectag_insert_mode = 1;
 	opts.mtu = RTE_ETHER_MTU;
 
-	size = (sizeof(list_mcs_err_cipher_vectors) / sizeof((list_mcs_err_cipher_vectors)[0]));
+	size = RTE_DIM(list_mcs_err_cipher_vectors);
 
 	for (i = 0; i < size; i++) {
 		cur_td = &list_mcs_err_cipher_vectors[i];
@@ -1693,8 +1693,7 @@ test_inline_macsec_untagged_rx(void)
 	opts.mtu = RTE_ETHER_MTU;
 	opts.check_untagged_rx = 1;
 
-	size = (sizeof(list_mcs_untagged_cipher_vectors) /
-		sizeof((list_mcs_untagged_cipher_vectors)[0]));
+	size = RTE_DIM(list_mcs_untagged_cipher_vectors);
 
 	for (i = 0; i < size; i++) {
 		cur_td = &list_mcs_untagged_cipher_vectors[i];
@@ -1747,7 +1746,7 @@ test_inline_macsec_bad_tag_rx(void)
 	opts.mtu = RTE_ETHER_MTU;
 	opts.check_bad_tag_cnt = 1;
 
-	size = (sizeof(list_mcs_bad_tag_vectors) / sizeof((list_mcs_bad_tag_vectors)[0]));
+	size = RTE_DIM(list_mcs_bad_tag_vectors);
 
 	for (i = 0; i < size; i++) {
 		cur_td = &list_mcs_bad_tag_vectors[i];
@@ -1786,7 +1785,7 @@ test_inline_macsec_sa_not_in_use(void)
 	opts.mtu = RTE_ETHER_MTU;
 	opts.check_sa_not_in_use = 1;
 
-	size = (sizeof(list_mcs_cipher_vectors) / sizeof((list_mcs_cipher_vectors)[0]));
+	size = RTE_DIM(list_mcs_cipher_vectors);
 
 	for (i = 0; i < size; i++) {
 		cur_td = &list_mcs_cipher_vectors[i];
@@ -1825,7 +1824,7 @@ test_inline_macsec_decap_stats(void)
 	opts.mtu = RTE_ETHER_MTU;
 	opts.check_decap_stats = 1;
 
-	size = (sizeof(list_mcs_cipher_vectors) / sizeof((list_mcs_cipher_vectors)[0]));
+	size = RTE_DIM(list_mcs_cipher_vectors);
 
 	for (i = 0; i < size; i++) {
 		cur_td = &list_mcs_cipher_vectors[i];
@@ -1866,7 +1865,7 @@ test_inline_macsec_verify_only_stats(void)
 	opts.mtu = RTE_ETHER_MTU;
 	opts.check_verify_only_stats = 1;
 
-	size = (sizeof(list_mcs_integrity_vectors) / sizeof((list_mcs_integrity_vectors)[0]));
+	size = RTE_DIM(list_mcs_integrity_vectors);
 
 	for (i = 0; i < size; i++) {
 		cur_td = &list_mcs_integrity_vectors[i];
@@ -1906,7 +1905,7 @@ test_inline_macsec_pkts_invalid_stats(void)
 	opts.sectag_insert_mode = 1;
 	opts.mtu = RTE_ETHER_MTU;
 
-	size = (sizeof(list_mcs_err_cipher_vectors) / sizeof((list_mcs_err_cipher_vectors)[0]));
+	size = RTE_DIM(list_mcs_err_cipher_vectors);
 
 	for (i = 0; i < size; i++) {
 		cur_td = &list_mcs_err_cipher_vectors[i];
@@ -1943,7 +1942,7 @@ test_inline_macsec_pkts_unchecked_stats(void)
 	opts.mtu = RTE_ETHER_MTU;
 	opts.check_pkts_unchecked_stats = 1;
 
-	size = (sizeof(list_mcs_integrity_vectors) / sizeof((list_mcs_integrity_vectors)[0]));
+	size = RTE_DIM(list_mcs_integrity_vectors);
 
 	for (i = 0; i < size; i++) {
 		cur_td = &list_mcs_integrity_vectors[i];
@@ -1982,7 +1981,7 @@ test_inline_macsec_out_pkts_untagged(void)
 	opts.mtu = RTE_ETHER_MTU;
 	opts.check_out_pkts_untagged = 1;
 
-	size = (sizeof(list_mcs_cipher_vectors) / sizeof((list_mcs_cipher_vectors)[0]));
+	size = RTE_DIM(list_mcs_cipher_vectors);
 	for (i = 0; i < size; i++) {
 		cur_td = &list_mcs_cipher_vectors[i];
 		err = test_macsec(&cur_td, MCS_ENCAP, &opts);
@@ -2020,7 +2019,7 @@ test_inline_macsec_out_pkts_toolong(void)
 	opts.mtu = 50;
 	opts.check_out_pkts_toolong = 1;
 
-	size = (sizeof(list_mcs_cipher_vectors) / sizeof((list_mcs_cipher_vectors)[0]));
+	size = RTE_DIM(list_mcs_cipher_vectors);
 	for (i = 0; i < size; i++) {
 		cur_td = &list_mcs_cipher_vectors[i];
 		err = test_macsec(&cur_td, MCS_ENCAP, &opts);
@@ -2058,7 +2057,7 @@ test_inline_macsec_encap_stats(void)
 	opts.mtu = RTE_ETHER_MTU;
 	opts.check_encap_stats = 1;
 
-	size = (sizeof(list_mcs_cipher_vectors) / sizeof((list_mcs_cipher_vectors)[0]));
+	size = RTE_DIM(list_mcs_cipher_vectors);
 	for (i = 0; i < size; i++) {
 		cur_td = &list_mcs_cipher_vectors[i];
 		err = test_macsec(&cur_td, MCS_ENCAP, &opts);
@@ -2095,7 +2094,7 @@ test_inline_macsec_auth_only_stats(void)
 	opts.mtu = RTE_ETHER_MTU;
 	opts.check_auth_only_stats = 1;
 
-	size = (sizeof(list_mcs_integrity_vectors) / sizeof((list_mcs_integrity_vectors)[0]));
+	size = RTE_DIM(list_mcs_integrity_vectors);
 
 	for (i = 0; i < size; i++) {
 		cur_td = &list_mcs_integrity_vectors[i];
@@ -2146,7 +2145,7 @@ test_inline_macsec_interrupts_all(void)
 	rte_eth_dev_callback_register(port_id, RTE_ETH_EVENT_MACSEC,
 			test_macsec_event_callback, &err_vector);
 
-	size = (sizeof(list_mcs_intr_test_vectors) / sizeof((list_mcs_intr_test_vectors)[0]));
+	size = RTE_DIM(list_mcs_intr_test_vectors);
 
 	for (i = 0; i < size; i++) {
 		cur_td = &list_mcs_intr_test_vectors[i];
@@ -2194,7 +2193,7 @@ test_inline_macsec_rekey_tx(void)
 	opts.mtu = RTE_ETHER_MTU;
 	opts.rekey_en = 1;
 
-	size = (sizeof(list_mcs_rekey_vectors) / sizeof((list_mcs_rekey_vectors)[0]));
+	size = RTE_DIM(list_mcs_rekey_vectors);
 
 	for (i = 0; i < size; i++) {
 		cur_td = &list_mcs_rekey_vectors[i];
@@ -2236,7 +2235,7 @@ test_inline_macsec_rekey_rx(void)
 	opts.mtu = RTE_ETHER_MTU;
 	opts.rekey_en = 1;
 
-	size = (sizeof(list_mcs_rekey_vectors) / sizeof((list_mcs_rekey_vectors)[0]));
+	size = RTE_DIM(list_mcs_rekey_vectors);
 	for (i = 0; i < size; i++) {
 		cur_td = &list_mcs_rekey_vectors[i];
 		opts.rekey_td = &list_mcs_rekey_vectors[++i];
@@ -2277,7 +2276,7 @@ test_inline_macsec_anti_replay(void)
 	opts.sectag_insert_mode = 1;
 	opts.replay_protect = 1;
 
-	size = (sizeof(list_mcs_anti_replay_vectors) / sizeof((list_mcs_anti_replay_vectors)[0]));
+	size = RTE_DIM(list_mcs_anti_replay_vectors);
 
 	for (j = 0; j < 2; j++) {
 		opts.replay_win_sz = replay_win_sz[j];
-- 
2.43.0


  parent reply	other threads:[~2024-04-16 15:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-16 15:19 [PATCH 0/5] use RTE_DIM where possible Stephen Hemminger
2024-04-16 15:19 ` [PATCH 1/5] cocci: add script to use RTE_DIM Stephen Hemminger
2024-04-16 15:19 ` Stephen Hemminger [this message]
2024-04-16 15:30   ` [PATCH 2/5] app: " Tyler Retzlaff
2024-04-17  6:13   ` [EXTERNAL] " Akhil Goyal
2024-04-16 15:19 ` [PATCH 3/5] lib: " Stephen Hemminger
2024-04-16 15:32   ` Tyler Retzlaff
2024-04-16 15:19 ` [PATCH 4/5] examples _use RTE_DIM Stephen Hemminger
2024-04-16 15:32   ` Tyler Retzlaff
2024-04-16 15:19 ` [PATCH 5/5] drivers/net: use RTE_DIM Stephen Hemminger
2024-04-16 16:29   ` Ferruh Yigit
2024-04-16 17:32     ` Stephen Hemminger
2024-04-17  8:00       ` Ferruh Yigit

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=20240416152124.69590-3-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=anoobj@marvell.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=gakhil@marvell.com \
    --cc=thomas@monjalon.net \
    --cc=wisamm@nvidia.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).