aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/marvell
diff options
context:
space:
mode:
authorKarl Beldan <karl.beldan@rivierawaves.com>2014-11-05 09:32:59 -0500
committerDavid S. Miller <davem@davemloft.net>2014-11-06 14:54:39 -0500
commit2c2a9cbd64387d6b70ac5db013e9bfe9412c7354 (patch)
tree24457fbbaab2016171b13aae6c2e105c082b8f2a /drivers/net/ethernet/marvell
parent66f1c44887ba4f47d617f8ae21cf8e04e1892bd7 (diff)
net: mv643xx_eth: reclaim TX skbs only when released by the HW
ATM, txq_reclaim will dequeue and free an skb for each tx desc released by the hw that has TX_LAST_DESC set. However, in case of TSO, each hw desc embedding the last part of a segment has TX_LAST_DESC set, losing the one-to-one 'last skb frag'/'TX_LAST_DESC set' correspondance, which causes data corruption. Fix this by checking TX_ENABLE_INTERRUPT instead of TX_LAST_DESC, and warn when trying to dequeue from an empty txq (which can be symptomatic of releasing skbs prematurely). Fixes: 3ae8f4e0b98 ('net: mv643xx_eth: Implement software TSO') Reported-by: Slawomir Gajzner <slawomir.gajzner@gmail.com> Reported-by: Julien D'Ascenzio <jdascenzio@yahoo.fr> Signed-off-by: Karl Beldan <karl.beldan@rivierawaves.com> Cc: Ian Campbell <ijc@hellion.org.uk> Cc: Eric Dumazet <eric.dumazet@gmail.com> Cc: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/marvell')
-rw-r--r--drivers/net/ethernet/marvell/mv643xx_eth.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index b151a949f352..d44560d1d268 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -1047,7 +1047,6 @@ static int txq_reclaim(struct tx_queue *txq, int budget, int force)
1047 int tx_index; 1047 int tx_index;
1048 struct tx_desc *desc; 1048 struct tx_desc *desc;
1049 u32 cmd_sts; 1049 u32 cmd_sts;
1050 struct sk_buff *skb;
1051 1050
1052 tx_index = txq->tx_used_desc; 1051 tx_index = txq->tx_used_desc;
1053 desc = &txq->tx_desc_area[tx_index]; 1052 desc = &txq->tx_desc_area[tx_index];
@@ -1066,19 +1065,22 @@ static int txq_reclaim(struct tx_queue *txq, int budget, int force)
1066 reclaimed++; 1065 reclaimed++;
1067 txq->tx_desc_count--; 1066 txq->tx_desc_count--;
1068 1067
1069 skb = NULL; 1068 if (!IS_TSO_HEADER(txq, desc->buf_ptr))
1070 if (cmd_sts & TX_LAST_DESC) 1069 dma_unmap_single(mp->dev->dev.parent, desc->buf_ptr,
1071 skb = __skb_dequeue(&txq->tx_skb); 1070 desc->byte_cnt, DMA_TO_DEVICE);
1071
1072 if (cmd_sts & TX_ENABLE_INTERRUPT) {
1073 struct sk_buff *skb = __skb_dequeue(&txq->tx_skb);
1074
1075 if (!WARN_ON(!skb))
1076 dev_kfree_skb(skb);
1077 }
1072 1078
1073 if (cmd_sts & ERROR_SUMMARY) { 1079 if (cmd_sts & ERROR_SUMMARY) {
1074 netdev_info(mp->dev, "tx error\n"); 1080 netdev_info(mp->dev, "tx error\n");
1075 mp->dev->stats.tx_errors++; 1081 mp->dev->stats.tx_errors++;
1076 } 1082 }
1077 1083
1078 if (!IS_TSO_HEADER(txq, desc->buf_ptr))
1079 dma_unmap_single(mp->dev->dev.parent, desc->buf_ptr,
1080 desc->byte_cnt, DMA_TO_DEVICE);
1081 dev_kfree_skb(skb);
1082 } 1084 }
1083 1085
1084 __netif_tx_unlock_bh(nq); 1086 __netif_tx_unlock_bh(nq);