Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c18fbd5f authored by Alexander Duyck's avatar Alexander Duyck Committed by Jeff Kirsher
Browse files

ixgbe: Simplify definitions for regidx and bit in set_vfta



This patch simplifies the logic for setting the VFTA register by removing
the number of conditional checks needed.  Instead we just use some boolean
logic to generate vfta_delta, and if that is set then we xor the vfta by
that value and write it back.

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 8e8e9a0b
Loading
Loading
Loading
Loading
+19 −29
Original line number Original line Diff line number Diff line
@@ -3050,13 +3050,9 @@ 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)
{
{
	s32 regindex;
	u32 regidx, vfta_delta, vfta;
	u32 bitindex;
	u32 vfta;
	u32 bits;
	u32 bits;
	u32 vt;
	u32 vt;
	u32 targetbit;
	bool vfta_changed = false;


	if (vlan > 4095)
	if (vlan > 4095)
		return IXGBE_ERR_PARAM;
		return IXGBE_ERR_PARAM;
@@ -3073,22 +3069,16 @@ s32 ixgbe_set_vfta_generic(struct ixgbe_hw *hw, u32 vlan, u32 vind,
	 *    bits[11-5]: which register
	 *    bits[11-5]: which register
	 *    bits[4-0]:  which bit in the register
	 *    bits[4-0]:  which bit in the register
	 */
	 */
	regindex = (vlan >> 5) & 0x7F;
	regidx = vlan / 32;
	bitindex = vlan & 0x1F;
	vfta_delta = 1 << (vlan % 32);
	targetbit = (1 << bitindex);
	vfta = IXGBE_READ_REG(hw, IXGBE_VFTA(regidx));
	vfta = IXGBE_READ_REG(hw, IXGBE_VFTA(regindex));


	if (vlan_on) {
	/* vfta_delta represents the difference between the current value
		if (!(vfta & targetbit)) {
	 * of vfta and the value we want in the register.  Since the diff
			vfta |= targetbit;
	 * is an XOR mask we can just update vfta using an XOR.
			vfta_changed = true;
	 */
		}
	vfta_delta &= vlan_on ? ~vfta : vfta;
	} else {
	vfta ^= vfta_delta;
		if ((vfta & targetbit)) {
			vfta &= ~targetbit;
			vfta_changed = true;
		}
	}


	/* Part 2
	/* Part 2
	 * If VT Mode is set
	 * If VT Mode is set
@@ -3164,19 +3154,19 @@ s32 ixgbe_set_vfta_generic(struct ixgbe_hw *hw, u32 vlan, u32 vind,
		if (bits) {
		if (bits) {
			IXGBE_WRITE_REG(hw, IXGBE_VLVF(vlvf_index),
			IXGBE_WRITE_REG(hw, IXGBE_VLVF(vlvf_index),
					(IXGBE_VLVF_VIEN | vlan));
					(IXGBE_VLVF_VIEN | vlan));
			if (!vlan_on) {

				/* someone wants to clear the vfta entry
			/* if someone wants to clear the vfta entry but
				 * but some pools/VFs are still using it.
			 * some pools/VFs are still using it.  Ignore it.
				 * Ignore it. */
			 */
				vfta_changed = false;
			if (!vlan_on)
			}
				vfta_delta = 0;
		} else {
		} else {
			IXGBE_WRITE_REG(hw, IXGBE_VLVF(vlvf_index), 0);
			IXGBE_WRITE_REG(hw, IXGBE_VLVF(vlvf_index), 0);
		}
		}
	}
	}


	if (vfta_changed)
	if (vfta_delta)
		IXGBE_WRITE_REG(hw, IXGBE_VFTA(regindex), vfta);
		IXGBE_WRITE_REG(hw, IXGBE_VFTA(regidx), vfta);


	return 0;
	return 0;
}
}