Two clean-ups for recent ixgbe VLAN changes
Subsystems (2)
cover Two clean-ups for recent ixgbe VLAN changes
These two patches clean up some minor left-overs from the recent VLAN changes I had submitted. With the first patch we should be able to avoid having the PF leave any entries in the VLVF unless one of the VFs has made use of the VLAN in which case we end up with a shared VLVF entry being created for both the PF and the VF. The other patch just prevents us from looping through the setup for VLAN 0 twice.
---
Alexander Duyck (2):
ixgbe: Do not allow PF to add VLVF entry unless it actually needs it
ixgbe: Avoid adding VLAN 0 twice to VLVF and VFTA
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 12 +++++---- drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c | 31 +++++++++++++----------- 2 files changed, 23 insertions(+), 20 deletions(-)
--
PATCH 1/2 ixgbe: Do not allow PF to add VLVF entry unless it actually needs it
While doing the work on igb I realized there were a few cases where we were still adding VLANs to the VLVF entries for the PF when they were not needed. This patch cleans that up so that the only time we add a PF entry to the VLVF is either for VLAN 0 or if the PF has requested a VLAN that a VF is already using.
--- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 8 +++--- drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c | 31 +++++++++++++----------- 2 files changed, 21 insertions(+), 18 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +4 -4
@@ -3905,7 +3905,9 @@ static int ixgbe_vlan_rx_add_vid(struct net_device *netdev,struct ixgbe_hw *hw = &adapter->hw;/* add VID to filter table */ - hw->mac.ops.set_vfta (&adapter->hw, vid,VMDQ_P (0 ), true, true); +if (!vid || !(adapter->flags2 &IXGBE_FLAG2_VLAN_PROMISC )) + hw->mac.ops.set_vfta (&adapter->hw, vid,VMDQ_P (0 ), true, !!vid); +set_bit (vid, adapter->active_vlans);return 0 ;
@@ -3962,9 +3964,7 @@ static int ixgbe_vlan_rx_kill_vid(struct net_device *netdev,struct ixgbe_hw *hw = &adapter->hw;/* remove VID from filter table */ -if (adapter->flags2 &IXGBE_FLAG2_VLAN_PROMISC ) -ixgbe_update_pf_promisc_vlvf (adapter, vid); -else +if (vid && !(adapter->flags2 &IXGBE_FLAG2_VLAN_PROMISC )) hw->mac.ops.set_vfta (hw, vid,VMDQ_P (0 ), false, true);clear_bit (vid, adapter->active_vlans);
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c +17 -14
@@ -589,40 +589,40 @@ static void ixgbe_clear_vmvir(struct ixgbe_adapter *adapter, u32 vf)static void ixgbe_clear_vf_vlans (struct ixgbe_adapter *adapter,u32 vf) {struct ixgbe_hw *hw = &adapter->hw; -u32 i; +u32 vlvfb_mask, pool_mask, i; + +/* create mask for VF and other pools */ + pool_mask = ~(1 << (VMDQ_P (0 ) %32 )); + vlvfb_mask =1 << (vf %32 );/* post increment loop, covers VLVF_ENTRIES - 1 to 0 */ for (i =IXGBE_VLVF_ENTRIES ; i--;) {u32 bits[2 ], vlvfb, vid, vfta, vlvf;u32 word = i *2 + vf /32 ; -u32 mask =1 << (vf %32 ); +u32 mask; vlvfb =IXGBE_READ_REG (hw,IXGBE_VLVFB (word));/* if our bit isn't set we can skip it */ -if (!(vlvfb & mask)) +if (!(vlvfb & vlvfb_mask))continue ;/* clear our bit from vlvfb */ - vlvfb ^= mask; + vlvfb ^= vlvfb_mask;/* create 64b mask to chedk to see if we should clear VLVF */ bits[word %2 ] = vlvfb; bits[~word %2 ] =IXGBE_READ_REG (hw,IXGBE_VLVFB (word ^1 )); -/* if promisc is enabled, PF will be present, leave VFTA */ -if (adapter->flags2 &IXGBE_FLAG2_VLAN_PROMISC ) { - bits[VMDQ_P (0 ) /32 ] &= ~(1 << (VMDQ_P (0 ) %32 )); - -if (bits[0 ] || bits[1 ]) - goto update_vlvfb; - goto update_vlvf; - } -/* if other pools are present, just remove ourselves */ -if (bits[0 ] || bits[1 ]) +if (bits[(VMDQ_P (0 ) /32 ) ^1 ] || + (bits[VMDQ_P (0 ) /32 ] & pool_mask)) goto update_vlvfb; +/* if PF is present, leave VFTA */ +if (bits[0 ] || bits[1 ]) + goto update_vlvf; +/* if we cannot determine VLAN just remove ourselves */ vlvf =IXGBE_READ_REG (hw,IXGBE_VLVF (i));if (!vlvf)
@@ -638,6 +638,9 @@ static void ixgbe_clear_vf_vlans(struct ixgbe_adapter *adapter, u32 vf) update_vlvf:/* clear POOL selection enable */ IXGBE_WRITE_REG (hw,IXGBE_VLVF (i),0 ); + +if (!(adapter->flags2 &IXGBE_FLAG2_VLAN_PROMISC )) + vlvfb =0 ; update_vlvfb:/* clear pool bits */ IXGBE_WRITE_REG (hw,IXGBE_VLVFB (word), vlvfb);
PATCH 2/2 ixgbe: Avoid adding VLAN 0 twice to VLVF and VFTA
In reply to Alexander DuyckWe were adding VLAN 0 twice each time we restored the VLAN configuration. Instead of doing it twice we can just start working through the active VLANs from ID 1 on and skip the double write.
--- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +2 -2
@@ -4169,11 +4169,11 @@ static void ixgbe_vlan_promisc_disable(struct ixgbe_adapter *adapter)static void ixgbe_restore_vlan (struct ixgbe_adapter *adapter) { -u16 vid; +u16 vid =1 ;ixgbe_vlan_rx_add_vid (adapter->netdev,htons (ETH_P_8021Q ),0 ); -for_each_set_bit (vid, adapter->active_vlans,VLAN_N_VID ) +for_each_set_bit_from (vid, adapter->active_vlans,VLAN_N_VID )ixgbe_vlan_rx_add_vid (adapter->netdev,htons (ETH_P_8021Q ), vid); }
Schmitt
PATCH 1/2 ixgbe: Do not allow PF to add VLVF entry unless it actually needs it
In reply to Alexander DuyckQuoted 10 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Alexander Duyck
Sent: Wednesday, January 06, 2016 10:49 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH 1/2] ixgbe: Do not allow PF to add VLVF entry unless it actually needs it
Quoted 7 lines
While doing the work on igb I realized there were a few cases where we were still adding VLANs to the VLVF entries for the PF when they were not needed. This patch cleans that up so that the only time we add a PF entry to the VLVF is either for VLAN 0 or if the PF has requested a VLAN that a VF is already using.
Signed-off-by Alexander Duyck <[email protected]>---
Schmitt
PATCH 2/2 ixgbe: Avoid adding VLAN 0 twice to VLVF and VFTA
In reply to Alexander DuyckQuoted 10 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Alexander Duyck
Sent: Wednesday, January 06, 2016 10:49 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH 2/2] ixgbe: Avoid adding VLAN 0 twice to VLVF and VFTA
Quoted 6 lines
We were adding VLAN 0 twice each time we restored the VLAN configuration. Instead of doing it twice we can just start working through the active VLANs from ID 1 on and skip the double write.
Signed-off-by Alexander Duyck <[email protected]>---