Skip to contentSkip to conversation

XSC PMD for Yunsilicon NICs

PATCH Superseded WanRenyong 2 participants 32 messages Jan 3, 2025 – Jan 6, 2025

Subsystems (2)

v4 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

WanRenyong

author
#0 lore raw

v4 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

---

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           | 943 +++++++++++++++++++++++++
 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             | 750 ++++++++++++++++++++
 drivers/net/xsc/xsc_vfio_mbox.c        | 691 ++++++++++++++++++
 drivers/net/xsc/xsc_vfio_mbox.h        | 142 ++++
 25 files changed, 5598 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 v4 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 v4 01/15] net/xsc: add xsc PMD framework

Quoted 18 lines · On Fri, 03 Jan 2025 23:04:06 +0800 "WanRenyong" <[email protected]> wrote:
doc/guides/nics/xsc.rst new file +18 -0
+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
+--------------

doc/guides/nics/xsc.rst line 31

Quoted 10 lines
doc/guides/nics/xsc.rst new file +10 -0
+
+- 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.

What kernel components does this driver expect? Are they all available in current kernels?

author
#3 lore raw

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

Quoted 24 lines · Stephen Hemminger
Quoted 21 lines · On Fri, 03 Jan 2025 23:04:06 +0800 "WanRenyong" <[email protected]> wrote:
doc/guides/nics/xsc.rst new file +21 -0
+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.
+
Quoted 8 lines

doc/guides/nics/xsc.rst line 31

Quoted 7 lines

+- Learning about Yunsilicon metaScale Series NICs using

doc/guides/nics/xsc.rst new file +6 -0
+  `<https://www.yunsilicon.com/#/productInformation>`_.
+
+Limitations or Known issues
+---------------------------
+32bit ARCHs are not supported.
+Windows and BSD are not supported yet.

What kernel components does this driver expect? Are they all available in current kernels?

Currently this driver expects only the vfio-pci kernel module which is recommended by DPDK .

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

PATCH v4 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.

---
 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
#5 lore raw

Re: [PATCH v4 02/15] net/xsc: add xsc device initialization

Quoted 20 lines · On Fri, 03 Jan 2025 23:04:08 +0800 "WanRenyong" <[email protected]> wrote:
drivers/net/xsc/xsc_dev.h new file +20 -0
+struct xsc_hwinfo {
+	uint8_t valid; /* 1: current phy info is valid, 0 : invalid */
+	uint32_t pcie_no; /* pcie number , 0 or 1 */
+	uint32_t func_id; /* pf glb func id */
+	uint32_t pcie_host; /* host pcie number */
+	uint32_t mac_phy_port; /* mac port */
+	uint32_t funcid_to_logic_port_off; /* port func id offset */
+	uint16_t lag_id;
+	uint16_t raw_qp_id_base;
+	uint16_t raw_rss_qp_id_base;
+	uint16_t pf0_vf_funcid_base;
+	uint16_t pf0_vf_funcid_top;
+	uint16_t pf1_vf_funcid_base;
+	uint16_t pf1_vf_funcid_top;
+	uint16_t pcie0_pf_funcid_base;
+	uint16_t pcie0_pf_funcid_top;
+	uint16_t pcie1_pf_funcid_base;
+	uint16_t pcie1_pf_funcid_top;
+	uint16_t lag_port_start;
+	uint16_t raw_tpe_qp_num;

drivers/net/xsc/xsc_dev.h line 57

Quoted 10 lines
drivers/net/xsc/xsc_dev.h new file +10 -0
+	int send_seg_num;
+	int recv_seg_num;
+	uint8_t on_chip_tbl_vld;
+	uint8_t dma_rw_tbl_vld;
+	uint8_t pct_compress_vld;
+	uint32_t chip_version;
+	uint32_t hca_core_clock;
+	uint8_t mac_bit;
+	uint8_t esw_mode;
+};

Can you rearrange elements in this structure so there are less holes? Or is it shared with the hardware.

Unless you need negative value as a sentinel, avoid use of int where unsigned could be used for seg_num.

author
#6 lore raw

Re: [PATCH v4 02/15] net/xsc: add xsc device initialization

