Skip to contentSkip to conversation

common/sxe2: add common functions for sxe2 driver

PATCH Superseded [email protected] 2 participants 143 messages Apr 30 – May 13 Page 2 of 2

Subsystems (2)

v1 of 19 Superseded Latest is v19 →

lore
Share & tools
lore
#93 lore raw

PATCH v9 9/10 drivers: add data path for Rx and Tx

In reply to [email protected]

From: Jie Liu <[email protected]>

Implement receive and transmit burst functions for sxe2 PMD. Add sxe2_recv_pkts and sxe2_xmit_pkts as the primary data path interfaces.

The implementation includes:
- Efficient descriptor fetching and mbuf allocation for Rx.
- Descriptor setup and checksum offload handling for Tx.
- Buffer recycling and hardware tail pointer updates.
- Performance-oriented loop unrolling and prefetching where applicable.

---
 drivers/common/sxe2/sxe2_common.c     |  13 +-
 drivers/common/sxe2/sxe2_common_log.h | 105 ----
 drivers/common/sxe2/sxe2_errno.h      |   3 -
 drivers/common/sxe2/sxe2_ioctl_chnl.c |  20 +-
 drivers/common/sxe2/sxe2_osal.h       |   4 +-
 drivers/common/sxe2/sxe2_type.h       |   1 -
 drivers/net/sxe2/meson.build          |   2 +
 drivers/net/sxe2/sxe2_ethdev.c        |  15 +-
 drivers/net/sxe2/sxe2_txrx.c          | 249 ++++++++
 drivers/net/sxe2/sxe2_txrx.h          |  21 +
 drivers/net/sxe2/sxe2_txrx_poll.c     | 782 ++++++++++++++++++++++++++
 11 files changed, 1082 insertions(+), 133 deletions(-)
 create mode 100644 drivers/net/sxe2/sxe2_txrx.c
 create mode 100644 drivers/net/sxe2/sxe2_txrx.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_poll.c
drivers/common/sxe2/sxe2_common.c +6 -7
index 537d4e9f6a..d2ed1460a3 100644
@@ -28,7 +28,7 @@ static TAILQ_HEAD(sxe2_class_drivers, sxe2_class_driver) sxe2_class_drivers_list
 static TAILQ_HEAD(sxe2_common_devices, sxe2_common_device) sxe2_common_devices_list =
 				TAILQ_HEAD_INITIALIZER(sxe2_common_devices_list);
 
-static pthread_mutex_t sxe2_common_devices_list_lock;
+static rte_spinlock_t sxe2_common_devices_list_lock;
 
 static struct rte_pci_id *sxe2_common_pci_id_table;
 
@@ -223,9 +223,9 @@ static struct sxe2_common_device *sxe2_common_device_alloc(
 	cdev->config.kernel_reset = false;
 	rte_ticketlock_init(&cdev->config.lock);
 
-	(void)pthread_mutex_lock(&sxe2_common_devices_list_lock);
+	rte_spinlock_lock(&sxe2_common_devices_list_lock);
 	TAILQ_INSERT_TAIL(&sxe2_common_devices_list, cdev, next);
-	(void)pthread_mutex_unlock(&sxe2_common_devices_list_lock);
+	rte_spinlock_unlock(&sxe2_common_devices_list_lock);
 
 l_end:
 	return cdev;
@@ -233,10 +233,9 @@ static struct sxe2_common_device *sxe2_common_device_alloc(
 
 static void sxe2_common_device_free(struct sxe2_common_device *cdev)
 {
-
-	(void)pthread_mutex_lock(&sxe2_common_devices_list_lock);
+	rte_spinlock_lock(&sxe2_common_devices_list_lock);
 	TAILQ_REMOVE(&sxe2_common_devices_list, cdev, next);
-	(void)pthread_mutex_unlock(&sxe2_common_devices_list_lock);
+	rte_spinlock_unlock(&sxe2_common_devices_list_lock);
 
 	rte_free(cdev);
 }
@@ -662,7 +661,7 @@ sxe2_common_init(void)
 	if (sxe2_commoin_inited)
 		goto l_end;
 
-	pthread_mutex_init(&sxe2_common_devices_list_lock, NULL);
+	rte_spinlock_init(&sxe2_common_devices_list_lock);
 #ifdef SXE2_DPDK_DEBUG
 	sxe2_common_log_stream_init();
 #endif
drivers/common/sxe2/sxe2_common_log.h +0 -105

109 lines not on this page · raw message

drivers/common/sxe2/sxe2_errno.h +0 -3
index 89a715eaef..1257319edf 100644
@@ -50,9 +50,6 @@ enum sxe2_status {
 	SXE2_ERR_NOLCK              = -ENOLCK,
 	SXE2_ERR_NOSYS              = -ENOSYS,
 	SXE2_ERR_NOTEMPTY           = -ENOTEMPTY,
-	SXE2_ERR_ILSEQ              = -EILSEQ,
-	SXE2_ERR_NODATA             = -ENODATA,
-	SXE2_ERR_CANCELED           = -ECANCELED,
 	SXE2_ERR_TIMEDOUT           = -ETIMEDOUT,
 
 	SXE2_ERROR                  = -150,
drivers/common/sxe2/sxe2_ioctl_chnl.c +10 -10
index 1a14d401e7..cb83fb837d 100644
@@ -37,7 +37,7 @@ sxe2_drv_cmd_exec(struct sxe2_common_device *cdev,
 
 	if (cdev->config.kernel_reset) {
 		ret = SXE2_ERR_PERM;
-		PMD_LOG_WARN(COM, "kernel reseted, need restart app.");
+		PMD_LOG_WARN(COM, "kernel reset, need restart app.");
 		goto l_end;
 	}
 
@@ -123,7 +123,7 @@ sxe2_drv_dev_handshark(struct sxe2_common_device *cdev)
 
 	if (cdev->config.kernel_reset) {
 		ret = SXE2_ERR_PERM;
-		PMD_LOG_WARN(COM, "kernel reseted, need restart app.");
+		PMD_LOG_WARN(COM, "kernel reset, need restart app.");
 		goto l_end;
 	}
 
@@ -168,7 +168,7 @@ void
 	void *virt = NULL;
 
 	if (cdev->config.kernel_reset) {
-		PMD_LOG_WARN(COM, "kernel reseted, need restart app.");
+		PMD_LOG_WARN(COM, "kernel reset, need restart app.");
 		goto l_err;
 	}
 
@@ -178,13 +178,13 @@ void
 		goto l_err;
 	}
 
-	PMD_LOG_DEBUG(COM, "fd=%d, bar idx=%d, len=0x%zx, src=0x%"PRIx64", offset=0x%"PRIx64"",
+	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));
 
 	virt = mmap(NULL, len, PROT_READ | PROT_WRITE,
 		MAP_SHARED, cmd_fd, SXE2_COM_PCI_OFFSET_GEN(bar_idx, offset));
 	if (virt == MAP_FAILED) {
-		PMD_LOG_ERR(COM, "Failed mmap, cmd_fd=%d, len=0x%zx, offset=0x%"PRIx64", err:%s",
+		PMD_LOG_ERR(COM, "Failed mmap, cmd_fd=%d, len=%"PRIu64", offset=0x%"PRIx64", err:%s",
 			cmd_fd, len, offset, strerror(errno));
 		goto l_err;
 	}
@@ -206,12 +206,12 @@ sxe2_drv_dev_munmap(struct sxe2_common_device *cdev, void *virt, u64 len)
 		goto l_end;
 	}
 
-	PMD_LOG_DEBUG(COM, "Munmap virt=%p, len=0x%zx",
+	PMD_LOG_DEBUG(COM, "Munmap virt=%p, len=0x%"PRIx64"",
 		virt, len);
 
 	ret = munmap(virt, len);
 	if (ret < 0) {
-		PMD_LOG_ERR(COM, "Failed to munmap, virt=%p, len=0x%zx, err:%s",
+		PMD_LOG_ERR(COM, "Failed to munmap, virt=%p, len=%"PRIu64", err:%s",
 			virt, len, strerror(errno));
 		ret = SXE2_ERR_IO;
 		goto l_end;
@@ -233,7 +233,7 @@ sxe2_drv_dev_dma_map(struct sxe2_common_device *cdev, u64 vaddr,
 
 	if (cdev->config.kernel_reset) {
 		ret = SXE2_ERR_PERM;
-		PMD_LOG_WARN(COM, "kernel reseted, need restart app.");
+		PMD_LOG_WARN(COM, "kernel reset, need restart app.");
 		goto l_end;
 	}
 
@@ -246,7 +246,7 @@ sxe2_drv_dev_dma_map(struct sxe2_common_device *cdev, u64 vaddr,
 		goto l_end;
 	} else if (iova_mode == RTE_IOVA_VA) {
 		if (!cdev->config.support_iommu) {
-			PMD_LOG_ERR(COM, "no iommu not support va mode, plese use pa mode.");
+			PMD_LOG_ERR(COM, "no iommu not support va mode, please use pa mode.");
 			ret = SXE2_ERR_IO;
 			goto l_end;
 		}
@@ -289,7 +289,7 @@ sxe2_drv_dev_dma_unmap(struct sxe2_common_device *cdev, u64 iova)
 
 	if (cdev->config.kernel_reset) {
 		ret = SXE2_ERR_PERM;
-		PMD_LOG_WARN(COM, "kernel reseted, need restart app.");
+		PMD_LOG_WARN(COM, "kernel reset, need restart app.");
 		goto l_end;
 	}
 
drivers/common/sxe2/sxe2_osal.h +1 -3
index fd6823fe98..23882f3f52 100644
@@ -29,8 +29,6 @@
 #define BIT_ULL(a) (1ULL << (a))
 #endif
 
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
-
 #define BITS_PER_BYTE 8
 
 #define IS_UNICAST_ETHER_ADDR(addr)			\
@@ -88,7 +86,7 @@
 			(((n) + (typeof(n))(d) - (typeof(n))1) / (typeof(n))(d))
 #endif
 
-#define usleep_range(min, max) msleep(DIV_ROUND_UP(min, 1000))
+#define usleep_range(min) msleep(DIV_ROUND_UP(min, 1000))
 
 #define __bf_shf(x) ((uint32_t)rte_bsf64(x))
 
drivers/common/sxe2/sxe2_type.h +0 -1
index 56d0a11f48..fbf4a6674f 100644
@@ -8,7 +8,6 @@
 #include <sys/time.h>
 
 #include <stdlib.h>
-#include <stdio.h>
 #include <errno.h>
 #include <stdarg.h>
 #include <unistd.h>
drivers/net/sxe2/meson.build +2 -0
index 61467a4e31..b331451160 100644
@@ -25,6 +25,8 @@ sources += files(
         'sxe2_queue.c',
         'sxe2_tx.c',
         'sxe2_rx.c',
+        'sxe2_txrx_poll.c',
+        'sxe2_txrx.c',
 )
 
 allow_internal_get_api = true
drivers/net/sxe2/sxe2_ethdev.c +11 -4
index c1a65f25ce..68d7e36cf1 100644
@@ -26,6 +26,7 @@
 #include "sxe2_cmd_chnl.h"
 #include "sxe2_tx.h"
 #include "sxe2_rx.h"
+#include "sxe2_txrx.h"
 #include "sxe2_common.h"
 #include "sxe2_common_log.h"
 #include "sxe2_host_regs.h"
@@ -131,6 +132,9 @@ static s32 sxe2_dev_start(struct rte_eth_dev *dev)
 		goto l_end;
 	}
 
+	sxe2_rx_mode_func_set(dev);
+	sxe2_tx_mode_func_set(dev);
+
 	ret = sxe2_queues_start(dev);
 	if (ret) {
 		PMD_LOG_ERR(INIT, "enable queues failed");
@@ -363,8 +367,8 @@ void __iomem *sxe2_pci_map_addr_get(struct sxe2_adapter *adapter,
 	for (i = 0; i < bar_info->map_cnt; i++) {
 		seg_info = &bar_info->seg_info[i];
 		if (res_type == seg_info->type) {
-			addr = (void __iomem *)((uintptr_t)seg_info->addr +
-					seg_info->page_inner_offset + reg_width	* idx_in_func);
+			addr = (uint8_t __iomem *)seg_info->addr +
+					seg_info->page_inner_offset + reg_width * idx_in_func;
 			goto l_end;
 		}
 	}
@@ -475,8 +479,9 @@ s32 sxe2_dev_pci_seg_map(struct sxe2_adapter *adapter,
 
 	map_addr = sxe2_drv_dev_mmap(adapter->cdev, bar_info->bar_idx, aligned_len, aligned_offset);
 	if (!map_addr) {
-		PMD_LOG_ERR(INIT, "Failed to mmap BAR space, type=%d, len=%zu, page_size=%zu",
-					res_type, org_len, page_size);
+		PMD_LOG_ERR(INIT, "Failed to mmap BAR space, type=%d, len=%" PRIu64
+			", offset=%" PRIu64 ", page_size=%zu",
+					res_type, org_len, org_offset, page_size);
 		ret = SXE2_ERR_FAULT;
 		goto l_end;
 	}
@@ -760,6 +765,8 @@ static s32 sxe2_dev_init(struct rte_eth_dev *dev, struct sxe2_dev_kvargs_info *k
 
 	PMD_INIT_FUNC_TRACE();
 
+	sxe2_set_common_function(dev);
+
 	dev->dev_ops = &sxe2_eth_dev_ops;
 
 	ret = sxe2_hw_init(dev);
drivers/net/sxe2/sxe2_txrx.c new file +249 -0

249 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx.h new file +21 -0
new file mode 100644
index 0000000000..cd9ebfa32f
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+ */
+
+#ifndef SXE2_TXRX_H
+#define SXE2_TXRX_H
+#include <ethdev_driver.h>
+#include "sxe2_queue.h"
+
+void sxe2_set_common_function(struct rte_eth_dev *dev);
+
+u16 sxe2_tx_pkts_prepare(__rte_unused void *tx_queue,
+		struct rte_mbuf **tx_pkts, u16 nb_pkts);
+
+void sxe2_tx_mode_func_set(struct rte_eth_dev *dev);
+
+void __rte_cold sxe2_rx_queue_reset(struct sxe2_rx_queue *rxq);
+
+void sxe2_rx_mode_func_set(struct rte_eth_dev *dev);
+
+#endif
drivers/net/sxe2/sxe2_txrx_poll.c new file +782 -0

782 lines not on this page · raw message

Signature · 1 line
2.47.3
#94 lore raw

PATCH v9 10/10 net/sxe2: add vectorized Rx and Tx

In reply to [email protected]

From: Jie Liu <[email protected]>

This patch implements the vectorized data path for the sxe2 PMD. It utilizes SIMD instructions (e.g., SSE) to process multiple packets simultaneously, significantly improving throughput for small packet processing.

The implementation includes:
* Vectorized Rx burst function for bulk descriptor processing.
* Vectorized Tx burst function with optimized resource cleanup.
* Capability flags update to reflect vectorized path support.

---
 drivers/net/sxe2/meson.build            |  11 +
 drivers/net/sxe2/sxe2_ethdev.c          |   8 +-
 drivers/net/sxe2/sxe2_ethdev.h          |   1 -
 drivers/net/sxe2/sxe2_txrx.c            | 222 +++++++---
 drivers/net/sxe2/sxe2_txrx.h            |  12 +-
 drivers/net/sxe2/sxe2_txrx_poll.c       | 186 +++++++-
 drivers/net/sxe2/sxe2_txrx_poll.h       |   3 +-
 drivers/net/sxe2/sxe2_txrx_vec.c        | 188 ++++++++
 drivers/net/sxe2/sxe2_txrx_vec.h        |  72 ++++
 drivers/net/sxe2/sxe2_txrx_vec_common.h | 235 ++++++++++
 drivers/net/sxe2/sxe2_txrx_vec_sse.c    | 547 ++++++++++++++++++++++++
 11 files changed, 1418 insertions(+), 67 deletions(-)
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec.c
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec_common.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec_sse.c
drivers/net/sxe2/meson.build +11 -0
index b331451160..0975366c10 100644
@@ -18,6 +18,16 @@ cflags += ['-g']
 
 deps += ['common_sxe2', 'hash','cryptodev','security']
 
+includes += include_directories('../../common/sxe2')
+
+if arch_subdir == 'x86'
+        sources += files('sxe2_txrx_vec_sse.c')
+
+        if is_windows and cc.get_id() != 'clang'
+                cflags += ['-fno-asynchronous-unwind-tables']
+        endif
+endif
+
 sources += files(
         'sxe2_ethdev.c',
         'sxe2_cmd_chnl.c',
@@ -27,6 +37,7 @@ sources += files(
         'sxe2_rx.c',
         'sxe2_txrx_poll.c',
         'sxe2_txrx.c',
+        'sxe2_txrx_vec.c',
 )
 
 allow_internal_get_api = true
drivers/net/sxe2/sxe2_ethdev.c +2 -6
index 68d7e36cf1..7eaa1722d0 100644
@@ -58,17 +58,11 @@ static const struct rte_pci_id pci_id_sxe2_tbl[] = {
 };
 
 static struct sxe2_pci_map_addr_info sxe2_net_map_addr_info_pf[SXE2_PCI_MAP_RES_MAX_COUNT] = {
-	/* SXE2_PCI_MAP_RES_INVALID */
 	{0, 0, 0},
-	/* SXE2_PCI_MAP_RES_DOORBELL_TX */
 	{ SXE2_TXQ_LEGACY_DBLL(0), 0, 4},
-	/* SXE2_PCI_MAP_RES_DOORBELL_RX_TAIL */
 	{ SXE2_RXQ_TAIL(0), 0, 4},
-	/* SXE2_PCI_MAP_RES_IRQ_DYN */
 	{ SXE2_VF_DYN_CTL(0), 0, 4},
-	/* SXE2_PCI_MAP_RES_IRQ_ITR(默认使用ITR0) */
 	{ SXE2_VF_INT_ITR(0, 0), 0, 4},
-	/* SXE2_PCI_MAP_RES_IRQ_MSIX */
 	{ SXE2_BAR4_MSIX_CTL(0), 4, 0x10},
 };
 
@@ -312,6 +306,8 @@ static const struct eth_dev_ops sxe2_eth_dev_ops = {
 
 	.rxq_info_get               = sxe2_rx_queue_info_get,
 	.txq_info_get               = sxe2_tx_queue_info_get,
+	.rx_burst_mode_get          = sxe2_rx_burst_mode_get,
+	.tx_burst_mode_get          = sxe2_tx_burst_mode_get,
 };
 
 struct sxe2_pci_map_bar_info *sxe2_dev_get_bar_info(struct sxe2_adapter *adapter,
drivers/net/sxe2/sxe2_ethdev.h +0 -1
index 7999e4f331..0881d57d77 100644
@@ -11,7 +11,6 @@
 #include <rte_tm_driver.h>
 #include <rte_io.h>
 
-#include "sxe2_common.h"
 #include "sxe2_errno.h"
 #include "sxe2_type.h"
 #include "sxe2_vsi.h"
drivers/net/sxe2/sxe2_txrx.c +170 -52

373 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx.h +6 -6
index cd9ebfa32f..7bb852789c 100644
@@ -6,16 +6,16 @@
 #define SXE2_TXRX_H
 #include <ethdev_driver.h>
 #include "sxe2_queue.h"
-
 void sxe2_set_common_function(struct rte_eth_dev *dev);
-
+s32 __rte_cold sxe2_tx_simple_batch_support_check(struct rte_eth_dev *dev,
+	u32 *batch_flags);
 u16 sxe2_tx_pkts_prepare(__rte_unused void *tx_queue,
 		struct rte_mbuf **tx_pkts, u16 nb_pkts);
-
 void sxe2_tx_mode_func_set(struct rte_eth_dev *dev);
-
 void __rte_cold sxe2_rx_queue_reset(struct sxe2_rx_queue *rxq);
-
 void sxe2_rx_mode_func_set(struct rte_eth_dev *dev);
-
+s32 sxe2_tx_burst_mode_get(struct rte_eth_dev *dev,
+			__rte_unused uint16_t queue_id, struct rte_eth_burst_mode *mode);
+s32 sxe2_rx_burst_mode_get(struct rte_eth_dev *dev,
+			__rte_unused u16 queue_id, struct rte_eth_burst_mode *mode);
 #endif
drivers/net/sxe2/sxe2_txrx_poll.c +185 -1

204 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx_poll.h +2 -1
index 4924b0f41f..67da08e58e 100644
@@ -8,7 +8,8 @@
 #include "sxe2_queue.h"
 
 u16 sxe2_tx_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, u16 nb_pkts);
-
+u16 sxe2_tx_pkts_simple(void *tx_queue,
+			struct rte_mbuf **tx_pkts, u16 nb_pkts);
 u16 sxe2_rx_pkts_scattered(void *rx_queue, struct rte_mbuf **rx_pkts, u16 nb_pkts);
 
 u16 sxe2_rx_pkts_scattered_split(void *rx_queue, struct rte_mbuf **rx_pkts, u16 nb_pkts);
drivers/net/sxe2/sxe2_txrx_vec.c new file +188 -0

188 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx_vec.h new file +72 -0

72 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx_vec_common.h new file +235 -0

235 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx_vec_sse.c new file +547 -0

547 lines not on this page · raw message

Signature · 1 line
2.47.3
#95 lore raw

v10 cover Add Linkdata sxe2 driver

From: Jie Liu <[email protected]>

V10:
- Addressed AI comments

Jie Liu (10):
mailmap: add Jie Liu
doc: add sxe2 guide and release notes
drivers: add sxe2 basic structures common/sxe2: add base driver skeleton
drivers: add base driver probe skeleton
drivers: support PCI BAR mapping
common/sxe2: add ioctl interface for DMA map and unmap net/sxe2: support queue setup and control
drivers: add data path for Rx and Tx net/sxe2: add vectorized Rx and Tx

 .mailmap                                   |   1 +
 doc/guides/nics/features/sxe2.ini          |  11 +
 doc/guides/nics/index.rst                  |   1 +
 doc/guides/nics/sxe2.rst                   |  23 +
 doc/guides/rel_notes/release_26_07.rst     |   4 +
 drivers/common/sxe2/meson.build            |  21 +
 drivers/common/sxe2/sxe2_common.c          | 683 +++++++++++++++
 drivers/common/sxe2/sxe2_common.h          |  86 ++
 drivers/common/sxe2/sxe2_common_log.c      |  75 ++
 drivers/common/sxe2/sxe2_common_log.h      | 263 ++++++
 drivers/common/sxe2/sxe2_errno.h           | 110 +++
 drivers/common/sxe2/sxe2_host_regs.h       | 707 +++++++++++++++
 drivers/common/sxe2/sxe2_internal_ver.h    |  33 +
 drivers/common/sxe2/sxe2_ioctl_chnl.c      | 326 +++++++
 drivers/common/sxe2/sxe2_ioctl_chnl.h      | 141 +++
 drivers/common/sxe2/sxe2_ioctl_chnl_func.h |  63 ++
 drivers/common/sxe2/sxe2_osal.h            | 582 ++++++++++++
 drivers/common/sxe2/sxe2_type.h            |  64 ++
 drivers/meson.build                        |   1 +
 drivers/net/meson.build                    |   1 +
 drivers/net/sxe2/meson.build               |  43 +
 drivers/net/sxe2/sxe2_cmd_chnl.c           | 319 +++++++
 drivers/net/sxe2/sxe2_cmd_chnl.h           |  33 +
 drivers/net/sxe2/sxe2_drv_cmd.h            | 398 +++++++++
 drivers/net/sxe2/sxe2_ethdev.c             | 971 +++++++++++++++++++++
 drivers/net/sxe2/sxe2_ethdev.h             | 315 +++++++
 drivers/net/sxe2/sxe2_irq.h                |  49 ++
 drivers/net/sxe2/sxe2_queue.c              |  39 +
 drivers/net/sxe2/sxe2_queue.h              | 227 +++++
 drivers/net/sxe2/sxe2_rx.c                 | 579 ++++++++++++
 drivers/net/sxe2/sxe2_rx.h                 |  34 +
 drivers/net/sxe2/sxe2_tx.c                 | 447 ++++++++++
 drivers/net/sxe2/sxe2_tx.h                 |  32 +
 drivers/net/sxe2/sxe2_txrx.c               | 367 ++++++++
 drivers/net/sxe2/sxe2_txrx.h               |  21 +
 drivers/net/sxe2/sxe2_txrx_common.h        | 541 ++++++++++++
 drivers/net/sxe2/sxe2_txrx_poll.c          | 966 ++++++++++++++++++++
 drivers/net/sxe2/sxe2_txrx_poll.h          |  17 +
 drivers/net/sxe2/sxe2_txrx_vec.c           | 192 ++++
 drivers/net/sxe2/sxe2_txrx_vec.h           |  72 ++
 drivers/net/sxe2/sxe2_txrx_vec_common.h    | 235 +++++
 drivers/net/sxe2/sxe2_txrx_vec_sse.c       | 547 ++++++++++++
 drivers/net/sxe2/sxe2_vsi.c                | 211 +++++
 drivers/net/sxe2/sxe2_vsi.h                | 205 +++++
 44 files changed, 10056 insertions(+)
 create mode 100644 doc/guides/nics/features/sxe2.ini
 create mode 100644 doc/guides/nics/sxe2.rst
 create mode 100644 drivers/common/sxe2/meson.build
 create mode 100644 drivers/common/sxe2/sxe2_common.c
 create mode 100644 drivers/common/sxe2/sxe2_common.h
 create mode 100644 drivers/common/sxe2/sxe2_common_log.c
 create mode 100644 drivers/common/sxe2/sxe2_common_log.h
 create mode 100644 drivers/common/sxe2/sxe2_errno.h
 create mode 100644 drivers/common/sxe2/sxe2_host_regs.h
 create mode 100644 drivers/common/sxe2/sxe2_internal_ver.h
 create mode 100644 drivers/common/sxe2/sxe2_ioctl_chnl.c
 create mode 100644 drivers/common/sxe2/sxe2_ioctl_chnl.h
 create mode 100644 drivers/common/sxe2/sxe2_ioctl_chnl_func.h
 create mode 100644 drivers/common/sxe2/sxe2_osal.h
 create mode 100644 drivers/common/sxe2/sxe2_type.h
 create mode 100644 drivers/net/sxe2/meson.build
 create mode 100644 drivers/net/sxe2/sxe2_cmd_chnl.c
 create mode 100644 drivers/net/sxe2/sxe2_cmd_chnl.h
 create mode 100644 drivers/net/sxe2/sxe2_drv_cmd.h
 create mode 100644 drivers/net/sxe2/sxe2_ethdev.c
 create mode 100644 drivers/net/sxe2/sxe2_ethdev.h
 create mode 100644 drivers/net/sxe2/sxe2_irq.h
 create mode 100644 drivers/net/sxe2/sxe2_queue.c
 create mode 100644 drivers/net/sxe2/sxe2_queue.h
 create mode 100644 drivers/net/sxe2/sxe2_rx.c
 create mode 100644 drivers/net/sxe2/sxe2_rx.h
 create mode 100644 drivers/net/sxe2/sxe2_tx.c
 create mode 100644 drivers/net/sxe2/sxe2_tx.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx.c
 create mode 100644 drivers/net/sxe2/sxe2_txrx.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_common.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_poll.c
 create mode 100644 drivers/net/sxe2/sxe2_txrx_poll.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec.c
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec_common.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec_sse.c
 create mode 100644 drivers/net/sxe2/sxe2_vsi.c
 create mode 100644 drivers/net/sxe2/sxe2_vsi.h
Signature · 1 line
2.47.3
#96 lore raw

PATCH v10 1/10 mailmap: add Jie Liu

From: Jie Liu <[email protected]>

---
 .mailmap | 1 +
 1 file changed, 1 insertion(+)
.mailmap +1 -0
index 895412e568..d2c4485636 100644
@@ -739,6 +739,7 @@ Jiawen Wu <[email protected]>
 Jiayu Hu <[email protected]> <[email protected]>
 Jie Hai <[email protected]>
 Jie Liu <[email protected]>
+Jie Liu <[email protected]>
 Jie Pan <[email protected]>
 Jie Wang <[email protected]>
 Jie Zhou <[email protected]> <[email protected]>
Signature · 1 line
2.47.3
#97 lore raw

PATCH v10 2/10 doc: add sxe2 guide and release notes

In reply to [email protected]

From: Jie Liu <[email protected]>

Add a new guide for SXE2 PMD in the nics directory. The guide contains driver capabilities, prerequisites, and compilation/usage instructions.

Update the release notes to announce the addition of the sxe2 network driver.

---
 doc/guides/nics/features/sxe2.ini      | 11 +++++++++++
 doc/guides/nics/index.rst              |  1 +
 doc/guides/nics/sxe2.rst               | 23 +++++++++++++++++++++++
 doc/guides/rel_notes/release_26_07.rst |  4 ++++
 4 files changed, 39 insertions(+)
 create mode 100644 doc/guides/nics/features/sxe2.ini
 create mode 100644 doc/guides/nics/sxe2.rst
doc/guides/nics/features/sxe2.ini new file +11 -0
new file mode 100644
index 0000000000..cbf5a773fb
@@ -0,0 +1,11 @@
+;
+; Supported features of the 'sxe2' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+; A feature with "P" indicates only be supported when non-vector path
+; is selected.
+;
+[Features]
+Queue start/stop     = Y
+Linux                = Y
\ No newline at end of file
doc/guides/nics/index.rst +1 -0
index cb818284fe..e20be478f8 100644
@@ -68,6 +68,7 @@ Network Interface Controller Drivers
     rnp
     sfc_efx
     softnic
+    sxe2
     tap
     thunderx
     txgbe
doc/guides/nics/sxe2.rst new file +23 -0
new file mode 100644
index 0000000000..2f9ba91c33
@@ -0,0 +1,23 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+
+SXE2 Poll Mode Driver
+======================
+
+The sxe2 PMD (**librte_net_sxe2**) provides poll mode driver support for
+10/25/50/100/200 Gbps Network Adapters.
+The embedded switch, Physical Functions (PF),
+and SR-IOV Virtual Functions (VF) are supported
+
+Implementation details
+----------------------
+
+For security reasons and robustness, this driver only deals with virtual
+memory addresses. The way resources allocations are handled by the kernel
+combined with hardware specifications that allow it to handle virtual memory
+addresses directly ensure that DPDK applications cannot access random
+physical memory (or memory that does not belong to the current process).
+
+This capability allows the PMD to coexist with kernel network interfaces
+which remain functional, although they stop receiving unicast packets as
+long as they share the same MAC address.
doc/guides/rel_notes/release_26_07.rst +4 -0
index f012d47a4b..fa0f0f5cca 100644
@@ -64,6 +64,10 @@ New Features
   * ``--auto-probing`` enables the initial bus probing, which is the current default behavior.
 
 
+* **Added Linkdata sxe2 ethernet driver.**
+
+  Added network driver for the Linkdata Network Adapters.
+
 Removed Items
 -------------
 
Signature · 1 line
2.47.3
#98 lore raw

PATCH v10 3/10 drivers: add sxe2 basic structures

In reply to [email protected]

From: Jie Liu <[email protected]>

This patch adds the base infrastructure for the sxe2 common library. It includes the mandatory OS abstraction layer (OSAL), common structure definitions, error codes, and the logging system implementation.

Specifically, this commit:
- Implements the logging stream management using RTE_LOG_LINE.
- Defines device-specific error codes and status registers.
- Adds the initial meson build configuration for the common library.

---
 drivers/common/sxe2/meson.build         |  19 +
 drivers/common/sxe2/sxe2_common_log.c   |  75 +++
 drivers/common/sxe2/sxe2_common_log.h   | 368 ++++++++++++
 drivers/common/sxe2/sxe2_errno.h        | 113 ++++
 drivers/common/sxe2/sxe2_host_regs.h    | 707 ++++++++++++++++++++++++
 drivers/common/sxe2/sxe2_internal_ver.h |  33 ++
 drivers/common/sxe2/sxe2_osal.h         | 584 +++++++++++++++++++
 drivers/common/sxe2/sxe2_type.h         |  65 +++
 drivers/meson.build                     |   1 +
 9 files changed, 1965 insertions(+)
 create mode 100644 drivers/common/sxe2/meson.build
 create mode 100644 drivers/common/sxe2/sxe2_common_log.c
 create mode 100644 drivers/common/sxe2/sxe2_common_log.h
 create mode 100644 drivers/common/sxe2/sxe2_errno.h
 create mode 100644 drivers/common/sxe2/sxe2_host_regs.h
 create mode 100644 drivers/common/sxe2/sxe2_internal_ver.h
 create mode 100644 drivers/common/sxe2/sxe2_osal.h
 create mode 100644 drivers/common/sxe2/sxe2_type.h
drivers/common/sxe2/meson.build new file +19 -0
new file mode 100644
index 0000000000..09ce556f70
@@ -0,0 +1,19 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2023 Corigine, Inc.
+
+if is_windows
+        build = false
+        reason = 'only supported on Linux'
+        subdir_done()
+endif
+
+cflags += [
+        '-DSXE2_DPDK_DRIVER',
+        '-DSXE2_DPDK_DEBUG',
+]
+
+deps += ['bus_pci', 'net', 'eal', 'ethdev']
+
+sources = files(
+        'sxe2_common_log.c',
+)
drivers/common/sxe2/sxe2_common_log.c new file +75 -0

75 lines not on this page · raw message

drivers/common/sxe2/sxe2_common_log.h new file +368 -0

368 lines not on this page · raw message

drivers/common/sxe2/sxe2_errno.h new file +113 -0

113 lines not on this page · raw message

drivers/common/sxe2/sxe2_host_regs.h new file +707 -0

707 lines not on this page · raw message

drivers/common/sxe2/sxe2_internal_ver.h new file +33 -0
new file mode 100644
index 0000000000..a41913fdd8
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+ */
+
+#ifndef __SXE2_INTERNAL_VER_H__
+#define __SXE2_INTERNAL_VER_H__
+
+#define SXE2_VER_MAJOR_OFFSET (16)
+#define SXE2_MK_VER(major, minor) \
+	(major << SXE2_VER_MAJOR_OFFSET | minor)
+#define SXE2_MK_VER_MAJOR(ver) ((ver >> SXE2_VER_MAJOR_OFFSET) & 0xff)
+#define SXE2_MK_VER_MINOR(ver) ((ver) & 0xff)
+
+#define SXE2_ITR_VER_MAJOR_V100    1
+#define SXE2_ITR_VER_MAJOR_V200    2
+
+#define SXE2_ITR_VER_MAJOR      1
+#define SXE2_ITR_VER_MINOR      1
+#define SXE2_ITR_VER SXE2_MK_VER(SXE2_ITR_VER_MAJOR, SXE2_ITR_VER_MINOR)
+
+#define SXE2_CTRL_VER_IS_V100(ver)  (SXE2_MK_VER_MAJOR(ver) == SXE2_ITR_VER_MAJOR_V100)
+#define SXE2_CTRL_VER_IS_V200(ver)  (SXE2_MK_VER_MAJOR(ver) == SXE2_ITR_VER_MAJOR_V200)
+
+#define SXE2LIB_ITR_VER_MAJOR      1
+#define SXE2LIB_ITR_VER_MINOR      1
+#define SXE2LIB_ITR_VER     SXE2_MK_VER(SXE2LIB_ITR_VER_MAJOR, SXE2LIB_ITR_VER_MINOR)
+
+#define SXE2_DRV_CLI_VER_MAJOR      1
+#define SXE2_DRV_CLI_VER_MINOR      1
+#define SXE2_DRV_CLI_VER \
+	SXE2_MK_VER(SXE2_DRV_CLI_VER_MAJOR, SXE2_DRV_CLI_VER_MINOR)
+
+#endif
drivers/common/sxe2/sxe2_osal.h new file +584 -0

584 lines not on this page · raw message

drivers/common/sxe2/sxe2_type.h new file +65 -0

65 lines not on this page · raw message

drivers/meson.build +1 -0
index 6ae102e943..d4ae512bae 100644
@@ -12,6 +12,7 @@ subdirs = [
         'common/qat',     # depends on bus.
         'common/sfc_efx', # depends on bus.
         'common/zsda',    # depends on bus.
+        'common/sxe2',    # depends on bus.
         'mempool',        # depends on common and bus.
         'dma',            # depends on common and bus.
         'net',            # depends on common, bus, mempool
Signature · 1 line
2.47.3
#99 lore raw

PATCH v10 4/10 common/sxe2: add base driver skeleton

In reply to [email protected]

From: Jie Liu <[email protected]>

Initialize the sxe2 PMD skeleton by implementing the PCI probe and remove functions. This includes the setup and cleanup of a character device used for control path communication between the user space and the hardware.

The character device provides an interface for ioctl-based management operations, supporting device-specific configuration.

---
 drivers/common/sxe2/meson.build            |   2 +
 drivers/common/sxe2/sxe2_common.c          | 636 +++++++++++++++++++++
 drivers/common/sxe2/sxe2_common.h          |  86 +++
 drivers/common/sxe2/sxe2_ioctl_chnl.c      | 161 ++++++
 drivers/common/sxe2/sxe2_ioctl_chnl.h      | 141 +++++
 drivers/common/sxe2/sxe2_ioctl_chnl_func.h |  45 ++
 6 files changed, 1071 insertions(+)
 create mode 100644 drivers/common/sxe2/sxe2_common.c
 create mode 100644 drivers/common/sxe2/sxe2_common.h
 create mode 100644 drivers/common/sxe2/sxe2_ioctl_chnl.c
 create mode 100644 drivers/common/sxe2/sxe2_ioctl_chnl.h
 create mode 100644 drivers/common/sxe2/sxe2_ioctl_chnl_func.h
drivers/common/sxe2/meson.build +2 -0
index 09ce556f70..b4ad4ed58d 100644
@@ -15,5 +15,7 @@ cflags += [
 deps += ['bus_pci', 'net', 'eal', 'ethdev']
 
 sources = files(
+        'sxe2_common.c',
         'sxe2_common_log.c',
+        'sxe2_ioctl_chnl.c',
 )
drivers/common/sxe2/sxe2_common.c new file +636 -0

636 lines not on this page · raw message

drivers/common/sxe2/sxe2_common.h new file +86 -0

86 lines not on this page · raw message

drivers/common/sxe2/sxe2_ioctl_chnl.c new file +161 -0

161 lines not on this page · raw message

drivers/common/sxe2/sxe2_ioctl_chnl.h new file +141 -0

141 lines not on this page · raw message

drivers/common/sxe2/sxe2_ioctl_chnl_func.h new file +45 -0

45 lines not on this page · raw message

Signature · 1 line
2.47.3
#100 lore raw

PATCH v10 5/10 drivers: add base driver probe skeleton

In reply to [email protected]

From: Jie Liu <[email protected]>

Initialize the eth_dev_ops for the sxe2 PMD. This includes the implementation of mandatory ethdev operations such as dev_configure, dev_start, dev_stop, and dev_infos_get.

Set up the basic infrastructure for device initialization to allow the driver to be recognized as a valid ethernet device within the DPDK framework.

---
 drivers/common/sxe2/sxe2_ioctl_chnl.c      |  27 +
 drivers/common/sxe2/sxe2_ioctl_chnl_func.h |   9 +
 drivers/net/meson.build                    |   1 +
 drivers/net/sxe2/meson.build               |  28 +
 drivers/net/sxe2/sxe2_cmd_chnl.c           | 319 +++++++++++
 drivers/net/sxe2/sxe2_cmd_chnl.h           |  33 ++
 drivers/net/sxe2/sxe2_drv_cmd.h            | 398 +++++++++++++
 drivers/net/sxe2/sxe2_ethdev.c             | 633 +++++++++++++++++++++
 drivers/net/sxe2/sxe2_ethdev.h             | 295 ++++++++++
 drivers/net/sxe2/sxe2_irq.h                |  49 ++
 drivers/net/sxe2/sxe2_queue.c              |  39 ++
 drivers/net/sxe2/sxe2_queue.h              | 227 ++++++++
 drivers/net/sxe2/sxe2_txrx_common.h        | 541 ++++++++++++++++++
 drivers/net/sxe2/sxe2_txrx_poll.h          |  16 +
 drivers/net/sxe2/sxe2_vsi.c                | 211 +++++++
 drivers/net/sxe2/sxe2_vsi.h                | 205 +++++++
 16 files changed, 3031 insertions(+)
 create mode 100644 drivers/net/sxe2/meson.build
 create mode 100644 drivers/net/sxe2/sxe2_cmd_chnl.c
 create mode 100644 drivers/net/sxe2/sxe2_cmd_chnl.h
 create mode 100644 drivers/net/sxe2/sxe2_drv_cmd.h
 create mode 100644 drivers/net/sxe2/sxe2_ethdev.c
 create mode 100644 drivers/net/sxe2/sxe2_ethdev.h
 create mode 100644 drivers/net/sxe2/sxe2_irq.h
 create mode 100644 drivers/net/sxe2/sxe2_queue.c
 create mode 100644 drivers/net/sxe2/sxe2_queue.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_common.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_poll.h
 create mode 100644 drivers/net/sxe2/sxe2_vsi.c
 create mode 100644 drivers/net/sxe2/sxe2_vsi.h
drivers/common/sxe2/sxe2_ioctl_chnl.c +27 -0
index db09dd3126..e22731065d 100644
@@ -159,3 +159,30 @@ sxe2_drv_dev_handshark(struct sxe2_common_device *cdev)
 l_end:
 	return ret;
 }
+
+RTE_EXPORT_INTERNAL_SYMBOL(sxe2_drv_dev_munmap)
+s32
+sxe2_drv_dev_munmap(struct sxe2_common_device *cdev, void *virt, u64 len)
+{
+	s32 ret = SXE2_SUCCESS;
+
+	if (cdev->config.kernel_reset) {
+		ret = SXE2_ERR_PERM;
+		PMD_LOG_WARN(COM, "kernel reseted, need restart app.");
+		goto l_end;
+	}
+
+	PMD_LOG_DEBUG(COM, "Munmap virt=%p, len=0x%zx",
+		virt, len);
+
+	ret = munmap(virt, len);
+	if (ret < 0) {
+		PMD_LOG_ERR(COM, "Failed to munmap, virt=%p, len=0x%zx, err:%s",
+			virt, len, strerror(errno));
+		ret = SXE2_ERR_IO;
+		goto l_end;
+	}
+
+l_end:
+	return ret;
+}
drivers/common/sxe2/sxe2_ioctl_chnl_func.h +9 -0
index 0c3cb9caea..376c5e3ac7 100644
@@ -38,6 +38,15 @@ __rte_internal
 s32
 sxe2_drv_dev_handshark(struct sxe2_common_device *cdev);
 
+__rte_internal
+void
+*sxe2_drv_dev_mmap(struct sxe2_common_device *cdev, u8 bar_idx,
+		u64 len, u64 offset);
+
+__rte_internal
+s32
+sxe2_drv_dev_munmap(struct sxe2_common_device *cdev, void *virt, u64 len);
+
 #ifdef __cplusplus
 }
 #endif
drivers/net/meson.build +1 -0
index c7dae4ad27..4e8ccb945f 100644
@@ -58,6 +58,7 @@ drivers = [
         'rnp',
         'sfc',
         'softnic',
+        'sxe2',
         'tap',
         'thunderx',
         'txgbe',
drivers/net/sxe2/meson.build new file +28 -0
new file mode 100644
index 0000000000..98d0b7fc6d
@@ -0,0 +1,28 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+#执行子目录base,并获取目标对象
+
+if is_windows
+        build = false
+        reason = 'only supported on Linux'
+        subdir_done()
+endif
+
+cflags += ['-DSXE2_DPDK_DRIVER']
+cflags += ['-DFPGA_VER_ASIC']
+if arch_subdir != 'arm'
+        cflags += ['-Werror']
+endif
+
+cflags += ['-g']
+
+deps += ['common_sxe2', 'hash','cryptodev','security']
+
+sources += files(
+        'sxe2_ethdev.c',
+        'sxe2_cmd_chnl.c',
+        'sxe2_vsi.c',
+        'sxe2_queue.c',
+)
+
+allow_internal_get_api = true
drivers/net/sxe2/sxe2_cmd_chnl.c new file +319 -0

319 lines not on this page · raw message

drivers/net/sxe2/sxe2_cmd_chnl.h new file +33 -0
new file mode 100644
index 0000000000..200fe0be00
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+ */
+
+#ifndef __SXE2_CMD_CHNL_H__
+#define __SXE2_CMD_CHNL_H__
+
+#include "sxe2_ethdev.h"
+#include "sxe2_drv_cmd.h"
+#include "sxe2_ioctl_chnl_func.h"
+
+s32 sxe2_drv_dev_caps_get(struct sxe2_adapter *adapter,
+		struct sxe2_drv_dev_caps_resp *dev_caps);
+
+s32 sxe2_drv_dev_info_get(struct sxe2_adapter *adapter,
+		struct sxe2_drv_dev_info_resp *dev_info_resp);
+
+s32 sxe2_drv_dev_fw_info_get(struct sxe2_adapter *adapter,
+		struct sxe2_drv_dev_fw_info_resp *dev_fw_info_resp);
+
+s32 sxe2_drv_vsi_add(struct sxe2_adapter *adapter, struct sxe2_vsi *vsi);
+
+s32 sxe2_drv_vsi_del(struct sxe2_adapter *adapter, struct sxe2_vsi *vsi);
+
+s32 sxe2_drv_rxq_switch(struct sxe2_adapter *adapter, struct sxe2_rx_queue *rxq, bool enable);
+
+s32 sxe2_drv_txq_switch(struct sxe2_adapter *adapter, struct sxe2_tx_queue *txq, bool enable);
+
+s32 sxe2_drv_rxq_ctxt_cfg(struct sxe2_adapter *adapter, struct sxe2_rx_queue *rxq, u16 rxq_cnt);
+
+s32 sxe2_drv_txq_ctxt_cfg(struct sxe2_adapter *adapter, struct sxe2_tx_queue *txq, u16 txq_cnt);
+
+#endif
drivers/net/sxe2/sxe2_drv_cmd.h new file +398 -0

398 lines not on this page · raw message

drivers/net/sxe2/sxe2_ethdev.c new file +633 -0

633 lines not on this page · raw message

drivers/net/sxe2/sxe2_ethdev.h new file +295 -0

295 lines not on this page · raw message

drivers/net/sxe2/sxe2_irq.h new file +49 -0

49 lines not on this page · raw message

drivers/net/sxe2/sxe2_queue.c new file +39 -0
new file mode 100644
index 0000000000..98343679f6
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+ */
+
+#include "sxe2_ethdev.h"
+#include "sxe2_queue.h"
+#include "sxe2_common_log.h"
+#include "sxe2_errno.h"
+
+void sxe2_sw_queue_ctx_hw_cap_set(struct sxe2_adapter *adapter,
+		struct sxe2_drv_queue_caps *q_caps)
+{
+	adapter->q_ctxt.qp_cnt_assign = q_caps->queues_cnt;
+	adapter->q_ctxt.base_idx_in_pf = q_caps->base_idx_in_pf;
+}
+
+s32 sxe2_queues_init(struct rte_eth_dev *dev)
+{
+	s32 ret = SXE2_SUCCESS;
+	u16 buf_size;
+	u16 frame_size;
+	struct sxe2_rx_queue *rxq;
+	u16 nb_rxq;
+
+	frame_size = dev->data->mtu + SXE2_ETH_OVERHEAD;
+	for (nb_rxq = 0; nb_rxq < dev->data->nb_rx_queues; nb_rxq++) {
+		rxq = dev->data->rx_queues[nb_rxq];
+		if (!rxq)
+			continue;
+
+		buf_size = rte_pktmbuf_data_room_size(rxq->mb_pool) - RTE_PKTMBUF_HEADROOM;
+		rxq->rx_buf_len = RTE_ALIGN_FLOOR(buf_size, (1 << SXE2_RXQ_CTX_DBUFF_SHIFT));
+		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;
+	}
+
+	return ret;
+}
drivers/net/sxe2/sxe2_queue.h new file +227 -0

227 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx_common.h new file +541 -0

541 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx_poll.h new file +16 -0
new file mode 100644
index 0000000000..4924b0f41f
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+ */
+
+#ifndef SXE2_TXRX_POLL_H
+#define SXE2_TXRX_POLL_H
+
+#include "sxe2_queue.h"
+
+u16 sxe2_tx_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, u16 nb_pkts);
+
+u16 sxe2_rx_pkts_scattered(void *rx_queue, struct rte_mbuf **rx_pkts, u16 nb_pkts);
+
+u16 sxe2_rx_pkts_scattered_split(void *rx_queue, struct rte_mbuf **rx_pkts, u16 nb_pkts);
+
+#endif
drivers/net/sxe2/sxe2_vsi.c new file +211 -0

211 lines not on this page · raw message

drivers/net/sxe2/sxe2_vsi.h new file +205 -0

159 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.47.3

Part of the diff is not shown here. View the raw message.

#101 lore raw

PATCH v10 6/10 drivers: support PCI BAR mapping

In reply to [email protected]

From: Jie Liu <[email protected]>

Implement PCI BAR (Base Address Register) mapping and unmapping logic to enable MMIO (Memory Mapped I/O) access to hardware registers.

The driver retrieves the BAR0 virtual address from the PCI resource during the probing phase. This mapping is used for subsequent register-level operations. Proper cleanup is implemented in the device close path.

---
 drivers/common/sxe2/sxe2_ioctl_chnl.c |  34 +++
 drivers/net/sxe2/sxe2_ethdev.c        | 307 ++++++++++++++++++++++++++
 drivers/net/sxe2/sxe2_ethdev.h        |  18 ++
 3 files changed, 359 insertions(+)
drivers/common/sxe2/sxe2_ioctl_chnl.c +34 -0
index e22731065d..2bd7c2b2eb 100644
@@ -160,6 +160,40 @@ sxe2_drv_dev_handshark(struct sxe2_common_device *cdev)
 	return ret;
 }
 
+RTE_EXPORT_INTERNAL_SYMBOL(sxe2_drv_dev_mmap)
+void
+*sxe2_drv_dev_mmap(struct sxe2_common_device *cdev, u8 bar_idx, u64 len, u64 offset)
+{
+	s32 cmd_fd = 0;
+	void *virt = NULL;
+
+	if (cdev->config.kernel_reset) {
+		PMD_LOG_WARN(COM, "kernel reseted, need restart app.");
+		goto l_err;
+	}
+
+	cmd_fd = SXE2_CDEV_TO_CMD_FD(cdev);
+	if (cmd_fd < 0) {
+		PMD_LOG_ERR(COM, "Failed to exec cmd, fd=%d", cmd_fd);
+		goto l_err;
+	}
+
+	PMD_LOG_DEBUG(COM, "fd=%d, bar idx=%d, len=0x%zx, src=0x%"PRIx64", offset=0x%"PRIx64"",
+		bar_idx, cmd_fd, 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));
+	if (virt == MAP_FAILED) {
+		PMD_LOG_ERR(COM, "Failed mmap, cmd_fd=%d, len=0x%zx, offset=0x%"PRIx64", err:%s",
+			cmd_fd, len, offset, strerror(errno));
+		goto l_err;
+	}
+
+	return virt;
+l_err:
+	return NULL;
+}
+
 RTE_EXPORT_INTERNAL_SYMBOL(sxe2_drv_dev_munmap)
 s32
 sxe2_drv_dev_munmap(struct sxe2_common_device *cdev, void *virt, u64 len)
drivers/net/sxe2/sxe2_ethdev.c +307 -0

349 lines not on this page · raw message

drivers/net/sxe2/sxe2_ethdev.h +18 -0
index dc3a3175d1..fb7813ef80 100644
@@ -292,4 +292,22 @@ struct sxe2_adapter {
 #define SXE2_DEV_PRIVATE_TO_ADAPTER(dev) \
 	((struct sxe2_adapter *)(dev)->data->dev_private)
 
+#define SXE2_DEV_TO_PCI(eth_dev) \
+		RTE_DEV_TO_PCI((eth_dev)->device)
+
+struct sxe2_pci_map_bar_info *sxe2_dev_get_bar_info(struct sxe2_adapter *adapter,
+		enum sxe2_pci_map_resource res_type);
+
+s32 sxe2_dev_pci_seg_map(struct sxe2_adapter *adapter,
+		enum sxe2_pci_map_resource res_type, u64 org_len, u64 org_offset);
+
+s32 sxe2_dev_pci_res_seg_map(struct sxe2_adapter *adapter, u32 res_type,
+		u32 item_cnt, u32 item_base);
+
+void sxe2_dev_pci_seg_unmap(struct sxe2_adapter *adapter, u32 res_type);
+
+s32 sxe2_dev_pci_map_init(struct rte_eth_dev *dev);
+
+void sxe2_dev_pci_map_uinit(struct rte_eth_dev *dev);
+
 #endif
Signature · 1 line
2.47.3
#102 lore raw

PATCH v10 7/10 common/sxe2: add ioctl interface for DMA map and unmap

In reply to [email protected]

From: Jie Liu <[email protected]>

Implement DMA mapping and unmapping functionality using ioctl calls. This allows the driver to configure the hardware's IOMMU/DMA tables, ensuring the device can safely access memory buffers allocated by the userspace.

The mapping is established during device initialization or queue setup and is revoked during device closure to prevent memory leaks and ensure hardware security.

---
 drivers/common/sxe2/sxe2_common.c          |  48 ++++++++++
 drivers/common/sxe2/sxe2_ioctl_chnl.c      | 104 +++++++++++++++++++++
 drivers/common/sxe2/sxe2_ioctl_chnl_func.h |   9 ++
 3 files changed, 161 insertions(+)
drivers/common/sxe2/sxe2_common.c +48 -0
index dfdefb8b78..537d4e9f6a 100644
@@ -466,12 +466,60 @@ static s32 sxe2_common_pci_remove(struct rte_pci_device *pci_dev)
 	return ret;
 }
 
+static s32 sxe2_common_pci_dma_map(struct rte_pci_device *pci_dev,
+		void *addr,	u64 iova, size_t len)
+{
+	struct sxe2_common_device *cdev;
+	s32 ret = SXE2_ERROR;
+
+	cdev = sxe2_rtedev_to_cdev(&pci_dev->device);
+	if (cdev == NULL) {
+		ret = SXE2_ERR_NODEV;
+		PMD_LOG_ERR(COM, "Fail to get remove device.");
+		goto l_end;
+	}
+
+	ret = sxe2_drv_dev_dma_map(cdev, (u64)(uintptr_t)addr, iova, len);
+	if (ret) {
+		PMD_LOG_ERR(COM, "Fail to dma map, ret=%d", ret);
+		goto l_end;
+	}
+
+l_end:
+	return ret;
+}
+
+static s32 sxe2_common_pci_dma_unmap(struct rte_pci_device *pci_dev,
+		void *addr __rte_unused, u64 iova, size_t len __rte_unused)
+{
+	struct sxe2_common_device *cdev;
+	s32 ret = SXE2_ERROR;
+
+	cdev = sxe2_rtedev_to_cdev(&pci_dev->device);
+	if (cdev == NULL) {
+		ret = SXE2_ERR_NODEV;
+		PMD_LOG_ERR(COM, "Fail to get remove device.");
+		goto l_end;
+	}
+
+	ret = sxe2_drv_dev_dma_unmap(cdev, iova);
+	if (ret) {
+		PMD_LOG_ERR(COM, "Fail to dma map, ret=%d", ret);
+		goto l_end;
+	}
+
+l_end:
+	return ret;
+}
+
 static struct rte_pci_driver sxe2_common_pci_driver = {
 	.driver = {
 		   .name = SXE2_COMMON_PCI_DRIVER_NAME,
 	},
 	.probe = sxe2_common_pci_probe,
 	.remove = sxe2_common_pci_remove,
+	.dma_map = sxe2_common_pci_dma_map,
+	.dma_unmap = sxe2_common_pci_dma_unmap,
 };
 
 static u32 sxe2_common_pci_id_table_size_get(const struct rte_pci_id *id_table)
drivers/common/sxe2/sxe2_ioctl_chnl.c +104 -0

107 lines not on this page · raw message

drivers/common/sxe2/sxe2_ioctl_chnl_func.h +9 -0
index 376c5e3ac7..e8f983e40e 100644
@@ -47,6 +47,15 @@ __rte_internal
 s32
 sxe2_drv_dev_munmap(struct sxe2_common_device *cdev, void *virt, u64 len);
 
+__rte_internal
+s32
+sxe2_drv_dev_dma_map(struct sxe2_common_device *cdev, u64 vaddr,
+		u64 iova, u64 size);
+
+__rte_internal
+s32
+sxe2_drv_dev_dma_unmap(struct sxe2_common_device *cdev, u64 iova);
+
 #ifdef __cplusplus
 }
 #endif
Signature · 1 line
2.47.3
#103 lore raw

PATCH v10 8/10 net/sxe2: support queue setup and control

In reply to [email protected]

From: Jie Liu <[email protected]>

Add support for Rx and Tx queue setup, release, and management. Implement eth_dev_ops callbacks for rx_queue_setup, tx_queue_setup, rx_queue_release, and tx_queue_release.

This includes:
- Allocating memory for hardware ring descriptors.
- Initializing software ring structures and hardware head/tail pointers.
- Implementing proper resource cleanup logic to prevent memory leaks during queue reconfiguration or device close.

---
 drivers/net/sxe2/meson.build   |   2 +
 drivers/net/sxe2/sxe2_ethdev.c |  64 +++-
 drivers/net/sxe2/sxe2_ethdev.h |   3 +
 drivers/net/sxe2/sxe2_rx.c     | 579 +++++++++++++++++++++++++++++++++
 drivers/net/sxe2/sxe2_rx.h     |  34 ++
 drivers/net/sxe2/sxe2_tx.c     | 447 +++++++++++++++++++++++++
 drivers/net/sxe2/sxe2_tx.h     |  32 ++
 7 files changed, 1143 insertions(+), 18 deletions(-)
 create mode 100644 drivers/net/sxe2/sxe2_rx.c
 create mode 100644 drivers/net/sxe2/sxe2_rx.h
 create mode 100644 drivers/net/sxe2/sxe2_tx.c
 create mode 100644 drivers/net/sxe2/sxe2_tx.h
drivers/net/sxe2/meson.build +2 -0
index 98d0b7fc6d..61467a4e31 100644
@@ -23,6 +23,8 @@ sources += files(
         'sxe2_cmd_chnl.c',
         'sxe2_vsi.c',
         'sxe2_queue.c',
+        'sxe2_tx.c',
+        'sxe2_rx.c',
 )
 
 allow_internal_get_api = true
drivers/net/sxe2/sxe2_ethdev.c +46 -18

94 lines not on this page · raw message

drivers/net/sxe2/sxe2_ethdev.h +3 -0
index fb7813ef80..7999e4f331 100644
@@ -295,6 +295,9 @@ struct sxe2_adapter {
 #define SXE2_DEV_TO_PCI(eth_dev) \
 		RTE_DEV_TO_PCI((eth_dev)->device)
 
+void __iomem *sxe2_pci_map_addr_get(struct sxe2_adapter *adapter,
+		enum sxe2_pci_map_resource res_type, u16 idx_in_func);
+
 struct sxe2_pci_map_bar_info *sxe2_dev_get_bar_info(struct sxe2_adapter *adapter,
 		enum sxe2_pci_map_resource res_type);
 
drivers/net/sxe2/sxe2_rx.c new file +579 -0

579 lines not on this page · raw message

drivers/net/sxe2/sxe2_rx.h new file +34 -0
new file mode 100644
index 0000000000..7c6239b387
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+ */
+
+#ifndef __SXE2_RX_H__
+#define __SXE2_RX_H__
+
+#include "sxe2_queue.h"
+
+s32 __rte_cold sxe2_rx_queue_setup(struct rte_eth_dev *dev,
+				u16 queue_idx, u16 nb_desc, u32 socket_id,
+				const struct rte_eth_rxconf *rx_conf,
+				struct rte_mempool *mp);
+
+s32 __rte_cold sxe2_rx_queue_stop(struct rte_eth_dev *dev, u16 rx_queue_id);
+
+void __rte_cold sxe2_rx_queue_mbufs_release(struct sxe2_rx_queue *rxq);
+
+void __rte_cold sxe2_rx_queue_release(struct rte_eth_dev *dev, u16 queue_idx);
+
+void __rte_cold sxe2_all_rxqs_release(struct rte_eth_dev *dev);
+
+void __rte_cold sxe2_rx_queue_info_get(struct rte_eth_dev *dev, u16 queue_id,
+		struct rte_eth_rxq_info *qinfo);
+
+s32 __rte_cold sxe2_rx_queue_start(struct rte_eth_dev *dev, u16 rx_queue_id);
+
+s32 __rte_cold sxe2_rxqs_all_start(struct rte_eth_dev *dev);
+
+void __rte_cold sxe2_rxqs_all_stop(struct rte_eth_dev *dev);
+
+struct rte_mbuf *sxe2_mbuf_raw_alloc(struct rte_mempool *mp);
+
+#endif
drivers/net/sxe2/sxe2_tx.c new file +447 -0

447 lines not on this page · raw message

drivers/net/sxe2/sxe2_tx.h new file +32 -0
new file mode 100644
index 0000000000..58b668e337
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+ */
+
+#ifndef __SXE2_TX_H__
+#define __SXE2_TX_H__
+#include "sxe2_queue.h"
+
+void __rte_cold sxe2_tx_queue_reset(struct sxe2_tx_queue *txq);
+
+s32 __rte_cold sxe2_tx_queue_start(struct rte_eth_dev *dev, u16 queue_id);
+
+void sxe2_tx_queue_mbufs_release(struct sxe2_tx_queue *txq);
+
+s32 __rte_cold sxe2_tx_queue_stop(struct rte_eth_dev *dev, u16 queue_id);
+
+s32 __rte_cold sxe2_tx_queue_setup(struct rte_eth_dev *dev,
+		u16 queue_idx, u16 nb_desc, u32 socket_id,
+		const struct rte_eth_txconf *tx_conf);
+
+void __rte_cold sxe2_tx_queue_release(struct rte_eth_dev *dev, u16 queue_idx);
+
+void __rte_cold sxe2_all_txqs_release(struct rte_eth_dev *dev);
+
+void __rte_cold sxe2_tx_queue_info_get(struct rte_eth_dev *dev, u16 queue_id,
+		struct rte_eth_txq_info *qinfo);
+
+s32 __rte_cold sxe2_txqs_all_start(struct rte_eth_dev *dev);
+
+void __rte_cold sxe2_txqs_all_stop(struct rte_eth_dev *dev);
+
+#endif
Signature · 1 line
2.47.3
#104 lore raw

PATCH v10 9/10 drivers: add data path for Rx and Tx

In reply to [email protected]

From: Jie Liu <[email protected]>

Implement receive and transmit burst functions for sxe2 PMD. Add sxe2_recv_pkts and sxe2_xmit_pkts as the primary data path interfaces.

The implementation includes:
- Efficient descriptor fetching and mbuf allocation for Rx.
- Descriptor setup and checksum offload handling for Tx.
- Buffer recycling and hardware tail pointer updates.
- Performance-oriented loop unrolling and prefetching where applicable.

---
 drivers/common/sxe2/sxe2_common.c     |  13 +-
 drivers/common/sxe2/sxe2_common_log.h | 105 ----
 drivers/common/sxe2/sxe2_errno.h      |   3 -
 drivers/common/sxe2/sxe2_ioctl_chnl.c |  20 +-
 drivers/common/sxe2/sxe2_osal.h       |   4 +-
 drivers/common/sxe2/sxe2_type.h       |   1 -
 drivers/net/sxe2/meson.build          |   2 +
 drivers/net/sxe2/sxe2_ethdev.c        |  15 +-
 drivers/net/sxe2/sxe2_txrx.c          | 249 ++++++++
 drivers/net/sxe2/sxe2_txrx.h          |  21 +
 drivers/net/sxe2/sxe2_txrx_poll.c     | 782 ++++++++++++++++++++++++++
 11 files changed, 1082 insertions(+), 133 deletions(-)
 create mode 100644 drivers/net/sxe2/sxe2_txrx.c
 create mode 100644 drivers/net/sxe2/sxe2_txrx.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_poll.c
drivers/common/sxe2/sxe2_common.c +6 -7
index 537d4e9f6a..d2ed1460a3 100644
@@ -28,7 +28,7 @@ static TAILQ_HEAD(sxe2_class_drivers, sxe2_class_driver) sxe2_class_drivers_list
 static TAILQ_HEAD(sxe2_common_devices, sxe2_common_device) sxe2_common_devices_list =
 				TAILQ_HEAD_INITIALIZER(sxe2_common_devices_list);
 
-static pthread_mutex_t sxe2_common_devices_list_lock;
+static rte_spinlock_t sxe2_common_devices_list_lock;
 
 static struct rte_pci_id *sxe2_common_pci_id_table;
 
@@ -223,9 +223,9 @@ static struct sxe2_common_device *sxe2_common_device_alloc(
 	cdev->config.kernel_reset = false;
 	rte_ticketlock_init(&cdev->config.lock);
 
-	(void)pthread_mutex_lock(&sxe2_common_devices_list_lock);
+	rte_spinlock_lock(&sxe2_common_devices_list_lock);
 	TAILQ_INSERT_TAIL(&sxe2_common_devices_list, cdev, next);
-	(void)pthread_mutex_unlock(&sxe2_common_devices_list_lock);
+	rte_spinlock_unlock(&sxe2_common_devices_list_lock);
 
 l_end:
 	return cdev;
@@ -233,10 +233,9 @@ static struct sxe2_common_device *sxe2_common_device_alloc(
 
 static void sxe2_common_device_free(struct sxe2_common_device *cdev)
 {
-
-	(void)pthread_mutex_lock(&sxe2_common_devices_list_lock);
+	rte_spinlock_lock(&sxe2_common_devices_list_lock);
 	TAILQ_REMOVE(&sxe2_common_devices_list, cdev, next);
-	(void)pthread_mutex_unlock(&sxe2_common_devices_list_lock);
+	rte_spinlock_unlock(&sxe2_common_devices_list_lock);
 
 	rte_free(cdev);
 }
@@ -662,7 +661,7 @@ sxe2_common_init(void)
 	if (sxe2_commoin_inited)
 		goto l_end;
 
-	pthread_mutex_init(&sxe2_common_devices_list_lock, NULL);
+	rte_spinlock_init(&sxe2_common_devices_list_lock);
 #ifdef SXE2_DPDK_DEBUG
 	sxe2_common_log_stream_init();
 #endif
drivers/common/sxe2/sxe2_common_log.h +0 -105

109 lines not on this page · raw message

drivers/common/sxe2/sxe2_errno.h +0 -3
index 89a715eaef..1257319edf 100644
@@ -50,9 +50,6 @@ enum sxe2_status {
 	SXE2_ERR_NOLCK              = -ENOLCK,
 	SXE2_ERR_NOSYS              = -ENOSYS,
 	SXE2_ERR_NOTEMPTY           = -ENOTEMPTY,
-	SXE2_ERR_ILSEQ              = -EILSEQ,
-	SXE2_ERR_NODATA             = -ENODATA,
-	SXE2_ERR_CANCELED           = -ECANCELED,
 	SXE2_ERR_TIMEDOUT           = -ETIMEDOUT,
 
 	SXE2_ERROR                  = -150,
drivers/common/sxe2/sxe2_ioctl_chnl.c +10 -10
index 1a14d401e7..cb83fb837d 100644
@@ -37,7 +37,7 @@ sxe2_drv_cmd_exec(struct sxe2_common_device *cdev,
 
 	if (cdev->config.kernel_reset) {
 		ret = SXE2_ERR_PERM;
-		PMD_LOG_WARN(COM, "kernel reseted, need restart app.");
+		PMD_LOG_WARN(COM, "kernel reset, need restart app.");
 		goto l_end;
 	}
 
@@ -123,7 +123,7 @@ sxe2_drv_dev_handshark(struct sxe2_common_device *cdev)
 
 	if (cdev->config.kernel_reset) {
 		ret = SXE2_ERR_PERM;
-		PMD_LOG_WARN(COM, "kernel reseted, need restart app.");
+		PMD_LOG_WARN(COM, "kernel reset, need restart app.");
 		goto l_end;
 	}
 
@@ -168,7 +168,7 @@ void
 	void *virt = NULL;
 
 	if (cdev->config.kernel_reset) {
-		PMD_LOG_WARN(COM, "kernel reseted, need restart app.");
+		PMD_LOG_WARN(COM, "kernel reset, need restart app.");
 		goto l_err;
 	}
 
@@ -178,13 +178,13 @@ void
 		goto l_err;
 	}
 
-	PMD_LOG_DEBUG(COM, "fd=%d, bar idx=%d, len=0x%zx, src=0x%"PRIx64", offset=0x%"PRIx64"",
+	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));
 
 	virt = mmap(NULL, len, PROT_READ | PROT_WRITE,
 		MAP_SHARED, cmd_fd, SXE2_COM_PCI_OFFSET_GEN(bar_idx, offset));
 	if (virt == MAP_FAILED) {
-		PMD_LOG_ERR(COM, "Failed mmap, cmd_fd=%d, len=0x%zx, offset=0x%"PRIx64", err:%s",
+		PMD_LOG_ERR(COM, "Failed mmap, cmd_fd=%d, len=%"PRIu64", offset=0x%"PRIx64", err:%s",
 			cmd_fd, len, offset, strerror(errno));
 		goto l_err;
 	}
@@ -206,12 +206,12 @@ sxe2_drv_dev_munmap(struct sxe2_common_device *cdev, void *virt, u64 len)
 		goto l_end;
 	}
 
-	PMD_LOG_DEBUG(COM, "Munmap virt=%p, len=0x%zx",
+	PMD_LOG_DEBUG(COM, "Munmap virt=%p, len=0x%"PRIx64"",
 		virt, len);
 
 	ret = munmap(virt, len);
 	if (ret < 0) {
-		PMD_LOG_ERR(COM, "Failed to munmap, virt=%p, len=0x%zx, err:%s",
+		PMD_LOG_ERR(COM, "Failed to munmap, virt=%p, len=%"PRIu64", err:%s",
 			virt, len, strerror(errno));
 		ret = SXE2_ERR_IO;
 		goto l_end;
@@ -233,7 +233,7 @@ sxe2_drv_dev_dma_map(struct sxe2_common_device *cdev, u64 vaddr,
 
 	if (cdev->config.kernel_reset) {
 		ret = SXE2_ERR_PERM;
-		PMD_LOG_WARN(COM, "kernel reseted, need restart app.");
+		PMD_LOG_WARN(COM, "kernel reset, need restart app.");
 		goto l_end;
 	}
 
@@ -246,7 +246,7 @@ sxe2_drv_dev_dma_map(struct sxe2_common_device *cdev, u64 vaddr,
 		goto l_end;
 	} else if (iova_mode == RTE_IOVA_VA) {
 		if (!cdev->config.support_iommu) {
-			PMD_LOG_ERR(COM, "no iommu not support va mode, plese use pa mode.");
+			PMD_LOG_ERR(COM, "no iommu not support va mode, please use pa mode.");
 			ret = SXE2_ERR_IO;
 			goto l_end;
 		}
@@ -289,7 +289,7 @@ sxe2_drv_dev_dma_unmap(struct sxe2_common_device *cdev, u64 iova)
 
 	if (cdev->config.kernel_reset) {
 		ret = SXE2_ERR_PERM;
-		PMD_LOG_WARN(COM, "kernel reseted, need restart app.");
+		PMD_LOG_WARN(COM, "kernel reset, need restart app.");
 		goto l_end;
 	}
 
drivers/common/sxe2/sxe2_osal.h +1 -3
index fd6823fe98..23882f3f52 100644
@@ -29,8 +29,6 @@
 #define BIT_ULL(a) (1ULL << (a))
 #endif
 
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
-
 #define BITS_PER_BYTE 8
 
 #define IS_UNICAST_ETHER_ADDR(addr)			\
@@ -88,7 +86,7 @@
 			(((n) + (typeof(n))(d) - (typeof(n))1) / (typeof(n))(d))
 #endif
 
-#define usleep_range(min, max) msleep(DIV_ROUND_UP(min, 1000))
+#define usleep_range(min) msleep(DIV_ROUND_UP(min, 1000))
 
 #define __bf_shf(x) ((uint32_t)rte_bsf64(x))
 
drivers/common/sxe2/sxe2_type.h +0 -1
index 56d0a11f48..fbf4a6674f 100644
@@ -8,7 +8,6 @@
 #include <sys/time.h>
 
 #include <stdlib.h>
-#include <stdio.h>
 #include <errno.h>
 #include <stdarg.h>
 #include <unistd.h>
drivers/net/sxe2/meson.build +2 -0
index 61467a4e31..b331451160 100644
@@ -25,6 +25,8 @@ sources += files(
         'sxe2_queue.c',
         'sxe2_tx.c',
         'sxe2_rx.c',
+        'sxe2_txrx_poll.c',
+        'sxe2_txrx.c',
 )
 
 allow_internal_get_api = true
drivers/net/sxe2/sxe2_ethdev.c +11 -4
index c1a65f25ce..68d7e36cf1 100644
@@ -26,6 +26,7 @@
 #include "sxe2_cmd_chnl.h"
 #include "sxe2_tx.h"
 #include "sxe2_rx.h"
+#include "sxe2_txrx.h"
 #include "sxe2_common.h"
 #include "sxe2_common_log.h"
 #include "sxe2_host_regs.h"
@@ -131,6 +132,9 @@ static s32 sxe2_dev_start(struct rte_eth_dev *dev)
 		goto l_end;
 	}
 
+	sxe2_rx_mode_func_set(dev);
+	sxe2_tx_mode_func_set(dev);
+
 	ret = sxe2_queues_start(dev);
 	if (ret) {
 		PMD_LOG_ERR(INIT, "enable queues failed");
@@ -363,8 +367,8 @@ void __iomem *sxe2_pci_map_addr_get(struct sxe2_adapter *adapter,
 	for (i = 0; i < bar_info->map_cnt; i++) {
 		seg_info = &bar_info->seg_info[i];
 		if (res_type == seg_info->type) {
-			addr = (void __iomem *)((uintptr_t)seg_info->addr +
-					seg_info->page_inner_offset + reg_width	* idx_in_func);
+			addr = (uint8_t __iomem *)seg_info->addr +
+					seg_info->page_inner_offset + reg_width * idx_in_func;
 			goto l_end;
 		}
 	}
@@ -475,8 +479,9 @@ s32 sxe2_dev_pci_seg_map(struct sxe2_adapter *adapter,
 
 	map_addr = sxe2_drv_dev_mmap(adapter->cdev, bar_info->bar_idx, aligned_len, aligned_offset);
 	if (!map_addr) {
-		PMD_LOG_ERR(INIT, "Failed to mmap BAR space, type=%d, len=%zu, page_size=%zu",
-					res_type, org_len, page_size);
+		PMD_LOG_ERR(INIT, "Failed to mmap BAR space, type=%d, len=%" PRIu64
+			", offset=%" PRIu64 ", page_size=%zu",
+					res_type, org_len, org_offset, page_size);
 		ret = SXE2_ERR_FAULT;
 		goto l_end;
 	}
@@ -760,6 +765,8 @@ static s32 sxe2_dev_init(struct rte_eth_dev *dev, struct sxe2_dev_kvargs_info *k
 
 	PMD_INIT_FUNC_TRACE();
 
+	sxe2_set_common_function(dev);
+
 	dev->dev_ops = &sxe2_eth_dev_ops;
 
 	ret = sxe2_hw_init(dev);
drivers/net/sxe2/sxe2_txrx.c new file +249 -0

249 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx.h new file +21 -0
new file mode 100644
index 0000000000..cd9ebfa32f
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+ */
+
+#ifndef SXE2_TXRX_H
+#define SXE2_TXRX_H
+#include <ethdev_driver.h>
+#include "sxe2_queue.h"
+
+void sxe2_set_common_function(struct rte_eth_dev *dev);
+
+u16 sxe2_tx_pkts_prepare(__rte_unused void *tx_queue,
+		struct rte_mbuf **tx_pkts, u16 nb_pkts);
+
+void sxe2_tx_mode_func_set(struct rte_eth_dev *dev);
+
+void __rte_cold sxe2_rx_queue_reset(struct sxe2_rx_queue *rxq);
+
+void sxe2_rx_mode_func_set(struct rte_eth_dev *dev);
+
+#endif
drivers/net/sxe2/sxe2_txrx_poll.c new file +782 -0

782 lines not on this page · raw message

Signature · 1 line
2.47.3
#105 lore raw

PATCH v10 10/10 net/sxe2: add vectorized Rx and Tx

In reply to [email protected]

From: Jie Liu <[email protected]>

This patch implements the vectorized data path for the sxe2 PMD. It utilizes SIMD instructions (e.g., SSE) to process multiple packets simultaneously, significantly improving throughput for small packet processing.

The implementation includes:
* Vectorized Rx burst function for bulk descriptor processing.
* Vectorized Tx burst function with optimized resource cleanup.
* Capability flags update to reflect vectorized path support.

---
 drivers/net/sxe2/meson.build            |  11 +
 drivers/net/sxe2/sxe2_ethdev.c          |   8 +-
 drivers/net/sxe2/sxe2_ethdev.h          |   1 -
 drivers/net/sxe2/sxe2_txrx.c            | 222 +++++++---
 drivers/net/sxe2/sxe2_txrx.h            |  12 +-
 drivers/net/sxe2/sxe2_txrx_poll.c       | 186 +++++++-
 drivers/net/sxe2/sxe2_txrx_poll.h       |   3 +-
 drivers/net/sxe2/sxe2_txrx_vec.c        | 192 +++++++++
 drivers/net/sxe2/sxe2_txrx_vec.h        |  72 ++++
 drivers/net/sxe2/sxe2_txrx_vec_common.h | 235 ++++++++++
 drivers/net/sxe2/sxe2_txrx_vec_sse.c    | 547 ++++++++++++++++++++++++
 11 files changed, 1422 insertions(+), 67 deletions(-)
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec.c
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec_common.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec_sse.c
drivers/net/sxe2/meson.build +11 -0
index b331451160..0975366c10 100644
@@ -18,6 +18,16 @@ cflags += ['-g']
 
 deps += ['common_sxe2', 'hash','cryptodev','security']
 
+includes += include_directories('../../common/sxe2')
+
+if arch_subdir == 'x86'
+        sources += files('sxe2_txrx_vec_sse.c')
+
+        if is_windows and cc.get_id() != 'clang'
+                cflags += ['-fno-asynchronous-unwind-tables']
+        endif
+endif
+
 sources += files(
         'sxe2_ethdev.c',
         'sxe2_cmd_chnl.c',
@@ -27,6 +37,7 @@ sources += files(
         'sxe2_rx.c',
         'sxe2_txrx_poll.c',
         'sxe2_txrx.c',
+        'sxe2_txrx_vec.c',
 )
 
 allow_internal_get_api = true
drivers/net/sxe2/sxe2_ethdev.c +2 -6
index 68d7e36cf1..7eaa1722d0 100644
@@ -58,17 +58,11 @@ static const struct rte_pci_id pci_id_sxe2_tbl[] = {
 };
 
 static struct sxe2_pci_map_addr_info sxe2_net_map_addr_info_pf[SXE2_PCI_MAP_RES_MAX_COUNT] = {
-	/* SXE2_PCI_MAP_RES_INVALID */
 	{0, 0, 0},
-	/* SXE2_PCI_MAP_RES_DOORBELL_TX */
 	{ SXE2_TXQ_LEGACY_DBLL(0), 0, 4},
-	/* SXE2_PCI_MAP_RES_DOORBELL_RX_TAIL */
 	{ SXE2_RXQ_TAIL(0), 0, 4},
-	/* SXE2_PCI_MAP_RES_IRQ_DYN */
 	{ SXE2_VF_DYN_CTL(0), 0, 4},
-	/* SXE2_PCI_MAP_RES_IRQ_ITR(默认使用ITR0) */
 	{ SXE2_VF_INT_ITR(0, 0), 0, 4},
-	/* SXE2_PCI_MAP_RES_IRQ_MSIX */
 	{ SXE2_BAR4_MSIX_CTL(0), 4, 0x10},
 };
 
@@ -312,6 +306,8 @@ static const struct eth_dev_ops sxe2_eth_dev_ops = {
 
 	.rxq_info_get               = sxe2_rx_queue_info_get,
 	.txq_info_get               = sxe2_tx_queue_info_get,
+	.rx_burst_mode_get          = sxe2_rx_burst_mode_get,
+	.tx_burst_mode_get          = sxe2_tx_burst_mode_get,
 };
 
 struct sxe2_pci_map_bar_info *sxe2_dev_get_bar_info(struct sxe2_adapter *adapter,
drivers/net/sxe2/sxe2_ethdev.h +0 -1
index 7999e4f331..0881d57d77 100644
@@ -11,7 +11,6 @@
 #include <rte_tm_driver.h>
 #include <rte_io.h>
 
-#include "sxe2_common.h"
 #include "sxe2_errno.h"
 #include "sxe2_type.h"
 #include "sxe2_vsi.h"
drivers/net/sxe2/sxe2_txrx.c +170 -52

373 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx.h +6 -6
index cd9ebfa32f..7bb852789c 100644
@@ -6,16 +6,16 @@
 #define SXE2_TXRX_H
 #include <ethdev_driver.h>
 #include "sxe2_queue.h"
-
 void sxe2_set_common_function(struct rte_eth_dev *dev);
-
+s32 __rte_cold sxe2_tx_simple_batch_support_check(struct rte_eth_dev *dev,
+	u32 *batch_flags);
 u16 sxe2_tx_pkts_prepare(__rte_unused void *tx_queue,
 		struct rte_mbuf **tx_pkts, u16 nb_pkts);
-
 void sxe2_tx_mode_func_set(struct rte_eth_dev *dev);
-
 void __rte_cold sxe2_rx_queue_reset(struct sxe2_rx_queue *rxq);
-
 void sxe2_rx_mode_func_set(struct rte_eth_dev *dev);
-
+s32 sxe2_tx_burst_mode_get(struct rte_eth_dev *dev,
+			__rte_unused uint16_t queue_id, struct rte_eth_burst_mode *mode);
+s32 sxe2_rx_burst_mode_get(struct rte_eth_dev *dev,
+			__rte_unused u16 queue_id, struct rte_eth_burst_mode *mode);
 #endif
drivers/net/sxe2/sxe2_txrx_poll.c +185 -1

204 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx_poll.h +2 -1
index 4924b0f41f..67da08e58e 100644
@@ -8,7 +8,8 @@
 #include "sxe2_queue.h"
 
 u16 sxe2_tx_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, u16 nb_pkts);
-
+u16 sxe2_tx_pkts_simple(void *tx_queue,
+			struct rte_mbuf **tx_pkts, u16 nb_pkts);
 u16 sxe2_rx_pkts_scattered(void *rx_queue, struct rte_mbuf **rx_pkts, u16 nb_pkts);
 
 u16 sxe2_rx_pkts_scattered_split(void *rx_queue, struct rte_mbuf **rx_pkts, u16 nb_pkts);
drivers/net/sxe2/sxe2_txrx_vec.c new file +192 -0

192 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx_vec.h new file +72 -0

72 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx_vec_common.h new file +235 -0

235 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx_vec_sse.c new file +547 -0

547 lines not on this page · raw message

Signature · 1 line
2.47.3
#106 lore raw

v11 cover Add Linkdata sxe2 driver

From: Jie Liu <[email protected]>

V11:
- Addressed AI comments

Jie Liu (9):
mailmap: add Jie Liu
doc: add sxe2 guide and release notes
drivers: add sxe2 basic structures common/sxe2: add base driver skeleton
drivers: add base driver probe skeleton
drivers: support PCI BAR mapping
common/sxe2: add ioctl interface for DMA map and unmap net/sxe2: support queue setup and control
drivers: add data path for Rx and Tx

 .mailmap                                   |   1 +
 doc/guides/nics/features/sxe2.ini          |  11 +
 doc/guides/nics/index.rst                  |   1 +
 doc/guides/nics/sxe2.rst                   |  23 +
 doc/guides/rel_notes/release_26_07.rst     |   4 +
 drivers/common/sxe2/meson.build            |  21 +
 drivers/common/sxe2/sxe2_common.c          | 683 +++++++++++++++
 drivers/common/sxe2/sxe2_common.h          |  86 ++
 drivers/common/sxe2/sxe2_common_log.c      |  75 ++
 drivers/common/sxe2/sxe2_common_log.h      | 263 ++++++
 drivers/common/sxe2/sxe2_errno.h           | 110 +++
 drivers/common/sxe2/sxe2_host_regs.h       | 707 +++++++++++++++
 drivers/common/sxe2/sxe2_internal_ver.h    |  33 +
 drivers/common/sxe2/sxe2_ioctl_chnl.c      | 326 +++++++
 drivers/common/sxe2/sxe2_ioctl_chnl.h      | 141 +++
 drivers/common/sxe2/sxe2_ioctl_chnl_func.h |  63 ++
 drivers/common/sxe2/sxe2_osal.h            | 582 ++++++++++++
 drivers/common/sxe2/sxe2_type.h            |  64 ++
 drivers/meson.build                        |   1 +
 drivers/net/meson.build                    |   1 +
 drivers/net/sxe2/meson.build               |  32 +
 drivers/net/sxe2/sxe2_cmd_chnl.c           | 319 +++++++
 drivers/net/sxe2/sxe2_cmd_chnl.h           |  33 +
 drivers/net/sxe2/sxe2_drv_cmd.h            | 398 +++++++++
 drivers/net/sxe2/sxe2_ethdev.c             | 975 +++++++++++++++++++++
 drivers/net/sxe2/sxe2_ethdev.h             | 316 +++++++
 drivers/net/sxe2/sxe2_irq.h                |  49 ++
 drivers/net/sxe2/sxe2_queue.c              |  39 +
 drivers/net/sxe2/sxe2_queue.h              | 227 +++++
 drivers/net/sxe2/sxe2_rx.c                 | 579 ++++++++++++
 drivers/net/sxe2/sxe2_rx.h                 |  34 +
 drivers/net/sxe2/sxe2_tx.c                 | 447 ++++++++++
 drivers/net/sxe2/sxe2_tx.h                 |  32 +
 drivers/net/sxe2/sxe2_txrx.c               | 249 ++++++
 drivers/net/sxe2/sxe2_txrx.h               |  21 +
 drivers/net/sxe2/sxe2_txrx_common.h        | 541 ++++++++++++
 drivers/net/sxe2/sxe2_txrx_poll.c          | 782 +++++++++++++++++
 drivers/net/sxe2/sxe2_txrx_poll.h          |  16 +
 drivers/net/sxe2/sxe2_vsi.c                | 211 +++++
 drivers/net/sxe2/sxe2_vsi.h                | 205 +++++
 40 files changed, 8701 insertions(+)
 create mode 100644 doc/guides/nics/features/sxe2.ini
 create mode 100644 doc/guides/nics/sxe2.rst
 create mode 100644 drivers/common/sxe2/meson.build
 create mode 100644 drivers/common/sxe2/sxe2_common.c
 create mode 100644 drivers/common/sxe2/sxe2_common.h
 create mode 100644 drivers/common/sxe2/sxe2_common_log.c
 create mode 100644 drivers/common/sxe2/sxe2_common_log.h
 create mode 100644 drivers/common/sxe2/sxe2_errno.h
 create mode 100644 drivers/common/sxe2/sxe2_host_regs.h
 create mode 100644 drivers/common/sxe2/sxe2_internal_ver.h
 create mode 100644 drivers/common/sxe2/sxe2_ioctl_chnl.c
 create mode 100644 drivers/common/sxe2/sxe2_ioctl_chnl.h
 create mode 100644 drivers/common/sxe2/sxe2_ioctl_chnl_func.h
 create mode 100644 drivers/common/sxe2/sxe2_osal.h
 create mode 100644 drivers/common/sxe2/sxe2_type.h
 create mode 100644 drivers/net/sxe2/meson.build
 create mode 100644 drivers/net/sxe2/sxe2_cmd_chnl.c
 create mode 100644 drivers/net/sxe2/sxe2_cmd_chnl.h
 create mode 100644 drivers/net/sxe2/sxe2_drv_cmd.h
 create mode 100644 drivers/net/sxe2/sxe2_ethdev.c
 create mode 100644 drivers/net/sxe2/sxe2_ethdev.h
 create mode 100644 drivers/net/sxe2/sxe2_irq.h
 create mode 100644 drivers/net/sxe2/sxe2_queue.c
 create mode 100644 drivers/net/sxe2/sxe2_queue.h
 create mode 100644 drivers/net/sxe2/sxe2_rx.c
 create mode 100644 drivers/net/sxe2/sxe2_rx.h
 create mode 100644 drivers/net/sxe2/sxe2_tx.c
 create mode 100644 drivers/net/sxe2/sxe2_tx.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx.c
 create mode 100644 drivers/net/sxe2/sxe2_txrx.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_common.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_poll.c
 create mode 100644 drivers/net/sxe2/sxe2_txrx_poll.h
 create mode 100644 drivers/net/sxe2/sxe2_vsi.c
 create mode 100644 drivers/net/sxe2/sxe2_vsi.h
Signature · 1 line
2.47.3
#107 lore raw

PATCH v11 1/9 mailmap: add Jie Liu

From: Jie Liu <[email protected]>

---
 .mailmap | 1 +
 1 file changed, 1 insertion(+)
.mailmap +1 -0
index 895412e568..d2c4485636 100644
@@ -739,6 +739,7 @@ Jiawen Wu <[email protected]>
 Jiayu Hu <[email protected]> <[email protected]>
 Jie Hai <[email protected]>
 Jie Liu <[email protected]>
+Jie Liu <[email protected]>
 Jie Pan <[email protected]>
 Jie Wang <[email protected]>
 Jie Zhou <[email protected]> <[email protected]>
Signature · 1 line
2.47.3
#108 lore raw

PATCH v11 2/9 doc: add sxe2 guide and release notes

In reply to [email protected]

From: Jie Liu <[email protected]>

Add a new guide for SXE2 PMD in the nics directory. The guide contains driver capabilities, prerequisites, and compilation/usage instructions.

Update the release notes to announce the addition of the sxe2 network driver.

---
 doc/guides/nics/features/sxe2.ini      | 11 +++++++++++
 doc/guides/nics/index.rst              |  1 +
 doc/guides/nics/sxe2.rst               | 23 +++++++++++++++++++++++
 doc/guides/rel_notes/release_26_07.rst |  4 ++++
 4 files changed, 39 insertions(+)
 create mode 100644 doc/guides/nics/features/sxe2.ini
 create mode 100644 doc/guides/nics/sxe2.rst
doc/guides/nics/features/sxe2.ini new file +11 -0
new file mode 100644
index 0000000000..cbf5a773fb
@@ -0,0 +1,11 @@
+;
+; Supported features of the 'sxe2' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+; A feature with "P" indicates only be supported when non-vector path
+; is selected.
+;
+[Features]
+Queue start/stop     = Y
+Linux                = Y
\ No newline at end of file
doc/guides/nics/index.rst +1 -0
index cb818284fe..e20be478f8 100644
@@ -68,6 +68,7 @@ Network Interface Controller Drivers
     rnp
     sfc_efx
     softnic
+    sxe2
     tap
     thunderx
     txgbe
doc/guides/nics/sxe2.rst new file +23 -0
new file mode 100644
index 0000000000..2f9ba91c33
@@ -0,0 +1,23 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+
+SXE2 Poll Mode Driver
+======================
+
+The sxe2 PMD (**librte_net_sxe2**) provides poll mode driver support for
+10/25/50/100/200 Gbps Network Adapters.
+The embedded switch, Physical Functions (PF),
+and SR-IOV Virtual Functions (VF) are supported
+
+Implementation details
+----------------------
+
+For security reasons and robustness, this driver only deals with virtual
+memory addresses. The way resources allocations are handled by the kernel
+combined with hardware specifications that allow it to handle virtual memory
+addresses directly ensure that DPDK applications cannot access random
+physical memory (or memory that does not belong to the current process).
+
+This capability allows the PMD to coexist with kernel network interfaces
+which remain functional, although they stop receiving unicast packets as
+long as they share the same MAC address.
doc/guides/rel_notes/release_26_07.rst +4 -0
index f012d47a4b..fa0f0f5cca 100644
@@ -64,6 +64,10 @@ New Features
   * ``--auto-probing`` enables the initial bus probing, which is the current default behavior.
 
 
+* **Added Linkdata sxe2 ethernet driver.**
+
+  Added network driver for the Linkdata Network Adapters.
+
 Removed Items
 -------------
 
Signature · 1 line
2.47.3
#109 lore raw

PATCH v11 3/9 drivers: add sxe2 basic structures

In reply to [email protected]

From: Jie Liu <[email protected]>

This patch adds the base infrastructure for the sxe2 common library. It includes the mandatory OS abstraction layer (OSAL), common structure definitions, error codes, and the logging system implementation.

Specifically, this commit:
- Implements the logging stream management using RTE_LOG_LINE.
- Defines device-specific error codes and status registers.
- Adds the initial meson build configuration for the common library.

---
 drivers/common/sxe2/meson.build         |  19 +
 drivers/common/sxe2/sxe2_common_log.c   |  75 +++
 drivers/common/sxe2/sxe2_common_log.h   | 368 ++++++++++++
 drivers/common/sxe2/sxe2_errno.h        | 113 ++++
 drivers/common/sxe2/sxe2_host_regs.h    | 707 ++++++++++++++++++++++++
 drivers/common/sxe2/sxe2_internal_ver.h |  33 ++
 drivers/common/sxe2/sxe2_osal.h         | 584 +++++++++++++++++++
 drivers/common/sxe2/sxe2_type.h         |  65 +++
 drivers/meson.build                     |   1 +
 9 files changed, 1965 insertions(+)
 create mode 100644 drivers/common/sxe2/meson.build
 create mode 100644 drivers/common/sxe2/sxe2_common_log.c
 create mode 100644 drivers/common/sxe2/sxe2_common_log.h
 create mode 100644 drivers/common/sxe2/sxe2_errno.h
 create mode 100644 drivers/common/sxe2/sxe2_host_regs.h
 create mode 100644 drivers/common/sxe2/sxe2_internal_ver.h
 create mode 100644 drivers/common/sxe2/sxe2_osal.h
 create mode 100644 drivers/common/sxe2/sxe2_type.h
drivers/common/sxe2/meson.build new file +19 -0
new file mode 100644
index 0000000000..09ce556f70
@@ -0,0 +1,19 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2023 Corigine, Inc.
+
+if is_windows
+        build = false
+        reason = 'only supported on Linux'
+        subdir_done()
+endif
+
+cflags += [
+        '-DSXE2_DPDK_DRIVER',
+        '-DSXE2_DPDK_DEBUG',
+]
+
+deps += ['bus_pci', 'net', 'eal', 'ethdev']
+
+sources = files(
+        'sxe2_common_log.c',
+)
drivers/common/sxe2/sxe2_common_log.c new file +75 -0

75 lines not on this page · raw message

drivers/common/sxe2/sxe2_common_log.h new file +368 -0

368 lines not on this page · raw message

drivers/common/sxe2/sxe2_errno.h new file +113 -0

113 lines not on this page · raw message

drivers/common/sxe2/sxe2_host_regs.h new file +707 -0

707 lines not on this page · raw message

drivers/common/sxe2/sxe2_internal_ver.h new file +33 -0
new file mode 100644
index 0000000000..a41913fdd8
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+ */
+
+#ifndef __SXE2_INTERNAL_VER_H__
+#define __SXE2_INTERNAL_VER_H__
+
+#define SXE2_VER_MAJOR_OFFSET (16)
+#define SXE2_MK_VER(major, minor) \
+	(major << SXE2_VER_MAJOR_OFFSET | minor)
+#define SXE2_MK_VER_MAJOR(ver) ((ver >> SXE2_VER_MAJOR_OFFSET) & 0xff)
+#define SXE2_MK_VER_MINOR(ver) ((ver) & 0xff)
+
+#define SXE2_ITR_VER_MAJOR_V100    1
+#define SXE2_ITR_VER_MAJOR_V200    2
+
+#define SXE2_ITR_VER_MAJOR      1
+#define SXE2_ITR_VER_MINOR      1
+#define SXE2_ITR_VER SXE2_MK_VER(SXE2_ITR_VER_MAJOR, SXE2_ITR_VER_MINOR)
+
+#define SXE2_CTRL_VER_IS_V100(ver)  (SXE2_MK_VER_MAJOR(ver) == SXE2_ITR_VER_MAJOR_V100)
+#define SXE2_CTRL_VER_IS_V200(ver)  (SXE2_MK_VER_MAJOR(ver) == SXE2_ITR_VER_MAJOR_V200)
+
+#define SXE2LIB_ITR_VER_MAJOR      1
+#define SXE2LIB_ITR_VER_MINOR      1
+#define SXE2LIB_ITR_VER     SXE2_MK_VER(SXE2LIB_ITR_VER_MAJOR, SXE2LIB_ITR_VER_MINOR)
+
+#define SXE2_DRV_CLI_VER_MAJOR      1
+#define SXE2_DRV_CLI_VER_MINOR      1
+#define SXE2_DRV_CLI_VER \
+	SXE2_MK_VER(SXE2_DRV_CLI_VER_MAJOR, SXE2_DRV_CLI_VER_MINOR)
+
+#endif
drivers/common/sxe2/sxe2_osal.h new file +584 -0

584 lines not on this page · raw message

drivers/common/sxe2/sxe2_type.h new file +65 -0

65 lines not on this page · raw message

drivers/meson.build +1 -0
index 6ae102e943..d4ae512bae 100644
@@ -12,6 +12,7 @@ subdirs = [
         'common/qat',     # depends on bus.
         'common/sfc_efx', # depends on bus.
         'common/zsda',    # depends on bus.
+        'common/sxe2',    # depends on bus.
         'mempool',        # depends on common and bus.
         'dma',            # depends on common and bus.
         'net',            # depends on common, bus, mempool
Signature · 1 line
2.47.3
#110 lore raw

PATCH v11 4/9 common/sxe2: add base driver skeleton

In reply to [email protected]

From: Jie Liu <[email protected]>

Initialize the sxe2 PMD skeleton by implementing the PCI probe and remove functions. This includes the setup and cleanup of a character device used for control path communication between the user space and the hardware.

The character device provides an interface for ioctl-based management operations, supporting device-specific configuration.

---
 drivers/common/sxe2/meson.build            |   2 +
 drivers/common/sxe2/sxe2_common.c          | 636 +++++++++++++++++++++
 drivers/common/sxe2/sxe2_common.h          |  86 +++
 drivers/common/sxe2/sxe2_ioctl_chnl.c      | 161 ++++++
 drivers/common/sxe2/sxe2_ioctl_chnl.h      | 141 +++++
 drivers/common/sxe2/sxe2_ioctl_chnl_func.h |  45 ++
 6 files changed, 1071 insertions(+)
 create mode 100644 drivers/common/sxe2/sxe2_common.c
 create mode 100644 drivers/common/sxe2/sxe2_common.h
 create mode 100644 drivers/common/sxe2/sxe2_ioctl_chnl.c
 create mode 100644 drivers/common/sxe2/sxe2_ioctl_chnl.h
 create mode 100644 drivers/common/sxe2/sxe2_ioctl_chnl_func.h
drivers/common/sxe2/meson.build +2 -0
index 09ce556f70..b4ad4ed58d 100644
@@ -15,5 +15,7 @@ cflags += [
 deps += ['bus_pci', 'net', 'eal', 'ethdev']
 
 sources = files(
+        'sxe2_common.c',
         'sxe2_common_log.c',
+        'sxe2_ioctl_chnl.c',
 )
drivers/common/sxe2/sxe2_common.c new file +636 -0

636 lines not on this page · raw message

drivers/common/sxe2/sxe2_common.h new file +86 -0

86 lines not on this page · raw message

drivers/common/sxe2/sxe2_ioctl_chnl.c new file +161 -0

161 lines not on this page · raw message

drivers/common/sxe2/sxe2_ioctl_chnl.h new file +141 -0

141 lines not on this page · raw message

drivers/common/sxe2/sxe2_ioctl_chnl_func.h new file +45 -0

45 lines not on this page · raw message

Signature · 1 line
2.47.3
#111 lore raw

PATCH v11 5/9 drivers: add base driver probe skeleton

In reply to [email protected]

From: Jie Liu <[email protected]>

Initialize the eth_dev_ops for the sxe2 PMD. This includes the implementation of mandatory ethdev operations such as dev_configure, dev_start, dev_stop, and dev_infos_get.

Set up the basic infrastructure for device initialization to allow the driver to be recognized as a valid ethernet device within the DPDK framework.

---
 drivers/common/sxe2/sxe2_ioctl_chnl.c      |  27 +
 drivers/common/sxe2/sxe2_ioctl_chnl_func.h |   9 +
 drivers/net/meson.build                    |   1 +
 drivers/net/sxe2/meson.build               |  28 +
 drivers/net/sxe2/sxe2_cmd_chnl.c           | 319 +++++++++++
 drivers/net/sxe2/sxe2_cmd_chnl.h           |  33 ++
 drivers/net/sxe2/sxe2_drv_cmd.h            | 398 +++++++++++++
 drivers/net/sxe2/sxe2_ethdev.c             | 633 +++++++++++++++++++++
 drivers/net/sxe2/sxe2_ethdev.h             | 295 ++++++++++
 drivers/net/sxe2/sxe2_irq.h                |  49 ++
 drivers/net/sxe2/sxe2_queue.c              |  39 ++
 drivers/net/sxe2/sxe2_queue.h              | 227 ++++++++
 drivers/net/sxe2/sxe2_txrx_common.h        | 541 ++++++++++++++++++
 drivers/net/sxe2/sxe2_txrx_poll.h          |  16 +
 drivers/net/sxe2/sxe2_vsi.c                | 211 +++++++
 drivers/net/sxe2/sxe2_vsi.h                | 205 +++++++
 16 files changed, 3031 insertions(+)
 create mode 100644 drivers/net/sxe2/meson.build
 create mode 100644 drivers/net/sxe2/sxe2_cmd_chnl.c
 create mode 100644 drivers/net/sxe2/sxe2_cmd_chnl.h
 create mode 100644 drivers/net/sxe2/sxe2_drv_cmd.h
 create mode 100644 drivers/net/sxe2/sxe2_ethdev.c
 create mode 100644 drivers/net/sxe2/sxe2_ethdev.h
 create mode 100644 drivers/net/sxe2/sxe2_irq.h
 create mode 100644 drivers/net/sxe2/sxe2_queue.c
 create mode 100644 drivers/net/sxe2/sxe2_queue.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_common.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_poll.h
 create mode 100644 drivers/net/sxe2/sxe2_vsi.c
 create mode 100644 drivers/net/sxe2/sxe2_vsi.h
drivers/common/sxe2/sxe2_ioctl_chnl.c +27 -0
index db09dd3126..e22731065d 100644
@@ -159,3 +159,30 @@ sxe2_drv_dev_handshark(struct sxe2_common_device *cdev)
 l_end:
 	return ret;
 }
+
+RTE_EXPORT_INTERNAL_SYMBOL(sxe2_drv_dev_munmap)
+s32
+sxe2_drv_dev_munmap(struct sxe2_common_device *cdev, void *virt, u64 len)
+{
+	s32 ret = SXE2_SUCCESS;
+
+	if (cdev->config.kernel_reset) {
+		ret = SXE2_ERR_PERM;
+		PMD_LOG_WARN(COM, "kernel reseted, need restart app.");
+		goto l_end;
+	}
+
+	PMD_LOG_DEBUG(COM, "Munmap virt=%p, len=0x%zx",
+		virt, len);
+
+	ret = munmap(virt, len);
+	if (ret < 0) {
+		PMD_LOG_ERR(COM, "Failed to munmap, virt=%p, len=0x%zx, err:%s",
+			virt, len, strerror(errno));
+		ret = SXE2_ERR_IO;
+		goto l_end;
+	}
+
+l_end:
+	return ret;
+}
drivers/common/sxe2/sxe2_ioctl_chnl_func.h +9 -0
index 0c3cb9caea..376c5e3ac7 100644
@@ -38,6 +38,15 @@ __rte_internal
 s32
 sxe2_drv_dev_handshark(struct sxe2_common_device *cdev);
 
+__rte_internal
+void
+*sxe2_drv_dev_mmap(struct sxe2_common_device *cdev, u8 bar_idx,
+		u64 len, u64 offset);
+
+__rte_internal
+s32
+sxe2_drv_dev_munmap(struct sxe2_common_device *cdev, void *virt, u64 len);
+
 #ifdef __cplusplus
 }
 #endif
drivers/net/meson.build +1 -0
index c7dae4ad27..4e8ccb945f 100644
@@ -58,6 +58,7 @@ drivers = [
         'rnp',
         'sfc',
         'softnic',
+        'sxe2',
         'tap',
         'thunderx',
         'txgbe',
drivers/net/sxe2/meson.build new file +28 -0
new file mode 100644
index 0000000000..98d0b7fc6d
@@ -0,0 +1,28 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+#执行子目录base,并获取目标对象
+
+if is_windows
+        build = false
+        reason = 'only supported on Linux'
+        subdir_done()
+endif
+
+cflags += ['-DSXE2_DPDK_DRIVER']
+cflags += ['-DFPGA_VER_ASIC']
+if arch_subdir != 'arm'
+        cflags += ['-Werror']
+endif
+
+cflags += ['-g']
+
+deps += ['common_sxe2', 'hash','cryptodev','security']
+
+sources += files(
+        'sxe2_ethdev.c',
+        'sxe2_cmd_chnl.c',
+        'sxe2_vsi.c',
+        'sxe2_queue.c',
+)
+
+allow_internal_get_api = true
drivers/net/sxe2/sxe2_cmd_chnl.c new file +319 -0

319 lines not on this page · raw message

drivers/net/sxe2/sxe2_cmd_chnl.h new file +33 -0
new file mode 100644
index 0000000000..200fe0be00
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+ */
+
+#ifndef __SXE2_CMD_CHNL_H__
+#define __SXE2_CMD_CHNL_H__
+
+#include "sxe2_ethdev.h"
+#include "sxe2_drv_cmd.h"
+#include "sxe2_ioctl_chnl_func.h"
+
+s32 sxe2_drv_dev_caps_get(struct sxe2_adapter *adapter,
+		struct sxe2_drv_dev_caps_resp *dev_caps);
+
+s32 sxe2_drv_dev_info_get(struct sxe2_adapter *adapter,
+		struct sxe2_drv_dev_info_resp *dev_info_resp);
+
+s32 sxe2_drv_dev_fw_info_get(struct sxe2_adapter *adapter,
+		struct sxe2_drv_dev_fw_info_resp *dev_fw_info_resp);
+
+s32 sxe2_drv_vsi_add(struct sxe2_adapter *adapter, struct sxe2_vsi *vsi);
+
+s32 sxe2_drv_vsi_del(struct sxe2_adapter *adapter, struct sxe2_vsi *vsi);
+
+s32 sxe2_drv_rxq_switch(struct sxe2_adapter *adapter, struct sxe2_rx_queue *rxq, bool enable);
+
+s32 sxe2_drv_txq_switch(struct sxe2_adapter *adapter, struct sxe2_tx_queue *txq, bool enable);
+
+s32 sxe2_drv_rxq_ctxt_cfg(struct sxe2_adapter *adapter, struct sxe2_rx_queue *rxq, u16 rxq_cnt);
+
+s32 sxe2_drv_txq_ctxt_cfg(struct sxe2_adapter *adapter, struct sxe2_tx_queue *txq, u16 txq_cnt);
+
+#endif
drivers/net/sxe2/sxe2_drv_cmd.h new file +398 -0

398 lines not on this page · raw message

drivers/net/sxe2/sxe2_ethdev.c new file +633 -0

633 lines not on this page · raw message

drivers/net/sxe2/sxe2_ethdev.h new file +295 -0

295 lines not on this page · raw message

drivers/net/sxe2/sxe2_irq.h new file +49 -0

49 lines not on this page · raw message

drivers/net/sxe2/sxe2_queue.c new file +39 -0
new file mode 100644
index 0000000000..98343679f6
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+ */
+
+#include "sxe2_ethdev.h"
+#include "sxe2_queue.h"
+#include "sxe2_common_log.h"
+#include "sxe2_errno.h"
+
+void sxe2_sw_queue_ctx_hw_cap_set(struct sxe2_adapter *adapter,
+		struct sxe2_drv_queue_caps *q_caps)
+{
+	adapter->q_ctxt.qp_cnt_assign = q_caps->queues_cnt;
+	adapter->q_ctxt.base_idx_in_pf = q_caps->base_idx_in_pf;
+}
+
+s32 sxe2_queues_init(struct rte_eth_dev *dev)
+{
+	s32 ret = SXE2_SUCCESS;
+	u16 buf_size;
+	u16 frame_size;
+	struct sxe2_rx_queue *rxq;
+	u16 nb_rxq;
+
+	frame_size = dev->data->mtu + SXE2_ETH_OVERHEAD;
+	for (nb_rxq = 0; nb_rxq < dev->data->nb_rx_queues; nb_rxq++) {
+		rxq = dev->data->rx_queues[nb_rxq];
+		if (!rxq)
+			continue;
+
+		buf_size = rte_pktmbuf_data_room_size(rxq->mb_pool) - RTE_PKTMBUF_HEADROOM;
+		rxq->rx_buf_len = RTE_ALIGN_FLOOR(buf_size, (1 << SXE2_RXQ_CTX_DBUFF_SHIFT));
+		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;
+	}
+
+	return ret;
+}
drivers/net/sxe2/sxe2_queue.h new file +227 -0

227 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx_common.h new file +541 -0

541 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx_poll.h new file +16 -0
new file mode 100644
index 0000000000..4924b0f41f
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+ */
+
+#ifndef SXE2_TXRX_POLL_H
+#define SXE2_TXRX_POLL_H
+
+#include "sxe2_queue.h"
+
+u16 sxe2_tx_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, u16 nb_pkts);
+
+u16 sxe2_rx_pkts_scattered(void *rx_queue, struct rte_mbuf **rx_pkts, u16 nb_pkts);
+
+u16 sxe2_rx_pkts_scattered_split(void *rx_queue, struct rte_mbuf **rx_pkts, u16 nb_pkts);
+
+#endif
drivers/net/sxe2/sxe2_vsi.c new file +211 -0

211 lines not on this page · raw message

drivers/net/sxe2/sxe2_vsi.h new file +205 -0

159 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.47.3

Part of the diff is not shown here. View the raw message.

#112 lore raw

PATCH v11 6/9 drivers: support PCI BAR mapping

In reply to [email protected]

From: Jie Liu <[email protected]>

Implement PCI BAR (Base Address Register) mapping and unmapping logic to enable MMIO (Memory Mapped I/O) access to hardware registers.

The driver retrieves the BAR0 virtual address from the PCI resource during the probing phase. This mapping is used for subsequent register-level operations. Proper cleanup is implemented in the device close path.

---
 drivers/common/sxe2/sxe2_ioctl_chnl.c |  34 +++
 drivers/net/sxe2/sxe2_ethdev.c        | 307 ++++++++++++++++++++++++++
 drivers/net/sxe2/sxe2_ethdev.h        |  18 ++
 3 files changed, 359 insertions(+)
drivers/common/sxe2/sxe2_ioctl_chnl.c +34 -0
index e22731065d..2bd7c2b2eb 100644
@@ -160,6 +160,40 @@ sxe2_drv_dev_handshark(struct sxe2_common_device *cdev)
 	return ret;
 }
 
+RTE_EXPORT_INTERNAL_SYMBOL(sxe2_drv_dev_mmap)
+void
+*sxe2_drv_dev_mmap(struct sxe2_common_device *cdev, u8 bar_idx, u64 len, u64 offset)
+{
+	s32 cmd_fd = 0;
+	void *virt = NULL;
+
+	if (cdev->config.kernel_reset) {
+		PMD_LOG_WARN(COM, "kernel reseted, need restart app.");
+		goto l_err;
+	}
+
+	cmd_fd = SXE2_CDEV_TO_CMD_FD(cdev);
+	if (cmd_fd < 0) {
+		PMD_LOG_ERR(COM, "Failed to exec cmd, fd=%d", cmd_fd);
+		goto l_err;
+	}
+
+	PMD_LOG_DEBUG(COM, "fd=%d, bar idx=%d, len=0x%zx, src=0x%"PRIx64", offset=0x%"PRIx64"",
+		bar_idx, cmd_fd, 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));
+	if (virt == MAP_FAILED) {
+		PMD_LOG_ERR(COM, "Failed mmap, cmd_fd=%d, len=0x%zx, offset=0x%"PRIx64", err:%s",
+			cmd_fd, len, offset, strerror(errno));
+		goto l_err;
+	}
+
+	return virt;
+l_err:
+	return NULL;
+}
+
 RTE_EXPORT_INTERNAL_SYMBOL(sxe2_drv_dev_munmap)
 s32
 sxe2_drv_dev_munmap(struct sxe2_common_device *cdev, void *virt, u64 len)
drivers/net/sxe2/sxe2_ethdev.c +307 -0

349 lines not on this page · raw message

drivers/net/sxe2/sxe2_ethdev.h +18 -0
index dc3a3175d1..fb7813ef80 100644
@@ -292,4 +292,22 @@ struct sxe2_adapter {
 #define SXE2_DEV_PRIVATE_TO_ADAPTER(dev) \
 	((struct sxe2_adapter *)(dev)->data->dev_private)
 
+#define SXE2_DEV_TO_PCI(eth_dev) \
+		RTE_DEV_TO_PCI((eth_dev)->device)
+
+struct sxe2_pci_map_bar_info *sxe2_dev_get_bar_info(struct sxe2_adapter *adapter,
+		enum sxe2_pci_map_resource res_type);
+
+s32 sxe2_dev_pci_seg_map(struct sxe2_adapter *adapter,
+		enum sxe2_pci_map_resource res_type, u64 org_len, u64 org_offset);
+
+s32 sxe2_dev_pci_res_seg_map(struct sxe2_adapter *adapter, u32 res_type,
+		u32 item_cnt, u32 item_base);
+
+void sxe2_dev_pci_seg_unmap(struct sxe2_adapter *adapter, u32 res_type);
+
+s32 sxe2_dev_pci_map_init(struct rte_eth_dev *dev);
+
+void sxe2_dev_pci_map_uinit(struct rte_eth_dev *dev);
+
 #endif
Signature · 1 line
2.47.3
#113 lore raw

PATCH v11 7/9 common/sxe2: add ioctl interface for DMA map and unmap

In reply to [email protected]

From: Jie Liu <[email protected]>

Implement DMA mapping and unmapping functionality using ioctl calls. This allows the driver to configure the hardware's IOMMU/DMA tables, ensuring the device can safely access memory buffers allocated by the userspace.

The mapping is established during device initialization or queue setup and is revoked during device closure to prevent memory leaks and ensure hardware security.

---
 drivers/common/sxe2/sxe2_common.c          |  48 ++++++++++
 drivers/common/sxe2/sxe2_ioctl_chnl.c      | 104 +++++++++++++++++++++
 drivers/common/sxe2/sxe2_ioctl_chnl_func.h |   9 ++
 3 files changed, 161 insertions(+)
drivers/common/sxe2/sxe2_common.c +48 -0
index dfdefb8b78..537d4e9f6a 100644
@@ -466,12 +466,60 @@ static s32 sxe2_common_pci_remove(struct rte_pci_device *pci_dev)
 	return ret;
 }
 
+static s32 sxe2_common_pci_dma_map(struct rte_pci_device *pci_dev,
+		void *addr,	u64 iova, size_t len)
+{
+	struct sxe2_common_device *cdev;
+	s32 ret = SXE2_ERROR;
+
+	cdev = sxe2_rtedev_to_cdev(&pci_dev->device);
+	if (cdev == NULL) {
+		ret = SXE2_ERR_NODEV;
+		PMD_LOG_ERR(COM, "Fail to get remove device.");
+		goto l_end;
+	}
+
+	ret = sxe2_drv_dev_dma_map(cdev, (u64)(uintptr_t)addr, iova, len);
+	if (ret) {
+		PMD_LOG_ERR(COM, "Fail to dma map, ret=%d", ret);
+		goto l_end;
+	}
+
+l_end:
+	return ret;
+}
+
+static s32 sxe2_common_pci_dma_unmap(struct rte_pci_device *pci_dev,
+		void *addr __rte_unused, u64 iova, size_t len __rte_unused)
+{
+	struct sxe2_common_device *cdev;
+	s32 ret = SXE2_ERROR;
+
+	cdev = sxe2_rtedev_to_cdev(&pci_dev->device);
+	if (cdev == NULL) {
+		ret = SXE2_ERR_NODEV;
+		PMD_LOG_ERR(COM, "Fail to get remove device.");
+		goto l_end;
+	}
+
+	ret = sxe2_drv_dev_dma_unmap(cdev, iova);
+	if (ret) {
+		PMD_LOG_ERR(COM, "Fail to dma map, ret=%d", ret);
+		goto l_end;
+	}
+
+l_end:
+	return ret;
+}
+
 static struct rte_pci_driver sxe2_common_pci_driver = {
 	.driver = {
 		   .name = SXE2_COMMON_PCI_DRIVER_NAME,
 	},
 	.probe = sxe2_common_pci_probe,
 	.remove = sxe2_common_pci_remove,
+	.dma_map = sxe2_common_pci_dma_map,
+	.dma_unmap = sxe2_common_pci_dma_unmap,
 };
 
 static u32 sxe2_common_pci_id_table_size_get(const struct rte_pci_id *id_table)
drivers/common/sxe2/sxe2_ioctl_chnl.c +104 -0

107 lines not on this page · raw message

drivers/common/sxe2/sxe2_ioctl_chnl_func.h +9 -0
index 376c5e3ac7..e8f983e40e 100644
@@ -47,6 +47,15 @@ __rte_internal
 s32
 sxe2_drv_dev_munmap(struct sxe2_common_device *cdev, void *virt, u64 len);
 
+__rte_internal
+s32
+sxe2_drv_dev_dma_map(struct sxe2_common_device *cdev, u64 vaddr,
+		u64 iova, u64 size);
+
+__rte_internal
+s32
+sxe2_drv_dev_dma_unmap(struct sxe2_common_device *cdev, u64 iova);
+
 #ifdef __cplusplus
 }
 #endif
Signature · 1 line
2.47.3
#114 lore raw

PATCH v11 8/9 net/sxe2: support queue setup and control

In reply to [email protected]

From: Jie Liu <[email protected]>

Add support for Rx and Tx queue setup, release, and management. Implement eth_dev_ops callbacks for rx_queue_setup, tx_queue_setup, rx_queue_release, and tx_queue_release.

This includes:
- Allocating memory for hardware ring descriptors.
- Initializing software ring structures and hardware head/tail pointers.
- Implementing proper resource cleanup logic to prevent memory leaks during queue reconfiguration or device close.

---
 drivers/net/sxe2/meson.build   |   2 +
 drivers/net/sxe2/sxe2_ethdev.c |  64 +++-
 drivers/net/sxe2/sxe2_ethdev.h |   3 +
 drivers/net/sxe2/sxe2_rx.c     | 579 +++++++++++++++++++++++++++++++++
 drivers/net/sxe2/sxe2_rx.h     |  34 ++
 drivers/net/sxe2/sxe2_tx.c     | 447 +++++++++++++++++++++++++
 drivers/net/sxe2/sxe2_tx.h     |  32 ++
 7 files changed, 1143 insertions(+), 18 deletions(-)
 create mode 100644 drivers/net/sxe2/sxe2_rx.c
 create mode 100644 drivers/net/sxe2/sxe2_rx.h
 create mode 100644 drivers/net/sxe2/sxe2_tx.c
 create mode 100644 drivers/net/sxe2/sxe2_tx.h
drivers/net/sxe2/meson.build +2 -0
index 98d0b7fc6d..61467a4e31 100644
@@ -23,6 +23,8 @@ sources += files(
         'sxe2_cmd_chnl.c',
         'sxe2_vsi.c',
         'sxe2_queue.c',
+        'sxe2_tx.c',
+        'sxe2_rx.c',
 )
 
 allow_internal_get_api = true
drivers/net/sxe2/sxe2_ethdev.c +46 -18

94 lines not on this page · raw message

drivers/net/sxe2/sxe2_ethdev.h +3 -0
index fb7813ef80..7999e4f331 100644
@@ -295,6 +295,9 @@ struct sxe2_adapter {
 #define SXE2_DEV_TO_PCI(eth_dev) \
 		RTE_DEV_TO_PCI((eth_dev)->device)
 
+void __iomem *sxe2_pci_map_addr_get(struct sxe2_adapter *adapter,
+		enum sxe2_pci_map_resource res_type, u16 idx_in_func);
+
 struct sxe2_pci_map_bar_info *sxe2_dev_get_bar_info(struct sxe2_adapter *adapter,
 		enum sxe2_pci_map_resource res_type);
 
drivers/net/sxe2/sxe2_rx.c new file +579 -0

579 lines not on this page · raw message

drivers/net/sxe2/sxe2_rx.h new file +34 -0
new file mode 100644
index 0000000000..7c6239b387
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+ */
+
+#ifndef __SXE2_RX_H__
+#define __SXE2_RX_H__
+
+#include "sxe2_queue.h"
+
+s32 __rte_cold sxe2_rx_queue_setup(struct rte_eth_dev *dev,
+				u16 queue_idx, u16 nb_desc, u32 socket_id,
+				const struct rte_eth_rxconf *rx_conf,
+				struct rte_mempool *mp);
+
+s32 __rte_cold sxe2_rx_queue_stop(struct rte_eth_dev *dev, u16 rx_queue_id);
+
+void __rte_cold sxe2_rx_queue_mbufs_release(struct sxe2_rx_queue *rxq);
+
+void __rte_cold sxe2_rx_queue_release(struct rte_eth_dev *dev, u16 queue_idx);
+
+void __rte_cold sxe2_all_rxqs_release(struct rte_eth_dev *dev);
+
+void __rte_cold sxe2_rx_queue_info_get(struct rte_eth_dev *dev, u16 queue_id,
+		struct rte_eth_rxq_info *qinfo);
+
+s32 __rte_cold sxe2_rx_queue_start(struct rte_eth_dev *dev, u16 rx_queue_id);
+
+s32 __rte_cold sxe2_rxqs_all_start(struct rte_eth_dev *dev);
+
+void __rte_cold sxe2_rxqs_all_stop(struct rte_eth_dev *dev);
+
+struct rte_mbuf *sxe2_mbuf_raw_alloc(struct rte_mempool *mp);
+
+#endif
drivers/net/sxe2/sxe2_tx.c new file +447 -0

447 lines not on this page · raw message

drivers/net/sxe2/sxe2_tx.h new file +32 -0
new file mode 100644
index 0000000000..58b668e337
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+ */
+
+#ifndef __SXE2_TX_H__
+#define __SXE2_TX_H__
+#include "sxe2_queue.h"
+
+void __rte_cold sxe2_tx_queue_reset(struct sxe2_tx_queue *txq);
+
+s32 __rte_cold sxe2_tx_queue_start(struct rte_eth_dev *dev, u16 queue_id);
+
+void sxe2_tx_queue_mbufs_release(struct sxe2_tx_queue *txq);
+
+s32 __rte_cold sxe2_tx_queue_stop(struct rte_eth_dev *dev, u16 queue_id);
+
+s32 __rte_cold sxe2_tx_queue_setup(struct rte_eth_dev *dev,
+		u16 queue_idx, u16 nb_desc, u32 socket_id,
+		const struct rte_eth_txconf *tx_conf);
+
+void __rte_cold sxe2_tx_queue_release(struct rte_eth_dev *dev, u16 queue_idx);
+
+void __rte_cold sxe2_all_txqs_release(struct rte_eth_dev *dev);
+
+void __rte_cold sxe2_tx_queue_info_get(struct rte_eth_dev *dev, u16 queue_id,
+		struct rte_eth_txq_info *qinfo);
+
+s32 __rte_cold sxe2_txqs_all_start(struct rte_eth_dev *dev);
+
+void __rte_cold sxe2_txqs_all_stop(struct rte_eth_dev *dev);
+
+#endif
Signature · 1 line
2.47.3
#115 lore raw

PATCH v11 9/9 drivers: add data path for Rx and Tx

In reply to [email protected]

From: Jie Liu <[email protected]>

Implement receive and transmit burst functions for sxe2 PMD. Add sxe2_recv_pkts and sxe2_xmit_pkts as the primary data path interfaces.

The implementation includes:
- Efficient descriptor fetching and mbuf allocation for Rx.
- Descriptor setup and checksum offload handling for Tx.
- Buffer recycling and hardware tail pointer updates.
- Performance-oriented loop unrolling and prefetching where applicable.

---
 drivers/common/sxe2/sxe2_common.c     |  13 +-
 drivers/common/sxe2/sxe2_common_log.h | 105 ----
 drivers/common/sxe2/sxe2_errno.h      |   3 -
 drivers/common/sxe2/sxe2_ioctl_chnl.c |  20 +-
 drivers/common/sxe2/sxe2_osal.h       |   4 +-
 drivers/common/sxe2/sxe2_type.h       |   1 -
 drivers/net/sxe2/meson.build          |   2 +
 drivers/net/sxe2/sxe2_ethdev.c        |  15 +-
 drivers/net/sxe2/sxe2_txrx.c          | 249 ++++++++
 drivers/net/sxe2/sxe2_txrx.h          |  21 +
 drivers/net/sxe2/sxe2_txrx_poll.c     | 782 ++++++++++++++++++++++++++
 11 files changed, 1082 insertions(+), 133 deletions(-)
 create mode 100644 drivers/net/sxe2/sxe2_txrx.c
 create mode 100644 drivers/net/sxe2/sxe2_txrx.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_poll.c
drivers/common/sxe2/sxe2_common.c +6 -7
index 537d4e9f6a..d2ed1460a3 100644
@@ -28,7 +28,7 @@ static TAILQ_HEAD(sxe2_class_drivers, sxe2_class_driver) sxe2_class_drivers_list
 static TAILQ_HEAD(sxe2_common_devices, sxe2_common_device) sxe2_common_devices_list =
 				TAILQ_HEAD_INITIALIZER(sxe2_common_devices_list);
 
-static pthread_mutex_t sxe2_common_devices_list_lock;
+static rte_spinlock_t sxe2_common_devices_list_lock;
 
 static struct rte_pci_id *sxe2_common_pci_id_table;
 
@@ -223,9 +223,9 @@ static struct sxe2_common_device *sxe2_common_device_alloc(
 	cdev->config.kernel_reset = false;
 	rte_ticketlock_init(&cdev->config.lock);
 
-	(void)pthread_mutex_lock(&sxe2_common_devices_list_lock);
+	rte_spinlock_lock(&sxe2_common_devices_list_lock);
 	TAILQ_INSERT_TAIL(&sxe2_common_devices_list, cdev, next);
-	(void)pthread_mutex_unlock(&sxe2_common_devices_list_lock);
+	rte_spinlock_unlock(&sxe2_common_devices_list_lock);
 
 l_end:
 	return cdev;
@@ -233,10 +233,9 @@ static struct sxe2_common_device *sxe2_common_device_alloc(
 
 static void sxe2_common_device_free(struct sxe2_common_device *cdev)
 {
-
-	(void)pthread_mutex_lock(&sxe2_common_devices_list_lock);
+	rte_spinlock_lock(&sxe2_common_devices_list_lock);
 	TAILQ_REMOVE(&sxe2_common_devices_list, cdev, next);
-	(void)pthread_mutex_unlock(&sxe2_common_devices_list_lock);
+	rte_spinlock_unlock(&sxe2_common_devices_list_lock);
 
 	rte_free(cdev);
 }
@@ -662,7 +661,7 @@ sxe2_common_init(void)
 	if (sxe2_commoin_inited)
 		goto l_end;
 
-	pthread_mutex_init(&sxe2_common_devices_list_lock, NULL);
+	rte_spinlock_init(&sxe2_common_devices_list_lock);
 #ifdef SXE2_DPDK_DEBUG
 	sxe2_common_log_stream_init();
 #endif
drivers/common/sxe2/sxe2_common_log.h +0 -105

109 lines not on this page · raw message

drivers/common/sxe2/sxe2_errno.h +0 -3
index 89a715eaef..1257319edf 100644
@@ -50,9 +50,6 @@ enum sxe2_status {
 	SXE2_ERR_NOLCK              = -ENOLCK,
 	SXE2_ERR_NOSYS              = -ENOSYS,
 	SXE2_ERR_NOTEMPTY           = -ENOTEMPTY,
-	SXE2_ERR_ILSEQ              = -EILSEQ,
-	SXE2_ERR_NODATA             = -ENODATA,
-	SXE2_ERR_CANCELED           = -ECANCELED,
 	SXE2_ERR_TIMEDOUT           = -ETIMEDOUT,
 
 	SXE2_ERROR                  = -150,
drivers/common/sxe2/sxe2_ioctl_chnl.c +10 -10
index 1a14d401e7..cb83fb837d 100644
@@ -37,7 +37,7 @@ sxe2_drv_cmd_exec(struct sxe2_common_device *cdev,
 
 	if (cdev->config.kernel_reset) {
 		ret = SXE2_ERR_PERM;
-		PMD_LOG_WARN(COM, "kernel reseted, need restart app.");
+		PMD_LOG_WARN(COM, "kernel reset, need restart app.");
 		goto l_end;
 	}
 
@@ -123,7 +123,7 @@ sxe2_drv_dev_handshark(struct sxe2_common_device *cdev)
 
 	if (cdev->config.kernel_reset) {
 		ret = SXE2_ERR_PERM;
-		PMD_LOG_WARN(COM, "kernel reseted, need restart app.");
+		PMD_LOG_WARN(COM, "kernel reset, need restart app.");
 		goto l_end;
 	}
 
@@ -168,7 +168,7 @@ void
 	void *virt = NULL;
 
 	if (cdev->config.kernel_reset) {
-		PMD_LOG_WARN(COM, "kernel reseted, need restart app.");
+		PMD_LOG_WARN(COM, "kernel reset, need restart app.");
 		goto l_err;
 	}
 
@@ -178,13 +178,13 @@ void
 		goto l_err;
 	}
 
-	PMD_LOG_DEBUG(COM, "fd=%d, bar idx=%d, len=0x%zx, src=0x%"PRIx64", offset=0x%"PRIx64"",
+	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));
 
 	virt = mmap(NULL, len, PROT_READ | PROT_WRITE,
 		MAP_SHARED, cmd_fd, SXE2_COM_PCI_OFFSET_GEN(bar_idx, offset));
 	if (virt == MAP_FAILED) {
-		PMD_LOG_ERR(COM, "Failed mmap, cmd_fd=%d, len=0x%zx, offset=0x%"PRIx64", err:%s",
+		PMD_LOG_ERR(COM, "Failed mmap, cmd_fd=%d, len=%"PRIu64", offset=0x%"PRIx64", err:%s",
 			cmd_fd, len, offset, strerror(errno));
 		goto l_err;
 	}
@@ -206,12 +206,12 @@ sxe2_drv_dev_munmap(struct sxe2_common_device *cdev, void *virt, u64 len)
 		goto l_end;
 	}
 
-	PMD_LOG_DEBUG(COM, "Munmap virt=%p, len=0x%zx",
+	PMD_LOG_DEBUG(COM, "Munmap virt=%p, len=0x%"PRIx64"",
 		virt, len);
 
 	ret = munmap(virt, len);
 	if (ret < 0) {
-		PMD_LOG_ERR(COM, "Failed to munmap, virt=%p, len=0x%zx, err:%s",
+		PMD_LOG_ERR(COM, "Failed to munmap, virt=%p, len=%"PRIu64", err:%s",
 			virt, len, strerror(errno));
 		ret = SXE2_ERR_IO;
 		goto l_end;
@@ -233,7 +233,7 @@ sxe2_drv_dev_dma_map(struct sxe2_common_device *cdev, u64 vaddr,
 
 	if (cdev->config.kernel_reset) {
 		ret = SXE2_ERR_PERM;
-		PMD_LOG_WARN(COM, "kernel reseted, need restart app.");
+		PMD_LOG_WARN(COM, "kernel reset, need restart app.");
 		goto l_end;
 	}
 
@@ -246,7 +246,7 @@ sxe2_drv_dev_dma_map(struct sxe2_common_device *cdev, u64 vaddr,
 		goto l_end;
 	} else if (iova_mode == RTE_IOVA_VA) {
 		if (!cdev->config.support_iommu) {
-			PMD_LOG_ERR(COM, "no iommu not support va mode, plese use pa mode.");
+			PMD_LOG_ERR(COM, "no iommu not support va mode, please use pa mode.");
 			ret = SXE2_ERR_IO;
 			goto l_end;
 		}
@@ -289,7 +289,7 @@ sxe2_drv_dev_dma_unmap(struct sxe2_common_device *cdev, u64 iova)
 
 	if (cdev->config.kernel_reset) {
 		ret = SXE2_ERR_PERM;
-		PMD_LOG_WARN(COM, "kernel reseted, need restart app.");
+		PMD_LOG_WARN(COM, "kernel reset, need restart app.");
 		goto l_end;
 	}
 
drivers/common/sxe2/sxe2_osal.h +1 -3
index fd6823fe98..23882f3f52 100644
@@ -29,8 +29,6 @@
 #define BIT_ULL(a) (1ULL << (a))
 #endif
 
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
-
 #define BITS_PER_BYTE 8
 
 #define IS_UNICAST_ETHER_ADDR(addr)			\
@@ -88,7 +86,7 @@
 			(((n) + (typeof(n))(d) - (typeof(n))1) / (typeof(n))(d))
 #endif
 
-#define usleep_range(min, max) msleep(DIV_ROUND_UP(min, 1000))
+#define usleep_range(min) msleep(DIV_ROUND_UP(min, 1000))
 
 #define __bf_shf(x) ((uint32_t)rte_bsf64(x))
 
drivers/common/sxe2/sxe2_type.h +0 -1
index 56d0a11f48..fbf4a6674f 100644
@@ -8,7 +8,6 @@
 #include <sys/time.h>
 
 #include <stdlib.h>
-#include <stdio.h>
 #include <errno.h>
 #include <stdarg.h>
 #include <unistd.h>
drivers/net/sxe2/meson.build +2 -0
index 61467a4e31..b331451160 100644
@@ -25,6 +25,8 @@ sources += files(
         'sxe2_queue.c',
         'sxe2_tx.c',
         'sxe2_rx.c',
+        'sxe2_txrx_poll.c',
+        'sxe2_txrx.c',
 )
 
 allow_internal_get_api = true
drivers/net/sxe2/sxe2_ethdev.c +11 -4
index c1a65f25ce..68d7e36cf1 100644
@@ -26,6 +26,7 @@
 #include "sxe2_cmd_chnl.h"
 #include "sxe2_tx.h"
 #include "sxe2_rx.h"
+#include "sxe2_txrx.h"
 #include "sxe2_common.h"
 #include "sxe2_common_log.h"
 #include "sxe2_host_regs.h"
@@ -131,6 +132,9 @@ static s32 sxe2_dev_start(struct rte_eth_dev *dev)
 		goto l_end;
 	}
 
+	sxe2_rx_mode_func_set(dev);
+	sxe2_tx_mode_func_set(dev);
+
 	ret = sxe2_queues_start(dev);
 	if (ret) {
 		PMD_LOG_ERR(INIT, "enable queues failed");
@@ -363,8 +367,8 @@ void __iomem *sxe2_pci_map_addr_get(struct sxe2_adapter *adapter,
 	for (i = 0; i < bar_info->map_cnt; i++) {
 		seg_info = &bar_info->seg_info[i];
 		if (res_type == seg_info->type) {
-			addr = (void __iomem *)((uintptr_t)seg_info->addr +
-					seg_info->page_inner_offset + reg_width	* idx_in_func);
+			addr = (uint8_t __iomem *)seg_info->addr +
+					seg_info->page_inner_offset + reg_width * idx_in_func;
 			goto l_end;
 		}
 	}
@@ -475,8 +479,9 @@ s32 sxe2_dev_pci_seg_map(struct sxe2_adapter *adapter,
 
 	map_addr = sxe2_drv_dev_mmap(adapter->cdev, bar_info->bar_idx, aligned_len, aligned_offset);
 	if (!map_addr) {
-		PMD_LOG_ERR(INIT, "Failed to mmap BAR space, type=%d, len=%zu, page_size=%zu",
-					res_type, org_len, page_size);
+		PMD_LOG_ERR(INIT, "Failed to mmap BAR space, type=%d, len=%" PRIu64
+			", offset=%" PRIu64 ", page_size=%zu",
+					res_type, org_len, org_offset, page_size);
 		ret = SXE2_ERR_FAULT;
 		goto l_end;
 	}
@@ -760,6 +765,8 @@ static s32 sxe2_dev_init(struct rte_eth_dev *dev, struct sxe2_dev_kvargs_info *k
 
 	PMD_INIT_FUNC_TRACE();
 
+	sxe2_set_common_function(dev);
+
 	dev->dev_ops = &sxe2_eth_dev_ops;
 
 	ret = sxe2_hw_init(dev);
drivers/net/sxe2/sxe2_txrx.c new file +249 -0

249 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx.h new file +21 -0
new file mode 100644
index 0000000000..cd9ebfa32f
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+ */
+
+#ifndef SXE2_TXRX_H
+#define SXE2_TXRX_H
+#include <ethdev_driver.h>
+#include "sxe2_queue.h"
+
+void sxe2_set_common_function(struct rte_eth_dev *dev);
+
+u16 sxe2_tx_pkts_prepare(__rte_unused void *tx_queue,
+		struct rte_mbuf **tx_pkts, u16 nb_pkts);
+
+void sxe2_tx_mode_func_set(struct rte_eth_dev *dev);
+
+void __rte_cold sxe2_rx_queue_reset(struct sxe2_rx_queue *rxq);
+
+void sxe2_rx_mode_func_set(struct rte_eth_dev *dev);
+
+#endif
drivers/net/sxe2/sxe2_txrx_poll.c new file +782 -0

782 lines not on this page · raw message

Signature · 1 line
2.47.3
#116 lore raw

Re: [PATCH v11 0/9] Add Linkdata sxe2 driver

In reply to [email protected]
Quoted 4 lines · On Thu, 7 May 2026 09:44:40 +0800 [email protected] wrote:

From: Jie Liu <[email protected]>

V11:
- Addressed AI comments

Not better. v11 is byte-for-byte identical to v10 except:

The vector Rx/Tx patch (10/10) was dropped, so it's now a 9-patch series. One trailing blank line was removed from the data-path patch (now 9/9).

#117 lore raw

v12 cover net/sxe2: fix logic errors and address feedback

In reply to [email protected]

From: Jie Liu <[email protected]>

This patch set addresses the feedback received on the v10 submission for the sxe2 PMD. The primary focus is on fixing vector path selection, ensuring memory safety during mbuf initialization, and cleaning up redundant logic in the configuration functions.

v12 Changes:
- Fixed vector Rx burst function being overwritten by scalar selection.
- Refactored Rx/Tx mode set functions to seed flags from caps first,eliminating tautological checks.
- Added memset for mbuf_def in vector init to avoid uninitialized reads.
- Converted pci_map_addr_info to designated initializers.
- Removed dead Windows-only code in meson.build.
- Added NULL checks for mbuf free for driver-wide consistency.
- Updated burst_mode_get to accurately report AVX paths.
- Adjusted SXE2_ETH_OVERHEAD to match actual VLAN capabilities.

Jie Liu (10):
mailmap: add Jie Liu
doc: add sxe2 guide and release notes common/sxe2: add sxe2 basic structures
drivers: add base driver skeleton
drivers: add base driver probe skeleton
drivers: support PCI BAR mapping
common/sxe2: add ioctl interface for DMA map and unmap net/sxe2: support queue setup and control
drivers: add data path for Rx and Tx net/sxe2: add vectorized Rx and Tx

 .mailmap                                   |   1 +
 doc/guides/nics/features/sxe2.ini          |  30 +
 doc/guides/nics/index.rst                  |   1 +
 doc/guides/nics/sxe2.rst                   |  34 +
 doc/guides/rel_notes/release_26_07.rst     |   4 +
 drivers/common/sxe2/meson.build            |  15 +
 drivers/common/sxe2/sxe2_common.c          | 685 +++++++++++++++
 drivers/common/sxe2/sxe2_common.h          |  86 ++
 drivers/common/sxe2/sxe2_common_log.h      |  83 ++
 drivers/common/sxe2/sxe2_errno.h           | 110 +++
 drivers/common/sxe2/sxe2_host_regs.h       | 707 +++++++++++++++
 drivers/common/sxe2/sxe2_internal_ver.h    |  33 +
 drivers/common/sxe2/sxe2_ioctl_chnl.c      | 326 +++++++
 drivers/common/sxe2/sxe2_ioctl_chnl.h      | 141 +++
 drivers/common/sxe2/sxe2_ioctl_chnl_func.h |  63 ++
 drivers/common/sxe2/sxe2_osal.h            | 584 +++++++++++++
 drivers/common/sxe2/sxe2_type.h            |  60 ++
 drivers/meson.build                        |   1 +
 drivers/net/meson.build                    |   1 +
 drivers/net/sxe2/meson.build               |  32 +
 drivers/net/sxe2/sxe2_cmd_chnl.c           | 319 +++++++
 drivers/net/sxe2/sxe2_cmd_chnl.h           |  33 +
 drivers/net/sxe2/sxe2_drv_cmd.h            | 389 +++++++++
 drivers/net/sxe2/sxe2_ethdev.c             | 942 ++++++++++++++++++++
 drivers/net/sxe2/sxe2_ethdev.h             | 315 +++++++
 drivers/net/sxe2/sxe2_irq.h                |  49 ++
 drivers/net/sxe2/sxe2_queue.c              |  67 ++
 drivers/net/sxe2/sxe2_queue.h              | 194 +++++
 drivers/net/sxe2/sxe2_rx.c                 | 579 +++++++++++++
 drivers/net/sxe2/sxe2_rx.h                 |  34 +
 drivers/net/sxe2/sxe2_tx.c                 | 447 ++++++++++
 drivers/net/sxe2/sxe2_tx.h                 |  32 +
 drivers/net/sxe2/sxe2_txrx.c               | 372 ++++++++
 drivers/net/sxe2/sxe2_txrx.h               |  22 +
 drivers/net/sxe2/sxe2_txrx_common.h        | 541 ++++++++++++
 drivers/net/sxe2/sxe2_txrx_poll.c          | 945 +++++++++++++++++++++
 drivers/net/sxe2/sxe2_txrx_poll.h          |  17 +
 drivers/net/sxe2/sxe2_txrx_vec.c           | 197 +++++
 drivers/net/sxe2/sxe2_txrx_vec.h           |  72 ++
 drivers/net/sxe2/sxe2_txrx_vec_common.h    | 235 +++++
 drivers/net/sxe2/sxe2_txrx_vec_sse.c       | 545 ++++++++++++
 drivers/net/sxe2/sxe2_vsi.c                | 212 +++++
 drivers/net/sxe2/sxe2_vsi.h                | 205 +++++
 43 files changed, 9760 insertions(+)
 create mode 100644 doc/guides/nics/features/sxe2.ini
 create mode 100644 doc/guides/nics/sxe2.rst
 create mode 100644 drivers/common/sxe2/meson.build
 create mode 100644 drivers/common/sxe2/sxe2_common.c
 create mode 100644 drivers/common/sxe2/sxe2_common.h
 create mode 100644 drivers/common/sxe2/sxe2_common_log.h
 create mode 100644 drivers/common/sxe2/sxe2_errno.h
 create mode 100644 drivers/common/sxe2/sxe2_host_regs.h
 create mode 100644 drivers/common/sxe2/sxe2_internal_ver.h
 create mode 100644 drivers/common/sxe2/sxe2_ioctl_chnl.c
 create mode 100644 drivers/common/sxe2/sxe2_ioctl_chnl.h
 create mode 100644 drivers/common/sxe2/sxe2_ioctl_chnl_func.h
 create mode 100644 drivers/common/sxe2/sxe2_osal.h
 create mode 100644 drivers/common/sxe2/sxe2_type.h
 create mode 100644 drivers/net/sxe2/meson.build
 create mode 100644 drivers/net/sxe2/sxe2_cmd_chnl.c
 create mode 100644 drivers/net/sxe2/sxe2_cmd_chnl.h
 create mode 100644 drivers/net/sxe2/sxe2_drv_cmd.h
 create mode 100644 drivers/net/sxe2/sxe2_ethdev.c
 create mode 100644 drivers/net/sxe2/sxe2_ethdev.h
 create mode 100644 drivers/net/sxe2/sxe2_irq.h
 create mode 100644 drivers/net/sxe2/sxe2_queue.c
 create mode 100644 drivers/net/sxe2/sxe2_queue.h
 create mode 100644 drivers/net/sxe2/sxe2_rx.c
 create mode 100644 drivers/net/sxe2/sxe2_rx.h
 create mode 100644 drivers/net/sxe2/sxe2_tx.c
 create mode 100644 drivers/net/sxe2/sxe2_tx.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx.c
 create mode 100644 drivers/net/sxe2/sxe2_txrx.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_common.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_poll.c
 create mode 100644 drivers/net/sxe2/sxe2_txrx_poll.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec.c
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec_common.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec_sse.c
 create mode 100644 drivers/net/sxe2/sxe2_vsi.c
 create mode 100644 drivers/net/sxe2/sxe2_vsi.h
Signature · 1 line
2.47.3
#118 lore raw

PATCH v12 1/10 mailmap: add Jie Liu

From: Jie Liu <[email protected]>

---
 .mailmap | 1 +
 1 file changed, 1 insertion(+)
.mailmap +1 -0
index 895412e568..d2c4485636 100644
@@ -739,6 +739,7 @@ Jiawen Wu <[email protected]>
 Jiayu Hu <[email protected]> <[email protected]>
 Jie Hai <[email protected]>
 Jie Liu <[email protected]>
+Jie Liu <[email protected]>
 Jie Pan <[email protected]>
 Jie Wang <[email protected]>
 Jie Zhou <[email protected]> <[email protected]>
Signature · 1 line
2.47.3
#119 lore raw

PATCH v12 2/10 doc: add sxe2 guide and release notes

In reply to [email protected]

From: Jie Liu <[email protected]>

Add a new guide for SXE2 PMD in the nics directory. The guide contains driver capabilities, prerequisites, and compilation/usage instructions.

Update the release notes to announce the addition of the sxe2 network driver.

---
 doc/guides/nics/features/sxe2.ini      | 30 +++++++++++++++++++++++
 doc/guides/nics/index.rst              |  1 +
 doc/guides/nics/sxe2.rst               | 34 ++++++++++++++++++++++++++
 doc/guides/rel_notes/release_26_07.rst |  4 +++
 4 files changed, 69 insertions(+)
 create mode 100644 doc/guides/nics/features/sxe2.ini
 create mode 100644 doc/guides/nics/sxe2.rst
doc/guides/nics/features/sxe2.ini new file +30 -0
new file mode 100644
index 0000000000..2718a702d4
@@ -0,0 +1,30 @@
+;
+; Supported features of the 'sxe2' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+; A feature with "P" indicates only be supported when non-vector path
+; is selected.
+;
+[Features]
+Fast mbuf free       = P
+Free Tx mbuf on demand = Y
+Burst mode info      = Y
+Queue start/stop     = Y
+MTU update           = Y
+Buffer split on Rx   = P
+Scattered Rx         = Y
+CRC offload          = Y
+VLAN offload         = Y
+QinQ offload         = P
+L3 checksum offload  = Y
+L4 checksum offload  = Y
+Timestamp offload    = P
+Inner L3 checksum    = P
+Inner L4 checksum    = P
+Rx descriptor status = Y
+Tx descriptor status = Y
+FreeBSD              = Y
+Linux                = Y
+x86-32               = Y
+x86-64               = Y
doc/guides/nics/index.rst +1 -0
index cb818284fe..e20be478f8 100644
@@ -68,6 +68,7 @@ Network Interface Controller Drivers
     rnp
     sfc_efx
     softnic
+    sxe2
     tap
     thunderx
     txgbe
doc/guides/nics/sxe2.rst new file +34 -0
new file mode 100644
index 0000000000..7fcf9c085b
@@ -0,0 +1,34 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+
+SXE2 Poll Mode Driver
+======================
+
+The sxe2 PMD (**librte_net_sxe2**) provides poll mode driver support for
+10/25/50/100 Gbps Network Adapters.
+The embedded switch, Physical Functions (PF),
+and SR-IOV Virtual Functions (VF) are supported.
+
+Implementation details
+----------------------
+
+The sxe2 PMD is designed to operate alongside the sxe2 kernel network driver.
+For management and control operations, the PMD communicates with the kernel
+driver via ioctl interfaces. These commands are processed by the kernel
+driver and subsequently dispatched to the hardware firmware for execution.
+
+For security and robustness, the driver's data path is optimized to operate
+using virtual addresses (IOVA as VA mode). However, to ensure full
+compatibility in system environments where an IOMMU is absent or disabled,
+the driver also provides an explicit path to support physical addressing
+(IOVA as PA mode).
+
+The hardware is capable of handling the corresponding IOVA addresses (either
+VA or PA) directly, as provided by the DPDK memory subsystem. This ensures
+that DPDK applications can only access memory segments explicitly allocated
+to the current process, preventing unauthorized access to random physical
+memory.
+
+This capability allows the PMD to coexist with kernel network interfaces
+which remain functional, although they stop receiving unicast packets as
+long as they share the same MAC address.
doc/guides/rel_notes/release_26_07.rst +4 -0
index f012d47a4b..fa0f0f5cca 100644
@@ -64,6 +64,10 @@ New Features
   * ``--auto-probing`` enables the initial bus probing, which is the current default behavior.
 
 
+* **Added Linkdata sxe2 ethernet driver.**
+
+  Added network driver for the Linkdata Network Adapters.
+
 Removed Items
 -------------
 
Signature · 1 line
2.47.3
#120 lore raw

PATCH v12 3/10 common/sxe2: add sxe2 basic structures

In reply to [email protected]

From: Jie Liu <[email protected]>

This patch adds the base infrastructure for the sxe2 common library. It includes the mandatory OS abstraction layer (OSAL), common structure definitions, error codes, and the logging system implementation.

Specifically, this commit:
- Implements the logging stream management using RTE_LOG_LINE.
- Defines device-specific error codes and status registers.
- Adds the initial meson build configuration for the common library.

---
 drivers/common/sxe2/sxe2_common_log.h   |  84 +++
 drivers/common/sxe2/sxe2_errno.h        | 113 ++++
 drivers/common/sxe2/sxe2_host_regs.h    | 707 ++++++++++++++++++++++++
 drivers/common/sxe2/sxe2_internal_ver.h |  33 ++
 drivers/common/sxe2/sxe2_osal.h         | 586 ++++++++++++++++++++
 drivers/common/sxe2/sxe2_type.h         |  61 ++
 6 files changed, 1584 insertions(+)
 create mode 100644 drivers/common/sxe2/sxe2_common_log.h
 create mode 100644 drivers/common/sxe2/sxe2_errno.h
 create mode 100644 drivers/common/sxe2/sxe2_host_regs.h
 create mode 100644 drivers/common/sxe2/sxe2_internal_ver.h
 create mode 100644 drivers/common/sxe2/sxe2_osal.h
 create mode 100644 drivers/common/sxe2/sxe2_type.h
drivers/common/sxe2/sxe2_common_log.h new file +84 -0
new file mode 100644
index 0000000000..a7d2157610
@@ -0,0 +1,84 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+ */
+
+#ifndef __SXE2_COMMON_LOG_H__
+#define __SXE2_COMMON_LOG_H__
+
+#include "sxe2_type.h"
+
+extern s32 sxe2_common_log;
+extern s32 sxe2_log_init;
+extern s32 sxe2_log_driver;
+extern s32 sxe2_log_rx;
+extern s32 sxe2_log_tx;
+extern s32 sxe2_log_hw;
+
+#define RTE_LOGTYPE_SXE2_COM  sxe2_common_log
+#define RTE_LOGTYPE_SXE2_INIT sxe2_log_init
+#define RTE_LOGTYPE_SXE2_DRV  sxe2_log_driver
+#define RTE_LOGTYPE_SXE2_RX   sxe2_log_rx
+#define RTE_LOGTYPE_SXE2_TX   sxe2_log_tx
+#define RTE_LOGTYPE_SXE2_HW   sxe2_log_hw
+
+#define SXE2_PMD_LOG(level, log_type, ...) \
+	RTE_LOG_LINE_PREFIX(level, log_type, "%s(): ", \
+		__func__, __VA_ARGS__)
+
+#define SXE2_PMD_DRV_LOG(level, log_type, adapter, ...) \
+	RTE_LOG_LINE_PREFIX(level, log_type, "%s(): port:%u ", \
+		__func__ RTE_LOG_COMMA \
+		adapter->dev_port_id, __VA_ARGS__)
+
+#define PMD_LOG_DEBUG(logtype, fmt, ...) \
+	SXE2_PMD_LOG(DEBUG, SXE2_##logtype, fmt, ##__VA_ARGS__)
+
+#define PMD_LOG_INFO(logtype, fmt, ...) \
+	SXE2_PMD_LOG(INFO, SXE2_##logtype, fmt, ##__VA_ARGS__)
+
+#define PMD_LOG_NOTICE(logtype, fmt, ...) \
+	SXE2_PMD_LOG(NOTICE, SXE2_##logtype, fmt, ##__VA_ARGS__)
+
+#define PMD_LOG_WARN(logtype, fmt, ...) \
+	SXE2_PMD_LOG(WARNING, SXE2_##logtype, fmt, ##__VA_ARGS__)
+
+#define PMD_LOG_ERR(logtype, fmt, ...) \
+	SXE2_PMD_LOG(ERR, SXE2_##logtype, fmt, ##__VA_ARGS__)
+
+#define PMD_LOG_CRIT(logtype, fmt, ...) \
+	SXE2_PMD_LOG(CRIT, SXE2_##logtype, fmt, ##__VA_ARGS__)
+
+#define PMD_LOG_ALERT(logtype, fmt, ...) \
+	SXE2_PMD_LOG(ALERT, SXE2_##logtype, fmt, ##__VA_ARGS__)
+
+#define PMD_LOG_EMERG(logtype, fmt, ...) \
+	SXE2_PMD_LOG(EMERG, SXE2_##logtype, fmt, ##__VA_ARGS__)
+
+#define PMD_DEV_LOG_DEBUG(adapter, logtype, fmt, ...) \
+	SXE2_PMD_DRV_LOG(DEBUG, SXE2_##logtype, adapter, fmt, ##__VA_ARGS__)
+
+#define PMD_DEV_LOG_INFO(adapter, logtype, fmt, ...) \
+	SXE2_PMD_DRV_LOG(INFO, SXE2_##logtype, adapter, fmt, ##__VA_ARGS__)
+
+#define PMD_DEV_LOG_NOTICE(adapter, logtype, fmt, ...) \
+	SXE2_PMD_DRV_LOG(NOTICE, SXE2_##logtype, adapter, fmt, ##__VA_ARGS__)
+
+#define PMD_DEV_LOG_WARN(adapter, logtype, fmt, ...) \
+	SXE2_PMD_DRV_LOG(WARNING, SXE2_##logtype, adapter, fmt, ##__VA_ARGS__)
+
+#define PMD_DEV_LOG_ERR(adapter, logtype, fmt, ...) \
+	SXE2_PMD_DRV_LOG(ERR, SXE2_##logtype, adapter, fmt, ##__VA_ARGS__)
+
+#define PMD_DEV_LOG_CRIT(adapter, logtype, fmt, ...) \
+	SXE2_PMD_DRV_LOG(CRIT, SXE2_##logtype, adapter, fmt, ##__VA_ARGS__)
+
+#define PMD_DEV_LOG_ALERT(adapter, logtype, fmt, ...) \
+	SXE2_PMD_DRV_LOG(ALERT, SXE2_##logtype, adapter, fmt, ##__VA_ARGS__)
+
+#define PMD_DEV_LOG_EMERG(adapter, logtype, fmt, ...) \
+	SXE2_PMD_DRV_LOG(EMERG, SXE2_##logtype, adapter, fmt, ##__VA_ARGS__)
+
+#define PMD_INIT_FUNC_TRACE() PMD_LOG_DEBUG(INIT, " >>")
+
+#endif /* __SXE2_COMMON_LOG_H__ */
+
drivers/common/sxe2/sxe2_errno.h new file +113 -0

113 lines not on this page · raw message

drivers/common/sxe2/sxe2_host_regs.h new file +707 -0

707 lines not on this page · raw message

drivers/common/sxe2/sxe2_internal_ver.h new file +33 -0
new file mode 100644
index 0000000000..92f49e7a20
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+ */
+
+#ifndef __SXE2_INTERNAL_VER_H__
+#define __SXE2_INTERNAL_VER_H__
+
+#define SXE2_VER_MAJOR_OFFSET (16)
+#define SXE2_MK_VER(major, minor) \
+	(major << SXE2_VER_MAJOR_OFFSET | minor)
+#define SXE2_MK_VER_MAJOR(ver) (((ver) >> SXE2_VER_MAJOR_OFFSET) & 0xff)
+#define SXE2_MK_VER_MINOR(ver) ((ver) & 0xff)
+
+#define SXE2_ITR_VER_MAJOR_V100    1
+#define SXE2_ITR_VER_MAJOR_V200    2
+
+#define SXE2_ITR_VER_MAJOR      1
+#define SXE2_ITR_VER_MINOR      1
+#define SXE2_ITR_VER SXE2_MK_VER(SXE2_ITR_VER_MAJOR, SXE2_ITR_VER_MINOR)
+
+#define SXE2_CTRL_VER_IS_V100(ver)  (SXE2_MK_VER_MAJOR(ver) == SXE2_ITR_VER_MAJOR_V100)
+#define SXE2_CTRL_VER_IS_V200(ver)  (SXE2_MK_VER_MAJOR(ver) == SXE2_ITR_VER_MAJOR_V200)
+
+#define SXE2LIB_ITR_VER_MAJOR      1
+#define SXE2LIB_ITR_VER_MINOR      1
+#define SXE2LIB_ITR_VER     SXE2_MK_VER(SXE2LIB_ITR_VER_MAJOR, SXE2LIB_ITR_VER_MINOR)
+
+#define SXE2_DRV_CLI_VER_MAJOR      1
+#define SXE2_DRV_CLI_VER_MINOR      1
+#define SXE2_DRV_CLI_VER \
+	SXE2_MK_VER(SXE2_DRV_CLI_VER_MAJOR, SXE2_DRV_CLI_VER_MINOR)
+
+#endif /* __SXE2_INTERNAL_VER_H__ */
drivers/common/sxe2/sxe2_osal.h new file +586 -0

586 lines not on this page · raw message

drivers/common/sxe2/sxe2_type.h new file +61 -0

61 lines not on this page · raw message

Signature · 1 line
2.47.3
#121 lore raw

PATCH v12 4/10 drivers: add base driver skeleton

In reply to [email protected]

From: Jie Liu <[email protected]>

Initialize the sxe2 PMD skeleton by implementing the PCI probe and remove functions. This includes the setup and cleanup of a character device used for control path communication between the user space and the hardware.

The character device provides an interface for ioctl-based management operations, supporting device-specific configuration.

---
 drivers/common/sxe2/meson.build            |  15 +
 drivers/common/sxe2/sxe2_common.c          | 636 +++++++++++++++++++++
 drivers/common/sxe2/sxe2_common.h          |  86 +++
 drivers/common/sxe2/sxe2_ioctl_chnl.c      | 161 ++++++
 drivers/common/sxe2/sxe2_ioctl_chnl.h      | 141 +++++
 drivers/common/sxe2/sxe2_ioctl_chnl_func.h |  45 ++
 drivers/meson.build                        |   1 +
 7 files changed, 1085 insertions(+)
 create mode 100644 drivers/common/sxe2/meson.build
 create mode 100644 drivers/common/sxe2/sxe2_common.c
 create mode 100644 drivers/common/sxe2/sxe2_common.h
 create mode 100644 drivers/common/sxe2/sxe2_ioctl_chnl.c
 create mode 100644 drivers/common/sxe2/sxe2_ioctl_chnl.h
 create mode 100644 drivers/common/sxe2/sxe2_ioctl_chnl_func.h
drivers/common/sxe2/meson.build new file +15 -0
new file mode 100644
index 0000000000..f1cc1205a0
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2023 Corigine, Inc.
+
+if is_windows
+        build = false
+        reason = 'only supported on Linux'
+        subdir_done()
+endif
+
+deps += ['bus_pci', 'net', 'eal', 'ethdev']
+
+sources = files(
+        'sxe2_common.c',
+        'sxe2_ioctl_chnl.c',
+)
drivers/common/sxe2/sxe2_common.c new file +636 -0

636 lines not on this page · raw message

drivers/common/sxe2/sxe2_common.h new file +86 -0

86 lines not on this page · raw message

drivers/common/sxe2/sxe2_ioctl_chnl.c new file +161 -0

161 lines not on this page · raw message

drivers/common/sxe2/sxe2_ioctl_chnl.h new file +141 -0

141 lines not on this page · raw message

drivers/common/sxe2/sxe2_ioctl_chnl_func.h new file +45 -0

45 lines not on this page · raw message

drivers/meson.build +1 -0
index 6ae102e943..d4ae512bae 100644
@@ -12,6 +12,7 @@ subdirs = [
         'common/qat',     # depends on bus.
         'common/sfc_efx', # depends on bus.
         'common/zsda',    # depends on bus.
+        'common/sxe2',    # depends on bus.
         'mempool',        # depends on common and bus.
         'dma',            # depends on common and bus.
         'net',            # depends on common, bus, mempool
Signature · 1 line
2.47.3
#122 lore raw

PATCH v12 5/10 drivers: add base driver probe skeleton

In reply to [email protected]

From: Jie Liu <[email protected]>

Initialize the eth_dev_ops for the sxe2 PMD. This includes the implementation of mandatory ethdev operations such as dev_configure, dev_start, dev_stop, and dev_infos_get.

Set up the basic infrastructure for device initialization to allow the driver to be recognized as a valid ethernet device within the DPDK framework.

---
 drivers/common/sxe2/sxe2_common.h          |   2 +-
 drivers/common/sxe2/sxe2_ioctl_chnl.c      |  27 +
 drivers/common/sxe2/sxe2_ioctl_chnl_func.h |   9 +
 drivers/net/meson.build                    |   1 +
 drivers/net/sxe2/meson.build               |  21 +
 drivers/net/sxe2/sxe2_cmd_chnl.c           | 319 +++++++++++
 drivers/net/sxe2/sxe2_cmd_chnl.h           |  33 ++
 drivers/net/sxe2/sxe2_drv_cmd.h            | 398 ++++++++++++++
 drivers/net/sxe2/sxe2_ethdev.c             | 611 +++++++++++++++++++++
 drivers/net/sxe2/sxe2_ethdev.h             | 295 ++++++++++
 drivers/net/sxe2/sxe2_irq.h                |  49 ++
 drivers/net/sxe2/sxe2_queue.c              |  39 ++
 drivers/net/sxe2/sxe2_queue.h              | 191 +++++++
 drivers/net/sxe2/sxe2_txrx_common.h        | 541 ++++++++++++++++++
 drivers/net/sxe2/sxe2_txrx_poll.h          |  16 +
 drivers/net/sxe2/sxe2_vsi.c                | 212 +++++++
 drivers/net/sxe2/sxe2_vsi.h                | 205 +++++++
 17 files changed, 2968 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/sxe2/meson.build
 create mode 100644 drivers/net/sxe2/sxe2_cmd_chnl.c
 create mode 100644 drivers/net/sxe2/sxe2_cmd_chnl.h
 create mode 100644 drivers/net/sxe2/sxe2_drv_cmd.h
 create mode 100644 drivers/net/sxe2/sxe2_ethdev.c
 create mode 100644 drivers/net/sxe2/sxe2_ethdev.h
 create mode 100644 drivers/net/sxe2/sxe2_irq.h
 create mode 100644 drivers/net/sxe2/sxe2_queue.c
 create mode 100644 drivers/net/sxe2/sxe2_queue.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_common.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_poll.h
 create mode 100644 drivers/net/sxe2/sxe2_vsi.c
 create mode 100644 drivers/net/sxe2/sxe2_vsi.h
drivers/common/sxe2/sxe2_common.h +1 -1
index d02d281a70..090b643548 100644
@@ -57,7 +57,7 @@ typedef s32 (sxe2_class_driver_remove_t)(struct sxe2_common_device *scdev);
 struct sxe2_class_driver {
 	TAILQ_ENTRY(sxe2_class_driver) next;
 	enum sxe2_class_type drv_class;
-	const s8 *name;
+	const char *name;
 	sxe2_class_driver_probe_t *probe;
 	sxe2_class_driver_remove_t *remove;
 	const struct rte_pci_id *id_table;
drivers/common/sxe2/sxe2_ioctl_chnl.c +27 -0
index 0d300e0f81..b8830039ff 100644
@@ -159,3 +159,30 @@ sxe2_drv_dev_handshark(struct sxe2_common_device *cdev)
 l_end:
 	return ret;
 }
+
+RTE_EXPORT_INTERNAL_SYMBOL(sxe2_drv_dev_munmap)
+s32
+sxe2_drv_dev_munmap(struct sxe2_common_device *cdev, void *virt, u64 len)
+{
+	s32 ret = SXE2_SUCCESS;
+
+	if (cdev->config.kernel_reset) {
+		ret = SXE2_ERR_PERM;
+		PMD_LOG_WARN(COM, "kernel reseted, need restart app.");
+		goto l_end;
+	}
+
+	PMD_LOG_DEBUG(COM, "Munmap virt=%p, len=0x%zx",
+		virt, len);
+
+	ret = munmap(virt, len);
+	if (ret < 0) {
+		PMD_LOG_ERR(COM, "Failed to munmap, virt=%p, len=0x%zx, err:%s",
+			virt, len, strerror(errno));
+		ret = SXE2_ERR_IO;
+		goto l_end;
+	}
+
+l_end:
+	return ret;
+}
drivers/common/sxe2/sxe2_ioctl_chnl_func.h +9 -0
index 0c3cb9caea..376c5e3ac7 100644
@@ -38,6 +38,15 @@ __rte_internal
 s32
 sxe2_drv_dev_handshark(struct sxe2_common_device *cdev);
 
+__rte_internal
+void
+*sxe2_drv_dev_mmap(struct sxe2_common_device *cdev, u8 bar_idx,
+		u64 len, u64 offset);
+
+__rte_internal
+s32
+sxe2_drv_dev_munmap(struct sxe2_common_device *cdev, void *virt, u64 len);
+
 #ifdef __cplusplus
 }
 #endif
drivers/net/meson.build +1 -0
index c7dae4ad27..4e8ccb945f 100644
@@ -58,6 +58,7 @@ drivers = [
         'rnp',
         'sfc',
         'softnic',
+        'sxe2',
         'tap',
         'thunderx',
         'txgbe',
drivers/net/sxe2/meson.build new file +21 -0
new file mode 100644
index 0000000000..6c9a86423a
@@ -0,0 +1,21 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+
+if is_windows
+        build = false
+        reason = 'only supported on Linux'
+        subdir_done()
+endif
+
+cflags += ['-g']
+
+deps += ['common_sxe2', 'hash','cryptodev','security']
+
+sources += files(
+        'sxe2_ethdev.c',
+        'sxe2_cmd_chnl.c',
+        'sxe2_vsi.c',
+        'sxe2_queue.c',
+)
+
+allow_internal_get_api = true
drivers/net/sxe2/sxe2_cmd_chnl.c new file +319 -0

319 lines not on this page · raw message

drivers/net/sxe2/sxe2_cmd_chnl.h new file +33 -0
new file mode 100644
index 0000000000..200fe0be00
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+ */
+
+#ifndef __SXE2_CMD_CHNL_H__
+#define __SXE2_CMD_CHNL_H__
+
+#include "sxe2_ethdev.h"
+#include "sxe2_drv_cmd.h"
+#include "sxe2_ioctl_chnl_func.h"
+
+s32 sxe2_drv_dev_caps_get(struct sxe2_adapter *adapter,
+		struct sxe2_drv_dev_caps_resp *dev_caps);
+
+s32 sxe2_drv_dev_info_get(struct sxe2_adapter *adapter,
+		struct sxe2_drv_dev_info_resp *dev_info_resp);
+
+s32 sxe2_drv_dev_fw_info_get(struct sxe2_adapter *adapter,
+		struct sxe2_drv_dev_fw_info_resp *dev_fw_info_resp);
+
+s32 sxe2_drv_vsi_add(struct sxe2_adapter *adapter, struct sxe2_vsi *vsi);
+
+s32 sxe2_drv_vsi_del(struct sxe2_adapter *adapter, struct sxe2_vsi *vsi);
+
+s32 sxe2_drv_rxq_switch(struct sxe2_adapter *adapter, struct sxe2_rx_queue *rxq, bool enable);
+
+s32 sxe2_drv_txq_switch(struct sxe2_adapter *adapter, struct sxe2_tx_queue *txq, bool enable);
+
+s32 sxe2_drv_rxq_ctxt_cfg(struct sxe2_adapter *adapter, struct sxe2_rx_queue *rxq, u16 rxq_cnt);
+
+s32 sxe2_drv_txq_ctxt_cfg(struct sxe2_adapter *adapter, struct sxe2_tx_queue *txq, u16 txq_cnt);
+
+#endif
drivers/net/sxe2/sxe2_drv_cmd.h new file +398 -0

398 lines not on this page · raw message

drivers/net/sxe2/sxe2_ethdev.c new file +611 -0

611 lines not on this page · raw message

drivers/net/sxe2/sxe2_ethdev.h new file +295 -0

295 lines not on this page · raw message

drivers/net/sxe2/sxe2_irq.h new file +49 -0

49 lines not on this page · raw message

drivers/net/sxe2/sxe2_queue.c new file +39 -0
new file mode 100644
index 0000000000..98343679f6
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+ */
+
+#include "sxe2_ethdev.h"
+#include "sxe2_queue.h"
+#include "sxe2_common_log.h"
+#include "sxe2_errno.h"
+
+void sxe2_sw_queue_ctx_hw_cap_set(struct sxe2_adapter *adapter,
+		struct sxe2_drv_queue_caps *q_caps)
+{
+	adapter->q_ctxt.qp_cnt_assign = q_caps->queues_cnt;
+	adapter->q_ctxt.base_idx_in_pf = q_caps->base_idx_in_pf;
+}
+
+s32 sxe2_queues_init(struct rte_eth_dev *dev)
+{
+	s32 ret = SXE2_SUCCESS;
+	u16 buf_size;
+	u16 frame_size;
+	struct sxe2_rx_queue *rxq;
+	u16 nb_rxq;
+
+	frame_size = dev->data->mtu + SXE2_ETH_OVERHEAD;
+	for (nb_rxq = 0; nb_rxq < dev->data->nb_rx_queues; nb_rxq++) {
+		rxq = dev->data->rx_queues[nb_rxq];
+		if (!rxq)
+			continue;
+
+		buf_size = rte_pktmbuf_data_room_size(rxq->mb_pool) - RTE_PKTMBUF_HEADROOM;
+		rxq->rx_buf_len = RTE_ALIGN_FLOOR(buf_size, (1 << SXE2_RXQ_CTX_DBUFF_SHIFT));
+		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;
+	}
+
+	return ret;
+}
drivers/net/sxe2/sxe2_queue.h new file +191 -0

191 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx_common.h new file +541 -0

541 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx_poll.h new file +16 -0
new file mode 100644
index 0000000000..4924b0f41f
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+ */
+
+#ifndef SXE2_TXRX_POLL_H
+#define SXE2_TXRX_POLL_H
+
+#include "sxe2_queue.h"
+
+u16 sxe2_tx_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, u16 nb_pkts);
+
+u16 sxe2_rx_pkts_scattered(void *rx_queue, struct rte_mbuf **rx_pkts, u16 nb_pkts);
+
+u16 sxe2_rx_pkts_scattered_split(void *rx_queue, struct rte_mbuf **rx_pkts, u16 nb_pkts);
+
+#endif
drivers/net/sxe2/sxe2_vsi.c new file +212 -0

212 lines not on this page · raw message

drivers/net/sxe2/sxe2_vsi.h new file +205 -0

205 lines not on this page · raw message

Signature · 1 line
2.47.3
#123 lore raw

PATCH v12 6/10 drivers: support PCI BAR mapping

In reply to [email protected]

From: Jie Liu <[email protected]>

Implement PCI BAR (Base Address Register) mapping and unmapping logic to enable MMIO (Memory Mapped I/O) access to hardware registers.

The driver retrieves the BAR0 virtual address from the PCI resource during the probing phase. This mapping is used for subsequent register-level operations. Proper cleanup is implemented in the device close path.

---
 drivers/common/sxe2/sxe2_ioctl_chnl.c |  38 +++-
 drivers/net/sxe2/sxe2_ethdev.c        | 308 ++++++++++++++++++++++++++
 drivers/net/sxe2/sxe2_ethdev.h        |  18 ++
 3 files changed, 362 insertions(+), 2 deletions(-)
drivers/common/sxe2/sxe2_ioctl_chnl.c +36 -2
index b8830039ff..8c55f5098f 100644
@@ -160,6 +160,40 @@ sxe2_drv_dev_handshark(struct sxe2_common_device *cdev)
 	return ret;
 }
 
+RTE_EXPORT_INTERNAL_SYMBOL(sxe2_drv_dev_mmap)
+void
+*sxe2_drv_dev_mmap(struct sxe2_common_device *cdev, u8 bar_idx, u64 len, u64 offset)
+{
+	s32 cmd_fd = 0;
+	void *virt = NULL;
+
+	if (cdev->config.kernel_reset) {
+		PMD_LOG_WARN(COM, "kernel reseted, need restart app.");
+		goto l_err;
+	}
+
+	cmd_fd = SXE2_CDEV_TO_CMD_FD(cdev);
+	if (cmd_fd < 0) {
+		PMD_LOG_ERR(COM, "Failed to exec cmd, fd=%d", cmd_fd);
+		goto l_err;
+	}
+
+	PMD_LOG_DEBUG(COM, "fd=%d, bar idx=%d, len=0x%zx, src=0x%"PRIx64", offset=0x%"PRIx64"",
+		bar_idx, cmd_fd, 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));
+	if (virt == MAP_FAILED) {
+		PMD_LOG_ERR(COM, "Failed mmap, cmd_fd=%d, len=0x%zx, offset=0x%"PRIx64", err:%s",
+			cmd_fd, len, offset, strerror(errno));
+		goto l_err;
+	}
+
+	return virt;
+l_err:
+	return NULL;
+}
+
 RTE_EXPORT_INTERNAL_SYMBOL(sxe2_drv_dev_munmap)
 s32
 sxe2_drv_dev_munmap(struct sxe2_common_device *cdev, void *virt, u64 len)
@@ -167,7 +201,7 @@ sxe2_drv_dev_munmap(struct sxe2_common_device *cdev, void *virt, u64 len)
 	s32 ret = SXE2_SUCCESS;
 
 	if (cdev->config.kernel_reset) {
-		ret = SXE2_ERR_PERM;
+		ret = -EPERM;
 		PMD_LOG_WARN(COM, "kernel reseted, need restart app.");
 		goto l_end;
 	}
@@ -179,7 +213,7 @@ sxe2_drv_dev_munmap(struct sxe2_common_device *cdev, void *virt, u64 len)
 	if (ret < 0) {
 		PMD_LOG_ERR(COM, "Failed to munmap, virt=%p, len=0x%zx, err:%s",
 			virt, len, strerror(errno));
-		ret = SXE2_ERR_IO;
+		ret = -EIO;
 		goto l_end;
 	}
 
drivers/net/sxe2/sxe2_ethdev.c +308 -0

356 lines not on this page · raw message

drivers/net/sxe2/sxe2_ethdev.h +18 -0
index 412f5d2b14..698e2ee4a2 100644
@@ -292,4 +292,22 @@ struct sxe2_adapter {
 #define SXE2_DEV_PRIVATE_TO_ADAPTER(dev) \
 	((struct sxe2_adapter *)(dev)->data->dev_private)
 
+#define SXE2_DEV_TO_PCI(eth_dev) \
+		RTE_DEV_TO_PCI((eth_dev)->device)
+
+struct sxe2_pci_map_bar_info *sxe2_dev_get_bar_info(struct sxe2_adapter *adapter,
+		enum sxe2_pci_map_resource res_type);
+
+s32 sxe2_dev_pci_seg_map(struct sxe2_adapter *adapter,
+		enum sxe2_pci_map_resource res_type, u64 org_len, u64 org_offset);
+
+s32 sxe2_dev_pci_res_seg_map(struct sxe2_adapter *adapter, u32 res_type,
+		u32 item_cnt, u32 item_base);
+
+void sxe2_dev_pci_seg_unmap(struct sxe2_adapter *adapter, u32 res_type);
+
+s32 sxe2_dev_pci_map_init(struct rte_eth_dev *dev);
+
+void sxe2_dev_pci_map_uinit(struct rte_eth_dev *dev);
+
 #endif
Signature · 1 line
2.47.3
#124 lore raw

PATCH v12 7/10 common/sxe2: add ioctl interface for DMA map and unmap

In reply to [email protected]

From: Jie Liu <[email protected]>

Implement DMA mapping and unmapping functionality using ioctl calls. This allows the driver to configure the hardware's IOMMU/DMA tables, ensuring the device can safely access memory buffers allocated by the userspace.

The mapping is established during device initialization or queue setup and is revoked during device closure to prevent memory leaks and ensure hardware security.

---
 drivers/common/sxe2/sxe2_common.c          |  50 +++++++++-
 drivers/common/sxe2/sxe2_ioctl_chnl.c      | 108 ++++++++++++++++++++-
 drivers/common/sxe2/sxe2_ioctl_chnl_func.h |   9 ++
 3 files changed, 164 insertions(+), 3 deletions(-)
drivers/common/sxe2/sxe2_common.c +49 -1
index 7d4001343a..e04982e92f 100644
@@ -443,7 +443,7 @@ static s32 sxe2_common_pci_remove(struct rte_pci_device *pci_dev)
 	cdev = sxe2_rtedev_to_cdev(&pci_dev->device);
 	if (cdev == NULL) {
 		ret = -ENODEV;
-		PMD_LOG_ERR(COM, "Fail to get remove device.");
+		PMD_LOG_ERR(COM, "Fail to get device when remove.");
 		goto l_end;
 	}
 
@@ -467,12 +467,60 @@ static s32 sxe2_common_pci_remove(struct rte_pci_device *pci_dev)
 	return ret;
 }
 
+static s32 sxe2_common_pci_dma_map(struct rte_pci_device *pci_dev,
+		void *addr,	u64 iova, size_t len)
+{
+	struct sxe2_common_device *cdev;
+	s32 ret = SXE2_ERROR;
+
+	cdev = sxe2_rtedev_to_cdev(&pci_dev->device);
+	if (cdev == NULL) {
+		ret = -ENODEV;
+		PMD_LOG_ERR(COM, "Fail to get device when dma map.");
+		goto l_end;
+	}
+
+	ret = sxe2_drv_dev_dma_map(cdev, (u64)(uintptr_t)addr, iova, len);
+	if (ret) {
+		PMD_LOG_ERR(COM, "Fail to map dma map, ret=%d", ret);
+		goto l_end;
+	}
+
+l_end:
+	return ret;
+}
+
+static s32 sxe2_common_pci_dma_unmap(struct rte_pci_device *pci_dev,
+		void *addr __rte_unused, u64 iova, size_t len __rte_unused)
+{
+	struct sxe2_common_device *cdev;
+	s32 ret = SXE2_ERROR;
+
+	cdev = sxe2_rtedev_to_cdev(&pci_dev->device);
+	if (cdev == NULL) {
+		ret = -ENODEV;
+		PMD_LOG_ERR(COM, "Fail to get device when dma unmap.");
+		goto l_end;
+	}
+
+	ret = sxe2_drv_dev_dma_unmap(cdev, iova);
+	if (ret) {
+		PMD_LOG_ERR(COM, "Fail to unmap dma map, ret=%d", ret);
+		goto l_end;
+	}
+
+l_end:
+	return ret;
+}
+
 static struct rte_pci_driver sxe2_common_pci_driver = {
 	.driver = {
 		   .name = SXE2_COMMON_PCI_DRIVER_NAME,
 	},
 	.probe = sxe2_common_pci_probe,
 	.remove = sxe2_common_pci_remove,
+	.dma_map = sxe2_common_pci_dma_map,
+	.dma_unmap = sxe2_common_pci_dma_unmap,
 };
 
 static u32 sxe2_common_pci_id_table_size_get(const struct rte_pci_id *id_table)
drivers/common/sxe2/sxe2_ioctl_chnl.c +106 -2

123 lines not on this page · raw message

drivers/common/sxe2/sxe2_ioctl_chnl_func.h +9 -0
index 376c5e3ac7..e8f983e40e 100644
@@ -47,6 +47,15 @@ __rte_internal
 s32
 sxe2_drv_dev_munmap(struct sxe2_common_device *cdev, void *virt, u64 len);
 
+__rte_internal
+s32
+sxe2_drv_dev_dma_map(struct sxe2_common_device *cdev, u64 vaddr,
+		u64 iova, u64 size);
+
+__rte_internal
+s32
+sxe2_drv_dev_dma_unmap(struct sxe2_common_device *cdev, u64 iova);
+
 #ifdef __cplusplus
 }
 #endif
Signature · 1 line
2.47.3
#125 lore raw

PATCH v12 8/10 net/sxe2: support queue setup and control

In reply to [email protected]

From: Jie Liu <[email protected]>

Add support for Rx and Tx queue setup, release, and management. Implement eth_dev_ops callbacks for rx_queue_setup, tx_queue_setup, rx_queue_release, and tx_queue_release.

This includes:
- Allocating memory for hardware ring descriptors.
- Initializing software ring structures and hardware head/tail pointers.
- Implementing proper resource cleanup logic to prevent memory leaks during queue reconfiguration or device close.

---
 drivers/net/sxe2/meson.build    |   2 +
 drivers/net/sxe2/sxe2_drv_cmd.h |   9 -
 drivers/net/sxe2/sxe2_ethdev.c  |  66 +++-
 drivers/net/sxe2/sxe2_ethdev.h  |   3 +
 drivers/net/sxe2/sxe2_rx.c      | 579 ++++++++++++++++++++++++++++++++
 drivers/net/sxe2/sxe2_rx.h      |  34 ++
 drivers/net/sxe2/sxe2_tx.c      | 447 ++++++++++++++++++++++++
 drivers/net/sxe2/sxe2_tx.h      |  32 ++
 8 files changed, 1145 insertions(+), 27 deletions(-)
 create mode 100644 drivers/net/sxe2/sxe2_rx.c
 create mode 100644 drivers/net/sxe2/sxe2_rx.h
 create mode 100644 drivers/net/sxe2/sxe2_tx.c
 create mode 100644 drivers/net/sxe2/sxe2_tx.h
drivers/net/sxe2/meson.build +2 -0
index 6c9a86423a..8638244d80 100644
@@ -16,6 +16,8 @@ sources += files(
         'sxe2_cmd_chnl.c',
         'sxe2_vsi.c',
         'sxe2_queue.c',
+        'sxe2_tx.c',
+        'sxe2_rx.c',
 )
 
 allow_internal_get_api = true
drivers/net/sxe2/sxe2_drv_cmd.h +0 -9
index 4094442077..f236e30c40 100644
@@ -5,17 +5,8 @@
 #ifndef __SXE2_DRV_CMD_H__
 #define __SXE2_DRV_CMD_H__
 
-#ifdef SXE2_DPDK_DRIVER
 #include "sxe2_type.h"
 #define SXE2_DPDK_RESOURCE_INSUFFICIENT
-#endif
-
-#ifdef SXE2_LINUX_DRIVER
-#ifdef __KERNEL__
-#include <linux/types.h>
-#include <linux/if_ether.h>
-#endif
-#endif
 
 #define SXE2_DRV_CMD_MODULE_S        (16)
 #define SXE2_MK_DRV_CMD(module, cmd) (((module) << SXE2_DRV_CMD_MODULE_S) | ((cmd) & 0xFFFF))
drivers/net/sxe2/sxe2_ethdev.c +48 -18

96 lines not on this page · raw message

drivers/net/sxe2/sxe2_ethdev.h +3 -0
index 698e2ee4a2..4ef7854479 100644
@@ -295,6 +295,9 @@ struct sxe2_adapter {
 #define SXE2_DEV_TO_PCI(eth_dev) \
 		RTE_DEV_TO_PCI((eth_dev)->device)
 
+void __iomem *sxe2_pci_map_addr_get(struct sxe2_adapter *adapter,
+		enum sxe2_pci_map_resource res_type, u16 idx_in_func);
+
 struct sxe2_pci_map_bar_info *sxe2_dev_get_bar_info(struct sxe2_adapter *adapter,
 		enum sxe2_pci_map_resource res_type);
 
drivers/net/sxe2/sxe2_rx.c new file +579 -0

579 lines not on this page · raw message

drivers/net/sxe2/sxe2_rx.h new file +34 -0
new file mode 100644
index 0000000000..7c6239b387
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+ */
+
+#ifndef __SXE2_RX_H__
+#define __SXE2_RX_H__
+
+#include "sxe2_queue.h"
+
+s32 __rte_cold sxe2_rx_queue_setup(struct rte_eth_dev *dev,
+				u16 queue_idx, u16 nb_desc, u32 socket_id,
+				const struct rte_eth_rxconf *rx_conf,
+				struct rte_mempool *mp);
+
+s32 __rte_cold sxe2_rx_queue_stop(struct rte_eth_dev *dev, u16 rx_queue_id);
+
+void __rte_cold sxe2_rx_queue_mbufs_release(struct sxe2_rx_queue *rxq);
+
+void __rte_cold sxe2_rx_queue_release(struct rte_eth_dev *dev, u16 queue_idx);
+
+void __rte_cold sxe2_all_rxqs_release(struct rte_eth_dev *dev);
+
+void __rte_cold sxe2_rx_queue_info_get(struct rte_eth_dev *dev, u16 queue_id,
+		struct rte_eth_rxq_info *qinfo);
+
+s32 __rte_cold sxe2_rx_queue_start(struct rte_eth_dev *dev, u16 rx_queue_id);
+
+s32 __rte_cold sxe2_rxqs_all_start(struct rte_eth_dev *dev);
+
+void __rte_cold sxe2_rxqs_all_stop(struct rte_eth_dev *dev);
+
+struct rte_mbuf *sxe2_mbuf_raw_alloc(struct rte_mempool *mp);
+
+#endif
drivers/net/sxe2/sxe2_tx.c new file +447 -0

447 lines not on this page · raw message

drivers/net/sxe2/sxe2_tx.h new file +32 -0
new file mode 100644
index 0000000000..58b668e337
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+ */
+
+#ifndef __SXE2_TX_H__
+#define __SXE2_TX_H__
+#include "sxe2_queue.h"
+
+void __rte_cold sxe2_tx_queue_reset(struct sxe2_tx_queue *txq);
+
+s32 __rte_cold sxe2_tx_queue_start(struct rte_eth_dev *dev, u16 queue_id);
+
+void sxe2_tx_queue_mbufs_release(struct sxe2_tx_queue *txq);
+
+s32 __rte_cold sxe2_tx_queue_stop(struct rte_eth_dev *dev, u16 queue_id);
+
+s32 __rte_cold sxe2_tx_queue_setup(struct rte_eth_dev *dev,
+		u16 queue_idx, u16 nb_desc, u32 socket_id,
+		const struct rte_eth_txconf *tx_conf);
+
+void __rte_cold sxe2_tx_queue_release(struct rte_eth_dev *dev, u16 queue_idx);
+
+void __rte_cold sxe2_all_txqs_release(struct rte_eth_dev *dev);
+
+void __rte_cold sxe2_tx_queue_info_get(struct rte_eth_dev *dev, u16 queue_id,
+		struct rte_eth_txq_info *qinfo);
+
+s32 __rte_cold sxe2_txqs_all_start(struct rte_eth_dev *dev);
+
+void __rte_cold sxe2_txqs_all_stop(struct rte_eth_dev *dev);
+
+#endif
Signature · 1 line
2.47.3
#126 lore raw

PATCH v12 9/10 drivers: add data path for Rx and Tx

In reply to [email protected]

From: Jie Liu <[email protected]>

Implement receive and transmit burst functions for sxe2 PMD. Add sxe2_recv_pkts and sxe2_xmit_pkts as the primary data path interfaces.

The implementation includes:
- Efficient descriptor fetching and mbuf allocation for Rx.
- Descriptor setup and checksum offload handling for Tx.
- Buffer recycling and hardware tail pointer updates.
- Performance-oriented loop unrolling and prefetching where applicable.

---
 drivers/common/sxe2/sxe2_common.c     |   1 +
 drivers/common/sxe2/sxe2_common_log.h |   1 -
 drivers/common/sxe2/sxe2_errno.h      |   3 -
 drivers/common/sxe2/sxe2_ioctl_chnl.c |   8 +-
 drivers/common/sxe2/sxe2_osal.h       |   4 +-
 drivers/common/sxe2/sxe2_type.h       |   1 -
 drivers/net/sxe2/meson.build          |   2 +
 drivers/net/sxe2/sxe2_ethdev.c        |  22 +-
 drivers/net/sxe2/sxe2_txrx.c          | 247 +++++++
 drivers/net/sxe2/sxe2_txrx.h          |  21 +
 drivers/net/sxe2/sxe2_txrx_poll.c     | 945 ++++++++++++++++++++++++++
 11 files changed, 1238 insertions(+), 17 deletions(-)
 create mode 100644 drivers/net/sxe2/sxe2_txrx.c
 create mode 100644 drivers/net/sxe2/sxe2_txrx.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_poll.c
drivers/common/sxe2/sxe2_common.c +1 -0
index e04982e92f..73b288d5d8 100644
@@ -664,6 +664,7 @@ sxe2_common_init(void)
 		goto l_end;
 
 	pthread_mutex_init(&sxe2_common_devices_list_lock, NULL);
+
 	sxe2_common_pci_init();
 	sxe2_commoin_inited = true;
 
drivers/common/sxe2/sxe2_common_log.h +0 -1
index a7d2157610..cbb53263b5 100644
@@ -81,4 +81,3 @@ extern s32 sxe2_log_hw;
 #define PMD_INIT_FUNC_TRACE() PMD_LOG_DEBUG(INIT, " >>")
 
 #endif /* __SXE2_COMMON_LOG_H__ */
-
drivers/common/sxe2/sxe2_errno.h +0 -3
index 89a715eaef..1257319edf 100644
@@ -50,9 +50,6 @@ enum sxe2_status {
 	SXE2_ERR_NOLCK              = -ENOLCK,
 	SXE2_ERR_NOSYS              = -ENOSYS,
 	SXE2_ERR_NOTEMPTY           = -ENOTEMPTY,
-	SXE2_ERR_ILSEQ              = -EILSEQ,
-	SXE2_ERR_NODATA             = -ENODATA,
-	SXE2_ERR_CANCELED           = -ECANCELED,
 	SXE2_ERR_TIMEDOUT           = -ETIMEDOUT,
 
 	SXE2_ERROR                  = -150,
drivers/common/sxe2/sxe2_ioctl_chnl.c +4 -4
index 4dfc4fd0fa..b9224cf197 100644
@@ -178,13 +178,13 @@ void
 		goto l_err;
 	}
 
-	PMD_LOG_DEBUG(COM, "fd=%d, bar idx=%d, len=0x%zx, src=0x%"PRIx64", offset=0x%"PRIx64"",
+	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));
 
 	virt = mmap(NULL, len, PROT_READ | PROT_WRITE,
 		MAP_SHARED, cmd_fd, SXE2_COM_PCI_OFFSET_GEN(bar_idx, offset));
 	if (virt == MAP_FAILED) {
-		PMD_LOG_ERR(COM, "Failed mmap, cmd_fd=%d, len=0x%zx, offset=0x%"PRIx64", err:%s",
+		PMD_LOG_ERR(COM, "Failed mmap, cmd_fd=%d, len=%"PRIu64", offset=0x%"PRIx64", err:%s",
 			cmd_fd, len, offset, strerror(errno));
 		goto l_err;
 	}
@@ -206,12 +206,12 @@ sxe2_drv_dev_munmap(struct sxe2_common_device *cdev, void *virt, u64 len)
 		goto l_end;
 	}
 
-	PMD_LOG_DEBUG(COM, "Munmap virt=%p, len=0x%zx",
+	PMD_LOG_DEBUG(COM, "Munmap virt=%p, len=0x%"PRIx64"",
 		virt, len);
 
 	ret = munmap(virt, len);
 	if (ret < 0) {
-		PMD_LOG_ERR(COM, "Failed to munmap, virt=%p, len=0x%zx, err:%s",
+		PMD_LOG_ERR(COM, "Failed to munmap, virt=%p, len=%"PRIu64", err:%s",
 			virt, len, strerror(errno));
 		ret = -EIO;
 		goto l_end;
drivers/common/sxe2/sxe2_osal.h +1 -3
index e0f4b753b2..20d1accd5f 100644
@@ -29,8 +29,6 @@
 #define BIT_ULL(a) (1ULL << (a))
 #endif
 
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
-
 #define BITS_PER_BYTE 8
 
 #define IS_UNICAST_ETHER_ADDR(addr)			\
@@ -88,7 +86,7 @@
 			(((n) + (typeof(n))(d) - (typeof(n))1) / (typeof(n))(d))
 #endif
 
-#define usleep_range(min, max) msleep(DIV_ROUND_UP(min, 1000))
+#define usleep_range(min) msleep(DIV_ROUND_UP(min, 1000))
 
 #define __bf_shf(x) ((uint32_t)rte_bsf64(x))
 
drivers/common/sxe2/sxe2_type.h +0 -1
index 86923adf6f..e4ef6ed2ce 100644
@@ -8,7 +8,6 @@
 #include <sys/time.h>
 
 #include <stdlib.h>
-#include <stdio.h>
 #include <errno.h>
 #include <stdarg.h>
 #include <unistd.h>
drivers/net/sxe2/meson.build +2 -0
index 8638244d80..b348dd71a1 100644
@@ -18,6 +18,8 @@ sources += files(
         'sxe2_queue.c',
         'sxe2_tx.c',
         'sxe2_rx.c',
+        'sxe2_txrx_poll.c',
+        'sxe2_txrx.c',
 )
 
 allow_internal_get_api = true
drivers/net/sxe2/sxe2_ethdev.c +17 -5
index bb51b9fb71..38e3967c56 100644
@@ -27,6 +27,7 @@
 #include "sxe2_cmd_chnl.h"
 #include "sxe2_tx.h"
 #include "sxe2_rx.h"
+#include "sxe2_txrx.h"
 #include "sxe2_common.h"
 #include "sxe2_common_log.h"
 #include "sxe2_host_regs.h"
@@ -132,6 +133,9 @@ static s32 sxe2_dev_start(struct rte_eth_dev *dev)
 		goto l_end;
 	}
 
+	sxe2_rx_mode_func_set(dev);
+	sxe2_tx_mode_func_set(dev);
+
 	ret = sxe2_queues_start(dev);
 	if (ret) {
 		PMD_LOG_ERR(INIT, "enable queues failed");
@@ -349,8 +353,8 @@ void __iomem *sxe2_pci_map_addr_get(struct sxe2_adapter *adapter,
 	for (i = 0; i < bar_info->map_cnt; i++) {
 		seg_info = &bar_info->seg_info[i];
 		if (res_type == seg_info->type) {
-			addr = (void __iomem *)((uintptr_t)seg_info->addr +
-					seg_info->page_inner_offset + reg_width	* idx_in_func);
+			addr = (uint8_t __iomem *)seg_info->addr +
+					seg_info->page_inner_offset + reg_width * idx_in_func;
 			goto l_end;
 		}
 	}
@@ -461,8 +465,9 @@ s32 sxe2_dev_pci_seg_map(struct sxe2_adapter *adapter,
 
 	map_addr = sxe2_drv_dev_mmap(adapter->cdev, bar_info->bar_idx, aligned_len, aligned_offset);
 	if (!map_addr) {
-		PMD_LOG_ERR(INIT, "Failed to mmap BAR space, type=%d, len=%zu, page_size=%zu",
-					res_type, org_len, page_size);
+		PMD_LOG_ERR(INIT, "Failed to mmap BAR space, type=%d, len=%" PRIu64
+			", offset=%" PRIu64 ", page_size=%zu",
+					res_type, org_len, org_offset, page_size);
 		ret = -EFAULT;
 		goto l_end;
 	}
@@ -746,10 +751,17 @@ static s32 sxe2_dev_init(struct rte_eth_dev *dev, struct sxe2_dev_kvargs_info *k
 
 	PMD_INIT_FUNC_TRACE();
 
+	sxe2_set_common_function(dev);
+
 	dev->dev_ops = &sxe2_eth_dev_ops;
 
-	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		sxe2_rx_mode_func_set(dev);
+		sxe2_tx_mode_func_set(dev);
+		if (ret != SXE2_SUCCESS)
+			PMD_LOG_ERR(INIT, "Failed to mp init (secondary), ret=%d", ret);
 		goto l_end;
+	}
 
 	ret = sxe2_hw_init(dev);
 	if (ret) {
drivers/net/sxe2/sxe2_txrx.c new file +247 -0

247 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx.h new file +21 -0
new file mode 100644
index 0000000000..e6f671e3dc
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+ */
+
+#ifndef SXE2_TXRX_H
+#define SXE2_TXRX_H
+#include <ethdev_driver.h>
+#include "sxe2_queue.h"
+
+void sxe2_set_common_function(struct rte_eth_dev *dev);
+
+u16 sxe2_tx_pkts_prepare(void *tx_queue,
+		struct rte_mbuf **tx_pkts, u16 nb_pkts);
+
+void sxe2_tx_mode_func_set(struct rte_eth_dev *dev);
+
+void __rte_cold sxe2_rx_queue_reset(struct sxe2_rx_queue *rxq);
+
+void sxe2_rx_mode_func_set(struct rte_eth_dev *dev);
+
+#endif
drivers/net/sxe2/sxe2_txrx_poll.c new file +945 -0

945 lines not on this page · raw message

Signature · 1 line
2.47.3
#127 lore raw

PATCH v12 10/10 net/sxe2: add vectorized Rx and Tx

In reply to [email protected]

From: Jie Liu <[email protected]>

This patch implements the vectorized data path for the sxe2 PMD. It utilizes SIMD instructions (e.g., SSE) to process multiple packets simultaneously, significantly improving throughput for small packet processing.

The implementation includes:
* Vectorized Rx burst function for bulk descriptor processing.
* Vectorized Tx burst function with optimized resource cleanup.
* Capability flags update to reflect vectorized path support.

---
 drivers/net/sxe2/meson.build            |   7 +
 drivers/net/sxe2/sxe2_ethdev.c          |  35 +-
 drivers/net/sxe2/sxe2_ethdev.h          |   1 -
 drivers/net/sxe2/sxe2_queue.c           |  28 ++
 drivers/net/sxe2/sxe2_queue.h           |   3 +
 drivers/net/sxe2/sxe2_txrx.c            | 221 +++++++---
 drivers/net/sxe2/sxe2_txrx.h            |  11 +-
 drivers/net/sxe2/sxe2_txrx_poll.h       |   3 +-
 drivers/net/sxe2/sxe2_txrx_vec.c        | 197 +++++++++
 drivers/net/sxe2/sxe2_txrx_vec.h        |  72 ++++
 drivers/net/sxe2/sxe2_txrx_vec_common.h | 235 ++++++++++
 drivers/net/sxe2/sxe2_txrx_vec_sse.c    | 545 ++++++++++++++++++++++++
 12 files changed, 1276 insertions(+), 82 deletions(-)
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec.c
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec_common.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec_sse.c
drivers/net/sxe2/meson.build +7 -0
index b348dd71a1..3df57aee8c 100644
@@ -11,6 +11,12 @@ cflags += ['-g']
 
 deps += ['common_sxe2', 'hash','cryptodev','security']
 
+includes += include_directories('../../common/sxe2')
+
+if arch_subdir == 'x86'
+        sources += files('sxe2_txrx_vec_sse.c')
+endif
+
 sources += files(
         'sxe2_ethdev.c',
         'sxe2_cmd_chnl.c',
@@ -20,6 +26,7 @@ sources += files(
         'sxe2_rx.c',
         'sxe2_txrx_poll.c',
         'sxe2_txrx.c',
+        'sxe2_txrx_vec.c',
 )
 
 allow_internal_get_api = true
drivers/net/sxe2/sxe2_ethdev.c +8 -27
index 38e3967c56..dc4a33901d 100644
@@ -59,17 +59,11 @@ static const struct rte_pci_id pci_id_sxe2_tbl[] = {
 };
 
 static struct sxe2_pci_map_addr_info sxe2_net_map_addr_info_pf[SXE2_PCI_MAP_RES_MAX_COUNT] = {
-	/* SXE2_PCI_MAP_RES_INVALID */
 	{0, 0, 0},
-	/* SXE2_PCI_MAP_RES_DOORBELL_TX */
 	{ SXE2_TXQ_LEGACY_DBLL(0), 0, 4},
-	/* SXE2_PCI_MAP_RES_DOORBELL_RX_TAIL */
 	{ SXE2_RXQ_TAIL(0), 0, 4},
-	/* SXE2_PCI_MAP_RES_IRQ_DYN */
 	{ SXE2_VF_DYN_CTL(0), 0, 4},
-	/* SXE2_PCI_MAP_RES_IRQ_ITR(默认使用ITR0) */
 	{ SXE2_VF_INT_ITR(0, 0), 0, 4},
-	/* SXE2_PCI_MAP_RES_IRQ_MSIX */
 	{ SXE2_BAR4_MSIX_CTL(0), 4, 0x10},
 };
 
@@ -102,25 +96,6 @@ static s32 sxe2_dev_stop(struct rte_eth_dev *dev)
 	return ret;
 }
 
-static s32 sxe2_queues_start(struct rte_eth_dev *dev)
-{
-	s32 ret = SXE2_SUCCESS;
-	ret = sxe2_txqs_all_start(dev);
-	if (ret) {
-		PMD_LOG_ERR(INIT, "Failed to start tx queue.");
-		goto l_end;
-	}
-
-	ret = sxe2_rxqs_all_start(dev);
-	if (ret) {
-		PMD_LOG_ERR(INIT, "Failed to start rx queue.");
-		sxe2_txqs_all_stop(dev);
-	}
-
-l_end:
-	return ret;
-}
-
 static s32 sxe2_dev_start(struct rte_eth_dev *dev)
 {
 	s32 ret = SXE2_SUCCESS;
@@ -153,7 +128,7 @@ static s32 sxe2_dev_start(struct rte_eth_dev *dev)
 static s32 sxe2_dev_close(struct rte_eth_dev *dev)
 {
 	(void)sxe2_dev_stop(dev);
-
+	(void)sxe2_queues_release(dev);
 	sxe2_vsi_uninit(dev);
 	sxe2_dev_pci_map_uinit(dev);
 
@@ -291,13 +266,19 @@ static const struct eth_dev_ops sxe2_eth_dev_ops = {
 	.dev_close                  = sxe2_dev_close,
 	.dev_infos_get              = sxe2_dev_infos_get,
 
+	.rx_queue_start             = sxe2_rx_queue_start,
+	.rx_queue_stop              = sxe2_rx_queue_stop,
+	.tx_queue_start             = sxe2_tx_queue_start,
+	.tx_queue_stop              = sxe2_tx_queue_stop,
 	.rx_queue_setup             = sxe2_rx_queue_setup,
-	.tx_queue_setup             = sxe2_tx_queue_setup,
 	.rx_queue_release           = sxe2_rx_queue_release,
+	.tx_queue_setup             = sxe2_tx_queue_setup,
 	.tx_queue_release           = sxe2_tx_queue_release,
 
 	.rxq_info_get               = sxe2_rx_queue_info_get,
 	.txq_info_get               = sxe2_tx_queue_info_get,
+	.rx_burst_mode_get          = sxe2_rx_burst_mode_get,
+	.tx_burst_mode_get          = sxe2_tx_burst_mode_get,
 };
 
 struct sxe2_pci_map_bar_info *sxe2_dev_get_bar_info(struct sxe2_adapter *adapter,
drivers/net/sxe2/sxe2_ethdev.h +0 -1
index 4ef7854479..43148f9b03 100644
@@ -11,7 +11,6 @@
 #include <rte_tm_driver.h>
 #include <rte_io.h>
 
-#include "sxe2_common.h"
 #include "sxe2_errno.h"
 #include "sxe2_type.h"
 #include "sxe2_vsi.h"
drivers/net/sxe2/sxe2_queue.c +28 -0
index 98343679f6..b1860490aa 100644
@@ -6,6 +6,8 @@
 #include "sxe2_queue.h"
 #include "sxe2_common_log.h"
 #include "sxe2_errno.h"
+#include "sxe2_tx.h"
+#include "sxe2_rx.h"
 
 void sxe2_sw_queue_ctx_hw_cap_set(struct sxe2_adapter *adapter,
 		struct sxe2_drv_queue_caps *q_caps)
@@ -37,3 +39,29 @@ s32 sxe2_queues_init(struct rte_eth_dev *dev)
 
 	return ret;
 }
+
+s32 sxe2_queues_start(struct rte_eth_dev *dev)
+{
+	s32 ret = SXE2_SUCCESS;
+
+	ret = sxe2_txqs_all_start(dev);
+	if (ret) {
+		PMD_LOG_ERR(INIT, "Failed to start tx queue.");
+		goto l_end;
+	}
+
+	ret = sxe2_rxqs_all_start(dev);
+	if (ret) {
+		PMD_LOG_ERR(INIT, "Failed to start rx queue.");
+		sxe2_txqs_all_stop(dev);
+	}
+l_end:
+	return ret;
+}
+
+void sxe2_queues_release(struct rte_eth_dev *dev)
+{
+	sxe2_all_rxqs_release(dev);
+
+	sxe2_all_txqs_release(dev);
+}
drivers/net/sxe2/sxe2_queue.h +3 -0
index 7fa22e2820..93402186c7 100644
@@ -188,4 +188,7 @@ void sxe2_sw_queue_ctx_hw_cap_set(struct sxe2_adapter *adapter,
 
 s32 sxe2_queues_init(struct rte_eth_dev *dev);
 
+s32 sxe2_queues_start(struct rte_eth_dev *dev);
+
+void sxe2_queues_release(struct rte_eth_dev *dev);
 #endif
drivers/net/sxe2/sxe2_txrx.c +173 -48

372 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx.h +6 -5
index e6f671e3dc..8f929c4f19 100644
@@ -6,16 +6,17 @@
 #define SXE2_TXRX_H
 #include <ethdev_driver.h>
 #include "sxe2_queue.h"
-
 void sxe2_set_common_function(struct rte_eth_dev *dev);
 
+s32 __rte_cold sxe2_tx_simple_batch_support_check(struct rte_eth_dev *dev,
+	u32 *batch_flags);
 u16 sxe2_tx_pkts_prepare(void *tx_queue,
 		struct rte_mbuf **tx_pkts, u16 nb_pkts);
-
 void sxe2_tx_mode_func_set(struct rte_eth_dev *dev);
-
 void __rte_cold sxe2_rx_queue_reset(struct sxe2_rx_queue *rxq);
-
 void sxe2_rx_mode_func_set(struct rte_eth_dev *dev);
-
+s32 sxe2_tx_burst_mode_get(struct rte_eth_dev *dev,
+			__rte_unused uint16_t queue_id, struct rte_eth_burst_mode *mode);
+s32 sxe2_rx_burst_mode_get(struct rte_eth_dev *dev,
+			__rte_unused u16 queue_id, struct rte_eth_burst_mode *mode);
 #endif
drivers/net/sxe2/sxe2_txrx_poll.h +2 -1
index 4924b0f41f..67da08e58e 100644
@@ -8,7 +8,8 @@
 #include "sxe2_queue.h"
 
 u16 sxe2_tx_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, u16 nb_pkts);
-
+u16 sxe2_tx_pkts_simple(void *tx_queue,
+			struct rte_mbuf **tx_pkts, u16 nb_pkts);
 u16 sxe2_rx_pkts_scattered(void *rx_queue, struct rte_mbuf **rx_pkts, u16 nb_pkts);
 
 u16 sxe2_rx_pkts_scattered_split(void *rx_queue, struct rte_mbuf **rx_pkts, u16 nb_pkts);
drivers/net/sxe2/sxe2_txrx_vec.c new file +197 -0

197 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx_vec.h new file +72 -0

72 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx_vec_common.h new file +235 -0

235 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx_vec_sse.c new file +545 -0

545 lines not on this page · raw message

Signature · 1 line
2.47.3
#128 lore raw

v13 cover net/sxe2: fix logic errors and address feedback

From: Jie Liu <[email protected]>

This patch set addresses the feedback received on the v10 submission for the sxe2 PMD. The primary focus is on fixing vector path selection, ensuring memory safety during mbuf initialization, and cleaning up redundant logic in the configuration functions.

v13 Changes:
- Fixed vector Rx burst function being overwritten by scalar selection.
- Refactored Rx/Tx mode set functions to seed flags from caps first,eliminating tautological checks.
- Added memset for mbuf_def in vector init to avoid uninitialized reads.
- Converted pci_map_addr_info to designated initializers.
- Removed dead Windows-only code in meson.build.
- Added NULL checks for mbuf free for driver-wide consistency.
- Updated burst_mode_get to accurately report AVX paths.
- Adjusted SXE2_ETH_OVERHEAD to match actual VLAN capabilities.

Jie Liu (10):
mailmap: add Jie Liu
doc: add sxe2 guide and release notes common/sxe2: add sxe2 basic structures
drivers: add base driver skeleton
drivers: add base driver probe skeleton
drivers: support PCI BAR mapping
common/sxe2: add ioctl interface for DMA map and unmap net/sxe2: support queue setup and control
drivers: add data path for Rx and Tx net/sxe2: add vectorized Rx and Tx

 .mailmap                                   |   1 +
 doc/guides/nics/features/sxe2.ini          |  30 +
 doc/guides/nics/index.rst                  |   1 +
 doc/guides/nics/sxe2.rst                   |  34 +
 doc/guides/rel_notes/release_26_07.rst     |   4 +
 drivers/common/sxe2/meson.build            |  15 +
 drivers/common/sxe2/sxe2_common.c          | 685 +++++++++++++++
 drivers/common/sxe2/sxe2_common.h          |  86 ++
 drivers/common/sxe2/sxe2_common_log.h      |  83 ++
 drivers/common/sxe2/sxe2_errno.h           | 110 +++
 drivers/common/sxe2/sxe2_host_regs.h       | 707 +++++++++++++++
 drivers/common/sxe2/sxe2_internal_ver.h    |  33 +
 drivers/common/sxe2/sxe2_ioctl_chnl.c      | 326 +++++++
 drivers/common/sxe2/sxe2_ioctl_chnl.h      | 141 +++
 drivers/common/sxe2/sxe2_ioctl_chnl_func.h |  63 ++
 drivers/common/sxe2/sxe2_osal.h            | 584 +++++++++++++
 drivers/common/sxe2/sxe2_type.h            |  60 ++
 drivers/meson.build                        |   1 +
 drivers/net/meson.build                    |   1 +
 drivers/net/sxe2/meson.build               |  32 +
 drivers/net/sxe2/sxe2_cmd_chnl.c           | 319 +++++++
 drivers/net/sxe2/sxe2_cmd_chnl.h           |  33 +
 drivers/net/sxe2/sxe2_drv_cmd.h            | 389 +++++++++
 drivers/net/sxe2/sxe2_ethdev.c             | 941 ++++++++++++++++++++
 drivers/net/sxe2/sxe2_ethdev.h             | 315 +++++++
 drivers/net/sxe2/sxe2_irq.h                |  49 ++
 drivers/net/sxe2/sxe2_queue.c              |  67 ++
 drivers/net/sxe2/sxe2_queue.h              | 194 +++++
 drivers/net/sxe2/sxe2_rx.c                 | 579 +++++++++++++
 drivers/net/sxe2/sxe2_rx.h                 |  34 +
 drivers/net/sxe2/sxe2_tx.c                 | 447 ++++++++++
 drivers/net/sxe2/sxe2_tx.h                 |  32 +
 drivers/net/sxe2/sxe2_txrx.c               | 372 ++++++++
 drivers/net/sxe2/sxe2_txrx.h               |  22 +
 drivers/net/sxe2/sxe2_txrx_common.h        | 541 ++++++++++++
 drivers/net/sxe2/sxe2_txrx_poll.c          | 945 +++++++++++++++++++++
 drivers/net/sxe2/sxe2_txrx_poll.h          |  17 +
 drivers/net/sxe2/sxe2_txrx_vec.c           | 197 +++++
 drivers/net/sxe2/sxe2_txrx_vec.h           |  72 ++
 drivers/net/sxe2/sxe2_txrx_vec_common.h    | 235 +++++
 drivers/net/sxe2/sxe2_txrx_vec_sse.c       | 545 ++++++++++++
 drivers/net/sxe2/sxe2_vsi.c                | 212 +++++
 drivers/net/sxe2/sxe2_vsi.h                | 205 +++++
 43 files changed, 9759 insertions(+)
 create mode 100644 doc/guides/nics/features/sxe2.ini
 create mode 100644 doc/guides/nics/sxe2.rst
 create mode 100644 drivers/common/sxe2/meson.build
 create mode 100644 drivers/common/sxe2/sxe2_common.c
 create mode 100644 drivers/common/sxe2/sxe2_common.h
 create mode 100644 drivers/common/sxe2/sxe2_common_log.h
 create mode 100644 drivers/common/sxe2/sxe2_errno.h
 create mode 100644 drivers/common/sxe2/sxe2_host_regs.h
 create mode 100644 drivers/common/sxe2/sxe2_internal_ver.h
 create mode 100644 drivers/common/sxe2/sxe2_ioctl_chnl.c
 create mode 100644 drivers/common/sxe2/sxe2_ioctl_chnl.h
 create mode 100644 drivers/common/sxe2/sxe2_ioctl_chnl_func.h
 create mode 100644 drivers/common/sxe2/sxe2_osal.h
 create mode 100644 drivers/common/sxe2/sxe2_type.h
 create mode 100644 drivers/net/sxe2/meson.build
 create mode 100644 drivers/net/sxe2/sxe2_cmd_chnl.c
 create mode 100644 drivers/net/sxe2/sxe2_cmd_chnl.h
 create mode 100644 drivers/net/sxe2/sxe2_drv_cmd.h
 create mode 100644 drivers/net/sxe2/sxe2_ethdev.c
 create mode 100644 drivers/net/sxe2/sxe2_ethdev.h
 create mode 100644 drivers/net/sxe2/sxe2_irq.h
 create mode 100644 drivers/net/sxe2/sxe2_queue.c
 create mode 100644 drivers/net/sxe2/sxe2_queue.h
 create mode 100644 drivers/net/sxe2/sxe2_rx.c
 create mode 100644 drivers/net/sxe2/sxe2_rx.h
 create mode 100644 drivers/net/sxe2/sxe2_tx.c
 create mode 100644 drivers/net/sxe2/sxe2_tx.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx.c
 create mode 100644 drivers/net/sxe2/sxe2_txrx.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_common.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_poll.c
 create mode 100644 drivers/net/sxe2/sxe2_txrx_poll.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec.c
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec_common.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec_sse.c
 create mode 100644 drivers/net/sxe2/sxe2_vsi.c
 create mode 100644 drivers/net/sxe2/sxe2_vsi.h
Signature · 1 line
2.47.3
#129 lore raw

PATCH v13 1/10 mailmap: add Jie Liu

From: Jie Liu <[email protected]>

---
 .mailmap | 1 +
 1 file changed, 1 insertion(+)
.mailmap +1 -0
index 895412e568..d2c4485636 100644
@@ -739,6 +739,7 @@ Jiawen Wu <[email protected]>
 Jiayu Hu <[email protected]> <[email protected]>
 Jie Hai <[email protected]>
 Jie Liu <[email protected]>
+Jie Liu <[email protected]>
 Jie Pan <[email protected]>
 Jie Wang <[email protected]>
 Jie Zhou <[email protected]> <[email protected]>
Signature · 1 line
2.47.3
#130 lore raw

PATCH v13 2/10 doc: add sxe2 guide and release notes

In reply to [email protected]

From: Jie Liu <[email protected]>

Add a new guide for SXE2 PMD in the nics directory. The guide contains driver capabilities, prerequisites, and compilation/usage instructions.

Update the release notes to announce the addition of the sxe2 network driver.

---
 doc/guides/nics/features/sxe2.ini      | 30 +++++++++++++++++++++++
 doc/guides/nics/index.rst              |  1 +
 doc/guides/nics/sxe2.rst               | 34 ++++++++++++++++++++++++++
 doc/guides/rel_notes/release_26_07.rst |  4 +++
 4 files changed, 69 insertions(+)
 create mode 100644 doc/guides/nics/features/sxe2.ini
 create mode 100644 doc/guides/nics/sxe2.rst
doc/guides/nics/features/sxe2.ini new file +30 -0
new file mode 100644
index 0000000000..2718a702d4
@@ -0,0 +1,30 @@
+;
+; Supported features of the 'sxe2' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+; A feature with "P" indicates only be supported when non-vector path
+; is selected.
+;
+[Features]
+Fast mbuf free       = P
+Free Tx mbuf on demand = Y
+Burst mode info      = Y
+Queue start/stop     = Y
+MTU update           = Y
+Buffer split on Rx   = P
+Scattered Rx         = Y
+CRC offload          = Y
+VLAN offload         = Y
+QinQ offload         = P
+L3 checksum offload  = Y
+L4 checksum offload  = Y
+Timestamp offload    = P
+Inner L3 checksum    = P
+Inner L4 checksum    = P
+Rx descriptor status = Y
+Tx descriptor status = Y
+FreeBSD              = Y
+Linux                = Y
+x86-32               = Y
+x86-64               = Y
doc/guides/nics/index.rst +1 -0
index cb818284fe..e20be478f8 100644
@@ -68,6 +68,7 @@ Network Interface Controller Drivers
     rnp
     sfc_efx
     softnic
+    sxe2
     tap
     thunderx
     txgbe
doc/guides/nics/sxe2.rst new file +34 -0
new file mode 100644
index 0000000000..7fcf9c085b
@@ -0,0 +1,34 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+
+SXE2 Poll Mode Driver
+======================
+
+The sxe2 PMD (**librte_net_sxe2**) provides poll mode driver support for
+10/25/50/100 Gbps Network Adapters.
+The embedded switch, Physical Functions (PF),
+and SR-IOV Virtual Functions (VF) are supported.
+
+Implementation details
+----------------------
+
+The sxe2 PMD is designed to operate alongside the sxe2 kernel network driver.
+For management and control operations, the PMD communicates with the kernel
+driver via ioctl interfaces. These commands are processed by the kernel
+driver and subsequently dispatched to the hardware firmware for execution.
+
+For security and robustness, the driver's data path is optimized to operate
+using virtual addresses (IOVA as VA mode). However, to ensure full
+compatibility in system environments where an IOMMU is absent or disabled,
+the driver also provides an explicit path to support physical addressing
+(IOVA as PA mode).
+
+The hardware is capable of handling the corresponding IOVA addresses (either
+VA or PA) directly, as provided by the DPDK memory subsystem. This ensures
+that DPDK applications can only access memory segments explicitly allocated
+to the current process, preventing unauthorized access to random physical
+memory.
+
+This capability allows the PMD to coexist with kernel network interfaces
+which remain functional, although they stop receiving unicast packets as
+long as they share the same MAC address.
doc/guides/rel_notes/release_26_07.rst +4 -0
index f012d47a4b..fa0f0f5cca 100644
@@ -64,6 +64,10 @@ New Features
   * ``--auto-probing`` enables the initial bus probing, which is the current default behavior.
 
 
+* **Added Linkdata sxe2 ethernet driver.**
+
+  Added network driver for the Linkdata Network Adapters.
+
 Removed Items
 -------------
 
Signature · 1 line
2.47.3
#131 lore raw

PATCH v13 3/10 common/sxe2: add sxe2 basic structures

In reply to [email protected]

From: Jie Liu <[email protected]>

This patch adds the base infrastructure for the sxe2 common library. It includes the mandatory OS abstraction layer (OSAL), common structure definitions, error codes, and the logging system implementation.

Specifically, this commit:
- Implements the logging stream management using RTE_LOG_LINE.
- Defines device-specific error codes and status registers.
- Adds the initial meson build configuration for the common library.

---
 drivers/common/sxe2/sxe2_common_log.h   |  84 +++
 drivers/common/sxe2/sxe2_errno.h        | 113 ++++
 drivers/common/sxe2/sxe2_host_regs.h    | 707 ++++++++++++++++++++++++
 drivers/common/sxe2/sxe2_internal_ver.h |  33 ++
 drivers/common/sxe2/sxe2_osal.h         | 586 ++++++++++++++++++++
 drivers/common/sxe2/sxe2_type.h         |  60 ++
 6 files changed, 1583 insertions(+)
 create mode 100644 drivers/common/sxe2/sxe2_common_log.h
 create mode 100644 drivers/common/sxe2/sxe2_errno.h
 create mode 100644 drivers/common/sxe2/sxe2_host_regs.h
 create mode 100644 drivers/common/sxe2/sxe2_internal_ver.h
 create mode 100644 drivers/common/sxe2/sxe2_osal.h
 create mode 100644 drivers/common/sxe2/sxe2_type.h
drivers/common/sxe2/sxe2_common_log.h new file +84 -0
new file mode 100644
index 0000000000..a7d2157610
@@ -0,0 +1,84 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+ */
+
+#ifndef __SXE2_COMMON_LOG_H__
+#define __SXE2_COMMON_LOG_H__
+
+#include "sxe2_type.h"
+
+extern s32 sxe2_common_log;
+extern s32 sxe2_log_init;
+extern s32 sxe2_log_driver;
+extern s32 sxe2_log_rx;
+extern s32 sxe2_log_tx;
+extern s32 sxe2_log_hw;
+
+#define RTE_LOGTYPE_SXE2_COM  sxe2_common_log
+#define RTE_LOGTYPE_SXE2_INIT sxe2_log_init
+#define RTE_LOGTYPE_SXE2_DRV  sxe2_log_driver
+#define RTE_LOGTYPE_SXE2_RX   sxe2_log_rx
+#define RTE_LOGTYPE_SXE2_TX   sxe2_log_tx
+#define RTE_LOGTYPE_SXE2_HW   sxe2_log_hw
+
+#define SXE2_PMD_LOG(level, log_type, ...) \
+	RTE_LOG_LINE_PREFIX(level, log_type, "%s(): ", \
+		__func__, __VA_ARGS__)
+
+#define SXE2_PMD_DRV_LOG(level, log_type, adapter, ...) \
+	RTE_LOG_LINE_PREFIX(level, log_type, "%s(): port:%u ", \
+		__func__ RTE_LOG_COMMA \
+		adapter->dev_port_id, __VA_ARGS__)
+
+#define PMD_LOG_DEBUG(logtype, fmt, ...) \
+	SXE2_PMD_LOG(DEBUG, SXE2_##logtype, fmt, ##__VA_ARGS__)
+
+#define PMD_LOG_INFO(logtype, fmt, ...) \
+	SXE2_PMD_LOG(INFO, SXE2_##logtype, fmt, ##__VA_ARGS__)
+
+#define PMD_LOG_NOTICE(logtype, fmt, ...) \
+	SXE2_PMD_LOG(NOTICE, SXE2_##logtype, fmt, ##__VA_ARGS__)
+
+#define PMD_LOG_WARN(logtype, fmt, ...) \
+	SXE2_PMD_LOG(WARNING, SXE2_##logtype, fmt, ##__VA_ARGS__)
+
+#define PMD_LOG_ERR(logtype, fmt, ...) \
+	SXE2_PMD_LOG(ERR, SXE2_##logtype, fmt, ##__VA_ARGS__)
+
+#define PMD_LOG_CRIT(logtype, fmt, ...) \
+	SXE2_PMD_LOG(CRIT, SXE2_##logtype, fmt, ##__VA_ARGS__)
+
+#define PMD_LOG_ALERT(logtype, fmt, ...) \
+	SXE2_PMD_LOG(ALERT, SXE2_##logtype, fmt, ##__VA_ARGS__)
+
+#define PMD_LOG_EMERG(logtype, fmt, ...) \
+	SXE2_PMD_LOG(EMERG, SXE2_##logtype, fmt, ##__VA_ARGS__)
+
+#define PMD_DEV_LOG_DEBUG(adapter, logtype, fmt, ...) \
+	SXE2_PMD_DRV_LOG(DEBUG, SXE2_##logtype, adapter, fmt, ##__VA_ARGS__)
+
+#define PMD_DEV_LOG_INFO(adapter, logtype, fmt, ...) \
+	SXE2_PMD_DRV_LOG(INFO, SXE2_##logtype, adapter, fmt, ##__VA_ARGS__)
+
+#define PMD_DEV_LOG_NOTICE(adapter, logtype, fmt, ...) \
+	SXE2_PMD_DRV_LOG(NOTICE, SXE2_##logtype, adapter, fmt, ##__VA_ARGS__)
+
+#define PMD_DEV_LOG_WARN(adapter, logtype, fmt, ...) \
+	SXE2_PMD_DRV_LOG(WARNING, SXE2_##logtype, adapter, fmt, ##__VA_ARGS__)
+
+#define PMD_DEV_LOG_ERR(adapter, logtype, fmt, ...) \
+	SXE2_PMD_DRV_LOG(ERR, SXE2_##logtype, adapter, fmt, ##__VA_ARGS__)
+
+#define PMD_DEV_LOG_CRIT(adapter, logtype, fmt, ...) \
+	SXE2_PMD_DRV_LOG(CRIT, SXE2_##logtype, adapter, fmt, ##__VA_ARGS__)
+
+#define PMD_DEV_LOG_ALERT(adapter, logtype, fmt, ...) \
+	SXE2_PMD_DRV_LOG(ALERT, SXE2_##logtype, adapter, fmt, ##__VA_ARGS__)
+
+#define PMD_DEV_LOG_EMERG(adapter, logtype, fmt, ...) \
+	SXE2_PMD_DRV_LOG(EMERG, SXE2_##logtype, adapter, fmt, ##__VA_ARGS__)
+
+#define PMD_INIT_FUNC_TRACE() PMD_LOG_DEBUG(INIT, " >>")
+
+#endif /* __SXE2_COMMON_LOG_H__ */
+
drivers/common/sxe2/sxe2_errno.h new file +113 -0

113 lines not on this page · raw message

drivers/common/sxe2/sxe2_host_regs.h new file +707 -0

707 lines not on this page · raw message

drivers/common/sxe2/sxe2_internal_ver.h new file +33 -0
new file mode 100644
index 0000000000..92f49e7a20
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+ */
+
+#ifndef __SXE2_INTERNAL_VER_H__
+#define __SXE2_INTERNAL_VER_H__
+
+#define SXE2_VER_MAJOR_OFFSET (16)
+#define SXE2_MK_VER(major, minor) \
+	(major << SXE2_VER_MAJOR_OFFSET | minor)
+#define SXE2_MK_VER_MAJOR(ver) (((ver) >> SXE2_VER_MAJOR_OFFSET) & 0xff)
+#define SXE2_MK_VER_MINOR(ver) ((ver) & 0xff)
+
+#define SXE2_ITR_VER_MAJOR_V100    1
+#define SXE2_ITR_VER_MAJOR_V200    2
+
+#define SXE2_ITR_VER_MAJOR      1
+#define SXE2_ITR_VER_MINOR      1
+#define SXE2_ITR_VER SXE2_MK_VER(SXE2_ITR_VER_MAJOR, SXE2_ITR_VER_MINOR)
+
+#define SXE2_CTRL_VER_IS_V100(ver)  (SXE2_MK_VER_MAJOR(ver) == SXE2_ITR_VER_MAJOR_V100)
+#define SXE2_CTRL_VER_IS_V200(ver)  (SXE2_MK_VER_MAJOR(ver) == SXE2_ITR_VER_MAJOR_V200)
+
+#define SXE2LIB_ITR_VER_MAJOR      1
+#define SXE2LIB_ITR_VER_MINOR      1
+#define SXE2LIB_ITR_VER     SXE2_MK_VER(SXE2LIB_ITR_VER_MAJOR, SXE2LIB_ITR_VER_MINOR)
+
+#define SXE2_DRV_CLI_VER_MAJOR      1
+#define SXE2_DRV_CLI_VER_MINOR      1
+#define SXE2_DRV_CLI_VER \
+	SXE2_MK_VER(SXE2_DRV_CLI_VER_MAJOR, SXE2_DRV_CLI_VER_MINOR)
+
+#endif /* __SXE2_INTERNAL_VER_H__ */
drivers/common/sxe2/sxe2_osal.h new file +586 -0

586 lines not on this page · raw message

drivers/common/sxe2/sxe2_type.h new file +60 -0

60 lines not on this page · raw message

Signature · 1 line
2.47.3
#132 lore raw

PATCH v13 4/10 drivers: add base driver skeleton

In reply to [email protected]

From: Jie Liu <[email protected]>

Initialize the sxe2 PMD skeleton by implementing the PCI probe and remove functions. This includes the setup and cleanup of a character device used for control path communication between the user space and the hardware.

The character device provides an interface for ioctl-based management operations, supporting device-specific configuration.

---
 drivers/common/sxe2/meson.build            |  15 +
 drivers/common/sxe2/sxe2_common.c          | 636 +++++++++++++++++++++
 drivers/common/sxe2/sxe2_common.h          |  86 +++
 drivers/common/sxe2/sxe2_ioctl_chnl.c      | 161 ++++++
 drivers/common/sxe2/sxe2_ioctl_chnl.h      | 141 +++++
 drivers/common/sxe2/sxe2_ioctl_chnl_func.h |  45 ++
 drivers/meson.build                        |   1 +
 7 files changed, 1085 insertions(+)
 create mode 100644 drivers/common/sxe2/meson.build
 create mode 100644 drivers/common/sxe2/sxe2_common.c
 create mode 100644 drivers/common/sxe2/sxe2_common.h
 create mode 100644 drivers/common/sxe2/sxe2_ioctl_chnl.c
 create mode 100644 drivers/common/sxe2/sxe2_ioctl_chnl.h
 create mode 100644 drivers/common/sxe2/sxe2_ioctl_chnl_func.h
drivers/common/sxe2/meson.build new file +15 -0
new file mode 100644
index 0000000000..f1cc1205a0
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2023 Corigine, Inc.
+
+if is_windows
+        build = false
+        reason = 'only supported on Linux'
+        subdir_done()
+endif
+
+deps += ['bus_pci', 'net', 'eal', 'ethdev']
+
+sources = files(
+        'sxe2_common.c',
+        'sxe2_ioctl_chnl.c',
+)
drivers/common/sxe2/sxe2_common.c new file +636 -0

636 lines not on this page · raw message

drivers/common/sxe2/sxe2_common.h new file +86 -0

86 lines not on this page · raw message

drivers/common/sxe2/sxe2_ioctl_chnl.c new file +161 -0

161 lines not on this page · raw message

drivers/common/sxe2/sxe2_ioctl_chnl.h new file +141 -0

141 lines not on this page · raw message

drivers/common/sxe2/sxe2_ioctl_chnl_func.h new file +45 -0

45 lines not on this page · raw message

drivers/meson.build +1 -0
index 6ae102e943..d4ae512bae 100644
@@ -12,6 +12,7 @@ subdirs = [
         'common/qat',     # depends on bus.
         'common/sfc_efx', # depends on bus.
         'common/zsda',    # depends on bus.
+        'common/sxe2',    # depends on bus.
         'mempool',        # depends on common and bus.
         'dma',            # depends on common and bus.
         'net',            # depends on common, bus, mempool
Signature · 1 line
2.47.3
#133 lore raw

PATCH v13 5/10 drivers: add base driver probe skeleton

In reply to [email protected]

From: Jie Liu <[email protected]>

Initialize the eth_dev_ops for the sxe2 PMD. This includes the implementation of mandatory ethdev operations such as dev_configure, dev_start, dev_stop, and dev_infos_get.

Set up the basic infrastructure for device initialization to allow the driver to be recognized as a valid ethernet device within the DPDK framework.

---
 drivers/common/sxe2/sxe2_common.h          |   2 +-
 drivers/common/sxe2/sxe2_ioctl_chnl.c      |  27 +
 drivers/common/sxe2/sxe2_ioctl_chnl_func.h |   9 +
 drivers/net/meson.build                    |   1 +
 drivers/net/sxe2/meson.build               |  21 +
 drivers/net/sxe2/sxe2_cmd_chnl.c           | 319 +++++++++++
 drivers/net/sxe2/sxe2_cmd_chnl.h           |  33 ++
 drivers/net/sxe2/sxe2_drv_cmd.h            | 398 ++++++++++++++
 drivers/net/sxe2/sxe2_ethdev.c             | 611 +++++++++++++++++++++
 drivers/net/sxe2/sxe2_ethdev.h             | 295 ++++++++++
 drivers/net/sxe2/sxe2_irq.h                |  49 ++
 drivers/net/sxe2/sxe2_queue.c              |  39 ++
 drivers/net/sxe2/sxe2_queue.h              | 191 +++++++
 drivers/net/sxe2/sxe2_txrx_common.h        | 541 ++++++++++++++++++
 drivers/net/sxe2/sxe2_txrx_poll.h          |  16 +
 drivers/net/sxe2/sxe2_vsi.c                | 212 +++++++
 drivers/net/sxe2/sxe2_vsi.h                | 205 +++++++
 17 files changed, 2968 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/sxe2/meson.build
 create mode 100644 drivers/net/sxe2/sxe2_cmd_chnl.c
 create mode 100644 drivers/net/sxe2/sxe2_cmd_chnl.h
 create mode 100644 drivers/net/sxe2/sxe2_drv_cmd.h
 create mode 100644 drivers/net/sxe2/sxe2_ethdev.c
 create mode 100644 drivers/net/sxe2/sxe2_ethdev.h
 create mode 100644 drivers/net/sxe2/sxe2_irq.h
 create mode 100644 drivers/net/sxe2/sxe2_queue.c
 create mode 100644 drivers/net/sxe2/sxe2_queue.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_common.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_poll.h
 create mode 100644 drivers/net/sxe2/sxe2_vsi.c
 create mode 100644 drivers/net/sxe2/sxe2_vsi.h
drivers/common/sxe2/sxe2_common.h +1 -1
index d02d281a70..090b643548 100644
@@ -57,7 +57,7 @@ typedef s32 (sxe2_class_driver_remove_t)(struct sxe2_common_device *scdev);
 struct sxe2_class_driver {
 	TAILQ_ENTRY(sxe2_class_driver) next;
 	enum sxe2_class_type drv_class;
-	const s8 *name;
+	const char *name;
 	sxe2_class_driver_probe_t *probe;
 	sxe2_class_driver_remove_t *remove;
 	const struct rte_pci_id *id_table;
drivers/common/sxe2/sxe2_ioctl_chnl.c +27 -0
index 0d300e0f81..4b041765de 100644
@@ -159,3 +159,30 @@ sxe2_drv_dev_handshark(struct sxe2_common_device *cdev)
 l_end:
 	return ret;
 }
+
+RTE_EXPORT_INTERNAL_SYMBOL(sxe2_drv_dev_munmap)
+s32
+sxe2_drv_dev_munmap(struct sxe2_common_device *cdev, void *virt, u64 len)
+{
+	s32 ret = SXE2_SUCCESS;
+
+	if (cdev->config.kernel_reset) {
+		ret = SXE2_ERR_PERM;
+		PMD_LOG_WARN(COM, "kernel reset, need restart app.");
+		goto l_end;
+	}
+
+	PMD_LOG_DEBUG(COM, "Munmap virt=%p, len=0x%zx",
+		virt, len);
+
+	ret = munmap(virt, len);
+	if (ret < 0) {
+		PMD_LOG_ERR(COM, "Failed to munmap, virt=%p, len=0x%zx, err:%s",
+			virt, len, strerror(errno));
+		ret = SXE2_ERR_IO;
+		goto l_end;
+	}
+
+l_end:
+	return ret;
+}
drivers/common/sxe2/sxe2_ioctl_chnl_func.h +9 -0
index 0c3cb9caea..376c5e3ac7 100644
@@ -38,6 +38,15 @@ __rte_internal
 s32
 sxe2_drv_dev_handshark(struct sxe2_common_device *cdev);
 
+__rte_internal
+void
+*sxe2_drv_dev_mmap(struct sxe2_common_device *cdev, u8 bar_idx,
+		u64 len, u64 offset);
+
+__rte_internal
+s32
+sxe2_drv_dev_munmap(struct sxe2_common_device *cdev, void *virt, u64 len);
+
 #ifdef __cplusplus
 }
 #endif
drivers/net/meson.build +1 -0
index c7dae4ad27..4e8ccb945f 100644
@@ -58,6 +58,7 @@ drivers = [
         'rnp',
         'sfc',
         'softnic',
+        'sxe2',
         'tap',
         'thunderx',
         'txgbe',
drivers/net/sxe2/meson.build new file +21 -0
new file mode 100644
index 0000000000..6c9a86423a
@@ -0,0 +1,21 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+
+if is_windows
+        build = false
+        reason = 'only supported on Linux'
+        subdir_done()
+endif
+
+cflags += ['-g']
+
+deps += ['common_sxe2', 'hash','cryptodev','security']
+
+sources += files(
+        'sxe2_ethdev.c',
+        'sxe2_cmd_chnl.c',
+        'sxe2_vsi.c',
+        'sxe2_queue.c',
+)
+
+allow_internal_get_api = true
drivers/net/sxe2/sxe2_cmd_chnl.c new file +319 -0

319 lines not on this page · raw message

drivers/net/sxe2/sxe2_cmd_chnl.h new file +33 -0
new file mode 100644
index 0000000000..200fe0be00
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+ */
+
+#ifndef __SXE2_CMD_CHNL_H__
+#define __SXE2_CMD_CHNL_H__
+
+#include "sxe2_ethdev.h"
+#include "sxe2_drv_cmd.h"
+#include "sxe2_ioctl_chnl_func.h"
+
+s32 sxe2_drv_dev_caps_get(struct sxe2_adapter *adapter,
+		struct sxe2_drv_dev_caps_resp *dev_caps);
+
+s32 sxe2_drv_dev_info_get(struct sxe2_adapter *adapter,
+		struct sxe2_drv_dev_info_resp *dev_info_resp);
+
+s32 sxe2_drv_dev_fw_info_get(struct sxe2_adapter *adapter,
+		struct sxe2_drv_dev_fw_info_resp *dev_fw_info_resp);
+
+s32 sxe2_drv_vsi_add(struct sxe2_adapter *adapter, struct sxe2_vsi *vsi);
+
+s32 sxe2_drv_vsi_del(struct sxe2_adapter *adapter, struct sxe2_vsi *vsi);
+
+s32 sxe2_drv_rxq_switch(struct sxe2_adapter *adapter, struct sxe2_rx_queue *rxq, bool enable);
+
+s32 sxe2_drv_txq_switch(struct sxe2_adapter *adapter, struct sxe2_tx_queue *txq, bool enable);
+
+s32 sxe2_drv_rxq_ctxt_cfg(struct sxe2_adapter *adapter, struct sxe2_rx_queue *rxq, u16 rxq_cnt);
+
+s32 sxe2_drv_txq_ctxt_cfg(struct sxe2_adapter *adapter, struct sxe2_tx_queue *txq, u16 txq_cnt);
+
+#endif
drivers/net/sxe2/sxe2_drv_cmd.h new file +398 -0

398 lines not on this page · raw message

drivers/net/sxe2/sxe2_ethdev.c new file +611 -0

611 lines not on this page · raw message

drivers/net/sxe2/sxe2_ethdev.h new file +295 -0

295 lines not on this page · raw message

drivers/net/sxe2/sxe2_irq.h new file +49 -0

49 lines not on this page · raw message

drivers/net/sxe2/sxe2_queue.c new file +39 -0
new file mode 100644
index 0000000000..98343679f6
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+ */
+
+#include "sxe2_ethdev.h"
+#include "sxe2_queue.h"
+#include "sxe2_common_log.h"
+#include "sxe2_errno.h"
+
+void sxe2_sw_queue_ctx_hw_cap_set(struct sxe2_adapter *adapter,
+		struct sxe2_drv_queue_caps *q_caps)
+{
+	adapter->q_ctxt.qp_cnt_assign = q_caps->queues_cnt;
+	adapter->q_ctxt.base_idx_in_pf = q_caps->base_idx_in_pf;
+}
+
+s32 sxe2_queues_init(struct rte_eth_dev *dev)
+{
+	s32 ret = SXE2_SUCCESS;
+	u16 buf_size;
+	u16 frame_size;
+	struct sxe2_rx_queue *rxq;
+	u16 nb_rxq;
+
+	frame_size = dev->data->mtu + SXE2_ETH_OVERHEAD;
+	for (nb_rxq = 0; nb_rxq < dev->data->nb_rx_queues; nb_rxq++) {
+		rxq = dev->data->rx_queues[nb_rxq];
+		if (!rxq)
+			continue;
+
+		buf_size = rte_pktmbuf_data_room_size(rxq->mb_pool) - RTE_PKTMBUF_HEADROOM;
+		rxq->rx_buf_len = RTE_ALIGN_FLOOR(buf_size, (1 << SXE2_RXQ_CTX_DBUFF_SHIFT));
+		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;
+	}
+
+	return ret;
+}
drivers/net/sxe2/sxe2_queue.h new file +191 -0

191 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx_common.h new file +541 -0

541 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx_poll.h new file +16 -0
new file mode 100644
index 0000000000..4924b0f41f
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+ */
+
+#ifndef SXE2_TXRX_POLL_H
+#define SXE2_TXRX_POLL_H
+
+#include "sxe2_queue.h"
+
+u16 sxe2_tx_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, u16 nb_pkts);
+
+u16 sxe2_rx_pkts_scattered(void *rx_queue, struct rte_mbuf **rx_pkts, u16 nb_pkts);
+
+u16 sxe2_rx_pkts_scattered_split(void *rx_queue, struct rte_mbuf **rx_pkts, u16 nb_pkts);
+
+#endif
drivers/net/sxe2/sxe2_vsi.c new file +212 -0

212 lines not on this page · raw message

drivers/net/sxe2/sxe2_vsi.h new file +205 -0

205 lines not on this page · raw message

Signature · 1 line
2.47.3
#134 lore raw

PATCH v13 6/10 drivers: support PCI BAR mapping

In reply to [email protected]

From: Jie Liu <[email protected]>

Implement PCI BAR (Base Address Register) mapping and unmapping logic to enable MMIO (Memory Mapped I/O) access to hardware registers.

The driver retrieves the BAR0 virtual address from the PCI resource during the probing phase. This mapping is used for subsequent register-level operations. Proper cleanup is implemented in the device close path.

---
 drivers/common/sxe2/sxe2_ioctl_chnl.c |  40 +++-
 drivers/net/sxe2/sxe2_ethdev.c        | 307 ++++++++++++++++++++++++++
 drivers/net/sxe2/sxe2_ethdev.h        |  18 ++
 3 files changed, 362 insertions(+), 3 deletions(-)
drivers/common/sxe2/sxe2_ioctl_chnl.c +37 -3
index 4b041765de..80fccc6a11 100644
@@ -160,6 +160,40 @@ sxe2_drv_dev_handshark(struct sxe2_common_device *cdev)
 	return ret;
 }
 
+RTE_EXPORT_INTERNAL_SYMBOL(sxe2_drv_dev_mmap)
+void
+*sxe2_drv_dev_mmap(struct sxe2_common_device *cdev, u8 bar_idx, u64 len, u64 offset)
+{
+	s32 cmd_fd = 0;
+	void *virt = NULL;
+
+	if (cdev->config.kernel_reset) {
+		PMD_LOG_WARN(COM, "kernel reset, need restart app.");
+		goto l_err;
+	}
+
+	cmd_fd = SXE2_CDEV_TO_CMD_FD(cdev);
+	if (cmd_fd < 0) {
+		PMD_LOG_ERR(COM, "Failed to exec cmd, fd=%d", cmd_fd);
+		goto l_err;
+	}
+
+	PMD_LOG_DEBUG(COM, "fd=%d, bar idx=%d, len=0x%zx, src=0x%"PRIx64", offset=0x%"PRIx64"",
+		bar_idx, cmd_fd, 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));
+	if (virt == MAP_FAILED) {
+		PMD_LOG_ERR(COM, "Failed mmap, cmd_fd=%d, len=0x%zx, offset=0x%"PRIx64", err:%s",
+			cmd_fd, len, offset, strerror(errno));
+		goto l_err;
+	}
+
+	return virt;
+l_err:
+	return NULL;
+}
+
 RTE_EXPORT_INTERNAL_SYMBOL(sxe2_drv_dev_munmap)
 s32
 sxe2_drv_dev_munmap(struct sxe2_common_device *cdev, void *virt, u64 len)
@@ -167,8 +201,8 @@ sxe2_drv_dev_munmap(struct sxe2_common_device *cdev, void *virt, u64 len)
 	s32 ret = SXE2_SUCCESS;
 
 	if (cdev->config.kernel_reset) {
-		ret = SXE2_ERR_PERM;
-		PMD_LOG_WARN(COM, "kernel reset, need restart app.");
+		ret = -EPERM;
+		PMD_LOG_WARN(COM, "kernel reseted, need restart app.");
 		goto l_end;
 	}
 
@@ -179,7 +213,7 @@ sxe2_drv_dev_munmap(struct sxe2_common_device *cdev, void *virt, u64 len)
 	if (ret < 0) {
 		PMD_LOG_ERR(COM, "Failed to munmap, virt=%p, len=0x%zx, err:%s",
 			virt, len, strerror(errno));
-		ret = SXE2_ERR_IO;
+		ret = -EIO;
 		goto l_end;
 	}
 
drivers/net/sxe2/sxe2_ethdev.c +307 -0

349 lines not on this page · raw message

drivers/net/sxe2/sxe2_ethdev.h +18 -0
index 412f5d2b14..698e2ee4a2 100644
@@ -292,4 +292,22 @@ struct sxe2_adapter {
 #define SXE2_DEV_PRIVATE_TO_ADAPTER(dev) \
 	((struct sxe2_adapter *)(dev)->data->dev_private)
 
+#define SXE2_DEV_TO_PCI(eth_dev) \
+		RTE_DEV_TO_PCI((eth_dev)->device)
+
+struct sxe2_pci_map_bar_info *sxe2_dev_get_bar_info(struct sxe2_adapter *adapter,
+		enum sxe2_pci_map_resource res_type);
+
+s32 sxe2_dev_pci_seg_map(struct sxe2_adapter *adapter,
+		enum sxe2_pci_map_resource res_type, u64 org_len, u64 org_offset);
+
+s32 sxe2_dev_pci_res_seg_map(struct sxe2_adapter *adapter, u32 res_type,
+		u32 item_cnt, u32 item_base);
+
+void sxe2_dev_pci_seg_unmap(struct sxe2_adapter *adapter, u32 res_type);
+
+s32 sxe2_dev_pci_map_init(struct rte_eth_dev *dev);
+
+void sxe2_dev_pci_map_uinit(struct rte_eth_dev *dev);
+
 #endif
Signature · 1 line
2.47.3
#135 lore raw

PATCH v13 7/10 common/sxe2: add ioctl interface for DMA map and unmap

In reply to [email protected]

From: Jie Liu <[email protected]>

Implement DMA mapping and unmapping functionality using ioctl calls. This allows the driver to configure the hardware's IOMMU/DMA tables, ensuring the device can safely access memory buffers allocated by the userspace.

The mapping is established during device initialization or queue setup and is revoked during device closure to prevent memory leaks and ensure hardware security.

---
 drivers/common/sxe2/sxe2_common.c          |  50 +++++++++-
 drivers/common/sxe2/sxe2_ioctl_chnl.c      | 106 ++++++++++++++++++++-
 drivers/common/sxe2/sxe2_ioctl_chnl_func.h |   9 ++
 3 files changed, 163 insertions(+), 2 deletions(-)
drivers/common/sxe2/sxe2_common.c +49 -1
index 62bdc93b5c..63873afe4a 100644
@@ -443,7 +443,7 @@ static s32 sxe2_common_pci_remove(struct rte_pci_device *pci_dev)
 	cdev = sxe2_rtedev_to_cdev(&pci_dev->device);
 	if (cdev == NULL) {
 		ret = -ENODEV;
-		PMD_LOG_ERR(COM, "Fail to get remove device.");
+		PMD_LOG_ERR(COM, "Fail to get device when remove.");
 		goto l_end;
 	}
 
@@ -467,12 +467,60 @@ static s32 sxe2_common_pci_remove(struct rte_pci_device *pci_dev)
 	return ret;
 }
 
+static s32 sxe2_common_pci_dma_map(struct rte_pci_device *pci_dev,
+		void *addr,	u64 iova, size_t len)
+{
+	struct sxe2_common_device *cdev;
+	s32 ret = SXE2_ERROR;
+
+	cdev = sxe2_rtedev_to_cdev(&pci_dev->device);
+	if (cdev == NULL) {
+		ret = -ENODEV;
+		PMD_LOG_ERR(COM, "Fail to get device when dma map.");
+		goto l_end;
+	}
+
+	ret = sxe2_drv_dev_dma_map(cdev, (u64)(uintptr_t)addr, iova, len);
+	if (ret) {
+		PMD_LOG_ERR(COM, "Fail to map dma map, ret=%d", ret);
+		goto l_end;
+	}
+
+l_end:
+	return ret;
+}
+
+static s32 sxe2_common_pci_dma_unmap(struct rte_pci_device *pci_dev,
+		void *addr __rte_unused, u64 iova, size_t len __rte_unused)
+{
+	struct sxe2_common_device *cdev;
+	s32 ret = SXE2_ERROR;
+
+	cdev = sxe2_rtedev_to_cdev(&pci_dev->device);
+	if (cdev == NULL) {
+		ret = -ENODEV;
+		PMD_LOG_ERR(COM, "Fail to get device when dma unmap.");
+		goto l_end;
+	}
+
+	ret = sxe2_drv_dev_dma_unmap(cdev, iova);
+	if (ret) {
+		PMD_LOG_ERR(COM, "Fail to unmap dma map, ret=%d", ret);
+		goto l_end;
+	}
+
+l_end:
+	return ret;
+}
+
 static struct rte_pci_driver sxe2_common_pci_driver = {
 	.driver = {
 		   .name = SXE2_COMMON_PCI_DRIVER_NAME,
 	},
 	.probe = sxe2_common_pci_probe,
 	.remove = sxe2_common_pci_remove,
+	.dma_map = sxe2_common_pci_dma_map,
+	.dma_unmap = sxe2_common_pci_dma_unmap,
 };
 
 static u32 sxe2_common_pci_id_table_size_get(const struct rte_pci_id *id_table)
drivers/common/sxe2/sxe2_ioctl_chnl.c +105 -1

115 lines not on this page · raw message

drivers/common/sxe2/sxe2_ioctl_chnl_func.h +9 -0
index 376c5e3ac7..e8f983e40e 100644
@@ -47,6 +47,15 @@ __rte_internal
 s32
 sxe2_drv_dev_munmap(struct sxe2_common_device *cdev, void *virt, u64 len);
 
+__rte_internal
+s32
+sxe2_drv_dev_dma_map(struct sxe2_common_device *cdev, u64 vaddr,
+		u64 iova, u64 size);
+
+__rte_internal
+s32
+sxe2_drv_dev_dma_unmap(struct sxe2_common_device *cdev, u64 iova);
+
 #ifdef __cplusplus
 }
 #endif
Signature · 1 line
2.47.3
#136 lore raw

PATCH v13 8/10 net/sxe2: support queue setup and control

In reply to [email protected]

From: Jie Liu <[email protected]>

Add support for Rx and Tx queue setup, release, and management. Implement eth_dev_ops callbacks for rx_queue_setup, tx_queue_setup, rx_queue_release, and tx_queue_release.

This includes:
- Allocating memory for hardware ring descriptors.
- Initializing software ring structures and hardware head/tail pointers.
- Implementing proper resource cleanup logic to prevent memory leaks during queue reconfiguration or device close.

---
 drivers/net/sxe2/meson.build    |   2 +
 drivers/net/sxe2/sxe2_drv_cmd.h |   9 -
 drivers/net/sxe2/sxe2_ethdev.c  |  66 +++-
 drivers/net/sxe2/sxe2_ethdev.h  |   3 +
 drivers/net/sxe2/sxe2_rx.c      | 579 ++++++++++++++++++++++++++++++++
 drivers/net/sxe2/sxe2_rx.h      |  34 ++
 drivers/net/sxe2/sxe2_tx.c      | 447 ++++++++++++++++++++++++
 drivers/net/sxe2/sxe2_tx.h      |  32 ++
 8 files changed, 1145 insertions(+), 27 deletions(-)
 create mode 100644 drivers/net/sxe2/sxe2_rx.c
 create mode 100644 drivers/net/sxe2/sxe2_rx.h
 create mode 100644 drivers/net/sxe2/sxe2_tx.c
 create mode 100644 drivers/net/sxe2/sxe2_tx.h
drivers/net/sxe2/meson.build +2 -0
index 6c9a86423a..8638244d80 100644
@@ -16,6 +16,8 @@ sources += files(
         'sxe2_cmd_chnl.c',
         'sxe2_vsi.c',
         'sxe2_queue.c',
+        'sxe2_tx.c',
+        'sxe2_rx.c',
 )
 
 allow_internal_get_api = true
drivers/net/sxe2/sxe2_drv_cmd.h +0 -9
index 4094442077..f236e30c40 100644
@@ -5,17 +5,8 @@
 #ifndef __SXE2_DRV_CMD_H__
 #define __SXE2_DRV_CMD_H__
 
-#ifdef SXE2_DPDK_DRIVER
 #include "sxe2_type.h"
 #define SXE2_DPDK_RESOURCE_INSUFFICIENT
-#endif
-
-#ifdef SXE2_LINUX_DRIVER
-#ifdef __KERNEL__
-#include <linux/types.h>
-#include <linux/if_ether.h>
-#endif
-#endif
 
 #define SXE2_DRV_CMD_MODULE_S        (16)
 #define SXE2_MK_DRV_CMD(module, cmd) (((module) << SXE2_DRV_CMD_MODULE_S) | ((cmd) & 0xFFFF))
drivers/net/sxe2/sxe2_ethdev.c +48 -18

96 lines not on this page · raw message

drivers/net/sxe2/sxe2_ethdev.h +3 -0
index 698e2ee4a2..4ef7854479 100644
@@ -295,6 +295,9 @@ struct sxe2_adapter {
 #define SXE2_DEV_TO_PCI(eth_dev) \
 		RTE_DEV_TO_PCI((eth_dev)->device)
 
+void __iomem *sxe2_pci_map_addr_get(struct sxe2_adapter *adapter,
+		enum sxe2_pci_map_resource res_type, u16 idx_in_func);
+
 struct sxe2_pci_map_bar_info *sxe2_dev_get_bar_info(struct sxe2_adapter *adapter,
 		enum sxe2_pci_map_resource res_type);
 
drivers/net/sxe2/sxe2_rx.c new file +579 -0

579 lines not on this page · raw message

drivers/net/sxe2/sxe2_rx.h new file +34 -0
new file mode 100644
index 0000000000..7c6239b387
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+ */
+
+#ifndef __SXE2_RX_H__
+#define __SXE2_RX_H__
+
+#include "sxe2_queue.h"
+
+s32 __rte_cold sxe2_rx_queue_setup(struct rte_eth_dev *dev,
+				u16 queue_idx, u16 nb_desc, u32 socket_id,
+				const struct rte_eth_rxconf *rx_conf,
+				struct rte_mempool *mp);
+
+s32 __rte_cold sxe2_rx_queue_stop(struct rte_eth_dev *dev, u16 rx_queue_id);
+
+void __rte_cold sxe2_rx_queue_mbufs_release(struct sxe2_rx_queue *rxq);
+
+void __rte_cold sxe2_rx_queue_release(struct rte_eth_dev *dev, u16 queue_idx);
+
+void __rte_cold sxe2_all_rxqs_release(struct rte_eth_dev *dev);
+
+void __rte_cold sxe2_rx_queue_info_get(struct rte_eth_dev *dev, u16 queue_id,
+		struct rte_eth_rxq_info *qinfo);
+
+s32 __rte_cold sxe2_rx_queue_start(struct rte_eth_dev *dev, u16 rx_queue_id);
+
+s32 __rte_cold sxe2_rxqs_all_start(struct rte_eth_dev *dev);
+
+void __rte_cold sxe2_rxqs_all_stop(struct rte_eth_dev *dev);
+
+struct rte_mbuf *sxe2_mbuf_raw_alloc(struct rte_mempool *mp);
+
+#endif
drivers/net/sxe2/sxe2_tx.c new file +447 -0

447 lines not on this page · raw message

drivers/net/sxe2/sxe2_tx.h new file +32 -0
new file mode 100644
index 0000000000..58b668e337
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+ */
+
+#ifndef __SXE2_TX_H__
+#define __SXE2_TX_H__
+#include "sxe2_queue.h"
+
+void __rte_cold sxe2_tx_queue_reset(struct sxe2_tx_queue *txq);
+
+s32 __rte_cold sxe2_tx_queue_start(struct rte_eth_dev *dev, u16 queue_id);
+
+void sxe2_tx_queue_mbufs_release(struct sxe2_tx_queue *txq);
+
+s32 __rte_cold sxe2_tx_queue_stop(struct rte_eth_dev *dev, u16 queue_id);
+
+s32 __rte_cold sxe2_tx_queue_setup(struct rte_eth_dev *dev,
+		u16 queue_idx, u16 nb_desc, u32 socket_id,
+		const struct rte_eth_txconf *tx_conf);
+
+void __rte_cold sxe2_tx_queue_release(struct rte_eth_dev *dev, u16 queue_idx);
+
+void __rte_cold sxe2_all_txqs_release(struct rte_eth_dev *dev);
+
+void __rte_cold sxe2_tx_queue_info_get(struct rte_eth_dev *dev, u16 queue_id,
+		struct rte_eth_txq_info *qinfo);
+
+s32 __rte_cold sxe2_txqs_all_start(struct rte_eth_dev *dev);
+
+void __rte_cold sxe2_txqs_all_stop(struct rte_eth_dev *dev);
+
+#endif
Signature · 1 line
2.47.3
#137 lore raw

PATCH v13 9/10 drivers: add data path for Rx and Tx

In reply to [email protected]

From: Jie Liu <[email protected]>

Implement receive and transmit burst functions for sxe2 PMD. Add sxe2_recv_pkts and sxe2_xmit_pkts as the primary data path interfaces.

The implementation includes:
- Efficient descriptor fetching and mbuf allocation for Rx.
- Descriptor setup and checksum offload handling for Tx.
- Buffer recycling and hardware tail pointer updates.
- Performance-oriented loop unrolling and prefetching where applicable.

---
 drivers/common/sxe2/sxe2_common.c     |   1 +
 drivers/common/sxe2/sxe2_common_log.h |   1 -
 drivers/common/sxe2/sxe2_errno.h      |   3 -
 drivers/common/sxe2/sxe2_ioctl_chnl.c |   8 +-
 drivers/common/sxe2/sxe2_osal.h       |   2 -
 drivers/net/sxe2/meson.build          |   2 +
 drivers/net/sxe2/sxe2_ethdev.c        |  22 +-
 drivers/net/sxe2/sxe2_txrx.c          | 247 +++++++
 drivers/net/sxe2/sxe2_txrx.h          |  21 +
 drivers/net/sxe2/sxe2_txrx_poll.c     | 945 ++++++++++++++++++++++++++
 10 files changed, 1237 insertions(+), 15 deletions(-)
 create mode 100644 drivers/net/sxe2/sxe2_txrx.c
 create mode 100644 drivers/net/sxe2/sxe2_txrx.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_poll.c
drivers/common/sxe2/sxe2_common.c +1 -0
index 63873afe4a..bfb54eec49 100644
@@ -664,6 +664,7 @@ sxe2_common_init(void)
 		goto l_end;
 
 	pthread_mutex_init(&sxe2_common_devices_list_lock, NULL);
+
 	sxe2_common_pci_init();
 	sxe2_commoin_inited = true;
 
drivers/common/sxe2/sxe2_common_log.h +0 -1
index a7d2157610..cbb53263b5 100644
@@ -81,4 +81,3 @@ extern s32 sxe2_log_hw;
 #define PMD_INIT_FUNC_TRACE() PMD_LOG_DEBUG(INIT, " >>")
 
 #endif /* __SXE2_COMMON_LOG_H__ */
-
drivers/common/sxe2/sxe2_errno.h +0 -3
index 89a715eaef..1257319edf 100644
@@ -50,9 +50,6 @@ enum sxe2_status {
 	SXE2_ERR_NOLCK              = -ENOLCK,
 	SXE2_ERR_NOSYS              = -ENOSYS,
 	SXE2_ERR_NOTEMPTY           = -ENOTEMPTY,
-	SXE2_ERR_ILSEQ              = -EILSEQ,
-	SXE2_ERR_NODATA             = -ENODATA,
-	SXE2_ERR_CANCELED           = -ECANCELED,
 	SXE2_ERR_TIMEDOUT           = -ETIMEDOUT,
 
 	SXE2_ERROR                  = -150,
drivers/common/sxe2/sxe2_ioctl_chnl.c +4 -4
index 4dfc4fd0fa..b9224cf197 100644
@@ -178,13 +178,13 @@ void
 		goto l_err;
 	}
 
-	PMD_LOG_DEBUG(COM, "fd=%d, bar idx=%d, len=0x%zx, src=0x%"PRIx64", offset=0x%"PRIx64"",
+	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));
 
 	virt = mmap(NULL, len, PROT_READ | PROT_WRITE,
 		MAP_SHARED, cmd_fd, SXE2_COM_PCI_OFFSET_GEN(bar_idx, offset));
 	if (virt == MAP_FAILED) {
-		PMD_LOG_ERR(COM, "Failed mmap, cmd_fd=%d, len=0x%zx, offset=0x%"PRIx64", err:%s",
+		PMD_LOG_ERR(COM, "Failed mmap, cmd_fd=%d, len=%"PRIu64", offset=0x%"PRIx64", err:%s",
 			cmd_fd, len, offset, strerror(errno));
 		goto l_err;
 	}
@@ -206,12 +206,12 @@ sxe2_drv_dev_munmap(struct sxe2_common_device *cdev, void *virt, u64 len)
 		goto l_end;
 	}
 
-	PMD_LOG_DEBUG(COM, "Munmap virt=%p, len=0x%zx",
+	PMD_LOG_DEBUG(COM, "Munmap virt=%p, len=0x%"PRIx64"",
 		virt, len);
 
 	ret = munmap(virt, len);
 	if (ret < 0) {
-		PMD_LOG_ERR(COM, "Failed to munmap, virt=%p, len=0x%zx, err:%s",
+		PMD_LOG_ERR(COM, "Failed to munmap, virt=%p, len=%"PRIu64", err:%s",
 			virt, len, strerror(errno));
 		ret = -EIO;
 		goto l_end;
drivers/common/sxe2/sxe2_osal.h +0 -2
index d77057e7ee..20d1accd5f 100644
@@ -29,8 +29,6 @@
 #define BIT_ULL(a) (1ULL << (a))
 #endif
 
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
-
 #define BITS_PER_BYTE 8
 
 #define IS_UNICAST_ETHER_ADDR(addr)			\
drivers/net/sxe2/meson.build +2 -0
index 8638244d80..b348dd71a1 100644
@@ -18,6 +18,8 @@ sources += files(
         'sxe2_queue.c',
         'sxe2_tx.c',
         'sxe2_rx.c',
+        'sxe2_txrx_poll.c',
+        'sxe2_txrx.c',
 )
 
 allow_internal_get_api = true
drivers/net/sxe2/sxe2_ethdev.c +17 -5
index 2a07c211bf..7e9a842eb9 100644
@@ -26,6 +26,7 @@
 #include "sxe2_cmd_chnl.h"
 #include "sxe2_tx.h"
 #include "sxe2_rx.h"
+#include "sxe2_txrx.h"
 #include "sxe2_common.h"
 #include "sxe2_common_log.h"
 #include "sxe2_host_regs.h"
@@ -131,6 +132,9 @@ static s32 sxe2_dev_start(struct rte_eth_dev *dev)
 		goto l_end;
 	}
 
+	sxe2_rx_mode_func_set(dev);
+	sxe2_tx_mode_func_set(dev);
+
 	ret = sxe2_queues_start(dev);
 	if (ret) {
 		PMD_LOG_ERR(INIT, "enable queues failed");
@@ -348,8 +352,8 @@ void __iomem *sxe2_pci_map_addr_get(struct sxe2_adapter *adapter,
 	for (i = 0; i < bar_info->map_cnt; i++) {
 		seg_info = &bar_info->seg_info[i];
 		if (res_type == seg_info->type) {
-			addr = (void __iomem *)((uintptr_t)seg_info->addr +
-					seg_info->page_inner_offset + reg_width	* idx_in_func);
+			addr = (uint8_t __iomem *)seg_info->addr +
+					seg_info->page_inner_offset + reg_width * idx_in_func;
 			goto l_end;
 		}
 	}
@@ -460,8 +464,9 @@ s32 sxe2_dev_pci_seg_map(struct sxe2_adapter *adapter,
 
 	map_addr = sxe2_drv_dev_mmap(adapter->cdev, bar_info->bar_idx, aligned_len, aligned_offset);
 	if (!map_addr) {
-		PMD_LOG_ERR(INIT, "Failed to mmap BAR space, type=%d, len=%zu, page_size=%zu",
-					res_type, org_len, page_size);
+		PMD_LOG_ERR(INIT, "Failed to mmap BAR space, type=%d, len=%" PRIu64
+			", offset=%" PRIu64 ", page_size=%zu",
+					res_type, org_len, org_offset, page_size);
 		ret = -EFAULT;
 		goto l_end;
 	}
@@ -745,10 +750,17 @@ static s32 sxe2_dev_init(struct rte_eth_dev *dev, struct sxe2_dev_kvargs_info *k
 
 	PMD_INIT_FUNC_TRACE();
 
+	sxe2_set_common_function(dev);
+
 	dev->dev_ops = &sxe2_eth_dev_ops;
 
-	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		sxe2_rx_mode_func_set(dev);
+		sxe2_tx_mode_func_set(dev);
+		if (ret != SXE2_SUCCESS)
+			PMD_LOG_ERR(INIT, "Failed to mp init (secondary), ret=%d", ret);
 		goto l_end;
+	}
 
 	ret = sxe2_hw_init(dev);
 	if (ret) {
drivers/net/sxe2/sxe2_txrx.c new file +247 -0

247 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx.h new file +21 -0
new file mode 100644
index 0000000000..e6f671e3dc
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd.
+ */
+
+#ifndef SXE2_TXRX_H
+#define SXE2_TXRX_H
+#include <ethdev_driver.h>
+#include "sxe2_queue.h"
+
+void sxe2_set_common_function(struct rte_eth_dev *dev);
+
+u16 sxe2_tx_pkts_prepare(void *tx_queue,
+		struct rte_mbuf **tx_pkts, u16 nb_pkts);
+
+void sxe2_tx_mode_func_set(struct rte_eth_dev *dev);
+
+void __rte_cold sxe2_rx_queue_reset(struct sxe2_rx_queue *rxq);
+
+void sxe2_rx_mode_func_set(struct rte_eth_dev *dev);
+
+#endif
drivers/net/sxe2/sxe2_txrx_poll.c new file +945 -0

945 lines not on this page · raw message

Signature · 1 line
2.47.3
#138 lore raw

PATCH v13 10/10 net/sxe2: add vectorized Rx and Tx

In reply to [email protected]

From: Jie Liu <[email protected]>

This patch implements the vectorized data path for the sxe2 PMD. It utilizes SIMD instructions (e.g., SSE) to process multiple packets simultaneously, significantly improving throughput for small packet processing.

The implementation includes:
* Vectorized Rx burst function for bulk descriptor processing.
* Vectorized Tx burst function with optimized resource cleanup.
* Capability flags update to reflect vectorized path support.

---
 drivers/net/sxe2/meson.build            |   7 +
 drivers/net/sxe2/sxe2_ethdev.c          |  35 +-
 drivers/net/sxe2/sxe2_ethdev.h          |   1 -
 drivers/net/sxe2/sxe2_queue.c           |  28 ++
 drivers/net/sxe2/sxe2_queue.h           |   3 +
 drivers/net/sxe2/sxe2_txrx.c            | 223 +++++++---
 drivers/net/sxe2/sxe2_txrx.h            |  11 +-
 drivers/net/sxe2/sxe2_txrx_poll.h       |   3 +-
 drivers/net/sxe2/sxe2_txrx_vec.c        | 197 +++++++++
 drivers/net/sxe2/sxe2_txrx_vec.h        |  72 ++++
 drivers/net/sxe2/sxe2_txrx_vec_common.h | 235 ++++++++++
 drivers/net/sxe2/sxe2_txrx_vec_sse.c    | 545 ++++++++++++++++++++++++
 12 files changed, 1277 insertions(+), 83 deletions(-)
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec.c
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec_common.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec_sse.c
drivers/net/sxe2/meson.build +7 -0
index b348dd71a1..3df57aee8c 100644
@@ -11,6 +11,12 @@ cflags += ['-g']
 
 deps += ['common_sxe2', 'hash','cryptodev','security']
 
+includes += include_directories('../../common/sxe2')
+
+if arch_subdir == 'x86'
+        sources += files('sxe2_txrx_vec_sse.c')
+endif
+
 sources += files(
         'sxe2_ethdev.c',
         'sxe2_cmd_chnl.c',
@@ -20,6 +26,7 @@ sources += files(
         'sxe2_rx.c',
         'sxe2_txrx_poll.c',
         'sxe2_txrx.c',
+        'sxe2_txrx_vec.c',
 )
 
 allow_internal_get_api = true
drivers/net/sxe2/sxe2_ethdev.c +8 -27
index 7e9a842eb9..b6b444a600 100644
@@ -58,17 +58,11 @@ static const struct rte_pci_id pci_id_sxe2_tbl[] = {
 };
 
 static struct sxe2_pci_map_addr_info sxe2_net_map_addr_info_pf[SXE2_PCI_MAP_RES_MAX_COUNT] = {
-	/* SXE2_PCI_MAP_RES_INVALID */
 	{0, 0, 0},
-	/* SXE2_PCI_MAP_RES_DOORBELL_TX */
 	{ SXE2_TXQ_LEGACY_DBLL(0), 0, 4},
-	/* SXE2_PCI_MAP_RES_DOORBELL_RX_TAIL */
 	{ SXE2_RXQ_TAIL(0), 0, 4},
-	/* SXE2_PCI_MAP_RES_IRQ_DYN */
 	{ SXE2_VF_DYN_CTL(0), 0, 4},
-	/* SXE2_PCI_MAP_RES_IRQ_ITR(默认使用ITR0) */
 	{ SXE2_VF_INT_ITR(0, 0), 0, 4},
-	/* SXE2_PCI_MAP_RES_IRQ_MSIX */
 	{ SXE2_BAR4_MSIX_CTL(0), 4, 0x10},
 };
 
@@ -101,25 +95,6 @@ static s32 sxe2_dev_stop(struct rte_eth_dev *dev)
 	return ret;
 }
 
-static s32 sxe2_queues_start(struct rte_eth_dev *dev)
-{
-	s32 ret = SXE2_SUCCESS;
-	ret = sxe2_txqs_all_start(dev);
-	if (ret) {
-		PMD_LOG_ERR(INIT, "Failed to start tx queue.");
-		goto l_end;
-	}
-
-	ret = sxe2_rxqs_all_start(dev);
-	if (ret) {
-		PMD_LOG_ERR(INIT, "Failed to start rx queue.");
-		sxe2_txqs_all_stop(dev);
-	}
-
-l_end:
-	return ret;
-}
-
 static s32 sxe2_dev_start(struct rte_eth_dev *dev)
 {
 	s32 ret = SXE2_SUCCESS;
@@ -152,7 +127,7 @@ static s32 sxe2_dev_start(struct rte_eth_dev *dev)
 static s32 sxe2_dev_close(struct rte_eth_dev *dev)
 {
 	(void)sxe2_dev_stop(dev);
-
+	(void)sxe2_queues_release(dev);
 	sxe2_vsi_uninit(dev);
 	sxe2_dev_pci_map_uinit(dev);
 
@@ -290,13 +265,19 @@ static const struct eth_dev_ops sxe2_eth_dev_ops = {
 	.dev_close                  = sxe2_dev_close,
 	.dev_infos_get              = sxe2_dev_infos_get,
 
+	.rx_queue_start             = sxe2_rx_queue_start,
+	.rx_queue_stop              = sxe2_rx_queue_stop,
+	.tx_queue_start             = sxe2_tx_queue_start,
+	.tx_queue_stop              = sxe2_tx_queue_stop,
 	.rx_queue_setup             = sxe2_rx_queue_setup,
-	.tx_queue_setup             = sxe2_tx_queue_setup,
 	.rx_queue_release           = sxe2_rx_queue_release,
+	.tx_queue_setup             = sxe2_tx_queue_setup,
 	.tx_queue_release           = sxe2_tx_queue_release,
 
 	.rxq_info_get               = sxe2_rx_queue_info_get,
 	.txq_info_get               = sxe2_tx_queue_info_get,
+	.rx_burst_mode_get          = sxe2_rx_burst_mode_get,
+	.tx_burst_mode_get          = sxe2_tx_burst_mode_get,
 };
 
 struct sxe2_pci_map_bar_info *sxe2_dev_get_bar_info(struct sxe2_adapter *adapter,
drivers/net/sxe2/sxe2_ethdev.h +0 -1
index 4ef7854479..43148f9b03 100644
@@ -11,7 +11,6 @@
 #include <rte_tm_driver.h>
 #include <rte_io.h>
 
-#include "sxe2_common.h"
 #include "sxe2_errno.h"
 #include "sxe2_type.h"
 #include "sxe2_vsi.h"
drivers/net/sxe2/sxe2_queue.c +28 -0
index 98343679f6..b1860490aa 100644
@@ -6,6 +6,8 @@
 #include "sxe2_queue.h"
 #include "sxe2_common_log.h"
 #include "sxe2_errno.h"
+#include "sxe2_tx.h"
+#include "sxe2_rx.h"
 
 void sxe2_sw_queue_ctx_hw_cap_set(struct sxe2_adapter *adapter,
 		struct sxe2_drv_queue_caps *q_caps)
@@ -37,3 +39,29 @@ s32 sxe2_queues_init(struct rte_eth_dev *dev)
 
 	return ret;
 }
+
+s32 sxe2_queues_start(struct rte_eth_dev *dev)
+{
+	s32 ret = SXE2_SUCCESS;
+
+	ret = sxe2_txqs_all_start(dev);
+	if (ret) {
+		PMD_LOG_ERR(INIT, "Failed to start tx queue.");
+		goto l_end;
+	}
+
+	ret = sxe2_rxqs_all_start(dev);
+	if (ret) {
+		PMD_LOG_ERR(INIT, "Failed to start rx queue.");
+		sxe2_txqs_all_stop(dev);
+	}
+l_end:
+	return ret;
+}
+
+void sxe2_queues_release(struct rte_eth_dev *dev)
+{
+	sxe2_all_rxqs_release(dev);
+
+	sxe2_all_txqs_release(dev);
+}
drivers/net/sxe2/sxe2_queue.h +3 -0
index 7fa22e2820..93402186c7 100644
@@ -188,4 +188,7 @@ void sxe2_sw_queue_ctx_hw_cap_set(struct sxe2_adapter *adapter,
 
 s32 sxe2_queues_init(struct rte_eth_dev *dev);
 
+s32 sxe2_queues_start(struct rte_eth_dev *dev);
+
+void sxe2_queues_release(struct rte_eth_dev *dev);
 #endif
drivers/net/sxe2/sxe2_txrx.c +174 -49

373 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx.h +6 -5
index e6f671e3dc..8f929c4f19 100644
@@ -6,16 +6,17 @@
 #define SXE2_TXRX_H
 #include <ethdev_driver.h>
 #include "sxe2_queue.h"
-
 void sxe2_set_common_function(struct rte_eth_dev *dev);
 
+s32 __rte_cold sxe2_tx_simple_batch_support_check(struct rte_eth_dev *dev,
+	u32 *batch_flags);
 u16 sxe2_tx_pkts_prepare(void *tx_queue,
 		struct rte_mbuf **tx_pkts, u16 nb_pkts);
-
 void sxe2_tx_mode_func_set(struct rte_eth_dev *dev);
-
 void __rte_cold sxe2_rx_queue_reset(struct sxe2_rx_queue *rxq);
-
 void sxe2_rx_mode_func_set(struct rte_eth_dev *dev);
-
+s32 sxe2_tx_burst_mode_get(struct rte_eth_dev *dev,
+			__rte_unused uint16_t queue_id, struct rte_eth_burst_mode *mode);
+s32 sxe2_rx_burst_mode_get(struct rte_eth_dev *dev,
+			__rte_unused u16 queue_id, struct rte_eth_burst_mode *mode);
 #endif
drivers/net/sxe2/sxe2_txrx_poll.h +2 -1
index 4924b0f41f..67da08e58e 100644
@@ -8,7 +8,8 @@
 #include "sxe2_queue.h"
 
 u16 sxe2_tx_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, u16 nb_pkts);
-
+u16 sxe2_tx_pkts_simple(void *tx_queue,
+			struct rte_mbuf **tx_pkts, u16 nb_pkts);
 u16 sxe2_rx_pkts_scattered(void *rx_queue, struct rte_mbuf **rx_pkts, u16 nb_pkts);
 
 u16 sxe2_rx_pkts_scattered_split(void *rx_queue, struct rte_mbuf **rx_pkts, u16 nb_pkts);
drivers/net/sxe2/sxe2_txrx_vec.c new file +197 -0

197 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx_vec.h new file +72 -0

72 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx_vec_common.h new file +235 -0

235 lines not on this page · raw message

drivers/net/sxe2/sxe2_txrx_vec_sse.c new file +545 -0

545 lines not on this page · raw message

Signature · 1 line
2.47.3
#139 lore raw

Re: [PATCH v13 00/10] net/sxe2: fix logic errors and address feedback

In reply to [email protected]
Quoted 103 lines · On Tue, 12 May 2026 19:36:49 +0800 [email protected] wrote:

From: Jie Liu <[email protected]>

This patch set addresses the feedback received on the v10 submission for the sxe2 PMD. The primary focus is on fixing vector path selection, ensuring memory safety during mbuf initialization, and cleaning up redundant logic in the configuration functions.

v13 Changes:
- Fixed vector Rx burst function being overwritten by scalar selection.
- Refactored Rx/Tx mode set functions to seed flags from caps first,eliminating tautological checks.
- Added memset for mbuf_def in vector init to avoid uninitialized reads.
- Converted pci_map_addr_info to designated initializers.
- Removed dead Windows-only code in meson.build.
- Added NULL checks for mbuf free for driver-wide consistency.
- Updated burst_mode_get to accurately report AVX paths.
- Adjusted SXE2_ETH_OVERHEAD to match actual VLAN capabilities.

Jie Liu (10):
mailmap: add Jie Liu
doc: add sxe2 guide and release notes common/sxe2: add sxe2 basic structures
drivers: add base driver skeleton
drivers: add base driver probe skeleton
drivers: support PCI BAR mapping
common/sxe2: add ioctl interface for DMA map and unmap net/sxe2: support queue setup and control
drivers: add data path for Rx and Tx net/sxe2: add vectorized Rx and Tx

 .mailmap                                   |   1 +
 doc/guides/nics/features/sxe2.ini          |  30 +
 doc/guides/nics/index.rst                  |   1 +
 doc/guides/nics/sxe2.rst                   |  34 +
 doc/guides/rel_notes/release_26_07.rst     |   4 +
 drivers/common/sxe2/meson.build            |  15 +
 drivers/common/sxe2/sxe2_common.c          | 685 +++++++++++++++
 drivers/common/sxe2/sxe2_common.h          |  86 ++
 drivers/common/sxe2/sxe2_common_log.h      |  83 ++
 drivers/common/sxe2/sxe2_errno.h           | 110 +++
 drivers/common/sxe2/sxe2_host_regs.h       | 707 +++++++++++++++
 drivers/common/sxe2/sxe2_internal_ver.h    |  33 +
 drivers/common/sxe2/sxe2_ioctl_chnl.c      | 326 +++++++
 drivers/common/sxe2/sxe2_ioctl_chnl.h      | 141 +++
 drivers/common/sxe2/sxe2_ioctl_chnl_func.h |  63 ++
 drivers/common/sxe2/sxe2_osal.h            | 584 +++++++++++++
 drivers/common/sxe2/sxe2_type.h            |  60 ++
 drivers/meson.build                        |   1 +
 drivers/net/meson.build                    |   1 +
 drivers/net/sxe2/meson.build               |  32 +
 drivers/net/sxe2/sxe2_cmd_chnl.c           | 319 +++++++
 drivers/net/sxe2/sxe2_cmd_chnl.h           |  33 +
 drivers/net/sxe2/sxe2_drv_cmd.h            | 389 +++++++++
 drivers/net/sxe2/sxe2_ethdev.c             | 941 ++++++++++++++++++++
 drivers/net/sxe2/sxe2_ethdev.h             | 315 +++++++
 drivers/net/sxe2/sxe2_irq.h                |  49 ++
 drivers/net/sxe2/sxe2_queue.c              |  67 ++
 drivers/net/sxe2/sxe2_queue.h              | 194 +++++
 drivers/net/sxe2/sxe2_rx.c                 | 579 +++++++++++++
 drivers/net/sxe2/sxe2_rx.h                 |  34 +
 drivers/net/sxe2/sxe2_tx.c                 | 447 ++++++++++
 drivers/net/sxe2/sxe2_tx.h                 |  32 +
 drivers/net/sxe2/sxe2_txrx.c               | 372 ++++++++
 drivers/net/sxe2/sxe2_txrx.h               |  22 +
 drivers/net/sxe2/sxe2_txrx_common.h        | 541 ++++++++++++
 drivers/net/sxe2/sxe2_txrx_poll.c          | 945 +++++++++++++++++++++
 drivers/net/sxe2/sxe2_txrx_poll.h          |  17 +
 drivers/net/sxe2/sxe2_txrx_vec.c           | 197 +++++
 drivers/net/sxe2/sxe2_txrx_vec.h           |  72 ++
 drivers/net/sxe2/sxe2_txrx_vec_common.h    | 235 +++++
 drivers/net/sxe2/sxe2_txrx_vec_sse.c       | 545 ++++++++++++
 drivers/net/sxe2/sxe2_vsi.c                | 212 +++++
 drivers/net/sxe2/sxe2_vsi.h                | 205 +++++
 43 files changed, 9759 insertions(+)
 create mode 100644 doc/guides/nics/features/sxe2.ini
 create mode 100644 doc/guides/nics/sxe2.rst
 create mode 100644 drivers/common/sxe2/meson.build
 create mode 100644 drivers/common/sxe2/sxe2_common.c
 create mode 100644 drivers/common/sxe2/sxe2_common.h
 create mode 100644 drivers/common/sxe2/sxe2_common_log.h
 create mode 100644 drivers/common/sxe2/sxe2_errno.h
 create mode 100644 drivers/common/sxe2/sxe2_host_regs.h
 create mode 100644 drivers/common/sxe2/sxe2_internal_ver.h
 create mode 100644 drivers/common/sxe2/sxe2_ioctl_chnl.c
 create mode 100644 drivers/common/sxe2/sxe2_ioctl_chnl.h
 create mode 100644 drivers/common/sxe2/sxe2_ioctl_chnl_func.h
 create mode 100644 drivers/common/sxe2/sxe2_osal.h
 create mode 100644 drivers/common/sxe2/sxe2_type.h
 create mode 100644 drivers/net/sxe2/meson.build
 create mode 100644 drivers/net/sxe2/sxe2_cmd_chnl.c
 create mode 100644 drivers/net/sxe2/sxe2_cmd_chnl.h
 create mode 100644 drivers/net/sxe2/sxe2_drv_cmd.h
 create mode 100644 drivers/net/sxe2/sxe2_ethdev.c
 create mode 100644 drivers/net/sxe2/sxe2_ethdev.h
 create mode 100644 drivers/net/sxe2/sxe2_irq.h
 create mode 100644 drivers/net/sxe2/sxe2_queue.c
 create mode 100644 drivers/net/sxe2/sxe2_queue.h
 create mode 100644 drivers/net/sxe2/sxe2_rx.c
 create mode 100644 drivers/net/sxe2/sxe2_rx.h
 create mode 100644 drivers/net/sxe2/sxe2_tx.c
 create mode 100644 drivers/net/sxe2/sxe2_tx.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx.c
 create mode 100644 drivers/net/sxe2/sxe2_txrx.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_common.h
Quoted 9 lines
 create mode 100644 drivers/net/sxe2/sxe2_txrx_poll.c
 create mode 100644 drivers/net/sxe2/sxe2_txrx_poll.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec.c
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec_common.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_vec_sse.c
 create mode 100644 drivers/net/sxe2/sxe2_vsi.c
 create mode 100644 drivers/net/sxe2/sxe2_vsi.h

Still lots of AI review feedback:

Summary of v13 sxe2 PMD review

Most of the mechanical issues from v10 (carried into v11/v12) have been addressed in v13: duplicate tx_queue_offload_capa is gone, RTE_LOG_REGISTER_SUFFIX no longer registers Tx as "rx", the fopen("/var/log/...") path, SXE2_DPDK_DEBUG, FPGA_VER_ASIC and the debug flags in meson are gone, rx_queue_release / tx_queue_release are in dev_ops, and mmap() is correctly checked against MAP_FAILED.

What still needs to be fixed:

Errors
------

Patch 06/10 - Inverted error checks in sxe2_dev_pci_map_init(). sxe2_dev_pci_res_seg_map() returns 0 on success, negative on failure (the definition is in this same patch). Five consecutive call sites use "if (!ret)" which is true on success, then log "Failed to map..." and goto cleanup, unmapping the BAR segment just mapped and returning ret=0 so the caller thinks probe succeeded. On a real failure, the check is false and the code proceeds as if the mapping had succeeded. Same bug flagged in v10, unchanged in v11/v12/v13.

Patch 04/10 - rte_ticketlock_t (busy-wait FIFO lock) held across blocking ioctl() to the kernel driver in sxe2_drv_cmd_exec(), sxe2_drv_dev_handshark(), and the DMA map/unmap entry points added in patch 07. Other lcores trying to acquire the lock burn CPU spinning until the kernel returns. Use pthread_mutex_t; the lock is in process-private memory so PTHREAD_PROCESS_SHARED is not needed.

Patch 06/10 - Non-ASCII characters in source comments. In sxe2_net_map_addr_info_pf[]: "/* SXE2_PCI_MAP_RES_IRQ_ITR(默认使用ITR0) */". DPDK source should be ASCII English.

Warnings
--------

Patch 02/10 - Feature matrix overclaims. sxe2.ini lists "MTU update = Y" but no .mtu_set is registered, and "Free Tx mbuf on demand = Y" but no .tx_done_cleanup is registered. Either implement the callbacks or fix the matrix.

Patch 09/10 - Dead "if (ret != SXE2_SUCCESS)" check in the secondary-process branch of sxe2_dev_init() after two calls to void-returning functions (sxe2_rx_mode_func_set, sxe2_tx_mode_func_set). ret cannot change, so the error log never fires.

Patch 03/10 - Driver-private kernel-style aliases in sxe2_type.h: u8/s8/u16/.../s64 typedefs, "#define STATIC static", "#define __le16 u16", "#define __be16 u16". DPDK convention is to use the standard names directly. The __le*/__be* defines also erase the endianness annotation rather than preserving it.

Patch 03/10 - sxe2_osal.h reinvents infrastructure that already exists in DPDK: BIT/BIT_ULL/GENMASK/set_bit/test_bit/bitmap_weight (use rte_bitops.h / rte_bitmap.h), LIST_FOR_EACH_ENTRY and friends (use sys/queue.h TAILQ_* or rte_tailq), COMPILER_BARRIER (use rte_compiler_barrier), sxe2_*_lock wrappers around rte_spinlock_*, and udelay/mdelay/msleep aliases for rte_delay_us. The kernel idioms __iomem and IS_ERR/IS_ERR_VALUE do not belong in a userspace PMD.

Patch 03/10 - sxe2_errno.h defines a parallel SXE2_ERR_* namespace that aliases every POSIX errno. The rest of the driver mixes both spellings (-EFAULT and SXE2_ERR_PERM appear in the same file). Pick one and use it everywhere.

Patch 08/10 - Redundant "queue_idx >= nb_*_queues" guards at the top of sxe2_rx_queue_setup / sxe2_tx_queue_setup / queue_start / queue_stop. The ethdev layer validates queue_idx before calling the PMD.

Patches 04 and 06 - Typos in identifiers and log strings:
sxe2_commoin_inited (commoin -> common), sxe2_drv_dev_handshark (handshark -> handshake; the ioctl SXE2_COM_CMD_HANDSHAKE is correct, only the wrapper is mistyped), "kernel reseted, need restart app." (reseted -> was reset).

Info
----

Patch 09/10 - sxe2_rx_mode_func_set always picks a scattered Rx burst (split or non-split) regardless of dev->data->scattered_rx. There is no plain single-segment fast path.

Patch 10/10 - The vector capability probe in sxe2_rx_mode_func_set is gated on RTE_PROC_PRIMARY, but a secondary process calls the same function and lands on the scalar path. Since rx_pkt_burst is per-rte_eth_dev and re-assigned by whichever process calls last, the resulting mode depends on attach ordering.

Patch 09/10 - Dead "goto l_end_of_tx;" immediately before the "l_end_of_tx:" label in sxe2_tx_pkts().

Patch 10/10 - The "AVX512/AVX2 is not supported in build env" log lines fire based on CPU capability, not on any build-time absence, so the message is misleading.

The v10-flagged PCI map inverted-check bug is still present after three respins.

Longer report available if needed.

#140 lore raw

Re: [PATCH v10 00/10] Add Linkdata sxe2 driver

In reply to [email protected]
Quoted 5 lines · On Wed, 6 May 2026 19:35:46 +0800 [email protected] wrote:

From: Jie Liu <[email protected]>

V10:
- Addressed AI comments

Quoted 11 lines

Jie Liu (10):
mailmap: add Jie Liu
doc: add sxe2 guide and release notes
drivers: add sxe2 basic structures common/sxe2: add base driver skeleton
drivers: add base driver probe skeleton
drivers: support PCI BAR mapping
common/sxe2: add ioctl interface for DMA map and unmap net/sxe2: support queue setup and control
drivers: add data path for Rx and Tx net/sxe2: add vectorized Rx and Tx

My comments first:
- drivers going upstream are expected to be production quality. Having #ifdef for driver specific stuff indicates to me either that the code is not ready, existing DPDK debug infrastructure is insufficient, or that the author is unwilling to "kill his darlings".

You may not get the last reference, but in writing "kill your darlings" refers to the problem where author becomes too attached to characters or scenes and is unwilling to make the deep edits necessary to be good writing.

- slicing up out of tree code base leads to messy code. Don't have all the other OS code still in base.

As usual AI review has lots, lots more to say.
Don't treat it all as absolute, but it looks like it found lots of real bugs and things like mismatch of doc's and features.

If you want to run AI review yourself see AGENTS.md file pending in patchwork.

Now for the long AI review:

Review of v10 sxe2 PMD series
=============================

Overall comments
----------------

The series adds a new PMD for the Linkdata sxe2 family. Several patches in this series contain serious correctness bugs that would prevent the driver from working with real hardware, including inverted error checks that take the failure path on success, an uninitialised mbuf->next dereference in an error path, a use-after-free / double-free in the buffer-split scatter Rx, and a vector-mode selection that is unconditionally overwritten by the scalar selection that follows it. These need to be fixed before the driver can be considered ready for merge.

Beyond those correctness issues, two structural problems in this series need addressing before a merge can be considered. Both are fundamental enough that I want to call them out at the top.

1. The driver opens its own file under /var/log and routes its log lines through a private FILE *.

drivers/common/sxe2/sxe2_common_log.c does fopen() on /var/log/sxe2pmd.log.<timestamp> and then every PMD_LOG_* call goes through a wrapper that does rte_openlog_stream(g_sxe2_common_log_fp) before the log line and rte_openlog_stream(NULL) after.

This is not acceptable for a DPDK driver. rte_openlog_stream is a process-global setting; flipping it on every log call means any other PMD or application code in the same process that has set its own log stream gets clobbered every time sxe2 logs anything. /var/log is a privileged path that ordinary DPDK applications cannot write to. The FILE * is opened once and never closed, so it leaks across the lifetime of the process. The whole code path is also gated on SXE2_DPDK_DEBUG, which the driver's meson.build defines unconditionally - so the debug-only path is the production path.

DPDK drivers log via RTE_LOG / RTE_LOG_LINE / RTE_LOG_LINE_PREFIX into the rte_log infrastructure. The application owns the log stream, not the PMD. Please remove the file-logging path entirely and use rte_log directly; if a per-thread/per-port prefix is wanted, use RTE_LOG_LINE_PREFIX. The 350+ lines of PMD_LOG_*/LOG_*/LOG_DEV_*/LOG_MSG_* macros in sxe2_common_log.h can collapse to a handful of one-line wrappers over RTE_LOG_LINE.

2. The driver is being submitted as a slice of a larger out-of-tree codebase, with the slicing done at compile time via #ifdef.

sxe2_drv_cmd.h, sxe2_ioctl_chnl.h and others contain the pattern

	#ifdef SXE2_DPDK_DRIVER
	#include "sxe2_type.h"
	...
	#endif

	#ifdef SXE2_LINUX_DRIVER
	#ifdef __KERNEL__
	#include <linux/types.h>
	#include <linux/if_ether.h>
	#endif
	#endif

and sxe2_osal.h carries a #ifndef ladder around BIT_ULL, BITS_PER_LONG, DIV_ROUND_UP, TAILQ_FOREACH_SAFE and friends so the same header can be included from both sides. On top of that there is a SXE2_DPDK_DEBUG knob, a SXE2_DPDK_DEBUG_RXTX_LOG knob, a SXE2_TEST knob, an FPGA_VER_ASIC knob (defined unconditionally in meson.build, so it is dead - but its existence implies multiple build flavours), a RTE_LIBRTE_SXE2_16BYTE_RX_DESC knob that selects descriptor format at compile time, and a PCLINT knob. The result is that nobody upstream can audit "what gets built" without picking a specific combination of flags, and the variants that aren't built by default will rot.

DPDK is not a kernel-driver-sharing host. The expectation is that what is submitted is the DPDK driver, written in DPDK style, building exactly one binary per arch. Please:

- Remove the SXE2_LINUX_DRIVER / __KERNEL__ branches from every header. The kernel driver lives elsewhere; ship its headers there.
- Remove the SXE2_DPDK_DRIVER guard - it is the only thing being built here.
- Remove FPGA_VER_ASIC (unused) and PCLINT (lint annotations should not be in shipping source).
- Make RTE_LIBRTE_SXE2_16BYTE_RX_DESC a runtime decision or just pick one format. Compile-time descriptor format selection is a pattern other PMDs have moved away from.
- SXE2_DPDK_DEBUG / SXE2_DPDK_DEBUG_RXTX_LOG / SXE2_TEST should be removed; if a debug counter or extra log line is genuinely useful, gate it on the existing RTE_ETHDEV_DEBUG_RX/TX or on a runtime devarg, not on a build-time flag the driver defines for itself.

With those gone, the same set of files will be cleaner, smaller, and a lot easier to review.

The driver also reinvents a fair amount of infrastructure that already exists in DPDK - logging (above), the entire linux-kernel-style bit/bitmap/list layer in sxe2_osal.h (BIT/GENMASK/set_bit/test_bit/LIST_FOR_EACH_ENTRY/COMPILER_BARRIER/ sxe2_lock/etc.), and a parallel sxe2_errno.h that maps every errno to a SXE2_ERR_* alias. Please use the DPDK equivalents (rte_bitops.h, rte_bitmap, sys/queue.h or rte_tailq, rte_compiler_barrier, rte_spinlock_t, plain -errno) directly.

Severity legend: Error = correctness/build; Warning = should fix; Info = consider.

Patch 02/10 doc: add sxe2 guide and release notes
--------------------------------------------------

Warning: doc/guides/nics/features/sxe2.ini lists only "Queue start/stop" and "Linux", but sxe2_dev_infos_get in patch 5 advertises VLAN_STRIP, KEEP_CRC, SCATTER, RSS_HASH, LRO, BUFFER_SPLIT, multiple checksum offloads, MBUF_FAST_FREE, TSO, tunnel TSO, etc. The features matrix needs to be updated to match what dev_info reports (and to drop entries the v10 patches do not yet implement).

Warning: doc/guides/nics/sxe2.rst states "this driver only deals with virtual memory addresses", but sxe2_drv_dev_dma_map() in patch 7 has an explicit RTE_IOVA_PA branch and supports PA mode when IOMMU is absent. Either remove the PA path or update the doc.

Info: sxe2.ini ends without a newline ("\ No newline at end of file" in the diff).

Info: in sxe2.rst, "are supported" sentence is missing a trailing period; reST renders the next blank line as a section break which is probably not intended.

Patch 03/10 drivers: add sxe2 basic structures
-----------------------------------------------

Error: drivers/common/sxe2/meson.build enables -DSXE2_DPDK_DEBUG unconditionally, which turns on the fopen()/private-stream logging path in sxe2_common_log.c. See "Overall comments" - that path needs to go away entirely, and the build flag needs to go with it.

Error: sxe2_common_log.h's PMD_LOG_NOTICE / PMD_LOG_WARN / PMD_LOG_ERR / PMD_LOG_CRIT / PMD_LOG_ALERT / PMD_LOG_EMERG (and the matching PMD_DEV_LOG_* variants) emit the same log line twice when SXE2_DPDK_DEBUG is on:

	#define PMD_LOG_ERR(logtype, fmt, ...) \
		do { \
			SXE2_PMD_LOG(ERR, SXE2_##logtype, fmt, ##__VA_ARGS__); \
			sxe2_common_log_stream_open();\
			SXE2_PMD_LOG(ERR, SXE2_##logtype, fmt, ##__VA_ARGS__); \
			sxe2_common_log_stream_close();\
		} while (0)

The first SXE2_PMD_LOG goes to whatever rte_log stream was in effect; the second goes to the private file. This is almost certainly a bug independent of (1) above. When the file-logging path is removed, just call SXE2_PMD_LOG once.

Warning: drivers/common/sxe2/meson.build uses sources = files(...) instead of sources += files(...). This works today because nothing else sets sources for this subdir, but the rest of DPDK uses += and any future infra change that sets a source from outside will be silently dropped.

Warning: drivers/common/sxe2/sxe2_type.h does typedef char s8. Plain char is signed on x86 and unsigned on arm64/ppc64 by default. s8 is then used as a string buffer (e.g. s8 g_sxe2_common_log_filename[], s8 stime[40], s8 drv_name[32]) and passed to snprintf/fopen/strerror. Under -Werror with -Wpointer-sign this will fail to build on platforms where char is unsigned. Use int8_t for s8 (and only use it where you truly want a signed 8-bit integer), and use char for text buffers.

Warning: sxe2_type.h also defines unused S8/S16/S32 typedefs. Drop them.

Warning: sxe2_osal.h defines GENMASK as `(((~0UL) - (1UL << (l)) + 1) & (~0UL >> (__BITS_PER_LONG
- 1 - (h)))). When h == __BITS_PER_LONG - 1 the right operand becomes a shift by 0 which is fine, but the macro also relies on 1UL` being at least __BITS_PER_LONG bits; on a 32-bit build any GENMASK with l >= 32 invokes UB. Use RTE_GENMASK64 from rte_bitops.h.

Warning: sxe2_osal.h sxe2_swap_u16() uses an arithmetic swap (a += b; b = a - b; a -= b). This is harder to read than a tmp variable, computes the same result, and offers no benefit. Use a tmp.

Info: sxe2_common_log.h STIME macro is defined but unused.

Info: sxe2_internal_ver.h SXE2_MK_VER_MAJOR/MINOR rely on operator precedence inside macro expansion - parenthesise the macro arguments.

Patch 04/10 common/sxe2: add base driver skeleton
--------------------------------------------------

Error: drivers/common/sxe2/sxe2_common.c sxe2_common_pci_id_table_update() silently returns SXE2_SUCCESS when calloc() fails:

	s32 ret = SXE2_SUCCESS;
	...
	updated_table = calloc(num_ids, sizeof(*updated_table));
	if (!updated_table) {
		PMD_LOG_ERR(COM, "Failed to allocate memory for PCI ID table");
		goto l_end;
	}
	...
l_end:
	return ret;

ret is never set to an error value before the goto, so the caller (sxe2_common_pci_init / sxe2_common_driver_on_register_pci) proceeds as if the PCI ID table were updated. Set
ret = SXE2_ERR_NO_MEMORY (or -ENOMEM) before the goto.

Warning: sxe2_ioctl_chnl.c first include line is indented with a leading space ( #include <sys/types.h>), the rest of the includes are not indented. Fixes the diff indentation noise as well.

Warning: sxe2_drv_dev_close() uses if (fd > 0) to decide whether to close. fd 0 is a legitimate file descriptor (stdin in the host, but also a valid value returned by open() in unusual cases). Use if (fd >= 0).

Warning: sxe2_common_pci_remove() frees cdev->kvargs with free(), but if the kvargs were never allocated (rte_dev->devargs->args was NULL), cdev->kvargs is also NULL and the free() is fine. However the comment "Fail to get remove device" in sxe2_common_pci_dma_unmap (patch 7) is the unmap path, not remove - copy/paste from the remove function.

Info: sxe2_kvargs_process() uses (*handler)(...) syntax; plain handler(...) reads better.

Patch 05/10 drivers: add base driver probe skeleton
----------------------------------------------------

Error: drivers/net/sxe2/sxe2_ethdev.c registers the Tx logtype with the wrong suffix (twice):

	RTE_LOG_REGISTER_SUFFIX(sxe2_log_tx, rx, DEBUG);
	...
	RTE_LOG_REGISTER_SUFFIX(sxe2_log_tx, rx, NOTICE);

Both should be tx. As written, all Tx logs flow into the rx logtype name, and rte_log_register_pattern won't be able to address them separately.

Error: sxe2_eth_pmd_probe_pf() does not set adapter->cdev for secondary processes, but sxe2_dev_init() unconditionally calls sxe2_hw_init() -> sxe2_dev_caps_get() -> sxe2_func_caps_get() -> sxe2_drv_dev_caps_get() which dereferences adapter->cdev. NULL-deref on secondary attach. sxe2_dev_init() should early-return after setting up ops/burst pointers when
rte_eal_process_type() != RTE_PROC_PRIMARY.

Error: sxe2_dev_infos_get() assigns dev_info->tx_queue_offload_capa twice; the second assignment unconditionally overwrites the first with just RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE. Either drop the second assignment or change it to |=. As written, the per-queue Tx offload caps reported to the application are just MBUF_FAST_FREE, contradicting the much longer list a few lines above.

Error: sxe2_eth_pmd_remove() leaks the eth_dev port when sxe2_dev_uninit() fails. rte_eth_dev_release_port() is only called on the success path. Either always release or report the leak.

Warning: drivers/net/sxe2/meson.build contains a non-ASCII comment ("#执行子目录base,并获取目标对象") and unconditionally adds -DFPGA_VER_ASIC, -DSXE2_DPDK_DRIVER, -g and -Werror to cflags. -Werror in particular should be controlled via -Dwerror=true at the project level, not hard-coded per-driver. -g should come from the buildtype. FPGA_VER_ASIC is not used in any of the patches in this series; if it is dead, drop it.

Warning: sxe2_dev_infos_get() reports a long list of offloads (RSS_HASH, BUFFER_SPLIT, QINQ_STRIP, VLAN_EXTEND, TCP_LRO, several tunnel TSOs, PTP timestamp, etc.) that are not implemented anywhere in the v10 series. Either implement them, or trim dev_info to what actually works. Currently testpmd will accept and silently ignore flags the driver claims to support.

Warning: sxe2_dev_infos_get() sets nb_rx_queues and nb_tx_queues from dev->data->nb_rx_queues/nb_tx_queues
- those are the currently-configured queue counts, not the driver capability. rte_eth_dev_info_get callers expect maxima.

Warning: sxe2_main_vsi_create() error path does sxe2_vsi_node_free(adapter->vsi_ctxt.main_vsi) but sxe2_vsi_node_free() rte_free()s the pointer and then does vsi = NULL on its local variable, leaving adapter->vsi_ctxt.main_vsi dangling. sxe2_vsi_uninit() and sxe2_dev_close() later read this field. Set adapter->vsi_ctxt.main_vsi = NULL in the caller after free.

Warning: SXE2_ETH_OVERHEAD in sxe2_ethdev.h hardcodes + SXE2_VLAN_TAG_SIZE * 2 (8 bytes for QinQ) but the driver does not actually advertise/implement QINQ_STRIP/QINQ_INSERT in v10. This is the "hardcoded VLAN overhead in a PMD that does not support VLAN" pattern - either reflect the driver's actual capability or implement QinQ.

Info: sxe2_vsi.h defines an enum sxe2_vsi_type and a parallel set of sxe2_VSI_DOWN/sxe2_VSI_CLOSE enums with lower-case prefixes - normalise to upper-case SXE2_ prefix.

Info: sxe2_vsi.c sxe2_vsi_node_alloc() logs "Failed to malloc vf vsi struct" even when the caller is creating a PF VSI - generic message would be clearer.

Info: sxe2_dev_close() does not yet release queues; this is added piecemeal in later patches but the dev_ops table in patch 8 still does not register .rx_queue_release / .tx_queue_release. See note on patch 8.

Patch 06/10 drivers: support PCI BAR mapping
---------------------------------------------

Error (critical): sxe2_dev_pci_map_init() in drivers/net/sxe2/sxe2_ethdev.c uses inverted error checks for every sxe2_dev_pci_res_seg_map() call. sxe2_dev_pci_res_seg_map() returns SXE2_SUCCESS (0) on success, but the caller does:

	ret = sxe2_dev_pci_res_seg_map(adapter,
			SXE2_PCI_MAP_RES_DOORBELL_TX,
			txq_cnt, txq_base);
	if (!ret) {
		PMD_LOG_ERR(INIT, "Failed to map txq doorbell addr, ret=%d", ret);
		goto l_free_seg1;
	}

!ret is true on success. All five mapping calls (DOORBELL_TX, DOORBELL_RX_TAIL, IRQ_DYN, IRQ_ITR, IRQ_MSIX) have the same inversion. The result is:

- First successful map -> goto l_free_seg1 -> frees

    bar_info[1].seg_info, bar_info[0].seg_info, bar_info.
  - But `map_ctxt->bar_info = bar_info;` was set just
    above the goto, so map_ctxt->bar_info is now a
    dangling pointer.
  - ret stays 0, so the function returns SUCCESS.
  - Caller (sxe2_dev_init) proceeds.
  - Subsequent access to map_ctxt->bar_info from
    sxe2_dev_get_bar_info() / sxe2_pci_map_addr_get() is
    use-after-free.
  - sxe2_dev_pci_map_uinit() will also UAF on
    map_ctxt->bar_info.

This bug means the driver cannot have been exercised on real hardware in this form. Fix all five checks to if (ret).

Warning: sxe2_dev_pci_seg_map() uses size_t for org_len in the printf format %zu in patch 6 but the prototype takes u64. Patch 9 then changes the format to PRIu64. Use PRIu64 from the start to avoid the noise commit.

Patch 07/10 common/sxe2: add ioctl interface for DMA map and IRQ
-----------------------------------------------------------------

Warning: sxe2_drv_dev_dma_unmap() does
if (!cdev->config.support_iommu) return SXE2_SUCCESS; mid-function, while every other path in the same file uses goto l_end. Make the style consistent.

Info: sxe2_common_pci_dma_map()/dma_unmap() error logs both say "Fail to get remove device" - copy/paste from sxe2_common_pci_remove(). Use a message that matches the operation.

Patch 08/10 net/sxe2: support queue setup and control
------------------------------------------------------

Error: sxe2_rx_queue_mbufs_alloc() error path uses mbuf->next which was never initialised:

	for (i = 0; i < rxq->ring_depth; i++) {
		mbuf = sxe2_mbuf_raw_alloc(rxq->mb_pool);
		if (mbuf == NULL) { ... goto l_err_free_mbuf; }
		buf_ring[i] = mbuf;
		...
		} else {
			mbuf_pay = rte_mbuf_raw_alloc(rxq->rx_seg[1].mp);
			if (unlikely(!mbuf_pay)) { ... goto l_err_free_mbuf; }
			...
			mbuf->next = mbuf_pay;
		}
	}
l_err_free_mbuf:
	for (j = 0; j <= i; j++) {
		if (buf_ring[j] != NULL && buf_ring[j]->next != NULL) {
			rte_pktmbuf_free(buf_ring[j]->next);
			...
		}
		...
	}

When mbuf_pay allocation fails on iteration i, buf_ring[i] is set to mbuf but mbuf->next has not yet been assigned — rte_mbuf_raw_alloc() does not zero ->next. The cleanup loop then reads buf_ring[i]->next (uninitialised pointer) and may pass it to rte_pktmbuf_free(). Use rte_pktmbuf_alloc() (which initialises ->next), or set mbuf->next = NULL right after the raw_alloc.

Error: the dev_ops table in sxe2_ethdev.c is updated to add .rx_queue_setup, .tx_queue_setup, .rxq_info_get, .txq_info_get, but not .rx_queue_release / .tx_queue_release. All Rx/Tx queue memory (descriptor ring memzone, buffer ring, queue struct) is leaked when ports are reconfigured or closed. Wire up sxe2_rx_queue_release() and sxe2_tx_queue_release() into dev_ops.

Warning: sxe2_txqs_all_start() / sxe2_txqs_all_stop() / sxe2_rxqs_all_start() / sxe2_rxqs_all_stop() declare their dev parameter as __rte_unused but then read dev->data. Drop the __rte_unused annotation; otherwise readers will assume the parameter really is unused.

Warning: sxe2_tx.c sxe2_txqs_all_start() opens with

	s32 __rte_cold sxe2_txqs_all_start(struct rte_eth_dev *dev __rte_unused)
	{
	struct rte_eth_dev_data *data = dev->data;

The first line of the function body has no leading tab, breaking the indent.

Warning: sxe2_rx_queue_alloc() and sxe2_tx_queue_alloc() call sxe2_rx_queue_release(dev, queue_idx) / sxe2_tx_queue_release(dev, queue_idx) on the error path right after a fresh rte_zmalloc_socket() failure, even though dev->data->rx_queues[queue_idx] / dev->data->tx_queues[queue_idx] have not been written yet. These calls are no-ops at runtime but they read oddly - drop them and free the just-allocated objects directly.

Warning: sxe2_rx_queue_setup() validates rx_nseg > 1 && !(offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) and (offloads & BUFFER_SPLIT) && !(rx_nseg > 1) — these are validations that ethdev already performs in rte_eth_rx_queue_setup(). The PMD does not need to duplicate them.

Info: sxe2_mbuf_raw_alloc() is a one-line wrapper around rte_mbuf_raw_alloc() that adds nothing. Drop it and call rte_mbuf_raw_alloc() directly.

Patch 09/10 drivers: add data path for Rx and Tx
-------------------------------------------------

Error: sxe2_rx_pkts_scattered_split() in sxe2_txrx_poll.c has a use-after-free / double-free in the RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT path:

	new_mbuf = NULL;

	while (done_num < nb_pkts) {
		...
		if ((rxq->offloads & BUFFER_SPLIT) == 0 ||
		    first_seg == NULL) {
			new_mbuf = rte_mbuf_raw_alloc(rxq->mb_pool);
			if (unlikely(new_mbuf == NULL)) { ... break; }
		}

		if (rxq->offloads & BUFFER_SPLIT) {
			new_mbuf_pay = rte_mbuf_raw_alloc(rxq->rx_seg[1].mp);
			if (unlikely(new_mbuf_pay == NULL)) {
				...
				if (new_mbuf != NULL)
					rte_pktmbuf_free(new_mbuf);
				new_mbuf = NULL;
				break;
			}
		}
		...

When BUFFER_SPLIT is enabled and first_seg != NULL (continuing a multi-descriptor packet), the first if block is skipped, so new_mbuf keeps the value it had on the previous iteration — which has already been stored in *cur_buffer and is now part of the buffer ring.

If new_mbuf_pay alloc fails on this iteration, the if (new_mbuf != NULL) rte_pktmbuf_free(new_mbuf); frees an mbuf that is still owned by the buffer ring. The next Rx burst will hand a freed mbuf back to the application (or the NIC will DMA into freed memory once the descriptor is rearmed). Set new_mbuf = NULL at the start of every loop iteration, or only free new_mbuf when this iteration actually allocated it.

Warning: sxe2_rx_pkts_scattered_split() also writes cur_mbuf->next = new_mbuf_pay (in the first_seg != NULL branch) before any of the subsequent failure checks. If a later step in the same iteration would fail, the mbuf chain is left in an inconsistent state. Reorder so the chain is updated only after all allocations succeed.

Warning: sxe2_tx_pkts_prepare() declares its tx_queue parameter as __rte_unused void *tx_queue but uses txq->ring_depth. Drop the __rte_unused annotation.

Warning: sxe2_set_common_function() assigns dev->rx_pkt_burst = sxe2_rx_pkts_scattered; but sxe2_rx_mode_func_set() (called later from dev_start) unconditionally overwrites it. The first assignment is either dead code or needs to gate on something — pick one.

Info: sxe2_rx_mode_func_set() always selects a scattered Rx burst regardless of dev->data->scattered_rx, and without checking whether MTU exceeds rx_buf_len. The non-scattered fast path is never reachable. Either add a non-scattered burst function and dispatch on scattered_rx, or document that this PMD always uses scattered Rx and remove the unused split between "scattered" and "single-buffer" code paths.

Info: sxe2_txrx.c is hit by a large reformatting of already-correct code in patch 10 (whitespace removal). Either keep the blank lines from patch 9, or do the reflow as a single dedicated cleanup patch.

Patch 10/10 net/sxe2: add vectorized Rx and Tx
-----------------------------------------------

Error (critical): sxe2_rx_mode_func_set() in sxe2_txrx.c selects the SSE vector Rx burst and then immediately overwrites it:

	#ifdef RTE_ARCH_X86
		if (rx_mode_flags & SXE2_RX_MODE_VEC_SET_MASK)
			dev->rx_pkt_burst = sxe2_rx_pkts_scattered_vec_sse_offload;
	#endif
		if (sxe2_rx_offload_en_check(dev, RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT))
			dev->rx_pkt_burst = sxe2_rx_pkts_scattered_split;
		else
			dev->rx_pkt_burst = sxe2_rx_pkts_scattered;

The vector path is never used in practice. Restructure to either an if/else if/else, or gate the scalar selection on !vec_path.

Error: sxe2_rx_queue_vec_init() in sxe2_txrx_vec.c constructs an mbuf on the stack, sets only buf_addr, nb_segs, data_off, port and refcnt, then reads *(u64 *)&mbuf_def.rearm_data. This is correct only as long as rearm_data exactly aliases those four fields and nothing else; this is fragile across DPDK releases. memset() the struct to zero first, then assign the fields.

Warning: meson.build adds a Windows-only branch inside if arch_subdir == 'x86':

	if arch_subdir == 'x86'
		sources += files('sxe2_txrx_vec_sse.c')
		if is_windows and cc.get_id() != 'clang'
			cflags += ['-fno-asynchronous-unwind-tables']
		endif
	endif

But the top of meson.build for net/sxe2 already does if is_windows: build = false; subdir_done(), so is_windows is always false here. Dead branch — drop it.

Warning: the global static sxe2_net_map_addr_info_pf table loses its trailing comments in this patch (the SXE2_PCI_MAP_RES_* identifiers no longer label each row). Either keep the labels or convert the table to designated initialisers [SXE2_PCI_MAP_RES_DOORBELL_TX] = { ... }.

Warning: sxe2_tx_queue_mbufs_release_vec() does rte_pktmbuf_free_seg(buffer[i].mbuf) without checking buffer[i].mbuf for NULL. rte_pktmbuf_free_seg() handles NULL on current DPDK, but the rest of this driver guards explicitly; do the same here for consistency.

Warning: sxe2_rx_mode_func_set() and sxe2_tx_mode_func_set() set rx_mode_flags = 0 / tx_mode_flags = 0, then check (rx_mode_flags & SXE2_RX_MODE_VEC_SET_MASK) == 0 / similar inside an if block before any flag has been set — those conditions are tautologically true. Either seed the flags from the caps result first, or drop the redundant guard.

Info: sxe2_rx_mode_func_set() ends with a goto l_end;\nl_end: that immediately follows — the goto is a no-op, drop it.

Info: sxe2_tx_burst_mode_get() / sxe2_rx_burst_mode_get() list only the scalar and SSE variants in their infos[] table, but the AVX2/AVX512 selection in sxe2_tx_mode_func_set() can in principle assign a non-SSE burst function to dev->tx_pkt_burst. Either include the AVX paths or drop the AVX selection logic.

#141 lore raw

Re: [PATCH v3 0/9] net/sxe2: added Linkdata sxe2 ethernet driver

In reply to [email protected]
Quoted 6 lines · On Thu, 30 Apr 2026 18:18:08 +0800 [email protected] wrote:

From: Jie Liu <[email protected]>

This patch set implements core functionality for the SXE PMD, which is a Linkdata sxe2 ethernet driver.

V3: Addressed AI comments

Please limit submissions of patch update to one bundle per day. Our CI is a limited resource.

#142 lore raw

Re: [PATCH v3 0/9] net/sxe2: added Linkdata sxe2 ethernet driver

In reply to [email protected]
Quoted 86 lines · On Thu, 30 Apr 2026 18:18:08 +0800 [email protected] wrote:

From: Jie Liu <[email protected]>

This patch set implements core functionality for the SXE PMD, which is a Linkdata sxe2 ethernet driver.

V3: Addressed AI comments

Jie Liu (9):
mailmap: add Jie Liu
doc: add sxe2 guide and release notes
drivers: add sxe2 basic structures common/sxe2: add base driver skeleton
drivers: add base driver probe skeleton
drivers: support PCI BAR mapping
common/sxe2: add ioctl interface for DMA map and unmap net/sxe2: support queue setup and control net/sxe2: add data path for Rx and Tx

 .mailmap                                   |   1 +
 doc/guides/nics/features/sxe2.ini          |  11 +
 doc/guides/nics/index.rst                  |   1 +
 doc/guides/nics/sxe2.rst                   |  23 +
 doc/guides/rel_notes/release_26_07.rst     |   3 +
 drivers/common/sxe2/meson.build            |  15 +
 drivers/common/sxe2/sxe2_common.c          | 684 +++++++++++++++
 drivers/common/sxe2/sxe2_common.h          |  86 ++
 drivers/common/sxe2/sxe2_common_log.c      |  75 ++
 drivers/common/sxe2/sxe2_common_log.h      | 263 ++++++
 drivers/common/sxe2/sxe2_errno.h           | 110 +++
 drivers/common/sxe2/sxe2_host_regs.h       | 707 +++++++++++++++
 drivers/common/sxe2/sxe2_internal_ver.h    |  33 +
 drivers/common/sxe2/sxe2_ioctl_chnl.c      | 326 +++++++
 drivers/common/sxe2/sxe2_ioctl_chnl.h      | 141 +++
 drivers/common/sxe2/sxe2_ioctl_chnl_func.h |  63 ++
 drivers/common/sxe2/sxe2_osal.h            | 582 ++++++++++++
 drivers/common/sxe2/sxe2_type.h            |  64 ++
 drivers/meson.build                        |   1 +
 drivers/net/meson.build                    |   1 +
 drivers/net/sxe2/meson.build               |  26 +
 drivers/net/sxe2/sxe2_cmd_chnl.c           | 319 +++++++
 drivers/net/sxe2/sxe2_cmd_chnl.h           |  33 +
 drivers/net/sxe2/sxe2_drv_cmd.h            | 398 +++++++++
 drivers/net/sxe2/sxe2_ethdev.c             | 975 +++++++++++++++++++++
 drivers/net/sxe2/sxe2_ethdev.h             | 316 +++++++
 drivers/net/sxe2/sxe2_irq.h                |  49 ++
 drivers/net/sxe2/sxe2_queue.c              |  39 +
 drivers/net/sxe2/sxe2_queue.h              | 227 +++++
 drivers/net/sxe2/sxe2_rx.c                 | 579 ++++++++++++
 drivers/net/sxe2/sxe2_rx.h                 |  34 +
 drivers/net/sxe2/sxe2_tx.c                 | 447 ++++++++++
 drivers/net/sxe2/sxe2_tx.h                 |  32 +
 drivers/net/sxe2/sxe2_txrx.c               | 249 ++++++
 drivers/net/sxe2/sxe2_txrx.h               |  21 +
 drivers/net/sxe2/sxe2_txrx_common.h        | 541 ++++++++++++
 drivers/net/sxe2/sxe2_txrx_poll.c          | 782 +++++++++++++++++
 drivers/net/sxe2/sxe2_txrx_poll.h          |  16 +
 drivers/net/sxe2/sxe2_vsi.c                | 211 +++++
 drivers/net/sxe2/sxe2_vsi.h                | 205 +++++
 40 files changed, 8689 insertions(+)
 create mode 100644 doc/guides/nics/features/sxe2.ini
 create mode 100644 doc/guides/nics/sxe2.rst
 create mode 100644 drivers/common/sxe2/meson.build
 create mode 100644 drivers/common/sxe2/sxe2_common.c
 create mode 100644 drivers/common/sxe2/sxe2_common.h
 create mode 100644 drivers/common/sxe2/sxe2_common_log.c
 create mode 100644 drivers/common/sxe2/sxe2_common_log.h
 create mode 100644 drivers/common/sxe2/sxe2_errno.h
 create mode 100644 drivers/common/sxe2/sxe2_host_regs.h
 create mode 100644 drivers/common/sxe2/sxe2_internal_ver.h
 create mode 100644 drivers/common/sxe2/sxe2_ioctl_chnl.c
 create mode 100644 drivers/common/sxe2/sxe2_ioctl_chnl.h
 create mode 100644 drivers/common/sxe2/sxe2_ioctl_chnl_func.h
 create mode 100644 drivers/common/sxe2/sxe2_osal.h
 create mode 100644 drivers/common/sxe2/sxe2_type.h
 create mode 100644 drivers/net/sxe2/meson.build
 create mode 100644 drivers/net/sxe2/sxe2_cmd_chnl.c
 create mode 100644 drivers/net/sxe2/sxe2_cmd_chnl.h
 create mode 100644 drivers/net/sxe2/sxe2_drv_cmd.h
 create mode 100644 drivers/net/sxe2/sxe2_ethdev.c
 create mode 100644 drivers/net/sxe2/sxe2_ethdev.h
 create mode 100644 drivers/net/sxe2/sxe2_irq.h
 create mode 100644 drivers/net/sxe2/sxe2_queue.c
 create mode 100644 drivers/net/sxe2/sxe2_queue.h
 create mode 100644 drivers/net/sxe2/sxe2_rx.c
 create mode 100644 drivers/net/sxe2/sxe2_rx.h
 create mode 100644 drivers/net/sxe2/sxe2_tx.c
Quoted 9 lines
 create mode 100644 drivers/net/sxe2/sxe2_tx.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx.c
 create mode 100644 drivers/net/sxe2/sxe2_txrx.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_common.h
 create mode 100644 drivers/net/sxe2/sxe2_txrx_poll.c
 create mode 100644 drivers/net/sxe2/sxe2_txrx_poll.h
 create mode 100644 drivers/net/sxe2/sxe2_vsi.c
 create mode 100644 drivers/net/sxe2/sxe2_vsi.h

Since this is a large patch series turned to command line use of AGENTS.md for AI review and cot this nice summary. Lots to fix here.

● Deep Dive Analysis of bundle-1856.mbox DPDK Patch Series

Executive Summary

This patch series introduces the SXE2 Poll Mode Driver (PMD) for DPDK, submitted by Jie Liu from Linkdata Technology (formerly Wuxi Stars Micro System Technologies Co., Ltd.). The driver provides support for 10/25/50/100/200 Gbps Network Adapters with embedded switch
functionality, Physical Functions (PF), and SR-IOV Virtual Functions (VF).

---
Patch Series Overview

The series consists of 9 patches (v3 revision):

1. Patch 1/9: Mailmap update - adds contributor entry
2. Patch 2/9: Documentation - guide and release notes for SXE2 PMD
3. Patch 3/9: Basic structures - common library infrastructure (1959 lines)
4. Patch 4/9: Base driver skeleton - core functionality
5. Patch 5/9: Probe skeleton - PCI device initialization
6. Patch 6/9: PCI BAR mapping support
7. Patch 7/9: DMA mapping via ioctl interface
8. Patch 8/9: Queue setup and control (1161 lines)
9. Patch 9/9: Data path implementation for Rx/Tx (1076 lines)

---
Technical Architecture Analysis

1. Driver Structure

- Common library (drivers/common/sxe2/) - shared functionality
- Network driver (drivers/net/sxe2/) - ethernet-specific implementation
- Uses DPDK's standard PMD framework with proper eth_dev_ops callbacks

2. Key Components

- OSAL (OS Abstraction Layer): Platform-independent interface
- Logging system: Dual logging to console and file (/var/log/sxe2pmd.log.*)
- Command channel: Communication with hardware via ioctl
- DMA mapping: User-space to device memory mapping

3. Hardware Interface

- Supports multiple speeds: 10/25/50/100/200 Gbps
- Virtual memory address handling for security
- Embedded switch support
- SR-IOV capability

---
Code Quality Issues Identified

Critical Issues

1. License Header Inconsistency
- Line 355: # Copyright (c) 2023 Corigine, Inc. in meson.build
- All other files show 2025 Wuxi/Linkdata copyright
- Impact: Legal/compliance issue - appears to be copy-pasted from another driver
2. Custom Type Definitions
- Lines 2327-2339: Defines custom types (u8, u16, u32, u64, s8, etc.)
- Problem: Goes against DPDK coding standards which prefer standard types
- Recommendation: Use uint8_t, uint16_t, etc. directly
3. Debug Logging to File System
- Lines 386-427: Creates log files in /var/log/ during debug mode
- Issues:
- No permission checking
- No disk space validation
- Could fail in containerized environments
- Security concern: world-readable logs

Moderate Issues

4. Excessive Macro Complexity
- Lines 514-652: Complex nested logging macros
- Multiple levels of macro expansion
- Makes debugging difficult
5. Missing Error Handling
- Line 421: goto l_end pattern used but incomplete error paths
- Some functions don't check all allocation failures
6. Documentation Quality
- Line 191: Missing newline at end of sxe2.ini file
- Minimal driver documentation in sxe2.rst
- No performance tuning guidance

Minor Issues

7. Code Style
- Inconsistent use of tabs vs spaces
- Non-standard label naming (l_end: instead of descriptive names)
- Mixed naming conventions (snake_case and camelCase)
8. Thread ID Portability
- Lines 495-498: Windows/Linux compatibility code seems incomplete
- pthread_self() cast to uint64_t may cause issues on some platforms

---
Security Considerations

1. DMA Mapping Interface
- Patch 7/9 implements ioctl-based DMA mapping
- Positive: Includes proper IOVA mode checking
- Concern: No apparent validation of user-provided addresses/sizes
2. Memory Safety
- Uses rte_memcpy and safe string functions
- No obvious buffer overflows detected
3. Virtual Memory Handling
- Claims to only work with virtual addresses for security
- Good design choice for isolation

---
Performance Considerations

1. Data Path
- Patch 9/9 mentions "loop unrolling and prefetching"
- Standard PMD burst interface implementation
- No vector instructions optimization visible
2. Queue Management
- Proper separation of Rx/Tx queue setup
- Hardware tail pointer updates for efficiency

---
Recommendations

Must Fix Before Merge

1. Remove or correct the Corigine copyright in meson.build
2. Replace custom type definitions with standard DPDK types
3. Add proper error handling for file operations
4. Validate DMA mapping parameters

Should Improve

1. Enhance documentation with usage examples
2. Simplify logging macro hierarchy
3. Add performance tuning guide
4. Include test cases

Nice to Have

1. Vector PMD implementation for better performance
2. More comprehensive feature set in sxe2.ini
3. Debugging/troubleshooting guide

---
Overall Assessment

The SXE2 PMD shows a structured approach to DPDK driver development with proper separation of concerns between common and network-specific code. However, several code quality and compliance issues need addressing before the patch series is ready for merge.

Rating: 6/10 - Functional but needs significant cleanup