Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] net: stmmac: handle RX checksum and wire errors on sun8i
@ 2026-11-20 15:32 James Hilliard
  2026-11-20 15:32 ` [PATCH net-next 1/2] net: stmmac: dwmac-sun8i: deliver RX checksum errors to the stack James Hilliard
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: James Hilliard @ 2026-11-20 15:32 UTC (permalink / raw)
  To: netdev, Maxime Chevallier, Andrew Lunn, David S. Miller,
	Eric Dumazet, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
	Ong Boon Leong, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
	LABBE Corentin
  Cc: Jakub Kicinski, Oleksij Rempel, linux-arm-kernel, linux-sunxi,
	James Hilliard

The sun8i MAC has one DMA forwarding control for both IP checksum
failures and Ethernet errors. With forwarding disabled, packet sockets
cannot see bad transport checksums, and the stack cannot apply its own
checksum policy. Toggling the hardware checker instead leaves no way
to tell whether a queued IP frame was actually checked.

Jakub asked how the proposed bit-27 change [0] fits into the complete
fix [1]. This series replaces that change: the checker stays on whenever
the receiver is running. Both ethtool modes deliver checksum failures for
software validation; only with rx on can the driver mark a checked
packet as verified. Changing modes no longer needs a ring flush.

The first patch fixes ordinary reception while still dropping frames
with a bad FCS. The second adds rx-all support for capturing complete
frames with wire errors and runts that the MAC can forward.
On H616, a bad-FCS 64-byte frame reaches DMA, but a bad-FCS 63-byte
frame does not, even with both forwarding controls enabled.

[0] https://lore.kernel.org/r/20261115-submit-sun8i-emac-rx-checksum-v1-v1-1-f186d127b39f@gmail.com/
[1] https://lore.kernel.org/r/20261119161151.5251fc86@kernel.org/

Assisted-by: Codex:gpt-6-astra
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
James Hilliard (2):
      net: stmmac: dwmac-sun8i: deliver RX checksum errors to the stack
      net: stmmac: dwmac-sun8i: support ethtool rx-all

 drivers/net/ethernet/stmicro/stmmac/common.h      |   4 +
 drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 167 ++++++++++++++++------
 drivers/net/ethernet/stmicro/stmmac/hwif.h        |   3 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |  59 +++++---
 4 files changed, 172 insertions(+), 61 deletions(-)
---
base-commit: 2208ab00f4f213ade91ab775e7f8c4dacdcc856e
base-tree: git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git main
change-id: 20261119-submit-sun8i-rx-features-v1-9177e8328598

Best regards,
--  
James Hilliard <james.hilliard1@gmail.com>



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH net-next 1/2] net: stmmac: dwmac-sun8i: deliver RX checksum errors to the stack
  2026-11-20 15:32 [PATCH net-next 0/2] net: stmmac: handle RX checksum and wire errors on sun8i James Hilliard
@ 2026-11-20 15:32 ` James Hilliard
  2026-11-24 15:47   ` netdev-bot+sashiko
  2026-11-20 15:32 ` [PATCH net-next 2/2] net: stmmac: dwmac-sun8i: support ethtool rx-all James Hilliard
  2026-11-20 15:37 ` [PATCH net-next 0/2] net: stmmac: handle RX checksum and wire errors on sun8i netdev-bot+sinfo
  2 siblings, 1 reply; 9+ messages in thread
From: James Hilliard @ 2026-11-20 15:32 UTC (permalink / raw)
  To: netdev, Maxime Chevallier, Andrew Lunn, David S. Miller,
	Eric Dumazet, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
	Ong Boon Leong, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
	LABBE Corentin
  Cc: Jakub Kicinski, Oleksij Rempel, linux-arm-kernel, linux-sunxi,
	James Hilliard

The sun8i MAC drops packets with a bad IP or transport checksum before
packet sockets or the protocol stack can see them, even with RX checksum
offload disabled. Its error-forwarding bit controls Ethernet and IP
errors together.

Enable error forwarding and decode the sun8i RX status in both receive
paths. Give checksum failures and unchecked packets to the stack with
CHECKSUM_NONE. Continue to discard Ethernet errors, incomplete frames
and lengths that cannot fit in the receive buffer. Address filter and
VLAN indications are not checksum errors.

Keep the hardware checker running whenever the receiver is enabled.
Turning RX checksum reporting back on can then use the result already
recorded in queued descriptors without flushing the ring.

Fixes: 9f93ac8d4085 ("net-next: stmmac: Add dwmac-sun8i")
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
 drivers/net/ethernet/stmicro/stmmac/common.h      |  2 +
 drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 98 ++++++++++++++++++++---
 drivers/net/ethernet/stmicro/stmmac/hwif.h        |  2 -
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |  7 +-
 4 files changed, 94 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
index a972bee66504..706feb7bcbed 100644
--- a/drivers/net/ethernet/stmicro/stmmac/common.h
+++ b/drivers/net/ethernet/stmicro/stmmac/common.h
@@ -615,6 +615,8 @@ struct mii_regs {
 struct mac_device_info {
 	const struct stmmac_ops *mac;
 	const struct stmmac_desc_ops *desc;
+	/* Defaults to the descriptor format's decoder unless the MAC overrides it. */
+	int (*rx_status)(struct stmmac_extra_stats *x, struct dma_desc *p);
 	const struct stmmac_dma_ops *dma;
 	const struct stmmac_mode_ops *mode;
 	const struct stmmac_hwtimestamp *ptp;
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index 2ece7ba9dd73..0ad2203f76c3 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -5,6 +5,7 @@
  * Copyright (C) 2017 Corentin Labbe <clabbe.montjoie@gmail.com>
  */
 
+#include <linux/bitfield.h>
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/iopoll.h>
@@ -197,6 +198,7 @@ static const struct emac_variant emac_variant_h616_emac1 = {
 
 /* Used in RX_CTL1*/
 #define EMAC_RX_MD              BIT(1)
+#define EMAC_RX_ERR_FRM		BIT(3)
 #define EMAC_RX_TH_MASK		GENMASK(5, 4)
 #define EMAC_RX_TH_32		0
 #define EMAC_RX_TH_64		(0x1 << 4)
@@ -644,6 +646,9 @@ static void sun8i_dwmac_core_init(struct mac_device_info *hw,
 
 	v = (8 << EMAC_BURSTLEN_SHIFT); /* burst len */
 	writel(v, ioaddr + EMAC_BASIC_CTL1);
+
+	/* Forward checksum failures to software before starting RX. */
+	writel(EMAC_RX_ERR_FRM, ioaddr + EMAC_RX_CTL1);
 }
 
 static void sun8i_dwmac_set_mac(void __iomem *ioaddr, bool enable)
@@ -654,7 +659,7 @@ static void sun8i_dwmac_set_mac(void __iomem *ioaddr, bool enable)
 	r = readl(ioaddr + EMAC_RX_CTL0);
 	if (enable) {
 		t |= EMAC_TX_TRANSMITTER_EN;
-		r |= EMAC_RX_RECEIVER_EN;
+		r |= EMAC_RX_RECEIVER_EN | EMAC_RX_DO_CRC;
 	} else {
 		t &= ~EMAC_TX_TRANSMITTER_EN;
 		r &= ~EMAC_RX_RECEIVER_EN;
@@ -698,16 +703,9 @@ static void sun8i_dwmac_get_umac_addr(struct mac_device_info *hw,
 			    EMAC_MACADDR_LO(reg_n));
 }
 
-/* caution this function must return non 0 to work */
-static int sun8i_dwmac_rx_ipc_enable(struct mac_device_info *hw)
+static int sun8i_dwmac_rx_ipc(struct mac_device_info *hw)
 {
-	void __iomem *ioaddr = hw->pcsr;
-	u32 v;
-
-	v = readl(ioaddr + EMAC_RX_CTL0);
-	v |= EMAC_RX_DO_CRC;
-	writel(v, ioaddr + EMAC_RX_CTL0);
-
+	/* The receiver always records the checksum result, even with RXCSUM off. */
 	return 1;
 }
 
@@ -1053,7 +1051,7 @@ static const struct stmmac_ops sun8i_dwmac_ops = {
 	.core_init = sun8i_dwmac_core_init,
 	.set_mac = sun8i_dwmac_set_mac,
 	.dump_regs = sun8i_dwmac_dump_mac_regs,
-	.rx_ipc = sun8i_dwmac_rx_ipc_enable,
+	.rx_ipc = sun8i_dwmac_rx_ipc,
 	.set_filter = sun8i_dwmac_set_filter,
 	.flow_ctrl = sun8i_dwmac_flow_ctrl,
 	.set_umac_addr = sun8i_dwmac_set_umac_addr,
@@ -1061,6 +1059,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;
@@ -1068,6 +1143,7 @@ static int sun8i_dwmac_setup(void *ppriv, struct mac_device_info *mac)
 	mac->pcsr = priv->ioaddr;
 	mac->mac = &sun8i_dwmac_ops;
 	mac->dma = &sun8i_dwmac_dma_ops;
+	mac->rx_status = sun8i_dwmac_rx_status;
 
 	priv->dev->priv_flags |= IFF_UNICAST_FLT;
 
diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h
index 8ae95e91a36a..047d809b8b88 100644
--- a/drivers/net/ethernet/stmicro/stmmac/hwif.h
+++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h
@@ -125,8 +125,6 @@ struct stmmac_desc_ops {
 	stmmac_do_void_callback(__priv, desc, set_rx_owner, __args)
 #define stmmac_get_rx_frame_len(__priv, __args...) \
 	stmmac_do_callback(__priv, desc, get_rx_frame_len, __args)
-#define stmmac_rx_status(__priv, __args...) \
-	stmmac_do_callback(__priv, desc, rx_status, __args)
 #define stmmac_rx_extended_status(__priv, __args...) \
 	stmmac_do_callback(__priv, desc, rx_extended_status, __args)
 #define stmmac_enable_tx_timestamp(__priv, __args...) \
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index f256244ce0d1..2f33fc0126b1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -5775,7 +5775,7 @@ static int stmmac_rx_zc(struct stmmac_priv *priv, int limit, u32 queue)
 		p = stmmac_get_rx_desc(priv, rx_q, entry);
 
 		/* read the status of the incoming frame */
-		status = stmmac_rx_status(priv, &priv->xstats, p);
+		status = priv->hw->rx_status(&priv->xstats, p);
 		/* check if managed by the DMA otherwise go ahead */
 		if (unlikely(status & dma_own))
 			break;
@@ -5978,7 +5978,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
 		p = stmmac_get_rx_desc(priv, rx_q, entry);
 
 		/* read the status of the incoming frame */
-		status = stmmac_rx_status(priv, &priv->xstats, p);
+		status = priv->hw->rx_status(&priv->xstats, p);
 		/* check if managed by the DMA otherwise go ahead */
 		if (unlikely(status & dma_own))
 			break;
@@ -7809,6 +7809,9 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
 			return ret;
 	}
 
+	if (!priv->hw->rx_status)
+		priv->hw->rx_status = priv->hw->desc->rx_status;
+
 	/* Set alternate descriptor size (which tells the hardware that
 	 * descriptors are 8 32-bit words) when using extended descriptors
 	 * with ring mode. Only applicable for pre-v4.0 cores. Platform glue

-- 
2.53.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH net-next 2/2] net: stmmac: dwmac-sun8i: support ethtool rx-all
  2026-11-20 15:32 [PATCH net-next 0/2] net: stmmac: handle RX checksum and wire errors on sun8i James Hilliard
  2026-11-20 15:32 ` [PATCH net-next 1/2] net: stmmac: dwmac-sun8i: deliver RX checksum errors to the stack James Hilliard
