net/ice: fix vlan stripping in double VLAN mode

Message ID 20240327184413.3192526-1-vladimir.medvedkin@intel.com (mailing list archive)
State Accepted
Delegated to: Bruce Richardson
Headers
Series net/ice: fix vlan stripping in double VLAN mode |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-sample-apps-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS

Commit Message

Vladimir Medvedkin March 27, 2024, 6:44 p.m. UTC
  The ICE hardware can operate in two modes - single vlan mode
or double vlan mode. Depending on the operating mode the hardware
handles vlan header with single vlan tag differently.
When double vlan enabled, a packet with a single VLAN is treated
as a packet with outer VLAN only. Otherwise, a single VLAN in a
packet is treated as inner VLAN.

This patch fixes the logic of how vlan stripping is programmed.

Bugzilla ID: 1402

Fixes: de5da9d16430 ("net/ice: support double VLAN")
Cc: mingjinx.ye@intel.com
Cc: stable@dpdk.org

Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
---
 drivers/net/ice/ice_ethdev.c | 45 +++++++++++++++++++++++++-----------
 1 file changed, 32 insertions(+), 13 deletions(-)
  

Comments

David Marchand March 28, 2024, 11:16 a.m. UTC | #1
On Wed, Mar 27, 2024 at 7:44 PM Vladimir Medvedkin
<vladimir.medvedkin@intel.com> wrote:
>
> The ICE hardware can operate in two modes - single vlan mode
> or double vlan mode. Depending on the operating mode the hardware
> handles vlan header with single vlan tag differently.
> When double vlan enabled, a packet with a single VLAN is treated
> as a packet with outer VLAN only. Otherwise, a single VLAN in a
> packet is treated as inner VLAN.
>
> This patch fixes the logic of how vlan stripping is programmed.
>
> Bugzilla ID: 1402

Nit: no need for an empty line here, the Bugzilla ID: tag goes with
the Fixes: and Cc: block.

>
> Fixes: de5da9d16430 ("net/ice: support double VLAN")
> Cc: mingjinx.ye@intel.com
> Cc: stable@dpdk.org
>
> Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>

Thanks Vladimir.
It looks to fix the issue I observed.
I'll let Carlos confirm the fix is good for him too.
  
Carlos de Souza Moraes Neto April 3, 2024, 2:03 p.m. UTC | #2
Hi David,

I verified using testpmd and my application and worked fine.
Thank you for your help,

Sincerely
Carlos Moraes.

-----Mensagem original-----
De: David Marchand <david.marchand@redhat.com> 
Enviada em: quinta-feira, 28 de março de 2024 08:16
Para: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
Cc: dev@dpdk.org; Carlos de Souza Moraes Neto <carlosmn@weg.net>; mingjinx.ye@intel.com; stable@dpdk.org
Assunto: Re: [PATCH] net/ice: fix vlan stripping in double VLAN mode

ATENÇÃO:  Esta mensagem é de REMETENTE EXTERNO - Tenha cuidado ao abrir links e anexos.
*** NOVO *** NÃO digite sua SENHA WEG quando solicitada por E-MAIL EXTERNO


On Wed, Mar 27, 2024 at 7:44 PM Vladimir Medvedkin <vladimir.medvedkin@intel.com> wrote:
>
> The ICE hardware can operate in two modes - single vlan mode or double 
> vlan mode. Depending on the operating mode the hardware handles vlan 
> header with single vlan tag differently.
> When double vlan enabled, a packet with a single VLAN is treated as a 
> packet with outer VLAN only. Otherwise, a single VLAN in a packet is 
> treated as inner VLAN.
>
> This patch fixes the logic of how vlan stripping is programmed.
>
> Bugzilla ID: 1402

Nit: no need for an empty line here, the Bugzilla ID: tag goes with the Fixes: and Cc: block.

>
> Fixes: de5da9d16430 ("net/ice: support double VLAN")
> Cc: mingjinx.ye@intel.com
> Cc: stable@dpdk.org
>
> Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>

