Skip to contentSkip to conversation

e1000e: keep vlan interfaces functional after rxvlan off

RFC PATCH Superseded Jarod Wilson 5 participants 13 messages May 17, 2016 – Jun 16, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 e1000e: keep vlan interfaces functional after rxvlan off

I've got a bug report about an e1000e interface, where a vlan interface is set up on top of it:

$ ip link add link ens1f0 name ens1f0.99 type vlan id 99
$ ip link set ens1f0 up
$ ip link set ens1f0.99 up
$ ip addr add 192.168.99.92 dev ens1f0.99

At this point, I can ping another host on vlan 99, ip 192.168.99.91. However, if I do the following:

$ ethtool -K ens1f0 rxvlan off

Then no traffic passes on ens1f0.99. It comes back if I toggle rxvlan on again. I'm not sure if this is actually intended behavior, or if there's a lack of software vlan stripping fallback, or what, but things continue to work if I simply don't call e1000e_vlan_strip_disable() if there are active vlans (plagiarizing a function from the e1000 driver here) on the interface.

Also slipped a related-ish fix to the kerneldoc text for e1000e_vlan_strip_disable here...

CC Jeff Kirsher <[email protected]>
CC intel-wired-lan at lists.osuosl.org
CC netdev at vger.kernel.org
---
 drivers/net/ethernet/intel/e1000e/netdev.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/e1000e/netdev.c +13 -2
index 75e6089..73f7452 100644
@@ -154,6 +154,16 @@ void __ew32(struct e1000_hw *hw, unsigned long reg, u32 val)
 	writel(val, hw->hw_addr + reg);
 }
 
+static bool e1000e_vlan_used(struct e1000_adapter *adapter)
+{
+	u16 vid;
+
+	for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID)
+		return true;
+
+	return false;
+}
+
 /**
  * e1000_regdump - register printout routine
  * @hw: pointer to the HW structure
@@ -2789,7 +2799,7 @@ static void e1000e_vlan_filter_enable(struct e1000_adapter *adapter)
 }
 
 /**
- * e1000e_vlan_strip_enable - helper to disable HW VLAN stripping
+ * e1000e_vlan_strip_disable - helper to disable HW VLAN stripping
  * @adapter: board private structure to initialize
  **/
 static void e1000e_vlan_strip_disable(struct e1000_adapter *adapter)
@@ -3443,7 +3453,8 @@ static void e1000e_set_rx_mode(struct net_device *netdev)
 
 	ew32(RCTL, rctl);
 
-	if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX)
+	if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX ||
+	    e1000e_vlan_used(adapter))
 		e1000e_vlan_strip_enable(adapter);
 	else
 		e1000e_vlan_strip_disable(adapter);
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 25 lines · Jarod Wilson

I've got a bug report about an e1000e interface, where a vlan interface is
set up on top of it:

$ ip link add link ens1f0 name ens1f0.99 type vlan id 99
$ ip link set ens1f0 up
$ ip link set ens1f0.99 up
$ ip addr add 192.168.99.92 dev ens1f0.99

At this point, I can ping another host on vlan 99, ip 192.168.99.91. However, if I do the following:

$ ethtool -K ens1f0 rxvlan off

Then no traffic passes on ens1f0.99. It comes back if I toggle rxvlan on again. I'm not sure if this is actually intended behavior, or if there's a
lack of software vlan stripping fallback, or what, but things continue to work if I simply don't call e1000e_vlan_strip_disable() if there are active vlans (plagiarizing a function from the e1000 driver here) on the interface.

Also slipped a related-ish fix to the kerneldoc text for e1000e_vlan_strip_disable here...

Quoted 7 lines
CC Jeff Kirsher <[email protected]>
CC intel-wired-lan at lists.osuosl.org
CC netdev at vger.kernel.org

---
?drivers/net/ethernet/intel/e1000e/netdev.c | 15 +++++++++++++-- ?1 file changed, 13 insertions(+), 2 deletions(-)

Raanan, please review this patch. ?Even though it is an RFC I will be
adding it to my queue for testing.
http://patchwork.ozlabs.org/patch/623238/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.osuosl.org/pipermail/intel-wired-lan/attachments/20160518/a8f29947/attachment.asc>

Tested-by
#2 lore raw
Quoted 43 lines

From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jeff Kirsher
Sent: Wednesday, May 18, 2016 2:40 PM
To: Jarod Wilson <[email protected]>; linux-kernel at vger.kernel.org; Avargil, Raanan <[email protected]>
Cc: netdev at vger.kernel.org; intel-wired-lan at lists.osuosl.org
Subject: Re: [Intel-wired-lan] [RFC PATCH net] e1000e: keep vlan interfaces functional after rxvlan off

Quoted 25 lines · Jarod Wilson

I've got a bug report about an e1000e interface, where a vlan interface is
set up on top of it:

$ ip link add link ens1f0 name ens1f0.99 type vlan id 99
$ ip link set ens1f0 up
$ ip link set ens1f0.99 up
$ ip addr add 192.168.99.92 dev ens1f0.99

At this point, I can ping another host on vlan 99, ip 192.168.99.91. However, if I do the following:

$ ethtool -K ens1f0 rxvlan off

Then no traffic passes on ens1f0.99. It comes back if I toggle rxvlan on again. I'm not sure if this is actually intended behavior, or if there's a
lack of software vlan stripping fallback, or what, but things continue to work if I simply don't call e1000e_vlan_strip_disable() if there are active vlans (plagiarizing a function from the e1000 driver here) on the interface.

Also slipped a related-ish fix to the kerneldoc text for e1000e_vlan_strip_disable here...

Quoted 7 lines
CC Jeff Kirsher <[email protected]>
CC intel-wired-lan at lists.osuosl.org
CC netdev at vger.kernel.org

