From nobody Thu Jul 30 00:08:48 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4h9V120r67z6n6XX for ; Thu, 30 Jul 2026 00:08:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4h9V120Cznz3rYH for ; Thu, 30 Jul 2026 00:08:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1785370134; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0zwQd7Klyy3Si7r28ZcMFxVWj3yBH7jhQt+67Tdha9M=; b=lMF7Iv7Fc9QnymAs4McV3vE4xPLGntmTAa6bHdnWZIup5qAMZHviHOigov3BihA1fHK6R4 ulrpJ+DS08+kv47KCH9ytvco9VV1jKQCZp+tQh47IcJukDMI/7cQi2Op2hskASdWN6xw5s GH0gB0XJcNMDOvKm10XtaLasvawkPIBiHZreSNHYdJbJRQDEmgn7127sJBhK8F1rX3tPM9 8D6IV3vBZN0yxjaSzzdQ0+LbRBdcCZSsziX4IUsPh13oSkj9oG4mndcm4TE9lUlM7gC3Z2 MhhfWZQeS7O+tUPZlj2REMgI9VhcSyJa6VLZE/PQ+Gtzvtb4EXRa0+fvZmyPDg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1785370134; a=rsa-sha256; cv=none; b=w5KeAF8aWegLPOwomNMYMQZYvEH0PtTPakxar1v8u4UGNDHuK2rCqVdyCq+AXxrCRlPqD5 qnmfhel/FfNJWsD17uUZysL/yqnO5vufFDc/hpDMBfUn0te53o+LUFs1FFV4ZUx/vLOMi4 H3zqroCYhgw4PWyupivtwQY0ZIaUmh3dsyySzmko429TlQSwyI6OOmhqnkgWHZPJoCuQ8O dGP5Fy4UlbpG2NYwaLExQICFj1U01MwrWxuTL3loBSkdt5SO4U+iKxniEgSLSiLubI2Dyu 32kAbVkCBiDtyJFt7x2ZbG6eXzOsuG+RkeemIbL9N9k+9htDVTzQoSINOOJaNw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1785370134; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0zwQd7Klyy3Si7r28ZcMFxVWj3yBH7jhQt+67Tdha9M=; b=aV2Gew+rYrlWojOCR2gqF+twuuiRbK3zCPtTV7mGA8NLupKfMVsKsAZF69U3uhfZ+hAlJF w63Ne9j3dyj3ZWUFp3YtzOzIXuvnd3GnRQdI0psuj9n0bkaOcjvdPqUny/YzQpydjDUChJ xZuwTqDBJbb+/lKs4uNoRZN7kl8dYHYxQnW0SpNcuBLDwrZp8llrOpIDBFRZx7VbEcOfo8 nuliL1o/DZ0x6TLA9yul8hRXThAiY7GRgJ2PvDwTDiwrn+yfvCQu+i+fsY2lCssR3LMs49 GRaCldCTJLzOuWtU2vR3D+qpBrDM7Y5fyoGPqWEnHHp7DnvQ+4D97vyQT0Y1Vw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4h9V115pZMzpdl for ; Thu, 30 Jul 2026 00:08:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3a37e by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 30 Jul 2026 00:08:48 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kevin Bowling Subject: git: f8fa2d77bc30 - main - iflib: Add restart transactions for IOV reconfiguration List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f8fa2d77bc305bec519f9f02afe211e903c57573 Auto-Submitted: auto-generated Date: Thu, 30 Jul 2026 00:08:48 +0000 Message-Id: <6a6a9610.3a37e.22e4499d@gitrepo.freebsd.org> The branch main has been updated by kbowling: URL: https://cgit.FreeBSD.org/src/commit/?id=f8fa2d77bc305bec519f9f02afe211e903c57573 commit f8fa2d77bc305bec519f9f02afe211e903c57573 Author: Kevin Bowling AuthorDate: 2026-07-28 21:53:18 +0000 Commit: Kevin Bowling CommitDate: 2026-07-30 00:08:41 +0000 iflib: Add restart transactions for IOV reconfiguration Some devices remap the PF queues when entering or leaving SR-IOV. Add opt-in PCI IOV helpers that hold the iflib context lock across the complete stop, driver callback, and restart transaction. Existing drivers continue to use the non-restarting helpers. Sponsored by: BBOX.io --- sys/net/iflib.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ sys/net/iflib.h | 2 ++ 2 files changed, 55 insertions(+) diff --git a/sys/net/iflib.c b/sys/net/iflib.c index 87626ae59815..b6a8ec1eb6ce 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -5545,6 +5545,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; + 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. Keep that 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); + error = IFDI_IOV_INIT(ctx, num_vfs, params); + iflib_init_locked(ctx); +out: + CTX_UNLOCK(ctx); + return (error); +} + void iflib_device_iov_uninit(device_t dev) { @@ -5555,6 +5586,28 @@ iflib_device_iov_uninit(device_t dev) CTX_UNLOCK(ctx); } +void +iflib_device_iov_uninit_restart(device_t dev) +{ + if_ctx_t ctx; + bool restart; + + ctx = device_get_softc(dev); + + CTX_LOCK(ctx); + /* + * RUNNING can be clear while a watchdog reset is pending but the + * hardware is still live. Always stop before the driver changes its + * queue layout, and use IFF_UP only to preserve administrative state. + */ + restart = (if_getflags(ctx->ifc_ifp) & IFF_UP) != 0; + iflib_stop(ctx); + IFDI_IOV_UNINIT(ctx); + if (restart) + iflib_init_locked(ctx); + CTX_UNLOCK(ctx); +} + int iflib_device_iov_add_vf(device_t dev, uint16_t vfnum, const nvlist_t *params) { diff --git a/sys/net/iflib.h b/sys/net/iflib.h index c73c50e5a3b3..6e9c6e10cc5d 100644 --- a/sys/net/iflib.h +++ b/sys/net/iflib.h @@ -450,7 +450,9 @@ int iflib_device_shutdown(device_t); int iflib_device_probe_vendor(device_t); int iflib_device_iov_init(device_t, uint16_t, const nvlist_t *); +int iflib_device_iov_init_restart(device_t, uint16_t, const nvlist_t *); void iflib_device_iov_uninit(device_t); +void iflib_device_iov_uninit_restart(device_t); int iflib_device_iov_add_vf(device_t, uint16_t, const nvlist_t *); /*