Lines Matching +full:hw +full:- +full:channels

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-2024 Intel Corporation
25 #include "driver-ops.h"
37 cfg80211_put_bss(local->hw.wiphy, in ieee80211_rx_bss_put()
45 if (elems->wmm_info && elems->wmm_info_len == 7 in is_uapsd_supported()
46 && elems->wmm_info[5] == 1) in is_uapsd_supported()
47 qos_info = elems->wmm_info[6]; in is_uapsd_supported()
48 else if (elems->wmm_param && elems->wmm_param_len == 24 in is_uapsd_supported()
49 && elems->wmm_param[5] == 1) in is_uapsd_supported()
50 qos_info = elems->wmm_param[6]; in is_uapsd_supported()
70 struct ieee80211_bss *bss = (void *)cbss->priv; in ieee80211_inform_bss()
79 elems = ieee802_11_parse_elems(ies->data, ies->len, false, NULL); in ieee80211_inform_bss()
83 rx_status = update_data->rx_status; in ieee80211_inform_bss()
85 if (update_data->beacon) in ieee80211_inform_bss()
86 bss->device_ts_beacon = rx_status->device_timestamp; in ieee80211_inform_bss()
88 bss->device_ts_presp = rx_status->device_timestamp; in ieee80211_inform_bss()
90 if (elems->parse_error) { in ieee80211_inform_bss()
91 if (update_data->beacon) in ieee80211_inform_bss()
92 bss->corrupt_data |= IEEE80211_BSS_CORRUPT_BEACON; in ieee80211_inform_bss()
94 bss->corrupt_data |= IEEE80211_BSS_CORRUPT_PROBE_RESP; in ieee80211_inform_bss()
96 if (update_data->beacon) in ieee80211_inform_bss()
97 bss->corrupt_data &= ~IEEE80211_BSS_CORRUPT_BEACON; in ieee80211_inform_bss()
99 bss->corrupt_data &= ~IEEE80211_BSS_CORRUPT_PROBE_RESP; in ieee80211_inform_bss()
103 if (elems->erp_info && (!elems->parse_error || in ieee80211_inform_bss()
104 !(bss->valid_data & IEEE80211_BSS_VALID_ERP))) { in ieee80211_inform_bss()
105 bss->erp_value = elems->erp_info[0]; in ieee80211_inform_bss()
106 bss->has_erp_value = true; in ieee80211_inform_bss()
107 if (!elems->parse_error) in ieee80211_inform_bss()
108 bss->valid_data |= IEEE80211_BSS_VALID_ERP; in ieee80211_inform_bss()
112 if (!elems->parse_error || in ieee80211_inform_bss()
113 !(bss->valid_data & IEEE80211_BSS_VALID_RATES)) { in ieee80211_inform_bss()
115 if (elems->supp_rates) { in ieee80211_inform_bss()
117 if (clen > elems->supp_rates_len) in ieee80211_inform_bss()
118 clen = elems->supp_rates_len; in ieee80211_inform_bss()
119 memcpy(bss->supp_rates, elems->supp_rates, clen); in ieee80211_inform_bss()
122 if (elems->ext_supp_rates) { in ieee80211_inform_bss()
123 clen = IEEE80211_MAX_SUPP_RATES - srlen; in ieee80211_inform_bss()
124 if (clen > elems->ext_supp_rates_len) in ieee80211_inform_bss()
125 clen = elems->ext_supp_rates_len; in ieee80211_inform_bss()
126 memcpy(bss->supp_rates + srlen, elems->ext_supp_rates, in ieee80211_inform_bss()
131 bss->supp_rates_len = srlen; in ieee80211_inform_bss()
132 if (!elems->parse_error) in ieee80211_inform_bss()
133 bss->valid_data |= IEEE80211_BSS_VALID_RATES; in ieee80211_inform_bss()
137 if (!elems->parse_error || in ieee80211_inform_bss()
138 !(bss->valid_data & IEEE80211_BSS_VALID_WMM)) { in ieee80211_inform_bss()
139 bss->wmm_used = elems->wmm_param || elems->wmm_info; in ieee80211_inform_bss()
140 bss->uapsd_supported = is_uapsd_supported(elems); in ieee80211_inform_bss()
141 if (!elems->parse_error) in ieee80211_inform_bss()
142 bss->valid_data |= IEEE80211_BSS_VALID_WMM; in ieee80211_inform_bss()
145 if (update_data->beacon) { in ieee80211_inform_bss()
147 local->hw.wiphy->bands[rx_status->band]; in ieee80211_inform_bss()
148 if (!(rx_status->encoding == RX_ENC_HT) && in ieee80211_inform_bss()
149 !(rx_status->encoding == RX_ENC_VHT)) in ieee80211_inform_bss()
150 bss->beacon_rate = in ieee80211_inform_bss()
151 &sband->bitrates[rx_status->rate_idx]; in ieee80211_inform_bss()
154 if (elems->vht_cap_elem) in ieee80211_inform_bss()
155 bss->vht_cap_info = in ieee80211_inform_bss()
156 le32_to_cpu(elems->vht_cap_elem->vht_cap_info); in ieee80211_inform_bss()
158 bss->vht_cap_info = 0; in ieee80211_inform_bss()
169 bool beacon = ieee80211_is_beacon(mgmt->frame_control) || in ieee80211_bss_info_update()
170 ieee80211_is_s1g_beacon(mgmt->frame_control); in ieee80211_bss_info_update()
177 .boottime_ns = rx_status->boottime_ns, in ieee80211_bss_info_update()
183 if (rx_status->flag & RX_FLAG_NO_SIGNAL_VAL) in ieee80211_bss_info_update()
185 else if (ieee80211_hw_check(&local->hw, SIGNAL_DBM)) in ieee80211_bss_info_update()
186 bss_meta.signal = rx_status->signal * 100; in ieee80211_bss_info_update()
187 else if (ieee80211_hw_check(&local->hw, SIGNAL_UNSPEC)) in ieee80211_bss_info_update()
188 bss_meta.signal = (rx_status->signal * 100) / local->hw.max_signal; in ieee80211_bss_info_update()
193 scan_sdata = rcu_dereference(local->scan_sdata); in ieee80211_bss_info_update()
194 if (scan_sdata && scan_sdata->vif.type == NL80211_IFTYPE_STATION && in ieee80211_bss_info_update()
195 scan_sdata->vif.cfg.assoc && in ieee80211_bss_info_update()
202 if (ieee80211_vif_is_mld(&scan_sdata->vif)) { in ieee80211_bss_info_update()
203 if (rx_status->link_valid) { in ieee80211_bss_info_update()
204 s8 link_id = rx_status->link_id; in ieee80211_bss_info_update()
207 rcu_dereference(scan_sdata->vif.link_conf[link_id]); in ieee80211_bss_info_update()
210 link_conf = &scan_sdata->vif.bss_conf; in ieee80211_bss_info_update()
221 link_conf->bssid); in ieee80211_bss_info_update()
226 cbss = cfg80211_inform_bss_frame_data(local->hw.wiphy, &bss_meta, in ieee80211_bss_info_update()
232 signal_valid = channel == cbss->channel; in ieee80211_bss_info_update()
234 rx_status->flag |= RX_FLAG_NO_SIGNAL_VAL; in ieee80211_bss_info_update()
236 return (void *)cbss->priv; in ieee80211_bss_info_update()
248 (channel->band == NL80211_BAND_6GHZ || in ieee80211_scan_accept_presp()
254 return ether_addr_equal(da, sdata->vif.addr); in ieee80211_scan_accept_presp()
260 struct ieee80211_mgmt *mgmt = (void *)skb->data; in ieee80211_scan_rx()
266 if (!ieee80211_is_probe_resp(mgmt->frame_control) && in ieee80211_scan_rx()
267 !ieee80211_is_beacon(mgmt->frame_control) && in ieee80211_scan_rx()
268 !ieee80211_is_s1g_beacon(mgmt->frame_control)) in ieee80211_scan_rx()
271 if (ieee80211_is_s1g_beacon(mgmt->frame_control)) { in ieee80211_scan_rx()
272 if (ieee80211_is_s1g_short_beacon(mgmt->frame_control)) in ieee80211_scan_rx()
280 if (skb->len < min_hdr_len) in ieee80211_scan_rx()
283 if (test_and_clear_bit(SCAN_BEACON_WAIT, &local->scanning)) { in ieee80211_scan_rx()
285 * we were passive scanning because of radar/no-IR, but in ieee80211_scan_rx()
289 set_bit(SCAN_BEACON_DONE, &local->scanning); in ieee80211_scan_rx()
290 wiphy_delayed_work_queue(local->hw.wiphy, &local->scan_work, 0); in ieee80211_scan_rx()
293 channel = ieee80211_get_channel_khz(local->hw.wiphy, in ieee80211_scan_rx()
296 if (!channel || channel->flags & IEEE80211_CHAN_DISABLED) in ieee80211_scan_rx()
299 if (ieee80211_is_probe_resp(mgmt->frame_control)) { in ieee80211_scan_rx()
305 sdata1 = rcu_dereference(local->scan_sdata); in ieee80211_scan_rx()
306 sdata2 = rcu_dereference(local->sched_scan_sdata); in ieee80211_scan_rx()
311 scan_req = rcu_dereference(local->scan_req); in ieee80211_scan_rx()
312 sched_scan_req = rcu_dereference(local->sched_scan_req); in ieee80211_scan_rx()
315 scan_req_flags = scan_req->flags; in ieee80211_scan_rx()
318 sched_scan_req_flags = sched_scan_req->flags; in ieee80211_scan_rx()
320 /* ignore ProbeResp to foreign address or non-bcast (OCE) in ieee80211_scan_rx()
325 mgmt->da) && in ieee80211_scan_rx()
328 mgmt->da)) in ieee80211_scan_rx()
332 if (!is_broadcast_ether_addr(mgmt->da)) in ieee80211_scan_rx()
337 if (local->open_count == local->monitors) in ieee80211_scan_rx()
341 mgmt, skb->len, in ieee80211_scan_rx()
351 chandef->width = NL80211_CHAN_WIDTH_20_NOHT; in ieee80211_prepare_scan_chandef()
357 struct ieee80211_local *local = sdata->local; in ieee80211_prep_hw_scan()
365 req = rcu_dereference_protected(local->scan_req, in ieee80211_prep_hw_scan()
366 lockdep_is_held(&local->hw.wiphy->mtx)); in ieee80211_prep_hw_scan()
368 if (test_bit(SCAN_HW_CANCELLED, &local->scanning)) in ieee80211_prep_hw_scan()
371 if (ieee80211_hw_check(&local->hw, SINGLE_SCAN_ON_ALL_BANDS)) { in ieee80211_prep_hw_scan()
372 local->hw_scan_req->req.n_channels = req->n_channels; in ieee80211_prep_hw_scan()
374 for (i = 0; i < req->n_channels; i++) { in ieee80211_prep_hw_scan()
375 local->hw_scan_req->req.channels[i] = req->channels[i]; in ieee80211_prep_hw_scan()
376 bands_used |= BIT(req->channels[i]->band); in ieee80211_prep_hw_scan()
380 if (local->hw_scan_band == NUM_NL80211_BANDS) in ieee80211_prep_hw_scan()
383 n_chans = &local->hw_scan_req->req.n_channels; in ieee80211_prep_hw_scan()
386 for (i = 0; i < req->n_channels; i++) { in ieee80211_prep_hw_scan()
387 if (req->channels[i]->band != in ieee80211_prep_hw_scan()
388 local->hw_scan_band) in ieee80211_prep_hw_scan()
390 local->hw_scan_req->req.channels[(*n_chans)++] = in ieee80211_prep_hw_scan()
391 req->channels[i]; in ieee80211_prep_hw_scan()
393 bands_used |= BIT(req->channels[i]->band); in ieee80211_prep_hw_scan()
396 local->hw_scan_band++; in ieee80211_prep_hw_scan()
402 if (req->flags & NL80211_SCAN_FLAG_MIN_PREQ_CONTENT) in ieee80211_prep_hw_scan()
406 (u8 *)local->hw_scan_req->req.ie, in ieee80211_prep_hw_scan()
407 local->hw_scan_ies_bufsize, in ieee80211_prep_hw_scan()
408 &local->hw_scan_req->ies, in ieee80211_prep_hw_scan()
409 req->ie, req->ie_len, in ieee80211_prep_hw_scan()
410 bands_used, req->rates, &chandef, in ieee80211_prep_hw_scan()
414 local->hw_scan_req->req.ie_len = ielen; in ieee80211_prep_hw_scan()
415 local->hw_scan_req->req.no_cck = req->no_cck; in ieee80211_prep_hw_scan()
416 ether_addr_copy(local->hw_scan_req->req.mac_addr, req->mac_addr); in ieee80211_prep_hw_scan()
417 ether_addr_copy(local->hw_scan_req->req.mac_addr_mask, in ieee80211_prep_hw_scan()
418 req->mac_addr_mask); in ieee80211_prep_hw_scan()
419 ether_addr_copy(local->hw_scan_req->req.bssid, req->bssid); in ieee80211_prep_hw_scan()
424 static void __ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted) in __ieee80211_scan_completed() argument
426 struct ieee80211_local *local = hw_to_local(hw); in __ieee80211_scan_completed()
427 bool hw_scan = test_bit(SCAN_HW_SCANNING, &local->scanning); in __ieee80211_scan_completed()
428 bool was_scanning = local->scanning; in __ieee80211_scan_completed()
433 lockdep_assert_wiphy(local->hw.wiphy); in __ieee80211_scan_completed()
436 * It's ok to abort a not-yet-running scan (that in __ieee80211_scan_completed()
438 * local->scan_req next), but not to complete it in __ieee80211_scan_completed()
441 if (WARN_ON(!local->scanning && !aborted)) in __ieee80211_scan_completed()
444 if (WARN_ON(!local->scan_req)) in __ieee80211_scan_completed()
447 scan_sdata = rcu_dereference_protected(local->scan_sdata, in __ieee80211_scan_completed()
448 lockdep_is_held(&local->hw.wiphy->mtx)); in __ieee80211_scan_completed()
451 !ieee80211_hw_check(&local->hw, SINGLE_SCAN_ON_ALL_BANDS) && in __ieee80211_scan_completed()
456 rcu_dereference_protected(local->scan_sdata, in __ieee80211_scan_completed()
457 lockdep_is_held(&local->hw.wiphy->mtx)), in __ieee80211_scan_completed()
458 local->hw_scan_req); in __ieee80211_scan_completed()
463 /* HW scan failed and is going to be reported as aborted, in __ieee80211_scan_completed()
466 memset(&local->scan_info, 0, sizeof(local->scan_info)); in __ieee80211_scan_completed()
470 kfree(local->hw_scan_req); in __ieee80211_scan_completed()
471 local->hw_scan_req = NULL; in __ieee80211_scan_completed()
473 scan_req = rcu_dereference_protected(local->scan_req, in __ieee80211_scan_completed()
474 lockdep_is_held(&local->hw.wiphy->mtx)); in __ieee80211_scan_completed()
476 RCU_INIT_POINTER(local->scan_req, NULL); in __ieee80211_scan_completed()
477 RCU_INIT_POINTER(local->scan_sdata, NULL); in __ieee80211_scan_completed()
479 local->scanning = 0; in __ieee80211_scan_completed()
480 local->scan_chandef.chan = NULL; in __ieee80211_scan_completed()
484 if (scan_req != local->int_scan_req) { in __ieee80211_scan_completed()
485 local->scan_info.aborted = aborted; in __ieee80211_scan_completed()
486 cfg80211_scan_done(scan_req, &local->scan_info); in __ieee80211_scan_completed()
505 * just be a no-op for the particular interface. in __ieee80211_scan_completed()
507 list_for_each_entry(sdata, &local->interfaces, list) { in __ieee80211_scan_completed()
509 wiphy_work_queue(sdata->local->hw.wiphy, &sdata->work); in __ieee80211_scan_completed()
516 void ieee80211_scan_completed(struct ieee80211_hw *hw, in ieee80211_scan_completed() argument
519 struct ieee80211_local *local = hw_to_local(hw); in ieee80211_scan_completed()
521 trace_api_scan_completed(local, info->aborted); in ieee80211_scan_completed()
523 set_bit(SCAN_COMPLETED, &local->scanning); in ieee80211_scan_completed()
524 if (info->aborted) in ieee80211_scan_completed()
525 set_bit(SCAN_ABORTED, &local->scanning); in ieee80211_scan_completed()
527 memcpy(&local->scan_info, info, sizeof(*info)); in ieee80211_scan_completed()
529 wiphy_delayed_work_queue(local->hw.wiphy, &local->scan_work, 0); in ieee80211_scan_completed()
536 /* Software scan is not supported in multi-channel cases */ in ieee80211_start_sw_scan()
537 if (!local->emulate_chanctx) in ieee80211_start_sw_scan()
538 return -EOPNOTSUPP; in ieee80211_start_sw_scan()
545 * the responses. After all channels are scanned, tune back to the in ieee80211_start_sw_scan()
549 * Note that while local->sw_scanning is true everything else but in ieee80211_start_sw_scan()
553 drv_sw_scan_start(local, sdata, local->scan_addr); in ieee80211_start_sw_scan()
555 local->leave_oper_channel_time = jiffies; in ieee80211_start_sw_scan()
556 local->next_scan_state = SCAN_DECISION; in ieee80211_start_sw_scan()
557 local->scan_channel_idx = 0; in ieee80211_start_sw_scan()
569 wiphy_delayed_work_queue(local->hw.wiphy, &local->scan_work, 0); in ieee80211_start_sw_scan()
576 struct ieee80211_local *local = sdata->local; in __ieee80211_can_leave_ch()
580 lockdep_assert_wiphy(local->hw.wiphy); in __ieee80211_can_leave_ch()
585 if (!regulatory_pre_cac_allowed(local->hw.wiphy)) in __ieee80211_can_leave_ch()
588 list_for_each_entry(sdata_iter, &local->interfaces, list) { in __ieee80211_can_leave_ch()
589 for_each_valid_link(&sdata_iter->wdev, link_id) in __ieee80211_can_leave_ch()
590 if (sdata_iter->wdev.links[link_id].cac_started) in __ieee80211_can_leave_ch()
603 if (!list_empty(&local->roc_list)) in ieee80211_can_scan()
606 if (sdata->vif.type == NL80211_IFTYPE_STATION && in ieee80211_can_scan()
607 sdata->u.mgd.flags & IEEE80211_STA_CONNECTION_POLL) in ieee80211_can_scan()
615 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_run_deferred_scan()
617 if (!local->scan_req || local->scanning) in ieee80211_run_deferred_scan()
622 local->scan_sdata, in ieee80211_run_deferred_scan()
623 lockdep_is_held(&local->hw.wiphy->mtx)))) in ieee80211_run_deferred_scan()
626 wiphy_delayed_work_queue(local->hw.wiphy, &local->scan_work, in ieee80211_run_deferred_scan()
645 struct ieee80211_hdr *hdr = (void *)skb->data; in ieee80211_send_scan_probe_req()
649 info->control.flags |= IEEE80211_TX_CTRL_NO_SEQNO; in ieee80211_send_scan_probe_req()
650 hdr->seq_ctrl = in ieee80211_send_scan_probe_req()
653 IEEE80211_SKB_CB(skb)->flags |= tx_flags; in ieee80211_send_scan_probe_req()
654 IEEE80211_SKB_CB(skb)->control.flags |= IEEE80211_TX_CTRL_DONT_USE_RATE_MASK; in ieee80211_send_scan_probe_req()
655 ieee80211_tx_skb_tid_band(sdata, skb, 7, channel->band); in ieee80211_send_scan_probe_req()
665 enum nl80211_band band = local->hw.conf.chandef.chan->band; in ieee80211_scan_state_send_probe()
668 scan_req = rcu_dereference_protected(local->scan_req, in ieee80211_scan_state_send_probe()
669 lockdep_is_held(&local->hw.wiphy->mtx)); in ieee80211_scan_state_send_probe()
672 if (scan_req->no_cck) in ieee80211_scan_state_send_probe()
674 if (scan_req->flags & NL80211_SCAN_FLAG_MIN_PREQ_CONTENT) in ieee80211_scan_state_send_probe()
676 if (scan_req->flags & NL80211_SCAN_FLAG_RANDOM_SN) in ieee80211_scan_state_send_probe()
679 sdata = rcu_dereference_protected(local->scan_sdata, in ieee80211_scan_state_send_probe()
680 lockdep_is_held(&local->hw.wiphy->mtx)); in ieee80211_scan_state_send_probe()
682 for (i = 0; i < scan_req->n_ssids; i++) in ieee80211_scan_state_send_probe()
684 sdata, local->scan_addr, scan_req->bssid, in ieee80211_scan_state_send_probe()
685 scan_req->ssids[i].ssid, scan_req->ssids[i].ssid_len, in ieee80211_scan_state_send_probe()
686 scan_req->ie, scan_req->ie_len, in ieee80211_scan_state_send_probe()
687 scan_req->rates[band], flags, in ieee80211_scan_state_send_probe()
688 tx_flags, local->hw.conf.chandef.chan); in ieee80211_scan_state_send_probe()
694 *next_delay = msecs_to_jiffies(scan_req->duration) > in ieee80211_scan_state_send_probe()
696 msecs_to_jiffies(scan_req->duration) - IEEE80211_PROBE_DELAY : in ieee80211_scan_state_send_probe()
698 local->next_scan_state = SCAN_DECISION; in ieee80211_scan_state_send_probe()
704 struct ieee80211_local *local = sdata->local; in __ieee80211_start_scan()
705 bool hw_scan = local->ops->hw_scan; in __ieee80211_start_scan()
708 lockdep_assert_wiphy(local->hw.wiphy); in __ieee80211_start_scan()
710 if (local->scan_req) in __ieee80211_start_scan()
711 return -EBUSY; in __ieee80211_start_scan()
716 if (ieee80211_vif_is_mld(&sdata->vif) && req->tsf_report_link_id >= 0 && in __ieee80211_start_scan()
717 !(sdata->vif.active_links & BIT(req->tsf_report_link_id))) in __ieee80211_start_scan()
718 return -EINVAL; in __ieee80211_start_scan()
721 return -EBUSY; in __ieee80211_start_scan()
725 rcu_assign_pointer(local->scan_req, req); in __ieee80211_start_scan()
726 rcu_assign_pointer(local->scan_sdata, sdata); in __ieee80211_start_scan()
734 local->hw_scan_ies_bufsize = local->scan_ies_len + req->ie_len; in __ieee80211_start_scan()
736 if (ieee80211_hw_check(&local->hw, SINGLE_SCAN_ON_ALL_BANDS)) { in __ieee80211_start_scan()
740 for (i = 0; i < req->n_channels; i++) { in __ieee80211_start_scan()
741 if (bands_counted & BIT(req->channels[i]->band)) in __ieee80211_start_scan()
743 bands_counted |= BIT(req->channels[i]->band); in __ieee80211_start_scan()
747 local->hw_scan_ies_bufsize *= n_bands; in __ieee80211_start_scan()
750 local->hw_scan_req = kmalloc(struct_size(local->hw_scan_req, in __ieee80211_start_scan()
751 req.channels, in __ieee80211_start_scan()
752 req->n_channels) + in __ieee80211_start_scan()
753 local->hw_scan_ies_bufsize, in __ieee80211_start_scan()
755 if (!local->hw_scan_req) in __ieee80211_start_scan()
756 return -ENOMEM; in __ieee80211_start_scan()
758 local->hw_scan_req->req.ssids = req->ssids; in __ieee80211_start_scan()
759 local->hw_scan_req->req.n_ssids = req->n_ssids; in __ieee80211_start_scan()
760 /* None of the channels are actually set in __ieee80211_start_scan()
763 local->hw_scan_req->req.n_channels = req->n_channels; in __ieee80211_start_scan()
765 ies = (u8 *)local->hw_scan_req + in __ieee80211_start_scan()
766 sizeof(*local->hw_scan_req) + in __ieee80211_start_scan()
767 req->n_channels * sizeof(req->channels[0]); in __ieee80211_start_scan()
768 local->hw_scan_req->req.ie = ies; in __ieee80211_start_scan()
769 local->hw_scan_req->req.flags = req->flags; in __ieee80211_start_scan()
770 eth_broadcast_addr(local->hw_scan_req->req.bssid); in __ieee80211_start_scan()
771 local->hw_scan_req->req.duration = req->duration; in __ieee80211_start_scan()
772 local->hw_scan_req->req.duration_mandatory = in __ieee80211_start_scan()
773 req->duration_mandatory; in __ieee80211_start_scan()
774 local->hw_scan_req->req.tsf_report_link_id = in __ieee80211_start_scan()
775 req->tsf_report_link_id; in __ieee80211_start_scan()
777 local->hw_scan_band = 0; in __ieee80211_start_scan()
778 local->hw_scan_req->req.n_6ghz_params = req->n_6ghz_params; in __ieee80211_start_scan()
779 local->hw_scan_req->req.scan_6ghz_params = in __ieee80211_start_scan()
780 req->scan_6ghz_params; in __ieee80211_start_scan()
781 local->hw_scan_req->req.scan_6ghz = req->scan_6ghz; in __ieee80211_start_scan()
784 * After allocating local->hw_scan_req, we must in __ieee80211_start_scan()
792 rcu_assign_pointer(local->scan_req, req); in __ieee80211_start_scan()
793 rcu_assign_pointer(local->scan_sdata, sdata); in __ieee80211_start_scan()
795 if (req->flags & NL80211_SCAN_FLAG_RANDOM_ADDR) in __ieee80211_start_scan()
796 get_random_mask_addr(local->scan_addr, in __ieee80211_start_scan()
797 req->mac_addr, in __ieee80211_start_scan()
798 req->mac_addr_mask); in __ieee80211_start_scan()
800 memcpy(local->scan_addr, sdata->vif.addr, ETH_ALEN); in __ieee80211_start_scan()
803 __set_bit(SCAN_HW_SCANNING, &local->scanning); in __ieee80211_start_scan()
804 } else if ((req->n_channels == 1) && in __ieee80211_start_scan()
805 (req->channels[0] == local->hw.conf.chandef.chan)) { in __ieee80211_start_scan()
812 __set_bit(SCAN_ONCHANNEL_SCANNING, &local->scanning); in __ieee80211_start_scan()
818 drv_sw_scan_start(local, sdata, local->scan_addr); in __ieee80211_start_scan()
820 ieee80211_configure_filter(local); /* accept probe-responses */ in __ieee80211_start_scan()
825 if ((req->channels[0]->flags & (IEEE80211_CHAN_NO_IR | in __ieee80211_start_scan()
827 !req->n_ssids) { in __ieee80211_start_scan()
829 if (req->n_ssids) in __ieee80211_start_scan()
830 set_bit(SCAN_BEACON_WAIT, &local->scanning); in __ieee80211_start_scan()
837 wiphy_delayed_work_queue(local->hw.wiphy, &local->scan_work, in __ieee80211_start_scan()
842 __set_bit(SCAN_SW_SCANNING, &local->scanning); in __ieee80211_start_scan()
849 rc = drv_hw_scan(local, sdata, local->hw_scan_req); in __ieee80211_start_scan()
855 kfree(local->hw_scan_req); in __ieee80211_start_scan()
856 local->hw_scan_req = NULL; in __ieee80211_start_scan()
857 local->scanning = 0; in __ieee80211_start_scan()
861 local->scan_req = NULL; in __ieee80211_start_scan()
862 RCU_INIT_POINTER(local->scan_sdata, NULL); in __ieee80211_start_scan()
867 * we can't fall back to software for P2P-GO in __ieee80211_start_scan()
870 if (ieee80211_vif_type_p2p(&sdata->vif) == in __ieee80211_start_scan()
872 return -EOPNOTSUPP; in __ieee80211_start_scan()
887 if (chan->flags & (IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_RADAR)) in ieee80211_scan_get_channel_time()
903 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_scan_state_decision()
910 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_scan_state_decision()
914 if (sdata->vif.type == NL80211_IFTYPE_STATION) { in ieee80211_scan_state_decision()
915 if (sdata->u.mgd.associated) { in ieee80211_scan_state_decision()
918 if (!qdisc_all_tx_empty(sdata->dev)) { in ieee80211_scan_state_decision()
926 scan_req = rcu_dereference_protected(local->scan_req, in ieee80211_scan_state_decision()
927 lockdep_is_held(&local->hw.wiphy->mtx)); in ieee80211_scan_state_decision()
929 next_chan = scan_req->channels[local->scan_channel_idx]; in ieee80211_scan_state_decision()
936 * Keep good latency, do not stay off-channel more than 125 ms. in ieee80211_scan_state_decision()
941 local->leave_oper_channel_time + HZ / 8); in ieee80211_scan_state_decision()
944 if (scan_req->flags & NL80211_SCAN_FLAG_LOW_PRIORITY) in ieee80211_scan_state_decision()
954 local->next_scan_state = next_scan_state; in ieee80211_scan_state_decision()
966 scan_req = rcu_dereference_protected(local->scan_req, in ieee80211_scan_state_set_channel()
967 lockdep_is_held(&local->hw.wiphy->mtx)); in ieee80211_scan_state_set_channel()
970 chan = scan_req->channels[local->scan_channel_idx]; in ieee80211_scan_state_set_channel()
972 local->scan_chandef.chan = chan; in ieee80211_scan_state_set_channel()
973 local->scan_chandef.center_freq1 = chan->center_freq; in ieee80211_scan_state_set_channel()
974 local->scan_chandef.freq1_offset = chan->freq_offset; in ieee80211_scan_state_set_channel()
975 local->scan_chandef.center_freq2 = 0; in ieee80211_scan_state_set_channel()
980 if (chan->band == NL80211_BAND_S1GHZ) { in ieee80211_scan_state_set_channel()
981 local->scan_chandef.width = ieee80211_s1g_channel_width(chan); in ieee80211_scan_state_set_channel()
985 /* If scanning on oper channel, use whatever channel-type in ieee80211_scan_state_set_channel()
988 if (chan == local->hw.conf.chandef.chan) in ieee80211_scan_state_set_channel()
989 local->scan_chandef = local->hw.conf.chandef; in ieee80211_scan_state_set_channel()
991 local->scan_chandef.width = NL80211_CHAN_WIDTH_20_NOHT; in ieee80211_scan_state_set_channel()
998 local->scan_channel_idx++; in ieee80211_scan_state_set_channel()
1002 local->next_scan_state = SCAN_DECISION; in ieee80211_scan_state_set_channel()
1010 * received - and the received frame would update the NAV). in ieee80211_scan_state_set_channel()
1016 if ((chan->flags & (IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_RADAR)) || in ieee80211_scan_state_set_channel()
1017 !scan_req->n_ssids) { in ieee80211_scan_state_set_channel()
1018 *next_delay = max(msecs_to_jiffies(scan_req->duration), in ieee80211_scan_state_set_channel()
1020 local->next_scan_state = SCAN_DECISION; in ieee80211_scan_state_set_channel()
1021 if (scan_req->n_ssids) in ieee80211_scan_state_set_channel()
1022 set_bit(SCAN_BEACON_WAIT, &local->scanning); in ieee80211_scan_state_set_channel()
1028 local->next_scan_state = SCAN_SEND_PROBE; in ieee80211_scan_state_set_channel()
1035 local->scan_chandef.chan = NULL; in ieee80211_scan_state_suspend()
1043 local->next_scan_state = SCAN_RESUME; in ieee80211_scan_state_suspend()
1051 if (local->ops->flush) { in ieee80211_scan_state_resume()
1058 local->leave_oper_channel_time = jiffies; in ieee80211_scan_state_resume()
1061 local->next_scan_state = SCAN_SET_CHANNEL; in ieee80211_scan_state_resume()
1073 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_scan_work()
1080 sdata = rcu_dereference_protected(local->scan_sdata, in ieee80211_scan_work()
1081 lockdep_is_held(&local->hw.wiphy->mtx)); in ieee80211_scan_work()
1082 scan_req = rcu_dereference_protected(local->scan_req, in ieee80211_scan_work()
1083 lockdep_is_held(&local->hw.wiphy->mtx)); in ieee80211_scan_work()
1085 /* When scanning on-channel, the first-callback means completed. */ in ieee80211_scan_work()
1086 if (test_bit(SCAN_ONCHANNEL_SCANNING, &local->scanning)) { in ieee80211_scan_work()
1087 aborted = test_and_clear_bit(SCAN_ABORTED, &local->scanning); in ieee80211_scan_work()
1091 if (test_and_clear_bit(SCAN_COMPLETED, &local->scanning)) { in ieee80211_scan_work()
1092 aborted = test_and_clear_bit(SCAN_ABORTED, &local->scanning); in ieee80211_scan_work()
1099 if (!local->scanning) { in ieee80211_scan_work()
1102 RCU_INIT_POINTER(local->scan_req, NULL); in ieee80211_scan_work()
1103 RCU_INIT_POINTER(local->scan_sdata, NULL); in ieee80211_scan_work()
1109 rcu_assign_pointer(local->scan_req, scan_req); in ieee80211_scan_work()
1114 clear_bit(SCAN_BEACON_WAIT, &local->scanning); in ieee80211_scan_work()
1126 if (test_and_clear_bit(SCAN_BEACON_DONE, &local->scanning) && in ieee80211_scan_work()
1127 local->next_scan_state == SCAN_DECISION) in ieee80211_scan_work()
1128 local->next_scan_state = SCAN_SEND_PROBE; in ieee80211_scan_work()
1130 switch (local->next_scan_state) { in ieee80211_scan_work()
1132 /* if no more bands/channels left, complete scan */ in ieee80211_scan_work()
1133 if (local->scan_channel_idx >= scan_req->n_channels) { in ieee80211_scan_work()
1157 wiphy_delayed_work_queue(local->hw.wiphy, &local->scan_work, in ieee80211_scan_work()
1162 __ieee80211_scan_completed(&local->hw, aborted); in ieee80211_scan_work()
1168 lockdep_assert_wiphy(sdata->local->hw.wiphy); in ieee80211_request_scan()
1175 struct ieee80211_channel **channels, in ieee80211_request_ibss_scan() argument
1178 struct ieee80211_local *local = sdata->local; in ieee80211_request_ibss_scan()
1179 int ret = -EBUSY, i, n_ch = 0; in ieee80211_request_ibss_scan()
1182 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_request_ibss_scan()
1185 if (local->scan_req) in ieee80211_request_ibss_scan()
1189 if (!channels) { in ieee80211_request_ibss_scan()
1193 if (!local->hw.wiphy->bands[band] || in ieee80211_request_ibss_scan()
1197 max_n = local->hw.wiphy->bands[band]->n_channels; in ieee80211_request_ibss_scan()
1200 &local->hw.wiphy->bands[band]->channels[i]; in ieee80211_request_ibss_scan()
1202 if (tmp_ch->flags & (IEEE80211_CHAN_NO_IR | in ieee80211_request_ibss_scan()
1206 local->int_scan_req->channels[n_ch] = tmp_ch; in ieee80211_request_ibss_scan()
1214 local->int_scan_req->n_channels = n_ch; in ieee80211_request_ibss_scan()
1217 if (channels[i]->flags & (IEEE80211_CHAN_NO_IR | in ieee80211_request_ibss_scan()
1221 local->int_scan_req->channels[n_ch] = channels[i]; in ieee80211_request_ibss_scan()
1228 local->int_scan_req->n_channels = n_ch; in ieee80211_request_ibss_scan()
1231 local->int_scan_req->ssids = &local->scan_ssid; in ieee80211_request_ibss_scan()
1232 local->int_scan_req->n_ssids = 1; in ieee80211_request_ibss_scan()
1233 memcpy(local->int_scan_req->ssids[0].ssid, ssid, IEEE80211_MAX_SSID_LEN); in ieee80211_request_ibss_scan()
1234 local->int_scan_req->ssids[0].ssid_len = ssid_len; in ieee80211_request_ibss_scan()
1236 ret = __ieee80211_start_scan(sdata, sdata->local->int_scan_req); in ieee80211_request_ibss_scan()
1244 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_scan_cancel()
1251 * - we can not call __ieee80211_scan_completed() as when in ieee80211_scan_cancel()
1253 * local->hw_scan_req to operate on 5G band, what race with in ieee80211_scan_cancel()
1254 * driver which can use local->hw_scan_req in ieee80211_scan_cancel()
1256 * - we can not cancel scan_work since driver can schedule it in ieee80211_scan_cancel()
1259 * Hence we only call the cancel_hw_scan() callback, but the low-level in ieee80211_scan_cancel()
1264 if (!local->scan_req) in ieee80211_scan_cancel()
1269 * but the worker hasn't run yet or is stuck on the mutex - mark it as in ieee80211_scan_cancel()
1272 if (test_bit(SCAN_HW_SCANNING, &local->scanning) && in ieee80211_scan_cancel()
1273 test_bit(SCAN_COMPLETED, &local->scanning)) { in ieee80211_scan_cancel()
1274 set_bit(SCAN_HW_CANCELLED, &local->scanning); in ieee80211_scan_cancel()
1278 if (test_bit(SCAN_HW_SCANNING, &local->scanning)) { in ieee80211_scan_cancel()
1283 set_bit(SCAN_HW_CANCELLED, &local->scanning); in ieee80211_scan_cancel()
1284 if (local->ops->cancel_hw_scan) in ieee80211_scan_cancel()
1286 rcu_dereference_protected(local->scan_sdata, in ieee80211_scan_cancel()
1287 lockdep_is_held(&local->hw.wiphy->mtx))); in ieee80211_scan_cancel()
1291 wiphy_delayed_work_cancel(local->hw.wiphy, &local->scan_work); in ieee80211_scan_cancel()
1293 memset(&local->scan_info, 0, sizeof(local->scan_info)); in ieee80211_scan_cancel()
1294 __ieee80211_scan_completed(&local->hw, true); in ieee80211_scan_cancel()
1300 struct ieee80211_local *local = sdata->local; in __ieee80211_request_sched_scan_start()
1309 lockdep_assert_wiphy(local->hw.wiphy); in __ieee80211_request_sched_scan_start()
1311 iebufsz = local->scan_ies_len + req->ie_len; in __ieee80211_request_sched_scan_start()
1313 if (!local->ops->sched_scan_start) in __ieee80211_request_sched_scan_start()
1314 return -EOPNOTSUPP; in __ieee80211_request_sched_scan_start()
1317 if (local->hw.wiphy->bands[i]) { in __ieee80211_request_sched_scan_start()
1319 rate_masks[i] = (u32) -1; in __ieee80211_request_sched_scan_start()
1324 if (req->flags & NL80211_SCAN_FLAG_MIN_PREQ_CONTENT) in __ieee80211_request_sched_scan_start()
1329 ret = -ENOMEM; in __ieee80211_request_sched_scan_start()
1336 &sched_scan_ies, req->ie, in __ieee80211_request_sched_scan_start()
1337 req->ie_len, bands_used, rate_masks, in __ieee80211_request_sched_scan_start()
1344 rcu_assign_pointer(local->sched_scan_sdata, sdata); in __ieee80211_request_sched_scan_start()
1345 rcu_assign_pointer(local->sched_scan_req, req); in __ieee80211_request_sched_scan_start()
1352 /* Clean in case of failure after HW restart or upon resume. */ in __ieee80211_request_sched_scan_start()
1353 RCU_INIT_POINTER(local->sched_scan_sdata, NULL); in __ieee80211_request_sched_scan_start()
1354 RCU_INIT_POINTER(local->sched_scan_req, NULL); in __ieee80211_request_sched_scan_start()
1363 struct ieee80211_local *local = sdata->local; in ieee80211_request_sched_scan_start()
1365 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_request_sched_scan_start()
1367 if (rcu_access_pointer(local->sched_scan_sdata)) in ieee80211_request_sched_scan_start()
1368 return -EBUSY; in ieee80211_request_sched_scan_start()
1376 int ret = -ENOENT; in ieee80211_request_sched_scan_stop()
1378 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_request_sched_scan_stop()
1380 if (!local->ops->sched_scan_stop) in ieee80211_request_sched_scan_stop()
1381 return -EOPNOTSUPP; in ieee80211_request_sched_scan_stop()
1384 RCU_INIT_POINTER(local->sched_scan_req, NULL); in ieee80211_request_sched_scan_stop()
1386 sched_scan_sdata = rcu_dereference_protected(local->sched_scan_sdata, in ieee80211_request_sched_scan_stop()
1387 lockdep_is_held(&local->hw.wiphy->mtx)); in ieee80211_request_sched_scan_stop()
1391 RCU_INIT_POINTER(local->sched_scan_sdata, NULL); in ieee80211_request_sched_scan_stop()
1397 void ieee80211_sched_scan_results(struct ieee80211_hw *hw) in ieee80211_sched_scan_results() argument
1399 struct ieee80211_local *local = hw_to_local(hw); in ieee80211_sched_scan_results()
1403 cfg80211_sched_scan_results(hw->wiphy, 0); in ieee80211_sched_scan_results()
1409 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_sched_scan_end()
1411 if (!rcu_access_pointer(local->sched_scan_sdata)) in ieee80211_sched_scan_end()
1414 RCU_INIT_POINTER(local->sched_scan_sdata, NULL); in ieee80211_sched_scan_end()
1417 RCU_INIT_POINTER(local->sched_scan_req, NULL); in ieee80211_sched_scan_end()
1419 cfg80211_sched_scan_stopped_locked(local->hw.wiphy, 0); in ieee80211_sched_scan_end()
1432 void ieee80211_sched_scan_stopped(struct ieee80211_hw *hw) in ieee80211_sched_scan_stopped() argument
1434 struct ieee80211_local *local = hw_to_local(hw); in ieee80211_sched_scan_stopped()
1443 if (local->in_reconfig) in ieee80211_sched_scan_stopped()
1446 wiphy_work_queue(hw->wiphy, &local->sched_scan_stopped_work); in ieee80211_sched_scan_stopped()