DPDK patches and discussions
 help / color / mirror / Atom feed
* RE: [PATCH v5] net/i40e: fix error disable double VLAN
  2022-06-29 15:39       ` [PATCH v5] " Kevin Liu
@ 2022-06-29  7:53         ` Zhang, Qi Z
  2022-07-06 10:59         ` Han, YingyaX
  1 sibling, 0 replies; 7+ messages in thread
From: Zhang, Qi Z @ 2022-06-29  7:53 UTC (permalink / raw)
  To: Liu, KevinX, dev; +Cc: Xing, Beilei, Zhang, Yuying, Yang, SteveX, Liu, KevinX



> -----Original Message-----
> From: Kevin Liu <kevinx.liu@intel.com>
> Sent: Wednesday, June 29, 2022 11:40 PM
> To: dev@dpdk.org
> Cc: Xing, Beilei <beilei.xing@intel.com>; Zhang, Yuying
> <yuying.zhang@intel.com>; Yang, SteveX <stevex.yang@intel.com>; Liu, KevinX
> <kevinx.liu@intel.com>
> Subject: [PATCH v5] net/i40e: fix error disable double VLAN
> 
> Enable double VLAN by default after firmware v8.3 and disable double VLAN is
> not allowed in subsequent operations.
> 
> Fixes: 4f13a78f1b8f ("net/i40e: add outer VLAN processing")
> Signed-off-by: Kevin Liu <kevinx.liu@intel.com>
> 
> v4: fix warnig
> 
> v3: refine commit log
> 
> v2: update the document
> ---

Please move change log below "---" next time

Acked-by: Qi Zhang <qi.z.zhang@intel.com>

Applied to dpdk-next-net-intel.

Thanks
Qi


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

* [PATCH] net/i40e: fix error disable double VLAN
@ 2022-06-29  9:57 Kevin Liu
  2022-06-29 10:47 ` [PATCH v2] " Kevin Liu
  0 siblings, 1 reply; 7+ messages in thread
From: Kevin Liu @ 2022-06-29  9:57 UTC (permalink / raw)
  To: dev; +Cc: Yuying.Zhang, beilei.xing, stevex.yang, Kevin Liu

Sync the kernel driver, enable double VLAN by default after
firmware v8.3 and disable double VLAN is not allowed in subsequent
operations.

Fixes: 4f13a78f1b8f ("net/i40e: add outer VLAN processing")
Signed-off-by: Kevin Liu <kevinx.liu@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c | 45 ++++++++++++----------------------
 1 file changed, 15 insertions(+), 30 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index dd471d487e..b07ef89220 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -2575,7 +2575,6 @@ i40e_dev_close(struct rte_eth_dev *dev)
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 	struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
-	struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
 	struct i40e_filter_control_settings settings;
 	struct rte_flow *p_flow;
 	uint32_t reg;
@@ -2588,18 +2587,6 @@ i40e_dev_close(struct rte_eth_dev *dev)
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
-	/*
-	 * It is a workaround, if the double VLAN is disabled when
-	 * the program exits, an abnormal error will occur on the
-	 * NIC. Need to enable double VLAN when dev is closed.
-	 */
-	if (pf->fw8_3gt) {
-		if (!(rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_EXTEND)) {
-			rxmode->offloads |= RTE_ETH_RX_OFFLOAD_VLAN_EXTEND;
-			i40e_vlan_offload_set(dev, RTE_ETH_VLAN_EXTEND_MASK);
-		}
-	}
-
 	ret = rte_eth_switch_domain_free(pf->switch_domain_id);
 	if (ret)
 		PMD_INIT_LOG(WARNING, "failed to free switch domain: %d", ret);
@@ -3950,20 +3937,8 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev,
 			else if (vlan_type == RTE_ETH_VLAN_TYPE_INNER)
 				hw->second_tag = rte_cpu_to_le_16(tpid);
 		} else {
-			/*
-			 * If tpid is equal to 0x88A8, indicates that the
-			 * disable double VLAN operation is in progress.
-			 * Need set switch configuration back to default.
-			 */
-			if (pf->fw8_3gt && tpid == RTE_ETHER_TYPE_QINQ) {
-				sw_flags = 0;
-				valid_flags = I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN;
-				if (vlan_type == RTE_ETH_VLAN_TYPE_OUTER)
-					hw->first_tag = rte_cpu_to_le_16(tpid);
-			} else {
-				if (vlan_type == RTE_ETH_VLAN_TYPE_OUTER)
-					hw->second_tag = rte_cpu_to_le_16(tpid);
-			}
+			if (vlan_type == RTE_ETH_VLAN_TYPE_OUTER)
+				hw->second_tag = rte_cpu_to_le_16(tpid);
 		}
 		ret = i40e_aq_set_switch_config(hw, sw_flags,
 						valid_flags, 0, NULL);