---
?drivers/net/ethernet/intel/e1000e/netdev.c | 15 +++++++++++++-- ?1 file changed, 13 insertions(+), 2 deletions(-)

Quoted 3 lines

Raanan, please review this patch. ?Even though it is an RFC I will be adding it to my queue for testing.
http://patchwork.ozlabs.org/patch/623238/

Yup, without this patch disabling rxvlan offload does indeed break vlan connectivity and with the patch I can disable and re-enable rxvlan offloads as much as I care to. It also makes it through my regression tests without problems.

This is from functional - does it work - testing perspective so review is probably still in order.

#3 lore raw
Quoted 51 lines

-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Brown, Aaron F
Sent: Friday, 27 May, 2016 04:31
To: Kirsher, Jeffrey T; Jarod Wilson; linux-kernel at vger.kernel.org; Avargil, Raanan
Cc: netdev at vger.kernel.org; intel-wired-lan at lists.osuosl.org
Subject: Re: [Intel-wired-lan] [RFC PATCH net] e1000e: keep vlan interfaces functional after rxvlan off

Quoted 41 lines

From: Intel-wired-lan
[mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jeff Kirsher
Sent: Wednesday, May 18, 2016 2:40 PM
To: Jarod Wilson <[email protected]>; linux-kernel at vger.kernel.org; Avargil, Raanan <[email protected]>
Cc: netdev at vger.kernel.org; intel-wired-lan at lists.osuosl.org
Subject: Re: [Intel-wired-lan] [RFC PATCH net] e1000e: keep vlan interfaces functional after rxvlan off

Quoted 29 lines · Jarod Wilson

I've got a bug report about an e1000e interface, where a vlan interface is set up on top of it:

$ ip link add link ens1f0 name ens1f0.99 type vlan id 99 $ ip link
set ens1f0 up $ ip link set ens1f0.99 up $ ip addr add 192.168.99.92
dev ens1f0.99

At this point, I can ping another host on vlan 99, ip 192.168.99.91. However, if I do the following:

$ ethtool -K ens1f0 rxvlan off

Then no traffic passes on ens1f0.99. It comes back if I toggle rxvlan on again. I'm not sure if this is actually intended behavior, or if there's a lack of software vlan stripping fallback, or what, but things continue to work if I simply don't call e1000e_vlan_strip_disable() if there are active vlans (plagiarizing a function from the e1000 driver here) on the interface.

Also slipped a related-ish fix to the kerneldoc text for e1000e_vlan_strip_disable here...

CC Jeff Kirsher <[email protected]>
CC intel-wired-lan at lists.osuosl.org
CC netdev at vger.kernel.org

---
?drivers/net/ethernet/intel/e1000e/netdev.c | 15 +++++++++++++-- ?1 file changed, 13 insertions(+), 2 deletions(-)

Quoted 8 lines
Quoted 3 lines

Raanan, please review this patch. ?Even though it is an RFC I will be adding it to my queue for testing.
http://patchwork.ozlabs.org/patch/623238/

Yup, without this patch disabling rxvlan offload does indeed break vlan connectivity and with the patch I can disable and re-enable rxvlan offloads as much as I care to. It also makes it through my regression tests without problems.

Well, what the patch essentially does is block disabling RX VLAN stripping if any VLANs are active, so there is nothing surprising there. You are essentially running with VLAN offloads enabled all the time. :)

Quoted 5 lines

This is from functional - does it work - testing perspective so review is probably still in order.

I am not sure if this behavior is by design or not, and whether un-stripped VLAN traffic is being blocked by the HW, the driver or the stack.

I have two questions:
1) Does the unpatched behavior change if promiscuous RX is set in the HW?
2) Is the behavior different in other devices (igb, ixgbe)? Do they allow VLAN traffic to pass even if VLAN offloads are disabled?

I believe that the e1000e behavior should be consistent with other devices, whatever that behavior is.
---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

#4 lore raw
In reply to Jarod Wilson
Quoted 36 lines · Jarod Wilson

I've got a bug report about an e1000e interface, where a vlan interface is set up on top of it:

$ ip link add link ens1f0 name ens1f0.99 type vlan id 99
$ ip link set ens1f0 up
$ ip link set ens1f0.99 up
$ ip addr add 192.168.99.92 dev ens1f0.99

At this point, I can ping another host on vlan 99, ip 192.168.99.91. However, if I do the following:

$ ethtool -K ens1f0 rxvlan off

Then no traffic passes on ens1f0.99. It comes back if I toggle rxvlan on again. I'm not sure if this is actually intended behavior, or if there's a lack of software vlan stripping fallback, or what, but things continue to work if I simply don't call e1000e_vlan_strip_disable() if there are active vlans (plagiarizing a function from the e1000 driver here) on the interface.

Also slipped a related-ish fix to the kerneldoc text for e1000e_vlan_strip_disable here...

CC Jeff Kirsher <[email protected]>
CC intel-wired-lan at lists.osuosl.org
CC netdev at vger.kernel.org
---
 drivers/net/ethernet/intel/e1000e/netdev.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/e1000e/netdev.c +0 -0
index 75e6089..73f7452 100644

drivers/net/ethernet/intel/e1000e/netdev.c void __ew32(struct e1000_hw *hw, unsigned long reg, u32 val) · line 163

Quoted 10 lines
drivers/net/ethernet/intel/e1000e/netdev.c +7 -0
@@ -154,6 +154,16 @@ void __ew32(struct e1000_hw *hw, unsigned long reg, u32 val)
        writel(val, hw->hw_addr + reg);
 }
 
+static bool e1000e_vlan_used(struct e1000_adapter *adapter)
+{
+       u16 vid;
+
+       for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID)
+               return true;
+

I'm pretty sure this is always going to return true if 8021q is loaded because VLAN 0 is always added to the device even if no other VLANs are in use.

Quoted 16 lines
drivers/net/ethernet/intel/e1000e/netdev.c +4 -1
+       return false;
+}
+
 /**
  * e1000_regdump - register printout routine
  * @hw: pointer to the HW structure
@@ -2789,7 +2799,7 @@ static void e1000e_vlan_filter_enable(struct e1000_adapter *adapter)
 }
 
 /**
- * e1000e_vlan_strip_enable - helper to disable HW VLAN stripping
+ * e1000e_vlan_strip_disable - helper to disable HW VLAN stripping
  * @adapter: board private structure to initialize
  **/
 static void e1000e_vlan_strip_disable(struct e1000_adapter *adapter)

drivers/net/ethernet/intel/e1000e/netdev.c static void e1000e_set_rx_mode(struct net_device *netdev) · line 3460

Quoted 9 lines
drivers/net/ethernet/intel/e1000e/netdev.c +2 -1
@@ -3443,7 +3453,8 @@ static void e1000e_set_rx_mode(struct net_device *netdev)
 
        ew32(RCTL, rctl);
 
-       if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX)
+       if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX ||
+           e1000e_vlan_used(adapter))
                e1000e_vlan_strip_enable(adapter);
        else
                e1000e_vlan_strip_disable(adapter);

So if the VLAN tag stripping is disabled what happens that is causing the VLAN test to fail? It sounds like this might be working around a kernel bug where a VLAN created on a device that supports hardware tag stripping only supports hardware tag stripping. Maybe a better fix would be to add a fall back so if the VLAN tag is in the frame instead of stripped it still makes it to the correct spot.

- Alex

#5 lore raw
Quoted 40 lines · Alexander Duyck
Quoted 39 lines · Jarod Wilson

I've got a bug report about an e1000e interface, where a vlan interface is set up on top of it:

$ ip link add link ens1f0 name ens1f0.99 type vlan id 99
$ ip link set ens1f0 up
$ ip link set ens1f0.99 up
$ ip addr add 192.168.99.92 dev ens1f0.99

At this point, I can ping another host on vlan 99, ip 192.168.99.91. However, if I do the following:

$ ethtool -K ens1f0 rxvlan off

Then no traffic passes on ens1f0.99. It comes back if I toggle rxvlan on again. I'm not sure if this is actually intended behavior, or if there's a lack of software vlan stripping fallback, or what, but things continue to work if I simply don't call e1000e_vlan_strip_disable() if there are active vlans (plagiarizing a function from the e1000 driver here) on the interface.

Also slipped a related-ish fix to the kerneldoc text for e1000e_vlan_strip_disable here...

CC Jeff Kirsher <[email protected]>
CC intel-wired-lan at lists.osuosl.org
CC netdev at vger.kernel.org
---
 drivers/net/ethernet/intel/e1000e/netdev.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/e1000e/netdev.c +0 -0
index 75e6089..73f7452 100644
@@ -154,6 +154,16 @@ void __ew32(struct e1000_hw *hw, unsigned long reg, u32 val)
        writel(val, hw->hw_addr + reg);
 }
 
Quoted 11 lines

drivers/net/ethernet/intel/e1000e/netdev.c void __ew32(struct e1000_hw *hw, unsigned long reg, u32 val) · line 163

Quoted 7 lines
drivers/net/ethernet/intel/e1000e/netdev.c +7 -0
+static bool e1000e_vlan_used(struct e1000_adapter *adapter)
+{
+       u16 vid;
+
+       for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID)
+               return true;
+

I'm pretty sure this is always going to return true if 8021q is loaded because VLAN 0 is always added to the device even if no other VLANs are in use.

Ah, hadn't considered that, I just plucked it straight from e1000.

Quoted 19 lines
Quoted 19 lines
drivers/net/ethernet/intel/e1000e/netdev.c +4 -1
+       return false;
+}
+
 /**
  * e1000_regdump - register printout routine
  * @hw: pointer to the HW structure
@@ -2789,7 +2799,7 @@ static void e1000e_vlan_filter_enable(struct e1000_adapter *adapter)
 }
 
 /**
- * e1000e_vlan_strip_enable - helper to disable HW VLAN stripping
+ * e1000e_vlan_strip_disable - helper to disable HW VLAN stripping
  * @adapter: board private structure to initialize
  **/
 static void e1000e_vlan_strip_disable(struct e1000_adapter *adapter)
@@ -3443,7 +3453,8 @@ static void e1000e_set_rx_mode(struct net_device *netdev)
 
        ew32(RCTL, rctl);
 
Quoted 13 lines

drivers/net/ethernet/intel/e1000e/netdev.c static void e1000e_set_rx_mode(struct net_device *netdev) · line 3460

Quoted 6 lines
drivers/net/ethernet/intel/e1000e/netdev.c +2 -1
-       if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX)
+       if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX ||
+           e1000e_vlan_used(adapter))
                e1000e_vlan_strip_enable(adapter);
        else
                e1000e_vlan_strip_disable(adapter);

So if the VLAN tag stripping is disabled what happens that is causing the VLAN test to fail? It sounds like this might be working around a kernel bug where a VLAN created on a device that supports hardware tag stripping only supports hardware tag stripping. Maybe a better fix would be to add a fall back so if the VLAN tag is in the frame instead of stripped it still makes it to the correct spot.

That's the main reason I labeled it as an RFC -- I wasn't sure exactly how things were intended to work when the hardware stripping was disabled. It seems quite plausible to me that this patch simply papers over the real
bug: lack of a functional software fallback. I'm not particularly up on the vlan code just yet though, so I'm not yet sure where to poke next. Suggestions welcomed. :)

