Skip to content

Commit 88824e3

Browse files
ozbenhdavem330
authored andcommitted
net: ethernet: ftgmac100: Fix DMA coherency issue with SW checksum
We are calling the checksum helper after the dma_map_single() call to map the packet. This is incorrect as the checksumming code will touch the packet from the CPU. This means the cache won't be properly flushes (or the bounce buffering will leave us with the unmodified packet to DMA). This moves the calculation of the checksum & vlan tags to before the DMA mapping. This also has the side effect of fixing another bug: If the checksum helper fails, we goto "drop" to drop the packet, which will not unmap the DMA mapping. Signed-off-by: Benjamin Herrenschmidt <[email protected]> Fixes: 05690d6 ("ftgmac100: Upgrade to NETIF_F_HW_CSUM") Reviewed-by: Vijay Khemka <[email protected]> Tested-by: Vijay Khemka <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 20eb4f2 commit 88824e3

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

drivers/net/ethernet/faraday/ftgmac100.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,18 @@ static netdev_tx_t ftgmac100_hard_start_xmit(struct sk_buff *skb,
727727
*/
728728
nfrags = skb_shinfo(skb)->nr_frags;
729729

730+
/* Setup HW checksumming */
731+
csum_vlan = 0;
732+
if (skb->ip_summed == CHECKSUM_PARTIAL &&
733+
!ftgmac100_prep_tx_csum(skb, &csum_vlan))
734+
goto drop;
735+
736+
/* Add VLAN tag */
737+
if (skb_vlan_tag_present(skb)) {
738+
csum_vlan |= FTGMAC100_TXDES1_INS_VLANTAG;
739+
csum_vlan |= skb_vlan_tag_get(skb) & 0xffff;
740+
}
741+
730742
/* Get header len */
731743
len = skb_headlen(skb);
732744

@@ -753,19 +765,6 @@ static netdev_tx_t ftgmac100_hard_start_xmit(struct sk_buff *skb,
753765
if (nfrags == 0)
754766
f_ctl_stat |= FTGMAC100_TXDES0_LTS;
755767
txdes->txdes3 = cpu_to_le32(map);
756-
757-
/* Setup HW checksumming */
758-
csum_vlan = 0;
759-
if (skb->ip_summed == CHECKSUM_PARTIAL &&
760-
!ftgmac100_prep_tx_csum(skb, &csum_vlan))
761-
goto drop;
762-
763-
/* Add VLAN tag */
764-
if (skb_vlan_tag_present(skb)) {
765-
csum_vlan |= FTGMAC100_TXDES1_INS_VLANTAG;
766-
csum_vlan |= skb_vlan_tag_get(skb) & 0xffff;
767-
}
768-
769768
txdes->txdes1 = cpu_to_le32(csum_vlan);
770769

771770
/* Next descriptor */

0 commit comments

Comments
 (0)