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 0EB7145CB8; Sat, 9 Nov 2024 02:50:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8F17843458; Sat, 9 Nov 2024 02:48:50 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 1B4374342B for ; Sat, 9 Nov 2024 02:48:26 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1213) id 1B1272130843; Fri, 8 Nov 2024 17:48:23 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 1B1272130843 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1731116904; bh=H+Rx8BMPTwbb8L4DSgZiy9DnPAagdnDW+RLVO7Cda6w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FnexhHilhibRdlKtIY/O3+aEWJf119N+u5MR2qGGn9fhZS1OdZQNX6tCMl6Jts5Tx sedMoh5ckByGB1y3JSrp41RIYmH1Wd+I6iFzhe58/vTYZzK8sHFcBu2zOT4/G/8U/m Y3qAjAFEl1Pup9DRKwlIW4EE9bw55ObqBrl8wocU= From: Andre Muezerie To: dev@dpdk.org Cc: Konstantin Ananyev Subject: [PATCH v6 09/20] gro: remove use of VLAs Date: Fri, 8 Nov 2024 17:48:01 -0800 Message-Id: <1731116892-17109-10-git-send-email-andremue@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1731116892-17109-1-git-send-email-andremue@linux.microsoft.com> References: <1713397319-26135-1-git-send-email-roretzla@linux.microsoft.com> <1731116892-17109-1-git-send-email-andremue@linux.microsoft.com> 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 ../lib/gro/rte_gro.c:182:34: warning: variable length array used [-Wvla] ../lib/gro/rte_gro.c:363:34: warning: variable length array used [-Wvla] In both cases the pattern is the same: we use unprocess_pkts[nb_pkts] to collect un-used by GRO packets, and then copy them to the start of input/output pkts[] array. In both cases, we can safely copy pkts[i] into already processed entry at the same array, i.e. into pkts[unprocess_num]. Such change eliminates need of temporary VLA: unprocess_pkts[nb_pkts]. Signed-off-by: Konstantin Ananyev Acked-by: Ferruh Yigit --- lib/gro/rte_gro.c | 40 ++++++++++++++-------------------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/lib/gro/rte_gro.c b/lib/gro/rte_gro.c index db86117609..6d5aadf32a 100644 --- a/lib/gro/rte_gro.c +++ b/lib/gro/rte_gro.c @@ -179,7 +179,6 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts, struct gro_vxlan_udp4_item vxlan_udp_items[RTE_GRO_MAX_BURST_ITEM_NUM] = {{{0}} }; - struct rte_mbuf *unprocess_pkts[nb_pkts]; uint32_t item_num; int32_t ret; uint16_t i, unprocess_num = 0, nb_after_gro = nb_pkts; @@ -275,7 +274,7 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts, /* Merge successfully */ nb_after_gro--; else if (ret < 0) - unprocess_pkts[unprocess_num++] = pkts[i]; + pkts[unprocess_num++] = pkts[i]; } else if (IS_IPV4_VXLAN_UDP4_PKT(pkts[i]->packet_type) && do_vxlan_udp_gro) { ret = gro_vxlan_udp4_reassemble(pkts[i], @@ -284,7 +283,7 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts, /* Merge successfully */ nb_after_gro--; else if (ret < 0) - unprocess_pkts[unprocess_num++] = pkts[i]; + pkts[unprocess_num++] = pkts[i]; } else if (IS_IPV4_TCP_PKT(pkts[i]->packet_type) && do_tcp4_gro) { ret = gro_tcp4_reassemble(pkts[i], &tcp_tbl, 0); @@ -292,7 +291,7 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts, /* merge successfully */ nb_after_gro--; else if (ret < 0) - unprocess_pkts[unprocess_num++] = pkts[i]; + pkts[unprocess_num++] = pkts[i]; } else if (IS_IPV4_UDP_PKT(pkts[i]->packet_type) && do_udp4_gro) { ret = gro_udp4_reassemble(pkts[i], &udp_tbl, 0); @@ -300,7 +299,7 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts, /* merge successfully */ nb_after_gro--; else if (ret < 0) - unprocess_pkts[unprocess_num++] = pkts[i]; + pkts[unprocess_num++] = pkts[i]; } else if (IS_IPV6_TCP_PKT(pkts[i]->packet_type) && do_tcp6_gro) { ret = gro_tcp6_reassemble(pkts[i], &tcp6_tbl, 0); @@ -308,21 +307,15 @@ rte_gro_reassemble_burst(struct rte_mbuf **pkts, /* merge successfully */ nb_after_gro--; else if (ret < 0) - unprocess_pkts[unprocess_num++] = pkts[i]; + pkts[unprocess_num++] = pkts[i]; } else - unprocess_pkts[unprocess_num++] = pkts[i]; + pkts[unprocess_num++] = pkts[i]; } if ((nb_after_gro < nb_pkts) || (unprocess_num < nb_pkts)) { - i = 0; - /* Copy unprocessed packets */ - if (unprocess_num > 0) { - memcpy(&pkts[i], unprocess_pkts, - sizeof(struct rte_mbuf *) * - unprocess_num); - i = unprocess_num; - } + + i = unprocess_num; /* Flush all packets from the tables */ if (do_vxlan_tcp_gro) { @@ -360,7 +353,6 @@ rte_gro_reassemble(struct rte_mbuf **pkts, uint16_t nb_pkts, void *ctx) { - struct rte_mbuf *unprocess_pkts[nb_pkts]; struct gro_ctx *gro_ctx = ctx; void *tcp_tbl, *udp_tbl, *vxlan_tcp_tbl, *vxlan_udp_tbl, *tcp6_tbl; uint64_t current_time; @@ -396,33 +388,29 @@ rte_gro_reassemble(struct rte_mbuf **pkts, do_vxlan_tcp_gro) { if (gro_vxlan_tcp4_reassemble(pkts[i], vxlan_tcp_tbl, current_time) < 0) - unprocess_pkts[unprocess_num++] = pkts[i]; + pkts[unprocess_num++] = pkts[i]; } else if (IS_IPV4_VXLAN_UDP4_PKT(pkts[i]->packet_type) && do_vxlan_udp_gro) { if (gro_vxlan_udp4_reassemble(pkts[i], vxlan_udp_tbl, current_time) < 0) - unprocess_pkts[unprocess_num++] = pkts[i]; + pkts[unprocess_num++] = pkts[i]; } else if (IS_IPV4_TCP_PKT(pkts[i]->packet_type) && do_tcp4_gro) { if (gro_tcp4_reassemble(pkts[i], tcp_tbl, current_time) < 0) - unprocess_pkts[unprocess_num++] = pkts[i]; + pkts[unprocess_num++] = pkts[i]; } else if (IS_IPV4_UDP_PKT(pkts[i]->packet_type) && do_udp4_gro) { if (gro_udp4_reassemble(pkts[i], udp_tbl, current_time) < 0) - unprocess_pkts[unprocess_num++] = pkts[i]; + pkts[unprocess_num++] = pkts[i]; } else if (IS_IPV6_TCP_PKT(pkts[i]->packet_type) && do_tcp6_gro) { if (gro_tcp6_reassemble(pkts[i], tcp6_tbl, current_time) < 0) - unprocess_pkts[unprocess_num++] = pkts[i]; + pkts[unprocess_num++] = pkts[i]; } else - unprocess_pkts[unprocess_num++] = pkts[i]; - } - if (unprocess_num > 0) { - memcpy(pkts, unprocess_pkts, sizeof(struct rte_mbuf *) * - unprocess_num); + pkts[unprocess_num++] = pkts[i]; } return unprocess_num; -- 2.34.1