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
5 This is a preliminary patch to add mt7986 ethernet support.
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>
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;
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,
22 - return ((void *)dma - (void *)ring->dma) / sizeof(*dma);
23 + return ((void *)dma - (void *)ring->dma) / txd_size;
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
29 mtk_w32(eth, txd->txd2, MTK_QTX_CTX_PTR);
31 - int next_idx = NEXT_DESP_IDX(txd_to_idx(ring, txd),
35 + next_idx = NEXT_DESP_IDX(txd_to_idx(ring, txd, soc->txrx.txd_size),
37 mtk_w32(eth, next_idx, MT7628_TX_CTX_IDX0);