[dpdk-stable] patch 'net/i40e: fix VLAN filter' has been queued to stable release 17.02.1

Yuanhan Liu yuanhan.liu at linux.intel.com
Thu May 25 11:48:13 CEST 2017


Hi,

FYI, your patch has been queued to stable release 17.02.1

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 05/28/17. So please
shout if anyone has objections.

Thanks.

	--yliu

---
>From 8755f34d9d4b6cf742b11f6b4cb6ef7e835a9c9b Mon Sep 17 00:00:00 2001
From: Wenzhuo Lu <wenzhuo.lu at intel.com>
Date: Wed, 22 Mar 2017 16:39:07 +0800
Subject: [PATCH] net/i40e: fix VLAN filter

[ upstream commit 9f0645cd147c8819deb8d844850c577b433f6b6a ]

VLAN filter is not working on i40e because driver need to
disable the VLAN promiscuous mode and set the VLAN filter
table.

Fixes: 5f2b0e3f7656 ("net/i40e: set VF VLAN filter from PF")

Signed-off-by: Wenzhuo Lu <wenzhuo.lu at intel.com>
---
 drivers/net/i40e/i40e_ethdev.c | 50 ++++++++++++++++++++++++++++++------------
 drivers/net/i40e/i40e_ethdev.h |  1 +
 2 files changed, 37 insertions(+), 14 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 047855c..a3f8514 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -1873,6 +1873,7 @@ i40e_dev_start(struct rte_eth_dev *dev)
 	struct rte_pci_device *pci_dev = I40E_DEV_TO_PCI(dev);
 	struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
 	uint32_t intr_vector = 0;
+	struct i40e_vsi *vsi;
 
 	hw->adapter_stopped = 0;
 
@@ -1951,6 +1952,15 @@ i40e_dev_start(struct rte_eth_dev *dev)
 			PMD_DRV_LOG(INFO, "fail to set vsi broadcast");
 	}
 
+	/* Enable the VLAN promiscuous mode. */
+	if (pf->vfs) {
+		for (i = 0; i < pf->vf_num; i++) {
+			vsi = pf->vfs[i].vsi;
+			i40e_aq_set_vsi_vlan_promisc(hw, vsi->seid,
+						     true, NULL);
+		}
+	}
+
 	/* Apply link configure */
 	if (dev->data->dev_conf.link_speeds & ~(ETH_LINK_SPEED_100M |
 				ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G |
@@ -4666,6 +4676,7 @@ i40e_vsi_setup(struct i40e_pf *pf,
 	vsi->parent_vsi = uplink_vsi ? uplink_vsi : pf->main_vsi;
 	vsi->user_param = user_param;
 	vsi->vlan_anti_spoof_on = 0;
+	vsi->vlan_filter_on = 0;
 	/* Allocate queues */
 	switch (vsi->type) {
 	case I40E_VSI_MAIN  :
@@ -6034,7 +6045,7 @@ i40e_set_vlan_filter(struct i40e_vsi *vsi,
 
 	i40e_store_vlan_filter(vsi, vlan_id, on);
 
-	if (!vsi->vlan_anti_spoof_on || !vlan_id)
+	if ((!vsi->vlan_anti_spoof_on && !vsi->vlan_filter_on) || !vlan_id)
 		return;
 
 	vlan_data.vlan_tag = rte_cpu_to_le_16(vlan_id);
@@ -10462,10 +10473,12 @@ rte_pmd_i40e_set_vf_vlan_anti_spoof(uint8_t port, uint16_t vf_id, uint8_t on)
 		return 0; /* already on or off */
 
 	vsi->vlan_anti_spoof_on = on;
-	ret = i40e_add_rm_all_vlan_filter(vsi, on);
-	if (ret) {
-		PMD_DRV_LOG(ERR, "Failed to remove VLAN filters.");
-		return -ENOTSUP;
+	if (!vsi->vlan_filter_on) {
+		ret = i40e_add_rm_all_vlan_filter(vsi, on);
+		if (ret) {
+			PMD_DRV_LOG(ERR, "Failed to add/remove VLAN filters.");
+			return -ENOTSUP;
+		}
 	}
 
 	vsi->info.valid_sections = cpu_to_le16(I40E_AQ_VSI_PROP_SECURITY_VALID);
@@ -10648,7 +10661,7 @@ i40e_vsi_set_tx_loopback(struct i40e_vsi *vsi, uint8_t on)
 		PMD_INIT_LOG(ERR, "Failed to remove MAC filters.");
 		return ret;
 	}
-	if (vsi->vlan_anti_spoof_on) {
+	if (vsi->vlan_anti_spoof_on || vsi->vlan_filter_on) {
 		ret = i40e_add_rm_all_vlan_filter(vsi, 0);
 		if (ret) {
 			PMD_INIT_LOG(ERR, "Failed to remove VLAN filters.");
@@ -10676,7 +10689,7 @@ i40e_vsi_set_tx_loopback(struct i40e_vsi *vsi, uint8_t on)
 	ret = i40e_vsi_restore_mac_filter(vsi);
 	if (ret)
 		return ret;
-	if (vsi->vlan_anti_spoof_on) {
+	if (vsi->vlan_anti_spoof_on || vsi->vlan_filter_on) {
 		ret = i40e_add_rm_all_vlan_filter(vsi, 1);
 		if (ret)
 			return ret;
@@ -11094,6 +11107,7 @@ int rte_pmd_i40e_set_vf_vlan_filter(uint8_t port, uint16_t vlan_id,
 	struct rte_eth_dev *dev;
 	struct i40e_pf *pf;
 	struct i40e_hw *hw;
+	struct i40e_vsi *vsi;
 	uint16_t vf_idx;
 	int ret = I40E_SUCCESS;
 
@@ -11132,14 +11146,22 @@ int rte_pmd_i40e_set_vf_vlan_filter(uint8_t port, uint16_t vlan_id,
 		return -ENODEV;
 	}
 
-	for (vf_idx = 0; vf_idx < 64 && ret == I40E_SUCCESS; vf_idx++) {
+	for (vf_idx = 0; vf_idx < pf->vf_num && ret == I40E_SUCCESS; vf_idx++) {
 		if (vf_mask & ((uint64_t)(1ULL << vf_idx))) {
-			if (on)
-				ret = i40e_vsi_add_vlan(pf->vfs[vf_idx].vsi,
-							vlan_id);
-			else
-				ret = i40e_vsi_delete_vlan(pf->vfs[vf_idx].vsi,
-							   vlan_id);
+			vsi = pf->vfs[vf_idx].vsi;
+			if (on) {
+				if (!vsi->vlan_filter_on) {
+					vsi->vlan_filter_on = true;
+					if (!vsi->vlan_anti_spoof_on)
+						i40e_add_rm_all_vlan_filter(
+							vsi, true);
+				}
+				i40e_aq_set_vsi_vlan_promisc(hw, vsi->seid,
+							     false, NULL);
+				ret = i40e_vsi_add_vlan(vsi, vlan_id);
+			} else {
+				ret = i40e_vsi_delete_vlan(vsi, vlan_id);
+			}
 		}
 	}
 
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index f545850..aebb097 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -364,6 +364,7 @@ struct i40e_vsi {
 	uint16_t nb_msix;   /* The max number of msix vector */
 	uint8_t enabled_tc; /* The traffic class enabled */
 	uint8_t vlan_anti_spoof_on; /* The VLAN anti-spoofing enabled */
+	uint8_t vlan_filter_on; /* The VLAN filter enabled */
 	struct i40e_bw_info bw_info; /* VSI bandwidth information */
 };
 
-- 
1.9.0



More information about the stable mailing list