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 C88B943345 for ; Thu, 16 Nov 2023 14:25:07 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C3BC940ED8; Thu, 16 Nov 2023 14:25:07 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 0824540A89 for ; Thu, 16 Nov 2023 14:25:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700141105; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n0QAfN+r1Bbn176LtQoKPUhQGfMl4jgVmNiy+LUSohI=; b=AuOrYk7RMVxnM7MyccuIWXIdItiMDv74MDnOdPfJ1oLBKClTJXbhZxyURcD5FkehYEFAuD DMjCvJBYmqUi+eDJB4vUnusydYa2TdoeZvrbRQ2o6D8BGy4e/MNgsCIBwet4gYnLAYDF9W LXZF3T15RWnvga8qkIVvtokerDjbyZg= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-131-YMiNc6QZMm-zz7vbMHhupA-1; Thu, 16 Nov 2023 08:25:02 -0500 X-MC-Unique: YMiNc6QZMm-zz7vbMHhupA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2E9C1101A529; Thu, 16 Nov 2023 13:25:02 +0000 (UTC) Received: from rh.Home (unknown [10.39.194.169]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A5592166B27; Thu, 16 Nov 2023 13:25:01 +0000 (UTC) From: Kevin Traynor To: Mingjin Ye Cc: Qi Zhang , dpdk stable Subject: patch 'net/ice: fix crash on closing representor ports' has been queued to stable release 21.11.6 Date: Thu, 16 Nov 2023 13:23:30 +0000 Message-ID: <20231116132348.557257-48-ktraynor@redhat.com> In-Reply-To: <20231116132348.557257-1-ktraynor@redhat.com> References: <20231116132348.557257-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 21.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/21/23. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/cd1428559cf407f2844c6fe9d600bf2d5d9ce2a6 Thanks. Kevin --- >From cd1428559cf407f2844c6fe9d600bf2d5d9ce2a6 Mon Sep 17 00:00:00 2001 From: Mingjin Ye Date: Wed, 8 Nov 2023 11:39:34 +0000 Subject: [PATCH] net/ice: fix crash on closing representor ports [ upstream commit 1d704031642926688c453331b13690a4151e5276 ] The data resource in struct rte_eth_dev is cleared and points to NULL when the DCF port is closed. If the DCF representor port is closed after the DCF port is closed, a segmentation fault occurs because the representor port accesses the data resource released by the DCF port. This patch fixes this issue by synchronizing the state of DCF ports and representor ports to the peer in real time when their state changes. Fixes: c7e1a1a3bfeb ("net/ice: refactor DCF VLAN handling") Signed-off-by: Mingjin Ye Acked-by: Qi Zhang --- drivers/net/ice/ice_dcf_ethdev.c | 30 ++++++++++++++-- drivers/net/ice/ice_dcf_ethdev.h | 3 ++ drivers/net/ice/ice_dcf_vf_representor.c | 46 ++++++++++++++++++++++-- 3 files changed, 73 insertions(+), 6 deletions(-) diff --git a/drivers/net/ice/ice_dcf_ethdev.c b/drivers/net/ice/ice_dcf_ethdev.c index 16321195ed..d2ea5aff43 100644 --- a/drivers/net/ice/ice_dcf_ethdev.c +++ b/drivers/net/ice/ice_dcf_ethdev.c @@ -870,4 +870,24 @@ ice_dcf_free_repr_info(struct ice_dcf_adapter *dcf_adapter) } +int +ice_dcf_handle_vf_repr_close(struct ice_dcf_adapter *dcf_adapter, + uint16_t vf_id) +{ + struct ice_dcf_repr_info *vf_rep_info; + + if (dcf_adapter->num_reprs >= vf_id) { + PMD_DRV_LOG(ERR, "Invalid VF id: %d", vf_id); + return -1; + } + + if (!dcf_adapter->repr_infos) + return 0; + + vf_rep_info = &dcf_adapter->repr_infos[vf_id]; + vf_rep_info->vf_rep_eth_dev = NULL; + + return 0; +} + static int ice_dcf_init_repr_info(struct ice_dcf_adapter *dcf_adapter) @@ -893,9 +913,8 @@ ice_dcf_dev_close(struct rte_eth_dev *dev) return 0; + ice_dcf_vf_repr_notify_all(adapter, false); (void)ice_dcf_dev_stop(dev); ice_free_queues(dev); - - ice_dcf_free_repr_info(adapter); ice_dcf_uninit_parent_adapter(dev); ice_dcf_uninit_hw(dev, &adapter->real_hw); @@ -1074,5 +1093,5 @@ ice_dcf_dev_reset(struct rte_eth_dev *dev) } - ret = ice_dcf_dev_uninit(dev); + ret = ice_dcf_dev_close(dev); if (ret) return ret; @@ -1142,4 +1161,6 @@ ice_dcf_dev_init(struct rte_eth_dev *eth_dev) ice_dcf_stats_reset(eth_dev); + ice_dcf_vf_repr_notify_all(adapter, true); + return 0; } @@ -1148,4 +1169,7 @@ static int ice_dcf_dev_uninit(struct rte_eth_dev *eth_dev) { + struct ice_dcf_adapter *adapter = eth_dev->data->dev_private; + + ice_dcf_free_repr_info(adapter); ice_dcf_dev_close(eth_dev); diff --git a/drivers/net/ice/ice_dcf_ethdev.h b/drivers/net/ice/ice_dcf_ethdev.h index 11a1305038..b651d31d37 100644 --- a/drivers/net/ice/ice_dcf_ethdev.h +++ b/drivers/net/ice/ice_dcf_ethdev.h @@ -51,4 +51,5 @@ struct ice_dcf_vf_repr { uint16_t switch_domain_id; uint16_t vf_id; + bool dcf_valid; struct ice_dcf_vlan outer_vlan_info; /* DCF always handle outer VLAN */ @@ -65,4 +66,6 @@ int ice_dcf_vf_repr_uninit(struct rte_eth_dev *vf_rep_eth_dev); int ice_dcf_vf_repr_init_vlan(struct rte_eth_dev *vf_rep_eth_dev); void ice_dcf_vf_repr_stop_all(struct ice_dcf_adapter *dcf_adapter); +void ice_dcf_vf_repr_notify_all(struct ice_dcf_adapter *dcf_adapter, bool valid); +int ice_dcf_handle_vf_repr_close(struct ice_dcf_adapter *dcf_adapter, uint16_t vf_id); bool ice_dcf_adminq_need_retry(struct ice_adapter *ad); diff --git a/drivers/net/ice/ice_dcf_vf_representor.c b/drivers/net/ice/ice_dcf_vf_representor.c index b9fcfc80ad..af281f069a 100644 --- a/drivers/net/ice/ice_dcf_vf_representor.c +++ b/drivers/net/ice/ice_dcf_vf_representor.c @@ -51,7 +51,26 @@ ice_dcf_vf_repr_dev_stop(struct rte_eth_dev *dev) } +static void +ice_dcf_vf_repr_notify_one(struct rte_eth_dev *dev, bool valid) +{ + struct ice_dcf_vf_repr *repr = dev->data->dev_private; + + repr->dcf_valid = valid; +} + static int ice_dcf_vf_repr_dev_close(struct rte_eth_dev *dev) { + struct ice_dcf_vf_repr *repr = dev->data->dev_private; + struct ice_dcf_adapter *dcf_adapter; + int err; + + if (repr->dcf_valid) { + dcf_adapter = repr->dcf_eth_dev->data->dev_private; + err = ice_dcf_handle_vf_repr_close(dcf_adapter, repr->vf_id); + if (err) + PMD_DRV_LOG(ERR, "VF representor invalid"); + } + return ice_dcf_vf_repr_uninit(dev); } @@ -112,12 +131,13 @@ static __rte_always_inline struct ice_dcf_hw * ice_dcf_vf_repr_hw(struct ice_dcf_vf_repr *repr) { - struct ice_dcf_adapter *dcf_adapter = - repr->dcf_eth_dev->data->dev_private; + struct ice_dcf_adapter *dcf_adapter; - if (!dcf_adapter) { + if (!repr->dcf_valid) { PMD_DRV_LOG(ERR, "DCF for VF representor has been released\n"); return NULL; } + dcf_adapter = repr->dcf_eth_dev->data->dev_private; + return &dcf_adapter->real_hw; } @@ -415,4 +435,5 @@ ice_dcf_vf_repr_init(struct rte_eth_dev *vf_rep_eth_dev, void *init_param) repr->switch_domain_id = param->switch_domain_id; repr->vf_id = param->vf_id; + repr->dcf_valid = true; repr->outer_vlan_info.port_vlan_ena = false; repr->outer_vlan_info.stripping_ena = false; @@ -489,2 +510,21 @@ ice_dcf_vf_repr_stop_all(struct ice_dcf_adapter *dcf_adapter) } } + +void +ice_dcf_vf_repr_notify_all(struct ice_dcf_adapter *dcf_adapter, bool valid) +{ + uint16_t vf_id; + struct rte_eth_dev *vf_rep_eth_dev; + + if (!dcf_adapter->repr_infos) + return; + + for (vf_id = 0; vf_id < dcf_adapter->real_hw.num_vfs; vf_id++) { + vf_rep_eth_dev = dcf_adapter->repr_infos[vf_id].vf_rep_eth_dev; + + if (!vf_rep_eth_dev) + continue; + + ice_dcf_vf_repr_notify_one(vf_rep_eth_dev, valid); + } +} -- 2.41.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-11-16 13:21:53.692615035 +0000 +++ 0048-net-ice-fix-crash-on-closing-representor-ports.patch 2023-11-16 13:21:52.510946550 +0000 @@ -1 +1 @@ -From 1d704031642926688c453331b13690a4151e5276 Mon Sep 17 00:00:00 2001 +From cd1428559cf407f2844c6fe9d600bf2d5d9ce2a6 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 1d704031642926688c453331b13690a4151e5276 ] + @@ -17 +18,0 @@ -Cc: stable@dpdk.org @@ -28 +29 @@ -index 29699c2c32..5d845bba31 100644 +index 16321195ed..d2ea5aff43 100644 @@ -31 +32 @@ -@@ -1619,4 +1619,24 @@ ice_dcf_free_repr_info(struct ice_dcf_adapter *dcf_adapter) +@@ -870,4 +870,24 @@ ice_dcf_free_repr_info(struct ice_dcf_adapter *dcf_adapter) @@ -56 +57 @@ -@@ -1642,9 +1662,8 @@ ice_dcf_dev_close(struct rte_eth_dev *dev) +@@ -893,9 +913,8 @@ ice_dcf_dev_close(struct rte_eth_dev *dev) @@ -67 +68 @@ -@@ -1836,5 +1855,5 @@ ice_dcf_dev_reset(struct rte_eth_dev *dev) +@@ -1074,5 +1093,5 @@ ice_dcf_dev_reset(struct rte_eth_dev *dev) @@ -74 +75,2 @@ -@@ -1941,4 +1960,6 @@ ice_dcf_dev_init(struct rte_eth_dev *eth_dev) +@@ -1142,4 +1161,6 @@ ice_dcf_dev_init(struct rte_eth_dev *eth_dev) + ice_dcf_stats_reset(eth_dev); @@ -76 +77,0 @@ - dcf_config_promisc(adapter, false, false); @@ -81 +82 @@ -@@ -1947,4 +1968,7 @@ static int +@@ -1148,4 +1169,7 @@ static int @@ -90 +91 @@ -index 4baaec4b8b..6dcbaac5eb 100644 +index 11a1305038..b651d31d37 100644 @@ -93 +94 @@ -@@ -61,4 +61,5 @@ struct ice_dcf_vf_repr { +@@ -51,4 +51,5 @@ struct ice_dcf_vf_repr { @@ -99 +100 @@ -@@ -81,4 +82,6 @@ int ice_dcf_vf_repr_uninit(struct rte_eth_dev *vf_rep_eth_dev); +@@ -65,4 +66,6 @@ int ice_dcf_vf_repr_uninit(struct rte_eth_dev *vf_rep_eth_dev);