@ 2026-11-20 15:32 ` James Hilliard
  2026-11-20 18:30   ` Maxime Chevallier
  2026-11-24 15:47   ` netdev-bot+sashiko
  2026-11-20 15:37 ` [PATCH net-next 0/2] net: stmmac: handle RX checksum and wire errors on sun8i netdev-bot+sinfo
  2 siblings, 2 replies; 9+ messages in thread
From: James Hilliard @ 2026-11-20 15:32 UTC (permalink / raw)
  To: netdev, Maxime Chevallier, Andrew Lunn, David S. Miller,
	Eric Dumazet, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
	Ong Boon Leong, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
	LABBE Corentin
  Cc: Jakub Kicinski, Oleksij Rempel, linux-arm-kernel, linux-sunxi,
	James Hilliard

Packet captures on sun8i cannot currently inspect frames the driver
discards for Ethernet errors. Add opt-in rx-all support for complete
frames with a reported wire error and for runts the MAC can forward.

Set the runt-forwarding bit at hardware initialization and when rx-all
changes. Serialize live updates with the DMA controls in the same
register. Deliver these frames without claiming a verified checksum or
including them in the good-packet and good-byte totals. Keep counting
the wire errors even when the frames are delivered.

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
 drivers/net/ethernet/stmicro/stmmac/common.h      |  2 +
 drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 73 +++++++++++++----------
 drivers/net/ethernet/stmicro/stmmac/hwif.h        |  1 +
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 52 +++++++++++-----
 4 files changed, 80 insertions(+), 48 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/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index 0ad2203f76c3..8398788d334e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -21,16 +21,12 @@
 #include <linux/pm_runtime.h>
 #include <linux/regulator/consumer.h>
 #include <linux/regmap.h>
