Re: [PATCH net v5] net: stmmac: preserve RX checksum capability when offload is disabled
From: Maxime Chevallier
Date: Mon Nov 30 2026 - 17:37:02 EST
Hi,
On 11/25/26 10:14, James Hilliard wrote:
> Disabling RX checksum offload with ethtool and reopening the interface
> can make it impossible to enable offload again. GMAC, GMAC4 and XGMAC
> return the IPC enable bit after programming it. A clear bit is expected
> on disable, but stmmac_hw_setup() treats it as a missing capability and
> discards the detected checksum type.
>
> Keep the detected type and pass the requested setting directly to the
> MAC. Publish a nonzero checksum type only after a successful enable
> readback. If the MAC rejects an enable, mask RXCSUM in subsequent
> feature negotiation. Finish applying the other features in the same
> request and report the resulting active mask. This lets an ethtool
> request change VLAN stripping even when it cannot enable RXCSUM.
>
> On open and resume, probe a previously failed checker before starting
> reception. If it still fails, the active feature mask already reflects
> that and there is nothing to report. If its availability changes, let
> the network core reconcile the current request before starting RX.
>
> Found while investigating RX checksum offload on H616. Maxime
> Chevallier reproduced the capability loss on AgileX5, CycloneV and
> STM32MP1.
>
> In a host test with mocked XGMAC registers, a rejected enable left
> only RXCSUM unmet and repeated resets sent no feature notifications.
>
> Fixes: d2afb5bdffde ("stmmac: fix the rx csum feature")
> Signed-off-by: James Hilliard <james.hilliard1@xxxxxxxxx>
> ---
> Changes in v5:
> - Base on posted Sun8i checksum-delivery v3 and retain its always-on
> checker while adding the callback's enable argument.
> - Apply unrelated features in the same request when a live RX checksum
> enable fails; report the active mask to ethtool.
> - Recheck a previously failed checker before RX starts. Recalculate
> features only when the checker's availability changes.
> - When merging the RXALL series mentioned below, apply RXALL alongside
> VLAN stripping even if RXCSUM is refused.
> - Link to v4: https://patch.msgid.link/20261122-submit-stmmac-rx-checksum-capability-v1-v4-1-b729bef2695d@xxxxxxxxx
>
> IPC readback confirms the register state, not whether frames already in
> the FIFO or ring were checked. The live NAPI and FIFO transition is
> unchanged.
>
> Changes in v4:
> - Repeat feature negotiation after a reset-time RX checksum retry fails,
> so RXCSUM is masked before unrelated requested features are applied.
> - Link to v3: https://patch.msgid.link/20261120-submit-stmmac-rx-checksum-capability-v1-v3-1-e9e1fd85f380@xxxxxxxxx
>
> The sun8i checksum-delivery fix for net [0] renames the RX IPC callback.
> When merging, keep its new name and body, and add the bool enable
> argument from this patch. The RXALL series for net-next [1] also changes
> stmmac_set_features(); apply the RXALL setting after the RX checksum
> change succeeds.
>
> [0] https://lore.kernel.org/r/20261122-submit-sun8i-rx-features-v1-v2-1-24a2564f6edf@xxxxxxxxx/
> [1] https://lore.kernel.org/r/20261122-submit-sun8i-rxall-v1-v1-0-607789772c56@xxxxxxxxx/
>
> Changes in v3:
> - Check a live enable before reporting hardware-verified checksums;
> defer requests made while down to hardware setup.
> - Keep a failed enable from blocking unrelated feature changes and
> recheck the saved request before RX starts on open and resume.
> - Pass the requested state directly to the MAC and document the
> callback's return value.
> - Link to v2: https://patch.msgid.link/20261117-submit-stmmac-rx-checksum-capability-v1-v2-1-059f9499c386@xxxxxxxxx
I fail to see how we got there. This was a one-liner in V2.
Now there are changes in the internal API, new fields to check if a configuration
action failed before, stuff in the resume path...
You're trying too hard to please sashiko here, without looking at the quality
of the code being produced.
Frankly, V2 was fine, it fixed a real problem. After that, it goes to fixing
theoretical issues and it seems way too complicated, especially for something
that goes to net...
Sorry not I'm not confortable with that, should've said so earlier but man is
there a lot of stmmac stuff lately.
Feel free to do the more advanced reworks on net-next. I would definitely not go
with "bool rx_csum_failed". We have the rx_coe and rx_csum fields already to track
the HW caps and enable status. We write to rx_coe upon failure and it's very likely
not a good idea :
ret = stmmac_rx_ipc(priv, priv->hw);
if (!ret) {
netdev_warn(priv->dev, "RX IPC Checksum Offload disabled\n");
priv->plat->rx_coe = STMMAC_RX_COE_NONE; <<<<< We probably don't want that
priv->hw->rx_csum = 0;
}
that would be a cleaner approach to build on that ground instead of tracking if
we failed IPC config.
pw-bot: cr
Maxime