mt76: improve tx queue stop/wake

Instead of stopping and waking only a single queue, handle all phy tx queues
mapped ot the same hardware queue.
Also allow the driver to block tx queues

Signed-off-by: Felix Fietkau <[email protected]>
This commit is contained in:
Felix Fietkau
2020-11-21 15:58:52 +01:00
parent 19c9e277ef
commit e361b6a71e
3 changed files with 55 additions and 16 deletions
-10
View File
@@ -220,7 +220,6 @@ static void
mt76_dma_tx_cleanup(struct mt76_dev *dev, struct mt76_queue *q, bool flush)
{
struct mt76_queue_entry entry;
bool wake = false;
int last;
if (!q)
@@ -238,7 +237,6 @@ mt76_dma_tx_cleanup(struct mt76_dev *dev, struct mt76_queue *q, bool flush)
if (entry.txwi) {
if (!(dev->drv->drv_flags & MT_DRV_TXWI_NO_FREE))
mt76_put_txwi(dev, entry.txwi);
wake = !flush;
}
if (!flush && q->tail == last)
@@ -253,16 +251,8 @@ mt76_dma_tx_cleanup(struct mt76_dev *dev, struct mt76_queue *q, bool flush)
spin_unlock_bh(&q->lock);
}
wake = wake && q->stopped &&
q->qid < IEEE80211_NUM_ACS && q->queued < q->ndesc - 8;
if (wake)
q->stopped = false;
if (!q->queued)
wake_up(&dev->tx_wait);
if (wake)
ieee80211_wake_queue(dev->hw, q->qid);
}
static void *
+1
View File
@@ -136,6 +136,7 @@ struct mt76_queue {
int queued;
int buf_size;
bool stopped;
bool blocked;
u8 buf_offset;
u8 hw_idx;
+54 -6
View File
@@ -291,12 +291,6 @@ mt76_tx(struct mt76_phy *phy, struct ieee80211_sta *sta,
spin_lock_bh(&q->lock);
__mt76_tx_queue_skb(phy, qid, skb, wcid, sta, NULL);
dev->queue_ops->kick(dev, q);
if (q->queued > q->ndesc - 8 && !q->stopped) {
ieee80211_stop_queue(phy->hw, skb_get_queue_mapping(skb));
q->stopped = true;
}
spin_unlock_bh(&q->lock);
}
EXPORT_SYMBOL_GPL(mt76_tx);
@@ -463,6 +457,9 @@ mt76_txq_schedule_list(struct mt76_phy *phy, enum mt76_txq_id qid)
break;
}
if (q->stopped || q->blocked)
break;
if (q->queued + MT_TXQ_FREE_THR >= q->ndesc)
break;
@@ -496,13 +493,60 @@ mt76_txq_schedule_list(struct mt76_phy *phy, enum mt76_txq_id qid)
return ret;
}
static void
__mt76_tx_check_hwq_stop(struct mt76_phy *phy, struct mt76_queue *q,
bool stopped)
{
int i;
for (i = 0; i < IEEE80211_NUM_ACS; i++) {
if (phy->q_tx[i] != q)
continue;
if (stopped)
ieee80211_stop_queue(phy->hw, i);
else
ieee80211_wake_queue(phy->hw, i);
}
}
static bool
mt76_tx_check_hwq_stop(struct mt76_dev *dev, struct mt76_queue *q)
{
return q->blocked || q->queued >= q->ndesc - MT_TXQ_FREE_THR;
}
static void
mt76_tx_update_hwq_stop(struct mt76_dev *dev, struct mt76_queue *q)
{
bool stopped, prev_stopped;
stopped = mt76_tx_check_hwq_stop(dev, q);
prev_stopped = q->stopped;
q->stopped = stopped;
if (stopped == prev_stopped)
return;
__mt76_tx_check_hwq_stop(&dev->phy, q, stopped);
if (dev->phy2)
__mt76_tx_check_hwq_stop(dev->phy2, q, stopped);
}
void mt76_txq_schedule(struct mt76_phy *phy, enum mt76_txq_id qid)
{
struct mt76_queue *q;
int len;
if (qid >= 4)
return;
q = phy->q_tx[qid];
spin_lock_bh(&q->lock);
mt76_tx_update_hwq_stop(phy->dev, q);
spin_unlock_bh(&q->lock);
rcu_read_lock();
do {
@@ -623,6 +667,10 @@ void mt76_queue_tx_complete(struct mt76_dev *dev, struct mt76_queue *q,
spin_lock_bh(&q->lock);
q->tail = (q->tail + 1) % q->ndesc;
q->queued--;
if (q->stopped && !mt76_tx_check_hwq_stop(dev, q))
mt76_worker_schedule(&dev->tx_worker);
spin_unlock_bh(&q->lock);
}
EXPORT_SYMBOL_GPL(mt76_queue_tx_complete);