4fb7d0767b1d1687c80427c32c0d07ecc3c0721a
[openwrt/staging/jow.git] /
1 From 14d4e308e0aa0b78dc7a059716861a4380de3535 Mon Sep 17 00:00:00 2001
2 From: Aleksander Jan Bajkowski <olek2@wp.pl>
3 Date: Tue, 14 Sep 2021 23:21:02 +0200
4 Subject: [PATCH 5/5] net: lantiq: configure the burst length in ethernet
5 drivers
6
7 Configure the burst length in Ethernet drivers. This improves
8 Ethernet performance by 58%. According to the vendor BSP,
9 8W burst length is supported by ar9 and newer SoCs.
10
11 The NAT benchmark results on xRX200 (Down/Up):
12 * 2W: 330 Mb/s
13 * 4W: 432 Mb/s 372 Mb/s
14 * 8W: 520 Mb/s 389 Mb/s
15
16 Tested on xRX200 and xRX330.
17
18 Signed-off-by: Aleksander Jan Bajkowski <olek2@wp.pl>
19 Signed-off-by: David S. Miller <davem@davemloft.net>
20 ---
21 drivers/net/ethernet/lantiq_etop.c | 21 ++++++++++++++++++---
22 drivers/net/ethernet/lantiq_xrx200.c | 21 ++++++++++++++++++---
23 2 files changed, 36 insertions(+), 6 deletions(-)
24
25 --- a/drivers/net/ethernet/lantiq_etop.c
26 +++ b/drivers/net/ethernet/lantiq_etop.c
27 @@ -148,6 +148,9 @@ struct ltq_etop_priv {
28 struct ltq_etop_chan txch;
29 struct ltq_etop_chan rxch;
30
31 + int tx_burst_len;
32 + int rx_burst_len;
33 +
34 int tx_irq;
35 int rx_irq;
36
37 @@ -399,7 +402,7 @@ ltq_etop_dma_init(struct net_device *dev
38 int rx = priv->rx_irq - LTQ_DMA_ETOP;
39 int err;
40
41 - ltq_dma_init_port(DMA_PORT_ETOP);
42 + ltq_dma_init_port(DMA_PORT_ETOP, priv->tx_burst_len, rx_burst_len);
43
44 priv->txch.dma.nr = tx;
45 priv->txch.dma.dev = &priv->pdev->dev;
46 @@ -676,8 +679,8 @@ ltq_etop_tx(struct sk_buff *skb, struct
47 return NETDEV_TX_BUSY;
48 }
49
50 - /* dma needs to start on a 16 byte aligned address */
51 - byte_offset = CPHYSADDR(skb->data) % 16;
52 + /* dma needs to start on a burst length value aligned address */
53 + byte_offset = CPHYSADDR(skb->data) % (priv->tx_burst_len * 4);
54 priv->txch.skb[priv->txch.dma.desc] = skb;
55
56 netif_trans_update(dev);
57 @@ -925,6 +928,18 @@ static int ltq_etop_probe(struct platfor
58 spin_lock_init(&priv->lock);
59 SET_NETDEV_DEV(dev, &pdev->dev);
60
61 + err = device_property_read_u32(&pdev->dev, "lantiq,tx-burst-length", &priv->tx_burst_len);
62 + if (err < 0) {
63 + dev_err(&pdev->dev, "unable to read tx-burst-length property\n");
64 + return err;
65 + }
66 +
67 + err = device_property_read_u32(&pdev->dev, "lantiq,rx-burst-length", &priv->rx_burst_len);
68 + if (err < 0) {
69 + dev_err(&pdev->dev, "unable to read rx-burst-length property\n");
70 + return err;
71 + }
72 +
73 netif_napi_add(dev, &priv->txch.napi, ltq_etop_poll_tx, 8);
74 netif_napi_add(dev, &priv->rxch.napi, ltq_etop_poll_rx, 32);
75 priv->txch.netdev = dev;
76 --- a/drivers/net/ethernet/lantiq_xrx200.c
77 +++ b/drivers/net/ethernet/lantiq_xrx200.c
78 @@ -81,6 +81,9 @@ struct xrx200_priv {
79 struct net_device *net_dev;
80 struct device *dev;
81
82 + int tx_burst_len;
83 + int rx_burst_len;
84 +
85 __iomem void *pmac_reg;
86 };
87
88 @@ -363,8 +366,8 @@ static netdev_tx_t xrx200_start_xmit(str
89 if (unlikely(dma_mapping_error(priv->dev, mapping)))
90 goto err_drop;
91
92 - /* dma needs to start on a 16 byte aligned address */
93 - byte_offset = mapping % 16;
94 + /* dma needs to start on a burst length value aligned address */
95 + byte_offset = mapping % (priv->tx_burst_len * 4);
96
97 desc->addr = mapping - byte_offset;
98 /* Make sure the address is written before we give it to HW */
99 @@ -465,7 +468,7 @@ static int xrx200_dma_init(struct xrx200
100 int ret = 0;
101 int i;
102
103 - ltq_dma_init_port(DMA_PORT_ETOP);
104 + ltq_dma_init_port(DMA_PORT_ETOP, priv->tx_burst_len, rx_burst_len);
105
106 ch_rx->dma.nr = XRX200_DMA_RX;
107 ch_rx->dma.dev = priv->dev;
108 @@ -584,6 +587,18 @@ static int xrx200_probe(struct platform_
109 if (err)
110 eth_hw_addr_random(net_dev);
111
112 + err = device_property_read_u32(dev, "lantiq,tx-burst-length", &priv->tx_burst_len);
113 + if (err < 0) {
114 + dev_err(dev, "unable to read tx-burst-length property\n");
115 + return err;
116 + }
117 +
118 + err = device_property_read_u32(dev, "lantiq,rx-burst-length", &priv->rx_burst_len);
119 + if (err < 0) {
120 + dev_err(dev, "unable to read rx-burst-length property\n");
121 + return err;
122 + }
123 +
124 /* bring up the dma engine and IP core */
125 err = xrx200_dma_init(priv);
126 if (err)