git: d2cb52033b67 - stable/15 - e1000: clear VFTA when last VLAN is removed

From: Kevin Bowling <kbowling_at_FreeBSD.org>
Date: Fri, 30 Oct 2026 18:04:32 UTC
The branch stable/15 has been updated by kbowling:

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

commit d2cb52033b6701fbe1631b3e294109bcd8102c15
Author:     Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2026-08-03 05:36:04 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2026-10-30 18:03:43 +0000

    e1000: clear VFTA when last VLAN is removed
    
    The conventional VLAN filter update skipped zero shadow words. Removing
    the final VLAN represented by a VFTA word therefore left the hardware
    bit programmed even though the software shadow was clear.
    
    Pass the changed word to em_if_vlan_filter_write() and write it even
    when its new value is zero. Retained nonzero words continue to be
    replayed as before.
    
    (cherry picked from commit a9305a6f50be89f22c7a469aeee4c3bea2086ace)
---
 sys/dev/e1000/if_em.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c
index 7829bd7a2f64..696fed6e8e25 100644
--- a/sys/dev/e1000/if_em.c
+++ b/sys/dev/e1000/if_em.c
@@ -467,7 +467,7 @@ static bool	em_if_vlan_filter_capable(if_ctx_t);
 static bool	em_if_vlan_filter_used(if_ctx_t);
 static void	em_if_vlan_filter_enable(struct e1000_softc *);
 static void	em_if_vlan_filter_disable(struct e1000_softc *);
-static void	em_if_vlan_filter_write(struct e1000_softc *);
+static void	em_if_vlan_filter_write(struct e1000_softc *, int);
 static void	em_setup_vlan_hw_support(if_ctx_t ctx);
 static int	em_sysctl_nvm_info(SYSCTL_HANDLER_ARGS);
 static void	em_print_nvm_info(struct e1000_softc *);
@@ -5596,7 +5596,7 @@ em_if_vlan_register(if_ctx_t ctx, u16 vtag)
 	sc->shadow_vfta[index] |= (1 << bit);
 	++sc->num_vlans;
 	if (!sc->vf_ifp)
-		em_if_vlan_filter_write(sc);
+		em_if_vlan_filter_write(sc, index);
 	else
 		/*
 		 * Physical funtion may reject registering VLAN
@@ -5617,7 +5617,7 @@ em_if_vlan_unregister(if_ctx_t ctx, u16 vtag)
 	sc->shadow_vfta[index] &= ~(1 << bit);
 	--sc->num_vlans;
 	if (!sc->vf_ifp)
-		em_if_vlan_filter_write(sc);
+		em_if_vlan_filter_write(sc, index);
 	else
 		e1000_vfta_set_vf(&sc->hw, vtag, false);
 }
@@ -5673,7 +5673,7 @@ em_if_vlan_filter_disable(struct e1000_softc *sc)
 }
 
 static void
-em_if_vlan_filter_write(struct e1000_softc *sc)
+em_if_vlan_filter_write(struct e1000_softc *sc, int changed_index)
 {
 	struct e1000_hw *hw = &sc->hw;
 
@@ -5683,8 +5683,13 @@ em_if_vlan_filter_write(struct e1000_softc *sc)
 	if (hw->mac.type < em_mac_min)
 		em_if_intr_disable(sc->ctx);
 
+	/*
+	 * Restore every retained VLAN after reset.  Also write the changed
+	 * word when its final VLAN was removed so stale hardware membership
+	 * does not survive a zero shadow value.
+	 */
 	for (int i = 0; i < EM_VFTA_SIZE; i++)
-		if (sc->shadow_vfta[i] != 0)
+		if (sc->shadow_vfta[i] != 0 || i == changed_index)
 			e1000_write_vfta(hw, i, sc->shadow_vfta[i]);
 
 	/* Re-enable interrupts for lem-class devices */