[PATCH v2] net: stmmac: Disable checksum insertion for XDP frame TX

From: Jisheng Zhang

Date: Mon Nov 16 2026 - 09:09:12 EST


stmmac enables TX checksum insertion for XDP frames whenever the queue
supports it. XDP frames carry no TX checksum offload request, so this
can overwrite a checksum already present in the packet.

dwmac can only do HW checksum for normal particular packets
layouts, such as TCP, UDP etc. The stmmac_has_ip_ethertype() has
well demostrated this limitation. Different with normal tx where the
common stack supplies the skb->ip_summed metadata, XDP path doesn't
have the necessary metadata. So to make the XDP always work properly
when transmiting arbitrary Eth frames, dwmac HW csum needs to be
disabled by default.

Pass false to stmmac_prepare_tx_desc() when transmitting an XDP frame
so that the packet is sent with its checksum fields unchanged.

Fixes: be8b38a722e6 ("net: stmmac: Add support for XDP_TX action")
Fixes: 8b278a5b69a2 ("net: stmmac: Add support for XDP_REDIRECT action")
Signed-off-by: Jisheng Zhang <jszhang@xxxxxxxxxx>
---

since v1:
- rebase against latest rcN
- update the commit msg

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 3014f9c7c3e6..0545f086212e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -5284,7 +5284,6 @@ static int stmmac_xdp_xmit_xdpf(struct stmmac_priv *priv, int queue,
{
struct skb_shared_info *sinfo = xdp_get_shared_info_from_frame(xdpf);
struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[queue];
- bool csum = !priv->plat->tx_queues_cfg[queue].coe_unsupported;
unsigned int txq_thr = STMMAC_TX_THRESH(priv);
unsigned int first_entry = tx_q->cur_tx;
unsigned int entry = tx_q->cur_tx;
@@ -5306,14 +5305,6 @@ static int stmmac_xdp_xmit_xdpf(struct stmmac_priv *priv, int queue,
return STMMAC_XDP_CONSUMED;
}

- /* Disable TX checksum offload for jumbo frames on cores where
- * checksum insertion is broken for oversized frames, matching the
- * stmmac_fix_features() workaround used by the skb path.
- */
- if (priv->plat->bugged_jumbo &&
- xdp_get_frame_len(xdpf) > ETH_FRAME_LEN)
- csum = false;
-
while (true) {
skb_frag_t *frag = i ? &sinfo->frags[i - 1] : NULL;
int len = frag ? skb_frag_size(frag) : xdpf->len;
@@ -5353,7 +5344,7 @@ static int stmmac_xdp_xmit_xdpf(struct stmmac_priv *priv, int queue,
stmmac_set_tx_dma_entry(tx_q, entry, buf_type, dma_addr, len,
dma_map && frag);
stmmac_set_desc_addr(priv, desc, dma_addr);
- stmmac_prepare_tx_desc(priv, desc, !i, len, csum,
+ stmmac_prepare_tx_desc(priv, desc, !i, len, false,
priv->descriptor_mode, !!i, last_frame,
xdp_get_frame_len(xdpf));
tx_q->xdpf[entry] = last_frame ? xdpf : NULL;
--
2.55.0