DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@amd.com>
To: Konstantin Ananyev <konstantin.v.ananyev@yandex.ru>, dev@dpdk.org
Cc: hujiayu.hu@foxmail.com, roretzla@linux.microsoft.com,
	bruce.richardson@intel.com, anatoly.burakov@intel.com,
	vladimir.medvedkin@intel.com,
	Konstantin Ananyev <konstantin.ananyev@huawei.com>
Subject: Re: [RFC 3/4] net/ixgbe: remove use of VLAs
Date: Wed, 12 Jun 2024 02:00:24 +0100	[thread overview]
Message-ID: <59dd1185-6eec-4a08-9d8f-aa184ba87cbf@amd.com> (raw)
In-Reply-To: <20240523162604.2600-4-konstantin.v.ananyev@yandex.ru>

On 5/23/2024 5:26 PM, Konstantin Ananyev wrote:
> From: Konstantin Ananyev <konstantin.ananyev@huawei.com>
> 
> 1) ../drivers/net/ixgbe/ixgbe_ethdev.c:3556:46: warning: variable length array used [-Wvla]
> 2) ../drivers/net/ixgbe/ixgbe_ethdev.c:3739:23: warning: variable length array used [-Wvla]
> 3) ../drivers/net/ixgbe/ixgbe_rxtx_vec_common.h:17:24: warning: variable length array used [-Wvla]
> 
> For first two cases: in fact ixgbe_xstats_calc_num() always returns
> constant value, so it should be safe to replace that function invocation
> just with a macro that performs same calculations.
>

ack


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

Ack

I see you already add assert, +1.
Do you think adding a comment that caller calls with max
RTE_IXGBE_MAX_RX_BURST helps?

> 
> Signed-off-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
> ---
>  drivers/net/ixgbe/ixgbe_ethdev.c          | 21 +++++++++++++--------
>  drivers/net/ixgbe/ixgbe_rxtx_vec_common.h |  4 +++-
>  2 files changed, 16 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
> index bbdc996f31..7843cd41d3 100644
> --- a/drivers/net/ixgbe/ixgbe_ethdev.c
> +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
> @@ -3432,11 +3432,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,
> @@ -3552,8 +3557,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);
> @@ -3735,8 +3740,8 @@ ixgbe_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
>  	}
>  
>  	uint16_t i;
> -	uint16_t size = ixgbe_xstats_calc_num();
> -	uint64_t values_copy[size];
> +	uint64_t values_copy[IXGBE_XSTATS_CALC_NUM];
> +	const uint16_t size = RTE_DIM(values_copy);
>  
>  	ixgbe_dev_xstats_get_by_id(dev, NULL, values_copy, size);
>  
> diff --git a/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h b/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h
> index a4d9ec9b08..c1cf0a581a 100644
> --- a/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h
> +++ b/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h
> @@ -14,11 +14,13 @@ static inline uint16_t
>  reassemble_packets(struct ixgbe_rx_queue *rxq, struct rte_mbuf **rx_bufs,
>  		   uint16_t nb_bufs, uint8_t *split_flags)
>  {
> -	struct rte_mbuf *pkts[nb_bufs]; /*finished pkts*/
> +	struct rte_mbuf *pkts[RTE_IXGBE_MAX_RX_BURST]; /*finished pkts*/
>  	struct rte_mbuf *start = rxq->pkt_first_seg;
>  	struct rte_mbuf *end =  rxq->pkt_last_seg;
>  	unsigned int pkt_idx, buf_idx;
>  
> +	RTE_ASSERT(nb_bufs <= RTE_DIM(pkts));
> +
>  	for (buf_idx = 0, pkt_idx = 0; buf_idx < nb_bufs; buf_idx++) {
>  		if (end != NULL) {
>  			/* processing a split packet */


  reply	other threads:[~2024-06-12  1:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-23 16:26 [RFC 0/4] remove use of VLA Konstantin Ananyev
2024-05-23 16:26 ` [RFC 1/4] gro: fix overwrite unprocessed packets Konstantin Ananyev
2024-06-12  0:48   ` Ferruh Yigit
2024-05-23 16:26 ` [RFC 2/4] gro: remove use of VLAs Konstantin Ananyev
2024-06-12  0:48   ` Ferruh Yigit
2024-06-13 10:20     ` Konstantin Ananyev
2024-06-14 15:11       ` Ferruh Yigit
2024-06-28 12:57         ` Konstantin Ananyev
2024-05-23 16:26 ` [RFC 3/4] net/ixgbe: " Konstantin Ananyev
2024-06-12  1:00   ` Ferruh Yigit [this message]
2024-05-23 16:26 ` [RFC 4/4] net/ice: " Konstantin Ananyev
2024-06-12  1:12   ` Ferruh Yigit
2024-06-13 10:32     ` Konstantin Ananyev
2024-06-14 15:31       ` Ferruh Yigit
2024-06-12  1:14 ` [RFC 0/4] remove use of VLA Ferruh Yigit
2024-06-13 10:43   ` Konstantin Ananyev

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=59dd1185-6eec-4a08-9d8f-aa184ba87cbf@amd.com \
    --to=ferruh.yigit@amd.com \
    --cc=anatoly.burakov@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=hujiayu.hu@foxmail.com \
    --cc=konstantin.ananyev@huawei.com \
    --cc=konstantin.v.ananyev@yandex.ru \
    --cc=roretzla@linux.microsoft.com \
    --cc=vladimir.medvedkin@intel.com \
    /path/to/YOUR_REPLY

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

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).