Thanks Vladimir.
It looks to fix the issue I observed.
I'll let Carlos confirm the fix is good for him too.


--
David Marchand
  
Bruce Richardson April 4, 2024, 10:43 a.m. UTC | #3
On Wed, Mar 27, 2024 at 06:44:13PM +0000, Vladimir Medvedkin wrote:
> The ICE hardware can operate in two modes - single vlan mode
> or double vlan mode. Depending on the operating mode the hardware
> handles vlan header with single vlan tag differently.
> When double vlan enabled, a packet with a single VLAN is treated
> as a packet with outer VLAN only. Otherwise, a single VLAN in a
> packet is treated as inner VLAN.
> 
> This patch fixes the logic of how vlan stripping is programmed.
> 
> Bugzilla ID: 1402
> 
> Fixes: de5da9d16430 ("net/ice: support double VLAN")
> Cc: mingjinx.ye@intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
> ---
Acked-by: Bruce Richardson <bruce.richardson@intel.com>

Patch applied to dpdk-next-net-intel.
Thanks,
/Bruce
  

Patch

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 87385d2649..205c5f5f43 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -3826,7 +3826,10 @@  ice_dev_start(struct rte_eth_dev *dev)
 	ice_set_tx_function(dev);
 
 	mask = RTE_ETH_VLAN_STRIP_MASK | RTE_ETH_VLAN_FILTER_MASK |
-			RTE_ETH_VLAN_EXTEND_MASK | RTE_ETH_QINQ_STRIP_MASK;
+			RTE_ETH_VLAN_EXTEND_MASK;
+	if (ice_is_dvm_ena(hw))
+		mask |= RTE_ETH_QINQ_STRIP_MASK;
+
 	ret = ice_vlan_offload_set(dev, mask);
 	if (ret) {
 		PMD_INIT_LOG(ERR, "Unable to set VLAN offload");
@@ -4896,19 +4899,35 @@  ice_vlan_offload_set(struct rte_eth_dev *dev, int mask)
 			ice_vsi_config_vlan_filter(vsi, false);
 	}
 
-	if (mask & RTE_ETH_VLAN_STRIP_MASK) {
-		if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP)
-			ice_vsi_config_vlan_stripping(vsi, true);
-		else
-			ice_vsi_config_vlan_stripping(vsi, false);
-	}
+	struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
+	if (!ice_is_dvm_ena(hw)) {
+		if (mask & RTE_ETH_VLAN_STRIP_MASK) {
+			if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP)
+				ice_vsi_config_vlan_stripping(vsi, true);
+			else
+				ice_vsi_config_vlan_stripping(vsi, false);
+		}
 
-	if (mask & RTE_ETH_QINQ_STRIP_MASK) {
-		/* Enable or disable outer VLAN stripping */
-		if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_QINQ_STRIP)
-			ice_vsi_config_outer_vlan_stripping(vsi, true);
-		else
-			ice_vsi_config_outer_vlan_stripping(vsi, false);
+		if (mask & RTE_ETH_QINQ_STRIP_MASK) {
+			PMD_DRV_LOG(ERR, "Single VLAN mode (SVM) does not support qinq");
+			return -ENOTSUP;
+		}
+	} else {
+		if ((mask & RTE_ETH_VLAN_STRIP_MASK) |
+				(mask & RTE_ETH_QINQ_STRIP_MASK)) {
+			if (rxmode->offloads & (RTE_ETH_RX_OFFLOAD_VLAN_STRIP |
+						RTE_ETH_RX_OFFLOAD_QINQ_STRIP))
+				ice_vsi_config_outer_vlan_stripping(vsi, true);
+			else
+				ice_vsi_config_outer_vlan_stripping(vsi, false);
+		}
+
+		if (mask & RTE_ETH_QINQ_STRIP_MASK) {
+			if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_QINQ_STRIP)
+				ice_vsi_config_vlan_stripping(vsi, true);
+			else
+				ice_vsi_config_vlan_stripping(vsi, false);
+		}
 	}
 
 	return 0;