drivers/net Add Support mucse N10 Pmd Driver
Subsystems (2)
v6 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 supprt 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 desgin 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.
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 (8):
net/rnp: add skeleton
net/rnp: add ethdev probe and remove
net/rnp: add device init and uninit
net/rnp: add mbx basic api feature
net/rnp add reset code for Chip Init process
net/rnp add port info resource init
net/rnp add devargs runtime parsing functions
net/rnp handle device interrupts
MAINTAINERS | 6 + doc/guides/nics/features/rnp.ini | 8 + doc/guides/nics/index.rst | 1 + doc/guides/nics/rnp.rst | 43 ++ drivers/net/meson.build | 1 + drivers/net/rnp/base/rnp_api.c | 71 +++ drivers/net/rnp/base/rnp_api.h | 17 + drivers/net/rnp/base/rnp_cfg.h | 7 + drivers/net/rnp/base/rnp_dma_regs.h | 73 +++ drivers/net/rnp/base/rnp_eth_regs.h | 124 +++++ drivers/net/rnp/base/rnp_hw.h | 206 +++++++ drivers/net/rnp/base/rnp_mac_regs.h | 279 ++++++++++ drivers/net/rnp/meson.build | 18 + drivers/net/rnp/rnp.h | 218 ++++++++ drivers/net/rnp/rnp_ethdev.c | 822 ++++++++++++++++++++++++++++ drivers/net/rnp/rnp_logs.h | 43 ++ drivers/net/rnp/rnp_mbx.c | 524 ++++++++++++++++++ drivers/net/rnp/rnp_mbx.h | 140 +++++ drivers/net/rnp/rnp_mbx_fw.c | 781 ++++++++++++++++++++++++++ drivers/net/rnp/rnp_mbx_fw.h | 401 ++++++++++++++ drivers/net/rnp/rnp_osdep.h | 30 + drivers/net/rnp/rnp_rxtx.c | 83 +++ drivers/net/rnp/rnp_rxtx.h | 14 + 23 files changed, 3910 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/rnp_api.c create mode 100644 drivers/net/rnp/base/rnp_api.h create mode 100644 drivers/net/rnp/base/rnp_cfg.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_hw.h create mode 100644 drivers/net/rnp/base/rnp_mac_regs.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_logs.h create mode 100644 drivers/net/rnp/rnp_mbx.c create mode 100644 drivers/net/rnp/rnp_mbx.h create mode 100644 drivers/net/rnp/rnp_mbx_fw.c create mode 100644 drivers/net/rnp/rnp_mbx_fw.h create mode 100644 drivers/net/rnp/rnp_osdep.h create mode 100644 drivers/net/rnp/rnp_rxtx.c create mode 100644 drivers/net/rnp/rnp_rxtx.h
Signature · 1 line
2.27.0
PATCH v6 1/8 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 | 38 ++++++++++++++++++++++++++++++++ drivers/net/meson.build | 1 + drivers/net/rnp/meson.build | 11 +++++++++ drivers/net/rnp/rnp_ethdev.c | 3 +++ 7 files changed, 68 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
@@ -955,6 +955,12 @@ F: drivers/net/qede/ F: doc/guides/nics/qede.rst F: doc/guides/nics/features/qede*.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
@@ -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
@@ -61,6 +61,7 @@ Network Interface Controller Drivers pcap_ring pfe qede + rnp sfc_efx softnic tap
doc/guides/nics/rnp.rst new file +38 -0
@@ -0,0 +1,38 @@ +.. SPADIX-License-Identifier: BSD-3-Clause + Copyright(c) 2023 Mucse IC Design Ltd. + +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** + +Prerequisites +------------- +More information can be found at `Mucse, Official Website +<https://mucse.com/productDetail>`_. + +Supported Chipsets and NICs +--------------------------- + +- MUCSE Ethernet Controller N10 Series for 10GbE or 40GbE (Dual-port) + +Limitations or Known issues +--------------------------- + +Build with ICC is not supported yet. +BSD are not supported yet. + +CRC stripping +~~~~~~~~~~~~~ + +The RNP Soc family Nic strip the CRC for every packets coming into the +host interface irrespective of the offload configuration. +When you want to disable CRC_OFFLOAD the operate will influence the rxCksum offload. + +VLAN Strip/Filter +~~~~~~~~~~~~~~~~~ + +For VLAN strip/filter, RNP just support vlan is CVLAN(0x8100).If the outvlan type is SVLAN(0X88a8) +VLAN filter or strip will not effort for this packet.It will bypass filter to the host default queue, +whatever the other filter rule is.
drivers/net/meson.build +1 -0
@@ -54,6 +54,7 @@ drivers = [ 'pfe', 'qede', 'ring', + 'rnp', 'sfc', 'softnic', 'tap',
drivers/net/rnp/meson.build new file +11 -0
@@ -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
@@ -0,0 +1,3 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(C) 2023 Mucse IC Design Ltd. +*/
Signature · 1 line
2.27.0
Re: [PATCH v6 1/8] net/rnp: add skeleton
Quoted 4 lines · Wenbo Cao
Add Basic PMD library and doc build infrastructure Update maintainers file to claim responsibility.
Signed-off-by Wenbo Cao <[email protected]>
<...>
doc/guides/nics/rnp.rst line 1
Quoted 7 lines
doc/guides/nics/rnp.rst new file +1
-0@@ -0,0 +1,38 @@ +.. SPADIX-License-Identifier: BSD-3-Clause
s/SPADIX/SPDX/
Quoted 8 lines
doc/guides/nics/rnp.rst new file +8
-0+ Copyright(c) 2023 Mucse IC Design Ltd. + +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** +
doc/guides/nics/rnp.rst line 19
Quoted 10 lines
doc/guides/nics/rnp.rst new file +10
-0+Prerequisites +------------- +More information can be found at `Mucse, Official Website +<https://mucse.com/productDetail>`_. + +Supported Chipsets and NICs +--------------------------- + +- MUCSE Ethernet Controller N10 Series for 10GbE or 40GbE (Dual-port) +
Can you provide a link for the product, and if there is an English version it can reach to more people?
doc/guides/nics/rnp.rst line 23
Quoted 5 lines
doc/guides/nics/rnp.rst new file +4
-0+Limitations or Known issues +--------------------------- + +Build with ICC is not supported yet.
I know this is documented in other PMDs too, but at this stage ICC is supported with best effort, and I am not sure if anybody testing with it, so I think it is OK to drop this as limitation.
doc/guides/nics/rnp.rst line 24
Quoted 2 lines
doc/guides/nics/rnp.rst new file +1
-0+BSD are not supported yet.
FreeBSD is not supported.
Also Windows seems not supported, you may document that too.
doc/guides/nics/rnp.rst line 29
Quoted 5 lines
doc/guides/nics/rnp.rst new file +5
-0+ +CRC stripping +~~~~~~~~~~~~~ + +The RNP Soc family Nic strip the CRC for every packets coming into the
s/Soc/SoC/
s/Nic/NIC/
doc/guides/nics/rnp.rst line 31
Quoted 3 lines
doc/guides/nics/rnp.rst new file +2
-0+host interface irrespective of the offload configuration. +When you want to disable CRC_OFFLOAD the operate will influence the rxCksum offload.
I didn't understand the second sentences, from first one I understand 'RTE_ETH_RX_OFFLOAD_KEEP_CRC' is not supported by the PMD, but can you please clarify more?
doc/guides/nics/rnp.rst line 36
Quoted 5 lines
doc/guides/nics/rnp.rst new file +5
-0+ +VLAN Strip/Filter +~~~~~~~~~~~~~~~~~ + +For VLAN strip/filter, RNP just support vlan is CVLAN(0x8100).If the outvlan type is SVLAN(0X88a8)
s/vlan/VLAN/
Please put space, " ", after '.' in documentation. Same comment for all document.
doc/guides/nics/rnp.rst line 38
Quoted 3 lines
doc/guides/nics/rnp.rst new file +2
-0+VLAN filter or strip will not effort for this packet.It will bypass filter to the host default queue, +whatever the other filter rule is.
VLAN strip/filter doesn't work for double-tag (QinQ), it only works for single VLAN tag, is this correct? If so can you please update above sentences to clarify this?
RE: [PATCH v6 1/8] net/rnp: add skeleton
Hi Ferruh,
Thanks for your kindly review, please see the below comment.
Regards Wenbo
Quoted 16 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: 2023年9月5日 23:35
To: Wenbo Cao <[email protected]>; Thomas Monjalon <[email protected]>
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v6 1/8] net/rnp: add skeletonQuoted 4 lines · Wenbo Cao
Add Basic PMD library and doc build infrastructure Update maintainers file to claim responsibility.
Signed-off-by Wenbo Cao <[email protected]><...>
Quoted 8 lines
doc/guides/nics/rnp.rst line 1
Quoted 6 lines
doc/guides/nics/rnp.rst new renamed from doc/guides/nics/rnp.rst +0
-0file mode 100644 index 0000000000..0eb8f2d415
doc/guides/nics/rnp.rst new file +1
-0@@ -0,0 +1,38 @@ +.. SPADIX-License-Identifier: BSD-3-Clauses/SPADIX/SPDX/
I get it.
Quoted 15 lines
Quoted 15 lines
doc/guides/nics/rnp.rst new file +14
-0+ Copyright(c) 2023 Mucse IC Design Ltd. + +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** + +Prerequisites +------------- +More information can be found at `Mucse, Official Website +<https://mucse.com/productDetail>`_. +
Quoted 9 lines
doc/guides/nics/rnp.rst line 19
Quoted 5 lines
doc/guides/nics/rnp.rst new file +5
-0+Supported Chipsets and NICs +--------------------------- + +- MUCSE Ethernet Controller N10 Series for 10GbE or 40GbE (Dual-port) +Can you provide a link for the product, and if there is an English version it can reach to more people?
For English version, it will be coming soon in a month about. we will provide a html link of pdf for the time.
Quoted 11 lines
doc/guides/nics/rnp.rst line 23
Quoted 5 lines
doc/guides/nics/rnp.rst new file +4
-0+Limitations or Known issues +--------------------------- + +Build with ICC is not supported yet.I know this is documented in other PMDs too, but at this stage ICC is supported with best effort, and I am not sure if anybody testing with it, so I think it is OK to drop this as limitation.
We have never test the code use icc-compile-tool, just use gcc-compile-tool, I'm going to try to test it with icc :)
Quoted 6 lines
doc/guides/nics/rnp.rst line 24
Quoted 2 lines
doc/guides/nics/rnp.rst new file +1
-0+BSD are not supported yet.FreeBSD is not supported.
Also Windows seems not supported, you may document that too.
Quoted 10 lines
doc/guides/nics/rnp.rst
Quoted 6 lines
doc/guides/nics/rnp.rst new file +6
-0+ +CRC stripping +~~~~~~~~~~~~~ + +The RNP Soc family Nic strip the CRC for every packets coming into +thes/Soc/SoC/
s/Nic/NIC/
For this spell issue, is there exist tool I can use to check it ? Thanks a lot.
Quoted 10 lines
doc/guides/nics/rnp.rst line 33
Quoted 2 lines
doc/guides/nics/rnp.rst new file +2
-0+host interface irrespective of the offload configuration. +When you want to disable CRC_OFFLOAD the operate will influence therxCksum offload.
Quoted 1 line
I didn't understand the second sentences, from first one I understand '
RTE_ETH_RX_OFFLOAD_KEEP_CRC' is not supported by the PMD, but can you please clarify more?
disable CRC_OFFLOAD will trigger SOC bug,
which causing bad-cksum bit in rx description always be 1 ,even package has no cksum error.
Quoted 10 lines
doc/guides/nics/rnp.rst
Quoted 6 lines
doc/guides/nics/rnp.rst new file +6
-0+ +VLAN Strip/Filter +~~~~~~~~~~~~~~~~~ + +For VLAN strip/filter, RNP just support vlan is CVLAN(0x8100).If the +outvlan type is SVLAN(0X88a8)s/vlan/VLAN/
Please put space, " ", after '.' in documentation. Same comment for all document.
I forgot the format before.
Quoted 7 lines
doc/guides/nics/rnp.rst
Quoted 3 lines
doc/guides/nics/rnp.rst new file +2
-0+VLAN filter or strip will not effort for this packet.It will bypass +filter to the host default queue, whatever the other filter rule is.VLAN strip/filter doesn't work for double-tag (QinQ), it only works for single VLAN tag, is this correct? If so can you please update above sentences to clarify this?
For VLAN strip/filter, if the VLAN type have (0x88a8), the feature of hardware isn't effect.
Re: [PATCH v6 1/8] net/rnp: add skeleton
In reply to Wenbo CaoQuoted 5 lines · Wenbo Cao
Add Basic PMD library and doc build infrastructure Update maintainers file to claim responsibility.
Signed-off-by Wenbo Cao <[email protected]>
Hi Wenbo,
What is the status of the 'rnp' driver, v7 was expected but not received, will upstreaming continue for v24.03?
RE: [PATCH v6 1/8] net/rnp: add skeleton
Hi Ferruh,
Thanks for your reminder, I'm sorry for that I had been work on anothing before. Recendly, I have been reworked on this work. It will miss on release of v24.03.
For another thing, I'm always confused for the secondary process call like hw->mac_ops this function pointer. is this method can work normally on secondary process ?
For example,ixgbe on secondary process call ixgbe_get_module_eeprom I fond that it will cause process core-dump. because of secondary process use primary process function-point address.
Is dpdk plaform allowed user call the eth_dev_ops on secondary process?
I don't find any limit and don't know wether or not to protect this function call work normally. My driver eth_dev_ops achieve will used some function-pointer, so I'm confued about this.
Wish your kind guidance.
Regadrs Wenbo
Quoted 19 lines
-----Original Message-----
From: [email protected] <[email protected]>
Sent: 2024年3月29日 19:28
To: Wenbo Cao <[email protected]>; Thomas Monjalon <[email protected]>
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v6 1/8] net/rnp: add skeletonQuoted 5 lines · Wenbo Cao
Add Basic PMD library and doc build infrastructure Update maintainers file to claim responsibility.
Signed-off-by Wenbo Cao <[email protected]>Hi Wenbo,
What is the status of the 'rnp' driver, v7 was expected but not received, will upstreaming continue for v24.03?
Re: [PATCH v6 1/8] net/rnp: add skeleton
Quoted 5 lines · On 3/29/2024 2:45 PM, 11 wrote:
Hi Ferruh,
Thanks for your reminder, I'm sorry for that I had been work on anothing before. Recendly, I have been reworked on this work. It will miss on release of v24.03.
Quoted 9 lines
For another thing, I'm always confused for the secondary process call like
hw->mac_opsthis function pointer. is this method can work normally on secondary process ?
For example,ixgbe on secondary process callixgbe_get_module_eepromI fond that it will cause process core-dump. because of secondary process use primary process function-point address.
Is dpdk plaform allowed user call theeth_dev_opson secondary process?
I don't find any limit and don't know wether or not to protect this function call work normally. My drivereth_dev_opsachieve will used some function-pointer, so I'm confued about this.
Wish your kind guidance.
Hi Wenbo,
"struct rte_eth_dev" is per process, not shared, so both primary and and secondary has a copy of it.
And during driver initialization, 'eth_dev->dev_ops' is set, so both primary and secondary processes has correct function pointers. ("struct rte_eth_dev_data" is shared, so any pointer withing that struct should be in a shared memory between primary and secondaries.)
And there is no restriction for secondary process call 'eth_dev_ops' but this call needs to be synchronized by application, since there is no locking around those functions.
Common usecase is primary process runs the control path, uses 'eth_dev_ops' calls, and secondaries only does the datapath on specific set of queues.
If you are referring to 'mac_ops', that is another layer of abstraction some drivers use, but those should be tied to ethdev control path functions eventually, so same rule for using ethdev control path applies to them.
Quoted 23 lines
Quoted 21 lines
-----Original Message-----
From: [email protected] <[email protected]>
Sent: 2024年3月29日 19:28
To: Wenbo Cao <[email protected]>; Thomas Monjalon <[email protected]>
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v6 1/8] net/rnp: add skeletonQuoted 5 lines · Wenbo Cao
Add Basic PMD library and doc build infrastructure Update maintainers file to claim responsibility.
Signed-off-by Wenbo Cao <[email protected]>Hi Wenbo,
What is the status of the 'rnp' driver, v7 was expected but not received, will upstreaming continue for v24.03?
PATCH v6 2/8 net/rnp: add ethdev probe and remove
In reply to Wenbo CaoAdd basic PCIe ethdev probe and remove.
--- drivers/net/rnp/rnp.h | 13 ++++++ drivers/net/rnp/rnp_ethdev.c | 83 ++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 drivers/net/rnp/rnp.h
drivers/net/rnp/rnp.h new file +13 -0
@@ -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 { +} __rte_cache_aligned; + +#endif /* __RNP_H__ */
drivers/net/rnp/rnp_ethdev.c +83 -0
86 lines not on this page · raw message
Signature · 1 line
2.27.0
Re: [PATCH v6 2/8] net/rnp: add ethdev probe and remove
Quoted 17 lines · Wenbo Cao
Add basic PCIe ethdev probe and remove.
Signed-off-by Wenbo Cao <[email protected]>--- drivers/net/rnp/rnp.h | 13 ++++++ drivers/net/rnp/rnp_ethdev.c | 83 ++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 drivers/net/rnp/rnp.hdrivers/net/rnp/rnp.h new file +2
-0@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(C) 2023 Mucse IC Design Ltd.
drivers/net/rnp/rnp.h line 12
Quoted 10 lines
drivers/net/rnp/rnp.h new file +10
-0+*/ +#ifndef __RNP_H__ +#define __RNP_H__ + +#define PCI_VENDOR_ID_MUCSE (0x8848) +#define RNP_DEV_ID_N10G (0x1000) + +struct rnp_eth_port { +} __rte_cache_aligned; +
Is the struct needs to be cache aligned?
Quoted 41 lines
drivers/net/rnp/rnp.h new file +1
-0+#endif /* __RNP_H__ */ drivers/net/rnp/rnp_ethdev.c +32
-0@@ -1,3 +1,86 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(C) 2023 Mucse IC Design Ltd. */ + +#include <ethdev_pci.h> +#include <rte_io.h> +#include <rte_malloc.h> + +#include "rnp.h" + +static int +rnp_eth_dev_init (struct rte_eth_dev *eth_dev) +{ +RTE_SET_USED (eth_dev); + +return -ENODEV ; +} + +static int +rnp_eth_dev_uninit (struct rte_eth_dev *eth_dev) +{ +RTE_SET_USED (eth_dev); + +return -ENODEV ; +} + +static int +rnp_pci_remove (struct rte_pci_device *pci_dev) +{ +struct rte_eth_dev *eth_dev; +int rc; + + eth_dev =rte_eth_dev_allocated (pci_dev->device.name); + +if (eth_dev) {
drivers/net/rnp/rnp_ethdev.c line 45
Quoted 10 lines
drivers/net/rnp/rnp_ethdev.c +10
-0+/* Cleanup eth dev */ + rc =rte_eth_dev_pci_generic_remove (pci_dev, + rnp_eth_dev_uninit); +if (rc) +return rc; + } +/* Nothing to be done for secondary processes */ +if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) +return 0 ; +
Primary also don't do anything after this stage, I suggest adding this code when primary & secondary diverges.
Quoted 9 lines
drivers/net/rnp/rnp_ethdev.c +9
-0+return 0 ; +} + +static int +rnp_pci_probe (struct rte_pci_driver *pci_drv,struct rte_pci_device *pci_dev) +{ +int rc; + +RTE_SET_USED (pci_drv);
drivers/net/rnp/rnp_ethdev.c line 64
Quoted 10 lines
drivers/net/rnp/rnp_ethdev.c +10
-0+ + rc =rte_eth_dev_pci_generic_probe (pci_dev,sizeof (struct rnp_eth_port ), + rnp_eth_dev_init); + +/* On error on secondary, recheck if port exists in primary or +* in mid of detach state. +*/ +if (rte_eal_process_type () !=RTE_PROC_PRIMARY && rc) +if (!rte_eth_dev_allocated (pci_dev->device.name)) +return 0 ;
Why this additional secondary check is required? 'rte_eth_dev_pci_generic_probe()' should be dealing with primary/secondary process case.
RE: [PATCH v6 2/8] net/rnp: add ethdev probe and remove
Quoted 33 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: 2023年9月5日 23:36
To: Wenbo Cao <[email protected]>; Anatoly Burakov <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v6 2/8] net/rnp: add ethdev probe and removeQuoted 21 lines · Wenbo Cao
Add basic PCIe ethdev probe and remove.
Signed-off-by Wenbo Cao <[email protected]>--- drivers/net/rnp/rnp.h | 13 ++++++ drivers/net/rnp/rnp_ethdev.c | 83 ++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 drivers/net/rnp/rnp.hdrivers/net/rnp/rnp.h new file renamed from drivers/net/rnp/rnp.h +0
-0mode 100644 index 0000000000..76d281cc0a
drivers/net/rnp/rnp.h new file +6
-0@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(C) 2023 Mucse IC Design Ltd. +*/ +#ifndef __RNP_H__ +#define __RNP_H__ +
Quoted 9 lines
drivers/net/rnp/rnp.h line 12
Quoted 6 lines
drivers/net/rnp/rnp.h new file +6
-0+#define PCI_VENDOR_ID_MUCSE (0x8848) +#define RNP_DEV_ID_N10G (0x1000) + +struct rnp_eth_port { +} __rte_cache_aligned; +Is the struct needs to be cache aligned?
This struct may use frequently so I want it to fast to load.
Quoted 43 lines
Quoted 43 lines
drivers/net/rnp/rnp.h new file +1
-0+#endif /* __RNP_H__ */ (quoted diff) +0
-0
b/drivers/net/rnp/rnp_ethdev.cindex9ce3c0b497..390f2e7743100644drivers/net/rnp/rnp_ethdev.c +34
-0@@ -1,3 +1,86 @@/* SPDX-License-Identifier: BSD-3-Clause * Copyright(C) 2023 Mucse IC Design Ltd. */ + +#include <ethdev_pci.h> +#include <rte_io.h> +#include <rte_malloc.h> + +#include "rnp.h" + +static int +rnp_eth_dev_init (struct rte_eth_dev *eth_dev) { +RTE_SET_USED (eth_dev); + +return -ENODEV ; +} + +static int +rnp_eth_dev_uninit (struct rte_eth_dev *eth_dev) { +RTE_SET_USED (eth_dev); + +return -ENODEV ; +} + +static int +rnp_pci_remove (struct rte_pci_device *pci_dev) { +struct rte_eth_dev *eth_dev; +int rc; + + eth_dev =rte_eth_dev_allocated (pci_dev->device.name); + +if (eth_dev) { +/* Cleanup eth dev */ + rc =rte_eth_dev_pci_generic_remove (pci_dev, + rnp_eth_dev_uninit); +if (rc) +return rc;
Quoted 9 lines
drivers/net/rnp/rnp_ethdev.c line 45
Quoted 5 lines
drivers/net/rnp/rnp_ethdev.c +5
-0+ } +/* Nothing to be done for secondary processes */ +if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) +return 0 ; +Primary also don't do anything after this stage, I suggest adding this code when primary & secondary diverges.
Ok, I get it.
Quoted 12 lines
drivers/net/rnp/rnp_ethdev.c
Quoted 11 lines
drivers/net/rnp/rnp_ethdev.c +11
-0+return 0 ; +} + +static int +rnp_pci_probe (struct rte_pci_driver *pci_drv,struct rte_pci_device +*pci_dev) { +int rc; + +RTE_SET_USED (pci_drv); + + rc = rte_eth_dev_pci_generic_probe(pci_dev, sizeof(struct
rnp_eth_port),
Quoted 13 lines
drivers/net/rnp/rnp_ethdev.c line 64
Quoted 8 lines
drivers/net/rnp/rnp_ethdev.c +8
-0+ rnp_eth_dev_init); + +/* On error on secondary, recheck if port exists in primary or +* in mid of detach state. +*/ +if (rte_eal_process_type () !=RTE_PROC_PRIMARY && rc) +if (!rte_eth_dev_allocated (pci_dev->device.name)) +return 0 ;Why this additional secondary check is required? '
rte_eth_dev_pci_generic_probe()' should be dealing with primary/secondary process case.
Because of multiple port mode single pcie-bdf the other port
Alloc use xx:xx.0_0, xx:xx.0_1, xx:xx.0_2, xx:xx.0_0, use rnp_alloc_eth_port api.
PATCH v6 3/8 net/rnp: add device init and uninit
In reply to Wenbo CaoAdd basic init and uninit function
--- drivers/net/rnp/base/rnp_hw.h | 19 ++++ drivers/net/rnp/meson.build | 1 + drivers/net/rnp/rnp.h | 25 +++++ drivers/net/rnp/rnp_ethdev.c | 196 +++++++++++++++++++++++++++++++++- drivers/net/rnp/rnp_logs.h | 34 ++++++ drivers/net/rnp/rnp_osdep.h | 30 ++++++ 6 files changed, 300 insertions(+), 5 deletions(-) create mode 100644 drivers/net/rnp/base/rnp_hw.h create mode 100644 drivers/net/rnp/rnp_logs.h create mode 100644 drivers/net/rnp/rnp_osdep.h
drivers/net/rnp/base/rnp_hw.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(C) 2023 Mucse IC Design Ltd. +*/ +#ifndef __RNP_HW_H__ +#define __RNP_HW_H__ + +struct rnp_eth_adapter ; +struct rnp_hw { +struct rnp_eth_adapter *back; +void *iobar0; +uint32_t iobar0_len; +void *iobar4; +uint32_t iobar4_len; + +uint16_t device_id; +uint16_t vendor_id; +} __rte_cache_aligned; + +#endif /* __RNP_H__*/
drivers/net/rnp/meson.build +1 -0
@@ -9,3 +9,4 @@ endif sources = files( 'rnp_ethdev.c', ) +includes += include_directories('base')
drivers/net/rnp/rnp.h +25 -0
@@ -4,10 +4,35 @@#ifndef __RNP_H__#define __RNP_H__ +#include "base/rnp_hw.h" +#define PCI_VENDOR_ID_MUCSE (0x8848)#define RNP_DEV_ID_N10G (0x1000) +#define RNP_MAX_PORT_OF_PF (4) +#define RNP_CFG_BAR (4) +#define RNP_PF_INFO_BAR (0)struct rnp_eth_port { +struct rnp_eth_adapter *adapt; +struct rte_eth_dev *eth_dev; +} __rte_cache_aligned; + +struct rnp_share_ops { } __rte_cache_aligned; +struct rnp_eth_adapter { +struct rnp_hw hw; +struct rte_pci_device *pdev; +struct rte_eth_dev *eth_dev;/* primary eth_dev */ +struct rnp_eth_port *ports[RNP_MAX_PORT_OF_PF ]; +struct rnp_share_ops *share_priv; + +uint8_t num_ports;/* Cur Pf Has physical Port Num */ +} __rte_cache_aligned; + +#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)->adapt)) +#endif /* __RNP_H__ */
drivers/net/rnp/rnp_ethdev.c +191 -5
217 lines not on this page · raw message
drivers/net/rnp/rnp_logs.h new file +34 -0
@@ -0,0 +1,34 @@ +#ifndef __RNP_LOGS_H__ +#define __RNP_LOGS_H__ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(C) 2023 Mucse IC Design Ltd. +*/ +extern int rnp_init_logtype; + +#define RNP_PMD_INIT_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_##level, rnp_init_logtype, \ + "%s() " fmt, __func__, ##args) +#define PMD_INIT_FUNC_TRACE () RNP_PMD_INIT_LOG(DEBUG, " >>") +extern int rnp_drv_logtype; +#define RNP_PMD_DRV_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_##level, rnp_drv_logtype, \ + "%s() " fmt, __func__, ##args) +#ifdef RTE_LIBRTE_RNP_DEBUG_RX +extern int rnp_rx_logtype; +#define RNP_PMD_RX_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, rnp_rx_logtype, \ + "%s(): " fmt "\n", __func__, ##args) +#else +#define RNP_PMD_RX_LOG(level, fmt, args...) do { } while (0) +#endif + +#ifdef RTE_LIBRTE_RNP_DEBUG_TX +extern int rnp_tx_logtype; +#define PMD_TX_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, rnp_tx_logtype, \ + "%s(): " fmt "\n", __func__, ##args) +#else +#define PMD_TX_LOG(level, fmt, args...) do { } while (0) +#endif + +#endif /* __RNP_LOGS_H__ */
drivers/net/rnp/rnp_osdep.h new file +30 -0
@@ -0,0 +1,30 @@ +#ifndef __RNP_OSDEP_H__ +#define __RNP_OSDEP_H__ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(C) 2023 Mucse IC Design Ltd. +*/ +#include <stdint.h> + +#include <rte_byteorder.h> + +#define __iomem +#define _RING_ (off) ((off) + 0x000000) +#define _DMA_ (off) ((off)) +#define _GLB_ (off) ((off) + 0x000000) +#define _NIC_ (off) ((off) + 0x000000) +#define _ETH_ (off) ((off)) +#define _MAC_ (off) ((off)) +#define BIT (n) (1UL << (n)) +#define BIT64 (n) (1ULL << (n)) +#define BITS_PER_LONG (__SIZEOF_LONG__ * 8) +#define GENMASK (h, l) \ + (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) + +typedef uint8_t u8 ; +typedef uint16_t u16 ; +typedef uint32_t u32 ; +typedef uint64_t u64 ; +typedef int32_t s32 ; +typedef int16_t s16 ; +typedef int8_t s8 ; +#endif /* __RNP_OSDEP_H__ */
Signature · 1 line
2.27.0
Re: [PATCH v6 3/8] net/rnp: add device init and uninit
Quoted 15 lines · Wenbo Cao
Add basic init and uninit function
Signed-off-by Wenbo Cao <[email protected]>--- drivers/net/rnp/base/rnp_hw.h | 19 ++++ drivers/net/rnp/meson.build | 1 + drivers/net/rnp/rnp.h | 25 +++++ drivers/net/rnp/rnp_ethdev.c | 196 +++++++++++++++++++++++++++++++++- drivers/net/rnp/rnp_logs.h | 34 ++++++ drivers/net/rnp/rnp_osdep.h | 30 ++++++ 6 files changed, 300 insertions(+), 5 deletions(-) create mode 100644 drivers/net/rnp/base/rnp_hw.h create mode 100644 drivers/net/rnp/rnp_logs.h create mode 100644 drivers/net/rnp/rnp_osdep.h
'rnp_osdep.h' not used at all in the patch, can you move it where it is used?
Quoted 14 lines
drivers/net/rnp/base/rnp_hw.h new file +8
-0@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(C) 2023 Mucse IC Design Ltd. +*/ +#ifndef __RNP_HW_H__ +#define __RNP_HW_H__ + +struct rnp_eth_adapter ; +struct rnp_hw {
drivers/net/rnp/base/rnp_hw.h line 18
Quoted 10 lines
drivers/net/rnp/base/rnp_hw.h new file +10
-0+struct rnp_eth_adapter *back; +void *iobar0; +uint32_t iobar0_len; +void *iobar4; +uint32_t iobar4_len; + +uint16_t device_id; +uint16_t vendor_id; +} __rte_cache_aligned; +
All structs seems alligned to the cache, although it may not hurt, it is better to align ones that is necessary for performance.
<...>
drivers/net/rnp/base/rnp_hw.h
Quoted 3 lines
drivers/net/rnp/base/rnp_hw.h new file +3
-0+ +static struct rte_eth_dev * +rnp_alloc_eth_port (struct rte_pci_device *primary_pci,char *name)
Why variable name is 'primary_pci', are there different pci device types?
drivers/net/rnp/base/rnp_hw.h
Quoted 8 lines
drivers/net/rnp/base/rnp_hw.h new file +8
-0+{ +struct rnp_eth_port *port; +struct rte_eth_dev *eth_dev; + + eth_dev =rte_eth_dev_allocate (name); +if (!eth_dev) { +RNP_PMD_DRV_LOG (ERR ,"Could not allocate " +"eth_dev for %s\n" , name);
Please don't split the log message, instead can do:
RNP_PMD_DRV_LOG(ERR,
"Could not allocate eth_dev for %s\n", name);
Same for all log messages.
drivers/net/rnp/base/rnp_hw.h
Quoted 10 lines
drivers/net/rnp/base/rnp_hw.h new file +10
-0+return NULL ; + } + port =rte_zmalloc_socket (name, +sizeof (*port), +RTE_CACHE_LINE_SIZE , + primary_pci->device.numa_node); +if (!port) { +RNP_PMD_DRV_LOG (ERR ,"Could not allocate " +"rnp_eth_port for %s\n" , name); +return NULL ;
Should 'eth_dev' released here?
Quoted 33 lines
drivers/net/rnp/base/rnp_hw.h new file +33
-0+ } + eth_dev->data->dev_private = port; + eth_dev->process_private =calloc (1 ,sizeof (struct rnp_share_ops )); +if (!eth_dev->process_private) { +RNP_PMD_DRV_LOG (ERR ,"Could not calloc " +"for Process_priv\n" ); + goto fail_calloc; + } +return eth_dev; +fail_calloc: +rte_free (port); +rte_eth_dev_release_port (eth_dev); + +return NULL ; +} + +static int +rnp_eth_dev_init (struct rte_eth_dev *dev) +{ +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rnp_eth_adapter *adapter =NULL ; +char name[RTE_ETH_NAME_MAX_LEN ] =" " ; +struct rnp_eth_port *port =NULL ; +struct rte_eth_dev *eth_dev; +struct rnp_hw *hw =NULL ; +int32_t p_id; +int ret; + +PMD_INIT_FUNC_TRACE (); + +if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) +return 0 ; +memset (name,0 ,sizeof (name));
drivers/net/rnp/base/rnp_hw.h
Quoted 10 lines
drivers/net/rnp/base/rnp_hw.h new file +10
-0+snprintf (name,sizeof (name),"rnp_adapter_%d" , dev->data->port_id); + adapter =rte_zmalloc (name,sizeof (struct rnp_eth_adapter ),0 ); +if (!adapter) { +RNP_PMD_DRV_LOG (ERR ,"zmalloc for adapter failed\n" ); +return -ENOMEM ; + } + hw = &adapter->hw; + adapter->pdev = pci_dev; + adapter->eth_dev = dev; + adapter->num_ports =1 ;
This is hardcoded value, so no need the loop below but perhaps it is for future.
drivers/net/rnp/base/rnp_hw.h
Quoted 10 lines
drivers/net/rnp/base/rnp_hw.h new file +10
-0+ hw->back = adapter; + hw->iobar4 = pci_dev->mem_resource[RNP_CFG_BAR ].addr; + hw->iobar0 = pci_dev->mem_resource[RNP_PF_INFO_BAR ].addr; + hw->iobar4_len = pci_dev->mem_resource[RNP_CFG_BAR ].len; + hw->iobar0_len = pci_dev->mem_resource[RNP_PF_INFO_BAR ].len; + hw->device_id = pci_dev->id.device_id; + hw->vendor_id = pci_dev->id.vendor_id; + hw->device_id = pci_dev->id.device_id; +for (p_id =0 ; p_id < adapter->num_ports; p_id++) { +/* port 0 resource has been allocated When Probe */
Why 'When' & 'Probe' starts with uppercase, similar usage exists many places, although that is not an issue, just catches eye, can you please fix them if there is no specific reason.
drivers/net/rnp/base/rnp_hw.h
Quoted 12 lines
drivers/net/rnp/base/rnp_hw.h new file +12
-0+if (!p_id) { + eth_dev = dev; + }else { +snprintf (name,sizeof (name),"%s_%d" , + adapter->pdev->device.name, + p_id); + eth_dev =rnp_alloc_eth_port (pci_dev, name); +if (eth_dev) +rte_memcpy (eth_dev->process_private, + adapter->share_priv, +sizeof (*adapter->share_priv)); +if (!eth_dev) {
This can be 'else' leg of above branch.
drivers/net/rnp/base/rnp_hw.h
Quoted 7 lines
drivers/net/rnp/base/rnp_hw.h new file +7
-0+ ret = -ENOMEM ; + goto eth_alloc_error; + } + } + ret =rnp_init_port_resource (adapter, eth_dev, name, p_id); +if (ret) + goto eth_alloc_error;
'rnp_init_port_resource()' can't return error but perhaps this check is for future.
Quoted 5 lines
drivers/net/rnp/base/rnp_hw.h new file +5
-0+ +rnp_mac_rx_disable (eth_dev); +rnp_mac_tx_disable (eth_dev); + } +
drivers/net/rnp/base/rnp_hw.h
Quoted 10 lines
drivers/net/rnp/base/rnp_hw.h new file +10
-0+return 0 ; +eth_alloc_error: +for (p_id =0 ; p_id < adapter->num_ports; p_id++) { + port = adapter->ports[p_id]; +if (!port) +continue ; +if (port->eth_dev) { +rnp_dev_close (port->eth_dev); +rte_eth_dev_release_port (port->eth_dev); +if (port->eth_dev->process_private)
This should crash, because 'port' is 'dev_private' and 'rte_eth_dev_release_port()' frees the dev_private, so can't access 'port->' here.
Also 'process_private' set to NULL in the 'rte_eth_dev_release_port()', it should be freed in 'rnp_dev_close()', not here.
Quoted 43 lines
drivers/net/rnp/base/rnp_hw.h new file +31
-2+free (port->eth_dev->process_private); + } +rte_free (port); + } +rte_free (adapter); + +return 0 ; }static int rnp_eth_dev_uninit (struct rte_eth_dev *eth_dev) { -RTE_SET_USED (eth_dev); +struct rnp_eth_adapter *adapter =RNP_DEV_TO_ADAPTER (eth_dev); +struct rnp_eth_port *port =NULL ; +uint8_t p_id; + +if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) +return 0 ; -return -ENODEV ; +if (adapter->eth_dev != eth_dev) { +RNP_PMD_DRV_LOG (ERR ,"Input Argument ethdev " +"Isn't Primary Ethdev\n" ); +return -EINVAL ; + } +for (p_id =0 ; p_id < adapter->num_ports; p_id++) { + port = adapter->ports[p_id]; +if (!port) +continue ; +if (port->eth_dev) { +rnp_dev_close (port->eth_dev); +/* Just Release Not Primary Port Allocated By PMD */ +if (p_id) +rte_eth_dev_release_port (port->eth_dev); + } + } + +return 0 ; } static int
drivers/net/rnp/base/rnp_hw.h static struct rte_pci_driver rte_rnp_pmd = { · line 265
Quoted 7 lines
drivers/net/rnp/base/rnp_hw.h new file +4
-0@@ -84,3 +259,14 @@ static struct rte_pci_driver rte_rnp_pmd = {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" ); + +RTE_LOG_REGISTER_SUFFIX (rnp_init_logtype, init,NOTICE ); +RTE_LOG_REGISTER_SUFFIX (rnp_drv_logtype, driver,NOTICE ); +
Do you really need two different log types? What about reducing it to one?
<...>
Quoted 14 lines
drivers/net/rnp/rnp_osdep.h new file +8
-0@@ -0,0 +1,30 @@ +#ifndef __RNP_OSDEP_H__ +#define __RNP_OSDEP_H__ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(C) 2023 Mucse IC Design Ltd. +*/ +#include <stdint.h> + +#include <rte_byteorder.h>
drivers/net/rnp/rnp_osdep.h line 18
Quoted 10 lines
drivers/net/rnp/rnp_osdep.h new file +10
-0+ +#define __iomem +#define _RING_ (off) ((off) + 0x000000) +#define _DMA_ (off) ((off)) +#define _GLB_ (off) ((off) + 0x000000) +#define _NIC_ (off) ((off) + 0x000000) +#define _ETH_ (off) ((off)) +#define _MAC_ (off) ((off)) +#define BIT (n) (1UL << (n)) +#define BIT64 (n) (1ULL << (n))
DPDK has RTE_BIT64 / RTE_BIT32 macros that can be reused.
Quoted 12 lines
drivers/net/rnp/rnp_osdep.h new file +12
-0+#define BITS_PER_LONG (__SIZEOF_LONG__ * 8) +#define GENMASK (h, l) \ + (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) + +typedef uint8_t u8 ; +typedef uint16_t u16 ; +typedef uint32_t u32 ; +typedef uint64_t u64 ; +typedef int32_t s32 ; +typedef int16_t s16 ; +typedef int8_t s8 ; +#endif /* __RNP_OSDEP_H__ */
RE: [PATCH v6 3/8] net/rnp: add device init and uninit
Hi Ferruh,
Thanks your kindly review, please see the below comment.
Regards Wenbo
Quoted 26 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: 2023年9月5日 23:44
To: Wenbo Cao <[email protected]>; Anatoly Burakov <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v6 3/8] net/rnp: add device init and uninitQuoted 11 lines · Wenbo Cao
Add basic init and uninit function
Signed-off-by Wenbo Cao <[email protected]>--- drivers/net/rnp/base/rnp_hw.h | 19 ++++ drivers/net/rnp/meson.build | 1 + drivers/net/rnp/rnp.h | 25 +++++ drivers/net/rnp/rnp_ethdev.c | 196 +++++++++++++++++++++++++++++++++- drivers/net/rnp/rnp_logs.h | 34 ++++++ drivers/net/rnp/rnp_osdep.h | 30 ++++++ 6 files changed, 300 insertions(+), 5 deletions(-) create modeQuoted 4 lines
100644
drivers/net/rnp/base/rnp_hw.hcreate mode 100644drivers/net/rnp/rnp_logs.hcreate mode 100644drivers/net/rnp/rnp_osdep.h
Quoted 2 lines
'
rnp_osdep.h' not used at all in the patch, can you move it where it is used?
I got it.
Quoted 28 lines
Quoted 14 lines
(quoted diff) +0
-0
b/drivers/net/rnp/base/rnp_hw.hnew file mode 100644 index 0000000000..d80d23f4b4drivers/net/rnp/base/rnp_hw.h new file +8
-0@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(C) 2023 Mucse IC Design Ltd. +*/ +#ifndef __RNP_HW_H__ +#define __RNP_HW_H__ + +struct rnp_eth_adapter ; +struct rnp_hw {drivers/net/rnp/base/rnp_hw.h line 18
Quoted 10 lines
drivers/net/rnp/base/rnp_hw.h new file +10
-0+struct rnp_eth_adapter *back; +void *iobar0; +uint32_t iobar0_len; +void *iobar4; +uint32_t iobar4_len; + +uint16_t device_id; +uint16_t vendor_id; +} __rte_cache_aligned; +All structs seems alligned to the cache, although it may not hurt, it is better to align ones that is necessary for performance.
Quoted 2 lines
<...>
For this I need to select a often used struct value?
Quoted 6 lines
drivers/net/rnp/base/rnp_hw.h
Quoted 3 lines
drivers/net/rnp/base/rnp_hw.h new file +3
-0+ +static struct rte_eth_dev * +rnp_alloc_eth_port (struct rte_pci_device *primary_pci,char *name)Why variable name is '
primary_pci', are there different pci device types?
Because of the chip is just have two pcie-bdf, the can have max eight port, So rte_eth_dev_pci_generic_probe alloc the first port, the other port is a fake string Add for x:x.0_1, x:x.0_2, x:x.0_3, so the 'primary_pci' is to mark the real pci_addr
Quoted 11 lines
drivers/net/rnp/base/rnp_hw.h
Quoted 8 lines
drivers/net/rnp/base/rnp_hw.h new file +8
-0+{ +struct rnp_eth_port *port; +struct rte_eth_dev *eth_dev; + + eth_dev =rte_eth_dev_allocate (name); +if (!eth_dev) { +RNP_PMD_DRV_LOG (ERR ,"Could not allocate " +"eth_dev for %s\n" , name);Please don't split the log message, instead can do:
RNP_PMD_DRV_LOG(ERR,
Quoted 5 lines
"Could not allocate eth_dev for %s\n", name);Same for all log messages.
Ok, I got it.
Quoted 4 lines
Quoted 4 lines
drivers/net/rnp/base/rnp_hw.h new file +4
-0+return NULL ; + } + port = rte_zmalloc_socket(name, + sizeof(*port),
Quoted 9 lines
drivers/net/rnp/base/rnp_hw.h
Quoted 6 lines
drivers/net/rnp/base/rnp_hw.h new file +6
-0+RTE_CACHE_LINE_SIZE , + primary_pci->device.numa_node); +if (!port) { +RNP_PMD_DRV_LOG (ERR ,"Could not allocate " +"rnp_eth_port for %s\n" , name); +return NULL ;Should '
eth_dev' released here?
Yes , this need to free resource.
Quoted 36 lines
Quoted 36 lines
drivers/net/rnp/base/rnp_hw.h new file +36
-0+ } + eth_dev->data->dev_private = port; + eth_dev->process_private =calloc (1 ,sizeof (struct rnp_share_ops )); +if (!eth_dev->process_private) { +RNP_PMD_DRV_LOG (ERR ,"Could not calloc " +"for Process_priv\n" ); + goto fail_calloc; + } +return eth_dev; +fail_calloc: +rte_free (port); +rte_eth_dev_release_port (eth_dev); + +return NULL ; +} + +static int +rnp_eth_dev_init (struct rte_eth_dev *dev) { +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rnp_eth_adapter *adapter =NULL ; +char name[RTE_ETH_NAME_MAX_LEN ] =" " ; +struct rnp_eth_port *port =NULL ; +struct rte_eth_dev *eth_dev; +struct rnp_hw *hw =NULL ; +int32_t p_id; +int ret; + +PMD_INIT_FUNC_TRACE (); + +if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) +return 0 ; +memset (name,0 ,sizeof (name)); +snprintf (name,sizeof (name),"rnp_adapter_%d" , dev->data->port_id); + adapter =rte_zmalloc (name,sizeof (struct rnp_eth_adapter ),0 ); +if (!adapter) { +RNP_PMD_DRV_LOG (ERR ,"zmalloc for adapter failed\n" );
Quoted 9 lines
drivers/net/rnp/base/rnp_hw.h
Quoted 6 lines
drivers/net/rnp/base/rnp_hw.h new file +6
-0+return -ENOMEM ; + } + hw = &adapter->hw; + adapter->pdev = pci_dev; + adapter->eth_dev = dev; + adapter->num_ports =1 ;This is hardcoded value, so no need the loop below but perhaps it is for future.
I will change the commit sequence ,first achieve mailbox api get hw-info. So adapter->num_ports info will get from firmware.
Quoted 6 lines
Quoted 6 lines
drivers/net/rnp/base/rnp_hw.h new file +6
-0+ hw->back = adapter; + hw->iobar4 = pci_dev->mem_resource[RNP_CFG_BAR ].addr; + hw->iobar0 = pci_dev->mem_resource[RNP_PF_INFO_BAR ].addr; + hw->iobar4_len = pci_dev->mem_resource[RNP_CFG_BAR ].len; + hw->iobar0_len = pci_dev->mem_resource[RNP_PF_INFO_BAR ].len; + hw->device_id = pci_dev->id.device_id;
Quoted 9 lines
drivers/net/rnp/base/rnp_hw.h
Quoted 4 lines
drivers/net/rnp/base/rnp_hw.h new file +4
-0+ hw->vendor_id = pci_dev->id.vendor_id; + hw->device_id = pci_dev->id.device_id; +for (p_id =0 ; p_id < adapter->num_ports; p_id++) { +/* port 0 resource has been allocated When Probe */ Why 'When' & 'Probe' starts with uppercase, similar usage exists many places, although that is not an issue, just catches eye, can you please fix them if there is no specific reason.
There isn't special meaning, I will change it to low.
Quoted 6 lines
Quoted 6 lines
drivers/net/rnp/base/rnp_hw.h new file +6
-0+if (!p_id) { + eth_dev = dev; + }else { +snprintf (name,sizeof (name),"%s_%d" , + adapter->pdev->device.name, + p_id);
Quoted 9 lines
drivers/net/rnp/base/rnp_hw.h
Quoted 6 lines
drivers/net/rnp/base/rnp_hw.h new file +6
-0+ eth_dev =rnp_alloc_eth_port (pci_dev, name); +if (eth_dev) +rte_memcpy (eth_dev->process_private, + adapter->share_priv, +sizeof (*adapter->share_priv)); +if (!eth_dev) {This can be 'else' leg of above branch.
I will check the code.
Quoted 10 lines
drivers/net/rnp/base/rnp_hw.h
Quoted 7 lines
drivers/net/rnp/base/rnp_hw.h new file +7
-0+ ret = -ENOMEM ; + goto eth_alloc_error; + } + } + ret =rnp_init_port_resource (adapter, eth_dev, name, p_id); +if (ret) + goto eth_alloc_error;'
rnp_init_port_resource()' can't return error but perhaps this check is for future.
Thanks for you advise, I will consider it .
Quoted 19 lines
Quoted 5 lines
drivers/net/rnp/base/rnp_hw.h new file +5
-0+ +rnp_mac_rx_disable (eth_dev); +rnp_mac_tx_disable (eth_dev); + } +drivers/net/rnp/base/rnp_hw.h
Quoted 10 lines
drivers/net/rnp/base/rnp_hw.h new file +10
-0+return 0 ; +eth_alloc_error: +for (p_id =0 ; p_id < adapter->num_ports; p_id++) { + port = adapter->ports[p_id]; +if (!port) +continue ; +if (port->eth_dev) { +rnp_dev_close (port->eth_dev); +rte_eth_dev_release_port (port->eth_dev); +if (port->eth_dev->process_private)This should crash, because 'port' is '
dev_private' and 'rte_eth_dev_release_port()' frees thedev_private, so can't access 'port->' here.
Quoted 1 line
drivers/net/rnp/base/rnp_hw.h
Quoted 1 line
drivers/net/rnp/base/rnp_hw.h new file +1
-0+for (p_id =0 ; p_id < adapter->num_ports; p_id++) {
This adapter->num_ports need to use port init success num.
Quoted 3 lines
Also '
process_private' set to NULL in the 'rte_eth_dev_release_port()', it should be freed in 'rnp_dev_close()', not here.
I have miss check the last dpdk version.
Quoted 53 lines
Quoted 46 lines
drivers/net/rnp/base/rnp_hw.h new file +31
-2+free (port->eth_dev->process_private); + } +rte_free (port); + } +rte_free (adapter); + +return 0 ; }static int rnp_eth_dev_uninit (struct rte_eth_dev *eth_dev) { -RTE_SET_USED (eth_dev); +struct rnp_eth_adapter *adapter =RNP_DEV_TO_ADAPTER (eth_dev); +struct rnp_eth_port *port =NULL ; +uint8_t p_id; + +if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) +return 0 ; -return -ENODEV ; +if (adapter->eth_dev != eth_dev) { +RNP_PMD_DRV_LOG (ERR ,"Input Argument ethdev " +"Isn't Primary Ethdev\n" ); +return -EINVAL ; + } +for (p_id =0 ; p_id < adapter->num_ports; p_id++) { + port = adapter->ports[p_id]; +if (!port) +continue ; +if (port->eth_dev) { +rnp_dev_close (port->eth_dev); +/* Just Release Not Primary Port Allocated By PMD */ +if (p_id) +rte_eth_dev_release_port (port->eth_dev); + } + } + +return 0 ; } static int@@ -84,3 +259,14 @@ static struct rte_pci_driver rte_rnp_pmd = {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/base/rnp_hw.h
Quoted 4 lines
drivers/net/rnp/base/rnp_hw.h new file +4
-0+ +RTE_LOG_REGISTER_SUFFIX (rnp_init_logtype, init,NOTICE ); +RTE_LOG_REGISTER_SUFFIX (rnp_drv_logtype, driver,NOTICE ); +Do you really need two different log types? What about reducing it to one?
Quoted 2 lines
<...>
This can reduce it .
Quoted 17 lines
Quoted 17 lines
drivers/net/rnp/rnp_osdep.h new file +12
-0@@ -0,0 +1,30 @@ +#ifndef __RNP_OSDEP_H__ +#define __RNP_OSDEP_H__ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(C) 2023 Mucse IC Design Ltd. +*/ +#include <stdint.h> + +#include <rte_byteorder.h> + +#define __iomem +#define _RING_ (off) ((off) + 0x000000) +#define _DMA_ (off) ((off))
Quoted 9 lines
drivers/net/rnp/rnp_osdep.h line 18
Quoted 6 lines
drivers/net/rnp/rnp_osdep.h new file +6
-0+#define _GLB_ (off) ((off) + 0x000000) +#define _NIC_ (off) ((off) + 0x000000) +#define _ETH_ (off) ((off)) +#define _MAC_ (off) ((off)) +#define BIT (n) (1UL << (n)) +#define BIT64 (n) (1ULL << (n))DPDK has
RTE_BIT64/RTE_BIT32macros that can be reused.
Old DPDK version don't have the macro, this can be removed.
Quoted 13 lines
Quoted 12 lines
drivers/net/rnp/rnp_osdep.h new file +12
-0+#define BITS_PER_LONG (__SIZEOF_LONG__ * 8) +#define GENMASK (h, l) \ + (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) + +typedef uint8_t u8 ; +typedef uint16_t u16 ; +typedef uint32_t u32 ; +typedef uint64_t u64 ; +typedef int32_t s32 ; +typedef int16_t s16 ; +typedef int8_t s8 ; +#endif /* __RNP_OSDEP_H__ */
PATCH v6 4/8 net/rnp: add mbx basic api feature
In reply to Wenbo Caombx base code is for communicate with the firmware
--- drivers/net/rnp/base/rnp_api.c | 23 ++ drivers/net/rnp/base/rnp_api.h | 7 + drivers/net/rnp/base/rnp_cfg.h | 7 + drivers/net/rnp/base/rnp_dma_regs.h | 73 ++++ drivers/net/rnp/base/rnp_eth_regs.h | 124 +++++++ drivers/net/rnp/base/rnp_hw.h | 112 +++++- drivers/net/rnp/meson.build | 1 + drivers/net/rnp/rnp.h | 35 ++ drivers/net/rnp/rnp_ethdev.c | 70 +++- drivers/net/rnp/rnp_logs.h | 9 + drivers/net/rnp/rnp_mbx.c | 522 ++++++++++++++++++++++++++++ drivers/net/rnp/rnp_mbx.h | 139 ++++++++ drivers/net/rnp/rnp_mbx_fw.c | 271 +++++++++++++++ drivers/net/rnp/rnp_mbx_fw.h | 22 ++ 14 files changed, 1412 insertions(+), 3 deletions(-) create mode 100644 drivers/net/rnp/base/rnp_api.c create mode 100644 drivers/net/rnp/base/rnp_api.h create mode 100644 drivers/net/rnp/base/rnp_cfg.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/rnp_mbx.c create mode 100644 drivers/net/rnp/rnp_mbx.h create mode 100644 drivers/net/rnp/rnp_mbx_fw.c create mode 100644 drivers/net/rnp/rnp_mbx_fw.h
drivers/net/rnp/base/rnp_api.c new file +23 -0
@@ -0,0 +1,23 @@ +#include "rnp.h" +#include "rnp_api.h" + +int +rnp_init_hw (struct rte_eth_dev *dev) +{ +const struct rnp_mac_api *ops =RNP_DEV_TO_MAC_OPS (dev); +struct rnp_hw *hw =RNP_DEV_TO_HW (dev); + +if (ops->init_hw) +return ops->init_hw (hw); +return -EOPNOTSUPP ; +} + +int +rnp_reset_hw (struct rte_eth_dev *dev,struct rnp_hw *hw) +{ +const struct rnp_mac_api *ops =RNP_DEV_TO_MAC_OPS (dev); + +if (ops->reset_hw) +return ops->reset_hw (hw); +return -EOPNOTSUPP ; +}
drivers/net/rnp/base/rnp_api.h new file +7 -0
@@ -0,0 +1,7 @@ +#ifndef __RNP_API_H__ +#define __RNP_API_H__ +int +rnp_init_hw (struct rte_eth_dev *dev); +int +rnp_reset_hw (struct rte_eth_dev *dev,struct rnp_hw *hw); +#endif /* __RNP_API_H__ */
drivers/net/rnp/base/rnp_cfg.h new file +7 -0
@@ -0,0 +1,7 @@ +#ifndef __RNP_CFG_H__ +#define __RNP_CFG_H__ +#include "rnp_osdep.h" + +#define RNP_NIC_RESET _NIC_(0x0010) +#define RNP_TX_QINQ_WORKAROUND _NIC_(0x801c) +#endif /* __RNP_CFG_H__ */
drivers/net/rnp/base/rnp_dma_regs.h new file +73 -0
73 lines not on this page · raw message
drivers/net/rnp/base/rnp_eth_regs.h new file +124 -0
124 lines not on this page · raw message
drivers/net/rnp/base/rnp_hw.h +111 -1
127 lines not on this page · raw message
drivers/net/rnp/meson.build +1 -0
@@ -8,5 +8,6 @@ endif sources = files( 'rnp_ethdev.c', + 'rnp_mbx.c', ) includes += include_directories('base')
drivers/net/rnp/rnp.h +35 -0
@@ -3,6 +3,7 @@*/ #ifndef __RNP_H__#define __RNP_H__ +#include <rte_log.h> #include "base/rnp_hw.h"
@@ -14,14 +15,17 @@struct rnp_eth_port {struct rnp_eth_adapter *adapt; +struct rnp_hw *hw;struct rte_eth_dev *eth_dev; } __rte_cache_aligned;struct rnp_share_ops { +const struct rnp_mbx_api *mbx_api; } __rte_cache_aligned;struct rnp_eth_adapter {struct rnp_hw hw; +uint16_t max_vfs;struct rte_pci_device *pdev;struct rte_eth_dev *eth_dev;/* primary eth_dev */ struct rnp_eth_port *ports[RNP_MAX_PORT_OF_PF ];
@@ -34,5 +38,36 @@ struct rnp_eth_adapter { (((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)->adapt)) +#define RNP_DEV_TO_HW (eth_dev) \ + (&((struct rnp_eth_adapter *)(RNP_DEV_TO_PORT((eth_dev))->adapt))->hw) +#define RNP_DEV_PP_PRIV_TO_MBX_OPS (dev) \ + (((struct rnp_share_ops *)(dev)->process_private)->mbx_api) +#define RNP_DEV_TO_MBX_OPS (dev) RNP_DEV_PP_PRIV_TO_MBX_OPS(dev) +static inline void rnp_reg_offset_init (struct rnp_hw *hw) +{ +uint16_t i; + +if (hw->device_id ==RNP_DEV_ID_N10G && hw->mbx.pf_num) { + hw->iobar4 = (void *)((uint8_t *)hw->iobar4 +0x100000 ); + hw->msix_base = (void *)((uint8_t *)hw->iobar4 +0xa4000 ); + hw->msix_base = (void *)((uint8_t *)hw->msix_base +0x200 ); + }else { + hw->msix_base = (void *)((uint8_t *)hw->iobar4 +0xa4000 ); + } +/* === dma status/config====== */ + hw->link_sync = (void *)((uint8_t *)hw->iobar4 +0x000c ); + hw->dma_axi_en = (void *)((uint8_t *)hw->iobar4 +0x0010 ); + hw->dma_axi_st = (void *)((uint8_t *)hw->iobar4 +0x0014 ); + +if (hw->mbx.pf_num) + hw->msix_base = (void *)((uint8_t *)0x200 ); +/* === queue registers === */ + hw->dma_base = (void *)((uint8_t *)hw->iobar4 +0x08000 ); + hw->veb_base = (void *)((uint8_t *)hw->iobar4 +0x0 ); + hw->eth_base = (void *)((uint8_t *)hw->iobar4 +0x10000 ); +/* mac */ +for (i =0 ; i <RNP_MAX_HW_PORT_PERR_PF ; i++) + hw->mac_base[i] = (void *)((uint8_t *)hw->iobar4 +0x60000 +0x10000 * i); +}#endif /* __RNP_H__ */
drivers/net/rnp/rnp_ethdev.c +68 -2
97 lines not on this page · raw message
drivers/net/rnp/rnp_logs.h +9 -0
@@ -13,6 +13,15 @@ extern int rnp_drv_logtype; #define RNP_PMD_DRV_LOG(level, fmt, args...) \ rte_log(RTE_LOG_##level, rnp_drv_logtype, \ "%s() " fmt, __func__, ##args) +#define PMD_DRV_LOG_RAW(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, rnp_drv_logtype, "%s(): " fmt, \ + __func__, ## args) +#define PMD_DRV_LOG(level, fmt, args...) \ + PMD_DRV_LOG_RAW(level, fmt "\n", ## args) + +#define RNP_PMD_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_##level, rnp_drv_logtype, \ + "rnp_net: (%d) " fmt, __LINE__, ##args)#ifdef RTE_LIBRTE_RNP_DEBUG_RX extern int rnp_rx_logtype; #define RNP_PMD_RX_LOG(level, fmt, args...) \
drivers/net/rnp/rnp_mbx.c new file +522 -0
522 lines not on this page · raw message
drivers/net/rnp/rnp_mbx.h new file +139 -0
139 lines not on this page · raw message
drivers/net/rnp/rnp_mbx_fw.c new file +271 -0
271 lines not on this page · raw message
drivers/net/rnp/rnp_mbx_fw.h new file +22 -0
@@ -0,0 +1,22 @@ +#ifndef __RNP_MBX_FW_H__ +#define __RNP_MBX_FW_H__ + +struct mbx_fw_cmd_reply ; +typedef void (*cookie_cb )(struct mbx_fw_cmd_reply *reply,void *priv); +#define RNP_MAX_SHARE_MEM (8 * 8) +struct mbx_req_cookie { +int magic; +#define COOKIE_MAGIC 0xCE +cookie_cb cb; +int timeout_ms; +int errcode; + +/* wait_queue_head_t wait; */ +volatile int done; +int priv_len; +char priv[RNP_MAX_SHARE_MEM ]; +}; +struct mbx_fw_cmd_reply { +} __rte_cache_aligned; + +#endif /* __RNP_MBX_FW_H__*/
Signature · 1 line
2.27.0
Re: [PATCH v6 4/8] net/rnp: add mbx basic api feature
Quoted 2 lines · Wenbo Cao
mbx base code is for communicate with the firmware
I assume mbx is mailbox, can you please use full name in the patch title and commit log.
How the parties get notified about new messages, is the interrupt support enabled or polling, can you please elabore the support in the commit log?
Quoted 9 lines
Signed-off-by Wenbo Cao <[email protected]>Suggested-by Stephen Hemminger <[email protected]>--- drivers/net/rnp/base/rnp_api.c | 23 ++ drivers/net/rnp/base/rnp_api.h | 7 + drivers/net/rnp/base/rnp_cfg.h | 7 + drivers/net/rnp/base/rnp_dma_regs.h | 73 ++++ drivers/net/rnp/base/rnp_eth_regs.h | 124 +++++++ drivers/net/rnp/base/rnp_hw.h | 112 +++++-
Why there is no meson file in base folder?
Quoted 8 lines
drivers/net/rnp/meson.build | 1 + drivers/net/rnp/rnp.h | 35 ++ drivers/net/rnp/rnp_ethdev.c | 70 +++- drivers/net/rnp/rnp_logs.h | 9 + drivers/net/rnp/rnp_mbx.c | 522 ++++++++++++++++++++++++++++ drivers/net/rnp/rnp_mbx.h | 139 ++++++++ drivers/net/rnp/rnp_mbx_fw.c | 271 +++++++++++++++ drivers/net/rnp/rnp_mbx_fw.h | 22 ++
Should 'rnp_mbx*' files also go under base folder? I can see they use some 'u8' like typedef, making me think they are shared between other platforms, if so base folder suits better.
Quoted 18 lines
14 files changed, 1412 insertions(+), 3 deletions(-) create mode 100644 drivers/net/rnp/base/rnp_api.c create mode 100644 drivers/net/rnp/base/rnp_api.h create mode 100644 drivers/net/rnp/base/rnp_cfg.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/rnp_mbx.c create mode 100644 drivers/net/rnp/rnp_mbx.h create mode 100644 drivers/net/rnp/rnp_mbx_fw.c create mode 100644 drivers/net/rnp/rnp_mbx_fw.hdrivers/net/rnp/base/rnp_api.c new file +0
-0
drivers/net/rnp/base/rnp_api.c line 6
Quoted 6 lines
drivers/net/rnp/base/rnp_api.c new file +6
-0@@ -0,0 +1,23 @@ +#include "rnp.h" +#include "rnp_api.h" + +int +rnp_init_hw (struct rte_eth_dev *dev) +{
Base code is mostly for works as HAL and you don't need to pass "struct rte_eth_dev" in this level, but mostly adapte (struct rnp_eth_adapter) or hw (struct rnp_hw) should be sufficient.
I assume you are passing "struct rte_eth_dev" because "struct rnp_mac_api" is stored in 'process_private', this part I am not clear.
Why need 'mac_ops' pointers for secondary process?
Primary process should be doing all hw initialization, otherwise both primary and secondar(y|ies) trying to configure the MAC can cause unexpected results.
Seconday process is only for datapath, which can access to the queues and do packet processing.
Needing "mac_ops" in the secondary can be bad design desicion, can you please double check it?
<...>
Quoted 13 lines
drivers/net/rnp/rnp.h +1
-0@@ -3,6 +3,7 @@*/ #ifndef __RNP_H__#define __RNP_H__ +#include <rte_log.h> #include "base/rnp_hw.h"
drivers/net/rnp/rnp.h line 18
Quoted 4 lines
drivers/net/rnp/rnp.h +1
-0@@ -14,14 +15,17 @@struct rnp_eth_port {struct rnp_eth_adapter *adapt; +struct rnp_hw *hw;
adapter already has the 'hw', is there a specific reason not to access it via 'port->adapt->hw'
Quoted 35 lines
drivers/net/rnp/rnp.h +19
-0struct rte_eth_dev *eth_dev; } __rte_cache_aligned;struct rnp_share_ops { +const struct rnp_mbx_api *mbx_api; } __rte_cache_aligned;struct rnp_eth_adapter {struct rnp_hw hw; +uint16_t max_vfs;struct rte_pci_device *pdev;struct rte_eth_dev *eth_dev;/* primary eth_dev */ struct rnp_eth_port *ports[RNP_MAX_PORT_OF_PF ];@@ -34,5 +38,36 @@ struct rnp_eth_adapter { (((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)->adapt)) +#define RNP_DEV_TO_HW (eth_dev) \ + (&((struct rnp_eth_adapter *)(RNP_DEV_TO_PORT((eth_dev))->adapt))->hw) +#define RNP_DEV_PP_PRIV_TO_MBX_OPS (dev) \ + (((struct rnp_share_ops *)(dev)->process_private)->mbx_api) +#define RNP_DEV_TO_MBX_OPS (dev) RNP_DEV_PP_PRIV_TO_MBX_OPS(dev) +static inline void rnp_reg_offset_init (struct rnp_hw *hw) +{ +uint16_t i; + +if (hw->device_id ==RNP_DEV_ID_N10G && hw->mbx.pf_num) { + hw->iobar4 = (void *)((uint8_t *)hw->iobar4 +0x100000 ); + hw->msix_base = (void *)((uint8_t *)hw->iobar4 +0xa4000 ); + hw->msix_base = (void *)((uint8_t *)hw->msix_base +0x200 ); + }else { + hw->msix_base = (void *)((uint8_t *)hw->iobar4 +0xa4000 ); + } +/* === dma status/config====== */
drivers/net/rnp/rnp.h struct rnp_eth_adapter { · line 68
Quoted 10 lines
drivers/net/rnp/rnp.h +10
-0+ hw->link_sync = (void *)((uint8_t *)hw->iobar4 +0x000c ); + hw->dma_axi_en = (void *)((uint8_t *)hw->iobar4 +0x0010 ); + hw->dma_axi_st = (void *)((uint8_t *)hw->iobar4 +0x0014 ); + +if (hw->mbx.pf_num) + hw->msix_base = (void *)((uint8_t *)0x200 ); +/* === queue registers === */ + hw->dma_base = (void *)((uint8_t *)hw->iobar4 +0x08000 ); + hw->veb_base = (void *)((uint8_t *)hw->iobar4 +0x0 ); + hw->eth_base = (void *)((uint8_t *)hw->iobar4 +0x10000 );
There are lots of hardcoded values in this function, can you make them macros?
Quoted 35 lines
drivers/net/rnp/rnp.h +4
-0+/* mac */ +for (i =0 ; i <RNP_MAX_HW_PORT_PERR_PF ; i++) + hw->mac_base[i] = (void *)((uint8_t *)hw->iobar4 + 0x60000 + 0x10000 * i); +}#endif /* __RNP_H__ */ drivers/net/rnp/rnp_ethdev.c +15
-0@@ -8,6 +8,7 @@#include <ethdev_driver.h> #include "rnp.h" +#include "rnp_mbx.h" #include "rnp_logs.h" static int@@ -89,6 +90,58 @@ rnp_alloc_eth_port(struct rte_pci_device *primary_pci, char *name)return NULL ; } +static void rnp_get_nic_attr (struct rnp_eth_adapter *adapter) +{ +RTE_SET_USED (adapter); +} + +static int +rnp_process_resource_init (struct rte_eth_dev *eth_dev) +{ +struct rnp_share_ops *share_priv; + +/* allocate process_private memory this must can't +* belone to the dpdk mem resource manager +* such as from rte_malloc or rte_dma_zone.. +*/
drivers/net/rnp/rnp_ethdev.c rnp_alloc_eth_port(struct rte_pci_device *primary_pci, char *name) · line 116
Quoted 10 lines
drivers/net/rnp/rnp_ethdev.c +10
-0+/* use the process_prive point to resolve secondary process +* use point-func. This point is per process will be safe to cover. +* This will cause secondary process core-dump because of IPC +* Secondary will call primary process point func virt-address +* secondary process don't alloc user/pmd to alloc or free +* the memory of dpdk-mem resource it will cause hugepage +* mem exception +* be careful for secondary Process to use the share-mem of +* point correlation +*/
As commented above, I am not sure why you need this, it should be sufficient to have mac_ops in primary proccess.
Quoted 32 lines
drivers/net/rnp/rnp_ethdev.c +28
-0+ share_priv =calloc (1 ,sizeof (*share_priv)); +if (!share_priv) { +PMD_DRV_LOG (ERR ,"calloc share_priv failed" ); +return -ENOMEM ; + } +memset (share_priv,0 ,sizeof (*share_priv)); + eth_dev->process_private = share_priv; + +return 0 ; +} + +static void +rnp_common_ops_init (struct rnp_eth_adapter *adapter) +{ +struct rnp_share_ops *share_priv; + + share_priv = adapter->share_priv; + share_priv->mbx_api = &rnp_mbx_pf_ops; +} + +static int +rnp_special_ops_init (struct rte_eth_dev *eth_dev) +{ +RTE_SET_USED (eth_dev); + +return 0 ; +} +static int rnp_eth_dev_init (struct rte_eth_dev *dev) {
drivers/net/rnp/rnp_ethdev.c rnp_eth_dev_init(struct rte_eth_dev *dev) · line 186
Quoted 10 lines
drivers/net/rnp/rnp_ethdev.c +7
-0@@ -124,6 +177,20 @@ rnp_eth_dev_init(struct rte_eth_dev *dev) hw->device_id = pci_dev->id.device_id; hw->vendor_id = pci_dev->id.vendor_id; hw->device_id = pci_dev->id.device_id; + adapter->max_vfs = pci_dev->max_vfs; + ret =rnp_process_resource_init (dev); +if (ret) { +PMD_DRV_LOG (ERR ,"share prive resource init failed" ); +return ret; + } + adapter->share_priv = dev->process_private;
Isn't 'adapter' shared betwen primary and secondary ('port' is dev_private and 'port->adapt' is 'adapter'), so updating "adapter->share_priv" defeats the purpose of process_private, no?
drivers/net/rnp/rnp_ethdev.c rnp_eth_dev_init(struct rte_eth_dev *dev)
Quoted 5 lines
drivers/net/rnp/rnp_ethdev.c +4
-0+rnp_common_ops_init (adapter); +rnp_get_nic_attr (adapter); +/* We need Use Device Id To Change The Resource Mode */ +rnp_special_ops_init (dev);
You can add this when it is needed, so in same patch we can see where it is called and how it is implemented, right now it is not possible that what 'special' init does.
drivers/net/rnp/rnp_ethdev.c rnp_eth_dev_init(struct rte_eth_dev *dev) · line 192
Quoted 2 lines
drivers/net/rnp/rnp_ethdev.c +2
-0+ port->adapt = adapter; + port->hw = hw;
At this stage port is NULL, probably above needs to go to other patch that sets 'port'.
Quoted 24 lines
drivers/net/rnp/rnp_ethdev.c +1
-0+rnp_init_mbx_ops_pf (hw);for (p_id =0 ; p_id < adapter->num_ports; p_id++) {/* port 0 resource has been allocated When Probe */ drivers/net/rnp/rnp_ethdev.c +1
-2if (!p_id) {@@ -158,11 +225,10 @@ rnp_eth_dev_init(struct rte_eth_dev *dev)continue ;if (port->eth_dev) {rnp_dev_close (port->eth_dev); -rte_eth_dev_release_port (port->eth_dev);if (port->eth_dev->process_private)free (port->eth_dev->process_private); +rte_eth_dev_release_port (port->eth_dev); } -rte_free (port); }rte_free (adapter);drivers/net/rnp/rnp_logs.h +0
-0@@ -13,6 +13,15 @@ extern int rnp_drv_logtype; #define RNP_PMD_DRV_LOG(level, fmt, args...) \ rte_log(RTE_LOG_##level, rnp_drv_logtype, \
drivers/net/rnp/rnp_logs.h extern int rnp_drv_logtype; · line 24
Quoted 10 lines
drivers/net/rnp/rnp_logs.h +9
-0"%s() " fmt, __func__, ##args) +#define PMD_DRV_LOG_RAW(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, rnp_drv_logtype, "%s(): " fmt, \ + __func__, ## args) +#define PMD_DRV_LOG(level, fmt, args...) \ + PMD_DRV_LOG_RAW(level, fmt "\n", ## args) + +#define RNP_PMD_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_##level, rnp_drv_logtype, \ + "rnp_net: (%d) " fmt, __LINE__, ##args)
With these there are three different macros used to log in 'rnp_drv_logtype' type:
RNP_PMD_LOGPMD_DRV_LOGRNP_PMD_DRV_LOG
'RNP_PMD_DRV_LOG' and 'PMD_DRV_LOG' looks exact same, do you need all these macros, why not stick to one?
If more than one required, can you please comment what is used for what, and perhaps rename macros in a way that it is clear which one to use where (as I assume one is specific to base files).
<...>
Quoted 31 lines
drivers/net/rnp/rnp_logs.h +31
-0+/** +* rnp_write_mbx_pf - Places a message in the mailbox +* @hw: pointer to the HW structure +* @msg: The message buffer +* @size: Length of buffer +* @mbx_id: the VF index +* +* returns SUCCESS if it successfully copied message into the buffer +**/ +static int32_t rnp_write_mbx_pf (struct rnp_hw *hw,u32 *msg, +u16 size,enum MBX_ID mbx_id) +{ +u32 DATA_REG = (mbx_id ==MBX_CM3CPU ) ? +CPU_PF_SHM_DATA :PF_VF_SHM_DATA (mbx_id); +u32 CTRL_REG = (mbx_id ==MBX_CM3CPU ) ? +PF2CPU_MBOX_CTRL :PF2VF_MBOX_CTRL (mbx_id); +int32_t ret_val =0 ; + u32 stat __rte_unused; +u16 i; + +if (size >RNP_VFMAILBOX_SIZE ) { +RNP_PMD_LOG (ERR ,"%s: size:%d should <%d\n" , __func__, + size,RNP_VFMAILBOX_SIZE ); +return -EINVAL ; + } + +/* lock the mailbox to prevent pf/vf/cpu race condition */ + ret_val =rnp_obtain_mbx_lock_pf (hw, mbx_id); +if (ret_val) { +RNP_PMD_LOG (WARNING ,"PF[%d] Can't Get Mbx-Lock Try Again\n" , + hw->function);
drivers/net/rnp/rnp_logs.h extern int rnp_drv_logtype;
Quoted 10 lines
drivers/net/rnp/rnp_logs.h +10
-0+return ret_val; + } + +/* copy the caller specified message to the mailbox memory buffer */ +for (i =0 ; i < size; i++) { +#ifdef MBX_WR_DEBUG +mbx_pwr32 (hw,DATA_REG + i *4 , msg[i]); +#else +mbx_wr32 (hw,DATA_REG + i *4 , msg[i]); +#endif
Who sets this define, if not used please remove it.
RE: [PATCH v6 4/8] net/rnp: add mbx basic api feature
Hi Ferruh,
Please see the below comment :)
Regards Wenbo
Quoted 8 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: 2023年9月5日 23:45
To: Wenbo Cao <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Stephen Hemminger <[email protected]>
Subject: Re: [PATCH v6 4/8] net/rnp: add mbx basic api feature
Quoted 7 lines
Quoted 2 lines · Wenbo Cao
mbx base code is for communicate with the firmware
I assume mbx is mailbox, can you please use full name in the patch title and commit log.
Yes, mbx is mailbox.
I will change the commit log
Quoted 13 lines
How the parties get notified about new messages, is the interrupt support enabled or polling, can you please elabore the support in the commit log?
Quoted 9 lines
Signed-off-by Wenbo Cao <[email protected]>Suggested-by Stephen Hemminger <[email protected]>--- drivers/net/rnp/base/rnp_api.c | 23 ++ drivers/net/rnp/base/rnp_api.h | 7 + drivers/net/rnp/base/rnp_cfg.h | 7 + drivers/net/rnp/base/rnp_dma_regs.h | 73 ++++ drivers/net/rnp/base/rnp_eth_regs.h | 124 +++++++ drivers/net/rnp/base/rnp_hw.h | 112 +++++-
Quoted 2 lines
Why there is no meson file in base folder?
For base folder also need meson.build ?
I have add the base/.c in the rnp/meson.build.
Do I need to split it to the base/meson.build ?
Quoted 9 lines
Quoted 8 lines
drivers/net/rnp/meson.build | 1 + drivers/net/rnp/rnp.h | 35 ++ drivers/net/rnp/rnp_ethdev.c | 70 +++- drivers/net/rnp/rnp_logs.h | 9 + drivers/net/rnp/rnp_mbx.c | 522 ++++++++++++++++++++++++++++ drivers/net/rnp/rnp_mbx.h | 139 ++++++++ drivers/net/rnp/rnp_mbx_fw.c | 271 +++++++++++++++ drivers/net/rnp/rnp_mbx_fw.h | 22 ++
Quoted 4 lines
Should 'rnp_mbx*' files also go under base folder? I can see they use some 'u8' like typedef, making me think they are shared between other platforms, if so base folder suits better.
Yes, the mbx.c or rnp_mbx_fw.c is share code, need change to the base folder.
Quoted 20 lines
Quoted 20 lines
14 files changed, 1412 insertions(+), 3 deletions(-) create mode100644
drivers/net/rnp/base/rnp_api.ccreate mode 100644drivers/net/rnp/base/rnp_api.hcreate mode 100644drivers/net/rnp/base/rnp_cfg.hcreate mode 100644drivers/net/rnp/base/rnp_dma_regs.hcreate mode 100644 drivers/net/rnp/base/rnp_eth_regs.h create mode 100644 drivers/net/rnp/rnp_mbx.c create mode 100644
drivers/net/rnp/rnp_mbx.hcreate mode 100644drivers/net/rnp/rnp_mbx_fw.ccreate mode 100644drivers/net/rnp/rnp_mbx_fw.h(quoted diff) +0
-0
b/drivers/net/rnp/base/rnp_api.cnew file mode 100644 index 0000000000..550da6217ddrivers/net/rnp/base/rnp_api.c new file +3
-0@@ -0,0 +1,23 @@ +#include "rnp.h" +#include "rnp_api.h" +
Quoted 9 lines
drivers/net/rnp/base/rnp_api.c line 6
Quoted 4 lines
drivers/net/rnp/base/rnp_api.c new file +3
-0+int +rnp_init_hw (struct rte_eth_dev *dev) +{Base code is mostly for works as HAL and you don't need to pass "struct
rte_eth_dev" in this level, but mostly adapte (structrnp_eth_adapter) or hw (structrnp_hw) should be sufficient.
Because of one-pcie-bdf have multiple-port, the hw only manage by the adapter struct But the adapter struct and hw struct don't have port info(0,1,2,3). For this problem I can change 'rte_eth_dev' to struct rnp_eth_port'
Quoted 7 lines
I assume you are passing "struct
rte_eth_dev" because "structrnp_mac_api" is stored in 'process_private', this part I am not clear.Why need '
mac_ops' pointers for secondary process?
Primary process should be doing all hw initialization, otherwise both primary and secondar(y|ies) trying to configure the MAC can cause unexpected results.
For secondary process support to set, I find refer driver don't have limit for 'dev->dev_ops' set in SECONDARY mode.
.promiscuous_enable
.promiscuous_disable
.allmulticast_enable
.allmulticast_disable
.fw_version_get
Quoted 3 lines
Seconday process is only for datapath, which can access to the queues and do packet processing.
For secondary process support to set, I find refer driver don't have limit for 'dev->dev_ops' set in SECONDARY mode.
User can set api , if 'dev->dev_ops' set don’t limit.
Quoted 5 lines
Needing "
mac_ops" in the secondary can be bad design desicion, can you please double check it?<...>
I refer to some exist driver, it is not special limit for SECONDARY process for 'dev->dev_ops' set. So when I test some code fond that some api will be cause crash such as 'get_module_eeprom' And I find this is because of function point api, the secondary process use primary function point api address. The address for secondary is can't reach. So I try to move the mac_ops, mbx_ops to the process_prive to resolved this problem. Primary and secondary will have it own function point api address.
Quoted 61 lines
Quoted 13 lines
drivers/net/rnp/rnp.h index renamed from drivers/net/rnp/rnp.h +0
-0
cab1b8e85d..6e12885877100644drivers/net/rnp/rnp.h +1
-0@@ -3,6 +3,7 @@*/ #ifndef __RNP_H__#define __RNP_H__ +#include <rte_log.h> #include "base/rnp_hw.h" drivers/net/rnp/rnp.h line 18
Quoted 4 lines
drivers/net/rnp/rnp.h +1
-0@@ -14,14 +15,17 @@struct rnp_eth_port {struct rnp_eth_adapter *adapt; +struct rnp_hw *hw;adapter already has the 'hw', is there a specific reason not to access it via 'port-
Quoted 5 lines
adapt->hw'drivers/net/rnp/rnp.h +0
-0struct rte_eth_dev *eth_dev; } __rte_cache_aligned;drivers/net/rnp/rnp.h
Quoted 10 lines
drivers/net/rnp/rnp.h +2
-0struct rnp_share_ops { +const struct rnp_mbx_api *mbx_api; } __rte_cache_aligned;struct rnp_eth_adapter {struct rnp_hw hw; +uint16_t max_vfs;struct rte_pci_device *pdev;struct rte_eth_dev *eth_dev;/* primary eth_dev */ struct rnp_eth_port *ports[RNP_MAX_PORT_OF_PF]; @@ -34,5 +38,36@@
Quoted 26 lines
struct
rnp_eth_adapter{drivers/net/rnp/rnp.h +21
-0(((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)->adapt)) +#define RNP_DEV_TO_HW (eth_dev) \ + (&((struct rnp_eth_adapter +*)(RNP_DEV_TO_PORT((eth_dev))->adapt))->hw) +#define RNP_DEV_PP_PRIV_TO_MBX_OPS (dev) \ + (((struct rnp_share_ops *)(dev)->process_private)->mbx_api) +#define RNP_DEV_TO_MBX_OPS (dev) RNP_DEV_PP_PRIV_TO_MBX_OPS(dev) +static inline void rnp_reg_offset_init (struct rnp_hw *hw) { +uint16_t i; + +if (hw->device_id ==RNP_DEV_ID_N10G && hw->mbx.pf_num) { + hw->iobar4 = (void *)((uint8_t *)hw->iobar4 +0x100000 ); + hw->msix_base = (void *)((uint8_t *)hw->iobar4 +0xa4000 ); + hw->msix_base = (void *)((uint8_t *)hw->msix_base +0x200 ); + }else { + hw->msix_base = (void *)((uint8_t *)hw->iobar4 +0xa4000 ); + } +/* === dma status/config====== */ + hw->link_sync = (void *)((uint8_t *)hw->iobar4 +0x000c ); + hw->dma_axi_en = (void *)((uint8_t *)hw->iobar4 +0x0010 ); + hw->dma_axi_st = (void *)((uint8_t *)hw->iobar4 +0x0014 ); +
Quoted 9 lines
drivers/net/rnp/rnp.h struct rnp_eth_adapter { · line 68
Quoted 6 lines
drivers/net/rnp/rnp.h +6
-0+if (hw->mbx.pf_num) + hw->msix_base = (void *)((uint8_t *)0x200 ); +/* === queue registers === */ + hw->dma_base = (void *)((uint8_t *)hw->iobar4 +0x08000 ); + hw->veb_base = (void *)((uint8_t *)hw->iobar4 +0x0 ); + hw->eth_base = (void *)((uint8_t *)hw->iobar4 +0x10000 );There are lots of hardcoded values in this function, can you make them macros?
Yes, I can change it to macros.
Quoted 39 lines
drivers/net/rnp/rnp_ethdev.c rnp_alloc_eth_port(struct rte_pci_device *primary_pci,
Quoted 18 lines
drivers/net/rnp/rnp.h +4
-0+/* mac */ +for (i =0 ; i <RNP_MAX_HW_PORT_PERR_PF ; i++) + hw->mac_base[i] = (void *)((uint8_t *)hw->iobar4 +0x60000 + +0x10000 * i); }#endif /* __RNP_H__ */ (quoted diff) +0
-0
b/drivers/net/rnp/rnp_ethdev.cindexae737643a7..a2dc27548a100644drivers/net/rnp/rnp_ethdev.c +1
-0@@ -8,6 +8,7 @@#include <ethdev_driver.h> #include "rnp.h" +#include "rnp_mbx.h" #include "rnp_logs.h" static int@@ -89,6 +90,58 @@ rnp_alloc_eth_port(struct rte_pci_device *primary_pci,char *name)
Quoted 20 lines
drivers/net/rnp/rnp_ethdev.c +17
-0return NULL ; } +static void rnp_get_nic_attr (struct rnp_eth_adapter *adapter) { +RTE_SET_USED (adapter); +} + +static int +rnp_process_resource_init (struct rte_eth_dev *eth_dev) { +struct rnp_share_ops *share_priv; + +/* allocate process_private memory this must can't +* belone to the dpdk mem resource manager +* such as from rte_malloc or rte_dma_zone.. +*/ +/* use the process_prive point to resolve secondary process +* use point-func. This point is per process will be safe to cover. +* This will cause secondary process core-dump because of IPC +* Secondary will call primary process point func virt-address +* secondary process don't alloc user/pmd to alloc or free
Quoted 9 lines
drivers/net/rnp/rnp_ethdev.c rnp_alloc_eth_port(struct rte_pci_device *primary_pci, char *name) · line 116
Quoted 5 lines
drivers/net/rnp/rnp_ethdev.c +5
-0+* the memory of dpdk-mem resource it will cause hugepage +* mem exception +* be careful for secondary Process to use the share-mem of +* point correlation +*/ As commented above, I am not sure why you need this, it should be sufficient to have
mac_opsin primary proccess.
This is because of supporting
.promiscuous_enable
.promiscuous_disable
.allmulticast_enable
.allmulticast_disable
.fw_version_get
In the secondary process
Quoted 34 lines
Quoted 34 lines
drivers/net/rnp/rnp_ethdev.c +28
-0+ share_priv =calloc (1 ,sizeof (*share_priv)); +if (!share_priv) { +PMD_DRV_LOG (ERR ,"calloc share_priv failed" ); +return -ENOMEM ; + } +memset (share_priv,0 ,sizeof (*share_priv)); + eth_dev->process_private = share_priv; + +return 0 ; +} + +static void +rnp_common_ops_init (struct rnp_eth_adapter *adapter) { +struct rnp_share_ops *share_priv; + + share_priv = adapter->share_priv; + share_priv->mbx_api = &rnp_mbx_pf_ops; } + +static int +rnp_special_ops_init (struct rte_eth_dev *eth_dev) { +RTE_SET_USED (eth_dev); + +return 0 ; +} +static int rnp_eth_dev_init(struct rte_eth_dev *dev) { @@ -124,6 +177,20 @@ rnp_eth_dev_init(struct rte_eth_dev *dev) hw->device_id = pci_dev->id.device_id; hw->vendor_id = pci_dev->id.vendor_id; hw->device_id = pci_dev->id.device_id; + adapter->max_vfs = pci_dev->max_vfs; + ret =rnp_process_resource_init (dev); +if (ret) {
Quoted 9 lines
drivers/net/rnp/rnp_ethdev.c rnp_eth_dev_init(struct rte_eth_dev *dev) · line 186
Quoted 4 lines
drivers/net/rnp/rnp_ethdev.c +4
-0+PMD_DRV_LOG (ERR ,"share prive resource init failed" ); +return ret; + } + adapter->share_priv = dev->process_private;Isn't 'adapter' shared betwen primary and secondary ('port' is
dev_privateand 'port->adapt' is 'adapter'), so updating "adapter->share_priv" defeats the purpose ofprocess_private, no?
Yes just process private.dev->process_private; this dev is alloc by 'rte_eth_dev_pci_generic_probe' So we must record the first port dev->process_private,
when the secondary port of the same PF, alloc by rnp_alloc_eth_port we can use lase record info 'adapter->share_priv' turn to 'dev->process_private' (alloc by rnp_alloc_eth_port).
Quoted 11 lines
drivers/net/rnp/rnp_ethdev.c rnp_eth_dev_init(struct rte_eth_dev *dev) · line 190
Quoted 5 lines
drivers/net/rnp/rnp_ethdev.c +4
-0+rnp_common_ops_init (adapter); +rnp_get_nic_attr (adapter); +/* We need Use Device Id To Change The Resource Mode */ +rnp_special_ops_init (dev);You can add this when it is needed, so in same patch we can see where it is called and how it is implemented, right now it is not possible that what 'special' init does.
Yes, it is used to for multiple-port mode and one pcie-bdf select api. For now, I can remove the code for one pcie-bdf-one-port mode.
Quoted 6 lines
drivers/net/rnp/rnp_ethdev.c rnp_eth_dev_init(struct rte_eth_dev *dev) · line 192
Quoted 2 lines
drivers/net/rnp/rnp_ethdev.c +2
-0+ port->adapt = adapter; + port->hw = hw;At this stage port is NULL, probably above needs to go to other patch that sets 'port'.
Port(dev_private) is get from the first port (bdf) alloc by rte_eth_dev_pci_generic_probe
Quoted 37 lines
Quoted 24 lines
drivers/net/rnp/rnp_ethdev.c +2
-2+rnp_init_mbx_ops_pf (hw);for (p_id =0 ; p_id < adapter->num_ports; p_id++) {/* port 0 resource has been allocated When Probe */ if (!p_id) {@@ -158,11 +225,10 @@ rnp_eth_dev_init(struct rte_eth_dev *dev)continue ;if (port->eth_dev) {rnp_dev_close (port->eth_dev); -rte_eth_dev_release_port (port->eth_dev);if (port->eth_dev->process_private)free (port->eth_dev->process_private); +rte_eth_dev_release_port (port->eth_dev); } -rte_free (port); }rte_free (adapter);drivers/net/rnp/rnp_logs.h +0
-0@@ -13,6 +13,15 @@ extern int rnp_drv_logtype; #define RNP_PMD_DRV_LOG(level, fmt, args...) \ rte_log(RTE_LOG_##level, rnp_drv_logtype, \drivers/net/rnp/rnp_logs.h extern int rnp_drv_logtype; #define · line 24
Quoted 10 lines
drivers/net/rnp/rnp_logs.h +9
-0"%s() " fmt, __func__, ##args) +#define PMD_DRV_LOG_RAW(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, rnp_drv_logtype, "%s(): " fmt, \ + __func__, ## args) +#define PMD_DRV_LOG(level, fmt, args...) \ + PMD_DRV_LOG_RAW(level, fmt "\n", ## args) + +#define RNP_PMD_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_##level, rnp_drv_logtype, \ + "rnp_net: (%d) " fmt, __LINE__, ##args)With these there are three different macros used to log in '
rnp_drv_logtype' type:
Quoted 8 lines
RNP_PMD_LOGPMD_DRV_LOGRNP_PMD_DRV_LOG'
RNP_PMD_DRV_LOG' and 'PMD_DRV_LOG' looks exact same, do you need all these macros, why not stick to one?
PMD_DRV_LOG
This need to remove it.
Quoted 6 lines
If more than one required, can you please comment what is used for what, and perhaps rename macros in a way that it is clear which one to use where (as I assume one is specific to base files).
<...>
Thanks a lot, I will add comment for the macros before it.
Quoted 30 lines
Quoted 19 lines
drivers/net/rnp/rnp_logs.h +19
-0+/** +* rnp_write_mbx_pf - Places a message in the mailbox +* @hw: pointer to the HW structure +* @msg: The message buffer +* @size: Length of buffer +* @mbx_id: the VF index +* +* returns SUCCESS if it successfully copied message into the buffer +**/ static int32_t rnp_write_mbx_pf (struct rnp_hw *hw,u32 *msg, +u16 size,enum MBX_ID mbx_id) +{ +u32 DATA_REG = (mbx_id ==MBX_CM3CPU ) ? +CPU_PF_SHM_DATA :PF_VF_SHM_DATA (mbx_id); +u32 CTRL_REG = (mbx_id ==MBX_CM3CPU ) ? +PF2CPU_MBOX_CTRL :PF2VF_MBOX_CTRL (mbx_id); +int32_t ret_val =0 ; + u32 stat __rte_unused; +u16 i; +drivers/net/rnp/rnp_logs.h extern int rnp_drv_logtype; #define
Quoted 10 lines
drivers/net/rnp/rnp_logs.h +10
-0+if (size >RNP_VFMAILBOX_SIZE ) { +RNP_PMD_LOG (ERR ,"%s: size:%d should <%d\n" , __func__, + size,RNP_VFMAILBOX_SIZE ); +return -EINVAL ; + } + +/* lock the mailbox to prevent pf/vf/cpu race condition */ + ret_val =rnp_obtain_mbx_lock_pf (hw, mbx_id); +if (ret_val) { + RNP_PMD_LOG(WARNING, "PF[%d] Can't Get Mbx-Lock TryAgain\n",
Quoted 12 lines
drivers/net/rnp/rnp_logs.h
Quoted 9 lines
drivers/net/rnp/rnp_logs.h +9
-0+ hw->function); +return ret_val; + } + +/* copy the caller specified message to the mailbox memory buffer */ +for (i =0 ; i < size; i++) { +#ifdef MBX_WR_DEBUG +mbx_pwr32 (hw,DATA_REG + i *4 , msg[i]);#else +mbx_wr32 (hw,DATA_REG + i *4 , msg[i]);#endif Who sets this define, if not used please remove it.
This need to remove 😊.
PATCH v6 5/8 net/rnp add reset code for Chip Init process
In reply to Wenbo Caowe must get the shape info of nic from Firmware for reset. so the related codes is first get firmware info and then reset the chip
--- drivers/net/rnp/base/rnp_hw.h | 56 +++++++++++- drivers/net/rnp/meson.build | 3 + drivers/net/rnp/rnp.h | 27 ++++++ drivers/net/rnp/rnp_ethdev.c | 93 ++++++++++++++++++- drivers/net/rnp/rnp_mbx_fw.h | 163 +++++++++++++++++++++++++++++++++- 5 files changed, 339 insertions(+), 3 deletions(-)
drivers/net/rnp/base/rnp_hw.h +55 -1
@@ -8,6 +8,9 @@#include <ethdev_driver.h> #include "rnp_osdep.h" +#include "rnp_dma_regs.h" +#include "rnp_eth_regs.h" +#include "rnp_cfg.h" static inline unsigned int rnp_rd_reg (volatile void *addr) {
@@ -29,7 +32,18 @@ static inline void rnp_wr_reg(volatile void *reg, int val) rnp_rd_reg((uint8_t *)(_base) + (_off))#define rnp_io_wr (_base, _off, _val) \ rnp_wr_reg((uint8_t *)(_base) + (_off), (_val)) - +#define rnp_eth_rd (_hw, _off) \ + rnp_rd_reg((uint8_t *)((_hw)->eth_base) + (_off)) +#define rnp_eth_wr (_hw, _off, _val) \ + rnp_wr_reg((uint8_t *)((_hw)->eth_base) + (_off), (_val)) +#define rnp_dma_rd (_hw, _off) \ + rnp_rd_reg((uint8_t *)((_hw)->dma_base) + (_off)) +#define rnp_dma_wr (_hw, _off, _val) \ + rnp_wr_reg((uint8_t *)((_hw)->dma_base) + (_off), (_val)) +#define rnp_top_rd (_hw, _off) \ + rnp_rd_reg((uint8_t *)((_hw)->comm_reg_base) + (_off)) +#define rnp_top_wr (_hw, _off, _val) \ + rnp_wr_reg((uint8_t *)((_hw)->comm_reg_base) + (_off), (_val))struct rnp_hw ;/* Mbx Operate info */ enum MBX_ID {
@@ -98,6 +112,17 @@ struct rnp_mbx_info {rte_atomic16_t state; } __rte_cache_aligned; +struct rnp_mac_api { +int32_t (*init_hw)(struct rnp_hw *hw); +int32_t (*reset_hw)(struct rnp_hw *hw); +}; + +struct rnp_mac_info { +uint8_t assign_addr[RTE_ETHER_ADDR_LEN ]; +uint8_t set_addr[RTE_ETHER_ADDR_LEN ]; +struct rnp_mac_api ops; +} __rte_cache_aligned; +struct rnp_eth_adapter ;#define RNP_MAX_HW_PORT_PERR_PF (4)struct rnp_hw {
@@ -111,8 +136,10 @@ struct rnp_hw {void *eth_base;void *veb_base;void *mac_base[RNP_MAX_HW_PORT_PERR_PF ]; +void *comm_reg_base;void *msix_base;/* === dma == */ +void *dev_version;void *dma_axi_en;void *dma_axi_st;
@@ -120,10 +147,37 @@ struct rnp_hw {uint16_t vendor_id;uint16_t function;uint16_t pf_vf_num; +int pfvfnum;uint16_t max_vfs; + +bool ncsi_en; +uint8_t ncsi_rar_entries; + +int sgmii_phy_id; +int is_sgmii; +u16 phy_type; +uint8_t force_10g_1g_speed_ablity; +uint8_t force_speed_stat; +#define FORCE_SPEED_STAT_DISABLED (0) +#define FORCE_SPEED_STAT_1G (1) +#define FORCE_SPEED_STAT_10G (2) +uint32_t speed; +unsigned int axi_mhz; + +int fw_version;/* Primary FW Version */ +uint32_t fw_uid;/* Subclass Fw Version */ + +int nic_mode; +unsigned char lane_mask; +int lane_of_port[4 ]; +char phy_port_ids[4 ];/* port id: for lane0~3: value: 0 ~ 7 */ +uint8_t max_port_num;/* Max Port Num This PF Have */ +void *cookie_pool;char cookie_p_name[RTE_MEMZONE_NAMESIZE ]; +struct rnp_mac_info mac;struct rnp_mbx_info mbx; + rte_spinlock_t fw_lock; } __rte_cache_aligned;#endif /* __RNP_H__*/
drivers/net/rnp/meson.build +3 -0
@@ -9,5 +9,8 @@ endif sources = files( 'rnp_ethdev.c', 'rnp_mbx.c', + 'rnp_mbx_fw.c', + 'base/rnp_api.c', ) + includes += include_directories('base')
drivers/net/rnp/rnp.h +27 -0
@@ -13,6 +13,20 @@#define RNP_CFG_BAR (4)#define RNP_PF_INFO_BAR (0) +enum rnp_resource_share_m { +RNP_SHARE_CORPORATE =0 , +RNP_SHARE_INDEPENDENT , +}; +/* +* Structure to store private data for each driver instance (for each port). +*/ +enum rnp_work_mode { +RNP_SINGLE_40G =0 , +RNP_SINGLE_10G =1 , +RNP_DUAL_10G =2 , +RNP_QUAD_10G =3 , +}; +struct rnp_eth_port {struct rnp_eth_adapter *adapt;struct rnp_hw *hw;
@@ -21,9 +35,12 @@ struct rnp_eth_port {struct rnp_share_ops {const struct rnp_mbx_api *mbx_api; +const struct rnp_mac_api *mac_api; } __rte_cache_aligned;struct rnp_eth_adapter { +enum rnp_work_mode mode; +enum rnp_resource_share_m s_mode;/* Port Resource Share Policy */ struct rnp_hw hw;uint16_t max_vfs;struct rte_pci_device *pdev;
@@ -31,7 +48,9 @@ struct rnp_eth_adapter {struct rnp_eth_port *ports[RNP_MAX_PORT_OF_PF ];struct rnp_share_ops *share_priv; +int max_link_speed;uint8_t num_ports;/* Cur Pf Has physical Port Num */ +uint8_t lane_mask; } __rte_cache_aligned;#define RNP_DEV_TO_PORT (eth_dev) \
@@ -40,9 +59,14 @@ struct rnp_eth_adapter { ((struct rnp_eth_adapter *)(RNP_DEV_TO_PORT(eth_dev)->adapt))#define RNP_DEV_TO_HW (eth_dev) \ (&((struct rnp_eth_adapter *)(RNP_DEV_TO_PORT((eth_dev))->adapt))->hw) +#define RNP_HW_TO_ADAPTER (hw) \ + ((struct rnp_eth_adapter *)((hw)->back))#define RNP_DEV_PP_PRIV_TO_MBX_OPS (dev) \ (((struct rnp_share_ops *)(dev)->process_private)->mbx_api)#define RNP_DEV_TO_MBX_OPS (dev) RNP_DEV_PP_PRIV_TO_MBX_OPS(dev) +#define RNP_DEV_PP_PRIV_TO_MAC_OPS (dev) \ + (((struct rnp_share_ops *)(dev)->process_private)->mac_api) +#define RNP_DEV_TO_MAC_OPS (dev) RNP_DEV_PP_PRIV_TO_MAC_OPS(dev)static inline void rnp_reg_offset_init (struct rnp_hw *hw) {
@@ -56,6 +80,7 @@ static inline void rnp_reg_offset_init(struct rnp_hw *hw) hw->msix_base = (void *)((uint8_t *)hw->iobar4 +0xa4000 ); }/* === dma status/config====== */ + hw->dev_version = (void *)((uint8_t *)hw->iobar4 +0x0000 ); hw->link_sync = (void *)((uint8_t *)hw->iobar4 +0x000c ); hw->dma_axi_en = (void *)((uint8_t *)hw->iobar4 +0x0010 ); hw->dma_axi_st = (void *)((uint8_t *)hw->iobar4 +0x0014 );
@@ -69,5 +94,7 @@ static inline void rnp_reg_offset_init(struct rnp_hw *hw)/* mac */ for (i =0 ; i <RNP_MAX_HW_PORT_PERR_PF ; i++) hw->mac_base[i] = (void *)((uint8_t *)hw->iobar4 +0x60000 +0x10000 * i); +/* === top reg === */ + hw->comm_reg_base = (void *)((uint8_t *)hw->iobar4 + 0x30000); }#endif /* __RNP_H__ */
drivers/net/rnp/rnp_ethdev.c +92 -1
112 lines not on this page · raw message
drivers/net/rnp/rnp_mbx_fw.h +162 -1
169 lines not on this page · raw message
Signature · 1 line
2.27.0
Re: [PATCH v6 5/8] net/rnp add reset code for Chip Init process
Quoted 1 line · Wenbo Cao
we must get the shape info of nic from Firmware for
What is "shape info"?
Quoted 3 lines
reset. so the related codes is first get firmware info and then reset the chip
Is there a specific reason to have "Chip Init" start with uppercase, if not please make all lowercase, also ':' after domain, like "net/rnp:'.
RE: [PATCH v6 5/8] net/rnp add reset code for Chip Init process
Hi Ferruh,
Please see the below comment.
Regards Wenbo.
Quoted 8 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: 2023年9月5日 23:46
To: Wenbo Cao <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v6 5/8] net/rnp add reset code for Chip Init process
Quoted 5 lines
Quoted 1 line · Wenbo Cao
we must get the shape info of nic from Firmware for
What is "shape info"?
For the nic 4/8 port mode or one-pcie-one port, media type fiber or copper, 10G/1G "shape info" words may be confused.
Quoted 6 lines
Quoted 3 lines
reset. so the related codes is first get firmware info and then reset the chip
Is there a specific reason to have "Chip Init" start with uppercase, if not please make all lowercase, also ':' after domain, like "net/rnp:'.
"Chip Init" is don't have any special meaning, will change the to lowercase.
PATCH v6 6/8 net/rnp add port info resource init
In reply to Wenbo CaoAdd Api For FW Mac Info, Port Resoucre info init Code For Different Shape Of Nic
--- drivers/net/rnp/base/rnp_api.c | 48 +++++++ drivers/net/rnp/base/rnp_api.h | 10 ++ drivers/net/rnp/base/rnp_hw.h | 18 +++ drivers/net/rnp/meson.build | 1 + drivers/net/rnp/rnp.h | 88 +++++++++++++ drivers/net/rnp/rnp_ethdev.c | 224 +++++++++++++++++++++++++++++++-- drivers/net/rnp/rnp_mbx_fw.c | 112 +++++++++++++++++ drivers/net/rnp/rnp_mbx_fw.h | 115 +++++++++++++++++ drivers/net/rnp/rnp_rxtx.c | 82 ++++++++++++ drivers/net/rnp/rnp_rxtx.h | 14 +++ 10 files changed, 705 insertions(+), 7 deletions(-) create mode 100644 drivers/net/rnp/rnp_rxtx.c create mode 100644 drivers/net/rnp/rnp_rxtx.h
drivers/net/rnp/base/rnp_api.c +48 -0
@@ -21,3 +21,51 @@ rnp_reset_hw(struct rte_eth_dev *dev, struct rnp_hw *hw)return ops->reset_hw (hw);return -EOPNOTSUPP ; } + +int +rnp_get_mac_addr (struct rte_eth_dev *dev,uint8_t *macaddr) +{ +struct rnp_eth_port *port =RNP_DEV_TO_PORT (dev); +const struct rnp_mac_api *ops =RNP_DEV_TO_MAC_OPS (dev); + +if (!macaddr) +return -EINVAL ; +if (ops->get_mac_addr) +return ops->get_mac_addr (port, port->attr.nr_lane, macaddr); +return -EOPNOTSUPP ; +} + +int +rnp_set_default_mac (struct rte_eth_dev *dev,uint8_t *mac_addr) +{ +const struct rnp_mac_api *ops =RNP_DEV_TO_MAC_OPS (dev); +struct rnp_eth_port *port =RNP_DEV_TO_PORT (dev); + +if (ops->set_default_mac) +return ops->set_default_mac (port, mac_addr); +return -EOPNOTSUPP ; +} + +int +rnp_set_rafb (struct rte_eth_dev *dev,uint8_t *addr, +uint8_t vm_pool,uint8_t index) +{ +const struct rnp_mac_api *ops =RNP_DEV_TO_MAC_OPS (dev); +struct rnp_eth_port *port =RNP_DEV_TO_PORT (dev); + +if (ops->set_rafb) +return ops->set_rafb (port, addr, vm_pool, index); +return -EOPNOTSUPP ; +} + +int +rnp_clear_rafb (struct rte_eth_dev *dev, +uint8_t vm_pool,uint8_t index) +{ +const struct rnp_mac_api *ops =RNP_DEV_TO_MAC_OPS (dev); +struct rnp_eth_port *port =RNP_DEV_TO_PORT (dev); + +if (ops->clear_rafb) +return ops->clear_rafb (port, vm_pool, index); +return -EOPNOTSUPP ; +}
drivers/net/rnp/base/rnp_api.h +10 -0
@@ -4,4 +4,14 @@ int rnp_init_hw(struct rte_eth_dev *dev);int rnp_reset_hw (struct rte_eth_dev *dev,struct rnp_hw *hw); +int +rnp_get_mac_addr (struct rte_eth_dev *dev,uint8_t *macaddr); +int +rnp_set_default_mac (struct rte_eth_dev *dev,uint8_t *mac_addr); +int +rnp_set_rafb (struct rte_eth_dev *dev,uint8_t *addr, +uint8_t vm_pool,uint8_t index); +int +rnp_clear_rafb (struct rte_eth_dev *dev, +uint8_t vm_pool,uint8_t index);#endif /* __RNP_API_H__ */
drivers/net/rnp/base/rnp_hw.h +18 -0
@@ -44,6 +44,10 @@ static inline void rnp_wr_reg(volatile void *reg, int val) rnp_rd_reg((uint8_t *)((_hw)->comm_reg_base) + (_off))#define rnp_top_wr (_hw, _off, _val) \ rnp_wr_reg((uint8_t *)((_hw)->comm_reg_base) + (_off), (_val)) +#define RNP_MACADDR_UPDATE_LO (hw, hw_idx, val) \ + rnp_eth_wr(hw, RNP_RAL_BASE_ADDR(hw_idx), val) +#define RNP_MACADDR_UPDATE_HI (hw, hw_idx, val) \ + rnp_eth_wr(hw, RNP_RAH_BASE_ADDR(hw_idx), val)struct rnp_hw ;/* Mbx Operate info */ enum MBX_ID {
@@ -112,9 +116,23 @@ struct rnp_mbx_info {rte_atomic16_t state; } __rte_cache_aligned; +struct rnp_eth_port ;struct rnp_mac_api {int32_t (*init_hw)(struct rnp_hw *hw);int32_t (*reset_hw)(struct rnp_hw *hw); +/* MAC Address */ +int32_t (*get_mac_addr)(struct rnp_eth_port *port, +uint8_t lane, +uint8_t *macaddr); +int32_t (*set_default_mac)(struct rnp_eth_port *port,uint8_t *mac); +/* Receive Address Filter Table */ +int32_t (*set_rafb)(struct rnp_eth_port *port, +uint8_t *mac, +uint8_t vm_pool, +uint8_t index); +int32_t (*clear_rafb)(struct rnp_eth_port *port, +uint8_t vm_pool, +uint8_t index); };struct rnp_mac_info {
drivers/net/rnp/meson.build +1 -0
@@ -10,6 +10,7 @@ sources = files( 'rnp_ethdev.c', 'rnp_mbx.c', 'rnp_mbx_fw.c', + 'rnp_rxtx.c', 'base/rnp_api.c', )
drivers/net/rnp/rnp.h +88 -0
116 lines not on this page · raw message
drivers/net/rnp/rnp_ethdev.c +217 -7
278 lines not on this page · raw message
drivers/net/rnp/rnp_mbx_fw.c +112 -0
115 lines not on this page · raw message
drivers/net/rnp/rnp_mbx_fw.h +115 -0
159 lines not on this page · raw message
drivers/net/rnp/rnp_rxtx.c new file +82 -0
82 lines not on this page · raw message
drivers/net/rnp/rnp_rxtx.h new file +14 -0
@@ -0,0 +1,14 @@ +#ifndef __RNP_RXTX_H__ +#define __RNP_RXTX_H__ + +uint32_t rnp_dev_rx_queue_count (void *rx_queue); +int rnp_dev_rx_descriptor_status (void *rx_queue,uint16_t offset); +int rnp_dev_tx_descriptor_status (void *tx_queue,uint16_t offset); +uint16_t +rnp_recv_pkts (void *_rxq,struct rte_mbuf **rx_pkts,uint16_t nb_pkts); +uint16_t +rnp_xmit_pkts (void *_txq,struct rte_mbuf **tx_pkts,uint16_t nb_pkts); +uint16_t rnp_prep_pkts (void *tx_queue, +struct rte_mbuf **tx_pkts, +uint16_t nb_pkts); +#endif /* __RNP_RXTX_H__ */
Signature · 1 line
2.27.0
Re: [PATCH v6 6/8] net/rnp add port info resource init
Quoted 4 lines · Wenbo Cao
Add Api For FW Mac Info, Port Resoucre info init Code For Different Shape Of Nic
Signed-off-by Wenbo Cao <[email protected]>
<...>
Quoted 33 lines
drivers/net/rnp/rnp_ethdev.c +24
-2@@ -47,11 +104,53 @@ rnp_init_port_resource(struct rnp_eth_adapter *adapter, uint8_t p_id) {struct rnp_eth_port *port =RNP_DEV_TO_PORT (dev); +struct rte_pci_device *pci_dev = adapter->pdev; +struct rnp_hw *hw = &adapter->hw; + port->adapt = adapter; + port->s_mode = adapter->s_mode; + port->port_stopped =1 ; + port->hw = hw; port->eth_dev = dev; - adapter->ports[p_id] = port; + + dev->device = &pci_dev->device; +rte_eth_copy_pci_info (dev, pci_dev); dev->dev_ops = &rnp_eth_dev_ops; -RTE_SET_USED (name); + dev->rx_queue_count = rnp_dev_rx_queue_count; + dev->rx_descriptor_status = rnp_dev_rx_descriptor_status; + dev->tx_descriptor_status = rnp_dev_tx_descriptor_status; + dev->rx_pkt_burst = rnp_recv_pkts; + dev->tx_pkt_burst = rnp_xmit_pkts; + dev->tx_pkt_prepare = rnp_prep_pkts; + +rnp_setup_port_attr (port, dev, adapter->num_ports, p_id); +rnp_init_filter_setup (port, adapter->num_ports); +rnp_get_mac_addr (dev, port->mac_addr); + dev->data->mac_addrs =rte_zmalloc (name,sizeof (struct rte_ether_addr ) * + port->attr.max_mac_addrs,0 ); +if (!dev->data->mac_addrs) { +RNP_PMD_DRV_LOG (ERR ,"Memory allocation " +"for MAC failed! Exiting.\n" );
drivers/net/rnp/rnp_ethdev.c rnp_init_port_resource(struct rnp_eth_adapter *adapter, · line 143
Quoted 10 lines
drivers/net/rnp/rnp_ethdev.c +10
-0+return -ENOMEM ; + } +/* Allocate memory for storing hash filter MAC addresses */ + dev->data->hash_mac_addrs =rte_zmalloc (name, +RTE_ETHER_ADDR_LEN * port->attr.max_uc_mac_hash,0 ); +if (dev->data->hash_mac_addrs ==NULL ) { +RNP_PMD_INIT_LOG (ERR ,"Failed to allocate %d bytes " +"needed to store MAC addresses" , +RTE_ETHER_ADDR_LEN * port->attr.max_uc_mac_hash); +return -ENOMEM ;
Should free 'dev->data->mac_addrs' here, or even better can be to implement 'rnp_dev_close()' to free device resources.
drivers/net/rnp/rnp_ethdev.c rnp_init_port_resource(struct rnp_eth_adapter *adapter, · line 146
Quoted 3 lines
drivers/net/rnp/rnp_ethdev.c +3
-0+ } + +rnp_set_default_mac (dev, port->mac_addr);
I guess the 'port->mac_addr' got from device via 'rnp_get_mac_addr()' above, but if 'rnp_get_mac_addr()' fails what will be the value. Should there be check and set a random mac if required?
drivers/net/rnp/rnp_ethdev.c rnp_init_port_resource(struct rnp_eth_adapter *adapter, · line 154
Quoted 8 lines
drivers/net/rnp/rnp_ethdev.c +7
-0+rte_ether_addr_copy ((const struct rte_ether_addr *)port->mac_addr, + dev->data->mac_addrs); +/* MTU */ + dev->data->mtu =RTE_ETHER_MAX_LEN - +RTE_ETHER_HDR_LEN -RTE_ETHER_CRC_LEN ; + adapter->ports[p_id] = port; +rte_eth_dev_probing_finish (dev);
rte_eth_dev_probing_finish() is not required, as 'rte_eth_dev_pci_generic_probe()' calls it if dev_init() returns success.
<...>
drivers/net/rnp/rnp_ethdev.c static int32_t rnp_reset_hw_pf(struct rnp_hw *hw) · line 399
Quoted 9 lines
drivers/net/rnp/rnp_ethdev.c +9
-0+static int32_t rnp_get_mac_addr_pf (struct rnp_eth_port *port, +uint8_t lane, +uint8_t *macaddr) +{ +struct rnp_hw *hw =RNP_DEV_TO_HW (port->eth_dev); + +return rnp_fw_get_macaddr (port->eth_dev, hw->pf_vf_num, macaddr, lane); +} +
These are mac_ops functions, normally the reason to have mac_ops is to support different HW that behaves slightly different and this difference managed by different function pointers per device. Is this your usecase?
And since these are mac_ops, defined in the base folder header, it suits better to have separate .c file for them which is under base file, what do you think? Or am I getting these mac_ops wrong?
Quoted 28 lines
drivers/net/rnp/rnp_ethdev.c +21
-1+static int32_t +rnp_set_default_mac_pf (struct rnp_eth_port *port, +uint8_t *mac) +{ +struct rnp_eth_adapter *adap =RNP_PORT_TO_ADAPTER (port); +uint16_t max_vfs; + +if (port->s_mode ==RNP_SHARE_INDEPENDENT ) +return rnp_set_rafb (port->eth_dev, (uint8_t *)mac, +UINT8_MAX ,0 ); + + max_vfs = adap->max_vfs; + +return rnp_set_rafb (port->eth_dev, mac, max_vfs,0 ); +} +const struct rnp_mac_api rnp_mac_ops = { .reset_hw = rnp_reset_hw_pf, - .init_hw = rnp_init_hw_pf + .init_hw = rnp_init_hw_pf, + .get_mac_addr = rnp_get_mac_addr_pf, + .set_default_mac = rnp_set_default_mac_pf, + .set_rafb = rnp_set_mac_addr_pf, + .clear_rafb = rnp_clear_mac_addr_pf }; static void
drivers/net/rnp/rnp_ethdev.c rnp_common_ops_init(struct rnp_eth_adapter *adapter) · line 442
Quoted 10 lines
drivers/net/rnp/rnp_ethdev.c +5
-1@@ -228,7 +434,11 @@ rnp_common_ops_init(struct rnp_eth_adapter *adapter)static int rnp_special_ops_init (struct rte_eth_dev *eth_dev) { -RTE_SET_USED (eth_dev); +struct rnp_eth_adapter *adapter =RNP_DEV_TO_ADAPTER (eth_dev); +struct rnp_share_ops *share_priv; + + share_priv = adapter->share_priv; + share_priv->mac_api = &rnp_mac_ops;
Can you please describe why this 'rnp_special_ops_init()' is for (its difference from rnp_common_ops_init()) ?
RE: [PATCH v6 6/8] net/rnp add port info resource init
Hi Ferruh,
Quoted 68 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: 2023年9月6日 0:56
To: Wenbo Cao <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v6 6/8] net/rnp add port info resource initQuoted 4 lines · Wenbo Cao
Add Api For FW Mac Info, Port Resoucre info init Code For Different Shape Of Nic
Signed-off-by Wenbo Cao <[email protected]><...>
Review rnp_init_port_resource(struct rnp_eth_adapter
Quoted 1 line
(quoted diff) +0
-0@@ -47,11 +104,53 @@ rnp_init_port_resource(struct rnp_eth_adapter*adapter,
Quoted 18 lines
drivers/net/rnp/rnp_ethdev.c +10
-2uint8_t p_id) {struct rnp_eth_port *port =RNP_DEV_TO_PORT (dev); +struct rte_pci_device *pci_dev = adapter->pdev; +struct rnp_hw *hw = &adapter->hw; + port->adapt = adapter; + port->s_mode = adapter->s_mode; + port->port_stopped =1 ; + port->hw = hw; port->eth_dev = dev; - adapter->ports[p_id] = port; + + dev->device = &pci_dev->device; +rte_eth_copy_pci_info (dev, pci_dev); dev->dev_ops = &rnp_eth_dev_ops; -RTE_SET_USED (name); + dev->rx_queue_count = rnp_dev_rx_queue_count;drivers/net/rnp/rnp_ethdev.c rnp_init_port_resource(struct rnp_eth_adapter *adapter,
Quoted 10 lines
drivers/net/rnp/rnp_ethdev.c +10
-0+ dev->rx_descriptor_status = rnp_dev_rx_descriptor_status; + dev->tx_descriptor_status = rnp_dev_tx_descriptor_status; + dev->rx_pkt_burst = rnp_recv_pkts; + dev->tx_pkt_burst = rnp_xmit_pkts; + dev->tx_pkt_prepare = rnp_prep_pkts; + +rnp_setup_port_attr (port, dev, adapter->num_ports, p_id); +rnp_init_filter_setup (port, adapter->num_ports); +rnp_get_mac_addr (dev, port->mac_addr); + dev->data->mac_addrs = rte_zmalloc(name, sizeof(struct
rte_ether_addr) *Quoted 6 lines
drivers/net/rnp/rnp_ethdev.c +6
-0+ port->attr.max_mac_addrs, 0); +if (!dev->data->mac_addrs) { +RNP_PMD_DRV_LOG (ERR ,"Memory allocation " +"for MAC failed! Exiting.\n" ); +return -ENOMEM ; + }drivers/net/rnp/rnp_ethdev.c rnp_init_port_resource(struct rnp_eth_adapter *adapter, · line 143
Quoted 10 lines
drivers/net/rnp/rnp_ethdev.c +8
-0+/* Allocate memory for storing hash filter MAC addresses */ + dev->data->hash_mac_addrs =rte_zmalloc (name, +RTE_ETHER_ADDR_LEN * port- attr.max_uc_mac_hash,0 ); +if (dev->data->hash_mac_addrs ==NULL ) { +RNP_PMD_INIT_LOG (ERR ,"Failed to allocate %d bytes " +"needed to store MAC addresses" , +RTE_ETHER_ADDR_LEN * port- attr.max_uc_mac_hash); +return -ENOMEM ;Should free '
dev->data->mac_addrs' here, or even better can be to implement 'rnp_dev_close()' to free device resources.
Quoted 1 line
Review rnp_init_port_resource(struct rnp_eth_adapter · line 146
Quoted 1 line
(quoted diff) +1
-0+ dev->data->mac_addrs = rte_zmalloc(name, sizeof(struct
Yes, for the failed branch, need to free the last alloc success argument mac_addrs
Quoted 8 lines
drivers/net/rnp/rnp_ethdev.c rnp_init_port_resource(struct rnp_eth_adapter *adapter, · line 146
Quoted 3 lines
drivers/net/rnp/rnp_ethdev.c +3
-0+ } + +rnp_set_default_mac (dev, port->mac_addr);I guess the '
port->mac_addr' got from device via 'rnp_get_mac_addr()' above, but if 'rnp_get_mac_addr()' fails what will be the value. Should there be check and set a random mac if required?
Yes, you are right :) , it the rnp_get_mac_addr failed, this may have fireware issue thing about Communicate.This need to be check and warning.
Quoted 12 lines
drivers/net/rnp/rnp_ethdev.c rnp_init_port_resource(struct rnp_eth_adapter *adapter, · line 153
Quoted 8 lines
drivers/net/rnp/rnp_ethdev.c +7
-0+rte_ether_addr_copy ((const struct rte_ether_addr *)port->mac_addr, + dev->data->mac_addrs); +/* MTU */ + dev->data->mtu =RTE_ETHER_MAX_LEN - +RTE_ETHER_HDR_LEN -RTE_ETHER_CRC_LEN ; + adapter->ports[p_id] = port; +rte_eth_dev_probing_finish (dev);
rte_eth_dev_probing_finish()is not required, as 'rte_eth_dev_pci_generic_probe()' calls it ifdev_init()returns success.
Quoted 2 lines
<...>
For N10 chip is just have two pcie-bdf, the one pcie-bdf may have multiple port(max 4) 'rte_eth_dev_pci_generic_probe' probe the pcie-pdf port(master port port 0) the other port alloc by 'rnp_alloc_eth_port', not set 'rte_eth_dev_probing_finish()' so the 1,2,3 port will set 'rte_eth_dev_probing_finish()'.
Quoted 5 lines
Quoted 5 lines
drivers/net/rnp/rnp_ethdev.c +5
-0+static int32_t rnp_get_mac_addr_pf (struct rnp_eth_port *port, +uint8_t lane, +uint8_t *macaddr) +{ +struct rnp_hw *hw =RNP_DEV_TO_HW (port->eth_dev);
Quoted 9 lines
drivers/net/rnp/base/rnp_api.c rnp_reset_hw(struct rte_eth_dev *dev, struct rnp_hw *hw) · line 30
Quoted 4 lines
drivers/net/rnp/base/rnp_api.c +4
-0+ +return rnp_fw_get_macaddr (port->eth_dev, hw->pf_vf_num, macaddr, +lane); } +These are
mac_opsfunctions, normally the reason to havemac_opsis to support different HW that behaves slightly different and this difference managed by different function pointers per device. Is this your usecase?
This is because for one pcie-bdf one port and one pcie-bdf multiple port usecase For hareware design limit, we max can support eight port but just have two pcie-bdf. We must use two set of api to resolve one pcie-bdf one port and
one pcie-bdf multiple port for the port Control independence feature.
Such as vlan-filter, mac unicast/Multicast filter, promise, Multicast promise, Broadcast promise. So that some API is common used for one-port-pcie-bdf and multiple-port-one-pcie-bdf :(. And some mac-api must change when known the nic is multiple-port mode.
Quoted 4 lines
And since these are
mac_ops, defined in the base folder header, it suits better to have separate .c file for them which is under base file, what do you think? Or am I getting thesemac_opswrong?
You are right, 😊 mac_ops api need to depart from rnp.c to a separate.c .
Quoted 25 lines
Quoted 25 lines
drivers/net/rnp/rnp_ethdev.c +20
-1+static int32_t +rnp_set_default_mac_pf (struct rnp_eth_port *port, +uint8_t *mac) +{ +struct rnp_eth_adapter *adap =RNP_PORT_TO_ADAPTER (port); +uint16_t max_vfs; + +if (port->s_mode ==RNP_SHARE_INDEPENDENT ) +return rnp_set_rafb (port->eth_dev, (uint8_t *)mac, +UINT8_MAX ,0 ); + + max_vfs = adap->max_vfs; + +return rnp_set_rafb (port->eth_dev, mac, max_vfs,0 ); } +const struct rnp_mac_api rnp_mac_ops = { .reset_hw = rnp_reset_hw_pf, - .init_hw = rnp_init_hw_pf + .init_hw = rnp_init_hw_pf, + .get_mac_addr = rnp_get_mac_addr_pf, + .set_default_mac = rnp_set_default_mac_pf, + .set_rafb = rnp_set_mac_addr_pf, + .clear_rafb = rnp_clear_mac_addr_pf };
Quoted 16 lines
drivers/net/rnp/rnp_ethdev.c rnp_common_ops_init(struct rnp_eth_adapter · line 441
Quoted 11 lines
static void
drivers/net/rnp/rnp_ethdev.c +5
-1@@ -228,7 +434,11 @@ rnp_common_ops_init(struct rnp_eth_adapter *adapter) static int rnp_special_ops_init(struct rte_eth_dev *eth_dev) { -RTE_SET_USED (eth_dev); +struct rnp_eth_adapter *adapter =RNP_DEV_TO_ADAPTER (eth_dev); +struct rnp_share_ops *share_priv; + + share_priv = adapter->share_priv; + share_priv->mac_api = &rnp_mac_ops;Can you please describe why this '
rnp_special_ops_init()' is for (its difference fromrnp_common_ops_init()) ?
In 'rnp_common_ops_init' both one pcie-bdf one port and one pcie-bdf multiple port, will use mailbox to communicase with fireware.
'rnp_special_ops_init() is design to change the mac api when the nic is multiple-port mode.
For now, the code is just for one-pcie-one-port mode.
PATCH v6 7/8 net/rnp add devargs runtime parsing functions
In reply to Wenbo Caoadd various runtime devargs command line options
supported by this driver.
--- drivers/net/rnp/rnp.h | 22 +++++ drivers/net/rnp/rnp_ethdev.c | 166 +++++++++++++++++++++++++++++++++++ drivers/net/rnp/rnp_mbx_fw.c | 164 ++++++++++++++++++++++++++++++++++ drivers/net/rnp/rnp_mbx_fw.h | 69 +++++++++++++++ 4 files changed, 421 insertions(+)
drivers/net/rnp/rnp.h +22 -0
@@ -107,6 +107,8 @@ struct rnp_eth_port {struct rnp_eth_adapter *adapt;uint8_t mac_addr[RTE_ETHER_ADDR_LEN ];struct rnp_hw *hw; +uint8_t rx_func_sec;/* force set io rx_func */ +uint8_t tx_func_sec;/* force set io tx func */ struct rte_eth_dev *eth_dev;struct rnp_port_attr attr;/* Recvice Mac Address Record Table */
@@ -122,6 +124,13 @@ struct rnp_share_ops {const struct rnp_mac_api *mac_api; } __rte_cache_aligned; +enum { +RNP_IO_FUNC_USE_NONE =0 , +RNP_IO_FUNC_USE_VEC , +RNP_IO_FUNC_USE_SIMPLE , +RNP_IO_FUNC_USE_COMMON , +}; +struct rnp_eth_adapter {enum rnp_work_mode mode;enum rnp_resource_share_m s_mode;/* Port Resource Share Policy */
@@ -135,6 +144,19 @@ struct rnp_eth_adapter {int max_link_speed;uint8_t num_ports;/* Cur Pf Has physical Port Num */ uint8_t lane_mask; + +uint8_t rx_func_sec;/* force set io rx_func */ +uint8_t tx_func_sec;/* force set io tx func*/ +/*fw-update*/ +bool do_fw_update; +char *fw_path; + +bool loopback_en; +bool fw_sfp_10g_1g_auto_det; +int fw_force_speed_1g; +#define FOCE_SPEED_1G_NOT_SET (-1) +#define FOCE_SPEED_1G_DISABLED (0) +#define FOCE_SPEED_1G_ENABLED (1) } __rte_cache_aligned;#define RNP_DEV_TO_PORT (eth_dev) \
drivers/net/rnp/rnp_ethdev.c +166 -0
202 lines not on this page · raw message
drivers/net/rnp/rnp_mbx_fw.c +164 -0
173 lines not on this page · raw message
drivers/net/rnp/rnp_mbx_fw.h +69 -0
97 lines not on this page · raw message
Signature · 1 line
2.27.0
Re: [PATCH v6 7/8] net/rnp add devargs runtime parsing functions
Quoted 4 lines · Wenbo Cao
add various runtime devargs command line options
supported by this driver.Signed-off-by Wenbo Cao <[email protected]>
<...>
drivers/net/rnp/rnp_ethdev.c line 24
Quoted 8 lines
drivers/net/rnp/rnp_ethdev.c +7
-0+#define RNP_HW_MAC_LOOPBACK_ARG "hw_loopback" +#define RNP_FW_UPDATE "fw_update" +#define RNP_RX_FUNC_SELECT "rx_func_sec" +#define RNP_TX_FUNC_SELECT "tx_func_sec" +#define RNP_FW_4X10G_10G_1G_DET "fw_4x10g_10g_1g_auto_det" +#define RNP_FW_FORCE_SPEED_1G "fw_force_1g_speed" +
Please document these runtime arguments in the device document.
Also please add 'RTE_PMD_REGISTER_PARAM_STRING()' macros to document argument for pmdinfogen, please see samples in existing code.
<...>
Quoted 5 lines
drivers/net/rnp/rnp_ethdev.c +5
-0+ +static int +rnp_parse_io_select_func (const char *key,const char *value,void *extra_args) +{ +uint8_t select =RNP_IO_FUNC_USE_NONE ;
drivers/net/rnp/rnp_ethdev.c rnp_special_ops_init(struct rte_eth_dev *eth_dev) · line 522
Quoted 10 lines
drivers/net/rnp/rnp_ethdev.c +10
-0+ +RTE_SET_USED (key); + +if (strcmp (value,"vec" ) ==0 ) + select =RNP_IO_FUNC_USE_VEC ; +else if (strcmp (value,"simple" ) ==0 ) + select =RNP_IO_FUNC_USE_SIMPLE ; +else if (strcmp (value,"common" ) ==0 ) + select =RNP_IO_FUNC_USE_COMMON ; +
There is already an generic eal argument that lets you select between vector and scalar datapath implementation:
--force-max-simd-bitwidth=<val>
<...>
drivers/net/rnp/rnp_ethdev.c rnp_special_ops_init(struct rte_eth_dev *eth_dev) · line 591
Quoted 9 lines
drivers/net/rnp/rnp_ethdev.c +9
-0+static int rnp_post_handle (struct rnp_eth_adapter *adapter) +{ +bool on = false; + +if (!adapter->eth_dev) +return -ENOMEM ; +if (adapter->do_fw_update && adapter->fw_path) { +rnp_fw_update (adapter); + adapter->do_fw_update =0 ;
This patch also enables FW upgrade, can you please detail this in the commit log? Or even you can consider to split this part into separate patch.
RE: [PATCH v6 7/8] net/rnp add devargs runtime parsing functions
Quoted 29 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: 2023年9月5日 23:47
To: Wenbo Cao <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v6 7/8] net/rnp add devargs runtime parsing functionsQuoted 4 lines · Wenbo Cao
add various runtime devargs command line options supported by this driver.
Signed-off-by Wenbo Cao <[email protected]><...>
drivers/net/rnp/rnp_ethdev.c line 24
Quoted 8 lines
drivers/net/rnp/rnp_ethdev.c +7
-0+#define RNP_HW_MAC_LOOPBACK_ARG "hw_loopback" +#define RNP_FW_UPDATE "fw_update" +#define RNP_RX_FUNC_SELECT "rx_func_sec" +#define RNP_TX_FUNC_SELECT "tx_func_sec" +#define RNP_FW_4X10G_10G_1G_DET "fw_4x10g_10g_1g_auto_det" +#define RNP_FW_FORCE_SPEED_1G "fw_force_1g_speed" +Please document these runtime arguments in the device document.
Quoted 5 lines
Also please add '
RTE_PMD_REGISTER_PARAM_STRING()' macros to document argument for pmdinfogen, please see samples in existing code.<...>
OK, I will check the samples.
Quoted 20 lines
Quoted 5 lines
drivers/net/rnp/rnp_ethdev.c +5
-0+ +static int +rnp_parse_io_select_func (const char *key,const char *value,void +*extra_args) { +uint8_t select =RNP_IO_FUNC_USE_NONE ;drivers/net/rnp/rnp_ethdev.c rnp_special_ops_init(struct rte_eth_dev *eth_dev) · line 522
Quoted 10 lines
drivers/net/rnp/rnp_ethdev.c +10
-0+ +RTE_SET_USED (key); + +if (strcmp (value,"vec" ) ==0 ) + select =RNP_IO_FUNC_USE_VEC ; +else if (strcmp (value,"simple" ) ==0 ) + select =RNP_IO_FUNC_USE_SIMPLE ; +else if (strcmp (value,"common" ) ==0 ) + select =RNP_IO_FUNC_USE_COMMON ; +There is already an generic eal argument that lets you select between vector and scalar datapath implementation:
--force-max-simd-bitwidth=<val>
Quoted 3 lines
<...>
--force-max-simd-bitwidth=<val>
This option I have noticed before. Thanks a lot.
I will check the generic eal argume code, and reedit the interrelated code
Quoted 14 lines
drivers/net/rnp/rnp_ethdev.c rnp_special_ops_init(struct rte_eth_dev *eth_dev) · line 591
Quoted 8 lines
drivers/net/rnp/rnp_ethdev.c +8
-0+static int rnp_post_handle (struct rnp_eth_adapter *adapter) { +bool on = false; + +if (!adapter->eth_dev) +return -ENOMEM ; +if (adapter->do_fw_update && adapter->fw_path) { +rnp_fw_update (adapter); + adapter->do_fw_update =0 ;This patch also enables FW upgrade, can you please detail this in the commit log? Or even you can consider to split this part into separate patch.
For this, I will split it to another commit.
PATCH v6 8/8 net/rnp handle device interrupts
In reply to Wenbo CaoHandle device lsc interrupt event
--- drivers/net/rnp/base/rnp_hw.h | 5 + drivers/net/rnp/base/rnp_mac_regs.h | 279 ++++++++++++++++++++++++++++ drivers/net/rnp/rnp.h | 8 + drivers/net/rnp/rnp_ethdev.c | 17 ++ drivers/net/rnp/rnp_mbx.h | 3 +- drivers/net/rnp/rnp_mbx_fw.c | 233 +++++++++++++++++++++++ drivers/net/rnp/rnp_mbx_fw.h | 38 +++- 7 files changed, 580 insertions(+), 3 deletions(-) create mode 100644 drivers/net/rnp/base/rnp_mac_regs.h
drivers/net/rnp/base/rnp_hw.h +5 -0
@@ -10,6 +10,7 @@#include "rnp_osdep.h" #include "rnp_dma_regs.h" #include "rnp_eth_regs.h" +#include "rnp_mac_regs.h" #include "rnp_cfg.h" static inline unsigned int rnp_rd_reg (volatile void *addr)
@@ -48,6 +49,10 @@ static inline void rnp_wr_reg(volatile void *reg, int val) rnp_eth_wr(hw, RNP_RAL_BASE_ADDR(hw_idx), val)#define RNP_MACADDR_UPDATE_HI (hw, hw_idx, val) \ rnp_eth_wr(hw, RNP_RAH_BASE_ADDR(hw_idx), val) +#define rnp_mac_rd (hw, id, off) \ + rnp_rd_reg((char *)(hw)->mac_base[id] + (off)) +#define rnp_mac_wr (hw, id, off, val) \ + rnp_wr_reg((char *)(hw)->mac_base[id] + (off), val)struct rnp_hw ;/* Mbx Operate info */ enum MBX_ID {
drivers/net/rnp/base/rnp_mac_regs.h new file +279 -0
279 lines not on this page · raw message
drivers/net/rnp/rnp.h +8 -0
@@ -111,6 +111,8 @@ struct rnp_eth_port {uint8_t tx_func_sec;/* force set io tx func */ struct rte_eth_dev *eth_dev;struct rnp_port_attr attr; +uint64_t state; +rte_spinlock_t rx_mac_lock;/* Lock For Mac_cfg resource write */ /* Recvice Mac Address Record Table */ uint8_t mac_use_tb[RNP_MAX_MAC_ADDRS ];uint8_t use_num_mac;
@@ -131,6 +133,12 @@ enum { RNP_IO_FUNC_USE_COMMON, }; +enum rnp_port_state { +RNP_PORT_STATE_PAUSE =0 , +RNP_PORT_STATE_FINISH , +RNP_PORT_STATE_SETTING , +}; +struct rnp_eth_adapter {enum rnp_work_mode mode;enum rnp_resource_share_m s_mode;/* Port Resource Share Policy */
drivers/net/rnp/rnp_ethdev.c +17 -0
@@ -601,10 +601,23 @@ static int rnp_post_handle(struct rnp_eth_adapter *adapter)return 0 ; } +static void rnp_dev_interrupt_handler (void *param) +{ +struct rte_eth_dev *dev = (struct rte_eth_dev *)param; +struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_intr_handle *intr_handle = pci_dev->intr_handle; +struct rnp_eth_adapter *adapter =RNP_DEV_TO_ADAPTER (dev); + +rte_intr_disable (intr_handle); +rnp_fw_msg_handler (adapter); +rte_intr_enable (intr_handle); +} +static int rnp_eth_dev_init (struct rte_eth_dev *dev) {struct rte_pci_device *pci_dev =RTE_ETH_DEV_TO_PCI (dev); +struct rte_intr_handle *intr_handle = pci_dev->intr_handle;struct rnp_eth_port *port =RNP_DEV_TO_PORT (dev);struct rnp_eth_adapter *adapter =NULL ;char name[RTE_ETH_NAME_MAX_LEN ] =" " ;
@@ -680,6 +693,10 @@ rnp_eth_dev_init(struct rte_eth_dev *dev)rnp_mac_rx_disable (eth_dev);rnp_mac_tx_disable (eth_dev); } +rte_intr_disable (intr_handle); +/* Enable Link Update Event Interrupt */ +rte_intr_callback_register (intr_handle, + rnp_dev_interrupt_handler, dev); ret =rnp_post_handle (adapter);if (ret) goto eth_alloc_error;
drivers/net/rnp/rnp_mbx.h +2 -1
@@ -13,7 +13,8 @@/* Mbx Ctrl state */ #define RNP_VFMAILBOX_SIZE (14)/* 16 32 bit words - 64 bytes */ -#define TSRN10_VFMBX_SIZE (RNP_VFMAILBOX_SIZE) +#define RNP_FW_MAILBOX_SIZE RNP_VFMAILBOX_SIZE +#define RNP_VFMBX_SIZE (RNP_VFMAILBOX_SIZE)#define RNP_VT_MSGTYPE_ACK (0x80000000)#define RNP_VT_MSGTYPE_NACK (0x40000000)
drivers/net/rnp/rnp_mbx_fw.c +233 -0
236 lines not on this page · raw message
drivers/net/rnp/rnp_mbx_fw.h +36 -2
@@ -32,6 +32,8 @@ enum GENERIC_CMD {GET_PHY_ABALITY =0x0601 ,GET_MAC_ADDRESS =0x0602 ,RESET_PHY =0x0603 , +GET_LINK_STATUS =0x0607 , +LINK_STATUS_EVENT =0x0608 ,GET_LANE_STATUS =0x0610 , SET_EVENT_MASK = 0x0613,/* fw update */
@@ -98,6 +100,21 @@ struct phy_abilities { }; } __rte_packed __rte_aligned(4); +struct port_stat { +u8 phy_addr;/* Phy MDIO address */ + +u8 duplex :1 ;/* FIBRE is always 1,Twisted Pair 1 or 0 */ +u8 autoneg :1 ;/* autoned state */ +u8 fec :1 ; +u8 an_rev :1 ; +u8 link_traing :1 ; +u8 is_sgmii :1 ;/* avild fw >= 0.5.0.17 */ +u16 speed;/* cur port linked speed */ + +u16 pause :4 ; +u16 rev :12 ; +} __rte_packed; +#define RNP_SPEED_CAP_UNKNOWN (0)#define RNP_SPEED_CAP_10M_FULL BIT(2)#define RNP_SPEED_CAP_100M_FULL BIT(3)
@@ -186,8 +203,14 @@ struct mbx_fw_cmd_reply {struct phy_abilities phy_abilities; }; } __rte_packed __rte_aligned(4); - -#define MBX_REQ_HDR_LEN 24 +/* == flags == */ +#define FLAGS_DD BIT(0)/* driver clear 0, FW must set 1 */ +#define FLAGS_CMP BIT(1)/* driver clear 0, FW mucst set */ +/* driver clear 0, FW must set only if it reporting an error */ +#define FLAGS_ERR BIT(2) + +#define MBX_REQ_HDR_LEN (24) +#define RNP_ALARM_INTERVAL (50000)/* unit us */ /* driver -> firmware */ struct mbx_fw_cmd_req {unsigned short flags;/* 0-1 */
@@ -240,6 +263,14 @@ struct mbx_fw_cmd_req {int flag;int nr_lane; } set_dump; + +struct { +unsigned short changed_lanes; +unsigned short lane_status; +unsigned int port_st_magic; +#define SPEED_VALID_MAGIC 0xa4a6a8a9 +struct port_stat st[4 ]; + } link_stat;/* FW->RC */ }; } __rte_packed __rte_aligned(4);
@@ -364,4 +395,7 @@ int rnp_mbx_get_lane_stat(struct rte_eth_dev *dev);int rnp_fw_update (struct rnp_eth_adapter *adapter);int rnp_hw_set_fw_10g_1g_auto_detch (struct rte_eth_dev *dev,int enable);int rnp_hw_set_fw_force_speed_1g (struct rte_eth_dev *dev,int enable); +void rnp_link_stat_mark (struct rnp_hw *hw,int nr_lane,int up); +void rnp_link_report (struct rte_eth_dev *dev,bool link_en); +int rnp_fw_msg_handler (struct rnp_eth_adapter *adapter);#endif /* __RNP_MBX_FW_H__*/
Signature · 1 line
2.27.0
Quoted 3 lines · Wenbo Cao
For This patchset just to support the basic chip init work and user can just found the
eth_dev, but can't control more.
Hi Wenbo,
After this patch, driver doesn't implement any of the dev_ops (struct eth_dev_ops), so I assume it is not functional at all.
But meanwhile patchset has devargs parsing, fw_update, LSC interrupts, implemented etc.
I think it makes testing/reviewing harder to add more code before basic device functionality is missing.
What about implementing following main dev_ops and implement a simple datapath, to have minimum working driver, later add features on top of it:dev_configuredev_startdev_stopdev_closedev_infos_getrx_queue_setuptx_queue_setup
Also I have comment on putting 'mac_ops' on process_private, I suspect there is a design problem there, please check details in relevant patch.
Thanks,
Ferruh
Quoted 45 lines
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 supprt tx-cksum-offload,tso,vxlan-tso flow director base on ntuple pattern of tcp/udp/ip/eth_hdr->typefor sriov is also support.Because of the chip desgin 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.
v6:
* fixed the doc(rst) format problem advise by Thomas Monjalonv5:
* fixed the symbol name require by the style documentationrx_queue_setup
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
* addKMOD_DEPsupport for vfio-pci
* change run-cmd argument parse check for invalidextra_argsv2:
* 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 HemmingerWenbo Cao (8):
net/rnp: add skeleton
net/rnp: add ethdev probe and remove
net/rnp: add device init and uninit
net/rnp: add mbx basic api feature
net/rnp add reset code for Chip Init process
net/rnp add port info resource init
net/rnp add devargs runtime parsing functions
net/rnp handle device interrupts
Hello,
Is there any plan to resume this work?
01/09/2023 04:30, Wenbo Cao:
Quoted 13 lines
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 supprt tx-cksum-offload,tso,vxlan-tso flow director base on ntuple pattern of tcp/udp/ip/eth_hdr->typefor sriov is also support.Because of the chip desgin 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.
Hi Thomas,
I will continue to work on it on this quarter,
a more detail servial patchs will be summit after the Spring Festival.
Regards Wenbo
Quoted 31 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: 2025年1月17日 0:50
To: [email protected]; Wenbo Cao <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v6 0/8] [v6]drivers/net Add Support mucse N10 Pmd DriverHello,
Is there any plan to resume this work?
01/09/2023 04:30, Wenbo Cao:
Quoted 13 lines
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 supprt tx-cksum-offload,tso,vxlan-tso flow director base on ntuple pattern of tcp/udp/ip/eth_hdr->typefor sriov is also support.Because of the chip desgin 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.