15 #include <linux/if_arp.h>
17 #include <linux/rtnetlink.h>
20 #include <linux/slab.h>
21 #include <linux/export.h>
28 #define IEEE80211_PROBE_DELAY (HZ / 33)
29 #define IEEE80211_CHANNEL_TIME (HZ / 33)
30 #define IEEE80211_PASSIVE_CHANNEL_TIME (HZ / 8)
32 static void ieee80211_rx_bss_free(
struct cfg80211_bss *cbss)
36 kfree(bss_mesh_id(bss));
37 kfree(bss_mesh_cfg(bss));
80 signal = rx_status->
signal * 100;
82 signal = (rx_status->
signal * 100) / local->
hw.max_signal;
90 bss = (
void *)cbss->priv;
189 if (
likely(!sdata1 && !sdata2))
194 if ((!sdata1 || !ether_addr_equal(mgmt->
da, sdata1->
vif.addr)) &&
195 (!sdata2 || !ether_addr_equal(mgmt->
da, sdata2->
vif.addr)))
207 if (baselen > skb->
len)
224 mgmt, skb->
len, &elems,
235 int i, ielen, n_chans;
244 if (req->
channels[i]->band == band) {
258 req->
rates[band], 0);
284 if (was_hw_scan && !aborted && ieee80211_prep_hw_scan(local)) {
287 rc = drv_hw_scan(local,
289 lockdep_is_held(&local->
mtx)),
312 drv_sw_scan_complete(local);
328 trace_api_scan_completed(local, aborted);
352 drv_sw_scan_start(local);
392 if (!ieee80211_can_scan(local,
395 lockdep_is_held(&local->
mtx))))
402 static void ieee80211_scan_state_send_probe(
struct ieee80211_local *local,
403 unsigned long *next_delay)
410 lockdep_is_held(&local->
mtx));
412 for (i = 0; i < local->
scan_req->n_ssids; i++)
418 local->
scan_req->rates[band],
false,
420 local->
hw.conf.channel);
441 if (!ieee80211_can_scan(local, sdata)) {
448 if (local->
ops->hw_scan) {
480 if (local->
ops->hw_scan) {
488 unsigned long next_delay;
496 drv_sw_scan_start(local);
508 ieee80211_scan_state_send_probe(local, &next_delay);
523 if (local->
ops->hw_scan) {
524 WARN_ON(!ieee80211_prep_hw_scan(local));
525 rc = drv_hw_scan(local, sdata, local->
hw_scan_req);
527 rc = ieee80211_start_sw_scan(local);
555 static void ieee80211_scan_state_decision(
struct ieee80211_local *local,
556 unsigned long *next_delay)
558 bool associated =
false;
559 bool tx_empty =
true;
561 bool listen_int_exceeded;
562 unsigned long min_beacon_int = 0;
573 if (!ieee80211_sdata_running(sdata))
577 if (sdata->
u.
mgd.associated) {
580 if (sdata->
vif.bss_conf.beacon_int <
581 min_beacon_int || min_beacon_int == 0)
583 sdata->
vif.bss_conf.beacon_int;
585 if (!qdisc_all_tx_empty(sdata->
dev)) {
613 ieee80211_scan_get_channel_time(next_chan),
618 ieee80211_scan_get_channel_time(next_chan),
621 local->
hw.conf.listen_interval);
623 if (associated && (!tx_empty || bad_latency || listen_int_exceeded))
631 static void ieee80211_scan_state_set_channel(
struct ieee80211_local *local,
632 unsigned long *next_delay)
676 static void ieee80211_scan_state_suspend(
struct ieee80211_local *local,
677 unsigned long *next_delay)
690 *next_delay =
HZ / 5;
696 unsigned long *next_delay)
701 if (local->
ops->flush) {
702 drv_flush(local,
false);
705 *next_delay =
HZ / 10;
719 unsigned long next_delay = 0;
725 lockdep_is_held(&local->
mtx));
748 rc = __ieee80211_start_scan(sdata, req);
761 if (!ieee80211_sdata_running(sdata)) {
771 if (!ieee80211_sdata_running(sdata)) {
783 ieee80211_scan_state_decision(local, &next_delay);
786 ieee80211_scan_state_set_channel(local, &next_delay);
789 ieee80211_scan_state_send_probe(local, &next_delay);
792 ieee80211_scan_state_suspend(local, &next_delay);
795 ieee80211_scan_state_resume(local, &next_delay);
798 }
while (next_delay == 0);
805 __ieee80211_scan_completed(&local->
hw, aborted, hw_scan);
816 res = __ieee80211_start_scan(sdata, req);
841 if (!local->
hw.wiphy->bands[band])
844 i < local->
hw.wiphy->bands[band]->n_channels;
847 &local->
hw.wiphy->bands[band]->channels[
i];
863 ret = __ieee80211_start_scan(sdata, sdata->
local->int_scan_req);
897 if (local->
ops->cancel_hw_scan)
898 drv_cancel_hw_scan(local,
900 lockdep_is_held(&local->
mtx)));
911 __ieee80211_scan_completed(&local->
hw,
true,
false);
930 if (!local->
ops->sched_scan_start) {
936 if (!local->
hw.wiphy->bands[i])
943 if (!sched_scan_ies.
ie[i]) {
948 sched_scan_ies.
len[
i] =
954 ret = drv_sched_scan_start(local, sdata, req, &sched_scan_ies);
973 if (!local->
ops->sched_scan_stop) {
979 drv_sched_scan_stop(local, sdata);
991 trace_api_sched_scan_results(local);
1021 trace_api_sched_scan_stopped(local);