Skip to contentSkip to conversation

XSC PMD for Yunsilicon NICs

PATCH Superseded WanRenyong 2 participants 25 messages Jan 7, 2025 – Jan 18, 2025

Subsystems (2)

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

WanRenyong

author
#0 lore raw

v5 cover XSC PMD for Yunsilicon NICs

This xsc PMD (**librte_net_xsc**) provides poll mode driver for Yunsilicon metaScale serials NICs.

Features:
---------
- MTU update
- TSO
- RSS hash
- RSS key update
- RSS reta update
- L3 checksum offload
- L4 checksum offload
- Inner L3 checksum
- Inner L4 checksum
- Basic stats

Support NICs:
-------------

- metaScale-200S   Single QSFP56 Port 200GE SmartNIC
- metaScale-200    Quad QSFP28 Ports 100GE SmartNIC
- metaScale-50     Dual QSFP28 Port 25GE SmartNIC
- metaScale-100Q   Quad QSFP28 Port 25GE SmartNIC

---

v5:
* fix compilation errors.
* fix coding style issue with misspelling.
* remove some unnecessary parameter checks.
* remove unnecessary call of rte_wmb.
* Rearrange elements in structure to avoid holes.

v4:
* Based on the review comments from previous versions, reconstruct the xsc PMD to eliminate the dependency on rdma core library and proprietary kernel driver, while adding support for the vfio kernel driver.

v3:
* fix compilation errors

v2:
* fix checkpatch warnings and errors

---
WanRenyong (15):
net/xsc: add xsc PMD framework
net/xsc: add xsc device initialization
net/xsc: add xsc mailbox
net/xsc: add xsc dev ops to support VFIO driver
net/xsc: add PCT interfaces
net/xsc: initialize xsc representors
net/xsc: add ethdev configure and RSS ops
net/xsc: add Rx and Tx queue setup
net/xsc: add ethdev start
net/xsc: add ethdev stop and close
net/xsc: add ethdev Rx burst
net/xsc: add ethdev Tx burst
net/xsc: add basic stats ops
net/xsc: add ethdev infos get
net/xsc: add ethdev link and MTU ops

 .mailmap                               |   5 +
 MAINTAINERS                            |  10 +
 doc/guides/nics/features/xsc.ini       |  18 +
 doc/guides/nics/index.rst              |   1 +
 doc/guides/nics/xsc.rst                |  31 +
 doc/guides/rel_notes/release_25_03.rst |   4 +
 drivers/net/meson.build                |   1 +
 drivers/net/xsc/meson.build            |  17 +
 drivers/net/xsc/xsc_cmd.h              | 387 +++++++++++
 drivers/net/xsc/xsc_defs.h             | 100 +++
 drivers/net/xsc/xsc_dev.c              | 397 +++++++++++
 drivers/net/xsc/xsc_dev.h              | 184 +++++
 drivers/net/xsc/xsc_ethdev.c           | 918 +++++++++++++++++++++++++
 drivers/net/xsc/xsc_ethdev.h           |  63 ++
 drivers/net/xsc/xsc_log.h              |  24 +
 drivers/net/xsc/xsc_np.c               | 492 +++++++++++++
 drivers/net/xsc/xsc_np.h               | 154 +++++
 drivers/net/xsc/xsc_rx.c               | 512 ++++++++++++++
 drivers/net/xsc/xsc_rx.h               |  65 ++
 drivers/net/xsc/xsc_rxtx.h             | 191 +++++
 drivers/net/xsc/xsc_tx.c               | 354 ++++++++++
 drivers/net/xsc/xsc_tx.h               |  62 ++
 drivers/net/xsc/xsc_vfio.c             | 746 ++++++++++++++++++++
 drivers/net/xsc/xsc_vfio_mbox.c        | 691 +++++++++++++++++++
 drivers/net/xsc/xsc_vfio_mbox.h        | 142 ++++
 25 files changed, 5569 insertions(+)
 create mode 100644 doc/guides/nics/features/xsc.ini
 create mode 100644 doc/guides/nics/xsc.rst
 create mode 100644 drivers/net/xsc/meson.build
 create mode 100644 drivers/net/xsc/xsc_cmd.h
 create mode 100644 drivers/net/xsc/xsc_defs.h
 create mode 100644 drivers/net/xsc/xsc_dev.c
 create mode 100644 drivers/net/xsc/xsc_dev.h
 create mode 100644 drivers/net/xsc/xsc_ethdev.c
 create mode 100644 drivers/net/xsc/xsc_ethdev.h
 create mode 100644 drivers/net/xsc/xsc_log.h
 create mode 100644 drivers/net/xsc/xsc_np.c
 create mode 100644 drivers/net/xsc/xsc_np.h
 create mode 100644 drivers/net/xsc/xsc_rx.c
 create mode 100644 drivers/net/xsc/xsc_rx.h
 create mode 100644 drivers/net/xsc/xsc_rxtx.h
 create mode 100644 drivers/net/xsc/xsc_tx.c
 create mode 100644 drivers/net/xsc/xsc_tx.h
 create mode 100644 drivers/net/xsc/xsc_vfio.c
 create mode 100644 drivers/net/xsc/xsc_vfio_mbox.c
 create mode 100644 drivers/net/xsc/xsc_vfio_mbox.h
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH v5 1/15 net/xsc: add xsc PMD framework

Add xsc PMD framework, doc and build infrastructure, supporting PCI probe.

---
 .mailmap                               |  5 ++
 MAINTAINERS                            | 10 +++
 doc/guides/nics/features/xsc.ini       |  9 +++
 doc/guides/nics/index.rst              |  1 +
 doc/guides/nics/xsc.rst                | 31 +++++++++
 doc/guides/rel_notes/release_25_03.rst |  4 ++
 drivers/net/meson.build                |  1 +
 drivers/net/xsc/meson.build            | 11 ++++
 drivers/net/xsc/xsc_defs.h             | 15 +++++
 drivers/net/xsc/xsc_ethdev.c           | 89 ++++++++++++++++++++++++++
 drivers/net/xsc/xsc_ethdev.h           | 15 +++++
 drivers/net/xsc/xsc_log.h              | 24 +++++++
 12 files changed, 215 insertions(+)
 create mode 100644 doc/guides/nics/features/xsc.ini
 create mode 100644 doc/guides/nics/xsc.rst
 create mode 100644 drivers/net/xsc/meson.build
 create mode 100644 drivers/net/xsc/xsc_defs.h
 create mode 100644 drivers/net/xsc/xsc_ethdev.c
 create mode 100644 drivers/net/xsc/xsc_ethdev.h
 create mode 100644 drivers/net/xsc/xsc_log.h
.mailmap +5 -0
index 818798273f..18293215c3 100644
@@ -370,6 +370,7 @@ Dongdong Liu <[email protected]>
 Dongsheng Rong <[email protected]>
 Dongsu Han <[email protected]>
 Dong Wang <[email protected]>
+Dongwei Xu <[email protected]>
 Dongyang Pan <[email protected]>
 Dong Zhou <[email protected]> <[email protected]>
 Don Provan <[email protected]>
@@ -1062,6 +1063,7 @@ Nagadheeraj Rottela <[email protected]>
 Naga Harish K S V <[email protected]>
 Naga Suresh Somarowthu <[email protected]>
 Nalla Pradeep <[email protected]>
+Na Na <[email protected]>
 Na Na <[email protected]>
 Nan Chen <[email protected]>
 Nandini Persad <[email protected]>
@@ -1306,6 +1308,7 @@ Ronak Doshi <[email protected]> <[email protected]>
 Ron Beider <[email protected]>
 Ronghua Zhang <[email protected]>
 RongQiang Xie <[email protected]>
+Rong Qian <[email protected]>
 RongQing Li <[email protected]>
 Rongwei Liu <[email protected]>
 Rory Sexton <[email protected]>
@@ -1633,6 +1636,7 @@ Waldemar Dworakowski <[email protected]>
 Walter Heymans <[email protected]>
 Wang Sheng-Hui <[email protected]>
 Wangyu (Eric) <[email protected]>
+WanRenyong <[email protected]>
 Waterman Cao <[email protected]>
 Wathsala Vithanage <[email protected]>
 Weichun Chen <[email protected]>
@@ -1686,6 +1690,7 @@ Xiaonan Zhang <[email protected]>
 Xiao Wang <[email protected]>
 Xiaoxiao Zeng <[email protected]>
 Xiaoxin Peng <[email protected]>
+Xiaoxiong Zhang <[email protected]>
 Xiaoyu Min <[email protected]> <[email protected]>
 Xiaoyun Li <[email protected]>
 Xiaoyun Wang <[email protected]>
MAINTAINERS +10 -0
index 60bdcce543..3426658486 100644
@@ -1075,6 +1075,16 @@ F: drivers/net/avp/
 F: doc/guides/nics/avp.rst
 F: doc/guides/nics/features/avp.ini
 
+Yunsilicon xsc
+M: WanRenyong <[email protected]>
+M: Na Na <[email protected]>
+M: Rong Qian <[email protected]>
+M: Xiaoxiong Zhang <[email protected]>
+M: Dongwei Xu <[email protected]>
+F: drivers/net/xsc/
+F: doc/guides/nics/xsc.rst
+F: doc/guides/nics/features/xsc.ini
+
 ZTE zxdh - EXPERIMENTAL
 M: Junlong Wang <[email protected]>
 M: Lijie Shan <[email protected]>
doc/guides/nics/features/xsc.ini new file +9 -0
new file mode 100644
index 0000000000..b5c44ce535
@@ -0,0 +1,9 @@
+;
+; Supported features of the 'xsc' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Linux                = Y
+ARMv8                = Y
+x86-64               = Y
doc/guides/nics/index.rst +1 -0
index 50688d9f64..10a2eca3b0 100644
@@ -70,4 +70,5 @@ Network Interface Controller Drivers
     vhost
     virtio
     vmxnet3
+    xsc
     zxdh
doc/guides/nics/xsc.rst new file +31 -0
new file mode 100644
index 0000000000..8e189db541
@@ -0,0 +1,31 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright 2024 Yunsilicon Technology Co., Ltd
+
+XSC Poll Mode Driver
+======================
+
+The xsc PMD (**librte_net_xsc**) provides poll mode driver support for
+10/25/50/100/200 Gbps Yunsilicon metaScale Series Network Adapters.
+
+Supported NICs
+--------------
+
+The following Yunsilicon device models are supported by the same xsc driver:
+
+  - metaScale-200S
+  - metaScale-200
+  - metaScale-100Q
+  - metaScale-50
+
+Prerequisites
+--------------
+
+- Follow the DPDK :ref:`Getting Started Guide for Linux <linux_gsg>` to setup the basic DPDK environment.
+
+- Learning about Yunsilicon metaScale Series NICs using
+  `<https://www.yunsilicon.com/#/productInformation>`_.
+
+Limitations or Known issues
+---------------------------
+32bit ARCHs are not supported.
+Windows and BSD are not supported yet.
doc/guides/rel_notes/release_25_03.rst +4 -0
index 426dfcd982..6f766add72 100644
@@ -55,6 +55,10 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added Yunsilicon xsc net driver [EXPERIMENTAL].**
+
+  * Added the PMD for Yunsilicon metaScale serials NICs.
+
 
 Removed Items
 -------------
drivers/net/meson.build +1 -0
index dafd637ba4..c1ca7b0b39 100644
@@ -63,6 +63,7 @@ drivers = [
         'vhost',
         'virtio',
         'vmxnet3',
+        'xsc',
         'zxdh',
 ]
 std_deps = ['ethdev', 'kvargs'] # 'ethdev' also pulls in mbuf, net, eal etc
drivers/net/xsc/meson.build new file +11 -0
new file mode 100644
index 0000000000..84a09a23de
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright 2025 Yunsilicon Technology Co., Ltd.
+
+if not is_linux or not dpdk_conf.get('RTE_ARCH_64')
+    build = false
+    reason = 'only supported on 64bit Linux'
+endif
+
+sources = files(
+        'xsc_ethdev.c',
+)
drivers/net/xsc/xsc_defs.h new file +15 -0
new file mode 100644
index 0000000000..7c91d3443f
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2025 Yunsilicon Technology Co., Ltd.
+ */
+
+#ifndef XSC_DEFS_H_
+#define XSC_DEFS_H_
+
+#define XSC_PCI_VENDOR_ID		0x1f67
+#define XSC_PCI_DEV_ID_MS		0x1111
+#define XSC_PCI_DEV_ID_MSVF		0x1112
+#define XSC_PCI_DEV_ID_MVH		0x1151
+#define XSC_PCI_DEV_ID_MVHVF		0x1152
+#define XSC_PCI_DEV_ID_MVS		0x1153
+
+#endif /* XSC_DEFS_H_ */
drivers/net/xsc/xsc_ethdev.c new file +89 -0

89 lines not on this page · raw message

drivers/net/xsc/xsc_ethdev.h new file +15 -0
new file mode 100644
index 0000000000..508f5a86de
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2025 Yunsilicon Technology Co., Ltd.
+ */
+
+#ifndef _XSC_ETHDEV_H_
+#define _XSC_ETHDEV_H_
+
+struct xsc_ethdev_priv {
+	struct rte_eth_dev *eth_dev;
+	struct rte_pci_device *pci_dev;
+};
+
+#define TO_XSC_ETHDEV_PRIV(dev) ((struct xsc_ethdev_priv *)(dev)->data->dev_private)
+
+#endif /* _XSC_ETHDEV_H_ */
drivers/net/xsc/xsc_log.h new file +24 -0
new file mode 100644
index 0000000000..16de436edb
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2025 Yunsilicon Technology Co., Ltd.
+ */
+
+#ifndef _XSC_LOG_H_
+#define _XSC_LOG_H_
+
+#include <rte_log.h>
+
+extern int xsc_logtype_init;
+extern int xsc_logtype_driver;
+
+#define RTE_LOGTYPE_XSC_INIT	xsc_logtype_init
+#define RTE_LOGTYPE_XSC_DRV	xsc_logtype_driver
+
+#define PMD_INIT_LOG(level, ...) \
+	RTE_LOG_LINE_PREFIX(level, XSC_INIT, "%s(): ", __func__, __VA_ARGS__)
+
+#define PMD_INIT_FUNC_TRACE() PMD_INIT_LOG(DEBUG, " >>")
+
+#define PMD_DRV_LOG(level, ...) \
+	RTE_LOG_LINE_PREFIX(level, XSC_DRV, "%s(): ", __func__, __VA_ARGS__)
+
+#endif /* _XSC_LOG_H_ */
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH v5 01/15] net/xsc: add xsc PMD framework

drivers/net/xsc/xsc_ethdev.c line 5

Quoted 11 lines · On Tue, 07 Jan 2025 10:49:40 +0800 "WanRenyong" <[email protected]> wrote:
drivers/net/xsc/xsc_ethdev.c new file +5 -0
new file mode 100644
index 0000000000..a7dca46127
@@ -0,0 +1,89 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2025 Yunsilicon Technology Co., Ltd.
+ */
+
+#include <net/if.h>

Why are you including this file (it relates to Linux networking not DPDK)? If I remove it build works fine.

author
#3 lore raw

Re: [PATCH v5 01/15] net/xsc: add xsc PMD framework

Quoted 17 lines · Stephen Hemminger

drivers/net/xsc/xsc_ethdev.c line 5

Quoted 11 lines · On Tue, 07 Jan 2025 10:49:40 +0800 "WanRenyong" <[email protected]> wrote:
drivers/net/xsc/xsc_ethdev.c new file +5 -0
new file mode 100644
index 0000000000..a7dca46127
@@ -0,0 +1,89 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2025 Yunsilicon Technology Co., Ltd.
+ */
+
+#include <net/if.h>

Why are you including this file (it relates to Linux networking not DPDK)? If I remove it build works fine.

Thank you for your review. This is codeleftoverfrom early patches that had dependencies on kernel drivers. I will remove it next time.

By the way, is there any new incoming review feedback about this patch series? If not, I will address current review comments and resubmit the new revised version of the patches.

Signature · 2 lines
Thanks,
WanRenyong
#4 lore raw

Re: [PATCH v5 01/15] net/xsc: add xsc PMD framework

In reply to WanRenyong
Quoted 5 lines · On Tue, 07 Jan 2025 10:49:40 +0800 "WanRenyong" <[email protected]> wrote:
doc/guides/rel_notes/release_25_03.rst +0 -0
index 426dfcd982..6f766add72 100644

doc/guides/rel_notes/release_25_03.rst New Features · line 64

Quoted 10 lines
doc/guides/rel_notes/release_25_03.rst +4 -0
@@ -55,6 +55,10 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added Yunsilicon xsc net driver [EXPERIMENTAL].**
+
+  * Added the PMD for Yunsilicon metaScale serials NICs.
+
 
 Removed Items
 -------------

This part will need to be rebased since release notes got updated on main branch

author
#5 lore raw

Re: [PATCH v5 01/15] net/xsc: add xsc PMD framework

Quoted 11 lines · Stephen Hemminger
Quoted 8 lines · On Tue, 07 Jan 2025 10:49:40 +0800 "WanRenyong" <[email protected]> wrote:
doc/guides/rel_notes/release_25_03.rst +0 -0
index 426dfcd982..6f766add72 100644
@@ -55,6 +55,10 @@ New Features
       Also, make sure to start the actual text at the margin.
       =======================================================
 
Quoted 8 lines

doc/guides/rel_notes/release_25_03.rst New Features · line 64

Quoted 7 lines
doc/guides/rel_notes/release_25_03.rst +4 -0
+* **Added Yunsilicon xsc net driver [EXPERIMENTAL].**
+
+  * Added the PMD for Yunsilicon metaScale serials NICs.
+
 
  Removed Items
  -------------

This part will need to be rebased since release notes got updated on main branch

OK, thank you!

Signature · 2 lines
Best regards,
WanRenyong
author
#6 lore raw

PATCH v5 2/15 net/xsc: add xsc device initialization

In reply to WanRenyong

XSC device is a hardware abstract level device serving as a handle to interact with hardware.

---

v5:
* Fix coding style issue with misspelling
* Rearrange the elements in struct xsc_hwinfo to reduce holes

---
 drivers/net/xsc/meson.build  |   1 +
 drivers/net/xsc/xsc_defs.h   |  16 ++++
 drivers/net/xsc/xsc_dev.c    | 181 +++++++++++++++++++++++++++++++++++
 drivers/net/xsc/xsc_dev.h    | 131 +++++++++++++++++++++++++
 drivers/net/xsc/xsc_ethdev.c |  16 +++-
 drivers/net/xsc/xsc_ethdev.h |   3 +
 6 files changed, 347 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/xsc/xsc_dev.c
 create mode 100644 drivers/net/xsc/xsc_dev.h
drivers/net/xsc/meson.build +1 -0
index 84a09a23de..683a1f6632 100644
@@ -8,4 +8,5 @@ endif
 
 sources = files(
         'xsc_ethdev.c',
+        'xsc_dev.c',
 )
drivers/net/xsc/xsc_defs.h +16 -0
index 7c91d3443f..60244425cd 100644
@@ -12,4 +12,20 @@
 #define XSC_PCI_DEV_ID_MVHVF		0x1152
 #define XSC_PCI_DEV_ID_MVS		0x1153
 
+#define XSC_VFREP_BASE_LOGICAL_PORT	1081
+
+enum xsc_nic_mode {
+	XSC_NIC_MODE_LEGACY,
+	XSC_NIC_MODE_SWITCHDEV,
+	XSC_NIC_MODE_SOC,
+};
+
+enum xsc_pph_type {
+	XSC_PPH_NONE	= 0,
+	XSC_RX_PPH	= 0x1,
+	XSC_TX_PPH	= 0x2,
+	XSC_VFREP_PPH	= 0x4,
+	XSC_UPLINK_PPH	= 0x8,
+};
+
 #endif /* XSC_DEFS_H_ */
drivers/net/xsc/xsc_dev.c new file +181 -0

181 lines not on this page · raw message

drivers/net/xsc/xsc_dev.h new file +131 -0

131 lines not on this page · raw message

drivers/net/xsc/xsc_ethdev.c +15 -1
index a7dca46127..4bdc70507f 100644
@@ -13,22 +13,32 @@ static int
 xsc_ethdev_init(struct rte_eth_dev *eth_dev)
 {
 	struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(eth_dev);
+	int ret;
 
 	PMD_INIT_FUNC_TRACE();
 
 	priv->eth_dev = eth_dev;
 	priv->pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
 
+	ret = xsc_dev_init(priv->pci_dev, &priv->xdev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "Failed to initialize xsc device");
+		return ret;
+	}
+	priv->xdev->port_id = eth_dev->data->port_id;
+
 	return 0;
 }
 
 static int
 xsc_ethdev_uninit(struct rte_eth_dev *eth_dev)
 {
-	RTE_SET_USED(eth_dev);
+	struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(eth_dev);
 
 	PMD_INIT_FUNC_TRACE();
 
+	xsc_dev_uninit(priv->xdev);
+
 	return 0;
 }
 