Signature · 2 lines
Jarod Wilson
jarod at redhat.com
#6 lore raw
Quoted 88 lines · Jarod Wilson
Quoted 40 lines · Alexander Duyck
Quoted 39 lines · Jarod Wilson

I've got a bug report about an e1000e interface, where a vlan interface is set up on top of it:

$ ip link add link ens1f0 name ens1f0.99 type vlan id 99
$ ip link set ens1f0 up
$ ip link set ens1f0.99 up
$ ip addr add 192.168.99.92 dev ens1f0.99

At this point, I can ping another host on vlan 99, ip 192.168.99.91. However, if I do the following:

$ ethtool -K ens1f0 rxvlan off

Then no traffic passes on ens1f0.99. It comes back if I toggle rxvlan on again. I'm not sure if this is actually intended behavior, or if there's a lack of software vlan stripping fallback, or what, but things continue to work if I simply don't call e1000e_vlan_strip_disable() if there are active vlans (plagiarizing a function from the e1000 driver here) on the interface.

Also slipped a related-ish fix to the kerneldoc text for e1000e_vlan_strip_disable here...

CC Jeff Kirsher <[email protected]>
CC intel-wired-lan at lists.osuosl.org
CC netdev at vger.kernel.org
---
 drivers/net/ethernet/intel/e1000e/netdev.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/e1000e/netdev.c +0 -0
index 75e6089..73f7452 100644
@@ -154,6 +154,16 @@ void __ew32(struct e1000_hw *hw, unsigned long reg, u32 val)
        writel(val, hw->hw_addr + reg);
 }
 
Quoted 11 lines

drivers/net/ethernet/intel/e1000e/netdev.c void __ew32(struct e1000_hw *hw, unsigned long reg, u32 val) · line 163

Quoted 7 lines
drivers/net/ethernet/intel/e1000e/netdev.c +7 -0
+static bool e1000e_vlan_used(struct e1000_adapter *adapter)
+{
+       u16 vid;
+
+       for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID)
+               return true;
+

I'm pretty sure this is always going to return true if 8021q is loaded because VLAN 0 is always added to the device even if no other VLANs are in use.

Ah, hadn't considered that, I just plucked it straight from e1000.

Quoted 19 lines
Quoted 19 lines
drivers/net/ethernet/intel/e1000e/netdev.c +4 -1
+       return false;
+}
+
 /**
  * e1000_regdump - register printout routine
  * @hw: pointer to the HW structure
@@ -2789,7 +2799,7 @@ static void e1000e_vlan_filter_enable(struct e1000_adapter *adapter)
 }
 
 /**
- * e1000e_vlan_strip_enable - helper to disable HW VLAN stripping
+ * e1000e_vlan_strip_disable - helper to disable HW VLAN stripping
  * @adapter: board private structure to initialize
  **/
 static void e1000e_vlan_strip_disable(struct e1000_adapter *adapter)
@@ -3443,7 +3453,8 @@ static void e1000e_set_rx_mode(struct net_device *netdev)
 
        ew32(RCTL, rctl);
 
Quoted 13 lines

drivers/net/ethernet/intel/e1000e/netdev.c static void e1000e_set_rx_mode(struct net_device *netdev) · line 3460

Quoted 6 lines
drivers/net/ethernet/intel/e1000e/netdev.c +2 -1
-       if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX)
+       if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX ||
+           e1000e_vlan_used(adapter))
                e1000e_vlan_strip_enable(adapter);
        else
                e1000e_vlan_strip_disable(adapter);

So if the VLAN tag stripping is disabled what happens that is causing the VLAN test to fail? It sounds like this might be working around a kernel bug where a VLAN created on a device that supports hardware tag stripping only supports hardware tag stripping. Maybe a better fix would be to add a fall back so if the VLAN tag is in the frame instead of stripped it still makes it to the correct spot.

Quoted 6 lines

That's the main reason I labeled it as an RFC -- I wasn't sure exactly how things were intended to work when the hardware stripping was disabled. It seems quite plausible to me that this patch simply papers over the real
bug: lack of a functional software fallback. I'm not particularly up on the vlan code just yet though, so I'm not yet sure where to poke next. Suggestions welcomed. :)

Well the software fallback should be the call to skb_vlan_untag in __netif_receive_skb_core. If that isn't being triggered then we should probably be fixing the files in the core code then.

- Alex

#7 lore raw
Quoted 96 lines · Alexander Duyck
Quoted 88 lines · Jarod Wilson
Quoted 40 lines · Alexander Duyck
Quoted 39 lines · Jarod Wilson

I've got a bug report about an e1000e interface, where a vlan interface is set up on top of it:

$ ip link add link ens1f0 name ens1f0.99 type vlan id 99
$ ip link set ens1f0 up
$ ip link set ens1f0.99 up
$ ip addr add 192.168.99.92 dev ens1f0.99

At this point, I can ping another host on vlan 99, ip 192.168.99.91. However, if I do the following:

$ ethtool -K ens1f0 rxvlan off

Then no traffic passes on ens1f0.99. It comes back if I toggle rxvlan on again. I'm not sure if this is actually intended behavior, or if there's a lack of software vlan stripping fallback, or what, but things continue to work if I simply don't call e1000e_vlan_strip_disable() if there are active vlans (plagiarizing a function from the e1000 driver here) on the interface.

Also slipped a related-ish fix to the kerneldoc text for e1000e_vlan_strip_disable here...

CC Jeff Kirsher <[email protected]>
CC intel-wired-lan at lists.osuosl.org
CC netdev at vger.kernel.org
---
 drivers/net/ethernet/intel/e1000e/netdev.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/e1000e/netdev.c +0 -0
