Skip to contentSkip to conversation

net/sxe2: fix bugs

PATCH In review [email protected] 3 participants 429 messages Aug 18 – Sep 3 Network drivers Page 3 of 4

lore
Share & tools
lore
#282 lore raw

PATCH v8 4/49 net/sxe2: fix MSIX register width in PF map table

In reply to [email protected]

From: Jie Liu <[email protected]>

The MSIX entry in sxe2_net_map_addr_info_pf sets a register width of 10 (decimal), but each PCIe MSIX table entry is 16 bytes (0x10). The VF map table already uses 0x10.

Since reg_width is used as the stride between MSIX entries in sxe2_dev_pci_seg_map(), the wrong value makes the mapped region too short and places the entries at incorrect offsets.

Change .reg_width from 10 to 0x10 for the SXE2_PCI_MAP_RES_IRQ_MSIX entry to match the VF table.

Fixes 66a10eb60ebe ("net/sxe2: add PCI BAR mapping")
---
 drivers/net/sxe2/sxe2_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/sxe2/sxe2_ethdev.c +1 -1
index ec376b76dc..5d8cfca6cf 100644
@@ -94,7 +94,7 @@ static struct sxe2_pci_map_addr_info sxe2_net_map_addr_info_pf[SXE2_PCI_MAP_RES_
 				      .reg_width = 4},
 	[SXE2_PCI_MAP_RES_IRQ_MSIX] = {.addr_base = SXE2_BAR4_MSIX_CTL(0),
 				      .bar_idx = 4,
-				      .reg_width = 10},
+				      .reg_width = 0x10},
 };
 
 static struct sxe2_pci_map_addr_info sxe2_net_map_addr_info_vf[SXE2_PCI_MAP_RES_MAX_COUNT] = {
Signature · 1 line
2.52.0
#283 lore raw

PATCH v8 5/49 net/sxe2: restore PF and port index caps assignment

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_func_caps_get() never assigns adapter->pf_idx from the device capabilities, leaving it at its zero-initialized value. Switchdev requests and representor setup that use pf_idx then report the wrong PF index on multi-PF configurations.

Restore the pf_idx and port_idx assignments in sxe2_func_caps_get() and drop the now-redundant port_idx assignment from sxe2_drv_dev_caps_set().

Fixes d8e4e075acb4 ("net/sxe2: add probing skeleton")
---
 drivers/net/sxe2/sxe2_ethdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/sxe2/sxe2_ethdev.c +2 -2
index 5d8cfca6cf..2e14c372f8 100644
@@ -1284,8 +1284,6 @@ void sxe2_eth_uinit(struct rte_eth_dev *dev __rte_unused)
 static void sxe2_drv_dev_caps_set(struct sxe2_adapter *adapter,
 			struct sxe2_drv_dev_caps_resp *dev_caps)
 {
-	adapter->port_idx = dev_caps->port_idx;
-
 	adapter->cap_flags = 0;
 
 	if (dev_caps->cap_flags & SXE2_DEV_CAPS_OFFLOAD_L2)
@@ -1344,6 +1342,8 @@ static int32_t sxe2_func_caps_get(struct sxe2_adapter *adapter)
 		goto l_end;
 
 	adapter->dev_type = dev_caps.dev_type;
+	adapter->port_idx = dev_caps.port_idx;
+	adapter->pf_idx = dev_caps.pf_idx;
 
 	sxe2_drv_dev_caps_set(adapter,  &dev_caps);
 
Signature · 1 line
2.52.0
#284 lore raw

PATCH v8 6/49 net/sxe2: fix VSI lifecycle management

In reply to [email protected]

From: Jie Liu <[email protected]>

Fix several VSI create/destroy issues introduced by VF representor support:

- Initialize other_vsi_list with TAILQ_INIT in sxe2_vsi_init before any VSI is inserted into it.
- Treat -EPERM as a non-fatal error when destroying VSIs, since the kernel may have already removed the VSI.
- Set main_vsi to NULL after destroy/free to avoid a dangling pointer if the VSI is destroyed again.

Fixes 635084db5d57 ("net/sxe2: support VF representors")
---
 drivers/net/sxe2/sxe2_vsi.c | 31 ++++++++++---------------------
 1 file changed, 10 insertions(+), 21 deletions(-)
drivers/net/sxe2/sxe2_vsi.c +10 -21
index d29480b931..e1a26fda6a 100644
@@ -96,21 +96,6 @@ static struct sxe2_vsi *sxe2_vsi_node_create(struct sxe2_adapter *adapter,
 	return vsi;
 }
 
-static void sxe2_vsi_node_free(struct sxe2_vsi *vsi)
-{
-	struct sxe2_adapter *adapter;
-
-	if (!vsi)
-		return;
-
-	adapter = vsi->adapter;
-	if (vsi->vsi_type == SXE2_VSI_T_ESW)
-		TAILQ_REMOVE(&adapter->vsi_ctxt.other_vsi_list, vsi, next);
-
-	rte_free(vsi);
-	vsi = NULL;
-}
-
 static int32_t sxe2_vsi_destroy(struct sxe2_adapter *adapter, struct sxe2_vsi *vsi)
 {
 	int32_t ret = 0;
@@ -131,6 +116,8 @@ static int32_t sxe2_vsi_destroy(struct sxe2_adapter *adapter, struct sxe2_vsi *v
 	}
 
 l_free:
+	if (vsi->vsi_type == SXE2_VSI_T_DPDK_ESW)
+		TAILQ_REMOVE(&adapter->vsi_ctxt.other_vsi_list, vsi, next);
 	rte_free(vsi);
 	vsi = NULL;
 
@@ -174,7 +161,7 @@ static int32_t sxe2_main_vsi_create(struct sxe2_adapter *adapter)
 	goto l_end;
 
 l_free_vsi:
-	sxe2_vsi_node_free(adapter->vsi_ctxt.main_vsi);
+	rte_free(adapter->vsi_ctxt.main_vsi);
 	adapter->vsi_ctxt.main_vsi = NULL;
 l_end:
 	return ret;
@@ -217,7 +204,7 @@ int32_t sxe2_other_vsi_create(struct sxe2_adapter *adapter, uint16_t cnt_vf)
 	goto l_end;
 
 l_free_vsi:
-	sxe2_vsi_node_free(other_vsi);
+	rte_free(other_vsi);
 l_end:
 	return ret;
 }
@@ -230,7 +217,7 @@ int32_t sxe2_vsi_init(struct rte_eth_dev *dev)
 	uint16_t srcvsi_cnt;
 
 	PMD_INIT_FUNC_TRACE();
-
+	TAILQ_INIT(&adapter->vsi_ctxt.other_vsi_list);
 	ret = sxe2_main_vsi_create(adapter);
 	if (ret) {
 		PMD_LOG_ERR(DRV, "Failed to create main VSI, ret=%d", ret);
@@ -283,13 +270,14 @@ void sxe2_vsi_uninit(struct rte_eth_dev *dev)
 
 l_free:
 	ret = sxe2_vsi_destroy(adapter, adapter->vsi_ctxt.main_vsi);
-	if (ret) {
+	if (ret && ret != -EPERM) {
 		PMD_LOG_ERR(DRV, "Failed to del vsi from fw, ret=%d", ret);
 		goto l_end;
 	}
+	adapter->vsi_ctxt.main_vsi = NULL;
 	RTE_TAILQ_FOREACH_SAFE(var, &adapter->vsi_ctxt.other_vsi_list, next, tvar) {
 		ret = sxe2_vsi_destroy(adapter, var);
-		if (ret) {
+		if (ret && ret != -EPERM) {
 			PMD_LOG_ERR(DRV, "Failed to del vsi from fw, ret=%d", ret);
 			break;
 		}
@@ -356,5 +344,6 @@ void sxe2_vsi_repr_main_vsi_destroy(struct rte_eth_dev *dev)
 {
 	struct sxe2_adapter *adapter = SXE2_DEV_PRIVATE_TO_ADAPTER(dev);
 
-	sxe2_vsi_node_free(adapter->vsi_ctxt.main_vsi);
+	rte_free(adapter->vsi_ctxt.main_vsi);
+	adapter->vsi_ctxt.main_vsi = NULL;
 }
Signature · 1 line
2.52.0
#285 lore raw

PATCH v8 7/49 net/sxe2: initialize stats in representor device init

In reply to [email protected]

From: Jie Liu <[email protected]>

Add sxe2_stats_init() call in sxe2_repr_dev_init to set up the statistics infrastructure for representor devices, and add the l_init_irq_ctxt_err error path to uninitialize the software irq context if stats initialization fails.

---
 drivers/net/sxe2/sxe2_ethdev_repr.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/net/sxe2/sxe2_ethdev_repr.c +8 -0
index f32318b731..c698baafe0 100644
@@ -483,8 +483,16 @@ int32_t sxe2_repr_dev_init(struct rte_eth_dev *dev,
 		goto l_init_sw_err;
 	}
 
+	ret = sxe2_stats_init(dev);
+	if (ret) {
+		PMD_LOG_ERR(INIT, "Failed to initialize stats, ret=[%d]", ret);
+		goto l_init_irq_ctxt_err;
+	}
+
 	goto l_end;
 
+l_init_irq_ctxt_err:
+	sxe2_sw_irq_ctxt_uninit(dev);
 l_init_sw_err:
 	sxe2_eth_uinit(dev);
 l_init_eth_err:
Signature · 1 line
2.52.0
#286 lore raw

PATCH v8 8/49 net/sxe2: use base device name for representor naming

In reply to [email protected]

From: Jie Liu <[email protected]>

Update the representor device naming to use the base device name prefix, and set the numa_node from the parent device data so that representor devices are allocated on the same NUMA node.

---
 drivers/net/sxe2/sxe2_ethdev_repr.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/sxe2/sxe2_ethdev_repr.c +4 -4
index c698baafe0..6f5642ad5d 100644
@@ -552,9 +552,8 @@ int32_t sxe2_switchdev_repr_devs_init(struct sxe2_adapter *adapter,
 	}
 
 	for (repr_idx = 0; repr_idx < req_eth_da->nb_representor_ports; ++repr_idx) {
-		snprintf(name, sizeof(name), "sxe2_representor_c%dpf%d%s%u",
-			 adapter->pf_idx, adapter->pf_idx,
-			 "vf",
+		snprintf(name, sizeof(name), "%s_representor_vf%u",
+			 adapter->cdev->dev->name,
 			 req_eth_da->representor_ports[repr_idx]);
 
 		eth_dev = rte_eth_dev_allocate(name);
@@ -562,10 +561,11 @@ int32_t sxe2_switchdev_repr_devs_init(struct sxe2_adapter *adapter,
 			ret = -ENOMEM;
 			goto l_release_port;
 		}
+		eth_dev->data->numa_node = adapter->dev_info.dev_data->numa_node;
 		eth_dev->data->dev_private = rte_zmalloc_socket(name,
 			sizeof(struct sxe2_adapter),
 			RTE_CACHE_LINE_SIZE,
-			rte_socket_id());
+			eth_dev->data->numa_node);
 
 		if (!eth_dev->data->dev_private) {
 			rte_eth_dev_release_port(eth_dev);
Signature · 1 line
2.52.0
#287 lore raw

PATCH v8 9/49 net/sxe2: propagate LSC event to VF representors

In reply to [email protected]

From: Jie Liu <[email protected]>

When the PF link state changes in switchdev mode, refresh the link status of every VF representor and trigger the RTE_ETH_EVENT_INTR_LSC callback on each, so applications receive link events on representor ports. Also log OICR in hexadecimal for better readability.

---
 drivers/net/sxe2/sxe2_irq.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
drivers/net/sxe2/sxe2_irq.c +20 -2
index 3306504761..ba764dd5e4 100644
@@ -77,14 +77,32 @@ static int32_t sxe2_fc_state_callback(struct rte_eth_dev *dev)
 static void sxe2_event_irq_common_handler(struct sxe2_adapter *adapter, uint64_t oicr)
 {
 	struct rte_eth_dev *dev = &rte_eth_devices[adapter->dev_info.dev_data->port_id];
+	struct rte_eth_dev *repr_eth_dev;
+	struct sxe2_adapter *repr_adapter;
+	uint16_t vf_id;
 
 	if (oicr & RTE_BIT32(SXE2_COM_EC_LINK_CHG)) {
-		PMD_DEV_LOG_INFO(adapter, DRV, "OICR=%" PRIu64, oicr);
+		PMD_DEV_LOG_INFO(adapter, DRV, "OICR=0x%" PRIx64, oicr);
 		(void)sxe2_drv_mac_link_status_get(adapter);
-		if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+		if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 			rte_eth_dev_callback_process(dev,
 						     RTE_ETH_EVENT_INTR_LSC,
 						     NULL);
+		}
+		if (adapter->switchdev_info.is_switchdev) {
+			for (vf_id = 0; vf_id < adapter->repr_ctxt.nb_repr_vf; vf_id++) {
+				repr_eth_dev = adapter->repr_ctxt.vf_rep_eth_dev[vf_id];
+				if (!repr_eth_dev)
+					continue;
+				repr_adapter = SXE2_DEV_PRIVATE_TO_ADAPTER(repr_eth_dev);
+				(void)sxe2_drv_mac_link_status_get(repr_adapter);
+				if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+					rte_eth_dev_callback_process(repr_eth_dev,
+								     RTE_ETH_EVENT_INTR_LSC,
+								     NULL);
+				}
+			}
+		}
 	}
 	if (oicr & RTE_BIT32(SXE2_COM_SW_MODE_SWITCHDEV)) {
 		PMD_DEV_LOG_INFO(adapter, DRV, "event notify switchdev");
Signature · 1 line
2.52.0
#288 lore raw

PATCH v8 10/49 net/sxe2: clear security context pointer on uninit

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_security_uinit() frees the security session but leaves dev->security_ctx pointing at the freed memory. Set dev->security_ctx to NULL after releasing the security context so a later access does not dereference a dangling pointer.

---
 drivers/net/sxe2/sxe2_security.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/sxe2/sxe2_security.c +1 -0
index bc59d1b880..8f31067942 100644
@@ -326,6 +326,7 @@ void sxe2_security_uinit(struct rte_eth_dev *dev)
 	if (sctx != NULL) {
 		rte_free(sctx);
 		sctx = NULL;
+		dev->security_ctx = NULL;
 	}
 
 	sxe2_ipsec_uinit(adapter);
Signature · 1 line
2.52.0
#289 lore raw

PATCH v8 11/49 net/sxe2: rename representor VSI ID fields

In reply to [email protected]

From: Jie Liu <[email protected]>

Rename repr_vf_k_vsi_id/repr_vf_u_vsi_id to
repr_vf_primary_vsi_id/repr_vf_backup_vsi_id in
sxe2_repr_private_data and update all references.

---
 drivers/net/sxe2/sxe2_dump.c      | 8 ++++----
 drivers/net/sxe2/sxe2_ethdev.h    | 4 ++--
 drivers/net/sxe2/sxe2_flow.c      | 4 ++--
 drivers/net/sxe2/sxe2_switchdev.c | 4 ++--
 4 files changed, 10 insertions(+), 10 deletions(-)
drivers/net/sxe2/sxe2_dump.c +4 -4
index d43473e083..590219f502 100644
@@ -211,16 +211,16 @@ sxe2_dump_switchdev_info(FILE *file, struct rte_eth_dev *dev)
 			"\t  -- repr_pf_id: %u\n"
 			"\t  -- repr_vf_id: %u\n"
 			"\t  -- repr_vf_vsi_id: %u\n"
-			"\t  -- repr_vf_k_vsi_id: %s\n"
-			"\t  -- repr_vf_u_vsi_id: %s\n",
+			"\t  -- repr_vf_primary_vsi_id: %s\n"
+			"\t  -- repr_vf_backup_vsi_id: %s\n",
 			adapter->repr_priv_data->repr_id,
 			adapter->repr_priv_data->repr_q_id,
 			adapter->repr_priv_data->repr_pf_id,
 			adapter->repr_priv_data->repr_vf_id,
 			adapter->repr_priv_data->repr_vf_vsi_id,
-			sxe2_vsi_id_str(adapter->repr_priv_data->repr_vf_k_vsi_id,
+			sxe2_vsi_id_str(adapter->repr_priv_data->repr_vf_primary_vsi_id,
 					k_vsi_buf, sizeof(k_vsi_buf)),
-			sxe2_vsi_id_str(adapter->repr_priv_data->repr_vf_u_vsi_id,
+			sxe2_vsi_id_str(adapter->repr_priv_data->repr_vf_backup_vsi_id,
 					u_vsi_buf, sizeof(u_vsi_buf)));
 		goto l_end;
 	}
drivers/net/sxe2/sxe2_ethdev.h +2 -2
index c54e8a435e..158198d74b 100644
@@ -263,8 +263,8 @@ struct sxe2_repr_private_data {
 	uint16_t repr_pf_id;
 	uint16_t repr_vf_id;
 	uint16_t repr_vf_vsi_id;
-	uint16_t repr_vf_k_vsi_id;
-	uint16_t repr_vf_u_vsi_id;
+	uint16_t repr_vf_primary_vsi_id;
+	uint16_t repr_vf_backup_vsi_id;
 };
 
 struct sxe2_sched_hw_cap {
drivers/net/sxe2/sxe2_flow.c +2 -2
index 63cfc36968..cf54803301 100644
@@ -380,9 +380,9 @@ static int32_t sxe2_flow_src_split_proc(struct rte_eth_dev *dev,
 	if (adapter->switchdev_info.is_switchdev && adapter->is_dev_repr) {
 		flow_bond_num = 1;
 		flow_src_vsi[SXE2_MAX_DRV_TYPE_DPDK][0] =
-			adapter->repr_priv_data->repr_vf_u_vsi_id;
+			adapter->repr_priv_data->repr_vf_backup_vsi_id;
 		flow_src_vsi[SXE2_MAX_DRV_TYPE_KERNEL][0] =
-			adapter->repr_priv_data->repr_vf_k_vsi_id;
+			adapter->repr_priv_data->repr_vf_primary_vsi_id;
 	}
 
 	for (idx = 0; idx < flow_bond_num; idx++) {
drivers/net/sxe2/sxe2_switchdev.c +2 -2
index 44703cfb5c..efb1468b91 100644
@@ -312,9 +312,9 @@ int32_t sxe2_switchdev_repr_private_data_init(struct rte_eth_dev *dev,
 	repr_priv_data->repr_q_id = repr_id;
 	repr_priv_data->repr_pf_id = parent_adapter->pf_idx;
 	repr_priv_data->repr_vf_id = repr_id;
-	repr_priv_data->repr_vf_k_vsi_id =
+	repr_priv_data->repr_vf_primary_vsi_id =
 		parent_adapter->repr_ctxt.repr_vf_id[repr_id].kernel_vsi_id;
-	repr_priv_data->repr_vf_u_vsi_id =
+	repr_priv_data->repr_vf_backup_vsi_id =
 		parent_adapter->repr_ctxt.repr_vf_id[repr_id].dpdk_vsi_id;
 
 	repr_priv_data->repr_vf_vsi_id =
Signature · 1 line
2.52.0
#290 lore raw

PATCH v8 12/49 net/sxe2: clean up duplicate function declarations

In reply to [email protected]

From: Jie Liu <[email protected]>

Remove duplicate function declarations from the sxe2 driver headers:
- sxe2_drv_promisc_config, sxe2_drv_vsi_info_get and sxe2_drv_rxq_mapping_set in sxe2_cmd_chnl.h
- sxe2_dev_pci_seg_unmap in sxe2_ethdev.h
- sxe2_rx_pkts_scattered in sxe2_txrx_poll.h

---
 drivers/net/sxe2/sxe2_cmd_chnl.h  | 6 ------
 drivers/net/sxe2/sxe2_ethdev.h    | 2 --
 drivers/net/sxe2/sxe2_txrx_poll.h | 2 --
 3 files changed, 10 deletions(-)
drivers/net/sxe2/sxe2_cmd_chnl.h +0 -6
index d63caad526..294ac15db4 100644
@@ -65,8 +65,6 @@ int32_t sxe2_drv_ipsec_rxsa_delete(struct sxe2_adapter *adapter,
 int32_t sxe2_drv_ipsec_txsa_delete(struct sxe2_adapter *adapter,
 			       uint16_t sa_id);
 
-int32_t sxe2_drv_promisc_config(struct sxe2_adapter *adapter, bool set);
-
 int32_t sxe2_drv_udp_tunnel_add(struct sxe2_adapter *adapter,
 			    enum sxe2_udp_tunnel_protocol tunnel_proto,
 			    uint16_t udp_port);
@@ -84,8 +82,6 @@ int32_t sxe2_drv_get_udp_tunnel_port(struct sxe2_adapter *adapter,
 
 int32_t sxe2_drv_vsi_info_get(struct sxe2_adapter *adapter, struct sxe2_vsi *vsi);
 
-int32_t sxe2_drv_vsi_info_get(struct sxe2_adapter *adapter, struct sxe2_vsi *vsi);
-
 int32_t sxe2_drv_mac_link_status_get(struct sxe2_adapter *adapter);
 
 int32_t sxe2_drv_get_mac_stats(struct sxe2_adapter *adapter);
@@ -110,8 +106,6 @@ int32_t sxe2_drv_mapping_reset(struct rte_eth_dev *eth_dev);
 
 int32_t sxe2_drv_mapping_stats_info_clear(struct rte_eth_dev *eth_dev);
 
-int32_t sxe2_drv_rxq_mapping_set(struct rte_eth_dev *eth_dev, uint16_t queue_id, uint8_t pool_idx);
-
 int32_t sxe2_drv_allmulti_config(struct sxe2_adapter *adapter, bool set);
 
 int32_t sxe2_drv_uc_config(struct sxe2_adapter *adapter, struct rte_ether_addr *addr, bool add);
drivers/net/sxe2/sxe2_ethdev.h +0 -2
index 158198d74b..1409be74d3 100644
@@ -385,8 +385,6 @@ void sxe2_dev_pci_seg_unmap(struct sxe2_adapter *adapter, uint32_t res_type);
 
 int32_t sxe2_dev_pci_map_init(struct rte_eth_dev *dev);
 
-void sxe2_dev_pci_seg_unmap(struct sxe2_adapter *adapter, uint32_t res_type);
-
 int32_t sxe2_udp_tunnel_port_del_common(struct sxe2_adapter *ad,
 		enum sxe2_udp_tunnel_protocol tunnel_proto, uint16_t udp_port);
 
drivers/net/sxe2/sxe2_txrx_poll.h +0 -2
index 708e3839d7..bfa099c097 100644
@@ -13,8 +13,6 @@ uint16_t sxe2_tx_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t
 
 uint16_t sxe2_rx_pkts_scattered(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
 
-uint16_t sxe2_rx_pkts_scattered(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
-
 uint16_t sxe2_rx_pkts_scattered_split(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
 
 #endif /* SXE2_TXRX_POLL_H */
Signature · 1 line
2.52.0
#291 lore raw

PATCH v8 13/49 net/sxe2: fix null VSI dereference in device info

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_dev_infos_get() dereferences adapter->vsi_ctxt.main_vsi without checking for NULL, which can crash when the main VSI has not been created yet.

Add an early NULL check on vsi and return -EINVAL.

Fixes d8e4e075acb4 ("net/sxe2: add probing skeleton")
---
 drivers/net/sxe2/sxe2_ethdev.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/sxe2/sxe2_ethdev.c +4 -0
index 2e14c372f8..02f9ce3d32 100644
@@ -781,6 +781,10 @@ static int32_t sxe2_dev_infos_get(struct rte_eth_dev *dev,
 	struct sxe2_adapter *adapter = SXE2_DEV_PRIVATE_TO_ADAPTER(dev);
 	struct sxe2_vsi *vsi = adapter->vsi_ctxt.main_vsi;
 
+	if (unlikely(vsi == NULL)) {
+		PMD_LOG_ERR(INIT, "main vsi is NULL");
+		return -EINVAL;
+	}
 	dev_info->max_rx_queues = vsi->rxqs.q_cnt;
 	dev_info->max_tx_queues = vsi->txqs.q_cnt;
 	dev_info->min_rx_bufsize = SXE2_MIN_BUF_SIZE;
Signature · 1 line
2.52.0
#292 lore raw

PATCH v8 14/49 net/sxe2: fill MAC addresses in device info

In reply to [email protected]

From: Jie Liu <[email protected]>

Fill max_mac_addrs in sxe2_dev_infos_get() so applications can query the maximum number of MAC addresses supported by the device.

---
 drivers/net/sxe2/sxe2_ethdev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/sxe2/sxe2_ethdev.c +1 -0
index 02f9ce3d32..e85e34aa1a 100644
@@ -792,6 +792,7 @@ static int32_t sxe2_dev_infos_get(struct rte_eth_dev *dev,
 	dev_info->max_lro_pkt_size = SXE2_FRAME_SIZE_MAX * SXE2_RX_LRO_DESC_MAX_NUM;
 	dev_info->max_mtu = dev_info->max_rx_pktlen - SXE2_ETH_OVERHEAD;
 	dev_info->min_mtu = RTE_ETHER_MIN_MTU;
+	dev_info->max_mac_addrs = SXE2_NUM_MACADDR_MAX;
 
 	dev_info->rx_offload_capa =
 		RTE_ETH_RX_OFFLOAD_VLAN_STRIP |
Signature · 1 line
2.52.0
#293 lore raw

PATCH v8 15/49 net/sxe2: fix QinQ and RSS offload capability report

In reply to [email protected]

From: Jie Liu <[email protected]>

Make the QINQ offload capabilities conditional on the port VLAN
setting: only advertise RTE_ETH_TX_OFFLOAD_QINQ_INSERT, RTE_ETH_RX_OFFLOAD_QINQ_STRIP and RTE_ETH_RX_OFFLOAD_VLAN_FILTER when no port VLAN is configured. Report the buffer split supported header ptypes count in sxe2_buffer_split_supported_hdr_ptypes_get().

Fixes a2b79a93515e ("net/sxe2: support L2 filtering and MAC config")
---
 drivers/net/sxe2/sxe2_ethdev.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)
drivers/net/sxe2/sxe2_ethdev.c +13 -8
index e85e34aa1a..7a11a93dff 100644
@@ -804,15 +804,11 @@ static int32_t sxe2_dev_infos_get(struct rte_eth_dev *dev,
 		RTE_ETH_RX_OFFLOAD_SCTP_CKSUM |
 		RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM |
 		RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT |
-#ifndef RTE_LIBRTE_SXE2_16BYTE_RX_DESC
-		RTE_ETH_RX_OFFLOAD_QINQ_STRIP |
-#endif
 		RTE_ETH_RX_OFFLOAD_VLAN_EXTEND |
 		RTE_ETH_RX_OFFLOAD_TCP_LRO;
 
 	dev_info->tx_offload_capa =
 		RTE_ETH_TX_OFFLOAD_VLAN_INSERT |
-		RTE_ETH_TX_OFFLOAD_QINQ_INSERT |
 		RTE_ETH_TX_OFFLOAD_MULTI_SEGS |
 		RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE |
 		RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
@@ -855,14 +851,22 @@ static int32_t sxe2_dev_infos_get(struct rte_eth_dev *dev,
 		RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO;
 
 
-	if (adapter->cap_flags & SXE2_DEV_CAPS_OFFLOAD_PTP)
-		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_TIMESTAMP;
-
 	if (sxe2_ipsec_supported(adapter)) {
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_SECURITY;
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_SECURITY;
 	}
 
+	if (adapter->cap_flags & SXE2_DEV_CAPS_OFFLOAD_PTP)
+		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_TIMESTAMP;
+
+	if (!sxe2_dev_port_vlan_check(dev)) {
+		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_QINQ_INSERT;
+#ifndef RTE_LIBRTE_SXE2_16BYTE_RX_DESC
+		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_QINQ_STRIP;
+#endif
+		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_VLAN_FILTER;
+	}
+
 	if (adapter->cap_flags & SXE2_DEV_CAPS_OFFLOAD_RSS) {
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
 		dev_info->flow_type_rss_offloads  |= SXE2_RSS_HF_SUPPORT_ALL;
@@ -934,7 +938,7 @@ static int32_t sxe2_dev_infos_get(struct rte_eth_dev *dev,
 
 static const uint32_t *
 sxe2_buffer_split_supported_hdr_ptypes_get(struct rte_eth_dev *dev __rte_unused,
-					   size_t *no_of_elements __rte_unused)
+					   size_t *no_of_elements)
 {
 	static const uint32_t ptypes[] = {
 		RTE_PTYPE_L2_ETHER,
@@ -972,6 +976,7 @@ sxe2_buffer_split_supported_hdr_ptypes_get(struct rte_eth_dev *dev __rte_unused,
 
 		RTE_PTYPE_UNKNOWN
 	};
+	*no_of_elements = RTE_DIM(ptypes) - 1;
 
 	return ptypes;
 }
Signature · 1 line
2.52.0
#294 lore raw

PATCH v8 16/49 net/sxe2: use regular write for mapped registers

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_pci_map_write_reg() uses the write-combined store (SXE2_PCI_REG_WRITE_WC) to write control registers, which is intended for doorbell/tail writes and can be lossy or delayed for ordering sensitive register updates.

Add SXE2_PCI_REG_WRITE macro using a regular rte_write32() and use it in sxe2_pci_map_write_reg().

Fixes 8cebf80f1eda ("net/sxe2: support Rx interrupt")
---
 drivers/net/sxe2/sxe2_ethdev.c | 2 +-
 drivers/net/sxe2/sxe2_ethdev.h | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/net/sxe2/sxe2_ethdev.c +1 -1
index 7a11a93dff..589f09c113 100644
@@ -1439,7 +1439,7 @@ void sxe2_pci_map_write_reg(struct sxe2_adapter *adapter,
 		goto l_ret;
 	}
 
-	SXE2_PCI_REG_WRITE_WC(reg_addr, value);
+	SXE2_PCI_REG_WRITE(reg_addr, value);
 l_ret:
 	return;
 }
drivers/net/sxe2/sxe2_ethdev.h +2 -0
index 1409be74d3..cf1104144c 100644
@@ -355,6 +355,8 @@ struct sxe2_adapter {
 #define SXE2_DEV_PRIVATE_TO_ADAPTER(dev) \
 	((struct sxe2_adapter *)(dev)->data->dev_private)
 
+#define SXE2_PCI_REG_WRITE(reg, value) rte_write32((rte_cpu_to_le_32(value)), (reg))
+
 void *sxe2_pci_map_addr_get(struct sxe2_adapter *adapter,
 			    enum sxe2_pci_map_resource res_type,
 			    uint16_t idx_in_func);
Signature · 1 line
2.52.0
#295 lore raw

PATCH v8 17/49 net/sxe2: move PCI register read macro to common header

In reply to [email protected]

From: Jie Liu <[email protected]>

Move SXE2_PCI_REG_READ to sxe2_ethdev.h so the PCI register access macros are kept together in the common header, matching SXE2_PCI_REG_WRITE.

---
 drivers/net/sxe2/sxe2_ethdev.h | 1 +
 drivers/net/sxe2/sxe2_queue.h  | 2 --
 2 files changed, 1 insertion(+), 2 deletions(-)
drivers/net/sxe2/sxe2_ethdev.h +1 -0
index cf1104144c..f2557b28c3 100644
@@ -356,6 +356,7 @@ struct sxe2_adapter {
 	((struct sxe2_adapter *)(dev)->data->dev_private)
 
 #define SXE2_PCI_REG_WRITE(reg, value) rte_write32((rte_cpu_to_le_32(value)), (reg))
+#define SXE2_PCI_REG_READ(reg)         rte_read32(reg)
 
 void *sxe2_pci_map_addr_get(struct sxe2_adapter *adapter,
 			    enum sxe2_pci_map_resource res_type,
drivers/net/sxe2/sxe2_queue.h +0 -2
index a300b66771..10bdaf5b8d 100644
@@ -12,8 +12,6 @@
 #include "sxe2_drv_cmd.h"
 #include "sxe2_txrx_common.h"
 
-#define SXE2_PCI_REG_READ(reg)			\
-		rte_read32(reg)
 #define SXE2_PCI_REG_WRITE_WC(reg, value)			\
 		rte_write32_wc((rte_cpu_to_le_32(value)), reg)
 #define SXE2_PCI_REG_WRITE_WC_RELAXED(reg, value)		\
Signature · 1 line
2.52.0
#296 lore raw

PATCH v8 18/49 net/sxe2: validate PCI map resource type

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_dev_pci_res_seg_map() indexes adapter->map_ctxt.addr_info[] with res_type without bounds checking, which can access out of bounds when an invalid resource type is passed.

Add a bounds check on res_type and return -EINVAL.

Fixes 66a10eb60ebe ("net/sxe2: add PCI BAR mapping")
---
 drivers/net/sxe2/sxe2_ethdev.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/sxe2/sxe2_ethdev.c +6 -0
index 589f09c113..9ef93b8076 100644
@@ -1552,6 +1552,12 @@ int32_t sxe2_dev_pci_res_seg_map(struct sxe2_adapter *adapter,
 	struct sxe2_pci_map_addr_info *addr_info = NULL;
 	int32_t ret = 0;
 
+	if (unlikely(res_type >= SXE2_PCI_MAP_RES_MAX_COUNT)) {
+		PMD_DEV_LOG_ERR(adapter, INIT, "Invalid resource type %u", res_type);
+		ret = -EINVAL;
+		goto l_end;
+	}
+
 	addr_info = &adapter->map_ctxt.addr_info[res_type];
 	if (!addr_info || addr_info->bar_idx == SXE2_PCI_MAP_BAR_INVALID) {
 		PMD_DEV_LOG_ERR(adapter, INIT, "Invalid bar index with resource type %d", res_type);
Signature · 1 line
2.52.0
#297 lore raw

PATCH v8 19/49 net/sxe2: guard PCI BAR unmap when not initialized

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_dev_pci_map_uinit() calls sxe2_dev_pci_seg_unmap() and walks bar_info unconditionally. Only perform the unmap and free when bar_info has been allocated, so an uninitialized map context is handled cleanly.

Fixes 66a10eb60ebe ("net/sxe2: add PCI BAR mapping")
---
 drivers/net/sxe2/sxe2_ethdev.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/net/sxe2/sxe2_ethdev.c +6 -8
index 9ef93b8076..fdff4ae10f 100644
@@ -1773,14 +1773,13 @@ void sxe2_dev_pci_map_uinit(struct rte_eth_dev *dev)
 	uint8_t i = 0;
 
 	PMD_INIT_FUNC_TRACE();
+	if (map_ctxt->bar_info != NULL) {
+		(void)sxe2_dev_pci_seg_unmap(adapter, SXE2_PCI_MAP_RES_DOORBELL_RX_TAIL);
+		(void)sxe2_dev_pci_seg_unmap(adapter, SXE2_PCI_MAP_RES_DOORBELL_TX);
+		(void)sxe2_dev_pci_seg_unmap(adapter, SXE2_PCI_MAP_RES_IRQ_DYN);
+		(void)sxe2_dev_pci_seg_unmap(adapter, SXE2_PCI_MAP_RES_IRQ_ITR);
+		(void)sxe2_dev_pci_seg_unmap(adapter, SXE2_PCI_MAP_RES_IRQ_MSIX);
 
-	(void)sxe2_dev_pci_seg_unmap(adapter, SXE2_PCI_MAP_RES_DOORBELL_RX_TAIL);
-	(void)sxe2_dev_pci_seg_unmap(adapter, SXE2_PCI_MAP_RES_DOORBELL_TX);
-	(void)sxe2_dev_pci_seg_unmap(adapter, SXE2_PCI_MAP_RES_IRQ_DYN);
-	(void)sxe2_dev_pci_seg_unmap(adapter, SXE2_PCI_MAP_RES_IRQ_ITR);
-	(void)sxe2_dev_pci_seg_unmap(adapter, SXE2_PCI_MAP_RES_IRQ_MSIX);
-
-	if (map_ctxt != NULL && map_ctxt->bar_info != NULL) {
 		for (i = 0; i < map_ctxt->bar_cnt; i++) {
 			bar_info = &map_ctxt->bar_info[i];
 			if (bar_info != NULL && bar_info->seg_info != NULL) {
@@ -1791,7 +1790,6 @@ void sxe2_dev_pci_map_uinit(struct rte_eth_dev *dev)
 		rte_free(map_ctxt->bar_info);
 		map_ctxt->bar_info = NULL;
 	}
-
 	adapter->dev_info.dev_data = NULL;
 }
 
Signature · 1 line
2.52.0
#298 lore raw

PATCH v8 20/49 net/sxe2: fix null dereference in dev uninit

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_dev_uninit() calls rep_dev->dev_ops->dev_close() for each VF representor without checking that dev_ops or dev_close is present, which can crash when the representor device is not fully initialized.

Guard the call with NULL checks.

Fixes 635084db5d57 ("net/sxe2: support VF representors")
---
 drivers/net/sxe2/sxe2_ethdev.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/sxe2/sxe2_ethdev.c +5 -3
index fdff4ae10f..41ea67a607 100644
@@ -2074,9 +2074,11 @@ static int32_t sxe2_dev_uninit(struct rte_eth_dev *dev)
 	for (i = 0; i < adapter->repr_ctxt.nb_repr_vf; i++) {
 		rep_dev = adapter->repr_ctxt.vf_rep_eth_dev[i];
 		if (rep_dev) {
-			ret = rep_dev->dev_ops->dev_close(rep_dev);
-			if (ret)
-				goto l_end;
+			if (rep_dev->dev_ops && rep_dev->dev_ops->dev_close) {
+				ret = rep_dev->dev_ops->dev_close(rep_dev);
+				if (ret)
+					goto l_end;
+			}
 			if (rep_dev->intr_handle)
 				rte_intr_instance_free(rep_dev->intr_handle);
 			ret = rte_eth_dev_release_port(rep_dev);
Signature · 1 line
2.52.0
#299 lore raw

PATCH v8 21/49 net/sxe2: fix duplicated cleanup in dev close

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_dev_close() calls sxe2_switchdev_uninit() and sxe2_dev_pci_map_uinit() twice, and releases resources in an order that does not match the initialization sequence.

Remove the duplicated calls and align the teardown order with the device init order.

Fixes 8cebf80f1eda ("net/sxe2: support Rx interrupt")
---
 drivers/net/sxe2/sxe2_ethdev.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/sxe2/sxe2_ethdev.c +2 -4
index 41ea67a607..5d14e28d96 100644
@@ -2041,17 +2041,15 @@ static int32_t sxe2_dev_close(struct rte_eth_dev *dev)
 	(void)sxe2_queues_release(dev);
 	sxe2_mp_uninit(dev);
 	(void)sxe2_sched_uinit(dev);
-	(void)sxe2_rss_disable(dev);
 	(void)sxe2_flow_uninit(dev);
+	(void)sxe2_rss_disable(dev);
 	(void)sxe2_udp_tunnel_port_clear(dev);
-	sxe2_vsi_uninit(dev);
 	sxe2_security_uinit(dev);
 	sxe2_intr_uninit(dev);
 	(void)sxe2_switchdev_uninit(dev);
 	sxe2_sw_uninit(dev);
-	(void)sxe2_switchdev_uninit(dev);
-	sxe2_dev_pci_map_uinit(dev);
 	sxe2_eth_uinit(dev);
+	sxe2_vsi_uninit(dev);
 	sxe2_dev_pci_map_uinit(dev);
 	sxe2_free_repr_info(dev);
 	sxe2_fc_state_uinit(dev);
Signature · 1 line
2.52.0
#300 lore raw

PATCH v8 22/49 net/sxe2: align dev init and cleanup order

In reply to [email protected]

From: Jie Liu <[email protected]>

Move sxe2_eth_init() to be called before sxe2_sw_init() and rearrange the error cleanup labels so that resources are torn down in the reverse order of initialization.

---
 drivers/net/sxe2/sxe2_ethdev.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/net/sxe2/sxe2_ethdev.c +8 -8
index 5d14e28d96..5bce710b29 100644
@@ -1942,6 +1942,12 @@ static int32_t sxe2_dev_init(struct rte_eth_dev *dev,
 		goto init_switchdev_err;
 	}
 
+	ret = sxe2_eth_init(dev);
+	if (ret) {
+		PMD_LOG_ERR(INIT, "Failed to initialize eth parameters, ret=%d", ret);
+		goto init_eth_err;
+	}
+
 	ret = sxe2_sw_init(dev);
 	if (ret) {
 		PMD_LOG_ERR(INIT, "Failed to initialize sw parameters, ret=[%d]", ret);
@@ -1954,12 +1960,6 @@ static int32_t sxe2_dev_init(struct rte_eth_dev *dev,
 		goto init_irq_err;
 	}
 
-	ret = sxe2_eth_init(dev);
-	if (ret) {
-		PMD_LOG_ERR(INIT, "Failed to initialize eth parameters, ret=%d", ret);
-		goto init_eth_err;
-	}
-
 	ret = sxe2_security_init(dev);
 	if (ret) {
 		PMD_LOG_ERR(INIT, "Failed to initialize security, ret=%d", ret);
@@ -2014,12 +2014,12 @@ static int32_t sxe2_dev_init(struct rte_eth_dev *dev,
 init_rss_err:
 	sxe2_security_uinit(dev);
 init_security_err:
-	sxe2_eth_uinit(dev);
-init_eth_err:
 	sxe2_intr_uninit(dev);
 init_irq_err:
 	sxe2_sw_uninit(dev);
 init_sw_err:
+	sxe2_eth_uinit(dev);
+init_eth_err:
 	(void)sxe2_switchdev_uninit(dev);
 init_switchdev_err:
 init_dev_info_err:
Signature · 1 line
2.52.0
#301 lore raw

PATCH v8 23/49 net/sxe2: simplify switchdev representor matching

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_switchdev_repr_match() encodes the kernel representor ID and compares it against each requested port, which is fragile. Match the PF number and VF ID directly against the switchdev representor info instead, and drop the sxe2_switchdev_repr_id_encode_get() helper.

Fixes 635084db5d57 ("net/sxe2: support VF representors")
---
 drivers/net/sxe2/sxe2_ethdev.c | 72 +++++++++++++++++-----------------
 drivers/net/sxe2/sxe2_ethdev.h |  3 --
 2 files changed, 37 insertions(+), 38 deletions(-)
drivers/net/sxe2/sxe2_ethdev.c +37 -35
index 5bce710b29..08986e384f 100644
@@ -2149,42 +2149,25 @@ static int32_t sxe2_fw_version_string_get(struct rte_eth_dev *dev, char *fw_vers
 	return ret;
 }
 
-static uint16_t sxe2_switchdev_repr_id_encode_get(struct sxe2_switchdev_info *switchdev_info)
-{
-	enum rte_eth_representor_type type;
-	uint16_t repr = switchdev_info->vf_num;
-	uint32_t pf = switchdev_info->pf_num;
-
-	switch (switchdev_info->port_name_type) {
-	case SXE2_PHYS_PORT_NAME_TYPE_UPLINK:
-		if (!switchdev_info->representor)
-			return UINT16_MAX;
-		type = RTE_ETH_REPRESENTOR_PF;
-		pf = switchdev_info->mpesw_owner;
-		break;
-	case SXE2_PHYS_PORT_NAME_TYPE_PFVF:
-	default:
-		type = RTE_ETH_REPRESENTOR_VF;
-		break;
-	}
-
-	return SXE2_REPRESENTOR_ID(pf, type, repr);
-}
-
 static bool sxe2_switchdev_repr_match(struct sxe2_adapter *adapter,
 				   struct rte_eth_devargs *req_eth_da)
 {
-	uint32_t port_idx = 0;
-	uint32_t repr_idx;
-	uint16_t kernel_repr_id = sxe2_switchdev_repr_id_encode_get(&adapter->switchdev_info);
-	uint16_t repr_id;
+	uint16_t port_idx;
+	uint16_t repr_idx;
+	uint16_t vf_id;
+	uint16_t i;
 
 	switch (req_eth_da->type) {
 	case RTE_ETH_REPRESENTOR_PF:
+		if (adapter->switchdev_info.port_name_type !=
+			SXE2_PHYS_PORT_NAME_TYPE_UPLINK) {
+			rte_errno = EBUSY;
+			return false;
+		}
 		break;
 	case RTE_ETH_REPRESENTOR_VF:
 		if (adapter->switchdev_info.port_name_type !=
-		SXE2_PHYS_PORT_NAME_TYPE_PFVF) {
+			SXE2_PHYS_PORT_NAME_TYPE_PFVF) {
 			rte_errno = EBUSY;
 			return false;
 		}
@@ -2197,15 +2180,34 @@ static bool sxe2_switchdev_repr_match(struct sxe2_adapter *adapter,
 		return false;
 	}
 
+	if (req_eth_da->nb_ports > 0) {
+		for (port_idx = 0; port_idx < req_eth_da->nb_ports; ++port_idx) {
+			if (adapter->switchdev_info.pf_num == req_eth_da->ports[port_idx])
+				break;
+		}
+		if (port_idx == req_eth_da->nb_ports) {
+			PMD_DEV_LOG_DEBUG(adapter, DRV, "switchdev pf %u not match req pf",
+				adapter->switchdev_info.pf_num);
+			rte_errno = EBUSY;
+			return false;
+		}
+	}
+
 	for (repr_idx = 0; repr_idx < req_eth_da->nb_representor_ports; ++repr_idx) {
-		repr_id = SXE2_REPRESENTOR_ID(req_eth_da->ports[port_idx],
-					      req_eth_da->type,
-					      req_eth_da->representor_ports[repr_idx]);
-		if (repr_id == kernel_repr_id)
-			return true;
-	}
-	rte_errno = EBUSY;
-	return false;
+		for (i = 0; i < adapter->repr_ctxt.nb_vf; ++i) {
+			vf_id = rte_le_to_cpu_16(adapter->repr_ctxt.repr_vf_id[i].func_id);
+			if (vf_id == req_eth_da->representor_ports[repr_idx])
+				break;
+		}
+		if (i == adapter->repr_ctxt.nb_vf) {
+			PMD_DEV_LOG_DEBUG(adapter, DRV, "switchdev vf %u not match req vf(cnt:%u)",
+				req_eth_da->representor_ports[repr_idx], adapter->repr_ctxt.nb_vf);
+			rte_errno = EBUSY;
+			return false;
+		}
+	}
+
+	return true;
 }
 
 static int32_t sxe2_eth_pmd_probe_pf(struct sxe2_common_device *cdev,
drivers/net/sxe2/sxe2_ethdev.h +0 -3
index f2557b28c3..e818578319 100644
@@ -65,9 +65,6 @@ enum sxe2_fnav_tunnel_flag_type {
 #define upper_32_bits(n) ((uint32_t)(((n) >> 16) >> 16))
 #define lower_32_bits(n) ((uint32_t)((n) & 0xffffffff))
 
-#define SXE2_REPRESENTOR_ID(pf, type, repr) \
-		(((pf) << 14) + ((type) << 12) + ((repr) & 0xfff))
-
 #define SXE2_I2C_EEPROM_DEV_ADDR	0xA0
 #define SXE2_I2C_EEPROM_DEV_ADDR2	0xA2
 #define SXE2_MODULE_TYPE_SFP		0x03
Signature · 1 line
2.52.0
#302 lore raw

PATCH v8 24/49 net/sxe2: rename fnav cid manager symbols to flow

In reply to [email protected]

From: Jie Liu <[email protected]>

Rename the sxe2_fnav_cid_mgr, sxe2_fnav_cid_mgr_list_t, sxe2_fnav_count_resource and sxe2_fnav_get_filter_cid symbols to the sxe2_flow_* prefix for consistency with the flow module naming.

---
 drivers/net/sxe2/sxe2_cmd_chnl.c    |  2 +-
 drivers/net/sxe2/sxe2_cmd_chnl.h    |  2 +-
 drivers/net/sxe2/sxe2_flow.c        | 46 ++++++++++++++---------------
 drivers/net/sxe2/sxe2_flow.h        |  6 ++--
 drivers/net/sxe2/sxe2_flow_define.h | 12 ++++----
 5 files changed, 34 insertions(+), 34 deletions(-)
drivers/net/sxe2/sxe2_cmd_chnl.c +1 -1
index b09989fe50..3229c72597 100644
@@ -1800,7 +1800,7 @@ int32_t sxe2_drv_flow_fnav_free_stat(struct sxe2_adapter *adapter, uint32_t stat
 }
 
 int32_t sxe2_drv_flow_fnav_query_stat(struct sxe2_adapter *adapter,
-		struct sxe2_fnav_cid_mgr *mgr)
+		struct sxe2_flow_cid_mgr *mgr)
 {
 	struct sxe2_drv_flow_fnav_query_stat_req req = { 0 };
 	struct sxe2_drv_flow_fnav_query_stat_resp resp = { 0 };
drivers/net/sxe2/sxe2_cmd_chnl.h +1 -1
index 294ac15db4..cfea1a1f0e 100644
@@ -159,7 +159,7 @@ int32_t sxe2_drv_flow_fnav_get_stat_id(struct sxe2_adapter *adapter, uint32_t *s
 int32_t sxe2_drv_flow_fnav_free_stat(struct sxe2_adapter *adapter, uint32_t stat_id);
 
 int32_t sxe2_drv_flow_fnav_query_stat(struct sxe2_adapter *adapter,
-		struct sxe2_fnav_cid_mgr *mgr);
+		struct sxe2_flow_cid_mgr *mgr);
 
 int32_t sxe2_drv_srcvsi_prune_config(struct sxe2_adapter *adapter,
 		uint16_t *vsi_list, uint16_t vsi_cnt, bool set);
drivers/net/sxe2/sxe2_flow.c +23 -23

111 lines not on this page · raw message

drivers/net/sxe2/sxe2_flow.h +3 -3
index daaeedd4dc..8d47b11ff4 100644
@@ -14,16 +14,16 @@ int32_t sxe2_flow_init(struct rte_eth_dev *dev);
 
 int32_t sxe2_flow_uninit(struct rte_eth_dev *dev);
 
-int32_t sxe2_fnav_get_filter_cid(struct sxe2_adapter *adapter, struct sxe2_flow *flow);
+int32_t sxe2_flow_get_filter_cid(struct sxe2_adapter *adapter, struct sxe2_flow *flow);
 
 int32_t sxe2_flow_free_mgr(struct sxe2_adapter *adapter,
 		       struct sxe2_flow *flow,
-		       struct sxe2_fnav_cid_mgr **mgr_ptr,
+		       struct sxe2_flow_cid_mgr **mgr_ptr,
 		       struct rte_flow_error *error);
 
 int32_t sxe2_flow_query_mgr(struct sxe2_adapter *adapter,
 			struct sxe2_flow *flow,
-			struct sxe2_fnav_cid_mgr **mgr_ptr,
+			struct sxe2_flow_cid_mgr **mgr_ptr,
 			struct rte_flow_error *error);
 
 int32_t sxe2_flow_init_udp_tunnel_port(struct rte_eth_dev *dev);
drivers/net/sxe2/sxe2_flow_define.h +6 -6
index 263a573f04..8a5d871978 100644
@@ -98,8 +98,8 @@ struct rte_flow {
 };
 TAILQ_HEAD(rte_flow_list_t, rte_flow);
 
-struct sxe2_fnav_cid_mgr {
-	TAILQ_ENTRY(sxe2_fnav_cid_mgr) next;
+struct sxe2_flow_cid_mgr {
+	TAILQ_ENTRY(sxe2_flow_cid_mgr) next;
 	uint16_t stat_index;
 	uint32_t user_id;
 	uint32_t driver_id;
@@ -107,18 +107,18 @@ struct sxe2_fnav_cid_mgr {
 	uint64_t hits;
 	uint64_t bytes;
 };
-TAILQ_HEAD(sxe2_fnav_cid_mgr_list_t, sxe2_fnav_cid_mgr);
+TAILQ_HEAD(sxe2_flow_cid_mgr_list_t, sxe2_flow_cid_mgr);
 
-struct sxe2_fnav_count_resource {
+struct sxe2_flow_count_resource {
 	uint32_t count_type;
 	uint32_t global_index;
-	struct sxe2_fnav_cid_mgr_list_t fnav_cid_mgr_list;
+	struct sxe2_flow_cid_mgr_list_t flow_cid_mgr_list;
 };
 
 struct sxe2_flow_context {
 	struct rte_flow_list_t rte_flow_list;
 	rte_spinlock_t flow_list_lock;
-	struct sxe2_fnav_count_resource hw_res;
+	struct sxe2_flow_count_resource hw_res;
 	uint16_t tunnel_port_list[SXE2_FLOW_UDP_TUNNEL_MAX];
 	uint32_t fnav_inited;
 };
Signature · 1 line
2.52.0
#303 lore raw

PATCH v8 25/49 net/sxe2: move tunnel port helpers into flow module

In reply to [email protected]

From: Jie Liu <[email protected]>

Move sxe2_flow_parse_pattern_ipip, sxe2_flow_add_udp_tunnel_port and sxe2_flow_add_tunnel_port from sxe2_flow_parse_pattern.c into sxe2_flow.c as static helpers, and drop the public declaration of sxe2_flow_add_tunnel_port from the header, keeping the tunnel port handling internal to the flow module.

---
 drivers/net/sxe2/sxe2_flow.c               | 113 +++++++++++++++++++++
 drivers/net/sxe2/sxe2_flow_parse_pattern.c | 113 ---------------------
 drivers/net/sxe2/sxe2_flow_parse_pattern.h |   6 --
 3 files changed, 113 insertions(+), 119 deletions(-)
drivers/net/sxe2/sxe2_flow.c +113 -0
index a33b8606df..cd39385340 100644
@@ -550,6 +550,119 @@ int32_t sxe2_flow_init_udp_tunnel_port(struct rte_eth_dev *dev)
 	return ret;
 }
 
+static int32_t sxe2_flow_add_udp_tunnel_port(struct sxe2_adapter *adapter,
+					 enum sxe2_flow_udp_tunnel_protocol proto,
+					 struct sxe2_flow *flow,
+					 BITMAP_TYPE *flow_type)
+{
+	int32_t ret = 0;
+	uint16_t tun_port;
+
+	tun_port = adapter->flow_ctxt.tunnel_port_list[proto];
+	if (tun_port == 0xffff || tun_port == 0) {
+		ret = -EINVAL;
+		PMD_LOG_ERR(DRV, "UDP tunnel port not initialized, proto: %d", proto);
+		goto l_end;
+	}
+	if (!sxe2_test_bit(SXE2_EXPANSION_OUTER_UDP, flow_type)) {
+		ret = -EINVAL;
+		PMD_LOG_ERR(DRV, "UDP must be over tunnel");
+		goto l_end;
+	}
+	sxe2_set_bit(SXE2_FLOW_FLD_ID_UDP_DST_PORT, flow->pattern_outer.map_spec);
+	flow->pattern_outer.item_spec.udp.dest = rte_cpu_to_be_16(tun_port);
+l_end:
+	return ret;
+}
+
+static int32_t sxe2_flow_parse_pattern_ipip(struct sxe2_flow *flow, BITMAP_TYPE *flow_type)
+{
+	sxe2_set_bit(SXE2_EXPANSION_IPIP, flow_type);
+	if (sxe2_test_bit(SXE2_EXPANSION_OUTER_IPV4, flow_type)) {
+		sxe2_set_bit(SXE2_FLOW_FLD_ID_IPV4_PROT, flow->pattern_outer.map_spec);
+		if (sxe2_test_bit(SXE2_EXPANSION_IPV4, flow_type))
+			flow->pattern_outer.item_spec.ipv4.protocol = SXE2_FLOW_IP_PROTOCOL_IPV4;
+		if (sxe2_test_bit(SXE2_EXPANSION_IPV6, flow_type))
+			flow->pattern_outer.item_spec.ipv4.protocol = SXE2_FLOW_IP_PROTOCOL_IPV6;
+	}
+	if (sxe2_test_bit(SXE2_EXPANSION_OUTER_IPV6, flow_type)) {
+		sxe2_set_bit(SXE2_FLOW_FLD_ID_IPV6_PROT, flow->pattern_outer.map_spec);
+		if (sxe2_test_bit(SXE2_EXPANSION_ETH, flow_type)) {
+			flow->pattern_outer.item_spec.ipv6.nexthdr = SXE2_FLOW_IP_PROTOCOL_ETH;
+		} else {
+			if (sxe2_test_bit(SXE2_EXPANSION_IPV4, flow_type))
+				flow->pattern_outer.item_spec.ipv6.nexthdr =
+					SXE2_FLOW_IP_PROTOCOL_IPV4;
+			if (sxe2_test_bit(SXE2_EXPANSION_IPV6, flow_type))
+				flow->pattern_outer.item_spec.ipv6.nexthdr =
+					SXE2_FLOW_IP_PROTOCOL_IPV6;
+		}
+	}
+	return 0;
+}
+
+static int32_t sxe2_flow_add_tunnel_port(struct rte_eth_dev *dev,
+			struct rte_flow_error *error,
+			struct sxe2_flow *flow, BITMAP_TYPE *flow_type,
+			enum sxe2_flow_tunnel_type tunnel_type)
+{
+	int32_t ret = 0;
+	enum sxe2_flow_udp_tunnel_protocol proto = SXE2_FLOW_UDP_TUNNEL_MAX;
+	struct sxe2_adapter *adapter = SXE2_DEV_PRIVATE_TO_ADAPTER(dev);
+	struct sxe2_flow_pattern *pattern = &flow->pattern_outer;
+	switch (tunnel_type) {
+	case SXE2_FLOW_TUNNEL_TYPE_VXLAN:
+		if (sxe2_test_bit(SXE2_EXPANSION_ETH, flow_type)) {
+			proto = SXE2_FLOW_UDP_TUNNEL_PROTOCOL_VXLAN;
+		} else if (sxe2_test_bit(SXE2_EXPANSION_IPV4, flow_type) ||
+			sxe2_test_bit(SXE2_EXPANSION_IPV6, flow_type)) {
+			proto = SXE2_FLOW_UDP_TUNNEL_PROTOCOL_VXLAN_GPE;
+		}
+		break;
+	case SXE2_FLOW_TUNNEL_TYPE_GTPU:
+		proto = SXE2_FLOW_UDP_TUNNEL_PROTOCOL_GTP_U;
+		break;
+	case SXE2_FLOW_TUNNEL_TYPE_GENEVE:
+		proto = SXE2_FLOW_UDP_TUNNEL_PROTOCOL_GENEVE;
+		break;
+	case SXE2_FLOW_TUNNEL_TYPE_GRE:
+		if (sxe2_test_bit(SXE2_EXPANSION_OUTER_UDP, flow_type)) {
+			proto = SXE2_FLOW_UDP_TUNNEL_PROTOCOL_NVGRE;
+		} else {
+			if (sxe2_test_bit(SXE2_EXPANSION_OUTER_IPV4, flow_type)) {
+				pattern->item_spec.ipv4.protocol = SXE2_FLOW_IP_PROTOCOL_GRE;
+				sxe2_set_bit(SXE2_FLOW_FLD_ID_IPV4_PROT, pattern->map_spec);
+			}
+			if (sxe2_test_bit(SXE2_EXPANSION_OUTER_IPV6, flow_type)) {
+				pattern->item_spec.ipv6.nexthdr = SXE2_FLOW_IP_PROTOCOL_GRE;
+				sxe2_set_bit(SXE2_FLOW_FLD_ID_IPV6_PROT, pattern->map_spec);
+			}
+		}
+		break;
+	case SXE2_FLOW_TUNNEL_TYPE_IPIP:
+		ret = sxe2_flow_parse_pattern_ipip(flow, flow_type);
+		break;
+	default:
+		break;
+	}
+	if (proto != SXE2_FLOW_UDP_TUNNEL_MAX) {
+		ret = sxe2_flow_add_udp_tunnel_port(adapter, proto, flow, flow_type);
+		if (ret != 0) {
+			rte_flow_error_set(error, EINVAL,
+					RTE_FLOW_ERROR_TYPE_ITEM,
+					NULL, "Failed to add udp port for tunnel.");
+			PMD_LOG_ERR(DRV, "Failed to add udp port for tunnel, ret %d.", ret);
+			goto l_end;
+		}
+	}
+	if (tunnel_type != SXE2_FLOW_TUNNEL_TYPE_NONE) {
+		if (!sxe2_test_bit(SXE2_EXPANSION_OUTER_UDP, flow_type))
+			sxe2_set_bit(SXE2_FLOW_HDR_IPV_OTHER, pattern->hdrs);
+	}
+l_end:
+	return ret;
+}
+
 static int32_t sxe2_flowlist_add_tunnel_port(struct rte_eth_dev *dev,
 			struct rte_flow *flow_list,
 			struct rte_flow_error *error)
drivers/net/sxe2/sxe2_flow_parse_pattern.c +0 -113

119 lines not on this page · raw message

drivers/net/sxe2/sxe2_flow_parse_pattern.h +0 -6
index 8442c35cae..69d83a6ea6 100644
@@ -37,10 +37,4 @@ int32_t sxe2_flow_parse_pattern(struct rte_eth_dev *dev,
 			    struct rte_flow_error *error,
 			    struct sxe2_flow *flow);
 
-int32_t sxe2_flow_add_tunnel_port(struct rte_eth_dev *dev,
-			      struct rte_flow_error *error,
-			      struct sxe2_flow *flow,
-			      BITMAP_TYPE *flow_type,
-			      enum sxe2_flow_tunnel_type tunnel_type);
-
 #endif /* SXE2_FLOW_PARSE_PATTERN_H_ */
Signature · 1 line
2.52.0
#304 lore raw

PATCH v8 26/49 net/sxe2: add ACL engine event statistics support

In reply to [email protected]

From: Jie Liu <[email protected]>

Add statistics support for the ACL flow engine to track packet hits and bytes, enabling flow aging and traffic monitoring for ACL rules.

- Add acl-stat-type devarg to configure the statistics type
- Implement sxe2_drv_flow_acl_get_stat_id/free_stat/query_stat
- Handle the ACL engine in flow create/destroy/query paths
- Add fnav_hw_res and acl_hw_res count resources

---
 doc/guides/nics/sxe2.rst                  | 11 +++
 drivers/net/sxe2/sxe2_cmd_chnl.c          | 71 ++++++++++++++++++
 drivers/net/sxe2/sxe2_cmd_chnl.h          |  7 ++
 drivers/net/sxe2/sxe2_drv_cmd.h           |  7 ++
 drivers/net/sxe2/sxe2_dump.c              |  2 +
 drivers/net/sxe2/sxe2_ethdev.c            | 23 ++++--
 drivers/net/sxe2/sxe2_ethdev.h            |  1 +
 drivers/net/sxe2/sxe2_flow.c              | 90 ++++++++++++++++++-----
 drivers/net/sxe2/sxe2_flow_define.h       |  5 +-
 drivers/net/sxe2/sxe2_flow_parse_action.c | 28 ++++---
 10 files changed, 209 insertions(+), 36 deletions(-)
doc/guides/nics/sxe2.rst +11 -0
index 8278a5f108..c5b400a8ba 100644
@@ -98,6 +98,17 @@ Runtime Configuration
 
   Default value is 3 (count both packets and bytes).
 
+- ``acl-stat-type`` parameter [int]
+
+  This parameter controls the ACL flow engine statistics type
+  used for flow rule hit counting (via ``rte_flow_query``).
+
+  - 1: Only count the number of packets.
+  - 2: Only count the number of bytes.
+  - 3: Count both packets and bytes (default).
+
+  Default value is 3 (count both packets and bytes).
+
 - ``drv-sw-stats`` parameter [int]
 
   This parameter controls whether per-packet software statistics (SW stats)
drivers/net/sxe2/sxe2_cmd_chnl.c +71 -0

77 lines not on this page · raw message

drivers/net/sxe2/sxe2_cmd_chnl.h +7 -0
index cfea1a1f0e..7d07068bfc 100644
@@ -161,6 +161,13 @@ int32_t sxe2_drv_flow_fnav_free_stat(struct sxe2_adapter *adapter, uint32_t stat
 int32_t sxe2_drv_flow_fnav_query_stat(struct sxe2_adapter *adapter,
 		struct sxe2_flow_cid_mgr *mgr);
 
+int32_t sxe2_drv_flow_acl_get_stat_id(struct sxe2_adapter *adapter, uint32_t *stat_id);
+
+int32_t sxe2_drv_flow_acl_free_stat(struct sxe2_adapter *adapter, uint32_t stat_id);
+
+int32_t sxe2_drv_flow_acl_query_stat(struct sxe2_adapter *adapter,
+			struct sxe2_flow_cid_mgr *mgr);
+
 int32_t sxe2_drv_srcvsi_prune_config(struct sxe2_adapter *adapter,
 		uint16_t *vsi_list, uint16_t vsi_cnt, bool set);
 
drivers/net/sxe2/sxe2_drv_cmd.h +7 -0
index 03ef3b315d..01fd813ed1 100644
@@ -824,6 +824,13 @@ enum sxe2_drv_cmd_code {
 	SXE2_DRV_CMD_OPT_EEP_GET =
 		SXE2_MK_DRV_CMD(SXE2_DRV_CMD_MODULE_OPT, 1),
 
+	SXE2_DRV_CMD_FLOW_ACL_STAT_QUERY =
+		SXE2_MK_DRV_CMD(SXE2_DRV_CMD_MODULE_ACL, 1),
+	SXE2_DRV_CMD_FLOW_ACL_STAT_ALLOC =
+		SXE2_MK_DRV_CMD(SXE2_DRV_CMD_MODULE_ACL, 2),
+	SXE2_DRV_CMD_FLOW_ACL_STAT_FREE =
+		SXE2_MK_DRV_CMD(SXE2_DRV_CMD_MODULE_ACL, 3),
+
 };
 
 #endif /* SXE2_DRV_CMD_H */
drivers/net/sxe2/sxe2_dump.c +2 -0
index 590219f502..31f7d6ba61 100644
@@ -80,12 +80,14 @@ sxe2_dump_dev_args_info(FILE *file, struct rte_eth_dev *dev)
 		"\t  -- no_sched_mode: %s\n"
 		"\t  -- flow-duplicate-pattern: %u\n"
 		"\t  -- fnav-stat-type: %u\n"
+		"\t  -- acl-stat-type: %u\n"
 		"\t  -- sched_layer_mode: %u\n"
 		"\t  -- rx_low_latency: %s\n"
 		"\t  -- function-flow-direct: %s\n",
 		adapter->devargs.no_sched_mode ? "On" : "Off",
 		adapter->devargs.flow_dup_pattern_mode,
 		adapter->devargs.fnav_stat_type,
+		adapter->devargs.acl_stat_type,
 		adapter->devargs.sched_layer_mode,
 		adapter->devargs.rx_low_latency ? "On" : "Off",
 		adapter->devargs.func_flow_direct_en ? "On" : "Off");
drivers/net/sxe2/sxe2_ethdev.c +16 -7
index 08986e384f..77a31eb8a1 100644
@@ -72,6 +72,7 @@ static const struct rte_pci_id pci_id_sxe2_tbl[] = {
 #define SXE2_DEVARG_FLOW_DUP_PATTERN_MODE "flow-duplicate-pattern"
 #define SXE2_DEVARG_FUNC_FLOW_DIRCT "function-flow-direct"
 #define SXE2_DEVARG_FNAV_STAT_TYPE "fnav-stat-type"
+#define SXE2_DEVARG_ACL_STAT_TYPE "acl-stat-type"
 #define SXE2_DEVARG_NO_SCHED_MODE "no-sched-mode"
 #define SXE2_DEVARG_SCHED_LAYER_MODE "sched-layer-mode"
 #define SXE2_DEVARG_RX_LOW_LATENCY "rx-low-latency"
@@ -981,11 +982,11 @@ sxe2_buffer_split_supported_hdr_ptypes_get(struct rte_eth_dev *dev __rte_unused,
 	return ptypes;
 }
 
-static int32_t sxe2_parse_fnav_stat_type(const char *key, const char *value, void *args)
+static int32_t sxe2_parse_stat_type(const char *key, const char *value, void *args)
 {
 	int32_t ret = -EINVAL;
 	uint8_t *num = (uint8_t *)args;
-	unsigned long fnav_stat_type;
+	unsigned long stat_type;
 	char *endptr = NULL;
 
 	if (value == NULL || args == NULL) {
@@ -993,19 +994,19 @@ static int32_t sxe2_parse_fnav_stat_type(const char *key, const char *value, voi
 		goto l_end;
 	}
 	errno = 0;
-	fnav_stat_type = strtoul(value, &endptr, 10);
+	stat_type = strtoul(value, &endptr, 10);
 	if (errno != 0 || endptr == value || *endptr != '\0') {
 		PMD_LOG_WARN(INIT, "%s: \"%s\" is not a valid int value.",
 			key, value);
 		goto l_end;
 	}
-	if (fnav_stat_type > SXE2_FNAV_STAT_ENA_ALL ||
-		fnav_stat_type == SXE2_FNAV_STAT_ENA_NONE) {
+	if (stat_type > SXE2_FNAV_STAT_ENA_ALL ||
+		stat_type == SXE2_FNAV_STAT_ENA_NONE) {
 		PMD_LOG_ERR(INIT, "%s: \"%s\" out of range [1-3].",
 			key, value);
 		goto l_end;
 	}
-	*num = (uint8_t)fnav_stat_type;
+	*num = (uint8_t)stat_type;
 	ret = 0;
 l_end:
 	return ret;
@@ -1187,13 +1188,20 @@ static int32_t sxe2_args_parse(struct rte_eth_dev *dev, struct sxe2_dev_kvargs_i
 	if (kvargs == NULL)
 		goto l_end;
 	ret = sxe2_kvargs_process(kvargs, SXE2_DEVARG_FNAV_STAT_TYPE,
-				 &sxe2_parse_fnav_stat_type,
+				 &sxe2_parse_stat_type,
 				 &adapter->devargs.fnav_stat_type);
 	if (ret) {
 		PMD_DEV_LOG_ERR(adapter, INIT, "Failed to parse fnav stat type, ret:%d", ret);
 		goto l_end;
 	}
 
+	ret = sxe2_kvargs_process(kvargs, SXE2_DEVARG_ACL_STAT_TYPE,
+				 &sxe2_parse_stat_type, &adapter->devargs.acl_stat_type);
+	if (ret) {
+		PMD_DEV_LOG_ERR(adapter, INIT, "Failed to parse acl stat type, ret:%d", ret);
+		goto l_end;
+	}
+
 	ret = sxe2_kvargs_process(kvargs, SXE2_DEVARG_NO_SCHED_MODE,
 				 &sxe2_parse_bool,
 				 &adapter->devargs.no_sched_mode);
@@ -2366,6 +2374,7 @@ RTE_PMD_REGISTER_PARAM_STRING(net_sxe2,
 	"flow-duplicate-pattern=<0|1|2> "
 	"function-flow-direct=<0|1> "
 	"fnav-stat-type=<1|2|3> "
+	"acl-stat-type=<1|2|3> "
 	"no-sched-mode=<0|1> "
 	"sched-layer-mode=<0-3> "
 	"rx-low-latency=<0|1>");
drivers/net/sxe2/sxe2_ethdev.h +1 -0
index e818578319..e9f78fe57f 100644
@@ -135,6 +135,7 @@ struct sxe2_devargs {
 	uint8_t flow_dup_pattern_mode;
 	uint8_t func_flow_direct_en;
 	uint8_t fnav_stat_type;
+	uint8_t acl_stat_type;
 	uint8_t no_sched_mode;
 	uint8_t sched_layer_mode;
 	uint8_t rx_low_latency;
drivers/net/sxe2/sxe2_flow.c +73 -17

163 lines not on this page · raw message

drivers/net/sxe2/sxe2_flow_define.h +3 -2
index 8a5d871978..d04499f5cb 100644
@@ -100,7 +100,7 @@ TAILQ_HEAD(rte_flow_list_t, rte_flow);
 
 struct sxe2_flow_cid_mgr {
 	TAILQ_ENTRY(sxe2_flow_cid_mgr) next;
-	uint16_t stat_index;
+	uint32_t stat_index;
 	uint32_t user_id;
 	uint32_t driver_id;
 	uint32_t count_type;
@@ -118,7 +118,8 @@ struct sxe2_flow_count_resource {
 struct sxe2_flow_context {
 	struct rte_flow_list_t rte_flow_list;
 	rte_spinlock_t flow_list_lock;
-	struct sxe2_flow_count_resource hw_res;
+	struct sxe2_flow_count_resource fnav_hw_res;
+	struct sxe2_flow_count_resource acl_hw_res;
 	uint16_t tunnel_port_list[SXE2_FLOW_UDP_TUNNEL_MAX];
 	uint32_t fnav_inited;
 };
drivers/net/sxe2/sxe2_flow_parse_action.c +18 -10
index a9559e2d7e..03ada4e8a6 100644
@@ -953,7 +953,8 @@ static int32_t sxe2_flow_check_actions(struct rte_eth_dev *dev __rte_unused, str
 		}
 	}
 
-	if (engine_type == SXE2_FLOW_ENGINE_FNAV) {
+	if (engine_type == SXE2_FLOW_ENGINE_FNAV ||
+		engine_type == SXE2_FLOW_ENGINE_ACL) {
 		if (vsi_num) {
 			flow->action.q_region.q_index = 0;
 			flow->action.q_region.region = 7;
@@ -980,6 +981,7 @@ int32_t sxe2_flow_parse_action(struct rte_eth_dev *dev,
 	uint8_t action_num[SXE2_FLOW_ACTION_MAX] = {0};
 	enum sxe2_flow_engine_type engine_type = flow->engine_type;
 	struct sxe2_adapter *adapter = SXE2_DEV_PRIVATE_TO_ADAPTER(dev);
+	struct sxe2_flow_count_resource *hw_res = NULL;
 
 	sxe2_flow_action_pre(flow);
 
@@ -988,7 +990,8 @@ int32_t sxe2_flow_parse_action(struct rte_eth_dev *dev,
 		case RTE_FLOW_ACTION_TYPE_VOID:
 			break;
 		case RTE_FLOW_ACTION_TYPE_PASSTHRU:
-			if (engine_type == SXE2_FLOW_ENGINE_FNAV) {
+			if (engine_type == SXE2_FLOW_ENGINE_FNAV ||
+				engine_type == SXE2_FLOW_ENGINE_ACL) {
 				sxe2_set_bit(SXE2_FLOW_ACTION_PASSTHRU, flow->action.act_types);
 				action_num[SXE2_FLOW_ACTION_PASSTHRU]++;
 			} else {
@@ -1035,14 +1038,9 @@ int32_t sxe2_flow_parse_action(struct rte_eth_dev *dev,
 			break;
 		case RTE_FLOW_ACTION_TYPE_COUNT:
 			if (engine_type == SXE2_FLOW_ENGINE_FNAV) {
-				sxe2_set_bit(SXE2_FLOW_ACTION_COUNT, flow->action.act_types);
-				act_count = action->conf;
-				flow->action.count.user_id = act_count->id;
-				flow->action.count.driver_id = 0;
-				if (flow->action.count.user_id == 0)
-					flow->action.count.driver_id =
-						++adapter->flow_ctxt.hw_res.global_index;
-				action_num[SXE2_FLOW_ACTION_COUNT]++;
+				hw_res = &adapter->flow_ctxt.fnav_hw_res;
+			} else if (engine_type == SXE2_FLOW_ENGINE_ACL) {
+				hw_res = &adapter->flow_ctxt.acl_hw_res;
 			} else {
 				rte_flow_error_set(error, ENOTSUP,
 					RTE_FLOW_ERROR_TYPE_ACTION, action,
@@ -1052,6 +1050,16 @@ int32_t sxe2_flow_parse_action(struct rte_eth_dev *dev,
 				ret = -EINVAL;
 				goto l_end;
 			}
+			sxe2_set_bit(SXE2_FLOW_ACTION_COUNT, flow->action.act_types);
+			act_count = action->conf;
+			flow->action.count.user_id =
+				(act_count == NULL) ? 0 : act_count->id;
+			flow->action.count.driver_id = 0;
+			if (flow->action.count.user_id == 0) {
+				flow->action.count.driver_id =
+					++hw_res->global_index;
+			}
+			action_num[SXE2_FLOW_ACTION_COUNT]++;
 			break;
 		case RTE_FLOW_ACTION_TYPE_RSS:
 			if (engine_type == SXE2_FLOW_ENGINE_RSS) {
Signature · 1 line
2.52.0
#305 lore raw

PATCH v8 27/49 net/sxe2: enable FDIR on all Rx queues

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_flow_init() always sets fnav_inited, so enable FDIR on every Rx queue during queue init by setting rxq->fnav_enable. FDIR/FNAV flags are required for flow rules and ACL statistics, so every Rx queue must have them enabled. This makes the fnav blocks in the vectorized Rx paths live on all queues.

---
 drivers/net/sxe2/sxe2_queue.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/sxe2/sxe2_queue.c +2 -0
index afb2681b72..3aaa14c685 100644
@@ -39,6 +39,8 @@ int32_t sxe2_queues_init(struct rte_eth_dev *dev)
 		rxq->rx_buf_len = RTE_MIN(rxq->rx_buf_len, SXE2_RX_MAX_DATA_BUF_SIZE);
 		if (frame_size > rxq->rx_buf_len)
 			dev->data->scattered_rx = 1;
+		if (adapter->flow_ctxt.fnav_inited)
+			rxq->fnav_enable = true;
 	}
 
 	adapter->ptp_ctxt.mbuf_rx_ts_offset = -1;
Signature · 1 line
2.52.0
#306 lore raw

PATCH v8 28/49 net/sxe2: refactor primary process MP message handling

In reply to [email protected]

From: Jie Liu <[email protected]>

Extract the multi-process work logic into the sxe2_mp_do_primary_work helper and operate on a copy of the request in the primary handler so the original message is not modified. Simplify the reply construction and return -ENOENT instead of -EINVAL when no response is received from the primary process.

Fixes 5db446ba97b0 ("net/sxe2: support statistics and multi-process")
---
 drivers/net/sxe2/sxe2_mp.c | 59 ++++++++++++++++++++++----------------
 1 file changed, 34 insertions(+), 25 deletions(-)
drivers/net/sxe2/sxe2_mp.c +34 -25
index a4a5c76495..93a11150a9 100644
@@ -29,16 +29,11 @@ static int32_t sxe2_mp_secondary_handle(const struct rte_mp_msg *mp_msg,
 					 const void *peer);
 
 static int32_t
-sxe2_mp_primary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
+sxe2_mp_do_primary_work(struct sxe2_mp_param *param)
 {
-	struct rte_mp_msg reply;
-	const struct sxe2_mp_param *param =
-			(const struct sxe2_mp_param *)mp_msg->param;
-	struct sxe2_mp_param *reply_param = (struct sxe2_mp_param *)reply.param;
 	struct rte_eth_dev *dev;
-	int32_t ret = 0;
 	struct sxe2_mp_shared_data *mz_data;
-	int32_t send_reply = 0;
+	int32_t ret = 0;
 	int32_t cnt = 0;
 
 	if (!rte_eth_dev_is_valid_port(param->port_id)) {
@@ -49,24 +44,21 @@ sxe2_mp_primary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
 	}
 
 	dev = &rte_eth_devices[param->port_id];
-	sxe2_mp_mz = rte_memzone_lookup(SXE2_MP_MZ_NAME);
+
 	if (sxe2_mp_mz == NULL) {
-		PMD_LOG_ERR(DRV, "Failed to lookup memzone %s", SXE2_MP_MZ_NAME);
-		ret = -ENOENT;
-		goto out;
+		sxe2_mp_mz = rte_memzone_lookup(SXE2_MP_MZ_NAME);
+		if (sxe2_mp_mz == NULL) {
+			PMD_LOG_ERR(DRV, "Failed to lookup memzone %s",
+					SXE2_MP_MZ_NAME);
+			ret = -ENOENT;
+			goto out;
+		}
 	}
 
 	mz_data = (struct sxe2_mp_shared_data *)sxe2_mp_mz->addr;
-	send_reply = 1;
-
-	memset(&reply, 0, sizeof(reply));
-	(void)strlcpy(reply.name, SXE2_MP_NAME, sizeof(reply.name));
-	reply.len_param = sizeof(*reply_param);
-
 	switch (param->type) {
 	case SXE2_MP_REQ_GET_STATS:
-		ret = sxe2_stats_info_get(dev,
-					  &mz_data->payload.stats_blk.stats,
+		ret = sxe2_stats_info_get(dev, &mz_data->payload.stats_blk.stats,
 					  &mz_data->payload.stats_blk.qstats);
 		break;
 	case SXE2_MP_REQ_GET_XSTATS:
@@ -88,15 +80,32 @@ sxe2_mp_primary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
 	default:
 		PMD_LOG_ERR(DRV, "primary process: unrecognized msg type: %d",
 				param->type);
-		send_reply = false;
 		ret = -EINVAL;
-		goto out;
+		break;
 	}
+
 out:
-	if (!send_reply)
-		return ret;
+	param->result = ret;
+	return ret;
+}
 
-	reply_param->result = ret;
+static int32_t
+sxe2_mp_primary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
+{
+	struct rte_mp_msg reply;
+	struct sxe2_mp_param *reply_param = (struct sxe2_mp_param *)reply.param;
+	const struct sxe2_mp_param *param =
+			(const struct sxe2_mp_param *)mp_msg->param;
+	struct sxe2_mp_param param_copy;
+
+	memset(&reply, 0, sizeof(reply));
+	(void)strlcpy(reply.name, SXE2_MP_NAME, sizeof(reply.name));
+	reply.len_param = sizeof(*reply_param);
+
+	param_copy = *param;
+	(void)sxe2_mp_do_primary_work(&param_copy);
+
+	reply_param->result = param_copy.result;
 	reply_param->type = param->type;
 	reply_param->port_id = param->port_id;
 
@@ -275,7 +284,7 @@ int32_t sxe2_mp_request_simple(struct rte_eth_dev *dev,
 	if (reply.nb_received == 0) {
 		PMD_LOG_ERR(DRV, "No response received from primary for type=%d, port %u",
 			type, dev->data->port_id);
-		ret = -EINVAL;
+		ret = -ENOENT;
 		goto out;
 	}
 
Signature · 1 line
2.52.0
#307 lore raw

PATCH v8 29/49 net/sxe2: refactor Tx queue reset operations

In reply to [email protected]

From: Jie Liu <[email protected]>

Extract the descriptor ring reset loop into a sxe2_tx_queue_desc_ring_reset helper and reuse it from both the scalar and vectorized queue reset paths. Add a sxe2_tx_queue_reset_vec entry point for vectorized queues, export sxe2_tx_buffer_ring_free for reuse outside the module (clearing the buffer ring pointer after freeing it), and add sxe2_tx_vec_ops_get to build the vectorized Tx queue operations table used by the vector path setup.

---
 drivers/net/sxe2/sxe2_tx.c       | 42 +++++++++++++++++++++++---------
 drivers/net/sxe2/sxe2_tx.h       |  4 +++
 drivers/net/sxe2/sxe2_txrx_vec.c | 17 ++++++++++---
 3 files changed, 49 insertions(+), 14 deletions(-)
drivers/net/sxe2/sxe2_tx.c +31 -11
index f49238ceef..94a6e9afc7 100644
@@ -19,6 +19,17 @@ static void *sxe2_tx_doorbell_addr_get(struct sxe2_adapter *adapter, uint16_t qu
 				     queue_id);
 }
 
+static void sxe2_tx_queue_desc_ring_reset(struct sxe2_tx_queue *txq)
+{
+	uint16_t i;
+	static const union sxe2_tx_data_desc zeroed_desc = {{0}};
+
+	for (i = 0; i < txq->ring_depth; i++) {
+		txq->desc_ring[i] = zeroed_desc;
+		txq->desc_ring[i].wb.dd = rte_cpu_to_le_64(SXE2_TX_DESC_DTYPE_DESC_DONE);
+	}
+}
+
 static void sxe2_tx_tail_init(struct sxe2_adapter *adapter, struct sxe2_tx_queue *txq)
 {
 	txq->tdt_reg_addr = sxe2_tx_doorbell_addr_get(adapter, txq->queue_id);
@@ -28,20 +39,12 @@ static void sxe2_tx_tail_init(struct sxe2_adapter *adapter, struct sxe2_tx_queue
 void __rte_cold sxe2_tx_queue_reset(struct sxe2_tx_queue *txq)
 {
 	uint16_t prev, i;
-	volatile union sxe2_tx_data_desc *txd;
-	static const union sxe2_tx_data_desc zeroed_desc = {{0}};
 	struct sxe2_tx_buffer *tx_buffer = txq->buffer_ring;
 
-	for (i = 0; i < txq->ring_depth; i++)
-		txq->desc_ring[i] = zeroed_desc;
+	sxe2_tx_queue_desc_ring_reset(txq);
 
 	prev = txq->ring_depth - 1;
 	for (i = 0; i < txq->ring_depth; i++) {
-		txd = &txq->desc_ring[i];
-		if (txd == NULL)
-			continue;
-
-		txd->wb.dd = rte_cpu_to_le_64(SXE2_TX_DESC_DTYPE_DESC_DONE);
 		tx_buffer[i].mbuf       = NULL;
 		tx_buffer[i].last_id    = i;
 		tx_buffer[prev].next_id = i;
@@ -56,6 +59,21 @@ void __rte_cold sxe2_tx_queue_reset(struct sxe2_tx_queue *txq)
 	txq->next_rs       = txq->rs_thresh  - 1;
 }
 
+void __rte_cold sxe2_tx_queue_reset_vec(struct sxe2_tx_queue *txq)
+{
+	sxe2_tx_queue_desc_ring_reset(txq);
+
+	memset(txq->buffer_ring, 0,
+		sizeof(struct sxe2_tx_buffer) * txq->ring_depth);
+
+	txq->desc_used_num = 0;
+	txq->desc_free_num = txq->ring_depth - 1;
+	txq->next_use      = 0;
+	txq->next_clean    = txq->ring_depth - 1;
+	txq->next_dd       = txq->rs_thresh  - 1;
+	txq->next_rs       = txq->rs_thresh  - 1;
+}
+
 void __rte_cold sxe2_tx_queue_mbufs_release(struct sxe2_tx_queue *txq)
 {
 	uint32_t i;
@@ -70,10 +88,12 @@ void __rte_cold sxe2_tx_queue_mbufs_release(struct sxe2_tx_queue *txq)
 	}
 }
 
-static void sxe2_tx_buffer_ring_free(struct sxe2_tx_queue *txq)
+void __rte_cold sxe2_tx_buffer_ring_free(struct sxe2_tx_queue *txq)
 {
-	if (txq != NULL && txq->buffer_ring != NULL)
+	if (txq != NULL && txq->buffer_ring != NULL) {
 		rte_free(txq->buffer_ring);
+		txq->buffer_ring = NULL;
+	}
 }
 
 const struct sxe2_txq_ops sxe2_default_txq_ops = {
drivers/net/sxe2/sxe2_tx.h +4 -0
index f4823126b3..bc5ff1c2bc 100644
@@ -9,6 +9,10 @@
 
 void __rte_cold sxe2_tx_queue_reset(struct sxe2_tx_queue *txq);
 
+void __rte_cold sxe2_tx_queue_reset_vec(struct sxe2_tx_queue *txq);
+
+void __rte_cold sxe2_tx_buffer_ring_free(struct sxe2_tx_queue *txq);
+
 int32_t __rte_cold sxe2_tx_queue_start(struct rte_eth_dev *dev, uint16_t queue_id);
 
 void sxe2_tx_queue_mbufs_release(struct sxe2_tx_queue *txq);
drivers/net/sxe2/sxe2_txrx_vec.c +14 -3
index cf004f5eb2..1442d5d119 100644
@@ -8,6 +8,14 @@
 #include "sxe2_ethdev.h"
 #include "sxe2_common_log.h"
 
+static void sxe2_tx_queue_mbufs_release_vec(struct sxe2_tx_queue *txq);
+
+static const struct sxe2_txq_ops sxe2_tx_vec_ops = {
+	.queue_reset      = sxe2_tx_queue_reset_vec,
+	.mbufs_release    = sxe2_tx_queue_mbufs_release_vec,
+	.buffer_ring_free = sxe2_tx_buffer_ring_free,
+};
+
 int32_t __rte_cold sxe2_rx_vec_support_check(struct rte_eth_dev *dev, uint32_t *vec_flags)
 {
 	struct sxe2_rx_queue *rxq;
@@ -230,10 +238,13 @@ int32_t __rte_cold sxe2_tx_queues_vec_prepare(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_tx_queues; ++i) {
 		txq = dev->data->tx_queues[i];
 		if (txq == NULL) {
-			PMD_LOG_INFO(TX, "Failed to prepare tx queue, txq[%d] is NULL", i);
-			continue;
+			PMD_LOG_ERR(TX, "Failed to prepare tx queue, txq[%d] is NULL", i);
+			ret = -EINVAL;
+			goto l_end;
 		}
-		txq->ops.mbufs_release = sxe2_tx_queue_mbufs_release_vec;
+		txq->ops = sxe2_tx_vec_ops;
+		txq->ops.queue_reset(txq);
 	}
+l_end:
 	return ret;
 }
Signature · 1 line
2.52.0
#308 lore raw

PATCH v8 30/49 net/sxe2: unify vectorized Tx buffer handling

In reply to [email protected]

From: Jie Liu <[email protected]>

Add a union of the scalar and vectorized buffer ring pointers to the Tx queue structure so the vectorized path can use sxe2_tx_buffer_vec directly. Rename the mbuf fill helper to sxe2_tx_pkts_mbuf_fill_vec, switch the vectorized Tx burst and mbuf release paths to the buffer_ring_vec member, and drop the AVX512-specific fill handling and conditional branching.

Fixes ac60f302cbef ("net/sxe2: add vectorized Rx and Tx")
---
 drivers/net/sxe2/sxe2_queue.h           |   5 +-
 drivers/net/sxe2/sxe2_txrx_vec.c        |  57 ++--------
 drivers/net/sxe2/sxe2_txrx_vec_avx2.c   |  10 +-
 drivers/net/sxe2/sxe2_txrx_vec_avx512.c | 133 +-----------------------
 drivers/net/sxe2/sxe2_txrx_vec_common.h |   9 +-
 drivers/net/sxe2/sxe2_txrx_vec_neon.c   |  10 +-
 drivers/net/sxe2/sxe2_txrx_vec_sse.c    |  10 +-
 7 files changed, 40 insertions(+), 194 deletions(-)
drivers/net/sxe2/sxe2_queue.h +4 -1
index 10bdaf5b8d..e53a1ce852 100644
@@ -62,7 +62,10 @@ struct sxe2_txq_ops {
 };
 struct sxe2_tx_queue {
 	volatile union sxe2_tx_data_desc *desc_ring;
-	struct sxe2_tx_buffer *buffer_ring;
+	union {
+		struct sxe2_tx_buffer *buffer_ring;
+		struct sxe2_tx_buffer_vec *buffer_ring_vec;
+	};
 	volatile uint32_t *tdt_reg_addr;
 
 	uint64_t offloads;
drivers/net/sxe2/sxe2_txrx_vec.c +11 -46

77 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx_vec_avx2.c +5 -5
index 0618e6d988..da96ca3064 100644
@@ -115,7 +115,7 @@ sxe2_tx_pkts_vec_avx2_batch(struct sxe2_tx_queue *txq, struct rte_mbuf **tx_pkts
 			    uint16_t nb_pkts, bool with_offloads)
 {
 	volatile union sxe2_tx_data_desc *desc;
-	struct sxe2_tx_buffer *buffer;
+	struct sxe2_tx_buffer_vec *buffer;
 	uint16_t next_use;
 	uint16_t res_num;
 	uint16_t tx_num;
@@ -134,14 +134,14 @@ sxe2_tx_pkts_vec_avx2_batch(struct sxe2_tx_queue *txq, struct rte_mbuf **tx_pkts
 
 	next_use = txq->next_use;
 	desc     = &txq->desc_ring[next_use];
-	buffer   = &txq->buffer_ring[next_use];
+	buffer   = &txq->buffer_ring_vec[next_use];
 
 	txq->desc_free_num -= nb_pkts;
 
 	res_num = txq->ring_depth - txq->next_use;
 
 	if (tx_num >= res_num) {
-		sxe2_tx_pkts_mbuf_fill(buffer, tx_pkts, res_num);
+		sxe2_tx_pkts_mbuf_fill_vec(buffer, tx_pkts, res_num);
 
 		sxe2_tx_desc_fill_avx2(desc, tx_pkts, res_num,
 				SXE2_TX_DATA_DESC_CMD_EOP, with_offloads);
@@ -157,10 +157,10 @@ sxe2_tx_pkts_vec_avx2_batch(struct sxe2_tx_queue *txq, struct rte_mbuf **tx_pkts
 		next_use     = 0;
 		txq->next_rs = txq->rs_thresh - 1;
 		desc         = &txq->desc_ring[next_use];
-		buffer       = &txq->buffer_ring[next_use];
+		buffer       = &txq->buffer_ring_vec[next_use];
 	}
 
-	sxe2_tx_pkts_mbuf_fill(buffer, tx_pkts, tx_num);
+	sxe2_tx_pkts_mbuf_fill_vec(buffer, tx_pkts, tx_num);
 
 	sxe2_tx_desc_fill_avx2(desc, tx_pkts, tx_num,
 			SXE2_TX_DATA_DESC_CMD_EOP, with_offloads);
drivers/net/sxe2/sxe2_txrx_vec_avx512.c +5 -128

180 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx_vec_common.h +5 -4
index 9ac99cf0fa..ede4c236b1 100644
@@ -25,10 +25,11 @@
 #define SXE2_TX_FREE_BUFFER_SIZE_MAX_VEC  64
 
 static __rte_always_inline void
-sxe2_tx_pkts_mbuf_fill(struct sxe2_tx_buffer *buffer,
-		struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
+sxe2_tx_pkts_mbuf_fill_vec(struct sxe2_tx_buffer_vec *buffer,
+			   struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 {
 	uint16_t i;
+
 	for (i = 0; i < nb_pkts; ++i)
 		buffer[i].mbuf = tx_pkts[i];
 }
@@ -36,7 +37,7 @@ sxe2_tx_pkts_mbuf_fill(struct sxe2_tx_buffer *buffer,
 static __rte_always_inline int32_t
 sxe2_tx_bufs_free_vec(struct sxe2_tx_queue *txq)
 {
-	struct sxe2_tx_buffer *buffer;
+	struct sxe2_tx_buffer_vec *buffer;
 	struct rte_mbuf *mbuf;
 	struct rte_mbuf *mbuf_free_arr[SXE2_TX_FREE_BUFFER_SIZE_MAX_VEC];
 	int32_t ret;
@@ -50,7 +51,7 @@ sxe2_tx_bufs_free_vec(struct sxe2_tx_queue *txq)
 		goto l_end;
 	}
 	rs_thresh = txq->rs_thresh;
-	buffer = &txq->buffer_ring[txq->next_dd - (rs_thresh - 1)];
+	buffer = &txq->buffer_ring_vec[txq->next_dd - (rs_thresh - 1)];
 	mbuf = rte_pktmbuf_prefree_seg(buffer[0].mbuf);
 	if (likely(mbuf)) {
 		mbuf_free_arr[0] = mbuf;
drivers/net/sxe2/sxe2_txrx_vec_neon.c +5 -5
index 4e5cb87cd5..b51cc55368 100644
@@ -39,7 +39,7 @@ sxe2_tx_pkts_vec_neon_batch(struct sxe2_tx_queue *txq, struct rte_mbuf **tx_pkts
 			uint16_t nb_pkts, bool with_offloads)
 {
 	volatile union sxe2_tx_data_desc *desc;
-	struct sxe2_tx_buffer *buffer;
+	struct sxe2_tx_buffer_vec *buffer;
 	uint16_t next_use;
 	uint16_t res_num;
 	uint16_t tx_num;
@@ -59,14 +59,14 @@ sxe2_tx_pkts_vec_neon_batch(struct sxe2_tx_queue *txq, struct rte_mbuf **tx_pkts
 
 	next_use = txq->next_use;
 	desc     = &txq->desc_ring[next_use];
-	buffer   = &txq->buffer_ring[next_use];
+	buffer   = &txq->buffer_ring_vec[next_use];
 
 	txq->desc_free_num -= nb_pkts;
 
 	res_num = txq->ring_depth - txq->next_use;
 
 	if (tx_num >= res_num) {
-		sxe2_tx_pkts_mbuf_fill(buffer, tx_pkts, res_num);
+		sxe2_tx_pkts_mbuf_fill_vec(buffer, tx_pkts, res_num);
 
 		for (i = 0; i < res_num - 1; ++i, ++tx_pkts, ++desc) {
 			sxe2_tx_desc_fill_one_neon(desc, *tx_pkts,
@@ -82,10 +82,10 @@ sxe2_tx_pkts_vec_neon_batch(struct sxe2_tx_queue *txq, struct rte_mbuf **tx_pkts
 		next_use     = 0;
 		txq->next_rs = txq->rs_thresh - 1;
 		desc         = &txq->desc_ring[next_use];
-		buffer       = &txq->buffer_ring[next_use];
+		buffer       = &txq->buffer_ring_vec[next_use];
 	}
 
-	sxe2_tx_pkts_mbuf_fill(buffer, tx_pkts, tx_num);
+	sxe2_tx_pkts_mbuf_fill_vec(buffer, tx_pkts, tx_num);
 
 	for (i = 0; i < tx_num; ++i, ++tx_pkts, ++desc) {
 		sxe2_tx_desc_fill_one_neon(desc, *tx_pkts,
drivers/net/sxe2/sxe2_txrx_vec_sse.c +5 -5
index c3e8a2983b..181bb40041 100644
@@ -40,7 +40,7 @@ sxe2_tx_pkts_vec_sse_batch(struct sxe2_tx_queue *txq,
 		uint16_t nb_pkts, bool with_offloads)
 {
 	volatile union sxe2_tx_data_desc *desc;
-	struct sxe2_tx_buffer *buffer;
+	struct sxe2_tx_buffer_vec *buffer;
 	uint16_t next_use;
 	uint16_t res_num;
 	uint16_t tx_num;
@@ -57,11 +57,11 @@ sxe2_tx_pkts_vec_sse_batch(struct sxe2_tx_queue *txq,
 	tx_num = nb_pkts;
 	next_use = txq->next_use;
 	desc     = &txq->desc_ring[next_use];
-	buffer   = &txq->buffer_ring[next_use];
+	buffer   = &txq->buffer_ring_vec[next_use];
 	txq->desc_free_num -= nb_pkts;
 	res_num = txq->ring_depth - txq->next_use;
 	if (tx_num >= res_num) {
-		sxe2_tx_pkts_mbuf_fill(buffer, tx_pkts, res_num);
+		sxe2_tx_pkts_mbuf_fill_vec(buffer, tx_pkts, res_num);
 		for (i = 0; i < res_num - 1; ++i, ++tx_pkts, ++desc) {
 			sxe2_tx_desc_fill_one_sse(desc, *tx_pkts,
 						  SXE2_TX_DATA_DESC_CMD_EOP,
@@ -74,9 +74,9 @@ sxe2_tx_pkts_vec_sse_batch(struct sxe2_tx_queue *txq,
 		next_use     = 0;
 		txq->next_rs = txq->rs_thresh - 1;
 		desc         = &txq->desc_ring[next_use];
-		buffer       = &txq->buffer_ring[next_use];
+		buffer       = &txq->buffer_ring_vec[next_use];
 	}
-	sxe2_tx_pkts_mbuf_fill(buffer, tx_pkts, tx_num);
+	sxe2_tx_pkts_mbuf_fill_vec(buffer, tx_pkts, tx_num);
 	for (i = 0; i < tx_num; ++i, ++tx_pkts, ++desc) {
 		sxe2_tx_desc_fill_one_sse(desc, *tx_pkts,
 					  SXE2_TX_DATA_DESC_CMD_EOP,
Signature · 1 line
2.52.0
#309 lore raw

PATCH v8 31/49 net/sxe2: optimize NEON Tx descriptor fill

In reply to [email protected]

From: Jie Liu <[email protected]>

Add sxe2_tx_desc_fill_4_neon_simple() to write four data descriptors with a single vst1q_u64_x4 store, and use it in sxe2_tx_pkts_vec_neon_batch() for the non-offload path to reduce the number of per-packet descriptor stores.

---
 drivers/net/sxe2/sxe2_txrx_vec_neon.c | 77 ++++++++++++++++++++++++---
 1 file changed, 70 insertions(+), 7 deletions(-)
drivers/net/sxe2/sxe2_txrx_vec_neon.c +70 -7
index b51cc55368..6b4c70c7ac 100644
@@ -34,6 +34,52 @@ sxe2_tx_desc_fill_one_neon(volatile union sxe2_tx_data_desc *desc,
 	vst1q_u64(RTE_CAST_PTR(uint64_t *, desc), data_desc);
 }
 
+static __rte_always_inline void
+sxe2_tx_desc_fill_4_neon_simple(volatile union sxe2_tx_data_desc *desc,
+				struct rte_mbuf **pkts)
+{
+	uint64x2_t d0, d1, d2, d3;
+	uint64x2x4_t v;
+	const uint64_t cmd_base = ((uint64_t)SXE2_TX_DESC_DTYPE_DATA) |
+				((uint64_t)SXE2_TX_DATA_DESC_CMD_EOP) <<
+				SXE2_TX_DATA_DESC_CMD_SHIFT;
+
+	d0 = (uint64x2_t){
+		rte_pktmbuf_iova(pkts[0]),
+		cmd_base |
+		((uint64_t)pkts[0]->data_len) << SXE2_TX_DATA_DESC_BUF_SZ_SHIFT |
+		((uint64_t)SXE2_TX_DATA_DESC_MACLEN_VAL(pkts[0]->l2_len))
+				<< SXE2_TX_DATA_DESC_OFFSET_SHIFT
+	};
+	d1 = (uint64x2_t){
+		rte_pktmbuf_iova(pkts[1]),
+		cmd_base |
+		((uint64_t)pkts[1]->data_len) << SXE2_TX_DATA_DESC_BUF_SZ_SHIFT |
+		((uint64_t)SXE2_TX_DATA_DESC_MACLEN_VAL(pkts[1]->l2_len))
+				<< SXE2_TX_DATA_DESC_OFFSET_SHIFT
+	};
+	d2 = (uint64x2_t){
+		rte_pktmbuf_iova(pkts[2]),
+		cmd_base |
+		((uint64_t)pkts[2]->data_len) << SXE2_TX_DATA_DESC_BUF_SZ_SHIFT |
+		((uint64_t)SXE2_TX_DATA_DESC_MACLEN_VAL(pkts[2]->l2_len))
+				<< SXE2_TX_DATA_DESC_OFFSET_SHIFT
+	};
+	d3 = (uint64x2_t){
+		rte_pktmbuf_iova(pkts[3]),
+		cmd_base |
+		((uint64_t)pkts[3]->data_len) << SXE2_TX_DATA_DESC_BUF_SZ_SHIFT |
+		((uint64_t)SXE2_TX_DATA_DESC_MACLEN_VAL(pkts[3]->l2_len))
+				<< SXE2_TX_DATA_DESC_OFFSET_SHIFT
+	};
+
+	v.val[0] = d0;
+	v.val[1] = d1;
+	v.val[2] = d2;
+	v.val[3] = d3;
+	vst1q_u64_x4(RTE_CAST_PTR(uint64_t *, desc), v);
+}
+
 static __rte_always_inline uint16_t
 sxe2_tx_pkts_vec_neon_batch(struct sxe2_tx_queue *txq, struct rte_mbuf **tx_pkts,
 			uint16_t nb_pkts, bool with_offloads)
@@ -67,10 +113,18 @@ sxe2_tx_pkts_vec_neon_batch(struct sxe2_tx_queue *txq, struct rte_mbuf **tx_pkts
 
 	if (tx_num >= res_num) {
 		sxe2_tx_pkts_mbuf_fill_vec(buffer, tx_pkts, res_num);
-
-		for (i = 0; i < res_num - 1; ++i, ++tx_pkts, ++desc) {
-			sxe2_tx_desc_fill_one_neon(desc, *tx_pkts,
-					SXE2_TX_DATA_DESC_CMD_EOP, with_offloads);
+		if (with_offloads) {
+			for (i = 0; i < res_num - 1; ++i, ++tx_pkts, ++desc) {
+				sxe2_tx_desc_fill_one_neon(desc, *tx_pkts,
+						SXE2_TX_DATA_DESC_CMD_EOP, with_offloads);
+			}
+		} else {
+			for (i = 0; i + 3 < res_num - 1; i += 4, tx_pkts += 4, desc += 4)
+				sxe2_tx_desc_fill_4_neon_simple(desc, tx_pkts);
+			for (; i < res_num - 1; ++i, ++tx_pkts, ++desc) {
+				sxe2_tx_desc_fill_one_neon(desc, *tx_pkts,
+						SXE2_TX_DATA_DESC_CMD_EOP, false);
+			}
 		}
 
 		sxe2_tx_desc_fill_one_neon(desc, *tx_pkts++,
@@ -87,9 +141,18 @@ sxe2_tx_pkts_vec_neon_batch(struct sxe2_tx_queue *txq, struct rte_mbuf **tx_pkts
 
 	sxe2_tx_pkts_mbuf_fill_vec(buffer, tx_pkts, tx_num);
 
-	for (i = 0; i < tx_num; ++i, ++tx_pkts, ++desc) {
-		sxe2_tx_desc_fill_one_neon(desc, *tx_pkts,
-				SXE2_TX_DATA_DESC_CMD_EOP, with_offloads);
+	if (with_offloads) {
+		for (i = 0; i < tx_num; ++i, ++tx_pkts, ++desc) {
+			sxe2_tx_desc_fill_one_neon(desc, *tx_pkts,
+					SXE2_TX_DATA_DESC_CMD_EOP, true);
+		}
+	} else {
+		for (i = 0; i + 3 < tx_num; i += 4, tx_pkts += 4, desc += 4)
+			sxe2_tx_desc_fill_4_neon_simple(desc, tx_pkts);
+		for (; i < tx_num; ++i, ++tx_pkts, ++desc) {
+			sxe2_tx_desc_fill_one_neon(desc, *tx_pkts,
+					SXE2_TX_DATA_DESC_CMD_EOP, false);
+		}
 	}
 
 	next_use += tx_num;
Signature · 1 line
2.52.0
#310 lore raw

PATCH v8 32/49 net/sxe2: fix NEON Rx ptype mapping and memory ordering

In reply to [email protected]

From: Jie Liu <[email protected]>

Reorder the descriptor lane mapping in the NEON Rx path to use the natural d0/d1/d2/d3 order for desc_lo/desc_hi, and update the staterr zip (16-bit), the shuffle masks and the ptype lane selection accordingly.

Correct the DD count in the NEON Rx path: count the leading run of done descriptors with rte_ctz64() instead of rte_popcount64(), which could hand up a descriptor the hardware has not yet written when DD bits are not contiguous.

Fix the FNAV/FDIR lane order in sxe2_rx_desc_fnav_flags_neon() to match the natural descriptor order used by the ptype and offload paths, so FDIR flags land on the correct mbuf.

Drop three of the four rte_atomic_thread_fence(acquire) barriers between descriptor loads; the single acquire fence after the descriptor set is loaded is sufficient for the Rx producer/consumer ordering.

Fixes ac60f302cbef ("net/sxe2: add vectorized Rx and Tx")
---
 drivers/net/sxe2/sxe2_txrx_vec_neon.c | 136 +++++++++++++-------------
 1 file changed, 70 insertions(+), 66 deletions(-)
drivers/net/sxe2/sxe2_txrx_vec_neon.c +70 -66
index 6b4c70c7ac..72338ee61a 100644
@@ -213,22 +213,24 @@ uint16_t sxe2_tx_pkts_vec_neon(void *tx_queue,
 }
 
 static __rte_always_inline void
-sxe2_rx_desc_ptype_fill_neon(uint16x8_t staterr, struct rte_mbuf **__rte_restrict rx_pkts)
+sxe2_rx_desc_ptype_fill_neon(uint32x4_t desc_lo,
+							 struct rte_mbuf **__rte_restrict rx_pkts,
+							 const uint32_t *__rte_restrict ptype_tbl)
 {
-	uint16x8_t ptype_mask = {
-		0, 0x3FFULL,
-		0, 0x3FFULL,
-		0, 0x3FFULL,
-		0, 0x3FFULL,
+	const uint32x4_t ptype_mask = {
+		SXE2_RX_DESC_PTYPE_MASK_NO_SHIFT << 16,
+		SXE2_RX_DESC_PTYPE_MASK_NO_SHIFT << 16,
+		SXE2_RX_DESC_PTYPE_MASK_NO_SHIFT << 16,
+		SXE2_RX_DESC_PTYPE_MASK_NO_SHIFT << 16,
 	};
 	uint16x8_t ptype_all;
 
-	ptype_all = vandq_u16(staterr, ptype_mask);
+	ptype_all = vreinterpretq_u16_u32(vandq_u32(desc_lo, ptype_mask));
 
-	rx_pkts[3]->packet_type = sxe2_ptype_tbl[vgetq_lane_u16(ptype_all, 3)];
-	rx_pkts[2]->packet_type = sxe2_ptype_tbl[vgetq_lane_u16(ptype_all, 7)];
-	rx_pkts[1]->packet_type = sxe2_ptype_tbl[vgetq_lane_u16(ptype_all, 1)];
-	rx_pkts[0]->packet_type = sxe2_ptype_tbl[vgetq_lane_u16(ptype_all, 5)];
+	rx_pkts[0]->packet_type = ptype_tbl[vgetq_lane_u16(ptype_all, 1)];
+	rx_pkts[1]->packet_type = ptype_tbl[vgetq_lane_u16(ptype_all, 3)];
+	rx_pkts[2]->packet_type = ptype_tbl[vgetq_lane_u16(ptype_all, 5)];
+	rx_pkts[3]->packet_type = ptype_tbl[vgetq_lane_u16(ptype_all, 7)];
 }
 
 static __rte_always_inline uint32x4_t
@@ -247,8 +249,8 @@ sxe2_rx_desc_fnav_flags_neon(uint64x2_t descs_arr[4])
 	uint32x4_t d2 = vreinterpretq_u32_u64(descs_arr[2]);
 	uint32x4_t d3 = vreinterpretq_u32_u64(descs_arr[3]);
 
-	descs_tmp1 = vzip1q_u32(d1, d0);
-	descs_tmp2 = vzip1q_u32(d3, d2);
+	descs_tmp1 = vzip1q_u32(d0, d1);
+	descs_tmp2 = vzip1q_u32(d2, d3);
 
 	uint64x2_t a = vreinterpretq_u64_u32(descs_tmp1);
 	uint64x2_t b = vreinterpretq_u64_u32(descs_tmp2);
@@ -271,9 +273,10 @@ sxe2_rx_desc_fnav_flags_neon(uint64x2_t descs_arr[4])
 static __rte_always_inline void
 sxe2_rx_desc_offloads_para_fill_neon(struct sxe2_rx_queue *rxq,
 			volatile union sxe2_rx_desc *desc,
-			uint64x2_t descs[4], struct rte_mbuf **rx_pkts)
+			uint64x2_t descs[4], uint32x4_t desc_lo, uint32x4_t desc_hi,
+			struct rte_mbuf **rx_pkts)
 {
-	uint32x4_t desc_lo, desc_hi, flags, tmp_flags;
+	uint32x4_t flags, tmp_flags;
 	const uint64x2_t mbuf_init = {rxq->mbuf_init_value, 0};
 	uint64x2_t rearm0, rearm1, rearm2, rearm3;
 
@@ -330,23 +333,6 @@ sxe2_rx_desc_offloads_para_fill_neon(struct sxe2_rx_queue *rxq,
 		0, 0, 0, 0, 0, 0, 0, 0
 	};
 
-	{
-		uint32x4_t d0 = vreinterpretq_u32_u64(descs[0]);
-		uint32x4_t d1 = vreinterpretq_u32_u64(descs[1]);
-		uint32x4_t d2 = vreinterpretq_u32_u64(descs[2]);
-		uint32x4_t d3 = vreinterpretq_u32_u64(descs[3]);
-		uint64x2_t f64, t64;
-
-		flags = vzip2q_u32(d1, d0);
-		tmp_flags = vzip2q_u32(d3, d2);
-		f64 = vreinterpretq_u64_u32(flags);
-		t64 = vreinterpretq_u64_u32(tmp_flags);
-		desc_lo = vreinterpretq_u32_u64(vcombine_u64(vget_low_u64(f64),
-							     vget_low_u64(t64)));
-		desc_hi = vreinterpretq_u32_u64(vcombine_u64(vget_high_u64(f64),
-							     vget_high_u64(t64)));
-	}
-
 	desc_lo = vandq_u32(desc_lo, desc_msk);
 	desc_hi = vandq_u32(desc_hi, rss_msk);
 
@@ -505,25 +491,39 @@ sxe2_rx_pkts_common_vec_neon(struct sxe2_rx_queue *rxq, struct rte_mbuf **rx_pkt
 		uint64x2_t descs[SXE2_RX_NUM_PER_LOOP_NEON];
 		uint8x16_t pkt_mb1, pkt_mb2, pkt_mb3, pkt_mb4;
 		uint64x2_t mbp1, mbp2;
+		uint32x4_t desc_lo, desc_hi;
 		uint16x8_t staterr;
 		uint16x8_t tmp;
 		uint16_t bit_num;
 
 		descs[3] = vld1q_u64(RTE_CAST_PTR(uint64_t *, desc + 3));
-		rte_atomic_thread_fence(rte_memory_order_acquire);
 		descs[2] = vld1q_u64(RTE_CAST_PTR(uint64_t *, desc + 2));
-		rte_atomic_thread_fence(rte_memory_order_acquire);
 		descs[1] = vld1q_u64(RTE_CAST_PTR(uint64_t *, desc + 1));
-		rte_atomic_thread_fence(rte_memory_order_acquire);
 		descs[0] = vld1q_u64(RTE_CAST_PTR(uint64_t *, desc));
 
 		rte_atomic_thread_fence(rte_memory_order_acquire);
-
 		descs[3] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, desc + 3), descs[3], 0);
 		descs[2] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, desc + 2), descs[2], 0);
 		descs[1] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, desc + 1), descs[1], 0);
 		descs[0] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, desc), descs[0], 0);
 
+		{
+			uint32x4_t d0 = vreinterpretq_u32_u64(descs[0]);
+			uint32x4_t d1 = vreinterpretq_u32_u64(descs[1]);
+			uint32x4_t d2 = vreinterpretq_u32_u64(descs[2]);
+			uint32x4_t d3 = vreinterpretq_u32_u64(descs[3]);
+
+			uint32x4_t q1_01 = vzip2q_u32(d0, d1);
+			uint32x4_t q1_23 = vzip2q_u32(d2, d3);
+			uint64x2_t q1_01_64 = vreinterpretq_u64_u32(q1_01);
+			uint64x2_t q1_23_64 = vreinterpretq_u64_u32(q1_23);
+
+			desc_lo = vreinterpretq_u32_u64(vcombine_u64(vget_low_u64(q1_01_64),
+							vget_low_u64(q1_23_64)));
+			desc_hi = vreinterpretq_u32_u64(vcombine_u64(vget_high_u64(q1_01_64),
+							vget_high_u64(q1_23_64)));
+		}
+
 		mbp1 = vld1q_u64((uint64_t *)&buffer[i]);
 		mbp2 = vld1q_u64((uint64_t *)&buffer[i + 2]);
 
@@ -543,7 +543,8 @@ sxe2_rx_pkts_common_vec_neon(struct sxe2_rx_queue *rxq, struct rte_mbuf **rx_pkt
 		pkt_mb1 = vqtbl1q_u8(vreinterpretq_u8_u64(descs[0]), rvp_shuf_mask);
 
 		if (do_offload) {
-			sxe2_rx_desc_offloads_para_fill_neon(rxq, desc, descs, &rx_pkts[i]);
+			sxe2_rx_desc_offloads_para_fill_neon(rxq, desc, descs, desc_lo,
+							     desc_hi, &rx_pkts[i]);
 		} else {
 			const uint64x2_t mbuf_init = {
 				rxq->mbuf_init_value,
@@ -578,55 +579,48 @@ sxe2_rx_pkts_common_vec_neon(struct sxe2_rx_queue *rxq, struct rte_mbuf **rx_pkt
 			rte_prefetch_non_temporal(desc + SXE2_RX_NUM_PER_LOOP_NEON);
 
 		{
-			uint32x4_t d0 = vreinterpretq_u32_u64(descs[0]);
-			uint32x4_t d1 = vreinterpretq_u32_u64(descs[1]);
-			uint32x4_t d2 = vreinterpretq_u32_u64(descs[2]);
-			uint32x4_t d3 = vreinterpretq_u32_u64(descs[3]);
-			uint32x4_t sterr_tmp1 = vzip2q_u32(d1, d0);
-			uint32x4_t sterr_tmp2 = vzip2q_u32(d3, d2);
-			uint32x4_t sterr_u32 = vzip1q_u32(sterr_tmp1, sterr_tmp2);
-
-			staterr = vreinterpretq_u16_u32(sterr_u32);
+			uint16x8_t sterr_tmp1 = vzip2q_u16(vreinterpretq_u16_u64(descs[0]),
+							   vreinterpretq_u16_u64(descs[2]));
+			uint16x8_t sterr_tmp2 = vzip2q_u16(vreinterpretq_u16_u64(descs[1]),
+							   vreinterpretq_u16_u64(descs[3]));
+			staterr = vzip1q_u16(sterr_tmp1, sterr_tmp2);
 		}
 
-		sxe2_rx_desc_ptype_fill_neon(staterr, &rx_pkts[i]);
+		sxe2_rx_desc_ptype_fill_neon(desc_lo, &rx_pkts[i], sxe2_ptype_tbl);
 
 		if (umbcast_flags != NULL) {
-			uint32x4_t umbcast_mask = {
-				SXE2_RX_DESC_STATUS_UMBCAST_MASK, SXE2_RX_DESC_STATUS_UMBCAST_MASK,
-				SXE2_RX_DESC_STATUS_UMBCAST_MASK, SXE2_RX_DESC_STATUS_UMBCAST_MASK,
-			};
-
+			const uint32x4_t umbcast_mask =
+				vdupq_n_u32(SXE2_RX_DESC_STATUS_UMBCAST_MASK);
 			uint8x16_t umbcast_shuf_mask = {
-				0x0B, 0x03, 0x0F, 0x07,
+				3, 7, 11, 15,
 				0xFF, 0xFF, 0xFF, 0xFF,
 				0xFF, 0xFF, 0xFF, 0xFF,
 				0xFF, 0xFF, 0xFF, 0xFF,
 			};
 			uint8x16_t umbcast_bits =
-				vreinterpretq_u8_u32(vandq_u32(vreinterpretq_u32_u16(staterr),
-							       umbcast_mask));
+				vreinterpretq_u8_u32(vandq_u32(desc_lo, umbcast_mask));
 
 			umbcast_bits = vqtbl1q_u8(umbcast_bits, umbcast_shuf_mask);
-			vst1q_lane_u32((uint32_t *)umbcast_flags,
-					vreinterpretq_u32_u8(umbcast_bits), 0);
+			*(uint32_t *)umbcast_flags =
+				vgetq_lane_u32(vreinterpretq_u32_u8(umbcast_bits), 0);
 			umbcast_flags += SXE2_RX_NUM_PER_LOOP_NEON;
 		}
 
 		if (split_rxe_flags) {
 			uint8x16_t eop_shuf_mask = {
-					0x08, 0x00, 0x0C, 0x04,
+					0, 2, 4, 6,
 					0xFF, 0xFF, 0xFF, 0xFF,
 					0xFF, 0xFF, 0xFF, 0xFF,
 					0xFF, 0xFF, 0xFF, 0xFF};
 			uint8x16_t eop_bits;
 			uint32x4_t rxe_mask = {
-				0x2080, 0x2080, 0x2080, 0x2080
+				0x20802080, 0x20802080, 0x20802080, 0x20802080
 			};
 			uint32x4_t rxe_bits;
 			uint32x4_t eop_mask;
 
-			eop_mask = vshlq_n_u32(vdupq_n_u32(1), SXE2_RX_DESC_STATUS_EOP_SHIFT);
+			eop_mask = vdupq_n_u32((1U << SXE2_RX_DESC_STATUS_EOP_SHIFT) |
+					(1U << (SXE2_RX_DESC_STATUS_EOP_SHIFT + 16)));
 			eop_bits = vandq_u8(vmvnq_u8(vreinterpretq_u8_u16(staterr)),
 					vreinterpretq_u8_u32(eop_mask));
 
@@ -650,12 +644,22 @@ sxe2_rx_pkts_common_vec_neon(struct sxe2_rx_queue *rxq, struct rte_mbuf **rx_pkt
 		}
 
 		{
-			uint32x4_t dd_mask = vdupq_n_u32(1);
-			uint32x4_t sterr_dd = vandq_u32(vreinterpretq_u32_u16(staterr), dd_mask);
-			uint16x4_t packed_lo = vmovn_u32(sterr_dd);
-			uint64_t dd64 = vget_lane_u64(vreinterpret_u64_u16(packed_lo), 0);
-
-			bit_num = (uint16_t)rte_popcount64(dd64);
+			const uint16x8_t dd_check = {
+				0x0001, 0x0001, 0x0001, 0x0001,
+				0, 0, 0, 0
+			};
+			uint16x8_t sterr_dd;
+			uint64_t stat;
+			sterr_dd = vandq_u16(staterr, dd_check);
+			sterr_dd = vshlq_n_u16(sterr_dd, 15);
+			sterr_dd =
+				vreinterpretq_u16_s16(vshrq_n_s16(vreinterpretq_s16_u16(sterr_dd),
+								  15));
+			stat = ~vgetq_lane_u64(vreinterpretq_u64_u16(sterr_dd), 0);
+			if (likely(stat == 0))
+				bit_num = SXE2_RX_NUM_PER_LOOP_NEON;
+			else
+				bit_num = (uint16_t)(rte_ctz64(stat) / 16);
 		}
 		done_num += bit_num;
 		if (likely(bit_num != SXE2_RX_NUM_PER_LOOP_NEON))
Signature · 1 line
2.52.0
#311 lore raw

PATCH v8 33/49 net/sxe2: refine vectorized Tx/Rx mode setup

In reply to [email protected]

From: Jie Liu <[email protected]>

Set rte_eth_tx_pkt_prepare_dummy for the simple and vectorized Tx paths instead of leaving the prepare callback unset, and split the NEON simple/offload mode selection based on the offload flag. Log the selected Tx/Rx mode flags and apply the default Rx free threshold when the configured value is zero.

Fixes ac60f302cbef ("net/sxe2: add vectorized Rx and Tx")
---
 drivers/net/sxe2/sxe2_rx.c   |  3 ++-
 drivers/net/sxe2/sxe2_txrx.c | 20 +++++++++++++++-----
 2 files changed, 17 insertions(+), 6 deletions(-)
drivers/net/sxe2/sxe2_rx.c +2 -1
index d700c60083..3830c676d7 100644
@@ -319,7 +319,8 @@ int32_t __rte_cold sxe2_rx_queue_setup(struct rte_eth_dev *dev,
 		rxq->mb_pool = mp;
 	}
 
-	rxq->rx_free_thresh = rx_conf->rx_free_thresh;
+	rxq->rx_free_thresh = (rx_conf->rx_free_thresh == 0) ?
+		SXE2_DEFAULT_RX_FREE_THRESH : rx_conf->rx_free_thresh;
 	rxq->port_id = dev->data->port_id;
 	rxq->offloads = offloads;
 	if (offloads & RTE_ETH_RX_OFFLOAD_KEEP_CRC)
drivers/net/sxe2/sxe2_txrx.c +15 -5
index 79870866d1..09f1dfe9fc 100644
@@ -358,7 +358,7 @@ void sxe2_tx_mode_func_set(struct rte_eth_dev *dev)
 	}
 
 	if (tx_mode_flags & SXE2_TX_MODE_VEC_SET_MASK) {
-		dev->tx_pkt_prepare = NULL;
+		dev->tx_pkt_prepare = rte_eth_tx_pkt_prepare_dummy;
 #ifdef RTE_ARCH_X86
 		if (tx_mode_flags & SXE2_TX_MODE_VEC_AVX512) {
 #ifdef CC_AVX512_SUPPORT
@@ -386,21 +386,28 @@ void sxe2_tx_mode_func_set(struct rte_eth_dev *dev)
 		}
 #elif defined(RTE_ARCH_ARM64)
 		if (tx_mode_flags & SXE2_TX_MODE_VEC_NEON) {
-			dev->tx_pkt_prepare = sxe2_tx_pkts_prepare;
-			dev->tx_pkt_burst = sxe2_tx_pkts_vec_neon;
+			if (tx_mode_flags & SXE2_TX_MODE_VEC_OFFLOAD) {
+				dev->tx_pkt_prepare = sxe2_tx_pkts_prepare;
+				dev->tx_pkt_burst = sxe2_tx_pkts_vec_neon;
+			} else {
+				dev->tx_pkt_burst = sxe2_tx_pkts_vec_neon_simple;
+			}
 		} else {
-			dev->tx_pkt_burst = sxe2_tx_pkts_vec_neon_simple;
+			dev->tx_pkt_prepare = sxe2_tx_pkts_prepare;
+			dev->tx_pkt_burst = sxe2_tx_pkts;
 		}
 #endif
 	} else {
 		if (tx_mode_flags & SXE2_TX_MODE_SIMPLE_BATCH) {
-			dev->tx_pkt_prepare = NULL;
+			dev->tx_pkt_prepare = rte_eth_tx_pkt_prepare_dummy;
 			dev->tx_pkt_burst = sxe2_tx_pkts_simple;
 		} else {
 			dev->tx_pkt_prepare = sxe2_tx_pkts_prepare;
 			dev->tx_pkt_burst = sxe2_tx_pkts;
 		}
 	}
+	PMD_LOG_DEBUG(TX, "Tx mode flags:0x%08x port_id:%u.",
+				tx_mode_flags, dev->data->port_id);
 }
 
 static const struct {
@@ -582,6 +589,9 @@ void sxe2_rx_mode_func_set(struct rte_eth_dev *dev)
 		dev->rx_pkt_burst = sxe2_rx_pkts_scattered_split;
 	else
 		dev->rx_pkt_burst = sxe2_rx_pkts_scattered;
+
+	PMD_LOG_DEBUG(RX, "Rx mode flags:0x%08x port_id:%u.",
+				rx_mode_flags, dev->data->port_id);
 }
 
 static const struct {
Signature · 1 line
2.52.0
#312 lore raw

PATCH v8 34/49 net/sxe2: fix RSS action attribute validation

In reply to [email protected]

From: Jie Liu <[email protected]>

The rss->level/key_len/queue_num checks only set the rte_flow_error but still return 0 (success), so invalid RSS configurations are accepted instead of being rejected with ENOTSUP.

Return the error code from the validation checks, matching the behavior in the V3 implementation.

Fixes 635084db5d57 ("net/sxe2: support VF representors")
---
 drivers/net/sxe2/sxe2_flow_parse_action.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/net/sxe2/sxe2_flow_parse_action.c +10 -4
index 03ada4e8a6..65ddfeb47f 100644
@@ -12,7 +12,7 @@
 static int32_t sxe2_flow_check_rss_action_attr(const struct rte_flow_action_rss *rss,
 					   struct rte_flow_error *error)
 {
-	int32_t ret = ENOTSUP;
+	int32_t ret = -ENOTSUP;
 	switch (rss->func) {
 	case RTE_ETH_HASH_FUNCTION_DEFAULT:
 	case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
@@ -25,15 +25,21 @@ static int32_t sxe2_flow_check_rss_action_attr(const struct rte_flow_action_rss
 		goto l_end;
 	}
 
-	if (rss->level > 2)
+	if (rss->level > 2) {
 		rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, NULL,
 			"RSS  level is could not be greater than 2");
-	if (rss->key_len)
+		goto l_end;
+	}
+	if (rss->key_len) {
 		rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, NULL,
 			"a nonzero RSS key_len is not supported");
-	if (rss->queue_num)
+		goto l_end;
+	}
+	if (rss->queue_num) {
 		rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, NULL,
 			"a non-NULL RSS queue is not supported");
+		goto l_end;
+	}
 	ret = 0;
 l_end:
 	return ret;
Signature · 1 line
2.52.0
#313 lore raw

PATCH v8 35/49 net/sxe2: restore PF-only guard in UDP tunnel port add

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_udp_tunnel_port_add_common() lost the check that restricts UDP tunnel port configuration to PF devices (not VF or representor), so VF/representor devices can now attempt to add UDP tunnel ports, which the hardware does not support.

Restore the PF-only guard returning -ENOTSUP, matching the V3 implementation.

Fixes fff24885f70a ("net/sxe2: support custom UDP tunnel ports")
---
 drivers/net/sxe2/sxe2_ethdev.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/net/sxe2/sxe2_ethdev.c +11 -0
index 77a31eb8a1..8c60c9cfde 100644
@@ -630,6 +630,10 @@ int32_t sxe2_udp_tunnel_port_add_common(struct sxe2_adapter *ad,
 	struct sxe2_udp_tunnel_cfg *tunnel_config;
 	int32_t ret = -1;
 
+	if (ad->dev_type != SXE2_DEV_T_PF || ad->is_dev_repr) {
+		ret = -ENOTSUP;
+		goto l_end;
+	}
 	rte_spinlock_lock(&ad->udp_tunnel_ctx.lock);
 
 	tunnel_config = &ad->udp_tunnel_ctx.tunnel_conf[tunnel_proto];
@@ -659,6 +663,7 @@ int32_t sxe2_udp_tunnel_port_add_common(struct sxe2_adapter *ad,
 
 l_unlock_end:
 	rte_spinlock_unlock(&ad->udp_tunnel_ctx.lock);
+l_end:
 	return ret;
 }
 
@@ -669,6 +674,9 @@ int32_t sxe2_udp_tunnel_port_del_common(struct sxe2_adapter *ad,
 	struct sxe2_udp_tunnel_cfg *tunnel_config;
 	int32_t ret = -1;
 
+	if (ad->dev_type != SXE2_DEV_T_PF || ad->is_dev_repr)
+		return -ENOTSUP;
+
 	rte_spinlock_lock(&ad->udp_tunnel_ctx.lock);
 	tunnel_config = &ad->udp_tunnel_ctx.tunnel_conf[tunnel_proto];
 
@@ -703,6 +711,9 @@ static int32_t sxe2_udp_tunnel_port_clear(struct rte_eth_dev *dev)
 	int32_t ret = 0;
 	uint16_t tunnel_proto = 0;
 
+	if (ad->dev_type != SXE2_DEV_T_PF || ad->is_dev_repr)
+		return -ENOTSUP;
+
 	rte_spinlock_lock(&ad->udp_tunnel_ctx.lock);
 
 	for (tunnel_proto = 0; tunnel_proto < SXE2_UDP_TUNNEL_MAX; tunnel_proto++) {
Signature · 1 line
2.52.0
#314 lore raw

PATCH v8 36/49 net/sxe2: refresh link state on link change events

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_link_update() was only called during device init, so the ethdev link state was not refreshed when link status changed at runtime.

Call sxe2_link_update() in the link-change IRQ handler for both the PF and its representors, so the link state is updated on LSC events. Remove the now-redundant call from sxe2_link_update_init().

Fixes 1d7fd921beef ("net/sxe2: support link update")
---
 drivers/net/sxe2/sxe2_irq.c |  2 ++
 drivers/net/sxe2/sxe2_mac.c | 11 +++--------
 2 files changed, 5 insertions(+), 8 deletions(-)
drivers/net/sxe2/sxe2_irq.c +2 -0
index ba764dd5e4..4c3a29900d 100644
@@ -84,6 +84,7 @@ static void sxe2_event_irq_common_handler(struct sxe2_adapter *adapter, uint64_t
 	if (oicr & RTE_BIT32(SXE2_COM_EC_LINK_CHG)) {
 		PMD_DEV_LOG_INFO(adapter, DRV, "OICR=0x%" PRIx64, oicr);
 		(void)sxe2_drv_mac_link_status_get(adapter);
+		(void)sxe2_link_update(dev, 0);
 		if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 			rte_eth_dev_callback_process(dev,
 						     RTE_ETH_EVENT_INTR_LSC,
@@ -96,6 +97,7 @@ static void sxe2_event_irq_common_handler(struct sxe2_adapter *adapter, uint64_t
 					continue;
 				repr_adapter = SXE2_DEV_PRIVATE_TO_ADAPTER(repr_eth_dev);
 				(void)sxe2_drv_mac_link_status_get(repr_adapter);
+				(void)sxe2_link_update(repr_eth_dev, 0);
 				if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 					rte_eth_dev_callback_process(repr_eth_dev,
 								     RTE_ETH_EVENT_INTR_LSC,
drivers/net/sxe2/sxe2_mac.c +3 -8
index 729c804ac3..ab9bd5355b 100644
@@ -448,18 +448,13 @@ int32_t sxe2_link_update_init(struct rte_eth_dev *dev)
 	int32_t ret;
 
 	PMD_INIT_FUNC_TRACE();
-
 	rte_spinlock_init(&adapter->link_ctxt.link_lock);
-
 	ret = sxe2_drv_mac_link_status_get(adapter);
-	if (ret) {
+	if (ret)
 		PMD_DEV_LOG_ERR(adapter, DRV, "Failed to get link status, ret=%d", ret);
-		goto l_end;
-	}
-
-	(void)sxe2_link_update(dev, 0);
+	else
+		(void)sxe2_link_update(dev, 0);
 
-l_end:
 	return ret;
 }
 int32_t sxe2_link_update(struct rte_eth_dev *dev, __rte_unused int32_t wait_to_complete)
Signature · 1 line
2.52.0
#315 lore raw

PATCH v8 37/49 net/sxe2: validate representor ID against VF count

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_switchdev_repr_private_data_init() indexes parent_adapter->repr_ctxt.repr_vf_id[repr_id] without checking that repr_id is within the number of configured VFs, which can access out of bounds when an invalid representor ID is passed.

Add a bounds check on repr_id against repr_ctxt.nb_vf and return -EINVAL on the error path.

Fixes 635084db5d57 ("net/sxe2: support VF representors")
---
 drivers/net/sxe2/sxe2_switchdev.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/sxe2/sxe2_switchdev.c +6 -0
index efb1468b91..d0304ccc94 100644
@@ -312,6 +312,12 @@ int32_t sxe2_switchdev_repr_private_data_init(struct rte_eth_dev *dev,
 	repr_priv_data->repr_q_id = repr_id;
 	repr_priv_data->repr_pf_id = parent_adapter->pf_idx;
 	repr_priv_data->repr_vf_id = repr_id;
+	if (repr_id >= parent_adapter->repr_ctxt.nb_vf) {
+		PMD_LOG_ERR(INIT, "repr_id %u exceed max vf %u",
+			repr_id, parent_adapter->repr_ctxt.nb_vf);
+		ret = -EINVAL;
+		goto l_free;
+	}
 	repr_priv_data->repr_vf_primary_vsi_id =
 		parent_adapter->repr_ctxt.repr_vf_id[repr_id].kernel_vsi_id;
 	repr_priv_data->repr_vf_backup_vsi_id =
Signature · 1 line
2.52.0
#316 lore raw

PATCH v8 38/49 net/sxe2: use primary VSI ID for representor VSI

In reply to [email protected]

From: Jie Liu <[email protected]>

For repr_vf_vsi_id, use the primary VSI id directly instead of falling back to the DPDK VSI id when the kernel VSI id is invalid. The kernel side guarantees the primary VSI id it provides is always valid in any scenario, so the fallback ternary is unnecessary.

---
 drivers/net/sxe2/sxe2_switchdev.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/net/sxe2/sxe2_switchdev.c +1 -4
index d0304ccc94..466182c55c 100644
@@ -324,10 +324,7 @@ int32_t sxe2_switchdev_repr_private_data_init(struct rte_eth_dev *dev,
 		parent_adapter->repr_ctxt.repr_vf_id[repr_id].dpdk_vsi_id;
 
 	repr_priv_data->repr_vf_vsi_id =
-		parent_adapter->repr_ctxt.repr_vf_id[repr_id].kernel_vsi_id !=
-		SXE2_INVALID_VSI_ID ?
-		parent_adapter->repr_ctxt.repr_vf_id[repr_id].kernel_vsi_id :
-		parent_adapter->repr_ctxt.repr_vf_id[repr_id].dpdk_vsi_id;
+		repr_priv_data->repr_vf_primary_vsi_id;
 
 	adapter->repr_priv_data = repr_priv_data;
 	goto l_end;
Signature · 1 line
2.52.0
#317 lore raw

PATCH v8 39/49 net/sxe2: wrap command params fill debug log in macro

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_drv_cmd_params_fill() passes the opcode string as a parameter to __sxe2_drv_cmd_params_fill() just to emit a debug log. The debug log is level-gated by PMD_DEV_LOG_DEBUG either way; moving it into the macro body only consolidates the call sites.

Wrap the log and the fill helper in a do/while block, dropping the opc_str parameter so the opcode stringization happens at the call site. Evaluate the adapter argument exactly once through a local variable.

---
 drivers/net/sxe2/sxe2_cmd_chnl.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/sxe2/sxe2_cmd_chnl.c +6 -4
index 3a55528c44..85098ac664 100644
@@ -26,10 +26,9 @@ static void sxe2_drv_trace_id_alloc(uint64_t *trace_id)
 }
 
 static void __sxe2_drv_cmd_params_fill(struct sxe2_adapter *adapter,
-		struct sxe2_drv_cmd_params *cmd, uint32_t opc, const char *opc_str,
+		struct sxe2_drv_cmd_params *cmd, uint32_t opc,
 		void *in_data, uint32_t in_len, void *out_data, uint32_t out_len)
 {
-	PMD_DEV_LOG_DEBUG(adapter, DRV, "cmd opcode:%s", opc_str);
 	cmd->timeout = SXE2_DRV_CMD_DFLT_TIMEOUT;
 	cmd->opcode  = opc;
 	cmd->vsi_id  = adapter->vsi_ctxt.dpdk_vsi_id;
@@ -44,8 +43,11 @@ static void __sxe2_drv_cmd_params_fill(struct sxe2_adapter *adapter,
 }
 
 #define sxe2_drv_cmd_params_fill(adapter, cmd, opc, in_data, in_len, out_data, out_len) \
-	__sxe2_drv_cmd_params_fill(adapter, cmd, opc, #opc, in_data, in_len, out_data, out_len)
-
+	do { \
+		struct sxe2_adapter *_ad = (adapter); \
+		PMD_DEV_LOG_DEBUG(_ad, DRV, "cmd opcode:%s", #opc); \
+		__sxe2_drv_cmd_params_fill(_ad, cmd, opc, in_data, in_len, out_data, out_len); \
+	} while (0)
 
 int32_t sxe2_drv_dev_caps_get(struct sxe2_adapter *adapter, struct sxe2_drv_dev_caps_resp *dev_caps)
 {
Signature · 1 line
2.52.0
#318 lore raw

PATCH v8 40/49 net/sxe2: restore Rx queue buffer split fill support

In reply to [email protected]

From: Jie Liu <[email protected]>

The V4 branch dropped sxe2_rxq_buf_split_fill() and the buffer split handling in sxe2_rxq_ctxt_cfg_fill(), so the Rx buffer split offload (RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) is advertised in device info but the per-queue context never configures split_en/split_type_mask/ hdr_len, and buffer split packets are not handled correctly.

Restore the sxe2_rxq_buf_split_fill() helper and the buffer split branch in sxe2_rxq_ctxt_cfg_fill(), matching the V3 implementation.

Fixes d8e4e075acb4 ("net/sxe2: add probing skeleton")
---
 drivers/net/sxe2/sxe2_cmd_chnl.c | 88 ++++++++++++++++++++++++++++++++
 1 file changed, 88 insertions(+)
drivers/net/sxe2/sxe2_cmd_chnl.c +88 -0
index 85098ac664..7b27cf2e8d 100644
@@ -195,6 +195,84 @@ int32_t sxe2_drv_vsi_del(struct sxe2_adapter *adapter, struct sxe2_vsi *vsi)
 #define SXE2_RXQ_CTXT_CFG_BUF_LEN_ALIGN  (1 << 7)
 #define SXE2_RX_HDR_SIZE 256
 
+static int32_t sxe2_rxq_buf_split_fill(struct sxe2_rx_queue *rxq,
+				   struct sxe2_drv_rxq_ctxt *ctxt)
+{
+	uint32_t proto_hdr;
+
+	proto_hdr = rxq->rx_seg[0].proto_hdr;
+	if (proto_hdr == RTE_PTYPE_UNKNOWN) {
+		PMD_LOG_ERR(RX, "Buffer split protocol must be configured");
+		return -EINVAL;
+	}
+
+	switch (proto_hdr & RTE_PTYPE_L4_MASK) {
+	case RTE_PTYPE_L4_TCP:
+		ctxt->split_type_mask = SXE2_PTYPE_L4_TCP;
+		goto l_end;
+	case RTE_PTYPE_L4_UDP:
+		ctxt->split_type_mask = SXE2_PTYPE_L4_UDP;
+		goto l_end;
+	case RTE_PTYPE_L4_SCTP:
+		ctxt->split_type_mask = SXE2_PTYPE_L4_SCTP;
+		goto l_end;
+	}
+
+	switch (proto_hdr & RTE_PTYPE_L3_MASK) {
+	case RTE_PTYPE_L3_IPV4_EXT_UNKNOWN:
+		ctxt->split_type_mask = SXE2_PTYPE_L3_IPV4;
+		goto l_end;
+	case RTE_PTYPE_L3_IPV6_EXT_UNKNOWN:
+		ctxt->split_type_mask = SXE2_PTYPE_L3_IPV6;
+		goto l_end;
+	}
+
+	switch (proto_hdr & RTE_PTYPE_L2_MASK) {
+	case RTE_PTYPE_L2_ETHER:
+		ctxt->split_type_mask = SXE2_PTYPE_L2_ETHER;
+		goto l_end;
+	}
+
+	switch (proto_hdr & RTE_PTYPE_INNER_L4_MASK) {
+	case RTE_PTYPE_INNER_L4_TCP:
+		ctxt->split_type_mask = SXE2_PTYPE_INNER_L4_TCP;
+		goto l_end;
+	case RTE_PTYPE_INNER_L4_UDP:
+		ctxt->split_type_mask = SXE2_PTYPE_INNER_L4_UDP;
+		goto l_end;
+	case RTE_PTYPE_INNER_L4_SCTP:
+		ctxt->split_type_mask = SXE2_PTYPE_INNER_L4_SCTP;
+		goto l_end;
+	}
+
+	switch (proto_hdr & RTE_PTYPE_INNER_L3_MASK) {
+	case RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN:
+		ctxt->split_type_mask = SXE2_PTYPE_INNER_L3_IPV4;
+		goto l_end;
+	case RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN:
+		ctxt->split_type_mask = SXE2_PTYPE_INNER_L3_IPV6;
+		goto l_end;
+	}
+
+	switch (proto_hdr & RTE_PTYPE_INNER_L2_MASK) {
+	case RTE_PTYPE_INNER_L2_ETHER:
+		ctxt->split_type_mask = SXE2_PTYPE_INNER_L2_ETHER;
+		goto l_end;
+	}
+
+	switch (proto_hdr & RTE_PTYPE_TUNNEL_MASK) {
+	case RTE_PTYPE_TUNNEL_GRENAT:
+		ctxt->split_type_mask = SXE2_PTYPE_TUNNEL_GRENAT;
+		goto l_end;
+	}
+
+	PMD_LOG_ERR(RX, "Buffer split protocol is not supported");
+	return -ENOTSUP;
+l_end:
+	ctxt->hdr_len = SXE2_RX_HDR_SIZE;
+	return 0;
+}
+
 static int32_t sxe2_rxq_ctxt_cfg_fill(struct sxe2_rx_queue *rxq,
 		struct sxe2_drv_rxq_cfg_req *req, uint16_t rxq_cnt)
 {
@@ -228,7 +306,17 @@ static int32_t sxe2_rxq_ctxt_cfg_fill(struct sxe2_rx_queue *rxq,
 	else
 		ctxt->keep_crc_en = 0;
 
+	if (rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) {
+		ret = sxe2_rxq_buf_split_fill(rxq, ctxt);
+		if (ret)
+			goto l_end;
+		ctxt->split_en = 1;
+	} else {
+		ctxt->split_en = 0;
+	}
+
 	ctxt->desc_size = sizeof(union sxe2_rx_desc);
+l_end:
 	return ret;
 }
 
Signature · 1 line
2.52.0
#319 lore raw

PATCH v8 41/49 net/sxe2: skip tunnel config fill on get failure

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_drv_udp_tunnel_get() fills tunnel_config fields even when the firmware command fails, so a failed get overwrites the config with the (zero-initialized) response data instead of leaving it intact.

Return early with the error code when sxe2_drv_cmd_exec() fails, matching the V3 implementation.

Fixes fff24885f70a ("net/sxe2: support custom UDP tunnel ports")
---
 drivers/net/sxe2/sxe2_cmd_chnl.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/sxe2/sxe2_cmd_chnl.c +4 -2
index 7b27cf2e8d..5ab287a77b 100644
@@ -1650,15 +1650,17 @@ int32_t sxe2_drv_udp_tunnel_get(struct sxe2_adapter *adapter,
 				 &req, sizeof(req),
 				 &resp, sizeof(resp));
 	ret = sxe2_drv_cmd_exec(cdev, &cmd);
-	if (ret)
+	if (ret) {
 		PMD_LOG_ERR(DRV, "Failed to get udp proto %d port, ret=%d", req.type, ret);
+		goto l_end;
+	}
 
 	tunnel_config->fw_port   = resp.port;
 	tunnel_config->fw_status = resp.enable;
 	tunnel_config->fw_dst_en = resp.dst;
 	tunnel_config->fw_src_en = resp.src;
 	tunnel_config->fw_used   = resp.fw_used;
-
+l_end:
 	return ret;
 }
 
Signature · 1 line
2.52.0
#320 lore raw

PATCH v8 42/49 net/sxe2: skip flow ID assignment on filter add failure

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_drv_flow_filter_add() assigns flow->flow_id from the response even when the firmware command fails, overwriting any previously set flow id with the zero-initialized response value.

Return early on command failure so flow->flow_id is preserved, and set flow->create_err on both the success and error paths.

Fixes 635084db5d57 ("net/sxe2: support VF representors")
---
 drivers/net/sxe2/sxe2_cmd_chnl.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/sxe2/sxe2_cmd_chnl.c +5 -1
index 5ab287a77b..6a5c1907c2 100644
@@ -1818,9 +1818,13 @@ int32_t sxe2_drv_flow_filter_add(struct sxe2_adapter *adapter, struct sxe2_flow
 	sxe2_drv_cmd_params_fill(adapter, &cmd, SXE2_DRV_CMD_FLOW_FILTER_ADD, &req,
 			   sizeof(req), &resp, sizeof(resp));
 	ret = sxe2_drv_cmd_exec(cdev, &cmd);
-	if (ret)
+	if (ret) {
 		PMD_DEV_LOG_ERR(adapter, DRV, "Failed to add flow filter, ret: %d.", ret);
+		goto l_end;
+	}
 	flow->flow_id = resp.flow_id;
+
+l_end:
 	flow->create_err = ret;
 	return ret;
 }
Signature · 1 line
2.52.0
#321 lore raw

PATCH v8 43/49 net/sxe2: correct command channel log messages

In reply to [email protected]

From: Jie Liu <[email protected]>

Several error/warning messages in sxe2_cmd_chnl.c are inaccurate or lost context:

- vsi_info_get: message lost the vsi id; restore it
- rxq_bind_irq/rxq_unbind_irq: message lost the rxq index; restore it
- promisc_config: fix "promic" typo in the message
- queue_info_get_update: use "tx/rx queue map get failed" wording
- rxq_mapping_set: incorrect "get dev caps" wording; use "rx queue mapping failed"
- txq_mapping_set: "Rx queue" should read "Tx queue"; incorrect "get dev caps" wording should read "tx queue mapping failed"

---
 drivers/net/sxe2/sxe2_cmd_chnl.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/net/sxe2/sxe2_cmd_chnl.c +8 -8
index 6a5c1907c2..65e3a4ca21 100644
@@ -481,7 +481,7 @@ int32_t sxe2_drv_vsi_info_get(struct sxe2_adapter *adapter, struct sxe2_vsi *vsi
 			&vsi_info_get_resp, sizeof(vsi_info_get_resp));
 	ret = sxe2_drv_cmd_exec(cdev, &param);
 	if (ret) {
-		PMD_DEV_LOG_ERR(adapter, DRV, "switchdev cpvsi info get failed, ret=%d", ret);
+		PMD_DEV_LOG_ERR(adapter, DRV, "vsi %u info get failed, ret=%d", vsi->vsi_id, ret);
 		goto l_end;
 	}
 
@@ -537,7 +537,7 @@ int32_t sxe2_drv_rxq_bind_irq(struct sxe2_adapter *adapter, uint16_t rxq_idx, ui
 				 NULL, 0);
 	ret = sxe2_drv_cmd_exec(cdev, &param);
 	if (ret)
-		PMD_DEV_LOG_ERR(adapter, DRV, "rxq bind irq failed, ret=%d", ret);
+		PMD_DEV_LOG_ERR(adapter, DRV, "rxq %u bind irq failed, ret=%d", rxq_idx, ret);
 
 	return ret;
 }
@@ -557,7 +557,7 @@ int32_t sxe2_drv_rxq_unbind_irq(struct sxe2_adapter *adapter, uint16_t rxq_idx)
 				 NULL, 0);
 	ret = sxe2_drv_cmd_exec(cdev, &param);
 	if (ret)
-		PMD_DEV_LOG_ERR(adapter, DRV, "rxq unbind irq failed, ret=%d", ret);
+		PMD_DEV_LOG_ERR(adapter, DRV, "rxq %u unbind irq failed, ret=%d", rxq_idx, ret);
 
 	return ret;
 }
@@ -758,7 +758,7 @@ int32_t sxe2_drv_promisc_config(struct sxe2_adapter *adapter, bool set)
 
 	ret = sxe2_drv_cmd_exec(cdev, &param);
 	if (ret)
-		PMD_DEV_LOG_WARN(adapter, DRV, "promic config failed, ret=%d", ret);
+		PMD_DEV_LOG_WARN(adapter, DRV, "promisc config failed, ret=%d", ret);
 
 	return ret;
 }
@@ -1683,7 +1683,7 @@ int32_t sxe2_drv_queue_info_get_update(struct sxe2_adapter *adapter, struct eth_
 				 &resp, sizeof(resp));
 	ret = sxe2_drv_cmd_exec(cdev, &param);
 	if (ret) {
-		PMD_LOG_ERR(DRV, "get queue info map failed, ret=%d", ret);
+		PMD_LOG_ERR(DRV, "tx/rx queue map get failed, ret=%d", ret);
 		goto l_end;
 	}
 
@@ -1727,7 +1727,7 @@ int32_t sxe2_drv_rxq_mapping_set(struct rte_eth_dev *eth_dev, uint16_t queue_id,
 
 	ret = sxe2_drv_cmd_exec(cdev, &param);
 	if (ret)
-		PMD_LOG_ERR(DRV, "get dev caps failed, ret=%d", ret);
+		PMD_LOG_ERR(DRV, "rx queue mapping failed, ret=%d", ret);
 
 l_end:
 	return ret;
@@ -1744,7 +1744,7 @@ int32_t sxe2_drv_txq_mapping_set(struct rte_eth_dev *eth_dev, uint16_t queue_id,
 
 	txq = eth_dev->data->tx_queues[queue_id];
 	if (txq == NULL) {
-		PMD_LOG_ERR(DRV, "Rx queue %u is not available or setup", queue_id);
+		PMD_LOG_ERR(DRV, "Tx queue %u is not available or setup", queue_id);
 		ret = -EINVAL;
 		goto l_end;
 	}
@@ -1758,7 +1758,7 @@ int32_t sxe2_drv_txq_mapping_set(struct rte_eth_dev *eth_dev, uint16_t queue_id,
 
 	ret = sxe2_drv_cmd_exec(cdev, &param);
 	if (ret)
-		PMD_LOG_ERR(DRV, "get dev caps failed, ret=%d", ret);
+		PMD_LOG_ERR(DRV, "tx queue mapping failed, ret=%d", ret);
 
 l_end:
 	return ret;
Signature · 1 line
2.52.0
#322 lore raw

PATCH v8 44/49 net/sxe2: align command structs with kernel layout

In reply to [email protected]

From: Jie Liu <[email protected]>

The sxe2_drv_cmd.h command structures must match the layout used by historical SXE2 kernel versions so the same firmware command ABI is shared. Several structures were declared with __rte_packed_begin/ __rte_packed_end and extra rsv padding that the kernel layout does not have:

- sxe2_drv_link_info_resp: drop rsv[3] padding (size unchanged)
- sxe2_tm_res: drop rsv[2] padding and packed attribute, reducing the TM command payload length from 4 to 2 bytes to match the historical kernel layout
- sxe2_tm_info: drop packed attribute, removing -Wpacked-not-aligned warnings
- sxe2_tm_add_mid_msg/sxe2_tm_add_queue_msg: drop packed attribute; the message sizes (16 and 20 bytes) are unchanged, but the tm info member moves to its naturally aligned offset (4 and 8)
- sxe2_drv_sfp_req/sxe2_drv_sfp_resp: drop packed attribute

Fixes 9c894f75113f ("net/sxe2: support TM hierarchy and shaping")
---
 drivers/net/sxe2/sxe2_drv_cmd.h | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)
drivers/net/sxe2/sxe2_drv_cmd.h +12 -14
index 01fd813ed1..ee9d86dd4c 100644
@@ -230,7 +230,6 @@ struct __rte_aligned(4) __rte_packed_begin sxe2_drv_vsi_info_get_resp {
 struct __rte_aligned(4) __rte_packed_begin sxe2_drv_link_info_resp {
 	uint32_t speed;
 	uint8_t status;
-	uint8_t rsv[3];
 } __rte_packed_end;
 
 struct __rte_aligned(4) __rte_packed_begin sxe2_switchdev_info {
@@ -348,31 +347,30 @@ struct __rte_aligned(4) __rte_packed_begin sxe2_rss_hf_req {
 	uint8_t rsv1[3];
 } __rte_packed_end;
 
-struct __rte_aligned(4) __rte_packed_begin sxe2_tm_res {
+struct sxe2_tm_res {
 	uint16_t teid;
-	uint8_t rsv[2];
-} __rte_packed_end;
+};
 
-struct __rte_aligned(4) __rte_packed_begin sxe2_tm_info {
+struct sxe2_tm_info {
 	uint32_t committed;
 	uint32_t peak;
 	uint8_t priority;
 	uint8_t reserve;
 	uint16_t weight;
-} __rte_packed_end;
+};
 
-struct __rte_aligned(4) __rte_packed_begin sxe2_tm_add_mid_msg {
+struct sxe2_tm_add_mid_msg {
 	uint16_t parent_teid;
 	uint8_t adj_lvl;
 	struct sxe2_tm_info info;
-} __rte_packed_end;
+};
 
-struct __rte_aligned(4) __rte_packed_begin sxe2_tm_add_queue_msg {
+struct sxe2_tm_add_queue_msg {
 	uint16_t parent_teid;
 	uint16_t queue_id;
 	uint8_t adj_lvl;
 	struct sxe2_tm_info info;
-} __rte_packed_end;
+};
 
 struct __rte_aligned(4) __rte_packed_begin sxe2_drv_ipsec_capa_resq {
 	uint16_t tx_sa_cnt;
@@ -633,7 +631,7 @@ struct __rte_aligned(4) __rte_packed_begin sxe2_drv_udp_tunnel_resp {
 	uint8_t rsv;
 } __rte_packed_end;
 
-struct __rte_aligned(4) __rte_packed_begin sxe2_drv_sfp_req {
+struct sxe2_drv_sfp_req {
 	uint8_t is_wr;
 	uint8_t is_qsfp;
 	uint16_t bus_addr;
@@ -642,14 +640,14 @@ struct __rte_aligned(4) __rte_packed_begin sxe2_drv_sfp_req {
 	uint16_t data_len;
 	uint16_t rvd;
 	uint8_t data[];
-} __rte_packed_end;
+};
 
-struct __rte_aligned(4) __rte_packed_begin sxe2_drv_sfp_resp {
+struct sxe2_drv_sfp_resp {
 	uint8_t is_wr;
 	uint8_t is_qsfp;
 	uint16_t data_len;
 	uint8_t data[];
-} __rte_packed_end;
+};
 
 enum sxe2_fc_type {
 	SXE2_FC_T_DIS = 0,
Signature · 1 line
2.52.0
#323 lore raw

PATCH v8 45/49 common/sxe2: fix ioctl channel log and close handling

In reply to [email protected]

From: Jie Liu <[email protected]>

Compare sxe2_ioctl_chnl.c against the reference implementation and correct the following discrepancies:

- sxe2_drv_dev_close: only log the closed fd when it is valid, move PMD_LOG_INFO inside the fd >= 0 check
- sxe2_drv_dev_mmap: fix swapped format arguments in the debug log (cmd_fd and bar_idx were passed in the wrong order)
- sxe2_drv_dev_dma_unmap: use PMD_LOG_ERR instead of PMD_LOG_INFO for the ioctl failure message

Fixes 83866f8d7638 ("common/sxe2: add base driver skeleton")
---
 drivers/common/sxe2/sxe2_ioctl_chnl.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/common/sxe2/sxe2_ioctl_chnl.c +8 -5
index 3e2fbf572f..9f455bd8d5 100644
@@ -107,9 +107,11 @@ sxe2_drv_dev_close(struct sxe2_common_device *cdev)
 {
 	int32_t fd = SXE2_CDEV_TO_CMD_FD(cdev);
 
-	if (fd >= 0)
+	if (fd >= 0) {
 		close(fd);
-	PMD_LOG_INFO(COM, "closed device fd=%d", fd);
+		PMD_LOG_INFO(COM, "closed device fd=%d", fd);
+	}
+
 	SXE2_CDEV_TO_CMD_FD(cdev) = SXE2_CMD_FD_INVALID;
 }
 
@@ -349,8 +351,9 @@ void
 		goto l_err;
 	}
 
-	PMD_LOG_DEBUG(COM, "fd=%d, bar idx=%d, len=%"PRIu64", src=0x%"PRIx64", offset=0x%"PRIx64"",
-		bar_idx, cmd_fd, len, offset, SXE2_COM_PCI_OFFSET_GEN(bar_idx, offset));
+	PMD_LOG_DEBUG(COM, "fd=%d, bar idx=%d, len=%"PRIu64", "
+		"offset=0x%"PRIx64", pci_offset=0x%"PRIx64"",
+		cmd_fd, bar_idx, len, offset, SXE2_COM_PCI_OFFSET_GEN(bar_idx, offset));
 
 	virt = mmap(NULL, len, PROT_READ | PROT_WRITE,
 		MAP_SHARED, cmd_fd, SXE2_COM_PCI_OFFSET_GEN(bar_idx, offset));
@@ -477,7 +480,7 @@ sxe2_drv_dev_dma_unmap(struct sxe2_common_device *cdev, uint64_t iova)
 	pthread_mutex_lock(&cdev->config.lock);
 	ret = ioctl(cmd_fd, SXE2_COM_CMD_DMA_UNMAP, &cmd_params);
 	if (ret < 0) {
-		PMD_LOG_INFO(COM, "Failed to dma unmap, fd=%d, ret=%d, err:%s",
+		PMD_LOG_ERR(COM, "Failed to dma unmap, fd=%d, ret=%d, err:%s",
 				cmd_fd, ret, strerror(errno));
 		ret = -EIO;
 		pthread_mutex_unlock(&cdev->config.lock);
Signature · 1 line
2.52.0
#324 lore raw

PATCH v8 46/49 doc/sxe2: remove drv-SW-stats parameter documentation

In reply to [email protected]

From: Jie Liu <[email protected]>

The drv-sw-stats devarg is no longer supported. Remove its parameter description from the Runtime Configuration section. The "Receive Software Statistics" xstats section is kept because the rx_sw_* counters are still accumulated in the Rx data path and reported through rte_eth_xstats_get().

Fixes 9e95b2b3859c ("doc: update sxe2 guide and features")
---
 doc/guides/nics/sxe2.rst | 31 ++-----------------------------
 1 file changed, 2 insertions(+), 29 deletions(-)
doc/guides/nics/sxe2.rst +2 -29
index c5b400a8ba..fe4f9f916b 100644
@@ -109,30 +109,6 @@ Runtime Configuration
 
   Default value is 3 (count both packets and bytes).
 
-- ``drv-sw-stats`` parameter [int]
-
-  This parameter controls whether per-packet software statistics (SW stats)
-  are collected in the Rx data path.
-
-  Hardware packet statistic counters may be inaccurate for certain packet types
-  due to hardware design limitations.
-  When accuracy of Rx packet classification statistics is critical,
-  enabling this parameter allows the driver to accumulate statistics in software
-  as packets are received, providing an alternative statistical path
-  that bypasses hardware counter inaccuracies.
-
-  - 0: Disable software statistics collection (default).
-    The basic port statistics (``ipackets``, ``ibytes``) are reported
-    from the hardware counters.
-  - 1: Enable software statistics collection.
-    Per-packet software statistics are accumulated for unicast,
-    multicast, broadcast, and dropped packets in the Rx data path.
-
-  When enabled, the following extended statistics (xstats) are available:
-  ``rx_sw_unicast_packets``, ``rx_sw_multicast_packets``,
-  ``rx_sw_broadcast_packets``, ``rx_sw_drop_packets``,
-  and ``rx_sw_drop_bytes``.
-
 - ``no-sched-mode`` parameter [int]
 
   This parameter enables non-scheduling mode (no-sched mode).
@@ -208,8 +184,7 @@ reflect the actual packets processed by the driver.
 
 Receive Software Statistics
   These counters are collected in the Rx data path
-  when ``drv-sw-stats=1`` is configured (see the ``drv-sw-stats`` devarg above).
-  When ``drv-sw-stats`` is disabled (default), these xstats report zero.
+  on every received packet.
 
   - ``rx_sw_unicast_packets``: Number of unicast packets received.
   - ``rx_sw_multicast_packets``: Number of multicast packets received.
@@ -217,10 +192,8 @@ Receive Software Statistics
   - ``rx_sw_drop_packets``: Number of packets dropped in the Rx data path.
   - ``rx_sw_drop_bytes``: Number of bytes dropped in the Rx data path.
 
-  When ``drv-sw-stats`` is enabled, the basic counters
-  ``ipackets`` and ``ibytes`` (from ``rte_eth_stats``)
+  The basic counters ``ipackets`` and ``ibytes`` (from ``rte_eth_stats``)
   also reflect the software-accumulated packet and byte counts.
-  Otherwise, they are reported from hardware counters.
 
 Fnav Flow Engine Statistics
   The Fnav flow engine statistics type is controlled by
Signature · 1 line
2.52.0
#325 lore raw

PATCH v8 47/49 net/sxe2: remove ineffective representor queue counts

In reply to [email protected]

From: Jie Liu <[email protected]>

rte_eth_dev_info_get() overwrites dev_info->nb_rx_queues and dev_info->nb_tx_queues from dev->data after the PMD dev_infos_get callback returns, so assigning them in sxe2_repr_dev_infos_get() has no effect. Remove the ineffective assignments.

Fixes 635084db5d57 ("net/sxe2: support VF representors")
---
 drivers/net/sxe2/sxe2_ethdev_repr.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/sxe2/sxe2_ethdev_repr.c +1 -3
index 6f5642ad5d..880a54bea8 100644
@@ -127,7 +127,7 @@ static int32_t sxe2_repr_dev_close(struct rte_eth_dev *dev)
 	return 0;
 }
 
-static int32_t sxe2_repr_dev_infos_get(struct rte_eth_dev *dev,
+static int32_t sxe2_repr_dev_infos_get(__rte_unused struct rte_eth_dev *dev,
 			struct rte_eth_dev_info *dev_info)
 {
 	dev_info->max_rx_queues = 1;
@@ -195,8 +195,6 @@ static int32_t sxe2_repr_dev_infos_get(struct rte_eth_dev *dev,
 	dev_info->speed_capa = RTE_ETH_LINK_SPEED_10G | RTE_ETH_LINK_SPEED_25G |
 			 RTE_ETH_LINK_SPEED_50G | RTE_ETH_LINK_SPEED_100G;
 
-	dev_info->nb_rx_queues = dev->data->nb_rx_queues;
-	dev_info->nb_tx_queues = dev->data->nb_tx_queues;
 
 	dev_info->default_rxportconf.burst_size = SXE2_RX_MAX_BURST;
 	dev_info->default_txportconf.burst_size = SXE2_TX_MAX_BURST;
Signature · 1 line
2.52.0
#326 lore raw

PATCH v8 48/49 net/sxe2: fix VEC mode selection in mode set functions

In reply to [email protected]

From: Jie Liu <[email protected]>

The Tx/Rx mode set functions pre-assigned tx_mode_flags/rx_mode_flags from vec_flags (SXE2_{TX,RX}_MODE_VEC_SIMPLE or _VEC_OFFLOAD) before the per-ISA capability checks. As SXE2_{TX,RX}_MODE_VEC_SET_MASK includes the SIMPLE and OFFLOAD bits, the subsequent "(flags & SET_MASK) == 0" guards never matched, so the AVX2 and SSE VEC mode bits were never set and the vectorized path fell back to SSE even when AVX2 was available.

Remove the pre-assignment and OR in "vec_flags | MODE" at each ISA selection branch so the correct VEC mode bit is selected on every architecture.

Fixes ac60f302cbef ("net/sxe2: add vectorized Rx and Tx")
---
 drivers/net/sxe2/sxe2_txrx.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/net/sxe2/sxe2_txrx.c +6 -8
index 09f1dfe9fc..eb1092714a 100644
@@ -319,13 +319,12 @@ void sxe2_tx_mode_func_set(struct rte_eth_dev *dev)
 		ret = sxe2_tx_vec_support_check(dev, &vec_flags);
 		if (ret == 0 &&
 		    rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128) {
-			tx_mode_flags = vec_flags;
 #ifdef RTE_ARCH_X86
 			if ((rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512) &&
 			    (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1) &&
 			    (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512BW) == 1)) {
 #ifdef CC_AVX512_SUPPORT
-				tx_mode_flags |= SXE2_TX_MODE_VEC_AVX512;
+				tx_mode_flags |= (vec_flags | SXE2_TX_MODE_VEC_AVX512);
 #else
 				PMD_LOG_INFO(TX, "AVX512 is not supported in build env.");
 #endif
@@ -334,10 +333,10 @@ void sxe2_tx_mode_func_set(struct rte_eth_dev *dev)
 			    ((rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2) == 1) ||
 			    (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1)) &&
 			    (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_256))
-				tx_mode_flags |= SXE2_TX_MODE_VEC_AVX2;
+				tx_mode_flags |= (vec_flags | SXE2_TX_MODE_VEC_AVX2);
 
 			if ((0 == (tx_mode_flags & SXE2_TX_MODE_VEC_SET_MASK)))
-				tx_mode_flags |=  SXE2_TX_MODE_VEC_SSE;
+				tx_mode_flags |= (vec_flags | SXE2_TX_MODE_VEC_SSE);
 #elif defined(RTE_ARCH_ARM64)
 			if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_NEON) == 1)
 				tx_mode_flags |= (vec_flags | SXE2_TX_MODE_VEC_NEON);
@@ -520,13 +519,12 @@ void sxe2_rx_mode_func_set(struct rte_eth_dev *dev)
 		ret = sxe2_rx_vec_support_check(dev, &vec_flags);
 		if (ret == 0 &&
 		    rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128) {
-			rx_mode_flags = vec_flags;
 #ifdef RTE_ARCH_X86
 			if ((rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512) &&
 				(rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1) &&
 				(rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512BW) == 1)) {
 #ifdef CC_AVX512_SUPPORT
-				rx_mode_flags |= SXE2_RX_MODE_VEC_AVX512;
+				rx_mode_flags |= (vec_flags | SXE2_RX_MODE_VEC_AVX512);
 #else
 				PMD_LOG_INFO(RX, "AVX512 support detected but not enabled");
 #endif
@@ -535,11 +533,11 @@ void sxe2_rx_mode_func_set(struct rte_eth_dev *dev)
 				((rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2) == 1) ||
 				(rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1)) &&
 				(rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_256))
-				rx_mode_flags |= SXE2_RX_MODE_VEC_AVX2;
+				rx_mode_flags |= (vec_flags | SXE2_RX_MODE_VEC_AVX2);
 
 			if (((rx_mode_flags & SXE2_RX_MODE_VEC_SET_MASK) == 0) &&
 				rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128)
-				rx_mode_flags |= SXE2_RX_MODE_VEC_SSE;
+				rx_mode_flags |= (vec_flags | SXE2_RX_MODE_VEC_SSE);
 
 #elif defined(RTE_ARCH_ARM64)
 			if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_NEON) == 1) {
Signature · 1 line
2.52.0
#327 lore raw

PATCH v8 49/49 net/sxe2: fix devargs parse error check for representors

In reply to [email protected]

From: Jie Liu <[email protected]>

rte_eth_devargs_parse() returns a positive value (the number of representor ports) when a representor is specified in the device string, and a negative value on error. The old check treated any non-zero return as an error, so probing a representor device always failed.

Only treat a negative return as an error, so the positive representor count is not misreported.

Fixes d8e4e075acb4 ("net/sxe2: add probing skeleton")
---
 drivers/net/sxe2/sxe2_ethdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/sxe2/sxe2_ethdev.c +2 -2
index 8c60c9cfde..3871acdc77 100644
@@ -2318,7 +2318,7 @@ static int32_t sxe2_parse_eth_devargs(struct rte_device *dev,
 		ret = rte_eth_devargs_parse(dev->devargs->cls_str,
 					    eth_da,
 					    1);
-		if (ret) {
+		if (ret < 0) {
 			PMD_LOG_ERR(INIT, "Failed to parse device arguments: %s",
 				dev->devargs->cls_str);
 			return -rte_errno;
@@ -2329,7 +2329,7 @@ static int32_t sxe2_parse_eth_devargs(struct rte_device *dev,
 		ret = rte_eth_devargs_parse(dev->devargs->args,
 					    eth_da,
 					    1);
-		if (ret) {
+		if (ret < 0) {
 			PMD_LOG_ERR(INIT, "Failed to parse device arguments: %s",
 				dev->devargs->args);
 			return -rte_errno;
Signature · 1 line
2.52.0
#328 lore raw

v9 cover net/sxe2: re-align with reference and fix review findings

From: Jie Liu <[email protected]>

This series updates the SXE2 poll mode driver (drivers/net/sxe2) and its common library (drivers/common/sxe2), fixing issues found in the previous version and re-aligning the driver with the reference implementation.

Changes since v8:
- drop the dead dev_ops/dev_close NULL check in the representor
teardown: dev_ops points at the driver's static ops struct, so dev_close is always present for a stored representor. The init path stores the representor pointer in vf_rep_eth_dev[] only after sxe2_repr_dev_init() succeeds (which sets dev_ops), so a stored representor never has a NULL dev_ops.

Jie Liu (48):
common/sxe2: fix null pointer in class driver remove common/sxe2: allow munmap during kernel reset net/sxe2: fix VF PCI device ID
net/sxe2: fix MSIX register width in PF map table net/sxe2: restore PF and port index caps assignment net/sxe2: fix VSI lifecycle management net/sxe2: initialize stats in representor device init net/sxe2: use base device name for representor naming net/sxe2: propagate LSC event to VF representors net/sxe2: clear security context pointer on uninit net/sxe2: rename representor VSI ID fields net/sxe2: clean up duplicate function declarations net/sxe2: fix null VSI dereference in device info net/sxe2: fill MAC addresses in device info net/sxe2: fix QinQ and RSS offload capability report net/sxe2: use regular write for mapped registers net/sxe2: move PCI register read macro to common header net/sxe2: validate PCI map resource type net/sxe2: guard PCI BAR unmap when not initialized net/sxe2: fix duplicated cleanup in dev close net/sxe2: align dev init and cleanup order net/sxe2: simplify switchdev representor matching net/sxe2: rename fnav cid manager symbols to flow net/sxe2: move tunnel port helpers into flow module net/sxe2: add ACL engine event statistics support net/sxe2: enable FDIR on all Rx queues net/sxe2: refactor primary process MP message handling net/sxe2: refactor Tx queue reset operations net/sxe2: unify vectorized Tx buffer handling net/sxe2: optimize NEON Tx descriptor fill net/sxe2: fix NEON Rx ptype mapping and memory ordering net/sxe2: refine vectorized Tx/Rx mode setup net/sxe2: fix RSS action attribute validation net/sxe2: restore PF-only guard in UDP tunnel port add net/sxe2: refresh link state on link change events net/sxe2: validate representor ID against VF count net/sxe2: use primary VSI ID for representor VSI net/sxe2: wrap command params fill debug log in macro net/sxe2: restore Rx queue buffer split fill support net/sxe2: skip tunnel config fill on get failure net/sxe2: skip flow ID assignment on filter add failure net/sxe2: correct command channel log messages net/sxe2: align command structs with kernel layout common/sxe2: fix ioctl channel log and close handling doc/sxe2: remove drv-SW-stats parameter documentation net/sxe2: remove ineffective representor queue counts net/sxe2: fix VEC mode selection in mode set functions net/sxe2: fix devargs parse error check for representors

 doc/guides/nics/sxe2.rst                   |  40 ++--
 drivers/common/sxe2/sxe2_common.c          |   6 +-
 drivers/common/sxe2/sxe2_ioctl_chnl.c      |  21 +-
 drivers/net/sxe2/sxe2_cmd_chnl.c           | 199 +++++++++++++++--
 drivers/net/sxe2/sxe2_cmd_chnl.h           |  15 +-
 drivers/net/sxe2/sxe2_drv_cmd.h            |  33 +--
 drivers/net/sxe2/sxe2_dump.c               |  10 +-
 drivers/net/sxe2/sxe2_ethdev.c             | 188 ++++++++++-------
 drivers/net/sxe2/sxe2_ethdev.h             |  13 +-
 drivers/net/sxe2/sxe2_ethdev_repr.c        |  20 +-
 drivers/net/sxe2/sxe2_flow.c               | 235 ++++++++++++++++++---
 drivers/net/sxe2/sxe2_flow.h               |   6 +-
 drivers/net/sxe2/sxe2_flow_define.h        |  15 +-
 drivers/net/sxe2/sxe2_flow_parse_action.c  |  42 ++--
 drivers/net/sxe2/sxe2_flow_parse_pattern.c | 113 ----------
 drivers/net/sxe2/sxe2_flow_parse_pattern.h |   6 -
 drivers/net/sxe2/sxe2_irq.c                |  24 ++-
 drivers/net/sxe2/sxe2_mac.c                |  11 +-
 drivers/net/sxe2/sxe2_mp.c                 |  59 +++---
 drivers/net/sxe2/sxe2_queue.c              |   2 +
 drivers/net/sxe2/sxe2_queue.h              |   7 +-
 drivers/net/sxe2/sxe2_rx.c                 |   3 +-
 drivers/net/sxe2/sxe2_security.c           |   1 +
 drivers/net/sxe2/sxe2_switchdev.c          |  15 +-
 drivers/net/sxe2/sxe2_tx.c                 |  42 +++-
 drivers/net/sxe2/sxe2_tx.h                 |   4 +
 drivers/net/sxe2/sxe2_txrx.c               |  34 +--
 drivers/net/sxe2/sxe2_txrx_poll.h          |   2 -
 drivers/net/sxe2/sxe2_txrx_vec.c           |  74 +++----
 drivers/net/sxe2/sxe2_txrx_vec_avx2.c      |  10 +-
 drivers/net/sxe2/sxe2_txrx_vec_avx512.c    | 133 +-----------
 drivers/net/sxe2/sxe2_txrx_vec_common.h    |   9 +-
 drivers/net/sxe2/sxe2_txrx_vec_neon.c      | 223 ++++++++++++-------
 drivers/net/sxe2/sxe2_txrx_vec_sse.c       |  10 +-
 drivers/net/sxe2/sxe2_vsi.c                |  31 +--
 35 files changed, 946 insertions(+), 710 deletions(-)
Signature · 1 line
2.52.0
#329 lore raw

Re: [PATCH v9 00/48] net/sxe2: re-align with reference and fix review findings

Quoted 6 lines · On Wed, 2 Sep 2026 09:56:49 +0800 [email protected] wrote:

From: Jie Liu <[email protected]>

This series updates the SXE2 poll mode driver (drivers/net/sxe2) and its common library (drivers/common/sxe2), fixing issues found in the previous version and re-aligning the driver with the reference implementation.

Very very close to being ready.

Two things left.

Patch 35/48: refresh link state on link change events
-------------------------------------------------------

Warning: the commit message says the call is removed from sxe2_link_update_init(). It is not removed, it is made conditional:

	ret = sxe2_drv_mac_link_status_get(adapter);
-	if (ret) {
+	if (ret)
		PMD_DEV_LOG_ERR(adapter, DRV, "Failed to get link status, ret=%d", ret);

- goto l_end;
- }
-
- (void)sxe2_link_update(dev, 0);
+ else
+ (void)sxe2_link_update(dev, 0);

Keeping it is fine, the initial link state still has to come from somewhere. Please just say that in the message instead of saying the call is removed.

Patch 48/48: fix devargs parse error check for representors
-------------------------------------------------------------

The check itself is correct. rte_eth_devargs_parse() returns the number of devargs parsed on success and a negative errno on error, so "ret < 0" is right and the old test did break representor probing.

Warning: the error path below it still returns something else:

		if (ret < 0) {
			PMD_LOG_ERR(INIT, "Failed to parse device arguments: %s",
				dev->devargs->cls_str);
			return -rte_errno;
		}

rte_eth_devargs_parse() returns the error code directly, it does not set rte_errno. If rte_errno happens to be 0 here, this returns 0, and sxe2_eth_pmd_probe() tests "ret != 0" and carries on with an empty eth_da. A parse failure then looks like a successful probe.

The line is not touched by the patch, but this patch is the one fixing the error handling of that call, so please fix it here too:

	return ret;

in both places.

#330 lore raw

PATCH v9 1/48 common/sxe2: fix null pointer in class driver remove

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_classes_driver_remove() calls cdrv->remove(cdev) without checking whether cdrv or cdrv->remove is NULL. If the class driver was never probed, cdev->cdrv remains NULL, and the unconditional call dereferences a NULL pointer, crashing during device removal.

Add NULL checks for cdrv and cdrv->remove, returning 0 when either is NULL.

Fixes 83866f8d7638 ("common/sxe2: add base driver skeleton")
---
 drivers/common/sxe2/sxe2_common.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/common/sxe2/sxe2_common.c +5 -1
index 5c5db85f29..6e387a8a73 100644
@@ -465,8 +465,12 @@ static int32_t sxe2_classes_driver_probe(struct sxe2_common_device *cdev,
 static int32_t sxe2_classes_driver_remove(struct sxe2_common_device *cdev)
 {
 	struct sxe2_class_driver *cdrv = cdev->cdrv;
+	int32_t ret = 0;
+
+	if (cdrv != NULL && cdrv->remove != NULL)
+		ret = cdrv->remove(cdev);
 
-	return cdrv->remove(cdev);
+	return ret;
 }
 
 static int32_t sxe2_kvargs_validate(struct sxe2_dev_kvargs_info *kv_info)
Signature · 1 line
2.52.0
#331 lore raw

PATCH v9 2/48 common/sxe2: allow munmap during kernel reset

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_drv_dev_munmap() refuses to unmap the BAR region when cdev->config.kernel_reset is set, returning -EPERM. After a kernel reset the application still needs to release the previously mapped regions during cleanup; blocking munmap leaves stale mappings and prevents a clean teardown.

Remove the kernel_reset check from sxe2_drv_dev_munmap() so the mapping is always released. The cdev parameter is no longer used, so mark it __rte_unused.

Fixes 66a10eb60ebe ("net/sxe2: add PCI BAR mapping")
---
 drivers/common/sxe2/sxe2_ioctl_chnl.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/common/sxe2/sxe2_ioctl_chnl.c +1 -7
index a233a78136..3e2fbf572f 100644
@@ -367,16 +367,10 @@ void
 
 RTE_EXPORT_INTERNAL_SYMBOL(sxe2_drv_dev_munmap)
 int32_t
-sxe2_drv_dev_munmap(struct sxe2_common_device *cdev, void *virt, uint64_t len)
+sxe2_drv_dev_munmap(struct sxe2_common_device *cdev __rte_unused, void *virt, uint64_t len)
 {
 	int32_t ret = 0;
 
-	if (cdev->config.kernel_reset) {
-		ret = -EPERM;
-		PMD_LOG_WARN(COM, "kernel reset, need restart app.");
-		goto l_end;
-	}
-
 	PMD_LOG_DEBUG(COM, "Munmap virt=%p, len=0x%"PRIx64"",
 		virt, len);
 
Signature · 1 line
2.52.0
#332 lore raw

PATCH v9 3/48 net/sxe2: fix VF PCI device ID

In reply to [email protected]

From: Jie Liu <[email protected]>

The VF PCI device ID is defined as 0x10b2 per the hardware specification, but the code incorrectly uses 0x10b.

As a result, the VF driver never binds to the device, making VF functionality completely unusable.

Fix this by changing SXE2_PCI_DEVICE_ID_VF_1 from 0x10b to 0x10b2.

Fixes d8e4e075acb4 ("net/sxe2: add probing skeleton")
---
 drivers/net/sxe2/sxe2_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/sxe2/sxe2_ethdev.c +1 -1
index 8bbfdc3a15..ec376b76dc 100644
@@ -44,7 +44,7 @@
 
 #define SXE2_PCI_VENDOR_ID_1    0x1ff2
 #define SXE2_PCI_DEVICE_ID_PF_1 0x10b1
-#define SXE2_PCI_DEVICE_ID_VF_1 0x10b
+#define SXE2_PCI_DEVICE_ID_VF_1 0x10b2
 
 #define SXE2_PCI_VENDOR_ID_2    0x1d94
 #define SXE2_PCI_DEVICE_ID_PF_2 0x1260
Signature · 1 line
2.52.0
#333 lore raw

PATCH v9 4/48 net/sxe2: fix MSIX register width in PF map table

In reply to [email protected]

From: Jie Liu <[email protected]>

The MSIX entry in sxe2_net_map_addr_info_pf sets a register width of 10 (decimal), but each PCIe MSIX table entry is 16 bytes (0x10). The VF map table already uses 0x10.

Since reg_width is used as the stride between MSIX entries in sxe2_dev_pci_seg_map(), the wrong value makes the mapped region too short and places the entries at incorrect offsets.

Change .reg_width from 10 to 0x10 for the SXE2_PCI_MAP_RES_IRQ_MSIX entry to match the VF table.

Fixes 66a10eb60ebe ("net/sxe2: add PCI BAR mapping")
---
 drivers/net/sxe2/sxe2_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/sxe2/sxe2_ethdev.c +1 -1
index ec376b76dc..5d8cfca6cf 100644
@@ -94,7 +94,7 @@ static struct sxe2_pci_map_addr_info sxe2_net_map_addr_info_pf[SXE2_PCI_MAP_RES_
 				      .reg_width = 4},
 	[SXE2_PCI_MAP_RES_IRQ_MSIX] = {.addr_base = SXE2_BAR4_MSIX_CTL(0),
 				      .bar_idx = 4,
-				      .reg_width = 10},
+				      .reg_width = 0x10},
 };
 
 static struct sxe2_pci_map_addr_info sxe2_net_map_addr_info_vf[SXE2_PCI_MAP_RES_MAX_COUNT] = {
Signature · 1 line
2.52.0
#334 lore raw

PATCH v9 5/48 net/sxe2: restore PF and port index caps assignment

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_func_caps_get() never assigns adapter->pf_idx from the device capabilities, leaving it at its zero-initialized value. Switchdev requests and representor setup that use pf_idx then report the wrong PF index on multi-PF configurations.

Restore the pf_idx and port_idx assignments in sxe2_func_caps_get() and drop the now-redundant port_idx assignment from sxe2_drv_dev_caps_set().

Fixes d8e4e075acb4 ("net/sxe2: add probing skeleton")
---
 drivers/net/sxe2/sxe2_ethdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/sxe2/sxe2_ethdev.c +2 -2
index 5d8cfca6cf..2e14c372f8 100644
@@ -1284,8 +1284,6 @@ void sxe2_eth_uinit(struct rte_eth_dev *dev __rte_unused)
 static void sxe2_drv_dev_caps_set(struct sxe2_adapter *adapter,
 			struct sxe2_drv_dev_caps_resp *dev_caps)
 {
-	adapter->port_idx = dev_caps->port_idx;
-
 	adapter->cap_flags = 0;
 
 	if (dev_caps->cap_flags & SXE2_DEV_CAPS_OFFLOAD_L2)
@@ -1344,6 +1342,8 @@ static int32_t sxe2_func_caps_get(struct sxe2_adapter *adapter)
 		goto l_end;
 
 	adapter->dev_type = dev_caps.dev_type;
+	adapter->port_idx = dev_caps.port_idx;
+	adapter->pf_idx = dev_caps.pf_idx;
 
 	sxe2_drv_dev_caps_set(adapter,  &dev_caps);
 
Signature · 1 line
2.52.0
#335 lore raw

PATCH v9 6/48 net/sxe2: fix VSI lifecycle management

In reply to [email protected]

From: Jie Liu <[email protected]>

Fix several VSI create/destroy issues introduced by VF representor support:

- Initialize other_vsi_list with TAILQ_INIT in sxe2_vsi_init before any VSI is inserted into it.
- Treat -EPERM as a non-fatal error when destroying VSIs, since the kernel may have already removed the VSI.
- Set main_vsi to NULL after destroy/free to avoid a dangling pointer if the VSI is destroyed again.

Fixes 635084db5d57 ("net/sxe2: support VF representors")
---
 drivers/net/sxe2/sxe2_vsi.c | 31 ++++++++++---------------------
 1 file changed, 10 insertions(+), 21 deletions(-)
drivers/net/sxe2/sxe2_vsi.c +10 -21
index d29480b931..e1a26fda6a 100644
@@ -96,21 +96,6 @@ static struct sxe2_vsi *sxe2_vsi_node_create(struct sxe2_adapter *adapter,
 	return vsi;
 }
 
-static void sxe2_vsi_node_free(struct sxe2_vsi *vsi)
-{
-	struct sxe2_adapter *adapter;
-
-	if (!vsi)
-		return;
-
-	adapter = vsi->adapter;
-	if (vsi->vsi_type == SXE2_VSI_T_ESW)
-		TAILQ_REMOVE(&adapter->vsi_ctxt.other_vsi_list, vsi, next);
-
-	rte_free(vsi);
-	vsi = NULL;
-}
-
 static int32_t sxe2_vsi_destroy(struct sxe2_adapter *adapter, struct sxe2_vsi *vsi)
 {
 	int32_t ret = 0;
@@ -131,6 +116,8 @@ static int32_t sxe2_vsi_destroy(struct sxe2_adapter *adapter, struct sxe2_vsi *v
 	}
 
 l_free:
+	if (vsi->vsi_type == SXE2_VSI_T_DPDK_ESW)
+		TAILQ_REMOVE(&adapter->vsi_ctxt.other_vsi_list, vsi, next);
 	rte_free(vsi);
 	vsi = NULL;
 
@@ -174,7 +161,7 @@ static int32_t sxe2_main_vsi_create(struct sxe2_adapter *adapter)
 	goto l_end;
 
 l_free_vsi:
-	sxe2_vsi_node_free(adapter->vsi_ctxt.main_vsi);
+	rte_free(adapter->vsi_ctxt.main_vsi);
 	adapter->vsi_ctxt.main_vsi = NULL;
 l_end:
 	return ret;
@@ -217,7 +204,7 @@ int32_t sxe2_other_vsi_create(struct sxe2_adapter *adapter, uint16_t cnt_vf)
 	goto l_end;
 
 l_free_vsi:
-	sxe2_vsi_node_free(other_vsi);
+	rte_free(other_vsi);
 l_end:
 	return ret;
 }
@@ -230,7 +217,7 @@ int32_t sxe2_vsi_init(struct rte_eth_dev *dev)
 	uint16_t srcvsi_cnt;
 
 	PMD_INIT_FUNC_TRACE();
-
+	TAILQ_INIT(&adapter->vsi_ctxt.other_vsi_list);
 	ret = sxe2_main_vsi_create(adapter);
 	if (ret) {
 		PMD_LOG_ERR(DRV, "Failed to create main VSI, ret=%d", ret);
@@ -283,13 +270,14 @@ void sxe2_vsi_uninit(struct rte_eth_dev *dev)
 
 l_free:
 	ret = sxe2_vsi_destroy(adapter, adapter->vsi_ctxt.main_vsi);
-	if (ret) {
+	if (ret && ret != -EPERM) {
 		PMD_LOG_ERR(DRV, "Failed to del vsi from fw, ret=%d", ret);
 		goto l_end;
 	}
+	adapter->vsi_ctxt.main_vsi = NULL;
 	RTE_TAILQ_FOREACH_SAFE(var, &adapter->vsi_ctxt.other_vsi_list, next, tvar) {
 		ret = sxe2_vsi_destroy(adapter, var);
-		if (ret) {
+		if (ret && ret != -EPERM) {
 			PMD_LOG_ERR(DRV, "Failed to del vsi from fw, ret=%d", ret);
 			break;
 		}
@@ -356,5 +344,6 @@ void sxe2_vsi_repr_main_vsi_destroy(struct rte_eth_dev *dev)
 {
 	struct sxe2_adapter *adapter = SXE2_DEV_PRIVATE_TO_ADAPTER(dev);
 
-	sxe2_vsi_node_free(adapter->vsi_ctxt.main_vsi);
+	rte_free(adapter->vsi_ctxt.main_vsi);
+	adapter->vsi_ctxt.main_vsi = NULL;
 }
Signature · 1 line
2.52.0
#336 lore raw

PATCH v9 7/48 net/sxe2: initialize stats in representor device init

In reply to [email protected]

From: Jie Liu <[email protected]>

Add sxe2_stats_init() call in sxe2_repr_dev_init to set up the statistics infrastructure for representor devices, and add the l_init_irq_ctxt_err error path to uninitialize the software irq context if stats initialization fails.

---
 drivers/net/sxe2/sxe2_ethdev_repr.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/net/sxe2/sxe2_ethdev_repr.c +8 -0
index f32318b731..c698baafe0 100644
@@ -483,8 +483,16 @@ int32_t sxe2_repr_dev_init(struct rte_eth_dev *dev,
 		goto l_init_sw_err;
 	}
 
+	ret = sxe2_stats_init(dev);
+	if (ret) {
+		PMD_LOG_ERR(INIT, "Failed to initialize stats, ret=[%d]", ret);
+		goto l_init_irq_ctxt_err;
+	}
+
 	goto l_end;
 
+l_init_irq_ctxt_err:
+	sxe2_sw_irq_ctxt_uninit(dev);
 l_init_sw_err:
 	sxe2_eth_uinit(dev);
 l_init_eth_err:
Signature · 1 line
2.52.0
#337 lore raw

PATCH v9 8/48 net/sxe2: use base device name for representor naming

In reply to [email protected]

From: Jie Liu <[email protected]>

Update the representor device naming to use the base device name prefix, and set the numa_node from the parent device data so that representor devices are allocated on the same NUMA node.

---
 drivers/net/sxe2/sxe2_ethdev_repr.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/sxe2/sxe2_ethdev_repr.c +4 -4
index c698baafe0..6f5642ad5d 100644
@@ -552,9 +552,8 @@ int32_t sxe2_switchdev_repr_devs_init(struct sxe2_adapter *adapter,
 	}
 
 	for (repr_idx = 0; repr_idx < req_eth_da->nb_representor_ports; ++repr_idx) {
-		snprintf(name, sizeof(name), "sxe2_representor_c%dpf%d%s%u",
-			 adapter->pf_idx, adapter->pf_idx,
-			 "vf",
+		snprintf(name, sizeof(name), "%s_representor_vf%u",
+			 adapter->cdev->dev->name,
 			 req_eth_da->representor_ports[repr_idx]);
 
 		eth_dev = rte_eth_dev_allocate(name);
@@ -562,10 +561,11 @@ int32_t sxe2_switchdev_repr_devs_init(struct sxe2_adapter *adapter,
 			ret = -ENOMEM;
 			goto l_release_port;
 		}
+		eth_dev->data->numa_node = adapter->dev_info.dev_data->numa_node;
 		eth_dev->data->dev_private = rte_zmalloc_socket(name,
 			sizeof(struct sxe2_adapter),
 			RTE_CACHE_LINE_SIZE,
-			rte_socket_id());
+			eth_dev->data->numa_node);
 
 		if (!eth_dev->data->dev_private) {
 			rte_eth_dev_release_port(eth_dev);
Signature · 1 line
2.52.0
#338 lore raw

PATCH v9 9/48 net/sxe2: propagate LSC event to VF representors

In reply to [email protected]

From: Jie Liu <[email protected]>

When the PF link state changes in switchdev mode, refresh the link status of every VF representor and trigger the RTE_ETH_EVENT_INTR_LSC callback on each, so applications receive link events on representor ports. Also log OICR in hexadecimal for better readability.

---
 drivers/net/sxe2/sxe2_irq.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
drivers/net/sxe2/sxe2_irq.c +20 -2
index 3306504761..ba764dd5e4 100644
@@ -77,14 +77,32 @@ static int32_t sxe2_fc_state_callback(struct rte_eth_dev *dev)
 static void sxe2_event_irq_common_handler(struct sxe2_adapter *adapter, uint64_t oicr)
 {
 	struct rte_eth_dev *dev = &rte_eth_devices[adapter->dev_info.dev_data->port_id];
+	struct rte_eth_dev *repr_eth_dev;
+	struct sxe2_adapter *repr_adapter;
+	uint16_t vf_id;
 
 	if (oicr & RTE_BIT32(SXE2_COM_EC_LINK_CHG)) {
-		PMD_DEV_LOG_INFO(adapter, DRV, "OICR=%" PRIu64, oicr);
+		PMD_DEV_LOG_INFO(adapter, DRV, "OICR=0x%" PRIx64, oicr);
 		(void)sxe2_drv_mac_link_status_get(adapter);
-		if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+		if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 			rte_eth_dev_callback_process(dev,
 						     RTE_ETH_EVENT_INTR_LSC,
 						     NULL);
+		}
+		if (adapter->switchdev_info.is_switchdev) {
+			for (vf_id = 0; vf_id < adapter->repr_ctxt.nb_repr_vf; vf_id++) {
+				repr_eth_dev = adapter->repr_ctxt.vf_rep_eth_dev[vf_id];
+				if (!repr_eth_dev)
+					continue;
+				repr_adapter = SXE2_DEV_PRIVATE_TO_ADAPTER(repr_eth_dev);
+				(void)sxe2_drv_mac_link_status_get(repr_adapter);
+				if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+					rte_eth_dev_callback_process(repr_eth_dev,
+								     RTE_ETH_EVENT_INTR_LSC,
+								     NULL);
+				}
+			}
+		}
 	}
 	if (oicr & RTE_BIT32(SXE2_COM_SW_MODE_SWITCHDEV)) {
 		PMD_DEV_LOG_INFO(adapter, DRV, "event notify switchdev");
Signature · 1 line
2.52.0
#339 lore raw

PATCH v9 10/48 net/sxe2: clear security context pointer on uninit

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_security_uinit() frees the security session but leaves dev->security_ctx pointing at the freed memory. Set dev->security_ctx to NULL after releasing the security context so a later access does not dereference a dangling pointer.

---
 drivers/net/sxe2/sxe2_security.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/sxe2/sxe2_security.c +1 -0
index bc59d1b880..8f31067942 100644
@@ -326,6 +326,7 @@ void sxe2_security_uinit(struct rte_eth_dev *dev)
 	if (sctx != NULL) {
 		rte_free(sctx);
 		sctx = NULL;
+		dev->security_ctx = NULL;
 	}
 
 	sxe2_ipsec_uinit(adapter);
Signature · 1 line
2.52.0
#340 lore raw

PATCH v9 11/48 net/sxe2: rename representor VSI ID fields

In reply to [email protected]

From: Jie Liu <[email protected]>

Rename repr_vf_k_vsi_id/repr_vf_u_vsi_id to
repr_vf_primary_vsi_id/repr_vf_backup_vsi_id in
sxe2_repr_private_data and update all references.

---
 drivers/net/sxe2/sxe2_dump.c      | 8 ++++----
 drivers/net/sxe2/sxe2_ethdev.h    | 4 ++--
 drivers/net/sxe2/sxe2_flow.c      | 4 ++--
 drivers/net/sxe2/sxe2_switchdev.c | 4 ++--
 4 files changed, 10 insertions(+), 10 deletions(-)
drivers/net/sxe2/sxe2_dump.c +4 -4
index d43473e083..590219f502 100644
@@ -211,16 +211,16 @@ sxe2_dump_switchdev_info(FILE *file, struct rte_eth_dev *dev)
 			"\t  -- repr_pf_id: %u\n"
 			"\t  -- repr_vf_id: %u\n"
 			"\t  -- repr_vf_vsi_id: %u\n"
-			"\t  -- repr_vf_k_vsi_id: %s\n"
-			"\t  -- repr_vf_u_vsi_id: %s\n",
+			"\t  -- repr_vf_primary_vsi_id: %s\n"
+			"\t  -- repr_vf_backup_vsi_id: %s\n",
 			adapter->repr_priv_data->repr_id,
 			adapter->repr_priv_data->repr_q_id,
 			adapter->repr_priv_data->repr_pf_id,
 			adapter->repr_priv_data->repr_vf_id,
 			adapter->repr_priv_data->repr_vf_vsi_id,
-			sxe2_vsi_id_str(adapter->repr_priv_data->repr_vf_k_vsi_id,
+			sxe2_vsi_id_str(adapter->repr_priv_data->repr_vf_primary_vsi_id,
 					k_vsi_buf, sizeof(k_vsi_buf)),
-			sxe2_vsi_id_str(adapter->repr_priv_data->repr_vf_u_vsi_id,
+			sxe2_vsi_id_str(adapter->repr_priv_data->repr_vf_backup_vsi_id,
 					u_vsi_buf, sizeof(u_vsi_buf)));
 		goto l_end;
 	}
drivers/net/sxe2/sxe2_ethdev.h +2 -2
index c54e8a435e..158198d74b 100644
@@ -263,8 +263,8 @@ struct sxe2_repr_private_data {
 	uint16_t repr_pf_id;
 	uint16_t repr_vf_id;
 	uint16_t repr_vf_vsi_id;
-	uint16_t repr_vf_k_vsi_id;
-	uint16_t repr_vf_u_vsi_id;
+	uint16_t repr_vf_primary_vsi_id;
+	uint16_t repr_vf_backup_vsi_id;
 };
 
 struct sxe2_sched_hw_cap {
drivers/net/sxe2/sxe2_flow.c +2 -2
index 63cfc36968..cf54803301 100644
@@ -380,9 +380,9 @@ static int32_t sxe2_flow_src_split_proc(struct rte_eth_dev *dev,
 	if (adapter->switchdev_info.is_switchdev && adapter->is_dev_repr) {
 		flow_bond_num = 1;
 		flow_src_vsi[SXE2_MAX_DRV_TYPE_DPDK][0] =
-			adapter->repr_priv_data->repr_vf_u_vsi_id;
+			adapter->repr_priv_data->repr_vf_backup_vsi_id;
 		flow_src_vsi[SXE2_MAX_DRV_TYPE_KERNEL][0] =
-			adapter->repr_priv_data->repr_vf_k_vsi_id;
+			adapter->repr_priv_data->repr_vf_primary_vsi_id;
 	}
 
 	for (idx = 0; idx < flow_bond_num; idx++) {
drivers/net/sxe2/sxe2_switchdev.c +2 -2
index 44703cfb5c..efb1468b91 100644
@@ -312,9 +312,9 @@ int32_t sxe2_switchdev_repr_private_data_init(struct rte_eth_dev *dev,
 	repr_priv_data->repr_q_id = repr_id;
 	repr_priv_data->repr_pf_id = parent_adapter->pf_idx;
 	repr_priv_data->repr_vf_id = repr_id;
-	repr_priv_data->repr_vf_k_vsi_id =
+	repr_priv_data->repr_vf_primary_vsi_id =
 		parent_adapter->repr_ctxt.repr_vf_id[repr_id].kernel_vsi_id;
-	repr_priv_data->repr_vf_u_vsi_id =
+	repr_priv_data->repr_vf_backup_vsi_id =
 		parent_adapter->repr_ctxt.repr_vf_id[repr_id].dpdk_vsi_id;
 
 	repr_priv_data->repr_vf_vsi_id =
Signature · 1 line
2.52.0
#341 lore raw

PATCH v9 12/48 net/sxe2: clean up duplicate function declarations

In reply to [email protected]

From: Jie Liu <[email protected]>

Remove duplicate function declarations from the sxe2 driver headers:
- sxe2_drv_promisc_config, sxe2_drv_vsi_info_get and sxe2_drv_rxq_mapping_set in sxe2_cmd_chnl.h
- sxe2_dev_pci_seg_unmap in sxe2_ethdev.h
- sxe2_rx_pkts_scattered in sxe2_txrx_poll.h

---
 drivers/net/sxe2/sxe2_cmd_chnl.h  | 6 ------
 drivers/net/sxe2/sxe2_ethdev.h    | 2 --
 drivers/net/sxe2/sxe2_txrx_poll.h | 2 --
 3 files changed, 10 deletions(-)
drivers/net/sxe2/sxe2_cmd_chnl.h +0 -6
index d63caad526..294ac15db4 100644
@@ -65,8 +65,6 @@ int32_t sxe2_drv_ipsec_rxsa_delete(struct sxe2_adapter *adapter,
 int32_t sxe2_drv_ipsec_txsa_delete(struct sxe2_adapter *adapter,
 			       uint16_t sa_id);
 
-int32_t sxe2_drv_promisc_config(struct sxe2_adapter *adapter, bool set);
-
 int32_t sxe2_drv_udp_tunnel_add(struct sxe2_adapter *adapter,
 			    enum sxe2_udp_tunnel_protocol tunnel_proto,
 			    uint16_t udp_port);
@@ -84,8 +82,6 @@ int32_t sxe2_drv_get_udp_tunnel_port(struct sxe2_adapter *adapter,
 
 int32_t sxe2_drv_vsi_info_get(struct sxe2_adapter *adapter, struct sxe2_vsi *vsi);
 
-int32_t sxe2_drv_vsi_info_get(struct sxe2_adapter *adapter, struct sxe2_vsi *vsi);
-
 int32_t sxe2_drv_mac_link_status_get(struct sxe2_adapter *adapter);
 
 int32_t sxe2_drv_get_mac_stats(struct sxe2_adapter *adapter);
@@ -110,8 +106,6 @@ int32_t sxe2_drv_mapping_reset(struct rte_eth_dev *eth_dev);
 
 int32_t sxe2_drv_mapping_stats_info_clear(struct rte_eth_dev *eth_dev);
 
-int32_t sxe2_drv_rxq_mapping_set(struct rte_eth_dev *eth_dev, uint16_t queue_id, uint8_t pool_idx);
-
 int32_t sxe2_drv_allmulti_config(struct sxe2_adapter *adapter, bool set);
 
 int32_t sxe2_drv_uc_config(struct sxe2_adapter *adapter, struct rte_ether_addr *addr, bool add);
drivers/net/sxe2/sxe2_ethdev.h +0 -2
index 158198d74b..1409be74d3 100644
@@ -385,8 +385,6 @@ void sxe2_dev_pci_seg_unmap(struct sxe2_adapter *adapter, uint32_t res_type);
 
 int32_t sxe2_dev_pci_map_init(struct rte_eth_dev *dev);
 
-void sxe2_dev_pci_seg_unmap(struct sxe2_adapter *adapter, uint32_t res_type);
-
 int32_t sxe2_udp_tunnel_port_del_common(struct sxe2_adapter *ad,
 		enum sxe2_udp_tunnel_protocol tunnel_proto, uint16_t udp_port);
 
drivers/net/sxe2/sxe2_txrx_poll.h +0 -2
index 708e3839d7..bfa099c097 100644
@@ -13,8 +13,6 @@ uint16_t sxe2_tx_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t
 
 uint16_t sxe2_rx_pkts_scattered(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
 
-uint16_t sxe2_rx_pkts_scattered(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
-
 uint16_t sxe2_rx_pkts_scattered_split(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
 
 #endif /* SXE2_TXRX_POLL_H */
Signature · 1 line
2.52.0
#342 lore raw

PATCH v9 13/48 net/sxe2: fix null VSI dereference in device info

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_dev_infos_get() dereferences adapter->vsi_ctxt.main_vsi without checking for NULL, which can crash when the main VSI has not been created yet.

Add an early NULL check on vsi and return -EINVAL.

Fixes d8e4e075acb4 ("net/sxe2: add probing skeleton")
---
 drivers/net/sxe2/sxe2_ethdev.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/sxe2/sxe2_ethdev.c +4 -0
index 2e14c372f8..02f9ce3d32 100644
@@ -781,6 +781,10 @@ static int32_t sxe2_dev_infos_get(struct rte_eth_dev *dev,
 	struct sxe2_adapter *adapter = SXE2_DEV_PRIVATE_TO_ADAPTER(dev);
 	struct sxe2_vsi *vsi = adapter->vsi_ctxt.main_vsi;
 
+	if (unlikely(vsi == NULL)) {
+		PMD_LOG_ERR(INIT, "main vsi is NULL");
+		return -EINVAL;
+	}
 	dev_info->max_rx_queues = vsi->rxqs.q_cnt;
 	dev_info->max_tx_queues = vsi->txqs.q_cnt;
 	dev_info->min_rx_bufsize = SXE2_MIN_BUF_SIZE;
Signature · 1 line
2.52.0
#343 lore raw

PATCH v9 14/48 net/sxe2: fill MAC addresses in device info

In reply to [email protected]

From: Jie Liu <[email protected]>

Fill max_mac_addrs in sxe2_dev_infos_get() so applications can query the maximum number of MAC addresses supported by the device.

---
 drivers/net/sxe2/sxe2_ethdev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/sxe2/sxe2_ethdev.c +1 -0
index 02f9ce3d32..e85e34aa1a 100644
@@ -792,6 +792,7 @@ static int32_t sxe2_dev_infos_get(struct rte_eth_dev *dev,
 	dev_info->max_lro_pkt_size = SXE2_FRAME_SIZE_MAX * SXE2_RX_LRO_DESC_MAX_NUM;
 	dev_info->max_mtu = dev_info->max_rx_pktlen - SXE2_ETH_OVERHEAD;
 	dev_info->min_mtu = RTE_ETHER_MIN_MTU;
+	dev_info->max_mac_addrs = SXE2_NUM_MACADDR_MAX;
 
 	dev_info->rx_offload_capa =
 		RTE_ETH_RX_OFFLOAD_VLAN_STRIP |
Signature · 1 line
2.52.0
#344 lore raw

PATCH v9 15/48 net/sxe2: fix QinQ and RSS offload capability report

In reply to [email protected]

From: Jie Liu <[email protected]>

Make the QINQ offload capabilities conditional on the port VLAN
setting: only advertise RTE_ETH_TX_OFFLOAD_QINQ_INSERT, RTE_ETH_RX_OFFLOAD_QINQ_STRIP and RTE_ETH_RX_OFFLOAD_VLAN_FILTER when no port VLAN is configured. Report the buffer split supported header ptypes count in sxe2_buffer_split_supported_hdr_ptypes_get().

Fixes a2b79a93515e ("net/sxe2: support L2 filtering and MAC config")
---
 drivers/net/sxe2/sxe2_ethdev.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)
drivers/net/sxe2/sxe2_ethdev.c +13 -8
index e85e34aa1a..7a11a93dff 100644
@@ -804,15 +804,11 @@ static int32_t sxe2_dev_infos_get(struct rte_eth_dev *dev,
 		RTE_ETH_RX_OFFLOAD_SCTP_CKSUM |
 		RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM |
 		RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT |
-#ifndef RTE_LIBRTE_SXE2_16BYTE_RX_DESC
-		RTE_ETH_RX_OFFLOAD_QINQ_STRIP |
-#endif
 		RTE_ETH_RX_OFFLOAD_VLAN_EXTEND |
 		RTE_ETH_RX_OFFLOAD_TCP_LRO;
 
 	dev_info->tx_offload_capa =
 		RTE_ETH_TX_OFFLOAD_VLAN_INSERT |
-		RTE_ETH_TX_OFFLOAD_QINQ_INSERT |
 		RTE_ETH_TX_OFFLOAD_MULTI_SEGS |
 		RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE |
 		RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
@@ -855,14 +851,22 @@ static int32_t sxe2_dev_infos_get(struct rte_eth_dev *dev,
 		RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO;
 
 
-	if (adapter->cap_flags & SXE2_DEV_CAPS_OFFLOAD_PTP)
-		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_TIMESTAMP;
-
 	if (sxe2_ipsec_supported(adapter)) {
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_SECURITY;
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_SECURITY;
 	}
 
+	if (adapter->cap_flags & SXE2_DEV_CAPS_OFFLOAD_PTP)
+		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_TIMESTAMP;
+
+	if (!sxe2_dev_port_vlan_check(dev)) {
+		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_QINQ_INSERT;
+#ifndef RTE_LIBRTE_SXE2_16BYTE_RX_DESC
+		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_QINQ_STRIP;
+#endif
+		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_VLAN_FILTER;
+	}
+
 	if (adapter->cap_flags & SXE2_DEV_CAPS_OFFLOAD_RSS) {
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
 		dev_info->flow_type_rss_offloads  |= SXE2_RSS_HF_SUPPORT_ALL;
@@ -934,7 +938,7 @@ static int32_t sxe2_dev_infos_get(struct rte_eth_dev *dev,
 
 static const uint32_t *
 sxe2_buffer_split_supported_hdr_ptypes_get(struct rte_eth_dev *dev __rte_unused,
-					   size_t *no_of_elements __rte_unused)
+					   size_t *no_of_elements)
 {
 	static const uint32_t ptypes[] = {
 		RTE_PTYPE_L2_ETHER,
@@ -972,6 +976,7 @@ sxe2_buffer_split_supported_hdr_ptypes_get(struct rte_eth_dev *dev __rte_unused,
 
 		RTE_PTYPE_UNKNOWN
 	};
+	*no_of_elements = RTE_DIM(ptypes) - 1;
 
 	return ptypes;
 }
Signature · 1 line
2.52.0
#345 lore raw

PATCH v9 16/48 net/sxe2: use regular write for mapped registers

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_pci_map_write_reg() uses the write-combined store (SXE2_PCI_REG_WRITE_WC) to write control registers, which is intended for doorbell/tail writes and can be lossy or delayed for ordering sensitive register updates.

Add SXE2_PCI_REG_WRITE macro using a regular rte_write32() and use it in sxe2_pci_map_write_reg().

Fixes 8cebf80f1eda ("net/sxe2: support Rx interrupt")
---
 drivers/net/sxe2/sxe2_ethdev.c | 2 +-
 drivers/net/sxe2/sxe2_ethdev.h | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/net/sxe2/sxe2_ethdev.c +1 -1
index 7a11a93dff..589f09c113 100644
@@ -1439,7 +1439,7 @@ void sxe2_pci_map_write_reg(struct sxe2_adapter *adapter,
 		goto l_ret;
 	}
 
-	SXE2_PCI_REG_WRITE_WC(reg_addr, value);
+	SXE2_PCI_REG_WRITE(reg_addr, value);
 l_ret:
 	return;
 }
drivers/net/sxe2/sxe2_ethdev.h +2 -0
index 1409be74d3..cf1104144c 100644
@@ -355,6 +355,8 @@ struct sxe2_adapter {
 #define SXE2_DEV_PRIVATE_TO_ADAPTER(dev) \
 	((struct sxe2_adapter *)(dev)->data->dev_private)
 
+#define SXE2_PCI_REG_WRITE(reg, value) rte_write32((rte_cpu_to_le_32(value)), (reg))
+
 void *sxe2_pci_map_addr_get(struct sxe2_adapter *adapter,
 			    enum sxe2_pci_map_resource res_type,
 			    uint16_t idx_in_func);
Signature · 1 line
2.52.0
#346 lore raw

PATCH v9 17/48 net/sxe2: move PCI register read macro to common header

In reply to [email protected]

From: Jie Liu <[email protected]>

Move SXE2_PCI_REG_READ to sxe2_ethdev.h so the PCI register access macros are kept together in the common header, matching SXE2_PCI_REG_WRITE.

---
 drivers/net/sxe2/sxe2_ethdev.h | 1 +
 drivers/net/sxe2/sxe2_queue.h  | 2 --
 2 files changed, 1 insertion(+), 2 deletions(-)
drivers/net/sxe2/sxe2_ethdev.h +1 -0
index cf1104144c..f2557b28c3 100644
@@ -356,6 +356,7 @@ struct sxe2_adapter {
 	((struct sxe2_adapter *)(dev)->data->dev_private)
 
 #define SXE2_PCI_REG_WRITE(reg, value) rte_write32((rte_cpu_to_le_32(value)), (reg))
+#define SXE2_PCI_REG_READ(reg)         rte_read32(reg)
 
 void *sxe2_pci_map_addr_get(struct sxe2_adapter *adapter,
 			    enum sxe2_pci_map_resource res_type,
drivers/net/sxe2/sxe2_queue.h +0 -2
index a300b66771..10bdaf5b8d 100644
@@ -12,8 +12,6 @@
 #include "sxe2_drv_cmd.h"
 #include "sxe2_txrx_common.h"
 
-#define SXE2_PCI_REG_READ(reg)			\
-		rte_read32(reg)
 #define SXE2_PCI_REG_WRITE_WC(reg, value)			\
 		rte_write32_wc((rte_cpu_to_le_32(value)), reg)
 #define SXE2_PCI_REG_WRITE_WC_RELAXED(reg, value)		\
Signature · 1 line
2.52.0
#347 lore raw

PATCH v9 18/48 net/sxe2: validate PCI map resource type

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_dev_pci_res_seg_map() indexes adapter->map_ctxt.addr_info[] with res_type without bounds checking, which can access out of bounds when an invalid resource type is passed.

Add a bounds check on res_type and return -EINVAL.

Fixes 66a10eb60ebe ("net/sxe2: add PCI BAR mapping")
---
 drivers/net/sxe2/sxe2_ethdev.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/sxe2/sxe2_ethdev.c +6 -0
index 589f09c113..9ef93b8076 100644
@@ -1552,6 +1552,12 @@ int32_t sxe2_dev_pci_res_seg_map(struct sxe2_adapter *adapter,
 	struct sxe2_pci_map_addr_info *addr_info = NULL;
 	int32_t ret = 0;
 
+	if (unlikely(res_type >= SXE2_PCI_MAP_RES_MAX_COUNT)) {
+		PMD_DEV_LOG_ERR(adapter, INIT, "Invalid resource type %u", res_type);
+		ret = -EINVAL;
+		goto l_end;
+	}
+
 	addr_info = &adapter->map_ctxt.addr_info[res_type];
 	if (!addr_info || addr_info->bar_idx == SXE2_PCI_MAP_BAR_INVALID) {
 		PMD_DEV_LOG_ERR(adapter, INIT, "Invalid bar index with resource type %d", res_type);
Signature · 1 line
2.52.0
#348 lore raw

PATCH v9 19/48 net/sxe2: guard PCI BAR unmap when not initialized

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_dev_pci_map_uinit() calls sxe2_dev_pci_seg_unmap() and walks bar_info unconditionally. Only perform the unmap and free when bar_info has been allocated, so an uninitialized map context is handled cleanly.

Fixes 66a10eb60ebe ("net/sxe2: add PCI BAR mapping")
---
 drivers/net/sxe2/sxe2_ethdev.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/net/sxe2/sxe2_ethdev.c +6 -8
index 9ef93b8076..fdff4ae10f 100644
@@ -1773,14 +1773,13 @@ void sxe2_dev_pci_map_uinit(struct rte_eth_dev *dev)
 	uint8_t i = 0;
 
 	PMD_INIT_FUNC_TRACE();
+	if (map_ctxt->bar_info != NULL) {
+		(void)sxe2_dev_pci_seg_unmap(adapter, SXE2_PCI_MAP_RES_DOORBELL_RX_TAIL);
+		(void)sxe2_dev_pci_seg_unmap(adapter, SXE2_PCI_MAP_RES_DOORBELL_TX);
+		(void)sxe2_dev_pci_seg_unmap(adapter, SXE2_PCI_MAP_RES_IRQ_DYN);
+		(void)sxe2_dev_pci_seg_unmap(adapter, SXE2_PCI_MAP_RES_IRQ_ITR);
+		(void)sxe2_dev_pci_seg_unmap(adapter, SXE2_PCI_MAP_RES_IRQ_MSIX);
 
-	(void)sxe2_dev_pci_seg_unmap(adapter, SXE2_PCI_MAP_RES_DOORBELL_RX_TAIL);
-	(void)sxe2_dev_pci_seg_unmap(adapter, SXE2_PCI_MAP_RES_DOORBELL_TX);
-	(void)sxe2_dev_pci_seg_unmap(adapter, SXE2_PCI_MAP_RES_IRQ_DYN);
-	(void)sxe2_dev_pci_seg_unmap(adapter, SXE2_PCI_MAP_RES_IRQ_ITR);
-	(void)sxe2_dev_pci_seg_unmap(adapter, SXE2_PCI_MAP_RES_IRQ_MSIX);
-
-	if (map_ctxt != NULL && map_ctxt->bar_info != NULL) {
 		for (i = 0; i < map_ctxt->bar_cnt; i++) {
 			bar_info = &map_ctxt->bar_info[i];
 			if (bar_info != NULL && bar_info->seg_info != NULL) {
@@ -1791,7 +1790,6 @@ void sxe2_dev_pci_map_uinit(struct rte_eth_dev *dev)
 		rte_free(map_ctxt->bar_info);
 		map_ctxt->bar_info = NULL;
 	}
-
 	adapter->dev_info.dev_data = NULL;
 }
 
Signature · 1 line
2.52.0
#349 lore raw

PATCH v9 20/48 net/sxe2: fix duplicated cleanup in dev close

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_dev_close() calls sxe2_switchdev_uninit() and sxe2_dev_pci_map_uinit() twice, and releases resources in an order that does not match the initialization sequence.

Remove the duplicated calls and align the teardown order with the device init order.

Fixes 8cebf80f1eda ("net/sxe2: support Rx interrupt")
---
 drivers/net/sxe2/sxe2_ethdev.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/sxe2/sxe2_ethdev.c +2 -4
index fdff4ae10f..fab7dcf44c 100644
@@ -2041,17 +2041,15 @@ static int32_t sxe2_dev_close(struct rte_eth_dev *dev)
 	(void)sxe2_queues_release(dev);
 	sxe2_mp_uninit(dev);
 	(void)sxe2_sched_uinit(dev);
-	(void)sxe2_rss_disable(dev);
 	(void)sxe2_flow_uninit(dev);
+	(void)sxe2_rss_disable(dev);
 	(void)sxe2_udp_tunnel_port_clear(dev);
-	sxe2_vsi_uninit(dev);
 	sxe2_security_uinit(dev);
 	sxe2_intr_uninit(dev);
 	(void)sxe2_switchdev_uninit(dev);
 	sxe2_sw_uninit(dev);
-	(void)sxe2_switchdev_uninit(dev);
-	sxe2_dev_pci_map_uinit(dev);
 	sxe2_eth_uinit(dev);
+	sxe2_vsi_uninit(dev);
 	sxe2_dev_pci_map_uinit(dev);
 	sxe2_free_repr_info(dev);
 	sxe2_fc_state_uinit(dev);
Signature · 1 line
2.52.0
#350 lore raw

PATCH v9 21/48 net/sxe2: align dev init and cleanup order

In reply to [email protected]

From: Jie Liu <[email protected]>

Move sxe2_eth_init() to be called before sxe2_sw_init() and rearrange the error cleanup labels so that resources are torn down in the reverse order of initialization.

---
 drivers/net/sxe2/sxe2_ethdev.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/net/sxe2/sxe2_ethdev.c +8 -8
index fab7dcf44c..a4ce601349 100644
@@ -1942,6 +1942,12 @@ static int32_t sxe2_dev_init(struct rte_eth_dev *dev,
 		goto init_switchdev_err;
 	}
 
+	ret = sxe2_eth_init(dev);
+	if (ret) {
+		PMD_LOG_ERR(INIT, "Failed to initialize eth parameters, ret=%d", ret);
+		goto init_eth_err;
+	}
+
 	ret = sxe2_sw_init(dev);
 	if (ret) {
 		PMD_LOG_ERR(INIT, "Failed to initialize sw parameters, ret=[%d]", ret);
@@ -1954,12 +1960,6 @@ static int32_t sxe2_dev_init(struct rte_eth_dev *dev,
 		goto init_irq_err;
 	}
 
-	ret = sxe2_eth_init(dev);
-	if (ret) {
-		PMD_LOG_ERR(INIT, "Failed to initialize eth parameters, ret=%d", ret);
-		goto init_eth_err;
-	}
-
 	ret = sxe2_security_init(dev);
 	if (ret) {
 		PMD_LOG_ERR(INIT, "Failed to initialize security, ret=%d", ret);
@@ -2014,12 +2014,12 @@ static int32_t sxe2_dev_init(struct rte_eth_dev *dev,
 init_rss_err:
 	sxe2_security_uinit(dev);
 init_security_err:
-	sxe2_eth_uinit(dev);
-init_eth_err:
 	sxe2_intr_uninit(dev);
 init_irq_err:
 	sxe2_sw_uninit(dev);
 init_sw_err:
+	sxe2_eth_uinit(dev);
+init_eth_err:
 	(void)sxe2_switchdev_uninit(dev);
 init_switchdev_err:
 init_dev_info_err:
Signature · 1 line
2.52.0
#351 lore raw

PATCH v9 22/48 net/sxe2: simplify switchdev representor matching

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_switchdev_repr_match() encodes the kernel representor ID and compares it against each requested port, which is fragile. Match the PF number and VF ID directly against the switchdev representor info instead, and drop the sxe2_switchdev_repr_id_encode_get() helper.

Fixes 635084db5d57 ("net/sxe2: support VF representors")
---
 drivers/net/sxe2/sxe2_ethdev.c | 72 +++++++++++++++++-----------------
 drivers/net/sxe2/sxe2_ethdev.h |  3 --
 2 files changed, 37 insertions(+), 38 deletions(-)
drivers/net/sxe2/sxe2_ethdev.c +37 -35
index a4ce601349..c5f6bc8af4 100644
@@ -2147,42 +2147,25 @@ static int32_t sxe2_fw_version_string_get(struct rte_eth_dev *dev, char *fw_vers
 	return ret;
 }
 
-static uint16_t sxe2_switchdev_repr_id_encode_get(struct sxe2_switchdev_info *switchdev_info)
-{
-	enum rte_eth_representor_type type;
-	uint16_t repr = switchdev_info->vf_num;
-	uint32_t pf = switchdev_info->pf_num;
-
-	switch (switchdev_info->port_name_type) {
-	case SXE2_PHYS_PORT_NAME_TYPE_UPLINK:
-		if (!switchdev_info->representor)
-			return UINT16_MAX;
-		type = RTE_ETH_REPRESENTOR_PF;
-		pf = switchdev_info->mpesw_owner;
-		break;
-	case SXE2_PHYS_PORT_NAME_TYPE_PFVF:
-	default:
-		type = RTE_ETH_REPRESENTOR_VF;
-		break;
-	}
-
-	return SXE2_REPRESENTOR_ID(pf, type, repr);
-}
-
 static bool sxe2_switchdev_repr_match(struct sxe2_adapter *adapter,
 				   struct rte_eth_devargs *req_eth_da)
 {
-	uint32_t port_idx = 0;
-	uint32_t repr_idx;
-	uint16_t kernel_repr_id = sxe2_switchdev_repr_id_encode_get(&adapter->switchdev_info);
-	uint16_t repr_id;
+	uint16_t port_idx;
+	uint16_t repr_idx;
+	uint16_t vf_id;
+	uint16_t i;
 
 	switch (req_eth_da->type) {
 	case RTE_ETH_REPRESENTOR_PF:
+		if (adapter->switchdev_info.port_name_type !=
+			SXE2_PHYS_PORT_NAME_TYPE_UPLINK) {
+			rte_errno = EBUSY;
+			return false;
+		}
 		break;
 	case RTE_ETH_REPRESENTOR_VF:
 		if (adapter->switchdev_info.port_name_type !=
-		SXE2_PHYS_PORT_NAME_TYPE_PFVF) {
+			SXE2_PHYS_PORT_NAME_TYPE_PFVF) {
 			rte_errno = EBUSY;
 			return false;
 		}
@@ -2195,15 +2178,34 @@ static bool sxe2_switchdev_repr_match(struct sxe2_adapter *adapter,
 		return false;
 	}
 
+	if (req_eth_da->nb_ports > 0) {
+		for (port_idx = 0; port_idx < req_eth_da->nb_ports; ++port_idx) {
+			if (adapter->switchdev_info.pf_num == req_eth_da->ports[port_idx])
+				break;
+		}
+		if (port_idx == req_eth_da->nb_ports) {
+			PMD_DEV_LOG_DEBUG(adapter, DRV, "switchdev pf %u not match req pf",
+				adapter->switchdev_info.pf_num);
+			rte_errno = EBUSY;
+			return false;
+		}
+	}
+
 	for (repr_idx = 0; repr_idx < req_eth_da->nb_representor_ports; ++repr_idx) {
-		repr_id = SXE2_REPRESENTOR_ID(req_eth_da->ports[port_idx],
-					      req_eth_da->type,
-					      req_eth_da->representor_ports[repr_idx]);
-		if (repr_id == kernel_repr_id)
-			return true;
-	}
-	rte_errno = EBUSY;
-	return false;
+		for (i = 0; i < adapter->repr_ctxt.nb_vf; ++i) {
+			vf_id = rte_le_to_cpu_16(adapter->repr_ctxt.repr_vf_id[i].func_id);
+			if (vf_id == req_eth_da->representor_ports[repr_idx])
+				break;
+		}
+		if (i == adapter->repr_ctxt.nb_vf) {
+			PMD_DEV_LOG_DEBUG(adapter, DRV, "switchdev vf %u not match req vf(cnt:%u)",
+				req_eth_da->representor_ports[repr_idx], adapter->repr_ctxt.nb_vf);
+			rte_errno = EBUSY;
+			return false;
+		}
+	}
+
+	return true;
 }
 
 static int32_t sxe2_eth_pmd_probe_pf(struct sxe2_common_device *cdev,
drivers/net/sxe2/sxe2_ethdev.h +0 -3
index f2557b28c3..e818578319 100644
@@ -65,9 +65,6 @@ enum sxe2_fnav_tunnel_flag_type {
 #define upper_32_bits(n) ((uint32_t)(((n) >> 16) >> 16))
 #define lower_32_bits(n) ((uint32_t)((n) & 0xffffffff))
 
-#define SXE2_REPRESENTOR_ID(pf, type, repr) \
-		(((pf) << 14) + ((type) << 12) + ((repr) & 0xfff))
-
 #define SXE2_I2C_EEPROM_DEV_ADDR	0xA0
 #define SXE2_I2C_EEPROM_DEV_ADDR2	0xA2
 #define SXE2_MODULE_TYPE_SFP		0x03
Signature · 1 line
2.52.0
#352 lore raw

PATCH v9 23/48 net/sxe2: rename fnav cid manager symbols to flow

In reply to [email protected]

From: Jie Liu <[email protected]>

Rename the sxe2_fnav_cid_mgr, sxe2_fnav_cid_mgr_list_t, sxe2_fnav_count_resource and sxe2_fnav_get_filter_cid symbols to the sxe2_flow_* prefix for consistency with the flow module naming.

---
 drivers/net/sxe2/sxe2_cmd_chnl.c    |  2 +-
 drivers/net/sxe2/sxe2_cmd_chnl.h    |  2 +-
 drivers/net/sxe2/sxe2_flow.c        | 46 ++++++++++++++---------------
 drivers/net/sxe2/sxe2_flow.h        |  6 ++--
 drivers/net/sxe2/sxe2_flow_define.h | 12 ++++----
 5 files changed, 34 insertions(+), 34 deletions(-)
drivers/net/sxe2/sxe2_cmd_chnl.c +1 -1
index b09989fe50..3229c72597 100644
@@ -1800,7 +1800,7 @@ int32_t sxe2_drv_flow_fnav_free_stat(struct sxe2_adapter *adapter, uint32_t stat
 }
 
 int32_t sxe2_drv_flow_fnav_query_stat(struct sxe2_adapter *adapter,
-		struct sxe2_fnav_cid_mgr *mgr)
+		struct sxe2_flow_cid_mgr *mgr)
 {
 	struct sxe2_drv_flow_fnav_query_stat_req req = { 0 };
 	struct sxe2_drv_flow_fnav_query_stat_resp resp = { 0 };
drivers/net/sxe2/sxe2_cmd_chnl.h +1 -1
index 294ac15db4..cfea1a1f0e 100644
@@ -159,7 +159,7 @@ int32_t sxe2_drv_flow_fnav_get_stat_id(struct sxe2_adapter *adapter, uint32_t *s
 int32_t sxe2_drv_flow_fnav_free_stat(struct sxe2_adapter *adapter, uint32_t stat_id);
 
 int32_t sxe2_drv_flow_fnav_query_stat(struct sxe2_adapter *adapter,
-		struct sxe2_fnav_cid_mgr *mgr);
+		struct sxe2_flow_cid_mgr *mgr);
 
 int32_t sxe2_drv_srcvsi_prune_config(struct sxe2_adapter *adapter,
 		uint16_t *vsi_list, uint16_t vsi_cnt, bool set);
drivers/net/sxe2/sxe2_flow.c +23 -23

111 lines not on this page · raw message

drivers/net/sxe2/sxe2_flow.h +3 -3
index daaeedd4dc..8d47b11ff4 100644
@@ -14,16 +14,16 @@ int32_t sxe2_flow_init(struct rte_eth_dev *dev);
 
 int32_t sxe2_flow_uninit(struct rte_eth_dev *dev);
 
-int32_t sxe2_fnav_get_filter_cid(struct sxe2_adapter *adapter, struct sxe2_flow *flow);
+int32_t sxe2_flow_get_filter_cid(struct sxe2_adapter *adapter, struct sxe2_flow *flow);
 
 int32_t sxe2_flow_free_mgr(struct sxe2_adapter *adapter,
 		       struct sxe2_flow *flow,
-		       struct sxe2_fnav_cid_mgr **mgr_ptr,
+		       struct sxe2_flow_cid_mgr **mgr_ptr,
 		       struct rte_flow_error *error);
 
 int32_t sxe2_flow_query_mgr(struct sxe2_adapter *adapter,
 			struct sxe2_flow *flow,
-			struct sxe2_fnav_cid_mgr **mgr_ptr,
+			struct sxe2_flow_cid_mgr **mgr_ptr,
 			struct rte_flow_error *error);
 
 int32_t sxe2_flow_init_udp_tunnel_port(struct rte_eth_dev *dev);
drivers/net/sxe2/sxe2_flow_define.h +6 -6
index 263a573f04..8a5d871978 100644
@@ -98,8 +98,8 @@ struct rte_flow {
 };
 TAILQ_HEAD(rte_flow_list_t, rte_flow);
 
-struct sxe2_fnav_cid_mgr {
-	TAILQ_ENTRY(sxe2_fnav_cid_mgr) next;
+struct sxe2_flow_cid_mgr {
+	TAILQ_ENTRY(sxe2_flow_cid_mgr) next;
 	uint16_t stat_index;
 	uint32_t user_id;
 	uint32_t driver_id;
@@ -107,18 +107,18 @@ struct sxe2_fnav_cid_mgr {
 	uint64_t hits;
 	uint64_t bytes;
 };
-TAILQ_HEAD(sxe2_fnav_cid_mgr_list_t, sxe2_fnav_cid_mgr);
+TAILQ_HEAD(sxe2_flow_cid_mgr_list_t, sxe2_flow_cid_mgr);
 
-struct sxe2_fnav_count_resource {
+struct sxe2_flow_count_resource {
 	uint32_t count_type;
 	uint32_t global_index;
-	struct sxe2_fnav_cid_mgr_list_t fnav_cid_mgr_list;
+	struct sxe2_flow_cid_mgr_list_t flow_cid_mgr_list;
 };
 
 struct sxe2_flow_context {
 	struct rte_flow_list_t rte_flow_list;
 	rte_spinlock_t flow_list_lock;
-	struct sxe2_fnav_count_resource hw_res;
+	struct sxe2_flow_count_resource hw_res;
 	uint16_t tunnel_port_list[SXE2_FLOW_UDP_TUNNEL_MAX];
 	uint32_t fnav_inited;
 };
Signature · 1 line
2.52.0
#353 lore raw

PATCH v9 24/48 net/sxe2: move tunnel port helpers into flow module

In reply to [email protected]

From: Jie Liu <[email protected]>

Move sxe2_flow_parse_pattern_ipip, sxe2_flow_add_udp_tunnel_port and sxe2_flow_add_tunnel_port from sxe2_flow_parse_pattern.c into sxe2_flow.c as static helpers, and drop the public declaration of sxe2_flow_add_tunnel_port from the header, keeping the tunnel port handling internal to the flow module.

---
 drivers/net/sxe2/sxe2_flow.c               | 113 +++++++++++++++++++++
 drivers/net/sxe2/sxe2_flow_parse_pattern.c | 113 ---------------------
 drivers/net/sxe2/sxe2_flow_parse_pattern.h |   6 --
 3 files changed, 113 insertions(+), 119 deletions(-)
drivers/net/sxe2/sxe2_flow.c +113 -0
index a33b8606df..cd39385340 100644
@@ -550,6 +550,119 @@ int32_t sxe2_flow_init_udp_tunnel_port(struct rte_eth_dev *dev)
 	return ret;
 }
 
+static int32_t sxe2_flow_add_udp_tunnel_port(struct sxe2_adapter *adapter,
+					 enum sxe2_flow_udp_tunnel_protocol proto,
+					 struct sxe2_flow *flow,
+					 BITMAP_TYPE *flow_type)
+{
+	int32_t ret = 0;
+	uint16_t tun_port;
+
+	tun_port = adapter->flow_ctxt.tunnel_port_list[proto];
+	if (tun_port == 0xffff || tun_port == 0) {
+		ret = -EINVAL;
+		PMD_LOG_ERR(DRV, "UDP tunnel port not initialized, proto: %d", proto);
+		goto l_end;
+	}
+	if (!sxe2_test_bit(SXE2_EXPANSION_OUTER_UDP, flow_type)) {
+		ret = -EINVAL;
+		PMD_LOG_ERR(DRV, "UDP must be over tunnel");
+		goto l_end;
+	}
+	sxe2_set_bit(SXE2_FLOW_FLD_ID_UDP_DST_PORT, flow->pattern_outer.map_spec);
+	flow->pattern_outer.item_spec.udp.dest = rte_cpu_to_be_16(tun_port);
+l_end:
+	return ret;
+}
+
+static int32_t sxe2_flow_parse_pattern_ipip(struct sxe2_flow *flow, BITMAP_TYPE *flow_type)
+{
+	sxe2_set_bit(SXE2_EXPANSION_IPIP, flow_type);
+	if (sxe2_test_bit(SXE2_EXPANSION_OUTER_IPV4, flow_type)) {
+		sxe2_set_bit(SXE2_FLOW_FLD_ID_IPV4_PROT, flow->pattern_outer.map_spec);
+		if (sxe2_test_bit(SXE2_EXPANSION_IPV4, flow_type))
+			flow->pattern_outer.item_spec.ipv4.protocol = SXE2_FLOW_IP_PROTOCOL_IPV4;
+		if (sxe2_test_bit(SXE2_EXPANSION_IPV6, flow_type))
+			flow->pattern_outer.item_spec.ipv4.protocol = SXE2_FLOW_IP_PROTOCOL_IPV6;
+	}
+	if (sxe2_test_bit(SXE2_EXPANSION_OUTER_IPV6, flow_type)) {
+		sxe2_set_bit(SXE2_FLOW_FLD_ID_IPV6_PROT, flow->pattern_outer.map_spec);
+		if (sxe2_test_bit(SXE2_EXPANSION_ETH, flow_type)) {
+			flow->pattern_outer.item_spec.ipv6.nexthdr = SXE2_FLOW_IP_PROTOCOL_ETH;
+		} else {
+			if (sxe2_test_bit(SXE2_EXPANSION_IPV4, flow_type))
+				flow->pattern_outer.item_spec.ipv6.nexthdr =
+					SXE2_FLOW_IP_PROTOCOL_IPV4;
+			if (sxe2_test_bit(SXE2_EXPANSION_IPV6, flow_type))
+				flow->pattern_outer.item_spec.ipv6.nexthdr =
+					SXE2_FLOW_IP_PROTOCOL_IPV6;
+		}
+	}
+	return 0;
+}
+
+static int32_t sxe2_flow_add_tunnel_port(struct rte_eth_dev *dev,
+			struct rte_flow_error *error,
+			struct sxe2_flow *flow, BITMAP_TYPE *flow_type,
+			enum sxe2_flow_tunnel_type tunnel_type)
+{
+	int32_t ret = 0;
+	enum sxe2_flow_udp_tunnel_protocol proto = SXE2_FLOW_UDP_TUNNEL_MAX;
+	struct sxe2_adapter *adapter = SXE2_DEV_PRIVATE_TO_ADAPTER(dev);
+	struct sxe2_flow_pattern *pattern = &flow->pattern_outer;
+	switch (tunnel_type) {
+	case SXE2_FLOW_TUNNEL_TYPE_VXLAN:
+		if (sxe2_test_bit(SXE2_EXPANSION_ETH, flow_type)) {
+			proto = SXE2_FLOW_UDP_TUNNEL_PROTOCOL_VXLAN;
+		} else if (sxe2_test_bit(SXE2_EXPANSION_IPV4, flow_type) ||
+			sxe2_test_bit(SXE2_EXPANSION_IPV6, flow_type)) {
+			proto = SXE2_FLOW_UDP_TUNNEL_PROTOCOL_VXLAN_GPE;
+		}
+		break;
+	case SXE2_FLOW_TUNNEL_TYPE_GTPU:
+		proto = SXE2_FLOW_UDP_TUNNEL_PROTOCOL_GTP_U;
+		break;
+	case SXE2_FLOW_TUNNEL_TYPE_GENEVE:
+		proto = SXE2_FLOW_UDP_TUNNEL_PROTOCOL_GENEVE;
+		break;
+	case SXE2_FLOW_TUNNEL_TYPE_GRE:
+		if (sxe2_test_bit(SXE2_EXPANSION_OUTER_UDP, flow_type)) {
+			proto = SXE2_FLOW_UDP_TUNNEL_PROTOCOL_NVGRE;
+		} else {
+			if (sxe2_test_bit(SXE2_EXPANSION_OUTER_IPV4, flow_type)) {
+				pattern->item_spec.ipv4.protocol = SXE2_FLOW_IP_PROTOCOL_GRE;
+				sxe2_set_bit(SXE2_FLOW_FLD_ID_IPV4_PROT, pattern->map_spec);
+			}
+			if (sxe2_test_bit(SXE2_EXPANSION_OUTER_IPV6, flow_type)) {
+				pattern->item_spec.ipv6.nexthdr = SXE2_FLOW_IP_PROTOCOL_GRE;
+				sxe2_set_bit(SXE2_FLOW_FLD_ID_IPV6_PROT, pattern->map_spec);
+			}
+		}
+		break;
+	case SXE2_FLOW_TUNNEL_TYPE_IPIP:
+		ret = sxe2_flow_parse_pattern_ipip(flow, flow_type);
+		break;
+	default:
+		break;
+	}
+	if (proto != SXE2_FLOW_UDP_TUNNEL_MAX) {
+		ret = sxe2_flow_add_udp_tunnel_port(adapter, proto, flow, flow_type);
+		if (ret != 0) {
+			rte_flow_error_set(error, EINVAL,
+					RTE_FLOW_ERROR_TYPE_ITEM,
+					NULL, "Failed to add udp port for tunnel.");
+			PMD_LOG_ERR(DRV, "Failed to add udp port for tunnel, ret %d.", ret);
+			goto l_end;
+		}
+	}
+	if (tunnel_type != SXE2_FLOW_TUNNEL_TYPE_NONE) {
+		if (!sxe2_test_bit(SXE2_EXPANSION_OUTER_UDP, flow_type))
+			sxe2_set_bit(SXE2_FLOW_HDR_IPV_OTHER, pattern->hdrs);
+	}
+l_end:
+	return ret;
+}
+
 static int32_t sxe2_flowlist_add_tunnel_port(struct rte_eth_dev *dev,
 			struct rte_flow *flow_list,
 			struct rte_flow_error *error)
drivers/net/sxe2/sxe2_flow_parse_pattern.c +0 -113

119 lines not on this page · raw message

drivers/net/sxe2/sxe2_flow_parse_pattern.h +0 -6
index 8442c35cae..69d83a6ea6 100644
@@ -37,10 +37,4 @@ int32_t sxe2_flow_parse_pattern(struct rte_eth_dev *dev,
 			    struct rte_flow_error *error,
 			    struct sxe2_flow *flow);
 
-int32_t sxe2_flow_add_tunnel_port(struct rte_eth_dev *dev,
-			      struct rte_flow_error *error,
-			      struct sxe2_flow *flow,
-			      BITMAP_TYPE *flow_type,
-			      enum sxe2_flow_tunnel_type tunnel_type);
-
 #endif /* SXE2_FLOW_PARSE_PATTERN_H_ */
Signature · 1 line
2.52.0
#354 lore raw

PATCH v9 25/48 net/sxe2: add ACL engine event statistics support

In reply to [email protected]

From: Jie Liu <[email protected]>

Add statistics support for the ACL flow engine to track packet hits and bytes, enabling flow aging and traffic monitoring for ACL rules.

- Add acl-stat-type devarg to configure the statistics type
- Implement sxe2_drv_flow_acl_get_stat_id/free_stat/query_stat
- Handle the ACL engine in flow create/destroy/query paths
- Add fnav_hw_res and acl_hw_res count resources

---
 doc/guides/nics/sxe2.rst                  | 11 +++
 drivers/net/sxe2/sxe2_cmd_chnl.c          | 71 ++++++++++++++++++
 drivers/net/sxe2/sxe2_cmd_chnl.h          |  7 ++
 drivers/net/sxe2/sxe2_drv_cmd.h           |  7 ++
 drivers/net/sxe2/sxe2_dump.c              |  2 +
 drivers/net/sxe2/sxe2_ethdev.c            | 23 ++++--
 drivers/net/sxe2/sxe2_ethdev.h            |  1 +
 drivers/net/sxe2/sxe2_flow.c              | 90 ++++++++++++++++++-----
 drivers/net/sxe2/sxe2_flow_define.h       |  5 +-
 drivers/net/sxe2/sxe2_flow_parse_action.c | 28 ++++---
 10 files changed, 209 insertions(+), 36 deletions(-)
doc/guides/nics/sxe2.rst +11 -0
index 8278a5f108..c5b400a8ba 100644
@@ -98,6 +98,17 @@ Runtime Configuration
 
   Default value is 3 (count both packets and bytes).
 
+- ``acl-stat-type`` parameter [int]
+
+  This parameter controls the ACL flow engine statistics type
+  used for flow rule hit counting (via ``rte_flow_query``).
+
+  - 1: Only count the number of packets.
+  - 2: Only count the number of bytes.
+  - 3: Count both packets and bytes (default).
+
+  Default value is 3 (count both packets and bytes).
+
 - ``drv-sw-stats`` parameter [int]
 
   This parameter controls whether per-packet software statistics (SW stats)
drivers/net/sxe2/sxe2_cmd_chnl.c +71 -0

77 lines not on this page · raw message

drivers/net/sxe2/sxe2_cmd_chnl.h +7 -0
index cfea1a1f0e..7d07068bfc 100644
@@ -161,6 +161,13 @@ int32_t sxe2_drv_flow_fnav_free_stat(struct sxe2_adapter *adapter, uint32_t stat
 int32_t sxe2_drv_flow_fnav_query_stat(struct sxe2_adapter *adapter,
 		struct sxe2_flow_cid_mgr *mgr);
 
+int32_t sxe2_drv_flow_acl_get_stat_id(struct sxe2_adapter *adapter, uint32_t *stat_id);
+
+int32_t sxe2_drv_flow_acl_free_stat(struct sxe2_adapter *adapter, uint32_t stat_id);
+
+int32_t sxe2_drv_flow_acl_query_stat(struct sxe2_adapter *adapter,
+			struct sxe2_flow_cid_mgr *mgr);
+
 int32_t sxe2_drv_srcvsi_prune_config(struct sxe2_adapter *adapter,
 		uint16_t *vsi_list, uint16_t vsi_cnt, bool set);
 
drivers/net/sxe2/sxe2_drv_cmd.h +7 -0
index 03ef3b315d..01fd813ed1 100644
@@ -824,6 +824,13 @@ enum sxe2_drv_cmd_code {
 	SXE2_DRV_CMD_OPT_EEP_GET =
 		SXE2_MK_DRV_CMD(SXE2_DRV_CMD_MODULE_OPT, 1),
 
+	SXE2_DRV_CMD_FLOW_ACL_STAT_QUERY =
+		SXE2_MK_DRV_CMD(SXE2_DRV_CMD_MODULE_ACL, 1),
+	SXE2_DRV_CMD_FLOW_ACL_STAT_ALLOC =
+		SXE2_MK_DRV_CMD(SXE2_DRV_CMD_MODULE_ACL, 2),
+	SXE2_DRV_CMD_FLOW_ACL_STAT_FREE =
+		SXE2_MK_DRV_CMD(SXE2_DRV_CMD_MODULE_ACL, 3),
+
 };
 
 #endif /* SXE2_DRV_CMD_H */
drivers/net/sxe2/sxe2_dump.c +2 -0
index 590219f502..31f7d6ba61 100644
@@ -80,12 +80,14 @@ sxe2_dump_dev_args_info(FILE *file, struct rte_eth_dev *dev)
 		"\t  -- no_sched_mode: %s\n"
 		"\t  -- flow-duplicate-pattern: %u\n"
 		"\t  -- fnav-stat-type: %u\n"
+		"\t  -- acl-stat-type: %u\n"
 		"\t  -- sched_layer_mode: %u\n"
 		"\t  -- rx_low_latency: %s\n"
 		"\t  -- function-flow-direct: %s\n",
 		adapter->devargs.no_sched_mode ? "On" : "Off",
 		adapter->devargs.flow_dup_pattern_mode,
 		adapter->devargs.fnav_stat_type,
+		adapter->devargs.acl_stat_type,
 		adapter->devargs.sched_layer_mode,
 		adapter->devargs.rx_low_latency ? "On" : "Off",
 		adapter->devargs.func_flow_direct_en ? "On" : "Off");
drivers/net/sxe2/sxe2_ethdev.c +16 -7
index c5f6bc8af4..ea589c7eaa 100644
@@ -72,6 +72,7 @@ static const struct rte_pci_id pci_id_sxe2_tbl[] = {
 #define SXE2_DEVARG_FLOW_DUP_PATTERN_MODE "flow-duplicate-pattern"
 #define SXE2_DEVARG_FUNC_FLOW_DIRCT "function-flow-direct"
 #define SXE2_DEVARG_FNAV_STAT_TYPE "fnav-stat-type"
+#define SXE2_DEVARG_ACL_STAT_TYPE "acl-stat-type"
 #define SXE2_DEVARG_NO_SCHED_MODE "no-sched-mode"
 #define SXE2_DEVARG_SCHED_LAYER_MODE "sched-layer-mode"
 #define SXE2_DEVARG_RX_LOW_LATENCY "rx-low-latency"
@@ -981,11 +982,11 @@ sxe2_buffer_split_supported_hdr_ptypes_get(struct rte_eth_dev *dev __rte_unused,
 	return ptypes;
 }
 
-static int32_t sxe2_parse_fnav_stat_type(const char *key, const char *value, void *args)
+static int32_t sxe2_parse_stat_type(const char *key, const char *value, void *args)
 {
 	int32_t ret = -EINVAL;
 	uint8_t *num = (uint8_t *)args;
-	unsigned long fnav_stat_type;
+	unsigned long stat_type;
 	char *endptr = NULL;
 
 	if (value == NULL || args == NULL) {
@@ -993,19 +994,19 @@ static int32_t sxe2_parse_fnav_stat_type(const char *key, const char *value, voi
 		goto l_end;
 	}
 	errno = 0;
-	fnav_stat_type = strtoul(value, &endptr, 10);
+	stat_type = strtoul(value, &endptr, 10);
 	if (errno != 0 || endptr == value || *endptr != '\0') {
 		PMD_LOG_WARN(INIT, "%s: \"%s\" is not a valid int value.",
 			key, value);
 		goto l_end;
 	}
-	if (fnav_stat_type > SXE2_FNAV_STAT_ENA_ALL ||
-		fnav_stat_type == SXE2_FNAV_STAT_ENA_NONE) {
+	if (stat_type > SXE2_FNAV_STAT_ENA_ALL ||
+		stat_type == SXE2_FNAV_STAT_ENA_NONE) {
 		PMD_LOG_ERR(INIT, "%s: \"%s\" out of range [1-3].",
 			key, value);
 		goto l_end;
 	}
-	*num = (uint8_t)fnav_stat_type;
+	*num = (uint8_t)stat_type;
 	ret = 0;
 l_end:
 	return ret;
@@ -1187,13 +1188,20 @@ static int32_t sxe2_args_parse(struct rte_eth_dev *dev, struct sxe2_dev_kvargs_i
 	if (kvargs == NULL)
 		goto l_end;
 	ret = sxe2_kvargs_process(kvargs, SXE2_DEVARG_FNAV_STAT_TYPE,
-				 &sxe2_parse_fnav_stat_type,
+				 &sxe2_parse_stat_type,
 				 &adapter->devargs.fnav_stat_type);
 	if (ret) {
 		PMD_DEV_LOG_ERR(adapter, INIT, "Failed to parse fnav stat type, ret:%d", ret);
 		goto l_end;
 	}
 
+	ret = sxe2_kvargs_process(kvargs, SXE2_DEVARG_ACL_STAT_TYPE,
+				 &sxe2_parse_stat_type, &adapter->devargs.acl_stat_type);
+	if (ret) {
+		PMD_DEV_LOG_ERR(adapter, INIT, "Failed to parse acl stat type, ret:%d", ret);
+		goto l_end;
+	}
+
 	ret = sxe2_kvargs_process(kvargs, SXE2_DEVARG_NO_SCHED_MODE,
 				 &sxe2_parse_bool,
 				 &adapter->devargs.no_sched_mode);
@@ -2364,6 +2372,7 @@ RTE_PMD_REGISTER_PARAM_STRING(net_sxe2,
 	"flow-duplicate-pattern=<0|1|2> "
 	"function-flow-direct=<0|1> "
 	"fnav-stat-type=<1|2|3> "
+	"acl-stat-type=<1|2|3> "
 	"no-sched-mode=<0|1> "
 	"sched-layer-mode=<0-3> "
 	"rx-low-latency=<0|1>");
drivers/net/sxe2/sxe2_ethdev.h +1 -0
index e818578319..e9f78fe57f 100644
@@ -135,6 +135,7 @@ struct sxe2_devargs {
 	uint8_t flow_dup_pattern_mode;
 	uint8_t func_flow_direct_en;
 	uint8_t fnav_stat_type;
+	uint8_t acl_stat_type;
 	uint8_t no_sched_mode;
 	uint8_t sched_layer_mode;
 	uint8_t rx_low_latency;
drivers/net/sxe2/sxe2_flow.c +73 -17

163 lines not on this page · raw message

drivers/net/sxe2/sxe2_flow_define.h +3 -2
index 8a5d871978..d04499f5cb 100644
@@ -100,7 +100,7 @@ TAILQ_HEAD(rte_flow_list_t, rte_flow);
 
 struct sxe2_flow_cid_mgr {
 	TAILQ_ENTRY(sxe2_flow_cid_mgr) next;
-	uint16_t stat_index;
+	uint32_t stat_index;
 	uint32_t user_id;
 	uint32_t driver_id;
 	uint32_t count_type;
@@ -118,7 +118,8 @@ struct sxe2_flow_count_resource {
 struct sxe2_flow_context {
 	struct rte_flow_list_t rte_flow_list;
 	rte_spinlock_t flow_list_lock;
-	struct sxe2_flow_count_resource hw_res;
+	struct sxe2_flow_count_resource fnav_hw_res;
+	struct sxe2_flow_count_resource acl_hw_res;
 	uint16_t tunnel_port_list[SXE2_FLOW_UDP_TUNNEL_MAX];
 	uint32_t fnav_inited;
 };
drivers/net/sxe2/sxe2_flow_parse_action.c +18 -10
index a9559e2d7e..03ada4e8a6 100644
@@ -953,7 +953,8 @@ static int32_t sxe2_flow_check_actions(struct rte_eth_dev *dev __rte_unused, str
 		}
 	}
 
-	if (engine_type == SXE2_FLOW_ENGINE_FNAV) {
+	if (engine_type == SXE2_FLOW_ENGINE_FNAV ||
+		engine_type == SXE2_FLOW_ENGINE_ACL) {
 		if (vsi_num) {
 			flow->action.q_region.q_index = 0;
 			flow->action.q_region.region = 7;
@@ -980,6 +981,7 @@ int32_t sxe2_flow_parse_action(struct rte_eth_dev *dev,
 	uint8_t action_num[SXE2_FLOW_ACTION_MAX] = {0};
 	enum sxe2_flow_engine_type engine_type = flow->engine_type;
 	struct sxe2_adapter *adapter = SXE2_DEV_PRIVATE_TO_ADAPTER(dev);
+	struct sxe2_flow_count_resource *hw_res = NULL;
 
 	sxe2_flow_action_pre(flow);
 
@@ -988,7 +990,8 @@ int32_t sxe2_flow_parse_action(struct rte_eth_dev *dev,
 		case RTE_FLOW_ACTION_TYPE_VOID:
 			break;
 		case RTE_FLOW_ACTION_TYPE_PASSTHRU:
-			if (engine_type == SXE2_FLOW_ENGINE_FNAV) {
+			if (engine_type == SXE2_FLOW_ENGINE_FNAV ||
+				engine_type == SXE2_FLOW_ENGINE_ACL) {
 				sxe2_set_bit(SXE2_FLOW_ACTION_PASSTHRU, flow->action.act_types);
 				action_num[SXE2_FLOW_ACTION_PASSTHRU]++;
 			} else {
@@ -1035,14 +1038,9 @@ int32_t sxe2_flow_parse_action(struct rte_eth_dev *dev,
 			break;
 		case RTE_FLOW_ACTION_TYPE_COUNT:
 			if (engine_type == SXE2_FLOW_ENGINE_FNAV) {
-				sxe2_set_bit(SXE2_FLOW_ACTION_COUNT, flow->action.act_types);
-				act_count = action->conf;
-				flow->action.count.user_id = act_count->id;
-				flow->action.count.driver_id = 0;
-				if (flow->action.count.user_id == 0)
-					flow->action.count.driver_id =
-						++adapter->flow_ctxt.hw_res.global_index;
-				action_num[SXE2_FLOW_ACTION_COUNT]++;
+				hw_res = &adapter->flow_ctxt.fnav_hw_res;
+			} else if (engine_type == SXE2_FLOW_ENGINE_ACL) {
+				hw_res = &adapter->flow_ctxt.acl_hw_res;
 			} else {
 				rte_flow_error_set(error, ENOTSUP,
 					RTE_FLOW_ERROR_TYPE_ACTION, action,
@@ -1052,6 +1050,16 @@ int32_t sxe2_flow_parse_action(struct rte_eth_dev *dev,
 				ret = -EINVAL;
 				goto l_end;
 			}
+			sxe2_set_bit(SXE2_FLOW_ACTION_COUNT, flow->action.act_types);
+			act_count = action->conf;
+			flow->action.count.user_id =
+				(act_count == NULL) ? 0 : act_count->id;
+			flow->action.count.driver_id = 0;
+			if (flow->action.count.user_id == 0) {
+				flow->action.count.driver_id =
+					++hw_res->global_index;
+			}
+			action_num[SXE2_FLOW_ACTION_COUNT]++;
 			break;
 		case RTE_FLOW_ACTION_TYPE_RSS:
 			if (engine_type == SXE2_FLOW_ENGINE_RSS) {
Signature · 1 line
2.52.0
#355 lore raw

PATCH v9 26/48 net/sxe2: enable FDIR on all Rx queues

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_flow_init() always sets fnav_inited, so enable FDIR on every Rx queue during queue init by setting rxq->fnav_enable. FDIR/FNAV flags are required for flow rules and ACL statistics, so every Rx queue must have them enabled. This makes the fnav blocks in the vectorized Rx paths live on all queues.

---
 drivers/net/sxe2/sxe2_queue.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/sxe2/sxe2_queue.c +2 -0
index afb2681b72..3aaa14c685 100644
@@ -39,6 +39,8 @@ int32_t sxe2_queues_init(struct rte_eth_dev *dev)
 		rxq->rx_buf_len = RTE_MIN(rxq->rx_buf_len, SXE2_RX_MAX_DATA_BUF_SIZE);
 		if (frame_size > rxq->rx_buf_len)
 			dev->data->scattered_rx = 1;
+		if (adapter->flow_ctxt.fnav_inited)
+			rxq->fnav_enable = true;
 	}
 
 	adapter->ptp_ctxt.mbuf_rx_ts_offset = -1;
Signature · 1 line
2.52.0
#356 lore raw

PATCH v9 27/48 net/sxe2: refactor primary process MP message handling

In reply to [email protected]

From: Jie Liu <[email protected]>

Extract the multi-process work logic into the sxe2_mp_do_primary_work helper and operate on a copy of the request in the primary handler so the original message is not modified. Simplify the reply construction and return -ENOENT instead of -EINVAL when no response is received from the primary process.

Fixes 5db446ba97b0 ("net/sxe2: support statistics and multi-process")
---
 drivers/net/sxe2/sxe2_mp.c | 59 ++++++++++++++++++++++----------------
 1 file changed, 34 insertions(+), 25 deletions(-)
drivers/net/sxe2/sxe2_mp.c +34 -25
index a4a5c76495..93a11150a9 100644
@@ -29,16 +29,11 @@ static int32_t sxe2_mp_secondary_handle(const struct rte_mp_msg *mp_msg,
 					 const void *peer);
 
 static int32_t
-sxe2_mp_primary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
+sxe2_mp_do_primary_work(struct sxe2_mp_param *param)
 {
-	struct rte_mp_msg reply;
-	const struct sxe2_mp_param *param =
-			(const struct sxe2_mp_param *)mp_msg->param;
-	struct sxe2_mp_param *reply_param = (struct sxe2_mp_param *)reply.param;
 	struct rte_eth_dev *dev;
-	int32_t ret = 0;
 	struct sxe2_mp_shared_data *mz_data;
-	int32_t send_reply = 0;
+	int32_t ret = 0;
 	int32_t cnt = 0;
 
 	if (!rte_eth_dev_is_valid_port(param->port_id)) {
@@ -49,24 +44,21 @@ sxe2_mp_primary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
 	}
 
 	dev = &rte_eth_devices[param->port_id];
-	sxe2_mp_mz = rte_memzone_lookup(SXE2_MP_MZ_NAME);
+
 	if (sxe2_mp_mz == NULL) {
-		PMD_LOG_ERR(DRV, "Failed to lookup memzone %s", SXE2_MP_MZ_NAME);
-		ret = -ENOENT;
-		goto out;
+		sxe2_mp_mz = rte_memzone_lookup(SXE2_MP_MZ_NAME);
+		if (sxe2_mp_mz == NULL) {
+			PMD_LOG_ERR(DRV, "Failed to lookup memzone %s",
+					SXE2_MP_MZ_NAME);
+			ret = -ENOENT;
+			goto out;
+		}
 	}
 
 	mz_data = (struct sxe2_mp_shared_data *)sxe2_mp_mz->addr;
-	send_reply = 1;
-
-	memset(&reply, 0, sizeof(reply));
-	(void)strlcpy(reply.name, SXE2_MP_NAME, sizeof(reply.name));
-	reply.len_param = sizeof(*reply_param);
-
 	switch (param->type) {
 	case SXE2_MP_REQ_GET_STATS:
-		ret = sxe2_stats_info_get(dev,
-					  &mz_data->payload.stats_blk.stats,
+		ret = sxe2_stats_info_get(dev, &mz_data->payload.stats_blk.stats,
 					  &mz_data->payload.stats_blk.qstats);
 		break;
 	case SXE2_MP_REQ_GET_XSTATS:
@@ -88,15 +80,32 @@ sxe2_mp_primary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
 	default:
 		PMD_LOG_ERR(DRV, "primary process: unrecognized msg type: %d",
 				param->type);
-		send_reply = false;
 		ret = -EINVAL;
-		goto out;
+		break;
 	}
+
 out:
-	if (!send_reply)
-		return ret;
+	param->result = ret;
+	return ret;
+}
 
-	reply_param->result = ret;
+static int32_t
+sxe2_mp_primary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
+{
+	struct rte_mp_msg reply;
+	struct sxe2_mp_param *reply_param = (struct sxe2_mp_param *)reply.param;
+	const struct sxe2_mp_param *param =
+			(const struct sxe2_mp_param *)mp_msg->param;
+	struct sxe2_mp_param param_copy;
+
+	memset(&reply, 0, sizeof(reply));
+	(void)strlcpy(reply.name, SXE2_MP_NAME, sizeof(reply.name));
+	reply.len_param = sizeof(*reply_param);
+
+	param_copy = *param;
+	(void)sxe2_mp_do_primary_work(&param_copy);
+
+	reply_param->result = param_copy.result;
 	reply_param->type = param->type;
 	reply_param->port_id = param->port_id;
 
@@ -275,7 +284,7 @@ int32_t sxe2_mp_request_simple(struct rte_eth_dev *dev,
 	if (reply.nb_received == 0) {
 		PMD_LOG_ERR(DRV, "No response received from primary for type=%d, port %u",
 			type, dev->data->port_id);
-		ret = -EINVAL;
+		ret = -ENOENT;
 		goto out;
 	}
 
Signature · 1 line
2.52.0
#357 lore raw

PATCH v9 28/48 net/sxe2: refactor Tx queue reset operations

In reply to [email protected]

From: Jie Liu <[email protected]>

Extract the descriptor ring reset loop into a sxe2_tx_queue_desc_ring_reset helper and reuse it from both the scalar and vectorized queue reset paths. Add a sxe2_tx_queue_reset_vec entry point for vectorized queues, export sxe2_tx_buffer_ring_free for reuse outside the module (clearing the buffer ring pointer after freeing it), and add sxe2_tx_vec_ops_get to build the vectorized Tx queue operations table used by the vector path setup.

---
 drivers/net/sxe2/sxe2_tx.c       | 42 +++++++++++++++++++++++---------
 drivers/net/sxe2/sxe2_tx.h       |  4 +++
 drivers/net/sxe2/sxe2_txrx_vec.c | 17 ++++++++++---
 3 files changed, 49 insertions(+), 14 deletions(-)
drivers/net/sxe2/sxe2_tx.c +31 -11
index f49238ceef..94a6e9afc7 100644
@@ -19,6 +19,17 @@ static void *sxe2_tx_doorbell_addr_get(struct sxe2_adapter *adapter, uint16_t qu
 				     queue_id);
 }
 
+static void sxe2_tx_queue_desc_ring_reset(struct sxe2_tx_queue *txq)
+{
+	uint16_t i;
+	static const union sxe2_tx_data_desc zeroed_desc = {{0}};
+
+	for (i = 0; i < txq->ring_depth; i++) {
+		txq->desc_ring[i] = zeroed_desc;
+		txq->desc_ring[i].wb.dd = rte_cpu_to_le_64(SXE2_TX_DESC_DTYPE_DESC_DONE);
+	}
+}
+
 static void sxe2_tx_tail_init(struct sxe2_adapter *adapter, struct sxe2_tx_queue *txq)
 {
 	txq->tdt_reg_addr = sxe2_tx_doorbell_addr_get(adapter, txq->queue_id);
@@ -28,20 +39,12 @@ static void sxe2_tx_tail_init(struct sxe2_adapter *adapter, struct sxe2_tx_queue
 void __rte_cold sxe2_tx_queue_reset(struct sxe2_tx_queue *txq)
 {
 	uint16_t prev, i;
-	volatile union sxe2_tx_data_desc *txd;
-	static const union sxe2_tx_data_desc zeroed_desc = {{0}};
 	struct sxe2_tx_buffer *tx_buffer = txq->buffer_ring;
 
-	for (i = 0; i < txq->ring_depth; i++)
-		txq->desc_ring[i] = zeroed_desc;
+	sxe2_tx_queue_desc_ring_reset(txq);
 
 	prev = txq->ring_depth - 1;
 	for (i = 0; i < txq->ring_depth; i++) {
-		txd = &txq->desc_ring[i];
-		if (txd == NULL)
-			continue;
-
-		txd->wb.dd = rte_cpu_to_le_64(SXE2_TX_DESC_DTYPE_DESC_DONE);
 		tx_buffer[i].mbuf       = NULL;
 		tx_buffer[i].last_id    = i;
 		tx_buffer[prev].next_id = i;
@@ -56,6 +59,21 @@ void __rte_cold sxe2_tx_queue_reset(struct sxe2_tx_queue *txq)
 	txq->next_rs       = txq->rs_thresh  - 1;
 }
 
+void __rte_cold sxe2_tx_queue_reset_vec(struct sxe2_tx_queue *txq)
+{
+	sxe2_tx_queue_desc_ring_reset(txq);
+
+	memset(txq->buffer_ring, 0,
+		sizeof(struct sxe2_tx_buffer) * txq->ring_depth);
+
+	txq->desc_used_num = 0;
+	txq->desc_free_num = txq->ring_depth - 1;
+	txq->next_use      = 0;
+	txq->next_clean    = txq->ring_depth - 1;
+	txq->next_dd       = txq->rs_thresh  - 1;
+	txq->next_rs       = txq->rs_thresh  - 1;
+}
+
 void __rte_cold sxe2_tx_queue_mbufs_release(struct sxe2_tx_queue *txq)
 {
 	uint32_t i;
@@ -70,10 +88,12 @@ void __rte_cold sxe2_tx_queue_mbufs_release(struct sxe2_tx_queue *txq)
 	}
 }
 
-static void sxe2_tx_buffer_ring_free(struct sxe2_tx_queue *txq)
+void __rte_cold sxe2_tx_buffer_ring_free(struct sxe2_tx_queue *txq)
 {
-	if (txq != NULL && txq->buffer_ring != NULL)
+	if (txq != NULL && txq->buffer_ring != NULL) {
 		rte_free(txq->buffer_ring);
+		txq->buffer_ring = NULL;
+	}
 }
 
 const struct sxe2_txq_ops sxe2_default_txq_ops = {
drivers/net/sxe2/sxe2_tx.h +4 -0
index f4823126b3..bc5ff1c2bc 100644
@@ -9,6 +9,10 @@
 
 void __rte_cold sxe2_tx_queue_reset(struct sxe2_tx_queue *txq);
 
+void __rte_cold sxe2_tx_queue_reset_vec(struct sxe2_tx_queue *txq);
+
+void __rte_cold sxe2_tx_buffer_ring_free(struct sxe2_tx_queue *txq);
+
 int32_t __rte_cold sxe2_tx_queue_start(struct rte_eth_dev *dev, uint16_t queue_id);
 
 void sxe2_tx_queue_mbufs_release(struct sxe2_tx_queue *txq);
drivers/net/sxe2/sxe2_txrx_vec.c +14 -3
index cf004f5eb2..1442d5d119 100644
@@ -8,6 +8,14 @@
 #include "sxe2_ethdev.h"
 #include "sxe2_common_log.h"
 
+static void sxe2_tx_queue_mbufs_release_vec(struct sxe2_tx_queue *txq);
+
+static const struct sxe2_txq_ops sxe2_tx_vec_ops = {
+	.queue_reset      = sxe2_tx_queue_reset_vec,
+	.mbufs_release    = sxe2_tx_queue_mbufs_release_vec,
+	.buffer_ring_free = sxe2_tx_buffer_ring_free,
+};
+
 int32_t __rte_cold sxe2_rx_vec_support_check(struct rte_eth_dev *dev, uint32_t *vec_flags)
 {
 	struct sxe2_rx_queue *rxq;
@@ -230,10 +238,13 @@ int32_t __rte_cold sxe2_tx_queues_vec_prepare(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_tx_queues; ++i) {
 		txq = dev->data->tx_queues[i];
 		if (txq == NULL) {
-			PMD_LOG_INFO(TX, "Failed to prepare tx queue, txq[%d] is NULL", i);
-			continue;
+			PMD_LOG_ERR(TX, "Failed to prepare tx queue, txq[%d] is NULL", i);
+			ret = -EINVAL;
+			goto l_end;
 		}
-		txq->ops.mbufs_release = sxe2_tx_queue_mbufs_release_vec;
+		txq->ops = sxe2_tx_vec_ops;
+		txq->ops.queue_reset(txq);
 	}
+l_end:
 	return ret;
 }
Signature · 1 line
2.52.0
#358 lore raw

PATCH v9 29/48 net/sxe2: unify vectorized Tx buffer handling

In reply to [email protected]

From: Jie Liu <[email protected]>

Add a union of the scalar and vectorized buffer ring pointers to the Tx queue structure so the vectorized path can use sxe2_tx_buffer_vec directly. Rename the mbuf fill helper to sxe2_tx_pkts_mbuf_fill_vec, switch the vectorized Tx burst and mbuf release paths to the buffer_ring_vec member, and drop the AVX512-specific fill handling and conditional branching.

Fixes ac60f302cbef ("net/sxe2: add vectorized Rx and Tx")
---
 drivers/net/sxe2/sxe2_queue.h           |   5 +-
 drivers/net/sxe2/sxe2_txrx_vec.c        |  57 ++--------
 drivers/net/sxe2/sxe2_txrx_vec_avx2.c   |  10 +-
 drivers/net/sxe2/sxe2_txrx_vec_avx512.c | 133 +-----------------------
 drivers/net/sxe2/sxe2_txrx_vec_common.h |   9 +-
 drivers/net/sxe2/sxe2_txrx_vec_neon.c   |  10 +-
 drivers/net/sxe2/sxe2_txrx_vec_sse.c    |  10 +-
 7 files changed, 40 insertions(+), 194 deletions(-)
drivers/net/sxe2/sxe2_queue.h +4 -1
index 10bdaf5b8d..e53a1ce852 100644
@@ -62,7 +62,10 @@ struct sxe2_txq_ops {
 };
 struct sxe2_tx_queue {
 	volatile union sxe2_tx_data_desc *desc_ring;
-	struct sxe2_tx_buffer *buffer_ring;
+	union {
+		struct sxe2_tx_buffer *buffer_ring;
+		struct sxe2_tx_buffer_vec *buffer_ring_vec;
+	};
 	volatile uint32_t *tdt_reg_addr;
 
 	uint64_t offloads;
drivers/net/sxe2/sxe2_txrx_vec.c +11 -46

77 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx_vec_avx2.c +5 -5
index 0618e6d988..da96ca3064 100644
@@ -115,7 +115,7 @@ sxe2_tx_pkts_vec_avx2_batch(struct sxe2_tx_queue *txq, struct rte_mbuf **tx_pkts
 			    uint16_t nb_pkts, bool with_offloads)
 {
 	volatile union sxe2_tx_data_desc *desc;
-	struct sxe2_tx_buffer *buffer;
+	struct sxe2_tx_buffer_vec *buffer;
 	uint16_t next_use;
 	uint16_t res_num;
 	uint16_t tx_num;
@@ -134,14 +134,14 @@ sxe2_tx_pkts_vec_avx2_batch(struct sxe2_tx_queue *txq, struct rte_mbuf **tx_pkts
 
 	next_use = txq->next_use;
 	desc     = &txq->desc_ring[next_use];
-	buffer   = &txq->buffer_ring[next_use];
+	buffer   = &txq->buffer_ring_vec[next_use];
 
 	txq->desc_free_num -= nb_pkts;
 
 	res_num = txq->ring_depth - txq->next_use;
 
 	if (tx_num >= res_num) {
-		sxe2_tx_pkts_mbuf_fill(buffer, tx_pkts, res_num);
+		sxe2_tx_pkts_mbuf_fill_vec(buffer, tx_pkts, res_num);
 
 		sxe2_tx_desc_fill_avx2(desc, tx_pkts, res_num,
 				SXE2_TX_DATA_DESC_CMD_EOP, with_offloads);
@@ -157,10 +157,10 @@ sxe2_tx_pkts_vec_avx2_batch(struct sxe2_tx_queue *txq, struct rte_mbuf **tx_pkts
 		next_use     = 0;
 		txq->next_rs = txq->rs_thresh - 1;
 		desc         = &txq->desc_ring[next_use];
-		buffer       = &txq->buffer_ring[next_use];
+		buffer       = &txq->buffer_ring_vec[next_use];
 	}
 
-	sxe2_tx_pkts_mbuf_fill(buffer, tx_pkts, tx_num);
+	sxe2_tx_pkts_mbuf_fill_vec(buffer, tx_pkts, tx_num);
 
 	sxe2_tx_desc_fill_avx2(desc, tx_pkts, tx_num,
 			SXE2_TX_DATA_DESC_CMD_EOP, with_offloads);
drivers/net/sxe2/sxe2_txrx_vec_avx512.c +5 -128

180 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx_vec_common.h +5 -4
index 9ac99cf0fa..ede4c236b1 100644
@@ -25,10 +25,11 @@
 #define SXE2_TX_FREE_BUFFER_SIZE_MAX_VEC  64
 
 static __rte_always_inline void
-sxe2_tx_pkts_mbuf_fill(struct sxe2_tx_buffer *buffer,
-		struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
+sxe2_tx_pkts_mbuf_fill_vec(struct sxe2_tx_buffer_vec *buffer,
+			   struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 {
 	uint16_t i;
+
 	for (i = 0; i < nb_pkts; ++i)
 		buffer[i].mbuf = tx_pkts[i];
 }
@@ -36,7 +37,7 @@ sxe2_tx_pkts_mbuf_fill(struct sxe2_tx_buffer *buffer,
 static __rte_always_inline int32_t
 sxe2_tx_bufs_free_vec(struct sxe2_tx_queue *txq)
 {
-	struct sxe2_tx_buffer *buffer;
+	struct sxe2_tx_buffer_vec *buffer;
 	struct rte_mbuf *mbuf;
 	struct rte_mbuf *mbuf_free_arr[SXE2_TX_FREE_BUFFER_SIZE_MAX_VEC];
 	int32_t ret;
@@ -50,7 +51,7 @@ sxe2_tx_bufs_free_vec(struct sxe2_tx_queue *txq)
 		goto l_end;
 	}
 	rs_thresh = txq->rs_thresh;
-	buffer = &txq->buffer_ring[txq->next_dd - (rs_thresh - 1)];
+	buffer = &txq->buffer_ring_vec[txq->next_dd - (rs_thresh - 1)];
 	mbuf = rte_pktmbuf_prefree_seg(buffer[0].mbuf);
 	if (likely(mbuf)) {
 		mbuf_free_arr[0] = mbuf;
drivers/net/sxe2/sxe2_txrx_vec_neon.c +5 -5
index 4e5cb87cd5..b51cc55368 100644
@@ -39,7 +39,7 @@ sxe2_tx_pkts_vec_neon_batch(struct sxe2_tx_queue *txq, struct rte_mbuf **tx_pkts
 			uint16_t nb_pkts, bool with_offloads)
 {
 	volatile union sxe2_tx_data_desc *desc;
-	struct sxe2_tx_buffer *buffer;
+	struct sxe2_tx_buffer_vec *buffer;
 	uint16_t next_use;
 	uint16_t res_num;
 	uint16_t tx_num;
@@ -59,14 +59,14 @@ sxe2_tx_pkts_vec_neon_batch(struct sxe2_tx_queue *txq, struct rte_mbuf **tx_pkts
 
 	next_use = txq->next_use;
 	desc     = &txq->desc_ring[next_use];
-	buffer   = &txq->buffer_ring[next_use];
+	buffer   = &txq->buffer_ring_vec[next_use];
 
 	txq->desc_free_num -= nb_pkts;
 
 	res_num = txq->ring_depth - txq->next_use;
 
 	if (tx_num >= res_num) {
-		sxe2_tx_pkts_mbuf_fill(buffer, tx_pkts, res_num);
+		sxe2_tx_pkts_mbuf_fill_vec(buffer, tx_pkts, res_num);
 
 		for (i = 0; i < res_num - 1; ++i, ++tx_pkts, ++desc) {
 			sxe2_tx_desc_fill_one_neon(desc, *tx_pkts,
@@ -82,10 +82,10 @@ sxe2_tx_pkts_vec_neon_batch(struct sxe2_tx_queue *txq, struct rte_mbuf **tx_pkts
 		next_use     = 0;
 		txq->next_rs = txq->rs_thresh - 1;
 		desc         = &txq->desc_ring[next_use];
-		buffer       = &txq->buffer_ring[next_use];
+		buffer       = &txq->buffer_ring_vec[next_use];
 	}
 
-	sxe2_tx_pkts_mbuf_fill(buffer, tx_pkts, tx_num);
+	sxe2_tx_pkts_mbuf_fill_vec(buffer, tx_pkts, tx_num);
 
 	for (i = 0; i < tx_num; ++i, ++tx_pkts, ++desc) {
 		sxe2_tx_desc_fill_one_neon(desc, *tx_pkts,
drivers/net/sxe2/sxe2_txrx_vec_sse.c +5 -5
index c3e8a2983b..181bb40041 100644
@@ -40,7 +40,7 @@ sxe2_tx_pkts_vec_sse_batch(struct sxe2_tx_queue *txq,
 		uint16_t nb_pkts, bool with_offloads)
 {
 	volatile union sxe2_tx_data_desc *desc;
-	struct sxe2_tx_buffer *buffer;
+	struct sxe2_tx_buffer_vec *buffer;
 	uint16_t next_use;
 	uint16_t res_num;
 	uint16_t tx_num;
@@ -57,11 +57,11 @@ sxe2_tx_pkts_vec_sse_batch(struct sxe2_tx_queue *txq,
 	tx_num = nb_pkts;
 	next_use = txq->next_use;
 	desc     = &txq->desc_ring[next_use];
-	buffer   = &txq->buffer_ring[next_use];
+	buffer   = &txq->buffer_ring_vec[next_use];
 	txq->desc_free_num -= nb_pkts;
 	res_num = txq->ring_depth - txq->next_use;
 	if (tx_num >= res_num) {
-		sxe2_tx_pkts_mbuf_fill(buffer, tx_pkts, res_num);
+		sxe2_tx_pkts_mbuf_fill_vec(buffer, tx_pkts, res_num);
 		for (i = 0; i < res_num - 1; ++i, ++tx_pkts, ++desc) {
 			sxe2_tx_desc_fill_one_sse(desc, *tx_pkts,
 						  SXE2_TX_DATA_DESC_CMD_EOP,
@@ -74,9 +74,9 @@ sxe2_tx_pkts_vec_sse_batch(struct sxe2_tx_queue *txq,
 		next_use     = 0;
 		txq->next_rs = txq->rs_thresh - 1;
 		desc         = &txq->desc_ring[next_use];
-		buffer       = &txq->buffer_ring[next_use];
+		buffer       = &txq->buffer_ring_vec[next_use];
 	}
-	sxe2_tx_pkts_mbuf_fill(buffer, tx_pkts, tx_num);
+	sxe2_tx_pkts_mbuf_fill_vec(buffer, tx_pkts, tx_num);
 	for (i = 0; i < tx_num; ++i, ++tx_pkts, ++desc) {
 		sxe2_tx_desc_fill_one_sse(desc, *tx_pkts,
 					  SXE2_TX_DATA_DESC_CMD_EOP,
Signature · 1 line
2.52.0
#359 lore raw

PATCH v9 30/48 net/sxe2: optimize NEON Tx descriptor fill

In reply to [email protected]

From: Jie Liu <[email protected]>

Add sxe2_tx_desc_fill_4_neon_simple() to write four data descriptors with a single vst1q_u64_x4 store, and use it in sxe2_tx_pkts_vec_neon_batch() for the non-offload path to reduce the number of per-packet descriptor stores.

---
 drivers/net/sxe2/sxe2_txrx_vec_neon.c | 77 ++++++++++++++++++++++++---
 1 file changed, 70 insertions(+), 7 deletions(-)
drivers/net/sxe2/sxe2_txrx_vec_neon.c +70 -7
index b51cc55368..6b4c70c7ac 100644
@@ -34,6 +34,52 @@ sxe2_tx_desc_fill_one_neon(volatile union sxe2_tx_data_desc *desc,
 	vst1q_u64(RTE_CAST_PTR(uint64_t *, desc), data_desc);
 }
 
+static __rte_always_inline void
+sxe2_tx_desc_fill_4_neon_simple(volatile union sxe2_tx_data_desc *desc,
+				struct rte_mbuf **pkts)
+{
+	uint64x2_t d0, d1, d2, d3;
+	uint64x2x4_t v;
+	const uint64_t cmd_base = ((uint64_t)SXE2_TX_DESC_DTYPE_DATA) |
+				((uint64_t)SXE2_TX_DATA_DESC_CMD_EOP) <<
+				SXE2_TX_DATA_DESC_CMD_SHIFT;
+
+	d0 = (uint64x2_t){
+		rte_pktmbuf_iova(pkts[0]),
+		cmd_base |
+		((uint64_t)pkts[0]->data_len) << SXE2_TX_DATA_DESC_BUF_SZ_SHIFT |
+		((uint64_t)SXE2_TX_DATA_DESC_MACLEN_VAL(pkts[0]->l2_len))
+				<< SXE2_TX_DATA_DESC_OFFSET_SHIFT
+	};
+	d1 = (uint64x2_t){
+		rte_pktmbuf_iova(pkts[1]),
+		cmd_base |
+		((uint64_t)pkts[1]->data_len) << SXE2_TX_DATA_DESC_BUF_SZ_SHIFT |
+		((uint64_t)SXE2_TX_DATA_DESC_MACLEN_VAL(pkts[1]->l2_len))
+				<< SXE2_TX_DATA_DESC_OFFSET_SHIFT
+	};
+	d2 = (uint64x2_t){
+		rte_pktmbuf_iova(pkts[2]),
+		cmd_base |
+		((uint64_t)pkts[2]->data_len) << SXE2_TX_DATA_DESC_BUF_SZ_SHIFT |
+		((uint64_t)SXE2_TX_DATA_DESC_MACLEN_VAL(pkts[2]->l2_len))
+				<< SXE2_TX_DATA_DESC_OFFSET_SHIFT
+	};
+	d3 = (uint64x2_t){
+		rte_pktmbuf_iova(pkts[3]),
+		cmd_base |
+		((uint64_t)pkts[3]->data_len) << SXE2_TX_DATA_DESC_BUF_SZ_SHIFT |
+		((uint64_t)SXE2_TX_DATA_DESC_MACLEN_VAL(pkts[3]->l2_len))
+				<< SXE2_TX_DATA_DESC_OFFSET_SHIFT
+	};
+
+	v.val[0] = d0;
+	v.val[1] = d1;
+	v.val[2] = d2;
+	v.val[3] = d3;
+	vst1q_u64_x4(RTE_CAST_PTR(uint64_t *, desc), v);
+}
+
 static __rte_always_inline uint16_t
 sxe2_tx_pkts_vec_neon_batch(struct sxe2_tx_queue *txq, struct rte_mbuf **tx_pkts,
 			uint16_t nb_pkts, bool with_offloads)
@@ -67,10 +113,18 @@ sxe2_tx_pkts_vec_neon_batch(struct sxe2_tx_queue *txq, struct rte_mbuf **tx_pkts
 
 	if (tx_num >= res_num) {
 		sxe2_tx_pkts_mbuf_fill_vec(buffer, tx_pkts, res_num);
-
-		for (i = 0; i < res_num - 1; ++i, ++tx_pkts, ++desc) {
-			sxe2_tx_desc_fill_one_neon(desc, *tx_pkts,
-					SXE2_TX_DATA_DESC_CMD_EOP, with_offloads);
+		if (with_offloads) {
+			for (i = 0; i < res_num - 1; ++i, ++tx_pkts, ++desc) {
+				sxe2_tx_desc_fill_one_neon(desc, *tx_pkts,
+						SXE2_TX_DATA_DESC_CMD_EOP, with_offloads);
+			}
+		} else {
+			for (i = 0; i + 3 < res_num - 1; i += 4, tx_pkts += 4, desc += 4)
+				sxe2_tx_desc_fill_4_neon_simple(desc, tx_pkts);
+			for (; i < res_num - 1; ++i, ++tx_pkts, ++desc) {
+				sxe2_tx_desc_fill_one_neon(desc, *tx_pkts,
+						SXE2_TX_DATA_DESC_CMD_EOP, false);
+			}
 		}
 
 		sxe2_tx_desc_fill_one_neon(desc, *tx_pkts++,
@@ -87,9 +141,18 @@ sxe2_tx_pkts_vec_neon_batch(struct sxe2_tx_queue *txq, struct rte_mbuf **tx_pkts
 
 	sxe2_tx_pkts_mbuf_fill_vec(buffer, tx_pkts, tx_num);
 
-	for (i = 0; i < tx_num; ++i, ++tx_pkts, ++desc) {
-		sxe2_tx_desc_fill_one_neon(desc, *tx_pkts,
-				SXE2_TX_DATA_DESC_CMD_EOP, with_offloads);
+	if (with_offloads) {
+		for (i = 0; i < tx_num; ++i, ++tx_pkts, ++desc) {
+			sxe2_tx_desc_fill_one_neon(desc, *tx_pkts,
+					SXE2_TX_DATA_DESC_CMD_EOP, true);
+		}
+	} else {
+		for (i = 0; i + 3 < tx_num; i += 4, tx_pkts += 4, desc += 4)
+			sxe2_tx_desc_fill_4_neon_simple(desc, tx_pkts);
+		for (; i < tx_num; ++i, ++tx_pkts, ++desc) {
+			sxe2_tx_desc_fill_one_neon(desc, *tx_pkts,
+					SXE2_TX_DATA_DESC_CMD_EOP, false);
+		}
 	}
 
 	next_use += tx_num;
Signature · 1 line
2.52.0
#360 lore raw

PATCH v9 31/48 net/sxe2: fix NEON Rx ptype mapping and memory ordering

In reply to [email protected]

From: Jie Liu <[email protected]>

Reorder the descriptor lane mapping in the NEON Rx path to use the natural d0/d1/d2/d3 order for desc_lo/desc_hi, and update the staterr zip (16-bit), the shuffle masks and the ptype lane selection accordingly.

Correct the DD count in the NEON Rx path: count the leading run of done descriptors with rte_ctz64() instead of rte_popcount64(), which could hand up a descriptor the hardware has not yet written when DD bits are not contiguous.

Fix the FNAV/FDIR lane order in sxe2_rx_desc_fnav_flags_neon() to match the natural descriptor order used by the ptype and offload paths, so FDIR flags land on the correct mbuf.

Drop three of the four rte_atomic_thread_fence(acquire) barriers between descriptor loads; the single acquire fence after the descriptor set is loaded is sufficient for the Rx producer/consumer ordering.

Fixes ac60f302cbef ("net/sxe2: add vectorized Rx and Tx")
---
 drivers/net/sxe2/sxe2_txrx_vec_neon.c | 136 +++++++++++++-------------
 1 file changed, 70 insertions(+), 66 deletions(-)
drivers/net/sxe2/sxe2_txrx_vec_neon.c +70 -66
index 6b4c70c7ac..72338ee61a 100644
@@ -213,22 +213,24 @@ uint16_t sxe2_tx_pkts_vec_neon(void *tx_queue,
 }
 
 static __rte_always_inline void
-sxe2_rx_desc_ptype_fill_neon(uint16x8_t staterr, struct rte_mbuf **__rte_restrict rx_pkts)
+sxe2_rx_desc_ptype_fill_neon(uint32x4_t desc_lo,
+							 struct rte_mbuf **__rte_restrict rx_pkts,
+							 const uint32_t *__rte_restrict ptype_tbl)
 {
-	uint16x8_t ptype_mask = {
-		0, 0x3FFULL,
-		0, 0x3FFULL,
-		0, 0x3FFULL,
-		0, 0x3FFULL,
+	const uint32x4_t ptype_mask = {
+		SXE2_RX_DESC_PTYPE_MASK_NO_SHIFT << 16,
+		SXE2_RX_DESC_PTYPE_MASK_NO_SHIFT << 16,
+		SXE2_RX_DESC_PTYPE_MASK_NO_SHIFT << 16,
+		SXE2_RX_DESC_PTYPE_MASK_NO_SHIFT << 16,
 	};
 	uint16x8_t ptype_all;
 
-	ptype_all = vandq_u16(staterr, ptype_mask);
+	ptype_all = vreinterpretq_u16_u32(vandq_u32(desc_lo, ptype_mask));
 
-	rx_pkts[3]->packet_type = sxe2_ptype_tbl[vgetq_lane_u16(ptype_all, 3)];
-	rx_pkts[2]->packet_type = sxe2_ptype_tbl[vgetq_lane_u16(ptype_all, 7)];
-	rx_pkts[1]->packet_type = sxe2_ptype_tbl[vgetq_lane_u16(ptype_all, 1)];
-	rx_pkts[0]->packet_type = sxe2_ptype_tbl[vgetq_lane_u16(ptype_all, 5)];
+	rx_pkts[0]->packet_type = ptype_tbl[vgetq_lane_u16(ptype_all, 1)];
+	rx_pkts[1]->packet_type = ptype_tbl[vgetq_lane_u16(ptype_all, 3)];
+	rx_pkts[2]->packet_type = ptype_tbl[vgetq_lane_u16(ptype_all, 5)];
+	rx_pkts[3]->packet_type = ptype_tbl[vgetq_lane_u16(ptype_all, 7)];
 }
 
 static __rte_always_inline uint32x4_t
@@ -247,8 +249,8 @@ sxe2_rx_desc_fnav_flags_neon(uint64x2_t descs_arr[4])
 	uint32x4_t d2 = vreinterpretq_u32_u64(descs_arr[2]);
 	uint32x4_t d3 = vreinterpretq_u32_u64(descs_arr[3]);
 
-	descs_tmp1 = vzip1q_u32(d1, d0);
-	descs_tmp2 = vzip1q_u32(d3, d2);
+	descs_tmp1 = vzip1q_u32(d0, d1);
+	descs_tmp2 = vzip1q_u32(d2, d3);
 
 	uint64x2_t a = vreinterpretq_u64_u32(descs_tmp1);
 	uint64x2_t b = vreinterpretq_u64_u32(descs_tmp2);
@@ -271,9 +273,10 @@ sxe2_rx_desc_fnav_flags_neon(uint64x2_t descs_arr[4])
 static __rte_always_inline void
 sxe2_rx_desc_offloads_para_fill_neon(struct sxe2_rx_queue *rxq,
 			volatile union sxe2_rx_desc *desc,
-			uint64x2_t descs[4], struct rte_mbuf **rx_pkts)
+			uint64x2_t descs[4], uint32x4_t desc_lo, uint32x4_t desc_hi,
+			struct rte_mbuf **rx_pkts)
 {
-	uint32x4_t desc_lo, desc_hi, flags, tmp_flags;
+	uint32x4_t flags, tmp_flags;
 	const uint64x2_t mbuf_init = {rxq->mbuf_init_value, 0};
 	uint64x2_t rearm0, rearm1, rearm2, rearm3;
 
@@ -330,23 +333,6 @@ sxe2_rx_desc_offloads_para_fill_neon(struct sxe2_rx_queue *rxq,
 		0, 0, 0, 0, 0, 0, 0, 0
 	};
 
-	{
-		uint32x4_t d0 = vreinterpretq_u32_u64(descs[0]);
-		uint32x4_t d1 = vreinterpretq_u32_u64(descs[1]);
-		uint32x4_t d2 = vreinterpretq_u32_u64(descs[2]);
-		uint32x4_t d3 = vreinterpretq_u32_u64(descs[3]);
-		uint64x2_t f64, t64;
-
-		flags = vzip2q_u32(d1, d0);
-		tmp_flags = vzip2q_u32(d3, d2);
-		f64 = vreinterpretq_u64_u32(flags);
-		t64 = vreinterpretq_u64_u32(tmp_flags);
-		desc_lo = vreinterpretq_u32_u64(vcombine_u64(vget_low_u64(f64),
-							     vget_low_u64(t64)));
-		desc_hi = vreinterpretq_u32_u64(vcombine_u64(vget_high_u64(f64),
-							     vget_high_u64(t64)));
-	}
-
 	desc_lo = vandq_u32(desc_lo, desc_msk);
 	desc_hi = vandq_u32(desc_hi, rss_msk);
 
@@ -505,25 +491,39 @@ sxe2_rx_pkts_common_vec_neon(struct sxe2_rx_queue *rxq, struct rte_mbuf **rx_pkt
 		uint64x2_t descs[SXE2_RX_NUM_PER_LOOP_NEON];
 		uint8x16_t pkt_mb1, pkt_mb2, pkt_mb3, pkt_mb4;
 		uint64x2_t mbp1, mbp2;
+		uint32x4_t desc_lo, desc_hi;
 		uint16x8_t staterr;
 		uint16x8_t tmp;
 		uint16_t bit_num;
 
 		descs[3] = vld1q_u64(RTE_CAST_PTR(uint64_t *, desc + 3));
-		rte_atomic_thread_fence(rte_memory_order_acquire);
 		descs[2] = vld1q_u64(RTE_CAST_PTR(uint64_t *, desc + 2));
-		rte_atomic_thread_fence(rte_memory_order_acquire);
 		descs[1] = vld1q_u64(RTE_CAST_PTR(uint64_t *, desc + 1));
-		rte_atomic_thread_fence(rte_memory_order_acquire);
 		descs[0] = vld1q_u64(RTE_CAST_PTR(uint64_t *, desc));
 
 		rte_atomic_thread_fence(rte_memory_order_acquire);
-
 		descs[3] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, desc + 3), descs[3], 0);
 		descs[2] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, desc + 2), descs[2], 0);
 		descs[1] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, desc + 1), descs[1], 0);
 		descs[0] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, desc), descs[0], 0);
 
+		{
+			uint32x4_t d0 = vreinterpretq_u32_u64(descs[0]);
+			uint32x4_t d1 = vreinterpretq_u32_u64(descs[1]);
+			uint32x4_t d2 = vreinterpretq_u32_u64(descs[2]);
+			uint32x4_t d3 = vreinterpretq_u32_u64(descs[3]);
+
+			uint32x4_t q1_01 = vzip2q_u32(d0, d1);
+			uint32x4_t q1_23 = vzip2q_u32(d2, d3);
+			uint64x2_t q1_01_64 = vreinterpretq_u64_u32(q1_01);
+			uint64x2_t q1_23_64 = vreinterpretq_u64_u32(q1_23);
+
+			desc_lo = vreinterpretq_u32_u64(vcombine_u64(vget_low_u64(q1_01_64),
+							vget_low_u64(q1_23_64)));
+			desc_hi = vreinterpretq_u32_u64(vcombine_u64(vget_high_u64(q1_01_64),
+							vget_high_u64(q1_23_64)));
+		}
+
 		mbp1 = vld1q_u64((uint64_t *)&buffer[i]);
 		mbp2 = vld1q_u64((uint64_t *)&buffer[i + 2]);
 
@@ -543,7 +543,8 @@ sxe2_rx_pkts_common_vec_neon(struct sxe2_rx_queue *rxq, struct rte_mbuf **rx_pkt
 		pkt_mb1 = vqtbl1q_u8(vreinterpretq_u8_u64(descs[0]), rvp_shuf_mask);
 
 		if (do_offload) {
-			sxe2_rx_desc_offloads_para_fill_neon(rxq, desc, descs, &rx_pkts[i]);
+			sxe2_rx_desc_offloads_para_fill_neon(rxq, desc, descs, desc_lo,
+							     desc_hi, &rx_pkts[i]);
 		} else {
 			const uint64x2_t mbuf_init = {
 				rxq->mbuf_init_value,
@@ -578,55 +579,48 @@ sxe2_rx_pkts_common_vec_neon(struct sxe2_rx_queue *rxq, struct rte_mbuf **rx_pkt
 			rte_prefetch_non_temporal(desc + SXE2_RX_NUM_PER_LOOP_NEON);
 
 		{
-			uint32x4_t d0 = vreinterpretq_u32_u64(descs[0]);
-			uint32x4_t d1 = vreinterpretq_u32_u64(descs[1]);
-			uint32x4_t d2 = vreinterpretq_u32_u64(descs[2]);
-			uint32x4_t d3 = vreinterpretq_u32_u64(descs[3]);
-			uint32x4_t sterr_tmp1 = vzip2q_u32(d1, d0);
-			uint32x4_t sterr_tmp2 = vzip2q_u32(d3, d2);
-			uint32x4_t sterr_u32 = vzip1q_u32(sterr_tmp1, sterr_tmp2);
-
-			staterr = vreinterpretq_u16_u32(sterr_u32);
+			uint16x8_t sterr_tmp1 = vzip2q_u16(vreinterpretq_u16_u64(descs[0]),
+							   vreinterpretq_u16_u64(descs[2]));
+			uint16x8_t sterr_tmp2 = vzip2q_u16(vreinterpretq_u16_u64(descs[1]),
+							   vreinterpretq_u16_u64(descs[3]));
+			staterr = vzip1q_u16(sterr_tmp1, sterr_tmp2);
 		}
 
-		sxe2_rx_desc_ptype_fill_neon(staterr, &rx_pkts[i]);
+		sxe2_rx_desc_ptype_fill_neon(desc_lo, &rx_pkts[i], sxe2_ptype_tbl);
 
 		if (umbcast_flags != NULL) {
-			uint32x4_t umbcast_mask = {
-				SXE2_RX_DESC_STATUS_UMBCAST_MASK, SXE2_RX_DESC_STATUS_UMBCAST_MASK,
-				SXE2_RX_DESC_STATUS_UMBCAST_MASK, SXE2_RX_DESC_STATUS_UMBCAST_MASK,
-			};
-
+			const uint32x4_t umbcast_mask =
+				vdupq_n_u32(SXE2_RX_DESC_STATUS_UMBCAST_MASK);
 			uint8x16_t umbcast_shuf_mask = {
-				0x0B, 0x03, 0x0F, 0x07,
+				3, 7, 11, 15,
 				0xFF, 0xFF, 0xFF, 0xFF,
 				0xFF, 0xFF, 0xFF, 0xFF,
 				0xFF, 0xFF, 0xFF, 0xFF,
 			};
 			uint8x16_t umbcast_bits =
-				vreinterpretq_u8_u32(vandq_u32(vreinterpretq_u32_u16(staterr),
-							       umbcast_mask));
+				vreinterpretq_u8_u32(vandq_u32(desc_lo, umbcast_mask));
 
 			umbcast_bits = vqtbl1q_u8(umbcast_bits, umbcast_shuf_mask);
-			vst1q_lane_u32((uint32_t *)umbcast_flags,
-					vreinterpretq_u32_u8(umbcast_bits), 0);
+			*(uint32_t *)umbcast_flags =
+				vgetq_lane_u32(vreinterpretq_u32_u8(umbcast_bits), 0);
 			umbcast_flags += SXE2_RX_NUM_PER_LOOP_NEON;
 		}
 
 		if (split_rxe_flags) {
 			uint8x16_t eop_shuf_mask = {
-					0x08, 0x00, 0x0C, 0x04,
+					0, 2, 4, 6,
 					0xFF, 0xFF, 0xFF, 0xFF,
 					0xFF, 0xFF, 0xFF, 0xFF,
 					0xFF, 0xFF, 0xFF, 0xFF};
 			uint8x16_t eop_bits;
 			uint32x4_t rxe_mask = {
-				0x2080, 0x2080, 0x2080, 0x2080
+				0x20802080, 0x20802080, 0x20802080, 0x20802080
 			};
 			uint32x4_t rxe_bits;
 			uint32x4_t eop_mask;
 
-			eop_mask = vshlq_n_u32(vdupq_n_u32(1), SXE2_RX_DESC_STATUS_EOP_SHIFT);
+			eop_mask = vdupq_n_u32((1U << SXE2_RX_DESC_STATUS_EOP_SHIFT) |
+					(1U << (SXE2_RX_DESC_STATUS_EOP_SHIFT + 16)));
 			eop_bits = vandq_u8(vmvnq_u8(vreinterpretq_u8_u16(staterr)),
 					vreinterpretq_u8_u32(eop_mask));
 
@@ -650,12 +644,22 @@ sxe2_rx_pkts_common_vec_neon(struct sxe2_rx_queue *rxq, struct rte_mbuf **rx_pkt
 		}
 
 		{
-			uint32x4_t dd_mask = vdupq_n_u32(1);
-			uint32x4_t sterr_dd = vandq_u32(vreinterpretq_u32_u16(staterr), dd_mask);
-			uint16x4_t packed_lo = vmovn_u32(sterr_dd);
-			uint64_t dd64 = vget_lane_u64(vreinterpret_u64_u16(packed_lo), 0);
-
-			bit_num = (uint16_t)rte_popcount64(dd64);
+			const uint16x8_t dd_check = {
+				0x0001, 0x0001, 0x0001, 0x0001,
+				0, 0, 0, 0
+			};
+			uint16x8_t sterr_dd;
+			uint64_t stat;
+			sterr_dd = vandq_u16(staterr, dd_check);
+			sterr_dd = vshlq_n_u16(sterr_dd, 15);
+			sterr_dd =
+				vreinterpretq_u16_s16(vshrq_n_s16(vreinterpretq_s16_u16(sterr_dd),
+								  15));
+			stat = ~vgetq_lane_u64(vreinterpretq_u64_u16(sterr_dd), 0);
+			if (likely(stat == 0))
+				bit_num = SXE2_RX_NUM_PER_LOOP_NEON;
+			else
+				bit_num = (uint16_t)(rte_ctz64(stat) / 16);
 		}
 		done_num += bit_num;
 		if (likely(bit_num != SXE2_RX_NUM_PER_LOOP_NEON))
Signature · 1 line
2.52.0
#361 lore raw

PATCH v9 32/48 net/sxe2: refine vectorized Tx/Rx mode setup

In reply to [email protected]

From: Jie Liu <[email protected]>

Set rte_eth_tx_pkt_prepare_dummy for the simple and vectorized Tx paths instead of leaving the prepare callback unset, and split the NEON simple/offload mode selection based on the offload flag. Log the selected Tx/Rx mode flags and apply the default Rx free threshold when the configured value is zero.

Fixes ac60f302cbef ("net/sxe2: add vectorized Rx and Tx")
---
 drivers/net/sxe2/sxe2_rx.c   |  3 ++-
 drivers/net/sxe2/sxe2_txrx.c | 20 +++++++++++++++-----
 2 files changed, 17 insertions(+), 6 deletions(-)
drivers/net/sxe2/sxe2_rx.c +2 -1
index d700c60083..3830c676d7 100644
@@ -319,7 +319,8 @@ int32_t __rte_cold sxe2_rx_queue_setup(struct rte_eth_dev *dev,
 		rxq->mb_pool = mp;
 	}
 
-	rxq->rx_free_thresh = rx_conf->rx_free_thresh;
+	rxq->rx_free_thresh = (rx_conf->rx_free_thresh == 0) ?
+		SXE2_DEFAULT_RX_FREE_THRESH : rx_conf->rx_free_thresh;
 	rxq->port_id = dev->data->port_id;
 	rxq->offloads = offloads;
 	if (offloads & RTE_ETH_RX_OFFLOAD_KEEP_CRC)
drivers/net/sxe2/sxe2_txrx.c +15 -5
index 79870866d1..09f1dfe9fc 100644
@@ -358,7 +358,7 @@ void sxe2_tx_mode_func_set(struct rte_eth_dev *dev)
 	}
 
 	if (tx_mode_flags & SXE2_TX_MODE_VEC_SET_MASK) {
-		dev->tx_pkt_prepare = NULL;
+		dev->tx_pkt_prepare = rte_eth_tx_pkt_prepare_dummy;
 #ifdef RTE_ARCH_X86
 		if (tx_mode_flags & SXE2_TX_MODE_VEC_AVX512) {
 #ifdef CC_AVX512_SUPPORT
@@ -386,21 +386,28 @@ void sxe2_tx_mode_func_set(struct rte_eth_dev *dev)
 		}
 #elif defined(RTE_ARCH_ARM64)
 		if (tx_mode_flags & SXE2_TX_MODE_VEC_NEON) {
-			dev->tx_pkt_prepare = sxe2_tx_pkts_prepare;
-			dev->tx_pkt_burst = sxe2_tx_pkts_vec_neon;
+			if (tx_mode_flags & SXE2_TX_MODE_VEC_OFFLOAD) {
+				dev->tx_pkt_prepare = sxe2_tx_pkts_prepare;
+				dev->tx_pkt_burst = sxe2_tx_pkts_vec_neon;
+			} else {
+				dev->tx_pkt_burst = sxe2_tx_pkts_vec_neon_simple;
+			}
 		} else {
-			dev->tx_pkt_burst = sxe2_tx_pkts_vec_neon_simple;
+			dev->tx_pkt_prepare = sxe2_tx_pkts_prepare;
+			dev->tx_pkt_burst = sxe2_tx_pkts;
 		}
 #endif
 	} else {
 		if (tx_mode_flags & SXE2_TX_MODE_SIMPLE_BATCH) {
-			dev->tx_pkt_prepare = NULL;
+			dev->tx_pkt_prepare = rte_eth_tx_pkt_prepare_dummy;
 			dev->tx_pkt_burst = sxe2_tx_pkts_simple;
 		} else {
 			dev->tx_pkt_prepare = sxe2_tx_pkts_prepare;
 			dev->tx_pkt_burst = sxe2_tx_pkts;
 		}
 	}
+	PMD_LOG_DEBUG(TX, "Tx mode flags:0x%08x port_id:%u.",
+				tx_mode_flags, dev->data->port_id);
 }
 
 static const struct {
@@ -582,6 +589,9 @@ void sxe2_rx_mode_func_set(struct rte_eth_dev *dev)
 		dev->rx_pkt_burst = sxe2_rx_pkts_scattered_split;
 	else
 		dev->rx_pkt_burst = sxe2_rx_pkts_scattered;
+
+	PMD_LOG_DEBUG(RX, "Rx mode flags:0x%08x port_id:%u.",
+				rx_mode_flags, dev->data->port_id);
 }
 
 static const struct {
Signature · 1 line
2.52.0
#362 lore raw

PATCH v9 33/48 net/sxe2: fix RSS action attribute validation

In reply to [email protected]

From: Jie Liu <[email protected]>

The rss->level/key_len/queue_num checks only set the rte_flow_error but still return 0 (success), so invalid RSS configurations are accepted instead of being rejected with ENOTSUP.

Return the error code from the validation checks, matching the behavior in the V3 implementation.

Fixes 635084db5d57 ("net/sxe2: support VF representors")
---
 drivers/net/sxe2/sxe2_flow_parse_action.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/net/sxe2/sxe2_flow_parse_action.c +10 -4
index 03ada4e8a6..65ddfeb47f 100644
@@ -12,7 +12,7 @@
 static int32_t sxe2_flow_check_rss_action_attr(const struct rte_flow_action_rss *rss,
 					   struct rte_flow_error *error)
 {
-	int32_t ret = ENOTSUP;
+	int32_t ret = -ENOTSUP;
 	switch (rss->func) {
 	case RTE_ETH_HASH_FUNCTION_DEFAULT:
 	case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
@@ -25,15 +25,21 @@ static int32_t sxe2_flow_check_rss_action_attr(const struct rte_flow_action_rss
 		goto l_end;
 	}
 
-	if (rss->level > 2)
+	if (rss->level > 2) {
 		rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, NULL,
 			"RSS  level is could not be greater than 2");
-	if (rss->key_len)
+		goto l_end;
+	}
+	if (rss->key_len) {
 		rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, NULL,
 			"a nonzero RSS key_len is not supported");
-	if (rss->queue_num)
+		goto l_end;
+	}
+	if (rss->queue_num) {
 		rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, NULL,
 			"a non-NULL RSS queue is not supported");
+		goto l_end;
+	}
 	ret = 0;
 l_end:
 	return ret;
Signature · 1 line
2.52.0
#363 lore raw

PATCH v9 34/48 net/sxe2: restore PF-only guard in UDP tunnel port add

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_udp_tunnel_port_add_common() lost the check that restricts UDP tunnel port configuration to PF devices (not VF or representor), so VF/representor devices can now attempt to add UDP tunnel ports, which the hardware does not support.

Restore the PF-only guard returning -ENOTSUP, matching the V3 implementation.

Fixes fff24885f70a ("net/sxe2: support custom UDP tunnel ports")
---
 drivers/net/sxe2/sxe2_ethdev.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/net/sxe2/sxe2_ethdev.c +11 -0
index ea589c7eaa..82ad6e660a 100644
@@ -630,6 +630,10 @@ int32_t sxe2_udp_tunnel_port_add_common(struct sxe2_adapter *ad,
 	struct sxe2_udp_tunnel_cfg *tunnel_config;
 	int32_t ret = -1;
 
+	if (ad->dev_type != SXE2_DEV_T_PF || ad->is_dev_repr) {
+		ret = -ENOTSUP;
+		goto l_end;
+	}
 	rte_spinlock_lock(&ad->udp_tunnel_ctx.lock);
 
 	tunnel_config = &ad->udp_tunnel_ctx.tunnel_conf[tunnel_proto];
@@ -659,6 +663,7 @@ int32_t sxe2_udp_tunnel_port_add_common(struct sxe2_adapter *ad,
 
 l_unlock_end:
 	rte_spinlock_unlock(&ad->udp_tunnel_ctx.lock);
+l_end:
 	return ret;
 }
 
@@ -669,6 +674,9 @@ int32_t sxe2_udp_tunnel_port_del_common(struct sxe2_adapter *ad,
 	struct sxe2_udp_tunnel_cfg *tunnel_config;
 	int32_t ret = -1;
 
+	if (ad->dev_type != SXE2_DEV_T_PF || ad->is_dev_repr)
+		return -ENOTSUP;
+
 	rte_spinlock_lock(&ad->udp_tunnel_ctx.lock);
 	tunnel_config = &ad->udp_tunnel_ctx.tunnel_conf[tunnel_proto];
 
@@ -703,6 +711,9 @@ static int32_t sxe2_udp_tunnel_port_clear(struct rte_eth_dev *dev)
 	int32_t ret = 0;
 	uint16_t tunnel_proto = 0;
 
+	if (ad->dev_type != SXE2_DEV_T_PF || ad->is_dev_repr)
+		return -ENOTSUP;
+
 	rte_spinlock_lock(&ad->udp_tunnel_ctx.lock);
 
 	for (tunnel_proto = 0; tunnel_proto < SXE2_UDP_TUNNEL_MAX; tunnel_proto++) {
Signature · 1 line
2.52.0
#364 lore raw

PATCH v9 35/48 net/sxe2: refresh link state on link change events

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_link_update() was only called during device init, so the ethdev link state was not refreshed when link status changed at runtime.

Call sxe2_link_update() in the link-change IRQ handler for both the PF and its representors, so the link state is updated on LSC events. Remove the now-redundant call from sxe2_link_update_init().

Fixes 1d7fd921beef ("net/sxe2: support link update")
---
 drivers/net/sxe2/sxe2_irq.c |  2 ++
 drivers/net/sxe2/sxe2_mac.c | 11 +++--------
 2 files changed, 5 insertions(+), 8 deletions(-)
drivers/net/sxe2/sxe2_irq.c +2 -0
index ba764dd5e4..4c3a29900d 100644
@@ -84,6 +84,7 @@ static void sxe2_event_irq_common_handler(struct sxe2_adapter *adapter, uint64_t
 	if (oicr & RTE_BIT32(SXE2_COM_EC_LINK_CHG)) {
 		PMD_DEV_LOG_INFO(adapter, DRV, "OICR=0x%" PRIx64, oicr);
 		(void)sxe2_drv_mac_link_status_get(adapter);
+		(void)sxe2_link_update(dev, 0);
 		if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 			rte_eth_dev_callback_process(dev,
 						     RTE_ETH_EVENT_INTR_LSC,
@@ -96,6 +97,7 @@ static void sxe2_event_irq_common_handler(struct sxe2_adapter *adapter, uint64_t
 					continue;
 				repr_adapter = SXE2_DEV_PRIVATE_TO_ADAPTER(repr_eth_dev);
 				(void)sxe2_drv_mac_link_status_get(repr_adapter);
+				(void)sxe2_link_update(repr_eth_dev, 0);
 				if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 					rte_eth_dev_callback_process(repr_eth_dev,
 								     RTE_ETH_EVENT_INTR_LSC,
drivers/net/sxe2/sxe2_mac.c +3 -8
index 729c804ac3..ab9bd5355b 100644
@@ -448,18 +448,13 @@ int32_t sxe2_link_update_init(struct rte_eth_dev *dev)
 	int32_t ret;
 
 	PMD_INIT_FUNC_TRACE();
-
 	rte_spinlock_init(&adapter->link_ctxt.link_lock);
-
 	ret = sxe2_drv_mac_link_status_get(adapter);
-	if (ret) {
+	if (ret)
 		PMD_DEV_LOG_ERR(adapter, DRV, "Failed to get link status, ret=%d", ret);
-		goto l_end;
-	}
-
-	(void)sxe2_link_update(dev, 0);
+	else
+		(void)sxe2_link_update(dev, 0);
 
-l_end:
 	return ret;
 }
 int32_t sxe2_link_update(struct rte_eth_dev *dev, __rte_unused int32_t wait_to_complete)
Signature · 1 line
2.52.0
#365 lore raw

PATCH v9 36/48 net/sxe2: validate representor ID against VF count

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_switchdev_repr_private_data_init() indexes parent_adapter->repr_ctxt.repr_vf_id[repr_id] without checking that repr_id is within the number of configured VFs, which can access out of bounds when an invalid representor ID is passed.

Add a bounds check on repr_id against repr_ctxt.nb_vf and return -EINVAL on the error path.

Fixes 635084db5d57 ("net/sxe2: support VF representors")
---
 drivers/net/sxe2/sxe2_switchdev.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/sxe2/sxe2_switchdev.c +6 -0
index efb1468b91..d0304ccc94 100644
@@ -312,6 +312,12 @@ int32_t sxe2_switchdev_repr_private_data_init(struct rte_eth_dev *dev,
 	repr_priv_data->repr_q_id = repr_id;
 	repr_priv_data->repr_pf_id = parent_adapter->pf_idx;
 	repr_priv_data->repr_vf_id = repr_id;
+	if (repr_id >= parent_adapter->repr_ctxt.nb_vf) {
+		PMD_LOG_ERR(INIT, "repr_id %u exceed max vf %u",
+			repr_id, parent_adapter->repr_ctxt.nb_vf);
+		ret = -EINVAL;
+		goto l_free;
+	}
 	repr_priv_data->repr_vf_primary_vsi_id =
 		parent_adapter->repr_ctxt.repr_vf_id[repr_id].kernel_vsi_id;
 	repr_priv_data->repr_vf_backup_vsi_id =
Signature · 1 line
2.52.0
#366 lore raw

v10 cover net/sxe2: re-align with reference and fix review findings

From: Jie Liu <[email protected]>

This series updates the SXE2 poll mode driver (drivers/net/sxe2) and its common library (drivers/common/sxe2), fixing issues found in the previous version and re-aligning the driver with the reference implementation.

Changes since v9:
- correct the commit message of the link state refresh patch: the sxe2_link_update() call in sxe2_link_update_init() is kept, not removed, and is now conditional on a successful link status read so the initial link state is still populated at init
- return the error from rte_eth_devargs_parse() directly on the devargs parse failure paths: that function does not set rte_errno, so returning -rte_errno could yield 0 and let probing continue with an empty eth_da after a parse failure

Jie Liu (48):
common/sxe2: fix null pointer in class driver remove common/sxe2: allow munmap during kernel reset net/sxe2: fix VF PCI device ID
net/sxe2: fix MSIX register width in PF map table net/sxe2: restore PF and port index caps assignment net/sxe2: fix VSI lifecycle management net/sxe2: initialize stats in representor device init net/sxe2: use base device name for representor naming net/sxe2: propagate LSC event to VF representors net/sxe2: clear security context pointer on uninit net/sxe2: rename representor VSI ID fields net/sxe2: clean up duplicate function declarations net/sxe2: fix null VSI dereference in device info net/sxe2: fill MAC addresses in device info net/sxe2: fix QinQ and RSS offload capability report net/sxe2: use regular write for mapped registers net/sxe2: move PCI register read macro to common header net/sxe2: validate PCI map resource type net/sxe2: guard PCI BAR unmap when not initialized net/sxe2: fix duplicated cleanup in dev close net/sxe2: align dev init and cleanup order net/sxe2: simplify switchdev representor matching net/sxe2: rename fnav cid manager symbols to flow net/sxe2: move tunnel port helpers into flow module net/sxe2: add ACL engine event statistics support net/sxe2: enable FDIR on all Rx queues net/sxe2: refactor primary process MP message handling net/sxe2: refactor Tx queue reset operations net/sxe2: unify vectorized Tx buffer handling net/sxe2: optimize NEON Tx descriptor fill net/sxe2: fix NEON Rx ptype mapping and memory ordering net/sxe2: refine vectorized Tx/Rx mode setup net/sxe2: fix RSS action attribute validation net/sxe2: restore PF-only guard in UDP tunnel port add net/sxe2: refresh link state on link change events net/sxe2: validate representor ID against VF count net/sxe2: use primary VSI ID for representor VSI net/sxe2: wrap command params fill debug log in macro net/sxe2: restore Rx queue buffer split fill support net/sxe2: skip tunnel config fill on get failure net/sxe2: skip flow ID assignment on filter add failure net/sxe2: correct command channel log messages net/sxe2: align command structs with kernel layout common/sxe2: fix ioctl channel log and close handling doc/sxe2: remove drv-SW-stats parameter documentation net/sxe2: remove ineffective representor queue counts net/sxe2: fix VEC mode selection in mode set functions net/sxe2: fix devargs parse error check for representors

 doc/guides/nics/sxe2.rst                   |  40 ++--
 drivers/common/sxe2/sxe2_common.c          |   6 +-
 drivers/common/sxe2/sxe2_ioctl_chnl.c      |  21 +-
 drivers/net/sxe2/sxe2_cmd_chnl.c           | 199 +++++++++++++++--
 drivers/net/sxe2/sxe2_cmd_chnl.h           |  15 +-
 drivers/net/sxe2/sxe2_drv_cmd.h            |  33 +--
 drivers/net/sxe2/sxe2_dump.c               |  10 +-
 drivers/net/sxe2/sxe2_ethdev.c             | 192 ++++++++++-------
 drivers/net/sxe2/sxe2_ethdev.h             |  13 +-
 drivers/net/sxe2/sxe2_ethdev_repr.c        |  20 +-
 drivers/net/sxe2/sxe2_flow.c               | 235 ++++++++++++++++++---
 drivers/net/sxe2/sxe2_flow.h               |   6 +-
 drivers/net/sxe2/sxe2_flow_define.h        |  15 +-
 drivers/net/sxe2/sxe2_flow_parse_action.c  |  42 ++--
 drivers/net/sxe2/sxe2_flow_parse_pattern.c | 113 ----------
 drivers/net/sxe2/sxe2_flow_parse_pattern.h |   6 -
 drivers/net/sxe2/sxe2_irq.c                |  24 ++-
 drivers/net/sxe2/sxe2_mac.c                |  11 +-
 drivers/net/sxe2/sxe2_mp.c                 |  59 +++---
 drivers/net/sxe2/sxe2_queue.c              |   2 +
 drivers/net/sxe2/sxe2_queue.h              |   7 +-
 drivers/net/sxe2/sxe2_rx.c                 |   3 +-
 drivers/net/sxe2/sxe2_security.c           |   1 +
 drivers/net/sxe2/sxe2_switchdev.c          |  15 +-
 drivers/net/sxe2/sxe2_tx.c                 |  42 +++-
 drivers/net/sxe2/sxe2_tx.h                 |   4 +
 drivers/net/sxe2/sxe2_txrx.c               |  34 +--
 drivers/net/sxe2/sxe2_txrx_poll.h          |   2 -
 drivers/net/sxe2/sxe2_txrx_vec.c           |  74 +++----
 drivers/net/sxe2/sxe2_txrx_vec_avx2.c      |  10 +-
 drivers/net/sxe2/sxe2_txrx_vec_avx512.c    | 133 +-----------
 drivers/net/sxe2/sxe2_txrx_vec_common.h    |   9 +-
 drivers/net/sxe2/sxe2_txrx_vec_neon.c      | 223 ++++++++++++-------
 drivers/net/sxe2/sxe2_txrx_vec_sse.c       |  10 +-
 drivers/net/sxe2/sxe2_vsi.c                |  31 +--
 35 files changed, 948 insertions(+), 712 deletions(-)
Signature · 1 line
2.52.0
#367 lore raw

Re: [PATCH v10 00/48] net/sxe2: re-align with reference and fix review findings

Quoted 17 lines · On Thu, 3 Sep 2026 09:53:49 +0800 [email protected] wrote:

From: Jie Liu <[email protected]>

This series updates the SXE2 poll mode driver (drivers/net/sxe2) and its common library (drivers/common/sxe2), fixing issues found in the previous version and re-aligning the driver with the reference implementation.

Changes since v9:
- correct the commit message of the link state refresh patch: the sxe2_link_update() call in sxe2_link_update_init() is kept, not removed, and is now conditional on a successful link status read so the initial link state is still populated at init
- return the error from rte_eth_devargs_parse() directly on the devargs parse failure paths: that function does not set rte_errno, so returning -rte_errno could yield 0 and let probing continue with an empty eth_da after a parse failure

Quoted 1 line

Applied to next-net

The older queue stats mapping is gone in 26.11 so it requires some rework.

Patchwork was getting confused by the mail threading. Not sure how you sent it but the easiest way would have been to thread reply against the msgid of the first cover letter.

  $ [email protected]
  $ git send-email -v10 --in-reply-to=$MSGID \
     --to [email protected] --cc-cmd ./devtools/get-maintainer.sh \
     --cover-letter --annotate
     origin/main # or *.patch
#368 lore raw

PATCH v10 1/48 common/sxe2: fix null pointer in class driver remove

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_classes_driver_remove() calls cdrv->remove(cdev) without checking whether cdrv or cdrv->remove is NULL. If the class driver was never probed, cdev->cdrv remains NULL, and the unconditional call dereferences a NULL pointer, crashing during device removal.

Add NULL checks for cdrv and cdrv->remove, returning 0 when either is NULL.

Fixes 83866f8d7638 ("common/sxe2: add base driver skeleton")
---
 drivers/common/sxe2/sxe2_common.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/common/sxe2/sxe2_common.c +5 -1
index 5c5db85f29..6e387a8a73 100644
@@ -465,8 +465,12 @@ static int32_t sxe2_classes_driver_probe(struct sxe2_common_device *cdev,
 static int32_t sxe2_classes_driver_remove(struct sxe2_common_device *cdev)
 {
 	struct sxe2_class_driver *cdrv = cdev->cdrv;
+	int32_t ret = 0;
+
+	if (cdrv != NULL && cdrv->remove != NULL)
+		ret = cdrv->remove(cdev);
 
-	return cdrv->remove(cdev);
+	return ret;
 }
 
 static int32_t sxe2_kvargs_validate(struct sxe2_dev_kvargs_info *kv_info)
Signature · 1 line
2.52.0
#369 lore raw

PATCH v10 2/48 common/sxe2: allow munmap during kernel reset

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_drv_dev_munmap() refuses to unmap the BAR region when cdev->config.kernel_reset is set, returning -EPERM. After a kernel reset the application still needs to release the previously mapped regions during cleanup; blocking munmap leaves stale mappings and prevents a clean teardown.

Remove the kernel_reset check from sxe2_drv_dev_munmap() so the mapping is always released. The cdev parameter is no longer used, so mark it __rte_unused.

Fixes 66a10eb60ebe ("net/sxe2: add PCI BAR mapping")
---
 drivers/common/sxe2/sxe2_ioctl_chnl.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/common/sxe2/sxe2_ioctl_chnl.c +1 -7
index a233a78136..3e2fbf572f 100644
@@ -367,16 +367,10 @@ void
 
 RTE_EXPORT_INTERNAL_SYMBOL(sxe2_drv_dev_munmap)
 int32_t
-sxe2_drv_dev_munmap(struct sxe2_common_device *cdev, void *virt, uint64_t len)
+sxe2_drv_dev_munmap(struct sxe2_common_device *cdev __rte_unused, void *virt, uint64_t len)
 {
 	int32_t ret = 0;
 
-	if (cdev->config.kernel_reset) {
-		ret = -EPERM;
-		PMD_LOG_WARN(COM, "kernel reset, need restart app.");
-		goto l_end;
-	}
-
 	PMD_LOG_DEBUG(COM, "Munmap virt=%p, len=0x%"PRIx64"",
 		virt, len);
 
Signature · 1 line
2.52.0
#370 lore raw

PATCH v10 3/48 net/sxe2: fix VF PCI device ID

In reply to [email protected]

From: Jie Liu <[email protected]>

The VF PCI device ID is defined as 0x10b2 per the hardware specification, but the code incorrectly uses 0x10b.

As a result, the VF driver never binds to the device, making VF functionality completely unusable.

Fix this by changing SXE2_PCI_DEVICE_ID_VF_1 from 0x10b to 0x10b2.

Fixes d8e4e075acb4 ("net/sxe2: add probing skeleton")
---
 drivers/net/sxe2/sxe2_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/sxe2/sxe2_ethdev.c +1 -1
index 8bbfdc3a15..ec376b76dc 100644
@@ -44,7 +44,7 @@
 
 #define SXE2_PCI_VENDOR_ID_1    0x1ff2
 #define SXE2_PCI_DEVICE_ID_PF_1 0x10b1
-#define SXE2_PCI_DEVICE_ID_VF_1 0x10b
+#define SXE2_PCI_DEVICE_ID_VF_1 0x10b2
 
 #define SXE2_PCI_VENDOR_ID_2    0x1d94
 #define SXE2_PCI_DEVICE_ID_PF_2 0x1260
Signature · 1 line
2.52.0
#371 lore raw

PATCH v10 4/48 net/sxe2: fix MSIX register width in PF map table

In reply to [email protected]

From: Jie Liu <[email protected]>

The MSIX entry in sxe2_net_map_addr_info_pf sets a register width of 10 (decimal), but each PCIe MSIX table entry is 16 bytes (0x10). The VF map table already uses 0x10.

Since reg_width is used as the stride between MSIX entries in sxe2_dev_pci_seg_map(), the wrong value makes the mapped region too short and places the entries at incorrect offsets.

Change .reg_width from 10 to 0x10 for the SXE2_PCI_MAP_RES_IRQ_MSIX entry to match the VF table.

Fixes 66a10eb60ebe ("net/sxe2: add PCI BAR mapping")
---
 drivers/net/sxe2/sxe2_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/sxe2/sxe2_ethdev.c +1 -1
index ec376b76dc..5d8cfca6cf 100644
@@ -94,7 +94,7 @@ static struct sxe2_pci_map_addr_info sxe2_net_map_addr_info_pf[SXE2_PCI_MAP_RES_
 				      .reg_width = 4},
 	[SXE2_PCI_MAP_RES_IRQ_MSIX] = {.addr_base = SXE2_BAR4_MSIX_CTL(0),
 				      .bar_idx = 4,
-				      .reg_width = 10},
+				      .reg_width = 0x10},
 };
 
 static struct sxe2_pci_map_addr_info sxe2_net_map_addr_info_vf[SXE2_PCI_MAP_RES_MAX_COUNT] = {
Signature · 1 line
2.52.0
#372 lore raw

PATCH v10 5/48 net/sxe2: restore PF and port index caps assignment

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_func_caps_get() never assigns adapter->pf_idx from the device capabilities, leaving it at its zero-initialized value. Switchdev requests and representor setup that use pf_idx then report the wrong PF index on multi-PF configurations.

Restore the pf_idx and port_idx assignments in sxe2_func_caps_get() and drop the now-redundant port_idx assignment from sxe2_drv_dev_caps_set().

Fixes d8e4e075acb4 ("net/sxe2: add probing skeleton")
---
 drivers/net/sxe2/sxe2_ethdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/sxe2/sxe2_ethdev.c +2 -2
index 5d8cfca6cf..2e14c372f8 100644
@@ -1284,8 +1284,6 @@ void sxe2_eth_uinit(struct rte_eth_dev *dev __rte_unused)
 static void sxe2_drv_dev_caps_set(struct sxe2_adapter *adapter,
 			struct sxe2_drv_dev_caps_resp *dev_caps)
 {
-	adapter->port_idx = dev_caps->port_idx;
-
 	adapter->cap_flags = 0;
 
 	if (dev_caps->cap_flags & SXE2_DEV_CAPS_OFFLOAD_L2)
@@ -1344,6 +1342,8 @@ static int32_t sxe2_func_caps_get(struct sxe2_adapter *adapter)
 		goto l_end;
 
 	adapter->dev_type = dev_caps.dev_type;
+	adapter->port_idx = dev_caps.port_idx;
+	adapter->pf_idx = dev_caps.pf_idx;
 
 	sxe2_drv_dev_caps_set(adapter,  &dev_caps);
 
Signature · 1 line
2.52.0
#373 lore raw

PATCH v10 6/48 net/sxe2: fix VSI lifecycle management

In reply to [email protected]

From: Jie Liu <[email protected]>

Fix several VSI create/destroy issues introduced by VF representor support:

- Initialize other_vsi_list with TAILQ_INIT in sxe2_vsi_init before any VSI is inserted into it.
- Treat -EPERM as a non-fatal error when destroying VSIs, since the kernel may have already removed the VSI.
- Set main_vsi to NULL after destroy/free to avoid a dangling pointer if the VSI is destroyed again.

Fixes 635084db5d57 ("net/sxe2: support VF representors")
---
 drivers/net/sxe2/sxe2_vsi.c | 31 ++++++++++---------------------
 1 file changed, 10 insertions(+), 21 deletions(-)
drivers/net/sxe2/sxe2_vsi.c +10 -21
index d29480b931..e1a26fda6a 100644
@@ -96,21 +96,6 @@ static struct sxe2_vsi *sxe2_vsi_node_create(struct sxe2_adapter *adapter,
 	return vsi;
 }
 
-static void sxe2_vsi_node_free(struct sxe2_vsi *vsi)
-{
-	struct sxe2_adapter *adapter;
-
-	if (!vsi)
-		return;
-
-	adapter = vsi->adapter;
-	if (vsi->vsi_type == SXE2_VSI_T_ESW)
-		TAILQ_REMOVE(&adapter->vsi_ctxt.other_vsi_list, vsi, next);
-
-	rte_free(vsi);
-	vsi = NULL;
-}
-
 static int32_t sxe2_vsi_destroy(struct sxe2_adapter *adapter, struct sxe2_vsi *vsi)
 {
 	int32_t ret = 0;
@@ -131,6 +116,8 @@ static int32_t sxe2_vsi_destroy(struct sxe2_adapter *adapter, struct sxe2_vsi *v
 	}
 
 l_free:
+	if (vsi->vsi_type == SXE2_VSI_T_DPDK_ESW)
+		TAILQ_REMOVE(&adapter->vsi_ctxt.other_vsi_list, vsi, next);
 	rte_free(vsi);
 	vsi = NULL;
 
@@ -174,7 +161,7 @@ static int32_t sxe2_main_vsi_create(struct sxe2_adapter *adapter)
 	goto l_end;
 
 l_free_vsi:
-	sxe2_vsi_node_free(adapter->vsi_ctxt.main_vsi);
+	rte_free(adapter->vsi_ctxt.main_vsi);
 	adapter->vsi_ctxt.main_vsi = NULL;
 l_end:
 	return ret;
@@ -217,7 +204,7 @@ int32_t sxe2_other_vsi_create(struct sxe2_adapter *adapter, uint16_t cnt_vf)
 	goto l_end;
 
 l_free_vsi:
-	sxe2_vsi_node_free(other_vsi);
+	rte_free(other_vsi);
 l_end:
 	return ret;
 }
@@ -230,7 +217,7 @@ int32_t sxe2_vsi_init(struct rte_eth_dev *dev)
 	uint16_t srcvsi_cnt;
 
 	PMD_INIT_FUNC_TRACE();
-
+	TAILQ_INIT(&adapter->vsi_ctxt.other_vsi_list);
 	ret = sxe2_main_vsi_create(adapter);
 	if (ret) {
 		PMD_LOG_ERR(DRV, "Failed to create main VSI, ret=%d", ret);
@@ -283,13 +270,14 @@ void sxe2_vsi_uninit(struct rte_eth_dev *dev)
 
 l_free:
 	ret = sxe2_vsi_destroy(adapter, adapter->vsi_ctxt.main_vsi);
-	if (ret) {
+	if (ret && ret != -EPERM) {
 		PMD_LOG_ERR(DRV, "Failed to del vsi from fw, ret=%d", ret);
 		goto l_end;
 	}
+	adapter->vsi_ctxt.main_vsi = NULL;
 	RTE_TAILQ_FOREACH_SAFE(var, &adapter->vsi_ctxt.other_vsi_list, next, tvar) {
 		ret = sxe2_vsi_destroy(adapter, var);
-		if (ret) {
+		if (ret && ret != -EPERM) {
 			PMD_LOG_ERR(DRV, "Failed to del vsi from fw, ret=%d", ret);
 			break;
 		}
@@ -356,5 +344,6 @@ void sxe2_vsi_repr_main_vsi_destroy(struct rte_eth_dev *dev)
 {
 	struct sxe2_adapter *adapter = SXE2_DEV_PRIVATE_TO_ADAPTER(dev);
 
-	sxe2_vsi_node_free(adapter->vsi_ctxt.main_vsi);
+	rte_free(adapter->vsi_ctxt.main_vsi);
+	adapter->vsi_ctxt.main_vsi = NULL;
 }
Signature · 1 line
2.52.0
#374 lore raw

PATCH v10 7/48 net/sxe2: initialize stats in representor device init

In reply to [email protected]

From: Jie Liu <[email protected]>

Add sxe2_stats_init() call in sxe2_repr_dev_init to set up the statistics infrastructure for representor devices, and add the l_init_irq_ctxt_err error path to uninitialize the software irq context if stats initialization fails.

---
 drivers/net/sxe2/sxe2_ethdev_repr.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/net/sxe2/sxe2_ethdev_repr.c +8 -0
index f32318b731..c698baafe0 100644
@@ -483,8 +483,16 @@ int32_t sxe2_repr_dev_init(struct rte_eth_dev *dev,
 		goto l_init_sw_err;
 	}
 
+	ret = sxe2_stats_init(dev);
+	if (ret) {
+		PMD_LOG_ERR(INIT, "Failed to initialize stats, ret=[%d]", ret);
+		goto l_init_irq_ctxt_err;
+	}
+
 	goto l_end;
 
+l_init_irq_ctxt_err:
+	sxe2_sw_irq_ctxt_uninit(dev);
 l_init_sw_err:
 	sxe2_eth_uinit(dev);
 l_init_eth_err:
Signature · 1 line
2.52.0
#375 lore raw

PATCH v10 8/48 net/sxe2: use base device name for representor naming

In reply to [email protected]

From: Jie Liu <[email protected]>

Update the representor device naming to use the base device name prefix, and set the numa_node from the parent device data so that representor devices are allocated on the same NUMA node.

---
 drivers/net/sxe2/sxe2_ethdev_repr.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/sxe2/sxe2_ethdev_repr.c +4 -4
index c698baafe0..6f5642ad5d 100644
@@ -552,9 +552,8 @@ int32_t sxe2_switchdev_repr_devs_init(struct sxe2_adapter *adapter,
 	}
 
 	for (repr_idx = 0; repr_idx < req_eth_da->nb_representor_ports; ++repr_idx) {
-		snprintf(name, sizeof(name), "sxe2_representor_c%dpf%d%s%u",
-			 adapter->pf_idx, adapter->pf_idx,
-			 "vf",
+		snprintf(name, sizeof(name), "%s_representor_vf%u",
+			 adapter->cdev->dev->name,
 			 req_eth_da->representor_ports[repr_idx]);
 
 		eth_dev = rte_eth_dev_allocate(name);
@@ -562,10 +561,11 @@ int32_t sxe2_switchdev_repr_devs_init(struct sxe2_adapter *adapter,
 			ret = -ENOMEM;
 			goto l_release_port;
 		}
+		eth_dev->data->numa_node = adapter->dev_info.dev_data->numa_node;
 		eth_dev->data->dev_private = rte_zmalloc_socket(name,
 			sizeof(struct sxe2_adapter),
 			RTE_CACHE_LINE_SIZE,
-			rte_socket_id());
+			eth_dev->data->numa_node);
 
 		if (!eth_dev->data->dev_private) {
 			rte_eth_dev_release_port(eth_dev);
Signature · 1 line
2.52.0
#376 lore raw

PATCH v10 9/48 net/sxe2: propagate LSC event to VF representors

In reply to [email protected]

From: Jie Liu <[email protected]>

When the PF link state changes in switchdev mode, refresh the link status of every VF representor and trigger the RTE_ETH_EVENT_INTR_LSC callback on each, so applications receive link events on representor ports. Also log OICR in hexadecimal for better readability.

---
 drivers/net/sxe2/sxe2_irq.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
drivers/net/sxe2/sxe2_irq.c +20 -2
index 3306504761..ba764dd5e4 100644
@@ -77,14 +77,32 @@ static int32_t sxe2_fc_state_callback(struct rte_eth_dev *dev)
 static void sxe2_event_irq_common_handler(struct sxe2_adapter *adapter, uint64_t oicr)
 {
 	struct rte_eth_dev *dev = &rte_eth_devices[adapter->dev_info.dev_data->port_id];
+	struct rte_eth_dev *repr_eth_dev;
+	struct sxe2_adapter *repr_adapter;
+	uint16_t vf_id;
 
 	if (oicr & RTE_BIT32(SXE2_COM_EC_LINK_CHG)) {
-		PMD_DEV_LOG_INFO(adapter, DRV, "OICR=%" PRIu64, oicr);
+		PMD_DEV_LOG_INFO(adapter, DRV, "OICR=0x%" PRIx64, oicr);
 		(void)sxe2_drv_mac_link_status_get(adapter);
-		if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+		if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 			rte_eth_dev_callback_process(dev,
 						     RTE_ETH_EVENT_INTR_LSC,
 						     NULL);
+		}
+		if (adapter->switchdev_info.is_switchdev) {
+			for (vf_id = 0; vf_id < adapter->repr_ctxt.nb_repr_vf; vf_id++) {
+				repr_eth_dev = adapter->repr_ctxt.vf_rep_eth_dev[vf_id];
+				if (!repr_eth_dev)
+					continue;
+				repr_adapter = SXE2_DEV_PRIVATE_TO_ADAPTER(repr_eth_dev);
+				(void)sxe2_drv_mac_link_status_get(repr_adapter);
+				if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+					rte_eth_dev_callback_process(repr_eth_dev,
+								     RTE_ETH_EVENT_INTR_LSC,
+								     NULL);
+				}
+			}
+		}
 	}
 	if (oicr & RTE_BIT32(SXE2_COM_SW_MODE_SWITCHDEV)) {
 		PMD_DEV_LOG_INFO(adapter, DRV, "event notify switchdev");
Signature · 1 line
2.52.0
#377 lore raw

PATCH v10 10/48 net/sxe2: clear security context pointer on uninit

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_security_uinit() frees the security session but leaves dev->security_ctx pointing at the freed memory. Set dev->security_ctx to NULL after releasing the security context so a later access does not dereference a dangling pointer.

---
 drivers/net/sxe2/sxe2_security.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/sxe2/sxe2_security.c +1 -0
index bc59d1b880..8f31067942 100644
@@ -326,6 +326,7 @@ void sxe2_security_uinit(struct rte_eth_dev *dev)
 	if (sctx != NULL) {
 		rte_free(sctx);
 		sctx = NULL;
+		dev->security_ctx = NULL;
 	}
 
 	sxe2_ipsec_uinit(adapter);
Signature · 1 line
2.52.0
#378 lore raw

PATCH v10 11/48 net/sxe2: rename representor VSI ID fields

In reply to [email protected]

From: Jie Liu <[email protected]>

Rename repr_vf_k_vsi_id/repr_vf_u_vsi_id to
repr_vf_primary_vsi_id/repr_vf_backup_vsi_id in
sxe2_repr_private_data and update all references.

---
 drivers/net/sxe2/sxe2_dump.c      | 8 ++++----
 drivers/net/sxe2/sxe2_ethdev.h    | 4 ++--
 drivers/net/sxe2/sxe2_flow.c      | 4 ++--
 drivers/net/sxe2/sxe2_switchdev.c | 4 ++--
 4 files changed, 10 insertions(+), 10 deletions(-)
drivers/net/sxe2/sxe2_dump.c +4 -4
index d43473e083..590219f502 100644
@@ -211,16 +211,16 @@ sxe2_dump_switchdev_info(FILE *file, struct rte_eth_dev *dev)
 			"\t  -- repr_pf_id: %u\n"
 			"\t  -- repr_vf_id: %u\n"
 			"\t  -- repr_vf_vsi_id: %u\n"
-			"\t  -- repr_vf_k_vsi_id: %s\n"
-			"\t  -- repr_vf_u_vsi_id: %s\n",
+			"\t  -- repr_vf_primary_vsi_id: %s\n"
+			"\t  -- repr_vf_backup_vsi_id: %s\n",
 			adapter->repr_priv_data->repr_id,
 			adapter->repr_priv_data->repr_q_id,
 			adapter->repr_priv_data->repr_pf_id,
 			adapter->repr_priv_data->repr_vf_id,
 			adapter->repr_priv_data->repr_vf_vsi_id,
-			sxe2_vsi_id_str(adapter->repr_priv_data->repr_vf_k_vsi_id,
+			sxe2_vsi_id_str(adapter->repr_priv_data->repr_vf_primary_vsi_id,
 					k_vsi_buf, sizeof(k_vsi_buf)),
-			sxe2_vsi_id_str(adapter->repr_priv_data->repr_vf_u_vsi_id,
+			sxe2_vsi_id_str(adapter->repr_priv_data->repr_vf_backup_vsi_id,
 					u_vsi_buf, sizeof(u_vsi_buf)));
 		goto l_end;
 	}
drivers/net/sxe2/sxe2_ethdev.h +2 -2
index c54e8a435e..158198d74b 100644
@@ -263,8 +263,8 @@ struct sxe2_repr_private_data {
 	uint16_t repr_pf_id;
 	uint16_t repr_vf_id;
 	uint16_t repr_vf_vsi_id;
-	uint16_t repr_vf_k_vsi_id;
-	uint16_t repr_vf_u_vsi_id;
+	uint16_t repr_vf_primary_vsi_id;
+	uint16_t repr_vf_backup_vsi_id;
 };
 
 struct sxe2_sched_hw_cap {
drivers/net/sxe2/sxe2_flow.c +2 -2
index 63cfc36968..cf54803301 100644
@@ -380,9 +380,9 @@ static int32_t sxe2_flow_src_split_proc(struct rte_eth_dev *dev,
 	if (adapter->switchdev_info.is_switchdev && adapter->is_dev_repr) {
 		flow_bond_num = 1;
 		flow_src_vsi[SXE2_MAX_DRV_TYPE_DPDK][0] =
-			adapter->repr_priv_data->repr_vf_u_vsi_id;
+			adapter->repr_priv_data->repr_vf_backup_vsi_id;
 		flow_src_vsi[SXE2_MAX_DRV_TYPE_KERNEL][0] =
-			adapter->repr_priv_data->repr_vf_k_vsi_id;
+			adapter->repr_priv_data->repr_vf_primary_vsi_id;
 	}
 
 	for (idx = 0; idx < flow_bond_num; idx++) {
drivers/net/sxe2/sxe2_switchdev.c +2 -2
index 44703cfb5c..efb1468b91 100644
@@ -312,9 +312,9 @@ int32_t sxe2_switchdev_repr_private_data_init(struct rte_eth_dev *dev,
 	repr_priv_data->repr_q_id = repr_id;
 	repr_priv_data->repr_pf_id = parent_adapter->pf_idx;
 	repr_priv_data->repr_vf_id = repr_id;
-	repr_priv_data->repr_vf_k_vsi_id =
+	repr_priv_data->repr_vf_primary_vsi_id =
 		parent_adapter->repr_ctxt.repr_vf_id[repr_id].kernel_vsi_id;
-	repr_priv_data->repr_vf_u_vsi_id =
+	repr_priv_data->repr_vf_backup_vsi_id =
 		parent_adapter->repr_ctxt.repr_vf_id[repr_id].dpdk_vsi_id;
 
 	repr_priv_data->repr_vf_vsi_id =
Signature · 1 line
2.52.0
#379 lore raw

PATCH v10 12/48 net/sxe2: clean up duplicate function declarations

In reply to [email protected]

From: Jie Liu <[email protected]>

Remove duplicate function declarations from the sxe2 driver headers:
- sxe2_drv_promisc_config, sxe2_drv_vsi_info_get and sxe2_drv_rxq_mapping_set in sxe2_cmd_chnl.h
- sxe2_dev_pci_seg_unmap in sxe2_ethdev.h
- sxe2_rx_pkts_scattered in sxe2_txrx_poll.h

---
 drivers/net/sxe2/sxe2_cmd_chnl.h  | 6 ------
 drivers/net/sxe2/sxe2_ethdev.h    | 2 --
 drivers/net/sxe2/sxe2_txrx_poll.h | 2 --
 3 files changed, 10 deletions(-)
drivers/net/sxe2/sxe2_cmd_chnl.h +0 -6
index d63caad526..294ac15db4 100644
@@ -65,8 +65,6 @@ int32_t sxe2_drv_ipsec_rxsa_delete(struct sxe2_adapter *adapter,
 int32_t sxe2_drv_ipsec_txsa_delete(struct sxe2_adapter *adapter,
 			       uint16_t sa_id);
 
-int32_t sxe2_drv_promisc_config(struct sxe2_adapter *adapter, bool set);
-
 int32_t sxe2_drv_udp_tunnel_add(struct sxe2_adapter *adapter,
 			    enum sxe2_udp_tunnel_protocol tunnel_proto,
 			    uint16_t udp_port);
@@ -84,8 +82,6 @@ int32_t sxe2_drv_get_udp_tunnel_port(struct sxe2_adapter *adapter,
 
 int32_t sxe2_drv_vsi_info_get(struct sxe2_adapter *adapter, struct sxe2_vsi *vsi);
 
-int32_t sxe2_drv_vsi_info_get(struct sxe2_adapter *adapter, struct sxe2_vsi *vsi);
-
 int32_t sxe2_drv_mac_link_status_get(struct sxe2_adapter *adapter);
 
 int32_t sxe2_drv_get_mac_stats(struct sxe2_adapter *adapter);
@@ -110,8 +106,6 @@ int32_t sxe2_drv_mapping_reset(struct rte_eth_dev *eth_dev);
 
 int32_t sxe2_drv_mapping_stats_info_clear(struct rte_eth_dev *eth_dev);
 
-int32_t sxe2_drv_rxq_mapping_set(struct rte_eth_dev *eth_dev, uint16_t queue_id, uint8_t pool_idx);
-
 int32_t sxe2_drv_allmulti_config(struct sxe2_adapter *adapter, bool set);
 
 int32_t sxe2_drv_uc_config(struct sxe2_adapter *adapter, struct rte_ether_addr *addr, bool add);
drivers/net/sxe2/sxe2_ethdev.h +0 -2
index 158198d74b..1409be74d3 100644
@@ -385,8 +385,6 @@ void sxe2_dev_pci_seg_unmap(struct sxe2_adapter *adapter, uint32_t res_type);
 
 int32_t sxe2_dev_pci_map_init(struct rte_eth_dev *dev);
 
-void sxe2_dev_pci_seg_unmap(struct sxe2_adapter *adapter, uint32_t res_type);
-
 int32_t sxe2_udp_tunnel_port_del_common(struct sxe2_adapter *ad,
 		enum sxe2_udp_tunnel_protocol tunnel_proto, uint16_t udp_port);
 
drivers/net/sxe2/sxe2_txrx_poll.h +0 -2
index 708e3839d7..bfa099c097 100644
@@ -13,8 +13,6 @@ uint16_t sxe2_tx_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t
 
 uint16_t sxe2_rx_pkts_scattered(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
 
-uint16_t sxe2_rx_pkts_scattered(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
-
 uint16_t sxe2_rx_pkts_scattered_split(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
 
 #endif /* SXE2_TXRX_POLL_H */
Signature · 1 line
2.52.0
#380 lore raw

PATCH v10 13/48 net/sxe2: fix null VSI dereference in device info

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_dev_infos_get() dereferences adapter->vsi_ctxt.main_vsi without checking for NULL, which can crash when the main VSI has not been created yet.

Add an early NULL check on vsi and return -EINVAL.

Fixes d8e4e075acb4 ("net/sxe2: add probing skeleton")
---
 drivers/net/sxe2/sxe2_ethdev.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/sxe2/sxe2_ethdev.c +4 -0
index 2e14c372f8..02f9ce3d32 100644
@@ -781,6 +781,10 @@ static int32_t sxe2_dev_infos_get(struct rte_eth_dev *dev,
 	struct sxe2_adapter *adapter = SXE2_DEV_PRIVATE_TO_ADAPTER(dev);
 	struct sxe2_vsi *vsi = adapter->vsi_ctxt.main_vsi;
 
+	if (unlikely(vsi == NULL)) {
+		PMD_LOG_ERR(INIT, "main vsi is NULL");
+		return -EINVAL;
+	}
 	dev_info->max_rx_queues = vsi->rxqs.q_cnt;
 	dev_info->max_tx_queues = vsi->txqs.q_cnt;
 	dev_info->min_rx_bufsize = SXE2_MIN_BUF_SIZE;
Signature · 1 line
2.52.0
#381 lore raw

PATCH v10 14/48 net/sxe2: fill MAC addresses in device info

In reply to [email protected]

From: Jie Liu <[email protected]>

Fill max_mac_addrs in sxe2_dev_infos_get() so applications can query the maximum number of MAC addresses supported by the device.

---
 drivers/net/sxe2/sxe2_ethdev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/sxe2/sxe2_ethdev.c +1 -0
index 02f9ce3d32..e85e34aa1a 100644
@@ -792,6 +792,7 @@ static int32_t sxe2_dev_infos_get(struct rte_eth_dev *dev,
 	dev_info->max_lro_pkt_size = SXE2_FRAME_SIZE_MAX * SXE2_RX_LRO_DESC_MAX_NUM;
 	dev_info->max_mtu = dev_info->max_rx_pktlen - SXE2_ETH_OVERHEAD;
 	dev_info->min_mtu = RTE_ETHER_MIN_MTU;
+	dev_info->max_mac_addrs = SXE2_NUM_MACADDR_MAX;
 
 	dev_info->rx_offload_capa =
 		RTE_ETH_RX_OFFLOAD_VLAN_STRIP |
Signature · 1 line
2.52.0
#382 lore raw

PATCH v10 15/48 net/sxe2: fix QinQ and RSS offload capability report

In reply to [email protected]

From: Jie Liu <[email protected]>

Make the QINQ offload capabilities conditional on the port VLAN
setting: only advertise RTE_ETH_TX_OFFLOAD_QINQ_INSERT, RTE_ETH_RX_OFFLOAD_QINQ_STRIP and RTE_ETH_RX_OFFLOAD_VLAN_FILTER when no port VLAN is configured. Report the buffer split supported header ptypes count in sxe2_buffer_split_supported_hdr_ptypes_get().

Fixes a2b79a93515e ("net/sxe2: support L2 filtering and MAC config")
---
 drivers/net/sxe2/sxe2_ethdev.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)
drivers/net/sxe2/sxe2_ethdev.c +13 -8
index e85e34aa1a..7a11a93dff 100644
@@ -804,15 +804,11 @@ static int32_t sxe2_dev_infos_get(struct rte_eth_dev *dev,
 		RTE_ETH_RX_OFFLOAD_SCTP_CKSUM |
 		RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM |
 		RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT |
-#ifndef RTE_LIBRTE_SXE2_16BYTE_RX_DESC
-		RTE_ETH_RX_OFFLOAD_QINQ_STRIP |
-#endif
 		RTE_ETH_RX_OFFLOAD_VLAN_EXTEND |
 		RTE_ETH_RX_OFFLOAD_TCP_LRO;
 
 	dev_info->tx_offload_capa =
 		RTE_ETH_TX_OFFLOAD_VLAN_INSERT |
-		RTE_ETH_TX_OFFLOAD_QINQ_INSERT |
 		RTE_ETH_TX_OFFLOAD_MULTI_SEGS |
 		RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE |
 		RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
@@ -855,14 +851,22 @@ static int32_t sxe2_dev_infos_get(struct rte_eth_dev *dev,
 		RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO;
 
 
-	if (adapter->cap_flags & SXE2_DEV_CAPS_OFFLOAD_PTP)
-		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_TIMESTAMP;
-
 	if (sxe2_ipsec_supported(adapter)) {
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_SECURITY;
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_SECURITY;
 	}
 
+	if (adapter->cap_flags & SXE2_DEV_CAPS_OFFLOAD_PTP)
+		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_TIMESTAMP;
+
+	if (!sxe2_dev_port_vlan_check(dev)) {
+		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_QINQ_INSERT;
+#ifndef RTE_LIBRTE_SXE2_16BYTE_RX_DESC
+		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_QINQ_STRIP;
+#endif
+		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_VLAN_FILTER;
+	}
+
 	if (adapter->cap_flags & SXE2_DEV_CAPS_OFFLOAD_RSS) {
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
 		dev_info->flow_type_rss_offloads  |= SXE2_RSS_HF_SUPPORT_ALL;
@@ -934,7 +938,7 @@ static int32_t sxe2_dev_infos_get(struct rte_eth_dev *dev,
 
 static const uint32_t *
 sxe2_buffer_split_supported_hdr_ptypes_get(struct rte_eth_dev *dev __rte_unused,
-					   size_t *no_of_elements __rte_unused)
+					   size_t *no_of_elements)
 {
 	static const uint32_t ptypes[] = {
 		RTE_PTYPE_L2_ETHER,
@@ -972,6 +976,7 @@ sxe2_buffer_split_supported_hdr_ptypes_get(struct rte_eth_dev *dev __rte_unused,
 
 		RTE_PTYPE_UNKNOWN
 	};
+	*no_of_elements = RTE_DIM(ptypes) - 1;
 
 	return ptypes;
 }
Signature · 1 line
2.52.0
#383 lore raw

PATCH v10 16/48 net/sxe2: use regular write for mapped registers

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_pci_map_write_reg() uses the write-combined store (SXE2_PCI_REG_WRITE_WC) to write control registers, which is intended for doorbell/tail writes and can be lossy or delayed for ordering sensitive register updates.

Add SXE2_PCI_REG_WRITE macro using a regular rte_write32() and use it in sxe2_pci_map_write_reg().

Fixes 8cebf80f1eda ("net/sxe2: support Rx interrupt")
---
 drivers/net/sxe2/sxe2_ethdev.c | 2 +-
 drivers/net/sxe2/sxe2_ethdev.h | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/net/sxe2/sxe2_ethdev.c +1 -1
index 7a11a93dff..589f09c113 100644
@@ -1439,7 +1439,7 @@ void sxe2_pci_map_write_reg(struct sxe2_adapter *adapter,
 		goto l_ret;
 	}
 
-	SXE2_PCI_REG_WRITE_WC(reg_addr, value);
+	SXE2_PCI_REG_WRITE(reg_addr, value);
 l_ret:
 	return;
 }
drivers/net/sxe2/sxe2_ethdev.h +2 -0
index 1409be74d3..cf1104144c 100644
@@ -355,6 +355,8 @@ struct sxe2_adapter {
 #define SXE2_DEV_PRIVATE_TO_ADAPTER(dev) \
 	((struct sxe2_adapter *)(dev)->data->dev_private)
 
+#define SXE2_PCI_REG_WRITE(reg, value) rte_write32((rte_cpu_to_le_32(value)), (reg))
+
 void *sxe2_pci_map_addr_get(struct sxe2_adapter *adapter,
 			    enum sxe2_pci_map_resource res_type,
 			    uint16_t idx_in_func);
Signature · 1 line
2.52.0
#384 lore raw

PATCH v10 17/48 net/sxe2: move PCI register read macro to common header

In reply to [email protected]

From: Jie Liu <[email protected]>

Move SXE2_PCI_REG_READ to sxe2_ethdev.h so the PCI register access macros are kept together in the common header, matching SXE2_PCI_REG_WRITE.

---
 drivers/net/sxe2/sxe2_ethdev.h | 1 +
 drivers/net/sxe2/sxe2_queue.h  | 2 --
 2 files changed, 1 insertion(+), 2 deletions(-)
drivers/net/sxe2/sxe2_ethdev.h +1 -0
index cf1104144c..f2557b28c3 100644
@@ -356,6 +356,7 @@ struct sxe2_adapter {
 	((struct sxe2_adapter *)(dev)->data->dev_private)
 
 #define SXE2_PCI_REG_WRITE(reg, value) rte_write32((rte_cpu_to_le_32(value)), (reg))
+#define SXE2_PCI_REG_READ(reg)         rte_read32(reg)
 
 void *sxe2_pci_map_addr_get(struct sxe2_adapter *adapter,
 			    enum sxe2_pci_map_resource res_type,
drivers/net/sxe2/sxe2_queue.h +0 -2
index a300b66771..10bdaf5b8d 100644
@@ -12,8 +12,6 @@
 #include "sxe2_drv_cmd.h"
 #include "sxe2_txrx_common.h"
 
-#define SXE2_PCI_REG_READ(reg)			\
-		rte_read32(reg)
 #define SXE2_PCI_REG_WRITE_WC(reg, value)			\
 		rte_write32_wc((rte_cpu_to_le_32(value)), reg)
 #define SXE2_PCI_REG_WRITE_WC_RELAXED(reg, value)		\
Signature · 1 line
2.52.0
#385 lore raw

PATCH v10 18/48 net/sxe2: validate PCI map resource type

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_dev_pci_res_seg_map() indexes adapter->map_ctxt.addr_info[] with res_type without bounds checking, which can access out of bounds when an invalid resource type is passed.

Add a bounds check on res_type and return -EINVAL.

Fixes 66a10eb60ebe ("net/sxe2: add PCI BAR mapping")
---
 drivers/net/sxe2/sxe2_ethdev.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/sxe2/sxe2_ethdev.c +6 -0
index 589f09c113..9ef93b8076 100644
@@ -1552,6 +1552,12 @@ int32_t sxe2_dev_pci_res_seg_map(struct sxe2_adapter *adapter,
 	struct sxe2_pci_map_addr_info *addr_info = NULL;
 	int32_t ret = 0;
 
+	if (unlikely(res_type >= SXE2_PCI_MAP_RES_MAX_COUNT)) {
+		PMD_DEV_LOG_ERR(adapter, INIT, "Invalid resource type %u", res_type);
+		ret = -EINVAL;
+		goto l_end;
+	}
+
 	addr_info = &adapter->map_ctxt.addr_info[res_type];
 	if (!addr_info || addr_info->bar_idx == SXE2_PCI_MAP_BAR_INVALID) {
 		PMD_DEV_LOG_ERR(adapter, INIT, "Invalid bar index with resource type %d", res_type);
Signature · 1 line
2.52.0
#386 lore raw

PATCH v10 19/48 net/sxe2: guard PCI BAR unmap when not initialized

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_dev_pci_map_uinit() calls sxe2_dev_pci_seg_unmap() and walks bar_info unconditionally. Only perform the unmap and free when bar_info has been allocated, so an uninitialized map context is handled cleanly.

Fixes 66a10eb60ebe ("net/sxe2: add PCI BAR mapping")
---
 drivers/net/sxe2/sxe2_ethdev.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/net/sxe2/sxe2_ethdev.c +6 -8
index 9ef93b8076..fdff4ae10f 100644
@@ -1773,14 +1773,13 @@ void sxe2_dev_pci_map_uinit(struct rte_eth_dev *dev)
 	uint8_t i = 0;
 
 	PMD_INIT_FUNC_TRACE();
+	if (map_ctxt->bar_info != NULL) {
+		(void)sxe2_dev_pci_seg_unmap(adapter, SXE2_PCI_MAP_RES_DOORBELL_RX_TAIL);
+		(void)sxe2_dev_pci_seg_unmap(adapter, SXE2_PCI_MAP_RES_DOORBELL_TX);
+		(void)sxe2_dev_pci_seg_unmap(adapter, SXE2_PCI_MAP_RES_IRQ_DYN);
+		(void)sxe2_dev_pci_seg_unmap(adapter, SXE2_PCI_MAP_RES_IRQ_ITR);
+		(void)sxe2_dev_pci_seg_unmap(adapter, SXE2_PCI_MAP_RES_IRQ_MSIX);
 
-	(void)sxe2_dev_pci_seg_unmap(adapter, SXE2_PCI_MAP_RES_DOORBELL_RX_TAIL);
-	(void)sxe2_dev_pci_seg_unmap(adapter, SXE2_PCI_MAP_RES_DOORBELL_TX);
-	(void)sxe2_dev_pci_seg_unmap(adapter, SXE2_PCI_MAP_RES_IRQ_DYN);
-	(void)sxe2_dev_pci_seg_unmap(adapter, SXE2_PCI_MAP_RES_IRQ_ITR);
-	(void)sxe2_dev_pci_seg_unmap(adapter, SXE2_PCI_MAP_RES_IRQ_MSIX);
-
-	if (map_ctxt != NULL && map_ctxt->bar_info != NULL) {
 		for (i = 0; i < map_ctxt->bar_cnt; i++) {
 			bar_info = &map_ctxt->bar_info[i];
 			if (bar_info != NULL && bar_info->seg_info != NULL) {
@@ -1791,7 +1790,6 @@ void sxe2_dev_pci_map_uinit(struct rte_eth_dev *dev)
 		rte_free(map_ctxt->bar_info);
 		map_ctxt->bar_info = NULL;
 	}
-
 	adapter->dev_info.dev_data = NULL;
 }
 
Signature · 1 line
2.52.0
#387 lore raw

PATCH v10 20/48 net/sxe2: fix duplicated cleanup in dev close

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_dev_close() calls sxe2_switchdev_uninit() and sxe2_dev_pci_map_uinit() twice, and releases resources in an order that does not match the initialization sequence.

Remove the duplicated calls and align the teardown order with the device init order.

Fixes 8cebf80f1eda ("net/sxe2: support Rx interrupt")
---
 drivers/net/sxe2/sxe2_ethdev.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/sxe2/sxe2_ethdev.c +2 -4
index fdff4ae10f..fab7dcf44c 100644
@@ -2041,17 +2041,15 @@ static int32_t sxe2_dev_close(struct rte_eth_dev *dev)
 	(void)sxe2_queues_release(dev);
 	sxe2_mp_uninit(dev);
 	(void)sxe2_sched_uinit(dev);
-	(void)sxe2_rss_disable(dev);
 	(void)sxe2_flow_uninit(dev);
+	(void)sxe2_rss_disable(dev);
 	(void)sxe2_udp_tunnel_port_clear(dev);
-	sxe2_vsi_uninit(dev);
 	sxe2_security_uinit(dev);
 	sxe2_intr_uninit(dev);
 	(void)sxe2_switchdev_uninit(dev);
 	sxe2_sw_uninit(dev);
-	(void)sxe2_switchdev_uninit(dev);
-	sxe2_dev_pci_map_uinit(dev);
 	sxe2_eth_uinit(dev);
+	sxe2_vsi_uninit(dev);
 	sxe2_dev_pci_map_uinit(dev);
 	sxe2_free_repr_info(dev);
 	sxe2_fc_state_uinit(dev);
Signature · 1 line
2.52.0
#388 lore raw

PATCH v10 21/48 net/sxe2: align dev init and cleanup order

In reply to [email protected]

From: Jie Liu <[email protected]>

Move sxe2_eth_init() to be called before sxe2_sw_init() and rearrange the error cleanup labels so that resources are torn down in the reverse order of initialization.

---
 drivers/net/sxe2/sxe2_ethdev.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/net/sxe2/sxe2_ethdev.c +8 -8
index fab7dcf44c..a4ce601349 100644
@@ -1942,6 +1942,12 @@ static int32_t sxe2_dev_init(struct rte_eth_dev *dev,
 		goto init_switchdev_err;
 	}
 
+	ret = sxe2_eth_init(dev);
+	if (ret) {
+		PMD_LOG_ERR(INIT, "Failed to initialize eth parameters, ret=%d", ret);
+		goto init_eth_err;
+	}
+
 	ret = sxe2_sw_init(dev);
 	if (ret) {
 		PMD_LOG_ERR(INIT, "Failed to initialize sw parameters, ret=[%d]", ret);
@@ -1954,12 +1960,6 @@ static int32_t sxe2_dev_init(struct rte_eth_dev *dev,
 		goto init_irq_err;
 	}
 
-	ret = sxe2_eth_init(dev);
-	if (ret) {
-		PMD_LOG_ERR(INIT, "Failed to initialize eth parameters, ret=%d", ret);
-		goto init_eth_err;
-	}
-
 	ret = sxe2_security_init(dev);
 	if (ret) {
 		PMD_LOG_ERR(INIT, "Failed to initialize security, ret=%d", ret);
@@ -2014,12 +2014,12 @@ static int32_t sxe2_dev_init(struct rte_eth_dev *dev,
 init_rss_err:
 	sxe2_security_uinit(dev);
 init_security_err:
-	sxe2_eth_uinit(dev);
-init_eth_err:
 	sxe2_intr_uninit(dev);
 init_irq_err:
 	sxe2_sw_uninit(dev);
 init_sw_err:
+	sxe2_eth_uinit(dev);
+init_eth_err:
 	(void)sxe2_switchdev_uninit(dev);
 init_switchdev_err:
 init_dev_info_err:
Signature · 1 line
2.52.0
#389 lore raw

PATCH v10 22/48 net/sxe2: simplify switchdev representor matching

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_switchdev_repr_match() encodes the kernel representor ID and compares it against each requested port, which is fragile. Match the PF number and VF ID directly against the switchdev representor info instead, and drop the sxe2_switchdev_repr_id_encode_get() helper.

Fixes 635084db5d57 ("net/sxe2: support VF representors")
---
 drivers/net/sxe2/sxe2_ethdev.c | 72 +++++++++++++++++-----------------
 drivers/net/sxe2/sxe2_ethdev.h |  3 --
 2 files changed, 37 insertions(+), 38 deletions(-)
drivers/net/sxe2/sxe2_ethdev.c +37 -35
index a4ce601349..c5f6bc8af4 100644
@@ -2147,42 +2147,25 @@ static int32_t sxe2_fw_version_string_get(struct rte_eth_dev *dev, char *fw_vers
 	return ret;
 }
 
-static uint16_t sxe2_switchdev_repr_id_encode_get(struct sxe2_switchdev_info *switchdev_info)
-{
-	enum rte_eth_representor_type type;
-	uint16_t repr = switchdev_info->vf_num;
-	uint32_t pf = switchdev_info->pf_num;
-
-	switch (switchdev_info->port_name_type) {
-	case SXE2_PHYS_PORT_NAME_TYPE_UPLINK:
-		if (!switchdev_info->representor)
-			return UINT16_MAX;
-		type = RTE_ETH_REPRESENTOR_PF;
-		pf = switchdev_info->mpesw_owner;
-		break;
-	case SXE2_PHYS_PORT_NAME_TYPE_PFVF:
-	default:
-		type = RTE_ETH_REPRESENTOR_VF;
-		break;
-	}
-
-	return SXE2_REPRESENTOR_ID(pf, type, repr);
-}
-
 static bool sxe2_switchdev_repr_match(struct sxe2_adapter *adapter,
 				   struct rte_eth_devargs *req_eth_da)
 {
-	uint32_t port_idx = 0;
-	uint32_t repr_idx;
-	uint16_t kernel_repr_id = sxe2_switchdev_repr_id_encode_get(&adapter->switchdev_info);
-	uint16_t repr_id;
+	uint16_t port_idx;
+	uint16_t repr_idx;
+	uint16_t vf_id;
+	uint16_t i;
 
 	switch (req_eth_da->type) {
 	case RTE_ETH_REPRESENTOR_PF:
+		if (adapter->switchdev_info.port_name_type !=
+			SXE2_PHYS_PORT_NAME_TYPE_UPLINK) {
+			rte_errno = EBUSY;
+			return false;
+		}
 		break;
 	case RTE_ETH_REPRESENTOR_VF:
 		if (adapter->switchdev_info.port_name_type !=
-		SXE2_PHYS_PORT_NAME_TYPE_PFVF) {
+			SXE2_PHYS_PORT_NAME_TYPE_PFVF) {
 			rte_errno = EBUSY;
 			return false;
 		}
@@ -2195,15 +2178,34 @@ static bool sxe2_switchdev_repr_match(struct sxe2_adapter *adapter,
 		return false;
 	}
 
+	if (req_eth_da->nb_ports > 0) {
+		for (port_idx = 0; port_idx < req_eth_da->nb_ports; ++port_idx) {
+			if (adapter->switchdev_info.pf_num == req_eth_da->ports[port_idx])
+				break;
+		}
+		if (port_idx == req_eth_da->nb_ports) {
+			PMD_DEV_LOG_DEBUG(adapter, DRV, "switchdev pf %u not match req pf",
+				adapter->switchdev_info.pf_num);
+			rte_errno = EBUSY;
+			return false;
+		}
+	}
+
 	for (repr_idx = 0; repr_idx < req_eth_da->nb_representor_ports; ++repr_idx) {
-		repr_id = SXE2_REPRESENTOR_ID(req_eth_da->ports[port_idx],
-					      req_eth_da->type,
-					      req_eth_da->representor_ports[repr_idx]);
-		if (repr_id == kernel_repr_id)
-			return true;
-	}
-	rte_errno = EBUSY;
-	return false;
+		for (i = 0; i < adapter->repr_ctxt.nb_vf; ++i) {
+			vf_id = rte_le_to_cpu_16(adapter->repr_ctxt.repr_vf_id[i].func_id);
+			if (vf_id == req_eth_da->representor_ports[repr_idx])
+				break;
+		}
+		if (i == adapter->repr_ctxt.nb_vf) {
+			PMD_DEV_LOG_DEBUG(adapter, DRV, "switchdev vf %u not match req vf(cnt:%u)",
+				req_eth_da->representor_ports[repr_idx], adapter->repr_ctxt.nb_vf);
+			rte_errno = EBUSY;
+			return false;
+		}
+	}
+
+	return true;
 }
 
 static int32_t sxe2_eth_pmd_probe_pf(struct sxe2_common_device *cdev,
drivers/net/sxe2/sxe2_ethdev.h +0 -3
index f2557b28c3..e818578319 100644
@@ -65,9 +65,6 @@ enum sxe2_fnav_tunnel_flag_type {
 #define upper_32_bits(n) ((uint32_t)(((n) >> 16) >> 16))
 #define lower_32_bits(n) ((uint32_t)((n) & 0xffffffff))
 
-#define SXE2_REPRESENTOR_ID(pf, type, repr) \
-		(((pf) << 14) + ((type) << 12) + ((repr) & 0xfff))
-
 #define SXE2_I2C_EEPROM_DEV_ADDR	0xA0
 #define SXE2_I2C_EEPROM_DEV_ADDR2	0xA2
 #define SXE2_MODULE_TYPE_SFP		0x03
Signature · 1 line
2.52.0
#390 lore raw

PATCH v10 23/48 net/sxe2: rename fnav cid manager symbols to flow

In reply to [email protected]

From: Jie Liu <[email protected]>

Rename the sxe2_fnav_cid_mgr, sxe2_fnav_cid_mgr_list_t, sxe2_fnav_count_resource and sxe2_fnav_get_filter_cid symbols to the sxe2_flow_* prefix for consistency with the flow module naming.

---
 drivers/net/sxe2/sxe2_cmd_chnl.c    |  2 +-
 drivers/net/sxe2/sxe2_cmd_chnl.h    |  2 +-
 drivers/net/sxe2/sxe2_flow.c        | 46 ++++++++++++++---------------
 drivers/net/sxe2/sxe2_flow.h        |  6 ++--
 drivers/net/sxe2/sxe2_flow_define.h | 12 ++++----
 5 files changed, 34 insertions(+), 34 deletions(-)
drivers/net/sxe2/sxe2_cmd_chnl.c +1 -1
index b09989fe50..3229c72597 100644
@@ -1800,7 +1800,7 @@ int32_t sxe2_drv_flow_fnav_free_stat(struct sxe2_adapter *adapter, uint32_t stat
 }
 
 int32_t sxe2_drv_flow_fnav_query_stat(struct sxe2_adapter *adapter,
-		struct sxe2_fnav_cid_mgr *mgr)
+		struct sxe2_flow_cid_mgr *mgr)
 {
 	struct sxe2_drv_flow_fnav_query_stat_req req = { 0 };
 	struct sxe2_drv_flow_fnav_query_stat_resp resp = { 0 };
drivers/net/sxe2/sxe2_cmd_chnl.h +1 -1
index 294ac15db4..cfea1a1f0e 100644
@@ -159,7 +159,7 @@ int32_t sxe2_drv_flow_fnav_get_stat_id(struct sxe2_adapter *adapter, uint32_t *s
 int32_t sxe2_drv_flow_fnav_free_stat(struct sxe2_adapter *adapter, uint32_t stat_id);
 
 int32_t sxe2_drv_flow_fnav_query_stat(struct sxe2_adapter *adapter,
-		struct sxe2_fnav_cid_mgr *mgr);
+		struct sxe2_flow_cid_mgr *mgr);
 
 int32_t sxe2_drv_srcvsi_prune_config(struct sxe2_adapter *adapter,
 		uint16_t *vsi_list, uint16_t vsi_cnt, bool set);
drivers/net/sxe2/sxe2_flow.c +23 -23

111 lines not on this page · raw message

drivers/net/sxe2/sxe2_flow.h +3 -3
index daaeedd4dc..8d47b11ff4 100644
@@ -14,16 +14,16 @@ int32_t sxe2_flow_init(struct rte_eth_dev *dev);
 
 int32_t sxe2_flow_uninit(struct rte_eth_dev *dev);
 
-int32_t sxe2_fnav_get_filter_cid(struct sxe2_adapter *adapter, struct sxe2_flow *flow);
+int32_t sxe2_flow_get_filter_cid(struct sxe2_adapter *adapter, struct sxe2_flow *flow);
 
 int32_t sxe2_flow_free_mgr(struct sxe2_adapter *adapter,
 		       struct sxe2_flow *flow,
-		       struct sxe2_fnav_cid_mgr **mgr_ptr,
+		       struct sxe2_flow_cid_mgr **mgr_ptr,
 		       struct rte_flow_error *error);
 
 int32_t sxe2_flow_query_mgr(struct sxe2_adapter *adapter,
 			struct sxe2_flow *flow,
-			struct sxe2_fnav_cid_mgr **mgr_ptr,
+			struct sxe2_flow_cid_mgr **mgr_ptr,
 			struct rte_flow_error *error);
 
 int32_t sxe2_flow_init_udp_tunnel_port(struct rte_eth_dev *dev);
drivers/net/sxe2/sxe2_flow_define.h +6 -6
index 263a573f04..8a5d871978 100644
@@ -98,8 +98,8 @@ struct rte_flow {
 };
 TAILQ_HEAD(rte_flow_list_t, rte_flow);
 
-struct sxe2_fnav_cid_mgr {
-	TAILQ_ENTRY(sxe2_fnav_cid_mgr) next;
+struct sxe2_flow_cid_mgr {
+	TAILQ_ENTRY(sxe2_flow_cid_mgr) next;
 	uint16_t stat_index;
 	uint32_t user_id;
 	uint32_t driver_id;
@@ -107,18 +107,18 @@ struct sxe2_fnav_cid_mgr {
 	uint64_t hits;
 	uint64_t bytes;
 };
-TAILQ_HEAD(sxe2_fnav_cid_mgr_list_t, sxe2_fnav_cid_mgr);
+TAILQ_HEAD(sxe2_flow_cid_mgr_list_t, sxe2_flow_cid_mgr);
 
-struct sxe2_fnav_count_resource {
+struct sxe2_flow_count_resource {
 	uint32_t count_type;
 	uint32_t global_index;
-	struct sxe2_fnav_cid_mgr_list_t fnav_cid_mgr_list;
+	struct sxe2_flow_cid_mgr_list_t flow_cid_mgr_list;
 };
 
 struct sxe2_flow_context {
 	struct rte_flow_list_t rte_flow_list;
 	rte_spinlock_t flow_list_lock;
-	struct sxe2_fnav_count_resource hw_res;
+	struct sxe2_flow_count_resource hw_res;
 	uint16_t tunnel_port_list[SXE2_FLOW_UDP_TUNNEL_MAX];
 	uint32_t fnav_inited;
 };
Signature · 1 line
2.52.0
#391 lore raw

PATCH v10 24/48 net/sxe2: move tunnel port helpers into flow module

In reply to [email protected]

From: Jie Liu <[email protected]>

Move sxe2_flow_parse_pattern_ipip, sxe2_flow_add_udp_tunnel_port and sxe2_flow_add_tunnel_port from sxe2_flow_parse_pattern.c into sxe2_flow.c as static helpers, and drop the public declaration of sxe2_flow_add_tunnel_port from the header, keeping the tunnel port handling internal to the flow module.

---
 drivers/net/sxe2/sxe2_flow.c               | 113 +++++++++++++++++++++
 drivers/net/sxe2/sxe2_flow_parse_pattern.c | 113 ---------------------
 drivers/net/sxe2/sxe2_flow_parse_pattern.h |   6 --
 3 files changed, 113 insertions(+), 119 deletions(-)
drivers/net/sxe2/sxe2_flow.c +113 -0
index a33b8606df..cd39385340 100644
@@ -550,6 +550,119 @@ int32_t sxe2_flow_init_udp_tunnel_port(struct rte_eth_dev *dev)
 	return ret;
 }
 
+static int32_t sxe2_flow_add_udp_tunnel_port(struct sxe2_adapter *adapter,
+					 enum sxe2_flow_udp_tunnel_protocol proto,
+					 struct sxe2_flow *flow,
+					 BITMAP_TYPE *flow_type)
+{
+	int32_t ret = 0;
+	uint16_t tun_port;
+
+	tun_port = adapter->flow_ctxt.tunnel_port_list[proto];
+	if (tun_port == 0xffff || tun_port == 0) {
+		ret = -EINVAL;
+		PMD_LOG_ERR(DRV, "UDP tunnel port not initialized, proto: %d", proto);
+		goto l_end;
+	}
+	if (!sxe2_test_bit(SXE2_EXPANSION_OUTER_UDP, flow_type)) {
+		ret = -EINVAL;
+		PMD_LOG_ERR(DRV, "UDP must be over tunnel");
+		goto l_end;
+	}
+	sxe2_set_bit(SXE2_FLOW_FLD_ID_UDP_DST_PORT, flow->pattern_outer.map_spec);
+	flow->pattern_outer.item_spec.udp.dest = rte_cpu_to_be_16(tun_port);
+l_end:
+	return ret;
+}
+
+static int32_t sxe2_flow_parse_pattern_ipip(struct sxe2_flow *flow, BITMAP_TYPE *flow_type)
+{
+	sxe2_set_bit(SXE2_EXPANSION_IPIP, flow_type);
+	if (sxe2_test_bit(SXE2_EXPANSION_OUTER_IPV4, flow_type)) {
+		sxe2_set_bit(SXE2_FLOW_FLD_ID_IPV4_PROT, flow->pattern_outer.map_spec);
+		if (sxe2_test_bit(SXE2_EXPANSION_IPV4, flow_type))
+			flow->pattern_outer.item_spec.ipv4.protocol = SXE2_FLOW_IP_PROTOCOL_IPV4;
+		if (sxe2_test_bit(SXE2_EXPANSION_IPV6, flow_type))
+			flow->pattern_outer.item_spec.ipv4.protocol = SXE2_FLOW_IP_PROTOCOL_IPV6;
+	}
+	if (sxe2_test_bit(SXE2_EXPANSION_OUTER_IPV6, flow_type)) {
+		sxe2_set_bit(SXE2_FLOW_FLD_ID_IPV6_PROT, flow->pattern_outer.map_spec);
+		if (sxe2_test_bit(SXE2_EXPANSION_ETH, flow_type)) {
+			flow->pattern_outer.item_spec.ipv6.nexthdr = SXE2_FLOW_IP_PROTOCOL_ETH;
+		} else {
+			if (sxe2_test_bit(SXE2_EXPANSION_IPV4, flow_type))
+				flow->pattern_outer.item_spec.ipv6.nexthdr =
+					SXE2_FLOW_IP_PROTOCOL_IPV4;
+			if (sxe2_test_bit(SXE2_EXPANSION_IPV6, flow_type))
+				flow->pattern_outer.item_spec.ipv6.nexthdr =
+					SXE2_FLOW_IP_PROTOCOL_IPV6;
+		}
+	}
+	return 0;
+}
+
+static int32_t sxe2_flow_add_tunnel_port(struct rte_eth_dev *dev,
+			struct rte_flow_error *error,
+			struct sxe2_flow *flow, BITMAP_TYPE *flow_type,
+			enum sxe2_flow_tunnel_type tunnel_type)
+{
+	int32_t ret = 0;
+	enum sxe2_flow_udp_tunnel_protocol proto = SXE2_FLOW_UDP_TUNNEL_MAX;
+	struct sxe2_adapter *adapter = SXE2_DEV_PRIVATE_TO_ADAPTER(dev);
+	struct sxe2_flow_pattern *pattern = &flow->pattern_outer;
+	switch (tunnel_type) {
+	case SXE2_FLOW_TUNNEL_TYPE_VXLAN:
+		if (sxe2_test_bit(SXE2_EXPANSION_ETH, flow_type)) {
+			proto = SXE2_FLOW_UDP_TUNNEL_PROTOCOL_VXLAN;
+		} else if (sxe2_test_bit(SXE2_EXPANSION_IPV4, flow_type) ||
+			sxe2_test_bit(SXE2_EXPANSION_IPV6, flow_type)) {
+			proto = SXE2_FLOW_UDP_TUNNEL_PROTOCOL_VXLAN_GPE;
+		}
+		break;
+	case SXE2_FLOW_TUNNEL_TYPE_GTPU:
+		proto = SXE2_FLOW_UDP_TUNNEL_PROTOCOL_GTP_U;
+		break;
+	case SXE2_FLOW_TUNNEL_TYPE_GENEVE:
+		proto = SXE2_FLOW_UDP_TUNNEL_PROTOCOL_GENEVE;
+		break;
+	case SXE2_FLOW_TUNNEL_TYPE_GRE:
+		if (sxe2_test_bit(SXE2_EXPANSION_OUTER_UDP, flow_type)) {
+			proto = SXE2_FLOW_UDP_TUNNEL_PROTOCOL_NVGRE;
+		} else {
+			if (sxe2_test_bit(SXE2_EXPANSION_OUTER_IPV4, flow_type)) {
+				pattern->item_spec.ipv4.protocol = SXE2_FLOW_IP_PROTOCOL_GRE;
+				sxe2_set_bit(SXE2_FLOW_FLD_ID_IPV4_PROT, pattern->map_spec);
+			}
+			if (sxe2_test_bit(SXE2_EXPANSION_OUTER_IPV6, flow_type)) {
+				pattern->item_spec.ipv6.nexthdr = SXE2_FLOW_IP_PROTOCOL_GRE;
+				sxe2_set_bit(SXE2_FLOW_FLD_ID_IPV6_PROT, pattern->map_spec);
+			}
+		}
+		break;
+	case SXE2_FLOW_TUNNEL_TYPE_IPIP:
+		ret = sxe2_flow_parse_pattern_ipip(flow, flow_type);
+		break;
+	default:
+		break;
+	}
+	if (proto != SXE2_FLOW_UDP_TUNNEL_MAX) {
+		ret = sxe2_flow_add_udp_tunnel_port(adapter, proto, flow, flow_type);
+		if (ret != 0) {
+			rte_flow_error_set(error, EINVAL,
+					RTE_FLOW_ERROR_TYPE_ITEM,
+					NULL, "Failed to add udp port for tunnel.");
+			PMD_LOG_ERR(DRV, "Failed to add udp port for tunnel, ret %d.", ret);
+			goto l_end;
+		}
+	}
+	if (tunnel_type != SXE2_FLOW_TUNNEL_TYPE_NONE) {
+		if (!sxe2_test_bit(SXE2_EXPANSION_OUTER_UDP, flow_type))
+			sxe2_set_bit(SXE2_FLOW_HDR_IPV_OTHER, pattern->hdrs);
+	}
+l_end:
+	return ret;
+}
+
 static int32_t sxe2_flowlist_add_tunnel_port(struct rte_eth_dev *dev,
 			struct rte_flow *flow_list,
 			struct rte_flow_error *error)
drivers/net/sxe2/sxe2_flow_parse_pattern.c +0 -113

119 lines not on this page · raw message

drivers/net/sxe2/sxe2_flow_parse_pattern.h +0 -6
index 8442c35cae..69d83a6ea6 100644
@@ -37,10 +37,4 @@ int32_t sxe2_flow_parse_pattern(struct rte_eth_dev *dev,
 			    struct rte_flow_error *error,
 			    struct sxe2_flow *flow);
 
-int32_t sxe2_flow_add_tunnel_port(struct rte_eth_dev *dev,
-			      struct rte_flow_error *error,
-			      struct sxe2_flow *flow,
-			      BITMAP_TYPE *flow_type,
-			      enum sxe2_flow_tunnel_type tunnel_type);
-
 #endif /* SXE2_FLOW_PARSE_PATTERN_H_ */
Signature · 1 line
2.52.0
#392 lore raw

PATCH v10 25/48 net/sxe2: add ACL engine event statistics support

In reply to [email protected]

From: Jie Liu <[email protected]>

Add statistics support for the ACL flow engine to track packet hits and bytes, enabling flow aging and traffic monitoring for ACL rules.

- Add acl-stat-type devarg to configure the statistics type
- Implement sxe2_drv_flow_acl_get_stat_id/free_stat/query_stat
- Handle the ACL engine in flow create/destroy/query paths
- Add fnav_hw_res and acl_hw_res count resources

---
 doc/guides/nics/sxe2.rst                  | 11 +++
 drivers/net/sxe2/sxe2_cmd_chnl.c          | 71 ++++++++++++++++++
 drivers/net/sxe2/sxe2_cmd_chnl.h          |  7 ++
 drivers/net/sxe2/sxe2_drv_cmd.h           |  7 ++
 drivers/net/sxe2/sxe2_dump.c              |  2 +
 drivers/net/sxe2/sxe2_ethdev.c            | 23 ++++--
 drivers/net/sxe2/sxe2_ethdev.h            |  1 +
 drivers/net/sxe2/sxe2_flow.c              | 90 ++++++++++++++++++-----
 drivers/net/sxe2/sxe2_flow_define.h       |  5 +-
 drivers/net/sxe2/sxe2_flow_parse_action.c | 28 ++++---
 10 files changed, 209 insertions(+), 36 deletions(-)
doc/guides/nics/sxe2.rst +11 -0
index 8278a5f108..c5b400a8ba 100644
@@ -98,6 +98,17 @@ Runtime Configuration
 
   Default value is 3 (count both packets and bytes).
 
+- ``acl-stat-type`` parameter [int]
+
+  This parameter controls the ACL flow engine statistics type
+  used for flow rule hit counting (via ``rte_flow_query``).
+
+  - 1: Only count the number of packets.
+  - 2: Only count the number of bytes.
+  - 3: Count both packets and bytes (default).
+
+  Default value is 3 (count both packets and bytes).
+
 - ``drv-sw-stats`` parameter [int]
 
   This parameter controls whether per-packet software statistics (SW stats)
drivers/net/sxe2/sxe2_cmd_chnl.c +71 -0

77 lines not on this page · raw message

drivers/net/sxe2/sxe2_cmd_chnl.h +7 -0
index cfea1a1f0e..7d07068bfc 100644
@@ -161,6 +161,13 @@ int32_t sxe2_drv_flow_fnav_free_stat(struct sxe2_adapter *adapter, uint32_t stat
 int32_t sxe2_drv_flow_fnav_query_stat(struct sxe2_adapter *adapter,
 		struct sxe2_flow_cid_mgr *mgr);
 
+int32_t sxe2_drv_flow_acl_get_stat_id(struct sxe2_adapter *adapter, uint32_t *stat_id);
+
+int32_t sxe2_drv_flow_acl_free_stat(struct sxe2_adapter *adapter, uint32_t stat_id);
+
+int32_t sxe2_drv_flow_acl_query_stat(struct sxe2_adapter *adapter,
+			struct sxe2_flow_cid_mgr *mgr);
+
 int32_t sxe2_drv_srcvsi_prune_config(struct sxe2_adapter *adapter,
 		uint16_t *vsi_list, uint16_t vsi_cnt, bool set);
 
drivers/net/sxe2/sxe2_drv_cmd.h +7 -0
index 03ef3b315d..01fd813ed1 100644
@@ -824,6 +824,13 @@ enum sxe2_drv_cmd_code {
 	SXE2_DRV_CMD_OPT_EEP_GET =
 		SXE2_MK_DRV_CMD(SXE2_DRV_CMD_MODULE_OPT, 1),
 
+	SXE2_DRV_CMD_FLOW_ACL_STAT_QUERY =
+		SXE2_MK_DRV_CMD(SXE2_DRV_CMD_MODULE_ACL, 1),
+	SXE2_DRV_CMD_FLOW_ACL_STAT_ALLOC =
+		SXE2_MK_DRV_CMD(SXE2_DRV_CMD_MODULE_ACL, 2),
+	SXE2_DRV_CMD_FLOW_ACL_STAT_FREE =
+		SXE2_MK_DRV_CMD(SXE2_DRV_CMD_MODULE_ACL, 3),
+
 };
 
 #endif /* SXE2_DRV_CMD_H */
drivers/net/sxe2/sxe2_dump.c +2 -0
index 590219f502..31f7d6ba61 100644
@@ -80,12 +80,14 @@ sxe2_dump_dev_args_info(FILE *file, struct rte_eth_dev *dev)
 		"\t  -- no_sched_mode: %s\n"
 		"\t  -- flow-duplicate-pattern: %u\n"
 		"\t  -- fnav-stat-type: %u\n"
+		"\t  -- acl-stat-type: %u\n"
 		"\t  -- sched_layer_mode: %u\n"
 		"\t  -- rx_low_latency: %s\n"
 		"\t  -- function-flow-direct: %s\n",
 		adapter->devargs.no_sched_mode ? "On" : "Off",
 		adapter->devargs.flow_dup_pattern_mode,
 		adapter->devargs.fnav_stat_type,
+		adapter->devargs.acl_stat_type,
 		adapter->devargs.sched_layer_mode,
 		adapter->devargs.rx_low_latency ? "On" : "Off",
 		adapter->devargs.func_flow_direct_en ? "On" : "Off");
drivers/net/sxe2/sxe2_ethdev.c +16 -7
index c5f6bc8af4..ea589c7eaa 100644
@@ -72,6 +72,7 @@ static const struct rte_pci_id pci_id_sxe2_tbl[] = {
 #define SXE2_DEVARG_FLOW_DUP_PATTERN_MODE "flow-duplicate-pattern"
 #define SXE2_DEVARG_FUNC_FLOW_DIRCT "function-flow-direct"
 #define SXE2_DEVARG_FNAV_STAT_TYPE "fnav-stat-type"
+#define SXE2_DEVARG_ACL_STAT_TYPE "acl-stat-type"
 #define SXE2_DEVARG_NO_SCHED_MODE "no-sched-mode"
 #define SXE2_DEVARG_SCHED_LAYER_MODE "sched-layer-mode"
 #define SXE2_DEVARG_RX_LOW_LATENCY "rx-low-latency"
@@ -981,11 +982,11 @@ sxe2_buffer_split_supported_hdr_ptypes_get(struct rte_eth_dev *dev __rte_unused,
 	return ptypes;
 }
 
-static int32_t sxe2_parse_fnav_stat_type(const char *key, const char *value, void *args)
+static int32_t sxe2_parse_stat_type(const char *key, const char *value, void *args)
 {
 	int32_t ret = -EINVAL;
 	uint8_t *num = (uint8_t *)args;
-	unsigned long fnav_stat_type;
+	unsigned long stat_type;
 	char *endptr = NULL;
 
 	if (value == NULL || args == NULL) {
@@ -993,19 +994,19 @@ static int32_t sxe2_parse_fnav_stat_type(const char *key, const char *value, voi
 		goto l_end;
 	}
 	errno = 0;
-	fnav_stat_type = strtoul(value, &endptr, 10);
+	stat_type = strtoul(value, &endptr, 10);
 	if (errno != 0 || endptr == value || *endptr != '\0') {
 		PMD_LOG_WARN(INIT, "%s: \"%s\" is not a valid int value.",
 			key, value);
 		goto l_end;
 	}
-	if (fnav_stat_type > SXE2_FNAV_STAT_ENA_ALL ||
-		fnav_stat_type == SXE2_FNAV_STAT_ENA_NONE) {
+	if (stat_type > SXE2_FNAV_STAT_ENA_ALL ||
+		stat_type == SXE2_FNAV_STAT_ENA_NONE) {
 		PMD_LOG_ERR(INIT, "%s: \"%s\" out of range [1-3].",
 			key, value);
 		goto l_end;
 	}
-	*num = (uint8_t)fnav_stat_type;
+	*num = (uint8_t)stat_type;
 	ret = 0;
 l_end:
 	return ret;
@@ -1187,13 +1188,20 @@ static int32_t sxe2_args_parse(struct rte_eth_dev *dev, struct sxe2_dev_kvargs_i
 	if (kvargs == NULL)
 		goto l_end;
 	ret = sxe2_kvargs_process(kvargs, SXE2_DEVARG_FNAV_STAT_TYPE,
-				 &sxe2_parse_fnav_stat_type,
+				 &sxe2_parse_stat_type,
 				 &adapter->devargs.fnav_stat_type);
 	if (ret) {
 		PMD_DEV_LOG_ERR(adapter, INIT, "Failed to parse fnav stat type, ret:%d", ret);
 		goto l_end;
 	}
 
+	ret = sxe2_kvargs_process(kvargs, SXE2_DEVARG_ACL_STAT_TYPE,
+				 &sxe2_parse_stat_type, &adapter->devargs.acl_stat_type);
+	if (ret) {
+		PMD_DEV_LOG_ERR(adapter, INIT, "Failed to parse acl stat type, ret:%d", ret);
+		goto l_end;
+	}
+
 	ret = sxe2_kvargs_process(kvargs, SXE2_DEVARG_NO_SCHED_MODE,
 				 &sxe2_parse_bool,
 				 &adapter->devargs.no_sched_mode);
@@ -2364,6 +2372,7 @@ RTE_PMD_REGISTER_PARAM_STRING(net_sxe2,
 	"flow-duplicate-pattern=<0|1|2> "
 	"function-flow-direct=<0|1> "
 	"fnav-stat-type=<1|2|3> "
+	"acl-stat-type=<1|2|3> "
 	"no-sched-mode=<0|1> "
 	"sched-layer-mode=<0-3> "
 	"rx-low-latency=<0|1>");
drivers/net/sxe2/sxe2_ethdev.h +1 -0
index e818578319..e9f78fe57f 100644
@@ -135,6 +135,7 @@ struct sxe2_devargs {
 	uint8_t flow_dup_pattern_mode;
 	uint8_t func_flow_direct_en;
 	uint8_t fnav_stat_type;
+	uint8_t acl_stat_type;
 	uint8_t no_sched_mode;
 	uint8_t sched_layer_mode;
 	uint8_t rx_low_latency;
drivers/net/sxe2/sxe2_flow.c +73 -17

163 lines not on this page · raw message

drivers/net/sxe2/sxe2_flow_define.h +3 -2
index 8a5d871978..d04499f5cb 100644
@@ -100,7 +100,7 @@ TAILQ_HEAD(rte_flow_list_t, rte_flow);
 
 struct sxe2_flow_cid_mgr {
 	TAILQ_ENTRY(sxe2_flow_cid_mgr) next;
-	uint16_t stat_index;
+	uint32_t stat_index;
 	uint32_t user_id;
 	uint32_t driver_id;
 	uint32_t count_type;
@@ -118,7 +118,8 @@ struct sxe2_flow_count_resource {
 struct sxe2_flow_context {
 	struct rte_flow_list_t rte_flow_list;
 	rte_spinlock_t flow_list_lock;
-	struct sxe2_flow_count_resource hw_res;
+	struct sxe2_flow_count_resource fnav_hw_res;
+	struct sxe2_flow_count_resource acl_hw_res;
 	uint16_t tunnel_port_list[SXE2_FLOW_UDP_TUNNEL_MAX];
 	uint32_t fnav_inited;
 };
drivers/net/sxe2/sxe2_flow_parse_action.c +18 -10
index a9559e2d7e..03ada4e8a6 100644
@@ -953,7 +953,8 @@ static int32_t sxe2_flow_check_actions(struct rte_eth_dev *dev __rte_unused, str
 		}
 	}
 
-	if (engine_type == SXE2_FLOW_ENGINE_FNAV) {
+	if (engine_type == SXE2_FLOW_ENGINE_FNAV ||
+		engine_type == SXE2_FLOW_ENGINE_ACL) {
 		if (vsi_num) {
 			flow->action.q_region.q_index = 0;
 			flow->action.q_region.region = 7;
@@ -980,6 +981,7 @@ int32_t sxe2_flow_parse_action(struct rte_eth_dev *dev,
 	uint8_t action_num[SXE2_FLOW_ACTION_MAX] = {0};
 	enum sxe2_flow_engine_type engine_type = flow->engine_type;
 	struct sxe2_adapter *adapter = SXE2_DEV_PRIVATE_TO_ADAPTER(dev);
+	struct sxe2_flow_count_resource *hw_res = NULL;
 
 	sxe2_flow_action_pre(flow);
 
@@ -988,7 +990,8 @@ int32_t sxe2_flow_parse_action(struct rte_eth_dev *dev,
 		case RTE_FLOW_ACTION_TYPE_VOID:
 			break;
 		case RTE_FLOW_ACTION_TYPE_PASSTHRU:
-			if (engine_type == SXE2_FLOW_ENGINE_FNAV) {
+			if (engine_type == SXE2_FLOW_ENGINE_FNAV ||
+				engine_type == SXE2_FLOW_ENGINE_ACL) {
 				sxe2_set_bit(SXE2_FLOW_ACTION_PASSTHRU, flow->action.act_types);
 				action_num[SXE2_FLOW_ACTION_PASSTHRU]++;
 			} else {
@@ -1035,14 +1038,9 @@ int32_t sxe2_flow_parse_action(struct rte_eth_dev *dev,
 			break;
 		case RTE_FLOW_ACTION_TYPE_COUNT:
 			if (engine_type == SXE2_FLOW_ENGINE_FNAV) {
-				sxe2_set_bit(SXE2_FLOW_ACTION_COUNT, flow->action.act_types);
-				act_count = action->conf;
-				flow->action.count.user_id = act_count->id;
-				flow->action.count.driver_id = 0;
-				if (flow->action.count.user_id == 0)
-					flow->action.count.driver_id =
-						++adapter->flow_ctxt.hw_res.global_index;
-				action_num[SXE2_FLOW_ACTION_COUNT]++;
+				hw_res = &adapter->flow_ctxt.fnav_hw_res;
+			} else if (engine_type == SXE2_FLOW_ENGINE_ACL) {
+				hw_res = &adapter->flow_ctxt.acl_hw_res;
 			} else {
 				rte_flow_error_set(error, ENOTSUP,
 					RTE_FLOW_ERROR_TYPE_ACTION, action,
@@ -1052,6 +1050,16 @@ int32_t sxe2_flow_parse_action(struct rte_eth_dev *dev,
 				ret = -EINVAL;
 				goto l_end;
 			}
+			sxe2_set_bit(SXE2_FLOW_ACTION_COUNT, flow->action.act_types);
+			act_count = action->conf;
+			flow->action.count.user_id =
+				(act_count == NULL) ? 0 : act_count->id;
+			flow->action.count.driver_id = 0;
+			if (flow->action.count.user_id == 0) {
+				flow->action.count.driver_id =
+					++hw_res->global_index;
+			}
+			action_num[SXE2_FLOW_ACTION_COUNT]++;
 			break;
 		case RTE_FLOW_ACTION_TYPE_RSS:
 			if (engine_type == SXE2_FLOW_ENGINE_RSS) {
Signature · 1 line
2.52.0
#393 lore raw

PATCH v10 26/48 net/sxe2: enable FDIR on all Rx queues

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_flow_init() always sets fnav_inited, so enable FDIR on every Rx queue during queue init by setting rxq->fnav_enable. FDIR/FNAV flags are required for flow rules and ACL statistics, so every Rx queue must have them enabled. This makes the fnav blocks in the vectorized Rx paths live on all queues.

---
 drivers/net/sxe2/sxe2_queue.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/sxe2/sxe2_queue.c +2 -0
index afb2681b72..3aaa14c685 100644
@@ -39,6 +39,8 @@ int32_t sxe2_queues_init(struct rte_eth_dev *dev)
 		rxq->rx_buf_len = RTE_MIN(rxq->rx_buf_len, SXE2_RX_MAX_DATA_BUF_SIZE);
 		if (frame_size > rxq->rx_buf_len)
 			dev->data->scattered_rx = 1;
+		if (adapter->flow_ctxt.fnav_inited)
+			rxq->fnav_enable = true;
 	}
 
 	adapter->ptp_ctxt.mbuf_rx_ts_offset = -1;
Signature · 1 line
2.52.0
#394 lore raw

PATCH v10 27/48 net/sxe2: refactor primary process MP message handling

In reply to [email protected]

From: Jie Liu <[email protected]>

Extract the multi-process work logic into the sxe2_mp_do_primary_work helper and operate on a copy of the request in the primary handler so the original message is not modified. Simplify the reply construction and return -ENOENT instead of -EINVAL when no response is received from the primary process.

Fixes 5db446ba97b0 ("net/sxe2: support statistics and multi-process")
---
 drivers/net/sxe2/sxe2_mp.c | 59 ++++++++++++++++++++++----------------
 1 file changed, 34 insertions(+), 25 deletions(-)
drivers/net/sxe2/sxe2_mp.c +34 -25
index a4a5c76495..93a11150a9 100644
@@ -29,16 +29,11 @@ static int32_t sxe2_mp_secondary_handle(const struct rte_mp_msg *mp_msg,
 					 const void *peer);
 
 static int32_t
-sxe2_mp_primary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
+sxe2_mp_do_primary_work(struct sxe2_mp_param *param)
 {
-	struct rte_mp_msg reply;
-	const struct sxe2_mp_param *param =
-			(const struct sxe2_mp_param *)mp_msg->param;
-	struct sxe2_mp_param *reply_param = (struct sxe2_mp_param *)reply.param;
 	struct rte_eth_dev *dev;
-	int32_t ret = 0;
 	struct sxe2_mp_shared_data *mz_data;
-	int32_t send_reply = 0;
+	int32_t ret = 0;
 	int32_t cnt = 0;
 
 	if (!rte_eth_dev_is_valid_port(param->port_id)) {
@@ -49,24 +44,21 @@ sxe2_mp_primary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
 	}
 
 	dev = &rte_eth_devices[param->port_id];
-	sxe2_mp_mz = rte_memzone_lookup(SXE2_MP_MZ_NAME);
+
 	if (sxe2_mp_mz == NULL) {
-		PMD_LOG_ERR(DRV, "Failed to lookup memzone %s", SXE2_MP_MZ_NAME);
-		ret = -ENOENT;
-		goto out;
+		sxe2_mp_mz = rte_memzone_lookup(SXE2_MP_MZ_NAME);
+		if (sxe2_mp_mz == NULL) {
+			PMD_LOG_ERR(DRV, "Failed to lookup memzone %s",
+					SXE2_MP_MZ_NAME);
+			ret = -ENOENT;
+			goto out;
+		}
 	}
 
 	mz_data = (struct sxe2_mp_shared_data *)sxe2_mp_mz->addr;
-	send_reply = 1;
-
-	memset(&reply, 0, sizeof(reply));
-	(void)strlcpy(reply.name, SXE2_MP_NAME, sizeof(reply.name));
-	reply.len_param = sizeof(*reply_param);
-
 	switch (param->type) {
 	case SXE2_MP_REQ_GET_STATS:
-		ret = sxe2_stats_info_get(dev,
-					  &mz_data->payload.stats_blk.stats,
+		ret = sxe2_stats_info_get(dev, &mz_data->payload.stats_blk.stats,
 					  &mz_data->payload.stats_blk.qstats);
 		break;
 	case SXE2_MP_REQ_GET_XSTATS:
@@ -88,15 +80,32 @@ sxe2_mp_primary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
 	default:
 		PMD_LOG_ERR(DRV, "primary process: unrecognized msg type: %d",
 				param->type);
-		send_reply = false;
 		ret = -EINVAL;
-		goto out;
+		break;
 	}
+
 out:
-	if (!send_reply)
-		return ret;
+	param->result = ret;
+	return ret;
+}
 
-	reply_param->result = ret;
+static int32_t
+sxe2_mp_primary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
+{
+	struct rte_mp_msg reply;
+	struct sxe2_mp_param *reply_param = (struct sxe2_mp_param *)reply.param;
+	const struct sxe2_mp_param *param =
+			(const struct sxe2_mp_param *)mp_msg->param;
+	struct sxe2_mp_param param_copy;
+
+	memset(&reply, 0, sizeof(reply));
+	(void)strlcpy(reply.name, SXE2_MP_NAME, sizeof(reply.name));
+	reply.len_param = sizeof(*reply_param);
+
+	param_copy = *param;
+	(void)sxe2_mp_do_primary_work(&param_copy);
+
+	reply_param->result = param_copy.result;
 	reply_param->type = param->type;
 	reply_param->port_id = param->port_id;
 
@@ -275,7 +284,7 @@ int32_t sxe2_mp_request_simple(struct rte_eth_dev *dev,
 	if (reply.nb_received == 0) {
 		PMD_LOG_ERR(DRV, "No response received from primary for type=%d, port %u",
 			type, dev->data->port_id);
-		ret = -EINVAL;
+		ret = -ENOENT;
 		goto out;
 	}
 
Signature · 1 line
2.52.0
#395 lore raw

PATCH v10 28/48 net/sxe2: refactor Tx queue reset operations

In reply to [email protected]

From: Jie Liu <[email protected]>

Extract the descriptor ring reset loop into a sxe2_tx_queue_desc_ring_reset helper and reuse it from both the scalar and vectorized queue reset paths. Add a sxe2_tx_queue_reset_vec entry point for vectorized queues, export sxe2_tx_buffer_ring_free for reuse outside the module (clearing the buffer ring pointer after freeing it), and add sxe2_tx_vec_ops_get to build the vectorized Tx queue operations table used by the vector path setup.

---
 drivers/net/sxe2/sxe2_tx.c       | 42 +++++++++++++++++++++++---------
 drivers/net/sxe2/sxe2_tx.h       |  4 +++
 drivers/net/sxe2/sxe2_txrx_vec.c | 17 ++++++++++---
 3 files changed, 49 insertions(+), 14 deletions(-)
drivers/net/sxe2/sxe2_tx.c +31 -11
index f49238ceef..94a6e9afc7 100644
@@ -19,6 +19,17 @@ static void *sxe2_tx_doorbell_addr_get(struct sxe2_adapter *adapter, uint16_t qu
 				     queue_id);
 }
 
+static void sxe2_tx_queue_desc_ring_reset(struct sxe2_tx_queue *txq)
+{
+	uint16_t i;
+	static const union sxe2_tx_data_desc zeroed_desc = {{0}};
+
+	for (i = 0; i < txq->ring_depth; i++) {
+		txq->desc_ring[i] = zeroed_desc;
+		txq->desc_ring[i].wb.dd = rte_cpu_to_le_64(SXE2_TX_DESC_DTYPE_DESC_DONE);
+	}
+}
+
 static void sxe2_tx_tail_init(struct sxe2_adapter *adapter, struct sxe2_tx_queue *txq)
 {
 	txq->tdt_reg_addr = sxe2_tx_doorbell_addr_get(adapter, txq->queue_id);
@@ -28,20 +39,12 @@ static void sxe2_tx_tail_init(struct sxe2_adapter *adapter, struct sxe2_tx_queue
 void __rte_cold sxe2_tx_queue_reset(struct sxe2_tx_queue *txq)
 {
 	uint16_t prev, i;
-	volatile union sxe2_tx_data_desc *txd;
-	static const union sxe2_tx_data_desc zeroed_desc = {{0}};
 	struct sxe2_tx_buffer *tx_buffer = txq->buffer_ring;
 
-	for (i = 0; i < txq->ring_depth; i++)
-		txq->desc_ring[i] = zeroed_desc;
+	sxe2_tx_queue_desc_ring_reset(txq);
 
 	prev = txq->ring_depth - 1;
 	for (i = 0; i < txq->ring_depth; i++) {
-		txd = &txq->desc_ring[i];
-		if (txd == NULL)
-			continue;
-
-		txd->wb.dd = rte_cpu_to_le_64(SXE2_TX_DESC_DTYPE_DESC_DONE);
 		tx_buffer[i].mbuf       = NULL;
 		tx_buffer[i].last_id    = i;
 		tx_buffer[prev].next_id = i;
@@ -56,6 +59,21 @@ void __rte_cold sxe2_tx_queue_reset(struct sxe2_tx_queue *txq)
 	txq->next_rs       = txq->rs_thresh  - 1;
 }
 
+void __rte_cold sxe2_tx_queue_reset_vec(struct sxe2_tx_queue *txq)
+{
+	sxe2_tx_queue_desc_ring_reset(txq);
+
+	memset(txq->buffer_ring, 0,
+		sizeof(struct sxe2_tx_buffer) * txq->ring_depth);
+
+	txq->desc_used_num = 0;
+	txq->desc_free_num = txq->ring_depth - 1;
+	txq->next_use      = 0;
+	txq->next_clean    = txq->ring_depth - 1;
+	txq->next_dd       = txq->rs_thresh  - 1;
+	txq->next_rs       = txq->rs_thresh  - 1;
+}
+
 void __rte_cold sxe2_tx_queue_mbufs_release(struct sxe2_tx_queue *txq)
 {
 	uint32_t i;
@@ -70,10 +88,12 @@ void __rte_cold sxe2_tx_queue_mbufs_release(struct sxe2_tx_queue *txq)
 	}
 }
 
-static void sxe2_tx_buffer_ring_free(struct sxe2_tx_queue *txq)
+void __rte_cold sxe2_tx_buffer_ring_free(struct sxe2_tx_queue *txq)
 {
-	if (txq != NULL && txq->buffer_ring != NULL)
+	if (txq != NULL && txq->buffer_ring != NULL) {
 		rte_free(txq->buffer_ring);
+		txq->buffer_ring = NULL;
+	}
 }
 
 const struct sxe2_txq_ops sxe2_default_txq_ops = {
drivers/net/sxe2/sxe2_tx.h +4 -0
index f4823126b3..bc5ff1c2bc 100644
@@ -9,6 +9,10 @@
 
 void __rte_cold sxe2_tx_queue_reset(struct sxe2_tx_queue *txq);
 
+void __rte_cold sxe2_tx_queue_reset_vec(struct sxe2_tx_queue *txq);
+
+void __rte_cold sxe2_tx_buffer_ring_free(struct sxe2_tx_queue *txq);
+
 int32_t __rte_cold sxe2_tx_queue_start(struct rte_eth_dev *dev, uint16_t queue_id);
 
 void sxe2_tx_queue_mbufs_release(struct sxe2_tx_queue *txq);
drivers/net/sxe2/sxe2_txrx_vec.c +14 -3
index cf004f5eb2..1442d5d119 100644
@@ -8,6 +8,14 @@
 #include "sxe2_ethdev.h"
 #include "sxe2_common_log.h"
 
+static void sxe2_tx_queue_mbufs_release_vec(struct sxe2_tx_queue *txq);
+
+static const struct sxe2_txq_ops sxe2_tx_vec_ops = {
+	.queue_reset      = sxe2_tx_queue_reset_vec,
+	.mbufs_release    = sxe2_tx_queue_mbufs_release_vec,
+	.buffer_ring_free = sxe2_tx_buffer_ring_free,
+};
+
 int32_t __rte_cold sxe2_rx_vec_support_check(struct rte_eth_dev *dev, uint32_t *vec_flags)
 {
 	struct sxe2_rx_queue *rxq;
@@ -230,10 +238,13 @@ int32_t __rte_cold sxe2_tx_queues_vec_prepare(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_tx_queues; ++i) {
 		txq = dev->data->tx_queues[i];
 		if (txq == NULL) {
-			PMD_LOG_INFO(TX, "Failed to prepare tx queue, txq[%d] is NULL", i);
-			continue;
+			PMD_LOG_ERR(TX, "Failed to prepare tx queue, txq[%d] is NULL", i);
+			ret = -EINVAL;
+			goto l_end;
 		}
-		txq->ops.mbufs_release = sxe2_tx_queue_mbufs_release_vec;
+		txq->ops = sxe2_tx_vec_ops;
+		txq->ops.queue_reset(txq);
 	}
+l_end:
 	return ret;
 }
Signature · 1 line
2.52.0
#396 lore raw

PATCH v10 29/48 net/sxe2: unify vectorized Tx buffer handling

In reply to [email protected]

From: Jie Liu <[email protected]>

Add a union of the scalar and vectorized buffer ring pointers to the Tx queue structure so the vectorized path can use sxe2_tx_buffer_vec directly. Rename the mbuf fill helper to sxe2_tx_pkts_mbuf_fill_vec, switch the vectorized Tx burst and mbuf release paths to the buffer_ring_vec member, and drop the AVX512-specific fill handling and conditional branching.

Fixes ac60f302cbef ("net/sxe2: add vectorized Rx and Tx")
---
 drivers/net/sxe2/sxe2_queue.h           |   5 +-
 drivers/net/sxe2/sxe2_txrx_vec.c        |  57 ++--------
 drivers/net/sxe2/sxe2_txrx_vec_avx2.c   |  10 +-
 drivers/net/sxe2/sxe2_txrx_vec_avx512.c | 133 +-----------------------
 drivers/net/sxe2/sxe2_txrx_vec_common.h |   9 +-
 drivers/net/sxe2/sxe2_txrx_vec_neon.c   |  10 +-
 drivers/net/sxe2/sxe2_txrx_vec_sse.c    |  10 +-
 7 files changed, 40 insertions(+), 194 deletions(-)
drivers/net/sxe2/sxe2_queue.h +4 -1
index 10bdaf5b8d..e53a1ce852 100644
@@ -62,7 +62,10 @@ struct sxe2_txq_ops {
 };
 struct sxe2_tx_queue {
 	volatile union sxe2_tx_data_desc *desc_ring;
-	struct sxe2_tx_buffer *buffer_ring;
+	union {
+		struct sxe2_tx_buffer *buffer_ring;
+		struct sxe2_tx_buffer_vec *buffer_ring_vec;
+	};
 	volatile uint32_t *tdt_reg_addr;
 
 	uint64_t offloads;
drivers/net/sxe2/sxe2_txrx_vec.c +11 -46

77 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx_vec_avx2.c +5 -5
index 0618e6d988..da96ca3064 100644
@@ -115,7 +115,7 @@ sxe2_tx_pkts_vec_avx2_batch(struct sxe2_tx_queue *txq, struct rte_mbuf **tx_pkts
 			    uint16_t nb_pkts, bool with_offloads)
 {
 	volatile union sxe2_tx_data_desc *desc;
-	struct sxe2_tx_buffer *buffer;
+	struct sxe2_tx_buffer_vec *buffer;
 	uint16_t next_use;
 	uint16_t res_num;
 	uint16_t tx_num;
@@ -134,14 +134,14 @@ sxe2_tx_pkts_vec_avx2_batch(struct sxe2_tx_queue *txq, struct rte_mbuf **tx_pkts
 
 	next_use = txq->next_use;
 	desc     = &txq->desc_ring[next_use];
-	buffer   = &txq->buffer_ring[next_use];
+	buffer   = &txq->buffer_ring_vec[next_use];
 
 	txq->desc_free_num -= nb_pkts;
 
 	res_num = txq->ring_depth - txq->next_use;
 
 	if (tx_num >= res_num) {
-		sxe2_tx_pkts_mbuf_fill(buffer, tx_pkts, res_num);
+		sxe2_tx_pkts_mbuf_fill_vec(buffer, tx_pkts, res_num);
 
 		sxe2_tx_desc_fill_avx2(desc, tx_pkts, res_num,
 				SXE2_TX_DATA_DESC_CMD_EOP, with_offloads);
@@ -157,10 +157,10 @@ sxe2_tx_pkts_vec_avx2_batch(struct sxe2_tx_queue *txq, struct rte_mbuf **tx_pkts
 		next_use     = 0;
 		txq->next_rs = txq->rs_thresh - 1;
 		desc         = &txq->desc_ring[next_use];
-		buffer       = &txq->buffer_ring[next_use];
+		buffer       = &txq->buffer_ring_vec[next_use];
 	}
 
-	sxe2_tx_pkts_mbuf_fill(buffer, tx_pkts, tx_num);
+	sxe2_tx_pkts_mbuf_fill_vec(buffer, tx_pkts, tx_num);
 
 	sxe2_tx_desc_fill_avx2(desc, tx_pkts, tx_num,
 			SXE2_TX_DATA_DESC_CMD_EOP, with_offloads);
drivers/net/sxe2/sxe2_txrx_vec_avx512.c +5 -128

180 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx_vec_common.h +5 -4
index 9ac99cf0fa..ede4c236b1 100644
@@ -25,10 +25,11 @@
 #define SXE2_TX_FREE_BUFFER_SIZE_MAX_VEC  64
 
 static __rte_always_inline void
-sxe2_tx_pkts_mbuf_fill(struct sxe2_tx_buffer *buffer,
-		struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
+sxe2_tx_pkts_mbuf_fill_vec(struct sxe2_tx_buffer_vec *buffer,
+			   struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 {
 	uint16_t i;
+
 	for (i = 0; i < nb_pkts; ++i)
 		buffer[i].mbuf = tx_pkts[i];
 }
@@ -36,7 +37,7 @@ sxe2_tx_pkts_mbuf_fill(struct sxe2_tx_buffer *buffer,
 static __rte_always_inline int32_t
 sxe2_tx_bufs_free_vec(struct sxe2_tx_queue *txq)
 {
-	struct sxe2_tx_buffer *buffer;
+	struct sxe2_tx_buffer_vec *buffer;
 	struct rte_mbuf *mbuf;
 	struct rte_mbuf *mbuf_free_arr[SXE2_TX_FREE_BUFFER_SIZE_MAX_VEC];
 	int32_t ret;
@@ -50,7 +51,7 @@ sxe2_tx_bufs_free_vec(struct sxe2_tx_queue *txq)
 		goto l_end;
 	}
 	rs_thresh = txq->rs_thresh;
-	buffer = &txq->buffer_ring[txq->next_dd - (rs_thresh - 1)];
+	buffer = &txq->buffer_ring_vec[txq->next_dd - (rs_thresh - 1)];
 	mbuf = rte_pktmbuf_prefree_seg(buffer[0].mbuf);
 	if (likely(mbuf)) {
 		mbuf_free_arr[0] = mbuf;
drivers/net/sxe2/sxe2_txrx_vec_neon.c +5 -5
index 4e5cb87cd5..b51cc55368 100644
@@ -39,7 +39,7 @@ sxe2_tx_pkts_vec_neon_batch(struct sxe2_tx_queue *txq, struct rte_mbuf **tx_pkts
 			uint16_t nb_pkts, bool with_offloads)
 {
 	volatile union sxe2_tx_data_desc *desc;
-	struct sxe2_tx_buffer *buffer;
+	struct sxe2_tx_buffer_vec *buffer;
 	uint16_t next_use;
 	uint16_t res_num;
 	uint16_t tx_num;
@@ -59,14 +59,14 @@ sxe2_tx_pkts_vec_neon_batch(struct sxe2_tx_queue *txq, struct rte_mbuf **tx_pkts
 
 	next_use = txq->next_use;
 	desc     = &txq->desc_ring[next_use];
-	buffer   = &txq->buffer_ring[next_use];
+	buffer   = &txq->buffer_ring_vec[next_use];
 
 	txq->desc_free_num -= nb_pkts;
 
 	res_num = txq->ring_depth - txq->next_use;
 
 	if (tx_num >= res_num) {
-		sxe2_tx_pkts_mbuf_fill(buffer, tx_pkts, res_num);
+		sxe2_tx_pkts_mbuf_fill_vec(buffer, tx_pkts, res_num);
 
 		for (i = 0; i < res_num - 1; ++i, ++tx_pkts, ++desc) {
 			sxe2_tx_desc_fill_one_neon(desc, *tx_pkts,
@@ -82,10 +82,10 @@ sxe2_tx_pkts_vec_neon_batch(struct sxe2_tx_queue *txq, struct rte_mbuf **tx_pkts
 		next_use     = 0;
 		txq->next_rs = txq->rs_thresh - 1;
 		desc         = &txq->desc_ring[next_use];
-		buffer       = &txq->buffer_ring[next_use];
+		buffer       = &txq->buffer_ring_vec[next_use];
 	}
 
-	sxe2_tx_pkts_mbuf_fill(buffer, tx_pkts, tx_num);
+	sxe2_tx_pkts_mbuf_fill_vec(buffer, tx_pkts, tx_num);
 
 	for (i = 0; i < tx_num; ++i, ++tx_pkts, ++desc) {
 		sxe2_tx_desc_fill_one_neon(desc, *tx_pkts,
drivers/net/sxe2/sxe2_txrx_vec_sse.c +5 -5
index c3e8a2983b..181bb40041 100644
@@ -40,7 +40,7 @@ sxe2_tx_pkts_vec_sse_batch(struct sxe2_tx_queue *txq,
 		uint16_t nb_pkts, bool with_offloads)
 {
 	volatile union sxe2_tx_data_desc *desc;
-	struct sxe2_tx_buffer *buffer;
+	struct sxe2_tx_buffer_vec *buffer;
 	uint16_t next_use;
 	uint16_t res_num;
 	uint16_t tx_num;
@@ -57,11 +57,11 @@ sxe2_tx_pkts_vec_sse_batch(struct sxe2_tx_queue *txq,
 	tx_num = nb_pkts;
 	next_use = txq->next_use;
 	desc     = &txq->desc_ring[next_use];
-	buffer   = &txq->buffer_ring[next_use];
+	buffer   = &txq->buffer_ring_vec[next_use];
 	txq->desc_free_num -= nb_pkts;
 	res_num = txq->ring_depth - txq->next_use;
 	if (tx_num >= res_num) {
-		sxe2_tx_pkts_mbuf_fill(buffer, tx_pkts, res_num);
+		sxe2_tx_pkts_mbuf_fill_vec(buffer, tx_pkts, res_num);
 		for (i = 0; i < res_num - 1; ++i, ++tx_pkts, ++desc) {
 			sxe2_tx_desc_fill_one_sse(desc, *tx_pkts,
 						  SXE2_TX_DATA_DESC_CMD_EOP,
@@ -74,9 +74,9 @@ sxe2_tx_pkts_vec_sse_batch(struct sxe2_tx_queue *txq,
 		next_use     = 0;
 		txq->next_rs = txq->rs_thresh - 1;
 		desc         = &txq->desc_ring[next_use];
-		buffer       = &txq->buffer_ring[next_use];
+		buffer       = &txq->buffer_ring_vec[next_use];
 	}
-	sxe2_tx_pkts_mbuf_fill(buffer, tx_pkts, tx_num);
+	sxe2_tx_pkts_mbuf_fill_vec(buffer, tx_pkts, tx_num);
 	for (i = 0; i < tx_num; ++i, ++tx_pkts, ++desc) {
 		sxe2_tx_desc_fill_one_sse(desc, *tx_pkts,
 					  SXE2_TX_DATA_DESC_CMD_EOP,
Signature · 1 line
2.52.0
#397 lore raw

PATCH v10 30/48 net/sxe2: optimize NEON Tx descriptor fill

In reply to [email protected]

From: Jie Liu <[email protected]>

Add sxe2_tx_desc_fill_4_neon_simple() to write four data descriptors with a single vst1q_u64_x4 store, and use it in sxe2_tx_pkts_vec_neon_batch() for the non-offload path to reduce the number of per-packet descriptor stores.

---
 drivers/net/sxe2/sxe2_txrx_vec_neon.c | 77 ++++++++++++++++++++++++---
 1 file changed, 70 insertions(+), 7 deletions(-)
drivers/net/sxe2/sxe2_txrx_vec_neon.c +70 -7
index b51cc55368..6b4c70c7ac 100644
@@ -34,6 +34,52 @@ sxe2_tx_desc_fill_one_neon(volatile union sxe2_tx_data_desc *desc,
 	vst1q_u64(RTE_CAST_PTR(uint64_t *, desc), data_desc);
 }
 
+static __rte_always_inline void
+sxe2_tx_desc_fill_4_neon_simple(volatile union sxe2_tx_data_desc *desc,
+				struct rte_mbuf **pkts)
+{
+	uint64x2_t d0, d1, d2, d3;
+	uint64x2x4_t v;
+	const uint64_t cmd_base = ((uint64_t)SXE2_TX_DESC_DTYPE_DATA) |
+				((uint64_t)SXE2_TX_DATA_DESC_CMD_EOP) <<
+				SXE2_TX_DATA_DESC_CMD_SHIFT;
+
+	d0 = (uint64x2_t){
+		rte_pktmbuf_iova(pkts[0]),
+		cmd_base |
+		((uint64_t)pkts[0]->data_len) << SXE2_TX_DATA_DESC_BUF_SZ_SHIFT |
+		((uint64_t)SXE2_TX_DATA_DESC_MACLEN_VAL(pkts[0]->l2_len))
+				<< SXE2_TX_DATA_DESC_OFFSET_SHIFT
+	};
+	d1 = (uint64x2_t){
+		rte_pktmbuf_iova(pkts[1]),
+		cmd_base |
+		((uint64_t)pkts[1]->data_len) << SXE2_TX_DATA_DESC_BUF_SZ_SHIFT |
+		((uint64_t)SXE2_TX_DATA_DESC_MACLEN_VAL(pkts[1]->l2_len))
+				<< SXE2_TX_DATA_DESC_OFFSET_SHIFT
+	};
+	d2 = (uint64x2_t){
+		rte_pktmbuf_iova(pkts[2]),
+		cmd_base |
+		((uint64_t)pkts[2]->data_len) << SXE2_TX_DATA_DESC_BUF_SZ_SHIFT |
+		((uint64_t)SXE2_TX_DATA_DESC_MACLEN_VAL(pkts[2]->l2_len))
+				<< SXE2_TX_DATA_DESC_OFFSET_SHIFT
+	};
+	d3 = (uint64x2_t){
+		rte_pktmbuf_iova(pkts[3]),
+		cmd_base |
+		((uint64_t)pkts[3]->data_len) << SXE2_TX_DATA_DESC_BUF_SZ_SHIFT |
+		((uint64_t)SXE2_TX_DATA_DESC_MACLEN_VAL(pkts[3]->l2_len))
+				<< SXE2_TX_DATA_DESC_OFFSET_SHIFT
+	};
+
+	v.val[0] = d0;
+	v.val[1] = d1;
+	v.val[2] = d2;
+	v.val[3] = d3;
+	vst1q_u64_x4(RTE_CAST_PTR(uint64_t *, desc), v);
+}
+
 static __rte_always_inline uint16_t
 sxe2_tx_pkts_vec_neon_batch(struct sxe2_tx_queue *txq, struct rte_mbuf **tx_pkts,
 			uint16_t nb_pkts, bool with_offloads)
@@ -67,10 +113,18 @@ sxe2_tx_pkts_vec_neon_batch(struct sxe2_tx_queue *txq, struct rte_mbuf **tx_pkts
 
 	if (tx_num >= res_num) {
 		sxe2_tx_pkts_mbuf_fill_vec(buffer, tx_pkts, res_num);
-
-		for (i = 0; i < res_num - 1; ++i, ++tx_pkts, ++desc) {
-			sxe2_tx_desc_fill_one_neon(desc, *tx_pkts,
-					SXE2_TX_DATA_DESC_CMD_EOP, with_offloads);
+		if (with_offloads) {
+			for (i = 0; i < res_num - 1; ++i, ++tx_pkts, ++desc) {
+				sxe2_tx_desc_fill_one_neon(desc, *tx_pkts,
+						SXE2_TX_DATA_DESC_CMD_EOP, with_offloads);
+			}
+		} else {
+			for (i = 0; i + 3 < res_num - 1; i += 4, tx_pkts += 4, desc += 4)
+				sxe2_tx_desc_fill_4_neon_simple(desc, tx_pkts);
+			for (; i < res_num - 1; ++i, ++tx_pkts, ++desc) {
+				sxe2_tx_desc_fill_one_neon(desc, *tx_pkts,
+						SXE2_TX_DATA_DESC_CMD_EOP, false);
+			}
 		}
 
 		sxe2_tx_desc_fill_one_neon(desc, *tx_pkts++,
@@ -87,9 +141,18 @@ sxe2_tx_pkts_vec_neon_batch(struct sxe2_tx_queue *txq, struct rte_mbuf **tx_pkts
 
 	sxe2_tx_pkts_mbuf_fill_vec(buffer, tx_pkts, tx_num);
 
-	for (i = 0; i < tx_num; ++i, ++tx_pkts, ++desc) {
-		sxe2_tx_desc_fill_one_neon(desc, *tx_pkts,
-				SXE2_TX_DATA_DESC_CMD_EOP, with_offloads);
+	if (with_offloads) {
+		for (i = 0; i < tx_num; ++i, ++tx_pkts, ++desc) {
+			sxe2_tx_desc_fill_one_neon(desc, *tx_pkts,
+					SXE2_TX_DATA_DESC_CMD_EOP, true);
+		}
+	} else {
+		for (i = 0; i + 3 < tx_num; i += 4, tx_pkts += 4, desc += 4)
+			sxe2_tx_desc_fill_4_neon_simple(desc, tx_pkts);
+		for (; i < tx_num; ++i, ++tx_pkts, ++desc) {
+			sxe2_tx_desc_fill_one_neon(desc, *tx_pkts,
+					SXE2_TX_DATA_DESC_CMD_EOP, false);
+		}
 	}
 
 	next_use += tx_num;
Signature · 1 line
2.52.0
#398 lore raw

PATCH v10 31/48 net/sxe2: fix NEON Rx ptype mapping and memory ordering

In reply to [email protected]

From: Jie Liu <[email protected]>

Reorder the descriptor lane mapping in the NEON Rx path to use the natural d0/d1/d2/d3 order for desc_lo/desc_hi, and update the staterr zip (16-bit), the shuffle masks and the ptype lane selection accordingly.

Correct the DD count in the NEON Rx path: count the leading run of done descriptors with rte_ctz64() instead of rte_popcount64(), which could hand up a descriptor the hardware has not yet written when DD bits are not contiguous.

Fix the FNAV/FDIR lane order in sxe2_rx_desc_fnav_flags_neon() to match the natural descriptor order used by the ptype and offload paths, so FDIR flags land on the correct mbuf.

Drop three of the four rte_atomic_thread_fence(acquire) barriers between descriptor loads; the single acquire fence after the descriptor set is loaded is sufficient for the Rx producer/consumer ordering.

Fixes ac60f302cbef ("net/sxe2: add vectorized Rx and Tx")
---
 drivers/net/sxe2/sxe2_txrx_vec_neon.c | 136 +++++++++++++-------------
 1 file changed, 70 insertions(+), 66 deletions(-)
drivers/net/sxe2/sxe2_txrx_vec_neon.c +70 -66
index 6b4c70c7ac..72338ee61a 100644
@@ -213,22 +213,24 @@ uint16_t sxe2_tx_pkts_vec_neon(void *tx_queue,
 }
 
 static __rte_always_inline void
-sxe2_rx_desc_ptype_fill_neon(uint16x8_t staterr, struct rte_mbuf **__rte_restrict rx_pkts)
+sxe2_rx_desc_ptype_fill_neon(uint32x4_t desc_lo,
+							 struct rte_mbuf **__rte_restrict rx_pkts,
+							 const uint32_t *__rte_restrict ptype_tbl)
 {
-	uint16x8_t ptype_mask = {
-		0, 0x3FFULL,
-		0, 0x3FFULL,
-		0, 0x3FFULL,
-		0, 0x3FFULL,
+	const uint32x4_t ptype_mask = {
+		SXE2_RX_DESC_PTYPE_MASK_NO_SHIFT << 16,
+		SXE2_RX_DESC_PTYPE_MASK_NO_SHIFT << 16,
+		SXE2_RX_DESC_PTYPE_MASK_NO_SHIFT << 16,
+		SXE2_RX_DESC_PTYPE_MASK_NO_SHIFT << 16,
 	};
 	uint16x8_t ptype_all;
 
-	ptype_all = vandq_u16(staterr, ptype_mask);
+	ptype_all = vreinterpretq_u16_u32(vandq_u32(desc_lo, ptype_mask));
 
-	rx_pkts[3]->packet_type = sxe2_ptype_tbl[vgetq_lane_u16(ptype_all, 3)];
-	rx_pkts[2]->packet_type = sxe2_ptype_tbl[vgetq_lane_u16(ptype_all, 7)];
-	rx_pkts[1]->packet_type = sxe2_ptype_tbl[vgetq_lane_u16(ptype_all, 1)];
-	rx_pkts[0]->packet_type = sxe2_ptype_tbl[vgetq_lane_u16(ptype_all, 5)];
+	rx_pkts[0]->packet_type = ptype_tbl[vgetq_lane_u16(ptype_all, 1)];
+	rx_pkts[1]->packet_type = ptype_tbl[vgetq_lane_u16(ptype_all, 3)];
+	rx_pkts[2]->packet_type = ptype_tbl[vgetq_lane_u16(ptype_all, 5)];
+	rx_pkts[3]->packet_type = ptype_tbl[vgetq_lane_u16(ptype_all, 7)];
 }
 
 static __rte_always_inline uint32x4_t
@@ -247,8 +249,8 @@ sxe2_rx_desc_fnav_flags_neon(uint64x2_t descs_arr[4])
 	uint32x4_t d2 = vreinterpretq_u32_u64(descs_arr[2]);
 	uint32x4_t d3 = vreinterpretq_u32_u64(descs_arr[3]);
 
-	descs_tmp1 = vzip1q_u32(d1, d0);
-	descs_tmp2 = vzip1q_u32(d3, d2);
+	descs_tmp1 = vzip1q_u32(d0, d1);
+	descs_tmp2 = vzip1q_u32(d2, d3);
 
 	uint64x2_t a = vreinterpretq_u64_u32(descs_tmp1);
 	uint64x2_t b = vreinterpretq_u64_u32(descs_tmp2);
@@ -271,9 +273,10 @@ sxe2_rx_desc_fnav_flags_neon(uint64x2_t descs_arr[4])
 static __rte_always_inline void
 sxe2_rx_desc_offloads_para_fill_neon(struct sxe2_rx_queue *rxq,
 			volatile union sxe2_rx_desc *desc,
-			uint64x2_t descs[4], struct rte_mbuf **rx_pkts)
+			uint64x2_t descs[4], uint32x4_t desc_lo, uint32x4_t desc_hi,
+			struct rte_mbuf **rx_pkts)
 {
-	uint32x4_t desc_lo, desc_hi, flags, tmp_flags;
+	uint32x4_t flags, tmp_flags;
 	const uint64x2_t mbuf_init = {rxq->mbuf_init_value, 0};
 	uint64x2_t rearm0, rearm1, rearm2, rearm3;
 
@@ -330,23 +333,6 @@ sxe2_rx_desc_offloads_para_fill_neon(struct sxe2_rx_queue *rxq,
 		0, 0, 0, 0, 0, 0, 0, 0
 	};
 
-	{
-		uint32x4_t d0 = vreinterpretq_u32_u64(descs[0]);
-		uint32x4_t d1 = vreinterpretq_u32_u64(descs[1]);
-		uint32x4_t d2 = vreinterpretq_u32_u64(descs[2]);
-		uint32x4_t d3 = vreinterpretq_u32_u64(descs[3]);
-		uint64x2_t f64, t64;
-
-		flags = vzip2q_u32(d1, d0);
-		tmp_flags = vzip2q_u32(d3, d2);
-		f64 = vreinterpretq_u64_u32(flags);
-		t64 = vreinterpretq_u64_u32(tmp_flags);
-		desc_lo = vreinterpretq_u32_u64(vcombine_u64(vget_low_u64(f64),
-							     vget_low_u64(t64)));
-		desc_hi = vreinterpretq_u32_u64(vcombine_u64(vget_high_u64(f64),
-							     vget_high_u64(t64)));
-	}
-
 	desc_lo = vandq_u32(desc_lo, desc_msk);
 	desc_hi = vandq_u32(desc_hi, rss_msk);
 
@@ -505,25 +491,39 @@ sxe2_rx_pkts_common_vec_neon(struct sxe2_rx_queue *rxq, struct rte_mbuf **rx_pkt
 		uint64x2_t descs[SXE2_RX_NUM_PER_LOOP_NEON];
 		uint8x16_t pkt_mb1, pkt_mb2, pkt_mb3, pkt_mb4;
 		uint64x2_t mbp1, mbp2;
+		uint32x4_t desc_lo, desc_hi;
 		uint16x8_t staterr;
 		uint16x8_t tmp;
 		uint16_t bit_num;
 
 		descs[3] = vld1q_u64(RTE_CAST_PTR(uint64_t *, desc + 3));
-		rte_atomic_thread_fence(rte_memory_order_acquire);
 		descs[2] = vld1q_u64(RTE_CAST_PTR(uint64_t *, desc + 2));
-		rte_atomic_thread_fence(rte_memory_order_acquire);
 		descs[1] = vld1q_u64(RTE_CAST_PTR(uint64_t *, desc + 1));
-		rte_atomic_thread_fence(rte_memory_order_acquire);
 		descs[0] = vld1q_u64(RTE_CAST_PTR(uint64_t *, desc));
 
 		rte_atomic_thread_fence(rte_memory_order_acquire);
-
 		descs[3] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, desc + 3), descs[3], 0);
 		descs[2] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, desc + 2), descs[2], 0);
 		descs[1] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, desc + 1), descs[1], 0);
 		descs[0] = vld1q_lane_u64(RTE_CAST_PTR(uint64_t *, desc), descs[0], 0);
 
+		{
+			uint32x4_t d0 = vreinterpretq_u32_u64(descs[0]);
+			uint32x4_t d1 = vreinterpretq_u32_u64(descs[1]);
+			uint32x4_t d2 = vreinterpretq_u32_u64(descs[2]);
+			uint32x4_t d3 = vreinterpretq_u32_u64(descs[3]);
+
+			uint32x4_t q1_01 = vzip2q_u32(d0, d1);
+			uint32x4_t q1_23 = vzip2q_u32(d2, d3);
+			uint64x2_t q1_01_64 = vreinterpretq_u64_u32(q1_01);
+			uint64x2_t q1_23_64 = vreinterpretq_u64_u32(q1_23);
+
+			desc_lo = vreinterpretq_u32_u64(vcombine_u64(vget_low_u64(q1_01_64),
+							vget_low_u64(q1_23_64)));
+			desc_hi = vreinterpretq_u32_u64(vcombine_u64(vget_high_u64(q1_01_64),
+							vget_high_u64(q1_23_64)));
+		}
+
 		mbp1 = vld1q_u64((uint64_t *)&buffer[i]);
 		mbp2 = vld1q_u64((uint64_t *)&buffer[i + 2]);
 
@@ -543,7 +543,8 @@ sxe2_rx_pkts_common_vec_neon(struct sxe2_rx_queue *rxq, struct rte_mbuf **rx_pkt
 		pkt_mb1 = vqtbl1q_u8(vreinterpretq_u8_u64(descs[0]), rvp_shuf_mask);
 
 		if (do_offload) {
-			sxe2_rx_desc_offloads_para_fill_neon(rxq, desc, descs, &rx_pkts[i]);
+			sxe2_rx_desc_offloads_para_fill_neon(rxq, desc, descs, desc_lo,
+							     desc_hi, &rx_pkts[i]);
 		} else {
 			const uint64x2_t mbuf_init = {
 				rxq->mbuf_init_value,
@@ -578,55 +579,48 @@ sxe2_rx_pkts_common_vec_neon(struct sxe2_rx_queue *rxq, struct rte_mbuf **rx_pkt
 			rte_prefetch_non_temporal(desc + SXE2_RX_NUM_PER_LOOP_NEON);
 
 		{
-			uint32x4_t d0 = vreinterpretq_u32_u64(descs[0]);
-			uint32x4_t d1 = vreinterpretq_u32_u64(descs[1]);
-			uint32x4_t d2 = vreinterpretq_u32_u64(descs[2]);
-			uint32x4_t d3 = vreinterpretq_u32_u64(descs[3]);
-			uint32x4_t sterr_tmp1 = vzip2q_u32(d1, d0);
-			uint32x4_t sterr_tmp2 = vzip2q_u32(d3, d2);
-			uint32x4_t sterr_u32 = vzip1q_u32(sterr_tmp1, sterr_tmp2);
-
-			staterr = vreinterpretq_u16_u32(sterr_u32);
+			uint16x8_t sterr_tmp1 = vzip2q_u16(vreinterpretq_u16_u64(descs[0]),
+							   vreinterpretq_u16_u64(descs[2]));
+			uint16x8_t sterr_tmp2 = vzip2q_u16(vreinterpretq_u16_u64(descs[1]),
+							   vreinterpretq_u16_u64(descs[3]));
+			staterr = vzip1q_u16(sterr_tmp1, sterr_tmp2);
 		}
 
-		sxe2_rx_desc_ptype_fill_neon(staterr, &rx_pkts[i]);
+		sxe2_rx_desc_ptype_fill_neon(desc_lo, &rx_pkts[i], sxe2_ptype_tbl);
 
 		if (umbcast_flags != NULL) {
-			uint32x4_t umbcast_mask = {
-				SXE2_RX_DESC_STATUS_UMBCAST_MASK, SXE2_RX_DESC_STATUS_UMBCAST_MASK,
-				SXE2_RX_DESC_STATUS_UMBCAST_MASK, SXE2_RX_DESC_STATUS_UMBCAST_MASK,
-			};
-
+			const uint32x4_t umbcast_mask =
+				vdupq_n_u32(SXE2_RX_DESC_STATUS_UMBCAST_MASK);
 			uint8x16_t umbcast_shuf_mask = {
-				0x0B, 0x03, 0x0F, 0x07,
+				3, 7, 11, 15,
 				0xFF, 0xFF, 0xFF, 0xFF,
 				0xFF, 0xFF, 0xFF, 0xFF,
 				0xFF, 0xFF, 0xFF, 0xFF,
 			};
 			uint8x16_t umbcast_bits =
-				vreinterpretq_u8_u32(vandq_u32(vreinterpretq_u32_u16(staterr),
-							       umbcast_mask));
+				vreinterpretq_u8_u32(vandq_u32(desc_lo, umbcast_mask));
 
 			umbcast_bits = vqtbl1q_u8(umbcast_bits, umbcast_shuf_mask);
-			vst1q_lane_u32((uint32_t *)umbcast_flags,
-					vreinterpretq_u32_u8(umbcast_bits), 0);
+			*(uint32_t *)umbcast_flags =
+				vgetq_lane_u32(vreinterpretq_u32_u8(umbcast_bits), 0);
 			umbcast_flags += SXE2_RX_NUM_PER_LOOP_NEON;
 		}
 
 		if (split_rxe_flags) {
 			uint8x16_t eop_shuf_mask = {
-					0x08, 0x00, 0x0C, 0x04,
+					0, 2, 4, 6,
 					0xFF, 0xFF, 0xFF, 0xFF,
 					0xFF, 0xFF, 0xFF, 0xFF,
 					0xFF, 0xFF, 0xFF, 0xFF};
 			uint8x16_t eop_bits;
 			uint32x4_t rxe_mask = {
-				0x2080, 0x2080, 0x2080, 0x2080
+				0x20802080, 0x20802080, 0x20802080, 0x20802080
 			};
 			uint32x4_t rxe_bits;
 			uint32x4_t eop_mask;
 
-			eop_mask = vshlq_n_u32(vdupq_n_u32(1), SXE2_RX_DESC_STATUS_EOP_SHIFT);
+			eop_mask = vdupq_n_u32((1U << SXE2_RX_DESC_STATUS_EOP_SHIFT) |
+					(1U << (SXE2_RX_DESC_STATUS_EOP_SHIFT + 16)));
 			eop_bits = vandq_u8(vmvnq_u8(vreinterpretq_u8_u16(staterr)),
 					vreinterpretq_u8_u32(eop_mask));
 
@@ -650,12 +644,22 @@ sxe2_rx_pkts_common_vec_neon(struct sxe2_rx_queue *rxq, struct rte_mbuf **rx_pkt
 		}
 
 		{
-			uint32x4_t dd_mask = vdupq_n_u32(1);
-			uint32x4_t sterr_dd = vandq_u32(vreinterpretq_u32_u16(staterr), dd_mask);
-			uint16x4_t packed_lo = vmovn_u32(sterr_dd);
-			uint64_t dd64 = vget_lane_u64(vreinterpret_u64_u16(packed_lo), 0);
-
-			bit_num = (uint16_t)rte_popcount64(dd64);
+			const uint16x8_t dd_check = {
+				0x0001, 0x0001, 0x0001, 0x0001,
+				0, 0, 0, 0
+			};
+			uint16x8_t sterr_dd;
+			uint64_t stat;
+			sterr_dd = vandq_u16(staterr, dd_check);
+			sterr_dd = vshlq_n_u16(sterr_dd, 15);
+			sterr_dd =
+				vreinterpretq_u16_s16(vshrq_n_s16(vreinterpretq_s16_u16(sterr_dd),
+								  15));
+			stat = ~vgetq_lane_u64(vreinterpretq_u64_u16(sterr_dd), 0);
+			if (likely(stat == 0))
+				bit_num = SXE2_RX_NUM_PER_LOOP_NEON;
+			else
+				bit_num = (uint16_t)(rte_ctz64(stat) / 16);
 		}
 		done_num += bit_num;
 		if (likely(bit_num != SXE2_RX_NUM_PER_LOOP_NEON))
Signature · 1 line
2.52.0
#399 lore raw

PATCH v10 32/48 net/sxe2: refine vectorized Tx/Rx mode setup

In reply to [email protected]

From: Jie Liu <[email protected]>

Set rte_eth_tx_pkt_prepare_dummy for the simple and vectorized Tx paths instead of leaving the prepare callback unset, and split the NEON simple/offload mode selection based on the offload flag. Log the selected Tx/Rx mode flags and apply the default Rx free threshold when the configured value is zero.

Fixes ac60f302cbef ("net/sxe2: add vectorized Rx and Tx")
---
 drivers/net/sxe2/sxe2_rx.c   |  3 ++-
 drivers/net/sxe2/sxe2_txrx.c | 20 +++++++++++++++-----
 2 files changed, 17 insertions(+), 6 deletions(-)
drivers/net/sxe2/sxe2_rx.c +2 -1
index d700c60083..3830c676d7 100644
@@ -319,7 +319,8 @@ int32_t __rte_cold sxe2_rx_queue_setup(struct rte_eth_dev *dev,
 		rxq->mb_pool = mp;
 	}
 
-	rxq->rx_free_thresh = rx_conf->rx_free_thresh;
+	rxq->rx_free_thresh = (rx_conf->rx_free_thresh == 0) ?
+		SXE2_DEFAULT_RX_FREE_THRESH : rx_conf->rx_free_thresh;
 	rxq->port_id = dev->data->port_id;
 	rxq->offloads = offloads;
 	if (offloads & RTE_ETH_RX_OFFLOAD_KEEP_CRC)
drivers/net/sxe2/sxe2_txrx.c +15 -5
index 79870866d1..09f1dfe9fc 100644
@@ -358,7 +358,7 @@ void sxe2_tx_mode_func_set(struct rte_eth_dev *dev)
 	}
 
 	if (tx_mode_flags & SXE2_TX_MODE_VEC_SET_MASK) {
-		dev->tx_pkt_prepare = NULL;
+		dev->tx_pkt_prepare = rte_eth_tx_pkt_prepare_dummy;
 #ifdef RTE_ARCH_X86
 		if (tx_mode_flags & SXE2_TX_MODE_VEC_AVX512) {
 #ifdef CC_AVX512_SUPPORT
@@ -386,21 +386,28 @@ void sxe2_tx_mode_func_set(struct rte_eth_dev *dev)
 		}
 #elif defined(RTE_ARCH_ARM64)
 		if (tx_mode_flags & SXE2_TX_MODE_VEC_NEON) {
-			dev->tx_pkt_prepare = sxe2_tx_pkts_prepare;
-			dev->tx_pkt_burst = sxe2_tx_pkts_vec_neon;
+			if (tx_mode_flags & SXE2_TX_MODE_VEC_OFFLOAD) {
+				dev->tx_pkt_prepare = sxe2_tx_pkts_prepare;
+				dev->tx_pkt_burst = sxe2_tx_pkts_vec_neon;
+			} else {
+				dev->tx_pkt_burst = sxe2_tx_pkts_vec_neon_simple;
+			}
 		} else {
-			dev->tx_pkt_burst = sxe2_tx_pkts_vec_neon_simple;
+			dev->tx_pkt_prepare = sxe2_tx_pkts_prepare;
+			dev->tx_pkt_burst = sxe2_tx_pkts;
 		}
 #endif
 	} else {
 		if (tx_mode_flags & SXE2_TX_MODE_SIMPLE_BATCH) {
-			dev->tx_pkt_prepare = NULL;
+			dev->tx_pkt_prepare = rte_eth_tx_pkt_prepare_dummy;
 			dev->tx_pkt_burst = sxe2_tx_pkts_simple;
 		} else {
 			dev->tx_pkt_prepare = sxe2_tx_pkts_prepare;
 			dev->tx_pkt_burst = sxe2_tx_pkts;
 		}
 	}
+	PMD_LOG_DEBUG(TX, "Tx mode flags:0x%08x port_id:%u.",
+				tx_mode_flags, dev->data->port_id);
 }
 
 static const struct {
@@ -582,6 +589,9 @@ void sxe2_rx_mode_func_set(struct rte_eth_dev *dev)
 		dev->rx_pkt_burst = sxe2_rx_pkts_scattered_split;
 	else
 		dev->rx_pkt_burst = sxe2_rx_pkts_scattered;
+
+	PMD_LOG_DEBUG(RX, "Rx mode flags:0x%08x port_id:%u.",
+				rx_mode_flags, dev->data->port_id);
 }
 
 static const struct {
Signature · 1 line
2.52.0
#400 lore raw

PATCH v10 33/48 net/sxe2: fix RSS action attribute validation

In reply to [email protected]

From: Jie Liu <[email protected]>

The rss->level/key_len/queue_num checks only set the rte_flow_error but still return 0 (success), so invalid RSS configurations are accepted instead of being rejected with ENOTSUP.

Return the error code from the validation checks, matching the behavior in the V3 implementation.

Fixes 635084db5d57 ("net/sxe2: support VF representors")
---
 drivers/net/sxe2/sxe2_flow_parse_action.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/net/sxe2/sxe2_flow_parse_action.c +10 -4
index 03ada4e8a6..65ddfeb47f 100644
@@ -12,7 +12,7 @@
 static int32_t sxe2_flow_check_rss_action_attr(const struct rte_flow_action_rss *rss,
 					   struct rte_flow_error *error)
 {
-	int32_t ret = ENOTSUP;
+	int32_t ret = -ENOTSUP;
 	switch (rss->func) {
 	case RTE_ETH_HASH_FUNCTION_DEFAULT:
 	case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
@@ -25,15 +25,21 @@ static int32_t sxe2_flow_check_rss_action_attr(const struct rte_flow_action_rss
 		goto l_end;
 	}
 
-	if (rss->level > 2)
+	if (rss->level > 2) {
 		rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, NULL,
 			"RSS  level is could not be greater than 2");
-	if (rss->key_len)
+		goto l_end;
+	}
+	if (rss->key_len) {
 		rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, NULL,
 			"a nonzero RSS key_len is not supported");
-	if (rss->queue_num)
+		goto l_end;
+	}
+	if (rss->queue_num) {
 		rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, NULL,
 			"a non-NULL RSS queue is not supported");
+		goto l_end;
+	}
 	ret = 0;
 l_end:
 	return ret;
Signature · 1 line
2.52.0
#401 lore raw

PATCH v10 34/48 net/sxe2: restore PF-only guard in UDP tunnel port add

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_udp_tunnel_port_add_common() lost the check that restricts UDP tunnel port configuration to PF devices (not VF or representor), so VF/representor devices can now attempt to add UDP tunnel ports, which the hardware does not support.

Restore the PF-only guard returning -ENOTSUP, matching the V3 implementation.

Fixes fff24885f70a ("net/sxe2: support custom UDP tunnel ports")
---
 drivers/net/sxe2/sxe2_ethdev.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/net/sxe2/sxe2_ethdev.c +11 -0
index ea589c7eaa..82ad6e660a 100644
@@ -630,6 +630,10 @@ int32_t sxe2_udp_tunnel_port_add_common(struct sxe2_adapter *ad,
 	struct sxe2_udp_tunnel_cfg *tunnel_config;
 	int32_t ret = -1;
 
+	if (ad->dev_type != SXE2_DEV_T_PF || ad->is_dev_repr) {
+		ret = -ENOTSUP;
+		goto l_end;
+	}
 	rte_spinlock_lock(&ad->udp_tunnel_ctx.lock);
 
 	tunnel_config = &ad->udp_tunnel_ctx.tunnel_conf[tunnel_proto];
@@ -659,6 +663,7 @@ int32_t sxe2_udp_tunnel_port_add_common(struct sxe2_adapter *ad,
 
 l_unlock_end:
 	rte_spinlock_unlock(&ad->udp_tunnel_ctx.lock);
+l_end:
 	return ret;
 }
 
@@ -669,6 +674,9 @@ int32_t sxe2_udp_tunnel_port_del_common(struct sxe2_adapter *ad,
 	struct sxe2_udp_tunnel_cfg *tunnel_config;
 	int32_t ret = -1;
 
+	if (ad->dev_type != SXE2_DEV_T_PF || ad->is_dev_repr)
+		return -ENOTSUP;
+
 	rte_spinlock_lock(&ad->udp_tunnel_ctx.lock);
 	tunnel_config = &ad->udp_tunnel_ctx.tunnel_conf[tunnel_proto];
 
@@ -703,6 +711,9 @@ static int32_t sxe2_udp_tunnel_port_clear(struct rte_eth_dev *dev)
 	int32_t ret = 0;
 	uint16_t tunnel_proto = 0;
 
+	if (ad->dev_type != SXE2_DEV_T_PF || ad->is_dev_repr)
+		return -ENOTSUP;
+
 	rte_spinlock_lock(&ad->udp_tunnel_ctx.lock);
 
 	for (tunnel_proto = 0; tunnel_proto < SXE2_UDP_TUNNEL_MAX; tunnel_proto++) {
Signature · 1 line
2.52.0
#402 lore raw

PATCH v10 35/48 net/sxe2: refresh link state on link change events

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_link_update() was only called during device init, so the ethdev link state was not refreshed when link status changed at runtime.

Call sxe2_link_update() in the link-change IRQ handler for both the PF and its representors, so the link state is updated on LSC events. Keep the sxe2_link_update() call in sxe2_link_update_init(), now conditional on a successful link status read, so the initial link state is still populated at init.

Fixes 1d7fd921beef ("net/sxe2: support link update")
---
 drivers/net/sxe2/sxe2_irq.c |  2 ++
 drivers/net/sxe2/sxe2_mac.c | 11 +++--------
 2 files changed, 5 insertions(+), 8 deletions(-)
drivers/net/sxe2/sxe2_irq.c +2 -0
index ba764dd5e4..4c3a29900d 100644
@@ -84,6 +84,7 @@ static void sxe2_event_irq_common_handler(struct sxe2_adapter *adapter, uint64_t
 	if (oicr & RTE_BIT32(SXE2_COM_EC_LINK_CHG)) {
 		PMD_DEV_LOG_INFO(adapter, DRV, "OICR=0x%" PRIx64, oicr);
 		(void)sxe2_drv_mac_link_status_get(adapter);
+		(void)sxe2_link_update(dev, 0);
 		if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 			rte_eth_dev_callback_process(dev,
 						     RTE_ETH_EVENT_INTR_LSC,
@@ -96,6 +97,7 @@ static void sxe2_event_irq_common_handler(struct sxe2_adapter *adapter, uint64_t
 					continue;
 				repr_adapter = SXE2_DEV_PRIVATE_TO_ADAPTER(repr_eth_dev);
 				(void)sxe2_drv_mac_link_status_get(repr_adapter);
+				(void)sxe2_link_update(repr_eth_dev, 0);
 				if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 					rte_eth_dev_callback_process(repr_eth_dev,
 								     RTE_ETH_EVENT_INTR_LSC,
drivers/net/sxe2/sxe2_mac.c +3 -8
index 729c804ac3..ab9bd5355b 100644
@@ -448,18 +448,13 @@ int32_t sxe2_link_update_init(struct rte_eth_dev *dev)
 	int32_t ret;
 
 	PMD_INIT_FUNC_TRACE();
-
 	rte_spinlock_init(&adapter->link_ctxt.link_lock);
-
 	ret = sxe2_drv_mac_link_status_get(adapter);
-	if (ret) {
+	if (ret)
 		PMD_DEV_LOG_ERR(adapter, DRV, "Failed to get link status, ret=%d", ret);
-		goto l_end;
-	}
-
-	(void)sxe2_link_update(dev, 0);
+	else
+		(void)sxe2_link_update(dev, 0);
 
-l_end:
 	return ret;
 }
 int32_t sxe2_link_update(struct rte_eth_dev *dev, __rte_unused int32_t wait_to_complete)
Signature · 1 line
2.52.0
#403 lore raw

PATCH v10 36/48 net/sxe2: validate representor ID against VF count

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_switchdev_repr_private_data_init() indexes parent_adapter->repr_ctxt.repr_vf_id[repr_id] without checking that repr_id is within the number of configured VFs, which can access out of bounds when an invalid representor ID is passed.

Add a bounds check on repr_id against repr_ctxt.nb_vf and return -EINVAL on the error path.

Fixes 635084db5d57 ("net/sxe2: support VF representors")
---
 drivers/net/sxe2/sxe2_switchdev.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/sxe2/sxe2_switchdev.c +6 -0
index efb1468b91..d0304ccc94 100644
@@ -312,6 +312,12 @@ int32_t sxe2_switchdev_repr_private_data_init(struct rte_eth_dev *dev,
 	repr_priv_data->repr_q_id = repr_id;
 	repr_priv_data->repr_pf_id = parent_adapter->pf_idx;
 	repr_priv_data->repr_vf_id = repr_id;
+	if (repr_id >= parent_adapter->repr_ctxt.nb_vf) {
+		PMD_LOG_ERR(INIT, "repr_id %u exceed max vf %u",
+			repr_id, parent_adapter->repr_ctxt.nb_vf);
+		ret = -EINVAL;
+		goto l_free;
+	}
 	repr_priv_data->repr_vf_primary_vsi_id =
 		parent_adapter->repr_ctxt.repr_vf_id[repr_id].kernel_vsi_id;
 	repr_priv_data->repr_vf_backup_vsi_id =
Signature · 1 line
2.52.0
#404 lore raw

PATCH v10 37/48 net/sxe2: use primary VSI ID for representor VSI

In reply to [email protected]

From: Jie Liu <[email protected]>

For repr_vf_vsi_id, use the primary VSI id directly instead of falling back to the DPDK VSI id when the kernel VSI id is invalid. The kernel side guarantees the primary VSI id it provides is always valid in any scenario, so the fallback ternary is unnecessary.

---
 drivers/net/sxe2/sxe2_switchdev.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/net/sxe2/sxe2_switchdev.c +1 -4
index d0304ccc94..466182c55c 100644
@@ -324,10 +324,7 @@ int32_t sxe2_switchdev_repr_private_data_init(struct rte_eth_dev *dev,
 		parent_adapter->repr_ctxt.repr_vf_id[repr_id].dpdk_vsi_id;
 
 	repr_priv_data->repr_vf_vsi_id =
-		parent_adapter->repr_ctxt.repr_vf_id[repr_id].kernel_vsi_id !=
-		SXE2_INVALID_VSI_ID ?
-		parent_adapter->repr_ctxt.repr_vf_id[repr_id].kernel_vsi_id :
-		parent_adapter->repr_ctxt.repr_vf_id[repr_id].dpdk_vsi_id;
+		repr_priv_data->repr_vf_primary_vsi_id;
 
 	adapter->repr_priv_data = repr_priv_data;
 	goto l_end;
Signature · 1 line
2.52.0
#405 lore raw

PATCH v10 38/48 net/sxe2: wrap command params fill debug log in macro

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_drv_cmd_params_fill() passes the opcode string as a parameter to __sxe2_drv_cmd_params_fill() just to emit a debug log. The debug log is level-gated by PMD_DEV_LOG_DEBUG either way; moving it into the macro body only consolidates the call sites.

Wrap the log and the fill helper in a do/while block, dropping the opc_str parameter so the opcode stringization happens at the call site. Evaluate the adapter argument exactly once through a local variable.

---
 drivers/net/sxe2/sxe2_cmd_chnl.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/sxe2/sxe2_cmd_chnl.c +6 -4
index 3a55528c44..85098ac664 100644
@@ -26,10 +26,9 @@ static void sxe2_drv_trace_id_alloc(uint64_t *trace_id)
 }
 
 static void __sxe2_drv_cmd_params_fill(struct sxe2_adapter *adapter,
-		struct sxe2_drv_cmd_params *cmd, uint32_t opc, const char *opc_str,
+		struct sxe2_drv_cmd_params *cmd, uint32_t opc,
 		void *in_data, uint32_t in_len, void *out_data, uint32_t out_len)
 {
-	PMD_DEV_LOG_DEBUG(adapter, DRV, "cmd opcode:%s", opc_str);
 	cmd->timeout = SXE2_DRV_CMD_DFLT_TIMEOUT;
 	cmd->opcode  = opc;
 	cmd->vsi_id  = adapter->vsi_ctxt.dpdk_vsi_id;
@@ -44,8 +43,11 @@ static void __sxe2_drv_cmd_params_fill(struct sxe2_adapter *adapter,
 }
 
 #define sxe2_drv_cmd_params_fill(adapter, cmd, opc, in_data, in_len, out_data, out_len) \
-	__sxe2_drv_cmd_params_fill(adapter, cmd, opc, #opc, in_data, in_len, out_data, out_len)
-
+	do { \
+		struct sxe2_adapter *_ad = (adapter); \
+		PMD_DEV_LOG_DEBUG(_ad, DRV, "cmd opcode:%s", #opc); \
+		__sxe2_drv_cmd_params_fill(_ad, cmd, opc, in_data, in_len, out_data, out_len); \
+	} while (0)
 
 int32_t sxe2_drv_dev_caps_get(struct sxe2_adapter *adapter, struct sxe2_drv_dev_caps_resp *dev_caps)
 {
Signature · 1 line
2.52.0
#406 lore raw

PATCH v10 39/48 net/sxe2: restore Rx queue buffer split fill support

In reply to [email protected]

From: Jie Liu <[email protected]>

The V4 branch dropped sxe2_rxq_buf_split_fill() and the buffer split handling in sxe2_rxq_ctxt_cfg_fill(), so the Rx buffer split offload (RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) is advertised in device info but the per-queue context never configures split_en/split_type_mask/ hdr_len, and buffer split packets are not handled correctly.

Restore the sxe2_rxq_buf_split_fill() helper and the buffer split branch in sxe2_rxq_ctxt_cfg_fill(), matching the V3 implementation.

Fixes d8e4e075acb4 ("net/sxe2: add probing skeleton")
---
 drivers/net/sxe2/sxe2_cmd_chnl.c | 88 ++++++++++++++++++++++++++++++++
 1 file changed, 88 insertions(+)
drivers/net/sxe2/sxe2_cmd_chnl.c +88 -0
index 85098ac664..7b27cf2e8d 100644
@@ -195,6 +195,84 @@ int32_t sxe2_drv_vsi_del(struct sxe2_adapter *adapter, struct sxe2_vsi *vsi)
 #define SXE2_RXQ_CTXT_CFG_BUF_LEN_ALIGN  (1 << 7)
 #define SXE2_RX_HDR_SIZE 256
 
+static int32_t sxe2_rxq_buf_split_fill(struct sxe2_rx_queue *rxq,
+				   struct sxe2_drv_rxq_ctxt *ctxt)
+{
+	uint32_t proto_hdr;
+
+	proto_hdr = rxq->rx_seg[0].proto_hdr;
+	if (proto_hdr == RTE_PTYPE_UNKNOWN) {
+		PMD_LOG_ERR(RX, "Buffer split protocol must be configured");
+		return -EINVAL;
+	}
+
+	switch (proto_hdr & RTE_PTYPE_L4_MASK) {
+	case RTE_PTYPE_L4_TCP:
+		ctxt->split_type_mask = SXE2_PTYPE_L4_TCP;
+		goto l_end;
+	case RTE_PTYPE_L4_UDP:
+		ctxt->split_type_mask = SXE2_PTYPE_L4_UDP;
+		goto l_end;
+	case RTE_PTYPE_L4_SCTP:
+		ctxt->split_type_mask = SXE2_PTYPE_L4_SCTP;
+		goto l_end;
+	}
+
+	switch (proto_hdr & RTE_PTYPE_L3_MASK) {
+	case RTE_PTYPE_L3_IPV4_EXT_UNKNOWN:
+		ctxt->split_type_mask = SXE2_PTYPE_L3_IPV4;
+		goto l_end;
+	case RTE_PTYPE_L3_IPV6_EXT_UNKNOWN:
+		ctxt->split_type_mask = SXE2_PTYPE_L3_IPV6;
+		goto l_end;
+	}
+
+	switch (proto_hdr & RTE_PTYPE_L2_MASK) {
+	case RTE_PTYPE_L2_ETHER:
+		ctxt->split_type_mask = SXE2_PTYPE_L2_ETHER;
+		goto l_end;
+	}
+
+	switch (proto_hdr & RTE_PTYPE_INNER_L4_MASK) {
+	case RTE_PTYPE_INNER_L4_TCP:
+		ctxt->split_type_mask = SXE2_PTYPE_INNER_L4_TCP;
+		goto l_end;
+	case RTE_PTYPE_INNER_L4_UDP:
+		ctxt->split_type_mask = SXE2_PTYPE_INNER_L4_UDP;
+		goto l_end;
+	case RTE_PTYPE_INNER_L4_SCTP:
+		ctxt->split_type_mask = SXE2_PTYPE_INNER_L4_SCTP;
+		goto l_end;
+	}
+
+	switch (proto_hdr & RTE_PTYPE_INNER_L3_MASK) {
+	case RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN:
+		ctxt->split_type_mask = SXE2_PTYPE_INNER_L3_IPV4;
+		goto l_end;
+	case RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN:
+		ctxt->split_type_mask = SXE2_PTYPE_INNER_L3_IPV6;
+		goto l_end;
+	}
+
+	switch (proto_hdr & RTE_PTYPE_INNER_L2_MASK) {
+	case RTE_PTYPE_INNER_L2_ETHER:
+		ctxt->split_type_mask = SXE2_PTYPE_INNER_L2_ETHER;
+		goto l_end;
+	}
+
+	switch (proto_hdr & RTE_PTYPE_TUNNEL_MASK) {
+	case RTE_PTYPE_TUNNEL_GRENAT:
+		ctxt->split_type_mask = SXE2_PTYPE_TUNNEL_GRENAT;
+		goto l_end;
+	}
+
+	PMD_LOG_ERR(RX, "Buffer split protocol is not supported");
+	return -ENOTSUP;
+l_end:
+	ctxt->hdr_len = SXE2_RX_HDR_SIZE;
+	return 0;
+}
+
 static int32_t sxe2_rxq_ctxt_cfg_fill(struct sxe2_rx_queue *rxq,
 		struct sxe2_drv_rxq_cfg_req *req, uint16_t rxq_cnt)
 {
@@ -228,7 +306,17 @@ static int32_t sxe2_rxq_ctxt_cfg_fill(struct sxe2_rx_queue *rxq,
 	else
 		ctxt->keep_crc_en = 0;
 
+	if (rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) {
+		ret = sxe2_rxq_buf_split_fill(rxq, ctxt);
+		if (ret)
+			goto l_end;
+		ctxt->split_en = 1;
+	} else {
+		ctxt->split_en = 0;
+	}
+
 	ctxt->desc_size = sizeof(union sxe2_rx_desc);
+l_end:
 	return ret;
 }
 
Signature · 1 line
2.52.0
#407 lore raw

PATCH v10 40/48 net/sxe2: skip tunnel config fill on get failure

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_drv_udp_tunnel_get() fills tunnel_config fields even when the firmware command fails, so a failed get overwrites the config with the (zero-initialized) response data instead of leaving it intact.

Return early with the error code when sxe2_drv_cmd_exec() fails, matching the V3 implementation.

Fixes fff24885f70a ("net/sxe2: support custom UDP tunnel ports")
---
 drivers/net/sxe2/sxe2_cmd_chnl.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/sxe2/sxe2_cmd_chnl.c +4 -2
index 7b27cf2e8d..5ab287a77b 100644
@@ -1650,15 +1650,17 @@ int32_t sxe2_drv_udp_tunnel_get(struct sxe2_adapter *adapter,
 				 &req, sizeof(req),
 				 &resp, sizeof(resp));
 	ret = sxe2_drv_cmd_exec(cdev, &cmd);
-	if (ret)
+	if (ret) {
 		PMD_LOG_ERR(DRV, "Failed to get udp proto %d port, ret=%d", req.type, ret);
+		goto l_end;
+	}
 
 	tunnel_config->fw_port   = resp.port;
 	tunnel_config->fw_status = resp.enable;
 	tunnel_config->fw_dst_en = resp.dst;
 	tunnel_config->fw_src_en = resp.src;
 	tunnel_config->fw_used   = resp.fw_used;
-
+l_end:
 	return ret;
 }
 
Signature · 1 line
2.52.0
#408 lore raw

PATCH v10 41/48 net/sxe2: skip flow ID assignment on filter add failure

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_drv_flow_filter_add() assigns flow->flow_id from the response even when the firmware command fails, overwriting any previously set flow id with the zero-initialized response value.

Return early on command failure so flow->flow_id is preserved, and set flow->create_err on both the success and error paths.

Fixes 635084db5d57 ("net/sxe2: support VF representors")
---
 drivers/net/sxe2/sxe2_cmd_chnl.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/sxe2/sxe2_cmd_chnl.c +5 -1
index 5ab287a77b..6a5c1907c2 100644
@@ -1818,9 +1818,13 @@ int32_t sxe2_drv_flow_filter_add(struct sxe2_adapter *adapter, struct sxe2_flow
 	sxe2_drv_cmd_params_fill(adapter, &cmd, SXE2_DRV_CMD_FLOW_FILTER_ADD, &req,
 			   sizeof(req), &resp, sizeof(resp));
 	ret = sxe2_drv_cmd_exec(cdev, &cmd);
-	if (ret)
+	if (ret) {
 		PMD_DEV_LOG_ERR(adapter, DRV, "Failed to add flow filter, ret: %d.", ret);
+		goto l_end;
+	}
 	flow->flow_id = resp.flow_id;
+
+l_end:
 	flow->create_err = ret;
 	return ret;
 }
Signature · 1 line
2.52.0
#409 lore raw

PATCH v10 42/48 net/sxe2: correct command channel log messages

In reply to [email protected]

From: Jie Liu <[email protected]>

Several error/warning messages in sxe2_cmd_chnl.c are inaccurate or lost context:

- vsi_info_get: message lost the vsi id; restore it
- rxq_bind_irq/rxq_unbind_irq: message lost the rxq index; restore it
- promisc_config: fix "promic" typo in the message
- queue_info_get_update: use "tx/rx queue map get failed" wording
- rxq_mapping_set: incorrect "get dev caps" wording; use "rx queue mapping failed"
- txq_mapping_set: "Rx queue" should read "Tx queue"; incorrect "get dev caps" wording should read "tx queue mapping failed"

---
 drivers/net/sxe2/sxe2_cmd_chnl.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/net/sxe2/sxe2_cmd_chnl.c +8 -8
index 6a5c1907c2..65e3a4ca21 100644
@@ -481,7 +481,7 @@ int32_t sxe2_drv_vsi_info_get(struct sxe2_adapter *adapter, struct sxe2_vsi *vsi
 			&vsi_info_get_resp, sizeof(vsi_info_get_resp));
 	ret = sxe2_drv_cmd_exec(cdev, &param);
 	if (ret) {
-		PMD_DEV_LOG_ERR(adapter, DRV, "switchdev cpvsi info get failed, ret=%d", ret);
+		PMD_DEV_LOG_ERR(adapter, DRV, "vsi %u info get failed, ret=%d", vsi->vsi_id, ret);
 		goto l_end;
 	}
 
@@ -537,7 +537,7 @@ int32_t sxe2_drv_rxq_bind_irq(struct sxe2_adapter *adapter, uint16_t rxq_idx, ui
 				 NULL, 0);
 	ret = sxe2_drv_cmd_exec(cdev, &param);
 	if (ret)
-		PMD_DEV_LOG_ERR(adapter, DRV, "rxq bind irq failed, ret=%d", ret);
+		PMD_DEV_LOG_ERR(adapter, DRV, "rxq %u bind irq failed, ret=%d", rxq_idx, ret);
 
 	return ret;
 }
@@ -557,7 +557,7 @@ int32_t sxe2_drv_rxq_unbind_irq(struct sxe2_adapter *adapter, uint16_t rxq_idx)
 				 NULL, 0);
 	ret = sxe2_drv_cmd_exec(cdev, &param);
 	if (ret)
-		PMD_DEV_LOG_ERR(adapter, DRV, "rxq unbind irq failed, ret=%d", ret);
+		PMD_DEV_LOG_ERR(adapter, DRV, "rxq %u unbind irq failed, ret=%d", rxq_idx, ret);
 
 	return ret;
 }
@@ -758,7 +758,7 @@ int32_t sxe2_drv_promisc_config(struct sxe2_adapter *adapter, bool set)
 
 	ret = sxe2_drv_cmd_exec(cdev, &param);
 	if (ret)
-		PMD_DEV_LOG_WARN(adapter, DRV, "promic config failed, ret=%d", ret);
+		PMD_DEV_LOG_WARN(adapter, DRV, "promisc config failed, ret=%d", ret);
 
 	return ret;
 }
@@ -1683,7 +1683,7 @@ int32_t sxe2_drv_queue_info_get_update(struct sxe2_adapter *adapter, struct eth_
 				 &resp, sizeof(resp));
 	ret = sxe2_drv_cmd_exec(cdev, &param);
 	if (ret) {
-		PMD_LOG_ERR(DRV, "get queue info map failed, ret=%d", ret);
+		PMD_LOG_ERR(DRV, "tx/rx queue map get failed, ret=%d", ret);
 		goto l_end;
 	}
 
@@ -1727,7 +1727,7 @@ int32_t sxe2_drv_rxq_mapping_set(struct rte_eth_dev *eth_dev, uint16_t queue_id,
 
 	ret = sxe2_drv_cmd_exec(cdev, &param);
 	if (ret)
-		PMD_LOG_ERR(DRV, "get dev caps failed, ret=%d", ret);
+		PMD_LOG_ERR(DRV, "rx queue mapping failed, ret=%d", ret);
 
 l_end:
 	return ret;
@@ -1744,7 +1744,7 @@ int32_t sxe2_drv_txq_mapping_set(struct rte_eth_dev *eth_dev, uint16_t queue_id,
 
 	txq = eth_dev->data->tx_queues[queue_id];
 	if (txq == NULL) {
-		PMD_LOG_ERR(DRV, "Rx queue %u is not available or setup", queue_id);
+		PMD_LOG_ERR(DRV, "Tx queue %u is not available or setup", queue_id);
 		ret = -EINVAL;
 		goto l_end;
 	}
@@ -1758,7 +1758,7 @@ int32_t sxe2_drv_txq_mapping_set(struct rte_eth_dev *eth_dev, uint16_t queue_id,
 
 	ret = sxe2_drv_cmd_exec(cdev, &param);
 	if (ret)
-		PMD_LOG_ERR(DRV, "get dev caps failed, ret=%d", ret);
+		PMD_LOG_ERR(DRV, "tx queue mapping failed, ret=%d", ret);
 
 l_end:
 	return ret;
Signature · 1 line
2.52.0
#410 lore raw

PATCH v10 43/48 net/sxe2: align command structs with kernel layout

In reply to [email protected]

From: Jie Liu <[email protected]>

The sxe2_drv_cmd.h command structures must match the layout used by historical SXE2 kernel versions so the same firmware command ABI is shared. Several structures were declared with __rte_packed_begin/ __rte_packed_end and extra rsv padding that the kernel layout does not have:

- sxe2_drv_link_info_resp: drop rsv[3] padding (size unchanged)
- sxe2_tm_res: drop rsv[2] padding and packed attribute, reducing the TM command payload length from 4 to 2 bytes to match the historical kernel layout
- sxe2_tm_info: drop packed attribute, removing -Wpacked-not-aligned warnings
- sxe2_tm_add_mid_msg/sxe2_tm_add_queue_msg: drop packed attribute; the message sizes (16 and 20 bytes) are unchanged, but the tm info member moves to its naturally aligned offset (4 and 8)
- sxe2_drv_sfp_req/sxe2_drv_sfp_resp: drop packed attribute

Fixes 9c894f75113f ("net/sxe2: support TM hierarchy and shaping")
---
 drivers/net/sxe2/sxe2_drv_cmd.h | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)
drivers/net/sxe2/sxe2_drv_cmd.h +12 -14
index 01fd813ed1..ee9d86dd4c 100644
@@ -230,7 +230,6 @@ struct __rte_aligned(4) __rte_packed_begin sxe2_drv_vsi_info_get_resp {
 struct __rte_aligned(4) __rte_packed_begin sxe2_drv_link_info_resp {
 	uint32_t speed;
 	uint8_t status;
-	uint8_t rsv[3];
 } __rte_packed_end;
 
 struct __rte_aligned(4) __rte_packed_begin sxe2_switchdev_info {
@@ -348,31 +347,30 @@ struct __rte_aligned(4) __rte_packed_begin sxe2_rss_hf_req {
 	uint8_t rsv1[3];
 } __rte_packed_end;
 
-struct __rte_aligned(4) __rte_packed_begin sxe2_tm_res {
+struct sxe2_tm_res {
 	uint16_t teid;
-	uint8_t rsv[2];
-} __rte_packed_end;
+};
 
-struct __rte_aligned(4) __rte_packed_begin sxe2_tm_info {
+struct sxe2_tm_info {
 	uint32_t committed;
 	uint32_t peak;
 	uint8_t priority;
 	uint8_t reserve;
 	uint16_t weight;
-} __rte_packed_end;
+};
 
-struct __rte_aligned(4) __rte_packed_begin sxe2_tm_add_mid_msg {
+struct sxe2_tm_add_mid_msg {
 	uint16_t parent_teid;
 	uint8_t adj_lvl;
 	struct sxe2_tm_info info;
-} __rte_packed_end;
+};
 
-struct __rte_aligned(4) __rte_packed_begin sxe2_tm_add_queue_msg {
+struct sxe2_tm_add_queue_msg {
 	uint16_t parent_teid;
 	uint16_t queue_id;
 	uint8_t adj_lvl;
 	struct sxe2_tm_info info;
-} __rte_packed_end;
+};
 
 struct __rte_aligned(4) __rte_packed_begin sxe2_drv_ipsec_capa_resq {
 	uint16_t tx_sa_cnt;
@@ -633,7 +631,7 @@ struct __rte_aligned(4) __rte_packed_begin sxe2_drv_udp_tunnel_resp {
 	uint8_t rsv;
 } __rte_packed_end;
 
-struct __rte_aligned(4) __rte_packed_begin sxe2_drv_sfp_req {
+struct sxe2_drv_sfp_req {
 	uint8_t is_wr;
 	uint8_t is_qsfp;
 	uint16_t bus_addr;
@@ -642,14 +640,14 @@ struct __rte_aligned(4) __rte_packed_begin sxe2_drv_sfp_req {
 	uint16_t data_len;
 	uint16_t rvd;
 	uint8_t data[];
-} __rte_packed_end;
+};
 
-struct __rte_aligned(4) __rte_packed_begin sxe2_drv_sfp_resp {
+struct sxe2_drv_sfp_resp {
 	uint8_t is_wr;
 	uint8_t is_qsfp;
 	uint16_t data_len;
 	uint8_t data[];
-} __rte_packed_end;
+};
 
 enum sxe2_fc_type {
 	SXE2_FC_T_DIS = 0,
Signature · 1 line
2.52.0
#411 lore raw

PATCH v10 44/48 common/sxe2: fix ioctl channel log and close handling

In reply to [email protected]

From: Jie Liu <[email protected]>

Compare sxe2_ioctl_chnl.c against the reference implementation and correct the following discrepancies:

- sxe2_drv_dev_close: only log the closed fd when it is valid, move PMD_LOG_INFO inside the fd >= 0 check
- sxe2_drv_dev_mmap: fix swapped format arguments in the debug log (cmd_fd and bar_idx were passed in the wrong order)
- sxe2_drv_dev_dma_unmap: use PMD_LOG_ERR instead of PMD_LOG_INFO for the ioctl failure message

Fixes 83866f8d7638 ("common/sxe2: add base driver skeleton")
---
 drivers/common/sxe2/sxe2_ioctl_chnl.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/common/sxe2/sxe2_ioctl_chnl.c +8 -5
index 3e2fbf572f..9f455bd8d5 100644
@@ -107,9 +107,11 @@ sxe2_drv_dev_close(struct sxe2_common_device *cdev)
 {
 	int32_t fd = SXE2_CDEV_TO_CMD_FD(cdev);
 
-	if (fd >= 0)
+	if (fd >= 0) {
 		close(fd);
-	PMD_LOG_INFO(COM, "closed device fd=%d", fd);
+		PMD_LOG_INFO(COM, "closed device fd=%d", fd);
+	}
+
 	SXE2_CDEV_TO_CMD_FD(cdev) = SXE2_CMD_FD_INVALID;
 }
 
@@ -349,8 +351,9 @@ void
 		goto l_err;
 	}
 
-	PMD_LOG_DEBUG(COM, "fd=%d, bar idx=%d, len=%"PRIu64", src=0x%"PRIx64", offset=0x%"PRIx64"",
-		bar_idx, cmd_fd, len, offset, SXE2_COM_PCI_OFFSET_GEN(bar_idx, offset));
+	PMD_LOG_DEBUG(COM, "fd=%d, bar idx=%d, len=%"PRIu64", "
+		"offset=0x%"PRIx64", pci_offset=0x%"PRIx64"",
+		cmd_fd, bar_idx, len, offset, SXE2_COM_PCI_OFFSET_GEN(bar_idx, offset));
 
 	virt = mmap(NULL, len, PROT_READ | PROT_WRITE,
 		MAP_SHARED, cmd_fd, SXE2_COM_PCI_OFFSET_GEN(bar_idx, offset));
@@ -477,7 +480,7 @@ sxe2_drv_dev_dma_unmap(struct sxe2_common_device *cdev, uint64_t iova)
 	pthread_mutex_lock(&cdev->config.lock);
 	ret = ioctl(cmd_fd, SXE2_COM_CMD_DMA_UNMAP, &cmd_params);
 	if (ret < 0) {
-		PMD_LOG_INFO(COM, "Failed to dma unmap, fd=%d, ret=%d, err:%s",
+		PMD_LOG_ERR(COM, "Failed to dma unmap, fd=%d, ret=%d, err:%s",
 				cmd_fd, ret, strerror(errno));
 		ret = -EIO;
 		pthread_mutex_unlock(&cdev->config.lock);
Signature · 1 line
2.52.0
#412 lore raw

PATCH v10 45/48 doc/sxe2: remove drv-SW-stats parameter documentation

In reply to [email protected]

From: Jie Liu <[email protected]>

The drv-sw-stats devarg is no longer supported. Remove its parameter description from the Runtime Configuration section. The "Receive Software Statistics" xstats section is kept because the rx_sw_* counters are still accumulated in the Rx data path and reported through rte_eth_xstats_get().

Fixes 9e95b2b3859c ("doc: update sxe2 guide and features")
---
 doc/guides/nics/sxe2.rst | 31 ++-----------------------------
 1 file changed, 2 insertions(+), 29 deletions(-)
doc/guides/nics/sxe2.rst +2 -29
index c5b400a8ba..fe4f9f916b 100644
@@ -109,30 +109,6 @@ Runtime Configuration
 
   Default value is 3 (count both packets and bytes).
 
-- ``drv-sw-stats`` parameter [int]
-
-  This parameter controls whether per-packet software statistics (SW stats)
-  are collected in the Rx data path.
-
-  Hardware packet statistic counters may be inaccurate for certain packet types
-  due to hardware design limitations.
-  When accuracy of Rx packet classification statistics is critical,
-  enabling this parameter allows the driver to accumulate statistics in software
-  as packets are received, providing an alternative statistical path
-  that bypasses hardware counter inaccuracies.
-
-  - 0: Disable software statistics collection (default).
-    The basic port statistics (``ipackets``, ``ibytes``) are reported
-    from the hardware counters.
-  - 1: Enable software statistics collection.
-    Per-packet software statistics are accumulated for unicast,
-    multicast, broadcast, and dropped packets in the Rx data path.
-
-  When enabled, the following extended statistics (xstats) are available:
-  ``rx_sw_unicast_packets``, ``rx_sw_multicast_packets``,
-  ``rx_sw_broadcast_packets``, ``rx_sw_drop_packets``,
-  and ``rx_sw_drop_bytes``.
-
 - ``no-sched-mode`` parameter [int]
 
   This parameter enables non-scheduling mode (no-sched mode).
@@ -208,8 +184,7 @@ reflect the actual packets processed by the driver.
 
 Receive Software Statistics
   These counters are collected in the Rx data path
-  when ``drv-sw-stats=1`` is configured (see the ``drv-sw-stats`` devarg above).
-  When ``drv-sw-stats`` is disabled (default), these xstats report zero.
+  on every received packet.
 
   - ``rx_sw_unicast_packets``: Number of unicast packets received.
   - ``rx_sw_multicast_packets``: Number of multicast packets received.
@@ -217,10 +192,8 @@ Receive Software Statistics
   - ``rx_sw_drop_packets``: Number of packets dropped in the Rx data path.
   - ``rx_sw_drop_bytes``: Number of bytes dropped in the Rx data path.
 
-  When ``drv-sw-stats`` is enabled, the basic counters
-  ``ipackets`` and ``ibytes`` (from ``rte_eth_stats``)
+  The basic counters ``ipackets`` and ``ibytes`` (from ``rte_eth_stats``)
   also reflect the software-accumulated packet and byte counts.
-  Otherwise, they are reported from hardware counters.
 
 Fnav Flow Engine Statistics
   The Fnav flow engine statistics type is controlled by
Signature · 1 line
2.52.0
#413 lore raw

PATCH v10 46/48 net/sxe2: remove ineffective representor queue counts

In reply to [email protected]

From: Jie Liu <[email protected]>

rte_eth_dev_info_get() overwrites dev_info->nb_rx_queues and dev_info->nb_tx_queues from dev->data after the PMD dev_infos_get callback returns, so assigning them in sxe2_repr_dev_infos_get() has no effect. Remove the ineffective assignments.

Fixes 635084db5d57 ("net/sxe2: support VF representors")
---
 drivers/net/sxe2/sxe2_ethdev_repr.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/sxe2/sxe2_ethdev_repr.c +1 -3
index 6f5642ad5d..880a54bea8 100644
@@ -127,7 +127,7 @@ static int32_t sxe2_repr_dev_close(struct rte_eth_dev *dev)
 	return 0;
 }
 
-static int32_t sxe2_repr_dev_infos_get(struct rte_eth_dev *dev,
+static int32_t sxe2_repr_dev_infos_get(__rte_unused struct rte_eth_dev *dev,
 			struct rte_eth_dev_info *dev_info)
 {
 	dev_info->max_rx_queues = 1;
@@ -195,8 +195,6 @@ static int32_t sxe2_repr_dev_infos_get(struct rte_eth_dev *dev,
 	dev_info->speed_capa = RTE_ETH_LINK_SPEED_10G | RTE_ETH_LINK_SPEED_25G |
 			 RTE_ETH_LINK_SPEED_50G | RTE_ETH_LINK_SPEED_100G;
 
-	dev_info->nb_rx_queues = dev->data->nb_rx_queues;
-	dev_info->nb_tx_queues = dev->data->nb_tx_queues;
 
 	dev_info->default_rxportconf.burst_size = SXE2_RX_MAX_BURST;
 	dev_info->default_txportconf.burst_size = SXE2_TX_MAX_BURST;
Signature · 1 line
2.52.0
#414 lore raw

PATCH v10 47/48 net/sxe2: fix VEC mode selection in mode set functions

In reply to [email protected]

From: Jie Liu <[email protected]>

The Tx/Rx mode set functions pre-assigned tx_mode_flags/rx_mode_flags from vec_flags (SXE2_{TX,RX}_MODE_VEC_SIMPLE or _VEC_OFFLOAD) before the per-ISA capability checks. As SXE2_{TX,RX}_MODE_VEC_SET_MASK includes the SIMPLE and OFFLOAD bits, the subsequent "(flags & SET_MASK) == 0" guards never matched, so the AVX2 and SSE VEC mode bits were never set and the vectorized path fell back to SSE even when AVX2 was available.

Remove the pre-assignment and OR in "vec_flags | MODE" at each ISA selection branch so the correct VEC mode bit is selected on every architecture.

Fixes ac60f302cbef ("net/sxe2: add vectorized Rx and Tx")
---
 drivers/net/sxe2/sxe2_txrx.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/net/sxe2/sxe2_txrx.c +6 -8
index 09f1dfe9fc..eb1092714a 100644
@@ -319,13 +319,12 @@ void sxe2_tx_mode_func_set(struct rte_eth_dev *dev)
 		ret = sxe2_tx_vec_support_check(dev, &vec_flags);
 		if (ret == 0 &&
 		    rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128) {
-			tx_mode_flags = vec_flags;
 #ifdef RTE_ARCH_X86
 			if ((rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512) &&
 			    (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1) &&
 			    (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512BW) == 1)) {
 #ifdef CC_AVX512_SUPPORT
-				tx_mode_flags |= SXE2_TX_MODE_VEC_AVX512;
+				tx_mode_flags |= (vec_flags | SXE2_TX_MODE_VEC_AVX512);
 #else
 				PMD_LOG_INFO(TX, "AVX512 is not supported in build env.");
 #endif
@@ -334,10 +333,10 @@ void sxe2_tx_mode_func_set(struct rte_eth_dev *dev)
 			    ((rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2) == 1) ||
 			    (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1)) &&
 			    (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_256))
-				tx_mode_flags |= SXE2_TX_MODE_VEC_AVX2;
+				tx_mode_flags |= (vec_flags | SXE2_TX_MODE_VEC_AVX2);
 
 			if ((0 == (tx_mode_flags & SXE2_TX_MODE_VEC_SET_MASK)))
-				tx_mode_flags |=  SXE2_TX_MODE_VEC_SSE;
+				tx_mode_flags |= (vec_flags | SXE2_TX_MODE_VEC_SSE);
 #elif defined(RTE_ARCH_ARM64)
 			if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_NEON) == 1)
 				tx_mode_flags |= (vec_flags | SXE2_TX_MODE_VEC_NEON);
@@ -520,13 +519,12 @@ void sxe2_rx_mode_func_set(struct rte_eth_dev *dev)
 		ret = sxe2_rx_vec_support_check(dev, &vec_flags);
 		if (ret == 0 &&
 		    rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128) {
-			rx_mode_flags = vec_flags;
 #ifdef RTE_ARCH_X86
 			if ((rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512) &&
 				(rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1) &&
 				(rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512BW) == 1)) {
 #ifdef CC_AVX512_SUPPORT
-				rx_mode_flags |= SXE2_RX_MODE_VEC_AVX512;
+				rx_mode_flags |= (vec_flags | SXE2_RX_MODE_VEC_AVX512);
 #else
 				PMD_LOG_INFO(RX, "AVX512 support detected but not enabled");
 #endif
@@ -535,11 +533,11 @@ void sxe2_rx_mode_func_set(struct rte_eth_dev *dev)
 				((rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2) == 1) ||
 				(rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1)) &&
 				(rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_256))
-				rx_mode_flags |= SXE2_RX_MODE_VEC_AVX2;
+				rx_mode_flags |= (vec_flags | SXE2_RX_MODE_VEC_AVX2);
 
 			if (((rx_mode_flags & SXE2_RX_MODE_VEC_SET_MASK) == 0) &&
 				rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128)
-				rx_mode_flags |= SXE2_RX_MODE_VEC_SSE;
+				rx_mode_flags |= (vec_flags | SXE2_RX_MODE_VEC_SSE);
 
 #elif defined(RTE_ARCH_ARM64)
 			if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_NEON) == 1) {
Signature · 1 line
2.52.0
#415 lore raw

PATCH v10 48/48 net/sxe2: fix devargs parse error check for representors

In reply to [email protected]

From: Jie Liu <[email protected]>

rte_eth_devargs_parse() returns a positive value (the number of representor ports) when a representor is specified in the device string, and a negative value on error. The old check treated any non-zero return as an error, so probing a representor device always failed.

Only treat a negative return as an error, so the positive representor count is not misreported.

Fixes d8e4e075acb4 ("net/sxe2: add probing skeleton")
---
 drivers/net/sxe2/sxe2_ethdev.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/sxe2/sxe2_ethdev.c +4 -4
index 82ad6e660a..abbec09cc2 100644
@@ -2316,10 +2316,10 @@ static int32_t sxe2_parse_eth_devargs(struct rte_device *dev,
 		ret = rte_eth_devargs_parse(dev->devargs->cls_str,
 					    eth_da,
 					    1);
-		if (ret) {
+		if (ret < 0) {
 			PMD_LOG_ERR(INIT, "Failed to parse device arguments: %s",
 				dev->devargs->cls_str);
-			return -rte_errno;
+			return ret;
 		}
 	}
 
@@ -2327,10 +2327,10 @@ static int32_t sxe2_parse_eth_devargs(struct rte_device *dev,
 		ret = rte_eth_devargs_parse(dev->devargs->args,
 					    eth_da,
 					    1);
-		if (ret) {
+		if (ret < 0) {
 			PMD_LOG_ERR(INIT, "Failed to parse device arguments: %s",
 				dev->devargs->args);
-			return -rte_errno;
+			return ret;
 		}
 	}
 
Signature · 1 line
2.52.0
#416 lore raw

PATCH v9 37/48 net/sxe2: use primary VSI ID for representor VSI

In reply to [email protected]

From: Jie Liu <[email protected]>

For repr_vf_vsi_id, use the primary VSI id directly instead of falling back to the DPDK VSI id when the kernel VSI id is invalid. The kernel side guarantees the primary VSI id it provides is always valid in any scenario, so the fallback ternary is unnecessary.

---
 drivers/net/sxe2/sxe2_switchdev.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/net/sxe2/sxe2_switchdev.c +1 -4
index d0304ccc94..466182c55c 100644
@@ -324,10 +324,7 @@ int32_t sxe2_switchdev_repr_private_data_init(struct rte_eth_dev *dev,
 		parent_adapter->repr_ctxt.repr_vf_id[repr_id].dpdk_vsi_id;
 
 	repr_priv_data->repr_vf_vsi_id =
-		parent_adapter->repr_ctxt.repr_vf_id[repr_id].kernel_vsi_id !=
-		SXE2_INVALID_VSI_ID ?
-		parent_adapter->repr_ctxt.repr_vf_id[repr_id].kernel_vsi_id :
-		parent_adapter->repr_ctxt.repr_vf_id[repr_id].dpdk_vsi_id;
+		repr_priv_data->repr_vf_primary_vsi_id;
 
 	adapter->repr_priv_data = repr_priv_data;
 	goto l_end;
Signature · 1 line
2.52.0
#417 lore raw

PATCH v9 38/48 net/sxe2: wrap command params fill debug log in macro

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_drv_cmd_params_fill() passes the opcode string as a parameter to __sxe2_drv_cmd_params_fill() just to emit a debug log. The debug log is level-gated by PMD_DEV_LOG_DEBUG either way; moving it into the macro body only consolidates the call sites.

Wrap the log and the fill helper in a do/while block, dropping the opc_str parameter so the opcode stringization happens at the call site. Evaluate the adapter argument exactly once through a local variable.

---
 drivers/net/sxe2/sxe2_cmd_chnl.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/sxe2/sxe2_cmd_chnl.c +6 -4
index 3a55528c44..85098ac664 100644
@@ -26,10 +26,9 @@ static void sxe2_drv_trace_id_alloc(uint64_t *trace_id)
 }
 
 static void __sxe2_drv_cmd_params_fill(struct sxe2_adapter *adapter,
-		struct sxe2_drv_cmd_params *cmd, uint32_t opc, const char *opc_str,
+		struct sxe2_drv_cmd_params *cmd, uint32_t opc,
 		void *in_data, uint32_t in_len, void *out_data, uint32_t out_len)
 {
-	PMD_DEV_LOG_DEBUG(adapter, DRV, "cmd opcode:%s", opc_str);
 	cmd->timeout = SXE2_DRV_CMD_DFLT_TIMEOUT;
 	cmd->opcode  = opc;
 	cmd->vsi_id  = adapter->vsi_ctxt.dpdk_vsi_id;
@@ -44,8 +43,11 @@ static void __sxe2_drv_cmd_params_fill(struct sxe2_adapter *adapter,
 }
 
 #define sxe2_drv_cmd_params_fill(adapter, cmd, opc, in_data, in_len, out_data, out_len) \
-	__sxe2_drv_cmd_params_fill(adapter, cmd, opc, #opc, in_data, in_len, out_data, out_len)
-
+	do { \
+		struct sxe2_adapter *_ad = (adapter); \
+		PMD_DEV_LOG_DEBUG(_ad, DRV, "cmd opcode:%s", #opc); \
+		__sxe2_drv_cmd_params_fill(_ad, cmd, opc, in_data, in_len, out_data, out_len); \
+	} while (0)
 
 int32_t sxe2_drv_dev_caps_get(struct sxe2_adapter *adapter, struct sxe2_drv_dev_caps_resp *dev_caps)
 {
Signature · 1 line
2.52.0
#418 lore raw

PATCH v9 39/48 net/sxe2: restore Rx queue buffer split fill support

In reply to [email protected]

From: Jie Liu <[email protected]>

The V4 branch dropped sxe2_rxq_buf_split_fill() and the buffer split handling in sxe2_rxq_ctxt_cfg_fill(), so the Rx buffer split offload (RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) is advertised in device info but the per-queue context never configures split_en/split_type_mask/ hdr_len, and buffer split packets are not handled correctly.

Restore the sxe2_rxq_buf_split_fill() helper and the buffer split branch in sxe2_rxq_ctxt_cfg_fill(), matching the V3 implementation.

Fixes d8e4e075acb4 ("net/sxe2: add probing skeleton")
---
 drivers/net/sxe2/sxe2_cmd_chnl.c | 88 ++++++++++++++++++++++++++++++++
 1 file changed, 88 insertions(+)
drivers/net/sxe2/sxe2_cmd_chnl.c +88 -0
index 85098ac664..7b27cf2e8d 100644
@@ -195,6 +195,84 @@ int32_t sxe2_drv_vsi_del(struct sxe2_adapter *adapter, struct sxe2_vsi *vsi)
 #define SXE2_RXQ_CTXT_CFG_BUF_LEN_ALIGN  (1 << 7)
 #define SXE2_RX_HDR_SIZE 256
 
+static int32_t sxe2_rxq_buf_split_fill(struct sxe2_rx_queue *rxq,
+				   struct sxe2_drv_rxq_ctxt *ctxt)
+{
+	uint32_t proto_hdr;
+
+	proto_hdr = rxq->rx_seg[0].proto_hdr;
+	if (proto_hdr == RTE_PTYPE_UNKNOWN) {
+		PMD_LOG_ERR(RX, "Buffer split protocol must be configured");
+		return -EINVAL;
+	}
+
+	switch (proto_hdr & RTE_PTYPE_L4_MASK) {
+	case RTE_PTYPE_L4_TCP:
+		ctxt->split_type_mask = SXE2_PTYPE_L4_TCP;
+		goto l_end;
+	case RTE_PTYPE_L4_UDP:
+		ctxt->split_type_mask = SXE2_PTYPE_L4_UDP;
+		goto l_end;
+	case RTE_PTYPE_L4_SCTP:
+		ctxt->split_type_mask = SXE2_PTYPE_L4_SCTP;
+		goto l_end;
+	}
+
+	switch (proto_hdr & RTE_PTYPE_L3_MASK) {
+	case RTE_PTYPE_L3_IPV4_EXT_UNKNOWN:
+		ctxt->split_type_mask = SXE2_PTYPE_L3_IPV4;
+		goto l_end;
+	case RTE_PTYPE_L3_IPV6_EXT_UNKNOWN:
+		ctxt->split_type_mask = SXE2_PTYPE_L3_IPV6;
+		goto l_end;
+	}
+
+	switch (proto_hdr & RTE_PTYPE_L2_MASK) {
+	case RTE_PTYPE_L2_ETHER:
+		ctxt->split_type_mask = SXE2_PTYPE_L2_ETHER;
+		goto l_end;
+	}
+
+	switch (proto_hdr & RTE_PTYPE_INNER_L4_MASK) {
+	case RTE_PTYPE_INNER_L4_TCP:
+		ctxt->split_type_mask = SXE2_PTYPE_INNER_L4_TCP;
+		goto l_end;
+	case RTE_PTYPE_INNER_L4_UDP:
+		ctxt->split_type_mask = SXE2_PTYPE_INNER_L4_UDP;
+		goto l_end;
+	case RTE_PTYPE_INNER_L4_SCTP:
+		ctxt->split_type_mask = SXE2_PTYPE_INNER_L4_SCTP;
+		goto l_end;
+	}
+
+	switch (proto_hdr & RTE_PTYPE_INNER_L3_MASK) {
+	case RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN:
+		ctxt->split_type_mask = SXE2_PTYPE_INNER_L3_IPV4;
+		goto l_end;
+	case RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN:
+		ctxt->split_type_mask = SXE2_PTYPE_INNER_L3_IPV6;
+		goto l_end;
+	}
+
+	switch (proto_hdr & RTE_PTYPE_INNER_L2_MASK) {
+	case RTE_PTYPE_INNER_L2_ETHER:
+		ctxt->split_type_mask = SXE2_PTYPE_INNER_L2_ETHER;
+		goto l_end;
+	}
+
+	switch (proto_hdr & RTE_PTYPE_TUNNEL_MASK) {
+	case RTE_PTYPE_TUNNEL_GRENAT:
+		ctxt->split_type_mask = SXE2_PTYPE_TUNNEL_GRENAT;
+		goto l_end;
+	}
+
+	PMD_LOG_ERR(RX, "Buffer split protocol is not supported");
+	return -ENOTSUP;
+l_end:
+	ctxt->hdr_len = SXE2_RX_HDR_SIZE;
+	return 0;
+}
+
 static int32_t sxe2_rxq_ctxt_cfg_fill(struct sxe2_rx_queue *rxq,
 		struct sxe2_drv_rxq_cfg_req *req, uint16_t rxq_cnt)
 {
@@ -228,7 +306,17 @@ static int32_t sxe2_rxq_ctxt_cfg_fill(struct sxe2_rx_queue *rxq,
 	else
 		ctxt->keep_crc_en = 0;
 
+	if (rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) {
+		ret = sxe2_rxq_buf_split_fill(rxq, ctxt);
+		if (ret)
+			goto l_end;
+		ctxt->split_en = 1;
+	} else {
+		ctxt->split_en = 0;
+	}
+
 	ctxt->desc_size = sizeof(union sxe2_rx_desc);
+l_end:
 	return ret;
 }
 
Signature · 1 line
2.52.0
#419 lore raw

PATCH v9 40/48 net/sxe2: skip tunnel config fill on get failure

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_drv_udp_tunnel_get() fills tunnel_config fields even when the firmware command fails, so a failed get overwrites the config with the (zero-initialized) response data instead of leaving it intact.

Return early with the error code when sxe2_drv_cmd_exec() fails, matching the V3 implementation.

Fixes fff24885f70a ("net/sxe2: support custom UDP tunnel ports")
---
 drivers/net/sxe2/sxe2_cmd_chnl.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/sxe2/sxe2_cmd_chnl.c +4 -2
index 7b27cf2e8d..5ab287a77b 100644
@@ -1650,15 +1650,17 @@ int32_t sxe2_drv_udp_tunnel_get(struct sxe2_adapter *adapter,
 				 &req, sizeof(req),
 				 &resp, sizeof(resp));
 	ret = sxe2_drv_cmd_exec(cdev, &cmd);
-	if (ret)
+	if (ret) {
 		PMD_LOG_ERR(DRV, "Failed to get udp proto %d port, ret=%d", req.type, ret);
+		goto l_end;
+	}
 
 	tunnel_config->fw_port   = resp.port;
 	tunnel_config->fw_status = resp.enable;
 	tunnel_config->fw_dst_en = resp.dst;
 	tunnel_config->fw_src_en = resp.src;
 	tunnel_config->fw_used   = resp.fw_used;
-
+l_end:
 	return ret;
 }
 
Signature · 1 line
2.52.0
#420 lore raw

PATCH v9 41/48 net/sxe2: skip flow ID assignment on filter add failure

In reply to [email protected]

From: Jie Liu <[email protected]>

sxe2_drv_flow_filter_add() assigns flow->flow_id from the response even when the firmware command fails, overwriting any previously set flow id with the zero-initialized response value.

Return early on command failure so flow->flow_id is preserved, and set flow->create_err on both the success and error paths.

Fixes 635084db5d57 ("net/sxe2: support VF representors")
---
 drivers/net/sxe2/sxe2_cmd_chnl.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/sxe2/sxe2_cmd_chnl.c +5 -1
index 5ab287a77b..6a5c1907c2 100644
@@ -1818,9 +1818,13 @@ int32_t sxe2_drv_flow_filter_add(struct sxe2_adapter *adapter, struct sxe2_flow
 	sxe2_drv_cmd_params_fill(adapter, &cmd, SXE2_DRV_CMD_FLOW_FILTER_ADD, &req,
 			   sizeof(req), &resp, sizeof(resp));
 	ret = sxe2_drv_cmd_exec(cdev, &cmd);
-	if (ret)
+	if (ret) {
 		PMD_DEV_LOG_ERR(adapter, DRV, "Failed to add flow filter, ret: %d.", ret);
+		goto l_end;
+	}
 	flow->flow_id = resp.flow_id;
+
+l_end:
 	flow->create_err = ret;
 	return ret;
 }
Signature · 1 line
2.52.0
#421 lore raw

PATCH v9 42/48 net/sxe2: correct command channel log messages

In reply to [email protected]

From: Jie Liu <[email protected]>

Several error/warning messages in sxe2_cmd_chnl.c are inaccurate or lost context:

- vsi_info_get: message lost the vsi id; restore it
- rxq_bind_irq/rxq_unbind_irq: message lost the rxq index; restore it
- promisc_config: fix "promic" typo in the message
- queue_info_get_update: use "tx/rx queue map get failed" wording
- rxq_mapping_set: incorrect "get dev caps" wording; use "rx queue mapping failed"
- txq_mapping_set: "Rx queue" should read "Tx queue"; incorrect "get dev caps" wording should read "tx queue mapping failed"

---
 drivers/net/sxe2/sxe2_cmd_chnl.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/net/sxe2/sxe2_cmd_chnl.c +8 -8
index 6a5c1907c2..65e3a4ca21 100644
@@ -481,7 +481,7 @@ int32_t sxe2_drv_vsi_info_get(struct sxe2_adapter *adapter, struct sxe2_vsi *vsi
 			&vsi_info_get_resp, sizeof(vsi_info_get_resp));
 	ret = sxe2_drv_cmd_exec(cdev, &param);
 	if (ret) {
-		PMD_DEV_LOG_ERR(adapter, DRV, "switchdev cpvsi info get failed, ret=%d", ret);
+		PMD_DEV_LOG_ERR(adapter, DRV, "vsi %u info get failed, ret=%d", vsi->vsi_id, ret);
 		goto l_end;
 	}
 
@@ -537,7 +537,7 @@ int32_t sxe2_drv_rxq_bind_irq(struct sxe2_adapter *adapter, uint16_t rxq_idx, ui
 				 NULL, 0);
 	ret = sxe2_drv_cmd_exec(cdev, &param);
 	if (ret)
-		PMD_DEV_LOG_ERR(adapter, DRV, "rxq bind irq failed, ret=%d", ret);
+		PMD_DEV_LOG_ERR(adapter, DRV, "rxq %u bind irq failed, ret=%d", rxq_idx, ret);
 
 	return ret;
 }
@@ -557,7 +557,7 @@ int32_t sxe2_drv_rxq_unbind_irq(struct sxe2_adapter *adapter, uint16_t rxq_idx)
 				 NULL, 0);
 	ret = sxe2_drv_cmd_exec(cdev, &param);
 	if (ret)
-		PMD_DEV_LOG_ERR(adapter, DRV, "rxq unbind irq failed, ret=%d", ret);
+		PMD_DEV_LOG_ERR(adapter, DRV, "rxq %u unbind irq failed, ret=%d", rxq_idx, ret);
 
 	return ret;
 }
@@ -758,7 +758,7 @@ int32_t sxe2_drv_promisc_config(struct sxe2_adapter *adapter, bool set)
 
 	ret = sxe2_drv_cmd_exec(cdev, &param);
 	if (ret)
-		PMD_DEV_LOG_WARN(adapter, DRV, "promic config failed, ret=%d", ret);
+		PMD_DEV_LOG_WARN(adapter, DRV, "promisc config failed, ret=%d", ret);
 
 	return ret;
 }
@@ -1683,7 +1683,7 @@ int32_t sxe2_drv_queue_info_get_update(struct sxe2_adapter *adapter, struct eth_
 				 &resp, sizeof(resp));
 	ret = sxe2_drv_cmd_exec(cdev, &param);
 	if (ret) {
-		PMD_LOG_ERR(DRV, "get queue info map failed, ret=%d", ret);
+		PMD_LOG_ERR(DRV, "tx/rx queue map get failed, ret=%d", ret);
 		goto l_end;
 	}
 
@@ -1727,7 +1727,7 @@ int32_t sxe2_drv_rxq_mapping_set(struct rte_eth_dev *eth_dev, uint16_t queue_id,
 
 	ret = sxe2_drv_cmd_exec(cdev, &param);
 	if (ret)
-		PMD_LOG_ERR(DRV, "get dev caps failed, ret=%d", ret);
+		PMD_LOG_ERR(DRV, "rx queue mapping failed, ret=%d", ret);
 
 l_end:
 	return ret;
@@ -1744,7 +1744,7 @@ int32_t sxe2_drv_txq_mapping_set(struct rte_eth_dev *eth_dev, uint16_t queue_id,
 
 	txq = eth_dev->data->tx_queues[queue_id];
 	if (txq == NULL) {
-		PMD_LOG_ERR(DRV, "Rx queue %u is not available or setup", queue_id);
+		PMD_LOG_ERR(DRV, "Tx queue %u is not available or setup", queue_id);
 		ret = -EINVAL;
 		goto l_end;
 	}
@@ -1758,7 +1758,7 @@ int32_t sxe2_drv_txq_mapping_set(struct rte_eth_dev *eth_dev, uint16_t queue_id,
 
 	ret = sxe2_drv_cmd_exec(cdev, &param);
 	if (ret)
-		PMD_LOG_ERR(DRV, "get dev caps failed, ret=%d", ret);
+		PMD_LOG_ERR(DRV, "tx queue mapping failed, ret=%d", ret);
 
 l_end:
 	return ret;
Signature · 1 line
2.52.0