@@ -84,6 +94,10 @@ static struct rte_pci_driver xsc_ethdev_pci_driver = {
 
 RTE_PMD_REGISTER_PCI(net_xsc, xsc_ethdev_pci_driver);
 RTE_PMD_REGISTER_PCI_TABLE(net_xsc, xsc_ethdev_pci_id_map);
+RTE_PMD_REGISTER_PARAM_STRING(net_xsc,
+			      XSC_PPH_MODE_ARG "=<x>"
+			      XSC_NIC_MODE_ARG "=<x>"
+			      XSC_FLOW_MODE_ARG "=<x>");
 
 RTE_LOG_REGISTER_SUFFIX(xsc_logtype_init, init, NOTICE);
 RTE_LOG_REGISTER_SUFFIX(xsc_logtype_driver, driver, NOTICE);
drivers/net/xsc/xsc_ethdev.h +3 -0
index 508f5a86de..05040f8865 100644
@@ -5,9 +5,12 @@
 #ifndef _XSC_ETHDEV_H_
 #define _XSC_ETHDEV_H_
 
+#include "xsc_dev.h"
+
 struct xsc_ethdev_priv {
 	struct rte_eth_dev *eth_dev;
 	struct rte_pci_device *pci_dev;
+	struct xsc_dev *xdev;
 };
 
 #define TO_XSC_ETHDEV_PRIV(dev) ((struct xsc_ethdev_priv *)(dev)->data->dev_private)
Signature · 1 line
2.25.1
author
#7 lore raw

PATCH v5 3/15 net/xsc: add xsc mailbox

In reply to WanRenyong

XSC mailbox is a mechanism used for interaction between PMD and firmware.

---
 drivers/net/xsc/meson.build     |   1 +
 drivers/net/xsc/xsc_cmd.h       | 387 ++++++++++++++++++
 drivers/net/xsc/xsc_defs.h      |   2 +
 drivers/net/xsc/xsc_vfio_mbox.c | 691 ++++++++++++++++++++++++++++++++
 drivers/net/xsc/xsc_vfio_mbox.h | 142 +++++++
 5 files changed, 1223 insertions(+)
 create mode 100644 drivers/net/xsc/xsc_cmd.h
 create mode 100644 drivers/net/xsc/xsc_vfio_mbox.c
 create mode 100644 drivers/net/xsc/xsc_vfio_mbox.h
drivers/net/xsc/meson.build +1 -0
index 683a1f6632..df4c8ea499 100644
@@ -9,4 +9,5 @@ endif
 sources = files(
         'xsc_ethdev.c',
         'xsc_dev.c',
+        'xsc_vfio_mbox.c',
 )
drivers/net/xsc/xsc_cmd.h new file +387 -0

387 lines not on this page · raw message

drivers/net/xsc/xsc_defs.h +2 -0
index 60244425cd..a4b36685a6 100644
@@ -5,6 +5,8 @@
 #ifndef XSC_DEFS_H_
 #define XSC_DEFS_H_
 
+#define XSC_PAGE_SIZE			4096
+
 #define XSC_PCI_VENDOR_ID		0x1f67
 #define XSC_PCI_DEV_ID_MS		0x1111
 #define XSC_PCI_DEV_ID_MSVF		0x1112
drivers/net/xsc/xsc_vfio_mbox.c new file +691 -0

691 lines not on this page · raw message

drivers/net/xsc/xsc_vfio_mbox.h new file +142 -0

142 lines not on this page · raw message

Signature · 1 line
2.25.1
author
#8 lore raw

PATCH v5 4/15 net/xsc: add xsc dev ops to support VFIO driver

In reply to WanRenyong

XSC PMD is designed to support both VFIO and private kernel drivers. This commit add xsc dev ops to support VFIO driver.

---

v5
* Using RTE_ETHER_ADDR_LEN instead of numeral 6.
* Initialize some local variables while be defined.
* Fix compilation warnings.

---
 drivers/net/xsc/meson.build |   1 +
 drivers/net/xsc/xsc_defs.h  |   8 +
 drivers/net/xsc/xsc_dev.h   |  32 ++
 drivers/net/xsc/xsc_rxtx.h  | 102 +++++
 drivers/net/xsc/xsc_vfio.c  | 746 ++++++++++++++++++++++++++++++++++++
 5 files changed, 889 insertions(+)
 create mode 100644 drivers/net/xsc/xsc_rxtx.h
 create mode 100644 drivers/net/xsc/xsc_vfio.c
drivers/net/xsc/meson.build +1 -0
index df4c8ea499..4e20b30438 100644
@@ -10,4 +10,5 @@ sources = files(
         'xsc_ethdev.c',
         'xsc_dev.c',
         'xsc_vfio_mbox.c',
+        'xsc_vfio.c',
 )
drivers/net/xsc/xsc_defs.h +8 -0
index a4b36685a6..8fd59133bc 100644
@@ -16,6 +16,14 @@
 
 #define XSC_VFREP_BASE_LOGICAL_PORT	1081
 
+#define XSC_PF_TX_DB_ADDR		0x4802000
+#define XSC_PF_RX_DB_ADDR		0x4804000
+#define XSC_PF_CQ_DB_ADDR		0x2120000
+
+#define XSC_VF_RX_DB_ADDR		0x8d4
+#define XSC_VF_TX_DB_ADDR		0x8d0
+#define XSC_VF_CQ_DB_ADDR		0x8c4
+
 enum xsc_nic_mode {
 	XSC_NIC_MODE_LEGACY,
 	XSC_NIC_MODE_SWITCHDEV,
drivers/net/xsc/xsc_dev.h +32 -0
index e013d954b9..059d7d37ff 100644
@@ -14,6 +14,7 @@
 
 #include "xsc_defs.h"
 #include "xsc_log.h"
+#include "xsc_rxtx.h"
 
 #define XSC_PPH_MODE_ARG	"pph_mode"
 #define XSC_NIC_MODE_ARG	"nic_mode"
@@ -25,6 +26,18 @@
 #define XSC_DEV_PCT_IDX_INVALID	0xFFFFFFFF
 #define XSC_DEV_REPR_ID_INVALID	0x7FFFFFFF
 
+enum xsc_queue_type {
+	XSC_QUEUE_TYPE_RDMA_RC		= 0,
+	XSC_QUEUE_TYPE_RDMA_MAD		= 1,
+	XSC_QUEUE_TYPE_RAW		= 2,
+	XSC_QUEUE_TYPE_VIRTIO_NET	= 3,
+	XSC_QUEUE_TYPE_VIRTIO_BLK	= 4,
+	XSC_QUEUE_TYPE_RAW_TPE		= 5,
+	XSC_QUEUE_TYPE_RAW_TSO		= 6,
+	XSC_QUEUE_TYPE_RAW_TX		= 7,
+	XSC_QUEUE_TYPE_INVALID		= 0xFF,
+};
+
 struct xsc_hwinfo {
 	uint32_t pcie_no; /* pcie number , 0 or 1 */
 	uint32_t func_id; /* pf glb func id */
@@ -120,6 +133,25 @@ struct xsc_dev_ops {
 	enum rte_pci_kernel_driver kdrv;
 	int (*dev_init)(struct xsc_dev *xdev);
 	int (*dev_close)(struct xsc_dev *xdev);
+	int (*get_mac)(struct xsc_dev *xdev, uint8_t *mac);
+	int (*set_link_up)(struct xsc_dev *xdev);
+	int (*set_link_down)(struct xsc_dev *xdev);
+	int (*link_update)(struct xsc_dev *xdev, uint8_t funcid_type, int wait_to_complete);
+	int (*set_mtu)(struct xsc_dev *xdev, uint16_t mtu);
+	int (*destroy_qp)(void *qp);
+	int (*destroy_cq)(void *cq);
+	int (*modify_qp_status)(struct xsc_dev *xdev,
+				uint32_t qpn, int num, int opcode);
+	int (*modify_qp_qostree)(struct xsc_dev *xdev, uint16_t qpn);
+
+	int (*rx_cq_create)(struct xsc_dev *xdev, struct xsc_rx_cq_params *cq_params,
+			    struct xsc_rx_cq_info *cq_info);
+	int (*tx_cq_create)(struct xsc_dev *xdev, struct xsc_tx_cq_params *cq_params,
+			    struct xsc_tx_cq_info *cq_info);
+	int (*tx_qp_create)(struct xsc_dev *xdev, struct xsc_tx_qp_params *qp_params,
+			    struct xsc_tx_qp_info *qp_info);
+	int (*mailbox_exec)(struct xsc_dev *xdev, void *data_in,
+			    int in_len, void *data_out, int out_len);
 };
 
 void xsc_dev_ops_register(struct xsc_dev_ops *new_ops);
drivers/net/xsc/xsc_rxtx.h new file +102 -0

102 lines not on this page · raw message

drivers/net/xsc/xsc_vfio.c new file +746 -0

746 lines not on this page · raw message

Signature · 1 line
2.25.1
author
#9 lore raw

PATCH v5 5/15 net/xsc: add PCT interfaces

In reply to WanRenyong

PCT is the abbreviation of Packet classifier table, which is built in NP to define behavior of various packets.

---
 drivers/net/xsc/meson.build |   1 +
 drivers/net/xsc/xsc_defs.h  |  29 +++
 drivers/net/xsc/xsc_dev.c   |  19 +-
 drivers/net/xsc/xsc_dev.h   |   3 +
 drivers/net/xsc/xsc_np.c    | 492 ++++++++++++++++++++++++++++++++++++
 drivers/net/xsc/xsc_np.h    | 154 +++++++++++
 6 files changed, 697 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/xsc/xsc_np.c
 create mode 100644 drivers/net/xsc/xsc_np.h
drivers/net/xsc/meson.build +1 -0
index 4e20b30438..5ee03ea835 100644
@@ -11,4 +11,5 @@ sources = files(
         'xsc_dev.c',
         'xsc_vfio_mbox.c',
         'xsc_vfio.c',
+        'xsc_np.c',
 )
drivers/net/xsc/xsc_defs.h +29 -0
index 8fd59133bc..b1e37a5870 100644
@@ -16,6 +16,26 @@
 
 #define XSC_VFREP_BASE_LOGICAL_PORT	1081
 
+#define XSC_RSS_HASH_KEY_LEN		52
+#define XSC_RSS_HASH_BIT_IPV4_SIP	(1ULL << 0)
+#define XSC_RSS_HASH_BIT_IPV4_DIP	(1ULL << 1)
+#define XSC_RSS_HASH_BIT_IPV6_SIP	(1ULL << 2)
+#define XSC_RSS_HASH_BIT_IPV6_DIP	(1ULL << 3)
+#define XSC_RSS_HASH_BIT_IPV4_SPORT	(1ULL << 4)
+#define XSC_RSS_HASH_BIT_IPV4_DPORT	(1ULL << 5)
+#define XSC_RSS_HASH_BIT_IPV6_SPORT	(1ULL << 6)
+#define XSC_RSS_HASH_BIT_IPV6_DPORT	(1ULL << 7)
+#define XSC_RSS_HASH_BIT_TNL_ID		(1ULL << 8)
+#define XSC_RSS_HASH_BIT_NXT_PRO	(1ULL << 9)
+
+#define XSC_EPAT_VLD_FLAG		(1ULL)
+#define XSC_EPAT_RX_QP_ID_OFST_FLAG	(1ULL << 2)
+#define XSC_EPAT_QP_NUM_FLAG		(1ULL << 3)
+#define XSC_EPAT_RSS_EN_FLAG		(1ULL << 4)
+#define XSC_EPAT_RSS_HASH_TEMPLATE_FLAG	(1ULL << 5)
+#define XSC_EPAT_RSS_HASH_FUNC_FLAG	(1ULL << 6)
+#define XSC_EPAT_HAS_PPH_FLAG		(1ULL << 9)
+
 #define XSC_PF_TX_DB_ADDR		0x4802000
 #define XSC_PF_RX_DB_ADDR		0x4804000
 #define XSC_PF_CQ_DB_ADDR		0x2120000
@@ -38,4 +58,13 @@ enum xsc_pph_type {
 	XSC_UPLINK_PPH	= 0x8,
 };
 
+enum xsc_port_type {
+	XSC_PORT_TYPE_NONE = 0,
+	XSC_PORT_TYPE_UPLINK,
+	XSC_PORT_TYPE_UPLINK_BOND,
+	XSC_PORT_TYPE_PFVF,
+	XSC_PORT_TYPE_PFHPF,
+	XSC_PORT_TYPE_UNKNOWN,
+};
+
 #endif /* XSC_DEFS_H_ */
drivers/net/xsc/xsc_dev.c +18 -1
index b030eb3410..8933f77b8f 100644
@@ -54,8 +54,17 @@ xsc_dev_ops_register(struct xsc_dev_ops *new_ops)
 }
 
 int
-xsc_dev_close(struct xsc_dev *xdev, int __rte_unused repr_id)
+xsc_dev_mailbox_exec(struct xsc_dev *xdev, void *data_in,
+		     int in_len, void *data_out, int out_len)
 {
+	return xdev->dev_ops->mailbox_exec(xdev, data_in, in_len,
+					   data_out, out_len);
+}
+
+int
+xsc_dev_close(struct xsc_dev *xdev, int repr_id)
+{
+	xsc_dev_clear_pct(xdev, repr_id);
 	return xdev->dev_ops->dev_close(xdev);
 }
 
@@ -121,6 +130,7 @@ void
 xsc_dev_uninit(struct xsc_dev *xdev)
 {
 	PMD_INIT_FUNC_TRACE();
+	xsc_dev_pct_uninit();
 	xsc_dev_close(xdev, XSC_DEV_REPR_ID_INVALID);
 	rte_free(xdev);
 }
@@ -159,6 +169,13 @@ xsc_dev_init(struct rte_pci_device *pci_dev, struct xsc_dev **xdev)
 		goto hwinfo_init_fail;
 	}
 
+	ret = xsc_dev_pct_init();
+	if (ret) {
+		PMD_DRV_LOG(ERR, "Failed to init xsc pct");
+		ret = -EINVAL;
+		goto hwinfo_init_fail;
+	}
+
 	*xdev = d;
 
 	return 0;
drivers/net/xsc/xsc_dev.h +3 -0
index 059d7d37ff..54e0275411 100644
@@ -15,6 +15,7 @@
 #include "xsc_defs.h"
 #include "xsc_log.h"
 #include "xsc_rxtx.h"
+#include "xsc_np.h"
 
 #define XSC_PPH_MODE_ARG	"pph_mode"
 #define XSC_NIC_MODE_ARG	"nic_mode"
@@ -154,6 +155,8 @@ struct xsc_dev_ops {
 			    int in_len, void *data_out, int out_len);
 };
 
