Netdev List
 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 4/5] net: stmmac: add common RXALL handling
Date: Sat, 05 Dec 2026 02:52:59 +0000	[thread overview]
Message-ID: <179643917903.3146.16853339147522457093@kernel.org> (raw)
In-Reply-To: <20261203-submit-sun8i-rxall-v1-v4-4-af22aec6ae13@gmail.com>

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

  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
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 [this message]
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=179643917903.3146.16853339147522457093@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