aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Bowling <kbowling@FreeBSD.org>2026-08-08 17:37:56 +0000
committerKevin Bowling <kbowling@FreeBSD.org>2026-08-09 06:46:57 +0000
commitc30021fe0df9e045a17292dbe50dfc054b69871f (patch)
tree89a5769b5e6dbf33c25f41b1ae726269ada88b3d
parentceb282bbd62eed5e84df9abaede0dd183f66997a (diff)
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, the queue count selected by the current virtualization mode, negotiated mailbox API, whether traffic is enabled, and the MDD-blocked and quarantine state. The query runs under the iflib context lock and does not issue mailbox requests or read hardware registers.
-rw-r--r--sys/dev/ixgbe/if_ix.c1
-rw-r--r--sys/dev/ixgbe/if_sriov.c90
-rw-r--r--sys/dev/ixgbe/ixgbe_sriov.h1
3 files changed, 92 insertions, 0 deletions
diff --git a/sys/dev/ixgbe/if_ix.c b/sys/dev/ixgbe/if_ix.c
index 545516cb7372..2bdfc20df9bc 100644
--- a/sys/dev/ixgbe/if_ix.c
+++ b/sys/dev/ixgbe/if_ix.c
@@ -380,6 +380,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
};
diff --git a/sys/dev/ixgbe/if_sriov.c b/sys/dev/ixgbe/if_sriov.c
index 4e98b2b5de0c..93555d11e72e 100644
--- a/sys/dev/ixgbe/if_sriov.c
+++ b/sys/dev/ixgbe/if_sriov.c
@@ -1686,6 +1686,96 @@ 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_20:
+ return ("2.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");
+ default:
+ return (NULL);
+ }
+}
+
+int
+ixgbe_if_vf_status(if_ctx_t ctx, nvlist_t *status)
+{
+ struct ixgbe_softc *sc;
+ struct ixgbe_vf *vf;
+ const char *api_ver;
+ nvlist_t **vfs;
+ int error, i;
+
+ sc = iflib_get_softc(ctx);
+ if (sc->num_vfs == 0)
+ return (ENXIO);
+ vfs = mallocarray(sc->num_vfs, sizeof(*vfs), M_IXGBE_SRIOV,
+ M_WAITOK | M_ZERO);
+ for (i = 0; i < sc->num_vfs; i++) {
+ vf = &sc->vfs[i];
+ vfs[i] = nvlist_create(0);
+ nvlist_add_number(vfs[i], IFVF_STATUS_INDEX, i);
+ nvlist_add_bool(vfs[i], IFVF_STATUS_CONFIGURED,
+ (vf->flags & IXGBE_VF_ACTIVE) != 0);
+ nvlist_add_bool(vfs[i], IFVF_STATUS_INITIALIZED,
+ (vf->flags & IXGBE_VF_CTS) != 0);
+ nvlist_add_binary(vfs[i], IFVF_STATUS_MAC, vf->ether_addr,
+ ETHER_ADDR_LEN);
+ if (vf->default_vlan == 0)
+ nvlist_add_string(vfs[i], IFVF_STATUS_VLAN_MODE,
+ IFVF_VLAN_MODE_TRUNK);
+ else {
+ nvlist_add_string(vfs[i], IFVF_STATUS_VLAN_MODE,
+ IFVF_VLAN_MODE_ACCESS);
+ nvlist_add_number(vfs[i], IFVF_STATUS_VLAN,
+ vf->default_vlan);
+ }
+ nvlist_add_number(vfs[i], IFVF_STATUS_VLAN_COUNT,
+ vf->num_vlans);
+ nvlist_add_number(vfs[i], IFVF_STATUS_NUM_QUEUES,
+ ixgbe_vf_queues(sc->iov_mode));
+ nvlist_add_bool(vfs[i], IFVF_STATUS_ALLOW_SET_MAC,
+ (vf->flags & IXGBE_VF_CAP_MAC) != 0);
+ nvlist_add_bool(vfs[i], IFVF_STATUS_ALLOW_SET_VLAN,
+ (vf->flags & IXGBE_VF_CAP_VLAN) != 0);
+ nvlist_add_bool(vfs[i], IFVF_STATUS_MAC_ANTI_SPOOF,
+ (vf->flags & IXGBE_VF_ANTI_SPOOF) != 0);
+ nvlist_add_bool(vfs[i], IFVF_STATUS_ALLOW_PROMISC,
+ (vf->flags & IXGBE_VF_ALLOW_PROMISC) != 0);
+ nvlist_add_bool(vfs[i], IFVF_STATUS_TRAFFIC_ENABLED,
+ (vf->flags & IXGBE_VF_TRAFFIC_DISABLED) == 0);
+ nvlist_add_bool(vfs[i], IFVF_STATUS_MDD_BLOCKED,
+ (vf->flags & IXGBE_VF_MDD_BLOCKED) != 0);
+ nvlist_add_bool(vfs[i], IFVF_STATUS_QUARANTINED,
+ (vf->flags & IXGBE_VF_QUARANTINED) != 0);
+ api_ver = ixgbe_vf_api_version(vf->api_ver);
+ if (api_ver != NULL)
+ nvlist_add_string(vfs[i], IFVF_STATUS_API_VERSION,
+ api_ver);
+ }
+ nvlist_add_nvlist_array(status, IFVF_STATUS_VFS,
+ (const nvlist_t * const *)vfs, sc->num_vfs);
+ error = nvlist_error(status);
+ for (i = 0; i < sc->num_vfs; i++)
+ nvlist_destroy(vfs[i]);
+ free(vfs, M_IXGBE_SRIOV);
+ return (error);
+}
+
int
ixgbe_iov_validate(struct ixgbe_softc *sc, u16 num_vfs)
{
diff --git a/sys/dev/ixgbe/ixgbe_sriov.h b/sys/dev/ixgbe/ixgbe_sriov.h
index de0485f6e9a2..3bd86fe06c1b 100644
--- a/sys/dev/ixgbe/ixgbe_sriov.h
+++ b/sys/dev/ixgbe/ixgbe_sriov.h
@@ -85,6 +85,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_if_vf_status(if_ctx_t, 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 *);