From nobody Fri Aug 21 00:44: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 4hR1mK7224z6pP6x for ; Fri, 21 Aug 2026 00:44: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 "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hR1mJ670dz44sr for ; Fri, 21 Aug 2026 00:44:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1787273088; 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=XGzGt2S/q7wG9xmvxQIHYtRGNxczgNKE7jzRQ9ydPEI=; b=ZN+TWjzj380FcCn9PMdCkErjc/KyWl2OWhn+hzfqtMM2TCxeRJYV07Hg+TaIm6advuWNE5 PleHYipaIYuqU2f5Xy9oIcywV1GXH4hDqkEJd5q6xK5OI1l+qC7HK31jB9wDd5p1TAZlTS mCyyi97tEdCnDmegJ+fmZyOf1LJriSBcYHe3ufQw4HoTT3rD5XLneWPZQwSwEQDJsER1dO JKPyPFpZ9EYniGWjWfWtVh0zRoofHuag8rxVHHKiTi2916XwFzkn7zYstMVRbFPg5puXzi kv0miQWYAP9h76j1PkFYauOuRSnFX8yp0zjBGl7fQ0qQxrzn3HQyp8jwEiNsgg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1787273088; a=rsa-sha256; cv=none; b=A6OKkzBZLi+JG6dCT65wbIdP8726HGRFB1KFFeddCl0z3oaipQKcBgm3KYiSn7kqNeRRkk K3unBjuetLzwoiGeI6c3ozjm6By/vXLbaltlW/IUzjig+YmUgtqtqlGzc4TpGfiMaoq8Na +Gu3ld6Jk9oGl4bh+8tdoEF1SkSkNRuY+F/4840XrZlZ6saAJ0awh29Mc/o0mkMQW36ONH bVsoL7oN6+EiV12kBsMpg+9j5/KaDkH1wDMhkMOllY+ZVpdMwRkoop3injV+H7iSuxfZzT d57YnfXn28MDilmrhsJ9qUyu+Q0eXTIsD3c77nsllltEKVHtWH0GiP+SjU4pmQ== 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=1787273088; 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=XGzGt2S/q7wG9xmvxQIHYtRGNxczgNKE7jzRQ9ydPEI=; b=W9+ROe4IPOYZ6AawrX2RDkVBTo1eU8aqoLB3besJ3SPJsKkdSmNsVJaL06q8GaHkqJaJ0d /MXdYRer1ECRupYlMsZCSRZk4DXda/nSy5cte81sWzcwtlUfaOt3Q2vffq0R7X3jBdnAyJ YxlRs2GYyOJ5neLFd6tLYN0Q4JL+82faf95zxzONO9oKfdn3dRV1oGjWcz+fi/JjVBiBf/ pRJ2KmMqKmf7pTIqSVUI7iBctjzOLZNSR+KaJapq1Ie+33si+oFbpqHL9sc3sHNYaW7cc6 O7SbeazVj+4bLM24P2o1RItoGsMApzjkCjJrreUUB8lXotwRKh8wF5Ln3Bj0Yg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hR1mJ2NgRzhVj for ; Fri, 21 Aug 2026 00:44:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 23fbf by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 21 Aug 2026 00:44:48 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: ef5956efcbde - stable/14 - ixgbe: Validate SR-IOV before restarting the PF 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/stable/14 X-Git-Reftype: branch X-Git-Commit: ef5956efcbde2afb1f565643a166ef1c4874787a Auto-Submitted: auto-generated Date: Fri, 21 Aug 2026 00:44:48 +0000 Message-Id: <6a879f80.23fbf.995ea56@gitrepo.freebsd.org> The branch stable/14 has been updated by kbowling: URL: https://cgit.FreeBSD.org/src/commit/?id=ef5956efcbde2afb1f565643a166ef1c4874787a commit ef5956efcbde2afb1f565643a166ef1c4874787a Author: Kevin Bowling AuthorDate: 2026-08-06 11:05:32 +0000 Commit: Kevin Bowling CommitDate: 2026-08-21 00:42:19 +0000 ixgbe: Validate SR-IOV before restarting the PF A deterministic IOV configuration error currently reaches the driver only after iflib has stopped the PF. The required cleanup restart then causes an avoidable carrier flap. Follow the igb pattern and validate the request in the PCI IOV method before entering the restart transaction. Reject queue layouts wider than the selected virtualization pool before they can alias unrelated 82599 registers. (cherry picked from commit 703c756a2d298e5841471eb7d4d40f95a0dafe50) --- sys/dev/ixgbe/if_ix.c | 23 +++++++++++++++- sys/dev/ixgbe/if_sriov.c | 67 +++++++++++++++++++++++++++++++++------------ sys/dev/ixgbe/ixgbe_sriov.h | 1 + 3 files changed, 73 insertions(+), 18 deletions(-) diff --git a/sys/dev/ixgbe/if_ix.c b/sys/dev/ixgbe/if_ix.c index ca7a277dfc16..aa649e7a16e9 100644 --- a/sys/dev/ixgbe/if_ix.c +++ b/sys/dev/ixgbe/if_ix.c @@ -165,6 +165,9 @@ static int ixgbe_if_detach(if_ctx_t); static int ixgbe_if_shutdown(if_ctx_t); static int ixgbe_if_suspend(if_ctx_t); static int ixgbe_if_resume(if_ctx_t); +#ifdef PCI_IOV +static int ixgbe_device_iov_init(device_t, uint16_t, const nvlist_t *); +#endif static void ixgbe_if_stop(if_ctx_t); void ixgbe_if_enable_intr(if_ctx_t); @@ -293,7 +296,7 @@ static device_method_t ix_methods[] = { DEVMETHOD(device_suspend, iflib_device_suspend), DEVMETHOD(device_resume, iflib_device_resume), #ifdef PCI_IOV - DEVMETHOD(pci_iov_init, iflib_device_iov_init_restart), + DEVMETHOD(pci_iov_init, ixgbe_device_iov_init), DEVMETHOD(pci_iov_uninit, iflib_device_iov_uninit_restart), DEVMETHOD(pci_iov_add_vf, iflib_device_iov_add_vf), #endif /* PCI_IOV */ @@ -310,6 +313,24 @@ MODULE_DEPEND(ix, pci, 1, 1, 1); MODULE_DEPEND(ix, ether, 1, 1, 1); MODULE_DEPEND(ix, iflib, 1, 1, 1); +#ifdef PCI_IOV +static int +ixgbe_device_iov_init(device_t dev, uint16_t num_vfs, + const nvlist_t *params) +{ + struct ixgbe_softc *sc; + if_ctx_t ctx; + int error; + + ctx = device_get_softc(dev); + sc = iflib_get_softc(ctx); + error = ixgbe_iov_validate(sc, num_vfs); + if (error != 0) + return (error); + return (iflib_device_iov_init_restart(dev, num_vfs, params)); +} +#endif + static device_method_t ixgbe_if_methods[] = { DEVMETHOD(ifdi_attach_pre, ixgbe_if_attach_pre), DEVMETHOD(ifdi_attach_post, ixgbe_if_attach_post), diff --git a/sys/dev/ixgbe/if_sriov.c b/sys/dev/ixgbe/if_sriov.c index c05b82533081..b2325046d5e8 100644 --- a/sys/dev/ixgbe/if_sriov.c +++ b/sys/dev/ixgbe/if_sriov.c @@ -1028,18 +1028,20 @@ ixgbe_handle_mbx(void *context) } /* ixgbe_handle_mbx */ int -ixgbe_if_iov_init(if_ctx_t ctx, u16 num_vfs, const nvlist_t *config) +ixgbe_iov_validate(struct ixgbe_softc *sc, u16 num_vfs) { - struct ixgbe_softc *sc; - int i, num_filters, retval = 0; - - sc = iflib_get_softc(ctx); - sc->iov_mode = IXGBE_NO_VM; + int mode, pool, queue_count; - if (num_vfs == 0) { - /* Would we ever get num_vfs = 0? */ - retval = EINVAL; - goto err_init_iov; + if (!(sc->feat_cap & IXGBE_FEATURE_SRIOV)) + return (ENXIO); + if (num_vfs == 0) + return (EINVAL); + if (sc->vfs != NULL || sc->vf_mac_filters != NULL || + (sc->feat_en & IXGBE_FEATURE_SRIOV)) + return (EBUSY); + if (sc->intr_type != IFLIB_INTR_MSIX) { + device_printf(sc->dev, "SR-IOV requires MSI-X\n"); + return (ENOTSUP); } /* @@ -1049,17 +1051,43 @@ ixgbe_if_iov_init(if_ctx_t ctx, u16 num_vfs, const nvlist_t *config) * With 32 VFs, you can have up to four queues per VF. */ if (num_vfs >= IXGBE_32_VM) - sc->iov_mode = IXGBE_64_VM; + mode = IXGBE_64_VM; else - sc->iov_mode = IXGBE_32_VM; + mode = IXGBE_32_VM; + queue_count = ixgbe_vf_queues(mode); + if (sc->num_rx_queues > queue_count || + sc->num_tx_queues > queue_count) { + device_printf(sc->dev, + "SR-IOV mode supports %d PF queues, but %d RX and %d TX " + "queues are allocated\n", queue_count, sc->num_rx_queues, + sc->num_tx_queues); + return (ENOSPC); + } /* Again, reserving 1 VM's worth of queues for the PF */ - sc->pool = sc->iov_mode - 1; + pool = mode - 1; + if (num_vfs > pool || num_vfs >= IXGBE_64_VM) + return (ENOSPC); + return (0); +} - if ((num_vfs > sc->pool) || (num_vfs >= IXGBE_64_VM)) { - retval = ENOSPC; - goto err_init_iov; - } +int +ixgbe_if_iov_init(if_ctx_t ctx, u16 num_vfs, const nvlist_t *config) +{ + struct ixgbe_softc *sc; + int i, num_filters, retval; + + (void)config; + sc = iflib_get_softc(ctx); + retval = ixgbe_iov_validate(sc, num_vfs); + if (retval != 0) + return (retval); + + if (num_vfs >= IXGBE_32_VM) + sc->iov_mode = IXGBE_64_VM; + else + sc->iov_mode = IXGBE_32_VM; + sc->pool = sc->iov_mode - 1; sc->vfs = malloc(sizeof(*sc->vfs) * num_vfs, M_IXGBE_SRIOV, M_NOWAIT | M_ZERO); @@ -1093,6 +1121,11 @@ ixgbe_if_iov_init(if_ctx_t ctx, u16 num_vfs, const nvlist_t *config) return (retval); err_init_iov: + free(sc->vf_mac_filters, M_IXGBE_SRIOV); + sc->vf_mac_filters = NULL; + sc->num_vf_mac_filters = 0; + free(sc->vfs, M_IXGBE_SRIOV); + sc->vfs = NULL; sc->num_vfs = 0; sc->pool = 0; sc->iov_mode = IXGBE_NO_VM; diff --git a/sys/dev/ixgbe/ixgbe_sriov.h b/sys/dev/ixgbe/ixgbe_sriov.h index c38f4075b97a..443bf78e9a1d 100644 --- a/sys/dev/ixgbe/ixgbe_sriov.h +++ b/sys/dev/ixgbe/ixgbe_sriov.h @@ -74,6 +74,7 @@ int ixgbe_if_iov_vf_add(if_ctx_t, u16, const nvlist_t *); int ixgbe_if_iov_init(if_ctx_t, u16, const nvlist_t *); +int ixgbe_iov_validate(struct ixgbe_softc *, u16); void ixgbe_if_iov_uninit(if_ctx_t); void ixgbe_initialize_iov(struct ixgbe_softc *); void ixgbe_recalculate_max_frame(struct ixgbe_softc *);