All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i40e: fix vlan filter in promiscuous mode
@ 2016-05-27  8:05 Jingjing Wu
  2016-05-30  2:41 ` Peng, Yuan
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Jingjing Wu @ 2016-05-27  8:05 UTC (permalink / raw)
  To: helin.zhang; +Cc: dev, jingjing.wu, yulong.pei

Vlan filter didn't work if promiscuous mode is enabled. That is
because i40e driver uses MAC VLAN table for the l2 filtering and
internal switch. And the vlan table is disabled by default, till
the first time to add rule in vlan table.
This patch fixed this issue to enable vlan filter by using vlan table.

Fixes: 4861cde46116 (i40e: new poll mode driver)
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 24777d5..0d91e29 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -2443,12 +2443,16 @@ 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;
+	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
 	if (mask & ETH_VLAN_FILTER_MASK) {
-		if (dev->data->dev_conf.rxmode.hw_vlan_filter)
+		if (dev->data->dev_conf.rxmode.hw_vlan_filter) {
+			i40e_aq_set_vsi_vlan_promisc(hw, vsi->seid, false, NULL);
 			i40e_vsi_config_vlan_filter(vsi, TRUE);
-		else
+		} else {
+			i40e_aq_set_vsi_vlan_promisc(hw, vsi->seid, true, NULL);
 			i40e_vsi_config_vlan_filter(vsi, FALSE);
+		}
 	}
 
 	if (mask & ETH_VLAN_STRIP_MASK) {
@@ -5419,17 +5423,28 @@ i40e_set_vlan_filter(struct i40e_vsi *vsi,
 			 uint16_t vlan_id, bool on)
 {
 	uint32_t vid_idx, vid_bit;
+	struct i40e_hw *hw = I40E_VSI_TO_HW(vsi);
+	struct i40e_aqc_add_remove_vlan_element_data vlan_data = {0};
+	int ret;
 
 	if (vlan_id > ETH_VLAN_ID_MAX)
 		return;
 
 	vid_idx = I40E_VFTA_IDX(vlan_id);
 	vid_bit = I40E_VFTA_BIT(vlan_id);
+	vlan_data.vlan_tag = rte_cpu_to_le_16(vlan_id);
 
-	if (on)
+	if (on) {
+		ret = i40e_aq_add_vlan(hw, vsi->seid, &vlan_data, 1, NULL);
+		if (ret != I40E_SUCCESS)
+			PMD_DRV_LOG(ERR, "Failed to add vlan filter");
 		vsi->vfta[vid_idx] |= vid_bit;
-	else
+	} else {
+		ret = i40e_aq_remove_vlan(hw, vsi->seid, &vlan_data, 1, NULL);
+		if (ret != I40E_SUCCESS)
+			PMD_DRV_LOG(ERR, "Failed to remove vlan filter");
 		vsi->vfta[vid_idx] &= ~vid_bit;
+	}
 }
 
 /**
-- 
2.4.0

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] i40e: fix vlan filter in promiscuous mode
  2016-05-27  8:05 [PATCH] i40e: fix vlan filter in promiscuous mode Jingjing Wu
@ 2016-05-30  2:41 ` Peng, Yuan
  2016-06-13 10:51 ` Bruce Richardson
  2016-06-14  2:24 ` [PATCH v2] i40e: fix VLAN " Jingjing Wu
  2 siblings, 0 replies; 7+ messages in thread
From: Peng, Yuan @ 2016-05-30  2:41 UTC (permalink / raw)
  To: Wu, Jingjing, Zhang, Helin; +Cc: dev, Wu, Jingjing, Pei, Yulong

Tested-by: Peng Yuan <yuan.peng@intel.com>



- Test Commit: a3f9ec846f9e7347d3a98da52256607345b4861d

- OS/Kernel: Fedora 23/4.2.3

- GCC: gcc version 5.3.1 20151207 (Red Hat 5.3.1-2) (GCC)

- CPU: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz

- Total 7 cases, 7 passed, 0 failed.



pf

vf(pf_kerneldriver)


mac_filter

vlan_filter

mac+vlan_filter

mac_filter

vlan_filter

mac+vlan_filter

promisc off

