299928114743cfdaad9e86e4337972370b294bfe
[openwrt.git] / target / linux / mediatek / patches-4.4 / 0079-net-next-fix-BQL-support.patch
1 From f84a8ad5cc385fe414758fa4d423e26197a79c28 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/91] net-next: fix BQL support
5
6 Signed-off-by: John Crispin <blogic@openwrt.org>
7 ---
8  drivers/net/ethernet/mediatek/mtk_eth_soc.c |   33 +++++++++++++++------------
9  1 file changed, 19 insertions(+), 14 deletions(-)
10
11 diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
12 index bab5d45..ded09bc 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,15 @@ 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)));
18  
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
22 +        */
23 +       for (i = 0; i < MTK_MAC_COUNT; i++) {
24 +               if (!eth->netdev[i])
25 +                       continue;
26 +               netdev_sent_queue(dev, skb->len);
27 +       }
28 +
29         skb_tx_timestamp(skb);
30  
31         ring->next_free = mtk_qdma_phys_to_virt(ring, txd->txd2);
32 @@ -853,21 +861,18 @@ static int mtk_poll_tx(struct mtk_eth *eth, int budget, bool *tx_again)
33         struct mtk_tx_dma *desc;
34         struct sk_buff *skb;
35         struct mtk_tx_buf *tx_buf;
36 -       int total = 0, done[MTK_MAX_DEVS];
37 -       unsigned int bytes[MTK_MAX_DEVS];
38 +       int total = 0, done = 0;
39 +       unsigned int bytes = 0;
40         u32 cpu, dma;
41         static int condition;
42         int i;
43  
44 -       memset(done, 0, sizeof(done));
45 -       memset(bytes, 0, sizeof(bytes));
46 -
47         cpu = mtk_r32(eth, MTK_QTX_CRX_PTR);
48         dma = mtk_r32(eth, MTK_QTX_DRX_PTR);
49  
50         desc = mtk_qdma_phys_to_virt(ring, cpu);
51  
52 -       while ((cpu != dma) && budget) {
53 +       while ((cpu != dma) && done < budget) {
54                 u32 next_cpu = desc->txd2;
55                 int mac;
56  
57 @@ -887,9 +892,8 @@ static int mtk_poll_tx(struct mtk_eth *eth, int budget, bool *tx_again)
58                 }
59  
60                 if (skb != (struct sk_buff *)MTK_DMA_DUMMY_DESC) {
61 -                       bytes[mac] += skb->len;
62 -                       done[mac]++;
63 -                       budget--;
64 +                       bytes += skb->len;
65 +                       done++;
66                 }
67                 mtk_tx_unmap(eth->dev, tx_buf);
68  
69 @@ -902,13 +906,14 @@ static int mtk_poll_tx(struct mtk_eth *eth, int budget, bool *tx_again)
70  
71         mtk_w32(eth, cpu, MTK_QTX_CRX_PTR);
72  
73 +       /* we have a single DMA ring so BQL needs to be updated for all devices
74 +        * sitting on this ring
75 +        */
76         for (i = 0; i < MTK_MAC_COUNT; i++) {
77 -               if (!eth->netdev[i] || !done[i])
78 +               if (!eth->netdev[i])
79                         continue;
80 -               netdev_completed_queue(eth->netdev[i], done[i], bytes[i]);
81 -               total += done[i];
82 +               netdev_completed_queue(eth->netdev[i], done, bytes);
83         }
84 -
85         /* read hw index again make sure no new tx packet */
86         if (cpu != dma || cpu != mtk_r32(eth, MTK_QTX_DRX_PTR))
87                 *tx_again = true;
88 -- 
89 1.7.10.4
90