Skip to content

Commit 5c69e0b

Browse files
committed
Merge branch 'stmmac-stop-silently-dropping-bad-checksum-packets'
Oleksij Rempel says: ==================== stmmac: stop silently dropping bad checksum packets this series reworks how stmmac handles receive checksum offload (CoE) errors on dwmac4. At present, when CoE is enabled, the hardware silently discards any frame that fails checksum validation. These packets never reach the driver and are not accounted in the generic drop statistics. They are only visible in the stmmac-specific counters as "payload error" or "header error" packets, which makes it harder to debug or monitor network issues. Following discussion [1], the driver is reworked to propagate checksum error information up to the stack. With these changes, CoE stays enabled, but frames that fail hardware validation are no longer dropped in hardware. Instead, the driver marks them with CHECKSUM_NONE so the network stack can validate, drop, and properly account them in the standard drop statistics. [1] https://lore.kernel.org/all/[email protected]/ ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 8beead2 + fe40427 commit 5c69e0b

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

drivers/net/ethernet/stmicro/stmmac/dwmac4.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ static inline u32 mtl_chanx_base_addr(const struct dwmac4_addrs *addrs,
341341
#define MTL_OP_MODE_RFA_SHIFT 8
342342

343343
#define MTL_OP_MODE_EHFC BIT(7)
344+
#define MTL_OP_MODE_DIS_TCP_EF BIT(6)
344345

345346
#define MTL_OP_MODE_RTC_MASK GENMASK(1, 0)
346347
#define MTL_OP_MODE_RTC_SHIFT 0

drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,20 @@ static int dwmac4_wrback_get_rx_status(struct stmmac_extra_stats *x,
110110

111111
message_type = (rdes1 & ERDES4_MSG_TYPE_MASK) >> 8;
112112

113-
if (rdes1 & RDES1_IP_HDR_ERROR)
113+
if (rdes1 & RDES1_IP_HDR_ERROR) {
114114
x->ip_hdr_err++;
115+
ret |= csum_none;
116+
}
115117
if (rdes1 & RDES1_IP_CSUM_BYPASSED)
116118
x->ip_csum_bypassed++;
117119
if (rdes1 & RDES1_IPV4_HEADER)
118120
x->ipv4_pkt_rcvd++;
119121
if (rdes1 & RDES1_IPV6_HEADER)
120122
x->ipv6_pkt_rcvd++;
121-
if (rdes1 & RDES1_IP_PAYLOAD_ERROR)
123+
if (rdes1 & RDES1_IP_PAYLOAD_ERROR) {
122124
x->ip_payload_err++;
125+
ret |= csum_none;
126+
}
123127

124128
if (message_type == RDES_EXT_NO_PTP)
125129
x->no_ptp_rx_msg_type_ext++;

drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ static void dwmac4_dma_rx_chan_op_mode(struct stmmac_priv *priv,
268268

269269
mtl_rx_op = readl(ioaddr + MTL_CHAN_RX_OP_MODE(dwmac4_addrs, channel));
270270

271+
mtl_rx_op |= MTL_OP_MODE_DIS_TCP_EF;
272+
271273
if (mode == SF_DMA_MODE) {
272274
pr_debug("GMAC: enable RX store and forward mode\n");
273275
mtl_rx_op |= MTL_OP_MODE_RSF;

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5737,7 +5737,8 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
57375737

57385738
skb->protocol = eth_type_trans(skb, priv->dev);
57395739

5740-
if (unlikely(!coe) || !stmmac_has_ip_ethertype(skb))
5740+
if (unlikely(!coe) || !stmmac_has_ip_ethertype(skb) ||
5741+
(status & csum_none))
57415742
skb_checksum_none_assert(skb);
57425743
else
57435744
skb->ip_summed = CHECKSUM_UNNECESSARY;

0 commit comments

Comments
 (0)