Skip to content

Commit 4444bc2

Browse files
alexw65500jmberg-intel
authored andcommitted
wifi: mac80211: Proper mark iTXQs for resumption
When a running wake_tx_queue() call is aborted due to a hw queue stop the corresponding iTXQ is not always correctly marked for resumption: wake_tx_push_queue() can stops the queue run without setting @IEEE80211_TXQ_STOP_NETIF_TX. Without the @IEEE80211_TXQ_STOP_NETIF_TX flag __ieee80211_wake_txqs() will not schedule a new queue run and remaining frames in the queue get stuck till another frame is queued to it. Fix the issue for all drivers - also the ones with custom wake_tx_queue callbacks - by moving the logic into ieee80211_tx_dequeue() and drop the redundant @txqs_stopped. @IEEE80211_TXQ_STOP_NETIF_TX is also renamed to @IEEE80211_TXQ_DIRTY to better describe the flag. Fixes: c850e31 ("wifi: mac80211: add internal handler for wake_tx_queue") Signed-off-by: Alexander Wetzel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: [email protected] Signed-off-by: Johannes Berg <[email protected]>
1 parent e66b792 commit 4444bc2

File tree

6 files changed

+21
-54
lines changed

6 files changed

+21
-54
lines changed

include/net/mac80211.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,8 +1832,6 @@ struct ieee80211_vif_cfg {
18321832
* @drv_priv: data area for driver use, will always be aligned to
18331833
* sizeof(void \*).
18341834
* @txq: the multicast data TX queue
1835-
* @txqs_stopped: per AC flag to indicate that intermediate TXQs are stopped,
1836-
* protected by fq->lock.
18371835
* @offload_flags: 802.3 -> 802.11 enapsulation offload flags, see
18381836
* &enum ieee80211_offload_flags.
18391837
* @mbssid_tx_vif: Pointer to the transmitting interface if MBSSID is enabled.
@@ -1863,8 +1861,6 @@ struct ieee80211_vif {
18631861
bool probe_req_reg;
18641862
bool rx_mcast_action_reg;
18651863

1866-
bool txqs_stopped[IEEE80211_NUM_ACS];
1867-
18681864
struct ieee80211_vif *mbssid_tx_vif;
18691865

18701866
/* must be last */

net/mac80211/debugfs_sta.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ static ssize_t sta_aqm_read(struct file *file, char __user *userbuf,
167167
continue;
168168
txqi = to_txq_info(sta->sta.txq[i]);
169169
p += scnprintf(p, bufsz + buf - p,
170-
"%d %d %u %u %u %u %u %u %u %u %u 0x%lx(%s%s%s)\n",
170+
"%d %d %u %u %u %u %u %u %u %u %u 0x%lx(%s%s%s%s)\n",
171171
txqi->txq.tid,
172172
txqi->txq.ac,
173173
txqi->tin.backlog_bytes,
@@ -182,7 +182,8 @@ static ssize_t sta_aqm_read(struct file *file, char __user *userbuf,
182182
txqi->flags,
183183
test_bit(IEEE80211_TXQ_STOP, &txqi->flags) ? "STOP" : "RUN",
184184
test_bit(IEEE80211_TXQ_AMPDU, &txqi->flags) ? " AMPDU" : "",
185-
test_bit(IEEE80211_TXQ_NO_AMSDU, &txqi->flags) ? " NO-AMSDU" : "");
185+
test_bit(IEEE80211_TXQ_NO_AMSDU, &txqi->flags) ? " NO-AMSDU" : "",
186+
test_bit(IEEE80211_TXQ_DIRTY, &txqi->flags) ? " DIRTY" : "");
186187
}
187188

188189
rcu_read_unlock();

net/mac80211/driver-ops.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,7 @@ static inline void drv_wake_tx_queue(struct ieee80211_local *local,
11991199

12001200
/* In reconfig don't transmit now, but mark for waking later */
12011201
if (local->in_reconfig) {
1202-
set_bit(IEEE80211_TXQ_STOP_NETIF_TX, &txq->flags);
1202+
set_bit(IEEE80211_TXQ_DIRTY, &txq->flags);
12031203
return;
12041204
}
12051205

net/mac80211/ieee80211_i.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ enum txq_info_flags {
838838
IEEE80211_TXQ_STOP,
839839
IEEE80211_TXQ_AMPDU,
840840
IEEE80211_TXQ_NO_AMSDU,
841-
IEEE80211_TXQ_STOP_NETIF_TX,
841+
IEEE80211_TXQ_DIRTY,
842842
};
843843

844844
/**

net/mac80211/tx.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3783,23 +3783,29 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,
37833783
struct ieee80211_tx_data tx;
37843784
ieee80211_tx_result r;
37853785
struct ieee80211_vif *vif = txq->vif;
3786+
int q = vif->hw_queue[txq->ac];
3787+
bool q_stopped;
37863788

37873789
WARN_ON_ONCE(softirq_count() == 0);
37883790

37893791
if (!ieee80211_txq_airtime_check(hw, txq))
37903792
return NULL;
37913793

37923794
begin:
3793-
spin_lock_bh(&fq->lock);
3795+
spin_lock(&local->queue_stop_reason_lock);
3796+
q_stopped = local->queue_stop_reasons[q];
3797+
spin_unlock(&local->queue_stop_reason_lock);
37943798

3795-
if (test_bit(IEEE80211_TXQ_STOP, &txqi->flags) ||
3796-
test_bit(IEEE80211_TXQ_STOP_NETIF_TX, &txqi->flags))
3797-
goto out;
3799+
if (unlikely(q_stopped)) {
3800+
/* mark for waking later */
3801+
set_bit(IEEE80211_TXQ_DIRTY, &txqi->flags);
3802+
return NULL;
3803+
}
37983804

3799-
if (vif->txqs_stopped[txq->ac]) {
3800-
set_bit(IEEE80211_TXQ_STOP_NETIF_TX, &txqi->flags);
3805+
spin_lock_bh(&fq->lock);
3806+
3807+
if (unlikely(test_bit(IEEE80211_TXQ_STOP, &txqi->flags)))
38013808
goto out;
3802-
}
38033809

38043810
/* Make sure fragments stay together. */
38053811
skb = __skb_dequeue(&txqi->frags);

net/mac80211/util.c

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -292,22 +292,12 @@ static void wake_tx_push_queue(struct ieee80211_local *local,
292292
struct ieee80211_sub_if_data *sdata,
293293
struct ieee80211_txq *queue)
294294
{
295-
int q = sdata->vif.hw_queue[queue->ac];
296295
struct ieee80211_tx_control control = {
297296
.sta = queue->sta,
298297
};
299298
struct sk_buff *skb;
300-
unsigned long flags;
301-
bool q_stopped;
302299

303300
while (1) {
304-
spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
305-
q_stopped = local->queue_stop_reasons[q];
306-
spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
307-
308-
if (q_stopped)
309-
break;
310-
311301
skb = ieee80211_tx_dequeue(&local->hw, queue);
312302
if (!skb)
313303
break;
@@ -347,8 +337,6 @@ static void __ieee80211_wake_txqs(struct ieee80211_sub_if_data *sdata, int ac)
347337
local_bh_disable();
348338
spin_lock(&fq->lock);
349339

350-
sdata->vif.txqs_stopped[ac] = false;
351-
352340
if (!test_bit(SDATA_STATE_RUNNING, &sdata->state))
353341
goto out;
354342

@@ -370,7 +358,7 @@ static void __ieee80211_wake_txqs(struct ieee80211_sub_if_data *sdata, int ac)
370358
if (ac != txq->ac)
371359
continue;
372360

373-
if (!test_and_clear_bit(IEEE80211_TXQ_STOP_NETIF_TX,
361+
if (!test_and_clear_bit(IEEE80211_TXQ_DIRTY,
374362
&txqi->flags))
375363
continue;
376364

@@ -385,7 +373,7 @@ static void __ieee80211_wake_txqs(struct ieee80211_sub_if_data *sdata, int ac)
385373

386374
txqi = to_txq_info(vif->txq);
387375

388-
if (!test_and_clear_bit(IEEE80211_TXQ_STOP_NETIF_TX, &txqi->flags) ||
376+
if (!test_and_clear_bit(IEEE80211_TXQ_DIRTY, &txqi->flags) ||
389377
(ps && atomic_read(&ps->num_sta_ps)) || ac != vif->txq->ac)
390378
goto out;
391379

@@ -517,8 +505,6 @@ static void __ieee80211_stop_queue(struct ieee80211_hw *hw, int queue,
517505
bool refcounted)
518506
{
519507
struct ieee80211_local *local = hw_to_local(hw);
520-
struct ieee80211_sub_if_data *sdata;
521-
int n_acs = IEEE80211_NUM_ACS;
522508

523509
trace_stop_queue(local, queue, reason);
524510

@@ -530,29 +516,7 @@ static void __ieee80211_stop_queue(struct ieee80211_hw *hw, int queue,
530516
else
531517
local->q_stop_reasons[queue][reason]++;
532518

533-
if (__test_and_set_bit(reason, &local->queue_stop_reasons[queue]))
534-
return;
535-
536-
if (local->hw.queues < IEEE80211_NUM_ACS)
537-
n_acs = 1;
538-
539-
rcu_read_lock();
540-
list_for_each_entry_rcu(sdata, &local->interfaces, list) {
541-
int ac;
542-
543-
if (!sdata->dev)
544-
continue;
545-
546-
for (ac = 0; ac < n_acs; ac++) {
547-
if (sdata->vif.hw_queue[ac] == queue ||
548-
sdata->vif.cab_queue == queue) {
549-
spin_lock(&local->fq.lock);
550-
sdata->vif.txqs_stopped[ac] = true;
551-
spin_unlock(&local->fq.lock);
552-
}
553-
}
554-
}
555-
rcu_read_unlock();
519+
set_bit(reason, &local->queue_stop_reasons[queue]);
556520
}
557521

558522
void ieee80211_stop_queue_by_reason(struct ieee80211_hw *hw, int queue,

0 commit comments

Comments
 (0)