PASS(dts case)

PASS

PASS

PASS(dts case)

PASS(dts case)

PASS

promisc on

N/A

PASS(dts case)

N/A

N/A

N/A

N/A






All the test cases I verified covers 7 scenarios as below table.



The issue happened in vlan_filter/promisc on, so I just describe the test steps in this scenario.



Test_vlan_enable_receipt



1.       Fortpark i40e driver,  . /dpdk_nic_bind.py --bind=igb_uio 0000:8a:00.1 0000:8a:00.3

2.       ./x86_64-native-linuxapp-gcc/app/testpmd -c 0x6 -n 4  -- -i --portmask=0x1 --port-topology=loop --txqflags=0

3.       Testpmd> set verbose 1

Testpmd> set fwd mac

Testpmd> vlan set filter on 0

Testpmd> vlan set strip off 0

Testpmd> rx_vlan add 51 0

Testpmd>start

4.       Tester:

sendp([Ether(dst="00:00:00:00:03:15")/Dot1Q(vlan=51)/IP()/UDP()],iface="enp138s0f0", count=1)

5.       DUT can receive the packet, and check the vlan ID is correct.

6.       Send packet with vlan0 and the packet can be received,
send packet without vlan and the packet can be received.

Send packet with wrong vlan(52/4095) and packet can't be receive.



Test_ vlan_disable_receipt



1.       Testpmd>rx_vlan rm 51 0

Testpmd>start

2.       Tester:

sendp([Ether(dst="00:00:00:00:03:15")/Dot1Q(vlan=51)/IP()/UDP()],iface="enp138s0f0", count=1)

3.       DUT can not receive the packet.



The vlan filter works normally.



Thanks

Yuan.





-----Original Message-----
From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jingjing Wu
Sent: Friday, May 27, 2016 4:06 PM
To: Zhang, Helin <helin.zhang@intel.com>
Cc: dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>; Pei, Yulong <yulong.pei@intel.com>
Subject: [dpdk-dev] [PATCH] i40e: fix vlan filter in promiscuous mode



Vlan filter didn't work if promiscuous mode is enabled. That is because i40e driver uses MAC VLAN table for the l2 filtering and internal switch. And the vlan table is disabled by default, till the first time to add rule in vlan table.

This patch fixed this issue to enable vlan filter by using vlan table.



Fixes: 4861cde46116 (i40e: new poll mode driver)

Signed-off-by: Jingjing Wu <jingjing.wu@intel.com<mailto:jingjing.wu@intel.com>>

---

drivers/net/i40e/i40e_ethdev.c | 23 +++++++++++++++++++----

1 file changed, 19 insertions(+), 4 deletions(-)



diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 24777d5..0d91e29 100644

--- a/drivers/net/i40e/i40e_ethdev.c

+++ b/drivers/net/i40e/i40e_ethdev.c

@@ -2443,12 +2443,16 @@ 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;

