Skip to content

Commit 18be4fc

Browse files
Alexander DuyckJeff Kirsher
authored andcommitted
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. Signed-off-by: Alexander Duyck <[email protected]> Tested-by: Phil Schmitt <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 1d96cf9 commit 18be4fc

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3908,7 +3908,9 @@ static int ixgbe_vlan_rx_add_vid(struct net_device *netdev,
39083908
struct ixgbe_hw *hw = &adapter->hw;
39093909

39103910
/* add VID to filter table */
3911-
hw->mac.ops.set_vfta(&adapter->hw, vid, VMDQ_P(0), true, true);
3911+
if (!vid || !(adapter->flags2 & IXGBE_FLAG2_VLAN_PROMISC))
3912+
hw->mac.ops.set_vfta(&adapter->hw, vid, VMDQ_P(0), true, !!vid);
3913+
39123914
set_bit(vid, adapter->active_vlans);
39133915

39143916
return 0;
@@ -3965,9 +3967,7 @@ static int ixgbe_vlan_rx_kill_vid(struct net_device *netdev,
39653967
struct ixgbe_hw *hw = &adapter->hw;
39663968

39673969
/* remove VID from filter table */
3968-
if (adapter->flags2 & IXGBE_FLAG2_VLAN_PROMISC)
3969-
ixgbe_update_pf_promisc_vlvf(adapter, vid);
3970-
else
3970+
if (vid && !(adapter->flags2 & IXGBE_FLAG2_VLAN_PROMISC))
39713971
hw->mac.ops.set_vfta(hw, vid, VMDQ_P(0), false, true);
39723972

39733973
clear_bit(vid, adapter->active_vlans);

drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -589,40 +589,40 @@ static void ixgbe_clear_vmvir(struct ixgbe_adapter *adapter, u32 vf)
589589
static void ixgbe_clear_vf_vlans(struct ixgbe_adapter *adapter, u32 vf)
590590
{
591591
struct ixgbe_hw *hw = &adapter->hw;
592-
u32 i;
592+
u32 vlvfb_mask, pool_mask, i;
593+
594+
/* create mask for VF and other pools */
595+
pool_mask = ~(1 << (VMDQ_P(0) % 32));
596+
vlvfb_mask = 1 << (vf % 32);
593597

594598
/* post increment loop, covers VLVF_ENTRIES - 1 to 0 */
595599
for (i = IXGBE_VLVF_ENTRIES; i--;) {
596600
u32 bits[2], vlvfb, vid, vfta, vlvf;
597601
u32 word = i * 2 + vf / 32;
598-
u32 mask = 1 << (vf % 32);
602+
u32 mask;
599603

600604
vlvfb = IXGBE_READ_REG(hw, IXGBE_VLVFB(word));
601605

602606
/* if our bit isn't set we can skip it */
603-
if (!(vlvfb & mask))
607+
if (!(vlvfb & vlvfb_mask))
604608
continue;
605609

606610
/* clear our bit from vlvfb */
607-
vlvfb ^= mask;
611+
vlvfb ^= vlvfb_mask;
608612

609613
/* create 64b mask to chedk to see if we should clear VLVF */
610614
bits[word % 2] = vlvfb;
611615
bits[~word % 2] = IXGBE_READ_REG(hw, IXGBE_VLVFB(word ^ 1));
612616

613-
/* if promisc is enabled, PF will be present, leave VFTA */
614-
if (adapter->flags2 & IXGBE_FLAG2_VLAN_PROMISC) {
615-
bits[VMDQ_P(0) / 32] &= ~(1 << (VMDQ_P(0) % 32));
616-
617-
if (bits[0] || bits[1])
618-
goto update_vlvfb;
619-
goto update_vlvf;
620-
}
621-
622617
/* if other pools are present, just remove ourselves */
623-
if (bits[0] || bits[1])
618+
if (bits[(VMDQ_P(0) / 32) ^ 1] ||
619+
(bits[VMDQ_P(0) / 32] & pool_mask))
624620
goto update_vlvfb;
625621

622+
/* if PF is present, leave VFTA */
623+
if (bits[0] || bits[1])
624+
goto update_vlvf;
625+
626626
/* if we cannot determine VLAN just remove ourselves */
627627
vlvf = IXGBE_READ_REG(hw, IXGBE_VLVF(i));
628628
if (!vlvf)
@@ -638,6 +638,9 @@ static void ixgbe_clear_vf_vlans(struct ixgbe_adapter *adapter, u32 vf)
638638
update_vlvf:
639639
/* clear POOL selection enable */
640640
IXGBE_WRITE_REG(hw, IXGBE_VLVF(i), 0);
641+
642+
if (!(adapter->flags2 & IXGBE_FLAG2_VLAN_PROMISC))
643+
vlvfb = 0;
641644
update_vlvfb:
642645
/* clear pool bits */
643646
IXGBE_WRITE_REG(hw, IXGBE_VLVFB(word), vlvfb);

0 commit comments

Comments
 (0)