@@ -4043,6 +4018,12 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask)
 	}
 
 	if (mask & RTE_ETH_VLAN_EXTEND_MASK) {
+		/* Sync the kernel driver. Double VLAN not allowed to be disabled.*/
+		if (pf->fw8_3gt && !(rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_EXTEND)) {
+			PMD_DRV_LOG(WARNING,
+				"Disable double VLAN is not allowed after firmwarev8.3!");
+			return 0;
+		}
 		i = 0;
 		num = vsi->mac_num;
 		mac_filter = rte_zmalloc("mac_filter_info_data",
@@ -4078,9 +4059,6 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask)
 			i40e_vlan_tpid_set(dev, RTE_ETH_VLAN_TYPE_INNER,
 					   RTE_ETHER_TYPE_VLAN);
 		} else {
-			if (pf->fw8_3gt)
-				i40e_vlan_tpid_set(dev, RTE_ETH_VLAN_TYPE_OUTER,
-					   RTE_ETHER_TYPE_QINQ);
 			i40e_vsi_config_double_vlan(vsi, FALSE);
 		}
 		/* Restore all mac */
@@ -6176,6 +6154,7 @@ i40e_vsi_config_vlan_stripping(struct i40e_vsi *vsi, bool on)
 static int
 i40e_dev_init_vlan(struct rte_eth_dev *dev)
 {
+	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
 	struct rte_eth_dev_data *data = dev->data;
 	int ret;
 	int mask = 0;
@@ -6185,6 +6164,12 @@ i40e_dev_init_vlan(struct rte_eth_dev *dev)
 	       RTE_ETH_QINQ_STRIP_MASK |
 	       RTE_ETH_VLAN_FILTER_MASK |
 	       RTE_ETH_VLAN_EXTEND_MASK;
+
+	/* Sync the kernel driver. Double VLAN be enabled by default.*/
+	if (pf->fw8_3gt) {
+		struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
+		rxmode->offloads |= RTE_ETH_RX_OFFLOAD_VLAN_EXTEND;
+	}
 	ret = i40e_vlan_offload_set(dev, mask);
 	if (ret) {
 		PMD_DRV_LOG(INFO, "Failed to update vlan offload");
-- 
2.34.1


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

* [PATCH v2] net/i40e: fix error disable double VLAN
  2022-06-29  9:57 [PATCH] net/i40e: fix error disable double VLAN Kevin Liu
@ 2022-06-29 10:47 ` Kevin Liu
  2022-06-29 14:41   ` [PATCH v3] " Kevin Liu
  0 siblings, 1 reply; 7+ messages in thread
From: Kevin Liu @ 2022-06-29 10:47 UTC (permalink / raw)
  To: dev; +Cc: beilei.xing, Yuying.Zhang, stevex.yang, Kevin Liu

Sync the kernel driver, enable double VLAN by default after
firmware v8.3 and disable double VLAN is not allowed in subsequent
operations.

Fixes: 4f13a78f1b8f ("net/i40e: add outer VLAN processing")
Signed-off-by: Kevin Liu <kevinx.liu@intel.com>

v2: update the document
---
 doc/guides/nics/i40e.rst       |  5 ++--
 drivers/net/i40e/i40e_ethdev.c | 45 ++++++++++++----------------------
 2 files changed, 17 insertions(+), 33 deletions(-)

diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst
index a7b51618b0..d051c7ec36 100644
--- a/doc/guides/nics/i40e.rst
+++ b/doc/guides/nics/i40e.rst
@@ -969,11 +969,10 @@ it will fail and return the info "Conflict with the first rule's input set",
 which means the current rule's input set conflicts with the first rule's.
 Remove the first rule if want to change the input set of the PCTYPE.
 
-PF reset fail after QinQ set with FW >= 8.4
+Disable Qinq is not supported when FW >= 8.4
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-If upgrade FW to version 8.4 and higher, after set MAC VLAN filter and configure outer VLAN on PF, kill
-DPDK process will cause the card crash.
+If upgrade FW to version 8.4 and higher, sync kernel driver, enable Qinq by default and disable Qinq is not supported.
 
 
 Example of getting best performance with l3fwd example
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index dd471d487e..b07ef89220 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -2575,7 +2575,6 @@ i40e_dev_close(struct rte_eth_dev *dev)
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 	struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
-	struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
 	struct i40e_filter_control_settings settings;
 	struct rte_flow *p_flow;
 	uint32_t reg;
@@ -2588,18 +2587,6 @@ i40e_dev_close(struct rte_eth_dev *dev)
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
-	/*
-	 * It is a workaround, if the double VLAN is disabled when
-	 * the program exits, an abnormal error will occur on the
-	 * NIC. Need to enable double VLAN when dev is closed.
-	 */
-	if (pf->fw8_3gt) {
-		if (!(rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_EXTEND)) {
-			rxmode->offloads |= RTE_ETH_RX_OFFLOAD_VLAN_EXTEND;
-			i40e_vlan_offload_set(dev, RTE_ETH_VLAN_EXTEND_MASK);
-		}
-	}
-
 	ret = rte_eth_switch_domain_free(pf->switch_domain_id);
 	if (ret)
 		PMD_INIT_LOG(WARNING, "failed to free switch domain: %d", ret);
@@ -3950,20 +3937,8 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev,
 			else if (vlan_type == RTE_ETH_VLAN_TYPE_INNER)
 				hw->second_tag = rte_cpu_to_le_16(tpid);
 		} else {
-			/*
-			 * If tpid is equal to 0x88A8, indicates that the
-			 * disable double VLAN operation is in progress.
-			 * Need set switch configuration back to default.
-			 */
-			if (pf->fw8_3gt && tpid == RTE_ETHER_TYPE_QINQ) {
-				sw_flags = 0;
-				valid_flags = I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN;
-				if (vlan_type == RTE_ETH_VLAN_TYPE_OUTER)
-					hw->first_tag = rte_cpu_to_le_16(tpid);
-			} else {
-				if (vlan_type == RTE_ETH_VLAN_TYPE_OUTER)
-					hw->second_tag = rte_cpu_to_le_16(tpid);
-			}
+			if (vlan_type == RTE_ETH_VLAN_TYPE_OUTER)
+				hw->second_tag = rte_cpu_to_le_16(tpid);
 		}
 		ret = i40e_aq_set_switch_config(hw, sw_flags,
 						valid_flags, 0, NULL);
@@ -4043,6 +4018,12 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask)
 	}
 
 	if (mask & RTE_ETH_VLAN_EXTEND_MASK) {
+		/* Sync the kernel driver. Double VLAN not allowed to be disabled.*/
+		if (pf->fw8_3gt && !(rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_EXTEND)) {
+			PMD_DRV_LOG(WARNING,
+				"Disable double VLAN is not allowed after firmwarev8.3!");
+			return 0;
+		}
 		i = 0;
 		num = vsi->mac_num;
 		mac_filter = rte_zmalloc("mac_filter_info_data",
@@ -4078,9 +4059,6 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask)
 			i40e_vlan_tpid_set(dev, RTE_ETH_VLAN_TYPE_INNER,
 					   RTE_ETHER_TYPE_VLAN);
 		} else {
-			if (pf->fw8_3gt)
-				i40e_vlan_tpid_set(dev, RTE_ETH_VLAN_TYPE_OUTER,
-					   RTE_ETHER_TYPE_QINQ);
 			i40e_vsi_config_double_vlan(vsi, FALSE);
 		}
 		/* Restore all mac */
