From nobody Sun Sep 06 14:40:39 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 4hdCYM2f2cz6rCvb for ; Sun, 06 Sep 2026 14:40:39 +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 4hdCYM1Lqnz41dt for ; Sun, 06 Sep 2026 14:40:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1788705639; 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=G3FLh3qjtncHT3qy5suzxj+FU3TP3D7IFfCYxC89zxE=; b=xdb1NYJiSFhPef4wWQIv9+8PV2mypGupEZCSoXS//Ozau9XXsKj6m1kA2krFxeoron5w6K c7BbDfh+1c9twMNuP6rRLsXOl6jHhG6G/5OuH6nfyQ8YrXCWoByRTMyrkDDJgh6M1cRfxb zj8N4+IQSBg984dJ7x++Be4J0z7lYlF2/dedqCCVGMzNsYepX01hCf0df7f5qw7B8FsevV 1Zy97/ijk1fHA7RC/xmoxJWsxWA7WQOcs7jHEVDmYm3igQvjcTQajokzURc+5TwYMzLKeN 2m1QeCxv8Y1bNw1GLm+cRvCVp4ec/8Ycn096g1xdkk++btRA+LLk6V21au1lFw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1788705639; a=rsa-sha256; cv=none; b=lpURhgGbiEqVnPDcr/W8Be8FozTn0djTUx3M3unxRJAFYuT99uACVcyN00p3i3gPpZ3gSs BSRUm+7TYi0G3IGvc9qRWfhiM41Hee+aB2NmOmqXTNkI4KgLPBKKPngnDcAbm5wxkORpa/ cBVvmCx9T4UUfmUOKXH0XjWUkn3MGwp8Dc0Qp43lH5exaf6sgIHyPCkD02dct3MG+S+tFu FomR1fskCUWsMdMCVrt+xQCG68hp9mjhVubxwT9qD1C3Jif6HiAkhm9zavJ4tb1sAIk3EV 5u03UxVZKT6KvFV4wcCtE4+oqZQzjVG+3uiSy+Bnabr+S3t6NfTT0ILY7lSuIQ== 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=1788705639; 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=G3FLh3qjtncHT3qy5suzxj+FU3TP3D7IFfCYxC89zxE=; b=x3oBXcuKDm2TXNkaJQuxWP3l+i4A5vwPi0jaRo7KbRgZRfYcl8lf3hxkgqtC13hIHtvmqU 8XeNuQqZJhPEEOb8B4O/UHp6Y5n4wz7ho940p8HqJi5L8ToQrgdqjfMZ5kfK93FzTj95yj LAW3yqecBl5cKamwxwwW2AUXKkuQHR0nkb6xzQ4Zsphtw466qZstXZr8NekAYv+ICyGNon qnxkCl20r1PzhSFL9zCzhW/QipwiODeDxMhl1OIUz+CT5ml/IJV8adcK4/NB+WBCLHQjgm qu4pg6UID+2uRP+zPA8/eslG/2IpgTjtjTiIlNhXGVzdh//T++fhD46RqjCKMw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hdCYM0GGTzbtv for ; Sun, 06 Sep 2026 14:40:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3cde9 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 06 Sep 2026 14:40:39 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kevin Bowling Subject: git: 049331b20657 - main - ixgbe: Report SR-IOV VF status 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: 049331b20657cf0e7723c071efb75fda53a655fd Auto-Submitted: auto-generated Date: Sun, 06 Sep 2026 14:40:39 +0000 Message-Id: <6a9d7b67.3cde9.4cb74f54@gitrepo.freebsd.org> The branch main has been updated by kbowling: URL: https://cgit.FreeBSD.org/src/commit/?id=049331b20657cf0e7723c071efb75fda53a655fd commit 049331b20657cf0e7723c071efb75fda53a655fd Author: Kevin Bowling AuthorDate: 2026-08-10 22:29:37 +0000 Commit: Kevin Bowling CommitDate: 2026-09-06 14:40:32 +0000 ixgbe: Report SR-IOV VF status Expose cached VF configuration, policy, and runtime state through the iflib VF status method. Include access or trunk VLAN mode, transmit and receive queue counts selected by the current virtualization mode, negotiated mailbox API, PF traffic permission, fault containment, and quarantine state. Initialize every cached API version before VF enumeration so an unconfigured slot cannot be mistaken for API 1.0. The query does not issue mailbox requests or read hardware registers. Sponsored by: BBOX.io --- sys/dev/ixgbe/if_ix.c | 3 +- sys/dev/ixgbe/if_sriov.c | 105 +++++++++++++++++++++++++++++++++++++++++++- sys/dev/ixgbe/ixgbe.h | 1 + sys/dev/ixgbe/ixgbe_sriov.h | 4 +- 4 files changed, 110 insertions(+), 3 deletions(-) diff --git a/sys/dev/ixgbe/if_ix.c b/sys/dev/ixgbe/if_ix.c index 4eec0badc465..e7bcf150319a 100644 --- a/sys/dev/ixgbe/if_ix.c +++ b/sys/dev/ixgbe/if_ix.c @@ -395,6 +395,7 @@ static device_method_t ixgbe_if_methods[] = { DEVMETHOD(ifdi_iov_init, ixgbe_if_iov_init), DEVMETHOD(ifdi_iov_uninit, ixgbe_if_iov_uninit), DEVMETHOD(ifdi_iov_vf_add, ixgbe_if_iov_vf_add), + DEVMETHOD(ifdi_vf_status, ixgbe_if_vf_status), #endif /* PCI_IOV */ DEVMETHOD_END }; @@ -1391,7 +1392,7 @@ ixgbe_if_attach_post(if_ctx_t ctx) sc->advertise = ixgbe_get_default_advertise(sc); if (sc->feat_cap & IXGBE_FEATURE_SRIOV) - ixgbe_define_iov_schemas(dev, &error); + ixgbe_define_iov_schemas(sc, &error); /* Add sysctls */ ixgbe_add_device_sysctls(ctx); diff --git a/sys/dev/ixgbe/if_sriov.c b/sys/dev/ixgbe/if_sriov.c index 13ba3cdaf132..7f2689f39459 100644 --- a/sys/dev/ixgbe/if_sriov.c +++ b/sys/dev/ixgbe/if_sriov.c @@ -39,6 +39,8 @@ #include #include +#include + MALLOC_DEFINE(M_IXGBE_SRIOV, "ix_sriov", "ix SR-IOV allocations"); #define IXGBE_VF_MBX_CLEANUP_GRACE (2 * SBT_1S) @@ -59,10 +61,12 @@ ixgbe_has_legacy_iov_recovery(const struct ixgbe_hw *hw) * ixgbe_define_iov_schemas ************************************************************************/ void -ixgbe_define_iov_schemas(device_t dev, int *error) +ixgbe_define_iov_schemas(struct ixgbe_softc *sc, int *error) { + device_t dev; nvlist_t *pf_schema, *vf_schema; + dev = sc->dev; pf_schema = pci_iov_schema_alloc_node(); vf_schema = pci_iov_schema_alloc_node(); pci_iov_schema_add_unicast_mac(vf_schema, "mac-addr", 0, NULL); @@ -78,6 +82,8 @@ ixgbe_define_iov_schemas(device_t dev, int *error) if (*error != 0) { device_printf(dev, "Error %d setting up SR-IOV\n", *error); + } else { + sc->iov_attached = true; } } /* ixgbe_define_iov_schemas */ @@ -1743,6 +1749,101 @@ ixgbe_mbx_pending(struct ixgbe_softc *sc) return (false); } +static const char * +ixgbe_vf_api_version(uint16_t api_ver) +{ + switch (api_ver) { + case ixgbe_mbox_api_10: + return ("1.0"); + case ixgbe_mbox_api_11: + return ("1.1"); + case ixgbe_mbox_api_12: + return ("1.2"); + case ixgbe_mbox_api_13: + return ("1.3"); + case ixgbe_mbox_api_14: + return ("1.4"); + case ixgbe_mbox_api_15: + return ("1.5"); + case ixgbe_mbox_api_16: + return ("1.6"); + case ixgbe_mbox_api_20: + return ("2.0"); + default: + return (NULL); + } +} + +int +ixgbe_if_vf_status(if_ctx_t ctx, struct if_vf_status **statusp) +{ + struct ixgbe_softc *sc; + struct ixgbe_vf *vf; + struct if_vf_info *info; + struct if_vf_status *status; + const char *api_ver; + int i; + + sc = iflib_get_softc(ctx); + if (!sc->iov_attached) + return (EOPNOTSUPP); + status = if_vf_status_alloc(sc->num_vfs); + if (status == NULL) + return (ENOMEM); + for (i = 0; i < sc->num_vfs; i++) { + vf = &sc->vfs[i]; + info = &status->vfs[i]; + info->fields = IFVF_F_CONFIGURED | IFVF_F_INITIALIZED | + IFVF_F_VLAN_MODE | IFVF_F_VLAN_COUNT | + IFVF_F_NUM_TX_QUEUES | IFVF_F_NUM_RX_QUEUES | + IFVF_F_ALLOW_SET_MAC | + IFVF_F_ALLOW_SET_VLAN | IFVF_F_MAC_ANTI_SPOOF | + IFVF_F_ALLOW_PROMISC | IFVF_F_TRAFFIC_ALLOWED | + IFVF_F_FAULT_BLOCKED | IFVF_F_QUARANTINED; + info->index = i; + info->configured = (vf->flags & IXGBE_VF_ACTIVE) != 0; + info->initialized = + (vf->flags & (IXGBE_VF_CTS | IXGBE_VF_INIT_DONE)) == + (IXGBE_VF_CTS | IXGBE_VF_INIT_DONE); + if (!ETHER_IS_ZERO(vf->ether_addr)) { + memcpy(info->mac, vf->ether_addr, sizeof(info->mac)); + info->fields |= IFVF_F_MAC; + } + if (vf->default_vlan == 0) + info->vlan_mode = IFVF_VLAN_TRUNK; + else { + info->vlan_mode = IFVF_VLAN_ACCESS; + info->vlan = vf->default_vlan; + info->vlan_pcp = 0; + info->vlan_proto = ETHERTYPE_VLAN; + info->fields |= IFVF_F_VLAN | IFVF_F_VLAN_PCP | + IFVF_F_VLAN_PROTO; + } + info->vlan_count = vf->num_vlans; + info->tx_queue_count = ixgbe_vf_queues(sc->iov_mode); + info->rx_queue_count = ixgbe_vf_queues(sc->iov_mode); + info->allow_set_mac = (vf->flags & IXGBE_VF_CAP_MAC) != 0; + info->allow_set_vlan = (vf->flags & IXGBE_VF_CAP_VLAN) != 0; + info->mac_anti_spoof = + (vf->flags & IXGBE_VF_ANTI_SPOOF) != 0; + info->allow_promisc = + (vf->flags & IXGBE_VF_ALLOW_PROMISC) != 0; + info->traffic_allowed = info->configured && + (vf->flags & IXGBE_VF_TRAFFIC_DISABLED) == 0; + info->fault_blocked = + (vf->flags & IXGBE_VF_TRAFFIC_DISABLED) != 0; + info->quarantined = (vf->flags & IXGBE_VF_QUARANTINED) != 0; + api_ver = ixgbe_vf_api_version(vf->api_ver); + if (api_ver != NULL) { + strlcpy(info->api_version, api_ver, + sizeof(info->api_version)); + info->fields |= IFVF_F_API_VERSION; + } + } + *statusp = status; + return (0); +} + int ixgbe_iov_validate(struct ixgbe_softc *sc, u16 num_vfs) { @@ -1817,6 +1918,8 @@ ixgbe_if_iov_init(if_ctx_t ctx, u16 num_vfs, const nvlist_t *config) retval = ENOMEM; goto err_init_iov; } + for (i = 0; i < num_vfs; i++) + sc->vfs[i].api_ver = IXGBE_API_VER_UNKNOWN; num_filters = sc->hw.mac.num_rar_entries - num_vfs - 1 - IXGBE_MAX_PF_MAC_FILTERS; if (num_filters > 0) { diff --git a/sys/dev/ixgbe/ixgbe.h b/sys/dev/ixgbe/ixgbe.h index f02b1a64afff..ba8cfb94915a 100644 --- a/sys/dev/ixgbe/ixgbe.h +++ b/sys/dev/ixgbe/ixgbe.h @@ -484,6 +484,7 @@ struct ixgbe_softc { struct ixgbe_vf *vfs; struct ixgbe_vf_mac_filter *vf_mac_filters; int num_vf_mac_filters; + bool iov_attached; bool iov_mta_valid; bool iov_vfta_valid; bool iov_vlan_promisc; diff --git a/sys/dev/ixgbe/ixgbe_sriov.h b/sys/dev/ixgbe/ixgbe_sriov.h index 0a1eeb642366..9f1a1eb65aab 100644 --- a/sys/dev/ixgbe/ixgbe_sriov.h +++ b/sys/dev/ixgbe/ixgbe_sriov.h @@ -86,6 +86,8 @@ 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 *); +struct if_vf_status; +int ixgbe_if_vf_status(if_ctx_t, struct if_vf_status **); int ixgbe_iov_validate(struct ixgbe_softc *, u16); void ixgbe_if_iov_uninit(if_ctx_t); void ixgbe_initialize_iov(struct ixgbe_softc *); @@ -96,7 +98,7 @@ void ixgbe_ping_all_vfs(struct ixgbe_softc *); void ixgbe_init_iov_recovery(struct ixgbe_softc *); void ixgbe_schedule_iov_recovery(struct ixgbe_softc *); u_int ixgbe_iov_rebuild_mta(struct ixgbe_softc *); -void ixgbe_define_iov_schemas(device_t, int *); +void ixgbe_define_iov_schemas(struct ixgbe_softc *, int *); void ixgbe_align_all_queue_indices(struct ixgbe_softc *); int ixgbe_vf_que_index(int, int, int); u32 ixgbe_get_mtqc(int);