Skip to content

Commit a946898

Browse files
committed
net/netvsc: retry when no matching MAC found in net directory
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 30, ~30 seconds) so the main retry loop remains unlimited. Signed-off-by: Long Li <longli@microsoft.com>
1 parent a3ce92e commit a946898

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

drivers/net/netvsc/hn_ethdev.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ struct netvsc_mp_param {
9292
/* Retry interval for hot-add VF device (microseconds) */
9393
#define NETVSC_HOTADD_RETRY_INTERVAL 1000000
9494

95+
/* Max retries when net/ directory exists but no matching MAC found.
96+
* On multi-NIC PCI devices, a second VF may register later.
97+
* 120 retries = ~2 minutes.
98+
*/
99+
#define NETVSC_MAX_MAC_RETRY 120
100+
95101
struct hn_xstats_name_off {
96102
char name[RTE_ETH_XSTATS_NAME_SIZE];
97103
unsigned int offset;
@@ -763,6 +769,34 @@ static void netvsc_hotplug_retry(void *args)
763769
}
764770
}
765771

772+
/* If we opened the net directory but didn't find a matching MAC,
773+
* the VF interface may not have appeared yet (e.g. on a multi-NIC
774+
* PCI device, the second VF registers later). Retry.
775+
*/
776+
if (di) {
777+
closedir(di);
778+
di = NULL;
779+
if (!dir) {
780+
/* readdir returned NULL — loop ended without match */
781+
hot_ctx->mac_retry++;
782+
if (hot_ctx->mac_retry < NETVSC_MAX_MAC_RETRY) {
783+
PMD_DRV_LOG(NOTICE,
784+
"%s: no matching MAC found in %s, "
785+
"retrying in 1 second (mac_retry %d/%d)",
786+
__func__, buf,
787+
hot_ctx->mac_retry,
788+
NETVSC_MAX_MAC_RETRY);
789+
rte_eal_alarm_set(NETVSC_HOTADD_RETRY_INTERVAL,
790+
netvsc_hotplug_retry,
791+
hot_ctx);
792+
return;
793+
}
794+
PMD_DRV_LOG(NOTICE,
795+
"%s: no matching MAC found after %d retries, giving up",
796+
__func__, hot_ctx->mac_retry);
797+
}
798+
}
799+
766800
free_hotadd_ctx:
767801
if (di)
768802
closedir(di);

drivers/net/netvsc/hn_var.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ struct hv_hotadd_context {
127127
struct hn_data *hv;
128128
struct rte_devargs da;
129129
int eal_hot_plug_retry;
130+
int mac_retry;
130131
};
131132

132133
struct hn_data {

0 commit comments

Comments
 (0)