Lines Matching refs:local

32 void ieee80211_rx_bss_put(struct ieee80211_local *local,
37 cfg80211_put_bss(local->hw.wiphy,
68 struct ieee80211_local *local = wiphy_priv(wiphy);
147 local->hw.wiphy->bands[rx_status->band];
164 ieee80211_bss_info_update(struct ieee80211_local *local,
185 else if (ieee80211_hw_check(&local->hw, SIGNAL_DBM))
187 else if (ieee80211_hw_check(&local->hw, SIGNAL_UNSPEC))
188 bss_meta.signal = (rx_status->signal * 100) / local->hw.max_signal;
199 scan_sdata = rcu_dereference(local->scan_sdata);
204 ieee80211_calculate_rx_timestamp(local, rx_status,
211 cbss = cfg80211_inform_bss_frame_data(local->hw.wiphy, &bss_meta,
242 void ieee80211_scan_rx(struct ieee80211_local *local, struct sk_buff *skb)
269 sdata1 = rcu_dereference(local->scan_sdata);
270 sdata2 = rcu_dereference(local->sched_scan_sdata);
275 if (test_and_clear_bit(SCAN_BEACON_WAIT, &local->scanning)) {
281 set_bit(SCAN_BEACON_DONE, &local->scanning);
282 wiphy_delayed_work_queue(local->hw.wiphy, &local->scan_work, 0);
285 channel = ieee80211_get_channel_khz(local->hw.wiphy,
296 scan_req = rcu_dereference(local->scan_req);
297 sched_scan_req = rcu_dereference(local->sched_scan_req);
317 bss = ieee80211_bss_info_update(local, rx_status,
321 ieee80211_rx_bss_put(local, bss);
345 struct ieee80211_local *local = sdata->local;
352 req = rcu_dereference_protected(local->scan_req,
353 lockdep_is_held(&local->mtx));
355 if (test_bit(SCAN_HW_CANCELLED, &local->scanning))
358 if (ieee80211_hw_check(&local->hw, SINGLE_SCAN_ON_ALL_BANDS)) {
360 local->hw_scan_req->req.channels[i] = req->channels[i];
367 if (local->hw_scan_band == NUM_NL80211_BANDS)
374 local->hw_scan_band)
376 local->hw_scan_req->req.channels[n_chans] =
382 local->hw_scan_band++;
386 local->hw_scan_req->req.n_channels = n_chans;
393 (u8 *)local->hw_scan_req->req.ie,
394 local->hw_scan_ies_bufsize,
395 &local->hw_scan_req->ies,
399 local->hw_scan_req->req.ie_len = ielen;
400 local->hw_scan_req->req.no_cck = req->no_cck;
401 ether_addr_copy(local->hw_scan_req->req.mac_addr, req->mac_addr);
402 ether_addr_copy(local->hw_scan_req->req.mac_addr_mask,
404 ether_addr_copy(local->hw_scan_req->req.bssid, req->bssid);
411 struct ieee80211_local *local = hw_to_local(hw);
412 bool hw_scan = test_bit(SCAN_HW_SCANNING, &local->scanning);
413 bool was_scanning = local->scanning;
418 lockdep_assert_held(&local->mtx);
423 * local->scan_req next), but not to complete it
426 if (WARN_ON(!local->scanning && !aborted))
429 if (WARN_ON(!local->scan_req))
432 scan_sdata = rcu_dereference_protected(local->scan_sdata,
433 lockdep_is_held(&local->mtx));
436 !ieee80211_hw_check(&local->hw, SINGLE_SCAN_ON_ALL_BANDS) &&
440 rc = drv_hw_scan(local,
441 rcu_dereference_protected(local->scan_sdata,
442 lockdep_is_held(&local->mtx)),
443 local->hw_scan_req);
451 memset(&local->scan_info, 0, sizeof(local->scan_info));
455 kfree(local->hw_scan_req);
456 local->hw_scan_req = NULL;
458 scan_req = rcu_dereference_protected(local->scan_req,
459 lockdep_is_held(&local->mtx));
461 RCU_INIT_POINTER(local->scan_req, NULL);
462 RCU_INIT_POINTER(local->scan_sdata, NULL);
464 local->scanning = 0;
465 local->scan_chandef.chan = NULL;
469 if (scan_req != local->int_scan_req) {
470 local->scan_info.aborted = aborted;
471 cfg80211_scan_done(scan_req, &local->scan_info);
475 ieee80211_hw_config(local, 0);
478 ieee80211_configure_filter(local);
479 drv_sw_scan_complete(local, scan_sdata);
480 ieee80211_offchannel_return(local);
483 ieee80211_recalc_idle(local);
485 ieee80211_mlme_notify_scan_completed(local);
486 ieee80211_ibss_notify_scan_completed(local);
492 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
494 wiphy_work_queue(sdata->local->hw.wiphy, &sdata->work);
498 ieee80211_start_next_roc(local);
504 struct ieee80211_local *local = hw_to_local(hw);
506 trace_api_scan_completed(local, info->aborted);
508 set_bit(SCAN_COMPLETED, &local->scanning);
510 set_bit(SCAN_ABORTED, &local->scanning);
512 memcpy(&local->scan_info, info, sizeof(*info));
514 wiphy_delayed_work_queue(local->hw.wiphy, &local->scan_work, 0);
518 static int ieee80211_start_sw_scan(struct ieee80211_local *local,
522 if (local->use_chanctx)
534 * Note that while local->sw_scanning is true everything else but
538 drv_sw_scan_start(local, sdata, local->scan_addr);
540 local->leave_oper_channel_time = jiffies;
541 local->next_scan_state = SCAN_DECISION;
542 local->scan_channel_idx = 0;
544 ieee80211_offchannel_stop_vifs(local);
547 ieee80211_flush_queues(local, NULL, false);
549 ieee80211_configure_filter(local);
552 ieee80211_hw_config(local, 0);
554 wiphy_delayed_work_queue(local->hw.wiphy, &local->scan_work, 0);
561 struct ieee80211_local *local = sdata->local;
564 if (!ieee80211_is_radar_required(local))
567 if (!regulatory_pre_cac_allowed(local->hw.wiphy))
570 mutex_lock(&local->iflist_mtx);
571 list_for_each_entry(sdata_iter, &local->interfaces, list) {
573 mutex_unlock(&local->iflist_mtx);
577 mutex_unlock(&local->iflist_mtx);
582 static bool ieee80211_can_scan(struct ieee80211_local *local,
588 if (!list_empty(&local->roc_list))
598 void ieee80211_run_deferred_scan(struct ieee80211_local *local)
600 lockdep_assert_held(&local->mtx);
602 if (!local->scan_req || local->scanning)
605 if (!ieee80211_can_scan(local,
607 local->scan_sdata,
608 lockdep_is_held(&local->mtx))))
611 wiphy_delayed_work_queue(local->hw.wiphy, &local->scan_work,
643 static void ieee80211_scan_state_send_probe(struct ieee80211_local *local,
649 enum nl80211_band band = local->hw.conf.chandef.chan->band;
652 scan_req = rcu_dereference_protected(local->scan_req,
653 lockdep_is_held(&local->mtx));
663 sdata = rcu_dereference_protected(local->scan_sdata,
664 lockdep_is_held(&local->mtx));
668 sdata, local->scan_addr, scan_req->bssid,
672 tx_flags, local->hw.conf.chandef.chan);
679 local->next_scan_state = SCAN_DECISION;
685 struct ieee80211_local *local = sdata->local;
686 bool hw_scan = local->ops->hw_scan;
689 lockdep_assert_held(&local->mtx);
691 if (local->scan_req)
697 if (!ieee80211_can_scan(local, sdata)) {
699 rcu_assign_pointer(local->scan_req, req);
700 rcu_assign_pointer(local->scan_sdata, sdata);
708 local->hw_scan_ies_bufsize = local->scan_ies_len + req->ie_len;
710 if (ieee80211_hw_check(&local->hw, SINGLE_SCAN_ON_ALL_BANDS)) {
721 local->hw_scan_ies_bufsize *= n_bands;
724 local->hw_scan_req = kmalloc(
725 sizeof(*local->hw_scan_req) +
727 local->hw_scan_ies_bufsize, GFP_KERNEL);
728 if (!local->hw_scan_req)
731 local->hw_scan_req->req.ssids = req->ssids;
732 local->hw_scan_req->req.n_ssids = req->n_ssids;
733 ies = (u8 *)local->hw_scan_req +
734 sizeof(*local->hw_scan_req) +
736 local->hw_scan_req->req.ie = ies;
737 local->hw_scan_req->req.flags = req->flags;
738 eth_broadcast_addr(local->hw_scan_req->req.bssid);
739 local->hw_scan_req->req.duration = req->duration;
740 local->hw_scan_req->req.duration_mandatory =
743 local->hw_scan_band = 0;
744 local->hw_scan_req->req.n_6ghz_params = req->n_6ghz_params;
745 local->hw_scan_req->req.scan_6ghz_params =
747 local->hw_scan_req->req.scan_6ghz = req->scan_6ghz;
750 * After allocating local->hw_scan_req, we must
758 rcu_assign_pointer(local->scan_req, req);
759 rcu_assign_pointer(local->scan_sdata, sdata);
762 get_random_mask_addr(local->scan_addr,
766 memcpy(local->scan_addr, sdata->vif.addr, ETH_ALEN);
769 __set_bit(SCAN_HW_SCANNING, &local->scanning);
771 (req->channels[0] == local->_oper_chandef.chan)) {
778 __set_bit(SCAN_ONCHANNEL_SCANNING, &local->scanning);
780 ieee80211_recalc_idle(local);
784 drv_sw_scan_start(local, sdata, local->scan_addr);
786 ieee80211_configure_filter(local); /* accept probe-responses */
789 ieee80211_hw_config(local, 0);
796 set_bit(SCAN_BEACON_WAIT, &local->scanning);
798 ieee80211_scan_state_send_probe(local, &next_delay);
803 wiphy_delayed_work_queue(local->hw.wiphy, &local->scan_work,
808 __set_bit(SCAN_SW_SCANNING, &local->scanning);
811 ieee80211_recalc_idle(local);
815 rc = drv_hw_scan(local, sdata, local->hw_scan_req);
817 rc = ieee80211_start_sw_scan(local, sdata);
821 kfree(local->hw_scan_req);
822 local->hw_scan_req = NULL;
823 local->scanning = 0;
825 ieee80211_recalc_idle(local);
827 local->scan_req = NULL;
828 RCU_INIT_POINTER(local->scan_sdata, NULL);
858 static void ieee80211_scan_state_decision(struct ieee80211_local *local,
874 mutex_lock(&local->iflist_mtx);
875 list_for_each_entry(sdata, &local->interfaces, list) {
890 mutex_unlock(&local->iflist_mtx);
892 scan_req = rcu_dereference_protected(local->scan_req,
893 lockdep_is_held(&local->mtx));
895 next_chan = scan_req->channels[local->scan_channel_idx];
907 local->leave_oper_channel_time + HZ / 8);
920 local->next_scan_state = next_scan_state;
925 static void ieee80211_scan_state_set_channel(struct ieee80211_local *local,
933 scan_req = rcu_dereference_protected(local->scan_req,
934 lockdep_is_held(&local->mtx));
937 chan = scan_req->channels[local->scan_channel_idx];
939 local->scan_chandef.chan = chan;
940 local->scan_chandef.center_freq1 = chan->center_freq;
941 local->scan_chandef.freq1_offset = chan->freq_offset;
942 local->scan_chandef.center_freq2 = 0;
950 local->scan_chandef.width = ieee80211_s1g_channel_width(chan);
956 local->scan_chandef.width = NL80211_CHAN_WIDTH_5;
959 local->scan_chandef.width = NL80211_CHAN_WIDTH_10;
967 &local->_oper_chandef);
968 if (chan == local->_oper_chandef.chan &&
970 local->scan_chandef = local->_oper_chandef;
972 local->scan_chandef.width = NL80211_CHAN_WIDTH_20_NOHT;
982 if (ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL))
986 local->scan_channel_idx++;
990 local->next_scan_state = SCAN_DECISION;
1007 local->next_scan_state = SCAN_DECISION;
1009 set_bit(SCAN_BEACON_WAIT, &local->scanning);
1015 local->next_scan_state = SCAN_SEND_PROBE;
1018 static void ieee80211_scan_state_suspend(struct ieee80211_local *local,
1022 local->scan_chandef.chan = NULL;
1023 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
1026 ieee80211_offchannel_return(local);
1030 local->next_scan_state = SCAN_RESUME;
1033 static void ieee80211_scan_state_resume(struct ieee80211_local *local,
1036 ieee80211_offchannel_stop_vifs(local);
1038 if (local->ops->flush) {
1039 ieee80211_flush_queues(local, NULL, false);
1045 local->leave_oper_channel_time = jiffies;
1048 local->next_scan_state = SCAN_SET_CHANNEL;
1053 struct ieee80211_local *local =
1060 mutex_lock(&local->mtx);
1062 if (!ieee80211_can_run_worker(local)) {
1067 sdata = rcu_dereference_protected(local->scan_sdata,
1068 lockdep_is_held(&local->mtx));
1069 scan_req = rcu_dereference_protected(local->scan_req,
1070 lockdep_is_held(&local->mtx));
1073 if (test_bit(SCAN_ONCHANNEL_SCANNING, &local->scanning)) {
1074 aborted = test_and_clear_bit(SCAN_ABORTED, &local->scanning);
1078 if (test_and_clear_bit(SCAN_COMPLETED, &local->scanning)) {
1079 aborted = test_and_clear_bit(SCAN_ABORTED, &local->scanning);
1086 if (!local->scanning) {
1089 RCU_INIT_POINTER(local->scan_req, NULL);
1090 RCU_INIT_POINTER(local->scan_sdata, NULL);
1095 rcu_assign_pointer(local->scan_req, scan_req);
1102 clear_bit(SCAN_BEACON_WAIT, &local->scanning);
1114 if (test_and_clear_bit(SCAN_BEACON_DONE, &local->scanning) &&
1115 local->next_scan_state == SCAN_DECISION)
1116 local->next_scan_state = SCAN_SEND_PROBE;
1118 switch (local->next_scan_state) {
1121 if (local->scan_channel_idx >= scan_req->n_channels) {
1125 ieee80211_scan_state_decision(local, &next_delay);
1128 ieee80211_scan_state_set_channel(local, &next_delay);
1131 ieee80211_scan_state_send_probe(local, &next_delay);
1134 ieee80211_scan_state_suspend(local, &next_delay);
1137 ieee80211_scan_state_resume(local, &next_delay);
1145 wiphy_delayed_work_queue(local->hw.wiphy, &local->scan_work,
1150 __ieee80211_scan_completed(&local->hw, aborted);
1152 mutex_unlock(&local->mtx);
1160 mutex_lock(&sdata->local->mtx);
1162 mutex_unlock(&sdata->local->mtx);
1173 struct ieee80211_local *local = sdata->local;
1177 mutex_lock(&local->mtx);
1180 if (local->scan_req)
1188 if (!local->hw.wiphy->bands[band] ||
1192 max_n = local->hw.wiphy->bands[band]->n_channels;
1195 &local->hw.wiphy->bands[band]->channels[i];
1201 local->int_scan_req->channels[n_ch] = tmp_ch;
1209 local->int_scan_req->n_channels = n_ch;
1216 local->int_scan_req->channels[n_ch] = channels[i];
1223 local->int_scan_req->n_channels = n_ch;
1226 local->int_scan_req->ssids = &local->scan_ssid;
1227 local->int_scan_req->n_ssids = 1;
1228 local->int_scan_req->scan_width = scan_width;
1229 memcpy(local->int_scan_req->ssids[0].ssid, ssid, IEEE80211_MAX_SSID_LEN);
1230 local->int_scan_req->ssids[0].ssid_len = ssid_len;
1232 ret = __ieee80211_start_scan(sdata, sdata->local->int_scan_req);
1234 mutex_unlock(&local->mtx);
1238 void ieee80211_scan_cancel(struct ieee80211_local *local)
1241 lockdep_assert_wiphy(local->hw.wiphy);
1250 * local->hw_scan_req to operate on 5G band, what race with
1251 * driver which can use local->hw_scan_req
1261 mutex_lock(&local->mtx);
1262 if (!local->scan_req)
1270 if (test_bit(SCAN_HW_SCANNING, &local->scanning) &&
1271 test_bit(SCAN_COMPLETED, &local->scanning)) {
1272 set_bit(SCAN_HW_CANCELLED, &local->scanning);
1276 if (test_bit(SCAN_HW_SCANNING, &local->scanning)) {
1281 set_bit(SCAN_HW_CANCELLED, &local->scanning);
1282 if (local->ops->cancel_hw_scan)
1283 drv_cancel_hw_scan(local,
1284 rcu_dereference_protected(local->scan_sdata,
1285 lockdep_is_held(&local->mtx)));
1289 wiphy_delayed_work_cancel(local->hw.wiphy, &local->scan_work);
1291 memset(&local->scan_info, 0, sizeof(local->scan_info));
1292 __ieee80211_scan_completed(&local->hw, true);
1294 mutex_unlock(&local->mtx);
1300 struct ieee80211_local *local = sdata->local;
1309 iebufsz = local->scan_ies_len + req->ie_len;
1311 lockdep_assert_held(&local->mtx);
1313 if (!local->ops->sched_scan_start)
1317 if (local->hw.wiphy->bands[i]) {
1340 ret = drv_sched_scan_start(local, sdata, req, &sched_scan_ies);
1342 rcu_assign_pointer(local->sched_scan_sdata, sdata);
1343 rcu_assign_pointer(local->sched_scan_req, req);
1351 RCU_INIT_POINTER(local->sched_scan_sdata, NULL);
1352 RCU_INIT_POINTER(local->sched_scan_req, NULL);
1361 struct ieee80211_local *local = sdata->local;
1364 mutex_lock(&local->mtx);
1366 if (rcu_access_pointer(local->sched_scan_sdata)) {
1367 mutex_unlock(&local->mtx);
1373 mutex_unlock(&local->mtx);
1377 int ieee80211_request_sched_scan_stop(struct ieee80211_local *local)
1382 mutex_lock(&local->mtx);
1384 if (!local->ops->sched_scan_stop) {
1390 RCU_INIT_POINTER(local->sched_scan_req, NULL);
1392 sched_scan_sdata = rcu_dereference_protected(local->sched_scan_sdata,
1393 lockdep_is_held(&local->mtx));
1395 ret = drv_sched_scan_stop(local, sched_scan_sdata);
1397 RCU_INIT_POINTER(local->sched_scan_sdata, NULL);
1400 mutex_unlock(&local->mtx);
1407 struct ieee80211_local *local = hw_to_local(hw);
1409 trace_api_sched_scan_results(local);
1415 void ieee80211_sched_scan_end(struct ieee80211_local *local)
1417 mutex_lock(&local->mtx);
1419 if (!rcu_access_pointer(local->sched_scan_sdata)) {
1420 mutex_unlock(&local->mtx);
1424 RCU_INIT_POINTER(local->sched_scan_sdata, NULL);
1427 RCU_INIT_POINTER(local->sched_scan_req, NULL);
1429 mutex_unlock(&local->mtx);
1431 cfg80211_sched_scan_stopped_locked(local->hw.wiphy, 0);
1437 struct ieee80211_local *local =
1441 ieee80211_sched_scan_end(local);
1446 struct ieee80211_local *local = hw_to_local(hw);
1448 trace_api_sched_scan_stopped(local);
1455 if (local->in_reconfig)
1458 wiphy_work_queue(hw->wiphy, &local->sched_scan_stopped_work);