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 313CF46079; Tue, 14 Jan 2025 02:32:21 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 119D2402A0; Tue, 14 Jan 2025 02:32:21 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id A2D314025A for ; Tue, 14 Jan 2025 02:32:19 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1213) id 05FA420BEBE1; Mon, 13 Jan 2025 17:32:19 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 05FA420BEBE1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1736818339; bh=196xF1cROOq19fTmKVqFvfSi9sqgjw5UUl4kU75al3s=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SbYUpHTYPCeJgJVcnHx6gyR/vNvchpvCbGSHgCNFXORi/dMK3molFlNsHpU+pIu9j qfvk1+YIxc/07YwFGEob/CP3is7372E7XGDlvg3T1zu0BIUq0YjMmouYMQpJv76iVh FssnkPmPgxxRPEXQHJRCbSikl+CHzeLw42VOEECE= Date: Mon, 13 Jan 2025 17:32:18 -0800 From: Andre Muezerie To: Konstantin Ananyev Cc: Konstantin Ananyev , Vladimir Medvedkin , "dev@dpdk.org" Subject: Re: [PATCH 1/2] lib/ipsec: compile ipsec on Windows Message-ID: <20250114013218.GA26785@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1736181948-8907-1-git-send-email-andremue@linux.microsoft.com> <1736181948-8907-2-git-send-email-andremue@linux.microsoft.com> <506a31ede96645a299b31445f8574fa2@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <506a31ede96645a299b31445f8574fa2@huawei.com> User-Agent: Mutt/1.5.21 (2010-09-15) 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 On Thu, Jan 09, 2025 at 05:27:11PM +0000, Konstantin Ananyev wrote: > > > > Removed VLA for compatibility with MSVC (which does not support VLAs). > > Used alloca when a constant fixed length that can be used instead is > > not known. > > > ... > > > Signed-off-by: Andre Muezerie > > --- > > ... > > > diff --git a/lib/ipsec/esp_inb.c b/lib/ipsec/esp_inb.c > > index f159bf7460..305ac48dc5 100644 > > --- a/lib/ipsec/esp_inb.c > > +++ b/lib/ipsec/esp_inb.c > > @@ -370,8 +370,9 @@ esp_inb_pkt_prepare(const struct rte_ipsec_session *ss, struct rte_mbuf *mb[], > > struct rte_cryptodev_sym_session *cs; > > struct replay_sqn *rsn; > > union sym_op_data icv; > > - uint32_t dr[num]; > > + uint32_t *dr; > > I understand the intention, but obviously as the lib maintainer, I am no > very happy with mechanic replacement of VLAs with alloca() calls. > Again, while it helps to make MSVC happy, it doesn't really solve a potential problem > with using VLAs here - I we can end-up with stack overflowed if someone will call > one of these functions with input arrays of huge size. > It would be much better to re-work the internal functions to work over fixed-size array > an then call them in a loop. > The main issue here is that by API convention we need to re-arrange input array by > moving bad (not processed) mbuf after the good ones. > But even with that splitting processing into multiple iterations over small chunks > might help I think. Understood. I'll focus on the other patches being reviewed and revisit this one at some other time. > > > + dr = alloca(sizeof(uint32_t) * num); > > sa = ss->sa; > > cs = ss->crypto.ses; > > rsn = rsn_acquire(sa); > > @@ -576,12 +577,16 @@ tun_process(struct rte_ipsec_sa *sa, struct rte_mbuf *mb[], > > uint32_t sqn[], uint32_t dr[], uint16_t num, uint8_t sqh_len) > > { > > uint32_t adj, i, k, tl, bytes; > > - uint32_t hl[num], to[num]; > > - struct rte_esp_tail espt[num]; > > - struct rte_mbuf *ml[num]; > > + uint32_t *hl, *to; > > + struct rte_esp_tail *espt; > > + struct rte_mbuf **ml; > > const void *outh; > > void *inh; > > > > + hl = alloca(sizeof(uint32_t) * num); > > + to = alloca(sizeof(uint32_t) * num); > > + espt = alloca(sizeof(struct rte_esp_tail) * num); > > + ml = alloca(sizeof(struct rte_mbuf *) * num); > > /* > > * remove icv, esp trailer and high-order > > * 32 bits of esn from packet length