[v2] net/i40e: solve vf vlan strip

Message ID 20210830020945.2715-1-chenqiming_huawei@163.com (mailing list archive)
State Superseded, archived
Delegated to: Qi Zhang
Headers
Series [v2] net/i40e: solve vf vlan strip |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot: build success github build: passed
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-unit-testing fail Testing issues
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/intel-Testing fail Testing issues
ci/iol-aarch64-compile-testing success Testing PASS

Commit Message

Qiming Chen Aug. 30, 2021, 2:09 a.m. UTC
  Kernel PF+DPDK VF mode, after vf adds vlan, the test result shows that the
vlan received from vf has been stripped.

The patch solves the problem that the kernel i40e.ko driver strips the vlan
by default after vf adds vlan. Determine whether to strip vlan through
the DEV_RX_OFFLOAD_VLAN_STRIP mask bit in rxmode.offload.

Environmental information:
1) dpdk 19.11
2) Kernel PF i40e.ko: 2.7.12
3) Firmware: 6.01 0x800034a3 1.1747.0

I did not use testpmd to test vlan filter, but write Demo for testing
based on the following deployment:
1) x710 nic, use 2 PFs, each PF virtualizes 1 VF
2) 2 pf connected with fiber optic cable
3) 2 vf are hard to pass through to the VM
4) In vm, dpdk takes over the vf port,
5) One port is used as the sending port, and the other port is used as
the receiving port, e.g. xmit portid is 0, rx portid is 1

Use the default configuration for port 0 as the sender, and configure
port 1 as the receiving port as follows:
1) rte_eth_dev_set_vlan_offload(1, ETH_VLAN_FILTER_OFFLOAD)
2) rte_eth_dev_vlan_filter(1, 100, 1)

Do the following tests:
Demo constructs a message with vlan 100 to be sent from port 0, and found
that the vlan header of the message received from port 1 was stripped.

Signed-off-by: Qiming Chen <chenqiming_huawei@163.com>
---
v2:
  Clear coding style quesion.
---
 drivers/net/i40e/i40e_ethdev_vf.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
  

Comments

Xing, Beilei Aug. 30, 2021, 5:23 a.m. UTC | #1
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Qiming Chen
> Sent: Monday, August 30, 2021 10:10 AM
> To: dev@dpdk.org
> Cc: Xing, Beilei <beilei.xing@intel.com>; Qiming Chen
> <chenqiming_huawei@163.com>
> Subject: [dpdk-dev] [PATCH v2] net/i40e: solve vf vlan strip
> 
> Kernel PF+DPDK VF mode, after vf adds vlan, the test result shows that the
> vlan received from vf has been stripped.
> 
> The patch solves the problem that the kernel i40e.ko driver strips the vlan by
> default after vf adds vlan. Determine whether to strip vlan through the
> DEV_RX_OFFLOAD_VLAN_STRIP mask bit in rxmode.offload.
> 
> Environmental information:
> 1) dpdk 19.11
> 2) Kernel PF i40e.ko: 2.7.12
> 3) Firmware: 6.01 0x800034a3 1.1747.0

Thanks for the patch.
As Qi mentioned, i40evf will be deprecated. So please don't submit the patch to master repo, but submit to LTS.
Thanks.

> 
> I did not use testpmd to test vlan filter, but write Demo for testing based on
> the following deployment:
> 1) x710 nic, use 2 PFs, each PF virtualizes 1 VF
> 2) 2 pf connected with fiber optic cable
> 3) 2 vf are hard to pass through to the VM
> 4) In vm, dpdk takes over the vf port,
> 5) One port is used as the sending port, and the other port is used as the
> receiving port, e.g. xmit portid is 0, rx portid is 1
> 
> Use the default configuration for port 0 as the sender, and configure port 1
> as the receiving port as follows:
> 1) rte_eth_dev_set_vlan_offload(1, ETH_VLAN_FILTER_OFFLOAD)
> 2) rte_eth_dev_vlan_filter(1, 100, 1)
> 
> Do the following tests:
> Demo constructs a message with vlan 100 to be sent from port 0, and found
> that the vlan header of the message received from port 1 was stripped.
> 
> Signed-off-by: Qiming Chen <chenqiming_huawei@163.com>
> ---
> v2:
>   Clear coding style quesion.
> ---
>  drivers/net/i40e/i40e_ethdev_vf.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/i40e/i40e_ethdev_vf.c
> b/drivers/net/i40e/i40e_ethdev_vf.c
> index 625981048a..267e7be0c6 100644
> --- a/drivers/net/i40e/i40e_ethdev_vf.c
> +++ b/drivers/net/i40e/i40e_ethdev_vf.c
> @@ -1852,11 +1852,15 @@ static int
>  i40evf_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)  {
>  	int ret;
> +	struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
> 
> -	if (on)
> +	if (on) {
>  		ret = i40evf_add_vlan(dev, vlan_id);
> -	else
> +		if (!(dev_conf->rxmode.offloads &
> DEV_RX_OFFLOAD_VLAN_STRIP))
> +			i40evf_disable_vlan_strip(dev);
> +	} else {
>  		ret = i40evf_del_vlan(dev,vlan_id);
> +	}
> 
>  	return ret;
>  }
> --
> 2.30.1.windows.1
  
Qiming Chen Aug. 31, 2021, 4:12 a.m. UTC | #2
ok,Has been resubmitted to LTS


https://inbox.dpdk.org/stable/20210831035207.5590-1-chenqiming_huawei@163.com/T/#u


| |
Qiming Chen
|
|
chenqiming_huawei@163.com
|
签名由网易邮箱大师定制
On 8/30/2021 13:23,Xing, Beilei<beilei.xing@intel.com> wrote:


-----Original Message-----
From: dev <dev-bounces@dpdk.org> On Behalf Of Qiming Chen
Sent: Monday, August 30, 2021 10:10 AM
To: dev@dpdk.org
Cc: Xing, Beilei <beilei.xing@intel.com>; Qiming Chen
<chenqiming_huawei@163.com>
Subject: [dpdk-dev] [PATCH v2] net/i40e: solve vf vlan strip

Kernel PF+DPDK VF mode, after vf adds vlan, the test result shows that the
vlan received from vf has been stripped.

The patch solves the problem that the kernel i40e.ko driver strips the vlan by
default after vf adds vlan. Determine whether to strip vlan through the
DEV_RX_OFFLOAD_VLAN_STRIP mask bit in rxmode.offload.

Environmental information:
1) dpdk 19.11
2) Kernel PF i40e.ko: 2.7.12
3) Firmware: 6.01 0x800034a3 1.1747.0

Thanks for the patch.
As Qi mentioned, i40evf will be deprecated. So please don't submit the patch to master repo, but submit to LTS.
Thanks.


I did not use testpmd to test vlan filter, but write Demo for testing based on
the following deployment:
1) x710 nic, use 2 PFs, each PF virtualizes 1 VF
2) 2 pf connected with fiber optic cable
3) 2 vf are hard to pass through to the VM
4) In vm, dpdk takes over the vf port,
5) One port is used as the sending port, and the other port is used as the
receiving port, e.g. xmit portid is 0, rx portid is 1

Use the default configuration for port 0 as the sender, and configure port 1
as the receiving port as follows:
1) rte_eth_dev_set_vlan_offload(1, ETH_VLAN_FILTER_OFFLOAD)
2) rte_eth_dev_vlan_filter(1, 100, 1)

Do the following tests:
Demo constructs a message with vlan 100 to be sent from port 0, and found
that the vlan header of the message received from port 1 was stripped.

Signed-off-by: Qiming Chen <chenqiming_huawei@163.com>
---
v2:
Clear coding style quesion.
---
drivers/net/i40e/i40e_ethdev_vf.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev_vf.c
b/drivers/net/i40e/i40e_ethdev_vf.c
index 625981048a..267e7be0c6 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -1852,11 +1852,15 @@ static int
i40evf_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)  {
int ret;
+  struct rte_eth_conf *dev_conf = &dev->data->dev_conf;

-  if (on)
+  if (on) {
ret = i40evf_add_vlan(dev, vlan_id);
-  else
+    if (!(dev_conf->rxmode.offloads &
DEV_RX_OFFLOAD_VLAN_STRIP))
+      i40evf_disable_vlan_strip(dev);
+  } else {
ret = i40evf_del_vlan(dev,vlan_id);
+  }

return ret;
}
--
2.30.1.windows.1
  

Patch

diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 625981048a..267e7be0c6 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -1852,11 +1852,15 @@  static int
 i40evf_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
 {
 	int ret;
+	struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
 
-	if (on)
+	if (on) {
 		ret = i40evf_add_vlan(dev, vlan_id);
-	else
+		if (!(dev_conf->rxmode.offloads & DEV_RX_OFFLOAD_VLAN_STRIP))
+			i40evf_disable_vlan_strip(dev);
+	} else {
 		ret = i40evf_del_vlan(dev,vlan_id);
+	}
 
 	return ret;
 }