From: Long Li <longli@microsoft.com>
To: dev@dpdk.org, Wei Hu <weh@microsoft.com>,
Stephen Hemminger <stephen@networkplumber.org>
Cc: Long Li <longli@microsoft.com>, stable@dpdk.org
Subject: [PATCH v3 5/7] net/netvsc: retry when no matching MAC found in net directory
Date: Fri, 15 May 2026 12:28:39 -0700 [thread overview]
Message-ID: <20260515192843.552762-6-longli@microsoft.com> (raw)
In-Reply-To: <20260515192843.552762-1-longli@microsoft.com>
On multi-NIC Azure VMs, a single MANA PCI device (7870:00:00.0) hosts
multiple VF interfaces. After PCI rescan, these interfaces register
at different times — the management NIC's VF appears first, followed
by the test NIC's VF.
Previously, when netvsc_hotplug_retry scanned the net/ directory and
found interfaces with non-matching MACs, it would exit the readdir
loop and free the hotadd context, permanently giving up. The matching
VF interface had not appeared yet.
Now, when the readdir loop ends without finding a matching MAC (dir
is NULL after loop), schedule another retry instead of giving up.
This uses a separate mac_retry counter (limit 120, ~2 minutes) so
the main retry loop remains unlimited.
Fixes: a2a23a794b3a ("net/netvsc: support VF device hot add/remove")
Cc: stable@dpdk.org
Signed-off-by: Long Li <longli@microsoft.com>
---
v3: no change
v2:
- Fixed commit message (limit 120 not 30)
- Changed mac_retry log to DEBUG
- Explicit NULL comparisons
drivers/net/netvsc/hn_ethdev.c | 36 +++++++++++++++++++++++++++++++++-
drivers/net/netvsc/hn_var.h | 1 +
2 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c
index 16fb2b344d..72743872bb 100644
--- a/drivers/net/netvsc/hn_ethdev.c
+++ b/drivers/net/netvsc/hn_ethdev.c
@@ -92,6 +92,12 @@ struct netvsc_mp_param {
/* Retry interval for hot-add VF device (microseconds) */
#define NETVSC_HOTADD_RETRY_INTERVAL 1000000
+/* Max retries when net/ directory exists but no matching MAC found.
+ * On multi-NIC PCI devices, a second VF may register later.
+ * 120 retries = ~2 minutes.
+ */
+#define NETVSC_MAX_MAC_RETRY 120
+
struct hn_xstats_name_off {
char name[RTE_ETH_XSTATS_NAME_SIZE];
unsigned int offset;
@@ -768,8 +774,36 @@ static void netvsc_hotplug_retry(void *args)
RTE_ETHER_ADDR_BYTES(dev->data->mac_addrs));
}
+ /* If we opened the net directory but didn't find a matching MAC,
+ * the VF interface may not have appeared yet (e.g. on a multi-NIC
+ * PCI device, the second VF registers later). Retry.
+ */
+ if (di != NULL) {
+ closedir(di);
+ di = NULL;
+ if (dir == NULL) {
+ /* readdir returned NULL — loop ended without match */
+ hot_ctx->mac_retry++;
+ if (hot_ctx->mac_retry < NETVSC_MAX_MAC_RETRY) {
+ PMD_DRV_LOG(DEBUG,
+ "%s: no matching MAC found in %s, "
+ "retrying in 1 second (mac_retry %d/%d)",
+ __func__, buf,
+ hot_ctx->mac_retry,
+ NETVSC_MAX_MAC_RETRY);
+ rte_eal_alarm_set(NETVSC_HOTADD_RETRY_INTERVAL,
+ netvsc_hotplug_retry,
+ hot_ctx);
+ return;
+ }
+ PMD_DRV_LOG(NOTICE,
+ "%s: no matching MAC found after %d retries, giving up",
+ __func__, hot_ctx->mac_retry);
+ }
+ }
+
free_hotadd_ctx:
- if (di)
+ if (di != NULL)
closedir(di);
PMD_DRV_LOG(DEBUG, "%s: retry loop exiting for device %s (retry %d)",
diff --git a/drivers/net/netvsc/hn_var.h b/drivers/net/netvsc/hn_var.h
index ef55dee28e..574b909c82 100644
--- a/drivers/net/netvsc/hn_var.h
+++ b/drivers/net/netvsc/hn_var.h
@@ -127,6 +127,7 @@ struct hv_hotadd_context {
struct hn_data *hv;
struct rte_devargs da;
int eal_hot_plug_retry;
+ int mac_retry;
};
struct hn_data {
--
2.43.0
next prev parent reply other threads:[~2026-05-15 19:29 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-06 2:05 [PATCH v2 1/7] net/netvsc: retry VF hotplug indefinitely until PCI device disappears Long Li
2026-05-06 2:05 ` [PATCH v2 2/7] net/netvsc: retry on SIOCGIFHWADDR failure during VF hotplug Long Li
2026-05-06 2:05 ` [PATCH v2 3/7] net/netvsc: retry full probe when IB device not ready during hotplug Long Li
2026-05-06 2:05 ` [PATCH v2 4/7] net/netvsc: add debug logging for VF hotplug retry Long Li
2026-05-06 2:05 ` [PATCH v2 5/7] net/netvsc: retry when no matching MAC found in net directory Long Li
2026-05-06 2:05 ` [PATCH v2 6/7] net/netvsc: forward per-queue stats from VF device Long Li
2026-05-06 2:05 ` [PATCH v2 7/7] net/netvsc: handle VF recovery events for service reset Long Li
2026-05-07 2:49 ` [PATCH v2 1/7] net/netvsc: retry VF hotplug indefinitely until PCI device disappears Stephen Hemminger
2026-05-15 19:45 ` [EXTERNAL] " Long Li
2026-05-15 19:28 ` [PATCH v3 0/7] net/netvsc: fix VF hotplug and service reset handling Long Li
2026-05-15 19:28 ` [PATCH v3 1/7] net/netvsc: retry VF hotplug indefinitely until PCI device disappears Long Li
2026-05-15 19:28 ` [PATCH v3 2/7] net/netvsc: retry on SIOCGIFHWADDR failure during VF hotplug Long Li
2026-05-15 19:28 ` [PATCH v3 3/7] net/netvsc: retry full probe when IB device not ready during hotplug Long Li
2026-05-15 19:28 ` [PATCH v3 4/7] net/netvsc: add debug logging for VF hotplug retry Long Li
2026-05-15 19:28 ` Long Li [this message]
2026-05-15 19:28 ` [PATCH v3 6/7] net/netvsc: forward per-queue stats from VF device Long Li
2026-05-15 19:28 ` [PATCH v3 7/7] net/netvsc: handle VF recovery events for service reset Long Li
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=20260515192843.552762-6-longli@microsoft.com \
--to=longli@microsoft.com \
--cc=dev@dpdk.org \
--cc=stable@dpdk.org \
--cc=stephen@networkplumber.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