git: dc1d2c7f1453 - stable/14 - iflib: Permit SR-IOV configuration on a down interface

Kevin Bowling <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a8223be.18b8e.27042a2b__9199.89407282031$1786913822$gmane$org@gitrepo.freebsd.org>
The branch stable/14 has been updated by kbowling:

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

commit dc1d2c7f1453544ad11d9f88e5207cc6670acec5
Author:     Kevin Bowling <[email protected]>
AuthorDate: 2026-08-06 11:03:28 +0000
Commit:     Kevin Bowling <[email protected]>
CommitDate: 2026-08-16 20:54:37 +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 0f6ecb73a8a0..dcdbe816f9aa 100644
--- a/sys/net/iflib.c
+++ b/sys/net/iflib.c
@@ -5585,6 +5585,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)
 {
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.