From nobody Thu Jul 30 00:08:48 2026 X-Original-To: dev-commits-src-main@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 4h9V0x0fbbz6n6fX for ; Thu, 30 Jul 2026 00:08:49 +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 4h9V0x01mvz3rRF for ; Thu, 30 Jul 2026 00:08:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1785370129; 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=RE1+FFUHwpq5tpuGFO2VXgiT6OiOP/YRIDCQOr2ck0PlhqpsRUEsSaA0UbJjetLSmclF5z EDAuhpCO5R60eFTbwJ/T5TnKy0o5fv7Eqe9HEIcLWDiyWPdarH7QSnsUnd58KQh8pp+tIa NZFvx+kNRDXpoBihbM5msAWvELA5FoE331b0F0aNrS8Wceo37vbPK4qEjKdPEOSnc+6/LH ybU1WcKKL4+mFFo8bDxOqdoBJt9XHqFlLY5+HBmtWo0ClS7bKyJ3h6sR1mCwJt8JfLo4vu 8l6CJaXM7PTYasUyTjpKWdCtaZzJjWLe9P7iU9JM1Qv2tujk1NPdUOIcqE/DgQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1785370129; a=rsa-sha256; cv=none; b=Vx7ssjDe1gHUywC+G4irbxKRZXzNxOr4EL7gosdzM+IKCTZgKjZ2uNUeRVl5M4wcl2tfqf yrh2rapooG35zAn3+xkyi5eZ8isdzq7ZVbFjSY2KMED31UrMginrZx8ZHabjMZGOGU69NB cDHYhWnhxCW5u+lQXdFURluXzJdsg0ZqNucHPboFB0uqFyWvXU0i50Vj1wQH73kXuaQmKp eSBIkdA3b7Z8JAEUlveWimfjFNacei5S+WSlzvUIIla9Nxq0YhaY4MTG8KbIPv8PwV+5tJ GvY5bTd5IvEigmU+4ZA3Gsv1NA4C/Clf1XYKbdwz33xZ5tPL0/qNTfno1c9yog== 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=1785370129; 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=SnfOBqisTOdZO31N/NDm7tZSKjRainCMtTJL4fi+V1rbohpduUY603HALjgqsTZEvjDLMK ZP1dWcc8lB1bFx0gs6abZJ9Y51wAgUNjtfhthvZN1st9/NS1VSHaZh3iOQd8Gn5y07jS1J QyZhVnhRdIqV0lx0vosUT3o+1NAbdLg6eDcRu5//75uF10ntPUr6TgnVw5T6LtLn+lCvKS 3NpUcTMwZV7ZrvVbuFqN6GDK9xerf7VRYhIfw6rhK+9+CQE3xgeutsXnEWhWK/ioxJUbzk WezDuNkLGqEUkjBos49RM56wPQ4JwwYJI7qOpayr8CAX//yoeGABQDacXAKBOQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4h9V0w5f3Gzpdk for ; Thu, 30 Jul 2026 00:08:48 +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 the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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 *); /*