* [PATCH net-next v4 0/5] net: stmmac: support ethtool rx-all on sun8i
@ 2026-12-04 2:37 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
` (5 more replies)
0 siblings, 6 replies; 10+ messages in thread
From: James Hilliard @ 2026-12-04 2:37 UTC (permalink / raw)
To: netdev, Maxime Chevallier, Andrew Lunn, David S. Miller,
Eric Dumazet, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, LABBE Corentin,
Willem de Bruijn, Nicolai Buchwitz
Cc: Jakub Kicinski, Oleksij Rempel, linux-arm-kernel, linux-sunxi,
James Hilliard
On H616 the PHY can count a bad-FCS frame even when it does not appear
in a packet capture. Enabling rx-all lets a capture see the complete
errored frames the MAC can forward. On this hardware, a 64-byte frame
with a bad FCS reaches DMA, but a 63-byte one does not, even with runt
forwarding enabled. Both lengths include the FCS.
Patch 1 supersedes the standalone sun8i RX checksum-delivery fix [0].
The series also serializes changes to the register shared by RX DMA,
pause thresholds and runt forwarding before adding the rx-all switch.
[0] https://lore.kernel.org/r/20261125-submit-sun8i-rx-features-v1-v3-1-79273f18a028@gmail.com/
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
Changes in v4:
- Serialize live RX_CTL1 updates, including phylink pause configuration
and RX DMA start/stop, before using the register for rx-all. Sashiko
reported the ethtool/phylink race [1]; Codex helped implement and
check the locking change.
- Record the H616 checksum status encoding and the two stmmac checksum
fixes needed for backports in patch 1.
- Link to v3: https://patch.msgid.link/20261201-submit-sun8i-rxall-v1-v3-0-01aa6280e6ae@gmail.com
[1] https://lore.kernel.org/r/sashiko-outbox-247233@kernel.org/
Changes in v3:
- Carry the checksum-delivery fix as patch 1 against net-next, superseding
its separate net submission and removing the external prerequisite.
- Rebase onto net-next at 0a837a30e55b, following Willem's review.
- Link to v2: https://patch.msgid.link/20261125-submit-sun8i-rxall-v1-v2-0-4de03fbde087@gmail.com
Changes in v2:
- Drop the RX_CTL1 lock and leave DMA start, stop and mode setup unchanged.
- Align the EMAC_RX_MD definition in a separate patch, as Andrew requested.
- Apply rx-all alongside the other receive filters, independently of RX checksum reporting.
- Link to v1: https://patch.msgid.link/20261122-submit-sun8i-rxall-v1-v1-0-607789772c56@gmail.com
---
James Hilliard (5):
net: stmmac: dwmac-sun8i: deliver RX checksum errors to the stack
net: stmmac: dwmac-sun8i: align EMAC_RX_MD with tabs
net: stmmac: dwmac-sun8i: serialize RX_CTL1 updates
net: stmmac: add common RXALL handling
net: stmmac: dwmac-sun8i: support ethtool rx-all
drivers/net/ethernet/stmicro/stmmac/common.h | 10 +-
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 185 +++++++++++++++------
.../net/ethernet/stmicro/stmmac/dwmac1000_core.c | 4 +-
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 4 +-
.../net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 4 +-
drivers/net/ethernet/stmicro/stmmac/hwif.c | 2 +-
drivers/net/ethernet/stmicro/stmmac/hwif.h | 4 +-
drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c | 4 +-
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 59 +++++--
9 files changed, 191 insertions(+), 85 deletions(-)
---
base-commit: c1165beb053a652299b1503b2dd7674ced0b1596
base-tree: git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git main
change-id: 20261122-submit-sun8i-rxall-v1-2666ccf2a020
Best regards,
--
James Hilliard <james.hilliard1@gmail.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH net-next v4 1/5] net: stmmac: dwmac-sun8i: deliver RX checksum errors to the stack
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 ` 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
` (4 subsequent siblings)
5 siblings, 1 reply; 10+ messages in thread
From: James Hilliard @ 2026-12-04 2:37 UTC (permalink / raw)
To: netdev, Maxime Chevallier, Andrew Lunn, David S. Miller,
Eric Dumazet, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, LABBE Corentin,
Willem de Bruijn, Nicolai Buchwitz
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.
On H616, IPv4 and IPv6 UDP frames with a valid checksum had RX status
bit 5 set and bits 7 and 0 clear. Sending the same frames with a bad UDP
checksum also set bit 0. This matches the checksum status encoding in
the Allwinner driver.
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.
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")
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
Standalone checksum-delivery revision notes:
Changes in v3:
- Explain how both RX paths select their decoder and why the default
is installed after descriptor selection.
- Clarify that moving the checker enable preserves its behavior.
- Document the checksum-status requirements for stable backports.
- Link to v2: https://patch.msgid.link/20261122-submit-sun8i-rx-features-v1-v2-1-24a2564f6edf@gmail.com
Changes in v2:
- Submit the checksum-delivery fix alone for net, following Maxime's
review. The RXALL feature will be submitted separately for net-next.
- Link to v1: https://patch.msgid.link/20261120-submit-sun8i-rx-features-v1-v1-0-5058fecba6b3@gmail.com
---
drivers/net/ethernet/stmicro/stmmac/common.h | 2 +
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 97 ++++++++++++++++++++---
drivers/net/ethernet/stmicro/stmmac/hwif.h | 2 -
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 7 +-
4 files changed, 93 insertions(+), 15 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
index 17cc0dc7e79d..95d272e87524 100644
--- a/drivers/net/ethernet/stmicro/stmmac/common.h
+++ b/drivers/net/ethernet/stmicro/stmmac/common.h
@@ -627,6 +627,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 613199da57c1..a7e4fca50141 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -198,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)
@@ -652,6 +653,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)
@@ -662,7 +666,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;
@@ -706,16 +710,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;
}
@@ -1073,7 +1070,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,
@@ -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;
@@ -1088,6 +1162,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 6895ae21f918..6849b58ba2f8 100644
--- a/drivers/net/ethernet/stmicro/stmmac/hwif.h
+++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h
@@ -127,8 +127,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 4ee4952a1427..99252fb83675 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -5772,7 +5772,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;
@@ -5975,7 +5975,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;
@@ -7806,6 +7806,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] 10+ messages in thread
* [PATCH net-next v4 2/5] net: stmmac: dwmac-sun8i: align EMAC_RX_MD with tabs
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-04 2:37 ` James Hilliard
2026-12-04 2:37 ` [PATCH net-next v4 3/5] net: stmmac: dwmac-sun8i: serialize RX_CTL1 updates James Hilliard
` (3 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: James Hilliard @ 2026-12-04 2:37 UTC (permalink / raw)
To: netdev, Maxime Chevallier, Andrew Lunn, David S. Miller,
Eric Dumazet, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, LABBE Corentin,
Willem de Bruijn, Nicolai Buchwitz
Cc: Jakub Kicinski, Oleksij Rempel, linux-arm-kernel, linux-sunxi,
James Hilliard
Use tabs to align the receive mode bit with the receive error and
threshold definitions in the same register.
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index a7e4fca50141..8377dc798537 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -197,7 +197,7 @@ static const struct emac_variant emac_variant_h616_emac1 = {
#define EMAC_FRM_FLT_MULTICAST BIT(16)
/* Used in RX_CTL1*/
-#define EMAC_RX_MD BIT(1)
+#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
--
2.53.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH net-next v4 3/5] net: stmmac: dwmac-sun8i: serialize RX_CTL1 updates
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-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 ` 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
` (2 subsequent siblings)
5 siblings, 1 reply; 10+ messages in thread
From: James Hilliard @ 2026-12-04 2:37 UTC (permalink / raw)
To: netdev, Maxime Chevallier, Andrew Lunn, David S. Miller,
Eric Dumazet, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, LABBE Corentin,
Willem de Bruijn, Nicolai Buchwitz
Cc: Jakub Kicinski, Oleksij Rempel, linux-arm-kernel, linux-sunxi,
James Hilliard
A link-up event can race with RX queue reconfiguration on sun8i. If
phylink reads RX_CTL1 before the queue stops RX DMA and writes its
pause settings afterward, it restores the old DMA enable bit. The
opposite ordering can lose the new pause thresholds.
Use the per-MAC register lock for live changes to RX_CTL1. The DMA
start, stop and mode callbacks and the phylink flow-control callback
now update only their own fields under that lock. Reset and core
initialization write the whole register before these users run.
Fixes: 22fc89783468 ("net: stmmac: dwmac-sun8i: emit pause frames when the RX FIFO fills")
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
drivers/net/ethernet/stmicro/stmmac/common.h | 6 +-
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 75 ++++++++++------------
.../net/ethernet/stmicro/stmmac/dwmac1000_core.c | 4 +-
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 4 +-
.../net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 4 +-
drivers/net/ethernet/stmicro/stmmac/hwif.c | 2 +-
drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c | 4 +-
7 files changed, 46 insertions(+), 53 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
index 95d272e87524..08de79107c50 100644
--- a/drivers/net/ethernet/stmicro/stmmac/common.h
+++ b/drivers/net/ethernet/stmicro/stmmac/common.h
@@ -655,10 +655,8 @@ struct mac_device_info {
bool additional_32_addr;
bool additional_64_addr;
- /* This spinlock protects read-modify-write of the interrupt
- * mask/enable registers.
- */
- spinlock_t irq_ctrl_lock;
+ /* Serializes updates to shared MAC control registers. */
+ spinlock_t reg_lock;
};
struct stmmac_rx_routing {
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index 8377dc798537..ada927fe943f 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
@@ -449,25 +445,28 @@ 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 mac_device_info *hw, u32 clear,
+ u32 set)
{
+ unsigned long flags;
u32 v;
- v = readl(ioaddr + EMAC_RX_CTL1);
- v |= EMAC_RX_DMA_START;
- v |= EMAC_RX_DMA_EN;
- writel(v, ioaddr + EMAC_RX_CTL1);
+ spin_lock_irqsave(&hw->reg_lock, flags);
+ v = readl(hw->pcsr + EMAC_RX_CTL1);
+ writel((v & ~clear) | set, hw->pcsr + EMAC_RX_CTL1);
+ spin_unlock_irqrestore(&hw->reg_lock, flags);
+}
+
+static void sun8i_dwmac_dma_start_rx(struct stmmac_priv *priv,
+ void __iomem *ioaddr, u32 chan)
+{
+ sun8i_dwmac_update_rx_ctl1(priv->hw, 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;
-
- v = readl(ioaddr + EMAC_RX_CTL1);
- v &= ~EMAC_RX_DMA_EN;
- writel(v, ioaddr + EMAC_RX_CTL1);
+ sun8i_dwmac_update_rx_ctl1(priv->hw, EMAC_RX_DMA_EN, 0);
}
static int sun8i_dwmac_dma_interrupt(struct stmmac_priv *priv,
@@ -546,24 +545,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;
- 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->hw, 0, EMAC_RX_MD);
+ return;
}
- writel(v, ioaddr + EMAC_RX_CTL1);
+
+ if (mode < 32 || mode >= 128)
+ threshold = EMAC_RX_TH_32;
+ else if (mode < 64)
+ threshold = EMAC_RX_TH_64;
+ else if (mode < 96)
+ threshold = EMAC_RX_TH_96;
+ else
+ threshold = EMAC_RX_TH_128;
+
+ sun8i_dwmac_update_rx_ctl1(priv->hw, EMAC_RX_MD | EMAC_RX_TH_MASK, threshold);
}
static void sun8i_dwmac_dma_operation_mode_tx(struct stmmac_priv *priv,
@@ -771,16 +769,13 @@ static void sun8i_dwmac_flow_ctrl(struct mac_device_info *hw,
v &= ~EMAC_RX_FLOW_CTL_EN;
writel(v, ioaddr + EMAC_RX_CTL0);
- v = readl(ioaddr + EMAC_RX_CTL1);
- v &= ~(EMAC_RX_FIFO_FLOW_CTL | EMAC_RX_FLOW_CTL_TH_ACT |
- EMAC_RX_FLOW_CTL_TH_DEACT);
+ v = 0;
if (fc & FLOW_TX)
- v |= EMAC_RX_FIFO_FLOW_CTL |
- FIELD_PREP(EMAC_RX_FLOW_CTL_TH_ACT,
- EMAC_RX_FLOW_CTL_TH_2K) |
- FIELD_PREP(EMAC_RX_FLOW_CTL_TH_DEACT,
- EMAC_RX_FLOW_CTL_TH_4K);
- writel(v, ioaddr + EMAC_RX_CTL1);
+ v = EMAC_RX_FIFO_FLOW_CTL |
+ FIELD_PREP(EMAC_RX_FLOW_CTL_TH_ACT, EMAC_RX_FLOW_CTL_TH_2K) |
+ FIELD_PREP(EMAC_RX_FLOW_CTL_TH_DEACT, EMAC_RX_FLOW_CTL_TH_4K);
+ sun8i_dwmac_update_rx_ctl1(hw, EMAC_RX_FIFO_FLOW_CTL | EMAC_RX_FLOW_CTL_TH_ACT |
+ EMAC_RX_FLOW_CTL_TH_DEACT, v);
v = readl(ioaddr + EMAC_TX_FLOW_CTL);
v &= ~(EMAC_TX_FLOW_CTL_EN | EMAC_TX_FLOW_CTL_ZQP_FRM_EN |
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
index 66337cfd9824..78eada27ef97 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
@@ -70,11 +70,11 @@ static void dwmac1000_irq_modify(struct mac_device_info *hw, u32 disable,
unsigned long flags;
u32 value;
- spin_lock_irqsave(&hw->irq_ctrl_lock, flags);
+ spin_lock_irqsave(&hw->reg_lock, flags);
value = readl(int_mask) | disable;
value &= ~enable;
writel(value, int_mask);
- spin_unlock_irqrestore(&hw->irq_ctrl_lock, flags);
+ spin_unlock_irqrestore(&hw->reg_lock, flags);
}
static int dwmac1000_rx_ipc_enable(struct mac_device_info *hw)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
index efbe2ec4c213..8a30856b3a79 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
@@ -71,11 +71,11 @@ static void dwmac4_irq_modify(struct mac_device_info *hw, u32 disable,
unsigned long flags;
u32 value;
- spin_lock_irqsave(&hw->irq_ctrl_lock, flags);
+ spin_lock_irqsave(&hw->reg_lock, flags);
value = readl(int_mask) & ~disable;
value |= enable;
writel(value, int_mask);
- spin_unlock_irqrestore(&hw->irq_ctrl_lock, flags);
+ spin_unlock_irqrestore(&hw->reg_lock, flags);
}
static void dwmac4_update_caps(struct stmmac_priv *priv)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
index d5bcbd6dfadf..ac8546b0778e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
@@ -36,11 +36,11 @@ static void dwxgmac2_irq_modify(struct mac_device_info *hw, u32 disable,
unsigned long flags;
u32 value;
- spin_lock_irqsave(&hw->irq_ctrl_lock, flags);
+ spin_lock_irqsave(&hw->reg_lock, flags);
value = readl(int_mask) & ~disable;
value |= enable;
writel(value, int_mask);
- spin_unlock_irqrestore(&hw->irq_ctrl_lock, flags);
+ spin_unlock_irqrestore(&hw->reg_lock, flags);
}
static void dwxgmac2_update_caps(struct stmmac_priv *priv)
diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.c b/drivers/net/ethernet/stmicro/stmmac/hwif.c
index 8d26b43ab2a6..df7ce8051ff5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/hwif.c
+++ b/drivers/net/ethernet/stmicro/stmmac/hwif.c
@@ -341,7 +341,7 @@ int stmmac_hwif_init(struct stmmac_priv *priv)
needs_setup = false;
}
- spin_lock_init(&mac->irq_ctrl_lock);
+ spin_lock_init(&mac->reg_lock);
/* Fallback to generic HW */
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c
index b6b5ef7c8fc4..8b1ad7e1445d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c
@@ -73,7 +73,7 @@ static void stmmac_fpe_configure_pmac(struct ethtool_mmsv *mmsv, bool pmac_enabl
unsigned long flags;
u32 value;
- spin_lock_irqsave(&priv->hw->irq_ctrl_lock, flags);
+ spin_lock_irqsave(&priv->hw->reg_lock, flags);
value = readl(ioaddr + reg->int_en_reg);
if (pmac_enable) {
@@ -88,7 +88,7 @@ static void stmmac_fpe_configure_pmac(struct ethtool_mmsv *mmsv, bool pmac_enabl
}
writel(value, ioaddr + reg->int_en_reg);
- spin_unlock_irqrestore(&priv->hw->irq_ctrl_lock, flags);
+ spin_unlock_irqrestore(&priv->hw->reg_lock, flags);
}
static void stmmac_fpe_send_mpacket(struct ethtool_mmsv *mmsv,
--
2.53.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH net-next v4 4/5] net: stmmac: add common RXALL handling
2026-12-04 2:37 [PATCH net-next v4 0/5] net: stmmac: support ethtool rx-all on sun8i James Hilliard
` (2 preceding siblings ...)
2026-12-04 2:37 ` [PATCH net-next v4 3/5] net: stmmac: dwmac-sun8i: serialize RX_CTL1 updates James Hilliard
@ 2026-12-04 2:37 ` 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
5 siblings, 1 reply; 10+ messages in thread
From: James Hilliard @ 2026-12-04 2:37 UTC (permalink / raw)
To: netdev, Maxime Chevallier, Andrew Lunn, David S. Miller,
Eric Dumazet, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, LABBE Corentin,
Willem de Bruijn, Nicolai Buchwitz
Cc: Jakub Kicinski, Oleksij Rempel, linux-arm-kernel, linux-sunxi,
James Hilliard
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 08de79107c50..91025ebd1afb 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,
};
/* Tx status */
diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h
index 6849b58ba2f8..5f910df7f765 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 99252fb83675..842d6d7f82a4 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -5652,10 +5652,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)
@@ -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)++;
+ 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];
@@ -5803,11 +5820,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);
@@ -6001,11 +6015,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) &&
@@ -6167,8 +6178,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;
@@ -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);
+
if (features & NETIF_F_HW_VLAN_CTAG_RX)
priv->hw->hw_vlan_en = true;
else
@@ -8282,6 +8300,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] 10+ messages in thread
* [PATCH net-next v4 5/5] net: stmmac: dwmac-sun8i: support ethtool rx-all
2026-12-04 2:37 [PATCH net-next v4 0/5] net: stmmac: support ethtool rx-all on sun8i James Hilliard
` (3 preceding siblings ...)
2026-12-04 2:37 ` [PATCH net-next v4 4/5] net: stmmac: add common RXALL handling James Hilliard
@ 2026-12-04 2:37 ` James Hilliard
2026-12-04 2:42 ` [PATCH net-next v4 0/5] net: stmmac: support ethtool rx-all on sun8i netdev-bot+sinfo
5 siblings, 0 replies; 10+ messages in thread
From: James Hilliard @ 2026-12-04 2:37 UTC (permalink / raw)
To: netdev, Maxime Chevallier, Andrew Lunn, David S. Miller,
Eric Dumazet, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, LABBE Corentin,
Willem de Bruijn, Nicolai Buchwitz
Cc: Jakub Kicinski, Oleksij Rempel, linux-arm-kernel, linux-sunxi,
James Hilliard
Allow packet captures to see complete frames that the sun8i MAC
forwards with wire errors. Mark these frames, including runts, as
errored with an unverified checksum so stmmac can deliver them when
rx-all is enabled. Incomplete frames and DMA errors still require a
drop.
Set runt forwarding from the rx-all setting at initialization and
update just that bit under the RX_CTL1 lock when the setting changes
on a running interface. Keep error forwarding enabled in both modes so
checksum failures still reach the stack.
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index ada927fe943f..51209d8cfbe8 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -194,6 +194,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
@@ -653,7 +654,16 @@ 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_rx_all(struct stmmac_priv *priv, bool enable)
+{
+ sun8i_dwmac_update_rx_ctl1(priv->hw, EMAC_RX_RUNT_FRM,
+ enable ? EMAC_RX_RUNT_FRM : 0);
}
static void sun8i_dwmac_set_mac(void __iomem *ioaddr, bool enable)
@@ -1067,6 +1077,7 @@ static const struct stmmac_ops sun8i_dwmac_ops = {
.dump_regs = sun8i_dwmac_dump_mac_regs,
.rx_ipc = sun8i_dwmac_rx_ipc,
.set_filter = sun8i_dwmac_set_filter,
+ .set_rx_all = sun8i_dwmac_set_rx_all,
.flow_ctrl = sun8i_dwmac_flow_ctrl,
.set_umac_addr = sun8i_dwmac_set_umac_addr,
.get_umac_addr = sun8i_dwmac_get_umac_addr,
@@ -1140,7 +1151,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. */
--
2.53.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH net-next v4 0/5] net: stmmac: support ethtool rx-all on sun8i
2026-12-04 2:37 [PATCH net-next v4 0/5] net: stmmac: support ethtool rx-all on sun8i James Hilliard
` (4 preceding siblings ...)
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 ` netdev-bot+sinfo
5 siblings, 0 replies; 10+ messages in thread
From: netdev-bot+sinfo @ 2026-12-04 2:42 UTC (permalink / raw)
To: James Hilliard
Cc: netdev, Maxime Chevallier, Andrew Lunn, David S. Miller,
Eric Dumazet, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, LABBE Corentin,
Willem de Bruijn, Nicolai Buchwitz, 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:
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by LLM and not proven at runtime). If it was triggered
please include the symptoms, like the stack trace or kernel messages.
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] 10+ messages in thread
* Re: [PATCH net-next v4 1/5] net: stmmac: dwmac-sun8i: deliver RX checksum errors to the stack
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
0 siblings, 0 replies; 10+ messages in thread
From: netdev-bot+sashiko @ 2026-12-05 2:52 UTC (permalink / raw)
To: james.hilliard1
Cc: netdev, maxime.chevallier, andrew+netdev, davem, edumazet, pabeni,
mcoquelin.stm32, alexandre.torgue, wens, jernej.skrabec, samuel,
clabbe.montjoie, willemb, nbb, 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] 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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net-next v4 3/5] net: stmmac: dwmac-sun8i: serialize RX_CTL1 updates
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
0 siblings, 0 replies; 10+ messages in thread
From: netdev-bot+sashiko @ 2026-12-05 2:52 UTC (permalink / raw)
To: james.hilliard1
Cc: netdev, maxime.chevallier, andrew+netdev, davem, edumazet, pabeni,
mcoquelin.stm32, alexandre.torgue, wens, jernej.skrabec, samuel,
clabbe.montjoie, willemb, nbb, 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 commit message says it closes the case where "a link-up
event can race with RX queue reconfiguration on sun8i".
- [Low] The subject and commit message describe a sun8i-only RX_CTL1 fix.
--
net: stmmac: dwmac-sun8i: serialize RX_CTL1 updates
This commit adds sun8i_dwmac_update_rx_ctl1(), which does the RX_CTL1
read-modify-write under a spinlock. The RX DMA start/stop, RX operation
mode and flow-control callbacks are converted to use it. It also renames
mac_device_info::irq_ctrl_lock to reg_lock and updates the generic
stmmac users of that lock.
> diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
> index 95d272e87524e..08de79107c503 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/common.h
> +++ b/drivers/net/ethernet/stmicro/stmmac/common.h
> @@ -655,10 +655,8 @@ struct mac_device_info {
> bool additional_32_addr;
> bool additional_64_addr;
>
> - /* This spinlock protects read-modify-write of the interrupt
> - * mask/enable registers.
> - */
> - spinlock_t irq_ctrl_lock;
> + /* Serializes updates to shared MAC control registers. */
> + spinlock_t reg_lock;
> };
[Severity: Low]
This isn't a bug, but the commit message doesn't mention this rename. It
says:
Use the per-MAC register lock for live changes to RX_CTL1.
That reads as if reg_lock already exists. In fact the patch renames the
generic irq_ctrl_lock to reg_lock and widens its documented purpose.
The rename touches code outside sun8i: dwmac1000_irq_modify(),
dwmac4_irq_modify(), dwxgmac2_irq_modify(), stmmac_fpe_configure_pmac()
and stmmac_hwif_init().
The rename has no functional effect. Still, it is extra core churn in a
Fixes-tagged dwmac-sun8i patch.
Could the lock be reused under its current irq_ctrl_lock name? If the
rename is wanted, could it go in a separate preparatory patch, or at
least be described in the commit message?
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> index 8377dc7985377..ada927fe943fb 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
[ ... ]
> @@ -771,16 +769,13 @@ static void sun8i_dwmac_flow_ctrl(struct mac_device_info *hw,
> v &= ~EMAC_RX_FLOW_CTL_EN;
> writel(v, ioaddr + EMAC_RX_CTL0);
>
> - v = readl(ioaddr + EMAC_RX_CTL1);
> - v &= ~(EMAC_RX_FIFO_FLOW_CTL | EMAC_RX_FLOW_CTL_TH_ACT |
> - EMAC_RX_FLOW_CTL_TH_DEACT);
> + v = 0;
> if (fc & FLOW_TX)
> - v |= EMAC_RX_FIFO_FLOW_CTL |
> - FIELD_PREP(EMAC_RX_FLOW_CTL_TH_ACT,
> - EMAC_RX_FLOW_CTL_TH_2K) |
> - FIELD_PREP(EMAC_RX_FLOW_CTL_TH_DEACT,
> - EMAC_RX_FLOW_CTL_TH_4K);
> - writel(v, ioaddr + EMAC_RX_CTL1);
> + v = EMAC_RX_FIFO_FLOW_CTL |
> + FIELD_PREP(EMAC_RX_FLOW_CTL_TH_ACT, EMAC_RX_FLOW_CTL_TH_2K) |
> + FIELD_PREP(EMAC_RX_FLOW_CTL_TH_DEACT, EMAC_RX_FLOW_CTL_TH_4K);
> + sun8i_dwmac_update_rx_ctl1(hw, EMAC_RX_FIFO_FLOW_CTL | EMAC_RX_FLOW_CTL_TH_ACT |
> + EMAC_RX_FLOW_CTL_TH_DEACT, v);
[Severity: Medium]
RX_CTL1 is now updated under reg_lock here. The RX_CTL0
read-modify-write just above it is still unlocked, though. Could the
link-up vs. RX reconfiguration race from the commit message lose the
EMAC_RX_FLOW_CTL_EN update?
sun8i_dwmac_set_mac() also does an unlocked read-modify-write of
RX_CTL0:
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c:sun8i_dwmac_set_mac() {
...
r = readl(ioaddr + EMAC_RX_CTL0);
if (enable) {
t |= EMAC_TX_TRANSMITTER_EN;
r |= EMAC_RX_RECEIVER_EN | EMAC_RX_DO_CRC;
...
writel(r, ioaddr + EMAC_RX_CTL0);
}
The link-up path runs from phylink_resolve(). It holds phydev->lock and
pl->state_mutex, but not rtnl:
phylink_resolve()
stmmac_mac_link_up()
stmmac_mac_flow_ctrl()
sun8i_dwmac_flow_ctrl()
The XDP reconfiguration path runs under rtnl only and does not stop
phylink:
stmmac_xdp_set_prog()
stmmac_xdp_release()
stmmac_mac_set(priv, priv->ioaddr, false)
stmmac_xdp_open()
stmmac_mac_set(priv, priv->ioaddr, true)
sun8i_dwmac_set_mac()
Consider this order:
1. sun8i_dwmac_set_mac(), called from stmmac_xdp_open(), reads RX_CTL0.
2. sun8i_dwmac_flow_ctrl() writes the newly negotiated
EMAC_RX_FLOW_CTL_EN.
3. sun8i_dwmac_set_mac() writes back its stale value.
The RX pause setting is then lost. The later sun8i_dwmac_set_mac(true)
call from link-up keeps the stale bit, so it would stay wrong until the
next link-up.
The RX_CTL0 read-modify-write in sun8i_dwmac_flow_ctrl() already existed
before the commit in the Fixes tag. However, the commit message says the
phylink flow-control callback now updates only its own fields under the
lock.
Would it make sense to also take reg_lock for RX_CTL0 in
sun8i_dwmac_flow_ctrl() and sun8i_dwmac_set_mac()?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203-submit-sun8i-rxall-v1-v4-0-af22aec6ae13%40gmail.com
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net-next v4 4/5] net: stmmac: add common RXALL handling
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
0 siblings, 0 replies; 10+ messages in thread
From: netdev-bot+sashiko @ 2026-12-05 2:52 UTC (permalink / raw)
To: james.hilliard1
Cc: netdev, maxime.chevallier, andrew+netdev, davem, edumazet, pabeni,
mcoquelin.stm32, alexandre.torgue, wens, jernej.skrabec, samuel,
clabbe.montjoie, willemb, nbb, 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] 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
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-12-05 2:53 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox