Skip to content

Commit de0337d

Browse files
mohammadheibkuba-moo
authored andcommitted
net: ionic: map SKB after pseudo-header checksum prep
The TSO path called ionic_tx_map_skb() before preparing the TCP pseudo checksum (ionic_tx_tcp_[inner_]pseudo_csum()), which may perform skb_cow_head() and might modifies bytes in the linear header area. Mapping first and then mutating the header risks: - Using a stale DMA address if skb_cow_head() relocates the head, and/or - Device reading stale header bytes on weakly-ordered systems (CPU writes after mapping are not guaranteed visible without an explicit dma_sync_single_for_device()). Reorder the TX path to perform all header mutations (including skb_cow_head()) *before* DMA mapping. Mapping is now done only after the skb layout and header contents are final. This removes the need for any post-mapping dma_sync and prevents on-wire corruption observed under VLAN+TSO load after repeated runs. This change is purely an ordering fix; no functional behavior change otherwise. Fixes: 0f3154e ("ionic: Add Tx and Rx handling") Signed-off-by: Mohammad Heib <mheib@redhat.com> Reviewed-by: Brett Creeley <brett.creeley@amd.com> Link: https://patch.msgid.link/20251031155203.203031-2-mheib@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent d261f5b commit de0337d

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

drivers/net/ethernet/pensando/ionic/ionic_txrx.c

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,19 +1448,6 @@ static int ionic_tx_tso(struct net_device *netdev, struct ionic_queue *q,
14481448
bool encap;
14491449
int err;
14501450

1451-
desc_info = &q->tx_info[q->head_idx];
1452-
1453-
if (unlikely(ionic_tx_map_skb(q, skb, desc_info)))
1454-
return -EIO;
1455-
1456-
len = skb->len;
1457-
mss = skb_shinfo(skb)->gso_size;
1458-
outer_csum = (skb_shinfo(skb)->gso_type & (SKB_GSO_GRE |
1459-
SKB_GSO_GRE_CSUM |
1460-
SKB_GSO_IPXIP4 |
1461-
SKB_GSO_IPXIP6 |
1462-
SKB_GSO_UDP_TUNNEL |
1463-
SKB_GSO_UDP_TUNNEL_CSUM));
14641451
has_vlan = !!skb_vlan_tag_present(skb);
14651452
vlan_tci = skb_vlan_tag_get(skb);
14661453
encap = skb->encapsulation;
@@ -1474,12 +1461,21 @@ static int ionic_tx_tso(struct net_device *netdev, struct ionic_queue *q,
14741461
err = ionic_tx_tcp_inner_pseudo_csum(skb);
14751462
else
14761463
err = ionic_tx_tcp_pseudo_csum(skb);
1477-
if (unlikely(err)) {
1478-
/* clean up mapping from ionic_tx_map_skb */
1479-
ionic_tx_desc_unmap_bufs(q, desc_info);
1464+
if (unlikely(err))
14801465
return err;
1481-
}
14821466

1467+
desc_info = &q->tx_info[q->head_idx];
1468+
if (unlikely(ionic_tx_map_skb(q, skb, desc_info)))
1469+
return -EIO;
1470+
1471+
len = skb->len;
1472+
mss = skb_shinfo(skb)->gso_size;
1473+
outer_csum = (skb_shinfo(skb)->gso_type & (SKB_GSO_GRE |
1474+
SKB_GSO_GRE_CSUM |
1475+
SKB_GSO_IPXIP4 |
1476+
SKB_GSO_IPXIP6 |
1477+
SKB_GSO_UDP_TUNNEL |
1478+
SKB_GSO_UDP_TUNNEL_CSUM));
14831479
if (encap)
14841480
hdrlen = skb_inner_tcp_all_headers(skb);
14851481
else

0 commit comments

Comments
 (0)