XSC PMD for Yunsilicon NICs
Subsystems (2)
v6 cover XSC PMD for Yunsilicon NICs
This xsc PMD (**librte_net_xsc**) provides poll mode driver for Yunsilicon metaScale serials NICs.
Features:
---------
- MTU update
- TSO
- RSS hash
- RSS key update
- RSS reta update
- L3 checksum offload
- L4 checksum offload
- Inner L3 checksum
- Inner L4 checksum
- Basic stats
Support NICs:
-------------
- metaScale-200S Single QSFP56 Port 200GE SmartNIC - metaScale-200 Quad QSFP28 Ports 100GE SmartNIC - metaScale-50 Dual QSFP28 Port 25GE SmartNIC - metaScale-100Q Quad QSFP28 Port 25GE SmartNIC
---
v6:
* Remove unnecessary paren.
* Add the feature of stats per queue in xsc.ini.
* Use memcpy instead of rte_memcpy in non critical path.
* Rebase from the main branch and merge release notes.
* Replace __rte_packed with __rte_packed_begin and __rte_packed_end.
v5:
* fix compilation errors.
* fix coding style issue with misspelling.
* remove some unnecessary parameter checks.
* remove unnecessary call of rte_wmb.
* Rearrange elements in structure to avoid holes.
v4:
* Based on the review comments from previous versions, reconstruct the xsc PMD to eliminate the dependency on rdma core library and proprietary kernel driver, while adding support for the vfio kernel driver.
v3:
* fix compilation errors
v2:
* fix checkpatch warnings and errors
---
WanRenyong (15):
net/xsc: add xsc PMD framework
net/xsc: add xsc device initialization
net/xsc: add xsc mailbox
net/xsc: add xsc dev ops to support VFIO driver
net/xsc: add PCT interfaces
net/xsc: initialize xsc representors
net/xsc: add ethdev configure and RSS ops
net/xsc: add Rx and Tx queue setup
net/xsc: add ethdev start
net/xsc: add ethdev stop and close
net/xsc: add ethdev Rx burst
net/xsc: add ethdev Tx burst
net/xsc: add basic stats ops
net/xsc: add ethdev infos get
net/xsc: add ethdev link and MTU ops
.mailmap | 5 + MAINTAINERS | 10 + doc/guides/nics/features/xsc.ini | 19 + doc/guides/nics/index.rst | 1 + doc/guides/nics/xsc.rst | 31 + doc/guides/rel_notes/release_25_03.rst | 4 + drivers/net/meson.build | 1 + drivers/net/xsc/meson.build | 17 + drivers/net/xsc/xsc_cmd.h | 387 +++++++++++ drivers/net/xsc/xsc_defs.h | 100 +++ drivers/net/xsc/xsc_dev.c | 397 +++++++++++ drivers/net/xsc/xsc_dev.h | 184 +++++ drivers/net/xsc/xsc_ethdev.c | 917 +++++++++++++++++++++++++ drivers/net/xsc/xsc_ethdev.h | 63 ++ drivers/net/xsc/xsc_log.h | 24 + drivers/net/xsc/xsc_np.c | 492 +++++++++++++ drivers/net/xsc/xsc_np.h | 154 +++++ drivers/net/xsc/xsc_rx.c | 512 ++++++++++++++ drivers/net/xsc/xsc_rx.h | 65 ++ drivers/net/xsc/xsc_rxtx.h | 191 +++++ drivers/net/xsc/xsc_tx.c | 354 ++++++++++ drivers/net/xsc/xsc_tx.h | 62 ++ drivers/net/xsc/xsc_vfio.c | 746 ++++++++++++++++++++ drivers/net/xsc/xsc_vfio_mbox.c | 691 +++++++++++++++++++ drivers/net/xsc/xsc_vfio_mbox.h | 142 ++++ 25 files changed, 5569 insertions(+) create mode 100644 doc/guides/nics/features/xsc.ini create mode 100644 doc/guides/nics/xsc.rst create mode 100644 drivers/net/xsc/meson.build create mode 100644 drivers/net/xsc/xsc_cmd.h create mode 100644 drivers/net/xsc/xsc_defs.h create mode 100644 drivers/net/xsc/xsc_dev.c create mode 100644 drivers/net/xsc/xsc_dev.h create mode 100644 drivers/net/xsc/xsc_ethdev.c create mode 100644 drivers/net/xsc/xsc_ethdev.h create mode 100644 drivers/net/xsc/xsc_log.h create mode 100644 drivers/net/xsc/xsc_np.c create mode 100644 drivers/net/xsc/xsc_np.h create mode 100644 drivers/net/xsc/xsc_rx.c create mode 100644 drivers/net/xsc/xsc_rx.h create mode 100644 drivers/net/xsc/xsc_rxtx.h create mode 100644 drivers/net/xsc/xsc_tx.c create mode 100644 drivers/net/xsc/xsc_tx.h create mode 100644 drivers/net/xsc/xsc_vfio.c create mode 100644 drivers/net/xsc/xsc_vfio_mbox.c create mode 100644 drivers/net/xsc/xsc_vfio_mbox.h
Signature · 1 line
2.25.1
PATCH v6 1/15 net/xsc: add xsc PMD framework
Add xsc PMD framework, doc and build infrastructure, supporting PCI probe.
---
v6:
* Delete the included header file net/if.h.
* Rebase from the main branch and merge release notes.
--- .mailmap | 5 ++ MAINTAINERS | 10 +++ doc/guides/nics/features/xsc.ini | 9 +++ doc/guides/nics/index.rst | 1 + doc/guides/nics/xsc.rst | 31 +++++++++ doc/guides/rel_notes/release_25_03.rst | 4 ++ drivers/net/meson.build | 1 + drivers/net/xsc/meson.build | 11 ++++ drivers/net/xsc/xsc_defs.h | 15 +++++ drivers/net/xsc/xsc_ethdev.c | 88 ++++++++++++++++++++++++++ drivers/net/xsc/xsc_ethdev.h | 15 +++++ drivers/net/xsc/xsc_log.h | 24 +++++++ 12 files changed, 214 insertions(+) create mode 100644 doc/guides/nics/features/xsc.ini create mode 100644 doc/guides/nics/xsc.rst create mode 100644 drivers/net/xsc/meson.build create mode 100644 drivers/net/xsc/xsc_defs.h create mode 100644 drivers/net/xsc/xsc_ethdev.c create mode 100644 drivers/net/xsc/xsc_ethdev.h create mode 100644 drivers/net/xsc/xsc_log.h
.mailmap +5 -0
@@ -371,6 +371,7 @@ Dongdong Liu <[email protected]> Dongsheng Rong <[email protected]> Dongsu Han <[email protected]> Dong Wang <[email protected]> +Dongwei Xu <[email protected]> Dongyang Pan <[email protected]> Dong Zhou <[email protected]> <[email protected]> Don Provan <[email protected]>
@@ -1064,6 +1065,7 @@ Nagadheeraj Rottela <[email protected]> Naga Harish K S V <[email protected]> Naga Suresh Somarowthu <[email protected]> Nalla Pradeep <[email protected]> +Na Na <[email protected]> Na Na <[email protected]> Nan Chen <[email protected]> Nandini Persad <[email protected]>
@@ -1308,6 +1310,7 @@ Ronak Doshi <[email protected]> <[email protected]> Ron Beider <[email protected]> Ronghua Zhang <[email protected]> RongQiang Xie <[email protected]> +Rong Qian <[email protected]> RongQing Li <[email protected]> Rongwei Liu <[email protected]> Rory Sexton <[email protected]>
@@ -1635,6 +1638,7 @@ Waldemar Dworakowski <[email protected]> Walter Heymans <[email protected]> Wang Sheng-Hui <[email protected]> Wangyu (Eric) <[email protected]> +WanRenyong <[email protected]> Waterman Cao <[email protected]> Wathsala Vithanage <[email protected]> Weichun Chen <[email protected]>
@@ -1688,6 +1692,7 @@ Xiaonan Zhang <[email protected]> Xiao Wang <[email protected]> Xiaoxiao Zeng <[email protected]> Xiaoxin Peng <[email protected]> +Xiaoxiong Zhang <[email protected]> Xiaoyu Min <[email protected]> <[email protected]> Xiaoyun Li <[email protected]> Xiaoyun Wang <[email protected]>
MAINTAINERS +10 -0
@@ -1075,6 +1075,16 @@ F: drivers/net/avp/ F: doc/guides/nics/avp.rst F: doc/guides/nics/features/avp.ini +Yunsilicon xsc +M: WanRenyong <[email protected]> +M: Na Na <[email protected]> +M: Rong Qian <[email protected]> +M: Xiaoxiong Zhang <[email protected]> +M: Dongwei Xu <[email protected]> +F: drivers/net/xsc/ +F: doc/guides/nics/xsc.rst +F: doc/guides/nics/features/xsc.ini + ZTE zxdh - EXPERIMENTAL M: Junlong Wang <[email protected]> M: Lijie Shan <[email protected]>
doc/guides/nics/features/xsc.ini new file +9 -0
@@ -0,0 +1,9 @@ +; +; Supported features of the 'xsc' network poll mode driver. +; +; Refer to default.ini for the full list of available PMD features. +; +[Features] +Linux = Y +ARMv8 = Y +x86-64 = Y
doc/guides/nics/index.rst +1 -0
@@ -70,4 +70,5 @@ Network Interface Controller Drivers vhost virtio vmxnet3 + xsc zxdh
doc/guides/nics/xsc.rst new file +31 -0
@@ -0,0 +1,31 @@ +.. SPDX-License-Identifier: BSD-3-Clause + Copyright 2024 Yunsilicon Technology Co., Ltd + +XSC Poll Mode Driver +====================== + +The xsc PMD (**librte_net_xsc**) provides poll mode driver support for +10/25/50/100/200 Gbps Yunsilicon metaScale Series Network Adapters. + +Supported NICs +-------------- + +The following Yunsilicon device models are supported by the same xsc driver: + + - metaScale-200S + - metaScale-200 + - metaScale-100Q + - metaScale-50 + +Prerequisites +-------------- + +- Follow the DPDK :ref:`Getting Started Guide for Linux <linux_gsg>` to setup the basic DPDK environment. + +- Learning about Yunsilicon metaScale Series NICs using + `<https://www.yunsilicon.com/#/productInformation>`_. + +Limitations or Known issues +--------------------------- +32bit ARCHs are not supported. +Windows and BSD are not supported yet.
doc/guides/rel_notes/release_25_03.rst +4 -0
@@ -63,6 +63,10 @@ New Features and even substantial part of its code. It can be viewed as an extension of rte_ring functionality. +* **Added Yunsilicon xsc net driver [EXPERIMENTAL].** + + * Added the PMD for Yunsilicon metaScale serials NICs. + Removed Items -------------
drivers/net/meson.build +1 -0
@@ -63,6 +63,7 @@ drivers = [ 'vhost', 'virtio', 'vmxnet3', + 'xsc', 'zxdh', ] std_deps = ['ethdev', 'kvargs'] # 'ethdev' also pulls in mbuf, net, eal etc
drivers/net/xsc/meson.build new file +11 -0
@@ -0,0 +1,11 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2025 Yunsilicon Technology Co., Ltd. + +if not is_linux or not dpdk_conf.get('RTE_ARCH_64') + build = false + reason = 'only supported on 64bit Linux' +endif + +sources = files( + 'xsc_ethdev.c', +)
drivers/net/xsc/xsc_defs.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2025 Yunsilicon Technology Co., Ltd. +*/ + +#ifndef XSC_DEFS_H_ +#define XSC_DEFS_H_ + +#define XSC_PCI_VENDOR_ID 0x1f67 +#define XSC_PCI_DEV_ID_MS 0x1111 +#define XSC_PCI_DEV_ID_MSVF 0x1112 +#define XSC_PCI_DEV_ID_MVH 0x1151 +#define XSC_PCI_DEV_ID_MVHVF 0x1152 +#define XSC_PCI_DEV_ID_MVS 0x1153 + +#endif /* XSC_DEFS_H_ */
drivers/net/xsc/xsc_ethdev.c new file +88 -0
88 lines not on this page · raw message
drivers/net/xsc/xsc_ethdev.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2025 Yunsilicon Technology Co., Ltd. +*/ + +#ifndef _XSC_ETHDEV_H_ +#define _XSC_ETHDEV_H_ + +struct xsc_ethdev_priv { +struct rte_eth_dev *eth_dev; +struct rte_pci_device *pci_dev; +}; + +#define TO_XSC_ETHDEV_PRIV (dev) ((struct xsc_ethdev_priv *)(dev)->data->dev_private) + +#endif /* _XSC_ETHDEV_H_ */
drivers/net/xsc/xsc_log.h new file +24 -0
@@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2025 Yunsilicon Technology Co., Ltd. +*/ + +#ifndef _XSC_LOG_H_ +#define _XSC_LOG_H_ + +#include <rte_log.h> + +extern int xsc_logtype_init; +extern int xsc_logtype_driver; + +#define RTE_LOGTYPE_XSC_INIT xsc_logtype_init +#define RTE_LOGTYPE_XSC_DRV xsc_logtype_driver + +#define PMD_INIT_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, XSC_INIT, "%s(): ", __func__, __VA_ARGS__) + +#define PMD_INIT_FUNC_TRACE () PMD_INIT_LOG(DEBUG, " >>") + +#define PMD_DRV_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, XSC_DRV, "%s(): ", __func__, __VA_ARGS__) + +#endif /* _XSC_LOG_H_ */
Signature · 1 line
2.25.1
Re: [PATCH v6 01/15] net/xsc: add xsc PMD framework
MAINTAINERS F: drivers/net/avp/ · line 1083
Quoted 6 lines
MAINTAINERS +6
-0+Yunsilicon xsc +M: WanRenyong <[email protected]> +M: Na Na <[email protected]> +M: Rong Qian <[email protected]> +M: Xiaoxiong Zhang <[email protected]> +M: Dongwei Xu <[email protected]>
Looking at how the names are codified in email addresses,
I feel "Renyong Wan" is the right form for your name in English format.
Re: [PATCH v6 01/15] net/xsc: add xsc PMD framework
Quoted 10 lines · Thomas Monjalon
MAINTAINERS F: drivers/net/avp/ · line 1083
Quoted 6 lines
MAINTAINERS +6
-0+Yunsilicon xsc +M: WanRenyong <[email protected]> +M: Na Na <[email protected]> +M: Rong Qian <[email protected]> +M: Xiaoxiong Zhang <[email protected]> +M: Dongwei Xu <[email protected]>Looking at how the names are codified in email addresses,
I feel "Renyong Wan" is the right form for your name in English format.
Hello Tomas Monjalon,
Yes, you are right, but if I use "Renyong Wan" as my English name, every patch alway gets a misspelling warning from checkpatch. :( It's really annoying. If it isn't unacceptable to DPDK for using "WanRenyong" as my name, I don't mind of it too.
Thank your for review.
--
Best regards,
WanRenyong
Re: [PATCH v6 01/15] net/xsc: add xsc PMD framework
23/01/2025 06:48, WanRenyong:
Quoted 11 lines · Thomas Monjalon
Quoted 10 lines
MAINTAINERS F: drivers/net/avp/ · line 1083
Quoted 6 lines
MAINTAINERS +6
-0+Yunsilicon xsc +M: WanRenyong <[email protected]> +M: Na Na <[email protected]> +M: Rong Qian <[email protected]> +M: Xiaoxiong Zhang <[email protected]> +M: Dongwei Xu <[email protected]>Looking at how the names are codified in email addresses,
I feel "Renyong Wan" is the right form for your name in English format.
Quoted 6 lines
Hello Tomas Monjalon,
Yes, you are right, but if I use "Renyong Wan" as my English name, every patch alway gets a misspelling warning from checkpatch. :( It's really annoying. If it isn't unacceptable to DPDK for using "WanRenyong" as my name, I don't mind of it too.
Can't you set "Renyong Wan" in your .gitconfig?
I think it would solve your issue.
Re: [PATCH v6 01/15] net/xsc: add xsc PMD framework
Quoted 12 lines · Thomas Monjalon
23/01/2025 06:48, WanRenyong:
Quoted 11 lines · Thomas Monjalon
Quoted 10 lines
MAINTAINERS F: drivers/net/avp/ · line 1083
Quoted 6 lines
MAINTAINERS +6
-0+Yunsilicon xsc +M: WanRenyong <[email protected]> +M: Na Na <[email protected]> +M: Rong Qian <[email protected]> +M: Xiaoxiong Zhang <[email protected]> +M: Dongwei Xu <[email protected]>Looking at how the names are codified in email addresses,
I feel "Renyong Wan" is the right form for your name in English format.
Quoted 10 lines
Quoted 6 lines
Hello Tomas Monjalon,
Yes, you are right, but if I use "Renyong Wan" as my English name, every patch alway gets a misspelling warning from checkpatch. :( It's really annoying. If it isn't unacceptable to DPDK for using "WanRenyong" as my name, I don't mind of it too.
Can't you set "Renyong Wan" in your .gitconfig?
I think it would solve your issue.
Hello Tomas Monjalon,
I tried it , there are still a few warnings from checkpatch like below:
WARNING:TYPO_SPELLING: 'Wan' may be misspelled - perhaps 'Want'? #8:
Renyong Wan (15):
^^^
If DPDK accept it , I'll change my name to "Renyong Wan" in the next version.
Thank you.
Signature · 2 lines
Best regards, WanRenyong
Re: [PATCH v6 01/15] net/xsc: add xsc PMD framework
23/01/2025 10:19, WanRenyong:
Quoted 27 lines · Thomas Monjalon
Quoted 12 lines
23/01/2025 06:48, WanRenyong:
Quoted 11 lines · Thomas Monjalon
Quoted 10 lines
MAINTAINERS F: drivers/net/avp/ · line 1083
Quoted 6 lines
MAINTAINERS +6
-0+Yunsilicon xsc +M: WanRenyong <[email protected]> +M: Na Na <[email protected]> +M: Rong Qian <[email protected]> +M: Xiaoxiong Zhang <[email protected]> +M: Dongwei Xu <[email protected]>Looking at how the names are codified in email addresses,
I feel "Renyong Wan" is the right form for your name in English format.Quoted 10 lines
Quoted 6 lines
Hello Tomas Monjalon,
Yes, you are right, but if I use "Renyong Wan" as my English name, every patch alway gets a misspelling warning from checkpatch. :( It's really annoying. If it isn't unacceptable to DPDK for using "WanRenyong" as my name, I don't mind of it too.
Can't you set "Renyong Wan" in your .gitconfig?
I think it would solve your issue.Hello Tomas Monjalon,
I tried it , there are still a few warnings from checkpatch like below:
Quoted 7 lines
WARNING:TYPO_SPELLING: 'Wan' may be misspelled - perhaps 'Want'? #8:
Renyong Wan (15):^^^If DPDK accept it , I'll change my name to "Renyong Wan" in the next version.
Yes it is just a false warning, no problem.
Thank you
Re: [PATCH v6 01/15] net/xsc: add xsc PMD framework
In reply to WanRenyongQuoted 18 lines · On Thu, 23 Jan 2025 13:48:25 +0800 "WanRenyong" <[email protected]> wrote:
Quoted 10 lines · Thomas Monjalon
MAINTAINERS F: drivers/net/avp/ · line 1083
Quoted 6 lines
MAINTAINERS +6
-0+Yunsilicon xsc +M: WanRenyong <[email protected]> +M: Na Na <[email protected]> +M: Rong Qian <[email protected]> +M: Xiaoxiong Zhang <[email protected]> +M: Dongwei Xu <[email protected]>Looking at how the names are codified in email addresses,
I feel "Renyong Wan" is the right form for your name in English format.Hello Tomas Monjalon,
Yes, you are right, but if I use "Renyong Wan" as my English name, every patch alway gets a misspelling warning from checkpatch. :( It's really annoying. If it isn't unacceptable to DPDK for using "WanRenyong" as my name, I don't mind of it too.
Quoted 5 lines
Thank your for review.
--
Best regards,
WanRenyong
No worries, we don't blindly trust checkpatch.
What matters is that Signed-off-by must match your legal name because it has Signed-off-by has some legal significance to lawyers.
Re: [PATCH v6 01/15] net/xsc: add xsc PMD framework
Quoted 21 lines · Stephen Hemminger
Quoted 18 lines · On Thu, 23 Jan 2025 13:48:25 +0800 "WanRenyong" <[email protected]> wrote:
Quoted 10 lines · Thomas Monjalon
MAINTAINERS F: drivers/net/avp/ · line 1083
Quoted 6 lines
MAINTAINERS +6
-0+Yunsilicon xsc +M: WanRenyong <[email protected]> +M: Na Na <[email protected]> +M: Rong Qian <[email protected]> +M: Xiaoxiong Zhang <[email protected]> +M: Dongwei Xu <[email protected]>Looking at how the names are codified in email addresses,
I feel "Renyong Wan" is the right form for your name in English format.Hello Tomas Monjalon,
Yes, you are right, but if I use "Renyong Wan" as my English name, every patch alway gets a misspelling warning from checkpatch. :( It's really annoying. If it isn't unacceptable to DPDK for using "WanRenyong" as my name, I don't mind of it too.
Quoted 8 lines
Quoted 5 lines
Thank your for review.
--
Best regards,
WanRenyongNo worries, we don't blindly trust checkpatch.
What matters is that Signed-off-by must match your legal name because it has Signed-off-by has some legal significance to lawyers.
Got it, thank you Stephen.
Will there be any new review comments for this version of patchset? Should I submit the next version?
Signature · 2 lines
Best regards, WanRenyong
PATCH v6 2/15 net/xsc: add xsc device initialization
In reply to WanRenyongXSC device is a hardware abstract level device serving as a handle to interact with hardware.
---
v5:
* Fix coding style issue with misspelling
* Rearrange the elements in struct xsc_hwinfo to reduce holes
--- drivers/net/xsc/meson.build | 1 + drivers/net/xsc/xsc_defs.h | 16 ++++ drivers/net/xsc/xsc_dev.c | 181 +++++++++++++++++++++++++++++++++++ drivers/net/xsc/xsc_dev.h | 131 +++++++++++++++++++++++++ drivers/net/xsc/xsc_ethdev.c | 16 +++- drivers/net/xsc/xsc_ethdev.h | 3 + 6 files changed, 347 insertions(+), 1 deletion(-) create mode 100644 drivers/net/xsc/xsc_dev.c create mode 100644 drivers/net/xsc/xsc_dev.h
drivers/net/xsc/meson.build +1 -0
@@ -8,4 +8,5 @@ endif sources = files( 'xsc_ethdev.c', + 'xsc_dev.c', )
drivers/net/xsc/xsc_defs.h +16 -0
@@ -12,4 +12,20 @@#define XSC_PCI_DEV_ID_MVHVF 0x1152#define XSC_PCI_DEV_ID_MVS 0x1153 +#define XSC_VFREP_BASE_LOGICAL_PORT 1081 + +enum xsc_nic_mode { +XSC_NIC_MODE_LEGACY , +XSC_NIC_MODE_SWITCHDEV , +XSC_NIC_MODE_SOC , +}; + +enum xsc_pph_type { +XSC_PPH_NONE =0 , +XSC_RX_PPH =0x1 , +XSC_TX_PPH =0x2 , +XSC_VFREP_PPH =0x4 , +XSC_UPLINK_PPH =0x8 , +}; +#endif /* XSC_DEFS_H_ */
drivers/net/xsc/xsc_dev.c new file +181 -0
181 lines not on this page · raw message
drivers/net/xsc/xsc_dev.h new file +131 -0
131 lines not on this page · raw message
drivers/net/xsc/xsc_ethdev.c +15 -1
@@ -12,22 +12,32 @@ static int xsc_ethdev_init(struct rte_eth_dev *eth_dev) {struct xsc_ethdev_priv *priv =TO_XSC_ETHDEV_PRIV (eth_dev); +int ret;PMD_INIT_FUNC_TRACE (); priv->eth_dev = eth_dev; priv->pci_dev =RTE_ETH_DEV_TO_PCI (eth_dev); + ret =xsc_dev_init (priv->pci_dev, &priv->xdev); +if (ret) { +PMD_DRV_LOG (ERR ,"Failed to initialize xsc device" ); +return ret; + } + priv->xdev->port_id = eth_dev->data->port_id; +return 0 ; }static int xsc_ethdev_uninit (struct rte_eth_dev *eth_dev) { -RTE_SET_USED (eth_dev); +struct xsc_ethdev_priv *priv =TO_XSC_ETHDEV_PRIV (eth_dev);PMD_INIT_FUNC_TRACE (); +xsc_dev_uninit (priv->xdev); +return 0 ; }
@@ -83,6 +93,10 @@ static struct rte_pci_driver xsc_ethdev_pci_driver = {RTE_PMD_REGISTER_PCI (net_xsc, xsc_ethdev_pci_driver);RTE_PMD_REGISTER_PCI_TABLE (net_xsc, xsc_ethdev_pci_id_map); +RTE_PMD_REGISTER_PARAM_STRING (net_xsc, +XSC_PPH_MODE_ARG "=<x>" +XSC_NIC_MODE_ARG "=<x>" +XSC_FLOW_MODE_ARG "=<x>" );RTE_LOG_REGISTER_SUFFIX (xsc_logtype_init, init,NOTICE );RTE_LOG_REGISTER_SUFFIX (xsc_logtype_driver, driver,NOTICE );
drivers/net/xsc/xsc_ethdev.h +3 -0
@@ -5,9 +5,12 @@#ifndef _XSC_ETHDEV_H_#define _XSC_ETHDEV_H_ +#include "xsc_dev.h" +struct xsc_ethdev_priv {struct rte_eth_dev *eth_dev;struct rte_pci_device *pci_dev; +struct xsc_dev *xdev; };#define TO_XSC_ETHDEV_PRIV (dev) ((struct xsc_ethdev_priv *)(dev)->data->dev_private)
Signature · 1 line
2.25.1
PATCH v6 3/15 net/xsc: add xsc mailbox
In reply to WanRenyongXSC mailbox is a mechanism used for interaction between PMD and firmware.
--- drivers/net/xsc/meson.build | 1 + drivers/net/xsc/xsc_cmd.h | 387 ++++++++++++++++++ drivers/net/xsc/xsc_defs.h | 2 + drivers/net/xsc/xsc_vfio_mbox.c | 691 ++++++++++++++++++++++++++++++++ drivers/net/xsc/xsc_vfio_mbox.h | 142 +++++++ 5 files changed, 1223 insertions(+) create mode 100644 drivers/net/xsc/xsc_cmd.h create mode 100644 drivers/net/xsc/xsc_vfio_mbox.c create mode 100644 drivers/net/xsc/xsc_vfio_mbox.h
drivers/net/xsc/meson.build +1 -0
@@ -9,4 +9,5 @@ endif sources = files( 'xsc_ethdev.c', 'xsc_dev.c', + 'xsc_vfio_mbox.c', )
drivers/net/xsc/xsc_cmd.h new file +387 -0
387 lines not on this page · raw message
drivers/net/xsc/xsc_defs.h +2 -0
@@ -5,6 +5,8 @@#ifndef XSC_DEFS_H_ #define XSC_DEFS_H_ +#define XSC_PAGE_SIZE 4096 +#define XSC_PCI_VENDOR_ID 0x1f67#define XSC_PCI_DEV_ID_MS 0x1111#define XSC_PCI_DEV_ID_MSVF 0x1112
drivers/net/xsc/xsc_vfio_mbox.c new file +691 -0
691 lines not on this page · raw message
drivers/net/xsc/xsc_vfio_mbox.h new file +142 -0
142 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v6 03/15] net/xsc: add xsc mailbox
drivers/net/xsc/xsc_vfio_mbox.c line 147
Quoted 5 lines · On Mon, 20 Jan 2025 19:14:37 +0800 "WanRenyong" <[email protected]> wrote:
drivers/net/xsc/xsc_vfio_mbox.c new file +5
-0+static void +xsc_cmdq_mbox_free (struct xsc_dev *xdev,struct xsc_cmdq_mbox *mbox) +{ +struct xsc_cmdq_mbox *next, *head; +struct xsc_vfio_priv *priv = (struct xsc_vfio_priv *)xdev->dev_priv;
Since dev_priv is void *, the cast here is unnecessary in C
Re: [PATCH v6 03/15] net/xsc: add xsc mailbox
Quoted 9 lines · Stephen Hemminger
drivers/net/xsc/xsc_vfio_mbox.c line 147
Quoted 5 lines · On Mon, 20 Jan 2025 19:14:37 +0800 "WanRenyong" <[email protected]> wrote:
drivers/net/xsc/xsc_vfio_mbox.c new file +5
-0+static void +xsc_cmdq_mbox_free (struct xsc_dev *xdev,struct xsc_cmdq_mbox *mbox) +{ +struct xsc_cmdq_mbox *next, *head; +struct xsc_vfio_priv *priv = (struct xsc_vfio_priv *)xdev->dev_priv;Since
dev_privis void *, the cast here is unnecessary in C
OK, I'll fix it in the next version. Thanks for your review.
Signature · 2 lines
Best regards, WanRenyong
Re: [PATCH v6 03/15] net/xsc: add xsc mailbox
In reply to WanRenyongdrivers/net/xsc/xsc_vfio_mbox.c line 236
Quoted 8 lines · On Mon, 20 Jan 2025 19:14:37 +0800 "WanRenyong" <[email protected]> wrote:
drivers/net/xsc/xsc_vfio_mbox.c new file +8
-0+static struct xsc_cmdq_req_msg * +xsc_cmdq_req_msg_alloc (struct xsc_dev *xdev,int len) +{ +struct xsc_cmdq_req_msg *msg; +struct xsc_cmdq_mbox *head =NULL ; +int cmd_len, nb_mbox; + + msg = (struct xsc_cmdq_req_msg *)malloc (sizeof (*msg));
Malloc returns void *, so cast here is unnecessary in C
Re: [PATCH v6 03/15] net/xsc: add xsc mailbox
Quoted 12 lines · Stephen Hemminger
drivers/net/xsc/xsc_vfio_mbox.c line 236
Quoted 8 lines · On Mon, 20 Jan 2025 19:14:37 +0800 "WanRenyong" <[email protected]> wrote:
drivers/net/xsc/xsc_vfio_mbox.c new file +8
-0+static struct xsc_cmdq_req_msg * +xsc_cmdq_req_msg_alloc (struct xsc_dev *xdev,int len) +{ +struct xsc_cmdq_req_msg *msg; +struct xsc_cmdq_mbox *head =NULL ; +int cmd_len, nb_mbox; + + msg = (struct xsc_cmdq_req_msg *)malloc (sizeof (*msg));Malloc returns void *, so cast here is unnecessary in C
Thanks for your review.
I will address this issue and any similar issues elsewhere in the next version.
Signature · 2 lines
Best regards, WanRenyong
PATCH v6 4/15 net/xsc: add xsc dev ops to support VFIO driver
In reply to WanRenyongXSC PMD is designed to support both VFIO and private kernel drivers. This commit add xsc dev ops to support VFIO driver.
---
v6:
* Replace __rte_packed with __rte_packed_begin and __rte_packed_end.
v5:
* Using RTE_ETHER_ADDR_LEN instead of numeral 6.
* Initialize some local variables while be defined.
* Fix compilation warnings.
--- drivers/net/xsc/meson.build | 1 + drivers/net/xsc/xsc_defs.h | 8 + drivers/net/xsc/xsc_dev.h | 32 ++ drivers/net/xsc/xsc_rxtx.h | 102 +++++ drivers/net/xsc/xsc_vfio.c | 746 ++++++++++++++++++++++++++++++++++++ 5 files changed, 889 insertions(+) create mode 100644 drivers/net/xsc/xsc_rxtx.h create mode 100644 drivers/net/xsc/xsc_vfio.c
drivers/net/xsc/meson.build +1 -0
@@ -10,4 +10,5 @@ sources = files( 'xsc_ethdev.c', 'xsc_dev.c', 'xsc_vfio_mbox.c', + 'xsc_vfio.c', )
drivers/net/xsc/xsc_defs.h +8 -0
@@ -16,6 +16,14 @@#define XSC_VFREP_BASE_LOGICAL_PORT 1081 +#define XSC_PF_TX_DB_ADDR 0x4802000 +#define XSC_PF_RX_DB_ADDR 0x4804000 +#define XSC_PF_CQ_DB_ADDR 0x2120000 + +#define XSC_VF_RX_DB_ADDR 0x8d4 +#define XSC_VF_TX_DB_ADDR 0x8d0 +#define XSC_VF_CQ_DB_ADDR 0x8c4 +enum xsc_nic_mode {XSC_NIC_MODE_LEGACY ,XSC_NIC_MODE_SWITCHDEV ,
drivers/net/xsc/xsc_dev.h +32 -0
@@ -14,6 +14,7 @@#include "xsc_defs.h" #include "xsc_log.h" +#include "xsc_rxtx.h" #define XSC_PPH_MODE_ARG "pph_mode"#define XSC_NIC_MODE_ARG "nic_mode"
@@ -25,6 +26,18 @@#define XSC_DEV_PCT_IDX_INVALID 0xFFFFFFFF#define XSC_DEV_REPR_ID_INVALID 0x7FFFFFFF +enum xsc_queue_type { +XSC_QUEUE_TYPE_RDMA_RC =0 , +XSC_QUEUE_TYPE_RDMA_MAD =1 , +XSC_QUEUE_TYPE_RAW =2 , +XSC_QUEUE_TYPE_VIRTIO_NET =3 , +XSC_QUEUE_TYPE_VIRTIO_BLK =4 , +XSC_QUEUE_TYPE_RAW_TPE =5 , +XSC_QUEUE_TYPE_RAW_TSO =6 , +XSC_QUEUE_TYPE_RAW_TX =7 , +XSC_QUEUE_TYPE_INVALID =0xFF , +}; +struct xsc_hwinfo {uint32_t pcie_no;/* pcie number , 0 or 1 */ uint32_t func_id;/* pf glb func id */
@@ -120,6 +133,25 @@ struct xsc_dev_ops {enum rte_pci_kernel_driver kdrv;int (*dev_init)(struct xsc_dev *xdev);int (*dev_close)(struct xsc_dev *xdev); +int (*get_mac)(struct xsc_dev *xdev,uint8_t *mac); +int (*set_link_up)(struct xsc_dev *xdev); +int (*set_link_down)(struct xsc_dev *xdev); +int (*link_update)(struct xsc_dev *xdev,uint8_t funcid_type,int wait_to_complete); +int (*set_mtu)(struct xsc_dev *xdev,uint16_t mtu); +int (*destroy_qp)(void *qp); +int (*destroy_cq)(void *cq); +int (*modify_qp_status)(struct xsc_dev *xdev, +uint32_t qpn,int num,int opcode); +int (*modify_qp_qostree)(struct xsc_dev *xdev,uint16_t qpn); + +int (*rx_cq_create)(struct xsc_dev *xdev,struct xsc_rx_cq_params *cq_params, +struct xsc_rx_cq_info *cq_info); +int (*tx_cq_create)(struct xsc_dev *xdev,struct xsc_tx_cq_params *cq_params, +struct xsc_tx_cq_info *cq_info); +int (*tx_qp_create)(struct xsc_dev *xdev,struct xsc_tx_qp_params *qp_params, +struct xsc_tx_qp_info *qp_info); +int (*mailbox_exec)(struct xsc_dev *xdev,void *data_in, +int in_len,void *data_out,int out_len); };void xsc_dev_ops_register (struct xsc_dev_ops *new_ops);
drivers/net/xsc/xsc_rxtx.h new file +102 -0
102 lines not on this page · raw message
drivers/net/xsc/xsc_vfio.c new file +746 -0
746 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v6 5/15 net/xsc: add PCT interfaces
In reply to WanRenyongPCT is the abbreviation of Packet classifier table, which is built in NP to define behavior of various packets.
---
v6:
* Replace __rte_packed with __rte_packed_begin and __rte_packed_end.
--- drivers/net/xsc/meson.build | 1 + drivers/net/xsc/xsc_defs.h | 29 +++ drivers/net/xsc/xsc_dev.c | 19 +- drivers/net/xsc/xsc_dev.h | 3 + drivers/net/xsc/xsc_np.c | 492 ++++++++++++++++++++++++++++++++++++ drivers/net/xsc/xsc_np.h | 154 +++++++++++ 6 files changed, 697 insertions(+), 1 deletion(-) create mode 100644 drivers/net/xsc/xsc_np.c create mode 100644 drivers/net/xsc/xsc_np.h
drivers/net/xsc/meson.build +1 -0
@@ -11,4 +11,5 @@ sources = files( 'xsc_dev.c', 'xsc_vfio_mbox.c', 'xsc_vfio.c', + 'xsc_np.c', )
drivers/net/xsc/xsc_defs.h +29 -0
@@ -16,6 +16,26 @@#define XSC_VFREP_BASE_LOGICAL_PORT 1081 +#define XSC_RSS_HASH_KEY_LEN 52 +#define XSC_RSS_HASH_BIT_IPV4_SIP (1ULL << 0) +#define XSC_RSS_HASH_BIT_IPV4_DIP (1ULL << 1) +#define XSC_RSS_HASH_BIT_IPV6_SIP (1ULL << 2) +#define XSC_RSS_HASH_BIT_IPV6_DIP (1ULL << 3) +#define XSC_RSS_HASH_BIT_IPV4_SPORT (1ULL << 4) +#define XSC_RSS_HASH_BIT_IPV4_DPORT (1ULL << 5) +#define XSC_RSS_HASH_BIT_IPV6_SPORT (1ULL << 6) +#define XSC_RSS_HASH_BIT_IPV6_DPORT (1ULL << 7) +#define XSC_RSS_HASH_BIT_TNL_ID (1ULL << 8) +#define XSC_RSS_HASH_BIT_NXT_PRO (1ULL << 9) + +#define XSC_EPAT_VLD_FLAG (1ULL) +#define XSC_EPAT_RX_QP_ID_OFST_FLAG (1ULL << 2) +#define XSC_EPAT_QP_NUM_FLAG (1ULL << 3) +#define XSC_EPAT_RSS_EN_FLAG (1ULL << 4) +#define XSC_EPAT_RSS_HASH_TEMPLATE_FLAG (1ULL << 5) +#define XSC_EPAT_RSS_HASH_FUNC_FLAG (1ULL << 6) +#define XSC_EPAT_HAS_PPH_FLAG (1ULL << 9) +#define XSC_PF_TX_DB_ADDR 0x4802000#define XSC_PF_RX_DB_ADDR 0x4804000#define XSC_PF_CQ_DB_ADDR 0x2120000
@@ -38,4 +58,13 @@ enum xsc_pph_type { XSC_UPLINK_PPH = 0x8, }; +enum xsc_port_type { +XSC_PORT_TYPE_NONE =0 , +XSC_PORT_TYPE_UPLINK , +XSC_PORT_TYPE_UPLINK_BOND , +XSC_PORT_TYPE_PFVF , +XSC_PORT_TYPE_PFHPF , +XSC_PORT_TYPE_UNKNOWN , +}; +#endif /* XSC_DEFS_H_ */
drivers/net/xsc/xsc_dev.c +18 -1
@@ -54,8 +54,17 @@ xsc_dev_ops_register(struct xsc_dev_ops *new_ops) }int -xsc_dev_close(struct xsc_dev *xdev, int __rte_unused repr_id) +xsc_dev_mailbox_exec (struct xsc_dev *xdev,void *data_in, +int in_len,void *data_out,int out_len) { +return xdev->dev_ops->mailbox_exec (xdev, data_in, in_len, + data_out, out_len); +} + +int +xsc_dev_close (struct xsc_dev *xdev,int repr_id) +{ +xsc_dev_clear_pct (xdev, repr_id);return xdev->dev_ops->dev_close (xdev); }
@@ -121,6 +130,7 @@ void xsc_dev_uninit(struct xsc_dev *xdev) {PMD_INIT_FUNC_TRACE (); +xsc_dev_pct_uninit ();xsc_dev_close (xdev,XSC_DEV_REPR_ID_INVALID );rte_free (xdev); }
@@ -159,6 +169,13 @@ xsc_dev_init(struct rte_pci_device *pci_dev, struct xsc_dev **xdev) goto hwinfo_init_fail; } + ret =xsc_dev_pct_init (); +if (ret) { +PMD_DRV_LOG (ERR ,"Failed to init xsc pct" ); + ret = -EINVAL ; + goto hwinfo_init_fail; + } + *xdev = d;return 0 ;
drivers/net/xsc/xsc_dev.h +3 -0
@@ -15,6 +15,7 @@#include "xsc_defs.h" #include "xsc_log.h" #include "xsc_rxtx.h" +#include "xsc_np.h" #define XSC_PPH_MODE_ARG "pph_mode"#define XSC_NIC_MODE_ARG "nic_mode"
@@ -154,6 +155,8 @@ struct xsc_dev_ops { int in_len, void *data_out, int out_len); }; +int xsc_dev_mailbox_exec (struct xsc_dev *xdev,void *data_in, +int in_len,void *data_out,int out_len);void xsc_dev_ops_register (struct xsc_dev_ops *new_ops);int xsc_dev_init (struct rte_pci_device *pci_dev,struct xsc_dev **dev);void xsc_dev_uninit (struct xsc_dev *xdev);
drivers/net/xsc/xsc_np.c new file +492 -0
492 lines not on this page · raw message
drivers/net/xsc/xsc_np.h new file +154 -0
154 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v6 05/15] net/xsc: add PCT interfaces
drivers/net/xsc/xsc_np.c line 265
Quoted 9 lines · On Mon, 20 Jan 2025 19:14:42 +0800 "WanRenyong" <[email protected]> wrote:
drivers/net/xsc/xsc_np.c new file +9
-0+int +xsc_dev_create_ipat (struct xsc_dev *xdev,uint16_t logic_in_port,uint16_t dst_info) +{ +struct xsc_np_ipat add; + +memset (&add,0 ,sizeof (add)); + add.key.logical_in_port = logic_in_port; + add.action.dst_info = dst_info; + add.action.vld =1 ;
You could use initializer here, and avoid a few steps:
struct xsd_np_ipat add = {
.key.logical_in_port = logic_in_port,
.action = {
.dst_info = dst_info,
.vlid = 1,
},
};And several other places.
This is purely a suggestion, either way is fine will accept it either way.
Re: [PATCH v6 05/15] net/xsc: add PCT interfaces
Quoted 22 lines · Stephen Hemminger
drivers/net/xsc/xsc_np.c line 265
Quoted 9 lines · On Mon, 20 Jan 2025 19:14:42 +0800 "WanRenyong" <[email protected]> wrote:
drivers/net/xsc/xsc_np.c new file +9
-0+int +xsc_dev_create_ipat (struct xsc_dev *xdev,uint16_t logic_in_port,uint16_t dst_info) +{ +struct xsc_np_ipat add; + +memset (&add,0 ,sizeof (add)); + add.key.logical_in_port = logic_in_port; + add.action.dst_info = dst_info; + add.action.vld =1 ;You could use initializer here, and avoid a few steps:
struct xsd_np_ipat add = { .key.logical_in_port = logic_in_port, .action = { .dst_info = dst_info, .vlid = 1, }, };
Quoted 3 lines
And several other places.
This is purely a suggestion, either way is fine will accept it either way.
Hello, Stephen Hemminger,
Thanks for your suggestion, I don't plan to address this issue.
Signature · 2 lines
Best regards, WanRenyong
PATCH v6 6/15 net/xsc: initialize xsc representors
In reply to WanRenyongFor the design of the xsc PMD, each ethdev corresponds to a representor.
--- drivers/net/xsc/xsc_defs.h | 11 +++ drivers/net/xsc/xsc_dev.c | 95 ++++++++++++++++++++ drivers/net/xsc/xsc_dev.h | 3 + drivers/net/xsc/xsc_ethdev.c | 170 +++++++++++++++++++++++++++++++++++ drivers/net/xsc/xsc_ethdev.h | 19 ++++ 5 files changed, 298 insertions(+)
drivers/net/xsc/xsc_defs.h +11 -0
@@ -6,6 +6,7 @@#define XSC_DEFS_H_ #define XSC_PAGE_SIZE 4096 +#define XSC_PHY_PORT_NUM 1#define XSC_PCI_VENDOR_ID 0x1f67#define XSC_PCI_DEV_ID_MS 0x1111
@@ -15,6 +16,7 @@#define XSC_PCI_DEV_ID_MVS 0x1153#define XSC_VFREP_BASE_LOGICAL_PORT 1081 +#define XSC_MAX_MAC_ADDRESSES 3#define XSC_RSS_HASH_KEY_LEN 52#define XSC_RSS_HASH_BIT_IPV4_SIP (1ULL << 0)
@@ -58,6 +60,15 @@ enum xsc_pph_type { XSC_UPLINK_PPH = 0x8, }; +enum xsc_funcid_type { +XSC_FUNCID_TYPE_INVAL =0x0 , +XSC_EMU_FUNCID =0x1 , +XSC_PHYPORT_MAC_FUNCID =0x2 , +XSC_VF_IOCTL_FUNCID =0x3 , +XSC_PHYPORT_LAG_FUNCID =0x4 , +XSC_FUNCID_TYPE_UNKNOWN =0x5 , +}; +enum xsc_port_type {XSC_PORT_TYPE_NONE =0 ,XSC_PORT_TYPE_UPLINK ,
drivers/net/xsc/xsc_dev.c +95 -0
107 lines not on this page · raw message
drivers/net/xsc/xsc_dev.h +3 -0
@@ -161,6 +161,9 @@ void xsc_dev_ops_register(struct xsc_dev_ops *new_ops);int xsc_dev_init (struct rte_pci_device *pci_dev,struct xsc_dev **dev);void xsc_dev_uninit (struct xsc_dev *xdev);int xsc_dev_close (struct xsc_dev *xdev,int repr_id); +int xsc_dev_repr_ports_probe (struct xsc_dev *xdev,int nb_repr_ports,int max_eth_ports);bool xsc_dev_is_vf (struct xsc_dev *xdev); +int xsc_dev_qp_set_id_get (struct xsc_dev *xdev,int repr_id); +int xsc_dev_get_mac (struct xsc_dev *xdev,uint8_t *mac);#endif /* _XSC_DEV_H_ */
drivers/net/xsc/xsc_ethdev.c +170 -0
183 lines not on this page · raw message
drivers/net/xsc/xsc_ethdev.h +19 -0
@@ -11,6 +11,25 @@ struct xsc_ethdev_priv {struct rte_eth_dev *eth_dev;struct rte_pci_device *pci_dev;struct xsc_dev *xdev; +struct xsc_repr_port *repr_port; +struct xsc_dev_config config; +struct rte_eth_dev_data *dev_data; +struct rte_ether_addr mac[XSC_MAX_MAC_ADDRESSES ]; +struct rte_eth_rss_conf rss_conf; + +int representor_id; +uint32_t ifindex; +uint16_t mtu; +uint8_t isolated; +uint8_t is_representor; + + uint32_t mode:7; + uint32_t member_bitmap:8; + uint32_t funcid_type:3; + uint32_t funcid:14; + +uint16_t eth_type; +uint16_t qp_set_id; };#define TO_XSC_ETHDEV_PRIV (dev) ((struct xsc_ethdev_priv *)(dev)->data->dev_private)
Signature · 1 line
2.25.1
Re: [PATCH v6 06/15] net/xsc: initialize xsc representors
Quoted 35 lines · On Mon, 20 Jan 2025 19:14:44 +0800 "WanRenyong" <[email protected]> wrote:
(quoted diff) +35
-0+static int +xsc_ethdev_init_representors(struct rte_eth_dev *eth_dev) +{ + struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(eth_dev); + struct rte_eth_devargs eth_da = { .nb_representor_ports = 0 }; + struct rte_device *dev; + struct xsc_dev *xdev; + struct xsc_repr_port *repr_port; + char name[RTE_ETH_NAME_MAX_LEN]; + int i; + int ret; + + PMD_INIT_FUNC_TRACE(); + + dev = &priv->pci_dev->device; + if (dev->devargs != NULL) { + ret = rte_eth_devargs_parse(dev->devargs->args, ð_da, 1); + if (ret < 0) { + PMD_DRV_LOG(ERR, "Failed to parse device arguments: %s", + dev->devargs->args); + return -EINVAL; + } + } + + xdev = priv->xdev; + ret = xsc_dev_repr_ports_probe(xdev, eth_da.nb_representor_ports, RTE_MAX_ETHPORTS); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Failed to probe %d xsc device representors", + eth_da.nb_representor_ports); + return ret; + } + + /* PF rep init */ + repr_port = &xdev->repr_ports[xdev->num_repr_ports - 1]; + ret = xsc_ethdev_init_one_representor(eth_dev, repr_port);
Review
Quoted 10 lines
(quoted diff) +10
-0+ if (ret != 0) { + PMD_DRV_LOG(ERR, "Failed to init backing representor"); + return ret; + } + + /* VF rep init */ + for (i = 0; i < eth_da.nb_representor_ports; i++) { + repr_port = &xdev->repr_ports[i]; + snprintf(name, sizeof(name), "%s_rep_%d", + xdev->name, repr_port->info.repr_id);
If I enable format-truncation warnings then there is this message. The warning is suppressed by drivers/meson.build, but would like in the future to not disable warnings there.
../drivers/net/xsc/xsc_ethdev.c: In function ‘xsc_ethdev_init’:../drivers/net/xsc/xsc_ethdev.c:787:49: warning: ‘_rep_’ directive output may be truncated writing 5 bytes into a region of size between 1 and 64 [-Wformat-truncation=]
787 | snprintf(name, sizeof(name), "%s_rep_%d",
| ^~~~~
In function ‘xsc_ethdev_init_representors’,
inlined from ‘xsc_ethdev_init’ at ../drivers/net/xsc/xsc_ethdev.c:834:8:../drivers/net/xsc/xsc_ethdev.c:787:17: note: ‘snprintf’ output between 7 and 80 bytes into a destination of size 64
787 | snprintf(name, sizeof(name), "%s_rep_%d",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
788 | xdev->name, repr_port->info.repr_id);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~This is because local variable name is of size RTE_ETH_NAME_MAX_LEN which is 64 and xdev->name is defined as RTE_ETH_NAME_MAX_LEN as well.
The warning is correct but impossible to happen since xdev->name is only filled in with PCI information. A simple way to get rid of it (and save some space) would be to define name to be for PCI address only.
Would this work?
drivers/net/xsc/xsc_dev.h +1 -1
@@ -121,7 +121,7 @@ struct xsc_dev {int ifindex;int port_id;/* Probe dev */ void *dev_priv; -char name[RTE_ETH_NAME_MAX_LEN ]; +char name[PCI_PRI_STR_SIZE ];void *bar_addr;void *jumbo_buffer_pa;void *jumbo_buffer_va;
Re: [PATCH v6 06/15] net/xsc: initialize xsc representors
Quoted 78 lines · Stephen Hemminger
Quoted 35 lines · On Mon, 20 Jan 2025 19:14:44 +0800 "WanRenyong" <[email protected]> wrote:
(quoted diff) +35
-0+static int +xsc_ethdev_init_representors(struct rte_eth_dev *eth_dev) +{ + struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(eth_dev); + struct rte_eth_devargs eth_da = { .nb_representor_ports = 0 }; + struct rte_device *dev; + struct xsc_dev *xdev; + struct xsc_repr_port *repr_port; + char name[RTE_ETH_NAME_MAX_LEN]; + int i; + int ret; + + PMD_INIT_FUNC_TRACE(); + + dev = &priv->pci_dev->device; + if (dev->devargs != NULL) { + ret = rte_eth_devargs_parse(dev->devargs->args, ð_da, 1); + if (ret < 0) { + PMD_DRV_LOG(ERR, "Failed to parse device arguments: %s", + dev->devargs->args); + return -EINVAL; + } + } + + xdev = priv->xdev; + ret = xsc_dev_repr_ports_probe(xdev, eth_da.nb_representor_ports, RTE_MAX_ETHPORTS); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Failed to probe %d xsc device representors", + eth_da.nb_representor_ports); + return ret; + } + + /* PF rep init */ + repr_port = &xdev->repr_ports[xdev->num_repr_ports - 1]; + ret = xsc_ethdev_init_one_representor(eth_dev, repr_port);Review
Quoted 10 lines
(quoted diff) +10
-0+ if (ret != 0) { + PMD_DRV_LOG(ERR, "Failed to init backing representor"); + return ret; + } + + /* VF rep init */ + for (i = 0; i < eth_da.nb_representor_ports; i++) { + repr_port = &xdev->repr_ports[i]; + snprintf(name, sizeof(name), "%s_rep_%d", + xdev->name, repr_port->info.repr_id);If I enable format-truncation warnings then there is this message. The warning is suppressed by
drivers/meson.build, but would like in the future to not disable warnings there.
../drivers/net/xsc/xsc_ethdev.c: In function ‘xsc_ethdev_init’:../drivers/net/xsc/xsc_ethdev.c:787:49: warning: ‘_rep_’ directive output may be truncated writing 5 bytes into a region of size between 1 and 64 [-Wformat-truncation=]
787 | snprintf(name, sizeof(name), "%s_rep_%d",
| ^~~~~
In function ‘xsc_ethdev_init_representors’,
inlined from ‘xsc_ethdev_init’ at../drivers/net/xsc/xsc_ethdev.c:834:8:../drivers/net/xsc/xsc_ethdev.c:787:17: note: ‘snprintf’ output between 7 and 80 bytes into a destination of size 64787 | snprintf(name, sizeof(name), "%s_rep_%d", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 788 | xdev->name, repr_port->info.repr_id); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~This is because local variable name is of size
RTE_ETH_NAME_MAX_LENwhich is 64 andxdev->nameis defined asRTE_ETH_NAME_MAX_LENas well.
The warning is correct but impossible to happen sincexdev->nameis only filled in with PCI information. A simple way to get rid of it (and save some space) would be to define name to be for PCI address only.Would this work?
drivers/net/xsc/xsc_dev.h +0
-0
drivers/net/xsc/xsc_dev.h struct xsc_dev { · line 127
Quoted 8 lines
drivers/net/xsc/xsc_dev.h +1
-1@@ -121,7 +121,7 @@ struct xsc_dev {int ifindex;int port_id;/* Probe dev */ void *dev_priv; -char name[RTE_ETH_NAME_MAX_LEN ]; +char name[PCI_PRI_STR_SIZE ];void *bar_addr;void *jumbo_buffer_pa;void *jumbo_buffer_va;
Hello Stephen Hemminger,
Thanks for your review.
Your suggestion is correct. In fact, xdev->name is initialized to the PCI address , it will work if size of xdev->name defined as PCI_PRI_STR_SIZE. I will modify it in the next version.
Signature · 2 lines
Best regards, WanRenyong
PATCH v6 7/15 net/xsc: add ethdev configure and RSS ops
In reply to WanRenyongImplement xsc ethdev configure and RSS hash functions.
---
v6:
* Use memcpy instead of rte_memcpy.
v5:
* Remove some unnecessary parameter checks.
--- doc/guides/nics/features/xsc.ini | 3 ++ drivers/net/xsc/xsc_defs.h | 15 ++++++ drivers/net/xsc/xsc_dev.c | 26 ++++++++++ drivers/net/xsc/xsc_dev.h | 1 + drivers/net/xsc/xsc_ethdev.c | 82 ++++++++++++++++++++++++++++++++ drivers/net/xsc/xsc_ethdev.h | 7 +++ 6 files changed, 134 insertions(+)
doc/guides/nics/features/xsc.ini +3 -0
@@ -4,6 +4,9 @@ ; Refer to default.ini for the full list of available PMD features. ; [Features] +RSS hash = Y +RSS key update = Y +RSS reta update = Y Linux = Y ARMv8 = Y x86-64 = Y
drivers/net/xsc/xsc_defs.h +15 -0
@@ -78,4 +78,19 @@ enum xsc_port_type { XSC_PORT_TYPE_UNKNOWN, }; +enum xsc_tbm_cap { +XSC_TBM_CAP_HASH_PPH =0 , +XSC_TBM_CAP_RSS , +XSC_TBM_CAP_PP_BYPASS , +XSC_TBM_CAP_PCT_DROP_CONFIG , +}; + +enum xsc_rss_hf { +XSC_RSS_HASH_KEY_UPDATE =0 , +XSC_RSS_HASH_TEMP_UPDATE , +XSC_RSS_HASH_FUNC_UPDATE , +XSC_RSS_RXQ_UPDATE , +XSC_RSS_RXQ_DROP , +}; +#endif /* XSC_DEFS_H_ */
drivers/net/xsc/xsc_dev.c +26 -0
@@ -19,6 +19,7 @@#include "xsc_log.h" #include "xsc_defs.h" #include "xsc_dev.h" +#include "xsc_cmd.h" #define XSC_DEV_DEF_FLOW_MODE 7
@@ -74,6 +75,31 @@ xsc_dev_close(struct xsc_dev *xdev, int repr_id)return xdev->dev_ops->dev_close (xdev); } +int +xsc_dev_rss_key_modify (struct xsc_dev *xdev,uint8_t *rss_key,uint8_t rss_key_len) +{ +struct xsc_cmd_modify_nic_hca_mbox_in in = {}; +struct xsc_cmd_modify_nic_hca_mbox_out out = {}; +uint8_t rss_caps_mask =0 ; +int ret, key_len =0 ; + + in.hdr.opcode =rte_cpu_to_be_16 (XSC_CMD_OP_MODIFY_NIC_HCA ); + + key_len =RTE_MIN (rss_key_len,XSC_RSS_HASH_KEY_LEN ); +rte_memcpy (in.rss.hash_key, rss_key, key_len); + rss_caps_mask |=RTE_BIT32 (XSC_RSS_HASH_KEY_UPDATE ); + + in.rss.caps_mask = rss_caps_mask; + in.rss.rss_en =1 ; + in.nic.caps_mask =rte_cpu_to_be_16 (RTE_BIT32 (XSC_TBM_CAP_RSS )); + in.nic.caps = in.nic.caps_mask; + + ret =xsc_dev_mailbox_exec (xdev, &in,sizeof (in), &out,sizeof (out)); +if (ret !=0 || out.hdr.status !=0 ) +return -1 ; +return 0 ; +} +static int xsc_dev_alloc_vfos_info (struct xsc_dev *xdev) {
drivers/net/xsc/xsc_dev.h +1 -0
@@ -162,6 +162,7 @@ int xsc_dev_init(struct rte_pci_device *pci_dev, struct xsc_dev **dev);void xsc_dev_uninit (struct xsc_dev *xdev);int xsc_dev_close (struct xsc_dev *xdev,int repr_id);int xsc_dev_repr_ports_probe (struct xsc_dev *xdev,int nb_repr_ports,int max_eth_ports); +int xsc_dev_rss_key_modify (struct xsc_dev *xdev,uint8_t *rss_key,uint8_t rss_key_len);bool xsc_dev_is_vf (struct xsc_dev *xdev);int xsc_dev_qp_set_id_get (struct xsc_dev *xdev,int repr_id);int xsc_dev_get_mac (struct xsc_dev *xdev,uint8_t *mac);
drivers/net/xsc/xsc_ethdev.c +82 -0
100 lines not on this page · raw message
drivers/net/xsc/xsc_ethdev.h +7 -0
@@ -30,6 +30,13 @@ struct xsc_ethdev_priv {uint16_t eth_type;uint16_t qp_set_id; + +uint16_t num_sq; +uint16_t num_rq; + +uint16_t flags; +struct xsc_txq_data *(*txqs)[]; +struct xsc_rxq_data *(*rxqs)[]; };#define TO_XSC_ETHDEV_PRIV (dev) ((struct xsc_ethdev_priv *)(dev)->data->dev_private)
Signature · 1 line
2.25.1
PATCH v6 8/15 net/xsc: add Rx and Tx queue setup
In reply to WanRenyongImplement xsc ethdev Rx and Tx queue setup functions.
---
v6:
* Replace __rte_packed with __rte_packed_begin and __rte_packed_end.
--- drivers/net/xsc/xsc_defs.h | 4 ++ drivers/net/xsc/xsc_ethdev.c | 83 ++++++++++++++++++++++++++++++++++++ drivers/net/xsc/xsc_rx.h | 59 +++++++++++++++++++++++++ drivers/net/xsc/xsc_rxtx.h | 49 +++++++++++++++++++++ drivers/net/xsc/xsc_tx.h | 55 ++++++++++++++++++++++++ 5 files changed, 250 insertions(+) create mode 100644 drivers/net/xsc/xsc_rx.h create mode 100644 drivers/net/xsc/xsc_tx.h
drivers/net/xsc/xsc_defs.h +4 -0
@@ -38,6 +38,10 @@#define XSC_EPAT_RSS_HASH_FUNC_FLAG (1ULL << 6)#define XSC_EPAT_HAS_PPH_FLAG (1ULL << 9) +#define XSC_MAX_DESC_NUMBER 1024 +#define XSC_SEND_WQE_DS 3 +#define XSC_ESEG_EXTRA_DATA_SIZE 48u +#define XSC_PF_TX_DB_ADDR 0x4802000#define XSC_PF_RX_DB_ADDR 0x4804000#define XSC_PF_CQ_DB_ADDR 0x2120000
drivers/net/xsc/xsc_ethdev.c +83 -0
101 lines not on this page · raw message
drivers/net/xsc/xsc_rx.h new file +59 -0
59 lines not on this page · raw message
drivers/net/xsc/xsc_rxtx.h +49 -0
67 lines not on this page · raw message
drivers/net/xsc/xsc_tx.h new file +55 -0
55 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v6 08/15] net/xsc: add Rx and Tx queue setup
Quoted 13 lines · On Mon, 20 Jan 2025 19:14:48 +0800 "WanRenyong" <[email protected]> wrote:
drivers/net/xsc/xsc_rxtx.h +13
-0+struct __rte_packed_begin xsc_send_wqe_ctrl_seg { + rte_le32_t msg_opcode:8; + rte_le32_t with_immdt:1; + rte_le32_t csum_en:2; + rte_le32_t ds_data_num:5; + rte_le32_t wqe_id:16; + rte_le32_t msg_len; + union __rte_packed_begin { + rte_le32_t opcode_data; + struct __rte_packed_begin { + rte_le16_t has_pph:1; + rte_le16_t so_type:1; + rte_le16_t so_data_size:14;
drivers/net/xsc/xsc_rxtx.h line 38
Quoted 10 lines
drivers/net/xsc/xsc_rxtx.h +10
-0+ rte_le16_t rsv1:8; + rte_le16_t so_hdr_len:8; + } __rte_packed_end; +struct __rte_packed_begin { +rte_le16_t desc_id; +rte_le16_t is_last_wqe:1 ; +rte_le16_t dst_qp_id:15 ; + } __rte_packed_end; + } __rte_packed_end; + rte_le32_t se:1;
If the whole structure is marked with packed attribute, don't think you also need to mark the sub structures and unions as packed.
This is what is confusing the checkpatch check for __rte_packed_begin / __rte_packed_end
Re: [PATCH v6 08/15] net/xsc: add Rx and Tx queue setup
Quoted 30 lines · Stephen Hemminger
Quoted 13 lines · On Mon, 20 Jan 2025 19:14:48 +0800 "WanRenyong" <[email protected]> wrote:
drivers/net/xsc/xsc_rxtx.h +13
-0+struct __rte_packed_begin xsc_send_wqe_ctrl_seg { + rte_le32_t msg_opcode:8; + rte_le32_t with_immdt:1; + rte_le32_t csum_en:2; + rte_le32_t ds_data_num:5; + rte_le32_t wqe_id:16; + rte_le32_t msg_len; + union __rte_packed_begin { + rte_le32_t opcode_data; + struct __rte_packed_begin { + rte_le16_t has_pph:1; + rte_le16_t so_type:1; + rte_le16_t so_data_size:14;drivers/net/xsc/xsc_rxtx.h line 38
Quoted 10 lines
drivers/net/xsc/xsc_rxtx.h +10
-0+ rte_le16_t rsv1:8; + rte_le16_t so_hdr_len:8; + } __rte_packed_end; +struct __rte_packed_begin { +rte_le16_t desc_id; +rte_le16_t is_last_wqe:1 ; +rte_le16_t dst_qp_id:15 ; + } __rte_packed_end; + } __rte_packed_end; + rte_le32_t se:1;If the whole structure is marked with packed attribute, don't think you also need to mark the sub structures and unions as packed.
Quoted 1 line
This is what is confusing the checkpatch check for
__rte_packed_begin/__rte_packed_end
Hello, Stephen Hemminger,
Thanks for your review.
Initially, we did not mark sub structures and unions with the packed attribute. However, when we encountered checkpatch errors due to unmatched|__rte_packed_begin|/|__rte_packed_end|pairs,
we referred to other PMD codes in DPDK and marked the sub structures and unions with the packed attribute as well. Unfortunately, this did not resolve the checkpatch errors.
I think that might be a bug in the|checkpatch|tool, so I have submitted a patch to address this issue:https://inbox.dpdk.org/dev/[email protected]/.
Regardless, I will remove the packed attribute from sub structures and unions in the next verion.
Signature · 2 lines
Best regards, WanRenyong
PATCH v6 9/15 net/xsc: add ethdev start
In reply to WanRenyongImplement xsc ethdev start function.
---
v5:
* Remove unnecessary call of rte_wmb.
--- drivers/net/xsc/meson.build | 2 + drivers/net/xsc/xsc_dev.c | 33 ++++ drivers/net/xsc/xsc_dev.h | 8 + drivers/net/xsc/xsc_ethdev.c | 172 +++++++++++++++++++++ drivers/net/xsc/xsc_ethdev.h | 19 +++ drivers/net/xsc/xsc_rx.c | 291 +++++++++++++++++++++++++++++++++++ drivers/net/xsc/xsc_rx.h | 3 + drivers/net/xsc/xsc_rxtx.h | 27 ++++ drivers/net/xsc/xsc_tx.c | 93 +++++++++++ drivers/net/xsc/xsc_tx.h | 4 + 10 files changed, 652 insertions(+) create mode 100644 drivers/net/xsc/xsc_rx.c create mode 100644 drivers/net/xsc/xsc_tx.c
drivers/net/xsc/meson.build +2 -0
@@ -12,4 +12,6 @@ sources = files( 'xsc_vfio_mbox.c', 'xsc_vfio.c', 'xsc_np.c', + 'xsc_rx.c', + 'xsc_tx.c', )
drivers/net/xsc/xsc_dev.c +33 -0
@@ -68,6 +68,39 @@ xsc_dev_get_mac(struct xsc_dev *xdev, uint8_t *mac)return xdev->dev_ops->get_mac (xdev, mac); } +int +xsc_dev_modify_qp_status (struct xsc_dev *xdev,uint32_t qpn,int num,int opcode) +{ +return xdev->dev_ops->modify_qp_status (xdev, qpn, num, opcode); +} + +int +xsc_dev_modify_qp_qostree (struct xsc_dev *xdev,uint16_t qpn) +{ +return xdev->dev_ops->modify_qp_qostree (xdev, qpn); +} + +int +xsc_dev_rx_cq_create (struct xsc_dev *xdev,struct xsc_rx_cq_params *cq_params, +struct xsc_rx_cq_info *cq_info) +{ +return xdev->dev_ops->rx_cq_create (xdev, cq_params, cq_info); +} + +int +xsc_dev_tx_cq_create (struct xsc_dev *xdev,struct xsc_tx_cq_params *cq_params, +struct xsc_tx_cq_info *cq_info) +{ +return xdev->dev_ops->tx_cq_create (xdev, cq_params, cq_info); +} + +int +xsc_dev_tx_qp_create (struct xsc_dev *xdev,struct xsc_tx_qp_params *qp_params, +struct xsc_tx_qp_info *qp_info) +{ +return xdev->dev_ops->tx_qp_create (xdev, qp_params, qp_info); +} +int xsc_dev_close (struct xsc_dev *xdev,int repr_id) {
drivers/net/xsc/xsc_dev.h +8 -0
@@ -158,6 +158,14 @@ struct xsc_dev_ops {int xsc_dev_mailbox_exec (struct xsc_dev *xdev,void *data_in,int in_len,void *data_out,int out_len);void xsc_dev_ops_register (struct xsc_dev_ops *new_ops); +int xsc_dev_modify_qp_status (struct xsc_dev *xdev,uint32_t qpn,int num,int opcode); +int xsc_dev_modify_qp_qostree (struct xsc_dev *xdev,uint16_t qpn); +int xsc_dev_rx_cq_create (struct xsc_dev *xdev,struct xsc_rx_cq_params *cq_params, +struct xsc_rx_cq_info *cq_info); +int xsc_dev_tx_cq_create (struct xsc_dev *xdev,struct xsc_tx_cq_params *cq_params, +struct xsc_tx_cq_info *cq_info); +int xsc_dev_tx_qp_create (struct xsc_dev *xdev,struct xsc_tx_qp_params *qp_params, +struct xsc_tx_qp_info *qp_info);int xsc_dev_init (struct rte_pci_device *pci_dev,struct xsc_dev **dev);void xsc_dev_uninit (struct xsc_dev *xdev);int xsc_dev_close (struct xsc_dev *xdev,int repr_id);
drivers/net/xsc/xsc_ethdev.c +172 -0
190 lines not on this page · raw message
drivers/net/xsc/xsc_ethdev.h +19 -0
@@ -7,6 +7,9 @@#include "xsc_dev.h" +#define XSC_FLAG_RX_QUEUE_INIT 0x1 +#define XSC_FLAG_TX_QUEUE_INIT 0x2 +struct xsc_ethdev_priv {struct rte_eth_dev *eth_dev;struct rte_pci_device *pci_dev;
@@ -41,4 +44,20 @@ struct xsc_ethdev_priv {#define TO_XSC_ETHDEV_PRIV (dev) ((struct xsc_ethdev_priv *)(dev)->data->dev_private) +static __rte_always_inline struct xsc_txq_data * +xsc_txq_get (struct xsc_ethdev_priv *priv,uint16_t idx) +{ +if (priv->txqs !=NULL && (*priv->txqs)[idx] !=NULL ) +return (*priv->txqs)[idx]; +return NULL ; +} + +static __rte_always_inline struct xsc_rxq_data * +xsc_rxq_get (struct xsc_ethdev_priv *priv,uint16_t idx) +{ +if (priv->rxqs !=NULL && (*priv->rxqs)[idx] !=NULL ) +return (*priv->rxqs)[idx]; +return NULL ; +} +#endif /* _XSC_ETHDEV_H_ */
drivers/net/xsc/xsc_rx.c new file +291 -0
291 lines not on this page · raw message
drivers/net/xsc/xsc_rx.h +3 -0
@@ -56,4 +56,7 @@ struct __rte_cache_aligned xsc_rxq_data { uint16_t rsv1:11; }; +int xsc_rxq_elts_alloc (struct xsc_rxq_data *rxq_data); +int xsc_rxq_rss_obj_new (struct xsc_ethdev_priv *priv,uint16_t port_id); +#endif /* _XSC_RX_H_ */
drivers/net/xsc/xsc_rxtx.h +27 -0
@@ -102,6 +102,24 @@ struct xsc_cqe_u64 {struct xsc_cqe cqe1; }; +union xsc_cq_doorbell { +struct { +uint32_t next_cid:16 ; +uint32_t cq_num:15 ; +uint32_t cq_sta:1 ; + }; +uint32_t cq_data; +}; + +union xsc_send_doorbell { +struct { +uint32_t next_pid:16 ; +uint32_t qp_num:15 ; +uint32_t rsv:1 ; + }; +uint32_t send_data; +}; +struct xsc_tx_cq_params {uint16_t port_id;uint16_t qp_id;
@@ -134,6 +152,15 @@ struct xsc_tx_qp_info {uint16_t wqe_n; }; +union xsc_recv_doorbell { +struct { +uint32_t next_pid:13 ; +uint32_t qp_num:15 ; +uint32_t rsv:4 ; + }; +uint32_t recv_data; +}; +struct xsc_rx_cq_params {uint16_t port_id;uint16_t qp_id;
drivers/net/xsc/xsc_tx.c new file +93 -0
93 lines not on this page · raw message
drivers/net/xsc/xsc_tx.h +4 -0
@@ -52,4 +52,8 @@ struct __rte_cache_aligned xsc_txq_data { struct rte_mbuf *elts[]; /* Storage for queued packets, for free */ }; +int xsc_txq_obj_new (struct xsc_dev *xdev,struct xsc_txq_data *txq_data, +uint64_t offloads,uint16_t idx); +void xsc_txq_elts_alloc (struct xsc_txq_data *txq_data); +#endif /* _XSC_TX_H_ */
Signature · 1 line
2.25.1
PATCH v6 10/15 net/xsc: add ethdev stop and close
In reply to WanRenyongImplement xsc ethdev close and stop functions.
--- drivers/net/xsc/xsc_dev.c | 12 ++++ drivers/net/xsc/xsc_dev.h | 2 + drivers/net/xsc/xsc_ethdev.c | 108 +++++++++++++++++++++++++++++++++++ drivers/net/xsc/xsc_rx.c | 47 +++++++++++++++ drivers/net/xsc/xsc_rx.h | 2 + drivers/net/xsc/xsc_tx.c | 33 +++++++++++ drivers/net/xsc/xsc_tx.h | 2 + 7 files changed, 206 insertions(+)
drivers/net/xsc/xsc_dev.c +12 -0
@@ -68,6 +68,18 @@ xsc_dev_get_mac(struct xsc_dev *xdev, uint8_t *mac)return xdev->dev_ops->get_mac (xdev, mac); } +int +xsc_dev_destroy_qp (struct xsc_dev *xdev,void *qp) +{ +return xdev->dev_ops->destroy_qp (qp); +} + +int +xsc_dev_destroy_cq (struct xsc_dev *xdev,void *cq) +{ +return xdev->dev_ops->destroy_cq (cq); +} +int xsc_dev_modify_qp_status (struct xsc_dev *xdev,uint32_t qpn,int num,int opcode) {
drivers/net/xsc/xsc_dev.h +2 -0
@@ -158,6 +158,8 @@ struct xsc_dev_ops {int xsc_dev_mailbox_exec (struct xsc_dev *xdev,void *data_in,int in_len,void *data_out,int out_len);void xsc_dev_ops_register (struct xsc_dev_ops *new_ops); +int xsc_dev_destroy_qp (struct xsc_dev *xdev,void *qp); +int xsc_dev_destroy_cq (struct xsc_dev *xdev,void *cq);int xsc_dev_modify_qp_status (struct xsc_dev *xdev,uint32_t qpn,int num,int opcode);int xsc_dev_modify_qp_qostree (struct xsc_dev *xdev,uint16_t qpn); int xsc_dev_rx_cq_create(struct xsc_dev *xdev, struct xsc_rx_cq_params *cq_params,
drivers/net/xsc/xsc_ethdev.c +108 -0
137 lines not on this page · raw message
drivers/net/xsc/xsc_rx.c +47 -0
50 lines not on this page · raw message
drivers/net/xsc/xsc_rx.h +2 -0
@@ -58,5 +58,7 @@ struct __rte_cache_aligned xsc_rxq_data {int xsc_rxq_elts_alloc (struct xsc_rxq_data *rxq_data);int xsc_rxq_rss_obj_new (struct xsc_ethdev_priv *priv,uint16_t port_id); +void xsc_rxq_rss_obj_release (struct xsc_dev *xdev,struct xsc_rxq_data *rxq_data); +void xsc_rxq_elts_free (struct xsc_rxq_data *rxq_data);#endif /* _XSC_RX_H_ */
drivers/net/xsc/xsc_tx.c +33 -0
@@ -91,3 +91,36 @@ xsc_txq_obj_new(struct xsc_dev *xdev, struct xsc_txq_data *txq_data, error:return -rte_errno; } + +void +xsc_txq_obj_release (struct xsc_dev *xdev,struct xsc_txq_data *txq_data) +{ +PMD_DRV_LOG (DEBUG ,"Destroy tx queue %u, portid %u" , + txq_data->idx, txq_data->port_id); +if (txq_data->qp !=NULL ) +xsc_dev_destroy_qp (xdev, txq_data->qp); +if (txq_data->cq !=NULL ) +xsc_dev_destroy_cq (xdev, txq_data->cq); +} + +void +xsc_txq_elts_free (struct xsc_txq_data *txq_data) +{ +const uint16_t elts_n =1 << txq_data->elts_n; +const uint16_t elts_m = elts_n -1 ; +uint16_t elts_head = txq_data->elts_head; +uint16_t elts_tail = txq_data->elts_tail; +struct rte_mbuf *(*elts)[elts_n] = &txq_data->elts; + + txq_data->elts_head =0 ; + txq_data->elts_tail =0 ; + txq_data->elts_comp =0 ; + +while (elts_tail != elts_head) { +struct rte_mbuf *elt = (*elts)[elts_tail & elts_m]; + +rte_pktmbuf_free_seg (elt); + ++elts_tail; + } +PMD_DRV_LOG (DEBUG ,"Port %u txq %u free elts" , txq_data->port_id, txq_data->idx); +}
drivers/net/xsc/xsc_tx.h +2 -0
@@ -55,5 +55,7 @@ struct __rte_cache_aligned xsc_txq_data {int xsc_txq_obj_new (struct xsc_dev *xdev,struct xsc_txq_data *txq_data,uint64_t offloads,uint16_t idx);void xsc_txq_elts_alloc (struct xsc_txq_data *txq_data); +void xsc_txq_obj_release (struct xsc_dev *xdev,struct xsc_txq_data *txq_data); +void xsc_txq_elts_free (struct xsc_txq_data *txq_data);#endif /* _XSC_TX_H_ */
Signature · 1 line
2.25.1
PATCH v6 11/15 net/xsc: add ethdev Rx burst
In reply to WanRenyongImplement xsc ethdev Rx burst function.
--- drivers/net/xsc/xsc_ethdev.c | 3 + drivers/net/xsc/xsc_rx.c | 174 +++++++++++++++++++++++++++++++++++ drivers/net/xsc/xsc_rx.h | 1 + drivers/net/xsc/xsc_rxtx.h | 13 +++ 4 files changed, 191 insertions(+)
drivers/net/xsc/xsc_ethdev.c +3 -0
@@ -309,6 +309,9 @@ xsc_ethdev_start(struct rte_eth_dev *dev) } dev->data->dev_started =1 ; + + dev->rx_pkt_burst = xsc_rx_burst; + ret =xsc_ethdev_enable (dev);return 0 ;
drivers/net/xsc/xsc_rx.c +174 -0
180 lines not on this page · raw message
drivers/net/xsc/xsc_rx.h +1 -0
@@ -56,6 +56,7 @@ struct __rte_cache_aligned xsc_rxq_data { uint16_t rsv1:11; }; +uint16_t xsc_rx_burst (void *dpdk_rxq,struct rte_mbuf **pkts,uint16_t pkts_n);int xsc_rxq_elts_alloc (struct xsc_rxq_data *rxq_data);int xsc_rxq_rss_obj_new (struct xsc_ethdev_priv *priv,uint16_t port_id);void xsc_rxq_rss_obj_release (struct xsc_dev *xdev,struct xsc_rxq_data *rxq_data);
drivers/net/xsc/xsc_rxtx.h +13 -0
@@ -175,4 +175,17 @@ struct xsc_rx_cq_info {uint16_t cqe_n; }; +static __rte_always_inline int +xsc_check_cqe_own (volatile struct xsc_cqe *cqe,const uint16_t cqe_n,const uint16_t ci) +{ +if (unlikely (((cqe->owner &XSC_CQE_OWNER_MASK ) != ((ci >> cqe_n) &XSC_CQE_OWNER_MASK )))) +return XSC_CQE_OWNER_HW ; + +rte_io_rmb (); +if (cqe->msg_len <=0 && cqe->is_error) +return XSC_CQE_OWNER_ERR ; + +return XSC_CQE_OWNER_SW ; +} +#endif /* _XSC_RXTX_H_ */
Signature · 1 line
2.25.1
PATCH v6 12/15 net/xsc: add ethdev Tx burst
In reply to WanRenyongImplement xsc ethdev Tx burst function.
--- doc/guides/nics/features/xsc.ini | 4 + drivers/net/xsc/xsc_ethdev.c | 1 + drivers/net/xsc/xsc_tx.c | 228 +++++++++++++++++++++++++++++++ drivers/net/xsc/xsc_tx.h | 1 + 4 files changed, 234 insertions(+)
doc/guides/nics/features/xsc.ini +4 -0
@@ -7,6 +7,10 @@ RSS hash = Y RSS key update = Y RSS reta update = Y +L3 checksum offload = Y +L4 checksum offload = Y +Inner L3 checksum = Y +Inner L4 checksum = Y Linux = Y ARMv8 = Y x86-64 = Y
drivers/net/xsc/xsc_ethdev.c +1 -0
@@ -311,6 +311,7 @@ xsc_ethdev_start(struct rte_eth_dev *dev) dev->data->dev_started =1 ; dev->rx_pkt_burst = xsc_rx_burst; + dev->tx_pkt_burst = xsc_tx_burst; ret =xsc_ethdev_enable (dev);
drivers/net/xsc/xsc_tx.c +228 -0
231 lines not on this page · raw message
drivers/net/xsc/xsc_tx.h +1 -0
@@ -52,6 +52,7 @@ struct __rte_cache_aligned xsc_txq_data {struct rte_mbuf *elts[];/* Storage for queued packets, for free */ }; +uint16_t xsc_tx_burst (void *dpdk_txq,struct rte_mbuf **pkts,uint16_t pkts_n);int xsc_txq_obj_new (struct xsc_dev *xdev,struct xsc_txq_data *txq_data,uint64_t offloads,uint16_t idx);void xsc_txq_elts_alloc (struct xsc_txq_data *txq_data);
Signature · 1 line
2.25.1
PATCH v6 13/15 net/xsc: add basic stats ops
In reply to WanRenyongImplement xsc ethdev basic statatics ops.
---
v6:
* Remove unnecessary paren.
* Add the feature of stats per queue in xsc.ini.
--- doc/guides/nics/features/xsc.ini | 2 + drivers/net/xsc/xsc_ethdev.c | 75 ++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+)
doc/guides/nics/features/xsc.ini +2 -0
@@ -11,6 +11,8 @@ L3 checksum offload = Y L4 checksum offload = Y Inner L3 checksum = Y Inner L4 checksum = Y +Basic stats = Y +Stats per queue = Y Linux = Y ARMv8 = Y x86-64 = Y
drivers/net/xsc/xsc_ethdev.c +75 -0
87 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v6 14/15 net/xsc: add ethdev infos get
In reply to WanRenyongImplement xsc ethdev information get ops.
--- drivers/net/xsc/xsc_ethdev.c | 61 ++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+)
drivers/net/xsc/xsc_ethdev.c +61 -0
@@ -364,6 +364,66 @@ xsc_ethdev_close(struct rte_eth_dev *dev)return 0 ; } +static uint64_t +xsc_get_rx_queue_offloads (struct rte_eth_dev *dev) +{ +struct xsc_ethdev_priv *priv =TO_XSC_ETHDEV_PRIV (dev); +struct xsc_dev_config *config = &priv->config; +uint64_t offloads =0 ; + +if (config->hw_csum) + offloads |= (RTE_ETH_RX_OFFLOAD_IPV4_CKSUM | +RTE_ETH_RX_OFFLOAD_UDP_CKSUM | +RTE_ETH_RX_OFFLOAD_TCP_CKSUM ); + +return offloads; +} + +static uint64_t +xsc_get_tx_port_offloads (struct rte_eth_dev *dev) +{ +struct xsc_ethdev_priv *priv =TO_XSC_ETHDEV_PRIV (dev); +uint64_t offloads =0 ; +struct xsc_dev_config *config = &priv->config; + +if (config->hw_csum) + offloads |= (RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | +RTE_ETH_TX_OFFLOAD_UDP_CKSUM | +RTE_ETH_TX_OFFLOAD_TCP_CKSUM ); +if (config->tso) + offloads |=RTE_ETH_TX_OFFLOAD_TCP_TSO ; +return offloads; +} + +static int +xsc_ethdev_infos_get (struct rte_eth_dev *dev,struct rte_eth_dev_info *info) +{ +struct xsc_ethdev_priv *priv =TO_XSC_ETHDEV_PRIV (dev); + + info->min_rx_bufsize =64 ; + info->max_rx_pktlen =65536 ; + info->max_lro_pkt_size =0 ; + info->max_rx_queues =256 ; + info->max_tx_queues =1024 ; + info->rx_desc_lim.nb_max =4096 ; + info->rx_desc_lim.nb_min =16 ; + info->tx_desc_lim.nb_max =8192 ; + info->tx_desc_lim.nb_min =128 ; + + info->rx_queue_offload_capa =xsc_get_rx_queue_offloads (dev); + info->rx_offload_capa = info->rx_queue_offload_capa; + info->tx_offload_capa =xsc_get_tx_port_offloads (dev); + + info->if_index = priv->ifindex; + info->speed_capa = priv->xdev->link_speed_capa; + info->hash_key_size =XSC_RSS_HASH_KEY_LEN ; + info->tx_desc_lim.nb_seg_max =8 ; + info->tx_desc_lim.nb_mtu_seg_max =8 ; + info->switch_info.name = dev->data->name; + info->switch_info.port_id = priv->representor_id; +return 0 ; +} + static int xsc_ethdev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, uint32_t socket, const struct rte_eth_rxconf *conf,
@@ -549,6 +609,7 @@ const struct eth_dev_ops xsc_eth_dev_ops = { .dev_close = xsc_ethdev_close, .stats_get = xsc_ethdev_stats_get, .stats_reset = xsc_ethdev_stats_reset, + .dev_infos_get = xsc_ethdev_infos_get, .rx_queue_setup = xsc_ethdev_rx_queue_setup, .tx_queue_setup = xsc_ethdev_tx_queue_setup, .rx_queue_release = xsc_ethdev_rxq_release,
Signature · 1 line
2.25.1
PATCH v6 15/15 net/xsc: add ethdev link and MTU ops
In reply to WanRenyongImplement xsc ethdev link and MTU ops.
--- doc/guides/nics/features/xsc.ini | 1 + drivers/net/xsc/xsc_dev.c | 33 ++++++++++++++++++ drivers/net/xsc/xsc_dev.h | 4 +++ drivers/net/xsc/xsc_ethdev.c | 60 ++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+)
doc/guides/nics/features/xsc.ini +1 -0
@@ -4,6 +4,7 @@ ; Refer to default.ini for the full list of available PMD features. ; [Features] +MTU update = Y RSS hash = Y RSS key update = Y RSS reta update = Y
drivers/net/xsc/xsc_dev.c +33 -0
@@ -62,6 +62,39 @@ xsc_dev_mailbox_exec(struct xsc_dev *xdev, void *data_in, data_out, out_len); } +int +xsc_dev_set_link_up (struct xsc_dev *xdev) +{ +if (xdev->dev_ops->set_link_up ==NULL ) +return -ENOTSUP ; + +return xdev->dev_ops->set_link_up (xdev); +} + +int +xsc_dev_set_link_down (struct xsc_dev *xdev) +{ +if (xdev->dev_ops->set_link_down ==NULL ) +return -ENOTSUP ; + +return xdev->dev_ops->set_link_down (xdev); +} + +int +xsc_dev_link_update (struct xsc_dev *xdev,uint8_t funcid_type,int wait_to_complete) +{ +if (xdev->dev_ops->link_update ==NULL ) +return -ENOTSUP ; + +return xdev->dev_ops->link_update (xdev, funcid_type, wait_to_complete); +} + +int +xsc_dev_set_mtu (struct xsc_dev *xdev,uint16_t mtu) +{ +return xdev->dev_ops->set_mtu (xdev, mtu); +} +int xsc_dev_get_mac (struct xsc_dev *xdev,uint8_t *mac) {
drivers/net/xsc/xsc_dev.h +4 -0
@@ -158,6 +158,9 @@ struct xsc_dev_ops {int xsc_dev_mailbox_exec (struct xsc_dev *xdev,void *data_in,int in_len,void *data_out,int out_len);void xsc_dev_ops_register (struct xsc_dev_ops *new_ops); +int xsc_dev_set_link_up (struct xsc_dev *xdev); +int xsc_dev_set_link_down (struct xsc_dev *xde); +int xsc_dev_link_update (struct xsc_dev *xdev,uint8_t funcid_type,int wait_to_complete);int xsc_dev_destroy_qp (struct xsc_dev *xdev,void *qp);int xsc_dev_destroy_cq (struct xsc_dev *xdev,void *cq);int xsc_dev_modify_qp_status (struct xsc_dev *xdev,uint32_t qpn,int num,int opcode);
@@ -175,6 +178,7 @@ int xsc_dev_repr_ports_probe(struct xsc_dev *xdev, int nb_repr_ports, int max_etint xsc_dev_rss_key_modify (struct xsc_dev *xdev,uint8_t *rss_key,uint8_t rss_key_len);bool xsc_dev_is_vf (struct xsc_dev *xdev);int xsc_dev_qp_set_id_get (struct xsc_dev *xdev,int repr_id); +int xsc_dev_set_mtu (struct xsc_dev *xdev,uint16_t mtu);int xsc_dev_get_mac (struct xsc_dev *xdev,uint8_t *mac);#endif /* _XSC_DEV_H_ */
drivers/net/xsc/xsc_ethdev.c +60 -0
85 lines not on this page · raw message
Signature · 1 line
2.25.1