Skip to contentSkip to conversation

drivers/net Add Support mucse N10 Pmd Driver

PATCH Superseded Wenbo Cao 2 participants 36 messages Feb 10, 2025 – Feb 11, 2025

Subsystems (2)

v8 of 17 Superseded Latest is v17 →

lore
Share & tools
lore

Wenbo Cao

author
#0 lore raw

v8 cover drivers/net Add Support mucse N10 Pmd Driver

For This patchset just to support the basic chip init work and user can just found the eth_dev, but can't control more. For Now just support 2*10g nic,the chip can support 2*10g,4*10g,4*1g,8*1g,8*10g.
The Feature rx side can support rx-cksum-offload,rss,vlan-filter flow_clow,uncast_filter,mcast_filter,1588,Jumbo-frame The Feature tx side can support tx-cksum-offload,tso,vxlan-tso flow director base on ntuple pattern of tcp/udp/ip/ eth_hdr->type for sriov is also support.

Because of the chip design defect, for multiple-port mode one pci-bdf will have multiple-port (max can have four ports) so this code must be care of one bdf init multiple-port.

v8:
* fixed codespell issue.
* fixed MAINTAINERS file

v7:
* add support nic basic feature such as rss vlan strip/filter,
* mtu-change recv/send scater-recv/mutltiple-send.
* fixed code rationality, advised by Ferruh Yigit.

v6:
* fixed the doc(rst) format problem advise by Thomas Monjalon

v5:
* fixed the symbol name require by the style documentation

v4:
* one patch has been forgot to upload :(

v3:
* fixed http://dpdk.org/patch/129830 FreeBSD 13 compile Issue
* change iobar type to void suggest by Stephen Hemminger
* add KMOD_DEP support for vfio-pci
* change run-cmd argument parse check for invalid extra_args

v2:
* fixed MAINTAIN maillist fullname format
* fixed driver/net/meson the order issue of new driver to driver list
* improve virtual point function usage suggest by Stephen Hemminger

Wenbo Cao (28):
net/rnp: add skeleton
net/rnp: add ethdev probe and remove net/rnp: add log
net/rnp: support mailbox basic operate net/rnp: add device init and uninit net/rnp: add get device information operation net/rnp: add support mac promisc mode net/rnp: add queue setup and release operations net/rnp: add queue stop and start operations net/rnp: add support device start stop operations net/rnp: add RSS support operations net/rnp: add support link update operations. net/rnp: add support link setup operations net/rnp: add Rx burst simple support net/rnp: add Tx burst simple support net/rnp: add MTU set operation
net/rnp: add Rx scatter segment version net/rnp: add Tx multiple segment version net/rnp: add support basic stats operation net/rnp: add support xstats operation net/rnp: add unicast MAC filter operation net/rnp: add supported packet types net/rnp: add support Rx checksum offload net/rnp: add support Tx TSO offload net/rnp: support VLAN offloads.
net/rnp: add support VLAN filters operations. net/rnp: add queue info operation. net/rnp: support Rx/Tx burst mode info

 MAINTAINERS                         |    6 +
 doc/guides/nics/features/rnp.ini    |   33 +
 doc/guides/nics/index.rst           |    1 +
 doc/guides/nics/rnp.rst             |  100 ++
 drivers/net/meson.build             |    1 +
 drivers/net/rnp/base/meson.build    |   28 +
 drivers/net/rnp/base/rnp_bdq_if.c   |  398 ++++++
 drivers/net/rnp/base/rnp_bdq_if.h   |  154 +++
 drivers/net/rnp/base/rnp_bitrev.h   |   64 +
 drivers/net/rnp/base/rnp_common.c   |  103 ++
 drivers/net/rnp/base/rnp_common.h   |   17 +
 drivers/net/rnp/base/rnp_crc32.c    |   37 +
 drivers/net/rnp/base/rnp_crc32.h    |   10 +
 drivers/net/rnp/base/rnp_dma_regs.h |   68 +
 drivers/net/rnp/base/rnp_eth_regs.h |   90 ++
 drivers/net/rnp/base/rnp_fw_cmd.c   |  162 +++
 drivers/net/rnp/base/rnp_fw_cmd.h   |  358 ++++++
 drivers/net/rnp/base/rnp_hw.h       |  136 ++
 drivers/net/rnp/base/rnp_mac.c      |  367 ++++++
 drivers/net/rnp/base/rnp_mac.h      |   34 +
 drivers/net/rnp/base/rnp_mac_regs.h |  207 +++
 drivers/net/rnp/base/rnp_mbx.c      |  512 ++++++++
 drivers/net/rnp/base/rnp_mbx.h      |   58 +
 drivers/net/rnp/base/rnp_mbx_fw.c   |  499 ++++++++
 drivers/net/rnp/base/rnp_mbx_fw.h   |   24 +
 drivers/net/rnp/base/rnp_osdep.h    |  175 +++
 drivers/net/rnp/meson.build         |   20 +
 drivers/net/rnp/rnp.h               |  258 ++++
 drivers/net/rnp/rnp_ethdev.c        | 1829 +++++++++++++++++++++++++++
 drivers/net/rnp/rnp_link.c          |  439 +++++++
 drivers/net/rnp/rnp_link.h          |   38 +
 drivers/net/rnp/rnp_logs.h          |   36 +
 drivers/net/rnp/rnp_rss.c           |  367 ++++++
 drivers/net/rnp/rnp_rss.h           |   43 +
 drivers/net/rnp/rnp_rxtx.c          | 1820 ++++++++++++++++++++++++++
 drivers/net/rnp/rnp_rxtx.h          |  162 +++
 36 files changed, 8654 insertions(+)
 create mode 100644 doc/guides/nics/features/rnp.ini
 create mode 100644 doc/guides/nics/rnp.rst
 create mode 100644 drivers/net/rnp/base/meson.build
 create mode 100644 drivers/net/rnp/base/rnp_bdq_if.c
 create mode 100644 drivers/net/rnp/base/rnp_bdq_if.h
 create mode 100644 drivers/net/rnp/base/rnp_bitrev.h
 create mode 100644 drivers/net/rnp/base/rnp_common.c
 create mode 100644 drivers/net/rnp/base/rnp_common.h
 create mode 100644 drivers/net/rnp/base/rnp_crc32.c
 create mode 100644 drivers/net/rnp/base/rnp_crc32.h
 create mode 100644 drivers/net/rnp/base/rnp_dma_regs.h
 create mode 100644 drivers/net/rnp/base/rnp_eth_regs.h
 create mode 100644 drivers/net/rnp/base/rnp_fw_cmd.c
 create mode 100644 drivers/net/rnp/base/rnp_fw_cmd.h
 create mode 100644 drivers/net/rnp/base/rnp_hw.h
 create mode 100644 drivers/net/rnp/base/rnp_mac.c
 create mode 100644 drivers/net/rnp/base/rnp_mac.h
 create mode 100644 drivers/net/rnp/base/rnp_mac_regs.h
 create mode 100644 drivers/net/rnp/base/rnp_mbx.c
 create mode 100644 drivers/net/rnp/base/rnp_mbx.h
 create mode 100644 drivers/net/rnp/base/rnp_mbx_fw.c
 create mode 100644 drivers/net/rnp/base/rnp_mbx_fw.h
 create mode 100644 drivers/net/rnp/base/rnp_osdep.h
 create mode 100644 drivers/net/rnp/meson.build
 create mode 100644 drivers/net/rnp/rnp.h
 create mode 100644 drivers/net/rnp/rnp_ethdev.c
 create mode 100644 drivers/net/rnp/rnp_link.c
 create mode 100644 drivers/net/rnp/rnp_link.h
 create mode 100644 drivers/net/rnp/rnp_logs.h
 create mode 100644 drivers/net/rnp/rnp_rss.c
 create mode 100644 drivers/net/rnp/rnp_rss.h
 create mode 100644 drivers/net/rnp/rnp_rxtx.c
 create mode 100644 drivers/net/rnp/rnp_rxtx.h
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v8 1/28 net/rnp: add skeleton

Add basic PMD library and doc build infrastructure Update maintainers file to claim responsibility.

---
 MAINTAINERS                      |  6 +++
 doc/guides/nics/features/rnp.ini |  8 ++++
 doc/guides/nics/index.rst        |  1 +
 doc/guides/nics/rnp.rst          | 82 ++++++++++++++++++++++++++++++++
 drivers/net/meson.build          |  1 +
 drivers/net/rnp/meson.build      | 11 +++++
 drivers/net/rnp/rnp_ethdev.c     |  3 ++
 7 files changed, 112 insertions(+)
 create mode 100644 doc/guides/nics/features/rnp.ini
 create mode 100644 doc/guides/nics/rnp.rst
 create mode 100644 drivers/net/rnp/meson.build
 create mode 100644 drivers/net/rnp/rnp_ethdev.c
MAINTAINERS +6 -0
index 0f940ad713..f9e0a312db 100644
@@ -1011,6 +1011,12 @@ F: drivers/net/r8169/
 F: doc/guides/nics/r8169.rst
 F: doc/guides/nics/features/r8169.ini
 
+Mucse rnp
+M: Wenbo Cao <[email protected]>
+F: drivers/net/rnp
+F: doc/guides/nics/rnp.rst
+F: doc/guides/nics/features/rnp.ini
+
 Solarflare sfc_efx
 M: Andrew Rybchenko <[email protected]>
 F: drivers/common/sfc_efx/
doc/guides/nics/features/rnp.ini new file +8 -0
new file mode 100644
index 0000000000..2ad04ee330
@@ -0,0 +1,8 @@
+;
+; Supported features of the 'rnp' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Linux                = Y
+x86-64               = Y
doc/guides/nics/index.rst +1 -0
index 50688d9f64..6ce7ef24df 100644
@@ -61,6 +61,7 @@ Network Interface Controller Drivers
     pfe
     qede
     r8169
+    rnp
     sfc_efx
     softnic
     tap
doc/guides/nics/rnp.rst new file +82 -0

82 lines not on this page · raw message

drivers/net/meson.build +1 -0
index dafd637ba4..2e2327c760 100644
@@ -54,6 +54,7 @@ drivers = [
         'qede',
         'r8169',
         'ring',
+        'rnp',
         'sfc',
         'softnic',
         'tap',
drivers/net/rnp/meson.build new file +11 -0
new file mode 100644
index 0000000000..494f10efd0
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(C) 2023 Mucse IC Design Ltd.
+#
+if not is_linux
+    build = false
+    reason = 'only supported on Linux'
+endif
+
+sources = files(
+                'rnp_ethdev.c',
+)
drivers/net/rnp/rnp_ethdev.c new file +3 -0
new file mode 100644
index 0000000000..9ce3c0b497
@@ -0,0 +1,3 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2023 Mucse IC Design Ltd.
+ */
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH v8 01/28] net/rnp: add skeleton

Quoted 5 lines · On Mon, 10 Feb 2025 15:26:28 +0800 Wenbo Cao <[email protected]> wrote:

Add basic PMD library and doc build infrastructure Update maintainers file to claim responsibility.

Quoted 13 lines
---
 MAINTAINERS                      |  6 +++
 doc/guides/nics/features/rnp.ini |  8 ++++
 doc/guides/nics/index.rst        |  1 +
 doc/guides/nics/rnp.rst          | 82 ++++++++++++++++++++++++++++++++
 drivers/net/meson.build          |  1 +
 drivers/net/rnp/meson.build      | 11 +++++
 drivers/net/rnp/rnp_ethdev.c     |  3 ++
 7 files changed, 112 insertions(+)
 create mode 100644 doc/guides/nics/features/rnp.ini
 create mode 100644 doc/guides/nics/rnp.rst
 create mode 100644 drivers/net/rnp/meson.build
 create mode 100644 drivers/net/rnp/rnp_ethdev.c

You need to add your mail address to .mailmap

$  ./devtools/check-git-log.sh 
Wrong headline format:
	net/rnp: add support link update operations.
	net/rnp: support VLAN offloads.
	net/rnp: add support VLAN filters operations.
	net/rnp: add queue info operation.
Wrong headline case:
			"net/rnp: add support mac promisc mode": mac --> MAC
Missing 'Signed-off-by:' tag: 
	net/rnp: add get device information operation
Contributor name/email mismatch with .mailmap: 
	Wenbo Cao <[email protected]> is unknown in .mailmap
author
#3 lore raw

PATCH v8 2/28 net/rnp: add ethdev probe and remove

In reply to Wenbo Cao

Add basic PCIe ethdev probe and remove.

---
 drivers/net/rnp/rnp.h        | 13 +++++++
 drivers/net/rnp/rnp_ethdev.c | 74 ++++++++++++++++++++++++++++++++++++
 2 files changed, 87 insertions(+)
 create mode 100644 drivers/net/rnp/rnp.h
drivers/net/rnp/rnp.h new file +13 -0
new file mode 100644
index 0000000000..6cd717a36e
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2023 Mucse IC Design Ltd.
+ */
+#ifndef __RNP_H__
+#define __RNP_H__
+
+#define PCI_VENDOR_ID_MUCSE	(0x8848)
+#define RNP_DEV_ID_N10G		(0x1000)
+
+struct rnp_eth_port {
+};
+
+#endif /* __RNP_H__ */
drivers/net/rnp/rnp_ethdev.c +74 -0

77 lines not on this page · raw message

Signature · 1 line
2.34.1
author
#4 lore raw

PATCH v8 3/28 net/rnp: add log

In reply to Wenbo Cao

add log function for trace or debug

---
 drivers/net/rnp/rnp_ethdev.c |  2 ++
 drivers/net/rnp/rnp_logs.h   | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+)
 create mode 100644 drivers/net/rnp/rnp_logs.h
drivers/net/rnp/rnp_ethdev.c +2 -0
index b71226cb84..12cc30e013 100644
@@ -72,6 +72,8 @@ static struct rte_pci_driver rte_rnp_pmd = {
 	.remove = rnp_pci_remove,
 };
 
+RTE_LOG_REGISTER_SUFFIX(rnp_init_logtype, init, NOTICE);
+
 RTE_PMD_REGISTER_PCI(net_rnp, rte_rnp_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_rnp, pci_id_rnp_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_rnp, "igb_uio | uio_pci_generic | vfio-pci");
