🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27218

Re: [PATCH net-next v4 4/5] net: stmmac: add common RXALL handling

#27218
From: netdev-bot+sashiko
Date: Sat, 05 Dec 2026 02:52
197 lines
16088 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] Concern: frames that stmmac_rx() and stmmac_dispatch_skb_zc()
  deliver as rx_error_frame under NETIF_F_RXALL could be marked…
- [Low] Concern: set_rx_all() is called only from stmmac_set_features()
  and only while the interface is running and present.
- [Low] Concern: the new stmmac_ops::set_rx_all() callback has no locking
  contract, and stmmac_set_features() calls it without hw->reg_lock.
- [Low] Concern: stmmac_set_features() calls set_rx_all() outside
  phylink_rx_clk_stop_block()/unblock(), so if the PHY stopped RXC in…

Pre-existing issues:
- [Medium] priv->xstats.rx_errors and priv->xstats.rx_dropped are device-
  wide counters.

--

net: stmmac: add common RXALL handling

This adds an rx_error_frame status bit. A MAC can use it to mark complete
frames with wire errors separately from descriptors that must always be
discarded. With NETIF_F_RXALL enabled, those frames are delivered on the
page-pool and zero-copy RX paths but are not counted as good packets.
NETIF_F_RXALL is advertised only when the MAC provides the new
set_rx_all() callback.

> diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
> index 08de79107c503..91025ebd1afbc 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/common.h
> +++ b/drivers/net/ethernet/stmicro/stmmac/common.h
> @@ -372,6 +372,8 @@ enum rx_frame_status {
>  	llc_snap = 0x4,
>  	dma_own = 0x8,
>  	rx_not_ls = 0x10,
> +	/* Complete frame with a wire error, deliverable only with RXALL. */
> +	rx_error_frame = 0x20,
>  };

[Severity: Low]
The commit message says these frames are delivered "without trusting
their checksum". Does anything in this patch enforce that?

The checksum test in stmmac_rx() and stmmac_dispatch_skb_zc() has not
changed, and it does not look at rx_error_frame:

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

If a frame had rx_error_frame set and csum_none clear, it would be passed
up as CHECKSUM_UNNECESSARY.

This doesn't happen anywhere in the series. The only producer is
sun8i_dwmac_rx_status(), added later in "net: stmmac: dwmac-sun8i:
support ethtool rx-all", and it returns rx_error_frame | csum_none.
sun8i also doesn't use extended descriptors, so
stmmac_rx_extended_status() never rewrites that status.

Could this comment say that producers of rx_error_frame must also set
csum_none? Alternatively, the common checksum test could treat
rx_error_frame like csum_none.

> diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h
> index 6849b58ba2f82..5f910df7f7658 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h
> +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h
> @@ -354,6 +354,8 @@ struct stmmac_ops {
>  				   struct mac_device_info *hw, u32 chan);
>  	/* Multicast filter setting */
>  	void (*set_filter)(struct mac_device_info *hw, struct net_device *dev);
> +	/* Program the MAC receive mode for NETIF_F_RXALL. */
> +	void (*set_rx_all)(struct stmmac_priv *priv, bool enable);

[Severity: Low]
What locking rule applies to set_rx_all()? stmmac_set_features() calls
it without holding hw->reg_lock. Meanwhile, set_filter() can run
read-modify-write cycles on MAC filter registers from ndo_set_rx_mode,
for example GMAC_PACKET_FILTER_RA in dwmac4_set_filter().

There is no race in the series today. sun8i_dwmac_set_rx_all(), the only
implementer, takes hw->reg_lock inside sun8i_dwmac_update_rx_ctl1().
sun8i_dwmac_set_filter() writes EMAC_RX_FRM_FLT, not EMAC_RX_CTL1.

Should this comment state that implementers must serialize against other
writers of the same register?

>  	/* Flow control setting */
>  	void (*flow_ctrl)(struct mac_device_info *hw, unsigned int duplex,
>  			  unsigned int fc, unsigned int pause_time, u8 tx_cnt);
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 99252fb836750..842d6d7f82a44 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

[ ... ]

> @@ -5713,6 +5715,21 @@ static struct stmmac_xdp_buff *xsk_buff_to_stmmac_ctx(struct xdp_buff *xdp)
>  	return (struct stmmac_xdp_buff *)xdp;
>  }
>  
> +static bool stmmac_rx_discard(struct stmmac_priv *priv, int status, u32 *rx_errors)
> +{
> +	if (likely(!(status & (discard_frame | rx_error_frame))))
> +		return false;
> +
> +	if (status & discard_frame) {
> +		if (!priv->hwts_rx_en)
> +			(*rx_errors)++;
> +		return true;
> +	}
> +
> +	(*rx_errors)++;

[Severity: Medium]
This is a pre-existing issue and was not introduced by this patch. The
local count kept here is added to device-wide counters without any
synchronization. At the end of stmmac_rx() and stmmac_rx_zc():

	priv->xstats.rx_dropped += rx_dropped;
	priv->xstats.rx_errors += rx_errors;

stmmac_dispatch_skb_zc() also does priv->xstats.rx_dropped++ directly.

These paths run in per-queue NAPI contexts, which can poll on different
CPUs at the same time. If two RX queues finish polling at once, can
increments to priv->xstats.rx_errors and priv->xstats.rx_dropped get
lost?

This patch only sends the new rx_error_frame class into the same
counter. sun8i, the only RXALL implementer, has a single RX queue by
default, so the race doesn't occur there.

> +	return !(READ_ONCE(priv->dev->features) & NETIF_F_RXALL);
> +}