Quoted 27 lines · Stephen Hemminger
Quoted 24 lines · On Fri, 03 Jan 2025 23:04:08 +0800 "WanRenyong" <[email protected]> wrote:
drivers/net/xsc/xsc_dev.h new file +24 -0
+struct xsc_hwinfo {
+	uint8_t valid; /* 1: current phy info is valid, 0 : invalid */
+	uint32_t pcie_no; /* pcie number , 0 or 1 */
+	uint32_t func_id; /* pf glb func id */
+	uint32_t pcie_host; /* host pcie number */
+	uint32_t mac_phy_port; /* mac port */
+	uint32_t funcid_to_logic_port_off; /* port func id offset */
+	uint16_t lag_id;
+	uint16_t raw_qp_id_base;
+	uint16_t raw_rss_qp_id_base;
+	uint16_t pf0_vf_funcid_base;
+	uint16_t pf0_vf_funcid_top;
+	uint16_t pf1_vf_funcid_base;
+	uint16_t pf1_vf_funcid_top;
+	uint16_t pcie0_pf_funcid_base;
+	uint16_t pcie0_pf_funcid_top;
+	uint16_t pcie1_pf_funcid_base;
+	uint16_t pcie1_pf_funcid_top;
+	uint16_t lag_port_start;
+	uint16_t raw_tpe_qp_num;
+	int send_seg_num;
+	int recv_seg_num;
+	uint8_t on_chip_tbl_vld;
+	uint8_t dma_rw_tbl_vld;
Quoted 8 lines

drivers/net/xsc/xsc_dev.h line 57

Quoted 6 lines
drivers/net/xsc/xsc_dev.h new file +6 -0
+	uint8_t pct_compress_vld;
+	uint32_t chip_version;
+	uint32_t hca_core_clock;
+	uint8_t mac_bit;
+	uint8_t esw_mode;
+};

Can you rearrange elements in this structure so there are less holes? Or is it shared with the hardware.

OK, I will try to rearrange the elemments in the next version. It 's not shared with hardware, it is just used to store hardward infos.

Quoted 3 lines

Unless you need negative value as a sentinel, avoid use of int where unsigned could be used for seg_num.

Got it, will fix it in the next version.

unsigned

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

PATCH v4 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 v4 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.

---
 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  | 750 ++++++++++++++++++++++++++++++++++++
 5 files changed, 893 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 7eae78d9bf..deeddeb7f1 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 {
 	uint8_t valid; /* 1: current phy info is valid, 0 : invalid */
 	uint32_t pcie_no; /* pcie number , 0 or 1 */
@@ -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 +750 -0

750 lines not on this page · raw message

Signature · 1 line
2.25.1
#9 lore raw

Re: [PATCH v4 04/15] net/xsc: add xsc dev ops to support VFIO driver

Quoted 10 lines · On Fri, 03 Jan 2025 23:04:13 +0800 "WanRenyong" <[email protected]> wrote:
drivers/net/xsc/xsc_vfio.c new file +10 -0
+static int
+xsc_vfio_destroy_qp(void *qp)
+{
+	int ret;
+	int in_len, out_len, cmd_len;
+	struct xsc_cmd_destroy_qp_mbox_in *in;
+	struct xsc_cmd_destroy_qp_mbox_out *out;
+	struct xsc_vfio_qp *data = (struct xsc_vfio_qp *)qp;
+
+	in_len = sizeof(struct xsc_cmd_destroy_qp_mbox_in);

drivers/net/xsc/xsc_vfio.c line 203

Quoted 10 lines
drivers/net/xsc/xsc_vfio.c new file +10 -0
+	out_len = sizeof(struct xsc_cmd_destroy_qp_mbox_out);
+	cmd_len = RTE_MAX(in_len, out_len);
+
+	in = malloc(cmd_len);
+	if (in == NULL) {
+		rte_errno = ENOMEM;
+		PMD_DRV_LOG(ERR, "Failed to alloc qp destroy cmd memory");
+		return -rte_errno;
+	}
+	memset(in, 0, cmd_len);

If this data structure needs to be shared between primary and secondary process, then it needs to be allocated with rte_malloc(). If it does not need to be shared, then it can come from heap with malloc().

author
#10 lore raw

Re: [PATCH v4 04/15] net/xsc: add xsc dev ops to support VFIO driver

Quoted 18 lines · Stephen Hemminger
Quoted 15 lines · On Fri, 03 Jan 2025 23:04:13 +0800 "WanRenyong" <[email protected]> wrote:
drivers/net/xsc/xsc_vfio.c new file +15 -0
+static int
+xsc_vfio_destroy_qp(void *qp)
+{
+	int ret;
+	int in_len, out_len, cmd_len;
+	struct xsc_cmd_destroy_qp_mbox_in *in;
+	struct xsc_cmd_destroy_qp_mbox_out *out;
+	struct xsc_vfio_qp *data = (struct xsc_vfio_qp *)qp;
+
+	in_len = sizeof(struct xsc_cmd_destroy_qp_mbox_in);
+	out_len = sizeof(struct xsc_cmd_destroy_qp_mbox_out);
+	cmd_len = RTE_MAX(in_len, out_len);
+
+	in = malloc(cmd_len);
+	if (in == NULL) {
Quoted 8 lines

drivers/net/xsc/xsc_vfio.c line 203

Quoted 5 lines
drivers/net/xsc/xsc_vfio.c new file +5 -0
+		rte_errno = ENOMEM;
+		PMD_DRV_LOG(ERR, "Failed to alloc qp destroy cmd memory");
+		return -rte_errno;
+	}
+	memset(in, 0, cmd_len);

If this data structure needs to be shared between primary and secondary process, then it needs to be allocated with rte_malloc(). If it does not need to be shared, then it can come from heap with malloc().

no, this data structure is not shared between primary and secondary process. it is a temporary memory to initial mailbox data structure.

Signature · 2 lines
Thanks,
WanRenyong
#11 lore raw

Re: [PATCH v4 04/15] net/xsc: add xsc dev ops to support VFIO driver

In reply to WanRenyong

drivers/net/xsc/xsc_vfio.c line 274

Quoted 9 lines · On Fri, 03 Jan 2025 23:04:13 +0800 "WanRenyong" <[email protected]> wrote:
drivers/net/xsc/xsc_vfio.c new file +9 -0
+static int
+xsc_vfio_set_mtu(struct xsc_dev *xdev, uint16_t mtu)
+{
+	struct xsc_cmd_set_mtu_mbox_in in;
+	struct xsc_cmd_set_mtu_mbox_out out;
+	int ret;
+
+	memset(&in, 0, sizeof(in));
+	memset(&out, 0, sizeof(out));

Optionally, you can initalize on stack variables with:

	struct xsc_cmd_set_mtu_mbox_in in = { };

Either way is ok, it is up to you.

author
#12 lore raw

Re: [PATCH v4 04/15] net/xsc: add xsc dev ops to support VFIO driver

Quoted 13 lines · Stephen Hemminger

drivers/net/xsc/xsc_vfio.c line 274

Quoted 9 lines · On Fri, 03 Jan 2025 23:04:13 +0800 "WanRenyong" <[email protected]> wrote:
drivers/net/xsc/xsc_vfio.c new file +9 -0
+static int
+xsc_vfio_set_mtu(struct xsc_dev *xdev, uint16_t mtu)
+{
+	struct xsc_cmd_set_mtu_mbox_in in;
+	struct xsc_cmd_set_mtu_mbox_out out;
+	int ret;
+
+	memset(&in, 0, sizeof(in));
+	memset(&out, 0, sizeof(out));

Optionally, you can initalize on stack variables with:

Quoted 3 lines
	struct xsc_cmd_set_mtu_mbox_in in = { };

Either way is ok, it is up to you.

Got it.

Signature · 2 lines
Thanks,
WanRenyong
#13 lore raw

Re: [PATCH v4 04/15] net/xsc: add xsc dev ops to support VFIO driver

In reply to WanRenyong
Quoted 9 lines · On Fri, 03 Jan 2025 23:04:13 +0800 "WanRenyong" <[email protected]> wrote:
drivers/net/xsc/xsc_vfio.c new file +9 -0
+static int
+xsc_vfio_get_mac(struct xsc_dev *xdev, uint8_t *mac)
+{
+	struct xsc_cmd_query_eth_mac_mbox_in in;
+	struct xsc_cmd_query_eth_mac_mbox_out out;
+	int ret;
+
+	memset(&in, 0, sizeof(in));
+	memset(&out, 0, sizeof(out));

drivers/net/xsc/xsc_vfio.c line 309

Quoted 10 lines
drivers/net/xsc/xsc_vfio.c new file +10 -0
+	in.hdr.opcode = rte_cpu_to_be_16(XSC_CMD_OP_QUERY_ETH_MAC);
+	ret = xsc_vfio_mbox_exec(xdev, &in, sizeof(in), &out, sizeof(out));
+	if (ret != 0 || out.hdr.status != 0) {
+		PMD_DRV_LOG(ERR, "Failed to get mtu, port=%d, err=%d, out.status=%u",
+			    xdev->port_id, ret, out.hdr.status);
+		rte_errno = ENOEXEC;
+		return -rte_errno;
+	}
+
+	memcpy(mac, out.mac, 6);

Prefer to use RTE_ETHER_ADDR_LEN rather than 6.
Or use rte_ether_addr_copy

author
#14 lore raw

Re: [PATCH v4 04/15] net/xsc: add xsc dev ops to support VFIO driver

Quoted 16 lines · Stephen Hemminger
Quoted 13 lines · On Fri, 03 Jan 2025 23:04:13 +0800 "WanRenyong" <[email protected]> wrote:
drivers/net/xsc/xsc_vfio.c new file +13 -0
+static int
+xsc_vfio_get_mac(struct xsc_dev *xdev, uint8_t *mac)
+{
+	struct xsc_cmd_query_eth_mac_mbox_in in;
+	struct xsc_cmd_query_eth_mac_mbox_out out;
+	int ret;
+
+	memset(&in, 0, sizeof(in));
+	memset(&out, 0, sizeof(out));
+	in.hdr.opcode = rte_cpu_to_be_16(XSC_CMD_OP_QUERY_ETH_MAC);
+	ret = xsc_vfio_mbox_exec(xdev, &in, sizeof(in), &out, sizeof(out));
+	if (ret != 0 || out.hdr.status != 0) {
+		PMD_DRV_LOG(ERR, "Failed to get mtu, port=%d, err=%d, out.status=%u",
Quoted 8 lines

drivers/net/xsc/xsc_vfio.c line 309

Quoted 6 lines
drivers/net/xsc/xsc_vfio.c new file +6 -0
+			    xdev->port_id, ret, out.hdr.status);
+		rte_errno = ENOEXEC;
+		return -rte_errno;
+	}
+
+	memcpy(mac, out.mac, 6);

Prefer to use RTE_ETHER_ADDR_LEN rather than 6.
Or use rte_ether_addr_copy

will fix it in the next version.

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

PATCH v4 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 1b8a84baa6..02c6346b45 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 deeddeb7f1..60762c84de 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
#16 lore raw

PATCH v4 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 60762c84de..9010225a20 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
#17 lore raw

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

In reply to WanRenyong

Implement xsc ethdev configure and RSS hash functions.

---
 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     | 106 +++++++++++++++++++++++++++++++
 drivers/net/xsc/xsc_ethdev.h     |   7 ++
 6 files changed, 158 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 71d7ab7ea4..84bab2bb93 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 9010225a20..3bebb18b98 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 +106 -0

124 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
#18 lore raw

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

drivers/net/xsc/xsc_ethdev.c line 21

Quoted 10 lines · On Fri, 03 Jan 2025 23:04:19 +0800 "WanRenyong" <[email protected]> wrote:
drivers/net/xsc/xsc_ethdev.c +10 -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) {
+		rte_errno = EINVAL;
+		return -rte_errno;
+	}

The parameter rss_conf is already checked for null in rte_eth_dev_rss_hash_conf_get().

drivers/net/xsc/xsc_ethdev.c line 42

Quoted 12 lines
drivers/net/xsc/xsc_ethdev.c +12 -0
+static int
+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;
+
+	if (rss_conf->rss_key_len > XSC_RSS_HASH_KEY_LEN || rss_conf->rss_key == NULL) {
+		PMD_DRV_LOG(ERR, "Xsc pmd key len is %d bigger than %d",
+			    rss_conf->rss_key_len, XSC_RSS_HASH_KEY_LEN);
+		return -EINVAL;
+	}

Key length is already validated against value returned from dev_info.hash_key_size before this is called by rte_eth_dev_rss_hash_update().

Quoted 37 lines
drivers/net/xsc/xsc_ethdev.c +37 -0
+static int
+xsc_ethdev_configure(struct rte_eth_dev *dev)
+{
+	struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev);
+	struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
+	int ret;
+	struct rte_eth_rss_conf *rss_conf;
+
+	priv->num_sq = dev->data->nb_tx_queues;
+	priv->num_rq = dev->data->nb_rx_queues;
+
+	if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)
+		dev->data->dev_conf.rxmode.offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
+
+	if (priv->rss_conf.rss_key == NULL) {
+		priv->rss_conf.rss_key = rte_zmalloc(NULL, XSC_RSS_HASH_KEY_LEN,
+						     RTE_CACHE_LINE_SIZE);
+		if (priv->rss_conf.rss_key == NULL) {
+			PMD_DRV_LOG(ERR, "Failed to alloc rss key");
+			rte_errno = ENOMEM;
+			ret = -rte_errno;
+			goto error;
+		}
+		priv->rss_conf.rss_key_len = XSC_RSS_HASH_KEY_LEN;
+	}
+
+	if (dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key != NULL) {
+		rss_conf = &dev->data->dev_conf.rx_adv_conf.rss_conf;
+		ret = xsc_ethdev_rss_hash_update(dev, rss_conf);
+		if (ret != 0) {
+			PMD_DRV_LOG(ERR, "Xsc pmd set rss key error!");
+			rte_errno = -ENOEXEC;
+			goto error;
+		}
+	}
+
+	if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_FILTER) {

drivers/net/xsc/xsc_ethdev.c line 101

Quoted 10 lines
drivers/net/xsc/xsc_ethdev.c +10 -0
+		PMD_DRV_LOG(ERR, "Xsc pmd do not support vlan filter now!");
+		rte_errno = EINVAL;
+		goto error;
+	}
+
+	if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP) {
+		PMD_DRV_LOG(ERR, "Xsc pmd do not support vlan strip now!");
+		rte_errno = EINVAL;
+		goto error;
+	}

These offload flags are already validated against rx_offload_capa by rte_eth_dev_configure().

author
#19 lore raw

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

Quoted 14 lines · Stephen Hemminger

drivers/net/xsc/xsc_ethdev.c line 21

Quoted 10 lines · On Fri, 03 Jan 2025 23:04:19 +0800 "WanRenyong" <[email protected]> wrote:
drivers/net/xsc/xsc_ethdev.c +10 -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) {
+		rte_errno = EINVAL;
+		return -rte_errno;
+	}

The parameter rss_conf is already checked for null in rte_eth_dev_rss_hash_conf_get().

will remove rss_conf check in the next version.

Quoted 15 lines

drivers/net/xsc/xsc_ethdev.c line 42

Quoted 13 lines
drivers/net/xsc/xsc_ethdev.c +12 -0
+static int
+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;
+
+	if (rss_conf->rss_key_len > XSC_RSS_HASH_KEY_LEN || rss_conf->rss_key == NULL) {
+		PMD_DRV_LOG(ERR, "Xsc pmd key len is %d bigger than %d",
+			    rss_conf->rss_key_len, XSC_RSS_HASH_KEY_LEN);
+		return -EINVAL;
+	}

Key length is already validated against value returned from dev_info.hash_key_size before this is called by rte_eth_dev_rss_hash_update().

will remove the key length validation in the next version.

Quoted 40 lines
Quoted 40 lines
drivers/net/xsc/xsc_ethdev.c +40 -0
+static int
+xsc_ethdev_configure(struct rte_eth_dev *dev)
+{
+	struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev);
+	struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
+	int ret;
+	struct rte_eth_rss_conf *rss_conf;
+
+	priv->num_sq = dev->data->nb_tx_queues;
+	priv->num_rq = dev->data->nb_rx_queues;
+
+	if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)
+		dev->data->dev_conf.rxmode.offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
+
+	if (priv->rss_conf.rss_key == NULL) {
+		priv->rss_conf.rss_key = rte_zmalloc(NULL, XSC_RSS_HASH_KEY_LEN,
+						     RTE_CACHE_LINE_SIZE);
+		if (priv->rss_conf.rss_key == NULL) {
+			PMD_DRV_LOG(ERR, "Failed to alloc rss key");
+			rte_errno = ENOMEM;
+			ret = -rte_errno;
+			goto error;
+		}
+		priv->rss_conf.rss_key_len = XSC_RSS_HASH_KEY_LEN;
+	}
+
+	if (dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key != NULL) {
+		rss_conf = &dev->data->dev_conf.rx_adv_conf.rss_conf;
+		ret = xsc_ethdev_rss_hash_update(dev, rss_conf);
+		if (ret != 0) {
+			PMD_DRV_LOG(ERR, "Xsc pmd set rss key error!");
+			rte_errno = -ENOEXEC;
+			goto error;
+		}
+	}
+
+	if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_FILTER) {
+		PMD_DRV_LOG(ERR, "Xsc pmd do not support vlan filter now!");
+		rte_errno = EINVAL;
+		goto error;
Quoted 8 lines

drivers/net/xsc/xsc_ethdev.c line 101

Quoted 7 lines
drivers/net/xsc/xsc_ethdev.c +7 -0
+	}
+
+	if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP) {
+		PMD_DRV_LOG(ERR, "Xsc pmd do not support vlan strip now!");
+		rte_errno = EINVAL;
+		goto error;
+	}

