From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9727C61DE4 for ; Mon, 31 Aug 2026 02:36:05 +0000 (UTC) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0F9E140395; Mon, 31 Aug 2026 04:35:30 +0200 (CEST) Received: from cstnet.cn (smtp81.cstnet.cn [159.226.251.81]) by mails.dpdk.org (Postfix) with ESMTP id 927D44042E; Mon, 31 Aug 2026 04:35:08 +0200 (CEST) Received: from localhost.localdomain (unknown [118.112.177.181]) by APP-03 (Coremail) with SMTP id rQCowABnckBX6JRq27+jBg--.24645S8; Mon, 31 Aug 2026 10:35:06 +0800 (CST) From: Jie Liu To: dev@dpdk.org Cc: Jie Liu , stable@dpdk.org, stephen@networkplumber.org Subject: [PATCH v7 06/47] net/sxe2: fix VSI lifecycle management Date: Mon, 31 Aug 2026 10:34:19 +0800 Message-ID: <20260831023500.3229289-7-liujie5@linkdatatechnology.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260831023500.3229289-1-liujie5@linkdatatechnology.com> References: <20260828074056.2250222-1-liujie5@linkdatatechnology.com> <20260831023500.3229289-1-liujie5@linkdatatechnology.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: rQCowABnckBX6JRq27+jBg--.24645S8 X-Coremail-Antispam: 1UD129KBjvJXoWxXr4kAFWrKrWxGF1xuw47CFg_yoW5uF1xpF s3A3WYqF40qFn09FW7Jr4rZF15KrWrtry09a1S9w1fJ3ZrAry5AF95Xr1Fka4Sk3ykWwna yan7Ww18Jr1DGFUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9G14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr 1l84ACjcxK6I8E87Iv67AKxVWUJVW8JwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1U M2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjx v20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1l F7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxAIw28IcxkI7VAKI48JMx C20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAF wI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20x vE14v26r1I6r4UMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v2 0xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxV W8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7VUbmZX7UUUUU== X-Originating-IP: [118.112.177.181] X-CM-SenderInfo: xolxyxrhv6zxpqngt3pdwhux5qro0w31of0z/ 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 Fix several VSI create/destroy issues introduced by VF representor support: - Initialize other_vsi_list with TAILQ_INIT in sxe2_vsi_init before any VSI is inserted into it. - Treat -EPERM as a non-fatal error when destroying VSIs, since the kernel may have already removed the VSI. - Set main_vsi to NULL after destroy/free to avoid a dangling pointer if the VSI is destroyed again. Fixes: 635084db5d57 ("net/sxe2: support VF representors") Cc: stable@dpdk.org Cc: stephen@networkplumber.org Signed-off-by: Jie Liu --- drivers/net/sxe2/sxe2_vsi.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/drivers/net/sxe2/sxe2_vsi.c b/drivers/net/sxe2/sxe2_vsi.c index d29480b931..e1a26fda6a 100644 --- a/drivers/net/sxe2/sxe2_vsi.c +++ b/drivers/net/sxe2/sxe2_vsi.c @@ -96,21 +96,6 @@ static struct sxe2_vsi *sxe2_vsi_node_create(struct sxe2_adapter *adapter, return vsi; } -static void sxe2_vsi_node_free(struct sxe2_vsi *vsi) -{ - struct sxe2_adapter *adapter; - - if (!vsi) - return; - - adapter = vsi->adapter; - if (vsi->vsi_type == SXE2_VSI_T_ESW) - TAILQ_REMOVE(&adapter->vsi_ctxt.other_vsi_list, vsi, next); - - rte_free(vsi); - vsi = NULL; -} - static int32_t sxe2_vsi_destroy(struct sxe2_adapter *adapter, struct sxe2_vsi *vsi) { int32_t ret = 0; @@ -131,6 +116,8 @@ static int32_t sxe2_vsi_destroy(struct sxe2_adapter *adapter, struct sxe2_vsi *v } l_free: + if (vsi->vsi_type == SXE2_VSI_T_DPDK_ESW) + TAILQ_REMOVE(&adapter->vsi_ctxt.other_vsi_list, vsi, next); rte_free(vsi); vsi = NULL; @@ -174,7 +161,7 @@ static int32_t sxe2_main_vsi_create(struct sxe2_adapter *adapter) goto l_end; l_free_vsi: - sxe2_vsi_node_free(adapter->vsi_ctxt.main_vsi); + rte_free(adapter->vsi_ctxt.main_vsi); adapter->vsi_ctxt.main_vsi = NULL; l_end: return ret; @@ -217,7 +204,7 @@ int32_t sxe2_other_vsi_create(struct sxe2_adapter *adapter, uint16_t cnt_vf) goto l_end; l_free_vsi: - sxe2_vsi_node_free(other_vsi); + rte_free(other_vsi); l_end: return ret; } @@ -230,7 +217,7 @@ int32_t sxe2_vsi_init(struct rte_eth_dev *dev) uint16_t srcvsi_cnt; PMD_INIT_FUNC_TRACE(); - + TAILQ_INIT(&adapter->vsi_ctxt.other_vsi_list); ret = sxe2_main_vsi_create(adapter); if (ret) { PMD_LOG_ERR(DRV, "Failed to create main VSI, ret=%d", ret); @@ -283,13 +270,14 @@ void sxe2_vsi_uninit(struct rte_eth_dev *dev) l_free: ret = sxe2_vsi_destroy(adapter, adapter->vsi_ctxt.main_vsi); - if (ret) { + if (ret && ret != -EPERM) { PMD_LOG_ERR(DRV, "Failed to del vsi from fw, ret=%d", ret); goto l_end; } + adapter->vsi_ctxt.main_vsi = NULL; RTE_TAILQ_FOREACH_SAFE(var, &adapter->vsi_ctxt.other_vsi_list, next, tvar) { ret = sxe2_vsi_destroy(adapter, var); - if (ret) { + if (ret && ret != -EPERM) { PMD_LOG_ERR(DRV, "Failed to del vsi from fw, ret=%d", ret); break; } @@ -356,5 +344,6 @@ void sxe2_vsi_repr_main_vsi_destroy(struct rte_eth_dev *dev) { struct sxe2_adapter *adapter = SXE2_DEV_PRIVATE_TO_ADAPTER(dev); - sxe2_vsi_node_free(adapter->vsi_ctxt.main_vsi); + rte_free(adapter->vsi_ctxt.main_vsi); + adapter->vsi_ctxt.main_vsi = NULL; } -- 2.52.0