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

mt76: move mt76_init_tx_queue in common code

Move mt76_init_tx_queue in mac80211.c since it is shared by all
drivers.
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 3d51a3e9
...@@ -1213,3 +1213,24 @@ int mt76_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant) ...@@ -1213,3 +1213,24 @@ int mt76_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant)
return 0; return 0;
} }
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,
int n_desc, int ring_base)
{
struct mt76_queue *hwq;
int err;
hwq = devm_kzalloc(dev->dev, sizeof(*hwq), GFP_KERNEL);
if (!hwq)
return -ENOMEM;
err = dev->queue_ops->alloc(dev, hwq, idx, n_desc, 0, ring_base);
if (err < 0)
return err;
hwq->qid = qid;
dev->q_tx[qid] = hwq;
return 0;
}
EXPORT_SYMBOL_GPL(mt76_init_tx_queue);
...@@ -134,6 +134,7 @@ struct mt76_queue { ...@@ -134,6 +134,7 @@ struct mt76_queue {
u8 buf_offset; u8 buf_offset;
u8 hw_idx; u8 hw_idx;
u8 qid;
dma_addr_t desc_dma; dma_addr_t desc_dma;
struct sk_buff *rx_head; struct sk_buff *rx_head;
...@@ -778,6 +779,9 @@ void mt76_seq_puts_array(struct seq_file *file, const char *str, ...@@ -778,6 +779,9 @@ 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,
int n_desc, int ring_base);
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)
{ {
......
...@@ -7,19 +7,13 @@ ...@@ -7,19 +7,13 @@
static int static int
mt7603_init_tx_queue(struct mt7603_dev *dev, int qid, int idx, int n_desc) mt7603_init_tx_queue(struct mt7603_dev *dev, int qid, int idx, int n_desc)
{ {
struct mt76_queue *hwq;
int err; int err;
hwq = devm_kzalloc(dev->mt76.dev, sizeof(*hwq), GFP_KERNEL); err = mt76_init_tx_queue(&dev->mt76, qid, idx, n_desc,
if (!hwq) MT_TX_RING_BASE);
return -ENOMEM;
err = mt76_queue_alloc(dev, hwq, idx, n_desc, 0, MT_TX_RING_BASE);
if (err < 0) if (err < 0)
return err; return err;
dev->mt76.q_tx[qid] = hwq;
mt7603_irq_enable(dev, MT_INT_TX_DONE(idx)); mt7603_irq_enable(dev, MT_INT_TX_DONE(idx));
return 0; return 0;
......
...@@ -11,25 +11,6 @@ ...@@ -11,25 +11,6 @@
#include "../dma.h" #include "../dma.h"
#include "mac.h" #include "mac.h"
static int
mt7615_init_tx_queue(struct mt7615_dev *dev, int qid, int idx, int n_desc)
{
struct mt76_queue *hwq;
int err;
hwq = devm_kzalloc(dev->mt76.dev, sizeof(*hwq), GFP_KERNEL);
if (!hwq)
return -ENOMEM;
err = mt76_queue_alloc(dev, hwq, idx, n_desc, 0, MT_TX_RING_BASE);
if (err < 0)
return err;
dev->mt76.q_tx[qid] = hwq;
return 0;
}
static int static int
mt7622_init_tx_queues_multi(struct mt7615_dev *dev) mt7622_init_tx_queues_multi(struct mt7615_dev *dev)
{ {
...@@ -43,20 +24,22 @@ mt7622_init_tx_queues_multi(struct mt7615_dev *dev) ...@@ -43,20 +24,22 @@ 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 = mt7615_init_tx_queue(dev, i, wmm_queue_map[i], ret = mt76_init_tx_queue(&dev->mt76, i, wmm_queue_map[i],
MT7615_TX_RING_SIZE / 2); MT7615_TX_RING_SIZE / 2,
MT_TX_RING_BASE);
if (ret) if (ret)
return ret; return ret;
} }
ret = mt7615_init_tx_queue(dev, MT_TXQ_PSD, ret = mt76_init_tx_queue(&dev->mt76, MT_TXQ_PSD, MT7622_TXQ_MGMT,
MT7622_TXQ_MGMT, MT7615_TX_MGMT_RING_SIZE); MT7615_TX_MGMT_RING_SIZE,
MT_TX_RING_BASE);
if (ret) if (ret)
return ret; return ret;
ret = mt7615_init_tx_queue(dev, MT_TXQ_MCU, return mt76_init_tx_queue(&dev->mt76, MT_TXQ_MCU, MT7622_TXQ_MCU,
MT7622_TXQ_MCU, MT7615_TX_MCU_RING_SIZE); MT7615_TX_MCU_RING_SIZE,
return ret; MT_TX_RING_BASE);
} }
static int static int
...@@ -64,25 +47,26 @@ mt7615_init_tx_queues(struct mt7615_dev *dev) ...@@ -64,25 +47,26 @@ mt7615_init_tx_queues(struct mt7615_dev *dev)
{ {
int ret, i; int ret, i;
ret = mt7615_init_tx_queue(dev, MT_TXQ_FWDL, ret = mt76_init_tx_queue(&dev->mt76, MT_TXQ_FWDL, MT7615_TXQ_FWDL,
MT7615_TXQ_FWDL, MT7615_TX_FWDL_RING_SIZE,
MT7615_TX_FWDL_RING_SIZE); MT_TX_RING_BASE);
if (ret) if (ret)
return ret; return ret;
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 = mt7615_init_tx_queue(dev, 0, 0, MT7615_TX_RING_SIZE); ret = mt76_init_tx_queue(&dev->mt76, 0, 0, MT7615_TX_RING_SIZE,
MT_TX_RING_BASE);
if (ret) if (ret)
return ret; return ret;
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];
ret = mt7615_init_tx_queue(dev, MT_TXQ_MCU, MT7615_TXQ_MCU, return mt76_init_tx_queue(&dev->mt76, MT_TXQ_MCU, MT7615_TXQ_MCU,
MT7615_TX_MCU_RING_SIZE); MT7615_TX_MCU_RING_SIZE,
return 0; MT_TX_RING_BASE);
} }
static int mt7615_poll_tx(struct napi_struct *napi, int budget) static int mt7615_poll_tx(struct napi_struct *napi, int budget)
......
...@@ -106,19 +106,13 @@ EXPORT_SYMBOL_GPL(mt76x02e_init_beacon_config); ...@@ -106,19 +106,13 @@ EXPORT_SYMBOL_GPL(mt76x02e_init_beacon_config);
static int static int
mt76x02_init_tx_queue(struct mt76x02_dev *dev, int qid, int idx, int n_desc) mt76x02_init_tx_queue(struct mt76x02_dev *dev, int qid, int idx, int n_desc)
{ {
struct mt76_queue *hwq;
int err; int err;
hwq = devm_kzalloc(dev->mt76.dev, sizeof(*hwq), GFP_KERNEL); err = mt76_init_tx_queue(&dev->mt76, qid, idx, n_desc,
if (!hwq) MT_TX_RING_BASE);
return -ENOMEM;
err = mt76_queue_alloc(dev, hwq, idx, n_desc, 0, MT_TX_RING_BASE);
if (err < 0) if (err < 0)
return err; return err;
dev->mt76.q_tx[qid] = hwq;
mt76x02_irq_enable(dev, MT_INT_TX_DONE(idx)); mt76x02_irq_enable(dev, MT_INT_TX_DONE(idx));
return 0; return 0;
......
...@@ -6,41 +6,16 @@ ...@@ -6,41 +6,16 @@
#include "mac.h" #include "mac.h"
static int static int
mt7915_init_tx_queues(struct mt7915_dev *dev, int n_desc) mt7915_init_tx_queues(struct mt7915_dev *dev, int idx, int n_desc)
{ {
struct mt76_queue *hwq; int i, err;
int err, i;
hwq = devm_kzalloc(dev->mt76.dev, sizeof(*hwq), GFP_KERNEL); err = mt76_init_tx_queue(&dev->mt76, 0, idx, n_desc, MT_TX_RING_BASE);
if (!hwq)
return -ENOMEM;
err = mt76_queue_alloc(dev, hwq, MT7915_TXQ_BAND0, n_desc, 0,
MT_TX_RING_BASE);
if (err < 0) if (err < 0)
return err; return err;
for (i = 0; i < MT_TXQ_MCU; i++) for (i = 0; i < MT_TXQ_MCU; i++)
dev->mt76.q_tx[i] = hwq; dev->mt76.q_tx[i] = dev->mt76.q_tx[0];
return 0;
}
static int
mt7915_init_mcu_queue(struct mt7915_dev *dev, int qid, int idx, int n_desc)
{
struct mt76_queue *hwq;
int err;
hwq = devm_kzalloc(dev->mt76.dev, sizeof(*hwq), GFP_KERNEL);
if (!hwq)
return -ENOMEM;
err = mt76_queue_alloc(dev, hwq, idx, n_desc, 0, MT_TX_RING_BASE);
if (err < 0)
return err;
dev->mt76.q_tx[qid] = hwq;
return 0; return 0;
} }
...@@ -262,25 +237,26 @@ int mt7915_dma_init(struct mt7915_dev *dev) ...@@ -262,25 +237,26 @@ int mt7915_dma_init(struct mt7915_dev *dev)
mt76_wr(dev, MT_WFDMA1_PRI_DLY_INT_CFG0, 0); mt76_wr(dev, MT_WFDMA1_PRI_DLY_INT_CFG0, 0);
/* init tx queue */ /* init tx queue */
ret = mt7915_init_tx_queues(dev, MT7915_TX_RING_SIZE); ret = mt7915_init_tx_queues(dev, MT7915_TXQ_BAND0,
MT7915_TX_RING_SIZE);
if (ret) if (ret)
return ret; return ret;
/* command to WM */ /* command to WM */
ret = mt7915_init_mcu_queue(dev, MT_TXQ_MCU, MT7915_TXQ_MCU_WM, ret = mt76_init_tx_queue(&dev->mt76, MT_TXQ_MCU, MT7915_TXQ_MCU_WM,
MT7915_TX_MCU_RING_SIZE); MT7915_TX_MCU_RING_SIZE, MT_TX_RING_BASE);
if (ret) if (ret)
return ret; return ret;
/* command to WA */ /* command to WA */
ret = mt7915_init_mcu_queue(dev, MT_TXQ_MCU_WA, MT7915_TXQ_MCU_WA, ret = mt76_init_tx_queue(&dev->mt76, MT_TXQ_MCU_WA, MT7915_TXQ_MCU_WA,
MT7915_TX_MCU_RING_SIZE); MT7915_TX_MCU_RING_SIZE, MT_TX_RING_BASE);
if (ret) if (ret)
return ret; return ret;
/* firmware download */ /* firmware download */
ret = mt7915_init_mcu_queue(dev, MT_TXQ_FWDL, MT7915_TXQ_FWDL, ret = mt76_init_tx_queue(&dev->mt76, MT_TXQ_FWDL, MT7915_TXQ_FWDL,
MT7915_TX_FWDL_RING_SIZE); 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