+int xsc_dev_mailbox_exec(struct xsc_dev *xdev, void *data_in,
+			 int in_len, void *data_out, int out_len);
 void xsc_dev_ops_register(struct xsc_dev_ops *new_ops);
 int xsc_dev_init(struct rte_pci_device *pci_dev, struct xsc_dev **dev);
 void xsc_dev_uninit(struct xsc_dev *xdev);
drivers/net/xsc/xsc_np.c new file +492 -0

492 lines not on this page · raw message

drivers/net/xsc/xsc_np.h new file +154 -0

154 lines not on this page · raw message

Signature · 1 line
2.25.1
author
#10 lore raw

PATCH v5 6/15 net/xsc: initialize xsc representors

In reply to WanRenyong

For the design of the xsc PMD, each ethdev corresponds to a representor.

---
 drivers/net/xsc/xsc_defs.h   |  11 +++
 drivers/net/xsc/xsc_dev.c    |  95 ++++++++++++++++++++
 drivers/net/xsc/xsc_dev.h    |   3 +
 drivers/net/xsc/xsc_ethdev.c | 170 +++++++++++++++++++++++++++++++++++
 drivers/net/xsc/xsc_ethdev.h |  19 ++++
 5 files changed, 298 insertions(+)
drivers/net/xsc/xsc_defs.h +11 -0
index b1e37a5870..111776f37e 100644
@@ -6,6 +6,7 @@
 #define XSC_DEFS_H_
 
 #define XSC_PAGE_SIZE			4096
+#define XSC_PHY_PORT_NUM		1
 
 #define XSC_PCI_VENDOR_ID		0x1f67
 #define XSC_PCI_DEV_ID_MS		0x1111
@@ -15,6 +16,7 @@
 #define XSC_PCI_DEV_ID_MVS		0x1153
 
 #define XSC_VFREP_BASE_LOGICAL_PORT	1081
+#define XSC_MAX_MAC_ADDRESSES		3
 
 #define XSC_RSS_HASH_KEY_LEN		52
 #define XSC_RSS_HASH_BIT_IPV4_SIP	(1ULL << 0)
@@ -58,6 +60,15 @@ enum xsc_pph_type {
 	XSC_UPLINK_PPH	= 0x8,
 };
 
+enum xsc_funcid_type {
+	XSC_FUNCID_TYPE_INVAL	= 0x0,
+	XSC_EMU_FUNCID		= 0x1,
+	XSC_PHYPORT_MAC_FUNCID	= 0x2,
+	XSC_VF_IOCTL_FUNCID	= 0x3,
+	XSC_PHYPORT_LAG_FUNCID	= 0x4,
+	XSC_FUNCID_TYPE_UNKNOWN	= 0x5,
+};
+
 enum xsc_port_type {
 	XSC_PORT_TYPE_NONE = 0,
 	XSC_PORT_TYPE_UPLINK,
drivers/net/xsc/xsc_dev.c +95 -0

107 lines not on this page · raw message

drivers/net/xsc/xsc_dev.h +3 -0
index 54e0275411..297c5d2324 100644
@@ -161,6 +161,9 @@ void xsc_dev_ops_register(struct xsc_dev_ops *new_ops);
 int xsc_dev_init(struct rte_pci_device *pci_dev, struct xsc_dev **dev);
 void xsc_dev_uninit(struct xsc_dev *xdev);
 int xsc_dev_close(struct xsc_dev *xdev, int repr_id);
+int xsc_dev_repr_ports_probe(struct xsc_dev *xdev, int nb_repr_ports, int max_eth_ports);
 bool xsc_dev_is_vf(struct xsc_dev *xdev);
+int xsc_dev_qp_set_id_get(struct xsc_dev *xdev, int repr_id);
+int xsc_dev_get_mac(struct xsc_dev *xdev, uint8_t *mac);
 
 #endif /* _XSC_DEV_H_ */
drivers/net/xsc/xsc_ethdev.c +170 -0

183 lines not on this page · raw message

drivers/net/xsc/xsc_ethdev.h +19 -0
index 05040f8865..7d161bd22e 100644
@@ -11,6 +11,25 @@ struct xsc_ethdev_priv {
 	struct rte_eth_dev *eth_dev;
 	struct rte_pci_device *pci_dev;
 	struct xsc_dev *xdev;
+	struct xsc_repr_port *repr_port;
+	struct xsc_dev_config config;
+	struct rte_eth_dev_data *dev_data;
+	struct rte_ether_addr mac[XSC_MAX_MAC_ADDRESSES];
+	struct rte_eth_rss_conf rss_conf;
+
+	int representor_id;
+	uint32_t ifindex;
+	uint16_t mtu;
+	uint8_t isolated;
+	uint8_t is_representor;
+
+	uint32_t mode:7;
+	uint32_t member_bitmap:8;
+	uint32_t funcid_type:3;
+	uint32_t funcid:14;
+
+	uint16_t eth_type;
+	uint16_t qp_set_id;
 };
 
 #define TO_XSC_ETHDEV_PRIV(dev) ((struct xsc_ethdev_priv *)(dev)->data->dev_private)
Signature · 1 line
2.25.1
author
#11 lore raw

PATCH v5 7/15 net/xsc: add ethdev configure and RSS ops

In reply to WanRenyong

Implement xsc ethdev configure and RSS hash functions.

---

v5:
* Remove some unnecessary parameter checks.

---
 doc/guides/nics/features/xsc.ini |  3 ++
 drivers/net/xsc/xsc_defs.h       | 15 ++++++
 drivers/net/xsc/xsc_dev.c        | 26 ++++++++++
 drivers/net/xsc/xsc_dev.h        |  1 +
 drivers/net/xsc/xsc_ethdev.c     | 82 ++++++++++++++++++++++++++++++++
 drivers/net/xsc/xsc_ethdev.h     |  7 +++
 6 files changed, 134 insertions(+)
doc/guides/nics/features/xsc.ini +3 -0
index b5c44ce535..bdeb7a984b 100644
@@ -4,6 +4,9 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+RSS hash             = Y
+RSS key update       = Y
+RSS reta update      = Y
 Linux                = Y
 ARMv8                = Y
 x86-64               = Y
drivers/net/xsc/xsc_defs.h +15 -0
index 111776f37e..c445eadca1 100644
@@ -78,4 +78,19 @@ enum xsc_port_type {
 	XSC_PORT_TYPE_UNKNOWN,
 };
 
+enum xsc_tbm_cap {
+	XSC_TBM_CAP_HASH_PPH = 0,
+	XSC_TBM_CAP_RSS,
+	XSC_TBM_CAP_PP_BYPASS,
+	XSC_TBM_CAP_PCT_DROP_CONFIG,
+};
+
+enum xsc_rss_hf {
+	XSC_RSS_HASH_KEY_UPDATE = 0,
+	XSC_RSS_HASH_TEMP_UPDATE,
+	XSC_RSS_HASH_FUNC_UPDATE,
+	XSC_RSS_RXQ_UPDATE,
+	XSC_RSS_RXQ_DROP,
+};
+
 #endif /* XSC_DEFS_H_ */
drivers/net/xsc/xsc_dev.c +26 -0
index aaf18bf8e5..74d577c7d0 100644
@@ -19,6 +19,7 @@
 #include "xsc_log.h"
 #include "xsc_defs.h"
 #include "xsc_dev.h"
+#include "xsc_cmd.h"
 
 #define XSC_DEV_DEF_FLOW_MODE	7
 
@@ -74,6 +75,31 @@ xsc_dev_close(struct xsc_dev *xdev, int repr_id)
 	return xdev->dev_ops->dev_close(xdev);
 }
 
+int
+xsc_dev_rss_key_modify(struct xsc_dev *xdev, uint8_t *rss_key, uint8_t rss_key_len)
+{
+	struct xsc_cmd_modify_nic_hca_mbox_in in = {};
+	struct xsc_cmd_modify_nic_hca_mbox_out out = {};
+	uint8_t rss_caps_mask = 0;
+	int ret, key_len = 0;
+
+	in.hdr.opcode = rte_cpu_to_be_16(XSC_CMD_OP_MODIFY_NIC_HCA);
+
+	key_len = RTE_MIN(rss_key_len, XSC_RSS_HASH_KEY_LEN);
+	rte_memcpy(in.rss.hash_key, rss_key, key_len);
+	rss_caps_mask |= RTE_BIT32(XSC_RSS_HASH_KEY_UPDATE);
+
+	in.rss.caps_mask = rss_caps_mask;
+	in.rss.rss_en = 1;
+	in.nic.caps_mask = rte_cpu_to_be_16(RTE_BIT32(XSC_TBM_CAP_RSS));
+	in.nic.caps = in.nic.caps_mask;
+
+	ret = xsc_dev_mailbox_exec(xdev, &in, sizeof(in), &out, sizeof(out));
+	if (ret != 0 || out.hdr.status != 0)
+		return -1;
+	return 0;
+}
+
 static int
 xsc_dev_alloc_vfos_info(struct xsc_dev *xdev)
 {
drivers/net/xsc/xsc_dev.h +1 -0
index 297c5d2324..2072f9ccb8 100644
@@ -162,6 +162,7 @@ int xsc_dev_init(struct rte_pci_device *pci_dev, struct xsc_dev **dev);
 void xsc_dev_uninit(struct xsc_dev *xdev);
 int xsc_dev_close(struct xsc_dev *xdev, int repr_id);
 int xsc_dev_repr_ports_probe(struct xsc_dev *xdev, int nb_repr_ports, int max_eth_ports);
+int xsc_dev_rss_key_modify(struct xsc_dev *xdev, uint8_t *rss_key, uint8_t rss_key_len);
 bool xsc_dev_is_vf(struct xsc_dev *xdev);
 int xsc_dev_qp_set_id_get(struct xsc_dev *xdev, int repr_id);
 int xsc_dev_get_mac(struct xsc_dev *xdev, uint8_t *mac);
drivers/net/xsc/xsc_ethdev.c +82 -0

100 lines not on this page · raw message

drivers/net/xsc/xsc_ethdev.h +7 -0
index 7d161bd22e..bc0fc54d50 100644
@@ -30,6 +30,13 @@ struct xsc_ethdev_priv {
 
 	uint16_t eth_type;
 	uint16_t qp_set_id;
+
+	uint16_t num_sq;
+	uint16_t num_rq;
+
+	uint16_t flags;
+	struct xsc_txq_data *(*txqs)[];
+	struct xsc_rxq_data *(*rxqs)[];
 };
 
 #define TO_XSC_ETHDEV_PRIV(dev) ((struct xsc_ethdev_priv *)(dev)->data->dev_private)
Signature · 1 line
2.25.1
#12 lore raw

Re: [PATCH v5 07/15] net/xsc: add ethdev configure and RSS ops

Quoted 15 lines · On Tue, 07 Jan 2025 10:49:55 +0800 "WanRenyong" <[email protected]> wrote:
drivers/net/xsc/xsc_ethdev.c +15 -0
+static int
+xsc_ethdev_rss_hash_conf_get(struct rte_eth_dev *dev,
+			     struct rte_eth_rss_conf *rss_conf)
+{
+	struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev);
+
+	if (rss_conf->rss_key != NULL && rss_conf->rss_key_len >= priv->rss_conf.rss_key_len)
+		memcpy(rss_conf->rss_key, priv->rss_conf.rss_key, priv->rss_conf.rss_key_len);
+
+	rss_conf->rss_key_len = priv->rss_conf.rss_key_len;
+	rss_conf->rss_hf = priv->rss_conf.rss_hf;
+	return 0;
+}
+
+static int

drivers/net/xsc/xsc_ethdev.c line 36

Quoted 10 lines
drivers/net/xsc/xsc_ethdev.c +10 -0
+xsc_ethdev_rss_hash_update(struct rte_eth_dev *dev,
+			   struct rte_eth_rss_conf *rss_conf)
+{
+	struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev);
+	int ret = 0;
+
+	ret = xsc_dev_rss_key_modify(priv->xdev, rss_conf->rss_key, rss_conf->rss_key_len);
+	if (ret == 0) {
+		rte_memcpy(priv->rss_conf.rss_key, rss_conf->rss_key,
+			   priv->rss_conf.rss_key_len);

This should probably be memcpy (not rte_memcpy) since not critical path.

author
#13 lore raw

Re: [PATCH v5 07/15] net/xsc: add ethdev configure and RSS ops

Quoted 21 lines · Stephen Hemminger
Quoted 18 lines · On Tue, 07 Jan 2025 10:49:55 +0800 "WanRenyong" <[email protected]> wrote:
drivers/net/xsc/xsc_ethdev.c +18 -0
+static int
+xsc_ethdev_rss_hash_conf_get(struct rte_eth_dev *dev,
+			     struct rte_eth_rss_conf *rss_conf)
+{
+	struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev);
+
+	if (rss_conf->rss_key != NULL && rss_conf->rss_key_len >= priv->rss_conf.rss_key_len)
+		memcpy(rss_conf->rss_key, priv->rss_conf.rss_key, priv->rss_conf.rss_key_len);
+
+	rss_conf->rss_key_len = priv->rss_conf.rss_key_len;
+	rss_conf->rss_hf = priv->rss_conf.rss_hf;
+	return 0;
+}
+
+static int
+xsc_ethdev_rss_hash_update(struct rte_eth_dev *dev,
+			   struct rte_eth_rss_conf *rss_conf)
+{
Quoted 8 lines

drivers/net/xsc/xsc_ethdev.c line 36

Quoted 7 lines
drivers/net/xsc/xsc_ethdev.c +7 -0
+	struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev);
+	int ret = 0;
+
+	ret = xsc_dev_rss_key_modify(priv->xdev, rss_conf->rss_key, rss_conf->rss_key_len);
+	if (ret == 0) {
+		rte_memcpy(priv->rss_conf.rss_key, rss_conf->rss_key,
+			   priv->rss_conf.rss_key_len);

This should probably be memcpy (not rte_memcpy) since not critical path.

OK, I will fix it next time.

Signature · 2 lines
Thanks,
WanRenyong
author
#14 lore raw

PATCH v5 8/15 net/xsc: add Rx and Tx queue setup

In reply to WanRenyong

Implement xsc ethdev Rx and Tx queue setup functions.

---
 drivers/net/xsc/xsc_defs.h   |  4 ++
 drivers/net/xsc/xsc_ethdev.c | 83 ++++++++++++++++++++++++++++++++++++
 drivers/net/xsc/xsc_rx.h     | 59 +++++++++++++++++++++++++
 drivers/net/xsc/xsc_rxtx.h   | 49 +++++++++++++++++++++
 drivers/net/xsc/xsc_tx.h     | 55 ++++++++++++++++++++++++
 5 files changed, 250 insertions(+)
 create mode 100644 drivers/net/xsc/xsc_rx.h
 create mode 100644 drivers/net/xsc/xsc_tx.h
drivers/net/xsc/xsc_defs.h +4 -0
index c445eadca1..6497b53e1e 100644
@@ -38,6 +38,10 @@
 #define XSC_EPAT_RSS_HASH_FUNC_FLAG	(1ULL << 6)
 #define XSC_EPAT_HAS_PPH_FLAG		(1ULL << 9)
 
+#define XSC_MAX_DESC_NUMBER		1024
+#define XSC_SEND_WQE_DS			3
+#define XSC_ESEG_EXTRA_DATA_SIZE	48u
+
 #define XSC_PF_TX_DB_ADDR		0x4802000
 #define XSC_PF_RX_DB_ADDR		0x4804000
 #define XSC_PF_CQ_DB_ADDR		0x2120000
drivers/net/xsc/xsc_ethdev.c +83 -0

101 lines not on this page · raw message

drivers/net/xsc/xsc_rx.h new file +59 -0

59 lines not on this page · raw message

drivers/net/xsc/xsc_rxtx.h +49 -0

67 lines not on this page · raw message

drivers/net/xsc/xsc_tx.h new file +55 -0

55 lines not on this page · raw message

Signature · 1 line
2.25.1
author
#15 lore raw

PATCH v5 9/15 net/xsc: add ethdev start

In reply to WanRenyong

Implement xsc ethdev start function.

---
v5:
* Remove unnecessary call of rte_wmb.

---
 drivers/net/xsc/meson.build  |   2 +
 drivers/net/xsc/xsc_dev.c    |  33 ++++
 drivers/net/xsc/xsc_dev.h    |   8 +
 drivers/net/xsc/xsc_ethdev.c | 172 +++++++++++++++++++++
 drivers/net/xsc/xsc_ethdev.h |  19 +++
 drivers/net/xsc/xsc_rx.c     | 291 +++++++++++++++++++++++++++++++++++
 drivers/net/xsc/xsc_rx.h     |   3 +
 drivers/net/xsc/xsc_rxtx.h   |  27 ++++
 drivers/net/xsc/xsc_tx.c     |  93 +++++++++++
 drivers/net/xsc/xsc_tx.h     |   4 +
 10 files changed, 652 insertions(+)
 create mode 100644 drivers/net/xsc/xsc_rx.c
 create mode 100644 drivers/net/xsc/xsc_tx.c
drivers/net/xsc/meson.build +2 -0
index 5ee03ea835..79664374e3 100644
@@ -12,4 +12,6 @@ sources = files(
         'xsc_vfio_mbox.c',
         'xsc_vfio.c',
         'xsc_np.c',
+        'xsc_rx.c',
+        'xsc_tx.c',
 )
drivers/net/xsc/xsc_dev.c +33 -0
index 74d577c7d0..054a08bf84 100644
@@ -68,6 +68,39 @@ xsc_dev_get_mac(struct xsc_dev *xdev, uint8_t *mac)
 	return xdev->dev_ops->get_mac(xdev, mac);
 }
 
