Commit b1cb42ad authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76: introduce mt76_init_mcu_queue utility routine

Introduce mt76_init_mcu_queue utility routine in order to allocate
dedicate q_mcu pointers for mcu hw queues. This is a preliminary patch
to move data queues in mt76_phy and add dbdc support to mt7915 driver
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 89870594
...@@ -1214,23 +1214,21 @@ int mt76_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant) ...@@ -1214,23 +1214,21 @@ int mt76_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant)
} }
EXPORT_SYMBOL_GPL(mt76_get_antenna); EXPORT_SYMBOL_GPL(mt76_get_antenna);
int mt76_init_tx_queue(struct mt76_dev *dev, int qid, int idx, struct mt76_queue *
int n_desc, int ring_base) mt76_init_queue(struct mt76_dev *dev, int qid, int idx, int n_desc,
int ring_base)
{ {
struct mt76_queue *hwq; struct mt76_queue *hwq;
int err; int err;
hwq = devm_kzalloc(dev->dev, sizeof(*hwq), GFP_KERNEL); hwq = devm_kzalloc(dev->dev, sizeof(*hwq), GFP_KERNEL);
if (!hwq) if (!hwq)
return -ENOMEM; return ERR_PTR(-ENOMEM);
err = dev->queue_ops->alloc(dev, hwq, idx, n_desc, 0, ring_base); err = dev->queue_ops->alloc(dev, hwq, idx, n_desc, 0, ring_base);
if (err < 0) if (err < 0)
return err; return ERR_PTR(err);
hwq->qid = qid;
dev->q_tx[qid] = hwq;
return 0; return hwq;
} }
EXPORT_SYMBOL_GPL(mt76_init_tx_queue); EXPORT_SYMBOL_GPL(mt76_init_queue);
...@@ -72,6 +72,10 @@ enum mt76_txq_id { ...@@ -72,6 +72,10 @@ enum mt76_txq_id {
__MT_TXQ_MAX __MT_TXQ_MAX
}; };
enum mt76_mcuq_id {
__MT_MCUQ_MAX
};
enum mt76_rxq_id { enum mt76_rxq_id {
MT_RXQ_MAIN, MT_RXQ_MAIN,
MT_RXQ_MCU, MT_RXQ_MCU,
...@@ -604,6 +608,7 @@ struct mt76_dev { ...@@ -604,6 +608,7 @@ struct mt76_dev {
struct list_head txwi_cache; struct list_head txwi_cache;
struct mt76_queue *q_tx[2 * __MT_TXQ_MAX]; struct mt76_queue *q_tx[2 * __MT_TXQ_MAX];
struct mt76_queue *q_mcu[__MT_MCUQ_MAX];
struct mt76_queue q_rx[__MT_RXQ_MAX]; struct mt76_queue q_rx[__MT_RXQ_MAX];
const struct mt76_queue_ops *queue_ops; const struct mt76_queue_ops *queue_ops;
int tx_dma_idx[4]; int tx_dma_idx[4];
...@@ -779,8 +784,38 @@ void mt76_seq_puts_array(struct seq_file *file, const char *str, ...@@ -779,8 +784,38 @@ void mt76_seq_puts_array(struct seq_file *file, const char *str,
int mt76_eeprom_init(struct mt76_dev *dev, int len); int mt76_eeprom_init(struct mt76_dev *dev, int len);
void mt76_eeprom_override(struct mt76_dev *dev); void mt76_eeprom_override(struct mt76_dev *dev);
int mt76_init_tx_queue(struct mt76_dev *dev, int qid, int idx, struct mt76_queue *
int n_desc, int ring_base); mt76_init_queue(struct mt76_dev *dev, int qid, int idx, int n_desc,
int ring_base);
static inline int mt76_init_tx_queue(struct mt76_phy *phy, int qid, int idx,
int n_desc, int ring_base)
{
struct mt76_queue *q;
q = mt76_init_queue(phy->dev, qid, idx, n_desc, ring_base);
if (IS_ERR(q))
return PTR_ERR(q);
q->qid = qid;
phy->dev->q_tx[qid] = q;
return 0;
}
static inline int mt76_init_mcu_queue(struct mt76_dev *dev, int qid, int idx,
int n_desc, int ring_base)
{
struct mt76_queue *q;
q = mt76_init_queue(dev, qid, idx, n_desc, ring_base);
if (IS_ERR(q))
return PTR_ERR(q);
q->qid = qid;
dev->q_mcu[qid] = q;
return 0;
}
static inline struct mt76_phy * static inline struct mt76_phy *
mt76_dev_phy(struct mt76_dev *dev, bool phy_ext) mt76_dev_phy(struct mt76_dev *dev, bool phy_ext)
......
...@@ -9,7 +9,7 @@ mt7603_init_tx_queue(struct mt7603_dev *dev, int qid, int idx, int n_desc) ...@@ -9,7 +9,7 @@ mt7603_init_tx_queue(struct mt7603_dev *dev, int qid, int idx, int n_desc)
{ {
int err; int err;
err = mt76_init_tx_queue(&dev->mt76, qid, idx, n_desc, err = mt76_init_tx_queue(&dev->mphy, qid, idx, n_desc,
MT_TX_RING_BASE); MT_TX_RING_BASE);
if (err < 0) if (err < 0)
return err; return err;
......
...@@ -24,20 +24,20 @@ mt7622_init_tx_queues_multi(struct mt7615_dev *dev) ...@@ -24,20 +24,20 @@ mt7622_init_tx_queues_multi(struct mt7615_dev *dev)
int i; int i;
for (i = 0; i < ARRAY_SIZE(wmm_queue_map); i++) { for (i = 0; i < ARRAY_SIZE(wmm_queue_map); i++) {
ret = mt76_init_tx_queue(&dev->mt76, i, wmm_queue_map[i], ret = mt76_init_tx_queue(&dev->mphy, i, wmm_queue_map[i],
MT7615_TX_RING_SIZE / 2, MT7615_TX_RING_SIZE / 2,
MT_TX_RING_BASE); MT_TX_RING_BASE);
if (ret) if (ret)
return ret; return ret;
} }
ret = mt76_init_tx_queue(&dev->mt76, MT_TXQ_PSD, MT7622_TXQ_MGMT, ret = mt76_init_tx_queue(&dev->mphy, MT_TXQ_PSD, MT7622_TXQ_MGMT,
MT7615_TX_MGMT_RING_SIZE, MT7615_TX_MGMT_RING_SIZE,
MT_TX_RING_BASE); MT_TX_RING_BASE);
if (ret) if (ret)
return ret; return ret;
return mt76_init_tx_queue(&dev->mt76, MT_TXQ_MCU, MT7622_TXQ_MCU, return mt76_init_tx_queue(&dev->mphy, MT_TXQ_MCU, MT7622_TXQ_MCU,
MT7615_TX_MCU_RING_SIZE, MT7615_TX_MCU_RING_SIZE,
MT_TX_RING_BASE); MT_TX_RING_BASE);
} }
...@@ -47,7 +47,7 @@ mt7615_init_tx_queues(struct mt7615_dev *dev) ...@@ -47,7 +47,7 @@ mt7615_init_tx_queues(struct mt7615_dev *dev)
{ {
int ret, i; int ret, i;
ret = mt76_init_tx_queue(&dev->mt76, MT_TXQ_FWDL, MT7615_TXQ_FWDL, ret = mt76_init_tx_queue(&dev->mphy, MT_TXQ_FWDL, MT7615_TXQ_FWDL,
MT7615_TX_FWDL_RING_SIZE, MT7615_TX_FWDL_RING_SIZE,
MT_TX_RING_BASE); MT_TX_RING_BASE);
if (ret) if (ret)
...@@ -56,7 +56,7 @@ mt7615_init_tx_queues(struct mt7615_dev *dev) ...@@ -56,7 +56,7 @@ mt7615_init_tx_queues(struct mt7615_dev *dev)
if (!is_mt7615(&dev->mt76)) if (!is_mt7615(&dev->mt76))
return mt7622_init_tx_queues_multi(dev); return mt7622_init_tx_queues_multi(dev);
ret = mt76_init_tx_queue(&dev->mt76, 0, 0, MT7615_TX_RING_SIZE, ret = mt76_init_tx_queue(&dev->mphy, 0, 0, MT7615_TX_RING_SIZE,
MT_TX_RING_BASE); MT_TX_RING_BASE);
if (ret) if (ret)
return ret; return ret;
...@@ -64,7 +64,7 @@ mt7615_init_tx_queues(struct mt7615_dev *dev) ...@@ -64,7 +64,7 @@ mt7615_init_tx_queues(struct mt7615_dev *dev)
for (i = 1; i < MT_TXQ_MCU; i++) for (i = 1; i < MT_TXQ_MCU; i++)
dev->mt76.q_tx[i] = dev->mt76.q_tx[0]; dev->mt76.q_tx[i] = dev->mt76.q_tx[0];
return mt76_init_tx_queue(&dev->mt76, MT_TXQ_MCU, MT7615_TXQ_MCU, return mt76_init_tx_queue(&dev->mphy, MT_TXQ_MCU, MT7615_TXQ_MCU,
MT7615_TX_MCU_RING_SIZE, MT7615_TX_MCU_RING_SIZE,
MT_TX_RING_BASE); MT_TX_RING_BASE);
} }
......
...@@ -109,7 +109,7 @@ mt76x02_init_tx_queue(struct mt76x02_dev *dev, int qid, int idx, int n_desc) ...@@ -109,7 +109,7 @@ mt76x02_init_tx_queue(struct mt76x02_dev *dev, int qid, int idx, int n_desc)
{ {
int err; int err;
err = mt76_init_tx_queue(&dev->mt76, qid, idx, n_desc, err = mt76_init_tx_queue(&dev->mphy, qid, idx, n_desc,
MT_TX_RING_BASE); MT_TX_RING_BASE);
if (err < 0) if (err < 0)
return err; return err;
......
...@@ -10,7 +10,7 @@ mt7915_init_tx_queues(struct mt7915_dev *dev, int idx, int n_desc) ...@@ -10,7 +10,7 @@ mt7915_init_tx_queues(struct mt7915_dev *dev, int idx, int n_desc)
{ {
int i, err; int i, err;
err = mt76_init_tx_queue(&dev->mt76, 0, idx, n_desc, MT_TX_RING_BASE); err = mt76_init_tx_queue(&dev->mphy, 0, idx, n_desc, MT_TX_RING_BASE);
if (err < 0) if (err < 0)
return err; return err;
...@@ -243,19 +243,19 @@ int mt7915_dma_init(struct mt7915_dev *dev) ...@@ -243,19 +243,19 @@ int mt7915_dma_init(struct mt7915_dev *dev)
return ret; return ret;
/* command to WM */ /* command to WM */
ret = mt76_init_tx_queue(&dev->mt76, MT_TXQ_MCU, MT7915_TXQ_MCU_WM, ret = mt76_init_tx_queue(&dev->mphy, MT_TXQ_MCU, MT7915_TXQ_MCU_WM,
MT7915_TX_MCU_RING_SIZE, MT_TX_RING_BASE); MT7915_TX_MCU_RING_SIZE, MT_TX_RING_BASE);
if (ret) if (ret)
return ret; return ret;
/* command to WA */ /* command to WA */
ret = mt76_init_tx_queue(&dev->mt76, MT_TXQ_MCU_WA, MT7915_TXQ_MCU_WA, ret = mt76_init_tx_queue(&dev->mphy, MT_TXQ_MCU_WA, MT7915_TXQ_MCU_WA,
MT7915_TX_MCU_RING_SIZE, MT_TX_RING_BASE); MT7915_TX_MCU_RING_SIZE, MT_TX_RING_BASE);
if (ret) if (ret)
return ret; return ret;
/* firmware download */ /* firmware download */
ret = mt76_init_tx_queue(&dev->mt76, MT_TXQ_FWDL, MT7915_TXQ_FWDL, ret = mt76_init_tx_queue(&dev->mphy, MT_TXQ_FWDL, MT7915_TXQ_FWDL,
MT7915_TX_FWDL_RING_SIZE, MT_TX_RING_BASE); MT7915_TX_FWDL_RING_SIZE, MT_TX_RING_BASE);
if (ret) if (ret)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment