net: rnpgbe: Add TX/RX and link status support
Subsystems (3)
Dong Yibo
maintainerv16 cover net: rnpgbe: Add TX/RX and link status support
Hi maintainers,
This patch series adds the packet transmission, reception, and link status management features to the RNPGBE driver, building upon the previously introduced mailbox communication and basic driver infrastructure.
The series introduces:
- MSI-X interrupt handling with NAPI support
- TX path with scatter-gather DMA and completion handling
- RX path with page pool buffer management
- Unicast/Multicast filter.
- Firmware link-event processing and carrier management
These changes enable the RNPGBE driver to support basic TX/RX network operations.
---
Changelog:
v15 -> v16:
[patch 2/5]:
1. Clarify that carrier is enabled by the later link-status patch. [patch 3/5]:
1. Track RX drop reasons across polls and account each packet once at EOP, giving length errors precedence over resource drops.
2. Check for pending RX refills before releasing NAPI ownership, and arm the retry timer after successful completion.
Links:
v1: https://lore.kernel.org/netdev/[email protected]/ v2: https://lore.kernel.org/netdev/[email protected]/ v3: https://lore.kernel.org/netdev/[email protected]/ v4: https://lore.kernel.org/netdev/[email protected]/ v5: https://lore.kernel.org/netdev/[email protected]/ v6: https://lore.kernel.org/netdev/[email protected]/ v7: https://lore.kernel.org/netdev/[email protected]/ v8: https://lore.kernel.org/netdev/[email protected]/ v9: https://lore.kernel.org/netdev/[email protected]/ v10: https://lore.kernel.org/netdev/[email protected]/ v11: https://lore.kernel.org/netdev/[email protected]/ v12: https://lore.kernel.org/netdev/[email protected]/ v13: https://lore.kernel.org/netdev/[email protected]/ v14: https://lore.kernel.org/netdev/[email protected]/ v15: https://lore.kernel.org/netdev/[email protected]/
---
Dong Yibo (5):
net: rnpgbe: Add interrupt handling
net: rnpgbe: Add basic TX packet transmission support
net: rnpgbe: Add basic RX data path support
net: rnpgbe: Add receive mode support
net: rnpgbe: Add link status handling support
drivers/net/ethernet/mucse/Kconfig | 2 + drivers/net/ethernet/mucse/rnpgbe/Makefile | 3 +- drivers/net/ethernet/mucse/rnpgbe/rnpgbe.h | 216 +- .../net/ethernet/mucse/rnpgbe/rnpgbe_chip.c | 167 +- drivers/net/ethernet/mucse/rnpgbe/rnpgbe_hw.h | 45 + .../net/ethernet/mucse/rnpgbe/rnpgbe_lib.c | 2262 +++++++++++++++++ .../net/ethernet/mucse/rnpgbe/rnpgbe_lib.h | 88 + .../net/ethernet/mucse/rnpgbe/rnpgbe_main.c | 208 +- .../net/ethernet/mucse/rnpgbe/rnpgbe_mbx.c | 179 +- .../net/ethernet/mucse/rnpgbe/rnpgbe_mbx.h | 4 + .../net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.c | 283 +++ .../net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.h | 60 + 12 files changed, 3478 insertions(+), 39 deletions(-) create mode 100644 drivers/net/ethernet/mucse/rnpgbe/rnpgbe_lib.c create mode 100644 drivers/net/ethernet/mucse/rnpgbe/rnpgbe_lib.h
Signature · 1 line
2.50.1
Dong Yibo
maintainerPATCH v16 1/5 net: rnpgbe: Add interrupt handling
Add interrupt setup and teardown for the RNPGBE driver.
Require at least two MSI-X vectors. Reserve vector 0 for the mailbox and assign the remaining vectors to the data path. Set up mailbox workqueue plumbing for asynchronous firmware events. Mailbox transactions run in process context, allowing mailbox lock acquisition to use sleepable polling.
Notify firmware of driver powerdown from both remove and shutdown through a shared helper.
--- drivers/net/ethernet/mucse/Kconfig | 1 + drivers/net/ethernet/mucse/rnpgbe/Makefile | 3 +- drivers/net/ethernet/mucse/rnpgbe/rnpgbe.h | 48 ++ .../net/ethernet/mucse/rnpgbe/rnpgbe_chip.c | 4 + drivers/net/ethernet/mucse/rnpgbe/rnpgbe_hw.h | 2 + .../net/ethernet/mucse/rnpgbe/rnpgbe_lib.c | 576 ++++++++++++++++++ .../net/ethernet/mucse/rnpgbe/rnpgbe_lib.h | 35 ++ .../net/ethernet/mucse/rnpgbe/rnpgbe_main.c | 89 ++- .../net/ethernet/mucse/rnpgbe/rnpgbe_mbx.c | 12 +- .../net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.c | 11 + .../net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.h | 1 + 11 files changed, 765 insertions(+), 17 deletions(-) create mode 100644 drivers/net/ethernet/mucse/rnpgbe/rnpgbe_lib.c create mode 100644 drivers/net/ethernet/mucse/rnpgbe/rnpgbe_lib.h
drivers/net/ethernet/mucse/Kconfig +1 -0
@@ -19,6 +19,7 @@ if NET_VENDOR_MUCSE config MGBE tristate "Mucse(R) 1GbE PCI Express adapters support" depends on PCI + depends on PCI_MSI help This driver supports Mucse(R) 1GbE PCI Express family of adapters.
drivers/net/ethernet/mucse/rnpgbe/Makefile +2 -1
@@ -8,4 +8,5 @@ obj-$(CONFIG_MGBE) += rnpgbe.o rnpgbe-objs := rnpgbe_main.o\ rnpgbe_chip.o\ rnpgbe_mbx.o\ - rnpgbe_mbx_fw.o + rnpgbe_mbx_fw.o\ + rnpgbe_lib.o
drivers/net/ethernet/mucse/rnpgbe/rnpgbe.h +48 -0
79 lines not on this page · raw message
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_chip.c +4 -0
@@ -89,6 +89,8 @@ static void rnpgbe_init_n500(struct mucse_hw *hw) {struct mucse_mbx_info *mbx = &hw->mbx; + hw->ring_msix_base = hw->hw_addr +MUCSE_N500_RING_MSIX_BASE ; + mbx->fwpf_ctrl_base =MUCSE_N500_FWPF_CTRL_BASE ; mbx->fwpf_shm_base =MUCSE_N500_FWPF_SHM_BASE ; }
@@ -104,6 +106,8 @@ static void rnpgbe_init_n210(struct mucse_hw *hw) {struct mucse_mbx_info *mbx = &hw->mbx; + hw->ring_msix_base = hw->hw_addr +MUCSE_N210_RING_MSIX_BASE ; + mbx->fwpf_ctrl_base =MUCSE_N210_FWPF_CTRL_BASE ; mbx->fwpf_shm_base =MUCSE_N210_FWPF_SHM_BASE ; }
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_hw.h +2 -0
@@ -6,10 +6,12 @@#define MUCSE_N500_FWPF_CTRL_BASE 0x28b00#define MUCSE_N500_FWPF_SHM_BASE 0x2d000 +#define MUCSE_N500_RING_MSIX_BASE 0x28700#define MUCSE_GBE_PFFW_MBX_CTRL_OFFSET 0x5500#define MUCSE_GBE_FWPF_MBX_MASK_OFFSET 0x5700#define MUCSE_N210_FWPF_CTRL_BASE 0x29400#define MUCSE_N210_FWPF_SHM_BASE 0x2d900 +#define MUCSE_N210_RING_MSIX_BASE 0x29000#define RNPGBE_DMA_AXI_EN 0x0010
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_lib.c new file +576 -0
576 lines not on this page · raw message
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_lib.h new file +35 -0
@@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright(c) 2020 - 2025 Mucse Corporation. */ + +#ifndef _RNPGBE_LIB_H +#define _RNPGBE_LIB_H + +#include <linux/bits.h> + +struct mucse ; +struct mucse_hw ; + +#define RING_OFFSET (n) (0x1000 + 0x100 * (n)) +#define RNPGBE_DMA_INT_MASK 0x24 +#define TX_INT_MASK BIT(1) +#define RX_INT_MASK BIT(0) +#define INT_VALID (BIT(16) | BIT(17)) +#define RNPGBE_DMA_INT_TRIG 0x2c/* lost-interrupt recovery trigger */ +/* | 31:24 | .... | 15:8 | 7:0 | */ +/* | pfvfnum | | tx vector | rx vector | */ +#define RING_VECTOR (n) (0x04 * (n)) + +#define mucse_for_each_ring (pos, head)\ + for (typeof((head).ring) __pos = (head).ring;\ + __pos ? ({ pos = __pos; 1; }) : 0;\ + __pos = __pos->next) + +int rnpgbe_init_interrupt_scheme (struct mucse *mucse); +void rnpgbe_clear_interrupt_scheme (struct mucse *mucse); +int rnpgbe_request_mbx_irq (struct mucse *mucse); +void rnpgbe_free_mbx_irq (struct mucse *mucse); +int rnpgbe_request_irq (struct mucse *mucse); +void rnpgbe_free_irq (struct mucse *mucse); +void rnpgbe_down (struct mucse *mucse); +void rnpgbe_up_complete (struct mucse *mucse); +#endif
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_main.c +79 -10
152 lines not on this page · raw message
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx.c +6 -6
@@ -84,7 +84,7 @@ static u32 mucse_mbx_get_lock_pf(struct mucse_hw *hw)* @hw: pointer to the HW structure * * Pair with mucse_release_mbx_lock_pf() -* This function maybe used in an irq handler. +* All mailbox access runs in process context. * * Return: 0 on success, negative errno on failure **/
@@ -93,11 +93,11 @@ static int mucse_obtain_mbx_lock_pf(struct mucse_hw *hw)struct mucse_mbx_info *mbx = &hw->mbx;u32 val; -return read_poll_timeout_atomic (mucse_mbx_get_lock_pf, - val, val &MUCSE_MBX_PFU , - mbx->delay_us, - mbx->timeout_us, - false, hw); +return read_poll_timeout (mucse_mbx_get_lock_pf, + val, val &MUCSE_MBX_PFU , + mbx->delay_us, + mbx->timeout_us, + false, hw); }/**
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.c +11 -0
@@ -197,3 +197,14 @@ int mucse_mbx_get_macaddr(struct mucse_hw *hw, int pfvfnum,return 0 ; } + +/** +* mucse_fw_irq_handler - Deferred firmware mailbox notification hook +* @hw: pointer to the HW structure +* +* No asynchronous firmware events are enabled until link status support is +* added. +**/ +void mucse_fw_irq_handler (struct mucse_hw *hw) +{ +}
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.h +1 -0
@@ -99,4 +99,5 @@ int mucse_mbx_powerup(struct mucse_hw *hw, bool is_powerup);int mucse_mbx_reset_hw (struct mucse_hw *hw);int mucse_mbx_get_macaddr (struct mucse_hw *hw,int pfvfnum,u8 *mac_addr,int port); +void mucse_fw_irq_handler (struct mucse_hw *hw);#endif /* _RNPGBE_MBX_FW_H */
Signature · 1 line
2.50.1
[email protected]
AI reviewRe: [PATCH net-next v16 1/5] net: rnpgbe: Add interrupt handling
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you…
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The patch is titled and described as "Add interrupt handling", but it also changes how the already-merged driver shuts down and is…
--
net: rnpgbe: Add interrupt handling
This commit adds MSI-X interrupt setup and teardown for the rnpgbe driver. Vector 0 is reserved for the mailbox and the remaining vectors are used for the data path. Mailbox lock polling now uses a sleepable variant, and a shared helper sends the firmware powerdown notification from both remove and shutdown.
Quoted 4 lines
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_main.c +0
-0
[ ... ]
Quoted 17 lines
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_main.c +13
-0@@ -236,6 +281,26 @@ static int rnpgbe_probe(struct pci_dev *pdev, const struct pci_device_id *id)return err; } +/** +* rnpgbe_notify_powerdown - Notify firmware that the driver is going down +* @mucse: pointer to private structure +* +* Skip the mailbox access if an earlier shutdown has already disabled the +* PCI device. +**/ +static void rnpgbe_notify_powerdown (struct mucse *mucse) +{ +int err; + +if (!pci_is_enabled (mucse->pdev)) +return ;
[ ... ]
Quoted 15 lines
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_main.c +2
-2@@ -272,7 +335,8 @@ static void rnpgbe_remove(struct pci_dev *pdev) {rnpgbe_rm_adapter (pdev);pci_release_mem_regions (pdev); -pci_disable_device (pdev); +if (pci_is_enabled (pdev)) +pci_disable_device (pdev); }/** @@ -287,9 +351,14 @@ static void rnpgbe_dev_shutdown(struct pci_dev *pdev)rtnl_lock ();netif_device_detach (netdev);if (netif_running (netdev)) -rnpgbe_close (netdev);
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_main.c static void rnpgbe_dev_shutdown(struct pci_dev *pdev) · line 362
Quoted 10 lines
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_main.c +7
-1+dev_close (netdev);rtnl_unlock (); -pci_disable_device (pdev); + +rnpgbe_free_mbx_irq (mucse); +rnpgbe_notify_powerdown (mucse); +rnpgbe_clear_interrupt_scheme (mucse); +if (pci_is_enabled (pdev)) +pci_disable_device (pdev); }
[Severity: Low]
This isn't a bug, but should the commit message cover these teardown changes? The only related text in the commit message is:
Notify firmware of driver powerdown from both remove and shutdown through a shared helper.
The patch also changes how the existing teardown code behaves, and the commit message does not describe these changes:
- rnpgbe_dev_shutdown() now calls dev_close() instead of calling rnpgbe_close() directly.
- rnpgbe_dev_shutdown() and rnpgbe_remove() now call pci_disable_device() only when pci_is_enabled() is true.
- rnpgbe_notify_powerdown() skips the mailbox when the device is already disabled. Its kernel-doc says this is for remove running after an earlier shutdown.
- Shutdown now sends a firmware powerdown, which the previous rnpgbe_dev_shutdown() never did. The commit message doesn't say why.
The dev_close() switch looks correct. rnpgbe_close() now calls rnpgbe_down() and rnpgbe_free_irq(). Calling ndo_stop directly leaves IFF_UP set, so a later unregister_netdev() would call it again and run napi_disable() and free_irq() a second time.
Could these changes be explained in the commit message? Another option is to split them into a separate patch, with a Fixes: tag if they address an observed problem, so reviewers and backporters can follow them.
This code in rnpgbe_main.c is unchanged through the end of the series ("net: rnpgbe: Add link status handling support"), and no later patch explains it either.
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/3B42BE25B3696EAE%2B20261013022920.63529-1-dong100%40mucse.com
Dong Yibo
maintainerPATCH v16 2/5 net: rnpgbe: Add basic TX packet transmission support
In reply to Dong YiboAdd the basic TX path for the RNPGBE driver.
Introduce the TX descriptor structure and buffer management, the rnpgbe_xmit_frame_ring() transmit function, TX ring allocation and teardown, and TX completion handling in rnpgbe_clean_tx_irq(). Track TX packet and byte statistics, and report dropped and tx_dropped counts through ndo_get_stats64().
Keep carrier state off during registration. The link-status patch later in this series enables carrier after firmware reports a valid link.
Configure streaming and coherent DMA masks for the hardware's 56-bit DMA addressing capability. Add cycles_per_us to struct mucse_hw to scale the TX interrupt timer, and enable NETIF_F_HIGHDMA when the DMA mask allows it.
A TX DMA idle timeout is terminal for the current driver instance. The hardware stops PCIe DMA requests, allowing cleanup to release DMA resources. Recovery requires a chip-level reset and driver rebind.
--- drivers/net/ethernet/mucse/rnpgbe/rnpgbe.h | 85 ++- .../net/ethernet/mucse/rnpgbe/rnpgbe_chip.c | 4 + drivers/net/ethernet/mucse/rnpgbe/rnpgbe_hw.h | 9 + .../net/ethernet/mucse/rnpgbe/rnpgbe_lib.c | 695 +++++++++++++++++- .../net/ethernet/mucse/rnpgbe/rnpgbe_lib.h | 31 + .../net/ethernet/mucse/rnpgbe/rnpgbe_main.c | 71 +- 6 files changed, 876 insertions(+), 19 deletions(-)
drivers/net/ethernet/mucse/rnpgbe/rnpgbe.h +80 -5
@@ -44,20 +44,85 @@ struct mucse_hw {struct pci_dev *pdev;struct mucse_mbx_info mbx;int port; +u16 cycles_per_us;u8 pfvfnum; }; +struct rnpgbe_tx_desc { +__le64 pkt_addr;/* Packet buffer address */ +union { +__le64 vlan_cmd_bsz; +struct { +__le32 blen_mac_ip_len; +__le32 vlan_cmd;/* vlan & cmd status */ + }; + }; +#define M_TXD_CMD_RS 0x040000/* Report Status */ +#define M_TXD_STAT_DD 0x020000/* Descriptor Done */ +#define M_TXD_CMD_EOP 0x010000/* End of Packet */ +}; + +#define M_TX_DESC (R , i) (&(((struct rnpgbe_tx_desc *)((R)->desc))[i])) + +struct mucse_tx_buffer { +struct rnpgbe_tx_desc *next_to_watch; +struct sk_buff *skb; +unsigned int bytecount; +unsigned short gso_segs; +DEFINE_DMA_UNMAP_ADDR (dma); +DEFINE_DMA_UNMAP_LEN (len); +bool mapped_as_page;/* true if dma was mapped with dma_map_page */ +}; + +struct mucse_queue_stats { +u64 packets; +u64 bytes; +atomic64_t dropped; +struct u64_stats_sync syncp; +}____cacheline_aligned_in_smp ; +struct mucse_ring {struct mucse_ring *next;struct mucse_q_vector *q_vector; +struct net_device *netdev; +struct device *dev; +void *desc; +struct mucse_tx_buffer *tx_buffer_info;void __iomem *ring_addr; +void __iomem *tail;void __iomem *irq_mask;void __iomem *trig;u8 queue_index;/* hw ring idx */ u8 rnpgbe_queue_idx; +u8 pfvfnum; +u16 count; +u16 next_to_use; +u16 next_to_clean; +dma_addr_t dma; +unsigned int size; +struct mucse_queue_stats *stats; }____cacheline_internodealigned_in_smp ; +static inline u16 mucse_desc_unused (struct mucse_ring *ring) +{ +u16 ntc = ring->next_to_clean; +u16 ntu = ring->next_to_use; + +return ((ntc > ntu) ?0 : ring->count) + ntc - ntu -1 ; +} + +static inline __le64 build_ctob (u32 vlan_cmd,u32 mac_ip_len,u32 size) +{ +return cpu_to_le64 (((u64 )vlan_cmd <<32 ) | ((u64 )mac_ip_len <<16 ) | + ((u64 )size)); +} + +static inline struct netdev_queue *txring_txq (const struct mucse_ring *ring) +{ +return netdev_get_tx_queue (ring->netdev, ring->queue_index); +} +struct mucse_ring_container {struct mucse_ring *ring;u16 count;
@@ -74,27 +139,33 @@ struct mucse_q_vector {struct mucse_ring ring[]____cacheline_internodealigned_in_smp ; }; -struct mucse_stats { -u64 tx_dropped; -}; -#define MAX_Q_VECTORS 8 +#define M_DEFAULT_TXD 512 +#define M_DEFAULT_TX_WORK 256 + +enum mucse_state_t { + __MUCSE_AXI_FAULT, +}; +struct mucse {struct net_device *netdev;struct pci_dev *pdev;struct mucse_hw hw; -struct mucse_stats stats;struct mucse_ring *tx_ring[RNPGBE_MAX_QUEUES ]____cacheline_aligned_in_smp ;struct mucse_ring *rx_ring[RNPGBE_MAX_QUEUES ]____cacheline_aligned_in_smp ; +struct mucse_queue_stats tx_stats[RNPGBE_MAX_QUEUES ];struct mucse_q_vector *q_vector[MAX_Q_VECTORS ]; +int tx_ring_item_count; +int tx_work_limit;int num_tx_queues;int num_q_vectors;int num_rx_queues;char mbx_name[32 ];bool mbx_irq_requested; +unsigned long state;struct work_struct mbx_work; };
@@ -116,4 +187,8 @@ int rnpgbe_init_hw(struct mucse_hw *hw, int board_type); writel((val), (hw)->hw_addr + (reg))#define mucse_hw_rd32 (hw, reg) \ readl((hw)->hw_addr + (reg)) +#define mucse_ring_wr32 (ring, reg, val) \ + writel((val), (ring)->ring_addr + (reg)) +#define mucse_ring_rd32 (ring, reg) \ + readl((ring)->ring_addr + (reg))#endif /* _RNPGBE_H */
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_chip.c +4 -0
@@ -93,6 +93,8 @@ static void rnpgbe_init_n500(struct mucse_hw *hw) mbx->fwpf_ctrl_base =MUCSE_N500_FWPF_CTRL_BASE ; mbx->fwpf_shm_base =MUCSE_N500_FWPF_SHM_BASE ; + + hw->cycles_per_us =M_DEFAULT_N500_MHZ ; }/**
@@ -110,6 +112,8 @@ static void rnpgbe_init_n210(struct mucse_hw *hw) mbx->fwpf_ctrl_base =MUCSE_N210_FWPF_CTRL_BASE ; mbx->fwpf_shm_base =MUCSE_N210_FWPF_SHM_BASE ; + + hw->cycles_per_us =M_DEFAULT_N210_MHZ ; }/**
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_hw.h +9 -0
@@ -4,16 +4,25 @@#ifndef _RNPGBE_HW_H#define _RNPGBE_HW_H +#include <linux/bits.h> +#define MUCSE_N500_FWPF_CTRL_BASE 0x28b00#define MUCSE_N500_FWPF_SHM_BASE 0x2d000#define MUCSE_N500_RING_MSIX_BASE 0x28700 +#define M_DEFAULT_N500_MHZ 125#define MUCSE_GBE_PFFW_MBX_CTRL_OFFSET 0x5500#define MUCSE_GBE_FWPF_MBX_MASK_OFFSET 0x5700#define MUCSE_N210_FWPF_CTRL_BASE 0x29400#define MUCSE_N210_FWPF_SHM_BASE 0x2d900#define MUCSE_N210_RING_MSIX_BASE 0x29000 +#define M_DEFAULT_N210_MHZ 62 +#define RNPGBE_DMA_STATUS 0x0008 +#define TX_AXI_RW_EN 0xc +/* DMA_STATUS_REG[23:20]: tx_wr, tx_rd, rx_wr, rx_rd done status. */ +#define RNPGBE_DMA_TX_STATUS GENMASK_U32(23, 22)#define RNPGBE_DMA_AXI_EN 0x0010 +#define RNPGBE_TX_MIN_PKT_LEN 33#define RNPGBE_MAX_QUEUES 8#endif /* _RNPGBE_HW_H */
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_lib.c +691 -4
762 lines not on this page · raw message
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_lib.h +31 -0
@@ -5,20 +5,43 @@#define _RNPGBE_LIB_H#include <linux/bits.h> +#include <linux/netdevice.h> +#include <linux/skbuff.h> struct mucse ;struct mucse_hw ; +struct mucse_ring ;#define RING_OFFSET (n) (0x1000 + 0x100 * (n)) +#define RNPGBE_TX_START 0x18#define RNPGBE_DMA_INT_MASK 0x24#define TX_INT_MASK BIT(1)#define RX_INT_MASK BIT(0)#define INT_VALID (BIT(16) | BIT(17))#define RNPGBE_DMA_INT_TRIG 0x2c/* lost-interrupt recovery trigger */ +#define RNPGBE_TX_BASE_ADDR_HI 0x60 +#define RNPGBE_TX_BASE_ADDR_LO 0x64 +#define RNPGBE_TX_LEN 0x68 +#define RNPGBE_TX_HEAD 0x6c +#define RNPGBE_TX_TAIL 0x70 +#define M_DEFAULT_TX_FETCH 0x80008 +#define RNPGBE_TX_FETCH_CTRL 0x74 +#define M_DEFAULT_INT_TIMER 100 +#define RNPGBE_TX_INT_TIMER 0x78 +#define M_DEFAULT_INT_PKTCNT 48 +#define RNPGBE_TX_INT_PKTCNT 0x7c/* | 31:24 | .... | 15:8 | 7:0 | */ /* | pfvfnum | | tx vector | rx vector | */ #define RING_VECTOR (n) (0x04 * (n)) +#define M_MAX_TXD_PWR 12 +#define M_MAX_DATA_PER_TXD (0x1 << M_MAX_TXD_PWR) +#define TXD_USE_COUNT (S ) DIV_ROUND_UP((S), M_MAX_DATA_PER_TXD) +#define DESC_NEEDED (MAX_SKB_FRAGS + 4) +/* Leave two descriptors between the tail and head. */ +#define RESV_DESC_NEEDED 2 +/* Hardware requires this to be nonzero */ +#define M_DEFAULT_MAC_IP_LEN 20#define mucse_for_each_ring (pos, head)\ for (typeof((head).ring) __pos = (head).ring;\ __pos ? ({ pos = __pos; 1; }) : 0;\
@@ -32,4 +55,12 @@ int rnpgbe_request_irq(struct mucse *mucse);void rnpgbe_free_irq (struct mucse *mucse);void rnpgbe_down (struct mucse *mucse);void rnpgbe_up_complete (struct mucse *mucse); +int rnpgbe_configure_tx (struct mucse *mucse); +void rnpgbe_clean_all_tx_rings (struct mucse *mucse); +int rnpgbe_setup_all_tx_resources (struct mucse *mucse); +void rnpgbe_free_all_tx_resources (struct mucse *mucse); +netdev_tx_t rnpgbe_xmit_frame_ring (struct sk_buff *skb, +struct mucse_ring *tx_ring); +void rnpgbe_get_stats64 (struct net_device *netdev, +struct rtnl_link_stats64 *stats);#endif
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_main.c +61 -10
143 lines not on this page · raw message
Signature · 1 line
2.50.1
[email protected]
AI reviewRe: [PATCH net-next v16 2/5] net: rnpgbe: Add basic TX packet transmission support
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 2
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [Medium] When rnpgbe_wait_tx_dma_idle() times out, the driver only latches __MUCSE_AXI_FAULT and logs an error.
- [Low] The commit message does not cover everything the patch changes.
- [Low] In rnpgbe_clean_tx_irq() the comment says it clears next_to_watch "to prevent false hangs", but the driver has no TX hang detection.
--
net: rnpgbe: Add basic TX packet transmission support
This commit adds the basic TX path for the rnpgbe driver. It covers TX descriptor and buffer management, rnpgbe_xmit_frame_ring(), TX ring setup and teardown, and NAPI TX completion in rnpgbe_clean_tx_irq(). It also sets a 56-bit DMA mask, reports TX statistics through ndo_get_stats64(), and treats a TX DMA idle timeout as a terminal fault.
Quoted 5 lines
Introduce the TX descriptor structure and buffer management, the
rnpgbe_xmit_frame_ring()transmit function, TX ring allocation and teardown, and TX completion handling inrnpgbe_clean_tx_irq(). Track TX packet and byte statistics, and report dropped andtx_droppedcounts throughndo_get_stats64().
[ ... ]
Quoted 4 lines
Configure streaming and coherent DMA masks for the hardware's 56-bit DMA addressing capability. Add
cycles_per_usto structmucse_hwto scale the TX interrupt timer, and enableNETIF_F_HIGHDMAwhen the DMA mask allows it.
[Severity: Low]
Is "report dropped and tx_dropped counts" accurate?
rnpgbe_get_stats64() fills only stats->tx_packets, stats->tx_bytes and stats->tx_dropped. The per-queue dropped counter is added into tx_dropped and is not reported on its own.
The message mentions NETIF_F_HIGHDMA, but not the NETIF_F_SG change right next to it. rnpgbe_add_adapter() now sets NETIF_F_SG in both netdev->features and netdev->hw_features, so non-linear skbs will go through the frag-mapping loop in rnpgbe_tx_map().
The patch also adds BQL accounting, which the message doesn't mention:netdev_tx_sent_queue() in rnpgbe_tx_map(), __netif_txq_completed_wake() in rnpgbe_clean_tx_irq(), and netdev_tx_reset_queue() in rnpgbe_clean_tx_ring().
Could the commit message describe the SG and BQL changes too?
Quoted 4 lines
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_lib.c +0
-0
[ ... ]
Quoted 6 lines
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_lib.c +2
-0@@ -65,26 +67,143 @@ static void rnpgbe_irq_enable_queues(struct mucse_q_vector *q_vector) } } +/** +* rnpgbe_clean_tx_irq - Reclaim resources after transmit completes
[ ... ]
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_lib.c static void rnpgbe_irq_enable_queues(struct mucse_q_vector *q_vector) · line 107
Quoted 5 lines
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_lib.c +5
-0+/* if eop DD is not set pending work has not been completed */ +if (!(eop_desc->vlan_cmd &cpu_to_le32 (M_TXD_STAT_DD ))) +break ; +/* clear next_to_watch to prevent false hangs */ + tx_buffer->next_to_watch =NULL ;
[Severity: Low]
This isn't a bug, but is the "prevent false hangs" comment accurate for this driver?
rnpgbe_netdev_ops has no ndo_tx_timeout, and nothing in the driver checks next_to_watch for hangs. Here next_to_watch only marks a pending packet for rnpgbe_clean_tx_irq() and rnpgbe_clean_tx_ring(). The comment seems to have been carried over from ixgbe.
[ ... ]
Quoted 4 lines
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_lib.c +0
-0@@ -556,12 +680,173 @@ static void rnpgbe_napi_disable_all(struct mucse *mucse)napi_disable (&mucse->q_vector[i]->napi); }
[ ... ]
Quoted 24 lines
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_lib.c +24
-0+static int rnpgbe_wait_tx_dma_idle (struct mucse *mucse) +{ +struct mucse_hw *hw = &mucse->hw; +u32 dma_status; +int err; + +/* A timeout indicates a terminal AXI fault. Hardware stops all PCIe +* DMA requests in this state, including requests accepted before the +* fault. Teardown may therefore release mappings and descriptor memory. +* Recovery requires a chip-level reset. +*/ + err =readl_poll_timeout (hw->hw_addr +RNPGBE_DMA_STATUS , + dma_status, + (dma_status &RNPGBE_DMA_TX_STATUS ) == +RNPGBE_DMA_TX_STATUS , +10 ,100000 ); +if (err) { +set_bit (__MUCSE_AXI_FAULT, &mucse->state); +dev_err (&mucse->pdev->dev, +"TX DMA failed to quiesce, status %#x\n" , dma_status); + } + +return err; +}
[ ... ]
Quoted 9 lines
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_lib.c +9
-0+if (mucse->num_tx_queues && + !test_bit (__MUCSE_AXI_FAULT, &mucse->state)) + err =rnpgbe_wait_tx_dma_idle (mucse); + + dma_axi_ctl =mucse_hw_rd32 (hw,RNPGBE_DMA_AXI_EN ); + dma_axi_ctl &= ~TX_AXI_RW_EN ; +mucse_hw_wr32 (hw,RNPGBE_DMA_AXI_EN , dma_axi_ctl); +/* Flush the posted write before continuing. */ + (void )mucse_hw_rd32 (hw,RNPGBE_DMA_AXI_EN );
[ ... ]
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_lib.c static void rnpgbe_napi_disable_all(struct mucse *mucse) · line 838
Quoted 11 lines
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_lib.c +11
-0+void rnpgbe_clean_all_tx_rings (struct mucse *mucse) +{ +/* rnpgbe_stop_all_tx_rings() logs and latches any AXI fault. Hardware +* stops DMA requests in this state, so cleanup intentionally ignores +* an error and releases the mappings and descriptor memory. +*/ +rnpgbe_stop_all_tx_rings (mucse); + +for (int i =0 ; i < mucse->num_tx_queues; i++) +rnpgbe_clean_tx_ring (mucse->tx_ring[i]); +}
[Severity: Medium]
After rnpgbe_wait_tx_dma_idle() times out, what guarantees that the device has actually stopped DMA?
On a timeout the driver only sets __MUCSE_AXI_FAULT and clears the internal TX_AXI_RW_EN gate in rnpgbe_stop_all_tx_rings(). rnpgbe_clean_all_tx_rings() then ignores the error. It unmaps the TX buffers, frees the skbs and memsets the descriptor ring.
After that, rnpgbe_close() or the err_free_tx path in rnpgbe_open() continues with:
rnpgbe_free_all_tx_resources()
rnpgbe_free_tx_resources()
dma_free_coherent(tx_ring->dev, tx_ring->size, tx_ring->desc,
tx_ring->dma);The only reason this would be safe is the hardware claim in the comment and the commit message, that the hardware "stops all PCIe DMA requests in this state". Nothing on the host side enforces that:
- rnpgbe_probe() calls pci_set_master(), but the driver never calls pci_clear_master() and never resets the function.
- TX_BASE_ADDR_HI/LO keep pointing at the freed ring. Once the bit is set, rnpgbe_open() returns -EIO, so nothing reprograms them.
- Bus Master Enable is only cleared by pci_disable_device() in rnpgbe_remove() or rnpgbe_dev_shutdown(), long after the memory was freed.
The timeout also only means the done bits weren't seen within 100ms. A slow drain looks the same as a real fault.
If the device does write DD status back late, or reads a buffer after the unmap, wouldn't that land in freed and possibly reused memory?
Would it be safer to call pci_clear_master() (or reset the function) on the fault path before releasing DMA memory, or to leak the ring and buffers in this case instead of freeing them?
The later patch "net: rnpgbe: Add basic RX data path support" in this series uses the same approach for RX.
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/3B42BE25B3696EAE%2B20261013022920.63529-1-dong100%40mucse.com
Yibo Dong
maintainerRe: [PATCH net-next v16 2/5] net: rnpgbe: Add basic TX packet transmission support
Quoted 95 lines · On Wed, Oct 14, 2026 at 02:59:13AM +0000, [email protected] wrote:
[ ... ]
Quoted 4 lines
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_lib.c +0
-0@@ -556,12 +680,173 @@ static void rnpgbe_napi_disable_all(struct mucse *mucse)napi_disable (&mucse->q_vector[i]->napi); }[ ... ]
Quoted 24 lines
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_lib.c +24
-0+static int rnpgbe_wait_tx_dma_idle (struct mucse *mucse) +{ +struct mucse_hw *hw = &mucse->hw; +u32 dma_status; +int err; + +/* A timeout indicates a terminal AXI fault. Hardware stops all PCIe +* DMA requests in this state, including requests accepted before the +* fault. Teardown may therefore release mappings and descriptor memory. +* Recovery requires a chip-level reset. +*/ + err =readl_poll_timeout (hw->hw_addr +RNPGBE_DMA_STATUS , + dma_status, + (dma_status &RNPGBE_DMA_TX_STATUS ) == +RNPGBE_DMA_TX_STATUS , +10 ,100000 ); +if (err) { +set_bit (__MUCSE_AXI_FAULT, &mucse->state); +dev_err (&mucse->pdev->dev, +"TX DMA failed to quiesce, status %#x\n" , dma_status); + } + +return err; +}[ ... ]
Quoted 9 lines
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_lib.c +9
-0+if (mucse->num_tx_queues && + !test_bit (__MUCSE_AXI_FAULT, &mucse->state)) + err =rnpgbe_wait_tx_dma_idle (mucse); + + dma_axi_ctl =mucse_hw_rd32 (hw,RNPGBE_DMA_AXI_EN ); + dma_axi_ctl &= ~TX_AXI_RW_EN ; +mucse_hw_wr32 (hw,RNPGBE_DMA_AXI_EN , dma_axi_ctl); +/* Flush the posted write before continuing. */ + (void )mucse_hw_rd32 (hw,RNPGBE_DMA_AXI_EN );[ ... ]
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_lib.c static void rnpgbe_napi_disable_all(struct mucse *mucse) · line 838
Quoted 11 lines
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_lib.c +11
-0+void rnpgbe_clean_all_tx_rings (struct mucse *mucse) +{ +/* rnpgbe_stop_all_tx_rings() logs and latches any AXI fault. Hardware +* stops DMA requests in this state, so cleanup intentionally ignores +* an error and releases the mappings and descriptor memory. +*/ +rnpgbe_stop_all_tx_rings (mucse); + +for (int i =0 ; i < mucse->num_tx_queues; i++) +rnpgbe_clean_tx_ring (mucse->tx_ring[i]); +}[Severity: Medium]
Afterrnpgbe_wait_tx_dma_idle()times out, what guarantees that the device has actually stopped DMA?On a timeout the driver only sets
__MUCSE_AXI_FAULTand clears the internalTX_AXI_RW_ENgate inrnpgbe_stop_all_tx_rings().rnpgbe_clean_all_tx_rings()then ignores the error. It unmaps the TX buffers, frees the skbs and memsets the descriptor ring.After that,
rnpgbe_close()or theerr_free_txpath inrnpgbe_open()continues with:
rnpgbe_free_all_tx_resources()
rnpgbe_free_tx_resources()dma_free_coherent(tx_ring->dev, tx_ring->size, tx_ring->desc, tx_ring->dma);The only reason this would be safe is the hardware claim in the comment and the commit message, that the hardware "stops all PCIe DMA requests in this state". Nothing on the host side enforces that:
-
rnpgbe_probe()callspci_set_master(), but the driver never callspci_clear_master()and never resets the function.
- TX_BASE_ADDR_HI/LO keep pointing at the freed ring. Once the bit is set,rnpgbe_open()returns-EIO, so nothing reprograms them.
- Bus Master Enable is only cleared bypci_disable_device()inrnpgbe_remove()orrnpgbe_dev_shutdown(), long after the memory was freed.The timeout also only means the done bits weren't seen within 100ms. A slow drain looks the same as a real fault.
If the device does write DD status back late, or reads a buffer after the unmap, wouldn't that land in freed and possibly reused memory?
Quoted 6 lines
Would it be safer to call
pci_clear_master()(or reset the function) on the fault path before releasing DMA memory, or to leak the ring and buffers in this case instead of freeing them?The later patch "net: rnpgbe: Add basic RX data path support" in this series uses the same approach for RX.
This is illegitimate.
Once START=0 has taken effect, hardware does not initiate any new PCIe memory read or write requests, including for prefetched descriptors. The 100 ms wait only covers transactions already in flight. For this chip, failure to reach the done state within that window indicates a terminal AXI fault, not a recoverable slow drain. As documented in the code comments, this fault prevents further host-memory accesses, including from previously accepted requests, and requires a chip-level reset. Cleanup therefore relies on this hardware guarantee. The same to RX.
Quoted 4 lines
Signature · 2 lines
-- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/3B42BE25B3696EAE%2B20261013022920.63529-1-dong100%40mucse.com
Dong Yibo
maintainerPATCH v16 3/5 net: rnpgbe: Add basic RX data path support
In reply to Dong YiboAdd basic RX DMA data path for the RNPGBE driver.
Introduce the RX descriptor structure (union rnpgbe_rx_desc) with the hardware write-back format, and manage RX buffers with page_pool using a single page per descriptor without page splitting. Implement the NAPI poll callback, RX ring setup and teardown, and packet assembly from page buffers, along with RX statistics.
Keep a 16-descriptor gap in the fixed 512-entry RX ring so at most 496 descriptors are posted to hardware. Retry failed page allocations with one timer per q_vector that schedules NAPI and is cancelled before RX cleanup and q_vector teardown.
An RX DMA quiesce timeout is a terminal AXI fault: keep DMA disabled, release existing mappings safely, and reject subsequent opens. Recovery requires a chip-level reset and driver rebind.
--- drivers/net/ethernet/mucse/Kconfig | 1 + drivers/net/ethernet/mucse/rnpgbe/rnpgbe.h | 67 +- drivers/net/ethernet/mucse/rnpgbe/rnpgbe_hw.h | 2 + .../net/ethernet/mucse/rnpgbe/rnpgbe_lib.c | 837 +++++++++++++++++- .../net/ethernet/mucse/rnpgbe/rnpgbe_lib.h | 23 +- .../net/ethernet/mucse/rnpgbe/rnpgbe_main.c | 21 +- 6 files changed, 942 insertions(+), 9 deletions(-)
drivers/net/ethernet/mucse/Kconfig +1 -0
@@ -20,6 +20,7 @@ config MGBE tristate "Mucse(R) 1GbE PCI Express adapters support" depends on PCI depends on PCI_MSI + select PAGE_POOL help This driver supports Mucse(R) 1GbE PCI Express family of adapters.
drivers/net/ethernet/mucse/rnpgbe/rnpgbe.h +66 -1
134 lines not on this page · raw message
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_hw.h +2 -0
@@ -21,6 +21,8 @@#define TX_AXI_RW_EN 0xc/* DMA_STATUS_REG[23:20]: tx_wr, tx_rd, rx_wr, rx_rd done status. */ #define RNPGBE_DMA_TX_STATUS GENMASK_U32(23, 22) +#define RNPGBE_DMA_RX_STATUS GENMASK_U32(21, 20) +#define RX_AXI_RW_EN 0x03#define RNPGBE_DMA_AXI_EN 0x0010#define RNPGBE_TX_MIN_PKT_LEN 33
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_lib.c +833 -4
927 lines not on this page · raw message
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_lib.h +22 -1
@@ -13,12 +13,29 @@ struct mucse_hw;struct mucse_ring ;#define RING_OFFSET (n) (0x1000 + 0x100 * (n)) +#define RNPGBE_RX_START 0x10#define RNPGBE_TX_START 0x18#define RNPGBE_DMA_INT_MASK 0x24#define TX_INT_MASK BIT(1)#define RX_INT_MASK BIT(0)#define INT_VALID (BIT(16) | BIT(17))#define RNPGBE_DMA_INT_TRIG 0x2c/* lost-interrupt recovery trigger */ +#define RNPGBE_RX_BASE_ADDR_HI 0x30 +#define RNPGBE_RX_BASE_ADDR_LO 0x34 +#define RNPGBE_RX_LEN 0x38 +#define RNPGBE_RX_HEAD 0x3c +#define RNPGBE_RX_TAIL 0x40 +#define M_DEFAULT_RX_FETCH 0x100020 +#define RNPGBE_RX_FETCH 0x44 +#define M_DEFAULT_INT_TIMER_R 30 +#define RNPGBE_RX_INT_TIMER 0x48 +#define M_DEFAULT_RX_INT_PKTCNT 64 +#define RNPGBE_RX_INT_PKTCNT 0x4c +#define RNPGBE_RX_TIMEOUT_TH 0x54 +#define RNPGBE_RX_SG_UNIT_BYTES 16 +#define M_DEFAULT_SG 96 +#define RNPGBE_RX_DESC_DATA_LEN (M_DEFAULT_SG * RNPGBE_RX_SG_UNIT_BYTES) +#define RNPGBE_RX_SG_LEN 0x58#define RNPGBE_TX_BASE_ADDR_HI 0x60#define RNPGBE_TX_BASE_ADDR_LO 0x64#define RNPGBE_TX_LEN 0x68
@@ -40,13 +57,14 @@ struct mucse_ring;#define DESC_NEEDED (MAX_SKB_FRAGS + 4)/* Leave two descriptors between the tail and head. */ #define RESV_DESC_NEEDED 2 +#define RNPGBE_SKB_PAD (NET_SKB_PAD + NET_IP_ALIGN) +/* Hardware requires this to be nonzero */ #define M_DEFAULT_MAC_IP_LEN 20#define mucse_for_each_ring (pos, head)\ for (typeof((head).ring) __pos = (head).ring;\ __pos ? ({ pos = __pos; 1; }) : 0;\ __pos = __pos->next) -int rnpgbe_init_interrupt_scheme (struct mucse *mucse);void rnpgbe_clear_interrupt_scheme (struct mucse *mucse);int rnpgbe_request_mbx_irq (struct mucse *mucse);
@@ -56,6 +74,7 @@ void rnpgbe_free_irq(struct mucse *mucse);void rnpgbe_down (struct mucse *mucse);void rnpgbe_up_complete (struct mucse *mucse);int rnpgbe_configure_tx (struct mucse *mucse); +int rnpgbe_configure_rx (struct mucse *mucse);void rnpgbe_clean_all_tx_rings (struct mucse *mucse);int rnpgbe_setup_all_tx_resources (struct mucse *mucse);void rnpgbe_free_all_tx_resources (struct mucse *mucse);
@@ -63,4 +82,6 @@ netdev_tx_t rnpgbe_xmit_frame_ring(struct sk_buff *skb, struct mucse_ring *tx_ring);void rnpgbe_get_stats64 (struct net_device *netdev,struct rtnl_link_stats64 *stats); +int rnpgbe_setup_all_rx_resources (struct mucse *mucse); +void rnpgbe_free_all_rx_resources (struct mucse *mucse);#endif
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_main.c +18 -3
@@ -31,13 +31,19 @@ static struct pci_device_id rnpgbe_pci_tbl[] = {* rnpgbe_configure - Configure the hardware * @mucse: pointer to private structure * -* Configure Tx registers in hardware. +* Configure Tx and Rx registers in hardware. * * Return: 0 on success, negative errno if hardware configuration fails **/ static int rnpgbe_configure (struct mucse *mucse) { -return rnpgbe_configure_tx (mucse); +int err; + + err =rnpgbe_configure_tx (mucse); +if (err) +return err; + +return rnpgbe_configure_rx (mucse); }/**
@@ -69,13 +75,18 @@ static int rnpgbe_open(struct net_device *netdev) err =rnpgbe_setup_all_tx_resources (mucse);if (err) goto err_free_irqs; + err =rnpgbe_setup_all_rx_resources (mucse); +if (err) + goto err_free_tx; err =rnpgbe_configure (mucse);if (err) - goto err_free_tx; + goto err_free_rx;rnpgbe_up_complete (mucse);return 0 ; +err_free_rx: +rnpgbe_free_all_rx_resources (mucse); err_free_tx:rnpgbe_clean_all_tx_rings (mucse);rnpgbe_free_all_tx_resources (mucse);
@@ -100,6 +111,7 @@ static int rnpgbe_close(struct net_device *netdev)rnpgbe_down (mucse);rnpgbe_free_irq (mucse);rnpgbe_free_all_tx_resources (mucse); +rnpgbe_free_all_rx_resources (mucse);return 0 ; }
@@ -139,11 +151,14 @@ static void rnpgbe_sw_init(struct mucse *mucse)int i; mucse->tx_ring_item_count =M_DEFAULT_TXD ; + mucse->rx_ring_item_count =M_DEFAULT_RXD ; mucse->tx_work_limit =M_DEFAULT_TX_WORK ;for (i =0 ; i <RNPGBE_MAX_QUEUES ; i++) {u64_stats_init (&mucse->tx_stats[i].syncp);atomic64_set (&mucse->tx_stats[i].dropped,0 ); +u64_stats_init (&mucse->rx_stats[i].syncp); +atomic64_set (&mucse->rx_stats[i].dropped,0 ); } }
Signature · 1 line
2.50.1
Dong Yibo
maintainerPATCH v16 4/5 net: rnpgbe: Add receive mode support
In reply to Dong YiboAdd chip-level receive filtering and the ndo_set_rx_mode_async callback.
Program the primary and additional unicast addresses into the available RAR entries, and use the 4096-bit multicast hash table for multicast addresses. Advertise RAR-based secondary unicast filtering to the networking core, so it does not force promiscuous mode for a non-empty secondary unicast list. Fall back to accepting all unicast addresses if the RAR table is exhausted, and handle IFF_PROMISC and IFF_ALLMULTI through the chip-level filter control register.
--- drivers/net/ethernet/mucse/rnpgbe/rnpgbe.h | 3 + .../net/ethernet/mucse/rnpgbe/rnpgbe_chip.c | 96 +++++++++++++++++++ drivers/net/ethernet/mucse/rnpgbe/rnpgbe_hw.h | 15 +++ .../net/ethernet/mucse/rnpgbe/rnpgbe_main.c | 17 +++- 4 files changed, 127 insertions(+), 4 deletions(-)
drivers/net/ethernet/mucse/rnpgbe/rnpgbe.h +3 -0
@@ -240,6 +240,9 @@ int rnpgbe_send_notify(struct mucse_hw *hw,bool enable, int mode);int rnpgbe_init_hw (struct mucse_hw *hw,int board_type); +int rnpgbe_set_rx_mode (struct net_device *netdev, +struct netdev_hw_addr_list *uc, +struct netdev_hw_addr_list *mc);/* Device IDs */ #define PCI_VENDOR_ID_MUCSE 0x8848
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_chip.c +96 -0
99 lines not on this page · raw message
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_hw.h +15 -0
@@ -26,5 +26,20 @@#define RNPGBE_DMA_AXI_EN 0x0010#define RNPGBE_TX_MIN_PKT_LEN 33 +#define MUCSE_ETH_OFF (_n) (0x10000 + (_n)) +#define RNPGBE_RX_RAR_LOW (_n) MUCSE_ETH_OFF(0xa000 + 4 * (_n)) +#define RNPGBE_RX_RAR_HIGH (_n) MUCSE_ETH_OFF(0xa400 + 4 * (_n)) +#define RNPGBE_RX_MCAST_HASH (_n) MUCSE_ETH_OFF(0xac00 + 4 * (_n)) +#define RNPGBE_RX_FILTER_CTRL MUCSE_ETH_OFF(0x9110) +#define RNPGBE_RX_MCAST_CTRL MUCSE_ETH_OFF(0x9114) +#define RNPGBE_RX_RAR_VALID BIT(31) +#define RNPGBE_RX_FILTER_BCAST BIT(10) +#define RNPGBE_RX_FILTER_UCAST_ALL BIT(9) +#define RNPGBE_RX_FILTER_MCAST_ALL BIT(8) +#define RNPGBE_RX_MCAST_HASH_EN BIT(4) +#define RNPGBE_RX_UCAST_TABLE_EN BIT(3) +/* The final two of the 32 hardware RAR entries are reserved for NCSI. */ +#define RNPGBE_RX_RAR_ENTRIES 30 +#define RNPGBE_RX_MCAST_HASH_ENTRIES 128#define RNPGBE_MAX_QUEUES 8#endif /* _RNPGBE_HW_H */
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_main.c +13 -4
@@ -43,6 +43,13 @@ static int rnpgbe_configure(struct mucse *mucse)if (err)return err; +netif_addr_lock_bh (mucse->netdev); + err =rnpgbe_set_rx_mode (mucse->netdev, &mucse->netdev->uc, + &mucse->netdev->mc); +netif_addr_unlock_bh (mucse->netdev); +if (err) +return err; +return rnpgbe_configure_rx (mucse); }
@@ -140,10 +147,11 @@ static netdev_tx_t rnpgbe_xmit_frame(struct sk_buff *skb, }static const struct net_device_ops rnpgbe_netdev_ops = { - .ndo_open = rnpgbe_open, - .ndo_stop = rnpgbe_close, - .ndo_start_xmit = rnpgbe_xmit_frame, - .ndo_get_stats64 = rnpgbe_get_stats64, + .ndo_open = rnpgbe_open, + .ndo_stop = rnpgbe_close, + .ndo_start_xmit = rnpgbe_xmit_frame, + .ndo_set_rx_mode_async = rnpgbe_set_rx_mode, + .ndo_get_stats64 = rnpgbe_get_stats64, };static void rnpgbe_sw_init (struct mucse *mucse)
@@ -234,6 +242,7 @@ static int rnpgbe_add_adapter(struct pci_dev *pdev, } netdev->netdev_ops = &rnpgbe_netdev_ops; + netdev->priv_flags |=IFF_UNICAST_FLT ;rnpgbe_sw_init (mucse); err =rnpgbe_reset_hw (hw);if (err) {
Signature · 1 line
2.50.1
Dong Yibo
maintainerPATCH v16 5/5 net: rnpgbe: Add link status handling support
In reply to Dong YiboAdd link status handling for the RNPGBE driver.
Introduce link state data structures for speed, duplex and link state, and process firmware link events delivered over the mailbox, since firmware controls the link and phylink is not used. Add a service task to handle pending events and manage carrier status with netif_carrier_on()/netif_carrier_off().
Notify firmware when the interface is brought up and after the data path is quiesced during teardown, and fail interface open if the firmware port-up or link-report setup fails. Validate firmware link events before updating the cached link state. Enable the GMAC receiver in receive-all mode after the chip-level receive filter has been configured, and document the driver-to-firmware link-state snapshot and reset semantics.
Configure firmware after reset to enable autonegotiation. Advertise 10/100Mb/s half- and full-duplex modes and 1000 Mb/s full-duplex mode. Fail probe if firmware does not acknowledge the link setup command.
--- drivers/net/ethernet/mucse/rnpgbe/rnpgbe.h | 19 +- .../net/ethernet/mucse/rnpgbe/rnpgbe_chip.c | 63 +++- drivers/net/ethernet/mucse/rnpgbe/rnpgbe_hw.h | 17 ++ .../net/ethernet/mucse/rnpgbe/rnpgbe_lib.c | 172 ++++++++++- .../net/ethernet/mucse/rnpgbe/rnpgbe_lib.h | 3 +- .../net/ethernet/mucse/rnpgbe/rnpgbe_main.c | 20 +- .../net/ethernet/mucse/rnpgbe/rnpgbe_mbx.c | 167 ++++++++++- .../net/ethernet/mucse/rnpgbe/rnpgbe_mbx.h | 4 + .../net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.c | 278 +++++++++++++++++- .../net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.h | 59 ++++ 10 files changed, 790 insertions(+), 12 deletions(-)
drivers/net/ethernet/mucse/rnpgbe/rnpgbe.h +16 -3
@@ -5,6 +5,7 @@#define _RNPGBE_H#include <linux/types.h> +#include <linux/atomic.h> #include <linux/mutex.h> #include <linux/netdevice.h> #include <linux/timer.h>
@@ -32,11 +33,10 @@ struct mucse_mbx_info {u32 fwpf_ctrl_base; }; -/* Enum for firmware notification modes, -* more modes (e.g., portup, link_report) will be added in future -**/ enum { mucse_fw_powerup, + mucse_fw_portup, + mucse_fw_link_report_en, };struct mucse_hw {
@@ -45,8 +45,11 @@ struct mucse_hw {struct pci_dev *pdev;struct mucse_mbx_info mbx;int port; +int speed; +bool link;u16 cycles_per_us;u8 pfvfnum; +u8 duplex; };struct rnpgbe_tx_desc {
@@ -230,12 +233,21 @@ struct mucse {int num_rx_queues;char mbx_name[32 ];bool mbx_irq_requested; +bool link_event_ready; +bool link_pending;unsigned long state; +atomic_t mbx_irq_seq;struct work_struct mbx_work; +struct delayed_work serv_task; +/* Protects event readiness, pending state, cached link state and +* driver-side link register updates. +*/ +spinlock_t link_lock; };int rnpgbe_get_permanent_mac (struct mucse_hw *hw,u8 *perm_addr);int rnpgbe_reset_hw (struct mucse_hw *hw); +int rnpgbe_setup_default_link (struct mucse_hw *hw);int rnpgbe_send_notify (struct mucse_hw *hw,bool enable,int mode);
@@ -243,6 +255,7 @@ int rnpgbe_init_hw(struct mucse_hw *hw, int board_type);int rnpgbe_set_rx_mode (struct net_device *netdev,struct netdev_hw_addr_list *uc,struct netdev_hw_addr_list *mc); +void rnpgbe_set_link (struct mucse_hw *hw,bool linkup);/* Device IDs */ #define PCI_VENDOR_ID_MUCSE 0x8848
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_chip.c +62 -1
94 lines not on this page · raw message
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_hw.h +17 -0
@@ -23,6 +23,17 @@#define RNPGBE_DMA_TX_STATUS GENMASK_U32(23, 22)#define RNPGBE_DMA_RX_STATUS GENMASK_U32(21, 20)#define RX_AXI_RW_EN 0x03 +/* RNPGBE_LINK_ST is a driver-owned link-state snapshot consumed by firmware. +* Set the driver-state marker; all other driver status fields start clear. +*/ +#define M_DEFAULT_ST 0xa0000000 +/* Firmware never reports 0xf in the speed field. */ +#define M_INVALID_ST (M_DEFAULT_ST | GENMASK_U32(11, 8)) +/* Driver-reported fields: 25:24 pause, 11:8 speed, 6 LLDP, 4 duplex, +* and 0 link up/down. M_DEFAULT_ST resets these fields so firmware reports +* the current hardware state again. +*/ +#define RNPGBE_LINK_ST 0x000c#define RNPGBE_DMA_AXI_EN 0x0010#define RNPGBE_TX_MIN_PKT_LEN 33
@@ -41,5 +52,11 @@/* The final two of the 32 hardware RAR entries are reserved for NCSI. */ #define RNPGBE_RX_RAR_ENTRIES 30#define RNPGBE_RX_MCAST_HASH_ENTRIES 128 + +#define MUCSE_GMAC_OFF (_n) (0x20000 + (_n)) +#define GMAC_CONTROL_RE 0x00000004 +#define GMAC_CONTROL MUCSE_GMAC_OFF(0) +#define GMAC_RX_ALL (BIT(31) | BIT(0)) +#define GMAC_FRAME_FILTER MUCSE_GMAC_OFF(0x4)#define RNPGBE_MAX_QUEUES 8#endif /* _RNPGBE_HW_H */
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_lib.c +171 -1
229 lines not on this page · raw message
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_lib.h +2 -1
@@ -72,7 +72,7 @@ void rnpgbe_free_mbx_irq(struct mucse *mucse);int rnpgbe_request_irq (struct mucse *mucse);void rnpgbe_free_irq (struct mucse *mucse);void rnpgbe_down (struct mucse *mucse); -void rnpgbe_up_complete (struct mucse *mucse); +int rnpgbe_up_complete (struct mucse *mucse);int rnpgbe_configure_tx (struct mucse *mucse);int rnpgbe_configure_rx (struct mucse *mucse);void rnpgbe_clean_all_tx_rings (struct mucse *mucse);
@@ -84,4 +84,5 @@ void rnpgbe_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats);int rnpgbe_setup_all_rx_resources (struct mucse *mucse);void rnpgbe_free_all_rx_resources (struct mucse *mucse); +void rnpgbe_service_task (struct work_struct *work);#endif
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_main.c +19 -1
@@ -70,6 +70,7 @@ static int rnpgbe_open(struct net_device *netdev)if (test_bit (__MUCSE_AXI_FAULT, &mucse->state))return -EIO ; +netif_carrier_off (netdev); err =rnpgbe_request_irq (mucse);if (err)return err;
@@ -89,9 +90,16 @@ static int rnpgbe_open(struct net_device *netdev) err =rnpgbe_configure (mucse);if (err) goto err_free_rx; -rnpgbe_up_complete (mucse); + err =rnpgbe_up_complete (mucse); +if (err) + goto err_down;return 0 ; +err_down: +rnpgbe_down (mucse); +rnpgbe_free_all_rx_resources (mucse); +rnpgbe_free_all_tx_resources (mucse); + goto err_free_irqs; err_free_rx:rnpgbe_free_all_rx_resources (mucse); err_free_tx:
@@ -249,6 +257,11 @@ static int rnpgbe_add_adapter(struct pci_dev *pdev,dev_err (&pdev->dev,"Hw reset failed %d\n" , err); goto err_powerdown; } + err =rnpgbe_setup_default_link (hw); +if (err) { +dev_err (&pdev->dev,"Setup link failed %d\n" , err); + goto err_powerdown; + } err =rnpgbe_get_permanent_mac (hw, perm_addr);if (!err) {
@@ -261,6 +274,11 @@ static int rnpgbe_add_adapter(struct pci_dev *pdev, goto err_powerdown; } +INIT_DELAYED_WORK (&mucse->serv_task, rnpgbe_service_task); +spin_lock_init (&mucse->link_lock); + mucse->link_event_ready = false; + mucse->link_pending = false; + err =rnpgbe_init_interrupt_scheme (mucse);if (err) {dev_err (&pdev->dev,"init interrupt failed %d\n" , err);
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx.c +165 -2
204 lines not on this page · raw message
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx.h +4 -0
@@ -16,6 +16,10 @@int mucse_write_and_wait_ack_mbx (struct mucse_hw *hw,const __le32 *msg,u16 size); +int mucse_write_mbx_coalesce_event (struct mucse_hw *hw, +const __le32 *msg,u16 size);void mucse_init_mbx_params_pf (struct mucse_hw *hw);int mucse_poll_and_read_mbx (struct mucse_hw *hw,__le32 *msg,u16 size); +int mucse_mbx_event_begin (struct mucse_hw *hw,__le32 *msg,u16 size); +void mucse_mbx_event_end (struct mucse_hw *hw);#endif /* _RNPGBE_MBX_H */
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.c +275 -3
293 lines not on this page · raw message
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.h +59 -0
90 lines not on this page · raw message
Signature · 1 line
2.50.1
[email protected]
AI reviewRe: [PATCH net-next v16 5/5] net: rnpgbe: Add link status handling support
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you…
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] This patch adds a rule for the shared FW<->PF mailbox window:
before a PF command overwrites MUCSE_MBX_FWPF_SHM, any unacknowledged…
--
net: rnpgbe: Add link status handling support
This commit adds link status handling to the rnpgbe driver. Firmware link events arrive over the mailbox and are handled by a service task that sets the carrier state. Firmware is notified on port up/down, and probe now configures autonegotiation through a new PHY_LINK_SET command.
Quoted 4 lines
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx.c +0
-0
[ ... ]
Quoted 26 lines
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx.c +22
-0@@ -320,6 +418,44 @@ static int mucse_write_mbx_pf(struct mucse_hw *hw, const __le32 *msg, u16 size)return 0 ; } +/** +* mucse_write_mbx_pf_coalesce_event - Write around a level-like event +* @hw: pointer to the HW structure +* @msg: the message buffer +* @size: length of buffer +* +* Return: 0 on success, negative errno on failure +**/ +static int mucse_write_mbx_pf_coalesce_event (struct mucse_hw *hw, +const __le32 *msg,u16 size) +{ +const int size_in_words = size /sizeof (__le32); +struct mucse_mbx_info *mbx = &hw->mbx; +int err; + + err =mucse_obtain_mbx_lock_pf (hw); +if (err) +return err; + + err =mucse_ack_pending_event (hw); +if (err) + goto release;
[ ... ]
Quoted 4 lines
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.c +0
-0
[ ... ]
Quoted 4 lines
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.c +4
-0+int mucse_mbx_set_link (struct mucse_hw *hw,u32 advertising,bool autoneg, +u32 speed,u32 duplex,u32 mdix_ctrl) +{ +union mbx_fw_cmd_req_u req = {
[ ... ]
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.c int mucse_mbx_get_macaddr(struct mucse_hw *hw, int pfvfnum,
Quoted 6 lines
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.c +5
-0+int len, err; + + len =le16_to_cpu (req.r.datalen); +mutex_lock (&hw->mbx.lock); + err =mucse_write_and_wait_ack_mbx (hw, req.dwords, len); ^^^^
[Severity: Low]
This patch adds mucse_write_mbx_pf_coalesce_event(). It acknowledges any unacknowledged firmware event in MUCSE_MBX_FWPF_SHM before a PF command overwrites the shared window. Only SET_PHY_UP and LINK_REPORT_EN use it.
Should mucse_mbx_set_link() go through mucse_write_mbx_coalesce_event() as well? Right now it uses mucse_write_and_wait_ack_mbx()->mucse_write_mbx_pf(), which writes the window without checking fw_req. mucse_mbx_powerup() and mucse_fw_send_cmd_wait_resp() use the same plain path.
One way to reach this is remove or shutdown after an earlier mailbox failure. rnpgbe_down() treats a failed LINK_REPORT_EN(false) as non-fatal:
err = rnpgbe_send_notify(hw, false, mucse_fw_link_report_en);
if (err) {
...
dev_warn(&hw->pdev->dev, "Fw will still report link event\n");
}It then sends SET_PHY_UP(false), which can trigger a link-down event.
rnpgbe_rm_adapter() and rnpgbe_dev_shutdown() tear down the event consumer before the power-down notification:
rnpgbe_free_mbx_irq(mucse);
rnpgbe_notify_powerdown(mucse);The cancel_work_sync() in rnpgbe_free_mbx_irq() can drop a queued mbx_work. An event can also arrive after free_irq().
In both cases rnpgbe_notify_powerdown()->mucse_mbx_powerup(hw, false) writes POWER_UP(false) over that event with the plain writer, and the event is never acknowledged.
What happens depends on how firmware handles a PF request that overwrites an unacknowledged event. Could the power-down command be misparsed, or time out waiting for an ack, in that case?
The stale event also looks like it carries over to the next driver instance. mucse_mbx_reset() syncs hw->mbx.fw_req to the current counter without incrementing pf_ack. On the next ifup, mucse_ack_pending_event() then sees fw_req == hw->mbx.fw_req and skips the acknowledgment.
Quoted 4 lines
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.c +4
-0+mutex_unlock (&hw->mbx.lock); + +return err; +}
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/3B42BE25B3696EAE%2B20261013022920.63529-1-dong100%40mucse.com
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 6 lines · On Tue, 13 Oct 2026 10:29:20 +0800 you wrote:
Hi maintainers,
This patch series adds the packet transmission, reception, and link status management features to the RNPGBE driver, building upon the previously introduced mailbox communication and basic driver infrastructure.
Quoted 8 lines
The series introduces:
- MSI-X interrupt handling with NAPI support
- TX path with scatter-gather DMA and completion handling
- RX path with page pool buffer management
- Unicast/Multicast filter.
- Firmware link-event processing and carrier management[...]
Here is the summary with links:
- [net-next,v16,1/5] net: rnpgbe: Add interrupt handling
https://git.kernel.org/netdev/net-next/c/600efa8e598c - [net-next,v16,2/5] net: rnpgbe: Add basic TX packet transmission support https://git.kernel.org/netdev/net-next/c/02b5891a50c1 - [net-next,v16,3/5] net: rnpgbe: Add basic RX data path support https://git.kernel.org/netdev/net-next/c/250a6edaea49 - [net-next,v16,4/5] net: rnpgbe: Add receive mode support https://git.kernel.org/netdev/net-next/c/20c17178e192 - [net-next,v16,5/5] net: rnpgbe: Add link status handling support https://git.kernel.org/netdev/net-next/c/92a671d510a8
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html