Skip to contentSkip to conversation

remove use of VLAs for Windows built code

PATCH Superseded Tyler Retzlaff 12 participants 726 messages Apr 17, 2024 – Feb 19, 2025 Page 3 of 6

Subsystems (10)
lore
Share & tools
lore
#265 lore raw

PATCH v11 7/21 rcu: remove use of VLAs for Windows built code

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

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.

---
 lib/rcu/rte_rcu_qsbr.c | 7 ++++---
 lib/rcu/rte_rcu_qsbr.h | 5 +++++
 2 files changed, 9 insertions(+), 3 deletions(-)
lib/rcu/rte_rcu_qsbr.c +4 -3
index dbf31501a6..fe68d16326 100644
@@ -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,
lib/rcu/rte_rcu_qsbr.h +5 -0
index 550fadf56a..abcbd78914 100644
@@ -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.
Signature · 1 line
2.47.0.vfs.0.3
#266 lore raw

PATCH v11 8/21 gro: fix overwrite unprocessed packets

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

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")
---
 lib/gro/rte_gro.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/gro/rte_gro.c +1 -1
index d824eebd93..db86117609 100644
@@ -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) {
Signature · 1 line
2.47.0.vfs.0.3
#267 lore raw

PATCH v11 9/21 gro: remove use of VLAs

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

../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].

---
 lib/gro/rte_gro.c | 40 ++++++++++++++--------------------------
 1 file changed, 14 insertions(+), 26 deletions(-)
lib/gro/rte_gro.c +14 -26
index db86117609..6d5aadf32a 100644
@@ -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;
Signature · 1 line
2.47.0.vfs.0.3
#268 lore raw

PATCH v11 10/21 net/ixgbe: remove use of VLAs

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

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.

---
 drivers/net/ixgbe/ixgbe_ethdev.c          | 21 +++++++++++++--------
 drivers/net/ixgbe/ixgbe_rxtx_vec_common.h |  4 +++-
 2 files changed, 16 insertions(+), 9 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +13 -8
index eb431889c3..cdeab563c5 100644
@@ -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);
 
drivers/net/ixgbe/ixgbe_rxtx_vec_common.h +3 -1
index a4d9ec9b08..c1cf0a581a 100644
@@ -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 */
Signature · 1 line
2.47.0.vfs.0.3
#269 lore raw

PATCH v11 11/21 net/ice: remove use of VLAs

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

../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.

---
 drivers/net/ice/ice_rxtx.c | 18 ++++++++++++------
 drivers/net/ice/ice_rxtx.h |  2 ++
 2 files changed, 14 insertions(+), 6 deletions(-)
drivers/net/ice/ice_rxtx.c +12 -6
index 0c7106c7e0..578453ec89 100644
@@ -1186,7 +1186,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;
@@ -1294,9 +1294,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) {
@@ -1305,6 +1310,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;
@@ -1883,7 +1890,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 -
@@ -1898,7 +1904,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;
@@ -1923,8 +1929,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;
 		}
drivers/net/ice/ice_rxtx.h +2 -0
index 45f25b3609..20ee325c2b 100644
@@ -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 */
Signature · 1 line
2.47.0.vfs.0.3
#270 lore raw

PATCH v11 12/21 app/testpmd: remove use of VLAs for Windows built

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 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(-)
app/test-pmd/cmdline.c +1 -1
index 7e0666e9f6..2897e44c34 100644
@@ -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) {
app/test-pmd/cmdline_flow.c +10 -5
index 1e4f2ebc55..fb0c4f838d 100644
@@ -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;
app/test-pmd/config.c +9 -7
index 28d45568ac..8117026c73 100644
@@ -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)
@@ -5551,7 +5552,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;
@@ -7292,7 +7293,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;
Signature · 1 line
2.47.0.vfs.0.3
#271 lore raw

PATCH v11 13/21 test: remove use of VLAs for Windows built code

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 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(-)
app/test/test.c +1 -1
index 680351f6a3..fd653cbbfd 100644
@@ -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;
app/test/test_cmdline_string.c +1 -1
index 97516c9400..e1cf86020f 100644
@@ -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 {
app/test/test_cryptodev.c +17 -17
index c647baeee1..9fdbfe5150 100644
@@ -2886,7 +2886,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;
@@ -2922,7 +2922,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;
 
@@ -3074,7 +3074,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;
@@ -9078,7 +9078,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;
@@ -12992,7 +12992,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;
@@ -13346,7 +13346,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");
@@ -13735,7 +13735,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));
@@ -13987,7 +13987,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);
@@ -14089,7 +14089,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);
@@ -15482,7 +15482,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;
@@ -16139,7 +16139,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);
 
@@ -16170,8 +16170,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);
@@ -16671,8 +16671,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);
@@ -16803,8 +16803,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);
app/test/test_cryptodev_blockcipher.c +2 -2
index 8e13cdfc7a..5a124bbb5e 100644
@@ -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;
app/test/test_cryptodev_crosscheck.c +1 -1
index c29b19cf6b..b9a53a430c 100644
@@ -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];
app/test/test_dmadev.c +6 -3
index 143e1bcd68..9cbb9a6552 100644
@@ -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;
app/test/test_hash.c +8 -6
index 65b9cad93c..16e63d2926 100644
@@ -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;
app/test/test_mempool.c +13 -12
index 3f7ba5872d..61385e096e 100644
@@ -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;
 
app/test/test_reorder.c +26 -22

155 lines not on this page · raw message

app/test/test_service_cores.c +4 -5
index 46ed9a1868..d95a71f80b 100644
@@ -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",
app/test/test_thash.c +3 -4
index b9c6e9118e..33b0c6adac 100644
@@ -565,9 +565,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;
@@ -575,9 +574,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");
 
Signature · 1 line
2.47.0.vfs.0.3
#272 lore raw

PATCH v11 14/21 common/idpf: remove use of VLAs for Windows built code

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 drivers/common/idpf/idpf_common_rxtx.c        | 2 +-
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/common/idpf/idpf_common_rxtx.c +1 -1
index a04e54ce26..e04ab40fa2 100644
@@ -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;
drivers/common/idpf/idpf_common_rxtx_avx512.c +4 -2
index b8450b03ae..63e10c542f 100644
@@ -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;
 
Signature · 1 line
2.47.0.vfs.0.3
#273 lore raw

PATCH v11 15/21 net/i40e: remove use of VLAs for Windows built code

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 drivers/net/i40e/i40e_testpmd.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/i40e/i40e_testpmd.c +2 -3
index b6ef5d6e42..21f596297b 100644
@@ -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) {
Signature · 1 line
2.47.0.vfs.0.3
#274 lore raw

PATCH v11 16/21 common/mlx5: remove use of VLAs for Windows built code

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 drivers/common/mlx5/mlx5_common.h    | 4 ++--
 drivers/common/mlx5/mlx5_devx_cmds.c | 7 +++----
 2 files changed, 5 insertions(+), 6 deletions(-)
drivers/common/mlx5/mlx5_common.h +2 -2
index 1abd1e8239..f29f06a86e 100644
@@ -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,
drivers/common/mlx5/mlx5_devx_cmds.c +3 -4
index a75f011750..804ee67cd6 100644
@@ -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),
Signature · 1 line
2.47.0.vfs.0.3
#275 lore raw

PATCH v11 17/21 net/mlx5: remove use of VLAs for Windows built code

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 drivers/net/mlx5/mlx5.c      | 5 ++---
 drivers/net/mlx5/mlx5_flow.c | 6 +++---
 2 files changed, 5 insertions(+), 6 deletions(-)
drivers/net/mlx5/mlx5.c +2 -3
index 6e4473e2f4..979e54686b 100644
@@ -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;
 
drivers/net/mlx5/mlx5_flow.c +3 -3
index 16ddd05448..37b5402447 100644
@@ -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;
 
@@ -8477,7 +8477,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,
Signature · 1 line
2.47.0.vfs.0.3
#276 lore raw

PATCH v11 18/21 build: enable vla warnings on Windows built code

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 config/meson.build | 4 ++++
 1 file changed, 4 insertions(+)
config/meson.build +4 -0
index 6aaad6d8a4..ebca19b4e5 100644
@@ -342,6 +342,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')
Signature · 1 line
2.47.0.vfs.0.3
#277 lore raw

PATCH v11 19/21 test: remove use of VLAs for Windows built code in bitset tests

In reply to 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).

---
 app/test/test_bitset.c          | 69 ++++++++++++++++++++-------------
 app/test/test_lcore_var_perf.c  |  2 +-
 app/test/test_reassembly_perf.c |  4 +-
 3 files changed, 46 insertions(+), 29 deletions(-)
app/test/test_bitset.c +43 -26
index 50b8bf0da4..45460204c1 100644
@@ -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);
@@ -131,8 +133,7 @@ test_set_clear_size(test_fun test_fun, set_fun set_fun, clear_fun clear_fun, siz
 	return TEST_SUCCESS;
 }
 
-#define RAND_ITERATIONS (10000)
-#define RAND_SET_MAX_SIZE (1000)
+#define RAND_ITERATIONS 10000
 
 static int
 test_set_clear_fun(test_fun test_fun, set_fun set_fun, clear_fun clear_fun)
@@ -168,10 +169,20 @@ 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);
+
+#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 110000)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Warray-bounds"
+#endif
 
+		/* gcc is giving false positives here when code is optimized */
 		rte_bitset_copy(reference, bitset, size);
 
+#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 110000)
+#pragma GCC diagnostic pop
+#endif
+
 		bool value = test_fun(bitset, i);
 
 		flip_fun(bitset, i);
@@ -282,13 +293,13 @@ find_clear(const bool *ary, size_t num_bools, size_t start, size_t len)
 	return find(ary, num_bools, start, len, false);
 }
 
-#define FFS_ITERATIONS (100)
+#define FFS_ITERATIONS 100
 
 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 +399,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 +644,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 +721,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 +739,8 @@ test_complement(void)
 	return TEST_SUCCESS;
 }
 
+#define SHIFT_SET_MAX_SIZE 500
+
 static int
 test_shift(bool right)
 {
@@ -734,12 +749,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 +803,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 +838,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));
app/test/test_lcore_var_perf.c +1 -1
index 41e29bbd49..5a74ce4808 100644
@@ -185,7 +185,7 @@ test_lcore_var_access_n(unsigned int num_mods)
 	double tls_latency;
 	double lazy_tls_latency;
 	double lvar_latency;
-	unsigned int mods[num_mods];
+	unsigned int mods[MAX_MODS];
 	unsigned int i;
 
 	for (i = 0; i < num_mods; i++)
app/test/test_reassembly_perf.c +2 -2
index 69cf029468..ac225e2b53 100644
@@ -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]);
Signature · 1 line
2.47.0.vfs.0.3
#278 lore raw

PATCH v11 20/21 app/testpmd: remove use of VLAs for Windows built code in shared_rxq_fwd

In reply to 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.

---
 app/test-pmd/shared_rxq_fwd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test-pmd/shared_rxq_fwd.c +1 -1
index 623d62da88..b85830b90e 100644
@@ -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);
Signature · 1 line
2.47.0.vfs.0.3
#279 lore raw

PATCH v11 21/21 hash: remove use of VLAs by using standard arrays

In reply to Andre Muezerie

MSVC does not support VLAs, replace VLAs with standard C arrays.

---
 lib/hash/rte_thash_gf2_poly_math.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
lib/hash/rte_thash_gf2_poly_math.c +4 -5
index 1c62974e71..825da4382f 100644
@@ -8,6 +8,7 @@
 #include <rte_thash.h>
 #include <rte_log.h>
 
+#define MAX_POLY_DEGREE 32
 #define MAX_TOEPLITZ_KEY_LENGTH 64
 RTE_LOG_REGISTER_SUFFIX(thash_poly_logtype, thash_poly, INFO);
 #define RTE_LOGTYPE_HASH thash_poly_logtype
@@ -149,7 +150,7 @@ gf2_pow(uint32_t a, uint32_t pow, uint32_t r, int degree)
 static uint32_t
 __thash_get_rand_poly(int poly_degree)
 {
-	uint32_t roots[poly_degree];
+	uint32_t roots[MAX_POLY_DEGREE];
 	uint32_t rnd;
 	uint32_t ret_poly = 0;
 	int i, j;
@@ -194,9 +195,7 @@ __thash_get_rand_poly(int poly_degree)
 	 * Get coefficients of the polynomial for
 	 * (x - roots[0])(x - roots[1])...(x - roots[n])
 	 */
-	uint32_t poly_coefficients[poly_degree + 1];
-	for (i = 0; i <= poly_degree; i++)
-		poly_coefficients[i] = 0;
+	uint32_t poly_coefficients[MAX_POLY_DEGREE + 1] = {0};
 
 	poly_coefficients[0] = 1; /* highest degree term coefficient in the end */
 	for (i = 0; i < (int)poly_degree; i++) {
@@ -247,7 +246,7 @@ thash_get_rand_poly(uint32_t poly_degree)
 {
 	uint32_t ret_poly;
 
-	if (poly_degree > 32) {
+	if (poly_degree > MAX_POLY_DEGREE) {
 		HASH_LOG(ERR, "Wrong polynomial degree %d, must be in range [1, 32]", poly_degree);
 		return 0;
 	}
Signature · 1 line
2.47.0.vfs.0.3
#280 lore raw

v12 cover remove use of VLAs for Windows

In reply to Tyler Retzlaff

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.

v12:
* update commit message for patch 06/21 to avoid warning

v11:
* add include stdlib.h for alloca() declaration on FreeBSD
* zero-initialize array without code loop
* increase maximum tuple length

v10:
* add ifdef to scope gcc's diagnostic error down to gcc only

v9:
* fix sender's email address
* fix gcc's diagnostic error string to make clang happy

v8:
* rebase
* reduce scope for disabling error "-Warray-bounds=" to only the place that needs it
* remove parentesis around numbers from defines in test_bitset.c

v7:
* remove use of VLA from new file which sneaked in during review

v6:
* remove use of VLA from new test code added recently
* fix title for patch 08/20

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 (3):
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
hash: remove use of VLAs by using standard arrays

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
gro: fix overwrite unprocessed packets
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/test.c                               |   2 +-
 app/test/test_bitset.c                        |  69 ++++---
 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_lcore_var_perf.c                |   2 +-
 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/freebsd/include/rte_os.h              |   1 +
 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                          |   7 +
 lib/hash/rte_thash_gf2_poly_math.c            |   9 +-
 lib/rcu/rte_rcu_qsbr.c                        |   7 +-
 lib/rcu/rte_rcu_qsbr.h                        |   5 +
 43 files changed, 384 insertions(+), 265 deletions(-)

--
2.47.0.vfs.0.3

#281 lore raw

PATCH v12 1/21 eal: include header required for alloca

From: Tyler Retzlaff <[email protected]>

Include alloca.h for Linux and malloc.h for Windows to get declaration of alloca().

---
 lib/eal/freebsd/include/rte_os.h | 1 +
 lib/eal/linux/include/rte_os.h   | 1 +
 lib/eal/windows/include/rte_os.h | 1 +
 3 files changed, 3 insertions(+)
lib/eal/freebsd/include/rte_os.h +1 -0
index 62e70dc15b..94b9275beb 100644
@@ -11,6 +11,7 @@
  */
 
 #include <pthread_np.h>
+#include <stdlib.h>            /* Declares alloca() */
 #include <sys/queue.h>
 
 /* These macros are compatible with system's sys/queue.h. */
lib/eal/linux/include/rte_os.h +1 -0
index 35c07c70cb..20eff0409a 100644
@@ -10,6 +10,7 @@
  * which is not supported natively or named differently in Linux.
  */
 
+#include <alloca.h>
 #include <sched.h>
 #include <sys/queue.h>
 
lib/eal/windows/include/rte_os.h +1 -0
index 9d69467aaa..d09adeb3b4 100644
@@ -13,6 +13,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <malloc.h>
 
 #include <sched.h>
 
Signature · 1 line
2.47.0.vfs.0.3
#282 lore raw

PATCH v12 2/21 eal/linux: remove use of VLAs

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

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);

---
 lib/eal/linux/eal_interrupts.c | 32 +++++++++++++++++++++++++++-----
 1 file changed, 27 insertions(+), 5 deletions(-)
lib/eal/linux/eal_interrupts.c +27 -5
index 6436f796eb..23039964fc 100644
@@ -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)
Signature · 1 line
2.47.0.vfs.0.3
#283 lore raw

PATCH v12 3/21 eal/common: remove use of VLAs

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

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.

---
 lib/eal/common/eal_common_proc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
lib/eal/common/eal_common_proc.c +3 -2
index d24093937c..201973c5db 100644
@@ -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);
Signature · 1 line
2.47.0.vfs.0.3
#284 lore raw

PATCH v12 4/21 ethdev: remove use of VLAs for Windows built code

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

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.

---
 lib/ethdev/rte_ethdev.c | 183 +++++++++++++++++++++++++---------------
 1 file changed, 113 insertions(+), 70 deletions(-)
lib/ethdev/rte_ethdev.c +113 -70
index 6413c54e3b..09cc4764c3 100644
@@ -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
Signature · 1 line
2.47.0.vfs.0.3
#285 lore raw

Re: [PATCH v12 04/21] ethdev: remove use of VLAs for Windows built code

Quoted 11 lines · Andre Muezerie

From: Konstantin Ananyev <[email protected]>

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’

Quoted 7 lines

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.

It will invoke PMD ops multi-times, I'm not sure whether all drivers impl correctly.

And it also belong control-path, so suggest use the call/free as 1&3 case.

#286 lore raw

RE: [PATCH v12 04/21] ethdev: remove use of VLAs for Windows built code

Quoted 29 lines

-----Original Message-----
From: Fengchengwen <[email protected]>
Sent: Friday, November 22, 2024 1:33 AM
To: Andre Muezerie <[email protected]>; [email protected]
Cc: Konstantin Ananyev <[email protected]>
Subject: Re: [PATCH v12 04/21] ethdev: remove use of VLAs for Windows built code

Quoted 11 lines · Andre Muezerie

From: Konstantin Ananyev <[email protected]>

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’

Quoted 7 lines

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.

Quoted 2 lines

It will invoke PMD ops multi-times, I'm not sure whether all drivers impl correctly.

Hmm..., but then there is a bug in the driver that has to be fixed, no?

Quoted 2 lines

And it also belong control-path, so suggest use the call/free as 1&3 case.

#287 lore raw

Re: [PATCH v12 04/21] ethdev: remove use of VLAs for Windows built code

Quoted 29 lines · Konstantin Ananyev
Quoted 29 lines

-----Original Message-----
From: Fengchengwen <[email protected]>
Sent: Friday, November 22, 2024 1:33 AM
To: Andre Muezerie <[email protected]>; [email protected]
Cc: Konstantin Ananyev <[email protected]>
Subject: Re: [PATCH v12 04/21] ethdev: remove use of VLAs for Windows built code

Quoted 18 lines · Andre Muezerie

From: Konstantin Ananyev <[email protected]>

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.

Quoted 4 lines
Quoted 2 lines

It will invoke PMD ops multi-times, I'm not sure whether all drivers impl correctly.

Hmm..., but then there is a bug in the driver that has to be fixed, no?

Yes, such bug need to be fixed.

In this case, we maybe need more review on PMD's impl.

Quoted 4 lines
Quoted 3 lines

And it also belong control-path, so suggest use the call/free as 1&3 case.

#288 lore raw

PATCH v12 5/21 hash: remove use of VLAs for Windows built code

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

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.

---
 lib/hash/rte_cuckoo_hash.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/hash/rte_cuckoo_hash.c +2 -2
index 9575e8aa0c..fc93182efe 100644
@@ -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);
Signature · 1 line
2.47.0.vfs.0.3
Acked-by on v12 5/21
#289 lore raw

Re: [PATCH v12 05/21] hash: remove use of VLAs for Windows built code

Quoted 42 lines · Andre Muezerie

From: Konstantin Ananyev <[email protected]>

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.

---
 lib/hash/rte_cuckoo_hash.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/hash/rte_cuckoo_hash.c +2 -2
index 9575e8aa0c..fc93182efe 100644
@@ -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);
#290 lore raw

PATCH v12 6/21 hash/thash: remove use of VLAs for Windows built

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

1) ./lib/hash/rte_thash.c:774:9
: warning: ISO C90 forbids variable length array ‘tmp_tuple’

The tuple can exceed sizeof(union rte_thash_tuple), for example if any tunneling header is used in the RSS hash calculation.

The longest RSS hash key currently supported is 52 bytes. Technically, the longest tuple with such a key should be (52 - sizeof(uint32_t)), so this can be used as a size of the tmp_tuple array.

---
 lib/hash/rte_thash.c | 2 +-
 lib/hash/rte_thash.h | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)
lib/hash/rte_thash.c +1 -1
index 336c228e64..fa78787143 100644
@@ -761,7 +761,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_TUPLE_LEN_MAX];
 	unsigned int i, j, ret = 0;
 	uint32_t hash, adj_bits;
 	const uint8_t *hash_key;
lib/hash/rte_thash.h +7 -0
index c0af5968df..04f9f1875c 100644
@@ -121,6 +121,13 @@ __rte_internal
 uint32_t
 thash_get_rand_poly(uint32_t poly_degree);
 
+/**
+ * Longest RSS hash key currently supported
+ */
+#define RTE_THASH_KEY_LEN_MAX	52
+
+#define RTE_THASH_TUPLE_LEN_MAX (RTE_THASH_KEY_LEN_MAX - sizeof(uint32_t))
+
 /**
  * Prepare special converted key to use with rte_softrss_be()
  * @param orig
Signature · 1 line
2.47.0.vfs.0.3
#291 lore raw

Re: [PATCH v12 06/21] hash/thash: remove use of VLAs for Windows built

Quoted 23 lines · Andre Muezerie

From: Konstantin Ananyev <[email protected]>

1) ./lib/hash/rte_thash.c:774:9
: warning: ISO C90 forbids variable length array ‘tmp_tuple’

The tuple can exceed sizeof(union rte_thash_tuple), for example if any tunneling header is used in the RSS hash calculation.

The longest RSS hash key currently supported is 52 bytes. Technically, the longest tuple with such a key should be (52 - sizeof(uint32_t)), so this can be used as a size of the tmp_tuple array.

---
 lib/hash/rte_thash.c | 2 +-
 lib/hash/rte_thash.h | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)
lib/hash/rte_thash.c +0 -0
index 336c228e64..fa78787143 100644

lib/hash/rte_thash.c rte_thash_adjust_tuple(struct rte_thash_ctx *ctx, · line 763

Quoted 3 lines
lib/hash/rte_thash.c +0 -0
@@ -761,7 +761,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)
 {

This API support parameter check, how about add tuple_len > RTE_THASH_TUPLE_LEN_MAX ?

Quoted 23 lines
lib/hash/rte_thash.c +1 -1
-	uint32_t tmp_tuple[tuple_len / sizeof(uint32_t)];
+	uint32_t tmp_tuple[RTE_THASH_TUPLE_LEN_MAX];
 	unsigned int i, j, ret = 0;
 	uint32_t hash, adj_bits;
 	const uint8_t *hash_key;
lib/hash/rte_thash.h +7 -0
index c0af5968df..04f9f1875c 100644
@@ -121,6 +121,13 @@ __rte_internal
 uint32_t
 thash_get_rand_poly(uint32_t poly_degree);
 
+/**
+ * Longest RSS hash key currently supported
+ */
+#define RTE_THASH_KEY_LEN_MAX	52
+
+#define RTE_THASH_TUPLE_LEN_MAX (RTE_THASH_KEY_LEN_MAX - sizeof(uint32_t))
+
 /**
  * Prepare special converted key to use with rte_softrss_be()
  * @param orig
#292 lore raw

PATCH v12 7/21 rcu: remove use of VLAs for Windows built code

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

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.

---
 lib/rcu/rte_rcu_qsbr.c | 7 ++++---
 lib/rcu/rte_rcu_qsbr.h | 5 +++++
 2 files changed, 9 insertions(+), 3 deletions(-)
lib/rcu/rte_rcu_qsbr.c +4 -3
index dbf31501a6..fe68d16326 100644
@@ -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,
lib/rcu/rte_rcu_qsbr.h +5 -0
index 550fadf56a..abcbd78914 100644
@@ -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.
Signature · 1 line
2.47.0.vfs.0.3
#293 lore raw

PATCH v12 8/21 gro: fix overwrite unprocessed packets

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

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")
---
 lib/gro/rte_gro.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/gro/rte_gro.c +1 -1
index d824eebd93..db86117609 100644
@@ -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) {
Signature · 1 line
2.47.0.vfs.0.3
#294 lore raw

PATCH v12 9/21 gro: remove use of VLAs

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

../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].

---
 lib/gro/rte_gro.c | 40 ++++++++++++++--------------------------
 1 file changed, 14 insertions(+), 26 deletions(-)
lib/gro/rte_gro.c +14 -26
index db86117609..6d5aadf32a 100644
@@ -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;
Signature · 1 line
2.47.0.vfs.0.3
#295 lore raw

PATCH v12 10/21 net/ixgbe: remove use of VLAs

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

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.

---
 drivers/net/ixgbe/ixgbe_ethdev.c          | 21 +++++++++++++--------
 drivers/net/ixgbe/ixgbe_rxtx_vec_common.h |  4 +++-
 2 files changed, 16 insertions(+), 9 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +13 -8
index eb431889c3..cdeab563c5 100644
@@ -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);
 
drivers/net/ixgbe/ixgbe_rxtx_vec_common.h +3 -1
index a4d9ec9b08..c1cf0a581a 100644
@@ -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 */
Signature · 1 line
2.47.0.vfs.0.3
#296 lore raw

PATCH v12 11/21 net/ice: remove use of VLAs

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

../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.

---
 drivers/net/ice/ice_rxtx.c | 18 ++++++++++++------
 drivers/net/ice/ice_rxtx.h |  2 ++
 2 files changed, 14 insertions(+), 6 deletions(-)
drivers/net/ice/ice_rxtx.c +12 -6
index 0c7106c7e0..578453ec89 100644
@@ -1186,7 +1186,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;
@@ -1294,9 +1294,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) {
@@ -1305,6 +1310,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;
@@ -1883,7 +1890,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 -
@@ -1898,7 +1904,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;
@@ -1923,8 +1929,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;
 		}
drivers/net/ice/ice_rxtx.h +2 -0
index 45f25b3609..20ee325c2b 100644
@@ -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 */
Signature · 1 line
2.47.0.vfs.0.3
#297 lore raw

PATCH v12 12/21 app/testpmd: remove use of VLAs for Windows built

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 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(-)
app/test-pmd/cmdline.c +1 -1
index 7e0666e9f6..2897e44c34 100644
@@ -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) {
app/test-pmd/cmdline_flow.c +10 -5
index 1e4f2ebc55..fb0c4f838d 100644
@@ -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;
app/test-pmd/config.c +9 -7
index 28d45568ac..8117026c73 100644
@@ -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)
@@ -5551,7 +5552,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;
@@ -7292,7 +7293,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;
Signature · 1 line
2.47.0.vfs.0.3
#298 lore raw

PATCH v12 13/21 test: remove use of VLAs for Windows built code

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 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(-)
app/test/test.c +1 -1
index 680351f6a3..fd653cbbfd 100644
@@ -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;
app/test/test_cmdline_string.c +1 -1
index 97516c9400..e1cf86020f 100644
@@ -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 {
app/test/test_cryptodev.c +17 -17
index c647baeee1..9fdbfe5150 100644
@@ -2886,7 +2886,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;
@@ -2922,7 +2922,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;
 
@@ -3074,7 +3074,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;
@@ -9078,7 +9078,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;
@@ -12992,7 +12992,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;
@@ -13346,7 +13346,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");
@@ -13735,7 +13735,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));
@@ -13987,7 +13987,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);
@@ -14089,7 +14089,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);
@@ -15482,7 +15482,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;
@@ -16139,7 +16139,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);
 
@@ -16170,8 +16170,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);
@@ -16671,8 +16671,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);
@@ -16803,8 +16803,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);
app/test/test_cryptodev_blockcipher.c +2 -2
index 8e13cdfc7a..5a124bbb5e 100644
@@ -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;
app/test/test_cryptodev_crosscheck.c +1 -1
index c29b19cf6b..b9a53a430c 100644
@@ -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];
app/test/test_dmadev.c +6 -3
index 143e1bcd68..9cbb9a6552 100644
@@ -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;
app/test/test_hash.c +8 -6
index 65b9cad93c..16e63d2926 100644
@@ -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;
app/test/test_mempool.c +13 -12
index 3f7ba5872d..61385e096e 100644
@@ -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;
 
app/test/test_reorder.c +26 -22

155 lines not on this page · raw message

app/test/test_service_cores.c +4 -5
index 46ed9a1868..d95a71f80b 100644
@@ -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",
app/test/test_thash.c +3 -4
index b9c6e9118e..33b0c6adac 100644
@@ -565,9 +565,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;
@@ -575,9 +574,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");
 
Signature · 1 line
2.47.0.vfs.0.3
#300 lore raw

PATCH v12 14/21 common/idpf: remove use of VLAs for Windows built code

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 drivers/common/idpf/idpf_common_rxtx.c        | 2 +-
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/common/idpf/idpf_common_rxtx.c +1 -1
index a04e54ce26..e04ab40fa2 100644
@@ -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;
drivers/common/idpf/idpf_common_rxtx_avx512.c +4 -2
index b8450b03ae..63e10c542f 100644
@@ -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;
 
Signature · 1 line
2.47.0.vfs.0.3
#301 lore raw

PATCH v12 15/21 net/i40e: remove use of VLAs for Windows built code

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 drivers/net/i40e/i40e_testpmd.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/i40e/i40e_testpmd.c +2 -3
index b6ef5d6e42..21f596297b 100644
@@ -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) {
Signature · 1 line
2.47.0.vfs.0.3
#302 lore raw

PATCH v12 16/21 common/mlx5: remove use of VLAs for Windows built code

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 drivers/common/mlx5/mlx5_common.h    | 4 ++--
 drivers/common/mlx5/mlx5_devx_cmds.c | 7 +++----
 2 files changed, 5 insertions(+), 6 deletions(-)
drivers/common/mlx5/mlx5_common.h +2 -2
index 1abd1e8239..f29f06a86e 100644
@@ -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,
drivers/common/mlx5/mlx5_devx_cmds.c +3 -4
index a75f011750..804ee67cd6 100644
@@ -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),
Signature · 1 line
2.47.0.vfs.0.3
#303 lore raw

PATCH v12 17/21 net/mlx5: remove use of VLAs for Windows built code

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 drivers/net/mlx5/mlx5.c      | 5 ++---
 drivers/net/mlx5/mlx5_flow.c | 6 +++---
 2 files changed, 5 insertions(+), 6 deletions(-)
drivers/net/mlx5/mlx5.c +2 -3
index 6e4473e2f4..979e54686b 100644
@@ -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;
 
drivers/net/mlx5/mlx5_flow.c +3 -3
index 16ddd05448..37b5402447 100644
@@ -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;
 
@@ -8477,7 +8477,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,
Signature · 1 line
2.47.0.vfs.0.3
#304 lore raw

PATCH v12 18/21 build: enable vla warnings on Windows built code

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 config/meson.build | 4 ++++
 1 file changed, 4 insertions(+)
config/meson.build +4 -0
index 6aaad6d8a4..ebca19b4e5 100644
@@ -342,6 +342,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')
Signature · 1 line
2.47.0.vfs.0.3
Acked-by on v12 18/21
#305 lore raw

Re: [PATCH v12 18/21] build: enable vla warnings on Windows built code

Quoted 26 lines · Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 config/meson.build | 4 ++++
 1 file changed, 4 insertions(+)
config/meson.build +4 -0
index 6aaad6d8a4..ebca19b4e5 100644
@@ -342,6 +342,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')
#306 lore raw

PATCH v12 19/21 test: remove use of VLAs for Windows built code in bitset tests

In reply to 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).

---
 app/test/test_bitset.c          | 69 ++++++++++++++++++++-------------
 app/test/test_lcore_var_perf.c  |  2 +-
 app/test/test_reassembly_perf.c |  4 +-
 3 files changed, 46 insertions(+), 29 deletions(-)
app/test/test_bitset.c +43 -26
index 50b8bf0da4..45460204c1 100644
@@ -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);
@@ -131,8 +133,7 @@ test_set_clear_size(test_fun test_fun, set_fun set_fun, clear_fun clear_fun, siz
 	return TEST_SUCCESS;
 }
 
-#define RAND_ITERATIONS (10000)
-#define RAND_SET_MAX_SIZE (1000)
+#define RAND_ITERATIONS 10000
 
 static int
 test_set_clear_fun(test_fun test_fun, set_fun set_fun, clear_fun clear_fun)
@@ -168,10 +169,20 @@ 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);
+
+#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 110000)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Warray-bounds"
+#endif
 
+		/* gcc is giving false positives here when code is optimized */
 		rte_bitset_copy(reference, bitset, size);
 
+#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 110000)
+#pragma GCC diagnostic pop
+#endif
+
 		bool value = test_fun(bitset, i);
 
 		flip_fun(bitset, i);
@@ -282,13 +293,13 @@ find_clear(const bool *ary, size_t num_bools, size_t start, size_t len)
 	return find(ary, num_bools, start, len, false);
 }
 
-#define FFS_ITERATIONS (100)
+#define FFS_ITERATIONS 100
 
 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 +399,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 +644,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 +721,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 +739,8 @@ test_complement(void)
 	return TEST_SUCCESS;
 }
 
+#define SHIFT_SET_MAX_SIZE 500
+
 static int
 test_shift(bool right)
 {
@@ -734,12 +749,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 +803,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 +838,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));
app/test/test_lcore_var_perf.c +1 -1
index 41e29bbd49..5a74ce4808 100644
@@ -185,7 +185,7 @@ test_lcore_var_access_n(unsigned int num_mods)
 	double tls_latency;
 	double lazy_tls_latency;
 	double lvar_latency;
-	unsigned int mods[num_mods];
+	unsigned int mods[MAX_MODS];
 	unsigned int i;
 
 	for (i = 0; i < num_mods; i++)
app/test/test_reassembly_perf.c +2 -2
index 69cf029468..ac225e2b53 100644
@@ -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]);
Signature · 1 line
2.47.0.vfs.0.3
#307 lore raw

PATCH v12 20/21 app/testpmd: remove use of VLAs for Windows built code in shared_rxq_fwd

In reply to 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.

---
 app/test-pmd/shared_rxq_fwd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test-pmd/shared_rxq_fwd.c +1 -1
index 623d62da88..b85830b90e 100644
@@ -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);
Signature · 1 line
2.47.0.vfs.0.3
Acked-by on v12 20/21
#308 lore raw

Re: [PATCH v12 20/21] app/testpmd: remove use of VLAs for Windows built code in shared_rxq_fwd

Quoted 22 lines · 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.

---
 app/test-pmd/shared_rxq_fwd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test-pmd/shared_rxq_fwd.c +1 -1
index 623d62da88..b85830b90e 100644
@@ -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);
#309 lore raw

PATCH v12 21/21 hash: remove use of VLAs by using standard arrays

In reply to Andre Muezerie

MSVC does not support VLAs, replace VLAs with standard C arrays.

---
 lib/hash/rte_thash_gf2_poly_math.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
lib/hash/rte_thash_gf2_poly_math.c +4 -5
index 1c62974e71..825da4382f 100644
@@ -8,6 +8,7 @@
 #include <rte_thash.h>
 #include <rte_log.h>
 
+#define MAX_POLY_DEGREE 32
 #define MAX_TOEPLITZ_KEY_LENGTH 64
 RTE_LOG_REGISTER_SUFFIX(thash_poly_logtype, thash_poly, INFO);
 #define RTE_LOGTYPE_HASH thash_poly_logtype
@@ -149,7 +150,7 @@ gf2_pow(uint32_t a, uint32_t pow, uint32_t r, int degree)
 static uint32_t
 __thash_get_rand_poly(int poly_degree)
 {
-	uint32_t roots[poly_degree];
+	uint32_t roots[MAX_POLY_DEGREE];
 	uint32_t rnd;
 	uint32_t ret_poly = 0;
 	int i, j;
@@ -194,9 +195,7 @@ __thash_get_rand_poly(int poly_degree)
 	 * Get coefficients of the polynomial for
 	 * (x - roots[0])(x - roots[1])...(x - roots[n])
 	 */
-	uint32_t poly_coefficients[poly_degree + 1];
-	for (i = 0; i <= poly_degree; i++)
-		poly_coefficients[i] = 0;
+	uint32_t poly_coefficients[MAX_POLY_DEGREE + 1] = {0};
 
 	poly_coefficients[0] = 1; /* highest degree term coefficient in the end */
 	for (i = 0; i < (int)poly_degree; i++) {
@@ -247,7 +246,7 @@ thash_get_rand_poly(uint32_t poly_degree)
 {
 	uint32_t ret_poly;
 
-	if (poly_degree > 32) {
+	if (poly_degree > MAX_POLY_DEGREE) {
 		HASH_LOG(ERR, "Wrong polynomial degree %d, must be in range [1, 32]", poly_degree);
 		return 0;
 	}
Signature · 1 line
2.47.0.vfs.0.3
#310 lore raw

v13 cover remove use of VLAs for Windows

In reply to Tyler Retzlaff

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.

v13:
* increase stack allocated buffer size in ipv4_reassembly_interleaved_flows_perf and ipv6_reassembly_interleaved_flows_perf to avoid STATUS_STACK_BUFFER_OVERRUN on Windows using MSVC

v12:
* update commit message for patch 06/21 to avoid warning

v11:
* add include stdlib.h for alloca() declaration on FreeBSD
* zero-initialize array without code loop
* increase maximum tuple length

v10:
* add ifdef to scope gcc's diagnostic error down to gcc only

v9:
* fix sender's email address
* fix gcc's diagnostic error string to make clang happy

v8:
* rebase
* reduce scope for disabling error "-Warray-bounds=" to only the place that needs it
* remove parentesis around numbers from defines in test_bitset.c

v7:
* remove use of VLA from new file which sneaked in during review

v6:
* remove use of VLA from new test code added recently
* fix title for patch 08/20

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 (3):
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
hash: remove use of VLAs by using standard arrays

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
gro: fix overwrite unprocessed packets
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/test.c                               |   2 +-
 app/test/test_bitset.c                        |  69 ++++---
 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_lcore_var_perf.c                |   2 +-
 app/test/test_mempool.c                       |  25 +--
 app/test/test_reassembly_perf.c               |  22 ++-
 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/freebsd/include/rte_os.h              |   1 +
 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                          |   7 +
 lib/hash/rte_thash_gf2_poly_math.c            |   9 +-
 lib/rcu/rte_rcu_qsbr.c                        |   7 +-
 lib/rcu/rte_rcu_qsbr.h                        |   5 +
 43 files changed, 394 insertions(+), 273 deletions(-)

--
2.47.0.vfs.0.3

#311 lore raw

PATCH v13 1/21 eal: include header required for alloca

From: Tyler Retzlaff <[email protected]>

Include alloca.h for Linux and malloc.h for Windows to get declaration of alloca().

---
 lib/eal/freebsd/include/rte_os.h | 1 +
 lib/eal/linux/include/rte_os.h   | 1 +
 lib/eal/windows/include/rte_os.h | 1 +
 3 files changed, 3 insertions(+)
lib/eal/freebsd/include/rte_os.h +1 -0
index 62e70dc15b..94b9275beb 100644
@@ -11,6 +11,7 @@
  */
 
 #include <pthread_np.h>
+#include <stdlib.h>            /* Declares alloca() */
 #include <sys/queue.h>
 
 /* These macros are compatible with system's sys/queue.h. */
lib/eal/linux/include/rte_os.h +1 -0
index 35c07c70cb..20eff0409a 100644
@@ -10,6 +10,7 @@
  * which is not supported natively or named differently in Linux.
  */
 
+#include <alloca.h>
 #include <sched.h>
 #include <sys/queue.h>
 
lib/eal/windows/include/rte_os.h +1 -0
index 9d69467aaa..d09adeb3b4 100644
@@ -13,6 +13,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <malloc.h>
 
 #include <sched.h>
 
Signature · 1 line
2.47.0.vfs.0.3
#312 lore raw

PATCH v13 2/21 eal/linux: remove use of VLAs

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

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);

---
 lib/eal/linux/eal_interrupts.c | 32 +++++++++++++++++++++++++++-----
 1 file changed, 27 insertions(+), 5 deletions(-)
lib/eal/linux/eal_interrupts.c +27 -5
index 6436f796eb..23039964fc 100644
@@ -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)
Signature · 1 line
2.47.0.vfs.0.3
#313 lore raw

PATCH v13 3/21 eal/common: remove use of VLAs

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

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.

---
 lib/eal/common/eal_common_proc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
lib/eal/common/eal_common_proc.c +3 -2
index d24093937c..201973c5db 100644
@@ -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);
Signature · 1 line
2.47.0.vfs.0.3
#314 lore raw

PATCH v13 4/21 ethdev: remove use of VLAs for Windows built code

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

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.

---
 lib/ethdev/rte_ethdev.c | 183 +++++++++++++++++++++++++---------------
 1 file changed, 113 insertions(+), 70 deletions(-)
lib/ethdev/rte_ethdev.c +113 -70
index 6413c54e3b..09cc4764c3 100644
@@ -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
Signature · 1 line
2.47.0.vfs.0.3
#315 lore raw

PATCH v13 5/21 hash: remove use of VLAs for Windows built code

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

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.

---
 lib/hash/rte_cuckoo_hash.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/hash/rte_cuckoo_hash.c +2 -2
index 9575e8aa0c..fc93182efe 100644
@@ -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);
Signature · 1 line
2.47.0.vfs.0.3
#316 lore raw

PATCH v13 6/21 hash/thash: remove use of VLAs for Windows built

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

1) ./lib/hash/rte_thash.c:774:9
: warning: ISO C90 forbids variable length array ‘tmp_tuple’

The tuple can exceed sizeof(union rte_thash_tuple), for example if any tunneling header is used in the RSS hash calculation.

The longest RSS hash key currently supported is 52 bytes. Technically, the longest tuple with such a key should be (52 - sizeof(uint32_t)), so this can be used as a size of the tmp_tuple array.

---
 lib/hash/rte_thash.c | 2 +-
 lib/hash/rte_thash.h | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)
lib/hash/rte_thash.c +1 -1
index 336c228e64..fa78787143 100644
@@ -761,7 +761,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_TUPLE_LEN_MAX];
 	unsigned int i, j, ret = 0;
 	uint32_t hash, adj_bits;
 	const uint8_t *hash_key;
lib/hash/rte_thash.h +7 -0
index c0af5968df..04f9f1875c 100644
@@ -121,6 +121,13 @@ __rte_internal
 uint32_t
 thash_get_rand_poly(uint32_t poly_degree);
 
+/**
+ * Longest RSS hash key currently supported
+ */
+#define RTE_THASH_KEY_LEN_MAX	52
+
+#define RTE_THASH_TUPLE_LEN_MAX (RTE_THASH_KEY_LEN_MAX - sizeof(uint32_t))
+
 /**
  * Prepare special converted key to use with rte_softrss_be()
  * @param orig
Signature · 1 line
2.47.0.vfs.0.3
#317 lore raw

PATCH v13 7/21 rcu: remove use of VLAs for Windows built code

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

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.

---
 lib/rcu/rte_rcu_qsbr.c | 7 ++++---
 lib/rcu/rte_rcu_qsbr.h | 5 +++++
 2 files changed, 9 insertions(+), 3 deletions(-)
lib/rcu/rte_rcu_qsbr.c +4 -3
index dbf31501a6..fe68d16326 100644
@@ -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,
lib/rcu/rte_rcu_qsbr.h +5 -0
index 550fadf56a..abcbd78914 100644
@@ -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.
Signature · 1 line
2.47.0.vfs.0.3
#318 lore raw

PATCH v13 8/21 gro: fix overwrite unprocessed packets

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

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")
---
 lib/gro/rte_gro.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/gro/rte_gro.c +1 -1
index d824eebd93..db86117609 100644
@@ -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) {
Signature · 1 line
2.47.0.vfs.0.3
#319 lore raw

PATCH v13 9/21 gro: remove use of VLAs

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

../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].

---
 lib/gro/rte_gro.c | 40 ++++++++++++++--------------------------
 1 file changed, 14 insertions(+), 26 deletions(-)
lib/gro/rte_gro.c +14 -26
index db86117609..6d5aadf32a 100644
@@ -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;
Signature · 1 line
2.47.0.vfs.0.3
#320 lore raw

PATCH v13 10/21 net/ixgbe: remove use of VLAs

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

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.

---
 drivers/net/ixgbe/ixgbe_ethdev.c          | 21 +++++++++++++--------
 drivers/net/ixgbe/ixgbe_rxtx_vec_common.h |  4 +++-
 2 files changed, 16 insertions(+), 9 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +13 -8
index 8bee97d191..47b0acd7b1 100644
@@ -3437,11 +3437,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,
@@ -3557,8 +3562,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);
@@ -3740,8 +3745,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);
 
drivers/net/ixgbe/ixgbe_rxtx_vec_common.h +3 -1
index a4d9ec9b08..c1cf0a581a 100644
@@ -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 */
Signature · 1 line
2.47.0.vfs.0.3
#321 lore raw

PATCH v13 11/21 net/ice: remove use of VLAs

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

../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.

---
 drivers/net/ice/ice_rxtx.c | 18 ++++++++++++------
 drivers/net/ice/ice_rxtx.h |  2 ++
 2 files changed, 14 insertions(+), 6 deletions(-)
drivers/net/ice/ice_rxtx.c +12 -6
index 0c7106c7e0..578453ec89 100644
@@ -1186,7 +1186,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;
@@ -1294,9 +1294,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) {
@@ -1305,6 +1310,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;
@@ -1883,7 +1890,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 -
@@ -1898,7 +1904,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;
@@ -1923,8 +1929,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;
 		}
drivers/net/ice/ice_rxtx.h +2 -0
index 45f25b3609..20ee325c2b 100644
@@ -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 */
Signature · 1 line
2.47.0.vfs.0.3
#322 lore raw

