525882c956b2df853e1cf9d95a5703744bcfb1c6
[openwrt/staging/stintel.git] /
1 From: Lorenzo Bianconi <lorenzo@kernel.org>
2 Date: Fri, 20 May 2022 20:11:32 +0200
3 Subject: [PATCH] net: ethernet: mtk_eth_soc: add rxd_size to mtk_soc_data
4
5 Similar to tx counterpart, introduce rxd_size in mtk_soc_data data
6 structure.
7 This is a preliminary patch to add mt7986 ethernet support.
8
9 Tested-by: Sam Shih <sam.shih@mediatek.com>
10 Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
11 Signed-off-by: David S. Miller <davem@davemloft.net>
12 ---
13
14 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
15 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
16 @@ -1776,7 +1776,7 @@ static int mtk_rx_alloc(struct mtk_eth *
17 }
18
19 ring->dma = dma_alloc_coherent(eth->dma_dev,
20 - rx_dma_size * sizeof(*ring->dma),
21 + rx_dma_size * eth->soc->txrx.rxd_size,
22 &ring->phys, GFP_KERNEL);
23 if (!ring->dma)
24 return -ENOMEM;
25 @@ -1834,9 +1834,8 @@ static void mtk_rx_clean(struct mtk_eth
26
27 if (ring->dma) {
28 dma_free_coherent(eth->dma_dev,
29 - ring->dma_size * sizeof(*ring->dma),
30 - ring->dma,
31 - ring->phys);
32 + ring->dma_size * eth->soc->txrx.rxd_size,
33 + ring->dma, ring->phys);
34 ring->dma = NULL;
35 }
36 }
37 @@ -3402,6 +3401,7 @@ static const struct mtk_soc_data mt2701_
38 .required_pctl = true,
39 .txrx = {
40 .txd_size = sizeof(struct mtk_tx_dma),
41 + .rxd_size = sizeof(struct mtk_rx_dma),
42 },
43 };
44
45 @@ -3413,6 +3413,7 @@ static const struct mtk_soc_data mt7621_
46 .offload_version = 2,
47 .txrx = {
48 .txd_size = sizeof(struct mtk_tx_dma),
49 + .rxd_size = sizeof(struct mtk_rx_dma),
50 },
51 };
52
53 @@ -3425,6 +3426,7 @@ static const struct mtk_soc_data mt7622_
54 .offload_version = 2,
55 .txrx = {
56 .txd_size = sizeof(struct mtk_tx_dma),
57 + .rxd_size = sizeof(struct mtk_rx_dma),
58 },
59 };
60
61 @@ -3436,6 +3438,7 @@ static const struct mtk_soc_data mt7623_
62 .offload_version = 2,
63 .txrx = {
64 .txd_size = sizeof(struct mtk_tx_dma),
65 + .rxd_size = sizeof(struct mtk_rx_dma),
66 },
67 };
68
69 @@ -3447,6 +3450,7 @@ static const struct mtk_soc_data mt7629_
70 .required_pctl = false,
71 .txrx = {
72 .txd_size = sizeof(struct mtk_tx_dma),
73 + .rxd_size = sizeof(struct mtk_rx_dma),
74 },
75 };
76
77 @@ -3457,6 +3461,7 @@ static const struct mtk_soc_data rt5350_
78 .required_pctl = false,
79 .txrx = {
80 .txd_size = sizeof(struct mtk_tx_dma),
81 + .rxd_size = sizeof(struct mtk_rx_dma),
82 },
83 };
84
85 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
86 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
87 @@ -865,6 +865,7 @@ struct mtk_tx_dma_desc_info {
88 * @required_pctl A bool value to show whether the SoC requires
89 * the extra setup for those pins used by GMAC.
90 * @txd_size Tx DMA descriptor size.
91 + * @rxd_size Rx DMA descriptor size.
92 */
93 struct mtk_soc_data {
94 u32 ana_rgc3;
95 @@ -875,6 +876,7 @@ struct mtk_soc_data {
96 netdev_features_t hw_features;
97 struct {
98 u32 txd_size;
99 + u32 rxd_size;
100 } txrx;
101 };
102