[ ... ]

> @@ -6468,6 +6481,11 @@ static int stmmac_set_features(struct net_device *netdev,
>  			stmmac_enable_sph(priv, priv->ioaddr, sph_en, chan);
>  	}
>  
> +	if (((netdev->features ^ features) & NETIF_F_RXALL) &&
> +	    netif_running(netdev) && netif_device_present(netdev) &&
> +	    priv->hw->mac->set_rx_all)
> +		priv->hw->mac->set_rx_all(priv, features & NETIF_F_RXALL);

[Severity: Low]
Is set_rx_all() called again after a reset? This is its only call site,
and it is skipped while the interface is down. stmmac_hw_setup() doesn't
call it after the DMA/MAC reset on open, resume or reconfiguration.

The MAC could then filter normally while dev->features still shows
NETIF_F_RXALL. An rx-all change made while the interface was down would
also never reach the hardware.

This patch on its own has no implementer. In the later "net: stmmac:
dwmac-sun8i: support ethtool rx-all" commit, sun8i_dwmac_dma_reset()
clears EMAC_RX_CTL1. stmmac_hw_setup() then calls stmmac_core_init(),
and sun8i_dwmac_core_init() rebuilds the register from dev->features:

	if (dev->features & NETIF_F_RXALL)
		v |= EMAC_RX_RUNT_FRM;
	writel(v, ioaddr + EMAC_RX_CTL1);

That covers sun8i. Should the callback documentation say that core_init()
must restore the RXALL state from dev->features? Another option is for
stmmac_hw_setup() to call set_rx_all() itself.

[Severity: Low]
This call is made outside the phylink_rx_clk_stop_block() and
phylink_rx_clk_stop_unblock() pair used below for the VLAN registers. If
the PHY has stopped RXC in EEE LPI, could the set_rx_all() register
write be lost or stall?

This can't happen on sun8i. Its DMA ops have no get_hw_feature callback,
so dma_cap.eee stays 0. stmmac_phylink_setup() then never sets
lpi_capabilities, and phylink disables EEE on the PHY.

stmmac_rx_ipc() and stmmac_enable_sph() are also called outside the
block in this function. Would a future set_rx_all() implementer on an
EEE-capable MAC need this call moved inside the block?

>  	if (features & NETIF_F_HW_VLAN_CTAG_RX)
>  		priv->hw->hw_vlan_en = true;
>  	else

[ ... ]

