285
296
local->scanning = 0;
286
297
local->scan_channel = NULL;
291
static void __ieee80211_scan_completed_finish(struct ieee80211_hw *hw,
294
struct ieee80211_local *local = hw_to_local(hw);
296
ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
299
on_oper_chan = ieee80211_cfg_on_oper_channel(local);
301
if (was_hw_scan || !on_oper_chan)
302
ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
304
/* Set power back to normal operating levels. */
305
ieee80211_hw_config(local, 0);
297
307
if (!was_hw_scan) {
298
309
ieee80211_configure_filter(local);
299
310
drv_sw_scan_complete(local);
300
ieee80211_offchannel_return(local, true);
311
on_oper_chan2 = ieee80211_cfg_on_oper_channel(local);
312
/* We should always be on-channel at this point. */
313
WARN_ON(!on_oper_chan2);
314
if (on_oper_chan2 && (on_oper_chan != on_oper_chan2))
315
enable_beacons = true;
317
ieee80211_offchannel_return(local, enable_beacons, true);
303
mutex_lock(&local->mtx);
304
320
ieee80211_recalc_idle(local);
305
mutex_unlock(&local->mtx);
307
322
ieee80211_mlme_notify_scan_completed(local);
308
323
ieee80211_ibss_notify_scan_completed(local);
341
356
drv_sw_scan_start(local);
343
ieee80211_offchannel_stop_beaconing(local);
345
358
local->leave_oper_channel_time = 0;
346
359
local->next_scan_state = SCAN_DECISION;
347
360
local->scan_channel_idx = 0;
349
drv_flush(local, false);
362
/* We always want to use off-channel PS, even if we
363
* are not really leaving oper-channel. Don't
364
* tell the AP though, as long as we are on-channel.
366
ieee80211_offchannel_enable_all_ps(local, false);
351
368
ieee80211_configure_filter(local);
370
/* We need to set power level at maximum rate for scanning. */
371
ieee80211_hw_config(local, 0);
353
373
ieee80211_queue_delayed_work(&local->hw,
354
374
&local->scan_work,
355
375
IEEE80211_CHANNEL_TIME);
487
507
mutex_unlock(&local->iflist_mtx);
489
if (local->scan_channel) {
509
next_chan = local->scan_req->channels[local->scan_channel_idx];
511
if (ieee80211_cfg_on_oper_channel(local)) {
512
/* We're currently on operating channel. */
513
if (next_chan == local->oper_channel)
514
/* We don't need to move off of operating channel. */
515
local->next_scan_state = SCAN_SET_CHANNEL;
518
* We do need to leave operating channel, as next
519
* scan is somewhere else.
521
local->next_scan_state = SCAN_LEAVE_OPER_CHANNEL;
491
524
* we're currently scanning a different channel, let's
492
525
* see if we can scan another channel without interfering
560
587
/* switch back to the operating channel */
561
588
local->scan_channel = NULL;
562
ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
589
if (!ieee80211_cfg_on_oper_channel(local))
590
ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
565
* Only re-enable station mode interface now; beaconing will be
566
* re-enabled once the full scan has been completed.
593
* Re-enable vifs and beaconing. Leave PS
594
* in off-channel state..will put that back
595
* on-channel at the end of scanning.
568
ieee80211_offchannel_return(local, false);
570
__clear_bit(SCAN_OFF_CHANNEL, &local->scanning);
597
ieee80211_offchannel_return(local, true, false);
572
599
*next_delay = HZ / 5;
573
600
local->next_scan_state = SCAN_DECISION;
643
673
struct ieee80211_local *local =
644
674
container_of(work, struct ieee80211_local, scan_work.work);
645
struct ieee80211_sub_if_data *sdata = local->scan_sdata;
675
struct ieee80211_sub_if_data *sdata;
646
676
unsigned long next_delay = 0;
647
bool aborted, hw_scan, finish;
677
bool aborted, hw_scan;
649
679
mutex_lock(&local->mtx);
681
sdata = local->scan_sdata;
651
683
if (test_and_clear_bit(SCAN_COMPLETED, &local->scanning)) {
652
684
aborted = test_and_clear_bit(SCAN_ABORTED, &local->scanning);
653
685
goto out_complete;
711
748
} while (next_delay == 0);
713
750
ieee80211_queue_delayed_work(&local->hw, &local->scan_work, next_delay);
714
mutex_unlock(&local->mtx);
718
754
hw_scan = test_bit(SCAN_HW_SCANNING, &local->scanning);
719
finish = __ieee80211_scan_completed(&local->hw, aborted, hw_scan);
720
mutex_unlock(&local->mtx);
722
__ieee80211_scan_completed_finish(&local->hw, hw_scan);
755
__ieee80211_scan_completed(&local->hw, aborted, hw_scan);
726
757
mutex_unlock(&local->mtx);
812
842
mutex_lock(&local->mtx);
813
843
abortscan = local->scan_req && !test_bit(SCAN_HW_SCANNING, &local->scanning);
815
finish = __ieee80211_scan_completed(&local->hw, true, false);
816
mutex_unlock(&local->mtx);
819
/* The scan is canceled, but stop work from being pending */
820
cancel_delayed_work_sync(&local->scan_work);
823
__ieee80211_scan_completed_finish(&local->hw, false);
846
* The scan is canceled, but stop work from being pending.
848
* If the work is currently running, it must be blocked on
849
* the mutex, but we'll set scan_sdata = NULL and it'll
850
* simply exit once it acquires the mutex.
852
cancel_delayed_work(&local->scan_work);
854
__ieee80211_scan_completed(&local->hw, true, false);
856
mutex_unlock(&local->mtx);
859
int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
860
struct cfg80211_sched_scan_request *req)
862
struct ieee80211_local *local = sdata->local;
865
mutex_lock(&sdata->local->mtx);
867
if (local->sched_scanning) {
872
if (!local->ops->sched_scan_start) {
877
for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
878
local->sched_scan_ies.ie[i] = kzalloc(2 +
879
IEEE80211_MAX_SSID_LEN +
880
local->scan_ies_len +
883
if (!local->sched_scan_ies.ie[i]) {
888
local->sched_scan_ies.len[i] =
889
ieee80211_build_preq_ies(local,
890
local->sched_scan_ies.ie[i],
891
req->ie, req->ie_len, i,
895
ret = drv_sched_scan_start(local, sdata, req,
896
&local->sched_scan_ies);
898
local->sched_scanning = true;
904
kfree(local->sched_scan_ies.ie[--i]);
906
mutex_unlock(&sdata->local->mtx);
910
int ieee80211_request_sched_scan_stop(struct ieee80211_sub_if_data *sdata)
912
struct ieee80211_local *local = sdata->local;
915
mutex_lock(&sdata->local->mtx);
917
if (!local->ops->sched_scan_stop) {
922
if (local->sched_scanning) {
923
for (i = 0; i < IEEE80211_NUM_BANDS; i++)
924
kfree(local->sched_scan_ies.ie[i]);
926
drv_sched_scan_stop(local, sdata);
927
local->sched_scanning = false;
930
mutex_unlock(&sdata->local->mtx);
935
void ieee80211_sched_scan_results(struct ieee80211_hw *hw)
937
struct ieee80211_local *local = hw_to_local(hw);
939
trace_api_sched_scan_results(local);
941
cfg80211_sched_scan_results(hw->wiphy);
943
EXPORT_SYMBOL(ieee80211_sched_scan_results);
945
void ieee80211_sched_scan_stopped_work(struct work_struct *work)
947
struct ieee80211_local *local =
948
container_of(work, struct ieee80211_local,
949
sched_scan_stopped_work);
952
mutex_lock(&local->mtx);
954
if (!local->sched_scanning) {
955
mutex_unlock(&local->mtx);
959
for (i = 0; i < IEEE80211_NUM_BANDS; i++)
960
kfree(local->sched_scan_ies.ie[i]);
962
local->sched_scanning = false;
964
mutex_unlock(&local->mtx);
966
cfg80211_sched_scan_stopped(local->hw.wiphy);
969
void ieee80211_sched_scan_stopped(struct ieee80211_hw *hw)
971
struct ieee80211_local *local = hw_to_local(hw);
973
trace_api_sched_scan_stopped(local);
975
ieee80211_queue_work(&local->hw, &local->sched_scan_stopped_work);
977
EXPORT_SYMBOL(ieee80211_sched_scan_stopped);