blob: 8b2f4eaac2ba65f8e25ae47dc316bf288ef8e0e9 [file] [log] [blame]
Jouni Malinenb203ffc2009-12-23 13:15:40 +01001/*
2 * Off-channel operation helpers
3 *
4 * Copyright 2003, Jouni Malinen <jkmaline@cc.hut.fi>
5 * Copyright 2004, Instant802 Networks, Inc.
6 * Copyright 2005, Devicescape Software, Inc.
7 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
8 * Copyright 2007, Michael Wu <flamingice@sourmilk.net>
9 * Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */
Paul Gortmakerbc3b2d72011-07-15 11:47:34 -040015#include <linux/export.h>
Jouni Malinenb203ffc2009-12-23 13:15:40 +010016#include <net/mac80211.h>
17#include "ieee80211_i.h"
Johannes Berg2eb278e2012-06-05 14:28:42 +020018#include "driver-ops.h"
Jouni Malinenb203ffc2009-12-23 13:15:40 +010019
20/*
Ben Greearb23b0252011-02-04 11:54:17 -080021 * Tell our hardware to disable PS.
22 * Optionally inform AP that we will go to sleep so that it will buffer
23 * the frames while we are doing off-channel work. This is optional
24 * because we *may* be doing work on-operating channel, and want our
25 * hardware unconditionally awake, but still let the AP send us normal frames.
Jouni Malinenb203ffc2009-12-23 13:15:40 +010026 */
Rajkumar Manoharan559cef92012-06-18 19:03:52 +053027static void ieee80211_offchannel_ps_enable(struct ieee80211_sub_if_data *sdata)
Jouni Malinenb203ffc2009-12-23 13:15:40 +010028{
29 struct ieee80211_local *local = sdata->local;
Luis R. Rodriguez4730d592010-09-16 15:12:31 -040030 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
Jouni Malinenb203ffc2009-12-23 13:15:40 +010031
32 local->offchannel_ps_enabled = false;
33
34 /* FIXME: what to do when local->pspolling is true? */
35
36 del_timer_sync(&local->dynamic_ps_timer);
Luis R. Rodriguez3bc3c0d2010-09-16 15:12:33 -040037 del_timer_sync(&ifmgd->bcn_mon_timer);
Luis R. Rodriguez4730d592010-09-16 15:12:31 -040038 del_timer_sync(&ifmgd->conn_mon_timer);
39
Jouni Malinenb203ffc2009-12-23 13:15:40 +010040 cancel_work_sync(&local->dynamic_ps_enable_work);
41
42 if (local->hw.conf.flags & IEEE80211_CONF_PS) {
43 local->offchannel_ps_enabled = true;
44 local->hw.conf.flags &= ~IEEE80211_CONF_PS;
45 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
46 }
47
Rajkumar Manoharan559cef92012-06-18 19:03:52 +053048 if (!local->offchannel_ps_enabled ||
Johannes Berg30686bf2015-06-02 21:39:54 +020049 !ieee80211_hw_check(&local->hw, PS_NULLFUNC_STACK))
Jouni Malinenb203ffc2009-12-23 13:15:40 +010050 /*
51 * If power save was enabled, no need to send a nullfunc
52 * frame because AP knows that we are sleeping. But if the
53 * hardware is creating the nullfunc frame for power save
54 * status (ie. IEEE80211_HW_PS_NULLFUNC_STACK is not
55 * enabled) and power save was enabled, the firmware just
56 * sent a null frame with power save disabled. So we need
57 * to send a new nullfunc frame to inform the AP that we
58 * are again sleeping.
59 */
Johannes Berg076cdcb2015-09-24 16:14:55 +020060 ieee80211_send_nullfunc(local, sdata, true);
Jouni Malinenb203ffc2009-12-23 13:15:40 +010061}
62
63/* inform AP that we are awake again, unless power save is enabled */
64static void ieee80211_offchannel_ps_disable(struct ieee80211_sub_if_data *sdata)
65{
66 struct ieee80211_local *local = sdata->local;
67
68 if (!local->ps_sdata)
Johannes Berg076cdcb2015-09-24 16:14:55 +020069 ieee80211_send_nullfunc(local, sdata, false);
Jouni Malinenb203ffc2009-12-23 13:15:40 +010070 else if (local->offchannel_ps_enabled) {
71 /*
72 * In !IEEE80211_HW_PS_NULLFUNC_STACK case the hardware
73 * will send a nullfunc frame with the powersave bit set
74 * even though the AP already knows that we are sleeping.
75 * This could be avoided by sending a null frame with power
76 * save bit disabled before enabling the power save, but
77 * this doesn't gain anything.
78 *
79 * When IEEE80211_HW_PS_NULLFUNC_STACK is enabled, no need
80 * to send a nullfunc frame because AP already knows that
81 * we are sleeping, let's just enable power save mode in
82 * hardware.
83 */
Ben Greearb23b0252011-02-04 11:54:17 -080084 /* TODO: Only set hardware if CONF_PS changed?
85 * TODO: Should we set offchannel_ps_enabled to false?
86 */
Jouni Malinenb203ffc2009-12-23 13:15:40 +010087 local->hw.conf.flags |= IEEE80211_CONF_PS;
88 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
89 } else if (local->hw.conf.dynamic_ps_timeout > 0) {
90 /*
91 * If IEEE80211_CONF_PS was not set and the dynamic_ps_timer
92 * had been running before leaving the operating channel,
93 * restart the timer now and send a nullfunc frame to inform
94 * the AP that we are awake.
95 */
Johannes Berg076cdcb2015-09-24 16:14:55 +020096 ieee80211_send_nullfunc(local, sdata, false);
Jouni Malinenb203ffc2009-12-23 13:15:40 +010097 mod_timer(&local->dynamic_ps_timer, jiffies +
98 msecs_to_jiffies(local->hw.conf.dynamic_ps_timeout));
99 }
Luis R. Rodriguez4730d592010-09-16 15:12:31 -0400100
Luis R. Rodriguez3bc3c0d2010-09-16 15:12:33 -0400101 ieee80211_sta_reset_beacon_monitor(sdata);
Luis R. Rodriguez4730d592010-09-16 15:12:31 -0400102 ieee80211_sta_reset_conn_monitor(sdata);
Jouni Malinenb203ffc2009-12-23 13:15:40 +0100103}
104
Stanislaw Gruszkaaacde9e2012-12-20 14:41:18 +0100105void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local)
Jouni Malinenb203ffc2009-12-23 13:15:40 +0100106{
107 struct ieee80211_sub_if_data *sdata;
108
Johannes Bergfe57d9f2012-07-26 14:55:08 +0200109 if (WARN_ON(local->use_chanctx))
110 return;
111
Jouni Malinenb203ffc2009-12-23 13:15:40 +0100112 /*
Ben Greearb23b0252011-02-04 11:54:17 -0800113 * notify the AP about us leaving the channel and stop all
114 * STA interfaces.
Jouni Malinenb203ffc2009-12-23 13:15:40 +0100115 */
Seth Forshee6c17b772013-02-11 11:21:07 -0600116
Seth Forshee9c35d7d2013-02-11 11:21:08 -0600117 /*
118 * Stop queues and transmit all frames queued by the driver
119 * before sending nullfunc to enable powersave at the AP.
120 */
Johannes Berg445ea4e2013-02-13 12:25:28 +0100121 ieee80211_stop_queues_by_reason(&local->hw, IEEE80211_MAX_QUEUE_MAP,
Luciano Coelhocca07b02014-06-13 16:30:05 +0300122 IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL,
123 false);
Emmanuel Grumbach3b24f4c2015-01-07 15:42:39 +0200124 ieee80211_flush_queues(local, NULL, false);
Seth Forshee6c17b772013-02-11 11:21:07 -0600125
Jouni Malinenb203ffc2009-12-23 13:15:40 +0100126 mutex_lock(&local->iflist_mtx);
127 list_for_each_entry(sdata, &local->interfaces, list) {
128 if (!ieee80211_sdata_running(sdata))
129 continue;
130
Johannes Bergf142c6b2012-06-18 20:07:15 +0200131 if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE)
132 continue;
133
Ben Greearb23b0252011-02-04 11:54:17 -0800134 if (sdata->vif.type != NL80211_IFTYPE_MONITOR)
Johannes Berg5b714c62010-08-27 13:45:28 +0200135 set_bit(SDATA_STATE_OFFCHANNEL, &sdata->state);
Ben Greearb23b0252011-02-04 11:54:17 -0800136
137 /* Check to see if we should disable beaconing. */
Johannes Bergd6a83222012-12-14 14:06:28 +0100138 if (sdata->vif.bss_conf.enable_beacon) {
139 set_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED,
140 &sdata->state);
141 sdata->vif.bss_conf.enable_beacon = false;
Ben Greearb23b0252011-02-04 11:54:17 -0800142 ieee80211_bss_info_change_notify(
143 sdata, BSS_CHANGED_BEACON_ENABLED);
Johannes Bergd6a83222012-12-14 14:06:28 +0100144 }
Ben Greearb23b0252011-02-04 11:54:17 -0800145
Seth Forshee6c17b772013-02-11 11:21:07 -0600146 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
147 sdata->u.mgd.associated)
148 ieee80211_offchannel_ps_enable(sdata);
Jouni Malinenb203ffc2009-12-23 13:15:40 +0100149 }
150 mutex_unlock(&local->iflist_mtx);
151}
152
Stanislaw Gruszkaaacde9e2012-12-20 14:41:18 +0100153void ieee80211_offchannel_return(struct ieee80211_local *local)
Jouni Malinenb203ffc2009-12-23 13:15:40 +0100154{
155 struct ieee80211_sub_if_data *sdata;
156
Johannes Bergfe57d9f2012-07-26 14:55:08 +0200157 if (WARN_ON(local->use_chanctx))
158 return;
159
Jouni Malinenb203ffc2009-12-23 13:15:40 +0100160 mutex_lock(&local->iflist_mtx);
161 list_for_each_entry(sdata, &local->interfaces, list) {
Johannes Bergf142c6b2012-06-18 20:07:15 +0200162 if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE)
163 continue;
164
Eliad Pellerf6e8cb72011-12-23 01:48:06 +0200165 if (sdata->vif.type != NL80211_IFTYPE_MONITOR)
166 clear_bit(SDATA_STATE_OFFCHANNEL, &sdata->state);
167
Jouni Malinenb203ffc2009-12-23 13:15:40 +0100168 if (!ieee80211_sdata_running(sdata))
169 continue;
170
171 /* Tell AP we're back */
Stanislaw Gruszkaaacde9e2012-12-20 14:41:18 +0100172 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
173 sdata->u.mgd.associated)
174 ieee80211_offchannel_ps_disable(sdata);
Jouni Malinenb203ffc2009-12-23 13:15:40 +0100175
Johannes Bergd6a83222012-12-14 14:06:28 +0100176 if (test_and_clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED,
177 &sdata->state)) {
178 sdata->vif.bss_conf.enable_beacon = true;
Jouni Malinenb203ffc2009-12-23 13:15:40 +0100179 ieee80211_bss_info_change_notify(
180 sdata, BSS_CHANGED_BEACON_ENABLED);
Johannes Bergd6a83222012-12-14 14:06:28 +0100181 }
Jouni Malinenb203ffc2009-12-23 13:15:40 +0100182 }
183 mutex_unlock(&local->iflist_mtx);
Seth Forshee6c17b772013-02-11 11:21:07 -0600184
Johannes Berg445ea4e2013-02-13 12:25:28 +0100185 ieee80211_wake_queues_by_reason(&local->hw, IEEE80211_MAX_QUEUE_MAP,
Luciano Coelhocca07b02014-06-13 16:30:05 +0300186 IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL,
187 false);
Jouni Malinenb203ffc2009-12-23 13:15:40 +0100188}
Johannes Berg21f83582010-12-18 17:20:47 +0100189
Johannes Bergaaa016c2015-11-23 23:53:51 +0100190static void ieee80211_roc_notify_destroy(struct ieee80211_roc_work *roc)
Johannes Berg2eb278e2012-06-05 14:28:42 +0200191{
Johannes Bergaaa016c2015-11-23 23:53:51 +0100192 /* was never transmitted */
193 if (roc->frame) {
194 cfg80211_mgmt_tx_status(&roc->sdata->wdev, roc->mgmt_tx_cookie,
195 roc->frame->data, roc->frame->len,
196 false, GFP_KERNEL);
197 ieee80211_free_txskb(&roc->sdata->local->hw, roc->frame);
198 }
199
200 if (!roc->mgmt_tx_cookie)
201 cfg80211_remain_on_channel_expired(&roc->sdata->wdev,
202 roc->cookie, roc->chan,
203 GFP_KERNEL);
204
205 list_del(&roc->list);
206 kfree(roc);
207}
208
209static unsigned long ieee80211_end_finished_rocs(struct ieee80211_local *local,
210 unsigned long now)
211{
212 struct ieee80211_roc_work *roc, *tmp;
213 long remaining_dur_min = LONG_MAX;
214
215 lockdep_assert_held(&local->mtx);
216
217 list_for_each_entry_safe(roc, tmp, &local->roc_list, list) {
218 long remaining;
219
220 if (!roc->started)
221 break;
222
223 remaining = roc->start_time +
224 msecs_to_jiffies(roc->duration) -
225 now;
226
Ilan Peer1b894522015-12-06 21:19:15 +0200227 /* In case of HW ROC, it is possible that the HW finished the
228 * ROC session before the actual requested time. In such a case
229 * end the ROC session (disregarding the remaining time).
230 */
231 if (roc->abort || roc->hw_begun || remaining <= 0)
Johannes Bergaaa016c2015-11-23 23:53:51 +0100232 ieee80211_roc_notify_destroy(roc);
233 else
234 remaining_dur_min = min(remaining_dur_min, remaining);
235 }
236
237 return remaining_dur_min;
238}
239
240static bool ieee80211_recalc_sw_work(struct ieee80211_local *local,
241 unsigned long now)
242{
243 long dur = ieee80211_end_finished_rocs(local, now);
244
245 if (dur == LONG_MAX)
246 return false;
247
248 mod_delayed_work(local->workqueue, &local->roc_work, dur);
249 return true;
250}
251
252static void ieee80211_handle_roc_started(struct ieee80211_roc_work *roc,
253 unsigned long start_time)
254{
255 struct ieee80211_local *local = roc->sdata->local;
256
257 if (WARN_ON(roc->notified))
Johannes Berg2eb278e2012-06-05 14:28:42 +0200258 return;
259
Johannes Bergaaa016c2015-11-23 23:53:51 +0100260 roc->start_time = start_time;
261 roc->started = true;
262 roc->hw_begun = true;
263
Johannes Berg2eb278e2012-06-05 14:28:42 +0200264 if (roc->mgmt_tx_cookie) {
265 if (!WARN_ON(!roc->frame)) {
Johannes Berg55de9082012-07-26 17:24:39 +0200266 ieee80211_tx_skb_tid_band(roc->sdata, roc->frame, 7,
267 roc->chan->band);
Johannes Berg2eb278e2012-06-05 14:28:42 +0200268 roc->frame = NULL;
269 }
270 } else {
Johannes Berg50febf62012-10-26 16:13:06 +0200271 cfg80211_ready_on_channel(&roc->sdata->wdev, roc->cookie,
Johannes Berg42d97a52012-11-08 18:31:02 +0100272 roc->chan, roc->req_duration,
273 GFP_KERNEL);
Johannes Berg2eb278e2012-06-05 14:28:42 +0200274 }
275
276 roc->notified = true;
Johannes Bergaaa016c2015-11-23 23:53:51 +0100277
278 if (!local->ops->remain_on_channel)
279 ieee80211_recalc_sw_work(local, start_time);
Johannes Berg2eb278e2012-06-05 14:28:42 +0200280}
281
Johannes Berg21f83582010-12-18 17:20:47 +0100282static void ieee80211_hw_roc_start(struct work_struct *work)
283{
284 struct ieee80211_local *local =
285 container_of(work, struct ieee80211_local, hw_roc_start);
Johannes Bergaaa016c2015-11-23 23:53:51 +0100286 struct ieee80211_roc_work *roc;
Johannes Berg21f83582010-12-18 17:20:47 +0100287
288 mutex_lock(&local->mtx);
289
Johannes Bergaaa016c2015-11-23 23:53:51 +0100290 list_for_each_entry(roc, &local->roc_list, list) {
291 if (!roc->started)
292 break;
Johannes Berg21f83582010-12-18 17:20:47 +0100293
Johannes Bergaaa016c2015-11-23 23:53:51 +0100294 ieee80211_handle_roc_started(roc, local->hw_roc_start_time);
Johannes Berg2eb278e2012-06-05 14:28:42 +0200295 }
Johannes Bergaaa016c2015-11-23 23:53:51 +0100296
Johannes Berg21f83582010-12-18 17:20:47 +0100297 mutex_unlock(&local->mtx);
298}
299
300void ieee80211_ready_on_channel(struct ieee80211_hw *hw)
301{
302 struct ieee80211_local *local = hw_to_local(hw);
303
Johannes Berg2eb278e2012-06-05 14:28:42 +0200304 local->hw_roc_start_time = jiffies;
305
Johannes Berg21f83582010-12-18 17:20:47 +0100306 trace_api_ready_on_channel(local);
307
308 ieee80211_queue_work(hw, &local->hw_roc_start);
309}
310EXPORT_SYMBOL_GPL(ieee80211_ready_on_channel);
311
Johannes Bergaaa016c2015-11-23 23:53:51 +0100312static void _ieee80211_start_next_roc(struct ieee80211_local *local)
Johannes Berg2eb278e2012-06-05 14:28:42 +0200313{
Johannes Bergaaa016c2015-11-23 23:53:51 +0100314 struct ieee80211_roc_work *roc, *tmp;
315 enum ieee80211_roc_type type;
316 u32 min_dur, max_dur;
Johannes Berg2eb278e2012-06-05 14:28:42 +0200317
318 lockdep_assert_held(&local->mtx);
319
Johannes Bergaaa016c2015-11-23 23:53:51 +0100320 if (WARN_ON(list_empty(&local->roc_list)))
Johannes Berg2eb278e2012-06-05 14:28:42 +0200321 return;
Johannes Berg2eb278e2012-06-05 14:28:42 +0200322
323 roc = list_first_entry(&local->roc_list, struct ieee80211_roc_work,
324 list);
325
Johannes Bergaaa016c2015-11-23 23:53:51 +0100326 if (WARN_ON(roc->started))
Johannes Berg0f6b3f52012-06-20 20:11:33 +0200327 return;
328
Johannes Bergaaa016c2015-11-23 23:53:51 +0100329 min_dur = roc->duration;
330 max_dur = roc->duration;
331 type = roc->type;
332
333 list_for_each_entry(tmp, &local->roc_list, list) {
334 if (tmp == roc)
335 continue;
336 if (tmp->sdata != roc->sdata || tmp->chan != roc->chan)
337 break;
338 max_dur = max(tmp->duration, max_dur);
339 min_dur = min(tmp->duration, min_dur);
340 type = max(tmp->type, type);
341 }
342
Johannes Berg2eb278e2012-06-05 14:28:42 +0200343 if (local->ops->remain_on_channel) {
Johannes Bergaaa016c2015-11-23 23:53:51 +0100344 int ret = drv_remain_on_channel(local, roc->sdata, roc->chan,
345 max_dur, type);
Johannes Berg2eb278e2012-06-05 14:28:42 +0200346
347 if (ret) {
348 wiphy_warn(local->hw.wiphy,
349 "failed to start next HW ROC (%d)\n", ret);
350 /*
351 * queue the work struct again to avoid recursion
352 * when multiple failures occur
353 */
Johannes Bergaaa016c2015-11-23 23:53:51 +0100354 list_for_each_entry(tmp, &local->roc_list, list) {
355 if (tmp->sdata != roc->sdata ||
356 tmp->chan != roc->chan)
357 break;
358 tmp->started = true;
359 tmp->abort = true;
360 }
361 ieee80211_queue_work(&local->hw, &local->hw_roc_done);
362 return;
363 }
364
365 /* we'll notify about the start once the HW calls back */
366 list_for_each_entry(tmp, &local->roc_list, list) {
367 if (tmp->sdata != roc->sdata || tmp->chan != roc->chan)
368 break;
369 tmp->started = true;
Johannes Berg2eb278e2012-06-05 14:28:42 +0200370 }
371 } else {
Johannes Bergb4b177a2014-05-14 15:34:41 +0200372 /* If actually operating on the desired channel (with at least
373 * 20 MHz channel width) don't stop all the operations but still
374 * treat it as though the ROC operation started properly, so
375 * other ROC operations won't interfere with this one.
376 */
377 roc->on_channel = roc->chan == local->_oper_chandef.chan &&
378 local->_oper_chandef.width != NL80211_CHAN_WIDTH_5 &&
379 local->_oper_chandef.width != NL80211_CHAN_WIDTH_10;
380
381 /* start this ROC */
Johannes Berg2eb278e2012-06-05 14:28:42 +0200382 ieee80211_recalc_idle(local);
383
Johannes Bergb4b177a2014-05-14 15:34:41 +0200384 if (!roc->on_channel) {
385 ieee80211_offchannel_stop_vifs(local);
386
387 local->tmp_channel = roc->chan;
388 ieee80211_hw_config(local, 0);
389 }
Johannes Berg2eb278e2012-06-05 14:28:42 +0200390
Johannes Bergaaa016c2015-11-23 23:53:51 +0100391 ieee80211_queue_delayed_work(&local->hw, &local->roc_work,
392 msecs_to_jiffies(min_dur));
Johannes Berg2eb278e2012-06-05 14:28:42 +0200393
Johannes Bergaaa016c2015-11-23 23:53:51 +0100394 /* tell userspace or send frame(s) */
395 list_for_each_entry(tmp, &local->roc_list, list) {
396 if (tmp->sdata != roc->sdata || tmp->chan != roc->chan)
397 break;
Johannes Berg2eb278e2012-06-05 14:28:42 +0200398
Johannes Bergaaa016c2015-11-23 23:53:51 +0100399 tmp->on_channel = roc->on_channel;
400 ieee80211_handle_roc_started(tmp, jiffies);
401 }
402 }
403}
404
405void ieee80211_start_next_roc(struct ieee80211_local *local)
406{
407 struct ieee80211_roc_work *roc;
408
409 lockdep_assert_held(&local->mtx);
410
411 if (list_empty(&local->roc_list)) {
412 ieee80211_run_deferred_scan(local);
413 return;
414 }
415
416 roc = list_first_entry(&local->roc_list, struct ieee80211_roc_work,
417 list);
418
419 if (WARN_ON_ONCE(roc->started))
420 return;
421
422 if (local->ops->remain_on_channel) {
423 _ieee80211_start_next_roc(local);
Johannes Berg2eb278e2012-06-05 14:28:42 +0200424 } else {
Johannes Bergaaa016c2015-11-23 23:53:51 +0100425 /* delay it a bit */
426 ieee80211_queue_delayed_work(&local->hw, &local->roc_work,
427 round_jiffies_relative(HZ/2));
428 }
429}
Johannes Berg2eb278e2012-06-05 14:28:42 +0200430
Johannes Bergaaa016c2015-11-23 23:53:51 +0100431static void __ieee80211_roc_work(struct ieee80211_local *local)
432{
433 struct ieee80211_roc_work *roc;
434 bool on_channel;
435
436 lockdep_assert_held(&local->mtx);
437
438 if (WARN_ON(local->ops->remain_on_channel))
439 return;
440
441 roc = list_first_entry_or_null(&local->roc_list,
442 struct ieee80211_roc_work, list);
443 if (!roc)
444 return;
445
446 if (!roc->started) {
447 WARN_ON(local->use_chanctx);
448 _ieee80211_start_next_roc(local);
449 } else {
450 on_channel = roc->on_channel;
451 if (ieee80211_recalc_sw_work(local, jiffies))
452 return;
453
454 /* careful - roc pointer became invalid during recalc */
455
456 if (!on_channel) {
Emmanuel Grumbach3b24f4c2015-01-07 15:42:39 +0200457 ieee80211_flush_queues(local, NULL, false);
Johannes Berg2eb278e2012-06-05 14:28:42 +0200458
459 local->tmp_channel = NULL;
460 ieee80211_hw_config(local, 0);
461
Stanislaw Gruszkaaacde9e2012-12-20 14:41:18 +0100462 ieee80211_offchannel_return(local);
Johannes Berg2eb278e2012-06-05 14:28:42 +0200463 }
464
465 ieee80211_recalc_idle(local);
Johannes Bergaaa016c2015-11-23 23:53:51 +0100466 ieee80211_start_next_roc(local);
Johannes Berg2eb278e2012-06-05 14:28:42 +0200467 }
Johannes Bergaaa016c2015-11-23 23:53:51 +0100468}
Johannes Berg2eb278e2012-06-05 14:28:42 +0200469
Johannes Bergaaa016c2015-11-23 23:53:51 +0100470static void ieee80211_roc_work(struct work_struct *work)
471{
472 struct ieee80211_local *local =
473 container_of(work, struct ieee80211_local, roc_work.work);
474
475 mutex_lock(&local->mtx);
476 __ieee80211_roc_work(local);
Johannes Berg2eb278e2012-06-05 14:28:42 +0200477 mutex_unlock(&local->mtx);
478}
479
Johannes Berg21f83582010-12-18 17:20:47 +0100480static void ieee80211_hw_roc_done(struct work_struct *work)
481{
482 struct ieee80211_local *local =
483 container_of(work, struct ieee80211_local, hw_roc_done);
484
485 mutex_lock(&local->mtx);
486
Johannes Bergaaa016c2015-11-23 23:53:51 +0100487 ieee80211_end_finished_rocs(local, jiffies);
Johannes Berg71ecfa12012-05-31 15:09:27 +0200488
Johannes Berg2eb278e2012-06-05 14:28:42 +0200489 /* if there's another roc, start it now */
490 ieee80211_start_next_roc(local);
Johannes Berg21f83582010-12-18 17:20:47 +0100491
Johannes Berg21f83582010-12-18 17:20:47 +0100492 mutex_unlock(&local->mtx);
493}
494
495void ieee80211_remain_on_channel_expired(struct ieee80211_hw *hw)
496{
497 struct ieee80211_local *local = hw_to_local(hw);
498
499 trace_api_remain_on_channel_expired(local);
500
501 ieee80211_queue_work(hw, &local->hw_roc_done);
502}
503EXPORT_SYMBOL_GPL(ieee80211_remain_on_channel_expired);
504
Johannes Bergaaa016c2015-11-23 23:53:51 +0100505static bool
506ieee80211_coalesce_hw_started_roc(struct ieee80211_local *local,
507 struct ieee80211_roc_work *new_roc,
508 struct ieee80211_roc_work *cur_roc)
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100509{
510 unsigned long now = jiffies;
Johannes Bergaaa016c2015-11-23 23:53:51 +0100511 unsigned long remaining;
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100512
Johannes Bergaaa016c2015-11-23 23:53:51 +0100513 if (WARN_ON(!cur_roc->started))
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100514 return false;
515
Johannes Bergaaa016c2015-11-23 23:53:51 +0100516 /* if it was scheduled in the hardware, but not started yet,
517 * we can only combine if the older one had a longer duration
518 */
519 if (!cur_roc->hw_begun && new_roc->duration > cur_roc->duration)
520 return false;
521
522 remaining = cur_roc->start_time +
523 msecs_to_jiffies(cur_roc->duration) -
524 now;
525
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100526 /* if it doesn't fit entirely, schedule a new one */
527 if (new_roc->duration > jiffies_to_msecs(remaining))
528 return false;
529
Johannes Bergaaa016c2015-11-23 23:53:51 +0100530 /* add just after the current one so we combine their finish later */
531 list_add(&new_roc->list, &cur_roc->list);
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100532
Johannes Bergaaa016c2015-11-23 23:53:51 +0100533 /* if the existing one has already begun then let this one also
534 * begin, otherwise they'll both be marked properly by the work
535 * struct that runs once the driver notifies us of the beginning
536 */
537 if (cur_roc->hw_begun)
538 ieee80211_handle_roc_started(new_roc, now);
539
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100540 return true;
541}
542
543static int ieee80211_start_roc_work(struct ieee80211_local *local,
544 struct ieee80211_sub_if_data *sdata,
545 struct ieee80211_channel *channel,
546 unsigned int duration, u64 *cookie,
547 struct sk_buff *txskb,
548 enum ieee80211_roc_type type)
549{
550 struct ieee80211_roc_work *roc, *tmp;
Johannes Bergaaa016c2015-11-23 23:53:51 +0100551 bool queued = false, combine_started = true;
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100552 int ret;
553
554 lockdep_assert_held(&local->mtx);
555
556 if (local->use_chanctx && !local->ops->remain_on_channel)
557 return -EOPNOTSUPP;
558
559 roc = kzalloc(sizeof(*roc), GFP_KERNEL);
560 if (!roc)
561 return -ENOMEM;
562
563 /*
564 * If the duration is zero, then the driver
565 * wouldn't actually do anything. Set it to
566 * 10 for now.
567 *
568 * TODO: cancel the off-channel operation
569 * when we get the SKB's TX status and
570 * the wait time was zero before.
571 */
572 if (!duration)
573 duration = 10;
574
575 roc->chan = channel;
576 roc->duration = duration;
577 roc->req_duration = duration;
578 roc->frame = txskb;
579 roc->type = type;
580 roc->sdata = sdata;
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100581
582 /*
583 * cookie is either the roc cookie (for normal roc)
584 * or the SKB (for mgmt TX)
585 */
586 if (!txskb) {
587 roc->cookie = ieee80211_mgmt_tx_cookie(local);
588 *cookie = roc->cookie;
589 } else {
590 roc->mgmt_tx_cookie = *cookie;
591 }
592
Johannes Bergaaa016c2015-11-23 23:53:51 +0100593 /* if there's no need to queue, handle it immediately */
594 if (list_empty(&local->roc_list) &&
595 !local->scanning && !ieee80211_is_radar_required(local)) {
596 /* if not HW assist, just queue & schedule work */
597 if (!local->ops->remain_on_channel) {
598 list_add_tail(&roc->list, &local->roc_list);
599 ieee80211_queue_delayed_work(&local->hw,
600 &local->roc_work, 0);
601 } else {
602 /* otherwise actually kick it off here
603 * (for error handling)
604 */
605 ret = drv_remain_on_channel(local, sdata, channel,
606 duration, type);
607 if (ret) {
608 kfree(roc);
609 return ret;
610 }
611 roc->started = true;
612 list_add_tail(&roc->list, &local->roc_list);
613 }
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100614
Johannes Bergaaa016c2015-11-23 23:53:51 +0100615 return 0;
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100616 }
617
Johannes Bergaaa016c2015-11-23 23:53:51 +0100618 /* otherwise handle queueing */
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100619
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100620 list_for_each_entry(tmp, &local->roc_list, list) {
621 if (tmp->chan != channel || tmp->sdata != sdata)
622 continue;
623
624 /*
Johannes Bergaaa016c2015-11-23 23:53:51 +0100625 * Extend this ROC if possible: If it hasn't started, add
626 * just after the new one to combine.
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100627 */
628 if (!tmp->started) {
Johannes Bergaaa016c2015-11-23 23:53:51 +0100629 list_add(&roc->list, &tmp->list);
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100630 queued = true;
631 break;
632 }
633
Johannes Bergaaa016c2015-11-23 23:53:51 +0100634 if (!combine_started)
635 continue;
636
637 if (!local->ops->remain_on_channel) {
638 /* If there's no hardware remain-on-channel, and
639 * doing so won't push us over the maximum r-o-c
640 * we allow, then we can just add the new one to
641 * the list and mark it as having started now.
642 * If it would push over the limit, don't try to
643 * combine with other started ones (that haven't
644 * been running as long) but potentially sort it
645 * with others that had the same fate.
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100646 */
Johannes Bergaaa016c2015-11-23 23:53:51 +0100647 unsigned long now = jiffies;
648 u32 elapsed = jiffies_to_msecs(now - tmp->start_time);
649 struct wiphy *wiphy = local->hw.wiphy;
650 u32 max_roc = wiphy->max_remain_on_channel_duration;
651
652 if (elapsed + roc->duration > max_roc) {
653 combine_started = false;
654 continue;
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100655 }
656
Johannes Bergaaa016c2015-11-23 23:53:51 +0100657 list_add(&roc->list, &tmp->list);
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100658 queued = true;
Johannes Bergaaa016c2015-11-23 23:53:51 +0100659 roc->on_channel = tmp->on_channel;
660 ieee80211_handle_roc_started(roc, now);
661 break;
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100662 }
Johannes Bergaaa016c2015-11-23 23:53:51 +0100663
664 queued = ieee80211_coalesce_hw_started_roc(local, roc, tmp);
665 if (queued)
666 break;
667 /* if it wasn't queued, perhaps it can be combined with
668 * another that also couldn't get combined previously,
669 * but no need to check for already started ones, since
670 * that can't work.
671 */
672 combine_started = false;
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100673 }
674
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100675 if (!queued)
676 list_add_tail(&roc->list, &local->roc_list);
677
678 return 0;
679}
680
681int ieee80211_remain_on_channel(struct wiphy *wiphy, struct wireless_dev *wdev,
682 struct ieee80211_channel *chan,
683 unsigned int duration, u64 *cookie)
684{
685 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
686 struct ieee80211_local *local = sdata->local;
687 int ret;
688
689 mutex_lock(&local->mtx);
690 ret = ieee80211_start_roc_work(local, sdata, chan,
691 duration, cookie, NULL,
692 IEEE80211_ROC_TYPE_NORMAL);
693 mutex_unlock(&local->mtx);
694
695 return ret;
696}
697
698static int ieee80211_cancel_roc(struct ieee80211_local *local,
699 u64 cookie, bool mgmt_tx)
700{
701 struct ieee80211_roc_work *roc, *tmp, *found = NULL;
702 int ret;
703
Johannes Berg7d37fcd2015-12-01 23:15:26 +0100704 if (!cookie)
705 return -ENOENT;
706
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100707 mutex_lock(&local->mtx);
708 list_for_each_entry_safe(roc, tmp, &local->roc_list, list) {
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100709 if (!mgmt_tx && roc->cookie != cookie)
710 continue;
711 else if (mgmt_tx && roc->mgmt_tx_cookie != cookie)
712 continue;
713
714 found = roc;
715 break;
716 }
717
718 if (!found) {
719 mutex_unlock(&local->mtx);
720 return -ENOENT;
721 }
722
Johannes Bergaaa016c2015-11-23 23:53:51 +0100723 if (!found->started) {
724 ieee80211_roc_notify_destroy(found);
725 goto out_unlock;
726 }
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100727
728 if (local->ops->remain_on_channel) {
Johannes Bergaaa016c2015-11-23 23:53:51 +0100729 ret = drv_cancel_remain_on_channel(local);
730 if (WARN_ON_ONCE(ret)) {
731 mutex_unlock(&local->mtx);
732 return ret;
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100733 }
734
Johannes Bergaaa016c2015-11-23 23:53:51 +0100735 /* TODO:
736 * if multiple items were combined here then we really shouldn't
737 * cancel them all - we should wait for as much time as needed
738 * for the longest remaining one, and only then cancel ...
739 */
740 list_for_each_entry_safe(roc, tmp, &local->roc_list, list) {
741 if (!roc->started)
742 break;
743 if (roc == found)
744 found = NULL;
745 ieee80211_roc_notify_destroy(roc);
746 }
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100747
Johannes Bergaaa016c2015-11-23 23:53:51 +0100748 /* that really must not happen - it was started */
749 WARN_ON(found);
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100750
Johannes Bergaaa016c2015-11-23 23:53:51 +0100751 ieee80211_start_next_roc(local);
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100752 } else {
Johannes Bergaaa016c2015-11-23 23:53:51 +0100753 /* go through work struct to return to the operating channel */
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100754 found->abort = true;
Johannes Bergaaa016c2015-11-23 23:53:51 +0100755 mod_delayed_work(local->workqueue, &local->roc_work, 0);
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100756 }
757
Johannes Bergaaa016c2015-11-23 23:53:51 +0100758 out_unlock:
759 mutex_unlock(&local->mtx);
760
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100761 return 0;
762}
763
764int ieee80211_cancel_remain_on_channel(struct wiphy *wiphy,
765 struct wireless_dev *wdev, u64 cookie)
766{
767 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
768 struct ieee80211_local *local = sdata->local;
769
770 return ieee80211_cancel_roc(local, cookie, false);
771}
772
773int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
774 struct cfg80211_mgmt_tx_params *params, u64 *cookie)
775{
776 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
777 struct ieee80211_local *local = sdata->local;
Johannes Berg5ee00db2015-11-24 14:25:49 +0100778 struct sk_buff *skb;
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100779 struct sta_info *sta;
780 const struct ieee80211_mgmt *mgmt = (void *)params->buf;
781 bool need_offchan = false;
782 u32 flags;
783 int ret;
784 u8 *data;
785
786 if (params->dont_wait_for_ack)
787 flags = IEEE80211_TX_CTL_NO_ACK;
788 else
789 flags = IEEE80211_TX_INTFL_NL80211_FRAME_TX |
790 IEEE80211_TX_CTL_REQ_TX_STATUS;
791
792 if (params->no_cck)
793 flags |= IEEE80211_TX_CTL_NO_CCK_RATE;
794
795 switch (sdata->vif.type) {
796 case NL80211_IFTYPE_ADHOC:
797 if (!sdata->vif.bss_conf.ibss_joined)
798 need_offchan = true;
799 /* fall through */
800#ifdef CONFIG_MAC80211_MESH
801 case NL80211_IFTYPE_MESH_POINT:
802 if (ieee80211_vif_is_mesh(&sdata->vif) &&
803 !sdata->u.mesh.mesh_id_len)
804 need_offchan = true;
805 /* fall through */
806#endif
807 case NL80211_IFTYPE_AP:
808 case NL80211_IFTYPE_AP_VLAN:
809 case NL80211_IFTYPE_P2P_GO:
810 if (sdata->vif.type != NL80211_IFTYPE_ADHOC &&
811 !ieee80211_vif_is_mesh(&sdata->vif) &&
812 !rcu_access_pointer(sdata->bss->beacon))
813 need_offchan = true;
814 if (!ieee80211_is_action(mgmt->frame_control) ||
815 mgmt->u.action.category == WLAN_CATEGORY_PUBLIC ||
816 mgmt->u.action.category == WLAN_CATEGORY_SELF_PROTECTED ||
817 mgmt->u.action.category == WLAN_CATEGORY_SPECTRUM_MGMT)
818 break;
819 rcu_read_lock();
820 sta = sta_info_get(sdata, mgmt->da);
821 rcu_read_unlock();
822 if (!sta)
823 return -ENOLINK;
824 break;
825 case NL80211_IFTYPE_STATION:
826 case NL80211_IFTYPE_P2P_CLIENT:
827 sdata_lock(sdata);
828 if (!sdata->u.mgd.associated ||
829 (params->offchan && params->wait &&
830 local->ops->remain_on_channel &&
831 memcmp(sdata->u.mgd.associated->bssid,
832 mgmt->bssid, ETH_ALEN)))
833 need_offchan = true;
834 sdata_unlock(sdata);
835 break;
836 case NL80211_IFTYPE_P2P_DEVICE:
837 need_offchan = true;
838 break;
839 default:
840 return -EOPNOTSUPP;
841 }
842
843 /* configurations requiring offchan cannot work if no channel has been
844 * specified
845 */
846 if (need_offchan && !params->chan)
847 return -EINVAL;
848
849 mutex_lock(&local->mtx);
850
851 /* Check if the operating channel is the requested channel */
852 if (!need_offchan) {
853 struct ieee80211_chanctx_conf *chanctx_conf;
854
855 rcu_read_lock();
856 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
857
858 if (chanctx_conf) {
859 need_offchan = params->chan &&
860 (params->chan !=
861 chanctx_conf->def.chan);
862 } else if (!params->chan) {
863 ret = -EINVAL;
864 rcu_read_unlock();
865 goto out_unlock;
866 } else {
867 need_offchan = true;
868 }
869 rcu_read_unlock();
870 }
871
872 if (need_offchan && !params->offchan) {
873 ret = -EBUSY;
874 goto out_unlock;
875 }
876
877 skb = dev_alloc_skb(local->hw.extra_tx_headroom + params->len);
878 if (!skb) {
879 ret = -ENOMEM;
880 goto out_unlock;
881 }
882 skb_reserve(skb, local->hw.extra_tx_headroom);
883
884 data = skb_put(skb, params->len);
885 memcpy(data, params->buf, params->len);
886
887 /* Update CSA counters */
888 if (sdata->vif.csa_active &&
889 (sdata->vif.type == NL80211_IFTYPE_AP ||
890 sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
891 sdata->vif.type == NL80211_IFTYPE_ADHOC) &&
892 params->n_csa_offsets) {
893 int i;
894 struct beacon_data *beacon = NULL;
895
896 rcu_read_lock();
897
898 if (sdata->vif.type == NL80211_IFTYPE_AP)
899 beacon = rcu_dereference(sdata->u.ap.beacon);
900 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
901 beacon = rcu_dereference(sdata->u.ibss.presp);
902 else if (ieee80211_vif_is_mesh(&sdata->vif))
903 beacon = rcu_dereference(sdata->u.mesh.beacon);
904
905 if (beacon)
906 for (i = 0; i < params->n_csa_offsets; i++)
907 data[params->csa_offsets[i]] =
908 beacon->csa_current_counter;
909
910 rcu_read_unlock();
911 }
912
913 IEEE80211_SKB_CB(skb)->flags = flags;
914
915 skb->dev = sdata->dev;
916
917 if (!params->dont_wait_for_ack) {
918 /* make a copy to preserve the frame contents
919 * in case of encryption.
920 */
Johannes Berg5ee00db2015-11-24 14:25:49 +0100921 ret = ieee80211_attach_ack_skb(local, skb, cookie, GFP_KERNEL);
922 if (ret) {
Johannes Berga2fcfccb2015-11-23 17:18:35 +0100923 kfree_skb(skb);
924 goto out_unlock;
925 }
926 } else {
927 /* Assign a dummy non-zero cookie, it's not sent to
928 * userspace in this case but we rely on its value
929 * internally in the need_offchan case to distinguish
930 * mgmt-tx from remain-on-channel.
931 */
932 *cookie = 0xffffffff;
933 }
934
935 if (!need_offchan) {
936 ieee80211_tx_skb(sdata, skb);
937 ret = 0;
938 goto out_unlock;
939 }
940
941 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_TX_OFFCHAN |
942 IEEE80211_TX_INTFL_OFFCHAN_TX_OK;
943 if (ieee80211_hw_check(&local->hw, QUEUE_CONTROL))
944 IEEE80211_SKB_CB(skb)->hw_queue =
945 local->hw.offchannel_tx_hw_queue;
946
947 /* This will handle all kinds of coalescing and immediate TX */
948 ret = ieee80211_start_roc_work(local, sdata, params->chan,
949 params->wait, cookie, skb,
950 IEEE80211_ROC_TYPE_MGMT_TX);
951 if (ret)
952 ieee80211_free_txskb(&local->hw, skb);
953 out_unlock:
954 mutex_unlock(&local->mtx);
955 return ret;
956}
957
958int ieee80211_mgmt_tx_cancel_wait(struct wiphy *wiphy,
959 struct wireless_dev *wdev, u64 cookie)
960{
961 struct ieee80211_local *local = wiphy_priv(wiphy);
962
963 return ieee80211_cancel_roc(local, cookie, true);
964}
965
Johannes Berg2eb278e2012-06-05 14:28:42 +0200966void ieee80211_roc_setup(struct ieee80211_local *local)
Johannes Berg21f83582010-12-18 17:20:47 +0100967{
968 INIT_WORK(&local->hw_roc_start, ieee80211_hw_roc_start);
969 INIT_WORK(&local->hw_roc_done, ieee80211_hw_roc_done);
Johannes Bergaaa016c2015-11-23 23:53:51 +0100970 INIT_DELAYED_WORK(&local->roc_work, ieee80211_roc_work);
Johannes Berg2eb278e2012-06-05 14:28:42 +0200971 INIT_LIST_HEAD(&local->roc_list);
972}
973
Johannes Bergc8f994e2013-03-27 22:49:19 +0100974void ieee80211_roc_purge(struct ieee80211_local *local,
975 struct ieee80211_sub_if_data *sdata)
Johannes Berg2eb278e2012-06-05 14:28:42 +0200976{
Johannes Berg2eb278e2012-06-05 14:28:42 +0200977 struct ieee80211_roc_work *roc, *tmp;
Johannes Bergaaa016c2015-11-23 23:53:51 +0100978 bool work_to_do = false;
Johannes Berg2eb278e2012-06-05 14:28:42 +0200979
980 mutex_lock(&local->mtx);
981 list_for_each_entry_safe(roc, tmp, &local->roc_list, list) {
Johannes Bergc8f994e2013-03-27 22:49:19 +0100982 if (sdata && roc->sdata != sdata)
Johannes Berg2eb278e2012-06-05 14:28:42 +0200983 continue;
984
Johannes Bergaaa016c2015-11-23 23:53:51 +0100985 if (roc->started) {
986 if (local->ops->remain_on_channel) {
987 /* can race, so ignore return value */
988 drv_cancel_remain_on_channel(local);
989 ieee80211_roc_notify_destroy(roc);
990 } else {
991 roc->abort = true;
992 work_to_do = true;
993 }
Johannes Berg2eb278e2012-06-05 14:28:42 +0200994 } else {
Johannes Bergaaa016c2015-11-23 23:53:51 +0100995 ieee80211_roc_notify_destroy(roc);
Johannes Berg2eb278e2012-06-05 14:28:42 +0200996 }
997 }
Johannes Bergaaa016c2015-11-23 23:53:51 +0100998 if (work_to_do)
999 __ieee80211_roc_work(local);
1000 mutex_unlock(&local->mtx);
Johannes Berg21f83582010-12-18 17:20:47 +01001001}