PATCH v13 12/21 app/testpmd: remove use of VLAs for Windows built

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 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(-)
app/test-pmd/cmdline.c +1 -1
index 7e0666e9f6..2897e44c34 100644
@@ -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) {
app/test-pmd/cmdline_flow.c +10 -5
index 9e4fc2d95d..e1720e54d7 100644
@@ -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;
app/test-pmd/config.c +9 -7
index 4e7fb69183..b19df95321 100644
@@ -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)
@@ -5551,7 +5552,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;
@@ -7292,7 +7293,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;
Signature · 1 line
2.47.0.vfs.0.3
#323 lore raw

PATCH v13 13/21 test: remove use of VLAs for Windows built code

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 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(-)
app/test/test.c +1 -1
index 680351f6a3..fd653cbbfd 100644
@@ -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;
app/test/test_cmdline_string.c +1 -1
index 97516c9400..e1cf86020f 100644
@@ -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 {
app/test/test_cryptodev.c +17 -17
index a33ef574cc..c05d377f0f 100644
@@ -2886,7 +2886,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;
@@ -2922,7 +2922,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;
 
@@ -3074,7 +3074,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;
@@ -9078,7 +9078,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;
@@ -12989,7 +12989,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;
@@ -13343,7 +13343,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");
@@ -13732,7 +13732,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));
@@ -13984,7 +13984,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);
@@ -14086,7 +14086,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);
@@ -15479,7 +15479,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;
@@ -16136,7 +16136,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);
 
@@ -16167,8 +16167,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);
@@ -16668,8 +16668,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);
@@ -16800,8 +16800,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);
app/test/test_cryptodev_blockcipher.c +2 -2
index 8e13cdfc7a..5a124bbb5e 100644
@@ -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;
app/test/test_cryptodev_crosscheck.c +1 -1
index c29b19cf6b..b9a53a430c 100644
@@ -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];
app/test/test_dmadev.c +6 -3
index 143e1bcd68..9cbb9a6552 100644
@@ -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;
app/test/test_hash.c +8 -6
index 65b9cad93c..16e63d2926 100644
@@ -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;
app/test/test_mempool.c +13 -12
index 3f7ba5872d..61385e096e 100644
@@ -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;
 
app/test/test_reorder.c +26 -22

155 lines not on this page · raw message

app/test/test_service_cores.c +4 -5
index 46ed9a1868..d95a71f80b 100644
@@ -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",
app/test/test_thash.c +3 -4
index b9c6e9118e..33b0c6adac 100644
@@ -565,9 +565,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;
@@ -575,9 +574,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");
 
Signature · 1 line
2.47.0.vfs.0.3
#324 lore raw

PATCH v13 14/21 common/idpf: remove use of VLAs for Windows built code

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 drivers/common/idpf/idpf_common_rxtx.c        | 2 +-
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/common/idpf/idpf_common_rxtx.c +1 -1
index a04e54ce26..e04ab40fa2 100644
@@ -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;
drivers/common/idpf/idpf_common_rxtx_avx512.c +4 -2
index b8450b03ae..63e10c542f 100644
@@ -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;
 
Signature · 1 line
2.47.0.vfs.0.3
#325 lore raw

PATCH v13 15/21 net/i40e: remove use of VLAs for Windows built code

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 drivers/net/i40e/i40e_testpmd.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/i40e/i40e_testpmd.c +2 -3
index b6ef5d6e42..21f596297b 100644
@@ -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) {
Signature · 1 line
2.47.0.vfs.0.3
#326 lore raw

PATCH v13 16/21 common/mlx5: remove use of VLAs for Windows built code

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 drivers/common/mlx5/mlx5_common.h    | 4 ++--
 drivers/common/mlx5/mlx5_devx_cmds.c | 7 +++----
 2 files changed, 5 insertions(+), 6 deletions(-)
drivers/common/mlx5/mlx5_common.h +2 -2
index 1abd1e8239..f29f06a86e 100644
@@ -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,
drivers/common/mlx5/mlx5_devx_cmds.c +3 -4
index a75f011750..804ee67cd6 100644
@@ -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),
Signature · 1 line
2.47.0.vfs.0.3
#327 lore raw

PATCH v13 17/21 net/mlx5: remove use of VLAs for Windows built code

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 drivers/net/mlx5/mlx5.c      | 5 ++---
 drivers/net/mlx5/mlx5_flow.c | 6 +++---
 2 files changed, 5 insertions(+), 6 deletions(-)
drivers/net/mlx5/mlx5.c +2 -3
index 6e4473e2f4..979e54686b 100644
@@ -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;
 
drivers/net/mlx5/mlx5_flow.c +3 -3
index 16ddd05448..37b5402447 100644
@@ -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;
 
@@ -8477,7 +8477,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,
Signature · 1 line
2.47.0.vfs.0.3
#328 lore raw

PATCH v13 18/21 build: enable vla warnings on Windows built code

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 config/meson.build | 4 ++++
 1 file changed, 4 insertions(+)
config/meson.build +4 -0
index 6aaad6d8a4..ebca19b4e5 100644
@@ -342,6 +342,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')
Signature · 1 line
2.47.0.vfs.0.3
#329 lore raw

PATCH v13 19/21 test: remove use of VLAs for Windows built code in bitset tests

In reply to 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).

---
 app/test/test_bitset.c          | 69 ++++++++++++++++++++-------------
 app/test/test_lcore_var_perf.c  |  2 +-
 app/test/test_reassembly_perf.c | 22 ++++++-----
 3 files changed, 56 insertions(+), 37 deletions(-)
app/test/test_bitset.c +43 -26
index 50b8bf0da4..45460204c1 100644
@@ -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);
@@ -131,8 +133,7 @@ test_set_clear_size(test_fun test_fun, set_fun set_fun, clear_fun clear_fun, siz
 	return TEST_SUCCESS;
 }
 
-#define RAND_ITERATIONS (10000)
-#define RAND_SET_MAX_SIZE (1000)
+#define RAND_ITERATIONS 10000
 
 static int
 test_set_clear_fun(test_fun test_fun, set_fun set_fun, clear_fun clear_fun)
@@ -168,10 +169,20 @@ 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);
+
+#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 110000)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Warray-bounds"
+#endif
 
+		/* gcc is giving false positives here when code is optimized */
 		rte_bitset_copy(reference, bitset, size);
 
+#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 110000)
+#pragma GCC diagnostic pop
+#endif
+
 		bool value = test_fun(bitset, i);
 
 		flip_fun(bitset, i);
@@ -282,13 +293,13 @@ find_clear(const bool *ary, size_t num_bools, size_t start, size_t len)
 	return find(ary, num_bools, start, len, false);
 }
 
-#define FFS_ITERATIONS (100)
+#define FFS_ITERATIONS 100
 
 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 +399,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 +644,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 +721,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 +739,8 @@ test_complement(void)
 	return TEST_SUCCESS;
 }
 
+#define SHIFT_SET_MAX_SIZE 500
+
 static int
 test_shift(bool right)
 {
@@ -734,12 +749,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 +803,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 +838,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));
app/test/test_lcore_var_perf.c +1 -1
index 41e29bbd49..5a74ce4808 100644
@@ -185,7 +185,7 @@ test_lcore_var_access_n(unsigned int num_mods)
 	double tls_latency;
 	double lazy_tls_latency;
 	double lvar_latency;
-	unsigned int mods[num_mods];
+	unsigned int mods[MAX_MODS];
 	unsigned int i;
 
 	for (i = 0; i < num_mods; i++)
app/test/test_reassembly_perf.c +12 -10
index 69cf029468..7d3c692547 100644
@@ -557,6 +557,8 @@ ipv4_outstanding_reassembly_perf(int8_t nb_frags, uint8_t fill_order,
 	return TEST_SUCCESS;
 }
 
+#define TEST_REASSEMBLY_ITERATIONS 4
+
 static int
 ipv4_reassembly_interleaved_flows_perf(uint8_t nb_frags)
 {
@@ -568,17 +570,17 @@ ipv4_reassembly_interleaved_flows_perf(uint8_t nb_frags)
 	uint64_t total_cyc = 0;
 	uint32_t i, j;
 
-	for (i = 0; i < flow_cnt; i += 4) {
+	for (i = 0; i < flow_cnt; i += TEST_REASSEMBLY_ITERATIONS) {
 		struct rte_mbuf *buf_out[4] = {NULL};
 		uint8_t reassembled = 0;
 		uint8_t nb_frags = 0;
 		uint8_t prev = 0;
 
-		for (j = 0; j < 4; j++)
+		for (j = 0; j < TEST_REASSEMBLY_ITERATIONS; j++)
 			nb_frags += frag_per_flow[i + j];
 
-		struct rte_mbuf *buf_arr[nb_frags];
-		for (j = 0; j < 4; j++) {
+		struct rte_mbuf *buf_arr[TEST_REASSEMBLY_ITERATIONS * MAX_FRAGMENTS];
+		for (j = 0; j < TEST_REASSEMBLY_ITERATIONS; j++) {
 			join_array(buf_arr, mbufs[i + j], prev,
 				   frag_per_flow[i + j]);
 			prev += frag_per_flow[i + j];
@@ -608,7 +610,7 @@ ipv4_reassembly_interleaved_flows_perf(uint8_t nb_frags)
 		total_cyc += rte_rdtsc_precise() - flow_tstamp;
 		if (reassembled != 4)
 			return TEST_FAILED;
-		for (j = 0; j < 4; j++) {
+		for (j = 0; j < TEST_REASSEMBLY_ITERATIONS; j++) {
 			memset(mbufs[i + j], 0,
 			       sizeof(struct rte_mbuf *) * MAX_FRAGMENTS);
 			mbufs[i + j][0] = buf_out[j];
@@ -779,17 +781,17 @@ ipv6_reassembly_interleaved_flows_perf(int8_t nb_frags)
 	uint64_t total_cyc = 0;
 	uint32_t i, j;
 
-	for (i = 0; i < flow_cnt; i += 4) {
+	for (i = 0; i < flow_cnt; i += TEST_REASSEMBLY_ITERATIONS) {
 		struct rte_mbuf *buf_out[4] = {NULL};
 		uint8_t reassembled = 0;
 		uint8_t nb_frags = 0;
 		uint8_t prev = 0;
 
-		for (j = 0; j < 4; j++)
+		for (j = 0; j < TEST_REASSEMBLY_ITERATIONS; j++)
 			nb_frags += frag_per_flow[i + j];
 
-		struct rte_mbuf *buf_arr[nb_frags];
-		for (j = 0; j < 4; j++) {
+		struct rte_mbuf *buf_arr[TEST_REASSEMBLY_ITERATIONS * MAX_FRAGMENTS];
+		for (j = 0; j < TEST_REASSEMBLY_ITERATIONS; j++) {
 			join_array(buf_arr, mbufs[i + j], prev,
 				   frag_per_flow[i + j]);
 			prev += frag_per_flow[i + j];
@@ -825,7 +827,7 @@ ipv6_reassembly_interleaved_flows_perf(int8_t nb_frags)
 		total_cyc += rte_rdtsc_precise() - flow_tstamp;
 		if (reassembled != 4)
 			return TEST_FAILED;
-		for (j = 0; j < 4; j++) {
+		for (j = 0; j < TEST_REASSEMBLY_ITERATIONS; j++) {
 			memset(mbufs[i + j], 0,
 			       sizeof(struct rte_mbuf *) * MAX_FRAGMENTS);
 			mbufs[i + j][0] = buf_out[j];
Signature · 1 line
2.47.0.vfs.0.3
#330 lore raw

PATCH v13 20/21 app/testpmd: remove use of VLAs for Windows built code in shared_rxq_fwd

In reply to 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.

---
 app/test-pmd/shared_rxq_fwd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test-pmd/shared_rxq_fwd.c +1 -1
index 623d62da88..b85830b90e 100644
@@ -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);
Signature · 1 line
2.47.0.vfs.0.3
#331 lore raw

PATCH v13 21/21 hash: remove use of VLAs by using standard arrays

In reply to Andre Muezerie

MSVC does not support VLAs, replace VLAs with standard C arrays.

---
 lib/hash/rte_thash_gf2_poly_math.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
lib/hash/rte_thash_gf2_poly_math.c +4 -5
index 1c62974e71..825da4382f 100644
@@ -8,6 +8,7 @@
 #include <rte_thash.h>
 #include <rte_log.h>
 
+#define MAX_POLY_DEGREE 32
 #define MAX_TOEPLITZ_KEY_LENGTH 64
 RTE_LOG_REGISTER_SUFFIX(thash_poly_logtype, thash_poly, INFO);
 #define RTE_LOGTYPE_HASH thash_poly_logtype
@@ -149,7 +150,7 @@ gf2_pow(uint32_t a, uint32_t pow, uint32_t r, int degree)
 static uint32_t
 __thash_get_rand_poly(int poly_degree)
 {
-	uint32_t roots[poly_degree];
+	uint32_t roots[MAX_POLY_DEGREE];
 	uint32_t rnd;
 	uint32_t ret_poly = 0;
 	int i, j;
@@ -194,9 +195,7 @@ __thash_get_rand_poly(int poly_degree)
 	 * Get coefficients of the polynomial for
 	 * (x - roots[0])(x - roots[1])...(x - roots[n])
 	 */
-	uint32_t poly_coefficients[poly_degree + 1];
-	for (i = 0; i <= poly_degree; i++)
-		poly_coefficients[i] = 0;
+	uint32_t poly_coefficients[MAX_POLY_DEGREE + 1] = {0};
 
 	poly_coefficients[0] = 1; /* highest degree term coefficient in the end */
 	for (i = 0; i < (int)poly_degree; i++) {
@@ -247,7 +246,7 @@ thash_get_rand_poly(uint32_t poly_degree)
 {
 	uint32_t ret_poly;
 
-	if (poly_degree > 32) {
+	if (poly_degree > MAX_POLY_DEGREE) {
 		HASH_LOG(ERR, "Wrong polynomial degree %d, must be in range [1, 32]", poly_degree);
 		return 0;
 	}
Signature · 1 line
2.47.0.vfs.0.3
#332 lore raw

RE: [PATCH v13 00/21] remove use of VLAs for Windows

In reply to Andre Muezerie
Quoted 93 lines

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.

v13:
* increase stack allocated buffer size in ipv4_reassembly_interleaved_flows_perf and ipv6_reassembly_interleaved_flows_perf to avoid STATUS_STACK_BUFFER_OVERRUN on Windows using MSVC

v12:
* update commit message for patch 06/21 to avoid warning

v11:
* add include stdlib.h for alloca() declaration on FreeBSD
* zero-initialize array without code loop
* increase maximum tuple length

v10:
* add ifdef to scope gcc's diagnostic error down to gcc only

v9:
* fix sender's email address
* fix gcc's diagnostic error string to make clang happy

v8:
* rebase
* reduce scope for disabling error "-Warray-bounds=" to only the place that needs it
* remove parentesis around numbers from defines in test_bitset.c

v7:
* remove use of VLA from new file which sneaked in during review

v6:
* remove use of VLA from new test code added recently
* fix title for patch 08/20

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 (3):
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
hash: remove use of VLAs by using standard arrays

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
gro: fix overwrite unprocessed packets
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

Quoted 1 line

--

One extra thing I would like to suggest: can we for each lib/driver/app/etc. we made VLA free add an '-Wvla' option into corresponding meson.build? To prevent people re-introducing VLA code.

Quoted 1 line

2.47.0.vfs.0.3

#333 lore raw

Re: [PATCH v13 00/21] remove use of VLAs for Windows

Quoted 93 lines · Konstantin Ananyev
Quoted 93 lines

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.

v13:
* increase stack allocated buffer size in ipv4_reassembly_interleaved_flows_perf and ipv6_reassembly_interleaved_flows_perf to avoid STATUS_STACK_BUFFER_OVERRUN on Windows using MSVC

v12:
* update commit message for patch 06/21 to avoid warning

v11:
* add include stdlib.h for alloca() declaration on FreeBSD
* zero-initialize array without code loop
* increase maximum tuple length

v10:
* add ifdef to scope gcc's diagnostic error down to gcc only

v9:
* fix sender's email address
* fix gcc's diagnostic error string to make clang happy

v8:
* rebase
* reduce scope for disabling error "-Warray-bounds=" to only the place that needs it
* remove parentesis around numbers from defines in test_bitset.c

v7:
* remove use of VLA from new file which sneaked in during review

v6:
* remove use of VLA from new test code added recently
* fix title for patch 08/20

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 (3):
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
hash: remove use of VLAs by using standard arrays

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
gro: fix overwrite unprocessed packets
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

Quoted 10 lines
Quoted 1 line

--

One extra thing I would like to suggest: can we for each lib/driver/app/etc. we made VLA free add an '-Wvla' option into corresponding meson.build? To prevent people re-introducing VLA code.

Quoted 1 line

2.47.0.vfs.0.3

Yes, I'll do so. It will add many small patches to the patchset though. I hope that is fine.

#334 lore raw

RE: [PATCH v13 00/21] remove use of VLAs for Windows

Quoted 104 lines · Konstantin Ananyev
Quoted 101 lines
Quoted 93 lines

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.

v13:
* increase stack allocated buffer size in ipv4_reassembly_interleaved_flows_perf and ipv6_reassembly_interleaved_flows_perf to avoid STATUS_STACK_BUFFER_OVERRUN on Windows using MSVC

v12:
* update commit message for patch 06/21 to avoid warning

v11:
* add include stdlib.h for alloca() declaration on FreeBSD
* zero-initialize array without code loop
* increase maximum tuple length

v10:
* add ifdef to scope gcc's diagnostic error down to gcc only

v9:
* fix sender's email address
* fix gcc's diagnostic error string to make clang happy

v8:
* rebase
* reduce scope for disabling error "-Warray-bounds=" to only the place that needs it
* remove parentesis around numbers from defines in test_bitset.c

v7:
* remove use of VLA from new file which sneaked in during review

v6:
* remove use of VLA from new test code added recently
* fix title for patch 08/20

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 (3):
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
hash: remove use of VLAs by using standard arrays

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
gro: fix overwrite unprocessed packets
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

Quoted 1 line

--

One extra thing I would like to suggest: can we for each lib/driver/app/etc. we made VLA free add an '-Wvla' option into corresponding meson.build? To prevent people re-introducing VLA code.

Quoted 5 lines
Quoted 2 lines
Quoted 1 line

2.47.0.vfs.0.3

Yes, I'll do so. It will add many small patches to the patchset though. I hope that is fine.

That's ok with me, hope tree maintainers will not complain too.
Another possible option - combine it with particular lib changes,
i.e. patch that fixing VLA usage in lib/hash can also enable -Wvla for it, and so on.

#335 lore raw

Re: [PATCH v13 00/21] remove use of VLAs for Windows

Quoted 107 lines · Konstantin Ananyev
Quoted 107 lines · Konstantin Ananyev
Quoted 103 lines
Quoted 93 lines

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.

v13:
* increase stack allocated buffer size in ipv4_reassembly_interleaved_flows_perf and ipv6_reassembly_interleaved_flows_perf to avoid STATUS_STACK_BUFFER_OVERRUN on Windows using MSVC

v12:
* update commit message for patch 06/21 to avoid warning

v11:
* add include stdlib.h for alloca() declaration on FreeBSD
* zero-initialize array without code loop
* increase maximum tuple length

v10:
* add ifdef to scope gcc's diagnostic error down to gcc only

v9:
* fix sender's email address
* fix gcc's diagnostic error string to make clang happy

v8:
* rebase
* reduce scope for disabling error "-Warray-bounds=" to only the place that needs it
* remove parentesis around numbers from defines in test_bitset.c

v7:
* remove use of VLA from new file which sneaked in during review

v6:
* remove use of VLA from new test code added recently
* fix title for patch 08/20

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 (3):
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
hash: remove use of VLAs by using standard arrays

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
gro: fix overwrite unprocessed packets
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

Quoted 1 line

--

One extra thing I would like to suggest: can we for each lib/driver/app/etc. we made VLA free add an '-Wvla' option into corresponding meson.build? To prevent people re-introducing VLA code.

Quoted 1 line

2.47.0.vfs.0.3

Quoted 8 lines
Quoted 2 lines

Yes, I'll do so. It will add many small patches to the patchset though. I hope that is fine.

That's ok with me, hope tree maintainers will not complain too.
Another possible option - combine it with particular lib changes,
i.e. patch that fixing VLA usage in lib/hash can also enable -Wvla for it, and so on.

The previous patchset added -Wvla to the code being built on Windows.

Your suggestion for adding -Wvla on Linux builds goes one step further and would give an earlier warning to people introducing VLAs in the code, which is a good thing. It also makes it easier to enable additional code in the Windows build in the future, as we will not be hitting so many VLAs anymore.

Patchset v14 containing your suggestions was sent out. Let me know if you have further comments about it.

#336 lore raw

v14 cover remove use of VLAs for Windows

In reply to Tyler Retzlaff

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.

v14:
* add -Wvla to meson build for directories that are VLA free under app, lib, drivers. This is to ensure that new VLAs are not added to these directories in the future.

v13:
* increase stack allocated buffer size in ipv4_reassembly_interleaved_flows_perf and ipv6_reassembly_interleaved_flows_perf to avoid STATUS_STACK_BUFFER_OVERRUN on Windows using MSVC

v12:
* update commit message for patch 06/21 to avoid warning

v11:
* add include stdlib.h for alloca() declaration on FreeBSD
* zero-initialize array without code loop
* increase maximum tuple length

v10:
* add ifdef to scope gcc's diagnostic error down to gcc only

v9:
* fix sender's email address
* fix gcc's diagnostic error string to make clang happy

v8:
* rebase
* reduce scope for disabling error "-Warray-bounds=" to only the place that needs it
* remove parentesis around numbers from defines in test_bitset.c

v7:
* remove use of VLA from new file which sneaked in during review

v6:
* remove use of VLA from new test code added recently
* fix title for patch 08/20

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 (63):
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
hash: remove use of VLAs by using standard arrays app/dumpcap: add compile warning about use of VLAs app/graph: add compile warning about use of VLAs app/test-cmdline: add compile warning about use of VLAs app/test-compress-perf: add compile warning about use of VLAs app/test-fib: add compile warning about use of VLAs app/test-gpudev: add compile warning about use of VLAs app/test-mldev: add compile warning about use of VLAs app/test-pipeline: add compile warning about use of VLAs app/test-regex: add compile warning about use of VLAs app/test-security-perf: add compile warning about use of VLAs lib/argparse: add compile warning about use of VLAs lib/bbdev: add compile warning about use of VLAs lib/bitratestats: add compile warning about use of VLAs lib/cfgfile: add compile warning about use of VLAs lib/cmdline: add compile warning about use of VLAs lib/compressdev: add compile warning about use of VLAs lib/cryptodev: add compile warning about use of VLAs lib/distributor: add compile warning about use of VLAs lib/dmadev: add compile warning about use of VLAs lib/efd: add compile warning about use of VLAs lib/fib: add compile warning about use of VLAs lib/gpudev: add compile warning about use of VLAs lib/gso: add compile warning about use of VLAs lib/ip_frag: add compile warning about use of VLAs lib/jobstats: add compile warning about use of VLAs lib/kvargs: add compile warning about use of VLAs lib/latencystats: add compile warning about use of VLAs lib/log: add compile warning about use of VLAs lib/lpm: add compile warning about use of VLAs lib/mbuf: add compile warning about use of VLAs lib/mempool: add compile warning about use of VLAs lib/meter: add compile warning about use of VLAs lib/metrics: add compile warning about use of VLAs lib/mldev: add compile warning about use of VLAs lib/net: add compile warning about use of VLAs lib/node: add compile warning about use of VLAs lib/pcapng: add compile warning about use of VLAs lib/pci: add compile warning about use of VLAs lib/port: add compile warning about use of VLAs lib/ptr_compress: add compile warning about use of VLAs lib/rawdev: add compile warning about use of VLAs lib/reorder: add compile warning about use of VLAs lib/rib: add compile warning about use of VLAs lib/ring: add compile warning about use of VLAs lib/sched: add compile warning about use of VLAs lib/security: add compile warning about use of VLAs lib/stack: add compile warning about use of VLAs lib/telemetry: add compile warning about use of VLAs lib/timer: add compile warning about use of VLAs drivers/baseband: add compile warning about use of VLAs drivers/bus: add compile warning about use of VLAs drivers/common: add compile warning about use of VLAs drivers/compress: add compile warning about use of VLAs drivers/gpu: add compile warning about use of VLAs drivers/mempool: add compile warning about use of VLAs drivers/ml: add compile warning about use of VLAs drivers/power: add compile warning about use of VLAs drivers/raw: add compile warning about use of VLAs drivers/regex: add compile warning about use of VLAs drivers/vdpa: add compile warning about use of VLAs

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
gro: fix overwrite unprocessed packets
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/dumpcap/meson.build                       |   8 +
 app/graph/meson.build                         |   8 +
 app/test-cmdline/meson.build                  |   8 +
 app/test-compress-perf/meson.build            |   8 +
 app/test-fib/meson.build                      |   8 +
 app/test-gpudev/meson.build                   |   8 +
 app/test-mldev/meson.build                    |   8 +
 app/test-pipeline/meson.build                 |   8 +
 app/test-pmd/cmdline.c                        |   2 +-
 app/test-pmd/cmdline_flow.c                   |  15 +-
 app/test-pmd/config.c                         |  16 +-
 app/test-pmd/meson.build                      |  10 +-
 app/test-pmd/shared_rxq_fwd.c                 |   2 +-
 app/test-regex/meson.build                    |   8 +
 app/test-security-perf/meson.build            |   8 +
 app/test/test.c                               |   2 +-
 app/test/test_bitset.c                        |  69 ++++---
 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_lcore_var_perf.c                |   2 +-
 app/test/test_mempool.c                       |  25 +--
 app/test/test_reassembly_perf.c               |  22 ++-
 app/test/test_reorder.c                       |  48 ++---
 app/test/test_service_cores.c                 |   9 +-
 app/test/test_thash.c                         |   7 +-
 config/meson.build                            |   4 +
 drivers/baseband/meson.build                  |   8 +
 drivers/bus/meson.build                       |   8 +
 drivers/common/idpf/idpf_common_rxtx.c        |   2 +-
 drivers/common/idpf/idpf_common_rxtx_avx512.c |   6 +-
 drivers/common/meson.build                    |   8 +
 drivers/common/mlx5/meson.build               |   1 +
 drivers/common/mlx5/mlx5_common.h             |   4 +-
 drivers/common/mlx5/mlx5_devx_cmds.c          |   7 +-
 drivers/common/nfp/meson.build                |   8 +
 drivers/common/nitrox/meson.build             |   8 +
 drivers/common/qat/meson.build                |   8 +
 drivers/common/sfc_efx/meson.build            |   1 +
 drivers/compress/meson.build                  |   8 +
 drivers/gpu/meson.build                       |   8 +
 drivers/mempool/meson.build                   |   8 +
 drivers/ml/meson.build                        |   8 +
 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/meson.build                       |   8 +
 drivers/net/mlx5/mlx5.c                       |   5 +-
 drivers/net/mlx5/mlx5_flow.c                  |   6 +-
 drivers/power/meson.build                     |   8 +
 drivers/raw/meson.build                       |   8 +
 drivers/regex/meson.build                     |   8 +
 drivers/vdpa/meson.build                      |   8 +
 lib/argparse/meson.build                      |   8 +
 lib/bbdev/meson.build                         |   8 +
 lib/bitratestats/meson.build                  |   8 +
 lib/cfgfile/meson.build                       |   8 +
 lib/cmdline/meson.build                       |   8 +
 lib/compressdev/meson.build                   |   8 +
 lib/cryptodev/meson.build                     |   8 +
 lib/distributor/meson.build                   |   8 +
 lib/dmadev/meson.build                        |   8 +
 lib/eal/common/eal_common_proc.c              |   5 +-
 lib/eal/freebsd/include/rte_os.h              |   1 +
 lib/eal/linux/eal_interrupts.c                |  32 ++-
 lib/eal/linux/include/rte_os.h                |   1 +
 lib/eal/meson.build                           |   8 +
 lib/eal/windows/include/rte_os.h              |   1 +
 lib/efd/meson.build                           |   8 +
 lib/ethdev/meson.build                        |   8 +
 lib/ethdev/rte_ethdev.c                       | 183 +++++++++++-------
 lib/fib/meson.build                           |   8 +
 lib/gpudev/meson.build                        |   8 +
 lib/gro/meson.build                           |   8 +
 lib/gro/rte_gro.c                             |  42 ++--
 lib/gso/meson.build                           |   8 +
 lib/hash/meson.build                          |   8 +
 lib/hash/rte_cuckoo_hash.c                    |   4 +-
 lib/hash/rte_thash.c                          |   2 +-
 lib/hash/rte_thash.h                          |   7 +
 lib/hash/rte_thash_gf2_poly_math.c            |   9 +-
 lib/ip_frag/meson.build                       |   8 +
 lib/jobstats/meson.build                      |   8 +
 lib/kvargs/meson.build                        |   8 +
 lib/latencystats/meson.build                  |   8 +
 lib/log/meson.build                           |   8 +
 lib/lpm/meson.build                           |   8 +
 lib/mbuf/meson.build                          |   8 +
 lib/mempool/meson.build                       |   2 +-
 lib/meter/meson.build                         |   8 +
 lib/metrics/meson.build                       |   8 +
 lib/mldev/meson.build                         |   8 +
 lib/net/meson.build                           |   8 +
 lib/node/meson.build                          |   8 +
 lib/pcapng/meson.build                        |   8 +
 lib/pci/meson.build                           |   8 +
 lib/port/meson.build                          |   8 +
 lib/ptr_compress/meson.build                  |   8 +
 lib/rawdev/meson.build                        |   8 +
 lib/rcu/meson.build                           |   8 +
 lib/rcu/rte_rcu_qsbr.c                        |   7 +-
 lib/rcu/rte_rcu_qsbr.h                        |   5 +
 lib/reorder/meson.build                       |   8 +
 lib/rib/meson.build                           |   8 +
 lib/ring/meson.build                          |   8 +
 lib/sched/meson.build                         |   8 +
 lib/security/meson.build                      |   8 +
 lib/stack/meson.build                         |   8 +
 lib/telemetry/meson.build                     |   8 +
 lib/timer/meson.build                         |   8 +
 115 files changed, 950 insertions(+), 275 deletions(-)

--
2.47.0.vfs.0.3

#337 lore raw

PATCH v14 1/81 eal: include header required for alloca

From: Tyler Retzlaff <[email protected]>

Include alloca.h for Linux and malloc.h for Windows to get declaration of alloca().

---
 lib/eal/freebsd/include/rte_os.h | 1 +
 lib/eal/linux/include/rte_os.h   | 1 +
 lib/eal/windows/include/rte_os.h | 1 +
 3 files changed, 3 insertions(+)
lib/eal/freebsd/include/rte_os.h +1 -0
index 62e70dc15b..94b9275beb 100644
@@ -11,6 +11,7 @@
  */
 
 #include <pthread_np.h>
+#include <stdlib.h>            /* Declares alloca() */
 #include <sys/queue.h>
 
 /* These macros are compatible with system's sys/queue.h. */
lib/eal/linux/include/rte_os.h +1 -0
index 35c07c70cb..20eff0409a 100644
@@ -10,6 +10,7 @@
  * which is not supported natively or named differently in Linux.
  */
 
+#include <alloca.h>
 #include <sched.h>
 #include <sys/queue.h>
 
lib/eal/windows/include/rte_os.h +1 -0
index 9d69467aaa..d09adeb3b4 100644
@@ -13,6 +13,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <malloc.h>
 
 #include <sched.h>
 
Signature · 1 line
2.47.0.vfs.0.3
#338 lore raw

PATCH v14 2/81 eal/linux: remove use of VLAs

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

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);

---
 lib/eal/linux/eal_interrupts.c | 32 +++++++++++++++++++++++++++-----
 1 file changed, 27 insertions(+), 5 deletions(-)
lib/eal/linux/eal_interrupts.c +27 -5
index 6436f796eb..23039964fc 100644
@@ -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)
Signature · 1 line
2.47.0.vfs.0.3
#339 lore raw

PATCH v14 3/81 eal/common: remove use of VLAs

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

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.

---
 lib/eal/common/eal_common_proc.c | 5 +++--
 lib/eal/meson.build              | 8 ++++++++
 2 files changed, 11 insertions(+), 2 deletions(-)
lib/eal/common/eal_common_proc.c +3 -2
index d24093937c..201973c5db 100644
@@ -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);
lib/eal/meson.build +8 -0
index e1d6c4cf17..352db049e9 100644
@@ -31,3 +31,11 @@ endif
 if is_freebsd
     annotate_locks = false
 endif
+
+warning_flags = ['-Wvla']
+
+foreach arg: warning_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#340 lore raw

Re: [PATCH v14 03/81] eal/common: remove use of VLAs

Quoted 7 lines · On Fri, 10 Jan 2025 12:22:22 -0800 Andre Muezerie…
lib/eal/meson.build +0 -0
index e1d6c4cf17..352db049e9 100644
@@ -31,3 +31,11 @@ endif
 if is_freebsd

lib/eal/meson.build endif · line 41

Quoted 10 lines
lib/eal/meson.build +8 -0
     annotate_locks = false
 endif
+
+warning_flags = ['-Wvla']
+
+foreach arg: warning_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach

Could we enable it for all libs and only turn it off as required?

#341 lore raw

Re: [PATCH v14 03/81] eal/common: remove use of VLAs

Quoted 14 lines · Stephen Hemminger
Quoted 11 lines · On Fri, 10 Jan 2025 12:22:22 -0800 Andre Muezerie…
lib/eal/meson.build +3 -0
index e1d6c4cf17..352db049e9 100644
@@ -31,3 +31,11 @@ endif
 if is_freebsd
     annotate_locks = false
 endif
+
+warning_flags = ['-Wvla']
+
Quoted 8 lines

lib/eal/meson.build endif · line 41

Quoted 6 lines
lib/eal/meson.build +5 -0
+foreach arg: warning_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach

Could we enable it for all libs and only turn it off as required?

Yes. Although the data types in meson are additive only, we can add -Wno-vla to cancel a -Wvla already present. Let me send out a new series with this change.

#342 lore raw

Re: [PATCH v14 03/81] eal/common: remove use of VLAs

Quoted 24 lines · Andre Muezerie
Quoted 14 lines · Stephen Hemminger
Quoted 11 lines · On Fri, 10 Jan 2025 12:22:22 -0800 Andre Muezerie…
lib/eal/meson.build +3 -0
index e1d6c4cf17..352db049e9 100644
@@ -31,3 +31,11 @@ endif
 if is_freebsd
     annotate_locks = false
 endif
+
+warning_flags = ['-Wvla']
+
Quoted 8 lines

lib/eal/meson.build endif · line 41

Quoted 6 lines
lib/eal/meson.build +5 -0
+foreach arg: warning_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach

Could we enable it for all libs and only turn it off as required?

Quoted 3 lines

Yes. Although the data types in meson are additive only, we can add -Wno-vla to cancel a -Wvla already present. Let me send out a new series with this change.

Series v16 has the changes proposed.

There was only one failure reported now, which seems infra-related:
"The requested resource was not found on this server":
https://mails.dpdk.org/archives/test-report/2025-January/842300.html

Let me know if any action is needed from my side.

Thanks,

Andre Muezerie

#343 lore raw

PATCH v14 4/81 ethdev: remove use of VLAs for Windows built code

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

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.

---
 lib/ethdev/meson.build  |   8 ++
 lib/ethdev/rte_ethdev.c | 183 +++++++++++++++++++++++++---------------
 2 files changed, 121 insertions(+), 70 deletions(-)
lib/ethdev/meson.build +8 -0
index f1d2586591..f5faac8bba 100644
@@ -62,3 +62,11 @@ endif
 if get_option('buildtype').contains('debug')
     cflags += ['-DRTE_FLOW_DEBUG']
 endif
+
+warning_flags = ['-Wvla']
+
+foreach arg: warning_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
lib/ethdev/rte_ethdev.c +113 -70

300 lines not on this page · raw message

Signature · 1 line
2.47.0.vfs.0.3
#344 lore raw

PATCH v14 5/81 hash: remove use of VLAs for Windows built code

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

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.

---
 lib/hash/rte_cuckoo_hash.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/hash/rte_cuckoo_hash.c +2 -2
index 9575e8aa0c..fc93182efe 100644
@@ -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);
Signature · 1 line
2.47.0.vfs.0.3
#345 lore raw

PATCH v14 6/81 hash/thash: remove use of VLAs for Windows built

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

1) ./lib/hash/rte_thash.c:774:9
: warning: ISO C90 forbids variable length array ‘tmp_tuple’

The tuple can exceed sizeof(union rte_thash_tuple), for example if any tunneling header is used in the RSS hash calculation.

The longest RSS hash key currently supported is 52 bytes. Technically, the longest tuple with such a key should be (52 - sizeof(uint32_t)), so this can be used as a size of the tmp_tuple array.

---
 lib/hash/rte_thash.c | 2 +-
 lib/hash/rte_thash.h | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)
lib/hash/rte_thash.c +1 -1
index 336c228e64..fa78787143 100644
@@ -761,7 +761,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_TUPLE_LEN_MAX];
 	unsigned int i, j, ret = 0;
 	uint32_t hash, adj_bits;
 	const uint8_t *hash_key;
lib/hash/rte_thash.h +7 -0
index c0af5968df..04f9f1875c 100644
@@ -121,6 +121,13 @@ __rte_internal
 uint32_t
 thash_get_rand_poly(uint32_t poly_degree);
 
+/**
+ * Longest RSS hash key currently supported
+ */
+#define RTE_THASH_KEY_LEN_MAX	52
+
+#define RTE_THASH_TUPLE_LEN_MAX (RTE_THASH_KEY_LEN_MAX - sizeof(uint32_t))
+
 /**
  * Prepare special converted key to use with rte_softrss_be()
  * @param orig
Signature · 1 line
2.47.0.vfs.0.3
#346 lore raw

PATCH v14 7/81 rcu: remove use of VLAs for Windows built code

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

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.

---
 lib/rcu/meson.build    | 8 ++++++++
 lib/rcu/rte_rcu_qsbr.c | 7 ++++---
 lib/rcu/rte_rcu_qsbr.h | 5 +++++
 3 files changed, 17 insertions(+), 3 deletions(-)
lib/rcu/meson.build +8 -0
index 71143f5210..bbe73aa72f 100644
@@ -11,3 +11,11 @@ sources = files('rte_rcu_qsbr.c')
 headers = files('rte_rcu_qsbr.h')
 
 deps += ['ring']
+
+warning_flags = ['-Wvla']
+
+foreach arg: warning_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
lib/rcu/rte_rcu_qsbr.c +4 -3
index dbf31501a6..fe68d16326 100644
@@ -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,
lib/rcu/rte_rcu_qsbr.h +5 -0
index 550fadf56a..abcbd78914 100644
@@ -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.
Signature · 1 line
2.47.0.vfs.0.3
#347 lore raw

PATCH v14 8/81 gro: fix overwrite unprocessed packets

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

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")
---
 lib/gro/rte_gro.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/gro/rte_gro.c +1 -1
index d824eebd93..db86117609 100644
@@ -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) {
Signature · 1 line
2.47.0.vfs.0.3
#348 lore raw

PATCH v14 9/81 gro: remove use of VLAs

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

../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].

---
 lib/gro/meson.build |  8 ++++++++
 lib/gro/rte_gro.c   | 40 ++++++++++++++--------------------------
 2 files changed, 22 insertions(+), 26 deletions(-)
lib/gro/meson.build +8 -0
index dbce05220d..83b97e2022 100644
@@ -11,3 +11,11 @@ sources = files(
 )
 headers = files('rte_gro.h')
 deps += ['ethdev']
+
+warning_flags = ['-Wvla']
+
+foreach arg: warning_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
lib/gro/rte_gro.c +14 -26
index db86117609..6d5aadf32a 100644
@@ -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;
Signature · 1 line
2.47.0.vfs.0.3
#349 lore raw

PATCH v14 10/81 net/ixgbe: remove use of VLAs

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

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.

---
 drivers/net/ixgbe/ixgbe_ethdev.c          | 21 +++++++++++++--------
 drivers/net/ixgbe/ixgbe_rxtx_vec_common.h |  4 +++-
 2 files changed, 16 insertions(+), 9 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +13 -8
index 8bee97d191..47b0acd7b1 100644
@@ -3437,11 +3437,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,
@@ -3557,8 +3562,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);
@@ -3740,8 +3745,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);
 
drivers/net/ixgbe/ixgbe_rxtx_vec_common.h +3 -1
index a4d9ec9b08..c1cf0a581a 100644
@@ -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 */
Signature · 1 line
2.47.0.vfs.0.3
#350 lore raw

PATCH v14 11/81 net/ice: remove use of VLAs

In reply to Andre Muezerie

From: Konstantin Ananyev <[email protected]>

../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.

---
 drivers/net/ice/ice_rxtx.c | 18 ++++++++++++------
 drivers/net/ice/ice_rxtx.h |  2 ++
 2 files changed, 14 insertions(+), 6 deletions(-)
drivers/net/ice/ice_rxtx.c +12 -6
index 0c7106c7e0..578453ec89 100644
@@ -1186,7 +1186,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;
@@ -1294,9 +1294,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) {
@@ -1305,6 +1310,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;
@@ -1883,7 +1890,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 -
@@ -1898,7 +1904,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;
@@ -1923,8 +1929,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;
 		}
drivers/net/ice/ice_rxtx.h +2 -0
index 45f25b3609..20ee325c2b 100644
@@ -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 */
Signature · 1 line
2.47.0.vfs.0.3
#351 lore raw

PATCH v14 12/81 app/testpmd: remove use of VLAs for Windows built

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 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(-)
app/test-pmd/cmdline.c +1 -1
index 7e0666e9f6..2897e44c34 100644
@@ -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) {
app/test-pmd/cmdline_flow.c +10 -5
index 9e4fc2d95d..e1720e54d7 100644
@@ -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;
app/test-pmd/config.c +9 -7
index 4e7fb69183..b19df95321 100644
@@ -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)
@@ -5551,7 +5552,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;
@@ -7292,7 +7293,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;
Signature · 1 line
2.47.0.vfs.0.3
#352 lore raw

PATCH v14 13/81 test: remove use of VLAs for Windows built code

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 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(-)
app/test/test.c +1 -1
index 680351f6a3..fd653cbbfd 100644
@@ -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;
app/test/test_cmdline_string.c +1 -1
index 97516c9400..e1cf86020f 100644
@@ -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 {
app/test/test_cryptodev.c +17 -17
index a33ef574cc..c05d377f0f 100644
@@ -2886,7 +2886,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;
@@ -2922,7 +2922,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;
 
@@ -3074,7 +3074,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;
@@ -9078,7 +9078,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;
@@ -12989,7 +12989,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;
@@ -13343,7 +13343,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");
@@ -13732,7 +13732,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));
@@ -13984,7 +13984,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);
@@ -14086,7 +14086,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);
@@ -15479,7 +15479,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;
@@ -16136,7 +16136,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);
 
@@ -16167,8 +16167,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);
@@ -16668,8 +16668,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);
@@ -16800,8 +16800,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);
app/test/test_cryptodev_blockcipher.c +2 -2
index 8e13cdfc7a..5a124bbb5e 100644
@@ -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;
app/test/test_cryptodev_crosscheck.c +1 -1
index c29b19cf6b..b9a53a430c 100644
@@ -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];
app/test/test_dmadev.c +6 -3
index 143e1bcd68..9cbb9a6552 100644
@@ -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;
app/test/test_hash.c +8 -6
index 65b9cad93c..16e63d2926 100644
@@ -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;
app/test/test_mempool.c +13 -12
index 3f7ba5872d..61385e096e 100644
@@ -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;
 
app/test/test_reorder.c +26 -22

155 lines not on this page · raw message

app/test/test_service_cores.c +4 -5
index 46ed9a1868..d95a71f80b 100644
@@ -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",
app/test/test_thash.c +3 -4
index b9c6e9118e..33b0c6adac 100644
@@ -565,9 +565,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;
@@ -575,9 +574,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");
 
Signature · 1 line
2.47.0.vfs.0.3
#353 lore raw

PATCH v14 14/81 common/idpf: remove use of VLAs for Windows built code

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 drivers/common/idpf/idpf_common_rxtx.c        | 2 +-
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/common/idpf/idpf_common_rxtx.c +1 -1
index a04e54ce26..e04ab40fa2 100644
@@ -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;
drivers/common/idpf/idpf_common_rxtx_avx512.c +4 -2
index b8450b03ae..63e10c542f 100644
@@ -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;
 
Signature · 1 line
2.47.0.vfs.0.3
#354 lore raw

PATCH v14 15/81 net/i40e: remove use of VLAs for Windows built code

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 drivers/net/i40e/i40e_testpmd.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/i40e/i40e_testpmd.c +2 -3
index b6ef5d6e42..21f596297b 100644
@@ -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) {
Signature · 1 line
2.47.0.vfs.0.3
#355 lore raw

PATCH v14 16/81 common/mlx5: remove use of VLAs for Windows built code

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 drivers/common/meson.build           | 8 ++++++++
 drivers/common/mlx5/mlx5_common.h    | 4 ++--
 drivers/common/mlx5/mlx5_devx_cmds.c | 7 +++----
 3 files changed, 13 insertions(+), 6 deletions(-)
drivers/common/meson.build +8 -0
index 8734af36aa..79ba0a3001 100644
@@ -11,3 +11,11 @@ drivers = [
         'mvep',
         'octeontx',
 ]
+
+warning_flags = ['-Wvla']
+
+foreach arg: warning_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
drivers/common/mlx5/mlx5_common.h +2 -2
index 1abd1e8239..f29f06a86e 100644
@@ -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,
drivers/common/mlx5/mlx5_devx_cmds.c +3 -4
index a75f011750..804ee67cd6 100644
@@ -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),
Signature · 1 line
2.47.0.vfs.0.3
#356 lore raw

PATCH v14 17/81 net/mlx5: remove use of VLAs for Windows built code

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 drivers/net/meson.build      | 8 ++++++++
 drivers/net/mlx5/mlx5.c      | 5 ++---
 drivers/net/mlx5/mlx5_flow.c | 6 +++---
 3 files changed, 13 insertions(+), 6 deletions(-)
drivers/net/meson.build +8 -0
index dafd637ba4..170e7339e5 100644
@@ -68,3 +68,11 @@ drivers = [
 std_deps = ['ethdev', 'kvargs'] # 'ethdev' also pulls in mbuf, net, eal etc
 std_deps += ['bus_pci']         # very many PMDs depend on PCI, so make std
 std_deps += ['bus_vdev']        # same with vdev bus
+
+warning_flags = ['-Wvla']
+
+foreach arg: warning_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
drivers/net/mlx5/mlx5.c +2 -3
index 6e4473e2f4..979e54686b 100644
@@ -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;
 
drivers/net/mlx5/mlx5_flow.c +3 -3
index 16ddd05448..37b5402447 100644
@@ -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;
 
@@ -8477,7 +8477,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,
Signature · 1 line
2.47.0.vfs.0.3
#357 lore raw

PATCH v14 18/81 build: enable vla warnings on Windows built code

In reply to Andre Muezerie

From: Tyler Retzlaff <[email protected]>

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.

---
 config/meson.build | 4 ++++
 1 file changed, 4 insertions(+)
config/meson.build +4 -0
index 6aaad6d8a4..ebca19b4e5 100644
@@ -342,6 +342,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')
Signature · 1 line
2.47.0.vfs.0.3
#358 lore raw

PATCH v14 19/81 test: remove use of VLAs for Windows built code in bitset tests

In reply to 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).

---
 app/test/test_bitset.c          | 69 ++++++++++++++++++++-------------
 app/test/test_lcore_var_perf.c  |  2 +-
 app/test/test_reassembly_perf.c | 22 ++++++-----
 3 files changed, 56 insertions(+), 37 deletions(-)
app/test/test_bitset.c +43 -26
index 50b8bf0da4..45460204c1 100644
@@ -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);
@@ -131,8 +133,7 @@ test_set_clear_size(test_fun test_fun, set_fun set_fun, clear_fun clear_fun, siz
 	return TEST_SUCCESS;
 }
 
-#define RAND_ITERATIONS (10000)
-#define RAND_SET_MAX_SIZE (1000)
+#define RAND_ITERATIONS 10000
 
 static int
 test_set_clear_fun(test_fun test_fun, set_fun set_fun, clear_fun clear_fun)
@@ -168,10 +169,20 @@ 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);
+
+#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 110000)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Warray-bounds"
+#endif
 
+		/* gcc is giving false positives here when code is optimized */
 		rte_bitset_copy(reference, bitset, size);
 
+#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 110000)
+#pragma GCC diagnostic pop
+#endif
+
 		bool value = test_fun(bitset, i);
 
 		flip_fun(bitset, i);
@@ -282,13 +293,13 @@ find_clear(const bool *ary, size_t num_bools, size_t start, size_t len)
 	return find(ary, num_bools, start, len, false);
 }
 
-#define FFS_ITERATIONS (100)
+#define FFS_ITERATIONS 100
 
 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 +399,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 +644,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 +721,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 +739,8 @@ test_complement(void)
 	return TEST_SUCCESS;
 }
 
+#define SHIFT_SET_MAX_SIZE 500
+
 static int
 test_shift(bool right)
 {
@@ -734,12 +749,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 +803,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 +838,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));
app/test/test_lcore_var_perf.c +1 -1
index 41e29bbd49..5a74ce4808 100644
@@ -185,7 +185,7 @@ test_lcore_var_access_n(unsigned int num_mods)
 	double tls_latency;
 	double lazy_tls_latency;
 	double lvar_latency;
-	unsigned int mods[num_mods];
+	unsigned int mods[MAX_MODS];
 	unsigned int i;
 
 	for (i = 0; i < num_mods; i++)
app/test/test_reassembly_perf.c +12 -10
index 69cf029468..7d3c692547 100644
@@ -557,6 +557,8 @@ ipv4_outstanding_reassembly_perf(int8_t nb_frags, uint8_t fill_order,
 	return TEST_SUCCESS;
 }
 
