aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/util.c
diff options
context:
space:
mode:
authorManikanta Pubbisetty <mpubbise@codeaurora.org>2018-07-10 14:42:53 -0400
committerJohannes Berg <johannes.berg@intel.com>2018-08-28 05:16:35 -0400
commit21a5d4c3a45ca608477a083096cfbce76e449a0c (patch)
tree683ec470ca1a00281ca6d6521bb93d5e4a5c8779 /net/mac80211/util.c
parent7417844b63d4b0dc8ab23f88259bf95de7d09b57 (diff)
mac80211: add stop/start logic for software TXQs
Sometimes, it is required to stop the transmissions momentarily and resume it later; stopping the txqs becomes very critical in scenarios where the packet transmission has to be ceased completely. For example, during the hardware restart, during off channel operations, when initiating CSA(upon detecting a radar on the DFS channel), etc. The TX queue stop/start logic in mac80211 works well in stopping the TX when drivers make use of netdev queues, i.e, when Qdiscs in network layer take care of traffic scheduling. Since the devices implementing wake_tx_queue can run without Qdiscs, packets will be handed to mac80211 directly without queueing them in the netdev queues. Also, mac80211 does not invoke any of the netif_stop_*/netif_wake_* APIs if wake_tx_queue is implemented. Since the queues are not stopped in this case, transmissions can continue and this will impact negatively on the operation of the wireless device. For example, During hardware restart, we stop the netdev queues so that packets are not sent to the driver. Since ath10k implements wake_tx_queue, TX queues will not be stopped and packets might reach the hardware while it is restarting; this can make hardware unresponsive and the only possible option for recovery is to reboot the entire system. There is another problem to this, it is observed that the packets were sent on the DFS channel for a prolonged duration after radar detection impacting the channel closing time. We can still invoke netif stop/wake APIs when wake_tx_queue is implemented but this could lead to packet drops in network layer; adding stop/start logic for software TXQs in mac80211 instead makes more sense; the change proposed adds the same in mac80211. Signed-off-by: Manikanta Pubbisetty <mpubbise@codeaurora.org> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211/util.c')
-rw-r--r--net/mac80211/util.c110
1 files changed, 105 insertions, 5 deletions
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 88efda7c9f8a..d886789ff59e 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -240,6 +240,99 @@ __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw,
240} 240}
241EXPORT_SYMBOL(ieee80211_ctstoself_duration); 241EXPORT_SYMBOL(ieee80211_ctstoself_duration);
242 242
243static void __ieee80211_wake_txqs(struct ieee80211_sub_if_data *sdata, int ac)
244{
245 struct ieee80211_local *local = sdata->local;
246 struct ieee80211_vif *vif = &sdata->vif;
247 struct fq *fq = &local->fq;
248 struct ps_data *ps = NULL;
249 struct txq_info *txqi;
250 struct sta_info *sta;
251 int i;
252
253 spin_lock_bh(&fq->lock);
254
255 if (sdata->vif.type == NL80211_IFTYPE_AP)
256 ps = &sdata->bss->ps;
257
258 sdata->vif.txqs_stopped[ac] = false;
259
260 list_for_each_entry_rcu(sta, &local->sta_list, list) {
261 if (sdata != sta->sdata)
262 continue;
263
264 for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) {
265 struct ieee80211_txq *txq = sta->sta.txq[i];
266
267 txqi = to_txq_info(txq);
268
269 if (ac != txq->ac)
270 continue;
271
272 if (!test_and_clear_bit(IEEE80211_TXQ_STOP_NETIF_TX,
273 &txqi->flags))
274 continue;
275
276 spin_unlock_bh(&fq->lock);
277 drv_wake_tx_queue(local, txqi);
278 spin_lock_bh(&fq->lock);
279 }
280 }
281
282 if (!vif->txq)
283 goto out;
284
285 txqi = to_txq_info(vif->txq);
286
287 if (!test_and_clear_bit(IEEE80211_TXQ_STOP_NETIF_TX, &txqi->flags) ||
288 (ps && atomic_read(&ps->num_sta_ps)) || ac != vif->txq->ac)
289 goto out;
290
291 spin_unlock_bh(&fq->lock);
292
293 drv_wake_tx_queue(local, txqi);
294 return;
295out:
296 spin_unlock_bh(&fq->lock);
297}
298
299void ieee80211_wake_txqs(unsigned long data)
300{
301 struct ieee80211_local *local = (struct ieee80211_local *)data;
302 struct ieee80211_sub_if_data *sdata;
303 int n_acs = IEEE80211_NUM_ACS;
304 unsigned long flags;
305 int i;
306
307 rcu_read_lock();
308 spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
309
310 if (local->hw.queues < IEEE80211_NUM_ACS)
311 n_acs = 1;
312
313 for (i = 0; i < local->hw.queues; i++) {
314 if (local->queue_stop_reasons[i])
315 continue;
316
317 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
318 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
319 int ac;
320
321 for (ac = 0; ac < n_acs; ac++) {
322 int ac_queue = sdata->vif.hw_queue[ac];
323
324 if (ac_queue == i ||
325 sdata->vif.cab_queue == i)
326 __ieee80211_wake_txqs(sdata, ac);
327 }
328 }
329 spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
330 }
331
332 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
333 rcu_read_unlock();
334}
335
243void ieee80211_propagate_queue_wake(struct ieee80211_local *local, int queue) 336void ieee80211_propagate_queue_wake(struct ieee80211_local *local, int queue)
244{ 337{
245 struct ieee80211_sub_if_data *sdata; 338 struct ieee80211_sub_if_data *sdata;
@@ -308,6 +401,9 @@ static void __ieee80211_wake_queue(struct ieee80211_hw *hw, int queue,
308 rcu_read_unlock(); 401 rcu_read_unlock();
309 } else 402 } else
310 tasklet_schedule(&local->tx_pending_tasklet); 403 tasklet_schedule(&local->tx_pending_tasklet);
404
405 if (local->ops->wake_tx_queue)
406 tasklet_schedule(&local->wake_txqs_tasklet);
311} 407}
312 408
313void ieee80211_wake_queue_by_reason(struct ieee80211_hw *hw, int queue, 409void ieee80211_wake_queue_by_reason(struct ieee80211_hw *hw, int queue,
@@ -351,9 +447,6 @@ static void __ieee80211_stop_queue(struct ieee80211_hw *hw, int queue,
351 if (__test_and_set_bit(reason, &local->queue_stop_reasons[queue])) 447 if (__test_and_set_bit(reason, &local->queue_stop_reasons[queue]))
352 return; 448 return;
353 449
354 if (local->ops->wake_tx_queue)
355 return;
356
357 if (local->hw.queues < IEEE80211_NUM_ACS) 450 if (local->hw.queues < IEEE80211_NUM_ACS)
358 n_acs = 1; 451 n_acs = 1;
359 452
@@ -366,8 +459,15 @@ static void __ieee80211_stop_queue(struct ieee80211_hw *hw, int queue,
366 459
367 for (ac = 0; ac < n_acs; ac++) { 460 for (ac = 0; ac < n_acs; ac++) {
368 if (sdata->vif.hw_queue[ac] == queue || 461 if (sdata->vif.hw_queue[ac] == queue ||
369 sdata->vif.cab_queue == queue) 462 sdata->vif.cab_queue == queue) {
370 netif_stop_subqueue(sdata->dev, ac); 463 if (!local->ops->wake_tx_queue) {
464 netif_stop_subqueue(sdata->dev, ac);
465 continue;
466 }
467 spin_lock(&local->fq.lock);
468 sdata->vif.txqs_stopped[ac] = true;
469 spin_unlock(&local->fq.lock);
470 }
371 } 471 }
372 } 472 }
373 rcu_read_unlock(); 473 rcu_read_unlock();