[dpdk-dev] [PATCH] net/i40e: fix vlan filter issue
Wenzhuo Lu
wenzhuo.lu at intel.com
Wed Mar 22 09:39:07 CET 2017
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 303027b..105b226 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -1867,6 +1867,7 @@ static inline void i40e_GLQF_reg_init(struct i40e_hw *hw)
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;
@@ -1945,6 +1946,15 @@ static inline void i40e_GLQF_reg_init(struct i40e_hw *hw)
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 |
@@ -4659,6 +4669,7 @@ struct i40e_vsi *
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 :
@@ -6027,7 +6038,7 @@ struct i40e_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);
@@ -10455,10 +10466,12 @@ static void i40e_set_default_mac_addr(struct rte_eth_dev *dev,
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);
@@ -10641,7 +10654,7 @@ static void i40e_set_default_mac_addr(struct rte_eth_dev *dev,
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.");
@@ -10669,7 +10682,7 @@ static void i40e_set_default_mac_addr(struct rte_eth_dev *dev,
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;
@@ -11077,6 +11090,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;
@@ -11115,14 +11129,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.3
More information about the dev
mailing list