@@ -6176,6 +6154,7 @@ i40e_vsi_config_vlan_stripping(struct i40e_vsi *vsi, bool on)
 static int
 i40e_dev_init_vlan(struct rte_eth_dev *dev)
 {
+	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
 	struct rte_eth_dev_data *data = dev->data;
 	int ret;
 	int mask = 0;
@@ -6185,6 +6164,12 @@ i40e_dev_init_vlan(struct rte_eth_dev *dev)
 	       RTE_ETH_QINQ_STRIP_MASK |
 	       RTE_ETH_VLAN_FILTER_MASK |
 	       RTE_ETH_VLAN_EXTEND_MASK;
+
+	/* Sync the kernel driver. Double VLAN be enabled by default.*/
+	if (pf->fw8_3gt) {
+		struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
+		rxmode->offloads |= RTE_ETH_RX_OFFLOAD_VLAN_EXTEND;
+	}
 	ret = i40e_vlan_offload_set(dev, mask);
 	if (ret) {
 		PMD_DRV_LOG(INFO, "Failed to update vlan offload");
-- 
2.34.1


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

* [PATCH v3] net/i40e: fix error disable double VLAN
  2022-06-29 10:47 ` [PATCH v2] " Kevin Liu
@ 2022-06-29 14:41   ` Kevin Liu
  2022-06-29 14:53     ` [PATCH v4] " Kevin Liu
  0 siblings, 1 reply; 7+ messages in thread
From: Kevin Liu @ 2022-06-29 14:41 UTC (permalink / raw)
  To: dev; +Cc: beilei.xing, Yuying.Zhang, stevex.yang, Kevin Liu

Enable double VLAN by default after firmware v8.3
and disable double VLAN is not allowed in subsequent
operations.

Fixes: 4f13a78f1b8f ("net/i40e: add outer VLAN processing")
Signed-off-by: Kevin Liu <kevinx.liu@intel.com>

v3: refine commit log

v2: update the document
---
 doc/guides/nics/i40e.rst       |  5 ++--
 drivers/net/i40e/i40e_ethdev.c | 46 ++++++++++++----------------------
 2 files changed, 18 insertions(+), 33 deletions(-)

diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst
index a7b51618b0..d051c7ec36 100644
--- a/doc/guides/nics/i40e.rst
+++ b/doc/guides/nics/i40e.rst
@@ -969,11 +969,10 @@ it will fail and return the info "Conflict with the first rule's input set",
 which means the current rule's input set conflicts with the first rule's.
 Remove the first rule if want to change the input set of the PCTYPE.
 
-PF reset fail after QinQ set with FW >= 8.4
+Disable Qinq is not supported when FW >= 8.4
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-If upgrade FW to version 8.4 and higher, after set MAC VLAN filter and configure outer VLAN on PF, kill
-DPDK process will cause the card crash.
+If upgrade FW to version 8.4 and higher, sync kernel driver, enable Qinq by default and disable Qinq is not supported.
 
 
 Example of getting best performance with l3fwd example
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index dd471d487e..95e6b1578c 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -2575,7 +2575,6 @@ i40e_dev_close(struct rte_eth_dev *dev)
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 	struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
-	struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
 	struct i40e_filter_control_settings settings;
 	struct rte_flow *p_flow;
 	uint32_t reg;
@@ -2588,18 +2587,6 @@ i40e_dev_close(struct rte_eth_dev *dev)
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
-	/*
-	 * It is a workaround, if the double VLAN is disabled when
-	 * the program exits, an abnormal error will occur on the
-	 * NIC. Need to enable double VLAN when dev is closed.
-	 */
-	if (pf->fw8_3gt) {
-		if (!(rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_EXTEND)) {
-			rxmode->offloads |= RTE_ETH_RX_OFFLOAD_VLAN_EXTEND;
-			i40e_vlan_offload_set(dev, RTE_ETH_VLAN_EXTEND_MASK);
-		}
-	}
-
 	ret = rte_eth_switch_domain_free(pf->switch_domain_id);
 	if (ret)
 		PMD_INIT_LOG(WARNING, "failed to free switch domain: %d", ret);
@@ -3950,20 +3937,8 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev,
 			else if (vlan_type == RTE_ETH_VLAN_TYPE_INNER)
 				hw->second_tag = rte_cpu_to_le_16(tpid);
 		} else {
-			/*
-			 * If tpid is equal to 0x88A8, indicates that the
-			 * disable double VLAN operation is in progress.
-			 * Need set switch configuration back to default.
-			 */
-			if (pf->fw8_3gt && tpid == RTE_ETHER_TYPE_QINQ) {
-				sw_flags = 0;
-				valid_flags = I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN;
-				if (vlan_type == RTE_ETH_VLAN_TYPE_OUTER)
-					hw->first_tag = rte_cpu_to_le_16(tpid);
-			} else {
-				if (vlan_type == RTE_ETH_VLAN_TYPE_OUTER)
-					hw->second_tag = rte_cpu_to_le_16(tpid);
-			}
+			if (vlan_type == RTE_ETH_VLAN_TYPE_OUTER)
+				hw->second_tag = rte_cpu_to_le_16(tpid);
 		}
 		ret = i40e_aq_set_switch_config(hw, sw_flags,
 						valid_flags, 0, NULL);
@@ -4043,6 +4018,12 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask)
 	}
 
 	if (mask & RTE_ETH_VLAN_EXTEND_MASK) {
+		/* Double VLAN not allowed to be disabled.*/
+		if (pf->fw8_3gt && !(rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_EXTEND)) {
+			PMD_DRV_LOG(WARNING,
+				"Disable double VLAN is not allowed after firmwarev8.3!");
+			return 0;
+		}
 		i = 0;
 		num = vsi->mac_num;
 		mac_filter = rte_zmalloc("mac_filter_info_data",
@@ -4078,9 +4059,6 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask)
 			i40e_vlan_tpid_set(dev, RTE_ETH_VLAN_TYPE_INNER,
 					   RTE_ETHER_TYPE_VLAN);
 		} else {
-			if (pf->fw8_3gt)
-				i40e_vlan_tpid_set(dev, RTE_ETH_VLAN_TYPE_OUTER,
-					   RTE_ETHER_TYPE_QINQ);
 			i40e_vsi_config_double_vlan(vsi, FALSE);
 		}
 		/* Restore all mac */
@@ -6135,6 +6113,7 @@ i40e_vsi_config_vlan_filter(struct i40e_vsi *vsi, bool on)
 int
 i40e_vsi_config_vlan_stripping(struct i40e_vsi *vsi, bool on)
 {
+	struct i40e_pf *pf = I40E_VSI_TO_PF(vsi);
 	struct i40e_hw *hw = I40E_VSI_TO_HW(vsi);
 	struct i40e_vsi_context ctxt;
 	uint8_t vlan_flags;
@@ -6176,6 +6155,7 @@ i40e_vsi_config_vlan_stripping(struct i40e_vsi *vsi, bool on)
 static int
 i40e_dev_init_vlan(struct rte_eth_dev *dev)
 {
+	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
 	struct rte_eth_dev_data *data = dev->data;
 	int ret;
 	int mask = 0;
@@ -6185,6 +6165,12 @@ i40e_dev_init_vlan(struct rte_eth_dev *dev)
 	       RTE_ETH_QINQ_STRIP_MASK |
 	       RTE_ETH_VLAN_FILTER_MASK |
 	       RTE_ETH_VLAN_EXTEND_MASK;
+
+	/* Double VLAN be enabled by default.*/
+	if (pf->fw8_3gt) {
+		struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
+		rxmode->offloads |= RTE_ETH_RX_OFFLOAD_VLAN_EXTEND;
+	}
 	ret = i40e_vlan_offload_set(dev, mask);
 	if (ret) {
 		PMD_DRV_LOG(INFO, "Failed to update vlan offload");
-- 
2.34.1


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

* [PATCH v4] net/i40e: fix error disable double VLAN
  2022-06-29 14:41   ` [PATCH v3] " Kevin Liu
@ 2022-06-29 14:53     ` Kevin Liu
  2022-06-29 15:39       ` [PATCH v5] " Kevin Liu
  0 siblings, 1 reply; 7+ messages in thread
From: Kevin Liu @ 2022-06-29 14:53 UTC (permalink / raw)
  To: dev; +Cc: beilei.xing, Yuying.Zhang, stevex.yang, Kevin Liu

Enable double VLAN by default after firmware v8.3
and disable double VLAN is not allowed in subsequent
operations.

Fixes: 4f13a78f1b8f ("net/i40e: add outer VLAN processing")
Signed-off-by: Kevin Liu <kevinx.liu@intel.com>

v4: fix warnig

v3: refine commit log

v2: update the document
---
 doc/guides/nics/i40e.rst       |  5 ++--
 drivers/net/i40e/i40e_ethdev.c | 45 ++++++++++++----------------------
 2 files changed, 17 insertions(+), 33 deletions(-)

diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst
index a7b51618b0..d051c7ec36 100644
--- a/doc/guides/nics/i40e.rst
+++ b/doc/guides/nics/i40e.rst
@@ -969,11 +969,10 @@ it will fail and return the info "Conflict with the first rule's input set",
 which means the current rule's input set conflicts with the first rule's.
 Remove the first rule if want to change the input set of the PCTYPE.
 
-PF reset fail after QinQ set with FW >= 8.4
+Disable Qinq is not supported when FW >= 8.4
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-If upgrade FW to version 8.4 and higher, after set MAC VLAN filter and configure outer VLAN on PF, kill
-DPDK process will cause the card crash.
+If upgrade FW to version 8.4 and higher, sync kernel driver, enable Qinq by default and disable Qinq is not supported.
 
 
 Example of getting best performance with l3fwd example
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index dd471d487e..7ab788246c 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -2575,7 +2575,6 @@ i40e_dev_close(struct rte_eth_dev *dev)
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 	struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
-	struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
 	struct i40e_filter_control_settings settings;
 	struct rte_flow *p_flow;
 	uint32_t reg;
@@ -2588,18 +2587,6 @@ i40e_dev_close(struct rte_eth_dev *dev)
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
-	/*
-	 * It is a workaround, if the double VLAN is disabled when
-	 * the program exits, an abnormal error will occur on the
-	 * NIC. Need to enable double VLAN when dev is closed.
-	 */
-	if (pf->fw8_3gt) {
-		if (!(rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_EXTEND)) {
-			rxmode->offloads |= RTE_ETH_RX_OFFLOAD_VLAN_EXTEND;
-			i40e_vlan_offload_set(dev, RTE_ETH_VLAN_EXTEND_MASK);
-		}
-	}
-
 	ret = rte_eth_switch_domain_free(pf->switch_domain_id);
 	if (ret)
 		PMD_INIT_LOG(WARNING, "failed to free switch domain: %d", ret);
@@ -3950,20 +3937,8 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev,
 			else if (vlan_type == RTE_ETH_VLAN_TYPE_INNER)
 				hw->second_tag = rte_cpu_to_le_16(tpid);
 		} else {
-			/*
-			 * If tpid is equal to 0x88A8, indicates that the
-			 * disable double VLAN operation is in progress.
-			 * Need set switch configuration back to default.
-			 */
-			if (pf->fw8_3gt && tpid == RTE_ETHER_TYPE_QINQ) {
-				sw_flags = 0;
-				valid_flags = I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN;
-				if (vlan_type == RTE_ETH_VLAN_TYPE_OUTER)
-					hw->first_tag = rte_cpu_to_le_16(tpid);
-			} else {
-				if (vlan_type == RTE_ETH_VLAN_TYPE_OUTER)
-					hw->second_tag = rte_cpu_to_le_16(tpid);
-			}
+			if (vlan_type == RTE_ETH_VLAN_TYPE_OUTER)
+				hw->second_tag = rte_cpu_to_le_16(tpid);
 		}
 		ret = i40e_aq_set_switch_config(hw, sw_flags,
 						valid_flags, 0, NULL);
@@ -4043,6 +4018,12 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask)
 	}
 
 	if (mask & RTE_ETH_VLAN_EXTEND_MASK) {
+		/* Double VLAN not allowed to be disabled.*/
+		if (pf->fw8_3gt && !(rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_EXTEND)) {
+			PMD_DRV_LOG(WARNING,
+				"Disable double VLAN is not allowed after firmwarev8.3!");
+			return 0;
+		}
 		i = 0;
 		num = vsi->mac_num;
 		mac_filter = rte_zmalloc("mac_filter_info_data",
@@ -4078,9 +4059,6 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask)
 			i40e_vlan_tpid_set(dev, RTE_ETH_VLAN_TYPE_INNER,
 					   RTE_ETHER_TYPE_VLAN);
 		} else {
-			if (pf->fw8_3gt)
-				i40e_vlan_tpid_set(dev, RTE_ETH_VLAN_TYPE_OUTER,
-					   RTE_ETHER_TYPE_QINQ);
 			i40e_vsi_config_double_vlan(vsi, FALSE);
 		}
 		/* Restore all mac */
