eb92b8c7a22e8d5186806918064006598a3b00ca
[openwrt/staging/jogo.git] /
1 From: Lorenzo Bianconi <lorenzo@kernel.org>
2 Date: Fri, 20 May 2022 20:11:33 +0200
3 Subject: [PATCH] net: ethernet: mtk_eth_soc: rely on txd_size field in
4 mtk_poll_tx/mtk_poll_rx
5
6 This is a preliminary to ad mt7986 ethernet support.
7
8 Tested-by: Sam Shih <sam.shih@mediatek.com>
9 Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
10 Signed-off-by: David S. Miller <davem@davemloft.net>
11 ---
12
13 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
14 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
15 @@ -1265,9 +1265,12 @@ static struct mtk_rx_ring *mtk_get_rx_ri
16 return &eth->rx_ring[0];
17
18 for (i = 0; i < MTK_MAX_RX_RING_NUM; i++) {
19 + struct mtk_rx_dma *rxd;
20 +
21 ring = &eth->rx_ring[i];
22 idx = NEXT_DESP_IDX(ring->calc_idx, ring->dma_size);
23 - if (ring->dma[idx].rxd2 & RX_DMA_DONE) {
24 + rxd = (void *)ring->dma + idx * eth->soc->txrx.rxd_size;
25 + if (rxd->rxd2 & RX_DMA_DONE) {
26 ring->calc_idx_update = true;
27 return ring;
28 }
29 @@ -1318,7 +1321,7 @@ static int mtk_poll_rx(struct napi_struc
30 goto rx_done;
31
32 idx = NEXT_DESP_IDX(ring->calc_idx, ring->dma_size);
33 - rxd = &ring->dma[idx];
34 + rxd = (void *)ring->dma + idx * eth->soc->txrx.rxd_size;
35 data = ring->data[idx];
36
37 if (!mtk_rx_get_desc(&trxd, rxd))
38 @@ -1510,7 +1513,7 @@ static int mtk_poll_tx_pdma(struct mtk_e
39
40 mtk_tx_unmap(eth, tx_buf, true);
41
42 - desc = &ring->dma[cpu];
43 + desc = (void *)ring->dma + cpu * eth->soc->txrx.txd_size;
44 ring->last_free = desc;
45 atomic_inc(&ring->free_count);
46