diff options
Diffstat (limited to 'net/mac80211/scan.c')
-rw-r--r-- | net/mac80211/scan.c | 414 |
1 files changed, 222 insertions, 192 deletions
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c index f25b07feabf9..c99ef8d04d3d 100644 --- a/net/mac80211/scan.c +++ b/net/mac80211/scan.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <net/iw_handler.h> | 21 | #include <net/iw_handler.h> |
22 | 22 | ||
23 | #include "ieee80211_i.h" | 23 | #include "ieee80211_i.h" |
24 | #include "driver-ops.h" | ||
24 | #include "mesh.h" | 25 | #include "mesh.h" |
25 | 26 | ||
26 | #define IEEE80211_PROBE_DELAY (HZ / 33) | 27 | #define IEEE80211_PROBE_DELAY (HZ / 33) |
@@ -202,18 +203,6 @@ ieee80211_scan_rx(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, | |||
202 | return RX_QUEUED; | 203 | return RX_QUEUED; |
203 | } | 204 | } |
204 | 205 | ||
205 | void ieee80211_scan_failed(struct ieee80211_local *local) | ||
206 | { | ||
207 | if (WARN_ON(!local->scan_req)) | ||
208 | return; | ||
209 | |||
210 | /* notify cfg80211 about the failed scan */ | ||
211 | if (local->scan_req != &local->int_scan_req) | ||
212 | cfg80211_scan_done(local->scan_req, true); | ||
213 | |||
214 | local->scan_req = NULL; | ||
215 | } | ||
216 | |||
217 | /* | 206 | /* |
218 | * inform AP that we will go to sleep so that it will buffer the frames | 207 | * inform AP that we will go to sleep so that it will buffer the frames |
219 | * while we scan | 208 | * while we scan |
@@ -274,55 +263,61 @@ static void ieee80211_scan_ps_disable(struct ieee80211_sub_if_data *sdata) | |||
274 | } | 263 | } |
275 | } | 264 | } |
276 | 265 | ||
266 | static void ieee80211_restore_scan_ies(struct ieee80211_local *local) | ||
267 | { | ||
268 | kfree(local->scan_req->ie); | ||
269 | local->scan_req->ie = local->orig_ies; | ||
270 | local->scan_req->ie_len = local->orig_ies_len; | ||
271 | } | ||
272 | |||
277 | void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted) | 273 | void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted) |
278 | { | 274 | { |
279 | struct ieee80211_local *local = hw_to_local(hw); | 275 | struct ieee80211_local *local = hw_to_local(hw); |
280 | struct ieee80211_sub_if_data *sdata; | 276 | struct ieee80211_sub_if_data *sdata; |
277 | bool was_hw_scan; | ||
281 | 278 | ||
282 | if (WARN_ON(!local->hw_scanning && !local->sw_scanning)) | 279 | mutex_lock(&local->scan_mtx); |
283 | return; | ||
284 | 280 | ||
285 | if (WARN_ON(!local->scan_req)) | 281 | if (WARN_ON(!local->hw_scanning && !local->sw_scanning)) { |
282 | mutex_unlock(&local->scan_mtx); | ||
286 | return; | 283 | return; |
284 | } | ||
287 | 285 | ||
288 | if (local->hw_scanning) { | 286 | if (WARN_ON(!local->scan_req)) { |
289 | kfree(local->scan_req->ie); | 287 | mutex_unlock(&local->scan_mtx); |
290 | local->scan_req->ie = local->orig_ies; | 288 | return; |
291 | local->scan_req->ie_len = local->orig_ies_len; | ||
292 | } | 289 | } |
293 | 290 | ||
291 | if (local->hw_scanning) | ||
292 | ieee80211_restore_scan_ies(local); | ||
293 | |||
294 | if (local->scan_req != &local->int_scan_req) | 294 | if (local->scan_req != &local->int_scan_req) |
295 | cfg80211_scan_done(local->scan_req, aborted); | 295 | cfg80211_scan_done(local->scan_req, aborted); |
296 | local->scan_req = NULL; | 296 | local->scan_req = NULL; |
297 | 297 | ||
298 | if (local->hw_scanning) { | 298 | was_hw_scan = local->hw_scanning; |
299 | local->hw_scanning = false; | 299 | local->hw_scanning = false; |
300 | /* | ||
301 | * Somebody might have requested channel change during scan | ||
302 | * that we won't have acted upon, try now. ieee80211_hw_config | ||
303 | * will set the flag based on actual changes. | ||
304 | */ | ||
305 | ieee80211_hw_config(local, 0); | ||
306 | goto done; | ||
307 | } | ||
308 | |||
309 | local->sw_scanning = false; | 300 | local->sw_scanning = false; |
301 | |||
302 | /* we only have to protect scan_req and hw/sw scan */ | ||
303 | mutex_unlock(&local->scan_mtx); | ||
304 | |||
310 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); | 305 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); |
306 | if (was_hw_scan) | ||
307 | goto done; | ||
311 | 308 | ||
312 | netif_tx_lock_bh(local->mdev); | 309 | netif_tx_lock_bh(local->mdev); |
313 | netif_addr_lock(local->mdev); | 310 | netif_addr_lock(local->mdev); |
314 | local->filter_flags &= ~FIF_BCN_PRBRESP_PROMISC; | 311 | local->filter_flags &= ~FIF_BCN_PRBRESP_PROMISC; |
315 | local->ops->configure_filter(local_to_hw(local), | 312 | drv_configure_filter(local, FIF_BCN_PRBRESP_PROMISC, |
316 | FIF_BCN_PRBRESP_PROMISC, | 313 | &local->filter_flags, |
317 | &local->filter_flags, | 314 | local->mdev->mc_count, |
318 | local->mdev->mc_count, | 315 | local->mdev->mc_list); |
319 | local->mdev->mc_list); | ||
320 | 316 | ||
321 | netif_addr_unlock(local->mdev); | 317 | netif_addr_unlock(local->mdev); |
322 | netif_tx_unlock_bh(local->mdev); | 318 | netif_tx_unlock_bh(local->mdev); |
323 | 319 | ||
324 | if (local->ops->sw_scan_complete) | 320 | drv_sw_scan_complete(local); |
325 | local->ops->sw_scan_complete(local_to_hw(local)); | ||
326 | 321 | ||
327 | mutex_lock(&local->iflist_mtx); | 322 | mutex_lock(&local->iflist_mtx); |
328 | list_for_each_entry(sdata, &local->interfaces, list) { | 323 | list_for_each_entry(sdata, &local->interfaces, list) { |
@@ -342,18 +337,160 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted) | |||
342 | if (sdata->vif.type == NL80211_IFTYPE_AP || | 337 | if (sdata->vif.type == NL80211_IFTYPE_AP || |
343 | sdata->vif.type == NL80211_IFTYPE_ADHOC || | 338 | sdata->vif.type == NL80211_IFTYPE_ADHOC || |
344 | sdata->vif.type == NL80211_IFTYPE_MESH_POINT) | 339 | sdata->vif.type == NL80211_IFTYPE_MESH_POINT) |
345 | ieee80211_if_config(sdata, | 340 | ieee80211_bss_info_change_notify( |
346 | IEEE80211_IFCC_BEACON_ENABLED); | 341 | sdata, BSS_CHANGED_BEACON_ENABLED); |
347 | } | 342 | } |
348 | mutex_unlock(&local->iflist_mtx); | 343 | mutex_unlock(&local->iflist_mtx); |
349 | 344 | ||
350 | done: | 345 | done: |
346 | ieee80211_recalc_idle(local); | ||
351 | ieee80211_mlme_notify_scan_completed(local); | 347 | ieee80211_mlme_notify_scan_completed(local); |
352 | ieee80211_ibss_notify_scan_completed(local); | 348 | ieee80211_ibss_notify_scan_completed(local); |
353 | ieee80211_mesh_notify_scan_completed(local); | 349 | ieee80211_mesh_notify_scan_completed(local); |
354 | } | 350 | } |
355 | EXPORT_SYMBOL(ieee80211_scan_completed); | 351 | EXPORT_SYMBOL(ieee80211_scan_completed); |
356 | 352 | ||
353 | static int ieee80211_start_sw_scan(struct ieee80211_local *local) | ||
354 | { | ||
355 | struct ieee80211_sub_if_data *sdata; | ||
356 | |||
357 | /* | ||
358 | * Hardware/driver doesn't support hw_scan, so use software | ||
359 | * scanning instead. First send a nullfunc frame with power save | ||
360 | * bit on so that AP will buffer the frames for us while we are not | ||
361 | * listening, then send probe requests to each channel and wait for | ||
362 | * the responses. After all channels are scanned, tune back to the | ||
363 | * original channel and send a nullfunc frame with power save bit | ||
364 | * off to trigger the AP to send us all the buffered frames. | ||
365 | * | ||
366 | * Note that while local->sw_scanning is true everything else but | ||
367 | * nullfunc frames and probe requests will be dropped in | ||
368 | * ieee80211_tx_h_check_assoc(). | ||
369 | */ | ||
370 | drv_sw_scan_start(local); | ||
371 | |||
372 | mutex_lock(&local->iflist_mtx); | ||
373 | list_for_each_entry(sdata, &local->interfaces, list) { | ||
374 | if (!netif_running(sdata->dev)) | ||
375 | continue; | ||
376 | |||
377 | /* disable beaconing */ | ||
378 | if (sdata->vif.type == NL80211_IFTYPE_AP || | ||
379 | sdata->vif.type == NL80211_IFTYPE_ADHOC || | ||
380 | sdata->vif.type == NL80211_IFTYPE_MESH_POINT) | ||
381 | ieee80211_bss_info_change_notify( | ||
382 | sdata, BSS_CHANGED_BEACON_ENABLED); | ||
383 | |||
384 | if (sdata->vif.type == NL80211_IFTYPE_STATION) { | ||
385 | if (sdata->u.mgd.flags & IEEE80211_STA_ASSOCIATED) { | ||
386 | netif_tx_stop_all_queues(sdata->dev); | ||
387 | ieee80211_scan_ps_enable(sdata); | ||
388 | } | ||
389 | } else | ||
390 | netif_tx_stop_all_queues(sdata->dev); | ||
391 | } | ||
392 | mutex_unlock(&local->iflist_mtx); | ||
393 | |||
394 | local->scan_state = SCAN_SET_CHANNEL; | ||
395 | local->scan_channel_idx = 0; | ||
396 | |||
397 | netif_addr_lock_bh(local->mdev); | ||
398 | local->filter_flags |= FIF_BCN_PRBRESP_PROMISC; | ||
399 | drv_configure_filter(local, FIF_BCN_PRBRESP_PROMISC, | ||
400 | &local->filter_flags, | ||
401 | local->mdev->mc_count, | ||
402 | local->mdev->mc_list); | ||
403 | netif_addr_unlock_bh(local->mdev); | ||
404 | |||
405 | /* TODO: start scan as soon as all nullfunc frames are ACKed */ | ||
406 | queue_delayed_work(local->hw.workqueue, &local->scan_work, | ||
407 | IEEE80211_CHANNEL_TIME); | ||
408 | |||
409 | return 0; | ||
410 | } | ||
411 | |||
412 | |||
413 | static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata, | ||
414 | struct cfg80211_scan_request *req) | ||
415 | { | ||
416 | struct ieee80211_local *local = sdata->local; | ||
417 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | ||
418 | int rc; | ||
419 | |||
420 | if (local->scan_req) | ||
421 | return -EBUSY; | ||
422 | |||
423 | if (local->ops->hw_scan) { | ||
424 | u8 *ies; | ||
425 | int ielen; | ||
426 | |||
427 | ies = kmalloc(2 + IEEE80211_MAX_SSID_LEN + | ||
428 | local->scan_ies_len + req->ie_len, GFP_KERNEL); | ||
429 | if (!ies) | ||
430 | return -ENOMEM; | ||
431 | |||
432 | ielen = ieee80211_build_preq_ies(local, ies, | ||
433 | req->ie, req->ie_len); | ||
434 | local->orig_ies = req->ie; | ||
435 | local->orig_ies_len = req->ie_len; | ||
436 | req->ie = ies; | ||
437 | req->ie_len = ielen; | ||
438 | } | ||
439 | |||
440 | local->scan_req = req; | ||
441 | local->scan_sdata = sdata; | ||
442 | |||
443 | if (req != &local->int_scan_req && | ||
444 | sdata->vif.type == NL80211_IFTYPE_STATION && | ||
445 | (ifmgd->state == IEEE80211_STA_MLME_DIRECT_PROBE || | ||
446 | ifmgd->state == IEEE80211_STA_MLME_AUTHENTICATE || | ||
447 | ifmgd->state == IEEE80211_STA_MLME_ASSOCIATE)) { | ||
448 | /* actually wait for the assoc to finish/time out */ | ||
449 | set_bit(IEEE80211_STA_REQ_SCAN, &ifmgd->request); | ||
450 | return 0; | ||
451 | } | ||
452 | |||
453 | if (local->ops->hw_scan) | ||
454 | local->hw_scanning = true; | ||
455 | else | ||
456 | local->sw_scanning = true; | ||
457 | /* | ||
458 | * Kicking off the scan need not be protected, | ||
459 | * only the scan variable stuff, since now | ||
460 | * local->scan_req is assigned and other callers | ||
461 | * will abort their scan attempts. | ||
462 | * | ||
463 | * This avoids getting a scan_mtx -> iflist_mtx | ||
464 | * dependency, so that the scan completed calls | ||
465 | * have more locking freedom. | ||
466 | */ | ||
467 | |||
468 | ieee80211_recalc_idle(local); | ||
469 | mutex_unlock(&local->scan_mtx); | ||
470 | |||
471 | if (local->ops->hw_scan) | ||
472 | rc = drv_hw_scan(local, local->scan_req); | ||
473 | else | ||
474 | rc = ieee80211_start_sw_scan(local); | ||
475 | |||
476 | mutex_lock(&local->scan_mtx); | ||
477 | |||
478 | if (rc) { | ||
479 | if (local->ops->hw_scan) { | ||
480 | local->hw_scanning = false; | ||
481 | ieee80211_restore_scan_ies(local); | ||
482 | } else | ||
483 | local->sw_scanning = false; | ||
484 | |||
485 | ieee80211_recalc_idle(local); | ||
486 | |||
487 | local->scan_req = NULL; | ||
488 | local->scan_sdata = NULL; | ||
489 | } | ||
490 | |||
491 | return rc; | ||
492 | } | ||
493 | |||
357 | void ieee80211_scan_work(struct work_struct *work) | 494 | void ieee80211_scan_work(struct work_struct *work) |
358 | { | 495 | { |
359 | struct ieee80211_local *local = | 496 | struct ieee80211_local *local = |
@@ -363,17 +500,41 @@ void ieee80211_scan_work(struct work_struct *work) | |||
363 | int skip, i; | 500 | int skip, i; |
364 | unsigned long next_delay = 0; | 501 | unsigned long next_delay = 0; |
365 | 502 | ||
503 | mutex_lock(&local->scan_mtx); | ||
504 | if (!sdata || !local->scan_req) { | ||
505 | mutex_unlock(&local->scan_mtx); | ||
506 | return; | ||
507 | } | ||
508 | |||
509 | if (local->scan_req && !(local->sw_scanning || local->hw_scanning)) { | ||
510 | struct cfg80211_scan_request *req = local->scan_req; | ||
511 | int rc; | ||
512 | |||
513 | local->scan_req = NULL; | ||
514 | |||
515 | rc = __ieee80211_start_scan(sdata, req); | ||
516 | mutex_unlock(&local->scan_mtx); | ||
517 | |||
518 | if (rc) | ||
519 | ieee80211_scan_completed(&local->hw, true); | ||
520 | return; | ||
521 | } | ||
522 | |||
523 | mutex_unlock(&local->scan_mtx); | ||
524 | |||
366 | /* | 525 | /* |
367 | * Avoid re-scheduling when the sdata is going away. | 526 | * Avoid re-scheduling when the sdata is going away. |
368 | */ | 527 | */ |
369 | if (!netif_running(sdata->dev)) | 528 | if (!netif_running(sdata->dev)) { |
529 | ieee80211_scan_completed(&local->hw, true); | ||
370 | return; | 530 | return; |
531 | } | ||
371 | 532 | ||
372 | switch (local->scan_state) { | 533 | switch (local->scan_state) { |
373 | case SCAN_SET_CHANNEL: | 534 | case SCAN_SET_CHANNEL: |
374 | /* if no more bands/channels left, complete scan */ | 535 | /* if no more bands/channels left, complete scan */ |
375 | if (local->scan_channel_idx >= local->scan_req->n_channels) { | 536 | if (local->scan_channel_idx >= local->scan_req->n_channels) { |
376 | ieee80211_scan_completed(local_to_hw(local), false); | 537 | ieee80211_scan_completed(&local->hw, false); |
377 | return; | 538 | return; |
378 | } | 539 | } |
379 | skip = 0; | 540 | skip = 0; |
@@ -422,166 +583,35 @@ void ieee80211_scan_work(struct work_struct *work) | |||
422 | next_delay); | 583 | next_delay); |
423 | } | 584 | } |
424 | 585 | ||
425 | 586 | int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata, | |
426 | int ieee80211_start_scan(struct ieee80211_sub_if_data *scan_sdata, | 587 | struct cfg80211_scan_request *req) |
427 | struct cfg80211_scan_request *req) | ||
428 | { | 588 | { |
429 | struct ieee80211_local *local = scan_sdata->local; | 589 | int res; |
430 | struct ieee80211_sub_if_data *sdata; | ||
431 | |||
432 | if (!req) | ||
433 | return -EINVAL; | ||
434 | |||
435 | if (local->scan_req && local->scan_req != req) | ||
436 | return -EBUSY; | ||
437 | |||
438 | local->scan_req = req; | ||
439 | 590 | ||
440 | /* MLME-SCAN.request (page 118) page 144 (11.1.3.1) | 591 | mutex_lock(&sdata->local->scan_mtx); |
441 | * BSSType: INFRASTRUCTURE, INDEPENDENT, ANY_BSS | 592 | res = __ieee80211_start_scan(sdata, req); |
442 | * BSSID: MACAddress | 593 | mutex_unlock(&sdata->local->scan_mtx); |
443 | * SSID | ||
444 | * ScanType: ACTIVE, PASSIVE | ||
445 | * ProbeDelay: delay (in microseconds) to be used prior to transmitting | ||
446 | * a Probe frame during active scanning | ||
447 | * ChannelList | ||
448 | * MinChannelTime (>= ProbeDelay), in TU | ||
449 | * MaxChannelTime: (>= MinChannelTime), in TU | ||
450 | */ | ||
451 | 594 | ||
452 | /* MLME-SCAN.confirm | 595 | return res; |
453 | * BSSDescriptionSet | ||
454 | * ResultCode: SUCCESS, INVALID_PARAMETERS | ||
455 | */ | ||
456 | |||
457 | if (local->sw_scanning || local->hw_scanning) { | ||
458 | if (local->scan_sdata == scan_sdata) | ||
459 | return 0; | ||
460 | return -EBUSY; | ||
461 | } | ||
462 | |||
463 | if (local->ops->hw_scan) { | ||
464 | u8 *ies; | ||
465 | int rc, ielen; | ||
466 | |||
467 | ies = kmalloc(2 + IEEE80211_MAX_SSID_LEN + | ||
468 | local->scan_ies_len + req->ie_len, GFP_KERNEL); | ||
469 | if (!ies) | ||
470 | return -ENOMEM; | ||
471 | |||
472 | ielen = ieee80211_build_preq_ies(local, ies, | ||
473 | req->ie, req->ie_len); | ||
474 | local->orig_ies = req->ie; | ||
475 | local->orig_ies_len = req->ie_len; | ||
476 | req->ie = ies; | ||
477 | req->ie_len = ielen; | ||
478 | |||
479 | local->hw_scanning = true; | ||
480 | rc = local->ops->hw_scan(local_to_hw(local), req); | ||
481 | if (rc) { | ||
482 | local->hw_scanning = false; | ||
483 | kfree(ies); | ||
484 | req->ie_len = local->orig_ies_len; | ||
485 | req->ie = local->orig_ies; | ||
486 | return rc; | ||
487 | } | ||
488 | local->scan_sdata = scan_sdata; | ||
489 | return 0; | ||
490 | } | ||
491 | |||
492 | /* | ||
493 | * Hardware/driver doesn't support hw_scan, so use software | ||
494 | * scanning instead. First send a nullfunc frame with power save | ||
495 | * bit on so that AP will buffer the frames for us while we are not | ||
496 | * listening, then send probe requests to each channel and wait for | ||
497 | * the responses. After all channels are scanned, tune back to the | ||
498 | * original channel and send a nullfunc frame with power save bit | ||
499 | * off to trigger the AP to send us all the buffered frames. | ||
500 | * | ||
501 | * Note that while local->sw_scanning is true everything else but | ||
502 | * nullfunc frames and probe requests will be dropped in | ||
503 | * ieee80211_tx_h_check_assoc(). | ||
504 | */ | ||
505 | local->sw_scanning = true; | ||
506 | if (local->ops->sw_scan_start) | ||
507 | local->ops->sw_scan_start(local_to_hw(local)); | ||
508 | |||
509 | mutex_lock(&local->iflist_mtx); | ||
510 | list_for_each_entry(sdata, &local->interfaces, list) { | ||
511 | if (!netif_running(sdata->dev)) | ||
512 | continue; | ||
513 | |||
514 | /* disable beaconing */ | ||
515 | if (sdata->vif.type == NL80211_IFTYPE_AP || | ||
516 | sdata->vif.type == NL80211_IFTYPE_ADHOC || | ||
517 | sdata->vif.type == NL80211_IFTYPE_MESH_POINT) | ||
518 | ieee80211_if_config(sdata, | ||
519 | IEEE80211_IFCC_BEACON_ENABLED); | ||
520 | |||
521 | if (sdata->vif.type == NL80211_IFTYPE_STATION) { | ||
522 | if (sdata->u.mgd.flags & IEEE80211_STA_ASSOCIATED) { | ||
523 | netif_tx_stop_all_queues(sdata->dev); | ||
524 | ieee80211_scan_ps_enable(sdata); | ||
525 | } | ||
526 | } else | ||
527 | netif_tx_stop_all_queues(sdata->dev); | ||
528 | } | ||
529 | mutex_unlock(&local->iflist_mtx); | ||
530 | |||
531 | local->scan_state = SCAN_SET_CHANNEL; | ||
532 | local->scan_channel_idx = 0; | ||
533 | local->scan_sdata = scan_sdata; | ||
534 | local->scan_req = req; | ||
535 | |||
536 | netif_addr_lock_bh(local->mdev); | ||
537 | local->filter_flags |= FIF_BCN_PRBRESP_PROMISC; | ||
538 | local->ops->configure_filter(local_to_hw(local), | ||
539 | FIF_BCN_PRBRESP_PROMISC, | ||
540 | &local->filter_flags, | ||
541 | local->mdev->mc_count, | ||
542 | local->mdev->mc_list); | ||
543 | netif_addr_unlock_bh(local->mdev); | ||
544 | |||
545 | /* TODO: start scan as soon as all nullfunc frames are ACKed */ | ||
546 | queue_delayed_work(local->hw.workqueue, &local->scan_work, | ||
547 | IEEE80211_CHANNEL_TIME); | ||
548 | |||
549 | return 0; | ||
550 | } | 596 | } |
551 | 597 | ||
552 | 598 | int ieee80211_request_internal_scan(struct ieee80211_sub_if_data *sdata, | |
553 | int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata, | 599 | const u8 *ssid, u8 ssid_len) |
554 | struct cfg80211_scan_request *req) | ||
555 | { | 600 | { |
556 | struct ieee80211_local *local = sdata->local; | 601 | struct ieee80211_local *local = sdata->local; |
557 | struct ieee80211_if_managed *ifmgd; | 602 | int ret = -EBUSY; |
558 | |||
559 | if (!req) | ||
560 | return -EINVAL; | ||
561 | |||
562 | if (local->scan_req && local->scan_req != req) | ||
563 | return -EBUSY; | ||
564 | |||
565 | local->scan_req = req; | ||
566 | 603 | ||
567 | if (sdata->vif.type != NL80211_IFTYPE_STATION) | 604 | mutex_lock(&local->scan_mtx); |
568 | return ieee80211_start_scan(sdata, req); | ||
569 | 605 | ||
570 | /* | 606 | /* busy scanning */ |
571 | * STA has a state machine that might need to defer scanning | 607 | if (local->scan_req) |
572 | * while it's trying to associate/authenticate, therefore we | 608 | goto unlock; |
573 | * queue it up to the state machine in that case. | ||
574 | */ | ||
575 | 609 | ||
576 | if (local->sw_scanning || local->hw_scanning) { | 610 | memcpy(local->int_scan_req.ssids[0].ssid, ssid, IEEE80211_MAX_SSID_LEN); |
577 | if (local->scan_sdata == sdata) | 611 | local->int_scan_req.ssids[0].ssid_len = ssid_len; |
578 | return 0; | ||
579 | return -EBUSY; | ||
580 | } | ||
581 | |||
582 | ifmgd = &sdata->u.mgd; | ||
583 | set_bit(IEEE80211_STA_REQ_SCAN, &ifmgd->request); | ||
584 | queue_work(local->hw.workqueue, &ifmgd->work); | ||
585 | 612 | ||
586 | return 0; | 613 | ret = __ieee80211_start_scan(sdata, &sdata->local->int_scan_req); |
614 | unlock: | ||
615 | mutex_unlock(&local->scan_mtx); | ||
616 | return ret; | ||
587 | } | 617 | } |