+#include <linux/spinlock.h>
 #include <linux/stmmac.h>
 
 #include "stmmac.h"
 #include "stmmac_platform.h"
 
-/* General notes on dwmac-sun8i:
- * Locking: no locking is necessary in this file because all necessary locking
- *		is done in the "stmmac files"
- */
-
 /* struct emac_variant - Describe dwmac-sun8i hardware variant
  * @syscon_field		reg_field for the syscon's gmac register
  * @soc_has_internal_phy:	Does the MAC embed an internal PHY
@@ -73,6 +69,7 @@ struct sunxi_priv_data {
 	bool internal_phy_powered;
 	bool use_internal_phy;
 	void *mux_handle;
+	spinlock_t rx_ctl1_lock; /* Protects live RX_CTL1 updates */
 };
 
 /* EMAC clock register @ 0x30 in the "system control" address range */
@@ -198,6 +195,7 @@ static const struct emac_variant emac_variant_h616_emac1 = {
 
 /* Used in RX_CTL1*/
 #define EMAC_RX_MD              BIT(1)
+#define EMAC_RX_RUNT_FRM	BIT(2)
 #define EMAC_RX_ERR_FRM		BIT(3)
 #define EMAC_RX_TH_MASK		GENMASK(5, 4)
 #define EMAC_RX_TH_32		0
@@ -442,25 +440,32 @@ static void sun8i_dwmac_dma_stop_tx(struct stmmac_priv *priv,
 	writel(v, ioaddr + EMAC_TX_CTL1);
 }
 
-static void sun8i_dwmac_dma_start_rx(struct stmmac_priv *priv,
-				     void __iomem *ioaddr, u32 chan)
+static void sun8i_dwmac_update_rx_ctl1(struct stmmac_priv *priv, u32 clear, u32 set)
 {
+	struct sunxi_priv_data *gmac = priv->plat->bsp_priv;
 	u32 v;
 
-	v = readl(ioaddr + EMAC_RX_CTL1);
-	v |= EMAC_RX_DMA_START;
-	v |= EMAC_RX_DMA_EN;
-	writel(v, ioaddr + EMAC_RX_CTL1);
+	guard(spinlock_irqsave)(&gmac->rx_ctl1_lock);
+	v = readl(priv->ioaddr + EMAC_RX_CTL1);
+	writel((v & ~clear) | set, priv->ioaddr + EMAC_RX_CTL1);
+}
+
+static void sun8i_dwmac_dma_start_rx(struct stmmac_priv *priv,
+				     void __iomem *ioaddr, u32 chan)
+{
+	sun8i_dwmac_update_rx_ctl1(priv, 0, EMAC_RX_DMA_START | EMAC_RX_DMA_EN);
 }
 
 static void sun8i_dwmac_dma_stop_rx(struct stmmac_priv *priv,
 				    void __iomem *ioaddr, u32 chan)
 {
-	u32 v;
+	sun8i_dwmac_update_rx_ctl1(priv, EMAC_RX_DMA_EN, 0);
+}
 
-	v = readl(ioaddr + EMAC_RX_CTL1);
-	v &= ~EMAC_RX_DMA_EN;
-	writel(v, ioaddr + EMAC_RX_CTL1);
+static void sun8i_dwmac_set_rx_all(struct stmmac_priv *priv, bool enable)
+{
+	sun8i_dwmac_update_rx_ctl1(priv, EMAC_RX_RUNT_FRM,
+				   enable ? EMAC_RX_RUNT_FRM : 0);
 }
 
 static int sun8i_dwmac_dma_interrupt(struct stmmac_priv *priv,
@@ -539,24 +544,23 @@ static void sun8i_dwmac_dma_operation_mode_rx(struct stmmac_priv *priv,
 					      void __iomem *ioaddr, int mode,
 					      u32 channel, int fifosz, u8 qmode)
 {
-	u32 v;
+	u32 threshold = 0;
 
-	v = readl(ioaddr + EMAC_RX_CTL1);
 	if (mode == SF_DMA_MODE) {
-		v |= EMAC_RX_MD;
-	} else {
-		v &= ~EMAC_RX_MD;
-		v &= ~EMAC_RX_TH_MASK;
-		if (mode < 32)
-			v |= EMAC_RX_TH_32;
-		else if (mode < 64)
-			v |= EMAC_RX_TH_64;
-		else if (mode < 96)
-			v |= EMAC_RX_TH_96;
-		else if (mode < 128)
-			v |= EMAC_RX_TH_128;
+		sun8i_dwmac_update_rx_ctl1(priv, 0, EMAC_RX_MD);
+		return;
 	}
-	writel(v, ioaddr + EMAC_RX_CTL1);
+
+	if (mode < 32)
+		threshold = EMAC_RX_TH_32;
+	else if (mode < 64)
+		threshold = EMAC_RX_TH_64;
+	else if (mode < 96)
+		threshold = EMAC_RX_TH_96;
+	else if (mode < 128)
+		threshold = EMAC_RX_TH_128;
+
+	sun8i_dwmac_update_rx_ctl1(priv, EMAC_RX_MD | EMAC_RX_TH_MASK, threshold);
 }
 
 static void sun8i_dwmac_dma_operation_mode_tx(struct stmmac_priv *priv,
@@ -648,7 +652,10 @@ static void sun8i_dwmac_core_init(struct mac_device_info *hw,
 	writel(v, ioaddr + EMAC_BASIC_CTL1);
 
 	/* Forward checksum failures to software before starting RX. */
-	writel(EMAC_RX_ERR_FRM, ioaddr + EMAC_RX_CTL1);
+	v = EMAC_RX_ERR_FRM;
+	if (dev->features & NETIF_F_RXALL)
+		v |= EMAC_RX_RUNT_FRM;
+	writel(v, ioaddr + EMAC_RX_CTL1);
 }
 
 static void sun8i_dwmac_set_mac(void __iomem *ioaddr, bool enable)
@@ -1052,6 +1059,7 @@ static const struct stmmac_ops sun8i_dwmac_ops = {
 	.set_mac = sun8i_dwmac_set_mac,
 	.dump_regs = sun8i_dwmac_dump_mac_regs,
 	.rx_ipc = sun8i_dwmac_rx_ipc,
+	.set_rx_all = sun8i_dwmac_set_rx_all,
 	.set_filter = sun8i_dwmac_set_filter,
 	.flow_ctrl = sun8i_dwmac_flow_ctrl,
 	.set_umac_addr = sun8i_dwmac_set_umac_addr,
@@ -1126,7 +1134,7 @@ static int sun8i_dwmac_rx_status(struct stmmac_extra_stats *x, struct dma_desc *
 	if (unlikely(runt || (status & wire_errors))) {
 		if (runt && !(status & RDES0_LENGTH_ERROR))
 			x->rx_length++;
-		return discard_frame;
+		return rx_error_frame | csum_none;
 	}
 
 	/* Only a checked IP frame is eligible for CHECKSUM_UNNECESSARY. */
@@ -1218,6 +1226,7 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
 	if (!gmac)
 		return -ENOMEM;
 
+	spin_lock_init(&gmac->rx_ctl1_lock);
 	gmac->variant = of_device_get_match_data(&pdev->dev);
 	if (!gmac->variant) {
 		dev_err(&pdev->dev, "Missing dwmac-sun8i variant\n");
diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h
index 047d809b8b88..2cfadc686104 100644
--- a/drivers/net/ethernet/stmicro/stmmac/hwif.h
+++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h
@@ -319,6 +319,7 @@ struct stmmac_ops {
 	void (*set_mac)(void __iomem *ioaddr, bool enable);
 	/* Enable and verify that the IPC module is supported */
 	int (*rx_ipc)(struct mac_device_info *hw);
+	void (*set_rx_all)(struct stmmac_priv *priv, bool enable);
 	/* Enable RX Queues */
 	void (*rx_queue_enable)(struct mac_device_info *hw, u8 mode, u32 queue);
 	/* RX Queues Priority */
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 2f33fc0126b1..0a893c2cea78 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -5655,10 +5655,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)
@@ -5716,6 +5718,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];
@@ -5806,11 +5823,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);
@@ -6004,11 +6018,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) &&
@@ -6170,8 +6181,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;
@@ -6453,6 +6466,11 @@ static int stmmac_set_features(struct net_device *netdev,
 {
 	struct stmmac_priv *priv = netdev_priv(netdev);
 
+	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);
+
 	/* Keep the COE Type in case of csum is supporting */
 	if (features & NETIF_F_RXCSUM)
 		priv->hw->rx_csum = priv->plat->rx_coe;
@@ -8285,6 +8303,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



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next 0/2] net: stmmac: handle RX checksum and wire errors on sun8i
  2026-11-20 15:32 [PATCH net-next 0/2] net: stmmac: handle RX checksum and wire errors on sun8i James Hilliard
  2026-11-20 15:32 ` [PATCH net-next 1/2] net: stmmac: dwmac-sun8i: deliver RX checksum errors to the stack James Hilliard
  2026-11-20 15:32 ` [PATCH net-next 2/2] net: stmmac: dwmac-sun8i: support ethtool rx-all James Hilliard
@ 2026-11-20 15:37 ` netdev-bot+sinfo
  2026-11-20 16:29   ` James Hilliard
  2 siblings, 1 reply; 9+ messages in thread
From: netdev-bot+sinfo @ 2026-11-20 15:37 UTC (permalink / raw)
  To: James Hilliard
  Cc: netdev, Maxime Chevallier, Andrew Lunn, David S. Miller,
	Eric Dumazet, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
	Ong Boon Leong, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
	LABBE Corentin, Jakub Kicinski, Oleksij Rempel, linux-arm-kernel,
	linux-sunxi

Hi!

This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:

 - How the issue was discovered, e.g. hit in production, hit during
   development, syzbot report, manual code inspection, LLM or static
   analysis tool scan.

Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.

*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
-- 
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next 0/2] net: stmmac: handle RX checksum and wire errors on sun8i
  2026-11-20 15:37 ` [PATCH net-next 0/2] net: stmmac: handle RX checksum and wire errors on sun8i netdev-bot+sinfo
@ 2026-11-20 16:29   ` James Hilliard
  0 siblings, 0 replies; 9+ messages in thread
From: James Hilliard @ 2026-11-20 16:29 UTC (permalink / raw)
  To: netdev-bot+sinfo
  Cc: netdev, Maxime Chevallier, Andrew Lunn, David S. Miller,
	Eric Dumazet, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
	Ong Boon Leong, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
	LABBE Corentin, Jakub Kicinski, Oleksij Rempel, linux-arm-kernel,
	linux-sunxi

On Fri, Nov 20, 2026 at 8:37 AM <netdev-bot+sinfo@kernel.org> wrote:
>
> Hi!
>
> This is an automated message. This series looks like a fix, but its
> commit messages seem to be missing some information:
>
>  - How the issue was discovered, e.g. hit in production, hit during
>    development, syzbot report, manual code inspection, LLM or static
>    analysis tool scan.

This series came out of Jakub's review of my earlier dwmac-sun8i
patch [0]. I found the original issue while testing on an Allwinner
H616 with an AC200 PHY: the MAC dropped packets with a bad UDP
checksum even with RX checksum offload disabled. My patch fixed that
case, but Jakub pointed out that a bad transport checksum alone should
not cause the MAC to drop a packet with offload enabled either.

Jakub asked to see the full fix before deciding what to apply [1], so
this series replaces the earlier patch and handles both modes.

[0] https://lore.kernel.org/r/20261119144848.4ddd88cb@kernel.org/
[1] https://lore.kernel.org/r/20261119161151.5251fc86@kernel.org/

>
> Please do not repost the series just to address the above. Instead,
> reply to this email with the missing information, so that reviewers
> can take it into account.
>
> *IMPORTANT*: If you do repost (for other reasons) - please include
> the relevant info in the cover letter or commit messages.
> --
> The evaluation is done by an LLM so it may be wrong, if you think
> that is the case please reply and explain.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next 2/2] net: stmmac: dwmac-sun8i: support ethtool rx-all
  2026-11-20 15:32 ` [PATCH net-next 2/2] net: stmmac: dwmac-sun8i: support ethtool rx-all James Hilliard
@ 2026-11-20 18:30   ` Maxime Chevallier
  2026-11-20 18:46     ` James Hilliard
  2026-11-24 15:47   ` netdev-bot+sashiko
  1 sibling, 1 reply; 9+ messages in thread
From: Maxime Chevallier @ 2026-11-20 18:30 UTC (permalink / raw)
  To: James Hilliard, netdev, Andrew Lunn, David S. Miller,
	Eric Dumazet, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
	Ong Boon Leong, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
	LABBE Corentin
  Cc: Jakub Kicinski, Oleksij Rempel, linux-arm-kernel, linux-sunxi

Hi,

On 11/20/26 16:32, James Hilliard wrote:
> Packet captures on sun8i cannot currently inspect frames the driver
> discards for Ethernet errors. Add opt-in rx-all support for complete
> frames with a reported wire error and for runts the MAC can forward.
> 
> Set the runt-forwarding bit at hardware initialization and when rx-all
> changes. Serialize live updates with the DMA controls in the same
> register. Deliver these frames without claiming a verified checksum or
> including them in the good-packet and good-byte totals. Keep counting
> the wire errors even when the frames are delivered.

This deserves a series on its own. it's not only about sun8i, it add the
whole plumbing to stmmac itself. Is it something you've used and needed ?

This feels a bit strange as you answer to the series info bot that this
comes from Jakub's comment on the previous series, but I don't really
see the connection except that Jakub mentions RX_ALL.

If you want and need this feature, you can submit that separately.

Maxime



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next 2/2] net: stmmac: dwmac-sun8i: support ethtool rx-all
  2026-11-20 18:30   ` Maxime Chevallier
@ 2026-11-20 18:46     ` James Hilliard
  0 siblings, 0 replies; 9+ messages in thread
From: James Hilliard @ 2026-11-20 18:46 UTC (permalink / raw)
  To: Maxime Chevallier
  Cc: netdev, Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni,
	Maxime Coquelin, Alexandre Torgue, Ong Boon Leong, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, LABBE Corentin, Jakub Kicinski,
	Oleksij Rempel, linux-arm-kernel, linux-sunxi

On Fri, Nov 20, 2026 at 11:30 AM Maxime Chevallier
<maxime.chevallier@bootlin.com> wrote:
>
> Hi,
>
> On 11/20/26 16:32, James Hilliard wrote:
> > Packet captures on sun8i cannot currently inspect frames the driver
> > discards for Ethernet errors. Add opt-in rx-all support for complete
> > frames with a reported wire error and for runts the MAC can forward.
> >
> > Set the runt-forwarding bit at hardware initialization and when rx-all
> > changes. Serialize live updates with the DMA controls in the same
> > register. Deliver these frames without claiming a verified checksum or
> > including them in the good-packet and good-byte totals. Keep counting
> > the wire errors even when the frames are delivered.
>
> This deserves a series on its own. it's not only about sun8i, it add the
> whole plumbing to stmmac itself. Is it something you've used and needed ?

I used the hardware error-forwarding controls on H616 while comparing
the AC200 PHY's CRC error counter with what the MAC delivered to DMA.
For example, the PHY counted both 63-byte and 64-byte frames with a bad
FCS, but only the 64-byte frames reached DMA. The use case for rx-all
is to inspect the frames the MAC can forward with a normal packet
capture. It isn't needed for normal reception.