index 75e6089..73f7452 100644
@@ -154,6 +154,16 @@ void __ew32(struct e1000_hw *hw, unsigned long reg, u32 val)
        writel(val, hw->hw_addr + reg);
 }
 
Quoted 11 lines

drivers/net/ethernet/intel/e1000e/netdev.c void __ew32(struct e1000_hw *hw, unsigned long reg, u32 val) · line 163

Quoted 7 lines
drivers/net/ethernet/intel/e1000e/netdev.c +7 -0
+static bool e1000e_vlan_used(struct e1000_adapter *adapter)
+{
+       u16 vid;
+
+       for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID)
+               return true;
+

I'm pretty sure this is always going to return true if 8021q is loaded because VLAN 0 is always added to the device even if no other VLANs are in use.

Ah, hadn't considered that, I just plucked it straight from e1000.

Quoted 19 lines
Quoted 19 lines
drivers/net/ethernet/intel/e1000e/netdev.c +4 -1
+       return false;
+}
+
 /**
  * e1000_regdump - register printout routine
  * @hw: pointer to the HW structure
@@ -2789,7 +2799,7 @@ static void e1000e_vlan_filter_enable(struct e1000_adapter *adapter)
 }
 
 /**
- * e1000e_vlan_strip_enable - helper to disable HW VLAN stripping
+ * e1000e_vlan_strip_disable - helper to disable HW VLAN stripping
  * @adapter: board private structure to initialize
  **/
 static void e1000e_vlan_strip_disable(struct e1000_adapter *adapter)
@@ -3443,7 +3453,8 @@ static void e1000e_set_rx_mode(struct net_device *netdev)
 
        ew32(RCTL, rctl);
 
Quoted 13 lines

drivers/net/ethernet/intel/e1000e/netdev.c static void e1000e_set_rx_mode(struct net_device *netdev) · line 3460

Quoted 6 lines
drivers/net/ethernet/intel/e1000e/netdev.c +2 -1
-       if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX)
+       if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX ||
+           e1000e_vlan_used(adapter))
                e1000e_vlan_strip_enable(adapter);
        else
                e1000e_vlan_strip_disable(adapter);

So if the VLAN tag stripping is disabled what happens that is causing the VLAN test to fail? It sounds like this might be working around a kernel bug where a VLAN created on a device that supports hardware tag stripping only supports hardware tag stripping. Maybe a better fix would be to add a fall back so if the VLAN tag is in the frame instead of stripped it still makes it to the correct spot.

Quoted 6 lines

That's the main reason I labeled it as an RFC -- I wasn't sure exactly how things were intended to work when the hardware stripping was disabled. It seems quite plausible to me that this patch simply papers over the real
bug: lack of a functional software fallback. I'm not particularly up on the vlan code just yet though, so I'm not yet sure where to poke next. Suggestions welcomed. :)

Quoted 3 lines

Well the software fallback should be the call to skb_vlan_untag in __netif_receive_skb_core. If that isn't being triggered then we should probably be fixing the files in the core code then.

So I've been poking at a debug-spew-laden kernel some, and skb_vlan_untag is most definitely not getting called when rxvlan off is set. I'm still poking around, trying to track down where things are going askew.

Signature · 2 lines
Jarod Wilson
jarod at redhat.com
#8 lore raw
Quoted 97 lines · Jarod Wilson
Quoted 96 lines · Alexander Duyck
Quoted 94 lines · Jarod Wilson
Quoted 40 lines · Alexander Duyck
Quoted 39 lines · Jarod Wilson

I've got a bug report about an e1000e interface, where a vlan interface is set up on top of it:

$ ip link add link ens1f0 name ens1f0.99 type vlan id 99
$ ip link set ens1f0 up
$ ip link set ens1f0.99 up
$ ip addr add 192.168.99.92 dev ens1f0.99

At this point, I can ping another host on vlan 99, ip 192.168.99.91. However, if I do the following:

$ ethtool -K ens1f0 rxvlan off

Then no traffic passes on ens1f0.99. It comes back if I toggle rxvlan on again. I'm not sure if this is actually intended behavior, or if there's a lack of software vlan stripping fallback, or what, but things continue to work if I simply don't call e1000e_vlan_strip_disable() if there are active vlans (plagiarizing a function from the e1000 driver here) on the interface.

Also slipped a related-ish fix to the kerneldoc text for e1000e_vlan_strip_disable here...

CC Jeff Kirsher <[email protected]>
CC intel-wired-lan at lists.osuosl.org
CC netdev at vger.kernel.org
---
 drivers/net/ethernet/intel/e1000e/netdev.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/e1000e/netdev.c +0 -0
index 75e6089..73f7452 100644
@@ -154,6 +154,16 @@ void __ew32(struct e1000_hw *hw, unsigned long reg, u32 val)
        writel(val, hw->hw_addr + reg);
 }
 
Quoted 11 lines

drivers/net/ethernet/intel/e1000e/netdev.c void __ew32(struct e1000_hw *hw, unsigned long reg, u32 val) · line 163

Quoted 7 lines
drivers/net/ethernet/intel/e1000e/netdev.c +7 -0
+static bool e1000e_vlan_used(struct e1000_adapter *adapter)
+{
+       u16 vid;
+
+       for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID)
+               return true;
+

I'm pretty sure this is always going to return true if 8021q is loaded because VLAN 0 is always added to the device even if no other VLANs are in use.

Ah, hadn't considered that, I just plucked it straight from e1000.

Quoted 19 lines
Quoted 19 lines
drivers/net/ethernet/intel/e1000e/netdev.c +4 -1
+       return false;
+}
+
 /**
  * e1000_regdump - register printout routine
  * @hw: pointer to the HW structure
@@ -2789,7 +2799,7 @@ static void e1000e_vlan_filter_enable(struct e1000_adapter *adapter)
 }
 
 /**
- * e1000e_vlan_strip_enable - helper to disable HW VLAN stripping
+ * e1000e_vlan_strip_disable - helper to disable HW VLAN stripping
  * @adapter: board private structure to initialize
  **/
 static void e1000e_vlan_strip_disable(struct e1000_adapter *adapter)
@@ -3443,7 +3453,8 @@ static void e1000e_set_rx_mode(struct net_device *netdev)
 
        ew32(RCTL, rctl);
 
Quoted 13 lines

drivers/net/ethernet/intel/e1000e/netdev.c static void e1000e_set_rx_mode(struct net_device *netdev) · line 3460

Quoted 6 lines
drivers/net/ethernet/intel/e1000e/netdev.c +2 -1
-       if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX)
+       if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX ||
+           e1000e_vlan_used(adapter))
                e1000e_vlan_strip_enable(adapter);
        else
                e1000e_vlan_strip_disable(adapter);

So if the VLAN tag stripping is disabled what happens that is causing the VLAN test to fail? It sounds like this might be working around a kernel bug where a VLAN created on a device that supports hardware tag stripping only supports hardware tag stripping. Maybe a better fix would be to add a fall back so if the VLAN tag is in the frame instead of stripped it still makes it to the correct spot.

That's the main reason I labeled it as an RFC -- I wasn't sure exactly how things were intended to work when the hardware stripping was disabled. It seems quite plausible to me that this patch simply papers over the real
bug: lack of a functional software fallback. I'm not particularly up on the vlan code just yet though, so I'm not yet sure where to poke next. Suggestions welcomed. :)

Quoted 7 lines
Quoted 3 lines

Well the software fallback should be the call to skb_vlan_untag in __netif_receive_skb_core. If that isn't being triggered then we should probably be fixing the files in the core code then.

So I've been poking at a debug-spew-laden kernel some, and skb_vlan_untag is most definitely not getting called when rxvlan off is set. I'm still poking around, trying to track down where things are going askew.

Okay, so rxvlan is *supposed* to only impact the rx path, right? It's looking like it is actually impacting the tx path too here. I actually *do* see calls to skb_vlan_untag with rxvlan off, if I ping from an external host, so it seems only the packets from the host with rxvlan toggled off aren't escaping correctly for some reason.

Signature · 2 lines
Jarod Wilson
jarod at redhat.com
#9 lore raw
Quoted 106 lines · Jarod Wilson
Quoted 97 lines · Jarod Wilson
Quoted 96 lines · Alexander Duyck
Quoted 94 lines · Jarod Wilson
Quoted 40 lines · Alexander Duyck
Quoted 39 lines · Jarod Wilson

I've got a bug report about an e1000e interface, where a vlan interface is set up on top of it:

$ ip link add link ens1f0 name ens1f0.99 type vlan id 99
$ ip link set ens1f0 up
$ ip link set ens1f0.99 up
$ ip addr add 192.168.99.92 dev ens1f0.99

At this point, I can ping another host on vlan 99, ip 192.168.99.91. However, if I do the following:

$ ethtool -K ens1f0 rxvlan off

Then no traffic passes on ens1f0.99. It comes back if I toggle rxvlan on again. I'm not sure if this is actually intended behavior, or if there's a lack of software vlan stripping fallback, or what, but things continue to work if I simply don't call e1000e_vlan_strip_disable() if there are active vlans (plagiarizing a function from the e1000 driver here) on the interface.

Also slipped a related-ish fix to the kerneldoc text for e1000e_vlan_strip_disable here...

CC Jeff Kirsher <[email protected]>
CC intel-wired-lan at lists.osuosl.org
CC netdev at vger.kernel.org
---
 drivers/net/ethernet/intel/e1000e/netdev.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/e1000e/netdev.c +0 -0
index 75e6089..73f7452 100644
@@ -154,6 +154,16 @@ void __ew32(struct e1000_hw *hw, unsigned long reg, u32 val)
        writel(val, hw->hw_addr + reg);
 }
 
Quoted 11 lines

drivers/net/ethernet/intel/e1000e/netdev.c void __ew32(struct e1000_hw *hw, unsigned long reg, u32 val) · line 163

Quoted 7 lines
drivers/net/ethernet/intel/e1000e/netdev.c +7 -0
+static bool e1000e_vlan_used(struct e1000_adapter *adapter)
+{
+       u16 vid;
+
+       for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID)
+               return true;
+

I'm pretty sure this is always going to return true if 8021q is loaded because VLAN 0 is always added to the device even if no other VLANs are in use.

Ah, hadn't considered that, I just plucked it straight from e1000.

Quoted 19 lines
Quoted 19 lines
drivers/net/ethernet/intel/e1000e/netdev.c +4 -1
+       return false;
+}
+
 /**
  * e1000_regdump - register printout routine
  * @hw: pointer to the HW structure
@@ -2789,7 +2799,7 @@ static void e1000e_vlan_filter_enable(struct e1000_adapter *adapter)
 }
 
 /**
- * e1000e_vlan_strip_enable - helper to disable HW VLAN stripping
+ * e1000e_vlan_strip_disable - helper to disable HW VLAN stripping
  * @adapter: board private structure to initialize
  **/
 static void e1000e_vlan_strip_disable(struct e1000_adapter *adapter)
@@ -3443,7 +3453,8 @@ static void e1000e_set_rx_mode(struct net_device *netdev)
 
        ew32(RCTL, rctl);
 
Quoted 13 lines

drivers/net/ethernet/intel/e1000e/netdev.c static void e1000e_set_rx_mode(struct net_device *netdev) · line 3460

Quoted 6 lines
drivers/net/ethernet/intel/e1000e/netdev.c +2 -1
-       if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX)
+       if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX ||
+           e1000e_vlan_used(adapter))
                e1000e_vlan_strip_enable(adapter);
        else
                e1000e_vlan_strip_disable(adapter);

