net: stmmac: support ethtool rx-all on sun8i
Subsystems (5)
v2 cover net: stmmac: support ethtool rx-all on sun8i
On H616 the PHY can count a bad-FCS frame even when it does not appear in a packet capture. Enabling rx-all lets a capture see the complete errored frames the MAC can forward. On this hardware, a 64-byte frame with a bad FCS reaches DMA, but a 63-byte one does not, even with runt forwarding enabled. Both lengths include the FCS.
Add the common stmmac receive and feature-handling paths, then enable them for sun8i. This feature was previously posted alongside the checksum fix and is now separate following Maxime's review [0].
[0] https://lore.kernel.org/r/[email protected]/
---
Changes in v2:
- Drop the RX_CTL1 lock and leave DMA start, stop and mode setup unchanged.
- Align the EMAC_RX_MD definition in a separate patch, as Andrew requested.
- Apply rx-all alongside the other receive filters, independently of RX checksum reporting.
- Link to v1: https://patch.msgid.link/[email protected]
---
James Hilliard (3):
net: stmmac: dwmac-sun8i: align EMAC_RX_MD with tabs
net: stmmac: add common RXALL handling
net: stmmac: dwmac-sun8i: support ethtool rx-all
drivers/net/ethernet/stmicro/stmmac/common.h | 2 + drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 22 ++++++++-- drivers/net/ethernet/stmicro/stmmac/hwif.h | 2 + drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 52 ++++++++++++++++------- 4 files changed, 59 insertions(+), 19 deletions(-)
---
base-commit: 612848d37e68b858e15815175f1c5e609e09d719
base-tree: git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git main
change-id: 20261122-submit-sun8i-rxall-v1-2666ccf2a020
prerequisite-change-id: 20261119-submit-sun8i-rx-features-v1-9177e8328598:v3
prerequisite-patch-id: cfcd83b1605af3856aff1188ef7bdbdbfc19cce0
Best regards,
Signature · 1 line
James Hilliard <[email protected]>
PATCH v2 1/3 net: stmmac: dwmac-sun8i: align EMAC_RX_MD with tabs
Use tabs to align the receive mode bit with the receive error and threshold definitions in the same register.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c +1 -1
@@ -197,7 +197,7 @@ static const struct emac_variant emac_variant_h616_emac1 = {#define EMAC_FRM_FLT_MULTICAST BIT(16)/* Used in RX_CTL1*/ -#define EMAC_RX_MD BIT(1) +#define EMAC_RX_MD BIT(1)#define EMAC_RX_ERR_FRM BIT(3)#define EMAC_RX_TH_MASK GENMASK(5, 4)#define EMAC_RX_TH_32 0
Signature · 1 line
2.53.0
PATCH v2 2/3 net: stmmac: add common RXALL handling
In reply to James HilliardAllow a MAC to distinguish complete frames with wire errors from descriptors that must always be discarded. When rx-all is enabled, deliver the former without trusting their checksum or counting them as good packets. Keep counting the errors in either mode.
Apply the same policy to page-pool and zero-copy RX. Advertise rx-all only when the MAC supplies the receive-mode callback; leave it off by default.
--- drivers/net/ethernet/stmicro/stmmac/common.h | 2 + drivers/net/ethernet/stmicro/stmmac/hwif.h | 2 + drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 52 ++++++++++++++++------- 3 files changed, 40 insertions(+), 16 deletions(-)
drivers/net/ethernet/stmicro/stmmac/common.h +2 -0
@@ -360,6 +360,8 @@ enum rx_frame_status { llc_snap =0x4 , dma_own =0x8 , rx_not_ls =0x10 , +/* Complete frame with a wire error, deliverable only with RXALL. */ + rx_error_frame = 0x20, };/* Tx status */
drivers/net/ethernet/stmicro/stmmac/hwif.h +2 -0
@@ -354,6 +354,8 @@ struct stmmac_ops { struct mac_device_info *hw, u32 chan);/* Multicast filter setting */ void (*set_filter)(struct mac_device_info *hw,struct net_device *dev); +/* Program the MAC receive mode for NETIF_F_RXALL. */ +void (*set_rx_all)(struct stmmac_priv *priv,bool enable);/* Flow control setting */ void (*flow_ctrl)(struct mac_device_info *hw,unsigned int duplex,unsigned int fc,unsigned int pause_time,u8 tx_cnt);
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +36 -16
94 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v2 3/3 net: stmmac: dwmac-sun8i: support ethtool rx-all
In reply to James HilliardAllow packet captures to see complete frames that the sun8i MAC forwards with wire errors. Mark these frames, including runts, as errored with an unverified checksum so stmmac can deliver them when rx-all is enabled. Incomplete frames and DMA errors still require a drop.
Set runt forwarding from the rx-all setting at initialization and update that bit when the setting changes on a running interface. RX_CTL1 also controls DMA, but RTNL serializes the ethtool update with open, close and reset. System suspend freezes userspace before stopping DMA, and the sun8i interrupt handler does not change the RX threshold. The setter can therefore update the register directly. Keep error forwarding enabled in both modes for RX checksum handling.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c +18 -2
@@ -198,6 +198,7 @@ static const struct emac_variant emac_variant_h616_emac1 = {/* Used in RX_CTL1*/ #define EMAC_RX_MD BIT(1) +#define EMAC_RX_RUNT_FRM BIT(2)#define EMAC_RX_ERR_FRM BIT(3)#define EMAC_RX_TH_MASK GENMASK(5, 4)#define EMAC_RX_TH_32 0
@@ -648,7 +649,21 @@ static void sun8i_dwmac_core_init(struct mac_device_info *hw,writel (v, ioaddr +EMAC_BASIC_CTL1 );/* Forward checksum failures to software before starting RX. */ -writel (EMAC_RX_ERR_FRM , ioaddr +EMAC_RX_CTL1 ); + v =EMAC_RX_ERR_FRM ; +if (dev->features &NETIF_F_RXALL ) + v |=EMAC_RX_RUNT_FRM ; +writel (v, ioaddr +EMAC_RX_CTL1 ); +} + +static void sun8i_dwmac_set_rx_all (struct stmmac_priv *priv,bool enable) +{ +u32 v =readl (priv->ioaddr +EMAC_RX_CTL1 ); + +if (enable) + v |=EMAC_RX_RUNT_FRM ; +else + v &= ~EMAC_RX_RUNT_FRM ; +writel (v, priv->ioaddr +EMAC_RX_CTL1 ); }static void sun8i_dwmac_set_mac (void __iomem *ioaddr,bool enable)
@@ -1053,6 +1068,7 @@ static const struct stmmac_ops sun8i_dwmac_ops = { .dump_regs = sun8i_dwmac_dump_mac_regs, .rx_ipc = sun8i_dwmac_rx_ipc, .set_filter = sun8i_dwmac_set_filter, + .set_rx_all = sun8i_dwmac_set_rx_all, .flow_ctrl = sun8i_dwmac_flow_ctrl, .set_umac_addr = sun8i_dwmac_set_umac_addr, .get_umac_addr = sun8i_dwmac_get_umac_addr,
@@ -1126,7 +1142,7 @@ static int sun8i_dwmac_rx_status(struct stmmac_extra_stats *x, struct dma_desc *if (unlikely (runt || (status & wire_errors))) {if (runt && !(status &RDES0_LENGTH_ERROR )) x->rx_length++; -return discard_frame; +return rx_error_frame | csum_none; }/* Only a checked IP frame is eligible for CHECKSUM_UNNECESSARY. */
Signature · 1 line
2.53.0
Quoted 45 lines · James Hilliard
On H616 the PHY can count a bad-FCS frame even when it does not appear in a packet capture. Enabling rx-all lets a capture see the complete errored frames the MAC can forward. On this hardware, a 64-byte frame with a bad FCS reaches DMA, but a 63-byte one does not, even with runt forwarding enabled. Both lengths include the FCS.
Add the common stmmac receive and feature-handling paths, then enable them for sun8i. This feature was previously posted alongside the checksum fix and is now separate following Maxime's review [0].
[0] https://lore.kernel.org/r/[email protected]/
Assisted-by Codex:gpt-6.2-astraSigned-off-by James Hilliard <[email protected]>---
Changes in v2:
- Drop theRX_CTL1lock and leave DMA start, stop and mode setup unchanged.
- Align theEMAC_RX_MDdefinition in a separate patch, as Andrew requested.
- Apply rx-all alongside the other receive filters, independently of RX checksum reporting.
- Link to v1:
https://patch.msgid.link/[email protected]---
James Hilliard (3):
net: stmmac: dwmac-sun8i: alignEMAC_RX_MDwith tabs
net: stmmac: add common RXALL handling
net: stmmac: dwmac-sun8i: support ethtool rx-alldrivers/net/ethernet/stmicro/stmmac/common.h | 2 + drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 22 ++++++++-- drivers/net/ethernet/stmicro/stmmac/hwif.h | 2 + drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 52 ++++++++++++++++------- 4 files changed, 59 insertions(+), 19 deletions(-)---
base-commit:612848d37e68b858e15815175f1c5e609e09d719
base-tree:git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.gitmain
change-id: 20261122-submit-sun8i-rxall-v1-2666ccf2a020
prerequisite-change-id: 20261119-submit-sun8i-rx-features-v1-9177e8328598:v3
prerequisite-patch-id:cfcd83b1605af3856aff1188ef7bdbdbfc19cce0
Quoted 3 lines
Best regards,
--
James Hilliard <[email protected]>
Does not apply cleanly. Please rebase this series on current net-next and repost.
pw-bot: cr