*** Add Support New Pmd Driver ***
Subsystems (2)
v2 cover *** Add Support New 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.
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 | 193 +++++++ drivers/net/rnp/base/rnp_mac_regs.h | 279 ++++++++++ drivers/net/rnp/meson.build | 18 + drivers/net/rnp/rnp.h | 217 ++++++++ drivers/net/rnp/rnp_ethdev.c | 820 ++++++++++++++++++++++++++++ drivers/net/rnp/rnp_logs.h | 43 ++ drivers/net/rnp/rnp_mbx.c | 522 ++++++++++++++++++ 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, 3892 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 v2 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 | 43 ++++++++++++++++++++++++++++++++ drivers/net/meson.build | 1 + drivers/net/rnp/meson.build | 12 +++++++++ drivers/net/rnp/rnp_ethdev.c | 3 +++ 7 files changed, 74 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 +43 -0
43 lines not on this page · raw message
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 +12 -0
@@ -0,0 +1,12 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(C) 2023 Mucse IC Design Ltd. +# +if is_windows + build = false + reason = 'not supported on Windows' + subdir_done() +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
PATCH v2 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 v2 2/8] net/rnp: add ethdev probe and remove
drivers/net/rnp/rnp_ethdev.c line 86
Quoted 3 lines · On Wed, 2 Aug 2023 08:11:00 +0000 Wenbo Cao <[email protected]> wrote:
drivers/net/rnp/rnp_ethdev.c +3
-0+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_txgbe,"igb_uio | uio_pci_generic" );
Will this driver work with VFIO? Vfio is preferred over igb_uio.
RE: [PATCH v2 2/8] net/rnp: add ethdev probe and remove
Hello Stephen,
Thanks for your comment.
For vfio-pci mode we can support it, but when multiple rerun dpdk-app, In rte_eal_init the logical of vfio will reset pcie.
The firmware will be core-dump for read pcie Configuration Space, when the pcie is in reset state.
This bug is resolving and testing, so that this code just support igb_uio. Until the test has been finished, I will add vfio-pci ability. Do I need add this ability of vfio in this patch ?
Regards Wenbo
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: 2023年8月3日 0:07
To: Wenbo Cao <[email protected]>
Cc: Anatoly Burakov <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2 2/8] net/rnp: add ethdev probe and remove
drivers/net/rnp/rnp_ethdev.c line 86
Quoted 3 lines · On Wed, 2 Aug 2023 08:11:00 +0000 Wenbo Cao <[email protected]> wrote:
drivers/net/rnp/rnp_ethdev.c +3
-0+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_txgbe,"igb_uio | uio_pci_generic" );
Will this driver work with VFIO? Vfio is preferred over igb_uio.
PATCH v2 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 | 18 ++++ 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, 299 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 +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(C) 2023 Mucse IC Design Ltd. +*/ +#ifndef __RNP_HW_H__ +#define __RNP_HW_H__ + +struct rnp_hw { +void *back; +char *iobar0; +uint32_t iobar0_len; +char *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
@@ -10,3 +10,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 { +void *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;/* master 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 v2 3/8] net/rnp: add device init and uninit
drivers/net/rnp/base/rnp_hw.h line 12
Quoted 6 lines · On Wed, 2 Aug 2023 08:11:01 +0000 Wenbo Cao <[email protected]> wrote:
drivers/net/rnp/base/rnp_hw.h new file +6
-0+struct rnp_hw { +void *back; +char *iobar0; +uint32_t iobar0_len; +char *iobar4; +uint32_t iobar4_len;
If possible, don't use untyped pointer for link list (back). The iobar's should probably be void * or better yet map to data structure.
Casts are often a source of bugs in C code.
RE: [PATCH v2 3/8] net/rnp: add device init and uninit
Thanks a lot, this problem that I have never been thought about it.
Regards Wenbo.
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: 2023年8月3日 0:08
To: Wenbo Cao <[email protected]>
Cc: Anatoly Burakov <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2 3/8] net/rnp: add device init and uninit
drivers/net/rnp/base/rnp_hw.h line 12
Quoted 6 lines · On Wed, 2 Aug 2023 08:11:01 +0000 Wenbo Cao <[email protected]> wrote:
drivers/net/rnp/base/rnp_hw.h new file +6
-0+struct rnp_hw { +void *back; +char *iobar0; +uint32_t iobar0_len; +char *iobar4; +uint32_t iobar4_len;
If possible, don't use untyped pointer for link list (back). The iobar's should probably be void * or better yet map to data structure.
Casts are often a source of bugs in C code.
PATCH v2 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_hw.h | 107 ++++++- 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.h | 22 ++ 8 files changed, 902 insertions(+), 3 deletions(-) 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.h
drivers/net/rnp/base/rnp_hw.h +106 -1
@@ -4,15 +4,120 @@#ifndef __RNP_HW_H__#define __RNP_HW_H__ +#include <rte_io.h> +#include <ethdev_driver.h> + +#include "rnp_osdep.h" + +static inline unsigned int rnp_rd_reg (volatile void *addr) +{ +unsigned int v =rte_read32 (addr); + +return v; +} + +static inline void rnp_wr_reg (volatile void *reg,int val) +{ +rte_write32_relaxed ((val), (reg)); +} + +#define mbx_rd32 (hw, reg) rnp_rd_reg((hw)->iobar4 + (reg)) +#define mbx_wr32 (hw, reg, val) rnp_wr_reg((hw)->iobar4 + (reg), (val)) + +struct rnp_hw ; +/* Mbx Operate info */ +enum MBX_ID { +MBX_PF =0 , +MBX_VF , +MBX_CM3CPU , +MBX_FW =MBX_CM3CPU , +MBX_VFCNT +}; +struct rnp_mbx_api { +void (*init_mbx)(struct rnp_hw *hw); +int32_t (*read)(struct rnp_hw *hw, +uint32_t *msg, +uint16_t size, +enum MBX_ID ); +int32_t (*write)(struct rnp_hw *hw, +uint32_t *msg, +uint16_t size, +enum MBX_ID ); +int32_t (*read_posted)(struct rte_eth_dev *dev, +uint32_t *msg, +uint16_t size, +enum MBX_ID ); +int32_t (*write_posted)(struct rte_eth_dev *dev, +uint32_t *msg, +uint16_t size, +enum MBX_ID ); +int32_t (*check_for_msg)(struct rnp_hw *hw,enum MBX_ID ); +int32_t (*check_for_ack)(struct rnp_hw *hw,enum MBX_ID ); +int32_t (*check_for_rst)(struct rnp_hw *hw,enum MBX_ID ); +int32_t (*configure)(struct rnp_hw *hw,int nr_vec,bool enable); +}; + +struct rnp_mbx_stats { +u32 msgs_tx; +u32 msgs_rx; + +u32 acks; +u32 reqs; +u32 rsts; +}; + +struct rnp_mbx_info { +struct rnp_mbx_api ops; +uint32_t usec_delay;/* retry interval delay time */ +uint32_t timeout;/* retry ops timeout limit */ +uint16_t size;/* data buffer size*/ +uint16_t vf_num;/* Virtual Function num */ +uint16_t pf_num;/* Physical Function num */ +uint16_t sriov_st;/* Sriov state */ +bool irq_enabled; +union { +struct { +unsigned short pf_req; +unsigned short pf_ack; + }; +struct { +unsigned short cpu_req; +unsigned short cpu_ack; + }; + }; +unsigned short vf_req[64 ]; +unsigned short vf_ack[64 ]; + +struct rnp_mbx_stats stats; + +rte_atomic16_t state; +} __rte_cache_aligned; + +#define RNP_MAX_HW_PORT_PERR_PF (4)struct rnp_hw {void *back;char *iobar0;uint32_t iobar0_len;char *iobar4;uint32_t iobar4_len; +char *link_sync; +char *dma_base; +char *eth_base; +char *veb_base; +char *mac_base[RNP_MAX_HW_PORT_PERR_PF ]; +char *msix_base; +/* === dma == */ +char *dma_axi_en; +char *dma_axi_st;uint16_t device_id;uint16_t vendor_id; -} __rte_cache_aligned; +uint16_t function; +uint16_t pf_vf_num; +uint16_t max_vfs; +void *cookie_pool; +char cookie_p_name[RTE_MEMZONE_NAMESIZE ]; +struct rnp_mbx_info mbx; +} __rte_cache_aligned;#endif /* __RNP_H__*/
drivers/net/rnp/meson.build +1 -0
@@ -9,5 +9,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 {void *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;/* master 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 +=0x100000 ; + hw->msix_base = hw->iobar4 +0xa0000 ; + hw->msix_base +=0x200 ; + }else { + hw->msix_base = hw->iobar4 +0xa0000 ; + } +/* === dma status/config====== */ + hw->link_sync = hw->iobar4 +0x000c ; + hw->dma_axi_en = hw->iobar4 +0x0010 ; + hw->dma_axi_st = hw->iobar4 +0x0014 ; + +if (hw->mbx.pf_num) + hw->msix_base +=0x200 ; +/* === queue registers === */ + hw->dma_base = hw->iobar4 +0x08000 ; + hw->veb_base = hw->iobar4 +0x0 ; + hw->eth_base = hw->iobar4 +0x10000 ; +/* mac */ +for (i =0 ; i <RNP_MAX_HW_PORT_PERR_PF ; i++) + hw->mac_base[i] = 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.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 v2 4/8] net/rnp: add mbx basic api feature
drivers/net/rnp/base/rnp_hw.h line 67
Quoted 8 lines · On Wed, 2 Aug 2023 08:11:02 +0000 Wenbo Cao <[email protected]> wrote:
drivers/net/rnp/base/rnp_hw.h +8
-0+struct rnp_mbx_stats { +u32 msgs_tx; +u32 msgs_rx; + +u32 acks; +u32 reqs; +u32 rsts; +};
Easy to cause wraparound of 32 bits in these stats. Why use u32 and not uint32_t or uint64_t.
Quoted 16 lines
drivers/net/rnp/base/rnp_hw.h +16
-0+struct rnp_mbx_info { + struct rnp_mbx_api ops; + uint32_t usec_delay; /* retry interval delay time */ + uint32_t timeout; /* retry ops timeout limit */ + uint16_t size; /* data buffer size*/ + uint16_t vf_num; /* Virtual Function num */ + uint16_t pf_num; /* Physical Function num */ + uint16_t sriov_st; /* Sriov state */ + bool irq_enabled; + union { + struct { + unsigned short pf_req; + unsigned short pf_ack; + }; + struct { + unsigned short cpu_req;
drivers/net/rnp/base/rnp_hw.h line 94
Quoted 10 lines
drivers/net/rnp/base/rnp_hw.h +10
-0+unsigned short cpu_ack; + }; + }; +unsigned short vf_req[64 ]; +unsigned short vf_ack[64 ]; + +struct rnp_mbx_stats stats; + +rte_atomic16_t state; +} __rte_cache_aligned;
You may want to reorder this data structure to reduce cache misses. The last element is almost certainly on another cache line.
Also, if you want faster statistics should consider per core, per queue or per VF.
RE: [PATCH v2 4/8] net/rnp: add mbx basic api feature
Hello, Stephen
Fort this struct is used for communicate with firmware or
Pf communicate with vf.
It is used for sync the communicative event.
It isn't used for performance sampling.
For u32(uint32_t) is because of the hardware register is 32bit read/write. So this counter size is enouth.
Review
Quoted 3 lines
(quoted diff) +2
-0+struct rnp_mbx_stats { +}
Regards Wenbo
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: 2023年8月3日 0:12
To: Wenbo Cao <[email protected]>
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2 4/8] net/rnp: add mbx basic api feature
drivers/net/rnp/base/rnp_hw.h line 67
Quoted 8 lines · On Wed, 2 Aug 2023 08:11:02 +0000 Wenbo Cao <[email protected]> wrote:
drivers/net/rnp/base/rnp_hw.h +8
-0+struct rnp_mbx_stats { +u32 msgs_tx; +u32 msgs_rx; + +u32 acks; +u32 reqs; +u32 rsts; +};
Easy to cause wraparound of 32 bits in these stats. Why use u32 and not uint32_t or uint64_t.
Quoted 16 lines
drivers/net/rnp/base/rnp_hw.h +16
-0+struct rnp_mbx_info { + struct rnp_mbx_api ops; + uint32_t usec_delay; /* retry interval delay time */ + uint32_t timeout; /* retry ops timeout limit */ + uint16_t size; /* data buffer size*/ + uint16_t vf_num; /* Virtual Function num */ + uint16_t pf_num; /* Physical Function num */ + uint16_t sriov_st; /* Sriov state */ + bool irq_enabled; + union { + struct { + unsigned short pf_req; + unsigned short pf_ack; + }; + struct { + unsigned short cpu_req;
drivers/net/rnp/base/rnp_hw.h line 94
Quoted 10 lines
drivers/net/rnp/base/rnp_hw.h +10
-0+unsigned short cpu_ack; + }; + }; +unsigned short vf_req[64 ]; +unsigned short vf_ack[64 ]; + +struct rnp_mbx_stats stats; + +rte_atomic16_t state; +} __rte_cache_aligned;
You may want to reorder this data structure to reduce cache misses. The last element is almost certainly on another cache line. Also, if you want faster statistics should consider per core, per queue or per VF.
PATCH v2 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_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 | 46 +++++ drivers/net/rnp/meson.build | 3 + drivers/net/rnp/rnp.h | 28 ++- drivers/net/rnp/rnp_ethdev.c | 93 +++++++++- drivers/net/rnp/rnp_mbx_fw.c | 272 ++++++++++++++++++++++++++++ drivers/net/rnp/rnp_mbx_fw.h | 163 ++++++++++++++++- 11 files changed, 836 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_fw.c
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 +46 -0
82 lines not on this page · raw message
drivers/net/rnp/meson.build +3 -0
@@ -10,5 +10,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 -1
@@ -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_INDEPEND , +}; +/* +* 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 {void *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,10 +80,10 @@ static inline void rnp_reg_offset_init(struct rnp_hw *hw) hw->msix_base = hw->iobar4 +0xa0000 ; }/* === dma status/config====== */ + hw->dev_version = hw->iobar4 +0x0000 ; hw->link_sync = hw->iobar4 +0x000c ; hw->dma_axi_en = hw->iobar4 +0x0010 ; hw->dma_axi_st = hw->iobar4 +0x0014 ; -if (hw->mbx.pf_num) hw->msix_base +=0x200 ;/* === queue registers === */
@@ -69,5 +93,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] = hw->iobar4 +0x60000 +0x10000 * i; +/* === top reg === */ + hw->comm_reg_base = 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.c new file +272 -0
272 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
PATCH v2 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 | 19 +++ 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 | 83 ++++++++++++ drivers/net/rnp/rnp_rxtx.h | 14 +++ 10 files changed, 707 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 +19 -0
@@ -30,6 +30,11 @@ static inline void rnp_wr_reg(volatile void *reg, int val)#define rnp_eth_rd (hw, off) rnp_rd_reg((char *)(hw)->eth_base + (off))#define rnp_eth_wr (hw, off, val) \ rnp_wr_reg((char *)(hw)->eth_base + (off), val) +/* ================== reg-rw == */ +#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 {
@@ -99,9 +104,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
@@ -11,6 +11,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 +83 -0
83 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
PATCH v2 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 | 164 +++++++++++++++++++++++++++++++++++ drivers/net/rnp/rnp_mbx_fw.c | 164 +++++++++++++++++++++++++++++++++++ drivers/net/rnp/rnp_mbx_fw.h | 69 +++++++++++++++ 4 files changed, 419 insertions(+)
drivers/net/rnp/rnp.h +22 -0
@@ -107,6 +107,8 @@ struct rnp_eth_port {void *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 +164 -0
200 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 v2 7/8] net/rnp add devargs runtime parsing functions
drivers/net/rnp/rnp_ethdev.c rnp_special_ops_init(struct rte_eth_dev *eth_dev) · line 479
Quoted 5 lines · On Wed, 2 Aug 2023 08:11:05 +0000 Wenbo Cao <[email protected]> wrote:
drivers/net/rnp/rnp_ethdev.c +5
-0+if (strcmp (key,RNP_HW_MAC_LOOPBACK_ARG ) ==0 ) { +uint16_t *n = extra_args; + *n = (uint16_t )strtoul (value,NULL ,10 ); +if (*n ==USHRT_MAX && errno ==ERANGE ) +return -1 ;
You should be using unsigned long for n here
and no cast. Otherwise a large buggy argument would not be caught.
Something like:
if (strcmp(key, RNP_HW_MAC_LOOPBACK_ARG) == 0) {
unsigned long n;
uint16_t *result = extra_args;
n = strtoul(value, NULL, 10);
if (n > UINT16_MAX) {
XXXLOG("invalid loopback arg"...
return -1;
}
*result = n;PATCH v2 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)
@@ -35,6 +36,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
@@ -599,10 +599,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 ] =" " ;
@@ -678,6 +691,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_ADDRES =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