@@ -6176,6 +6154,7 @@ i40e_vsi_config_vlan_stripping(struct i40e_vsi *vsi, bool on)
 static int
 i40e_dev_init_vlan(struct rte_eth_dev *dev)
 {
+	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
 	struct rte_eth_dev_data *data = dev->data;
 	int ret;
 	int mask = 0;
@@ -6185,6 +6164,12 @@ i40e_dev_init_vlan(struct rte_eth_dev *dev)
 	       RTE_ETH_QINQ_STRIP_MASK |
 	       RTE_ETH_VLAN_FILTER_MASK |
 	       RTE_ETH_VLAN_EXTEND_MASK;
+
+	/* Double VLAN be enabled by default.*/
+	if (pf->fw8_3gt) {
+		struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
+		rxmode->offloads |= RTE_ETH_RX_OFFLOAD_VLAN_EXTEND;
+	}
 	ret = i40e_vlan_offload_set(dev, mask);
 	if (ret) {
 		PMD_DRV_LOG(INFO, "Failed to update vlan offload");
-- 
2.34.1


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

* [PATCH v5] net/i40e: fix error disable double VLAN
  2022-06-29 14:53     ` [PATCH v4] " Kevin Liu
@ 2022-06-29 15:39       ` Kevin Liu
  2022-06-29  7:53         ` Zhang, Qi Z
  2022-07-06 10:59         ` Han, YingyaX
  0 siblings, 2 replies; 7+ messages in thread
From: Kevin Liu @ 2022-06-29 15:39 UTC (permalink / raw)
  To: dev; +Cc: beilei.xing, Yuying.Zhang, stevex.yang, Kevin Liu

Enable double VLAN by default after firmware v8.3
and disable double VLAN is not allowed in subsequent
operations.

Fixes: 4f13a78f1b8f ("net/i40e: add outer VLAN processing")
Signed-off-by: Kevin Liu <kevinx.liu@intel.com>

v4: fix warnig

v3: refine commit log

v2: update the document
---
 doc/guides/nics/i40e.rst       |  5 ++--
 drivers/net/i40e/i40e_ethdev.c | 45 ++++++++++++----------------------
 2 files changed, 17 insertions(+), 33 deletions(-)

diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst
index a7b51618b0..0f833d4231 100644
--- a/doc/guides/nics/i40e.rst
+++ b/doc/guides/nics/i40e.rst
@@ -969,11 +969,10 @@ it will fail and return the info "Conflict with the first rule's input set",
 which means the current rule's input set conflicts with the first rule's.
 Remove the first rule if want to change the input set of the PCTYPE.
 
-PF reset fail after QinQ set with FW >= 8.4
+Disable QinQ is not supported when FW >= 8.4
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-If upgrade FW to version 8.4 and higher, after set MAC VLAN filter and configure outer VLAN on PF, kill
-DPDK process will cause the card crash.
+If upgrade FW to version 8.4 and higher, enable QinQ by default and disable QinQ is not supported.
 
 
 Example of getting best performance with l3fwd example
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index dd471d487e..7ab788246c 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -2575,7 +2575,6 @@ i40e_dev_close(struct rte_eth_dev *dev)
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 	struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
-	struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
 	struct i40e_filter_control_settings settings;
 	struct rte_flow *p_flow;
 	uint32_t reg;
@@ -2588,18 +2587,6 @@ i40e_dev_close(struct rte_eth_dev *dev)
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
-	/*
-	 * It is a workaround, if the double VLAN is disabled when
-	 * the program exits, an abnormal error will occur on the
-	 * NIC. Need to enable double VLAN when dev is closed.
-	 */
-	if (pf->fw8_3gt) {
-		if (!(rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_EXTEND)) {
-			rxmode->offloads |= RTE_ETH_RX_OFFLOAD_VLAN_EXTEND;
-			i40e_vlan_offload_set(dev, RTE_ETH_VLAN_EXTEND_MASK);
-		}
-	}
-
 	ret = rte_eth_switch_domain_free(pf->switch_domain_id);
 	if (ret)
 		PMD_INIT_LOG(WARNING, "failed to free switch domain: %d", ret);
@@ -3950,20 +3937,8 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev,
 			else if (vlan_type == RTE_ETH_VLAN_TYPE_INNER)
 				hw->second_tag = rte_cpu_to_le_16(tpid);
 		} else {
-			/*
-			 * If tpid is equal to 0x88A8, indicates that the
-			 * disable double VLAN operation is in progress.
-			 * Need set switch configuration back to default.
-			 */
-			if (pf->fw8_3gt && tpid == RTE_ETHER_TYPE_QINQ) {
-				sw_flags = 0;
-				valid_flags = I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN;
-				if (vlan_type == RTE_ETH_VLAN_TYPE_OUTER)
-					hw->first_tag = rte_cpu_to_le_16(tpid);
-			} else {
-				if (vlan_type == RTE_ETH_VLAN_TYPE_OUTER)
-					hw->second_tag = rte_cpu_to_le_16(tpid);
-			}
+			if (vlan_type == RTE_ETH_VLAN_TYPE_OUTER)
+				hw->second_tag = rte_cpu_to_le_16(tpid);
 		}
 		ret = i40e_aq_set_switch_config(hw, sw_flags,
 						valid_flags, 0, NULL);
@@ -4043,6 +4018,12 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask)
 	}
 
 	if (mask & RTE_ETH_VLAN_EXTEND_MASK) {
+		/* Double VLAN not allowed to be disabled.*/
+		if (pf->fw8_3gt && !(rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_EXTEND)) {
+			PMD_DRV_LOG(WARNING,
+				"Disable double VLAN is not allowed after firmwarev8.3!");
+			return 0;
+		}
 		i = 0;
 		num = vsi->mac_num;
 		mac_filter = rte_zmalloc("mac_filter_info_data",
@@ -4078,9 +4059,6 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask)
 			i40e_vlan_tpid_set(dev, RTE_ETH_VLAN_TYPE_INNER,
 					   RTE_ETHER_TYPE_VLAN);
 		} else {
-			if (pf->fw8_3gt)
-				i40e_vlan_tpid_set(dev, RTE_ETH_VLAN_TYPE_OUTER,
-					   RTE_ETHER_TYPE_QINQ);
 			i40e_vsi_config_double_vlan(vsi, FALSE);
 		}
 		/* Restore all mac */
