From nobody Fri Aug 21 00:31:05 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 4hR1ST2mQ1z6pMrg for ; Fri, 21 Aug 2026 00:31:05 +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 4hR1ST27Mpz3xPj for ; Fri, 21 Aug 2026 00:31:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1787272265; 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=UvhA9dtDuu4pgnL2R60Opr4KlJdg6D8R3ibUR2QNicQ=; b=tB1Y+ukGQZUuheteOePObEiKxPr0u964NrkF+PNnb0LYkhB2RGAhpVjT1yjAoZp/AqHghM Xn9+uUf8mQsCWF6sbGcVYWnJlGTzTqlbZb6OgqxXGt9g8YSnKdaHWWS6zvnn2Q33kzgN1a 7GZ4IdyDulbluYVl/P23w3+9HwyE9/XilWYwiQypHSUhhMIoV+E57uBjTQS95g7eYAVBNu 8HY2KEo4UQtTqlmh4N4AncRmiL1Bns6KuGS5wlah5ZtRefEIqNCKOCFe7fmCvJC1vedj8J cAsCOl8uBQJinpB07lMYNW9E64DmeDaAPw7QN+bsy5NN9x9St6rgbdLtr/wORA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1787272265; a=rsa-sha256; cv=none; b=Er5V7vd2Q4pXJf/ps4Hm07tt3vj/EA82ZkRY8HQqW4fWuz6ZTwqeKL44rjVtNg5bSYr3F5 GWab0TXLwm9SExTavu4P3Lqcrnd5auyGT3JA66gx942T/ku3FzPR++ypcq4VDe84pqxvRL 1xj3cfwfwnBtYsVpKXyWqxZdFjZge+N7vJf63qu9xYdkDEmUziPmCPDYIrCQ+cMayU1Mrp 5t7AKg+0POxRCjIZZWxsahILoOUizStmdS9lFji54fZoL84AU51Lcm2OZ0cJiPm12eW+fC jAVQchgzMRfCHnqtrilsGDj4Tj+XHeWGblKtpO3Lh/+HWZp+Z2uQ2in6KIS6Mg== 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=1787272265; 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=UvhA9dtDuu4pgnL2R60Opr4KlJdg6D8R3ibUR2QNicQ=; b=AJaCdBOFDaFu0h8QMqdztpc43QMyoBzuKIrl36goAAKGtUqYSOFYRM+mIWN1e70yUqfH7G kOg+/S2Tlw1M59kSLMdTsBlBW9pdj7CgnvOLr68cmUSmLDwrd9vhj2wjH/THyaMq0anOYy q8iG8hu/D0pQajPApyMxxV3geXe5FlsYlLTRcQtQUkq/rBrJzbaFSxH9wfcr5ZWkYJGUu1 +YVAEj1Ra1PKb0SgaMDtz/m4oeD5IPXmHcqyUqWFQncpr1DCGUa3/lDBcg1yvP4tIvHGhM 7BpQxlcAaHd5PTGuI8lF9FLgP8V/MYSJ7xy4j4T5CEghaN8mmrU/kPm5VzJbpg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hR1ST0vhQzgct for ; Fri, 21 Aug 2026 00:31:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 23a32 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 21 Aug 2026 00:31:05 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: 2483c7dded33 - stable/15 - 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/15 X-Git-Reftype: branch X-Git-Commit: 2483c7dded33c9d98437863775f43d7c4d464195 Auto-Submitted: auto-generated Date: Fri, 21 Aug 2026 00:31:05 +0000 Message-Id: <6a879c49.23a32.3d61f315@gitrepo.freebsd.org> The branch stable/15 has been updated by kbowling: URL: https://cgit.FreeBSD.org/src/commit/?id=2483c7dded33c9d98437863775f43d7c4d464195 commit 2483c7dded33c9d98437863775f43d7c4d464195 Author: Kevin Bowling AuthorDate: 2026-08-06 11:05:32 +0000 Commit: Kevin Bowling CommitDate: 2026-08-21 00:30:57 +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 *);