-- 
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: <179643917903.3146.16853339147522457093@kernel.org>
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377802-linux-kernel-netdev=dewy.ru
References: <20261203-submit-sun8i-rxall-v1-v4-4-af22aec6ae13@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377802-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v4 4/5] net: stmmac: add common RXALL handling
Date: Sat, 05 Dec 2026 02:52:59 +0000
Organization: Usenet Network
Message-ID: <179643917903.3146.16853339147522457093@kernel.org>
References: <20261203-submit-sun8i-rxall-v1-v4-4-af22aec6ae13@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2939069"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:3M90ugyb8ZkbJuj4XOSF48SLfhU= sha256:/8syspBFU/vc7z69WmpQteieo8VjbonSeJQ2iVvK+38=
	sha1:qJ2kbmd+koz9fz+UsVud6ugvayQ= sha256:zPHSe4ST1Wqi3q4e/c9IrkqIlQ8gNtpQ2PELMhAmVDs=
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 F0122117D4A; Sat,  5 Dec 2026 05:53:23 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.541
X-Spam-Status: No, score=-3.541 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, 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 Azuqd8uW3oXG;
	Sat,  5 Dec 2026 05:53:20 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-377802-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 66B2A117D4E; Sat,  5 Dec 2026 05:53:09 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id 30B762ED7B; Sat,  5 Dec 2026 02:53:05 +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=1796439181;
	b=nNrPAqynh4MYLFrSYGHRF7r7lG9c/cl0i42AIYGkhavSS+dfpdG43tjx42FPP45eHxhT
	 qD1vd6D5MBdjI8eyJ+ndBrdlu+VtZzVD/gDfpWRW1D3gAxaR9+4oG1Y1mC4BZFHSdYorM
	 vv/TLTRl65/POxlFw8DUMWuuKpAeR1JyRGFoxRUsi3vt2ZnSaxWcc8D9wWhAB8rQGTG6c
	 BD0QC2zJzOUpYqggq2+v+ftsL3dHThIC8gIfOiwpHWaSLPTMigN4f7/rv1pfOuKMYKczF
	 3ysgRPDOfhjQ39i1ErchWlvC06j5GwtqhtMBLFtG4jZWqR7Nee8DjGMQgaAcmTpkCHQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796439181;
	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=DKRUs5kA2X8NqovZ5eQAVr9r/1ptjo9chDlRmQWshrY=;
	b=Cj2CZ0kqXmxDBt0NmqfxEs7zdWhOML8CNS6pyHwtDyEY0y4wJAuz+1QjXO8js1aIDkWL
	 a4WDvBUdNL4RUoQkva6/Tu8ILN6gOjx8fMPjgYaOVr0sxeErsi0d7E/JHnb+K1/OhhU35
	 B+kLDnexXtedsc/76S7gW4lHPJYKl5AN5f3Qs/GL9PI8kcK3BHdxu5x5n4UskmTTYsCVm
	 7XZQ521QTD3YcJu2hvuuznY7CqiLijxU/T26UZJ8WUttkSMYLpAQur287XcbtzAqBk4/d
	 5Onn0vHB+4Yfj9pwZF+NSqxxc0LAUCMyXvfyaJ4PYkX4o1yrsXhcLWZVR5GsgADONfw==
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=a7gcX9Yo;
	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 B4081606A334;
	Sat,  5 Dec 2026 02:53:01 +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=a7gcX9Yo
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=1796439180;
	b=KFIuMwPz3k0H0hpAIFr47+2J2kZAaF+sZUUCI+oG/EQpjcnVZSO/n9Apdc4Amn1arCwE
	 L0tJt29JGxeREpskn3X9DfjGvHFhDkEog5sF1fG1azZSH2I281+EurIQIF5bgEaHCrPBy
	 40K1De3iH5FsD65FsUMaGDl3/2leQ4rTdxedY4YMqdtQXbgTqwQnbFgfFKqz55i5c8FoY
	 7AgiaiA9+8M1cm6tjvuGmQ4f0Lzni3Y9l5VWb+D2YmP/1EjC3gQoYQt2jUdUYSWZOHCBw
	 8min5nDgQ35oAfQAhDt7T8/n/uJVQhIcVgR5LGxTUSHoM+jB/3t7FrOIIq5JuEfIz3g==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796439180;
	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=DKRUs5kA2X8NqovZ5eQAVr9r/1ptjo9chDlRmQWshrY=;
	b=C7mdRRobpkvtUpyrLh24juJjzCEnJ9d6I45qhZiBJmEJc91Kzvcm+mbxsuYnTypMOCDf
	 cweE5PJGY+hWrd9zIxCYv35dYVwGtcSxynh/MochkZIlA8+HdT6eLfZ2tKrlxplsymaO9
	 F0QYCcFd7nTeOela3UJ+EzVDyQBuhWIG12CWup3/qQIYcT//etTZ9AwhIEEIRuIPeVtu9
	 huwu+06skxZAeIguA7KwKlqJZx8ZAPjHdHhV03UGfFG0fs2GLRiLNp2nw+3Eg9iWZzin5
	 wSJgclx3TqtJwsHFlU7AT5Bgid1d/zOd4ghu+aPdlok61Z6PMiBiXv4W6c4WTxfgxFA==
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=a7gcX9Yo;
	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 D2E87606A339;
	Sat,  5 Dec 2026 02:53:00 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 794D01F00936;
	Sat,  5 Dec 2026 02:52:59 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796439180;
	bh=DKRUs5kA2X8NqovZ5eQAVr9r/1ptjo9chDlRmQWshrY=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=a7gcX9YopH1Eoo7bchZM8UJA2uZZN2R+RdrGBMjrQgSboAPj4U1Aj8owXxDnW/qbJ
	 hWjo/nrdqfQVPuOwcRHQv0l7aBaInbLaGG4T4UnMpZdlBdDOsPnqynHJnWfWt+uley
	 PIoyNE2j/LDcN5QlrdEJMMINGtkyOQmt9TlxrXkfPH1Pa52Gnr42SFzlu62NHPqYyE
	 fHi8yvO2t4bxkWwDeoAKa8eo80QzStOLUiTkuLONSHcwkQ+/BQELP/upAXGRtpFYeO
	 owb5U4t4DmfsmNiKNY4JxXfulJDNEhiXUhooYP4UabwpT/otrzkaoUhc1LlWeX9X/D
	 VhBzOKvLPewSA==
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-4-af22aec6ae13@gmail.com>
X-sashiko-severity: Low
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