* [PATCH net] net: stmmac: dwmac-sun8i: Honor the RX checksum offload setting
@ 2026-11-16 0:58 James Hilliard
2026-11-16 1:03 ` netdev-bot+sinfo
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: James Hilliard @ 2026-11-16 0:58 UTC (permalink / raw)
To: netdev, Maxime Chevallier, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Coquelin,
Alexandre Torgue, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
LABBE Corentin
Cc: linux-arm-kernel, linux-sunxi, linux-kernel, James Hilliard
stmmac_set_features() clears hw->rx_csum when RX checksum offload is
disabled, but sun8i_dwmac_rx_ipc_enable() unconditionally enables the
hardware checksum engine. The MAC therefore keeps dropping packets with
invalid IP or transport checksums before they reach the host, even after
ethtool reports RX checksumming as disabled.
Set or clear EMAC_RX_DO_CRC according to hw->rx_csum so that disabling
offload leaves checksum validation to the network stack. Preserve the
callback's existing success return value.
Fixes: 9f93ac8d4085 ("net-next: stmmac: Add dwmac-sun8i")
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index 2ece7ba9dd73..98cc7503bdde 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -705,7 +705,10 @@ static int sun8i_dwmac_rx_ipc_enable(struct mac_device_info *hw)
u32 v;
v = readl(ioaddr + EMAC_RX_CTL0);
- v |= EMAC_RX_DO_CRC;
+ if (hw->rx_csum)
+ v |= EMAC_RX_DO_CRC;
+ else
+ v &= ~EMAC_RX_DO_CRC;
writel(v, ioaddr + EMAC_RX_CTL0);
return 1;
---
base-commit: aa40afa831ebfe45e40a23721711059f2ac584d4
change-id: 20261115-submit-sun8i-emac-rx-checksum-v1-cf565a73c070
Best regards,
--
James Hilliard <james.hilliard1@gmail.com>
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net] net: stmmac: dwmac-sun8i: Honor the RX checksum offload setting
2026-11-16 0:58 [PATCH net] net: stmmac: dwmac-sun8i: Honor the RX checksum offload setting James Hilliard
@ 2026-11-16 1:03 ` netdev-bot+sinfo
2026-11-16 2:19 ` James Hilliard
2026-11-17 15:20 ` Maxime Chevallier
2026-11-18 4:00 ` netdev-bot+sashiko
2 siblings, 1 reply; 7+ messages in thread
From: netdev-bot+sinfo @ 2026-11-16 1:03 UTC (permalink / raw)
To: James Hilliard
Cc: netdev, Maxime Chevallier, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Coquelin,
Alexandre Torgue, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
LABBE Corentin, linux-arm-kernel, linux-sunxi, linux-kernel
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by LLM and not proven at runtime). If it was triggered
please include the symptoms, like the stack trace or kernel messages.
- What hardware the change was tested on. For driver fixes please
mention the device (and if relevant firmware version) used for
testing, or say that the change was not tested on real hardware.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net] net: stmmac: dwmac-sun8i: Honor the RX checksum offload setting
2026-11-16 1:03 ` netdev-bot+sinfo
@ 2026-11-16 2:19 ` James Hilliard
2026-11-16 2:28 ` James Hilliard
0 siblings, 1 reply; 7+ messages in thread
From: James Hilliard @ 2026-11-16 2:19 UTC (permalink / raw)
To: netdev-bot+sinfo
Cc: netdev, Maxime Chevallier, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Coquelin,
Alexandre Torgue, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
LABBE Corentin, linux-arm-kernel, linux-sunxi, linux-kernel
On Sun, Nov 15, 2026 at 6:03 PM <netdev-bot+sinfo@kernel.org> wrote:
>
> Hi!
>
> This is an automated message. This series looks like a fix, but its
> commit messages seem to be missing some information:
>
> - How the issue was discovered, e.g. hit in production, hit during
> development, syzbot report, manual code inspection, LLM or static
> analysis tool scan.
This was found while investigating RX checksum offload behavior on
H616 and reviewing the shared setup and feature-filtering paths.
>
> - Whether the issue was actually triggered, or is only theoretical
> (e.g. found by LLM and not proven at runtime). If it was triggered
> please include the symptoms, like the stack trace or kernel messages.
The capability loss was reproduced in a source-extracted test using the
actual GMAC, GMAC4 and XGMAC checksum callbacks with mocked MMIO and the
relevant setup and feature-filtering logic.
With the original code, disabling offload and following the reopen path
clears plat->rx_coe. The feature filter then prevents offload from being
enabled again. With the patch, the saved capability survives that
sequence. A requested enable that fails hardware readback still clears
the capability.
>
> - What hardware the change was tested on. For driver fixes please
> mention the device (and if relevant firmware version) used for
> testing, or say that the change was not tested on real hardware.
Tested on an Allwinner H616 board with an AC200 PHY.
>
> Please do not repost the series just to address the above. Instead,
> reply to this email with the missing information, so that reviewers
> can take it into account.
>
> *IMPORTANT*: If you do repost (for other reasons) - please include
> the relevant info in the cover letter or commit messages.
> --
> The evaluation is done by an LLM so it may be wrong, if you think
> that is the case please reply and explain.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net] net: stmmac: dwmac-sun8i: Honor the RX checksum offload setting
2026-11-16 2:19 ` James Hilliard
@ 2026-11-16 2:28 ` James Hilliard
0 siblings, 0 replies; 7+ messages in thread
From: James Hilliard @ 2026-11-16 2:28 UTC (permalink / raw)
To: netdev-bot+sinfo
Cc: netdev, Maxime Chevallier, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Coquelin,
Alexandre Torgue, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
LABBE Corentin, linux-arm-kernel, linux-sunxi, linux-kernel
On Sun, Nov 15, 2026 at 7:19 PM James Hilliard
<james.hilliard1@gmail.com> wrote:
>
> On Sun, Nov 15, 2026 at 6:03 PM <netdev-bot+sinfo@kernel.org> wrote:
> >
> > Hi!
> >
> > This is an automated message. This series looks like a fix, but its
> > commit messages seem to be missing some information:
> >
> > - How the issue was discovered, e.g. hit in production, hit during
> > development, syzbot report, manual code inspection, LLM or static
> > analysis tool scan.
>
> This was found while investigating RX checksum offload behavior on
> H616 and reviewing the shared setup and feature-filtering paths.
>
> >
> > - Whether the issue was actually triggered, or is only theoretical
> > (e.g. found by LLM and not proven at runtime). If it was triggered
> > please include the symptoms, like the stack trace or kernel messages.
>
> The capability loss was reproduced in a source-extracted test using the
> actual GMAC, GMAC4 and XGMAC checksum callbacks with mocked MMIO and the
> relevant setup and feature-filtering logic.
I mixed up the two threads. That explanation belongs to the
separate checksum-capability fix [0].
For this sun8i patch, the issue was found and reproduced during MAC/PHY
receive testing on an Allwinner H616 board with an AC200 PHY. Even after
ethtool reported RX checksumming disabled, EMAC_RX_DO_CRC remained set
and the hardware kept dropping packets with invalid IP or transport
checksums before they reached an RX descriptor.
With the fix, disabling offload cleared that bit. In steady-state tests,
those packets then reached the host and were rejected by software
checksum validation. Valid traffic continued to work, and Ethernet FCS
rejection remained active.
[0] https://lore.kernel.org/r/20261115-submit-stmmac-rx-checksum-capability-v1-v1-1-ea26fa3689be@gmail.com/
>
> With the original code, disabling offload and following the reopen path
> clears plat->rx_coe. The feature filter then prevents offload from being
> enabled again. With the patch, the saved capability survives that
> sequence. A requested enable that fails hardware readback still clears
> the capability.
>
> >
> > - What hardware the change was tested on. For driver fixes please
> > mention the device (and if relevant firmware version) used for
> > testing, or say that the change was not tested on real hardware.
>
> Tested on an Allwinner H616 board with an AC200 PHY.
>
> >
> > Please do not repost the series just to address the above. Instead,
> > reply to this email with the missing information, so that reviewers
> > can take it into account.
> >
> > *IMPORTANT*: If you do repost (for other reasons) - please include
> > the relevant info in the cover letter or commit messages.
> > --
> > The evaluation is done by an LLM so it may be wrong, if you think
> > that is the case please reply and explain.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net] net: stmmac: dwmac-sun8i: Honor the RX checksum offload setting
2026-11-16 0:58 [PATCH net] net: stmmac: dwmac-sun8i: Honor the RX checksum offload setting James Hilliard
2026-11-16 1:03 ` netdev-bot+sinfo
@ 2026-11-17 15:20 ` Maxime Chevallier
2026-11-17 15:26 ` Lorenzo Bianconi
2026-11-18 4:00 ` netdev-bot+sashiko
2 siblings, 1 reply; 7+ messages in thread
From: Maxime Chevallier @ 2026-11-17 15:20 UTC (permalink / raw)
To: James Hilliard, netdev, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Coquelin,
Alexandre Torgue, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
LABBE Corentin
Cc: linux-arm-kernel, linux-sunxi, linux-kernel
Hi,
On 11/16/26 01:58, James Hilliard wrote:
> stmmac_set_features() clears hw->rx_csum when RX checksum offload is
> disabled, but sun8i_dwmac_rx_ipc_enable() unconditionally enables the
> hardware checksum engine. The MAC therefore keeps dropping packets with
> invalid IP or transport checksums before they reach the host, even after
> ethtool reports RX checksumming as disabled.
>
> Set or clear EMAC_RX_DO_CRC according to hw->rx_csum so that disabling
> offload leaves checksum validation to the network stack. Preserve the
> callback's existing success return value.
>
> Fixes: 9f93ac8d4085 ("net-next: stmmac: Add dwmac-sun8i")
> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
Nice and simple, I tested that on an orangepi zero, with an allwinner
H2+, and I can indeed see the difference as bad chksum packets are
dropped on that core.
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Tested-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Maxime
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net] net: stmmac: dwmac-sun8i: Honor the RX checksum offload setting
2026-11-17 15:20 ` Maxime Chevallier
@ 2026-11-17 15:26 ` Lorenzo Bianconi
0 siblings, 0 replies; 7+ messages in thread
From: Lorenzo Bianconi @ 2026-11-17 15:26 UTC (permalink / raw)
To: Maxime Chevallier
Cc: James Hilliard, netdev, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Coquelin,
Alexandre Torgue, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
LABBE Corentin, linux-arm-kernel, linux-sunxi, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1144 bytes --]
> Hi,
>
> On 11/16/26 01:58, James Hilliard wrote:
> > stmmac_set_features() clears hw->rx_csum when RX checksum offload is
> > disabled, but sun8i_dwmac_rx_ipc_enable() unconditionally enables the
> > hardware checksum engine. The MAC therefore keeps dropping packets with
> > invalid IP or transport checksums before they reach the host, even after
> > ethtool reports RX checksumming as disabled.
> >
> > Set or clear EMAC_RX_DO_CRC according to hw->rx_csum so that disabling
> > offload leaves checksum validation to the network stack. Preserve the
> > callback's existing success return value.
> >
> > Fixes: 9f93ac8d4085 ("net-next: stmmac: Add dwmac-sun8i")
> > Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
>
> Nice and simple, I tested that on an orangepi zero, with an allwinner
> H2+, and I can indeed see the difference as bad chksum packets are
> dropped on that core.
>
> Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
> Tested-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Reviewed-by: Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>
>
> Maxime
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net] net: stmmac: dwmac-sun8i: Honor the RX checksum offload setting
2026-11-16 0:58 [PATCH net] net: stmmac: dwmac-sun8i: Honor the RX checksum offload setting James Hilliard
2026-11-16 1:03 ` netdev-bot+sinfo
2026-11-17 15:20 ` Maxime Chevallier
@ 2026-11-18 4:00 ` netdev-bot+sashiko
2 siblings, 0 replies; 7+ messages in thread
From: netdev-bot+sashiko @ 2026-11-18 4:00 UTC (permalink / raw)
To: james.hilliard1
Cc: netdev, maxime.chevallier, andrew+netdev, davem, edumazet, kuba,
pabeni, mcoquelin.stm32, alexandre.torgue, wens, jernej.skrabec,
samuel, clabbe.montjoie, linux-arm-kernel, linux-sunxi,
linux-kernel
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
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] Clearing EMAC_RX_DO_CRC (EMAC_RX_CTL0 bit 27) whenever
NETIF_F_RXCSUM is off may also turn off the MAC's Ethernet FCS…
- [Low] When RX checksum offload is turned back on, frames the sun8i MAC
received while EMAC_RX_DO_CRC was clear can be marked…
--
net: stmmac: dwmac-sun8i: Honor the RX checksum offload setting
Before this patch, sun8i_dwmac_rx_ipc_enable() always set
EMAC_RX_DO_CRC. With the patch, it sets or clears the bit based on
hw->rx_csum, so that turning off RX checksum offload through ethtool
also turns off the hardware checksum engine.
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> index 2ece7ba9dd73b..98cc7503bddeb 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> @@ -705,7 +705,10 @@ static int sun8i_dwmac_rx_ipc_enable(struct mac_device_info *hw)
> u32 v;
>
> v = readl(ioaddr + EMAC_RX_CTL0);
> - v |= EMAC_RX_DO_CRC;
> + if (hw->rx_csum)
> + v |= EMAC_RX_DO_CRC;
> + else
> + v &= ~EMAC_RX_DO_CRC;
[Severity: Medium]
Does clearing bit 27 of EMAC_RX_CTL0 also turn off the MAC's Ethernet
FCS check, and not only the IP/L4 checksum engine?
The bit is named after the CRC:
#define EMAC_RX_DO_CRC BIT(27)
The probe code says the hardware features were "copied from Allwinner
drivers". That code sets this bit with the comment "Enable CRC & IPv4
Header Checksum". The Allwinner manuals describe CHECK_CRC as "Calculate
CRC and check the IPv4 Header Checksum".
On this path, sun8i does not have the hardware strip the FCS.
stmmac_rx() removes it in software without checking it:
/* ACS is disabled; strip manually. */
if (likely(!(status & rx_not_ls)))
len -= ETH_FCS_LEN;
The only FCS check left is the hardware RDES0_CRC_ERROR bit, which
ndesc_get_rx_status() turns into discard_frame.
Suppose bit 27 does control CRC calculation. After "ethtool -K ethX rx
off", the path is stmmac_set_features() -> hw->rx_csum = 0 ->
sun8i_dwmac_rx_ipc_enable(). Frames with a corrupted FCS would then no
longer set RDES0_CRC_ERROR. They would reach the stack as good frames,
with the FCS silently stripped. That behaves like NETIF_F_RXALL rather
than "RX checksum offload off".
Is there a datasheet reference or a bad-FCS test showing that bit 27
gates only the L3/L4 checksum? If the hardware ties the two checks
together, a different approach may be needed. For example, keep bit 27
set and, when rx_csum is 0, stop discarding frames whose only error is
the IP or payload checksum.
[Severity: Low]
Can frames that arrive while EMAC_RX_DO_CRC is clear be marked as
checksum-verified once RX checksum offload is turned back on?
When "ethtool -K ethX rx on" runs, stmmac_set_features() publishes the
software flag before the MMIO write that re-enables the engine:
stmmac_set_features() {
...
if (features & NETIF_F_RXCSUM)
priv->hw->rx_csum = priv->plat->rx_coe;
else
priv->hw->rx_csum = 0;
...
stmmac_rx_ipc(priv, priv->hw);
...
}
NAPI is not disabled, RX DMA is not stopped and the ring is not drained.
Meanwhile, stmmac_rx() may run on another CPU and read the flag
directly:
int coe = priv->hw->rx_csum;
...
if (unlikely(!coe) || !stmmac_has_ip_ethertype(skb) ||
(status & csum_none))
skb_checksum_none_assert(skb);
else
skb->ip_summed = CHECKSUM_UNNECESSARY;
sun8i uses normal descriptors. ndesc_get_rx_status() never returns
csum_none, so nothing in the descriptor says whether the hardware
actually checked a given frame.
Any unchecked frame still in the RX ring would then be passed up as
CHECKSUM_UNNECESSARY. That covers frames received before the writel()
in sun8i_dwmac_rx_ipc_enable() and frames received just after it.
Before this patch, the bit was never cleared, so this state could not
happen on sun8i.
Swapping the two writes would narrow the window, but it would not cover
frames already in the ring. Would RX need to be quiesced or drained
across this transition?
> writel(v, ioaddr + EMAC_RX_CTL0);
>
> return 1;
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261115-submit-sun8i-emac-rx-checksum-v1-v1-1-f186d127b39f%40gmail.com
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-18 4:00 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-16 0:58 [PATCH net] net: stmmac: dwmac-sun8i: Honor the RX checksum offload setting James Hilliard
2026-11-16 1:03 ` netdev-bot+sinfo
2026-11-16 2:19 ` James Hilliard
2026-11-16 2:28 ` James Hilliard
2026-11-17 15:20 ` Maxime Chevallier
2026-11-17 15:26 ` Lorenzo Bianconi
2026-11-18 4:00 ` netdev-bot+sashiko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox