Lines Matching refs:local
32 void ieee80211_rx_bss_put(struct ieee80211_local *local,
37 cfg80211_put_bss(local->hw.wiphy,
59 ieee80211_update_bss_from_elems(struct ieee80211_local *local,
129 local->hw.wiphy->bands[rx_status->band];
144 ieee80211_bss_info_update(struct ieee80211_local *local,
164 else if (ieee80211_hw_check(&local->hw, SIGNAL_DBM))
166 else if (ieee80211_hw_check(&local->hw, SIGNAL_UNSPEC))
167 bss_meta.signal = (rx_status->signal * 100) / local->hw.max_signal;
178 scan_sdata = rcu_dereference(local->scan_sdata);
183 ieee80211_calculate_rx_timestamp(local, rx_status,
190 cbss = cfg80211_inform_bss_frame_data(local->hw.wiphy, &bss_meta,
221 ieee80211_update_bss_from_elems(local, bss, &elems, rx_status, beacon);
226 ieee80211_update_bss_from_elems(local, non_tx_bss, &elems,
249 void ieee80211_scan_rx(struct ieee80211_local *local, struct sk_buff *skb)
276 sdata1 = rcu_dereference(local->scan_sdata);
277 sdata2 = rcu_dereference(local->sched_scan_sdata);
282 if (test_and_clear_bit(SCAN_BEACON_WAIT, &local->scanning)) {
288 set_bit(SCAN_BEACON_DONE, &local->scanning);
289 ieee80211_queue_delayed_work(&local->hw, &local->scan_work, 0);
297 scan_req = rcu_dereference(local->scan_req);
298 sched_scan_req = rcu_dereference(local->sched_scan_req);
316 channel = ieee80211_get_channel_khz(local->hw.wiphy,
322 bss = ieee80211_bss_info_update(local, rx_status,
326 ieee80211_rx_bss_put(local, bss);
350 struct ieee80211_local *local = sdata->local;
357 req = rcu_dereference_protected(local->scan_req,
358 lockdep_is_held(&local->mtx));
360 if (test_bit(SCAN_HW_CANCELLED, &local->scanning))
363 if (ieee80211_hw_check(&local->hw, SINGLE_SCAN_ON_ALL_BANDS)) {
365 local->hw_scan_req->req.channels[i] = req->channels[i];
372 if (local->hw_scan_band == NUM_NL80211_BANDS)
379 local->hw_scan_band)
381 local->hw_scan_req->req.channels[n_chans] =
387 local->hw_scan_band++;
391 local->hw_scan_req->req.n_channels = n_chans;
398 (u8 *)local->hw_scan_req->req.ie,
399 local->hw_scan_ies_bufsize,
400 &local->hw_scan_req->ies,
404 local->hw_scan_req->req.ie_len = ielen;
405 local->hw_scan_req->req.no_cck = req->no_cck;
406 ether_addr_copy(local->hw_scan_req->req.mac_addr, req->mac_addr);
407 ether_addr_copy(local->hw_scan_req->req.mac_addr_mask,
409 ether_addr_copy(local->hw_scan_req->req.bssid, req->bssid);
416 struct ieee80211_local *local = hw_to_local(hw);
417 bool hw_scan = test_bit(SCAN_HW_SCANNING, &local->scanning);
418 bool was_scanning = local->scanning;
423 lockdep_assert_held(&local->mtx);
428 * local->scan_req next), but not to complete it
431 if (WARN_ON(!local->scanning && !aborted))
434 if (WARN_ON(!local->scan_req))
437 scan_sdata = rcu_dereference_protected(local->scan_sdata,
438 lockdep_is_held(&local->mtx));
441 !ieee80211_hw_check(&local->hw, SINGLE_SCAN_ON_ALL_BANDS) &&
445 rc = drv_hw_scan(local,
446 rcu_dereference_protected(local->scan_sdata,
447 lockdep_is_held(&local->mtx)),
448 local->hw_scan_req);
456 memset(&local->scan_info, 0, sizeof(local->scan_info));
460 kfree(local->hw_scan_req);
461 local->hw_scan_req = NULL;
463 scan_req = rcu_dereference_protected(local->scan_req,
464 lockdep_is_held(&local->mtx));
466 RCU_INIT_POINTER(local->scan_req, NULL);
467 RCU_INIT_POINTER(local->scan_sdata, NULL);
469 local->scanning = 0;
470 local->scan_chandef.chan = NULL;
474 if (scan_req != local->int_scan_req) {
475 local->scan_info.aborted = aborted;
476 cfg80211_scan_done(scan_req, &local->scan_info);
480 ieee80211_hw_config(local, 0);
483 ieee80211_configure_filter(local);
484 drv_sw_scan_complete(local, scan_sdata);
485 ieee80211_offchannel_return(local);
488 ieee80211_recalc_idle(local);
490 ieee80211_mlme_notify_scan_completed(local);
491 ieee80211_ibss_notify_scan_completed(local);
497 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
499 ieee80211_queue_work(&sdata->local->hw, &sdata->work);
503 ieee80211_start_next_roc(local);
509 struct ieee80211_local *local = hw_to_local(hw);
511 trace_api_scan_completed(local, info->aborted);
513 set_bit(SCAN_COMPLETED, &local->scanning);
515 set_bit(SCAN_ABORTED, &local->scanning);
517 memcpy(&local->scan_info, info, sizeof(*info));
519 ieee80211_queue_delayed_work(&local->hw, &local->scan_work, 0);
523 static int ieee80211_start_sw_scan(struct ieee80211_local *local,
527 if (local->use_chanctx)
539 * Note that while local->sw_scanning is true everything else but
543 drv_sw_scan_start(local, sdata, local->scan_addr);
545 local->leave_oper_channel_time = jiffies;
546 local->next_scan_state = SCAN_DECISION;
547 local->scan_channel_idx = 0;
549 ieee80211_offchannel_stop_vifs(local);
552 ieee80211_flush_queues(local, NULL, false);
554 ieee80211_configure_filter(local);
557 ieee80211_hw_config(local, 0);
559 ieee80211_queue_delayed_work(&local->hw,
560 &local->scan_work, 0);
567 struct ieee80211_local *local = sdata->local;
570 if (!ieee80211_is_radar_required(local))
573 if (!regulatory_pre_cac_allowed(local->hw.wiphy))
576 mutex_lock(&local->iflist_mtx);
577 list_for_each_entry(sdata_iter, &local->interfaces, list) {
579 mutex_unlock(&local->iflist_mtx);
583 mutex_unlock(&local->iflist_mtx);
588 static bool ieee80211_can_scan(struct ieee80211_local *local,
594 if (!list_empty(&local->roc_list))
604 void ieee80211_run_deferred_scan(struct ieee80211_local *local)
606 lockdep_assert_held(&local->mtx);
608 if (!local->scan_req || local->scanning)
611 if (!ieee80211_can_scan(local,
613 local->scan_sdata,
614 lockdep_is_held(&local->mtx))))
617 ieee80211_queue_delayed_work(&local->hw, &local->scan_work,
649 static void ieee80211_scan_state_send_probe(struct ieee80211_local *local,
655 enum nl80211_band band = local->hw.conf.chandef.chan->band;
658 scan_req = rcu_dereference_protected(local->scan_req,
659 lockdep_is_held(&local->mtx));
669 sdata = rcu_dereference_protected(local->scan_sdata,
670 lockdep_is_held(&local->mtx));
674 sdata, local->scan_addr, scan_req->bssid,
678 tx_flags, local->hw.conf.chandef.chan);
685 local->next_scan_state = SCAN_DECISION;
691 struct ieee80211_local *local = sdata->local;
692 bool hw_scan = local->ops->hw_scan;
695 lockdep_assert_held(&local->mtx);
697 if (local->scan_req)
703 if (!ieee80211_can_scan(local, sdata)) {
705 rcu_assign_pointer(local->scan_req, req);
706 rcu_assign_pointer(local->scan_sdata, sdata);
714 local->hw_scan_ies_bufsize = local->scan_ies_len + req->ie_len;
716 if (ieee80211_hw_check(&local->hw, SINGLE_SCAN_ON_ALL_BANDS)) {
727 local->hw_scan_ies_bufsize *= n_bands;
730 local->hw_scan_req = kmalloc(
731 sizeof(*local->hw_scan_req) +
733 local->hw_scan_ies_bufsize, GFP_KERNEL);
734 if (!local->hw_scan_req)
737 local->hw_scan_req->req.ssids = req->ssids;
738 local->hw_scan_req->req.n_ssids = req->n_ssids;
739 ies = (u8 *)local->hw_scan_req +
740 sizeof(*local->hw_scan_req) +
742 local->hw_scan_req->req.ie = ies;
743 local->hw_scan_req->req.flags = req->flags;
744 eth_broadcast_addr(local->hw_scan_req->req.bssid);
745 local->hw_scan_req->req.duration = req->duration;
746 local->hw_scan_req->req.duration_mandatory =
749 local->hw_scan_band = 0;
750 local->hw_scan_req->req.n_6ghz_params = req->n_6ghz_params;
751 local->hw_scan_req->req.scan_6ghz_params =
753 local->hw_scan_req->req.scan_6ghz = req->scan_6ghz;
756 * After allocating local->hw_scan_req, we must
764 rcu_assign_pointer(local->scan_req, req);
765 rcu_assign_pointer(local->scan_sdata, sdata);
768 get_random_mask_addr(local->scan_addr,
772 memcpy(local->scan_addr, sdata->vif.addr, ETH_ALEN);
775 __set_bit(SCAN_HW_SCANNING, &local->scanning);
777 (req->channels[0] == local->_oper_chandef.chan)) {
784 __set_bit(SCAN_ONCHANNEL_SCANNING, &local->scanning);
786 ieee80211_recalc_idle(local);
790 drv_sw_scan_start(local, sdata, local->scan_addr);
792 ieee80211_configure_filter(local); /* accept probe-responses */
795 ieee80211_hw_config(local, 0);
802 set_bit(SCAN_BEACON_WAIT, &local->scanning);
804 ieee80211_scan_state_send_probe(local, &next_delay);
809 ieee80211_queue_delayed_work(&local->hw, &local->scan_work,
814 __set_bit(SCAN_SW_SCANNING, &local->scanning);
817 ieee80211_recalc_idle(local);
821 rc = drv_hw_scan(local, sdata, local->hw_scan_req);
823 rc = ieee80211_start_sw_scan(local, sdata);
827 kfree(local->hw_scan_req);
828 local->hw_scan_req = NULL;
829 local->scanning = 0;
831 ieee80211_recalc_idle(local);
833 local->scan_req = NULL;
834 RCU_INIT_POINTER(local->scan_sdata, NULL);
864 static void ieee80211_scan_state_decision(struct ieee80211_local *local,
880 mutex_lock(&local->iflist_mtx);
881 list_for_each_entry(sdata, &local->interfaces, list) {
896 mutex_unlock(&local->iflist_mtx);
898 scan_req = rcu_dereference_protected(local->scan_req,
899 lockdep_is_held(&local->mtx));
901 next_chan = scan_req->channels[local->scan_channel_idx];
913 local->leave_oper_channel_time + HZ / 8);
926 local->next_scan_state = next_scan_state;
931 static void ieee80211_scan_state_set_channel(struct ieee80211_local *local,
939 scan_req = rcu_dereference_protected(local->scan_req,
940 lockdep_is_held(&local->mtx));
943 chan = scan_req->channels[local->scan_channel_idx];
945 local->scan_chandef.chan = chan;
946 local->scan_chandef.center_freq1 = chan->center_freq;
947 local->scan_chandef.freq1_offset = chan->freq_offset;
948 local->scan_chandef.center_freq2 = 0;
956 local->scan_chandef.width = ieee80211_s1g_channel_width(chan);
962 local->scan_chandef.width = NL80211_CHAN_WIDTH_5;
965 local->scan_chandef.width = NL80211_CHAN_WIDTH_10;
973 &local->_oper_chandef);
974 if (chan == local->_oper_chandef.chan &&
976 local->scan_chandef = local->_oper_chandef;
978 local->scan_chandef.width = NL80211_CHAN_WIDTH_20_NOHT;
988 if (ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL))
992 local->scan_channel_idx++;
996 local->next_scan_state = SCAN_DECISION;
1013 local->next_scan_state = SCAN_DECISION;
1015 set_bit(SCAN_BEACON_WAIT, &local->scanning);
1021 local->next_scan_state = SCAN_SEND_PROBE;
1024 static void ieee80211_scan_state_suspend(struct ieee80211_local *local,
1028 local->scan_chandef.chan = NULL;
1029 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
1032 ieee80211_offchannel_return(local);
1036 local->next_scan_state = SCAN_RESUME;
1039 static void ieee80211_scan_state_resume(struct ieee80211_local *local,
1042 ieee80211_offchannel_stop_vifs(local);
1044 if (local->ops->flush) {
1045 ieee80211_flush_queues(local, NULL, false);
1051 local->leave_oper_channel_time = jiffies;
1054 local->next_scan_state = SCAN_SET_CHANNEL;
1059 struct ieee80211_local *local =
1066 mutex_lock(&local->mtx);
1068 if (!ieee80211_can_run_worker(local)) {
1073 sdata = rcu_dereference_protected(local->scan_sdata,
1074 lockdep_is_held(&local->mtx));
1075 scan_req = rcu_dereference_protected(local->scan_req,
1076 lockdep_is_held(&local->mtx));
1079 if (test_bit(SCAN_ONCHANNEL_SCANNING, &local->scanning)) {
1080 aborted = test_and_clear_bit(SCAN_ABORTED, &local->scanning);
1084 if (test_and_clear_bit(SCAN_COMPLETED, &local->scanning)) {
1085 aborted = test_and_clear_bit(SCAN_ABORTED, &local->scanning);
1092 if (!local->scanning) {
1095 RCU_INIT_POINTER(local->scan_req, NULL);
1096 RCU_INIT_POINTER(local->scan_sdata, NULL);
1101 rcu_assign_pointer(local->scan_req, scan_req);
1108 clear_bit(SCAN_BEACON_WAIT, &local->scanning);
1120 if (test_and_clear_bit(SCAN_BEACON_DONE, &local->scanning) &&
1121 local->next_scan_state == SCAN_DECISION)
1122 local->next_scan_state = SCAN_SEND_PROBE;
1124 switch (local->next_scan_state) {
1127 if (local->scan_channel_idx >= scan_req->n_channels) {
1131 ieee80211_scan_state_decision(local, &next_delay);
1134 ieee80211_scan_state_set_channel(local, &next_delay);
1137 ieee80211_scan_state_send_probe(local, &next_delay);
1140 ieee80211_scan_state_suspend(local, &next_delay);
1143 ieee80211_scan_state_resume(local, &next_delay);
1151 ieee80211_queue_delayed_work(&local->hw, &local->scan_work, next_delay);
1155 __ieee80211_scan_completed(&local->hw, aborted);
1157 mutex_unlock(&local->mtx);
1165 mutex_lock(&sdata->local->mtx);
1167 mutex_unlock(&sdata->local->mtx);
1178 struct ieee80211_local *local = sdata->local;
1182 mutex_lock(&local->mtx);
1185 if (local->scan_req)
1193 if (!local->hw.wiphy->bands[band] ||
1197 max_n = local->hw.wiphy->bands[band]->n_channels;
1200 &local->hw.wiphy->bands[band]->channels[i];
1206 local->int_scan_req->channels[n_ch] = tmp_ch;
1214 local->int_scan_req->n_channels = n_ch;
1221 local->int_scan_req->channels[n_ch] = channels[i];
1228 local->int_scan_req->n_channels = n_ch;
1231 local->int_scan_req->ssids = &local->scan_ssid;
1232 local->int_scan_req->n_ssids = 1;
1233 local->int_scan_req->scan_width = scan_width;
1234 memcpy(local->int_scan_req->ssids[0].ssid, ssid, IEEE80211_MAX_SSID_LEN);
1235 local->int_scan_req->ssids[0].ssid_len = ssid_len;
1237 ret = __ieee80211_start_scan(sdata, sdata->local->int_scan_req);
1239 mutex_unlock(&local->mtx);
1246 void ieee80211_scan_cancel(struct ieee80211_local *local)
1255 * local->hw_scan_req to operate on 5G band, what race with
1256 * driver which can use local->hw_scan_req
1266 mutex_lock(&local->mtx);
1267 if (!local->scan_req)
1275 if (test_bit(SCAN_HW_SCANNING, &local->scanning) &&
1276 test_bit(SCAN_COMPLETED, &local->scanning)) {
1277 set_bit(SCAN_HW_CANCELLED, &local->scanning);
1281 if (test_bit(SCAN_HW_SCANNING, &local->scanning)) {
1286 set_bit(SCAN_HW_CANCELLED, &local->scanning);
1287 if (local->ops->cancel_hw_scan)
1288 drv_cancel_hw_scan(local,
1289 rcu_dereference_protected(local->scan_sdata,
1290 lockdep_is_held(&local->mtx)));
1299 cancel_delayed_work(&local->scan_work);
1301 memset(&local->scan_info, 0, sizeof(local->scan_info));
1302 __ieee80211_scan_completed(&local->hw, true);
1304 mutex_unlock(&local->mtx);
1310 struct ieee80211_local *local = sdata->local;
1319 iebufsz = local->scan_ies_len + req->ie_len;
1321 lockdep_assert_held(&local->mtx);
1323 if (!local->ops->sched_scan_start)
1327 if (local->hw.wiphy->bands[i]) {
1350 ret = drv_sched_scan_start(local, sdata, req, &sched_scan_ies);
1352 rcu_assign_pointer(local->sched_scan_sdata, sdata);
1353 rcu_assign_pointer(local->sched_scan_req, req);
1361 RCU_INIT_POINTER(local->sched_scan_sdata, NULL);
1362 RCU_INIT_POINTER(local->sched_scan_req, NULL);
1371 struct ieee80211_local *local = sdata->local;
1374 mutex_lock(&local->mtx);
1376 if (rcu_access_pointer(local->sched_scan_sdata)) {
1377 mutex_unlock(&local->mtx);
1383 mutex_unlock(&local->mtx);
1387 int ieee80211_request_sched_scan_stop(struct ieee80211_local *local)
1392 mutex_lock(&local->mtx);
1394 if (!local->ops->sched_scan_stop) {
1400 RCU_INIT_POINTER(local->sched_scan_req, NULL);
1402 sched_scan_sdata = rcu_dereference_protected(local->sched_scan_sdata,
1403 lockdep_is_held(&local->mtx));
1405 ret = drv_sched_scan_stop(local, sched_scan_sdata);
1407 RCU_INIT_POINTER(local->sched_scan_sdata, NULL);
1410 mutex_unlock(&local->mtx);
1417 struct ieee80211_local *local = hw_to_local(hw);
1419 trace_api_sched_scan_results(local);
1425 void ieee80211_sched_scan_end(struct ieee80211_local *local)
1427 mutex_lock(&local->mtx);
1429 if (!rcu_access_pointer(local->sched_scan_sdata)) {
1430 mutex_unlock(&local->mtx);
1434 RCU_INIT_POINTER(local->sched_scan_sdata, NULL);
1437 RCU_INIT_POINTER(local->sched_scan_req, NULL);
1439 mutex_unlock(&local->mtx);
1441 cfg80211_sched_scan_stopped(local->hw.wiphy, 0);
1446 struct ieee80211_local *local =
1450 ieee80211_sched_scan_end(local);
1455 struct ieee80211_local *local = hw_to_local(hw);
1457 trace_api_sched_scan_stopped(local);
1464 if (local->in_reconfig)
1467 schedule_work(&local->sched_scan_stopped_work);