drivers/net/rnp/rnp_logs.h new file +36 -0
new file mode 100644
index 0000000000..c68a5c1028
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2023 Mucse IC Design Ltd.
+ */
+
+#ifndef __RNP_LOGS_H__
+#define __RNP_LOGS_H__
+
+#include <rte_log.h>
+
+extern int rnp_init_logtype;
+#define RTE_LOGTYPE_RNP_INIT rnp_init_logtype
+#define RNP_PMD_INIT_LOG(level, ...) \
+	RTE_LOG_LINE_PREFIX(level, RNP_INIT, "%s(): ", __func__,  __VA_ARGS__)
+#define PMD_INIT_FUNC_TRACE() RNP_PMD_INIT_LOG(DEBUG, " >>")
+#define RNP_PMD_DRV_LOG(level, ...) \
+	RTE_LOG_LINE_PREFIX(level, RNP_INIT, \
+			"%s(): ", __func__, __VA_ARGS__)
+#define RNP_PMD_LOG(level, ...) \
+	RTE_LOG_LINE_PREFIX(level, RNP_INIT, \
+			"rnp_net: (%d) ", __LINE__, __VA_ARGS__)
+#define RNP_PMD_ERR(fmt, ...) \
+	RNP_PMD_LOG(ERR, fmt, ## __VA_ARGS__)
+#define RNP_PMD_WARN(fmt, ...) \
+	RNP_PMD_LOG(WARNING, fmt, ## __VA_ARGS__)
+#define RNP_PMD_INFO(fmt, ...) \
+	RNP_PMD_LOG(INFO, fmt, ## __VA_ARGS__)
+
+#ifdef RTE_LIBRTE_RNP_REG_DEBUG
+#define RNP_PMD_REG_LOG(level, ...) \
+	RTE_LOG_LINE_PREFIX(level, RNP_INIT, \
+			"%s(): ", __func__, __VA_ARGS__)
+#else
+#define RNP_PMD_REG_LOG(...) do { } while (0)
+#endif
+
+#endif /* __RNP_LOGS_H__ */
Signature · 1 line
2.34.1
author
#5 lore raw

PATCH v8 4/28 net/rnp: support mailbox basic operate

In reply to Wenbo Cao

This patch adds support for mailbox of rnp PMD driver, mailbox is used for communication between pf with fw and vf driver.

---
 drivers/net/rnp/base/meson.build |  22 ++
 drivers/net/rnp/base/rnp_hw.h    |  76 +++++
 drivers/net/rnp/base/rnp_mbx.c   | 512 +++++++++++++++++++++++++++++++
 drivers/net/rnp/base/rnp_mbx.h   |  58 ++++
 drivers/net/rnp/base/rnp_osdep.h |  53 ++++
 drivers/net/rnp/meson.build      |   5 +
 drivers/net/rnp/rnp.h            |  19 ++
 7 files changed, 745 insertions(+)
 create mode 100644 drivers/net/rnp/base/meson.build
 create mode 100644 drivers/net/rnp/base/rnp_hw.h
 create mode 100644 drivers/net/rnp/base/rnp_mbx.c
 create mode 100644 drivers/net/rnp/base/rnp_mbx.h
 create mode 100644 drivers/net/rnp/base/rnp_osdep.h
drivers/net/rnp/base/meson.build new file +22 -0
new file mode 100644
index 0000000000..9ea88c3bff
@@ -0,0 +1,22 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(C) 2023 Mucse IC Design Ltd.
+
+sources = [
+        'rnp_mbx.c',
+]
+
+error_cflags = ['-Wno-unused-value',
+        '-Wno-unused-but-set-variable',
+        '-Wno-unused-parameter',
+        ]
+c_args = cflags
+foreach flag: error_cflags
+    if cc.has_argument(flag)
+        c_args += flag
+    endif
+endforeach
+
+base_lib = static_library('rnp_base', sources,
+    dependencies: [static_rte_eal, static_rte_net, static_rte_ethdev],
+    c_args: c_args)
+base_objs = base_lib.extract_all_objects(recursive: true)
drivers/net/rnp/base/rnp_hw.h new file +76 -0

76 lines not on this page · raw message

drivers/net/rnp/base/rnp_mbx.c new file +512 -0

512 lines not on this page · raw message

drivers/net/rnp/base/rnp_mbx.h new file +58 -0

58 lines not on this page · raw message

drivers/net/rnp/base/rnp_osdep.h new file +53 -0

53 lines not on this page · raw message

drivers/net/rnp/meson.build +5 -0
index 494f10efd0..e6bcdf9299 100644
@@ -6,6 +6,11 @@ if not is_linux
     reason = 'only supported on Linux'
 endif
 
+subdir('base')
+objs = [base_objs]
+
+includes += include_directories('base')
+
 sources = files(
                 'rnp_ethdev.c',
 )
drivers/net/rnp/rnp.h +19 -0
index 6cd717a36e..904b7ad2f8 100644
@@ -4,10 +4,29 @@
 #ifndef __RNP_H__
 #define __RNP_H__
 
+#include <ethdev_driver.h>
+#include <rte_interrupts.h>
+
+#include "base/rnp_hw.h"
+
 #define PCI_VENDOR_ID_MUCSE	(0x8848)
 #define RNP_DEV_ID_N10G		(0x1000)
+#define RNP_MAX_VF_NUM		(64)
+#define RNP_MISC_VEC_ID		RTE_INTR_VEC_ZERO_OFFSET
+
+struct rnp_proc_priv {
+	const struct rnp_mbx_ops *mbx_ops;
+};
 
 struct rnp_eth_port {
 };
 
+struct rnp_eth_adapter {
+	struct rnp_hw hw;
+	struct rte_eth_dev *eth_dev; /* alloc eth_dev by platform */
+};
+
+#define RNP_DEV_TO_PROC_PRIV(eth_dev) \
+	((struct rnp_proc_priv *)(eth_dev)->process_private)
+
 #endif /* __RNP_H__ */
Signature · 1 line
2.34.1
author
#6 lore raw

PATCH v8 5/28 net/rnp: add device init and uninit

In reply to Wenbo Cao

add firmware communic method and basic device
init, uninit and close resource function.

---
 drivers/net/rnp/base/meson.build    |   4 +
 drivers/net/rnp/base/rnp_common.c   |  73 ++++++
 drivers/net/rnp/base/rnp_common.h   |  12 +
 drivers/net/rnp/base/rnp_dma_regs.h |  13 ++
 drivers/net/rnp/base/rnp_eth_regs.h |  15 ++
 drivers/net/rnp/base/rnp_fw_cmd.c   |  75 ++++++
 drivers/net/rnp/base/rnp_fw_cmd.h   | 216 ++++++++++++++++++
 drivers/net/rnp/base/rnp_hw.h       |  39 ++++
 drivers/net/rnp/base/rnp_mac.c      |  28 +++
 drivers/net/rnp/base/rnp_mac.h      |  14 ++
 drivers/net/rnp/base/rnp_mbx_fw.c   | 338 ++++++++++++++++++++++++++++
 drivers/net/rnp/base/rnp_mbx_fw.h   |  18 ++
 drivers/net/rnp/base/rnp_osdep.h    | 101 ++++++++-
 drivers/net/rnp/meson.build         |   1 +
 drivers/net/rnp/rnp.h               |  40 ++++
 drivers/net/rnp/rnp_ethdev.c        | 318 +++++++++++++++++++++++++-
 16 files changed, 1292 insertions(+), 13 deletions(-)
 create mode 100644 drivers/net/rnp/base/rnp_common.c
 create mode 100644 drivers/net/rnp/base/rnp_common.h
 create mode 100644 drivers/net/rnp/base/rnp_dma_regs.h
 create mode 100644 drivers/net/rnp/base/rnp_eth_regs.h
 create mode 100644 drivers/net/rnp/base/rnp_fw_cmd.c
 create mode 100644 drivers/net/rnp/base/rnp_fw_cmd.h
 create mode 100644 drivers/net/rnp/base/rnp_mac.c
 create mode 100644 drivers/net/rnp/base/rnp_mac.h
 create mode 100644 drivers/net/rnp/base/rnp_mbx_fw.c
 create mode 100644 drivers/net/rnp/base/rnp_mbx_fw.h
drivers/net/rnp/base/meson.build +4 -0
index 9ea88c3bff..b9db033ff6 100644
@@ -3,6 +3,10 @@
 
 sources = [
         'rnp_mbx.c',
+        'rnp_fw_cmd.c',
+        'rnp_mbx_fw.c',
+        'rnp_common.c',
+        'rnp_mac.c',
 ]
 
 error_cflags = ['-Wno-unused-value',
drivers/net/rnp/base/rnp_common.c new file +73 -0

73 lines not on this page · raw message

drivers/net/rnp/base/rnp_common.h new file +12 -0
new file mode 100644
index 0000000000..aaf77a6dad
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2023 Mucse IC Design Ltd.
+ */
+
+#ifndef _RNP_COMMON_H_
+#define _RNP_COMMON_H_
+
+#define RNP_NIC_RESET		_NIC_(0x0010)
+int rnp_init_hw(struct rnp_hw *hw);
+int rnp_setup_common_ops(struct rnp_hw *hw);
+
+#endif /* _RNP_COMMON_H_ */
drivers/net/rnp/base/rnp_dma_regs.h new file +13 -0
new file mode 100644
index 0000000000..00f8aff944
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2023 Mucse IC Design Ltd.
+ */
+
+#ifndef _RNP_DMA_REGS_H_
+#define _RNP_DMA_REGS_H_
+
+#define RNP_DMA_VERSION		(0)
+#define RNP_DMA_HW_EN		(0x10)
+#define RNP_DMA_EN_ALL		(0b1111)
+#define RNP_DMA_HW_STATE	(0x14)
+
+#endif /* _RNP_DMA_REGS_H_ */
drivers/net/rnp/base/rnp_eth_regs.h new file +15 -0
new file mode 100644
index 0000000000..6957866d76
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2023 Mucse IC Design Ltd.
+ */
+
+#ifndef _RNP_ETH_REGS_H
+#define _RNP_ETH_REGS_H
+
+#define RNP_E_ENG_BYPASS	_ETH_(0x8000)
+#define RNP_E_VXLAN_PARSE_EN	_ETH_(0x8004)
+#define RNP_E_FILTER_EN		_ETH_(0x801c)
+#define RNP_E_REDIR_EN		_ETH_(0x8030)
+
+#define RNP_TC_PORT_OFFSET(lane)	_ETH_(0xe840 + 0x04 * (lane))
+
+#endif /* _RNP_ETH_REGS_H */
drivers/net/rnp/base/rnp_fw_cmd.c new file +75 -0

75 lines not on this page · raw message

drivers/net/rnp/base/rnp_fw_cmd.h new file +216 -0

216 lines not on this page · raw message

drivers/net/rnp/base/rnp_hw.h +39 -0
index 959b4c3a11..3f0ef6cb83 100644
@@ -6,6 +6,8 @@
 
 #include "rnp_osdep.h"
 
+#define RNP_MAX_PORT_OF_PF	(4)
+
 struct rnp_hw;
 /* Mailbox Operate Info */
 enum RNP_MBX_ID {
@@ -55,7 +57,34 @@ struct rnp_mbx_info {
 	struct rnp_mbx_sync syncs[RNP_MBX_FW];
 };
 
+struct rnp_eth_port;
+/* mac operations */
+struct rnp_mac_ops {
+	/* update mac packet filter mode */
+	int (*get_macaddr)(struct rnp_eth_port *port, u8 *mac);
+};
+
 struct rnp_eth_adapter;
+struct rnp_fw_info {
+	char cookie_name[RTE_MEMZONE_NAMESIZE];
+	struct rnp_dma_mem mem;
+	void *cookie_pool;
+	bool fw_irq_en;
+	bool msg_alloced;
+
+	u64 fw_features;
+	spinlock_t fw_lock; /* mc-sp Protect firmware logic */
+};
+
+#define rnp_call_hwif_impl(port, f, arg...) \
+	(((f) != NULL) ? ((f) (port, arg)) : (-ENODEV))
+
+enum rnp_nic_mode {
+	RNP_SINGLE_40G = 0,
+	RNP_SINGLE_10G = 1,
+	RNP_DUAL_10G = 2,
+	RNP_QUAD_10G = 3,
+};
 
 /* hw device description */
 struct rnp_hw {
@@ -69,8 +98,18 @@ struct rnp_hw {
 	u16 vendor_id;
 	u16 max_vfs;			/* device max support vf */
 
+	char device_name[RTE_DEV_NAME_MAX_LEN];
+
+	u8 max_port_num;	/* max sub port of this nic */
+	u8 lane_mask;		/* lane enabled bit */
+	u8 nic_mode;
 	u16 pf_vf_num;
+	/* hardware port sequence info */
+	u8 phy_port_ids[RNP_MAX_PORT_OF_PF];	/* port id: for lane0~3: value:0 ~ 7*/
+	u8 lane_of_port[RNP_MAX_PORT_OF_PF];	/* lane_id: hw lane map port 1:0 0:1 or 0:0 1:1 */
+	bool lane_is_sgmii[RNP_MAX_PORT_OF_PF];
 	struct rnp_mbx_info mbx;
+	struct rnp_fw_info fw_info;
 };
 
 #endif /* __RNP_H__*/
drivers/net/rnp/base/rnp_mac.c new file +28 -0
new file mode 100644
index 0000000000..b063f4ca0b
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2023 Mucse IC Design Ltd.
+ */
+
+#include "rnp_osdep.h"
+
+#include "rnp_mbx_fw.h"
+#include "rnp_mac.h"
+#include "../rnp.h"
+
+const struct rnp_mac_ops rnp_mac_ops_pf = {
+	.get_macaddr = rnp_mbx_fw_get_macaddr,
+};
+
+int rnp_get_mac_addr(struct rnp_eth_port *port, u8 *mac)
+{
+	const struct rnp_mac_ops *mac_ops =
+		RNP_DEV_PP_TO_MAC_OPS(port->eth_dev);
+
+	return rnp_call_hwif_impl(port, mac_ops->get_macaddr, mac);
+}
+
+void rnp_mac_ops_init(struct rnp_hw *hw)
+{
+	struct rnp_proc_priv *proc_priv = RNP_DEV_TO_PROC_PRIV(hw->back->eth_dev);
+
+	proc_priv->mac_ops = &rnp_mac_ops_pf;
+}
drivers/net/rnp/base/rnp_mac.h new file +14 -0
new file mode 100644
index 0000000000..8a12aa4dcd
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2023 Mucse IC Design Ltd.
+ */
+
+#ifndef _RNP_MAC_H_
+#define _RNP_MAC_H_
+
+#include "rnp_osdep.h"
+#include "rnp_hw.h"
+
+void rnp_mac_ops_init(struct rnp_hw *hw);
+int rnp_get_mac_addr(struct rnp_eth_port *port, u8 *mac);
+
+#endif /* _RNP_MAC_H_ */
drivers/net/rnp/base/rnp_mbx_fw.c new file +338 -0

338 lines not on this page · raw message

drivers/net/rnp/base/rnp_mbx_fw.h new file +18 -0
new file mode 100644
index 0000000000..255d913a97
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2023 Mucse IC Design Ltd.
+ */
+
+#ifndef _RNP_MBX_FW_H_
+#define _RNP_MBX_FW_H_
+
+#include "rnp_osdep.h"
+#include "rnp_hw.h"
+
+struct rnp_eth_port;
+
+int rnp_mbx_fw_get_macaddr(struct rnp_eth_port *port, u8 *mac_addr);
+int rnp_mbx_fw_get_capability(struct rnp_eth_port *port);
+int rnp_mbx_fw_reset_phy(struct rnp_hw *hw);
+int rnp_fw_init(struct rnp_hw *hw);
+
+#endif /* _RNP_MBX_FW_H_ */
drivers/net/rnp/base/rnp_osdep.h +96 -5

137 lines not on this page · raw message

drivers/net/rnp/meson.build +1 -0
index e6bcdf9299..660b36e1b0 100644
@@ -9,6 +9,7 @@ endif
 subdir('base')
 objs = [base_objs]
 
+deps += ['net']
 includes += include_directories('base')
 
 sources = files(
drivers/net/rnp/rnp.h +40 -0
index 904b7ad2f8..5db92566cc 100644
@@ -13,20 +13,60 @@
 #define RNP_DEV_ID_N10G		(0x1000)
 #define RNP_MAX_VF_NUM		(64)
 #define RNP_MISC_VEC_ID		RTE_INTR_VEC_ZERO_OFFSET
+/* maximum frame size supported */
+#define RNP_MAC_MAXFRM_SIZE	(9590)
+
+struct rnp_port_attr {
+	uint16_t max_mac_addrs;	/* max support mac address */
+	uint16_t port_id;	/* platform manage port sequence id */
+	uint8_t port_offset;	/* port queue offset */
+	uint8_t sw_id;		/* software port init sequence id */
+	uint16_t nr_lane;	/* phy lane of This PF:0~3 */
+};
 
 struct rnp_proc_priv {
+	const struct rnp_mac_ops *mac_ops;
 	const struct rnp_mbx_ops *mbx_ops;
 };
 
 struct rnp_eth_port {
+	struct rnp_proc_priv *proc_priv;
+	struct rte_ether_addr mac_addr;
+	struct rte_eth_dev *eth_dev;
+	struct rnp_port_attr attr;
+	struct rnp_hw *hw;
 };
 
 struct rnp_eth_adapter {
 	struct rnp_hw hw;
+	struct rte_pci_device *pdev;
 	struct rte_eth_dev *eth_dev; /* alloc eth_dev by platform */
+
+	struct rnp_eth_port *ports[RNP_MAX_PORT_OF_PF];
+	uint16_t closed_ports;
+	uint16_t inited_ports;
+	bool intr_registered;
 };
 
+#define RNP_DEV_TO_PORT(eth_dev) \
+	((struct rnp_eth_port *)(eth_dev)->data->dev_private)
+#define RNP_DEV_TO_ADAPTER(eth_dev) \
+	((struct rnp_eth_adapter *)(RNP_DEV_TO_PORT(eth_dev))->hw->back)
 #define RNP_DEV_TO_PROC_PRIV(eth_dev) \
 	((struct rnp_proc_priv *)(eth_dev)->process_private)
+#define RNP_DEV_PP_TO_MBX_OPS(priv) \
+	(((RNP_DEV_TO_PROC_PRIV(priv))->mbx_ops))
+#define RNP_DEV_PP_TO_MAC_OPS(priv) \
+	(((RNP_DEV_TO_PROC_PRIV(priv))->mac_ops))
+
+#define RNP_PF_OWN_PORTS(id)	(((id) == 0) ? 1 : (((id) == 1) ? 2 : 4))
+
+static inline int
+rnp_pf_is_multiple_ports(uint32_t device_id)
+{
+	uint32_t verbit = (device_id >> 5) & 0x3;
+
+	return RNP_PF_OWN_PORTS(verbit) == 1 ? 0 : 1;
+}
 
 #endif /* __RNP_H__ */
drivers/net/rnp/rnp_ethdev.c +310 -8

349 lines not on this page · raw message

Signature · 1 line
2.34.1
author
#7 lore raw

PATCH v8 6/28 net/rnp: add get device information operation

In reply to Wenbo Cao

add get device hardware capability function

---
 doc/guides/nics/features/rnp.ini  |   1 +
 drivers/net/rnp/base/rnp_fw_cmd.c |  20 ++++++
 drivers/net/rnp/base/rnp_fw_cmd.h |  80 +++++++++++++++++++++
 drivers/net/rnp/base/rnp_mbx_fw.c |  58 +++++++++++++++
 drivers/net/rnp/base/rnp_mbx_fw.h |   1 +
 drivers/net/rnp/rnp.h             |  73 ++++++++++++++++++-
 drivers/net/rnp/rnp_ethdev.c      | 113 +++++++++++++++++++++++++++++-
 7 files changed, 344 insertions(+), 2 deletions(-)
doc/guides/nics/features/rnp.ini +1 -0
index 2ad04ee330..6766130a68 100644
@@ -4,5 +4,6 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+Speed capabilities   = Y
 Linux                = Y
 x86-64               = Y
drivers/net/rnp/base/rnp_fw_cmd.c +20 -0
index 064ba9e045..34a88a154f 100644
@@ -51,6 +51,23 @@ rnp_build_get_macaddress_req(struct rnp_mbx_fw_cmd_req *req,
 	arg->pfvf_num = req_arg->param1;
 }
 
+static inline void
+rnp_build_get_lane_status_req(struct rnp_mbx_fw_cmd_req *req,
+			      struct rnp_fw_req_arg *req_arg,
+			      void *cookie)
+{
+	struct rnp_get_lane_st_req *arg = (struct rnp_get_lane_st_req *)req->data;
+
+	req->flags = 0;
+	req->opcode = RNP_GET_LANE_STATUS;
+	req->datalen = sizeof(*arg);
+	req->cookie = cookie;
+	req->reply_lo = 0;
+	req->reply_hi = 0;
+
+	arg->nr_lane = req_arg->param0;
+}
+
 int rnp_build_fwcmd_req(struct rnp_mbx_fw_cmd_req *req,
 			struct rnp_fw_req_arg *arg,
 			void *cookie)
@@ -67,6 +84,9 @@ int rnp_build_fwcmd_req(struct rnp_mbx_fw_cmd_req *req,
 	case RNP_GET_MAC_ADDRESS:
 		rnp_build_get_macaddress_req(req, arg, cookie);
 		break;
+	case RNP_GET_LANE_STATUS:
+		rnp_build_get_lane_status_req(req, arg, cookie);
+		break;
 	default:
 		err = -EOPNOTSUPP;
 	}
drivers/net/rnp/base/rnp_fw_cmd.h +80 -0

92 lines not on this page · raw message

drivers/net/rnp/base/rnp_mbx_fw.c +58 -0

61 lines not on this page · raw message

drivers/net/rnp/base/rnp_mbx_fw.h +1 -0
index 255d913a97..fd0110b539 100644
@@ -12,6 +12,7 @@ struct rnp_eth_port;
 
 int rnp_mbx_fw_get_macaddr(struct rnp_eth_port *port, u8 *mac_addr);
 int rnp_mbx_fw_get_capability(struct rnp_eth_port *port);
+int rnp_mbx_fw_get_lane_stat(struct rnp_eth_port *port);
 int rnp_mbx_fw_reset_phy(struct rnp_hw *hw);
 int rnp_fw_init(struct rnp_hw *hw);
 
drivers/net/rnp/rnp.h +72 -1

82 lines not on this page · raw message

drivers/net/rnp/rnp_ethdev.c +112 -1

135 lines not on this page · raw message

Signature · 1 line
2.34.1
#8 lore raw

Re: [PATCH v8 06/28] net/rnp: add get device information operation

Quoted 10 lines · On Mon, 10 Feb 2025 15:26:33 +0800 Wenbo Cao <[email protected]> wrote:

add get device hardware capability function

---
 doc/guides/nics/features/rnp.ini  |   1 +
 drivers/net/rnp/base/rnp_fw_cmd.c |  20 ++++++
 drivers/net/rnp/base/rnp_fw_cmd.h |  80 +++++++++++++++++++++
 drivers/net/rnp/base/rnp_mbx_fw.c |  58 +++++++++++++++
 drivers/net/rnp/base/rnp_mbx_fw.h |   1 +
 drivers/net/rnp/rnp.h             |  73 ++++++++++++++++++-
 drivers/net/rnp/rnp_ethdev.c      | 113 +++++++++++++++++++++++++++++-
 7 files changed, 344 insertions(+), 2 deletions(-)

Need more here...

### [PATCH] net/rnp: add get device information operation

WARNING:COMMIT_MESSAGE: Missing commit description - Add an appropriate one

ERROR:MISSING_SIGN_OFF: Missing Signed-off-by: line(s)

author
#9 lore raw

PATCH v8 7/28 net/rnp: add support mac promisc mode

In reply to Wenbo Cao

add support two method of mac unicast promisc
mulcast promisc broadcast promisc mode

---
 doc/guides/nics/features/rnp.ini    |   2 +
 doc/guides/nics/rnp.rst             |   5 ++
 drivers/net/rnp/base/rnp_common.c   |   5 ++
 drivers/net/rnp/base/rnp_eth_regs.h |  15 ++++
 drivers/net/rnp/base/rnp_hw.h       |  12 ++-
 drivers/net/rnp/base/rnp_mac.c      | 114 +++++++++++++++++++++++++++-
 drivers/net/rnp/base/rnp_mac.h      |   2 +
 drivers/net/rnp/base/rnp_mac_regs.h |  39 ++++++++++
 drivers/net/rnp/base/rnp_osdep.h    |   5 ++
 drivers/net/rnp/rnp_ethdev.c        |  43 +++++++++++
 10 files changed, 240 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/rnp/base/rnp_mac_regs.h
doc/guides/nics/features/rnp.ini +2 -0
index 6766130a68..65f1ed3da0 100644
@@ -5,5 +5,7 @@
 ;
 [Features]
 Speed capabilities   = Y
+Promiscuous mode     = Y
+Allmulticast mode    = Y
 Linux                = Y
 x86-64               = Y
doc/guides/nics/rnp.rst +5 -0
index 618baa836a..62585acd4b 100644
@@ -7,6 +7,11 @@ RNP Poll Mode driver
 The RNP ETHDEV PMD (**librte_net_rnp**) provides poll mode ethdev
 driver support for the inbuilt network device found in the **Mucse RNP**
 
+Features
+--------
+
+- Promiscuous mode
+
 Prerequisites
 -------------
 More information can be found at `Mucse, Official Website
drivers/net/rnp/base/rnp_common.c +5 -0
index 5cd4ec133e..5655126ae0 100644
@@ -4,6 +4,7 @@
 
 #include "rnp_osdep.h"
 #include "rnp_hw.h"
+#include "rnp_mac_regs.h"
 #include "rnp_eth_regs.h"
 #include "rnp_dma_regs.h"
 #include "rnp_common.h"
@@ -28,6 +29,7 @@ int rnp_init_hw(struct rnp_hw *hw)
 	struct rnp_eth_port *port = RNP_DEV_TO_PORT(hw->back->eth_dev);
 	u32 version = 0;
 	int ret = -1;
+	u32 idx = 0;
 	u32 state;
 
 	PMD_INIT_FUNC_TRACE();
@@ -60,6 +62,9 @@ int rnp_init_hw(struct rnp_hw *hw)
 	if (hw->nic_mode == RNP_DUAL_10G && hw->max_port_num == 2)
 		RNP_E_REG_WR(hw, RNP_TC_PORT_OFFSET(RNP_TARGET_TC_PORT),
 				RNP_PORT_OFF_QUEUE_NUM);
+	/* setup mac resiger ctrl base */
+	for (idx = 0; idx < hw->max_port_num; idx++)
+		hw->mac_base[idx] = (u8 *)hw->e_ctrl + RNP_MAC_BASE_OFFSET(idx);
 
 	return 0;
 }
drivers/net/rnp/base/rnp_eth_regs.h +15 -0
index 6957866d76..c4519ba1e5 100644
@@ -10,6 +10,21 @@
 #define RNP_E_FILTER_EN		_ETH_(0x801c)
 #define RNP_E_REDIR_EN		_ETH_(0x8030)
 
+/* Mac Host Filter  */
+#define RNP_MAC_FCTRL		_ETH_(0x9110)
+#define RNP_MAC_FCTRL_MPE	RTE_BIT32(8)  /* Multicast Promiscuous En */
+#define RNP_MAC_FCTRL_UPE	RTE_BIT32(9)  /* Unicast Promiscuous En */
+#define RNP_MAC_FCTRL_BAM	RTE_BIT32(10) /* Broadcast Accept Mode */
+#define RNP_MAC_FCTRL_BYPASS	(\
+		RNP_MAC_FCTRL_MPE | \
+		RNP_MAC_FCTRL_UPE | \
+		RNP_MAC_FCTRL_BAM)
+/* Mucast unicast mac hash filter ctrl */
+#define RNP_MAC_MCSTCTRL		_ETH_(0x9114)
+#define RNP_MAC_HASH_MASK		RTE_GENMASK32(11, 0)
+#define RNP_MAC_MULTICASE_TBL_EN	RTE_BIT32(2)
+#define RNP_MAC_UNICASE_TBL_EN		RTE_BIT32(3)
+
 #define RNP_TC_PORT_OFFSET(lane)	_ETH_(0xe840 + 0x04 * (lane))
 
 #endif /* _RNP_ETH_REGS_H */
drivers/net/rnp/base/rnp_hw.h +11 -1
index 3f0ef6cb83..dd9649ddbc 100644
@@ -59,9 +59,18 @@ struct rnp_mbx_info {
 
 struct rnp_eth_port;
 /* mac operations */
+enum rnp_mpf_modes {
+	RNP_MPF_MODE_NONE = 0,
+	RNP_MPF_MODE_MULTI,    /* Multitle Filter */
+	RNP_MPF_MODE_ALLMULTI, /* Multitle Promisc */
+	RNP_MPF_MODE_PROMISC,  /* Unicast Promisc */
+};
+
 struct rnp_mac_ops {
-	/* update mac packet filter mode */
+	/* get default mac address */
 	int (*get_macaddr)(struct rnp_eth_port *port, u8 *mac);
+	/* update mac packet filter mode */
+	int (*update_mpfm)(struct rnp_eth_port *port, u32 mode, bool en);
 };
 
 struct rnp_eth_adapter;
@@ -91,6 +100,7 @@ struct rnp_hw {
 	struct rnp_eth_adapter *back;	/* backup to the adapter handle */
 	void __iomem *e_ctrl;           /* ethernet control bar */
 	void __iomem *c_ctrl;           /* crypto control bar */
+	void __iomem *mac_base[RNP_MAX_PORT_OF_PF]; /* mac ctrl register base */
 	u32 c_blen;                     /* crypto bar size */
 
 	/* pci device info */
drivers/net/rnp/base/rnp_mac.c +113 -1

132 lines not on this page · raw message

drivers/net/rnp/base/rnp_mac.h +2 -0
index 8a12aa4dcd..57cbd9e3d5 100644
@@ -10,5 +10,7 @@
 
 void rnp_mac_ops_init(struct rnp_hw *hw);
 int rnp_get_mac_addr(struct rnp_eth_port *port, u8 *mac);
+int rnp_update_mpfm(struct rnp_eth_port *port,
+		    u32 mode, bool en);
 
 #endif /* _RNP_MAC_H_ */
drivers/net/rnp/base/rnp_mac_regs.h new file +39 -0
new file mode 100644
index 0000000000..1dc0668b48
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2023 Mucse IC Design Ltd.
+ */
+
+#ifndef _RNP_MAC_REGS_H_
+#define _RNP_MAC_REGS_H_
+
+#define RNP_MAC_BASE_OFFSET(n)  (_MAC_(0) + ((0x10000) * (n)))
+
+#define RNP_MAC_PKT_FLT_CTRL	(0x8)
+/* Receive All */
+#define RNP_MAC_RA		RTE_BIT32(31)
+/* Pass Control Packets */
+#define RNP_MAC_PCF		RTE_GENMASK32(7, 6)
+#define RNP_MAC_PCF_S		(6)
+/* Mac Filter ALL Ctrl Frame */
+#define RNP_MAC_PCF_FAC		(0)
+/* Mac Forward ALL Ctrl Frame Except Pause */
+#define RNP_MAC_PCF_NO_PAUSE	(1)
+/* Mac Forward All Ctrl Pkt */
+#define RNP_MAC_PCF_PA		(2)
+/* Mac Forward Ctrl Frame Match Unicast */
+#define RNP_MAC_PCF_PUN		(3)
+/* Promiscuous Mode */
+#define RNP_MAC_PROMISC_EN	RTE_BIT32(0)
+/* Hash Unicast */
+#define RNP_MAC_HUC		RTE_BIT32(1)
+/* Hash Multicast */
+#define RNP_MAC_HMC		RTE_BIT32(2)
+/*  Pass All Multicast */
+#define RNP_MAC_PM		RTE_BIT32(4)
+/* Disable Broadcast Packets */
+#define RNP_MAC_DBF		RTE_BIT32(5)
+/* Hash or Perfect Filter */
+#define RNP_MAC_HPF		RTE_BIT32(10)
+#define RNP_MAC_VTFE		RTE_BIT32(16)
+
+
+#endif /* _RNP_MAC_REGS_H_ */
drivers/net/rnp/base/rnp_osdep.h +5 -0
index f8c7bddc6e..8817a4985c 100644
@@ -45,6 +45,7 @@ typedef rte_iova_t dma_addr_t;
 
 #define _ETH_(off)	((off) + (0x10000))
 #define _NIC_(off)	((off) + (0x30000))
+#define _MAC_(off)	((off) + (0x60000))
 #define _MSI_(off)	((off) + (0xA0000))
 
 #ifndef _PACKED_ALIGN4
@@ -140,5 +141,9 @@ rnp_dma_mem_free(__rte_unused struct rnp_hw *hw,
 #define RNP_REG_WR(base, offset, val)	rnp_reg_write32(base, offset, val)
 #define RNP_E_REG_WR(hw, off, value)	rnp_reg_write32((hw)->e_ctrl, (off), (value))
 #define RNP_E_REG_RD(hw, off)		rnp_reg_read32((hw)->e_ctrl, (off))
+#define RNP_MAC_REG_WR(hw, lane, off, value) \
+	rnp_reg_write32((hw)->mac_base[lane], (off), (value))
+#define RNP_MAC_REG_RD(hw, lane, off) \
+	rnp_reg_read32((hw)->mac_base[lane], (off))
 
 #endif /* _RNP_OSDEP_H_ */
drivers/net/rnp/rnp_ethdev.c +43 -0

54 lines not on this page · raw message

Signature · 1 line
2.34.1
author
#10 lore raw

PATCH v8 8/28 net/rnp: add queue setup and release operations

In reply to Wenbo Cao

support tx/rx queue setup and release add hw bd
queue reset,sw queue reset.

---
 doc/guides/nics/rnp.rst             |   1 +
 drivers/net/rnp/base/meson.build    |   1 +
 drivers/net/rnp/base/rnp_bdq_if.c   | 398 +++++++++++++++++++++++
 drivers/net/rnp/base/rnp_bdq_if.h   | 149 +++++++++
 drivers/net/rnp/base/rnp_common.h   |   4 +
 drivers/net/rnp/base/rnp_dma_regs.h |  45 +++
 drivers/net/rnp/base/rnp_eth_regs.h |   4 +
 drivers/net/rnp/base/rnp_hw.h       |   3 +
 drivers/net/rnp/base/rnp_osdep.h    |  13 +
 drivers/net/rnp/meson.build         |   1 +
 drivers/net/rnp/rnp.h               |   2 +
 drivers/net/rnp/rnp_ethdev.c        |  29 ++
 drivers/net/rnp/rnp_rxtx.c          | 476 ++++++++++++++++++++++++++++
 drivers/net/rnp/rnp_rxtx.h          | 123 +++++++
 14 files changed, 1249 insertions(+)
 create mode 100644 drivers/net/rnp/base/rnp_bdq_if.c
 create mode 100644 drivers/net/rnp/base/rnp_bdq_if.h
 create mode 100644 drivers/net/rnp/rnp_rxtx.c
 create mode 100644 drivers/net/rnp/rnp_rxtx.h
doc/guides/nics/rnp.rst +1 -0
index 62585acd4b..54175936b9 100644
@@ -10,6 +10,7 @@ driver support for the inbuilt network device found in the **Mucse RNP**
 Features
 --------
 
+- Multiple queues for TX and RX
 - Promiscuous mode
 
 Prerequisites
drivers/net/rnp/base/meson.build +1 -0
index b9db033ff6..c2ef0d05be 100644
@@ -7,6 +7,7 @@ sources = [
         'rnp_mbx_fw.c',
         'rnp_common.c',
         'rnp_mac.c',
+	'rnp_bdq_if.c',
 ]
 
 error_cflags = ['-Wno-unused-value',
drivers/net/rnp/base/rnp_bdq_if.c new file +398 -0

398 lines not on this page · raw message

drivers/net/rnp/base/rnp_bdq_if.h new file +149 -0

149 lines not on this page · raw message

drivers/net/rnp/base/rnp_common.h +4 -0
index aaf77a6dad..cf1996a675 100644
@@ -6,6 +6,10 @@
 #define _RNP_COMMON_H_
 
 #define RNP_NIC_RESET		_NIC_(0x0010)
+#define RNP_GET_MAC_HI(macaddr) (((macaddr[0]) << 8) | (macaddr[1]))
+#define RNP_GET_MAC_LO(macaddr) \
+	((macaddr[2] << 24) | (macaddr[3] << 16) | \
+	 ((macaddr[4] << 8)) | (macaddr[5]))
 int rnp_init_hw(struct rnp_hw *hw);
 int rnp_setup_common_ops(struct rnp_hw *hw);
 
drivers/net/rnp/base/rnp_dma_regs.h +45 -0

50 lines not on this page · raw message

drivers/net/rnp/base/rnp_eth_regs.h +4 -0
index c4519ba1e5..10e3d954b8 100644
@@ -10,6 +10,10 @@
 #define RNP_E_FILTER_EN		_ETH_(0x801c)
 #define RNP_E_REDIR_EN		_ETH_(0x8030)
 
+/* rx queue flow ctrl */
+#define RNP_RX_FC_ENABLE	_ETH_(0x8520)
+#define RNP_RING_FC_EN(n)	_ETH_(0x8524 + ((0x4) * ((n) / 32)))
+#define RNP_RING_FC_THRESH(n)	_ETH_(0x8a00 + ((0x4) * (n)))
 /* Mac Host Filter  */
 #define RNP_MAC_FCTRL		_ETH_(0x9110)
 #define RNP_MAC_FCTRL_MPE	RTE_BIT32(8)  /* Multicast Promiscuous En */
drivers/net/rnp/base/rnp_hw.h +3 -0
index dd9649ddbc..e2b2717f0a 100644
@@ -120,6 +120,9 @@ struct rnp_hw {
 	bool lane_is_sgmii[RNP_MAX_PORT_OF_PF];
 	struct rnp_mbx_info mbx;
 	struct rnp_fw_info fw_info;
+
+	spinlock_t rxq_reset_lock; /* reset op isn't thread safe */
+	spinlock_t txq_reset_lock; /* reset op isn't thread safe */
 };
 
 #endif /* __RNP_H__*/
drivers/net/rnp/base/rnp_osdep.h +13 -0
index 8817a4985c..c2dde3bb70 100644
@@ -14,6 +14,7 @@
 #include <rte_bitops.h>
 #include <rte_cycles.h>
 #include <rte_byteorder.h>
+#include <rte_spinlock.h>
 #include <rte_common.h>
 #include <rte_memcpy.h>
 #include <rte_memzone.h>
@@ -33,16 +34,28 @@ typedef rte_iova_t dma_addr_t;
 
 #define mb()	rte_mb()
 #define wmb()	rte_wmb()
+#define rmb()	rte_rmb()
 
 #define udelay(x) rte_delay_us(x)
 #define mdelay(x) rte_delay_ms(x)
 #define memcpy rte_memcpy
 
+#ifndef upper_32_bits
+#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
+#define lower_32_bits(n) ((u32)((n) & 0xffffffff))
+#endif
+
+#ifndef cpu_to_le32
+#define cpu_to_le16(v)	rte_cpu_to_le_16((u16)(v))
+#define cpu_to_le32(v)	rte_cpu_to_le_32((u32)(v))
+#endif
+
 #define spinlock_t			rte_spinlock_t
 #define spin_lock_init(spinlock_v)	rte_spinlock_init(spinlock_v)
 #define spin_lock(spinlock_v)		rte_spinlock_lock(spinlock_v)
 #define spin_unlock(spinlock_v)		rte_spinlock_unlock(spinlock_v)
 
+#define _RING_(off)	((off) + (0x08000))
 #define _ETH_(off)	((off) + (0x10000))
 #define _NIC_(off)	((off) + (0x30000))
 #define _MAC_(off)	((off) + (0x60000))
drivers/net/rnp/meson.build +1 -0
index 660b36e1b0..18cadd46ff 100644
@@ -14,4 +14,5 @@ includes += include_directories('base')
 
 sources = files(
                 'rnp_ethdev.c',
+                'rnp_rxtx.c',
 )
drivers/net/rnp/rnp.h +2 -0
index b777aa2a4a..b579fc1052 100644
@@ -105,6 +105,7 @@ struct rnp_eth_port {
 	struct rte_ether_addr mac_addr;
 	struct rte_eth_dev *eth_dev;
 	struct rnp_port_attr attr;
+	struct rnp_tx_queue *tx_queues[RNP_MAX_RX_QUEUE_NUM];
 	struct rnp_hw *hw;
 };
 
@@ -113,6 +114,7 @@ struct rnp_eth_adapter {
 	struct rte_pci_device *pdev;
 	struct rte_eth_dev *eth_dev; /* alloc eth_dev by platform */
 
+	struct rte_mempool *reset_pool;
 	struct rnp_eth_port *ports[RNP_MAX_PORT_OF_PF];
 	uint16_t closed_ports;
 	uint16_t inited_ports;
drivers/net/rnp/rnp_ethdev.c +29 -0
index 39736b01d0..52d2ed5641 100644
@@ -15,6 +15,7 @@
 #include "base/rnp_mac.h"
 #include "base/rnp_eth_regs.h"
 #include "base/rnp_common.h"
+#include "rnp_rxtx.h"
 
 static struct rte_eth_dev *
 rnp_alloc_eth_port(struct rte_pci_device *pci, char *name)
@@ -238,6 +239,11 @@ static const struct eth_dev_ops rnp_eth_dev_ops = {
 	.promiscuous_disable          = rnp_promiscuous_disable,
 	.allmulticast_enable          = rnp_allmulticast_enable,
 	.allmulticast_disable         = rnp_allmulticast_disable,
+
+	.rx_queue_setup               = rnp_rx_queue_setup,
+	.rx_queue_release             = rnp_dev_rx_queue_release,
+	.tx_queue_setup               = rnp_tx_queue_setup,
+	.tx_queue_release             = rnp_dev_tx_queue_release,
 };
 
 static void
@@ -330,6 +336,26 @@ rnp_proc_priv_init(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+rnp_rx_reset_pool_setup(struct rnp_eth_adapter *adapter)
+{
+	struct rte_eth_dev *eth_dev = adapter->eth_dev;
+	char name[RTE_MEMPOOL_NAMESIZE];
+
+	snprintf(name, sizeof(name), "rx_reset_pool_%d:%d",
+			eth_dev->data->port_id, eth_dev->device->numa_node);
+
+	adapter->reset_pool = rte_pktmbuf_pool_create(name, 2,
+			0, 0, RTE_MBUF_DEFAULT_BUF_SIZE,
+			eth_dev->device->numa_node);
+	if (adapter->reset_pool == NULL) {
+		RNP_PMD_ERR("mempool %s create failed", name);
+		return -ENOMEM;
+	}
+
+	return 0;
+}
+
 static int
 rnp_eth_dev_init(struct rte_eth_dev *eth_dev)
 {
@@ -425,6 +451,9 @@ rnp_eth_dev_init(struct rte_eth_dev *eth_dev)
 			rte_eth_dev_probing_finish(sub_eth_dev);
 		}
 	}
+	ret = rnp_rx_reset_pool_setup(adapter);
+	if (ret)
+		goto eth_alloc_error;
 	/* enable link update event interrupt */
 	rte_intr_callback_register(intr_handle,
 			rnp_dev_interrupt_handler, adapter);
drivers/net/rnp/rnp_rxtx.c new file +476 -0

476 lines not on this page · raw message

drivers/net/rnp/rnp_rxtx.h new file +123 -0

123 lines not on this page · raw message

Signature · 1 line
2.34.1
author
#11 lore raw

PATCH v8 9/28 net/rnp: add queue stop and start operations

In reply to Wenbo Cao

support rx/tx queue stop/start,for rx queue stop
need to reset a queue,must stop all rx queue
during reset this queue.

---
 doc/guides/nics/features/rnp.ini  |   1 +
 drivers/net/rnp/base/rnp_common.c |   3 +
 drivers/net/rnp/rnp_link.c        | 340 ++++++++++++++++++++++++++++++
 drivers/net/rnp/rnp_link.h        |  36 ++++
 drivers/net/rnp/rnp_rxtx.c        | 167 +++++++++++++++
 drivers/net/rnp/rnp_rxtx.h        |   9 +
 6 files changed, 556 insertions(+)
 create mode 100644 drivers/net/rnp/rnp_link.c
 create mode 100644 drivers/net/rnp/rnp_link.h
doc/guides/nics/features/rnp.ini +1 -0
index 65f1ed3da0..fd7d4b9d8d 100644
@@ -5,6 +5,7 @@
 ;
 [Features]
 Speed capabilities   = Y
+Queue start/stop     = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
 Linux                = Y
drivers/net/rnp/base/rnp_common.c +3 -0
index 5655126ae0..58de3bde03 100644
@@ -65,6 +65,9 @@ int rnp_init_hw(struct rnp_hw *hw)
 	/* setup mac resiger ctrl base */
 	for (idx = 0; idx < hw->max_port_num; idx++)
 		hw->mac_base[idx] = (u8 *)hw->e_ctrl + RNP_MAC_BASE_OFFSET(idx);
+	/* tx all hw queue must be started */
+	for (idx = 0; idx < RNP_MAX_RX_QUEUE_NUM; idx++)
+		RNP_E_REG_WR(hw, RNP_TXQ_START(idx), true);
 
 	return 0;
 }
drivers/net/rnp/rnp_link.c new file +340 -0

340 lines not on this page · raw message

drivers/net/rnp/rnp_link.h new file +36 -0
new file mode 100644
index 0000000000..f0705f17da
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2023 Mucse IC Design Ltd.
+ */
+
+#ifndef _RNP_LINK_H_
+#define _RNP_LINK_H_
+
+#define RNP_DEVICE_LINK		(0x3000c)
+#define RNP_DEVICE_LINK_EX	(0xa800 + 64 * 64 - 4)
+#define RNP_LINK_NOCHANGED(lane_bit, change_lane) \
+	(!((RTE_BIT32(lane_bit)) & (change_lane)))
+#define RNP_LINK_DUPLEX_ATTR_EN		(0xA0000000)
+#define RNP_SPEED_META_VALID(magic)	(!!(magic) == 0xA0000000)
+#define RNP_LINK_STATE(n)		RTE_BIT32(n)
+#define RNP_LINK_SPEED_CODE(sp, n) \
+	(((sp) & RTE_GENMASK32((11) + ((4) * (n)), \
+		(8) + ((4) * (n)))) >> (8 + 4 * (n)))
+#define RNP_LINK_DUPLEX_STATE(sp, n)	((sp) & RTE_BIT32((24) + (n)))
+#define RNP_ALARM_INTERVAL	(50000) /* unit us */
+enum rnp_lane_speed {
+	RNP_LANE_SPEED_10M = 0,
+	RNP_LANE_SPEED_100M,
+	RNP_LANE_SPEED_1G,
+	RNP_LANE_SPEED_10G,
+	RNP_LANE_SPEED_25G,
+	RNP_LANE_SPEED_40G,
+};
+
+void rnp_link_event(struct rnp_eth_adapter *adapter,
+		    struct rnp_mbx_fw_cmd_req *req);
+int rnp_dev_link_update(struct rte_eth_dev *eth_dev,
+			int wait_to_complete);
+void rnp_run_link_poll_task(struct rnp_eth_port *port);
+void rnp_cancel_link_poll_task(struct rnp_eth_port *port);
+
+#endif /* _RNP_LINK_H_ */
drivers/net/rnp/rnp_rxtx.c +167 -0

194 lines not on this page · raw message

drivers/net/rnp/rnp_rxtx.h +9 -0
index 3ea977ccaa..94e1f06722 100644
@@ -65,11 +65,14 @@ struct rnp_rx_queue {
 
 	uint32_t nodesc_tm_thresh; /* rx queue no desc timeout thresh */
 	uint8_t rx_deferred_start; /* do not start queue with dev_start(). */
+	uint8_t rxq_started; /* rx queue is started */
+	uint8_t rx_link; /* device link state */
 	uint8_t pthresh; /* rx desc prefetch threshold */
 	uint8_t pburst; /* rx desc prefetch burst */
 
 	uint64_t rx_offloads; /* user set hw offload features */
 	struct rte_mbuf **free_mbufs; /* rx bulk alloc reserve of free mbufs */
+	struct rte_mbuf fake_mbuf; /* dummy mbuf */
 };
 
 struct rnp_txsw_entry {
@@ -98,6 +101,8 @@ struct rnp_tx_queue {
 	uint16_t tx_free_thresh; /* thresh to free tx desc resource */
 
 	uint8_t tx_deferred_start; /*< Do not start queue with dev_start(). */
+	uint8_t txq_started; /* tx queue is started */
+	uint8_t tx_link; /* device link state */
 	uint8_t pthresh; /* rx desc prefetch threshold */
 	uint8_t pburst; /* rx desc burst*/
 
@@ -115,9 +120,13 @@ int rnp_rx_queue_setup(struct rte_eth_dev *eth_dev,
 		       unsigned int socket_id,
 		       const struct rte_eth_rxconf *rx_conf,
 		       struct rte_mempool *mb_pool);
+int rnp_tx_queue_stop(struct rte_eth_dev *eth_dev, uint16_t qidx);
+int rnp_tx_queue_start(struct rte_eth_dev *eth_dev, uint16_t qidx);
 int rnp_tx_queue_setup(struct rte_eth_dev *dev,
 		       uint16_t qidx, uint16_t nb_desc,
 		       unsigned int socket_id,
 		       const struct rte_eth_txconf *tx_conf);
+int rnp_rx_queue_stop(struct rte_eth_dev *eth_dev, uint16_t qidx);
+int rnp_rx_queue_start(struct rte_eth_dev *eth_dev, uint16_t qidx);
 
 #endif /* _RNP_RXTX_H_ */
Signature · 1 line
2.34.1
author
#12 lore raw

PATCH v8 10/28 net/rnp: add support device start stop operations

In reply to Wenbo Cao

add basic support for device to start/stop function

---
 drivers/net/rnp/base/rnp_common.c   |  22 +++
 drivers/net/rnp/base/rnp_common.h   |   1 +
 drivers/net/rnp/base/rnp_dma_regs.h |  10 +
 drivers/net/rnp/base/rnp_eth_regs.h |   5 +
 drivers/net/rnp/base/rnp_hw.h       |   1 +
 drivers/net/rnp/base/rnp_mac.h      |  14 ++
 drivers/net/rnp/base/rnp_mac_regs.h |  42 +++++
 drivers/net/rnp/rnp.h               |   3 +
 drivers/net/rnp/rnp_ethdev.c        | 274 +++++++++++++++++++++++++++-
 9 files changed, 371 insertions(+), 1 deletion(-)
drivers/net/rnp/base/rnp_common.c +22 -0
index 58de3bde03..2dacb5113e 100644
@@ -79,3 +79,25 @@ rnp_setup_common_ops(struct rnp_hw *hw)
 
 	return 0;
 }
+
+int rnp_clock_valid_check(struct rnp_hw *hw, u16 nr_lane)
+{
+	uint16_t timeout = 0;
+
+	do {
+		RNP_E_REG_WR(hw, RNP_RSS_REDIR_TB(nr_lane, 0), 0x7f);
+		udelay(10);
+		timeout++;
+		if (timeout >= 1000)
+			break;
+	} while (RNP_E_REG_RD(hw, RNP_RSS_REDIR_TB(nr_lane, 0)) != 0x7f);
+
+	if (timeout >= 1000) {
+		RNP_PMD_ERR("ethernet[%d] eth reg can't be write", nr_lane);
+		return -EPERM;
+	}
+	/* clear the dirty value */
+	RNP_E_REG_WR(hw, RNP_RSS_REDIR_TB(nr_lane, 0), 0);
+
+	return 0;
+}
drivers/net/rnp/base/rnp_common.h +1 -0
index cf1996a675..91e2996398 100644
@@ -12,5 +12,6 @@
 	 ((macaddr[4] << 8)) | (macaddr[5]))
 int rnp_init_hw(struct rnp_hw *hw);
 int rnp_setup_common_ops(struct rnp_hw *hw);
+int rnp_clock_valid_check(struct rnp_hw *hw, u16 nr_lane);
 
 #endif /* _RNP_COMMON_H_ */
drivers/net/rnp/base/rnp_dma_regs.h +10 -0
index 7c17741c55..8bc6fe581a 100644
@@ -6,9 +6,19 @@
 #define _RNP_DMA_REGS_H_
 
 #define RNP_DMA_VERSION		(0)
+#define RNP_DMA_CTRL		(0x4)
+/* 1bit <-> 16 bytes dma addr size */
+#define RNP_DMA_SCATTER_MEM_MASK	RTE_GENMASK32(31, 16)
+#define RNP_DMA_SCATTER_MEN_S		(16)
+#define RNP_DMA_RX_MEM_PAD_EN		RTE_BIT32(8)
+#define RTE_DMA_VEB_BYPASS		RTE_BIT32(4)
+#define RNP_DMA_TXRX_LOOP		RTE_BIT32(1)
+#define RNP_DMA_TXMRX_LOOP		RTE_BIT32(0)
+
 #define RNP_DMA_HW_EN		(0x10)
 #define RNP_DMA_EN_ALL		(0b1111)
 #define RNP_DMA_HW_STATE	(0x14)
+
 /* --- queue register --- */
 /* queue enable */
 #define RNP_RXQ_START(qid)	_RING_(0x0010 + 0x100 * (qid))
drivers/net/rnp/base/rnp_eth_regs.h +5 -0
index 10e3d954b8..60766d2035 100644
@@ -10,6 +10,9 @@
 #define RNP_E_FILTER_EN		_ETH_(0x801c)
 #define RNP_E_REDIR_EN		_ETH_(0x8030)
 
+#define RNP_RX_ETH_F_CTRL(n)	_ETH_(0x8070 + ((n) * 0x8))
+#define RNP_RX_ETH_F_OFF	(0x7ff)
+#define RNP_RX_ETH_F_ON		(0x270)
 /* rx queue flow ctrl */
 #define RNP_RX_FC_ENABLE	_ETH_(0x8520)
 #define RNP_RING_FC_EN(n)	_ETH_(0x8524 + ((0x4) * ((n) / 32)))
@@ -28,6 +31,8 @@
 #define RNP_MAC_HASH_MASK		RTE_GENMASK32(11, 0)
 #define RNP_MAC_MULTICASE_TBL_EN	RTE_BIT32(2)
 #define RNP_MAC_UNICASE_TBL_EN		RTE_BIT32(3)
+/* rss function ctrl */
+#define RNP_RSS_REDIR_TB(n, id) _ETH_(0xe000 + ((n) * 0x200) + ((id) * 0x4))
 
 #define RNP_TC_PORT_OFFSET(lane)	_ETH_(0xe840 + 0x04 * (lane))
 
drivers/net/rnp/base/rnp_hw.h +1 -0
index e2b2717f0a..6cdca99bda 100644
@@ -120,6 +120,7 @@ struct rnp_hw {
 	bool lane_is_sgmii[RNP_MAX_PORT_OF_PF];
 	struct rnp_mbx_info mbx;
 	struct rnp_fw_info fw_info;
+	u16 min_dma_size;
 
 	spinlock_t rxq_reset_lock; /* reset op isn't thread safe */
 	spinlock_t txq_reset_lock; /* reset op isn't thread safe */
drivers/net/rnp/base/rnp_mac.h +14 -0
index 57cbd9e3d5..1dac903396 100644
@@ -7,6 +7,20 @@
 
 #include "rnp_osdep.h"
 #include "rnp_hw.h"
+#include "rnp_eth_regs.h"
+
+#define RNP_RX_ETH_DISABLE(hw, nr_lane) do { \
+	wmb(); \
+	RNP_E_REG_WR(hw, RNP_RX_ETH_F_CTRL(nr_lane), \
+			RNP_RX_ETH_F_OFF); \
+} while (0)
+
+#define RNP_RX_ETH_ENABLE(hw, nr_lane) do { \
+	wmb(); \
+	RNP_E_REG_WR(hw, RNP_RX_ETH_F_CTRL(nr_lane), \
+			RNP_RX_ETH_F_ON); \
+} while (0)
+
 
 void rnp_mac_ops_init(struct rnp_hw *hw);
 int rnp_get_mac_addr(struct rnp_eth_port *port, u8 *mac);
drivers/net/rnp/base/rnp_mac_regs.h +42 -0

53 lines not on this page · raw message

drivers/net/rnp/rnp.h +3 -0
index b579fc1052..27fff0282f 100644
@@ -107,6 +107,9 @@ struct rnp_eth_port {
 	struct rnp_port_attr attr;
 	struct rnp_tx_queue *tx_queues[RNP_MAX_RX_QUEUE_NUM];
 	struct rnp_hw *hw;
+
+	rte_spinlock_t rx_mac_lock;
+	bool port_stopped;
 };
 
 struct rnp_eth_adapter {
drivers/net/rnp/rnp_ethdev.c +273 -1

306 lines not on this page · raw message

Signature · 1 line
2.34.1
author
#13 lore raw

PATCH v8 11/28 net/rnp: add RSS support operations

In reply to Wenbo Cao

add support rss reta updata/query rss hash update/get dev_configure add rss conf check.

---
 doc/guides/nics/features/rnp.ini    |   4 +
 doc/guides/nics/rnp.rst             |   3 +
 drivers/net/rnp/base/rnp_eth_regs.h |  16 ++
 drivers/net/rnp/meson.build         |   1 +
 drivers/net/rnp/rnp.h               |   7 +
 drivers/net/rnp/rnp_ethdev.c        |  23 ++
 drivers/net/rnp/rnp_rss.c           | 367 ++++++++++++++++++++++++++++
 drivers/net/rnp/rnp_rss.h           |  43 ++++
 8 files changed, 464 insertions(+)
 create mode 100644 drivers/net/rnp/rnp_rss.c
 create mode 100644 drivers/net/rnp/rnp_rss.h
doc/guides/nics/features/rnp.ini +4 -0
index fd7d4b9d8d..2fc94825f5 100644
@@ -8,5 +8,9 @@ Speed capabilities   = Y
 Queue start/stop     = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
+RSS hash             = Y
+RSS key update       = Y
+RSS reta update      = Y
+Inner RSS            = Y
 Linux                = Y
 x86-64               = Y
doc/guides/nics/rnp.rst +3 -0
index 54175936b9..8f9d38d92c 100644
@@ -11,6 +11,9 @@ Features
 --------
 
 - Multiple queues for TX and RX
+- Receiver Side Steering (RSS)
+  Receiver Side Steering (RSS) on IPv4, IPv6, IPv4-TCP/UDP/SCTP, IPv6-TCP/UDP/SCTP
+  Inner RSS is only support for vxlan/nvgre
 - Promiscuous mode
 
 Prerequisites
drivers/net/rnp/base/rnp_eth_regs.h +16 -0
index 60766d2035..be7ed5b886 100644
@@ -32,7 +32,23 @@
 #define RNP_MAC_MULTICASE_TBL_EN	RTE_BIT32(2)
 #define RNP_MAC_UNICASE_TBL_EN		RTE_BIT32(3)
 /* rss function ctrl */
+#define RNP_RSS_INNER_CTRL	_ETH_(0x805c)
+#define RNP_INNER_RSS_EN	(1)
+#define RNP_INNER_RSS_DIS	(0)
 #define RNP_RSS_REDIR_TB(n, id) _ETH_(0xe000 + ((n) * 0x200) + ((id) * 0x4))
+#define RNP_RSS_MRQC_ADDR	_ETH_(0x92a0)
+/* RSS policy */
+#define RNP_RSS_HASH_CFG_MASK	(0x3F30000)
+#define RNP_RSS_HASH_IPV4_TCP	RTE_BIT32(16)
+#define RNP_RSS_HASH_IPV4	RTE_BIT32(17)
+#define RNP_RSS_HASH_IPV6	RTE_BIT32(20)
+#define RNP_RSS_HASH_IPV6_TCP	RTE_BIT32(21)
+#define RNP_RSS_HASH_IPV4_UDP	RTE_BIT32(22)
+#define RNP_RSS_HASH_IPV6_UDP   RTE_BIT32(23)
+#define RNP_RSS_HASH_IPV4_SCTP  RTE_BIT32(24)
+#define RNP_RSS_HASH_IPV6_SCTP  RTE_BIT32(25)
+/* rss hash key */
+#define RNP_RSS_KEY_TABLE(idx)	_ETH_(0x92d0 + ((idx) * 0x4))
 
 #define RNP_TC_PORT_OFFSET(lane)	_ETH_(0xe840 + 0x04 * (lane))
 
drivers/net/rnp/meson.build +1 -0
index 18cadd46ff..a74fbe42bf 100644
@@ -15,4 +15,5 @@ includes += include_directories('base')
 sources = files(
                 'rnp_ethdev.c',
                 'rnp_rxtx.c',
+                'rnp_rss.c',
 )
drivers/net/rnp/rnp.h +7 -0
index 27fff0282f..c62204f851 100644
@@ -108,6 +108,13 @@ struct rnp_eth_port {
 	struct rnp_tx_queue *tx_queues[RNP_MAX_RX_QUEUE_NUM];
 	struct rnp_hw *hw;
 
+	struct rte_eth_rss_conf rss_conf;
+	uint16_t last_rx_num;
+	bool rxq_num_changed;
+	bool reta_has_cfg;
+	bool hw_rss_en;
+	uint32_t indirtbl[RNP_RSS_INDIR_SIZE];
+
 	rte_spinlock_t rx_mac_lock;
 	bool port_stopped;
 };
drivers/net/rnp/rnp_ethdev.c +23 -0
index 5d33da7fb2..482ebc84a9 100644
@@ -18,6 +18,7 @@
 #include "base/rnp_dma_regs.h"
 #include "base/rnp_mac_regs.h"
 #include "rnp_rxtx.h"
+#include "rnp_rss.h"
 
 static struct rte_eth_dev *
 rnp_alloc_eth_port(struct rte_pci_device *pci, char *name)
@@ -235,6 +236,9 @@ static int rnp_dev_start(struct rte_eth_dev *eth_dev)
 	}
 	/* disable eth rx flow */
 	RNP_RX_ETH_DISABLE(hw, lane);
+	ret = rnp_dev_rss_configure(eth_dev);
+	if (ret)
+		return ret;
 	ret = rnp_rx_scattered_setup(eth_dev);
 	if (ret)
 		return ret;
@@ -302,6 +306,19 @@ static int rnp_disable_all_tx_queue(struct rte_eth_dev *dev)
 	return ret;
 }
 
+static int rnp_dev_configure(struct rte_eth_dev *eth_dev)
+{
+	struct rnp_eth_port *port = RNP_DEV_TO_PORT(eth_dev);
+
+	if (port->last_rx_num != eth_dev->data->nb_rx_queues)
+		port->rxq_num_changed = true;
+	else
+		port->rxq_num_changed = false;
+	port->last_rx_num = eth_dev->data->nb_rx_queues;
+
+	return 0;
+}
+
 static int rnp_dev_stop(struct rte_eth_dev *eth_dev)
 {
 	struct rnp_eth_port *port = RNP_DEV_TO_PORT(eth_dev);
@@ -498,6 +515,7 @@ static int rnp_allmulticast_disable(struct rte_eth_dev *eth_dev)
 
 /* Features supported by this driver */
 static const struct eth_dev_ops rnp_eth_dev_ops = {
+	.dev_configure                = rnp_dev_configure,
 	.dev_close                    = rnp_dev_close,
 	.dev_start                    = rnp_dev_start,
 	.dev_stop                     = rnp_dev_stop,
@@ -513,6 +531,11 @@ static const struct eth_dev_ops rnp_eth_dev_ops = {
 	.rx_queue_release             = rnp_dev_rx_queue_release,
 	.tx_queue_setup               = rnp_tx_queue_setup,
 	.tx_queue_release             = rnp_dev_tx_queue_release,
+	/* rss impl */
+	.reta_update                  = rnp_dev_rss_reta_update,
+	.reta_query                   = rnp_dev_rss_reta_query,
+	.rss_hash_update              = rnp_dev_rss_hash_update,
+	.rss_hash_conf_get            = rnp_dev_rss_hash_conf_get,
 };
 
 static void
drivers/net/rnp/rnp_rss.c new file +367 -0

367 lines not on this page · raw message

drivers/net/rnp/rnp_rss.h new file +43 -0

43 lines not on this page · raw message

Signature · 1 line
2.34.1
author
#14 lore raw

PATCH v8 12/28 net/rnp: add support link update operations.

In reply to Wenbo Cao

add support poll/irq link get mode

---
 doc/guides/nics/features/rnp.ini  |   2 +
 doc/guides/nics/rnp.rst           |   1 +
 drivers/net/rnp/base/rnp_fw_cmd.c |  45 ++++++++++++
 drivers/net/rnp/base/rnp_fw_cmd.h |  58 ++++++++++++++-
 drivers/net/rnp/base/rnp_hw.h     |   1 +
 drivers/net/rnp/base/rnp_mbx_fw.c |  72 ++++++++++++++++++-
 drivers/net/rnp/base/rnp_mbx_fw.h |   4 ++
 drivers/net/rnp/meson.build       |   1 +
 drivers/net/rnp/rnp.h             |  12 ++++
 drivers/net/rnp/rnp_ethdev.c      | 116 ++++++++++++++++++++++++++++--
 drivers/net/rnp/rnp_link.h        |   2 +-
 11 files changed, 305 insertions(+), 9 deletions(-)
doc/guides/nics/features/rnp.ini +2 -0
index 2fc94825f5..695b9c0dba 100644
@@ -5,6 +5,8 @@
 ;
 [Features]
 Speed capabilities   = Y
+Link status          = Y
+Link status event    = Y
 Queue start/stop     = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
doc/guides/nics/rnp.rst +1 -0
index 8f9d38d92c..82dd2d8db0 100644
@@ -15,6 +15,7 @@ Features
   Receiver Side Steering (RSS) on IPv4, IPv6, IPv4-TCP/UDP/SCTP, IPv6-TCP/UDP/SCTP
   Inner RSS is only support for vxlan/nvgre
 - Promiscuous mode
+- Link state information
 
 Prerequisites
 -------------
drivers/net/rnp/base/rnp_fw_cmd.c +45 -0

57 lines not on this page · raw message

drivers/net/rnp/base/rnp_fw_cmd.h +57 -1

83 lines not on this page · raw message

drivers/net/rnp/base/rnp_hw.h +1 -0
index 6cdca99bda..0ec536e488 100644
@@ -124,6 +124,7 @@ struct rnp_hw {
 
 	spinlock_t rxq_reset_lock; /* reset op isn't thread safe */
 	spinlock_t txq_reset_lock; /* reset op isn't thread safe */
+	spinlock_t link_sync; /* link info update must be one user */
 };
 
 #endif /* __RNP_H__*/
drivers/net/rnp/base/rnp_mbx_fw.c +71 -1

81 lines not on this page · raw message

drivers/net/rnp/base/rnp_mbx_fw.h +4 -0
index fd0110b539..159a0237be 100644
@@ -14,6 +14,10 @@ int rnp_mbx_fw_get_macaddr(struct rnp_eth_port *port, u8 *mac_addr);
 int rnp_mbx_fw_get_capability(struct rnp_eth_port *port);
 int rnp_mbx_fw_get_lane_stat(struct rnp_eth_port *port);
 int rnp_mbx_fw_reset_phy(struct rnp_hw *hw);
+int rnp_mbx_fw_pf_link_event_en(struct rnp_eth_port *port, bool en);
 int rnp_fw_init(struct rnp_hw *hw);
+int rnp_rcv_msg_from_fw(struct rnp_eth_adapter *adapter, u32 *msgbuf);
+int rnp_fw_mbx_ifup_down(struct rnp_eth_port *port, int up);
+int rnp_mbx_fw_lane_link_event_en(struct rnp_eth_port *port, bool en);
 
 #endif /* _RNP_MBX_FW_H_ */
drivers/net/rnp/meson.build +1 -0
index a74fbe42bf..8a03f29dcd 100644
@@ -16,4 +16,5 @@ sources = files(
                 'rnp_ethdev.c',
                 'rnp_rxtx.c',
                 'rnp_rss.c',
+                'rnp_link.c',
 )
drivers/net/rnp/rnp.h +12 -0
index c62204f851..c61ade7925 100644
@@ -89,6 +89,11 @@ struct rnp_port_attr {
 
 	struct rnp_phy_meta phy_meta;
 
+	bool link_ready;
+	bool pre_link;
+	bool duplex;
+	uint32_t speed;
+
 	uint16_t port_id;	/* platform manage port sequence id */
 	uint8_t port_offset;	/* port queue offset */
 	uint8_t sw_id;		/* software port init sequence id */
@@ -119,6 +124,12 @@ struct rnp_eth_port {
 	bool port_stopped;
 };
 
+enum rnp_pf_op {
+	RNP_PF_OP_DONE,
+	RNP_PF_OP_CLOSING = 1,
+	RNP_PF_OP_PROCESS,
+};
+
 struct rnp_eth_adapter {
 	struct rnp_hw hw;
 	struct rte_pci_device *pdev;
@@ -126,6 +137,7 @@ struct rnp_eth_adapter {
 
 	struct rte_mempool *reset_pool;
 	struct rnp_eth_port *ports[RNP_MAX_PORT_OF_PF];
+	rte_atomic32_t pf_op;
 	uint16_t closed_ports;
 	uint16_t inited_ports;
 	bool intr_registered;
drivers/net/rnp/rnp_ethdev.c +110 -6

203 lines not on this page · raw message

drivers/net/rnp/rnp_link.h +1 -1
index f0705f17da..8c2a3cbd59 100644
@@ -10,7 +10,7 @@
 #define RNP_LINK_NOCHANGED(lane_bit, change_lane) \
 	(!((RTE_BIT32(lane_bit)) & (change_lane)))
 #define RNP_LINK_DUPLEX_ATTR_EN		(0xA0000000)
-#define RNP_SPEED_META_VALID(magic)	(!!(magic) == 0xA0000000)
+#define RNP_SPEED_META_VALID(magic)	(!!((magic) == 0xA0000000))
 #define RNP_LINK_STATE(n)		RTE_BIT32(n)
 #define RNP_LINK_SPEED_CODE(sp, n) \
 	(((sp) & RTE_GENMASK32((11) + ((4) * (n)), \
Signature · 1 line
2.34.1
author
#15 lore raw

PATCH v8 13/28 net/rnp: add support link setup operations

In reply to Wenbo Cao

add set link_down/link_up implement

---
 drivers/net/rnp/base/rnp_eth_regs.h |  3 +
 drivers/net/rnp/base/rnp_fw_cmd.c   | 22 +++++++
 drivers/net/rnp/base/rnp_fw_cmd.h   |  6 ++
 drivers/net/rnp/base/rnp_mbx_fw.c   | 33 ++++++++++
 drivers/net/rnp/base/rnp_mbx_fw.h   |  1 +
 drivers/net/rnp/rnp_ethdev.c        |  4 ++
 drivers/net/rnp/rnp_link.c          | 99 +++++++++++++++++++++++++++++
 drivers/net/rnp/rnp_link.h          |  2 +
 8 files changed, 170 insertions(+)
drivers/net/rnp/base/rnp_eth_regs.h +3 -0
index be7ed5b886..c74886e70c 100644
@@ -5,6 +5,9 @@
 #ifndef _RNP_ETH_REGS_H
 #define _RNP_ETH_REGS_H
 
+#define RNP_ETH_TX_FIFO_STATE		_ETH_(0x0330)
+#define RNP_ETH_TX_FIFO_EMPT(lane)	((1 << (lane)) | (1 << ((lane) + 4)))
+
 #define RNP_E_ENG_BYPASS	_ETH_(0x8000)
 #define RNP_E_VXLAN_PARSE_EN	_ETH_(0x8004)
 #define RNP_E_FILTER_EN		_ETH_(0x801c)
drivers/net/rnp/base/rnp_fw_cmd.c +22 -0
index c5ae7b954c..17d3bb2761 100644
@@ -107,6 +107,25 @@ rnp_build_lane_evet_mask(struct rnp_mbx_fw_cmd_req *req,
 	arg->event_en = req_arg->param2;
 }
 
+static void
+rnp_build_ifup_down(struct rnp_mbx_fw_cmd_req *req,
+		    struct rnp_fw_req_arg *req_arg,
+		    void *cookie)
+{
+	struct rnp_ifup_down_req *arg =
+		(struct rnp_ifup_down_req *)req->data;
+
+	req->flags = 0;
+	req->opcode = RNP_IFUP_DOWN;
+	req->datalen = sizeof(*arg);
+	req->cookie = cookie;
+	req->reply_lo = 0;
+	req->reply_hi = 0;
+
+	arg->nr_lane = req_arg->param0;
+	arg->up = req_arg->param1;
+}
+
 int rnp_build_fwcmd_req(struct rnp_mbx_fw_cmd_req *req,
 			struct rnp_fw_req_arg *arg,
 			void *cookie)
@@ -132,6 +151,9 @@ int rnp_build_fwcmd_req(struct rnp_mbx_fw_cmd_req *req,
 	case RNP_SET_LANE_EVENT_EN:
 		rnp_build_lane_evet_mask(req, arg, cookie);
 		break;
+	case RNP_IFUP_DOWN:
+		rnp_build_ifup_down(req, arg, cookie);
+		break;
 	default:
 		err = -EOPNOTSUPP;
 	}
drivers/net/rnp/base/rnp_fw_cmd.h +6 -0
index 6734834644..4d73b1e018 100644
@@ -310,6 +310,12 @@ struct rnp_link_stat_req {
 	struct rnp_port_stat states[RNP_MAX_PORT_OF_PF];
 };
 
+struct rnp_ifup_down_req {
+	u32 nr_lane;
+	u32 up;
+	u8 rsvd[24];
+};
+
 struct rnp_mbx_fw_cmd_req {
 	u16 flags;
 	u16 opcode;
drivers/net/rnp/base/rnp_mbx_fw.c +33 -0
index b968c50a5f..41b7d0df8b 100644
@@ -464,3 +464,36 @@ rnp_rcv_msg_from_fw(struct rnp_eth_adapter *adapter, u32 *msgbuf)
 
 	return 0;
 }
+
+static void rnp_link_stat_reset(struct rnp_hw *hw, u16 lane)
+{
+	u32 state;
+
+	spin_lock(&hw->link_sync);
+	state = RNP_E_REG_RD(hw, RNP_FW_LINK_SYNC);
+	state &= ~RNP_LINK_MAGIC_MASK;
+	state |= RNP_LINK_MAGIC_CODE;
+	state &= ~RTE_BIT32(lane);
+
+	RNP_E_REG_WR(hw, RNP_FW_LINK_SYNC, state);
+	rte_spinlock_unlock(&hw->link_sync);
+}
+
+int rnp_mbx_fw_ifup_down(struct rnp_eth_port *port, bool up)
+{
+	u16 nr_lane = port->attr.nr_lane;
+	struct rnp_hw *hw = port->hw;
+	struct rnp_fw_req_arg arg;
+	int err;
+
+	memset(&arg, 0, sizeof(arg));
+	arg.opcode = RNP_IFUP_DOWN;
+	arg.param0 = nr_lane;
+	arg.param1 = up;
+
+	err = rnp_fw_send_norep_cmd(port, &arg);
+	/* force firmware send irq event to dpdk */
+	if (!err && up)
+		rnp_link_stat_reset(hw, nr_lane);
+	return err;
+}
drivers/net/rnp/base/rnp_mbx_fw.h +1 -0
index 159a0237be..397d2ec8c4 100644
@@ -19,5 +19,6 @@ int rnp_fw_init(struct rnp_hw *hw);
 int rnp_rcv_msg_from_fw(struct rnp_eth_adapter *adapter, u32 *msgbuf);
 int rnp_fw_mbx_ifup_down(struct rnp_eth_port *port, int up);
 int rnp_mbx_fw_lane_link_event_en(struct rnp_eth_port *port, bool en);
+int rnp_mbx_fw_ifup_down(struct rnp_eth_port *port, bool up);
 
 #endif /* _RNP_MBX_FW_H_ */
drivers/net/rnp/rnp_ethdev.c +4 -0
index dbedb150c1..e122ccc006 100644
@@ -327,6 +327,7 @@ static int rnp_dev_start(struct rte_eth_dev *eth_dev)
 	rnp_mbx_fw_lane_link_event_en(port, lsc);
 	if (!lsc)
 		rnp_run_link_poll_task(port);
+	rnp_dev_set_link_up(eth_dev);
 	/* enable eth rx flow */
 	RNP_RX_ETH_ENABLE(hw, lane);
 	port->port_stopped = 0;
@@ -412,6 +413,7 @@ static int rnp_dev_stop(struct rte_eth_dev *eth_dev)
 	/* clear the recorded link status */
 	memset(&link, 0, sizeof(link));
 	rte_eth_linkstatus_set(eth_dev, &link);
+	rnp_dev_set_link_down(eth_dev);
 	rnp_disable_all_tx_queue(eth_dev);
 	rnp_disable_all_rx_queue(eth_dev);
 	rnp_mac_tx_disable(eth_dev);
@@ -639,6 +641,8 @@ static const struct eth_dev_ops rnp_eth_dev_ops = {
 	.rss_hash_conf_get            = rnp_dev_rss_hash_conf_get,
 	/* link impl */
 	.link_update                  = rnp_dev_link_update,
+	.dev_set_link_up              = rnp_dev_set_link_up,
+	.dev_set_link_down            = rnp_dev_set_link_down,
 };
 
 static void
drivers/net/rnp/rnp_link.c +99 -0

102 lines not on this page · raw message

drivers/net/rnp/rnp_link.h +2 -0
index 8c2a3cbd59..6f55049b1e 100644
@@ -32,5 +32,7 @@ int rnp_dev_link_update(struct rte_eth_dev *eth_dev,
 			int wait_to_complete);
 void rnp_run_link_poll_task(struct rnp_eth_port *port);
 void rnp_cancel_link_poll_task(struct rnp_eth_port *port);
+int rnp_dev_set_link_up(struct rte_eth_dev *eth_dev);
+int rnp_dev_set_link_down(struct rte_eth_dev *eth_dev);
 
 #endif /* _RNP_LINK_H_ */
Signature · 1 line
2.34.1
author
#16 lore raw

PATCH v8 14/28 net/rnp: add Rx burst simple support

In reply to Wenbo Cao

add only support simple recv pkts.

---
 drivers/net/rnp/rnp_ethdev.c |   7 ++
 drivers/net/rnp/rnp_rxtx.c   | 129 +++++++++++++++++++++++++++++++++++
 drivers/net/rnp/rnp_rxtx.h   |   5 ++
 3 files changed, 141 insertions(+)
drivers/net/rnp/rnp_ethdev.c +7 -0
index e122ccc006..064c155d28 100644
@@ -330,6 +330,8 @@ static int rnp_dev_start(struct rte_eth_dev *eth_dev)
 	rnp_dev_set_link_up(eth_dev);
 	/* enable eth rx flow */
 	RNP_RX_ETH_ENABLE(hw, lane);
+	rnp_rx_func_select(eth_dev);
+	rnp_tx_func_select(eth_dev);
 	port->port_stopped = 0;
 
 	return 0;
@@ -569,6 +571,11 @@ static int rnp_dev_infos_get(struct rte_eth_dev *eth_dev,
 
 	dev_info->default_rxconf = (struct rte_eth_rxconf) {
 		.rx_drop_en = 0,
+		.rx_thresh = {
+			.pthresh = RNP_RX_DESC_FETCH_TH,
+			.hthresh = RNP_RX_DESC_FETCH_BURST,
+		},
+		.rx_free_thresh = RNP_DEFAULT_RX_FREE_THRESH,
 		.offloads = 0,
 	};
 
drivers/net/rnp/rnp_rxtx.c +129 -0

132 lines not on this page · raw message

drivers/net/rnp/rnp_rxtx.h +5 -0
index 94e1f06722..39e5184502 100644
@@ -63,6 +63,9 @@ struct rnp_rx_queue {
 	uint16_t rx_free_thresh; /* rx free desc desource thresh */
 	uint16_t rx_tail;
 
+	uint16_t rxrearm_start;
+	uint16_t rxrearm_nb;
+
 	uint32_t nodesc_tm_thresh; /* rx queue no desc timeout thresh */
 	uint8_t rx_deferred_start; /* do not start queue with dev_start(). */
 	uint8_t rxq_started; /* rx queue is started */
@@ -128,5 +131,7 @@ int rnp_tx_queue_setup(struct rte_eth_dev *dev,
 		       const struct rte_eth_txconf *tx_conf);
 int rnp_rx_queue_stop(struct rte_eth_dev *eth_dev, uint16_t qidx);
 int rnp_rx_queue_start(struct rte_eth_dev *eth_dev, uint16_t qidx);
+int rnp_rx_func_select(struct rte_eth_dev *dev);
+int rnp_tx_func_select(struct rte_eth_dev *dev);
 
 #endif /* _RNP_RXTX_H_ */
Signature · 1 line
2.34.1
author
#17 lore raw

PATCH v8 15/28 net/rnp: add Tx burst simple support

In reply to Wenbo Cao

add only support simple send pkts.

---
 drivers/net/rnp/rnp_ethdev.c |  6 +++
 drivers/net/rnp/rnp_rxtx.c   | 85 +++++++++++++++++++++++++++++++++++-
 drivers/net/rnp/rnp_rxtx.h   |  1 +
 3 files changed, 91 insertions(+), 1 deletion(-)
drivers/net/rnp/rnp_ethdev.c +6 -0
index 064c155d28..bf69d598d3 100644
@@ -580,6 +580,12 @@ static int rnp_dev_infos_get(struct rte_eth_dev *eth_dev,
 	};
 
 	dev_info->default_txconf = (struct rte_eth_txconf) {
+		.tx_thresh = {
+			.pthresh = RNP_TX_DESC_FETCH_TH,
+			.hthresh = RNP_TX_DESC_FETCH_BURST,
+		},
+		.tx_free_thresh = RNP_DEFAULT_TX_FREE_THRESH,
+		.tx_rs_thresh = RNP_DEFAULT_TX_RS_THRESH,
 		.offloads = 0,
 	};
 
drivers/net/rnp/rnp_rxtx.c +84 -1

97 lines not on this page · raw message

drivers/net/rnp/rnp_rxtx.h +1 -0
index 39e5184502..a8fd8d052f 100644
@@ -89,6 +89,7 @@ struct rnp_tx_queue {
 	const struct rte_memzone *rz;
 	uint64_t ring_phys_addr; /* tx dma ring physical addr */
 	volatile struct rnp_tx_desc *tx_bdr; /* tx dma ring virtual addr */
+	volatile struct rnp_tx_desc zero_desc;
 	struct rnp_txsw_entry *sw_ring; /* tx software ring addr */
 	volatile void *tx_tailreg; /* hw desc tail register */
 	volatile void *tx_headreg; /* hw desc head register*/
Signature · 1 line
2.34.1
author
#18 lore raw

PATCH v8 16/28 net/rnp: add MTU set operation

In reply to Wenbo Cao

add mtu update limit for multiple port mode.
multiple mode just used the max-mtu of ports
to limit receive.

---
 doc/guides/nics/features/rnp.ini    |   1 +
 doc/guides/nics/rnp.rst             |   1 +
 drivers/net/rnp/base/rnp_eth_regs.h |   3 +
 drivers/net/rnp/rnp.h               |   3 +
 drivers/net/rnp/rnp_ethdev.c        | 144 +++++++++++++++++++++++++++-
 5 files changed, 151 insertions(+), 1 deletion(-)
doc/guides/nics/features/rnp.ini +1 -0
index 695b9c0dba..6d13370e8f 100644
@@ -10,6 +10,7 @@ Link status event    = Y
 Queue start/stop     = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
+MTU update           = Y
 RSS hash             = Y
 RSS key update       = Y
 RSS reta update      = Y
doc/guides/nics/rnp.rst +1 -0
index 82dd2d8db0..9fa7ad9ae9 100644
@@ -16,6 +16,7 @@ Features
   Inner RSS is only support for vxlan/nvgre
 - Promiscuous mode
 - Link state information
+- MTU update
 
 Prerequisites
 -------------
drivers/net/rnp/base/rnp_eth_regs.h +3 -0
index c74886e70c..91a18dd42d 100644
@@ -16,6 +16,9 @@
 #define RNP_RX_ETH_F_CTRL(n)	_ETH_(0x8070 + ((n) * 0x8))
 #define RNP_RX_ETH_F_OFF	(0x7ff)
 #define RNP_RX_ETH_F_ON		(0x270)
+/* max/min pkts length receive limit ctrl */
+#define RNP_MIN_FRAME_CTRL	_ETH_(0x80f0)
+#define RNP_MAX_FRAME_CTRL	_ETH_(0x80f4)
 /* rx queue flow ctrl */
 #define RNP_RX_FC_ENABLE	_ETH_(0x8520)
 #define RNP_RING_FC_EN(n)	_ETH_(0x8524 + ((0x4) * ((n) / 32)))
drivers/net/rnp/rnp.h +3 -0
index c61ade7925..7ed20521c5 100644
@@ -120,6 +120,9 @@ struct rnp_eth_port {
 	bool hw_rss_en;
 	uint32_t indirtbl[RNP_RSS_INDIR_SIZE];
 
+	uint16_t cur_mtu;
+	bool jumbo_en;
+
 	rte_spinlock_t rx_mac_lock;
 	bool port_stopped;
 };
drivers/net/rnp/rnp_ethdev.c +143 -1

192 lines not on this page · raw message

Signature · 1 line
2.34.1
author
#19 lore raw

PATCH v8 17/28 net/rnp: add Rx scatter segment version

In reply to Wenbo Cao

add support scatter multi segment received.

---
 doc/guides/nics/features/rnp.ini |   2 +
 doc/guides/nics/rnp.rst          |   2 +
 drivers/net/rnp/rnp_rxtx.c       | 131 ++++++++++++++++++++++++++++++-
 drivers/net/rnp/rnp_rxtx.h       |   2 +
 4 files changed, 135 insertions(+), 2 deletions(-)
doc/guides/nics/features/rnp.ini +2 -0
index 6d13370e8f..c68d6fbe2e 100644
@@ -15,5 +15,7 @@ RSS hash             = Y
 RSS key update       = Y
 RSS reta update      = Y
 Inner RSS            = Y
+Jumbo frame          = Y
+Scattered Rx         = Y
 Linux                = Y
 x86-64               = Y
doc/guides/nics/rnp.rst +2 -0
index 9fa7ad9ae9..db64104527 100644
@@ -17,6 +17,8 @@ Features
 - Promiscuous mode
 - Link state information
 - MTU update
+- Jumbo frames
+- Scatter-Gather IO support
 
 Prerequisites
 -------------
drivers/net/rnp/rnp_rxtx.c +129 -2

145 lines not on this page · raw message

drivers/net/rnp/rnp_rxtx.h +2 -0
index a8fd8d052f..973b667cb2 100644
@@ -76,6 +76,8 @@ struct rnp_rx_queue {
 	uint64_t rx_offloads; /* user set hw offload features */
 	struct rte_mbuf **free_mbufs; /* rx bulk alloc reserve of free mbufs */
 	struct rte_mbuf fake_mbuf; /* dummy mbuf */
+	struct rte_mbuf	*pkt_first_seg; /**< First segment of current packet. */
+	struct rte_mbuf *pkt_last_seg; /**< Last segment of current packet. */
 };
 
 struct rnp_txsw_entry {
Signature · 1 line
2.34.1
author
#20 lore raw

PATCH v8 18/28 net/rnp: add Tx multiple segment version

In reply to Wenbo Cao

add support multiple segs mbuf send.

---
 drivers/net/rnp/rnp_rxtx.c | 126 ++++++++++++++++++++++++++++++++++++-
 drivers/net/rnp/rnp_rxtx.h |   3 +-
 2 files changed, 126 insertions(+), 3 deletions(-)
drivers/net/rnp/rnp_rxtx.c +124 -2
index 018a861b51..96529884e1 100644
@@ -374,9 +374,11 @@ rnp_tx_queue_sw_reset(struct rnp_tx_queue *txq)
 		sw_ring[prev].next_id = idx;
 		prev = idx;
 	}
+	txq->last_desc_cleaned = txq->attr.nb_desc - 1;
 	txq->nb_tx_free = txq->attr.nb_desc - 1;
 	txq->tx_next_dd = txq->tx_rs_thresh - 1;
 	txq->tx_next_rs = txq->tx_rs_thresh - 1;
+	txq->nb_tx_used = 0;
 	txq->tx_tail = 0;
 
 	size = (txq->attr.nb_desc + RNP_TX_MAX_BURST_SIZE);
@@ -860,6 +862,7 @@ rnp_rxq_bulk_alloc(struct rnp_rx_queue *rxq,
 		rxe->mbuf = nmb;
 		rxbd->d.pkt_addr = rnp_get_dma_addr(&rxq->attr, nmb);
 	}
+	rxq->rxrearm_nb++;
 	if (rxq->rxrearm_nb > rxq->rx_free_thresh) {
 		rxq->rxrearm_nb -= rxq->rx_free_thresh;
 		rxq->rxrearm_start += rxq->rx_free_thresh;
@@ -927,7 +930,6 @@ rnp_scattered_rx(void *rx_queue, struct rte_mbuf **rx_pkts,
 			first_seg->nb_segs++;
 			last_seg->next = rxm;
 		}
-		rxq->rxrearm_nb++;
 		if (!(rx_status & rte_cpu_to_le_16(RNP_CMD_EOP))) {
 			last_seg = rxm;
 			continue;
@@ -950,6 +952,106 @@ rnp_scattered_rx(void *rx_queue, struct rte_mbuf **rx_pkts,
 	return nb_rx;
 }
 
+static __rte_always_inline uint16_t
+rnp_multiseg_clean_txq(struct rnp_tx_queue *txq)
+{
+	uint16_t last_desc_cleaned = txq->last_desc_cleaned;
+	struct rnp_txsw_entry *sw_ring = txq->sw_ring;
+	volatile struct rnp_tx_desc *txbd;
+	uint16_t desc_to_clean_to;
+	uint16_t nb_tx_to_clean;
+
+	desc_to_clean_to = (uint16_t)(last_desc_cleaned + txq->tx_rs_thresh);
+	desc_to_clean_to = desc_to_clean_to & (txq->attr.nb_desc - 1);
+
+	desc_to_clean_to = sw_ring[desc_to_clean_to].last_id;
+	txbd = &txq->tx_bdr[desc_to_clean_to];
+	if (!(txbd->d.cmd & RNP_CMD_DD))
+		return txq->nb_tx_free;
+
+	if (last_desc_cleaned > desc_to_clean_to)
+		nb_tx_to_clean = (uint16_t)((txq->attr.nb_desc -
+					last_desc_cleaned) + desc_to_clean_to);
+	else
+		nb_tx_to_clean = (uint16_t)(desc_to_clean_to -
+				last_desc_cleaned);
+
+	txbd->d.cmd = 0;
+
+	txq->last_desc_cleaned = desc_to_clean_to;
+	txq->nb_tx_free = (uint16_t)(txq->nb_tx_free + nb_tx_to_clean);
+
+	return txq->nb_tx_free;
+}
+
+static __rte_always_inline uint16_t
+rnp_multiseg_xmit_pkts(void *_txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
+{
+	struct rnp_tx_queue *txq = (struct rnp_tx_queue *)_txq;
+	volatile struct rnp_tx_desc *txbd;
+	struct rnp_txsw_entry *txe, *txn;
+	struct rte_mbuf *tx_pkt, *m_seg;
+	uint16_t send_pkts = 0;
+	uint16_t nb_used_bd;
+	uint16_t tx_last;
+	uint16_t nb_tx;
+	uint16_t tx_id;
+
+	if (unlikely(!txq->txq_started || !txq->tx_link))
+		return 0;
+	if (txq->nb_tx_free < txq->tx_free_thresh)
+		rnp_multiseg_clean_txq(txq);
+	if (unlikely(txq->nb_tx_free == 0))
+		return 0;
+	tx_id = txq->tx_tail;
+	txbd = &txq->tx_bdr[tx_id];
+	txe = &txq->sw_ring[tx_id];
+	for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
+		tx_pkt = tx_pkts[nb_tx];
+		nb_used_bd = tx_pkt->nb_segs;
+		tx_last = (uint16_t)(tx_id + nb_used_bd - 1);
+		if (tx_last >= txq->attr.nb_desc)
+			tx_last = (uint16_t)(tx_last - txq->attr.nb_desc);
+		if (nb_used_bd > txq->nb_tx_free)
+			if (nb_used_bd > rnp_multiseg_clean_txq(txq))
+				break;
+		m_seg = tx_pkt;
+		do {
+			txbd = &txq->tx_bdr[tx_id];
+			txn = &txq->sw_ring[txe->next_id];
+			if (txe->mbuf) {
+				rte_pktmbuf_free_seg(txe->mbuf);
+				txe->mbuf = NULL;
+			}
+			txe->mbuf = m_seg;
+			txe->last_id = tx_last;
+			txbd->d.addr = rnp_get_dma_addr(&txq->attr, m_seg);
+			txbd->d.blen = rte_cpu_to_le_32(m_seg->data_len);
+			txbd->d.cmd &= ~RNP_CMD_EOP;
+			txbd->d.cmd |= RNP_DATA_DESC;
+			m_seg = m_seg->next;
+			tx_id = txe->next_id;
+			txe = txn;
+		} while (m_seg != NULL);
+		txbd->d.cmd |= RNP_CMD_EOP;
+		txq->nb_tx_used = (uint16_t)txq->nb_tx_used + nb_used_bd;
+		txq->nb_tx_free = (uint16_t)txq->nb_tx_free - nb_used_bd;
+		if (txq->nb_tx_used >= txq->tx_rs_thresh) {
+			txq->nb_tx_used = 0;
+			txbd->d.cmd |= RNP_CMD_RS;
+		}
+		send_pkts++;
+	}
+	if (!send_pkts)
+		return 0;
+	txq->tx_tail = tx_id;
+
+	rte_wmb();
+	RNP_REG_WR(txq->tx_tailreg, 0, tx_id);
+
+	return send_pkts;
+}
+
 static int
 rnp_check_rx_simple_valid(struct rte_eth_dev *dev)
 {
@@ -973,9 +1075,29 @@ int rnp_rx_func_select(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+rnp_check_tx_simple_valid(struct rte_eth_dev *dev, struct rnp_tx_queue *txq)
+{
+	RTE_SET_USED(txq);
+	if (dev->data->scattered_rx)
+		return -ENOTSUP;
+	return 0;
+}
+
 int rnp_tx_func_select(struct rte_eth_dev *dev)
 {
-	dev->tx_pkt_burst = rnp_xmit_simple;
+	bool simple_allowed = false;
+	struct rnp_tx_queue *txq;
+	int idx = 0;
+
+	for (idx = 0; idx < dev->data->nb_tx_queues; idx++) {
+		txq = dev->data->tx_queues[idx];
+		simple_allowed = rnp_check_tx_simple_valid(dev, txq) == 0;
+	}
+	if (simple_allowed)
+		dev->tx_pkt_burst = rnp_xmit_simple;
+	else
+		dev->tx_pkt_burst = rnp_multiseg_xmit_pkts;
 	dev->tx_pkt_prepare = rte_eth_pkt_burst_dummy;
 
 	return 0;
drivers/net/rnp/rnp_rxtx.h +2 -1
index 973b667cb2..f63128555b 100644
@@ -98,7 +98,8 @@ struct rnp_tx_queue {
 	struct rnp_queue_attr attr;
 
 	uint16_t nb_tx_free; /* avail desc to set pkts */
-	uint16_t nb_tx_used;
+	uint16_t nb_tx_used; /* multiseg mbuf used num */
+	uint16_t last_desc_cleaned;
 	uint16_t tx_tail;
 
 	uint16_t tx_next_dd; /* next to scan writeback dd bit */
Signature · 1 line
2.34.1
author
#21 lore raw

PATCH v8 19/28 net/rnp: add support basic stats operation

In reply to Wenbo Cao

add support hw-missed rx/tx packets bytes.

---
 doc/guides/nics/features/rnp.ini    |   2 +
 doc/guides/nics/rnp.rst             |   1 +
 drivers/net/rnp/base/rnp_eth_regs.h |   3 +
 drivers/net/rnp/rnp.h               |  10 +-
 drivers/net/rnp/rnp_ethdev.c        | 147 ++++++++++++++++++++++++++++
 drivers/net/rnp/rnp_rxtx.c          |   9 ++
 drivers/net/rnp/rnp_rxtx.h          |  10 ++
 7 files changed, 181 insertions(+), 1 deletion(-)
doc/guides/nics/features/rnp.ini +2 -0
index c68d6fbe2e..45dae3ba14 100644
@@ -7,6 +7,8 @@
 Speed capabilities   = Y
 Link status          = Y
 Link status event    = Y
+Basic stats          = Y
+Stats per queue      = Y
 Queue start/stop     = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
doc/guides/nics/rnp.rst +1 -0
index db64104527..ec6f3f9dbb 100644
@@ -19,6 +19,7 @@ Features
 - MTU update
 - Jumbo frames
 - Scatter-Gather IO support
+- Port hardware statistic
 
 Prerequisites
 -------------
drivers/net/rnp/base/rnp_eth_regs.h +3 -0
index 91a18dd42d..391688bd80 100644
@@ -23,6 +23,9 @@
 #define RNP_RX_FC_ENABLE	_ETH_(0x8520)
 #define RNP_RING_FC_EN(n)	_ETH_(0x8524 + ((0x4) * ((n) / 32)))
 #define RNP_RING_FC_THRESH(n)	_ETH_(0x8a00 + ((0x4) * (n)))
+/* ETH Statistic */
+#define RNP_ETH_RXTRANS_DROP	_ETH_(0x8904)
+#define RNP_ETH_RXTRUNC_DROP	_ETH_(0x8928)
 /* Mac Host Filter  */
 #define RNP_MAC_FCTRL		_ETH_(0x9110)
 #define RNP_MAC_FCTRL_MPE	RTE_BIT32(8)  /* Multicast Promiscuous En */
drivers/net/rnp/rnp.h +9 -1
index 7ed20521c5..bd2eb8caff 100644
@@ -10,7 +10,7 @@
 #include "base/rnp_hw.h"
 
 #define PCI_VENDOR_ID_MUCSE	(0x8848)
-#define RNP_DEV_ID_N10G		(0x1000)
+#define RNP_DEV_ID_N10G		(0x1020)
 #define RNP_MAX_VF_NUM		(64)
 #define RNP_MISC_VEC_ID		RTE_INTR_VEC_ZERO_OFFSET
 /* maximum frame size supported */
@@ -105,6 +105,11 @@ struct rnp_proc_priv {
 	const struct rnp_mbx_ops *mbx_ops;
 };
 
+struct rnp_hw_eth_stats {
+	uint64_t rx_trans_drop;         /* rx eth to dma fifo full drop */
+	uint64_t rx_trunc_drop;         /* rx mac to eth to host copy fifo full drop */
+};
+
 struct rnp_eth_port {
 	struct rnp_proc_priv *proc_priv;
 	struct rte_ether_addr mac_addr;
@@ -113,6 +118,9 @@ struct rnp_eth_port {
 	struct rnp_tx_queue *tx_queues[RNP_MAX_RX_QUEUE_NUM];
 	struct rnp_hw *hw;
 
+	struct rnp_hw_eth_stats eth_stats_old;
+	struct rnp_hw_eth_stats eth_stats;
+
 	struct rte_eth_rss_conf rss_conf;
 	uint16_t last_rx_num;
 	bool rxq_num_changed;
drivers/net/rnp/rnp_ethdev.c +147 -0

159 lines not on this page · raw message

drivers/net/rnp/rnp_rxtx.c +9 -0
index 96529884e1..bce16334ac 100644
@@ -741,6 +741,8 @@ rnp_recv_pkts(void *_rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 			nmb->packet_type = 0;
 			nmb->ol_flags = 0;
 			nmb->nb_segs = 1;
+
+			rxq->stats.ibytes += nmb->data_len;
 		}
 		for (j = 0; j < nb_dd; ++j) {
 			rx_pkts[i + j] = rx_swbd[j].mbuf;
@@ -752,6 +754,7 @@ rnp_recv_pkts(void *_rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 		if (nb_dd != RNP_CACHE_FETCH_RX)
 			break;
 	}
+	rxq->stats.ipackets += nb_rx;
 	rxq->rx_tail = (rxq->rx_tail + nb_rx) & rxq->attr.nb_desc_mask;
 	rxq->rxrearm_nb = rxq->rxrearm_nb + nb_rx;
 
@@ -821,6 +824,7 @@ rnp_xmit_simple(void *_txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 		txbd->d.blen = tx_swbd->mbuf->data_len;
 		txbd->d.cmd = RNP_CMD_EOP;
 
+		txq->stats.obytes += txbd->d.blen;
 		i = (i + 1) & txq->attr.nb_desc_mask;
 	}
 	txq->nb_tx_free -= start;
@@ -832,6 +836,7 @@ rnp_xmit_simple(void *_txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 		if (txq->tx_next_rs > txq->attr.nb_desc)
 			txq->tx_next_rs = txq->tx_rs_thresh - 1;
 	}
+	txq->stats.opackets += start;
 	txq->tx_tail = i;
 
 	rte_wmb();
@@ -936,6 +941,7 @@ rnp_scattered_rx(void *rx_queue, struct rte_mbuf **rx_pkts,
 		}
 		rxm->next = NULL;
 		first_seg->port = rxq->attr.port_id;
+		rxq->stats.ibytes += first_seg->pkt_len;
 		/* this the end of packet the large pkt has been recv finish */
 		rte_prefetch0(RTE_PTR_ADD(first_seg->buf_addr,
 					first_seg->data_off));
@@ -944,6 +950,7 @@ rnp_scattered_rx(void *rx_queue, struct rte_mbuf **rx_pkts,
 	}
 	if (!nb_rx)
 		return 0;
+	rxq->stats.ipackets += nb_rx;
 	/* update sw record point */
 	rxq->rx_tail = rx_id;
 	rxq->pkt_first_seg = first_seg;
@@ -1033,6 +1040,7 @@ rnp_multiseg_xmit_pkts(void *_txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 			tx_id = txe->next_id;
 			txe = txn;
 		} while (m_seg != NULL);
+		txq->stats.obytes += tx_pkt->pkt_len;
 		txbd->d.cmd |= RNP_CMD_EOP;
 		txq->nb_tx_used = (uint16_t)txq->nb_tx_used + nb_used_bd;
 		txq->nb_tx_free = (uint16_t)txq->nb_tx_free - nb_used_bd;
@@ -1044,6 +1052,7 @@ rnp_multiseg_xmit_pkts(void *_txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 	}
 	if (!send_pkts)
 		return 0;
+	txq->stats.opackets += send_pkts;
 	txq->tx_tail = tx_id;
 
 	rte_wmb();
drivers/net/rnp/rnp_rxtx.h +10 -0
index f63128555b..d26497a263 100644
@@ -47,6 +47,14 @@ struct rnp_rxsw_entry {
 	struct rte_mbuf *mbuf;
 };
 
+struct rnp_queue_stats {
+	uint64_t obytes;
+	uint64_t opackets;
+
+	uint64_t ibytes;
+	uint64_t ipackets;
+};
+
 struct rnp_rx_queue {
 	struct rte_mempool *mb_pool; /* mbuf pool to populate rx ring. */
 	const struct rte_memzone *rz; /* rx hw ring base alloc memzone */
@@ -73,6 +81,7 @@ struct rnp_rx_queue {
 	uint8_t pthresh; /* rx desc prefetch threshold */
 	uint8_t pburst; /* rx desc prefetch burst */
 
+	struct rnp_queue_stats stats;
 	uint64_t rx_offloads; /* user set hw offload features */
 	struct rte_mbuf **free_mbufs; /* rx bulk alloc reserve of free mbufs */
 	struct rte_mbuf fake_mbuf; /* dummy mbuf */
@@ -113,6 +122,7 @@ struct rnp_tx_queue {
 	uint8_t pthresh; /* rx desc prefetch threshold */
 	uint8_t pburst; /* rx desc burst*/
 
+	struct rnp_queue_stats stats;
 	uint64_t tx_offloads; /* tx offload features */
 	struct rte_mbuf **free_mbufs; /* tx bulk free reserve of free mbufs */
 };
Signature · 1 line
2.34.1
author
#22 lore raw

PATCH v8 20/28 net/rnp: add support xstats operation

In reply to Wenbo Cao

add support mac eth rx tx hw xstats.

---
 doc/guides/nics/features/rnp.ini    |   1 +
 drivers/net/rnp/base/rnp_eth_regs.h |   3 +
 drivers/net/rnp/base/rnp_mac_regs.h |  80 +++++++++
 drivers/net/rnp/rnp.h               |  51 ++++++
 drivers/net/rnp/rnp_ethdev.c        | 243 ++++++++++++++++++++++++++++
 5 files changed, 378 insertions(+)
doc/guides/nics/features/rnp.ini +1 -0
index 45dae3ba14..c782efe2fb 100644
@@ -9,6 +9,7 @@ Link status          = Y
 Link status event    = Y
 Basic stats          = Y
 Stats per queue      = Y
+Extended stats       = Y
 Queue start/stop     = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
drivers/net/rnp/base/rnp_eth_regs.h +3 -0
index 391688bd80..ada42be8e9 100644
@@ -25,6 +25,9 @@
 #define RNP_RING_FC_THRESH(n)	_ETH_(0x8a00 + ((0x4) * (n)))
 /* ETH Statistic */
 #define RNP_ETH_RXTRANS_DROP	_ETH_(0x8904)
+#define RNP_ETH_RXGLAN_DROP	_ETH_(0x8918)
+#define RNP_ETH_RXIPH_E_DROP	_ETH_(0x891c)
+#define RNP_ETH_RXCKSUM_E_DROP	_ETH_(0x8920)
 #define RNP_ETH_RXTRUNC_DROP	_ETH_(0x8928)
 /* Mac Host Filter  */
 #define RNP_MAC_FCTRL		_ETH_(0x9110)
drivers/net/rnp/base/rnp_mac_regs.h +80 -0

84 lines not on this page · raw message

drivers/net/rnp/rnp.h +51 -0

63 lines not on this page · raw message

drivers/net/rnp/rnp_ethdev.c +243 -0

284 lines not on this page · raw message

Signature · 1 line
2.34.1
author
#23 lore raw

PATCH v8 21/28 net/rnp: add unicast MAC filter operation

In reply to Wenbo Cao

add mac filter for single/multiple port.

---
 doc/guides/nics/features/rnp.ini    |  1 +
 doc/guides/nics/rnp.rst             |  1 +
 drivers/net/rnp/base/rnp_eth_regs.h |  4 ++
 drivers/net/rnp/base/rnp_hw.h       |  3 +
 drivers/net/rnp/base/rnp_mac.c      | 91 +++++++++++++++++++++++++++++
 drivers/net/rnp/base/rnp_mac.h      |  2 +
 drivers/net/rnp/base/rnp_mac_regs.h |  5 +-
 drivers/net/rnp/rnp.h               |  4 ++
 drivers/net/rnp/rnp_ethdev.c        | 61 +++++++++++++++++--
 9 files changed, 166 insertions(+), 6 deletions(-)
doc/guides/nics/features/rnp.ini +1 -0
index c782efe2fb..de7e72c023 100644
@@ -14,6 +14,7 @@ Queue start/stop     = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
 MTU update           = Y
+Unicast MAC filter   = Y
 RSS hash             = Y
 RSS key update       = Y
 RSS reta update      = Y
doc/guides/nics/rnp.rst +1 -0
index ec6f3f9dbb..3315ff7f53 100644
@@ -17,6 +17,7 @@ Features
 - Promiscuous mode
 - Link state information
 - MTU update
+- MAC filtering
 - Jumbo frames
 - Scatter-Gather IO support
 - Port hardware statistic
drivers/net/rnp/base/rnp_eth_regs.h +4 -0
index ada42be8e9..8a448b9eec 100644
@@ -63,5 +63,9 @@
 #define RNP_RSS_KEY_TABLE(idx)	_ETH_(0x92d0 + ((idx) * 0x4))
 
 #define RNP_TC_PORT_OFFSET(lane)	_ETH_(0xe840 + 0x04 * (lane))
+/* host mac address filter */
+#define RNP_RAL_BASE_ADDR(n)	_ETH_(0xA000 + (0x04 * (n)))
+#define RNP_RAH_BASE_ADDR(n)	_ETH_(0xA400 + (0x04 * (n)))
+#define RNP_MAC_FILTER_EN	RTE_BIT32(31)
 
 #endif /* _RNP_ETH_REGS_H */
drivers/net/rnp/base/rnp_hw.h +3 -0
index 0ec536e488..73fe34ad4e 100644
@@ -71,6 +71,9 @@ struct rnp_mac_ops {
 	int (*get_macaddr)(struct rnp_eth_port *port, u8 *mac);
 	/* update mac packet filter mode */
 	int (*update_mpfm)(struct rnp_eth_port *port, u32 mode, bool en);
+	/* Receive Address Filter table */
+	int (*set_rafb)(struct rnp_eth_port *port, u8 *mac, u32 index);
+	int (*clear_rafb)(struct rnp_eth_port *port, u32 index);
 };
 
 struct rnp_eth_adapter;
drivers/net/rnp/base/rnp_mac.c +91 -0

111 lines not on this page · raw message

drivers/net/rnp/base/rnp_mac.h +2 -0
index 1dac903396..865fc348df 100644
@@ -24,6 +24,8 @@
 
 void rnp_mac_ops_init(struct rnp_hw *hw);
 int rnp_get_mac_addr(struct rnp_eth_port *port, u8 *mac);
+int rnp_set_macaddr(struct rnp_eth_port *port, u8 *mac, u32 index);
+int rnp_clear_macaddr(struct rnp_eth_port *port, u32 index);
 int rnp_update_mpfm(struct rnp_eth_port *port,
 		    u32 mode, bool en);
 
drivers/net/rnp/base/rnp_mac_regs.h +4 -1
index 94aeba9d6c..85308a749e 100644
@@ -77,7 +77,10 @@
 #define RNP_MAC_PLSDIS		RTE_BIT32(18)
 /* PHY Link Status */
 #define RNP_MAC_PLS		RTE_BIT32(17)
-
+/* Rx macaddr filter ctrl */
+#define RNP_MAC_ADDR_HI(n)	(0x0300 + ((n) * 0x8))
+#define RNP_MAC_AE		RTE_BIT32(31)
+#define RNP_MAC_ADDR_LO(n)	(0x0304 + ((n) * 0x8))
 /* Mac Manage Counts */
 #define RNP_MMC_CTRL		(0x0800)
 #define RNP_MMC_RSTONRD	RTE_BIT32(2)
drivers/net/rnp/rnp.h +4 -0
index 8ef0658d67..af930800c6 100644
@@ -56,6 +56,10 @@
 #define RNP_MAX_HASH_MC_MAC_SIZE	(4096)	/* max multicast hash mac num */
 #define RNP_MAX_UC_HASH_TABLE		(128)	/* max unicast hash mac filter table */
 #define RNP_MAC_MC_HASH_TABLE		(128)	/* max multicast hash mac filter table*/
+/* Peer port own independent resource */
+#define RNP_PORT_MAX_MACADDR         (32)
+#define RNP_PORT_MAX_UC_HASH_TB      (8)
+#define RNP_PORT_MAX_UC_MAC_SIZE     (RNP_PORT_MAX_UC_HASH_TB * 32)
 /* hardware media type */
 enum rnp_media_type {
 	RNP_MEDIA_TYPE_UNKNOWN,
drivers/net/rnp/rnp_ethdev.c +56 -5

85 lines not on this page · raw message

Signature · 1 line
2.34.1
author
#24 lore raw

PATCH v8 22/28 net/rnp: add supported packet types

In reply to Wenbo Cao

add support parse hw packet types result.

---
 doc/guides/nics/features/rnp.ini  |  1 +
 doc/guides/nics/rnp.rst           |  1 +
 drivers/net/rnp/base/rnp_bdq_if.h |  4 +++
 drivers/net/rnp/rnp_rxtx.c        | 45 +++++++++++++++++++++++++++++++
 4 files changed, 51 insertions(+)
doc/guides/nics/features/rnp.ini +1 -0
index de7e72c023..b81f11d904 100644
@@ -7,6 +7,7 @@
 Speed capabilities   = Y
 Link status          = Y
 Link status event    = Y
+Packet type parsing  = Y
 Basic stats          = Y
 Stats per queue      = Y
 Extended stats       = Y
doc/guides/nics/rnp.rst +1 -0
index 3315ff7f53..39ea2d1636 100644
@@ -21,6 +21,7 @@ Features
 - Jumbo frames
 - Scatter-Gather IO support
 - Port hardware statistic
+- Packet type parsing
 
 Prerequisites
 -------------
drivers/net/rnp/base/rnp_bdq_if.h +4 -0
index 61a38323e5..a7d27bdebb 100644
@@ -73,6 +73,7 @@ struct rnp_tx_desc {
 #define RNP_RX_L3TYPE_IPV4	(0x00UL << RNP_RX_L3TYPE_S)
 #define RNP_RX_L3TYPE_IPV6	(0x01UL << RNP_RX_L3TYPE_S)
 #define RNP_RX_L4TYPE_S		(6)
+#define RNP_RX_L4TYPE_MASK	RTE_GENMASK32(7, 6)
 #define RNP_RX_L4TYPE_TCP	(0x01UL << RNP_RX_L4TYPE_S)
 #define RNP_RX_L4TYPE_SCTP	(0x02UL << RNP_RX_L4TYPE_S)
 #define RNP_RX_L4TYPE_UDP	(0x03UL << RNP_RX_L4TYPE_S)
@@ -83,9 +84,12 @@ struct rnp_tx_desc {
 #define RNP_RX_IN_L3_ERR	RTE_BIT32(11)
 #define RNP_RX_IN_L4_ERR	RTE_BIT32(12)
 #define RNP_RX_TUNNEL_TYPE_S	(13)
+#define RNP_RX_TUNNEL_MASK	RTE_GENMASK32(14, 13)
 #define RNP_RX_PTYPE_VXLAN	(0x01UL << RNP_RX_TUNNEL_TYPE_S)
 #define RNP_RX_PTYPE_NVGRE	(0x02UL << RNP_RX_TUNNEL_TYPE_S)
 #define RNP_RX_PTYPE_VLAN	RTE_BIT32(15)
+/* mark_data */
+#define RNP_RX_L3TYPE_VALID	RTE_BIT32(31)
 /* tx data cmd */
 #define RNP_TX_TSO_EN		RTE_BIT32(4)
 #define RNP_TX_L3TYPE_S		(5)
drivers/net/rnp/rnp_rxtx.c +45 -0

63 lines not on this page · raw message

Signature · 1 line
2.34.1
author
#25 lore raw

PATCH v8 23/28 net/rnp: add support Rx checksum offload

In reply to Wenbo Cao

Add support Rx l3/l4 checum and tunnel
inner l3/l4, out l3 chksum.

---
 doc/guides/nics/features/rnp.ini    |  4 ++
 doc/guides/nics/rnp.rst             |  1 +
 drivers/net/rnp/base/rnp_eth_regs.h | 13 ++++
 drivers/net/rnp/rnp.h               |  7 +++
 drivers/net/rnp/rnp_ethdev.c        | 65 ++++++++++++++++++-
 drivers/net/rnp/rnp_rxtx.c          | 97 ++++++++++++++++++++++++++++-
 6 files changed, 185 insertions(+), 2 deletions(-)
doc/guides/nics/features/rnp.ini +4 -0
index b81f11d904..7e97da9325 100644
@@ -8,6 +8,10 @@ Speed capabilities   = Y
 Link status          = Y
 Link status event    = Y
 Packet type parsing  = Y
+L3 checksum offload  = P
+L4 checksum offload  = P
+Inner L3 checksum    = P
+Inner L4 checksum    = P
 Basic stats          = Y
 Stats per queue      = Y
 Extended stats       = Y
doc/guides/nics/rnp.rst +1 -0
index 39ea2d1636..8f667a481e 100644
@@ -22,6 +22,7 @@ Features
 - Scatter-Gather IO support
 - Port hardware statistic
 - Packet type parsing
+- Checksum offload
 
 Prerequisites
 -------------
drivers/net/rnp/base/rnp_eth_regs.h +13 -0
index 8a448b9eec..b0961a1459 100644
@@ -16,6 +16,19 @@
 #define RNP_RX_ETH_F_CTRL(n)	_ETH_(0x8070 + ((n) * 0x8))
 #define RNP_RX_ETH_F_OFF	(0x7ff)
 #define RNP_RX_ETH_F_ON		(0x270)
+/* rx checksum ctrl */
+#define RNP_HW_SCTP_CKSUM_CTRL		_ETH_(0x8038)
+#define RNP_HW_CHECK_ERR_CTRL		_ETH_(0x8060)
+#define RNP_HW_ERR_HDR_LEN		RTE_BIT32(0)
+#define RNP_HW_ERR_PKTLEN		RTE_BIT32(1)
+#define RNP_HW_L3_CKSUM_ERR		RTE_BIT32(2)
+#define RNP_HW_L4_CKSUM_ERR		RTE_BIT32(3)
+#define RNP_HW_SCTP_CKSUM_ERR		RTE_BIT32(4)
+#define RNP_HW_INNER_L3_CKSUM_ERR	RTE_BIT32(5)
+#define RNP_HW_INNER_L4_CKSUM_ERR	RTE_BIT32(6)
+#define RNP_HW_CKSUM_ERR_MASK		RTE_GENMASK32(6, 2)
+#define RNP_HW_CHECK_ERR_MASK		RTE_GENMASK32(6, 0)
+#define RNP_HW_ERR_RX_ALL_MASK		RTE_GENMASK32(1, 0)
 /* max/min pkts length receive limit ctrl */
 #define RNP_MIN_FRAME_CTRL	_ETH_(0x80f0)
 #define RNP_MAX_FRAME_CTRL	_ETH_(0x80f4)
drivers/net/rnp/rnp.h +7 -0
index af930800c6..9cfc17b93c 100644
@@ -42,6 +42,13 @@
 		RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
 		RTE_ETH_RSS_IPV6_UDP_EX | \
 		RTE_ETH_RSS_NONFRAG_IPV6_SCTP)
+/* rx checksum offload */
+#define RNP_RX_CHECKSUM_SUPPORT ( \
+		RTE_ETH_RX_OFFLOAD_IPV4_CKSUM | \
+		RTE_ETH_RX_OFFLOAD_UDP_CKSUM | \
+		RTE_ETH_RX_OFFLOAD_TCP_CKSUM | \
+		RTE_ETH_RX_OFFLOAD_SCTP_CKSUM | \
+		RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM)
 /* Ring info special */
 #define RNP_MAX_BD_COUNT	(4096)
 #define RNP_MIN_BD_COUNT	(128)
drivers/net/rnp/rnp_ethdev.c +64 -1

83 lines not on this page · raw message

drivers/net/rnp/rnp_rxtx.c +96 -1

110 lines not on this page · raw message

Signature · 1 line
2.34.1
author
#26 lore raw

PATCH v8 24/28 net/rnp: add support Tx TSO offload

In reply to Wenbo Cao

Add support tx tso and tunnel tso.
for tunnel just support vxlan/nvgre

---
 drivers/net/rnp/base/rnp_bdq_if.h |   1 +
 drivers/net/rnp/rnp.h             |   2 +-
 drivers/net/rnp/rnp_ethdev.c      |  16 ++
 drivers/net/rnp/rnp_rxtx.c        | 457 +++++++++++++++++++++++++++++-
 drivers/net/rnp/rnp_rxtx.h        |   1 +
 5 files changed, 471 insertions(+), 6 deletions(-)
drivers/net/rnp/base/rnp_bdq_if.h +1 -0
index a7d27bdebb..7a6d0b21ec 100644
@@ -111,6 +111,7 @@ struct rnp_tx_desc {
 #define RNP_TX_VLAN_VALID	RTE_BIT32(15)
 /* tx data mac_ip len */
 #define RNP_TX_MAC_LEN_S	(9)
+#define RNP_TX_MAC_LEN_MASK	RTE_GENMASK32(15, 9)
 /* tx ctrl cmd */
 #define RNP_TX_LEN_PAD_S	(8)
 #define RNP_TX_OFF_MAC_PAD	(0x01UL << RNP_TX_LEN_PAD_S)
drivers/net/rnp/rnp.h +1 -1
index 9cfc17b93c..5eb0676f11 100644
@@ -17,7 +17,7 @@
 #define RNP_ETH_OVERHEAD \
 	(RTE_ETHER_HDR_LEN + RTE_VLAN_HLEN * 2)
 #define RNP_MAC_MAXFRM_SIZE	(9590)
-
+#define RNP_MAX_TSO_PKT		(16 * 1024)
 #define RNP_RX_MAX_MTU_SEG	(64)
 #define RNP_TX_MAX_MTU_SEG	(32)
 #define RNP_RX_MAX_SEG		(150)
drivers/net/rnp/rnp_ethdev.c +16 -0
index b5d749e7a5..c43ffbe0c3 100644
@@ -651,6 +651,17 @@ static int rnp_dev_infos_get(struct rte_eth_dev *eth_dev,
 	dev_info->speed_capa = rnp_get_speed_caps(eth_dev);
 	/* rx support offload cap */
 	dev_info->rx_offload_capa = RNP_RX_CHECKSUM_SUPPORT;
+	/* tx support offload cap */
+	dev_info->tx_offload_capa = 0 |
+				     RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
+				     RTE_ETH_TX_OFFLOAD_UDP_CKSUM |
+				     RTE_ETH_TX_OFFLOAD_TCP_CKSUM |
+				     RTE_ETH_TX_OFFLOAD_SCTP_CKSUM |
+				     RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM |
+				     RTE_ETH_TX_OFFLOAD_TCP_TSO |
+				     RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
+				     RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
+				     RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
 	dev_info->default_rxconf = (struct rte_eth_rxconf) {
 		.rx_drop_en = 0,
 		.rx_thresh = {
@@ -1084,13 +1095,18 @@ rnp_dev_stats_get(struct rte_eth_dev *dev,
 					(data->tx_queues))[i]->stats.opackets;
 			stats->q_obytes[i] = ((struct rnp_tx_queue **)
 					(data->tx_queues))[i]->stats.obytes;
+			stats->oerrors += ((struct rnp_tx_queue **)
+					(data->tx_queues))[i]->stats.errors;
 			stats->opackets += stats->q_opackets[i];
 			stats->obytes += stats->q_obytes[i];
+
 		} else {
 			stats->opackets += ((struct rnp_tx_queue **)
 					(data->tx_queues))[i]->stats.opackets;
 			stats->obytes += ((struct rnp_tx_queue **)
 					(data->tx_queues))[i]->stats.obytes;
+			stats->oerrors += ((struct rnp_tx_queue **)
+					(data->tx_queues))[i]->stats.errors;
 		}
 	}
 	stats->imissed = eth_stats->rx_trans_drop + eth_stats->rx_trunc_drop;
drivers/net/rnp/rnp_rxtx.c +452 -5

507 lines not on this page · raw message

drivers/net/rnp/rnp_rxtx.h +1 -0
index d26497a263..51e5d4b600 100644
@@ -53,6 +53,7 @@ struct rnp_queue_stats {
 
 	uint64_t ibytes;
 	uint64_t ipackets;
+	uint64_t errors;
 };
 
 struct rnp_rx_queue {
Signature · 1 line
2.34.1
author
#27 lore raw

PATCH v8 25/28 net/rnp: support VLAN offloads.

In reply to Wenbo Cao

add support rx vlan strip,filter, tx vlan/qinq insert.

---
 doc/guides/nics/features/rnp.ini    |   2 +
 doc/guides/nics/rnp.rst             |   1 +
 drivers/net/rnp/base/rnp_bdq_if.h   |   2 +-
 drivers/net/rnp/base/rnp_eth_regs.h |   5 +
 drivers/net/rnp/base/rnp_hw.h       |   2 +
 drivers/net/rnp/base/rnp_mac.c      |  53 ++++++++-
 drivers/net/rnp/base/rnp_mac.h      |   1 +
 drivers/net/rnp/base/rnp_mac_regs.h |  41 ++++++-
 drivers/net/rnp/rnp.h               |   7 ++
 drivers/net/rnp/rnp_ethdev.c        | 177 +++++++++++++++++++++++++++-
 drivers/net/rnp/rnp_rxtx.c          |  22 +++-
 11 files changed, 306 insertions(+), 7 deletions(-)
doc/guides/nics/features/rnp.ini +2 -0
index 7e97da9325..18ec4bc8d4 100644
@@ -20,6 +20,8 @@ Promiscuous mode     = Y
 Allmulticast mode    = Y
 MTU update           = Y
 Unicast MAC filter   = Y
+VLAN offload         = Y
+QinQ offload         = Y
 RSS hash             = Y
 RSS key update       = Y
 RSS reta update      = Y
doc/guides/nics/rnp.rst +1 -0
index 8f667a481e..febdaf84d3 100644
@@ -23,6 +23,7 @@ Features
 - Port hardware statistic
 - Packet type parsing
 - Checksum offload
+- VLAN stripping and VLAN/QINQ insertion
 
 Prerequisites
 -------------
drivers/net/rnp/base/rnp_bdq_if.h +1 -1
index 7a6d0b21ec..182a8a715d 100644
@@ -87,7 +87,7 @@ struct rnp_tx_desc {
 #define RNP_RX_TUNNEL_MASK	RTE_GENMASK32(14, 13)
 #define RNP_RX_PTYPE_VXLAN	(0x01UL << RNP_RX_TUNNEL_TYPE_S)
 #define RNP_RX_PTYPE_NVGRE	(0x02UL << RNP_RX_TUNNEL_TYPE_S)
-#define RNP_RX_PTYPE_VLAN	RTE_BIT32(15)
+#define RNP_RX_STRIP_VLAN	RTE_BIT32(15)
 /* mark_data */
 #define RNP_RX_L3TYPE_VALID	RTE_BIT32(31)
 /* tx data cmd */
drivers/net/rnp/base/rnp_eth_regs.h +5 -0
index b0961a1459..802a127b1a 100644
@@ -56,6 +56,11 @@
 #define RNP_MAC_HASH_MASK		RTE_GENMASK32(11, 0)
 #define RNP_MAC_MULTICASE_TBL_EN	RTE_BIT32(2)
 #define RNP_MAC_UNICASE_TBL_EN		RTE_BIT32(3)
+/* vlan strip ctrl */
+#define RNP_VLAN_Q_STRIP_CTRL(n)	_ETH_(0x8040 + 0x4 * ((n) / 32))
+/* vlan filter ctrl */
+#define RNP_VLAN_FILTER_CTRL	_ETH_(0x9118)
+#define RNP_VLAN_FILTER_EN	RTE_BIT32(30)
 /* rss function ctrl */
 #define RNP_RSS_INNER_CTRL	_ETH_(0x805c)
 #define RNP_INNER_RSS_EN	(1)
drivers/net/rnp/base/rnp_hw.h +2 -0
index 73fe34ad4e..b0c599d22e 100644
@@ -74,6 +74,8 @@ struct rnp_mac_ops {
 	/* Receive Address Filter table */
 	int (*set_rafb)(struct rnp_eth_port *port, u8 *mac, u32 index);
 	int (*clear_rafb)(struct rnp_eth_port *port, u32 index);
+	/* receive vlan filter */
+	int (*vlan_f_en)(struct rnp_eth_port *port, bool en);
 };
 
 struct rnp_eth_adapter;
drivers/net/rnp/base/rnp_mac.c +52 -1

75 lines not on this page · raw message

drivers/net/rnp/base/rnp_mac.h +1 -0
index 865fc348df..4a5206ded3 100644
@@ -28,5 +28,6 @@ int rnp_set_macaddr(struct rnp_eth_port *port, u8 *mac, u32 index);
 int rnp_clear_macaddr(struct rnp_eth_port *port, u32 index);
 int rnp_update_mpfm(struct rnp_eth_port *port,
 		    u32 mode, bool en);
+int rnp_rx_vlan_filter_en(struct rnp_eth_port *port, bool en);
 
 #endif /* _RNP_MAC_H_ */
drivers/net/rnp/base/rnp_mac_regs.h +39 -2

47 lines not on this page · raw message

drivers/net/rnp/rnp.h +7 -0
index 5eb0676f11..12b2850ae3 100644
@@ -171,6 +171,11 @@ struct rnp_hw_mac_stats {
 	uint64_t tx_bad_pkts;
 };
 
+enum rnp_vlan_type {
+	RNP_CVLAN_TYPE = 0,
+	RNP_SVLAN_TYPE = 1,
+};
+
 struct rnp_eth_port {
 	struct rnp_proc_priv *proc_priv;
 	struct rte_ether_addr mac_addr;
@@ -193,6 +198,8 @@ struct rnp_eth_port {
 	uint16_t cur_mtu;
 	bool jumbo_en;
 
+	enum rnp_vlan_type outvlan_type;
+	enum rnp_vlan_type invlan_type;
 	rte_spinlock_t rx_mac_lock;
 	bool port_stopped;
 };
drivers/net/rnp/rnp_ethdev.c +175 -2

218 lines not on this page · raw message

drivers/net/rnp/rnp_rxtx.c +21 -1
index 209bd3690d..6498b012ca 100644
@@ -721,6 +721,7 @@ rnp_dev_rx_offload(struct rnp_rx_queue *rxq,
 		   volatile struct rnp_rx_desc rxbd)
 {
 	uint32_t rss = rte_le_to_cpu_32(rxbd.wb.qword0.rss_hash);
+	uint16_t vlan_tci = rxbd.wb.qword1.vlan_tci;
 	uint16_t cmd = rxbd.wb.qword1.cmd;
 
 	if (rxq->rx_offloads & RNP_RX_CHECKSUM_SUPPORT) {
@@ -736,6 +737,13 @@ rnp_dev_rx_offload(struct rnp_rx_queue *rxq,
 		m->hash.rss = rss;
 		m->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
 	}
+	if (rxq->rx_offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP) {
+		if (vlan_tci && cmd & RNP_RX_STRIP_VLAN) {
+			m->ol_flags |= RTE_MBUF_F_RX_VLAN |
+				RTE_MBUF_F_RX_VLAN_STRIPPED;
+			m->vlan_tci = vlan_tci;
+		}
+	}
 }
 
 static __rte_always_inline void
@@ -1149,7 +1157,8 @@ rnp_need_ctrl_desc(uint64_t flags)
 	static uint64_t mask = RTE_MBUF_F_TX_OUTER_IP_CKSUM |
 			       RTE_MBUF_F_TX_TCP_SEG |
 			       RTE_MBUF_F_TX_TUNNEL_VXLAN |
-			       RTE_MBUF_F_TX_TUNNEL_GRE;
+			       RTE_MBUF_F_TX_TUNNEL_GRE |
+			       RTE_MBUF_F_TX_QINQ;
 	return (flags & mask) ? 1 : 0;
 }
 
@@ -1176,6 +1185,10 @@ rnp_build_tx_control_desc(struct rnp_tx_queue *txq,
 		txbd->c.qword0.mss = rnp_cal_tso_seg(mbuf);
 		txbd->c.qword0.l4_len = mbuf->l4_len;
 	}
+	if (flags & RTE_MBUF_F_TX_QINQ) {
+		txbd->c.qword0.vlan_tci = mbuf->vlan_tci;
+		txbd->c.qword1.cmd |= RNP_TX_QINQ_INSERT;
+	}
 #define GRE_TUNNEL_KEY (4)
 #define GRE_TUNNEL_SEQ (4)
 	switch (flags & RTE_MBUF_F_TX_TUNNEL_MASK) {
@@ -1321,6 +1334,13 @@ rnp_setup_tx_offload(struct rnp_tx_queue *txq,
 	    flags & RTE_MBUF_F_TX_TCP_SEG ||
 	    flags & RTE_MBUF_F_TX_IP_CKSUM)
 		rnp_setup_csum_offload(tx_pkt, txbd);
+	if (flags & (RTE_MBUF_F_TX_VLAN |
+		     RTE_MBUF_F_TX_QINQ)) {
+		txbd->d.cmd |= RNP_TX_VLAN_VALID;
+		txbd->d.vlan_tci = (flags & RTE_MBUF_F_TX_QINQ) ?
+			tx_pkt->vlan_tci_outer : tx_pkt->vlan_tci;
+		txbd->d.cmd |= RNP_TX_VLAN_INSERT;
+	}
 }
 
 static __rte_always_inline uint16_t
Signature · 1 line
2.34.1
author
#28 lore raw

PATCH v8 26/28 net/rnp: add support VLAN filters operations.

In reply to Wenbo Cao

add support to update vid for vlan filter

---
 doc/guides/nics/features/rnp.ini    |  1 +
 doc/guides/nics/rnp.rst             |  2 +-
 drivers/net/rnp/base/meson.build    |  1 +
 drivers/net/rnp/base/rnp_bitrev.h   | 64 ++++++++++++++++++++++
 drivers/net/rnp/base/rnp_crc32.c    | 37 +++++++++++++
 drivers/net/rnp/base/rnp_crc32.h    | 10 ++++
 drivers/net/rnp/base/rnp_eth_regs.h |  1 +
 drivers/net/rnp/base/rnp_hw.h       |  1 +
 drivers/net/rnp/base/rnp_mac.c      | 85 +++++++++++++++++++++++++++++
 drivers/net/rnp/base/rnp_mac.h      |  1 +
 drivers/net/rnp/base/rnp_mac_regs.h |  6 ++
 drivers/net/rnp/base/rnp_osdep.h    | 13 +++++
 drivers/net/rnp/rnp.h               | 11 ++++
 drivers/net/rnp/rnp_ethdev.c        | 10 ++++
 14 files changed, 242 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/rnp/base/rnp_bitrev.h
 create mode 100644 drivers/net/rnp/base/rnp_crc32.c
 create mode 100644 drivers/net/rnp/base/rnp_crc32.h
doc/guides/nics/features/rnp.ini +1 -0
index 18ec4bc8d4..ce7381effe 100644
@@ -20,6 +20,7 @@ Promiscuous mode     = Y
 Allmulticast mode    = Y
 MTU update           = Y
 Unicast MAC filter   = Y
+VLAN filter          = Y
 VLAN offload         = Y
 QinQ offload         = Y
 RSS hash             = Y
doc/guides/nics/rnp.rst +1 -1
index febdaf84d3..f1d4a06ad7 100644
@@ -17,7 +17,7 @@ Features
 - Promiscuous mode
 - Link state information
 - MTU update
-- MAC filtering
+- MAC/VLAN filtering
 - Jumbo frames
 - Scatter-Gather IO support
 - Port hardware statistic
drivers/net/rnp/base/meson.build +1 -0
index c2ef0d05be..6b78de8841 100644
@@ -8,6 +8,7 @@ sources = [
         'rnp_common.c',
         'rnp_mac.c',
 	'rnp_bdq_if.c',
+	'rnp_crc32.c',
 ]
 
 error_cflags = ['-Wno-unused-value',
drivers/net/rnp/base/rnp_bitrev.h new file +64 -0

64 lines not on this page · raw message

drivers/net/rnp/base/rnp_crc32.c new file +37 -0
new file mode 100644
index 0000000000..c287b35759
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2023 Mucse IC Design Ltd.
+ */
+
+#include "rnp_osdep.h"
+#include "rnp_crc32.h"
+
+static inline int get_bitmask_order(u32 count)
+{
+	int order;
+
+	order = fls(count);
+
+	return order;   /* We could be slightly more clever with -1 here... */
+}
+
+u32 rnp_vid_crc32_calc(u32 crc_init, u16 vid_le)
+{
+	u8 *data = (u8 *)&vid_le;
+	u32 crc = crc_init;
+	u8 data_byte = 0;
+	u32 temp = 0;
+	int i, bits;
+
+	bits = get_bitmask_order(VLAN_VID_MASK);
+	for (i = 0; i < bits; i++) {
+		if ((i % 8) == 0)
+			data_byte = data[i / 8];
+		temp = ((crc & 1) ^ data_byte) & 1;
+		crc >>= 1;
+		data_byte >>= 1;
+		if (temp)
+			crc ^= 0xedb88320;
+	}
+
+	return crc;
+}
drivers/net/rnp/base/rnp_crc32.h new file +10 -0
new file mode 100644
index 0000000000..e117dcfc2f
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2023 Mucse IC Design Ltd.
+ */
+
+#ifndef _RNP_CRC32_H_
+#define _RNP_CRC32_H_
+
+u32 rnp_vid_crc32_calc(u32 crc_init, u16 vid_le);
+
+#endif /* _RNP_CRC32_H_ */
drivers/net/rnp/base/rnp_eth_regs.h +1 -0
index 802a127b1a..ac9cea484b 100644
@@ -61,6 +61,7 @@
 /* vlan filter ctrl */
 #define RNP_VLAN_FILTER_CTRL	_ETH_(0x9118)
 #define RNP_VLAN_FILTER_EN	RTE_BIT32(30)
+#define RNP_VFTA_HASH_TABLE(id) _ETH_(0xB000 + 0x4 * (id))
 /* rss function ctrl */
 #define RNP_RSS_INNER_CTRL	_ETH_(0x805c)
 #define RNP_INNER_RSS_EN	(1)
drivers/net/rnp/base/rnp_hw.h +1 -0
index b0c599d22e..92778a4276 100644
@@ -76,6 +76,7 @@ struct rnp_mac_ops {
 	int (*clear_rafb)(struct rnp_eth_port *port, u32 index);
 	/* receive vlan filter */
 	int (*vlan_f_en)(struct rnp_eth_port *port, bool en);
+	int (*update_vlan)(struct rnp_eth_port *port, u16 vid, bool en);
 };
 
 struct rnp_eth_adapter;
drivers/net/rnp/base/rnp_mac.c +85 -0

115 lines not on this page · raw message

drivers/net/rnp/base/rnp_mac.h +1 -0
index 4a5206ded3..6f22c8279a 100644
@@ -29,5 +29,6 @@ int rnp_clear_macaddr(struct rnp_eth_port *port, u32 index);
 int rnp_update_mpfm(struct rnp_eth_port *port,
 		    u32 mode, bool en);
 int rnp_rx_vlan_filter_en(struct rnp_eth_port *port, bool en);
+int rnp_update_vlan_filter(struct rnp_eth_port *port, u16 vid, bool en);
 
 #endif /* _RNP_MAC_H_ */
drivers/net/rnp/base/rnp_mac_regs.h +6 -0
index 43e0aed3ff..9c1d4406d2 100644
@@ -85,6 +85,12 @@
 #define RNP_MAC_VLAN_ETV	RTE_BIT32(16)
 /* enable vid valid  */
 #define RNP_MAC_VLAN_HASH_EN	RTE_GENMASK32(15, 0)
+/* mac vlan hash filter */
+#define RNP_MAC_VLAN_HASH	(0x58)
+#define RNP_MAC_VLAN_HASH_MASK	RTE_GENMASK32(15, 0)
+#define RNP_MAC_VLAN_HASH_SHIFT	(28)
+#define RNP_VLAN_BITMAP_BIT(vlan_id)	(1UL << ((vlan_id) & 0x3F))
+#define RNP_VLAN_BITMAP_IDX(vlan_id)	((vlan_id) >> 6)
 /* MAC VLAN CTRL INSERT REG */
 #define RNP_MAC_VLAN_INCL	(0x60)
 #define RNP_MAC_INNER_VLAN_INCL	(0x64)
drivers/net/rnp/base/rnp_osdep.h +13 -0
index c2dde3bb70..c41c5ca233 100644
@@ -50,6 +50,19 @@ typedef rte_iova_t dma_addr_t;
 #define cpu_to_le32(v)	rte_cpu_to_le_32((u32)(v))
 #endif
 
+#ifndef DIV_ROUND_UP
+#define DIV_ROUND_UP(n, d)      (((n) + (d) - 1) / (d))
+#define BITS_PER_BYTE           (8)
+#define BITS_TO_LONGS(nr)       DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
+#endif
+
+#define fls(n)	rte_fls_u32(n)
+
+#ifndef VLAN_N_VID
+#define VLAN_N_VID		(4096)
+#define VLAN_VID_MASK		(0x0fff)
+#endif
+
 #define spinlock_t			rte_spinlock_t
 #define spin_lock_init(spinlock_v)	rte_spinlock_init(spinlock_v)
 #define spin_lock(spinlock_v)		rte_spinlock_lock(spinlock_v)
drivers/net/rnp/rnp.h +11 -0
index 12b2850ae3..51f1e6b694 100644
@@ -63,6 +63,7 @@
 #define RNP_MAX_HASH_MC_MAC_SIZE	(4096)	/* max multicast hash mac num */
 #define RNP_MAX_UC_HASH_TABLE		(128)	/* max unicast hash mac filter table */
 #define RNP_MAC_MC_HASH_TABLE		(128)	/* max multicast hash mac filter table*/
+#define RNP_MAX_VFTA_SIZE		(128)   /* max pf vlan hash table size */
 /* Peer port own independent resource */
 #define RNP_PORT_MAX_MACADDR         (32)
 #define RNP_PORT_MAX_UC_HASH_TB      (8)
@@ -176,6 +177,15 @@ enum rnp_vlan_type {
 	RNP_SVLAN_TYPE = 1,
 };
 
+struct rnp_vlan_filter {
+	union {
+		/* indep vlan hash filter table used */
+		uint64_t vlans_bitmap[BITS_TO_LONGS(VLAN_N_VID)];
+		/* PF vlan filter table used */
+		uint32_t vfta_entries[RNP_MAX_VFTA_SIZE];
+	};
+};
+
 struct rnp_eth_port {
 	struct rnp_proc_priv *proc_priv;
 	struct rte_ether_addr mac_addr;
@@ -200,6 +210,7 @@ struct rnp_eth_port {
 
 	enum rnp_vlan_type outvlan_type;
 	enum rnp_vlan_type invlan_type;
+	struct rnp_vlan_filter vfta;
 	rte_spinlock_t rx_mac_lock;
 	bool port_stopped;
 };
drivers/net/rnp/rnp_ethdev.c +10 -0
index 0492d36ec2..a5ae670c96 100644
@@ -394,6 +394,15 @@ rnp_vlan_offload_set(struct rte_eth_dev *dev, int mask)
 	return 0;
 }
 
+static int
+rnp_vlan_filter_set(struct rte_eth_dev *dev,
+		uint16_t vlan_id, int on)
+{
+	struct rnp_eth_port *port = RNP_DEV_TO_PORT(dev);
+
+	return rnp_update_vlan_filter(port, vlan_id, on);
+}
+
 static int rnp_dev_start(struct rte_eth_dev *eth_dev)
 {
 	struct rnp_eth_port *port = RNP_DEV_TO_PORT(eth_dev);
@@ -1479,6 +1488,7 @@ static const struct eth_dev_ops rnp_eth_dev_ops = {
 	/* vlan offload */
 	.vlan_offload_set             = rnp_vlan_offload_set,
 	.vlan_strip_queue_set         = rnp_vlan_strip_queue_set,
+	.vlan_filter_set              = rnp_vlan_filter_set,
 };
 
 static void
Signature · 1 line
2.34.1
author
#29 lore raw

PATCH v8 27/28 net/rnp: add queue info operation.

In reply to Wenbo Cao

add support get queue configure info for user debug

---
 drivers/net/rnp/rnp_ethdev.c |  2 ++
 drivers/net/rnp/rnp_rxtx.c   | 42 ++++++++++++++++++++++++++++++++++++
 drivers/net/rnp/rnp_rxtx.h   |  4 ++++
 3 files changed, 48 insertions(+)
drivers/net/rnp/rnp_ethdev.c +2 -0
index a5ae670c96..0d37dd60b0 100644
@@ -1466,6 +1466,8 @@ static const struct eth_dev_ops rnp_eth_dev_ops = {
 	.rx_queue_release             = rnp_dev_rx_queue_release,
 	.tx_queue_setup               = rnp_tx_queue_setup,
 	.tx_queue_release             = rnp_dev_tx_queue_release,
+	.rxq_info_get                 = rnp_rx_queue_info_get,
+	.txq_info_get                 = rnp_tx_queue_info_get,
 	/* rss impl */
 	.reta_update                  = rnp_dev_rss_reta_update,
 	.reta_query                   = rnp_dev_rss_reta_query,
drivers/net/rnp/rnp_rxtx.c +42 -0

45 lines not on this page · raw message

drivers/net/rnp/rnp_rxtx.h +4 -0
index 51e5d4b600..dc4a8ea9dd 100644
@@ -148,5 +148,9 @@ int rnp_rx_queue_stop(struct rte_eth_dev *eth_dev, uint16_t qidx);
 int rnp_rx_queue_start(struct rte_eth_dev *eth_dev, uint16_t qidx);
 int rnp_rx_func_select(struct rte_eth_dev *dev);
 int rnp_tx_func_select(struct rte_eth_dev *dev);
+void rnp_rx_queue_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
+			   struct rte_eth_rxq_info *qinfo);
+void rnp_tx_queue_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
+			   struct rte_eth_txq_info *qinfo);
 
 #endif /* _RNP_RXTX_H_ */
Signature · 1 line
2.34.1
author
#30 lore raw

PATCH v8 28/28 net/rnp: support Rx/Tx burst mode info

In reply to Wenbo Cao

add platform method for get rx/tx burst function select by upload func name.

---
 drivers/net/rnp/rnp_ethdev.c |  2 ++
 drivers/net/rnp/rnp_rxtx.c   | 58 ++++++++++++++++++++++++++++++++++++
 drivers/net/rnp/rnp_rxtx.h   |  6 ++++
 3 files changed, 66 insertions(+)
drivers/net/rnp/rnp_ethdev.c +2 -0
index 0d37dd60b0..c5654ce1e5 100644
@@ -1468,6 +1468,8 @@ static const struct eth_dev_ops rnp_eth_dev_ops = {
 	.tx_queue_release             = rnp_dev_tx_queue_release,
 	.rxq_info_get                 = rnp_rx_queue_info_get,
 	.txq_info_get                 = rnp_tx_queue_info_get,
+	.rx_burst_mode_get            = rnp_rx_burst_mode_get,
+	.tx_burst_mode_get            = rnp_tx_burst_mode_get,
 	/* rss impl */
 	.reta_update                  = rnp_dev_rss_reta_update,
 	.reta_query                   = rnp_dev_rss_reta_query,
drivers/net/rnp/rnp_rxtx.c +58 -0

61 lines not on this page · raw message

drivers/net/rnp/rnp_rxtx.h +6 -0
index dc4a8ea9dd..8639f0892d 100644
@@ -152,5 +152,11 @@ void rnp_rx_queue_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
 			   struct rte_eth_rxq_info *qinfo);
 void rnp_tx_queue_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
 			   struct rte_eth_txq_info *qinfo);
+int rnp_rx_burst_mode_get(struct rte_eth_dev *dev,
+			  __rte_unused uint16_t queue_id,
+			  struct rte_eth_burst_mode *mode);
+int rnp_tx_burst_mode_get(struct rte_eth_dev *dev,
+			  __rte_unused uint16_t queue_id,
+			  struct rte_eth_burst_mode *mode);
 
 #endif /* _RNP_RXTX_H_ */
Signature · 1 line
2.34.1
#31 lore raw
In reply to Wenbo Cao

Driver review checklist for mucse PMD

Mark items with:
✔ passed
✘ Failed

Basic hygiene
✘ Look at CI results in patchwork; notify submitter if any failures ✔ Merge cleanly with git am; look for missing newline at EOF etc ✘ Run checkpatches; warnings are ok, but look more carefully. ✘ Run check-git-log; often get some minor warnings that are ok ✔ Run check-symbol-maps.sh
✔ Run check-doc-vs-code
✔ Run check-spdk-tag

Builds
✘ Normal Gcc build; make sure driver is built! ✘ Use latest experimental Gcc 15 to catch new warnings ✘ Clang build using current version (clang-19) ✘ Doc build

Rest of checklist skipped, not worth running with these kind of failures

author
#32 lore raw

Hi Stephen,

Thanks for your guideine, I will fixed these soon.

Regards Wenbo

Quoted 31 lines

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: 2025年2月11日 3:04
To: Wenbo Cao <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v8 00/28] [v8]drivers/net Add Support mucse N10 Pmd Driver

Driver review checklist for mucse PMD

Mark items with:
✔ passed
✘ Failed

Basic hygiene
✘ Look at CI results in patchwork; notify submitter if any failures ✔ Merge cleanly with git am; look for missing newline at EOF etc ✘ Run checkpatches; warnings are ok, but look more carefully. ✘ Run check-git-log; often get some minor warnings that are ok ✔ Run check-symbol-maps.sh
✔ Run check-doc-vs-code
✔ Run check-spdk-tag

Builds
✘ Normal Gcc build; make sure driver is built! ✘ Use latest experimental Gcc 15 to catch new warnings ✘ Clang build using current version (clang-19) ✘ Doc build

Rest of checklist skipped, not worth running with these kind of failures

#33 lore raw
In reply to Wenbo Cao
Quoted 135 lines · On Mon, 10 Feb 2025 15:26:27 +0800 Wenbo Cao <[email protected]> wrote:

For This patchset just to support the basic chip init work and user can just found the eth_dev, but can't control more. For Now just support 2*10g nic,the chip can support 2*10g,4*10g,4*1g,8*1g,8*10g.
The Feature rx side can support rx-cksum-offload,rss,vlan-filter flow_clow,uncast_filter,mcast_filter,1588,Jumbo-frame The Feature tx side can support tx-cksum-offload,tso,vxlan-tso flow director base on ntuple pattern of tcp/udp/ip/ eth_hdr->type for sriov is also support.

Because of the chip design defect, for multiple-port mode one pci-bdf will have multiple-port (max can have four ports) so this code must be care of one bdf init multiple-port.

v8:
* fixed codespell issue.
* fixed MAINTAINERS file

v7:
* add support nic basic feature such as rss vlan strip/filter,
* mtu-change recv/send scater-recv/mutltiple-send.
* fixed code rationality, advised by Ferruh Yigit.

v6:
* fixed the doc(rst) format problem advise by Thomas Monjalon

v5:
* fixed the symbol name require by the style documentation

v4:
* one patch has been forgot to upload :(

v3:
* fixed http://dpdk.org/patch/129830 FreeBSD 13 compile Issue
* change iobar type to void suggest by Stephen Hemminger
* add KMOD_DEP support for vfio-pci
* change run-cmd argument parse check for invalid extra_args

v2:
* fixed MAINTAIN maillist fullname format
* fixed driver/net/meson the order issue of new driver to driver list
* improve virtual point function usage suggest by Stephen Hemminger

Wenbo Cao (28):
net/rnp: add skeleton
net/rnp: add ethdev probe and remove net/rnp: add log
net/rnp: support mailbox basic operate net/rnp: add device init and uninit net/rnp: add get device information operation net/rnp: add support mac promisc mode net/rnp: add queue setup and release operations net/rnp: add queue stop and start operations net/rnp: add support device start stop operations net/rnp: add RSS support operations net/rnp: add support link update operations. net/rnp: add support link setup operations net/rnp: add Rx burst simple support net/rnp: add Tx burst simple support net/rnp: add MTU set operation
net/rnp: add Rx scatter segment version net/rnp: add Tx multiple segment version net/rnp: add support basic stats operation net/rnp: add support xstats operation net/rnp: add unicast MAC filter operation net/rnp: add supported packet types net/rnp: add support Rx checksum offload net/rnp: add support Tx TSO offload net/rnp: support VLAN offloads.
net/rnp: add support VLAN filters operations. net/rnp: add queue info operation. net/rnp: support Rx/Tx burst mode info

 MAINTAINERS                         |    6 +
 doc/guides/nics/features/rnp.ini    |   33 +
 doc/guides/nics/index.rst           |    1 +
 doc/guides/nics/rnp.rst             |  100 ++
 drivers/net/meson.build             |    1 +
 drivers/net/rnp/base/meson.build    |   28 +
 drivers/net/rnp/base/rnp_bdq_if.c   |  398 ++++++
 drivers/net/rnp/base/rnp_bdq_if.h   |  154 +++
 drivers/net/rnp/base/rnp_bitrev.h   |   64 +
 drivers/net/rnp/base/rnp_common.c   |  103 ++
 drivers/net/rnp/base/rnp_common.h   |   17 +
 drivers/net/rnp/base/rnp_crc32.c    |   37 +
 drivers/net/rnp/base/rnp_crc32.h    |   10 +
 drivers/net/rnp/base/rnp_dma_regs.h |   68 +
 drivers/net/rnp/base/rnp_eth_regs.h |   90 ++
 drivers/net/rnp/base/rnp_fw_cmd.c   |  162 +++
 drivers/net/rnp/base/rnp_fw_cmd.h   |  358 ++++++
 drivers/net/rnp/base/rnp_hw.h       |  136 ++
 drivers/net/rnp/base/rnp_mac.c      |  367 ++++++
 drivers/net/rnp/base/rnp_mac.h      |   34 +
 drivers/net/rnp/base/rnp_mac_regs.h |  207 +++
 drivers/net/rnp/base/rnp_mbx.c      |  512 ++++++++
 drivers/net/rnp/base/rnp_mbx.h      |   58 +
 drivers/net/rnp/base/rnp_mbx_fw.c   |  499 ++++++++
 drivers/net/rnp/base/rnp_mbx_fw.h   |   24 +
 drivers/net/rnp/base/rnp_osdep.h    |  175 +++
 drivers/net/rnp/meson.build         |   20 +
 drivers/net/rnp/rnp.h               |  258 ++++
 drivers/net/rnp/rnp_ethdev.c        | 1829 +++++++++++++++++++++++++++
 drivers/net/rnp/rnp_link.c          |  439 +++++++
 drivers/net/rnp/rnp_link.h          |   38 +
 drivers/net/rnp/rnp_logs.h          |   36 +
 drivers/net/rnp/rnp_rss.c           |  367 ++++++
 drivers/net/rnp/rnp_rss.h           |   43 +
 drivers/net/rnp/rnp_rxtx.c          | 1820 ++++++++++++++++++++++++++
 drivers/net/rnp/rnp_rxtx.h          |  162 +++
 36 files changed, 8654 insertions(+)
 create mode 100644 doc/guides/nics/features/rnp.ini
 create mode 100644 doc/guides/nics/rnp.rst
 create mode 100644 drivers/net/rnp/base/meson.build
 create mode 100644 drivers/net/rnp/base/rnp_bdq_if.c
 create mode 100644 drivers/net/rnp/base/rnp_bdq_if.h
 create mode 100644 drivers/net/rnp/base/rnp_bitrev.h
 create mode 100644 drivers/net/rnp/base/rnp_common.c
 create mode 100644 drivers/net/rnp/base/rnp_common.h
 create mode 100644 drivers/net/rnp/base/rnp_crc32.c
 create mode 100644 drivers/net/rnp/base/rnp_crc32.h
 create mode 100644 drivers/net/rnp/base/rnp_dma_regs.h
 create mode 100644 drivers/net/rnp/base/rnp_eth_regs.h
 create mode 100644 drivers/net/rnp/base/rnp_fw_cmd.c
 create mode 100644 drivers/net/rnp/base/rnp_fw_cmd.h
 create mode 100644 drivers/net/rnp/base/rnp_hw.h
 create mode 100644 drivers/net/rnp/base/rnp_mac.c
 create mode 100644 drivers/net/rnp/base/rnp_mac.h
 create mode 100644 drivers/net/rnp/base/rnp_mac_regs.h
 create mode 100644 drivers/net/rnp/base/rnp_mbx.c
 create mode 100644 drivers/net/rnp/base/rnp_mbx.h
 create mode 100644 drivers/net/rnp/base/rnp_mbx_fw.c
 create mode 100644 drivers/net/rnp/base/rnp_mbx_fw.h
 create mode 100644 drivers/net/rnp/base/rnp_osdep.h
 create mode 100644 drivers/net/rnp/meson.build
 create mode 100644 drivers/net/rnp/rnp.h
Quoted 9 lines
 create mode 100644 drivers/net/rnp/rnp_ethdev.c
 create mode 100644 drivers/net/rnp/rnp_link.c
 create mode 100644 drivers/net/rnp/rnp_link.h
 create mode 100644 drivers/net/rnp/rnp_logs.h
 create mode 100644 drivers/net/rnp/rnp_rss.c
 create mode 100644 drivers/net/rnp/rnp_rss.h
 create mode 100644 drivers/net/rnp/rnp_rxtx.c
 create mode 100644 drivers/net/rnp/rnp_rxtx.h

Clang build finds other errors.

[1520/3266] Compiling C object drivers/libtmp_rte_net_rnp.a.p/net_rnp_rnp_rxtx.c.o ../drivers/net/rnp/rnp_rxtx.c:1576:28: warning: use of logical '||' with constant operand [-Wconstant-logical-operand]

 1576 |                                 (RTE_MBUF_F_TX_L4_MASK || RTE_MBUF_F_TX_TCP_SEG))) {
      |                                                        ^  ~~~~~~~~~~~~~~~~~~~~~
../drivers/net/rnp/rnp_rxtx.c:1576:28: note: use '|' for a bitwise operation
 1576 |                                 (RTE_MBUF_F_TX_L4_MASK || RTE_MBUF_F_TX_TCP_SEG))) {
      |                                                        ^~
      |                                                        |

../drivers/net/rnp/rnp_rxtx.c:1576:6: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
1576 | (RTE_MBUF_F_TX_L4_MASK || RTE_MBUF_F_TX_TCP_SEG))) {
| ^
../lib/mbuf/rte_mbuf_core.h:312:43: note: expanded from macro 'RTE_MBUF_F_TX_L4_MASK'
312 | #define RTE_MBUF_F_TX_L4_MASK (3ULL << 52)
| ^
../drivers/net/rnp/rnp_rxtx.c:1576:31: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
1576 | (RTE_MBUF_F_TX_L4_MASK || RTE_MBUF_F_TX_TCP_SEG))) {
| ^
../lib/mbuf/rte_mbuf_core.h:284:43: note: expanded from macro 'RTE_MBUF_F_TX_TCP_SEG'
284 | #define RTE_MBUF_F_TX_TCP_SEG (1ULL << 50)

      |                     
#34 lore raw
In reply to Wenbo Cao
Quoted 10 lines · On Mon, 10 Feb 2025 15:26:27 +0800 Wenbo Cao <[email protected]> wrote:

For This patchset just to support the basic chip init work and user can just found the eth_dev, but can't control more. For Now just support 2*10g nic,the chip can support 2*10g,4*10g,4*1g,8*1g,8*10g.
The Feature rx side can support rx-cksum-offload,rss,vlan-filter flow_clow,uncast_filter,mcast_filter,1588,Jumbo-frame The Feature tx side can support tx-cksum-offload,tso,vxlan-tso flow director base on ntuple pattern of tcp/udp/ip/ eth_hdr->type for sriov is also support.

Quoted 3 lines

Because of the chip design defect, for multiple-port mode one pci-bdf will have multiple-port (max can have four ports) so this code must be care of one bdf init multiple-port.

Driver errors on most basic build (gcc-14 x86)

[2394/3266] Compiling C object drivers/net/rnp/base/librnp_base.a.p/rnp_mbx.c.o
../drivers/net/rnp/base/rnp_mbx.c: In function ‘rnp_write_mbx_pf’:
../drivers/net/rnp/base/rnp_mbx.c:323:51: warning: array subscript 64 is above array bounds of ‘struct rnp_mbx_sync[64]’ [-Warray-bounds=]

  323 |         struct rnp_mbx_sync *sync = &hw->mbx.syncs[mbx_id];
      |                                      ~~~~~~~~~~~~~^~~~~~~~

In file included from ../drivers/net/rnp/base/rnp_mbx.c:7:
../drivers/net/rnp/base/rnp_hw.h:57:29: note: while referencing ‘syncs’
57 | struct rnp_mbx_sync syncs[RNP_MBX_FW];
| ^~~~~
../drivers/net/rnp/base/rnp_mbx.c: In function ‘rnp_read_mbx_pf’:
../drivers/net/rnp/base/rnp_mbx.c:282:51: warning: array subscript 64 is above array bounds of ‘struct rnp_mbx_sync[64]’ [-Warray-bounds=]

  282 |         struct rnp_mbx_sync *sync = &hw->mbx.syncs[mbx_id];
      |                                      ~~~~~~~~~~~~~^~~~~~~~

../drivers/net/rnp/base/rnp_hw.h:57:29: note: while referencing ‘syncs’
57 | struct rnp_mbx_sync syncs[RNP_MBX_FW];
| ^~~~~
[3266/3266] Linking target app/dpdk-test

#35 lore raw
In reply to Wenbo Cao
Quoted 135 lines · On Mon, 10 Feb 2025 15:26:27 +0800 Wenbo Cao <[email protected]> wrote:

For This patchset just to support the basic chip init work and user can just found the eth_dev, but can't control more. For Now just support 2*10g nic,the chip can support 2*10g,4*10g,4*1g,8*1g,8*10g.
The Feature rx side can support rx-cksum-offload,rss,vlan-filter flow_clow,uncast_filter,mcast_filter,1588,Jumbo-frame The Feature tx side can support tx-cksum-offload,tso,vxlan-tso flow director base on ntuple pattern of tcp/udp/ip/ eth_hdr->type for sriov is also support.

Because of the chip design defect, for multiple-port mode one pci-bdf will have multiple-port (max can have four ports) so this code must be care of one bdf init multiple-port.

v8:
* fixed codespell issue.
* fixed MAINTAINERS file

v7:
* add support nic basic feature such as rss vlan strip/filter,
* mtu-change recv/send scater-recv/mutltiple-send.
* fixed code rationality, advised by Ferruh Yigit.

v6:
* fixed the doc(rst) format problem advise by Thomas Monjalon

v5:
* fixed the symbol name require by the style documentation

v4:
* one patch has been forgot to upload :(

v3:
* fixed http://dpdk.org/patch/129830 FreeBSD 13 compile Issue
* change iobar type to void suggest by Stephen Hemminger
* add KMOD_DEP support for vfio-pci
* change run-cmd argument parse check for invalid extra_args

v2:
* fixed MAINTAIN maillist fullname format
* fixed driver/net/meson the order issue of new driver to driver list
* improve virtual point function usage suggest by Stephen Hemminger

Wenbo Cao (28):
net/rnp: add skeleton
net/rnp: add ethdev probe and remove net/rnp: add log
net/rnp: support mailbox basic operate net/rnp: add device init and uninit net/rnp: add get device information operation net/rnp: add support mac promisc mode net/rnp: add queue setup and release operations net/rnp: add queue stop and start operations net/rnp: add support device start stop operations net/rnp: add RSS support operations net/rnp: add support link update operations. net/rnp: add support link setup operations net/rnp: add Rx burst simple support net/rnp: add Tx burst simple support net/rnp: add MTU set operation
net/rnp: add Rx scatter segment version net/rnp: add Tx multiple segment version net/rnp: add support basic stats operation net/rnp: add support xstats operation net/rnp: add unicast MAC filter operation net/rnp: add supported packet types net/rnp: add support Rx checksum offload net/rnp: add support Tx TSO offload net/rnp: support VLAN offloads.
net/rnp: add support VLAN filters operations. net/rnp: add queue info operation. net/rnp: support Rx/Tx burst mode info

 MAINTAINERS                         |    6 +
 doc/guides/nics/features/rnp.ini    |   33 +
 doc/guides/nics/index.rst           |    1 +
 doc/guides/nics/rnp.rst             |  100 ++
 drivers/net/meson.build             |    1 +
 drivers/net/rnp/base/meson.build    |   28 +
 drivers/net/rnp/base/rnp_bdq_if.c   |  398 ++++++
 drivers/net/rnp/base/rnp_bdq_if.h   |  154 +++
 drivers/net/rnp/base/rnp_bitrev.h   |   64 +
 drivers/net/rnp/base/rnp_common.c   |  103 ++
 drivers/net/rnp/base/rnp_common.h   |   17 +
 drivers/net/rnp/base/rnp_crc32.c    |   37 +
 drivers/net/rnp/base/rnp_crc32.h    |   10 +
 drivers/net/rnp/base/rnp_dma_regs.h |   68 +
 drivers/net/rnp/base/rnp_eth_regs.h |   90 ++
 drivers/net/rnp/base/rnp_fw_cmd.c   |  162 +++
 drivers/net/rnp/base/rnp_fw_cmd.h   |  358 ++++++
 drivers/net/rnp/base/rnp_hw.h       |  136 ++
 drivers/net/rnp/base/rnp_mac.c      |  367 ++++++
 drivers/net/rnp/base/rnp_mac.h      |   34 +
 drivers/net/rnp/base/rnp_mac_regs.h |  207 +++
 drivers/net/rnp/base/rnp_mbx.c      |  512 ++++++++
 drivers/net/rnp/base/rnp_mbx.h      |   58 +
 drivers/net/rnp/base/rnp_mbx_fw.c   |  499 ++++++++
 drivers/net/rnp/base/rnp_mbx_fw.h   |   24 +
 drivers/net/rnp/base/rnp_osdep.h    |  175 +++
 drivers/net/rnp/meson.build         |   20 +
 drivers/net/rnp/rnp.h               |  258 ++++
 drivers/net/rnp/rnp_ethdev.c        | 1829 +++++++++++++++++++++++++++
 drivers/net/rnp/rnp_link.c          |  439 +++++++
 drivers/net/rnp/rnp_link.h          |   38 +
 drivers/net/rnp/rnp_logs.h          |   36 +
 drivers/net/rnp/rnp_rss.c           |  367 ++++++
 drivers/net/rnp/rnp_rss.h           |   43 +
 drivers/net/rnp/rnp_rxtx.c          | 1820 ++++++++++++++++++++++++++
 drivers/net/rnp/rnp_rxtx.h          |  162 +++
 36 files changed, 8654 insertions(+)
 create mode 100644 doc/guides/nics/features/rnp.ini
 create mode 100644 doc/guides/nics/rnp.rst
 create mode 100644 drivers/net/rnp/base/meson.build
 create mode 100644 drivers/net/rnp/base/rnp_bdq_if.c
 create mode 100644 drivers/net/rnp/base/rnp_bdq_if.h
 create mode 100644 drivers/net/rnp/base/rnp_bitrev.h
 create mode 100644 drivers/net/rnp/base/rnp_common.c
 create mode 100644 drivers/net/rnp/base/rnp_common.h
 create mode 100644 drivers/net/rnp/base/rnp_crc32.c
 create mode 100644 drivers/net/rnp/base/rnp_crc32.h
 create mode 100644 drivers/net/rnp/base/rnp_dma_regs.h
 create mode 100644 drivers/net/rnp/base/rnp_eth_regs.h
 create mode 100644 drivers/net/rnp/base/rnp_fw_cmd.c
 create mode 100644 drivers/net/rnp/base/rnp_fw_cmd.h
 create mode 100644 drivers/net/rnp/base/rnp_hw.h
 create mode 100644 drivers/net/rnp/base/rnp_mac.c
 create mode 100644 drivers/net/rnp/base/rnp_mac.h
 create mode 100644 drivers/net/rnp/base/rnp_mac_regs.h
 create mode 100644 drivers/net/rnp/base/rnp_mbx.c
 create mode 100644 drivers/net/rnp/base/rnp_mbx.h
 create mode 100644 drivers/net/rnp/base/rnp_mbx_fw.c
 create mode 100644 drivers/net/rnp/base/rnp_mbx_fw.h
 create mode 100644 drivers/net/rnp/base/rnp_osdep.h
 create mode 100644 drivers/net/rnp/meson.build
 create mode 100644 drivers/net/rnp/rnp.h
Quoted 9 lines
 create mode 100644 drivers/net/rnp/rnp_ethdev.c
 create mode 100644 drivers/net/rnp/rnp_link.c
 create mode 100644 drivers/net/rnp/rnp_link.h
 create mode 100644 drivers/net/rnp/rnp_logs.h
 create mode 100644 drivers/net/rnp/rnp_rss.c
 create mode 100644 drivers/net/rnp/rnp_rss.h
 create mode 100644 drivers/net/rnp/rnp_rxtx.c
 create mode 100644 drivers/net/rnp/rnp_rxtx.h

Did you do a test build of doc's it shows error:

Warning generate_overview_table(): Unknown feature 'Jumbo frame' in 'rnp.ini'