🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27217

Re: [PATCH net-next v4 1/5] net: stmmac: dwmac-sun8i: deliver RX checksum errors to the stack

#27217
From: netdev-bot+sashiko
Date: Sat, 05 Dec 2026 02:52
201 lines
16023 bytes
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] This patch carries a Fixes: tag pointing at the 2017 driver
  addition (9f93ac8d4085, "net-next: stmmac: Add dwmac-sun8i"), so…
- [Low] net: stmmac: sun8i_dwmac_rx_status() counts sub-18-byte runts as
  rx_desc

--

net: stmmac: dwmac-sun8i: deliver RX checksum errors to the stack

This patch sets EMAC_RX_ERR_FRM so the sun8i MAC forwards frames with IP
or L4 checksum errors instead of dropping them. It adds a sun8i-specific
RX status decoder that both RX paths reach through a new
mac_device_info->rx_status hook. It also keeps the hardware checksum
checker enabled whenever the receiver is on.

> Backports need commit ee0aace5f844 ("net: stmmac: Correctly handle Rx
> checksum offload errors") so the skb path honors CHECKSUM_NONE. Trees
> with the AF_XDP zero-copy receive path also need commit fcfc52fcf89a
> ("net: stmmac: honour Rx checksum errors in the AF_XDP zero-copy path").
>
> Fixes: 9f93ac8d4085 ("net-next: stmmac: Add dwmac-sun8i")

[Severity: Medium]

The Fixes: tag points at the 2017 driver addition. Could stable tooling
then pick this patch for trees that have neither ee0aace5f844 nor
fcfc52fcf89a?

The dependency is described only in prose. There is no prerequisite
line in the form stable tooling parses:

  Cc: <stable@vger.kernel.org> # <ver>: <sha>: <subject>

Also, ee0aace5f844 has no Fixes: or Cc: stable tag of its own, so it
won't be pulled in automatically.

In a tree without ee0aace5f844, stmmac_rx() still has:

	if (unlikely(!coe) || !stmmac_has_ip_ethertype(skb))
		skb_checksum_none_assert(skb);
	else
		skb->ip_summed = CHECKSUM_UNNECESSARY;

sun8i_dwmac_rx_ipc() returns 1, so coe is always set on sun8i.

With this patch, sun8i_dwmac_core_init() writes EMAC_RX_ERR_FRM to
EMAC_RX_CTL1, so the MAC forwards checksum-error frames it used to drop.
sun8i_dwmac_rx_status() returns csum_none for frames with
RDES0_IPC_CSUM_ERROR or RDES0_PAYLOAD_CSUM_ERR set, but the older
stmmac_rx() never tests that bit.

Would those frames then reach the stack marked CHECKSUM_UNNECESSARY?
That seems worse than the drop this patch fixes. The AF_XDP zero-copy
path, stmmac_dispatch_skb_zc(), has the same dependency on fcfc52fcf89a.

For comparison, the similar dwmac4 change fe4042797651 ("net: stmmac:
dwmac4: stop hardware from dropping checksum-error packets") was merged
without a Fixes: tag and stated that it depends on the error-propagation
patches.

Would it be safer to either drop the Fixes: tag, or add Cc: stable
prerequisite lines for ee0aace5f844 and fcfc52fcf89a?

[ ... ]

> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> @@ -1081,6 +1078,83 @@ static const struct stmmac_ops sun8i_dwmac_ops = {
>  	.set_mac_loopback = sun8i_dwmac_set_mac_loopback,
>  };
>  
> +static void sun8i_dwmac_rx_error_stats(struct stmmac_extra_stats *x, u32 status)
> +{
> +	if (status & RDES0_DESCRIPTOR_ERROR)
> +		x->rx_desc++;
> +	if (status & RDES0_OVERFLOW_ERROR)
> +		x->overflow_error++;
> +	if (status & RDES0_RECEIVE_WATCHDOG)
> +		x->rx_watchdog++;
> +	if (status & RDES0_SA_FILTER_FAIL)
> +		x->sa_filter_fail++;
> +	if ((status & RDES0_FRAME_TYPE) && (status & RDES0_IPC_CSUM_ERROR))
> +		x->ipc_csum_error++;
> +	if (status & RDES0_COLLISION)
> +		x->rx_collision++;
> +	if (status & RDES0_CRC_ERROR)
> +		x->rx_crc_errors++;
> +	if (status & RDES0_MII_ERROR)
> +		x->rx_mii++;
> +	if (status & RDES0_LENGTH_ERROR)
> +		x->rx_length++;
> +}
> +
> +static int sun8i_dwmac_rx_status(struct stmmac_extra_stats *x, struct dma_desc *p)
> +{
> +	const u32 csum_mask = RDES0_IPC_CSUM_ERROR | RDES0_PAYLOAD_CSUM_ERR;
> +	const u32 dma_errors = RDES0_DESCRIPTOR_ERROR | RDES0_OVERFLOW_ERROR;
> +	const u32 wire_errors = RDES0_CRC_ERROR | RDES0_MII_ERROR |
> +				RDES0_RECEIVE_WATCHDOG | RDES0_COLLISION |
> +				RDES0_LENGTH_ERROR;
> +	u32 status = le32_to_cpu(READ_ONCE(p->des0));
> +	u32 len = FIELD_GET(RDES0_FRAME_LEN_MASK, status);
> +	bool runt = len < ETH_ZLEN + ETH_FCS_LEN;
> +
> +	if (unlikely(status & RDES0_OWN))
> +		return dma_own;
> +	if (unlikely(!(status & RDES0_LAST_DESCRIPTOR)))
> +		return discard_frame | rx_not_ls;
> +	if (unlikely(!(status & RDES0_FIRST_DESCRIPTOR))) {
> +		x->rx_length++;
> +		return discard_frame;
> +	}
> +
> +#ifdef STMMAC_VLAN_TAG_USED
> +	if (status & RDES0_VLAN_TAG)
> +		x->vlan_tag++;
> +#endif
> +	if (unlikely(status & RDES0_DRIBBLING))
> +		x->dribbling_bit++;
> +	if (unlikely(status & (RDES0_ERROR_SUMMARY | wire_errors | dma_errors))) {
> +		sun8i_dwmac_rx_error_stats(x, status);
> +		if (status & dma_errors)
> +			return discard_frame;
> +		/* An unexplained error summary is not a checksum verdict. */
> +		if (!(status & wire_errors) &&
> +		    (!(status & RDES0_FRAME_TYPE) || !(status & csum_mask)))
> +			return discard_frame;
> +	}
> +
> +	/* One buffer per chain descriptor; the reported length includes FCS. */
> +	if (unlikely(len < ETH_HLEN + ETH_FCS_LEN ||
> +		     len > FIELD_GET(RDES1_BUFFER1_SIZE_MASK, le32_to_cpu(p->des1)))) {
> +		x->rx_desc++;
> +		return discard_frame;
> +	}
> +	if (unlikely(runt || (status & wire_errors))) {
> +		if (runt && !(status & RDES0_LENGTH_ERROR))
> +			x->rx_length++;
> +		return discard_frame;
> +	}
> +
> +	/* Only a checked IP frame is eligible for CHECKSUM_UNNECESSARY. */
> +	if (!(status & RDES0_FRAME_TYPE) || (status & (csum_mask | RDES0_DRIBBLING)))
> +		return csum_none;
> +
> +	return good_frame;
> +}
> +
>  static int sun8i_dwmac_setup(void *ppriv, struct mac_device_info *mac)
>  {
>  	struct stmmac_priv *priv = ppriv;

[Severity: Low]
When len is below ETH_HLEN + ETH_FCS_LEN (18 bytes), this branch
increments x->rx_desc and returns before the runt accounting just
below it. Is that the intended attribution?

Elsewhere x->rx_desc counts RDES0_DESCRIPTOR_ERROR. That holds in
sun8i_dwmac_rx_error_stats() and in the norm_desc.c and enh_desc.c
decoders. A frame that is too short is not a descriptor error.

Two kinds of frame end up here.

The first is a collision, CRC or MII error fragment shorter than 18
bytes. EMAC_RX_ERR_FRM now forwards these. Such a fragment falls
through the error block because wire_errors is set and dma_errors is
not. sun8i_dwmac_rx_error_stats() has already counted it in
rx_collision, rx_crc_errors or rx_mii, and this branch then counts it
a second time as rx_desc.

The second is a runt shorter than 18 bytes without RDES0_LENGTH_ERROR
set. It returns here and never reaches the x->rx_length++ in the next
block, while an 18..63 byte runt does reach it. stmmac_get_stats64()
reports x->rx_length as rx_length_errors. So the shortest runts are
missing from rx_length_errors and show up as descriptor errors in
ethtool -S instead.

The frame is still dropped in both cases, so only the statistics are
affected. The same code is still there at the end of the series, after
the rx-all patch enables EMAC_RX_RUNT_FRM.

Could the two conditions be split? x->rx_desc would be kept for the
len > buffer size case. The short-length case would count x->rx_length
(when RDES0_LENGTH_ERROR is not already set) and still be discarded
unconditionally.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203-submit-sun8i-rxall-v1-v4-0-af22aec6ae13%40gmail.com
Technical Details
Message-ID: <179643917558.3146.3016621462138909746@kernel.org>
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!peer04.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377800-linux-kernel-netdev=dewy.ru
References: <20261203-submit-sun8i-rxall-v1-v4-1-af22aec6ae13@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!peer04.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377800-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v4 1/5] net: stmmac: dwmac-sun8i: deliver RX checksum errors to the stack
Date: Sat, 05 Dec 2026 02:52:55 +0000
Organization: Usenet Network
Message-ID: <179643917558.3146.3016621462138909746@kernel.org>
References: <20261203-submit-sun8i-rxall-v1-v4-1-af22aec6ae13@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network; logging-data="2939018"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:pdlbA/qfj1xcF3vUWPuXGztENE0= sha256:8AMWkscV+H54IF8XZ9hmrIha+fXU/Zz3dEv9pvCeX0Y= sha1:wqDnSLgvHNOmYFdb2ss0c/YHAnY= sha256:9BZ3joKtFsZiUf2XIpN8Gh1/u297zmSLbUv8ipyWa4E=
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 C4AF7117D49; Sat,  5 Dec 2026 05:53:17 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.641
X-Spam-Status: No, score=-3.641 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.142, 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 4ix22ZTc2fTD; Sat,  5 Dec 2026 05:53:14 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-377800-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 89820117D4A; Sat,  5 Dec 2026 05:53:03 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 662BB271CA; Sat,  5 Dec 2026 02:53:01 +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=1796439178; b=E2e1kt8JVY28exca3sawfgcmxR6ABKMIltBgh0DZqxbh6BW8gkOgZGnVLvgZygV95sHV e73qVmrA03UFjAQU3D2Dl1fb/qJLwhgS2fTkMTb8NXR70D8w4KHI4i+XZNl2l5atzONUK FFkd6Ok29r9ZYTxHs/J2SjLnDxXiAz9Hugjrm765H9j3A0oLUm1YfHYl07Zx81Dg5hSWU TR0eXzRH+hxzA77VBCbRPzT1fCtvlmXkjNvYQZHizGtff6s+CHx8JEr2QZMC9RM/mckut 5EWP8WQrdhudUXcYmLVBjfmYIMEBE3onBZyEIOZXUAph69c0kL4PxlKyAFRhKNYbZUw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796439178; 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=R35AcVNmWUvi/GQi1x0KhE+oeg7cC6GP7PAi0TDfQn4=; b=oz5DAuzK8Znt1mxM/I7beOpqTHvmu9ZepnTzIB1pCeLzGqYlCs6tcnOIAhiyHM+1HOl/ IIkUfrY60dipRBKrPDXeU+7nnTCvkuSSlS2G6CqMebi5koD0CA2jE4p3ad62VdQj8FRQ0 KBixJyWwucnhd8Qd82l32s8qvWSOrwXJe0Iy7HBn5fZoFxHPafyGt68ItTF0EWjyicIB+ wr8lX2KMHwwRboDqXS7bFDRzLTIjIDR4BrbDk2lPo2MMRlpt4iGirh0vfFGOhCCX6I6Gn ja4hyTbo7uBzUMYkI5kvlumHZg+aUXZYcmsHSEhB7zQO+4FcwPtvkCz/9py7Sfdnpww==
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=lNO+V9bR; 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 6C0AD606A335; Sat,  5 Dec 2026 02:52:58 +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=lNO+V9bR
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=1796439177; b=obxiiO/ND5pSx2aiNavjYFtAk4w2OdjyRvsOcr6stato+nxXwm0ADXvTTPKhst3zbC1S nFLMU3PkoU2YHpkQVu+w4LqnetkcaGklZF9aArmlFAVMuhxhRxQDMHB0lG3YsRewmuL5+ 5lxmQQQPmh7xPd1dUJWHCMuBELwOqpV5Lr7l8gzrzsEH06Ogn9650ccXFOp6ewW6h1vzT GDjDUFOOXhv23cEDaGotiKp5oQH3UIYrq4u5QfMcDpzk0N/Wy05NhZYXBtfEvH0Fgizew bHSxcXxjR5wwv9yWtQJqsOJ92rYap1+JQeVAqCyQfyLx4tj7wSm5OBXg03rYIvI5RXA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796439177; 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=R35AcVNmWUvi/GQi1x0KhE+oeg7cC6GP7PAi0TDfQn4=; b=5IiD6iIYm9zOQhGfDotxC/J/DR6yhtmYmVAMzNGLDGyBvl2mWcvULZDauWQUCXMcP7jP aiE4lltKLTTIhiUbNLGVaoZzBC5SLPtiZv5buUddyTUZRKjJ/qCarCKHxDX9bU/mg/q3G Fm44WiVtTmoEFDd6dy1Fz1r0BalFtQQO1YyoawVnnf+zyW4wPxspqjO44Kz9PlPFqnmRv dw08QrNZRKeZZrM4yTjNjukGfDuYgVXmRxk4phym9m/1N9frxJUXI5rPunv2Oqtha3kbl MwRU/aPw2DPDa+NLZOUR5ctdrefktvuQwcEE7CgstXlWI/NNwJzLOuRg7+Inkx/aG4Q==
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=lNO+V9bR; 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 877C5606A322; Sat,  5 Dec 2026 02:52:57 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F20A1F0092B; Sat,  5 Dec 2026 02:52:56 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796439177; bh=R35AcVNmWUvi/GQi1x0KhE+oeg7cC6GP7PAi0TDfQn4=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=lNO+V9bR7lDVN4FBweAXLTwy12jfAynksxKgpRNSZPBYQbwI20BfBvK95Fjbx64v2 CXhFi8MQgYB/3NCLDPik8mlxJ1DcXT5kgZU8kEfZp+jZRGeqO8MEqetMLbcFpp5brH MjOjzeEnkgMZLAMg9UT2mhmdeZqiLCkBGpYHqiz20GbHyAD6vWFj3eZzdJBnQk1TOP 8z84kGcsWst40SakLPUL5o2LRswESyUicG2p9pGRaEpAYLpqYS4RYVlPV4J+DXZaFi aDCzuCw4upf5g6unUxzU387Xh/ImwiJR5n0yeLiBWLJDrJ372FExu3FVtg8Ome5lN8 2rfFIp7PCwc3A==
X-Cc: netdev@vger.kernel.org, maxime.chevallier@bootlin.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, pabeni@redhat.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, wens@kernel.org, jernej.skrabec@gmail.com, samuel@sholland.org, clabbe.montjoie@gmail.com, willemb@google.com, nbb@tipi-net.de, kuba@kernel.org, o.rempel@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev
X-In-Reply-To: <20261203-submit-sun8i-rxall-v1-v4-1-af22aec6ae13@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
X-Received-Bytes: 15826