These offload flags are already validated against rx_offload_capa by rte_eth_dev_configure().

will remove these offload flags validation in the next version.

Quoted 2 lines
Signature · 2 lines
Thanks,
WanRenyong
author
#20 lore raw

PATCH v4 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
#21 lore raw

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

In reply to WanRenyong

Implement xsc ethdev start function.

---
 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 | 174 +++++++++++++++++++++
 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, 654 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 84bab2bb93..45e93e1a85 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 3bebb18b98..5aa1d8704e 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 +174 -0

192 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
#22 lore raw

Re: [PATCH v4 09/15] net/xsc: add ethdev start

Quoted 13 lines · On Fri, 03 Jan 2025 23:04:23 +0800 "WanRenyong" <[email protected]> wrote:
drivers/net/xsc/xsc_ethdev.c +13 -0
+static int
+xsc_ethdev_start(struct rte_eth_dev *dev)
+{
+	int ret;
+	struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev);
+
+	ret = xsc_txq_start(priv);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "Port %u txq start failed: %s",
+			    dev->data->port_id, strerror(rte_errno));
+		goto error;
+	}
+

drivers/net/xsc/xsc_ethdev.c xsc_ethdev_configure(struct rte_eth_dev *dev) · line 276

Quoted 10 lines
drivers/net/xsc/xsc_ethdev.c +10 -0
+	ret = xsc_rxq_start(priv);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "Port %u Rx queue start failed: %s",
+			    dev->data->port_id, strerror(rte_errno));
+		goto error;
+	}
+
+	dev->data->dev_started = 1;
+
+	rte_wmb();