> This feels a bit strange as you answer to the series info bot that this
> comes from Jakub's comment on the previous series, but I don't really
> see the connection except that Jakub mentions RX_ALL.

My reply to the bot was about the checksum fix in patch 1. Jakub's point
was that a bad transport checksum alone shouldn't cause a packet to be
dropped. On sun8i the same hardware bit forwards both checksum and
Ethernet errors to DMA, so patch 1 enables forwarding and lets the
driver discard bad-FCS frames. That addresses his comment without
needing rx-all.

> If you want and need this feature, you can submit that separately.

I'll send the checksum fix on its own and keep the rx-all support for a
separate net-next series.

>
> Maxime
>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next 1/2] net: stmmac: dwmac-sun8i: deliver RX checksum errors to the stack
  2026-11-20 15:32 ` [PATCH net-next 1/2] net: stmmac: dwmac-sun8i: deliver RX checksum errors to the stack James Hilliard
@ 2026-11-24 15:47   ` netdev-bot+sashiko
  0 siblings, 0 replies; 9+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 15:47 UTC (permalink / raw)
  To: james.hilliard1
  Cc: netdev, maxime.chevallier, andrew+netdev, davem, edumazet, pabeni,
	mcoquelin.stm32, alexandre.torgue, boon.leong.ong, wens,
	jernej.skrabec, samuel, clabbe.montjoie, kuba, o.rempel,
	linux-arm-kernel, linux-sunxi

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] The patch has `Fixes: 9f93ac8d4085` (the 2017 commit that
  added dwmac-sun8i), which invites backporting to every stable tree…
