* [PATCH net-next v1 0/3] stmmac: stop silently dropping bad checksum packets
@ 2025-08-18 9:02 Oleksij Rempel
2025-08-18 9:02 ` [PATCH net-next v1 1/3] net: stmmac: Correctly handle Rx checksum offload errors Oleksij Rempel
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Oleksij Rempel @ 2025-08-18 9:02 UTC (permalink / raw)
To: Andrew Lunn, Alexandre Torgue, Jose Abreu, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Coquelin
Cc: Oleksij Rempel, kernel, linux-kernel, netdev, Simon Horman,
Russell King (Oracle), Søren Andersen
Hi all,
this series reworks how stmmac handles receive checksum offload
(CoE) errors on dwmac4.
At present, when CoE is enabled, the hardware silently discards any
frame that fails checksum validation. These packets never reach the
driver and are not accounted in the generic drop statistics. They are
only visible in the stmmac-specific counters as "payload error" or
"header error" packets, which makes it harder to debug or monitor
network issues.
Following discussion [1], the driver is reworked to propagate checksum
error information up to the stack. With these changes, CoE stays
enabled, but frames that fail hardware validation are no longer dropped
in hardware. Instead, the driver marks them with CHECKSUM_NONE so the
network stack can validate, drop, and properly account them in the
standard drop statistics.
[1] https://lore.kernel.org/all/20250625132117.1b3264e8@kernel.org/
Oleksij Rempel (3):
net: stmmac: Correctly handle Rx checksum offload errors
net: stmmac: dwmac4: report Rx checksum errors in status
net: stmmac: dwmac4: stop hardware from dropping checksum-error
packets
drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 1 +
drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c | 8 ++++++--
drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c | 2 ++
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 3 ++-
4 files changed, 11 insertions(+), 3 deletions(-)
--
2.39.5
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next v1 1/3] net: stmmac: Correctly handle Rx checksum offload errors
2025-08-18 9:02 [PATCH net-next v1 0/3] stmmac: stop silently dropping bad checksum packets Oleksij Rempel
@ 2025-08-18 9:02 ` Oleksij Rempel
2025-08-18 9:02 ` [PATCH net-next v1 2/3] net: stmmac: dwmac4: report Rx checksum errors in status Oleksij Rempel
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Oleksij Rempel @ 2025-08-18 9:02 UTC (permalink / raw)
To: Andrew Lunn, Alexandre Torgue, Jose Abreu, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Coquelin
Cc: Oleksij Rempel, kernel, linux-kernel, netdev, Simon Horman,
Russell King (Oracle), Søren Andersen
The stmmac_rx function would previously set skb->ip_summed to
CHECKSUM_UNNECESSARY if hardware checksum offload (CoE) was enabled
and the packet was of a known IP ethertype.
However, this logic failed to check if the hardware had actually
reported a checksum error. The hardware status, indicating a header or
payload checksum failure, was being ignored at this stage. This could
cause corrupt packets to be passed up the network stack as valid.
This patch corrects the logic by checking the `csum_none` status flag,
which is set when the hardware reports a checksum error. If this flag
is set, skb->ip_summed is now correctly set to CHECKSUM_NONE,
ensuring the kernel's network stack will perform its own validation and
properly handle the corrupt packet.
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 9a77390b7f9d..75d8d8042316 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -5733,7 +5733,8 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
skb->protocol = eth_type_trans(skb, priv->dev);
- if (unlikely(!coe) || !stmmac_has_ip_ethertype(skb))
+ if (unlikely(!coe) || !stmmac_has_ip_ethertype(skb) ||
+ (status & csum_none))
skb_checksum_none_assert(skb);
else
skb->ip_summed = CHECKSUM_UNNECESSARY;
--
2.39.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next v1 2/3] net: stmmac: dwmac4: report Rx checksum errors in status
2025-08-18 9:02 [PATCH net-next v1 0/3] stmmac: stop silently dropping bad checksum packets Oleksij Rempel
2025-08-18 9:02 ` [PATCH net-next v1 1/3] net: stmmac: Correctly handle Rx checksum offload errors Oleksij Rempel
@ 2025-08-18 9:02 ` Oleksij Rempel
2025-08-18 9:02 ` [PATCH net-next v1 3/3] net: stmmac: dwmac4: stop hardware from dropping checksum-error packets Oleksij Rempel
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Oleksij Rempel @ 2025-08-18 9:02 UTC (permalink / raw)
To: Andrew Lunn, Alexandre Torgue, Jose Abreu, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Coquelin
Cc: Oleksij Rempel, kernel, linux-kernel, netdev, Simon Horman,
Russell King (Oracle), Søren Andersen
Propagate hardware checksum failures from the descriptor parser to the
caller.
Currently, dwmac4_wrback_get_rx_status() updates stats when the Rx
descriptor signals an IP header or payload checksum error, but it does
not reflect this in its return value. The higher-level stmmac_rx() code
therefore cannot tell that hardware checksum validation failed.
Set the csum_none flag in the returned status when either
RDES1_IP_HDR_ERROR or RDES1_IP_PAYLOAD_ERROR is present. This aligns
dwmac4 with enh_desc_coe_rdes0() and lets stmmac_rx() mark the skb as
CHECKSUM_NONE for software verification.
This is a preparatory step for disabling the hardware filter that drops
frames which do not pass checksum validation.
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
index a5fb31eb0192..aac68dc28dc1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
@@ -110,16 +110,20 @@ static int dwmac4_wrback_get_rx_status(struct stmmac_extra_stats *x,
message_type = (rdes1 & ERDES4_MSG_TYPE_MASK) >> 8;
- if (rdes1 & RDES1_IP_HDR_ERROR)
+ if (rdes1 & RDES1_IP_HDR_ERROR) {
x->ip_hdr_err++;
+ ret |= csum_none;
+ }
if (rdes1 & RDES1_IP_CSUM_BYPASSED)
x->ip_csum_bypassed++;
if (rdes1 & RDES1_IPV4_HEADER)
x->ipv4_pkt_rcvd++;
if (rdes1 & RDES1_IPV6_HEADER)
x->ipv6_pkt_rcvd++;
- if (rdes1 & RDES1_IP_PAYLOAD_ERROR)
+ if (rdes1 & RDES1_IP_PAYLOAD_ERROR) {
x->ip_payload_err++;
+ ret |= csum_none;
+ }
if (message_type == RDES_EXT_NO_PTP)
x->no_ptp_rx_msg_type_ext++;
--
2.39.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next v1 3/3] net: stmmac: dwmac4: stop hardware from dropping checksum-error packets
2025-08-18 9:02 [PATCH net-next v1 0/3] stmmac: stop silently dropping bad checksum packets Oleksij Rempel
2025-08-18 9:02 ` [PATCH net-next v1 1/3] net: stmmac: Correctly handle Rx checksum offload errors Oleksij Rempel
2025-08-18 9:02 ` [PATCH net-next v1 2/3] net: stmmac: dwmac4: report Rx checksum errors in status Oleksij Rempel
@ 2025-08-18 9:02 ` Oleksij Rempel
2025-08-20 3:11 ` [PATCH net-next v1 0/3] stmmac: stop silently dropping bad checksum packets patchwork-bot+netdevbpf
2025-08-20 7:07 ` Russell King (Oracle)
4 siblings, 0 replies; 6+ messages in thread
From: Oleksij Rempel @ 2025-08-18 9:02 UTC (permalink / raw)
To: Andrew Lunn, Alexandre Torgue, Jose Abreu, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Coquelin
Cc: Oleksij Rempel, kernel, linux-kernel, netdev, Simon Horman,
Russell King (Oracle), Søren Andersen
Tell the MAC not to discard frames that fail TCP/IP checksum
validation.
By default, when the hardware checksum engine (CoE) is enabled,
dwmac4 silently drops any packet where the offload engine detects
a checksum error. These frames are not reported to the driver and
are not counted in any statistics as dropped packets.
Set the MTL_OP_MODE_DIS_TCP_EF bit when initializing the Rx channel so
that all packets are delivered, even if they failed hardware checksum
validation. CoE remains enabled, but instead of dropping such frames,
the driver propagates the error status and marks the skb with
CHECKSUM_NONE. This allows the stack to verify and drop the packet
while updating statistics.
This change follows the decision made in the discussion:
Link: https://lore.kernel.org/all/20250625132117.1b3264e8@kernel.org/
It depends on the previous patches that added proper error propagation
in the Rx path.
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 1 +
drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c | 2 ++
2 files changed, 3 insertions(+)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
index f4694fd576f5..3dec1a264cf6 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
@@ -341,6 +341,7 @@ static inline u32 mtl_chanx_base_addr(const struct dwmac4_addrs *addrs,
#define MTL_OP_MODE_RFA_SHIFT 8
#define MTL_OP_MODE_EHFC BIT(7)
+#define MTL_OP_MODE_DIS_TCP_EF BIT(6)
#define MTL_OP_MODE_RTC_MASK GENMASK(1, 0)
#define MTL_OP_MODE_RTC_SHIFT 0
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
index 0cb84a0041a4..d87a8b595e6a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
@@ -268,6 +268,8 @@ static void dwmac4_dma_rx_chan_op_mode(struct stmmac_priv *priv,
mtl_rx_op = readl(ioaddr + MTL_CHAN_RX_OP_MODE(dwmac4_addrs, channel));
+ mtl_rx_op |= MTL_OP_MODE_DIS_TCP_EF;
+
if (mode == SF_DMA_MODE) {
pr_debug("GMAC: enable RX store and forward mode\n");
mtl_rx_op |= MTL_OP_MODE_RSF;
--
2.39.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next v1 0/3] stmmac: stop silently dropping bad checksum packets
2025-08-18 9:02 [PATCH net-next v1 0/3] stmmac: stop silently dropping bad checksum packets Oleksij Rempel
` (2 preceding siblings ...)
2025-08-18 9:02 ` [PATCH net-next v1 3/3] net: stmmac: dwmac4: stop hardware from dropping checksum-error packets Oleksij Rempel
@ 2025-08-20 3:11 ` patchwork-bot+netdevbpf
2025-08-20 7:07 ` Russell King (Oracle)
4 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-08-20 3:11 UTC (permalink / raw)
To: Oleksij Rempel
Cc: andrew+netdev, alexandre.torgue, joabreu, davem, edumazet, kuba,
pabeni, mcoquelin.stm32, kernel, linux-kernel, netdev, horms,
rmk+kernel, san
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 18 Aug 2025 11:02:14 +0200 you wrote:
> Hi all,
>
> this series reworks how stmmac handles receive checksum offload
> (CoE) errors on dwmac4.
>
> At present, when CoE is enabled, the hardware silently discards any
> frame that fails checksum validation. These packets never reach the
> driver and are not accounted in the generic drop statistics. They are
> only visible in the stmmac-specific counters as "payload error" or
> "header error" packets, which makes it harder to debug or monitor
> network issues.
>
> [...]
Here is the summary with links:
- [net-next,v1,1/3] net: stmmac: Correctly handle Rx checksum offload errors
https://git.kernel.org/netdev/net-next/c/ee0aace5f844
- [net-next,v1,2/3] net: stmmac: dwmac4: report Rx checksum errors in status
https://git.kernel.org/netdev/net-next/c/644b8437ccef
- [net-next,v1,3/3] net: stmmac: dwmac4: stop hardware from dropping checksum-error packets
https://git.kernel.org/netdev/net-next/c/fe4042797651
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next v1 0/3] stmmac: stop silently dropping bad checksum packets
2025-08-18 9:02 [PATCH net-next v1 0/3] stmmac: stop silently dropping bad checksum packets Oleksij Rempel
` (3 preceding siblings ...)
2025-08-20 3:11 ` [PATCH net-next v1 0/3] stmmac: stop silently dropping bad checksum packets patchwork-bot+netdevbpf
@ 2025-08-20 7:07 ` Russell King (Oracle)
4 siblings, 0 replies; 6+ messages in thread
From: Russell King (Oracle) @ 2025-08-20 7:07 UTC (permalink / raw)
To: Oleksij Rempel
Cc: Andrew Lunn, Alexandre Torgue, Jose Abreu, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Coquelin,
kernel, linux-kernel, netdev, Simon Horman, Søren Andersen
On Mon, Aug 18, 2025 at 11:02:14AM +0200, Oleksij Rempel wrote:
> Hi all,
>
> this series reworks how stmmac handles receive checksum offload
> (CoE) errors on dwmac4.
>
> At present, when CoE is enabled, the hardware silently discards any
> frame that fails checksum validation. These packets never reach the
> driver and are not accounted in the generic drop statistics. They are
> only visible in the stmmac-specific counters as "payload error" or
> "header error" packets, which makes it harder to debug or monitor
> network issues.
FYI, there are counters at 0x214 and 0x228 that indicate header
problems, including checksum failures. There are also counters
at 0x234, 0x23c, 0x244 that count udp, tcp and icmp checksum
errors.
So, the hardware does keep statistics. Maybe we should make use
of those rather than the approach in this series?
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-08-20 7:07 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-18 9:02 [PATCH net-next v1 0/3] stmmac: stop silently dropping bad checksum packets Oleksij Rempel
2025-08-18 9:02 ` [PATCH net-next v1 1/3] net: stmmac: Correctly handle Rx checksum offload errors Oleksij Rempel
2025-08-18 9:02 ` [PATCH net-next v1 2/3] net: stmmac: dwmac4: report Rx checksum errors in status Oleksij Rempel
2025-08-18 9:02 ` [PATCH net-next v1 3/3] net: stmmac: dwmac4: stop hardware from dropping checksum-error packets Oleksij Rempel
2025-08-20 3:11 ` [PATCH net-next v1 0/3] stmmac: stop silently dropping bad checksum packets patchwork-bot+netdevbpf
2025-08-20 7:07 ` Russell King (Oracle)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).