[dpdk-dev] [PATCH v4 7/7] pmd ixgbe: fix vlan setting in in PF

Pawel Wodkowski pawelx.wodkowski at intel.com
Thu Feb 19 16:54:49 CET 2015


The ixgbe_vlan_filter_set() should use hw->mac.ops.set_vfta() to set
VLAN filtering as this is generic function that handles both non-SRIOV
and SRIOV cases.

Bug was discovered issuing command in testpmd 'rx_vlan add VLAN PORT'
for PF. Requested VLAN was enabled but pool mask is not set. Only
command 'rx_vlan add VLAN port PORT vf MASK' can enable pointed VLAN id
for PF.

Signed-off-by: Pawel Wodkowski <pawelx.wodkowski at intel.com>
---
 lib/librte_pmd_ixgbe/ixgbe_ethdev.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
index 7551bcc..7aef0e8 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
+++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
@@ -1162,21 +1162,18 @@ ixgbe_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
 		IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct ixgbe_vfta * shadow_vfta =
 		IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
-	uint32_t vfta;
+	struct rte_eth_dev_sriov *sriov = &RTE_ETH_DEV_SRIOV(dev);
+	u32 vind = sriov->active ? sriov->def_vmdq_idx : 0;
+	s32 ret_val;
 	uint32_t vid_idx;
-	uint32_t vid_bit;
 
-	vid_idx = (uint32_t) ((vlan_id >> 5) & 0x7F);
-	vid_bit = (uint32_t) (1 << (vlan_id & 0x1F));
-	vfta = IXGBE_READ_REG(hw, IXGBE_VFTA(vid_idx));
-	if (on)
-		vfta |= vid_bit;
-	else
-		vfta &= ~vid_bit;
-	IXGBE_WRITE_REG(hw, IXGBE_VFTA(vid_idx), vfta);
+	ret_val = hw->mac.ops.set_vfta(hw, vlan_id, vind, on);
+	if (ret_val != IXGBE_SUCCESS)
+		return ret_val;
 
+	vid_idx = (uint32_t) ((vlan_id >> 5) & 0x7F);
 	/* update local VFTA copy */
-	shadow_vfta->vfta[vid_idx] = vfta;
+	shadow_vfta->vfta[vid_idx] = IXGBE_READ_REG(hw, IXGBE_VFTA(vid_idx));
 
 	return 0;
 }
-- 
1.9.1



More information about the dev mailing list