Lines Matching refs:local

33 void ieee80211_rx_bss_put(struct ieee80211_local *local,
38 cfg80211_put_bss(local->hw.wiphy,
60 ieee80211_bss_info_update(struct ieee80211_local *local,
73 if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM)
75 else if (local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC)
76 signal = (rx_status->signal * 100) / local->hw.max_signal;
84 cbss = cfg80211_inform_bss_width_frame(local->hw.wiphy, channel,
154 local->hw.wiphy->bands[rx_status->band];
164 void ieee80211_scan_rx(struct ieee80211_local *local, struct sk_buff *skb)
180 sdata1 = rcu_dereference(local->scan_sdata);
181 sdata2 = rcu_dereference(local->sched_scan_sdata);
204 channel = ieee80211_get_channel(local->hw.wiphy, rx_status->freq);
209 bss = ieee80211_bss_info_update(local, rx_status,
213 ieee80211_rx_bss_put(local, bss);
235 static bool ieee80211_prep_hw_scan(struct ieee80211_local *local)
237 struct cfg80211_scan_request *req = local->scan_req;
242 if (test_bit(SCAN_HW_CANCELLED, &local->scanning))
245 if (local->hw.flags & IEEE80211_SINGLE_HW_SCAN_ON_ALL_BANDS) {
247 local->hw_scan_req->req.channels[i] = req->channels[i];
254 if (local->hw_scan_band == IEEE80211_NUM_BANDS)
261 local->hw_scan_band)
263 local->hw_scan_req->req.channels[n_chans] =
269 local->hw_scan_band++;
273 local->hw_scan_req->req.n_channels = n_chans;
276 ielen = ieee80211_build_preq_ies(local,
277 (u8 *)local->hw_scan_req->req.ie,
278 local->hw_scan_ies_bufsize,
279 &local->hw_scan_req->ies,
282 local->hw_scan_req->req.ie_len = ielen;
283 local->hw_scan_req->req.no_cck = req->no_cck;
290 struct ieee80211_local *local = hw_to_local(hw);
291 bool hw_scan = local->ops->hw_scan;
292 bool was_scanning = local->scanning;
294 lockdep_assert_held(&local->mtx);
299 * local->scan_req next), but not to complete it
302 if (WARN_ON(!local->scanning && !aborted))
305 if (WARN_ON(!local->scan_req))
309 !(local->hw.flags & IEEE80211_SINGLE_HW_SCAN_ON_ALL_BANDS) &&
310 ieee80211_prep_hw_scan(local)) {
313 rc = drv_hw_scan(local,
314 rcu_dereference_protected(local->scan_sdata,
315 lockdep_is_held(&local->mtx)),
316 local->hw_scan_req);
322 kfree(local->hw_scan_req);
323 local->hw_scan_req = NULL;
325 if (local->scan_req != local->int_scan_req)
326 cfg80211_scan_done(local->scan_req, aborted);
327 local->scan_req = NULL;
328 RCU_INIT_POINTER(local->scan_sdata, NULL);
330 local->scanning = 0;
331 local->scan_chandef.chan = NULL;
334 ieee80211_hw_config(local, 0);
337 ieee80211_configure_filter(local);
338 drv_sw_scan_complete(local);
339 ieee80211_offchannel_return(local);
342 ieee80211_recalc_idle(local);
344 ieee80211_mlme_notify_scan_completed(local);
345 ieee80211_ibss_notify_scan_completed(local);
346 ieee80211_mesh_notify_scan_completed(local);
348 ieee80211_start_next_roc(local);
353 struct ieee80211_local *local = hw_to_local(hw);
355 trace_api_scan_completed(local, aborted);
357 set_bit(SCAN_COMPLETED, &local->scanning);
359 set_bit(SCAN_ABORTED, &local->scanning);
360 ieee80211_queue_delayed_work(&local->hw, &local->scan_work, 0);
364 static int ieee80211_start_sw_scan(struct ieee80211_local *local)
367 if (local->use_chanctx)
379 * Note that while local->sw_scanning is true everything else but
383 drv_sw_scan_start(local);
385 local->leave_oper_channel_time = jiffies;
386 local->next_scan_state = SCAN_DECISION;
387 local->scan_channel_idx = 0;
389 ieee80211_offchannel_stop_vifs(local);
392 ieee80211_flush_queues(local, NULL);
394 ieee80211_configure_filter(local);
397 ieee80211_hw_config(local, 0);
399 ieee80211_queue_delayed_work(&local->hw,
400 &local->scan_work, 0);
405 static bool ieee80211_can_scan(struct ieee80211_local *local,
408 if (local->radar_detect_enabled)
411 if (!list_empty(&local->roc_list))
421 void ieee80211_run_deferred_scan(struct ieee80211_local *local)
423 lockdep_assert_held(&local->mtx);
425 if (!local->scan_req || local->scanning)
428 if (!ieee80211_can_scan(local,
430 local->scan_sdata,
431 lockdep_is_held(&local->mtx))))
434 ieee80211_queue_delayed_work(&local->hw, &local->scan_work,
438 static void ieee80211_scan_state_send_probe(struct ieee80211_local *local,
443 enum ieee80211_band band = local->hw.conf.chandef.chan->band;
447 if (local->scan_req->no_cck)
450 sdata = rcu_dereference_protected(local->scan_sdata,
451 lockdep_is_held(&local->mtx));
453 for (i = 0; i < local->scan_req->n_ssids; i++)
456 local->scan_req->ssids[i].ssid,
457 local->scan_req->ssids[i].ssid_len,
458 local->scan_req->ie, local->scan_req->ie_len,
459 local->scan_req->rates[band], false,
460 tx_flags, local->hw.conf.chandef.chan, true);
467 local->next_scan_state = SCAN_DECISION;
473 struct ieee80211_local *local = sdata->local;
476 lockdep_assert_held(&local->mtx);
478 if (local->scan_req)
481 if (!ieee80211_can_scan(local, sdata)) {
483 local->scan_req = req;
484 rcu_assign_pointer(local->scan_sdata, sdata);
488 if (local->ops->hw_scan) {
491 local->hw_scan_ies_bufsize = local->scan_ies_len + req->ie_len;
493 if (local->hw.flags & IEEE80211_SINGLE_HW_SCAN_ON_ALL_BANDS) {
504 local->hw_scan_ies_bufsize *= n_bands;
507 local->hw_scan_req = kmalloc(
508 sizeof(*local->hw_scan_req) +
510 local->hw_scan_ies_bufsize, GFP_KERNEL);
511 if (!local->hw_scan_req)
514 local->hw_scan_req->req.ssids = req->ssids;
515 local->hw_scan_req->req.n_ssids = req->n_ssids;
516 ies = (u8 *)local->hw_scan_req +
517 sizeof(*local->hw_scan_req) +
519 local->hw_scan_req->req.ie = ies;
520 local->hw_scan_req->req.flags = req->flags;
522 local->hw_scan_band = 0;
525 * After allocating local->hw_scan_req, we must
533 local->scan_req = req;
534 rcu_assign_pointer(local->scan_sdata, sdata);
536 if (local->ops->hw_scan) {
537 __set_bit(SCAN_HW_SCANNING, &local->scanning);
539 (req->channels[0] == local->_oper_chandef.chan)) {
546 __set_bit(SCAN_ONCHANNEL_SCANNING, &local->scanning);
548 ieee80211_recalc_idle(local);
552 drv_sw_scan_start(local);
554 ieee80211_configure_filter(local); /* accept probe-responses */
557 ieee80211_hw_config(local, 0);
561 !local->scan_req->n_ssids) {
564 ieee80211_scan_state_send_probe(local, &next_delay);
569 ieee80211_queue_delayed_work(&local->hw, &local->scan_work,
574 __set_bit(SCAN_SW_SCANNING, &local->scanning);
577 ieee80211_recalc_idle(local);
579 if (local->ops->hw_scan) {
580 WARN_ON(!ieee80211_prep_hw_scan(local));
581 rc = drv_hw_scan(local, sdata, local->hw_scan_req);
583 rc = ieee80211_start_sw_scan(local);
586 kfree(local->hw_scan_req);
587 local->hw_scan_req = NULL;
588 local->scanning = 0;
590 ieee80211_recalc_idle(local);
592 local->scan_req = NULL;
593 RCU_INIT_POINTER(local->scan_sdata, NULL);
611 static void ieee80211_scan_state_decision(struct ieee80211_local *local,
626 mutex_lock(&local->iflist_mtx);
627 list_for_each_entry(sdata, &local->interfaces, list) {
642 mutex_unlock(&local->iflist_mtx);
644 next_chan = local->scan_req->channels[local->scan_channel_idx];
656 local->leave_oper_channel_time + HZ / 8);
659 if (local->scan_req->flags & NL80211_SCAN_FLAG_LOW_PRIORITY)
669 local->next_scan_state = next_scan_state;
674 static void ieee80211_scan_state_set_channel(struct ieee80211_local *local,
682 chan = local->scan_req->channels[local->scan_channel_idx];
684 local->scan_chandef.chan = chan;
685 local->scan_chandef.center_freq1 = chan->center_freq;
686 local->scan_chandef.center_freq2 = 0;
687 switch (local->scan_req->scan_width) {
689 local->scan_chandef.width = NL80211_CHAN_WIDTH_5;
692 local->scan_chandef.width = NL80211_CHAN_WIDTH_10;
699 &local->_oper_chandef);
700 if (chan == local->_oper_chandef.chan &&
701 oper_scan_width == local->scan_req->scan_width)
702 local->scan_chandef = local->_oper_chandef;
704 local->scan_chandef.width = NL80211_CHAN_WIDTH_20_NOHT;
708 if (ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL))
712 local->scan_channel_idx++;
716 local->next_scan_state = SCAN_DECISION;
731 !local->scan_req->n_ssids) {
733 local->next_scan_state = SCAN_DECISION;
739 local->next_scan_state = SCAN_SEND_PROBE;
742 static void ieee80211_scan_state_suspend(struct ieee80211_local *local,
746 local->scan_chandef.chan = NULL;
747 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
750 ieee80211_offchannel_return(local);
754 local->next_scan_state = SCAN_RESUME;
757 static void ieee80211_scan_state_resume(struct ieee80211_local *local,
760 ieee80211_offchannel_stop_vifs(local);
762 if (local->ops->flush) {
763 ieee80211_flush_queues(local, NULL);
769 local->leave_oper_channel_time = jiffies;
772 local->next_scan_state = SCAN_SET_CHANNEL;
777 struct ieee80211_local *local =
783 mutex_lock(&local->mtx);
785 sdata = rcu_dereference_protected(local->scan_sdata,
786 lockdep_is_held(&local->mtx));
789 if (test_bit(SCAN_ONCHANNEL_SCANNING, &local->scanning)) {
790 aborted = test_and_clear_bit(SCAN_ABORTED, &local->scanning);
794 if (test_and_clear_bit(SCAN_COMPLETED, &local->scanning)) {
795 aborted = test_and_clear_bit(SCAN_ABORTED, &local->scanning);
799 if (!sdata || !local->scan_req)
802 if (local->scan_req && !local->scanning) {
803 struct cfg80211_scan_request *req = local->scan_req;
806 local->scan_req = NULL;
807 RCU_INIT_POINTER(local->scan_sdata, NULL);
812 local->scan_req = req;
829 switch (local->next_scan_state) {
832 if (local->scan_channel_idx >= local->scan_req->n_channels) {
836 ieee80211_scan_state_decision(local, &next_delay);
839 ieee80211_scan_state_set_channel(local, &next_delay);
842 ieee80211_scan_state_send_probe(local, &next_delay);
845 ieee80211_scan_state_suspend(local, &next_delay);
848 ieee80211_scan_state_resume(local, &next_delay);
856 ieee80211_queue_delayed_work(&local->hw, &local->scan_work, next_delay);
860 __ieee80211_scan_completed(&local->hw, aborted);
862 mutex_unlock(&local->mtx);
870 mutex_lock(&sdata->local->mtx);
872 mutex_unlock(&sdata->local->mtx);
882 struct ieee80211_local *local = sdata->local;
886 mutex_lock(&local->mtx);
889 if (local->scan_req)
898 if (!local->hw.wiphy->bands[band])
901 max_n = local->hw.wiphy->bands[band]->n_channels;
904 &local->hw.wiphy->bands[band]->channels[i];
910 local->int_scan_req->channels[n_ch] = tmp_ch;
918 local->int_scan_req->n_channels = n_ch;
924 local->int_scan_req->channels[0] = chan;
925 local->int_scan_req->n_channels = 1;
928 local->int_scan_req->ssids = &local->scan_ssid;
929 local->int_scan_req->n_ssids = 1;
930 local->int_scan_req->scan_width = scan_width;
931 memcpy(local->int_scan_req->ssids[0].ssid, ssid, IEEE80211_MAX_SSID_LEN);
932 local->int_scan_req->ssids[0].ssid_len = ssid_len;
934 ret = __ieee80211_start_scan(sdata, sdata->local->int_scan_req);
936 mutex_unlock(&local->mtx);
943 void ieee80211_scan_cancel(struct ieee80211_local *local)
952 * local->hw_scan_req to operate on 5G band, what race with
953 * driver which can use local->hw_scan_req
963 mutex_lock(&local->mtx);
964 if (!local->scan_req)
972 if (test_bit(SCAN_HW_SCANNING, &local->scanning) &&
973 test_bit(SCAN_COMPLETED, &local->scanning)) {
974 set_bit(SCAN_HW_CANCELLED, &local->scanning);
978 if (test_bit(SCAN_HW_SCANNING, &local->scanning)) {
983 set_bit(SCAN_HW_CANCELLED, &local->scanning);
984 if (local->ops->cancel_hw_scan)
985 drv_cancel_hw_scan(local,
986 rcu_dereference_protected(local->scan_sdata,
987 lockdep_is_held(&local->mtx)));
996 cancel_delayed_work(&local->scan_work);
998 __ieee80211_scan_completed(&local->hw, true);
1000 mutex_unlock(&local->mtx);
1006 struct ieee80211_local *local = sdata->local;
1015 iebufsz = local->scan_ies_len + req->ie_len;
1017 lockdep_assert_held(&local->mtx);
1019 if (!local->ops->sched_scan_start)
1023 if (local->hw.wiphy->bands[i]) {
1038 len = ieee80211_build_preq_ies(local, ie, num_bands * iebufsz,
1043 ret = drv_sched_scan_start(local, sdata, req, &sched_scan_ies);
1045 rcu_assign_pointer(local->sched_scan_sdata, sdata);
1046 local->sched_scan_req = req;
1054 RCU_INIT_POINTER(local->sched_scan_sdata, NULL);
1055 local->sched_scan_req = NULL;
1064 struct ieee80211_local *local = sdata->local;
1067 mutex_lock(&local->mtx);
1069 if (rcu_access_pointer(local->sched_scan_sdata)) {
1070 mutex_unlock(&local->mtx);
1076 mutex_unlock(&local->mtx);
1082 struct ieee80211_local *local = sdata->local;
1085 mutex_lock(&local->mtx);
1087 if (!local->ops->sched_scan_stop) {
1093 local->sched_scan_req = NULL;
1095 if (rcu_access_pointer(local->sched_scan_sdata)) {
1096 ret = drv_sched_scan_stop(local, sdata);
1098 RCU_INIT_POINTER(local->sched_scan_sdata, NULL);
1101 mutex_unlock(&local->mtx);
1108 struct ieee80211_local *local = hw_to_local(hw);
1110 trace_api_sched_scan_results(local);
1116 void ieee80211_sched_scan_end(struct ieee80211_local *local)
1118 mutex_lock(&local->mtx);
1120 if (!rcu_access_pointer(local->sched_scan_sdata)) {
1121 mutex_unlock(&local->mtx);
1125 RCU_INIT_POINTER(local->sched_scan_sdata, NULL);
1128 local->sched_scan_req = NULL;
1130 mutex_unlock(&local->mtx);
1132 cfg80211_sched_scan_stopped(local->hw.wiphy);
1137 struct ieee80211_local *local =
1141 ieee80211_sched_scan_end(local);
1146 struct ieee80211_local *local = hw_to_local(hw);
1148 trace_api_sched_scan_stopped(local);
1150 schedule_work(&local->sched_scan_stopped_work);