DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Pei, Yulong" <yulong.pei@intel.com>
To: Julien Meunier <julien.meunier@6wind.com>,
	"Zhang, Helin" <helin.zhang@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] i40e: fix vlan filtering
Date: Wed, 20 Jan 2016 03:54:24 +0000	[thread overview]
Message-ID: <188971FCDA171749BED5DA74ABF3E6F00352A52C@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <1453137515-19195-1-git-send-email-julien.meunier@6wind.com>

It works as expected, thanks.

Tested-by Yulong.pei@intel.com

Best Regards
Yulong Pei

-----Original Message-----
From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Julien Meunier
Sent: Tuesday, January 19, 2016 1:19 AM
To: Zhang, Helin <helin.zhang@intel.com>
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] i40e: fix vlan filtering

VLAN filtering was always performed, even if hw_vlan_filter was disabled. During device initialization, default filter RTE_MACVLAN_PERFECT_MATCH was applied. In this situation, all incoming VLAN frames were dropped by the card (increase of the register RUPP - Rx Unsupported Protocol).

In order to restore default behavior, if HW VLAN filtering is activated, set a filter to match MAC and VLAN. If not, set a filter to only match MAC.

Signed-off-by: Julien Meunier <julien.meunier@6wind.com>
Signed-off-by: David Marchand <david.marchand@6wind.com>
---
 drivers/net/i40e/i40e_ethdev.c | 39 ++++++++++++++++++++++++++++++++++++++-
 drivers/net/i40e/i40e_ethdev.h |  1 +
 2 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index bf6220d..ef9d578 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -2332,6 +2332,13 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask)
 	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
 	struct i40e_vsi *vsi = pf->main_vsi;
 
+	if (mask & ETH_VLAN_FILTER_MASK) {
+		if (dev->data->dev_conf.rxmode.hw_vlan_filter)
+			i40e_vsi_config_vlan_filter(vsi, TRUE);
+		else
+			i40e_vsi_config_vlan_filter(vsi, FALSE);
+	}
+
 	if (mask & ETH_VLAN_STRIP_MASK) {
 		/* Enable or disable VLAN stripping */
 		if (dev->data->dev_conf.rxmode.hw_vlan_strip)
@@ -4156,6 +4163,34 @@ fail_mem:
 	return NULL;
 }
 
+/* Configure vlan filter on or off */
+int
+i40e_vsi_config_vlan_filter(struct i40e_vsi *vsi, bool on) {
+	struct i40e_hw *hw = I40E_VSI_TO_HW(vsi);
+	struct i40e_mac_filter_info filter;
+	int ret;
+
+	rte_memcpy(&filter.mac_addr,
+		   (struct ether_addr *)(hw->mac.perm_addr), ETH_ADDR_LEN);
+	ret = i40e_vsi_delete_mac(vsi, &filter.mac_addr);
+
+	if (on) {
+		/* Filter to match MAC and VLAN */
+		filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
+	} else {
+		/* Filter to match only MAC */
+		filter.filter_type = RTE_MAC_PERFECT_MATCH;
+	}
+
+	ret |= i40e_vsi_add_mac(vsi, &filter);
+
+	if (ret)
+		PMD_DRV_LOG(INFO, "Update VSI failed to %s vlan filter",
+			    on ? "enable" : "disable");
+	return ret;
+}
+
 /* Configure vlan stripping on or off */  int  i40e_vsi_config_vlan_stripping(struct i40e_vsi *vsi, bool on) @@ -4203,9 +4238,11 @@ i40e_dev_init_vlan(struct rte_eth_dev *dev)  {
 	struct rte_eth_dev_data *data = dev->data;
 	int ret;
+	int mask = 0;
 
 	/* Apply vlan offload setting */
-	i40e_vlan_offload_set(dev, ETH_VLAN_STRIP_MASK);
+	mask = ETH_VLAN_STRIP_MASK | ETH_VLAN_FILTER_MASK;
+	i40e_vlan_offload_set(dev, mask);
 
 	/* Apply double-vlan setting, not implemented yet */
 
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h index 1f9792b..5505d72 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -551,6 +551,7 @@ 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);
+int i40e_vsi_config_vlan_filter(struct i40e_vsi *vsi, bool on);
 uint64_t i40e_config_hena(uint64_t flags);  uint64_t i40e_parse_hena(uint64_t flags);  enum i40e_status_code i40e_fdir_setup_tx_resources(struct i40e_pf *pf);
--
2.1.4

  parent reply	other threads:[~2016-01-20  3:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-18 17:18 Julien Meunier
2016-01-19  0:39 ` Zhang, Helin
2016-01-20  3:54 ` Pei, Yulong [this message]
2016-01-20  5:00 ` Zhang, Helin
2016-01-20 14:56   ` Julien Meunier
2016-02-02 13:50 ` [dpdk-dev] [PATCH v2] " Julien Meunier
2016-02-03  1:15   ` Zhang, Helin
2016-02-03 11:32     ` Julien Meunier
2016-02-04  0:41       ` Zhang, Helin
2016-02-04  0:53         ` Stephen Hemminger
2016-02-04  8:38         ` Thomas Monjalon
2016-02-04 11:02   ` [dpdk-dev] [PATCH v3] " Julien Meunier
2016-02-05  0:20     ` Zhang, Helin
2016-02-24 17:51       ` Bruce Richardson

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=188971FCDA171749BED5DA74ABF3E6F00352A52C@shsmsx102.ccr.corp.intel.com \
    --to=yulong.pei@intel.com \
    --cc=dev@dpdk.org \
    --cc=helin.zhang@intel.com \
    --cc=julien.meunier@6wind.com \
    /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).