From: "Chen Jing D(Mark)" <jing.d.chen@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 4/6] i40e: make change to vlan_strip and vlan_set_pvid function
Date: Fri, 20 Jun 2014 18:24:42 +0800 [thread overview]
Message-ID: <1403259884-6498-5-git-send-email-jing.d.chen@intel.com> (raw)
In-Reply-To: <1403259884-6498-1-git-send-email-jing.d.chen@intel.com>
From: "Chen Jing D(Mark)" <jing.d.chen@intel.com>
Change original 2 functions to common ones that can take effect on
both VF and PF VSIs.
Signed-off-by: Chen Jing D(Mark) <jing.d.chen@intel.com>
Acked-by: Helin Zhang <helin.zhang@intel.com>
Acked-by: Cunming Liang <cunming.liang@intel.com>
Acked-by: Jingjing Wu <jingjing.wu@intel.com>
---
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
next prev parent reply other threads:[~2014-06-20 10:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-20 10:24 [dpdk-dev] [PATCH 0/6] Support i40e VF vlan offload and pvid config Chen Jing D(Mark)
2014-06-20 10:24 ` [dpdk-dev] [PATCH 1/6] i40e: destroy MSIX pool when device is closed Chen Jing D(Mark)
2014-06-20 10:24 ` [dpdk-dev] [PATCH 2/6] i40e: Add permenant mac address into mac list Chen Jing D(Mark)
2014-06-20 10:24 ` [dpdk-dev] [PATCH 3/6] i40e: Add sanity check in pf host driver Chen Jing D(Mark)
2014-06-20 10:24 ` Chen Jing D(Mark) [this message]
2014-06-20 10:24 ` [dpdk-dev] [PATCH 5/6] i40e: PF host driver to support VF vlan offload and set pvid Chen Jing D(Mark)
2014-06-20 10:24 ` [dpdk-dev] [PATCH 6/6] i40e: VF to support VLAN strip and pvid set/clear Chen Jing D(Mark)
2014-06-20 13:51 ` [dpdk-dev] [PATCH 0/6] Support i40e VF vlan offload and pvid config Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1403259884-6498-5-git-send-email-jing.d.chen@intel.com \
--to=jing.d.chen@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).