* [PATCH 00/16] remove use of VLAs for Windows built code @ 2024-04-17 23:41 Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 01/16] eal: include header required for alloca Tyler Retzlaff ` (22 more replies) 0 siblings, 23 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-17 23:41 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Yuying Zhang As per guidance technical board meeting 2024/04/17. This series removes the use of VLAs from code built for Windows for all 3 toolchains. If there are additional opportunities to convert VLAs to regular C arrays please provide the details for incorporation into the series. MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Tyler Retzlaff (16): eal: include header required for alloca hash: remove use of VLAs for Windows built code ethdev: remove use of VLAs for Windows built code gro: remove use of VLAs for Windows built code latencystats: remove use of VLAs for Windows built code lpm: remove use of VLAs for Windows built code rcu: remove use of VLAs for Windows built code app/testpmd: remove use of VLAs for Windows built code test: remove use of VLAs for Windows built code common/idpf: remove use of VLAs for Windows built code net/i40e: remove use of VLAs for Windows built code net/ice: remove use of VLAs for Windows built code net/ixgbe: remove use of VLAs for Windows built code common/mlx5: remove use of VLAs for Windows built code net/mlx5: remove use of VLAs for Windows built code build: enable vla warnings on Windows built code app/test-pmd/cmdline.c | 2 +- app/test-pmd/cmdline_flow.c | 9 +++-- app/test-pmd/config.c | 16 +++++---- app/test-pmd/shared_rxq_fwd.c | 2 +- app/test/test.c | 2 +- app/test/test_cmdline_string.c | 2 +- app/test/test_cryptodev.c | 32 +++++++++--------- app/test/test_cryptodev_blockcipher.c | 4 +-- app/test/test_cryptodev_crosscheck.c | 2 +- app/test/test_dmadev.c | 9 +++-- app/test/test_hash.c | 8 ++--- app/test/test_mempool.c | 25 +++++++------- app/test/test_reassembly_perf.c | 4 +-- app/test/test_reorder.c | 48 +++++++++++++++------------ app/test/test_service_cores.c | 9 +++-- app/test/test_thash.c | 7 ++-- config/meson.build | 4 +++ drivers/common/idpf/idpf_common_rxtx.c | 2 +- drivers/common/idpf/idpf_common_rxtx_avx512.c | 6 ++-- drivers/common/mlx5/mlx5_common.h | 4 +-- drivers/common/mlx5/mlx5_devx_cmds.c | 7 ++-- drivers/net/i40e/i40e_testpmd.c | 5 ++- drivers/net/ice/ice_rxtx.c | 2 +- drivers/net/ixgbe/ixgbe_ethdev.c | 5 +-- drivers/net/ixgbe/ixgbe_rxtx_vec_common.h | 2 +- drivers/net/mlx5/mlx5.c | 5 ++- drivers/net/mlx5/mlx5_flow.c | 6 ++-- lib/eal/linux/include/rte_os.h | 1 + lib/eal/windows/include/rte_os.h | 1 + lib/ethdev/rte_ethdev.c | 9 ++--- lib/gro/rte_gro.c | 4 +-- lib/hash/rte_cuckoo_hash.c | 4 +-- lib/hash/rte_thash.c | 2 +- lib/latencystats/rte_latencystats.c | 2 +- lib/lpm/rte_lpm.h | 2 +- lib/rcu/rte_rcu_qsbr.c | 6 ++-- 36 files changed, 137 insertions(+), 123 deletions(-) -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH 01/16] eal: include header required for alloca 2024-04-17 23:41 [PATCH 00/16] remove use of VLAs for Windows built code Tyler Retzlaff @ 2024-04-17 23:41 ` Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 02/16] hash: remove use of VLAs for Windows built code Tyler Retzlaff ` (21 subsequent siblings) 22 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-17 23:41 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Yuying Zhang Include alloca.h for Linux and malloc.h for Windows to get declaration of alloca(). Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- lib/eal/linux/include/rte_os.h | 1 + lib/eal/windows/include/rte_os.h | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/eal/linux/include/rte_os.h b/lib/eal/linux/include/rte_os.h index c72bf5b..18ee404 100644 --- a/lib/eal/linux/include/rte_os.h +++ b/lib/eal/linux/include/rte_os.h @@ -14,6 +14,7 @@ * which is not supported natively or named differently in Linux. */ +#include <alloca.h> #include <sched.h> #include <sys/queue.h> diff --git a/lib/eal/windows/include/rte_os.h b/lib/eal/windows/include/rte_os.h index 1c33058..5c9c542 100644 --- a/lib/eal/windows/include/rte_os.h +++ b/lib/eal/windows/include/rte_os.h @@ -13,6 +13,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <malloc.h> #include <sched.h> -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH 02/16] hash: remove use of VLAs for Windows built code 2024-04-17 23:41 [PATCH 00/16] remove use of VLAs for Windows built code Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 01/16] eal: include header required for alloca Tyler Retzlaff @ 2024-04-17 23:41 ` Tyler Retzlaff 2024-04-18 6:45 ` Morten Brørup 2024-04-17 23:41 ` [PATCH 03/16] ethdev: " Tyler Retzlaff ` (20 subsequent siblings) 22 siblings, 1 reply; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-17 23:41 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Yuying Zhang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- lib/hash/rte_cuckoo_hash.c | 4 ++-- lib/hash/rte_thash.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c index 9cf9464..bd2ff08 100644 --- a/lib/hash/rte_cuckoo_hash.c +++ b/lib/hash/rte_cuckoo_hash.c @@ -2359,7 +2359,7 @@ struct rte_hash * (num_keys > RTE_HASH_LOOKUP_BULK_MAX) || (hit_mask == NULL)), -EINVAL); - int32_t positions[num_keys]; + int32_t *positions = alloca(sizeof(int32_t) * num_keys); __rte_hash_lookup_bulk(h, keys, num_keys, positions, hit_mask, data); @@ -2475,7 +2475,7 @@ struct rte_hash * (num_keys > RTE_HASH_LOOKUP_BULK_MAX) || (hit_mask == NULL)), -EINVAL); - int32_t positions[num_keys]; + int32_t *positions = alloca(sizeof(int32_t) * num_keys); __rte_hash_lookup_with_hash_bulk(h, keys, sig, num_keys, positions, hit_mask, data); diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c index 68f653f..633e211 100644 --- a/lib/hash/rte_thash.c +++ b/lib/hash/rte_thash.c @@ -771,7 +771,7 @@ struct rte_thash_subtuple_helper * uint32_t desired_value, unsigned int attempts, rte_thash_check_tuple_t fn, void *userdata) { - uint32_t tmp_tuple[tuple_len / sizeof(uint32_t)]; + uint32_t *tmp_tuple = alloca(tuple_len); unsigned int i, j, ret = 0; uint32_t hash, adj_bits; const uint8_t *hash_key; -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* RE: [PATCH 02/16] hash: remove use of VLAs for Windows built code 2024-04-17 23:41 ` [PATCH 02/16] hash: remove use of VLAs for Windows built code Tyler Retzlaff @ 2024-04-18 6:45 ` Morten Brørup 0 siblings, 0 replies; 127+ messages in thread From: Morten Brørup @ 2024-04-18 6:45 UTC (permalink / raw) To: Tyler Retzlaff, dev Cc: Akhil Goyal, Aman Singh, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Yuying Zhang > - int32_t positions[num_keys]; > + int32_t *positions = alloca(sizeof(int32_t) * num_keys); A general comment, using this patch as an example... I wonder if adding const has any effect on the compilers' optimizers: int32_t * const positions = alloca(sizeof(int32_t) * num_keys); Perhaps not in this specific case, but maybe elsewhere. Especially if passing the array by reference. We're not good at adding const and restrict to function parameters, so declaring the alloca()'d arrays const might compensate for that. ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH 03/16] ethdev: remove use of VLAs for Windows built code 2024-04-17 23:41 [PATCH 00/16] remove use of VLAs for Windows built code Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 01/16] eal: include header required for alloca Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 02/16] hash: remove use of VLAs for Windows built code Tyler Retzlaff @ 2024-04-17 23:41 ` Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 04/16] gro: " Tyler Retzlaff ` (19 subsequent siblings) 22 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-17 23:41 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Yuying Zhang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- lib/ethdev/rte_ethdev.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index f1c658f..cd2ed74 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -3241,7 +3241,8 @@ enum { } /* Get id-name lookup table */ - struct rte_eth_xstat_name xstats_names[cnt_xstats]; + struct rte_eth_xstat_name *xstats_names = + alloca(sizeof(struct rte_eth_xstat_name) * cnt_xstats); if (cnt_xstats != rte_eth_xstats_get_names_by_id( port_id, xstats_names, cnt_xstats, NULL)) { @@ -3342,7 +3343,7 @@ enum { return -EINVAL; if (ids && dev->dev_ops->xstats_get_names_by_id != NULL && size > 0) { - uint64_t ids_copy[size]; + uint64_t *ids_copy = alloca(sizeof(uint64_t) * size); for (i = 0; i < size; i++) { if (ids[i] < basic_count) { @@ -3535,7 +3536,7 @@ enum { if (ret < 0) return ret; expected_entries = (uint16_t)ret; - struct rte_eth_xstat xstats[expected_entries]; + struct rte_eth_xstat *xstats = alloca(sizeof(struct rte_eth_xstat) * expected_entries); basic_count = eth_dev_get_xstats_basic_count(dev); /* Return max number of stats if no ids given */ @@ -3551,7 +3552,7 @@ enum { if (ids && dev->dev_ops->xstats_get_by_id != NULL && size) { unsigned int basic_count = eth_dev_get_xstats_basic_count(dev); - uint64_t ids_copy[size]; + uint64_t *ids_copy = alloca(sizeof(uint64_t) * size); for (i = 0; i < size; i++) { if (ids[i] < basic_count) { -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH 04/16] gro: remove use of VLAs for Windows built code 2024-04-17 23:41 [PATCH 00/16] remove use of VLAs for Windows built code Tyler Retzlaff ` (2 preceding siblings ...) 2024-04-17 23:41 ` [PATCH 03/16] ethdev: " Tyler Retzlaff @ 2024-04-17 23:41 ` Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 05/16] latencystats: " Tyler Retzlaff ` (18 subsequent siblings) 22 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-17 23:41 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Yuying Zhang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- lib/gro/rte_gro.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/gro/rte_gro.c b/lib/gro/rte_gro.c index d824eeb..0f9e85c 100644 --- a/lib/gro/rte_gro.c +++ b/lib/gro/rte_gro.c @@ -179,7 +179,7 @@ struct gro_ctx { struct gro_vxlan_udp4_item vxlan_udp_items[RTE_GRO_MAX_BURST_ITEM_NUM] = {{{0}} }; - struct rte_mbuf *unprocess_pkts[nb_pkts]; + struct rte_mbuf **unprocess_pkts = alloca(sizeof(struct rte_mbuf *) * nb_pkts); uint32_t item_num; int32_t ret; uint16_t i, unprocess_num = 0, nb_after_gro = nb_pkts; @@ -360,7 +360,7 @@ struct gro_ctx { uint16_t nb_pkts, void *ctx) { - struct rte_mbuf *unprocess_pkts[nb_pkts]; + struct rte_mbuf **unprocess_pkts = alloca(sizeof(struct rte_mbuf *) * nb_pkts); struct gro_ctx *gro_ctx = ctx; void *tcp_tbl, *udp_tbl, *vxlan_tcp_tbl, *vxlan_udp_tbl, *tcp6_tbl; uint64_t current_time; -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH 05/16] latencystats: remove use of VLAs for Windows built code 2024-04-17 23:41 [PATCH 00/16] remove use of VLAs for Windows built code Tyler Retzlaff ` (3 preceding siblings ...) 2024-04-17 23:41 ` [PATCH 04/16] gro: " Tyler Retzlaff @ 2024-04-17 23:41 ` Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 06/16] lpm: " Tyler Retzlaff ` (17 subsequent siblings) 22 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-17 23:41 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Yuying Zhang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- lib/latencystats/rte_latencystats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/latencystats/rte_latencystats.c b/lib/latencystats/rte_latencystats.c index 4ea9b0d..f59a9eb 100644 --- a/lib/latencystats/rte_latencystats.c +++ b/lib/latencystats/rte_latencystats.c @@ -159,7 +159,7 @@ struct latency_stats_nameoff { { unsigned int i, cnt = 0; uint64_t now; - float latency[nb_pkts]; + float *latency = alloca(sizeof(float) * nb_pkts); static float prev_latency; /* * Alpha represents degree of weighting decrease in EWMA, -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH 06/16] lpm: remove use of VLAs for Windows built code 2024-04-17 23:41 [PATCH 00/16] remove use of VLAs for Windows built code Tyler Retzlaff ` (4 preceding siblings ...) 2024-04-17 23:41 ` [PATCH 05/16] latencystats: " Tyler Retzlaff @ 2024-04-17 23:41 ` Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 07/16] rcu: " Tyler Retzlaff ` (16 subsequent siblings) 22 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-17 23:41 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Yuying Zhang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- lib/lpm/rte_lpm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lpm/rte_lpm.h b/lib/lpm/rte_lpm.h index 2888e5f..fc5805c 100644 --- a/lib/lpm/rte_lpm.h +++ b/lib/lpm/rte_lpm.h @@ -337,7 +337,7 @@ struct rte_lpm * uint32_t *next_hops, const unsigned n) { unsigned i; - unsigned tbl24_indexes[n]; + unsigned int *tbl24_indexes = (unsigned int *)alloca(sizeof(unsigned int) * n); const uint32_t *ptbl; /* DEBUG: Check user input arguments. */ -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH 07/16] rcu: remove use of VLAs for Windows built code 2024-04-17 23:41 [PATCH 00/16] remove use of VLAs for Windows built code Tyler Retzlaff ` (5 preceding siblings ...) 2024-04-17 23:41 ` [PATCH 06/16] lpm: " Tyler Retzlaff @ 2024-04-17 23:41 ` Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 08/16] app/testpmd: " Tyler Retzlaff ` (15 subsequent siblings) 22 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-17 23:41 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Yuying Zhang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- lib/rcu/rte_rcu_qsbr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/rcu/rte_rcu_qsbr.c b/lib/rcu/rte_rcu_qsbr.c index f08d974..971c056 100644 --- a/lib/rcu/rte_rcu_qsbr.c +++ b/lib/rcu/rte_rcu_qsbr.c @@ -356,7 +356,7 @@ int rte_rcu_qsbr_dq_enqueue(struct rte_rcu_qsbr_dq *dq, void *e) return 1; } - char data[dq->esize]; + char *data = alloca(dq->esize); dq_elem = (__rte_rcu_qsbr_dq_elem_t *)data; /* Start the grace period */ dq_elem->token = rte_rcu_qsbr_start(dq->v); @@ -419,10 +419,10 @@ int rte_rcu_qsbr_dq_enqueue(struct rte_rcu_qsbr_dq *dq, void *e) cnt = 0; - char data[dq->esize]; + char *data = alloca(dq->esize); /* Check reader threads quiescent state and reclaim resources */ while (cnt < n && - rte_ring_dequeue_bulk_elem_start(dq->r, &data, + rte_ring_dequeue_bulk_elem_start(dq->r, data, dq->esize, 1, available) != 0) { dq_elem = (__rte_rcu_qsbr_dq_elem_t *)data; -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH 08/16] app/testpmd: remove use of VLAs for Windows built code 2024-04-17 23:41 [PATCH 00/16] remove use of VLAs for Windows built code Tyler Retzlaff ` (6 preceding siblings ...) 2024-04-17 23:41 ` [PATCH 07/16] rcu: " Tyler Retzlaff @ 2024-04-17 23:41 ` Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 09/16] test: " Tyler Retzlaff ` (14 subsequent siblings) 22 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-17 23:41 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Yuying Zhang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- app/test-pmd/cmdline.c | 2 +- app/test-pmd/cmdline_flow.c | 9 ++++----- app/test-pmd/config.c | 16 +++++++++------- app/test-pmd/shared_rxq_fwd.c | 2 +- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index b7759e3..dee8f5f 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -12902,7 +12902,7 @@ struct cmd_set_port_ptypes_result { return; } - uint32_t ptypes[ret]; + uint32_t *ptypes = alloca(sizeof(uint32_t) * ret); ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret); if (ret < 0) { diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 60ee933..a4fe8d9 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -11546,8 +11546,7 @@ struct indlst_conf { char tmp[16]; /* Ought to be enough. */ int ret; unsigned int hexlen = len; - unsigned int length = 256; - uint8_t hex_tmp[length]; + uint8_t hex_tmp[256]; /* Arguments are expected. */ if (!arg_data) @@ -11574,7 +11573,7 @@ struct indlst_conf { str += 2; hexlen -= 2; } - if (hexlen > length) + if (hexlen > RTE_DIM(hex_tmp)) goto error; ret = parse_hex_string(str, hex_tmp, &hexlen); if (ret < 0) @@ -11707,7 +11706,7 @@ struct indlst_conf { void *buf, unsigned int size) { const struct arg *arg = pop_args(ctx); - char str2[len + 1]; + char *str2 = alloca(len + 1); struct in_addr tmp; int ret; @@ -11753,7 +11752,7 @@ struct indlst_conf { void *buf, unsigned int size) { const struct arg *arg = pop_args(ctx); - char str2[len + 1]; + char *str2 = alloca(len + 1); struct in6_addr tmp; int ret; diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index ba1007a..4dce6fa 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1760,7 +1760,8 @@ void port_flow_tunnel_create(portid_t port_id, const struct tunnel_ops *ops) { struct rte_port *port; struct rte_flow_error error; - const struct rte_flow_queue_attr *attr_list[nb_queue]; + const struct rte_flow_queue_attr **attr_list = + alloca(sizeof(struct rte_flow_queue_attr *) * nb_queue); int std_queue; if (port_id_is_invalid(port_id, ENABLED_WARN) || @@ -2577,10 +2578,10 @@ struct rte_flow_meter_policy * int ret; uint32_t i; struct rte_flow_error error; - struct rte_flow_pattern_template - *flow_pattern_templates[nb_pattern_templates]; - struct rte_flow_actions_template - *flow_actions_templates[nb_actions_templates]; + struct rte_flow_pattern_template **flow_pattern_templates = + alloca(sizeof(struct rte_flow_pattern_template *) * nb_pattern_templates); + struct rte_flow_actions_template **flow_actions_templates = + alloca(sizeof(struct rte_flow_actions_template *) * nb_actions_templates); if (port_id_is_invalid(port_id, ENABLED_WARN) || port_id == (portid_t)RTE_PORT_ALL) @@ -5460,7 +5461,7 @@ struct igb_ring_desc_16_bytes { char *end = NULL; int min, max; int value, i; - unsigned int marked[maxsize]; + unsigned int *marked = alloca(sizeof(unsigned int) * maxsize); if (list == NULL || values == NULL) return 0; @@ -7201,7 +7202,8 @@ static const char *get_ptype_str(uint32_t ptype) if (eth_dev_info_get_print_err(port_id, &dev_info)) return; - struct rte_ether_addr addr[dev_info.max_mac_addrs]; + struct rte_ether_addr *addr = + alloca(sizeof(struct rte_ether_addr) * dev_info.max_mac_addrs); rc = rte_eth_macaddrs_get(port_id, addr, dev_info.max_mac_addrs); if (rc < 0) return; diff --git a/app/test-pmd/shared_rxq_fwd.c b/app/test-pmd/shared_rxq_fwd.c index 623d62d..5d4ffff 100644 --- a/app/test-pmd/shared_rxq_fwd.c +++ b/app/test-pmd/shared_rxq_fwd.c @@ -92,7 +92,7 @@ static bool shared_rxq_fwd(struct fwd_stream *fs) { - struct rte_mbuf *pkts_burst[nb_pkt_per_burst]; + struct rte_mbuf **pkts_burst = alloca(sizeof(struct rte_mbuf *) * nb_pkt_per_burst); uint16_t nb_rx; nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst); -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH 09/16] test: remove use of VLAs for Windows built code 2024-04-17 23:41 [PATCH 00/16] remove use of VLAs for Windows built code Tyler Retzlaff ` (7 preceding siblings ...) 2024-04-17 23:41 ` [PATCH 08/16] app/testpmd: " Tyler Retzlaff @ 2024-04-17 23:41 ` Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 10/16] common/idpf: " Tyler Retzlaff ` (13 subsequent siblings) 22 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-17 23:41 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Yuying Zhang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- app/test/test.c | 2 +- app/test/test_cmdline_string.c | 2 +- app/test/test_cryptodev.c | 32 +++++++++++------------ app/test/test_cryptodev_blockcipher.c | 4 +-- app/test/test_cryptodev_crosscheck.c | 2 +- app/test/test_dmadev.c | 9 ++++--- app/test/test_hash.c | 8 +++--- app/test/test_mempool.c | 25 +++++++++--------- app/test/test_reassembly_perf.c | 4 +-- app/test/test_reorder.c | 48 +++++++++++++++++++---------------- app/test/test_service_cores.c | 9 +++---- app/test/test_thash.c | 7 +++-- 12 files changed, 79 insertions(+), 73 deletions(-) diff --git a/app/test/test.c b/app/test/test.c index 680351f..fd653cb 100644 --- a/app/test/test.c +++ b/app/test/test.c @@ -105,7 +105,7 @@ main(int argc, char **argv) { struct cmdline *cl; - char *tests[argc]; /* store an array of tests to run */ + char **tests = alloca(sizeof(char *) * argc); /* store an array of tests to run */ int test_count = 0; int i; char *extra_args; diff --git a/app/test/test_cmdline_string.c b/app/test/test_cmdline_string.c index 97516c9..e1cf860 100644 --- a/app/test/test_cmdline_string.c +++ b/app/test/test_cmdline_string.c @@ -40,7 +40,7 @@ struct string_elt_str string_elt_strs[] = { #if (CMDLINE_TEST_BUFSIZE < STR_TOKEN_SIZE) \ || (CMDLINE_TEST_BUFSIZE < STR_MULTI_TOKEN_SIZE) #undef CMDLINE_TEST_BUFSIZE -#define CMDLINE_TEST_BUFSIZE RTE_MAX(STR_TOKEN_SIZE, STR_MULTI_TOKEN_SIZE) +#define CMDLINE_TEST_BUFSIZE RTE_MAX_T(STR_TOKEN_SIZE, STR_MULTI_TOKEN_SIZE, size_t) #endif struct string_nb_str { diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index 1703ebc..fead21b 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -2686,7 +2686,7 @@ struct crypto_unittest_params { enum rte_crypto_auth_operation op, enum rte_crypto_auth_algorithm algo) { - uint8_t hash_key[key_len]; + uint8_t *hash_key = alloca(key_len); struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -2722,7 +2722,7 @@ struct crypto_unittest_params { const uint8_t *key, const uint8_t key_len, uint8_t iv_len) { - uint8_t cipher_key[key_len]; + uint8_t *cipher_key = alloca(key_len); struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -2874,7 +2874,7 @@ struct crypto_unittest_params { const struct wireless_test_data *tdata) { const uint8_t key_len = tdata->key.len; - uint8_t cipher_auth_key[key_len]; + uint8_t *cipher_auth_key = alloca(key_len); struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -8878,7 +8878,7 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata) const uint16_t aad_len, const uint8_t auth_len, uint8_t iv_len) { - uint8_t aead_key[key_len]; + uint8_t *aead_key = alloca(key_len); struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -12849,7 +12849,7 @@ static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc, test_AES_GCM_auth_encryption_fail_aad_corrupt(void) { struct aead_test_data tdata; - uint8_t aad[gcm_test_case_7.aad.len]; + uint8_t *aad = alloca(gcm_test_case_7.aad.len); int res; RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n"); @@ -13238,7 +13238,7 @@ static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc, test_AES_GCM_auth_decryption_fail_aad_corrupt(void) { struct aead_test_data tdata; - uint8_t aad[gcm_test_case_7.aad.len]; + uint8_t *aad = alloca(gcm_test_case_7.aad.len); int res; memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data)); @@ -13490,7 +13490,7 @@ static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc, int retval; uint8_t *ciphertext, *auth_tag; uint16_t plaintext_pad_len; - uint8_t key[tdata->key.len + 1]; + uint8_t *key = alloca(tdata->key.len + 1); struct rte_cryptodev_info dev_info; rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); @@ -13592,7 +13592,7 @@ static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc, int retval; uint8_t *plaintext; - uint8_t key[tdata->key.len + 1]; + uint8_t *key = alloca(tdata->key.len + 1); struct rte_cryptodev_info dev_info; rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); @@ -14895,7 +14895,7 @@ static int create_gmac_session(uint8_t dev_id, const struct gmac_test_data *tdata, enum rte_crypto_auth_operation auth_op) { - uint8_t auth_key[tdata->key.len]; + uint8_t *auth_key = alloca(tdata->key.len); struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -15552,7 +15552,7 @@ struct test_crypto_vector { enum rte_crypto_auth_operation auth_op) { struct crypto_testsuite_params *ts_params = &testsuite_params; - uint8_t auth_key[reference->auth_key.len + 1]; + uint8_t *auth_key = alloca(reference->auth_key.len + 1); memcpy(auth_key, reference->auth_key.data, reference->auth_key.len); @@ -15583,8 +15583,8 @@ struct test_crypto_vector { enum rte_crypto_cipher_operation cipher_op) { struct crypto_testsuite_params *ts_params = &testsuite_params; - uint8_t cipher_key[reference->cipher_key.len + 1]; - uint8_t auth_key[reference->auth_key.len + 1]; + uint8_t *cipher_key = alloca(reference->cipher_key.len + 1); + uint8_t *auth_key = alloca(reference->auth_key.len + 1); memcpy(cipher_key, reference->cipher_key.data, reference->cipher_key.len); @@ -16084,8 +16084,8 @@ struct test_crypto_vector { uint8_t *authciphertext, *plaintext, *auth_tag; uint16_t plaintext_pad_len; - uint8_t cipher_key[reference->cipher_key.len + 1]; - uint8_t auth_key[reference->auth_key.len + 1]; + uint8_t *cipher_key = alloca(reference->cipher_key.len + 1); + uint8_t *auth_key = alloca(reference->auth_key.len + 1); struct rte_cryptodev_info dev_info; rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); @@ -16216,8 +16216,8 @@ struct test_crypto_vector { int retval; uint8_t *ciphertext; - uint8_t cipher_key[reference->cipher_key.len + 1]; - uint8_t auth_key[reference->auth_key.len + 1]; + uint8_t *cipher_key = alloca(reference->cipher_key.len + 1); + uint8_t *auth_key = alloca(reference->auth_key.len + 1); struct rte_cryptodev_info dev_info; rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); diff --git a/app/test/test_cryptodev_blockcipher.c b/app/test/test_cryptodev_blockcipher.c index 87a321f..da7bf2c 100644 --- a/app/test/test_cryptodev_blockcipher.c +++ b/app/test/test_cryptodev_blockcipher.c @@ -85,8 +85,8 @@ int status = TEST_SUCCESS; const struct blockcipher_test_data *tdata = t->test_data; - uint8_t cipher_key[tdata->cipher_key.len]; - uint8_t auth_key[tdata->auth_key.len]; + uint8_t *cipher_key = alloca(tdata->cipher_key.len); + uint8_t *auth_key = alloca(tdata->auth_key.len); uint32_t buf_len = tdata->ciphertext.len; uint32_t digest_len = tdata->digest.len; char *buf_p = NULL; diff --git a/app/test/test_cryptodev_crosscheck.c b/app/test/test_cryptodev_crosscheck.c index c29b19c..b9a53a4 100644 --- a/app/test/test_cryptodev_crosscheck.c +++ b/app/test/test_cryptodev_crosscheck.c @@ -894,7 +894,7 @@ struct crosscheck_testsuite_params { crosscheck_with_profile_run(const struct crosscheck_test_profile *profile) { struct crosscheck_testsuite_params *ts_params = &testsuite_params; - uint8_t input_text[profile->input_buf_len]; + uint8_t *input_text = alloca(profile->input_buf_len); uint16_t output_len, encrypted_len; uint8_t encrypted_text[MBUF_SIZE]; uint8_t output_text[MBUF_SIZE]; diff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c index 143e1bc..9cbb9a6 100644 --- a/app/test/test_dmadev.c +++ b/app/test/test_dmadev.c @@ -417,9 +417,12 @@ struct runtest_param { dst_len = len / n_dst; src_len = len / n_src; - struct rte_dma_sge sg_src[n_sge], sg_dst[n_sge]; - struct rte_mbuf *src[n_sge], *dst[n_sge]; - char *src_data[n_sge], *dst_data[n_sge]; + struct rte_dma_sge *sg_src = alloca(sizeof(struct rte_dma_sge) * n_sge); + struct rte_dma_sge *sg_dst = alloca(sizeof(struct rte_dma_sge) * n_sge); + struct rte_mbuf **src = alloca(sizeof(struct rte_mbuf *) * n_sge); + struct rte_mbuf **dst = alloca(sizeof(struct rte_mbuf *) * n_sge); + char **src_data = alloca(sizeof(char *) * n_sge); + char **dst_data = alloca(sizeof(char *) * n_sge); for (i = 0 ; i < len; i++) orig_src[i] = rte_rand() & 0xFF; diff --git a/app/test/test_hash.c b/app/test/test_hash.c index d586878..65fd9e6 100644 --- a/app/test/test_hash.c +++ b/app/test/test_hash.c @@ -1930,8 +1930,8 @@ static int test_hash_iteration(uint32_t ext_table) .socket_id = 0, .extra_flag = hash_extra_flag, }; - int pos[total_entries]; - int expected_pos[total_entries]; + int *pos = alloca(sizeof(int) * total_entries); + int *expected_pos = alloca(sizeof(int) * total_entries); unsigned int i; size_t sz; int32_t status; @@ -2100,8 +2100,8 @@ static int test_hash_iteration(uint32_t ext_table) .socket_id = 0, .extra_flag = hash_extra_flag, }; - int pos[total_entries]; - int expected_pos[total_entries]; + int *pos = alloca(sizeof(int) * total_entries); + int *expected_pos = alloca(sizeof(int) * total_entries); unsigned int i; size_t sz; int32_t status; diff --git a/app/test/test_mempool.c b/app/test/test_mempool.c index ad7ebd6..4672795 100644 --- a/app/test/test_mempool.c +++ b/app/test/test_mempool.c @@ -515,19 +515,20 @@ struct test_mempool_events_data { #undef RTE_TEST_TRACE_FAILURE #define RTE_TEST_TRACE_FAILURE(...) do { goto fail; } while (0) - static const size_t callback_num = 3; - static const size_t mempool_num = 2; +#define CALLBACK_NUM 3u +#define MEMPOOL_NUM 2u + static const unsigned int mempool_elt_size = 64; static const unsigned int mempool_size = 64; - struct test_mempool_events_data data[callback_num]; - struct rte_mempool *mp[mempool_num], *freed; + struct test_mempool_events_data data[CALLBACK_NUM]; + struct rte_mempool *mp[MEMPOOL_NUM], *freed; char name[RTE_MEMPOOL_NAMESIZE]; size_t i, j; int ret; memset(mp, 0, sizeof(mp)); - for (i = 0; i < callback_num; i++) { + for (i = 0; i < CALLBACK_NUM; i++) { ret = rte_mempool_event_callback_register (test_mempool_events_cb, &data[i]); RTE_TEST_ASSERT_EQUAL(ret, 0, "Failed to register the callback %zu: %s", @@ -548,7 +549,7 @@ struct test_mempool_events_data { SOCKET_ID_ANY, 0); RTE_TEST_ASSERT_NOT_NULL(mp[0], "Cannot create mempool %s: %s", name, rte_strerror(rte_errno)); - for (j = 0; j < callback_num; j++) + for (j = 0; j < CALLBACK_NUM; j++) RTE_TEST_ASSERT_EQUAL(data[j].invoked, false, "Callback %zu invoked on %s mempool creation", j, name); @@ -557,7 +558,7 @@ struct test_mempool_events_data { ret = populate(mp[0]); RTE_TEST_ASSERT_EQUAL(ret, (int)mp[0]->size, "Failed to populate mempool %s: %s", name, rte_strerror(-ret)); - for (j = 0; j < callback_num; j++) { + for (j = 0; j < CALLBACK_NUM; j++) { RTE_TEST_ASSERT_EQUAL(data[j].invoked, true, "Callback %zu not invoked on mempool %s population", j, name); @@ -589,7 +590,7 @@ struct test_mempool_events_data { "Unregistered callback 0 invoked on %s mempool populaton", name); - for (i = 0; i < mempool_num; i++) { + for (i = 0; i < MEMPOOL_NUM; i++) { memset(&data, 0, sizeof(data)); sprintf(name, "empty%zu", i); rte_mempool_free(mp[i]); @@ -599,7 +600,7 @@ struct test_mempool_events_data { */ freed = mp[i]; mp[i] = NULL; - for (j = 1; j < callback_num; j++) { + for (j = 1; j < CALLBACK_NUM; j++) { RTE_TEST_ASSERT_EQUAL(data[j].invoked, true, "Callback %zu not invoked on mempool %s destruction", j, name); @@ -615,7 +616,7 @@ struct test_mempool_events_data { name); } - for (j = 1; j < callback_num; j++) { + for (j = 1; j < CALLBACK_NUM; j++) { ret = rte_mempool_event_callback_unregister (test_mempool_events_cb, &data[j]); RTE_TEST_ASSERT_EQUAL(ret, 0, "Failed to unregister the callback %zu: %s", @@ -624,10 +625,10 @@ struct test_mempool_events_data { return TEST_SUCCESS; fail: - for (j = 0; j < callback_num; j++) + for (j = 0; j < CALLBACK_NUM; j++) rte_mempool_event_callback_unregister (test_mempool_events_cb, &data[j]); - for (i = 0; i < mempool_num; i++) + for (i = 0; i < MEMPOOL_NUM; i++) rte_mempool_free(mp[i]); return TEST_FAILED; diff --git a/app/test/test_reassembly_perf.c b/app/test/test_reassembly_perf.c index 3912179..7f4ed31 100644 --- a/app/test/test_reassembly_perf.c +++ b/app/test/test_reassembly_perf.c @@ -604,7 +604,7 @@ for (j = 0; j < 4; j++) nb_frags += frag_per_flow[i + j]; - struct rte_mbuf *buf_arr[nb_frags]; + struct rte_mbuf **buf_arr = alloca(sizeof(struct rte_mbuf *) * nb_frags); for (j = 0; j < 4; j++) { join_array(buf_arr, mbufs[i + j], prev, frag_per_flow[i + j]); @@ -815,7 +815,7 @@ for (j = 0; j < 4; j++) nb_frags += frag_per_flow[i + j]; - struct rte_mbuf *buf_arr[nb_frags]; + struct rte_mbuf **buf_arr = alloca(sizeof(struct rte_mbuf *) * nb_frags); for (j = 0; j < 4; j++) { join_array(buf_arr, mbufs[i + j], prev, frag_per_flow[i + j]); diff --git a/app/test/test_reorder.c b/app/test/test_reorder.c index 501780c..aaa2c57 100644 --- a/app/test/test_reorder.c +++ b/app/test/test_reorder.c @@ -130,11 +130,12 @@ struct reorder_unittest_params { static int test_reorder_insert(void) { +#define INSERT_NUM_BUFS 7u + struct rte_reorder_buffer *b = NULL; struct rte_mempool *p = test_params->p; const unsigned int size = 4; - const unsigned int num_bufs = 7; - struct rte_mbuf *bufs[num_bufs]; + struct rte_mbuf *bufs[INSERT_NUM_BUFS]; int ret = 0; unsigned i; @@ -146,7 +147,7 @@ struct reorder_unittest_params { b = rte_reorder_create("test_insert", rte_socket_id(), size); TEST_ASSERT_NOT_NULL(b, "Failed to create reorder buffer"); - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < INSERT_NUM_BUFS; i++) { bufs[i] = rte_pktmbuf_alloc(p); TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n"); *rte_reorder_seqn(bufs[i]) = i; @@ -207,26 +208,27 @@ struct reorder_unittest_params { ret = 0; exit: rte_reorder_free(b); - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < INSERT_NUM_BUFS; i++) rte_pktmbuf_free(bufs[i]); - } + return ret; } static int test_reorder_drain(void) { +#define DRAIN_NUM_BUFS 8u + struct rte_reorder_buffer *b = NULL; struct rte_mempool *p = test_params->p; const unsigned int size = 4; - const unsigned int num_bufs = 8; - struct rte_mbuf *bufs[num_bufs]; - struct rte_mbuf *robufs[num_bufs]; + struct rte_mbuf *bufs[DRAIN_NUM_BUFS]; + struct rte_mbuf *robufs[DRAIN_NUM_BUFS]; int ret = 0; unsigned i, cnt; /* initialize all robufs to NULL */ - for (i = 0; i < num_bufs; i++) + for (i = 0; i < DRAIN_NUM_BUFS; i++) robufs[i] = NULL; /* This would create a reorder buffer instance consisting of: @@ -246,7 +248,7 @@ struct reorder_unittest_params { goto exit; } - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < DRAIN_NUM_BUFS; i++) { bufs[i] = rte_pktmbuf_alloc(p); TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n"); *rte_reorder_seqn(bufs[i]) = i; @@ -320,7 +322,7 @@ struct reorder_unittest_params { ret = 0; exit: rte_reorder_free(b); - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < DRAIN_NUM_BUFS; i++) { rte_pktmbuf_free(bufs[i]); rte_pktmbuf_free(robufs[i]); } @@ -337,15 +339,16 @@ struct reorder_unittest_params { static int test_reorder_drain_up_to_seqn(void) { +#define DRAIN_TO_NUM_BUFS 10u + struct rte_mempool *p = test_params->p; struct rte_reorder_buffer *b = NULL; - const unsigned int num_bufs = 10; const unsigned int size = 4; unsigned int i, cnt; int ret = 0; - struct rte_mbuf *bufs[num_bufs]; - struct rte_mbuf *robufs[num_bufs]; + struct rte_mbuf *bufs[DRAIN_TO_NUM_BUFS]; + struct rte_mbuf *robufs[DRAIN_TO_NUM_BUFS]; /* initialize all robufs to NULL */ memset(robufs, 0, sizeof(robufs)); @@ -358,7 +361,7 @@ struct reorder_unittest_params { b = rte_reorder_create("test_drain_up_to_seqn", rte_socket_id(), size); TEST_ASSERT_NOT_NULL(b, "Failed to create reorder buffer"); - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < DRAIN_TO_NUM_BUFS; i++) { bufs[i] = rte_pktmbuf_alloc(p); TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n"); *rte_reorder_seqn(bufs[i]) = i; @@ -372,7 +375,7 @@ struct reorder_unittest_params { buffer_to_reorder_move(&bufs[2], b); buffer_to_reorder_move(&bufs[3], b); /* Draining 1, 2 */ - cnt = rte_reorder_drain_up_to_seqn(b, robufs, num_bufs, 3); + cnt = rte_reorder_drain_up_to_seqn(b, robufs, DRAIN_TO_NUM_BUFS, 3); if (cnt != 2) { printf("%s:%d:%d: number of expected packets not drained\n", __func__, __LINE__, cnt); @@ -396,7 +399,7 @@ struct reorder_unittest_params { buffer_to_reorder_move(&bufs[8], b); /* Drain 3 and 5 */ - cnt = rte_reorder_drain_up_to_seqn(b, robufs, num_bufs, 6); + cnt = rte_reorder_drain_up_to_seqn(b, robufs, DRAIN_TO_NUM_BUFS, 6); if (cnt != 2) { printf("%s:%d:%d: number of expected packets not drained\n", __func__, __LINE__, cnt); @@ -410,7 +413,7 @@ struct reorder_unittest_params { ret = 0; exit: rte_reorder_free(b); - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < DRAIN_TO_NUM_BUFS; i++) { rte_pktmbuf_free(bufs[i]); rte_pktmbuf_free(robufs[i]); } @@ -420,14 +423,15 @@ struct reorder_unittest_params { static int test_reorder_set_seqn(void) { +#define SET_SEQN_NUM_BUFS 7u + struct rte_mempool *p = test_params->p; struct rte_reorder_buffer *b = NULL; - const unsigned int num_bufs = 7; const unsigned int size = 4; unsigned int i; int ret = 0; - struct rte_mbuf *bufs[num_bufs]; + struct rte_mbuf *bufs[SET_SEQN_NUM_BUFS]; /* This would create a reorder buffer instance consisting of: * reorder_seq = 0 @@ -437,7 +441,7 @@ struct reorder_unittest_params { b = rte_reorder_create("test_min_seqn_set", rte_socket_id(), size); TEST_ASSERT_NOT_NULL(b, "Failed to create reorder buffer"); - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < SET_SEQN_NUM_BUFS; i++) { bufs[i] = rte_pktmbuf_alloc(p); if (bufs[i] == NULL) { printf("Packet allocation failed\n"); @@ -479,7 +483,7 @@ struct reorder_unittest_params { ret = 0; exit: rte_reorder_free(b); - for (i = 0; i < num_bufs; i++) + for (i = 0; i < SET_SEQN_NUM_BUFS; i++) rte_pktmbuf_free(bufs[i]); return ret; diff --git a/app/test/test_service_cores.c b/app/test/test_service_cores.c index c12d52d..7c45733 100644 --- a/app/test/test_service_cores.c +++ b/app/test/test_service_cores.c @@ -561,9 +561,8 @@ static int32_t dummy_mt_safe_cb(void *args) "Service core count not equal to one"); /* retrieve core list, checking lcore ids */ - const uint32_t size = 4; - uint32_t service_core_ids[size]; - int32_t n = rte_service_lcore_list(service_core_ids, size); + uint32_t service_core_ids[4]; + int32_t n = rte_service_lcore_list(service_core_ids, RTE_DIM(service_core_ids)); TEST_ASSERT_EQUAL(1, n, "Service core list return should equal 1"); TEST_ASSERT_EQUAL(slcore_id, service_core_ids[0], "Service core list lcore must equal slcore_id"); @@ -589,7 +588,7 @@ static int32_t dummy_mt_safe_cb(void *args) cores_at_this_point); /* check longer service core list */ - n = rte_service_lcore_list(service_core_ids, size); + n = rte_service_lcore_list(service_core_ids, RTE_DIM(service_core_ids)); TEST_ASSERT_EQUAL(3, n, "Service core list return should equal 3"); TEST_ASSERT_EQUAL(slcore_id, service_core_ids[0], "Service core list[0] lcore must equal 1"); @@ -607,7 +606,7 @@ static int32_t dummy_mt_safe_cb(void *args) "Service core add did not return zero"); TEST_ASSERT_EQUAL(1, rte_service_lcore_count(), "Service core count not equal to one"); - n = rte_service_lcore_list(service_core_ids, size); + n = rte_service_lcore_list(service_core_ids, RTE_DIM(service_core_ids)); TEST_ASSERT_EQUAL(1, n, "Service core list return should equal one"); TEST_ASSERT_EQUAL(slcore_id, service_core_ids[0], "Service core list[0] lcore must equal %d", diff --git a/app/test/test_thash.c b/app/test/test_thash.c index 65d42fd..80d4106 100644 --- a/app/test/test_thash.c +++ b/app/test/test_thash.c @@ -576,9 +576,8 @@ enum { { struct rte_thash_ctx *ctx; struct rte_thash_subtuple_helper *h; - const int key_len = 40; int reta_sz = 6; - uint8_t initial_key[key_len]; + uint8_t initial_key[40]; const uint8_t *new_key; int ret; union rte_thash_tuple tuple; @@ -586,9 +585,9 @@ enum { unsigned int desired_value = 27 & HASH_MSK(reta_sz); uint16_t port_value = 22; - memset(initial_key, 0, key_len); + memset(initial_key, 0, RTE_DIM(initial_key)); - ctx = rte_thash_init_ctx("test", key_len, reta_sz, initial_key, + ctx = rte_thash_init_ctx("test", RTE_DIM(initial_key), reta_sz, initial_key, RTE_THASH_MINIMAL_SEQ); RTE_TEST_ASSERT(ctx != NULL, "can not create thash ctx\n"); -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH 10/16] common/idpf: remove use of VLAs for Windows built code 2024-04-17 23:41 [PATCH 00/16] remove use of VLAs for Windows built code Tyler Retzlaff ` (8 preceding siblings ...) 2024-04-17 23:41 ` [PATCH 09/16] test: " Tyler Retzlaff @ 2024-04-17 23:41 ` Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 11/16] net/i40e: " Tyler Retzlaff ` (12 subsequent siblings) 22 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-17 23:41 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Yuying Zhang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- drivers/common/idpf/idpf_common_rxtx.c | 2 +- drivers/common/idpf/idpf_common_rxtx_avx512.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/common/idpf/idpf_common_rxtx.c b/drivers/common/idpf/idpf_common_rxtx.c index 83b131e..da24b78 100644 --- a/drivers/common/idpf/idpf_common_rxtx.c +++ b/drivers/common/idpf/idpf_common_rxtx.c @@ -569,7 +569,7 @@ uint16_t nb_refill = rx_bufq->rx_free_thresh; uint16_t nb_desc = rx_bufq->nb_rx_desc; uint16_t next_avail = rx_bufq->rx_tail; - struct rte_mbuf *nmb[rx_bufq->rx_free_thresh]; + struct rte_mbuf **nmb = alloca(sizeof(struct rte_mbuf *) * rx_bufq->rx_free_thresh); uint64_t dma_addr; uint16_t delta; int i; diff --git a/drivers/common/idpf/idpf_common_rxtx_avx512.c b/drivers/common/idpf/idpf_common_rxtx_avx512.c index f65e8d5..9131bd6 100644 --- a/drivers/common/idpf/idpf_common_rxtx_avx512.c +++ b/drivers/common/idpf/idpf_common_rxtx_avx512.c @@ -1002,7 +1002,8 @@ uint32_t n; uint32_t i; int nb_free = 0; - struct rte_mbuf *m, *free[txq->rs_thresh]; + struct rte_mbuf *m; + struct rte_mbuf **free = alloca(sizeof(struct rte_mbuf *) * txq->rs_thresh); /* check DD bits on threshold descriptor */ if ((txq->tx_ring[txq->next_dd].qw1 & @@ -1319,7 +1320,8 @@ uint32_t n; uint32_t i; int nb_free = 0; - struct rte_mbuf *m, *free[txq->rs_thresh]; + struct rte_mbuf *m; + struct rte_mbuf **free = alloca(sizeof(struct rte_mbuf *) * txq->rs_thresh); n = txq->rs_thresh; -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH 11/16] net/i40e: remove use of VLAs for Windows built code 2024-04-17 23:41 [PATCH 00/16] remove use of VLAs for Windows built code Tyler Retzlaff ` (9 preceding siblings ...) 2024-04-17 23:41 ` [PATCH 10/16] common/idpf: " Tyler Retzlaff @ 2024-04-17 23:41 ` Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 12/16] net/ice: " Tyler Retzlaff ` (11 subsequent siblings) 22 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-17 23:41 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Yuying Zhang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- drivers/net/i40e/i40e_testpmd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/i40e/i40e_testpmd.c b/drivers/net/i40e/i40e_testpmd.c index b6ef5d6..21f5962 100644 --- a/drivers/net/i40e/i40e_testpmd.c +++ b/drivers/net/i40e/i40e_testpmd.c @@ -2168,8 +2168,7 @@ struct cmd_ptype_mapping_get_result { { struct cmd_ptype_mapping_get_result *res = parsed_result; int ret = -ENOTSUP; - int max_ptype_num = 256; - struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num]; + struct rte_pmd_i40e_ptype_mapping mapping[256]; uint16_t count; int i; @@ -2178,7 +2177,7 @@ struct cmd_ptype_mapping_get_result { ret = rte_pmd_i40e_ptype_mapping_get(res->port_id, mapping, - max_ptype_num, + RTE_DIM(mapping), &count, res->valid_only); switch (ret) { -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH 12/16] net/ice: remove use of VLAs for Windows built code 2024-04-17 23:41 [PATCH 00/16] remove use of VLAs for Windows built code Tyler Retzlaff ` (10 preceding siblings ...) 2024-04-17 23:41 ` [PATCH 11/16] net/i40e: " Tyler Retzlaff @ 2024-04-17 23:41 ` Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 13/16] net/ixgbe: " Tyler Retzlaff ` (10 subsequent siblings) 22 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-17 23:41 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Yuying Zhang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- drivers/net/ice/ice_rxtx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c index 13aabe9..81e2b50 100644 --- a/drivers/net/ice/ice_rxtx.c +++ b/drivers/net/ice/ice_rxtx.c @@ -1868,7 +1868,7 @@ uint64_t dma_addr; int diag, diag_pay; uint64_t pay_addr; - struct rte_mbuf *mbufs_pay[rxq->rx_free_thresh]; + struct rte_mbuf **mbufs_pay = alloca(sizeof(struct rte_mbuf *) * rxq->rx_free_thresh); /* Allocate buffers in bulk */ alloc_idx = (uint16_t)(rxq->rx_free_trigger - -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH 13/16] net/ixgbe: remove use of VLAs for Windows built code 2024-04-17 23:41 [PATCH 00/16] remove use of VLAs for Windows built code Tyler Retzlaff ` (11 preceding siblings ...) 2024-04-17 23:41 ` [PATCH 12/16] net/ice: " Tyler Retzlaff @ 2024-04-17 23:41 ` Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 14/16] common/mlx5: " Tyler Retzlaff ` (9 subsequent siblings) 22 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-17 23:41 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Yuying Zhang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- drivers/net/ixgbe/ixgbe_ethdev.c | 5 +++-- drivers/net/ixgbe/ixgbe_rxtx_vec_common.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index c61c52b..d460596 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -3553,7 +3553,8 @@ static int ixgbe_dev_xstats_get_names_by_id( uint16_t i; uint16_t size = ixgbe_xstats_calc_num(); - struct rte_eth_xstat_name xstats_names_copy[size]; + struct rte_eth_xstat_name *xstats_names_copy = + alloca(sizeof(struct rte_eth_xstat_name) * size); ixgbe_dev_xstats_get_names_by_id(dev, NULL, xstats_names_copy, size); @@ -3736,7 +3737,7 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, uint16_t i; uint16_t size = ixgbe_xstats_calc_num(); - uint64_t values_copy[size]; + uint64_t *values_copy = alloca(sizeof(uint64_t) * size); ixgbe_dev_xstats_get_by_id(dev, NULL, values_copy, size); diff --git a/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h b/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h index a4d9ec9..78b63b9 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h +++ b/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h @@ -14,7 +14,7 @@ reassemble_packets(struct ixgbe_rx_queue *rxq, struct rte_mbuf **rx_bufs, uint16_t nb_bufs, uint8_t *split_flags) { - struct rte_mbuf *pkts[nb_bufs]; /*finished pkts*/ + struct rte_mbuf **pkts = alloca(sizeof(struct rte_mbuf *) * nb_bufs); /*finished pkts*/ struct rte_mbuf *start = rxq->pkt_first_seg; struct rte_mbuf *end = rxq->pkt_last_seg; unsigned int pkt_idx, buf_idx; -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH 14/16] common/mlx5: remove use of VLAs for Windows built code 2024-04-17 23:41 [PATCH 00/16] remove use of VLAs for Windows built code Tyler Retzlaff ` (12 preceding siblings ...) 2024-04-17 23:41 ` [PATCH 13/16] net/ixgbe: " Tyler Retzlaff @ 2024-04-17 23:41 ` Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 15/16] net/mlx5: " Tyler Retzlaff ` (8 subsequent siblings) 22 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-17 23:41 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Yuying Zhang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- drivers/common/mlx5/mlx5_common.h | 4 ++-- drivers/common/mlx5/mlx5_devx_cmds.c | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h index 9c80277..76eba1c 100644 --- a/drivers/common/mlx5/mlx5_common.h +++ b/drivers/common/mlx5/mlx5_common.h @@ -112,10 +112,10 @@ /* Allocate a buffer on the stack and fill it with a printf format string. */ #define MKSTR(name, ...) \ int mkstr_size_##name = snprintf(NULL, 0, "" __VA_ARGS__); \ - char name[mkstr_size_##name + 1]; \ + char *name = alloca(mkstr_size_##name + 1); \ \ memset(name, 0, mkstr_size_##name + 1); \ - snprintf(name, sizeof(name), "" __VA_ARGS__) + snprintf(name, mkstr_size_##name + 1, "" __VA_ARGS__) enum { PCI_VENDOR_ID_MELLANOX = 0x15b3, diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c index 9b7abab..bac272f 100644 --- a/drivers/common/mlx5/mlx5_devx_cmds.c +++ b/drivers/common/mlx5/mlx5_devx_cmds.c @@ -284,10 +284,9 @@ struct mlx5_devx_obj * void *cmd_comp, uint64_t async_id) { - int out_len = MLX5_ST_SZ_BYTES(query_flow_counter_out) + - MLX5_ST_SZ_BYTES(traffic_counter); - uint32_t out[out_len]; + uint32_t out[MLX5_ST_SZ_BYTES(query_flow_counter_out) + MLX5_ST_SZ_BYTES(traffic_counter)]; uint32_t in[MLX5_ST_SZ_DW(query_flow_counter_in)] = {0}; + const int out_len = RTE_DIM(out); void *stats; int rc; @@ -346,7 +345,7 @@ struct mlx5_devx_obj * int klm_num = attr->klm_num; int in_size_dw = MLX5_ST_SZ_DW(create_mkey_in) + (klm_num ? RTE_ALIGN(klm_num, 4) : 0) * MLX5_ST_SZ_DW(klm); - uint32_t in[in_size_dw]; + uint32_t *in = alloca(sizeof(uint32_t) * in_size_dw); uint32_t out[MLX5_ST_SZ_DW(create_mkey_out)] = {0}; void *mkc; struct mlx5_devx_obj *mkey = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*mkey), -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH 15/16] net/mlx5: remove use of VLAs for Windows built code 2024-04-17 23:41 [PATCH 00/16] remove use of VLAs for Windows built code Tyler Retzlaff ` (13 preceding siblings ...) 2024-04-17 23:41 ` [PATCH 14/16] common/mlx5: " Tyler Retzlaff @ 2024-04-17 23:41 ` Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 16/16] build: enable vla warnings on " Tyler Retzlaff ` (7 subsequent siblings) 22 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-17 23:41 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Yuying Zhang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- drivers/net/mlx5/mlx5.c | 5 ++--- drivers/net/mlx5/mlx5_flow.c | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index d1a6382..de16acf 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1597,14 +1597,13 @@ mlx5_rt_timestamp_config(struct mlx5_dev_ctx_shared *sh, struct mlx5_hca_attr *hca_attr) { - uint32_t dw_cnt = MLX5_ST_SZ_DW(register_mtutc); - uint32_t reg[dw_cnt]; + uint32_t reg[MLX5_ST_SZ_DW(register_mtutc)]; int ret = ENOTSUP; if (hca_attr->access_register_user) ret = mlx5_devx_cmd_register_read(sh->cdev->ctx, MLX5_REGISTER_ID_MTUTC, 0, - reg, dw_cnt); + reg, RTE_DIM(reg)); if (!ret) { uint32_t ts_mode; diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index f31fdfb..b52fb77 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -1476,8 +1476,8 @@ struct mlx5_flow_tunnel_info { "mask/last without a spec is not" " supported"); if (item->spec && item->last && !range_accepted) { - uint8_t spec[size]; - uint8_t last[size]; + uint8_t *spec = alloca(size); + uint8_t *last = alloca(size); unsigned int i; int ret; @@ -8344,7 +8344,7 @@ struct mlx5_flow_workspace* .type = RTE_FLOW_ITEM_TYPE_END, }, }; - uint16_t queue[priv->reta_idx_n]; + uint16_t *queue = alloca(sizeof(uint16_t) * priv->reta_idx_n); struct rte_flow_action_rss action_rss = { .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .level = 0, -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH 16/16] build: enable vla warnings on Windows built code 2024-04-17 23:41 [PATCH 00/16] remove use of VLAs for Windows built code Tyler Retzlaff ` (14 preceding siblings ...) 2024-04-17 23:41 ` [PATCH 15/16] net/mlx5: " Tyler Retzlaff @ 2024-04-17 23:41 ` Tyler Retzlaff 2024-04-18 6:48 ` Morten Brørup 2024-04-18 6:49 ` [PATCH 00/16] remove use of VLAs for " Morten Brørup ` (6 subsequent siblings) 22 siblings, 1 reply; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-17 23:41 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Yuying Zhang MSVC does not support optional C11 VLAs. When building for Windows enable -Wvla so that mingw and clang also fail if a VLA is used. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- config/meson.build | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/meson.build b/config/meson.build index 8c8b019..9e887f2 100644 --- a/config/meson.build +++ b/config/meson.build @@ -344,6 +344,10 @@ if cc.get_id() == 'intel' warning_flags += '-diag-disable=@0@'.format(i) endforeach endif +# no VLAs in code built on Windows +if is_windows + warning_flags += '-Wvla' +endif foreach arg: warning_flags if cc.has_argument(arg) add_project_arguments(arg, language: 'c') -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* RE: [PATCH 16/16] build: enable vla warnings on Windows built code 2024-04-17 23:41 ` [PATCH 16/16] build: enable vla warnings on " Tyler Retzlaff @ 2024-04-18 6:48 ` Morten Brørup 2024-04-18 15:12 ` Tyler Retzlaff 0 siblings, 1 reply; 127+ messages in thread From: Morten Brørup @ 2024-04-18 6:48 UTC (permalink / raw) To: Tyler Retzlaff, dev Cc: Akhil Goyal, Aman Singh, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Yuying Zhang > MSVC does not support optional C11 VLAs. When building for Windows > enable -Wvla so that mingw and clang also fail if a VLA is used. Minor detail, doesn't affect my Ack for the series... Applications built for Windows with mingw and clang might use VLAs in the application itself. Perhaps we should let them continue doing that for now. > > Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> > --- > config/meson.build | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/config/meson.build b/config/meson.build > index 8c8b019..9e887f2 100644 > --- a/config/meson.build > +++ b/config/meson.build > @@ -344,6 +344,10 @@ if cc.get_id() == 'intel' > warning_flags += '-diag-disable=@0@'.format(i) > endforeach > endif > +# no VLAs in code built on Windows > +if is_windows > + warning_flags += '-Wvla' > +endif > foreach arg: warning_flags > if cc.has_argument(arg) > add_project_arguments(arg, language: 'c') > -- > 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* Re: [PATCH 16/16] build: enable vla warnings on Windows built code 2024-04-18 6:48 ` Morten Brørup @ 2024-04-18 15:12 ` Tyler Retzlaff 2024-04-18 15:23 ` Bruce Richardson 0 siblings, 1 reply; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-18 15:12 UTC (permalink / raw) To: Morten Brørup Cc: dev, Akhil Goyal, Aman Singh, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Yuying Zhang On Thu, Apr 18, 2024 at 08:48:39AM +0200, Morten Brørup wrote: > > MSVC does not support optional C11 VLAs. When building for Windows > > enable -Wvla so that mingw and clang also fail if a VLA is used. > > Minor detail, doesn't affect my Ack for the series... > > Applications built for Windows with mingw and clang might use VLAs in the application itself. > > Perhaps we should let them continue doing that for now. i guess you mean our examples or if dpdk is configured as a sub-project? for examples i could explicitly suppress in examples with -Wno-vla but that means any that use VLAs could not be built with MSVC. for sub-module and sub-project of dpdk i feel like these add_project_arguments are not imparted on the application with encapsulating project meson setup no? anyone know? Bruce? Stephen? > > > > > Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> > > --- > > config/meson.build | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/config/meson.build b/config/meson.build > > index 8c8b019..9e887f2 100644 > > --- a/config/meson.build > > +++ b/config/meson.build > > @@ -344,6 +344,10 @@ if cc.get_id() == 'intel' > > warning_flags += '-diag-disable=@0@'.format(i) > > endforeach > > endif > > +# no VLAs in code built on Windows > > +if is_windows > > + warning_flags += '-Wvla' > > +endif > > foreach arg: warning_flags > > if cc.has_argument(arg) > > add_project_arguments(arg, language: 'c') > > -- > > 1.8.3.1 > ^ permalink raw reply [flat|nested] 127+ messages in thread
* Re: [PATCH 16/16] build: enable vla warnings on Windows built code 2024-04-18 15:12 ` Tyler Retzlaff @ 2024-04-18 15:23 ` Bruce Richardson 2024-04-18 19:22 ` Morten Brørup 0 siblings, 1 reply; 127+ messages in thread From: Bruce Richardson @ 2024-04-18 15:23 UTC (permalink / raw) To: Tyler Retzlaff Cc: Morten Brørup, dev, Akhil Goyal, Aman Singh, Andrew Rybchenko, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Yuying Zhang On Thu, Apr 18, 2024 at 08:12:26AM -0700, Tyler Retzlaff wrote: > On Thu, Apr 18, 2024 at 08:48:39AM +0200, Morten Brørup wrote: > > > MSVC does not support optional C11 VLAs. When building for Windows > > > enable -Wvla so that mingw and clang also fail if a VLA is used. > > > > Minor detail, doesn't affect my Ack for the series... > > > > Applications built for Windows with mingw and clang might use VLAs in > > the application itself. > > > > Perhaps we should let them continue doing that for now. > > i guess you mean our examples or if dpdk is configured as a sub-project? > > for examples i could explicitly suppress in examples with -Wno-vla but > that means any that use VLAs could not be built with MSVC. > > for sub-module and sub-project of dpdk i feel like these > add_project_arguments are not imparted on the application with > encapsulating project meson setup no? > > anyone know? Bruce? Stephen? > Project args are not used when building external applications - either those using DPDK as a subproject or via pkg-config. So therefore, this change should be safe. It will only impact built-in DPDK apps and examples. /Bruce ^ permalink raw reply [flat|nested] 127+ messages in thread
* RE: [PATCH 16/16] build: enable vla warnings on Windows built code 2024-04-18 15:23 ` Bruce Richardson @ 2024-04-18 19:22 ` Morten Brørup 0 siblings, 0 replies; 127+ messages in thread From: Morten Brørup @ 2024-04-18 19:22 UTC (permalink / raw) To: Bruce Richardson, Tyler Retzlaff Cc: dev, Akhil Goyal, Aman Singh, Andrew Rybchenko, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Yuying Zhang > From: Bruce Richardson [mailto:bruce.richardson@intel.com] > Sent: Thursday, 18 April 2024 17.24 > > On Thu, Apr 18, 2024 at 08:12:26AM -0700, Tyler Retzlaff wrote: > > On Thu, Apr 18, 2024 at 08:48:39AM +0200, Morten Brørup wrote: > > > > MSVC does not support optional C11 VLAs. When building for Windows > > > > enable -Wvla so that mingw and clang also fail if a VLA is used. > > > > > > Minor detail, doesn't affect my Ack for the series... > > > > > > Applications built for Windows with mingw and clang might use VLAs > in > > > the application itself. > > > > > > Perhaps we should let them continue doing that for now. > > > > i guess you mean our examples or if dpdk is configured as a sub- > project? > > > > for examples i could explicitly suppress in examples with -Wno-vla but > > that means any that use VLAs could not be built with MSVC. > > > > for sub-module and sub-project of dpdk i feel like these > > add_project_arguments are not imparted on the application with > > encapsulating project meson setup no? > > > > anyone know? Bruce? Stephen? > > > Project args are not used when building external applications - either > those using DPDK as a subproject or via pkg-config. So therefore, this > change should be safe. It will only impact built-in DPDK apps and > examples. > > /Bruce Thank you for clarifying, Bruce. Then my comment was irrelevant. Sorry about the noise. ;-) ^ permalink raw reply [flat|nested] 127+ messages in thread
* RE: [PATCH 00/16] remove use of VLAs for Windows built code 2024-04-17 23:41 [PATCH 00/16] remove use of VLAs for Windows built code Tyler Retzlaff ` (15 preceding siblings ...) 2024-04-17 23:41 ` [PATCH 16/16] build: enable vla warnings on " Tyler Retzlaff @ 2024-04-18 6:49 ` Morten Brørup 2024-04-18 12:11 ` Konstantin Ananyev ` (5 subsequent siblings) 22 siblings, 0 replies; 127+ messages in thread From: Morten Brørup @ 2024-04-18 6:49 UTC (permalink / raw) To: Tyler Retzlaff, dev Cc: Akhil Goyal, Aman Singh, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Yuying Zhang > From: Tyler Retzlaff [mailto:roretzla@linux.microsoft.com] > Sent: Thursday, 18 April 2024 01.42 > > As per guidance technical board meeting 2024/04/17. This series > removes the use of VLAs from code built for Windows for all 3 > toolchains. If there are additional opportunities to convert VLAs > to regular C arrays please provide the details for incorporation > into the series. > > MSVC does not support VLAs, replace VLAs with standard C arrays > or alloca(). alloca() is available for all toolchain/platform > combinations officially supported by DPDK. Series-acked-by: Morten Brørup <mb@smartsharesystems.com> Two comments sent in individual mails, don't affect this Ack. ^ permalink raw reply [flat|nested] 127+ messages in thread
* RE: [PATCH 00/16] remove use of VLAs for Windows built code 2024-04-17 23:41 [PATCH 00/16] remove use of VLAs for Windows built code Tyler Retzlaff ` (16 preceding siblings ...) 2024-04-18 6:49 ` [PATCH 00/16] remove use of VLAs for " Morten Brørup @ 2024-04-18 12:11 ` Konstantin Ananyev 2024-04-18 15:15 ` Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (4 subsequent siblings) 22 siblings, 1 reply; 127+ messages in thread From: Konstantin Ananyev @ 2024-04-18 12:11 UTC (permalink / raw) To: Tyler Retzlaff, dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Andrew Rybchenko, Bruce Richardson, Fengchengwen, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Yuying Zhang Hi Tyler, > As per guidance technical board meeting 2024/04/17. This series > removes the use of VLAs from code built for Windows for all 3 > toolchains. If there are additional opportunities to convert VLAs > to regular C arrays please provide the details for incorporation > into the series. I submitted the RFC series: https://patchwork.dpdk.org/project/dpdk/list/?series=31781 that provides alternate approach to VLA removal (without alloca()) for core libs. Feel free to re-use whatever is appropriate in your series. If time permits, I'll try to look to other libs from your series (probably next week or so). Konstantin > > MSVC does not support VLAs, replace VLAs with standard C arrays > or alloca(). alloca() is available for all toolchain/platform > combinations officially supported by DPDK. > > Tyler Retzlaff (16): > eal: include header required for alloca > hash: remove use of VLAs for Windows built code > ethdev: remove use of VLAs for Windows built code > gro: remove use of VLAs for Windows built code > latencystats: remove use of VLAs for Windows built code > lpm: remove use of VLAs for Windows built code > rcu: remove use of VLAs for Windows built code > app/testpmd: remove use of VLAs for Windows built code > test: remove use of VLAs for Windows built code > common/idpf: remove use of VLAs for Windows built code > net/i40e: remove use of VLAs for Windows built code > net/ice: remove use of VLAs for Windows built code > net/ixgbe: remove use of VLAs for Windows built code > common/mlx5: remove use of VLAs for Windows built code > net/mlx5: remove use of VLAs for Windows built code > build: enable vla warnings on Windows built code > > app/test-pmd/cmdline.c | 2 +- > app/test-pmd/cmdline_flow.c | 9 +++-- > app/test-pmd/config.c | 16 +++++---- > app/test-pmd/shared_rxq_fwd.c | 2 +- > app/test/test.c | 2 +- > app/test/test_cmdline_string.c | 2 +- > app/test/test_cryptodev.c | 32 +++++++++--------- > app/test/test_cryptodev_blockcipher.c | 4 +-- > app/test/test_cryptodev_crosscheck.c | 2 +- > app/test/test_dmadev.c | 9 +++-- > app/test/test_hash.c | 8 ++--- > app/test/test_mempool.c | 25 +++++++------- > app/test/test_reassembly_perf.c | 4 +-- > app/test/test_reorder.c | 48 +++++++++++++++------------ > app/test/test_service_cores.c | 9 +++-- > app/test/test_thash.c | 7 ++-- > config/meson.build | 4 +++ > drivers/common/idpf/idpf_common_rxtx.c | 2 +- > drivers/common/idpf/idpf_common_rxtx_avx512.c | 6 ++-- > drivers/common/mlx5/mlx5_common.h | 4 +-- > drivers/common/mlx5/mlx5_devx_cmds.c | 7 ++-- > drivers/net/i40e/i40e_testpmd.c | 5 ++- > drivers/net/ice/ice_rxtx.c | 2 +- > drivers/net/ixgbe/ixgbe_ethdev.c | 5 +-- > drivers/net/ixgbe/ixgbe_rxtx_vec_common.h | 2 +- > drivers/net/mlx5/mlx5.c | 5 ++- > drivers/net/mlx5/mlx5_flow.c | 6 ++-- > lib/eal/linux/include/rte_os.h | 1 + > lib/eal/windows/include/rte_os.h | 1 + > lib/ethdev/rte_ethdev.c | 9 ++--- > lib/gro/rte_gro.c | 4 +-- > lib/hash/rte_cuckoo_hash.c | 4 +-- > lib/hash/rte_thash.c | 2 +- > lib/latencystats/rte_latencystats.c | 2 +- > lib/lpm/rte_lpm.h | 2 +- > lib/rcu/rte_rcu_qsbr.c | 6 ++-- > 36 files changed, 137 insertions(+), 123 deletions(-) > > -- > 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* Re: [PATCH 00/16] remove use of VLAs for Windows built code 2024-04-18 12:11 ` Konstantin Ananyev @ 2024-04-18 15:15 ` Tyler Retzlaff 2024-04-18 15:35 ` Konstantin Ananyev 0 siblings, 1 reply; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-18 15:15 UTC (permalink / raw) To: Konstantin Ananyev Cc: dev, Morten Brørup, Akhil Goyal, Aman Singh, Andrew Rybchenko, Bruce Richardson, Fengchengwen, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Yuying Zhang On Thu, Apr 18, 2024 at 12:11:35PM +0000, Konstantin Ananyev wrote: > Hi Tyler, > > > As per guidance technical board meeting 2024/04/17. This series > > removes the use of VLAs from code built for Windows for all 3 > > toolchains. If there are additional opportunities to convert VLAs > > to regular C arrays please provide the details for incorporation > > into the series. > > I submitted the RFC series: > https://patchwork.dpdk.org/project/dpdk/list/?series=31781 > that provides alternate approach to VLA removal (without alloca()) > for core libs. > Feel free to re-use whatever is appropriate in your series. > If time permits, I'll try to look to other libs from your series > (probably next week or so). > Konstantin if there is no objection i'm happy to drop changes in my series and integrate your changes into my series with your signoff. let me know and i'll roll them together into v2. thank you! ^ permalink raw reply [flat|nested] 127+ messages in thread
* RE: [PATCH 00/16] remove use of VLAs for Windows built code 2024-04-18 15:15 ` Tyler Retzlaff @ 2024-04-18 15:35 ` Konstantin Ananyev 0 siblings, 0 replies; 127+ messages in thread From: Konstantin Ananyev @ 2024-04-18 15:35 UTC (permalink / raw) To: Tyler Retzlaff Cc: dev, Morten Brørup, Akhil Goyal, Aman Singh, Andrew Rybchenko, Bruce Richardson, Fengchengwen, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Yuying Zhang > On Thu, Apr 18, 2024 at 12:11:35PM +0000, Konstantin Ananyev wrote: > > Hi Tyler, > > > > > As per guidance technical board meeting 2024/04/17. This series > > > removes the use of VLAs from code built for Windows for all 3 > > > toolchains. If there are additional opportunities to convert VLAs > > > to regular C arrays please provide the details for incorporation > > > into the series. > > > > I submitted the RFC series: > > https://patchwork.dpdk.org/project/dpdk/list/?series=31781 > > that provides alternate approach to VLA removal (without alloca()) > > for core libs. > > Feel free to re-use whatever is appropriate in your series. > > If time permits, I'll try to look to other libs from your series > > (probably next week or so). > > Konstantin > > if there is no objection i'm happy to drop changes in my series and > integrate your changes into my series with your signoff. > > let me know and i'll roll them together into v2. Yes absolutely, feel free to go ahead with that. Thanks Konstantin > > thank you! ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v2 00/19] remove use of VLAs for Windows 2024-04-17 23:41 [PATCH 00/16] remove use of VLAs for Windows built code Tyler Retzlaff ` (17 preceding siblings ...) 2024-04-18 12:11 ` Konstantin Ananyev @ 2024-04-18 20:02 ` Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 01/19] eal: include header required for alloca Tyler Retzlaff ` (18 more replies) 2024-05-06 18:18 ` [PATCH v3 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (3 subsequent siblings) 22 siblings, 19 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-18 20:02 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang As per guidance technical board meeting 2024/04/17. This series removes the use of VLAs from code built for Windows for all 3 toolchains. If there are additional opportunities to convert VLAs to regular C arrays please provide the details for incorporation into the series. MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. v2: * replace patches for ethdev, hash, rcu and include new patches for eal from Konstantin Ananyev from https://patchwork.dpdk.org/project/dpdk/list/?series=31781 Konstantin Ananyev (6): eal/linux: remove use of VLAs eal/common: remove use of VLAs ethdev: remove use of VLAs for Windows built code hash: remove use of VLAs for Windows built code hash/thash: remove use of VLAs for Windows built code rcu: remove use of VLAs for Windows built code Tyler Retzlaff (13): eal: include header required for alloca gro: remove use of VLAs for Windows built code latencystats: remove use of VLAs for Windows built code lpm: remove use of VLAs for Windows built code app/testpmd: remove use of VLAs for Windows built code test: remove use of VLAs for Windows built code common/idpf: remove use of VLAs for Windows built code net/i40e: remove use of VLAs for Windows built code net/ice: remove use of VLAs for Windows built code net/ixgbe: remove use of VLAs for Windows built code common/mlx5: remove use of VLAs for Windows built code net/mlx5: remove use of VLAs for Windows built code build: enable vla warnings on Windows built code app/test-pmd/cmdline.c | 2 +- app/test-pmd/cmdline_flow.c | 9 +- app/test-pmd/config.c | 16 ++- app/test-pmd/shared_rxq_fwd.c | 2 +- app/test/test.c | 2 +- app/test/test_cmdline_string.c | 2 +- app/test/test_cryptodev.c | 32 ++--- app/test/test_cryptodev_blockcipher.c | 4 +- app/test/test_cryptodev_crosscheck.c | 2 +- app/test/test_dmadev.c | 9 +- app/test/test_hash.c | 8 +- app/test/test_mempool.c | 25 ++-- app/test/test_reassembly_perf.c | 4 +- app/test/test_reorder.c | 48 +++---- app/test/test_service_cores.c | 9 +- app/test/test_thash.c | 7 +- config/meson.build | 4 + drivers/common/idpf/idpf_common_rxtx.c | 2 +- drivers/common/idpf/idpf_common_rxtx_avx512.c | 6 +- drivers/common/mlx5/mlx5_common.h | 4 +- drivers/common/mlx5/mlx5_devx_cmds.c | 7 +- drivers/net/i40e/i40e_testpmd.c | 5 +- drivers/net/ice/ice_rxtx.c | 2 +- drivers/net/ixgbe/ixgbe_ethdev.c | 5 +- drivers/net/ixgbe/ixgbe_rxtx_vec_common.h | 2 +- drivers/net/mlx5/mlx5.c | 5 +- drivers/net/mlx5/mlx5_flow.c | 6 +- lib/eal/common/eal_common_proc.c | 5 +- lib/eal/linux/eal_interrupts.c | 59 ++++++++- lib/eal/linux/include/rte_os.h | 1 + lib/eal/windows/include/rte_os.h | 1 + lib/ethdev/rte_ethdev.c | 183 ++++++++++++++++---------- lib/gro/rte_gro.c | 4 +- lib/hash/rte_cuckoo_hash.c | 4 +- lib/hash/rte_thash.c | 2 +- lib/hash/rte_thash.h | 8 ++ lib/latencystats/rte_latencystats.c | 2 +- lib/lpm/rte_lpm.h | 2 +- lib/rcu/rte_rcu_qsbr.c | 7 +- lib/rcu/rte_rcu_qsbr.h | 5 + 40 files changed, 314 insertions(+), 198 deletions(-) -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v2 01/19] eal: include header required for alloca 2024-04-18 20:02 ` [PATCH v2 00/19] remove use of VLAs for Windows Tyler Retzlaff @ 2024-04-18 20:02 ` Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 02/19] eal/linux: remove use of VLAs Tyler Retzlaff ` (17 subsequent siblings) 18 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-18 20:02 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang Include alloca.h for Linux and malloc.h for Windows to get declaration of alloca(). Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- lib/eal/linux/include/rte_os.h | 1 + lib/eal/windows/include/rte_os.h | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/eal/linux/include/rte_os.h b/lib/eal/linux/include/rte_os.h index c72bf5b..18ee404 100644 --- a/lib/eal/linux/include/rte_os.h +++ b/lib/eal/linux/include/rte_os.h @@ -14,6 +14,7 @@ * which is not supported natively or named differently in Linux. */ +#include <alloca.h> #include <sched.h> #include <sys/queue.h> diff --git a/lib/eal/windows/include/rte_os.h b/lib/eal/windows/include/rte_os.h index 1c33058..5c9c542 100644 --- a/lib/eal/windows/include/rte_os.h +++ b/lib/eal/windows/include/rte_os.h @@ -13,6 +13,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <malloc.h> #include <sched.h> -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v2 02/19] eal/linux: remove use of VLAs 2024-04-18 20:02 ` [PATCH v2 00/19] remove use of VLAs for Windows Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 01/19] eal: include header required for alloca Tyler Retzlaff @ 2024-04-18 20:02 ` Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 03/19] eal/common: " Tyler Retzlaff ` (16 subsequent siblings) 18 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-18 20:02 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Konstantin Ananyev From: Konstantin Ananyev <konstantin.ananyev@huawei.com> 1) ./lib/eal/linux/eal_interrupts.c:1073:16 : warning: ISO C90 forbids variable length array ‘events’ eal_intr_handle_interrupts() is called by eal_intr_thread_main() so it seems ok to simply alloc space for events from heap and reuse the same buffer through the life of the thread. 2) ./lib/eal/linux/eal_interrupts.c:1319:16 : warning: ISO C90 forbids variable length array ‘evs’ make eal_epoll_wait() to use fixed size array and use it though multiple iterations to preocess upt to @maxevents events. Note that techically it is not one to one raplacement, as here we might reduce number of events returned by first call to epoll_wait(..., timeout); Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> --- lib/eal/linux/eal_interrupts.c | 59 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 7 deletions(-) diff --git a/lib/eal/linux/eal_interrupts.c b/lib/eal/linux/eal_interrupts.c index 6436f79..58e3b8e 100644 --- a/lib/eal/linux/eal_interrupts.c +++ b/lib/eal/linux/eal_interrupts.c @@ -34,6 +34,8 @@ #define EAL_INTR_EPOLL_WAIT_FOREVER (-1) #define NB_OTHER_INTR 1 +#define MAX_ITER_EVNUM RTE_EVENT_ETH_INTR_RING_SIZE + static RTE_DEFINE_PER_LCORE(int, _epfd) = -1; /**< epoll fd per thread */ /** @@ -1068,9 +1070,9 @@ struct rte_intr_source { * void */ static void -eal_intr_handle_interrupts(int pfd, unsigned totalfds) +eal_intr_handle_interrupts(int pfd, struct epoll_event events[], + unsigned totalfds) { - struct epoll_event events[totalfds]; int nfds = 0; for(;;) { @@ -1106,6 +1108,12 @@ struct rte_intr_source { static __rte_noreturn uint32_t eal_intr_thread_main(__rte_unused void *arg) { + uint32_t n, nb_event; + struct epoll_event *events, *p; + + nb_event = 0; + events = NULL; + /* host thread, never break out */ for (;;) { /* build up the epoll fd with all descriptors we are to @@ -1159,8 +1167,23 @@ struct rte_intr_source { numfds++; } rte_spinlock_unlock(&intr_lock); + + /* alloc space for events, when necessary */ + if (numfds > nb_event) { + n = numfds + MAX_ITER_EVNUM; + p = realloc(events, n * sizeof(events[0])); + if (p == NULL) { + EAL_LOG(ERR, "failed to allocate %u events", + numfds); + numfds = nb_event; + } else { + nb_event = n; + events = p; + } + } + /* serve the interrupt */ - eal_intr_handle_interrupts(pfd, numfds); + eal_intr_handle_interrupts(pfd, events, numfds); /** * when we return, we need to rebuild the @@ -1168,6 +1191,8 @@ struct rte_intr_source { */ close(pfd); } + + free(events); } int @@ -1316,8 +1341,9 @@ struct rte_intr_source { eal_epoll_wait(int epfd, struct rte_epoll_event *events, int maxevents, int timeout, bool interruptible) { - struct epoll_event evs[maxevents]; int rc; + uint32_t i, k, n, num; + struct epoll_event evs[MAX_ITER_EVNUM]; if (!events) { EAL_LOG(ERR, "rte_epoll_event can't be NULL"); @@ -1328,12 +1354,31 @@ struct rte_intr_source { if (epfd == RTE_EPOLL_PER_THREAD) epfd = rte_intr_tls_epfd(); + num = maxevents; + n = RTE_MIN(RTE_DIM(evs), num); + + /* Process events in chunks of MAX_ITER_EVNUM */ + while (1) { - rc = epoll_wait(epfd, evs, maxevents, timeout); + rc = epoll_wait(epfd, evs, n, timeout); if (likely(rc > 0)) { + /* epoll_wait has at least one fd ready to read */ - rc = eal_epoll_process_event(evs, rc, events); - break; + for (i = 0, k = 0; rc > 0;) { + k += rc; + rc = eal_epoll_process_event(evs, rc, + events + i); + i += rc; + + /* + * try to read more events that are already + * available (up to maxevents in total). + */ + n = RTE_MIN(RTE_DIM(evs), num - k); + rc = (n == 0) ? 0 : epoll_wait(epfd, evs, n, 0); + } + return i; + } else if (rc < 0) { if (errno == EINTR) { if (interruptible) -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v2 03/19] eal/common: remove use of VLAs 2024-04-18 20:02 ` [PATCH v2 00/19] remove use of VLAs for Windows Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 01/19] eal: include header required for alloca Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 02/19] eal/linux: remove use of VLAs Tyler Retzlaff @ 2024-04-18 20:02 ` Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 04/19] ethdev: remove use of VLAs for Windows built code Tyler Retzlaff ` (15 subsequent siblings) 18 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-18 20:02 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Konstantin Ananyev From: Konstantin Ananyev <konstantin.ananyev@huawei.com> 1) ../lib/eal/common/eal_common_proc.c:695:15 : warning: variable length array used As msg->num_fds should not exceed RTE_MP_MAX_FD_NUM, replaced it with fixed size array. Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> --- lib/eal/common/eal_common_proc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/eal/common/eal_common_proc.c b/lib/eal/common/eal_common_proc.c index d240939..f21ce60 100644 --- a/lib/eal/common/eal_common_proc.c +++ b/lib/eal/common/eal_common_proc.c @@ -692,7 +692,8 @@ enum async_action { struct sockaddr_un dst; struct mp_msg_internal m; int fd_size = msg->num_fds * sizeof(int); - char control[CMSG_SPACE(fd_size)]; + int32_t control_sz = CMSG_SPACE(fd_size); + char control[CMSG_SPACE(sizeof(msg->fds))]; m.type = type; memcpy(&m.msg, msg, sizeof(*msg)); @@ -712,7 +713,7 @@ enum async_action { msgh.msg_iov = &iov; msgh.msg_iovlen = 1; msgh.msg_control = control; - msgh.msg_controllen = sizeof(control); + msgh.msg_controllen = control_sz; cmsg = CMSG_FIRSTHDR(&msgh); cmsg->cmsg_len = CMSG_LEN(fd_size); -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v2 04/19] ethdev: remove use of VLAs for Windows built code 2024-04-18 20:02 ` [PATCH v2 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (2 preceding siblings ...) 2024-04-18 20:02 ` [PATCH v2 03/19] eal/common: " Tyler Retzlaff @ 2024-04-18 20:02 ` Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 05/19] hash: " Tyler Retzlaff ` (14 subsequent siblings) 18 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-18 20:02 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Konstantin Ananyev From: Konstantin Ananyev <konstantin.ananyev@huawei.com> 1) ./lib/ethdev/rte_ethdev.c:3244:16 : warning: ISO C90 forbids variable length array ‘xstats_names’ 2) ./lib/ethdev/rte_ethdev.c:3345:17 : warning: ISO C90 forbids variable length array ‘ids_copy’ 3) ./lib/ethdev/rte_ethdev.c:3538:16 : warning: ISO C90 forbids variable length array ‘xstats’ 4) ./lib/ethdev/rte_ethdev.c:3554:17 : warning: ISO C90 forbids variable length array ‘ids_copy’ For 1) and 3) - just replaced VLA with arrays allocated from heap. As I understand xstats extraction belongs to control-path, so extra calloc/free is hopefully acceptable. Also ethdev xstats already doing that within rte_eth_xstats_get_id_by_name(). For 2) and 4) changed the code to use fixed size array and call appropriate devops function several times, if needed. Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> --- lib/ethdev/rte_ethdev.c | 183 ++++++++++++++++++++++++++++++------------------ 1 file changed, 113 insertions(+), 70 deletions(-) diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index f1c658f..e462f3d 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -36,6 +36,8 @@ #include "ethdev_trace.h" #include "sff_telemetry.h" +#define ETH_XSTATS_ITER_NUM 0x100 + struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS]; /* public fast-path API */ @@ -3215,7 +3217,8 @@ enum { rte_eth_xstats_get_id_by_name(uint16_t port_id, const char *xstat_name, uint64_t *id) { - int cnt_xstats, idx_xstat; + int cnt_xstats, idx_xstat, rc; + struct rte_eth_xstat_name *xstats_names; RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); @@ -3241,26 +3244,33 @@ enum { } /* Get id-name lookup table */ - struct rte_eth_xstat_name xstats_names[cnt_xstats]; + xstats_names = calloc(cnt_xstats, sizeof(xstats_names[0])); + if (xstats_names == NULL) { + RTE_ETHDEV_LOG_LINE(ERR, "Can't allocate memory"); + return -ENOMEM; + } if (cnt_xstats != rte_eth_xstats_get_names_by_id( port_id, xstats_names, cnt_xstats, NULL)) { RTE_ETHDEV_LOG_LINE(ERR, "Cannot get xstats lookup"); + free(xstats_names); return -1; } + rc = -EINVAL; for (idx_xstat = 0; idx_xstat < cnt_xstats; idx_xstat++) { if (!strcmp(xstats_names[idx_xstat].name, xstat_name)) { *id = idx_xstat; rte_eth_trace_xstats_get_id_by_name(port_id, xstat_name, *id); - - return 0; + rc = 0; + break; }; } - return -EINVAL; + free(xstats_names); + return rc; } /* retrieve basic stats names */ @@ -3306,6 +3316,38 @@ enum { return cnt_used_entries; } +static int +eth_xstats_get_by_name_by_id(struct rte_eth_dev *dev, const uint64_t *ids, + struct rte_eth_xstat_name *xstats_names, uint32_t size, + uint32_t basic_count) +{ + int32_t rc; + uint32_t i, k, m, n; + uint64_t ids_copy[ETH_XSTATS_ITER_NUM]; + + m = 0; + for (n = 0; n != size; n += k) { + + k = RTE_MIN(size - n, RTE_DIM(ids_copy)); + + /* + * Convert ids to xstats ids that PMD knows. + * ids known by user are basic + extended stats. + */ + for (i = 0; i < k; i++) + ids_copy[i] = ids[n + i] - basic_count; + + rc = (*dev->dev_ops->xstats_get_names_by_id)(dev, ids_copy, + xstats_names + m, k); + if (rc < 0) + return rc; + m += rc; + } + + return m; +} + + /* retrieve ethdev extended statistics names */ int rte_eth_xstats_get_names_by_id(uint16_t port_id, @@ -3313,9 +3355,8 @@ enum { uint64_t *ids) { struct rte_eth_xstat_name *xstats_names_copy; - unsigned int no_basic_stat_requested = 1; - unsigned int no_ext_stat_requested = 1; unsigned int expected_entries; + unsigned int nb_basic_stats; unsigned int basic_count; struct rte_eth_dev *dev; unsigned int i; @@ -3341,27 +3382,18 @@ enum { if (ids && !xstats_names) return -EINVAL; - if (ids && dev->dev_ops->xstats_get_names_by_id != NULL && size > 0) { - uint64_t ids_copy[size]; - - for (i = 0; i < size; i++) { - if (ids[i] < basic_count) { - no_basic_stat_requested = 0; - break; - } - - /* - * Convert ids to xstats ids that PMD knows. - * ids known by user are basic + extended stats. - */ - ids_copy[i] = ids[i] - basic_count; - } - - if (no_basic_stat_requested) - return (*dev->dev_ops->xstats_get_names_by_id)(dev, - ids_copy, xstats_names, size); + nb_basic_stats = 0; + if (ids != NULL) { + for (i = 0; i < size; i++) + nb_basic_stats += (ids[i] < basic_count); } + /* no baisc stats requested, devops function provided */ + if (nb_basic_stats == 0 && ids != NULL && size != 0 && + dev->dev_ops->xstats_get_names_by_id != NULL) + return eth_xstats_get_by_name_by_id(dev, ids, xstats_names, + size, basic_count); + /* Retrieve all stats */ if (!ids) { int num_stats = rte_eth_xstats_get_names(port_id, xstats_names, @@ -3380,17 +3412,8 @@ enum { return -ENOMEM; } - if (ids) { - for (i = 0; i < size; i++) { - if (ids[i] >= basic_count) { - no_ext_stat_requested = 0; - break; - } - } - } - /* Fill xstats_names_copy structure */ - if (ids && no_ext_stat_requested) { + if (ids && nb_basic_stats == size) { eth_basic_stats_get_names(dev, xstats_names_copy); } else { ret = rte_eth_xstats_get_names(port_id, xstats_names_copy, @@ -3514,17 +3537,47 @@ enum { return count; } +static int +eth_xtats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, + uint64_t *values, uint32_t size, uint32_t basic_count) +{ + int32_t rc; + uint32_t i, k, m, n; + uint64_t ids_copy[ETH_XSTATS_ITER_NUM]; + + m = 0; + for (n = 0; n != size; n += k) { + + k = RTE_MIN(size - n, RTE_DIM(ids_copy)); + + /* + * Convert ids to xstats ids that PMD knows. + * ids known by user are basic + extended stats. + */ + for (i = 0; i < k; i++) + ids_copy[i] = ids[n + i] - basic_count; + + rc = (*dev->dev_ops->xstats_get_by_id)(dev, ids_copy, + values + m, k); + if (rc < 0) + return rc; + m += rc; + } + + return m; +} + /* retrieve ethdev extended statistics */ int rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids, uint64_t *values, unsigned int size) { - unsigned int no_basic_stat_requested = 1; - unsigned int no_ext_stat_requested = 1; + unsigned int nb_basic_stats; unsigned int num_xstats_filled; unsigned int basic_count; uint16_t expected_entries; struct rte_eth_dev *dev; + struct rte_eth_xstat *xstats; unsigned int i; int ret; @@ -3535,7 +3588,6 @@ enum { if (ret < 0) return ret; expected_entries = (uint16_t)ret; - struct rte_eth_xstat xstats[expected_entries]; basic_count = eth_dev_get_xstats_basic_count(dev); /* Return max number of stats if no ids given */ @@ -3549,51 +3601,41 @@ enum { if (ids && !values) return -EINVAL; - if (ids && dev->dev_ops->xstats_get_by_id != NULL && size) { - unsigned int basic_count = eth_dev_get_xstats_basic_count(dev); - uint64_t ids_copy[size]; - - for (i = 0; i < size; i++) { - if (ids[i] < basic_count) { - no_basic_stat_requested = 0; - break; - } - - /* - * Convert ids to xstats ids that PMD knows. - * ids known by user are basic + extended stats. - */ - ids_copy[i] = ids[i] - basic_count; - } - - if (no_basic_stat_requested) - return (*dev->dev_ops->xstats_get_by_id)(dev, ids_copy, - values, size); + nb_basic_stats = 0; + if (ids != NULL) { + for (i = 0; i < size; i++) + nb_basic_stats += (ids[i] < basic_count); } - if (ids) { - for (i = 0; i < size; i++) { - if (ids[i] >= basic_count) { - no_ext_stat_requested = 0; - break; - } - } + /* no baisc stats requested, devops function provided */ + if (nb_basic_stats == 0 && ids != NULL && size != 0 && + dev->dev_ops->xstats_get_by_id != NULL) + return eth_xtats_get_by_id(dev, ids, values, size, basic_count); + + xstats = calloc(expected_entries, sizeof(xstats[0])); + if (xstats == NULL) { + RTE_ETHDEV_LOG_LINE(ERR, "Can't allocate memory"); + return -ENOMEM; } /* Fill the xstats structure */ - if (ids && no_ext_stat_requested) + if (ids && nb_basic_stats == size) ret = eth_basic_stats_get(port_id, xstats); else ret = rte_eth_xstats_get(port_id, xstats, expected_entries); - if (ret < 0) + if (ret < 0) { + free(xstats); return ret; + } num_xstats_filled = (unsigned int)ret; /* Return all stats */ if (!ids) { for (i = 0; i < num_xstats_filled; i++) values[i] = xstats[i].value; + + free(xstats); return expected_entries; } @@ -3601,14 +3643,15 @@ enum { for (i = 0; i < size; i++) { if (ids[i] >= expected_entries) { RTE_ETHDEV_LOG_LINE(ERR, "Id value isn't valid"); - return -1; + break; } values[i] = xstats[ids[i]].value; } rte_eth_trace_xstats_get_by_id(port_id, ids, values, size); - return size; + free(xstats); + return (i == size) ? (int32_t)size : -1; } int -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v2 05/19] hash: remove use of VLAs for Windows built code 2024-04-18 20:02 ` [PATCH v2 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (3 preceding siblings ...) 2024-04-18 20:02 ` [PATCH v2 04/19] ethdev: remove use of VLAs for Windows built code Tyler Retzlaff @ 2024-04-18 20:02 ` Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 06/19] hash/thash: " Tyler Retzlaff ` (13 subsequent siblings) 18 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-18 20:02 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Konstantin Ananyev From: Konstantin Ananyev <konstantin.ananyev@huawei.com> 1) ./lib/hash/rte_cuckoo_hash.c:2362:9 : warning: ISO C90 forbids variable length array ‘positions’ 2) ../lib/hash/rte_cuckoo_hash.c:2478:9 : warning: ISO C90 forbids variable length array ‘positions’ Both rte_hash_lookup_bulk_data() and rte_hash_lookup_with_hash_bulk_data() expect @num_keys <= RTE_HASH_LOOKUP_BULK_MAX. So, for both cases it should be safe to replace VLA with fixed size array. Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> --- lib/hash/rte_cuckoo_hash.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c index 9cf9464..82b74bd 100644 --- a/lib/hash/rte_cuckoo_hash.c +++ b/lib/hash/rte_cuckoo_hash.c @@ -2359,7 +2359,7 @@ struct rte_hash * (num_keys > RTE_HASH_LOOKUP_BULK_MAX) || (hit_mask == NULL)), -EINVAL); - int32_t positions[num_keys]; + int32_t positions[RTE_HASH_LOOKUP_BULK_MAX]; __rte_hash_lookup_bulk(h, keys, num_keys, positions, hit_mask, data); @@ -2475,7 +2475,7 @@ struct rte_hash * (num_keys > RTE_HASH_LOOKUP_BULK_MAX) || (hit_mask == NULL)), -EINVAL); - int32_t positions[num_keys]; + int32_t positions[RTE_HASH_LOOKUP_BULK_MAX]; __rte_hash_lookup_with_hash_bulk(h, keys, sig, num_keys, positions, hit_mask, data); -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v2 06/19] hash/thash: remove use of VLAs for Windows built code 2024-04-18 20:02 ` [PATCH v2 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (4 preceding siblings ...) 2024-04-18 20:02 ` [PATCH v2 05/19] hash: " Tyler Retzlaff @ 2024-04-18 20:02 ` Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 07/19] rcu: " Tyler Retzlaff ` (12 subsequent siblings) 18 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-18 20:02 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Konstantin Ananyev From: Konstantin Ananyev <konstantin.ananyev@huawei.com> 1) ./lib/hash/rte_thash.c:774:9 : warning: ISO C90 forbids variable length array ‘tmp_tuple’ [-Wvla] From my understanding, tuple size here should never exceed sizeof(union rte_thash_tuple), so it should be safe to replace VLA with fixed size array. Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> --- lib/hash/rte_thash.c | 2 +- lib/hash/rte_thash.h | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c index 68f653f..e28d423 100644 --- a/lib/hash/rte_thash.c +++ b/lib/hash/rte_thash.c @@ -771,7 +771,7 @@ struct rte_thash_subtuple_helper * uint32_t desired_value, unsigned int attempts, rte_thash_check_tuple_t fn, void *userdata) { - uint32_t tmp_tuple[tuple_len / sizeof(uint32_t)]; + uint32_t tmp_tuple[RTE_THASH_MAX_L4_LEN]; unsigned int i, j, ret = 0; uint32_t hash, adj_bits; const uint8_t *hash_key; diff --git a/lib/hash/rte_thash.h b/lib/hash/rte_thash.h index 30b657e..322fe3a 100644 --- a/lib/hash/rte_thash.h +++ b/lib/hash/rte_thash.h @@ -109,6 +109,14 @@ union __rte_aligned(XMM_SIZE) rte_thash_tuple { }; /** + * maximum length in dwords of input tuple to + * calculate hash of ipv(4|6) header + + * transport header + */ +#define RTE_THASH_MAX_L4_LEN \ + ((sizeof(union rte_thash_tuple)) / sizeof(uint32_t)) + +/** * Prepare special converted key to use with rte_softrss_be() * @param orig * pointer to original RSS key -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v2 07/19] rcu: remove use of VLAs for Windows built code 2024-04-18 20:02 ` [PATCH v2 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (5 preceding siblings ...) 2024-04-18 20:02 ` [PATCH v2 06/19] hash/thash: " Tyler Retzlaff @ 2024-04-18 20:02 ` Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 08/19] gro: " Tyler Retzlaff ` (11 subsequent siblings) 18 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-18 20:02 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Konstantin Ananyev From: Konstantin Ananyev <konstantin.ananyev@huawei.com> 1) ./lib/rcu/rte_rcu_qsbr.c:359:9 : warning: ISO C90 forbids variable length array ‘data’ [-Wvla] 2) ./lib/rcu/rte_rcu_qsbr.c:422:9 : warning: ISO C90 forbids variable length array ‘data’ [-Wvla] In both cases we allocate VLA for one element from RCU deferred queue. Right now, size of element in RCU queue is not limited by API. The approach is to introduce some reasonable limitation on RCU DQ element size. Choose 128B for now. With that in place we can replace both VLA occurencies with fixed size array. Note that such change need to be treated as API change. So can be applied only at 24.11. Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> --- lib/rcu/rte_rcu_qsbr.c | 7 ++++--- lib/rcu/rte_rcu_qsbr.h | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/rcu/rte_rcu_qsbr.c b/lib/rcu/rte_rcu_qsbr.c index f08d974..6800ef0 100644 --- a/lib/rcu/rte_rcu_qsbr.c +++ b/lib/rcu/rte_rcu_qsbr.c @@ -278,7 +278,8 @@ struct rte_rcu_qsbr_dq * if (params == NULL || params->free_fn == NULL || params->v == NULL || params->name == NULL || params->size == 0 || params->esize == 0 || - (params->esize % 4 != 0)) { + (params->esize % 4 != 0) || + params->esize > RTE_QSBR_ESIZE_MAX) { RCU_LOG(ERR, "Invalid input parameter"); rte_errno = EINVAL; @@ -356,7 +357,7 @@ int rte_rcu_qsbr_dq_enqueue(struct rte_rcu_qsbr_dq *dq, void *e) return 1; } - char data[dq->esize]; + char data[RTE_QSBR_ESIZE_MAX + __RTE_QSBR_TOKEN_SIZE]; dq_elem = (__rte_rcu_qsbr_dq_elem_t *)data; /* Start the grace period */ dq_elem->token = rte_rcu_qsbr_start(dq->v); @@ -419,7 +420,7 @@ int rte_rcu_qsbr_dq_enqueue(struct rte_rcu_qsbr_dq *dq, void *e) cnt = 0; - char data[dq->esize]; + char data[RTE_QSBR_ESIZE_MAX + __RTE_QSBR_TOKEN_SIZE]; /* Check reader threads quiescent state and reclaim resources */ while (cnt < n && rte_ring_dequeue_bulk_elem_start(dq->r, &data, diff --git a/lib/rcu/rte_rcu_qsbr.h b/lib/rcu/rte_rcu_qsbr.h index 0506191..892e5a3 100644 --- a/lib/rcu/rte_rcu_qsbr.h +++ b/lib/rcu/rte_rcu_qsbr.h @@ -86,6 +86,11 @@ struct __rte_cache_aligned rte_rcu_qsbr_cnt { #define __RTE_QSBR_CNT_MAX ((uint64_t)~0) #define __RTE_QSBR_TOKEN_SIZE sizeof(uint64_t) +/** + * Max allowable size (in bytes) of each element in the defer queue + */ +#define RTE_QSBR_ESIZE_MAX (2 * RTE_CACHE_LINE_MIN_SIZE) + /* RTE Quiescent State variable structure. * This structure has two elements that vary in size based on the * 'max_threads' parameter. -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v2 08/19] gro: remove use of VLAs for Windows built code 2024-04-18 20:02 ` [PATCH v2 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (6 preceding siblings ...) 2024-04-18 20:02 ` [PATCH v2 07/19] rcu: " Tyler Retzlaff @ 2024-04-18 20:02 ` Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 09/19] latencystats: " Tyler Retzlaff ` (10 subsequent siblings) 18 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-18 20:02 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- lib/gro/rte_gro.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/gro/rte_gro.c b/lib/gro/rte_gro.c index d824eeb..0f9e85c 100644 --- a/lib/gro/rte_gro.c +++ b/lib/gro/rte_gro.c @@ -179,7 +179,7 @@ struct gro_ctx { struct gro_vxlan_udp4_item vxlan_udp_items[RTE_GRO_MAX_BURST_ITEM_NUM] = {{{0}} }; - struct rte_mbuf *unprocess_pkts[nb_pkts]; + struct rte_mbuf **unprocess_pkts = alloca(sizeof(struct rte_mbuf *) * nb_pkts); uint32_t item_num; int32_t ret; uint16_t i, unprocess_num = 0, nb_after_gro = nb_pkts; @@ -360,7 +360,7 @@ struct gro_ctx { uint16_t nb_pkts, void *ctx) { - struct rte_mbuf *unprocess_pkts[nb_pkts]; + struct rte_mbuf **unprocess_pkts = alloca(sizeof(struct rte_mbuf *) * nb_pkts); struct gro_ctx *gro_ctx = ctx; void *tcp_tbl, *udp_tbl, *vxlan_tcp_tbl, *vxlan_udp_tbl, *tcp6_tbl; uint64_t current_time; -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v2 09/19] latencystats: remove use of VLAs for Windows built code 2024-04-18 20:02 ` [PATCH v2 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (7 preceding siblings ...) 2024-04-18 20:02 ` [PATCH v2 08/19] gro: " Tyler Retzlaff @ 2024-04-18 20:02 ` Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 10/19] lpm: " Tyler Retzlaff ` (9 subsequent siblings) 18 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-18 20:02 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- lib/latencystats/rte_latencystats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/latencystats/rte_latencystats.c b/lib/latencystats/rte_latencystats.c index 4ea9b0d..f59a9eb 100644 --- a/lib/latencystats/rte_latencystats.c +++ b/lib/latencystats/rte_latencystats.c @@ -159,7 +159,7 @@ struct latency_stats_nameoff { { unsigned int i, cnt = 0; uint64_t now; - float latency[nb_pkts]; + float *latency = alloca(sizeof(float) * nb_pkts); static float prev_latency; /* * Alpha represents degree of weighting decrease in EWMA, -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v2 10/19] lpm: remove use of VLAs for Windows built code 2024-04-18 20:02 ` [PATCH v2 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (8 preceding siblings ...) 2024-04-18 20:02 ` [PATCH v2 09/19] latencystats: " Tyler Retzlaff @ 2024-04-18 20:02 ` Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 11/19] app/testpmd: " Tyler Retzlaff ` (8 subsequent siblings) 18 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-18 20:02 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- lib/lpm/rte_lpm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lpm/rte_lpm.h b/lib/lpm/rte_lpm.h index 2888e5f..fc5805c 100644 --- a/lib/lpm/rte_lpm.h +++ b/lib/lpm/rte_lpm.h @@ -337,7 +337,7 @@ struct rte_lpm * uint32_t *next_hops, const unsigned n) { unsigned i; - unsigned tbl24_indexes[n]; + unsigned int *tbl24_indexes = (unsigned int *)alloca(sizeof(unsigned int) * n); const uint32_t *ptbl; /* DEBUG: Check user input arguments. */ -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v2 11/19] app/testpmd: remove use of VLAs for Windows built code 2024-04-18 20:02 ` [PATCH v2 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (9 preceding siblings ...) 2024-04-18 20:02 ` [PATCH v2 10/19] lpm: " Tyler Retzlaff @ 2024-04-18 20:02 ` Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 12/19] test: " Tyler Retzlaff ` (7 subsequent siblings) 18 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-18 20:02 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- app/test-pmd/cmdline.c | 2 +- app/test-pmd/cmdline_flow.c | 9 ++++----- app/test-pmd/config.c | 16 +++++++++------- app/test-pmd/shared_rxq_fwd.c | 2 +- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index b7759e3..dee8f5f 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -12902,7 +12902,7 @@ struct cmd_set_port_ptypes_result { return; } - uint32_t ptypes[ret]; + uint32_t *ptypes = alloca(sizeof(uint32_t) * ret); ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret); if (ret < 0) { diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 60ee933..a4fe8d9 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -11546,8 +11546,7 @@ struct indlst_conf { char tmp[16]; /* Ought to be enough. */ int ret; unsigned int hexlen = len; - unsigned int length = 256; - uint8_t hex_tmp[length]; + uint8_t hex_tmp[256]; /* Arguments are expected. */ if (!arg_data) @@ -11574,7 +11573,7 @@ struct indlst_conf { str += 2; hexlen -= 2; } - if (hexlen > length) + if (hexlen > RTE_DIM(hex_tmp)) goto error; ret = parse_hex_string(str, hex_tmp, &hexlen); if (ret < 0) @@ -11707,7 +11706,7 @@ struct indlst_conf { void *buf, unsigned int size) { const struct arg *arg = pop_args(ctx); - char str2[len + 1]; + char *str2 = alloca(len + 1); struct in_addr tmp; int ret; @@ -11753,7 +11752,7 @@ struct indlst_conf { void *buf, unsigned int size) { const struct arg *arg = pop_args(ctx); - char str2[len + 1]; + char *str2 = alloca(len + 1); struct in6_addr tmp; int ret; diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index ba1007a..4dce6fa 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1760,7 +1760,8 @@ void port_flow_tunnel_create(portid_t port_id, const struct tunnel_ops *ops) { struct rte_port *port; struct rte_flow_error error; - const struct rte_flow_queue_attr *attr_list[nb_queue]; + const struct rte_flow_queue_attr **attr_list = + alloca(sizeof(struct rte_flow_queue_attr *) * nb_queue); int std_queue; if (port_id_is_invalid(port_id, ENABLED_WARN) || @@ -2577,10 +2578,10 @@ struct rte_flow_meter_policy * int ret; uint32_t i; struct rte_flow_error error; - struct rte_flow_pattern_template - *flow_pattern_templates[nb_pattern_templates]; - struct rte_flow_actions_template - *flow_actions_templates[nb_actions_templates]; + struct rte_flow_pattern_template **flow_pattern_templates = + alloca(sizeof(struct rte_flow_pattern_template *) * nb_pattern_templates); + struct rte_flow_actions_template **flow_actions_templates = + alloca(sizeof(struct rte_flow_actions_template *) * nb_actions_templates); if (port_id_is_invalid(port_id, ENABLED_WARN) || port_id == (portid_t)RTE_PORT_ALL) @@ -5460,7 +5461,7 @@ struct igb_ring_desc_16_bytes { char *end = NULL; int min, max; int value, i; - unsigned int marked[maxsize]; + unsigned int *marked = alloca(sizeof(unsigned int) * maxsize); if (list == NULL || values == NULL) return 0; @@ -7201,7 +7202,8 @@ static const char *get_ptype_str(uint32_t ptype) if (eth_dev_info_get_print_err(port_id, &dev_info)) return; - struct rte_ether_addr addr[dev_info.max_mac_addrs]; + struct rte_ether_addr *addr = + alloca(sizeof(struct rte_ether_addr) * dev_info.max_mac_addrs); rc = rte_eth_macaddrs_get(port_id, addr, dev_info.max_mac_addrs); if (rc < 0) return; diff --git a/app/test-pmd/shared_rxq_fwd.c b/app/test-pmd/shared_rxq_fwd.c index 623d62d..5d4ffff 100644 --- a/app/test-pmd/shared_rxq_fwd.c +++ b/app/test-pmd/shared_rxq_fwd.c @@ -92,7 +92,7 @@ static bool shared_rxq_fwd(struct fwd_stream *fs) { - struct rte_mbuf *pkts_burst[nb_pkt_per_burst]; + struct rte_mbuf **pkts_burst = alloca(sizeof(struct rte_mbuf *) * nb_pkt_per_burst); uint16_t nb_rx; nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst); -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v2 12/19] test: remove use of VLAs for Windows built code 2024-04-18 20:02 ` [PATCH v2 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (10 preceding siblings ...) 2024-04-18 20:02 ` [PATCH v2 11/19] app/testpmd: " Tyler Retzlaff @ 2024-04-18 20:02 ` Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 13/19] common/idpf: " Tyler Retzlaff ` (6 subsequent siblings) 18 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-18 20:02 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- app/test/test.c | 2 +- app/test/test_cmdline_string.c | 2 +- app/test/test_cryptodev.c | 32 +++++++++++------------ app/test/test_cryptodev_blockcipher.c | 4 +-- app/test/test_cryptodev_crosscheck.c | 2 +- app/test/test_dmadev.c | 9 ++++--- app/test/test_hash.c | 8 +++--- app/test/test_mempool.c | 25 +++++++++--------- app/test/test_reassembly_perf.c | 4 +-- app/test/test_reorder.c | 48 +++++++++++++++++++---------------- app/test/test_service_cores.c | 9 +++---- app/test/test_thash.c | 7 +++-- 12 files changed, 79 insertions(+), 73 deletions(-) diff --git a/app/test/test.c b/app/test/test.c index 680351f..fd653cb 100644 --- a/app/test/test.c +++ b/app/test/test.c @@ -105,7 +105,7 @@ main(int argc, char **argv) { struct cmdline *cl; - char *tests[argc]; /* store an array of tests to run */ + char **tests = alloca(sizeof(char *) * argc); /* store an array of tests to run */ int test_count = 0; int i; char *extra_args; diff --git a/app/test/test_cmdline_string.c b/app/test/test_cmdline_string.c index 97516c9..e1cf860 100644 --- a/app/test/test_cmdline_string.c +++ b/app/test/test_cmdline_string.c @@ -40,7 +40,7 @@ struct string_elt_str string_elt_strs[] = { #if (CMDLINE_TEST_BUFSIZE < STR_TOKEN_SIZE) \ || (CMDLINE_TEST_BUFSIZE < STR_MULTI_TOKEN_SIZE) #undef CMDLINE_TEST_BUFSIZE -#define CMDLINE_TEST_BUFSIZE RTE_MAX(STR_TOKEN_SIZE, STR_MULTI_TOKEN_SIZE) +#define CMDLINE_TEST_BUFSIZE RTE_MAX_T(STR_TOKEN_SIZE, STR_MULTI_TOKEN_SIZE, size_t) #endif struct string_nb_str { diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index 1703ebc..fead21b 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -2686,7 +2686,7 @@ struct crypto_unittest_params { enum rte_crypto_auth_operation op, enum rte_crypto_auth_algorithm algo) { - uint8_t hash_key[key_len]; + uint8_t *hash_key = alloca(key_len); struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -2722,7 +2722,7 @@ struct crypto_unittest_params { const uint8_t *key, const uint8_t key_len, uint8_t iv_len) { - uint8_t cipher_key[key_len]; + uint8_t *cipher_key = alloca(key_len); struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -2874,7 +2874,7 @@ struct crypto_unittest_params { const struct wireless_test_data *tdata) { const uint8_t key_len = tdata->key.len; - uint8_t cipher_auth_key[key_len]; + uint8_t *cipher_auth_key = alloca(key_len); struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -8878,7 +8878,7 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata) const uint16_t aad_len, const uint8_t auth_len, uint8_t iv_len) { - uint8_t aead_key[key_len]; + uint8_t *aead_key = alloca(key_len); struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -12849,7 +12849,7 @@ static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc, test_AES_GCM_auth_encryption_fail_aad_corrupt(void) { struct aead_test_data tdata; - uint8_t aad[gcm_test_case_7.aad.len]; + uint8_t *aad = alloca(gcm_test_case_7.aad.len); int res; RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n"); @@ -13238,7 +13238,7 @@ static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc, test_AES_GCM_auth_decryption_fail_aad_corrupt(void) { struct aead_test_data tdata; - uint8_t aad[gcm_test_case_7.aad.len]; + uint8_t *aad = alloca(gcm_test_case_7.aad.len); int res; memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data)); @@ -13490,7 +13490,7 @@ static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc, int retval; uint8_t *ciphertext, *auth_tag; uint16_t plaintext_pad_len; - uint8_t key[tdata->key.len + 1]; + uint8_t *key = alloca(tdata->key.len + 1); struct rte_cryptodev_info dev_info; rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); @@ -13592,7 +13592,7 @@ static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc, int retval; uint8_t *plaintext; - uint8_t key[tdata->key.len + 1]; + uint8_t *key = alloca(tdata->key.len + 1); struct rte_cryptodev_info dev_info; rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); @@ -14895,7 +14895,7 @@ static int create_gmac_session(uint8_t dev_id, const struct gmac_test_data *tdata, enum rte_crypto_auth_operation auth_op) { - uint8_t auth_key[tdata->key.len]; + uint8_t *auth_key = alloca(tdata->key.len); struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -15552,7 +15552,7 @@ struct test_crypto_vector { enum rte_crypto_auth_operation auth_op) { struct crypto_testsuite_params *ts_params = &testsuite_params; - uint8_t auth_key[reference->auth_key.len + 1]; + uint8_t *auth_key = alloca(reference->auth_key.len + 1); memcpy(auth_key, reference->auth_key.data, reference->auth_key.len); @@ -15583,8 +15583,8 @@ struct test_crypto_vector { enum rte_crypto_cipher_operation cipher_op) { struct crypto_testsuite_params *ts_params = &testsuite_params; - uint8_t cipher_key[reference->cipher_key.len + 1]; - uint8_t auth_key[reference->auth_key.len + 1]; + uint8_t *cipher_key = alloca(reference->cipher_key.len + 1); + uint8_t *auth_key = alloca(reference->auth_key.len + 1); memcpy(cipher_key, reference->cipher_key.data, reference->cipher_key.len); @@ -16084,8 +16084,8 @@ struct test_crypto_vector { uint8_t *authciphertext, *plaintext, *auth_tag; uint16_t plaintext_pad_len; - uint8_t cipher_key[reference->cipher_key.len + 1]; - uint8_t auth_key[reference->auth_key.len + 1]; + uint8_t *cipher_key = alloca(reference->cipher_key.len + 1); + uint8_t *auth_key = alloca(reference->auth_key.len + 1); struct rte_cryptodev_info dev_info; rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); @@ -16216,8 +16216,8 @@ struct test_crypto_vector { int retval; uint8_t *ciphertext; - uint8_t cipher_key[reference->cipher_key.len + 1]; - uint8_t auth_key[reference->auth_key.len + 1]; + uint8_t *cipher_key = alloca(reference->cipher_key.len + 1); + uint8_t *auth_key = alloca(reference->auth_key.len + 1); struct rte_cryptodev_info dev_info; rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); diff --git a/app/test/test_cryptodev_blockcipher.c b/app/test/test_cryptodev_blockcipher.c index 87a321f..da7bf2c 100644 --- a/app/test/test_cryptodev_blockcipher.c +++ b/app/test/test_cryptodev_blockcipher.c @@ -85,8 +85,8 @@ int status = TEST_SUCCESS; const struct blockcipher_test_data *tdata = t->test_data; - uint8_t cipher_key[tdata->cipher_key.len]; - uint8_t auth_key[tdata->auth_key.len]; + uint8_t *cipher_key = alloca(tdata->cipher_key.len); + uint8_t *auth_key = alloca(tdata->auth_key.len); uint32_t buf_len = tdata->ciphertext.len; uint32_t digest_len = tdata->digest.len; char *buf_p = NULL; diff --git a/app/test/test_cryptodev_crosscheck.c b/app/test/test_cryptodev_crosscheck.c index c29b19c..b9a53a4 100644 --- a/app/test/test_cryptodev_crosscheck.c +++ b/app/test/test_cryptodev_crosscheck.c @@ -894,7 +894,7 @@ struct crosscheck_testsuite_params { crosscheck_with_profile_run(const struct crosscheck_test_profile *profile) { struct crosscheck_testsuite_params *ts_params = &testsuite_params; - uint8_t input_text[profile->input_buf_len]; + uint8_t *input_text = alloca(profile->input_buf_len); uint16_t output_len, encrypted_len; uint8_t encrypted_text[MBUF_SIZE]; uint8_t output_text[MBUF_SIZE]; diff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c index 143e1bc..9cbb9a6 100644 --- a/app/test/test_dmadev.c +++ b/app/test/test_dmadev.c @@ -417,9 +417,12 @@ struct runtest_param { dst_len = len / n_dst; src_len = len / n_src; - struct rte_dma_sge sg_src[n_sge], sg_dst[n_sge]; - struct rte_mbuf *src[n_sge], *dst[n_sge]; - char *src_data[n_sge], *dst_data[n_sge]; + struct rte_dma_sge *sg_src = alloca(sizeof(struct rte_dma_sge) * n_sge); + struct rte_dma_sge *sg_dst = alloca(sizeof(struct rte_dma_sge) * n_sge); + struct rte_mbuf **src = alloca(sizeof(struct rte_mbuf *) * n_sge); + struct rte_mbuf **dst = alloca(sizeof(struct rte_mbuf *) * n_sge); + char **src_data = alloca(sizeof(char *) * n_sge); + char **dst_data = alloca(sizeof(char *) * n_sge); for (i = 0 ; i < len; i++) orig_src[i] = rte_rand() & 0xFF; diff --git a/app/test/test_hash.c b/app/test/test_hash.c index d586878..65fd9e6 100644 --- a/app/test/test_hash.c +++ b/app/test/test_hash.c @@ -1930,8 +1930,8 @@ static int test_hash_iteration(uint32_t ext_table) .socket_id = 0, .extra_flag = hash_extra_flag, }; - int pos[total_entries]; - int expected_pos[total_entries]; + int *pos = alloca(sizeof(int) * total_entries); + int *expected_pos = alloca(sizeof(int) * total_entries); unsigned int i; size_t sz; int32_t status; @@ -2100,8 +2100,8 @@ static int test_hash_iteration(uint32_t ext_table) .socket_id = 0, .extra_flag = hash_extra_flag, }; - int pos[total_entries]; - int expected_pos[total_entries]; + int *pos = alloca(sizeof(int) * total_entries); + int *expected_pos = alloca(sizeof(int) * total_entries); unsigned int i; size_t sz; int32_t status; diff --git a/app/test/test_mempool.c b/app/test/test_mempool.c index ad7ebd6..4672795 100644 --- a/app/test/test_mempool.c +++ b/app/test/test_mempool.c @@ -515,19 +515,20 @@ struct test_mempool_events_data { #undef RTE_TEST_TRACE_FAILURE #define RTE_TEST_TRACE_FAILURE(...) do { goto fail; } while (0) - static const size_t callback_num = 3; - static const size_t mempool_num = 2; +#define CALLBACK_NUM 3u +#define MEMPOOL_NUM 2u + static const unsigned int mempool_elt_size = 64; static const unsigned int mempool_size = 64; - struct test_mempool_events_data data[callback_num]; - struct rte_mempool *mp[mempool_num], *freed; + struct test_mempool_events_data data[CALLBACK_NUM]; + struct rte_mempool *mp[MEMPOOL_NUM], *freed; char name[RTE_MEMPOOL_NAMESIZE]; size_t i, j; int ret; memset(mp, 0, sizeof(mp)); - for (i = 0; i < callback_num; i++) { + for (i = 0; i < CALLBACK_NUM; i++) { ret = rte_mempool_event_callback_register (test_mempool_events_cb, &data[i]); RTE_TEST_ASSERT_EQUAL(ret, 0, "Failed to register the callback %zu: %s", @@ -548,7 +549,7 @@ struct test_mempool_events_data { SOCKET_ID_ANY, 0); RTE_TEST_ASSERT_NOT_NULL(mp[0], "Cannot create mempool %s: %s", name, rte_strerror(rte_errno)); - for (j = 0; j < callback_num; j++) + for (j = 0; j < CALLBACK_NUM; j++) RTE_TEST_ASSERT_EQUAL(data[j].invoked, false, "Callback %zu invoked on %s mempool creation", j, name); @@ -557,7 +558,7 @@ struct test_mempool_events_data { ret = populate(mp[0]); RTE_TEST_ASSERT_EQUAL(ret, (int)mp[0]->size, "Failed to populate mempool %s: %s", name, rte_strerror(-ret)); - for (j = 0; j < callback_num; j++) { + for (j = 0; j < CALLBACK_NUM; j++) { RTE_TEST_ASSERT_EQUAL(data[j].invoked, true, "Callback %zu not invoked on mempool %s population", j, name); @@ -589,7 +590,7 @@ struct test_mempool_events_data { "Unregistered callback 0 invoked on %s mempool populaton", name); - for (i = 0; i < mempool_num; i++) { + for (i = 0; i < MEMPOOL_NUM; i++) { memset(&data, 0, sizeof(data)); sprintf(name, "empty%zu", i); rte_mempool_free(mp[i]); @@ -599,7 +600,7 @@ struct test_mempool_events_data { */ freed = mp[i]; mp[i] = NULL; - for (j = 1; j < callback_num; j++) { + for (j = 1; j < CALLBACK_NUM; j++) { RTE_TEST_ASSERT_EQUAL(data[j].invoked, true, "Callback %zu not invoked on mempool %s destruction", j, name); @@ -615,7 +616,7 @@ struct test_mempool_events_data { name); } - for (j = 1; j < callback_num; j++) { + for (j = 1; j < CALLBACK_NUM; j++) { ret = rte_mempool_event_callback_unregister (test_mempool_events_cb, &data[j]); RTE_TEST_ASSERT_EQUAL(ret, 0, "Failed to unregister the callback %zu: %s", @@ -624,10 +625,10 @@ struct test_mempool_events_data { return TEST_SUCCESS; fail: - for (j = 0; j < callback_num; j++) + for (j = 0; j < CALLBACK_NUM; j++) rte_mempool_event_callback_unregister (test_mempool_events_cb, &data[j]); - for (i = 0; i < mempool_num; i++) + for (i = 0; i < MEMPOOL_NUM; i++) rte_mempool_free(mp[i]); return TEST_FAILED; diff --git a/app/test/test_reassembly_perf.c b/app/test/test_reassembly_perf.c index 3912179..7f4ed31 100644 --- a/app/test/test_reassembly_perf.c +++ b/app/test/test_reassembly_perf.c @@ -604,7 +604,7 @@ for (j = 0; j < 4; j++) nb_frags += frag_per_flow[i + j]; - struct rte_mbuf *buf_arr[nb_frags]; + struct rte_mbuf **buf_arr = alloca(sizeof(struct rte_mbuf *) * nb_frags); for (j = 0; j < 4; j++) { join_array(buf_arr, mbufs[i + j], prev, frag_per_flow[i + j]); @@ -815,7 +815,7 @@ for (j = 0; j < 4; j++) nb_frags += frag_per_flow[i + j]; - struct rte_mbuf *buf_arr[nb_frags]; + struct rte_mbuf **buf_arr = alloca(sizeof(struct rte_mbuf *) * nb_frags); for (j = 0; j < 4; j++) { join_array(buf_arr, mbufs[i + j], prev, frag_per_flow[i + j]); diff --git a/app/test/test_reorder.c b/app/test/test_reorder.c index 501780c..aaa2c57 100644 --- a/app/test/test_reorder.c +++ b/app/test/test_reorder.c @@ -130,11 +130,12 @@ struct reorder_unittest_params { static int test_reorder_insert(void) { +#define INSERT_NUM_BUFS 7u + struct rte_reorder_buffer *b = NULL; struct rte_mempool *p = test_params->p; const unsigned int size = 4; - const unsigned int num_bufs = 7; - struct rte_mbuf *bufs[num_bufs]; + struct rte_mbuf *bufs[INSERT_NUM_BUFS]; int ret = 0; unsigned i; @@ -146,7 +147,7 @@ struct reorder_unittest_params { b = rte_reorder_create("test_insert", rte_socket_id(), size); TEST_ASSERT_NOT_NULL(b, "Failed to create reorder buffer"); - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < INSERT_NUM_BUFS; i++) { bufs[i] = rte_pktmbuf_alloc(p); TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n"); *rte_reorder_seqn(bufs[i]) = i; @@ -207,26 +208,27 @@ struct reorder_unittest_params { ret = 0; exit: rte_reorder_free(b); - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < INSERT_NUM_BUFS; i++) rte_pktmbuf_free(bufs[i]); - } + return ret; } static int test_reorder_drain(void) { +#define DRAIN_NUM_BUFS 8u + struct rte_reorder_buffer *b = NULL; struct rte_mempool *p = test_params->p; const unsigned int size = 4; - const unsigned int num_bufs = 8; - struct rte_mbuf *bufs[num_bufs]; - struct rte_mbuf *robufs[num_bufs]; + struct rte_mbuf *bufs[DRAIN_NUM_BUFS]; + struct rte_mbuf *robufs[DRAIN_NUM_BUFS]; int ret = 0; unsigned i, cnt; /* initialize all robufs to NULL */ - for (i = 0; i < num_bufs; i++) + for (i = 0; i < DRAIN_NUM_BUFS; i++) robufs[i] = NULL; /* This would create a reorder buffer instance consisting of: @@ -246,7 +248,7 @@ struct reorder_unittest_params { goto exit; } - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < DRAIN_NUM_BUFS; i++) { bufs[i] = rte_pktmbuf_alloc(p); TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n"); *rte_reorder_seqn(bufs[i]) = i; @@ -320,7 +322,7 @@ struct reorder_unittest_params { ret = 0; exit: rte_reorder_free(b); - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < DRAIN_NUM_BUFS; i++) { rte_pktmbuf_free(bufs[i]); rte_pktmbuf_free(robufs[i]); } @@ -337,15 +339,16 @@ struct reorder_unittest_params { static int test_reorder_drain_up_to_seqn(void) { +#define DRAIN_TO_NUM_BUFS 10u + struct rte_mempool *p = test_params->p; struct rte_reorder_buffer *b = NULL; - const unsigned int num_bufs = 10; const unsigned int size = 4; unsigned int i, cnt; int ret = 0; - struct rte_mbuf *bufs[num_bufs]; - struct rte_mbuf *robufs[num_bufs]; + struct rte_mbuf *bufs[DRAIN_TO_NUM_BUFS]; + struct rte_mbuf *robufs[DRAIN_TO_NUM_BUFS]; /* initialize all robufs to NULL */ memset(robufs, 0, sizeof(robufs)); @@ -358,7 +361,7 @@ struct reorder_unittest_params { b = rte_reorder_create("test_drain_up_to_seqn", rte_socket_id(), size); TEST_ASSERT_NOT_NULL(b, "Failed to create reorder buffer"); - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < DRAIN_TO_NUM_BUFS; i++) { bufs[i] = rte_pktmbuf_alloc(p); TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n"); *rte_reorder_seqn(bufs[i]) = i; @@ -372,7 +375,7 @@ struct reorder_unittest_params { buffer_to_reorder_move(&bufs[2], b); buffer_to_reorder_move(&bufs[3], b); /* Draining 1, 2 */ - cnt = rte_reorder_drain_up_to_seqn(b, robufs, num_bufs, 3); + cnt = rte_reorder_drain_up_to_seqn(b, robufs, DRAIN_TO_NUM_BUFS, 3); if (cnt != 2) { printf("%s:%d:%d: number of expected packets not drained\n", __func__, __LINE__, cnt); @@ -396,7 +399,7 @@ struct reorder_unittest_params { buffer_to_reorder_move(&bufs[8], b); /* Drain 3 and 5 */ - cnt = rte_reorder_drain_up_to_seqn(b, robufs, num_bufs, 6); + cnt = rte_reorder_drain_up_to_seqn(b, robufs, DRAIN_TO_NUM_BUFS, 6); if (cnt != 2) { printf("%s:%d:%d: number of expected packets not drained\n", __func__, __LINE__, cnt); @@ -410,7 +413,7 @@ struct reorder_unittest_params { ret = 0; exit: rte_reorder_free(b); - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < DRAIN_TO_NUM_BUFS; i++) { rte_pktmbuf_free(bufs[i]); rte_pktmbuf_free(robufs[i]); } @@ -420,14 +423,15 @@ struct reorder_unittest_params { static int test_reorder_set_seqn(void) { +#define SET_SEQN_NUM_BUFS 7u + struct rte_mempool *p = test_params->p; struct rte_reorder_buffer *b = NULL; - const unsigned int num_bufs = 7; const unsigned int size = 4; unsigned int i; int ret = 0; - struct rte_mbuf *bufs[num_bufs]; + struct rte_mbuf *bufs[SET_SEQN_NUM_BUFS]; /* This would create a reorder buffer instance consisting of: * reorder_seq = 0 @@ -437,7 +441,7 @@ struct reorder_unittest_params { b = rte_reorder_create("test_min_seqn_set", rte_socket_id(), size); TEST_ASSERT_NOT_NULL(b, "Failed to create reorder buffer"); - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < SET_SEQN_NUM_BUFS; i++) { bufs[i] = rte_pktmbuf_alloc(p); if (bufs[i] == NULL) { printf("Packet allocation failed\n"); @@ -479,7 +483,7 @@ struct reorder_unittest_params { ret = 0; exit: rte_reorder_free(b); - for (i = 0; i < num_bufs; i++) + for (i = 0; i < SET_SEQN_NUM_BUFS; i++) rte_pktmbuf_free(bufs[i]); return ret; diff --git a/app/test/test_service_cores.c b/app/test/test_service_cores.c index c12d52d..7c45733 100644 --- a/app/test/test_service_cores.c +++ b/app/test/test_service_cores.c @@ -561,9 +561,8 @@ static int32_t dummy_mt_safe_cb(void *args) "Service core count not equal to one"); /* retrieve core list, checking lcore ids */ - const uint32_t size = 4; - uint32_t service_core_ids[size]; - int32_t n = rte_service_lcore_list(service_core_ids, size); + uint32_t service_core_ids[4]; + int32_t n = rte_service_lcore_list(service_core_ids, RTE_DIM(service_core_ids)); TEST_ASSERT_EQUAL(1, n, "Service core list return should equal 1"); TEST_ASSERT_EQUAL(slcore_id, service_core_ids[0], "Service core list lcore must equal slcore_id"); @@ -589,7 +588,7 @@ static int32_t dummy_mt_safe_cb(void *args) cores_at_this_point); /* check longer service core list */ - n = rte_service_lcore_list(service_core_ids, size); + n = rte_service_lcore_list(service_core_ids, RTE_DIM(service_core_ids)); TEST_ASSERT_EQUAL(3, n, "Service core list return should equal 3"); TEST_ASSERT_EQUAL(slcore_id, service_core_ids[0], "Service core list[0] lcore must equal 1"); @@ -607,7 +606,7 @@ static int32_t dummy_mt_safe_cb(void *args) "Service core add did not return zero"); TEST_ASSERT_EQUAL(1, rte_service_lcore_count(), "Service core count not equal to one"); - n = rte_service_lcore_list(service_core_ids, size); + n = rte_service_lcore_list(service_core_ids, RTE_DIM(service_core_ids)); TEST_ASSERT_EQUAL(1, n, "Service core list return should equal one"); TEST_ASSERT_EQUAL(slcore_id, service_core_ids[0], "Service core list[0] lcore must equal %d", diff --git a/app/test/test_thash.c b/app/test/test_thash.c index 65d42fd..80d4106 100644 --- a/app/test/test_thash.c +++ b/app/test/test_thash.c @@ -576,9 +576,8 @@ enum { { struct rte_thash_ctx *ctx; struct rte_thash_subtuple_helper *h; - const int key_len = 40; int reta_sz = 6; - uint8_t initial_key[key_len]; + uint8_t initial_key[40]; const uint8_t *new_key; int ret; union rte_thash_tuple tuple; @@ -586,9 +585,9 @@ enum { unsigned int desired_value = 27 & HASH_MSK(reta_sz); uint16_t port_value = 22; - memset(initial_key, 0, key_len); + memset(initial_key, 0, RTE_DIM(initial_key)); - ctx = rte_thash_init_ctx("test", key_len, reta_sz, initial_key, + ctx = rte_thash_init_ctx("test", RTE_DIM(initial_key), reta_sz, initial_key, RTE_THASH_MINIMAL_SEQ); RTE_TEST_ASSERT(ctx != NULL, "can not create thash ctx\n"); -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v2 13/19] common/idpf: remove use of VLAs for Windows built code 2024-04-18 20:02 ` [PATCH v2 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (11 preceding siblings ...) 2024-04-18 20:02 ` [PATCH v2 12/19] test: " Tyler Retzlaff @ 2024-04-18 20:02 ` Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 14/19] net/i40e: " Tyler Retzlaff ` (5 subsequent siblings) 18 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-18 20:02 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- drivers/common/idpf/idpf_common_rxtx.c | 2 +- drivers/common/idpf/idpf_common_rxtx_avx512.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/common/idpf/idpf_common_rxtx.c b/drivers/common/idpf/idpf_common_rxtx.c index 83b131e..da24b78 100644 --- a/drivers/common/idpf/idpf_common_rxtx.c +++ b/drivers/common/idpf/idpf_common_rxtx.c @@ -569,7 +569,7 @@ uint16_t nb_refill = rx_bufq->rx_free_thresh; uint16_t nb_desc = rx_bufq->nb_rx_desc; uint16_t next_avail = rx_bufq->rx_tail; - struct rte_mbuf *nmb[rx_bufq->rx_free_thresh]; + struct rte_mbuf **nmb = alloca(sizeof(struct rte_mbuf *) * rx_bufq->rx_free_thresh); uint64_t dma_addr; uint16_t delta; int i; diff --git a/drivers/common/idpf/idpf_common_rxtx_avx512.c b/drivers/common/idpf/idpf_common_rxtx_avx512.c index f65e8d5..9131bd6 100644 --- a/drivers/common/idpf/idpf_common_rxtx_avx512.c +++ b/drivers/common/idpf/idpf_common_rxtx_avx512.c @@ -1002,7 +1002,8 @@ uint32_t n; uint32_t i; int nb_free = 0; - struct rte_mbuf *m, *free[txq->rs_thresh]; + struct rte_mbuf *m; + struct rte_mbuf **free = alloca(sizeof(struct rte_mbuf *) * txq->rs_thresh); /* check DD bits on threshold descriptor */ if ((txq->tx_ring[txq->next_dd].qw1 & @@ -1319,7 +1320,8 @@ uint32_t n; uint32_t i; int nb_free = 0; - struct rte_mbuf *m, *free[txq->rs_thresh]; + struct rte_mbuf *m; + struct rte_mbuf **free = alloca(sizeof(struct rte_mbuf *) * txq->rs_thresh); n = txq->rs_thresh; -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v2 14/19] net/i40e: remove use of VLAs for Windows built code 2024-04-18 20:02 ` [PATCH v2 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (12 preceding siblings ...) 2024-04-18 20:02 ` [PATCH v2 13/19] common/idpf: " Tyler Retzlaff @ 2024-04-18 20:02 ` Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 15/19] net/ice: " Tyler Retzlaff ` (4 subsequent siblings) 18 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-18 20:02 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- drivers/net/i40e/i40e_testpmd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/i40e/i40e_testpmd.c b/drivers/net/i40e/i40e_testpmd.c index b6ef5d6..21f5962 100644 --- a/drivers/net/i40e/i40e_testpmd.c +++ b/drivers/net/i40e/i40e_testpmd.c @@ -2168,8 +2168,7 @@ struct cmd_ptype_mapping_get_result { { struct cmd_ptype_mapping_get_result *res = parsed_result; int ret = -ENOTSUP; - int max_ptype_num = 256; - struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num]; + struct rte_pmd_i40e_ptype_mapping mapping[256]; uint16_t count; int i; @@ -2178,7 +2177,7 @@ struct cmd_ptype_mapping_get_result { ret = rte_pmd_i40e_ptype_mapping_get(res->port_id, mapping, - max_ptype_num, + RTE_DIM(mapping), &count, res->valid_only); switch (ret) { -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v2 15/19] net/ice: remove use of VLAs for Windows built code 2024-04-18 20:02 ` [PATCH v2 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (13 preceding siblings ...) 2024-04-18 20:02 ` [PATCH v2 14/19] net/i40e: " Tyler Retzlaff @ 2024-04-18 20:02 ` Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 16/19] net/ixgbe: " Tyler Retzlaff ` (3 subsequent siblings) 18 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-18 20:02 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- drivers/net/ice/ice_rxtx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c index 13aabe9..81e2b50 100644 --- a/drivers/net/ice/ice_rxtx.c +++ b/drivers/net/ice/ice_rxtx.c @@ -1868,7 +1868,7 @@ uint64_t dma_addr; int diag, diag_pay; uint64_t pay_addr; - struct rte_mbuf *mbufs_pay[rxq->rx_free_thresh]; + struct rte_mbuf **mbufs_pay = alloca(sizeof(struct rte_mbuf *) * rxq->rx_free_thresh); /* Allocate buffers in bulk */ alloc_idx = (uint16_t)(rxq->rx_free_trigger - -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v2 16/19] net/ixgbe: remove use of VLAs for Windows built code 2024-04-18 20:02 ` [PATCH v2 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (14 preceding siblings ...) 2024-04-18 20:02 ` [PATCH v2 15/19] net/ice: " Tyler Retzlaff @ 2024-04-18 20:02 ` Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 17/19] common/mlx5: " Tyler Retzlaff ` (2 subsequent siblings) 18 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-18 20:02 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- drivers/net/ixgbe/ixgbe_ethdev.c | 5 +++-- drivers/net/ixgbe/ixgbe_rxtx_vec_common.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index c61c52b..d460596 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -3553,7 +3553,8 @@ static int ixgbe_dev_xstats_get_names_by_id( uint16_t i; uint16_t size = ixgbe_xstats_calc_num(); - struct rte_eth_xstat_name xstats_names_copy[size]; + struct rte_eth_xstat_name *xstats_names_copy = + alloca(sizeof(struct rte_eth_xstat_name) * size); ixgbe_dev_xstats_get_names_by_id(dev, NULL, xstats_names_copy, size); @@ -3736,7 +3737,7 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, uint16_t i; uint16_t size = ixgbe_xstats_calc_num(); - uint64_t values_copy[size]; + uint64_t *values_copy = alloca(sizeof(uint64_t) * size); ixgbe_dev_xstats_get_by_id(dev, NULL, values_copy, size); diff --git a/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h b/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h index a4d9ec9..78b63b9 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h +++ b/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h @@ -14,7 +14,7 @@ reassemble_packets(struct ixgbe_rx_queue *rxq, struct rte_mbuf **rx_bufs, uint16_t nb_bufs, uint8_t *split_flags) { - struct rte_mbuf *pkts[nb_bufs]; /*finished pkts*/ + struct rte_mbuf **pkts = alloca(sizeof(struct rte_mbuf *) * nb_bufs); /*finished pkts*/ struct rte_mbuf *start = rxq->pkt_first_seg; struct rte_mbuf *end = rxq->pkt_last_seg; unsigned int pkt_idx, buf_idx; -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v2 17/19] common/mlx5: remove use of VLAs for Windows built code 2024-04-18 20:02 ` [PATCH v2 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (15 preceding siblings ...) 2024-04-18 20:02 ` [PATCH v2 16/19] net/ixgbe: " Tyler Retzlaff @ 2024-04-18 20:02 ` Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 18/19] net/mlx5: " Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 19/19] build: enable vla warnings on " Tyler Retzlaff 18 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-18 20:02 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- drivers/common/mlx5/mlx5_common.h | 4 ++-- drivers/common/mlx5/mlx5_devx_cmds.c | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h index 9c80277..76eba1c 100644 --- a/drivers/common/mlx5/mlx5_common.h +++ b/drivers/common/mlx5/mlx5_common.h @@ -112,10 +112,10 @@ /* Allocate a buffer on the stack and fill it with a printf format string. */ #define MKSTR(name, ...) \ int mkstr_size_##name = snprintf(NULL, 0, "" __VA_ARGS__); \ - char name[mkstr_size_##name + 1]; \ + char *name = alloca(mkstr_size_##name + 1); \ \ memset(name, 0, mkstr_size_##name + 1); \ - snprintf(name, sizeof(name), "" __VA_ARGS__) + snprintf(name, mkstr_size_##name + 1, "" __VA_ARGS__) enum { PCI_VENDOR_ID_MELLANOX = 0x15b3, diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c index 9b7abab..bac272f 100644 --- a/drivers/common/mlx5/mlx5_devx_cmds.c +++ b/drivers/common/mlx5/mlx5_devx_cmds.c @@ -284,10 +284,9 @@ struct mlx5_devx_obj * void *cmd_comp, uint64_t async_id) { - int out_len = MLX5_ST_SZ_BYTES(query_flow_counter_out) + - MLX5_ST_SZ_BYTES(traffic_counter); - uint32_t out[out_len]; + uint32_t out[MLX5_ST_SZ_BYTES(query_flow_counter_out) + MLX5_ST_SZ_BYTES(traffic_counter)]; uint32_t in[MLX5_ST_SZ_DW(query_flow_counter_in)] = {0}; + const int out_len = RTE_DIM(out); void *stats; int rc; @@ -346,7 +345,7 @@ struct mlx5_devx_obj * int klm_num = attr->klm_num; int in_size_dw = MLX5_ST_SZ_DW(create_mkey_in) + (klm_num ? RTE_ALIGN(klm_num, 4) : 0) * MLX5_ST_SZ_DW(klm); - uint32_t in[in_size_dw]; + uint32_t *in = alloca(sizeof(uint32_t) * in_size_dw); uint32_t out[MLX5_ST_SZ_DW(create_mkey_out)] = {0}; void *mkc; struct mlx5_devx_obj *mkey = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*mkey), -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v2 18/19] net/mlx5: remove use of VLAs for Windows built code 2024-04-18 20:02 ` [PATCH v2 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (16 preceding siblings ...) 2024-04-18 20:02 ` [PATCH v2 17/19] common/mlx5: " Tyler Retzlaff @ 2024-04-18 20:02 ` Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 19/19] build: enable vla warnings on " Tyler Retzlaff 18 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-18 20:02 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- drivers/net/mlx5/mlx5.c | 5 ++--- drivers/net/mlx5/mlx5_flow.c | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index d1a6382..de16acf 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1597,14 +1597,13 @@ mlx5_rt_timestamp_config(struct mlx5_dev_ctx_shared *sh, struct mlx5_hca_attr *hca_attr) { - uint32_t dw_cnt = MLX5_ST_SZ_DW(register_mtutc); - uint32_t reg[dw_cnt]; + uint32_t reg[MLX5_ST_SZ_DW(register_mtutc)]; int ret = ENOTSUP; if (hca_attr->access_register_user) ret = mlx5_devx_cmd_register_read(sh->cdev->ctx, MLX5_REGISTER_ID_MTUTC, 0, - reg, dw_cnt); + reg, RTE_DIM(reg)); if (!ret) { uint32_t ts_mode; diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index f31fdfb..b52fb77 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -1476,8 +1476,8 @@ struct mlx5_flow_tunnel_info { "mask/last without a spec is not" " supported"); if (item->spec && item->last && !range_accepted) { - uint8_t spec[size]; - uint8_t last[size]; + uint8_t *spec = alloca(size); + uint8_t *last = alloca(size); unsigned int i; int ret; @@ -8344,7 +8344,7 @@ struct mlx5_flow_workspace* .type = RTE_FLOW_ITEM_TYPE_END, }, }; - uint16_t queue[priv->reta_idx_n]; + uint16_t *queue = alloca(sizeof(uint16_t) * priv->reta_idx_n); struct rte_flow_action_rss action_rss = { .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .level = 0, -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v2 19/19] build: enable vla warnings on Windows built code 2024-04-18 20:02 ` [PATCH v2 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (17 preceding siblings ...) 2024-04-18 20:02 ` [PATCH v2 18/19] net/mlx5: " Tyler Retzlaff @ 2024-04-18 20:02 ` Tyler Retzlaff 18 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-04-18 20:02 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang MSVC does not support optional C11 VLAs. When building for Windows enable -Wvla so that mingw and clang also fail if a VLA is used. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- config/meson.build | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/meson.build b/config/meson.build index 8c8b019..9e887f2 100644 --- a/config/meson.build +++ b/config/meson.build @@ -344,6 +344,10 @@ if cc.get_id() == 'intel' warning_flags += '-diag-disable=@0@'.format(i) endforeach endif +# no VLAs in code built on Windows +if is_windows + warning_flags += '-Wvla' +endif foreach arg: warning_flags if cc.has_argument(arg) add_project_arguments(arg, language: 'c') -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v3 00/19] remove use of VLAs for Windows 2024-04-17 23:41 [PATCH 00/16] remove use of VLAs for Windows built code Tyler Retzlaff ` (18 preceding siblings ...) 2024-04-18 20:02 ` [PATCH v2 00/19] remove use of VLAs for Windows Tyler Retzlaff @ 2024-05-06 18:18 ` Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 01/19] eal: include header required for alloca Tyler Retzlaff ` (20 more replies) 2024-10-07 17:15 ` [PATCH 00/16] remove use of VLAs for Windows built code Stephen Hemminger ` (2 subsequent siblings) 22 siblings, 21 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-05-06 18:18 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang As per guidance technical board meeting 2024/04/17. This series removes the use of VLAs from code built for Windows for all 3 toolchains. If there are additional opportunities to convert VLAs to regular C arrays please provide the details for incorporation into the series. MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. v3: * address checkpatch/check git log warnings (minor typos) v2: * replace patches for ethdev, hash, rcu and include new patches for eal from Konstantin Ananyev from https://patchwork.dpdk.org/project/dpdk/list/?series=31781 Konstantin Ananyev (6): eal/linux: remove use of VLAs eal/common: remove use of VLAs ethdev: remove use of VLAs for Windows built code hash: remove use of VLAs for Windows built code hash/thash: remove use of VLAs for Windows built code rcu: remove use of VLAs for Windows built code Tyler Retzlaff (13): eal: include header required for alloca gro: remove use of VLAs for Windows built code latencystats: remove use of VLAs for Windows built code lpm: remove use of VLAs for Windows built code app/testpmd: remove use of VLAs for Windows built code test: remove use of VLAs for Windows built code common/idpf: remove use of VLAs for Windows built code net/i40e: remove use of VLAs for Windows built code net/ice: remove use of VLAs for Windows built code net/ixgbe: remove use of VLAs for Windows built code common/mlx5: remove use of VLAs for Windows built code net/mlx5: remove use of VLAs for Windows built code build: enable vla warnings on Windows built code app/test-pmd/cmdline.c | 2 +- app/test-pmd/cmdline_flow.c | 9 +- app/test-pmd/config.c | 16 ++- app/test-pmd/shared_rxq_fwd.c | 2 +- app/test/test.c | 2 +- app/test/test_cmdline_string.c | 2 +- app/test/test_cryptodev.c | 32 ++--- app/test/test_cryptodev_blockcipher.c | 4 +- app/test/test_cryptodev_crosscheck.c | 2 +- app/test/test_dmadev.c | 9 +- app/test/test_hash.c | 8 +- app/test/test_mempool.c | 25 ++-- app/test/test_reassembly_perf.c | 4 +- app/test/test_reorder.c | 48 +++---- app/test/test_service_cores.c | 9 +- app/test/test_thash.c | 7 +- config/meson.build | 4 + drivers/common/idpf/idpf_common_rxtx.c | 2 +- drivers/common/idpf/idpf_common_rxtx_avx512.c | 6 +- drivers/common/mlx5/mlx5_common.h | 4 +- drivers/common/mlx5/mlx5_devx_cmds.c | 7 +- drivers/net/i40e/i40e_testpmd.c | 5 +- drivers/net/ice/ice_rxtx.c | 2 +- drivers/net/ixgbe/ixgbe_ethdev.c | 5 +- drivers/net/ixgbe/ixgbe_rxtx_vec_common.h | 2 +- drivers/net/mlx5/mlx5.c | 5 +- drivers/net/mlx5/mlx5_flow.c | 6 +- lib/eal/common/eal_common_proc.c | 5 +- lib/eal/linux/eal_interrupts.c | 59 ++++++++- lib/eal/linux/include/rte_os.h | 1 + lib/eal/windows/include/rte_os.h | 1 + lib/ethdev/rte_ethdev.c | 183 ++++++++++++++++---------- lib/gro/rte_gro.c | 4 +- lib/hash/rte_cuckoo_hash.c | 4 +- lib/hash/rte_thash.c | 2 +- lib/hash/rte_thash.h | 8 ++ lib/latencystats/rte_latencystats.c | 2 +- lib/lpm/rte_lpm.h | 2 +- lib/rcu/rte_rcu_qsbr.c | 7 +- lib/rcu/rte_rcu_qsbr.h | 5 + 40 files changed, 314 insertions(+), 198 deletions(-) -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v3 01/19] eal: include header required for alloca 2024-05-06 18:18 ` [PATCH v3 00/19] remove use of VLAs for Windows Tyler Retzlaff @ 2024-05-06 18:18 ` Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 02/19] eal/linux: remove use of VLAs Tyler Retzlaff ` (19 subsequent siblings) 20 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-05-06 18:18 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang Include alloca.h for Linux and malloc.h for Windows to get declaration of alloca(). Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- lib/eal/linux/include/rte_os.h | 1 + lib/eal/windows/include/rte_os.h | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/eal/linux/include/rte_os.h b/lib/eal/linux/include/rte_os.h index c72bf5b..18ee404 100644 --- a/lib/eal/linux/include/rte_os.h +++ b/lib/eal/linux/include/rte_os.h @@ -14,6 +14,7 @@ * which is not supported natively or named differently in Linux. */ +#include <alloca.h> #include <sched.h> #include <sys/queue.h> diff --git a/lib/eal/windows/include/rte_os.h b/lib/eal/windows/include/rte_os.h index 1c33058..5c9c542 100644 --- a/lib/eal/windows/include/rte_os.h +++ b/lib/eal/windows/include/rte_os.h @@ -13,6 +13,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <malloc.h> #include <sched.h> -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v3 02/19] eal/linux: remove use of VLAs 2024-05-06 18:18 ` [PATCH v3 00/19] remove use of VLAs for Windows Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 01/19] eal: include header required for alloca Tyler Retzlaff @ 2024-05-06 18:18 ` Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 03/19] eal/common: " Tyler Retzlaff ` (18 subsequent siblings) 20 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-05-06 18:18 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Konstantin Ananyev From: Konstantin Ananyev <konstantin.ananyev@huawei.com> 1) ./lib/eal/linux/eal_interrupts.c:1073:16 : warning: ISO C90 forbids variable length array ‘events’ eal_intr_handle_interrupts() is called by eal_intr_thread_main() so it seems ok to simply alloc space for events from heap and reuse the same buffer through the life of the thread. 2) ./lib/eal/linux/eal_interrupts.c:1319:16 : warning: ISO C90 forbids variable length array ‘evs’ make eal_epoll_wait() use a fixed size array and use it though multiple iterations to process up to @maxevents events. Note that technically it is not one to one replacement, as here we might reduce number of events returned by first call to epoll_wait(..., timeout); Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> --- lib/eal/linux/eal_interrupts.c | 59 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 7 deletions(-) diff --git a/lib/eal/linux/eal_interrupts.c b/lib/eal/linux/eal_interrupts.c index 6436f79..d62bb80 100644 --- a/lib/eal/linux/eal_interrupts.c +++ b/lib/eal/linux/eal_interrupts.c @@ -34,6 +34,8 @@ #define EAL_INTR_EPOLL_WAIT_FOREVER (-1) #define NB_OTHER_INTR 1 +#define MAX_ITER_EVNUM RTE_EVENT_ETH_INTR_RING_SIZE + static RTE_DEFINE_PER_LCORE(int, _epfd) = -1; /**< epoll fd per thread */ /** @@ -1068,9 +1070,9 @@ struct rte_intr_source { * void */ static void -eal_intr_handle_interrupts(int pfd, unsigned totalfds) +eal_intr_handle_interrupts(int pfd, struct epoll_event events[], + unsigned int totalfds) { - struct epoll_event events[totalfds]; int nfds = 0; for(;;) { @@ -1106,6 +1108,12 @@ struct rte_intr_source { static __rte_noreturn uint32_t eal_intr_thread_main(__rte_unused void *arg) { + uint32_t n, nb_event; + struct epoll_event *events, *p; + + nb_event = 0; + events = NULL; + /* host thread, never break out */ for (;;) { /* build up the epoll fd with all descriptors we are to @@ -1159,8 +1167,23 @@ struct rte_intr_source { numfds++; } rte_spinlock_unlock(&intr_lock); + + /* alloc space for events, when necessary */ + if (numfds > nb_event) { + n = numfds + MAX_ITER_EVNUM; + p = realloc(events, n * sizeof(events[0])); + if (p == NULL) { + EAL_LOG(ERR, "failed to allocate %u events", + numfds); + numfds = nb_event; + } else { + nb_event = n; + events = p; + } + } + /* serve the interrupt */ - eal_intr_handle_interrupts(pfd, numfds); + eal_intr_handle_interrupts(pfd, events, numfds); /** * when we return, we need to rebuild the @@ -1168,6 +1191,8 @@ struct rte_intr_source { */ close(pfd); } + + free(events); } int @@ -1316,8 +1341,9 @@ struct rte_intr_source { eal_epoll_wait(int epfd, struct rte_epoll_event *events, int maxevents, int timeout, bool interruptible) { - struct epoll_event evs[maxevents]; int rc; + uint32_t i, k, n, num; + struct epoll_event evs[MAX_ITER_EVNUM]; if (!events) { EAL_LOG(ERR, "rte_epoll_event can't be NULL"); @@ -1328,12 +1354,31 @@ struct rte_intr_source { if (epfd == RTE_EPOLL_PER_THREAD) epfd = rte_intr_tls_epfd(); + num = maxevents; + n = RTE_MIN(RTE_DIM(evs), num); + + /* Process events in chunks of MAX_ITER_EVNUM */ + while (1) { - rc = epoll_wait(epfd, evs, maxevents, timeout); + rc = epoll_wait(epfd, evs, n, timeout); if (likely(rc > 0)) { + /* epoll_wait has at least one fd ready to read */ - rc = eal_epoll_process_event(evs, rc, events); - break; + for (i = 0, k = 0; rc > 0;) { + k += rc; + rc = eal_epoll_process_event(evs, rc, + events + i); + i += rc; + + /* + * try to read more events that are already + * available (up to maxevents in total). + */ + n = RTE_MIN(RTE_DIM(evs), num - k); + rc = (n == 0) ? 0 : epoll_wait(epfd, evs, n, 0); + } + return i; + } else if (rc < 0) { if (errno == EINTR) { if (interruptible) -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v3 03/19] eal/common: remove use of VLAs 2024-05-06 18:18 ` [PATCH v3 00/19] remove use of VLAs for Windows Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 01/19] eal: include header required for alloca Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 02/19] eal/linux: remove use of VLAs Tyler Retzlaff @ 2024-05-06 18:18 ` Tyler Retzlaff 2024-05-07 0:42 ` Stephen Hemminger 2024-05-06 18:18 ` [PATCH v3 04/19] ethdev: remove use of VLAs for Windows built code Tyler Retzlaff ` (17 subsequent siblings) 20 siblings, 1 reply; 127+ messages in thread From: Tyler Retzlaff @ 2024-05-06 18:18 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Konstantin Ananyev From: Konstantin Ananyev <konstantin.ananyev@huawei.com> 1) ../lib/eal/common/eal_common_proc.c:695:15 : warning: variable length array used As msg->num_fds should not exceed RTE_MP_MAX_FD_NUM, replaced it with fixed size array. Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> --- lib/eal/common/eal_common_proc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/eal/common/eal_common_proc.c b/lib/eal/common/eal_common_proc.c index d240939..f21ce60 100644 --- a/lib/eal/common/eal_common_proc.c +++ b/lib/eal/common/eal_common_proc.c @@ -692,7 +692,8 @@ enum async_action { struct sockaddr_un dst; struct mp_msg_internal m; int fd_size = msg->num_fds * sizeof(int); - char control[CMSG_SPACE(fd_size)]; + int32_t control_sz = CMSG_SPACE(fd_size); + char control[CMSG_SPACE(sizeof(msg->fds))]; m.type = type; memcpy(&m.msg, msg, sizeof(*msg)); @@ -712,7 +713,7 @@ enum async_action { msgh.msg_iov = &iov; msgh.msg_iovlen = 1; msgh.msg_control = control; - msgh.msg_controllen = sizeof(control); + msgh.msg_controllen = control_sz; cmsg = CMSG_FIRSTHDR(&msgh); cmsg->cmsg_len = CMSG_LEN(fd_size); -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* Re: [PATCH v3 03/19] eal/common: remove use of VLAs 2024-05-06 18:18 ` [PATCH v3 03/19] eal/common: " Tyler Retzlaff @ 2024-05-07 0:42 ` Stephen Hemminger 0 siblings, 0 replies; 127+ messages in thread From: Stephen Hemminger @ 2024-05-07 0:42 UTC (permalink / raw) To: Tyler Retzlaff Cc: dev, Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Konstantin Ananyev On Mon, 6 May 2024 11:18:35 -0700 Tyler Retzlaff <roretzla@linux.microsoft.com> wrote: > From: Konstantin Ananyev <konstantin.ananyev@huawei.com> > > 1) ../lib/eal/common/eal_common_proc.c:695:15 > : warning: variable length array used > > As msg->num_fds should not exceed RTE_MP_MAX_FD_NUM, replaced > it with fixed size array. > > Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> > --- Acked-by: Stephen Hemminger <stephen@networkplumber.org> ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v3 04/19] ethdev: remove use of VLAs for Windows built code 2024-05-06 18:18 ` [PATCH v3 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (2 preceding siblings ...) 2024-05-06 18:18 ` [PATCH v3 03/19] eal/common: " Tyler Retzlaff @ 2024-05-06 18:18 ` Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 05/19] hash: " Tyler Retzlaff ` (16 subsequent siblings) 20 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-05-06 18:18 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Konstantin Ananyev From: Konstantin Ananyev <konstantin.ananyev@huawei.com> 1) ./lib/ethdev/rte_ethdev.c:3244:16 : warning: ISO C90 forbids variable length array ‘xstats_names’ 2) ./lib/ethdev/rte_ethdev.c:3345:17 : warning: ISO C90 forbids variable length array ‘ids_copy’ 3) ./lib/ethdev/rte_ethdev.c:3538:16 : warning: ISO C90 forbids variable length array ‘xstats’ 4) ./lib/ethdev/rte_ethdev.c:3554:17 : warning: ISO C90 forbids variable length array ‘ids_copy’ For 1) and 3) - just replaced VLA with arrays allocated from heap. As I understand xstats extraction belongs to control-path, so extra calloc/free is hopefully acceptable. Also ethdev xstats already doing that within rte_eth_xstats_get_id_by_name(). For 2) and 4) changed the code to use fixed size array and call appropriate devops function several times, if needed. Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> --- lib/ethdev/rte_ethdev.c | 183 ++++++++++++++++++++++++++++++------------------ 1 file changed, 113 insertions(+), 70 deletions(-) diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index f1c658f..3f95d7d 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -36,6 +36,8 @@ #include "ethdev_trace.h" #include "sff_telemetry.h" +#define ETH_XSTATS_ITER_NUM 0x100 + struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS]; /* public fast-path API */ @@ -3215,7 +3217,8 @@ enum { rte_eth_xstats_get_id_by_name(uint16_t port_id, const char *xstat_name, uint64_t *id) { - int cnt_xstats, idx_xstat; + int cnt_xstats, idx_xstat, rc; + struct rte_eth_xstat_name *xstats_names; RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); @@ -3241,26 +3244,33 @@ enum { } /* Get id-name lookup table */ - struct rte_eth_xstat_name xstats_names[cnt_xstats]; + xstats_names = calloc(cnt_xstats, sizeof(xstats_names[0])); + if (xstats_names == NULL) { + RTE_ETHDEV_LOG_LINE(ERR, "Can't allocate memory"); + return -ENOMEM; + } if (cnt_xstats != rte_eth_xstats_get_names_by_id( port_id, xstats_names, cnt_xstats, NULL)) { RTE_ETHDEV_LOG_LINE(ERR, "Cannot get xstats lookup"); + free(xstats_names); return -1; } + rc = -EINVAL; for (idx_xstat = 0; idx_xstat < cnt_xstats; idx_xstat++) { if (!strcmp(xstats_names[idx_xstat].name, xstat_name)) { *id = idx_xstat; rte_eth_trace_xstats_get_id_by_name(port_id, xstat_name, *id); - - return 0; + rc = 0; + break; }; } - return -EINVAL; + free(xstats_names); + return rc; } /* retrieve basic stats names */ @@ -3306,6 +3316,38 @@ enum { return cnt_used_entries; } +static int +eth_xstats_get_by_name_by_id(struct rte_eth_dev *dev, const uint64_t *ids, + struct rte_eth_xstat_name *xstats_names, uint32_t size, + uint32_t basic_count) +{ + int32_t rc; + uint32_t i, k, m, n; + uint64_t ids_copy[ETH_XSTATS_ITER_NUM]; + + m = 0; + for (n = 0; n != size; n += k) { + + k = RTE_MIN(size - n, RTE_DIM(ids_copy)); + + /* + * Convert ids to xstats ids that PMD knows. + * ids known by user are basic + extended stats. + */ + for (i = 0; i < k; i++) + ids_copy[i] = ids[n + i] - basic_count; + + rc = (*dev->dev_ops->xstats_get_names_by_id)(dev, ids_copy, + xstats_names + m, k); + if (rc < 0) + return rc; + m += rc; + } + + return m; +} + + /* retrieve ethdev extended statistics names */ int rte_eth_xstats_get_names_by_id(uint16_t port_id, @@ -3313,9 +3355,8 @@ enum { uint64_t *ids) { struct rte_eth_xstat_name *xstats_names_copy; - unsigned int no_basic_stat_requested = 1; - unsigned int no_ext_stat_requested = 1; unsigned int expected_entries; + unsigned int nb_basic_stats; unsigned int basic_count; struct rte_eth_dev *dev; unsigned int i; @@ -3341,27 +3382,18 @@ enum { if (ids && !xstats_names) return -EINVAL; - if (ids && dev->dev_ops->xstats_get_names_by_id != NULL && size > 0) { - uint64_t ids_copy[size]; - - for (i = 0; i < size; i++) { - if (ids[i] < basic_count) { - no_basic_stat_requested = 0; - break; - } - - /* - * Convert ids to xstats ids that PMD knows. - * ids known by user are basic + extended stats. - */ - ids_copy[i] = ids[i] - basic_count; - } - - if (no_basic_stat_requested) - return (*dev->dev_ops->xstats_get_names_by_id)(dev, - ids_copy, xstats_names, size); + nb_basic_stats = 0; + if (ids != NULL) { + for (i = 0; i < size; i++) + nb_basic_stats += (ids[i] < basic_count); } + /* no basic stats requested, devops function provided */ + if (nb_basic_stats == 0 && ids != NULL && size != 0 && + dev->dev_ops->xstats_get_names_by_id != NULL) + return eth_xstats_get_by_name_by_id(dev, ids, xstats_names, + size, basic_count); + /* Retrieve all stats */ if (!ids) { int num_stats = rte_eth_xstats_get_names(port_id, xstats_names, @@ -3380,17 +3412,8 @@ enum { return -ENOMEM; } - if (ids) { - for (i = 0; i < size; i++) { - if (ids[i] >= basic_count) { - no_ext_stat_requested = 0; - break; - } - } - } - /* Fill xstats_names_copy structure */ - if (ids && no_ext_stat_requested) { + if (ids && nb_basic_stats == size) { eth_basic_stats_get_names(dev, xstats_names_copy); } else { ret = rte_eth_xstats_get_names(port_id, xstats_names_copy, @@ -3514,17 +3537,47 @@ enum { return count; } +static int +eth_xtats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, + uint64_t *values, uint32_t size, uint32_t basic_count) +{ + int32_t rc; + uint32_t i, k, m, n; + uint64_t ids_copy[ETH_XSTATS_ITER_NUM]; + + m = 0; + for (n = 0; n != size; n += k) { + + k = RTE_MIN(size - n, RTE_DIM(ids_copy)); + + /* + * Convert ids to xstats ids that PMD knows. + * ids known by user are basic + extended stats. + */ + for (i = 0; i < k; i++) + ids_copy[i] = ids[n + i] - basic_count; + + rc = (*dev->dev_ops->xstats_get_by_id)(dev, ids_copy, + values + m, k); + if (rc < 0) + return rc; + m += rc; + } + + return m; +} + /* retrieve ethdev extended statistics */ int rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids, uint64_t *values, unsigned int size) { - unsigned int no_basic_stat_requested = 1; - unsigned int no_ext_stat_requested = 1; + unsigned int nb_basic_stats; unsigned int num_xstats_filled; unsigned int basic_count; uint16_t expected_entries; struct rte_eth_dev *dev; + struct rte_eth_xstat *xstats; unsigned int i; int ret; @@ -3535,7 +3588,6 @@ enum { if (ret < 0) return ret; expected_entries = (uint16_t)ret; - struct rte_eth_xstat xstats[expected_entries]; basic_count = eth_dev_get_xstats_basic_count(dev); /* Return max number of stats if no ids given */ @@ -3549,51 +3601,41 @@ enum { if (ids && !values) return -EINVAL; - if (ids && dev->dev_ops->xstats_get_by_id != NULL && size) { - unsigned int basic_count = eth_dev_get_xstats_basic_count(dev); - uint64_t ids_copy[size]; - - for (i = 0; i < size; i++) { - if (ids[i] < basic_count) { - no_basic_stat_requested = 0; - break; - } - - /* - * Convert ids to xstats ids that PMD knows. - * ids known by user are basic + extended stats. - */ - ids_copy[i] = ids[i] - basic_count; - } - - if (no_basic_stat_requested) - return (*dev->dev_ops->xstats_get_by_id)(dev, ids_copy, - values, size); + nb_basic_stats = 0; + if (ids != NULL) { + for (i = 0; i < size; i++) + nb_basic_stats += (ids[i] < basic_count); } - if (ids) { - for (i = 0; i < size; i++) { - if (ids[i] >= basic_count) { - no_ext_stat_requested = 0; - break; - } - } + /* no basic stats requested, devops function provided */ + if (nb_basic_stats == 0 && ids != NULL && size != 0 && + dev->dev_ops->xstats_get_by_id != NULL) + return eth_xtats_get_by_id(dev, ids, values, size, basic_count); + + xstats = calloc(expected_entries, sizeof(xstats[0])); + if (xstats == NULL) { + RTE_ETHDEV_LOG_LINE(ERR, "Can't allocate memory"); + return -ENOMEM; } /* Fill the xstats structure */ - if (ids && no_ext_stat_requested) + if (ids && nb_basic_stats == size) ret = eth_basic_stats_get(port_id, xstats); else ret = rte_eth_xstats_get(port_id, xstats, expected_entries); - if (ret < 0) + if (ret < 0) { + free(xstats); return ret; + } num_xstats_filled = (unsigned int)ret; /* Return all stats */ if (!ids) { for (i = 0; i < num_xstats_filled; i++) values[i] = xstats[i].value; + + free(xstats); return expected_entries; } @@ -3601,14 +3643,15 @@ enum { for (i = 0; i < size; i++) { if (ids[i] >= expected_entries) { RTE_ETHDEV_LOG_LINE(ERR, "Id value isn't valid"); - return -1; + break; } values[i] = xstats[ids[i]].value; } rte_eth_trace_xstats_get_by_id(port_id, ids, values, size); - return size; + free(xstats); + return (i == size) ? (int32_t)size : -1; } int -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v3 05/19] hash: remove use of VLAs for Windows built code 2024-05-06 18:18 ` [PATCH v3 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (3 preceding siblings ...) 2024-05-06 18:18 ` [PATCH v3 04/19] ethdev: remove use of VLAs for Windows built code Tyler Retzlaff @ 2024-05-06 18:18 ` Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 06/19] hash/thash: " Tyler Retzlaff ` (15 subsequent siblings) 20 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-05-06 18:18 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Konstantin Ananyev From: Konstantin Ananyev <konstantin.ananyev@huawei.com> 1) ./lib/hash/rte_cuckoo_hash.c:2362:9 : warning: ISO C90 forbids variable length array ‘positions’ 2) ../lib/hash/rte_cuckoo_hash.c:2478:9 : warning: ISO C90 forbids variable length array ‘positions’ Both rte_hash_lookup_bulk_data() and rte_hash_lookup_with_hash_bulk_data() expect @num_keys <= RTE_HASH_LOOKUP_BULK_MAX. So, for both cases it should be safe to replace VLA with fixed size array. Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> --- lib/hash/rte_cuckoo_hash.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c index 9cf9464..82b74bd 100644 --- a/lib/hash/rte_cuckoo_hash.c +++ b/lib/hash/rte_cuckoo_hash.c @@ -2359,7 +2359,7 @@ struct rte_hash * (num_keys > RTE_HASH_LOOKUP_BULK_MAX) || (hit_mask == NULL)), -EINVAL); - int32_t positions[num_keys]; + int32_t positions[RTE_HASH_LOOKUP_BULK_MAX]; __rte_hash_lookup_bulk(h, keys, num_keys, positions, hit_mask, data); @@ -2475,7 +2475,7 @@ struct rte_hash * (num_keys > RTE_HASH_LOOKUP_BULK_MAX) || (hit_mask == NULL)), -EINVAL); - int32_t positions[num_keys]; + int32_t positions[RTE_HASH_LOOKUP_BULK_MAX]; __rte_hash_lookup_with_hash_bulk(h, keys, sig, num_keys, positions, hit_mask, data); -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v3 06/19] hash/thash: remove use of VLAs for Windows built code 2024-05-06 18:18 ` [PATCH v3 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (4 preceding siblings ...) 2024-05-06 18:18 ` [PATCH v3 05/19] hash: " Tyler Retzlaff @ 2024-05-06 18:18 ` Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 07/19] rcu: " Tyler Retzlaff ` (14 subsequent siblings) 20 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-05-06 18:18 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Konstantin Ananyev From: Konstantin Ananyev <konstantin.ananyev@huawei.com> 1) ./lib/hash/rte_thash.c:774:9 : warning: ISO C90 forbids variable length array ‘tmp_tuple’ From my understanding, tuple size here should never exceed sizeof(union rte_thash_tuple), so it should be safe to replace VLA with fixed size array. Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> --- lib/hash/rte_thash.c | 2 +- lib/hash/rte_thash.h | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c index 68f653f..e28d423 100644 --- a/lib/hash/rte_thash.c +++ b/lib/hash/rte_thash.c @@ -771,7 +771,7 @@ struct rte_thash_subtuple_helper * uint32_t desired_value, unsigned int attempts, rte_thash_check_tuple_t fn, void *userdata) { - uint32_t tmp_tuple[tuple_len / sizeof(uint32_t)]; + uint32_t tmp_tuple[RTE_THASH_MAX_L4_LEN]; unsigned int i, j, ret = 0; uint32_t hash, adj_bits; const uint8_t *hash_key; diff --git a/lib/hash/rte_thash.h b/lib/hash/rte_thash.h index 30b657e..322fe3a 100644 --- a/lib/hash/rte_thash.h +++ b/lib/hash/rte_thash.h @@ -109,6 +109,14 @@ union __rte_aligned(XMM_SIZE) rte_thash_tuple { }; /** + * maximum length in dwords of input tuple to + * calculate hash of ipv(4|6) header + + * transport header + */ +#define RTE_THASH_MAX_L4_LEN \ + ((sizeof(union rte_thash_tuple)) / sizeof(uint32_t)) + +/** * Prepare special converted key to use with rte_softrss_be() * @param orig * pointer to original RSS key -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v3 07/19] rcu: remove use of VLAs for Windows built code 2024-05-06 18:18 ` [PATCH v3 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (5 preceding siblings ...) 2024-05-06 18:18 ` [PATCH v3 06/19] hash/thash: " Tyler Retzlaff @ 2024-05-06 18:18 ` Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 08/19] gro: " Tyler Retzlaff ` (13 subsequent siblings) 20 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-05-06 18:18 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Konstantin Ananyev From: Konstantin Ananyev <konstantin.ananyev@huawei.com> 1) ./lib/rcu/rte_rcu_qsbr.c:359:9 : warning: ISO C90 forbids variable length array ‘data’ [-Wvla] 2) ./lib/rcu/rte_rcu_qsbr.c:422:9 : warning: ISO C90 forbids variable length array ‘data’ [-Wvla] In both cases we allocate VLA for one element from RCU deferred queue. Right now, size of element in RCU queue is not limited by API. The approach is to introduce some reasonable limitation on RCU DQ element size. Choose 128B for now. With that in place we can replace both VLA occurencies with fixed size array. Note that such change need to be treated as API change. So can be applied only at 24.11. Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> --- lib/rcu/rte_rcu_qsbr.c | 7 ++++--- lib/rcu/rte_rcu_qsbr.h | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/rcu/rte_rcu_qsbr.c b/lib/rcu/rte_rcu_qsbr.c index f08d974..6800ef0 100644 --- a/lib/rcu/rte_rcu_qsbr.c +++ b/lib/rcu/rte_rcu_qsbr.c @@ -278,7 +278,8 @@ struct rte_rcu_qsbr_dq * if (params == NULL || params->free_fn == NULL || params->v == NULL || params->name == NULL || params->size == 0 || params->esize == 0 || - (params->esize % 4 != 0)) { + (params->esize % 4 != 0) || + params->esize > RTE_QSBR_ESIZE_MAX) { RCU_LOG(ERR, "Invalid input parameter"); rte_errno = EINVAL; @@ -356,7 +357,7 @@ int rte_rcu_qsbr_dq_enqueue(struct rte_rcu_qsbr_dq *dq, void *e) return 1; } - char data[dq->esize]; + char data[RTE_QSBR_ESIZE_MAX + __RTE_QSBR_TOKEN_SIZE]; dq_elem = (__rte_rcu_qsbr_dq_elem_t *)data; /* Start the grace period */ dq_elem->token = rte_rcu_qsbr_start(dq->v); @@ -419,7 +420,7 @@ int rte_rcu_qsbr_dq_enqueue(struct rte_rcu_qsbr_dq *dq, void *e) cnt = 0; - char data[dq->esize]; + char data[RTE_QSBR_ESIZE_MAX + __RTE_QSBR_TOKEN_SIZE]; /* Check reader threads quiescent state and reclaim resources */ while (cnt < n && rte_ring_dequeue_bulk_elem_start(dq->r, &data, diff --git a/lib/rcu/rte_rcu_qsbr.h b/lib/rcu/rte_rcu_qsbr.h index 0506191..892e5a3 100644 --- a/lib/rcu/rte_rcu_qsbr.h +++ b/lib/rcu/rte_rcu_qsbr.h @@ -86,6 +86,11 @@ struct __rte_cache_aligned rte_rcu_qsbr_cnt { #define __RTE_QSBR_CNT_MAX ((uint64_t)~0) #define __RTE_QSBR_TOKEN_SIZE sizeof(uint64_t) +/** + * Max allowable size (in bytes) of each element in the defer queue + */ +#define RTE_QSBR_ESIZE_MAX (2 * RTE_CACHE_LINE_MIN_SIZE) + /* RTE Quiescent State variable structure. * This structure has two elements that vary in size based on the * 'max_threads' parameter. -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v3 08/19] gro: remove use of VLAs for Windows built code 2024-05-06 18:18 ` [PATCH v3 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (6 preceding siblings ...) 2024-05-06 18:18 ` [PATCH v3 07/19] rcu: " Tyler Retzlaff @ 2024-05-06 18:18 ` Tyler Retzlaff 2024-05-07 0:47 ` Stephen Hemminger 2024-05-06 18:18 ` [PATCH v3 09/19] latencystats: " Tyler Retzlaff ` (12 subsequent siblings) 20 siblings, 1 reply; 127+ messages in thread From: Tyler Retzlaff @ 2024-05-06 18:18 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- lib/gro/rte_gro.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/gro/rte_gro.c b/lib/gro/rte_gro.c index d824eeb..0f9e85c 100644 --- a/lib/gro/rte_gro.c +++ b/lib/gro/rte_gro.c @@ -179,7 +179,7 @@ struct gro_ctx { struct gro_vxlan_udp4_item vxlan_udp_items[RTE_GRO_MAX_BURST_ITEM_NUM] = {{{0}} }; - struct rte_mbuf *unprocess_pkts[nb_pkts]; + struct rte_mbuf **unprocess_pkts = alloca(sizeof(struct rte_mbuf *) * nb_pkts); uint32_t item_num; int32_t ret; uint16_t i, unprocess_num = 0, nb_after_gro = nb_pkts; @@ -360,7 +360,7 @@ struct gro_ctx { uint16_t nb_pkts, void *ctx) { - struct rte_mbuf *unprocess_pkts[nb_pkts]; + struct rte_mbuf **unprocess_pkts = alloca(sizeof(struct rte_mbuf *) * nb_pkts); struct gro_ctx *gro_ctx = ctx; void *tcp_tbl, *udp_tbl, *vxlan_tcp_tbl, *vxlan_udp_tbl, *tcp6_tbl; uint64_t current_time; -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* Re: [PATCH v3 08/19] gro: remove use of VLAs for Windows built code 2024-05-06 18:18 ` [PATCH v3 08/19] gro: " Tyler Retzlaff @ 2024-05-07 0:47 ` Stephen Hemminger 0 siblings, 0 replies; 127+ messages in thread From: Stephen Hemminger @ 2024-05-07 0:47 UTC (permalink / raw) To: Tyler Retzlaff Cc: dev, Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang On Mon, 6 May 2024 11:18:40 -0700 Tyler Retzlaff <roretzla@linux.microsoft.com> wrote: > MSVC does not support VLAs, replace VLAs with standard C arrays > or alloca(). alloca() is available for all toolchain/platform > combinations officially supported by DPDK. > > Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> > --- > lib/gro/rte_gro.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/lib/gro/rte_gro.c b/lib/gro/rte_gro.c > index d824eeb..0f9e85c 100644 > --- a/lib/gro/rte_gro.c > +++ b/lib/gro/rte_gro.c > @@ -179,7 +179,7 @@ struct gro_ctx { > struct gro_vxlan_udp4_item vxlan_udp_items[RTE_GRO_MAX_BURST_ITEM_NUM] > = {{{0}} }; > > - struct rte_mbuf *unprocess_pkts[nb_pkts]; > + struct rte_mbuf **unprocess_pkts = alloca(sizeof(struct rte_mbuf *) * nb_pkts); > uint32_t item_num; > int32_t ret; > uint16_t i, unprocess_num = 0, nb_after_gro = nb_pkts; > @@ -360,7 +360,7 @@ struct gro_ctx { > uint16_t nb_pkts, > void *ctx) > { > - struct rte_mbuf *unprocess_pkts[nb_pkts]; > + struct rte_mbuf **unprocess_pkts = alloca(sizeof(struct rte_mbuf *) * nb_pkts); > struct gro_ctx *gro_ctx = ctx; > void *tcp_tbl, *udp_tbl, *vxlan_tcp_tbl, *vxlan_udp_tbl, *tcp6_tbl; > uint64_t current_time; According to rte_gro.h the maximum supported burst size is #define RTE_GRO_MAX_BURST_ITEM_NUM 128U /**< the max number of packets that rte_gro_reassemble_burst() And it looks like the code already truncates at that. ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v3 09/19] latencystats: remove use of VLAs for Windows built code 2024-05-06 18:18 ` [PATCH v3 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (7 preceding siblings ...) 2024-05-06 18:18 ` [PATCH v3 08/19] gro: " Tyler Retzlaff @ 2024-05-06 18:18 ` Tyler Retzlaff 2024-05-07 0:47 ` Stephen Hemminger 2024-05-06 18:18 ` [PATCH v3 10/19] lpm: " Tyler Retzlaff ` (11 subsequent siblings) 20 siblings, 1 reply; 127+ messages in thread From: Tyler Retzlaff @ 2024-05-06 18:18 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- lib/latencystats/rte_latencystats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/latencystats/rte_latencystats.c b/lib/latencystats/rte_latencystats.c index 4ea9b0d..f59a9eb 100644 --- a/lib/latencystats/rte_latencystats.c +++ b/lib/latencystats/rte_latencystats.c @@ -159,7 +159,7 @@ struct latency_stats_nameoff { { unsigned int i, cnt = 0; uint64_t now; - float latency[nb_pkts]; + float *latency = alloca(sizeof(float) * nb_pkts); static float prev_latency; /* * Alpha represents degree of weighting decrease in EWMA, -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* Re: [PATCH v3 09/19] latencystats: remove use of VLAs for Windows built code 2024-05-06 18:18 ` [PATCH v3 09/19] latencystats: " Tyler Retzlaff @ 2024-05-07 0:47 ` Stephen Hemminger 0 siblings, 0 replies; 127+ messages in thread From: Stephen Hemminger @ 2024-05-07 0:47 UTC (permalink / raw) To: Tyler Retzlaff Cc: dev, Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang On Mon, 6 May 2024 11:18:41 -0700 Tyler Retzlaff <roretzla@linux.microsoft.com> wrote: > MSVC does not support VLAs, replace VLAs with standard C arrays > or alloca(). alloca() is available for all toolchain/platform > combinations officially supported by DPDK. > > Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> See the alternate patch, the temporary array is unneeded. ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v3 10/19] lpm: remove use of VLAs for Windows built code 2024-05-06 18:18 ` [PATCH v3 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (8 preceding siblings ...) 2024-05-06 18:18 ` [PATCH v3 09/19] latencystats: " Tyler Retzlaff @ 2024-05-06 18:18 ` Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 11/19] app/testpmd: " Tyler Retzlaff ` (10 subsequent siblings) 20 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-05-06 18:18 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- lib/lpm/rte_lpm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lpm/rte_lpm.h b/lib/lpm/rte_lpm.h index 2888e5f..fc5805c 100644 --- a/lib/lpm/rte_lpm.h +++ b/lib/lpm/rte_lpm.h @@ -337,7 +337,7 @@ struct rte_lpm * uint32_t *next_hops, const unsigned n) { unsigned i; - unsigned tbl24_indexes[n]; + unsigned int *tbl24_indexes = (unsigned int *)alloca(sizeof(unsigned int) * n); const uint32_t *ptbl; /* DEBUG: Check user input arguments. */ -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v3 11/19] app/testpmd: remove use of VLAs for Windows built code 2024-05-06 18:18 ` [PATCH v3 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (9 preceding siblings ...) 2024-05-06 18:18 ` [PATCH v3 10/19] lpm: " Tyler Retzlaff @ 2024-05-06 18:18 ` Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 12/19] test: " Tyler Retzlaff ` (9 subsequent siblings) 20 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-05-06 18:18 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- app/test-pmd/cmdline.c | 2 +- app/test-pmd/cmdline_flow.c | 9 ++++----- app/test-pmd/config.c | 16 +++++++++------- app/test-pmd/shared_rxq_fwd.c | 2 +- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index b7759e3..dee8f5f 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -12902,7 +12902,7 @@ struct cmd_set_port_ptypes_result { return; } - uint32_t ptypes[ret]; + uint32_t *ptypes = alloca(sizeof(uint32_t) * ret); ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret); if (ret < 0) { diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 60ee933..a4fe8d9 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -11546,8 +11546,7 @@ struct indlst_conf { char tmp[16]; /* Ought to be enough. */ int ret; unsigned int hexlen = len; - unsigned int length = 256; - uint8_t hex_tmp[length]; + uint8_t hex_tmp[256]; /* Arguments are expected. */ if (!arg_data) @@ -11574,7 +11573,7 @@ struct indlst_conf { str += 2; hexlen -= 2; } - if (hexlen > length) + if (hexlen > RTE_DIM(hex_tmp)) goto error; ret = parse_hex_string(str, hex_tmp, &hexlen); if (ret < 0) @@ -11707,7 +11706,7 @@ struct indlst_conf { void *buf, unsigned int size) { const struct arg *arg = pop_args(ctx); - char str2[len + 1]; + char *str2 = alloca(len + 1); struct in_addr tmp; int ret; @@ -11753,7 +11752,7 @@ struct indlst_conf { void *buf, unsigned int size) { const struct arg *arg = pop_args(ctx); - char str2[len + 1]; + char *str2 = alloca(len + 1); struct in6_addr tmp; int ret; diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index ba1007a..4dce6fa 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1760,7 +1760,8 @@ void port_flow_tunnel_create(portid_t port_id, const struct tunnel_ops *ops) { struct rte_port *port; struct rte_flow_error error; - const struct rte_flow_queue_attr *attr_list[nb_queue]; + const struct rte_flow_queue_attr **attr_list = + alloca(sizeof(struct rte_flow_queue_attr *) * nb_queue); int std_queue; if (port_id_is_invalid(port_id, ENABLED_WARN) || @@ -2577,10 +2578,10 @@ struct rte_flow_meter_policy * int ret; uint32_t i; struct rte_flow_error error; - struct rte_flow_pattern_template - *flow_pattern_templates[nb_pattern_templates]; - struct rte_flow_actions_template - *flow_actions_templates[nb_actions_templates]; + struct rte_flow_pattern_template **flow_pattern_templates = + alloca(sizeof(struct rte_flow_pattern_template *) * nb_pattern_templates); + struct rte_flow_actions_template **flow_actions_templates = + alloca(sizeof(struct rte_flow_actions_template *) * nb_actions_templates); if (port_id_is_invalid(port_id, ENABLED_WARN) || port_id == (portid_t)RTE_PORT_ALL) @@ -5460,7 +5461,7 @@ struct igb_ring_desc_16_bytes { char *end = NULL; int min, max; int value, i; - unsigned int marked[maxsize]; + unsigned int *marked = alloca(sizeof(unsigned int) * maxsize); if (list == NULL || values == NULL) return 0; @@ -7201,7 +7202,8 @@ static const char *get_ptype_str(uint32_t ptype) if (eth_dev_info_get_print_err(port_id, &dev_info)) return; - struct rte_ether_addr addr[dev_info.max_mac_addrs]; + struct rte_ether_addr *addr = + alloca(sizeof(struct rte_ether_addr) * dev_info.max_mac_addrs); rc = rte_eth_macaddrs_get(port_id, addr, dev_info.max_mac_addrs); if (rc < 0) return; diff --git a/app/test-pmd/shared_rxq_fwd.c b/app/test-pmd/shared_rxq_fwd.c index 623d62d..5d4ffff 100644 --- a/app/test-pmd/shared_rxq_fwd.c +++ b/app/test-pmd/shared_rxq_fwd.c @@ -92,7 +92,7 @@ static bool shared_rxq_fwd(struct fwd_stream *fs) { - struct rte_mbuf *pkts_burst[nb_pkt_per_burst]; + struct rte_mbuf **pkts_burst = alloca(sizeof(struct rte_mbuf *) * nb_pkt_per_burst); uint16_t nb_rx; nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst); -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v3 12/19] test: remove use of VLAs for Windows built code 2024-05-06 18:18 ` [PATCH v3 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (10 preceding siblings ...) 2024-05-06 18:18 ` [PATCH v3 11/19] app/testpmd: " Tyler Retzlaff @ 2024-05-06 18:18 ` Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 13/19] common/idpf: " Tyler Retzlaff ` (8 subsequent siblings) 20 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-05-06 18:18 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- app/test/test.c | 2 +- app/test/test_cmdline_string.c | 2 +- app/test/test_cryptodev.c | 32 +++++++++++------------ app/test/test_cryptodev_blockcipher.c | 4 +-- app/test/test_cryptodev_crosscheck.c | 2 +- app/test/test_dmadev.c | 9 ++++--- app/test/test_hash.c | 8 +++--- app/test/test_mempool.c | 25 +++++++++--------- app/test/test_reassembly_perf.c | 4 +-- app/test/test_reorder.c | 48 +++++++++++++++++++---------------- app/test/test_service_cores.c | 9 +++---- app/test/test_thash.c | 7 +++-- 12 files changed, 79 insertions(+), 73 deletions(-) diff --git a/app/test/test.c b/app/test/test.c index 680351f..fd653cb 100644 --- a/app/test/test.c +++ b/app/test/test.c @@ -105,7 +105,7 @@ main(int argc, char **argv) { struct cmdline *cl; - char *tests[argc]; /* store an array of tests to run */ + char **tests = alloca(sizeof(char *) * argc); /* store an array of tests to run */ int test_count = 0; int i; char *extra_args; diff --git a/app/test/test_cmdline_string.c b/app/test/test_cmdline_string.c index 97516c9..e1cf860 100644 --- a/app/test/test_cmdline_string.c +++ b/app/test/test_cmdline_string.c @@ -40,7 +40,7 @@ struct string_elt_str string_elt_strs[] = { #if (CMDLINE_TEST_BUFSIZE < STR_TOKEN_SIZE) \ || (CMDLINE_TEST_BUFSIZE < STR_MULTI_TOKEN_SIZE) #undef CMDLINE_TEST_BUFSIZE -#define CMDLINE_TEST_BUFSIZE RTE_MAX(STR_TOKEN_SIZE, STR_MULTI_TOKEN_SIZE) +#define CMDLINE_TEST_BUFSIZE RTE_MAX_T(STR_TOKEN_SIZE, STR_MULTI_TOKEN_SIZE, size_t) #endif struct string_nb_str { diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index 1703ebc..fead21b 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -2686,7 +2686,7 @@ struct crypto_unittest_params { enum rte_crypto_auth_operation op, enum rte_crypto_auth_algorithm algo) { - uint8_t hash_key[key_len]; + uint8_t *hash_key = alloca(key_len); struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -2722,7 +2722,7 @@ struct crypto_unittest_params { const uint8_t *key, const uint8_t key_len, uint8_t iv_len) { - uint8_t cipher_key[key_len]; + uint8_t *cipher_key = alloca(key_len); struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -2874,7 +2874,7 @@ struct crypto_unittest_params { const struct wireless_test_data *tdata) { const uint8_t key_len = tdata->key.len; - uint8_t cipher_auth_key[key_len]; + uint8_t *cipher_auth_key = alloca(key_len); struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -8878,7 +8878,7 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata) const uint16_t aad_len, const uint8_t auth_len, uint8_t iv_len) { - uint8_t aead_key[key_len]; + uint8_t *aead_key = alloca(key_len); struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -12849,7 +12849,7 @@ static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc, test_AES_GCM_auth_encryption_fail_aad_corrupt(void) { struct aead_test_data tdata; - uint8_t aad[gcm_test_case_7.aad.len]; + uint8_t *aad = alloca(gcm_test_case_7.aad.len); int res; RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n"); @@ -13238,7 +13238,7 @@ static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc, test_AES_GCM_auth_decryption_fail_aad_corrupt(void) { struct aead_test_data tdata; - uint8_t aad[gcm_test_case_7.aad.len]; + uint8_t *aad = alloca(gcm_test_case_7.aad.len); int res; memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data)); @@ -13490,7 +13490,7 @@ static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc, int retval; uint8_t *ciphertext, *auth_tag; uint16_t plaintext_pad_len; - uint8_t key[tdata->key.len + 1]; + uint8_t *key = alloca(tdata->key.len + 1); struct rte_cryptodev_info dev_info; rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); @@ -13592,7 +13592,7 @@ static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc, int retval; uint8_t *plaintext; - uint8_t key[tdata->key.len + 1]; + uint8_t *key = alloca(tdata->key.len + 1); struct rte_cryptodev_info dev_info; rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); @@ -14895,7 +14895,7 @@ static int create_gmac_session(uint8_t dev_id, const struct gmac_test_data *tdata, enum rte_crypto_auth_operation auth_op) { - uint8_t auth_key[tdata->key.len]; + uint8_t *auth_key = alloca(tdata->key.len); struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -15552,7 +15552,7 @@ struct test_crypto_vector { enum rte_crypto_auth_operation auth_op) { struct crypto_testsuite_params *ts_params = &testsuite_params; - uint8_t auth_key[reference->auth_key.len + 1]; + uint8_t *auth_key = alloca(reference->auth_key.len + 1); memcpy(auth_key, reference->auth_key.data, reference->auth_key.len); @@ -15583,8 +15583,8 @@ struct test_crypto_vector { enum rte_crypto_cipher_operation cipher_op) { struct crypto_testsuite_params *ts_params = &testsuite_params; - uint8_t cipher_key[reference->cipher_key.len + 1]; - uint8_t auth_key[reference->auth_key.len + 1]; + uint8_t *cipher_key = alloca(reference->cipher_key.len + 1); + uint8_t *auth_key = alloca(reference->auth_key.len + 1); memcpy(cipher_key, reference->cipher_key.data, reference->cipher_key.len); @@ -16084,8 +16084,8 @@ struct test_crypto_vector { uint8_t *authciphertext, *plaintext, *auth_tag; uint16_t plaintext_pad_len; - uint8_t cipher_key[reference->cipher_key.len + 1]; - uint8_t auth_key[reference->auth_key.len + 1]; + uint8_t *cipher_key = alloca(reference->cipher_key.len + 1); + uint8_t *auth_key = alloca(reference->auth_key.len + 1); struct rte_cryptodev_info dev_info; rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); @@ -16216,8 +16216,8 @@ struct test_crypto_vector { int retval; uint8_t *ciphertext; - uint8_t cipher_key[reference->cipher_key.len + 1]; - uint8_t auth_key[reference->auth_key.len + 1]; + uint8_t *cipher_key = alloca(reference->cipher_key.len + 1); + uint8_t *auth_key = alloca(reference->auth_key.len + 1); struct rte_cryptodev_info dev_info; rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); diff --git a/app/test/test_cryptodev_blockcipher.c b/app/test/test_cryptodev_blockcipher.c index 87a321f..da7bf2c 100644 --- a/app/test/test_cryptodev_blockcipher.c +++ b/app/test/test_cryptodev_blockcipher.c @@ -85,8 +85,8 @@ int status = TEST_SUCCESS; const struct blockcipher_test_data *tdata = t->test_data; - uint8_t cipher_key[tdata->cipher_key.len]; - uint8_t auth_key[tdata->auth_key.len]; + uint8_t *cipher_key = alloca(tdata->cipher_key.len); + uint8_t *auth_key = alloca(tdata->auth_key.len); uint32_t buf_len = tdata->ciphertext.len; uint32_t digest_len = tdata->digest.len; char *buf_p = NULL; diff --git a/app/test/test_cryptodev_crosscheck.c b/app/test/test_cryptodev_crosscheck.c index c29b19c..b9a53a4 100644 --- a/app/test/test_cryptodev_crosscheck.c +++ b/app/test/test_cryptodev_crosscheck.c @@ -894,7 +894,7 @@ struct crosscheck_testsuite_params { crosscheck_with_profile_run(const struct crosscheck_test_profile *profile) { struct crosscheck_testsuite_params *ts_params = &testsuite_params; - uint8_t input_text[profile->input_buf_len]; + uint8_t *input_text = alloca(profile->input_buf_len); uint16_t output_len, encrypted_len; uint8_t encrypted_text[MBUF_SIZE]; uint8_t output_text[MBUF_SIZE]; diff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c index 143e1bc..9cbb9a6 100644 --- a/app/test/test_dmadev.c +++ b/app/test/test_dmadev.c @@ -417,9 +417,12 @@ struct runtest_param { dst_len = len / n_dst; src_len = len / n_src; - struct rte_dma_sge sg_src[n_sge], sg_dst[n_sge]; - struct rte_mbuf *src[n_sge], *dst[n_sge]; - char *src_data[n_sge], *dst_data[n_sge]; + struct rte_dma_sge *sg_src = alloca(sizeof(struct rte_dma_sge) * n_sge); + struct rte_dma_sge *sg_dst = alloca(sizeof(struct rte_dma_sge) * n_sge); + struct rte_mbuf **src = alloca(sizeof(struct rte_mbuf *) * n_sge); + struct rte_mbuf **dst = alloca(sizeof(struct rte_mbuf *) * n_sge); + char **src_data = alloca(sizeof(char *) * n_sge); + char **dst_data = alloca(sizeof(char *) * n_sge); for (i = 0 ; i < len; i++) orig_src[i] = rte_rand() & 0xFF; diff --git a/app/test/test_hash.c b/app/test/test_hash.c index d586878..65fd9e6 100644 --- a/app/test/test_hash.c +++ b/app/test/test_hash.c @@ -1930,8 +1930,8 @@ static int test_hash_iteration(uint32_t ext_table) .socket_id = 0, .extra_flag = hash_extra_flag, }; - int pos[total_entries]; - int expected_pos[total_entries]; + int *pos = alloca(sizeof(int) * total_entries); + int *expected_pos = alloca(sizeof(int) * total_entries); unsigned int i; size_t sz; int32_t status; @@ -2100,8 +2100,8 @@ static int test_hash_iteration(uint32_t ext_table) .socket_id = 0, .extra_flag = hash_extra_flag, }; - int pos[total_entries]; - int expected_pos[total_entries]; + int *pos = alloca(sizeof(int) * total_entries); + int *expected_pos = alloca(sizeof(int) * total_entries); unsigned int i; size_t sz; int32_t status; diff --git a/app/test/test_mempool.c b/app/test/test_mempool.c index ad7ebd6..4672795 100644 --- a/app/test/test_mempool.c +++ b/app/test/test_mempool.c @@ -515,19 +515,20 @@ struct test_mempool_events_data { #undef RTE_TEST_TRACE_FAILURE #define RTE_TEST_TRACE_FAILURE(...) do { goto fail; } while (0) - static const size_t callback_num = 3; - static const size_t mempool_num = 2; +#define CALLBACK_NUM 3u +#define MEMPOOL_NUM 2u + static const unsigned int mempool_elt_size = 64; static const unsigned int mempool_size = 64; - struct test_mempool_events_data data[callback_num]; - struct rte_mempool *mp[mempool_num], *freed; + struct test_mempool_events_data data[CALLBACK_NUM]; + struct rte_mempool *mp[MEMPOOL_NUM], *freed; char name[RTE_MEMPOOL_NAMESIZE]; size_t i, j; int ret; memset(mp, 0, sizeof(mp)); - for (i = 0; i < callback_num; i++) { + for (i = 0; i < CALLBACK_NUM; i++) { ret = rte_mempool_event_callback_register (test_mempool_events_cb, &data[i]); RTE_TEST_ASSERT_EQUAL(ret, 0, "Failed to register the callback %zu: %s", @@ -548,7 +549,7 @@ struct test_mempool_events_data { SOCKET_ID_ANY, 0); RTE_TEST_ASSERT_NOT_NULL(mp[0], "Cannot create mempool %s: %s", name, rte_strerror(rte_errno)); - for (j = 0; j < callback_num; j++) + for (j = 0; j < CALLBACK_NUM; j++) RTE_TEST_ASSERT_EQUAL(data[j].invoked, false, "Callback %zu invoked on %s mempool creation", j, name); @@ -557,7 +558,7 @@ struct test_mempool_events_data { ret = populate(mp[0]); RTE_TEST_ASSERT_EQUAL(ret, (int)mp[0]->size, "Failed to populate mempool %s: %s", name, rte_strerror(-ret)); - for (j = 0; j < callback_num; j++) { + for (j = 0; j < CALLBACK_NUM; j++) { RTE_TEST_ASSERT_EQUAL(data[j].invoked, true, "Callback %zu not invoked on mempool %s population", j, name); @@ -589,7 +590,7 @@ struct test_mempool_events_data { "Unregistered callback 0 invoked on %s mempool populaton", name); - for (i = 0; i < mempool_num; i++) { + for (i = 0; i < MEMPOOL_NUM; i++) { memset(&data, 0, sizeof(data)); sprintf(name, "empty%zu", i); rte_mempool_free(mp[i]); @@ -599,7 +600,7 @@ struct test_mempool_events_data { */ freed = mp[i]; mp[i] = NULL; - for (j = 1; j < callback_num; j++) { + for (j = 1; j < CALLBACK_NUM; j++) { RTE_TEST_ASSERT_EQUAL(data[j].invoked, true, "Callback %zu not invoked on mempool %s destruction", j, name); @@ -615,7 +616,7 @@ struct test_mempool_events_data { name); } - for (j = 1; j < callback_num; j++) { + for (j = 1; j < CALLBACK_NUM; j++) { ret = rte_mempool_event_callback_unregister (test_mempool_events_cb, &data[j]); RTE_TEST_ASSERT_EQUAL(ret, 0, "Failed to unregister the callback %zu: %s", @@ -624,10 +625,10 @@ struct test_mempool_events_data { return TEST_SUCCESS; fail: - for (j = 0; j < callback_num; j++) + for (j = 0; j < CALLBACK_NUM; j++) rte_mempool_event_callback_unregister (test_mempool_events_cb, &data[j]); - for (i = 0; i < mempool_num; i++) + for (i = 0; i < MEMPOOL_NUM; i++) rte_mempool_free(mp[i]); return TEST_FAILED; diff --git a/app/test/test_reassembly_perf.c b/app/test/test_reassembly_perf.c index 3912179..7f4ed31 100644 --- a/app/test/test_reassembly_perf.c +++ b/app/test/test_reassembly_perf.c @@ -604,7 +604,7 @@ for (j = 0; j < 4; j++) nb_frags += frag_per_flow[i + j]; - struct rte_mbuf *buf_arr[nb_frags]; + struct rte_mbuf **buf_arr = alloca(sizeof(struct rte_mbuf *) * nb_frags); for (j = 0; j < 4; j++) { join_array(buf_arr, mbufs[i + j], prev, frag_per_flow[i + j]); @@ -815,7 +815,7 @@ for (j = 0; j < 4; j++) nb_frags += frag_per_flow[i + j]; - struct rte_mbuf *buf_arr[nb_frags]; + struct rte_mbuf **buf_arr = alloca(sizeof(struct rte_mbuf *) * nb_frags); for (j = 0; j < 4; j++) { join_array(buf_arr, mbufs[i + j], prev, frag_per_flow[i + j]); diff --git a/app/test/test_reorder.c b/app/test/test_reorder.c index 501780c..aaa2c57 100644 --- a/app/test/test_reorder.c +++ b/app/test/test_reorder.c @@ -130,11 +130,12 @@ struct reorder_unittest_params { static int test_reorder_insert(void) { +#define INSERT_NUM_BUFS 7u + struct rte_reorder_buffer *b = NULL; struct rte_mempool *p = test_params->p; const unsigned int size = 4; - const unsigned int num_bufs = 7; - struct rte_mbuf *bufs[num_bufs]; + struct rte_mbuf *bufs[INSERT_NUM_BUFS]; int ret = 0; unsigned i; @@ -146,7 +147,7 @@ struct reorder_unittest_params { b = rte_reorder_create("test_insert", rte_socket_id(), size); TEST_ASSERT_NOT_NULL(b, "Failed to create reorder buffer"); - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < INSERT_NUM_BUFS; i++) { bufs[i] = rte_pktmbuf_alloc(p); TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n"); *rte_reorder_seqn(bufs[i]) = i; @@ -207,26 +208,27 @@ struct reorder_unittest_params { ret = 0; exit: rte_reorder_free(b); - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < INSERT_NUM_BUFS; i++) rte_pktmbuf_free(bufs[i]); - } + return ret; } static int test_reorder_drain(void) { +#define DRAIN_NUM_BUFS 8u + struct rte_reorder_buffer *b = NULL; struct rte_mempool *p = test_params->p; const unsigned int size = 4; - const unsigned int num_bufs = 8; - struct rte_mbuf *bufs[num_bufs]; - struct rte_mbuf *robufs[num_bufs]; + struct rte_mbuf *bufs[DRAIN_NUM_BUFS]; + struct rte_mbuf *robufs[DRAIN_NUM_BUFS]; int ret = 0; unsigned i, cnt; /* initialize all robufs to NULL */ - for (i = 0; i < num_bufs; i++) + for (i = 0; i < DRAIN_NUM_BUFS; i++) robufs[i] = NULL; /* This would create a reorder buffer instance consisting of: @@ -246,7 +248,7 @@ struct reorder_unittest_params { goto exit; } - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < DRAIN_NUM_BUFS; i++) { bufs[i] = rte_pktmbuf_alloc(p); TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n"); *rte_reorder_seqn(bufs[i]) = i; @@ -320,7 +322,7 @@ struct reorder_unittest_params { ret = 0; exit: rte_reorder_free(b); - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < DRAIN_NUM_BUFS; i++) { rte_pktmbuf_free(bufs[i]); rte_pktmbuf_free(robufs[i]); } @@ -337,15 +339,16 @@ struct reorder_unittest_params { static int test_reorder_drain_up_to_seqn(void) { +#define DRAIN_TO_NUM_BUFS 10u + struct rte_mempool *p = test_params->p; struct rte_reorder_buffer *b = NULL; - const unsigned int num_bufs = 10; const unsigned int size = 4; unsigned int i, cnt; int ret = 0; - struct rte_mbuf *bufs[num_bufs]; - struct rte_mbuf *robufs[num_bufs]; + struct rte_mbuf *bufs[DRAIN_TO_NUM_BUFS]; + struct rte_mbuf *robufs[DRAIN_TO_NUM_BUFS]; /* initialize all robufs to NULL */ memset(robufs, 0, sizeof(robufs)); @@ -358,7 +361,7 @@ struct reorder_unittest_params { b = rte_reorder_create("test_drain_up_to_seqn", rte_socket_id(), size); TEST_ASSERT_NOT_NULL(b, "Failed to create reorder buffer"); - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < DRAIN_TO_NUM_BUFS; i++) { bufs[i] = rte_pktmbuf_alloc(p); TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n"); *rte_reorder_seqn(bufs[i]) = i; @@ -372,7 +375,7 @@ struct reorder_unittest_params { buffer_to_reorder_move(&bufs[2], b); buffer_to_reorder_move(&bufs[3], b); /* Draining 1, 2 */ - cnt = rte_reorder_drain_up_to_seqn(b, robufs, num_bufs, 3); + cnt = rte_reorder_drain_up_to_seqn(b, robufs, DRAIN_TO_NUM_BUFS, 3); if (cnt != 2) { printf("%s:%d:%d: number of expected packets not drained\n", __func__, __LINE__, cnt); @@ -396,7 +399,7 @@ struct reorder_unittest_params { buffer_to_reorder_move(&bufs[8], b); /* Drain 3 and 5 */ - cnt = rte_reorder_drain_up_to_seqn(b, robufs, num_bufs, 6); + cnt = rte_reorder_drain_up_to_seqn(b, robufs, DRAIN_TO_NUM_BUFS, 6); if (cnt != 2) { printf("%s:%d:%d: number of expected packets not drained\n", __func__, __LINE__, cnt); @@ -410,7 +413,7 @@ struct reorder_unittest_params { ret = 0; exit: rte_reorder_free(b); - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < DRAIN_TO_NUM_BUFS; i++) { rte_pktmbuf_free(bufs[i]); rte_pktmbuf_free(robufs[i]); } @@ -420,14 +423,15 @@ struct reorder_unittest_params { static int test_reorder_set_seqn(void) { +#define SET_SEQN_NUM_BUFS 7u + struct rte_mempool *p = test_params->p; struct rte_reorder_buffer *b = NULL; - const unsigned int num_bufs = 7; const unsigned int size = 4; unsigned int i; int ret = 0; - struct rte_mbuf *bufs[num_bufs]; + struct rte_mbuf *bufs[SET_SEQN_NUM_BUFS]; /* This would create a reorder buffer instance consisting of: * reorder_seq = 0 @@ -437,7 +441,7 @@ struct reorder_unittest_params { b = rte_reorder_create("test_min_seqn_set", rte_socket_id(), size); TEST_ASSERT_NOT_NULL(b, "Failed to create reorder buffer"); - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < SET_SEQN_NUM_BUFS; i++) { bufs[i] = rte_pktmbuf_alloc(p); if (bufs[i] == NULL) { printf("Packet allocation failed\n"); @@ -479,7 +483,7 @@ struct reorder_unittest_params { ret = 0; exit: rte_reorder_free(b); - for (i = 0; i < num_bufs; i++) + for (i = 0; i < SET_SEQN_NUM_BUFS; i++) rte_pktmbuf_free(bufs[i]); return ret; diff --git a/app/test/test_service_cores.c b/app/test/test_service_cores.c index c12d52d..7c45733 100644 --- a/app/test/test_service_cores.c +++ b/app/test/test_service_cores.c @@ -561,9 +561,8 @@ static int32_t dummy_mt_safe_cb(void *args) "Service core count not equal to one"); /* retrieve core list, checking lcore ids */ - const uint32_t size = 4; - uint32_t service_core_ids[size]; - int32_t n = rte_service_lcore_list(service_core_ids, size); + uint32_t service_core_ids[4]; + int32_t n = rte_service_lcore_list(service_core_ids, RTE_DIM(service_core_ids)); TEST_ASSERT_EQUAL(1, n, "Service core list return should equal 1"); TEST_ASSERT_EQUAL(slcore_id, service_core_ids[0], "Service core list lcore must equal slcore_id"); @@ -589,7 +588,7 @@ static int32_t dummy_mt_safe_cb(void *args) cores_at_this_point); /* check longer service core list */ - n = rte_service_lcore_list(service_core_ids, size); + n = rte_service_lcore_list(service_core_ids, RTE_DIM(service_core_ids)); TEST_ASSERT_EQUAL(3, n, "Service core list return should equal 3"); TEST_ASSERT_EQUAL(slcore_id, service_core_ids[0], "Service core list[0] lcore must equal 1"); @@ -607,7 +606,7 @@ static int32_t dummy_mt_safe_cb(void *args) "Service core add did not return zero"); TEST_ASSERT_EQUAL(1, rte_service_lcore_count(), "Service core count not equal to one"); - n = rte_service_lcore_list(service_core_ids, size); + n = rte_service_lcore_list(service_core_ids, RTE_DIM(service_core_ids)); TEST_ASSERT_EQUAL(1, n, "Service core list return should equal one"); TEST_ASSERT_EQUAL(slcore_id, service_core_ids[0], "Service core list[0] lcore must equal %d", diff --git a/app/test/test_thash.c b/app/test/test_thash.c index 65d42fd..80d4106 100644 --- a/app/test/test_thash.c +++ b/app/test/test_thash.c @@ -576,9 +576,8 @@ enum { { struct rte_thash_ctx *ctx; struct rte_thash_subtuple_helper *h; - const int key_len = 40; int reta_sz = 6; - uint8_t initial_key[key_len]; + uint8_t initial_key[40]; const uint8_t *new_key; int ret; union rte_thash_tuple tuple; @@ -586,9 +585,9 @@ enum { unsigned int desired_value = 27 & HASH_MSK(reta_sz); uint16_t port_value = 22; - memset(initial_key, 0, key_len); + memset(initial_key, 0, RTE_DIM(initial_key)); - ctx = rte_thash_init_ctx("test", key_len, reta_sz, initial_key, + ctx = rte_thash_init_ctx("test", RTE_DIM(initial_key), reta_sz, initial_key, RTE_THASH_MINIMAL_SEQ); RTE_TEST_ASSERT(ctx != NULL, "can not create thash ctx\n"); -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v3 13/19] common/idpf: remove use of VLAs for Windows built code 2024-05-06 18:18 ` [PATCH v3 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (11 preceding siblings ...) 2024-05-06 18:18 ` [PATCH v3 12/19] test: " Tyler Retzlaff @ 2024-05-06 18:18 ` Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 14/19] net/i40e: " Tyler Retzlaff ` (7 subsequent siblings) 20 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-05-06 18:18 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- drivers/common/idpf/idpf_common_rxtx.c | 2 +- drivers/common/idpf/idpf_common_rxtx_avx512.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/common/idpf/idpf_common_rxtx.c b/drivers/common/idpf/idpf_common_rxtx.c index 83b131e..da24b78 100644 --- a/drivers/common/idpf/idpf_common_rxtx.c +++ b/drivers/common/idpf/idpf_common_rxtx.c @@ -569,7 +569,7 @@ uint16_t nb_refill = rx_bufq->rx_free_thresh; uint16_t nb_desc = rx_bufq->nb_rx_desc; uint16_t next_avail = rx_bufq->rx_tail; - struct rte_mbuf *nmb[rx_bufq->rx_free_thresh]; + struct rte_mbuf **nmb = alloca(sizeof(struct rte_mbuf *) * rx_bufq->rx_free_thresh); uint64_t dma_addr; uint16_t delta; int i; diff --git a/drivers/common/idpf/idpf_common_rxtx_avx512.c b/drivers/common/idpf/idpf_common_rxtx_avx512.c index f65e8d5..9131bd6 100644 --- a/drivers/common/idpf/idpf_common_rxtx_avx512.c +++ b/drivers/common/idpf/idpf_common_rxtx_avx512.c @@ -1002,7 +1002,8 @@ uint32_t n; uint32_t i; int nb_free = 0; - struct rte_mbuf *m, *free[txq->rs_thresh]; + struct rte_mbuf *m; + struct rte_mbuf **free = alloca(sizeof(struct rte_mbuf *) * txq->rs_thresh); /* check DD bits on threshold descriptor */ if ((txq->tx_ring[txq->next_dd].qw1 & @@ -1319,7 +1320,8 @@ uint32_t n; uint32_t i; int nb_free = 0; - struct rte_mbuf *m, *free[txq->rs_thresh]; + struct rte_mbuf *m; + struct rte_mbuf **free = alloca(sizeof(struct rte_mbuf *) * txq->rs_thresh); n = txq->rs_thresh; -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v3 14/19] net/i40e: remove use of VLAs for Windows built code 2024-05-06 18:18 ` [PATCH v3 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (12 preceding siblings ...) 2024-05-06 18:18 ` [PATCH v3 13/19] common/idpf: " Tyler Retzlaff @ 2024-05-06 18:18 ` Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 15/19] net/ice: " Tyler Retzlaff ` (6 subsequent siblings) 20 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-05-06 18:18 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- drivers/net/i40e/i40e_testpmd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/i40e/i40e_testpmd.c b/drivers/net/i40e/i40e_testpmd.c index b6ef5d6..21f5962 100644 --- a/drivers/net/i40e/i40e_testpmd.c +++ b/drivers/net/i40e/i40e_testpmd.c @@ -2168,8 +2168,7 @@ struct cmd_ptype_mapping_get_result { { struct cmd_ptype_mapping_get_result *res = parsed_result; int ret = -ENOTSUP; - int max_ptype_num = 256; - struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num]; + struct rte_pmd_i40e_ptype_mapping mapping[256]; uint16_t count; int i; @@ -2178,7 +2177,7 @@ struct cmd_ptype_mapping_get_result { ret = rte_pmd_i40e_ptype_mapping_get(res->port_id, mapping, - max_ptype_num, + RTE_DIM(mapping), &count, res->valid_only); switch (ret) { -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v3 15/19] net/ice: remove use of VLAs for Windows built code 2024-05-06 18:18 ` [PATCH v3 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (13 preceding siblings ...) 2024-05-06 18:18 ` [PATCH v3 14/19] net/i40e: " Tyler Retzlaff @ 2024-05-06 18:18 ` Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 16/19] net/ixgbe: " Tyler Retzlaff ` (5 subsequent siblings) 20 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-05-06 18:18 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- drivers/net/ice/ice_rxtx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c index 95a2db3..78b7cd6 100644 --- a/drivers/net/ice/ice_rxtx.c +++ b/drivers/net/ice/ice_rxtx.c @@ -1868,7 +1868,7 @@ uint64_t dma_addr; int diag, diag_pay; uint64_t pay_addr; - struct rte_mbuf *mbufs_pay[rxq->rx_free_thresh]; + struct rte_mbuf **mbufs_pay = alloca(sizeof(struct rte_mbuf *) * rxq->rx_free_thresh); /* Allocate buffers in bulk */ alloc_idx = (uint16_t)(rxq->rx_free_trigger - -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v3 16/19] net/ixgbe: remove use of VLAs for Windows built code 2024-05-06 18:18 ` [PATCH v3 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (14 preceding siblings ...) 2024-05-06 18:18 ` [PATCH v3 15/19] net/ice: " Tyler Retzlaff @ 2024-05-06 18:18 ` Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 17/19] common/mlx5: " Tyler Retzlaff ` (4 subsequent siblings) 20 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-05-06 18:18 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- drivers/net/ixgbe/ixgbe_ethdev.c | 5 +++-- drivers/net/ixgbe/ixgbe_rxtx_vec_common.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index c61c52b..d460596 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -3553,7 +3553,8 @@ static int ixgbe_dev_xstats_get_names_by_id( uint16_t i; uint16_t size = ixgbe_xstats_calc_num(); - struct rte_eth_xstat_name xstats_names_copy[size]; + struct rte_eth_xstat_name *xstats_names_copy = + alloca(sizeof(struct rte_eth_xstat_name) * size); ixgbe_dev_xstats_get_names_by_id(dev, NULL, xstats_names_copy, size); @@ -3736,7 +3737,7 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, uint16_t i; uint16_t size = ixgbe_xstats_calc_num(); - uint64_t values_copy[size]; + uint64_t *values_copy = alloca(sizeof(uint64_t) * size); ixgbe_dev_xstats_get_by_id(dev, NULL, values_copy, size); diff --git a/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h b/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h index a4d9ec9..78b63b9 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h +++ b/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h @@ -14,7 +14,7 @@ reassemble_packets(struct ixgbe_rx_queue *rxq, struct rte_mbuf **rx_bufs, uint16_t nb_bufs, uint8_t *split_flags) { - struct rte_mbuf *pkts[nb_bufs]; /*finished pkts*/ + struct rte_mbuf **pkts = alloca(sizeof(struct rte_mbuf *) * nb_bufs); /*finished pkts*/ struct rte_mbuf *start = rxq->pkt_first_seg; struct rte_mbuf *end = rxq->pkt_last_seg; unsigned int pkt_idx, buf_idx; -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v3 17/19] common/mlx5: remove use of VLAs for Windows built code 2024-05-06 18:18 ` [PATCH v3 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (15 preceding siblings ...) 2024-05-06 18:18 ` [PATCH v3 16/19] net/ixgbe: " Tyler Retzlaff @ 2024-05-06 18:18 ` Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 18/19] net/mlx5: " Tyler Retzlaff ` (3 subsequent siblings) 20 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-05-06 18:18 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- drivers/common/mlx5/mlx5_common.h | 4 ++-- drivers/common/mlx5/mlx5_devx_cmds.c | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h index 9c80277..76eba1c 100644 --- a/drivers/common/mlx5/mlx5_common.h +++ b/drivers/common/mlx5/mlx5_common.h @@ -112,10 +112,10 @@ /* Allocate a buffer on the stack and fill it with a printf format string. */ #define MKSTR(name, ...) \ int mkstr_size_##name = snprintf(NULL, 0, "" __VA_ARGS__); \ - char name[mkstr_size_##name + 1]; \ + char *name = alloca(mkstr_size_##name + 1); \ \ memset(name, 0, mkstr_size_##name + 1); \ - snprintf(name, sizeof(name), "" __VA_ARGS__) + snprintf(name, mkstr_size_##name + 1, "" __VA_ARGS__) enum { PCI_VENDOR_ID_MELLANOX = 0x15b3, diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c index 9b7abab..bac272f 100644 --- a/drivers/common/mlx5/mlx5_devx_cmds.c +++ b/drivers/common/mlx5/mlx5_devx_cmds.c @@ -284,10 +284,9 @@ struct mlx5_devx_obj * void *cmd_comp, uint64_t async_id) { - int out_len = MLX5_ST_SZ_BYTES(query_flow_counter_out) + - MLX5_ST_SZ_BYTES(traffic_counter); - uint32_t out[out_len]; + uint32_t out[MLX5_ST_SZ_BYTES(query_flow_counter_out) + MLX5_ST_SZ_BYTES(traffic_counter)]; uint32_t in[MLX5_ST_SZ_DW(query_flow_counter_in)] = {0}; + const int out_len = RTE_DIM(out); void *stats; int rc; @@ -346,7 +345,7 @@ struct mlx5_devx_obj * int klm_num = attr->klm_num; int in_size_dw = MLX5_ST_SZ_DW(create_mkey_in) + (klm_num ? RTE_ALIGN(klm_num, 4) : 0) * MLX5_ST_SZ_DW(klm); - uint32_t in[in_size_dw]; + uint32_t *in = alloca(sizeof(uint32_t) * in_size_dw); uint32_t out[MLX5_ST_SZ_DW(create_mkey_out)] = {0}; void *mkc; struct mlx5_devx_obj *mkey = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*mkey), -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v3 18/19] net/mlx5: remove use of VLAs for Windows built code 2024-05-06 18:18 ` [PATCH v3 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (16 preceding siblings ...) 2024-05-06 18:18 ` [PATCH v3 17/19] common/mlx5: " Tyler Retzlaff @ 2024-05-06 18:18 ` Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 19/19] build: enable vla warnings on " Tyler Retzlaff ` (2 subsequent siblings) 20 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-05-06 18:18 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- drivers/net/mlx5/mlx5.c | 5 ++--- drivers/net/mlx5/mlx5_flow.c | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index d1a6382..de16acf 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1597,14 +1597,13 @@ mlx5_rt_timestamp_config(struct mlx5_dev_ctx_shared *sh, struct mlx5_hca_attr *hca_attr) { - uint32_t dw_cnt = MLX5_ST_SZ_DW(register_mtutc); - uint32_t reg[dw_cnt]; + uint32_t reg[MLX5_ST_SZ_DW(register_mtutc)]; int ret = ENOTSUP; if (hca_attr->access_register_user) ret = mlx5_devx_cmd_register_read(sh->cdev->ctx, MLX5_REGISTER_ID_MTUTC, 0, - reg, dw_cnt); + reg, RTE_DIM(reg)); if (!ret) { uint32_t ts_mode; diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index f31fdfb..b52fb77 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -1476,8 +1476,8 @@ struct mlx5_flow_tunnel_info { "mask/last without a spec is not" " supported"); if (item->spec && item->last && !range_accepted) { - uint8_t spec[size]; - uint8_t last[size]; + uint8_t *spec = alloca(size); + uint8_t *last = alloca(size); unsigned int i; int ret; @@ -8344,7 +8344,7 @@ struct mlx5_flow_workspace* .type = RTE_FLOW_ITEM_TYPE_END, }, }; - uint16_t queue[priv->reta_idx_n]; + uint16_t *queue = alloca(sizeof(uint16_t) * priv->reta_idx_n); struct rte_flow_action_rss action_rss = { .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .level = 0, -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v3 19/19] build: enable vla warnings on Windows built code 2024-05-06 18:18 ` [PATCH v3 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (17 preceding siblings ...) 2024-05-06 18:18 ` [PATCH v3 18/19] net/mlx5: " Tyler Retzlaff @ 2024-05-06 18:18 ` Tyler Retzlaff 2024-05-07 2:53 ` [PATCH 1/2] lpm: remove unnecessary temporary VLA Stephen Hemminger 2024-07-09 8:26 ` [PATCH v3 00/19] remove use of VLAs for Windows David Marchand 20 siblings, 0 replies; 127+ messages in thread From: Tyler Retzlaff @ 2024-05-06 18:18 UTC (permalink / raw) To: dev Cc: Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Tyler Retzlaff, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang MSVC does not support optional C11 VLAs. When building for Windows enable -Wvla so that mingw and clang also fail if a VLA is used. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- config/meson.build | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/meson.build b/config/meson.build index 8c8b019..9e887f2 100644 --- a/config/meson.build +++ b/config/meson.build @@ -344,6 +344,10 @@ if cc.get_id() == 'intel' warning_flags += '-diag-disable=@0@'.format(i) endforeach endif +# no VLAs in code built on Windows +if is_windows + warning_flags += '-Wvla' +endif foreach arg: warning_flags if cc.has_argument(arg) add_project_arguments(arg, language: 'c') -- 1.8.3.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH 1/2] lpm: remove unnecessary temporary VLA 2024-05-06 18:18 ` [PATCH v3 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (18 preceding siblings ...) 2024-05-06 18:18 ` [PATCH v3 19/19] build: enable vla warnings on " Tyler Retzlaff @ 2024-05-07 2:53 ` Stephen Hemminger 2024-05-07 2:53 ` [PATCH 2/2] latencystats: replace use of VLA Stephen Hemminger 2024-05-07 7:51 ` [PATCH 1/2] lpm: remove unnecessary temporary VLA Bruce Richardson 2024-07-09 8:26 ` [PATCH v3 00/19] remove use of VLAs for Windows David Marchand 20 siblings, 2 replies; 127+ messages in thread From: Stephen Hemminger @ 2024-05-07 2:53 UTC (permalink / raw) To: roretzla; +Cc: dev, Stephen Hemminger Do not need to recompute all the table indices. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> --- lib/lpm/rte_lpm.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/lpm/rte_lpm.h b/lib/lpm/rte_lpm.h index 2888e5f4ca..9c6df311cb 100644 --- a/lib/lpm/rte_lpm.h +++ b/lib/lpm/rte_lpm.h @@ -337,7 +337,6 @@ rte_lpm_lookup_bulk_func(const struct rte_lpm *lpm, const uint32_t *ips, uint32_t *next_hops, const unsigned n) { unsigned i; - unsigned tbl24_indexes[n]; const uint32_t *ptbl; /* DEBUG: Check user input arguments. */ @@ -345,12 +344,10 @@ rte_lpm_lookup_bulk_func(const struct rte_lpm *lpm, const uint32_t *ips, (next_hops == NULL)), -EINVAL); for (i = 0; i < n; i++) { - tbl24_indexes[i] = ips[i] >> 8; - } + unsigned int tbl24_index = ips[i] >> 8; - for (i = 0; i < n; i++) { /* Simply copy tbl24 entry to output */ - ptbl = (const uint32_t *)&lpm->tbl24[tbl24_indexes[i]]; + ptbl = (const uint32_t *)&lpm->tbl24[tbl24_index]; next_hops[i] = *ptbl; /* Overwrite output with tbl8 entry if needed */ -- 2.43.0 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH 2/2] latencystats: replace use of VLA 2024-05-07 2:53 ` [PATCH 1/2] lpm: remove unnecessary temporary VLA Stephen Hemminger @ 2024-05-07 2:53 ` Stephen Hemminger 2024-07-09 8:06 ` David Marchand 2024-05-07 7:51 ` [PATCH 1/2] lpm: remove unnecessary temporary VLA Bruce Richardson 1 sibling, 1 reply; 127+ messages in thread From: Stephen Hemminger @ 2024-05-07 2:53 UTC (permalink / raw) To: roretzla; +Cc: dev, Stephen Hemminger, Morten Brørup The temporary array latencystats is not needed if the algorithm is converted into one pass. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Acked-by: Morten Brørup <mb@smartsharesystems.com> Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- lib/latencystats/rte_latencystats.c | 31 +++++++++++++++-------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/latencystats/rte_latencystats.c b/lib/latencystats/rte_latencystats.c index 4ea9b0d75b..9b345bfb33 100644 --- a/lib/latencystats/rte_latencystats.c +++ b/lib/latencystats/rte_latencystats.c @@ -157,9 +157,9 @@ calc_latency(uint16_t pid __rte_unused, uint16_t nb_pkts, void *_ __rte_unused) { - unsigned int i, cnt = 0; + unsigned int i; uint64_t now; - float latency[nb_pkts]; + float latency; static float prev_latency; /* * Alpha represents degree of weighting decrease in EWMA, @@ -169,13 +169,14 @@ calc_latency(uint16_t pid __rte_unused, const float alpha = 0.2; now = rte_rdtsc(); - for (i = 0; i < nb_pkts; i++) { - if (pkts[i]->ol_flags & timestamp_dynflag) - latency[cnt++] = now - *timestamp_dynfield(pkts[i]); - } rte_spinlock_lock(&glob_stats->lock); - for (i = 0; i < cnt; i++) { + for (i = 0; i < nb_pkts; i++) { + if (!(pkts[i]->ol_flags & timestamp_dynflag)) + continue; + + latency = now - *timestamp_dynfield(pkts[i]); + /* * The jitter is calculated as statistical mean of interpacket * delay variation. The "jitter estimate" is computed by taking @@ -187,22 +188,22 @@ calc_latency(uint16_t pid __rte_unused, * Reference: Calculated as per RFC 5481, sec 4.1, * RFC 3393 sec 4.5, RFC 1889 sec. */ - glob_stats->jitter += (fabsf(prev_latency - latency[i]) + glob_stats->jitter += (fabsf(prev_latency - latency) - glob_stats->jitter)/16; if (glob_stats->min_latency == 0) - glob_stats->min_latency = latency[i]; - else if (latency[i] < glob_stats->min_latency) - glob_stats->min_latency = latency[i]; - else if (latency[i] > glob_stats->max_latency) - glob_stats->max_latency = latency[i]; + glob_stats->min_latency = latency; + else if (latency < glob_stats->min_latency) + glob_stats->min_latency = latency; + else if (latency > glob_stats->max_latency) + glob_stats->max_latency = latency; /* * The average latency is measured using exponential moving * average, i.e. using EWMA * https://en.wikipedia.org/wiki/Moving_average */ glob_stats->avg_latency += - alpha * (latency[i] - glob_stats->avg_latency); - prev_latency = latency[i]; + alpha * (latency - glob_stats->avg_latency); + prev_latency = latency; } rte_spinlock_unlock(&glob_stats->lock); -- 2.43.0 ^ permalink raw reply [flat|nested] 127+ messages in thread
* Re: [PATCH 2/2] latencystats: replace use of VLA 2024-05-07 2:53 ` [PATCH 2/2] latencystats: replace use of VLA Stephen Hemminger @ 2024-07-09 8:06 ` David Marchand 0 siblings, 0 replies; 127+ messages in thread From: David Marchand @ 2024-07-09 8:06 UTC (permalink / raw) To: Stephen Hemminger; +Cc: roretzla, dev, Morten Brørup On Tue, May 7, 2024 at 4:54 AM Stephen Hemminger <stephen@networkplumber.org> wrote: > > The temporary array latencystats is not needed if the algorithm > is converted into one pass. > > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> > Acked-by: Morten Brørup <mb@smartsharesystems.com> > Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com> Series applied, thanks for the cleanup. -- David Marchand ^ permalink raw reply [flat|nested] 127+ messages in thread
* Re: [PATCH 1/2] lpm: remove unnecessary temporary VLA 2024-05-07 2:53 ` [PATCH 1/2] lpm: remove unnecessary temporary VLA Stephen Hemminger 2024-05-07 2:53 ` [PATCH 2/2] latencystats: replace use of VLA Stephen Hemminger @ 2024-05-07 7:51 ` Bruce Richardson 1 sibling, 0 replies; 127+ messages in thread From: Bruce Richardson @ 2024-05-07 7:51 UTC (permalink / raw) To: Stephen Hemminger; +Cc: roretzla, dev On Mon, May 06, 2024 at 07:53:54PM -0700, Stephen Hemminger wrote: > Do not need to recompute all the table indices. > > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Acked-by: Bruce Richardson <bruce.richardson@intel.com> ^ permalink raw reply [flat|nested] 127+ messages in thread
* Re: [PATCH v3 00/19] remove use of VLAs for Windows 2024-05-06 18:18 ` [PATCH v3 00/19] remove use of VLAs for Windows Tyler Retzlaff ` (19 preceding siblings ...) 2024-05-07 2:53 ` [PATCH 1/2] lpm: remove unnecessary temporary VLA Stephen Hemminger @ 2024-07-09 8:26 ` David Marchand 20 siblings, 0 replies; 127+ messages in thread From: David Marchand @ 2024-07-09 8:26 UTC (permalink / raw) To: Tyler Retzlaff, Ferruh Yigit, Konstantin Ananyev Cc: dev, Morten Brørup, Akhil Goyal, Aman Singh, Anatoly Burakov, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Harman Kalra, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang Hello guys, On Mon, May 6, 2024 at 8:19 PM Tyler Retzlaff <roretzla@linux.microsoft.com> wrote: > > As per guidance technical board meeting 2024/04/17. This series > removes the use of VLAs from code built for Windows for all 3 > toolchains. If there are additional opportunities to convert VLAs > to regular C arrays please provide the details for incorporation > into the series. > > MSVC does not support VLAs, replace VLAs with standard C arrays > or alloca(). alloca() is available for all toolchain/platform > combinations officially supported by DPDK. > > v3: > * address checkpatch/check git log warnings (minor typos) > > v2: > * replace patches for ethdev, hash, rcu and include new > patches for eal from Konstantin Ananyev > from https://patchwork.dpdk.org/project/dpdk/list/?series=31781 > > Konstantin Ananyev (6): > eal/linux: remove use of VLAs > eal/common: remove use of VLAs > ethdev: remove use of VLAs for Windows built code > hash: remove use of VLAs for Windows built code > hash/thash: remove use of VLAs for Windows built code > rcu: remove use of VLAs for Windows built code > > Tyler Retzlaff (13): > eal: include header required for alloca > gro: remove use of VLAs for Windows built code > latencystats: remove use of VLAs for Windows built code > lpm: remove use of VLAs for Windows built code > app/testpmd: remove use of VLAs for Windows built code > test: remove use of VLAs for Windows built code > common/idpf: remove use of VLAs for Windows built code > net/i40e: remove use of VLAs for Windows built code > net/ice: remove use of VLAs for Windows built code > net/ixgbe: remove use of VLAs for Windows built code > common/mlx5: remove use of VLAs for Windows built code > net/mlx5: remove use of VLAs for Windows built code > build: enable vla warnings on Windows built code > > app/test-pmd/cmdline.c | 2 +- > app/test-pmd/cmdline_flow.c | 9 +- > app/test-pmd/config.c | 16 ++- > app/test-pmd/shared_rxq_fwd.c | 2 +- > app/test/test.c | 2 +- > app/test/test_cmdline_string.c | 2 +- > app/test/test_cryptodev.c | 32 ++--- > app/test/test_cryptodev_blockcipher.c | 4 +- > app/test/test_cryptodev_crosscheck.c | 2 +- > app/test/test_dmadev.c | 9 +- > app/test/test_hash.c | 8 +- > app/test/test_mempool.c | 25 ++-- > app/test/test_reassembly_perf.c | 4 +- > app/test/test_reorder.c | 48 +++---- > app/test/test_service_cores.c | 9 +- > app/test/test_thash.c | 7 +- > config/meson.build | 4 + > drivers/common/idpf/idpf_common_rxtx.c | 2 +- > drivers/common/idpf/idpf_common_rxtx_avx512.c | 6 +- > drivers/common/mlx5/mlx5_common.h | 4 +- > drivers/common/mlx5/mlx5_devx_cmds.c | 7 +- > drivers/net/i40e/i40e_testpmd.c | 5 +- > drivers/net/ice/ice_rxtx.c | 2 +- > drivers/net/ixgbe/ixgbe_ethdev.c | 5 +- > drivers/net/ixgbe/ixgbe_rxtx_vec_common.h | 2 +- > drivers/net/mlx5/mlx5.c | 5 +- > drivers/net/mlx5/mlx5_flow.c | 6 +- > lib/eal/common/eal_common_proc.c | 5 +- > lib/eal/linux/eal_interrupts.c | 59 ++++++++- > lib/eal/linux/include/rte_os.h | 1 + > lib/eal/windows/include/rte_os.h | 1 + > lib/ethdev/rte_ethdev.c | 183 ++++++++++++++++---------- > lib/gro/rte_gro.c | 4 +- > lib/hash/rte_cuckoo_hash.c | 4 +- > lib/hash/rte_thash.c | 2 +- > lib/hash/rte_thash.h | 8 ++ > lib/latencystats/rte_latencystats.c | 2 +- > lib/lpm/rte_lpm.h | 2 +- > lib/rcu/rte_rcu_qsbr.c | 7 +- > lib/rcu/rte_rcu_qsbr.h | 5 + > 40 files changed, 314 insertions(+), 198 deletions(-) I see discussions on patches for some net drivers and the gro library. Can you please sync and summarize which patches goes though next-net, though main etc..? In any case, I think this cleanup can wait 24.11. For now, I merged Stephen alternatives for lpm and latencystats as the patches looked clean and were acked. Thanks. -- David Marchand ^ permalink raw reply [flat|nested] 127+ messages in thread
* Re: [PATCH 00/16] remove use of VLAs for Windows built code 2024-04-17 23:41 [PATCH 00/16] remove use of VLAs for Windows built code Tyler Retzlaff ` (19 preceding siblings ...) 2024-05-06 18:18 ` [PATCH v3 00/19] remove use of VLAs for Windows Tyler Retzlaff @ 2024-10-07 17:15 ` Stephen Hemminger 2024-11-01 18:06 ` Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 00/19] remove use of VLAs for Windows Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 00/20] " Andre Muezerie 22 siblings, 1 reply; 127+ messages in thread From: Stephen Hemminger @ 2024-10-07 17:15 UTC (permalink / raw) To: Tyler Retzlaff Cc: dev, Morten Brørup, Akhil Goyal, Aman Singh, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Yuying Zhang On Wed, 17 Apr 2024 16:41:43 -0700 Tyler Retzlaff <roretzla@linux.microsoft.com> wrote: > As per guidance technical board meeting 2024/04/17. This series > removes the use of VLAs from code built for Windows for all 3 > toolchains. If there are additional opportunities to convert VLAs > to regular C arrays please provide the details for incorporation > into the series. > > MSVC does not support VLAs, replace VLAs with standard C arrays > or alloca(). alloca() is available for all toolchain/platform > combinations officially supported by DPDK. > > Tyler Retzlaff (16): > eal: include header required for alloca > hash: remove use of VLAs for Windows built code > ethdev: remove use of VLAs for Windows built code > gro: remove use of VLAs for Windows built code > latencystats: remove use of VLAs for Windows built code > lpm: remove use of VLAs for Windows built code > rcu: remove use of VLAs for Windows built code > app/testpmd: remove use of VLAs for Windows built code > test: remove use of VLAs for Windows built code > common/idpf: remove use of VLAs for Windows built code > net/i40e: remove use of VLAs for Windows built code > net/ice: remove use of VLAs for Windows built code > net/ixgbe: remove use of VLAs for Windows built code > common/mlx5: remove use of VLAs for Windows built code > net/mlx5: remove use of VLAs for Windows built code > build: enable vla warnings on Windows built code > > app/test-pmd/cmdline.c | 2 +- > app/test-pmd/cmdline_flow.c | 9 +++-- > app/test-pmd/config.c | 16 +++++---- > app/test-pmd/shared_rxq_fwd.c | 2 +- > app/test/test.c | 2 +- > app/test/test_cmdline_string.c | 2 +- > app/test/test_cryptodev.c | 32 +++++++++--------- > app/test/test_cryptodev_blockcipher.c | 4 +-- > app/test/test_cryptodev_crosscheck.c | 2 +- > app/test/test_dmadev.c | 9 +++-- > app/test/test_hash.c | 8 ++--- > app/test/test_mempool.c | 25 +++++++------- > app/test/test_reassembly_perf.c | 4 +-- > app/test/test_reorder.c | 48 +++++++++++++++------------ > app/test/test_service_cores.c | 9 +++-- > app/test/test_thash.c | 7 ++-- > config/meson.build | 4 +++ > drivers/common/idpf/idpf_common_rxtx.c | 2 +- > drivers/common/idpf/idpf_common_rxtx_avx512.c | 6 ++-- > drivers/common/mlx5/mlx5_common.h | 4 +-- > drivers/common/mlx5/mlx5_devx_cmds.c | 7 ++-- > drivers/net/i40e/i40e_testpmd.c | 5 ++- > drivers/net/ice/ice_rxtx.c | 2 +- > drivers/net/ixgbe/ixgbe_ethdev.c | 5 +-- > drivers/net/ixgbe/ixgbe_rxtx_vec_common.h | 2 +- > drivers/net/mlx5/mlx5.c | 5 ++- > drivers/net/mlx5/mlx5_flow.c | 6 ++-- > lib/eal/linux/include/rte_os.h | 1 + > lib/eal/windows/include/rte_os.h | 1 + > lib/ethdev/rte_ethdev.c | 9 ++--- > lib/gro/rte_gro.c | 4 +-- > lib/hash/rte_cuckoo_hash.c | 4 +-- > lib/hash/rte_thash.c | 2 +- > lib/latencystats/rte_latencystats.c | 2 +- > lib/lpm/rte_lpm.h | 2 +- > lib/rcu/rte_rcu_qsbr.c | 6 ++-- > 36 files changed, 137 insertions(+), 123 deletions(-) Looks good: Series-Acked-by: Stephen Hemminger <stephen@networkplumber.org> Series needs to be rebased to current master, some parts have changed. ^ permalink raw reply [flat|nested] 127+ messages in thread
* Re: [PATCH 00/16] remove use of VLAs for Windows built code 2024-10-07 17:15 ` [PATCH 00/16] remove use of VLAs for Windows built code Stephen Hemminger @ 2024-11-01 18:06 ` Andre Muezerie 0 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-01 18:06 UTC (permalink / raw) To: Stephen Hemminger Cc: Tyler Retzlaff, dev, Morten Brørup, Akhil Goyal, Aman Singh, Andrew Rybchenko, Bruce Richardson, Chengwen Feng, Dariusz Sosnowski, Dmitry Kozlyuk, Fan Zhang, Ferruh Yigit, Harry van Haaren, Honnappa Nagarahalli, Jiayu Hu, Jingjing Wu, Kevin Laatz, Konstantin Ananyev, Matan Azrad, Ori Kam, Pallavi Kadam, Reshma Pattan, Sameh Gobriel, Suanming Mou, Thomas Monjalon, Viacheslav Ovsiienko, Vladimir Medvedkin, Volodymyr Fialko, Yipeng Wang, Yuying Zhang On Mon, Oct 07, 2024 at 10:15:46AM -0700, Stephen Hemminger wrote: > On Wed, 17 Apr 2024 16:41:43 -0700 > Tyler Retzlaff <roretzla@linux.microsoft.com> wrote: > > > As per guidance technical board meeting 2024/04/17. This series > > removes the use of VLAs from code built for Windows for all 3 > > toolchains. If there are additional opportunities to convert VLAs > > to regular C arrays please provide the details for incorporation > > into the series. > > > > MSVC does not support VLAs, replace VLAs with standard C arrays > > or alloca(). alloca() is available for all toolchain/platform > > combinations officially supported by DPDK. > > > > Tyler Retzlaff (16): > > eal: include header required for alloca > > hash: remove use of VLAs for Windows built code > > ethdev: remove use of VLAs for Windows built code > > gro: remove use of VLAs for Windows built code > > latencystats: remove use of VLAs for Windows built code > > lpm: remove use of VLAs for Windows built code > > rcu: remove use of VLAs for Windows built code > > app/testpmd: remove use of VLAs for Windows built code > > test: remove use of VLAs for Windows built code > > common/idpf: remove use of VLAs for Windows built code > > net/i40e: remove use of VLAs for Windows built code > > net/ice: remove use of VLAs for Windows built code > > net/ixgbe: remove use of VLAs for Windows built code > > common/mlx5: remove use of VLAs for Windows built code > > net/mlx5: remove use of VLAs for Windows built code > > build: enable vla warnings on Windows built code > > > > app/test-pmd/cmdline.c | 2 +- > > app/test-pmd/cmdline_flow.c | 9 +++-- > > app/test-pmd/config.c | 16 +++++---- > > app/test-pmd/shared_rxq_fwd.c | 2 +- > > app/test/test.c | 2 +- > > app/test/test_cmdline_string.c | 2 +- > > app/test/test_cryptodev.c | 32 +++++++++--------- > > app/test/test_cryptodev_blockcipher.c | 4 +-- > > app/test/test_cryptodev_crosscheck.c | 2 +- > > app/test/test_dmadev.c | 9 +++-- > > app/test/test_hash.c | 8 ++--- > > app/test/test_mempool.c | 25 +++++++------- > > app/test/test_reassembly_perf.c | 4 +-- > > app/test/test_reorder.c | 48 +++++++++++++++------------ > > app/test/test_service_cores.c | 9 +++-- > > app/test/test_thash.c | 7 ++-- > > config/meson.build | 4 +++ > > drivers/common/idpf/idpf_common_rxtx.c | 2 +- > > drivers/common/idpf/idpf_common_rxtx_avx512.c | 6 ++-- > > drivers/common/mlx5/mlx5_common.h | 4 +-- > > drivers/common/mlx5/mlx5_devx_cmds.c | 7 ++-- > > drivers/net/i40e/i40e_testpmd.c | 5 ++- > > drivers/net/ice/ice_rxtx.c | 2 +- > > drivers/net/ixgbe/ixgbe_ethdev.c | 5 +-- > > drivers/net/ixgbe/ixgbe_rxtx_vec_common.h | 2 +- > > drivers/net/mlx5/mlx5.c | 5 ++- > > drivers/net/mlx5/mlx5_flow.c | 6 ++-- > > lib/eal/linux/include/rte_os.h | 1 + > > lib/eal/windows/include/rte_os.h | 1 + > > lib/ethdev/rte_ethdev.c | 9 ++--- > > lib/gro/rte_gro.c | 4 +-- > > lib/hash/rte_cuckoo_hash.c | 4 +-- > > lib/hash/rte_thash.c | 2 +- > > lib/latencystats/rte_latencystats.c | 2 +- > > lib/lpm/rte_lpm.h | 2 +- > > lib/rcu/rte_rcu_qsbr.c | 6 ++-- > > 36 files changed, 137 insertions(+), 123 deletions(-) > > Looks good: > > Series-Acked-by: Stephen Hemminger <stephen@networkplumber.org> > > > Series needs to be rebased to current master, some parts have changed. Hi Stephen, I'll continue the work Tyler was doing on this front. You can expect a new rebased patch soon. I'll also adapt it for the parts that have changed. ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v4 00/19] remove use of VLAs for Windows 2024-04-17 23:41 [PATCH 00/16] remove use of VLAs for Windows built code Tyler Retzlaff ` (20 preceding siblings ...) 2024-10-07 17:15 ` [PATCH 00/16] remove use of VLAs for Windows built code Stephen Hemminger @ 2024-11-05 3:15 ` Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 01/19] eal: include header required for alloca Andre Muezerie ` (19 more replies) 2024-11-08 0:44 ` [PATCH v5 00/20] " Andre Muezerie 22 siblings, 20 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-05 3:15 UTC (permalink / raw) To: stephen Cc: aman.deep.singh, anatoly.burakov, andrew.rybchenko, bruce.richardson, dev, dmitry.kozliuk, dsosnowski, fanzhang.oss, fengchengwen, ferruh.yigit, gakhil, harry.van.haaren, hkalra, honnappa.nagarahalli, hujiayu.hu, jingjing.wu, kevin.laatz, konstantin.v.ananyev, matan, mb, orika, pallavi.kadam, reshma.pattan, roretzla, sameh.gobriel, suanmingm, thomas, vfialko, viacheslavo, vladimir.medvedkin, yipeng1.wang, Andre Muezerie As per guidance technical board meeting 2024/04/17. This series removes the use of VLAs from code built for Windows for all 3 toolchains. If there are additional opportunities to convert VLAs to regular C arrays please provide the details for incorporation into the series. MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. v4: * rebase and adapt for changes made in main since v3 was sent * use fixed maximum array size instead of VLA when doable v3: * address checkpatch/check git log warnings (minor typos) v2: * replace patches for ethdev, hash, rcu and include new patches for eal from Konstantin Ananyev from https://patchwork.dpdk.org/project/dpdk/list/?series=31781 Andre Muezerie (2): test: remove use of VLAs for Windows built code in bitset tests app/testpmd: remove use of VLAs for Windows built code in shared_rxq_fwd Konstantin Ananyev (6): eal/linux: remove use of VLAs eal/common: remove use of VLAs ethdev: remove use of VLAs for Windows built code hash: remove use of VLAs for Windows built code hash/thash: remove use of VLAs for Windows built rcu: remove use of VLAs for Windows built code Tyler Retzlaff (11): eal: include header required for alloca gro: remove use of VLAs for Windows built code app/testpmd: remove use of VLAs for Windows built test: remove use of VLAs for Windows built code common/idpf: remove use of VLAs for Windows built code net/i40e: remove use of VLAs for Windows built code net/ice: remove use of VLAs for Windows built code net/ixgbe: remove use of VLAs for Windows built code common/mlx5: remove use of VLAs for Windows built code net/mlx5: remove use of VLAs for Windows built code build: enable vla warnings on Windows built code app/test-pmd/cmdline.c | 2 +- app/test-pmd/cmdline_flow.c | 15 +- app/test-pmd/config.c | 16 +- app/test-pmd/shared_rxq_fwd.c | 2 +- app/test/test.c | 2 +- app/test/test_bitset.c | 55 +++--- app/test/test_cmdline_string.c | 2 +- app/test/test_cryptodev.c | 34 ++-- app/test/test_cryptodev_blockcipher.c | 4 +- app/test/test_cryptodev_crosscheck.c | 2 +- app/test/test_dmadev.c | 9 +- app/test/test_hash.c | 14 +- app/test/test_mempool.c | 25 +-- app/test/test_reassembly_perf.c | 4 +- app/test/test_reorder.c | 48 ++--- app/test/test_service_cores.c | 9 +- app/test/test_thash.c | 7 +- config/meson.build | 4 + drivers/common/idpf/idpf_common_rxtx.c | 2 +- drivers/common/idpf/idpf_common_rxtx_avx512.c | 6 +- drivers/common/mlx5/mlx5_common.h | 4 +- drivers/common/mlx5/mlx5_devx_cmds.c | 7 +- drivers/net/i40e/i40e_testpmd.c | 5 +- drivers/net/ice/ice_rxtx.c | 2 +- drivers/net/ixgbe/ixgbe_ethdev.c | 5 +- drivers/net/ixgbe/ixgbe_rxtx_vec_common.h | 2 +- drivers/net/mlx5/mlx5.c | 5 +- drivers/net/mlx5/mlx5_flow.c | 6 +- lib/eal/common/eal_common_proc.c | 5 +- lib/eal/linux/eal_interrupts.c | 59 +++++- lib/eal/linux/include/rte_os.h | 1 + lib/eal/windows/include/rte_os.h | 1 + lib/ethdev/rte_ethdev.c | 183 +++++++++++------- lib/gro/rte_gro.c | 4 +- lib/hash/rte_cuckoo_hash.c | 4 +- lib/hash/rte_thash.c | 2 +- lib/hash/rte_thash.h | 8 + lib/rcu/rte_rcu_qsbr.c | 7 +- lib/rcu/rte_rcu_qsbr.h | 5 + 39 files changed, 354 insertions(+), 223 deletions(-) -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v4 01/19] eal: include header required for alloca 2024-11-05 3:15 ` [PATCH v4 00/19] remove use of VLAs for Windows Andre Muezerie @ 2024-11-05 3:15 ` Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 02/19] eal/linux: remove use of VLAs Andre Muezerie ` (18 subsequent siblings) 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-05 3:15 UTC (permalink / raw) To: stephen Cc: aman.deep.singh, anatoly.burakov, andrew.rybchenko, bruce.richardson, dev, dmitry.kozliuk, dsosnowski, fanzhang.oss, fengchengwen, ferruh.yigit, gakhil, harry.van.haaren, hkalra, honnappa.nagarahalli, hujiayu.hu, jingjing.wu, kevin.laatz, konstantin.v.ananyev, matan, mb, orika, pallavi.kadam, reshma.pattan, roretzla, sameh.gobriel, suanmingm, thomas, vfialko, viacheslavo, vladimir.medvedkin, yipeng1.wang From: Tyler Retzlaff <roretzla@linux.microsoft.com> Include alloca.h for Linux and malloc.h for Windows to get declaration of alloca(). Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- lib/eal/linux/include/rte_os.h | 1 + lib/eal/windows/include/rte_os.h | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/eal/linux/include/rte_os.h b/lib/eal/linux/include/rte_os.h index 35c07c70cb..20eff0409a 100644 --- a/lib/eal/linux/include/rte_os.h +++ b/lib/eal/linux/include/rte_os.h @@ -10,6 +10,7 @@ * which is not supported natively or named differently in Linux. */ +#include <alloca.h> #include <sched.h> #include <sys/queue.h> diff --git a/lib/eal/windows/include/rte_os.h b/lib/eal/windows/include/rte_os.h index 9d69467aaa..d09adeb3b4 100644 --- a/lib/eal/windows/include/rte_os.h +++ b/lib/eal/windows/include/rte_os.h @@ -13,6 +13,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <malloc.h> #include <sched.h> -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v4 02/19] eal/linux: remove use of VLAs 2024-11-05 3:15 ` [PATCH v4 00/19] remove use of VLAs for Windows Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 01/19] eal: include header required for alloca Andre Muezerie @ 2024-11-05 3:15 ` Andre Muezerie 2024-11-05 8:19 ` David Marchand 2024-11-05 3:15 ` [PATCH v4 03/19] eal/common: " Andre Muezerie ` (17 subsequent siblings) 19 siblings, 1 reply; 127+ messages in thread From: Andre Muezerie @ 2024-11-05 3:15 UTC (permalink / raw) To: stephen Cc: aman.deep.singh, anatoly.burakov, andrew.rybchenko, bruce.richardson, dev, dmitry.kozliuk, dsosnowski, fanzhang.oss, fengchengwen, ferruh.yigit, gakhil, harry.van.haaren, hkalra, honnappa.nagarahalli, hujiayu.hu, jingjing.wu, kevin.laatz, konstantin.v.ananyev, matan, mb, orika, pallavi.kadam, reshma.pattan, roretzla, sameh.gobriel, suanmingm, thomas, vfialko, viacheslavo, vladimir.medvedkin, yipeng1.wang, Konstantin Ananyev From: Konstantin Ananyev <konstantin.ananyev@huawei.com> 1) ./lib/eal/linux/eal_interrupts.c:1073:16 : warning: ISO C90 forbids variable length array ‘events’ eal_intr_handle_interrupts() is called by eal_intr_thread_main() so it seems ok to simply alloc space for events from heap and reuse the same buffer through the life of the thread. 2) ./lib/eal/linux/eal_interrupts.c:1319:16 : warning: ISO C90 forbids variable length array ‘evs’ make eal_epoll_wait() use a fixed size array and use it though multiple iterations to process up to @maxevents events. Note that technically it is not one to one replacement, as here we might reduce number of events returned by first call to epoll_wait(..., timeout); Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> --- lib/eal/linux/eal_interrupts.c | 59 ++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 7 deletions(-) diff --git a/lib/eal/linux/eal_interrupts.c b/lib/eal/linux/eal_interrupts.c index 6436f796eb..d62bb80a3e 100644 --- a/lib/eal/linux/eal_interrupts.c +++ b/lib/eal/linux/eal_interrupts.c @@ -34,6 +34,8 @@ #define EAL_INTR_EPOLL_WAIT_FOREVER (-1) #define NB_OTHER_INTR 1 +#define MAX_ITER_EVNUM RTE_EVENT_ETH_INTR_RING_SIZE + static RTE_DEFINE_PER_LCORE(int, _epfd) = -1; /**< epoll fd per thread */ /** @@ -1068,9 +1070,9 @@ eal_intr_process_interrupts(struct epoll_event *events, int nfds) * void */ static void -eal_intr_handle_interrupts(int pfd, unsigned totalfds) +eal_intr_handle_interrupts(int pfd, struct epoll_event events[], + unsigned int totalfds) { - struct epoll_event events[totalfds]; int nfds = 0; for(;;) { @@ -1106,6 +1108,12 @@ eal_intr_handle_interrupts(int pfd, unsigned totalfds) static __rte_noreturn uint32_t eal_intr_thread_main(__rte_unused void *arg) { + uint32_t n, nb_event; + struct epoll_event *events, *p; + + nb_event = 0; + events = NULL; + /* host thread, never break out */ for (;;) { /* build up the epoll fd with all descriptors we are to @@ -1159,8 +1167,23 @@ eal_intr_thread_main(__rte_unused void *arg) numfds++; } rte_spinlock_unlock(&intr_lock); + + /* alloc space for events, when necessary */ + if (numfds > nb_event) { + n = numfds + MAX_ITER_EVNUM; + p = realloc(events, n * sizeof(events[0])); + if (p == NULL) { + EAL_LOG(ERR, "failed to allocate %u events", + numfds); + numfds = nb_event; + } else { + nb_event = n; + events = p; + } + } + /* serve the interrupt */ - eal_intr_handle_interrupts(pfd, numfds); + eal_intr_handle_interrupts(pfd, events, numfds); /** * when we return, we need to rebuild the @@ -1168,6 +1191,8 @@ eal_intr_thread_main(__rte_unused void *arg) */ close(pfd); } + + free(events); } int @@ -1316,8 +1341,9 @@ static int eal_epoll_wait(int epfd, struct rte_epoll_event *events, int maxevents, int timeout, bool interruptible) { - struct epoll_event evs[maxevents]; int rc; + uint32_t i, k, n, num; + struct epoll_event evs[MAX_ITER_EVNUM]; if (!events) { EAL_LOG(ERR, "rte_epoll_event can't be NULL"); @@ -1328,12 +1354,31 @@ eal_epoll_wait(int epfd, struct rte_epoll_event *events, if (epfd == RTE_EPOLL_PER_THREAD) epfd = rte_intr_tls_epfd(); + num = maxevents; + n = RTE_MIN(RTE_DIM(evs), num); + + /* Process events in chunks of MAX_ITER_EVNUM */ + while (1) { - rc = epoll_wait(epfd, evs, maxevents, timeout); + rc = epoll_wait(epfd, evs, n, timeout); if (likely(rc > 0)) { + /* epoll_wait has at least one fd ready to read */ - rc = eal_epoll_process_event(evs, rc, events); - break; + for (i = 0, k = 0; rc > 0;) { + k += rc; + rc = eal_epoll_process_event(evs, rc, + events + i); + i += rc; + + /* + * try to read more events that are already + * available (up to maxevents in total). + */ + n = RTE_MIN(RTE_DIM(evs), num - k); + rc = (n == 0) ? 0 : epoll_wait(epfd, evs, n, 0); + } + return i; + } else if (rc < 0) { if (errno == EINTR) { if (interruptible) -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* Re: [PATCH v4 02/19] eal/linux: remove use of VLAs 2024-11-05 3:15 ` [PATCH v4 02/19] eal/linux: remove use of VLAs Andre Muezerie @ 2024-11-05 8:19 ` David Marchand 2024-11-06 2:02 ` Andre Muezerie 0 siblings, 1 reply; 127+ messages in thread From: David Marchand @ 2024-11-05 8:19 UTC (permalink / raw) To: Andre Muezerie Cc: stephen, aman.deep.singh, anatoly.burakov, andrew.rybchenko, bruce.richardson, dev, dmitry.kozliuk, dsosnowski, fanzhang.oss, fengchengwen, ferruh.yigit, gakhil, harry.van.haaren, hkalra, honnappa.nagarahalli, hujiayu.hu, jingjing.wu, kevin.laatz, konstantin.v.ananyev, matan, mb, orika, pallavi.kadam, reshma.pattan, roretzla, sameh.gobriel, suanmingm, thomas, vfialko, viacheslavo, vladimir.medvedkin, yipeng1.wang, Konstantin Ananyev Hello Andre, Thanks for taking over this series. On Tue, Nov 5, 2024 at 4:18 AM Andre Muezerie <andremue@linux.microsoft.com> wrote: > > From: Konstantin Ananyev <konstantin.ananyev@huawei.com> > > 1) ./lib/eal/linux/eal_interrupts.c:1073:16 > : warning: ISO C90 forbids variable length array ‘events’ > > eal_intr_handle_interrupts() is called by eal_intr_thread_main() > so it seems ok to simply alloc space for events from heap and reuse the > same buffer through the life of the thread. ASan reports this allocation as a leak because nothing releases it when terminating the interrupt thread. ================================================================= ==83289==ERROR: LeakSanitizer: detected memory leaks Direct leak of 12300 byte(s) in 1 object(s) allocated from: #0 0x55903c9a54b6 in __interceptor_realloc (/home/runner/work/dpdk/dpdk/build/app/dpdk-test+0x2744b6) (BuildId: e8a4f6c67f5c6afc20efb5f168c0df885d4c6493) #1 0x7f0011ee8873 in eal_intr_thread_main /home/runner/work/dpdk/dpdk/build/../lib/eal/linux/eal_interrupts.c:1174:8 #2 0x7f0010694ac2 in start_thread nptl/./nptl/pthread_create.c:442:8 SUMMARY: AddressSanitizer: 12300 byte(s) leaked in 1 allocation(s). ------------------------------------------------------------------------------ It will need some rework. -- David Marchand ^ permalink raw reply [flat|nested] 127+ messages in thread
* Re: [PATCH v4 02/19] eal/linux: remove use of VLAs 2024-11-05 8:19 ` David Marchand @ 2024-11-06 2:02 ` Andre Muezerie 2024-11-08 13:44 ` Konstantin Ananyev 0 siblings, 1 reply; 127+ messages in thread From: Andre Muezerie @ 2024-11-06 2:02 UTC (permalink / raw) To: David Marchand Cc: stephen, aman.deep.singh, anatoly.burakov, andrew.rybchenko, bruce.richardson, dev, dmitry.kozliuk, dsosnowski, fanzhang.oss, fengchengwen, ferruh.yigit, gakhil, harry.van.haaren, hkalra, honnappa.nagarahalli, hujiayu.hu, jingjing.wu, kevin.laatz, konstantin.v.ananyev, matan, mb, orika, pallavi.kadam, reshma.pattan, roretzla, sameh.gobriel, suanmingm, thomas, vfialko, viacheslavo, vladimir.medvedkin, yipeng1.wang, Konstantin Ananyev On Tue, Nov 05, 2024 at 09:19:25AM +0100, David Marchand wrote: > Hello Andre, > > Thanks for taking over this series. > > On Tue, Nov 5, 2024 at 4:18 AM Andre Muezerie > <andremue@linux.microsoft.com> wrote: > > > > From: Konstantin Ananyev <konstantin.ananyev@huawei.com> > > > > 1) ./lib/eal/linux/eal_interrupts.c:1073:16 > > : warning: ISO C90 forbids variable length array ‘events’ > > > > eal_intr_handle_interrupts() is called by eal_intr_thread_main() > > so it seems ok to simply alloc space for events from heap and reuse the > > same buffer through the life of the thread. > > ASan reports this allocation as a leak because nothing releases it > when terminating the interrupt thread. > > ================================================================= > ==83289==ERROR: LeakSanitizer: detected memory leaks > > Direct leak of 12300 byte(s) in 1 object(s) allocated from: > #0 0x55903c9a54b6 in __interceptor_realloc > (/home/runner/work/dpdk/dpdk/build/app/dpdk-test+0x2744b6) (BuildId: > e8a4f6c67f5c6afc20efb5f168c0df885d4c6493) > #1 0x7f0011ee8873 in eal_intr_thread_main > /home/runner/work/dpdk/dpdk/build/../lib/eal/linux/eal_interrupts.c:1174:8 > #2 0x7f0010694ac2 in start_thread nptl/./nptl/pthread_create.c:442:8 > > SUMMARY: AddressSanitizer: 12300 byte(s) leaked in 1 allocation(s). > ------------------------------------------------------------------------------ > > It will need some rework. > > > -- > David Marchand Thanks David, I'll look into this. ^ permalink raw reply [flat|nested] 127+ messages in thread
* RE: [PATCH v4 02/19] eal/linux: remove use of VLAs 2024-11-06 2:02 ` Andre Muezerie @ 2024-11-08 13:44 ` Konstantin Ananyev 0 siblings, 0 replies; 127+ messages in thread From: Konstantin Ananyev @ 2024-11-08 13:44 UTC (permalink / raw) To: Andre Muezerie, David Marchand Cc: stephen, aman.deep.singh, anatoly.burakov, andrew.rybchenko, bruce.richardson, dev, dmitry.kozliuk, dsosnowski, fanzhang.oss, Fengchengwen, ferruh.yigit, gakhil, harry.van.haaren, hkalra, honnappa.nagarahalli, hujiayu.hu, jingjing.wu, kevin.laatz, konstantin.v.ananyev, matan, mb, orika, pallavi.kadam, reshma.pattan, roretzla, sameh.gobriel, suanmingm, thomas, vfialko, viacheslavo, vladimir.medvedkin, yipeng1.wang > On Tue, Nov 05, 2024 at 09:19:25AM +0100, David Marchand wrote: > > Hello Andre, > > > > Thanks for taking over this series. > > > > On Tue, Nov 5, 2024 at 4:18 AM Andre Muezerie > > <andremue@linux.microsoft.com> wrote: > > > > > > From: Konstantin Ananyev <konstantin.ananyev@huawei.com> > > > > > > 1) ./lib/eal/linux/eal_interrupts.c:1073:16 > > > : warning: ISO C90 forbids variable length array ‘events’ > > > > > > eal_intr_handle_interrupts() is called by eal_intr_thread_main() > > > so it seems ok to simply alloc space for events from heap and reuse the > > > same buffer through the life of the thread. > > > > ASan reports this allocation as a leak because nothing releases it > > when terminating the interrupt thread. > > > > ================================================================= > > ==83289==ERROR: LeakSanitizer: detected memory leaks > > > > Direct leak of 12300 byte(s) in 1 object(s) allocated from: > > #0 0x55903c9a54b6 in __interceptor_realloc > > (/home/runner/work/dpdk/dpdk/build/app/dpdk-test+0x2744b6) (BuildId: > > e8a4f6c67f5c6afc20efb5f168c0df885d4c6493) > > #1 0x7f0011ee8873 in eal_intr_thread_main > > /home/runner/work/dpdk/dpdk/build/../lib/eal/linux/eal_interrupts.c:1174:8 > > #2 0x7f0010694ac2 in start_thread nptl/./nptl/pthread_create.c:442:8 > > > > SUMMARY: AddressSanitizer: 12300 byte(s) leaked in 1 allocation(s). > > ------------------------------------------------------------------------------ > > > > It will need some rework. My bad, forgot that interrupt thread never exits normally. As I saw Andre already updated a patch with revering back to alloca(), which I suppose is ok. Though I wonder would pthread_cleanup_push() and keeping realloc() be a good alternative here? ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v4 03/19] eal/common: remove use of VLAs 2024-11-05 3:15 ` [PATCH v4 00/19] remove use of VLAs for Windows Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 01/19] eal: include header required for alloca Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 02/19] eal/linux: remove use of VLAs Andre Muezerie @ 2024-11-05 3:15 ` Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 04/19] ethdev: remove use of VLAs for Windows built code Andre Muezerie ` (16 subsequent siblings) 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-05 3:15 UTC (permalink / raw) To: stephen Cc: aman.deep.singh, anatoly.burakov, andrew.rybchenko, bruce.richardson, dev, dmitry.kozliuk, dsosnowski, fanzhang.oss, fengchengwen, ferruh.yigit, gakhil, harry.van.haaren, hkalra, honnappa.nagarahalli, hujiayu.hu, jingjing.wu, kevin.laatz, konstantin.v.ananyev, matan, mb, orika, pallavi.kadam, reshma.pattan, roretzla, sameh.gobriel, suanmingm, thomas, vfialko, viacheslavo, vladimir.medvedkin, yipeng1.wang, Konstantin Ananyev From: Konstantin Ananyev <konstantin.ananyev@huawei.com> 1) ../lib/eal/common/eal_common_proc.c:695:15 : warning: variable length array used As msg->num_fds should not exceed RTE_MP_MAX_FD_NUM, replaced it with fixed size array. Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> --- lib/eal/common/eal_common_proc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/eal/common/eal_common_proc.c b/lib/eal/common/eal_common_proc.c index d24093937c..201973c5db 100644 --- a/lib/eal/common/eal_common_proc.c +++ b/lib/eal/common/eal_common_proc.c @@ -692,7 +692,8 @@ send_msg(const char *dst_path, struct rte_mp_msg *msg, int type) struct sockaddr_un dst; struct mp_msg_internal m; int fd_size = msg->num_fds * sizeof(int); - char control[CMSG_SPACE(fd_size)]; + const int32_t control_sz = CMSG_SPACE(fd_size); + char control[CMSG_SPACE(sizeof(msg->fds))]; m.type = type; memcpy(&m.msg, msg, sizeof(*msg)); @@ -712,7 +713,7 @@ send_msg(const char *dst_path, struct rte_mp_msg *msg, int type) msgh.msg_iov = &iov; msgh.msg_iovlen = 1; msgh.msg_control = control; - msgh.msg_controllen = sizeof(control); + msgh.msg_controllen = control_sz; cmsg = CMSG_FIRSTHDR(&msgh); cmsg->cmsg_len = CMSG_LEN(fd_size); -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v4 04/19] ethdev: remove use of VLAs for Windows built code 2024-11-05 3:15 ` [PATCH v4 00/19] remove use of VLAs for Windows Andre Muezerie ` (2 preceding siblings ...) 2024-11-05 3:15 ` [PATCH v4 03/19] eal/common: " Andre Muezerie @ 2024-11-05 3:15 ` Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 05/19] hash: " Andre Muezerie ` (15 subsequent siblings) 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-05 3:15 UTC (permalink / raw) To: stephen Cc: aman.deep.singh, anatoly.burakov, andrew.rybchenko, bruce.richardson, dev, dmitry.kozliuk, dsosnowski, fanzhang.oss, fengchengwen, ferruh.yigit, gakhil, harry.van.haaren, hkalra, honnappa.nagarahalli, hujiayu.hu, jingjing.wu, kevin.laatz, konstantin.v.ananyev, matan, mb, orika, pallavi.kadam, reshma.pattan, roretzla, sameh.gobriel, suanmingm, thomas, vfialko, viacheslavo, vladimir.medvedkin, yipeng1.wang, Konstantin Ananyev From: Konstantin Ananyev <konstantin.ananyev@huawei.com> 1) ./lib/ethdev/rte_ethdev.c:3244:16 : warning: ISO C90 forbids variable length array ‘xstats_names’ 2) ./lib/ethdev/rte_ethdev.c:3345:17 : warning: ISO C90 forbids variable length array ‘ids_copy’ 3) ./lib/ethdev/rte_ethdev.c:3538:16 : warning: ISO C90 forbids variable length array ‘xstats’ 4) ./lib/ethdev/rte_ethdev.c:3554:17 : warning: ISO C90 forbids variable length array ‘ids_copy’ For 1) and 3) - just replaced VLA with arrays allocated from heap. As I understand xstats extraction belongs to control-path, so extra calloc/free is hopefully acceptable. Also ethdev xstats already doing that within rte_eth_xstats_get_id_by_name(). For 2) and 4) changed the code to use fixed size array and call appropriate devops function several times, if needed. Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> --- lib/ethdev/rte_ethdev.c | 183 +++++++++++++++++++++++++--------------- 1 file changed, 113 insertions(+), 70 deletions(-) diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 6413c54e3b..09cc4764c3 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -36,6 +36,8 @@ #include "ethdev_trace.h" #include "sff_telemetry.h" +#define ETH_XSTATS_ITER_NUM 0x100 + struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS]; /* public fast-path API */ @@ -3308,7 +3310,8 @@ int rte_eth_xstats_get_id_by_name(uint16_t port_id, const char *xstat_name, uint64_t *id) { - int cnt_xstats, idx_xstat; + int cnt_xstats, idx_xstat, rc; + struct rte_eth_xstat_name *xstats_names; RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); @@ -3334,26 +3337,33 @@ rte_eth_xstats_get_id_by_name(uint16_t port_id, const char *xstat_name, } /* Get id-name lookup table */ - struct rte_eth_xstat_name xstats_names[cnt_xstats]; + xstats_names = calloc(cnt_xstats, sizeof(xstats_names[0])); + if (xstats_names == NULL) { + RTE_ETHDEV_LOG_LINE(ERR, "Can't allocate memory"); + return -ENOMEM; + } if (cnt_xstats != rte_eth_xstats_get_names_by_id( port_id, xstats_names, cnt_xstats, NULL)) { RTE_ETHDEV_LOG_LINE(ERR, "Cannot get xstats lookup"); + free(xstats_names); return -1; } + rc = -EINVAL; for (idx_xstat = 0; idx_xstat < cnt_xstats; idx_xstat++) { if (!strcmp(xstats_names[idx_xstat].name, xstat_name)) { *id = idx_xstat; rte_eth_trace_xstats_get_id_by_name(port_id, xstat_name, *id); - - return 0; + rc = 0; + break; }; } - return -EINVAL; + free(xstats_names); + return rc; } /* retrieve basic stats names */ @@ -3399,6 +3409,38 @@ eth_basic_stats_get_names(struct rte_eth_dev *dev, return cnt_used_entries; } +static int +eth_xstats_get_by_name_by_id(struct rte_eth_dev *dev, const uint64_t *ids, + struct rte_eth_xstat_name *xstats_names, uint32_t size, + uint32_t basic_count) +{ + int32_t rc; + uint32_t i, k, m, n; + uint64_t ids_copy[ETH_XSTATS_ITER_NUM]; + + m = 0; + for (n = 0; n != size; n += k) { + + k = RTE_MIN(size - n, RTE_DIM(ids_copy)); + + /* + * Convert ids to xstats ids that PMD knows. + * ids known by user are basic + extended stats. + */ + for (i = 0; i < k; i++) + ids_copy[i] = ids[n + i] - basic_count; + + rc = (*dev->dev_ops->xstats_get_names_by_id)(dev, ids_copy, + xstats_names + m, k); + if (rc < 0) + return rc; + m += rc; + } + + return m; +} + + /* retrieve ethdev extended statistics names */ int rte_eth_xstats_get_names_by_id(uint16_t port_id, @@ -3406,9 +3448,8 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id, uint64_t *ids) { struct rte_eth_xstat_name *xstats_names_copy; - unsigned int no_basic_stat_requested = 1; - unsigned int no_ext_stat_requested = 1; unsigned int expected_entries; + unsigned int nb_basic_stats; unsigned int basic_count; struct rte_eth_dev *dev; unsigned int i; @@ -3434,27 +3475,18 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id, if (ids && !xstats_names) return -EINVAL; - if (ids && dev->dev_ops->xstats_get_names_by_id != NULL && size > 0) { - uint64_t ids_copy[size]; - - for (i = 0; i < size; i++) { - if (ids[i] < basic_count) { - no_basic_stat_requested = 0; - break; - } - - /* - * Convert ids to xstats ids that PMD knows. - * ids known by user are basic + extended stats. - */ - ids_copy[i] = ids[i] - basic_count; - } - - if (no_basic_stat_requested) - return (*dev->dev_ops->xstats_get_names_by_id)(dev, - ids_copy, xstats_names, size); + nb_basic_stats = 0; + if (ids != NULL) { + for (i = 0; i < size; i++) + nb_basic_stats += (ids[i] < basic_count); } + /* no basic stats requested, devops function provided */ + if (nb_basic_stats == 0 && ids != NULL && size != 0 && + dev->dev_ops->xstats_get_names_by_id != NULL) + return eth_xstats_get_by_name_by_id(dev, ids, xstats_names, + size, basic_count); + /* Retrieve all stats */ if (!ids) { int num_stats = rte_eth_xstats_get_names(port_id, xstats_names, @@ -3473,17 +3505,8 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id, return -ENOMEM; } - if (ids) { - for (i = 0; i < size; i++) { - if (ids[i] >= basic_count) { - no_ext_stat_requested = 0; - break; - } - } - } - /* Fill xstats_names_copy structure */ - if (ids && no_ext_stat_requested) { + if (ids && nb_basic_stats == size) { eth_basic_stats_get_names(dev, xstats_names_copy); } else { ret = rte_eth_xstats_get_names(port_id, xstats_names_copy, @@ -3607,17 +3630,47 @@ eth_basic_stats_get(uint16_t port_id, struct rte_eth_xstat *xstats) return count; } +static int +eth_xtats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, + uint64_t *values, uint32_t size, uint32_t basic_count) +{ + int32_t rc; + uint32_t i, k, m, n; + uint64_t ids_copy[ETH_XSTATS_ITER_NUM]; + + m = 0; + for (n = 0; n != size; n += k) { + + k = RTE_MIN(size - n, RTE_DIM(ids_copy)); + + /* + * Convert ids to xstats ids that PMD knows. + * ids known by user are basic + extended stats. + */ + for (i = 0; i < k; i++) + ids_copy[i] = ids[n + i] - basic_count; + + rc = (*dev->dev_ops->xstats_get_by_id)(dev, ids_copy, + values + m, k); + if (rc < 0) + return rc; + m += rc; + } + + return m; +} + /* retrieve ethdev extended statistics */ int rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids, uint64_t *values, unsigned int size) { - unsigned int no_basic_stat_requested = 1; - unsigned int no_ext_stat_requested = 1; + unsigned int nb_basic_stats; unsigned int num_xstats_filled; unsigned int basic_count; uint16_t expected_entries; struct rte_eth_dev *dev; + struct rte_eth_xstat *xstats; unsigned int i; int ret; @@ -3628,7 +3681,6 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids, if (ret < 0) return ret; expected_entries = (uint16_t)ret; - struct rte_eth_xstat xstats[expected_entries]; basic_count = eth_dev_get_xstats_basic_count(dev); /* Return max number of stats if no ids given */ @@ -3642,51 +3694,41 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids, if (ids && !values) return -EINVAL; - if (ids && dev->dev_ops->xstats_get_by_id != NULL && size) { - unsigned int basic_count = eth_dev_get_xstats_basic_count(dev); - uint64_t ids_copy[size]; - - for (i = 0; i < size; i++) { - if (ids[i] < basic_count) { - no_basic_stat_requested = 0; - break; - } - - /* - * Convert ids to xstats ids that PMD knows. - * ids known by user are basic + extended stats. - */ - ids_copy[i] = ids[i] - basic_count; - } - - if (no_basic_stat_requested) - return (*dev->dev_ops->xstats_get_by_id)(dev, ids_copy, - values, size); + nb_basic_stats = 0; + if (ids != NULL) { + for (i = 0; i < size; i++) + nb_basic_stats += (ids[i] < basic_count); } - if (ids) { - for (i = 0; i < size; i++) { - if (ids[i] >= basic_count) { - no_ext_stat_requested = 0; - break; - } - } + /* no basic stats requested, devops function provided */ + if (nb_basic_stats == 0 && ids != NULL && size != 0 && + dev->dev_ops->xstats_get_by_id != NULL) + return eth_xtats_get_by_id(dev, ids, values, size, basic_count); + + xstats = calloc(expected_entries, sizeof(xstats[0])); + if (xstats == NULL) { + RTE_ETHDEV_LOG_LINE(ERR, "Can't allocate memory"); + return -ENOMEM; } /* Fill the xstats structure */ - if (ids && no_ext_stat_requested) + if (ids && nb_basic_stats == size) ret = eth_basic_stats_get(port_id, xstats); else ret = rte_eth_xstats_get(port_id, xstats, expected_entries); - if (ret < 0) + if (ret < 0) { + free(xstats); return ret; + } num_xstats_filled = (unsigned int)ret; /* Return all stats */ if (!ids) { for (i = 0; i < num_xstats_filled; i++) values[i] = xstats[i].value; + + free(xstats); return expected_entries; } @@ -3694,14 +3736,15 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids, for (i = 0; i < size; i++) { if (ids[i] >= expected_entries) { RTE_ETHDEV_LOG_LINE(ERR, "Id value isn't valid"); - return -1; + break; } values[i] = xstats[ids[i]].value; } rte_eth_trace_xstats_get_by_id(port_id, ids, values, size); - return size; + free(xstats); + return (i == size) ? (int32_t)size : -1; } int -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v4 05/19] hash: remove use of VLAs for Windows built code 2024-11-05 3:15 ` [PATCH v4 00/19] remove use of VLAs for Windows Andre Muezerie ` (3 preceding siblings ...) 2024-11-05 3:15 ` [PATCH v4 04/19] ethdev: remove use of VLAs for Windows built code Andre Muezerie @ 2024-11-05 3:15 ` Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 06/19] hash/thash: remove use of VLAs for Windows built Andre Muezerie ` (14 subsequent siblings) 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-05 3:15 UTC (permalink / raw) To: stephen Cc: aman.deep.singh, anatoly.burakov, andrew.rybchenko, bruce.richardson, dev, dmitry.kozliuk, dsosnowski, fanzhang.oss, fengchengwen, ferruh.yigit, gakhil, harry.van.haaren, hkalra, honnappa.nagarahalli, hujiayu.hu, jingjing.wu, kevin.laatz, konstantin.v.ananyev, matan, mb, orika, pallavi.kadam, reshma.pattan, roretzla, sameh.gobriel, suanmingm, thomas, vfialko, viacheslavo, vladimir.medvedkin, yipeng1.wang, Konstantin Ananyev From: Konstantin Ananyev <konstantin.ananyev@huawei.com> 1) ./lib/hash/rte_cuckoo_hash.c:2362:9 : warning: ISO C90 forbids variable length array ‘positions’ 2) ../lib/hash/rte_cuckoo_hash.c:2478:9 : warning: ISO C90 forbids variable length array ‘positions’ Both rte_hash_lookup_bulk_data() and rte_hash_lookup_with_hash_bulk_data() expect @num_keys <= RTE_HASH_LOOKUP_BULK_MAX. So, for both cases it should be safe to replace VLA with fixed size array. Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> --- lib/hash/rte_cuckoo_hash.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c index 9575e8aa0c..fc93182efe 100644 --- a/lib/hash/rte_cuckoo_hash.c +++ b/lib/hash/rte_cuckoo_hash.c @@ -2418,7 +2418,7 @@ rte_hash_lookup_bulk_data(const struct rte_hash *h, const void **keys, (num_keys > RTE_HASH_LOOKUP_BULK_MAX) || (hit_mask == NULL)), -EINVAL); - int32_t positions[num_keys]; + int32_t positions[RTE_HASH_LOOKUP_BULK_MAX]; __rte_hash_lookup_bulk(h, keys, num_keys, positions, hit_mask, data); @@ -2534,7 +2534,7 @@ rte_hash_lookup_with_hash_bulk_data(const struct rte_hash *h, (num_keys > RTE_HASH_LOOKUP_BULK_MAX) || (hit_mask == NULL)), -EINVAL); - int32_t positions[num_keys]; + int32_t positions[RTE_HASH_LOOKUP_BULK_MAX]; __rte_hash_lookup_with_hash_bulk(h, keys, sig, num_keys, positions, hit_mask, data); -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v4 06/19] hash/thash: remove use of VLAs for Windows built 2024-11-05 3:15 ` [PATCH v4 00/19] remove use of VLAs for Windows Andre Muezerie ` (4 preceding siblings ...) 2024-11-05 3:15 ` [PATCH v4 05/19] hash: " Andre Muezerie @ 2024-11-05 3:15 ` Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 07/19] rcu: remove use of VLAs for Windows built code Andre Muezerie ` (13 subsequent siblings) 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-05 3:15 UTC (permalink / raw) To: stephen Cc: aman.deep.singh, anatoly.burakov, andrew.rybchenko, bruce.richardson, dev, dmitry.kozliuk, dsosnowski, fanzhang.oss, fengchengwen, ferruh.yigit, gakhil, harry.van.haaren, hkalra, honnappa.nagarahalli, hujiayu.hu, jingjing.wu, kevin.laatz, konstantin.v.ananyev, matan, mb, orika, pallavi.kadam, reshma.pattan, roretzla, sameh.gobriel, suanmingm, thomas, vfialko, viacheslavo, vladimir.medvedkin, yipeng1.wang, Konstantin Ananyev From: Konstantin Ananyev <konstantin.ananyev@huawei.com> 1) ./lib/hash/rte_thash.c:774:9 : warning: ISO C90 forbids variable length array ‘tmp_tuple’ From my understanding, tuple size here should never exceed sizeof(union rte_thash_tuple), so it should be safe to replace VLA with fixed size array. Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> --- lib/hash/rte_thash.c | 2 +- lib/hash/rte_thash.h | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c index 99a685f0c8..8ecadb9fef 100644 --- a/lib/hash/rte_thash.c +++ b/lib/hash/rte_thash.c @@ -795,7 +795,7 @@ rte_thash_adjust_tuple(struct rte_thash_ctx *ctx, uint32_t desired_value, unsigned int attempts, rte_thash_check_tuple_t fn, void *userdata) { - uint32_t tmp_tuple[tuple_len / sizeof(uint32_t)]; + uint32_t tmp_tuple[RTE_THASH_MAX_L4_LEN]; unsigned int i, j, ret = 0; uint32_t hash, adj_bits; const uint8_t *hash_key; diff --git a/lib/hash/rte_thash.h b/lib/hash/rte_thash.h index e8fdb89530..3ee22c9e32 100644 --- a/lib/hash/rte_thash.h +++ b/lib/hash/rte_thash.h @@ -108,6 +108,14 @@ union rte_thash_tuple { struct rte_ipv6_tuple v6; }; +/** + * maximum length in dwords of input tuple to + * calculate hash of ipv(4|6) header + + * transport header + */ +#define RTE_THASH_MAX_L4_LEN \ + ((sizeof(union rte_thash_tuple)) / sizeof(uint32_t)) + /** * Prepare special converted key to use with rte_softrss_be() * @param orig -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v4 07/19] rcu: remove use of VLAs for Windows built code 2024-11-05 3:15 ` [PATCH v4 00/19] remove use of VLAs for Windows Andre Muezerie ` (5 preceding siblings ...) 2024-11-05 3:15 ` [PATCH v4 06/19] hash/thash: remove use of VLAs for Windows built Andre Muezerie @ 2024-11-05 3:15 ` Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 08/19] gro: " Andre Muezerie ` (12 subsequent siblings) 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-05 3:15 UTC (permalink / raw) To: stephen Cc: aman.deep.singh, anatoly.burakov, andrew.rybchenko, bruce.richardson, dev, dmitry.kozliuk, dsosnowski, fanzhang.oss, fengchengwen, ferruh.yigit, gakhil, harry.van.haaren, hkalra, honnappa.nagarahalli, hujiayu.hu, jingjing.wu, kevin.laatz, konstantin.v.ananyev, matan, mb, orika, pallavi.kadam, reshma.pattan, roretzla, sameh.gobriel, suanmingm, thomas, vfialko, viacheslavo, vladimir.medvedkin, yipeng1.wang, Konstantin Ananyev From: Konstantin Ananyev <konstantin.ananyev@huawei.com> 1) ./lib/rcu/rte_rcu_qsbr.c:359:9 : warning: ISO C90 forbids variable length array ‘data’ [-Wvla] 2) ./lib/rcu/rte_rcu_qsbr.c:422:9 : warning: ISO C90 forbids variable length array ‘data’ [-Wvla] In both cases we allocate VLA for one element from RCU deferred queue. Right now, size of element in RCU queue is not limited by API. The approach is to introduce some reasonable limitation on RCU DQ element size. Choose 128B for now. With that in place we can replace both VLA occurencies with fixed size array. Note that such change need to be treated as API change. So can be applied only at 24.11. Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> --- lib/rcu/rte_rcu_qsbr.c | 7 ++++--- lib/rcu/rte_rcu_qsbr.h | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/rcu/rte_rcu_qsbr.c b/lib/rcu/rte_rcu_qsbr.c index 40d7c566c8..09a14a15f1 100644 --- a/lib/rcu/rte_rcu_qsbr.c +++ b/lib/rcu/rte_rcu_qsbr.c @@ -245,7 +245,8 @@ rte_rcu_qsbr_dq_create(const struct rte_rcu_qsbr_dq_parameters *params) if (params == NULL || params->free_fn == NULL || params->v == NULL || params->name == NULL || params->size == 0 || params->esize == 0 || - (params->esize % 4 != 0)) { + (params->esize % 4 != 0) || + params->esize > RTE_QSBR_ESIZE_MAX) { RCU_LOG(ERR, "Invalid input parameter"); rte_errno = EINVAL; @@ -323,7 +324,7 @@ int rte_rcu_qsbr_dq_enqueue(struct rte_rcu_qsbr_dq *dq, void *e) return 1; } - char data[dq->esize]; + char data[RTE_QSBR_ESIZE_MAX + __RTE_QSBR_TOKEN_SIZE]; dq_elem = (__rte_rcu_qsbr_dq_elem_t *)data; /* Start the grace period */ dq_elem->token = rte_rcu_qsbr_start(dq->v); @@ -386,7 +387,7 @@ rte_rcu_qsbr_dq_reclaim(struct rte_rcu_qsbr_dq *dq, unsigned int n, cnt = 0; - char data[dq->esize]; + char data[RTE_QSBR_ESIZE_MAX + __RTE_QSBR_TOKEN_SIZE]; /* Check reader threads quiescent state and reclaim resources */ while (cnt < n && rte_ring_dequeue_bulk_elem_start(dq->r, &data, diff --git a/lib/rcu/rte_rcu_qsbr.h b/lib/rcu/rte_rcu_qsbr.h index 550fadf56a..abcbd78914 100644 --- a/lib/rcu/rte_rcu_qsbr.h +++ b/lib/rcu/rte_rcu_qsbr.h @@ -86,6 +86,11 @@ struct __rte_cache_aligned rte_rcu_qsbr_cnt { #define __RTE_QSBR_CNT_MAX ((uint64_t)~0) #define __RTE_QSBR_TOKEN_SIZE sizeof(uint64_t) +/** + * Max allowable size (in bytes) of each element in the defer queue + */ +#define RTE_QSBR_ESIZE_MAX (2 * RTE_CACHE_LINE_MIN_SIZE) + /* RTE Quiescent State variable structure. * This structure has two elements that vary in size based on the * 'max_threads' parameter. -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v4 08/19] gro: remove use of VLAs for Windows built code 2024-11-05 3:15 ` [PATCH v4 00/19] remove use of VLAs for Windows Andre Muezerie ` (6 preceding siblings ...) 2024-11-05 3:15 ` [PATCH v4 07/19] rcu: remove use of VLAs for Windows built code Andre Muezerie @ 2024-11-05 3:15 ` Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 09/19] app/testpmd: remove use of VLAs for Windows built Andre Muezerie ` (11 subsequent siblings) 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-05 3:15 UTC (permalink / raw) To: stephen Cc: aman.deep.singh, anatoly.burakov, andrew.rybchenko, bruce.richardson, dev, dmitry.kozliuk, dsosnowski, fanzhang.oss, fengchengwen, ferruh.yigit, gakhil, harry.van.haaren, hkalra, honnappa.nagarahalli, hujiayu.hu, jingjing.wu, kevin.laatz, konstantin.v.ananyev, matan, mb, orika, pallavi.kadam, reshma.pattan, roretzla, sameh.gobriel, suanmingm, thomas, vfialko, viacheslavo, vladimir.medvedkin, yipeng1.wang From: Tyler Retzlaff <roretzla@linux.microsoft.com> MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- lib/gro/rte_gro.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/gro/rte_gro.c b/lib/gro/rte_gro.c index d824eebd93..0f9e85c387 100644 --- a/lib/gro/rte_gro.c +++ b/lib/gro/rte_gro.c @@ -179,7 +179,7 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts, struct gro_vxlan_udp4_item vxlan_udp_items[RTE_GRO_MAX_BURST_ITEM_NUM] = {{{0}} }; - struct rte_mbuf *unprocess_pkts[nb_pkts]; + struct rte_mbuf **unprocess_pkts = alloca(sizeof(struct rte_mbuf *) * nb_pkts); uint32_t item_num; int32_t ret; uint16_t i, unprocess_num = 0, nb_after_gro = nb_pkts; @@ -360,7 +360,7 @@ rte_gro_reassemble(struct rte_mbuf **pkts, uint16_t nb_pkts, void *ctx) { - struct rte_mbuf *unprocess_pkts[nb_pkts]; + struct rte_mbuf **unprocess_pkts = alloca(sizeof(struct rte_mbuf *) * nb_pkts); struct gro_ctx *gro_ctx = ctx; void *tcp_tbl, *udp_tbl, *vxlan_tcp_tbl, *vxlan_udp_tbl, *tcp6_tbl; uint64_t current_time; -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v4 09/19] app/testpmd: remove use of VLAs for Windows built 2024-11-05 3:15 ` [PATCH v4 00/19] remove use of VLAs for Windows Andre Muezerie ` (7 preceding siblings ...) 2024-11-05 3:15 ` [PATCH v4 08/19] gro: " Andre Muezerie @ 2024-11-05 3:15 ` Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 10/19] test: remove use of VLAs for Windows built code Andre Muezerie ` (10 subsequent siblings) 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-05 3:15 UTC (permalink / raw) To: stephen Cc: aman.deep.singh, anatoly.burakov, andrew.rybchenko, bruce.richardson, dev, dmitry.kozliuk, dsosnowski, fanzhang.oss, fengchengwen, ferruh.yigit, gakhil, harry.van.haaren, hkalra, honnappa.nagarahalli, hujiayu.hu, jingjing.wu, kevin.laatz, konstantin.v.ananyev, matan, mb, orika, pallavi.kadam, reshma.pattan, roretzla, sameh.gobriel, suanmingm, thomas, vfialko, viacheslavo, vladimir.medvedkin, yipeng1.wang From: Tyler Retzlaff <roretzla@linux.microsoft.com> MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- app/test-pmd/cmdline.c | 2 +- app/test-pmd/cmdline_flow.c | 15 ++++++++++----- app/test-pmd/config.c | 16 +++++++++------- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 7e0666e9f6..2897e44c34 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -13274,7 +13274,7 @@ cmd_set_port_ptypes_parsed( return; } - uint32_t ptypes[ret]; + uint32_t *ptypes = alloca(sizeof(uint32_t) * ret); ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret); if (ret < 0) { diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 1e4f2ebc55..fb0c4f838d 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -11707,8 +11707,7 @@ parse_hex(struct context *ctx, const struct token *token, char tmp[16]; /* Ought to be enough. */ int ret; unsigned int hexlen = len; - unsigned int length = 256; - uint8_t hex_tmp[length]; + uint8_t hex_tmp[256]; /* Arguments are expected. */ if (!arg_data) @@ -11735,7 +11734,7 @@ parse_hex(struct context *ctx, const struct token *token, str += 2; hexlen -= 2; } - if (hexlen > length) + if (hexlen > RTE_DIM(hex_tmp)) goto error; ret = parse_hex_string(str, hex_tmp, &hexlen); if (ret < 0) @@ -11868,10 +11867,13 @@ parse_ipv4_addr(struct context *ctx, const struct token *token, void *buf, unsigned int size) { const struct arg *arg = pop_args(ctx); - char str2[len + 1]; + char str2[INET_ADDRSTRLEN]; struct in_addr tmp; int ret; + /* Length is longer than the max length an IPv4 address can have. */ + if (len >= INET_ADDRSTRLEN) + return -1; /* Argument is expected. */ if (!arg) return -1; @@ -11914,11 +11916,14 @@ parse_ipv6_addr(struct context *ctx, const struct token *token, void *buf, unsigned int size) { const struct arg *arg = pop_args(ctx); - char str2[len + 1]; + char str2[INET6_ADDRSTRLEN]; struct rte_ipv6_addr tmp; int ret; (void)token; + /* Length is longer than the max length an IPv6 address can have. */ + if (len >= INET6_ADDRSTRLEN) + return -1; /* Argument is expected. */ if (!arg) return -1; diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 88770b4dfc..9ff2b8817f 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1802,7 +1802,8 @@ port_flow_configure(portid_t port_id, { struct rte_port *port; struct rte_flow_error error; - const struct rte_flow_queue_attr *attr_list[nb_queue]; + const struct rte_flow_queue_attr **attr_list = + alloca(sizeof(struct rte_flow_queue_attr *) * nb_queue); int std_queue; if (port_id_is_invalid(port_id, ENABLED_WARN) || @@ -2616,10 +2617,10 @@ port_flow_template_table_create(portid_t port_id, uint32_t id, int ret; uint32_t i; struct rte_flow_error error; - struct rte_flow_pattern_template - *flow_pattern_templates[nb_pattern_templates]; - struct rte_flow_actions_template - *flow_actions_templates[nb_actions_templates]; + struct rte_flow_pattern_template **flow_pattern_templates = + alloca(sizeof(struct rte_flow_pattern_template *) * nb_pattern_templates); + struct rte_flow_actions_template **flow_actions_templates = + alloca(sizeof(struct rte_flow_actions_template *) * nb_actions_templates); if (port_id_is_invalid(port_id, ENABLED_WARN) || port_id == (portid_t)RTE_PORT_ALL) @@ -5529,7 +5530,7 @@ parse_port_list(const char *list, unsigned int *values, unsigned int maxsize) char *end = NULL; int min, max; int value, i; - unsigned int marked[maxsize]; + unsigned int *marked = alloca(sizeof(unsigned int) * maxsize); if (list == NULL || values == NULL) return 0; @@ -7270,7 +7271,8 @@ show_macs(portid_t port_id) if (eth_dev_info_get_print_err(port_id, &dev_info)) return; - struct rte_ether_addr addr[dev_info.max_mac_addrs]; + struct rte_ether_addr *addr = + alloca(sizeof(struct rte_ether_addr) * dev_info.max_mac_addrs); rc = rte_eth_macaddrs_get(port_id, addr, dev_info.max_mac_addrs); if (rc < 0) return; -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v4 10/19] test: remove use of VLAs for Windows built code 2024-11-05 3:15 ` [PATCH v4 00/19] remove use of VLAs for Windows Andre Muezerie ` (8 preceding siblings ...) 2024-11-05 3:15 ` [PATCH v4 09/19] app/testpmd: remove use of VLAs for Windows built Andre Muezerie @ 2024-11-05 3:15 ` Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 11/19] common/idpf: " Andre Muezerie ` (9 subsequent siblings) 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-05 3:15 UTC (permalink / raw) To: stephen Cc: aman.deep.singh, anatoly.burakov, andrew.rybchenko, bruce.richardson, dev, dmitry.kozliuk, dsosnowski, fanzhang.oss, fengchengwen, ferruh.yigit, gakhil, harry.van.haaren, hkalra, honnappa.nagarahalli, hujiayu.hu, jingjing.wu, kevin.laatz, konstantin.v.ananyev, matan, mb, orika, pallavi.kadam, reshma.pattan, roretzla, sameh.gobriel, suanmingm, thomas, vfialko, viacheslavo, vladimir.medvedkin, yipeng1.wang From: Tyler Retzlaff <roretzla@linux.microsoft.com> MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- app/test/test.c | 2 +- app/test/test_cmdline_string.c | 2 +- app/test/test_cryptodev.c | 34 +++++++++---------- app/test/test_cryptodev_blockcipher.c | 4 +-- app/test/test_cryptodev_crosscheck.c | 2 +- app/test/test_dmadev.c | 9 +++-- app/test/test_hash.c | 14 ++++---- app/test/test_mempool.c | 25 +++++++------- app/test/test_reorder.c | 48 +++++++++++++++------------ app/test/test_service_cores.c | 9 +++-- app/test/test_thash.c | 7 ++-- 11 files changed, 82 insertions(+), 74 deletions(-) diff --git a/app/test/test.c b/app/test/test.c index 680351f6a3..fd653cbbfd 100644 --- a/app/test/test.c +++ b/app/test/test.c @@ -105,7 +105,7 @@ int main(int argc, char **argv) { struct cmdline *cl; - char *tests[argc]; /* store an array of tests to run */ + char **tests = alloca(sizeof(char *) * argc); /* store an array of tests to run */ int test_count = 0; int i; char *extra_args; diff --git a/app/test/test_cmdline_string.c b/app/test/test_cmdline_string.c index 97516c9400..e1cf86020f 100644 --- a/app/test/test_cmdline_string.c +++ b/app/test/test_cmdline_string.c @@ -40,7 +40,7 @@ struct string_elt_str string_elt_strs[] = { #if (CMDLINE_TEST_BUFSIZE < STR_TOKEN_SIZE) \ || (CMDLINE_TEST_BUFSIZE < STR_MULTI_TOKEN_SIZE) #undef CMDLINE_TEST_BUFSIZE -#define CMDLINE_TEST_BUFSIZE RTE_MAX(STR_TOKEN_SIZE, STR_MULTI_TOKEN_SIZE) +#define CMDLINE_TEST_BUFSIZE RTE_MAX_T(STR_TOKEN_SIZE, STR_MULTI_TOKEN_SIZE, size_t) #endif struct string_nb_str { diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index 25eef342b0..888a3bfa21 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -2885,7 +2885,7 @@ create_wireless_algo_hash_session(uint8_t dev_id, enum rte_crypto_auth_operation op, enum rte_crypto_auth_algorithm algo) { - uint8_t hash_key[key_len]; + uint8_t *hash_key = alloca(key_len); struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -2921,7 +2921,7 @@ create_wireless_algo_cipher_session(uint8_t dev_id, const uint8_t *key, const uint8_t key_len, uint8_t iv_len) { - uint8_t cipher_key[key_len]; + uint8_t *cipher_key = alloca(key_len); struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -3073,7 +3073,7 @@ create_wireless_cipher_auth_session(uint8_t dev_id, const struct wireless_test_data *tdata) { const uint8_t key_len = tdata->key.len; - uint8_t cipher_auth_key[key_len]; + uint8_t *cipher_auth_key = alloca(key_len); struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -9077,7 +9077,7 @@ create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo, const uint16_t aad_len, const uint8_t auth_len, uint8_t iv_len) { - uint8_t aead_key[key_len]; + uint8_t *aead_key = alloca(key_len); struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -12991,7 +12991,7 @@ test_cryptodev_error_recover_helper(uint8_t dev_id, const void *test_data, bool struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; const struct blockcipher_test_data *tdata = test_data; - uint8_t cipher_key[tdata->cipher_key.len]; + uint8_t *cipher_key = alloca(tdata->cipher_key.len); struct rte_crypto_sym_op *sym_op = NULL; struct rte_crypto_op *op = NULL; char *dst; @@ -13345,7 +13345,7 @@ static int test_AES_GCM_auth_encryption_fail_aad_corrupt(void) { struct aead_test_data tdata; - uint8_t aad[gcm_test_case_7.aad.len]; + uint8_t *aad = alloca(gcm_test_case_7.aad.len); int res; RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n"); @@ -13734,7 +13734,7 @@ static int test_AES_GCM_auth_decryption_fail_aad_corrupt(void) { struct aead_test_data tdata; - uint8_t aad[gcm_test_case_7.aad.len]; + uint8_t *aad = alloca(gcm_test_case_7.aad.len); int res; memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data)); @@ -13986,7 +13986,7 @@ test_authenticated_encryption_sessionless( int retval; uint8_t *ciphertext, *auth_tag; uint16_t plaintext_pad_len; - uint8_t key[tdata->key.len + 1]; + uint8_t *key = alloca(tdata->key.len + 1); struct rte_cryptodev_info dev_info; rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); @@ -14088,7 +14088,7 @@ test_authenticated_decryption_sessionless( int retval; uint8_t *plaintext; - uint8_t key[tdata->key.len + 1]; + uint8_t *key = alloca(tdata->key.len + 1); struct rte_cryptodev_info dev_info; rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); @@ -15473,7 +15473,7 @@ static int create_gmac_session(uint8_t dev_id, const struct gmac_test_data *tdata, enum rte_crypto_auth_operation auth_op) { - uint8_t auth_key[tdata->key.len]; + uint8_t *auth_key = alloca(tdata->key.len); struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -16130,7 +16130,7 @@ create_auth_session(struct crypto_unittest_params *ut_params, enum rte_crypto_auth_operation auth_op) { struct crypto_testsuite_params *ts_params = &testsuite_params; - uint8_t auth_key[reference->auth_key.len + 1]; + uint8_t *auth_key = alloca(reference->auth_key.len + 1); memcpy(auth_key, reference->auth_key.data, reference->auth_key.len); @@ -16161,8 +16161,8 @@ create_auth_cipher_session(struct crypto_unittest_params *ut_params, enum rte_crypto_cipher_operation cipher_op) { struct crypto_testsuite_params *ts_params = &testsuite_params; - uint8_t cipher_key[reference->cipher_key.len + 1]; - uint8_t auth_key[reference->auth_key.len + 1]; + uint8_t *cipher_key = alloca(reference->cipher_key.len + 1); + uint8_t *auth_key = alloca(reference->auth_key.len + 1); memcpy(cipher_key, reference->cipher_key.data, reference->cipher_key.len); @@ -16662,8 +16662,8 @@ test_authenticated_encrypt_with_esn( uint8_t *authciphertext, *plaintext, *auth_tag; uint16_t plaintext_pad_len; - uint8_t cipher_key[reference->cipher_key.len + 1]; - uint8_t auth_key[reference->auth_key.len + 1]; + uint8_t *cipher_key = alloca(reference->cipher_key.len + 1); + uint8_t *auth_key = alloca(reference->auth_key.len + 1); struct rte_cryptodev_info dev_info; rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); @@ -16794,8 +16794,8 @@ test_authenticated_decrypt_with_esn( int retval; uint8_t *ciphertext; - uint8_t cipher_key[reference->cipher_key.len + 1]; - uint8_t auth_key[reference->auth_key.len + 1]; + uint8_t *cipher_key = alloca(reference->cipher_key.len + 1); + uint8_t *auth_key = alloca(reference->auth_key.len + 1); struct rte_cryptodev_info dev_info; rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); diff --git a/app/test/test_cryptodev_blockcipher.c b/app/test/test_cryptodev_blockcipher.c index 8e13cdfc7a..5a124bbb5e 100644 --- a/app/test/test_cryptodev_blockcipher.c +++ b/app/test/test_cryptodev_blockcipher.c @@ -85,8 +85,8 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t, int status = TEST_SUCCESS; const struct blockcipher_test_data *tdata = t->test_data; - uint8_t cipher_key[tdata->cipher_key.len]; - uint8_t auth_key[tdata->auth_key.len]; + uint8_t *cipher_key = alloca(tdata->cipher_key.len); + uint8_t *auth_key = alloca(tdata->auth_key.len); uint32_t buf_len = tdata->ciphertext.len; uint32_t digest_len = tdata->digest.len; char *buf_p = NULL; diff --git a/app/test/test_cryptodev_crosscheck.c b/app/test/test_cryptodev_crosscheck.c index c29b19cf6b..b9a53a430c 100644 --- a/app/test/test_cryptodev_crosscheck.c +++ b/app/test/test_cryptodev_crosscheck.c @@ -894,7 +894,7 @@ static int crosscheck_with_profile_run(const struct crosscheck_test_profile *profile) { struct crosscheck_testsuite_params *ts_params = &testsuite_params; - uint8_t input_text[profile->input_buf_len]; + uint8_t *input_text = alloca(profile->input_buf_len); uint16_t output_len, encrypted_len; uint8_t encrypted_text[MBUF_SIZE]; uint8_t output_text[MBUF_SIZE]; diff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c index 143e1bcd68..9cbb9a6552 100644 --- a/app/test/test_dmadev.c +++ b/app/test/test_dmadev.c @@ -417,9 +417,12 @@ test_enqueue_sg_copies(int16_t dev_id, uint16_t vchan) dst_len = len / n_dst; src_len = len / n_src; - struct rte_dma_sge sg_src[n_sge], sg_dst[n_sge]; - struct rte_mbuf *src[n_sge], *dst[n_sge]; - char *src_data[n_sge], *dst_data[n_sge]; + struct rte_dma_sge *sg_src = alloca(sizeof(struct rte_dma_sge) * n_sge); + struct rte_dma_sge *sg_dst = alloca(sizeof(struct rte_dma_sge) * n_sge); + struct rte_mbuf **src = alloca(sizeof(struct rte_mbuf *) * n_sge); + struct rte_mbuf **dst = alloca(sizeof(struct rte_mbuf *) * n_sge); + char **src_data = alloca(sizeof(char *) * n_sge); + char **dst_data = alloca(sizeof(char *) * n_sge); for (i = 0 ; i < len; i++) orig_src[i] = rte_rand() & 0xFF; diff --git a/app/test/test_hash.c b/app/test/test_hash.c index 65b9cad93c..16e63d2926 100644 --- a/app/test/test_hash.c +++ b/app/test/test_hash.c @@ -1947,6 +1947,8 @@ test_hash_rcu_qsbr_add(void) return 0; } +#define HASH_RCU_QSBR_MAX_TOTAL_ENTRIES 9 + /* * rte_hash_rcu_qsbr_add DQ mode functional test. * Reader and writer are in the same thread in this test. @@ -1966,7 +1968,7 @@ test_hash_rcu_qsbr_add(void) static int test_hash_rcu_qsbr_dq_mode(uint8_t ext_bkt) { - uint32_t total_entries = (ext_bkt == 0) ? 8 : 9; + const uint32_t total_entries = (ext_bkt == 0) ? 8 : HASH_RCU_QSBR_MAX_TOTAL_ENTRIES; uint8_t hash_extra_flag = RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF; @@ -1982,8 +1984,8 @@ test_hash_rcu_qsbr_dq_mode(uint8_t ext_bkt) .socket_id = 0, .extra_flag = hash_extra_flag, }; - int pos[total_entries]; - int expected_pos[total_entries]; + int pos[HASH_RCU_QSBR_MAX_TOTAL_ENTRIES]; + int expected_pos[HASH_RCU_QSBR_MAX_TOTAL_ENTRIES]; unsigned int i; size_t sz; int32_t status; @@ -2136,7 +2138,7 @@ test_hash_rcu_qsbr_reader(void *arg) static int test_hash_rcu_qsbr_sync_mode(uint8_t ext_bkt) { - uint32_t total_entries = (ext_bkt == 0) ? 8 : 9; + const uint32_t total_entries = (ext_bkt == 0) ? 8 : HASH_RCU_QSBR_MAX_TOTAL_ENTRIES; uint8_t hash_extra_flag = RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF; @@ -2152,8 +2154,8 @@ test_hash_rcu_qsbr_sync_mode(uint8_t ext_bkt) .socket_id = 0, .extra_flag = hash_extra_flag, }; - int pos[total_entries]; - int expected_pos[total_entries]; + int pos[HASH_RCU_QSBR_MAX_TOTAL_ENTRIES]; + int expected_pos[HASH_RCU_QSBR_MAX_TOTAL_ENTRIES]; unsigned int i; size_t sz; int32_t status; diff --git a/app/test/test_mempool.c b/app/test/test_mempool.c index 3f7ba5872d..61385e096e 100644 --- a/app/test/test_mempool.c +++ b/app/test/test_mempool.c @@ -515,19 +515,20 @@ test_mempool_events(int (*populate)(struct rte_mempool *mp)) #undef RTE_TEST_TRACE_FAILURE #define RTE_TEST_TRACE_FAILURE(...) do { goto fail; } while (0) - static const size_t callback_num = 3; - static const size_t mempool_num = 2; +#define CALLBACK_NUM 3u +#define MEMPOOL_NUM 2u + static const unsigned int mempool_elt_size = 64; static const unsigned int mempool_size = 64; - struct test_mempool_events_data data[callback_num]; - struct rte_mempool *mp[mempool_num], *freed; + struct test_mempool_events_data data[CALLBACK_NUM]; + struct rte_mempool *mp[MEMPOOL_NUM], *freed; char name[RTE_MEMPOOL_NAMESIZE]; size_t i, j; int ret; memset(mp, 0, sizeof(mp)); - for (i = 0; i < callback_num; i++) { + for (i = 0; i < CALLBACK_NUM; i++) { ret = rte_mempool_event_callback_register (test_mempool_events_cb, &data[i]); RTE_TEST_ASSERT_EQUAL(ret, 0, "Failed to register the callback %zu: %s", @@ -548,7 +549,7 @@ test_mempool_events(int (*populate)(struct rte_mempool *mp)) SOCKET_ID_ANY, 0); RTE_TEST_ASSERT_NOT_NULL(mp[0], "Cannot create mempool %s: %s", name, rte_strerror(rte_errno)); - for (j = 0; j < callback_num; j++) + for (j = 0; j < CALLBACK_NUM; j++) RTE_TEST_ASSERT_EQUAL(data[j].invoked, false, "Callback %zu invoked on %s mempool creation", j, name); @@ -557,7 +558,7 @@ test_mempool_events(int (*populate)(struct rte_mempool *mp)) ret = populate(mp[0]); RTE_TEST_ASSERT_EQUAL(ret, (int)mp[0]->size, "Failed to populate mempool %s: %s", name, rte_strerror(-ret)); - for (j = 0; j < callback_num; j++) { + for (j = 0; j < CALLBACK_NUM; j++) { RTE_TEST_ASSERT_EQUAL(data[j].invoked, true, "Callback %zu not invoked on mempool %s population", j, name); @@ -589,7 +590,7 @@ test_mempool_events(int (*populate)(struct rte_mempool *mp)) "Unregistered callback 0 invoked on %s mempool populaton", name); - for (i = 0; i < mempool_num; i++) { + for (i = 0; i < MEMPOOL_NUM; i++) { memset(&data, 0, sizeof(data)); sprintf(name, "empty%zu", i); rte_mempool_free(mp[i]); @@ -599,7 +600,7 @@ test_mempool_events(int (*populate)(struct rte_mempool *mp)) */ freed = mp[i]; mp[i] = NULL; - for (j = 1; j < callback_num; j++) { + for (j = 1; j < CALLBACK_NUM; j++) { RTE_TEST_ASSERT_EQUAL(data[j].invoked, true, "Callback %zu not invoked on mempool %s destruction", j, name); @@ -615,7 +616,7 @@ test_mempool_events(int (*populate)(struct rte_mempool *mp)) name); } - for (j = 1; j < callback_num; j++) { + for (j = 1; j < CALLBACK_NUM; j++) { ret = rte_mempool_event_callback_unregister (test_mempool_events_cb, &data[j]); RTE_TEST_ASSERT_EQUAL(ret, 0, "Failed to unregister the callback %zu: %s", @@ -624,10 +625,10 @@ test_mempool_events(int (*populate)(struct rte_mempool *mp)) return TEST_SUCCESS; fail: - for (j = 0; j < callback_num; j++) + for (j = 0; j < CALLBACK_NUM; j++) rte_mempool_event_callback_unregister (test_mempool_events_cb, &data[j]); - for (i = 0; i < mempool_num; i++) + for (i = 0; i < MEMPOOL_NUM; i++) rte_mempool_free(mp[i]); return TEST_FAILED; diff --git a/app/test/test_reorder.c b/app/test/test_reorder.c index 501780cb26..aaa2c57086 100644 --- a/app/test/test_reorder.c +++ b/app/test/test_reorder.c @@ -130,11 +130,12 @@ test_reorder_free(void) static int test_reorder_insert(void) { +#define INSERT_NUM_BUFS 7u + struct rte_reorder_buffer *b = NULL; struct rte_mempool *p = test_params->p; const unsigned int size = 4; - const unsigned int num_bufs = 7; - struct rte_mbuf *bufs[num_bufs]; + struct rte_mbuf *bufs[INSERT_NUM_BUFS]; int ret = 0; unsigned i; @@ -146,7 +147,7 @@ test_reorder_insert(void) b = rte_reorder_create("test_insert", rte_socket_id(), size); TEST_ASSERT_NOT_NULL(b, "Failed to create reorder buffer"); - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < INSERT_NUM_BUFS; i++) { bufs[i] = rte_pktmbuf_alloc(p); TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n"); *rte_reorder_seqn(bufs[i]) = i; @@ -207,26 +208,27 @@ test_reorder_insert(void) ret = 0; exit: rte_reorder_free(b); - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < INSERT_NUM_BUFS; i++) rte_pktmbuf_free(bufs[i]); - } + return ret; } static int test_reorder_drain(void) { +#define DRAIN_NUM_BUFS 8u + struct rte_reorder_buffer *b = NULL; struct rte_mempool *p = test_params->p; const unsigned int size = 4; - const unsigned int num_bufs = 8; - struct rte_mbuf *bufs[num_bufs]; - struct rte_mbuf *robufs[num_bufs]; + struct rte_mbuf *bufs[DRAIN_NUM_BUFS]; + struct rte_mbuf *robufs[DRAIN_NUM_BUFS]; int ret = 0; unsigned i, cnt; /* initialize all robufs to NULL */ - for (i = 0; i < num_bufs; i++) + for (i = 0; i < DRAIN_NUM_BUFS; i++) robufs[i] = NULL; /* This would create a reorder buffer instance consisting of: @@ -246,7 +248,7 @@ test_reorder_drain(void) goto exit; } - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < DRAIN_NUM_BUFS; i++) { bufs[i] = rte_pktmbuf_alloc(p); TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n"); *rte_reorder_seqn(bufs[i]) = i; @@ -320,7 +322,7 @@ test_reorder_drain(void) ret = 0; exit: rte_reorder_free(b); - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < DRAIN_NUM_BUFS; i++) { rte_pktmbuf_free(bufs[i]); rte_pktmbuf_free(robufs[i]); } @@ -337,15 +339,16 @@ buffer_to_reorder_move(struct rte_mbuf **mbuf, struct rte_reorder_buffer *b) static int test_reorder_drain_up_to_seqn(void) { +#define DRAIN_TO_NUM_BUFS 10u + struct rte_mempool *p = test_params->p; struct rte_reorder_buffer *b = NULL; - const unsigned int num_bufs = 10; const unsigned int size = 4; unsigned int i, cnt; int ret = 0; - struct rte_mbuf *bufs[num_bufs]; - struct rte_mbuf *robufs[num_bufs]; + struct rte_mbuf *bufs[DRAIN_TO_NUM_BUFS]; + struct rte_mbuf *robufs[DRAIN_TO_NUM_BUFS]; /* initialize all robufs to NULL */ memset(robufs, 0, sizeof(robufs)); @@ -358,7 +361,7 @@ test_reorder_drain_up_to_seqn(void) b = rte_reorder_create("test_drain_up_to_seqn", rte_socket_id(), size); TEST_ASSERT_NOT_NULL(b, "Failed to create reorder buffer"); - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < DRAIN_TO_NUM_BUFS; i++) { bufs[i] = rte_pktmbuf_alloc(p); TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n"); *rte_reorder_seqn(bufs[i]) = i; @@ -372,7 +375,7 @@ test_reorder_drain_up_to_seqn(void) buffer_to_reorder_move(&bufs[2], b); buffer_to_reorder_move(&bufs[3], b); /* Draining 1, 2 */ - cnt = rte_reorder_drain_up_to_seqn(b, robufs, num_bufs, 3); + cnt = rte_reorder_drain_up_to_seqn(b, robufs, DRAIN_TO_NUM_BUFS, 3); if (cnt != 2) { printf("%s:%d:%d: number of expected packets not drained\n", __func__, __LINE__, cnt); @@ -396,7 +399,7 @@ test_reorder_drain_up_to_seqn(void) buffer_to_reorder_move(&bufs[8], b); /* Drain 3 and 5 */ - cnt = rte_reorder_drain_up_to_seqn(b, robufs, num_bufs, 6); + cnt = rte_reorder_drain_up_to_seqn(b, robufs, DRAIN_TO_NUM_BUFS, 6); if (cnt != 2) { printf("%s:%d:%d: number of expected packets not drained\n", __func__, __LINE__, cnt); @@ -410,7 +413,7 @@ test_reorder_drain_up_to_seqn(void) ret = 0; exit: rte_reorder_free(b); - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < DRAIN_TO_NUM_BUFS; i++) { rte_pktmbuf_free(bufs[i]); rte_pktmbuf_free(robufs[i]); } @@ -420,14 +423,15 @@ test_reorder_drain_up_to_seqn(void) static int test_reorder_set_seqn(void) { +#define SET_SEQN_NUM_BUFS 7u + struct rte_mempool *p = test_params->p; struct rte_reorder_buffer *b = NULL; - const unsigned int num_bufs = 7; const unsigned int size = 4; unsigned int i; int ret = 0; - struct rte_mbuf *bufs[num_bufs]; + struct rte_mbuf *bufs[SET_SEQN_NUM_BUFS]; /* This would create a reorder buffer instance consisting of: * reorder_seq = 0 @@ -437,7 +441,7 @@ test_reorder_set_seqn(void) b = rte_reorder_create("test_min_seqn_set", rte_socket_id(), size); TEST_ASSERT_NOT_NULL(b, "Failed to create reorder buffer"); - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < SET_SEQN_NUM_BUFS; i++) { bufs[i] = rte_pktmbuf_alloc(p); if (bufs[i] == NULL) { printf("Packet allocation failed\n"); @@ -479,7 +483,7 @@ test_reorder_set_seqn(void) ret = 0; exit: rte_reorder_free(b); - for (i = 0; i < num_bufs; i++) + for (i = 0; i < SET_SEQN_NUM_BUFS; i++) rte_pktmbuf_free(bufs[i]); return ret; diff --git a/app/test/test_service_cores.c b/app/test/test_service_cores.c index 46ed9a1868..d95a71f80b 100644 --- a/app/test/test_service_cores.c +++ b/app/test/test_service_cores.c @@ -603,9 +603,8 @@ service_lcore_add_del(void) "Service core count not equal to one"); /* retrieve core list, checking lcore ids */ - const uint32_t size = 4; - uint32_t service_core_ids[size]; - int32_t n = rte_service_lcore_list(service_core_ids, size); + uint32_t service_core_ids[4]; + int32_t n = rte_service_lcore_list(service_core_ids, RTE_DIM(service_core_ids)); TEST_ASSERT_EQUAL(1, n, "Service core list return should equal 1"); TEST_ASSERT_EQUAL(slcore_id, service_core_ids[0], "Service core list lcore must equal slcore_id"); @@ -631,7 +630,7 @@ service_lcore_add_del(void) cores_at_this_point); /* check longer service core list */ - n = rte_service_lcore_list(service_core_ids, size); + n = rte_service_lcore_list(service_core_ids, RTE_DIM(service_core_ids)); TEST_ASSERT_EQUAL(3, n, "Service core list return should equal 3"); TEST_ASSERT_EQUAL(slcore_id, service_core_ids[0], "Service core list[0] lcore must equal 1"); @@ -649,7 +648,7 @@ service_lcore_add_del(void) "Service core add did not return zero"); TEST_ASSERT_EQUAL(1, rte_service_lcore_count(), "Service core count not equal to one"); - n = rte_service_lcore_list(service_core_ids, size); + n = rte_service_lcore_list(service_core_ids, RTE_DIM(service_core_ids)); TEST_ASSERT_EQUAL(1, n, "Service core list return should equal one"); TEST_ASSERT_EQUAL(slcore_id, service_core_ids[0], "Service core list[0] lcore must equal %d", diff --git a/app/test/test_thash.c b/app/test/test_thash.c index 0ad6943cf8..d2f0c252ca 100644 --- a/app/test/test_thash.c +++ b/app/test/test_thash.c @@ -564,9 +564,8 @@ test_predictable_rss_min_seq(void) { struct rte_thash_ctx *ctx; struct rte_thash_subtuple_helper *h; - const int key_len = 40; int reta_sz = 6; - uint8_t initial_key[key_len]; + uint8_t initial_key[40]; const uint8_t *new_key; int ret; union rte_thash_tuple tuple; @@ -574,9 +573,9 @@ test_predictable_rss_min_seq(void) unsigned int desired_value = 27 & HASH_MSK(reta_sz); uint16_t port_value = 22; - memset(initial_key, 0, key_len); + memset(initial_key, 0, RTE_DIM(initial_key)); - ctx = rte_thash_init_ctx("test", key_len, reta_sz, initial_key, + ctx = rte_thash_init_ctx("test", RTE_DIM(initial_key), reta_sz, initial_key, RTE_THASH_MINIMAL_SEQ); RTE_TEST_ASSERT(ctx != NULL, "can not create thash ctx\n"); -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v4 11/19] common/idpf: remove use of VLAs for Windows built code 2024-11-05 3:15 ` [PATCH v4 00/19] remove use of VLAs for Windows Andre Muezerie ` (9 preceding siblings ...) 2024-11-05 3:15 ` [PATCH v4 10/19] test: remove use of VLAs for Windows built code Andre Muezerie @ 2024-11-05 3:15 ` Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 12/19] net/i40e: " Andre Muezerie ` (8 subsequent siblings) 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-05 3:15 UTC (permalink / raw) To: stephen Cc: aman.deep.singh, anatoly.burakov, andrew.rybchenko, bruce.richardson, dev, dmitry.kozliuk, dsosnowski, fanzhang.oss, fengchengwen, ferruh.yigit, gakhil, harry.van.haaren, hkalra, honnappa.nagarahalli, hujiayu.hu, jingjing.wu, kevin.laatz, konstantin.v.ananyev, matan, mb, orika, pallavi.kadam, reshma.pattan, roretzla, sameh.gobriel, suanmingm, thomas, vfialko, viacheslavo, vladimir.medvedkin, yipeng1.wang From: Tyler Retzlaff <roretzla@linux.microsoft.com> MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- drivers/common/idpf/idpf_common_rxtx.c | 2 +- drivers/common/idpf/idpf_common_rxtx_avx512.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/common/idpf/idpf_common_rxtx.c b/drivers/common/idpf/idpf_common_rxtx.c index a04e54ce26..e04ab40fa2 100644 --- a/drivers/common/idpf/idpf_common_rxtx.c +++ b/drivers/common/idpf/idpf_common_rxtx.c @@ -569,7 +569,7 @@ idpf_split_rx_bufq_refill(struct idpf_rx_queue *rx_bufq) uint16_t nb_refill = rx_bufq->rx_free_thresh; uint16_t nb_desc = rx_bufq->nb_rx_desc; uint16_t next_avail = rx_bufq->rx_tail; - struct rte_mbuf *nmb[rx_bufq->rx_free_thresh]; + struct rte_mbuf **nmb = alloca(sizeof(struct rte_mbuf *) * rx_bufq->rx_free_thresh); uint64_t dma_addr; uint16_t delta; int i; diff --git a/drivers/common/idpf/idpf_common_rxtx_avx512.c b/drivers/common/idpf/idpf_common_rxtx_avx512.c index b8450b03ae..63e10c542f 100644 --- a/drivers/common/idpf/idpf_common_rxtx_avx512.c +++ b/drivers/common/idpf/idpf_common_rxtx_avx512.c @@ -1002,7 +1002,8 @@ idpf_tx_singleq_free_bufs_avx512(struct idpf_tx_queue *txq) uint32_t n; uint32_t i; int nb_free = 0; - struct rte_mbuf *m, *free[txq->rs_thresh]; + struct rte_mbuf *m; + struct rte_mbuf **free = alloca(sizeof(struct rte_mbuf *) * txq->rs_thresh); /* check DD bits on threshold descriptor */ if ((txq->tx_ring[txq->next_dd].qw1 & @@ -1326,7 +1327,8 @@ idpf_tx_splitq_free_bufs_avx512(struct idpf_tx_queue *txq) uint32_t n; uint32_t i; int nb_free = 0; - struct rte_mbuf *m, *free[txq->rs_thresh]; + struct rte_mbuf *m; + struct rte_mbuf **free = alloca(sizeof(struct rte_mbuf *) * txq->rs_thresh); n = txq->rs_thresh; -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v4 12/19] net/i40e: remove use of VLAs for Windows built code 2024-11-05 3:15 ` [PATCH v4 00/19] remove use of VLAs for Windows Andre Muezerie ` (10 preceding siblings ...) 2024-11-05 3:15 ` [PATCH v4 11/19] common/idpf: " Andre Muezerie @ 2024-11-05 3:15 ` Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 13/19] net/ice: " Andre Muezerie ` (7 subsequent siblings) 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-05 3:15 UTC (permalink / raw) To: stephen Cc: aman.deep.singh, anatoly.burakov, andrew.rybchenko, bruce.richardson, dev, dmitry.kozliuk, dsosnowski, fanzhang.oss, fengchengwen, ferruh.yigit, gakhil, harry.van.haaren, hkalra, honnappa.nagarahalli, hujiayu.hu, jingjing.wu, kevin.laatz, konstantin.v.ananyev, matan, mb, orika, pallavi.kadam, reshma.pattan, roretzla, sameh.gobriel, suanmingm, thomas, vfialko, viacheslavo, vladimir.medvedkin, yipeng1.wang From: Tyler Retzlaff <roretzla@linux.microsoft.com> MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- drivers/net/i40e/i40e_testpmd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/i40e/i40e_testpmd.c b/drivers/net/i40e/i40e_testpmd.c index b6ef5d6e42..21f596297b 100644 --- a/drivers/net/i40e/i40e_testpmd.c +++ b/drivers/net/i40e/i40e_testpmd.c @@ -2168,8 +2168,7 @@ cmd_ptype_mapping_get_parsed(void *parsed_result, { struct cmd_ptype_mapping_get_result *res = parsed_result; int ret = -ENOTSUP; - int max_ptype_num = 256; - struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num]; + struct rte_pmd_i40e_ptype_mapping mapping[256]; uint16_t count; int i; @@ -2178,7 +2177,7 @@ cmd_ptype_mapping_get_parsed(void *parsed_result, ret = rte_pmd_i40e_ptype_mapping_get(res->port_id, mapping, - max_ptype_num, + RTE_DIM(mapping), &count, res->valid_only); switch (ret) { -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v4 13/19] net/ice: remove use of VLAs for Windows built code 2024-11-05 3:15 ` [PATCH v4 00/19] remove use of VLAs for Windows Andre Muezerie ` (11 preceding siblings ...) 2024-11-05 3:15 ` [PATCH v4 12/19] net/i40e: " Andre Muezerie @ 2024-11-05 3:15 ` Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 14/19] net/ixgbe: " Andre Muezerie ` (6 subsequent siblings) 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-05 3:15 UTC (permalink / raw) To: stephen Cc: aman.deep.singh, anatoly.burakov, andrew.rybchenko, bruce.richardson, dev, dmitry.kozliuk, dsosnowski, fanzhang.oss, fengchengwen, ferruh.yigit, gakhil, harry.van.haaren, hkalra, honnappa.nagarahalli, hujiayu.hu, jingjing.wu, kevin.laatz, konstantin.v.ananyev, matan, mb, orika, pallavi.kadam, reshma.pattan, roretzla, sameh.gobriel, suanmingm, thomas, vfialko, viacheslavo, vladimir.medvedkin, yipeng1.wang From: Tyler Retzlaff <roretzla@linux.microsoft.com> MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- drivers/net/ice/ice_rxtx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c index 024d97cb46..b4013483b0 100644 --- a/drivers/net/ice/ice_rxtx.c +++ b/drivers/net/ice/ice_rxtx.c @@ -1873,7 +1873,7 @@ ice_rx_alloc_bufs(struct ice_rx_queue *rxq) uint64_t dma_addr; int diag, diag_pay; uint64_t pay_addr; - struct rte_mbuf *mbufs_pay[rxq->rx_free_thresh]; + struct rte_mbuf **mbufs_pay = alloca(sizeof(struct rte_mbuf *) * rxq->rx_free_thresh); /* Allocate buffers in bulk */ alloc_idx = (uint16_t)(rxq->rx_free_trigger - -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v4 14/19] net/ixgbe: remove use of VLAs for Windows built code 2024-11-05 3:15 ` [PATCH v4 00/19] remove use of VLAs for Windows Andre Muezerie ` (12 preceding siblings ...) 2024-11-05 3:15 ` [PATCH v4 13/19] net/ice: " Andre Muezerie @ 2024-11-05 3:15 ` Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 15/19] common/mlx5: " Andre Muezerie ` (5 subsequent siblings) 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-05 3:15 UTC (permalink / raw) To: stephen Cc: aman.deep.singh, anatoly.burakov, andrew.rybchenko, bruce.richardson, dev, dmitry.kozliuk, dsosnowski, fanzhang.oss, fengchengwen, ferruh.yigit, gakhil, harry.van.haaren, hkalra, honnappa.nagarahalli, hujiayu.hu, jingjing.wu, kevin.laatz, konstantin.v.ananyev, matan, mb, orika, pallavi.kadam, reshma.pattan, roretzla, sameh.gobriel, suanmingm, thomas, vfialko, viacheslavo, vladimir.medvedkin, yipeng1.wang From: Tyler Retzlaff <roretzla@linux.microsoft.com> MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- drivers/net/ixgbe/ixgbe_ethdev.c | 5 +++-- drivers/net/ixgbe/ixgbe_rxtx_vec_common.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 7da2ccf6a8..389ff36a8b 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -3556,7 +3556,8 @@ static int ixgbe_dev_xstats_get_names_by_id( uint16_t i; uint16_t size = ixgbe_xstats_calc_num(); - struct rte_eth_xstat_name xstats_names_copy[size]; + struct rte_eth_xstat_name *xstats_names_copy = + alloca(sizeof(struct rte_eth_xstat_name) * size); ixgbe_dev_xstats_get_names_by_id(dev, NULL, xstats_names_copy, size); @@ -3739,7 +3740,7 @@ ixgbe_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, uint16_t i; uint16_t size = ixgbe_xstats_calc_num(); - uint64_t values_copy[size]; + uint64_t *values_copy = alloca(sizeof(uint64_t) * size); ixgbe_dev_xstats_get_by_id(dev, NULL, values_copy, size); diff --git a/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h b/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h index a4d9ec9b08..78b63b919e 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h +++ b/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h @@ -14,7 +14,7 @@ static inline uint16_t reassemble_packets(struct ixgbe_rx_queue *rxq, struct rte_mbuf **rx_bufs, uint16_t nb_bufs, uint8_t *split_flags) { - struct rte_mbuf *pkts[nb_bufs]; /*finished pkts*/ + struct rte_mbuf **pkts = alloca(sizeof(struct rte_mbuf *) * nb_bufs); /*finished pkts*/ struct rte_mbuf *start = rxq->pkt_first_seg; struct rte_mbuf *end = rxq->pkt_last_seg; unsigned int pkt_idx, buf_idx; -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v4 15/19] common/mlx5: remove use of VLAs for Windows built code 2024-11-05 3:15 ` [PATCH v4 00/19] remove use of VLAs for Windows Andre Muezerie ` (13 preceding siblings ...) 2024-11-05 3:15 ` [PATCH v4 14/19] net/ixgbe: " Andre Muezerie @ 2024-11-05 3:15 ` Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 16/19] net/mlx5: " Andre Muezerie ` (4 subsequent siblings) 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-05 3:15 UTC (permalink / raw) To: stephen Cc: aman.deep.singh, anatoly.burakov, andrew.rybchenko, bruce.richardson, dev, dmitry.kozliuk, dsosnowski, fanzhang.oss, fengchengwen, ferruh.yigit, gakhil, harry.van.haaren, hkalra, honnappa.nagarahalli, hujiayu.hu, jingjing.wu, kevin.laatz, konstantin.v.ananyev, matan, mb, orika, pallavi.kadam, reshma.pattan, roretzla, sameh.gobriel, suanmingm, thomas, vfialko, viacheslavo, vladimir.medvedkin, yipeng1.wang From: Tyler Retzlaff <roretzla@linux.microsoft.com> MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- drivers/common/mlx5/mlx5_common.h | 4 ++-- drivers/common/mlx5/mlx5_devx_cmds.c | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h index 1abd1e8239..f29f06a86e 100644 --- a/drivers/common/mlx5/mlx5_common.h +++ b/drivers/common/mlx5/mlx5_common.h @@ -125,10 +125,10 @@ mlx5_fp_debug_enabled(void) /* Allocate a buffer on the stack and fill it with a printf format string. */ #define MKSTR(name, ...) \ int mkstr_size_##name = snprintf(NULL, 0, "" __VA_ARGS__); \ - char name[mkstr_size_##name + 1]; \ + char *name = alloca(mkstr_size_##name + 1); \ \ memset(name, 0, mkstr_size_##name + 1); \ - snprintf(name, sizeof(name), "" __VA_ARGS__) + snprintf(name, mkstr_size_##name + 1, "" __VA_ARGS__) enum { PCI_VENDOR_ID_MELLANOX = 0x15b3, diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c index 9710dcedd3..fbe528a9ea 100644 --- a/drivers/common/mlx5/mlx5_devx_cmds.c +++ b/drivers/common/mlx5/mlx5_devx_cmds.c @@ -284,10 +284,9 @@ mlx5_devx_cmd_flow_counter_query(struct mlx5_devx_obj *dcs, void *cmd_comp, uint64_t async_id) { - int out_len = MLX5_ST_SZ_BYTES(query_flow_counter_out) + - MLX5_ST_SZ_BYTES(traffic_counter); - uint32_t out[out_len]; + uint32_t out[MLX5_ST_SZ_BYTES(query_flow_counter_out) + MLX5_ST_SZ_BYTES(traffic_counter)]; uint32_t in[MLX5_ST_SZ_DW(query_flow_counter_in)] = {0}; + const int out_len = RTE_DIM(out); void *stats; int rc; @@ -346,7 +345,7 @@ mlx5_devx_cmd_mkey_create(void *ctx, int klm_num = attr->klm_num; int in_size_dw = MLX5_ST_SZ_DW(create_mkey_in) + (klm_num ? RTE_ALIGN(klm_num, 4) : 0) * MLX5_ST_SZ_DW(klm); - uint32_t in[in_size_dw]; + uint32_t *in = alloca(sizeof(uint32_t) * in_size_dw); uint32_t out[MLX5_ST_SZ_DW(create_mkey_out)] = {0}; void *mkc; struct mlx5_devx_obj *mkey = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*mkey), -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v4 16/19] net/mlx5: remove use of VLAs for Windows built code 2024-11-05 3:15 ` [PATCH v4 00/19] remove use of VLAs for Windows Andre Muezerie ` (14 preceding siblings ...) 2024-11-05 3:15 ` [PATCH v4 15/19] common/mlx5: " Andre Muezerie @ 2024-11-05 3:15 ` Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 17/19] build: enable vla warnings on " Andre Muezerie ` (3 subsequent siblings) 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-05 3:15 UTC (permalink / raw) To: stephen Cc: aman.deep.singh, anatoly.burakov, andrew.rybchenko, bruce.richardson, dev, dmitry.kozliuk, dsosnowski, fanzhang.oss, fengchengwen, ferruh.yigit, gakhil, harry.van.haaren, hkalra, honnappa.nagarahalli, hujiayu.hu, jingjing.wu, kevin.laatz, konstantin.v.ananyev, matan, mb, orika, pallavi.kadam, reshma.pattan, roretzla, sameh.gobriel, suanmingm, thomas, vfialko, viacheslavo, vladimir.medvedkin, yipeng1.wang From: Tyler Retzlaff <roretzla@linux.microsoft.com> MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- drivers/net/mlx5/mlx5.c | 5 ++--- drivers/net/mlx5/mlx5_flow.c | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 52b90e6ff3..ab6fe6d753 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1598,14 +1598,13 @@ void mlx5_rt_timestamp_config(struct mlx5_dev_ctx_shared *sh, struct mlx5_hca_attr *hca_attr) { - uint32_t dw_cnt = MLX5_ST_SZ_DW(register_mtutc); - uint32_t reg[dw_cnt]; + uint32_t reg[MLX5_ST_SZ_DW(register_mtutc)]; int ret = ENOTSUP; if (hca_attr->access_register_user) ret = mlx5_devx_cmd_register_read(sh->cdev->ctx, MLX5_REGISTER_ID_MTUTC, 0, - reg, dw_cnt); + reg, RTE_DIM(reg)); if (!ret) { uint32_t ts_mode; diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 7f8640b488..eca08a2111 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -1479,8 +1479,8 @@ mlx5_flow_item_acceptable(const struct rte_eth_dev *dev, "mask/last without a spec is not" " supported"); if (item->spec && item->last && !range_accepted) { - uint8_t spec[size]; - uint8_t last[size]; + uint8_t *spec = alloca(size); + uint8_t *last = alloca(size); unsigned int i; int ret; @@ -8474,7 +8474,7 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, .type = RTE_FLOW_ITEM_TYPE_END, }, }; - uint16_t queue[priv->reta_idx_n]; + uint16_t *queue = alloca(sizeof(uint16_t) * priv->reta_idx_n); struct rte_flow_action_rss action_rss = { .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .level = 0, -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v4 17/19] build: enable vla warnings on Windows built code 2024-11-05 3:15 ` [PATCH v4 00/19] remove use of VLAs for Windows Andre Muezerie ` (15 preceding siblings ...) 2024-11-05 3:15 ` [PATCH v4 16/19] net/mlx5: " Andre Muezerie @ 2024-11-05 3:15 ` Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 18/19] test: remove use of VLAs for Windows built code in bitset tests Andre Muezerie ` (2 subsequent siblings) 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-05 3:15 UTC (permalink / raw) To: stephen Cc: aman.deep.singh, anatoly.burakov, andrew.rybchenko, bruce.richardson, dev, dmitry.kozliuk, dsosnowski, fanzhang.oss, fengchengwen, ferruh.yigit, gakhil, harry.van.haaren, hkalra, honnappa.nagarahalli, hujiayu.hu, jingjing.wu, kevin.laatz, konstantin.v.ananyev, matan, mb, orika, pallavi.kadam, reshma.pattan, roretzla, sameh.gobriel, suanmingm, thomas, vfialko, viacheslavo, vladimir.medvedkin, yipeng1.wang From: Tyler Retzlaff <roretzla@linux.microsoft.com> MSVC does not support optional C11 VLAs. When building for Windows enable -Wvla so that mingw and clang also fail if a VLA is used. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- config/meson.build | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/meson.build b/config/meson.build index 5095d2fbcb..9a3ce5eaa9 100644 --- a/config/meson.build +++ b/config/meson.build @@ -339,6 +339,10 @@ if cc.get_id() == 'intel' warning_flags += '-diag-disable=@0@'.format(i) endforeach endif +# no VLAs in code built on Windows +if is_windows + warning_flags += '-Wvla' +endif foreach arg: warning_flags if cc.has_argument(arg) add_project_arguments(arg, language: 'c') -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v4 18/19] test: remove use of VLAs for Windows built code in bitset tests 2024-11-05 3:15 ` [PATCH v4 00/19] remove use of VLAs for Windows Andre Muezerie ` (16 preceding siblings ...) 2024-11-05 3:15 ` [PATCH v4 17/19] build: enable vla warnings on " Andre Muezerie @ 2024-11-05 3:15 ` Andre Muezerie 2024-11-05 8:32 ` David Marchand 2024-11-05 3:15 ` [PATCH v4 19/19] app/testpmd: remove use of VLAs for Windows built code in shared_rxq_fwd Andre Muezerie 2024-11-05 9:37 ` [PATCH v4 00/19] remove use of VLAs for Windows Konstantin Ananyev 19 siblings, 1 reply; 127+ messages in thread From: Andre Muezerie @ 2024-11-05 3:15 UTC (permalink / raw) To: stephen Cc: aman.deep.singh, anatoly.burakov, andrew.rybchenko, bruce.richardson, dev, dmitry.kozliuk, dsosnowski, fanzhang.oss, fengchengwen, ferruh.yigit, gakhil, harry.van.haaren, hkalra, honnappa.nagarahalli, hujiayu.hu, jingjing.wu, kevin.laatz, konstantin.v.ananyev, matan, mb, orika, pallavi.kadam, reshma.pattan, roretzla, sameh.gobriel, suanmingm, thomas, vfialko, viacheslavo, vladimir.medvedkin, yipeng1.wang, Andre Muezerie MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> --- app/test/test_bitset.c | 55 +++++++++++++++++++-------------- app/test/test_reassembly_perf.c | 4 +-- 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/app/test/test_bitset.c b/app/test/test_bitset.c index 50b8bf0da4..f58c491d8f 100644 --- a/app/test/test_bitset.c +++ b/app/test/test_bitset.c @@ -99,11 +99,13 @@ typedef void clear_fun(uint64_t *bitset, size_t bit_num); typedef void assign_fun(uint64_t *bitset, size_t bit_num, bool value); typedef void flip_fun(uint64_t *bitset, size_t bit_num); +#define RAND_SET_MAX_SIZE (1000) + static int test_set_clear_size(test_fun test_fun, set_fun set_fun, clear_fun clear_fun, size_t size) { size_t i; - bool reference[size]; + bool reference[RAND_SET_MAX_SIZE]; uint64_t *bitset; rand_bool_ary(reference, size); @@ -132,7 +134,6 @@ test_set_clear_size(test_fun test_fun, set_fun set_fun, clear_fun clear_fun, siz } #define RAND_ITERATIONS (10000) -#define RAND_SET_MAX_SIZE (1000) static int test_set_clear_fun(test_fun test_fun, set_fun set_fun, clear_fun clear_fun) @@ -168,7 +169,7 @@ test_flip_size(test_fun test_fun, assign_fun assign_fun, flip_fun flip_fun, size rand_bitset(bitset, size); for (i = 0; i < size; i++) { - RTE_BITSET_DECLARE(reference, size); + RTE_BITSET_DECLARE(reference, RAND_SET_MAX_SIZE); rte_bitset_copy(reference, bitset, size); @@ -288,7 +289,7 @@ static int test_find_size(size_t size, bool set) { uint64_t *bitset; - bool reference[size]; + bool reference[RAND_SET_MAX_SIZE]; size_t i; bitset = alloc_bitset(size); @@ -388,8 +389,8 @@ record_match(ssize_t match_idx, size_t size, int *calls) static int test_foreach_size(ssize_t size, bool may_wrap, bool set) { - bool reference[size]; - int calls[size]; + bool reference[RAND_SET_MAX_SIZE]; + int calls[RAND_SET_MAX_SIZE]; uint64_t *bitset; ssize_t i; ssize_t start_bit; @@ -633,17 +634,19 @@ test_define(void) typedef void bitset_op(uint64_t *dst, const uint64_t *a, const uint64_t *b, size_t bit_num); typedef bool bool_op(bool a, bool b); +#define LOGIC_MAX_SET_SIZE 200 + static int test_logic_op(bitset_op bitset_op, bool_op bool_op) { - const size_t size = 1 + rte_rand_max(200); - RTE_BITSET_DECLARE(bitset_a, size); - RTE_BITSET_DECLARE(bitset_b, size); - RTE_BITSET_DECLARE(bitset_d, size); + const size_t size = 1 + rte_rand_max(LOGIC_MAX_SET_SIZE); + RTE_BITSET_DECLARE(bitset_a, LOGIC_MAX_SET_SIZE); + RTE_BITSET_DECLARE(bitset_b, LOGIC_MAX_SET_SIZE); + RTE_BITSET_DECLARE(bitset_d, LOGIC_MAX_SET_SIZE); - bool ary_a[size]; - bool ary_b[size]; - bool ary_d[size]; + bool ary_a[LOGIC_MAX_SET_SIZE]; + bool ary_b[LOGIC_MAX_SET_SIZE]; + bool ary_d[LOGIC_MAX_SET_SIZE]; rand_bool_ary(ary_a, size); rand_bool_ary(ary_b, size); @@ -708,14 +711,14 @@ test_complement(void) for (i = 0; i < RAND_ITERATIONS; i++) { const size_t size = 1 + rte_rand_max(RAND_SET_MAX_SIZE - 1); - RTE_BITSET_DECLARE(src, size); + RTE_BITSET_DECLARE(src, RAND_SET_MAX_SIZE); rand_bitset(src, size); bool bit_idx = rte_rand_max(size); bool bit_value = rte_bitset_test(src, bit_idx); - RTE_BITSET_DECLARE(dst, size); + RTE_BITSET_DECLARE(dst, RAND_SET_MAX_SIZE); rte_bitset_complement(dst, src, size); @@ -726,6 +729,8 @@ test_complement(void) return TEST_SUCCESS; } +#define SHIFT_SET_MAX_SIZE 500 + static int test_shift(bool right) { @@ -734,12 +739,12 @@ test_shift(bool right) const char *direction = right ? "right" : "left"; for (i = 0; i < 10000; i++) { - const int size = 1 + (int)rte_rand_max(500); + const int size = 1 + (int)rte_rand_max(SHIFT_SET_MAX_SIZE); const int shift_count = (int)rte_rand_max(1.5 * size); int src_idx; - RTE_BITSET_DECLARE(src, size); - RTE_BITSET_DECLARE(reference, size); + RTE_BITSET_DECLARE(src, SHIFT_SET_MAX_SIZE); + RTE_BITSET_DECLARE(reference, SHIFT_SET_MAX_SIZE); rte_bitset_init(src, size); rte_bitset_init(reference, size); @@ -788,12 +793,14 @@ test_shift_left(void) return test_shift(false); } +#define EQUAL_SET_MAX_SIZE 100 + static int test_equal(void) { - const size_t size = 100; - RTE_BITSET_DECLARE(bitset_a, size); - RTE_BITSET_DECLARE(bitset_b, size); + const size_t size = EQUAL_SET_MAX_SIZE; + RTE_BITSET_DECLARE(bitset_a, EQUAL_SET_MAX_SIZE); + RTE_BITSET_DECLARE(bitset_b, EQUAL_SET_MAX_SIZE); rand_buf(bitset_a, RTE_BITSET_SIZE(size)); rand_buf(bitset_b, RTE_BITSET_SIZE(size)); @@ -821,9 +828,9 @@ test_equal(void) static int test_copy(void) { - const size_t size = 100; - RTE_BITSET_DECLARE(bitset_a, size); - RTE_BITSET_DECLARE(bitset_b, size); + const size_t size = EQUAL_SET_MAX_SIZE; + RTE_BITSET_DECLARE(bitset_a, EQUAL_SET_MAX_SIZE); + RTE_BITSET_DECLARE(bitset_b, EQUAL_SET_MAX_SIZE); rand_buf(bitset_a, RTE_BITSET_SIZE(size)); rand_buf(bitset_b, RTE_BITSET_SIZE(size)); diff --git a/app/test/test_reassembly_perf.c b/app/test/test_reassembly_perf.c index 69cf029468..ac225e2b53 100644 --- a/app/test/test_reassembly_perf.c +++ b/app/test/test_reassembly_perf.c @@ -577,7 +577,7 @@ ipv4_reassembly_interleaved_flows_perf(uint8_t nb_frags) for (j = 0; j < 4; j++) nb_frags += frag_per_flow[i + j]; - struct rte_mbuf *buf_arr[nb_frags]; + struct rte_mbuf *buf_arr[MAX_FRAGMENTS]; for (j = 0; j < 4; j++) { join_array(buf_arr, mbufs[i + j], prev, frag_per_flow[i + j]); @@ -788,7 +788,7 @@ ipv6_reassembly_interleaved_flows_perf(int8_t nb_frags) for (j = 0; j < 4; j++) nb_frags += frag_per_flow[i + j]; - struct rte_mbuf *buf_arr[nb_frags]; + struct rte_mbuf *buf_arr[MAX_FRAGMENTS]; for (j = 0; j < 4; j++) { join_array(buf_arr, mbufs[i + j], prev, frag_per_flow[i + j]); -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* Re: [PATCH v4 18/19] test: remove use of VLAs for Windows built code in bitset tests 2024-11-05 3:15 ` [PATCH v4 18/19] test: remove use of VLAs for Windows built code in bitset tests Andre Muezerie @ 2024-11-05 8:32 ` David Marchand 2024-11-06 2:06 ` Andre Muezerie 0 siblings, 1 reply; 127+ messages in thread From: David Marchand @ 2024-11-05 8:32 UTC (permalink / raw) To: Andre Muezerie Cc: stephen, aman.deep.singh, anatoly.burakov, andrew.rybchenko, bruce.richardson, dev, dmitry.kozliuk, dsosnowski, fanzhang.oss, fengchengwen, ferruh.yigit, gakhil, harry.van.haaren, hkalra, honnappa.nagarahalli, hujiayu.hu, jingjing.wu, kevin.laatz, konstantin.v.ananyev, matan, mb, orika, pallavi.kadam, reshma.pattan, roretzla, sameh.gobriel, suanmingm, thomas, vfialko, viacheslavo, vladimir.medvedkin, yipeng1.wang On Tue, Nov 5, 2024 at 4:19 AM Andre Muezerie <andremue@linux.microsoft.com> wrote: > > MSVC does not support VLAs, replace VLAs with standard C arrays > or alloca(). alloca() is available for all toolchain/platform > combinations officially supported by DPDK. This commitlog does not reflect what is being changed in the patch. > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> gcc 13 (at least) complains about this patch. https://github.com/ovsrobot/dpdk/actions/runs/11677008675/job/32514228727#step:12:3658 I suspect you may have to change some "static" bitset into a dynamically allocated one. -- David Marchand ^ permalink raw reply [flat|nested] 127+ messages in thread
* Re: [PATCH v4 18/19] test: remove use of VLAs for Windows built code in bitset tests 2024-11-05 8:32 ` David Marchand @ 2024-11-06 2:06 ` Andre Muezerie 0 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-06 2:06 UTC (permalink / raw) To: David Marchand Cc: stephen, aman.deep.singh, anatoly.burakov, andrew.rybchenko, bruce.richardson, dev, dmitry.kozliuk, dsosnowski, fanzhang.oss, fengchengwen, ferruh.yigit, gakhil, harry.van.haaren, hkalra, honnappa.nagarahalli, hujiayu.hu, jingjing.wu, kevin.laatz, konstantin.v.ananyev, matan, mb, orika, pallavi.kadam, reshma.pattan, roretzla, sameh.gobriel, suanmingm, thomas, vfialko, viacheslavo, vladimir.medvedkin, yipeng1.wang On Tue, Nov 05, 2024 at 09:32:36AM +0100, David Marchand wrote: > On Tue, Nov 5, 2024 at 4:19 AM Andre Muezerie > <andremue@linux.microsoft.com> wrote: > > > > MSVC does not support VLAs, replace VLAs with standard C arrays > > or alloca(). alloca() is available for all toolchain/platform > > combinations officially supported by DPDK. > > This commitlog does not reflect what is being changed in the patch. > > > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> > > gcc 13 (at least) complains about this patch. > https://github.com/ovsrobot/dpdk/actions/runs/11677008675/job/32514228727#step:12:3658 > > I suspect you may have to change some "static" bitset into a > dynamically allocated one. > > > -- > David Marchand Thanks David, I'll address this. ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v4 19/19] app/testpmd: remove use of VLAs for Windows built code in shared_rxq_fwd 2024-11-05 3:15 ` [PATCH v4 00/19] remove use of VLAs for Windows Andre Muezerie ` (17 preceding siblings ...) 2024-11-05 3:15 ` [PATCH v4 18/19] test: remove use of VLAs for Windows built code in bitset tests Andre Muezerie @ 2024-11-05 3:15 ` Andre Muezerie 2024-11-05 9:37 ` [PATCH v4 00/19] remove use of VLAs for Windows Konstantin Ananyev 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-05 3:15 UTC (permalink / raw) To: stephen Cc: aman.deep.singh, anatoly.burakov, andrew.rybchenko, bruce.richardson, dev, dmitry.kozliuk, dsosnowski, fanzhang.oss, fengchengwen, ferruh.yigit, gakhil, harry.van.haaren, hkalra, honnappa.nagarahalli, hujiayu.hu, jingjing.wu, kevin.laatz, konstantin.v.ananyev, matan, mb, orika, pallavi.kadam, reshma.pattan, roretzla, sameh.gobriel, suanmingm, thomas, vfialko, viacheslavo, vladimir.medvedkin, yipeng1.wang, Andre Muezerie MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> --- app/test-pmd/shared_rxq_fwd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/test-pmd/shared_rxq_fwd.c b/app/test-pmd/shared_rxq_fwd.c index 623d62da88..b85830b90e 100644 --- a/app/test-pmd/shared_rxq_fwd.c +++ b/app/test-pmd/shared_rxq_fwd.c @@ -92,7 +92,7 @@ forward_shared_rxq(struct fwd_stream *fs, uint16_t nb_rx, static bool shared_rxq_fwd(struct fwd_stream *fs) { - struct rte_mbuf *pkts_burst[nb_pkt_per_burst]; + struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; uint16_t nb_rx; nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst); -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* RE: [PATCH v4 00/19] remove use of VLAs for Windows 2024-11-05 3:15 ` [PATCH v4 00/19] remove use of VLAs for Windows Andre Muezerie ` (18 preceding siblings ...) 2024-11-05 3:15 ` [PATCH v4 19/19] app/testpmd: remove use of VLAs for Windows built code in shared_rxq_fwd Andre Muezerie @ 2024-11-05 9:37 ` Konstantin Ananyev 19 siblings, 0 replies; 127+ messages in thread From: Konstantin Ananyev @ 2024-11-05 9:37 UTC (permalink / raw) To: Andre Muezerie, stephen Cc: aman.deep.singh, anatoly.burakov, andrew.rybchenko, bruce.richardson, dev, dmitry.kozliuk, dsosnowski, fanzhang.oss, Fengchengwen, ferruh.yigit, gakhil, harry.van.haaren, hkalra, honnappa.nagarahalli, hujiayu.hu, jingjing.wu, kevin.laatz, konstantin.v.ananyev, matan, mb, orika, pallavi.kadam, reshma.pattan, roretzla, sameh.gobriel, suanmingm, thomas, vfialko, viacheslavo, vladimir.medvedkin, yipeng1.wang Hi Andre, > As per guidance technical board meeting 2024/04/17. This series > removes the use of VLAs from code built for Windows for all 3 > toolchains. If there are additional opportunities to convert VLAs > to regular C arrays please provide the details for incorporation > into the series. > > MSVC does not support VLAs, replace VLAs with standard C arrays > or alloca(). alloca() is available for all toolchain/platform > combinations officially supported by DPDK. > Can you also include these patches: https://patchwork.dpdk.org/project/dpdk/list/?series=31972&archive=both&state=* into your series? Should help to minimize cases with alloca() approach. Thanks Konstantin > v4: > * rebase and adapt for changes made in main since v3 was sent > * use fixed maximum array size instead of VLA when doable > > v3: > * address checkpatch/check git log warnings (minor typos) > > v2: > * replace patches for ethdev, hash, rcu and include new > patches for eal from Konstantin Ananyev > from https://patchwork.dpdk.org/project/dpdk/list/?series=31781 > > Andre Muezerie (2): > test: remove use of VLAs for Windows built code in bitset tests > app/testpmd: remove use of VLAs for Windows built code in > shared_rxq_fwd > > Konstantin Ananyev (6): > eal/linux: remove use of VLAs > eal/common: remove use of VLAs > ethdev: remove use of VLAs for Windows built code > hash: remove use of VLAs for Windows built code > hash/thash: remove use of VLAs for Windows built > rcu: remove use of VLAs for Windows built code > > Tyler Retzlaff (11): > eal: include header required for alloca > gro: remove use of VLAs for Windows built code > app/testpmd: remove use of VLAs for Windows built > test: remove use of VLAs for Windows built code > common/idpf: remove use of VLAs for Windows built code > net/i40e: remove use of VLAs for Windows built code > net/ice: remove use of VLAs for Windows built code > net/ixgbe: remove use of VLAs for Windows built code > common/mlx5: remove use of VLAs for Windows built code > net/mlx5: remove use of VLAs for Windows built code > build: enable vla warnings on Windows built code > > app/test-pmd/cmdline.c | 2 +- > app/test-pmd/cmdline_flow.c | 15 +- > app/test-pmd/config.c | 16 +- > app/test-pmd/shared_rxq_fwd.c | 2 +- > app/test/test.c | 2 +- > app/test/test_bitset.c | 55 +++--- > app/test/test_cmdline_string.c | 2 +- > app/test/test_cryptodev.c | 34 ++-- > app/test/test_cryptodev_blockcipher.c | 4 +- > app/test/test_cryptodev_crosscheck.c | 2 +- > app/test/test_dmadev.c | 9 +- > app/test/test_hash.c | 14 +- > app/test/test_mempool.c | 25 +-- > app/test/test_reassembly_perf.c | 4 +- > app/test/test_reorder.c | 48 ++--- > app/test/test_service_cores.c | 9 +- > app/test/test_thash.c | 7 +- > config/meson.build | 4 + > drivers/common/idpf/idpf_common_rxtx.c | 2 +- > drivers/common/idpf/idpf_common_rxtx_avx512.c | 6 +- > drivers/common/mlx5/mlx5_common.h | 4 +- > drivers/common/mlx5/mlx5_devx_cmds.c | 7 +- > drivers/net/i40e/i40e_testpmd.c | 5 +- > drivers/net/ice/ice_rxtx.c | 2 +- > drivers/net/ixgbe/ixgbe_ethdev.c | 5 +- > drivers/net/ixgbe/ixgbe_rxtx_vec_common.h | 2 +- > drivers/net/mlx5/mlx5.c | 5 +- > drivers/net/mlx5/mlx5_flow.c | 6 +- > lib/eal/common/eal_common_proc.c | 5 +- > lib/eal/linux/eal_interrupts.c | 59 +++++- > lib/eal/linux/include/rte_os.h | 1 + > lib/eal/windows/include/rte_os.h | 1 + > lib/ethdev/rte_ethdev.c | 183 +++++++++++------- > lib/gro/rte_gro.c | 4 +- > lib/hash/rte_cuckoo_hash.c | 4 +- > lib/hash/rte_thash.c | 2 +- > lib/hash/rte_thash.h | 8 + > lib/rcu/rte_rcu_qsbr.c | 7 +- > lib/rcu/rte_rcu_qsbr.h | 5 + > 39 files changed, 354 insertions(+), 223 deletions(-) > > -- > 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v5 00/20] remove use of VLAs for Windows 2024-04-17 23:41 [PATCH 00/16] remove use of VLAs for Windows built code Tyler Retzlaff ` (21 preceding siblings ...) 2024-11-05 3:15 ` [PATCH v4 00/19] remove use of VLAs for Windows Andre Muezerie @ 2024-11-08 0:44 ` Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 01/20] eal: include header required for alloca Andre Muezerie ` (19 more replies) 22 siblings, 20 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-08 0:44 UTC (permalink / raw) To: dev; +Cc: Andre Muezerie As per guidance technical board meeting 2024/04/17. This series removes the use of VLAs from code built for Windows for all 3 toolchains. If there are additional opportunities to convert VLAs to regular C arrays please provide the details for incorporation into the series. MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. v5: * add patches for net/ice, net/ixgbe and gro from Konstantin Ananyev from https://patchwork.dpdk.org/project/dpdk/list/?series=31972&archive=both&state=* * address debug_autotest ASan failure * address array-bound error in bitset_autotest with gcc-13 v4: * rebase and adapt for changes made in main since v3 was sent * use fixed maximum array size instead of VLA when doable v3: * address checkpatch/check git log warnings (minor typos) v2: * replace patches for ethdev, hash, rcu and include new patches for eal from Konstantin Ananyev from https://patchwork.dpdk.org/project/dpdk/list/?series=31781 Andre Muezerie (2): test: remove use of VLAs for Windows built code in bitset tests app/testpmd: remove use of VLAs for Windows built code in shared_rxq_fwd Konstantin Ananyev (10): eal/linux: remove use of VLAs eal/common: remove use of VLAs ethdev: remove use of VLAs for Windows built code hash: remove use of VLAs for Windows built code hash/thash: remove use of VLAs for Windows built rcu: remove use of VLAs for Windows built code net/ice: remove use of VLAs for Windows built code gro: remove use of VLAs net/ixgbe: remove use of VLAs net/ice: remove use of VLAs Tyler Retzlaff (8): eal: include header required for alloca app/testpmd: remove use of VLAs for Windows built test: remove use of VLAs for Windows built code common/idpf: remove use of VLAs for Windows built code net/i40e: remove use of VLAs for Windows built code common/mlx5: remove use of VLAs for Windows built code net/mlx5: remove use of VLAs for Windows built code build: enable vla warnings on Windows built code app/test-pmd/cmdline.c | 2 +- app/test-pmd/cmdline_flow.c | 15 +- app/test-pmd/config.c | 16 +- app/test-pmd/shared_rxq_fwd.c | 2 +- app/test/meson.build | 5 + app/test/test.c | 2 +- app/test/test_bitset.c | 55 +++--- app/test/test_cmdline_string.c | 2 +- app/test/test_cryptodev.c | 34 ++-- app/test/test_cryptodev_blockcipher.c | 4 +- app/test/test_cryptodev_crosscheck.c | 2 +- app/test/test_dmadev.c | 9 +- app/test/test_hash.c | 14 +- app/test/test_mempool.c | 25 +-- app/test/test_reassembly_perf.c | 4 +- app/test/test_reorder.c | 48 ++--- app/test/test_service_cores.c | 9 +- app/test/test_thash.c | 7 +- config/meson.build | 4 + drivers/common/idpf/idpf_common_rxtx.c | 2 +- drivers/common/idpf/idpf_common_rxtx_avx512.c | 6 +- drivers/common/mlx5/mlx5_common.h | 4 +- drivers/common/mlx5/mlx5_devx_cmds.c | 7 +- drivers/net/i40e/i40e_testpmd.c | 5 +- drivers/net/ice/ice_rxtx.c | 18 +- drivers/net/ice/ice_rxtx.h | 2 + drivers/net/ixgbe/ixgbe_ethdev.c | 21 +- drivers/net/ixgbe/ixgbe_rxtx_vec_common.h | 4 +- drivers/net/mlx5/mlx5.c | 5 +- drivers/net/mlx5/mlx5_flow.c | 6 +- lib/eal/common/eal_common_proc.c | 5 +- lib/eal/linux/eal_interrupts.c | 32 ++- lib/eal/linux/include/rte_os.h | 1 + lib/eal/windows/include/rte_os.h | 1 + lib/ethdev/rte_ethdev.c | 183 +++++++++++------- lib/gro/rte_gro.c | 42 ++-- lib/hash/rte_cuckoo_hash.c | 4 +- lib/hash/rte_thash.c | 2 +- lib/hash/rte_thash.h | 8 + lib/rcu/rte_rcu_qsbr.c | 7 +- lib/rcu/rte_rcu_qsbr.h | 5 + 41 files changed, 372 insertions(+), 257 deletions(-) -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v5 01/20] eal: include header required for alloca 2024-11-08 0:44 ` [PATCH v5 00/20] " Andre Muezerie @ 2024-11-08 0:44 ` Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 02/20] eal/linux: remove use of VLAs Andre Muezerie ` (18 subsequent siblings) 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-08 0:44 UTC (permalink / raw) To: dev; +Cc: Tyler Retzlaff From: Tyler Retzlaff <roretzla@linux.microsoft.com> Include alloca.h for Linux and malloc.h for Windows to get declaration of alloca(). Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- lib/eal/linux/include/rte_os.h | 1 + lib/eal/windows/include/rte_os.h | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/eal/linux/include/rte_os.h b/lib/eal/linux/include/rte_os.h index 35c07c70cb..20eff0409a 100644 --- a/lib/eal/linux/include/rte_os.h +++ b/lib/eal/linux/include/rte_os.h @@ -10,6 +10,7 @@ * which is not supported natively or named differently in Linux. */ +#include <alloca.h> #include <sched.h> #include <sys/queue.h> diff --git a/lib/eal/windows/include/rte_os.h b/lib/eal/windows/include/rte_os.h index 9d69467aaa..d09adeb3b4 100644 --- a/lib/eal/windows/include/rte_os.h +++ b/lib/eal/windows/include/rte_os.h @@ -13,6 +13,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <malloc.h> #include <sched.h> -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v5 02/20] eal/linux: remove use of VLAs 2024-11-08 0:44 ` [PATCH v5 00/20] " Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 01/20] eal: include header required for alloca Andre Muezerie @ 2024-11-08 0:44 ` Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 03/20] eal/common: " Andre Muezerie ` (17 subsequent siblings) 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-08 0:44 UTC (permalink / raw) To: dev; +Cc: Konstantin Ananyev From: Konstantin Ananyev <konstantin.ananyev@huawei.com> 1) ./lib/eal/linux/eal_interrupts.c:1073:16 : warning: ISO C90 forbids variable length array ‘events’ MSVC does not support VLAs. Use alloca() to allocate the memory on the stack. 2) ./lib/eal/linux/eal_interrupts.c:1319:16 : warning: ISO C90 forbids variable length array ‘evs’ make eal_epoll_wait() use a fixed size array and use it though multiple iterations to process up to @maxevents events. Note that technically it is not one to one replacement, as here we might reduce number of events returned by first call to epoll_wait(..., timeout); Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> --- lib/eal/linux/eal_interrupts.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/lib/eal/linux/eal_interrupts.c b/lib/eal/linux/eal_interrupts.c index 6436f796eb..23039964fc 100644 --- a/lib/eal/linux/eal_interrupts.c +++ b/lib/eal/linux/eal_interrupts.c @@ -34,6 +34,8 @@ #define EAL_INTR_EPOLL_WAIT_FOREVER (-1) #define NB_OTHER_INTR 1 +#define MAX_ITER_EVNUM RTE_EVENT_ETH_INTR_RING_SIZE + static RTE_DEFINE_PER_LCORE(int, _epfd) = -1; /**< epoll fd per thread */ /** @@ -1070,7 +1072,7 @@ eal_intr_process_interrupts(struct epoll_event *events, int nfds) static void eal_intr_handle_interrupts(int pfd, unsigned totalfds) { - struct epoll_event events[totalfds]; + struct epoll_event *events = alloca(sizeof(struct epoll_event) * totalfds); int nfds = 0; for(;;) { @@ -1316,8 +1318,9 @@ static int eal_epoll_wait(int epfd, struct rte_epoll_event *events, int maxevents, int timeout, bool interruptible) { - struct epoll_event evs[maxevents]; int rc; + uint32_t i, k, n, num; + struct epoll_event evs[MAX_ITER_EVNUM]; if (!events) { EAL_LOG(ERR, "rte_epoll_event can't be NULL"); @@ -1328,12 +1331,31 @@ eal_epoll_wait(int epfd, struct rte_epoll_event *events, if (epfd == RTE_EPOLL_PER_THREAD) epfd = rte_intr_tls_epfd(); + num = maxevents; + n = RTE_MIN(RTE_DIM(evs), num); + + /* Process events in chunks of MAX_ITER_EVNUM */ + while (1) { - rc = epoll_wait(epfd, evs, maxevents, timeout); + rc = epoll_wait(epfd, evs, n, timeout); if (likely(rc > 0)) { + /* epoll_wait has at least one fd ready to read */ - rc = eal_epoll_process_event(evs, rc, events); - break; + for (i = 0, k = 0; rc > 0;) { + k += rc; + rc = eal_epoll_process_event(evs, rc, + events + i); + i += rc; + + /* + * try to read more events that are already + * available (up to maxevents in total). + */ + n = RTE_MIN(RTE_DIM(evs), num - k); + rc = (n == 0) ? 0 : epoll_wait(epfd, evs, n, 0); + } + return i; + } else if (rc < 0) { if (errno == EINTR) { if (interruptible) -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v5 03/20] eal/common: remove use of VLAs 2024-11-08 0:44 ` [PATCH v5 00/20] " Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 01/20] eal: include header required for alloca Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 02/20] eal/linux: remove use of VLAs Andre Muezerie @ 2024-11-08 0:44 ` Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 04/20] ethdev: remove use of VLAs for Windows built code Andre Muezerie ` (16 subsequent siblings) 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-08 0:44 UTC (permalink / raw) To: dev; +Cc: Konstantin Ananyev From: Konstantin Ananyev <konstantin.ananyev@huawei.com> 1) ../lib/eal/common/eal_common_proc.c:695:15 : warning: variable length array used As msg->num_fds should not exceed RTE_MP_MAX_FD_NUM, replaced it with fixed size array. Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> --- lib/eal/common/eal_common_proc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/eal/common/eal_common_proc.c b/lib/eal/common/eal_common_proc.c index d24093937c..201973c5db 100644 --- a/lib/eal/common/eal_common_proc.c +++ b/lib/eal/common/eal_common_proc.c @@ -692,7 +692,8 @@ send_msg(const char *dst_path, struct rte_mp_msg *msg, int type) struct sockaddr_un dst; struct mp_msg_internal m; int fd_size = msg->num_fds * sizeof(int); - char control[CMSG_SPACE(fd_size)]; + const int32_t control_sz = CMSG_SPACE(fd_size); + char control[CMSG_SPACE(sizeof(msg->fds))]; m.type = type; memcpy(&m.msg, msg, sizeof(*msg)); @@ -712,7 +713,7 @@ send_msg(const char *dst_path, struct rte_mp_msg *msg, int type) msgh.msg_iov = &iov; msgh.msg_iovlen = 1; msgh.msg_control = control; - msgh.msg_controllen = sizeof(control); + msgh.msg_controllen = control_sz; cmsg = CMSG_FIRSTHDR(&msgh); cmsg->cmsg_len = CMSG_LEN(fd_size); -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v5 04/20] ethdev: remove use of VLAs for Windows built code 2024-11-08 0:44 ` [PATCH v5 00/20] " Andre Muezerie ` (2 preceding siblings ...) 2024-11-08 0:44 ` [PATCH v5 03/20] eal/common: " Andre Muezerie @ 2024-11-08 0:44 ` Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 05/20] hash: " Andre Muezerie ` (15 subsequent siblings) 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-08 0:44 UTC (permalink / raw) To: dev; +Cc: Konstantin Ananyev From: Konstantin Ananyev <konstantin.ananyev@huawei.com> 1) ./lib/ethdev/rte_ethdev.c:3244:16 : warning: ISO C90 forbids variable length array ‘xstats_names’ 2) ./lib/ethdev/rte_ethdev.c:3345:17 : warning: ISO C90 forbids variable length array ‘ids_copy’ 3) ./lib/ethdev/rte_ethdev.c:3538:16 : warning: ISO C90 forbids variable length array ‘xstats’ 4) ./lib/ethdev/rte_ethdev.c:3554:17 : warning: ISO C90 forbids variable length array ‘ids_copy’ For 1) and 3) - just replaced VLA with arrays allocated from heap. As I understand xstats extraction belongs to control-path, so extra calloc/free is hopefully acceptable. Also ethdev xstats already doing that within rte_eth_xstats_get_id_by_name(). For 2) and 4) changed the code to use fixed size array and call appropriate devops function several times, if needed. Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> --- lib/ethdev/rte_ethdev.c | 183 +++++++++++++++++++++++++--------------- 1 file changed, 113 insertions(+), 70 deletions(-) diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 6413c54e3b..09cc4764c3 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -36,6 +36,8 @@ #include "ethdev_trace.h" #include "sff_telemetry.h" +#define ETH_XSTATS_ITER_NUM 0x100 + struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS]; /* public fast-path API */ @@ -3308,7 +3310,8 @@ int rte_eth_xstats_get_id_by_name(uint16_t port_id, const char *xstat_name, uint64_t *id) { - int cnt_xstats, idx_xstat; + int cnt_xstats, idx_xstat, rc; + struct rte_eth_xstat_name *xstats_names; RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); @@ -3334,26 +3337,33 @@ rte_eth_xstats_get_id_by_name(uint16_t port_id, const char *xstat_name, } /* Get id-name lookup table */ - struct rte_eth_xstat_name xstats_names[cnt_xstats]; + xstats_names = calloc(cnt_xstats, sizeof(xstats_names[0])); + if (xstats_names == NULL) { + RTE_ETHDEV_LOG_LINE(ERR, "Can't allocate memory"); + return -ENOMEM; + } if (cnt_xstats != rte_eth_xstats_get_names_by_id( port_id, xstats_names, cnt_xstats, NULL)) { RTE_ETHDEV_LOG_LINE(ERR, "Cannot get xstats lookup"); + free(xstats_names); return -1; } + rc = -EINVAL; for (idx_xstat = 0; idx_xstat < cnt_xstats; idx_xstat++) { if (!strcmp(xstats_names[idx_xstat].name, xstat_name)) { *id = idx_xstat; rte_eth_trace_xstats_get_id_by_name(port_id, xstat_name, *id); - - return 0; + rc = 0; + break; }; } - return -EINVAL; + free(xstats_names); + return rc; } /* retrieve basic stats names */ @@ -3399,6 +3409,38 @@ eth_basic_stats_get_names(struct rte_eth_dev *dev, return cnt_used_entries; } +static int +eth_xstats_get_by_name_by_id(struct rte_eth_dev *dev, const uint64_t *ids, + struct rte_eth_xstat_name *xstats_names, uint32_t size, + uint32_t basic_count) +{ + int32_t rc; + uint32_t i, k, m, n; + uint64_t ids_copy[ETH_XSTATS_ITER_NUM]; + + m = 0; + for (n = 0; n != size; n += k) { + + k = RTE_MIN(size - n, RTE_DIM(ids_copy)); + + /* + * Convert ids to xstats ids that PMD knows. + * ids known by user are basic + extended stats. + */ + for (i = 0; i < k; i++) + ids_copy[i] = ids[n + i] - basic_count; + + rc = (*dev->dev_ops->xstats_get_names_by_id)(dev, ids_copy, + xstats_names + m, k); + if (rc < 0) + return rc; + m += rc; + } + + return m; +} + + /* retrieve ethdev extended statistics names */ int rte_eth_xstats_get_names_by_id(uint16_t port_id, @@ -3406,9 +3448,8 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id, uint64_t *ids) { struct rte_eth_xstat_name *xstats_names_copy; - unsigned int no_basic_stat_requested = 1; - unsigned int no_ext_stat_requested = 1; unsigned int expected_entries; + unsigned int nb_basic_stats; unsigned int basic_count; struct rte_eth_dev *dev; unsigned int i; @@ -3434,27 +3475,18 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id, if (ids && !xstats_names) return -EINVAL; - if (ids && dev->dev_ops->xstats_get_names_by_id != NULL && size > 0) { - uint64_t ids_copy[size]; - - for (i = 0; i < size; i++) { - if (ids[i] < basic_count) { - no_basic_stat_requested = 0; - break; - } - - /* - * Convert ids to xstats ids that PMD knows. - * ids known by user are basic + extended stats. - */ - ids_copy[i] = ids[i] - basic_count; - } - - if (no_basic_stat_requested) - return (*dev->dev_ops->xstats_get_names_by_id)(dev, - ids_copy, xstats_names, size); + nb_basic_stats = 0; + if (ids != NULL) { + for (i = 0; i < size; i++) + nb_basic_stats += (ids[i] < basic_count); } + /* no basic stats requested, devops function provided */ + if (nb_basic_stats == 0 && ids != NULL && size != 0 && + dev->dev_ops->xstats_get_names_by_id != NULL) + return eth_xstats_get_by_name_by_id(dev, ids, xstats_names, + size, basic_count); + /* Retrieve all stats */ if (!ids) { int num_stats = rte_eth_xstats_get_names(port_id, xstats_names, @@ -3473,17 +3505,8 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id, return -ENOMEM; } - if (ids) { - for (i = 0; i < size; i++) { - if (ids[i] >= basic_count) { - no_ext_stat_requested = 0; - break; - } - } - } - /* Fill xstats_names_copy structure */ - if (ids && no_ext_stat_requested) { + if (ids && nb_basic_stats == size) { eth_basic_stats_get_names(dev, xstats_names_copy); } else { ret = rte_eth_xstats_get_names(port_id, xstats_names_copy, @@ -3607,17 +3630,47 @@ eth_basic_stats_get(uint16_t port_id, struct rte_eth_xstat *xstats) return count; } +static int +eth_xtats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, + uint64_t *values, uint32_t size, uint32_t basic_count) +{ + int32_t rc; + uint32_t i, k, m, n; + uint64_t ids_copy[ETH_XSTATS_ITER_NUM]; + + m = 0; + for (n = 0; n != size; n += k) { + + k = RTE_MIN(size - n, RTE_DIM(ids_copy)); + + /* + * Convert ids to xstats ids that PMD knows. + * ids known by user are basic + extended stats. + */ + for (i = 0; i < k; i++) + ids_copy[i] = ids[n + i] - basic_count; + + rc = (*dev->dev_ops->xstats_get_by_id)(dev, ids_copy, + values + m, k); + if (rc < 0) + return rc; + m += rc; + } + + return m; +} + /* retrieve ethdev extended statistics */ int rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids, uint64_t *values, unsigned int size) { - unsigned int no_basic_stat_requested = 1; - unsigned int no_ext_stat_requested = 1; + unsigned int nb_basic_stats; unsigned int num_xstats_filled; unsigned int basic_count; uint16_t expected_entries; struct rte_eth_dev *dev; + struct rte_eth_xstat *xstats; unsigned int i; int ret; @@ -3628,7 +3681,6 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids, if (ret < 0) return ret; expected_entries = (uint16_t)ret; - struct rte_eth_xstat xstats[expected_entries]; basic_count = eth_dev_get_xstats_basic_count(dev); /* Return max number of stats if no ids given */ @@ -3642,51 +3694,41 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids, if (ids && !values) return -EINVAL; - if (ids && dev->dev_ops->xstats_get_by_id != NULL && size) { - unsigned int basic_count = eth_dev_get_xstats_basic_count(dev); - uint64_t ids_copy[size]; - - for (i = 0; i < size; i++) { - if (ids[i] < basic_count) { - no_basic_stat_requested = 0; - break; - } - - /* - * Convert ids to xstats ids that PMD knows. - * ids known by user are basic + extended stats. - */ - ids_copy[i] = ids[i] - basic_count; - } - - if (no_basic_stat_requested) - return (*dev->dev_ops->xstats_get_by_id)(dev, ids_copy, - values, size); + nb_basic_stats = 0; + if (ids != NULL) { + for (i = 0; i < size; i++) + nb_basic_stats += (ids[i] < basic_count); } - if (ids) { - for (i = 0; i < size; i++) { - if (ids[i] >= basic_count) { - no_ext_stat_requested = 0; - break; - } - } + /* no basic stats requested, devops function provided */ + if (nb_basic_stats == 0 && ids != NULL && size != 0 && + dev->dev_ops->xstats_get_by_id != NULL) + return eth_xtats_get_by_id(dev, ids, values, size, basic_count); + + xstats = calloc(expected_entries, sizeof(xstats[0])); + if (xstats == NULL) { + RTE_ETHDEV_LOG_LINE(ERR, "Can't allocate memory"); + return -ENOMEM; } /* Fill the xstats structure */ - if (ids && no_ext_stat_requested) + if (ids && nb_basic_stats == size) ret = eth_basic_stats_get(port_id, xstats); else ret = rte_eth_xstats_get(port_id, xstats, expected_entries); - if (ret < 0) + if (ret < 0) { + free(xstats); return ret; + } num_xstats_filled = (unsigned int)ret; /* Return all stats */ if (!ids) { for (i = 0; i < num_xstats_filled; i++) values[i] = xstats[i].value; + + free(xstats); return expected_entries; } @@ -3694,14 +3736,15 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids, for (i = 0; i < size; i++) { if (ids[i] >= expected_entries) { RTE_ETHDEV_LOG_LINE(ERR, "Id value isn't valid"); - return -1; + break; } values[i] = xstats[ids[i]].value; } rte_eth_trace_xstats_get_by_id(port_id, ids, values, size); - return size; + free(xstats); + return (i == size) ? (int32_t)size : -1; } int -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v5 05/20] hash: remove use of VLAs for Windows built code 2024-11-08 0:44 ` [PATCH v5 00/20] " Andre Muezerie ` (3 preceding siblings ...) 2024-11-08 0:44 ` [PATCH v5 04/20] ethdev: remove use of VLAs for Windows built code Andre Muezerie @ 2024-11-08 0:44 ` Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 06/20] hash/thash: remove use of VLAs for Windows built Andre Muezerie ` (14 subsequent siblings) 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-08 0:44 UTC (permalink / raw) To: dev; +Cc: Konstantin Ananyev From: Konstantin Ananyev <konstantin.ananyev@huawei.com> 1) ./lib/hash/rte_cuckoo_hash.c:2362:9 : warning: ISO C90 forbids variable length array ‘positions’ 2) ../lib/hash/rte_cuckoo_hash.c:2478:9 : warning: ISO C90 forbids variable length array ‘positions’ Both rte_hash_lookup_bulk_data() and rte_hash_lookup_with_hash_bulk_data() expect @num_keys <= RTE_HASH_LOOKUP_BULK_MAX. So, for both cases it should be safe to replace VLA with fixed size array. Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> --- lib/hash/rte_cuckoo_hash.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c index 9575e8aa0c..fc93182efe 100644 --- a/lib/hash/rte_cuckoo_hash.c +++ b/lib/hash/rte_cuckoo_hash.c @@ -2418,7 +2418,7 @@ rte_hash_lookup_bulk_data(const struct rte_hash *h, const void **keys, (num_keys > RTE_HASH_LOOKUP_BULK_MAX) || (hit_mask == NULL)), -EINVAL); - int32_t positions[num_keys]; + int32_t positions[RTE_HASH_LOOKUP_BULK_MAX]; __rte_hash_lookup_bulk(h, keys, num_keys, positions, hit_mask, data); @@ -2534,7 +2534,7 @@ rte_hash_lookup_with_hash_bulk_data(const struct rte_hash *h, (num_keys > RTE_HASH_LOOKUP_BULK_MAX) || (hit_mask == NULL)), -EINVAL); - int32_t positions[num_keys]; + int32_t positions[RTE_HASH_LOOKUP_BULK_MAX]; __rte_hash_lookup_with_hash_bulk(h, keys, sig, num_keys, positions, hit_mask, data); -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v5 06/20] hash/thash: remove use of VLAs for Windows built 2024-11-08 0:44 ` [PATCH v5 00/20] " Andre Muezerie ` (4 preceding siblings ...) 2024-11-08 0:44 ` [PATCH v5 05/20] hash: " Andre Muezerie @ 2024-11-08 0:44 ` Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 07/20] rcu: remove use of VLAs for Windows built code Andre Muezerie ` (13 subsequent siblings) 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-08 0:44 UTC (permalink / raw) To: dev; +Cc: Konstantin Ananyev From: Konstantin Ananyev <konstantin.ananyev@huawei.com> 1) ./lib/hash/rte_thash.c:774:9 : warning: ISO C90 forbids variable length array ‘tmp_tuple’ From my understanding, tuple size here should never exceed sizeof(union rte_thash_tuple), so it should be safe to replace VLA with fixed size array. Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> --- lib/hash/rte_thash.c | 2 +- lib/hash/rte_thash.h | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c index 99a685f0c8..8ecadb9fef 100644 --- a/lib/hash/rte_thash.c +++ b/lib/hash/rte_thash.c @@ -795,7 +795,7 @@ rte_thash_adjust_tuple(struct rte_thash_ctx *ctx, uint32_t desired_value, unsigned int attempts, rte_thash_check_tuple_t fn, void *userdata) { - uint32_t tmp_tuple[tuple_len / sizeof(uint32_t)]; + uint32_t tmp_tuple[RTE_THASH_MAX_L4_LEN]; unsigned int i, j, ret = 0; uint32_t hash, adj_bits; const uint8_t *hash_key; diff --git a/lib/hash/rte_thash.h b/lib/hash/rte_thash.h index e8fdb89530..3ee22c9e32 100644 --- a/lib/hash/rte_thash.h +++ b/lib/hash/rte_thash.h @@ -108,6 +108,14 @@ union rte_thash_tuple { struct rte_ipv6_tuple v6; }; +/** + * maximum length in dwords of input tuple to + * calculate hash of ipv(4|6) header + + * transport header + */ +#define RTE_THASH_MAX_L4_LEN \ + ((sizeof(union rte_thash_tuple)) / sizeof(uint32_t)) + /** * Prepare special converted key to use with rte_softrss_be() * @param orig -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v5 07/20] rcu: remove use of VLAs for Windows built code 2024-11-08 0:44 ` [PATCH v5 00/20] " Andre Muezerie ` (5 preceding siblings ...) 2024-11-08 0:44 ` [PATCH v5 06/20] hash/thash: remove use of VLAs for Windows built Andre Muezerie @ 2024-11-08 0:44 ` Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 08/20] net/ice: " Andre Muezerie ` (12 subsequent siblings) 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-08 0:44 UTC (permalink / raw) To: dev; +Cc: Konstantin Ananyev From: Konstantin Ananyev <konstantin.ananyev@huawei.com> 1) ./lib/rcu/rte_rcu_qsbr.c:359:9 : warning: ISO C90 forbids variable length array ‘data’ [-Wvla] 2) ./lib/rcu/rte_rcu_qsbr.c:422:9 : warning: ISO C90 forbids variable length array ‘data’ [-Wvla] In both cases we allocate VLA for one element from RCU deferred queue. Right now, size of element in RCU queue is not limited by API. The approach is to introduce some reasonable limitation on RCU DQ element size. Choose 128B for now. With that in place we can replace both VLA occurencies with fixed size array. Note that such change need to be treated as API change. So can be applied only at 24.11. Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> --- lib/rcu/rte_rcu_qsbr.c | 7 ++++--- lib/rcu/rte_rcu_qsbr.h | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/rcu/rte_rcu_qsbr.c b/lib/rcu/rte_rcu_qsbr.c index 40d7c566c8..09a14a15f1 100644 --- a/lib/rcu/rte_rcu_qsbr.c +++ b/lib/rcu/rte_rcu_qsbr.c @@ -245,7 +245,8 @@ rte_rcu_qsbr_dq_create(const struct rte_rcu_qsbr_dq_parameters *params) if (params == NULL || params->free_fn == NULL || params->v == NULL || params->name == NULL || params->size == 0 || params->esize == 0 || - (params->esize % 4 != 0)) { + (params->esize % 4 != 0) || + params->esize > RTE_QSBR_ESIZE_MAX) { RCU_LOG(ERR, "Invalid input parameter"); rte_errno = EINVAL; @@ -323,7 +324,7 @@ int rte_rcu_qsbr_dq_enqueue(struct rte_rcu_qsbr_dq *dq, void *e) return 1; } - char data[dq->esize]; + char data[RTE_QSBR_ESIZE_MAX + __RTE_QSBR_TOKEN_SIZE]; dq_elem = (__rte_rcu_qsbr_dq_elem_t *)data; /* Start the grace period */ dq_elem->token = rte_rcu_qsbr_start(dq->v); @@ -386,7 +387,7 @@ rte_rcu_qsbr_dq_reclaim(struct rte_rcu_qsbr_dq *dq, unsigned int n, cnt = 0; - char data[dq->esize]; + char data[RTE_QSBR_ESIZE_MAX + __RTE_QSBR_TOKEN_SIZE]; /* Check reader threads quiescent state and reclaim resources */ while (cnt < n && rte_ring_dequeue_bulk_elem_start(dq->r, &data, diff --git a/lib/rcu/rte_rcu_qsbr.h b/lib/rcu/rte_rcu_qsbr.h index 550fadf56a..abcbd78914 100644 --- a/lib/rcu/rte_rcu_qsbr.h +++ b/lib/rcu/rte_rcu_qsbr.h @@ -86,6 +86,11 @@ struct __rte_cache_aligned rte_rcu_qsbr_cnt { #define __RTE_QSBR_CNT_MAX ((uint64_t)~0) #define __RTE_QSBR_TOKEN_SIZE sizeof(uint64_t) +/** + * Max allowable size (in bytes) of each element in the defer queue + */ +#define RTE_QSBR_ESIZE_MAX (2 * RTE_CACHE_LINE_MIN_SIZE) + /* RTE Quiescent State variable structure. * This structure has two elements that vary in size based on the * 'max_threads' parameter. -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v5 08/20] net/ice: remove use of VLAs for Windows built code 2024-11-08 0:44 ` [PATCH v5 00/20] " Andre Muezerie ` (6 preceding siblings ...) 2024-11-08 0:44 ` [PATCH v5 07/20] rcu: remove use of VLAs for Windows built code Andre Muezerie @ 2024-11-08 0:44 ` Andre Muezerie 2024-11-08 8:51 ` Bruce Richardson 2024-11-08 0:44 ` [PATCH v5 09/20] gro: remove use of VLAs Andre Muezerie ` (11 subsequent siblings) 19 siblings, 1 reply; 127+ messages in thread From: Andre Muezerie @ 2024-11-08 0:44 UTC (permalink / raw) To: dev; +Cc: Konstantin Ananyev, stable From: Konstantin Ananyev <konstantin.ananyev@huawei.com> gro_vxlan_tcp4_tbl_timeout_flush() is called without taking into account that first entries in pkts[] can be already occupied by un-processed packets. Fixes: 74080d7dcf31 ("gro: support IPv6 for TCP") Cc: stable@dpdk.org Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> Acked-by: Ferruh Yigit <ferruh.yigit@amd.com> --- lib/gro/rte_gro.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gro/rte_gro.c b/lib/gro/rte_gro.c index d824eebd93..db86117609 100644 --- a/lib/gro/rte_gro.c +++ b/lib/gro/rte_gro.c @@ -327,7 +327,7 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts, /* Flush all packets from the tables */ if (do_vxlan_tcp_gro) { i += gro_vxlan_tcp4_tbl_timeout_flush(&vxlan_tcp_tbl, - 0, pkts, nb_pkts); + 0, &pkts[i], nb_pkts - i); } if (do_vxlan_udp_gro) { -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* Re: [PATCH v5 08/20] net/ice: remove use of VLAs for Windows built code 2024-11-08 0:44 ` [PATCH v5 08/20] net/ice: " Andre Muezerie @ 2024-11-08 8:51 ` Bruce Richardson 2024-11-08 10:18 ` Konstantin Ananyev 0 siblings, 1 reply; 127+ messages in thread From: Bruce Richardson @ 2024-11-08 8:51 UTC (permalink / raw) To: Andre Muezerie; +Cc: dev, Konstantin Ananyev, stable Title for this patch is incorrect. Does it belong merged with the next patch in series? On Thu, Nov 07, 2024 at 04:44:39PM -0800, Andre Muezerie wrote: > From: Konstantin Ananyev <konstantin.ananyev@huawei.com> > > gro_vxlan_tcp4_tbl_timeout_flush() is called without taking into account > that first entries in pkts[] can be already occupied by > un-processed packets. > > Fixes: 74080d7dcf31 ("gro: support IPv6 for TCP") > Cc: stable@dpdk.org > > Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> > Acked-by: Ferruh Yigit <ferruh.yigit@amd.com> > --- > lib/gro/rte_gro.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/gro/rte_gro.c b/lib/gro/rte_gro.c > index d824eebd93..db86117609 100644 > --- a/lib/gro/rte_gro.c > +++ b/lib/gro/rte_gro.c > @@ -327,7 +327,7 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts, > /* Flush all packets from the tables */ > if (do_vxlan_tcp_gro) { > i += gro_vxlan_tcp4_tbl_timeout_flush(&vxlan_tcp_tbl, > - 0, pkts, nb_pkts); > + 0, &pkts[i], nb_pkts - i); > } > > if (do_vxlan_udp_gro) { > -- > 2.34.1 > ^ permalink raw reply [flat|nested] 127+ messages in thread
* RE: [PATCH v5 08/20] net/ice: remove use of VLAs for Windows built code 2024-11-08 8:51 ` Bruce Richardson @ 2024-11-08 10:18 ` Konstantin Ananyev 0 siblings, 0 replies; 127+ messages in thread From: Konstantin Ananyev @ 2024-11-08 10:18 UTC (permalink / raw) To: Bruce Richardson, Andre Muezerie; +Cc: dev, stable > > Title for this patch is incorrect. Does it belong merged with the next > patch in series? Yes, seems like oringianl title get lost, I think it needs to be: gro: fix overwrite unprocessed packets https://patchwork.dpdk.org/project/dpdk/patch/20240523162604.2600-2-konstantin.v.ananyev@yandex.ru/ > > On Thu, Nov 07, 2024 at 04:44:39PM -0800, Andre Muezerie wrote: > > From: Konstantin Ananyev <konstantin.ananyev@huawei.com> > > > > gro_vxlan_tcp4_tbl_timeout_flush() is called without taking into account > > that first entries in pkts[] can be already occupied by > > un-processed packets. > > > > Fixes: 74080d7dcf31 ("gro: support IPv6 for TCP") > > Cc: stable@dpdk.org > > > > Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> > > Acked-by: Ferruh Yigit <ferruh.yigit@amd.com> > > --- > > lib/gro/rte_gro.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/lib/gro/rte_gro.c b/lib/gro/rte_gro.c > > index d824eebd93..db86117609 100644 > > --- a/lib/gro/rte_gro.c > > +++ b/lib/gro/rte_gro.c > > @@ -327,7 +327,7 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts, > > /* Flush all packets from the tables */ > > if (do_vxlan_tcp_gro) { > > i += gro_vxlan_tcp4_tbl_timeout_flush(&vxlan_tcp_tbl, > > - 0, pkts, nb_pkts); > > + 0, &pkts[i], nb_pkts - i); > > } > > > > if (do_vxlan_udp_gro) { > > -- > > 2.34.1 > > ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v5 09/20] gro: remove use of VLAs 2024-11-08 0:44 ` [PATCH v5 00/20] " Andre Muezerie ` (7 preceding siblings ...) 2024-11-08 0:44 ` [PATCH v5 08/20] net/ice: " Andre Muezerie @ 2024-11-08 0:44 ` Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 10/20] net/ixgbe: " Andre Muezerie ` (10 subsequent siblings) 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-08 0:44 UTC (permalink / raw) To: dev; +Cc: Konstantin Ananyev From: Konstantin Ananyev <konstantin.ananyev@huawei.com> ../lib/gro/rte_gro.c:182:34: warning: variable length array used [-Wvla] ../lib/gro/rte_gro.c:363:34: warning: variable length array used [-Wvla] In both cases the pattern is the same: we use unprocess_pkts[nb_pkts] to collect un-used by GRO packets, and then copy them to the start of input/output pkts[] array. In both cases, we can safely copy pkts[i] into already processed entry at the same array, i.e. into pkts[unprocess_num]. Such change eliminates need of temporary VLA: unprocess_pkts[nb_pkts]. Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> Acked-by: Ferruh Yigit <ferruh.yigit@amd.com> --- lib/gro/rte_gro.c | 40 ++++++++++++++-------------------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/lib/gro/rte_gro.c b/lib/gro/rte_gro.c index db86117609..6d5aadf32a 100644 --- a/lib/gro/rte_gro.c +++ b/lib/gro/rte_gro.c @@ -179,7 +179,6 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts, struct gro_vxlan_udp4_item vxlan_udp_items[RTE_GRO_MAX_BURST_ITEM_NUM] = {{{0}} }; - struct rte_mbuf *unprocess_pkts[nb_pkts]; uint32_t item_num; int32_t ret; uint16_t i, unprocess_num = 0, nb_after_gro = nb_pkts; @@ -275,7 +274,7 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts, /* Merge successfully */ nb_after_gro--; else if (ret < 0) - unprocess_pkts[unprocess_num++] = pkts[i]; + pkts[unprocess_num++] = pkts[i]; } else if (IS_IPV4_VXLAN_UDP4_PKT(pkts[i]->packet_type) && do_vxlan_udp_gro) { ret = gro_vxlan_udp4_reassemble(pkts[i], @@ -284,7 +283,7 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts, /* Merge successfully */ nb_after_gro--; else if (ret < 0) - unprocess_pkts[unprocess_num++] = pkts[i]; + pkts[unprocess_num++] = pkts[i]; } else if (IS_IPV4_TCP_PKT(pkts[i]->packet_type) && do_tcp4_gro) { ret = gro_tcp4_reassemble(pkts[i], &tcp_tbl, 0); @@ -292,7 +291,7 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts, /* merge successfully */ nb_after_gro--; else if (ret < 0) - unprocess_pkts[unprocess_num++] = pkts[i]; + pkts[unprocess_num++] = pkts[i]; } else if (IS_IPV4_UDP_PKT(pkts[i]->packet_type) && do_udp4_gro) { ret = gro_udp4_reassemble(pkts[i], &udp_tbl, 0); @@ -300,7 +299,7 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts, /* merge successfully */ nb_after_gro--; else if (ret < 0) - unprocess_pkts[unprocess_num++] = pkts[i]; + pkts[unprocess_num++] = pkts[i]; } else if (IS_IPV6_TCP_PKT(pkts[i]->packet_type) && do_tcp6_gro) { ret = gro_tcp6_reassemble(pkts[i], &tcp6_tbl, 0); @@ -308,21 +307,15 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts, /* merge successfully */ nb_after_gro--; else if (ret < 0) - unprocess_pkts[unprocess_num++] = pkts[i]; + pkts[unprocess_num++] = pkts[i]; } else - unprocess_pkts[unprocess_num++] = pkts[i]; + pkts[unprocess_num++] = pkts[i]; } if ((nb_after_gro < nb_pkts) || (unprocess_num < nb_pkts)) { - i = 0; - /* Copy unprocessed packets */ - if (unprocess_num > 0) { - memcpy(&pkts[i], unprocess_pkts, - sizeof(struct rte_mbuf *) * - unprocess_num); - i = unprocess_num; - } + + i = unprocess_num; /* Flush all packets from the tables */ if (do_vxlan_tcp_gro) { @@ -360,7 +353,6 @@ rte_gro_reassemble(struct rte_mbuf **pkts, uint16_t nb_pkts, void *ctx) { - struct rte_mbuf *unprocess_pkts[nb_pkts]; struct gro_ctx *gro_ctx = ctx; void *tcp_tbl, *udp_tbl, *vxlan_tcp_tbl, *vxlan_udp_tbl, *tcp6_tbl; uint64_t current_time; @@ -396,33 +388,29 @@ rte_gro_reassemble(struct rte_mbuf **pkts, do_vxlan_tcp_gro) { if (gro_vxlan_tcp4_reassemble(pkts[i], vxlan_tcp_tbl, current_time) < 0) - unprocess_pkts[unprocess_num++] = pkts[i]; + pkts[unprocess_num++] = pkts[i]; } else if (IS_IPV4_VXLAN_UDP4_PKT(pkts[i]->packet_type) && do_vxlan_udp_gro) { if (gro_vxlan_udp4_reassemble(pkts[i], vxlan_udp_tbl, current_time) < 0) - unprocess_pkts[unprocess_num++] = pkts[i]; + pkts[unprocess_num++] = pkts[i]; } else if (IS_IPV4_TCP_PKT(pkts[i]->packet_type) && do_tcp4_gro) { if (gro_tcp4_reassemble(pkts[i], tcp_tbl, current_time) < 0) - unprocess_pkts[unprocess_num++] = pkts[i]; + pkts[unprocess_num++] = pkts[i]; } else if (IS_IPV4_UDP_PKT(pkts[i]->packet_type) && do_udp4_gro) { if (gro_udp4_reassemble(pkts[i], udp_tbl, current_time) < 0) - unprocess_pkts[unprocess_num++] = pkts[i]; + pkts[unprocess_num++] = pkts[i]; } else if (IS_IPV6_TCP_PKT(pkts[i]->packet_type) && do_tcp6_gro) { if (gro_tcp6_reassemble(pkts[i], tcp6_tbl, current_time) < 0) - unprocess_pkts[unprocess_num++] = pkts[i]; + pkts[unprocess_num++] = pkts[i]; } else - unprocess_pkts[unprocess_num++] = pkts[i]; - } - if (unprocess_num > 0) { - memcpy(pkts, unprocess_pkts, sizeof(struct rte_mbuf *) * - unprocess_num); + pkts[unprocess_num++] = pkts[i]; } return unprocess_num; -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v5 10/20] net/ixgbe: remove use of VLAs 2024-11-08 0:44 ` [PATCH v5 00/20] " Andre Muezerie ` (8 preceding siblings ...) 2024-11-08 0:44 ` [PATCH v5 09/20] gro: remove use of VLAs Andre Muezerie @ 2024-11-08 0:44 ` Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 11/20] net/ice: " Andre Muezerie ` (9 subsequent siblings) 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-08 0:44 UTC (permalink / raw) To: dev; +Cc: Konstantin Ananyev From: Konstantin Ananyev <konstantin.ananyev@huawei.com> 1) ../drivers/net/ixgbe/ixgbe_ethdev.c:3556:46: warning: variable length array used [-Wvla] 2) ../drivers/net/ixgbe/ixgbe_ethdev.c:3739:23: warning: variable length array used [-Wvla] 3) ../drivers/net/ixgbe/ixgbe_rxtx_vec_common.h:17:24: warning: variable length array used [-Wvla] For first two cases: in fact ixgbe_xstats_calc_num() always returns constant value, so it should be safe to replace that function invocation just with a macro that performs same calculations. For case #3: reassemble_packets() is invoked only by ixgbe_recv_scattered_burst_vec(). And in turn, ixgbe_recv_scattered_burst_vec() operates only on fixed max amount of packets per call: RTE_IXGBE_MAX_RX_BURST. So, it should be safe to replace VLA with fixed size array. Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> --- drivers/net/ixgbe/ixgbe_ethdev.c | 21 +++++++++++++-------- drivers/net/ixgbe/ixgbe_rxtx_vec_common.h | 4 +++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 7da2ccf6a8..fea468140b 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -3435,11 +3435,16 @@ ixgbe_dev_stats_reset(struct rte_eth_dev *dev) } /* This function calculates the number of xstats based on the current config */ + +#define IXGBE_XSTATS_CALC_NUM \ + (IXGBE_NB_HW_STATS + IXGBE_NB_MACSEC_STATS + \ + (IXGBE_NB_RXQ_PRIO_STATS * IXGBE_NB_RXQ_PRIO_VALUES) + \ + (IXGBE_NB_TXQ_PRIO_STATS * IXGBE_NB_TXQ_PRIO_VALUES)) + static unsigned -ixgbe_xstats_calc_num(void) { - return IXGBE_NB_HW_STATS + IXGBE_NB_MACSEC_STATS + - (IXGBE_NB_RXQ_PRIO_STATS * IXGBE_NB_RXQ_PRIO_VALUES) + - (IXGBE_NB_TXQ_PRIO_STATS * IXGBE_NB_TXQ_PRIO_VALUES); +ixgbe_xstats_calc_num(void) +{ + return IXGBE_XSTATS_CALC_NUM; } static int ixgbe_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, @@ -3555,8 +3560,8 @@ static int ixgbe_dev_xstats_get_names_by_id( } uint16_t i; - uint16_t size = ixgbe_xstats_calc_num(); - struct rte_eth_xstat_name xstats_names_copy[size]; + struct rte_eth_xstat_name xstats_names_copy[IXGBE_XSTATS_CALC_NUM]; + const uint16_t size = RTE_DIM(xstats_names_copy); ixgbe_dev_xstats_get_names_by_id(dev, NULL, xstats_names_copy, size); @@ -3738,8 +3743,8 @@ ixgbe_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, } uint16_t i; - uint16_t size = ixgbe_xstats_calc_num(); - uint64_t values_copy[size]; + uint64_t values_copy[IXGBE_XSTATS_CALC_NUM]; + const uint16_t size = RTE_DIM(values_copy); ixgbe_dev_xstats_get_by_id(dev, NULL, values_copy, size); diff --git a/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h b/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h index a4d9ec9b08..c1cf0a581a 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h +++ b/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h @@ -14,11 +14,13 @@ static inline uint16_t reassemble_packets(struct ixgbe_rx_queue *rxq, struct rte_mbuf **rx_bufs, uint16_t nb_bufs, uint8_t *split_flags) { - struct rte_mbuf *pkts[nb_bufs]; /*finished pkts*/ + struct rte_mbuf *pkts[RTE_IXGBE_MAX_RX_BURST]; /*finished pkts*/ struct rte_mbuf *start = rxq->pkt_first_seg; struct rte_mbuf *end = rxq->pkt_last_seg; unsigned int pkt_idx, buf_idx; + RTE_ASSERT(nb_bufs <= RTE_DIM(pkts)); + for (buf_idx = 0, pkt_idx = 0; buf_idx < nb_bufs; buf_idx++) { if (end != NULL) { /* processing a split packet */ -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v5 11/20] net/ice: remove use of VLAs 2024-11-08 0:44 ` [PATCH v5 00/20] " Andre Muezerie ` (9 preceding siblings ...) 2024-11-08 0:44 ` [PATCH v5 10/20] net/ixgbe: " Andre Muezerie @ 2024-11-08 0:44 ` Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 12/20] app/testpmd: remove use of VLAs for Windows built Andre Muezerie ` (8 subsequent siblings) 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-08 0:44 UTC (permalink / raw) To: dev; +Cc: Konstantin Ananyev From: Konstantin Ananyev <konstantin.ananyev@huawei.com> ../drivers/net/ice/ice_rxtx.c:1871:29: warning: variable length array used [-Wvla] Here VLA is used as a temp array for mbufs that will be used as a split RX data buffers. As at any given time only one thread can do RX from particular queue, at rx_queue_setup() we can allocate extra space for that array, and then safely use it at RX fast-path. Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com> --- drivers/net/ice/ice_rxtx.c | 18 ++++++++++++------ drivers/net/ice/ice_rxtx.h | 2 ++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c index 024d97cb46..a52a759031 100644 --- a/drivers/net/ice/ice_rxtx.c +++ b/drivers/net/ice/ice_rxtx.c @@ -1176,7 +1176,7 @@ ice_rx_queue_setup(struct rte_eth_dev *dev, struct ice_vsi *vsi = pf->main_vsi; struct ice_rx_queue *rxq; const struct rte_memzone *rz; - uint32_t ring_size; + uint32_t ring_size, tlen; uint16_t len; int use_def_burst_func = 1; uint64_t offloads; @@ -1284,9 +1284,14 @@ ice_rx_queue_setup(struct rte_eth_dev *dev, /* always reserve more for bulk alloc */ len = (uint16_t)(nb_desc + ICE_RX_MAX_BURST); + /* allocate extra entries for SW split buffer */ + tlen = ((rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) != 0) ? + rxq->rx_free_thresh : 0; + tlen += len; + /* Allocate the software ring. */ rxq->sw_ring = rte_zmalloc_socket(NULL, - sizeof(struct ice_rx_entry) * len, + sizeof(struct ice_rx_entry) * tlen, RTE_CACHE_LINE_SIZE, socket_id); if (!rxq->sw_ring) { @@ -1295,6 +1300,8 @@ ice_rx_queue_setup(struct rte_eth_dev *dev, return -ENOMEM; } + rxq->sw_split_buf = (tlen == len) ? NULL : rxq->sw_ring + len; + ice_reset_rx_queue(rxq); rxq->q_set = true; dev->data->rx_queues[queue_idx] = rxq; @@ -1873,7 +1880,6 @@ ice_rx_alloc_bufs(struct ice_rx_queue *rxq) uint64_t dma_addr; int diag, diag_pay; uint64_t pay_addr; - struct rte_mbuf *mbufs_pay[rxq->rx_free_thresh]; /* Allocate buffers in bulk */ alloc_idx = (uint16_t)(rxq->rx_free_trigger - @@ -1888,7 +1894,7 @@ ice_rx_alloc_bufs(struct ice_rx_queue *rxq) if (rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) { diag_pay = rte_mempool_get_bulk(rxq->rxseg[1].mp, - (void *)mbufs_pay, rxq->rx_free_thresh); + (void *)rxq->sw_split_buf, rxq->rx_free_thresh); if (unlikely(diag_pay != 0)) { PMD_RX_LOG(ERR, "Failed to get payload mbufs in bulk"); return -ENOMEM; @@ -1913,8 +1919,8 @@ ice_rx_alloc_bufs(struct ice_rx_queue *rxq) rxdp[i].read.hdr_addr = 0; rxdp[i].read.pkt_addr = dma_addr; } else { - mb->next = mbufs_pay[i]; - pay_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbufs_pay[i])); + mb->next = rxq->sw_split_buf[i].mbuf; + pay_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(mb->next)); rxdp[i].read.hdr_addr = dma_addr; rxdp[i].read.pkt_addr = pay_addr; } diff --git a/drivers/net/ice/ice_rxtx.h b/drivers/net/ice/ice_rxtx.h index f7276cfc9f..d0f0b6c1d2 100644 --- a/drivers/net/ice/ice_rxtx.h +++ b/drivers/net/ice/ice_rxtx.h @@ -139,6 +139,8 @@ struct ice_rx_queue { uint32_t hw_time_high; /* high 32 bits of timestamp */ uint32_t hw_time_low; /* low 32 bits of timestamp */ uint64_t hw_time_update; /* SW time of HW record updating */ + struct ice_rx_entry *sw_split_buf; + /* address of temp buffer for RX split mbufs */ struct rte_eth_rxseg_split rxseg[ICE_RX_MAX_NSEG]; uint32_t rxseg_nb; bool ts_enable; /* if rxq timestamp is enabled */ -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v5 12/20] app/testpmd: remove use of VLAs for Windows built 2024-11-08 0:44 ` [PATCH v5 00/20] " Andre Muezerie ` (10 preceding siblings ...) 2024-11-08 0:44 ` [PATCH v5 11/20] net/ice: " Andre Muezerie @ 2024-11-08 0:44 ` Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 13/20] test: remove use of VLAs for Windows built code Andre Muezerie ` (7 subsequent siblings) 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-08 0:44 UTC (permalink / raw) To: dev; +Cc: Tyler Retzlaff From: Tyler Retzlaff <roretzla@linux.microsoft.com> MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- app/test-pmd/cmdline.c | 2 +- app/test-pmd/cmdline_flow.c | 15 ++++++++++----- app/test-pmd/config.c | 16 +++++++++------- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 7e0666e9f6..2897e44c34 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -13274,7 +13274,7 @@ cmd_set_port_ptypes_parsed( return; } - uint32_t ptypes[ret]; + uint32_t *ptypes = alloca(sizeof(uint32_t) * ret); ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret); if (ret < 0) { diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 1e4f2ebc55..fb0c4f838d 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -11707,8 +11707,7 @@ parse_hex(struct context *ctx, const struct token *token, char tmp[16]; /* Ought to be enough. */ int ret; unsigned int hexlen = len; - unsigned int length = 256; - uint8_t hex_tmp[length]; + uint8_t hex_tmp[256]; /* Arguments are expected. */ if (!arg_data) @@ -11735,7 +11734,7 @@ parse_hex(struct context *ctx, const struct token *token, str += 2; hexlen -= 2; } - if (hexlen > length) + if (hexlen > RTE_DIM(hex_tmp)) goto error; ret = parse_hex_string(str, hex_tmp, &hexlen); if (ret < 0) @@ -11868,10 +11867,13 @@ parse_ipv4_addr(struct context *ctx, const struct token *token, void *buf, unsigned int size) { const struct arg *arg = pop_args(ctx); - char str2[len + 1]; + char str2[INET_ADDRSTRLEN]; struct in_addr tmp; int ret; + /* Length is longer than the max length an IPv4 address can have. */ + if (len >= INET_ADDRSTRLEN) + return -1; /* Argument is expected. */ if (!arg) return -1; @@ -11914,11 +11916,14 @@ parse_ipv6_addr(struct context *ctx, const struct token *token, void *buf, unsigned int size) { const struct arg *arg = pop_args(ctx); - char str2[len + 1]; + char str2[INET6_ADDRSTRLEN]; struct rte_ipv6_addr tmp; int ret; (void)token; + /* Length is longer than the max length an IPv6 address can have. */ + if (len >= INET6_ADDRSTRLEN) + return -1; /* Argument is expected. */ if (!arg) return -1; diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 88770b4dfc..9ff2b8817f 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1802,7 +1802,8 @@ port_flow_configure(portid_t port_id, { struct rte_port *port; struct rte_flow_error error; - const struct rte_flow_queue_attr *attr_list[nb_queue]; + const struct rte_flow_queue_attr **attr_list = + alloca(sizeof(struct rte_flow_queue_attr *) * nb_queue); int std_queue; if (port_id_is_invalid(port_id, ENABLED_WARN) || @@ -2616,10 +2617,10 @@ port_flow_template_table_create(portid_t port_id, uint32_t id, int ret; uint32_t i; struct rte_flow_error error; - struct rte_flow_pattern_template - *flow_pattern_templates[nb_pattern_templates]; - struct rte_flow_actions_template - *flow_actions_templates[nb_actions_templates]; + struct rte_flow_pattern_template **flow_pattern_templates = + alloca(sizeof(struct rte_flow_pattern_template *) * nb_pattern_templates); + struct rte_flow_actions_template **flow_actions_templates = + alloca(sizeof(struct rte_flow_actions_template *) * nb_actions_templates); if (port_id_is_invalid(port_id, ENABLED_WARN) || port_id == (portid_t)RTE_PORT_ALL) @@ -5529,7 +5530,7 @@ parse_port_list(const char *list, unsigned int *values, unsigned int maxsize) char *end = NULL; int min, max; int value, i; - unsigned int marked[maxsize]; + unsigned int *marked = alloca(sizeof(unsigned int) * maxsize); if (list == NULL || values == NULL) return 0; @@ -7270,7 +7271,8 @@ show_macs(portid_t port_id) if (eth_dev_info_get_print_err(port_id, &dev_info)) return; - struct rte_ether_addr addr[dev_info.max_mac_addrs]; + struct rte_ether_addr *addr = + alloca(sizeof(struct rte_ether_addr) * dev_info.max_mac_addrs); rc = rte_eth_macaddrs_get(port_id, addr, dev_info.max_mac_addrs); if (rc < 0) return; -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v5 13/20] test: remove use of VLAs for Windows built code 2024-11-08 0:44 ` [PATCH v5 00/20] " Andre Muezerie ` (11 preceding siblings ...) 2024-11-08 0:44 ` [PATCH v5 12/20] app/testpmd: remove use of VLAs for Windows built Andre Muezerie @ 2024-11-08 0:44 ` Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 14/20] common/idpf: " Andre Muezerie ` (6 subsequent siblings) 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-08 0:44 UTC (permalink / raw) To: dev; +Cc: Tyler Retzlaff From: Tyler Retzlaff <roretzla@linux.microsoft.com> MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- app/test/test.c | 2 +- app/test/test_cmdline_string.c | 2 +- app/test/test_cryptodev.c | 34 +++++++++---------- app/test/test_cryptodev_blockcipher.c | 4 +-- app/test/test_cryptodev_crosscheck.c | 2 +- app/test/test_dmadev.c | 9 +++-- app/test/test_hash.c | 14 ++++---- app/test/test_mempool.c | 25 +++++++------- app/test/test_reorder.c | 48 +++++++++++++++------------ app/test/test_service_cores.c | 9 +++-- app/test/test_thash.c | 7 ++-- 11 files changed, 82 insertions(+), 74 deletions(-) diff --git a/app/test/test.c b/app/test/test.c index 680351f6a3..fd653cbbfd 100644 --- a/app/test/test.c +++ b/app/test/test.c @@ -105,7 +105,7 @@ int main(int argc, char **argv) { struct cmdline *cl; - char *tests[argc]; /* store an array of tests to run */ + char **tests = alloca(sizeof(char *) * argc); /* store an array of tests to run */ int test_count = 0; int i; char *extra_args; diff --git a/app/test/test_cmdline_string.c b/app/test/test_cmdline_string.c index 97516c9400..e1cf86020f 100644 --- a/app/test/test_cmdline_string.c +++ b/app/test/test_cmdline_string.c @@ -40,7 +40,7 @@ struct string_elt_str string_elt_strs[] = { #if (CMDLINE_TEST_BUFSIZE < STR_TOKEN_SIZE) \ || (CMDLINE_TEST_BUFSIZE < STR_MULTI_TOKEN_SIZE) #undef CMDLINE_TEST_BUFSIZE -#define CMDLINE_TEST_BUFSIZE RTE_MAX(STR_TOKEN_SIZE, STR_MULTI_TOKEN_SIZE) +#define CMDLINE_TEST_BUFSIZE RTE_MAX_T(STR_TOKEN_SIZE, STR_MULTI_TOKEN_SIZE, size_t) #endif struct string_nb_str { diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index 25eef342b0..888a3bfa21 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -2885,7 +2885,7 @@ create_wireless_algo_hash_session(uint8_t dev_id, enum rte_crypto_auth_operation op, enum rte_crypto_auth_algorithm algo) { - uint8_t hash_key[key_len]; + uint8_t *hash_key = alloca(key_len); struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -2921,7 +2921,7 @@ create_wireless_algo_cipher_session(uint8_t dev_id, const uint8_t *key, const uint8_t key_len, uint8_t iv_len) { - uint8_t cipher_key[key_len]; + uint8_t *cipher_key = alloca(key_len); struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -3073,7 +3073,7 @@ create_wireless_cipher_auth_session(uint8_t dev_id, const struct wireless_test_data *tdata) { const uint8_t key_len = tdata->key.len; - uint8_t cipher_auth_key[key_len]; + uint8_t *cipher_auth_key = alloca(key_len); struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -9077,7 +9077,7 @@ create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo, const uint16_t aad_len, const uint8_t auth_len, uint8_t iv_len) { - uint8_t aead_key[key_len]; + uint8_t *aead_key = alloca(key_len); struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -12991,7 +12991,7 @@ test_cryptodev_error_recover_helper(uint8_t dev_id, const void *test_data, bool struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; const struct blockcipher_test_data *tdata = test_data; - uint8_t cipher_key[tdata->cipher_key.len]; + uint8_t *cipher_key = alloca(tdata->cipher_key.len); struct rte_crypto_sym_op *sym_op = NULL; struct rte_crypto_op *op = NULL; char *dst; @@ -13345,7 +13345,7 @@ static int test_AES_GCM_auth_encryption_fail_aad_corrupt(void) { struct aead_test_data tdata; - uint8_t aad[gcm_test_case_7.aad.len]; + uint8_t *aad = alloca(gcm_test_case_7.aad.len); int res; RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n"); @@ -13734,7 +13734,7 @@ static int test_AES_GCM_auth_decryption_fail_aad_corrupt(void) { struct aead_test_data tdata; - uint8_t aad[gcm_test_case_7.aad.len]; + uint8_t *aad = alloca(gcm_test_case_7.aad.len); int res; memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data)); @@ -13986,7 +13986,7 @@ test_authenticated_encryption_sessionless( int retval; uint8_t *ciphertext, *auth_tag; uint16_t plaintext_pad_len; - uint8_t key[tdata->key.len + 1]; + uint8_t *key = alloca(tdata->key.len + 1); struct rte_cryptodev_info dev_info; rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); @@ -14088,7 +14088,7 @@ test_authenticated_decryption_sessionless( int retval; uint8_t *plaintext; - uint8_t key[tdata->key.len + 1]; + uint8_t *key = alloca(tdata->key.len + 1); struct rte_cryptodev_info dev_info; rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); @@ -15473,7 +15473,7 @@ static int create_gmac_session(uint8_t dev_id, const struct gmac_test_data *tdata, enum rte_crypto_auth_operation auth_op) { - uint8_t auth_key[tdata->key.len]; + uint8_t *auth_key = alloca(tdata->key.len); struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -16130,7 +16130,7 @@ create_auth_session(struct crypto_unittest_params *ut_params, enum rte_crypto_auth_operation auth_op) { struct crypto_testsuite_params *ts_params = &testsuite_params; - uint8_t auth_key[reference->auth_key.len + 1]; + uint8_t *auth_key = alloca(reference->auth_key.len + 1); memcpy(auth_key, reference->auth_key.data, reference->auth_key.len); @@ -16161,8 +16161,8 @@ create_auth_cipher_session(struct crypto_unittest_params *ut_params, enum rte_crypto_cipher_operation cipher_op) { struct crypto_testsuite_params *ts_params = &testsuite_params; - uint8_t cipher_key[reference->cipher_key.len + 1]; - uint8_t auth_key[reference->auth_key.len + 1]; + uint8_t *cipher_key = alloca(reference->cipher_key.len + 1); + uint8_t *auth_key = alloca(reference->auth_key.len + 1); memcpy(cipher_key, reference->cipher_key.data, reference->cipher_key.len); @@ -16662,8 +16662,8 @@ test_authenticated_encrypt_with_esn( uint8_t *authciphertext, *plaintext, *auth_tag; uint16_t plaintext_pad_len; - uint8_t cipher_key[reference->cipher_key.len + 1]; - uint8_t auth_key[reference->auth_key.len + 1]; + uint8_t *cipher_key = alloca(reference->cipher_key.len + 1); + uint8_t *auth_key = alloca(reference->auth_key.len + 1); struct rte_cryptodev_info dev_info; rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); @@ -16794,8 +16794,8 @@ test_authenticated_decrypt_with_esn( int retval; uint8_t *ciphertext; - uint8_t cipher_key[reference->cipher_key.len + 1]; - uint8_t auth_key[reference->auth_key.len + 1]; + uint8_t *cipher_key = alloca(reference->cipher_key.len + 1); + uint8_t *auth_key = alloca(reference->auth_key.len + 1); struct rte_cryptodev_info dev_info; rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); diff --git a/app/test/test_cryptodev_blockcipher.c b/app/test/test_cryptodev_blockcipher.c index 8e13cdfc7a..5a124bbb5e 100644 --- a/app/test/test_cryptodev_blockcipher.c +++ b/app/test/test_cryptodev_blockcipher.c @@ -85,8 +85,8 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t, int status = TEST_SUCCESS; const struct blockcipher_test_data *tdata = t->test_data; - uint8_t cipher_key[tdata->cipher_key.len]; - uint8_t auth_key[tdata->auth_key.len]; + uint8_t *cipher_key = alloca(tdata->cipher_key.len); + uint8_t *auth_key = alloca(tdata->auth_key.len); uint32_t buf_len = tdata->ciphertext.len; uint32_t digest_len = tdata->digest.len; char *buf_p = NULL; diff --git a/app/test/test_cryptodev_crosscheck.c b/app/test/test_cryptodev_crosscheck.c index c29b19cf6b..b9a53a430c 100644 --- a/app/test/test_cryptodev_crosscheck.c +++ b/app/test/test_cryptodev_crosscheck.c @@ -894,7 +894,7 @@ static int crosscheck_with_profile_run(const struct crosscheck_test_profile *profile) { struct crosscheck_testsuite_params *ts_params = &testsuite_params; - uint8_t input_text[profile->input_buf_len]; + uint8_t *input_text = alloca(profile->input_buf_len); uint16_t output_len, encrypted_len; uint8_t encrypted_text[MBUF_SIZE]; uint8_t output_text[MBUF_SIZE]; diff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c index 143e1bcd68..9cbb9a6552 100644 --- a/app/test/test_dmadev.c +++ b/app/test/test_dmadev.c @@ -417,9 +417,12 @@ test_enqueue_sg_copies(int16_t dev_id, uint16_t vchan) dst_len = len / n_dst; src_len = len / n_src; - struct rte_dma_sge sg_src[n_sge], sg_dst[n_sge]; - struct rte_mbuf *src[n_sge], *dst[n_sge]; - char *src_data[n_sge], *dst_data[n_sge]; + struct rte_dma_sge *sg_src = alloca(sizeof(struct rte_dma_sge) * n_sge); + struct rte_dma_sge *sg_dst = alloca(sizeof(struct rte_dma_sge) * n_sge); + struct rte_mbuf **src = alloca(sizeof(struct rte_mbuf *) * n_sge); + struct rte_mbuf **dst = alloca(sizeof(struct rte_mbuf *) * n_sge); + char **src_data = alloca(sizeof(char *) * n_sge); + char **dst_data = alloca(sizeof(char *) * n_sge); for (i = 0 ; i < len; i++) orig_src[i] = rte_rand() & 0xFF; diff --git a/app/test/test_hash.c b/app/test/test_hash.c index 65b9cad93c..16e63d2926 100644 --- a/app/test/test_hash.c +++ b/app/test/test_hash.c @@ -1947,6 +1947,8 @@ test_hash_rcu_qsbr_add(void) return 0; } +#define HASH_RCU_QSBR_MAX_TOTAL_ENTRIES 9 + /* * rte_hash_rcu_qsbr_add DQ mode functional test. * Reader and writer are in the same thread in this test. @@ -1966,7 +1968,7 @@ test_hash_rcu_qsbr_add(void) static int test_hash_rcu_qsbr_dq_mode(uint8_t ext_bkt) { - uint32_t total_entries = (ext_bkt == 0) ? 8 : 9; + const uint32_t total_entries = (ext_bkt == 0) ? 8 : HASH_RCU_QSBR_MAX_TOTAL_ENTRIES; uint8_t hash_extra_flag = RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF; @@ -1982,8 +1984,8 @@ test_hash_rcu_qsbr_dq_mode(uint8_t ext_bkt) .socket_id = 0, .extra_flag = hash_extra_flag, }; - int pos[total_entries]; - int expected_pos[total_entries]; + int pos[HASH_RCU_QSBR_MAX_TOTAL_ENTRIES]; + int expected_pos[HASH_RCU_QSBR_MAX_TOTAL_ENTRIES]; unsigned int i; size_t sz; int32_t status; @@ -2136,7 +2138,7 @@ test_hash_rcu_qsbr_reader(void *arg) static int test_hash_rcu_qsbr_sync_mode(uint8_t ext_bkt) { - uint32_t total_entries = (ext_bkt == 0) ? 8 : 9; + const uint32_t total_entries = (ext_bkt == 0) ? 8 : HASH_RCU_QSBR_MAX_TOTAL_ENTRIES; uint8_t hash_extra_flag = RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF; @@ -2152,8 +2154,8 @@ test_hash_rcu_qsbr_sync_mode(uint8_t ext_bkt) .socket_id = 0, .extra_flag = hash_extra_flag, }; - int pos[total_entries]; - int expected_pos[total_entries]; + int pos[HASH_RCU_QSBR_MAX_TOTAL_ENTRIES]; + int expected_pos[HASH_RCU_QSBR_MAX_TOTAL_ENTRIES]; unsigned int i; size_t sz; int32_t status; diff --git a/app/test/test_mempool.c b/app/test/test_mempool.c index 3f7ba5872d..61385e096e 100644 --- a/app/test/test_mempool.c +++ b/app/test/test_mempool.c @@ -515,19 +515,20 @@ test_mempool_events(int (*populate)(struct rte_mempool *mp)) #undef RTE_TEST_TRACE_FAILURE #define RTE_TEST_TRACE_FAILURE(...) do { goto fail; } while (0) - static const size_t callback_num = 3; - static const size_t mempool_num = 2; +#define CALLBACK_NUM 3u +#define MEMPOOL_NUM 2u + static const unsigned int mempool_elt_size = 64; static const unsigned int mempool_size = 64; - struct test_mempool_events_data data[callback_num]; - struct rte_mempool *mp[mempool_num], *freed; + struct test_mempool_events_data data[CALLBACK_NUM]; + struct rte_mempool *mp[MEMPOOL_NUM], *freed; char name[RTE_MEMPOOL_NAMESIZE]; size_t i, j; int ret; memset(mp, 0, sizeof(mp)); - for (i = 0; i < callback_num; i++) { + for (i = 0; i < CALLBACK_NUM; i++) { ret = rte_mempool_event_callback_register (test_mempool_events_cb, &data[i]); RTE_TEST_ASSERT_EQUAL(ret, 0, "Failed to register the callback %zu: %s", @@ -548,7 +549,7 @@ test_mempool_events(int (*populate)(struct rte_mempool *mp)) SOCKET_ID_ANY, 0); RTE_TEST_ASSERT_NOT_NULL(mp[0], "Cannot create mempool %s: %s", name, rte_strerror(rte_errno)); - for (j = 0; j < callback_num; j++) + for (j = 0; j < CALLBACK_NUM; j++) RTE_TEST_ASSERT_EQUAL(data[j].invoked, false, "Callback %zu invoked on %s mempool creation", j, name); @@ -557,7 +558,7 @@ test_mempool_events(int (*populate)(struct rte_mempool *mp)) ret = populate(mp[0]); RTE_TEST_ASSERT_EQUAL(ret, (int)mp[0]->size, "Failed to populate mempool %s: %s", name, rte_strerror(-ret)); - for (j = 0; j < callback_num; j++) { + for (j = 0; j < CALLBACK_NUM; j++) { RTE_TEST_ASSERT_EQUAL(data[j].invoked, true, "Callback %zu not invoked on mempool %s population", j, name); @@ -589,7 +590,7 @@ test_mempool_events(int (*populate)(struct rte_mempool *mp)) "Unregistered callback 0 invoked on %s mempool populaton", name); - for (i = 0; i < mempool_num; i++) { + for (i = 0; i < MEMPOOL_NUM; i++) { memset(&data, 0, sizeof(data)); sprintf(name, "empty%zu", i); rte_mempool_free(mp[i]); @@ -599,7 +600,7 @@ test_mempool_events(int (*populate)(struct rte_mempool *mp)) */ freed = mp[i]; mp[i] = NULL; - for (j = 1; j < callback_num; j++) { + for (j = 1; j < CALLBACK_NUM; j++) { RTE_TEST_ASSERT_EQUAL(data[j].invoked, true, "Callback %zu not invoked on mempool %s destruction", j, name); @@ -615,7 +616,7 @@ test_mempool_events(int (*populate)(struct rte_mempool *mp)) name); } - for (j = 1; j < callback_num; j++) { + for (j = 1; j < CALLBACK_NUM; j++) { ret = rte_mempool_event_callback_unregister (test_mempool_events_cb, &data[j]); RTE_TEST_ASSERT_EQUAL(ret, 0, "Failed to unregister the callback %zu: %s", @@ -624,10 +625,10 @@ test_mempool_events(int (*populate)(struct rte_mempool *mp)) return TEST_SUCCESS; fail: - for (j = 0; j < callback_num; j++) + for (j = 0; j < CALLBACK_NUM; j++) rte_mempool_event_callback_unregister (test_mempool_events_cb, &data[j]); - for (i = 0; i < mempool_num; i++) + for (i = 0; i < MEMPOOL_NUM; i++) rte_mempool_free(mp[i]); return TEST_FAILED; diff --git a/app/test/test_reorder.c b/app/test/test_reorder.c index 501780cb26..aaa2c57086 100644 --- a/app/test/test_reorder.c +++ b/app/test/test_reorder.c @@ -130,11 +130,12 @@ test_reorder_free(void) static int test_reorder_insert(void) { +#define INSERT_NUM_BUFS 7u + struct rte_reorder_buffer *b = NULL; struct rte_mempool *p = test_params->p; const unsigned int size = 4; - const unsigned int num_bufs = 7; - struct rte_mbuf *bufs[num_bufs]; + struct rte_mbuf *bufs[INSERT_NUM_BUFS]; int ret = 0; unsigned i; @@ -146,7 +147,7 @@ test_reorder_insert(void) b = rte_reorder_create("test_insert", rte_socket_id(), size); TEST_ASSERT_NOT_NULL(b, "Failed to create reorder buffer"); - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < INSERT_NUM_BUFS; i++) { bufs[i] = rte_pktmbuf_alloc(p); TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n"); *rte_reorder_seqn(bufs[i]) = i; @@ -207,26 +208,27 @@ test_reorder_insert(void) ret = 0; exit: rte_reorder_free(b); - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < INSERT_NUM_BUFS; i++) rte_pktmbuf_free(bufs[i]); - } + return ret; } static int test_reorder_drain(void) { +#define DRAIN_NUM_BUFS 8u + struct rte_reorder_buffer *b = NULL; struct rte_mempool *p = test_params->p; const unsigned int size = 4; - const unsigned int num_bufs = 8; - struct rte_mbuf *bufs[num_bufs]; - struct rte_mbuf *robufs[num_bufs]; + struct rte_mbuf *bufs[DRAIN_NUM_BUFS]; + struct rte_mbuf *robufs[DRAIN_NUM_BUFS]; int ret = 0; unsigned i, cnt; /* initialize all robufs to NULL */ - for (i = 0; i < num_bufs; i++) + for (i = 0; i < DRAIN_NUM_BUFS; i++) robufs[i] = NULL; /* This would create a reorder buffer instance consisting of: @@ -246,7 +248,7 @@ test_reorder_drain(void) goto exit; } - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < DRAIN_NUM_BUFS; i++) { bufs[i] = rte_pktmbuf_alloc(p); TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n"); *rte_reorder_seqn(bufs[i]) = i; @@ -320,7 +322,7 @@ test_reorder_drain(void) ret = 0; exit: rte_reorder_free(b); - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < DRAIN_NUM_BUFS; i++) { rte_pktmbuf_free(bufs[i]); rte_pktmbuf_free(robufs[i]); } @@ -337,15 +339,16 @@ buffer_to_reorder_move(struct rte_mbuf **mbuf, struct rte_reorder_buffer *b) static int test_reorder_drain_up_to_seqn(void) { +#define DRAIN_TO_NUM_BUFS 10u + struct rte_mempool *p = test_params->p; struct rte_reorder_buffer *b = NULL; - const unsigned int num_bufs = 10; const unsigned int size = 4; unsigned int i, cnt; int ret = 0; - struct rte_mbuf *bufs[num_bufs]; - struct rte_mbuf *robufs[num_bufs]; + struct rte_mbuf *bufs[DRAIN_TO_NUM_BUFS]; + struct rte_mbuf *robufs[DRAIN_TO_NUM_BUFS]; /* initialize all robufs to NULL */ memset(robufs, 0, sizeof(robufs)); @@ -358,7 +361,7 @@ test_reorder_drain_up_to_seqn(void) b = rte_reorder_create("test_drain_up_to_seqn", rte_socket_id(), size); TEST_ASSERT_NOT_NULL(b, "Failed to create reorder buffer"); - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < DRAIN_TO_NUM_BUFS; i++) { bufs[i] = rte_pktmbuf_alloc(p); TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n"); *rte_reorder_seqn(bufs[i]) = i; @@ -372,7 +375,7 @@ test_reorder_drain_up_to_seqn(void) buffer_to_reorder_move(&bufs[2], b); buffer_to_reorder_move(&bufs[3], b); /* Draining 1, 2 */ - cnt = rte_reorder_drain_up_to_seqn(b, robufs, num_bufs, 3); + cnt = rte_reorder_drain_up_to_seqn(b, robufs, DRAIN_TO_NUM_BUFS, 3); if (cnt != 2) { printf("%s:%d:%d: number of expected packets not drained\n", __func__, __LINE__, cnt); @@ -396,7 +399,7 @@ test_reorder_drain_up_to_seqn(void) buffer_to_reorder_move(&bufs[8], b); /* Drain 3 and 5 */ - cnt = rte_reorder_drain_up_to_seqn(b, robufs, num_bufs, 6); + cnt = rte_reorder_drain_up_to_seqn(b, robufs, DRAIN_TO_NUM_BUFS, 6); if (cnt != 2) { printf("%s:%d:%d: number of expected packets not drained\n", __func__, __LINE__, cnt); @@ -410,7 +413,7 @@ test_reorder_drain_up_to_seqn(void) ret = 0; exit: rte_reorder_free(b); - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < DRAIN_TO_NUM_BUFS; i++) { rte_pktmbuf_free(bufs[i]); rte_pktmbuf_free(robufs[i]); } @@ -420,14 +423,15 @@ test_reorder_drain_up_to_seqn(void) static int test_reorder_set_seqn(void) { +#define SET_SEQN_NUM_BUFS 7u + struct rte_mempool *p = test_params->p; struct rte_reorder_buffer *b = NULL; - const unsigned int num_bufs = 7; const unsigned int size = 4; unsigned int i; int ret = 0; - struct rte_mbuf *bufs[num_bufs]; + struct rte_mbuf *bufs[SET_SEQN_NUM_BUFS]; /* This would create a reorder buffer instance consisting of: * reorder_seq = 0 @@ -437,7 +441,7 @@ test_reorder_set_seqn(void) b = rte_reorder_create("test_min_seqn_set", rte_socket_id(), size); TEST_ASSERT_NOT_NULL(b, "Failed to create reorder buffer"); - for (i = 0; i < num_bufs; i++) { + for (i = 0; i < SET_SEQN_NUM_BUFS; i++) { bufs[i] = rte_pktmbuf_alloc(p); if (bufs[i] == NULL) { printf("Packet allocation failed\n"); @@ -479,7 +483,7 @@ test_reorder_set_seqn(void) ret = 0; exit: rte_reorder_free(b); - for (i = 0; i < num_bufs; i++) + for (i = 0; i < SET_SEQN_NUM_BUFS; i++) rte_pktmbuf_free(bufs[i]); return ret; diff --git a/app/test/test_service_cores.c b/app/test/test_service_cores.c index 46ed9a1868..d95a71f80b 100644 --- a/app/test/test_service_cores.c +++ b/app/test/test_service_cores.c @@ -603,9 +603,8 @@ service_lcore_add_del(void) "Service core count not equal to one"); /* retrieve core list, checking lcore ids */ - const uint32_t size = 4; - uint32_t service_core_ids[size]; - int32_t n = rte_service_lcore_list(service_core_ids, size); + uint32_t service_core_ids[4]; + int32_t n = rte_service_lcore_list(service_core_ids, RTE_DIM(service_core_ids)); TEST_ASSERT_EQUAL(1, n, "Service core list return should equal 1"); TEST_ASSERT_EQUAL(slcore_id, service_core_ids[0], "Service core list lcore must equal slcore_id"); @@ -631,7 +630,7 @@ service_lcore_add_del(void) cores_at_this_point); /* check longer service core list */ - n = rte_service_lcore_list(service_core_ids, size); + n = rte_service_lcore_list(service_core_ids, RTE_DIM(service_core_ids)); TEST_ASSERT_EQUAL(3, n, "Service core list return should equal 3"); TEST_ASSERT_EQUAL(slcore_id, service_core_ids[0], "Service core list[0] lcore must equal 1"); @@ -649,7 +648,7 @@ service_lcore_add_del(void) "Service core add did not return zero"); TEST_ASSERT_EQUAL(1, rte_service_lcore_count(), "Service core count not equal to one"); - n = rte_service_lcore_list(service_core_ids, size); + n = rte_service_lcore_list(service_core_ids, RTE_DIM(service_core_ids)); TEST_ASSERT_EQUAL(1, n, "Service core list return should equal one"); TEST_ASSERT_EQUAL(slcore_id, service_core_ids[0], "Service core list[0] lcore must equal %d", diff --git a/app/test/test_thash.c b/app/test/test_thash.c index 0ad6943cf8..d2f0c252ca 100644 --- a/app/test/test_thash.c +++ b/app/test/test_thash.c @@ -564,9 +564,8 @@ test_predictable_rss_min_seq(void) { struct rte_thash_ctx *ctx; struct rte_thash_subtuple_helper *h; - const int key_len = 40; int reta_sz = 6; - uint8_t initial_key[key_len]; + uint8_t initial_key[40]; const uint8_t *new_key; int ret; union rte_thash_tuple tuple; @@ -574,9 +573,9 @@ test_predictable_rss_min_seq(void) unsigned int desired_value = 27 & HASH_MSK(reta_sz); uint16_t port_value = 22; - memset(initial_key, 0, key_len); + memset(initial_key, 0, RTE_DIM(initial_key)); - ctx = rte_thash_init_ctx("test", key_len, reta_sz, initial_key, + ctx = rte_thash_init_ctx("test", RTE_DIM(initial_key), reta_sz, initial_key, RTE_THASH_MINIMAL_SEQ); RTE_TEST_ASSERT(ctx != NULL, "can not create thash ctx\n"); -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v5 14/20] common/idpf: remove use of VLAs for Windows built code 2024-11-08 0:44 ` [PATCH v5 00/20] " Andre Muezerie ` (12 preceding siblings ...) 2024-11-08 0:44 ` [PATCH v5 13/20] test: remove use of VLAs for Windows built code Andre Muezerie @ 2024-11-08 0:44 ` Andre Muezerie 2024-11-08 8:47 ` Bruce Richardson 2024-11-08 0:44 ` [PATCH v5 15/20] net/i40e: " Andre Muezerie ` (5 subsequent siblings) 19 siblings, 1 reply; 127+ messages in thread From: Andre Muezerie @ 2024-11-08 0:44 UTC (permalink / raw) To: dev; +Cc: Tyler Retzlaff From: Tyler Retzlaff <roretzla@linux.microsoft.com> MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- drivers/common/idpf/idpf_common_rxtx.c | 2 +- drivers/common/idpf/idpf_common_rxtx_avx512.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/common/idpf/idpf_common_rxtx.c b/drivers/common/idpf/idpf_common_rxtx.c index a04e54ce26..e04ab40fa2 100644 --- a/drivers/common/idpf/idpf_common_rxtx.c +++ b/drivers/common/idpf/idpf_common_rxtx.c @@ -569,7 +569,7 @@ idpf_split_rx_bufq_refill(struct idpf_rx_queue *rx_bufq) uint16_t nb_refill = rx_bufq->rx_free_thresh; uint16_t nb_desc = rx_bufq->nb_rx_desc; uint16_t next_avail = rx_bufq->rx_tail; - struct rte_mbuf *nmb[rx_bufq->rx_free_thresh]; + struct rte_mbuf **nmb = alloca(sizeof(struct rte_mbuf *) * rx_bufq->rx_free_thresh); uint64_t dma_addr; uint16_t delta; int i; diff --git a/drivers/common/idpf/idpf_common_rxtx_avx512.c b/drivers/common/idpf/idpf_common_rxtx_avx512.c index b8450b03ae..63e10c542f 100644 --- a/drivers/common/idpf/idpf_common_rxtx_avx512.c +++ b/drivers/common/idpf/idpf_common_rxtx_avx512.c @@ -1002,7 +1002,8 @@ idpf_tx_singleq_free_bufs_avx512(struct idpf_tx_queue *txq) uint32_t n; uint32_t i; int nb_free = 0; - struct rte_mbuf *m, *free[txq->rs_thresh]; + struct rte_mbuf *m; + struct rte_mbuf **free = alloca(sizeof(struct rte_mbuf *) * txq->rs_thresh); /* check DD bits on threshold descriptor */ if ((txq->tx_ring[txq->next_dd].qw1 & @@ -1326,7 +1327,8 @@ idpf_tx_splitq_free_bufs_avx512(struct idpf_tx_queue *txq) uint32_t n; uint32_t i; int nb_free = 0; - struct rte_mbuf *m, *free[txq->rs_thresh]; + struct rte_mbuf *m; + struct rte_mbuf **free = alloca(sizeof(struct rte_mbuf *) * txq->rs_thresh); n = txq->rs_thresh; -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* Re: [PATCH v5 14/20] common/idpf: remove use of VLAs for Windows built code 2024-11-08 0:44 ` [PATCH v5 14/20] common/idpf: " Andre Muezerie @ 2024-11-08 8:47 ` Bruce Richardson 0 siblings, 0 replies; 127+ messages in thread From: Bruce Richardson @ 2024-11-08 8:47 UTC (permalink / raw) To: Andre Muezerie; +Cc: dev, Tyler Retzlaff On Thu, Nov 07, 2024 at 04:44:45PM -0800, Andre Muezerie wrote: > From: Tyler Retzlaff <roretzla@linux.microsoft.com> > > MSVC does not support VLAs, replace VLAs with standard C arrays > or alloca(). alloca() is available for all toolchain/platform > combinations officially supported by DPDK. > > Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> Acked-by: Bruce Richardson <bruce.richardson@intel.com> ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v5 15/20] net/i40e: remove use of VLAs for Windows built code 2024-11-08 0:44 ` [PATCH v5 00/20] " Andre Muezerie ` (13 preceding siblings ...) 2024-11-08 0:44 ` [PATCH v5 14/20] common/idpf: " Andre Muezerie @ 2024-11-08 0:44 ` Andre Muezerie 2024-11-08 8:45 ` Bruce Richardson 2024-11-08 0:44 ` [PATCH v5 16/20] common/mlx5: " Andre Muezerie ` (4 subsequent siblings) 19 siblings, 1 reply; 127+ messages in thread From: Andre Muezerie @ 2024-11-08 0:44 UTC (permalink / raw) To: dev; +Cc: Tyler Retzlaff From: Tyler Retzlaff <roretzla@linux.microsoft.com> MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- drivers/net/i40e/i40e_testpmd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/i40e/i40e_testpmd.c b/drivers/net/i40e/i40e_testpmd.c index b6ef5d6e42..21f596297b 100644 --- a/drivers/net/i40e/i40e_testpmd.c +++ b/drivers/net/i40e/i40e_testpmd.c @@ -2168,8 +2168,7 @@ cmd_ptype_mapping_get_parsed(void *parsed_result, { struct cmd_ptype_mapping_get_result *res = parsed_result; int ret = -ENOTSUP; - int max_ptype_num = 256; - struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num]; + struct rte_pmd_i40e_ptype_mapping mapping[256]; uint16_t count; int i; @@ -2178,7 +2177,7 @@ cmd_ptype_mapping_get_parsed(void *parsed_result, ret = rte_pmd_i40e_ptype_mapping_get(res->port_id, mapping, - max_ptype_num, + RTE_DIM(mapping), &count, res->valid_only); switch (ret) { -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* Re: [PATCH v5 15/20] net/i40e: remove use of VLAs for Windows built code 2024-11-08 0:44 ` [PATCH v5 15/20] net/i40e: " Andre Muezerie @ 2024-11-08 8:45 ` Bruce Richardson 0 siblings, 0 replies; 127+ messages in thread From: Bruce Richardson @ 2024-11-08 8:45 UTC (permalink / raw) To: Andre Muezerie; +Cc: dev, Tyler Retzlaff On Thu, Nov 07, 2024 at 04:44:46PM -0800, Andre Muezerie wrote: > From: Tyler Retzlaff <roretzla@linux.microsoft.com> > > MSVC does not support VLAs, replace VLAs with standard C arrays > or alloca(). alloca() is available for all toolchain/platform > combinations officially supported by DPDK. > > Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> Reviewed-by: Bruce Richardson <bruce.richardson@intel.com> > --- > drivers/net/i40e/i40e_testpmd.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/i40e/i40e_testpmd.c b/drivers/net/i40e/i40e_testpmd.c > index b6ef5d6e42..21f596297b 100644 > --- a/drivers/net/i40e/i40e_testpmd.c > +++ b/drivers/net/i40e/i40e_testpmd.c > @@ -2168,8 +2168,7 @@ cmd_ptype_mapping_get_parsed(void *parsed_result, > { > struct cmd_ptype_mapping_get_result *res = parsed_result; > int ret = -ENOTSUP; > - int max_ptype_num = 256; > - struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num]; > + struct rte_pmd_i40e_ptype_mapping mapping[256]; > uint16_t count; > int i; > > @@ -2178,7 +2177,7 @@ cmd_ptype_mapping_get_parsed(void *parsed_result, > > ret = rte_pmd_i40e_ptype_mapping_get(res->port_id, > mapping, > - max_ptype_num, > + RTE_DIM(mapping), > &count, > res->valid_only); > switch (ret) { > -- > 2.34.1 > ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v5 16/20] common/mlx5: remove use of VLAs for Windows built code 2024-11-08 0:44 ` [PATCH v5 00/20] " Andre Muezerie ` (14 preceding siblings ...) 2024-11-08 0:44 ` [PATCH v5 15/20] net/i40e: " Andre Muezerie @ 2024-11-08 0:44 ` Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 17/20] net/mlx5: " Andre Muezerie ` (3 subsequent siblings) 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-08 0:44 UTC (permalink / raw) To: dev; +Cc: Tyler Retzlaff From: Tyler Retzlaff <roretzla@linux.microsoft.com> MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- drivers/common/mlx5/mlx5_common.h | 4 ++-- drivers/common/mlx5/mlx5_devx_cmds.c | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h index 1abd1e8239..f29f06a86e 100644 --- a/drivers/common/mlx5/mlx5_common.h +++ b/drivers/common/mlx5/mlx5_common.h @@ -125,10 +125,10 @@ mlx5_fp_debug_enabled(void) /* Allocate a buffer on the stack and fill it with a printf format string. */ #define MKSTR(name, ...) \ int mkstr_size_##name = snprintf(NULL, 0, "" __VA_ARGS__); \ - char name[mkstr_size_##name + 1]; \ + char *name = alloca(mkstr_size_##name + 1); \ \ memset(name, 0, mkstr_size_##name + 1); \ - snprintf(name, sizeof(name), "" __VA_ARGS__) + snprintf(name, mkstr_size_##name + 1, "" __VA_ARGS__) enum { PCI_VENDOR_ID_MELLANOX = 0x15b3, diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c index 9710dcedd3..fbe528a9ea 100644 --- a/drivers/common/mlx5/mlx5_devx_cmds.c +++ b/drivers/common/mlx5/mlx5_devx_cmds.c @@ -284,10 +284,9 @@ mlx5_devx_cmd_flow_counter_query(struct mlx5_devx_obj *dcs, void *cmd_comp, uint64_t async_id) { - int out_len = MLX5_ST_SZ_BYTES(query_flow_counter_out) + - MLX5_ST_SZ_BYTES(traffic_counter); - uint32_t out[out_len]; + uint32_t out[MLX5_ST_SZ_BYTES(query_flow_counter_out) + MLX5_ST_SZ_BYTES(traffic_counter)]; uint32_t in[MLX5_ST_SZ_DW(query_flow_counter_in)] = {0}; + const int out_len = RTE_DIM(out); void *stats; int rc; @@ -346,7 +345,7 @@ mlx5_devx_cmd_mkey_create(void *ctx, int klm_num = attr->klm_num; int in_size_dw = MLX5_ST_SZ_DW(create_mkey_in) + (klm_num ? RTE_ALIGN(klm_num, 4) : 0) * MLX5_ST_SZ_DW(klm); - uint32_t in[in_size_dw]; + uint32_t *in = alloca(sizeof(uint32_t) * in_size_dw); uint32_t out[MLX5_ST_SZ_DW(create_mkey_out)] = {0}; void *mkc; struct mlx5_devx_obj *mkey = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*mkey), -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v5 17/20] net/mlx5: remove use of VLAs for Windows built code 2024-11-08 0:44 ` [PATCH v5 00/20] " Andre Muezerie ` (15 preceding siblings ...) 2024-11-08 0:44 ` [PATCH v5 16/20] common/mlx5: " Andre Muezerie @ 2024-11-08 0:44 ` Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 18/20] build: enable vla warnings on " Andre Muezerie ` (2 subsequent siblings) 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-08 0:44 UTC (permalink / raw) To: dev; +Cc: Tyler Retzlaff From: Tyler Retzlaff <roretzla@linux.microsoft.com> MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- drivers/net/mlx5/mlx5.c | 5 ++--- drivers/net/mlx5/mlx5_flow.c | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 52b90e6ff3..ab6fe6d753 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1598,14 +1598,13 @@ void mlx5_rt_timestamp_config(struct mlx5_dev_ctx_shared *sh, struct mlx5_hca_attr *hca_attr) { - uint32_t dw_cnt = MLX5_ST_SZ_DW(register_mtutc); - uint32_t reg[dw_cnt]; + uint32_t reg[MLX5_ST_SZ_DW(register_mtutc)]; int ret = ENOTSUP; if (hca_attr->access_register_user) ret = mlx5_devx_cmd_register_read(sh->cdev->ctx, MLX5_REGISTER_ID_MTUTC, 0, - reg, dw_cnt); + reg, RTE_DIM(reg)); if (!ret) { uint32_t ts_mode; diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 7f8640b488..eca08a2111 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -1479,8 +1479,8 @@ mlx5_flow_item_acceptable(const struct rte_eth_dev *dev, "mask/last without a spec is not" " supported"); if (item->spec && item->last && !range_accepted) { - uint8_t spec[size]; - uint8_t last[size]; + uint8_t *spec = alloca(size); + uint8_t *last = alloca(size); unsigned int i; int ret; @@ -8474,7 +8474,7 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, .type = RTE_FLOW_ITEM_TYPE_END, }, }; - uint16_t queue[priv->reta_idx_n]; + uint16_t *queue = alloca(sizeof(uint16_t) * priv->reta_idx_n); struct rte_flow_action_rss action_rss = { .func = RTE_ETH_HASH_FUNCTION_DEFAULT, .level = 0, -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v5 18/20] build: enable vla warnings on Windows built code 2024-11-08 0:44 ` [PATCH v5 00/20] " Andre Muezerie ` (16 preceding siblings ...) 2024-11-08 0:44 ` [PATCH v5 17/20] net/mlx5: " Andre Muezerie @ 2024-11-08 0:44 ` Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 19/20] test: remove use of VLAs for Windows built code in bitset tests Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 20/20] app/testpmd: remove use of VLAs for Windows built code in shared_rxq_fwd Andre Muezerie 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-08 0:44 UTC (permalink / raw) To: dev; +Cc: Tyler Retzlaff From: Tyler Retzlaff <roretzla@linux.microsoft.com> MSVC does not support optional C11 VLAs. When building for Windows enable -Wvla so that mingw and clang also fail if a VLA is used. Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com> --- config/meson.build | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/meson.build b/config/meson.build index 5095d2fbcb..9a3ce5eaa9 100644 --- a/config/meson.build +++ b/config/meson.build @@ -339,6 +339,10 @@ if cc.get_id() == 'intel' warning_flags += '-diag-disable=@0@'.format(i) endforeach endif +# no VLAs in code built on Windows +if is_windows + warning_flags += '-Wvla' +endif foreach arg: warning_flags if cc.has_argument(arg) add_project_arguments(arg, language: 'c') -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v5 19/20] test: remove use of VLAs for Windows built code in bitset tests 2024-11-08 0:44 ` [PATCH v5 00/20] " Andre Muezerie ` (17 preceding siblings ...) 2024-11-08 0:44 ` [PATCH v5 18/20] build: enable vla warnings on " Andre Muezerie @ 2024-11-08 0:44 ` Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 20/20] app/testpmd: remove use of VLAs for Windows built code in shared_rxq_fwd Andre Muezerie 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-08 0:44 UTC (permalink / raw) To: dev; +Cc: Andre Muezerie 1) MSVC does not support VLAs. Use standard fixed C arrays of maximum size required instead. 2) ../usr/lib/gcc/x86_64-redhat-linux/13/include/emmintrin.h:742:8: error: array subscript 9 is outside array bounds of 'uint64_t[16]' {aka 'long unsigned int[16]'} [-Werror=array-bounds=] 3695 742 | *__P = __B; Compile with -Wno-array-bounds to avoid false positives when using gcc version 11 or newer (gcc compiler bug/limitation). Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> --- app/test/meson.build | 5 +++ app/test/test_bitset.c | 55 +++++++++++++++++++-------------- app/test/test_reassembly_perf.c | 4 +-- 3 files changed, 38 insertions(+), 26 deletions(-) diff --git a/app/test/meson.build b/app/test/meson.build index 0f7e11969a..7dedcddb1d 100644 --- a/app/test/meson.build +++ b/app/test/meson.build @@ -247,6 +247,11 @@ foreach d:optional_deps endif endforeach +# Bugzilla ID: 678 +if (toolchain == 'gcc' and cc.version().version_compare('>=11.0.0')) + cflags += '-Wno-array-bounds' +endif + if cc.has_argument('-Wno-format-truncation') cflags += '-Wno-format-truncation' endif diff --git a/app/test/test_bitset.c b/app/test/test_bitset.c index 50b8bf0da4..f58c491d8f 100644 --- a/app/test/test_bitset.c +++ b/app/test/test_bitset.c @@ -99,11 +99,13 @@ typedef void clear_fun(uint64_t *bitset, size_t bit_num); typedef void assign_fun(uint64_t *bitset, size_t bit_num, bool value); typedef void flip_fun(uint64_t *bitset, size_t bit_num); +#define RAND_SET_MAX_SIZE (1000) + static int test_set_clear_size(test_fun test_fun, set_fun set_fun, clear_fun clear_fun, size_t size) { size_t i; - bool reference[size]; + bool reference[RAND_SET_MAX_SIZE]; uint64_t *bitset; rand_bool_ary(reference, size); @@ -132,7 +134,6 @@ test_set_clear_size(test_fun test_fun, set_fun set_fun, clear_fun clear_fun, siz } #define RAND_ITERATIONS (10000) -#define RAND_SET_MAX_SIZE (1000) static int test_set_clear_fun(test_fun test_fun, set_fun set_fun, clear_fun clear_fun) @@ -168,7 +169,7 @@ test_flip_size(test_fun test_fun, assign_fun assign_fun, flip_fun flip_fun, size rand_bitset(bitset, size); for (i = 0; i < size; i++) { - RTE_BITSET_DECLARE(reference, size); + RTE_BITSET_DECLARE(reference, RAND_SET_MAX_SIZE); rte_bitset_copy(reference, bitset, size); @@ -288,7 +289,7 @@ static int test_find_size(size_t size, bool set) { uint64_t *bitset; - bool reference[size]; + bool reference[RAND_SET_MAX_SIZE]; size_t i; bitset = alloc_bitset(size); @@ -388,8 +389,8 @@ record_match(ssize_t match_idx, size_t size, int *calls) static int test_foreach_size(ssize_t size, bool may_wrap, bool set) { - bool reference[size]; - int calls[size]; + bool reference[RAND_SET_MAX_SIZE]; + int calls[RAND_SET_MAX_SIZE]; uint64_t *bitset; ssize_t i; ssize_t start_bit; @@ -633,17 +634,19 @@ test_define(void) typedef void bitset_op(uint64_t *dst, const uint64_t *a, const uint64_t *b, size_t bit_num); typedef bool bool_op(bool a, bool b); +#define LOGIC_MAX_SET_SIZE 200 + static int test_logic_op(bitset_op bitset_op, bool_op bool_op) { - const size_t size = 1 + rte_rand_max(200); - RTE_BITSET_DECLARE(bitset_a, size); - RTE_BITSET_DECLARE(bitset_b, size); - RTE_BITSET_DECLARE(bitset_d, size); + const size_t size = 1 + rte_rand_max(LOGIC_MAX_SET_SIZE); + RTE_BITSET_DECLARE(bitset_a, LOGIC_MAX_SET_SIZE); + RTE_BITSET_DECLARE(bitset_b, LOGIC_MAX_SET_SIZE); + RTE_BITSET_DECLARE(bitset_d, LOGIC_MAX_SET_SIZE); - bool ary_a[size]; - bool ary_b[size]; - bool ary_d[size]; + bool ary_a[LOGIC_MAX_SET_SIZE]; + bool ary_b[LOGIC_MAX_SET_SIZE]; + bool ary_d[LOGIC_MAX_SET_SIZE]; rand_bool_ary(ary_a, size); rand_bool_ary(ary_b, size); @@ -708,14 +711,14 @@ test_complement(void) for (i = 0; i < RAND_ITERATIONS; i++) { const size_t size = 1 + rte_rand_max(RAND_SET_MAX_SIZE - 1); - RTE_BITSET_DECLARE(src, size); + RTE_BITSET_DECLARE(src, RAND_SET_MAX_SIZE); rand_bitset(src, size); bool bit_idx = rte_rand_max(size); bool bit_value = rte_bitset_test(src, bit_idx); - RTE_BITSET_DECLARE(dst, size); + RTE_BITSET_DECLARE(dst, RAND_SET_MAX_SIZE); rte_bitset_complement(dst, src, size); @@ -726,6 +729,8 @@ test_complement(void) return TEST_SUCCESS; } +#define SHIFT_SET_MAX_SIZE 500 + static int test_shift(bool right) { @@ -734,12 +739,12 @@ test_shift(bool right) const char *direction = right ? "right" : "left"; for (i = 0; i < 10000; i++) { - const int size = 1 + (int)rte_rand_max(500); + const int size = 1 + (int)rte_rand_max(SHIFT_SET_MAX_SIZE); const int shift_count = (int)rte_rand_max(1.5 * size); int src_idx; - RTE_BITSET_DECLARE(src, size); - RTE_BITSET_DECLARE(reference, size); + RTE_BITSET_DECLARE(src, SHIFT_SET_MAX_SIZE); + RTE_BITSET_DECLARE(reference, SHIFT_SET_MAX_SIZE); rte_bitset_init(src, size); rte_bitset_init(reference, size); @@ -788,12 +793,14 @@ test_shift_left(void) return test_shift(false); } +#define EQUAL_SET_MAX_SIZE 100 + static int test_equal(void) { - const size_t size = 100; - RTE_BITSET_DECLARE(bitset_a, size); - RTE_BITSET_DECLARE(bitset_b, size); + const size_t size = EQUAL_SET_MAX_SIZE; + RTE_BITSET_DECLARE(bitset_a, EQUAL_SET_MAX_SIZE); + RTE_BITSET_DECLARE(bitset_b, EQUAL_SET_MAX_SIZE); rand_buf(bitset_a, RTE_BITSET_SIZE(size)); rand_buf(bitset_b, RTE_BITSET_SIZE(size)); @@ -821,9 +828,9 @@ test_equal(void) static int test_copy(void) { - const size_t size = 100; - RTE_BITSET_DECLARE(bitset_a, size); - RTE_BITSET_DECLARE(bitset_b, size); + const size_t size = EQUAL_SET_MAX_SIZE; + RTE_BITSET_DECLARE(bitset_a, EQUAL_SET_MAX_SIZE); + RTE_BITSET_DECLARE(bitset_b, EQUAL_SET_MAX_SIZE); rand_buf(bitset_a, RTE_BITSET_SIZE(size)); rand_buf(bitset_b, RTE_BITSET_SIZE(size)); diff --git a/app/test/test_reassembly_perf.c b/app/test/test_reassembly_perf.c index 69cf029468..ac225e2b53 100644 --- a/app/test/test_reassembly_perf.c +++ b/app/test/test_reassembly_perf.c @@ -577,7 +577,7 @@ ipv4_reassembly_interleaved_flows_perf(uint8_t nb_frags) for (j = 0; j < 4; j++) nb_frags += frag_per_flow[i + j]; - struct rte_mbuf *buf_arr[nb_frags]; + struct rte_mbuf *buf_arr[MAX_FRAGMENTS]; for (j = 0; j < 4; j++) { join_array(buf_arr, mbufs[i + j], prev, frag_per_flow[i + j]); @@ -788,7 +788,7 @@ ipv6_reassembly_interleaved_flows_perf(int8_t nb_frags) for (j = 0; j < 4; j++) nb_frags += frag_per_flow[i + j]; - struct rte_mbuf *buf_arr[nb_frags]; + struct rte_mbuf *buf_arr[MAX_FRAGMENTS]; for (j = 0; j < 4; j++) { join_array(buf_arr, mbufs[i + j], prev, frag_per_flow[i + j]); -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
* [PATCH v5 20/20] app/testpmd: remove use of VLAs for Windows built code in shared_rxq_fwd 2024-11-08 0:44 ` [PATCH v5 00/20] " Andre Muezerie ` (18 preceding siblings ...) 2024-11-08 0:44 ` [PATCH v5 19/20] test: remove use of VLAs for Windows built code in bitset tests Andre Muezerie @ 2024-11-08 0:44 ` Andre Muezerie 19 siblings, 0 replies; 127+ messages in thread From: Andre Muezerie @ 2024-11-08 0:44 UTC (permalink / raw) To: dev; +Cc: Andre Muezerie MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> --- app/test-pmd/shared_rxq_fwd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/test-pmd/shared_rxq_fwd.c b/app/test-pmd/shared_rxq_fwd.c index 623d62da88..b85830b90e 100644 --- a/app/test-pmd/shared_rxq_fwd.c +++ b/app/test-pmd/shared_rxq_fwd.c @@ -92,7 +92,7 @@ forward_shared_rxq(struct fwd_stream *fs, uint16_t nb_rx, static bool shared_rxq_fwd(struct fwd_stream *fs) { - struct rte_mbuf *pkts_burst[nb_pkt_per_burst]; + struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; uint16_t nb_rx; nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst); -- 2.34.1 ^ permalink raw reply [flat|nested] 127+ messages in thread
end of thread, other threads:[~2024-11-08 13:44 UTC | newest] Thread overview: 127+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2024-04-17 23:41 [PATCH 00/16] remove use of VLAs for Windows built code Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 01/16] eal: include header required for alloca Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 02/16] hash: remove use of VLAs for Windows built code Tyler Retzlaff 2024-04-18 6:45 ` Morten Brørup 2024-04-17 23:41 ` [PATCH 03/16] ethdev: " Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 04/16] gro: " Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 05/16] latencystats: " Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 06/16] lpm: " Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 07/16] rcu: " Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 08/16] app/testpmd: " Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 09/16] test: " Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 10/16] common/idpf: " Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 11/16] net/i40e: " Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 12/16] net/ice: " Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 13/16] net/ixgbe: " Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 14/16] common/mlx5: " Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 15/16] net/mlx5: " Tyler Retzlaff 2024-04-17 23:41 ` [PATCH 16/16] build: enable vla warnings on " Tyler Retzlaff 2024-04-18 6:48 ` Morten Brørup 2024-04-18 15:12 ` Tyler Retzlaff 2024-04-18 15:23 ` Bruce Richardson 2024-04-18 19:22 ` Morten Brørup 2024-04-18 6:49 ` [PATCH 00/16] remove use of VLAs for " Morten Brørup 2024-04-18 12:11 ` Konstantin Ananyev 2024-04-18 15:15 ` Tyler Retzlaff 2024-04-18 15:35 ` Konstantin Ananyev 2024-04-18 20:02 ` [PATCH v2 00/19] remove use of VLAs for Windows Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 01/19] eal: include header required for alloca Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 02/19] eal/linux: remove use of VLAs Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 03/19] eal/common: " Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 04/19] ethdev: remove use of VLAs for Windows built code Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 05/19] hash: " Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 06/19] hash/thash: " Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 07/19] rcu: " Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 08/19] gro: " Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 09/19] latencystats: " Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 10/19] lpm: " Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 11/19] app/testpmd: " Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 12/19] test: " Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 13/19] common/idpf: " Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 14/19] net/i40e: " Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 15/19] net/ice: " Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 16/19] net/ixgbe: " Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 17/19] common/mlx5: " Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 18/19] net/mlx5: " Tyler Retzlaff 2024-04-18 20:02 ` [PATCH v2 19/19] build: enable vla warnings on " Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 00/19] remove use of VLAs for Windows Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 01/19] eal: include header required for alloca Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 02/19] eal/linux: remove use of VLAs Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 03/19] eal/common: " Tyler Retzlaff 2024-05-07 0:42 ` Stephen Hemminger 2024-05-06 18:18 ` [PATCH v3 04/19] ethdev: remove use of VLAs for Windows built code Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 05/19] hash: " Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 06/19] hash/thash: " Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 07/19] rcu: " Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 08/19] gro: " Tyler Retzlaff 2024-05-07 0:47 ` Stephen Hemminger 2024-05-06 18:18 ` [PATCH v3 09/19] latencystats: " Tyler Retzlaff 2024-05-07 0:47 ` Stephen Hemminger 2024-05-06 18:18 ` [PATCH v3 10/19] lpm: " Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 11/19] app/testpmd: " Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 12/19] test: " Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 13/19] common/idpf: " Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 14/19] net/i40e: " Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 15/19] net/ice: " Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 16/19] net/ixgbe: " Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 17/19] common/mlx5: " Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 18/19] net/mlx5: " Tyler Retzlaff 2024-05-06 18:18 ` [PATCH v3 19/19] build: enable vla warnings on " Tyler Retzlaff 2024-05-07 2:53 ` [PATCH 1/2] lpm: remove unnecessary temporary VLA Stephen Hemminger 2024-05-07 2:53 ` [PATCH 2/2] latencystats: replace use of VLA Stephen Hemminger 2024-07-09 8:06 ` David Marchand 2024-05-07 7:51 ` [PATCH 1/2] lpm: remove unnecessary temporary VLA Bruce Richardson 2024-07-09 8:26 ` [PATCH v3 00/19] remove use of VLAs for Windows David Marchand 2024-10-07 17:15 ` [PATCH 00/16] remove use of VLAs for Windows built code Stephen Hemminger 2024-11-01 18:06 ` Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 00/19] remove use of VLAs for Windows Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 01/19] eal: include header required for alloca Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 02/19] eal/linux: remove use of VLAs Andre Muezerie 2024-11-05 8:19 ` David Marchand 2024-11-06 2:02 ` Andre Muezerie 2024-11-08 13:44 ` Konstantin Ananyev 2024-11-05 3:15 ` [PATCH v4 03/19] eal/common: " Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 04/19] ethdev: remove use of VLAs for Windows built code Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 05/19] hash: " Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 06/19] hash/thash: remove use of VLAs for Windows built Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 07/19] rcu: remove use of VLAs for Windows built code Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 08/19] gro: " Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 09/19] app/testpmd: remove use of VLAs for Windows built Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 10/19] test: remove use of VLAs for Windows built code Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 11/19] common/idpf: " Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 12/19] net/i40e: " Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 13/19] net/ice: " Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 14/19] net/ixgbe: " Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 15/19] common/mlx5: " Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 16/19] net/mlx5: " Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 17/19] build: enable vla warnings on " Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 18/19] test: remove use of VLAs for Windows built code in bitset tests Andre Muezerie 2024-11-05 8:32 ` David Marchand 2024-11-06 2:06 ` Andre Muezerie 2024-11-05 3:15 ` [PATCH v4 19/19] app/testpmd: remove use of VLAs for Windows built code in shared_rxq_fwd Andre Muezerie 2024-11-05 9:37 ` [PATCH v4 00/19] remove use of VLAs for Windows Konstantin Ananyev 2024-11-08 0:44 ` [PATCH v5 00/20] " Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 01/20] eal: include header required for alloca Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 02/20] eal/linux: remove use of VLAs Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 03/20] eal/common: " Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 04/20] ethdev: remove use of VLAs for Windows built code Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 05/20] hash: " Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 06/20] hash/thash: remove use of VLAs for Windows built Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 07/20] rcu: remove use of VLAs for Windows built code Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 08/20] net/ice: " Andre Muezerie 2024-11-08 8:51 ` Bruce Richardson 2024-11-08 10:18 ` Konstantin Ananyev 2024-11-08 0:44 ` [PATCH v5 09/20] gro: remove use of VLAs Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 10/20] net/ixgbe: " Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 11/20] net/ice: " Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 12/20] app/testpmd: remove use of VLAs for Windows built Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 13/20] test: remove use of VLAs for Windows built code Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 14/20] common/idpf: " Andre Muezerie 2024-11-08 8:47 ` Bruce Richardson 2024-11-08 0:44 ` [PATCH v5 15/20] net/i40e: " Andre Muezerie 2024-11-08 8:45 ` Bruce Richardson 2024-11-08 0:44 ` [PATCH v5 16/20] common/mlx5: " Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 17/20] net/mlx5: " Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 18/20] build: enable vla warnings on " Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 19/20] test: remove use of VLAs for Windows built code in bitset tests Andre Muezerie 2024-11-08 0:44 ` [PATCH v5 20/20] app/testpmd: remove use of VLAs for Windows built code in shared_rxq_fwd Andre Muezerie
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).