Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 09 Aug 2026 06:47:49 +0000
From:      Kevin Bowling <kbowling@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: ceb282bbd62e - main - igb: Report SR-IOV VF status
Message-ID:  <6a782295.3fa8e.12bc1488@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by kbowling:

URL: https://cgit.FreeBSD.org/src/commit/?id=ceb282bbd62eed5e84df9abaede0dd183f66997a

commit ceb282bbd62eed5e84df9abaede0dd183f66997a
Author:     Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2026-08-08 17:37:20 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2026-08-09 06:46:57 +0000

    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.
---
 sys/dev/e1000/if_em.c      |  1 +
 sys/dev/e1000/if_igb_iov.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++
 sys/dev/e1000/if_igb_iov.h |  1 +
 3 files changed, 60 insertions(+)

diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c
index 44c5ec7a850c..d9db4677bf62 100644
--- a/sys/dev/e1000/if_em.c
+++ b/sys/dev/e1000/if_em.c
@@ -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
 };
diff --git a/sys/dev/e1000/if_igb_iov.c b/sys/dev/e1000/if_igb_iov.c
index dc4b23397431..e62ca8aa029c 100644
--- a/sys/dev/e1000/if_igb_iov.c
+++ b/sys/dev/e1000/if_igb_iov.c
@@ -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)
 {
diff --git a/sys/dev/e1000/if_igb_iov.h b/sys/dev/e1000/if_igb_iov.h
index 8bd576d47649..390e63175c7a 100644
--- a/sys/dev/e1000/if_igb_iov.h
+++ b/sys/dev/e1000/if_igb_iov.h
@@ -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 *);


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a782295.3fa8e.12bc1488>