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.
This commit is contained in:
Kevin Bowling committed 2026-08-08 23:46:57 -07:00
1 parent ceb282bbd6
commit c30021fe0d
3 files changed
+92

No files matched your search

+1
View File
@@ -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
};
+90
View File
@@ -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)
{
+1
View File
@@ -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 *);