- [Low] The commit is titled and described as a dwmac-sun8i-only fix and
  carries a Fixes: tag, but it also changes the shared stmmac RX…

--

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

This patch turns on error-frame forwarding on the sun8i EMAC and adds a
sun8i RX status decoder. Frames with IP or L4 checksum failures now go to
the stack with CHECKSUM_NONE instead of being dropped by the hardware. To
make this possible it adds an rx_status hook to struct mac_device_info,
which defaults to the descriptor decoder and is called from stmmac_rx()
and stmmac_rx_zc(), and it moves EMAC_RX_DO_CRC from rx_ipc into set_mac.

> diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
> index a972bee66504b..706feb7bcbeda 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/common.h
> +++ b/drivers/net/ethernet/stmicro/stmmac/common.h
> @@ -615,6 +615,8 @@ struct mii_regs {
>  struct mac_device_info {
>  	const struct stmmac_ops *mac;
>  	const struct stmmac_desc_ops *desc;
> +	/* Defaults to the descriptor format's decoder unless the MAC overrides it. */
> +	int (*rx_status)(struct stmmac_extra_stats *x, struct dma_desc *p);
>  	const struct stmmac_dma_ops *dma;
>  	const struct stmmac_mode_ops *mode;
>  	const struct stmmac_hwtimestamp *ptp;
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> index 2ece7ba9dd73b..0ad2203f76c34 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c

[ ... ]

> @@ -644,6 +646,9 @@ static void sun8i_dwmac_core_init(struct mac_device_info *hw,
>  
>  	v = (8 << EMAC_BURSTLEN_SHIFT); /* burst len */
>  	writel(v, ioaddr + EMAC_BASIC_CTL1);
> +
> +	/* Forward checksum failures to software before starting RX. */
> +	writel(EMAC_RX_ERR_FRM, ioaddr + EMAC_RX_CTL1);
>  }
>  
>  static void sun8i_dwmac_set_mac(void __iomem *ioaddr, bool enable)
> @@ -654,7 +659,7 @@ static void sun8i_dwmac_set_mac(void __iomem *ioaddr, bool enable)
>  	r = readl(ioaddr + EMAC_RX_CTL0);
>  	if (enable) {
>  		t |= EMAC_TX_TRANSMITTER_EN;
> -		r |= EMAC_RX_RECEIVER_EN;
> +		r |= EMAC_RX_RECEIVER_EN | EMAC_RX_DO_CRC;
>  	} else {
>  		t &= ~EMAC_TX_TRANSMITTER_EN;
>  		r &= ~EMAC_RX_RECEIVER_EN;
> @@ -698,16 +703,9 @@ static void sun8i_dwmac_get_umac_addr(struct mac_device_info *hw,
>  			    EMAC_MACADDR_LO(reg_n));
>  }
>  
> -/* caution this function must return non 0 to work */
> -static int sun8i_dwmac_rx_ipc_enable(struct mac_device_info *hw)
> +static int sun8i_dwmac_rx_ipc(struct mac_device_info *hw)
>  {
> -	void __iomem *ioaddr = hw->pcsr;
> -	u32 v;
> -
> -	v = readl(ioaddr + EMAC_RX_CTL0);
> -	v |= EMAC_RX_DO_CRC;
> -	writel(v, ioaddr + EMAC_RX_CTL0);
> -
> +	/* The receiver always records the checksum result, even with RXCSUM off. */
>  	return 1;
>  }

[ ... ]

> @@ -1061,6 +1059,83 @@ static const struct stmmac_ops sun8i_dwmac_ops = {

[ ... ]

> +static int sun8i_dwmac_rx_status(struct stmmac_extra_stats *x, struct dma_desc *p)
> +{

[ ... ]

> +	/* 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;
> +}

[Severity: Medium]
This commit has Fixes: 9f93ac8d4085, so it will probably be picked up
for stable trees that have dwmac-sun8i. Is it safe there without the core
change that makes stmmac_rx() honour csum_none?

Before this patch, sun8i_dwmac_dma_reset() zeroed EMAC_RX_CTL1 and nothing
set EMAC_RX_ERR_FRM, so the MAC dropped frames with bad IP or L4
checksums. Now sun8i_dwmac_core_init() sets EMAC_RX_ERR_FRM. Those frames
reach the ring, and sun8i_dwmac_rx_status() returns csum_none for them.

The only thing that stops them being marked CHECKSUM_UNNECESSARY is this
test in stmmac_rx():

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

The csum_none clause there came from ee0aace5f844 ("net: stmmac:
Correctly handle Rx checksum offload errors"). That commit has no Fixes:
or Cc: stable tag, so older stable trees may not have it. The matching
clause in stmmac_dispatch_skb_zc() came from fcfc52fcf89a, which is
tagged for stable.

sun8i sets plat_dat->rx_coe = STMMAC_RX_COE_TYPE2, so coe is non-zero and
RXCSUM is on by default. In a tree without ee0aace5f844, would a frame
with a corrupt TCP or UDP checksum go up as CHECKSUM_UNNECESSARY? Before
this patch the hardware would have dropped it.

Could a stable dependency note be added, for example
"Cc: stable@vger.kernel.org # x.y: ee0aace5f844"?

[ ... ]

> diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h
> index 8ae95e91a36ab..047d809b8b889 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h
> +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h
> @@ -125,8 +125,6 @@ struct stmmac_desc_ops {
>  	stmmac_do_void_callback(__priv, desc, set_rx_owner, __args)
>  #define stmmac_get_rx_frame_len(__priv, __args...) \
>  	stmmac_do_callback(__priv, desc, get_rx_frame_len, __args)
> -#define stmmac_rx_status(__priv, __args...) \
> -	stmmac_do_callback(__priv, desc, rx_status, __args)
>  #define stmmac_rx_extended_status(__priv, __args...) \
>  	stmmac_do_callback(__priv, desc, rx_extended_status, __args)
>  #define stmmac_enable_tx_timestamp(__priv, __args...) \
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index f256244ce0d11..2f33fc0126b11 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

[ ... ]

> @@ -5978,7 +5978,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
>  		p = stmmac_get_rx_desc(priv, rx_q, entry);
>  
>  		/* read the status of the incoming frame */
> -		status = stmmac_rx_status(priv, &priv->xstats, p);
> +		status = priv->hw->rx_status(&priv->xstats, p);
>  		/* check if managed by the DMA otherwise go ahead */
>  		if (unlikely(status & dma_own))
>  			break;
> @@ -7809,6 +7809,9 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
>  			return ret;
>  	}
>  
> +	if (!priv->hw->rx_status)
> +		priv->hw->rx_status = priv->hw->desc->rx_status;
> +

[Severity: Low]
The subject and message describe a dwmac-sun8i only fix. The patch also
changes the shared stmmac RX path that every platform uses:

  struct mac_device_info gets a new rx_status hook in common.h

  hwif.h loses the stmmac_rx_status() wrapper, and with it the NULL
  checks on hw->desc and desc->rx_status that stmmac_do_callback() did

  stmmac_rx() and stmmac_rx_zc() now call priv->hw->rx_status() directly

  stmmac_hw_init() sets the default from priv->hw->desc->rx_status

The default only works because it runs after priv->hwif_quirks(). That is
where stmmac_dwmac1_quirks() sets mac->desc for the GMAC and MAC100
cores, whose hwif table entries have .desc = NULL.

This holds in the current tree. All the desc ops tables define
.rx_status, and every hwif entry either sets .desc or uses
stmmac_dwmac1_quirks(). The Fixes: tag will send this toward stable
trees, though. Could the commit message mention the core refactor and
this ordering requirement?

The message also says:

  Keep the hardware checker running whenever the receiver is enabled.

Is that actually a change in behaviour? The removed
sun8i_dwmac_rx_ipc_enable() set EMAC_RX_DO_CRC on every stmmac_rx_ipc()
call. Those calls come from stmmac_hw_setup() and stmmac_set_features(),
including when RXCSUM is turned off, and nothing cleared the bit. Moving
it into sun8i_dwmac_set_mac() seems to leave the behaviour as it was.

>  	/* Set alternate descriptor size (which tells the hardware that
>  	 * descriptors are 8 32-bit words) when using extended descriptors
>  	 * with ring mode. Only applicable for pre-v4.0 cores. Platform glue

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120-submit-sun8i-rx-features-v1-v1-0-5058fecba6b3%40gmail.com


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next 2/2] net: stmmac: dwmac-sun8i: support ethtool rx-all
  2026-11-20 15:32 ` [PATCH net-next 2/2] net: stmmac: dwmac-sun8i: support ethtool rx-all James Hilliard
  2026-11-20 18:30   ` Maxime Chevallier
@ 2026-11-24 15:47   ` netdev-bot+sashiko
  1 sibling, 0 replies; 9+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 15:47 UTC (permalink / raw)
  To: james.hilliard1
  Cc: netdev, maxime.chevallier, andrew+netdev, davem, edumazet, pabeni,
	mcoquelin.stm32, alexandre.torgue, boon.leong.ong, wens,
	jernej.skrabec, samuel, clabbe.montjoie, kuba, o.rempel,
	linux-arm-kernel, linux-sunxi

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] The patch adds a `set_rx_all` member to `struct stmmac_ops`
  (drivers/net/ethernet/stmicro/stmmac/hwif.h:322) but no…

--

net: stmmac: dwmac-sun8i: support ethtool rx-all

This adds opt-in NETIF_F_RXALL support for dwmac-sun8i. With it, complete
frames with a reported wire error, and runts the MAC can forward, are
delivered to the stack and are not counted in the good packet and byte
totals. A new set_rx_all op in struct stmmac_ops updates the runt
forwarding bit in RX_CTL1, and a new spinlock serializes those updates
against the DMA start/stop bits.

> diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h
> index 047d809b8b889..2cfadc6861047 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h
> +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h
> @@ -319,6 +319,7 @@ struct stmmac_ops {
>  	void (*set_mac)(void __iomem *ioaddr, bool enable);
>  	/* Enable and verify that the IPC module is supported */
>  	int (*rx_ipc)(struct mac_device_info *hw);
> +	void (*set_rx_all)(struct stmmac_priv *priv, bool enable);
>  	/* Enable RX Queues */
>  	void (*rx_queue_enable)(struct mac_device_info *hw, u8 mode, u32 queue);
>  	/* RX Queues Priority */
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 2f33fc0126b11..0a893c2cea78b 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

[ ... ]

> @@ -6453,6 +6466,11 @@ static int stmmac_set_features(struct net_device *netdev,
>  {
>  	struct stmmac_priv *priv = netdev_priv(netdev);
>  
> +	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]
This isn't a bug, but should the new op get a stmmac_set_rx_all() wrapper
in hwif.h like the other struct stmmac_ops members have?

Every other MAC op in that table goes through stmmac_do_callback() or
stmmac_do_void_callback(), which checks both hw->mac and the op pointer
for NULL:

drivers/net/ethernet/stmicro/stmmac/hwif.h:
#define stmmac_core_init(__priv, __args...) \
	stmmac_do_void_callback(__priv, mac, core_init, __args)
...
#define stmmac_rx_ipc(__priv, __args...) \
	stmmac_do_callback(__priv, mac, rx_ipc, __args)

Here stmmac_set_features() calls priv->hw->mac->set_rx_all() directly
and does its own NULL check. A few lines below, the same function calls
stmmac_rx_ipc() through the wrapper.

__stmmac_dvr_probe() also reads priv->hw->mac->set_rx_all directly to
decide whether to advertise NETIF_F_RXALL.

Both sites check for NULL today, so nothing breaks now. Only
sun8i_dwmac_ops sets this op, though. If a later caller copies the
direct call without the NULL check, could it oops on every other MAC?

>  	/* Keep the COE Type in case of csum is supporting */
>  	if (features & NETIF_F_RXCSUM)
>  		priv->hw->rx_csum = priv->plat->rx_coe;

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120-submit-sun8i-rx-features-v1-v1-0-5058fecba6b3%40gmail.com


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-11-24 15:47 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 15:32 [PATCH net-next 0/2] net: stmmac: handle RX checksum and wire errors on sun8i James Hilliard
2026-11-20 15:32 ` [PATCH net-next 1/2] net: stmmac: dwmac-sun8i: deliver RX checksum errors to the stack James Hilliard
2026-11-24 15:47   ` netdev-bot+sashiko
2026-11-20 15:32 ` [PATCH net-next 2/2] net: stmmac: dwmac-sun8i: support ethtool rx-all James Hilliard
2026-11-20 18:30   ` Maxime Chevallier
2026-11-20 18:46     ` James Hilliard
2026-11-24 15:47   ` netdev-bot+sashiko
2026-11-20 15:37 ` [PATCH net-next 0/2] net: stmmac: handle RX checksum and wire errors on sun8i netdev-bot+sinfo
2026-11-20 16:29   ` James Hilliard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox