From 361a7fb35bc74676b042aee87a20eec1ff7bc392 Mon Sep 17 00:00:00 2001 From: msaitoh Date: Wed, 13 Mar 2019 10:08:02 +0000 Subject: [PATCH] Fix a bug that the VLAN HW tagging function is not correctly disabled when all vlan is detached. Part of ixgbe.c rev. 1.177. --- sys/dev/pci/ixgbe/ixv.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/sys/dev/pci/ixgbe/ixv.c b/sys/dev/pci/ixgbe/ixv.c index 7dbd82017805..d546ddd9f4c0 100644 --- a/sys/dev/pci/ixgbe/ixv.c +++ b/sys/dev/pci/ixgbe/ixv.c @@ -1,4 +1,4 @@ -/*$NetBSD: ixv.c,v 1.109 2019/02/22 06:49:15 msaitoh Exp $*/ +/*$NetBSD: ixv.c,v 1.110 2019/03/13 10:08:02 msaitoh Exp $*/ /****************************************************************************** @@ -1972,27 +1972,31 @@ ixv_setup_vlan_support(struct adapter *adapter) struct ixgbe_hw *hw = &adapter->hw; struct rx_ring *rxr; u32 ctrl, vid, vfta, retry; + bool hwtagging; /* - * We get here thru init_locked, meaning - * a soft reset, this has already cleared - * the VFTA and other state, so if there - * have been no vlan's registered do nothing. + * This function is called from both if_init and ifflags_cb() + * on NetBSD. */ - if (!VLAN_ATTACHED(ec)) - return; + + /* Enalble HW tagging only if any vlan is attached */ + hwtagging = (ec->ec_capenable & ETHERCAP_VLAN_HWTAGGING) + && VLAN_ATTACHED(&adapter->osdep.ec); /* Enable the queues */ for (int i = 0; i < adapter->num_queues; i++) { rxr = &adapter->rx_rings[i]; ctrl = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(rxr->me)); - ctrl |= IXGBE_RXDCTL_VME; + if (hwtagging) + ctrl |= IXGBE_RXDCTL_VME; + else + ctrl &= ~IXGBE_RXDCTL_VME; IXGBE_WRITE_REG(hw, IXGBE_VFRXDCTL(rxr->me), ctrl); /* * Let Rx path know that it needs to store VLAN tag * as part of extra mbuf info. */ - rxr->vtag_strip = TRUE; + rxr->vtag_strip = hwtagging ? TRUE : FALSE; } #if 1