git: 5cd4954f3283 - stable/15 - iflib: Permit SR-IOV configuration on a down interface

From: Kevin Bowling <kbowling_at_FreeBSD.org>
Date: Sun, 16 Aug 2026 20:57:04 UTC
The branch stable/15 has been updated by kbowling:

URL: https://cgit.FreeBSD.org/src/commit/?id=5cd4954f328331384510486a023e6f03d08ec6a9

commit 5cd4954f328331384510486a023e6f03d08ec6a9
Author:     Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2026-08-06 11:03:28 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2026-08-16 20:56:45 +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 and
    lets other opt-in drivers configure VFs before netif brings the PF up.
    
    (cherry picked from commit 2cf580c694f6f392531a63f01c3fb89c0244f89a)
---
 sys/net/iflib.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/sys/net/iflib.c b/sys/net/iflib.c
index 786e5484f542..711c27f62939 100644
--- a/sys/net/iflib.c
+++ b/sys/net/iflib.c
@@ -5445,6 +5445,37 @@ iflib_device_iov_init(device_t dev, uint16_t num_vfs, const nvlist_t *params)
 	return (error);
 }
 
+int
+iflib_device_iov_init_restart(device_t dev, uint16_t num_vfs,
+    const nvlist_t *params)
+{
+	if_ctx_t ctx;
+	if_t ifp;
+	bool restart, running;
+	int error;
+
+	ctx = device_get_softc(dev);
+	ifp = ctx->ifc_ifp;
+
+	CTX_LOCK(ctx);
+	/*
+	 * Drivers which change the PF queue layout need the complete iflib
+	 * 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.
+	 */
+	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);
+	if (restart)
+		iflib_init_locked(ctx);
+	CTX_UNLOCK(ctx);
+	return (error);
+}
+
 void
 iflib_device_iov_uninit(device_t dev)
 {