Article View: linux.kernel.netdev
Article #20806Re: [PATCH net v4] net: stmmac: preserve RX checksum capability when offload is disabled
From: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 08:13
Date: Mon, 23 Nov 2026 08:13
226 lines
16766 bytes
16766 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · 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] When stmmac_set_features() fails to enable RX checksum on a
running interface, it returns -EIO before applying the split-header…
- [Medium] Toggling RX checksum offload on a running interface still
changes the IPC bit while the MAC receiver, the MTL RX FIFO and the RX…
- [Low] On a MAC that advertises RX COE but does not keep the IPC bit set
(the case the original d2afb5bdffde3 check handled), the patch retries…
--
net: stmmac: preserve RX checksum capability when offload is disabled
This commit keeps stmmac_hw_setup() from throwing away the detected RX
checksum type when the IPC bit reads back clear after a disable. The
requested state is now passed straight to the rx_ipc callbacks. After a
failed enable, a new rx_csum_failed flag masks RXCSUM in feature
negotiation until the next MAC reset, and open and resume now reconcile
features before RX starts.
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index a685ce4638f61..739c6aca447ed 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -3675,25 +3675,51 @@ static bool stmmac_tso_channel_permitted(struct stmmac_priv *priv,
> return !(priv->dma_conf.tx_queue[chan].tbs & STMMAC_TBS_AVAIL);
> }
>
> +static int stmmac_set_rx_csum(struct stmmac_priv *priv, unsigned int rx_csum)
> +{
> + int ret;
> +
> + if (!rx_csum) {
> + WRITE_ONCE(priv->hw->rx_csum, 0);
> + stmmac_rx_ipc(priv, priv->hw, false);
> + return 0;
> + }
> +
> + ret = stmmac_rx_ipc(priv, priv->hw, true);
> + if (ret <= 0) {
> + WRITE_ONCE(priv->hw->rx_csum, 0);
> + priv->rx_csum_failed = true;
> + return ret ?: -EIO;
> + }
> +
> + WRITE_ONCE(priv->hw->rx_csum, rx_csum);
[Severity: Medium]
The commit message says:
Check the result of an enable before allowing RX to mark packets
CHECKSUM_UNNECESSARY, including when the checker is first enabled on a
running interface.
When stmmac_set_features() calls this on a live interface, is RX still
running? The IPC bit changes while the MAC receiver, the MTL RX FIFO, the
RX DMA ring and NAPI all keep going.
Frames already in the RX ring or FIFO were received with IPC off. If NAPI
handles them after the WRITE_ONCE() above, could they be marked
CHECKSUM_UNNECESSARY even though the engine never checked them?
The descriptor status does not seem to show whether the engine ran:
- dwmac4_wrback_get_rx_status() sets csum_none only for
RDES1_IP_HDR_ERROR or RDES1_IP_PAYLOAD_ERROR.
- RDES1_IP_CSUM_BYPASSED only increments a counter.
- enh_desc_coe_rdes0() decodes status 0x4 as good_frame.
stmmac_rx() and stmmac_dispatch_skb_zc() then do:
if (unlikely(!coe) || !stmmac_has_ip_ethertype(skb) ||
(status & csum_none))
skb_checksum_none_assert(skb);
else
skb->ip_summed = CHECKSUM_UNNECESSARY;
The disable path has the same problem in the other direction.
stmmac_rx() reads coe once per poll:
int coe = READ_ONCE(priv->hw->rx_csum);
A poll already running on another CPU keeps the old non-zero coe for its
whole budget. Frames the MAC receives after IPC is cleared could then also
be marked CHECKSUM_UNNECESSARY.
On TYPE1 COE cores, would frames that straddle the toggle also get a
length that is off by 2 bytes? stmmac_get_rx_frame_len() strips the
appended checksum bytes based on the sampled coe, not on the IPC state
the frame was received under.
The readback shows the checker is on from this point on, but not that
frames already queued were checked. Would RX need to be quiesced around
the IPC change to close the window, for example by stopping RX DMA and
NAPI and draining or reinitialising the ring before publishing rx_csum?
> + return 0;
> +}
> +
> +/* Recheck the wanted features if this reset clears or uncovers a failure. */
> +static bool stmmac_init_rx_csum(struct net_device *dev)
> +{
> + struct stmmac_priv *priv = netdev_priv(dev);
> + bool was_failed = priv->rx_csum_failed;
> + unsigned int rx_csum;
> +
> + priv->rx_csum_failed = false;
> + rx_csum = dev->features & NETIF_F_RXCSUM ? priv->plat->rx_coe : 0;
> + if (stmmac_set_rx_csum(priv, rx_csum))
> + netdev_warn(dev, "RX IPC Checksum Offload disabled\n");
> +
> + return was_failed || priv->rx_csum_failed;
> +}
[ ... ]
> @@ -4216,6 +4244,12 @@ static int __stmmac_open(struct net_device *dev,
> netdev_err(priv->dev, "%s: Hw setup failed\n", __func__);
> return ret;
> }
> + if (stmmac_init_rx_csum(dev)) {
> + netdev_update_features(dev);
> + if (priv->rx_csum_failed)
> + netdev_update_features(dev);
> + }
> + stmmac_hw_start(dev);
[Severity: Low]
Some MACs report RX COE but do not keep the IPC bit set, which is the
case d2afb5bdffde3 handled. On those MACs, does this retry the enable on
every open and resume, and fail each time?
On the first open, stmmac_init_rx_csum() fails, sets rx_csum_failed and
warns. netdev_update_features() then masks RXCSUM out of dev->features.
On the next ifdown/ifup, or on resume, the sequence looks like this:
__stmmac_open()
stmmac_init_rx_csum()
was_failed = true
priv->rx_csum_failed = false
stmmac_set_rx_csum(priv, 0) succeeds, RXCSUM not in dev->features
returns true
netdev_update_features()
stmmac_fix_features() no longer masks RXCSUM
stmmac_set_features()
stmmac_set_rx_csum(priv, rx_coe)
rx_ipc(true) reads back 0, returns -EIO
__netdev_update_features()
netdev_err "set_features() failed (-5); wanted ..., left ..."
returns -1, so netdev_features_change() sends NETDEV_FEAT_CHANGE
netdev_update_features() masks RXCSUM again
stmmac_resume() follows the same path.
Before this patch, the capability was cleared once with a single
netdev_warn(). With this patch, every ifup and every resume would log a
netdev_err() from the core and send an extra NETDEV_FEAT_CHANGE
notification. Is that intended?
The commit message says "a reset can restore offload if it is still
wanted", but it does not mention this behavior on hardware where the
enable always fails.
[ ... ]
> @@ -6400,18 +6434,18 @@ static int stmmac_set_features(struct net_device *netdev,
> netdev_features_t features)
> {
> struct stmmac_priv *priv = netdev_priv(netdev);
> + bool running = netif_running(netdev);
> + unsigned int rx_csum;
> + int ret;
>
[ ... ]
> + rx_csum = features & NETIF_F_RXCSUM ? priv->plat->rx_coe : 0;
> + if (running && rx_csum != priv->hw->rx_csum) {
> + ret = stmmac_set_rx_csum(priv, rx_csum);
> + if (ret)
> + return ret;
> + }
[Severity: Medium]
If stmmac_set_rx_csum() fails here on a running interface, the early
return skips the split header update and the hw_vlan_en and
stmmac_set_hw_vlan_mode() changes requested in the same call. Open and
resume run a second netdev_update_features() to recover, but is there
anything like that on this path?
For example:
1. The interface is opened with RXCSUM off, so rx_csum_failed stays
false.
2. An admin runs "ethtool -K eth0 rx on rxvlan off".
3. stmmac_fix_features() does not mask RXCSUM. stmmac_set_rx_csum() fails,
sets rx_csum_failed and returns -EIO before hw_vlan_en is updated.
4. __netdev_update_features() logs the error and leaves dev->features
unchanged. VLAN stripping stays on in hardware and in dev->features,
while wanted_features asks for it to be off.
5. Repeating "ethtool -K eth0 rxvlan off" over netlink does nothing,
because ethnl_set_features() only calls __netdev_update_features() when
the requested wanted bitmap differs from the old one.
The VLAN change stays pending until an unrelated netdev_update_features()
call, a reopen or a resume.
The v3 changelog says "Keep a failed enable from blocking unrelated
feature changes", but that seems to cover only open and resume.
Should this path also run feature negotiation again, or apply the
remaining changes before it returns the error?
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261122-submit-stmmac-rx-checksum-capability-v1-v4-1-b729bef2695d%40gmail.com
Technical Details
Message-ID:
<179542163545.3135.9945110205092257108@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369140-linux-kernel-netdev=dewy.ruReferences:
<20261122-submit-stmmac-rx-checksum-capability-v1-v4-1-b729bef2695d@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369140-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v4] net: stmmac: preserve RX checksum capability when offload is disabled Date: Mon, 23 Nov 2026 08:13:55 +0000 Organization: Usenet Network Message-ID: <179542163545.3135.9945110205092257108@kernel.org> References: <20261122-submit-stmmac-rx-checksum-capability-v1-v4-1-b729bef2695d@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3823834"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:xYm0V5RpziLljcollUSMQGkrnBk= sha256:F2sLRNQBbu/6MbsMH0/LLSYanw9wvAUtheXBaJ1jOJw= sha1:h+Go/+ST30mnIZH9f8j2FwCP790= sha256:WG1C1YIXsand2nSRgeuUtIe/JMqJV1qWtx2Yjf0/5zU= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 92D99125D96; Mon, 23 Nov 2026 11:14:35 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BkPekZn7Z0Gi; Mon, 23 Nov 2026 11:14:31 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-369140-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 8FD07125D94; Mon, 23 Nov 2026 11:14:23 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 692DA2EB5A; Mon, 23 Nov 2026 08:14:02 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795421642; b=oYXjngaZmpgWxLQAz2ljykp6xRg+I6oFuMxkvvW0zeVhbhM8/7oVYd/cfAng26LMT1oY o4FX3yNcPiXpBLj2hYlYEUlBSw7JGAgkJfzXlTEd803/asUB/BJ4S07bOK+1X9YSud6/Y k9hI4IW44QfOhtF7R6tsqYBqwDk2BEbEzetb2Ld20wXY9kbLj60+heDqFrAIKrEobUIqQ e9i3C9R3ABfgLryeTWsBwYo5raajmwaNJnYZoQzccP/EblMCBURfN+2hlxTN0updowHxI 0YdHzCLypv2M6d1+GH+wV8MpyzZBI0zVBjIimQCLBmmOBNqNyW8yNT/GSpNqtr2Q60A== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795421642; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=Y1VdEYkOFsdjBJ4FhwL8M9gh2t6rskpg0TRoh1e25yA=; b=kll0i/NchMzrstVyk7BQC5MmOer9bwtja/lEV0uAjC7CuI+6szIQ6rXKo/u9agBZo5mZ 7d0k0Fxa58WDW/z9vyRAdugnjU1Okx6/5e+7cDe84rYKHn6N0zDFBclSsRSj3gaWyvQ1V XWZ9fnGrn6WwC+gH607itz22CxgOuQ4o/zLa38OPYbzOwogeikGhXTTKz5hrENasq2Wcc kMLjvuuQyqcXmk0OG15fHnAlVGATjcDg00ViaxPfIFCWfS1pL8XQvtqfh3HZQYK7mwS5P Gu5BJ5lAGFPQLrOZQJAQE63sh/CSoD0haz7poAfpBTiyicwqBXbiFEUEWQ9zg3tw9pg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZceTKAIe; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 16879606A32D; Mon, 23 Nov 2026 08:14:02 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZceTKAIe X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795421637; b=qbFcT6UP8uqBqeO92WJ4Fln76OcQ0vmxuLLB8zhSlfeaTMEsCHJh/q43tZYEJywg9na9 JkHtErb7STHJUzLTCCsgj26oGgD8f4X/wG1Xirk9sv6+d6Vu8nTs0ovSslfHIkQCaJ5l4 +lvbQH9Sqq98y7W5QfB6cy6qwadP2HMzKxfCNHbRPGdByr0sJlY143sG0IFydZNeXsbBA PgSCtzoknTlHdT7Elvew20Dv06B2yngf5vup9hD9vA8kppUJ1SW952FPQL6DGCxc03ZL6 WvS3vhgdSE4K9VcyNc4bsSBYVztQRIB6SvNafMSn7+95lImcLtdugrQYEnWI4wF8VCg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795421637; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=Y1VdEYkOFsdjBJ4FhwL8M9gh2t6rskpg0TRoh1e25yA=; b=d9RulYzDx9RfHFZ64VXlmK3jzYu80HRmeHVxNwc2pTCaYgVaaoidY8GgKJfP0FvAYkiV 7GGCbcWbtJme7ji8rnyL9alowREq01cSNm1kuX2D/H4r9HqVBw8U5cJel5wmE5a3iQ9ld BiJfa+js5Vjgx2NuLS35uqXIqbNIWp0DtROpLr7pqmmVJsFFwd7/3EokhhNnmrwrPlkGH M68Gld2T/Uw5CH3JWGDqnm9YtI+B4c28DNP2tYS9lSpI4d13i0uk2GUtbSqcwhmcsXFY1 Hr9/Q0M4EcTqviVhJtiHd6nZhgv1kSHQMKYmFxIHg9RMrSc6SAV7lx1OajWBV849mtw== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZceTKAIe; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 995CD606A31E; Mon, 23 Nov 2026 08:13:57 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE48A1F000CF; Mon, 23 Nov 2026 08:13:55 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795421636; bh=Y1VdEYkOFsdjBJ4FhwL8M9gh2t6rskpg0TRoh1e25yA=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=ZceTKAIeBcgVkkVLqhcltRBe/mvkHF0yq1cHkYA7Xr6s5K7iBpNALqzO0V/e/o8LM wjzPq6dsbfD7uPAeO8Oagu+bn6fXAGMdNvqwktcrmSgBu4FEF6YiOcv5xQl9JbHtFJ TJJhOeIWLfbGfaVc9n7aa3cBpy2cAjXRcnGNiQFhY5lv54HP44bP+lleKXhxi4Ji9W KpAIu7nevQdoaNeMmNS9UIZvQzkhgDuMeL6y5iLpFFgZHGXrnIGh8DT3m0eUr2GrQp 6/gitOqrTvz03EtIhV2yEIKHmg4ucWZEPawky2v/r9o+yzHm1SvC+04/PWSRCnhmm7 1aRX6IocvcFWQ== X-Cc: netdev@vger.kernel.org, maxime.chevallier@bootlin.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, peppe.cavallaro@st.com, wens@kernel.org, jernej.skrabec@gmail.com, samuel@sholland.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev X-In-Reply-To: <20261122-submit-stmmac-rx-checksum-capability-v1-v4-1-b729bef2695d@gmail.com> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list