Lines Matching +full:scan +full:- +full:delay

1 // SPDX-License-Identifier: GPL-2.0-only
8 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
10 * Copyright 2013-2015 Intel Mobile Communications GmbH
11 * Copyright 2016-2017 Intel Deutschland GmbH
12 * Copyright (C) 2018-2025 Intel Corporation
25 #include "driver-ops.h"
37 cfg80211_put_bss(local->hw.wiphy,
45 if (elems->wmm_info && elems->wmm_info_len == 7
46 && elems->wmm_info[5] == 1)
47 qos_info = elems->wmm_info[6];
48 else if (elems->wmm_param && elems->wmm_param_len == 24
49 && elems->wmm_param[5] == 1)
50 qos_info = elems->wmm_param[6];
70 struct ieee80211_bss *bss = (void *)cbss->priv;
79 elems = ieee802_11_parse_elems(ies->data, ies->len, false, NULL);
83 rx_status = update_data->rx_status;
85 if (update_data->beacon)
86 bss->device_ts_beacon = rx_status->device_timestamp;
88 bss->device_ts_presp = rx_status->device_timestamp;
90 if (elems->parse_error) {
91 if (update_data->beacon)
92 bss->corrupt_data |= IEEE80211_BSS_CORRUPT_BEACON;
94 bss->corrupt_data |= IEEE80211_BSS_CORRUPT_PROBE_RESP;
96 if (update_data->beacon)
97 bss->corrupt_data &= ~IEEE80211_BSS_CORRUPT_BEACON;
99 bss->corrupt_data &= ~IEEE80211_BSS_CORRUPT_PROBE_RESP;
103 if (elems->erp_info && (!elems->parse_error ||
104 !(bss->valid_data & IEEE80211_BSS_VALID_ERP))) {
105 bss->erp_value = elems->erp_info[0];
106 bss->has_erp_value = true;
107 if (!elems->parse_error)
108 bss->valid_data |= IEEE80211_BSS_VALID_ERP;
112 if (!elems->parse_error ||
113 !(bss->valid_data & IEEE80211_BSS_VALID_RATES)) {
115 if (elems->supp_rates) {
117 if (clen > elems->supp_rates_len)
118 clen = elems->supp_rates_len;
119 memcpy(bss->supp_rates, elems->supp_rates, clen);
122 if (elems->ext_supp_rates) {
123 clen = IEEE80211_MAX_SUPP_RATES - srlen;
124 if (clen > elems->ext_supp_rates_len)
125 clen = elems->ext_supp_rates_len;
126 memcpy(bss->supp_rates + srlen, elems->ext_supp_rates,
131 bss->supp_rates_len = srlen;
132 if (!elems->parse_error)
133 bss->valid_data |= IEEE80211_BSS_VALID_RATES;
137 if (!elems->parse_error ||
138 !(bss->valid_data & IEEE80211_BSS_VALID_WMM)) {
139 bss->wmm_used = elems->wmm_param || elems->wmm_info;
140 bss->uapsd_supported = is_uapsd_supported(elems);
141 if (!elems->parse_error)
142 bss->valid_data |= IEEE80211_BSS_VALID_WMM;
145 if (update_data->beacon) {
147 local->hw.wiphy->bands[rx_status->band];
148 if (!(rx_status->encoding == RX_ENC_HT) &&
149 !(rx_status->encoding == RX_ENC_VHT))
150 bss->beacon_rate =
151 &sband->bitrates[rx_status->rate_idx];
154 if (elems->vht_cap_elem)
155 bss->vht_cap_info =
156 le32_to_cpu(elems->vht_cap_elem->vht_cap_info);
158 bss->vht_cap_info = 0;
169 bool beacon = ieee80211_is_beacon(mgmt->frame_control) ||
170 ieee80211_is_s1g_beacon(mgmt->frame_control);
177 .boottime_ns = rx_status->boottime_ns,
183 if (rx_status->flag & RX_FLAG_NO_SIGNAL_VAL)
185 else if (ieee80211_hw_check(&local->hw, SIGNAL_DBM))
186 bss_meta.signal = rx_status->signal * 100;
187 else if (ieee80211_hw_check(&local->hw, SIGNAL_UNSPEC))
188 bss_meta.signal = (rx_status->signal * 100) / local->hw.max_signal;
193 scan_sdata = rcu_dereference(local->scan_sdata);
194 if (scan_sdata && scan_sdata->vif.type == NL80211_IFTYPE_STATION &&
195 scan_sdata->vif.cfg.assoc &&
202 if (ieee80211_vif_is_mld(&scan_sdata->vif)) {
203 if (rx_status->link_valid) {
204 s8 link_id = rx_status->link_id;
207 rcu_dereference(scan_sdata->vif.link_conf[link_id]);
210 link_conf = &scan_sdata->vif.bss_conf;
221 link_conf->bssid);
226 cbss = cfg80211_inform_bss_frame_data(local->hw.wiphy, &bss_meta,
232 signal_valid = channel == cbss->channel;
234 rx_status->flag |= RX_FLAG_NO_SIGNAL_VAL;
236 return (void *)cbss->priv;
251 (channel->band == NL80211_BAND_6GHZ ||
258 if (ether_addr_equal(da, sdata->vif.addr))
262 link_sdata = rcu_dereference(sdata->link[link_id]);
266 if (ether_addr_equal(da, link_sdata->conf->addr))
276 struct ieee80211_mgmt *mgmt = (void *)skb->data;
283 if (!ieee80211_is_probe_resp(mgmt->frame_control) &&
284 !ieee80211_is_beacon(mgmt->frame_control) &&
285 !ieee80211_is_s1g_beacon(mgmt->frame_control))
288 if (ieee80211_is_s1g_beacon(mgmt->frame_control)) {
292 ieee80211_s1g_optional_len(ext->frame_control);
295 if (skb->len < min_hdr_len)
298 if (test_and_clear_bit(SCAN_BEACON_WAIT, &local->scanning)) {
300 * we were passive scanning because of radar/no-IR, but
302 * to active scan
304 set_bit(SCAN_BEACON_DONE, &local->scanning);
305 wiphy_delayed_work_queue(local->hw.wiphy, &local->scan_work, 0);
308 channel = ieee80211_get_channel_khz(local->hw.wiphy,
311 if (!channel || channel->flags & IEEE80211_CHAN_DISABLED)
314 if (ieee80211_is_probe_resp(mgmt->frame_control)) {
320 sdata1 = rcu_dereference(local->scan_sdata);
321 sdata2 = rcu_dereference(local->sched_scan_sdata);
326 scan_req = rcu_dereference(local->scan_req);
327 sched_scan_req = rcu_dereference(local->sched_scan_req);
330 scan_req_flags = scan_req->flags;
333 sched_scan_req_flags = sched_scan_req->flags;
335 /* ignore ProbeResp to foreign address or non-bcast (OCE)
340 mgmt->da) &&
343 mgmt->da))
347 if (!is_broadcast_ether_addr(mgmt->da))
352 if (local->open_count == local->monitors)
356 mgmt, skb->len,
366 chandef->width = NL80211_CHAN_WIDTH_20_NOHT;
372 struct ieee80211_local *local = sdata->local;
380 req = rcu_dereference_protected(local->scan_req,
381 lockdep_is_held(&local->hw.wiphy->mtx));
383 if (test_bit(SCAN_HW_CANCELLED, &local->scanning))
386 if (ieee80211_hw_check(&local->hw, SINGLE_SCAN_ON_ALL_BANDS)) {
387 local->hw_scan_req->req.n_channels = req->n_channels;
389 for (i = 0; i < req->n_channels; i++) {
390 local->hw_scan_req->req.channels[i] = req->channels[i];
391 bands_used |= BIT(req->channels[i]->band);
395 if (local->hw_scan_band == NUM_NL80211_BANDS)
398 n_chans = &local->hw_scan_req->req.n_channels;
401 for (i = 0; i < req->n_channels; i++) {
402 if (req->channels[i]->band !=
403 local->hw_scan_band)
405 local->hw_scan_req->req.channels[(*n_chans)++] =
406 req->channels[i];
408 bands_used |= BIT(req->channels[i]->band);
411 local->hw_scan_band++;
417 if (req->flags & NL80211_SCAN_FLAG_MIN_PREQ_CONTENT)
421 (u8 *)local->hw_scan_req->req.ie,
422 local->hw_scan_ies_bufsize,
423 &local->hw_scan_req->ies,
424 req->ie, req->ie_len,
425 bands_used, req->rates, &chandef,
429 local->hw_scan_req->req.ie_len = ielen;
430 local->hw_scan_req->req.no_cck = req->no_cck;
431 ether_addr_copy(local->hw_scan_req->req.mac_addr, req->mac_addr);
432 ether_addr_copy(local->hw_scan_req->req.mac_addr_mask,
433 req->mac_addr_mask);
434 ether_addr_copy(local->hw_scan_req->req.bssid, req->bssid);
442 bool hw_scan = test_bit(SCAN_HW_SCANNING, &local->scanning);
443 bool was_scanning = local->scanning;
448 lockdep_assert_wiphy(local->hw.wiphy);
451 * It's ok to abort a not-yet-running scan (that
453 * local->scan_req next), but not to complete it
456 if (WARN_ON(!local->scanning && !aborted))
459 if (WARN_ON(!local->scan_req))
462 scan_sdata = rcu_dereference_protected(local->scan_sdata,
463 lockdep_is_held(&local->hw.wiphy->mtx));
466 !ieee80211_hw_check(&local->hw, SINGLE_SCAN_ON_ALL_BANDS) &&
471 rcu_dereference_protected(local->scan_sdata,
472 lockdep_is_held(&local->hw.wiphy->mtx)),
473 local->hw_scan_req);
478 /* HW scan failed and is going to be reported as aborted,
479 * so clear old scan info.
481 memset(&local->scan_info, 0, sizeof(local->scan_info));
485 kfree(local->hw_scan_req);
486 local->hw_scan_req = NULL;
488 scan_req = rcu_dereference_protected(local->scan_req,
489 lockdep_is_held(&local->hw.wiphy->mtx));
491 RCU_INIT_POINTER(local->scan_req, NULL);
492 RCU_INIT_POINTER(local->scan_sdata, NULL);
494 local->scanning = 0;
495 local->scan_chandef.chan = NULL;
499 if (scan_req != local->int_scan_req) {
500 local->scan_info.aborted = aborted;
501 cfg80211_scan_done(scan_req, &local->scan_info);
519 * the scan was in progress; if there was none this will
520 * just be a no-op for the particular interface.
522 list_for_each_entry(sdata, &local->interfaces, list) {
524 wiphy_work_queue(sdata->local->hw.wiphy, &sdata->work);
536 trace_api_scan_completed(local, info->aborted);
538 set_bit(SCAN_COMPLETED, &local->scanning);
539 if (info->aborted)
540 set_bit(SCAN_ABORTED, &local->scanning);
542 memcpy(&local->scan_info, info, sizeof(*info));
544 wiphy_delayed_work_queue(local->hw.wiphy, &local->scan_work, 0);
551 /* Software scan is not supported in multi-channel cases */
552 if (!local->emulate_chanctx)
553 return -EOPNOTSUPP;
564 * Note that while local->sw_scanning is true everything else but
568 drv_sw_scan_start(local, sdata, local->scan_addr);
570 local->leave_oper_channel_time = jiffies;
571 local->next_scan_state = SCAN_DECISION;
572 local->scan_channel_idx = 0;
584 wiphy_delayed_work_queue(local->hw.wiphy, &local->scan_work, 0);
592 struct ieee80211_local *local = sdata->local;
596 lockdep_assert_wiphy(local->hw.wiphy);
601 if (!regulatory_pre_cac_allowed(local->hw.wiphy))
604 list_for_each_entry(sdata_iter, &local->interfaces, list) {
605 for_each_valid_link(&sdata_iter->wdev, link_id)
606 if (sdata_iter->wdev.links[link_id].cac_started)
620 if (!list_empty(&local->roc_list))
623 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
624 sdata->u.mgd.flags & IEEE80211_STA_CONNECTION_POLL)
634 lockdep_assert_wiphy(local->hw.wiphy);
636 if (!local->scan_req || local->scanning)
639 req = wiphy_dereference(local->hw.wiphy, local->scan_req);
642 local->scan_sdata,
643 lockdep_is_held(&local->hw.wiphy->mtx)),
647 wiphy_delayed_work_queue(local->hw.wiphy, &local->scan_work,
666 struct ieee80211_hdr *hdr = (void *)skb->data;
670 info->control.flags |= IEEE80211_TX_CTRL_NO_SEQNO;
671 hdr->seq_ctrl =
674 IEEE80211_SKB_CB(skb)->flags |= tx_flags;
675 IEEE80211_SKB_CB(skb)->control.flags |= IEEE80211_TX_CTRL_DONT_USE_RATE_MASK;
676 ieee80211_tx_skb_tid_band(sdata, skb, 7, channel->band);
686 enum nl80211_band band = local->hw.conf.chandef.chan->band;
689 scan_req = rcu_dereference_protected(local->scan_req,
690 lockdep_is_held(&local->hw.wiphy->mtx));
693 if (scan_req->no_cck)
695 if (scan_req->flags & NL80211_SCAN_FLAG_MIN_PREQ_CONTENT)
697 if (scan_req->flags & NL80211_SCAN_FLAG_RANDOM_SN)
700 sdata = rcu_dereference_protected(local->scan_sdata,
701 lockdep_is_held(&local->hw.wiphy->mtx));
703 for (i = 0; i < scan_req->n_ssids; i++)
705 sdata, local->scan_addr, scan_req->bssid,
706 scan_req->ssids[i].ssid, scan_req->ssids[i].ssid_len,
707 scan_req->ie, scan_req->ie_len,
708 scan_req->rates[band], flags,
709 tx_flags, local->hw.conf.chandef.chan);
715 *next_delay = msecs_to_jiffies(scan_req->duration) >
717 msecs_to_jiffies(scan_req->duration) - IEEE80211_PROBE_DELAY :
719 local->next_scan_state = SCAN_DECISION;
725 struct ieee80211_local *local = sdata->local;
726 bool hw_scan = local->ops->hw_scan;
729 lockdep_assert_wiphy(local->hw.wiphy);
731 if (local->scan_req)
732 return -EBUSY;
737 if (ieee80211_vif_is_mld(&sdata->vif) && req->tsf_report_link_id >= 0 &&
738 !(sdata->vif.active_links & BIT(req->tsf_report_link_id)))
739 return -EINVAL;
742 return -EBUSY;
746 rcu_assign_pointer(local->scan_req, req);
747 rcu_assign_pointer(local->scan_sdata, sdata);
755 local->hw_scan_ies_bufsize = local->scan_ies_len + req->ie_len;
757 if (ieee80211_hw_check(&local->hw, SINGLE_SCAN_ON_ALL_BANDS)) {
761 for (i = 0; i < req->n_channels; i++) {
762 if (bands_counted & BIT(req->channels[i]->band))
764 bands_counted |= BIT(req->channels[i]->band);
768 local->hw_scan_ies_bufsize *= n_bands;
771 local->hw_scan_req = kmalloc(struct_size(local->hw_scan_req,
773 req->n_channels) +
774 local->hw_scan_ies_bufsize,
776 if (!local->hw_scan_req)
777 return -ENOMEM;
779 local->hw_scan_req->req.ssids = req->ssids;
780 local->hw_scan_req->req.n_ssids = req->n_ssids;
784 local->hw_scan_req->req.n_channels = req->n_channels;
786 ies = (u8 *)local->hw_scan_req +
787 sizeof(*local->hw_scan_req) +
788 req->n_channels * sizeof(req->channels[0]);
789 local->hw_scan_req->req.ie = ies;
790 local->hw_scan_req->req.flags = req->flags;
791 eth_broadcast_addr(local->hw_scan_req->req.bssid);
792 local->hw_scan_req->req.duration = req->duration;
793 local->hw_scan_req->req.duration_mandatory =
794 req->duration_mandatory;
795 local->hw_scan_req->req.tsf_report_link_id =
796 req->tsf_report_link_id;
798 local->hw_scan_band = 0;
799 local->hw_scan_req->req.n_6ghz_params = req->n_6ghz_params;
800 local->hw_scan_req->req.scan_6ghz_params =
801 req->scan_6ghz_params;
802 local->hw_scan_req->req.scan_6ghz = req->scan_6ghz;
803 local->hw_scan_req->req.first_part = req->first_part;
806 * After allocating local->hw_scan_req, we must
814 rcu_assign_pointer(local->scan_req, req);
815 rcu_assign_pointer(local->scan_sdata, sdata);
817 if (req->flags & NL80211_SCAN_FLAG_RANDOM_ADDR)
818 get_random_mask_addr(local->scan_addr,
819 req->mac_addr,
820 req->mac_addr_mask);
822 memcpy(local->scan_addr, sdata->vif.addr, ETH_ALEN);
825 __set_bit(SCAN_HW_SCANNING, &local->scanning);
826 } else if ((req->n_channels == 1) &&
827 (req->channels[0] == local->hw.conf.chandef.chan)) {
834 __set_bit(SCAN_ONCHANNEL_SCANNING, &local->scanning);
838 /* Notify driver scan is starting, keep order of operations
839 * same as normal software scan, in case that matters. */
840 drv_sw_scan_start(local, sdata, local->scan_addr);
842 ieee80211_configure_filter(local); /* accept probe-responses */
847 if ((req->channels[0]->flags & (IEEE80211_CHAN_NO_IR |
849 !req->n_ssids) {
851 if (req->n_ssids)
852 set_bit(SCAN_BEACON_WAIT, &local->scanning);
859 wiphy_delayed_work_queue(local->hw.wiphy, &local->scan_work,
863 /* Do normal software scan */
864 __set_bit(SCAN_SW_SCANNING, &local->scanning);
871 rc = drv_hw_scan(local, sdata, local->hw_scan_req);
877 kfree(local->hw_scan_req);
878 local->hw_scan_req = NULL;
879 local->scanning = 0;
883 local->scan_req = NULL;
884 RCU_INIT_POINTER(local->scan_sdata, NULL);
889 * we can't fall back to software for P2P-GO
892 if (ieee80211_vif_type_p2p(&sdata->vif) ==
894 return -EOPNOTSUPP;
907 * add that delay as well to get a better estimation
909 if (chan->flags & (IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_RADAR))
925 lockdep_assert_wiphy(local->hw.wiphy);
932 list_for_each_entry(sdata, &local->interfaces, list) {
936 if (sdata->vif.type == NL80211_IFTYPE_STATION) {
937 if (sdata->u.mgd.associated) {
940 if (!qdisc_all_tx_empty(sdata->dev)) {
948 scan_req = rcu_dereference_protected(local->scan_req,
949 lockdep_is_held(&local->hw.wiphy->mtx));
951 next_chan = scan_req->channels[local->scan_channel_idx];
955 * see if we can scan another channel without interfering
958 * Keep good latency, do not stay off-channel more than 125 ms.
963 local->leave_oper_channel_time + HZ / 8);
966 if (scan_req->flags & NL80211_SCAN_FLAG_LOW_PRIORITY)
976 local->next_scan_state = next_scan_state;
988 scan_req = rcu_dereference_protected(local->scan_req,
989 lockdep_is_held(&local->hw.wiphy->mtx));
992 chan = scan_req->channels[local->scan_channel_idx];
994 local->scan_chandef.chan = chan;
995 local->scan_chandef.center_freq1 = chan->center_freq;
996 local->scan_chandef.freq1_offset = chan->freq_offset;
997 local->scan_chandef.center_freq2 = 0;
999 /* For S1G, only scan the 1MHz primaries. */
1000 if (chan->band == NL80211_BAND_S1GHZ) {
1001 local->scan_chandef.width = NL80211_CHAN_WIDTH_1;
1002 local->scan_chandef.s1g_primary_2mhz = false;
1007 * If scanning on oper channel, use whatever channel-type
1010 if (chan == local->hw.conf.chandef.chan)
1011 local->scan_chandef = local->hw.conf.chandef;
1013 local->scan_chandef.width = NL80211_CHAN_WIDTH_20_NOHT;
1020 local->scan_channel_idx++;
1024 local->next_scan_state = SCAN_DECISION;
1029 * Probe delay is used to update the NAV, cf. 11.1.3.2.2
1031 * but it waits for the probe delay or until a frame is
1032 * received - and the received frame would update the NAV).
1036 * In any case, it is not necessary for a passive scan.
1038 if ((chan->flags & (IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_RADAR)) ||
1039 !scan_req->n_ssids) {
1040 *next_delay = max(msecs_to_jiffies(scan_req->duration),
1042 local->next_scan_state = SCAN_DECISION;
1043 if (scan_req->n_ssids)
1044 set_bit(SCAN_BEACON_WAIT, &local->scanning);
1048 /* active scan, send probes */
1050 local->next_scan_state = SCAN_SEND_PROBE;
1057 local->scan_chandef.chan = NULL;
1064 /* afterwards, resume scan & go to next channel */
1065 local->next_scan_state = SCAN_RESUME;
1073 if (local->ops->flush) {
1080 local->leave_oper_channel_time = jiffies;
1083 local->next_scan_state = SCAN_SET_CHANNEL;
1095 lockdep_assert_wiphy(local->hw.wiphy);
1102 sdata = rcu_dereference_protected(local->scan_sdata,
1103 lockdep_is_held(&local->hw.wiphy->mtx));
1104 scan_req = rcu_dereference_protected(local->scan_req,
1105 lockdep_is_held(&local->hw.wiphy->mtx));
1107 /* When scanning on-channel, the first-callback means completed. */
1108 if (test_bit(SCAN_ONCHANNEL_SCANNING, &local->scanning)) {
1109 aborted = test_and_clear_bit(SCAN_ABORTED, &local->scanning);
1113 if (test_and_clear_bit(SCAN_COMPLETED, &local->scanning)) {
1114 aborted = test_and_clear_bit(SCAN_ABORTED, &local->scanning);
1121 if (!local->scanning) {
1124 RCU_INIT_POINTER(local->scan_req, NULL);
1125 RCU_INIT_POINTER(local->scan_sdata, NULL);
1130 /* need to complete scan in cfg80211 */
1131 rcu_assign_pointer(local->scan_req, scan_req);
1136 clear_bit(SCAN_BEACON_WAIT, &local->scanning);
1139 * as long as no delay is required advance immediately
1148 if (test_and_clear_bit(SCAN_BEACON_DONE, &local->scanning) &&
1149 local->next_scan_state == SCAN_DECISION)
1150 local->next_scan_state = SCAN_SEND_PROBE;
1152 switch (local->next_scan_state) {
1154 /* if no more bands/channels left, complete scan */
1155 if (local->scan_channel_idx >= scan_req->n_channels) {
1179 wiphy_delayed_work_queue(local->hw.wiphy, &local->scan_work,
1184 __ieee80211_scan_completed(&local->hw, aborted);
1190 lockdep_assert_wiphy(sdata->local->hw.wiphy);
1200 struct ieee80211_local *local = sdata->local;
1204 lockdep_assert_wiphy(local->hw.wiphy);
1207 if (local->scan_req)
1208 return -EBUSY;
1210 /* fill internal scan request */
1215 if (!local->hw.wiphy->bands[band] ||
1220 max_n = local->hw.wiphy->bands[band]->n_channels;
1223 &local->hw.wiphy->bands[band]->channels[i];
1225 if (tmp_ch->flags & (IEEE80211_CHAN_NO_IR |
1227 !cfg80211_wdev_channel_allowed(&sdata->wdev,
1231 local->int_scan_req->channels[n_ch] = tmp_ch;
1237 return -EINVAL;
1239 local->int_scan_req->n_channels = n_ch;
1242 if (channels[i]->flags & (IEEE80211_CHAN_NO_IR |
1244 !cfg80211_wdev_channel_allowed(&sdata->wdev,
1248 local->int_scan_req->channels[n_ch] = channels[i];
1253 return -EINVAL;
1255 local->int_scan_req->n_channels = n_ch;
1258 local->int_scan_req->ssids = &local->scan_ssid;
1259 local->int_scan_req->n_ssids = 1;
1260 memcpy(local->int_scan_req->ssids[0].ssid, ssid, IEEE80211_MAX_SSID_LEN);
1261 local->int_scan_req->ssids[0].ssid_len = ssid_len;
1263 return __ieee80211_start_scan(sdata, sdata->local->int_scan_req);
1268 /* ensure a new scan cannot be queued */
1269 lockdep_assert_wiphy(local->hw.wiphy);
1272 * We are canceling software scan, or deferred scan that was not
1275 * Regarding hardware scan:
1276 * - we can not call __ieee80211_scan_completed() as when
1278 * local->hw_scan_req to operate on 5G band, what race with
1279 * driver which can use local->hw_scan_req
1281 * - we can not cancel scan_work since driver can schedule it
1282 * by ieee80211_scan_completed(..., true) to finish scan
1284 * Hence we only call the cancel_hw_scan() callback, but the low-level
1286 * after the scan was completed/aborted.
1289 if (!local->scan_req)
1293 * We have a scan running and the driver already reported completion,
1294 * but the worker hasn't run yet or is stuck on the mutex - mark it as
1297 if (test_bit(SCAN_HW_SCANNING, &local->scanning) &&
1298 test_bit(SCAN_COMPLETED, &local->scanning)) {
1299 set_bit(SCAN_HW_CANCELLED, &local->scanning);
1303 if (test_bit(SCAN_HW_SCANNING, &local->scanning)) {
1306 * scan on another band.
1308 set_bit(SCAN_HW_CANCELLED, &local->scanning);
1309 if (local->ops->cancel_hw_scan)
1311 rcu_dereference_protected(local->scan_sdata,
1312 lockdep_is_held(&local->hw.wiphy->mtx)));
1316 wiphy_delayed_work_cancel(local->hw.wiphy, &local->scan_work);
1318 memset(&local->scan_info, 0, sizeof(local->scan_info));
1319 __ieee80211_scan_completed(&local->hw, true);
1325 struct ieee80211_local *local = sdata->local;
1334 lockdep_assert_wiphy(local->hw.wiphy);
1336 iebufsz = local->scan_ies_len + req->ie_len;
1338 if (!local->ops->sched_scan_start)
1339 return -EOPNOTSUPP;
1342 if (local->hw.wiphy->bands[i]) {
1344 rate_masks[i] = (u32) -1;
1349 if (req->flags & NL80211_SCAN_FLAG_MIN_PREQ_CONTENT)
1354 ret = -ENOMEM;
1361 &sched_scan_ies, req->ie,
1362 req->ie_len, bands_used, rate_masks,
1369 rcu_assign_pointer(local->sched_scan_sdata, sdata);
1370 rcu_assign_pointer(local->sched_scan_req, req);
1378 RCU_INIT_POINTER(local->sched_scan_sdata, NULL);
1379 RCU_INIT_POINTER(local->sched_scan_req, NULL);
1388 struct ieee80211_local *local = sdata->local;
1390 lockdep_assert_wiphy(local->hw.wiphy);
1392 if (rcu_access_pointer(local->sched_scan_sdata))
1393 return -EBUSY;
1401 int ret = -ENOENT;
1403 lockdep_assert_wiphy(local->hw.wiphy);
1405 if (!local->ops->sched_scan_stop)
1406 return -EOPNOTSUPP;
1408 /* We don't want to restart sched scan anymore. */
1409 RCU_INIT_POINTER(local->sched_scan_req, NULL);
1411 sched_scan_sdata = rcu_dereference_protected(local->sched_scan_sdata,
1412 lockdep_is_held(&local->hw.wiphy->mtx));
1416 RCU_INIT_POINTER(local->sched_scan_sdata, NULL);
1428 cfg80211_sched_scan_results(hw->wiphy, 0);
1434 lockdep_assert_wiphy(local->hw.wiphy);
1436 if (!rcu_access_pointer(local->sched_scan_sdata))
1439 RCU_INIT_POINTER(local->sched_scan_sdata, NULL);
1441 /* If sched scan was aborted by the driver. */
1442 RCU_INIT_POINTER(local->sched_scan_req, NULL);
1444 cfg80211_sched_scan_stopped_locked(local->hw.wiphy, 0);
1466 * the sched scan later on.
1468 if (local->in_reconfig)
1471 wiphy_work_queue(hw->wiphy, &local->sched_scan_stopped_work);