Move token_lock, token and token_count data structures in mt76_dev.
This is a preliminary patch to move token management in mt76 common
module since it is shared by mt7615, mt7915 and mt7921 drivers.
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
struct mt76_worker tx_worker;
struct napi_struct tx_napi;
+ spinlock_t token_lock;
+ struct idr token;
+ int token_count;
+
wait_queue_head_t tx_wait;
struct sk_buff_head status_list;
trace_mac_tx_free(dev, token);
- spin_lock_bh(&dev->token_lock);
- txwi = idr_remove(&dev->token, token);
- spin_unlock_bh(&dev->token_lock);
+ spin_lock_bh(&mdev->token_lock);
+ txwi = idr_remove(&mdev->token, token);
+ spin_unlock_bh(&mdev->token_lock);
if (!txwi)
return;
struct mt76_txwi_cache *txwi;
int id;
- spin_lock_bh(&dev->token_lock);
- idr_for_each_entry(&dev->token, txwi, id) {
+ spin_lock_bh(&dev->mt76.token_lock);
+ idr_for_each_entry(&dev->mt76.token, txwi, id) {
mt7615_txp_skb_unmap(&dev->mt76, txwi);
if (txwi->skb) {
struct ieee80211_hw *hw;
}
mt76_put_txwi(&dev->mt76, txwi);
}
- spin_unlock_bh(&dev->token_lock);
- idr_destroy(&dev->token);
+ spin_unlock_bh(&dev->mt76.token_lock);
+ idr_destroy(&dev->mt76.token);
}
EXPORT_SYMBOL_GPL(mt7615_tx_token_put);
bool flash_eeprom;
bool dbdc_support;
- spinlock_t token_lock;
- struct idr token;
-
u8 fw_ver;
struct work_struct rate_work;
mt76_wr(dev, MT_INT_SOURCE_CSR, ~0);
INIT_WORK(&dev->mcu_work, mt7615_pci_init_work);
- spin_lock_init(&dev->token_lock);
- idr_init(&dev->token);
+ spin_lock_init(&dev->mt76.token_lock);
+ idr_init(&dev->mt76.token);
ret = mt7615_eeprom_init(dev, addr);
if (ret < 0)
token = le16_to_cpu(txp->hw.msdu_id[0]) &
~MT_MSDU_ID_VALID;
- spin_lock_bh(&dev->token_lock);
- t = idr_remove(&dev->token, token);
- spin_unlock_bh(&dev->token_lock);
+ spin_lock_bh(&mdev->token_lock);
+ t = idr_remove(&mdev->token, token);
+ spin_unlock_bh(&mdev->token_lock);
e->skb = t ? t->skb : NULL;
}
t = (struct mt76_txwi_cache *)(txwi + mdev->drv->txwi_size);
t->skb = tx_info->skb;
- spin_lock_bh(&dev->token_lock);
- id = idr_alloc(&dev->token, t, 0, MT7615_TOKEN_SIZE, GFP_ATOMIC);
- spin_unlock_bh(&dev->token_lock);
+ spin_lock_bh(&mdev->token_lock);
+ id = idr_alloc(&mdev->token, t, 0, MT7615_TOKEN_SIZE, GFP_ATOMIC);
+ spin_unlock_bh(&mdev->token_lock);
if (id < 0)
return id;
mt7615_dma_reset(dev);
mt7615_tx_token_put(dev);
- idr_init(&dev->token);
+ idr_init(&dev->mt76.token);
mt76_wr(dev, MT_WPDMA_MEM_RNG_ERR, 0);
mt76_wr(dev, MT_INT_SOURCE_CSR, ~0);
INIT_WORK(&dev->init_work, mt7915_init_work);
- spin_lock_init(&dev->token_lock);
- idr_init(&dev->token);
+ spin_lock_init(&dev->mt76.token_lock);
+ idr_init(&dev->mt76.token);
dev->dbdc_support = !!(mt76_rr(dev, MT_HW_BOUND) & BIT(5));
t = (struct mt76_txwi_cache *)(txwi + mdev->drv->txwi_size);
t->skb = tx_info->skb;
- spin_lock_bh(&dev->token_lock);
- id = idr_alloc(&dev->token, t, 0, MT7915_TOKEN_SIZE, GFP_ATOMIC);
+ spin_lock_bh(&mdev->token_lock);
+ id = idr_alloc(&mdev->token, t, 0, MT7915_TOKEN_SIZE, GFP_ATOMIC);
if (id >= 0)
- dev->token_count++;
+ mdev->token_count++;
- if (dev->token_count >= MT7915_TOKEN_SIZE - MT7915_TOKEN_FREE_THR)
+ if (mdev->token_count >= MT7915_TOKEN_SIZE - MT7915_TOKEN_FREE_THR)
mt7915_set_tx_blocked(dev, true);
- spin_unlock_bh(&dev->token_lock);
+ spin_unlock_bh(&mdev->token_lock);
if (id < 0)
return id;
msdu = FIELD_GET(MT_TX_FREE_MSDU_ID, info);
stat = FIELD_GET(MT_TX_FREE_STATUS, info);
- spin_lock_bh(&dev->token_lock);
- txwi = idr_remove(&dev->token, msdu);
+ spin_lock_bh(&mdev->token_lock);
+ txwi = idr_remove(&mdev->token, msdu);
if (txwi)
- dev->token_count--;
- if (dev->token_count < MT7915_TOKEN_SIZE - MT7915_TOKEN_FREE_THR &&
+ mdev->token_count--;
+ if (mdev->token_count < MT7915_TOKEN_SIZE - MT7915_TOKEN_FREE_THR &&
dev->mphy.q_tx[0]->blocked)
wake = true;
- spin_unlock_bh(&dev->token_lock);
+ spin_unlock_bh(&mdev->token_lock);
if (!txwi)
continue;
mt7915_mac_sta_poll(dev);
if (wake) {
- spin_lock_bh(&dev->token_lock);
+ spin_lock_bh(&mdev->token_lock);
mt7915_set_tx_blocked(dev, false);
- spin_unlock_bh(&dev->token_lock);
+ spin_unlock_bh(&mdev->token_lock);
}
mt76_worker_schedule(&dev->mt76.tx_worker);
txp = mt7915_txwi_to_txp(mdev, e->txwi);
- spin_lock_bh(&dev->token_lock);
- t = idr_remove(&dev->token, le16_to_cpu(txp->token));
- spin_unlock_bh(&dev->token_lock);
+ spin_lock_bh(&mdev->token_lock);
+ t = idr_remove(&mdev->token, le16_to_cpu(txp->token));
+ spin_unlock_bh(&mdev->token_lock);
e->skb = t ? t->skb : NULL;
}
struct mt76_txwi_cache *txwi;
int id;
- spin_lock_bh(&dev->token_lock);
- idr_for_each_entry(&dev->token, txwi, id) {
+ spin_lock_bh(&dev->mt76.token_lock);
+ idr_for_each_entry(&dev->mt76.token, txwi, id) {
mt7915_txp_skb_unmap(&dev->mt76, txwi);
if (txwi->skb) {
struct ieee80211_hw *hw;
ieee80211_free_txskb(hw, txwi->skb);
}
mt76_put_txwi(&dev->mt76, txwi);
- dev->token_count--;
+ dev->mt76.token_count--;
}
- spin_unlock_bh(&dev->token_lock);
- idr_destroy(&dev->token);
+ spin_unlock_bh(&dev->mt76.token_lock);
+ idr_destroy(&dev->mt76.token);
}
/* system error recovery */
mt7915_dma_reset(dev);
mt7915_tx_token_put(dev);
- idr_init(&dev->token);
+ idr_init(&dev->mt76.token);
mt76_wr(dev, MT_MCU_INT_EVENT, MT_MCU_INT_EVENT_DMA_INIT);
mt7915_wait_reset_state(dev, MT_MCU_CMD_RECOVERY_DONE);
u32 hw_pattern;
- spinlock_t token_lock;
- int token_count;
- struct idr token;
-
bool dbdc_support;
bool flash_mode;
bool fw_debug;
{
int ret, idx;
- spin_lock_init(&dev->token_lock);
- idr_init(&dev->token);
+ spin_lock_init(&dev->mt76.token_lock);
+ idr_init(&dev->mt76.token);
ret = mt7921_dma_init(dev);
if (ret)
t = (struct mt76_txwi_cache *)(txwi + mdev->drv->txwi_size);
t->skb = tx_info->skb;
- spin_lock_bh(&dev->token_lock);
- id = idr_alloc(&dev->token, t, 0, MT7921_TOKEN_SIZE, GFP_ATOMIC);
+ spin_lock_bh(&mdev->token_lock);
+ id = idr_alloc(&mdev->token, t, 0, MT7921_TOKEN_SIZE, GFP_ATOMIC);
if (id >= 0)
- dev->token_count++;
+ mdev->token_count++;
- if (dev->token_count >= MT7921_TOKEN_SIZE - MT7921_TOKEN_FREE_THR)
+ if (mdev->token_count >= MT7921_TOKEN_SIZE - MT7921_TOKEN_FREE_THR)
mt7921_set_tx_blocked(dev, true);
- spin_unlock_bh(&dev->token_lock);
+ spin_unlock_bh(&mdev->token_lock);
if (id < 0)
return id;
msdu = FIELD_GET(MT_TX_FREE_MSDU_ID, info);
stat = FIELD_GET(MT_TX_FREE_STATUS, info);
- spin_lock_bh(&dev->token_lock);
- txwi = idr_remove(&dev->token, msdu);
+ spin_lock_bh(&mdev->token_lock);
+ txwi = idr_remove(&mdev->token, msdu);
if (txwi)
- dev->token_count--;
- if (dev->token_count < MT7921_TOKEN_SIZE - MT7921_TOKEN_FREE_THR &&
+ mdev->token_count--;
+ if (mdev->token_count < MT7921_TOKEN_SIZE - MT7921_TOKEN_FREE_THR &&
dev->mphy.q_tx[0]->blocked)
wake = true;
- spin_unlock_bh(&dev->token_lock);
+ spin_unlock_bh(&mdev->token_lock);
if (!txwi)
continue;
}
if (wake) {
- spin_lock_bh(&dev->token_lock);
+ spin_lock_bh(&mdev->token_lock);
mt7921_set_tx_blocked(dev, false);
- spin_unlock_bh(&dev->token_lock);
+ spin_unlock_bh(&mdev->token_lock);
}
napi_consume_skb(skb, 1);
txp = mt7921_txwi_to_txp(mdev, e->txwi);
token = le16_to_cpu(txp->hw.msdu_id[0]) & ~MT_MSDU_ID_VALID;
- spin_lock_bh(&dev->token_lock);
- t = idr_remove(&dev->token, token);
- spin_unlock_bh(&dev->token_lock);
+ spin_lock_bh(&mdev->token_lock);
+ t = idr_remove(&mdev->token, token);
+ spin_unlock_bh(&mdev->token_lock);
e->skb = t ? t->skb : NULL;
}
struct mt76_txwi_cache *txwi;
int id;
- spin_lock_bh(&dev->token_lock);
- idr_for_each_entry(&dev->token, txwi, id) {
+ spin_lock_bh(&dev->mt76.token_lock);
+ idr_for_each_entry(&dev->mt76.token, txwi, id) {
mt7921_txp_skb_unmap(&dev->mt76, txwi);
if (txwi->skb) {
struct ieee80211_hw *hw;
ieee80211_free_txskb(hw, txwi->skb);
}
mt76_put_txwi(&dev->mt76, txwi);
- dev->token_count--;
+ dev->mt76.token_count--;
}
- spin_unlock_bh(&dev->token_lock);
- idr_destroy(&dev->token);
+ spin_unlock_bh(&dev->mt76.token_lock);
+ idr_destroy(&dev->mt76.token);
}
static void
napi_disable(&dev->mt76.tx_napi);
mt7921_tx_token_put(dev);
- idr_init(&dev->token);
+ idr_init(&dev->mt76.token);
err = mt7921_wpdma_reset(dev, true);
if (err)
struct list_head sta_poll_list;
spinlock_t sta_poll_lock;
- spinlock_t token_lock;
- int token_count;
- struct idr token;
-
u8 fw_debug;
struct mt76_connac_pm pm;