99ee2c5cf913b09d6a92d74b60d1022d015098a5
[openwrt/staging/ansuel.git] /
1 From: Lorenzo Bianconi <lorenzo@kernel.org>
2 Date: Fri, 20 May 2022 20:11:31 +0200
3 Subject: [PATCH] net: ethernet: mtk_eth_soc: rely on txd_size in txd_to_idx
4
5 This is a preliminary patch to add mt7986 ethernet support.
6
7 Tested-by: Sam Shih <sam.shih@mediatek.com>
8 Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
9 Signed-off-by: David S. Miller <davem@davemloft.net>
10 ---
11
12 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
13 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
14 @@ -916,9 +916,10 @@ static struct mtk_tx_dma *qdma_to_pdma(s
15 return ring->dma_pdma - ring->dma + dma;
16 }
17
18 -static int txd_to_idx(struct mtk_tx_ring *ring, struct mtk_tx_dma *dma)
19 +static int txd_to_idx(struct mtk_tx_ring *ring, struct mtk_tx_dma *dma,
20 + u32 txd_size)
21 {
22 - return ((void *)dma - (void *)ring->dma) / sizeof(*dma);
23 + return ((void *)dma - (void *)ring->dma) / txd_size;
24 }
25
26 static void mtk_tx_unmap(struct mtk_eth *eth, struct mtk_tx_buf *tx_buf,
27 @@ -1134,8 +1135,10 @@ static int mtk_tx_map(struct sk_buff *sk
28 !netdev_xmit_more())
29 mtk_w32(eth, txd->txd2, MTK_QTX_CTX_PTR);
30 } else {
31 - int next_idx = NEXT_DESP_IDX(txd_to_idx(ring, txd),
32 - ring->dma_size);
33 + int next_idx;
34 +
35 + next_idx = NEXT_DESP_IDX(txd_to_idx(ring, txd, soc->txrx.txd_size),
36 + ring->dma_size);
37 mtk_w32(eth, next_idx, MT7628_TX_CTX_IDX0);
38 }
39