From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 7E9B76A7F for ; Fri, 20 Jun 2014 12:24:55 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 20 Jun 2014 03:25:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,513,1400050800"; d="scan'208";a="558435536" Received: from shilc102.sh.intel.com ([10.239.39.44]) by fmsmga002.fm.intel.com with ESMTP; 20 Jun 2014 03:25:10 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shilc102.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id s5KAP7Al029313; Fri, 20 Jun 2014 18:25:09 +0800 Received: from shecgisg003.sh.intel.com (localhost [127.0.0.1]) by shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id s5KAP43Y006637; Fri, 20 Jun 2014 18:25:06 +0800 Received: (from jingche2@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id s5KAP4dF006633; Fri, 20 Jun 2014 18:25:04 +0800 From: "Chen Jing D(Mark)" To: dev@dpdk.org Date: Fri, 20 Jun 2014 18:24:42 +0800 Message-Id: <1403259884-6498-5-git-send-email-jing.d.chen@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1403259884-6498-1-git-send-email-jing.d.chen@intel.com> References: <1403259884-6498-1-git-send-email-jing.d.chen@intel.com> Subject: [dpdk-dev] [PATCH 4/6] i40e: make change to vlan_strip and vlan_set_pvid function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jun 2014 10:24:56 -0000 From: "Chen Jing D(Mark)" Change original 2 functions to common ones that can take effect on both VF and PF VSIs. Signed-off-by: Chen Jing D(Mark) Acked-by: Helin Zhang Acked-by: Cunming Liang Acked-by: Jingjing Wu --- lib/librte_pmd_i40e/i40e_ethdev.c | 141 ++++++++++++++++++------------------- lib/librte_pmd_i40e/i40e_ethdev.h | 17 +++++ 2 files changed, 87 insertions(+), 71 deletions(-) diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c b/lib/librte_pmd_i40e/i40e_ethdev.c index 4535cdf..1b4e822 100644 --- a/lib/librte_pmd_i40e/i40e_ethdev.c +++ b/lib/librte_pmd_i40e/i40e_ethdev.c @@ -182,11 +182,10 @@ static int i40e_res_pool_free(struct i40e_res_pool_info *pool, uint32_t base); static int i40e_res_pool_alloc(struct i40e_res_pool_info *pool, uint16_t num); -static int i40e_vsi_init_vlan(struct i40e_vsi *vsi); +static int i40e_dev_init_vlan(struct rte_eth_dev *dev); static int i40e_veb_release(struct i40e_veb *veb); static struct i40e_veb *i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi); -static int i40e_vsi_config_vlan_stripping(struct i40e_vsi *vsi, bool on); static int i40e_pf_config_mq_rx(struct i40e_pf *pf); static int i40e_vsi_config_double_vlan(struct i40e_vsi *vsi, int on); static int i40e_pf_disable_all_queues(struct i40e_hw *hw); @@ -534,13 +533,7 @@ err_get_capabilities: static int i40e_dev_configure(struct rte_eth_dev *dev) { - struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); - struct i40e_vsi *vsi = pf->main_vsi; - int ret; - - ret = i40e_vsi_init_vlan(vsi); - - return ret; + return i40e_dev_init_vlan(dev); } void @@ -1293,39 +1286,22 @@ static int i40e_vlan_pvid_set(struct rte_eth_dev *dev, uint16_t pvid, int on) { struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); - struct i40e_hw *hw = I40E_PF_TO_HW(pf); struct i40e_vsi *vsi = pf->main_vsi; struct rte_eth_dev_data *data = I40E_VSI_TO_DEV_DATA(vsi); - struct i40e_vsi_context ctxt; - uint8_t vlan_flags = 0; - int ret; + struct i40e_vsi_vlan_pvid_info info; - if (on) { - /** - * If insert pvid is enabled, only tagged pkts are - * allowed to be sent out. - */ - vlan_flags |= I40E_AQ_VSI_PVLAN_INSERT_PVID | - I40E_AQ_VSI_PVLAN_MODE_TAGGED; - } else { - if (data->dev_conf.txmode.hw_vlan_reject_tagged == 0) - vlan_flags |= I40E_AQ_VSI_PVLAN_MODE_TAGGED; - if (data->dev_conf.txmode.hw_vlan_reject_untagged == 0) - vlan_flags |= I40E_AQ_VSI_PVLAN_MODE_UNTAGGED; + memset(&info, 0, sizeof(info)); + info.on = on; + if (info.on) + info.config.pvid = pvid; + else { + info.config.reject.tagged = + data->dev_conf.txmode.hw_vlan_reject_tagged; + info.config.reject.untagged = + data->dev_conf.txmode.hw_vlan_reject_untagged; } - vsi->info.port_vlan_flags &= ~(I40E_AQ_VSI_PVLAN_INSERT_PVID | - I40E_AQ_VSI_PVLAN_MODE_MASK); - vsi->info.port_vlan_flags |= vlan_flags; - vsi->info.pvid = pvid; - vsi->info.valid_sections = - rte_cpu_to_le_16(I40E_AQ_VSI_PROP_VLAN_VALID); - (void)rte_memcpy(&ctxt.info, &vsi->info, sizeof(vsi->info)); - ctxt.seid = vsi->seid; - ret = i40e_aq_update_vsi_params(hw, &ctxt, NULL); - if (ret != I40E_SUCCESS) - PMD_DRV_LOG(INFO, "Failed to update VSI params\n"); - return ret; + return i40e_vsi_vlan_pvid_set(vsi, &info); } static int @@ -2039,6 +2015,53 @@ validate_tcmap_parameter(struct i40e_vsi *vsi, uint8_t enabled_tcmap) return I40E_SUCCESS; } +int +i40e_vsi_vlan_pvid_set(struct i40e_vsi *vsi, + struct i40e_vsi_vlan_pvid_info *info) +{ + struct i40e_hw *hw; + struct i40e_vsi_context ctxt; + uint8_t vlan_flags = 0; + int ret; + + if (vsi == NULL || info == NULL) { + PMD_DRV_LOG(ERR, "invalid parameters\n"); + return I40E_ERR_PARAM; + } + + if (info->on) { + vsi->info.pvid = info->config.pvid; + /** + * If insert pvid is enabled, only tagged pkts are + * allowed to be sent out. + */ + vlan_flags |= I40E_AQ_VSI_PVLAN_INSERT_PVID | + I40E_AQ_VSI_PVLAN_MODE_TAGGED; + } else { + vsi->info.pvid = 0; + if (info->config.reject.tagged == 0) + vlan_flags |= I40E_AQ_VSI_PVLAN_MODE_TAGGED; + + if (info->config.reject.untagged == 0) + vlan_flags |= I40E_AQ_VSI_PVLAN_MODE_UNTAGGED; + } + vsi->info.port_vlan_flags &= ~(I40E_AQ_VSI_PVLAN_INSERT_PVID | + I40E_AQ_VSI_PVLAN_MODE_MASK); + vsi->info.port_vlan_flags |= vlan_flags; + vsi->info.valid_sections = + rte_cpu_to_le_16(I40E_AQ_VSI_PROP_VLAN_VALID); + memset(&ctxt, 0, sizeof(ctxt)); + (void)rte_memcpy(&ctxt.info, &vsi->info, sizeof(vsi->info)); + ctxt.seid = vsi->seid; + + hw = I40E_VSI_TO_HW(vsi); + ret = i40e_aq_update_vsi_params(hw, &ctxt, NULL); + if (ret != I40E_SUCCESS) + PMD_DRV_LOG(ERR, "Failed to update VSI params\n"); + + return ret; +} + static int i40e_vsi_update_tc_bandwidth(struct i40e_vsi *vsi, uint8_t enabled_tcmap) { @@ -2574,7 +2597,7 @@ fail_mem: } /* Configure vlan stripping on or off */ -static int +int i40e_vsi_config_vlan_stripping(struct i40e_vsi *vsi, bool on) { struct i40e_hw *hw = I40E_VSI_TO_HW(vsi); @@ -2616,44 +2639,20 @@ i40e_vsi_config_vlan_stripping(struct i40e_vsi *vsi, bool on) } static int -i40e_vsi_init_vlan(struct i40e_vsi *vsi) +i40e_dev_init_vlan(struct rte_eth_dev *dev) { - struct i40e_hw *hw = I40E_VSI_TO_HW(vsi); - struct rte_eth_dev_data *data = I40E_VSI_TO_DEV_DATA(vsi); - struct i40e_vsi_context ctxt; - uint8_t vlan_flags = 0; + struct rte_eth_dev_data *data = dev->data; int ret; - /* Set PVID */ - if (data->dev_conf.txmode.hw_vlan_insert_pvid == 1) { - /** - * If insert pvid is enabled, only tagged pkts are - * allowed to be sent out. - */ - vlan_flags |= I40E_AQ_VSI_PVLAN_INSERT_PVID | - I40E_AQ_VSI_PVLAN_MODE_TAGGED; - } else { - if (data->dev_conf.txmode.hw_vlan_reject_tagged == 0) - vlan_flags |= I40E_AQ_VSI_PVLAN_MODE_TAGGED; - if (data->dev_conf.txmode.hw_vlan_reject_untagged == 0) - vlan_flags |= I40E_AQ_VSI_PVLAN_MODE_UNTAGGED; - } - - /* Strip VLAN tag or not */ - if (data->dev_conf.rxmode.hw_vlan_strip == 0) - vlan_flags |= I40E_AQ_VSI_PVLAN_EMOD_NOTHING; + /* Apply vlan offload setting */ + i40e_vlan_offload_set(dev, ETH_VLAN_STRIP_MASK); - vsi->info.port_vlan_flags &= ~(I40E_AQ_VSI_PVLAN_MODE_MASK | - I40E_AQ_VSI_PVLAN_INSERT_PVID | I40E_AQ_VSI_PVLAN_EMOD_MASK); - vsi->info.port_vlan_flags |= vlan_flags; - vsi->info.pvid = data->dev_conf.txmode.pvid; - vsi->info.valid_sections = - rte_cpu_to_le_16(I40E_AQ_VSI_PROP_VLAN_VALID); + /* Apply double-vlan setting, not implemented yet */ - (void)rte_memcpy(&ctxt.info, &vsi->info, sizeof(vsi->info)); - ctxt.seid = vsi->seid; - ret = i40e_aq_update_vsi_params(hw, &ctxt, NULL); - if (ret != I40E_SUCCESS) + /* Apply pvid setting */ + ret = i40e_vlan_pvid_set(dev, data->dev_conf.txmode.pvid, + data->dev_conf.txmode.hw_vlan_insert_pvid); + if (ret) PMD_DRV_LOG(INFO, "Failed to update VSI params\n"); return ret; diff --git a/lib/librte_pmd_i40e/i40e_ethdev.h b/lib/librte_pmd_i40e/i40e_ethdev.h index e00895d..64deef2 100644 --- a/lib/librte_pmd_i40e/i40e_ethdev.h +++ b/lib/librte_pmd_i40e/i40e_ethdev.h @@ -224,6 +224,20 @@ enum pending_msg { PFMSG_DRIVER_CLOSE = 0x4, }; +struct i40e_vsi_vlan_pvid_info { + uint16_t on; /* Enable or disable pvid */ + union { + uint16_t pvid; /* Valid in case 'on' is set to set pvid */ + struct { + /* Valid in case 'on' is cleared. 'tagged' will reject tagged packets, + * while 'untagged' will reject untagged packets. + */ + uint8_t tagged; + uint8_t untagged; + } reject; + } config; +}; + struct i40e_vf_rx_queues { uint64_t rx_dma_addr; uint32_t rx_ring_len; @@ -295,6 +309,9 @@ int i40e_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete); void i40e_vsi_queues_bind_intr(struct i40e_vsi *vsi); void i40e_vsi_queues_unbind_intr(struct i40e_vsi *vsi); +int i40e_vsi_vlan_pvid_set(struct i40e_vsi *vsi, + struct i40e_vsi_vlan_pvid_info *info); +int i40e_vsi_config_vlan_stripping(struct i40e_vsi *vsi, bool on); /* I40E_DEV_PRIVATE_TO */ #define I40E_DEV_PRIVATE_TO_PF(adapter) \ -- 1.7.7.6