Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Aug 2022 14:40:18 GMT
From:      Kristof Provost <kp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: e7abb897018b - main - ixgbe: fix software vlan handling
Message-ID:  <202208171440.27HEeILs046453@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by kp:

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

commit e7abb897018be34f039ad957562fdc2f38aa3562
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2022-08-11 12:45:01 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2022-08-17 14:39:18 +0000

    ixgbe: fix software vlan handling
    
    If hardware vlan tagging is disabled (after a vlan has been added) we
    receive double-tagged packets, even if the packet on the wire only has a
    
    single VLAN tag.  That looks like this:
    
            17:29:30.370787 00:51:82:11:22:02 > 90:ec:77:1f:8a:5f, ethertype 802.1Q (0x8100), length 64: vlan 0, p 0, ethertype 802.1Q, vlan 1001, p 0, ethertype ARP, Ethernet (len 6), IPv4 (len 4), Reply 10.101.0.12 is-at 00:51:82:11:22:02, length 42
    
    This happens because the ixgbe driver does not clear the vlan flags in
    the hardware (such as IXGBE_RXDCTL_VME) if IFCAP_VLAN_HWTAGGING is
    cleared.
    
    Add code to do so, which fixes this issue.
    
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D36139
---
 sys/dev/ixgbe/if_ix.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/sys/dev/ixgbe/if_ix.c b/sys/dev/ixgbe/if_ix.c
index ae5c65894f83..54008a24074b 100644
--- a/sys/dev/ixgbe/if_ix.c
+++ b/sys/dev/ixgbe/if_ix.c
@@ -1925,8 +1925,27 @@ ixgbe_setup_vlan_hw_support(if_ctx_t ctx)
 	 * the VFTA and other state, so if there
 	 * have been no vlan's registered do nothing.
 	 */
-	if (sc->num_vlans == 0)
+	if (sc->num_vlans == 0 || (ifp->if_capenable & IFCAP_VLAN_HWTAGGING) == 0) {
+		/* Clear the vlan hw flag */
+		for (i = 0; i < sc->num_rx_queues; i++) {
+			rxr = &sc->rx_queues[i].rxr;
+			/* On 82599 the VLAN enable is per/queue in RXDCTL */
+			if (hw->mac.type != ixgbe_mac_82598EB) {
+				ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxr->me));
+				ctrl &= ~IXGBE_RXDCTL_VME;
+				IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(rxr->me), ctrl);
+			}
+			rxr->vtag_strip = false;
+		}
+		ctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
+		/* Enable the Filter Table if enabled */
+		ctrl |= IXGBE_VLNCTRL_CFIEN;
+		ctrl &= ~IXGBE_VLNCTRL_VFE;
+		if (hw->mac.type == ixgbe_mac_82598EB)
+			ctrl &= ~IXGBE_VLNCTRL_VME;
+		IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, ctrl);
 		return;
+	}
 
 	/* Setup the queues for vlans */
 	if (ifp->if_capenable & IFCAP_VLAN_HWTAGGING) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202208171440.27HEeILs046453>