Commit 5ac736a6 authored by Alexander Duyck's avatar Alexander Duyck Committed by Jeff Kirsher

ixgbe: Simplify configuration of setting VLVF and VLVFB

This patch addresses several issues within the VLVF and VLVFB
configuration

First was the fact that code was overly complicated with multiple
conditional paths depending on if we adding or removing and which bit we
were going to add or remove.  Instead of messing with all that I have
simplified it by using (vid / 32) and (1 - vid / 32) to identify our
register and the other vlvfb register.

Second was the fact that we were likely leaking a few packets into the PF
in cases where we were deleting an entry and the VFTA filter for that entry
as the ordering was such that we deleted the pool and then the VLAN filter
instead of the other way around.  I have updated that by adding a check for
no bits being set and if that occurs we clear things up in the proper
order.
Signed-off-by: default avatarAlexander Duyck <aduyck@mirantis.com>
Tested-by: default avatarPhil Schmitt <phillip.j.schmitt@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent 63d9379a
...@@ -3050,11 +3050,10 @@ static s32 ixgbe_find_vlvf_slot(struct ixgbe_hw *hw, u32 vlan) ...@@ -3050,11 +3050,10 @@ static s32 ixgbe_find_vlvf_slot(struct ixgbe_hw *hw, u32 vlan)
s32 ixgbe_set_vfta_generic(struct ixgbe_hw *hw, u32 vlan, u32 vind, s32 ixgbe_set_vfta_generic(struct ixgbe_hw *hw, u32 vlan, u32 vind,
bool vlan_on) bool vlan_on)
{ {
u32 regidx, vfta_delta, vfta; u32 regidx, vfta_delta, vfta, bits;
s32 vlvf_index; s32 vlvf_index;
u32 bits;
if (vlan > 4095) if ((vlan > 4095) || (vind > 63))
return IXGBE_ERR_PARAM; return IXGBE_ERR_PARAM;
/* /*
...@@ -3095,44 +3094,30 @@ s32 ixgbe_set_vfta_generic(struct ixgbe_hw *hw, u32 vlan, u32 vind, ...@@ -3095,44 +3094,30 @@ s32 ixgbe_set_vfta_generic(struct ixgbe_hw *hw, u32 vlan, u32 vind,
if (vlvf_index < 0) if (vlvf_index < 0)
return vlvf_index; return vlvf_index;
if (vlan_on) { bits = IXGBE_READ_REG(hw, IXGBE_VLVFB(vlvf_index * 2 + vind / 32));
/* set the pool bit */
if (vind < 32) { /* set the pool bit */
bits = IXGBE_READ_REG(hw, bits |= 1 << (vind % 32);
IXGBE_VLVFB(vlvf_index*2)); if (vlan_on)
bits |= (1 << vind); goto vlvf_update;
IXGBE_WRITE_REG(hw,
IXGBE_VLVFB(vlvf_index*2), /* clear the pool bit */
bits); bits ^= 1 << (vind % 32);
} else {
bits = IXGBE_READ_REG(hw, if (!bits &&
IXGBE_VLVFB((vlvf_index*2)+1)); !IXGBE_READ_REG(hw, IXGBE_VLVFB(vlvf_index * 2 + 1 - vind / 32))) {
bits |= (1 << (vind-32)); /* Clear VFTA first, then disable VLVF. Otherwise
IXGBE_WRITE_REG(hw, * we run the risk of stray packets leaking into
IXGBE_VLVFB((vlvf_index*2)+1), * the PF via the default pool
bits); */
} if (vfta_delta)
} else { IXGBE_WRITE_REG(hw, IXGBE_VFTA(regidx), vfta);
/* clear the pool bit */
if (vind < 32) { /* disable VLVF and clear remaining bit from pool */
bits = IXGBE_READ_REG(hw, IXGBE_WRITE_REG(hw, IXGBE_VLVF(vlvf_index), 0);
IXGBE_VLVFB(vlvf_index*2)); IXGBE_WRITE_REG(hw, IXGBE_VLVFB(vlvf_index * 2 + vind / 32), 0);
bits &= ~(1 << vind);
IXGBE_WRITE_REG(hw, return 0;
IXGBE_VLVFB(vlvf_index*2),
bits);
bits |= IXGBE_READ_REG(hw,
IXGBE_VLVFB((vlvf_index*2)+1));
} else {
bits = IXGBE_READ_REG(hw,
IXGBE_VLVFB((vlvf_index*2)+1));
bits &= ~(1 << (vind-32));
IXGBE_WRITE_REG(hw,
IXGBE_VLVFB((vlvf_index*2)+1),
bits);
bits |= IXGBE_READ_REG(hw,
IXGBE_VLVFB(vlvf_index*2));
}
} }
/* If there are still bits set in the VLVFB registers /* If there are still bits set in the VLVFB registers
...@@ -3149,20 +3134,15 @@ s32 ixgbe_set_vfta_generic(struct ixgbe_hw *hw, u32 vlan, u32 vind, ...@@ -3149,20 +3134,15 @@ s32 ixgbe_set_vfta_generic(struct ixgbe_hw *hw, u32 vlan, u32 vind,
* been cleared. This will be indicated by "bits" being * been cleared. This will be indicated by "bits" being
* zero. * zero.
*/ */
if (bits) { vfta_delta = 0;
IXGBE_WRITE_REG(hw, IXGBE_VLVF(vlvf_index),
(IXGBE_VLVF_VIEN | vlan));
/* if someone wants to clear the vfta entry but vlvf_update:
* some pools/VFs are still using it. Ignore it. /* record pool change and enable VLAN ID if not already enabled */
*/ IXGBE_WRITE_REG(hw, IXGBE_VLVFB(vlvf_index * 2 + vind / 32), bits);
if (!vlan_on) IXGBE_WRITE_REG(hw, IXGBE_VLVF(vlvf_index), IXGBE_VLVF_VIEN | vlan);
vfta_delta = 0;
} else {
IXGBE_WRITE_REG(hw, IXGBE_VLVF(vlvf_index), 0);
}
vfta_update: vfta_update:
/* Update VFTA now that we are ready for traffic */
if (vfta_delta) if (vfta_delta)
IXGBE_WRITE_REG(hw, IXGBE_VFTA(regidx), vfta); IXGBE_WRITE_REG(hw, IXGBE_VFTA(regidx), vfta);
...@@ -3184,8 +3164,8 @@ s32 ixgbe_clear_vfta_generic(struct ixgbe_hw *hw) ...@@ -3184,8 +3164,8 @@ s32 ixgbe_clear_vfta_generic(struct ixgbe_hw *hw)
for (offset = 0; offset < IXGBE_VLVF_ENTRIES; offset++) { for (offset = 0; offset < IXGBE_VLVF_ENTRIES; offset++) {
IXGBE_WRITE_REG(hw, IXGBE_VLVF(offset), 0); IXGBE_WRITE_REG(hw, IXGBE_VLVF(offset), 0);
IXGBE_WRITE_REG(hw, IXGBE_VLVFB(offset*2), 0); IXGBE_WRITE_REG(hw, IXGBE_VLVFB(offset * 2), 0);
IXGBE_WRITE_REG(hw, IXGBE_VLVFB((offset*2)+1), 0); IXGBE_WRITE_REG(hw, IXGBE_VLVFB(offset * 2 + 1), 0);
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment