igb: Report SR-IOV VF status

Expose the cached per-VF configuration through the iflib VF status
method.  Report mailbox handshake state, MAC address, access or trunk
VLAN mode, hardware queue count, administrator policy, and MDD blocking
state without issuing mailbox requests or reading hardware registers.
This commit is contained in:
Kevin Bowling committed 2026-08-08 23:46:57 -07:00
1 parent d15f2551b2
commit ceb282bbd6
3 files changed
+60

No files matched your search

+1
View File
@@ -665,6 +665,7 @@ static device_method_t igb_if_methods[] = {
DEVMETHOD(ifdi_iov_init, igb_if_iov_init),
DEVMETHOD(ifdi_iov_uninit, igb_if_iov_uninit),
DEVMETHOD(ifdi_iov_vf_add, igb_if_iov_vf_add),
DEVMETHOD(ifdi_vf_status, igb_if_vf_status),
#endif
DEVMETHOD_END
};
+58
View File
@@ -1995,6 +1995,64 @@ igb_iov_validate(struct e1000_softc *sc, u16 num_vfs)
return (0);
}
int
igb_if_vf_status(if_ctx_t ctx, nvlist_t *status)
{
struct e1000_softc *sc;
struct igb_vf *vf;
nvlist_t **vfs;
u_int num_queues;
int error, i;
sc = iflib_get_softc(ctx);
if (sc->num_vfs == 0)
return (ENXIO);
num_queues = sc->hw.mac.type == e1000_82576 ?
IGB_82576_VF_QUEUES : IGB_I350_VF_QUEUES;
vfs = mallocarray(sc->num_vfs, sizeof(*vfs), M_IGB_IOV,
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 & IGB_VF_ACTIVE) != 0);
nvlist_add_bool(vfs[i], IFVF_STATUS_INITIALIZED,
(vf->flags & IGB_VF_CTS) != 0);
nvlist_add_binary(vfs[i], IFVF_STATUS_MAC, vf->mac,
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->vlan_count);
nvlist_add_number(vfs[i], IFVF_STATUS_NUM_QUEUES, num_queues);
nvlist_add_bool(vfs[i], IFVF_STATUS_ALLOW_SET_MAC,
(vf->flags & IGB_VF_CAP_MAC) != 0);
nvlist_add_bool(vfs[i], IFVF_STATUS_ALLOW_SET_VLAN,
vf->default_vlan == 0);
nvlist_add_bool(vfs[i], IFVF_STATUS_MAC_ANTI_SPOOF,
(vf->flags & IGB_VF_MAC_ANTI_SPOOF) != 0);
nvlist_add_bool(vfs[i], IFVF_STATUS_ALLOW_PROMISC,
(vf->flags & IGB_VF_ALLOW_PROMISC) != 0);
nvlist_add_bool(vfs[i], IFVF_STATUS_MDD_BLOCKED,
(vf->flags & IGB_VF_MDD_BLOCKED) != 0);
}
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_IGB_IOV);
return (error);
}
int
igb_if_iov_init(if_ctx_t ctx, u16 num_vfs, const nvlist_t *config)
{
+1
View File
@@ -24,6 +24,7 @@ int igb_iov_validate(struct e1000_softc *, u16);
int igb_if_iov_init(if_ctx_t, u16, const nvlist_t *);
void igb_if_iov_uninit(if_ctx_t);
int igb_if_iov_vf_add(if_ctx_t, u16, const nvlist_t *);
int igb_if_vf_status(if_ctx_t, nvlist_t *);
void igb_iov_initialize(struct e1000_softc *);
void igb_iov_handle_mbx(struct e1000_softc *);
void igb_iov_handle_mdd(struct e1000_softc *);