From: James Hilliard <james.hilliard1@gmail.com>
To: netdev@vger.kernel.org,
Maxime Chevallier <maxime.chevallier@bootlin.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Chen-Yu Tsai <wens@kernel.org>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Samuel Holland <samuel@sholland.org>
Cc: Jakub Kicinski <kuba@kernel.org>,
Oleksij Rempel <o.rempel@pengutronix.de>,
linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev,
James Hilliard <james.hilliard1@gmail.com>
Subject: [PATCH net-next v2 2/3] net: stmmac: add common RXALL handling
Date: Wed, 25 Nov 2026 01:18:31 -0700 [thread overview]
Message-ID: <20261125-submit-sun8i-rxall-v1-v2-2-4de03fbde087@gmail.com> (raw)
In-Reply-To: <20261125-submit-sun8i-rxall-v1-v2-0-4de03fbde087@gmail.com>
Allow a MAC to distinguish complete frames with wire errors from
descriptors that must always be discarded. When rx-all is enabled,
deliver the former without trusting their checksum or counting them
as good packets. Keep counting the errors in either mode.
Apply the same policy to page-pool and zero-copy RX. Advertise rx-all
only when the MAC supplies the receive-mode callback; leave it off by
default.
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
drivers/net/ethernet/stmicro/stmmac/common.h | 2 +
drivers/net/ethernet/stmicro/stmmac/hwif.h | 2 +
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 52 ++++++++++++++++-------
3 files changed, 40 insertions(+), 16 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
index 706feb7bcbed..ab959ee3a5dd 100644
--- a/drivers/net/ethernet/stmicro/stmmac/common.h
+++ b/drivers/net/ethernet/stmicro/stmmac/common.h
@@ -360,6 +360,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,
};
/* Tx status */
diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h
index 9ea76de030e4..81c8ac3756a7 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);
/* 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 70157efc2255..8102a72c52c5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -5646,10 +5646,12 @@ static void stmmac_dispatch_skb_zc(struct stmmac_priv *priv, u32 queue,
skb_record_rx_queue(skb, queue);
napi_gro_receive(&ch->rxtx_napi, skb);
- u64_stats_update_begin(&rxq_stats->napi_syncp);
- u64_stats_inc(&rxq_stats->napi.rx_packets);
- u64_stats_add(&rxq_stats->napi.rx_bytes, len);
- u64_stats_update_end(&rxq_stats->napi_syncp);
+ if (likely(!(status & rx_error_frame))) {
+ u64_stats_update_begin(&rxq_stats->napi_syncp);
+ u64_stats_inc(&rxq_stats->napi.rx_packets);
+ u64_stats_add(&rxq_stats->napi.rx_bytes, len);
+ u64_stats_update_end(&rxq_stats->napi_syncp);
+ }
}
static bool stmmac_rx_refill_zc(struct stmmac_priv *priv, u32 queue, u32 budget)
@@ -5707,6 +5709,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)++;
+ return !(READ_ONCE(priv->dev->features) & NETIF_F_RXALL);
+}
+
static int stmmac_rx_zc(struct stmmac_priv *priv, int limit, u32 queue)
{
struct stmmac_rxq_stats *rxq_stats = &priv->xstats.rxq_stats[queue];
@@ -5797,11 +5814,8 @@ static int stmmac_rx_zc(struct stmmac_priv *priv, int limit, u32 queue)
status);
}
- if (unlikely(!error && (status & discard_frame))) {
- error = 1;
- if (!priv->hwts_rx_en)
- rx_errors++;
- }
+ if (!error)
+ error = stmmac_rx_discard(priv, status, &rx_errors);
if (unlikely(error)) {
xsk_buff_free(buf->xdp);
@@ -5995,11 +6009,8 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
status);
}
- if (unlikely(!error && (status & discard_frame))) {
- error = 1;
- if (!priv->hwts_rx_en)
- rx_errors++;
- }
+ if (!error)
+ error = stmmac_rx_discard(priv, status, &rx_errors);
/* We do not support SG in XDP mode */
if (unlikely(!error && (status & rx_not_ls) &&
@@ -6161,8 +6172,10 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
skb_record_rx_queue(skb, queue);
napi_gro_receive(&ch->rx_napi, skb);
- rx_packets++;
- rx_bytes += len;
+ if (likely(!(status & rx_error_frame))) {
+ rx_packets++;
+ rx_bytes += len;
+ }
next:
in_progress = false;
skb = NULL;
@@ -6462,6 +6475,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);
+
if (features & NETIF_F_HW_VLAN_CTAG_RX)
priv->hw->hw_vlan_en = true;
else
@@ -8276,6 +8294,8 @@ static int __stmmac_dvr_probe(struct device *device,
}
ndev->features |= ndev->hw_features | NETIF_F_HIGHDMA;
+ if (priv->hw->mac->set_rx_all)
+ ndev->hw_features |= NETIF_F_RXALL;
ndev->watchdog_timeo = msecs_to_jiffies(watchdog);
#ifdef STMMAC_VLAN_TAG_USED
/* Both mac100 and gmac support receive VLAN tag detection */
--
2.53.0
next prev parent reply other threads:[~2026-11-25 8:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 8:18 [PATCH net-next v2 0/3] net: stmmac: support ethtool rx-all on sun8i James Hilliard
2026-11-25 8:18 ` [PATCH net-next v2 1/3] net: stmmac: dwmac-sun8i: align EMAC_RX_MD with tabs James Hilliard
2026-11-25 8:18 ` James Hilliard [this message]
2026-11-25 8:18 ` [PATCH net-next v2 3/3] net: stmmac: dwmac-sun8i: support ethtool rx-all James Hilliard
2026-12-02 4:02 ` [PATCH net-next v2 0/3] net: stmmac: support ethtool rx-all on sun8i willemb
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=20261125-submit-sun8i-rxall-v1-v2-2-4de03fbde087@gmail.com \
--to=james.hilliard1@gmail.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--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=netdev@vger.kernel.org \
--cc=o.rempel@pengutronix.de \
--cc=pabeni@redhat.com \
--cc=samuel@sholland.org \
--cc=wens@kernel.org \
/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