+       struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);

        if (mask & ETH_VLAN_FILTER_MASK) {

-                 if (dev->data->dev_conf.rxmode.hw_vlan_filter)

+                if (dev->data->dev_conf.rxmode.hw_vlan_filter) {

+                          i40e_aq_set_vsi_vlan_promisc(hw, vsi->seid, false, NULL);

                          i40e_vsi_config_vlan_filter(vsi, TRUE);

-                 else

+                } else {

+                          i40e_aq_set_vsi_vlan_promisc(hw, vsi->seid, true, NULL);

                          i40e_vsi_config_vlan_filter(vsi, FALSE);

+                }

       }

        if (mask & ETH_VLAN_STRIP_MASK) {

@@ -5419,17 +5423,28 @@ i40e_set_vlan_filter(struct i40e_vsi *vsi,

                           uint16_t vlan_id, bool on)

{

       uint32_t vid_idx, vid_bit;

+       struct i40e_hw *hw = I40E_VSI_TO_HW(vsi);

+       struct i40e_aqc_add_remove_vlan_element_data vlan_data = {0};

+       int ret;

        if (vlan_id > ETH_VLAN_ID_MAX)

                return;

        vid_idx = I40E_VFTA_IDX(vlan_id);

       vid_bit = I40E_VFTA_BIT(vlan_id);

+       vlan_data.vlan_tag = rte_cpu_to_le_16(vlan_id);

-        if (on)

+       if (on) {

+                ret = i40e_aq_add_vlan(hw, vsi->seid, &vlan_data, 1, NULL);

+                if (ret != I40E_SUCCESS)

+                          PMD_DRV_LOG(ERR, "Failed to add vlan filter");

                vsi->vfta[vid_idx] |= vid_bit;

-        else

+       } else {

+                ret = i40e_aq_remove_vlan(hw, vsi->seid, &vlan_data, 1, NULL);

+                if (ret != I40E_SUCCESS)

+                          PMD_DRV_LOG(ERR, "Failed to remove vlan filter");

                vsi->vfta[vid_idx] &= ~vid_bit;

+       }

}

 /**

--

2.4.0

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] i40e: fix vlan filter in promiscuous mode
  2016-05-27  8:05 [PATCH] i40e: fix vlan filter in promiscuous mode Jingjing Wu
  2016-05-30  2:41 ` Peng, Yuan
@ 2016-06-13 10:51 ` Bruce Richardson
  2016-06-14  2:24 ` [PATCH v2] i40e: fix VLAN " Jingjing Wu
  2 siblings, 0 replies; 7+ messages in thread
From: Bruce Richardson @ 2016-06-13 10:51 UTC (permalink / raw)
  To: Jingjing Wu; +Cc: helin.zhang, dev, yulong.pei

On Fri, May 27, 2016 at 04:05:45PM +0800, Jingjing Wu wrote:
> Vlan filter didn't work if promiscuous mode is enabled. That is
> because i40e driver uses MAC VLAN table for the l2 filtering and
> internal switch. And the vlan table is disabled by default, till
> the first time to add rule in vlan table.
> This patch fixed this issue to enable vlan filter by using vlan table.
> 
> Fixes: 4861cde46116 (i40e: new poll mode driver)
> Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
> ---
Hi Jingjing,

can you please clarify this commit message a little to give a little more detail
on how the current setup stops the feature from working, and how the fix
removes the problem.

Thanks,
/Bruce

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2] i40e: fix VLAN filter in promiscuous mode
  2016-05-27  8:05 [PATCH] i40e: fix vlan filter in promiscuous mode Jingjing Wu
  2016-05-30  2:41 ` Peng, Yuan
  2016-06-13 10:51 ` Bruce Richardson
@ 2016-06-14  2:24 ` Jingjing Wu
  2016-06-30  1:25   ` [PATCH v3] " Jingjing Wu
  2 siblings, 1 reply; 7+ messages in thread
From: Jingjing Wu @ 2016-06-14  2:24 UTC (permalink / raw)
  To: bruce.richardson; +Cc: dev, jingjing.wu, yuan.peng, helin.zhang

VLAN filter didn't work if promiscuous mode is enabled. That is
because i40e driver uses MAC VLAN table for the l2 filtering and
internal switch. And the VLAN table is disabled by default. So in
promiscuous mode, the VSI can receive packets if they don't match
any entry in MAC VLAN table, even their VLAN tags are unknown.

According to l2 filtering and VEB Switching algorithm on X710/XL710,
VLAN table can be used to filtering VLAN by:
 - Clear promiscuous VLAN flag on VSI.
 - Program VLAN table to enable it.

This patch adds the promiscuous VLAN flag setting/clearing and
VLAN programming when VLAN filtering is added/removed without any
change on MAC VLAN table.

Fixes: 4861cde46116 ("i40e: new poll mode driver")
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
v2 change:
 - commit log reword.

 drivers/net/i40e/i40e_ethdev.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 24777d5..0d91e29 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -2443,12 +2443,16 @@ 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;
+	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
 	if (mask & ETH_VLAN_FILTER_MASK) {
-		if (dev->data->dev_conf.rxmode.hw_vlan_filter)
+		if (dev->data->dev_conf.rxmode.hw_vlan_filter) {
+			i40e_aq_set_vsi_vlan_promisc(hw, vsi->seid, false, NULL);
 			i40e_vsi_config_vlan_filter(vsi, TRUE);
-		else
+		} else {
+			i40e_aq_set_vsi_vlan_promisc(hw, vsi->seid, true, NULL);
 			i40e_vsi_config_vlan_filter(vsi, FALSE);
+		}
 	}
 
 	if (mask & ETH_VLAN_STRIP_MASK) {
@@ -5419,17 +5423,28 @@ i40e_set_vlan_filter(struct i40e_vsi *vsi,
 			 uint16_t vlan_id, bool on)
 {
 	uint32_t vid_idx, vid_bit;
+	struct i40e_hw *hw = I40E_VSI_TO_HW(vsi);
+	struct i40e_aqc_add_remove_vlan_element_data vlan_data = {0};
+	int ret;
 
 	if (vlan_id > ETH_VLAN_ID_MAX)
 		return;
 
 	vid_idx = I40E_VFTA_IDX(vlan_id);
 	vid_bit = I40E_VFTA_BIT(vlan_id);
+	vlan_data.vlan_tag = rte_cpu_to_le_16(vlan_id);
 
-	if (on)
+	if (on) {
+		ret = i40e_aq_add_vlan(hw, vsi->seid, &vlan_data, 1, NULL);
+		if (ret != I40E_SUCCESS)
+			PMD_DRV_LOG(ERR, "Failed to add vlan filter");
 		vsi->vfta[vid_idx] |= vid_bit;
-	else
+	} else {
+		ret = i40e_aq_remove_vlan(hw, vsi->seid, &vlan_data, 1, NULL);
+		if (ret != I40E_SUCCESS)
+			PMD_DRV_LOG(ERR, "Failed to remove vlan filter");
 		vsi->vfta[vid_idx] &= ~vid_bit;
+	}
 }
 
 /**
-- 
2.4.0

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v3] i40e: fix VLAN filter in promiscuous mode
  2016-06-14  2:24 ` [PATCH v2] i40e: fix VLAN " Jingjing Wu
@ 2016-06-30  1:25   ` Jingjing Wu
  2016-07-04  6:33     ` Zhang, Helin
  0 siblings, 1 reply; 7+ messages in thread
From: Jingjing Wu @ 2016-06-30  1:25 UTC (permalink / raw)
  To: helin.zhang; +Cc: dev, jingjing.wu, ferruh.yigit

For VLAN filtering VLAN table should be enabled.
But VLAN table is disabled by default until a rule added. In
promiscuous mode no rule is added to enable the VLAN table.

So this patch clears promiscuous VLAN flag on VSI, and adds a
rule to enable VLAN table to fix VLAN filtering in promiscuous
mode.

Fixes: 4861cde46116 ("i40e: new poll mode driver")
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
v2
 * commit log rework.
v3
 * commit log rework.

 drivers/net/i40e/i40e_ethdev.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index c07da1b..7ddd93a 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -2709,12 +2709,16 @@ 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;
+	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
 	if (mask & ETH_VLAN_FILTER_MASK) {
-		if (dev->data->dev_conf.rxmode.hw_vlan_filter)
+		if (dev->data->dev_conf.rxmode.hw_vlan_filter) {
+			i40e_aq_set_vsi_vlan_promisc(hw, vsi->seid, false, NULL);
 			i40e_vsi_config_vlan_filter(vsi, TRUE);
-		else
+		} else {
+			i40e_aq_set_vsi_vlan_promisc(hw, vsi->seid, true, NULL);
 			i40e_vsi_config_vlan_filter(vsi, FALSE);
+		}
 	}
 
 	if (mask & ETH_VLAN_STRIP_MASK) {
@@ -5760,17 +5764,28 @@ i40e_set_vlan_filter(struct i40e_vsi *vsi,
 			 uint16_t vlan_id, bool on)
 {
 	uint32_t vid_idx, vid_bit;
+	struct i40e_hw *hw = I40E_VSI_TO_HW(vsi);
+	struct i40e_aqc_add_remove_vlan_element_data vlan_data = {0};
+	int ret;
 
 	if (vlan_id > ETH_VLAN_ID_MAX)
 		return;
 
 	vid_idx = I40E_VFTA_IDX(vlan_id);
 	vid_bit = I40E_VFTA_BIT(vlan_id);
+	vlan_data.vlan_tag = rte_cpu_to_le_16(vlan_id);
 
-	if (on)
+	if (on) {
+		ret = i40e_aq_add_vlan(hw, vsi->seid, &vlan_data, 1, NULL);
+		if (ret != I40E_SUCCESS)
+			PMD_DRV_LOG(ERR, "Failed to add vlan filter");
 		vsi->vfta[vid_idx] |= vid_bit;
-	else
+	} else {
+		ret = i40e_aq_remove_vlan(hw, vsi->seid, &vlan_data, 1, NULL);
+		if (ret != I40E_SUCCESS)
+			PMD_DRV_LOG(ERR, "Failed to remove vlan filter");
 		vsi->vfta[vid_idx] &= ~vid_bit;
+	}
 }
 
 /**
-- 
2.4.0

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v3] i40e: fix VLAN filter in promiscuous mode
  2016-06-30  1:25   ` [PATCH v3] " Jingjing Wu
@ 2016-07-04  6:33     ` Zhang, Helin
  2016-07-04 13:45       ` Bruce Richardson
  0 siblings, 1 reply; 7+ messages in thread
From: Zhang, Helin @ 2016-07-04  6:33 UTC (permalink / raw)
  To: Wu, Jingjing; +Cc: dev, Yigit, Ferruh



> -----Original Message-----
> From: Wu, Jingjing
> Sent: Thursday, June 30, 2016 9:26 AM
> To: Zhang, Helin
> Cc: dev@dpdk.org; Wu, Jingjing; Yigit, Ferruh
> Subject: [PATCH v3] i40e: fix VLAN filter in promiscuous mode
> 
> For VLAN filtering VLAN table should be enabled.
> But VLAN table is disabled by default until a rule added. In promiscuous mode
> no rule is added to enable the VLAN table.
> 
> So this patch clears promiscuous VLAN flag on VSI, and adds a rule to enable
> VLAN table to fix VLAN filtering in promiscuous mode.
> 
> Fixes: 4861cde46116 ("i40e: new poll mode driver")
> Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
Acked-by: Helin Zhang <helin.zhang@intel.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3] i40e: fix VLAN filter in promiscuous mode
  2016-07-04  6:33     ` Zhang, Helin
@ 2016-07-04 13:45       ` Bruce Richardson
  0 siblings, 0 replies; 7+ messages in thread
From: Bruce Richardson @ 2016-07-04 13:45 UTC (permalink / raw)
  To: Zhang, Helin; +Cc: Wu, Jingjing, dev, Yigit, Ferruh

On Mon, Jul 04, 2016 at 06:33:30AM +0000, Zhang, Helin wrote:
> 
> 
> > -----Original Message-----
> > From: Wu, Jingjing
> > Sent: Thursday, June 30, 2016 9:26 AM
> > To: Zhang, Helin
> > Cc: dev@dpdk.org; Wu, Jingjing; Yigit, Ferruh
> > Subject: [PATCH v3] i40e: fix VLAN filter in promiscuous mode
> > 
> > For VLAN filtering VLAN table should be enabled.
> > But VLAN table is disabled by default until a rule added. In promiscuous mode
> > no rule is added to enable the VLAN table.
> > 
> > So this patch clears promiscuous VLAN flag on VSI, and adds a rule to enable
> > VLAN table to fix VLAN filtering in promiscuous mode.
> > 
> > Fixes: 4861cde46116 ("i40e: new poll mode driver")
> > Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
> Acked-by: Helin Zhang <helin.zhang@intel.com>

Applied to dpdk-next-net/rel_16_07

/Bruce

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-07-04 13:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-27  8:05 [PATCH] i40e: fix vlan filter in promiscuous mode Jingjing Wu
2016-05-30  2:41 ` Peng, Yuan
2016-06-13 10:51 ` Bruce Richardson
2016-06-14  2:24 ` [PATCH v2] i40e: fix VLAN " Jingjing Wu
2016-06-30  1:25   ` [PATCH v3] " Jingjing Wu
2016-07-04  6:33     ` Zhang, Helin
2016-07-04 13:45       ` Bruce Richardson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.