In general, it is preferred that DPDK drivers use rte_atomic to get finer grain control over shared variables. Rather than using volatile and barriers. This is not an absolute requirement, but something that is preferred and improves performance on weakly ordered platforms.

author
#23 lore raw

Re: [PATCH v4 09/15] net/xsc: add ethdev start

Quoted 22 lines · Stephen Hemminger
Quoted 19 lines · On Fri, 03 Jan 2025 23:04:23 +0800 "WanRenyong" <[email protected]> wrote:
drivers/net/xsc/xsc_ethdev.c +19 -0
+static int
+xsc_ethdev_start(struct rte_eth_dev *dev)
+{
+	int ret;
+	struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev);
+
+	ret = xsc_txq_start(priv);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "Port %u txq start failed: %s",
+			    dev->data->port_id, strerror(rte_errno));
+		goto error;
+	}
+
+	ret = xsc_rxq_start(priv);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "Port %u Rx queue start failed: %s",
+			    dev->data->port_id, strerror(rte_errno));
+		goto error;
+	}
Quoted 8 lines

drivers/net/xsc/xsc_ethdev.c xsc_ethdev_configure(struct rte_eth_dev *dev) · line 276

Quoted 4 lines
drivers/net/xsc/xsc_ethdev.c +4 -0
+
+	dev->data->dev_started = 1;
+
+	rte_wmb();

In general, it is preferred that DPDK drivers use rte_atomic to get finer grain control over shared variables. Rather than using volatile and barriers. This is not an absolute requirement, but something that is preferred and improves performance on weakly ordered platforms.

Understood, maybe rte_wmb is not neccessary here, will remove it in the next version.

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

PATCH v4 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 45e93e1a85..80813c2c82 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 5aa1d8704e..4b5ab1d692 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
#25 lore raw

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

In reply to WanRenyong

Implement xsc ethdev Rx burst function.

---
 drivers/net/xsc/xsc_ethdev.c |   2 +
 drivers/net/xsc/xsc_rx.c     | 174 +++++++++++++++++++++++++++++++++++
 drivers/net/xsc/xsc_rx.h     |   1 +
 drivers/net/xsc/xsc_rxtx.h   |  13 +++
 4 files changed, 190 insertions(+)
drivers/net/xsc/xsc_ethdev.c +2 -0
index c5ee079d4a..00bd617c3e 100644
@@ -336,6 +336,8 @@ xsc_ethdev_start(struct rte_eth_dev *dev)
 	dev->data->dev_started = 1;
 
 	rte_wmb();
+	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
#26 lore raw

PATCH v4 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 00bd617c3e..0c49170313 100644
@@ -337,6 +337,7 @@ xsc_ethdev_start(struct rte_eth_dev *dev)
 
 	rte_wmb();
 	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
