DPDK patches and discussions
 help / color / mirror / Atom feed
From: Helin Zhang <helin.zhang@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 2/2] i40e: add VLAN ether type config
Date: Fri, 22 Jan 2016 09:37:03 +0800	[thread overview]
Message-ID: <1453426623-8696-3-git-send-email-helin.zhang@intel.com> (raw)
In-Reply-To: <1453426623-8696-1-git-send-email-helin.zhang@intel.com>

It adds the setting VLAN ether type of single VLAN, inner and
outer VLAN. Single VLAN is treated as inner VLAN as usual.

Signed-off-by: Helin Zhang <helin.zhang@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c | 55 +++++++++++++++++++++++++++++++++++++++---
 1 file changed, 51 insertions(+), 4 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 56ed28d..d97270d 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -273,6 +273,11 @@
 #define I40E_INSET_IPV6_TC_MASK       0x0009F00FUL
 #define I40E_INSET_IPV6_NEXT_HDR_MASK 0x000C00FFUL
 
+#define I40E_GL_SWT_L2TAGCTRL(_i)             (0x001C0A70 + ((_i) * 4))
+#define I40E_GL_SWT_L2TAGCTRL_ETHERTYPE_SHIFT 16
+#define I40E_GL_SWT_L2TAGCTRL_ETHERTYPE_MASK  \
+	I40E_MASK(0xFFFF, I40E_GL_SWT_L2TAGCTRL_ETHERTYPE_SHIFT)
+
 static int eth_i40e_dev_init(struct rte_eth_dev *eth_dev);
 static int eth_i40e_dev_uninit(struct rte_eth_dev *eth_dev);
 static int i40e_dev_configure(struct rte_eth_dev *dev);
@@ -2321,11 +2326,53 @@ i40e_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
 }
 
 static void
-i40e_vlan_tpid_set(__rte_unused struct rte_eth_dev *dev,
-		   __rte_unused enum rte_vlan_type vlan_type,
-		   __rte_unused uint16_t tpid)
+i40e_vlan_tpid_set(struct rte_eth_dev *dev,
+		   enum rte_vlan_type vlan_type,
+		   uint16_t tpid)
 {
-	PMD_INIT_FUNC_TRACE();
+	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	uint64_t reg_r = 0, reg_w = 0;
+	uint16_t reg_id = 0;
+	int ret;
+
+	switch (vlan_type) {
+	case ETH_VLAN_TYPE_OUTER:
+		reg_id = 2;
+		break;
+	case ETH_VLAN_TYPE_INNER:
+		reg_id = 3;
+		break;
+	default:
+		PMD_DRV_LOG(ERR, "Unsupported vlan type %d", vlan_type);
+		return;
+	}
+
+	ret = i40e_aq_debug_read_register(hw, I40E_GL_SWT_L2TAGCTRL(reg_id),
+					  &reg_r, NULL);
+	if (ret != I40E_SUCCESS) {
+		PMD_DRV_LOG(ERR, "Fail to debug read from "
+			    "I40E_GL_SWT_L2TAGCTRL[%d]", reg_id);
+		return;
+	}
+	PMD_DRV_LOG(DEBUG, "Debug read from I40E_GL_SWT_L2TAGCTRL[%d]: "
+		    "0x%08"PRIx64"", reg_id, reg_r);
+
+	reg_w = reg_r & (~(I40E_GL_SWT_L2TAGCTRL_ETHERTYPE_MASK));
+	reg_w |= ((uint64_t)tpid << I40E_GL_SWT_L2TAGCTRL_ETHERTYPE_SHIFT);
+	if (reg_r == reg_w) {
+		PMD_DRV_LOG(DEBUG, "No need to write");
+		return;
+	}
+
+	ret = i40e_aq_debug_write_register(hw, I40E_GL_SWT_L2TAGCTRL(reg_id),
+					   reg_w, NULL);
+	if (ret != I40E_SUCCESS) {
+		PMD_DRV_LOG(ERR, "Fail to debug write to "
+			    "I40E_GL_SWT_L2TAGCTRL[%d]", reg_id);
+		return;
+	}
+	PMD_DRV_LOG(DEBUG, "Debug write 0x%08"PRIx64" to "
+		    "I40E_GL_SWT_L2TAGCTRL[%d]", reg_w, reg_id);
 }
 
 static void
-- 
2.5.0

  parent reply	other threads:[~2016-01-22  1:37 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-22  1:37 [dpdk-dev] [PATCH 0/2] i40e setting ether type of VLANs Helin Zhang
2016-01-22  1:37 ` [dpdk-dev] [PATCH 1/2] ethdev: add vlan type for setting ether type Helin Zhang
2016-01-22  1:37 ` Helin Zhang [this message]
2016-03-07  8:12 ` [dpdk-dev] [PATCH v2 0/3] i40e setting ether type of VLANs Helin Zhang
2016-03-07  8:12   ` [dpdk-dev] [PATCH v2 1/3] ethdev: add vlan type for setting ether type Helin Zhang
2016-03-07  8:12   ` [dpdk-dev] [PATCH v2 2/3] i40e: add VLAN ether type config Helin Zhang
2016-03-07  8:12   ` [dpdk-dev] [PATCH v2 3/3] i40e: fix the overflow issue Helin Zhang
2016-03-07  9:28   ` [dpdk-dev] [PATCH v2 0/3] i40e setting ether type of VLANs Thomas Monjalon
2016-03-09 15:20     ` Zhang, Helin
2016-03-10 16:36   ` [dpdk-dev] [PATCH v3 0/2] " Helin Zhang
2016-03-10 16:36     ` [dpdk-dev] [PATCH v3 1/2] ethdev: add vlan type for setting ether type Helin Zhang
2016-03-10 16:36     ` [dpdk-dev] [PATCH v3 2/2] i40e: fix the overflow issue Helin Zhang
2016-03-11  2:36     ` [dpdk-dev] [PATCH v3 0/2] i40e setting ether type of VLANs Lu, Wenzhuo
2016-03-11  8:49     ` [dpdk-dev] [PATCH v4 " Helin Zhang
2016-03-11  8:49       ` [dpdk-dev] [PATCH v4 1/2] ethdev: add vlan type for setting ether type Helin Zhang
2016-03-11 11:19         ` Panu Matilainen
2016-03-11 11:20           ` Thomas Monjalon
2016-03-11 14:17             ` Zhang, Helin
2016-03-11 14:20               ` Thomas Monjalon
2016-03-11  8:49       ` [dpdk-dev] [PATCH v4 2/2] i40e: fix the overflow issue Helin Zhang
2016-03-11 16:50       ` [dpdk-dev] [PATCH v5 0/2] i40e setting ether type of VLANs Helin Zhang
2016-03-11 16:50         ` [dpdk-dev] [PATCH v5 1/2] ethdev: add vlan type for setting ether type Helin Zhang
2016-03-11 16:50         ` [dpdk-dev] [PATCH v5 2/2] i40e: fix the overflow issue Helin Zhang
2016-03-11 20:20         ` [dpdk-dev] [PATCH v5 0/2] i40e setting ether type of VLANs 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=1453426623-8696-3-git-send-email-helin.zhang@intel.com \
    --to=helin.zhang@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).