Skip to content

Commit 60e80e6

Browse files
ozbenhgregkh
authored andcommitted
net: ethernet: ftgmac100: Fix DMA coherency issue with SW checksum
[ Upstream commit 88824e3 ] 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 <benh@kernel.crashing.org> Fixes: 05690d6 ("ftgmac100: Upgrade to NETIF_F_HW_CSUM") Reviewed-by: Vijay Khemka <vijaykhemka@fb.com> Tested-by: Vijay Khemka <vijaykhemka@fb.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent efa7057 commit 60e80e6

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

‎drivers/net/ethernet/faraday/ftgmac100.c‎

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

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

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

770769
/* Next descriptor */

0 commit comments

Comments
 (0)