#27 lore raw

PATCH v4 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
author
#28 lore raw

PATCH v4 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 e44792e374..f4c127d7d4 100644
@@ -390,6 +390,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,
@@ -575,6 +635,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
#29 lore raw

Re: [PATCH v4 14/15] net/xsc: add ethdev infos get

Quoted 20 lines · On Fri, 03 Jan 2025 23:04:35 +0800 "WanRenyong" <[email protected]> wrote:
drivers/net/xsc/xsc_ethdev.c +20 -0
+
+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);
+

drivers/net/xsc/xsc_ethdev.c xsc_ethdev_close(struct rte_eth_dev *dev) · line 452

Quoted 10 lines
drivers/net/xsc/xsc_ethdev.c +10 -0
+	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;
+}
+

Note: that driver probably won't be at all functional without info_get but as long as each patch builds, it doesn't matter to me what order the patchset is in. Too hard to get a working driver at each step.

author
#30 lore raw

Re: [PATCH v4 14/15] net/xsc: add ethdev infos get

Quoted 28 lines · Stephen Hemminger
Quoted 25 lines · On Fri, 03 Jan 2025 23:04:35 +0800 "WanRenyong" <[email protected]> wrote:
drivers/net/xsc/xsc_ethdev.c +25 -0
+
+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;
Quoted 8 lines

drivers/net/xsc/xsc_ethdev.c xsc_ethdev_close(struct rte_eth_dev *dev) · line 452

Quoted 5 lines
drivers/net/xsc/xsc_ethdev.c +5 -0
+	info->switch_info.name = dev->data->name;
+	info->switch_info.port_id = priv->representor_id;
+	return 0;
+}
+

Note: that driver probably won't be at all functional without info_get but as long as each patch builds, it doesn't matter to me what order the patchset is in. Too hard to get a working driver at each step.

Agree with you.  When I made the patches, I had refered the the suggestion of Adding a new driver in DPDK Contributor's guidelines, the device info is recommanded to be placed later position. Altering the orde of the patchs is a bit of a hassle, so if it's not unacceptable, I am going to leave it as is.

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

PATCH v4 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 80813c2c82..b285a1e950 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 4b5ab1d692..ef0933ab06 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