DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] net/i40e: add outer VLAN processing
@ 2021-11-18  9:39 Robin Zhang
  2022-05-19  6:18 ` [PATCH v2] " Robin Zhang
  0 siblings, 1 reply; 18+ messages in thread
From: Robin Zhang @ 2021-11-18  9:39 UTC (permalink / raw)
  To: dev; +Cc: beilei.xing, qi.z.zhang, junfeng.guo, stevex.yang, Robin Zhang

Outer VLAN processing is supported after firmware v8.4, kernel driver
also change the default behavior to support this feature. To align with
kernel driver, add support for outer VLAN processing in DPDK. This will
not impact on an old firmware.

Signed-off-by: Robin Zhang <robinx.zhang@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c | 58 +++++++++++++++++++++++++++++++---
 drivers/net/i40e/i40e_ethdev.h |  3 ++
 2 files changed, 56 insertions(+), 5 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 344cbd25d3..6e6c0d51ac 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -2591,11 +2591,31 @@ i40e_dev_close(struct rte_eth_dev *dev)
 	int ret;
 	uint8_t aq_fail = 0;
 	int retries = 0;
+	int mask = 0;
+	struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
 
 	PMD_INIT_FUNC_TRACE();
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
+	/*
+	 * To avoid global register conflict with kernel driver, need set
+	 * switch configuration back to default, disable double vlan and
+	 * clear the VLAN filters when dev close.
+	 */
+	if (pf->is_outer_vlan_processing &&
+	    (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_EXTEND)) {
+		mask = RTE_ETH_VLAN_EXTEND_MASK;
+		rxmode->offloads &= ~RTE_ETH_RX_OFFLOAD_VLAN_EXTEND;
+
+		if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_FILTER) {
+			mask |= RTE_ETH_VLAN_FILTER_MASK;
+			rxmode->offloads &= ~RTE_ETH_RX_OFFLOAD_VLAN_FILTER;
+		}
+
+		i40e_vlan_offload_set(dev, mask);
+	}
+
 	ret = rte_eth_switch_domain_free(pf->switch_domain_id);
 	if (ret)
 		PMD_INIT_LOG(WARNING, "failed to free switch domain: %d", ret);
@@ -3918,6 +3938,7 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev,
 	int qinq = dev->data->dev_conf.rxmode.offloads &
 		   RTE_ETH_RX_OFFLOAD_VLAN_EXTEND;
 	int ret = 0;
+	u16 sw_flags = 0, valid_flags = 0;
 
 	if ((vlan_type != RTE_ETH_VLAN_TYPE_INNER &&
 	     vlan_type != RTE_ETH_VLAN_TYPE_OUTER) ||
@@ -3935,15 +3956,28 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev,
 	/* 802.1ad frames ability is added in NVM API 1.7*/
 	if (hw->flags & I40E_HW_FLAG_802_1AD_CAPABLE) {
 		if (qinq) {
+			if (pf->is_outer_vlan_processing) {
+				sw_flags = I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN;
+				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_INNER)
 				hw->second_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 (pf->is_outer_vlan_processing) {
+				sw_flags = 0;
+				valid_flags = I40E_AQ_SET_SWITCH_CFG_OUTER_VLAN;
+			}
+			if (vlan_type == RTE_ETH_VLAN_TYPE_OUTER) {
+				if (pf->is_outer_vlan_processing)
+					hw->first_tag = rte_cpu_to_le_16(tpid);
+				else
+					hw->second_tag = rte_cpu_to_le_16(tpid);
+			}
 		}
-		ret = i40e_aq_set_switch_config(hw, 0, 0, 0, NULL);
+		ret = i40e_aq_set_switch_config(hw, sw_flags,
+						valid_flags, 0, NULL);
 		if (ret != I40E_SUCCESS) {
 			PMD_DRV_LOG(ERR,
 				    "Set switch config failed aq_err: %d",
@@ -4022,9 +4056,12 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask)
 					   RTE_ETHER_TYPE_VLAN);
 			i40e_vlan_tpid_set(dev, RTE_ETH_VLAN_TYPE_INNER,
 					   RTE_ETHER_TYPE_VLAN);
-		}
-		else
+		} else {
+			if (pf->is_outer_vlan_processing)
+				i40e_vlan_tpid_set(dev, RTE_ETH_VLAN_TYPE_OUTER,
+					   RTE_ETHER_TYPE_QINQ);
 			i40e_vsi_config_double_vlan(vsi, FALSE);
+		}
 	}
 
 	if (mask & RTE_ETH_QINQ_STRIP_MASK) {
@@ -4854,6 +4891,17 @@ i40e_pf_parameter_init(struct rte_eth_dev *dev)
 		return -EINVAL;
 	}
 
+	/**
+	 * Enable outer VLAN processing if firmware version is greater
+	 * than v8.3
+	 */
+	if (hw->aq.fw_maj_ver > 8 ||
+	    (hw->aq.fw_maj_ver == 8 && hw->aq.fw_min_ver > 3)) {
+		pf->is_outer_vlan_processing = true;
+	} else {
+		pf->is_outer_vlan_processing = false;
+	}
+
 	return 0;
 }
 
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index d8042abbd9..e62e2fba4f 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -1190,6 +1190,9 @@ struct i40e_pf {
 	/* Switch Domain Id */
 	uint16_t switch_domain_id;
 
+	/* The enable flag for outer VLAN processing */
+	bool is_outer_vlan_processing;
+
 	struct i40e_vf_msg_cfg vf_msg_cfg;
 	uint64_t prev_rx_bytes;
 	uint64_t prev_tx_bytes;
-- 
2.25.1


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

end of thread, other threads:[~2022-06-15 12:12 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-18  9:39 [PATCH] net/i40e: add outer VLAN processing Robin Zhang
2022-05-19  6:18 ` [PATCH v2] " Robin Zhang
2022-06-09 11:26   ` [PATCH v3] " Kevin Liu
2022-06-09 14:43     ` [PATCH v4] " Kevin Liu
2022-04-07 20:01       ` [PATCH v5] " Kevin Liu
2022-06-10 15:52         ` [PATCH v6] " Kevin Liu
2022-06-10  8:06           ` Zhang, Qi Z
2022-06-10  8:14             ` Liu, KevinX
2022-06-10 16:29           ` [PATCH v7] " Kevin Liu
2022-06-10 14:27             ` Ben Magistro
2022-06-13  2:14               ` Liu, KevinX
2022-06-13 15:01                 ` Ben Magistro
2022-06-14  2:43             ` Zhang, Yuying
2022-06-14  3:06               ` Liu, KevinX
2022-06-14  8:39                 ` Zhang, Yuying
2022-06-14  8:43                   ` Liu, KevinX
2022-06-15 12:12                   ` Zhang, Qi Z
2022-06-10  1:01       ` [PATCH v4] " Zhang, Qi Z

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