git: 2cf580c694f6 - main - iflib: Permit SR-IOV configuration on a down interface

Kevin Bowling <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a75885a.41603.79234098__46668.8725560502$1786087549$gmane$org@gitrepo.freebsd.org>
The branch main has been updated by kbowling:

URL: https://cgit.FreeBSD.org/src/commit/?id=2cf580c694f6f392531a63f01c3fb89c0244f89a

commit 2cf580c694f6f392531a63f01c3fb89c0244f89a
Author:     Kevin Bowling <[email protected]>
AuthorDate: 2026-08-06 11:03:28 +0000
Commit:     Kevin Bowling <[email protected]>
CommitDate: 2026-08-07 07:24:57 +0000

    iflib: Permit SR-IOV configuration on a down interface
    
    Drivers which remap PF queues need a stop/mutate/restart transaction
    only when the interface has live queues. Permit their IOV
    initialization callback while the interface is administratively down
    and leave it down afterward.
    
    This restores the standard boot-time iovctl.conf workflow for igb and
    lets other opt-in drivers configure VFs before netif brings the PF up.
    
    MFC after:      1 week
---
 share/man/man4/em.4        |  8 +++++---
 sys/dev/e1000/if_igb_iov.c |  4 ++++
 sys/net/iflib.c            | 22 +++++++++++-----------
 3 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/share/man/man4/em.4 b/share/man/man4/em.4
index 328e1e77b18b..22898e894b00 100644
--- a/share/man/man4/em.4
+++ b/share/man/man4/em.4
@@ -32,7 +32,7 @@
 .\"
 .\" * Other names and brands may be claimed as the property of others.
 .\"
-.Dd July 29, 2026
+.Dd August 7, 2026
 .Dt EM 4
 .Os
 .Sh NAME
@@ -188,8 +188,10 @@ The supported SR-IOV configuration uses one PF transmit and receive queue and
 requires MSI-X.
 I350 requires this layout; 82576 hardware can combine VMDq with per-pool RSS,
 but that mode is not implemented by this driver.
-The PF must be administratively up and running when VFs are created and must
-remain up for VF mailbox and datapath service.
+The PF may be administratively down when VFs are created and remains down
+afterward.
+VF mailbox and datapath service begin when the PF is brought up, and the PF
+must remain up to provide those services.
 Creating or destroying VFs temporarily stops and restarts a running PF.
 Set the following per-device
 .Xr iflib 4
diff --git a/sys/dev/e1000/if_igb_iov.c b/sys/dev/e1000/if_igb_iov.c
index 7b6c18690db5..dc4b23397431 100644
--- a/sys/dev/e1000/if_igb_iov.c
+++ b/sys/dev/e1000/if_igb_iov.c
@@ -2003,6 +2003,10 @@ igb_if_iov_init(if_ctx_t ctx, u16 num_vfs, const nvlist_t *config)
 
 	sc = iflib_get_softc(ctx);
 	(void)config;
+	/*
+	 * This callback may run while the PF is down.  Record the software
+	 * layout here; igb_iov_initialize() programs it during interface init.
+	 */
 	atomic_store_rel_32(&sc->iov_teardown, 0);
 	error = igb_iov_validate(sc, num_vfs);
 	if (error != 0)
diff --git a/sys/net/iflib.c b/sys/net/iflib.c
index 63455fb46d70..da26926c8b17 100644
--- a/sys/net/iflib.c
+++ b/sys/net/iflib.c
@@ -5621,6 +5621,7 @@ iflib_device_iov_init_restart(device_t dev, uint16_t num_vfs,
 {
 	if_ctx_t ctx;
 	if_t ifp;
+	bool restart, running;
 	int error;
 
 	ctx = device_get_softc(dev);
@@ -5629,19 +5630,18 @@ iflib_device_iov_init_restart(device_t dev, uint16_t num_vfs,
 	CTX_LOCK(ctx);
 	/*
 	 * Drivers which change the PF queue layout need the complete iflib
-	 * stop/init sequence around their IOV callback.  Keep that transition
-	 * within one context-lock critical section.
+	 * stop/init sequence around their IOV callback when the interface is
+	 * active.  An administratively-down interface has no live queues to
+	 * quiesce, and must remain down after the new layout is installed.
+	 * Keep the transition within one context-lock critical section.
 	 */
-	if ((if_getflags(ifp) & IFF_UP) == 0 ||
-	    (if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0) {
-		error = ENETDOWN;
-		goto out;
-	}
-
-	iflib_stop(ctx);
+	restart = (if_getflags(ifp) & IFF_UP) != 0;
+	running = (if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0;
+	if (restart || running)
+		iflib_stop(ctx);
 	error = IFDI_IOV_INIT(ctx, num_vfs, params);
-	iflib_init_locked(ctx);
-out:
+	if (restart)
+		iflib_init_locked(ctx);
 	CTX_UNLOCK(ctx);
 	return (error);
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.