net: stmmac: Disable checksum insertion for XDP frame TX
Subsystems (4)
PATCH v2 1/1 net: stmmac: Disable checksum insertion for XDP frame TX
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.
---
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(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1 -10
@@ -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 ;
Signature · 1 line
2.55.0
[email protected]
AI reviewThis is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
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.
- 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.
- What hardware the change was tested on. For driver fixes please mention the device (and if relevant firmware version) used for testing, or say that the change was not tested on real hardware.
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.
Signature · 2 lines
The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
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 hard-codes csum=false in stmmac_xdp_xmit_xdpf() (drivers/net/ethernet/stmicro/stmmac/stmmac_main.c).
--
net: stmmac: Disable checksum insertion for XDP frame TX
This commit stops stmmac from requesting hardware checksum insertion for frames sent through XDP_TX and ndo_xdp_xmit. It does this by passing false as the csum argument to stmmac_prepare_tx_desc() in stmmac_xdp_xmit_xdpf(). The bugged_jumbo special case is removed because it is no longer needed.
Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0
-1@@ -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;
[ ... ]
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static int stmmac_xdp_xmit_xdpf(struct stmmac_priv *priv, int queue, · line 5349
Quoted 8 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-1@@ -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));
[Severity: Medium]
Could this break existing XDP setups that rely on the MAC to fix up checksums?
Since be8b38a722e6 and 8b278a5b69a2, stmmac_xdp_xmit_xdpf() has asked for hardware checksum insertion on every XDP_TX and redirected frame. At first it passed true, and since b1eded580ab2 it has passed:
!priv->plat->tx_queues_cfg[queue].coe_unsupported
Some XDP programs rewrite L3/L4 headers without updating the checksums, for example NAT, L4 load balancers that rewrite addresses or ports, and encapsulation. On COE-capable dwmac queues these have worked because the hardware recomputed the checksums. With csum hard-coded to false, it looks like those frames would go out with stale checksums and receivers would drop them.
The code change itself seems reasonable, given the stmmac_has_ip_ethertype() limitation and the lack of checksum metadata on XDP frames. The concern is how the change is labelled.
The commit carries two Fixes: tags pointing at 2021 commits and has no stable annotation, so it is likely to be picked up for stable backports. The commit message says the packet is sent "with its checksum fields unchanged", but it doesn't mention that this changes on-wire behaviour for existing users.
For comparison, the earlier commit ecf5985006dd ("net: stmmac: Disable unsolicited checksum insertion for AF_XDP TX") made the same kind of change on the AF_XDP zero-copy path. That commit included:
and the note "Applications must supply complete checksums".
Would it make sense to add a similar noautosel annotation here? Should the commit message also say that XDP programs must now supply complete checksums?
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116134848.4793-1-jszhang%40kernel.org