From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 37C61440A7; Thu, 23 May 2024 18:28:55 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 257DC4068A; Thu, 23 May 2024 18:28:53 +0200 (CEST) Received: from forward501b.mail.yandex.net (forward501b.mail.yandex.net [178.154.239.145]) by mails.dpdk.org (Postfix) with ESMTP id 8FE944068E for ; Thu, 23 May 2024 18:28:51 +0200 (CEST) Received: from mail-nwsmtp-smtp-production-main-39.sas.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-39.sas.yp-c.yandex.net [IPv6:2a02:6b8:c08:f220:0:640:b85:0]) by forward501b.mail.yandex.net (Yandex) with ESMTPS id E328D60BB4; Thu, 23 May 2024 19:28:50 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-39.sas.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id JSOa0WGg9Ko0-83tkH52Y; Thu, 23 May 2024 19:28:50 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1716481730; bh=w2Pz1B3anFSPAT+cCgcLU3DwhfpnQMbtK1B9jckbNUw=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=DzVzLA2J+burytTi3CUI2W/QdinYkwSSsCjCtx5SCQBOQCAJJrkvUm6m2j058+LVU 40R+ill0dD46aZ3HV6NBv/0MR963+mwbF2LjDuUTw4YE+t+EK1+wMGn2vDUb0iuiG6 So6j760TFhrPKdfbUDT4W622quqR1hUgfUReUF9s= Authentication-Results: mail-nwsmtp-smtp-production-main-39.sas.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Konstantin Ananyev To: 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 Subject: [RFC 3/4] net/ixgbe: remove use of VLAs Date: Thu, 23 May 2024 17:26:03 +0100 Message-Id: <20240523162604.2600-4-konstantin.v.ananyev@yandex.ru> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240523162604.2600-1-konstantin.v.ananyev@yandex.ru> References: <20240523162604.2600-1-konstantin.v.ananyev@yandex.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Konstantin Ananyev 1) ../drivers/net/ixgbe/ixgbe_ethdev.c:3556:46: warning: variable length array used [-Wvla] 2) ../drivers/net/ixgbe/ixgbe_ethdev.c:3739:23: warning: variable length array used [-Wvla] 3) ../drivers/net/ixgbe/ixgbe_rxtx_vec_common.h:17:24: warning: variable length array used [-Wvla] For first two cases: in fact ixgbe_xstats_calc_num() always returns constant value, so it should be safe to replace that function invocation just with a macro that performs same calculations. For case #3: reassemble_packets() is invoked only by ixgbe_recv_scattered_burst_vec(). And in turn, ixgbe_recv_scattered_burst_vec() operates only on fixed max amount of packets per call: RTE_IXGBE_MAX_RX_BURST. So, it should be safe to replace VLA with fixed size array. Signed-off-by: Konstantin Ananyev --- 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 */ -- 2.35.3