@@ -6176,6 +6154,7 @@ i40e_vsi_config_vlan_stripping(struct i40e_vsi *vsi, bool on)
 static int
 i40e_dev_init_vlan(struct rte_eth_dev *dev)
 {
+	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
 	struct rte_eth_dev_data *data = dev->data;
 	int ret;
 	int mask = 0;
@@ -6185,6 +6164,12 @@ i40e_dev_init_vlan(struct rte_eth_dev *dev)
 	       RTE_ETH_QINQ_STRIP_MASK |
 	       RTE_ETH_VLAN_FILTER_MASK |
 	       RTE_ETH_VLAN_EXTEND_MASK;
+
+	/* Double VLAN be enabled by default.*/
+	if (pf->fw8_3gt) {
+		struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
+		rxmode->offloads |= RTE_ETH_RX_OFFLOAD_VLAN_EXTEND;
+	}
 	ret = i40e_vlan_offload_set(dev, mask);
 	if (ret) {
 		PMD_DRV_LOG(INFO, "Failed to update vlan offload");
-- 
2.34.1


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

* RE: [PATCH v5] net/i40e: fix error disable double VLAN
  2022-06-29 15:39       ` [PATCH v5] " Kevin Liu
  2022-06-29  7:53         ` Zhang, Qi Z
@ 2022-07-06 10:59         ` Han, YingyaX
  1 sibling, 0 replies; 7+ messages in thread
From: Han, YingyaX @ 2022-07-06 10:59 UTC (permalink / raw)
  To: Liu, KevinX, dev
  Cc: Xing, Beilei, Zhang, Yuying, Yang, SteveX, Liu, KevinX, Zhang,
	Qi Z, Yang, Qiming


-----Original Message-----
From: Kevin Liu <kevinx.liu@intel.com> 
Sent: Wednesday, June 29, 2022 11:40 PM
To: dev@dpdk.org
Cc: Xing, Beilei <beilei.xing@intel.com>; Zhang, Yuying <yuying.zhang@intel.com>; Yang, SteveX <stevex.yang@intel.com>; Liu, KevinX <kevinx.liu@intel.com>
Subject: [PATCH v5] net/i40e: fix error disable double VLAN

Enable double VLAN by default after firmware v8.3 and disable double VLAN is not allowed in subsequent operations.

Fixes: 4f13a78f1b8f ("net/i40e: add outer VLAN processing")
Signed-off-by: Kevin Liu <kevinx.liu@intel.com>

The performance of X710 drop about 45% when testing nic_single_core.

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

end of thread, other threads:[~2022-07-06 11:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-29  9:57 [PATCH] net/i40e: fix error disable double VLAN Kevin Liu
2022-06-29 10:47 ` [PATCH v2] " Kevin Liu
2022-06-29 14:41   ` [PATCH v3] " Kevin Liu
2022-06-29 14:53     ` [PATCH v4] " Kevin Liu
2022-06-29 15:39       ` [PATCH v5] " Kevin Liu
2022-06-29  7:53         ` Zhang, Qi Z
2022-07-06 10:59         ` Han, YingyaX

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).