common/sxe2: add common functions for sxe2 driver
Subsystems (2)
cover common/sxe2: add common functions for sxe2 driver
From: Jie Liu <[email protected]>
This patch set implements core functionality for the SXE2 PMD, including basic driver framework, data path setup.
V1:
- Add sxe2 adapter
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 | 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_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 | 65 ++ drivers/meson.build | 1 + drivers/net/meson.build | 1 + drivers/net/sxe2/meson.build | 25 + 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 | 974 +++++++++++++++++++++ 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 | 815 +++++++++++++++++ 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, 8831 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
PATCH 1/9 mailmap: add Jie Liu
From: Jie Liu <[email protected]>
--- .mailmap | 1 + 1 file changed, 1 insertion(+)
.mailmap +1 -0
@@ -738,6 +738,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
PATCH 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 | 3 +++ 4 files changed, 38 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
@@ -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
doc/guides/nics/index.rst +1 -0
@@ -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
@@ -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 +3 -0
@@ -55,6 +55,9 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added Linkdata sxe2 ethernet driver.** + + Added network driver for the Linkdata Network Adapters. Removed Items -------------
Signature · 1 line
2.47.3
PATCH 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 | 13 + 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, 1959 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 +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2023 Corigine, Inc. + +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
@@ -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
@@ -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
PATCH 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
@@ -9,5 +9,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
PATCH 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 | 22 + 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, 3025 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
@@ -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
@@ -38,6 +38,15 @@ __rte_internals32 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
@@ -58,6 +58,7 @@ drivers = [ 'rnp', 'sfc', 'softnic', + 'sxe2', 'tap', 'thunderx', 'txgbe',
drivers/net/sxe2/meson.build new file +22 -0
@@ -0,0 +1,22 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd. +#执行子目录base,并获取目标对象 + +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
@@ -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
@@ -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
@@ -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
165 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.
PATCH 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
@@ -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) s32sxe2_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
@@ -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
PATCH 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
@@ -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
@@ -47,6 +47,15 @@ __rte_internals32 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
PATCH 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
@@ -17,6 +17,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
@@ -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
@@ -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
@@ -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
PATCH 9/9 net/sxe2: 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/net/sxe2/meson.build | 1 + drivers/net/sxe2/sxe2_ethdev.c | 6 + drivers/net/sxe2/sxe2_txrx.c | 249 +++++++++ drivers/net/sxe2/sxe2_txrx.h | 21 + drivers/net/sxe2/sxe2_txrx_poll.c | 815 ++++++++++++++++++++++++++++++ 5 files changed, 1092 insertions(+) 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/net/sxe2/meson.build +1 -0
@@ -19,6 +19,7 @@ sources += files( 'sxe2_queue.c', 'sxe2_tx.c', 'sxe2_rx.c', + 'sxe2_txrx_poll.c', ) allow_internal_get_api = true
drivers/net/sxe2/sxe2_ethdev.c +6 -0
@@ -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" );
@@ -760,6 +764,8 @@ static s32 sxe2_dev_init(struct rte_eth_dev *dev, struct sxe2_dev_kvargs_info *kPMD_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
@@ -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 +815 -0
815 lines not on this page · raw message
Signature · 1 line
2.47.3
v2 cover net/sxe2: added Linkdata sxe2 ethernet driver
From: Jie Liu <[email protected]>
This patch set implements core functionality for the SXE PMD, which is a Linkdata sxe2 ethernet driver.
V1:
- 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 | 974 +++++++++++++++++++++ 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, 8688 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
PATCH v2 1/9 mailmap: add Jie Liu
From: Jie Liu <[email protected]>
--- .mailmap | 1 + 1 file changed, 1 insertion(+)
.mailmap +1 -0
@@ -738,6 +738,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
PATCH v2 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 | 3 +++ 4 files changed, 38 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
@@ -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
doc/guides/nics/index.rst +1 -0
@@ -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
@@ -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 +3 -0
@@ -55,6 +55,9 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added Linkdata sxe2 ethernet driver.** + + Added network driver for the Linkdata Network Adapters. Removed Items -------------
Signature · 1 line
2.47.3
PATCH v2 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 | 13 + 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, 1959 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 +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2023 Corigine, Inc. + +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
@@ -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
@@ -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
PATCH v2 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
@@ -9,5 +9,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
PATCH v2 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 | 22 + 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, 3025 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
@@ -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
@@ -38,6 +38,15 @@ __rte_internals32 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
@@ -58,6 +58,7 @@ drivers = [ 'rnp', 'sfc', 'softnic', + 'sxe2', 'tap', 'thunderx', 'txgbe',
drivers/net/sxe2/meson.build new file +22 -0
@@ -0,0 +1,22 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd. +#执行子目录base,并获取目标对象 + +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
@@ -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
@@ -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
@@ -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
165 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.
PATCH v2 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
@@ -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) s32sxe2_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
@@ -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
PATCH v2 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
@@ -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
@@ -47,6 +47,15 @@ __rte_internals32 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
PATCH v2 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
@@ -17,6 +17,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
@@ -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
@@ -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
@@ -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
PATCH v2 9/9 net/sxe2: 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_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 | 6 + drivers/net/sxe2/sxe2_txrx.c | 249 ++++++++ drivers/net/sxe2/sxe2_txrx.h | 21 + drivers/net/sxe2/sxe2_txrx_poll.c | 782 ++++++++++++++++++++++++++ 10 files changed, 1071 insertions(+), 122 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_log.h +0 -105
@@ -260,109 +260,4 @@ sxe2_common_log_stream_init(void);#define PMD_INIT_FUNC_TRACE () PMD_LOG_DEBUG(INIT, " >>") -#ifdef SXE2_DPDK_DEBUG - -#define LOG_DEBUG (fmt, ...) \ - PMD_LOG_DEBUG(DRV, fmt, ##__VA_ARGS__) - -#define LOG_INFO (fmt, ...) \ - PMD_LOG_INFO(DRV, fmt, ##__VA_ARGS__) - -#define LOG_WARN (fmt, ...) \ - PMD_LOG_WARN(DRV, fmt, ##__VA_ARGS__) - -#define LOG_ERROR (fmt, ...) \ - PMD_LOG_ERR(DRV, fmt, ##__VA_ARGS__) - -#define LOG_DEBUG_BDF (dev_name, fmt, ...) \ - PMD_LOG_DEBUG(HW, fmt, ##__VA_ARGS__) - -#define LOG_INFO_BDF (dev_name, fmt, ...) \ - PMD_LOG_INFO(HW, fmt, ##__VA_ARGS__) - -#define LOG_WARN_BDF (dev_name, fmt, ...) \ - PMD_LOG_WARN(HW, fmt, ##__VA_ARGS__) - -#define LOG_ERROR_BDF (dev_name, fmt, ...) \ - PMD_LOG_ERR(HW, fmt, ##__VA_ARGS__) - -#else -#define LOG_DEBUG (fmt, ...) -#define LOG_INFO (fmt, ...) -#define LOG_WARN (fmt, ...) -#define LOG_ERROR (fmt, ...) -#define LOG_DEBUG_BDF (dev_name, fmt, ...) \ - PMD_LOG_DEBUG(HW, fmt, ##__VA_ARGS__) - -#define LOG_INFO_BDF (dev_name, fmt, ...) \ - PMD_LOG_INFO(HW, fmt, ##__VA_ARGS__) - -#define LOG_WARN_BDF (dev_name, fmt, ...) \ - PMD_LOG_WARN(HW, fmt, ##__VA_ARGS__) - -#define LOG_ERROR_BDF (dev_name, fmt, ...) \ - PMD_LOG_ERR(HW, fmt, ##__VA_ARGS__) -#endif - -#ifdef SXE2_DPDK_DEBUG -#define LOG_DEV_DEBUG (fmt, ...) \ - do { \ - RTE_SET_USED(adapter); \ - LOG_DEBUG_BDF(fmt, ##__VA_ARGS__); \ - } while (0) - -#define LOG_DEV_INFO (fmt, ...) \ - do { \ - RTE_SET_USED(adapter); \ - LOG_INFO_BDF(fmt, ##__VA_ARGS__); \ - } while (0) - -#define LOG_DEV_WARN (fmt, ...) \ - do { \ - RTE_SET_USED(adapter); \ - LOG_WARN_BDF(fmt, ##__VA_ARGS__); \ - } while (0) - -#define LOG_DEV_ERR (fmt, ...) \ - do { \ - RTE_SET_USED(adapter); \ - LOG_ERROR_BDF(fmt, ##__VA_ARGS__); \ - } while (0) - -#define LOG_MSG_DEBUG (msglvl, fmt, ...) \ - do { \ - RTE_SET_USED(adapter); \ - LOG_DEBUG_BDF(fmt, ##__VA_ARGS__); \ - } while (0) - -#define LOG_MSG_INFO (msglvl, fmt, ...) \ - do { \ - RTE_SET_USED(adapter); \ - LOG_INFO_BDF(fmt, ##__VA_ARGS__); \ - } while (0) - -#define LOG_MSG_WARN (msglvl, fmt, ...) \ - do { \ - RTE_SET_USED(adapter); \ - LOG_WARN_BDF(fmt, ##__VA_ARGS__); \ - } while (0) - -#define LOG_MSG_ERR (msglvl, fmt, ...) \ - do { \ - RTE_SET_USED(adapter); \ - LOG_ERROR_BDF(fmt, ##__VA_ARGS__); \ - } while (0) - -#else - -#define LOG_DEV_DEBUG (fmt, ...) RTE_SET_USED(adapter) -#define LOG_DEV_INFO (fmt, ...) RTE_SET_USED(adapter) -#define LOG_DEV_WARN (fmt, ...) RTE_SET_USED(adapter) -#define LOG_DEV_ERR (fmt, ...) RTE_SET_USED(adapter) -#define LOG_MSG_DEBUG (msglvl, fmt, ...) RTE_SET_USED(adapter) -#define LOG_MSG_INFO (msglvl, fmt, ...) RTE_SET_USED(adapter) -#define LOG_MSG_WARN (msglvl, fmt, ...) RTE_SET_USED(adapter) -#define LOG_MSG_ERR (msglvl, fmt, ...) RTE_SET_USED(adapter) -#endif -#endif /* SXE2_COMMON_LOG_H__ */
drivers/common/sxe2/sxe2_errno.h +0 -3
@@ -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
@@ -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 @@ voidvoid *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
@@ -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
@@ -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
@@ -19,6 +19,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 +6 -0
@@ -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" );
@@ -760,6 +764,8 @@ static s32 sxe2_dev_init(struct rte_eth_dev *dev, struct sxe2_dev_kvargs_info *kPMD_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
@@ -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
v3 cover net/sxe2: added Linkdata sxe2 ethernet driver
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 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
PATCH v3 1/9 mailmap: add Jie Liu
From: Jie Liu <[email protected]>
--- .mailmap | 1 + 1 file changed, 1 insertion(+)
.mailmap +1 -0
@@ -738,6 +738,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
PATCH v3 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 | 3 +++ 4 files changed, 38 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
@@ -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
doc/guides/nics/index.rst +1 -0
@@ -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
@@ -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 +3 -0
@@ -55,6 +55,9 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added Linkdata sxe2 ethernet driver.** + + Added network driver for the Linkdata Network Adapters. Removed Items -------------
Signature · 1 line
2.47.3
PATCH v3 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 | 13 + 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, 1959 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 +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2023 Corigine, Inc. + +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
@@ -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
@@ -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
PATCH v3 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
@@ -9,5 +9,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
PATCH v3 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 | 22 + 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, 3025 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
@@ -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
@@ -38,6 +38,15 @@ __rte_internals32 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
@@ -58,6 +58,7 @@ drivers = [ 'rnp', 'sfc', 'softnic', + 'sxe2', 'tap', 'thunderx', 'txgbe',
drivers/net/sxe2/meson.build new file +22 -0
@@ -0,0 +1,22 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd. +#执行子目录base,并获取目标对象 + +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
@@ -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
@@ -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
@@ -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
165 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.
PATCH v3 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
@@ -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) s32sxe2_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
@@ -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
PATCH v3 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
@@ -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
@@ -47,6 +47,15 @@ __rte_internals32 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
PATCH v3 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
@@ -17,6 +17,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
@@ -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
@@ -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
@@ -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
PATCH v3 9/9 net/sxe2: 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_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 ++++++++++++++++++++++++++ 10 files changed, 1076 insertions(+), 126 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_log.h +0 -105
@@ -260,109 +260,4 @@ sxe2_common_log_stream_init(void);#define PMD_INIT_FUNC_TRACE () PMD_LOG_DEBUG(INIT, " >>") -#ifdef SXE2_DPDK_DEBUG - -#define LOG_DEBUG (fmt, ...) \ - PMD_LOG_DEBUG(DRV, fmt, ##__VA_ARGS__) - -#define LOG_INFO (fmt, ...) \ - PMD_LOG_INFO(DRV, fmt, ##__VA_ARGS__) - -#define LOG_WARN (fmt, ...) \ - PMD_LOG_WARN(DRV, fmt, ##__VA_ARGS__) - -#define LOG_ERROR (fmt, ...) \ - PMD_LOG_ERR(DRV, fmt, ##__VA_ARGS__) - -#define LOG_DEBUG_BDF (dev_name, fmt, ...) \ - PMD_LOG_DEBUG(HW, fmt, ##__VA_ARGS__) - -#define LOG_INFO_BDF (dev_name, fmt, ...) \ - PMD_LOG_INFO(HW, fmt, ##__VA_ARGS__) - -#define LOG_WARN_BDF (dev_name, fmt, ...) \ - PMD_LOG_WARN(HW, fmt, ##__VA_ARGS__) - -#define LOG_ERROR_BDF (dev_name, fmt, ...) \ - PMD_LOG_ERR(HW, fmt, ##__VA_ARGS__) - -#else -#define LOG_DEBUG (fmt, ...) -#define LOG_INFO (fmt, ...) -#define LOG_WARN (fmt, ...) -#define LOG_ERROR (fmt, ...) -#define LOG_DEBUG_BDF (dev_name, fmt, ...) \ - PMD_LOG_DEBUG(HW, fmt, ##__VA_ARGS__) - -#define LOG_INFO_BDF (dev_name, fmt, ...) \ - PMD_LOG_INFO(HW, fmt, ##__VA_ARGS__) - -#define LOG_WARN_BDF (dev_name, fmt, ...) \ - PMD_LOG_WARN(HW, fmt, ##__VA_ARGS__) - -#define LOG_ERROR_BDF (dev_name, fmt, ...) \ - PMD_LOG_ERR(HW, fmt, ##__VA_ARGS__) -#endif - -#ifdef SXE2_DPDK_DEBUG -#define LOG_DEV_DEBUG (fmt, ...) \ - do { \ - RTE_SET_USED(adapter); \ - LOG_DEBUG_BDF(fmt, ##__VA_ARGS__); \ - } while (0) - -#define LOG_DEV_INFO (fmt, ...) \ - do { \ - RTE_SET_USED(adapter); \ - LOG_INFO_BDF(fmt, ##__VA_ARGS__); \ - } while (0) - -#define LOG_DEV_WARN (fmt, ...) \ - do { \ - RTE_SET_USED(adapter); \ - LOG_WARN_BDF(fmt, ##__VA_ARGS__); \ - } while (0) - -#define LOG_DEV_ERR (fmt, ...) \ - do { \ - RTE_SET_USED(adapter); \ - LOG_ERROR_BDF(fmt, ##__VA_ARGS__); \ - } while (0) - -#define LOG_MSG_DEBUG (msglvl, fmt, ...) \ - do { \ - RTE_SET_USED(adapter); \ - LOG_DEBUG_BDF(fmt, ##__VA_ARGS__); \ - } while (0) - -#define LOG_MSG_INFO (msglvl, fmt, ...) \ - do { \ - RTE_SET_USED(adapter); \ - LOG_INFO_BDF(fmt, ##__VA_ARGS__); \ - } while (0) - -#define LOG_MSG_WARN (msglvl, fmt, ...) \ - do { \ - RTE_SET_USED(adapter); \ - LOG_WARN_BDF(fmt, ##__VA_ARGS__); \ - } while (0) - -#define LOG_MSG_ERR (msglvl, fmt, ...) \ - do { \ - RTE_SET_USED(adapter); \ - LOG_ERROR_BDF(fmt, ##__VA_ARGS__); \ - } while (0) - -#else - -#define LOG_DEV_DEBUG (fmt, ...) RTE_SET_USED(adapter) -#define LOG_DEV_INFO (fmt, ...) RTE_SET_USED(adapter) -#define LOG_DEV_WARN (fmt, ...) RTE_SET_USED(adapter) -#define LOG_DEV_ERR (fmt, ...) RTE_SET_USED(adapter) -#define LOG_MSG_DEBUG (msglvl, fmt, ...) RTE_SET_USED(adapter) -#define LOG_MSG_INFO (msglvl, fmt, ...) RTE_SET_USED(adapter) -#define LOG_MSG_WARN (msglvl, fmt, ...) RTE_SET_USED(adapter) -#define LOG_MSG_ERR (msglvl, fmt, ...) RTE_SET_USED(adapter) -#endif -#endif /* SXE2_COMMON_LOG_H__ */
drivers/common/sxe2/sxe2_errno.h +0 -3
@@ -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
@@ -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 @@ voidvoid *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
@@ -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
@@ -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
@@ -19,6 +19,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
@@ -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 *kPMD_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
@@ -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
v4 cover net/sxe2: added Linkdata sxe2 ethernet driver
From: Jie Liu <[email protected]>
This patch set implements core functionality for the SXE PMD driver.
V4:
- 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 | 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 | 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, 8688 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
PATCH v4 1/9 mailmap: add Jie Liu
From: Jie Liu <[email protected]>
--- .mailmap | 1 + 1 file changed, 1 insertion(+)
.mailmap +1 -0
@@ -738,6 +738,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
PATCH v4 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 | 3 +++ 4 files changed, 38 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
@@ -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
doc/guides/nics/index.rst +1 -0
@@ -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
@@ -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 +3 -0
@@ -55,6 +55,9 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added Linkdata sxe2 ethernet driver.** + + Added network driver for the Linkdata Network Adapters. Removed Items -------------
Signature · 1 line
2.47.3
PATCH v4 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 | 13 + 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, 1959 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 +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2023 Corigine, Inc. + +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
@@ -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
@@ -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
Re: [PATCH v4 3/9] drivers: add sxe2 basic structures
Quoted 7 lines · On Fri, 1 May 2026 09:59:18 +0800 [email protected] wrote:
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.
Quoted 7 lines
Specifically, this commit:
- Implements the logging stream management usingRTE_LOG_LINE.
- Defines device-specific error codes and status registers.
- Adds the initial meson build configuration for the common library.Signed-off-by Jie Liu <[email protected]>---
NAK.
NAK.
DPDK drivers must not reinvent their own logging, and they absolutely must not hijack the log stream that is shared with the application and the rest of DPDK. This patch does both.
Concrete problems in what you posted:
1. PMD_LOG_NOTICE/WARN/ERR/CRIT/ALERT/EMERG call rte_openlog_stream(g_sxe2_common_log_fp) before logging and rte_openlog_stream(NULL) after. rte_openlog_stream() sets the *global* DPDK log stream for the entire application. A driver has no business deciding where the application's logs go. As written, this will silently redirect every other PMD's, every library's, and the application's own output any time sxe2 emits a message.
2. Those same macros emit the message twice -- once before the stream is swapped and once after -- so every NOTICE/WARN/ERR comes out duplicated.
3. Drivers must not open files. fopen("/var/log/sxe2pmd.log.<ts>", "w+") from inside a PMD is a security problem on every level:
- It runs with whatever privileges the application has, which for DPDK is typically root or CAP_*-loaded. Creating files in /var/log under those privileges is a classic symlink / TOCTOU attack surface.
- The path is attacker-influenceable in the timestamp component and is not created with O_CREAT|O_EXCL, no mode argument, no directory fd, none of the hardening you would expect.
- Log content is written without any escaping; anything an attacker can get into a log message ends up in a file the operator will later cat or grep.
- It bypasses whatever logging policy the operator, distro, systemd unit, container runtime, SELinux/AppArmor profile, or application has configured. A driver silently writing to /var/log is exactly the kind of thing those policies exist to prevent.
- It doesn't work for non-root users, in unprivileged containers, on read-only rootfs systems, or on Windows.
Drivers log through rte_log. The application decides where those logs go. Full stop.
4. RTE_LOG_REGISTER_SUFFIX(..., com, DEBUG) defaults the log type to DEBUG. The default level is the application's choice, not the driver's.
5. SXE2_DPDK_DEBUG is unconditionally defined in drivers/common/sxe2/meson.build, so the "debug" path with the file hijacking is always on. There is no off switch.
6. SXE2_PMD_LOG adds a thread id, basename, line number, and function name to every line. If those are useful, they are useful for every driver -- not just yours.
General principles, which apply to every driver:
- Drivers do not reinvent logging. Use RTE_LOG / RTE_LOG_LINE and a log type registered for the driver. That is it.
- Drivers do not open files, and do not change logging behavior that is shared with the application or with other drivers. Both have security implications well beyond this driver.
- If something is genuinely missing from the common logging infrastructure -- per-driver log files, richer prefixes, thread ids, structured fields, whatever -- propose it as a change to lib/log so every driver and every application benefits, and so it gets reviewed for security by people who do that for a living. Do not bury it inside one driver.
- "It works for our embedded use case" is not an argument. DPDK runs on Linux, FreeBSD, and Windows; on x86, Arm, POWER, and RISC-V; in bare metal, VMs, and containers; as root and as unprivileged users. A driver has to behave reasonably in all of those.
- Once we make an exception for one driver, every subsystem will expect one. That is not happening.
Please drop sxe2_common_log.c and sxe2_common_log.h entirely. Use the existing RTE_LOG_* macros directly against a log type registered for your driver, and respect the level and stream that the application has configured.
While you're at it, the same "this driver is a special snowflake" pattern shows up elsewhere in this series and gets the same answer:
- sxe2_type.h redefines u8/u16/u32/u64/s8/.../__le16/__be32 instead of using uintN_t and rte_beN_t.
- sxe2_errno.h reinvents errno values that already exist.
- sxe2_osal.h re-implements bitmap operations, allocation wrappers, and an OS abstraction layer that DPDK already provides.
This is the cost of being part of a shared community project across many platforms and architectures. Please rework on that basis before reposting.
Stephen
PS: AI revised this text, my initial version was probably not safe for public consumption.
PATCH v4 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
@@ -9,5 +9,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
PATCH v4 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 | 22 + 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, 3025 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
@@ -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
@@ -38,6 +38,15 @@ __rte_internals32 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
@@ -58,6 +58,7 @@ drivers = [ 'rnp', 'sfc', 'softnic', + 'sxe2', 'tap', 'thunderx', 'txgbe',
drivers/net/sxe2/meson.build new file +22 -0
@@ -0,0 +1,22 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd. +#执行子目录base,并获取目标对象 + +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
@@ -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
@@ -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
@@ -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
165 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.
PATCH v4 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
@@ -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) s32sxe2_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
@@ -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
PATCH v4 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
@@ -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
@@ -47,6 +47,15 @@ __rte_internals32 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
PATCH v4 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
@@ -17,6 +17,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
@@ -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
@@ -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
@@ -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
PATCH v4 9/9 net/sxe2: 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
@@ -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
@@ -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
@@ -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 @@ voidvoid *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
@@ -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
@@ -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
@@ -19,6 +19,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
@@ -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 *kPMD_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
@@ -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
v5 cover net/sxe2: added Linkdata sxe2 ethernet driver
From: Jie Liu <[email protected]>
V5:
- 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 | 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 | 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, 8688 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
PATCH v5 1/9 mailmap: add Jie Liu
From: Jie Liu <[email protected]>
Add Jie Liu's email to .mailmap file to ensure consistent author attribution across all commits. This helps maintain clean git history and ensures correct author information in release notes and changelogs.
--- .mailmap | 1 + 1 file changed, 1 insertion(+)
.mailmap +1 -0
@@ -738,6 +738,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
PATCH v5 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 | 3 +++ 4 files changed, 38 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
@@ -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
doc/guides/nics/index.rst +1 -0
@@ -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
@@ -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 +3 -0
@@ -55,6 +55,9 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added Linkdata sxe2 ethernet driver.** + + Added network driver for the Linkdata Network Adapters. Removed Items -------------
Signature · 1 line
2.47.3
PATCH v5 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 | 13 + 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, 1959 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 +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2023 Corigine, Inc. + +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
@@ -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
@@ -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
Re: [PATCH v5 3/9] drivers: add sxe2 basic structures
Quoted 7 lines · On Fri, 1 May 2026 11:33:53 +0800 [email protected] wrote:
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.
Quoted 7 lines
Specifically, this commit:
- Implements the logging stream management usingRTE_LOG_LINE.
- Defines device-specific error codes and status registers.
- Adds the initial meson build configuration for the common library.Signed-off-by Jie Liu <[email protected]>---
You ignored the feed back about drivers writing files and changing logging.
PATCH v5 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
@@ -9,5 +9,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
PATCH v5 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 | 22 + 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, 3025 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
@@ -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
@@ -38,6 +38,15 @@ __rte_internals32 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
@@ -58,6 +58,7 @@ drivers = [ 'rnp', 'sfc', 'softnic', + 'sxe2', 'tap', 'thunderx', 'txgbe',
drivers/net/sxe2/meson.build new file +22 -0
@@ -0,0 +1,22 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd. +#执行子目录base,并获取目标对象 + +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
@@ -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
@@ -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
@@ -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
165 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.
PATCH v5 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
@@ -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) s32sxe2_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
@@ -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
PATCH v5 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
@@ -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
@@ -47,6 +47,15 @@ __rte_internals32 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
PATCH v5 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
@@ -17,6 +17,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
@@ -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
@@ -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
@@ -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
PATCH v5 9/9 net/sxe2: 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
@@ -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
@@ -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
@@ -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 @@ voidvoid *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
@@ -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
@@ -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
@@ -19,6 +19,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
@@ -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 *kPMD_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
@@ -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
v6 cover Add sxe2 driver
From: Jie Liu <[email protected]>
V6:
- 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 | 15 + 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 | 35 + 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 | 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 | 368 ++++++++ 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 | 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 | 549 ++++++++++++ drivers/net/sxe2/sxe2_vsi.c | 211 +++++ drivers/net/sxe2/sxe2_vsi.h | 205 +++++ 44 files changed, 10042 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
PATCH v6 1/10 mailmap: add Jie Liu
From: Jie Liu <[email protected]>
--- .mailmap | 1 + 1 file changed, 1 insertion(+)
.mailmap +1 -0
@@ -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
PATCH v6 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
@@ -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
doc/guides/nics/index.rst +1 -0
@@ -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
@@ -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
@@ -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
PATCH v6 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 | 13 + 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, 1959 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 +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2023 Corigine, Inc. + +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
@@ -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
@@ -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
PATCH v6 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
@@ -9,5 +9,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
PATCH v6 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 | 22 + 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, 3025 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
@@ -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
@@ -38,6 +38,15 @@ __rte_internals32 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
@@ -58,6 +58,7 @@ drivers = [ 'rnp', 'sfc', 'softnic', + 'sxe2', 'tap', 'thunderx', 'txgbe',
drivers/net/sxe2/meson.build new file +22 -0
@@ -0,0 +1,22 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd. +#执行子目录base,并获取目标对象 + +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
@@ -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
@@ -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
@@ -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
165 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.
PATCH v6 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
@@ -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) s32sxe2_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
@@ -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
PATCH v6 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
@@ -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
@@ -47,6 +47,15 @@ __rte_internals32 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
PATCH v6 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
@@ -17,6 +17,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
@@ -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
@@ -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
@@ -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
PATCH v6 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
@@ -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
@@ -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
@@ -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 @@ voidvoid *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
@@ -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
@@ -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
@@ -19,6 +19,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
@@ -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 *kPMD_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
@@ -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
PATCH v6 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 | 9 + drivers/net/sxe2/sxe2_ethdev.c | 8 +- drivers/net/sxe2/sxe2_txrx.c | 227 +++++++--- drivers/net/sxe2/sxe2_txrx.h | 12 +- drivers/net/sxe2/sxe2_txrx_poll.c | 184 ++++++++ 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 | 549 ++++++++++++++++++++++++ 10 files changed, 1420 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 +9 -0
@@ -12,6 +12,14 @@ cflags += ['-g'] deps += ['common_sxe2', 'hash','cryptodev','security'] +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',
@@ -21,6 +29,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
@@ -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_txrx.c +173 -54
376 lines not on this page · raw message
drivers/net/sxe2/sxe2_txrx.h +6 -6
@@ -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 +184 -0
196 lines not on this page · raw message
drivers/net/sxe2/sxe2_txrx_poll.h +2 -1
@@ -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 +549 -0
549 lines not on this page · raw message
Signature · 1 line
2.47.3
v7 cover Add Linkdata sxe2 driver
From: Jie Liu <[email protected]>
V7:
- Addressed AI comments
V6:
- Addressed AI comments
Jie Liu (10):
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
net/sxe2: add AVX2 vector data path for Rx and Tx
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 | 15 + 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 | 46 + 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 | 384 ++++++++ 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 | 188 ++++ drivers/net/sxe2/sxe2_txrx_vec.h | 78 ++ drivers/net/sxe2/sxe2_txrx_vec_avx2.c | 749 ++++++++++++++++ drivers/net/sxe2/sxe2_txrx_vec_common.h | 235 +++++ drivers/net/sxe2/sxe2_txrx_vec_sse.c | 549 ++++++++++++ drivers/net/sxe2/sxe2_vsi.c | 211 +++++ drivers/net/sxe2/sxe2_vsi.h | 205 +++++ 44 files changed, 10822 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_avx2.c 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
PATCH v7 1/10 doc: add sxe2 guide and release notes
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
@@ -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
doc/guides/nics/index.rst +1 -0
@@ -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
@@ -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
@@ -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
PATCH v7 2/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 | 13 + 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, 1959 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 +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2023 Corigine, Inc. + +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
@@ -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
@@ -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
PATCH v7 3/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
@@ -9,5 +9,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
PATCH v7 4/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 | 22 + 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, 3025 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
@@ -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
@@ -38,6 +38,15 @@ __rte_internals32 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
@@ -58,6 +58,7 @@ drivers = [ 'rnp', 'sfc', 'softnic', + 'sxe2', 'tap', 'thunderx', 'txgbe',
drivers/net/sxe2/meson.build new file +22 -0
@@ -0,0 +1,22 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd. +#执行子目录base,并获取目标对象 + +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
@@ -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
@@ -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
@@ -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
165 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.
PATCH v7 5/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
@@ -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) s32sxe2_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
@@ -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
PATCH v7 6/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
@@ -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
@@ -47,6 +47,15 @@ __rte_internals32 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
PATCH v7 7/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
@@ -17,6 +17,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
@@ -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
@@ -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
@@ -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
PATCH v7 8/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
@@ -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
@@ -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
@@ -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 @@ voidvoid *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
@@ -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
@@ -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
@@ -19,6 +19,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
@@ -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 *kPMD_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
@@ -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
PATCH v7 9/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 | 9 + drivers/net/sxe2/sxe2_ethdev.c | 8 +- drivers/net/sxe2/sxe2_txrx.c | 227 +++++++--- drivers/net/sxe2/sxe2_txrx.h | 12 +- drivers/net/sxe2/sxe2_txrx_poll.c | 184 ++++++++ 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 | 549 ++++++++++++++++++++++++ 10 files changed, 1420 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 +9 -0
@@ -12,6 +12,14 @@ cflags += ['-g'] deps += ['common_sxe2', 'hash','cryptodev','security'] +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',
@@ -21,6 +29,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
@@ -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_txrx.c +173 -54
376 lines not on this page · raw message
drivers/net/sxe2/sxe2_txrx.h +6 -6
@@ -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 +184 -0
196 lines not on this page · raw message
drivers/net/sxe2/sxe2_txrx_poll.h +2 -1
@@ -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 +549 -0
549 lines not on this page · raw message
Signature · 1 line
2.47.3
v8 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 | 15 + 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 | 35 + 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 | 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 | 369 ++++++++ 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 | 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 ++++++++++++ drivers/net/sxe2/sxe2_vsi.c | 211 +++++ drivers/net/sxe2/sxe2_vsi.h | 205 +++++ 44 files changed, 10041 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
PATCH v8 1/10 mailmap: add Jie Liu
From: Jie Liu <[email protected]>
--- .mailmap | 1 + 1 file changed, 1 insertion(+)
.mailmap +1 -0
@@ -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
PATCH v8 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
@@ -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
doc/guides/nics/index.rst +1 -0
@@ -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
@@ -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
@@ -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
PATCH v8 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 | 13 + 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, 1959 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 +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2023 Corigine, Inc. + +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
@@ -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
@@ -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
PATCH v8 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
@@ -9,5 +9,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
PATCH v8 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 | 22 + 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, 3025 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
@@ -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
@@ -38,6 +38,15 @@ __rte_internals32 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
@@ -58,6 +58,7 @@ drivers = [ 'rnp', 'sfc', 'softnic', + 'sxe2', 'tap', 'thunderx', 'txgbe',
drivers/net/sxe2/meson.build new file +22 -0
@@ -0,0 +1,22 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (C), 2025, Wuxi Stars Micro System Technologies Co., Ltd. +#执行子目录base,并获取目标对象 + +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
@@ -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
@@ -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
@@ -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
165 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.
PATCH v8 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
@@ -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) s32sxe2_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
@@ -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
PATCH v8 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
@@ -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
@@ -47,6 +47,15 @@ __rte_internals32 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
PATCH v8 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
@@ -17,6 +17,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
@@ -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
@@ -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
@@ -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
PATCH v8 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
@@ -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
@@ -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
@@ -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 @@ voidvoid *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
@@ -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
@@ -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
@@ -19,6 +19,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
@@ -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 *kPMD_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
@@ -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
PATCH v8 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 | 9 + drivers/net/sxe2/sxe2_ethdev.c | 8 +- drivers/net/sxe2/sxe2_txrx.c | 224 +++++++--- drivers/net/sxe2/sxe2_txrx.h | 12 +- drivers/net/sxe2/sxe2_txrx_poll.c | 184 ++++++++ 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 ++++++++++++++++++++++++ 10 files changed, 1417 insertions(+), 65 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 +9 -0
@@ -12,6 +12,14 @@ cflags += ['-g'] deps += ['common_sxe2', 'hash','cryptodev','security'] +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',
@@ -21,6 +29,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
@@ -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_txrx.c +172 -52
375 lines not on this page · raw message
drivers/net/sxe2/sxe2_txrx.h +6 -6
@@ -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 +184 -0
196 lines not on this page · raw message
drivers/net/sxe2/sxe2_txrx_poll.h +2 -1
@@ -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
v9 cover Add Linkdata sxe2 driver
From: Jie Liu <[email protected]>
V9:
- 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 | 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 ++++++++++++ drivers/net/sxe2/sxe2_vsi.c | 211 +++++ drivers/net/sxe2/sxe2_vsi.h | 205 +++++ 44 files changed, 10052 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
PATCH v9 1/10 mailmap: add Jie Liu
From: Jie Liu <[email protected]>
--- .mailmap | 1 + 1 file changed, 1 insertion(+)
.mailmap +1 -0
@@ -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
PATCH v9 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
@@ -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
doc/guides/nics/index.rst +1 -0
@@ -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
@@ -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
@@ -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
PATCH v9 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
@@ -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
@@ -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
@@ -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
PATCH v9 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
@@ -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
PATCH v9 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
@@ -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
@@ -38,6 +38,15 @@ __rte_internals32 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
@@ -58,6 +58,7 @@ drivers = [ 'rnp', 'sfc', 'softnic', + 'sxe2', 'tap', 'thunderx', 'txgbe',
drivers/net/sxe2/meson.build new file +28 -0
@@ -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
@@ -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
@@ -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
@@ -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.
PATCH v9 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
@@ -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) s32sxe2_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
@@ -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
PATCH v9 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
@@ -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
@@ -47,6 +47,15 @@ __rte_internals32 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
PATCH v9 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
@@ -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
@@ -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
@@ -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
@@ -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