+#define TEST_REASSEMBLY_ITERATIONS 4
+
 static int
 ipv4_reassembly_interleaved_flows_perf(uint8_t nb_frags)
 {
@@ -568,17 +570,17 @@ ipv4_reassembly_interleaved_flows_perf(uint8_t nb_frags)
 	uint64_t total_cyc = 0;
 	uint32_t i, j;
 
-	for (i = 0; i < flow_cnt; i += 4) {
+	for (i = 0; i < flow_cnt; i += TEST_REASSEMBLY_ITERATIONS) {
 		struct rte_mbuf *buf_out[4] = {NULL};
 		uint8_t reassembled = 0;
 		uint8_t nb_frags = 0;
 		uint8_t prev = 0;
 
-		for (j = 0; j < 4; j++)
+		for (j = 0; j < TEST_REASSEMBLY_ITERATIONS; j++)
 			nb_frags += frag_per_flow[i + j];
 
-		struct rte_mbuf *buf_arr[nb_frags];
-		for (j = 0; j < 4; j++) {
+		struct rte_mbuf *buf_arr[TEST_REASSEMBLY_ITERATIONS * MAX_FRAGMENTS];
+		for (j = 0; j < TEST_REASSEMBLY_ITERATIONS; j++) {
 			join_array(buf_arr, mbufs[i + j], prev,
 				   frag_per_flow[i + j]);
 			prev += frag_per_flow[i + j];
@@ -608,7 +610,7 @@ ipv4_reassembly_interleaved_flows_perf(uint8_t nb_frags)
 		total_cyc += rte_rdtsc_precise() - flow_tstamp;
 		if (reassembled != 4)
 			return TEST_FAILED;
-		for (j = 0; j < 4; j++) {
+		for (j = 0; j < TEST_REASSEMBLY_ITERATIONS; j++) {
 			memset(mbufs[i + j], 0,
 			       sizeof(struct rte_mbuf *) * MAX_FRAGMENTS);
 			mbufs[i + j][0] = buf_out[j];
@@ -779,17 +781,17 @@ ipv6_reassembly_interleaved_flows_perf(int8_t nb_frags)
 	uint64_t total_cyc = 0;
 	uint32_t i, j;
 
-	for (i = 0; i < flow_cnt; i += 4) {
+	for (i = 0; i < flow_cnt; i += TEST_REASSEMBLY_ITERATIONS) {
 		struct rte_mbuf *buf_out[4] = {NULL};
 		uint8_t reassembled = 0;
 		uint8_t nb_frags = 0;
 		uint8_t prev = 0;
 
-		for (j = 0; j < 4; j++)
+		for (j = 0; j < TEST_REASSEMBLY_ITERATIONS; j++)
 			nb_frags += frag_per_flow[i + j];
 
-		struct rte_mbuf *buf_arr[nb_frags];
-		for (j = 0; j < 4; j++) {
+		struct rte_mbuf *buf_arr[TEST_REASSEMBLY_ITERATIONS * MAX_FRAGMENTS];
+		for (j = 0; j < TEST_REASSEMBLY_ITERATIONS; j++) {
 			join_array(buf_arr, mbufs[i + j], prev,
 				   frag_per_flow[i + j]);
 			prev += frag_per_flow[i + j];
@@ -825,7 +827,7 @@ ipv6_reassembly_interleaved_flows_perf(int8_t nb_frags)
 		total_cyc += rte_rdtsc_precise() - flow_tstamp;
 		if (reassembled != 4)
 			return TEST_FAILED;
-		for (j = 0; j < 4; j++) {
+		for (j = 0; j < TEST_REASSEMBLY_ITERATIONS; j++) {
 			memset(mbufs[i + j], 0,
 			       sizeof(struct rte_mbuf *) * MAX_FRAGMENTS);
 			mbufs[i + j][0] = buf_out[j];
Signature · 1 line
2.47.0.vfs.0.3
#359 lore raw

PATCH v14 20/81 app/testpmd: remove use of VLAs for Windows built code in shared_rxq_fwd

In reply to 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.

---
 app/test-pmd/meson.build      | 10 +++++++++-
 app/test-pmd/shared_rxq_fwd.c |  2 +-
 2 files changed, 10 insertions(+), 2 deletions(-)
app/test-pmd/meson.build +9 -1
index f1c36529b4..efd1eab0b0 100644
@@ -3,7 +3,15 @@
 
 # override default name to drop the hyphen
 name = 'testpmd'
-cflags += '-Wno-deprecated-declarations'
+
+warning_flags = ['-Wno-deprecated-declarations', '-Wvla']
+
+foreach arg: warning_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
+
 sources = files(
         '5tswap.c',
         'cmdline.c',
app/test-pmd/shared_rxq_fwd.c +1 -1
index 623d62da88..b85830b90e 100644
@@ -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);
Signature · 1 line
2.47.0.vfs.0.3
#360 lore raw

PATCH v14 21/81 hash: remove use of VLAs by using standard arrays

In reply to Andre Muezerie

MSVC does not support VLAs, replace VLAs with standard C arrays.

---
 lib/hash/meson.build               | 8 ++++++++
 lib/hash/rte_thash_gf2_poly_math.c | 9 ++++-----
 2 files changed, 12 insertions(+), 5 deletions(-)
lib/hash/meson.build +8 -0
index 7ce504ee8b..289c6a3543 100644
@@ -29,3 +29,11 @@ sources = files(
 deps += ['net']
 deps += ['ring']
 deps += ['rcu']
+
+warning_flags = ['-Wvla']
+
+foreach arg: warning_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
lib/hash/rte_thash_gf2_poly_math.c +4 -5
index 1c62974e71..825da4382f 100644
@@ -8,6 +8,7 @@
 #include <rte_thash.h>
 #include <rte_log.h>
 
+#define MAX_POLY_DEGREE 32
 #define MAX_TOEPLITZ_KEY_LENGTH 64
 RTE_LOG_REGISTER_SUFFIX(thash_poly_logtype, thash_poly, INFO);
 #define RTE_LOGTYPE_HASH thash_poly_logtype
@@ -149,7 +150,7 @@ gf2_pow(uint32_t a, uint32_t pow, uint32_t r, int degree)
 static uint32_t
 __thash_get_rand_poly(int poly_degree)
 {
-	uint32_t roots[poly_degree];
+	uint32_t roots[MAX_POLY_DEGREE];
 	uint32_t rnd;
 	uint32_t ret_poly = 0;
 	int i, j;
@@ -194,9 +195,7 @@ __thash_get_rand_poly(int poly_degree)
 	 * Get coefficients of the polynomial for
 	 * (x - roots[0])(x - roots[1])...(x - roots[n])
 	 */
-	uint32_t poly_coefficients[poly_degree + 1];
-	for (i = 0; i <= poly_degree; i++)
-		poly_coefficients[i] = 0;
+	uint32_t poly_coefficients[MAX_POLY_DEGREE + 1] = {0};
 
 	poly_coefficients[0] = 1; /* highest degree term coefficient in the end */
 	for (i = 0; i < (int)poly_degree; i++) {
@@ -247,7 +246,7 @@ thash_get_rand_poly(uint32_t poly_degree)
 {
 	uint32_t ret_poly;
 
-	if (poly_degree > 32) {
+	if (poly_degree > MAX_POLY_DEGREE) {
 		HASH_LOG(ERR, "Wrong polynomial degree %d, must be in range [1, 32]", poly_degree);
 		return 0;
 	}
Signature · 1 line
2.47.0.vfs.0.3
#361 lore raw

PATCH v14 22/81 app/dumpcap: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 app/dumpcap/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
app/dumpcap/meson.build +8 -0
index 69c016c780..675f5d7448 100644
@@ -15,3 +15,11 @@ endif
 ext_deps += pcap_dep
 sources = files('main.c')
 deps += ['ethdev', 'pdump', 'pcapng', 'bpf']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#362 lore raw

PATCH v14 23/81 app/graph: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 app/graph/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
app/graph/meson.build +8 -0
index 344e4a418f..28ad533498 100644
@@ -33,3 +33,11 @@ cmd_h = custom_target('commands_hdr',
         command: [cmdline_gen_cmd, '--context-name=modules_ctx', '@INPUT@']
 )
 sources += cmd_h
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#363 lore raw

PATCH v14 24/81 app/test-cmdline: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 app/test-cmdline/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
app/test-cmdline/meson.build +8 -0
index 6027f67919..06813ff1f5 100644
@@ -9,3 +9,11 @@ endif
 
 sources = files('commands.c', 'cmdline_test.c')
 deps += 'cmdline'
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#364 lore raw

PATCH v14 25/81 app/test-compress-perf: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 app/test-compress-perf/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
app/test-compress-perf/meson.build +8 -0
index 34dcfe5b8e..58fea052d9 100644
@@ -16,3 +16,11 @@ sources = files(
         'main.c',
 )
 deps = ['compressdev']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#365 lore raw

PATCH v14 26/81 app/test-fib: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 app/test-fib/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
app/test-fib/meson.build +8 -0
index eb36772cf3..f639171068 100644
@@ -9,3 +9,11 @@ endif
 
 sources = files('main.c')
 deps += ['fib', 'lpm', 'net']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#366 lore raw

PATCH v14 27/81 app/test-gpudev: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 app/test-gpudev/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
app/test-gpudev/meson.build +8 -0
index 17bdef3646..9d119a11a0 100644
@@ -3,3 +3,11 @@
 
 sources = files('main.c')
 deps = ['gpudev', 'ethdev']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#367 lore raw

PATCH v14 28/81 app/test-mldev: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 app/test-mldev/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
app/test-mldev/meson.build +8 -0
index 2922888e9f..06fba62947 100644
@@ -23,3 +23,11 @@ sources = files(
 )
 
 deps += ['mldev', 'hash']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#368 lore raw

PATCH v14 29/81 app/test-pipeline: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 app/test-pipeline/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
app/test-pipeline/meson.build +8 -0
index 3add6b637b..bec2e7958b 100644
@@ -19,3 +19,11 @@ sources = files(
         'runtime.c',
 )
 deps += ['pipeline', 'pci']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#369 lore raw

PATCH v14 30/81 app/test-regex: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 app/test-regex/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
app/test-regex/meson.build +8 -0
index e3ba060e55..a0c5bcebc4 100644
@@ -9,3 +9,11 @@ endif
 
 sources = files('main.c')
 deps = ['regexdev']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#370 lore raw

PATCH v14 31/81 app/test-security-perf: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 app/test-security-perf/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
app/test-security-perf/meson.build +8 -0
index 547de9c908..507d17d368 100644
@@ -13,3 +13,11 @@ sources = files(
         '../test/test_security_proto.c',
 )
 deps += ['security', 'cmdline']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#371 lore raw

PATCH v14 32/81 lib/argparse: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/argparse/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/argparse/meson.build +8 -0
index b6a08ca049..3ef537b958 100644
@@ -5,3 +5,11 @@ sources = files('rte_argparse.c')
 headers = files('rte_argparse.h')
 
 deps += ['log']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#372 lore raw

PATCH v14 33/81 lib/bbdev: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/bbdev/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/bbdev/meson.build +8 -0
index 07685e7578..542372d29b 100644
@@ -12,3 +12,11 @@ headers = files('rte_bbdev.h',
         'rte_bbdev_pmd.h',
         'rte_bbdev_op.h')
 deps += ['mbuf']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#373 lore raw

PATCH v14 34/81 lib/bitratestats: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/bitratestats/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/bitratestats/meson.build +8 -0
index ede7e0a579..793c6cfc04 100644
@@ -4,3 +4,11 @@
 sources = files('rte_bitrate.c')
 headers = files('rte_bitrate.h')
 deps += ['ethdev', 'metrics']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#374 lore raw

PATCH v14 35/81 lib/cfgfile: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/cfgfile/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/cfgfile/meson.build +8 -0
index 88eb819856..afc0a87c00 100644
@@ -3,3 +3,11 @@
 
 sources = files('rte_cfgfile.c')
 headers = files('rte_cfgfile.h')
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#375 lore raw

PATCH v14 36/81 lib/cmdline: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/cmdline/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/cmdline/meson.build +8 -0
index 63fb69100d..da7a578d05 100644
@@ -32,3 +32,11 @@ else
 endif
 
 deps += ['net']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#376 lore raw

PATCH v14 37/81 lib/compressdev: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/compressdev/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/compressdev/meson.build +8 -0
index c80295dc0d..b3546fa8e2 100644
@@ -17,3 +17,11 @@ driver_sdk_headers = files(
         'rte_compressdev_internal.h',
     )
 deps += ['kvargs', 'mbuf']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#377 lore raw

PATCH v14 38/81 lib/cryptodev: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/cryptodev/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/cryptodev/meson.build +8 -0
index 4734acf321..02bf7cec8e 100644
@@ -21,3 +21,11 @@ driver_sdk_headers += files(
 )
 
 deps += ['kvargs', 'mbuf', 'rcu', 'telemetry']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#378 lore raw

PATCH v14 39/81 lib/distributor: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/distributor/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/distributor/meson.build +8 -0
index 24988c5827..e41f65fcd3 100644
@@ -15,3 +15,11 @@ else
 endif
 headers = files('rte_distributor.h')
 deps += ['mbuf']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#379 lore raw

PATCH v14 40/81 lib/dmadev: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/dmadev/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/dmadev/meson.build +8 -0
index e66dcb66b0..61c99696ae 100644
@@ -13,3 +13,11 @@ indirect_headers += files('rte_dmadev_core.h', 'rte_dmadev_trace_fp.h')
 driver_sdk_headers += files('rte_dmadev_pmd.h')
 
 deps += ['telemetry']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#380 lore raw

PATCH v14 41/81 lib/efd: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/efd/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/efd/meson.build +8 -0
index 343f14e1f3..5475c05765 100644
@@ -10,3 +10,11 @@ endif
 sources = files('rte_efd.c')
 headers = files('rte_efd.h')
 deps += ['ring', 'hash']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#381 lore raw

PATCH v14 42/81 lib/fib: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/fib/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/fib/meson.build +8 -0
index 0c19cc8201..5a1cf0226a 100644
@@ -14,6 +14,14 @@ deps += ['rib']
 deps += ['rcu']
 deps += ['net']
 
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
+
 if dpdk_conf.has('RTE_ARCH_X86_64')
     if target_has_avx512
         cflags += ['-DCC_DIR24_8_AVX512_SUPPORT', '-DCC_TRIE_AVX512_SUPPORT']
Signature · 1 line
2.47.0.vfs.0.3
#382 lore raw

PATCH v14 43/81 lib/gpudev: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/gpudev/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/gpudev/meson.build +8 -0
index d21fadc052..57022d75a4 100644
@@ -14,3 +14,11 @@ sources = files(
 )
 
 deps += ['mbuf']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#383 lore raw

PATCH v14 44/81 lib/gso: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/gso/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/gso/meson.build +8 -0
index 622411df8f..f5702e200f 100644
@@ -11,3 +11,11 @@ sources = files(
 )
 headers = files('rte_gso.h')
 deps += ['ethdev']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#384 lore raw

PATCH v14 45/81 lib/ip_frag: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/ip_frag/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/ip_frag/meson.build +8 -0
index ea2de09f75..f5c6cb4769 100644
@@ -11,3 +11,11 @@ sources = files(
 )
 headers = files('rte_ip_frag.h')
 deps += ['ethdev', 'hash']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#385 lore raw

PATCH v14 46/81 lib/jobstats: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/jobstats/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/jobstats/meson.build +8 -0
index 6da2a95b75..e43e229247 100644
@@ -9,3 +9,11 @@ endif
 
 sources = files('rte_jobstats.c')
 headers = files('rte_jobstats.h')
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#386 lore raw

PATCH v14 47/81 lib/kvargs: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/kvargs/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/kvargs/meson.build +8 -0
index 7eae744a8f..c94ddb2fe3 100644
@@ -4,3 +4,11 @@
 deps += 'log'
 sources = files('rte_kvargs.c')
 headers = files('rte_kvargs.h')
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#387 lore raw

PATCH v14 48/81 lib/latencystats: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/latencystats/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/latencystats/meson.build +8 -0
index 286558dd79..e3da90dd4e 100644
@@ -4,3 +4,11 @@
 sources = files('rte_latencystats.c')
 headers = files('rte_latencystats.h')
 deps += ['metrics', 'ethdev']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#388 lore raw

PATCH v14 49/81 lib/log: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/log/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/log/meson.build +8 -0
index b3de57b9c7..5d7261a899 100644
@@ -17,3 +17,11 @@ if is_linux
 endif
 
 headers = files('rte_log.h')
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#389 lore raw

PATCH v14 50/81 lib/lpm: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/lpm/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/lpm/meson.build +8 -0
index fae4f79fb9..06525b76c1 100644
@@ -21,3 +21,11 @@ indirect_headers += files(
 deps += ['hash']
 deps += ['rcu']
 deps += ['net']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#390 lore raw

PATCH v14 51/81 lib/mbuf: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/mbuf/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/mbuf/meson.build +8 -0
index 2cee9057a5..1b94b286a6 100644
@@ -21,3 +21,11 @@ headers = files(
         'rte_mbuf_dyn.h',
 )
 deps += ['mempool']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#391 lore raw

PATCH v14 52/81 lib/mempool: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/mempool/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/mempool/meson.build +1 -1
index 8099a56466..3921945fb3 100644
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-extra_flags = []
+extra_flags = ['-Wvla']
 
 foreach flag: extra_flags
     if cc.has_argument(flag)
Signature · 1 line
2.47.0.vfs.0.3
#392 lore raw

PATCH v14 53/81 lib/meter: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/meter/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/meter/meson.build +8 -0
index 646fd4d43f..320e09e53f 100644
@@ -3,3 +3,11 @@
 
 sources = files('rte_meter.c')
 headers = files('rte_meter.h')
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#393 lore raw

PATCH v14 54/81 lib/metrics: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/metrics/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/metrics/meson.build +8 -0
index 8c1c4b4b49..86f320f90c 100644
@@ -9,3 +9,11 @@ if dpdk_conf.has('RTE_HAS_JANSSON')
 endif
 
 deps += ['ethdev', 'telemetry']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#394 lore raw

PATCH v14 55/81 lib/mldev: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/mldev/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/mldev/meson.build +8 -0
index 2c933baad6..d49302f021 100644
@@ -48,3 +48,11 @@ if get_option('buildtype').contains('debug')
 else
         cflags += [ '-URTE_LIBRTE_ML_DEV_DEBUG' ]
 endif
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#395 lore raw

PATCH v14 56/81 lib/net: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/net/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/net/meson.build +8 -0
index 8afcc4ed37..3194681521 100644
@@ -39,6 +39,14 @@ sources = files(
 )
 deps += ['mbuf']
 
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
+
 if dpdk_conf.has('RTE_ARCH_X86_64')
     net_crc_sse42_cpu_support = (cc.get_define('__PCLMUL__', args: machine_args) != '')
     net_crc_avx512_cpu_support = (
Signature · 1 line
2.47.0.vfs.0.3
#396 lore raw

PATCH v14 57/81 lib/node: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/node/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/node/meson.build +8 -0
index 0bed97a96c..4c7361a53a 100644
@@ -35,3 +35,11 @@ headers = files(
 # Strict-aliasing rules are violated by uint8_t[] to context size casts.
 cflags += '-fno-strict-aliasing'
 deps += ['graph', 'mbuf', 'lpm', 'ethdev', 'mempool', 'cryptodev', 'ip_frag']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#397 lore raw

PATCH v14 58/81 lib/pcapng: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/pcapng/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/pcapng/meson.build +8 -0
index 4549925d41..0ccaf2dcfd 100644
@@ -5,3 +5,11 @@ sources = files('rte_pcapng.c')
 headers = files('rte_pcapng.h')
 
 deps += ['ethdev']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#398 lore raw

PATCH v14 59/81 lib/pci: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/pci/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/pci/meson.build +8 -0
index dd41cd5068..88cfd2a238 100644
@@ -3,3 +3,11 @@
 
 sources = files('rte_pci.c')
 headers = files('rte_pci.h')
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#399 lore raw

PATCH v14 60/81 lib/port: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/port/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/port/meson.build +8 -0
index b597772872..4a09af361f 100644
@@ -46,3 +46,11 @@ if dpdk_conf.has('RTE_HAS_LIBPCAP')
     dpdk_conf.set('RTE_PORT_PCAP', 1)
     ext_deps += pcap_dep # dependency provided in config/meson.build
 endif
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#400 lore raw

PATCH v14 61/81 lib/ptr_compress: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/ptr_compress/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/ptr_compress/meson.build +8 -0
index e92706a45f..7074348513 100644
@@ -2,3 +2,11 @@
 # Copyright(c) 2024 Arm Limited
 
 headers = files('rte_ptr_compress.h')
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#401 lore raw

PATCH v14 62/81 lib/rawdev: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/rawdev/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/rawdev/meson.build +8 -0
index 7dfc3d5cf9..5e60255676 100644
@@ -11,3 +11,11 @@ sources = files('rte_rawdev.c')
 headers = files('rte_rawdev.h', 'rte_rawdev_pmd.h')
 
 deps += ['telemetry']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#402 lore raw

PATCH v14 63/81 lib/reorder: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/reorder/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/reorder/meson.build +8 -0
index 03aed53d90..5197da9298 100644
@@ -4,3 +4,11 @@
 sources = files('rte_reorder.c')
 headers = files('rte_reorder.h')
 deps += ['mbuf']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#403 lore raw

PATCH v14 64/81 lib/rib: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/rib/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/rib/meson.build +8 -0
index e98f708481..58fcb825a8 100644
@@ -5,3 +5,11 @@
 sources = files('rte_rib.c', 'rte_rib6.c')
 headers = files('rte_rib.h', 'rte_rib6.h')
 deps += ['net', 'mempool']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#404 lore raw

PATCH v14 65/81 lib/ring: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/ring/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/ring/meson.build +8 -0
index 7fca958ed7..c18033c205 100644
@@ -19,3 +19,11 @@ indirect_headers += files (
         'rte_ring_rts_elem_pvt.h',
 )
 deps += ['telemetry']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#405 lore raw

PATCH v14 66/81 lib/sched: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/sched/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/sched/meson.build +8 -0
index df75db51ed..78524c7e07 100644
@@ -16,3 +16,11 @@ headers = files(
         'rte_pie.h',
 )
 deps += ['mbuf', 'meter']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#406 lore raw

PATCH v14 67/81 lib/security: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/security/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/security/meson.build +8 -0
index 1034a7a299..6d0cefc943 100644
@@ -4,3 +4,11 @@
 sources = files('rte_security.c')
 headers = files('rte_security.h', 'rte_security_driver.h')
 deps += ['mempool', 'cryptodev', 'net']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#407 lore raw

PATCH v14 68/81 lib/stack: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/stack/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/stack/meson.build +8 -0
index 7631a14784..e5daf96e0e 100644
@@ -17,3 +17,11 @@ indirect_headers += files(
         'rte_stack_lf_c11.h',
         'rte_stack_lf_stubs.h',
 )
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#408 lore raw

PATCH v14 69/81 lib/telemetry: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/telemetry/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/telemetry/meson.build +8 -0
index 489d000047..188792fbfc 100644
@@ -5,3 +5,11 @@ deps += 'log'
 sources = files('telemetry.c', 'telemetry_data.c', 'telemetry_legacy.c')
 headers = files('rte_telemetry.h')
 includes += include_directories('../metrics')
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#409 lore raw

PATCH v14 70/81 lib/timer: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 lib/timer/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/timer/meson.build +8 -0
index 66ef89ac00..7546fc9838 100644
@@ -5,3 +5,11 @@ sources = files('rte_timer.c')
 headers = files('rte_timer.h')
 
 annotate_locks = false
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#410 lore raw

PATCH v14 71/81 drivers/baseband: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 drivers/baseband/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/baseband/meson.build +8 -0
index 3420d98564..6aa1b5b17e 100644
@@ -17,3 +17,11 @@ drivers = [
 std_deps = [ 'bbdev' ]
 
 log_prefix = 'pmd.bb'
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#411 lore raw

PATCH v14 72/81 drivers/bus: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 drivers/bus/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/bus/meson.build +8 -0
index d67db8576b..59af0f920e 100644
@@ -17,3 +17,11 @@ drivers = [
 std_deps = ['eal']
 
 log_prefix = 'bus'
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#412 lore raw

PATCH v14 73/81 drivers/common: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 drivers/common/mlx5/meson.build    | 1 +
 drivers/common/nfp/meson.build     | 8 ++++++++
 drivers/common/nitrox/meson.build  | 8 ++++++++
 drivers/common/qat/meson.build     | 8 ++++++++
 drivers/common/sfc_efx/meson.build | 1 +
 5 files changed, 26 insertions(+)
drivers/common/mlx5/meson.build +1 -0
index 1eefc02f06..a6a67fbb85 100644
@@ -26,6 +26,7 @@ sources += files(
 
 cflags_options = [
         '-std=c11',
+        '-Wvla',
         '-Wno-strict-prototypes',
         '-D_BSD_SOURCE',
         '-D_DEFAULT_SOURCE',
drivers/common/nfp/meson.build +8 -0
index a09d1e25e2..165be4a868 100644
@@ -14,3 +14,11 @@ sources = files(
 )
 
 deps += ['bus_pci', 'net']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
drivers/common/nitrox/meson.build +8 -0
index f3cb42f006..46cd8ba65c 100644
@@ -17,3 +17,11 @@ sources += files(
 
 includes += include_directories('../../crypto/nitrox')
 includes += include_directories('../../compress/nitrox')
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
drivers/common/qat/meson.build +8 -0
index 5a8de16fe0..8dd38e9abd 100644
@@ -119,3 +119,11 @@ if qat_crypto
     deps += ['security']
     cflags += ['-DBUILD_QAT_SYM', '-DBUILD_QAT_ASYM']
 endif
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
drivers/common/sfc_efx/meson.build +1 -0
index 0cf0a23bf8..e3b90f670a 100644
@@ -26,6 +26,7 @@ extra_flags += [
 extra_flags += [
         '-Waggregate-return',
         '-Wbad-function-cast',
+        '-Wvla',
 ]
 
 foreach flag: extra_flags
Signature · 1 line
2.47.0.vfs.0.3
#413 lore raw

PATCH v14 74/81 drivers/compress: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 drivers/compress/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/compress/meson.build +8 -0
index 91d7800a4a..293ddd5836 100644
@@ -15,3 +15,11 @@ drivers = [
 ]
 
 std_deps = ['compressdev'] # compressdev pulls in all other needed deps
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#414 lore raw

PATCH v14 75/81 drivers/gpu: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 drivers/gpu/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/meson.build +8 -0
index b6edd12678..610151e9b1 100644
@@ -4,3 +4,11 @@
 drivers = [ 'cuda' ]
 
 std_deps = [ 'gpudev' ]
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3
#415 lore raw

PATCH v14 76/81 drivers/mempool: add compile warning about use of VLAs

In reply to Andre Muezerie

MSVC does not support VLAs, so we want to prevent VLAs from being introduced under this path.

---
 drivers/mempool/meson.build | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/mempool/meson.build +8 -0
index dc88812585..4f74556eb5 100644
@@ -14,3 +14,11 @@ drivers = [
 std_deps = ['mempool']
 
 log_prefix = 'mempool'
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
Signature · 1 line
2.47.0.vfs.0.3