提交 189982d1 编写于 作者: B Benjamin Herrenschmidt 提交者: Greg Kroah-Hartman

net: ethernet: ftgmac100: Fix DMA coherency issue with SW checksum

[ Upstream commit 88824e3bf29a2fcacfd9ebbfe03063649f0f3254 ]

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: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
Fixes: 05690d63 ("ftgmac100: Upgrade to NETIF_F_HW_CSUM")
Reviewed-by: NVijay Khemka <vijaykhemka@fb.com>
Tested-by: NVijay Khemka <vijaykhemka@fb.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 5536fc89
...@@ -739,6 +739,18 @@ static int ftgmac100_hard_start_xmit(struct sk_buff *skb, ...@@ -739,6 +739,18 @@ static int ftgmac100_hard_start_xmit(struct sk_buff *skb,
*/ */
nfrags = skb_shinfo(skb)->nr_frags; nfrags = skb_shinfo(skb)->nr_frags;
/* Setup HW checksumming */
csum_vlan = 0;
if (skb->ip_summed == CHECKSUM_PARTIAL &&
!ftgmac100_prep_tx_csum(skb, &csum_vlan))
goto drop;
/* Add VLAN tag */
if (skb_vlan_tag_present(skb)) {
csum_vlan |= FTGMAC100_TXDES1_INS_VLANTAG;
csum_vlan |= skb_vlan_tag_get(skb) & 0xffff;
}
/* Get header len */ /* Get header len */
len = skb_headlen(skb); len = skb_headlen(skb);
...@@ -765,19 +777,6 @@ static int ftgmac100_hard_start_xmit(struct sk_buff *skb, ...@@ -765,19 +777,6 @@ static int ftgmac100_hard_start_xmit(struct sk_buff *skb,
if (nfrags == 0) if (nfrags == 0)
f_ctl_stat |= FTGMAC100_TXDES0_LTS; f_ctl_stat |= FTGMAC100_TXDES0_LTS;
txdes->txdes3 = cpu_to_le32(map); txdes->txdes3 = cpu_to_le32(map);
/* Setup HW checksumming */
csum_vlan = 0;
if (skb->ip_summed == CHECKSUM_PARTIAL &&
!ftgmac100_prep_tx_csum(skb, &csum_vlan))
goto drop;
/* Add VLAN tag */
if (skb_vlan_tag_present(skb)) {
csum_vlan |= FTGMAC100_TXDES1_INS_VLANTAG;
csum_vlan |= skb_vlan_tag_get(skb) & 0xffff;
}
txdes->txdes1 = cpu_to_le32(csum_vlan); txdes->txdes1 = cpu_to_le32(csum_vlan);
/* Next descriptor */ /* Next descriptor */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册