Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: james.hilliard1@gmail.com
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
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	[thread overview]
Message-ID: <179643917558.3146.3016621462138909746@kernel.org> (raw)
In-Reply-To: <20261203-submit-sun8i-rxall-v1-v4-1-af22aec6ae13@gmail.com>

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


  reply	other threads:[~2026-12-05  2:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  2:37 [PATCH net-next v4 0/5] net: stmmac: support ethtool rx-all on sun8i James Hilliard
2026-12-04  2:37 ` [PATCH net-next v4 1/5] net: stmmac: dwmac-sun8i: deliver RX checksum errors to the stack James Hilliard
2026-12-05  2:52   ` netdev-bot+sashiko [this message]
2026-12-04  2:37 ` [PATCH net-next v4 2/5] net: stmmac: dwmac-sun8i: align EMAC_RX_MD with tabs James Hilliard
2026-12-04  2:37 ` [PATCH net-next v4 3/5] net: stmmac: dwmac-sun8i: serialize RX_CTL1 updates James Hilliard
2026-12-05  2:52   ` netdev-bot+sashiko
2026-12-04  2:37 ` [PATCH net-next v4 4/5] net: stmmac: add common RXALL handling James Hilliard
2026-12-05  2:52   ` netdev-bot+sashiko
2026-12-04  2:37 ` [PATCH net-next v4 5/5] net: stmmac: dwmac-sun8i: support ethtool rx-all James Hilliard
2026-12-04  2:42 ` [PATCH net-next v4 0/5] net: stmmac: support ethtool rx-all on sun8i netdev-bot+sinfo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179643917558.3146.3016621462138909746@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=clabbe.montjoie@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=james.hilliard1@gmail.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=maxime.chevallier@bootlin.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=nbb@tipi-net.de \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=pabeni@redhat.com \
    --cc=samuel@sholland.org \
    --cc=wens@kernel.org \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox