wifi: mt76: mt792x: factor out common DMA queue allocation

The mt792x PCIe DMA setup uses the same standard queue allocation
sequence for data, MCU, firmware download and RX rings.

Factor this part out into a small common helper so later chip support
can reuse the existing flow without duplicating the queue setup logic.

This keeps the common DMA skeleton in one place and makes follow-up
chip-specific DMA changes smaller and easier to review.

Signed-off-by: Sean Wang <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Felix Fietkau <[email protected]>
This commit is contained in:
Sean Wang
2026-05-28 13:32:33 +02:00
committed by Felix Fietkau
parent d045c72b29
commit b81028de36
2 changed files with 75 additions and 0 deletions
+56
View File
@@ -87,6 +87,62 @@ void mt792x_rx_poll_complete(struct mt76_dev *mdev, enum mt76_rxq_id q)
}
EXPORT_SYMBOL_GPL(mt792x_rx_poll_complete);
int mt792x_dma_alloc_queues(struct mt792x_dev *dev,
const struct mt792x_dma_layout *layout)
{
int ret;
mt76_dma_attach(&dev->mt76);
ret = mt792x_dma_disable(dev, true);
if (ret)
return ret;
/* init tx queue */
ret = mt76_connac_init_tx_queues(dev->phy.mt76, layout->tx_data0.qid,
layout->tx_data0.n_desc,
layout->tx_data0.ring_base,
NULL, 0);
if (ret)
return ret;
mt76_wr(dev, MT_WFDMA0_TX_RING0_EXT_CTRL, 0x4);
/* command to WM */
ret = mt76_init_mcu_queue(&dev->mt76, MT_MCUQ_WM,
layout->tx_mcu.qid,
layout->tx_mcu.n_desc,
layout->tx_mcu.ring_base);
if (ret)
return ret;
/* firmware download */
ret = mt76_init_mcu_queue(&dev->mt76, MT_MCUQ_FWDL,
layout->tx_fwdl.qid,
layout->tx_fwdl.n_desc,
layout->tx_fwdl.ring_base);
if (ret)
return ret;
/* rx event */
ret = mt76_queue_alloc(dev, &dev->mt76.q_rx[MT_RXQ_MCU],
layout->rx_mcu.qid,
layout->rx_mcu.n_desc,
MT_RX_BUF_SIZE,
layout->rx_mcu.ring_base);
if (ret)
return ret;
/* rx data */
ret = mt76_queue_alloc(dev, &dev->mt76.q_rx[MT_RXQ_MAIN],
layout->rx_data.qid,
layout->rx_data.n_desc,
MT_RX_BUF_SIZE,
layout->rx_data.ring_base);
return ret;
}
EXPORT_SYMBOL_GPL(mt792x_dma_alloc_queues);
#define PREFETCH(base, depth) ((base) << 16 | (depth))
static void mt792x_dma_prefetch(struct mt792x_dev *dev)
{