From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 6B4E33777 for ; Wed, 22 Mar 2017 09:39:01 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP; 22 Mar 2017 01:39:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,204,1486454400"; d="scan'208";a="837326818" Received: from dpdk26.sh.intel.com ([10.239.128.228]) by FMSMGA003.fm.intel.com with ESMTP; 22 Mar 2017 01:38:59 -0700 From: Wenzhuo Lu To: dev@dpdk.org Cc: Wenzhuo Lu Date: Wed, 22 Mar 2017 16:39:07 +0800 Message-Id: <1490171947-104812-1-git-send-email-wenzhuo.lu@intel.com> X-Mailer: git-send-email 1.9.3 Subject: [dpdk-dev] [PATCH] net/i40e: fix vlan filter issue X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Mar 2017 08:39:01 -0000 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 --- 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