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

Signed-off-by: WanRenyong <[email protected]>
---
 .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

diff --git a/.mailmap b/.mailmap
index 818798273f..18293215c3 100644
--- a/.mailmap
+++ b/.mailmap
@@ -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]>
diff --git a/MAINTAINERS b/MAINTAINERS
index 60bdcce543..3426658486 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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]>
diff --git a/doc/guides/nics/features/xsc.ini b/doc/guides/nics/features/xsc.ini
new file mode 100644
index 0000000000..b5c44ce535
--- /dev/null
+++ b/doc/guides/nics/features/xsc.ini
@@ -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
diff --git a/doc/guides/nics/index.rst b/doc/guides/nics/index.rst
index 50688d9f64..10a2eca3b0 100644
--- a/doc/guides/nics/index.rst
+++ b/doc/guides/nics/index.rst
@@ -70,4 +70,5 @@ Network Interface Controller Drivers
     vhost
     virtio
     vmxnet3
+    xsc
     zxdh
diff --git a/doc/guides/nics/xsc.rst b/doc/guides/nics/xsc.rst
new file mode 100644
index 0000000000..8e189db541
--- /dev/null
+++ b/doc/guides/nics/xsc.rst
@@ -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.
diff --git a/doc/guides/rel_notes/release_25_03.rst 
b/doc/guides/rel_notes/release_25_03.rst
index 426dfcd982..6f766add72 100644
--- a/doc/guides/rel_notes/release_25_03.rst
+++ b/doc/guides/rel_notes/release_25_03.rst
@@ -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
 -------------
diff --git a/drivers/net/meson.build b/drivers/net/meson.build
index dafd637ba4..c1ca7b0b39 100644
--- a/drivers/net/meson.build
+++ b/drivers/net/meson.build
@@ -63,6 +63,7 @@ drivers = [
         'vhost',
         'virtio',
         'vmxnet3',
+        'xsc',
         'zxdh',
 ]
 std_deps = ['ethdev', 'kvargs'] # 'ethdev' also pulls in mbuf, net, eal etc
diff --git a/drivers/net/xsc/meson.build b/drivers/net/xsc/meson.build
new file mode 100644
index 0000000000..84a09a23de
--- /dev/null
+++ b/drivers/net/xsc/meson.build
@@ -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',
+)
diff --git a/drivers/net/xsc/xsc_defs.h b/drivers/net/xsc/xsc_defs.h
new file mode 100644
index 0000000000..7c91d3443f
--- /dev/null
+++ b/drivers/net/xsc/xsc_defs.h
@@ -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_ */
diff --git a/drivers/net/xsc/xsc_ethdev.c b/drivers/net/xsc/xsc_ethdev.c
new file mode 100644
index 0000000000..a7dca46127
--- /dev/null
+++ b/drivers/net/xsc/xsc_ethdev.c
@@ -0,0 +1,89 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2025 Yunsilicon Technology Co., Ltd.
+ */
+
+#include <net/if.h>
+#include <ethdev_pci.h>
+
+#include "xsc_log.h"
+#include "xsc_defs.h"
+#include "xsc_ethdev.h"
+
+static int
+xsc_ethdev_init(struct rte_eth_dev *eth_dev)
+{
+       struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(eth_dev);
+
+       PMD_INIT_FUNC_TRACE();
+
+       priv->eth_dev = eth_dev;
+       priv->pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
+
+       return 0;
+}
+
+static int
+xsc_ethdev_uninit(struct rte_eth_dev *eth_dev)
+{
+       RTE_SET_USED(eth_dev);
+
+       PMD_INIT_FUNC_TRACE();
+
+       return 0;
+}
+
+static int
+xsc_ethdev_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
+                    struct rte_pci_device *pci_dev)
+{
+       int ret;
+
+       PMD_INIT_FUNC_TRACE();
+
+       ret = rte_eth_dev_pci_generic_probe(pci_dev,
+                                           sizeof(struct xsc_ethdev_priv),
+                                           xsc_ethdev_init);
+       if (ret) {
+               PMD_DRV_LOG(ERR, "Failed to probe ethdev: %s", pci_dev->name);
+               return ret;
+       }
+
+       return 0;
+}
+
+static int
+xsc_ethdev_pci_remove(struct rte_pci_device *pci_dev)
+{
+       int ret;
+
+       PMD_INIT_FUNC_TRACE();
+
+       ret = rte_eth_dev_pci_generic_remove(pci_dev, xsc_ethdev_uninit);
+       if (ret) {
+               PMD_DRV_LOG(ERR, "Could not remove ethdev: %s", pci_dev->name);
+               return ret;
+       }
+
+       return 0;
+}
+
+static const struct rte_pci_id xsc_ethdev_pci_id_map[] = {
+       { RTE_PCI_DEVICE(XSC_PCI_VENDOR_ID, XSC_PCI_DEV_ID_MS) },
+       { RTE_PCI_DEVICE(XSC_PCI_VENDOR_ID, XSC_PCI_DEV_ID_MSVF) },
+       { RTE_PCI_DEVICE(XSC_PCI_VENDOR_ID, XSC_PCI_DEV_ID_MVH) },
+       { RTE_PCI_DEVICE(XSC_PCI_VENDOR_ID, XSC_PCI_DEV_ID_MVHVF) },
+       { RTE_PCI_DEVICE(XSC_PCI_VENDOR_ID, XSC_PCI_DEV_ID_MVS) },
+       { RTE_PCI_DEVICE(0, 0) },
+};
+
+static struct rte_pci_driver xsc_ethdev_pci_driver = {
+       .id_table  = xsc_ethdev_pci_id_map,
+       .probe = xsc_ethdev_pci_probe,
+       .remove = xsc_ethdev_pci_remove,
+};
+
+RTE_PMD_REGISTER_PCI(net_xsc, xsc_ethdev_pci_driver);
+RTE_PMD_REGISTER_PCI_TABLE(net_xsc, xsc_ethdev_pci_id_map);
+
+RTE_LOG_REGISTER_SUFFIX(xsc_logtype_init, init, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(xsc_logtype_driver, driver, NOTICE);
diff --git a/drivers/net/xsc/xsc_ethdev.h b/drivers/net/xsc/xsc_ethdev.h
new file mode 100644
index 0000000000..508f5a86de
--- /dev/null
+++ b/drivers/net/xsc/xsc_ethdev.h
@@ -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_ */
diff --git a/drivers/net/xsc/xsc_log.h b/drivers/net/xsc/xsc_log.h
new file mode 100644
index 0000000000..16de436edb
--- /dev/null
+++ b/drivers/net/xsc/xsc_log.h
@@ -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_ */
-- 
2.25.1

Reply via email to