Skip to contentSkip to conversation

net/zxdh: Provided zxdh basic init

PATCH In review Junlong Wang 5 participants 345 messages Sep 10, 2024 – Mar 4, 2025 Page 1 of 5

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 net/zxdh: Provided zxdh basic init

provided zxdh initialization of zxdh PMD driver.
include msg channel, np init and etc.

---
V4: Resolve compilation issues
V3: Resolve compilation issues
V2: Resolve compilation issues and modify doc(zxdh.ini zdh.rst)
V1: Provide zxdh basic init and open source NPSDK lib

---
 doc/guides/nics/features/zxdh.ini |   10 +
 doc/guides/nics/index.rst         |    1 +
 doc/guides/nics/zxdh.rst          |   34 +
 drivers/net/meson.build           |    1 +
 drivers/net/zxdh/meson.build      |   23 +
 drivers/net/zxdh/zxdh_common.c    |   59 ++
 drivers/net/zxdh/zxdh_common.h    |   32 +
 drivers/net/zxdh/zxdh_ethdev.c    | 1328 +++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev.h    |  202 +++++
 drivers/net/zxdh/zxdh_logs.h      |   38 +
 drivers/net/zxdh/zxdh_msg.c       | 1177 +++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_msg.h       |  408 +++++++++
 drivers/net/zxdh/zxdh_npsdk.c     |  158 ++++
 drivers/net/zxdh/zxdh_npsdk.h     |  216 +++++
 drivers/net/zxdh/zxdh_pci.c       |  462 ++++++++++
 drivers/net/zxdh/zxdh_pci.h       |  259 ++++++
 drivers/net/zxdh/zxdh_queue.c     |  138 +++
 drivers/net/zxdh/zxdh_queue.h     |   85 ++
 drivers/net/zxdh/zxdh_ring.h      |   87 ++
 drivers/net/zxdh/zxdh_rxtx.h      |   48 ++
 20 files changed, 4766 insertions(+)
 create mode 100644 doc/guides/nics/features/zxdh.ini
 create mode 100644 doc/guides/nics/zxdh.rst
 create mode 100644 drivers/net/zxdh/meson.build
 create mode 100644 drivers/net/zxdh/zxdh_common.c
 create mode 100644 drivers/net/zxdh/zxdh_common.h
 create mode 100644 drivers/net/zxdh/zxdh_ethdev.c
 create mode 100644 drivers/net/zxdh/zxdh_ethdev.h
 create mode 100644 drivers/net/zxdh/zxdh_logs.h
 create mode 100644 drivers/net/zxdh/zxdh_msg.c
 create mode 100644 drivers/net/zxdh/zxdh_msg.h
 create mode 100644 drivers/net/zxdh/zxdh_npsdk.c
 create mode 100644 drivers/net/zxdh/zxdh_npsdk.h
 create mode 100644 drivers/net/zxdh/zxdh_pci.c
 create mode 100644 drivers/net/zxdh/zxdh_pci.h
 create mode 100644 drivers/net/zxdh/zxdh_queue.c
 create mode 100644 drivers/net/zxdh/zxdh_queue.h
 create mode 100644 drivers/net/zxdh/zxdh_ring.h
 create mode 100644 drivers/net/zxdh/zxdh_rxtx.h
doc/guides/nics/features/zxdh.ini new file +10 -0
new file mode 100644
index 0000000000..083c75511b
@@ -0,0 +1,10 @@
+;
+; Supported features of the 'zxdh' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Linux                = Y
+x86-64               = Y
+ARMv8                = Y
+
doc/guides/nics/index.rst +1 -0
index c14bc7988a..8e371ac4a5 100644
@@ -69,3 +69,4 @@ Network Interface Controller Drivers
     vhost
     virtio
     vmxnet3
+    zxdh
doc/guides/nics/zxdh.rst new file +34 -0
new file mode 100644
index 0000000000..e878058b7b
@@ -0,0 +1,34 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright(c) 2023 ZTE Corporation.
+
+ZXDH Poll Mode Driver
+======================
+
+The ZXDH PMD (**librte_net_zxdh**) provides poll mode driver support
+for 25/100 Gbps ZXDH NX Series Ethernet Controller based on
+the ZTE Ethernet Controller E310/E312.
+
+
+Features
+--------
+
+Features of the zxdh PMD are:
+
+- Multi arch support: x86_64, ARMv8.
+
+Prerequisites
+-------------
+
+- Learning about ZXDH NX Series Ethernet Controller NICs using
+  `<https://enterprise.zte.com.cn/sup-detail.html?id=271&suptype=1>`_.
+
+Driver compilation and testing
+------------------------------
+
+Refer to the document :ref:`compiling and testing a PMD for a NIC <pmd_build_and_test>`
+for details.
+
+Limitations or Known issues
+---------------------------
+X86-32, Power8, ARMv7 and BSD are not supported yet.
+
drivers/net/meson.build +1 -0
index fb6d34b782..1a3db8a04d 100644
@@ -62,6 +62,7 @@ drivers = [
         'vhost',
         'virtio',
         'vmxnet3',
+	'zxdh',
 ]
 std_deps = ['ethdev', 'kvargs'] # 'ethdev' also pulls in mbuf, net, eal etc
 std_deps += ['bus_pci']         # very many PMDs depend on PCI, so make std
drivers/net/zxdh/meson.build new file +23 -0
new file mode 100644
index 0000000000..593e3c5933
@@ -0,0 +1,23 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2024 ZTE Corporation
+
+if not is_linux
+    build = false
+    reason = 'only supported on Linux'
+    subdir_done()
+endif
+
+if arch_subdir != 'x86' and arch_subdir != 'arm' or not dpdk_conf.get('RTE_ARCH_64')
+    build = false
+    reason = 'only supported on x86_64 and aarch64'
+    subdir_done()
+endif
+
+sources = files(
+	'zxdh_ethdev.c',
+	'zxdh_common.c',
+	'zxdh_pci.c',
+	'zxdh_msg.c',
+	'zxdh_queue.c',
+	'zxdh_npsdk.c',
+	)
drivers/net/zxdh/zxdh_common.c new file +59 -0

59 lines not on this page · raw message

drivers/net/zxdh/zxdh_common.h new file +32 -0
new file mode 100644
index 0000000000..912eb9ad42
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 ZTE Corporation
+ */
+
+#ifndef _ZXDH_COMMON_H_
+#define _ZXDH_COMMON_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <rte_ethdev.h>
+
+#include "zxdh_ethdev.h"
+
+#define ZXDH_VF_LOCK_ENABLE_MASK      0x1
+#define ZXDH_ACQUIRE_CHANNEL_NUM_MAX   10
+#define ZXDH_VF_LOCK_REG             0x90
+
+uint32_t zxdh_read_bar_reg(struct rte_eth_dev *dev, uint32_t bar, uint32_t reg);
+void zxdh_write_bar_reg(struct rte_eth_dev *dev, uint32_t bar, uint32_t reg, uint32_t val);
+int32_t zxdh_release_lock(struct zxdh_hw *hw);
+int32_t zxdh_acquire_lock(struct zxdh_hw *hw);
+uint32_t zxdh_read_comm_reg(uint64_t pci_comm_cfg_baseaddr, uint32_t reg);
+void zxdh_write_comm_reg(uint64_t pci_comm_cfg_baseaddr, uint32_t reg, uint32_t val);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ZXDH_COMMON_H_ */
drivers/net/zxdh/zxdh_ethdev.c new file +1328 -0

1,328 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev.h new file +202 -0

202 lines not on this page · raw message

drivers/net/zxdh/zxdh_logs.h new file +38 -0
new file mode 100644
index 0000000000..fb9b2d452f
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 ZTE Corporation
+ */
+
+#ifndef _ZXDH_LOGS_H_
+#define _ZXDH_LOGS_H_
+
+#include <rte_log.h>
+
+#define PMD_INIT_FUNC_TRACE() PMD_INIT_LOG(DEBUG, " >>")
+
+extern int32_t zxdh_logtype_init;
+#define PMD_INIT_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, zxdh_logtype_init, \
+	"offload_zxdh %s(): " fmt "\n", __func__, ## args)
+
+extern int32_t zxdh_logtype_driver;
+#define PMD_DRV_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, zxdh_logtype_driver, \
+	"offload_zxdh %s(): " fmt "\n", __func__, ## args)
+
+extern int zxdh_logtype_rx;
+#define PMD_RX_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, zxdh_logtype_rx, \
+	"offload_zxdh %s(): " fmt "\n", __func__, ## args)
+
+extern int zxdh_logtype_tx;
+#define PMD_TX_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, zxdh_logtype_tx, \
+	"offload_zxdh %s(): " fmt "\n", __func__, ## args)
+
+extern int32_t zxdh_logtype_msg;
+#define PMD_MSG_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, zxdh_logtype_msg, \
+	"offload_zxdh %s(): " fmt "\n", __func__, ## args)
+
+#endif /* _ZXDH_LOGS_H_ */
+
drivers/net/zxdh/zxdh_msg.c new file +1177 -0

1,177 lines not on this page · raw message

drivers/net/zxdh/zxdh_msg.h new file +408 -0

86 lines not on this page · raw message

drivers/net/zxdh/zxdh_npsdk.c new file +158 -0

158 lines not on this page · raw message

drivers/net/zxdh/zxdh_npsdk.h new file +216 -0

216 lines not on this page · raw message

drivers/net/zxdh/zxdh_pci.c new file +462 -0

462 lines not on this page · raw message

drivers/net/zxdh/zxdh_pci.h new file +259 -0

259 lines not on this page · raw message

drivers/net/zxdh/zxdh_queue.c new file +138 -0

138 lines not on this page · raw message

drivers/net/zxdh/zxdh_queue.h new file +85 -0

85 lines not on this page · raw message

drivers/net/zxdh/zxdh_ring.h new file +87 -0

87 lines not on this page · raw message

drivers/net/zxdh/zxdh_rxtx.h new file +48 -0

48 lines not on this page · raw message

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

Signature · 1 line
2.43.0

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

#1 lore raw

Hi, Ferruh

Could you please provide feedback on the patch I submitted? Any suggestions for improvement would be appreciated.

Thanks

#2 lore raw
In reply to Junlong Wang
Quoted 3 lines · Junlong Wang

provided zxdh initialization of zxdh PMD driver.
include msg channel, np init and etc.

Hi Junlong,

It is very hard to review the driver as a single patch, it helps to split driver into multiple patches, please check the suggestion on it:
https://patches.dpdk.org/project/dpdk/patch/[email protected]/

Also there are errors reported by scripts, please fix them:
./devtools/checkpatches.sh -n1 ./devtools/check-meson.py

Quoted 82 lines

---
V4: Resolve compilation issues
V3: Resolve compilation issues
V2: Resolve compilation issues and modify doc(zxdh.ini zdh.rst) V1: Provide zxdh basic init and open source NPSDK lib
---
 doc/guides/nics/features/zxdh.ini |   10 + doc/guides/nics/index.rst         |    1 + doc/guides/nics/zxdh.rst          |   34 + drivers/net/meson.build           |    1 + drivers/net/zxdh/meson.build      |   23 +

 drivers/net/zxdh/zxdh_common.c    |   59 ++
 drivers/net/zxdh/zxdh_common.h    |   32 +
 drivers/net/zxdh/zxdh_ethdev.c    | 1328 +++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev.h    |  202 +++++

 drivers/net/zxdh/zxdh_logs.h      |   38 + drivers/net/zxdh/zxdh_msg.c       | 1177 +++++++++++++++++++++++++ drivers/net/zxdh/zxdh_msg.h       |  408 +++++++++ drivers/net/zxdh/zxdh_npsdk.c     |  158 ++++ drivers/net/zxdh/zxdh_npsdk.h     |  216 +++++ drivers/net/zxdh/zxdh_pci.c       |  462 ++++++++++ drivers/net/zxdh/zxdh_pci.h       |  259 ++++++ drivers/net/zxdh/zxdh_queue.c     |  138 +++ drivers/net/zxdh/zxdh_queue.h     |   85 ++ drivers/net/zxdh/zxdh_ring.h      |   87 ++ drivers/net/zxdh/zxdh_rxtx.h      |   48 ++
 20 files changed, 4766 insertions(+)
 create mode 100644 doc/guides/nics/features/zxdh.ini create mode 100644 doc/guides/nics/zxdh.rst
 create mode 100644 drivers/net/zxdh/meson.build
 create mode 100644 drivers/net/zxdh/zxdh_common.c create mode 100644 drivers/net/zxdh/zxdh_common.h create mode 100644 drivers/net/zxdh/zxdh_ethdev.c create mode 100644 drivers/net/zxdh/zxdh_ethdev.h create mode 100644 drivers/net/zxdh/zxdh_logs.h
 create mode 100644 drivers/net/zxdh/zxdh_msg.c
 create mode 100644 drivers/net/zxdh/zxdh_msg.h
 create mode 100644 drivers/net/zxdh/zxdh_npsdk.c
 create mode 100644 drivers/net/zxdh/zxdh_npsdk.h
 create mode 100644 drivers/net/zxdh/zxdh_pci.c
 create mode 100644 drivers/net/zxdh/zxdh_pci.h
 create mode 100644 drivers/net/zxdh/zxdh_queue.c
 create mode 100644 drivers/net/zxdh/zxdh_queue.h
 create mode 100644 drivers/net/zxdh/zxdh_ring.h
 create mode 100644 drivers/net/zxdh/zxdh_rxtx.h

diff --git a/doc/guides/nics/features/zxdh.ini b/doc/guides/nics/ features/zxdh.ini
new file mode 100644
index 0000000000..083c75511b
--- /dev/null
+++ b/doc/guides/nics/features/zxdh.ini
@@ -0,0 +1,10 @@

doc/guides/nics/features/zxdh.ini new file +10 -0
+;
+; Supported features of the 'zxdh' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Linux                = Y
+x86-64               = Y
+ARMv8                = Y
+

diff --git a/doc/guides/nics/index.rst b/doc/guides/nics/index.rst index c14bc7988a..8e371ac4a5 100644
--- a/doc/guides/nics/index.rst
+++ b/doc/guides/nics/index.rst
@@ -69,3 +69,4 @@ Network Interface Controller Drivers vhost
     virtio
     vmxnet3
+    zxdh
diff --git a/doc/guides/nics/zxdh.rst b/doc/guides/nics/zxdh.rst new file mode 100644
index 0000000000..e878058b7b
--- /dev/null
+++ b/doc/guides/nics/zxdh.rst
@@ -0,0 +1,34 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright(c) 2023 ZTE Corporation.

doc/guides/nics/zxdh.rst line 10

Quoted 8 lines
doc/guides/nics/zxdh.rst new file +8 -0
+
+ZXDH Poll Mode Driver
+======================
+
+The ZXDH PMD (**librte_net_zxdh**) provides poll mode driver support
+for 25/100 Gbps ZXDH NX Series Ethernet Controller based on
+the ZTE Ethernet Controller E310/E312.
+

Can you please provide a link for the product?
There is a link in the prerequisetes section below, if that link is for product please move it here.

Quoted 52 lines
doc/guides/nics/zxdh.rst new file +24 -0
+
+Features
+--------
+
+Features of the zxdh PMD are:
+
+- Multi arch support: x86_64, ARMv8.
+
+Prerequisites
+-------------
+
+- Learning about ZXDH NX Series Ethernet Controller NICs using
+  `<https://enterprise.zte.com.cn/sup-detail.html?id=271&suptype=1>`_.
+
+Driver compilation and testing
+------------------------------
+
+Refer to the document :ref:`compiling and testing a PMD for a NIC <pmd_build_and_test>`
+for details.
+
+Limitations or Known issues
+---------------------------
+X86-32, Power8, ARMv7 and BSD are not supported yet.
+

diff --git a/drivers/net/meson.build b/drivers/net/meson.build index fb6d34b782..1a3db8a04d 100644
--- a/drivers/net/meson.build
+++ b/drivers/net/meson.build
@@ -62,6 +62,7 @@ drivers = [
         'vhost',
         'virtio',
         'vmxnet3',
+    'zxdh',
 ]
 std_deps = ['ethdev', 'kvargs'] # 'ethdev' also pulls in mbuf, net, eal etc std_deps += ['bus_pci']         # very many PMDs depend on PCI, so make std diff --git a/drivers/net/zxdh/meson.build b/drivers/net/zxdh/meson.build new file mode 100644
index 0000000000..593e3c5933
--- /dev/null
+++ b/drivers/net/zxdh/meson.build
@@ -0,0 +1,23 @@

drivers/net/zxdh/meson.build new file +10 -0
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2024 ZTE Corporation
+
+if not is_linux
+    build = false
+    reason = 'only supported on Linux'
+    subdir_done()
+endif
+
+if arch_subdir != 'x86' and arch_subdir !
Quoted 2 lines

= 'arm' or not dpdk_conf.get('RTE_ARCH_64')

Why not check 'RTE_ARCH_X86_64' and 'RTE_ARCH_ARM64'?

<...>

Quoted 4 lines
drivers/net/zxdh/zxdh_ethdev.c new file +3 -0
+/* dev_ops for zxdh, bare necessities for basic operation */
+static const struct eth_dev_ops zxdh_eth_dev_ops = {
+    .dev_configure             = NULL,

drivers/net/zxdh/zxdh_ethdev.c line 732

Quoted 10 lines
drivers/net/zxdh/zxdh_ethdev.c new file +10 -0
+    .dev_start                 = NULL,
+    .dev_stop                 = NULL,
+    .dev_close                 = NULL,
+
+    .rx_queue_setup             = NULL,
+    .rx_queue_intr_enable     = NULL,
+    .rx_queue_intr_disable     = NULL,
+
+    .tx_queue_setup             = NULL,
+};

No ops is implemented, so when you run dpdk application when your device exist, what happens, does application crash?

<...>

drivers/net/zxdh/zxdh_ethdev.c line 1287

Quoted 7 lines
drivers/net/zxdh/zxdh_ethdev.c new file +6 -0
+static int32_t zxdh_eth_dev_uninit(struct rte_eth_dev *eth_dev __rte_unused)
+{
+    if (rte_eal_process_type() == RTE_PROC_SECONDARY)
+        return 0;
+    /** todo later
+     * zxdh_dev_close(eth_dev);

Please either remove or implements todo comments in upstream driver.

Quoted 14 lines

+     */
+    return 0;

drivers/net/zxdh/zxdh_ethdev.c new file +11 -0
+}
+
+int32_t zxdh_eth_pci_remove(struct rte_pci_device *pci_dev)
+{
+    int32_t ret = rte_eth_dev_pci_generic_remove(pci_dev, zxdh_eth_dev_uninit);
+
+    if (ret == -ENODEV) { /* Port has already been released by close. */
+        ret = 0;
+    }
+    return ret;
+}

drivers/net/zxdh/zxdh_ethdev.c line 1310

Quoted 10 lines
drivers/net/zxdh/zxdh_ethdev.c new file +10 -0
+
+static const struct rte_pci_id pci_id_zxdh_map[] = {
+    {RTE_PCI_DEVICE(PCI_VENDOR_ID_ZTE, ZXDH_E310_PF_DEVICEID)},
+    {RTE_PCI_DEVICE(PCI_VENDOR_ID_ZTE, ZXDH_E310_VF_DEVICEID)},
+    {RTE_PCI_DEVICE(PCI_VENDOR_ID_ZTE, ZXDH_E312_PF_DEVICEID)},
+    {RTE_PCI_DEVICE(PCI_VENDOR_ID_ZTE, ZXDH_E312_VF_DEVICEID)},
+    {.vendor_id = 0, /* sentinel */ },
+};
+static struct rte_pci_driver zxdh_pmd = {
+    .driver = {.name = "net_zxdh", },

'driver.name' is already set by 'RTE_PMD_REGISTER_PCI' macro, no need to set above.

Quoted 6 lines

+    .id_table = pci_id_zxdh_map,
+    .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC, +    .probe = zxdh_eth_pci_probe,
+    .remove = zxdh_eth_pci_remove,

drivers/net/zxdh/zxdh_ethdev.c new file +1 -0
+};

drivers/net/zxdh/zxdh_ethdev.c line 1325

Quoted 10 lines
drivers/net/zxdh/zxdh_ethdev.c new file +10 -0
+
+RTE_PMD_REGISTER_PCI(net_zxdh, zxdh_pmd);
+RTE_PMD_REGISTER_PCI_TABLE(net_zxdh, pci_id_zxdh_map);
+RTE_PMD_REGISTER_KMOD_DEP(net_zxdh, "* vfio-pci");
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_init, init, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_driver, driver, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_rx, rx, DEBUG);
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_tx, tx, DEBUG);
+
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_msg, msg, DEBUG);

Default 'DEBUG' log level is too verbose, mostly default is NOTICE.

Quoted 3 lines

+RTE_PMD_REGISTER_PARAM_STRING(net_zxdh,
+    "q_depth=<int>");

Please document device arguments in the driver documentation.

<...>

#3 lore raw
In reply to Junlong Wang
Quoted 11 lines
Quoted 9 lines
drivers/net/zxdh/meson.build new file +7 -0
+if not is_linux
+    build = false
+    reason = 'only supported on Linux'
+    subdir_done()
+endif
+
+if arch_subdir != 'x86' and arch_subdir !

= 'arm' or not dpdk_conf.get('RTE_ARCH_64')

Why not check 'RTE_ARCH_X86_64' and 'RTE_ARCH_ARM64'?

we will fix it and use 'RTE_ARCH_X86_64' and 'RTE_ARCH_ARM64' to check,

other comments will be modified, and split the driver into multiple patches.

Thanks!

#4 lore raw
In reply to Junlong Wang
Quoted 31 lines · On Tue, 10 Sep 2024 20:00:20 +0800 Junlong Wang <[email protected]>…
doc/guides/nics/zxdh.rst new file +24 -0
new file mode 100644
index 0000000000..e878058b7b
@@ -0,0 +1,34 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright(c) 2023 ZTE Corporation.
+
+ZXDH Poll Mode Driver
+======================
+
+The ZXDH PMD (**librte_net_zxdh**) provides poll mode driver support
+for 25/100 Gbps ZXDH NX Series Ethernet Controller based on
+the ZTE Ethernet Controller E310/E312.
+
+
+Features
+--------
+
+Features of the zxdh PMD are:
+
+- Multi arch support: x86_64, ARMv8.
+
+Prerequisites
+-------------
+
+- Learning about ZXDH NX Series Ethernet Controller NICs using
+  `<https://enterprise.zte.com.cn/sup-detail.html?id=271&suptype=1>`_.
+

doc/guides/nics/zxdh.rst line 34

Quoted 10 lines
doc/guides/nics/zxdh.rst new file +10 -0
+Driver compilation and testing
+------------------------------
+
+Refer to the document :ref:`compiling and testing a PMD for a NIC <pmd_build_and_test>`
+for details.
+
+Limitations or Known issues
+---------------------------
+X86-32, Power8, ARMv7 and BSD are not supported yet.
+

Note: git gives warning when merging this.

/home/shemminger/DPDK/main/.git/worktrees/zxdh/rebase-apply/patch:78: new blank line at EOF. +
warning: 1 line adds whitespace errors.

#5 lore raw

v5 cover net/zxdh: introduce net zxdh driver

In reply to Junlong Wang

V5:
- split driver into multiple patches,part of the zxdh driver, later provide dev start/stop,queue_setup,mac,vlan,rss ,etc.
- fix errors reported by scripts.
- move the product link in zxdh.rst.
- fix meson check use RTE_ARCH_X86_64/RTE_ARCH_ARM64.
- modify other comments according to Ferruh's comments.

V4:
- Resolve compilation issues

Junlong Wang (9):
net/zxdh: add zxdh ethdev pmd driver net/zxdh: add logging implementation net/zxdh: add zxdh device pci init implementation net/zxdh: add msg chan and msg hwlock init net/zxdh: add msg chan enable implementation net/zxdh: add zxdh get device backend infos net/zxdh: add configure zxdh intr implementation net/zxdh: add zxdh dev infos get ops net/zxdh: add zxdh dev configure ops

 doc/guides/nics/features/zxdh.ini |    9 +
 doc/guides/nics/index.rst         |    1 +
 doc/guides/nics/zxdh.rst          |   30 +
 drivers/net/meson.build           |    1 +
 drivers/net/zxdh/meson.build      |   22 +
 drivers/net/zxdh/zxdh_common.c    |  368 +++++++++++
 drivers/net/zxdh/zxdh_common.h    |   42 ++
 drivers/net/zxdh/zxdh_ethdev.c    | 1021 +++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev.h    |  105 +++
 drivers/net/zxdh/zxdh_logs.h      |   35 +
 drivers/net/zxdh/zxdh_msg.c       |  992 ++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_msg.h       |  228 +++++++
 drivers/net/zxdh/zxdh_pci.c       |  449 +++++++++++++
 drivers/net/zxdh/zxdh_pci.h       |  191 ++++++
 drivers/net/zxdh/zxdh_queue.c     |  131 ++++
 drivers/net/zxdh/zxdh_queue.h     |  280 ++++++++
 drivers/net/zxdh/zxdh_rxtx.h      |   55 ++
 17 files changed, 3960 insertions(+)
 create mode 100644 doc/guides/nics/features/zxdh.ini
 create mode 100644 doc/guides/nics/zxdh.rst
 create mode 100644 drivers/net/zxdh/meson.build
 create mode 100644 drivers/net/zxdh/zxdh_common.c
 create mode 100644 drivers/net/zxdh/zxdh_common.h
 create mode 100644 drivers/net/zxdh/zxdh_ethdev.c
 create mode 100644 drivers/net/zxdh/zxdh_ethdev.h
 create mode 100644 drivers/net/zxdh/zxdh_logs.h
 create mode 100644 drivers/net/zxdh/zxdh_msg.c
 create mode 100644 drivers/net/zxdh/zxdh_msg.h
 create mode 100644 drivers/net/zxdh/zxdh_pci.c
 create mode 100644 drivers/net/zxdh/zxdh_pci.h
 create mode 100644 drivers/net/zxdh/zxdh_queue.c
 create mode 100644 drivers/net/zxdh/zxdh_queue.h
 create mode 100644 drivers/net/zxdh/zxdh_rxtx.h
Signature · 1 line
2.27.0
#6 lore raw

PATCH v5 1/9 net/zxdh: add zxdh ethdev pmd driver

Add basic zxdh ethdev init and register PCI probe functions Update doc files

---
 doc/guides/nics/features/zxdh.ini |  9 +++
 doc/guides/nics/index.rst         |  1 +
 doc/guides/nics/zxdh.rst          | 30 ++++++++++
 drivers/net/meson.build           |  1 +
 drivers/net/zxdh/meson.build      | 18 ++++++
 drivers/net/zxdh/zxdh_ethdev.c    | 92 +++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev.h    | 44 +++++++++++++++
 7 files changed, 195 insertions(+)
 create mode 100644 doc/guides/nics/features/zxdh.ini
 create mode 100644 doc/guides/nics/zxdh.rst
 create mode 100644 drivers/net/zxdh/meson.build
 create mode 100644 drivers/net/zxdh/zxdh_ethdev.c
 create mode 100644 drivers/net/zxdh/zxdh_ethdev.h
doc/guides/nics/features/zxdh.ini new file +9 -0
new file mode 100644
index 0000000000..05c8091ed7
@@ -0,0 +1,9 @@
+;
+; Supported features of the 'zxdh' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Linux                = Y
+x86-64               = Y
+ARMv8                = Y
doc/guides/nics/index.rst +1 -0
index c14bc7988a..8e371ac4a5 100644
@@ -69,3 +69,4 @@ Network Interface Controller Drivers
     vhost
     virtio
     vmxnet3
+    zxdh
doc/guides/nics/zxdh.rst new file +30 -0
new file mode 100644
index 0000000000..4cf531e967
@@ -0,0 +1,30 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright(c) 2023 ZTE Corporation.
+
+ZXDH Poll Mode Driver
+======================
+
+The ZXDH PMD (**librte_net_zxdh**) provides poll mode driver support
+for 25/100 Gbps ZXDH NX Series Ethernet Controller based on
+the ZTE Ethernet Controller E310/E312.
+
+- Learning about ZXDH NX Series Ethernet Controller NICs using
+  `<https://enterprise.zte.com.cn/sup-detail.html?id=271&suptype=1>`_.
+
+Features
+--------
+
+Features of the zxdh PMD are:
+
+- Multi arch support: x86_64, ARMv8.
+
+
+Driver compilation and testing
+------------------------------
+
+Refer to the document :ref:`compiling and testing a PMD for a NIC <pmd_build_and_test>`
+for details.
+
+Limitations or Known issues
+---------------------------
+X86-32, Power8, ARMv7 and BSD are not supported yet.
drivers/net/meson.build +1 -0
index fb6d34b782..0a12914534 100644
@@ -62,6 +62,7 @@ drivers = [
         'vhost',
         'virtio',
         'vmxnet3',
+        'zxdh',
 ]
 std_deps = ['ethdev', 'kvargs'] # 'ethdev' also pulls in mbuf, net, eal etc
 std_deps += ['bus_pci']         # very many PMDs depend on PCI, so make std
drivers/net/zxdh/meson.build new file +18 -0
new file mode 100644
index 0000000000..58e39c1f96
@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2024 ZTE Corporation
+
+if not is_linux
+    build = false
+    reason = 'only supported on Linux'
+    subdir_done()
+endif
+
+if not dpdk_conf.has('RTE_ARCH_X86_64') or not dpdk_conf.get('RTE_ARCH_64')
+    build = false
+    reason = 'only supported on x86_64 and aarch64'
+    subdir_done()
+endif
+
+sources = files(
+	'zxdh_ethdev.c',
+	)
drivers/net/zxdh/zxdh_ethdev.c new file +92 -0

92 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev.h new file +44 -0

44 lines not on this page · raw message

Signature · 1 line
2.27.0
#7 lore raw

PATCH v5 2/9 net/zxdh: add logging implementation

Adds zxdh logging implementation.

---
 drivers/net/zxdh/zxdh_ethdev.c | 15 +++++++++++++--
 drivers/net/zxdh/zxdh_logs.h   | 35 ++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/zxdh/zxdh_logs.h
drivers/net/zxdh/zxdh_ethdev.c +13 -2
index 75d8b28cc3..7220770c01 100644
@@ -7,6 +7,7 @@
 #include <rte_ethdev.h>
 
 #include "zxdh_ethdev.h"
+#include "zxdh_logs.h"
 
 static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 {
@@ -19,13 +20,18 @@ static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 	/* Allocate memory for storing MAC addresses */
 	eth_dev->data->mac_addrs = rte_zmalloc("zxdh_mac",
 			ZXDH_MAX_MAC_ADDRS * RTE_ETHER_ADDR_LEN, 0);
-	if (eth_dev->data->mac_addrs == NULL)
+	if (eth_dev->data->mac_addrs == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to allocate %d bytes store MAC addresses",
+				ZXDH_MAX_MAC_ADDRS * RTE_ETHER_ADDR_LEN);
 		return -ENOMEM;
+	}
 
 	memset(hw, 0, sizeof(*hw));
 	hw->bar_addr[0] = (uint64_t)pci_dev->mem_resource[0].addr;
-	if (hw->bar_addr[0] == 0)
+	if (hw->bar_addr[0] == 0) {
+		PMD_INIT_LOG(ERR, "Bad mem resource.");
 		return -EIO;
+	}
 
 	hw->device_id = pci_dev->id.device_id;
 	hw->port_id = eth_dev->data->port_id;
@@ -90,3 +96,8 @@ static struct rte_pci_driver zxdh_pmd = {
 RTE_PMD_REGISTER_PCI(net_zxdh, zxdh_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_zxdh, pci_id_zxdh_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_zxdh, "* vfio-pci");
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_init, init, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_driver, driver, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_rx, rx, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_tx, tx, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_msg, msg, NOTICE);
drivers/net/zxdh/zxdh_logs.h new file +35 -0
new file mode 100644
index 0000000000..e118d26379
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 ZTE Corporation
+ */
+
+#ifndef _ZXDH_LOGS_H_
+#define _ZXDH_LOGS_H_
+
+#include <rte_log.h>
+
+extern int zxdh_logtype_init;
+#define PMD_INIT_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, zxdh_logtype_init, \
+	"offload_zxdh %s(): " fmt "\n", __func__, ## args)
+
+extern int zxdh_logtype_driver;
+#define PMD_DRV_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, zxdh_logtype_driver, \
+	"offload_zxdh %s(): " fmt "\n", __func__, ## args)
+
+extern int zxdh_logtype_rx;
+#define PMD_RX_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, zxdh_logtype_rx, \
+	"offload_zxdh %s(): " fmt "\n", __func__, ## args)
+
+extern int zxdh_logtype_tx;
+#define PMD_TX_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, zxdh_logtype_tx, \
+	"offload_zxdh %s(): " fmt "\n", __func__, ## args)
+
+extern int zxdh_logtype_msg;
+#define PMD_MSG_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, zxdh_logtype_msg, \
+	"offload_zxdh %s(): " fmt "\n", __func__, ## args)
+
+#endif /* _ZXDH_LOGS_H_ */
Signature · 1 line
2.27.0
#8 lore raw

PATCH v5 3/9 net/zxdh: add zxdh device pci init implementation

Add device pci init implementation,
to obtain PCI capability and read configuration, etc

---
 drivers/net/zxdh/meson.build   |   5 +-
 drivers/net/zxdh/zxdh_ethdev.c |  43 +++++
 drivers/net/zxdh/zxdh_ethdev.h |  20 ++-
 drivers/net/zxdh/zxdh_pci.c    | 290 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_pci.h    | 151 +++++++++++++++++
 drivers/net/zxdh/zxdh_queue.h  | 109 +++++++++++++
 drivers/net/zxdh/zxdh_rxtx.h   |  55 +++++++
 7 files changed, 669 insertions(+), 4 deletions(-)
 create mode 100644 drivers/net/zxdh/zxdh_pci.c
 create mode 100644 drivers/net/zxdh/zxdh_pci.h
 create mode 100644 drivers/net/zxdh/zxdh_queue.h
 create mode 100644 drivers/net/zxdh/zxdh_rxtx.h
drivers/net/zxdh/meson.build +3 -2
index 58e39c1f96..080c6c7725 100644
@@ -14,5 +14,6 @@ if not dpdk_conf.has('RTE_ARCH_X86_64') or not dpdk_conf.get('RTE_ARCH_64')
 endif
 
 sources = files(
-	'zxdh_ethdev.c',
-	)
+    'zxdh_ethdev.c',
+    'zxdh_pci.c',
+    )
drivers/net/zxdh/zxdh_ethdev.c +43 -0

55 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev.h +18 -2
index 04023bfe84..18d9916713 100644
@@ -9,6 +9,7 @@
 extern "C" {
 #endif
 
+#include <rte_ether.h>
 #include "ethdev_driver.h"
 
 /* ZXDH PCI vendor/device ID. */
@@ -23,16 +24,31 @@ extern "C" {
 #define ZXDH_MAX_MC_MAC_ADDRS  32
 #define ZXDH_MAX_MAC_ADDRS     (ZXDH_MAX_UC_MAC_ADDRS + ZXDH_MAX_MC_MAC_ADDRS)
 
+#define ZXDH_RX_QUEUES_MAX  128U
+#define ZXDH_TX_QUEUES_MAX  128U
+
 #define ZXDH_NUM_BARS    2
 
 struct zxdh_hw {
 	struct rte_eth_dev *eth_dev;
-	uint64_t bar_addr[ZXDH_NUM_BARS];
+	struct zxdh_pci_common_cfg *common_cfg;
+	struct zxdh_net_config *dev_cfg;
 
-	uint32_t  speed;
+	uint64_t bar_addr[ZXDH_NUM_BARS];
+	uint64_t host_features;
+	uint64_t guest_features;
+	uint32_t max_queue_pairs;
+	uint32_t speed;
+	uint32_t notify_off_multiplier;
+	uint16_t *notify_base;
+	uint16_t pcie_id;
 	uint16_t device_id;
 	uint16_t port_id;
 
+	uint8_t *isr;
+	uint8_t weak_barriers;
+	uint8_t use_msix;
+	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
 	uint8_t duplex;
 	uint8_t is_pf;
 };
drivers/net/zxdh/zxdh_pci.c new file +290 -0

290 lines not on this page · raw message

drivers/net/zxdh/zxdh_pci.h new file +151 -0

151 lines not on this page · raw message

drivers/net/zxdh/zxdh_queue.h new file +109 -0

109 lines not on this page · raw message

drivers/net/zxdh/zxdh_rxtx.h new file +55 -0

55 lines not on this page · raw message

Signature · 1 line
2.27.0
#9 lore raw

PATCH v5 4/9 net/zxdh: add msg chan and msg hwlock init

In reply to Junlong Wang

Add msg channel and hwlock init implementation.

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_ethdev.c |  15 +++
 drivers/net/zxdh/zxdh_ethdev.h |   1 +
 drivers/net/zxdh/zxdh_msg.c    | 161 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_msg.h    |  65 +++++++++++++
 5 files changed, 243 insertions(+)
 create mode 100644 drivers/net/zxdh/zxdh_msg.c
 create mode 100644 drivers/net/zxdh/zxdh_msg.h
drivers/net/zxdh/meson.build +1 -0
index 080c6c7725..9d0b5b9fd3 100644
@@ -16,4 +16,5 @@ endif
 sources = files(
     'zxdh_ethdev.c',
     'zxdh_pci.c',
+    'zxdh_msg.c',
     )
drivers/net/zxdh/zxdh_ethdev.c +15 -0
index bb219c189f..66b57c4e59 100644
@@ -9,6 +9,7 @@
 #include "zxdh_ethdev.h"
 #include "zxdh_logs.h"
 #include "zxdh_pci.h"
+#include "zxdh_msg.h"
 
 struct zxdh_hw_internal zxdh_hw_internal[RTE_MAX_ETHPORTS];
 
@@ -83,9 +84,23 @@ static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 	if (ret < 0)
 		goto err_zxdh_init;
 
+	ret = zxdh_msg_chan_init();
+	if (ret < 0) {
+		PMD_INIT_LOG(ERR, "Failed to init bar msg chan");
+		goto err_zxdh_init;
+	}
+	hw->msg_chan_init = 1;
+
+	ret = zxdh_msg_chan_hwlock_init(eth_dev);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "zxdh_msg_chan_hwlock_init failed ret %d", ret);
+		goto err_zxdh_init;
+	}
+
 	return ret;
 
 err_zxdh_init:
+	zxdh_bar_msg_chan_exit();
 	rte_free(eth_dev->data->mac_addrs);
 	eth_dev->data->mac_addrs = NULL;
 	return ret;
drivers/net/zxdh/zxdh_ethdev.h +1 -0
index 18d9916713..24eb3a5ca0 100644
@@ -51,6 +51,7 @@ struct zxdh_hw {
 	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
 	uint8_t duplex;
 	uint8_t is_pf;
+	uint8_t msg_chan_init;
 };
 
 #ifdef __cplusplus
drivers/net/zxdh/zxdh_msg.c new file +161 -0

161 lines not on this page · raw message

drivers/net/zxdh/zxdh_msg.h new file +65 -0

65 lines not on this page · raw message

Signature · 1 line
2.27.0
#10 lore raw

PATCH v5 5/9 net/zxdh: add msg chan enable implementation

In reply to Junlong Wang

Add msg chan enable implementation to support
send msg to get infos.

---
 drivers/net/zxdh/zxdh_ethdev.c |   6 +
 drivers/net/zxdh/zxdh_ethdev.h |  12 +
 drivers/net/zxdh/zxdh_msg.c    | 655 ++++++++++++++++++++++++++++++++-
 drivers/net/zxdh/zxdh_msg.h    | 127 +++++++
 4 files changed, 796 insertions(+), 4 deletions(-)
drivers/net/zxdh/zxdh_ethdev.c +6 -0
index 66b57c4e59..d95ab4471a 100644
@@ -97,6 +97,12 @@ static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 		goto err_zxdh_init;
 	}
 
+	ret = zxdh_msg_chan_enable(eth_dev);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "zxdh_msg_bar_chan_enable failed ret %d", ret);
+		goto err_zxdh_init;
+	}
+
 	return ret;
 
 err_zxdh_init:
drivers/net/zxdh/zxdh_ethdev.h +12 -0
index 24eb3a5ca0..a51181f1ce 100644
@@ -29,10 +29,22 @@ extern "C" {
 
 #define ZXDH_NUM_BARS    2
 
+union VPORT {
+	uint16_t vport;
+	struct {
+		uint16_t vfid:8;
+		uint16_t pfid:3;
+		uint16_t vf_flag:1;
+		uint16_t epid:3;
+		uint16_t direct_flag:1;
+	};
+};
+
 struct zxdh_hw {
 	struct rte_eth_dev *eth_dev;
 	struct zxdh_pci_common_cfg *common_cfg;
 	struct zxdh_net_config *dev_cfg;
+	union VPORT vport;
 
 	uint64_t bar_addr[ZXDH_NUM_BARS];
 	uint64_t host_features;
drivers/net/zxdh/zxdh_msg.c +651 -4

679 lines not on this page · raw message

drivers/net/zxdh/zxdh_msg.h +127 -0

149 lines not on this page · raw message

Signature · 1 line
2.27.0
#11 lore raw

PATCH v5 6/9 net/zxdh: add zxdh get device backend infos

In reply to Junlong Wang

Add zxdh get device backend infos,
use msg chan to send msg get.

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_common.c | 249 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_common.h |  30 ++++
 drivers/net/zxdh/zxdh_ethdev.c |  35 +++++
 drivers/net/zxdh/zxdh_ethdev.h |   5 +
 drivers/net/zxdh/zxdh_msg.c    |   3 -
 drivers/net/zxdh/zxdh_msg.h    |  27 +++-
 7 files changed, 346 insertions(+), 4 deletions(-)
 create mode 100644 drivers/net/zxdh/zxdh_common.c
 create mode 100644 drivers/net/zxdh/zxdh_common.h
drivers/net/zxdh/meson.build +1 -0
index 9d0b5b9fd3..9aec47e68f 100644
@@ -17,4 +17,5 @@ sources = files(
     'zxdh_ethdev.c',
     'zxdh_pci.c',
     'zxdh_msg.c',
+    'zxdh_common.c',
     )
drivers/net/zxdh/zxdh_common.c new file +249 -0

249 lines not on this page · raw message

drivers/net/zxdh/zxdh_common.h new file +30 -0
new file mode 100644
index 0000000000..ec7011e820
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 ZTE Corporation
+ */
+
+#ifndef _ZXDH_COMMON_H_
+#define _ZXDH_COMMON_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <rte_ethdev.h>
+
+#include "zxdh_ethdev.h"
+
+struct zxdh_res_para {
+	uint64_t virt_addr;
+	uint16_t pcie_id;
+	uint16_t src_type; /* refer to BAR_DRIVER_TYPE */
+};
+
+int32_t zxdh_phyport_get(struct rte_eth_dev *dev, uint8_t *phyport);
+int32_t zxdh_pannelid_get(struct rte_eth_dev *dev, uint8_t *pannelid);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ZXDH_COMMON_H_ */
drivers/net/zxdh/zxdh_ethdev.c +35 -0
index d95ab4471a..ee2e1c0d5d 100644
@@ -10,9 +10,21 @@
 #include "zxdh_logs.h"
 #include "zxdh_pci.h"
 #include "zxdh_msg.h"
+#include "zxdh_common.h"
 
 struct zxdh_hw_internal zxdh_hw_internal[RTE_MAX_ETHPORTS];
 
+uint16_t vport_to_vfid(union VPORT v)
+{
+	/* epid > 4 is local soft queue. return 1192 */
+	if (v.epid > 4)
+		return 1192;
+	if (v.vf_flag)
+		return v.epid * 256 + v.vfid;
+	else
+		return (v.epid * 8 + v.pfid) + 1152;
+}
+
 static int32_t zxdh_init_device(struct rte_eth_dev *eth_dev)
 {
 	struct zxdh_hw *hw = eth_dev->data->dev_private;
@@ -44,6 +56,25 @@ static int32_t zxdh_init_device(struct rte_eth_dev *eth_dev)
 	return ret;
 }
 
+static int zxdh_agent_comm(struct rte_eth_dev *eth_dev, struct zxdh_hw *hw)
+{
+	if (zxdh_phyport_get(eth_dev, &hw->phyport) != 0) {
+		PMD_INIT_LOG(ERR, "Failed to get phyport");
+		return -1;
+	}
+	PMD_INIT_LOG(INFO, "Get phyport success: 0x%x", hw->phyport);
+
+	hw->vfid = vport_to_vfid(hw->vport);
+
+	if (zxdh_pannelid_get(eth_dev, &hw->panel_id) != 0) {
+		PMD_INIT_LOG(ERR, "Failed to get panel_id");
+		return -1;
+	}
+	PMD_INIT_LOG(INFO, "Get pannel id success: 0x%x", hw->panel_id);
+
+	return 0;
+}
+
 static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 {
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
@@ -103,6 +134,10 @@ static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 		goto err_zxdh_init;
 	}
 
+	ret = zxdh_agent_comm(eth_dev, hw);
+	if (ret != 0)
+		goto err_zxdh_init;
+
 	return ret;
 
 err_zxdh_init:
drivers/net/zxdh/zxdh_ethdev.h +5 -0
index a51181f1ce..2351393009 100644
@@ -56,6 +56,7 @@ struct zxdh_hw {
 	uint16_t pcie_id;
 	uint16_t device_id;
 	uint16_t port_id;
+	uint16_t vfid;
 
 	uint8_t *isr;
 	uint8_t weak_barriers;
@@ -63,9 +64,13 @@ struct zxdh_hw {
 	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
 	uint8_t duplex;
 	uint8_t is_pf;
+	uint8_t phyport;
+	uint8_t panel_id;
 	uint8_t msg_chan_init;
 };
 
+uint16_t vport_to_vfid(union VPORT v);
+
 #ifdef __cplusplus
 }
 #endif
drivers/net/zxdh/zxdh_msg.c +0 -3
index 4e4930e5a1..5a652a5f39 100644
@@ -18,8 +18,6 @@
 #define REPS_INFO_FLAG_USABLE  0x00
 #define BAR_SEQID_NUM_MAX  256
 
-#define ZXDH_BAR0_INDEX  0
-
 #define PCIEID_IS_PF_MASK   (0x0800)
 #define PCIEID_PF_IDX_MASK  (0x0700)
 #define PCIEID_VF_IDX_MASK  (0x00ff)
@@ -43,7 +41,6 @@
 #define FW_SHRD_OFFSET               (0x5000)
 #define FW_SHRD_INNER_HW_LABEL_PAT   (0x800)
 #define HW_LABEL_OFFSET              (FW_SHRD_OFFSET + FW_SHRD_INNER_HW_LABEL_PAT)
-#define ZXDH_CTRLCH_OFFSET           (0x2000)
 #define CHAN_RISC_SPINLOCK_OFFSET    (BAR0_SPINLOCK_OFFSET - BAR0_CHAN_RISC_OFFSET)
 #define CHAN_PFVF_SPINLOCK_OFFSET    (BAR0_SPINLOCK_OFFSET - BAR0_CHAN_PFVF_OFFSET)
 #define CHAN_RISC_LABEL_OFFSET       (HW_LABEL_OFFSET - BAR0_CHAN_RISC_OFFSET)
drivers/net/zxdh/zxdh_msg.h +26 -1
index 88d27756e2..5b599f8f6a 100644
@@ -13,9 +13,13 @@ extern "C" {
 
 #include <ethdev_driver.h>
 
+#define ZXDH_BAR0_INDEX  0
+
+#define ZXDH_CTRLCH_OFFSET         (0x2000)
+
 #define ZXDH_MSIX_INTR_MSG_VEC_BASE  1
 
-#define BAR_MSG_POLLING_SPAN     100 /* sleep us */
+#define BAR_MSG_POLLING_SPAN     100
 #define BAR_MSG_POLL_CNT_PER_MS  (1 * 1000 / BAR_MSG_POLLING_SPAN)
 #define BAR_MSG_POLL_CNT_PER_S   (1 * 1000 * 1000 / BAR_MSG_POLLING_SPAN)
 #define BAR_MSG_TIMEOUT_TH       (10 * 1000 * 1000 / BAR_MSG_POLLING_SPAN) /* 10s */
@@ -103,6 +107,27 @@ enum bar_module_id {
 	BAR_MSG_MODULE_NUM = 100,
 };
 
+enum RES_TBL_FILED {
+	TBL_FIELD_PCIEID     = 0,
+	TBL_FIELD_BDF        = 1,
+	TBL_FIELD_MSGCH      = 2,
+	TBL_FIELD_DATACH     = 3,
+	TBL_FIELD_VPORT      = 4,
+	TBL_FIELD_PNLID      = 5,
+	TBL_FIELD_PHYPORT    = 6,
+	TBL_FIELD_SERDES_NUM = 7,
+	TBL_FIELD_NP_PORT    = 8,
+	TBL_FIELD_SPEED      = 9,
+	TBL_FIELD_HASHID     = 10,
+	TBL_FIELD_NON,
+};
+
+enum TBL_MSG_TYPE {
+	TBL_TYPE_READ,
+	TBL_TYPE_WRITE,
+	TBL_TYPE_NON,
+};
+
 struct msix_para {
 	uint16_t pcie_id;
 	uint16_t vector_risc;
Signature · 1 line
2.27.0
#12 lore raw

PATCH v5 7/9 net/zxdh: add configure zxdh intr implementation

In reply to Junlong Wang

configure zxdh intr include risc,dtb. and release intr.

---
 drivers/net/zxdh/zxdh_ethdev.c | 302 ++++++++++++++++++++++++++++++++-
 drivers/net/zxdh/zxdh_ethdev.h |   8 +
 drivers/net/zxdh/zxdh_msg.c    | 187 ++++++++++++++++++++
 drivers/net/zxdh/zxdh_msg.h    |  11 ++
 drivers/net/zxdh/zxdh_pci.c    |  62 +++++++
 drivers/net/zxdh/zxdh_pci.h    |  12 ++
 6 files changed, 581 insertions(+), 1 deletion(-)
drivers/net/zxdh/zxdh_ethdev.c +301 -1
index ee2e1c0d5d..4f6711c9af 100644
@@ -25,6 +25,302 @@ uint16_t vport_to_vfid(union VPORT v)
 		return (v.epid * 8 + v.pfid) + 1152;
 }
 
+static void zxdh_queues_unbind_intr(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+	int32_t i;
+
+	for (i = 0; i < dev->data->nb_rx_queues; ++i) {
+		VTPCI_OPS(hw)->set_queue_irq(hw, hw->vqs[i * 2], ZXDH_MSI_NO_VECTOR);
+		VTPCI_OPS(hw)->set_queue_irq(hw, hw->vqs[i * 2 + 1], ZXDH_MSI_NO_VECTOR);
+	}
+}
+
+
+static int32_t zxdh_intr_unmask(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (rte_intr_ack(dev->intr_handle) < 0)
+		return -1;
+
+	hw->use_msix = zxdh_vtpci_msix_detect(RTE_ETH_DEV_TO_PCI(dev));
+
+	return 0;
+}
+
+static void zxdh_devconf_intr_handler(void *param)
+{
+	struct rte_eth_dev *dev = param;
+
+	if (zxdh_intr_unmask(dev) < 0)
+		PMD_DRV_LOG(ERR, "interrupt enable failed");
+}
+
+
+/* Interrupt handler triggered by NIC for handling specific interrupt. */
+static void zxdh_fromriscv_intr_handler(void *param)
+{
+	struct rte_eth_dev *dev = param;
+	struct zxdh_hw *hw = dev->data->dev_private;
+	uint64_t virt_addr = 0;
+
+	virt_addr = (uint64_t)(hw->bar_addr[ZXDH_BAR0_INDEX] + ZXDH_CTRLCH_OFFSET);
+	if (hw->is_pf) {
+		PMD_INIT_LOG(DEBUG, "zxdh_risc2pf_intr_handler\n");
+		zxdh_bar_irq_recv(MSG_CHAN_END_RISC, MSG_CHAN_END_PF, virt_addr, dev);
+	} else {
+		PMD_INIT_LOG(DEBUG, "zxdh_riscvf_intr_handler\n");
+		zxdh_bar_irq_recv(MSG_CHAN_END_RISC, MSG_CHAN_END_VF, virt_addr, dev);
+	}
+}
+
+/* Interrupt handler triggered by NIC for handling specific interrupt. */
+static void zxdh_frompfvf_intr_handler(void *param)
+{
+	struct rte_eth_dev *dev = param;
+	struct zxdh_hw *hw = dev->data->dev_private;
+	uint64_t virt_addr = 0;
+
+	virt_addr = (uint64_t)(hw->bar_addr[ZXDH_BAR0_INDEX] + ZXDH_MSG_CHAN_PFVFSHARE_OFFSET);
+	if (hw->is_pf) {
+		PMD_INIT_LOG(DEBUG, "zxdh_vf2pf_intr_handler\n");
+		zxdh_bar_irq_recv(MSG_CHAN_END_VF, MSG_CHAN_END_PF, virt_addr, dev);
+	} else {
+		PMD_INIT_LOG(DEBUG, "zxdh_pf2vf_intr_handler");
+		zxdh_bar_irq_recv(MSG_CHAN_END_PF, MSG_CHAN_END_VF, virt_addr, dev);
+	}
+}
+
+static void zxdh_intr_cb_reg(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
+		rte_intr_callback_unregister(dev->intr_handle, zxdh_devconf_intr_handler, dev);
+
+	/* register callback to update dev config intr */
+	rte_intr_callback_register(dev->intr_handle, zxdh_devconf_intr_handler, dev);
+	/* Register rsic_v to pf interrupt callback */
+	struct rte_intr_handle *tmp = hw->risc_intr +
+			(MSIX_FROM_PFVF - ZXDH_MSIX_INTR_MSG_VEC_BASE);
+
+	rte_intr_callback_register(tmp, zxdh_frompfvf_intr_handler, dev);
+
+	tmp = hw->risc_intr + (MSIX_FROM_RISCV - ZXDH_MSIX_INTR_MSG_VEC_BASE);
+	rte_intr_callback_register(tmp, zxdh_fromriscv_intr_handler, dev);
+}
+
+static void zxdh_intr_cb_unreg(struct rte_eth_dev *dev)
+{
+	if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
+		rte_intr_callback_unregister(dev->intr_handle, zxdh_devconf_intr_handler, dev);
+
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	/* register callback to update dev config intr */
+	rte_intr_callback_unregister(dev->intr_handle, zxdh_devconf_intr_handler, dev);
+	/* Register rsic_v to pf interrupt callback */
+	struct rte_intr_handle *tmp = hw->risc_intr +
+			(MSIX_FROM_PFVF - ZXDH_MSIX_INTR_MSG_VEC_BASE);
+
+	rte_intr_callback_unregister(tmp, zxdh_frompfvf_intr_handler, dev);
+	tmp = hw->risc_intr + (MSIX_FROM_RISCV - ZXDH_MSIX_INTR_MSG_VEC_BASE);
+	rte_intr_callback_unregister(tmp, zxdh_fromriscv_intr_handler, dev);
+}
+
+static int32_t zxdh_intr_disable(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (!hw->intr_enabled)
+		return 0;
+
+	zxdh_intr_cb_unreg(dev);
+	if (rte_intr_disable(dev->intr_handle) < 0)
+		return -1;
+
+	hw->intr_enabled = 0;
+	return 0;
+}
+
+static int32_t zxdh_intr_enable(struct rte_eth_dev *dev)
+{
+	int ret = 0;
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (!hw->intr_enabled) {
+		zxdh_intr_cb_reg(dev);
+		ret = rte_intr_enable(dev->intr_handle);
+		if (unlikely(ret))
+			PMD_INIT_LOG(ERR, "Failed to enable %s intr", dev->data->name);
+
+		hw->intr_enabled = 1;
+	}
+	return ret;
+}
+
+static int32_t zxdh_intr_release(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
+		VTPCI_OPS(hw)->set_config_irq(hw, ZXDH_MSI_NO_VECTOR);
+
+	zxdh_queues_unbind_intr(dev);
+	zxdh_intr_disable(dev);
+
+	rte_intr_efd_disable(dev->intr_handle);
+	rte_intr_vec_list_free(dev->intr_handle);
+	rte_free(hw->risc_intr);
+	hw->risc_intr = NULL;
+	rte_free(hw->dtb_intr);
+	hw->dtb_intr = NULL;
+	return 0;
+}
+
+static int32_t zxdh_setup_risc_interrupts(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+	uint8_t i;
+
+	if (!hw->risc_intr) {
+		PMD_INIT_LOG(ERR, " to allocate risc_intr");
+		hw->risc_intr = rte_zmalloc("risc_intr",
+			ZXDH_MSIX_INTR_MSG_VEC_NUM * sizeof(struct rte_intr_handle), 0);
+		if (hw->risc_intr == NULL) {
+			PMD_INIT_LOG(ERR, "Failed to allocate risc_intr");
+			return -ENOMEM;
+		}
+	}
+
+	for (i = 0; i < ZXDH_MSIX_INTR_MSG_VEC_NUM; i++) {
+		if (dev->intr_handle->efds[i] < 0) {
+			PMD_INIT_LOG(ERR, "[%u]risc interrupt fd is invalid", i);
+			rte_free(hw->risc_intr);
+			hw->risc_intr = NULL;
+			return -1;
+		}
+
+		struct rte_intr_handle *intr_handle = hw->risc_intr + i;
+
+		intr_handle->fd = dev->intr_handle->efds[i];
+		intr_handle->type = dev->intr_handle->type;
+	}
+
+	return 0;
+}
+
+static int32_t zxdh_setup_dtb_interrupts(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (!hw->dtb_intr) {
+		hw->dtb_intr = rte_zmalloc("dtb_intr", sizeof(struct rte_intr_handle), 0);
+		if (hw->dtb_intr == NULL) {
+			PMD_INIT_LOG(ERR, "Failed to allocate dtb_intr");
+			return -ENOMEM;
+		}
+	}
+
+	if (dev->intr_handle->efds[ZXDH_MSIX_INTR_DTB_VEC - 1] < 0) {
+		PMD_INIT_LOG(ERR, "[%d]dtb interrupt fd is invalid", ZXDH_MSIX_INTR_DTB_VEC - 1);
+		rte_free(hw->dtb_intr);
+		hw->dtb_intr = NULL;
+		return -1;
+	}
+	hw->dtb_intr->fd = dev->intr_handle->efds[ZXDH_MSIX_INTR_DTB_VEC - 1];
+	hw->dtb_intr->type = dev->intr_handle->type;
+	return 0;
+}
+
+static int32_t zxdh_queues_bind_intr(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+	int32_t i;
+	uint16_t vec;
+
+	if (!dev->data->dev_conf.intr_conf.rxq) {
+		for (i = 0; i < dev->data->nb_rx_queues; ++i) {
+			vec = VTPCI_OPS(hw)->set_queue_irq(hw,
+					hw->vqs[i * 2], ZXDH_MSI_NO_VECTOR);
+			PMD_INIT_LOG(DEBUG, "vq%d irq set 0x%x, get 0x%x",
+					i * 2, ZXDH_MSI_NO_VECTOR, vec);
+		}
+	} else {
+		for (i = 0; i < dev->data->nb_rx_queues; ++i) {
+			vec = VTPCI_OPS(hw)->set_queue_irq(hw,
+					hw->vqs[i * 2], i + ZXDH_QUEUE_INTR_VEC_BASE);
+			PMD_INIT_LOG(DEBUG, "vq%d irq set %d, get %d",
+					i * 2, i + ZXDH_QUEUE_INTR_VEC_BASE, vec);
+		}
+	}
+	/* mask all txq intr */
+	for (i = 0; i < dev->data->nb_tx_queues; ++i) {
+		vec = VTPCI_OPS(hw)->set_queue_irq(hw,
+				hw->vqs[(i * 2) + 1], ZXDH_MSI_NO_VECTOR);
+		PMD_INIT_LOG(DEBUG, "vq%d irq set 0x%x, get 0x%x",
+				(i * 2) + 1, ZXDH_MSI_NO_VECTOR, vec);
+	}
+	return 0;
+}
+
+static int32_t zxdh_configure_intr(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+	int32_t ret = 0;
+
+	if (!rte_intr_cap_multiple(dev->intr_handle)) {
+		PMD_INIT_LOG(ERR, "Multiple intr vector not supported");
+		return -ENOTSUP;
+	}
+	zxdh_intr_release(dev);
+	uint8_t nb_efd = ZXDH_MSIX_INTR_DTB_VEC_NUM + ZXDH_MSIX_INTR_MSG_VEC_NUM;
+
+	if (dev->data->dev_conf.intr_conf.rxq)
+		nb_efd += dev->data->nb_rx_queues;
+
+	if (rte_intr_efd_enable(dev->intr_handle, nb_efd)) {
+		PMD_INIT_LOG(ERR, "Fail to create eventfd");
+		return -1;
+	}
+
+	if (rte_intr_vec_list_alloc(dev->intr_handle, "intr_vec",
+					hw->max_queue_pairs + ZXDH_INTR_NONQUE_NUM)) {
+		PMD_INIT_LOG(ERR, "Failed to allocate %u rxq vectors",
+					hw->max_queue_pairs + ZXDH_INTR_NONQUE_NUM);
+		return -ENOMEM;
+	}
+	PMD_INIT_LOG(DEBUG, "allocate %u rxq vectors", dev->intr_handle->vec_list_size);
+	if (zxdh_setup_risc_interrupts(dev) != 0) {
+		PMD_INIT_LOG(ERR, "Error setting up rsic_v interrupts!");
+		ret = -1;
+		goto free_intr_vec;
+	}
+	if (zxdh_setup_dtb_interrupts(dev) != 0) {
+		PMD_INIT_LOG(ERR, "Error setting up dtb interrupts!");
+		ret = -1;
+		goto free_intr_vec;
+	}
+
+	if (zxdh_queues_bind_intr(dev) < 0) {
+		PMD_INIT_LOG(ERR, "Failed to bind queue/interrupt");
+		ret = -1;
+		goto free_intr_vec;
+	}
+
+	if (zxdh_intr_enable(dev) < 0) {
+		PMD_DRV_LOG(ERR, "interrupt enable failed");
+		ret = -1;
+		goto free_intr_vec;
+	}
+	return 0;
+
+free_intr_vec:
+	zxdh_intr_release(dev);
+	return ret;
+}
+
 static int32_t zxdh_init_device(struct rte_eth_dev *eth_dev)
 {
 	struct zxdh_hw *hw = eth_dev->data->dev_private;
@@ -138,10 +434,14 @@ static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 	if (ret != 0)
 		goto err_zxdh_init;
 
+	ret = zxdh_configure_intr(eth_dev);
+	if (ret != 0)
+		goto err_zxdh_init;
+
 	return ret;
 
 err_zxdh_init:
-	zxdh_bar_msg_chan_exit();
+	zxdh_intr_release(eth_dev);
 	rte_free(eth_dev->data->mac_addrs);
 	eth_dev->data->mac_addrs = NULL;
 	return ret;
drivers/net/zxdh/zxdh_ethdev.h +8 -0
index 2351393009..7c5f5940cb 100644
@@ -11,6 +11,10 @@ extern "C" {
 
 #include <rte_ether.h>
 #include "ethdev_driver.h"
+#include <rte_interrupts.h>
+#include <eal_interrupts.h>
+
+#include "zxdh_queue.h"
 
 /* ZXDH PCI vendor/device ID. */
 #define PCI_VENDOR_ID_ZTE        0x1cf2
@@ -44,6 +48,9 @@ struct zxdh_hw {
 	struct rte_eth_dev *eth_dev;
 	struct zxdh_pci_common_cfg *common_cfg;
 	struct zxdh_net_config *dev_cfg;
+	struct rte_intr_handle *risc_intr;
+	struct rte_intr_handle *dtb_intr;
+	struct virtqueue **vqs;
 	union VPORT vport;
 
 	uint64_t bar_addr[ZXDH_NUM_BARS];
@@ -60,6 +67,7 @@ struct zxdh_hw {
 
 	uint8_t *isr;
 	uint8_t weak_barriers;
+	uint8_t intr_enabled;
 	uint8_t use_msix;
 	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
 	uint8_t duplex;
drivers/net/zxdh/zxdh_msg.c +187 -0

202 lines not on this page · raw message

drivers/net/zxdh/zxdh_msg.h +11 -0
index 5b599f8f6a..2e4e6d3ba6 100644
@@ -16,8 +16,15 @@ extern "C" {
 #define ZXDH_BAR0_INDEX  0
 
 #define ZXDH_CTRLCH_OFFSET         (0x2000)
+#define ZXDH_MSG_CHAN_PFVFSHARE_OFFSET  (ZXDH_CTRLCH_OFFSET + 0x1000)
 
 #define ZXDH_MSIX_INTR_MSG_VEC_BASE  1
+#define ZXDH_MSIX_INTR_MSG_VEC_NUM   3
+#define ZXDH_MSIX_INTR_DTB_VEC      (ZXDH_MSIX_INTR_MSG_VEC_BASE + ZXDH_MSIX_INTR_MSG_VEC_NUM)
+#define ZXDH_MSIX_INTR_DTB_VEC_NUM  1
+#define ZXDH_INTR_NONQUE_NUM        (ZXDH_MSIX_INTR_MSG_VEC_NUM + ZXDH_MSIX_INTR_DTB_VEC_NUM + 1)
+#define ZXDH_QUEUE_INTR_VEC_BASE      (ZXDH_MSIX_INTR_DTB_VEC + ZXDH_MSIX_INTR_DTB_VEC_NUM) /* 5 */
+#define ZXDH_QUEUE_INTR_VEC_NUM       256
 
 #define BAR_MSG_POLLING_SPAN     100
 #define BAR_MSG_POLL_CNT_PER_MS  (1 * 1000 / BAR_MSG_POLLING_SPAN)
@@ -202,6 +209,9 @@ struct bar_msg_header {
 	uint16_t dst_pcieid; /* used in PF-->VF */
 };
 
+typedef int (*zxdh_bar_chan_msg_recv_callback)(void *pay_load, uint16_t len,
+					void *reps_buffer, uint16_t *reps_len, void *dev);
+
 int zxdh_msg_chan_init(void);
 int zxdh_bar_msg_chan_exit(void);
 int zxdh_msg_chan_hwlock_init(struct rte_eth_dev *dev);
@@ -209,6 +219,7 @@ int zxdh_msg_chan_hwlock_init(struct rte_eth_dev *dev);
 int zxdh_msg_chan_enable(struct rte_eth_dev *dev);
 int zxdh_bar_chan_sync_msg_send(struct zxdh_pci_bar_msg *in,
 			struct zxdh_msg_recviver_mem *result);
+int zxdh_bar_irq_recv(uint8_t src, uint8_t dst, uint64_t virt_addr, void *dev);
 
 #ifdef __cplusplus
 }
drivers/net/zxdh/zxdh_pci.c +62 -0

79 lines not on this page · raw message

drivers/net/zxdh/zxdh_pci.h +12 -0
index deda73a65a..677dadd5c8 100644
@@ -22,6 +22,13 @@ enum zxdh_msix_status {
 	ZXDH_MSIX_ENABLED  = 2
 };
 
+/* The bit of the ISR which indicates a device has an interrupt. */
+#define ZXDH_PCI_ISR_INTR    0x1
+/* The bit of the ISR which indicates a device configuration change. */
+#define ZXDH_PCI_ISR_CONFIG  0x2
+/* Vector value used to disable MSI for queue. */
+#define ZXDH_MSI_NO_VECTOR   0x7F
+
 #define PCI_CAPABILITY_LIST          0x34
 #define PCI_CAP_ID_VNDR              0x09
 #define PCI_CAP_ID_MSIX              0x11
@@ -124,6 +131,9 @@ struct zxdh_pci_ops {
 
 	uint64_t (*get_features)(struct zxdh_hw *hw);
 	void     (*set_features)(struct zxdh_hw *hw, uint64_t features);
+	uint16_t (*set_queue_irq)(struct zxdh_hw *hw, struct virtqueue *vq, uint16_t vec);
+	uint16_t (*set_config_irq)(struct zxdh_hw *hw, uint16_t vec);
+	uint8_t  (*get_isr)(struct zxdh_hw *hw);
 };
 
 struct zxdh_hw_internal {
@@ -143,6 +153,8 @@ int32_t zxdh_read_pci_caps(struct rte_pci_device *dev, struct zxdh_hw *hw);
 int32_t zxdh_get_pci_dev_config(struct zxdh_hw *hw);
 
 uint16_t zxdh_vtpci_get_features(struct zxdh_hw *hw);
+uint8_t zxdh_vtpci_isr(struct zxdh_hw *hw);
+enum zxdh_msix_status zxdh_vtpci_msix_detect(struct rte_pci_device *dev);
 
 #ifdef __cplusplus
 }
Signature · 1 line
2.27.0
#13 lore raw

PATCH v5 8/9 net/zxdh: add zxdh dev infos get ops

In reply to Junlong Wang

Add support for zxdh infos get.

---
 drivers/net/zxdh/zxdh_ethdev.c | 62 +++++++++++++++++++++++++++++++++-
 1 file changed, 61 insertions(+), 1 deletion(-)
drivers/net/zxdh/zxdh_ethdev.c +61 -1
index 4f6711c9af..e0f2c1985b 100644
@@ -12,6 +12,9 @@
 #include "zxdh_msg.h"
 #include "zxdh_common.h"
 
+#define ZXDH_MIN_RX_BUFSIZE     64
+#define ZXDH_MAX_RX_PKTLEN      14000U
+
 struct zxdh_hw_internal zxdh_hw_internal[RTE_MAX_ETHPORTS];
 
 uint16_t vport_to_vfid(union VPORT v)
@@ -25,6 +28,58 @@ uint16_t vport_to_vfid(union VPORT v)
 		return (v.epid * 8 + v.pfid) + 1152;
 }
 
+static uint32_t zxdh_dev_speed_capa_get(uint32_t speed)
+{
+	switch (speed) {
+	case RTE_ETH_SPEED_NUM_10G:  return RTE_ETH_LINK_SPEED_10G;
+	case RTE_ETH_SPEED_NUM_20G:  return RTE_ETH_LINK_SPEED_20G;
+	case RTE_ETH_SPEED_NUM_25G:  return RTE_ETH_LINK_SPEED_25G;
+	case RTE_ETH_SPEED_NUM_40G:  return RTE_ETH_LINK_SPEED_40G;
+	case RTE_ETH_SPEED_NUM_50G:  return RTE_ETH_LINK_SPEED_50G;
+	case RTE_ETH_SPEED_NUM_56G:  return RTE_ETH_LINK_SPEED_56G;
+	case RTE_ETH_SPEED_NUM_100G: return RTE_ETH_LINK_SPEED_100G;
+	case RTE_ETH_SPEED_NUM_200G: return RTE_ETH_LINK_SPEED_200G;
+	default:                     return 0;
+	}
+}
+
+static int32_t zxdh_dev_infos_get(struct rte_eth_dev *dev,
+					struct rte_eth_dev_info *dev_info)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	dev_info->speed_capa       = zxdh_dev_speed_capa_get(hw->speed);
+	dev_info->max_rx_queues    = RTE_MIN(hw->max_queue_pairs, ZXDH_RX_QUEUES_MAX);
+	dev_info->max_tx_queues    = RTE_MIN(hw->max_queue_pairs, ZXDH_TX_QUEUES_MAX);
+	dev_info->min_rx_bufsize   = ZXDH_MIN_RX_BUFSIZE;
+	dev_info->max_rx_pktlen    = ZXDH_MAX_RX_PKTLEN;
+	dev_info->max_mac_addrs    = ZXDH_MAX_MAC_ADDRS;
+	dev_info->rx_offload_capa  = (RTE_ETH_RX_OFFLOAD_VLAN_STRIP |
+					RTE_ETH_RX_OFFLOAD_VLAN_FILTER |
+					RTE_ETH_RX_OFFLOAD_QINQ_STRIP);
+	dev_info->rx_offload_capa |= (RTE_ETH_RX_OFFLOAD_IPV4_CKSUM |
+					RTE_ETH_RX_OFFLOAD_UDP_CKSUM |
+					RTE_ETH_RX_OFFLOAD_TCP_CKSUM |
+					RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM);
+	dev_info->rx_offload_capa |= (RTE_ETH_RX_OFFLOAD_SCATTER);
+	dev_info->rx_offload_capa |=  RTE_ETH_RX_OFFLOAD_TCP_LRO;
+	dev_info->rx_offload_capa |=  RTE_ETH_RX_OFFLOAD_RSS_HASH;
+
+	dev_info->tx_offload_capa = (RTE_ETH_TX_OFFLOAD_MULTI_SEGS);
+	dev_info->tx_offload_capa |= (RTE_ETH_TX_OFFLOAD_TCP_TSO |
+					RTE_ETH_TX_OFFLOAD_UDP_TSO);
+	dev_info->tx_offload_capa |= (RTE_ETH_TX_OFFLOAD_VLAN_INSERT |
+					RTE_ETH_TX_OFFLOAD_QINQ_INSERT |
+					RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO);
+	dev_info->tx_offload_capa |= (RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
+					RTE_ETH_TX_OFFLOAD_UDP_CKSUM |
+					RTE_ETH_TX_OFFLOAD_TCP_CKSUM |
+					RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM |
+					RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM);
+
+	return 0;
+}
+
 static void zxdh_queues_unbind_intr(struct rte_eth_dev *dev)
 {
 	struct zxdh_hw *hw = dev->data->dev_private;
@@ -321,6 +376,11 @@ static int32_t zxdh_configure_intr(struct rte_eth_dev *dev)
 	return ret;
 }
 
+/* dev_ops for zxdh, bare necessities for basic operation */
+static const struct eth_dev_ops zxdh_eth_dev_ops = {
+	.dev_infos_get			 = zxdh_dev_infos_get,
+};
+
 static int32_t zxdh_init_device(struct rte_eth_dev *eth_dev)
 {
 	struct zxdh_hw *hw = eth_dev->data->dev_private;
@@ -377,7 +437,7 @@ static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 	struct zxdh_hw *hw = eth_dev->data->dev_private;
 	int ret = 0;
 
-	eth_dev->dev_ops = NULL;
+	eth_dev->dev_ops = &zxdh_eth_dev_ops;
 
 	/* Allocate memory for storing MAC addresses */
 	eth_dev->data->mac_addrs = rte_zmalloc("zxdh_mac",
Signature · 1 line
2.27.0
#14 lore raw

PATCH v5 9/9 net/zxdh: add zxdh dev configure ops

In reply to Junlong Wang

provided zxdh dev configure ops for queue
check,reset,alloc resources,etc.

---
 drivers/net/zxdh/meson.build   |  11 +-
 drivers/net/zxdh/zxdh_common.c | 119 +++++++++
 drivers/net/zxdh/zxdh_common.h |  12 +
 drivers/net/zxdh/zxdh_ethdev.c | 459 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev.h |  23 +-
 drivers/net/zxdh/zxdh_pci.c    |  97 +++++++
 drivers/net/zxdh/zxdh_pci.h    |  28 ++
 drivers/net/zxdh/zxdh_queue.c  | 131 ++++++++++
 drivers/net/zxdh/zxdh_queue.h  | 171 ++++++++++++
 drivers/net/zxdh/zxdh_rxtx.h   |   2 +-
 10 files changed, 1045 insertions(+), 8 deletions(-)
 create mode 100644 drivers/net/zxdh/zxdh_queue.c
drivers/net/zxdh/meson.build +6 -5
index 9aec47e68f..cde96d8111 100644
@@ -14,8 +14,9 @@ if not dpdk_conf.has('RTE_ARCH_X86_64') or not dpdk_conf.get('RTE_ARCH_64')
 endif
 
 sources = files(
-    'zxdh_ethdev.c',
-    'zxdh_pci.c',
-    'zxdh_msg.c',
-    'zxdh_common.c',
-    )
+        'zxdh_ethdev.c',
+        'zxdh_pci.c',
+        'zxdh_msg.c',
+        'zxdh_common.c',
+        'zxdh_queue.c',
+        )
drivers/net/zxdh/zxdh_common.c +119 -0

128 lines not on this page · raw message

drivers/net/zxdh/zxdh_common.h +12 -0
index ec7011e820..5205d9db54 100644
@@ -14,6 +14,10 @@ extern "C" {
 
 #include "zxdh_ethdev.h"
 
+#define ZXDH_VF_LOCK_REG                0x90
+#define ZXDH_VF_LOCK_ENABLE_MASK        0x1
+#define ZXDH_ACQUIRE_CHANNEL_NUM_MAX    10
+
 struct zxdh_res_para {
 	uint64_t virt_addr;
 	uint16_t pcie_id;
@@ -23,6 +27,14 @@ struct zxdh_res_para {
 int32_t zxdh_phyport_get(struct rte_eth_dev *dev, uint8_t *phyport);
 int32_t zxdh_pannelid_get(struct rte_eth_dev *dev, uint8_t *pannelid);
 
+uint32_t zxdh_read_bar_reg(struct rte_eth_dev *dev, uint32_t bar, uint32_t reg);
+void zxdh_write_bar_reg(struct rte_eth_dev *dev, uint32_t bar, uint32_t reg, uint32_t val);
+int32_t zxdh_release_lock(struct zxdh_hw *hw);
+int32_t zxdh_acquire_lock(struct zxdh_hw *hw);
+uint32_t zxdh_read_comm_reg(uint64_t pci_comm_cfg_baseaddr, uint32_t reg);
+void zxdh_write_comm_reg(uint64_t pci_comm_cfg_baseaddr, uint32_t reg, uint32_t val);
+int32_t zxdh_datach_set(struct rte_eth_dev *dev);
+
 #ifdef __cplusplus
 }
 #endif
drivers/net/zxdh/zxdh_ethdev.c +459 -0

473 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev.h +21 -2
index 7c5f5940cb..f3fc5b3ce0 100644
@@ -14,8 +14,6 @@ extern "C" {
 #include <rte_interrupts.h>
 #include <eal_interrupts.h>
 
-#include "zxdh_queue.h"
-
 /* ZXDH PCI vendor/device ID. */
 #define PCI_VENDOR_ID_ZTE        0x1cf2
 
@@ -28,11 +26,23 @@ extern "C" {
 #define ZXDH_MAX_MC_MAC_ADDRS  32
 #define ZXDH_MAX_MAC_ADDRS     (ZXDH_MAX_UC_MAC_ADDRS + ZXDH_MAX_MC_MAC_ADDRS)
 
+/**
+ * zxdh has a total of 4096 queues,
+ * pf/vf devices support up to 256 queues
+ * (include private queues)
+ */
 #define ZXDH_RX_QUEUES_MAX  128U
 #define ZXDH_TX_QUEUES_MAX  128U
+#define ZXDH_QUEUE_DEPTH    1024
+#define ZXDH_QUEUES_BASE       0
+#define ZXDH_TOTAL_QUEUES_NUM  4096
+#define ZXDH_QUEUES_NUM_MAX    256
+#define ZXDH_QUERES_SHARE_BASE      (0x5000)
 
 #define ZXDH_NUM_BARS    2
 
+#define ZXDH_MBUF_BURST_SZ  64
+
 union VPORT {
 	uint16_t vport;
 	struct {
@@ -44,6 +54,11 @@ union VPORT {
 	};
 };
 
+struct chnl_context {
+	uint16_t valid;
+	uint16_t ph_chno;
+};
+
 struct zxdh_hw {
 	struct rte_eth_dev *eth_dev;
 	struct zxdh_pci_common_cfg *common_cfg;
@@ -51,6 +66,7 @@ struct zxdh_hw {
 	struct rte_intr_handle *risc_intr;
 	struct rte_intr_handle *dtb_intr;
 	struct virtqueue **vqs;
+	struct chnl_context channel_context[ZXDH_QUEUES_NUM_MAX];
 	union VPORT vport;
 
 	uint64_t bar_addr[ZXDH_NUM_BARS];
@@ -64,6 +80,7 @@ struct zxdh_hw {
 	uint16_t device_id;
 	uint16_t port_id;
 	uint16_t vfid;
+	uint16_t queue_num;
 
 	uint8_t *isr;
 	uint8_t weak_barriers;
@@ -75,6 +92,8 @@ struct zxdh_hw {
 	uint8_t phyport;
 	uint8_t panel_id;
 	uint8_t msg_chan_init;
+	uint8_t has_tx_offload;
+	uint8_t has_rx_offload;
 };
 
 uint16_t vport_to_vfid(union VPORT v);
drivers/net/zxdh/zxdh_pci.c +97 -0

115 lines not on this page · raw message

drivers/net/zxdh/zxdh_pci.h +28 -0
index 677dadd5c8..f8949ec041 100644
@@ -12,7 +12,9 @@ extern "C" {
 #include <stdint.h>
 #include <stdbool.h>
 
+#include <rte_pci.h>
 #include <bus_pci_driver.h>
+#include <ethdev_driver.h>
 
 #include "zxdh_ethdev.h"
 
@@ -34,8 +36,20 @@ enum zxdh_msix_status {
 #define PCI_CAP_ID_MSIX              0x11
 
 #define PCI_MSIX_ENABLE              0x8000
+#define ZXDH_PCI_VRING_ALIGN         4096
 
+#define ZXDH_NET_F_CSUM              0   /* Host handles pkts w/ partial csum */
+#define ZXDH_NET_F_GUEST_CSUM        1   /* Guest handles pkts w/ partial csum */
+#define ZXDH_NET_F_MTU               3   /* Initial MTU advice. */
 #define ZXDH_NET_F_MAC               5   /* Host has given MAC address. */
+#define ZXDH_NET_F_GUEST_TSO4        7   /* Guest can handle TSOv4 in. */
+#define ZXDH_NET_F_GUEST_TSO6        8   /* Guest can handle TSOv6 in. */
+#define ZXDH_NET_F_GUEST_ECN         9   /* Guest can handle TSO[6] w/ ECN in. */
+#define ZXDH_NET_F_GUEST_UFO         10  /* Guest can handle UFO in. */
+
+#define ZXDH_NET_F_HOST_UFO          14  /* Host can handle UFO in. */
+#define ZXDH_NET_F_HOST_TSO4         11  /* Host can handle TSOv4 in. */
+#define ZXDH_NET_F_HOST_TSO6         12  /* Host can handle TSOv6 in. */
 #define ZXDH_NET_F_MRG_RXBUF         15  /* Host can merge receive buffers. */
 #define ZXDH_NET_F_STATUS            16  /* zxdh_net_config.status available */
 #define ZXDH_NET_F_MQ                22  /* Device supports Receive Flow Steering */
@@ -60,6 +74,8 @@ enum zxdh_msix_status {
 #define ZXDH_CONFIG_STATUS_DEV_NEED_RESET  0x40
 #define ZXDH_CONFIG_STATUS_FAILED          0x80
 
+#define ZXDH_PCI_QUEUE_ADDR_SHIFT          12
+
 struct zxdh_net_config {
 	/* The config defining mac address (if ZXDH_NET_F_MAC) */
 	uint8_t    mac[RTE_ETHER_ADDR_LEN];
@@ -122,6 +138,11 @@ static inline int32_t vtpci_with_feature(struct zxdh_hw *hw, uint64_t bit)
 	return (hw->guest_features & (1ULL << bit)) != 0;
 }
 
+static inline int32_t vtpci_packed_queue(struct zxdh_hw *hw)
+{
+	return vtpci_with_feature(hw, ZXDH_F_RING_PACKED);
+}
+
 struct zxdh_pci_ops {
 	void     (*read_dev_cfg)(struct zxdh_hw *hw, size_t offset, void *dst, int32_t len);
 	void     (*write_dev_cfg)(struct zxdh_hw *hw, size_t offset, const void *src, int32_t len);
@@ -134,6 +155,11 @@ struct zxdh_pci_ops {
 	uint16_t (*set_queue_irq)(struct zxdh_hw *hw, struct virtqueue *vq, uint16_t vec);
 	uint16_t (*set_config_irq)(struct zxdh_hw *hw, uint16_t vec);
 	uint8_t  (*get_isr)(struct zxdh_hw *hw);
+	uint16_t (*get_queue_num)(struct zxdh_hw *hw, uint16_t queue_id);
+	void     (*set_queue_num)(struct zxdh_hw *hw, uint16_t queue_id, uint16_t vq_size);
+
+	int32_t  (*setup_queue)(struct zxdh_hw *hw, struct virtqueue *vq);
+	void     (*del_queue)(struct zxdh_hw *hw, struct virtqueue *vq);
 };
 
 struct zxdh_hw_internal {
@@ -155,6 +181,8 @@ int32_t zxdh_get_pci_dev_config(struct zxdh_hw *hw);
 uint16_t zxdh_vtpci_get_features(struct zxdh_hw *hw);
 uint8_t zxdh_vtpci_isr(struct zxdh_hw *hw);
 enum zxdh_msix_status zxdh_vtpci_msix_detect(struct rte_pci_device *dev);
+void zxdh_vtpci_reinit_complete(struct zxdh_hw *hw);
+void zxdh_vtpci_set_status(struct zxdh_hw *hw, uint8_t status);
 
 #ifdef __cplusplus
 }
drivers/net/zxdh/zxdh_queue.c new file +131 -0

131 lines not on this page · raw message

drivers/net/zxdh/zxdh_queue.h +171 -0

190 lines not on this page · raw message

drivers/net/zxdh/zxdh_rxtx.h +1 -1
index 6476bc15e2..7e9f3a3ae6 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2023 ZTE Corporation
+ * Copyright(c) 2024 ZTE Corporation
  */
 
 #ifndef _ZXDH_RXTX_H_
Signature · 1 line
2.27.0
#15 lore raw

Re: [PATCH v5 9/9] net/zxdh: add zxdh dev configure ops

Quoted 9 lines · On Tue, 15 Oct 2024 13:44:35 +0800 Junlong Wang <[email protected]>…
drivers/net/zxdh/meson.build +0 -1
index 9aec47e68f..cde96d8111 100644
@@ -14,8 +14,9 @@ if not dpdk_conf.has('RTE_ARCH_X86_64') or not dpdk_conf.get('RTE_ARCH_64')
 endif
 
 sources = files(
-    'zxdh_ethdev.c',

drivers/net/zxdh/meson.build if not dpdk_conf.has('RTE_ARCH_X86_64') or not dpdk_conf.get('RTE_ARCH_64') · line 22

Quoted 10 lines
drivers/net/zxdh/meson.build +6 -4
-    'zxdh_pci.c',
-    'zxdh_msg.c',
-    'zxdh_common.c',
-    )
+        'zxdh_ethdev.c',
+        'zxdh_pci.c',
+        'zxdh_msg.c',
+        'zxdh_common.c',
+        'zxdh_queue.c',
+        )

If you make a new version, then fix indentation in earlier patch to avoid having to fix it in last patch.

#16 lore raw

Re: [PATCH v5 9/9] net/zxdh: add zxdh dev configure ops

In reply to Junlong Wang
Quoted 4 lines · On Tue, 15 Oct 2024 13:44:35 +0800 Junlong Wang <[email protected]>…

provided zxdh dev configure ops for queue
check,reset,alloc resources,etc.

These build failures need to be addressed.
Probably as simple as adding

	struct bar_msg_header msg_header = { 0 };

####################################################################################
#### [Begin job log] "ubuntu-22.04-gcc-stdatomic" at step Build and test
####################################################################################

  951 |         struct bar_msg_header msg_header;
      |                               ^~~~~~~~~~

../drivers/net/zxdh/zxdh_msg.c:976:60: error: ‘msg_header.sync’ may be used uninitialized [-Werror=maybe-uninitialized]
976 | uint64_t reps_addr = zxdh_reply_addr_get(msg_header.sync, src, dst, virt_addr);
| ~~~~~~~~~~^~~~~
../drivers/net/zxdh/zxdh_msg.c:951:31: note: ‘msg_header’ declared here

  951 |         struct bar_msg_header msg_header;
      |                               ^~~~~~~~~~

In function ‘zxdh_bar_msg_ack_async_msg_proc’,
inlined from ‘zxdh_bar_irq_recv’ at ../drivers/net/zxdh/zxdh_msg.c:984:3:
../drivers/net/zxdh/zxdh_msg.c:860:78: error: ‘msg_header.msg_id’ may be used uninitialized [-Werror=maybe-uninitialized]
860 | struct seqid_item *reps_info = &g_seqid_ring.reps_info_tbl[msg_header->msg_id];
| ~~~~~~~~~~^~~~~~~~
../drivers/net/zxdh/zxdh_msg.c: In function ‘zxdh_bar_irq_recv’:
../drivers/net/zxdh/zxdh_msg.c:951:31: note: ‘msg_header’ declared here

  951 |         struct bar_msg_header msg_header;
      |                               ^~~~~~~~~~

cc1: all warnings being treated as errors
[2198/3046] Compiling C object 'drivers/a715181@@tmp_rte_net_zxdh at sta/net_zxdh_zxdh_queue.c.o'. [2199/3046] Compiling C object 'drivers/a715181@@tmp_rte_raw_cnxk_bphy at sta/raw_cnxk_bphy_cnxk_bphy_cgx.c.o'. [2200/3046] Generating rte_net_vmxnet3.pmd.c with a custom command.
[2201/3046] Compiling C object 'drivers/a715181@@tmp_rte_raw_cnxk_bphy at sta/raw_cnxk_bphy_cnxk_bphy.c.o'. [2202/3046] Compiling C object 'drivers/a715181@@tmp_rte_net_zxdh at sta/net_zxdh_zxdh_common.c.o'.
ninja: build stopped: subcommand failed.
##[error]Process completed with exit code 1.
####################################################################################
#### [End job log] "ubuntu-22.04-gcc-stdatomic" at step Build and test
####################################################################################

#17 lore raw

v6 cover net/zxdh: introduce net zxdh driver

In reply to Junlong Wang

v6:
- Resolve ci/intel compilation issues.
- fix meson.build indentation in earlier patch.

V5:
- split driver into multiple patches,part of the zxdh driver, later provide dev start/stop,queue_setup,npsdk_init,mac,vlan,rss ,etc.
- fix errors reported by scripts.
- move the product link in zxdh.rst.
- fix meson check use RTE_ARCH_X86_64/RTE_ARCH_ARM64.
- modify other comments according to Ferruh's comments.

V4:
- Resolve compilation issues

Junlong Wang (9):
net/zxdh: add zxdh ethdev pmd driver net/zxdh: add logging implementation net/zxdh: add zxdh device pci init implementation net/zxdh: add msg chan and msg hwlock init net/zxdh: add msg chan enable implementation net/zxdh: add zxdh get device backend infos net/zxdh: add configure zxdh intr implementation net/zxdh: add zxdh dev infos get ops net/zxdh: add zxdh dev configure ops

 doc/guides/nics/features/zxdh.ini |    9 +
 doc/guides/nics/index.rst         |    1 +
 doc/guides/nics/zxdh.rst          |   30 +
 drivers/net/meson.build           |    1 +
 drivers/net/zxdh/meson.build      |   22 +
 drivers/net/zxdh/zxdh_common.c    |  368 +++++++++++
 drivers/net/zxdh/zxdh_common.h    |   42 ++
 drivers/net/zxdh/zxdh_ethdev.c    | 1020 +++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev.h    |  100 +++
 drivers/net/zxdh/zxdh_logs.h      |   40 ++
 drivers/net/zxdh/zxdh_msg.c       |  986 ++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_msg.h       |  228 +++++++
 drivers/net/zxdh/zxdh_pci.c       |  449 +++++++++++++
 drivers/net/zxdh/zxdh_pci.h       |  194 ++++++
 drivers/net/zxdh/zxdh_queue.c     |  131 ++++
 drivers/net/zxdh/zxdh_queue.h     |  281 ++++++++
 drivers/net/zxdh/zxdh_rxtx.h      |   55 ++
 17 files changed, 3957 insertions(+)
 create mode 100644 doc/guides/nics/features/zxdh.ini
 create mode 100644 doc/guides/nics/zxdh.rst
 create mode 100644 drivers/net/zxdh/meson.build
 create mode 100644 drivers/net/zxdh/zxdh_common.c
 create mode 100644 drivers/net/zxdh/zxdh_common.h
 create mode 100644 drivers/net/zxdh/zxdh_ethdev.c
 create mode 100644 drivers/net/zxdh/zxdh_ethdev.h
 create mode 100644 drivers/net/zxdh/zxdh_logs.h
 create mode 100644 drivers/net/zxdh/zxdh_msg.c
 create mode 100644 drivers/net/zxdh/zxdh_msg.h
 create mode 100644 drivers/net/zxdh/zxdh_pci.c
 create mode 100644 drivers/net/zxdh/zxdh_pci.h
 create mode 100644 drivers/net/zxdh/zxdh_queue.c
 create mode 100644 drivers/net/zxdh/zxdh_queue.h
 create mode 100644 drivers/net/zxdh/zxdh_rxtx.h
Signature · 1 line
2.27.0
#18 lore raw

PATCH v6 1/9 net/zxdh: add zxdh ethdev pmd driver

Add basic zxdh ethdev init and register PCI probe functions Update doc files

---
 doc/guides/nics/features/zxdh.ini |  9 +++
 doc/guides/nics/index.rst         |  1 +
 doc/guides/nics/zxdh.rst          | 30 ++++++++++
 drivers/net/meson.build           |  1 +
 drivers/net/zxdh/meson.build      | 18 ++++++
 drivers/net/zxdh/zxdh_ethdev.c    | 92 +++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev.h    | 44 +++++++++++++++
 7 files changed, 195 insertions(+)
 create mode 100644 doc/guides/nics/features/zxdh.ini
 create mode 100644 doc/guides/nics/zxdh.rst
 create mode 100644 drivers/net/zxdh/meson.build
 create mode 100644 drivers/net/zxdh/zxdh_ethdev.c
 create mode 100644 drivers/net/zxdh/zxdh_ethdev.h
doc/guides/nics/features/zxdh.ini new file +9 -0
new file mode 100644
index 0000000000..05c8091ed7
@@ -0,0 +1,9 @@
+;
+; Supported features of the 'zxdh' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Linux                = Y
+x86-64               = Y
+ARMv8                = Y
doc/guides/nics/index.rst +1 -0
index c14bc7988a..8e371ac4a5 100644
@@ -69,3 +69,4 @@ Network Interface Controller Drivers
     vhost
     virtio
     vmxnet3
+    zxdh
doc/guides/nics/zxdh.rst new file +30 -0
new file mode 100644
index 0000000000..9832115e11
@@ -0,0 +1,30 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright(c) 2024 ZTE Corporation.
+
+ZXDH Poll Mode Driver
+======================
+
+The ZXDH PMD (**librte_net_zxdh**) provides poll mode driver support
+for 25/100 Gbps ZXDH NX Series Ethernet Controller based on
+the ZTE Ethernet Controller E310/E312.
+
+- Learning about ZXDH NX Series Ethernet Controller NICs using
+  `<https://enterprise.zte.com.cn/sup-detail.html?id=271&suptype=1>`_.
+
+Features
+--------
+
+Features of the zxdh PMD are:
+
+- Multi arch support: x86_64, ARMv8.
+
+
+Driver compilation and testing
+------------------------------
+
+Refer to the document :ref:`compiling and testing a PMD for a NIC <pmd_build_and_test>`
+for details.
+
+Limitations or Known issues
+---------------------------
+X86-32, Power8, ARMv7 and BSD are not supported yet.
drivers/net/meson.build +1 -0
index fb6d34b782..0a12914534 100644
@@ -62,6 +62,7 @@ drivers = [
         'vhost',
         'virtio',
         'vmxnet3',
+        'zxdh',
 ]
 std_deps = ['ethdev', 'kvargs'] # 'ethdev' also pulls in mbuf, net, eal etc
 std_deps += ['bus_pci']         # very many PMDs depend on PCI, so make std
drivers/net/zxdh/meson.build new file +18 -0
new file mode 100644
index 0000000000..932fb1c835
@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2024 ZTE Corporation
+
+if not is_linux
+    build = false
+    reason = 'only supported on Linux'
+    subdir_done()
+endif
+
+if not dpdk_conf.has('RTE_ARCH_X86_64') or not dpdk_conf.get('RTE_ARCH_64')
+    build = false
+    reason = 'only supported on x86_64 and aarch64'
+    subdir_done()
+endif
+
+sources = files(
+        'zxdh_ethdev.c',
+)
drivers/net/zxdh/zxdh_ethdev.c new file +92 -0

92 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev.h new file +44 -0

44 lines not on this page · raw message

Signature · 1 line
2.27.0
#19 lore raw

PATCH v6 2/9 net/zxdh: add logging implementation

Add zxdh logging implementation.

---
 drivers/net/zxdh/zxdh_ethdev.c | 15 +++++++++++--
 drivers/net/zxdh/zxdh_logs.h   | 40 ++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/zxdh/zxdh_logs.h
drivers/net/zxdh/zxdh_ethdev.c +13 -2
index 75d8b28cc3..7220770c01 100644
@@ -7,6 +7,7 @@
 #include <rte_ethdev.h>
 
 #include "zxdh_ethdev.h"
+#include "zxdh_logs.h"
 
 static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 {
@@ -19,13 +20,18 @@ static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 	/* Allocate memory for storing MAC addresses */
 	eth_dev->data->mac_addrs = rte_zmalloc("zxdh_mac",
 			ZXDH_MAX_MAC_ADDRS * RTE_ETHER_ADDR_LEN, 0);
-	if (eth_dev->data->mac_addrs == NULL)
+	if (eth_dev->data->mac_addrs == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to allocate %d bytes store MAC addresses",
+				ZXDH_MAX_MAC_ADDRS * RTE_ETHER_ADDR_LEN);
 		return -ENOMEM;
+	}
 
 	memset(hw, 0, sizeof(*hw));
 	hw->bar_addr[0] = (uint64_t)pci_dev->mem_resource[0].addr;
-	if (hw->bar_addr[0] == 0)
+	if (hw->bar_addr[0] == 0) {
+		PMD_INIT_LOG(ERR, "Bad mem resource.");
 		return -EIO;
+	}
 
 	hw->device_id = pci_dev->id.device_id;
 	hw->port_id = eth_dev->data->port_id;
@@ -90,3 +96,8 @@ static struct rte_pci_driver zxdh_pmd = {
 RTE_PMD_REGISTER_PCI(net_zxdh, zxdh_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_zxdh, pci_id_zxdh_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_zxdh, "* vfio-pci");
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_init, init, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_driver, driver, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_rx, rx, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_tx, tx, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_msg, msg, NOTICE);
drivers/net/zxdh/zxdh_logs.h new file +40 -0
new file mode 100644
index 0000000000..52dbd8228b
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 ZTE Corporation
+ */
+
+#ifndef _ZXDH_LOGS_H_
+#define _ZXDH_LOGS_H_
+
+#include <rte_log.h>
+
+extern int zxdh_logtype_init;
+#define RTE_LOGTYPE_ZXDH_INIT zxdh_logtype_init
+#define PMD_INIT_LOG(level, ...) \
+	RTE_LOG_LINE_PREFIX(level, ZXDH_INIT, "offload_zxdh %s(): ", \
+		__func__, __VA_ARGS__)
+
+extern int zxdh_logtype_driver;
+#define RTE_LOGTYPE_ZXDH_DRIVER zxdh_logtype_driver
+#define PMD_DRV_LOG(level, ...) \
+	RTE_LOG_LINE_PREFIX(level, ZXDH_DRIVER, "offload_zxdh %s(): ", \
+		__func__, __VA_ARGS__)
+
+extern int zxdh_logtype_rx;
+#define RTE_LOGTYPE_ZXDH_RX zxdh_logtype_rx
+#define PMD_RX_LOG(level, ...) \
+	RTE_LOG_LINE_PREFIX(level, ZXDH_RX, "offload_zxdh %s(): ", \
+		__func__, __VA_ARGS__)
+
+extern int zxdh_logtype_tx;
+#define RTE_LOGTYPE_ZXDH_TX zxdh_logtype_tx
+#define PMD_TX_LOG(level, ...) \
+	RTE_LOG_LINE_PREFIX(level, ZXDH_TX, "offload_zxdh %s(): ", \
+		__func__, __VA_ARGS__)
+
+extern int zxdh_logtype_msg;
+#define RTE_LOGTYPE_ZXDH_MSG zxdh_logtype_msg
+#define PMD_MSG_LOG(level, ...) \
+	RTE_LOG_LINE_PREFIX(level, ZXDH_MSG, "offload_zxdh %s(): ", \
+		__func__, __VA_ARGS__)
+
+#endif /* _ZXDH_LOGS_H_ */
Signature · 1 line
2.27.0
#20 lore raw

PATCH v6 3/9 net/zxdh: add zxdh device pci init implementation

Add device pci init implementation,
to obtain PCI capability and read configuration, etc.

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_ethdev.c |  43 +++++
 drivers/net/zxdh/zxdh_ethdev.h |  20 ++-
 drivers/net/zxdh/zxdh_pci.c    | 290 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_pci.h    | 151 +++++++++++++++++
 drivers/net/zxdh/zxdh_queue.h  | 105 ++++++++++++
 drivers/net/zxdh/zxdh_rxtx.h   |  51 ++++++
 7 files changed, 659 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/zxdh/zxdh_pci.c
 create mode 100644 drivers/net/zxdh/zxdh_pci.h
 create mode 100644 drivers/net/zxdh/zxdh_queue.h
 create mode 100644 drivers/net/zxdh/zxdh_rxtx.h
drivers/net/zxdh/meson.build +1 -0
index 932fb1c835..7db4e7bc71 100644
@@ -15,4 +15,5 @@ endif
 
 sources = files(
         'zxdh_ethdev.c',
+        'zxdh_pci.c',
 )
drivers/net/zxdh/zxdh_ethdev.c +43 -0

55 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev.h +18 -2
index 04023bfe84..18d9916713 100644
@@ -9,6 +9,7 @@
 extern "C" {
 #endif
 
+#include <rte_ether.h>
 #include "ethdev_driver.h"
 
 /* ZXDH PCI vendor/device ID. */
@@ -23,16 +24,31 @@ extern "C" {
 #define ZXDH_MAX_MC_MAC_ADDRS  32
 #define ZXDH_MAX_MAC_ADDRS     (ZXDH_MAX_UC_MAC_ADDRS + ZXDH_MAX_MC_MAC_ADDRS)
 
+#define ZXDH_RX_QUEUES_MAX  128U
+#define ZXDH_TX_QUEUES_MAX  128U
+
 #define ZXDH_NUM_BARS    2
 
 struct zxdh_hw {
 	struct rte_eth_dev *eth_dev;
-	uint64_t bar_addr[ZXDH_NUM_BARS];
+	struct zxdh_pci_common_cfg *common_cfg;
+	struct zxdh_net_config *dev_cfg;
 
-	uint32_t  speed;
+	uint64_t bar_addr[ZXDH_NUM_BARS];
+	uint64_t host_features;
+	uint64_t guest_features;
+	uint32_t max_queue_pairs;
+	uint32_t speed;
+	uint32_t notify_off_multiplier;
+	uint16_t *notify_base;
+	uint16_t pcie_id;
 	uint16_t device_id;
 	uint16_t port_id;
 
+	uint8_t *isr;
+	uint8_t weak_barriers;
+	uint8_t use_msix;
+	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
 	uint8_t duplex;
 	uint8_t is_pf;
 };
drivers/net/zxdh/zxdh_pci.c new file +290 -0

290 lines not on this page · raw message

drivers/net/zxdh/zxdh_pci.h new file +151 -0

151 lines not on this page · raw message

drivers/net/zxdh/zxdh_queue.h new file +105 -0

105 lines not on this page · raw message

drivers/net/zxdh/zxdh_rxtx.h new file +51 -0

51 lines not on this page · raw message

Signature · 1 line
2.27.0
#21 lore raw

PATCH v6 4/9 net/zxdh: add msg chan and msg hwlock init

In reply to Junlong Wang

Add msg channel and hwlock init implementation.

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_ethdev.c |  15 +++
 drivers/net/zxdh/zxdh_ethdev.h |   1 +
 drivers/net/zxdh/zxdh_msg.c    | 161 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_msg.h    |  65 +++++++++++++
 5 files changed, 243 insertions(+)
 create mode 100644 drivers/net/zxdh/zxdh_msg.c
 create mode 100644 drivers/net/zxdh/zxdh_msg.h
drivers/net/zxdh/meson.build +1 -0
index 7db4e7bc71..2e0c8fddae 100644
@@ -16,4 +16,5 @@ endif
 sources = files(
         'zxdh_ethdev.c',
         'zxdh_pci.c',
+        'zxdh_msg.c',
 )
drivers/net/zxdh/zxdh_ethdev.c +15 -0
index f34b2af7b3..e69d11e9fd 100644
@@ -9,6 +9,7 @@
 #include "zxdh_ethdev.h"
 #include "zxdh_logs.h"
 #include "zxdh_pci.h"
+#include "zxdh_msg.h"
 
 struct zxdh_hw_internal zxdh_hw_internal[RTE_MAX_ETHPORTS];
 
@@ -83,9 +84,23 @@ static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 	if (ret < 0)
 		goto err_zxdh_init;
 
+	ret = zxdh_msg_chan_init();
+	if (ret < 0) {
+		PMD_INIT_LOG(ERR, "Failed to init bar msg chan");
+		goto err_zxdh_init;
+	}
+	hw->msg_chan_init = 1;
+
+	ret = zxdh_msg_chan_hwlock_init(eth_dev);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "zxdh_msg_chan_hwlock_init failed ret %d", ret);
+		goto err_zxdh_init;
+	}
+
 	return ret;
 
 err_zxdh_init:
+	zxdh_bar_msg_chan_exit();
 	rte_free(eth_dev->data->mac_addrs);
 	eth_dev->data->mac_addrs = NULL;
 	return ret;
drivers/net/zxdh/zxdh_ethdev.h +1 -0
index 18d9916713..24eb3a5ca0 100644
@@ -51,6 +51,7 @@ struct zxdh_hw {
 	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
 	uint8_t duplex;
 	uint8_t is_pf;
+	uint8_t msg_chan_init;
 };
 
 #ifdef __cplusplus
drivers/net/zxdh/zxdh_msg.c new file +161 -0

161 lines not on this page · raw message

drivers/net/zxdh/zxdh_msg.h new file +65 -0

65 lines not on this page · raw message

Signature · 1 line
2.27.0
#22 lore raw

PATCH v6 5/9 net/zxdh: add msg chan enable implementation

In reply to Junlong Wang

Add msg chan enable implementation to support
send msg to get infos.

---
 drivers/net/zxdh/zxdh_ethdev.c |   6 +
 drivers/net/zxdh/zxdh_ethdev.h |  12 +
 drivers/net/zxdh/zxdh_msg.c    | 643 ++++++++++++++++++++++++++++++++-
 drivers/net/zxdh/zxdh_msg.h    | 127 +++++++
 4 files changed, 787 insertions(+), 1 deletion(-)
drivers/net/zxdh/zxdh_ethdev.c +6 -0
index e69d11e9fd..5002e76e23 100644
@@ -97,6 +97,12 @@ static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 		goto err_zxdh_init;
 	}
 
+	ret = zxdh_msg_chan_enable(eth_dev);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "zxdh_msg_bar_chan_enable failed ret %d", ret);
+		goto err_zxdh_init;
+	}
+
 	return ret;
 
 err_zxdh_init:
drivers/net/zxdh/zxdh_ethdev.h +12 -0
index 24eb3a5ca0..a51181f1ce 100644
@@ -29,10 +29,22 @@ extern "C" {
 
 #define ZXDH_NUM_BARS    2
 
+union VPORT {
+	uint16_t vport;
+	struct {
+		uint16_t vfid:8;
+		uint16_t pfid:3;
+		uint16_t vf_flag:1;
+		uint16_t epid:3;
+		uint16_t direct_flag:1;
+	};
+};
+
 struct zxdh_hw {
 	struct rte_eth_dev *eth_dev;
 	struct zxdh_pci_common_cfg *common_cfg;
 	struct zxdh_net_config *dev_cfg;
+	union VPORT vport;
 
 	uint64_t bar_addr[ZXDH_NUM_BARS];
 	uint64_t host_features;
drivers/net/zxdh/zxdh_msg.c +642 -1

673 lines not on this page · raw message

drivers/net/zxdh/zxdh_msg.h +127 -0

149 lines not on this page · raw message

Signature · 1 line
2.27.0
#23 lore raw

Re: [PATCH v6 5/9] net/zxdh: add msg chan enable implementation

16/10/2024 10:18, Junlong Wang:

Quoted 2 lines

Add msg chan enable implementation to support
send msg to get infos.

Would be interesting to explain which module is receiving the message.

Quoted 1 line

+union VPORT {

Why uppercase? for differenciate with vport below? In general we tend to use only lowercase.

drivers/net/zxdh/zxdh_ethdev.h extern "C" { · line 41

Quoted 9 lines
drivers/net/zxdh/zxdh_ethdev.h +9 -0
+	uint16_t vport;
+	struct {
+		uint16_t vfid:8;
+		uint16_t pfid:3;
+		uint16_t vf_flag:1;
+		uint16_t epid:3;
+		uint16_t direct_flag:1;
+	};
+};

I am curious about the spinlock function below.
What is it doing exactly?

drivers/net/zxdh/zxdh_msg.c static int32_t zxdh_spinlock_unlock(uint32_t virt_lock_id, uint64_t virt_addr, u · line 191

Quoted 8 lines
drivers/net/zxdh/zxdh_msg.c +8 -0
+static int32_t zxdh_spinlock_lock(uint32_t virt_lock_id, uint64_t virt_addr,
+					uint64_t label_addr, uint16_t primary_id)
+{
+	uint32_t lock_rd_cnt = 0;
+
+	do {
+		/* read to lock */
+		uint8_t spl_val = spinklock_read(virt_addr, virt_lock_id);

typo, it should be spinlock_read

Quoted 13 lines
drivers/net/zxdh/zxdh_msg.c +13 -0
+
+		if (spl_val == 0) {
+			label_write((uint64_t)label_addr, virt_lock_id, primary_id);
+			break;
+		}
+		rte_delay_us_block(SPINLOCK_POLLING_SPAN_US);
+		lock_rd_cnt++;
+	} while (lock_rd_cnt < MAX_HARD_SPINLOCK_ASK_TIMES);
+	if (lock_rd_cnt >= MAX_HARD_SPINLOCK_ASK_TIMES)
+		return -1;
+
+	return 0;
+}

[...]

Quoted 5 lines
drivers/net/zxdh/zxdh_msg.c +5 -0
+pthread_spinlock_t chan_lock;
+static int zxdh_bar_chan_lock(uint8_t src, uint8_t dst, uint16_t src_pcieid, uint64_t virt_addr)
+{
+	int ret = 0;
+	uint8_t src_index = zxdh_bar_msg_src_index_trans(src);

drivers/net/zxdh/zxdh_msg.c static int bar_chan_pf_init_spinlock(uint16_t pcie_id, uint64_t bar_base_addr) · line 412

Quoted 10 lines
drivers/net/zxdh/zxdh_msg.c +10 -0
+	uint8_t dst_index = zxdh_bar_msg_dst_index_trans(dst);
+
+	if (src_index == BAR_MSG_SRC_ERR || dst_index == BAR_MSG_DST_ERR) {
+		PMD_MSG_LOG(ERR, "lock ERR: chan doesn't exist.");
+		return BAR_MSG_ERR_TYPE;
+	}
+	uint16_t idx = lock_type_tbl[src_index][dst_index];
+
+	if (idx == LOCK_TYPE_SOFT)
+		pthread_spin_lock(&chan_lock);

In general we avoid the pthread.h functions.
Do you know we have rte_spinlock_lock()?

Quoted 8 lines
drivers/net/zxdh/zxdh_msg.c +8 -0
+	else
+		ret = zxdh_bar_hard_lock(src_pcieid, dst, virt_addr);
+
+	if (ret != 0)
+		PMD_MSG_LOG(ERR, "dev: 0x%x failed to lock.", src_pcieid);
+
+	return ret;
+}

[...]

drivers/net/zxdh/zxdh_msg.h extern "C" { · line 17

Quoted 8 lines
drivers/net/zxdh/zxdh_msg.h +2 -0
@@ -13,6 +13,19 @@ extern "C" {
 
 #include <ethdev_driver.h>
 
+#define ZXDH_MSIX_INTR_MSG_VEC_BASE  1
+

You should continue using the prefix ZXDH_
These definitions below have a high risk of namespace conflict in future. Using a namespace prefix is a good practice.

Quoted 143 lines
drivers/net/zxdh/zxdh_msg.h +10 -0
+#define BAR_MSG_POLLING_SPAN     100
+#define BAR_MSG_POLL_CNT_PER_MS  (1 * 1000 / BAR_MSG_POLLING_SPAN)
+#define BAR_MSG_POLL_CNT_PER_S   (1 * 1000 * 1000 / BAR_MSG_POLLING_SPAN)
+#define BAR_MSG_TIMEOUT_TH       (10 * 1000 * 1000 / BAR_MSG_POLLING_SPAN)
+
+#define BAR_CHAN_MSG_SYNC     0
+
+#define BAR_MSG_ADDR_CHAN_INTERVAL  (2 * 1024) /* channel size */
+#define BAR_MSG_PLAYLOAD_OFFSET     (sizeof(struct bar_msg_header))
+#define BAR_MSG_PAYLOAD_MAX_LEN     (BAR_MSG_ADDR_CHAN_INTERVAL -

sizeof(struct bar_msg_header)) +

enum DRIVER_TYPE {

     MSG_CHAN_END_MPF = 0,
     MSG_CHAN_END_PF,
drivers/net/zxdh/zxdh_msg.h +7 -0
@@ -20,6 +33,13 @@ enum DRIVER_TYPE {
 
     MSG_CHAN_END_RISC,
 
 };
 
+enum MSG_VEC {
+    MSIX_FROM_PFVF = ZXDH_MSIX_INTR_MSG_VEC_BASE,
+    MSIX_FROM_MPF,
+    MSIX_FROM_RISCV,
+    MSG_VEC_NUM,
+};
+
 

enum BAR_MSG_RTN {

     BAR_MSG_OK = 0,
     BAR_MSG_ERR_MSGID,
drivers/net/zxdh/zxdh_msg.h +101 -0
@@ -54,10 +74,117 @@ enum BAR_MSG_RTN {
 
     BAR_MSG_ERR_SOCKET, /* netlink sockte err */
 
 };
 
+enum bar_module_id {
+    BAR_MODULE_DBG = 0, /* 0:  debug */
+    BAR_MODULE_TBL,     /* 1:  resource table */
+    BAR_MODULE_MISX,    /* 2:  config msix */
+    BAR_MODULE_SDA,     /* 3: */
+    BAR_MODULE_RDMA,    /* 4: */
+    BAR_MODULE_DEMO,    /* 5:  channel test */
+    BAR_MODULE_SMMU,    /* 6: */
+    BAR_MODULE_MAC,     /* 7:  mac rx/tx stats */
+    BAR_MODULE_VDPA,    /* 8:  vdpa live migration */
+    BAR_MODULE_VQM,     /* 9:  vqm live migration */
+    BAR_MODULE_NP,      /* 10: vf msg callback np */
+    BAR_MODULE_VPORT,   /* 11: get vport */
+    BAR_MODULE_BDF,     /* 12: get bdf */
+    BAR_MODULE_RISC_READY, /* 13: */
+    BAR_MODULE_REVERSE,    /* 14: byte stream reverse */
+    BAR_MDOULE_NVME,       /* 15: */
+    BAR_MDOULE_NPSDK,      /* 16: */
+    BAR_MODULE_NP_TODO,    /* 17: */
+    MODULE_BAR_MSG_TO_PF,  /* 18: */
+    MODULE_BAR_MSG_TO_VF,  /* 19: */
+
+    MODULE_FLASH = 32,
+    BAR_MODULE_OFFSET_GET = 33,
+    BAR_EVENT_OVS_WITH_VCB = 36,
+
+    BAR_MSG_MODULE_NUM = 100,
+};
+
+struct msix_para {
+    uint16_t pcie_id;
+    uint16_t vector_risc;
+    uint16_t vector_pfvf;
+    uint16_t vector_mpf;
+    uint64_t virt_addr;
+    uint16_t driver_type; /* refer to DRIVER_TYPE */
+};
+
+struct msix_msg {
+    uint16_t pcie_id;
+    uint16_t vector_risc;
+    uint16_t vector_pfvf;
+    uint16_t vector_mpf;
+};
+
+struct zxdh_pci_bar_msg {
+    uint64_t virt_addr; /* bar addr */
+    void    *payload_addr;
+    uint16_t payload_len;
+    uint16_t emec;
+    uint16_t src; /* refer to BAR_DRIVER_TYPE */
+    uint16_t dst; /* refer to BAR_DRIVER_TYPE */
+    uint16_t module_id;
+    uint16_t src_pcieid;
+    uint16_t dst_pcieid;
+    uint16_t usr;
+};
+
+struct bar_msix_reps {
+    uint16_t pcie_id;
+    uint16_t check;
+    uint16_t vport;
+    uint16_t rsv;
+} __rte_packed;
+
+struct bar_offset_reps {
+    uint16_t check;
+    uint16_t rsv;
+    uint32_t offset;
+    uint32_t length;
+} __rte_packed;
+
+struct bar_recv_msg {
+    uint8_t reps_ok;
+    uint16_t reps_len;
+    uint8_t rsv;
+    /* */
+    union {
+        struct bar_msix_reps msix_reps;
+        struct bar_offset_reps offset_reps;
+    } __rte_packed;
+} __rte_packed;
+
+struct zxdh_msg_recviver_mem {
+    void *recv_buffer; /* first 4B is head, followed by payload */
+    uint64_t buffer_len;
+};
+
+struct bar_msg_header {
+    uint8_t valid : 1; /* used by __bar_chan_msg_valid_set/get */
+    uint8_t sync  : 1;
+    uint8_t emec  : 1; /* emergency? */
+    uint8_t ack   : 1; /* ack msg? */
+    uint8_t poll  : 1;
+    uint8_t usr   : 1;
+    uint8_t rsv;
+    uint16_t module_id;
+    uint16_t len;
+    uint16_t msg_id;
+    uint16_t src_pcieid;
+    uint16_t dst_pcieid; /* used in PF-->VF */
#24 lore raw

Re: [PATCH v6 5/9] net/zxdh: add msg chan enable implementation

In reply to Junlong Wang
Quoted 4 lines
Quoted 2 lines

Add msg chan enable implementation to support
send msg to get infos.

Would be interesting to explain which module is receiving the message.

Send messages to the backend (device side) to obtain information.

Quoted 11 lines

I am curious about the spinlock function below.
What is it doing exactly?

drivers/net/zxdh/zxdh_msg.c static int32_t zxdh_spinlock_unlock(uint32_t virt_lock_id, uint64_t virt_addr, u · line 191

Quoted 8 lines
drivers/net/zxdh/zxdh_msg.c +8 -0
+static int32_t zxdh_spinlock_lock(uint32_t virt_lock_id, uint64_t virt_addr,
+					uint64_t label_addr, uint16_t primary_id)
+{
+	uint32_t lock_rd_cnt = 0;
+
+	do {
+		/* read to lock */
+		uint8_t spl_val = spinklock_read(virt_addr, virt_lock_id);

Using locks to ensure message consistency when accessing backend information for multiple pf/vf.

#25 lore raw

PATCH v6 6/9 net/zxdh: add zxdh get device backend infos

In reply to Junlong Wang

Add zxdh get device backend infos,
use msg chan to send msg get.

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_common.c | 249 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_common.h |  30 ++++
 drivers/net/zxdh/zxdh_ethdev.c |  35 +++++
 drivers/net/zxdh/zxdh_ethdev.h |   5 +
 drivers/net/zxdh/zxdh_msg.c    |   3 -
 drivers/net/zxdh/zxdh_msg.h    |  24 ++++
 7 files changed, 344 insertions(+), 3 deletions(-)
 create mode 100644 drivers/net/zxdh/zxdh_common.c
 create mode 100644 drivers/net/zxdh/zxdh_common.h
drivers/net/zxdh/meson.build +1 -0
index 2e0c8fddae..a16db47f89 100644
@@ -17,4 +17,5 @@ sources = files(
         'zxdh_ethdev.c',
         'zxdh_pci.c',
         'zxdh_msg.c',
+        'zxdh_common.c',
 )
drivers/net/zxdh/zxdh_common.c new file +249 -0

249 lines not on this page · raw message

drivers/net/zxdh/zxdh_common.h new file +30 -0
new file mode 100644
index 0000000000..ec7011e820
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 ZTE Corporation
+ */
+
+#ifndef _ZXDH_COMMON_H_
+#define _ZXDH_COMMON_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <rte_ethdev.h>
+
+#include "zxdh_ethdev.h"
+
+struct zxdh_res_para {
+	uint64_t virt_addr;
+	uint16_t pcie_id;
+	uint16_t src_type; /* refer to BAR_DRIVER_TYPE */
+};
+
+int32_t zxdh_phyport_get(struct rte_eth_dev *dev, uint8_t *phyport);
+int32_t zxdh_pannelid_get(struct rte_eth_dev *dev, uint8_t *pannelid);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ZXDH_COMMON_H_ */
drivers/net/zxdh/zxdh_ethdev.c +35 -0
index 5002e76e23..e282012afb 100644
@@ -10,9 +10,21 @@
 #include "zxdh_logs.h"
 #include "zxdh_pci.h"
 #include "zxdh_msg.h"
+#include "zxdh_common.h"
 
 struct zxdh_hw_internal zxdh_hw_internal[RTE_MAX_ETHPORTS];
 
+uint16_t vport_to_vfid(union VPORT v)
+{
+	/* epid > 4 is local soft queue. return 1192 */
+	if (v.epid > 4)
+		return 1192;
+	if (v.vf_flag)
+		return v.epid * 256 + v.vfid;
+	else
+		return (v.epid * 8 + v.pfid) + 1152;
+}
+
 static int32_t zxdh_init_device(struct rte_eth_dev *eth_dev)
 {
 	struct zxdh_hw *hw = eth_dev->data->dev_private;
@@ -44,6 +56,25 @@ static int32_t zxdh_init_device(struct rte_eth_dev *eth_dev)
 	return ret;
 }
 
+static int zxdh_agent_comm(struct rte_eth_dev *eth_dev, struct zxdh_hw *hw)
+{
+	if (zxdh_phyport_get(eth_dev, &hw->phyport) != 0) {
+		PMD_INIT_LOG(ERR, "Failed to get phyport");
+		return -1;
+	}
+	PMD_INIT_LOG(INFO, "Get phyport success: 0x%x", hw->phyport);
+
+	hw->vfid = vport_to_vfid(hw->vport);
+
+	if (zxdh_pannelid_get(eth_dev, &hw->panel_id) != 0) {
+		PMD_INIT_LOG(ERR, "Failed to get panel_id");
+		return -1;
+	}
+	PMD_INIT_LOG(INFO, "Get panel id success: 0x%x", hw->panel_id);
+
+	return 0;
+}
+
 static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 {
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
@@ -103,6 +134,10 @@ static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 		goto err_zxdh_init;
 	}
 
+	ret = zxdh_agent_comm(eth_dev, hw);
+	if (ret != 0)
+		goto err_zxdh_init;
+
 	return ret;
 
 err_zxdh_init:
drivers/net/zxdh/zxdh_ethdev.h +5 -0
index a51181f1ce..2351393009 100644
@@ -56,6 +56,7 @@ struct zxdh_hw {
 	uint16_t pcie_id;
 	uint16_t device_id;
 	uint16_t port_id;
+	uint16_t vfid;
 
 	uint8_t *isr;
 	uint8_t weak_barriers;
@@ -63,9 +64,13 @@ struct zxdh_hw {
 	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
 	uint8_t duplex;
 	uint8_t is_pf;
+	uint8_t phyport;
+	uint8_t panel_id;
 	uint8_t msg_chan_init;
 };
 
+uint16_t vport_to_vfid(union VPORT v);
+
 #ifdef __cplusplus
 }
 #endif
drivers/net/zxdh/zxdh_msg.c +0 -3
index 3ac4c8d796..e243f97703 100644
@@ -18,8 +18,6 @@
 #define REPS_INFO_FLAG_USABLE  0x00
 #define BAR_SEQID_NUM_MAX  256
 
-#define ZXDH_BAR0_INDEX  0
-
 #define PCIEID_IS_PF_MASK   (0x0800)
 #define PCIEID_PF_IDX_MASK  (0x0700)
 #define PCIEID_VF_IDX_MASK  (0x00ff)
@@ -43,7 +41,6 @@
 #define FW_SHRD_OFFSET                     (0x5000)
 #define FW_SHRD_INNER_HW_LABEL_PAT         (0x800)
 #define HW_LABEL_OFFSET                    (FW_SHRD_OFFSET + FW_SHRD_INNER_HW_LABEL_PAT)
-#define ZXDH_CTRLCH_OFFSET           (0x2000)
 #define CHAN_RISC_SPINLOCK_OFFSET    (BAR0_SPINLOCK_OFFSET - BAR0_CHAN_RISC_OFFSET)
 #define CHAN_PFVF_SPINLOCK_OFFSET    (BAR0_SPINLOCK_OFFSET - BAR0_CHAN_PFVF_OFFSET)
 #define CHAN_RISC_LABEL_OFFSET       (HW_LABEL_OFFSET - BAR0_CHAN_RISC_OFFSET)
drivers/net/zxdh/zxdh_msg.h +24 -0
index 06be0f18c8..7379f57d17 100644
@@ -13,6 +13,9 @@ extern "C" {
 
 #include <ethdev_driver.h>
 
+#define ZXDH_BAR0_INDEX          0
+
+#define ZXDH_CTRLCH_OFFSET          (0x2000)
 #define ZXDH_MSIX_INTR_MSG_VEC_BASE  1
 
 #define BAR_MSG_POLLING_SPAN     100
@@ -103,6 +106,27 @@ enum bar_module_id {
 	BAR_MSG_MODULE_NUM = 100,
 };
 
+enum RES_TBL_FILED {
+	TBL_FIELD_PCIEID     = 0,
+	TBL_FIELD_BDF        = 1,
+	TBL_FIELD_MSGCH      = 2,
+	TBL_FIELD_DATACH     = 3,
+	TBL_FIELD_VPORT      = 4,
+	TBL_FIELD_PNLID      = 5,
+	TBL_FIELD_PHYPORT    = 6,
+	TBL_FIELD_SERDES_NUM = 7,
+	TBL_FIELD_NP_PORT    = 8,
+	TBL_FIELD_SPEED      = 9,
+	TBL_FIELD_HASHID     = 10,
+	TBL_FIELD_NON,
+};
+
+enum TBL_MSG_TYPE {
+	TBL_TYPE_READ,
+	TBL_TYPE_WRITE,
+	TBL_TYPE_NON,
+};
+
 struct msix_para {
 	uint16_t pcie_id;
 	uint16_t vector_risc;
Signature · 1 line
2.27.0
#26 lore raw

Re: [PATCH v6 6/9] net/zxdh: add zxdh get device backend infos

16/10/2024 10:18, Junlong Wang:

Quoted 12 lines
drivers/net/zxdh/zxdh_msg.c +0 -2
@@ -18,8 +18,6 @@
 #define REPS_INFO_FLAG_USABLE  0x00
 #define BAR_SEQID_NUM_MAX  256
 
-#define ZXDH_BAR0_INDEX  0
-
 #define PCIEID_IS_PF_MASK   (0x0800)
 #define PCIEID_PF_IDX_MASK  (0x0700)
 #define PCIEID_VF_IDX_MASK  (0x00ff)

drivers/net/zxdh/zxdh_msg.c line 46

Quoted 7 lines
drivers/net/zxdh/zxdh_msg.c +0 -1
@@ -43,7 +41,6 @@
 #define FW_SHRD_OFFSET                     (0x5000)
 #define FW_SHRD_INNER_HW_LABEL_PAT         (0x800)
 #define HW_LABEL_OFFSET                    (FW_SHRD_OFFSET + FW_SHRD_INNER_HW_LABEL_PAT)
-#define ZXDH_CTRLCH_OFFSET           (0x2000)
 #define CHAN_RISC_SPINLOCK_OFFSET    (BAR0_SPINLOCK_OFFSET - BAR0_CHAN_RISC_OFFSET)
 #define CHAN_PFVF_SPINLOCK_OFFSET    (BAR0_SPINLOCK_OFFSET - BAR0_CHAN_PFVF_OFFSET)
 #define CHAN_RISC_LABEL_OFFSET       (HW_LABEL_OFFSET - BAR0_CHAN_RISC_OFFSET)

Removing code is strange here.
Maybe it should have been placed somewhere else initially?

#27 lore raw

PATCH v6 7/9 net/zxdh: add configure zxdh intr implementation

In reply to Junlong Wang

configure zxdh intr include risc,dtb. and release intr.

---
 drivers/net/zxdh/zxdh_ethdev.c | 301 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev.h |   8 +
 drivers/net/zxdh/zxdh_msg.c    | 187 ++++++++++++++++++++
 drivers/net/zxdh/zxdh_msg.h    |  12 ++
 drivers/net/zxdh/zxdh_pci.c    |  62 +++++++
 drivers/net/zxdh/zxdh_pci.h    |  12 ++
 6 files changed, 582 insertions(+)
drivers/net/zxdh/zxdh_ethdev.c +301 -0
index e282012afb..fc141712aa 100644
@@ -25,6 +25,302 @@ uint16_t vport_to_vfid(union VPORT v)
 		return (v.epid * 8 + v.pfid) + 1152;
 }
 
+static void zxdh_queues_unbind_intr(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+	int32_t i;
+
+	for (i = 0; i < dev->data->nb_rx_queues; ++i) {
+		VTPCI_OPS(hw)->set_queue_irq(hw, hw->vqs[i * 2], ZXDH_MSI_NO_VECTOR);
+		VTPCI_OPS(hw)->set_queue_irq(hw, hw->vqs[i * 2 + 1], ZXDH_MSI_NO_VECTOR);
+	}
+}
+
+
+static int32_t zxdh_intr_unmask(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (rte_intr_ack(dev->intr_handle) < 0)
+		return -1;
+
+	hw->use_msix = zxdh_vtpci_msix_detect(RTE_ETH_DEV_TO_PCI(dev));
+
+	return 0;
+}
+
+static void zxdh_devconf_intr_handler(void *param)
+{
+	struct rte_eth_dev *dev = param;
+
+	if (zxdh_intr_unmask(dev) < 0)
+		PMD_DRV_LOG(ERR, "interrupt enable failed");
+}
+
+
+/* Interrupt handler triggered by NIC for handling specific interrupt. */
+static void zxdh_fromriscv_intr_handler(void *param)
+{
+	struct rte_eth_dev *dev = param;
+	struct zxdh_hw *hw = dev->data->dev_private;
+	uint64_t virt_addr = 0;
+
+	virt_addr = (uint64_t)(hw->bar_addr[ZXDH_BAR0_INDEX] + ZXDH_CTRLCH_OFFSET);
+	if (hw->is_pf) {
+		PMD_INIT_LOG(DEBUG, "zxdh_risc2pf_intr_handler");
+		zxdh_bar_irq_recv(MSG_CHAN_END_RISC, MSG_CHAN_END_PF, virt_addr, dev);
+	} else {
+		PMD_INIT_LOG(DEBUG, "zxdh_riscvf_intr_handler");
+		zxdh_bar_irq_recv(MSG_CHAN_END_RISC, MSG_CHAN_END_VF, virt_addr, dev);
+	}
+}
+
+/* Interrupt handler triggered by NIC for handling specific interrupt. */
+static void zxdh_frompfvf_intr_handler(void *param)
+{
+	struct rte_eth_dev *dev = param;
+	struct zxdh_hw *hw = dev->data->dev_private;
+	uint64_t virt_addr = 0;
+
+	virt_addr = (uint64_t)(hw->bar_addr[ZXDH_BAR0_INDEX] + ZXDH_MSG_CHAN_PFVFSHARE_OFFSET);
+	if (hw->is_pf) {
+		PMD_INIT_LOG(DEBUG, "zxdh_vf2pf_intr_handler");
+		zxdh_bar_irq_recv(MSG_CHAN_END_VF, MSG_CHAN_END_PF, virt_addr, dev);
+	} else {
+		PMD_INIT_LOG(DEBUG, "zxdh_pf2vf_intr_handler");
+		zxdh_bar_irq_recv(MSG_CHAN_END_PF, MSG_CHAN_END_VF, virt_addr, dev);
+	}
+}
+
+static void zxdh_intr_cb_reg(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
+		rte_intr_callback_unregister(dev->intr_handle, zxdh_devconf_intr_handler, dev);
+
+	/* register callback to update dev config intr */
+	rte_intr_callback_register(dev->intr_handle, zxdh_devconf_intr_handler, dev);
+	/* Register rsic_v to pf interrupt callback */
+	struct rte_intr_handle *tmp = hw->risc_intr +
+			(MSIX_FROM_PFVF - ZXDH_MSIX_INTR_MSG_VEC_BASE);
+
+	rte_intr_callback_register(tmp, zxdh_frompfvf_intr_handler, dev);
+
+	tmp = hw->risc_intr + (MSIX_FROM_RISCV - ZXDH_MSIX_INTR_MSG_VEC_BASE);
+	rte_intr_callback_register(tmp, zxdh_fromriscv_intr_handler, dev);
+}
+
+static void zxdh_intr_cb_unreg(struct rte_eth_dev *dev)
+{
+	if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
+		rte_intr_callback_unregister(dev->intr_handle, zxdh_devconf_intr_handler, dev);
+
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	/* register callback to update dev config intr */
+	rte_intr_callback_unregister(dev->intr_handle, zxdh_devconf_intr_handler, dev);
+	/* Register rsic_v to pf interrupt callback */
+	struct rte_intr_handle *tmp = hw->risc_intr +
+			(MSIX_FROM_PFVF - ZXDH_MSIX_INTR_MSG_VEC_BASE);
+
+	rte_intr_callback_unregister(tmp, zxdh_frompfvf_intr_handler, dev);
+	tmp = hw->risc_intr + (MSIX_FROM_RISCV - ZXDH_MSIX_INTR_MSG_VEC_BASE);
+	rte_intr_callback_unregister(tmp, zxdh_fromriscv_intr_handler, dev);
+}
+
+static int32_t zxdh_intr_disable(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (!hw->intr_enabled)
+		return 0;
+
+	zxdh_intr_cb_unreg(dev);
+	if (rte_intr_disable(dev->intr_handle) < 0)
+		return -1;
+
+	hw->intr_enabled = 0;
+	return 0;
+}
+
+static int32_t zxdh_intr_enable(struct rte_eth_dev *dev)
+{
+	int ret = 0;
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (!hw->intr_enabled) {
+		zxdh_intr_cb_reg(dev);
+		ret = rte_intr_enable(dev->intr_handle);
+		if (unlikely(ret))
+			PMD_INIT_LOG(ERR, "Failed to enable %s intr", dev->data->name);
+
+		hw->intr_enabled = 1;
+	}
+	return ret;
+}
+
+static int32_t zxdh_intr_release(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
+		VTPCI_OPS(hw)->set_config_irq(hw, ZXDH_MSI_NO_VECTOR);
+
+	zxdh_queues_unbind_intr(dev);
+	zxdh_intr_disable(dev);
+
+	rte_intr_efd_disable(dev->intr_handle);
+	rte_intr_vec_list_free(dev->intr_handle);
+	rte_free(hw->risc_intr);
+	hw->risc_intr = NULL;
+	rte_free(hw->dtb_intr);
+	hw->dtb_intr = NULL;
+	return 0;
+}
+
+static int32_t zxdh_setup_risc_interrupts(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+	uint8_t i;
+
+	if (!hw->risc_intr) {
+		PMD_INIT_LOG(ERR, " to allocate risc_intr");
+		hw->risc_intr = rte_zmalloc("risc_intr",
+			ZXDH_MSIX_INTR_MSG_VEC_NUM * sizeof(struct rte_intr_handle), 0);
+		if (hw->risc_intr == NULL) {
+			PMD_INIT_LOG(ERR, "Failed to allocate risc_intr");
+			return -ENOMEM;
+		}
+	}
+
+	for (i = 0; i < ZXDH_MSIX_INTR_MSG_VEC_NUM; i++) {
+		if (dev->intr_handle->efds[i] < 0) {
+			PMD_INIT_LOG(ERR, "[%u]risc interrupt fd is invalid", i);
+			rte_free(hw->risc_intr);
+			hw->risc_intr = NULL;
+			return -1;
+		}
+
+		struct rte_intr_handle *intr_handle = hw->risc_intr + i;
+
+		intr_handle->fd = dev->intr_handle->efds[i];
+		intr_handle->type = dev->intr_handle->type;
+	}
+
+	return 0;
+}
+
+static int32_t zxdh_setup_dtb_interrupts(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (!hw->dtb_intr) {
+		hw->dtb_intr = rte_zmalloc("dtb_intr", sizeof(struct rte_intr_handle), 0);
+		if (hw->dtb_intr == NULL) {
+			PMD_INIT_LOG(ERR, "Failed to allocate dtb_intr");
+			return -ENOMEM;
+		}
+	}
+
+	if (dev->intr_handle->efds[ZXDH_MSIX_INTR_DTB_VEC - 1] < 0) {
+		PMD_INIT_LOG(ERR, "[%d]dtb interrupt fd is invalid", ZXDH_MSIX_INTR_DTB_VEC - 1);
+		rte_free(hw->dtb_intr);
+		hw->dtb_intr = NULL;
+		return -1;
+	}
+	hw->dtb_intr->fd = dev->intr_handle->efds[ZXDH_MSIX_INTR_DTB_VEC - 1];
+	hw->dtb_intr->type = dev->intr_handle->type;
+	return 0;
+}
+
+static int32_t zxdh_queues_bind_intr(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+	int32_t i;
+	uint16_t vec;
+
+	if (!dev->data->dev_conf.intr_conf.rxq) {
+		for (i = 0; i < dev->data->nb_rx_queues; ++i) {
+			vec = VTPCI_OPS(hw)->set_queue_irq(hw,
+					hw->vqs[i * 2], ZXDH_MSI_NO_VECTOR);
+			PMD_INIT_LOG(DEBUG, "vq%d irq set 0x%x, get 0x%x",
+					i * 2, ZXDH_MSI_NO_VECTOR, vec);
+		}
+	} else {
+		for (i = 0; i < dev->data->nb_rx_queues; ++i) {
+			vec = VTPCI_OPS(hw)->set_queue_irq(hw,
+					hw->vqs[i * 2], i + ZXDH_QUEUE_INTR_VEC_BASE);
+			PMD_INIT_LOG(DEBUG, "vq%d irq set %d, get %d",
+					i * 2, i + ZXDH_QUEUE_INTR_VEC_BASE, vec);
+		}
+	}
+	/* mask all txq intr */
+	for (i = 0; i < dev->data->nb_tx_queues; ++i) {
+		vec = VTPCI_OPS(hw)->set_queue_irq(hw,
+				hw->vqs[(i * 2) + 1], ZXDH_MSI_NO_VECTOR);
+		PMD_INIT_LOG(DEBUG, "vq%d irq set 0x%x, get 0x%x",
+				(i * 2) + 1, ZXDH_MSI_NO_VECTOR, vec);
+	}
+	return 0;
+}
+
+static int32_t zxdh_configure_intr(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+	int32_t ret = 0;
+
+	if (!rte_intr_cap_multiple(dev->intr_handle)) {
+		PMD_INIT_LOG(ERR, "Multiple intr vector not supported");
+		return -ENOTSUP;
+	}
+	zxdh_intr_release(dev);
+	uint8_t nb_efd = ZXDH_MSIX_INTR_DTB_VEC_NUM + ZXDH_MSIX_INTR_MSG_VEC_NUM;
+
+	if (dev->data->dev_conf.intr_conf.rxq)
+		nb_efd += dev->data->nb_rx_queues;
+
+	if (rte_intr_efd_enable(dev->intr_handle, nb_efd)) {
+		PMD_INIT_LOG(ERR, "Fail to create eventfd");
+		return -1;
+	}
+
+	if (rte_intr_vec_list_alloc(dev->intr_handle, "intr_vec",
+					hw->max_queue_pairs + ZXDH_INTR_NONQUE_NUM)) {
+		PMD_INIT_LOG(ERR, "Failed to allocate %u rxq vectors",
+					hw->max_queue_pairs + ZXDH_INTR_NONQUE_NUM);
+		return -ENOMEM;
+	}
+	PMD_INIT_LOG(DEBUG, "allocate %u rxq vectors", dev->intr_handle->vec_list_size);
+	if (zxdh_setup_risc_interrupts(dev) != 0) {
+		PMD_INIT_LOG(ERR, "Error setting up rsic_v interrupts!");
+		ret = -1;
+		goto free_intr_vec;
+	}
+	if (zxdh_setup_dtb_interrupts(dev) != 0) {
+		PMD_INIT_LOG(ERR, "Error setting up dtb interrupts!");
+		ret = -1;
+		goto free_intr_vec;
+	}
+
+	if (zxdh_queues_bind_intr(dev) < 0) {
+		PMD_INIT_LOG(ERR, "Failed to bind queue/interrupt");
+		ret = -1;
+		goto free_intr_vec;
+	}
+
+	if (zxdh_intr_enable(dev) < 0) {
+		PMD_DRV_LOG(ERR, "interrupt enable failed");
+		ret = -1;
+		goto free_intr_vec;
+	}
+	return 0;
+
+free_intr_vec:
+	zxdh_intr_release(dev);
+	return ret;
+}
+
 static int32_t zxdh_init_device(struct rte_eth_dev *eth_dev)
 {
 	struct zxdh_hw *hw = eth_dev->data->dev_private;
@@ -138,9 +434,14 @@ static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 	if (ret != 0)
 		goto err_zxdh_init;
 
+	ret = zxdh_configure_intr(eth_dev);
+	if (ret != 0)
+		goto err_zxdh_init;
+
 	return ret;
 
 err_zxdh_init:
+	zxdh_intr_release(eth_dev);
 	zxdh_bar_msg_chan_exit();
 	rte_free(eth_dev->data->mac_addrs);
 	eth_dev->data->mac_addrs = NULL;
drivers/net/zxdh/zxdh_ethdev.h +8 -0
index 2351393009..7c5f5940cb 100644
@@ -11,6 +11,10 @@ extern "C" {
 
 #include <rte_ether.h>
 #include "ethdev_driver.h"
+#include <rte_interrupts.h>
+#include <eal_interrupts.h>
+
+#include "zxdh_queue.h"
 
 /* ZXDH PCI vendor/device ID. */
 #define PCI_VENDOR_ID_ZTE        0x1cf2
@@ -44,6 +48,9 @@ struct zxdh_hw {
 	struct rte_eth_dev *eth_dev;
 	struct zxdh_pci_common_cfg *common_cfg;
 	struct zxdh_net_config *dev_cfg;
+	struct rte_intr_handle *risc_intr;
+	struct rte_intr_handle *dtb_intr;
+	struct virtqueue **vqs;
 	union VPORT vport;
 
 	uint64_t bar_addr[ZXDH_NUM_BARS];
@@ -60,6 +67,7 @@ struct zxdh_hw {
 
 	uint8_t *isr;
 	uint8_t weak_barriers;
+	uint8_t intr_enabled;
 	uint8_t use_msix;
 	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
 	uint8_t duplex;
drivers/net/zxdh/zxdh_msg.c +187 -0

202 lines not on this page · raw message

drivers/net/zxdh/zxdh_msg.h +12 -0
index 7379f57d17..6c7bed86f1 100644
@@ -16,8 +16,16 @@ extern "C" {
 #define ZXDH_BAR0_INDEX          0
 
 #define ZXDH_CTRLCH_OFFSET          (0x2000)
+#define ZXDH_MSG_CHAN_PFVFSHARE_OFFSET  (ZXDH_CTRLCH_OFFSET + 0x1000)
 #define ZXDH_MSIX_INTR_MSG_VEC_BASE  1
 
+#define ZXDH_MSIX_INTR_MSG_VEC_NUM  3
+#define ZXDH_MSIX_INTR_DTB_VEC      (ZXDH_MSIX_INTR_MSG_VEC_BASE + ZXDH_MSIX_INTR_MSG_VEC_NUM)
+#define ZXDH_MSIX_INTR_DTB_VEC_NUM  1
+#define ZXDH_INTR_NONQUE_NUM        (ZXDH_MSIX_INTR_MSG_VEC_NUM + ZXDH_MSIX_INTR_DTB_VEC_NUM + 1)
+#define ZXDH_QUEUE_INTR_VEC_BASE    (ZXDH_MSIX_INTR_DTB_VEC + ZXDH_MSIX_INTR_DTB_VEC_NUM) /* 5 */
+#define ZXDH_QUEUE_INTR_VEC_NUM     256
+
 #define BAR_MSG_POLLING_SPAN     100
 #define BAR_MSG_POLL_CNT_PER_MS  (1 * 1000 / BAR_MSG_POLLING_SPAN)
 #define BAR_MSG_POLL_CNT_PER_S   (1 * 1000 * 1000 / BAR_MSG_POLLING_SPAN)
@@ -201,6 +209,9 @@ struct bar_msg_header {
 	uint16_t dst_pcieid; /* used in PF-->VF */
 };
 
+typedef int (*zxdh_bar_chan_msg_recv_callback)(void *pay_load, uint16_t len,
+					void *reps_buffer, uint16_t *reps_len, void *dev);
+
 int zxdh_msg_chan_init(void);
 int zxdh_bar_msg_chan_exit(void);
 int zxdh_msg_chan_hwlock_init(struct rte_eth_dev *dev);
@@ -208,6 +219,7 @@ int zxdh_msg_chan_hwlock_init(struct rte_eth_dev *dev);
 int zxdh_msg_chan_enable(struct rte_eth_dev *dev);
 int zxdh_bar_chan_sync_msg_send(struct zxdh_pci_bar_msg *in,
 			struct zxdh_msg_recviver_mem *result);
+int zxdh_bar_irq_recv(uint8_t src, uint8_t dst, uint64_t virt_addr, void *dev);
 
 #ifdef __cplusplus
 }
drivers/net/zxdh/zxdh_pci.c +62 -0

79 lines not on this page · raw message

drivers/net/zxdh/zxdh_pci.h +12 -0
index deda73a65a..677dadd5c8 100644
@@ -22,6 +22,13 @@ enum zxdh_msix_status {
 	ZXDH_MSIX_ENABLED  = 2
 };
 
+/* The bit of the ISR which indicates a device has an interrupt. */
+#define ZXDH_PCI_ISR_INTR    0x1
+/* The bit of the ISR which indicates a device configuration change. */
+#define ZXDH_PCI_ISR_CONFIG  0x2
+/* Vector value used to disable MSI for queue. */
+#define ZXDH_MSI_NO_VECTOR   0x7F
+
 #define PCI_CAPABILITY_LIST          0x34
 #define PCI_CAP_ID_VNDR              0x09
 #define PCI_CAP_ID_MSIX              0x11
@@ -124,6 +131,9 @@ struct zxdh_pci_ops {
 
 	uint64_t (*get_features)(struct zxdh_hw *hw);
 	void     (*set_features)(struct zxdh_hw *hw, uint64_t features);
+	uint16_t (*set_queue_irq)(struct zxdh_hw *hw, struct virtqueue *vq, uint16_t vec);
+	uint16_t (*set_config_irq)(struct zxdh_hw *hw, uint16_t vec);
+	uint8_t  (*get_isr)(struct zxdh_hw *hw);
 };
 
 struct zxdh_hw_internal {
@@ -143,6 +153,8 @@ int32_t zxdh_read_pci_caps(struct rte_pci_device *dev, struct zxdh_hw *hw);
 int32_t zxdh_get_pci_dev_config(struct zxdh_hw *hw);
 
 uint16_t zxdh_vtpci_get_features(struct zxdh_hw *hw);
+uint8_t zxdh_vtpci_isr(struct zxdh_hw *hw);
+enum zxdh_msix_status zxdh_vtpci_msix_detect(struct rte_pci_device *dev);
 
 #ifdef __cplusplus
 }
Signature · 1 line
2.27.0
#28 lore raw

PATCH v6 8/9 net/zxdh: add zxdh dev infos get ops

In reply to Junlong Wang

Add support for zxdh infos get.

---
 drivers/net/zxdh/zxdh_ethdev.c | 62 +++++++++++++++++++++++++++++++++-
 1 file changed, 61 insertions(+), 1 deletion(-)
drivers/net/zxdh/zxdh_ethdev.c +61 -1
index fc141712aa..65b649a156 100644
@@ -12,6 +12,9 @@
 #include "zxdh_msg.h"
 #include "zxdh_common.h"
 
+#define ZXDH_MIN_RX_BUFSIZE     64
+#define ZXDH_MAX_RX_PKTLEN      14000U
+
 struct zxdh_hw_internal zxdh_hw_internal[RTE_MAX_ETHPORTS];
 
 uint16_t vport_to_vfid(union VPORT v)
@@ -25,6 +28,58 @@ uint16_t vport_to_vfid(union VPORT v)
 		return (v.epid * 8 + v.pfid) + 1152;
 }
 
+static uint32_t zxdh_dev_speed_capa_get(uint32_t speed)
+{
+	switch (speed) {
+	case RTE_ETH_SPEED_NUM_10G:  return RTE_ETH_LINK_SPEED_10G;
+	case RTE_ETH_SPEED_NUM_20G:  return RTE_ETH_LINK_SPEED_20G;
+	case RTE_ETH_SPEED_NUM_25G:  return RTE_ETH_LINK_SPEED_25G;
+	case RTE_ETH_SPEED_NUM_40G:  return RTE_ETH_LINK_SPEED_40G;
+	case RTE_ETH_SPEED_NUM_50G:  return RTE_ETH_LINK_SPEED_50G;
+	case RTE_ETH_SPEED_NUM_56G:  return RTE_ETH_LINK_SPEED_56G;
+	case RTE_ETH_SPEED_NUM_100G: return RTE_ETH_LINK_SPEED_100G;
+	case RTE_ETH_SPEED_NUM_200G: return RTE_ETH_LINK_SPEED_200G;
+	default:                     return 0;
+	}
+}
+
+static int32_t zxdh_dev_infos_get(struct rte_eth_dev *dev,
+					struct rte_eth_dev_info *dev_info)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	dev_info->speed_capa       = zxdh_dev_speed_capa_get(hw->speed);
+	dev_info->max_rx_queues    = RTE_MIN(hw->max_queue_pairs, ZXDH_RX_QUEUES_MAX);
+	dev_info->max_tx_queues    = RTE_MIN(hw->max_queue_pairs, ZXDH_TX_QUEUES_MAX);
+	dev_info->min_rx_bufsize   = ZXDH_MIN_RX_BUFSIZE;
+	dev_info->max_rx_pktlen    = ZXDH_MAX_RX_PKTLEN;
+	dev_info->max_mac_addrs    = ZXDH_MAX_MAC_ADDRS;
+	dev_info->rx_offload_capa  = (RTE_ETH_RX_OFFLOAD_VLAN_STRIP |
+					RTE_ETH_RX_OFFLOAD_VLAN_FILTER |
+					RTE_ETH_RX_OFFLOAD_QINQ_STRIP);
+	dev_info->rx_offload_capa |= (RTE_ETH_RX_OFFLOAD_IPV4_CKSUM |
+					RTE_ETH_RX_OFFLOAD_UDP_CKSUM |
+					RTE_ETH_RX_OFFLOAD_TCP_CKSUM |
+					RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM);
+	dev_info->rx_offload_capa |= (RTE_ETH_RX_OFFLOAD_SCATTER);
+	dev_info->rx_offload_capa |=  RTE_ETH_RX_OFFLOAD_TCP_LRO;
+	dev_info->rx_offload_capa |=  RTE_ETH_RX_OFFLOAD_RSS_HASH;
+
+	dev_info->tx_offload_capa = (RTE_ETH_TX_OFFLOAD_MULTI_SEGS);
+	dev_info->tx_offload_capa |= (RTE_ETH_TX_OFFLOAD_TCP_TSO |
+					RTE_ETH_TX_OFFLOAD_UDP_TSO);
+	dev_info->tx_offload_capa |= (RTE_ETH_TX_OFFLOAD_VLAN_INSERT |
+					RTE_ETH_TX_OFFLOAD_QINQ_INSERT |
+					RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO);
+	dev_info->tx_offload_capa |= (RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
+					RTE_ETH_TX_OFFLOAD_UDP_CKSUM |
+					RTE_ETH_TX_OFFLOAD_TCP_CKSUM |
+					RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM |
+					RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM);
+
+	return 0;
+}
+
 static void zxdh_queues_unbind_intr(struct rte_eth_dev *dev)
 {
 	struct zxdh_hw *hw = dev->data->dev_private;
@@ -321,6 +376,11 @@ static int32_t zxdh_configure_intr(struct rte_eth_dev *dev)
 	return ret;
 }
 
+/* dev_ops for zxdh, bare necessities for basic operation */
+static const struct eth_dev_ops zxdh_eth_dev_ops = {
+	.dev_infos_get			 = zxdh_dev_infos_get,
+};
+
 static int32_t zxdh_init_device(struct rte_eth_dev *eth_dev)
 {
 	struct zxdh_hw *hw = eth_dev->data->dev_private;
@@ -377,7 +437,7 @@ static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 	struct zxdh_hw *hw = eth_dev->data->dev_private;
 	int ret = 0;
 
-	eth_dev->dev_ops = NULL;
+	eth_dev->dev_ops = &zxdh_eth_dev_ops;
 
 	/* Allocate memory for storing MAC addresses */
 	eth_dev->data->mac_addrs = rte_zmalloc("zxdh_mac",
Signature · 1 line
2.27.0
#29 lore raw

Re: [PATCH v6 8/9] net/zxdh: add zxdh dev infos get ops

16/10/2024 10:18, Junlong Wang:

Quoted 4 lines
drivers/net/zxdh/zxdh_ethdev.c +4 -0
+static uint32_t zxdh_dev_speed_capa_get(uint32_t speed)
+{
+	switch (speed) {
+	case RTE_ETH_SPEED_NUM_10G:  return RTE_ETH_LINK_SPEED_10G;

drivers/net/zxdh/zxdh_ethdev.c uint16_t vport_to_vfid(union VPORT v) · line 44

Quoted 10 lines
drivers/net/zxdh/zxdh_ethdev.c +10 -0
+	case RTE_ETH_SPEED_NUM_20G:  return RTE_ETH_LINK_SPEED_20G;
+	case RTE_ETH_SPEED_NUM_25G:  return RTE_ETH_LINK_SPEED_25G;
+	case RTE_ETH_SPEED_NUM_40G:  return RTE_ETH_LINK_SPEED_40G;
+	case RTE_ETH_SPEED_NUM_50G:  return RTE_ETH_LINK_SPEED_50G;
+	case RTE_ETH_SPEED_NUM_56G:  return RTE_ETH_LINK_SPEED_56G;
+	case RTE_ETH_SPEED_NUM_100G: return RTE_ETH_LINK_SPEED_100G;
+	case RTE_ETH_SPEED_NUM_200G: return RTE_ETH_LINK_SPEED_200G;
+	default:                     return 0;
+	}
+}

You could use rte_eth_speed_bitflag() instead.

#30 lore raw

PATCH v6 9/9 net/zxdh: add zxdh dev configure ops

In reply to Junlong Wang

provided zxdh dev configure ops for queue
check,reset,alloc resources,etc.

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_common.c | 119 +++++++++
 drivers/net/zxdh/zxdh_common.h |  12 +
 drivers/net/zxdh/zxdh_ethdev.c | 457 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev.h |  20 +-
 drivers/net/zxdh/zxdh_pci.c    |  97 +++++++
 drivers/net/zxdh/zxdh_pci.h    |  31 +++
 drivers/net/zxdh/zxdh_queue.c  | 131 ++++++++++
 drivers/net/zxdh/zxdh_queue.h  | 176 +++++++++++++
 drivers/net/zxdh/zxdh_rxtx.h   |   4 +
 10 files changed, 1045 insertions(+), 3 deletions(-)
 create mode 100644 drivers/net/zxdh/zxdh_queue.c
drivers/net/zxdh/meson.build +1 -0
index a16db47f89..b96aa5a27e 100644
@@ -18,4 +18,5 @@ sources = files(
         'zxdh_pci.c',
         'zxdh_msg.c',
         'zxdh_common.c',
+        'zxdh_queue.c',
 )
drivers/net/zxdh/zxdh_common.c +119 -0

128 lines not on this page · raw message

drivers/net/zxdh/zxdh_common.h +12 -0
index ec7011e820..24bbc7fee0 100644
@@ -14,6 +14,10 @@ extern "C" {
 
 #include "zxdh_ethdev.h"
 
+#define ZXDH_VF_LOCK_REG                  0x90
+#define ZXDH_VF_LOCK_ENABLE_MASK          0x1
+#define ZXDH_ACQUIRE_CHANNEL_NUM_MAX      10
+
 struct zxdh_res_para {
 	uint64_t virt_addr;
 	uint16_t pcie_id;
@@ -23,6 +27,14 @@ struct zxdh_res_para {
 int32_t zxdh_phyport_get(struct rte_eth_dev *dev, uint8_t *phyport);
 int32_t zxdh_pannelid_get(struct rte_eth_dev *dev, uint8_t *pannelid);
 
+uint32_t zxdh_read_bar_reg(struct rte_eth_dev *dev, uint32_t bar, uint32_t reg);
+void zxdh_write_bar_reg(struct rte_eth_dev *dev, uint32_t bar, uint32_t reg, uint32_t val);
+int32_t zxdh_release_lock(struct zxdh_hw *hw);
+int32_t zxdh_acquire_lock(struct zxdh_hw *hw);
+uint32_t zxdh_read_comm_reg(uint64_t pci_comm_cfg_baseaddr, uint32_t reg);
+void zxdh_write_comm_reg(uint64_t pci_comm_cfg_baseaddr, uint32_t reg, uint32_t val);
+int32_t zxdh_datach_set(struct rte_eth_dev *dev);
+
 #ifdef __cplusplus
 }
 #endif
drivers/net/zxdh/zxdh_ethdev.c +457 -0

471 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev.h +17 -3
index 7c5f5940cb..d547785e2a 100644
@@ -14,10 +14,8 @@ extern "C" {
 #include <rte_interrupts.h>
 #include <eal_interrupts.h>
 
-#include "zxdh_queue.h"
-
 /* ZXDH PCI vendor/device ID. */
-#define PCI_VENDOR_ID_ZTE        0x1cf2
+#define PCI_VENDOR_ID_ZTE         0x1cf2
 
 #define ZXDH_E310_PF_DEVICEID     0x8061
 #define ZXDH_E310_VF_DEVICEID     0x8062
@@ -30,9 +28,16 @@ extern "C" {
 
 #define ZXDH_RX_QUEUES_MAX  128U
 #define ZXDH_TX_QUEUES_MAX  128U
+#define ZXDH_QUEUE_DEPTH    1024
+#define ZXDH_QUEUES_BASE       0
+#define ZXDH_TOTAL_QUEUES_NUM  4096
+#define ZXDH_QUEUES_NUM_MAX    256
+#define ZXDH_QUERES_SHARE_BASE      (0x5000)
 
 #define ZXDH_NUM_BARS    2
 
+#define ZXDH_MBUF_BURST_SZ  64
+
 union VPORT {
 	uint16_t vport;
 	struct {
@@ -44,6 +49,11 @@ union VPORT {
 	};
 };
 
+struct chnl_context {
+	uint16_t valid;
+	uint16_t ph_chno;
+};
+
 struct zxdh_hw {
 	struct rte_eth_dev *eth_dev;
 	struct zxdh_pci_common_cfg *common_cfg;
@@ -51,6 +61,7 @@ struct zxdh_hw {
 	struct rte_intr_handle *risc_intr;
 	struct rte_intr_handle *dtb_intr;
 	struct virtqueue **vqs;
+	struct chnl_context channel_context[ZXDH_QUEUES_NUM_MAX];
 	union VPORT vport;
 
 	uint64_t bar_addr[ZXDH_NUM_BARS];
@@ -64,6 +75,7 @@ struct zxdh_hw {
 	uint16_t device_id;
 	uint16_t port_id;
 	uint16_t vfid;
+	uint16_t queue_num;
 
 	uint8_t *isr;
 	uint8_t weak_barriers;
@@ -75,6 +87,8 @@ struct zxdh_hw {
 	uint8_t phyport;
 	uint8_t panel_id;
 	uint8_t msg_chan_init;
+	uint8_t has_tx_offload;
+	uint8_t has_rx_offload;
 };
 
 uint16_t vport_to_vfid(union VPORT v);
drivers/net/zxdh/zxdh_pci.c +97 -0

115 lines not on this page · raw message

drivers/net/zxdh/zxdh_pci.h +31 -0
index 677dadd5c8..bb6714ecc0 100644
@@ -12,7 +12,9 @@ extern "C" {
 #include <stdint.h>
 #include <stdbool.h>
 
+#include <rte_pci.h>
 #include <bus_pci_driver.h>
+#include <ethdev_driver.h>
 
 #include "zxdh_ethdev.h"
 
@@ -34,8 +36,21 @@ enum zxdh_msix_status {
 #define PCI_CAP_ID_MSIX              0x11
 
 #define PCI_MSIX_ENABLE              0x8000
+#define ZXDH_PCI_VRING_ALIGN         4096
+
+#define ZXDH_NET_F_CSUM              0   /* Host handles pkts w/ partial csum */
+#define ZXDH_NET_F_GUEST_CSUM        1   /* Guest handles pkts w/ partial csum */
+#define ZXDH_NET_F_MTU               3   /* Initial MTU advice. */
 
 #define ZXDH_NET_F_MAC               5   /* Host has given MAC address. */
+#define ZXDH_NET_F_GUEST_TSO4        7   /* Guest can handle TSOv4 in. */
+#define ZXDH_NET_F_GUEST_TSO6        8   /* Guest can handle TSOv6 in. */
+#define ZXDH_NET_F_GUEST_ECN         9   /* Guest can handle TSO[6] w/ ECN in. */
+#define ZXDH_NET_F_GUEST_UFO         10  /* Guest can handle UFO in. */
+
+#define ZXDH_NET_F_HOST_UFO          14  /* Host can handle UFO in. */
+#define ZXDH_NET_F_HOST_TSO4         11  /* Host can handle TSOv4 in. */
+#define ZXDH_NET_F_HOST_TSO6         12  /* Host can handle TSOv6 in. */
 #define ZXDH_NET_F_MRG_RXBUF         15  /* Host can merge receive buffers. */
 #define ZXDH_NET_F_STATUS            16  /* zxdh_net_config.status available */
 #define ZXDH_NET_F_MQ                22  /* Device supports Receive Flow Steering */
@@ -60,6 +75,8 @@ enum zxdh_msix_status {
 #define ZXDH_CONFIG_STATUS_DEV_NEED_RESET  0x40
 #define ZXDH_CONFIG_STATUS_FAILED          0x80
 
+#define ZXDH_PCI_QUEUE_ADDR_SHIFT          12
+
 struct zxdh_net_config {
 	/* The config defining mac address (if ZXDH_NET_F_MAC) */
 	uint8_t    mac[RTE_ETHER_ADDR_LEN];
@@ -122,6 +139,12 @@ static inline int32_t vtpci_with_feature(struct zxdh_hw *hw, uint64_t bit)
 	return (hw->guest_features & (1ULL << bit)) != 0;
 }
 
+static inline int32_t vtpci_packed_queue(struct zxdh_hw *hw)
+{
+	return vtpci_with_feature(hw, ZXDH_F_RING_PACKED);
+}
+
+
 struct zxdh_pci_ops {
 	void     (*read_dev_cfg)(struct zxdh_hw *hw, size_t offset, void *dst, int32_t len);
 	void     (*write_dev_cfg)(struct zxdh_hw *hw, size_t offset, const void *src, int32_t len);
@@ -134,6 +157,11 @@ struct zxdh_pci_ops {
 	uint16_t (*set_queue_irq)(struct zxdh_hw *hw, struct virtqueue *vq, uint16_t vec);
 	uint16_t (*set_config_irq)(struct zxdh_hw *hw, uint16_t vec);
 	uint8_t  (*get_isr)(struct zxdh_hw *hw);
+	uint16_t (*get_queue_num)(struct zxdh_hw *hw, uint16_t queue_id);
+	void     (*set_queue_num)(struct zxdh_hw *hw, uint16_t queue_id, uint16_t vq_size);
+
+	int32_t  (*setup_queue)(struct zxdh_hw *hw, struct virtqueue *vq);
+	void     (*del_queue)(struct zxdh_hw *hw, struct virtqueue *vq);
 };
 
 struct zxdh_hw_internal {
@@ -156,6 +184,9 @@ uint16_t zxdh_vtpci_get_features(struct zxdh_hw *hw);
 uint8_t zxdh_vtpci_isr(struct zxdh_hw *hw);
 enum zxdh_msix_status zxdh_vtpci_msix_detect(struct rte_pci_device *dev);
 
+void zxdh_vtpci_reinit_complete(struct zxdh_hw *hw);
+void zxdh_vtpci_set_status(struct zxdh_hw *hw, uint8_t status);
+
 #ifdef __cplusplus
 }
 #endif
drivers/net/zxdh/zxdh_queue.c new file +131 -0

131 lines not on this page · raw message

drivers/net/zxdh/zxdh_queue.h +176 -0

192 lines not on this page · raw message

drivers/net/zxdh/zxdh_rxtx.h +4 -0
index 7314f76d2c..6476bc15e2 100644
@@ -48,4 +48,8 @@ struct virtnet_tx {
 	const struct rte_memzone *mz;                 /* mem zone to populate TX ring. */
 };
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif  /* _ZXDH_RXTX_H_ */
Signature · 1 line
2.27.0
#31 lore raw

Re: [v6,9/9] net/zxdh: add zxdh dev configure ops

Hi, Maintainer

iol-unit-amd64-testing/ Debian 12 | FAIL
DPDK:fast-tests / bitops_autotest FAIL 1.72 s (exit status 255 or signal 127 SIGinvalid)

Do we need to solve this error? We haven't found the detailed reason for the error in the output log. I noticed that the patches submitted by others also have this error.

Thanks.

#32 lore raw

Re: [v6,9/9] net/zxdh: add zxdh dev configure ops

Hello Junlong,

Quoted 7 lines · Junlong Wang

Hi, Maintainer

iol-unit-amd64-testing/ Debian 12 | FAIL
DPDK:fast-tests / bitops_autotest FAIL 1.72 s (exit status 255 or signal 127 SIGinvalid)

Do we need to solve this error? We haven't found the detailed reason for the error in the output log. I noticed that the patches submitted by others also have this error.

It was a false positive when testing your series (on top of next-net repo at the time) and you can ignore this failure.

This is fixed in the main repo with: 899cffe059b8 ("test/bitops: fix 32-bit atomic test spurious failure").
next-net was rebased recently and contains the fix.

Signature · 1 line
David Marchand
#33 lore raw

Re: [v6,9/9] net/zxdh: add zxdh dev configure ops

In reply to Junlong Wang

Hi, Maintainer

Hope you can take some time to check if there are any modifications needed for the net/zxdh driver.

Thank you very much!

#34 lore raw

Re: [PATCH v6 1/9] net/zxdh: add zxdh ethdev pmd driver

In reply to Junlong Wang

16/10/2024 10:16, Junlong Wang:

Quoted 4 lines

Add basic zxdh ethdev init and register PCI probe functions Update doc files

Quoted 9 lines
---
 doc/guides/nics/features/zxdh.ini |  9 +++
 doc/guides/nics/index.rst         |  1 +
 doc/guides/nics/zxdh.rst          | 30 ++++++++++
 drivers/net/meson.build           |  1 +
 drivers/net/zxdh/meson.build      | 18 ++++++
 drivers/net/zxdh/zxdh_ethdev.c    | 92 +++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev.h    | 44 +++++++++++++++
 7 files changed, 195 insertions(+)

Release notes are missing.

[...]

doc/guides/nics/zxdh.rst line 1

Quoted 3 lines

+++ b/doc/guides/nics/zxdh.rst

doc/guides/nics/zxdh.rst new file +1 -0
@@ -0,0 +1,30 @@
+..  SPDX-License-Identifier: BSD-3-Clause

A single space is enough here.

doc/guides/nics/zxdh.rst line 11

Quoted 10 lines
doc/guides/nics/zxdh.rst new file +10 -0
+    Copyright(c) 2024 ZTE Corporation.
+
+ZXDH Poll Mode Driver
+======================
+
+The ZXDH PMD (**librte_net_zxdh**) provides poll mode driver support
+for 25/100 Gbps ZXDH NX Series Ethernet Controller based on
+the ZTE Ethernet Controller E310/E312.
+
+- Learning about ZXDH NX Series Ethernet Controller NICs using

Active form is better: "Learn about"

doc/guides/nics/zxdh.rst line 17

Quoted 6 lines
doc/guides/nics/zxdh.rst new file +6 -0
+  `<https://enterprise.zte.com.cn/sup-detail.html?id=271&suptype=1>`_.
+
+Features
+--------
+
+Features of the zxdh PMD are:

Do you name your driver uppercase or lowercase?
Try to be consistent.

doc/guides/nics/zxdh.rst line 30

Quoted 13 lines
doc/guides/nics/zxdh.rst new file +13 -0
+
+- Multi arch support: x86_64, ARMv8.
+
+
+Driver compilation and testing
+------------------------------
+
+Refer to the document :ref:`compiling and testing a PMD for a NIC <pmd_build_and_test>`
+for details.
+
+Limitations or Known issues
+---------------------------
+X86-32, Power8, ARMv7 and BSD are not supported yet.

Keep an empty line after a title.
What about RISC-V and Windows?

[...]

drivers/net/zxdh/zxdh_ethdev.h line 6

Quoted 8 lines

+++ b/drivers/net/zxdh/zxdh_ethdev.h

drivers/net/zxdh/zxdh_ethdev.h new file +6 -0
@@ -0,0 +1,44 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 ZTE Corporation
+ */
+
+#ifndef _ZXDH_ETHDEV_H_
+#define _ZXDH_ETHDEV_H_

No need for the underscores at the beggining and end:
ZXDH_ETHDEV_H

drivers/net/zxdh/zxdh_ethdev.h line 12

Quoted 6 lines
drivers/net/zxdh/zxdh_ethdev.h new file +6 -0
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "ethdev_driver.h"

The includes should be before extern "C"

#35 lore raw

v7 cover net/zxdh: introduce net zxdh driver

In reply to Junlong Wang

v7:
- add release notes and modify zxdh.rst issues.
- avoid use pthread and use rte_spinlock_lock.
- using the prefix ZXDH_ before some definitions.
- resole issues according to thomas's comments.

v6:
- Resolve ci/intel compilation issues.
- fix meson.build indentation in earlier patch.

V5:
- split driver into multiple patches,part of the zxdh driver, later provide dev start/stop,queue_setup,npsdk_init,mac,vlan,rss ,etc.
- fix errors reported by scripts.
- move the product link in zxdh.rst.
- fix meson check use RTE_ARCH_X86_64/RTE_ARCH_ARM64.
- modify other comments according to Ferruh's comments.

Junlong Wang (9):
net/zxdh: add zxdh ethdev pmd driver net/zxdh: add logging implementation net/zxdh: add zxdh device pci init implementation net/zxdh: add msg chan and msg hwlock init net/zxdh: add msg chan enable implementation net/zxdh: add zxdh get device backend infos net/zxdh: add configure zxdh intr implementation net/zxdh: add zxdh dev infos get ops net/zxdh: add zxdh dev configure ops

 doc/guides/nics/features/zxdh.ini      |    9 +
 doc/guides/nics/index.rst              |    1 +
 doc/guides/nics/zxdh.rst               |   31 +
 doc/guides/rel_notes/release_24_11.rst |    4 +
 drivers/net/meson.build                |    1 +
 drivers/net/zxdh/meson.build           |   22 +
 drivers/net/zxdh/zxdh_common.c         |  367 +++++++++
 drivers/net/zxdh/zxdh_common.h         |   42 +
 drivers/net/zxdh/zxdh_ethdev.c         | 1006 ++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev.h         |  100 +++
 drivers/net/zxdh/zxdh_logs.h           |   40 +
 drivers/net/zxdh/zxdh_msg.c            |  982 +++++++++++++++++++++++
 drivers/net/zxdh/zxdh_msg.h            |  228 ++++++
 drivers/net/zxdh/zxdh_pci.c            |  449 +++++++++++
 drivers/net/zxdh/zxdh_pci.h            |  192 +++++
 drivers/net/zxdh/zxdh_queue.c          |  131 +++
 drivers/net/zxdh/zxdh_queue.h          |  282 +++++++
 drivers/net/zxdh/zxdh_rxtx.h           |   55 ++
 18 files changed, 3942 insertions(+)
 create mode 100644 doc/guides/nics/features/zxdh.ini
 create mode 100644 doc/guides/nics/zxdh.rst
 create mode 100644 drivers/net/zxdh/meson.build
 create mode 100644 drivers/net/zxdh/zxdh_common.c
 create mode 100644 drivers/net/zxdh/zxdh_common.h
 create mode 100644 drivers/net/zxdh/zxdh_ethdev.c
 create mode 100644 drivers/net/zxdh/zxdh_ethdev.h
 create mode 100644 drivers/net/zxdh/zxdh_logs.h
 create mode 100644 drivers/net/zxdh/zxdh_msg.c
 create mode 100644 drivers/net/zxdh/zxdh_msg.h
 create mode 100644 drivers/net/zxdh/zxdh_pci.c
 create mode 100644 drivers/net/zxdh/zxdh_pci.h
 create mode 100644 drivers/net/zxdh/zxdh_queue.c
 create mode 100644 drivers/net/zxdh/zxdh_queue.h
 create mode 100644 drivers/net/zxdh/zxdh_rxtx.h
Signature · 1 line
2.27.0
#36 lore raw

PATCH v7 1/9 net/zxdh: add zxdh ethdev pmd driver

Add basic zxdh ethdev init and register PCI probe functions Update doc files.

---
 doc/guides/nics/features/zxdh.ini      |  9 +++
 doc/guides/nics/index.rst              |  1 +
 doc/guides/nics/zxdh.rst               | 31 +++++++++
 doc/guides/rel_notes/release_24_11.rst |  4 ++
 drivers/net/meson.build                |  1 +
 drivers/net/zxdh/meson.build           | 18 +++++
 drivers/net/zxdh/zxdh_ethdev.c         | 92 ++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev.h         | 44 ++++++++++++
 8 files changed, 200 insertions(+)
 create mode 100644 doc/guides/nics/features/zxdh.ini
 create mode 100644 doc/guides/nics/zxdh.rst
 create mode 100644 drivers/net/zxdh/meson.build
 create mode 100644 drivers/net/zxdh/zxdh_ethdev.c
 create mode 100644 drivers/net/zxdh/zxdh_ethdev.h
doc/guides/nics/features/zxdh.ini new file +9 -0
new file mode 100644
index 0000000000..05c8091ed7
@@ -0,0 +1,9 @@
+;
+; Supported features of the 'zxdh' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Linux                = Y
+x86-64               = Y
+ARMv8                = Y
doc/guides/nics/index.rst +1 -0
index c14bc7988a..8e371ac4a5 100644
@@ -69,3 +69,4 @@ Network Interface Controller Drivers
     vhost
     virtio
     vmxnet3
+    zxdh
doc/guides/nics/zxdh.rst new file +31 -0
new file mode 100644
index 0000000000..920ff5175e
@@ -0,0 +1,31 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright(c) 2024 ZTE Corporation.
+
+ZXDH Poll Mode Driver
+======================
+
+The ZXDH PMD (**librte_net_zxdh**) provides poll mode driver support
+for 25/100 Gbps ZXDH NX Series Ethernet Controller based on
+the ZTE Ethernet Controller E310/E312.
+
+- Learn about ZXDH NX Series Ethernet Controller NICs using
+  `<https://enterprise.zte.com.cn/sup-detail.html?id=271&suptype=1>`_.
+
+Features
+--------
+
+Features of the ZXDH PMD are:
+
+- Multi arch support: x86_64, ARMv8.
+
+
+Driver compilation and testing
+------------------------------
+
+Refer to the document :ref:`compiling and testing a PMD for a NIC <pmd_build_and_test>`
+for details.
+
+Limitations or Known issues
+---------------------------
+
+X86-32, Power8, ARMv7, RISC-V, Windows and BSD are not supported yet.
doc/guides/rel_notes/release_24_11.rst +4 -0
index fa4822d928..d1edcfebee 100644
@@ -161,6 +161,10 @@ New Features
   * Added initialization of FPGA modules related to flow HW offload.
   * Added basic handling of the virtual queues.
 
+* **Updated ZTE zxdh net driver.**
+
+  * Added ethdev driver support for zxdh NX Series Ethernet Controller.
+
 * **Added cryptodev queue pair reset support.**
 
   A new API ``rte_cryptodev_queue_pair_reset`` is added
drivers/net/meson.build +1 -0
index fb6d34b782..0a12914534 100644
@@ -62,6 +62,7 @@ drivers = [
         'vhost',
         'virtio',
         'vmxnet3',
+        'zxdh',
 ]
 std_deps = ['ethdev', 'kvargs'] # 'ethdev' also pulls in mbuf, net, eal etc
 std_deps += ['bus_pci']         # very many PMDs depend on PCI, so make std
drivers/net/zxdh/meson.build new file +18 -0
new file mode 100644
index 0000000000..932fb1c835
@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2024 ZTE Corporation
+
+if not is_linux
+    build = false
+    reason = 'only supported on Linux'
+    subdir_done()
+endif
+
+if not dpdk_conf.has('RTE_ARCH_X86_64') or not dpdk_conf.get('RTE_ARCH_64')
+    build = false
+    reason = 'only supported on x86_64 and aarch64'
+    subdir_done()
+endif
+
+sources = files(
+        'zxdh_ethdev.c',
+)
drivers/net/zxdh/zxdh_ethdev.c new file +92 -0

92 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev.h new file +44 -0

44 lines not on this page · raw message

Signature · 1 line
2.27.0
#37 lore raw

v8 cover net/zxdh: introduce net zxdh driver

v8:
- fix flexible arrays銆乄address-of-packed-member error.
- all structs銆乪num銆乨efine ,etc use zxdh/ZXDH_ prefixed.
- use zxdh_try/release_lock,and move loop into zxdh_timedlock, make hardware lock follow spinlock pattern.

v7:
- add release notes and modify zxdh.rst issues.
- avoid use pthread and use rte_spinlock_lock.
- using the prefix ZXDH_ before some definitions.
- resole issues according to thomas's comments.

v6:
- Resolve ci/intel compilation issues.
- fix meson.build indentation in earlier patch.

V5:
- split driver into multiple patches,part of the zxdh driver, later provide dev start/stop,queue_setup,npsdk_init,mac,vlan,rss ,etc.
- fix errors reported by scripts.
- move the product link in zxdh.rst.
- fix meson check use RTE_ARCH_X86_64/RTE_ARCH_ARM64.
- modify other comments according to Ferruh's comments.

Junlong Wang (9):
net/zxdh: add zxdh ethdev pmd driver net/zxdh: add logging implementation net/zxdh: add zxdh device pci init implementation net/zxdh: add msg chan and msg hwlock init net/zxdh: add msg chan enable implementation net/zxdh: add zxdh get device backend infos net/zxdh: add configure zxdh intr implementation net/zxdh: add zxdh dev infos get ops net/zxdh: add zxdh dev configure ops

 MAINTAINERS                            |   6 +
 doc/guides/nics/features/zxdh.ini      |   9 +
 doc/guides/nics/index.rst              |   1 +
 doc/guides/nics/zxdh.rst               |  31 +
 doc/guides/rel_notes/release_24_11.rst |   4 +
 drivers/net/meson.build                |   1 +
 drivers/net/zxdh/meson.build           |  22 +
 drivers/net/zxdh/zxdh_common.c         | 385 ++++++++++
 drivers/net/zxdh/zxdh_common.h         |  42 ++
 drivers/net/zxdh/zxdh_ethdev.c         | 994 +++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev.h         | 104 +++
 drivers/net/zxdh/zxdh_logs.h           |  40 +
 drivers/net/zxdh/zxdh_msg.c            | 985 ++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_msg.h            | 230 ++++++
 drivers/net/zxdh/zxdh_pci.c            | 445 +++++++++++
 drivers/net/zxdh/zxdh_pci.h            | 192 +++++
 drivers/net/zxdh/zxdh_queue.c          | 123 +++
 drivers/net/zxdh/zxdh_queue.h          | 282 +++++++
 drivers/net/zxdh/zxdh_rxtx.h           |  55 ++
 19 files changed, 3951 insertions(+)
 create mode 100644 doc/guides/nics/features/zxdh.ini
 create mode 100644 doc/guides/nics/zxdh.rst
 create mode 100644 drivers/net/zxdh/meson.build
 create mode 100644 drivers/net/zxdh/zxdh_common.c
 create mode 100644 drivers/net/zxdh/zxdh_common.h
 create mode 100644 drivers/net/zxdh/zxdh_ethdev.c
 create mode 100644 drivers/net/zxdh/zxdh_ethdev.h
 create mode 100644 drivers/net/zxdh/zxdh_logs.h
 create mode 100644 drivers/net/zxdh/zxdh_msg.c
 create mode 100644 drivers/net/zxdh/zxdh_msg.h
 create mode 100644 drivers/net/zxdh/zxdh_pci.c
 create mode 100644 drivers/net/zxdh/zxdh_pci.h
 create mode 100644 drivers/net/zxdh/zxdh_queue.c
 create mode 100644 drivers/net/zxdh/zxdh_queue.h
 create mode 100644 drivers/net/zxdh/zxdh_rxtx.h
Signature · 1 line
2.27.0
#38 lore raw

PATCH v8 1/9 net/zxdh: add zxdh ethdev pmd driver

Add basic zxdh ethdev init and register PCI probe functions Update doc files.

---
 MAINTAINERS                            |  6 ++
 doc/guides/nics/features/zxdh.ini      |  9 +++
 doc/guides/nics/index.rst              |  1 +
 doc/guides/nics/zxdh.rst               | 31 +++++++++
 doc/guides/rel_notes/release_24_11.rst |  4 ++
 drivers/net/meson.build                |  1 +
 drivers/net/zxdh/meson.build           | 18 +++++
 drivers/net/zxdh/zxdh_ethdev.c         | 92 ++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev.h         | 44 ++++++++++++
 9 files changed, 206 insertions(+)
 create mode 100644 doc/guides/nics/features/zxdh.ini
 create mode 100644 doc/guides/nics/zxdh.rst
 create mode 100644 drivers/net/zxdh/meson.build
 create mode 100644 drivers/net/zxdh/zxdh_ethdev.c
 create mode 100644 drivers/net/zxdh/zxdh_ethdev.h
MAINTAINERS +6 -0
index ab64230920..a998bf0fd5 100644
@@ -1043,6 +1043,12 @@ F: drivers/net/virtio/
 F: doc/guides/nics/virtio.rst
 F: doc/guides/nics/features/virtio*.ini
 
+ZTE zxdh
+M: Lijie Shan <[email protected]>
+F: drivers/net/zxdh/
+F: doc/guides/nics/zxdh.rst
+F: doc/guides/nics/features/zxdh.ini
+
 Wind River AVP
 M: Steven Webster <[email protected]>
 M: Matt Peters <[email protected]>
doc/guides/nics/features/zxdh.ini new file +9 -0
new file mode 100644
index 0000000000..05c8091ed7
@@ -0,0 +1,9 @@
+;
+; Supported features of the 'zxdh' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Linux                = Y
+x86-64               = Y
+ARMv8                = Y
doc/guides/nics/index.rst +1 -0
index c14bc7988a..8e371ac4a5 100644
@@ -69,3 +69,4 @@ Network Interface Controller Drivers
     vhost
     virtio
     vmxnet3
+    zxdh
doc/guides/nics/zxdh.rst new file +31 -0
new file mode 100644
index 0000000000..920ff5175e
@@ -0,0 +1,31 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright(c) 2024 ZTE Corporation.
+
+ZXDH Poll Mode Driver
+======================
+
+The ZXDH PMD (**librte_net_zxdh**) provides poll mode driver support
+for 25/100 Gbps ZXDH NX Series Ethernet Controller based on
+the ZTE Ethernet Controller E310/E312.
+
+- Learn about ZXDH NX Series Ethernet Controller NICs using
+  `<https://enterprise.zte.com.cn/sup-detail.html?id=271&suptype=1>`_.
+
+Features
+--------
+
+Features of the ZXDH PMD are:
+
+- Multi arch support: x86_64, ARMv8.
+
+
+Driver compilation and testing
+------------------------------
+
+Refer to the document :ref:`compiling and testing a PMD for a NIC <pmd_build_and_test>`
+for details.
+
+Limitations or Known issues
+---------------------------
+
+X86-32, Power8, ARMv7, RISC-V, Windows and BSD are not supported yet.
doc/guides/rel_notes/release_24_11.rst +4 -0
index fa4822d928..986a611e08 100644
@@ -161,6 +161,10 @@ New Features
   * Added initialization of FPGA modules related to flow HW offload.
   * Added basic handling of the virtual queues.
 
+  * **Updated ZTE zxdh net driver.**
+
+  * Added ethdev driver support for zxdh NX Series Ethernet Controller.
+
 * **Added cryptodev queue pair reset support.**
 
   A new API ``rte_cryptodev_queue_pair_reset`` is added
drivers/net/meson.build +1 -0
index fb6d34b782..0a12914534 100644
@@ -62,6 +62,7 @@ drivers = [
         'vhost',
         'virtio',
         'vmxnet3',
+        'zxdh',
 ]
 std_deps = ['ethdev', 'kvargs'] # 'ethdev' also pulls in mbuf, net, eal etc
 std_deps += ['bus_pci']         # very many PMDs depend on PCI, so make std
drivers/net/zxdh/meson.build new file +18 -0
new file mode 100644
index 0000000000..932fb1c835
@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2024 ZTE Corporation
+
+if not is_linux
+    build = false
+    reason = 'only supported on Linux'
+    subdir_done()
+endif
+
+if not dpdk_conf.has('RTE_ARCH_X86_64') or not dpdk_conf.get('RTE_ARCH_64')
+    build = false
+    reason = 'only supported on x86_64 and aarch64'
+    subdir_done()
+endif
+
+sources = files(
+        'zxdh_ethdev.c',
+)
drivers/net/zxdh/zxdh_ethdev.c new file +92 -0

92 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev.h new file +44 -0

44 lines not on this page · raw message

Signature · 1 line
2.27.0
#39 lore raw

v9 cover net/zxdh: introduce net zxdh driver

v9:
- fix 'v8 3/9' patch use PCI bus API,
and common PCI constants according to David Marchand's comments.

v8:
- fix flexible arrays、Waddress-of-packed-member error.
- all structs、enum、define ,etc use zxdh/ZXDH_ prefixed.
- use zxdh_try/release_lock,and move loop into zxdh_timedlock, make hardware lock follow spinlock pattern.

v7:
- add release notes and modify zxdh.rst issues.
- avoid use pthread and use rte_spinlock_lock.
- using the prefix ZXDH_ before some definitions.
- resole issues according to thomas's comments.

v6:
- Resolve ci/intel compilation issues.
- fix meson.build indentation in earlier patch.

V5:
- split driver into multiple patches,part of the zxdh driver, later provide dev start/stop,queue_setup,npsdk_init,mac,vlan,rss ,etc.
- fix errors reported by scripts.
- move the product link in zxdh.rst.
- fix meson check use RTE_ARCH_X86_64/RTE_ARCH_ARM64.
- modify other comments according to Ferruh's comments.

Junlong Wang (9):
net/zxdh: add zxdh ethdev pmd driver net/zxdh: add logging implementation net/zxdh: add zxdh device pci init implementation net/zxdh: add msg chan and msg hwlock init net/zxdh: add msg chan enable implementation net/zxdh: add zxdh get device backend infos net/zxdh: add configure zxdh intr implementation net/zxdh: add zxdh dev infos get ops net/zxdh: add zxdh dev configure ops

 MAINTAINERS                            |   6 +
 doc/guides/nics/features/zxdh.ini      |   9 +
 doc/guides/nics/index.rst              |   1 +
 doc/guides/nics/zxdh.rst               |  31 +
 doc/guides/rel_notes/release_24_11.rst |   4 +
 drivers/net/meson.build                |   1 +
 drivers/net/zxdh/meson.build           |  22 +
 drivers/net/zxdh/zxdh_common.c         | 385 ++++++++++
 drivers/net/zxdh/zxdh_common.h         |  42 ++
 drivers/net/zxdh/zxdh_ethdev.c         | 994 +++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev.h         | 102 +++
 drivers/net/zxdh/zxdh_logs.h           |  40 +
 drivers/net/zxdh/zxdh_msg.c            | 986 ++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_msg.h            | 229 ++++++
 drivers/net/zxdh/zxdh_pci.c            | 402 ++++++++++
 drivers/net/zxdh/zxdh_pci.h            | 175 +++++
 drivers/net/zxdh/zxdh_queue.c          | 123 +++
 drivers/net/zxdh/zxdh_queue.h          | 281 +++++++
 drivers/net/zxdh/zxdh_rxtx.h           |  55 ++
 19 files changed, 3888 insertions(+)
 create mode 100644 doc/guides/nics/features/zxdh.ini
 create mode 100644 doc/guides/nics/zxdh.rst
 create mode 100644 drivers/net/zxdh/meson.build
 create mode 100644 drivers/net/zxdh/zxdh_common.c
 create mode 100644 drivers/net/zxdh/zxdh_common.h
 create mode 100644 drivers/net/zxdh/zxdh_ethdev.c
 create mode 100644 drivers/net/zxdh/zxdh_ethdev.h
 create mode 100644 drivers/net/zxdh/zxdh_logs.h
 create mode 100644 drivers/net/zxdh/zxdh_msg.c
 create mode 100644 drivers/net/zxdh/zxdh_msg.h
 create mode 100644 drivers/net/zxdh/zxdh_pci.c
 create mode 100644 drivers/net/zxdh/zxdh_pci.h
 create mode 100644 drivers/net/zxdh/zxdh_queue.c
 create mode 100644 drivers/net/zxdh/zxdh_queue.h
 create mode 100644 drivers/net/zxdh/zxdh_rxtx.h
Signature · 1 line
2.27.0
#40 lore raw

PATCH v9 1/9 net/zxdh: add zxdh ethdev pmd driver

Add basic zxdh ethdev init and register PCI probe functions Update doc files.

---
 MAINTAINERS                            |  6 ++
 doc/guides/nics/features/zxdh.ini      |  9 +++
 doc/guides/nics/index.rst              |  1 +
 doc/guides/nics/zxdh.rst               | 31 +++++++++
 doc/guides/rel_notes/release_24_11.rst |  4 ++
 drivers/net/meson.build                |  1 +
 drivers/net/zxdh/meson.build           | 18 +++++
 drivers/net/zxdh/zxdh_ethdev.c         | 92 ++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev.h         | 44 ++++++++++++
 9 files changed, 206 insertions(+)
 create mode 100644 doc/guides/nics/features/zxdh.ini
 create mode 100644 doc/guides/nics/zxdh.rst
 create mode 100644 drivers/net/zxdh/meson.build
 create mode 100644 drivers/net/zxdh/zxdh_ethdev.c
 create mode 100644 drivers/net/zxdh/zxdh_ethdev.h
MAINTAINERS +6 -0
index 8919d78919..a5534be2ab 100644
@@ -1051,6 +1051,12 @@ F: drivers/net/virtio/
 F: doc/guides/nics/virtio.rst
 F: doc/guides/nics/features/virtio*.ini
 
+ZTE zxdh
+M: Lijie Shan <[email protected]>
+F: drivers/net/zxdh/
+F: doc/guides/nics/zxdh.rst
+F: doc/guides/nics/features/zxdh.ini
+
 Wind River AVP
 M: Steven Webster <[email protected]>
 M: Matt Peters <[email protected]>
doc/guides/nics/features/zxdh.ini new file +9 -0
new file mode 100644
index 0000000000..05c8091ed7
@@ -0,0 +1,9 @@
+;
+; Supported features of the 'zxdh' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Linux                = Y
+x86-64               = Y
+ARMv8                = Y
doc/guides/nics/index.rst +1 -0
index c14bc7988a..8e371ac4a5 100644
@@ -69,3 +69,4 @@ Network Interface Controller Drivers
     vhost
     virtio
     vmxnet3
+    zxdh
doc/guides/nics/zxdh.rst new file +31 -0
new file mode 100644
index 0000000000..920ff5175e
@@ -0,0 +1,31 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright(c) 2024 ZTE Corporation.
+
+ZXDH Poll Mode Driver
+======================
+
+The ZXDH PMD (**librte_net_zxdh**) provides poll mode driver support
+for 25/100 Gbps ZXDH NX Series Ethernet Controller based on
+the ZTE Ethernet Controller E310/E312.
+
+- Learn about ZXDH NX Series Ethernet Controller NICs using
+  `<https://enterprise.zte.com.cn/sup-detail.html?id=271&suptype=1>`_.
+
+Features
+--------
+
+Features of the ZXDH PMD are:
+
+- Multi arch support: x86_64, ARMv8.
+
+
+Driver compilation and testing
+------------------------------
+
+Refer to the document :ref:`compiling and testing a PMD for a NIC <pmd_build_and_test>`
+for details.
+
+Limitations or Known issues
+---------------------------
+
+X86-32, Power8, ARMv7, RISC-V, Windows and BSD are not supported yet.
doc/guides/rel_notes/release_24_11.rst +4 -0
index 15b64a1829..dd9048d561 100644
@@ -162,6 +162,10 @@ New Features
   * Added initialization of FPGA modules related to flow HW offload.
   * Added basic handling of the virtual queues.
 
+* **Updated ZTE zxdh net driver.**
+
+  * Added ethdev driver support for zxdh NX Series Ethernet Controller.
+
 * **Added cryptodev queue pair reset support.**
 
   A new API ``rte_cryptodev_queue_pair_reset`` is added
drivers/net/meson.build +1 -0
index fb6d34b782..0a12914534 100644
@@ -62,6 +62,7 @@ drivers = [
         'vhost',
         'virtio',
         'vmxnet3',
+        'zxdh',
 ]
 std_deps = ['ethdev', 'kvargs'] # 'ethdev' also pulls in mbuf, net, eal etc
 std_deps += ['bus_pci']         # very many PMDs depend on PCI, so make std
drivers/net/zxdh/meson.build new file +18 -0
new file mode 100644
index 0000000000..932fb1c835
@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2024 ZTE Corporation
+
+if not is_linux
+    build = false
+    reason = 'only supported on Linux'
+    subdir_done()
+endif
+
+if not dpdk_conf.has('RTE_ARCH_X86_64') or not dpdk_conf.get('RTE_ARCH_64')
+    build = false
+    reason = 'only supported on x86_64 and aarch64'
+    subdir_done()
+endif
+
+sources = files(
+        'zxdh_ethdev.c',
+)
drivers/net/zxdh/zxdh_ethdev.c new file +92 -0

92 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev.h new file +44 -0

44 lines not on this page · raw message

Signature · 1 line
2.27.0
#41 lore raw

Re: [PATCH v9 1/9] net/zxdh: add zxdh ethdev pmd driver

Quoted 30 lines · Junlong Wang

Add basic zxdh ethdev init and register PCI probe functions Update doc files.

---
 MAINTAINERS                            |  6 ++ doc/guides/nics/features/zxdh.ini      |  9 +++ doc/guides/nics/index.rst              |  1 + doc/guides/nics/zxdh.rst               | 31 +++++++++ doc/guides/rel_notes/release_24_11.rst |  4 ++ drivers/net/meson.build                |  1 + drivers/net/zxdh/meson.build           | 18 +++++ drivers/net/zxdh/zxdh_ethdev.c         | 92 ++++++++++++++++++++++++++ drivers/net/zxdh/zxdh_ethdev.h         | 44 ++++++++++++
 9 files changed, 206 insertions(+)
 create mode 100644 doc/guides/nics/features/zxdh.ini
 create mode 100644 doc/guides/nics/zxdh.rst
 create mode 100644 drivers/net/zxdh/meson.build
 create mode 100644 drivers/net/zxdh/zxdh_ethdev.c
 create mode 100644 drivers/net/zxdh/zxdh_ethdev.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 8919d78919..a5534be2ab 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1051,6 +1051,12 @@ F: drivers/net/virtio/
 F: doc/guides/nics/virtio.rst
 F: doc/guides/nics/features/virtio*.ini

MAINTAINERS F: drivers/net/virtio/ · line 1055

Quoted 2 lines
MAINTAINERS +2 -0
+ZTE zxdh
+M: Lijie Shan <[email protected]>

You have your sign-off in the patch series, but adding someone else as maintainer?
We need someone that has technical expertise on the code, is there a reason to not add your name as maintainer.

MAINTAINERS F: drivers/net/virtio/ · line 1059

Quoted 5 lines
MAINTAINERS +4 -0
+F: drivers/net/zxdh/
+F: doc/guides/nics/zxdh.rst
+F: doc/guides/nics/features/zxdh.ini
+

Minor comment, rest looks good to me:

Please move this below "Wind River", this list is alphabetically shorted on company name. Last bit of the list is virtual drivers without specific company associated with them.

<...>

Quoted 9 lines

diff --git a/drivers/net/zxdh/zxdh_ethdev.c b/drivers/net/zxdh/zxdh_ethdev.c new file mode 100644
index 0000000000..5b6c9ec1bf
--- /dev/null
+++ b/drivers/net/zxdh/zxdh_ethdev.c
@@ -0,0 +1,92 @@

drivers/net/zxdh/zxdh_ethdev.c new file +2 -0
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 ZTE Corporation

drivers/net/zxdh/zxdh_ethdev.c line 12

Quoted 10 lines
drivers/net/zxdh/zxdh_ethdev.c new file +10 -0
+ */
+
+#include <ethdev_pci.h>
+#include <bus_pci_driver.h>
+#include <rte_ethdev.h>
+
+#include "zxdh_ethdev.h"
+
+static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
+{

DPDK syntax is to have return value in a separate line, like:
static int
zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
{

This is for all files in this series, can you please update all?

#42 lore raw

v10 cover net/zxdh: introduce net zxdh driver

In reply to Junlong Wang

v10:
- move zxdh under Wind River in MAINTAINERS and add myself as the maintainer and add experimental into MAINTAINERS/driver file,elease notes.
- changed DPDK syntax is to have return value in a separate line.
- Add a keyword in log types for distinguished.
- using regular comments (non doxygen syntax).
- fix other issues.

v9:
- fix 'v8 3/9' patch use PCI bus API,
and common PCI constants according to David Marchand's comments.

v8:
- fix flexible arrays、Waddress-of-packed-member error.
- all structs、enum、define ,etc use zxdh/ZXDH_ prefixed.
- use zxdh_try/release_lock,and move loop into zxdh_timedlock, make hardware lock follow spinlock pattern.

v7:
- add release notes and modify zxdh.rst issues.
- avoid use pthread and use rte_spinlock_lock.
- using the prefix ZXDH_ before some definitions.
- resole issues according to thomas's comments.

v6:
- Resolve ci/intel compilation issues.
- fix meson.build indentation in earlier patch.

V5:
- split driver into multiple patches,part of the zxdh driver, later provide dev start/stop,queue_setup,npsdk_init,mac,vlan,rss ,etc.
- fix errors reported by scripts.
- move the product link in zxdh.rst.
- fix meson check use RTE_ARCH_X86_64/RTE_ARCH_ARM64.
- modify other comments according to Ferruh's comments.

Junlong Wang (10):
net/zxdh: add zxdh ethdev pmd driver net/zxdh: add logging implementation net/zxdh: add zxdh device pci init implementation net/zxdh: add msg chan and msg hwlock init net/zxdh: add msg chan enable implementation net/zxdh: add zxdh get device backend infos net/zxdh: add configure zxdh intr implementation net/zxdh: add zxdh dev infos get ops net/zxdh: add zxdh dev configure ops net/zxdh: add zxdh dev close ops

 MAINTAINERS                            |    7 +
 doc/guides/nics/features/zxdh.ini      |    9 +
 doc/guides/nics/index.rst              |    1 +
 doc/guides/nics/zxdh.rst               |   33 +
 doc/guides/rel_notes/release_24_11.rst |    6 +
 drivers/net/meson.build                |    1 +
 drivers/net/zxdh/meson.build           |   22 +
 drivers/net/zxdh/zxdh_common.c         |  400 +++++++++
 drivers/net/zxdh/zxdh_common.h         |   41 +
 drivers/net/zxdh/zxdh_ethdev.c         | 1041 ++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev.h         |  102 +++
 drivers/net/zxdh/zxdh_logs.h           |   34 +
 drivers/net/zxdh/zxdh_msg.c            | 1037 +++++++++++++++++++++++
 drivers/net/zxdh/zxdh_msg.h            |  228 ++++++
 drivers/net/zxdh/zxdh_pci.c            |  420 ++++++++++
 drivers/net/zxdh/zxdh_pci.h            |  177 ++++
 drivers/net/zxdh/zxdh_queue.c          |  127 +++
 drivers/net/zxdh/zxdh_queue.h          |  285 +++++++
 drivers/net/zxdh/zxdh_rxtx.h           |   55 ++
 19 files changed, 4026 insertions(+)
 create mode 100644 doc/guides/nics/features/zxdh.ini
 create mode 100644 doc/guides/nics/zxdh.rst
 create mode 100644 drivers/net/zxdh/meson.build
 create mode 100644 drivers/net/zxdh/zxdh_common.c
 create mode 100644 drivers/net/zxdh/zxdh_common.h
 create mode 100644 drivers/net/zxdh/zxdh_ethdev.c
 create mode 100644 drivers/net/zxdh/zxdh_ethdev.h
 create mode 100644 drivers/net/zxdh/zxdh_logs.h
 create mode 100644 drivers/net/zxdh/zxdh_msg.c
 create mode 100644 drivers/net/zxdh/zxdh_msg.h
 create mode 100644 drivers/net/zxdh/zxdh_pci.c
 create mode 100644 drivers/net/zxdh/zxdh_pci.h
 create mode 100644 drivers/net/zxdh/zxdh_queue.c
 create mode 100644 drivers/net/zxdh/zxdh_queue.h
 create mode 100644 drivers/net/zxdh/zxdh_rxtx.h
Signature · 1 line
2.27.0
#43 lore raw

PATCH v10 1/10 net/zxdh: add zxdh ethdev pmd driver

Add basic zxdh ethdev init and register PCI probe functions Update doc files.

---
 MAINTAINERS                            |  7 ++
 doc/guides/nics/features/zxdh.ini      |  9 +++
 doc/guides/nics/index.rst              |  1 +
 doc/guides/nics/zxdh.rst               | 33 +++++++++
 doc/guides/rel_notes/release_24_11.rst |  6 ++
 drivers/net/meson.build                |  1 +
 drivers/net/zxdh/meson.build           | 18 +++++
 drivers/net/zxdh/zxdh_ethdev.c         | 97 ++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev.h         | 44 ++++++++++++
 9 files changed, 216 insertions(+)
 create mode 100644 doc/guides/nics/features/zxdh.ini
 create mode 100644 doc/guides/nics/zxdh.rst
 create mode 100644 drivers/net/zxdh/meson.build
 create mode 100644 drivers/net/zxdh/zxdh_ethdev.c
 create mode 100644 drivers/net/zxdh/zxdh_ethdev.h
MAINTAINERS +7 -0
index 8919d78919..9a812b3632 100644
@@ -1058,6 +1058,13 @@ F: drivers/net/avp/
 F: doc/guides/nics/avp.rst
 F: doc/guides/nics/features/avp.ini
 
+ZTE zxdh
+M: Junlong Wang <[email protected]>
+M: Lijie Shan <[email protected]>
+F: drivers/net/zxdh/
+F: doc/guides/nics/zxdh.rst
+F: doc/guides/nics/features/zxdh.ini
+
 PCAP PMD
 F: drivers/net/pcap/
 F: doc/guides/nics/pcap_ring.rst
doc/guides/nics/features/zxdh.ini new file +9 -0
new file mode 100644
index 0000000000..05c8091ed7
@@ -0,0 +1,9 @@
+;
+; Supported features of the 'zxdh' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Linux                = Y
+x86-64               = Y
+ARMv8                = Y
doc/guides/nics/index.rst +1 -0
index c14bc7988a..8e371ac4a5 100644
@@ -69,3 +69,4 @@ Network Interface Controller Drivers
     vhost
     virtio
     vmxnet3
+    zxdh
doc/guides/nics/zxdh.rst new file +33 -0
new file mode 100644
index 0000000000..1167d4c6be
@@ -0,0 +1,33 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright(c) 2024 ZTE Corporation.
+
+ZXDH Poll Mode Driver
+======================
+
+The ZXDH PMD (**librte_net_zxdh**) provides poll mode driver support
+for 25/100 Gbps ZXDH NX Series Ethernet Controller based on
+the ZTE Ethernet Controller E310/E312.
+
+- Learn about ZXDH NX Series Ethernet Controller NICs using
+  `<https://enterprise.zte.com.cn/sup-detail.html?id=271&suptype=1>`_.
+
+
+Features
+--------
+
+Features of the ZXDH PMD are:
+
+- Multi arch support: x86_64, ARMv8.
+
+
+Driver compilation and testing
+------------------------------
+
+Refer to the document :ref:`compiling and testing a PMD for a NIC <pmd_build_and_test>`
+for details.
+
+Limitations or Known issues
+---------------------------
+
+Datapath and some eth_dev_ops are not supported and will be provided later.
+X86-32, Power8, ARMv7, RISC-V, Windows and BSD are not supported yet.
doc/guides/rel_notes/release_24_11.rst +6 -0
index 517085f0b3..66b970e036 100644
@@ -170,6 +170,12 @@ New Features
   * Added asynchronous flow support
   * Added MTU update
 
+* **Updated ZTE zxdh net driver [EXPERIMENTAL].**
+
+  * Added ethdev driver support for zxdh NX Series Ethernet Controller.
+    - Ability to initialize the NIC
+    - Does not support datapath
+
 * **Added cryptodev queue pair reset support.**
 
   A new API ``rte_cryptodev_queue_pair_reset`` is added
drivers/net/meson.build +1 -0
index fb6d34b782..0a12914534 100644
@@ -62,6 +62,7 @@ drivers = [
         'vhost',
         'virtio',
         'vmxnet3',
+        'zxdh',
 ]
 std_deps = ['ethdev', 'kvargs'] # 'ethdev' also pulls in mbuf, net, eal etc
 std_deps += ['bus_pci']         # very many PMDs depend on PCI, so make std
drivers/net/zxdh/meson.build new file +18 -0
new file mode 100644
index 0000000000..932fb1c835
@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2024 ZTE Corporation
+
+if not is_linux
+    build = false
+    reason = 'only supported on Linux'
+    subdir_done()
+endif
+
+if not dpdk_conf.has('RTE_ARCH_X86_64') or not dpdk_conf.get('RTE_ARCH_64')
+    build = false
+    reason = 'only supported on x86_64 and aarch64'
+    subdir_done()
+endif
+
+sources = files(
+        'zxdh_ethdev.c',
+)
drivers/net/zxdh/zxdh_ethdev.c new file +97 -0

97 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev.h new file +44 -0

44 lines not on this page · raw message

Signature · 1 line
2.27.0
#44 lore raw

Re: [PATCH v10 00/10] net/zxdh: introduce net zxdh driver

Quoted 55 lines · Ferruh Yigit
Quoted 54 lines · Junlong Wang
Quoted 37 lines

v10:
-
move zxdh under Wind River in MAINTAINERS and add myself as the maintainer
and add experimental into MAINTAINERS/driver file,elease notes.
- changed DPDK syntax is to have return value in a separate line.
- Add a keyword in log types for distinguished.
- using regular comments (non doxygen syntax).
- fix other issues.

v9:
- fix 'v8 3/9' patch use PCI bus API,
and common PCI constants according to David Marchand's comments.

v8:
- fix flexible arrays、Waddress-of-packed-member error.
- all structs、enum、define ,etc use zxdh/ZXDH_ prefixed.
- use zxdh_try/release_lock,and move loop into zxdh_timedlock, make hardware lock follow spinlock pattern.

v7:
- add release notes and modify zxdh.rst issues.
- avoid use pthread and use rte_spinlock_lock.
- using the prefix ZXDH_ before some definitions.
- resole issues according to thomas's comments.

v6:
- Resolve ci/intel compilation issues.
- fix meson.build indentation in earlier patch.

V5:
- split driver into multiple patches,part of the zxdh driver, later provide dev start/stop,queue_setup,npsdk_init,mac,vlan,rss ,etc.
- fix errors reported by scripts.
- move the product link in zxdh.rst.
- fix meson check use RTE_ARCH_X86_64/RTE_ARCH_ARM64.
- modify other comments according to Ferruh's comments.

Quoted 12 lines

Junlong Wang (10):
net/zxdh: add zxdh ethdev pmd driver net/zxdh: add logging implementation net/zxdh: add zxdh device pci init implementation net/zxdh: add msg chan and msg hwlock init net/zxdh: add msg chan enable implementation net/zxdh: add zxdh get device backend infos net/zxdh: add configure zxdh intr implementation net/zxdh: add zxdh dev infos get ops net/zxdh: add zxdh dev configure ops net/zxdh: add zxdh dev close ops

For series,

Quoted 7 lines
Quoted 2 lines

Series applied to dpdk-next-net/main, thanks.

Hi Junlong,

It seems we missed to mark driver as experimental, I will update it in next-net.

Sorry, I'm too careless, I will pay more attention next time. Thank you very much.

#45 lore raw

Re: [PATCH v10 00/10] net/zxdh: introduce net zxdh driver

07/11/2024 11:32, Junlong Wang:

Quoted 7 lines
Quoted 6 lines · Ferruh Yigit
Quoted 5 lines

For series,

Series applied to dpdk-next-net/main, thanks.

Quoted 7 lines
Quoted 4 lines

Hi Junlong,

It seems we missed to mark driver as experimental, I will update it in next-net.

Sorry, I'm too careless, I will pay more attention next time. Thank you very much.

I'm removing the useless #ifdef __cplusplus while pulling in main, as we are trying to clean them in the repo.

#46 lore raw

cover net/zxdh: updated net zxdh driver

In reply to Junlong Wang

V1:
- updated net zxdh driver
provided insert/delete/get table code funcs. provided link/mac/vlan/promiscuous/rss/mtu ops.

Junlong Wang (15):
net/zxdh: zxdh np init implementation net/zxdh: zxdh np uninit implementation net/zxdh: port tables init implementations net/zxdh: port tables unint implementations net/zxdh: rx/tx queue setup and intr enable net/zxdh: dev start/stop ops implementations net/zxdh: provided dev simple tx implementations net/zxdh: provided dev simple rx implementations net/zxdh: link info update, set link up/down net/zxdh: mac set/add/remove ops implementations net/zxdh: promiscuous/allmulticast ops implementations net/zxdh: vlan filter, vlan offload ops implementations net/zxdh: rss hash config/update, reta update/get net/zxdh: basic stats ops implementations net/zxdh: mtu update ops implementations

 doc/guides/nics/features/zxdh.ini  |   17 +
 doc/guides/nics/zxdh.rst           |   17 +
 drivers/net/zxdh/meson.build       |    4 +
 drivers/net/zxdh/zxdh_common.c     |   24 +
 drivers/net/zxdh/zxdh_common.h     |    1 +
 drivers/net/zxdh/zxdh_ethdev.c     |  556 +++++++-
 drivers/net/zxdh/zxdh_ethdev.h     |   36 +
 drivers/net/zxdh/zxdh_ethdev_ops.c | 1500 +++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |   60 +
 drivers/net/zxdh/zxdh_msg.c        |  164 +++
 drivers/net/zxdh/zxdh_msg.h        |  231 +++
 drivers/net/zxdh/zxdh_np.c         | 2144 ++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_np.h         |  579 ++++++++
 drivers/net/zxdh/zxdh_pci.c        |   26 +-
 drivers/net/zxdh/zxdh_pci.h        |    9 +-
 drivers/net/zxdh/zxdh_queue.c      |  244 +++-
 drivers/net/zxdh/zxdh_queue.h      |  142 +-
 drivers/net/zxdh/zxdh_rxtx.c       |  802 +++++++++++
 drivers/net/zxdh/zxdh_rxtx.h       |    6 +
 drivers/net/zxdh/zxdh_tables.c     |  782 ++++++++++
 drivers/net/zxdh/zxdh_tables.h     |  231 +++
 21 files changed, 7541 insertions(+), 34 deletions(-)
 create mode 100644 drivers/net/zxdh/zxdh_ethdev_ops.c
 create mode 100644 drivers/net/zxdh/zxdh_ethdev_ops.h
 create mode 100644 drivers/net/zxdh/zxdh_np.c
 create mode 100644 drivers/net/zxdh/zxdh_np.h
 create mode 100644 drivers/net/zxdh/zxdh_rxtx.c
 create mode 100644 drivers/net/zxdh/zxdh_tables.c
 create mode 100644 drivers/net/zxdh/zxdh_tables.h
Signature · 1 line
2.27.0
#47 lore raw

PATCH 1/15 net/zxdh: zxdh np init implementation

(np)network Processor initialize resources in host, and initialize a channel for some tables insert/get/del.

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_ethdev.c | 236 ++++++++++++++++++++--
 drivers/net/zxdh/zxdh_ethdev.h |  28 +++
 drivers/net/zxdh/zxdh_msg.c    |  45 +++++
 drivers/net/zxdh/zxdh_msg.h    |  37 ++++
 drivers/net/zxdh/zxdh_np.c     | 347 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_np.h     | 198 +++++++++++++++++++
 drivers/net/zxdh/zxdh_pci.c    |   2 +-
 drivers/net/zxdh/zxdh_pci.h    |   6 +-
 drivers/net/zxdh/zxdh_queue.c  |   2 +-
 drivers/net/zxdh/zxdh_queue.h  |  14 +-
 11 files changed, 883 insertions(+), 33 deletions(-)
 create mode 100644 drivers/net/zxdh/zxdh_np.c
 create mode 100644 drivers/net/zxdh/zxdh_np.h
drivers/net/zxdh/meson.build +1 -0
index c9960f4c73..ab24a3145c 100644
@@ -19,4 +19,5 @@ sources = files(
         'zxdh_msg.c',
         'zxdh_pci.c',
         'zxdh_queue.c',
+        'zxdh_np.c',
 )
drivers/net/zxdh/zxdh_ethdev.c +215 -21

326 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev.h +28 -0
index 7658cbb461..6fdb5fb767 100644
@@ -35,6 +35,10 @@
 
 #define ZXDH_MBUF_BURST_SZ        64
 
+#define ZXDH_MAX_BASE_DTB_TABLE_COUNT   30
+#define ZXDH_DTB_TABLE_DUMP_SIZE        (32 * (16 + 16 * 1024))
+#define ZXDH_DTB_TABLE_CONF_SIZE        (32 * (16 + 16 * 1024))
+
 union zxdh_virport_num {
 	uint16_t vport;
 	struct {
@@ -89,6 +93,30 @@ struct zxdh_hw {
 	uint8_t has_rx_offload;
 };
 
+struct zxdh_dtb_shared_data {
+	int init_done;
+	char name[32];
+	uint16_t queueid;
+	uint16_t vport;
+	uint32_t vector;
+	const struct rte_memzone *dtb_table_conf_mz;
+	const struct rte_memzone *dtb_table_dump_mz;
+	const struct rte_memzone *dtb_table_bulk_dump_mz[ZXDH_MAX_BASE_DTB_TABLE_COUNT];
+	struct rte_eth_dev *bind_device;
+	uint32_t dev_refcnt;
+};
+
+/* Shared data between primary and secondary processes. */
+struct zxdh_shared_data {
+	rte_spinlock_t lock; /* Global spinlock for primary and secondary processes. */
+	int32_t init_done;       /* Whether primary has done initialization. */
+	unsigned int secondary_cnt; /* Number of secondary processes init'd. */
+
+	int32_t np_init_done;
+	uint32_t dev_refcnt;
+	struct zxdh_dtb_shared_data *dtb_data;
+};
+
 uint16_t zxdh_vport_to_vfid(union zxdh_virport_num v);
 
 #endif /* ZXDH_ETHDEV_H */
drivers/net/zxdh/zxdh_msg.c +45 -0

48 lines not on this page · raw message

drivers/net/zxdh/zxdh_msg.h +37 -0
index 530ee406b1..fbc79e8f9d 100644
@@ -131,6 +131,26 @@ enum ZXDH_TBL_MSG_TYPE {
 	ZXDH_TBL_TYPE_NON,
 };
 
+enum pciebar_layout_type {
+	ZXDH_URI_VQM      = 0,
+	ZXDH_URI_SPINLOCK = 1,
+	ZXDH_URI_FWCAP    = 2,
+	ZXDH_URI_FWSHR    = 3,
+	ZXDH_URI_DRS_SEC  = 4,
+	ZXDH_URI_RSV      = 5,
+	ZXDH_URI_CTRLCH   = 6,
+	ZXDH_URI_1588     = 7,
+	ZXDH_URI_QBV      = 8,
+	ZXDH_URI_MACPCS   = 9,
+	ZXDH_URI_RDMA     = 10,
+	ZXDH_URI_MNP      = 11,
+	ZXDH_URI_MSPM     = 12,
+	ZXDH_URI_MVQM     = 13,
+	ZXDH_URI_MDPI     = 14,
+	ZXDH_URI_NP       = 15,
+	ZXDH_URI_MAX,
+};
+
 struct zxdh_msix_para {
 	uint16_t pcie_id;
 	uint16_t vector_risc;
@@ -174,6 +194,17 @@ struct zxdh_bar_offset_reps {
 	uint32_t length;
 } __rte_packed;
 
+struct zxdh_bar_offset_params {
+	uint64_t virt_addr;  /* Bar space control space virtual address */
+	uint16_t pcie_id;
+	uint16_t type;  /* Module types corresponding to PCIBAR planning */
+};
+
+struct zxdh_bar_offset_res {
+	uint32_t bar_offset;
+	uint32_t bar_length;
+};
+
 struct zxdh_bar_recv_msg {
 	uint8_t reps_ok;
 	uint16_t reps_len;
@@ -204,9 +235,15 @@ struct zxdh_bar_msg_header {
 	uint16_t dst_pcieid; /* used in PF-->VF */
 };
 
+struct zxdh_offset_get_msg {
+	uint16_t pcie_id;
+	uint16_t type;
+};
+
 typedef int (*zxdh_bar_chan_msg_recv_callback)(void *pay_load, uint16_t len,
 		void *reps_buffer, uint16_t *reps_len, void *dev);
 
+int zxdh_get_bar_offset(struct zxdh_bar_offset_params *paras, struct zxdh_bar_offset_res *res);
 int zxdh_msg_chan_init(void);
 int zxdh_bar_msg_chan_exit(void);
 int zxdh_msg_chan_hwlock_init(struct rte_eth_dev *dev);
drivers/net/zxdh/zxdh_np.c new file +347 -0

347 lines not on this page · raw message

drivers/net/zxdh/zxdh_np.h new file +198 -0

198 lines not on this page · raw message

drivers/net/zxdh/zxdh_pci.c +1 -1
index 06d3f92b20..250e67d560 100644
@@ -159,7 +159,7 @@ zxdh_setup_queue(struct zxdh_hw *hw, struct zxdh_virtqueue *vq)
 
 	desc_addr = vq->vq_ring_mem;
 	avail_addr = desc_addr + vq->vq_nentries * sizeof(struct zxdh_vring_desc);
-	if (vtpci_packed_queue(vq->hw)) {
+	if (zxdh_pci_packed_queue(vq->hw)) {
 		used_addr = RTE_ALIGN_CEIL((avail_addr +
 				sizeof(struct zxdh_vring_packed_desc_event)),
 				ZXDH_PCI_VRING_ALIGN);
drivers/net/zxdh/zxdh_pci.h +3 -3
index ed6fd89742..d6487a574f 100644
@@ -114,15 +114,15 @@ struct zxdh_pci_common_cfg {
 };
 
 static inline int32_t
-vtpci_with_feature(struct zxdh_hw *hw, uint64_t bit)
+zxdh_pci_with_feature(struct zxdh_hw *hw, uint64_t bit)
 {
 	return (hw->guest_features & (1ULL << bit)) != 0;
 }
 
 static inline int32_t
-vtpci_packed_queue(struct zxdh_hw *hw)
+zxdh_pci_packed_queue(struct zxdh_hw *hw)
 {
-	return vtpci_with_feature(hw, ZXDH_F_RING_PACKED);
+	return zxdh_pci_with_feature(hw, ZXDH_F_RING_PACKED);
 }
 
 struct zxdh_pci_ops {
drivers/net/zxdh/zxdh_queue.c +1 -1
index 462a88b23c..b4ef90ea36 100644
@@ -13,7 +13,7 @@
 #include "zxdh_msg.h"
 
 struct rte_mbuf *
-zxdh_virtqueue_detach_unused(struct zxdh_virtqueue *vq)
+zxdh_queue_detach_unused(struct zxdh_virtqueue *vq)
 {
 	struct rte_mbuf *cookie = NULL;
 	int32_t          idx    = 0;
drivers/net/zxdh/zxdh_queue.h +7 -7
index 1088bf08fc..1304d5e4ea 100644
@@ -206,11 +206,11 @@ struct zxdh_tx_region {
 };
 
 static inline size_t
-vring_size(struct zxdh_hw *hw, uint32_t num, unsigned long align)
+zxdh_vring_size(struct zxdh_hw *hw, uint32_t num, unsigned long align)
 {
 	size_t size;
 
-	if (vtpci_packed_queue(hw)) {
+	if (zxdh_pci_packed_queue(hw)) {
 		size = num * sizeof(struct zxdh_vring_packed_desc);
 		size += sizeof(struct zxdh_vring_packed_desc_event);
 		size = RTE_ALIGN_CEIL(size, align);
@@ -226,7 +226,7 @@ vring_size(struct zxdh_hw *hw, uint32_t num, unsigned long align)
 }
 
 static inline void
-vring_init_packed(struct zxdh_vring_packed *vr, uint8_t *p,
+zxdh_vring_init_packed(struct zxdh_vring_packed *vr, uint8_t *p,
 		unsigned long align, uint32_t num)
 {
 	vr->num    = num;
@@ -238,7 +238,7 @@ vring_init_packed(struct zxdh_vring_packed *vr, uint8_t *p,
 }
 
 static inline void
-vring_desc_init_packed(struct zxdh_virtqueue *vq, int32_t n)
+zxdh_vring_desc_init_packed(struct zxdh_virtqueue *vq, int32_t n)
 {
 	int32_t i = 0;
 
@@ -251,7 +251,7 @@ vring_desc_init_packed(struct zxdh_virtqueue *vq, int32_t n)
 }
 
 static inline void
-vring_desc_init_indirect_packed(struct zxdh_vring_packed_desc *dp, int32_t n)
+zxdh_vring_desc_init_indirect_packed(struct zxdh_vring_packed_desc *dp, int32_t n)
 {
 	int32_t i = 0;
 
@@ -262,7 +262,7 @@ vring_desc_init_indirect_packed(struct zxdh_vring_packed_desc *dp, int32_t n)
 }
 
 static inline void
-virtqueue_disable_intr(struct zxdh_virtqueue *vq)
+zxdh_queue_disable_intr(struct zxdh_virtqueue *vq)
 {
 	if (vq->vq_packed.event_flags_shadow != ZXDH_RING_EVENT_FLAGS_DISABLE) {
 		vq->vq_packed.event_flags_shadow = ZXDH_RING_EVENT_FLAGS_DISABLE;
@@ -270,7 +270,7 @@ virtqueue_disable_intr(struct zxdh_virtqueue *vq)
 	}
 }
 
-struct rte_mbuf *zxdh_virtqueue_detach_unused(struct zxdh_virtqueue *vq);
+struct rte_mbuf *zxdh_queue_detach_unused(struct zxdh_virtqueue *vq);
 int32_t zxdh_free_queues(struct rte_eth_dev *dev);
 int32_t zxdh_get_queue_type(uint16_t vtpci_queue_idx);
 
Signature · 1 line
2.27.0
#48 lore raw

v2 cover net/zxdh: updated net zxdh driver

V2:
- resolve code style and github-robot build issue.

V1:
- updated net zxdh driver
provided insert/delete/get table code funcs. provided link/mac/vlan/promiscuous/rss/mtu ops.

Junlong Wang (15):
net/zxdh: zxdh np init implementation net/zxdh: zxdh np uninit implementation net/zxdh: port tables init implementations net/zxdh: port tables unint implementations net/zxdh: rx/tx queue setup and intr enable net/zxdh: dev start/stop ops implementations net/zxdh: provided dev simple tx implementations net/zxdh: provided dev simple rx implementations net/zxdh: link info update, set link up/down net/zxdh: mac set/add/remove ops implementations net/zxdh: promisc/allmulti ops implementations net/zxdh: vlan filter/ offload ops implementations net/zxdh: rss hash config/update, reta update/get net/zxdh: basic stats ops implementations net/zxdh: mtu update ops implementations

 doc/guides/nics/features/zxdh.ini  |   18 +
 doc/guides/nics/zxdh.rst           |   17 +
 drivers/net/zxdh/meson.build       |    4 +
 drivers/net/zxdh/zxdh_common.c     |   24 +
 drivers/net/zxdh/zxdh_common.h     |    1 +
 drivers/net/zxdh/zxdh_ethdev.c     |  575 +++++++-
 drivers/net/zxdh/zxdh_ethdev.h     |   37 +
 drivers/net/zxdh/zxdh_ethdev_ops.c | 1593 +++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |   80 ++
 drivers/net/zxdh/zxdh_msg.c        |  164 +++
 drivers/net/zxdh/zxdh_msg.h        |  232 +++
 drivers/net/zxdh/zxdh_np.c         | 2144 ++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_np.h         |  579 ++++++++
 drivers/net/zxdh/zxdh_pci.c        |   26 +-
 drivers/net/zxdh/zxdh_pci.h        |    9 +-
 drivers/net/zxdh/zxdh_queue.c      |  242 +++-
 drivers/net/zxdh/zxdh_queue.h      |  144 +-
 drivers/net/zxdh/zxdh_rxtx.c       |  804 +++++++++++
 drivers/net/zxdh/zxdh_rxtx.h       |    6 +
 drivers/net/zxdh/zxdh_tables.c     |  788 ++++++++++
 drivers/net/zxdh/zxdh_tables.h     |  232 +++
 21 files changed, 7682 insertions(+), 37 deletions(-)
 create mode 100644 drivers/net/zxdh/zxdh_ethdev_ops.c
 create mode 100644 drivers/net/zxdh/zxdh_ethdev_ops.h
 create mode 100644 drivers/net/zxdh/zxdh_np.c
 create mode 100644 drivers/net/zxdh/zxdh_np.h
 create mode 100644 drivers/net/zxdh/zxdh_rxtx.c
 create mode 100644 drivers/net/zxdh/zxdh_tables.c
 create mode 100644 drivers/net/zxdh/zxdh_tables.h
Signature · 1 line
2.27.0
#49 lore raw

PATCH v2 1/15 net/zxdh: zxdh np init implementation

(np)network Processor initialize resources in host, and initialize a channel for some tables insert/get/del.

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_ethdev.c | 238 ++++++++++++++++++++--
 drivers/net/zxdh/zxdh_ethdev.h |  27 +++
 drivers/net/zxdh/zxdh_msg.c    |  45 +++++
 drivers/net/zxdh/zxdh_msg.h    |  37 ++++
 drivers/net/zxdh/zxdh_np.c     | 347 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_np.h     | 198 +++++++++++++++++++
 drivers/net/zxdh/zxdh_pci.c    |   2 +-
 drivers/net/zxdh/zxdh_pci.h    |   6 +-
 drivers/net/zxdh/zxdh_queue.c  |   2 +-
 drivers/net/zxdh/zxdh_queue.h  |  14 +-
 11 files changed, 884 insertions(+), 33 deletions(-)
 create mode 100644 drivers/net/zxdh/zxdh_np.c
 create mode 100644 drivers/net/zxdh/zxdh_np.h
drivers/net/zxdh/meson.build +1 -0
index c9960f4c73..ab24a3145c 100644
@@ -19,4 +19,5 @@ sources = files(
         'zxdh_msg.c',
         'zxdh_pci.c',
         'zxdh_queue.c',
+        'zxdh_np.c',
 )
drivers/net/zxdh/zxdh_ethdev.c +217 -21

328 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev.h +27 -0
index 7658cbb461..78b1edd5a4 100644
@@ -34,6 +34,9 @@
 #define ZXDH_QUERES_SHARE_BASE    (0x5000)
 
 #define ZXDH_MBUF_BURST_SZ        64
+#define ZXDH_MAX_BASE_DTB_TABLE_COUNT   30
+#define ZXDH_DTB_TABLE_DUMP_SIZE        (32 * (16 + 16 * 1024))
+#define ZXDH_DTB_TABLE_CONF_SIZE        (32 * (16 + 16 * 1024))
 
 union zxdh_virport_num {
 	uint16_t vport;
@@ -89,6 +92,30 @@ struct zxdh_hw {
 	uint8_t has_rx_offload;
 };
 
+struct zxdh_dtb_shared_data {
+	int init_done;
+	char name[32];
+	uint16_t queueid;
+	uint16_t vport;
+	uint32_t vector;
+	const struct rte_memzone *dtb_table_conf_mz;
+	const struct rte_memzone *dtb_table_dump_mz;
+	const struct rte_memzone *dtb_table_bulk_dump_mz[ZXDH_MAX_BASE_DTB_TABLE_COUNT];
+	struct rte_eth_dev *bind_device;
+	uint32_t dev_refcnt;
+};
+
+/* Shared data between primary and secondary processes. */
+struct zxdh_shared_data {
+	rte_spinlock_t lock; /* Global spinlock for primary and secondary processes. */
+	int32_t init_done;       /* Whether primary has done initialization. */
+	unsigned int secondary_cnt; /* Number of secondary processes init'd. */
+
+	int32_t np_init_done;
+	uint32_t dev_refcnt;
+	struct zxdh_dtb_shared_data *dtb_data;
+};
+
 uint16_t zxdh_vport_to_vfid(union zxdh_virport_num v);
 
 #endif /* ZXDH_ETHDEV_H */
drivers/net/zxdh/zxdh_msg.c +45 -0

48 lines not on this page · raw message

drivers/net/zxdh/zxdh_msg.h +37 -0
index 530ee406b1..fbc79e8f9d 100644
@@ -131,6 +131,26 @@ enum ZXDH_TBL_MSG_TYPE {
 	ZXDH_TBL_TYPE_NON,
 };
 
+enum pciebar_layout_type {
+	ZXDH_URI_VQM      = 0,
+	ZXDH_URI_SPINLOCK = 1,
+	ZXDH_URI_FWCAP    = 2,
+	ZXDH_URI_FWSHR    = 3,
+	ZXDH_URI_DRS_SEC  = 4,
+	ZXDH_URI_RSV      = 5,
+	ZXDH_URI_CTRLCH   = 6,
+	ZXDH_URI_1588     = 7,
+	ZXDH_URI_QBV      = 8,
+	ZXDH_URI_MACPCS   = 9,
+	ZXDH_URI_RDMA     = 10,
+	ZXDH_URI_MNP      = 11,
+	ZXDH_URI_MSPM     = 12,
+	ZXDH_URI_MVQM     = 13,
+	ZXDH_URI_MDPI     = 14,
+	ZXDH_URI_NP       = 15,
+	ZXDH_URI_MAX,
+};
+
 struct zxdh_msix_para {
 	uint16_t pcie_id;
 	uint16_t vector_risc;
@@ -174,6 +194,17 @@ struct zxdh_bar_offset_reps {
 	uint32_t length;
 } __rte_packed;
 
+struct zxdh_bar_offset_params {
+	uint64_t virt_addr;  /* Bar space control space virtual address */
+	uint16_t pcie_id;
+	uint16_t type;  /* Module types corresponding to PCIBAR planning */
+};
+
+struct zxdh_bar_offset_res {
+	uint32_t bar_offset;
+	uint32_t bar_length;
+};
+
 struct zxdh_bar_recv_msg {
 	uint8_t reps_ok;
 	uint16_t reps_len;
@@ -204,9 +235,15 @@ struct zxdh_bar_msg_header {
 	uint16_t dst_pcieid; /* used in PF-->VF */
 };
 
+struct zxdh_offset_get_msg {
+	uint16_t pcie_id;
+	uint16_t type;
+};
+
 typedef int (*zxdh_bar_chan_msg_recv_callback)(void *pay_load, uint16_t len,
 		void *reps_buffer, uint16_t *reps_len, void *dev);
 
+int zxdh_get_bar_offset(struct zxdh_bar_offset_params *paras, struct zxdh_bar_offset_res *res);
 int zxdh_msg_chan_init(void);
 int zxdh_bar_msg_chan_exit(void);
 int zxdh_msg_chan_hwlock_init(struct rte_eth_dev *dev);
drivers/net/zxdh/zxdh_np.c new file +347 -0

347 lines not on this page · raw message

drivers/net/zxdh/zxdh_np.h new file +198 -0

198 lines not on this page · raw message

drivers/net/zxdh/zxdh_pci.c +1 -1
index 06d3f92b20..250e67d560 100644
@@ -159,7 +159,7 @@ zxdh_setup_queue(struct zxdh_hw *hw, struct zxdh_virtqueue *vq)
 
 	desc_addr = vq->vq_ring_mem;
 	avail_addr = desc_addr + vq->vq_nentries * sizeof(struct zxdh_vring_desc);
-	if (vtpci_packed_queue(vq->hw)) {
+	if (zxdh_pci_packed_queue(vq->hw)) {
 		used_addr = RTE_ALIGN_CEIL((avail_addr +
 				sizeof(struct zxdh_vring_packed_desc_event)),
 				ZXDH_PCI_VRING_ALIGN);
drivers/net/zxdh/zxdh_pci.h +3 -3
index ed6fd89742..d6487a574f 100644
@@ -114,15 +114,15 @@ struct zxdh_pci_common_cfg {
 };
 
 static inline int32_t
-vtpci_with_feature(struct zxdh_hw *hw, uint64_t bit)
+zxdh_pci_with_feature(struct zxdh_hw *hw, uint64_t bit)
 {
 	return (hw->guest_features & (1ULL << bit)) != 0;
 }
 
 static inline int32_t
-vtpci_packed_queue(struct zxdh_hw *hw)
+zxdh_pci_packed_queue(struct zxdh_hw *hw)
 {
-	return vtpci_with_feature(hw, ZXDH_F_RING_PACKED);
+	return zxdh_pci_with_feature(hw, ZXDH_F_RING_PACKED);
 }
 
 struct zxdh_pci_ops {
drivers/net/zxdh/zxdh_queue.c +1 -1
index 462a88b23c..b4ef90ea36 100644
@@ -13,7 +13,7 @@
 #include "zxdh_msg.h"
 
 struct rte_mbuf *
-zxdh_virtqueue_detach_unused(struct zxdh_virtqueue *vq)
+zxdh_queue_detach_unused(struct zxdh_virtqueue *vq)
 {
 	struct rte_mbuf *cookie = NULL;
 	int32_t          idx    = 0;
drivers/net/zxdh/zxdh_queue.h +7 -7
index 1088bf08fc..1304d5e4ea 100644
@@ -206,11 +206,11 @@ struct zxdh_tx_region {
 };
 
 static inline size_t
-vring_size(struct zxdh_hw *hw, uint32_t num, unsigned long align)
+zxdh_vring_size(struct zxdh_hw *hw, uint32_t num, unsigned long align)
 {
 	size_t size;
 
-	if (vtpci_packed_queue(hw)) {
+	if (zxdh_pci_packed_queue(hw)) {
 		size = num * sizeof(struct zxdh_vring_packed_desc);
 		size += sizeof(struct zxdh_vring_packed_desc_event);
 		size = RTE_ALIGN_CEIL(size, align);
@@ -226,7 +226,7 @@ vring_size(struct zxdh_hw *hw, uint32_t num, unsigned long align)
 }
 
 static inline void
-vring_init_packed(struct zxdh_vring_packed *vr, uint8_t *p,
+zxdh_vring_init_packed(struct zxdh_vring_packed *vr, uint8_t *p,
 		unsigned long align, uint32_t num)
 {
 	vr->num    = num;
@@ -238,7 +238,7 @@ vring_init_packed(struct zxdh_vring_packed *vr, uint8_t *p,
 }
 
 static inline void
-vring_desc_init_packed(struct zxdh_virtqueue *vq, int32_t n)
+zxdh_vring_desc_init_packed(struct zxdh_virtqueue *vq, int32_t n)
 {
 	int32_t i = 0;
 
@@ -251,7 +251,7 @@ vring_desc_init_packed(struct zxdh_virtqueue *vq, int32_t n)
 }
 
 static inline void
-vring_desc_init_indirect_packed(struct zxdh_vring_packed_desc *dp, int32_t n)
+zxdh_vring_desc_init_indirect_packed(struct zxdh_vring_packed_desc *dp, int32_t n)
 {
 	int32_t i = 0;
 
@@ -262,7 +262,7 @@ vring_desc_init_indirect_packed(struct zxdh_vring_packed_desc *dp, int32_t n)
 }
 
 static inline void
-virtqueue_disable_intr(struct zxdh_virtqueue *vq)
+zxdh_queue_disable_intr(struct zxdh_virtqueue *vq)
 {
 	if (vq->vq_packed.event_flags_shadow != ZXDH_RING_EVENT_FLAGS_DISABLE) {
 		vq->vq_packed.event_flags_shadow = ZXDH_RING_EVENT_FLAGS_DISABLE;
@@ -270,7 +270,7 @@ virtqueue_disable_intr(struct zxdh_virtqueue *vq)
 	}
 }
 
-struct rte_mbuf *zxdh_virtqueue_detach_unused(struct zxdh_virtqueue *vq);
+struct rte_mbuf *zxdh_queue_detach_unused(struct zxdh_virtqueue *vq);
 int32_t zxdh_free_queues(struct rte_eth_dev *dev);
 int32_t zxdh_get_queue_type(uint16_t vtpci_queue_idx);
 
Signature · 1 line
2.27.0
#50 lore raw

Re: [PATCH v2 01/15] net/zxdh: zxdh np init implementation

Quoted 4 lines · On Tue, 10 Dec 2024 13:53:19 +0800 Junlong Wang <[email protected]>…

(np)network Processor initialize resources in host, and initialize a channel for some tables insert/get/del.

This mostly looks good, just some small stuff.

Quoted 39 lines
---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_ethdev.c | 238 ++++++++++++++++++++--
 drivers/net/zxdh/zxdh_ethdev.h |  27 +++
 drivers/net/zxdh/zxdh_msg.c    |  45 +++++
 drivers/net/zxdh/zxdh_msg.h    |  37 ++++
 drivers/net/zxdh/zxdh_np.c     | 347 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_np.h     | 198 +++++++++++++++++++
 drivers/net/zxdh/zxdh_pci.c    |   2 +-
 drivers/net/zxdh/zxdh_pci.h    |   6 +-
 drivers/net/zxdh/zxdh_queue.c  |   2 +-
 drivers/net/zxdh/zxdh_queue.h  |  14 +-
 11 files changed, 884 insertions(+), 33 deletions(-)
 create mode 100644 drivers/net/zxdh/zxdh_np.c
 create mode 100644 drivers/net/zxdh/zxdh_np.h
drivers/net/zxdh/meson.build +1 -0
index c9960f4c73..ab24a3145c 100644
@@ -19,4 +19,5 @@ sources = files(
         'zxdh_msg.c',
         'zxdh_pci.c',
         'zxdh_queue.c',
+        'zxdh_np.c',
 )
drivers/net/zxdh/zxdh_ethdev.c +1 -0
index c786198535..c54d1f6669 100644
@@ -5,6 +5,7 @@
 #include <ethdev_pci.h>
 #include <bus_pci_driver.h>
 #include <rte_ethdev.h>
+#include <rte_malloc.h>
 
 #include "zxdh_ethdev.h"
 #include "zxdh_logs.h"

drivers/net/zxdh/zxdh_ethdev.c line 18

Quoted 6 lines
drivers/net/zxdh/zxdh_ethdev.c +1 -0
@@ -12,8 +13,15 @@
 #include "zxdh_msg.h"
 #include "zxdh_common.h"
 #include "zxdh_queue.h"
+#include "zxdh_np.h"
 
 struct zxdh_hw_internal zxdh_hw_internal[RTE_MAX_ETHPORTS];

If you want to support primary/secondary in future, variables in BSS are not shared between primary and secondary process

drivers/net/zxdh/zxdh_ethdev.c line 22

Quoted 4 lines
drivers/net/zxdh/zxdh_ethdev.c +4 -0
+struct zxdh_shared_data *zxdh_shared_data;
+const char *ZXDH_PMD_SHARED_DATA_MZ = "zxdh_pmd_shared_data";
+rte_spinlock_t zxdh_shared_data_lock = RTE_SPINLOCK_INITIALIZER;
+struct zxdh_dtb_shared_data g_dtb_data;

The shared data will be a problem if you support multiple devices. Or is this really a singleton device with only one bus and slot.

Quoted 23 lines
drivers/net/zxdh/zxdh_ethdev.c +19 -0
+
+#define ZXDH_INVALID_DTBQUE  0xFFFF
 
 uint16_t
 zxdh_vport_to_vfid(union zxdh_virport_num v)
 
+static int
+zxdh_np_dtb_res_init(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+	struct zxdh_bar_offset_params param = {0};
+	struct zxdh_bar_offset_res res = {0};
+	int ret = 0;
+
+	if (g_dtb_data.init_done) {
+		PMD_DRV_LOG(DEBUG, "DTB res already init done, dev %s no need init",
+			dev->device->name);
+		return 0;
+	}
+	g_dtb_data.queueid = ZXDH_INVALID_DTBQUE;
+	g_dtb_data.bind_device = dev;
+	g_dtb_data.dev_refcnt++;
+	g_dtb_data.init_done = 1;

drivers/net/zxdh/zxdh_ethdev.c zxdh_agent_comm(struct rte_eth_dev *eth_dev, struct zxdh_hw *hw) · line 951

Quoted 10 lines
drivers/net/zxdh/zxdh_ethdev.c +10 -0
+
+	ZXDH_DEV_INIT_CTRL_T *dpp_ctrl = rte_malloc(NULL, sizeof(*dpp_ctrl) +
+			sizeof(ZXDH_DTB_ADDR_INFO_T) * 256, 0);
+
+	if (dpp_ctrl == NULL) {
+		PMD_DRV_LOG(ERR, "dev %s annot allocate memory for dpp_ctrl", dev->device->name);
+		ret = -ENOMEM;
+		goto free_res;
+	}
+	memset(dpp_ctrl, 0, sizeof(*dpp_ctrl) + sizeof(ZXDH_DTB_ADDR_INFO_T) * 256);

You could use rte_zmalloc() and avoid having to do memset.

drivers/net/zxdh/zxdh_ethdev.c zxdh_agent_comm(struct rte_eth_dev *eth_dev, struct zxdh_hw *hw) · line 956

Quoted 5 lines
drivers/net/zxdh/zxdh_ethdev.c +5 -0
+
+	dpp_ctrl->queue_id = 0xff;
+	dpp_ctrl->vport = hw->vport.vport;
+	dpp_ctrl->vector = ZXDH_MSIX_INTR_DTB_VEC;
+	strcpy((char *)dpp_ctrl->port_name, dev->device->name);

Why the cast, port_name is already character. Should use strlcpy() incase device name is bigger than port_name.

Quoted 187 lines
drivers/net/zxdh/zxdh_ethdev.c +155 -0
+	dpp_ctrl->pcie_vir_addr = (uint32_t)hw->bar_addr[0];
+
+	param.pcie_id = hw->pcie_id;
+	param.virt_addr = hw->bar_addr[0] + ZXDH_CTRLCH_OFFSET;
+	param.type = ZXDH_URI_NP;
+
+	ret = zxdh_get_bar_offset(&param, &res);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "dev %s get npbar offset failed", dev->device->name);
+		goto free_res;
+	}
+	dpp_ctrl->np_bar_len = res.bar_length;
+	dpp_ctrl->np_bar_offset = res.bar_offset;
+
+	if (!g_dtb_data.dtb_table_conf_mz) {
+		const struct rte_memzone *conf_mz = rte_memzone_reserve_aligned("zxdh_dtb_table_conf_mz",
+				ZXDH_DTB_TABLE_CONF_SIZE, SOCKET_ID_ANY, 0, RTE_CACHE_LINE_SIZE);
+
+		if (conf_mz == NULL) {
+			PMD_DRV_LOG(ERR,
+				"dev %s annot allocate memory for dtb table conf",
+				dev->device->name);
+			ret = -ENOMEM;
+			goto free_res;
+		}
+		dpp_ctrl->down_vir_addr = conf_mz->addr_64;
+		dpp_ctrl->down_phy_addr = conf_mz->iova;
+		g_dtb_data.dtb_table_conf_mz = conf_mz;
+	}
+
+	if (!g_dtb_data.dtb_table_dump_mz) {
+		const struct rte_memzone *dump_mz = rte_memzone_reserve_aligned("zxdh_dtb_table_dump_mz",
+				ZXDH_DTB_TABLE_DUMP_SIZE, SOCKET_ID_ANY, 0, RTE_CACHE_LINE_SIZE);
+
+		if (dump_mz == NULL) {
+			PMD_DRV_LOG(ERR,
+				"dev %s Cannot allocate memory for dtb table dump",
+				dev->device->name);
+			ret = -ENOMEM;
+			goto free_res;
+		}
+		dpp_ctrl->dump_vir_addr = dump_mz->addr_64;
+		dpp_ctrl->dump_phy_addr = dump_mz->iova;
+		g_dtb_data.dtb_table_dump_mz = dump_mz;
+	}
+
+	ret = zxdh_np_host_init(0, dpp_ctrl);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "dev %s dpp host np init failed .ret %d", dev->device->name, ret);
+		goto free_res;
+	}
+
+	PMD_DRV_LOG(DEBUG, "dev %s dpp host np init ok.dtb queue %d",
+		dev->device->name, dpp_ctrl->queue_id);
+	g_dtb_data.queueid = dpp_ctrl->queue_id;
+	rte_free(dpp_ctrl);
+	return 0;
+
+free_res:
+	rte_free(dpp_ctrl);
+	return ret;
+}
+
+static int
+zxdh_init_shared_data(void)
+{
+	const struct rte_memzone *mz;
+	int ret = 0;
+
+	rte_spinlock_lock(&zxdh_shared_data_lock);
+	if (zxdh_shared_data == NULL) {
+		if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+			/* Allocate shared memory. */
+			mz = rte_memzone_reserve(ZXDH_PMD_SHARED_DATA_MZ,
+					sizeof(*zxdh_shared_data), SOCKET_ID_ANY, 0);
+			if (mz == NULL) {
+				PMD_DRV_LOG(ERR, "Cannot allocate zxdh shared data");
+				ret = -rte_errno;
+				goto error;
+			}
+			zxdh_shared_data = mz->addr;
+			memset(zxdh_shared_data, 0, sizeof(*zxdh_shared_data));
+			rte_spinlock_init(&zxdh_shared_data->lock);
+		} else { /* Lookup allocated shared memory. */
+			mz = rte_memzone_lookup(ZXDH_PMD_SHARED_DATA_MZ);
+			if (mz == NULL) {
+				PMD_DRV_LOG(ERR, "Cannot attach zxdh shared data");
+				ret = -rte_errno;
+				goto error;
+			}
+			zxdh_shared_data = mz->addr;
+		}
+	}
+
+error:
+	rte_spinlock_unlock(&zxdh_shared_data_lock);
+	return ret;
+}
+
+static int
+zxdh_init_once(void)
+{
+	int ret = 0;
+
+	if (zxdh_init_shared_data())
+		return -1;
+
+	struct zxdh_shared_data *sd = zxdh_shared_data;
+	rte_spinlock_lock(&sd->lock);
+	if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
+		if (!sd->init_done) {
+			++sd->secondary_cnt;
+			sd->init_done = true;
+		}
+		goto out;
+	}
+	/* RTE_PROC_PRIMARY */
+	if (!sd->init_done)
+		sd->init_done = true;
+	sd->dev_refcnt++;
+
+out:
+	rte_spinlock_unlock(&sd->lock);
+	return ret;
+}
+
+static int
+zxdh_np_init(struct rte_eth_dev *eth_dev)
+{
+	struct zxdh_hw *hw = eth_dev->data->dev_private;
+	int ret = 0;
+
+	if (hw->is_pf) {
+		ret = zxdh_np_dtb_res_init(eth_dev);
+		if (ret) {
+			PMD_DRV_LOG(ERR, "np dtb init failed, ret:%d ", ret);
+			return ret;
+		}
+	}
+	if (zxdh_shared_data != NULL)
+		zxdh_shared_data->np_init_done = 1;
+
+	PMD_DRV_LOG(DEBUG, "np init ok ");
+	return 0;
+}
+
+
 static int
 zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 {
@@ -950,6 +1138,10 @@ zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 		hw->is_pf = 1;
 	}
 
+	ret = zxdh_init_once();
+	if (ret != 0)
+		goto err_zxdh_init;
+
 	ret = zxdh_init_device(eth_dev);
 	if (ret < 0)
 		goto err_zxdh_init;
@@ -977,6 +1169,10 @@ zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 	if (ret != 0)
 		goto err_zxdh_init;
 
+	ret = zxdh_np_init(eth_dev);
+	if (ret)
+		goto err_zxdh_init;
+
 	ret = zxdh_configure_intr(eth_dev);
 	if (ret != 0)
 		goto err_zxdh_init;
drivers/net/zxdh/zxdh_ethdev.h +3 -0
index 7658cbb461..78b1edd5a4 100644
@@ -34,6 +34,9 @@
 #define ZXDH_QUERES_SHARE_BASE    (0x5000)
 
 #define ZXDH_MBUF_BURST_SZ        64
+#define ZXDH_MAX_BASE_DTB_TABLE_COUNT   30
+#define ZXDH_DTB_TABLE_DUMP_SIZE        (32 * (16 + 16 * 1024))
+#define ZXDH_DTB_TABLE_CONF_SIZE        (32 * (16 + 16 * 1024))
 
 union zxdh_virport_num {
 	uint16_t vport;

drivers/net/zxdh/zxdh_ethdev.h struct zxdh_hw { · line 96

Quoted 5 lines
drivers/net/zxdh/zxdh_ethdev.h +2 -0
@@ -89,6 +92,30 @@ struct zxdh_hw {
 	uint8_t has_rx_offload;
 };
 
+struct zxdh_dtb_shared_data {
+	int init_done;

You mix int and int32 when these are really booleans. Maybe use bool type

drivers/net/zxdh/zxdh_ethdev.h struct zxdh_hw { · line 97

Quoted 1 line
drivers/net/zxdh/zxdh_ethdev.h +1 -0
+	char name[32];

Better to not hardcode 32 directly. Maybe ZXDH_MAX_NAMELEN as a #define

Quoted 29 lines
drivers/net/zxdh/zxdh_ethdev.h +21 -0
+	uint16_t queueid;
+	uint16_t vport;
+	uint32_t vector;
+	const struct rte_memzone *dtb_table_conf_mz;
+	const struct rte_memzone *dtb_table_dump_mz;
+	const struct rte_memzone *dtb_table_bulk_dump_mz[ZXDH_MAX_BASE_DTB_TABLE_COUNT];
+	struct rte_eth_dev *bind_device;
+	uint32_t dev_refcnt;
+};
+
+/* Shared data between primary and secondary processes. */
+struct zxdh_shared_data {
+	rte_spinlock_t lock; /* Global spinlock for primary and secondary processes. */
+	int32_t init_done;       /* Whether primary has done initialization. */
+	unsigned int secondary_cnt; /* Number of secondary processes init'd. */
+
+	int32_t np_init_done;
+	uint32_t dev_refcnt;
+	struct zxdh_dtb_shared_data *dtb_data;
+};
+
 uint16_t zxdh_vport_to_vfid(union zxdh_virport_num v);
 
 #endif /* ZXDH_ETHDEV_H */
drivers/net/zxdh/zxdh_msg.c +0 -0
index 53cf972f86..a0a005b178 100644

drivers/net/zxdh/zxdh_msg.c zxdh_bar_irq_recv(uint8_t src, uint8_t dst, uint64_t virt_addr, void *dev) · line 1044

Quoted 10 lines
drivers/net/zxdh/zxdh_msg.c +7 -0
@@ -1035,3 +1035,48 @@ zxdh_bar_irq_recv(uint8_t src, uint8_t dst, uint64_t virt_addr, void *dev)
 	rte_free(recved_msg);
 	return ZXDH_BAR_MSG_OK;
 }
+
+int zxdh_get_bar_offset(struct zxdh_bar_offset_params *paras,
+		struct zxdh_bar_offset_res *res)
+{
+	uint16_t check_token = 0;
+	uint16_t sum_res = 0;
+	int ret = 0;

unnecessary initialization, first usage will set.

Quoted 7 lines
drivers/net/zxdh/zxdh_msg.c +7 -0
+
+	if (!paras)
+		return ZXDH_BAR_MSG_ERR_NULL;
+
+	struct zxdh_offset_get_msg send_msg = {
+		.pcie_id = paras->pcie_id,
+		.type = paras->type,

drivers/net/zxdh/zxdh_msg.c zxdh_bar_irq_recv(uint8_t src, uint8_t dst, uint64_t virt_addr, void *dev) · line 1061

Quoted 10 lines
drivers/net/zxdh/zxdh_msg.c +10 -0
+	};
+	struct zxdh_pci_bar_msg in = {0};
+
+	in.payload_addr = &send_msg;
+	in.payload_len = sizeof(send_msg);
+	in.virt_addr = paras->virt_addr;
+	in.src = ZXDH_MSG_CHAN_END_PF;
+	in.dst = ZXDH_MSG_CHAN_END_RISC;
+	in.module_id = ZXDH_BAR_MODULE_OFFSET_GET;
+	in.src_pcieid = paras->pcie_id;

Could use struct initializer here

Quoted 146 lines
drivers/net/zxdh/zxdh_msg.c +20 -0
+	struct zxdh_bar_recv_msg recv_msg = {0};
+	struct zxdh_msg_recviver_mem result = {
+		.recv_buffer = &recv_msg,
+		.buffer_len = sizeof(recv_msg),
+	};
+	ret = zxdh_bar_chan_sync_msg_send(&in, &result);
+	if (ret != ZXDH_BAR_MSG_OK)
+		return -ret;
+
+	check_token = recv_msg.offset_reps.check;
+	sum_res = zxdh_bar_get_sum((uint8_t *)&send_msg, sizeof(send_msg));
+
+	if (check_token != sum_res) {
+		PMD_MSG_LOG(ERR, "expect token: 0x%x, get token: 0x%x", sum_res, check_token);
+		return ZXDH_BAR_MSG_ERR_REPLY;
+	}
+	res->bar_offset = recv_msg.offset_reps.offset;
+	res->bar_length = recv_msg.offset_reps.length;
+	return ZXDH_BAR_MSG_OK;
+}
drivers/net/zxdh/zxdh_msg.h +37 -0
index 530ee406b1..fbc79e8f9d 100644
@@ -131,6 +131,26 @@ enum ZXDH_TBL_MSG_TYPE {
 	ZXDH_TBL_TYPE_NON,
 };
 
+enum pciebar_layout_type {
+	ZXDH_URI_VQM      = 0,
+	ZXDH_URI_SPINLOCK = 1,
+	ZXDH_URI_FWCAP    = 2,
+	ZXDH_URI_FWSHR    = 3,
+	ZXDH_URI_DRS_SEC  = 4,
+	ZXDH_URI_RSV      = 5,
+	ZXDH_URI_CTRLCH   = 6,
+	ZXDH_URI_1588     = 7,
+	ZXDH_URI_QBV      = 8,
+	ZXDH_URI_MACPCS   = 9,
+	ZXDH_URI_RDMA     = 10,
+	ZXDH_URI_MNP      = 11,
+	ZXDH_URI_MSPM     = 12,
+	ZXDH_URI_MVQM     = 13,
+	ZXDH_URI_MDPI     = 14,
+	ZXDH_URI_NP       = 15,
+	ZXDH_URI_MAX,
+};
+
 struct zxdh_msix_para {
 	uint16_t pcie_id;
 	uint16_t vector_risc;
@@ -174,6 +194,17 @@ struct zxdh_bar_offset_reps {
 	uint32_t length;
 } __rte_packed;
 
+struct zxdh_bar_offset_params {
+	uint64_t virt_addr;  /* Bar space control space virtual address */
+	uint16_t pcie_id;
+	uint16_t type;  /* Module types corresponding to PCIBAR planning */
+};
+
+struct zxdh_bar_offset_res {
+	uint32_t bar_offset;
+	uint32_t bar_length;
+};
+
 struct zxdh_bar_recv_msg {
 	uint8_t reps_ok;
 	uint16_t reps_len;
@@ -204,9 +235,15 @@ struct zxdh_bar_msg_header {
 	uint16_t dst_pcieid; /* used in PF-->VF */
 };
 
+struct zxdh_offset_get_msg {
+	uint16_t pcie_id;
+	uint16_t type;
+};
+
 typedef int (*zxdh_bar_chan_msg_recv_callback)(void *pay_load, uint16_t len,
 		void *reps_buffer, uint16_t *reps_len, void *dev);
 
+int zxdh_get_bar_offset(struct zxdh_bar_offset_params *paras, struct zxdh_bar_offset_res *res);
 int zxdh_msg_chan_init(void);
 int zxdh_bar_msg_chan_exit(void);
 int zxdh_msg_chan_hwlock_init(struct rte_eth_dev *dev);
drivers/net/zxdh/zxdh_np.c new file +55 -0
new file mode 100644
index 0000000000..9c50039fb1
@@ -0,0 +1,347 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 ZTE Corporation
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <rte_common.h>
+#include <rte_log.h>
+
+#include "zxdh_np.h"
+#include "zxdh_logs.h"
+
+static uint64_t g_np_bar_offset;
+static ZXDH_DEV_MGR_T g_dev_mgr = {0};
+static ZXDH_SDT_MGR_T g_sdt_mgr = {0};
+ZXDH_PPU_CLS_BITMAP_T g_ppu_cls_bit_map[ZXDH_DEV_CHANNEL_MAX];
+ZXDH_DTB_MGR_T *p_dpp_dtb_mgr[ZXDH_DEV_CHANNEL_MAX]   = {NULL};
+
+#define ZXDH_COMM_ASSERT(x)           assert(x)
+#define ZXDH_SDT_MGR_PTR_GET()    (&g_sdt_mgr)
+#define ZXDH_SDT_SOFT_TBL_GET(id) (g_sdt_mgr.sdt_tbl_array[id])
+
+#define ZXDH_COMM_CHECK_DEV_POINT(dev_id, point)\
+do {\
+	if (NULL == (point)) {\
+		PMD_DRV_LOG(ERR, "dev: %d ZXIC %s:%d[Error:POINT NULL] !"\
+			"FUNCTION : %s!", (dev_id), __FILE__, __LINE__, __func__);\
+		ZXDH_COMM_ASSERT(0);\
+	} \
+} while (0)
+
+#define ZXDH_COMM_CHECK_DEV_RC(dev_id, rc, becall)\
+do {\
+	if ((rc) != 0) {\
+		PMD_DRV_LOG(ERR, "dev: %d ZXIC  %s:%d !"\
+		"-- %s Call %s Fail!", (dev_id), __FILE__, __LINE__, __func__, becall);\
+		ZXDH_COMM_ASSERT(0);\
+	} \
+} while (0)
+
+#define ZXDH_COMM_CHECK_POINT_NO_ASSERT(point)\
+do {\
+	if ((point) == NULL) {\
+		PMD_DRV_LOG(ERR, "ZXIC %s:%d[Error:POINT NULL] ! FUNCTION : %s!",\
+		__FILE__, __LINE__, __func__);\
+	} \
+} while (0)
+
+#define ZXDH_COMM_CHECK_RC_NO_ASSERT(rc, becall)\
+do {\
+	if ((rc) != 0) {\
+		PMD_DRV_LOG(ERR, "ZXIC  %s:%d !-- %s Call %s"\
+		" Fail!", __FILE__, __LINE__, __func__, becall);\
+	} \

drivers/net/zxdh/zxdh_np.c line 65

Quoted 10 lines
drivers/net/zxdh/zxdh_np.c new file +10 -0
+} while (0)
+
+#define ZXDH_COMM_CHECK_RC(rc, becall)\
+do {\
+	if ((rc) != 0) {\
+		PMD_DRV_LOG(ERR, "ZXIC  %s:%d!-- %s Call %s "\
+		"Fail!", __FILE__, __LINE__, __func__, becall);\
+		ZXDH_COMM_ASSERT(0);\
+	} \
+} while (0)

Better to use RTE_ASSERT() or RTE_VERIFY() here rather than custom macros

Quoted 154 lines
drivers/net/zxdh/zxdh_np.c new file +154 -0
+
+static uint32_t
+zxdh_np_dev_init(void)
+{
+	if (g_dev_mgr.is_init) {
+		PMD_DRV_LOG(ERR, "Dev is already initialized.");
+		return 0;
+	}
+
+	g_dev_mgr.device_num = 0;
+	g_dev_mgr.is_init    = 1;
+
+	return 0;
+}
+
+static uint32_t
+zxdh_np_dev_add(uint32_t  dev_id, ZXDH_DEV_TYPE_E dev_type,
+		ZXDH_DEV_ACCESS_TYPE_E  access_type, uint64_t  pcie_addr,
+		uint64_t  riscv_addr, uint64_t  dma_vir_addr,
+		uint64_t  dma_phy_addr)
+{
+	ZXDH_DEV_CFG_T *p_dev_info = NULL;
+	ZXDH_DEV_MGR_T *p_dev_mgr  = NULL;
+
+	p_dev_mgr = &g_dev_mgr;
+	if (!p_dev_mgr->is_init) {
+		PMD_DRV_LOG(ERR, "ErrorCode[ 0x%x]: Device Manager is not init!!!",
+								 ZXDH_RC_DEV_MGR_NOT_INIT);
+		return ZXDH_RC_DEV_MGR_NOT_INIT;
+	}
+
+	if (p_dev_mgr->p_dev_array[dev_id] != NULL) {
+		/* device is already exist. */
+		PMD_DRV_LOG(ERR, "Device is added again!!!");
+		p_dev_info = p_dev_mgr->p_dev_array[dev_id];
+	} else {
+		/* device is new. */
+		p_dev_info = (ZXDH_DEV_CFG_T *)malloc(sizeof(ZXDH_DEV_CFG_T));
+		ZXDH_COMM_CHECK_DEV_POINT(dev_id, p_dev_info);
+		p_dev_mgr->p_dev_array[dev_id] = p_dev_info;
+		p_dev_mgr->device_num++;
+	}
+
+	p_dev_info->device_id   = dev_id;
+	p_dev_info->dev_type    = dev_type;
+	p_dev_info->access_type = access_type;
+	p_dev_info->pcie_addr   = pcie_addr;
+	p_dev_info->riscv_addr   = riscv_addr;
+	p_dev_info->dma_vir_addr = dma_vir_addr;
+	p_dev_info->dma_phy_addr = dma_phy_addr;
+
+	return 0;
+}
+
+static uint32_t
+zxdh_np_dev_agent_status_set(uint32_t dev_id, uint32_t agent_flag)
+{
+	ZXDH_DEV_MGR_T *p_dev_mgr = NULL;
+	ZXDH_DEV_CFG_T *p_dev_info = NULL;
+
+	p_dev_mgr = &g_dev_mgr;
+	p_dev_info = p_dev_mgr->p_dev_array[dev_id];
+
+	if (p_dev_info == NULL)
+		return ZXDH_DEV_TYPE_INVALID;
+	p_dev_info->agent_flag = agent_flag;
+
+	return 0;
+}
+
+static uint32_t
+zxdh_np_sdt_mgr_init(void)
+{
+	if (!g_sdt_mgr.is_init) {
+		g_sdt_mgr.channel_num = 0;
+		g_sdt_mgr.is_init = 1;
+		memset(g_sdt_mgr.sdt_tbl_array, 0, ZXDH_DEV_CHANNEL_MAX *
+			sizeof(ZXDH_SDT_SOFT_TABLE_T *));
+	}
+
+	return 0;
+}
+
+static uint32_t
+zxdh_np_sdt_mgr_create(uint32_t dev_id)
+{
+	ZXDH_SDT_SOFT_TABLE_T *p_sdt_tbl_temp = NULL;
+	ZXDH_SDT_MGR_T *p_sdt_mgr = NULL;
+
+	p_sdt_mgr = ZXDH_SDT_MGR_PTR_GET();
+
+	if (ZXDH_SDT_SOFT_TBL_GET(dev_id) == NULL) {
+		p_sdt_tbl_temp = malloc(sizeof(ZXDH_SDT_SOFT_TABLE_T));
+
+		p_sdt_tbl_temp->device_id = dev_id;
+		memset(p_sdt_tbl_temp->sdt_array, 0, ZXDH_DEV_SDT_ID_MAX * sizeof(ZXDH_SDT_ITEM_T));
+
+		ZXDH_SDT_SOFT_TBL_GET(dev_id) = p_sdt_tbl_temp;
+
+		p_sdt_mgr->channel_num++;
+	} else {
+		PMD_DRV_LOG(ERR, "Error: %s for dev[%d]"
+			"is called repeatedly!", __func__, dev_id);
+		return -1;
+	}
+
+	return 0;
+}
+
+static uint32_t
+zxdh_np_sdt_init(uint32_t dev_num, uint32_t *dev_id_array)
+{
+	uint32_t rc = 0;
+	uint32_t i = 0;
+
+	zxdh_np_sdt_mgr_init();
+
+	for (i = 0; i < dev_num; i++) {
+		rc = zxdh_np_sdt_mgr_create(dev_id_array[i]);
+		ZXDH_COMM_CHECK_RC(rc, "zxdh_sdt_mgr_create");
+	}
+
+	return 0;
+}
+
+static uint32_t
+zxdh_np_ppu_parse_cls_bitmap(uint32_t dev_id,
+								uint32_t bitmap)
+{
+	uint32_t cls_id = 0;
+	uint32_t mem_id = 0;
+	uint32_t cls_use = 0;
+	uint32_t instr_mem = 0;
+
+	for (cls_id = 0; cls_id < ZXDH_PPU_CLUSTER_NUM; cls_id++) {
+		cls_use = (bitmap >> cls_id) & 0x1;
+		g_ppu_cls_bit_map[dev_id].cls_use[cls_id] = cls_use;
+	}
+
+	for (mem_id = 0; mem_id < ZXDH_PPU_INSTR_MEM_NUM; mem_id++) {
+		instr_mem = (bitmap >> (mem_id * 2)) & 0x3;
+		g_ppu_cls_bit_map[dev_id].instr_mem[mem_id] = ((instr_mem > 0) ? 1 : 0);
+	}
+
+	return 0;
+}
+
+static ZXDH_DTB_MGR_T *
+zxdh_np_dtb_mgr_get(uint32_t dev_id)
+{
+	if (dev_id >= ZXDH_DEV_CHANNEL_MAX)
+		return NULL;
+	else
+		return p_dpp_dtb_mgr[dev_id];

drivers/net/zxdh/zxdh_np.c line 229

Quoted 10 lines
drivers/net/zxdh/zxdh_np.c new file +10 -0
+}
+
+static uint32_t
+zxdh_np_dtb_soft_init(uint32_t dev_id)
+{
+	ZXDH_DTB_MGR_T *p_dtb_mgr = NULL;
+
+	p_dtb_mgr = zxdh_np_dtb_mgr_get(dev_id);
+	if (p_dtb_mgr == NULL) {
+		p_dpp_dtb_mgr[dev_id] = (ZXDH_DTB_MGR_T *)malloc(sizeof(ZXDH_DTB_MGR_T));

malloc() returns void *, cast here is not needed.
Why does DTB_MGR_T come from malloc when most of other data is using rte_malloc()?

It will matter if you support multiprocess

Quoted 6 lines
drivers/net/zxdh/zxdh_np.c new file +6 -0
+		memset(p_dpp_dtb_mgr[dev_id], 0, sizeof(ZXDH_DTB_MGR_T));
+		p_dtb_mgr = zxdh_np_dtb_mgr_get(dev_id);
+		if (p_dtb_mgr == NULL)
+			return 1;
+	}
+

drivers/net/zxdh/zxdh_np.c line 245

Quoted 10 lines
drivers/net/zxdh/zxdh_np.c new file +10 -0
+	return 0;
+}
+
+static unsigned int
+zxdh_np_base_soft_init(unsigned int dev_id, ZXDH_SYS_INIT_CTRL_T *p_init_ctrl)
+{
+	unsigned int rt = 0;
+	unsigned int access_type = 0;
+	unsigned int dev_id_array[ZXDH_DEV_CHANNEL_MAX] = {0};
+	unsigned int agent_flag = 0;

Why init variable here, and set it one line later?

Quoted 54 lines
drivers/net/zxdh/zxdh_np.c new file +54 -0
+
+	rt = zxdh_np_dev_init();
+	ZXDH_COMM_CHECK_DEV_RC(dev_id, rt, "zxdh_dev_init");
+
+	if (p_init_ctrl->flags & ZXDH_INIT_FLAG_ACCESS_TYPE)
+		access_type = ZXDH_DEV_ACCESS_TYPE_RISCV;
+	else
+		access_type = ZXDH_DEV_ACCESS_TYPE_PCIE;
+
+	if (p_init_ctrl->flags & ZXDH_INIT_FLAG_AGENT_FLAG)
+		agent_flag = ZXDH_DEV_AGENT_ENABLE;
+	else
+		agent_flag = ZXDH_DEV_AGENT_DISABLE;
+
+	rt = zxdh_np_dev_add(dev_id,
+					 p_init_ctrl->device_type,
+					 access_type,
+					 p_init_ctrl->pcie_vir_baddr,
+					 p_init_ctrl->riscv_vir_baddr,
+					 p_init_ctrl->dma_vir_baddr,
+					 p_init_ctrl->dma_phy_baddr);
+	ZXDH_COMM_CHECK_DEV_RC(dev_id, rt, "zxdh_dev_add");
+
+	rt = zxdh_np_dev_agent_status_set(dev_id, agent_flag);
+	ZXDH_COMM_CHECK_DEV_RC(dev_id, rt, "zxdh_dev_agent_status_set");
+
+	dev_id_array[0] = dev_id;
+	rt = zxdh_np_sdt_init(1, dev_id_array);
+	ZXDH_COMM_CHECK_DEV_RC(dev_id, rt, "zxdh_sdt_init");
+
+	rt = zxdh_np_ppu_parse_cls_bitmap(dev_id, ZXDH_PPU_CLS_ALL_START);
+	ZXDH_COMM_CHECK_DEV_RC(dev_id, rt, "zxdh_ppu_parse_cls_bitmap");
+
+	rt = zxdh_np_dtb_soft_init(dev_id);
+	ZXDH_COMM_CHECK_DEV_RC(dev_id, rt, "zxdh_dtb_soft_init");
+
+	return 0;
+}
+
+static uint32_t
+zxdh_np_dev_vport_set(uint32_t dev_id, uint32_t vport)
+{
+	ZXDH_DEV_MGR_T *p_dev_mgr = NULL;
+	ZXDH_DEV_CFG_T *p_dev_info = NULL;
+
+	p_dev_mgr =  &g_dev_mgr;
+	p_dev_info = p_dev_mgr->p_dev_array[dev_id];
+	p_dev_info->vport = vport;
+
+	return 0;
+}
+
+static uint32_t
+zxdh_np_dev_agent_addr_set(uint32_t dev_id, uint64_t agent_addr)

drivers/net/zxdh/zxdh_np.c line 309

Quoted 10 lines
drivers/net/zxdh/zxdh_np.c new file +10 -0
+{
+	ZXDH_DEV_MGR_T *p_dev_mgr = NULL;
+	ZXDH_DEV_CFG_T *p_dev_info = NULL;
+
+	p_dev_mgr =  &g_dev_mgr;
+	p_dev_info = p_dev_mgr->p_dev_array[dev_id];
+	p_dev_info->agent_addr = agent_addr;
+
+	return 0;
+}

Always returns 0, could just be void and skip the ASSERTION later.

Quoted 353 lines
drivers/net/zxdh/zxdh_np.c new file +37 -0
+static uint64_t
+zxdh_np_addr_calc(uint64_t pcie_vir_baddr, uint32_t bar_offset)
+{
+	uint64_t np_addr = 0;
+
+	np_addr = ((pcie_vir_baddr + bar_offset) > ZXDH_PCIE_NP_MEM_SIZE)
+				? (pcie_vir_baddr + bar_offset - ZXDH_PCIE_NP_MEM_SIZE) : 0;
+	g_np_bar_offset = bar_offset;
+
+	return np_addr;
+}
+
+int
+zxdh_np_host_init(uint32_t dev_id,
+		ZXDH_DEV_INIT_CTRL_T *p_dev_init_ctrl)
+{
+	unsigned int rc = 0;
+	uint64_t agent_addr = 0;
+	ZXDH_SYS_INIT_CTRL_T sys_init_ctrl = {0};
+
+	ZXDH_COMM_CHECK_POINT_NO_ASSERT(p_dev_init_ctrl);
+
+	sys_init_ctrl.flags = (ZXDH_DEV_ACCESS_TYPE_PCIE << 0) | (ZXDH_DEV_AGENT_ENABLE << 10);
+	sys_init_ctrl.pcie_vir_baddr = zxdh_np_addr_calc(p_dev_init_ctrl->pcie_vir_addr,
+		p_dev_init_ctrl->np_bar_offset);
+	sys_init_ctrl.device_type = ZXDH_DEV_TYPE_CHIP;
+	rc = zxdh_np_base_soft_init(dev_id, &sys_init_ctrl);
+	ZXDH_COMM_CHECK_RC_NO_ASSERT(rc, "zxdh_base_soft_init");
+
+	rc = zxdh_np_dev_vport_set(dev_id, p_dev_init_ctrl->vport);
+	ZXDH_COMM_CHECK_RC_NO_ASSERT(rc, "dpp_dev_vport_set");
+
+	agent_addr = ZXDH_PCIE_AGENT_ADDR_OFFSET + p_dev_init_ctrl->pcie_vir_addr;
+	rc = zxdh_np_dev_agent_addr_set(dev_id, agent_addr);
+	ZXDH_COMM_CHECK_RC_NO_ASSERT(rc, "dpp_dev_agent_addr_set");
+	return 0;
+}
drivers/net/zxdh/zxdh_np.h new file +198 -0
new file mode 100644
index 0000000000..573eafe796
@@ -0,0 +1,198 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 ZTE Corporation
+ */
+
+#ifndef ZXDH_NP_H
+#define ZXDH_NP_H
+
+#include <stdint.h>
+
+#define ZXDH_PORT_NAME_MAX                    (32)
+#define ZXDH_DEV_CHANNEL_MAX                  (2)
+#define ZXDH_DEV_SDT_ID_MAX                   (256U)
+/*DTB*/
+#define ZXDH_DTB_QUEUE_ITEM_NUM_MAX           (32)
+#define ZXDH_DTB_QUEUE_NUM_MAX                (128)
+
+#define ZXDH_PPU_CLS_ALL_START                (0x3F)
+#define ZXDH_PPU_CLUSTER_NUM                  (6)
+#define ZXDH_PPU_INSTR_MEM_NUM                (3)
+#define ZXDH_SDT_CFG_LEN                      (2)
+
+#define ZXDH_RC_DEV_BASE                      (0x600)
+#define ZXDH_RC_DEV_PARA_INVALID              (ZXDH_RC_DEV_BASE | 0x0)
+#define ZXDH_RC_DEV_RANGE_INVALID             (ZXDH_RC_DEV_BASE | 0x1)
+#define ZXDH_RC_DEV_CALL_FUNC_FAIL            (ZXDH_RC_DEV_BASE | 0x2)
+#define ZXDH_RC_DEV_TYPE_INVALID              (ZXDH_RC_DEV_BASE | 0x3)
+#define ZXDH_RC_DEV_CONNECT_FAIL              (ZXDH_RC_DEV_BASE | 0x4)
+#define ZXDH_RC_DEV_MSG_INVALID               (ZXDH_RC_DEV_BASE | 0x5)
+#define ZXDH_RC_DEV_NOT_EXIST                 (ZXDH_RC_DEV_BASE | 0x6)
+#define ZXDH_RC_DEV_MGR_NOT_INIT              (ZXDH_RC_DEV_BASE | 0x7)
+#define ZXDH_RC_DEV_CFG_NOT_INIT              (ZXDH_RC_DEV_BASE | 0x8)
+
+#define ZXDH_SYS_VF_NP_BASE_OFFSET      0
+#define ZXDH_PCIE_DTB4K_ADDR_OFFSET     (0x6000)
+#define ZXDH_PCIE_NP_MEM_SIZE           (0x2000000)
+#define ZXDH_PCIE_AGENT_ADDR_OFFSET     (0x2000)
+
+#define ZXDH_INIT_FLAG_ACCESS_TYPE      (1 << 0)
+#define ZXDH_INIT_FLAG_SERDES_DOWN_TP   (1 << 1)
+#define ZXDH_INIT_FLAG_DDR_BACKDOOR     (1 << 2)
+#define ZXDH_INIT_FLAG_SA_MODE          (1 << 3)
+#define ZXDH_INIT_FLAG_SA_MESH          (1 << 4)
+#define ZXDH_INIT_FLAG_SA_SERDES_MODE   (1 << 5)
+#define ZXDH_INIT_FLAG_INT_DEST_MODE    (1 << 6)
+#define ZXDH_INIT_FLAG_LIF0_MODE        (1 << 7)
+#define ZXDH_INIT_FLAG_DMA_ENABLE       (1 << 8)
+#define ZXDH_INIT_FLAG_TM_IMEM_FLAG     (1 << 9)
+#define ZXDH_INIT_FLAG_AGENT_FLAG       (1 << 10)
+
+typedef enum zxdh_module_init_e {
+	ZXDH_MODULE_INIT_NPPU = 0,
+	ZXDH_MODULE_INIT_PPU,
+	ZXDH_MODULE_INIT_SE,
+	ZXDH_MODULE_INIT_ETM,
+	ZXDH_MODULE_INIT_DLB,
+	ZXDH_MODULE_INIT_TRPG,
+	ZXDH_MODULE_INIT_TSN,
+	ZXDH_MODULE_INIT_MAX
+} ZXDH_MODULE_INIT_E;
+
+typedef enum zxdh_dev_type_e {
+	ZXDH_DEV_TYPE_SIM  = 0,
+	ZXDH_DEV_TYPE_VCS  = 1,
+	ZXDH_DEV_TYPE_CHIP = 2,
+	ZXDH_DEV_TYPE_FPGA = 3,
+	ZXDH_DEV_TYPE_PCIE_ACC = 4,
+	ZXDH_DEV_TYPE_INVALID,
+} ZXDH_DEV_TYPE_E;
+
+typedef enum zxdh_dev_access_type_e {
+	ZXDH_DEV_ACCESS_TYPE_PCIE = 0,
+	ZXDH_DEV_ACCESS_TYPE_RISCV = 1,
+	ZXDH_DEV_ACCESS_TYPE_INVALID,
+} ZXDH_DEV_ACCESS_TYPE_E;
+
+typedef enum zxdh_dev_agent_flag_e {
+	ZXDH_DEV_AGENT_DISABLE = 0,
+	ZXDH_DEV_AGENT_ENABLE = 1,
+	ZXDH_DEV_AGENT_INVALID,
+} ZXDH_DEV_AGENT_FLAG_E;
+
+typedef struct zxdh_dtb_tab_up_user_addr_t {
+	uint32_t user_flag;
+	uint64_t phy_addr;
+	uint64_t vir_addr;
+} ZXDH_DTB_TAB_UP_USER_ADDR_T;
+
+typedef struct zxdh_dtb_tab_up_info_t {
+	uint64_t start_phy_addr;
+	uint64_t start_vir_addr;
+	uint32_t item_size;
+	uint32_t wr_index;
+	uint32_t rd_index;
+	uint32_t data_len[ZXDH_DTB_QUEUE_ITEM_NUM_MAX];
+	ZXDH_DTB_TAB_UP_USER_ADDR_T user_addr[ZXDH_DTB_QUEUE_ITEM_NUM_MAX];
+} ZXDH_DTB_TAB_UP_INFO_T;
+
+typedef struct zxdh_dtb_tab_down_info_t {
+	uint64_t start_phy_addr;
+	uint64_t start_vir_addr;
+	uint32_t item_size;
+	uint32_t wr_index;
+	uint32_t rd_index;
+} ZXDH_DTB_TAB_DOWN_INFO_T;
+
+typedef struct zxdh_dtb_queue_info_t {
+	uint32_t init_flag;
+	uint32_t vport;
+	uint32_t vector;
+	ZXDH_DTB_TAB_UP_INFO_T tab_up;
+	ZXDH_DTB_TAB_DOWN_INFO_T tab_down;
+} ZXDH_DTB_QUEUE_INFO_T;
+
+typedef struct zxdh_dtb_mgr_t {
+	ZXDH_DTB_QUEUE_INFO_T queue_info[ZXDH_DTB_QUEUE_NUM_MAX];
+} ZXDH_DTB_MGR_T;
+
+typedef struct zxdh_ppu_cls_bitmap_t {
+	uint32_t cls_use[ZXDH_PPU_CLUSTER_NUM];
+	uint32_t instr_mem[ZXDH_PPU_INSTR_MEM_NUM];
+} ZXDH_PPU_CLS_BITMAP_T;
+
+typedef struct dpp_sdt_item_t {
+	uint32_t     valid;
+	uint32_t     table_cfg[ZXDH_SDT_CFG_LEN];
+} ZXDH_SDT_ITEM_T;
+
+typedef struct dpp_sdt_soft_table_t {
+	uint32_t          device_id;
+	ZXDH_SDT_ITEM_T  sdt_array[ZXDH_DEV_SDT_ID_MAX];
+} ZXDH_SDT_SOFT_TABLE_T;
+
+typedef struct zxdh_sys_init_ctrl_t {
+	ZXDH_DEV_TYPE_E device_type;
+	uint32_t flags;
+	uint32_t sa_id;
+	uint32_t case_num;
+	uint32_t lif0_port_type;
+	uint32_t lif1_port_type;
+	uint64_t pcie_vir_baddr;
+	uint64_t riscv_vir_baddr;
+	uint64_t dma_vir_baddr;
+	uint64_t dma_phy_baddr;
+} ZXDH_SYS_INIT_CTRL_T;
+
+typedef struct dpp_dev_cfg_t {
+	uint32_t device_id;
+	ZXDH_DEV_TYPE_E dev_type;
+	uint32_t chip_ver;
+	uint32_t access_type;
+	uint32_t agent_flag;
+	uint32_t vport;
+	uint64_t pcie_addr;
+	uint64_t riscv_addr;
+	uint64_t dma_vir_addr;
+	uint64_t dma_phy_addr;
+	uint64_t agent_addr;
+	uint32_t init_flags[ZXDH_MODULE_INIT_MAX];
+} ZXDH_DEV_CFG_T;
+
+typedef struct zxdh_dev_mngr_t {
+	uint32_t         device_num;
+	uint32_t         is_init;
+	ZXDH_DEV_CFG_T       *p_dev_array[ZXDH_DEV_CHANNEL_MAX];
+} ZXDH_DEV_MGR_T;
+
+typedef struct zxdh_dtb_addr_info_t {
+	uint32_t sdt_no;
+	uint32_t size;
+	uint32_t phy_addr;
+	uint32_t vir_addr;
+} ZXDH_DTB_ADDR_INFO_T;
+
+typedef struct zxdh_dev_init_ctrl_t {
+	uint32_t vport;
+	char  port_name[ZXDH_PORT_NAME_MAX];
+	uint32_t vector;
+	uint32_t queue_id;
+	uint32_t np_bar_offset;
+	uint32_t np_bar_len;
+	uint32_t pcie_vir_addr;
+	uint32_t down_phy_addr;
+	uint32_t down_vir_addr;
+	uint32_t dump_phy_addr;
+	uint32_t dump_vir_addr;
+	uint32_t dump_sdt_num;
+	ZXDH_DTB_ADDR_INFO_T dump_addr_info[];
+} ZXDH_DEV_INIT_CTRL_T;
+
+typedef struct zxdh_sdt_mgr_t {
+	uint32_t          channel_num;
+	uint32_t          is_init;
+	ZXDH_SDT_SOFT_TABLE_T *sdt_tbl_array[ZXDH_DEV_CHANNEL_MAX];
+} ZXDH_SDT_MGR_T;
+
+int zxdh_np_host_init(uint32_t dev_id, ZXDH_DEV_INIT_CTRL_T *p_dev_init_ctrl);
+
+#endif /* ZXDH_NP_H */
drivers/net/zxdh/zxdh_pci.c +1 -1
index 06d3f92b20..250e67d560 100644
@@ -159,7 +159,7 @@ zxdh_setup_queue(struct zxdh_hw *hw, struct zxdh_virtqueue *vq)
 
 	desc_addr = vq->vq_ring_mem;
 	avail_addr = desc_addr + vq->vq_nentries * sizeof(struct zxdh_vring_desc);
-	if (vtpci_packed_queue(vq->hw)) {
+	if (zxdh_pci_packed_queue(vq->hw)) {
 		used_addr = RTE_ALIGN_CEIL((avail_addr +
 				sizeof(struct zxdh_vring_packed_desc_event)),
 				ZXDH_PCI_VRING_ALIGN);
drivers/net/zxdh/zxdh_pci.h +3 -3
index ed6fd89742..d6487a574f 100644
@@ -114,15 +114,15 @@ struct zxdh_pci_common_cfg {
 };
 
 static inline int32_t
-vtpci_with_feature(struct zxdh_hw *hw, uint64_t bit)
+zxdh_pci_with_feature(struct zxdh_hw *hw, uint64_t bit)
 {
 	return (hw->guest_features & (1ULL << bit)) != 0;
 }
 
 static inline int32_t
-vtpci_packed_queue(struct zxdh_hw *hw)
+zxdh_pci_packed_queue(struct zxdh_hw *hw)
 {
-	return vtpci_with_feature(hw, ZXDH_F_RING_PACKED);
+	return zxdh_pci_with_feature(hw, ZXDH_F_RING_PACKED);
 }
 
 struct zxdh_pci_ops {
drivers/net/zxdh/zxdh_queue.c +1 -1
index 462a88b23c..b4ef90ea36 100644
@@ -13,7 +13,7 @@
 #include "zxdh_msg.h"
 
 struct rte_mbuf *
-zxdh_virtqueue_detach_unused(struct zxdh_virtqueue *vq)
+zxdh_queue_detach_unused(struct zxdh_virtqueue *vq)
 {
 	struct rte_mbuf *cookie = NULL;
 	int32_t          idx    = 0;
drivers/net/zxdh/zxdh_queue.h +7 -7
index 1088bf08fc..1304d5e4ea 100644
@@ -206,11 +206,11 @@ struct zxdh_tx_region {
 };
 
 static inline size_t
-vring_size(struct zxdh_hw *hw, uint32_t num, unsigned long align)
+zxdh_vring_size(struct zxdh_hw *hw, uint32_t num, unsigned long align)
 {
 	size_t size;
 
-	if (vtpci_packed_queue(hw)) {
+	if (zxdh_pci_packed_queue(hw)) {
 		size = num * sizeof(struct zxdh_vring_packed_desc);
 		size += sizeof(struct zxdh_vring_packed_desc_event);
 		size = RTE_ALIGN_CEIL(size, align);
@@ -226,7 +226,7 @@ vring_size(struct zxdh_hw *hw, uint32_t num, unsigned long align)
 }
 
 static inline void
-vring_init_packed(struct zxdh_vring_packed *vr, uint8_t *p,
+zxdh_vring_init_packed(struct zxdh_vring_packed *vr, uint8_t *p,
 		unsigned long align, uint32_t num)
 {
 	vr->num    = num;
@@ -238,7 +238,7 @@ vring_init_packed(struct zxdh_vring_packed *vr, uint8_t *p,
 }
 
 static inline void
-vring_desc_init_packed(struct zxdh_virtqueue *vq, int32_t n)
+zxdh_vring_desc_init_packed(struct zxdh_virtqueue *vq, int32_t n)
 {
 	int32_t i = 0;
 
@@ -251,7 +251,7 @@ vring_desc_init_packed(struct zxdh_virtqueue *vq, int32_t n)
 }
 
 static inline void
-vring_desc_init_indirect_packed(struct zxdh_vring_packed_desc *dp, int32_t n)
+zxdh_vring_desc_init_indirect_packed(struct zxdh_vring_packed_desc *dp, int32_t n)
 {
 	int32_t i = 0;
 
@@ -262,7 +262,7 @@ vring_desc_init_indirect_packed(struct zxdh_vring_packed_desc *dp, int32_t n)
 }
 
 static inline void
-virtqueue_disable_intr(struct zxdh_virtqueue *vq)
+zxdh_queue_disable_intr(struct zxdh_virtqueue *vq)
 {
 	if (vq->vq_packed.event_flags_shadow != ZXDH_RING_EVENT_FLAGS_DISABLE) {
 		vq->vq_packed.event_flags_shadow = ZXDH_RING_EVENT_FLAGS_DISABLE;
@@ -270,7 +270,7 @@ virtqueue_disable_intr(struct zxdh_virtqueue *vq)
 	}
 }
 
-struct rte_mbuf *zxdh_virtqueue_detach_unused(struct zxdh_virtqueue *vq);
+struct rte_mbuf *zxdh_queue_detach_unused(struct zxdh_virtqueue *vq);
 int32_t zxdh_free_queues(struct rte_eth_dev *dev);
 int32_t zxdh_get_queue_type(uint16_t vtpci_queue_idx);
 
#51 lore raw

Re: [PATCH v2 01/15] net/zxdh: zxdh np init implementation

In reply to Junlong Wang
Quoted 4 lines
Quoted 1 line

struct zxdh_hw_internal zxdh_hw_internal[RTE_MAX_ETHPORTS];

If you want to support primary/secondary in future, variables in BSS are not shared between primary and secondary process

This structure mainly registers some PCI ops and will not be shared between primary/secondary processes.

Quoted 7 lines

drivers/net/zxdh/zxdh_ethdev.c line 22

Quoted 4 lines
drivers/net/zxdh/zxdh_ethdev.c +4 -0
+struct zxdh_shared_data *zxdh_shared_data;
+const char *ZXDH_PMD_SHARED_DATA_MZ = "zxdh_pmd_shared_data";
+rte_spinlock_t zxdh_shared_data_lock = RTE_SPINLOCK_INITIALIZER;
+struct zxdh_dtb_shared_data g_dtb_data;

The shared data will be a problem if you support multiple devices. Or is this really a singleton device with only one bus and slot.

In our latest version, we have optimized by placing this structure in a private data area and initializing each device independently.
Can we update later?

Quoted 12 lines

drivers/net/zxdh/zxdh_np.c line 229

Quoted 8 lines
drivers/net/zxdh/zxdh_np.c new file +8 -0
+static uint32_t
+zxdh_np_dtb_soft_init(uint32_t dev_id)
+{
+    ZXDH_DTB_MGR_T *p_dtb_mgr = NULL;
+
+    p_dtb_mgr = zxdh_np_dtb_mgr_get(dev_id);
+    if (p_dtb_mgr == NULL) {
+        p_dpp_dtb_mgr[dev_id] = (ZXDH_DTB_MGR_T *)malloc(sizeof(ZXDH_DTB_MGR_T));

malloc() returns void *, cast here is not needed.
Why does DTB_MGR_T come from malloc when most of other data is using rte_malloc()?

Quoted 1 line

It will matter if you support multiprocess

I didn't realize it, it was originally intended to use rte_malloc.

Thank you for your comments.
And other issues will modifyed according to the comments.

#52 lore raw

Re: [PATCH v2 01/15] net/zxdh: zxdh np init implementation

In reply to Junlong Wang
Quoted 6 lines
Quoted 4 lines

(np)network Processor initialize resources in host, and initialize a channel for some tables insert/get/del.

This mostly looks good, just some small stuff.

Hi, Stephen

May I ask a question.
There are modification suggestions for the first patch of v2 now. Will the remaining patches continue to be reviewed.

If there are any, we would like to modify them together. If not, we will modify the first patch and create a v3 version.

Thanks.

#53 lore raw

v3 cover net/zxdh: updated net zxdh driver

In reply to Junlong Wang

V3:
- use rte_zmalloc and rte_calloc to avoid memset.
- remove unnecessary initialization, which first usage will set.
- adjust some function which is always return 0, changed to void and skip the ASSERTION later.
- resolved some WARNING:MACRO_ARG_UNUSED issues.
- resolved some other issues.

V2:
- resolve code style and github-robot build issue.

V1:
- updated net zxdh driver
provided insert/delete/get table code funcs. provided link/mac/vlan/promiscuous/rss/mtu ops.

Junlong Wang (15):
net/zxdh: zxdh np init implementation net/zxdh: zxdh np uninit implementation net/zxdh: port tables init implementations net/zxdh: port tables unint implementations net/zxdh: rx/tx queue setup and intr enable net/zxdh: dev start/stop ops implementations net/zxdh: provided dev simple tx implementations net/zxdh: provided dev simple rx implementations net/zxdh: link info update, set link up/down net/zxdh: mac set/add/remove ops implementations net/zxdh: promisc/allmulti ops implementations net/zxdh: vlan filter/ offload ops implementations net/zxdh: rss hash config/update, reta update/get net/zxdh: basic stats ops implementations net/zxdh: mtu update ops implementations

 doc/guides/nics/features/zxdh.ini  |   18 +
 doc/guides/nics/zxdh.rst           |   17 +
 drivers/net/zxdh/meson.build       |    4 +
 drivers/net/zxdh/zxdh_common.c     |   24 +
 drivers/net/zxdh/zxdh_common.h     |    1 +
 drivers/net/zxdh/zxdh_ethdev.c     |  574 +++++++-
 drivers/net/zxdh/zxdh_ethdev.h     |   41 +-
 drivers/net/zxdh/zxdh_ethdev_ops.c | 1595 +++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |   80 ++
 drivers/net/zxdh/zxdh_msg.c        |  166 +++
 drivers/net/zxdh/zxdh_msg.h        |  232 ++++
 drivers/net/zxdh/zxdh_np.c         | 2060 ++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_np.h         |  579 ++++++++
 drivers/net/zxdh/zxdh_pci.c        |   26 +-
 drivers/net/zxdh/zxdh_pci.h        |    9 +-
 drivers/net/zxdh/zxdh_queue.c      |  242 +++-
 drivers/net/zxdh/zxdh_queue.h      |  144 +-
 drivers/net/zxdh/zxdh_rxtx.c       |  804 +++++++++++
 drivers/net/zxdh/zxdh_rxtx.h       |   20 +-
 drivers/net/zxdh/zxdh_tables.c     |  794 +++++++++++
 drivers/net/zxdh/zxdh_tables.h     |  231 ++++
 21 files changed, 7614 insertions(+), 47 deletions(-)
 create mode 100644 drivers/net/zxdh/zxdh_ethdev_ops.c
 create mode 100644 drivers/net/zxdh/zxdh_ethdev_ops.h
 create mode 100644 drivers/net/zxdh/zxdh_np.c
 create mode 100644 drivers/net/zxdh/zxdh_np.h
 create mode 100644 drivers/net/zxdh/zxdh_rxtx.c
 create mode 100644 drivers/net/zxdh/zxdh_tables.c
 create mode 100644 drivers/net/zxdh/zxdh_tables.h
Signature · 1 line
2.27.0
#54 lore raw

PATCH v3 1/15 net/zxdh: zxdh np init implementation

(np)network Processor initialize resources in host, and initialize a channel for some tables insert/get/del.

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_ethdev.c | 234 +++++++++++++++++++++--
 drivers/net/zxdh/zxdh_ethdev.h |  30 +++
 drivers/net/zxdh/zxdh_msg.c    |  44 +++++
 drivers/net/zxdh/zxdh_msg.h    |  37 ++++
 drivers/net/zxdh/zxdh_np.c     | 340 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_np.h     | 198 +++++++++++++++++++
 drivers/net/zxdh/zxdh_pci.c    |   2 +-
 drivers/net/zxdh/zxdh_pci.h    |   6 +-
 drivers/net/zxdh/zxdh_queue.c  |   2 +-
 drivers/net/zxdh/zxdh_queue.h  |  14 +-
 11 files changed, 875 insertions(+), 33 deletions(-)
 create mode 100644 drivers/net/zxdh/zxdh_np.c
 create mode 100644 drivers/net/zxdh/zxdh_np.h
drivers/net/zxdh/meson.build +1 -0
index c9960f4c73..ab24a3145c 100644
@@ -19,4 +19,5 @@ sources = files(
         'zxdh_msg.c',
         'zxdh_pci.c',
         'zxdh_queue.c',
+        'zxdh_np.c',
 )
drivers/net/zxdh/zxdh_ethdev.c +213 -21

324 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev.h +30 -0
index 7658cbb461..b1f398b28e 100644
@@ -35,6 +35,12 @@
 
 #define ZXDH_MBUF_BURST_SZ        64
 
+#define ZXDH_MAX_BASE_DTB_TABLE_COUNT   30
+#define ZXDH_DTB_TABLE_DUMP_SIZE        (32 * (16 + 16 * 1024))
+#define ZXDH_DTB_TABLE_CONF_SIZE        (32 * (16 + 16 * 1024))
+
+#define ZXDH_MAX_NAME_LEN               32
+
 union zxdh_virport_num {
 	uint16_t vport;
 	struct {
@@ -89,6 +95,30 @@ struct zxdh_hw {
 	uint8_t has_rx_offload;
 };
 
+struct zxdh_dtb_shared_data {
+	uint8_t init_done;
+	char name[ZXDH_MAX_NAME_LEN];
+	uint16_t queueid;
+	uint16_t vport;
+	uint32_t vector;
+	const struct rte_memzone *dtb_table_conf_mz;
+	const struct rte_memzone *dtb_table_dump_mz;
+	const struct rte_memzone *dtb_table_bulk_dump_mz[ZXDH_MAX_BASE_DTB_TABLE_COUNT];
+	struct rte_eth_dev *bind_device;
+	uint32_t dev_refcnt;
+};
+
+/* Shared data between primary and secondary processes. */
+struct zxdh_shared_data {
+	rte_spinlock_t lock; /* Global spinlock for primary and secondary processes. */
+	int32_t init_done;       /* Whether primary has done initialization. */
+	unsigned int secondary_cnt; /* Number of secondary processes init'd. */
+
+	int32_t np_init_done;
+	uint32_t dev_refcnt;
+	struct zxdh_dtb_shared_data *dtb_data;
+};
+
 uint16_t zxdh_vport_to_vfid(union zxdh_virport_num v);
 
 #endif /* ZXDH_ETHDEV_H */
drivers/net/zxdh/zxdh_msg.c +44 -0

47 lines not on this page · raw message

drivers/net/zxdh/zxdh_msg.h +37 -0
index 530ee406b1..fbc79e8f9d 100644
@@ -131,6 +131,26 @@ enum ZXDH_TBL_MSG_TYPE {
 	ZXDH_TBL_TYPE_NON,
 };
 
+enum pciebar_layout_type {
+	ZXDH_URI_VQM      = 0,
+	ZXDH_URI_SPINLOCK = 1,
+	ZXDH_URI_FWCAP    = 2,
+	ZXDH_URI_FWSHR    = 3,
+	ZXDH_URI_DRS_SEC  = 4,
+	ZXDH_URI_RSV      = 5,
+	ZXDH_URI_CTRLCH   = 6,
+	ZXDH_URI_1588     = 7,
+	ZXDH_URI_QBV      = 8,
+	ZXDH_URI_MACPCS   = 9,
+	ZXDH_URI_RDMA     = 10,
+	ZXDH_URI_MNP      = 11,
+	ZXDH_URI_MSPM     = 12,
+	ZXDH_URI_MVQM     = 13,
+	ZXDH_URI_MDPI     = 14,
+	ZXDH_URI_NP       = 15,
+	ZXDH_URI_MAX,
+};
+
 struct zxdh_msix_para {
 	uint16_t pcie_id;
 	uint16_t vector_risc;
@@ -174,6 +194,17 @@ struct zxdh_bar_offset_reps {
 	uint32_t length;
 } __rte_packed;
 
+struct zxdh_bar_offset_params {
+	uint64_t virt_addr;  /* Bar space control space virtual address */
+	uint16_t pcie_id;
+	uint16_t type;  /* Module types corresponding to PCIBAR planning */
+};
+
+struct zxdh_bar_offset_res {
+	uint32_t bar_offset;
+	uint32_t bar_length;
+};
+
 struct zxdh_bar_recv_msg {
 	uint8_t reps_ok;
 	uint16_t reps_len;
@@ -204,9 +235,15 @@ struct zxdh_bar_msg_header {
 	uint16_t dst_pcieid; /* used in PF-->VF */
 };
 
+struct zxdh_offset_get_msg {
+	uint16_t pcie_id;
+	uint16_t type;
+};
+
 typedef int (*zxdh_bar_chan_msg_recv_callback)(void *pay_load, uint16_t len,
 		void *reps_buffer, uint16_t *reps_len, void *dev);
 
+int zxdh_get_bar_offset(struct zxdh_bar_offset_params *paras, struct zxdh_bar_offset_res *res);
 int zxdh_msg_chan_init(void);
 int zxdh_bar_msg_chan_exit(void);
 int zxdh_msg_chan_hwlock_init(struct rte_eth_dev *dev);
drivers/net/zxdh/zxdh_np.c new file +340 -0

340 lines not on this page · raw message

drivers/net/zxdh/zxdh_np.h new file +198 -0

198 lines not on this page · raw message

drivers/net/zxdh/zxdh_pci.c +1 -1
index 06d3f92b20..250e67d560 100644
@@ -159,7 +159,7 @@ zxdh_setup_queue(struct zxdh_hw *hw, struct zxdh_virtqueue *vq)
 
 	desc_addr = vq->vq_ring_mem;
 	avail_addr = desc_addr + vq->vq_nentries * sizeof(struct zxdh_vring_desc);
-	if (vtpci_packed_queue(vq->hw)) {
+	if (zxdh_pci_packed_queue(vq->hw)) {
 		used_addr = RTE_ALIGN_CEIL((avail_addr +
 				sizeof(struct zxdh_vring_packed_desc_event)),
 				ZXDH_PCI_VRING_ALIGN);
drivers/net/zxdh/zxdh_pci.h +3 -3
index ed6fd89742..d6487a574f 100644
@@ -114,15 +114,15 @@ struct zxdh_pci_common_cfg {
 };
 
 static inline int32_t
-vtpci_with_feature(struct zxdh_hw *hw, uint64_t bit)
+zxdh_pci_with_feature(struct zxdh_hw *hw, uint64_t bit)
 {
 	return (hw->guest_features & (1ULL << bit)) != 0;
 }
 
 static inline int32_t
-vtpci_packed_queue(struct zxdh_hw *hw)
+zxdh_pci_packed_queue(struct zxdh_hw *hw)
 {
-	return vtpci_with_feature(hw, ZXDH_F_RING_PACKED);
+	return zxdh_pci_with_feature(hw, ZXDH_F_RING_PACKED);
 }
 
 struct zxdh_pci_ops {
drivers/net/zxdh/zxdh_queue.c +1 -1
index 462a88b23c..b4ef90ea36 100644
@@ -13,7 +13,7 @@
 #include "zxdh_msg.h"
 
 struct rte_mbuf *
-zxdh_virtqueue_detach_unused(struct zxdh_virtqueue *vq)
+zxdh_queue_detach_unused(struct zxdh_virtqueue *vq)
 {
 	struct rte_mbuf *cookie = NULL;
 	int32_t          idx    = 0;
drivers/net/zxdh/zxdh_queue.h +7 -7
index 1088bf08fc..1304d5e4ea 100644
@@ -206,11 +206,11 @@ struct zxdh_tx_region {
 };
 
 static inline size_t
-vring_size(struct zxdh_hw *hw, uint32_t num, unsigned long align)
+zxdh_vring_size(struct zxdh_hw *hw, uint32_t num, unsigned long align)
 {
 	size_t size;
 
-	if (vtpci_packed_queue(hw)) {
+	if (zxdh_pci_packed_queue(hw)) {
 		size = num * sizeof(struct zxdh_vring_packed_desc);
 		size += sizeof(struct zxdh_vring_packed_desc_event);
 		size = RTE_ALIGN_CEIL(size, align);
@@ -226,7 +226,7 @@ vring_size(struct zxdh_hw *hw, uint32_t num, unsigned long align)
 }
 
 static inline void
-vring_init_packed(struct zxdh_vring_packed *vr, uint8_t *p,
+zxdh_vring_init_packed(struct zxdh_vring_packed *vr, uint8_t *p,
 		unsigned long align, uint32_t num)
 {
 	vr->num    = num;
@@ -238,7 +238,7 @@ vring_init_packed(struct zxdh_vring_packed *vr, uint8_t *p,
 }
 
 static inline void
-vring_desc_init_packed(struct zxdh_virtqueue *vq, int32_t n)
+zxdh_vring_desc_init_packed(struct zxdh_virtqueue *vq, int32_t n)
 {
 	int32_t i = 0;
 
@@ -251,7 +251,7 @@ vring_desc_init_packed(struct zxdh_virtqueue *vq, int32_t n)
 }
 
 static inline void
-vring_desc_init_indirect_packed(struct zxdh_vring_packed_desc *dp, int32_t n)
+zxdh_vring_desc_init_indirect_packed(struct zxdh_vring_packed_desc *dp, int32_t n)
 {
 	int32_t i = 0;
 
@@ -262,7 +262,7 @@ vring_desc_init_indirect_packed(struct zxdh_vring_packed_desc *dp, int32_t n)
 }
 
 static inline void
-virtqueue_disable_intr(struct zxdh_virtqueue *vq)
+zxdh_queue_disable_intr(struct zxdh_virtqueue *vq)
 {
 	if (vq->vq_packed.event_flags_shadow != ZXDH_RING_EVENT_FLAGS_DISABLE) {
 		vq->vq_packed.event_flags_shadow = ZXDH_RING_EVENT_FLAGS_DISABLE;
@@ -270,7 +270,7 @@ virtqueue_disable_intr(struct zxdh_virtqueue *vq)
 	}
 }
 
-struct rte_mbuf *zxdh_virtqueue_detach_unused(struct zxdh_virtqueue *vq);
+struct rte_mbuf *zxdh_queue_detach_unused(struct zxdh_virtqueue *vq);
 int32_t zxdh_free_queues(struct rte_eth_dev *dev);
 int32_t zxdh_get_queue_type(uint16_t vtpci_queue_idx);
 
Signature · 1 line
2.27.0
#55 lore raw

PATCH v3 2/15 net/zxdh: zxdh np uninit implementation

In reply to Junlong Wang

(np)network processor release resources in host.

---
 drivers/net/zxdh/zxdh_ethdev.c |  48 ++++
 drivers/net/zxdh/zxdh_np.c     | 470 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_np.h     | 107 ++++++++
 3 files changed, 625 insertions(+)
drivers/net/zxdh/zxdh_ethdev.c +48 -0
index b8f4415e00..4e114d95da 100644
@@ -841,6 +841,51 @@ zxdh_dev_configure(struct rte_eth_dev *dev)
 	return ret;
 }
 
+static void
+zxdh_np_dtb_data_res_free(struct zxdh_hw *hw)
+{
+	struct rte_eth_dev *dev = hw->eth_dev;
+	int ret;
+	int i;
+
+	if (g_dtb_data.init_done && g_dtb_data.bind_device == dev) {
+		ret = zxdh_np_online_uninit(0, dev->data->name, g_dtb_data.queueid);
+		if (ret)
+			PMD_DRV_LOG(ERR, "%s dpp_np_online_uninstall failed", dev->data->name);
+
+		if (g_dtb_data.dtb_table_conf_mz)
+			rte_memzone_free(g_dtb_data.dtb_table_conf_mz);
+
+		if (g_dtb_data.dtb_table_dump_mz) {
+			rte_memzone_free(g_dtb_data.dtb_table_dump_mz);
+			g_dtb_data.dtb_table_dump_mz = NULL;
+		}
+
+		for (i = 0; i < ZXDH_MAX_BASE_DTB_TABLE_COUNT; i++) {
+			if (g_dtb_data.dtb_table_bulk_dump_mz[i]) {
+				rte_memzone_free(g_dtb_data.dtb_table_bulk_dump_mz[i]);
+				g_dtb_data.dtb_table_bulk_dump_mz[i] = NULL;
+			}
+		}
+		g_dtb_data.init_done = 0;
+		g_dtb_data.bind_device = NULL;
+	}
+	if (zxdh_shared_data != NULL)
+		zxdh_shared_data->np_init_done = 0;
+}
+
+static void
+zxdh_np_uninit(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (!g_dtb_data.init_done && !g_dtb_data.dev_refcnt)
+		return;
+
+	if (--g_dtb_data.dev_refcnt == 0)
+		zxdh_np_dtb_data_res_free(hw);
+}
+
 static int
 zxdh_dev_close(struct rte_eth_dev *dev)
 {
@@ -848,6 +893,7 @@ zxdh_dev_close(struct rte_eth_dev *dev)
 	int ret = 0;
 
 	zxdh_intr_release(dev);
+	zxdh_np_uninit(dev);
 	zxdh_pci_reset(hw);
 
 	zxdh_dev_free_mbufs(dev);
@@ -1010,6 +1056,7 @@ zxdh_np_dtb_res_init(struct rte_eth_dev *dev)
 	return 0;
 
 free_res:
+	zxdh_np_dtb_data_res_free(hw);
 	rte_free(dpp_ctrl);
 	return ret;
 }
@@ -1177,6 +1224,7 @@ zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 
 err_zxdh_init:
 	zxdh_intr_release(eth_dev);
+	zxdh_np_uninit(eth_dev);
 	zxdh_bar_msg_chan_exit();
 	rte_free(eth_dev->data->mac_addrs);
 	eth_dev->data->mac_addrs = NULL;
drivers/net/zxdh/zxdh_np.c +470 -0

483 lines not on this page · raw message

drivers/net/zxdh/zxdh_np.h +107 -0

131 lines not on this page · raw message

Signature · 1 line
2.27.0
#56 lore raw

PATCH v3 3/15 net/zxdh: port tables init implementations

In reply to Junlong Wang

insert port tables in host.

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_ethdev.c |  24 ++
 drivers/net/zxdh/zxdh_msg.c    |  65 ++++
 drivers/net/zxdh/zxdh_msg.h    |  72 ++++
 drivers/net/zxdh/zxdh_np.c     | 648 ++++++++++++++++++++++++++++++++-
 drivers/net/zxdh/zxdh_np.h     | 210 +++++++++++
 drivers/net/zxdh/zxdh_pci.h    |   2 +
 drivers/net/zxdh/zxdh_tables.c | 105 ++++++
 drivers/net/zxdh/zxdh_tables.h | 148 ++++++++
 9 files changed, 1274 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/zxdh/zxdh_tables.c
 create mode 100644 drivers/net/zxdh/zxdh_tables.h
drivers/net/zxdh/meson.build +1 -0
index ab24a3145c..5b3af87c5b 100644
@@ -20,4 +20,5 @@ sources = files(
         'zxdh_pci.c',
         'zxdh_queue.c',
         'zxdh_np.c',
+        'zxdh_tables.c',
 )
drivers/net/zxdh/zxdh_ethdev.c +24 -0
index 4e114d95da..ff44816384 100644
@@ -14,6 +14,7 @@
 #include "zxdh_common.h"
 #include "zxdh_queue.h"
 #include "zxdh_np.h"
+#include "zxdh_tables.h"
 
 struct zxdh_hw_internal zxdh_hw_internal[RTE_MAX_ETHPORTS];
 struct zxdh_shared_data *zxdh_shared_data;
@@ -1144,6 +1145,25 @@ zxdh_np_init(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
+static int
+zxdh_tables_init(struct rte_eth_dev *dev)
+{
+	int ret = 0;
+
+	ret = zxdh_port_attr_init(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "zxdh_port_attr_init failed");
+		return ret;
+	}
+
+	ret = zxdh_panel_table_init(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, " panel table init failed");
+		return ret;
+	}
+	return ret;
+}
+
 static int
 zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 {
@@ -1220,6 +1240,10 @@ zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 	if (ret != 0)
 		goto err_zxdh_init;
 
+	ret = zxdh_tables_init(eth_dev);
+	if (ret != 0)
+		goto err_zxdh_init;
+
 	return ret;
 
 err_zxdh_init:
drivers/net/zxdh/zxdh_msg.c +65 -0

80 lines not on this page · raw message

drivers/net/zxdh/zxdh_msg.h +72 -0

95 lines not on this page · raw message

drivers/net/zxdh/zxdh_np.c +647 -1

680 lines not on this page · raw message

drivers/net/zxdh/zxdh_np.h +210 -0

229 lines not on this page · raw message

drivers/net/zxdh/zxdh_pci.h +2 -0
index d6487a574f..e3f13cb17d 100644
@@ -12,6 +12,8 @@
 
 #include "zxdh_ethdev.h"
 
+#define ZXDH_PF_PCIE_ID(pcie_id)  (((pcie_id) & 0xff00) | 1 << 11)
+
 enum zxdh_msix_status {
 	ZXDH_MSIX_NONE     = 0,
 	ZXDH_MSIX_DISABLED = 1,
drivers/net/zxdh/zxdh_tables.c new file +105 -0

105 lines not on this page · raw message

drivers/net/zxdh/zxdh_tables.h new file +148 -0

148 lines not on this page · raw message

Signature · 1 line
2.27.0
#57 lore raw

PATCH v3 4/15 net/zxdh: port tables unint implementations

In reply to Junlong Wang

delete port tables in host.

---
 drivers/net/zxdh/zxdh_ethdev.c |  18 ++++++
 drivers/net/zxdh/zxdh_msg.h    |   1 +
 drivers/net/zxdh/zxdh_np.c     | 103 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_np.h     |   9 +++
 drivers/net/zxdh/zxdh_tables.c |  33 ++++++++++-
 drivers/net/zxdh/zxdh_tables.h |   1 +
 6 files changed, 164 insertions(+), 1 deletion(-)
drivers/net/zxdh/zxdh_ethdev.c +18 -0
index ff44816384..717a1d2b0b 100644
@@ -887,12 +887,30 @@ zxdh_np_uninit(struct rte_eth_dev *dev)
 		zxdh_np_dtb_data_res_free(hw);
 }
 
+static int
+zxdh_tables_uninit(struct rte_eth_dev *dev)
+{
+	int ret;
+
+	ret = zxdh_port_attr_uninit(dev);
+	if (ret)
+		PMD_DRV_LOG(ERR, "zxdh_port_attr_uninit failed");
+
+	return ret;
+}
+
 static int
 zxdh_dev_close(struct rte_eth_dev *dev)
 {
 	struct zxdh_hw *hw = dev->data->dev_private;
 	int ret = 0;
 
+	ret = zxdh_tables_uninit(dev);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "%s :tables uninit %s failed ", __func__, dev->device->name);
+		return -1;
+	}
+
 	zxdh_intr_release(dev);
 	zxdh_np_uninit(dev);
 	zxdh_pci_reset(hw);
drivers/net/zxdh/zxdh_msg.h +1 -0
index b7b17b8696..613ca71170 100644
@@ -167,6 +167,7 @@ enum pciebar_layout_type {
 enum zxdh_msg_type {
 	ZXDH_NULL = 0,
 	ZXDH_VF_PORT_INIT = 1,
+	ZXDH_VF_PORT_UNINIT = 2,
 
 	ZXDH_MSG_TYPE_END,
 };
drivers/net/zxdh/zxdh_np.c +103 -0

112 lines not on this page · raw message

drivers/net/zxdh/zxdh_np.h +9 -0
index 40961c02a2..42a652dd6b 100644
@@ -20,6 +20,8 @@
 #define ZXDH_PPU_CLUSTER_NUM                  (6)
 #define ZXDH_PPU_INSTR_MEM_NUM                (3)
 #define ZXDH_SDT_CFG_LEN                      (2)
+#define ZXDH_SDT_H_TBL_TYPE_BT_POS            (29)
+#define ZXDH_SDT_H_TBL_TYPE_BT_LEN            (3)
 
 #define ZXDH_RC_DEV_BASE                      (0x600)
 #define ZXDH_RC_DEV_PARA_INVALID              (ZXDH_RC_DEV_BASE | 0x0)
@@ -507,9 +509,16 @@ typedef struct zxdh_dtb_user_entry_t {
 	void *p_entry_data;
 } ZXDH_DTB_USER_ENTRY_T;
 
+typedef struct zxdh_sdt_tbl_data_t {
+	uint32_t data_high32;
+	uint32_t data_low32;
+} ZXDH_SDT_TBL_DATA_T;
+
 int zxdh_np_host_init(uint32_t dev_id, ZXDH_DEV_INIT_CTRL_T *p_dev_init_ctrl);
 int zxdh_np_online_uninit(uint32_t dev_id, char *port_name, uint32_t queue_id);
 int zxdh_np_dtb_table_entry_write(uint32_t dev_id, uint32_t queue_id,
 			uint32_t entrynum, ZXDH_DTB_USER_ENTRY_T *down_entries);
+int zxdh_np_dtb_table_entry_delete(uint32_t dev_id, uint32_t queue_id,
+			 uint32_t entrynum, ZXDH_DTB_USER_ENTRY_T *delete_entries);
 
 #endif /* ZXDH_NP_H */
drivers/net/zxdh/zxdh_tables.c +32 -1
index 91376e6ec0..9fd184e612 100644
@@ -11,7 +11,8 @@
 #define ZXDH_SDT_VPORT_ATT_TABLE          1
 #define ZXDH_SDT_PANEL_ATT_TABLE          2
 
-int zxdh_set_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr)
+int
+zxdh_set_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr)
 {
 	int ret = 0;
 
@@ -70,6 +71,36 @@ zxdh_port_attr_init(struct rte_eth_dev *dev)
 	return ret;
 };
 
+int
+zxdh_port_attr_uninit(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+	struct zxdh_msg_info msg_info = {0};
+	struct zxdh_port_attr_table port_attr = {0};
+	int ret = 0;
+
+	if (hw->is_pf == 1) {
+		ZXDH_DTB_ERAM_ENTRY_INFO_T port_attr_entry = {hw->vfid, (uint32_t *)&port_attr};
+		ZXDH_DTB_USER_ENTRY_T entry = {
+			.sdt_no = ZXDH_SDT_VPORT_ATT_TABLE,
+			.p_entry_data = (void *)&port_attr_entry
+		};
+		ret = zxdh_np_dtb_table_entry_delete(ZXDH_DEVICE_NO, g_dtb_data.queueid, 1, &entry);
+		if (ret) {
+			PMD_DRV_LOG(ERR, "delete port attr table failed");
+			ret = -1;
+		}
+	} else {
+		zxdh_msg_head_build(hw, ZXDH_VF_PORT_UNINIT, &msg_info);
+		ret = zxdh_vf_send_msg_to_pf(dev, &msg_info, sizeof(msg_info), NULL, 0);
+		if (ret) {
+			PMD_DRV_LOG(ERR, "vf port tables uninit failed");
+			ret = -1;
+		}
+	}
+	return ret;
+}
+
 int zxdh_panel_table_init(struct rte_eth_dev *dev)
 {
 	struct zxdh_hw *hw = dev->data->dev_private;
drivers/net/zxdh/zxdh_tables.h +1 -0
index 5d34af2f05..5e9b36faee 100644
@@ -144,5 +144,6 @@ struct zxdh_panel_table {
 int zxdh_port_attr_init(struct rte_eth_dev *dev);
 int zxdh_panel_table_init(struct rte_eth_dev *dev);
 int zxdh_set_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr);
+int zxdh_port_attr_uninit(struct rte_eth_dev *dev);
 
 #endif /* ZXDH_TABLES_H */
Signature · 1 line
2.27.0
#58 lore raw

PATCH v3 5/15 net/zxdh: rx/tx queue setup and intr enable

In reply to Junlong Wang

rx/tx queue setup and intr enable implementations.

---
 drivers/net/zxdh/zxdh_ethdev.c |   4 +
 drivers/net/zxdh/zxdh_queue.c  | 149 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_queue.h  |  33 ++++++++
 3 files changed, 186 insertions(+)
drivers/net/zxdh/zxdh_ethdev.c +4 -0
index 717a1d2b0b..521d7ed433 100644
@@ -933,6 +933,10 @@ static const struct eth_dev_ops zxdh_eth_dev_ops = {
 	.dev_configure			 = zxdh_dev_configure,
 	.dev_close				 = zxdh_dev_close,
 	.dev_infos_get			 = zxdh_dev_infos_get,
+	.rx_queue_setup			 = zxdh_dev_rx_queue_setup,
+	.tx_queue_setup			 = zxdh_dev_tx_queue_setup,
+	.rx_queue_intr_enable	 = zxdh_dev_rx_queue_intr_enable,
+	.rx_queue_intr_disable	 = zxdh_dev_rx_queue_intr_disable,
 };
 
 static int32_t
drivers/net/zxdh/zxdh_queue.c +149 -0

158 lines not on this page · raw message

drivers/net/zxdh/zxdh_queue.h +33 -0
index 1304d5e4ea..2f602d894f 100644
@@ -8,6 +8,7 @@
 #include <stdint.h>
 
 #include <rte_common.h>
+#include <rte_atomic.h>
 
 #include "zxdh_ethdev.h"
 #include "zxdh_rxtx.h"
@@ -30,6 +31,7 @@ enum { ZXDH_VTNET_RQ = 0, ZXDH_VTNET_TQ = 1 };
 #define ZXDH_RING_EVENT_FLAGS_DESC        0x2
 
 #define ZXDH_VQ_RING_DESC_CHAIN_END       32768
+#define ZXDH_QUEUE_DEPTH                  1024
 
 /*
  * ring descriptors: 16 bytes.
@@ -270,8 +272,39 @@ zxdh_queue_disable_intr(struct zxdh_virtqueue *vq)
 	}
 }
 
+static inline void
+zxdh_queue_enable_intr(struct zxdh_virtqueue *vq)
+{
+	if (vq->vq_packed.event_flags_shadow == ZXDH_RING_EVENT_FLAGS_DISABLE) {
+		vq->vq_packed.event_flags_shadow = ZXDH_RING_EVENT_FLAGS_DISABLE;
+		vq->vq_packed.ring.driver->desc_event_flags = vq->vq_packed.event_flags_shadow;
+	}
+}
+
+static inline void
+zxdh_mb(uint8_t weak_barriers)
+{
+	if (weak_barriers)
+		rte_atomic_thread_fence(rte_memory_order_seq_cst);
+	else
+		rte_mb();
+}
+
 struct rte_mbuf *zxdh_queue_detach_unused(struct zxdh_virtqueue *vq);
 int32_t zxdh_free_queues(struct rte_eth_dev *dev);
 int32_t zxdh_get_queue_type(uint16_t vtpci_queue_idx);
+int32_t zxdh_dev_tx_queue_setup(struct rte_eth_dev *dev,
+			uint16_t queue_idx,
+			uint16_t nb_desc,
+			uint32_t socket_id __rte_unused,
+			const struct rte_eth_txconf *tx_conf);
+int32_t zxdh_dev_rx_queue_setup(struct rte_eth_dev *dev,
+			uint16_t queue_idx,
+			uint16_t nb_desc,
+			uint32_t socket_id __rte_unused,
+			const struct rte_eth_rxconf *rx_conf,
+			struct rte_mempool *mp);
+int32_t zxdh_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id);
+int32_t zxdh_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id);
 
 #endif /* ZXDH_QUEUE_H */
Signature · 1 line
2.27.0
#59 lore raw

PATCH v3 6/15 net/zxdh: dev start/stop ops implementations

In reply to Junlong Wang

dev start/stop implementations, start/stop the rx/tx queues.

---
 doc/guides/nics/features/zxdh.ini |  2 +
 doc/guides/nics/zxdh.rst          |  2 +
 drivers/net/zxdh/zxdh_ethdev.c    | 61 +++++++++++++++++++++
 drivers/net/zxdh/zxdh_pci.c       | 24 ++++++++
 drivers/net/zxdh/zxdh_pci.h       |  1 +
 drivers/net/zxdh/zxdh_queue.c     | 91 +++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_queue.h     | 69 +++++++++++++++++++++++
 drivers/net/zxdh/zxdh_rxtx.h      | 14 ++---
 8 files changed, 256 insertions(+), 8 deletions(-)
doc/guides/nics/features/zxdh.ini +2 -0
index 05c8091ed7..7b72be5f25 100644
@@ -7,3 +7,5 @@
 Linux                = Y
 x86-64               = Y
 ARMv8                = Y
+SR-IOV               = Y
+Multiprocess aware   = Y
doc/guides/nics/zxdh.rst +2 -0
index 2144753d75..eb970a888f 100644
@@ -18,6 +18,8 @@ Features
 Features of the ZXDH PMD are:
 
 - Multi arch support: x86_64, ARMv8.
+- Multiple queues for TX and RX
+- SR-IOV VF
 
 
 Driver compilation and testing
drivers/net/zxdh/zxdh_ethdev.c +61 -0

82 lines not on this page · raw message

drivers/net/zxdh/zxdh_pci.c +24 -0
index 250e67d560..83164a5c79 100644
@@ -202,6 +202,29 @@ zxdh_del_queue(struct zxdh_hw *hw, struct zxdh_virtqueue *vq)
 	rte_write16(0, &hw->common_cfg->queue_enable);
 }
 
+static void
+zxdh_notify_queue(struct zxdh_hw *hw, struct zxdh_virtqueue *vq)
+{
+	uint32_t notify_data = 0;
+
+	if (!zxdh_pci_with_feature(hw, ZXDH_F_NOTIFICATION_DATA)) {
+		rte_write16(vq->vq_queue_index, vq->notify_addr);
+		return;
+	}
+
+	if (zxdh_pci_with_feature(hw, ZXDH_F_RING_PACKED)) {
+		notify_data = ((uint32_t)(!!(vq->vq_packed.cached_flags &
+						ZXDH_VRING_PACKED_DESC_F_AVAIL)) << 31) |
+						((uint32_t)vq->vq_avail_idx << 16) |
+						vq->vq_queue_index;
+	} else {
+		notify_data = ((uint32_t)vq->vq_avail_idx << 16) | vq->vq_queue_index;
+	}
+	PMD_DRV_LOG(DEBUG, "queue:%d notify_data 0x%x notify_addr 0x%p",
+				 vq->vq_queue_index, notify_data, vq->notify_addr);
+	rte_write32(notify_data, vq->notify_addr);
+}
+
 const struct zxdh_pci_ops zxdh_dev_pci_ops = {
 	.read_dev_cfg   = zxdh_read_dev_config,
 	.write_dev_cfg  = zxdh_write_dev_config,
@@ -216,6 +239,7 @@ const struct zxdh_pci_ops zxdh_dev_pci_ops = {
 	.set_queue_num  = zxdh_set_queue_num,
 	.setup_queue    = zxdh_setup_queue,
 	.del_queue      = zxdh_del_queue,
+	.notify_queue   = zxdh_notify_queue,
 };
 
 uint8_t
drivers/net/zxdh/zxdh_pci.h +1 -0
index e3f13cb17d..5c5f72b90e 100644
@@ -144,6 +144,7 @@ struct zxdh_pci_ops {
 
 	int32_t  (*setup_queue)(struct zxdh_hw *hw, struct zxdh_virtqueue *vq);
 	void     (*del_queue)(struct zxdh_hw *hw, struct zxdh_virtqueue *vq);
+	void     (*notify_queue)(struct zxdh_hw *hw, struct zxdh_virtqueue *vq);
 };
 
 struct zxdh_hw_internal {
drivers/net/zxdh/zxdh_queue.c +91 -0

94 lines not on this page · raw message

drivers/net/zxdh/zxdh_queue.h +69 -0

92 lines not on this page · raw message

drivers/net/zxdh/zxdh_rxtx.h +6 -8
index de9353b223..8c7f734805 100644
@@ -20,21 +20,19 @@ struct zxdh_virtnet_stats {
 	uint64_t size_bins[8];
 };
 
-struct zxdh_virtnet_rx {
+struct __rte_cache_aligned zxdh_virtnet_rx {
 	struct zxdh_virtqueue         *vq;
-
-	/* dummy mbuf, for wraparound when processing RX ring. */
-	struct rte_mbuf           fake_mbuf;
-
 	uint64_t                  mbuf_initializer; /* value to init mbufs. */
 	struct rte_mempool       *mpool;            /* mempool for mbuf allocation */
 	uint16_t                  queue_id;         /* DPDK queue index. */
 	uint16_t                  port_id;          /* Device port identifier. */
 	struct zxdh_virtnet_stats      stats;
 	const struct rte_memzone *mz;               /* mem zone to populate RX ring. */
-} __rte_packed;
+	/* dummy mbuf, for wraparound when processing RX ring. */
+	struct rte_mbuf           fake_mbuf;
+};
 
-struct zxdh_virtnet_tx {
+struct __rte_cache_aligned zxdh_virtnet_tx {
 	struct zxdh_virtqueue         *vq;
 	const struct rte_memzone *zxdh_net_hdr_mz;  /* memzone to populate hdr. */
 	rte_iova_t                zxdh_net_hdr_mem; /* hdr for each xmit packet */
@@ -42,6 +40,6 @@ struct zxdh_virtnet_tx {
 	uint16_t                  port_id;            /* Device port identifier. */
 	struct zxdh_virtnet_stats      stats;
 	const struct rte_memzone *mz;                 /* mem zone to populate TX ring. */
-} __rte_packed;
+};
 
 #endif  /* ZXDH_RXTX_H */
Signature · 1 line
2.27.0
#60 lore raw

PATCH v3 7/15 net/zxdh: provided dev simple tx implementations

In reply to Junlong Wang

provided dev simple tx implementations.

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_ethdev.c |  20 ++
 drivers/net/zxdh/zxdh_queue.h  |  26 ++-
 drivers/net/zxdh/zxdh_rxtx.c   | 396 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_rxtx.h   |   4 +
 5 files changed, 446 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/zxdh/zxdh_rxtx.c
drivers/net/zxdh/meson.build +1 -0
index 5b3af87c5b..20b2cf484a 100644
@@ -21,4 +21,5 @@ sources = files(
         'zxdh_queue.c',
         'zxdh_np.c',
         'zxdh_tables.c',
+        'zxdh_rxtx.c',
 )
drivers/net/zxdh/zxdh_ethdev.c +20 -0
index 59ee942bdd..14939cdb10 100644
@@ -15,6 +15,7 @@
 #include "zxdh_queue.h"
 #include "zxdh_np.h"
 #include "zxdh_tables.h"
+#include "zxdh_rxtx.h"
 
 struct zxdh_hw_internal zxdh_hw_internal[RTE_MAX_ETHPORTS];
 struct zxdh_shared_data *zxdh_shared_data;
@@ -951,6 +952,24 @@ zxdh_dev_close(struct rte_eth_dev *dev)
 	return ret;
 }
 
+static int32_t
+zxdh_set_rxtx_funcs(struct rte_eth_dev *eth_dev)
+{
+	struct zxdh_hw *hw = eth_dev->data->dev_private;
+
+	if (!zxdh_pci_packed_queue(hw)) {
+		PMD_DRV_LOG(ERR, " port %u not support packed queue", eth_dev->data->port_id);
+		return -1;
+	}
+	if (!zxdh_pci_with_feature(hw, ZXDH_NET_F_MRG_RXBUF)) {
+		PMD_DRV_LOG(ERR, " port %u not support rx mergeable", eth_dev->data->port_id);
+		return -1;
+	}
+	eth_dev->tx_pkt_prepare = zxdh_xmit_pkts_prepare;
+	eth_dev->tx_pkt_burst = &zxdh_xmit_pkts_packed;
+	return 0;
+}
+
 static int
 zxdh_dev_start(struct rte_eth_dev *dev)
 {
@@ -966,6 +985,7 @@ zxdh_dev_start(struct rte_eth_dev *dev)
 		if (ret < 0)
 			return ret;
 	}
+	zxdh_set_rxtx_funcs(dev);
 	ret = zxdh_intr_enable(dev);
 	if (ret) {
 		PMD_DRV_LOG(ERR, "interrupt enable failed");
drivers/net/zxdh/zxdh_queue.h +25 -1
index 6513aec3f0..9343df81ac 100644
@@ -21,8 +21,15 @@ enum { ZXDH_VTNET_RQ = 0, ZXDH_VTNET_TQ = 1 };
 #define ZXDH_TQ_QUEUE_IDX                 1
 #define ZXDH_MAX_TX_INDIRECT              8
 
+/* This marks a buffer as continuing via the next field. */
+#define ZXDH_VRING_DESC_F_NEXT                 1
+
 /* This marks a buffer as write-only (otherwise read-only). */
-#define ZXDH_VRING_DESC_F_WRITE           2
+#define ZXDH_VRING_DESC_F_WRITE                2
+
+/* This means the buffer contains a list of buffer descriptors. */
+#define ZXDH_VRING_DESC_F_INDIRECT             4
+
 /* This flag means the descriptor was made available by the driver */
 #define ZXDH_VRING_PACKED_DESC_F_AVAIL   (1 << (7))
 #define ZXDH_VRING_PACKED_DESC_F_USED    (1 << (15))
@@ -35,11 +42,17 @@ enum { ZXDH_VTNET_RQ = 0, ZXDH_VTNET_TQ = 1 };
 #define ZXDH_RING_EVENT_FLAGS_DISABLE     0x1
 #define ZXDH_RING_EVENT_FLAGS_DESC        0x2
 
+#define ZXDH_RING_F_INDIRECT_DESC         28
+
 #define ZXDH_VQ_RING_DESC_CHAIN_END       32768
 #define ZXDH_QUEUE_DEPTH                  1024
 
 #define ZXDH_RQ_QUEUE_IDX                 0
 #define ZXDH_TQ_QUEUE_IDX                 1
+#define ZXDH_TYPE_HDR_SIZE        sizeof(struct zxdh_type_hdr)
+#define ZXDH_PI_HDR_SIZE          sizeof(struct zxdh_pi_hdr)
+#define ZXDH_DL_NET_HDR_SIZE      sizeof(struct zxdh_net_hdr_dl)
+#define ZXDH_UL_NET_HDR_SIZE      sizeof(struct zxdh_net_hdr_ul)
 
 /*
  * ring descriptors: 16 bytes.
@@ -355,6 +368,17 @@ static inline void zxdh_queue_notify(struct zxdh_virtqueue *vq)
 	ZXDH_VTPCI_OPS(vq->hw)->notify_queue(vq->hw, vq);
 }
 
+static inline int32_t
+zxdh_queue_kick_prepare_packed(struct zxdh_virtqueue *vq)
+{
+	uint16_t flags = 0;
+
+	zxdh_mb(vq->hw->weak_barriers);
+	flags = vq->vq_packed.ring.device->desc_event_flags;
+
+	return (flags != ZXDH_RING_EVENT_FLAGS_DISABLE);
+}
+
 struct rte_mbuf *zxdh_queue_detach_unused(struct zxdh_virtqueue *vq);
 int32_t zxdh_free_queues(struct rte_eth_dev *dev);
 int32_t zxdh_get_queue_type(uint16_t vtpci_queue_idx);
drivers/net/zxdh/zxdh_rxtx.c new file +396 -0

396 lines not on this page · raw message

drivers/net/zxdh/zxdh_rxtx.h +4 -0
index 8c7f734805..0a02d319b2 100644
@@ -42,4 +42,8 @@ struct __rte_cache_aligned zxdh_virtnet_tx {
 	const struct rte_memzone *mz;                 /* mem zone to populate TX ring. */
 };
 
+uint16_t zxdh_xmit_pkts_packed(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts);
+uint16_t zxdh_xmit_pkts_prepare(void *tx_queue __rte_unused, struct rte_mbuf **tx_pkts,
+				uint16_t nb_pkts);
+
 #endif  /* ZXDH_RXTX_H */
Signature · 1 line
2.27.0
#61 lore raw

PATCH v3 8/15 net/zxdh: provided dev simple rx implementations

In reply to Junlong Wang

provided dev simple rx implementations.

---
 doc/guides/nics/features/zxdh.ini |   1 +
 doc/guides/nics/zxdh.rst          |   1 +
 drivers/net/zxdh/zxdh_ethdev.c    |   2 +
 drivers/net/zxdh/zxdh_rxtx.c      | 313 ++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_rxtx.h      |   2 +
 5 files changed, 319 insertions(+)
doc/guides/nics/features/zxdh.ini +1 -0
index 7b72be5f25..bb44e93fad 100644
@@ -9,3 +9,4 @@ x86-64               = Y
 ARMv8                = Y
 SR-IOV               = Y
 Multiprocess aware   = Y
+Scattered Rx         = Y
doc/guides/nics/zxdh.rst +1 -0
index eb970a888f..f42db9c1f1 100644
@@ -20,6 +20,7 @@ Features of the ZXDH PMD are:
 - Multi arch support: x86_64, ARMv8.
 - Multiple queues for TX and RX
 - SR-IOV VF
+- Scattered and gather for TX and RX
 
 
 Driver compilation and testing
drivers/net/zxdh/zxdh_ethdev.c +2 -0
index 14939cdb10..0d63129d8d 100644
@@ -967,6 +967,8 @@ zxdh_set_rxtx_funcs(struct rte_eth_dev *eth_dev)
 	}
 	eth_dev->tx_pkt_prepare = zxdh_xmit_pkts_prepare;
 	eth_dev->tx_pkt_burst = &zxdh_xmit_pkts_packed;
+	eth_dev->rx_pkt_burst = &zxdh_recv_pkts_packed;
+
 	return 0;
 }
 
drivers/net/zxdh/zxdh_rxtx.c +313 -0

322 lines not on this page · raw message

drivers/net/zxdh/zxdh_rxtx.h +2 -0
index 0a02d319b2..cc0004324a 100644
@@ -45,5 +45,7 @@ struct __rte_cache_aligned zxdh_virtnet_tx {
 uint16_t zxdh_xmit_pkts_packed(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts);
 uint16_t zxdh_xmit_pkts_prepare(void *tx_queue __rte_unused, struct rte_mbuf **tx_pkts,
 				uint16_t nb_pkts);
+uint16_t zxdh_recv_pkts_packed(void *rx_queue, struct rte_mbuf **rx_pkts,
+				uint16_t nb_pkts);
 
 #endif  /* ZXDH_RXTX_H */
Signature · 1 line
2.27.0
#62 lore raw

PATCH v3 9/15 net/zxdh: link info update, set link up/down

In reply to Junlong Wang

provided link info update, set link up /down,
and link intr.

---
 doc/guides/nics/features/zxdh.ini  |   2 +
 doc/guides/nics/zxdh.rst           |   3 +
 drivers/net/zxdh/meson.build       |   1 +
 drivers/net/zxdh/zxdh_ethdev.c     |  14 ++-
 drivers/net/zxdh/zxdh_ethdev.h     |   2 +
 drivers/net/zxdh/zxdh_ethdev_ops.c | 166 ++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |  14 +++
 drivers/net/zxdh/zxdh_msg.c        |  57 ++++++++++
 drivers/net/zxdh/zxdh_msg.h        |  40 +++++++
 drivers/net/zxdh/zxdh_np.c         | 172 ++++++++++++++++++++++++++++-
 drivers/net/zxdh/zxdh_np.h         |  20 ++++
 drivers/net/zxdh/zxdh_tables.c     |  15 +++
 drivers/net/zxdh/zxdh_tables.h     |   6 +-
 13 files changed, 503 insertions(+), 9 deletions(-)
 create mode 100644 drivers/net/zxdh/zxdh_ethdev_ops.c
 create mode 100644 drivers/net/zxdh/zxdh_ethdev_ops.h
doc/guides/nics/features/zxdh.ini +2 -0
index bb44e93fad..7da3aaced1 100644
@@ -10,3 +10,5 @@ ARMv8                = Y
 SR-IOV               = Y
 Multiprocess aware   = Y
 Scattered Rx         = Y
+Link status          = Y
+Link status event    = Y
doc/guides/nics/zxdh.rst +3 -0
index f42db9c1f1..fdbc3b3923 100644
@@ -21,6 +21,9 @@ Features of the ZXDH PMD are:
 - Multiple queues for TX and RX
 - SR-IOV VF
 - Scattered and gather for TX and RX
+- Link Auto-negotiation
+- Link state information
+- Set Link down or up
 
 
 Driver compilation and testing
drivers/net/zxdh/meson.build +1 -0
index 20b2cf484a..48f8f5e1ee 100644
@@ -22,4 +22,5 @@ sources = files(
         'zxdh_np.c',
         'zxdh_tables.c',
         'zxdh_rxtx.c',
+        'zxdh_ethdev_ops.c',
 )
drivers/net/zxdh/zxdh_ethdev.c +13 -1
index 0d63129d8d..d3876ec9b3 100644
@@ -16,6 +16,7 @@
 #include "zxdh_np.h"
 #include "zxdh_tables.h"
 #include "zxdh_rxtx.h"
+#include "zxdh_ethdev_ops.h"
 
 struct zxdh_hw_internal zxdh_hw_internal[RTE_MAX_ETHPORTS];
 struct zxdh_shared_data *zxdh_shared_data;
@@ -105,12 +106,18 @@ static void
 zxdh_devconf_intr_handler(void *param)
 {
 	struct rte_eth_dev *dev = param;
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	uint8_t isr = zxdh_pci_isr(hw);
 
 	if (zxdh_intr_unmask(dev) < 0)
 		PMD_DRV_LOG(ERR, "interrupt enable failed");
+	if (isr & ZXDH_PCI_ISR_CONFIG) {
+		if (zxdh_dev_link_update(dev, 0) == 0)
+			rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
+	}
 }
 
-
 /* Interrupt handler triggered by NIC for handling specific interrupt. */
 static void
 zxdh_fromriscv_intr_handler(void *param)
@@ -1006,6 +1013,8 @@ zxdh_dev_start(struct rte_eth_dev *dev)
 		vq = hw->vqs[logic_qidx];
 		zxdh_queue_notify(vq);
 	}
+	zxdh_dev_set_link_up(dev);
+
 	return 0;
 }
 
@@ -1020,6 +1029,9 @@ static const struct eth_dev_ops zxdh_eth_dev_ops = {
 	.tx_queue_setup			 = zxdh_dev_tx_queue_setup,
 	.rx_queue_intr_enable	 = zxdh_dev_rx_queue_intr_enable,
 	.rx_queue_intr_disable	 = zxdh_dev_rx_queue_intr_disable,
+	.link_update			 = zxdh_dev_link_update,
+	.dev_set_link_up		 = zxdh_dev_set_link_up,
+	.dev_set_link_down		 = zxdh_dev_set_link_down,
 };
 
 static int32_t
drivers/net/zxdh/zxdh_ethdev.h +2 -0
index b1f398b28e..c0b719062c 100644
@@ -72,6 +72,7 @@ struct zxdh_hw {
 	uint64_t guest_features;
 	uint32_t max_queue_pairs;
 	uint32_t speed;
+	uint32_t speed_mode;
 	uint32_t notify_off_multiplier;
 	uint16_t *notify_base;
 	uint16_t pcie_id;
@@ -93,6 +94,7 @@ struct zxdh_hw {
 	uint8_t panel_id;
 	uint8_t has_tx_offload;
 	uint8_t has_rx_offload;
+	uint8_t admin_status;
 };
 
 struct zxdh_dtb_shared_data {
drivers/net/zxdh/zxdh_ethdev_ops.c new file +166 -0

166 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev_ops.h new file +14 -0
new file mode 100644
index 0000000000..c6d6ca56fd
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 ZTE Corporation
+ */
+
+#ifndef ZXDH_ETHDEV_OPS_H
+#define ZXDH_ETHDEV_OPS_H
+
+#include "zxdh_ethdev.h"
+
+int zxdh_dev_set_link_up(struct rte_eth_dev *dev);
+int zxdh_dev_set_link_down(struct rte_eth_dev *dev);
+int32_t zxdh_dev_link_update(struct rte_eth_dev *dev, int32_t wait_to_complete __rte_unused);
+
+#endif /* ZXDH_ETHDEV_OPS_H */
drivers/net/zxdh/zxdh_msg.c +57 -0

66 lines not on this page · raw message

drivers/net/zxdh/zxdh_msg.h +40 -0
index 613ca71170..a78075c914 100644
@@ -164,11 +164,18 @@ enum pciebar_layout_type {
 	ZXDH_URI_MAX,
 };
 
+/* riscv msg opcodes */
+enum zxdh_agent_msg_type {
+	ZXDH_MAC_LINK_GET = 14,
+};
+
 enum zxdh_msg_type {
 	ZXDH_NULL = 0,
 	ZXDH_VF_PORT_INIT = 1,
 	ZXDH_VF_PORT_UNINIT = 2,
 
+	ZXDH_PORT_ATTRS_SET = 25,
+
 	ZXDH_MSG_TYPE_END,
 };
 
@@ -261,6 +268,15 @@ struct zxdh_offset_get_msg {
 	uint16_t type;
 };
 
+struct zxdh_link_info_msg {
+	uint8_t autoneg;
+	uint8_t link_state;
+	uint8_t blink_enable;
+	uint8_t duplex;
+	uint32_t speed_modes;
+	uint32_t speed;
+} __rte_packed;
+
 struct zxdh_msg_reply_head {
 	uint8_t flag;
 	uint16_t reps_len;
@@ -276,6 +292,7 @@ struct zxdh_msg_reply_body {
 	enum zxdh_reps_flag flag;
 	union {
 		uint8_t reply_data[ZXDH_MSG_REPLY_BODY_MAX_LEN - sizeof(enum zxdh_reps_flag)];
+		struct zxdh_link_info_msg link_msg;
 	} __rte_packed;
 } __rte_packed;
 
@@ -291,6 +308,12 @@ struct zxdh_vf_init_msg {
 	uint8_t rss_enable;
 } __rte_packed;
 
+struct zxdh_port_attr_set_msg {
+	uint32_t mode;
+	uint32_t value;
+	uint8_t allmulti_follow;
+} __rte_packed;
+
 struct zxdh_msg_head {
 	enum zxdh_msg_type msg_type;
 	uint16_t  vport;
@@ -298,14 +321,26 @@ struct zxdh_msg_head {
 	uint16_t pcieid;
 } __rte_packed;
 
+struct zxdh_agent_msg_head {
+	enum zxdh_agent_msg_type msg_type;
+	uint8_t panel_id;
+	uint8_t phyport;
+	uint8_t rsv;
+	uint16_t vf_id;
+	uint16_t pcie_id;
+} __rte_packed;
+
 struct zxdh_msg_info {
 	union {
 		uint8_t head_len[ZXDH_MSG_HEAD_LEN];
 		struct zxdh_msg_head msg_head;
+		struct zxdh_agent_msg_head agent_msg_head;
 	};
 	union {
 		uint8_t datainfo[ZXDH_MSG_REQ_BODY_MAX_LEN];
 		struct zxdh_vf_init_msg vf_init_msg;
+		struct zxdh_port_attr_set_msg port_attr_msg;
+		struct zxdh_link_info_msg link_msg;
 	} __rte_packed data;
 } __rte_packed;
 
@@ -326,5 +361,10 @@ void zxdh_msg_head_build(struct zxdh_hw *hw, enum zxdh_msg_type type,
 		struct zxdh_msg_info *msg_info);
 int zxdh_vf_send_msg_to_pf(struct rte_eth_dev *dev,  void *msg_req,
 			uint16_t msg_req_len, void *reply, uint16_t reply_len);
+void zxdh_agent_msg_build(struct zxdh_hw *hw, enum zxdh_agent_msg_type type,
+		struct zxdh_msg_info *msg_info);
+int32_t zxdh_send_msg_to_riscv(struct rte_eth_dev *dev, void *msg_req,
+			uint16_t msg_req_len, void *reply, uint16_t reply_len,
+			enum ZXDH_BAR_MODULE_ID module_id);
 
 #endif /* ZXDH_MSG_H */
drivers/net/zxdh/zxdh_np.c +166 -6

197 lines not on this page · raw message

drivers/net/zxdh/zxdh_np.h +20 -0
index 42a652dd6b..ac3931ba65 100644
@@ -514,11 +514,31 @@ typedef struct zxdh_sdt_tbl_data_t {
 	uint32_t data_low32;
 } ZXDH_SDT_TBL_DATA_T;
 
+typedef struct zxdh_sdt_tbl_etcam_t {
+	uint32_t table_type;
+	uint32_t etcam_id;
+	uint32_t etcam_key_mode;
+	uint32_t etcam_table_id;
+	uint32_t no_as_rsp_mode;
+	uint32_t as_en;
+	uint32_t as_eram_baddr;
+	uint32_t as_rsp_mode;
+	uint32_t etcam_table_depth;
+	uint32_t etcam_clutch_en;
+} ZXDH_SDTTBL_ETCAM_T;
+
+typedef struct zxdh_sdt_tbl_porttbl_t {
+	uint32_t table_type;
+	uint32_t porttbl_clutch_en;
+} ZXDH_SDTTBL_PORTTBL_T;
+
 int zxdh_np_host_init(uint32_t dev_id, ZXDH_DEV_INIT_CTRL_T *p_dev_init_ctrl);
 int zxdh_np_online_uninit(uint32_t dev_id, char *port_name, uint32_t queue_id);
 int zxdh_np_dtb_table_entry_write(uint32_t dev_id, uint32_t queue_id,
 			uint32_t entrynum, ZXDH_DTB_USER_ENTRY_T *down_entries);
 int zxdh_np_dtb_table_entry_delete(uint32_t dev_id, uint32_t queue_id,
 			 uint32_t entrynum, ZXDH_DTB_USER_ENTRY_T *delete_entries);
+int zxdh_np_dtb_table_entry_get(uint32_t dev_id, uint32_t queue_id,
+			ZXDH_DTB_USER_ENTRY_T *get_entry, uint32_t srh_mode);
 
 #endif /* ZXDH_NP_H */
drivers/net/zxdh/zxdh_tables.c +15 -0
index 9fd184e612..db0132ce3f 100644
@@ -134,3 +134,18 @@ int zxdh_panel_table_init(struct rte_eth_dev *dev)
 
 	return ret;
 }
+
+int
+zxdh_get_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr)
+{
+	int ret;
+
+	ZXDH_DTB_ERAM_ENTRY_INFO_T entry = {vfid, (uint32_t *)port_attr};
+	ZXDH_DTB_USER_ENTRY_T user_entry_get = {ZXDH_SDT_VPORT_ATT_TABLE, &entry};
+
+	ret = zxdh_np_dtb_table_entry_get(ZXDH_DEVICE_NO, g_dtb_data.queueid, &user_entry_get, 1);
+	if (ret != 0)
+		PMD_DRV_LOG(ERR, "get port_attr vfid:%d failed, ret:%d ", vfid, ret);
+
+	return ret;
+}
drivers/net/zxdh/zxdh_tables.h +4 -2
index 5e9b36faee..8676a8b375 100644
@@ -7,9 +7,10 @@
 
 #include <stdint.h>
 
-extern struct zxdh_dtb_shared_data g_dtb_data;
-
 #define ZXDH_DEVICE_NO                    0
+#define ZXDH_PORT_ATTR_IS_UP_FLAG         35
+
+extern struct zxdh_dtb_shared_data g_dtb_data;
 
 struct zxdh_port_attr_table {
 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
@@ -145,5 +146,6 @@ int zxdh_port_attr_init(struct rte_eth_dev *dev);
 int zxdh_panel_table_init(struct rte_eth_dev *dev);
 int zxdh_set_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr);
 int zxdh_port_attr_uninit(struct rte_eth_dev *dev);
+int zxdh_get_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr);
 
 #endif /* ZXDH_TABLES_H */
Signature · 1 line
2.27.0
#63 lore raw

PATCH v3 10/15 net/zxdh: mac set/add/remove ops implementations

In reply to Junlong Wang

provided mac set/add/remove ops.

---
 doc/guides/nics/features/zxdh.ini  |   2 +
 doc/guides/nics/zxdh.rst           |   2 +
 drivers/net/zxdh/zxdh_common.c     |  24 +++
 drivers/net/zxdh/zxdh_common.h     |   1 +
 drivers/net/zxdh/zxdh_ethdev.c     |  32 +++-
 drivers/net/zxdh/zxdh_ethdev.h     |   3 +
 drivers/net/zxdh/zxdh_ethdev_ops.c | 233 +++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |   4 +
 drivers/net/zxdh/zxdh_msg.h        |  12 ++
 drivers/net/zxdh/zxdh_np.h         |   5 +
 drivers/net/zxdh/zxdh_tables.c     | 197 ++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_tables.h     |  36 +++++
 12 files changed, 549 insertions(+), 2 deletions(-)
doc/guides/nics/features/zxdh.ini +2 -0
index 7da3aaced1..dc09fe3453 100644
@@ -12,3 +12,5 @@ Multiprocess aware   = Y
 Scattered Rx         = Y
 Link status          = Y
 Link status event    = Y
+Unicast MAC filter   = Y
+Multicast MAC filter = Y
doc/guides/nics/zxdh.rst +2 -0
index fdbc3b3923..e0b0776aca 100644
@@ -24,6 +24,8 @@ Features of the ZXDH PMD are:
 - Link Auto-negotiation
 - Link state information
 - Set Link down or up
+- Unicast MAC filter
+- Multicast MAC filter
 
 
 Driver compilation and testing
drivers/net/zxdh/zxdh_common.c +24 -0
index 4f18c97ed7..75883a8897 100644
@@ -256,6 +256,30 @@ zxdh_panelid_get(struct rte_eth_dev *dev, uint8_t *panelid)
 	return ret;
 }
 
+static int
+zxdh_get_res_hash_id(struct zxdh_res_para *in, uint8_t *hash_id)
+{
+	uint8_t reps = 0;
+	uint16_t reps_len = 0;
+
+	if (zxdh_get_res_info(in, ZXDH_TBL_FIELD_HASHID, &reps, &reps_len) != ZXDH_BAR_MSG_OK)
+		return -1;
+
+	*hash_id = reps;
+	return ZXDH_BAR_MSG_OK;
+}
+
+int32_t
+zxdh_hashidx_get(struct rte_eth_dev *dev, uint8_t *hash_idx)
+{
+	struct zxdh_res_para param;
+
+	zxdh_fill_res_para(dev, &param);
+	int32_t ret = zxdh_get_res_hash_id(&param, hash_idx);
+
+	return ret;
+}
+
 uint32_t
 zxdh_read_bar_reg(struct rte_eth_dev *dev, uint32_t bar, uint32_t reg)
 {
drivers/net/zxdh/zxdh_common.h +1 -0
index 72c29e1522..826f1fb95d 100644
@@ -22,6 +22,7 @@ struct zxdh_res_para {
 
 int32_t zxdh_phyport_get(struct rte_eth_dev *dev, uint8_t *phyport);
 int32_t zxdh_panelid_get(struct rte_eth_dev *dev, uint8_t *pannelid);
+int32_t zxdh_hashidx_get(struct rte_eth_dev *dev, uint8_t *hash_idx);
 uint32_t zxdh_read_bar_reg(struct rte_eth_dev *dev, uint32_t bar, uint32_t reg);
 void zxdh_write_bar_reg(struct rte_eth_dev *dev, uint32_t bar, uint32_t reg, uint32_t val);
 void zxdh_release_lock(struct zxdh_hw *hw);
drivers/net/zxdh/zxdh_ethdev.c +30 -2
index d3876ec9b3..85ada87cdc 100644
@@ -979,6 +979,23 @@ zxdh_set_rxtx_funcs(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
+static int
+zxdh_mac_config(struct rte_eth_dev *eth_dev)
+{
+	struct zxdh_hw *hw = eth_dev->data->dev_private;
+	int ret = 0;
+
+	if (hw->is_pf) {
+		ret = zxdh_set_mac_table(hw->vport.vport,
+				&eth_dev->data->mac_addrs[0], hw->hash_search_index);
+		if (ret) {
+			PMD_DRV_LOG(ERR, "Failed to add mac: port 0x%x", hw->vport.vport);
+			return ret;
+		}
+	}
+	return ret;
+}
+
 static int
 zxdh_dev_start(struct rte_eth_dev *dev)
 {
@@ -1014,6 +1031,9 @@ zxdh_dev_start(struct rte_eth_dev *dev)
 		zxdh_queue_notify(vq);
 	}
 	zxdh_dev_set_link_up(dev);
+	ret = zxdh_mac_config(hw->eth_dev);
+	if (ret)
+		PMD_DRV_LOG(ERR, " mac config failed");
 
 	return 0;
 }
@@ -1032,6 +1052,9 @@ static const struct eth_dev_ops zxdh_eth_dev_ops = {
 	.link_update			 = zxdh_dev_link_update,
 	.dev_set_link_up		 = zxdh_dev_set_link_up,
 	.dev_set_link_down		 = zxdh_dev_set_link_down,
+	.mac_addr_add			 = zxdh_dev_mac_addr_add,
+	.mac_addr_remove		 = zxdh_dev_mac_addr_remove,
+	.mac_addr_set			 = zxdh_dev_mac_addr_set,
 };
 
 static int32_t
@@ -1073,15 +1096,20 @@ zxdh_agent_comm(struct rte_eth_dev *eth_dev, struct zxdh_hw *hw)
 		PMD_DRV_LOG(ERR, "Failed to get phyport");
 		return -1;
 	}
-	PMD_DRV_LOG(INFO, "Get phyport success: 0x%x", hw->phyport);
+	PMD_DRV_LOG(DEBUG, "Get phyport success: 0x%x", hw->phyport);
 
 	hw->vfid = zxdh_vport_to_vfid(hw->vport);
 
+	if (zxdh_hashidx_get(eth_dev, &hw->hash_search_index) != 0) {
+		PMD_DRV_LOG(ERR, "Failed to get hash idx");
+		return -1;
+	}
+
 	if (zxdh_panelid_get(eth_dev, &hw->panel_id) != 0) {
 		PMD_DRV_LOG(ERR, "Failed to get panel_id");
 		return -1;
 	}
-	PMD_DRV_LOG(INFO, "Get panel id success: 0x%x", hw->panel_id);
+	PMD_DRV_LOG(DEBUG, "Get panel id success: 0x%x", hw->panel_id);
 
 	return 0;
 }
drivers/net/zxdh/zxdh_ethdev.h +3 -0
index c0b719062c..5b95cb1c2a 100644
@@ -80,6 +80,8 @@ struct zxdh_hw {
 	uint16_t port_id;
 	uint16_t vfid;
 	uint16_t queue_num;
+	uint16_t mc_num;
+	uint16_t uc_num;
 
 	uint8_t *isr;
 	uint8_t weak_barriers;
@@ -92,6 +94,7 @@ struct zxdh_hw {
 	uint8_t msg_chan_init;
 	uint8_t phyport;
 	uint8_t panel_id;
+	uint8_t hash_search_index;
 	uint8_t has_tx_offload;
 	uint8_t has_rx_offload;
 	uint8_t admin_status;
drivers/net/zxdh/zxdh_ethdev_ops.c +233 -0

236 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev_ops.h +4 -0
index c6d6ca56fd..4630bb70db 100644
@@ -10,5 +10,9 @@
 int zxdh_dev_set_link_up(struct rte_eth_dev *dev);
 int zxdh_dev_set_link_down(struct rte_eth_dev *dev);
 int32_t zxdh_dev_link_update(struct rte_eth_dev *dev, int32_t wait_to_complete __rte_unused);
+int zxdh_dev_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr,
+		uint32_t index, uint32_t vmdq);
+int zxdh_dev_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr);
+void zxdh_dev_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);
 
 #endif /* ZXDH_ETHDEV_OPS_H */
drivers/net/zxdh/zxdh_msg.h +12 -0
index a78075c914..44ce5d1b7f 100644
@@ -46,6 +46,9 @@
 #define ZXDH_MSG_REQ_BODY_MAX_LEN  \
 		(ZXDH_MSG_PAYLOAD_MAX_LEN - ZXDH_MSG_HEAD_LEN)
 
+#define ZXDH_MAC_FILTER            0xaa
+#define ZXDH_MAC_UNFILTER          0xff
+
 enum ZXDH_DRIVER_TYPE {
 	ZXDH_MSG_CHAN_END_MPF = 0,
 	ZXDH_MSG_CHAN_END_PF,
@@ -173,6 +176,8 @@ enum zxdh_msg_type {
 	ZXDH_NULL = 0,
 	ZXDH_VF_PORT_INIT = 1,
 	ZXDH_VF_PORT_UNINIT = 2,
+	ZXDH_MAC_ADD = 3,
+	ZXDH_MAC_DEL = 4,
 
 	ZXDH_PORT_ATTRS_SET = 25,
 
@@ -314,6 +319,12 @@ struct zxdh_port_attr_set_msg {
 	uint8_t allmulti_follow;
 } __rte_packed;
 
+struct zxdh_mac_filter {
+	uint8_t mac_flag;
+	uint8_t filter_flag;
+	struct rte_ether_addr mac;
+} __rte_packed;
+
 struct zxdh_msg_head {
 	enum zxdh_msg_type msg_type;
 	uint16_t  vport;
@@ -341,6 +352,7 @@ struct zxdh_msg_info {
 		struct zxdh_vf_init_msg vf_init_msg;
 		struct zxdh_port_attr_set_msg port_attr_msg;
 		struct zxdh_link_info_msg link_msg;
+		struct zxdh_mac_filter mac_filter_msg;
 	} __rte_packed data;
 } __rte_packed;
 
drivers/net/zxdh/zxdh_np.h +5 -0
index ac3931ba65..19d1f03f59 100644
@@ -532,6 +532,11 @@ typedef struct zxdh_sdt_tbl_porttbl_t {
 	uint32_t porttbl_clutch_en;
 } ZXDH_SDTTBL_PORTTBL_T;
 
+typedef struct zxdh_dtb_hash_entry_info_t {
+	uint8_t *p_actu_key;
+	uint8_t *p_rst;
+} ZXDH_DTB_HASH_ENTRY_INFO_T;
+
 int zxdh_np_host_init(uint32_t dev_id, ZXDH_DEV_INIT_CTRL_T *p_dev_init_ctrl);
 int zxdh_np_online_uninit(uint32_t dev_id, char *port_name, uint32_t queue_id);
 int zxdh_np_dtb_table_entry_write(uint32_t dev_id, uint32_t queue_id,
drivers/net/zxdh/zxdh_tables.c +197 -0

206 lines not on this page · raw message

drivers/net/zxdh/zxdh_tables.h +36 -0
index 8676a8b375..f16c4923ef 100644
@@ -142,10 +142,46 @@ struct zxdh_panel_table {
 	uint32_t rsv_2;
 }; /* 16B */
 
+struct zxdh_mac_unicast_key {
+	uint16_t rsv;
+	uint8_t  dmac_addr[6];
+};
+
+struct zxdh_mac_unicast_entry {
+	uint8_t rsv1     : 7,
+			hit_flag : 1;
+	uint8_t rsv;
+	uint16_t vfid;
+};
+
+struct zxdh_mac_unicast_table {
+	struct zxdh_mac_unicast_key key;
+	struct zxdh_mac_unicast_entry entry;
+};
+
+struct zxdh_mac_multicast_key {
+	uint8_t rsv;
+	uint8_t vf_group_id;
+	uint8_t mac_addr[6];
+};
+
+struct zxdh_mac_multicast_entry {
+	uint32_t mc_pf_enable;
+	uint32_t rsv1;
+	uint32_t mc_bitmap[2];
+};
+
+struct zxdh_mac_multicast_table {
+	struct zxdh_mac_multicast_key key;
+	struct zxdh_mac_multicast_entry entry;
+};
+
 int zxdh_port_attr_init(struct rte_eth_dev *dev);
 int zxdh_panel_table_init(struct rte_eth_dev *dev);
 int zxdh_set_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr);
 int zxdh_port_attr_uninit(struct rte_eth_dev *dev);
 int zxdh_get_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr);
+int zxdh_set_mac_table(uint16_t vport, struct rte_ether_addr *addr,  uint8_t hash_search_idx);
+int zxdh_del_mac_table(uint16_t vport, struct rte_ether_addr *addr,  uint8_t hash_search_idx);
 
 #endif /* ZXDH_TABLES_H */
Signature · 1 line
2.27.0
#64 lore raw

PATCH v3 11/15 net/zxdh: promisc/allmulti ops implementations

In reply to Junlong Wang

provided promiscuous/allmulticast ops.

---
 doc/guides/nics/features/zxdh.ini  |   2 +
 doc/guides/nics/zxdh.rst           |   2 +
 drivers/net/zxdh/zxdh_ethdev.c     |  21 ++-
 drivers/net/zxdh/zxdh_ethdev.h     |   2 +
 drivers/net/zxdh/zxdh_ethdev_ops.c | 132 +++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |   4 +
 drivers/net/zxdh/zxdh_msg.h        |  10 ++
 drivers/net/zxdh/zxdh_tables.c     | 223 +++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_tables.h     |  22 +++
 9 files changed, 417 insertions(+), 1 deletion(-)
doc/guides/nics/features/zxdh.ini +2 -0
index dc09fe3453..e9b237e102 100644
@@ -14,3 +14,5 @@ Link status          = Y
 Link status event    = Y
 Unicast MAC filter   = Y
 Multicast MAC filter = Y
+Promiscuous mode     = Y
+Allmulticast mode    = Y
doc/guides/nics/zxdh.rst +2 -0
index e0b0776aca..0399df1302 100644
@@ -26,6 +26,8 @@ Features of the ZXDH PMD are:
 - Set Link down or up
 - Unicast MAC filter
 - Multicast MAC filter
+- Promiscuous mode
+- Multicast mode
 
 
 Driver compilation and testing
drivers/net/zxdh/zxdh_ethdev.c +20 -1
index 85ada87cdc..1d64b877c1 100644
@@ -901,8 +901,16 @@ zxdh_tables_uninit(struct rte_eth_dev *dev)
 	int ret;
 
 	ret = zxdh_port_attr_uninit(dev);
-	if (ret)
+	if (ret) {
 		PMD_DRV_LOG(ERR, "zxdh_port_attr_uninit failed");
+		return ret;
+	}
+
+	ret = zxdh_promisc_table_uninit(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "uninit promisc_table failed");
+		return ret;
+	}
 
 	return ret;
 }
@@ -1055,6 +1063,10 @@ static const struct eth_dev_ops zxdh_eth_dev_ops = {
 	.mac_addr_add			 = zxdh_dev_mac_addr_add,
 	.mac_addr_remove		 = zxdh_dev_mac_addr_remove,
 	.mac_addr_set			 = zxdh_dev_mac_addr_set,
+	.promiscuous_enable		 = zxdh_dev_promiscuous_enable,
+	.promiscuous_disable	 = zxdh_dev_promiscuous_disable,
+	.allmulticast_enable	 = zxdh_dev_allmulticast_enable,
+	.allmulticast_disable	 = zxdh_dev_allmulticast_disable,
 };
 
 static int32_t
@@ -1306,6 +1318,13 @@ zxdh_tables_init(struct rte_eth_dev *dev)
 		PMD_DRV_LOG(ERR, " panel table init failed");
 		return ret;
 	}
+
+	ret = zxdh_promisc_table_init(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "promisc_table_init failed");
+		return ret;
+	}
+
 	return ret;
 }
 
drivers/net/zxdh/zxdh_ethdev.h +2 -0
index 5b95cb1c2a..3cdac5de73 100644
@@ -98,6 +98,8 @@ struct zxdh_hw {
 	uint8_t has_tx_offload;
 	uint8_t has_rx_offload;
 	uint8_t admin_status;
+	uint8_t promisc_status;
+	uint8_t allmulti_status;
 };
 
 struct zxdh_dtb_shared_data {
drivers/net/zxdh/zxdh_ethdev_ops.c +132 -0

135 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev_ops.h +4 -0
index 4630bb70db..394ddedc0e 100644
@@ -14,5 +14,9 @@ int zxdh_dev_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac_ad
 		uint32_t index, uint32_t vmdq);
 int zxdh_dev_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr);
 void zxdh_dev_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);
+int zxdh_dev_promiscuous_enable(struct rte_eth_dev *dev);
+int zxdh_dev_promiscuous_disable(struct rte_eth_dev *dev);
+int zxdh_dev_allmulticast_enable(struct rte_eth_dev *dev);
+int zxdh_dev_allmulticast_disable(struct rte_eth_dev *dev);
 
 #endif /* ZXDH_ETHDEV_OPS_H */
drivers/net/zxdh/zxdh_msg.h +10 -0
index 44ce5d1b7f..2abf579a80 100644
@@ -48,6 +48,8 @@
 
 #define ZXDH_MAC_FILTER            0xaa
 #define ZXDH_MAC_UNFILTER          0xff
+#define ZXDH_PROMISC_MODE          1
+#define ZXDH_ALLMULTI_MODE         2
 
 enum ZXDH_DRIVER_TYPE {
 	ZXDH_MSG_CHAN_END_MPF = 0,
@@ -180,6 +182,7 @@ enum zxdh_msg_type {
 	ZXDH_MAC_DEL = 4,
 
 	ZXDH_PORT_ATTRS_SET = 25,
+	ZXDH_PORT_PROMISC_SET = 26,
 
 	ZXDH_MSG_TYPE_END,
 };
@@ -325,6 +328,12 @@ struct zxdh_mac_filter {
 	struct rte_ether_addr mac;
 } __rte_packed;
 
+struct zxdh_port_promisc_msg {
+	uint8_t mode;
+	uint8_t value;
+	uint8_t mc_follow;
+} __rte_packed;
+
 struct zxdh_msg_head {
 	enum zxdh_msg_type msg_type;
 	uint16_t  vport;
@@ -353,6 +362,7 @@ struct zxdh_msg_info {
 		struct zxdh_port_attr_set_msg port_attr_msg;
 		struct zxdh_link_info_msg link_msg;
 		struct zxdh_mac_filter mac_filter_msg;
+		struct zxdh_port_promisc_msg port_promisc_msg;
 	} __rte_packed data;
 } __rte_packed;
 
drivers/net/zxdh/zxdh_tables.c +223 -0

236 lines not on this page · raw message

drivers/net/zxdh/zxdh_tables.h +22 -0
index f16c4923ef..0a1ddf7d9e 100644
@@ -176,12 +176,34 @@ struct zxdh_mac_multicast_table {
 	struct zxdh_mac_multicast_entry entry;
 };
 
+struct zxdh_brocast_table {
+	uint32_t flag;
+	uint32_t rsv;
+	uint32_t bitmap[2];
+};
+
+struct zxdh_unitcast_table {
+	uint32_t uc_flood_pf_enable;
+	uint32_t rsv;
+	uint32_t bitmap[2];
+};
+
+struct zxdh_multicast_table {
+	uint32_t mc_flood_pf_enable;
+	uint32_t rsv;
+	uint32_t bitmap[2];
+};
+
 int zxdh_port_attr_init(struct rte_eth_dev *dev);
 int zxdh_panel_table_init(struct rte_eth_dev *dev);
 int zxdh_set_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr);
 int zxdh_port_attr_uninit(struct rte_eth_dev *dev);
+int zxdh_promisc_table_init(struct rte_eth_dev *dev);
+int zxdh_promisc_table_uninit(struct rte_eth_dev *dev);
 int zxdh_get_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr);
 int zxdh_set_mac_table(uint16_t vport, struct rte_ether_addr *addr,  uint8_t hash_search_idx);
 int zxdh_del_mac_table(uint16_t vport, struct rte_ether_addr *addr,  uint8_t hash_search_idx);
+int zxdh_dev_unicast_table_set(struct zxdh_hw *hw, uint16_t vport, bool enable);
+int zxdh_dev_multicast_table_set(struct zxdh_hw *hw, uint16_t vport, bool enable);
 
 #endif /* ZXDH_TABLES_H */
Signature · 1 line
2.27.0
#65 lore raw

PATCH v3 12/15 net/zxdh: vlan filter/ offload ops implementations

In reply to Junlong Wang

provided vlan filter, vlan offload ops.

---
 doc/guides/nics/features/zxdh.ini  |   3 +
 doc/guides/nics/zxdh.rst           |   3 +
 drivers/net/zxdh/zxdh_ethdev.c     |  40 +++++-
 drivers/net/zxdh/zxdh_ethdev_ops.c | 223 +++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |   2 +
 drivers/net/zxdh/zxdh_msg.h        |  22 +++
 drivers/net/zxdh/zxdh_rxtx.c       |  18 +++
 drivers/net/zxdh/zxdh_tables.c     |  99 +++++++++++++
 drivers/net/zxdh/zxdh_tables.h     |  10 +-
 9 files changed, 417 insertions(+), 3 deletions(-)
doc/guides/nics/features/zxdh.ini +3 -0
index e9b237e102..6fb006c2da 100644
@@ -16,3 +16,6 @@ Unicast MAC filter   = Y
 Multicast MAC filter = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
+VLAN filter          = Y
+VLAN offload         = Y
+QinQ offload         = Y
doc/guides/nics/zxdh.rst +3 -0
index 0399df1302..3a7585d123 100644
@@ -28,6 +28,9 @@ Features of the ZXDH PMD are:
 - Multicast MAC filter
 - Promiscuous mode
 - Multicast mode
+- VLAN filter and VLAN offload
+- VLAN stripping and inserting
+- QINQ stripping and inserting
 
 
 Driver compilation and testing
drivers/net/zxdh/zxdh_ethdev.c +39 -1
index 1d64b877c1..cc32b467a9 100644
@@ -758,6 +758,34 @@ zxdh_alloc_queues(struct rte_eth_dev *dev, uint16_t nr_vq)
 	return 0;
 }
 
+static int
+zxdh_vlan_offload_configure(struct rte_eth_dev *dev)
+{
+	int ret;
+	int mask = RTE_ETH_VLAN_STRIP_MASK | RTE_ETH_VLAN_FILTER_MASK |	RTE_ETH_QINQ_STRIP_MASK;
+
+	ret = zxdh_dev_vlan_offload_set(dev, mask);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "vlan offload set error");
+		return -1;
+	}
+
+	return 0;
+}
+
+static int
+zxdh_dev_conf_offload(struct rte_eth_dev *dev)
+{
+	int ret = 0;
+
+	ret = zxdh_vlan_offload_configure(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "zxdh_vlan_offload_configure failed");
+		return ret;
+	}
+
+	return 0;
+}
 
 static int32_t
 zxdh_dev_configure(struct rte_eth_dev *dev)
@@ -815,7 +843,7 @@ zxdh_dev_configure(struct rte_eth_dev *dev)
 
 	nr_vq = dev->data->nb_rx_queues + dev->data->nb_tx_queues;
 	if (nr_vq == hw->queue_num)
-		return 0;
+		goto end;
 
 	PMD_DRV_LOG(DEBUG, "queue changed need reset ");
 	/* Reset the device although not necessary at startup */
@@ -847,6 +875,8 @@ zxdh_dev_configure(struct rte_eth_dev *dev)
 
 	zxdh_pci_reinit_complete(hw);
 
+end:
+	zxdh_dev_conf_offload(dev);
 	return ret;
 }
 
@@ -1067,6 +1097,8 @@ static const struct eth_dev_ops zxdh_eth_dev_ops = {
 	.promiscuous_disable	 = zxdh_dev_promiscuous_disable,
 	.allmulticast_enable	 = zxdh_dev_allmulticast_enable,
 	.allmulticast_disable	 = zxdh_dev_allmulticast_disable,
+	.vlan_filter_set		 = zxdh_dev_vlan_filter_set,
+	.vlan_offload_set		 = zxdh_dev_vlan_offload_set,
 };
 
 static int32_t
@@ -1325,6 +1357,12 @@ zxdh_tables_init(struct rte_eth_dev *dev)
 		return ret;
 	}
 
+	ret = zxdh_vlan_filter_table_init(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, " vlan filter table init failed");
+		return ret;
+	}
+
 	return ret;
 }
 
drivers/net/zxdh/zxdh_ethdev_ops.c +223 -0

238 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev_ops.h +2 -0
index 394ddedc0e..058d271ab3 100644
@@ -18,5 +18,7 @@ int zxdh_dev_promiscuous_enable(struct rte_eth_dev *dev);
 int zxdh_dev_promiscuous_disable(struct rte_eth_dev *dev);
 int zxdh_dev_allmulticast_enable(struct rte_eth_dev *dev);
 int zxdh_dev_allmulticast_disable(struct rte_eth_dev *dev);
+int zxdh_dev_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on);
+int zxdh_dev_vlan_offload_set(struct rte_eth_dev *dev, int mask);
 
 #endif /* ZXDH_ETHDEV_OPS_H */
drivers/net/zxdh/zxdh_msg.h +22 -0
index 2abf579a80..ec15388f7a 100644
@@ -50,6 +50,8 @@
 #define ZXDH_MAC_UNFILTER          0xff
 #define ZXDH_PROMISC_MODE          1
 #define ZXDH_ALLMULTI_MODE         2
+#define ZXDH_VLAN_STRIP_MSG_TYPE   0
+#define ZXDH_QINQ_STRIP_MSG_TYPE   1
 
 enum ZXDH_DRIVER_TYPE {
 	ZXDH_MSG_CHAN_END_MPF = 0,
@@ -180,6 +182,10 @@ enum zxdh_msg_type {
 	ZXDH_VF_PORT_UNINIT = 2,
 	ZXDH_MAC_ADD = 3,
 	ZXDH_MAC_DEL = 4,
+	ZXDH_VLAN_FILTER_SET = 17,
+	ZXDH_VLAN_FILTER_ADD = 18,
+	ZXDH_VLAN_FILTER_DEL = 19,
+	ZXDH_VLAN_OFFLOAD = 21,
 
 	ZXDH_PORT_ATTRS_SET = 25,
 	ZXDH_PORT_PROMISC_SET = 26,
@@ -341,6 +347,19 @@ struct zxdh_msg_head {
 	uint16_t pcieid;
 } __rte_packed;
 
+struct zxdh_vlan_filter {
+	uint16_t vlan_id;
+};
+
+struct zxdh_vlan_filter_set {
+	uint8_t enable;
+};
+
+struct zxdh_vlan_offload {
+	uint8_t enable;
+	uint8_t type;
+} __rte_packed;
+
 struct zxdh_agent_msg_head {
 	enum zxdh_agent_msg_type msg_type;
 	uint8_t panel_id;
@@ -363,6 +382,9 @@ struct zxdh_msg_info {
 		struct zxdh_link_info_msg link_msg;
 		struct zxdh_mac_filter mac_filter_msg;
 		struct zxdh_port_promisc_msg port_promisc_msg;
+		struct zxdh_vlan_filter vlan_filter_msg;
+		struct zxdh_vlan_filter_set vlan_filter_set_msg;
+		struct zxdh_vlan_offload vlan_offload_msg;
 	} __rte_packed data;
 } __rte_packed;
 
drivers/net/zxdh/zxdh_rxtx.c +18 -0
index 00e926bab9..e36ba39423 100644
@@ -11,6 +11,9 @@
 #include "zxdh_pci.h"
 #include "zxdh_queue.h"
 
+#define ZXDH_SVLAN_TPID                       0x88a8
+#define ZXDH_CVLAN_TPID                       0x8100
+
 #define ZXDH_PKT_FORM_CPU                     0x20    /* 1-cpu 0-np */
 #define ZXDH_NO_IP_FRAGMENT                   0x2000  /* ip fragment flag */
 #define ZXDH_NO_IPID_UPDATE                   0x4000  /* ipid update flag */
@@ -21,6 +24,9 @@
 #define ZXDH_PI_L3TYPE_RSV                    0xC0
 #define ZXDH_PI_L3TYPE_MASK                   0xC0
 
+#define  ZXDH_PD_OFFLOAD_SVLAN_INSERT         (1 << 14)
+#define  ZXDH_PD_OFFLOAD_CVLAN_INSERT         (1 << 13)
+
 #define ZXDH_PCODE_MASK                       0x1F
 #define ZXDH_PCODE_IP_PKT_TYPE                0x01
 #define ZXDH_PCODE_TCP_PKT_TYPE               0x02
@@ -259,6 +265,18 @@ static void zxdh_xmit_fill_net_hdr(struct rte_mbuf *cookie,
 	hdr->pi_hdr.l3_offset = rte_be_to_cpu_16(l3_offset);
 	hdr->pi_hdr.l4_offset = rte_be_to_cpu_16(l3_offset + cookie->l3_len);
 
+	if (cookie->ol_flags & RTE_MBUF_F_TX_VLAN) {
+		ol_flag |= ZXDH_PD_OFFLOAD_CVLAN_INSERT;
+		hdr->pi_hdr.vlan_id = rte_be_to_cpu_16(cookie->vlan_tci);
+		hdr->pd_hdr.cvlan_insert =
+			rte_be_to_cpu_32((ZXDH_CVLAN_TPID << 16) | cookie->vlan_tci);
+	}
+	if (cookie->ol_flags & RTE_MBUF_F_TX_QINQ) {
+		ol_flag |= ZXDH_PD_OFFLOAD_SVLAN_INSERT;
+		hdr->pd_hdr.svlan_insert =
+			rte_be_to_cpu_32((ZXDH_SVLAN_TPID << 16) | cookie->vlan_tci_outer);
+	}
+
 	hdr->pd_hdr.ol_flag = rte_be_to_cpu_32(ol_flag);
 }
 
drivers/net/zxdh/zxdh_tables.c +99 -0

114 lines not on this page · raw message

drivers/net/zxdh/zxdh_tables.h +8 -2
index 0a1ddf7d9e..28d4f6f7cf 100644
@@ -43,7 +43,7 @@ struct zxdh_port_attr_table {
 	uint8_t rdma_offload_enable: 1;
 	uint8_t vlan_filter_enable: 1;
 	uint8_t vlan_strip_offload: 1;
-	uint8_t qinq_valn_strip_offload: 1;
+	uint8_t qinq_strip_offload: 1;
 	uint8_t rss_enable: 1;
 	uint8_t mtu_enable: 1;
 	uint8_t hit_flag: 1;
@@ -73,7 +73,7 @@ struct zxdh_port_attr_table {
 	uint8_t rdma_offload_enable: 1;
 	uint8_t vlan_filter_enable: 1;
 	uint8_t vlan_strip_offload: 1;
-	uint8_t qinq_valn_strip_offload: 1;
+	uint8_t qinq_strip_offload: 1;
 	uint8_t rss_enable: 1;
 	uint8_t mtu_enable: 1;
 	uint8_t hit_flag: 1;
@@ -194,6 +194,10 @@ struct zxdh_multicast_table {
 	uint32_t bitmap[2];
 };
 
+struct zxdh_vlan_filter_table {
+	uint32_t vlans[4];
+};
+
 int zxdh_port_attr_init(struct rte_eth_dev *dev);
 int zxdh_panel_table_init(struct rte_eth_dev *dev);
 int zxdh_set_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr);
@@ -205,5 +209,7 @@ int zxdh_set_mac_table(uint16_t vport, struct rte_ether_addr *addr,  uint8_t has
 int zxdh_del_mac_table(uint16_t vport, struct rte_ether_addr *addr,  uint8_t hash_search_idx);
 int zxdh_dev_unicast_table_set(struct zxdh_hw *hw, uint16_t vport, bool enable);
 int zxdh_dev_multicast_table_set(struct zxdh_hw *hw, uint16_t vport, bool enable);
+int zxdh_vlan_filter_table_init(struct rte_eth_dev *dev);
+int zxdh_vlan_filter_table_set(uint16_t vport, uint16_t vlan_id, uint8_t enable);
 
 #endif /* ZXDH_TABLES_H */
Signature · 1 line
2.27.0
#66 lore raw

PATCH v3 13/15 net/zxdh: rss hash config/update, reta update/get

In reply to Junlong Wang

provided rss hash config/update, reta update/get ops.

---
 doc/guides/nics/features/zxdh.ini  |   3 +
 doc/guides/nics/zxdh.rst           |   1 +
 drivers/net/zxdh/zxdh_ethdev.c     |  51 ++++
 drivers/net/zxdh/zxdh_ethdev.h     |   4 +-
 drivers/net/zxdh/zxdh_ethdev_ops.c | 410 +++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |  26 ++
 drivers/net/zxdh/zxdh_msg.h        |  22 ++
 drivers/net/zxdh/zxdh_tables.c     |  82 ++++++
 drivers/net/zxdh/zxdh_tables.h     |   7 +
 9 files changed, 605 insertions(+), 1 deletion(-)
doc/guides/nics/features/zxdh.ini +3 -0
index 6fb006c2da..415ca547d0 100644
@@ -19,3 +19,6 @@ Allmulticast mode    = Y
 VLAN filter          = Y
 VLAN offload         = Y
 QinQ offload         = Y
+RSS hash             = Y
+RSS reta update      = Y
+Inner RSS            = Y
doc/guides/nics/zxdh.rst +1 -0
index 3a7585d123..3cc6a1d348 100644
@@ -31,6 +31,7 @@ Features of the ZXDH PMD are:
 - VLAN filter and VLAN offload
 - VLAN stripping and inserting
 - QINQ stripping and inserting
+- Receive Side Scaling (RSS)
 
 
 Driver compilation and testing
drivers/net/zxdh/zxdh_ethdev.c +51 -0

78 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev.h +3 -1
index 3cdac5de73..bd4e1587c8 100644
@@ -82,7 +82,7 @@ struct zxdh_hw {
 	uint16_t queue_num;
 	uint16_t mc_num;
 	uint16_t uc_num;
-
+	uint16_t *rss_reta;
 	uint8_t *isr;
 	uint8_t weak_barriers;
 	uint8_t intr_enabled;
@@ -100,6 +100,8 @@ struct zxdh_hw {
 	uint8_t admin_status;
 	uint8_t promisc_status;
 	uint8_t allmulti_status;
+	uint8_t rss_enable;
+	uint8_t rss_init;
 };
 
 struct zxdh_dtb_shared_data {
drivers/net/zxdh/zxdh_ethdev_ops.c +410 -0

425 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev_ops.h +26 -0
index 058d271ab3..860716d079 100644
@@ -5,8 +5,25 @@
 #ifndef ZXDH_ETHDEV_OPS_H
 #define ZXDH_ETHDEV_OPS_H
 
+#include <rte_ether.h>
+
 #include "zxdh_ethdev.h"
 
+#define ZXDH_ETH_RSS_L2  RTE_ETH_RSS_L2_PAYLOAD
+#define ZXDH_ETH_RSS_IP \
+			(RTE_ETH_RSS_IPV4 | \
+			 RTE_ETH_RSS_FRAG_IPV4 | \
+			 RTE_ETH_RSS_IPV6 | \
+			 RTE_ETH_RSS_FRAG_IPV6)
+#define ZXDH_ETH_RSS_TCP    (RTE_ETH_RSS_NONFRAG_IPV4_TCP | RTE_ETH_RSS_NONFRAG_IPV6_TCP)
+#define ZXDH_ETH_RSS_UDP    (RTE_ETH_RSS_NONFRAG_IPV4_UDP | RTE_ETH_RSS_NONFRAG_IPV6_UDP)
+#define ZXDH_ETH_RSS_SCTP   (RTE_ETH_RSS_NONFRAG_IPV4_SCTP | RTE_ETH_RSS_NONFRAG_IPV6_SCTP)
+
+#define ZXDH_HF_F5_ETH       (ZXDH_ETH_RSS_TCP | ZXDH_ETH_RSS_UDP | ZXDH_ETH_RSS_SCTP)
+#define ZXDH_HF_F3_ETH        ZXDH_ETH_RSS_IP
+#define ZXDH_HF_MAC_VLAN_ETH  ZXDH_ETH_RSS_L2
+#define ZXDH_RSS_HF  ((ZXDH_HF_MAC_VLAN_ETH | ZXDH_HF_F3_ETH | ZXDH_HF_F5_ETH))
+
 int zxdh_dev_set_link_up(struct rte_eth_dev *dev);
 int zxdh_dev_set_link_down(struct rte_eth_dev *dev);
 int32_t zxdh_dev_link_update(struct rte_eth_dev *dev, int32_t wait_to_complete __rte_unused);
@@ -20,5 +37,14 @@ int zxdh_dev_allmulticast_enable(struct rte_eth_dev *dev);
 int zxdh_dev_allmulticast_disable(struct rte_eth_dev *dev);
 int zxdh_dev_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on);
 int zxdh_dev_vlan_offload_set(struct rte_eth_dev *dev, int mask);
+int zxdh_dev_rss_reta_update(struct rte_eth_dev *dev,
+			 struct rte_eth_rss_reta_entry64 *reta_conf,
+			 uint16_t reta_size);
+int zxdh_dev_rss_reta_query(struct rte_eth_dev *dev,
+			struct rte_eth_rss_reta_entry64 *reta_conf,
+			uint16_t reta_size);
+int zxdh_rss_hash_update(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf);
+int zxdh_rss_hash_conf_get(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf);
+int zxdh_rss_configure(struct rte_eth_dev *dev);
 
 #endif /* ZXDH_ETHDEV_OPS_H */
drivers/net/zxdh/zxdh_msg.h +22 -0
index ec15388f7a..45a9b10aa4 100644
@@ -182,6 +182,11 @@ enum zxdh_msg_type {
 	ZXDH_VF_PORT_UNINIT = 2,
 	ZXDH_MAC_ADD = 3,
 	ZXDH_MAC_DEL = 4,
+	ZXDH_RSS_ENABLE = 7,
+	ZXDH_RSS_RETA_SET = 8,
+	ZXDH_RSS_RETA_GET = 9,
+	ZXDH_RSS_HF_SET = 15,
+	ZXDH_RSS_HF_GET = 16,
 	ZXDH_VLAN_FILTER_SET = 17,
 	ZXDH_VLAN_FILTER_ADD = 18,
 	ZXDH_VLAN_FILTER_DEL = 19,
@@ -291,6 +296,14 @@ struct zxdh_link_info_msg {
 	uint32_t speed;
 } __rte_packed;
 
+struct zxdh_rss_reta {
+	uint32_t reta[RTE_ETH_RSS_RETA_SIZE_256];
+};
+
+struct zxdh_rss_hf {
+	uint32_t rss_hf;
+};
+
 struct zxdh_msg_reply_head {
 	uint8_t flag;
 	uint16_t reps_len;
@@ -307,6 +320,8 @@ struct zxdh_msg_reply_body {
 	union {
 		uint8_t reply_data[ZXDH_MSG_REPLY_BODY_MAX_LEN - sizeof(enum zxdh_reps_flag)];
 		struct zxdh_link_info_msg link_msg;
+		struct zxdh_rss_hf rss_hf;
+		struct zxdh_rss_reta rss_reta;
 	} __rte_packed;
 } __rte_packed;
 
@@ -360,6 +375,10 @@ struct zxdh_vlan_offload {
 	uint8_t type;
 } __rte_packed;
 
+struct zxdh_rss_enable {
+	uint8_t enable;
+};
+
 struct zxdh_agent_msg_head {
 	enum zxdh_agent_msg_type msg_type;
 	uint8_t panel_id;
@@ -385,6 +404,9 @@ struct zxdh_msg_info {
 		struct zxdh_vlan_filter vlan_filter_msg;
 		struct zxdh_vlan_filter_set vlan_filter_set_msg;
 		struct zxdh_vlan_offload vlan_offload_msg;
+		struct zxdh_rss_reta rss_reta;
+		struct zxdh_rss_enable rss_enable;
+		struct zxdh_rss_hf rss_hf;
 	} __rte_packed data;
 } __rte_packed;
 
drivers/net/zxdh/zxdh_tables.c +82 -0

91 lines not on this page · raw message

drivers/net/zxdh/zxdh_tables.h +7 -0
index 28d4f6f7cf..c8d1de3bbb 100644
@@ -8,6 +8,7 @@
 #include <stdint.h>
 
 #define ZXDH_DEVICE_NO                    0
+#define ZXDH_PORT_BASE_QID_FLAG           10
 #define ZXDH_PORT_ATTR_IS_UP_FLAG         35
 
 extern struct zxdh_dtb_shared_data g_dtb_data;
@@ -198,6 +199,10 @@ struct zxdh_vlan_filter_table {
 	uint32_t vlans[4];
 };
 
+struct zxdh_rss_to_vqid_table {
+	uint16_t vqm_qid[8];
+};
+
 int zxdh_port_attr_init(struct rte_eth_dev *dev);
 int zxdh_panel_table_init(struct rte_eth_dev *dev);
 int zxdh_set_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr);
@@ -211,5 +216,7 @@ int zxdh_dev_unicast_table_set(struct zxdh_hw *hw, uint16_t vport, bool enable);
 int zxdh_dev_multicast_table_set(struct zxdh_hw *hw, uint16_t vport, bool enable);
 int zxdh_vlan_filter_table_init(struct rte_eth_dev *dev);
 int zxdh_vlan_filter_table_set(uint16_t vport, uint16_t vlan_id, uint8_t enable);
+int zxdh_rss_table_set(uint16_t vport, struct zxdh_rss_reta *rss_reta);
+int zxdh_rss_table_get(uint16_t vport, struct zxdh_rss_reta *rss_reta);
 
 #endif /* ZXDH_TABLES_H */
Signature · 1 line
2.27.0
#67 lore raw

PATCH v3 14/15 net/zxdh: basic stats ops implementations

In reply to Junlong Wang

basic stats ops implementations.

---
 doc/guides/nics/features/zxdh.ini  |   2 +
 doc/guides/nics/zxdh.rst           |   1 +
 drivers/net/zxdh/zxdh_ethdev.c     |   2 +
 drivers/net/zxdh/zxdh_ethdev_ops.c | 353 +++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |  27 +++
 drivers/net/zxdh/zxdh_msg.h        |  16 ++
 drivers/net/zxdh/zxdh_np.c         | 341 ++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_np.h         |  30 +++
 drivers/net/zxdh/zxdh_queue.h      |   2 +
 drivers/net/zxdh/zxdh_rxtx.c       |  83 ++++++-
 drivers/net/zxdh/zxdh_tables.h     |   5 +
 11 files changed, 859 insertions(+), 3 deletions(-)
doc/guides/nics/features/zxdh.ini +2 -0
index 415ca547d0..98c141cf95 100644
@@ -22,3 +22,5 @@ QinQ offload         = Y
 RSS hash             = Y
 RSS reta update      = Y
 Inner RSS            = Y
+Basic stats          = Y
+Stats per queue      = Y
doc/guides/nics/zxdh.rst +1 -0
index 3cc6a1d348..c8a52b587c 100644
@@ -32,6 +32,7 @@ Features of the ZXDH PMD are:
 - VLAN stripping and inserting
 - QINQ stripping and inserting
 - Receive Side Scaling (RSS)
+- Port hardware statistics
 
 
 Driver compilation and testing
drivers/net/zxdh/zxdh_ethdev.c +2 -0
index 17fca8e909..0326d143ec 100644
@@ -1150,6 +1150,8 @@ static const struct eth_dev_ops zxdh_eth_dev_ops = {
 	.reta_query				 = zxdh_dev_rss_reta_query,
 	.rss_hash_update		 = zxdh_rss_hash_update,
 	.rss_hash_conf_get		 = zxdh_rss_hash_conf_get,
+	.stats_get				 = zxdh_dev_stats_get,
+	.stats_reset			 = zxdh_dev_stats_reset,
 };
 
 static int32_t
drivers/net/zxdh/zxdh_ethdev_ops.c +353 -0

368 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev_ops.h +27 -0
index 860716d079..f35378e691 100644
@@ -5,6 +5,8 @@
 #ifndef ZXDH_ETHDEV_OPS_H
 #define ZXDH_ETHDEV_OPS_H
 
+#include <stdint.h>
+
 #include <rte_ether.h>
 
 #include "zxdh_ethdev.h"
@@ -24,6 +26,29 @@
 #define ZXDH_HF_MAC_VLAN_ETH  ZXDH_ETH_RSS_L2
 #define ZXDH_RSS_HF  ((ZXDH_HF_MAC_VLAN_ETH | ZXDH_HF_F3_ETH | ZXDH_HF_F5_ETH))
 
+struct zxdh_hw_vqm_stats {
+	uint64_t rx_total;
+	uint64_t tx_total;
+	uint64_t rx_bytes;
+	uint64_t tx_bytes;
+	uint64_t rx_error;
+	uint64_t tx_error;
+	uint64_t rx_drop;
+} __rte_packed;
+
+struct zxdh_hw_np_stats {
+	uint64_t np_rx_broadcast;
+	uint64_t np_tx_broadcast;
+	uint64_t np_rx_mtu_drop_pkts;
+	uint64_t np_tx_mtu_drop_pkts;
+	uint64_t np_rx_mtu_drop_bytes;
+	uint64_t np_tx_mtu_drop_bytes;
+	uint64_t np_rx_mtr_drop_pkts;
+	uint64_t np_tx_mtr_drop_pkts;
+	uint64_t np_rx_mtr_drop_bytes;
+	uint64_t np_tx_mtr_drop_bytes;
+};
+
 int zxdh_dev_set_link_up(struct rte_eth_dev *dev);
 int zxdh_dev_set_link_down(struct rte_eth_dev *dev);
 int32_t zxdh_dev_link_update(struct rte_eth_dev *dev, int32_t wait_to_complete __rte_unused);
@@ -46,5 +71,7 @@ int zxdh_dev_rss_reta_query(struct rte_eth_dev *dev,
 int zxdh_rss_hash_update(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf);
 int zxdh_rss_hash_conf_get(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf);
 int zxdh_rss_configure(struct rte_eth_dev *dev);
+int zxdh_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats);
+int zxdh_dev_stats_reset(struct rte_eth_dev *dev);
 
 #endif /* ZXDH_ETHDEV_OPS_H */
drivers/net/zxdh/zxdh_msg.h +16 -0
index 45a9b10aa4..159c8c9c71 100644
@@ -9,10 +9,16 @@
 
 #include <ethdev_driver.h>
 
+#include "zxdh_ethdev_ops.h"
+
 #define ZXDH_BAR0_INDEX                 0
 #define ZXDH_CTRLCH_OFFSET              (0x2000)
 #define ZXDH_MSG_CHAN_PFVFSHARE_OFFSET  (ZXDH_CTRLCH_OFFSET + 0x1000)
 
+#define ZXDH_MAC_OFFSET                 (0x24000)
+#define ZXDH_MAC_STATS_OFFSET           (0x1408)
+#define ZXDH_MAC_BYTES_OFFSET           (0xb000)
+
 #define ZXDH_MSIX_INTR_MSG_VEC_BASE   1
 #define ZXDH_MSIX_INTR_MSG_VEC_NUM    3
 #define ZXDH_MSIX_INTR_DTB_VEC        (ZXDH_MSIX_INTR_MSG_VEC_BASE + ZXDH_MSIX_INTR_MSG_VEC_NUM)
@@ -173,7 +179,13 @@ enum pciebar_layout_type {
 
 /* riscv msg opcodes */
 enum zxdh_agent_msg_type {
+	ZXDH_MAC_STATS_GET = 10,
+	ZXDH_MAC_STATS_RESET,
 	ZXDH_MAC_LINK_GET = 14,
+	ZXDH_VQM_DEV_STATS_GET = 21,
+	ZXDH_VQM_DEV_STATS_RESET,
+	ZXDH_VQM_QUEUE_STATS_GET = 24,
+	ZXDH_VQM_QUEUE_STATS_RESET,
 };
 
 enum zxdh_msg_type {
@@ -195,6 +207,8 @@ enum zxdh_msg_type {
 	ZXDH_PORT_ATTRS_SET = 25,
 	ZXDH_PORT_PROMISC_SET = 26,
 
+	ZXDH_GET_NP_STATS = 31,
+
 	ZXDH_MSG_TYPE_END,
 };
 
@@ -322,6 +336,8 @@ struct zxdh_msg_reply_body {
 		struct zxdh_link_info_msg link_msg;
 		struct zxdh_rss_hf rss_hf;
 		struct zxdh_rss_reta rss_reta;
+		struct zxdh_hw_vqm_stats vqm_stats;
+		struct zxdh_hw_np_stats np_stats;
 	} __rte_packed;
 } __rte_packed;
 
drivers/net/zxdh/zxdh_np.c +341 -0

356 lines not on this page · raw message

drivers/net/zxdh/zxdh_np.h +30 -0
index 19d1f03f59..7da29cf7bd 100644
@@ -432,6 +432,18 @@ typedef enum zxdh_sdt_table_type_e {
 	ZXDH_SDT_TBLT_MAX     = 7,
 } ZXDH_SDT_TABLE_TYPE_E;
 
+typedef enum zxdh_dtb_dir_type_e {
+	ZXDH_DTB_DIR_DOWN_TYPE    = 0,
+	ZXDH_DTB_DIR_UP_TYPE    = 1,
+	ZXDH_DTB_DIR_TYPE_MAX,
+} ZXDH_DTB_DIR_TYPE_E;
+
+typedef enum zxdh_dtb_tab_up_user_addr_type_e {
+	ZXDH_DTB_TAB_UP_NOUSER_ADDR_TYPE     = 0,
+	ZXDH_DTB_TAB_UP_USER_ADDR_TYPE       = 1,
+	ZXDH_DTB_TAB_UP_USER_ADDR_TYPE_MAX,
+} ZXDH_DTB_TAB_UP_USER_ADDR_TYPE_E;
+
 typedef struct zxdh_dtb_lpm_entry_t {
 	uint32_t dtb_len0;
 	uint8_t *p_data_buff0;
@@ -537,6 +549,19 @@ typedef struct zxdh_dtb_hash_entry_info_t {
 	uint8_t *p_rst;
 } ZXDH_DTB_HASH_ENTRY_INFO_T;
 
+typedef struct zxdh_ppu_stat_cfg_t {
+	uint32_t eram_baddr;
+	uint32_t eram_depth;
+	uint32_t ddr_base_addr;
+	uint32_t ppu_addr_offset;
+} ZXDH_PPU_STAT_CFG_T;
+
+typedef enum zxdh_stat_cnt_mode_e {
+	ZXDH_STAT_64_MODE  = 0,
+	ZXDH_STAT_128_MODE = 1,
+	ZXDH_STAT_MAX_MODE,
+} ZXDH_STAT_CNT_MODE_E;
+
 int zxdh_np_host_init(uint32_t dev_id, ZXDH_DEV_INIT_CTRL_T *p_dev_init_ctrl);
 int zxdh_np_online_uninit(uint32_t dev_id, char *port_name, uint32_t queue_id);
 int zxdh_np_dtb_table_entry_write(uint32_t dev_id, uint32_t queue_id,
@@ -545,5 +570,10 @@ int zxdh_np_dtb_table_entry_delete(uint32_t dev_id, uint32_t queue_id,
 			 uint32_t entrynum, ZXDH_DTB_USER_ENTRY_T *delete_entries);
 int zxdh_np_dtb_table_entry_get(uint32_t dev_id, uint32_t queue_id,
 			ZXDH_DTB_USER_ENTRY_T *get_entry, uint32_t srh_mode);
+int zxdh_np_dtb_stats_get(uint32_t dev_id,
+			uint32_t queue_id,
+			ZXDH_STAT_CNT_MODE_E rd_mode,
+			uint32_t index,
+			uint32_t *p_data);
 
 #endif /* ZXDH_NP_H */
drivers/net/zxdh/zxdh_queue.h +2 -0
index 9343df81ac..deb0dd891a 100644
@@ -53,6 +53,8 @@ enum { ZXDH_VTNET_RQ = 0, ZXDH_VTNET_TQ = 1 };
 #define ZXDH_PI_HDR_SIZE          sizeof(struct zxdh_pi_hdr)
 #define ZXDH_DL_NET_HDR_SIZE      sizeof(struct zxdh_net_hdr_dl)
 #define ZXDH_UL_NET_HDR_SIZE      sizeof(struct zxdh_net_hdr_ul)
+#define ZXDH_PD_HDR_SIZE_MAX              256
+#define ZXDH_PD_HDR_SIZE_MIN              ZXDH_TYPE_HDR_SIZE
 
 /*
  * ring descriptors: 16 bytes.
drivers/net/zxdh/zxdh_rxtx.c +80 -3

166 lines not on this page · raw message

drivers/net/zxdh/zxdh_tables.h +5 -0
index c8d1de3bbb..a77ec46d84 100644
@@ -11,6 +11,11 @@
 #define ZXDH_PORT_BASE_QID_FLAG           10
 #define ZXDH_PORT_ATTR_IS_UP_FLAG         35
 
+#define ZXDH_MTU_STATS_EGRESS_BASE        0x8481
+#define ZXDH_MTU_STATS_INGRESS_BASE       0x8981
+#define ZXDH_BROAD_STATS_EGRESS_BASE      0xC902
+#define ZXDH_BROAD_STATS_INGRESS_BASE     0xD102
+
 extern struct zxdh_dtb_shared_data g_dtb_data;
 
 struct zxdh_port_attr_table {
Signature · 1 line
2.27.0
#68 lore raw

PATCH v3 15/15 net/zxdh: mtu update ops implementations

In reply to Junlong Wang

mtu update ops implementations.

---
 doc/guides/nics/features/zxdh.ini  |  1 +
 doc/guides/nics/zxdh.rst           |  2 +
 drivers/net/zxdh/zxdh_ethdev.c     |  5 ++
 drivers/net/zxdh/zxdh_ethdev_ops.c | 78 ++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |  3 ++
 drivers/net/zxdh/zxdh_tables.c     | 42 ++++++++++++++++
 drivers/net/zxdh/zxdh_tables.h     |  4 ++
 7 files changed, 135 insertions(+)
doc/guides/nics/features/zxdh.ini +1 -0
index 98c141cf95..3561e31666 100644
@@ -24,3 +24,4 @@ RSS reta update      = Y
 Inner RSS            = Y
 Basic stats          = Y
 Stats per queue      = Y
+MTU update           = Y
doc/guides/nics/zxdh.rst +2 -0
index c8a52b587c..58e0c49a2e 100644
@@ -33,6 +33,8 @@ Features of the ZXDH PMD are:
 - QINQ stripping and inserting
 - Receive Side Scaling (RSS)
 - Port hardware statistics
+- MTU update
+- Jumbo frames
 
 
 Driver compilation and testing
drivers/net/zxdh/zxdh_ethdev.c +5 -0
index 0326d143ec..147b66b998 100644
@@ -63,6 +63,10 @@ zxdh_dev_infos_get(struct rte_eth_dev *dev,
 	dev_info->reta_size = RTE_ETH_RSS_RETA_SIZE_256;
 	dev_info->flow_type_rss_offloads = ZXDH_RSS_HF;
 
+	dev_info->max_mtu = ZXDH_MAX_RX_PKTLEN - RTE_ETHER_HDR_LEN -
+		RTE_VLAN_HLEN - ZXDH_DL_NET_HDR_SIZE;
+	dev_info->min_mtu = ZXDH_ETHER_MIN_MTU;
+
 	dev_info->tx_offload_capa = (RTE_ETH_TX_OFFLOAD_MULTI_SEGS);
 	dev_info->tx_offload_capa |= (RTE_ETH_TX_OFFLOAD_TCP_TSO |
 					RTE_ETH_TX_OFFLOAD_UDP_TSO);
@@ -1152,6 +1156,7 @@ static const struct eth_dev_ops zxdh_eth_dev_ops = {
 	.rss_hash_conf_get		 = zxdh_rss_hash_conf_get,
 	.stats_get				 = zxdh_dev_stats_get,
 	.stats_reset			 = zxdh_dev_stats_reset,
+	.mtu_set				 = zxdh_dev_mtu_set,
 };
 
 static int32_t
drivers/net/zxdh/zxdh_ethdev_ops.c +78 -0

87 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev_ops.h +3 -0
index f35378e691..fac6cbd5e8 100644
@@ -26,6 +26,8 @@
 #define ZXDH_HF_MAC_VLAN_ETH  ZXDH_ETH_RSS_L2
 #define ZXDH_RSS_HF  ((ZXDH_HF_MAC_VLAN_ETH | ZXDH_HF_F3_ETH | ZXDH_HF_F5_ETH))
 
+#define ZXDH_ETHER_MIN_MTU     68
+
 struct zxdh_hw_vqm_stats {
 	uint64_t rx_total;
 	uint64_t tx_total;
@@ -73,5 +75,6 @@ int zxdh_rss_hash_conf_get(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss
 int zxdh_rss_configure(struct rte_eth_dev *dev);
 int zxdh_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats);
 int zxdh_dev_stats_reset(struct rte_eth_dev *dev);
+int zxdh_dev_mtu_set(struct rte_eth_dev *dev, uint16_t new_mtu);
 
 #endif /* ZXDH_ETHDEV_OPS_H */
drivers/net/zxdh/zxdh_tables.c +42 -0

48 lines not on this page · raw message

drivers/net/zxdh/zxdh_tables.h +4 -0
index a77ec46d84..e2bdb01688 100644
@@ -8,8 +8,10 @@
 #include <stdint.h>
 
 #define ZXDH_DEVICE_NO                    0
+#define ZXDH_PORT_MTU_FLAG                9
 #define ZXDH_PORT_BASE_QID_FLAG           10
 #define ZXDH_PORT_ATTR_IS_UP_FLAG         35
+#define ZXDH_PORT_MTU_EN_FLAG             42
 
 #define ZXDH_MTU_STATS_EGRESS_BASE        0x8481
 #define ZXDH_MTU_STATS_INGRESS_BASE       0x8981
@@ -223,5 +225,7 @@ int zxdh_vlan_filter_table_init(struct rte_eth_dev *dev);
 int zxdh_vlan_filter_table_set(uint16_t vport, uint16_t vlan_id, uint8_t enable);
 int zxdh_rss_table_set(uint16_t vport, struct zxdh_rss_reta *rss_reta);
 int zxdh_rss_table_get(uint16_t vport, struct zxdh_rss_reta *rss_reta);
+int zxdh_get_panel_attr(struct rte_eth_dev *dev, struct zxdh_panel_table *panel_attr);
+int zxdh_set_panel_attr(struct rte_eth_dev *dev, struct zxdh_panel_table *panel_attr);
 
 #endif /* ZXDH_TABLES_H */
Signature · 1 line
2.27.0
#69 lore raw

v4 cover net/zxdh: updated net zxdh driver

In reply to Junlong Wang

V4:
- resolved ci compile issues.

V3:
- use rte_zmalloc and rte_calloc to avoid memset.
- remove unnecessary initialization, which first usage will set.
- adjust some function which is always return 0, changed to void and skip the ASSERTION later.
- resolved some WARNING:MACRO_ARG_UNUSED issues.
- resolved some other issues.

V2:
- resolve code style and github-robot build issue.

V1:
- updated net zxdh driver
provided insert/delete/get table code funcs. provided link/mac/vlan/promiscuous/rss/mtu ops.

Junlong Wang (15):
net/zxdh: zxdh np init implementation net/zxdh: zxdh np uninit implementation net/zxdh: port tables init implementations net/zxdh: port tables unint implementations net/zxdh: rx/tx queue setup and intr enable net/zxdh: dev start/stop ops implementations net/zxdh: provided dev simple tx implementations net/zxdh: provided dev simple rx implementations net/zxdh: link info update, set link up/down net/zxdh: mac set/add/remove ops implementations net/zxdh: promisc/allmulti ops implementations net/zxdh: vlan filter/ offload ops implementations net/zxdh: rss hash config/update, reta update/get net/zxdh: basic stats ops implementations net/zxdh: mtu update ops implementations

 doc/guides/nics/features/zxdh.ini  |   18 +
 doc/guides/nics/zxdh.rst           |   17 +
 drivers/net/zxdh/meson.build       |    4 +
 drivers/net/zxdh/zxdh_common.c     |   24 +
 drivers/net/zxdh/zxdh_common.h     |    1 +
 drivers/net/zxdh/zxdh_ethdev.c     |  575 +++++++-
 drivers/net/zxdh/zxdh_ethdev.h     |   40 +
 drivers/net/zxdh/zxdh_ethdev_ops.c | 1595 +++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |   80 ++
 drivers/net/zxdh/zxdh_msg.c        |  166 +++
 drivers/net/zxdh/zxdh_msg.h        |  232 ++++
 drivers/net/zxdh/zxdh_np.c         | 2060 ++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_np.h         |  579 ++++++++
 drivers/net/zxdh/zxdh_pci.c        |   26 +-
 drivers/net/zxdh/zxdh_pci.h        |    9 +-
 drivers/net/zxdh/zxdh_queue.c      |  242 +++-
 drivers/net/zxdh/zxdh_queue.h      |  144 +-
 drivers/net/zxdh/zxdh_rxtx.c       |  804 +++++++++++
 drivers/net/zxdh/zxdh_rxtx.h       |   20 +-
 drivers/net/zxdh/zxdh_tables.c     |  794 +++++++++++
 drivers/net/zxdh/zxdh_tables.h     |  231 ++++
 21 files changed, 7615 insertions(+), 46 deletions(-)
 create mode 100644 drivers/net/zxdh/zxdh_ethdev_ops.c
 create mode 100644 drivers/net/zxdh/zxdh_ethdev_ops.h
 create mode 100644 drivers/net/zxdh/zxdh_np.c
 create mode 100644 drivers/net/zxdh/zxdh_np.h
 create mode 100644 drivers/net/zxdh/zxdh_rxtx.c
 create mode 100644 drivers/net/zxdh/zxdh_tables.c
 create mode 100644 drivers/net/zxdh/zxdh_tables.h
Signature · 1 line
2.27.0
#70 lore raw

PATCH v4 1/15 net/zxdh: zxdh np init implementation

(np)network Processor initialize resources in host, and initialize a channel for some tables insert/get/del.

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_ethdev.c | 234 +++++++++++++++++++++--
 drivers/net/zxdh/zxdh_ethdev.h |  30 +++
 drivers/net/zxdh/zxdh_msg.c    |  44 +++++
 drivers/net/zxdh/zxdh_msg.h    |  37 ++++
 drivers/net/zxdh/zxdh_np.c     | 340 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_np.h     | 198 +++++++++++++++++++
 drivers/net/zxdh/zxdh_pci.c    |   2 +-
 drivers/net/zxdh/zxdh_pci.h    |   6 +-
 drivers/net/zxdh/zxdh_queue.c  |   2 +-
 drivers/net/zxdh/zxdh_queue.h  |  14 +-
 11 files changed, 875 insertions(+), 33 deletions(-)
 create mode 100644 drivers/net/zxdh/zxdh_np.c
 create mode 100644 drivers/net/zxdh/zxdh_np.h
drivers/net/zxdh/meson.build +1 -0
index c9960f4c73..ab24a3145c 100644
@@ -19,4 +19,5 @@ sources = files(
         'zxdh_msg.c',
         'zxdh_pci.c',
         'zxdh_queue.c',
+        'zxdh_np.c',
 )
drivers/net/zxdh/zxdh_ethdev.c +213 -21

324 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev.h +30 -0
index 7658cbb461..b1f398b28e 100644
@@ -35,6 +35,12 @@
 
 #define ZXDH_MBUF_BURST_SZ        64
 
+#define ZXDH_MAX_BASE_DTB_TABLE_COUNT   30
+#define ZXDH_DTB_TABLE_DUMP_SIZE        (32 * (16 + 16 * 1024))
+#define ZXDH_DTB_TABLE_CONF_SIZE        (32 * (16 + 16 * 1024))
+
+#define ZXDH_MAX_NAME_LEN               32
+
 union zxdh_virport_num {
 	uint16_t vport;
 	struct {
@@ -89,6 +95,30 @@ struct zxdh_hw {
 	uint8_t has_rx_offload;
 };
 
+struct zxdh_dtb_shared_data {
+	uint8_t init_done;
+	char name[ZXDH_MAX_NAME_LEN];
+	uint16_t queueid;
+	uint16_t vport;
+	uint32_t vector;
+	const struct rte_memzone *dtb_table_conf_mz;
+	const struct rte_memzone *dtb_table_dump_mz;
+	const struct rte_memzone *dtb_table_bulk_dump_mz[ZXDH_MAX_BASE_DTB_TABLE_COUNT];
+	struct rte_eth_dev *bind_device;
+	uint32_t dev_refcnt;
+};
+
+/* Shared data between primary and secondary processes. */
+struct zxdh_shared_data {
+	rte_spinlock_t lock; /* Global spinlock for primary and secondary processes. */
+	int32_t init_done;       /* Whether primary has done initialization. */
+	unsigned int secondary_cnt; /* Number of secondary processes init'd. */
+
+	int32_t np_init_done;
+	uint32_t dev_refcnt;
+	struct zxdh_dtb_shared_data *dtb_data;
+};
+
 uint16_t zxdh_vport_to_vfid(union zxdh_virport_num v);
 
 #endif /* ZXDH_ETHDEV_H */
drivers/net/zxdh/zxdh_msg.c +44 -0

47 lines not on this page · raw message

drivers/net/zxdh/zxdh_msg.h +37 -0
index 530ee406b1..fbc79e8f9d 100644
@@ -131,6 +131,26 @@ enum ZXDH_TBL_MSG_TYPE {
 	ZXDH_TBL_TYPE_NON,
 };
 
+enum pciebar_layout_type {
+	ZXDH_URI_VQM      = 0,
+	ZXDH_URI_SPINLOCK = 1,
+	ZXDH_URI_FWCAP    = 2,
+	ZXDH_URI_FWSHR    = 3,
+	ZXDH_URI_DRS_SEC  = 4,
+	ZXDH_URI_RSV      = 5,
+	ZXDH_URI_CTRLCH   = 6,
+	ZXDH_URI_1588     = 7,
+	ZXDH_URI_QBV      = 8,
+	ZXDH_URI_MACPCS   = 9,
+	ZXDH_URI_RDMA     = 10,
+	ZXDH_URI_MNP      = 11,
+	ZXDH_URI_MSPM     = 12,
+	ZXDH_URI_MVQM     = 13,
+	ZXDH_URI_MDPI     = 14,
+	ZXDH_URI_NP       = 15,
+	ZXDH_URI_MAX,
+};
+
 struct zxdh_msix_para {
 	uint16_t pcie_id;
 	uint16_t vector_risc;
@@ -174,6 +194,17 @@ struct zxdh_bar_offset_reps {
 	uint32_t length;
 } __rte_packed;
 
+struct zxdh_bar_offset_params {
+	uint64_t virt_addr;  /* Bar space control space virtual address */
+	uint16_t pcie_id;
+	uint16_t type;  /* Module types corresponding to PCIBAR planning */
+};
+
+struct zxdh_bar_offset_res {
+	uint32_t bar_offset;
+	uint32_t bar_length;
+};
+
 struct zxdh_bar_recv_msg {
 	uint8_t reps_ok;
 	uint16_t reps_len;
@@ -204,9 +235,15 @@ struct zxdh_bar_msg_header {
 	uint16_t dst_pcieid; /* used in PF-->VF */
 };
 
+struct zxdh_offset_get_msg {
+	uint16_t pcie_id;
+	uint16_t type;
+};
+
 typedef int (*zxdh_bar_chan_msg_recv_callback)(void *pay_load, uint16_t len,
 		void *reps_buffer, uint16_t *reps_len, void *dev);
 
+int zxdh_get_bar_offset(struct zxdh_bar_offset_params *paras, struct zxdh_bar_offset_res *res);
 int zxdh_msg_chan_init(void);
 int zxdh_bar_msg_chan_exit(void);
 int zxdh_msg_chan_hwlock_init(struct rte_eth_dev *dev);
drivers/net/zxdh/zxdh_np.c new file +340 -0

340 lines not on this page · raw message

drivers/net/zxdh/zxdh_np.h new file +198 -0

198 lines not on this page · raw message

drivers/net/zxdh/zxdh_pci.c +1 -1
index 06d3f92b20..250e67d560 100644
@@ -159,7 +159,7 @@ zxdh_setup_queue(struct zxdh_hw *hw, struct zxdh_virtqueue *vq)
 
 	desc_addr = vq->vq_ring_mem;
 	avail_addr = desc_addr + vq->vq_nentries * sizeof(struct zxdh_vring_desc);
-	if (vtpci_packed_queue(vq->hw)) {
+	if (zxdh_pci_packed_queue(vq->hw)) {
 		used_addr = RTE_ALIGN_CEIL((avail_addr +
 				sizeof(struct zxdh_vring_packed_desc_event)),
 				ZXDH_PCI_VRING_ALIGN);
drivers/net/zxdh/zxdh_pci.h +3 -3
index ed6fd89742..d6487a574f 100644
@@ -114,15 +114,15 @@ struct zxdh_pci_common_cfg {
 };
 
 static inline int32_t
-vtpci_with_feature(struct zxdh_hw *hw, uint64_t bit)
+zxdh_pci_with_feature(struct zxdh_hw *hw, uint64_t bit)
 {
 	return (hw->guest_features & (1ULL << bit)) != 0;
 }
 
 static inline int32_t
-vtpci_packed_queue(struct zxdh_hw *hw)
+zxdh_pci_packed_queue(struct zxdh_hw *hw)
 {
-	return vtpci_with_feature(hw, ZXDH_F_RING_PACKED);
+	return zxdh_pci_with_feature(hw, ZXDH_F_RING_PACKED);
 }
 
 struct zxdh_pci_ops {
drivers/net/zxdh/zxdh_queue.c +1 -1
index 462a88b23c..b4ef90ea36 100644
@@ -13,7 +13,7 @@
 #include "zxdh_msg.h"
 
 struct rte_mbuf *
-zxdh_virtqueue_detach_unused(struct zxdh_virtqueue *vq)
+zxdh_queue_detach_unused(struct zxdh_virtqueue *vq)
 {
 	struct rte_mbuf *cookie = NULL;
 	int32_t          idx    = 0;
drivers/net/zxdh/zxdh_queue.h +7 -7
index 1088bf08fc..1304d5e4ea 100644
@@ -206,11 +206,11 @@ struct zxdh_tx_region {
 };
 
 static inline size_t
-vring_size(struct zxdh_hw *hw, uint32_t num, unsigned long align)
+zxdh_vring_size(struct zxdh_hw *hw, uint32_t num, unsigned long align)
 {
 	size_t size;
 
-	if (vtpci_packed_queue(hw)) {
+	if (zxdh_pci_packed_queue(hw)) {
 		size = num * sizeof(struct zxdh_vring_packed_desc);
 		size += sizeof(struct zxdh_vring_packed_desc_event);
 		size = RTE_ALIGN_CEIL(size, align);
@@ -226,7 +226,7 @@ vring_size(struct zxdh_hw *hw, uint32_t num, unsigned long align)
 }
 
 static inline void
-vring_init_packed(struct zxdh_vring_packed *vr, uint8_t *p,
+zxdh_vring_init_packed(struct zxdh_vring_packed *vr, uint8_t *p,
 		unsigned long align, uint32_t num)
 {
 	vr->num    = num;
@@ -238,7 +238,7 @@ vring_init_packed(struct zxdh_vring_packed *vr, uint8_t *p,
 }
 
 static inline void
-vring_desc_init_packed(struct zxdh_virtqueue *vq, int32_t n)
+zxdh_vring_desc_init_packed(struct zxdh_virtqueue *vq, int32_t n)
 {
 	int32_t i = 0;
 
@@ -251,7 +251,7 @@ vring_desc_init_packed(struct zxdh_virtqueue *vq, int32_t n)
 }
 
 static inline void
-vring_desc_init_indirect_packed(struct zxdh_vring_packed_desc *dp, int32_t n)
+zxdh_vring_desc_init_indirect_packed(struct zxdh_vring_packed_desc *dp, int32_t n)
 {
 	int32_t i = 0;
 
@@ -262,7 +262,7 @@ vring_desc_init_indirect_packed(struct zxdh_vring_packed_desc *dp, int32_t n)
 }
 
 static inline void
-virtqueue_disable_intr(struct zxdh_virtqueue *vq)
+zxdh_queue_disable_intr(struct zxdh_virtqueue *vq)
 {
 	if (vq->vq_packed.event_flags_shadow != ZXDH_RING_EVENT_FLAGS_DISABLE) {
 		vq->vq_packed.event_flags_shadow = ZXDH_RING_EVENT_FLAGS_DISABLE;
@@ -270,7 +270,7 @@ virtqueue_disable_intr(struct zxdh_virtqueue *vq)
 	}
 }
 
-struct rte_mbuf *zxdh_virtqueue_detach_unused(struct zxdh_virtqueue *vq);
+struct rte_mbuf *zxdh_queue_detach_unused(struct zxdh_virtqueue *vq);
 int32_t zxdh_free_queues(struct rte_eth_dev *dev);
 int32_t zxdh_get_queue_type(uint16_t vtpci_queue_idx);
 
Signature · 1 line
2.27.0
#71 lore raw

PATCH v4 2/15 net/zxdh: zxdh np uninit implementation

In reply to Junlong Wang

(np)network processor release resources in host.

---
 drivers/net/zxdh/zxdh_ethdev.c |  48 ++++
 drivers/net/zxdh/zxdh_np.c     | 470 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_np.h     | 107 ++++++++
 3 files changed, 625 insertions(+)
drivers/net/zxdh/zxdh_ethdev.c +48 -0
index b8f4415e00..4e114d95da 100644
@@ -841,6 +841,51 @@ zxdh_dev_configure(struct rte_eth_dev *dev)
 	return ret;
 }
 
+static void
+zxdh_np_dtb_data_res_free(struct zxdh_hw *hw)
+{
+	struct rte_eth_dev *dev = hw->eth_dev;
+	int ret;
+	int i;
+
+	if (g_dtb_data.init_done && g_dtb_data.bind_device == dev) {
+		ret = zxdh_np_online_uninit(0, dev->data->name, g_dtb_data.queueid);
+		if (ret)
+			PMD_DRV_LOG(ERR, "%s dpp_np_online_uninstall failed", dev->data->name);
+
+		if (g_dtb_data.dtb_table_conf_mz)
+			rte_memzone_free(g_dtb_data.dtb_table_conf_mz);
+
+		if (g_dtb_data.dtb_table_dump_mz) {
+			rte_memzone_free(g_dtb_data.dtb_table_dump_mz);
+			g_dtb_data.dtb_table_dump_mz = NULL;
+		}
+
+		for (i = 0; i < ZXDH_MAX_BASE_DTB_TABLE_COUNT; i++) {
+			if (g_dtb_data.dtb_table_bulk_dump_mz[i]) {
+				rte_memzone_free(g_dtb_data.dtb_table_bulk_dump_mz[i]);
+				g_dtb_data.dtb_table_bulk_dump_mz[i] = NULL;
+			}
+		}
+		g_dtb_data.init_done = 0;
+		g_dtb_data.bind_device = NULL;
+	}
+	if (zxdh_shared_data != NULL)
+		zxdh_shared_data->np_init_done = 0;
+}
+
+static void
+zxdh_np_uninit(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (!g_dtb_data.init_done && !g_dtb_data.dev_refcnt)
+		return;
+
+	if (--g_dtb_data.dev_refcnt == 0)
+		zxdh_np_dtb_data_res_free(hw);
+}
+
 static int
 zxdh_dev_close(struct rte_eth_dev *dev)
 {
@@ -848,6 +893,7 @@ zxdh_dev_close(struct rte_eth_dev *dev)
 	int ret = 0;
 
 	zxdh_intr_release(dev);
+	zxdh_np_uninit(dev);
 	zxdh_pci_reset(hw);
 
 	zxdh_dev_free_mbufs(dev);
@@ -1010,6 +1056,7 @@ zxdh_np_dtb_res_init(struct rte_eth_dev *dev)
 	return 0;
 
 free_res:
+	zxdh_np_dtb_data_res_free(hw);
 	rte_free(dpp_ctrl);
 	return ret;
 }
@@ -1177,6 +1224,7 @@ zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 
 err_zxdh_init:
 	zxdh_intr_release(eth_dev);
+	zxdh_np_uninit(eth_dev);
 	zxdh_bar_msg_chan_exit();
 	rte_free(eth_dev->data->mac_addrs);
 	eth_dev->data->mac_addrs = NULL;
drivers/net/zxdh/zxdh_np.c +470 -0

483 lines not on this page · raw message

drivers/net/zxdh/zxdh_np.h +107 -0

131 lines not on this page · raw message

Signature · 1 line
2.27.0
#72 lore raw

PATCH v4 3/15 net/zxdh: port tables init implementations

In reply to Junlong Wang

insert port tables in host.

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_ethdev.c |  24 ++
 drivers/net/zxdh/zxdh_msg.c    |  65 ++++
 drivers/net/zxdh/zxdh_msg.h    |  72 ++++
 drivers/net/zxdh/zxdh_np.c     | 648 ++++++++++++++++++++++++++++++++-
 drivers/net/zxdh/zxdh_np.h     | 210 +++++++++++
 drivers/net/zxdh/zxdh_pci.h    |   2 +
 drivers/net/zxdh/zxdh_tables.c | 105 ++++++
 drivers/net/zxdh/zxdh_tables.h | 148 ++++++++
 9 files changed, 1274 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/zxdh/zxdh_tables.c
 create mode 100644 drivers/net/zxdh/zxdh_tables.h
drivers/net/zxdh/meson.build +1 -0
index ab24a3145c..5b3af87c5b 100644
@@ -20,4 +20,5 @@ sources = files(
         'zxdh_pci.c',
         'zxdh_queue.c',
         'zxdh_np.c',
+        'zxdh_tables.c',
 )
drivers/net/zxdh/zxdh_ethdev.c +24 -0
index 4e114d95da..ff44816384 100644
@@ -14,6 +14,7 @@
 #include "zxdh_common.h"
 #include "zxdh_queue.h"
 #include "zxdh_np.h"
+#include "zxdh_tables.h"
 
 struct zxdh_hw_internal zxdh_hw_internal[RTE_MAX_ETHPORTS];
 struct zxdh_shared_data *zxdh_shared_data;
@@ -1144,6 +1145,25 @@ zxdh_np_init(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
+static int
+zxdh_tables_init(struct rte_eth_dev *dev)
+{
+	int ret = 0;
+
+	ret = zxdh_port_attr_init(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "zxdh_port_attr_init failed");
+		return ret;
+	}
+
+	ret = zxdh_panel_table_init(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, " panel table init failed");
+		return ret;
+	}
+	return ret;
+}
+
 static int
 zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 {
@@ -1220,6 +1240,10 @@ zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 	if (ret != 0)
 		goto err_zxdh_init;
 
+	ret = zxdh_tables_init(eth_dev);
+	if (ret != 0)
+		goto err_zxdh_init;
+
 	return ret;
 
 err_zxdh_init:
drivers/net/zxdh/zxdh_msg.c +65 -0

80 lines not on this page · raw message

drivers/net/zxdh/zxdh_msg.h +72 -0

95 lines not on this page · raw message

drivers/net/zxdh/zxdh_np.c +647 -1

680 lines not on this page · raw message

drivers/net/zxdh/zxdh_np.h +210 -0

229 lines not on this page · raw message

drivers/net/zxdh/zxdh_pci.h +2 -0
index d6487a574f..e3f13cb17d 100644
@@ -12,6 +12,8 @@
 
 #include "zxdh_ethdev.h"
 
+#define ZXDH_PF_PCIE_ID(pcie_id)  (((pcie_id) & 0xff00) | 1 << 11)
+
 enum zxdh_msix_status {
 	ZXDH_MSIX_NONE     = 0,
 	ZXDH_MSIX_DISABLED = 1,
drivers/net/zxdh/zxdh_tables.c new file +105 -0

105 lines not on this page · raw message

drivers/net/zxdh/zxdh_tables.h new file +148 -0

148 lines not on this page · raw message

Signature · 1 line
2.27.0
#73 lore raw

PATCH v4 4/15 net/zxdh: port tables unint implementations

In reply to Junlong Wang

delete port tables in host.

---
 drivers/net/zxdh/zxdh_ethdev.c |  18 ++++++
 drivers/net/zxdh/zxdh_msg.h    |   1 +
 drivers/net/zxdh/zxdh_np.c     | 103 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_np.h     |   9 +++
 drivers/net/zxdh/zxdh_tables.c |  33 ++++++++++-
 drivers/net/zxdh/zxdh_tables.h |   1 +
 6 files changed, 164 insertions(+), 1 deletion(-)
drivers/net/zxdh/zxdh_ethdev.c +18 -0
index ff44816384..717a1d2b0b 100644
@@ -887,12 +887,30 @@ zxdh_np_uninit(struct rte_eth_dev *dev)
 		zxdh_np_dtb_data_res_free(hw);
 }
 
+static int
+zxdh_tables_uninit(struct rte_eth_dev *dev)
+{
+	int ret;
+
+	ret = zxdh_port_attr_uninit(dev);
+	if (ret)
+		PMD_DRV_LOG(ERR, "zxdh_port_attr_uninit failed");
+
+	return ret;
+}
+
 static int
 zxdh_dev_close(struct rte_eth_dev *dev)
 {
 	struct zxdh_hw *hw = dev->data->dev_private;
 	int ret = 0;
 
+	ret = zxdh_tables_uninit(dev);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "%s :tables uninit %s failed ", __func__, dev->device->name);
+		return -1;
+	}
+
 	zxdh_intr_release(dev);
 	zxdh_np_uninit(dev);
 	zxdh_pci_reset(hw);
drivers/net/zxdh/zxdh_msg.h +1 -0
index b7b17b8696..613ca71170 100644
@@ -167,6 +167,7 @@ enum pciebar_layout_type {
 enum zxdh_msg_type {
 	ZXDH_NULL = 0,
 	ZXDH_VF_PORT_INIT = 1,
+	ZXDH_VF_PORT_UNINIT = 2,
 
 	ZXDH_MSG_TYPE_END,
 };
drivers/net/zxdh/zxdh_np.c +103 -0

112 lines not on this page · raw message

drivers/net/zxdh/zxdh_np.h +9 -0
index 40961c02a2..42a652dd6b 100644
@@ -20,6 +20,8 @@
 #define ZXDH_PPU_CLUSTER_NUM                  (6)
 #define ZXDH_PPU_INSTR_MEM_NUM                (3)
 #define ZXDH_SDT_CFG_LEN                      (2)
+#define ZXDH_SDT_H_TBL_TYPE_BT_POS            (29)
+#define ZXDH_SDT_H_TBL_TYPE_BT_LEN            (3)
 
 #define ZXDH_RC_DEV_BASE                      (0x600)
 #define ZXDH_RC_DEV_PARA_INVALID              (ZXDH_RC_DEV_BASE | 0x0)
@@ -507,9 +509,16 @@ typedef struct zxdh_dtb_user_entry_t {
 	void *p_entry_data;
 } ZXDH_DTB_USER_ENTRY_T;
 
+typedef struct zxdh_sdt_tbl_data_t {
+	uint32_t data_high32;
+	uint32_t data_low32;
+} ZXDH_SDT_TBL_DATA_T;
+
 int zxdh_np_host_init(uint32_t dev_id, ZXDH_DEV_INIT_CTRL_T *p_dev_init_ctrl);
 int zxdh_np_online_uninit(uint32_t dev_id, char *port_name, uint32_t queue_id);
 int zxdh_np_dtb_table_entry_write(uint32_t dev_id, uint32_t queue_id,
 			uint32_t entrynum, ZXDH_DTB_USER_ENTRY_T *down_entries);
+int zxdh_np_dtb_table_entry_delete(uint32_t dev_id, uint32_t queue_id,
+			 uint32_t entrynum, ZXDH_DTB_USER_ENTRY_T *delete_entries);
 
 #endif /* ZXDH_NP_H */
drivers/net/zxdh/zxdh_tables.c +32 -1
index 91376e6ec0..9fd184e612 100644
@@ -11,7 +11,8 @@
 #define ZXDH_SDT_VPORT_ATT_TABLE          1
 #define ZXDH_SDT_PANEL_ATT_TABLE          2
 
-int zxdh_set_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr)
+int
+zxdh_set_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr)
 {
 	int ret = 0;
 
@@ -70,6 +71,36 @@ zxdh_port_attr_init(struct rte_eth_dev *dev)
 	return ret;
 };
 
+int
+zxdh_port_attr_uninit(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+	struct zxdh_msg_info msg_info = {0};
+	struct zxdh_port_attr_table port_attr = {0};
+	int ret = 0;
+
+	if (hw->is_pf == 1) {
+		ZXDH_DTB_ERAM_ENTRY_INFO_T port_attr_entry = {hw->vfid, (uint32_t *)&port_attr};
+		ZXDH_DTB_USER_ENTRY_T entry = {
+			.sdt_no = ZXDH_SDT_VPORT_ATT_TABLE,
+			.p_entry_data = (void *)&port_attr_entry
+		};
+		ret = zxdh_np_dtb_table_entry_delete(ZXDH_DEVICE_NO, g_dtb_data.queueid, 1, &entry);
+		if (ret) {
+			PMD_DRV_LOG(ERR, "delete port attr table failed");
+			ret = -1;
+		}
+	} else {
+		zxdh_msg_head_build(hw, ZXDH_VF_PORT_UNINIT, &msg_info);
+		ret = zxdh_vf_send_msg_to_pf(dev, &msg_info, sizeof(msg_info), NULL, 0);
+		if (ret) {
+			PMD_DRV_LOG(ERR, "vf port tables uninit failed");
+			ret = -1;
+		}
+	}
+	return ret;
+}
+
 int zxdh_panel_table_init(struct rte_eth_dev *dev)
 {
 	struct zxdh_hw *hw = dev->data->dev_private;
drivers/net/zxdh/zxdh_tables.h +1 -0
index 5d34af2f05..5e9b36faee 100644
@@ -144,5 +144,6 @@ struct zxdh_panel_table {
 int zxdh_port_attr_init(struct rte_eth_dev *dev);
 int zxdh_panel_table_init(struct rte_eth_dev *dev);
 int zxdh_set_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr);
+int zxdh_port_attr_uninit(struct rte_eth_dev *dev);
 
 #endif /* ZXDH_TABLES_H */
Signature · 1 line
2.27.0
#74 lore raw

PATCH v4 5/15 net/zxdh: rx/tx queue setup and intr enable

In reply to Junlong Wang

rx/tx queue setup and intr enable implementations.

---
 drivers/net/zxdh/zxdh_ethdev.c |   4 +
 drivers/net/zxdh/zxdh_queue.c  | 149 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_queue.h  |  33 ++++++++
 3 files changed, 186 insertions(+)
drivers/net/zxdh/zxdh_ethdev.c +4 -0
index 717a1d2b0b..521d7ed433 100644
@@ -933,6 +933,10 @@ static const struct eth_dev_ops zxdh_eth_dev_ops = {
 	.dev_configure			 = zxdh_dev_configure,
 	.dev_close				 = zxdh_dev_close,
 	.dev_infos_get			 = zxdh_dev_infos_get,
+	.rx_queue_setup			 = zxdh_dev_rx_queue_setup,
+	.tx_queue_setup			 = zxdh_dev_tx_queue_setup,
+	.rx_queue_intr_enable	 = zxdh_dev_rx_queue_intr_enable,
+	.rx_queue_intr_disable	 = zxdh_dev_rx_queue_intr_disable,
 };
 
 static int32_t
drivers/net/zxdh/zxdh_queue.c +149 -0

158 lines not on this page · raw message

drivers/net/zxdh/zxdh_queue.h +33 -0
index 1304d5e4ea..2f602d894f 100644
@@ -8,6 +8,7 @@
 #include <stdint.h>
 
 #include <rte_common.h>
+#include <rte_atomic.h>
 
 #include "zxdh_ethdev.h"
 #include "zxdh_rxtx.h"
@@ -30,6 +31,7 @@ enum { ZXDH_VTNET_RQ = 0, ZXDH_VTNET_TQ = 1 };
 #define ZXDH_RING_EVENT_FLAGS_DESC        0x2
 
 #define ZXDH_VQ_RING_DESC_CHAIN_END       32768
+#define ZXDH_QUEUE_DEPTH                  1024
 
 /*
  * ring descriptors: 16 bytes.
@@ -270,8 +272,39 @@ zxdh_queue_disable_intr(struct zxdh_virtqueue *vq)
 	}
 }
 
+static inline void
+zxdh_queue_enable_intr(struct zxdh_virtqueue *vq)
+{
+	if (vq->vq_packed.event_flags_shadow == ZXDH_RING_EVENT_FLAGS_DISABLE) {
+		vq->vq_packed.event_flags_shadow = ZXDH_RING_EVENT_FLAGS_DISABLE;
+		vq->vq_packed.ring.driver->desc_event_flags = vq->vq_packed.event_flags_shadow;
+	}
+}
+
+static inline void
+zxdh_mb(uint8_t weak_barriers)
+{
+	if (weak_barriers)
+		rte_atomic_thread_fence(rte_memory_order_seq_cst);
+	else
+		rte_mb();
+}
+
 struct rte_mbuf *zxdh_queue_detach_unused(struct zxdh_virtqueue *vq);
 int32_t zxdh_free_queues(struct rte_eth_dev *dev);
 int32_t zxdh_get_queue_type(uint16_t vtpci_queue_idx);
+int32_t zxdh_dev_tx_queue_setup(struct rte_eth_dev *dev,
+			uint16_t queue_idx,
+			uint16_t nb_desc,
+			uint32_t socket_id __rte_unused,
+			const struct rte_eth_txconf *tx_conf);
+int32_t zxdh_dev_rx_queue_setup(struct rte_eth_dev *dev,
+			uint16_t queue_idx,
+			uint16_t nb_desc,
+			uint32_t socket_id __rte_unused,
+			const struct rte_eth_rxconf *rx_conf,
+			struct rte_mempool *mp);
+int32_t zxdh_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id);
+int32_t zxdh_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id);
 
 #endif /* ZXDH_QUEUE_H */
Signature · 1 line
2.27.0
#75 lore raw

PATCH v4 6/15 net/zxdh: dev start/stop ops implementations

In reply to Junlong Wang

dev start/stop implementations, start/stop the rx/tx queues.

---
 doc/guides/nics/features/zxdh.ini |  2 +
 doc/guides/nics/zxdh.rst          |  2 +
 drivers/net/zxdh/zxdh_ethdev.c    | 61 +++++++++++++++++++++
 drivers/net/zxdh/zxdh_pci.c       | 24 ++++++++
 drivers/net/zxdh/zxdh_pci.h       |  1 +
 drivers/net/zxdh/zxdh_queue.c     | 91 +++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_queue.h     | 69 +++++++++++++++++++++++
 drivers/net/zxdh/zxdh_rxtx.h      | 14 ++---
 8 files changed, 256 insertions(+), 8 deletions(-)
doc/guides/nics/features/zxdh.ini +2 -0
index 05c8091ed7..7b72be5f25 100644
@@ -7,3 +7,5 @@
 Linux                = Y
 x86-64               = Y
 ARMv8                = Y
+SR-IOV               = Y
+Multiprocess aware   = Y
doc/guides/nics/zxdh.rst +2 -0
index 2144753d75..eb970a888f 100644
@@ -18,6 +18,8 @@ Features
 Features of the ZXDH PMD are:
 
 - Multi arch support: x86_64, ARMv8.
+- Multiple queues for TX and RX
+- SR-IOV VF
 
 
 Driver compilation and testing
drivers/net/zxdh/zxdh_ethdev.c +61 -0

82 lines not on this page · raw message

drivers/net/zxdh/zxdh_pci.c +24 -0
index 250e67d560..83164a5c79 100644
@@ -202,6 +202,29 @@ zxdh_del_queue(struct zxdh_hw *hw, struct zxdh_virtqueue *vq)
 	rte_write16(0, &hw->common_cfg->queue_enable);
 }
 
+static void
+zxdh_notify_queue(struct zxdh_hw *hw, struct zxdh_virtqueue *vq)
+{
+	uint32_t notify_data = 0;
+
+	if (!zxdh_pci_with_feature(hw, ZXDH_F_NOTIFICATION_DATA)) {
+		rte_write16(vq->vq_queue_index, vq->notify_addr);
+		return;
+	}
+
+	if (zxdh_pci_with_feature(hw, ZXDH_F_RING_PACKED)) {
+		notify_data = ((uint32_t)(!!(vq->vq_packed.cached_flags &
+						ZXDH_VRING_PACKED_DESC_F_AVAIL)) << 31) |
+						((uint32_t)vq->vq_avail_idx << 16) |
+						vq->vq_queue_index;
+	} else {
+		notify_data = ((uint32_t)vq->vq_avail_idx << 16) | vq->vq_queue_index;
+	}
+	PMD_DRV_LOG(DEBUG, "queue:%d notify_data 0x%x notify_addr 0x%p",
+				 vq->vq_queue_index, notify_data, vq->notify_addr);
+	rte_write32(notify_data, vq->notify_addr);
+}
+
 const struct zxdh_pci_ops zxdh_dev_pci_ops = {
 	.read_dev_cfg   = zxdh_read_dev_config,
 	.write_dev_cfg  = zxdh_write_dev_config,
@@ -216,6 +239,7 @@ const struct zxdh_pci_ops zxdh_dev_pci_ops = {
 	.set_queue_num  = zxdh_set_queue_num,
 	.setup_queue    = zxdh_setup_queue,
 	.del_queue      = zxdh_del_queue,
+	.notify_queue   = zxdh_notify_queue,
 };
 
 uint8_t
drivers/net/zxdh/zxdh_pci.h +1 -0
index e3f13cb17d..5c5f72b90e 100644
@@ -144,6 +144,7 @@ struct zxdh_pci_ops {
 
 	int32_t  (*setup_queue)(struct zxdh_hw *hw, struct zxdh_virtqueue *vq);
 	void     (*del_queue)(struct zxdh_hw *hw, struct zxdh_virtqueue *vq);
+	void     (*notify_queue)(struct zxdh_hw *hw, struct zxdh_virtqueue *vq);
 };
 
 struct zxdh_hw_internal {
drivers/net/zxdh/zxdh_queue.c +91 -0

94 lines not on this page · raw message

drivers/net/zxdh/zxdh_queue.h +69 -0

92 lines not on this page · raw message

drivers/net/zxdh/zxdh_rxtx.h +6 -8
index de9353b223..8c7f734805 100644
@@ -20,21 +20,19 @@ struct zxdh_virtnet_stats {
 	uint64_t size_bins[8];
 };
 
-struct zxdh_virtnet_rx {
+struct __rte_cache_aligned zxdh_virtnet_rx {
 	struct zxdh_virtqueue         *vq;
-
-	/* dummy mbuf, for wraparound when processing RX ring. */
-	struct rte_mbuf           fake_mbuf;
-
 	uint64_t                  mbuf_initializer; /* value to init mbufs. */
 	struct rte_mempool       *mpool;            /* mempool for mbuf allocation */
 	uint16_t                  queue_id;         /* DPDK queue index. */
 	uint16_t                  port_id;          /* Device port identifier. */
 	struct zxdh_virtnet_stats      stats;
 	const struct rte_memzone *mz;               /* mem zone to populate RX ring. */
-} __rte_packed;
+	/* dummy mbuf, for wraparound when processing RX ring. */
+	struct rte_mbuf           fake_mbuf;
+};
 
-struct zxdh_virtnet_tx {
+struct __rte_cache_aligned zxdh_virtnet_tx {
 	struct zxdh_virtqueue         *vq;
 	const struct rte_memzone *zxdh_net_hdr_mz;  /* memzone to populate hdr. */
 	rte_iova_t                zxdh_net_hdr_mem; /* hdr for each xmit packet */
@@ -42,6 +40,6 @@ struct zxdh_virtnet_tx {
 	uint16_t                  port_id;            /* Device port identifier. */
 	struct zxdh_virtnet_stats      stats;
 	const struct rte_memzone *mz;                 /* mem zone to populate TX ring. */
-} __rte_packed;
+};
 
 #endif  /* ZXDH_RXTX_H */
Signature · 1 line
2.27.0
#76 lore raw

Re: [PATCH v4 06/15] net/zxdh: dev start/stop ops implementations

Quoted 12 lines · On Wed, 18 Dec 2024 17:25:53 +0800 Junlong Wang <[email protected]>…
drivers/net/zxdh/zxdh_pci.c +12 -0
+static void
+zxdh_notify_queue(struct zxdh_hw *hw, struct zxdh_virtqueue *vq)
+{
+	uint32_t notify_data = 0;
+
+	if (!zxdh_pci_with_feature(hw, ZXDH_F_NOTIFICATION_DATA)) {
+		rte_write16(vq->vq_queue_index, vq->notify_addr);
+		return;
+	}
+
+	if (zxdh_pci_with_feature(hw, ZXDH_F_RING_PACKED)) {
+		notify_data = ((uint32_t)(!!(vq->vq_packed.cached_flags &

drivers/net/zxdh/zxdh_pci.c zxdh_del_queue(struct zxdh_hw *hw, struct zxdh_virtqueue *vq) · line 226

Quoted 10 lines
drivers/net/zxdh/zxdh_pci.c +10 -0
+						ZXDH_VRING_PACKED_DESC_F_AVAIL)) << 31) |
+						((uint32_t)vq->vq_avail_idx << 16) |
+						vq->vq_queue_index;
+	} else {
+		notify_data = ((uint32_t)vq->vq_avail_idx << 16) | vq->vq_queue_index;
+	}
+	PMD_DRV_LOG(DEBUG, "queue:%d notify_data 0x%x notify_addr 0x%p",
+				 vq->vq_queue_index, notify_data, vq->notify_addr);
+	rte_write32(notify_data, vq->notify_addr);
+}

Looks like the notify_data part could be simplified to:

	notify_data = ((uint32_t)vq->vq_avail_idx << 16) | vq->vq_queue_index;
	if (zxdh_pci_with_feature(hw, ZXDH_F_RING_PACKED) && (vq->vq_packed.cached_flags & ZXDH_VRING_PACKED_DESC_F_AVAIL)
		notify_data |= RTE_BIT32(31);
#77 lore raw

PATCH v4 7/15 net/zxdh: provided dev simple tx implementations

In reply to Junlong Wang

provided dev simple tx implementations.

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_ethdev.c |  21 ++
 drivers/net/zxdh/zxdh_queue.h  |  26 ++-
 drivers/net/zxdh/zxdh_rxtx.c   | 396 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_rxtx.h   |   4 +
 5 files changed, 447 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/zxdh/zxdh_rxtx.c
drivers/net/zxdh/meson.build +1 -0
index 5b3af87c5b..20b2cf484a 100644
@@ -21,4 +21,5 @@ sources = files(
         'zxdh_queue.c',
         'zxdh_np.c',
         'zxdh_tables.c',
+        'zxdh_rxtx.c',
 )
drivers/net/zxdh/zxdh_ethdev.c +21 -0
index 59ee942bdd..b6057edeaf 100644
@@ -15,6 +15,7 @@
 #include "zxdh_queue.h"
 #include "zxdh_np.h"
 #include "zxdh_tables.h"
+#include "zxdh_rxtx.h"
 
 struct zxdh_hw_internal zxdh_hw_internal[RTE_MAX_ETHPORTS];
 struct zxdh_shared_data *zxdh_shared_data;
@@ -951,6 +952,25 @@ zxdh_dev_close(struct rte_eth_dev *dev)
 	return ret;
 }
 
+static int32_t
+zxdh_set_rxtx_funcs(struct rte_eth_dev *eth_dev)
+{
+	struct zxdh_hw *hw = eth_dev->data->dev_private;
+
+	if (!zxdh_pci_packed_queue(hw)) {
+		PMD_DRV_LOG(ERR, " port %u not support packed queue", eth_dev->data->port_id);
+		return -1;
+	}
+	if (!zxdh_pci_with_feature(hw, ZXDH_NET_F_MRG_RXBUF)) {
+		PMD_DRV_LOG(ERR, " port %u not support rx mergeable", eth_dev->data->port_id);
+		return -1;
+	}
+	eth_dev->tx_pkt_prepare = zxdh_xmit_pkts_prepare;
+	eth_dev->tx_pkt_burst = &zxdh_xmit_pkts_packed;
+
+	return 0;
+}
+
 static int
 zxdh_dev_start(struct rte_eth_dev *dev)
 {
@@ -966,6 +986,7 @@ zxdh_dev_start(struct rte_eth_dev *dev)
 		if (ret < 0)
 			return ret;
 	}
+	zxdh_set_rxtx_funcs(dev);
 	ret = zxdh_intr_enable(dev);
 	if (ret) {
 		PMD_DRV_LOG(ERR, "interrupt enable failed");
drivers/net/zxdh/zxdh_queue.h +25 -1
index 6513aec3f0..9343df81ac 100644
@@ -21,8 +21,15 @@ enum { ZXDH_VTNET_RQ = 0, ZXDH_VTNET_TQ = 1 };
 #define ZXDH_TQ_QUEUE_IDX                 1
 #define ZXDH_MAX_TX_INDIRECT              8
 
+/* This marks a buffer as continuing via the next field. */
+#define ZXDH_VRING_DESC_F_NEXT                 1
+
 /* This marks a buffer as write-only (otherwise read-only). */
-#define ZXDH_VRING_DESC_F_WRITE           2
+#define ZXDH_VRING_DESC_F_WRITE                2
+
+/* This means the buffer contains a list of buffer descriptors. */
+#define ZXDH_VRING_DESC_F_INDIRECT             4
+
 /* This flag means the descriptor was made available by the driver */
 #define ZXDH_VRING_PACKED_DESC_F_AVAIL   (1 << (7))
 #define ZXDH_VRING_PACKED_DESC_F_USED    (1 << (15))
@@ -35,11 +42,17 @@ enum { ZXDH_VTNET_RQ = 0, ZXDH_VTNET_TQ = 1 };
 #define ZXDH_RING_EVENT_FLAGS_DISABLE     0x1
 #define ZXDH_RING_EVENT_FLAGS_DESC        0x2
 
+#define ZXDH_RING_F_INDIRECT_DESC         28
+
 #define ZXDH_VQ_RING_DESC_CHAIN_END       32768
 #define ZXDH_QUEUE_DEPTH                  1024
 
 #define ZXDH_RQ_QUEUE_IDX                 0
 #define ZXDH_TQ_QUEUE_IDX                 1
+#define ZXDH_TYPE_HDR_SIZE        sizeof(struct zxdh_type_hdr)
+#define ZXDH_PI_HDR_SIZE          sizeof(struct zxdh_pi_hdr)
+#define ZXDH_DL_NET_HDR_SIZE      sizeof(struct zxdh_net_hdr_dl)
+#define ZXDH_UL_NET_HDR_SIZE      sizeof(struct zxdh_net_hdr_ul)
 
 /*
  * ring descriptors: 16 bytes.
@@ -355,6 +368,17 @@ static inline void zxdh_queue_notify(struct zxdh_virtqueue *vq)
 	ZXDH_VTPCI_OPS(vq->hw)->notify_queue(vq->hw, vq);
 }
 
+static inline int32_t
+zxdh_queue_kick_prepare_packed(struct zxdh_virtqueue *vq)
+{
+	uint16_t flags = 0;
+
+	zxdh_mb(vq->hw->weak_barriers);
+	flags = vq->vq_packed.ring.device->desc_event_flags;
+
+	return (flags != ZXDH_RING_EVENT_FLAGS_DISABLE);
+}
+
 struct rte_mbuf *zxdh_queue_detach_unused(struct zxdh_virtqueue *vq);
 int32_t zxdh_free_queues(struct rte_eth_dev *dev);
 int32_t zxdh_get_queue_type(uint16_t vtpci_queue_idx);
drivers/net/zxdh/zxdh_rxtx.c new file +396 -0

396 lines not on this page · raw message

drivers/net/zxdh/zxdh_rxtx.h +4 -0
index 8c7f734805..0a02d319b2 100644
@@ -42,4 +42,8 @@ struct __rte_cache_aligned zxdh_virtnet_tx {
 	const struct rte_memzone *mz;                 /* mem zone to populate TX ring. */
 };
 
+uint16_t zxdh_xmit_pkts_packed(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts);
+uint16_t zxdh_xmit_pkts_prepare(void *tx_queue __rte_unused, struct rte_mbuf **tx_pkts,
+				uint16_t nb_pkts);
+
 #endif  /* ZXDH_RXTX_H */
Signature · 1 line
2.27.0
#78 lore raw

PATCH v4 8/15 net/zxdh: provided dev simple rx implementations

In reply to Junlong Wang

provided dev simple rx implementations.

---
 doc/guides/nics/features/zxdh.ini |   1 +
 doc/guides/nics/zxdh.rst          |   1 +
 drivers/net/zxdh/zxdh_ethdev.c    |   1 +
 drivers/net/zxdh/zxdh_rxtx.c      | 313 ++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_rxtx.h      |   2 +
 5 files changed, 318 insertions(+)
doc/guides/nics/features/zxdh.ini +1 -0
index 7b72be5f25..bb44e93fad 100644
@@ -9,3 +9,4 @@ x86-64               = Y
 ARMv8                = Y
 SR-IOV               = Y
 Multiprocess aware   = Y
+Scattered Rx         = Y
doc/guides/nics/zxdh.rst +1 -0
index eb970a888f..f42db9c1f1 100644
@@ -20,6 +20,7 @@ Features of the ZXDH PMD are:
 - Multi arch support: x86_64, ARMv8.
 - Multiple queues for TX and RX
 - SR-IOV VF
+- Scattered and gather for TX and RX
 
 
 Driver compilation and testing
drivers/net/zxdh/zxdh_ethdev.c +1 -0
index b6057edeaf..0d63129d8d 100644
@@ -967,6 +967,7 @@ zxdh_set_rxtx_funcs(struct rte_eth_dev *eth_dev)
 	}
 	eth_dev->tx_pkt_prepare = zxdh_xmit_pkts_prepare;
 	eth_dev->tx_pkt_burst = &zxdh_xmit_pkts_packed;
+	eth_dev->rx_pkt_burst = &zxdh_recv_pkts_packed;
 
 	return 0;
 }
drivers/net/zxdh/zxdh_rxtx.c +313 -0

322 lines not on this page · raw message

drivers/net/zxdh/zxdh_rxtx.h +2 -0
index 0a02d319b2..cc0004324a 100644
@@ -45,5 +45,7 @@ struct __rte_cache_aligned zxdh_virtnet_tx {
 uint16_t zxdh_xmit_pkts_packed(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts);
 uint16_t zxdh_xmit_pkts_prepare(void *tx_queue __rte_unused, struct rte_mbuf **tx_pkts,
 				uint16_t nb_pkts);
+uint16_t zxdh_recv_pkts_packed(void *rx_queue, struct rte_mbuf **rx_pkts,
+				uint16_t nb_pkts);
 
 #endif  /* ZXDH_RXTX_H */
Signature · 1 line
2.27.0
#79 lore raw

PATCH v4 9/15 net/zxdh: link info update, set link up/down

In reply to Junlong Wang

provided link info update, set link up /down,
and link intr.

---
 doc/guides/nics/features/zxdh.ini  |   2 +
 doc/guides/nics/zxdh.rst           |   3 +
 drivers/net/zxdh/meson.build       |   1 +
 drivers/net/zxdh/zxdh_ethdev.c     |  14 ++-
 drivers/net/zxdh/zxdh_ethdev.h     |   2 +
 drivers/net/zxdh/zxdh_ethdev_ops.c | 166 ++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |  14 +++
 drivers/net/zxdh/zxdh_msg.c        |  57 ++++++++++
 drivers/net/zxdh/zxdh_msg.h        |  40 +++++++
 drivers/net/zxdh/zxdh_np.c         | 172 ++++++++++++++++++++++++++++-
 drivers/net/zxdh/zxdh_np.h         |  20 ++++
 drivers/net/zxdh/zxdh_tables.c     |  15 +++
 drivers/net/zxdh/zxdh_tables.h     |   6 +-
 13 files changed, 503 insertions(+), 9 deletions(-)
 create mode 100644 drivers/net/zxdh/zxdh_ethdev_ops.c
 create mode 100644 drivers/net/zxdh/zxdh_ethdev_ops.h
doc/guides/nics/features/zxdh.ini +2 -0
index bb44e93fad..7da3aaced1 100644
@@ -10,3 +10,5 @@ ARMv8                = Y
 SR-IOV               = Y
 Multiprocess aware   = Y
 Scattered Rx         = Y
+Link status          = Y
+Link status event    = Y
doc/guides/nics/zxdh.rst +3 -0
index f42db9c1f1..fdbc3b3923 100644
@@ -21,6 +21,9 @@ Features of the ZXDH PMD are:
 - Multiple queues for TX and RX
 - SR-IOV VF
 - Scattered and gather for TX and RX
+- Link Auto-negotiation
+- Link state information
+- Set Link down or up
 
 
 Driver compilation and testing
drivers/net/zxdh/meson.build +1 -0
index 20b2cf484a..48f8f5e1ee 100644
@@ -22,4 +22,5 @@ sources = files(
         'zxdh_np.c',
         'zxdh_tables.c',
         'zxdh_rxtx.c',
+        'zxdh_ethdev_ops.c',
 )
drivers/net/zxdh/zxdh_ethdev.c +13 -1
index 0d63129d8d..d3876ec9b3 100644
@@ -16,6 +16,7 @@
 #include "zxdh_np.h"
 #include "zxdh_tables.h"
 #include "zxdh_rxtx.h"
+#include "zxdh_ethdev_ops.h"
 
 struct zxdh_hw_internal zxdh_hw_internal[RTE_MAX_ETHPORTS];
 struct zxdh_shared_data *zxdh_shared_data;
@@ -105,12 +106,18 @@ static void
 zxdh_devconf_intr_handler(void *param)
 {
 	struct rte_eth_dev *dev = param;
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	uint8_t isr = zxdh_pci_isr(hw);
 
 	if (zxdh_intr_unmask(dev) < 0)
 		PMD_DRV_LOG(ERR, "interrupt enable failed");
+	if (isr & ZXDH_PCI_ISR_CONFIG) {
+		if (zxdh_dev_link_update(dev, 0) == 0)
+			rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
+	}
 }
 
-
 /* Interrupt handler triggered by NIC for handling specific interrupt. */
 static void
 zxdh_fromriscv_intr_handler(void *param)
@@ -1006,6 +1013,8 @@ zxdh_dev_start(struct rte_eth_dev *dev)
 		vq = hw->vqs[logic_qidx];
 		zxdh_queue_notify(vq);
 	}
+	zxdh_dev_set_link_up(dev);
+
 	return 0;
 }
 
@@ -1020,6 +1029,9 @@ static const struct eth_dev_ops zxdh_eth_dev_ops = {
 	.tx_queue_setup			 = zxdh_dev_tx_queue_setup,
 	.rx_queue_intr_enable	 = zxdh_dev_rx_queue_intr_enable,
 	.rx_queue_intr_disable	 = zxdh_dev_rx_queue_intr_disable,
+	.link_update			 = zxdh_dev_link_update,
+	.dev_set_link_up		 = zxdh_dev_set_link_up,
+	.dev_set_link_down		 = zxdh_dev_set_link_down,
 };
 
 static int32_t
drivers/net/zxdh/zxdh_ethdev.h +2 -0
index b1f398b28e..c0b719062c 100644
@@ -72,6 +72,7 @@ struct zxdh_hw {
 	uint64_t guest_features;
 	uint32_t max_queue_pairs;
 	uint32_t speed;
+	uint32_t speed_mode;
 	uint32_t notify_off_multiplier;
 	uint16_t *notify_base;
 	uint16_t pcie_id;
@@ -93,6 +94,7 @@ struct zxdh_hw {
 	uint8_t panel_id;
 	uint8_t has_tx_offload;
 	uint8_t has_rx_offload;
+	uint8_t admin_status;
 };
 
 struct zxdh_dtb_shared_data {
drivers/net/zxdh/zxdh_ethdev_ops.c new file +166 -0

166 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev_ops.h new file +14 -0
new file mode 100644
index 0000000000..c6d6ca56fd
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 ZTE Corporation
+ */
+
+#ifndef ZXDH_ETHDEV_OPS_H
+#define ZXDH_ETHDEV_OPS_H
+
+#include "zxdh_ethdev.h"
+
+int zxdh_dev_set_link_up(struct rte_eth_dev *dev);
+int zxdh_dev_set_link_down(struct rte_eth_dev *dev);
+int32_t zxdh_dev_link_update(struct rte_eth_dev *dev, int32_t wait_to_complete __rte_unused);
+
+#endif /* ZXDH_ETHDEV_OPS_H */
drivers/net/zxdh/zxdh_msg.c +57 -0

66 lines not on this page · raw message

drivers/net/zxdh/zxdh_msg.h +40 -0
index 613ca71170..a78075c914 100644
@@ -164,11 +164,18 @@ enum pciebar_layout_type {
 	ZXDH_URI_MAX,
 };
 
+/* riscv msg opcodes */
+enum zxdh_agent_msg_type {
+	ZXDH_MAC_LINK_GET = 14,
+};
+
 enum zxdh_msg_type {
 	ZXDH_NULL = 0,
 	ZXDH_VF_PORT_INIT = 1,
 	ZXDH_VF_PORT_UNINIT = 2,
 
+	ZXDH_PORT_ATTRS_SET = 25,
+
 	ZXDH_MSG_TYPE_END,
 };
 
@@ -261,6 +268,15 @@ struct zxdh_offset_get_msg {
 	uint16_t type;
 };
 
+struct zxdh_link_info_msg {
+	uint8_t autoneg;
+	uint8_t link_state;
+	uint8_t blink_enable;
+	uint8_t duplex;
+	uint32_t speed_modes;
+	uint32_t speed;
+} __rte_packed;
+
 struct zxdh_msg_reply_head {
 	uint8_t flag;
 	uint16_t reps_len;
@@ -276,6 +292,7 @@ struct zxdh_msg_reply_body {
 	enum zxdh_reps_flag flag;
 	union {
 		uint8_t reply_data[ZXDH_MSG_REPLY_BODY_MAX_LEN - sizeof(enum zxdh_reps_flag)];
+		struct zxdh_link_info_msg link_msg;
 	} __rte_packed;
 } __rte_packed;
 
@@ -291,6 +308,12 @@ struct zxdh_vf_init_msg {
 	uint8_t rss_enable;
 } __rte_packed;
 
+struct zxdh_port_attr_set_msg {
+	uint32_t mode;
+	uint32_t value;
+	uint8_t allmulti_follow;
+} __rte_packed;
+
 struct zxdh_msg_head {
 	enum zxdh_msg_type msg_type;
 	uint16_t  vport;
@@ -298,14 +321,26 @@ struct zxdh_msg_head {
 	uint16_t pcieid;
 } __rte_packed;
 
+struct zxdh_agent_msg_head {
+	enum zxdh_agent_msg_type msg_type;
+	uint8_t panel_id;
+	uint8_t phyport;
+	uint8_t rsv;
+	uint16_t vf_id;
+	uint16_t pcie_id;
+} __rte_packed;
+
 struct zxdh_msg_info {
 	union {
 		uint8_t head_len[ZXDH_MSG_HEAD_LEN];
 		struct zxdh_msg_head msg_head;
+		struct zxdh_agent_msg_head agent_msg_head;
 	};
 	union {
 		uint8_t datainfo[ZXDH_MSG_REQ_BODY_MAX_LEN];
 		struct zxdh_vf_init_msg vf_init_msg;
+		struct zxdh_port_attr_set_msg port_attr_msg;
+		struct zxdh_link_info_msg link_msg;
 	} __rte_packed data;
 } __rte_packed;
 
@@ -326,5 +361,10 @@ void zxdh_msg_head_build(struct zxdh_hw *hw, enum zxdh_msg_type type,
 		struct zxdh_msg_info *msg_info);
 int zxdh_vf_send_msg_to_pf(struct rte_eth_dev *dev,  void *msg_req,
 			uint16_t msg_req_len, void *reply, uint16_t reply_len);
+void zxdh_agent_msg_build(struct zxdh_hw *hw, enum zxdh_agent_msg_type type,
+		struct zxdh_msg_info *msg_info);
+int32_t zxdh_send_msg_to_riscv(struct rte_eth_dev *dev, void *msg_req,
+			uint16_t msg_req_len, void *reply, uint16_t reply_len,
+			enum ZXDH_BAR_MODULE_ID module_id);
 
 #endif /* ZXDH_MSG_H */
drivers/net/zxdh/zxdh_np.c +166 -6

197 lines not on this page · raw message

drivers/net/zxdh/zxdh_np.h +20 -0
index 42a652dd6b..ac3931ba65 100644
@@ -514,11 +514,31 @@ typedef struct zxdh_sdt_tbl_data_t {
 	uint32_t data_low32;
 } ZXDH_SDT_TBL_DATA_T;
 
+typedef struct zxdh_sdt_tbl_etcam_t {
+	uint32_t table_type;
+	uint32_t etcam_id;
+	uint32_t etcam_key_mode;
+	uint32_t etcam_table_id;
+	uint32_t no_as_rsp_mode;
+	uint32_t as_en;
+	uint32_t as_eram_baddr;
+	uint32_t as_rsp_mode;
+	uint32_t etcam_table_depth;
+	uint32_t etcam_clutch_en;
+} ZXDH_SDTTBL_ETCAM_T;
+
+typedef struct zxdh_sdt_tbl_porttbl_t {
+	uint32_t table_type;
+	uint32_t porttbl_clutch_en;
+} ZXDH_SDTTBL_PORTTBL_T;
+
 int zxdh_np_host_init(uint32_t dev_id, ZXDH_DEV_INIT_CTRL_T *p_dev_init_ctrl);
 int zxdh_np_online_uninit(uint32_t dev_id, char *port_name, uint32_t queue_id);
 int zxdh_np_dtb_table_entry_write(uint32_t dev_id, uint32_t queue_id,
 			uint32_t entrynum, ZXDH_DTB_USER_ENTRY_T *down_entries);
 int zxdh_np_dtb_table_entry_delete(uint32_t dev_id, uint32_t queue_id,
 			 uint32_t entrynum, ZXDH_DTB_USER_ENTRY_T *delete_entries);
+int zxdh_np_dtb_table_entry_get(uint32_t dev_id, uint32_t queue_id,
+			ZXDH_DTB_USER_ENTRY_T *get_entry, uint32_t srh_mode);
 
 #endif /* ZXDH_NP_H */
drivers/net/zxdh/zxdh_tables.c +15 -0
index 9fd184e612..db0132ce3f 100644
@@ -134,3 +134,18 @@ int zxdh_panel_table_init(struct rte_eth_dev *dev)
 
 	return ret;
 }
+
+int
+zxdh_get_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr)
+{
+	int ret;
+
+	ZXDH_DTB_ERAM_ENTRY_INFO_T entry = {vfid, (uint32_t *)port_attr};
+	ZXDH_DTB_USER_ENTRY_T user_entry_get = {ZXDH_SDT_VPORT_ATT_TABLE, &entry};
+
+	ret = zxdh_np_dtb_table_entry_get(ZXDH_DEVICE_NO, g_dtb_data.queueid, &user_entry_get, 1);
+	if (ret != 0)
+		PMD_DRV_LOG(ERR, "get port_attr vfid:%d failed, ret:%d ", vfid, ret);
+
+	return ret;
+}
drivers/net/zxdh/zxdh_tables.h +4 -2
index 5e9b36faee..8676a8b375 100644
@@ -7,9 +7,10 @@
 
 #include <stdint.h>
 
-extern struct zxdh_dtb_shared_data g_dtb_data;
-
 #define ZXDH_DEVICE_NO                    0
+#define ZXDH_PORT_ATTR_IS_UP_FLAG         35
+
+extern struct zxdh_dtb_shared_data g_dtb_data;
 
 struct zxdh_port_attr_table {
 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
@@ -145,5 +146,6 @@ int zxdh_port_attr_init(struct rte_eth_dev *dev);
 int zxdh_panel_table_init(struct rte_eth_dev *dev);
 int zxdh_set_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr);
 int zxdh_port_attr_uninit(struct rte_eth_dev *dev);
+int zxdh_get_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr);
 
 #endif /* ZXDH_TABLES_H */
Signature · 1 line
2.27.0
#80 lore raw

PATCH v4 10/15 net/zxdh: mac set/add/remove ops implementations

In reply to Junlong Wang

provided mac set/add/remove ops.

---
 doc/guides/nics/features/zxdh.ini  |   2 +
 doc/guides/nics/zxdh.rst           |   2 +
 drivers/net/zxdh/zxdh_common.c     |  24 +++
 drivers/net/zxdh/zxdh_common.h     |   1 +
 drivers/net/zxdh/zxdh_ethdev.c     |  32 +++-
 drivers/net/zxdh/zxdh_ethdev.h     |   3 +
 drivers/net/zxdh/zxdh_ethdev_ops.c | 233 +++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |   4 +
 drivers/net/zxdh/zxdh_msg.h        |  12 ++
 drivers/net/zxdh/zxdh_np.h         |   5 +
 drivers/net/zxdh/zxdh_tables.c     | 197 ++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_tables.h     |  36 +++++
 12 files changed, 549 insertions(+), 2 deletions(-)
doc/guides/nics/features/zxdh.ini +2 -0
index 7da3aaced1..dc09fe3453 100644
@@ -12,3 +12,5 @@ Multiprocess aware   = Y
 Scattered Rx         = Y
 Link status          = Y
 Link status event    = Y
+Unicast MAC filter   = Y
+Multicast MAC filter = Y
doc/guides/nics/zxdh.rst +2 -0
index fdbc3b3923..e0b0776aca 100644
@@ -24,6 +24,8 @@ Features of the ZXDH PMD are:
 - Link Auto-negotiation
 - Link state information
 - Set Link down or up
+- Unicast MAC filter
+- Multicast MAC filter
 
 
 Driver compilation and testing
drivers/net/zxdh/zxdh_common.c +24 -0
index 4f18c97ed7..75883a8897 100644
@@ -256,6 +256,30 @@ zxdh_panelid_get(struct rte_eth_dev *dev, uint8_t *panelid)
 	return ret;
 }
 
+static int
+zxdh_get_res_hash_id(struct zxdh_res_para *in, uint8_t *hash_id)
+{
+	uint8_t reps = 0;
+	uint16_t reps_len = 0;
+
+	if (zxdh_get_res_info(in, ZXDH_TBL_FIELD_HASHID, &reps, &reps_len) != ZXDH_BAR_MSG_OK)
+		return -1;
+
+	*hash_id = reps;
+	return ZXDH_BAR_MSG_OK;
+}
+
+int32_t
+zxdh_hashidx_get(struct rte_eth_dev *dev, uint8_t *hash_idx)
+{
+	struct zxdh_res_para param;
+
+	zxdh_fill_res_para(dev, &param);
+	int32_t ret = zxdh_get_res_hash_id(&param, hash_idx);
+
+	return ret;
+}
+
 uint32_t
 zxdh_read_bar_reg(struct rte_eth_dev *dev, uint32_t bar, uint32_t reg)
 {
drivers/net/zxdh/zxdh_common.h +1 -0
index 72c29e1522..826f1fb95d 100644
@@ -22,6 +22,7 @@ struct zxdh_res_para {
 
 int32_t zxdh_phyport_get(struct rte_eth_dev *dev, uint8_t *phyport);
 int32_t zxdh_panelid_get(struct rte_eth_dev *dev, uint8_t *pannelid);
+int32_t zxdh_hashidx_get(struct rte_eth_dev *dev, uint8_t *hash_idx);
 uint32_t zxdh_read_bar_reg(struct rte_eth_dev *dev, uint32_t bar, uint32_t reg);
 void zxdh_write_bar_reg(struct rte_eth_dev *dev, uint32_t bar, uint32_t reg, uint32_t val);
 void zxdh_release_lock(struct zxdh_hw *hw);
drivers/net/zxdh/zxdh_ethdev.c +30 -2
index d3876ec9b3..85ada87cdc 100644
@@ -979,6 +979,23 @@ zxdh_set_rxtx_funcs(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
+static int
+zxdh_mac_config(struct rte_eth_dev *eth_dev)
+{
+	struct zxdh_hw *hw = eth_dev->data->dev_private;
+	int ret = 0;
+
+	if (hw->is_pf) {
+		ret = zxdh_set_mac_table(hw->vport.vport,
+				&eth_dev->data->mac_addrs[0], hw->hash_search_index);
+		if (ret) {
+			PMD_DRV_LOG(ERR, "Failed to add mac: port 0x%x", hw->vport.vport);
+			return ret;
+		}
+	}
+	return ret;
+}
+
 static int
 zxdh_dev_start(struct rte_eth_dev *dev)
 {
@@ -1014,6 +1031,9 @@ zxdh_dev_start(struct rte_eth_dev *dev)
 		zxdh_queue_notify(vq);
 	}
 	zxdh_dev_set_link_up(dev);
+	ret = zxdh_mac_config(hw->eth_dev);
+	if (ret)
+		PMD_DRV_LOG(ERR, " mac config failed");
 
 	return 0;
 }
@@ -1032,6 +1052,9 @@ static const struct eth_dev_ops zxdh_eth_dev_ops = {
 	.link_update			 = zxdh_dev_link_update,
 	.dev_set_link_up		 = zxdh_dev_set_link_up,
 	.dev_set_link_down		 = zxdh_dev_set_link_down,
+	.mac_addr_add			 = zxdh_dev_mac_addr_add,
+	.mac_addr_remove		 = zxdh_dev_mac_addr_remove,
+	.mac_addr_set			 = zxdh_dev_mac_addr_set,
 };
 
 static int32_t
@@ -1073,15 +1096,20 @@ zxdh_agent_comm(struct rte_eth_dev *eth_dev, struct zxdh_hw *hw)
 		PMD_DRV_LOG(ERR, "Failed to get phyport");
 		return -1;
 	}
-	PMD_DRV_LOG(INFO, "Get phyport success: 0x%x", hw->phyport);
+	PMD_DRV_LOG(DEBUG, "Get phyport success: 0x%x", hw->phyport);
 
 	hw->vfid = zxdh_vport_to_vfid(hw->vport);
 
+	if (zxdh_hashidx_get(eth_dev, &hw->hash_search_index) != 0) {
+		PMD_DRV_LOG(ERR, "Failed to get hash idx");
+		return -1;
+	}
+
 	if (zxdh_panelid_get(eth_dev, &hw->panel_id) != 0) {
 		PMD_DRV_LOG(ERR, "Failed to get panel_id");
 		return -1;
 	}
-	PMD_DRV_LOG(INFO, "Get panel id success: 0x%x", hw->panel_id);
+	PMD_DRV_LOG(DEBUG, "Get panel id success: 0x%x", hw->panel_id);
 
 	return 0;
 }
drivers/net/zxdh/zxdh_ethdev.h +3 -0
index c0b719062c..5b95cb1c2a 100644
@@ -80,6 +80,8 @@ struct zxdh_hw {
 	uint16_t port_id;
 	uint16_t vfid;
 	uint16_t queue_num;
+	uint16_t mc_num;
+	uint16_t uc_num;
 
 	uint8_t *isr;
 	uint8_t weak_barriers;
@@ -92,6 +94,7 @@ struct zxdh_hw {
 	uint8_t msg_chan_init;
 	uint8_t phyport;
 	uint8_t panel_id;
+	uint8_t hash_search_index;
 	uint8_t has_tx_offload;
 	uint8_t has_rx_offload;
 	uint8_t admin_status;
drivers/net/zxdh/zxdh_ethdev_ops.c +233 -0

236 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev_ops.h +4 -0
index c6d6ca56fd..4630bb70db 100644
@@ -10,5 +10,9 @@
 int zxdh_dev_set_link_up(struct rte_eth_dev *dev);
 int zxdh_dev_set_link_down(struct rte_eth_dev *dev);
 int32_t zxdh_dev_link_update(struct rte_eth_dev *dev, int32_t wait_to_complete __rte_unused);
+int zxdh_dev_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr,
+		uint32_t index, uint32_t vmdq);
+int zxdh_dev_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr);
+void zxdh_dev_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);
 
 #endif /* ZXDH_ETHDEV_OPS_H */
drivers/net/zxdh/zxdh_msg.h +12 -0
index a78075c914..44ce5d1b7f 100644
@@ -46,6 +46,9 @@
 #define ZXDH_MSG_REQ_BODY_MAX_LEN  \
 		(ZXDH_MSG_PAYLOAD_MAX_LEN - ZXDH_MSG_HEAD_LEN)
 
+#define ZXDH_MAC_FILTER            0xaa
+#define ZXDH_MAC_UNFILTER          0xff
+
 enum ZXDH_DRIVER_TYPE {
 	ZXDH_MSG_CHAN_END_MPF = 0,
 	ZXDH_MSG_CHAN_END_PF,
@@ -173,6 +176,8 @@ enum zxdh_msg_type {
 	ZXDH_NULL = 0,
 	ZXDH_VF_PORT_INIT = 1,
 	ZXDH_VF_PORT_UNINIT = 2,
+	ZXDH_MAC_ADD = 3,
+	ZXDH_MAC_DEL = 4,
 
 	ZXDH_PORT_ATTRS_SET = 25,
 
@@ -314,6 +319,12 @@ struct zxdh_port_attr_set_msg {
 	uint8_t allmulti_follow;
 } __rte_packed;
 
+struct zxdh_mac_filter {
+	uint8_t mac_flag;
+	uint8_t filter_flag;
+	struct rte_ether_addr mac;
+} __rte_packed;
+
 struct zxdh_msg_head {
 	enum zxdh_msg_type msg_type;
 	uint16_t  vport;
@@ -341,6 +352,7 @@ struct zxdh_msg_info {
 		struct zxdh_vf_init_msg vf_init_msg;
 		struct zxdh_port_attr_set_msg port_attr_msg;
 		struct zxdh_link_info_msg link_msg;
+		struct zxdh_mac_filter mac_filter_msg;
 	} __rte_packed data;
 } __rte_packed;
 
drivers/net/zxdh/zxdh_np.h +5 -0
index ac3931ba65..19d1f03f59 100644
@@ -532,6 +532,11 @@ typedef struct zxdh_sdt_tbl_porttbl_t {
 	uint32_t porttbl_clutch_en;
 } ZXDH_SDTTBL_PORTTBL_T;
 
+typedef struct zxdh_dtb_hash_entry_info_t {
+	uint8_t *p_actu_key;
+	uint8_t *p_rst;
+} ZXDH_DTB_HASH_ENTRY_INFO_T;
+
 int zxdh_np_host_init(uint32_t dev_id, ZXDH_DEV_INIT_CTRL_T *p_dev_init_ctrl);
 int zxdh_np_online_uninit(uint32_t dev_id, char *port_name, uint32_t queue_id);
 int zxdh_np_dtb_table_entry_write(uint32_t dev_id, uint32_t queue_id,
drivers/net/zxdh/zxdh_tables.c +197 -0

206 lines not on this page · raw message

drivers/net/zxdh/zxdh_tables.h +36 -0
index 8676a8b375..f16c4923ef 100644
@@ -142,10 +142,46 @@ struct zxdh_panel_table {
 	uint32_t rsv_2;
 }; /* 16B */
 
+struct zxdh_mac_unicast_key {
+	uint16_t rsv;
+	uint8_t  dmac_addr[6];
+};
+
+struct zxdh_mac_unicast_entry {
+	uint8_t rsv1     : 7,
+			hit_flag : 1;
+	uint8_t rsv;
+	uint16_t vfid;
+};
+
+struct zxdh_mac_unicast_table {
+	struct zxdh_mac_unicast_key key;
+	struct zxdh_mac_unicast_entry entry;
+};
+
+struct zxdh_mac_multicast_key {
+	uint8_t rsv;
+	uint8_t vf_group_id;
+	uint8_t mac_addr[6];
+};
+
+struct zxdh_mac_multicast_entry {
+	uint32_t mc_pf_enable;
+	uint32_t rsv1;
+	uint32_t mc_bitmap[2];
+};
+
+struct zxdh_mac_multicast_table {
+	struct zxdh_mac_multicast_key key;
+	struct zxdh_mac_multicast_entry entry;
+};
+
 int zxdh_port_attr_init(struct rte_eth_dev *dev);
 int zxdh_panel_table_init(struct rte_eth_dev *dev);
 int zxdh_set_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr);
 int zxdh_port_attr_uninit(struct rte_eth_dev *dev);
 int zxdh_get_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr);
+int zxdh_set_mac_table(uint16_t vport, struct rte_ether_addr *addr,  uint8_t hash_search_idx);
+int zxdh_del_mac_table(uint16_t vport, struct rte_ether_addr *addr,  uint8_t hash_search_idx);
 
 #endif /* ZXDH_TABLES_H */
Signature · 1 line
2.27.0
#81 lore raw

PATCH v4 11/15 net/zxdh: promisc/allmulti ops implementations

In reply to Junlong Wang

provided promiscuous/allmulticast ops.

---
 doc/guides/nics/features/zxdh.ini  |   2 +
 doc/guides/nics/zxdh.rst           |   2 +
 drivers/net/zxdh/zxdh_ethdev.c     |  21 ++-
 drivers/net/zxdh/zxdh_ethdev.h     |   2 +
 drivers/net/zxdh/zxdh_ethdev_ops.c | 132 +++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |   4 +
 drivers/net/zxdh/zxdh_msg.h        |  10 ++
 drivers/net/zxdh/zxdh_tables.c     | 223 +++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_tables.h     |  22 +++
 9 files changed, 417 insertions(+), 1 deletion(-)
doc/guides/nics/features/zxdh.ini +2 -0
index dc09fe3453..e9b237e102 100644
@@ -14,3 +14,5 @@ Link status          = Y
 Link status event    = Y
 Unicast MAC filter   = Y
 Multicast MAC filter = Y
+Promiscuous mode     = Y
+Allmulticast mode    = Y
doc/guides/nics/zxdh.rst +2 -0
index e0b0776aca..0399df1302 100644
@@ -26,6 +26,8 @@ Features of the ZXDH PMD are:
 - Set Link down or up
 - Unicast MAC filter
 - Multicast MAC filter
+- Promiscuous mode
+- Multicast mode
 
 
 Driver compilation and testing
drivers/net/zxdh/zxdh_ethdev.c +20 -1
index 85ada87cdc..1d64b877c1 100644
@@ -901,8 +901,16 @@ zxdh_tables_uninit(struct rte_eth_dev *dev)
 	int ret;
 
 	ret = zxdh_port_attr_uninit(dev);
-	if (ret)
+	if (ret) {
 		PMD_DRV_LOG(ERR, "zxdh_port_attr_uninit failed");
+		return ret;
+	}
+
+	ret = zxdh_promisc_table_uninit(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "uninit promisc_table failed");
+		return ret;
+	}
 
 	return ret;
 }
@@ -1055,6 +1063,10 @@ static const struct eth_dev_ops zxdh_eth_dev_ops = {
 	.mac_addr_add			 = zxdh_dev_mac_addr_add,
 	.mac_addr_remove		 = zxdh_dev_mac_addr_remove,
 	.mac_addr_set			 = zxdh_dev_mac_addr_set,
+	.promiscuous_enable		 = zxdh_dev_promiscuous_enable,
+	.promiscuous_disable	 = zxdh_dev_promiscuous_disable,
+	.allmulticast_enable	 = zxdh_dev_allmulticast_enable,
+	.allmulticast_disable	 = zxdh_dev_allmulticast_disable,
 };
 
 static int32_t
@@ -1306,6 +1318,13 @@ zxdh_tables_init(struct rte_eth_dev *dev)
 		PMD_DRV_LOG(ERR, " panel table init failed");
 		return ret;
 	}
+
+	ret = zxdh_promisc_table_init(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "promisc_table_init failed");
+		return ret;
+	}
+
 	return ret;
 }
 
drivers/net/zxdh/zxdh_ethdev.h +2 -0
index 5b95cb1c2a..3cdac5de73 100644
@@ -98,6 +98,8 @@ struct zxdh_hw {
 	uint8_t has_tx_offload;
 	uint8_t has_rx_offload;
 	uint8_t admin_status;
+	uint8_t promisc_status;
+	uint8_t allmulti_status;
 };
 
 struct zxdh_dtb_shared_data {
drivers/net/zxdh/zxdh_ethdev_ops.c +132 -0

135 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev_ops.h +4 -0
index 4630bb70db..394ddedc0e 100644
@@ -14,5 +14,9 @@ int zxdh_dev_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac_ad
 		uint32_t index, uint32_t vmdq);
 int zxdh_dev_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr);
 void zxdh_dev_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);
+int zxdh_dev_promiscuous_enable(struct rte_eth_dev *dev);
+int zxdh_dev_promiscuous_disable(struct rte_eth_dev *dev);
+int zxdh_dev_allmulticast_enable(struct rte_eth_dev *dev);
+int zxdh_dev_allmulticast_disable(struct rte_eth_dev *dev);
 
 #endif /* ZXDH_ETHDEV_OPS_H */
drivers/net/zxdh/zxdh_msg.h +10 -0
index 44ce5d1b7f..2abf579a80 100644
@@ -48,6 +48,8 @@
 
 #define ZXDH_MAC_FILTER            0xaa
 #define ZXDH_MAC_UNFILTER          0xff
+#define ZXDH_PROMISC_MODE          1
+#define ZXDH_ALLMULTI_MODE         2
 
 enum ZXDH_DRIVER_TYPE {
 	ZXDH_MSG_CHAN_END_MPF = 0,
@@ -180,6 +182,7 @@ enum zxdh_msg_type {
 	ZXDH_MAC_DEL = 4,
 
 	ZXDH_PORT_ATTRS_SET = 25,
+	ZXDH_PORT_PROMISC_SET = 26,
 
 	ZXDH_MSG_TYPE_END,
 };
@@ -325,6 +328,12 @@ struct zxdh_mac_filter {
 	struct rte_ether_addr mac;
 } __rte_packed;
 
+struct zxdh_port_promisc_msg {
+	uint8_t mode;
+	uint8_t value;
+	uint8_t mc_follow;
+} __rte_packed;
+
 struct zxdh_msg_head {
 	enum zxdh_msg_type msg_type;
 	uint16_t  vport;
@@ -353,6 +362,7 @@ struct zxdh_msg_info {
 		struct zxdh_port_attr_set_msg port_attr_msg;
 		struct zxdh_link_info_msg link_msg;
 		struct zxdh_mac_filter mac_filter_msg;
+		struct zxdh_port_promisc_msg port_promisc_msg;
 	} __rte_packed data;
 } __rte_packed;
 
drivers/net/zxdh/zxdh_tables.c +223 -0

236 lines not on this page · raw message

drivers/net/zxdh/zxdh_tables.h +22 -0
index f16c4923ef..fb30c8f32e 100644
@@ -176,6 +176,24 @@ struct zxdh_mac_multicast_table {
 	struct zxdh_mac_multicast_entry entry;
 };
 
+struct zxdh_brocast_table {
+	uint32_t flag;
+	uint32_t rsv;
+	uint32_t bitmap[2];
+};
+
+struct zxdh_unitcast_table {
+	uint32_t uc_flood_pf_enable;
+	uint32_t rsv;
+	uint32_t bitmap[2];
+};
+
+struct zxdh_multicast_table {
+	uint32_t mc_flood_pf_enable;
+	uint32_t rsv;
+	uint32_t bitmap[2];
+};
+
 int zxdh_port_attr_init(struct rte_eth_dev *dev);
 int zxdh_panel_table_init(struct rte_eth_dev *dev);
 int zxdh_set_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr);
@@ -183,5 +201,9 @@ int zxdh_port_attr_uninit(struct rte_eth_dev *dev);
 int zxdh_get_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr);
 int zxdh_set_mac_table(uint16_t vport, struct rte_ether_addr *addr,  uint8_t hash_search_idx);
 int zxdh_del_mac_table(uint16_t vport, struct rte_ether_addr *addr,  uint8_t hash_search_idx);
+int zxdh_promisc_table_init(struct rte_eth_dev *dev);
+int zxdh_promisc_table_uninit(struct rte_eth_dev *dev);
+int zxdh_dev_unicast_table_set(struct zxdh_hw *hw, uint16_t vport, bool enable);
+int zxdh_dev_multicast_table_set(struct zxdh_hw *hw, uint16_t vport, bool enable);
 
 #endif /* ZXDH_TABLES_H */
Signature · 1 line
2.27.0
#82 lore raw

PATCH v4 12/15 net/zxdh: vlan filter/ offload ops implementations

In reply to Junlong Wang

provided vlan filter, vlan offload ops.

---
 doc/guides/nics/features/zxdh.ini  |   3 +
 doc/guides/nics/zxdh.rst           |   3 +
 drivers/net/zxdh/zxdh_ethdev.c     |  40 +++++-
 drivers/net/zxdh/zxdh_ethdev_ops.c | 223 +++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |   2 +
 drivers/net/zxdh/zxdh_msg.h        |  22 +++
 drivers/net/zxdh/zxdh_rxtx.c       |  18 +++
 drivers/net/zxdh/zxdh_tables.c     |  99 +++++++++++++
 drivers/net/zxdh/zxdh_tables.h     |  10 +-
 9 files changed, 417 insertions(+), 3 deletions(-)
doc/guides/nics/features/zxdh.ini +3 -0
index e9b237e102..6fb006c2da 100644
@@ -16,3 +16,6 @@ Unicast MAC filter   = Y
 Multicast MAC filter = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
+VLAN filter          = Y
+VLAN offload         = Y
+QinQ offload         = Y
doc/guides/nics/zxdh.rst +3 -0
index 0399df1302..3a7585d123 100644
@@ -28,6 +28,9 @@ Features of the ZXDH PMD are:
 - Multicast MAC filter
 - Promiscuous mode
 - Multicast mode
+- VLAN filter and VLAN offload
+- VLAN stripping and inserting
+- QINQ stripping and inserting
 
 
 Driver compilation and testing
drivers/net/zxdh/zxdh_ethdev.c +39 -1
index 1d64b877c1..cc32b467a9 100644
@@ -758,6 +758,34 @@ zxdh_alloc_queues(struct rte_eth_dev *dev, uint16_t nr_vq)
 	return 0;
 }
 
+static int
+zxdh_vlan_offload_configure(struct rte_eth_dev *dev)
+{
+	int ret;
+	int mask = RTE_ETH_VLAN_STRIP_MASK | RTE_ETH_VLAN_FILTER_MASK |	RTE_ETH_QINQ_STRIP_MASK;
+
+	ret = zxdh_dev_vlan_offload_set(dev, mask);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "vlan offload set error");
+		return -1;
+	}
+
+	return 0;
+}
+
+static int
+zxdh_dev_conf_offload(struct rte_eth_dev *dev)
+{
+	int ret = 0;
+
+	ret = zxdh_vlan_offload_configure(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "zxdh_vlan_offload_configure failed");
+		return ret;
+	}
+
+	return 0;
+}
 
 static int32_t
 zxdh_dev_configure(struct rte_eth_dev *dev)
@@ -815,7 +843,7 @@ zxdh_dev_configure(struct rte_eth_dev *dev)
 
 	nr_vq = dev->data->nb_rx_queues + dev->data->nb_tx_queues;
 	if (nr_vq == hw->queue_num)
-		return 0;
+		goto end;
 
 	PMD_DRV_LOG(DEBUG, "queue changed need reset ");
 	/* Reset the device although not necessary at startup */
@@ -847,6 +875,8 @@ zxdh_dev_configure(struct rte_eth_dev *dev)
 
 	zxdh_pci_reinit_complete(hw);
 
+end:
+	zxdh_dev_conf_offload(dev);
 	return ret;
 }
 
@@ -1067,6 +1097,8 @@ static const struct eth_dev_ops zxdh_eth_dev_ops = {
 	.promiscuous_disable	 = zxdh_dev_promiscuous_disable,
 	.allmulticast_enable	 = zxdh_dev_allmulticast_enable,
 	.allmulticast_disable	 = zxdh_dev_allmulticast_disable,
+	.vlan_filter_set		 = zxdh_dev_vlan_filter_set,
+	.vlan_offload_set		 = zxdh_dev_vlan_offload_set,
 };
 
 static int32_t
@@ -1325,6 +1357,12 @@ zxdh_tables_init(struct rte_eth_dev *dev)
 		return ret;
 	}
 
+	ret = zxdh_vlan_filter_table_init(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, " vlan filter table init failed");
+		return ret;
+	}
+
 	return ret;
 }
 
drivers/net/zxdh/zxdh_ethdev_ops.c +223 -0

238 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev_ops.h +2 -0
index 394ddedc0e..058d271ab3 100644
@@ -18,5 +18,7 @@ int zxdh_dev_promiscuous_enable(struct rte_eth_dev *dev);
 int zxdh_dev_promiscuous_disable(struct rte_eth_dev *dev);
 int zxdh_dev_allmulticast_enable(struct rte_eth_dev *dev);
 int zxdh_dev_allmulticast_disable(struct rte_eth_dev *dev);
+int zxdh_dev_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on);
+int zxdh_dev_vlan_offload_set(struct rte_eth_dev *dev, int mask);
 
 #endif /* ZXDH_ETHDEV_OPS_H */
drivers/net/zxdh/zxdh_msg.h +22 -0
index 2abf579a80..ec15388f7a 100644
@@ -50,6 +50,8 @@
 #define ZXDH_MAC_UNFILTER          0xff
 #define ZXDH_PROMISC_MODE          1
 #define ZXDH_ALLMULTI_MODE         2
+#define ZXDH_VLAN_STRIP_MSG_TYPE   0
+#define ZXDH_QINQ_STRIP_MSG_TYPE   1
 
 enum ZXDH_DRIVER_TYPE {
 	ZXDH_MSG_CHAN_END_MPF = 0,
@@ -180,6 +182,10 @@ enum zxdh_msg_type {
 	ZXDH_VF_PORT_UNINIT = 2,
 	ZXDH_MAC_ADD = 3,
 	ZXDH_MAC_DEL = 4,
+	ZXDH_VLAN_FILTER_SET = 17,
+	ZXDH_VLAN_FILTER_ADD = 18,
+	ZXDH_VLAN_FILTER_DEL = 19,
+	ZXDH_VLAN_OFFLOAD = 21,
 
 	ZXDH_PORT_ATTRS_SET = 25,
 	ZXDH_PORT_PROMISC_SET = 26,
@@ -341,6 +347,19 @@ struct zxdh_msg_head {
 	uint16_t pcieid;
 } __rte_packed;
 
+struct zxdh_vlan_filter {
+	uint16_t vlan_id;
+};
+
+struct zxdh_vlan_filter_set {
+	uint8_t enable;
+};
+
+struct zxdh_vlan_offload {
+	uint8_t enable;
+	uint8_t type;
+} __rte_packed;
+
 struct zxdh_agent_msg_head {
 	enum zxdh_agent_msg_type msg_type;
 	uint8_t panel_id;
@@ -363,6 +382,9 @@ struct zxdh_msg_info {
 		struct zxdh_link_info_msg link_msg;
 		struct zxdh_mac_filter mac_filter_msg;
 		struct zxdh_port_promisc_msg port_promisc_msg;
+		struct zxdh_vlan_filter vlan_filter_msg;
+		struct zxdh_vlan_filter_set vlan_filter_set_msg;
+		struct zxdh_vlan_offload vlan_offload_msg;
 	} __rte_packed data;
 } __rte_packed;
 
drivers/net/zxdh/zxdh_rxtx.c +18 -0
index 06290d48bb..0ffce50042 100644
@@ -11,6 +11,9 @@
 #include "zxdh_pci.h"
 #include "zxdh_queue.h"
 
+#define ZXDH_SVLAN_TPID                       0x88a8
+#define ZXDH_CVLAN_TPID                       0x8100
+
 #define ZXDH_PKT_FORM_CPU                     0x20    /* 1-cpu 0-np */
 #define ZXDH_NO_IP_FRAGMENT                   0x2000  /* ip fragment flag */
 #define ZXDH_NO_IPID_UPDATE                   0x4000  /* ipid update flag */
@@ -21,6 +24,9 @@
 #define ZXDH_PI_L3TYPE_RSV                    0xC0
 #define ZXDH_PI_L3TYPE_MASK                   0xC0
 
+#define  ZXDH_PD_OFFLOAD_SVLAN_INSERT         (1 << 14)
+#define  ZXDH_PD_OFFLOAD_CVLAN_INSERT         (1 << 13)
+
 #define ZXDH_PCODE_MASK                       0x1F
 #define ZXDH_PCODE_IP_PKT_TYPE                0x01
 #define ZXDH_PCODE_TCP_PKT_TYPE               0x02
@@ -259,6 +265,18 @@ static void zxdh_xmit_fill_net_hdr(struct rte_mbuf *cookie,
 	hdr->pi_hdr.l3_offset = rte_be_to_cpu_16(l3_offset);
 	hdr->pi_hdr.l4_offset = rte_be_to_cpu_16(l3_offset + cookie->l3_len);
 
+	if (cookie->ol_flags & RTE_MBUF_F_TX_VLAN) {
+		ol_flag |= ZXDH_PD_OFFLOAD_CVLAN_INSERT;
+		hdr->pi_hdr.vlan_id = rte_be_to_cpu_16(cookie->vlan_tci);
+		hdr->pd_hdr.cvlan_insert =
+			rte_be_to_cpu_32((ZXDH_CVLAN_TPID << 16) | cookie->vlan_tci);
+	}
+	if (cookie->ol_flags & RTE_MBUF_F_TX_QINQ) {
+		ol_flag |= ZXDH_PD_OFFLOAD_SVLAN_INSERT;
+		hdr->pd_hdr.svlan_insert =
+			rte_be_to_cpu_32((ZXDH_SVLAN_TPID << 16) | cookie->vlan_tci_outer);
+	}
+
 	hdr->pd_hdr.ol_flag = rte_be_to_cpu_32(ol_flag);
 }
 
drivers/net/zxdh/zxdh_tables.c +99 -0

114 lines not on this page · raw message

drivers/net/zxdh/zxdh_tables.h +8 -2
index fb30c8f32e..8dac8f30dd 100644
@@ -43,7 +43,7 @@ struct zxdh_port_attr_table {
 	uint8_t rdma_offload_enable: 1;
 	uint8_t vlan_filter_enable: 1;
 	uint8_t vlan_strip_offload: 1;
-	uint8_t qinq_valn_strip_offload: 1;
+	uint8_t qinq_strip_offload: 1;
 	uint8_t rss_enable: 1;
 	uint8_t mtu_enable: 1;
 	uint8_t hit_flag: 1;
@@ -73,7 +73,7 @@ struct zxdh_port_attr_table {
 	uint8_t rdma_offload_enable: 1;
 	uint8_t vlan_filter_enable: 1;
 	uint8_t vlan_strip_offload: 1;
-	uint8_t qinq_valn_strip_offload: 1;
+	uint8_t qinq_strip_offload: 1;
 	uint8_t rss_enable: 1;
 	uint8_t mtu_enable: 1;
 	uint8_t hit_flag: 1;
@@ -194,6 +194,10 @@ struct zxdh_multicast_table {
 	uint32_t bitmap[2];
 };
 
+struct zxdh_vlan_filter_table {
+	uint32_t vlans[4];
+};
+
 int zxdh_port_attr_init(struct rte_eth_dev *dev);
 int zxdh_panel_table_init(struct rte_eth_dev *dev);
 int zxdh_set_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr);
@@ -205,5 +209,7 @@ int zxdh_promisc_table_init(struct rte_eth_dev *dev);
 int zxdh_promisc_table_uninit(struct rte_eth_dev *dev);
 int zxdh_dev_unicast_table_set(struct zxdh_hw *hw, uint16_t vport, bool enable);
 int zxdh_dev_multicast_table_set(struct zxdh_hw *hw, uint16_t vport, bool enable);
+int zxdh_vlan_filter_table_init(struct rte_eth_dev *dev);
+int zxdh_vlan_filter_table_set(uint16_t vport, uint16_t vlan_id, uint8_t enable);
 
 #endif /* ZXDH_TABLES_H */
Signature · 1 line
2.27.0
#83 lore raw

PATCH v4 13/15 net/zxdh: rss hash config/update, reta update/get

In reply to Junlong Wang

provided rss hash config/update, reta update/get ops.

---
 doc/guides/nics/features/zxdh.ini  |   3 +
 doc/guides/nics/zxdh.rst           |   1 +
 drivers/net/zxdh/zxdh_ethdev.c     |  52 ++++
 drivers/net/zxdh/zxdh_ethdev.h     |   3 +
 drivers/net/zxdh/zxdh_ethdev_ops.c | 410 +++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |  26 ++
 drivers/net/zxdh/zxdh_msg.h        |  22 ++
 drivers/net/zxdh/zxdh_tables.c     |  82 ++++++
 drivers/net/zxdh/zxdh_tables.h     |   7 +
 9 files changed, 606 insertions(+)
doc/guides/nics/features/zxdh.ini +3 -0
index 6fb006c2da..415ca547d0 100644
@@ -19,3 +19,6 @@ Allmulticast mode    = Y
 VLAN filter          = Y
 VLAN offload         = Y
 QinQ offload         = Y
+RSS hash             = Y
+RSS reta update      = Y
+Inner RSS            = Y
doc/guides/nics/zxdh.rst +1 -0
index 3a7585d123..3cc6a1d348 100644
@@ -31,6 +31,7 @@ Features of the ZXDH PMD are:
 - VLAN filter and VLAN offload
 - VLAN stripping and inserting
 - QINQ stripping and inserting
+- Receive Side Scaling (RSS)
 
 
 Driver compilation and testing
drivers/net/zxdh/zxdh_ethdev.c +52 -0

79 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev.h +3 -0
index 3cdac5de73..2934fa264a 100644
@@ -82,6 +82,7 @@ struct zxdh_hw {
 	uint16_t queue_num;
 	uint16_t mc_num;
 	uint16_t uc_num;
+	uint16_t *rss_reta;
 
 	uint8_t *isr;
 	uint8_t weak_barriers;
@@ -100,6 +101,8 @@ struct zxdh_hw {
 	uint8_t admin_status;
 	uint8_t promisc_status;
 	uint8_t allmulti_status;
+	uint8_t rss_enable;
+	uint8_t rss_init;
 };
 
 struct zxdh_dtb_shared_data {
drivers/net/zxdh/zxdh_ethdev_ops.c +410 -0

425 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev_ops.h +26 -0
index 058d271ab3..860716d079 100644
@@ -5,8 +5,25 @@
 #ifndef ZXDH_ETHDEV_OPS_H
 #define ZXDH_ETHDEV_OPS_H
 
+#include <rte_ether.h>
+
 #include "zxdh_ethdev.h"
 
+#define ZXDH_ETH_RSS_L2  RTE_ETH_RSS_L2_PAYLOAD
+#define ZXDH_ETH_RSS_IP \
+			(RTE_ETH_RSS_IPV4 | \
+			 RTE_ETH_RSS_FRAG_IPV4 | \
+			 RTE_ETH_RSS_IPV6 | \
+			 RTE_ETH_RSS_FRAG_IPV6)
+#define ZXDH_ETH_RSS_TCP    (RTE_ETH_RSS_NONFRAG_IPV4_TCP | RTE_ETH_RSS_NONFRAG_IPV6_TCP)
+#define ZXDH_ETH_RSS_UDP    (RTE_ETH_RSS_NONFRAG_IPV4_UDP | RTE_ETH_RSS_NONFRAG_IPV6_UDP)
+#define ZXDH_ETH_RSS_SCTP   (RTE_ETH_RSS_NONFRAG_IPV4_SCTP | RTE_ETH_RSS_NONFRAG_IPV6_SCTP)
+
+#define ZXDH_HF_F5_ETH       (ZXDH_ETH_RSS_TCP | ZXDH_ETH_RSS_UDP | ZXDH_ETH_RSS_SCTP)
+#define ZXDH_HF_F3_ETH        ZXDH_ETH_RSS_IP
+#define ZXDH_HF_MAC_VLAN_ETH  ZXDH_ETH_RSS_L2
+#define ZXDH_RSS_HF  ((ZXDH_HF_MAC_VLAN_ETH | ZXDH_HF_F3_ETH | ZXDH_HF_F5_ETH))
+
 int zxdh_dev_set_link_up(struct rte_eth_dev *dev);
 int zxdh_dev_set_link_down(struct rte_eth_dev *dev);
 int32_t zxdh_dev_link_update(struct rte_eth_dev *dev, int32_t wait_to_complete __rte_unused);
@@ -20,5 +37,14 @@ int zxdh_dev_allmulticast_enable(struct rte_eth_dev *dev);
 int zxdh_dev_allmulticast_disable(struct rte_eth_dev *dev);
 int zxdh_dev_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on);
 int zxdh_dev_vlan_offload_set(struct rte_eth_dev *dev, int mask);
+int zxdh_dev_rss_reta_update(struct rte_eth_dev *dev,
+			 struct rte_eth_rss_reta_entry64 *reta_conf,
+			 uint16_t reta_size);
+int zxdh_dev_rss_reta_query(struct rte_eth_dev *dev,
+			struct rte_eth_rss_reta_entry64 *reta_conf,
+			uint16_t reta_size);
+int zxdh_rss_hash_update(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf);
+int zxdh_rss_hash_conf_get(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf);
+int zxdh_rss_configure(struct rte_eth_dev *dev);
 
 #endif /* ZXDH_ETHDEV_OPS_H */
drivers/net/zxdh/zxdh_msg.h +22 -0
index ec15388f7a..45a9b10aa4 100644
@@ -182,6 +182,11 @@ enum zxdh_msg_type {
 	ZXDH_VF_PORT_UNINIT = 2,
 	ZXDH_MAC_ADD = 3,
 	ZXDH_MAC_DEL = 4,
+	ZXDH_RSS_ENABLE = 7,
+	ZXDH_RSS_RETA_SET = 8,
+	ZXDH_RSS_RETA_GET = 9,
+	ZXDH_RSS_HF_SET = 15,
+	ZXDH_RSS_HF_GET = 16,
 	ZXDH_VLAN_FILTER_SET = 17,
 	ZXDH_VLAN_FILTER_ADD = 18,
 	ZXDH_VLAN_FILTER_DEL = 19,
@@ -291,6 +296,14 @@ struct zxdh_link_info_msg {
 	uint32_t speed;
 } __rte_packed;
 
+struct zxdh_rss_reta {
+	uint32_t reta[RTE_ETH_RSS_RETA_SIZE_256];
+};
+
+struct zxdh_rss_hf {
+	uint32_t rss_hf;
+};
+
 struct zxdh_msg_reply_head {
 	uint8_t flag;
 	uint16_t reps_len;
@@ -307,6 +320,8 @@ struct zxdh_msg_reply_body {
 	union {
 		uint8_t reply_data[ZXDH_MSG_REPLY_BODY_MAX_LEN - sizeof(enum zxdh_reps_flag)];
 		struct zxdh_link_info_msg link_msg;
+		struct zxdh_rss_hf rss_hf;
+		struct zxdh_rss_reta rss_reta;
 	} __rte_packed;
 } __rte_packed;
 
@@ -360,6 +375,10 @@ struct zxdh_vlan_offload {
 	uint8_t type;
 } __rte_packed;
 
+struct zxdh_rss_enable {
+	uint8_t enable;
+};
+
 struct zxdh_agent_msg_head {
 	enum zxdh_agent_msg_type msg_type;
 	uint8_t panel_id;
@@ -385,6 +404,9 @@ struct zxdh_msg_info {
 		struct zxdh_vlan_filter vlan_filter_msg;
 		struct zxdh_vlan_filter_set vlan_filter_set_msg;
 		struct zxdh_vlan_offload vlan_offload_msg;
+		struct zxdh_rss_reta rss_reta;
+		struct zxdh_rss_enable rss_enable;
+		struct zxdh_rss_hf rss_hf;
 	} __rte_packed data;
 } __rte_packed;
 
drivers/net/zxdh/zxdh_tables.c +82 -0

91 lines not on this page · raw message

drivers/net/zxdh/zxdh_tables.h +7 -0
index 8dac8f30dd..7bac39375c 100644
@@ -8,6 +8,7 @@
 #include <stdint.h>
 
 #define ZXDH_DEVICE_NO                    0
+#define ZXDH_PORT_BASE_QID_FLAG           10
 #define ZXDH_PORT_ATTR_IS_UP_FLAG         35
 
 extern struct zxdh_dtb_shared_data g_dtb_data;
@@ -198,6 +199,10 @@ struct zxdh_vlan_filter_table {
 	uint32_t vlans[4];
 };
 
+struct zxdh_rss_to_vqid_table {
+	uint16_t vqm_qid[8];
+};
+
 int zxdh_port_attr_init(struct rte_eth_dev *dev);
 int zxdh_panel_table_init(struct rte_eth_dev *dev);
 int zxdh_set_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr);
@@ -211,5 +216,7 @@ int zxdh_dev_unicast_table_set(struct zxdh_hw *hw, uint16_t vport, bool enable);
 int zxdh_dev_multicast_table_set(struct zxdh_hw *hw, uint16_t vport, bool enable);
 int zxdh_vlan_filter_table_init(struct rte_eth_dev *dev);
 int zxdh_vlan_filter_table_set(uint16_t vport, uint16_t vlan_id, uint8_t enable);
+int zxdh_rss_table_set(uint16_t vport, struct zxdh_rss_reta *rss_reta);
+int zxdh_rss_table_get(uint16_t vport, struct zxdh_rss_reta *rss_reta);
 
 #endif /* ZXDH_TABLES_H */
Signature · 1 line
2.27.0
#84 lore raw

Re: [PATCH v4 13/15] net/zxdh: rss hash config/update, reta update/get

Quoted 15 lines · On Wed, 18 Dec 2024 17:26:00 +0800 Junlong Wang <[email protected]>…

provided rss hash config/update, reta update/get ops.

---
 doc/guides/nics/features/zxdh.ini  |   3 +
 doc/guides/nics/zxdh.rst           |   1 +
 drivers/net/zxdh/zxdh_ethdev.c     |  52 ++++
 drivers/net/zxdh/zxdh_ethdev.h     |   3 +
 drivers/net/zxdh/zxdh_ethdev_ops.c | 410 +++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |  26 ++
 drivers/net/zxdh/zxdh_msg.h        |  22 ++
 drivers/net/zxdh/zxdh_tables.c     |  82 ++++++
 drivers/net/zxdh/zxdh_tables.h     |   7 +
 9 files changed, 606 insertions(+)

Some suggestions:

Quoted 9 lines
drivers/net/zxdh/zxdh_ethdev_ops.c +9 -0
+int
+zxdh_dev_rss_reta_update(struct rte_eth_dev *dev,
+			 struct rte_eth_rss_reta_entry64 *reta_conf,
+			 uint16_t reta_size)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+	struct zxdh_msg_info msg = {0};
+	uint16_t old_reta[RTE_ETH_RSS_RETA_SIZE_256];
+	uint16_t idx;

drivers/net/zxdh/zxdh_ethdev_ops.c zxdh_dev_vlan_offload_set(struct rte_eth_dev *dev, int mask) · line 783

Quoted 10 lines
drivers/net/zxdh/zxdh_ethdev_ops.c +10 -0
+	uint16_t i;
+	uint16_t pos;
+	int ret;
+
+	if (reta_size != RTE_ETH_RSS_RETA_SIZE_256) {
+		PMD_DRV_LOG(ERR, "reta_size is illegal(%u).reta_size should be 256", reta_size);
+		return -EINVAL;
+	}
+	if (!hw->rss_reta) {
+		hw->rss_reta = rte_zmalloc(NULL, RTE_ETH_RSS_RETA_SIZE_256 * sizeof(uint16_t), 4);

This could be rte_calloc()

...

Quoted 7 lines
drivers/net/zxdh/zxdh_tables.c +7 -0
+int
+zxdh_rss_table_set(uint16_t vport, struct zxdh_rss_reta *rss_reta)
+{
+	struct zxdh_rss_to_vqid_table rss_vqid = {0};
+	union zxdh_virport_num vport_num = (union zxdh_virport_num)vport;
+	int ret = 0;
+

drivers/net/zxdh/zxdh_tables.c zxdh_vlan_filter_table_set(uint16_t vport, uint16_t vlan_id, uint8_t enable) · line 689

Quoted 10 lines
drivers/net/zxdh/zxdh_tables.c +10 -0
+	for (uint16_t i = 0; i < RTE_ETH_RSS_RETA_SIZE_256 / 8; i++) {
+		for (uint16_t j = 0; j < 8; j++) {
+		#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
+			if (j % 2 == 0)
+				rss_vqid.vqm_qid[j + 1] =  rss_reta->reta[i * 8 + j];
+			else
+				rss_vqid.vqm_qid[j - 1] =  rss_reta->reta[i * 8 + j];
+		#else
+			rss_vqid.vqm_qid[j] = rss_init->reta[i * 8 + j];
+		#endif

Please put #if in first column not indented. Better yet, use rte_byteorder functions to elimnate #if code pattern.

Quoted 7 lines
drivers/net/zxdh/zxdh_tables.c +7 -0
+		}
+
+		#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
+			rss_vqid.vqm_qid[1] |= 0x8000;
+		#else
+			rss_vqid.vqm_qid[0] |= 0x8000;
+		#endif