+int
+xsc_dev_modify_qp_status(struct xsc_dev *xdev, uint32_t qpn, int num, int opcode)
+{
+	return xdev->dev_ops->modify_qp_status(xdev, qpn, num, opcode);
+}
+
+int
+xsc_dev_modify_qp_qostree(struct xsc_dev *xdev, uint16_t qpn)
+{
+	return xdev->dev_ops->modify_qp_qostree(xdev, qpn);
+}
+
+int
+xsc_dev_rx_cq_create(struct xsc_dev *xdev, struct xsc_rx_cq_params *cq_params,
+		     struct xsc_rx_cq_info *cq_info)
+{
+	return xdev->dev_ops->rx_cq_create(xdev, cq_params, cq_info);
+}
+
+int
+xsc_dev_tx_cq_create(struct xsc_dev *xdev, struct xsc_tx_cq_params *cq_params,
+		     struct xsc_tx_cq_info *cq_info)
+{
+	return xdev->dev_ops->tx_cq_create(xdev, cq_params, cq_info);
+}
+
+int
+xsc_dev_tx_qp_create(struct xsc_dev *xdev, struct xsc_tx_qp_params *qp_params,
+		     struct xsc_tx_qp_info *qp_info)
+{
+	return xdev->dev_ops->tx_qp_create(xdev, qp_params, qp_info);
+}
+
 int
 xsc_dev_close(struct xsc_dev *xdev, int repr_id)
 {
drivers/net/xsc/xsc_dev.h +8 -0
index 2072f9ccb8..d867084d78 100644
@@ -158,6 +158,14 @@ struct xsc_dev_ops {
 int xsc_dev_mailbox_exec(struct xsc_dev *xdev, void *data_in,
 			 int in_len, void *data_out, int out_len);
 void xsc_dev_ops_register(struct xsc_dev_ops *new_ops);
+int xsc_dev_modify_qp_status(struct xsc_dev *xdev, uint32_t qpn, int num, int opcode);
+int xsc_dev_modify_qp_qostree(struct xsc_dev *xdev, uint16_t qpn);
+int xsc_dev_rx_cq_create(struct xsc_dev *xdev, struct xsc_rx_cq_params *cq_params,
+			 struct xsc_rx_cq_info *cq_info);
+int xsc_dev_tx_cq_create(struct xsc_dev *xdev, struct xsc_tx_cq_params *cq_params,
+			 struct xsc_tx_cq_info *cq_info);
+int xsc_dev_tx_qp_create(struct xsc_dev *xdev, struct xsc_tx_qp_params *qp_params,
+			 struct xsc_tx_qp_info *qp_info);
 int xsc_dev_init(struct rte_pci_device *pci_dev, struct xsc_dev **dev);
 void xsc_dev_uninit(struct xsc_dev *xdev);
 int xsc_dev_close(struct xsc_dev *xdev, int repr_id);
drivers/net/xsc/xsc_ethdev.c +172 -0

190 lines not on this page · raw message

drivers/net/xsc/xsc_ethdev.h +19 -0
index bc0fc54d50..0b307c2828 100644
@@ -7,6 +7,9 @@
 
 #include "xsc_dev.h"
 
+#define XSC_FLAG_RX_QUEUE_INIT		0x1
+#define XSC_FLAG_TX_QUEUE_INIT		0x2
+
 struct xsc_ethdev_priv {
 	struct rte_eth_dev *eth_dev;
 	struct rte_pci_device *pci_dev;
@@ -41,4 +44,20 @@ struct xsc_ethdev_priv {
 
 #define TO_XSC_ETHDEV_PRIV(dev) ((struct xsc_ethdev_priv *)(dev)->data->dev_private)
 
+static __rte_always_inline struct xsc_txq_data *
+xsc_txq_get(struct xsc_ethdev_priv *priv, uint16_t idx)
+{
+	if (priv->txqs != NULL && (*priv->txqs)[idx] != NULL)
+		return (*priv->txqs)[idx];
+	return NULL;
+}
+
+static __rte_always_inline struct xsc_rxq_data *
+xsc_rxq_get(struct xsc_ethdev_priv *priv, uint16_t idx)
+{
+	if (priv->rxqs != NULL && (*priv->rxqs)[idx] != NULL)
+		return (*priv->rxqs)[idx];
+	return NULL;
+}
+
 #endif /* _XSC_ETHDEV_H_ */
drivers/net/xsc/xsc_rx.c new file +291 -0

291 lines not on this page · raw message

drivers/net/xsc/xsc_rx.h +3 -0
index 3653c0e335..5a2c4839ce 100644
@@ -56,4 +56,7 @@ struct __rte_cache_aligned xsc_rxq_data {
 	uint16_t rsv1:11;
 };
 
+int xsc_rxq_elts_alloc(struct xsc_rxq_data *rxq_data);
+int xsc_rxq_rss_obj_new(struct xsc_ethdev_priv *priv, uint16_t port_id);
+
 #endif /* _XSC_RX_H_ */
drivers/net/xsc/xsc_rxtx.h +27 -0
index 6311ed12d2..2771efafc6 100644
@@ -102,6 +102,24 @@ struct xsc_cqe_u64 {
 	struct xsc_cqe cqe1;
 };
 
+union xsc_cq_doorbell {
+	struct {
+		uint32_t next_cid:16;
+		uint32_t cq_num:15;
+		uint32_t cq_sta:1;
+	};
+	uint32_t cq_data;
+};
+
+union xsc_send_doorbell {
+	struct {
+		uint32_t next_pid:16;
+		uint32_t qp_num:15;
+		uint32_t rsv:1;
+	};
+	uint32_t send_data;
+};
+
 struct xsc_tx_cq_params {
 	uint16_t port_id;
 	uint16_t qp_id;
@@ -134,6 +152,15 @@ struct xsc_tx_qp_info {
 	uint16_t wqe_n;
 };
 
+union xsc_recv_doorbell {
+	struct {
+		uint32_t next_pid:13;
+		uint32_t qp_num:15;
+		uint32_t rsv:4;
+	};
+	uint32_t recv_data;
+};
+
 struct xsc_rx_cq_params {
 	uint16_t port_id;
 	uint16_t qp_id;
drivers/net/xsc/xsc_tx.c new file +93 -0

93 lines not on this page · raw message

drivers/net/xsc/xsc_tx.h +4 -0
index 11e249a4e3..674b65a555 100644
@@ -52,4 +52,8 @@ struct __rte_cache_aligned xsc_txq_data {
 	struct rte_mbuf *elts[]; /* Storage for queued packets, for free */
 };
 
+int xsc_txq_obj_new(struct xsc_dev *xdev, struct xsc_txq_data *txq_data,
+		    uint64_t offloads, uint16_t idx);
+void xsc_txq_elts_alloc(struct xsc_txq_data *txq_data);
+
 #endif /* _XSC_TX_H_ */
Signature · 1 line
2.25.1
author
#16 lore raw

PATCH v5 10/15 net/xsc: add ethdev stop and close

In reply to WanRenyong

Implement xsc ethdev close and stop functions.

---
 drivers/net/xsc/xsc_dev.c    |  12 ++++
 drivers/net/xsc/xsc_dev.h    |   2 +
 drivers/net/xsc/xsc_ethdev.c | 108 +++++++++++++++++++++++++++++++++++
 drivers/net/xsc/xsc_rx.c     |  47 +++++++++++++++
 drivers/net/xsc/xsc_rx.h     |   2 +
 drivers/net/xsc/xsc_tx.c     |  33 +++++++++++
 drivers/net/xsc/xsc_tx.h     |   2 +
 7 files changed, 206 insertions(+)
drivers/net/xsc/xsc_dev.c +12 -0
index 054a08bf84..350a1fbc70 100644
@@ -68,6 +68,18 @@ xsc_dev_get_mac(struct xsc_dev *xdev, uint8_t *mac)
 	return xdev->dev_ops->get_mac(xdev, mac);
 }
 
+int
+xsc_dev_destroy_qp(struct xsc_dev *xdev, void *qp)
+{
+	return xdev->dev_ops->destroy_qp(qp);
+}
+
+int
+xsc_dev_destroy_cq(struct xsc_dev *xdev, void *cq)
+{
+	return xdev->dev_ops->destroy_cq(cq);
+}
+
 int
 xsc_dev_modify_qp_status(struct xsc_dev *xdev, uint32_t qpn, int num, int opcode)
 {
drivers/net/xsc/xsc_dev.h +2 -0
index d867084d78..686d3b664d 100644
@@ -158,6 +158,8 @@ struct xsc_dev_ops {
 int xsc_dev_mailbox_exec(struct xsc_dev *xdev, void *data_in,
 			 int in_len, void *data_out, int out_len);
 void xsc_dev_ops_register(struct xsc_dev_ops *new_ops);
+int xsc_dev_destroy_qp(struct xsc_dev *xdev, void *qp);
+int xsc_dev_destroy_cq(struct xsc_dev *xdev, void *cq);
 int xsc_dev_modify_qp_status(struct xsc_dev *xdev, uint32_t qpn, int num, int opcode);
 int xsc_dev_modify_qp_qostree(struct xsc_dev *xdev, uint16_t qpn);
 int xsc_dev_rx_cq_create(struct xsc_dev *xdev, struct xsc_rx_cq_params *cq_params,
drivers/net/xsc/xsc_ethdev.c +108 -0

137 lines not on this page · raw message

drivers/net/xsc/xsc_rx.c +47 -0

50 lines not on this page · raw message

drivers/net/xsc/xsc_rx.h +2 -0
index 5a2c4839ce..e24b1a8829 100644
@@ -58,5 +58,7 @@ struct __rte_cache_aligned xsc_rxq_data {
 
 int xsc_rxq_elts_alloc(struct xsc_rxq_data *rxq_data);
 int xsc_rxq_rss_obj_new(struct xsc_ethdev_priv *priv, uint16_t port_id);
+void xsc_rxq_rss_obj_release(struct xsc_dev *xdev, struct xsc_rxq_data *rxq_data);
+void xsc_rxq_elts_free(struct xsc_rxq_data *rxq_data);
 
 #endif /* _XSC_RX_H_ */
drivers/net/xsc/xsc_tx.c +33 -0
index ba80488010..56daf6b4c6 100644
@@ -91,3 +91,36 @@ xsc_txq_obj_new(struct xsc_dev *xdev, struct xsc_txq_data *txq_data,
 error:
 	return -rte_errno;
 }
+
+void
+xsc_txq_obj_release(struct xsc_dev *xdev, struct xsc_txq_data *txq_data)
+{
+	PMD_DRV_LOG(DEBUG, "Destroy tx queue %u, portid %u",
+		    txq_data->idx, txq_data->port_id);
+	if (txq_data->qp != NULL)
+		xsc_dev_destroy_qp(xdev, txq_data->qp);
+	if (txq_data->cq != NULL)
+		xsc_dev_destroy_cq(xdev, txq_data->cq);
+}
+
+void
+xsc_txq_elts_free(struct xsc_txq_data *txq_data)
+{
+	const uint16_t elts_n = 1 << txq_data->elts_n;
+	const uint16_t elts_m = elts_n - 1;
+	uint16_t elts_head = txq_data->elts_head;
+	uint16_t elts_tail = txq_data->elts_tail;
+	struct rte_mbuf *(*elts)[elts_n] = &txq_data->elts;
+
+	txq_data->elts_head = 0;
+	txq_data->elts_tail = 0;
+	txq_data->elts_comp = 0;
+
+	while (elts_tail != elts_head) {
+		struct rte_mbuf *elt = (*elts)[elts_tail & elts_m];
+
+		rte_pktmbuf_free_seg(elt);
+		++elts_tail;
+	}
+	PMD_DRV_LOG(DEBUG, "Port %u txq %u free elts", txq_data->port_id, txq_data->idx);
+}
drivers/net/xsc/xsc_tx.h +2 -0
index 674b65a555..208f1c8490 100644
@@ -55,5 +55,7 @@ struct __rte_cache_aligned xsc_txq_data {
 int xsc_txq_obj_new(struct xsc_dev *xdev, struct xsc_txq_data *txq_data,
 		    uint64_t offloads, uint16_t idx);
 void xsc_txq_elts_alloc(struct xsc_txq_data *txq_data);
+void xsc_txq_obj_release(struct xsc_dev *xdev, struct xsc_txq_data *txq_data);
+void xsc_txq_elts_free(struct xsc_txq_data *txq_data);
 
 #endif /* _XSC_TX_H_ */
Signature · 1 line
2.25.1
author
#17 lore raw

PATCH v5 11/15 net/xsc: add ethdev Rx burst

In reply to WanRenyong

Implement xsc ethdev Rx burst function.

---
 drivers/net/xsc/xsc_ethdev.c |   3 +
 drivers/net/xsc/xsc_rx.c     | 174 +++++++++++++++++++++++++++++++++++
 drivers/net/xsc/xsc_rx.h     |   1 +
 drivers/net/xsc/xsc_rxtx.h   |  13 +++
 4 files changed, 191 insertions(+)
drivers/net/xsc/xsc_ethdev.c +3 -0
index f873fb2ebc..2f3fe04d3c 100644
@@ -310,6 +310,9 @@ xsc_ethdev_start(struct rte_eth_dev *dev)
 	}
 
 	dev->data->dev_started = 1;
+
+	dev->rx_pkt_burst = xsc_rx_burst;
+
 	ret = xsc_ethdev_enable(dev);
 
 	return 0;
drivers/net/xsc/xsc_rx.c +174 -0

180 lines not on this page · raw message

drivers/net/xsc/xsc_rx.h +1 -0
index e24b1a8829..90fbb89197 100644
@@ -56,6 +56,7 @@ struct __rte_cache_aligned xsc_rxq_data {
 	uint16_t rsv1:11;
 };
 
+uint16_t xsc_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n);
 int xsc_rxq_elts_alloc(struct xsc_rxq_data *rxq_data);
 int xsc_rxq_rss_obj_new(struct xsc_ethdev_priv *priv, uint16_t port_id);
 void xsc_rxq_rss_obj_release(struct xsc_dev *xdev, struct xsc_rxq_data *rxq_data);
drivers/net/xsc/xsc_rxtx.h +13 -0
index 2771efafc6..fa068f8b29 100644
@@ -175,4 +175,17 @@ struct xsc_rx_cq_info {
 	uint16_t cqe_n;
 };
 
+static __rte_always_inline int
+xsc_check_cqe_own(volatile struct xsc_cqe *cqe, const uint16_t cqe_n, const uint16_t ci)
+{
+	if (unlikely(((cqe->owner & XSC_CQE_OWNER_MASK) != ((ci >> cqe_n) & XSC_CQE_OWNER_MASK))))
+		return XSC_CQE_OWNER_HW;
+
+	rte_io_rmb();
+	if (cqe->msg_len <= 0 && cqe->is_error)
+		return XSC_CQE_OWNER_ERR;
+
+	return XSC_CQE_OWNER_SW;
+}
+
 #endif /* _XSC_RXTX_H_ */
Signature · 1 line
2.25.1
author
#18 lore raw

PATCH v5 12/15 net/xsc: add ethdev Tx burst

In reply to WanRenyong

Implement xsc ethdev Tx burst function.

---
 doc/guides/nics/features/xsc.ini |   4 +
 drivers/net/xsc/xsc_ethdev.c     |   1 +
 drivers/net/xsc/xsc_tx.c         | 228 +++++++++++++++++++++++++++++++
 drivers/net/xsc/xsc_tx.h         |   1 +
 4 files changed, 234 insertions(+)
doc/guides/nics/features/xsc.ini +4 -0
index bdeb7a984b..772c6418c4 100644
@@ -7,6 +7,10 @@
 RSS hash             = Y
 RSS key update       = Y
 RSS reta update      = Y
+L3 checksum offload  = Y
+L4 checksum offload  = Y
+Inner L3 checksum    = Y
+Inner L4 checksum    = Y
 Linux                = Y
 ARMv8                = Y
 x86-64               = Y
drivers/net/xsc/xsc_ethdev.c +1 -0
index 2f3fe04d3c..9cfb07b023 100644
@@ -312,6 +312,7 @@ xsc_ethdev_start(struct rte_eth_dev *dev)
 	dev->data->dev_started = 1;
 
 	dev->rx_pkt_burst = xsc_rx_burst;
+	dev->tx_pkt_burst = xsc_tx_burst;
 
 	ret = xsc_ethdev_enable(dev);
 
drivers/net/xsc/xsc_tx.c +228 -0

231 lines not on this page · raw message

drivers/net/xsc/xsc_tx.h +1 -0
index 208f1c8490..88419dd3a0 100644
@@ -52,6 +52,7 @@ struct __rte_cache_aligned xsc_txq_data {
 	struct rte_mbuf *elts[]; /* Storage for queued packets, for free */
 };
 
+uint16_t xsc_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n);
 int xsc_txq_obj_new(struct xsc_dev *xdev, struct xsc_txq_data *txq_data,
 		    uint64_t offloads, uint16_t idx);
 void xsc_txq_elts_alloc(struct xsc_txq_data *txq_data);
Signature · 1 line
2.25.1
author
#19 lore raw

PATCH v5 13/15 net/xsc: add basic stats ops

In reply to WanRenyong

Implement xsc ethdev basic statatics ops.

---
 doc/guides/nics/features/xsc.ini |  1 +
 drivers/net/xsc/xsc_ethdev.c     | 75 ++++++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+)
doc/guides/nics/features/xsc.ini +1 -0
index 772c6418c4..eb88517104 100644
@@ -11,6 +11,7 @@ L3 checksum offload  = Y
 L4 checksum offload  = Y
 Inner L3 checksum    = Y
 Inner L4 checksum    = Y
+Basic stats          = Y
 Linux                = Y
 ARMv8                = Y
 x86-64               = Y
drivers/net/xsc/xsc_ethdev.c +75 -0

87 lines not on this page · raw message

Signature · 1 line
2.25.1
#20 lore raw

Re: [PATCH v5 13/15] net/xsc: add basic stats ops

Quoted 13 lines · On Tue, 07 Jan 2025 10:50:09 +0800 "WanRenyong" <[email protected]> wrote:

Implement xsc ethdev basic statatics ops.

---
 doc/guides/nics/features/xsc.ini |  1 +
 drivers/net/xsc/xsc_ethdev.c     | 75 ++++++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+)
doc/guides/nics/features/xsc.ini +0 -0
index 772c6418c4..eb88517104 100644

doc/guides/nics/features/xsc.ini L3 checksum offload = Y · line 17

Quoted 7 lines
doc/guides/nics/features/xsc.ini +1 -0
@@ -11,6 +11,7 @@ L3 checksum offload  = Y
 L4 checksum offload  = Y
 Inner L3 checksum    = Y
 Inner L4 checksum    = Y
+Basic stats          = Y
 Linux                = Y
 ARMv8                = Y
 x86-64               = Y

The driver is also doing per-queue stats.
Mind of I just add that here as well.

The definition of what that means was updated to be:

Stats per queue
---------------

Supports per queue stats: q_ipackets, q_opackets, q_ibytes, q_obytes, q_errors. Statistics only supplied for first ``RTE_ETHDEV_QUEUE_STAT_CNTRS`` (16) queues.

Quoted 19 lines
drivers/net/xsc/xsc_ethdev.c +11 -0
index 9cfb07b023..000e27222d 100644
@@ -444,6 +444,79 @@ xsc_ethdev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
 	return 0;
 }
 
+static int
+xsc_ethdev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
+{
+	struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev);
+	uint32_t rxqs_n = priv->num_rq;
+	uint32_t txqs_n = priv->num_sq;
+	uint32_t i, idx;
+	struct xsc_rxq_data *rxq;
+	struct xsc_txq_data *txq;
+
+	for (i = 0; i < rxqs_n; ++i) {

drivers/net/xsc/xsc_ethdev.c xsc_ethdev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, · line 467

Quoted 10 lines
drivers/net/xsc/xsc_ethdev.c +10 -0
+		rxq = xsc_rxq_get(priv, i);
+		if (unlikely(rxq == NULL))
+			continue;
+
+		idx = rxq->idx;
+		if (idx < RTE_ETHDEV_QUEUE_STAT_CNTRS) {
+			stats->q_ipackets[idx] += rxq->stats.rx_pkts;
+			stats->q_ibytes[idx] += rxq->stats.rx_bytes;
+			stats->q_errors[idx] += (rxq->stats.rx_errors +
+						 rxq->stats.rx_nombuf);

Paren not needed here, but ok.

author
#21 lore raw

Re: [PATCH v5 13/15] net/xsc: add basic stats ops

Quoted 26 lines · Stephen Hemminger
Quoted 13 lines · On Tue, 07 Jan 2025 10:50:09 +0800 "WanRenyong" <[email protected]> wrote:

Implement xsc ethdev basic statatics ops.

---
  doc/guides/nics/features/xsc.ini |  1 +
  drivers/net/xsc/xsc_ethdev.c     | 75 ++++++++++++++++++++++++++++++++
  2 files changed, 76 insertions(+)
doc/guides/nics/features/xsc.ini +0 -0
index 772c6418c4..eb88517104 100644

doc/guides/nics/features/xsc.ini L3 checksum offload = Y · line 17

Quoted 7 lines
doc/guides/nics/features/xsc.ini +1 -0
@@ -11,6 +11,7 @@ L3 checksum offload  = Y
  L4 checksum offload  = Y
  Inner L3 checksum    = Y
  Inner L4 checksum    = Y
+Basic stats          = Y
  Linux                = Y
  ARMv8                = Y
  x86-64               = Y

The driver is also doing per-queue stats.
Mind of I just add that here as well.

Quoted 8 lines

The definition of what that means was updated to be:

Stats per queue
---------------

Supports per queue stats: q_ipackets, q_opackets, q_ibytes, q_obytes, q_errors. Statistics only supplied for first ``RTE_ETHDEV_QUEUE_STAT_CNTRS`` (16) queues.

Yes,thanks for your reminder, I will add it next.

Quoted 22 lines
Quoted 22 lines
drivers/net/xsc/xsc_ethdev.c +14 -0
index 9cfb07b023..000e27222d 100644
@@ -444,6 +444,79 @@ xsc_ethdev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
  	return 0;
  }
 
+static int
+xsc_ethdev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
+{
+	struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev);
+	uint32_t rxqs_n = priv->num_rq;
+	uint32_t txqs_n = priv->num_sq;
+	uint32_t i, idx;
+	struct xsc_rxq_data *rxq;
+	struct xsc_txq_data *txq;
+
+	for (i = 0; i < rxqs_n; ++i) {
+		rxq = xsc_rxq_get(priv, i);
+		if (unlikely(rxq == NULL))
+			continue;
Quoted 8 lines

drivers/net/xsc/xsc_ethdev.c xsc_ethdev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, · line 467

Quoted 7 lines
drivers/net/xsc/xsc_ethdev.c +7 -0
+
+		idx = rxq->idx;
+		if (idx < RTE_ETHDEV_QUEUE_STAT_CNTRS) {
+			stats->q_ipackets[idx] += rxq->stats.rx_pkts;
+			stats->q_ibytes[idx] += rxq->stats.rx_bytes;
+			stats->q_errors[idx] += (rxq->stats.rx_errors +
+						 rxq->stats.rx_nombuf);

Paren not needed here, but ok.

OK, agree with you, I will remove them next.

Signature · 2 lines
Thanks,
WanRenyong
author
#22 lore raw

PATCH v5 14/15 net/xsc: add ethdev infos get

In reply to WanRenyong

Implement xsc ethdev information get ops.

---
 drivers/net/xsc/xsc_ethdev.c | 61 ++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)
drivers/net/xsc/xsc_ethdev.c +61 -0
index 000e27222d..584890aa6f 100644
@@ -365,6 +365,66 @@ xsc_ethdev_close(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static uint64_t
+xsc_get_rx_queue_offloads(struct rte_eth_dev *dev)
+{
+	struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev);
+	struct xsc_dev_config *config = &priv->config;
+	uint64_t offloads = 0;
+
+	if (config->hw_csum)
+		offloads |= (RTE_ETH_RX_OFFLOAD_IPV4_CKSUM |
+			     RTE_ETH_RX_OFFLOAD_UDP_CKSUM |
+			     RTE_ETH_RX_OFFLOAD_TCP_CKSUM);
+
+	return offloads;
+}
+
+static uint64_t
+xsc_get_tx_port_offloads(struct rte_eth_dev *dev)
+{
+	struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev);
+	uint64_t offloads = 0;
+	struct xsc_dev_config *config = &priv->config;
+
+	if (config->hw_csum)
+		offloads |= (RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
+			     RTE_ETH_TX_OFFLOAD_UDP_CKSUM |
+			     RTE_ETH_TX_OFFLOAD_TCP_CKSUM);
+	if (config->tso)
+		offloads |= RTE_ETH_TX_OFFLOAD_TCP_TSO;
+	return offloads;
+}
+
+static int
+xsc_ethdev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
+{
+	struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev);
+
+	info->min_rx_bufsize = 64;
+	info->max_rx_pktlen = 65536;
+	info->max_lro_pkt_size = 0;
+	info->max_rx_queues = 256;
+	info->max_tx_queues = 1024;
+	info->rx_desc_lim.nb_max = 4096;
+	info->rx_desc_lim.nb_min = 16;
+	info->tx_desc_lim.nb_max = 8192;
+	info->tx_desc_lim.nb_min = 128;
+
+	info->rx_queue_offload_capa = xsc_get_rx_queue_offloads(dev);
+	info->rx_offload_capa = info->rx_queue_offload_capa;
+	info->tx_offload_capa = xsc_get_tx_port_offloads(dev);
+
+	info->if_index = priv->ifindex;
+	info->speed_capa = priv->xdev->link_speed_capa;
+	info->hash_key_size = XSC_RSS_HASH_KEY_LEN;
+	info->tx_desc_lim.nb_seg_max = 8;
+	info->tx_desc_lim.nb_mtu_seg_max = 8;
+	info->switch_info.name = dev->data->name;
+	info->switch_info.port_id = priv->representor_id;
+	return 0;
+}
+
 static int
 xsc_ethdev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
 			  uint32_t socket, const struct rte_eth_rxconf *conf,
@@ -550,6 +610,7 @@ const struct eth_dev_ops xsc_eth_dev_ops = {
 	.dev_close = xsc_ethdev_close,
 	.stats_get = xsc_ethdev_stats_get,
 	.stats_reset = xsc_ethdev_stats_reset,
+	.dev_infos_get = xsc_ethdev_infos_get,
 	.rx_queue_setup = xsc_ethdev_rx_queue_setup,
 	.tx_queue_setup = xsc_ethdev_tx_queue_setup,
 	.rx_queue_release = xsc_ethdev_rxq_release,
Signature · 1 line
2.25.1
author
#23 lore raw

PATCH v5 15/15 net/xsc: add ethdev link and MTU ops

In reply to WanRenyong

Implement xsc ethdev link and MTU ops.

---
 doc/guides/nics/features/xsc.ini |  1 +
 drivers/net/xsc/xsc_dev.c        | 33 ++++++++++++++++++
 drivers/net/xsc/xsc_dev.h        |  4 +++
 drivers/net/xsc/xsc_ethdev.c     | 60 ++++++++++++++++++++++++++++++++
 4 files changed, 98 insertions(+)
doc/guides/nics/features/xsc.ini +1 -0
index eb88517104..d73cf9d136 100644
@@ -4,6 +4,7 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+MTU update           = Y
 RSS hash             = Y
 RSS key update       = Y
 RSS reta update      = Y
drivers/net/xsc/xsc_dev.c +33 -0
index 350a1fbc70..c836f2f35a 100644
@@ -62,6 +62,39 @@ xsc_dev_mailbox_exec(struct xsc_dev *xdev, void *data_in,
 					   data_out, out_len);
 }
 
+int
+xsc_dev_set_link_up(struct xsc_dev *xdev)
+{
+	if (xdev->dev_ops->set_link_up == NULL)
+		return -ENOTSUP;
+
+	return xdev->dev_ops->set_link_up(xdev);
+}
+
+int
+xsc_dev_set_link_down(struct xsc_dev *xdev)
+{
+	if (xdev->dev_ops->set_link_down == NULL)
+		return -ENOTSUP;
+
+	return xdev->dev_ops->set_link_down(xdev);
+}
+
+int
+xsc_dev_link_update(struct xsc_dev *xdev, uint8_t funcid_type, int wait_to_complete)
+{
+	if (xdev->dev_ops->link_update == NULL)
+		return -ENOTSUP;
+
+	return xdev->dev_ops->link_update(xdev, funcid_type, wait_to_complete);
+}
+
+int
+xsc_dev_set_mtu(struct xsc_dev *xdev, uint16_t mtu)
+{
+	return xdev->dev_ops->set_mtu(xdev, mtu);
+}
+
 int
 xsc_dev_get_mac(struct xsc_dev *xdev, uint8_t *mac)
 {
drivers/net/xsc/xsc_dev.h +4 -0
index 686d3b664d..d661523e13 100644
@@ -158,6 +158,9 @@ struct xsc_dev_ops {
 int xsc_dev_mailbox_exec(struct xsc_dev *xdev, void *data_in,
 			 int in_len, void *data_out, int out_len);
 void xsc_dev_ops_register(struct xsc_dev_ops *new_ops);
+int xsc_dev_set_link_up(struct xsc_dev *xdev);
+int xsc_dev_set_link_down(struct xsc_dev *xde);
+int xsc_dev_link_update(struct xsc_dev *xdev, uint8_t funcid_type, int wait_to_complete);
 int xsc_dev_destroy_qp(struct xsc_dev *xdev, void *qp);
 int xsc_dev_destroy_cq(struct xsc_dev *xdev, void *cq);
 int xsc_dev_modify_qp_status(struct xsc_dev *xdev, uint32_t qpn, int num, int opcode);
@@ -175,6 +178,7 @@ int xsc_dev_repr_ports_probe(struct xsc_dev *xdev, int nb_repr_ports, int max_et
 int xsc_dev_rss_key_modify(struct xsc_dev *xdev, uint8_t *rss_key, uint8_t rss_key_len);
 bool xsc_dev_is_vf(struct xsc_dev *xdev);
 int xsc_dev_qp_set_id_get(struct xsc_dev *xdev, int repr_id);
+int xsc_dev_set_mtu(struct xsc_dev *xdev, uint16_t mtu);
 int xsc_dev_get_mac(struct xsc_dev *xdev, uint8_t *mac);
 
 #endif /* _XSC_DEV_H_ */
drivers/net/xsc/xsc_ethdev.c +60 -0

85 lines not on this page · raw message

Signature · 1 line
2.25.1
author
#24 lore raw
In reply to WanRenyong

Dear Maintainers,

I wanted to follow up this patch series that I submitted a week ago. It is currently listed as being in an 'under review' status on the patch worker. A week has now passed, and I have not received any feedback May I kindly ask if there is any additional information or clarification that I need to provide to facilitate the review process?

Thank you very much for your time and consideration.

Best regards,
WanRenyong

Quoted 108 lines · WanRenyong

This xsc PMD (**librte_net_xsc**) provides poll mode driver for Yunsilicon metaScale serials NICs.

Features:
---------
- MTU update
- TSO
- RSS hash
- RSS key update
- RSS reta update
- L3 checksum offload
- L4 checksum offload
- Inner L3 checksum
- Inner L4 checksum
- Basic stats

Support NICs:
-------------

- metaScale-200S   Single QSFP56 Port 200GE SmartNIC
- metaScale-200    Quad QSFP28 Ports 100GE SmartNIC
- metaScale-50     Dual QSFP28 Port 25GE SmartNIC
- metaScale-100Q   Quad QSFP28 Port 25GE SmartNIC

---

v5:
* fix compilation errors.
* fix coding style issue with misspelling.
* remove some unnecessary parameter checks.
* remove unnecessary call of rte_wmb.
* Rearrange elements in structure to avoid holes.

v4:
* Based on the review comments from previous versions, reconstruct the xsc PMD to eliminate the dependency on rdma core library and proprietary kernel driver, while adding support for the vfio kernel driver.

v3:
* fix compilation errors

v2:
* fix checkpatch warnings and errors

---
WanRenyong (15):
net/xsc: add xsc PMD framework
net/xsc: add xsc device initialization net/xsc: add xsc mailbox
net/xsc: add xsc dev ops to support VFIO driver net/xsc: add PCT interfaces
net/xsc: initialize xsc representors net/xsc: add ethdev configure and RSS ops net/xsc: add Rx and Tx queue setup net/xsc: add ethdev start
net/xsc: add ethdev stop and close net/xsc: add ethdev Rx burst
net/xsc: add ethdev Tx burst
net/xsc: add basic stats ops
net/xsc: add ethdev infos get
net/xsc: add ethdev link and MTU ops

  .mailmap                               |   5 +
  MAINTAINERS                            |  10 +
  doc/guides/nics/features/xsc.ini       |  18 +
  doc/guides/nics/index.rst              |   1 +
  doc/guides/nics/xsc.rst                |  31 +
  doc/guides/rel_notes/release_25_03.rst |   4 +
  drivers/net/meson.build                |   1 +
  drivers/net/xsc/meson.build            |  17 +
  drivers/net/xsc/xsc_cmd.h              | 387 +++++++++++
  drivers/net/xsc/xsc_defs.h             | 100 +++
  drivers/net/xsc/xsc_dev.c              | 397 +++++++++++
  drivers/net/xsc/xsc_dev.h              | 184 +++++
  drivers/net/xsc/xsc_ethdev.c           | 918 +++++++++++++++++++++++++
  drivers/net/xsc/xsc_ethdev.h           |  63 ++
  drivers/net/xsc/xsc_log.h              |  24 +
  drivers/net/xsc/xsc_np.c               | 492 +++++++++++++
  drivers/net/xsc/xsc_np.h               | 154 +++++
  drivers/net/xsc/xsc_rx.c               | 512 ++++++++++++++
  drivers/net/xsc/xsc_rx.h               |  65 ++
  drivers/net/xsc/xsc_rxtx.h             | 191 +++++
  drivers/net/xsc/xsc_tx.c               | 354 ++++++++++
  drivers/net/xsc/xsc_tx.h               |  62 ++
  drivers/net/xsc/xsc_vfio.c             | 746 ++++++++++++++++++++
  drivers/net/xsc/xsc_vfio_mbox.c        | 691 +++++++++++++++++++
  drivers/net/xsc/xsc_vfio_mbox.h        | 142 ++++
  25 files changed, 5569 insertions(+)

create mode 100644 doc/guides/nics/features/xsc.ini create mode 100644 doc/guides/nics/xsc.rst create mode 100644 drivers/net/xsc/meson.build create mode 100644 drivers/net/xsc/xsc_cmd.h create mode 100644 drivers/net/xsc/xsc_defs.h create mode 100644 drivers/net/xsc/xsc_dev.c create mode 100644 drivers/net/xsc/xsc_dev.h create mode 100644 drivers/net/xsc/xsc_ethdev.c create mode 100644 drivers/net/xsc/xsc_ethdev.h create mode 100644 drivers/net/xsc/xsc_log.h create mode 100644 drivers/net/xsc/xsc_np.c create mode 100644 drivers/net/xsc/xsc_np.h create mode 100644 drivers/net/xsc/xsc_rx.c create mode 100644 drivers/net/xsc/xsc_rx.h create mode 100644 drivers/net/xsc/xsc_rxtx.h create mode 100644 drivers/net/xsc/xsc_tx.c create mode 100644 drivers/net/xsc/xsc_tx.h create mode 100644 drivers/net/xsc/xsc_vfio.c create mode 100644 drivers/net/xsc/xsc_vfio_mbox.c create mode 100644 drivers/net/xsc/xsc_vfio_mbox.h

Signature · 2 lines
Thanks,
WanRenyong