From: longli@linuxonhyperv.com
To: Ferruh Yigit <ferruh.yigit@amd.com>,
Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,
Wei Hu <weh@microsoft.com>
Cc: dev@dpdk.org, Long Li <longli@microsoft.com>, stable@dpdk.org
Subject: [PATCH 2/4] net/netvsc: remove RTE device if all its net devices are removed
Date: Mon, 27 Jan 2025 17:35:04 -0800 [thread overview]
Message-ID: <1738028106-25239-2-git-send-email-longli@linuxonhyperv.com> (raw)
In-Reply-To: <1738028106-25239-1-git-send-email-longli@linuxonhyperv.com>
From: Long Li <longli@microsoft.com>
An RTE device can have multiple Ethernet devices. On hot plug events, it
can't be removed until all its Ethernet devices have been removed.
Fixes: a2a23a794b3a ("net/netvsc: support VF device hot add/remove")
Cc: stable@dpdk.org
Signed-off-by: Long Li <longli@microsoft.com>
---
drivers/net/netvsc/hn_vf.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/net/netvsc/hn_vf.c b/drivers/net/netvsc/hn_vf.c
index b664beaa5d..5d8058774d 100644
--- a/drivers/net/netvsc/hn_vf.c
+++ b/drivers/net/netvsc/hn_vf.c
@@ -102,6 +102,7 @@ static void hn_remove_delayed(void *args)
uint16_t port_id = hv->vf_ctx.vf_port;
struct rte_device *dev = rte_eth_devices[port_id].device;
int ret;
+ bool all_eth_removed;
/* Tell VSP to switch data path to synthetic */
hn_vf_remove(hv);
@@ -138,7 +139,17 @@ static void hn_remove_delayed(void *args)
PMD_DRV_LOG(ERR, "rte_eth_dev_close failed port_id=%u ret=%d",
port_id, ret);
- ret = rte_dev_remove(dev);
+ /* Remove the rte device when all its eth devices are removed */
+ all_eth_removed = true;
+ RTE_ETH_FOREACH_DEV_OF(port_id, dev) {
+ if (rte_eth_devices[port_id].state != RTE_ETH_DEV_UNUSED) {
+ all_eth_removed = false;
+ break;
+ }
+ }
+ if (all_eth_removed)
+ ret = rte_dev_remove(dev);
+
hv->vf_ctx.vf_state = vf_removed;
rte_rwlock_write_unlock(&hv->vf_lock);
--
2.34.1
next prev parent reply other threads:[~2025-01-28 1:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-28 1:35 [PATCH 1/4] net/netvsc: scan all net devices under the PCI device longli
2025-01-28 1:35 ` longli [this message]
2025-01-28 1:35 ` [PATCH 3/4] net/netvsc: log error on failure to switch data path longli
2025-01-28 1:35 ` [PATCH 4/4] net/netvsc: cache device parameters for hot plug events longli
2025-01-28 21:00 ` Stephen Hemminger
2025-01-29 0:10 ` [EXTERNAL] " Long Li
2025-01-29 0:31 ` Stephen Hemminger
2025-01-29 0:54 ` Long Li
2025-01-30 3:59 ` Stephen Hemminger
2025-01-28 21:01 ` Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1738028106-25239-2-git-send-email-longli@linuxonhyperv.com \
--to=longli@linuxonhyperv.com \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@amd.com \
--cc=longli@microsoft.com \
--cc=stable@dpdk.org \
--cc=weh@microsoft.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).