: VLAN filtering fixes
Subsystems (2)
cover : VLAN filtering fixes
These two patches contain the last bits of my VLAN + tcpdump fixes. Currently some (all?) drivers have inconsistent behaviour wrt. VLAN filtering and promiscous mode:
They start with disabled VLAN filtering, meaning all VLAN packets are received on packet sockets. When adding the first VLAN, VLAN filtering is enabled and only packets for locally configured VLANs are received, even in promiscous mode. In most cases VLAN filtering is disabled again when removing the last VLAN, igxbe keeps it enabled permanently however.
These patches change the Intel drivers to always enable VLAN filtering while not in promiscous mode since there is little point in receiving VLAN packets while nothing is interested in them, but disable filtering while in promiscous mode so all VLANs are visible to packet sockets.
There are four more drivers that support VLAN filtering that I didn't adapt to this behaviour since I'm not sure about what exactly they currently do. All four of tehuti, starfire, ehea and via-velocity have a flag for the hardware to enable promiscous mode, its unknown to me whether this also automatically disables VLAN filtering. Any information on this someone might have is appreciated.
PATCH 1/2 : netdrv intel: disable VLAN filtering in promiscous mode
commit acec641127a35c44173d243ef300f7fa6cbec646
Author: Patrick McHardy <[email protected]> Date: Wed Jul 16 11:03:55 2008 +0200
netdrv intel: disable VLAN filtering in promiscous mode
As discussed in this thread:
http://www.mail-archive.com/[email protected]/msg53976.html
promiscous mode means to disable *all* filters. Currently only unicast and multicast filtering is disabled. This patch changes all Intel drivers to also disable VLAN filtering.
drivers/net/e1000/e1000_main.c +10 -4
@@ -2477,10 +2477,15 @@ e1000_set_rx_mode(struct net_device *netdev)if (netdev->flags &IFF_PROMISC ) { rctl |= (E1000_RCTL_UPE |E1000_RCTL_MPE ); - }else if (netdev->flags &IFF_ALLMULTI ) { - rctl |=E1000_RCTL_MPE ; + rctl &= ~E1000_RCTL_VFE ; }else { - rctl &= ~E1000_RCTL_MPE ; +if (netdev->flags &IFF_ALLMULTI ) { + rctl |=E1000_RCTL_MPE ; + }else { + rctl &= ~E1000_RCTL_MPE ; + } +if (adapter->vlgrp && adapter->hw.mac_type != e1000_ich8lan) + rctl |=E1000_RCTL_VFE ; } uc_ptr =NULL ;
@@ -4962,7 +4967,8 @@ e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)if (adapter->hw.mac_type != e1000_ich8lan) {/* enable VLAN receive filtering */ rctl =E1000_READ_REG (&adapter->hw,RCTL ); - rctl |=E1000_RCTL_VFE ; +if (!(netdev->flags &IFF_PROMISC )) + rctl |=E1000_RCTL_VFE ; rctl &= ~E1000_RCTL_CFIEN ;E1000_WRITE_REG (&adapter->hw,RCTL , rctl);e1000_update_mng_vlan (adapter);
drivers/net/e1000e/netdev.c +11 -5
@@ -1792,7 +1792,8 @@ static void e1000_vlan_rx_register(struct net_device *netdev,if (adapter->flags &FLAG_HAS_HW_VLAN_FILTER ) {/* enable VLAN receive filtering */ rctl =er32 (RCTL ); - rctl |=E1000_RCTL_VFE ; +if (!(netdev->flags &IFF_PROMISC )) + rctl |=E1000_RCTL_VFE ; rctl &= ~E1000_RCTL_CFIEN ;ew32 (RCTL , rctl);e1000_update_mng_vlan (adapter);
@@ -2230,11 +2231,16 @@ static void e1000_set_multi(struct net_device *netdev)if (netdev->flags &IFF_PROMISC ) { rctl |= (E1000_RCTL_UPE |E1000_RCTL_MPE ); - }else if (netdev->flags &IFF_ALLMULTI ) { - rctl |=E1000_RCTL_MPE ; - rctl &= ~E1000_RCTL_UPE ; + rctl &= ~E1000_RCTL_VFE ; }else { - rctl &= ~(E1000_RCTL_UPE |E1000_RCTL_MPE ); +if (netdev->flags &IFF_ALLMULTI ) { + rctl |=E1000_RCTL_MPE ; + rctl &= ~E1000_RCTL_UPE ; + }else { + rctl &= ~(E1000_RCTL_UPE |E1000_RCTL_MPE ); + } +if (adapter->vlgrp && adapter->flags &FLAG_HAS_HW_VLAN_FILTER ) + rctl |=E1000_RCTL_VFE ; }ew32 (RCTL , rctl);
drivers/net/igb/igb_main.c +13 -8
@@ -2268,14 +2268,18 @@ static void igb_set_multi(struct net_device *netdev) rctl =rd32 (E1000_RCTL ); -if (netdev->flags &IFF_PROMISC ) +if (netdev->flags &IFF_PROMISC ) { rctl |= (E1000_RCTL_UPE |E1000_RCTL_MPE ); -else if (netdev->flags &IFF_ALLMULTI ) { - rctl |=E1000_RCTL_MPE ; - rctl &= ~E1000_RCTL_UPE ; - }else - rctl &= ~(E1000_RCTL_UPE |E1000_RCTL_MPE ); - + rctl &= ~E1000_RCTL_VFE ; + }else { +if (netdev->flags &IFF_ALLMULTI ) { + rctl |=E1000_RCTL_MPE ; + rctl &= ~E1000_RCTL_UPE ; + }else + rctl &= ~(E1000_RCTL_UPE |E1000_RCTL_MPE ); +if (adapter->vlgrp) + rctl |=E1000_RCTL_VFE ; + }wr32 (E1000_RCTL , rctl);if (!netdev->mc_count) {
@@ -4220,7 +4224,8 @@ static void igb_vlan_rx_register(struct net_device *netdev,/* enable VLAN receive filtering */ rctl =rd32 (E1000_RCTL ); - rctl |=E1000_RCTL_VFE ; +if (!(netdev->flags &IFF_PROMISC )) + rctl |=E1000_RCTL_VFE ; rctl &= ~E1000_RCTL_CFIEN ;wr32 (E1000_RCTL , rctl);igb_update_mng_vlan (adapter);
drivers/net/ixgb/ixgb_main.c +11 -5
@@ -1053,11 +1053,16 @@ ixgb_set_multi(struct net_device *netdev)if (netdev->flags &IFF_PROMISC ) { rctl |= (IXGB_RCTL_UPE |IXGB_RCTL_MPE ); - }else if (netdev->flags &IFF_ALLMULTI ) { - rctl |=IXGB_RCTL_MPE ; - rctl &= ~IXGB_RCTL_UPE ; + rctl &= ~IXGB_RCTL_VFE ; }else { - rctl &= ~(IXGB_RCTL_UPE |IXGB_RCTL_MPE ); +if (netdev->flags &IFF_ALLMULTI ) { + rctl |=IXGB_RCTL_MPE ; + rctl &= ~IXGB_RCTL_UPE ; + }else { + rctl &= ~(IXGB_RCTL_UPE |IXGB_RCTL_MPE ); + } +if (adapter->vlgrp) + rctl |=IXGB_RCTL_VFE ; }if (netdev->mc_count >IXGB_MAX_NUM_MULTICAST_ADDRESSES ) {
@@ -2104,7 +2109,8 @@ ixgb_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)/* enable VLAN receive filtering */ rctl =IXGB_READ_REG (&adapter->hw,RCTL ); - rctl |=IXGB_RCTL_VFE ; +if (!(netdev->flags &IFF_PROMISC )) + rctl |=IXGB_RCTL_VFE ; rctl &= ~IXGB_RCTL_CFIEN ;IXGB_WRITE_REG (&adapter->hw,RCTL , rctl); }else {
drivers/net/ixgbe/ixgbe_main.c +12 -5
@@ -1574,7 +1574,9 @@ static void ixgbe_vlan_rx_register(struct net_device *netdev,if (grp) {/* enable VLAN tag insert/strip */ ctrl =IXGBE_READ_REG (&adapter->hw,IXGBE_VLNCTRL ); - ctrl |=IXGBE_VLNCTRL_VME |IXGBE_VLNCTRL_VFE ; + ctrl |=IXGBE_VLNCTRL_VME ; +if (!(netdev->flags &IFF_PROMISC )) + ctrl |=IXGBE_VLNCTRL_VFE ; ctrl &= ~IXGBE_VLNCTRL_CFIEN ;IXGBE_WRITE_REG (&adapter->hw,IXGBE_VLNCTRL , ctrl); }
@@ -1645,11 +1647,16 @@ static void ixgbe_set_multi(struct net_device *netdev)if (netdev->flags &IFF_PROMISC ) { fctrl |= (IXGBE_FCTRL_UPE |IXGBE_FCTRL_MPE ); - }else if (netdev->flags &IFF_ALLMULTI ) { - fctrl |=IXGBE_FCTRL_MPE ; - fctrl &= ~IXGBE_FCTRL_UPE ; + fctrl &= ~IXGBE_VLNCTRL_VFE ; }else { - fctrl &= ~(IXGBE_FCTRL_UPE |IXGBE_FCTRL_MPE ); +if (netdev->flags &IFF_ALLMULTI ) { + fctrl |=IXGBE_FCTRL_MPE ; + fctrl &= ~IXGBE_FCTRL_UPE ; + }else { + fctrl &= ~(IXGBE_FCTRL_UPE |IXGBE_FCTRL_MPE ); + } +if (adapter->vlgrp) + fctrl |=IXGBE_VLNCTRL_VFE ; }IXGBE_WRITE_REG (hw,IXGBE_FCTRL , fctrl);
PATCH 2/2 : netdrv intel: always enable VLAN filtering except in promiscous mode
In reply to Patrick McHardycommit 6e3767e854209df125d7c2d70f23ae97ab61e5f2
Author: Patrick McHardy <[email protected]> Date: Wed Jul 16 11:05:21 2008 +0200
netdrv intel: always enable VLAN filtering except in promiscous mode
Currently VLAN filtering is enabled when the first VLAN is added. Obviously before that there's no point in receiving any VLAN packets. Now that we disable VLAN filtering in promiscous mode, we can keep the VLAN filters enabled the remaining time.
drivers/net/e1000/e1000_main.c +1 -7
@@ -2484,7 +2484,7 @@ e1000_set_rx_mode(struct net_device *netdev) }else { rctl &= ~E1000_RCTL_MPE ; } -if (adapter->vlgrp && adapter->hw.mac_type != e1000_ich8lan) +if (adapter->hw.mac_type != e1000_ich8lan) rctl |=E1000_RCTL_VFE ; }
@@ -4967,8 +4967,6 @@ e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)if (adapter->hw.mac_type != e1000_ich8lan) {/* enable VLAN receive filtering */ rctl =E1000_READ_REG (&adapter->hw,RCTL ); -if (!(netdev->flags &IFF_PROMISC )) - rctl |=E1000_RCTL_VFE ; rctl &= ~E1000_RCTL_CFIEN ;E1000_WRITE_REG (&adapter->hw,RCTL , rctl);e1000_update_mng_vlan (adapter);
@@ -4980,10 +4978,6 @@ e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)E1000_WRITE_REG (&adapter->hw,CTRL , ctrl);if (adapter->hw.mac_type != e1000_ich8lan) { -/* disable VLAN filtering */ - rctl =E1000_READ_REG (&adapter->hw,RCTL ); - rctl &= ~E1000_RCTL_VFE ; -E1000_WRITE_REG (&adapter->hw,RCTL , rctl);if (adapter->mng_vlan_id != (u16 )E1000_MNG_VLAN_NONE ) { e1000_vlan_rx_kill_vid(netdev,
drivers/net/e1000e/netdev.c +1 -7
@@ -1792,8 +1792,6 @@ static void e1000_vlan_rx_register(struct net_device *netdev,if (adapter->flags &FLAG_HAS_HW_VLAN_FILTER ) {/* enable VLAN receive filtering */ rctl =er32 (RCTL ); -if (!(netdev->flags &IFF_PROMISC )) - rctl |=E1000_RCTL_VFE ; rctl &= ~E1000_RCTL_CFIEN ;ew32 (RCTL , rctl);e1000_update_mng_vlan (adapter);
@@ -1805,10 +1803,6 @@ static void e1000_vlan_rx_register(struct net_device *netdev,ew32 (CTRL , ctrl);if (adapter->flags &FLAG_HAS_HW_VLAN_FILTER ) { -/* disable VLAN filtering */ - rctl =er32 (RCTL ); - rctl &= ~E1000_RCTL_VFE ; -ew32 (RCTL , rctl);if (adapter->mng_vlan_id != (u16 )E1000_MNG_VLAN_NONE ) { e1000_vlan_rx_kill_vid(netdev,
@@ -2239,7 +2233,7 @@ static void e1000_set_multi(struct net_device *netdev) }else { rctl &= ~(E1000_RCTL_UPE |E1000_RCTL_MPE ); } -if (adapter->vlgrp && adapter->flags &FLAG_HAS_HW_VLAN_FILTER ) +if (adapter->flags &FLAG_HAS_HW_VLAN_FILTER ) rctl |=E1000_RCTL_VFE ; }
drivers/net/igb/igb_main.c +1 -8
@@ -2277,8 +2277,7 @@ static void igb_set_multi(struct net_device *netdev) rctl &= ~E1000_RCTL_UPE ; }else rctl &= ~(E1000_RCTL_UPE |E1000_RCTL_MPE ); -if (adapter->vlgrp) - rctl |=E1000_RCTL_VFE ; + rctl |=E1000_RCTL_VFE ; }wr32 (E1000_RCTL , rctl);
@@ -4224,8 +4223,6 @@ static void igb_vlan_rx_register(struct net_device *netdev,/* enable VLAN receive filtering */ rctl =rd32 (E1000_RCTL ); -if (!(netdev->flags &IFF_PROMISC )) - rctl |=E1000_RCTL_VFE ; rctl &= ~E1000_RCTL_CFIEN ;wr32 (E1000_RCTL , rctl);igb_update_mng_vlan (adapter);
@@ -4237,10 +4234,6 @@ static void igb_vlan_rx_register(struct net_device *netdev, ctrl &= ~E1000_CTRL_VME ;wr32 (E1000_CTRL , ctrl); -/* disable VLAN filtering */ - rctl =rd32 (E1000_RCTL ); - rctl &= ~E1000_RCTL_VFE ; -wr32 (E1000_RCTL , rctl);if (adapter->mng_vlan_id != (u16 )IGB_MNG_VLAN_NONE ) {igb_vlan_rx_kill_vid (netdev, adapter->mng_vlan_id); adapter->mng_vlan_id =IGB_MNG_VLAN_NONE ;
drivers/net/ixgb/ixgb_main.c +1 -10
@@ -1061,8 +1061,7 @@ ixgb_set_multi(struct net_device *netdev) }else { rctl &= ~(IXGB_RCTL_UPE |IXGB_RCTL_MPE ); } -if (adapter->vlgrp) - rctl |=IXGB_RCTL_VFE ; + rctl |=IXGB_RCTL_VFE ; }if (netdev->mc_count >IXGB_MAX_NUM_MULTICAST_ADDRESSES ) {
@@ -2109,8 +2108,6 @@ ixgb_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)/* enable VLAN receive filtering */ rctl =IXGB_READ_REG (&adapter->hw,RCTL ); -if (!(netdev->flags &IFF_PROMISC )) - rctl |=IXGB_RCTL_VFE ; rctl &= ~IXGB_RCTL_CFIEN ;IXGB_WRITE_REG (&adapter->hw,RCTL , rctl); }else {
@@ -2119,12 +2116,6 @@ ixgb_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp) ctrl =IXGB_READ_REG (&adapter->hw,CTRL0 ); ctrl &= ~IXGB_CTRL0_VME ;IXGB_WRITE_REG (&adapter->hw,CTRL0 , ctrl); - -/* disable VLAN filtering */ - - rctl =IXGB_READ_REG (&adapter->hw,RCTL ); - rctl &= ~IXGB_RCTL_VFE ; -IXGB_WRITE_REG (&adapter->hw,RCTL , rctl); }/* don't enable interrupts unless we are UP */
drivers/net/ixgbe/ixgbe_main.c +1 -4
@@ -1575,8 +1575,6 @@ static void ixgbe_vlan_rx_register(struct net_device *netdev,/* enable VLAN tag insert/strip */ ctrl =IXGBE_READ_REG (&adapter->hw,IXGBE_VLNCTRL ); ctrl |=IXGBE_VLNCTRL_VME ; -if (!(netdev->flags &IFF_PROMISC )) - ctrl |=IXGBE_VLNCTRL_VFE ; ctrl &= ~IXGBE_VLNCTRL_CFIEN ;IXGBE_WRITE_REG (&adapter->hw,IXGBE_VLNCTRL , ctrl); }
@@ -1655,8 +1653,7 @@ static void ixgbe_set_multi(struct net_device *netdev) }else { fctrl &= ~(IXGBE_FCTRL_UPE |IXGBE_FCTRL_MPE ); } -if (adapter->vlgrp) - fctrl |=IXGBE_VLNCTRL_VFE ; + fctrl |=IXGBE_VLNCTRL_VFE ; }IXGBE_WRITE_REG (hw,IXGBE_FCTRL , fctrl);
Quoted 23 lines · Patrick McHardy
These two patches contain the last bits of my VLAN + tcpdump fixes. Currently some (all?) drivers have inconsistent behaviour wrt. VLAN filtering and promiscous mode:
They start with disabled VLAN filtering, meaning all VLAN packets are received on packet sockets. When adding the first VLAN, VLAN filtering is enabled and only packets for locally configured VLANs are received, even in promiscous mode. In most cases VLAN filtering is disabled again when removing the last VLAN, igxbe keeps it enabled permanently however.
These patches change the Intel drivers to always enable VLAN filtering while not in promiscous mode since there is little point in receiving VLAN packets while nothing is interested in them, but disable filtering while in promiscous mode so all VLANs are visible to packet sockets.
There are four more drivers that support VLAN filtering that I didn't adapt to this behaviour since I'm not sure about what exactly they currently do. All four of tehuti, starfire, ehea and via-velocity have a flag for the hardware to enable promiscous mode, its unknown to me whether this also automatically disables VLAN filtering. Any information on this someone might have is appreciated.
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Cheers, Jeff
From: "Jeff Kirsher" <[email protected]>
Date: Wed, 16 Jul 2008 14:03:33 -0700
Quoted 4 lines · Patrick McHardy
Quoted 3 lines
These two patches contain the last bits of my VLAN + tcpdump fixes. Currently some (all?) drivers have inconsistent behaviour wrt. VLAN filtering and promiscous mode:
...
Quoted 2 lines
I've applied Patrick's patches, thanks everyone.