So if the VLAN tag stripping is disabled what happens that is causing the VLAN test to fail? It sounds like this might be working around a kernel bug where a VLAN created on a device that supports hardware tag stripping only supports hardware tag stripping. Maybe a better fix would be to add a fall back so if the VLAN tag is in the frame instead of stripped it still makes it to the correct spot.

That's the main reason I labeled it as an RFC -- I wasn't sure exactly how things were intended to work when the hardware stripping was disabled. It seems quite plausible to me that this patch simply papers over the real
bug: lack of a functional software fallback. I'm not particularly up on the vlan code just yet though, so I'm not yet sure where to poke next. Suggestions welcomed. :)

Quoted 7 lines
Quoted 3 lines

Well the software fallback should be the call to skb_vlan_untag in __netif_receive_skb_core. If that isn't being triggered then we should probably be fixing the files in the core code then.

So I've been poking at a debug-spew-laden kernel some, and skb_vlan_untag is most definitely not getting called when rxvlan off is set. I'm still poking around, trying to track down where things are going askew.

Quoted 5 lines

Okay, so rxvlan is *supposed* to only impact the rx path, right? It's looking like it is actually impacting the tx path too here. I actually *do* see calls to skb_vlan_untag with rxvlan off, if I ping from an external host, so it seems only the packets from the host with rxvlan toggled off aren't escaping correctly for some reason.

And this leads me to believe maybe the bit in the e1000 driver that mentions explicitly that the hardware has no support for separate RX/TX vlan accel toggling rings true for e1000e as well, and thus both NETIF_F_HW_VLAN_CTAG_RX and NETIF_F_HW_VLAN_CTAG_TX need to be kept in sync. Testing this theory out shortly...

Signature · 2 lines
Jarod Wilson
jarod at redhat.com
#10 lore raw
Quoted 25 lines · Jarod Wilson
Quoted 24 lines · Jarod Wilson
Quoted 23 lines · Jarod Wilson
Quoted 22 lines · Alexander Duyck
Quoted 21 lines · Jarod Wilson
Quoted 20 lines · Alexander Duyck
Quoted 19 lines · Jarod Wilson

I've got a bug report about an e1000e interface, where a vlan interface is set up on top of it:

$ ip link add link ens1f0 name ens1f0.99 type vlan id 99
$ ip link set ens1f0 up
$ ip link set ens1f0.99 up
$ ip addr add 192.168.99.92 dev ens1f0.99

At this point, I can ping another host on vlan 99, ip 192.168.99.91. However, if I do the following:

$ ethtool -K ens1f0 rxvlan off

Then no traffic passes on ens1f0.99. It comes back if I toggle rxvlan on again. I'm not sure if this is actually intended behavior, or if there's a lack of software vlan stripping fallback, or what, but things continue to work if I simply don't call e1000e_vlan_strip_disable() if there are active vlans (plagiarizing a function from the e1000 driver here) on the interface.

...

Quoted 11 lines
Quoted 5 lines

Okay, so rxvlan is *supposed* to only impact the rx path, right? It's looking like it is actually impacting the tx path too here. I actually *do* see calls to skb_vlan_untag with rxvlan off, if I ping from an external host, so it seems only the packets from the host with rxvlan toggled off aren't escaping correctly for some reason.

And this leads me to believe maybe the bit in the e1000 driver that mentions explicitly that the hardware has no support for separate RX/TX vlan accel toggling rings true for e1000e as well, and thus both NETIF_F_HW_VLAN_CTAG_RX and NETIF_F_HW_VLAN_CTAG_TX need to be kept in sync. Testing this theory out shortly...

We have a winner. If I make sure the TX flag gets toggled too, ping continues to work after disabling rxvlan.

$ ping 192.168.99.91
PING 192.168.99.91 (192.168.99.91) 56(84) bytes of data.
64 bytes from 192.168.99.91: icmp_seq=1 ttl=64 time=0.591 ms
64 bytes from 192.168.99.91: icmp_seq=2 ttl=64 time=0.335 ms
64 bytes from 192.168.99.91: icmp_seq=3 ttl=64 time=0.417 ms
^C
--- 192.168.99.91 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.335/0.447/0.591/0.109 ms
$ sudo ethtool -K ens1f0 rxvlan off
Actual changes:
rx-vlan-offload: off
tx-vlan-offload: off [requested on]
$ ping 192.168.99.91
PING 192.168.99.91 (192.168.99.91) 56(84) bytes of data.
64 bytes from 192.168.99.91: icmp_seq=1 ttl=64 time=0.327 ms
64 bytes from 192.168.99.91: icmp_seq=2 ttl=64 time=0.393 ms
64 bytes from 192.168.99.91: icmp_seq=3 ttl=64 time=0.424 ms
^C
--- 192.168.99.91 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 0.327/0.381/0.424/0.043 ms

I'll clean things up and submit a patch tonight or tomorrow.

Signature · 2 lines
Jarod Wilson
jarod at redhat.com
#11 lore raw

PATCH v2 1/1 e1000e: keep vlan interfaces functional after rxvlan off

In reply to Jarod Wilson

I've got a bug report about an e1000e interface, where a vlan interface is set up on top of it:

$ ip link add link ens1f0 name ens1f0.99 type vlan id 99
$ ip link set ens1f0 up
$ ip link set ens1f0.99 up
$ ip addr add 192.168.99.92 dev ens1f0.99

At this point, I can ping another host on vlan 99, ip 192.168.99.91. However, if I do the following:

$ ethtool -K ens1f0 rxvlan off

Then no traffic passes on ens1f0.99. It comes back if I toggle rxvlan on again. Upon discussion with folks here, and closer inspection, it appears that the software *receive* fallback is working correctly, but outbound traffic is broken. Upon glancing at the e1000 driver, I saw a note about having to keep RX and TX accel flags in sync, because there's no (hardware?) support for separate vlan accel toggle. Swipe the same hack from the e1000 driver, and things start to behave again with rxvlan off.

After patch:

$ ping 192.168.99.91
PING 192.168.99.91 (192.168.99.91) 56(84) bytes of data.
64 bytes from 192.168.99.91: icmp_seq=1 ttl=64 time=0.591 ms
64 bytes from 192.168.99.91: icmp_seq=2 ttl=64 time=0.335 ms
64 bytes from 192.168.99.91: icmp_seq=3 ttl=64 time=0.417 ms
^C
--- 192.168.99.91 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.335/0.447/0.591/0.109 ms
$ sudo ethtool -K ens1f0 rxvlan off
Actual changes:
rx-vlan-offload: off
tx-vlan-offload: off [requested on]
$ ping 192.168.99.91
PING 192.168.99.91 (192.168.99.91) 56(84) bytes of data.
64 bytes from 192.168.99.91: icmp_seq=1 ttl=64 time=0.327 ms
64 bytes from 192.168.99.91: icmp_seq=2 ttl=64 time=0.393 ms
64 bytes from 192.168.99.91: icmp_seq=3 ttl=64 time=0.424 ms
^C
--- 192.168.99.91 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 0.327/0.381/0.424/0.043 ms

Also slipped a related-ish fix to the kerneldoc text for e1000e_vlan_strip_disable here...

CC Jeff Kirsher <[email protected]>
CC intel-wired-lan at lists.osuosl.org
CC netdev at vger.kernel.org
---
 drivers/net/ethernet/intel/e1000e/netdev.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/e1000e/netdev.c +9 -1
index 75e6089..2b2e2f8 100644
@@ -2789,7 +2789,7 @@ static void e1000e_vlan_filter_enable(struct e1000_adapter *adapter)
 }
 
 /**
- * e1000e_vlan_strip_enable - helper to disable HW VLAN stripping
+ * e1000e_vlan_strip_disable - helper to disable HW VLAN stripping
  * @adapter: board private structure to initialize
  **/
 static void e1000e_vlan_strip_disable(struct e1000_adapter *adapter)
@@ -6915,6 +6915,14 @@ static netdev_features_t e1000_fix_features(struct net_device *netdev,
 	if ((hw->mac.type >= e1000_pch2lan) && (netdev->mtu > ETH_DATA_LEN))
 		features &= ~NETIF_F_RXFCS;
 
+	/* Since there is no support for separate Rx/Tx vlan accel
+	 * enable/disable make sure Tx flag is always in same state as Rx.
+	 */
+	if (features & NETIF_F_HW_VLAN_CTAG_RX)
+		features |= NETIF_F_HW_VLAN_CTAG_TX;
+	else
+		features &= ~NETIF_F_HW_VLAN_CTAG_TX;
+
 	return features;
 }
 
Signature · 1 line
1.8.3.1
Tested-by on v2 1/1
#12 lore raw
Quoted 59 lines

From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jarod Wilson
Sent: Thursday, June 9, 2016 4:50 PM
To: linux-kernel at vger.kernel.org
Cc: netdev at vger.kernel.org; intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH net v2] e1000e: keep vlan interfaces functional after rxvlan off

I've got a bug report about an e1000e interface, where a vlan interface is set up on top of it:

$ ip link add link ens1f0 name ens1f0.99 type vlan id 99
$ ip link set ens1f0 up
$ ip link set ens1f0.99 up
$ ip addr add 192.168.99.92 dev ens1f0.99

At this point, I can ping another host on vlan 99, ip 192.168.99.91. However, if I do the following:

$ ethtool -K ens1f0 rxvlan off

Then no traffic passes on ens1f0.99. It comes back if I toggle rxvlan on again. Upon discussion with folks here, and closer inspection, it appears that the software *receive* fallback is working correctly, but outbound traffic is broken. Upon glancing at the e1000 driver, I saw a note about having to keep RX and TX accel flags in sync, because there's no (hardware?) support for separate vlan accel toggle. Swipe the same hack from the e1000 driver, and things start to behave again with rxvlan off.

After patch:

$ ping 192.168.99.91
PING 192.168.99.91 (192.168.99.91) 56(84) bytes of data.
64 bytes from 192.168.99.91: icmp_seq=1 ttl=64 time=0.591 ms
64 bytes from 192.168.99.91: icmp_seq=2 ttl=64 time=0.335 ms
64 bytes from 192.168.99.91: icmp_seq=3 ttl=64 time=0.417 ms
^C
--- 192.168.99.91 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.335/0.447/0.591/0.109 ms
$ sudo ethtool -K ens1f0 rxvlan off
Actual changes:
rx-vlan-offload: off
tx-vlan-offload: off [requested on]
$ ping 192.168.99.91
PING 192.168.99.91 (192.168.99.91) 56(84) bytes of data.
64 bytes from 192.168.99.91: icmp_seq=1 ttl=64 time=0.327 ms
64 bytes from 192.168.99.91: icmp_seq=2 ttl=64 time=0.393 ms
64 bytes from 192.168.99.91: icmp_seq=3 ttl=64 time=0.424 ms
^C
--- 192.168.99.91 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 0.327/0.381/0.424/0.043 ms

Also slipped a related-ish fix to the kerneldoc text for e1000e_vlan_strip_disable here...

Quoted 7 lines
CC Jeff Kirsher <[email protected]>
CC intel-wired-lan at lists.osuosl.org
CC netdev at vger.kernel.org
---
 drivers/net/ethernet/intel/e1000e/netdev.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)