1 From d449af97701c1da5b373df5a7675b93b9a2067bf Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Sat, 23 Apr 2016 11:57:21 +0200
4 Subject: [PATCH 79/90] net-next: mediatek: fix BQL support
6 Signed-off-by: John Crispin <blogic@openwrt.org>
8 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 33 ++++++++++++++++-----------
9 1 file changed, 20 insertions(+), 13 deletions(-)
11 diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
12 index bab5d45..9928a79 100644
13 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
14 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
15 @@ -625,7 +625,16 @@ static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev,
16 WRITE_ONCE(itxd->txd3, (TX_DMA_SWC | TX_DMA_PLEN0(skb_headlen(skb)) |
17 (!nr_frags * TX_DMA_LS0)));
19 - netdev_sent_queue(dev, skb->len);
20 + /* we have a single DMA ring so BQL needs to be updated for all devices
21 + * sitting on this ring
23 + for (i = 0; i < MTK_MAC_COUNT; i++) {
24 + if (!eth->netdev[i])
27 + netdev_sent_queue(eth->netdev[i], skb->len);
30 skb_tx_timestamp(skb);
32 ring->next_free = mtk_qdma_phys_to_virt(ring, txd->txd2);
33 @@ -853,21 +862,18 @@ static int mtk_poll_tx(struct mtk_eth *eth, int budget, bool *tx_again)
34 struct mtk_tx_dma *desc;
36 struct mtk_tx_buf *tx_buf;
37 - int total = 0, done[MTK_MAX_DEVS];
38 - unsigned int bytes[MTK_MAX_DEVS];
39 + int total = 0, done = 0;
40 + unsigned int bytes = 0;
45 - memset(done, 0, sizeof(done));
46 - memset(bytes, 0, sizeof(bytes));
48 cpu = mtk_r32(eth, MTK_QTX_CRX_PTR);
49 dma = mtk_r32(eth, MTK_QTX_DRX_PTR);
51 desc = mtk_qdma_phys_to_virt(ring, cpu);
53 - while ((cpu != dma) && budget) {
54 + while ((cpu != dma) && done < budget) {
55 u32 next_cpu = desc->txd2;
58 @@ -887,9 +893,8 @@ static int mtk_poll_tx(struct mtk_eth *eth, int budget, bool *tx_again)
61 if (skb != (struct sk_buff *)MTK_DMA_DUMMY_DESC) {
62 - bytes[mac] += skb->len;
68 mtk_tx_unmap(eth->dev, tx_buf);
70 @@ -902,11 +907,13 @@ static int mtk_poll_tx(struct mtk_eth *eth, int budget, bool *tx_again)
72 mtk_w32(eth, cpu, MTK_QTX_CRX_PTR);
74 + /* we have a single DMA ring so BQL needs to be updated for all devices
75 + * sitting on this ring
77 for (i = 0; i < MTK_MAC_COUNT; i++) {
78 - if (!eth->netdev[i] || !done[i])
79 + if (!eth->netdev[i])
81 - netdev_completed_queue(eth->netdev[i], done[i], bytes[i]);
83 + netdev_completed_queue(eth->netdev[i], done, bytes);
86 /* read hw index again make sure no new tx packet */