2 * Scanning implementation
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>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
15 /* TODO: figure out how to avoid that the "current BSS" expires */
17 #include <linux/wireless.h>
18 #include <linux/if_arp.h>
19 #include <linux/rtnetlink.h>
20 #include <net/mac80211.h>
22 #include "ieee80211_i.h"
23 #include "driver-ops.h"
26 #define IEEE80211_PROBE_DELAY (HZ / 33)
27 #define IEEE80211_CHANNEL_TIME (HZ / 33)
28 #define IEEE80211_PASSIVE_CHANNEL_TIME (HZ / 8)
30 struct ieee80211_bss
*
31 ieee80211_rx_bss_get(struct ieee80211_local
*local
, u8
*bssid
, int freq
,
32 u8
*ssid
, u8 ssid_len
)
34 return (void *)cfg80211_get_bss(local
->hw
.wiphy
,
35 ieee80211_get_channel(local
->hw
.wiphy
,
37 bssid
, ssid
, ssid_len
,
41 static void ieee80211_rx_bss_free(struct cfg80211_bss
*cbss
)
43 struct ieee80211_bss
*bss
= (void *)cbss
;
45 kfree(bss_mesh_id(bss
));
46 kfree(bss_mesh_cfg(bss
));
49 void ieee80211_rx_bss_put(struct ieee80211_local
*local
,
50 struct ieee80211_bss
*bss
)
52 cfg80211_put_bss((struct cfg80211_bss
*)bss
);
55 struct ieee80211_bss
*
56 ieee80211_bss_info_update(struct ieee80211_local
*local
,
57 struct ieee80211_rx_status
*rx_status
,
58 struct ieee80211_mgmt
*mgmt
,
60 struct ieee802_11_elems
*elems
,
61 struct ieee80211_channel
*channel
,
64 struct ieee80211_bss
*bss
;
68 if (local
->hw
.flags
& IEEE80211_HW_SIGNAL_DBM
)
69 signal
= rx_status
->signal
* 100;
70 else if (local
->hw
.flags
& IEEE80211_HW_SIGNAL_UNSPEC
)
71 signal
= (rx_status
->signal
* 100) / local
->hw
.max_signal
;
73 bss
= (void *)cfg80211_inform_bss_frame(local
->hw
.wiphy
, channel
,
74 mgmt
, len
, signal
, GFP_ATOMIC
);
79 bss
->cbss
.free_priv
= ieee80211_rx_bss_free
;
81 /* save the ERP value so that it is available at association time */
82 if (elems
->erp_info
&& elems
->erp_info_len
>= 1) {
83 bss
->erp_value
= elems
->erp_info
[0];
84 bss
->has_erp_value
= 1;
88 struct ieee80211_tim_ie
*tim_ie
=
89 (struct ieee80211_tim_ie
*)elems
->tim
;
90 bss
->dtim_period
= tim_ie
->dtim_period
;
93 /* set default value for buggy AP/no TIM element */
94 if (bss
->dtim_period
== 0)
97 /* replace old supported rates if we get new values */
99 if (elems
->supp_rates
) {
100 clen
= IEEE80211_MAX_SUPP_RATES
;
101 if (clen
> elems
->supp_rates_len
)
102 clen
= elems
->supp_rates_len
;
103 memcpy(bss
->supp_rates
, elems
->supp_rates
, clen
);
106 if (elems
->ext_supp_rates
) {
107 clen
= IEEE80211_MAX_SUPP_RATES
- srlen
;
108 if (clen
> elems
->ext_supp_rates_len
)
109 clen
= elems
->ext_supp_rates_len
;
110 memcpy(bss
->supp_rates
+ srlen
, elems
->ext_supp_rates
, clen
);
114 bss
->supp_rates_len
= srlen
;
116 bss
->wmm_used
= elems
->wmm_param
|| elems
->wmm_info
;
119 bss
->last_probe_resp
= jiffies
;
125 ieee80211_scan_rx(struct ieee80211_sub_if_data
*sdata
, struct sk_buff
*skb
)
127 struct ieee80211_rx_status
*rx_status
= IEEE80211_SKB_RXCB(skb
);
128 struct ieee80211_mgmt
*mgmt
;
129 struct ieee80211_bss
*bss
;
131 struct ieee80211_channel
*channel
;
135 bool presp
, beacon
= false;
136 struct ieee802_11_elems elems
;
139 return RX_DROP_UNUSABLE
;
141 mgmt
= (struct ieee80211_mgmt
*) skb
->data
;
142 fc
= mgmt
->frame_control
;
144 if (ieee80211_is_ctl(fc
))
148 return RX_DROP_MONITOR
;
150 presp
= ieee80211_is_probe_resp(fc
);
152 /* ignore ProbeResp to foreign address */
153 if (memcmp(mgmt
->da
, sdata
->dev
->dev_addr
, ETH_ALEN
))
154 return RX_DROP_MONITOR
;
157 elements
= mgmt
->u
.probe_resp
.variable
;
158 baselen
= offsetof(struct ieee80211_mgmt
, u
.probe_resp
.variable
);
160 beacon
= ieee80211_is_beacon(fc
);
161 baselen
= offsetof(struct ieee80211_mgmt
, u
.beacon
.variable
);
162 elements
= mgmt
->u
.beacon
.variable
;
165 if (!presp
&& !beacon
)
168 if (baselen
> skb
->len
)
169 return RX_DROP_MONITOR
;
171 ieee802_11_parse_elems(elements
, skb
->len
- baselen
, &elems
);
173 if (elems
.ds_params
&& elems
.ds_params_len
== 1)
174 freq
= ieee80211_channel_to_frequency(elems
.ds_params
[0]);
176 freq
= rx_status
->freq
;
178 channel
= ieee80211_get_channel(sdata
->local
->hw
.wiphy
, freq
);
180 if (!channel
|| channel
->flags
& IEEE80211_CHAN_DISABLED
)
181 return RX_DROP_MONITOR
;
183 bss
= ieee80211_bss_info_update(sdata
->local
, rx_status
,
184 mgmt
, skb
->len
, &elems
,
187 ieee80211_rx_bss_put(sdata
->local
, bss
);
194 * inform AP that we will go to sleep so that it will buffer the frames
197 static void ieee80211_scan_ps_enable(struct ieee80211_sub_if_data
*sdata
)
199 struct ieee80211_local
*local
= sdata
->local
;
201 local
->scan_ps_enabled
= false;
203 /* FIXME: what to do when local->pspolling is true? */
205 del_timer_sync(&local
->dynamic_ps_timer
);
206 cancel_work_sync(&local
->dynamic_ps_enable_work
);
208 if (local
->hw
.conf
.flags
& IEEE80211_CONF_PS
) {
209 local
->scan_ps_enabled
= true;
210 local
->hw
.conf
.flags
&= ~IEEE80211_CONF_PS
;
211 ieee80211_hw_config(local
, IEEE80211_CONF_CHANGE_PS
);
214 if (!(local
->scan_ps_enabled
) ||
215 !(local
->hw
.flags
& IEEE80211_HW_PS_NULLFUNC_STACK
))
217 * If power save was enabled, no need to send a nullfunc
218 * frame because AP knows that we are sleeping. But if the
219 * hardware is creating the nullfunc frame for power save
220 * status (ie. IEEE80211_HW_PS_NULLFUNC_STACK is not
221 * enabled) and power save was enabled, the firmware just
222 * sent a null frame with power save disabled. So we need
223 * to send a new nullfunc frame to inform the AP that we
224 * are again sleeping.
226 ieee80211_send_nullfunc(local
, sdata
, 1);
229 /* inform AP that we are awake again, unless power save is enabled */
230 static void ieee80211_scan_ps_disable(struct ieee80211_sub_if_data
*sdata
)
232 struct ieee80211_local
*local
= sdata
->local
;
234 if (!local
->ps_sdata
)
235 ieee80211_send_nullfunc(local
, sdata
, 0);
236 else if (local
->scan_ps_enabled
) {
238 * In !IEEE80211_HW_PS_NULLFUNC_STACK case the hardware
239 * will send a nullfunc frame with the powersave bit set
240 * even though the AP already knows that we are sleeping.
241 * This could be avoided by sending a null frame with power
242 * save bit disabled before enabling the power save, but
243 * this doesn't gain anything.
245 * When IEEE80211_HW_PS_NULLFUNC_STACK is enabled, no need
246 * to send a nullfunc frame because AP already knows that
247 * we are sleeping, let's just enable power save mode in
250 local
->hw
.conf
.flags
|= IEEE80211_CONF_PS
;
251 ieee80211_hw_config(local
, IEEE80211_CONF_CHANGE_PS
);
252 } else if (local
->hw
.conf
.dynamic_ps_timeout
> 0) {
254 * If IEEE80211_CONF_PS was not set and the dynamic_ps_timer
255 * had been running before leaving the operating channel,
256 * restart the timer now and send a nullfunc frame to inform
257 * the AP that we are awake.
259 ieee80211_send_nullfunc(local
, sdata
, 0);
260 mod_timer(&local
->dynamic_ps_timer
, jiffies
+
261 msecs_to_jiffies(local
->hw
.conf
.dynamic_ps_timeout
));
265 static void ieee80211_restore_scan_ies(struct ieee80211_local
*local
)
267 kfree(local
->scan_req
->ie
);
268 local
->scan_req
->ie
= local
->orig_ies
;
269 local
->scan_req
->ie_len
= local
->orig_ies_len
;
272 void ieee80211_scan_completed(struct ieee80211_hw
*hw
, bool aborted
)
274 struct ieee80211_local
*local
= hw_to_local(hw
);
275 struct ieee80211_sub_if_data
*sdata
;
278 mutex_lock(&local
->scan_mtx
);
281 * It's ok to abort a not-yet-running scan (that
282 * we have one at all will be verified by checking
283 * local->scan_req next), but not to complete it
286 if (WARN_ON(!local
->scanning
&& !aborted
))
289 if (WARN_ON(!local
->scan_req
)) {
290 mutex_unlock(&local
->scan_mtx
);
294 if (test_bit(SCAN_HW_SCANNING
, &local
->scanning
))
295 ieee80211_restore_scan_ies(local
);
297 if (local
->scan_req
!= local
->int_scan_req
)
298 cfg80211_scan_done(local
->scan_req
, aborted
);
299 local
->scan_req
= NULL
;
300 local
->scan_sdata
= NULL
;
302 was_hw_scan
= test_bit(SCAN_HW_SCANNING
, &local
->scanning
);
304 local
->scan_channel
= NULL
;
306 /* we only have to protect scan_req and hw/sw scan */
307 mutex_unlock(&local
->scan_mtx
);
309 ieee80211_hw_config(local
, IEEE80211_CONF_CHANGE_CHANNEL
);
313 ieee80211_configure_filter(local
);
315 drv_sw_scan_complete(local
);
317 mutex_lock(&local
->iflist_mtx
);
318 list_for_each_entry(sdata
, &local
->interfaces
, list
) {
319 if (!netif_running(sdata
->dev
))
322 /* Tell AP we're back */
323 if (sdata
->vif
.type
== NL80211_IFTYPE_STATION
) {
324 if (sdata
->u
.mgd
.associated
) {
325 ieee80211_scan_ps_disable(sdata
);
326 netif_tx_wake_all_queues(sdata
->dev
);
329 netif_tx_wake_all_queues(sdata
->dev
);
331 /* re-enable beaconing */
332 if (sdata
->vif
.type
== NL80211_IFTYPE_AP
||
333 sdata
->vif
.type
== NL80211_IFTYPE_ADHOC
||
334 sdata
->vif
.type
== NL80211_IFTYPE_MESH_POINT
)
335 ieee80211_bss_info_change_notify(
336 sdata
, BSS_CHANGED_BEACON_ENABLED
);
338 mutex_unlock(&local
->iflist_mtx
);
341 ieee80211_recalc_idle(local
);
342 ieee80211_mlme_notify_scan_completed(local
);
343 ieee80211_ibss_notify_scan_completed(local
);
344 ieee80211_mesh_notify_scan_completed(local
);
346 EXPORT_SYMBOL(ieee80211_scan_completed
);
348 static int ieee80211_start_sw_scan(struct ieee80211_local
*local
)
350 struct ieee80211_sub_if_data
*sdata
;
353 * Hardware/driver doesn't support hw_scan, so use software
354 * scanning instead. First send a nullfunc frame with power save
355 * bit on so that AP will buffer the frames for us while we are not
356 * listening, then send probe requests to each channel and wait for
357 * the responses. After all channels are scanned, tune back to the
358 * original channel and send a nullfunc frame with power save bit
359 * off to trigger the AP to send us all the buffered frames.
361 * Note that while local->sw_scanning is true everything else but
362 * nullfunc frames and probe requests will be dropped in
363 * ieee80211_tx_h_check_assoc().
365 drv_sw_scan_start(local
);
367 mutex_lock(&local
->iflist_mtx
);
368 list_for_each_entry(sdata
, &local
->interfaces
, list
) {
369 if (!netif_running(sdata
->dev
))
372 /* disable beaconing */
373 if (sdata
->vif
.type
== NL80211_IFTYPE_AP
||
374 sdata
->vif
.type
== NL80211_IFTYPE_ADHOC
||
375 sdata
->vif
.type
== NL80211_IFTYPE_MESH_POINT
)
376 ieee80211_bss_info_change_notify(
377 sdata
, BSS_CHANGED_BEACON_ENABLED
);
380 * only handle non-STA interfaces here, STA interfaces
381 * are handled in the scan state machine
383 if (sdata
->vif
.type
!= NL80211_IFTYPE_STATION
)
384 netif_tx_stop_all_queues(sdata
->dev
);
386 mutex_unlock(&local
->iflist_mtx
);
388 local
->next_scan_state
= SCAN_DECISION
;
389 local
->scan_channel_idx
= 0;
391 ieee80211_configure_filter(local
);
393 /* TODO: start scan as soon as all nullfunc frames are ACKed */
394 ieee80211_queue_delayed_work(&local
->hw
,
396 IEEE80211_CHANNEL_TIME
);
402 static int __ieee80211_start_scan(struct ieee80211_sub_if_data
*sdata
,
403 struct cfg80211_scan_request
*req
)
405 struct ieee80211_local
*local
= sdata
->local
;
406 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
412 if (req
!= local
->int_scan_req
&&
413 sdata
->vif
.type
== NL80211_IFTYPE_STATION
&&
414 !list_empty(&ifmgd
->work_list
)) {
415 /* actually wait for the work it's doing to finish/time out */
416 set_bit(IEEE80211_STA_REQ_SCAN
, &ifmgd
->request
);
417 local
->scan_req
= req
;
418 local
->scan_sdata
= sdata
;
422 if (local
->ops
->hw_scan
) {
426 ies
= kmalloc(2 + IEEE80211_MAX_SSID_LEN
+
427 local
->scan_ies_len
+ req
->ie_len
, GFP_KERNEL
);
431 ielen
= ieee80211_build_preq_ies(local
, ies
,
432 req
->ie
, req
->ie_len
);
433 local
->orig_ies
= req
->ie
;
434 local
->orig_ies_len
= req
->ie_len
;
439 local
->scan_req
= req
;
440 local
->scan_sdata
= sdata
;
442 if (local
->ops
->hw_scan
)
443 __set_bit(SCAN_HW_SCANNING
, &local
->scanning
);
445 __set_bit(SCAN_SW_SCANNING
, &local
->scanning
);
447 * Kicking off the scan need not be protected,
448 * only the scan variable stuff, since now
449 * local->scan_req is assigned and other callers
450 * will abort their scan attempts.
452 * This avoids getting a scan_mtx -> iflist_mtx
453 * dependency, so that the scan completed calls
454 * have more locking freedom.
457 ieee80211_recalc_idle(local
);
458 mutex_unlock(&local
->scan_mtx
);
460 if (local
->ops
->hw_scan
)
461 rc
= drv_hw_scan(local
, local
->scan_req
);
463 rc
= ieee80211_start_sw_scan(local
);
465 mutex_lock(&local
->scan_mtx
);
468 if (local
->ops
->hw_scan
)
469 ieee80211_restore_scan_ies(local
);
472 ieee80211_recalc_idle(local
);
474 local
->scan_req
= NULL
;
475 local
->scan_sdata
= NULL
;
481 static int ieee80211_scan_state_decision(struct ieee80211_local
*local
,
482 unsigned long *next_delay
)
484 bool associated
= false;
485 struct ieee80211_sub_if_data
*sdata
;
487 /* if no more bands/channels left, complete scan and advance to the idle state */
488 if (local
->scan_channel_idx
>= local
->scan_req
->n_channels
) {
489 ieee80211_scan_completed(&local
->hw
, false);
493 /* check if at least one STA interface is associated */
494 mutex_lock(&local
->iflist_mtx
);
495 list_for_each_entry(sdata
, &local
->interfaces
, list
) {
496 if (!netif_running(sdata
->dev
))
499 if (sdata
->vif
.type
== NL80211_IFTYPE_STATION
) {
500 if (sdata
->u
.mgd
.associated
) {
506 mutex_unlock(&local
->iflist_mtx
);
508 if (local
->scan_channel
) {
510 * we're currently scanning a different channel, let's
511 * switch back to the operating channel now if at least
512 * one interface is associated. Otherwise just scan the
516 local
->next_scan_state
= SCAN_ENTER_OPER_CHANNEL
;
518 local
->next_scan_state
= SCAN_SET_CHANNEL
;
521 * we're on the operating channel currently, let's
522 * leave that channel now to scan another one
524 local
->next_scan_state
= SCAN_LEAVE_OPER_CHANNEL
;
531 static void ieee80211_scan_state_leave_oper_channel(struct ieee80211_local
*local
,
532 unsigned long *next_delay
)
534 struct ieee80211_sub_if_data
*sdata
;
537 * notify the AP about us leaving the channel and stop all STA interfaces
539 mutex_lock(&local
->iflist_mtx
);
540 list_for_each_entry(sdata
, &local
->interfaces
, list
) {
541 if (!netif_running(sdata
->dev
))
544 if (sdata
->vif
.type
== NL80211_IFTYPE_STATION
) {
545 netif_tx_stop_all_queues(sdata
->dev
);
546 if (sdata
->u
.mgd
.associated
)
547 ieee80211_scan_ps_enable(sdata
);
550 mutex_unlock(&local
->iflist_mtx
);
552 __set_bit(SCAN_OFF_CHANNEL
, &local
->scanning
);
554 /* advance to the next channel to be scanned */
555 *next_delay
= HZ
/ 10;
556 local
->next_scan_state
= SCAN_SET_CHANNEL
;
559 static void ieee80211_scan_state_enter_oper_channel(struct ieee80211_local
*local
,
560 unsigned long *next_delay
)
562 struct ieee80211_sub_if_data
*sdata
= local
->scan_sdata
;
564 /* switch back to the operating channel */
565 local
->scan_channel
= NULL
;
566 ieee80211_hw_config(local
, IEEE80211_CONF_CHANGE_CHANNEL
);
569 * notify the AP about us being back and restart all STA interfaces
571 mutex_lock(&local
->iflist_mtx
);
572 list_for_each_entry(sdata
, &local
->interfaces
, list
) {
573 if (!netif_running(sdata
->dev
))
576 /* Tell AP we're back */
577 if (sdata
->vif
.type
== NL80211_IFTYPE_STATION
) {
578 if (sdata
->u
.mgd
.associated
)
579 ieee80211_scan_ps_disable(sdata
);
580 netif_tx_wake_all_queues(sdata
->dev
);
583 mutex_unlock(&local
->iflist_mtx
);
585 __clear_bit(SCAN_OFF_CHANNEL
, &local
->scanning
);
587 *next_delay
= HZ
/ 5;
588 local
->next_scan_state
= SCAN_DECISION
;
591 static void ieee80211_scan_state_set_channel(struct ieee80211_local
*local
,
592 unsigned long *next_delay
)
595 struct ieee80211_channel
*chan
;
596 struct ieee80211_sub_if_data
*sdata
= local
->scan_sdata
;
599 chan
= local
->scan_req
->channels
[local
->scan_channel_idx
];
601 if (chan
->flags
& IEEE80211_CHAN_DISABLED
||
602 (sdata
->vif
.type
== NL80211_IFTYPE_ADHOC
&&
603 chan
->flags
& IEEE80211_CHAN_NO_IBSS
))
607 local
->scan_channel
= chan
;
608 if (ieee80211_hw_config(local
,
609 IEEE80211_CONF_CHANGE_CHANNEL
))
613 /* advance state machine to next channel/band */
614 local
->scan_channel_idx
++;
617 /* if we skip this channel return to the decision state */
618 local
->next_scan_state
= SCAN_DECISION
;
623 * Probe delay is used to update the NAV, cf. 11.1.3.2.2
624 * (which unfortunately doesn't say _why_ step a) is done,
625 * but it waits for the probe delay or until a frame is
626 * received - and the received frame would update the NAV).
627 * For now, we do not support waiting until a frame is
630 * In any case, it is not necessary for a passive scan.
632 if (chan
->flags
& IEEE80211_CHAN_PASSIVE_SCAN
||
633 !local
->scan_req
->n_ssids
) {
634 *next_delay
= IEEE80211_PASSIVE_CHANNEL_TIME
;
635 local
->next_scan_state
= SCAN_DECISION
;
639 /* active scan, send probes */
640 *next_delay
= IEEE80211_PROBE_DELAY
;
641 local
->next_scan_state
= SCAN_SEND_PROBE
;
644 static void ieee80211_scan_state_send_probe(struct ieee80211_local
*local
,
645 unsigned long *next_delay
)
648 struct ieee80211_sub_if_data
*sdata
= local
->scan_sdata
;
650 for (i
= 0; i
< local
->scan_req
->n_ssids
; i
++)
651 ieee80211_send_probe_req(
653 local
->scan_req
->ssids
[i
].ssid
,
654 local
->scan_req
->ssids
[i
].ssid_len
,
655 local
->scan_req
->ie
, local
->scan_req
->ie_len
);
658 * After sending probe requests, wait for probe responses
661 *next_delay
= IEEE80211_CHANNEL_TIME
;
662 local
->next_scan_state
= SCAN_DECISION
;
665 void ieee80211_scan_work(struct work_struct
*work
)
667 struct ieee80211_local
*local
=
668 container_of(work
, struct ieee80211_local
, scan_work
.work
);
669 struct ieee80211_sub_if_data
*sdata
= local
->scan_sdata
;
670 unsigned long next_delay
= 0;
672 mutex_lock(&local
->scan_mtx
);
673 if (!sdata
|| !local
->scan_req
) {
674 mutex_unlock(&local
->scan_mtx
);
678 if (local
->scan_req
&& !local
->scanning
) {
679 struct cfg80211_scan_request
*req
= local
->scan_req
;
682 local
->scan_req
= NULL
;
683 local
->scan_sdata
= NULL
;
685 rc
= __ieee80211_start_scan(sdata
, req
);
686 mutex_unlock(&local
->scan_mtx
);
689 ieee80211_scan_completed(&local
->hw
, true);
693 mutex_unlock(&local
->scan_mtx
);
696 * Avoid re-scheduling when the sdata is going away.
698 if (!netif_running(sdata
->dev
)) {
699 ieee80211_scan_completed(&local
->hw
, true);
704 * as long as no delay is required advance immediately
705 * without scheduling a new work
708 switch (local
->next_scan_state
) {
710 if (ieee80211_scan_state_decision(local
, &next_delay
))
713 case SCAN_SET_CHANNEL
:
714 ieee80211_scan_state_set_channel(local
, &next_delay
);
716 case SCAN_SEND_PROBE
:
717 ieee80211_scan_state_send_probe(local
, &next_delay
);
719 case SCAN_LEAVE_OPER_CHANNEL
:
720 ieee80211_scan_state_leave_oper_channel(local
, &next_delay
);
722 case SCAN_ENTER_OPER_CHANNEL
:
723 ieee80211_scan_state_enter_oper_channel(local
, &next_delay
);
726 } while (next_delay
== 0);
728 ieee80211_queue_delayed_work(&local
->hw
, &local
->scan_work
, next_delay
);
731 int ieee80211_request_scan(struct ieee80211_sub_if_data
*sdata
,
732 struct cfg80211_scan_request
*req
)
736 mutex_lock(&sdata
->local
->scan_mtx
);
737 res
= __ieee80211_start_scan(sdata
, req
);
738 mutex_unlock(&sdata
->local
->scan_mtx
);
743 int ieee80211_request_internal_scan(struct ieee80211_sub_if_data
*sdata
,
744 const u8
*ssid
, u8 ssid_len
)
746 struct ieee80211_local
*local
= sdata
->local
;
749 mutex_lock(&local
->scan_mtx
);
755 memcpy(local
->int_scan_req
->ssids
[0].ssid
, ssid
, IEEE80211_MAX_SSID_LEN
);
756 local
->int_scan_req
->ssids
[0].ssid_len
= ssid_len
;
758 ret
= __ieee80211_start_scan(sdata
, sdata
->local
->int_scan_req
);
760 mutex_unlock(&local
->scan_mtx
);
764 void ieee80211_scan_cancel(struct ieee80211_local
*local
)
768 cancel_delayed_work_sync(&local
->scan_work
);
771 * Only call this function when a scan can't be
772 * queued -- mostly at suspend under RTNL.
774 mutex_lock(&local
->scan_mtx
);
775 abortscan
= test_bit(SCAN_SW_SCANNING
, &local
->scanning
) ||
776 (!local
->scanning
&& local
->scan_req
);
777 mutex_unlock(&local
->scan_mtx
);
780 ieee80211_scan_completed(&local
->hw
, true);