Lines Matching +full:ftm +full:- +full:timer
1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright 2006-2010 Johannes Berg <[email protected]>
6 * Copyright 2013-2014 Intel Mobile Communications GmbH
7 * Copyright 2015-2017 Intel Deutschland GmbH
8 * Copyright (C) 2018-2024 Intel Corporation
31 #include "wext-compat.h"
32 #include "rdev-ops.h"
42 /* RCU-protected (and RTNL for writers) */
64 if (rdev->wiphy_idx == wiphy_idx) { in cfg80211_rdev_by_wiphy_idx()
77 return rdev->wiphy_idx; in get_wiphy_idx()
89 return &rdev->wiphy; in wiphy_idx_to_wiphy()
96 int wiphy_idx, taken = -1, digits; in cfg80211_dev_check_name()
101 return -EINVAL; in cfg80211_dev_check_name()
105 if (taken == strlen(newname) && wiphy_idx != rdev->wiphy_idx) { in cfg80211_dev_check_name()
115 return -EINVAL; in cfg80211_dev_check_name()
120 if (strcmp(newname, wiphy_name(&rdev2->wiphy)) == 0) in cfg80211_dev_check_name()
121 return -EINVAL; in cfg80211_dev_check_name()
132 lockdep_assert_wiphy(&rdev->wiphy); in cfg80211_dev_rename()
135 if (strcmp(newname, wiphy_name(&rdev->wiphy)) == 0) in cfg80211_dev_rename()
142 result = device_rename(&rdev->wiphy.dev, newname); in cfg80211_dev_rename()
146 debugfs_change_name(rdev->wiphy.debugfsdir, "%s", newname); in cfg80211_dev_rename()
159 if (!(rdev->wiphy.flags & WIPHY_FLAG_NETNS_OK)) in cfg80211_switch_netns()
160 return -EOPNOTSUPP; in cfg80211_switch_netns()
162 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) { in cfg80211_switch_netns()
163 if (!wdev->netdev) in cfg80211_switch_netns()
165 wdev->netdev->netns_local = false; in cfg80211_switch_netns()
166 err = dev_change_net_namespace(wdev->netdev, net, "wlan%d"); in cfg80211_switch_netns()
169 wdev->netdev->netns_local = true; in cfg80211_switch_netns()
173 /* failed -- clean up to old netns */ in cfg80211_switch_netns()
174 net = wiphy_net(&rdev->wiphy); in cfg80211_switch_netns()
177 &rdev->wiphy.wdev_list, in cfg80211_switch_netns()
179 if (!wdev->netdev) in cfg80211_switch_netns()
181 wdev->netdev->netns_local = false; in cfg80211_switch_netns()
182 err = dev_change_net_namespace(wdev->netdev, net, in cfg80211_switch_netns()
185 wdev->netdev->netns_local = true; in cfg80211_switch_netns()
191 guard(wiphy)(&rdev->wiphy); in cfg80211_switch_netns()
193 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) { in cfg80211_switch_netns()
194 if (!wdev->netdev) in cfg80211_switch_netns()
201 wiphy_net_set(&rdev->wiphy, net); in cfg80211_switch_netns()
203 err = device_rename(&rdev->wiphy.dev, dev_name(&rdev->wiphy.dev)); in cfg80211_switch_netns()
208 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) { in cfg80211_switch_netns()
209 if (!wdev->netdev) in cfg80211_switch_netns()
221 guard(wiphy)(&rdev->wiphy); in cfg80211_rfkill_poll()
229 lockdep_assert_held(&rdev->wiphy.mtx); in cfg80211_stop_p2p_device()
231 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_P2P_DEVICE)) in cfg80211_stop_p2p_device()
238 wdev->is_running = false; in cfg80211_stop_p2p_device()
240 rdev->opencount--; in cfg80211_stop_p2p_device()
242 if (rdev->scan_req && rdev->scan_req->wdev == wdev) { in cfg80211_stop_p2p_device()
243 if (WARN_ON(!rdev->scan_req->notified && in cfg80211_stop_p2p_device()
244 (!rdev->int_scan_req || in cfg80211_stop_p2p_device()
245 !rdev->int_scan_req->notified))) in cfg80211_stop_p2p_device()
246 rdev->scan_req->info.aborted = true; in cfg80211_stop_p2p_device()
254 lockdep_assert_held(&rdev->wiphy.mtx); in cfg80211_stop_nan()
256 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_NAN)) in cfg80211_stop_nan()
263 wdev->is_running = false; in cfg80211_stop_nan()
265 rdev->opencount--; in cfg80211_stop_nan()
275 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) { in cfg80211_shutdown_all_interfaces()
276 if (wdev->netdev) { in cfg80211_shutdown_all_interfaces()
277 dev_close(wdev->netdev); in cfg80211_shutdown_all_interfaces()
285 switch (wdev->iftype) { in cfg80211_shutdown_all_interfaces()
307 cfg80211_shutdown_all_interfaces(&rdev->wiphy); in cfg80211_rfkill_set_block()
329 guard(wiphy)(&rdev->wiphy); in cfg80211_event_work()
340 list_for_each_entry_safe(wdev, tmp, &rdev->wiphy.wdev_list, list) { in cfg80211_destroy_ifaces()
341 if (wdev->nl_owner_dead) { in cfg80211_destroy_ifaces()
342 if (wdev->netdev) in cfg80211_destroy_ifaces()
343 dev_close(wdev->netdev); in cfg80211_destroy_ifaces()
345 guard(wiphy)(&rdev->wiphy); in cfg80211_destroy_ifaces()
374 list_for_each_entry_safe(req, tmp, &rdev->sched_scan_req_list, list) { in cfg80211_sched_scan_stop_wk()
375 if (req->nl_owner_dead) in cfg80211_sched_scan_stop_wk()
389 regulatory_propagate_dfs_state(&rdev->wiphy, &rdev->radar_chandef, in cfg80211_propagate_radar_detect_wk()
405 regulatory_propagate_dfs_state(&rdev->wiphy, &rdev->cac_done_chandef, in cfg80211_propagate_cac_done_wk()
419 trace_wiphy_work_worker_start(&rdev->wiphy); in cfg80211_wiphy_work()
421 guard(wiphy)(&rdev->wiphy); in cfg80211_wiphy_work()
422 if (rdev->suspended) in cfg80211_wiphy_work()
425 spin_lock_irq(&rdev->wiphy_work_lock); in cfg80211_wiphy_work()
426 wk = list_first_entry_or_null(&rdev->wiphy_work_list, in cfg80211_wiphy_work()
429 list_del_init(&wk->entry); in cfg80211_wiphy_work()
430 if (!list_empty(&rdev->wiphy_work_list)) in cfg80211_wiphy_work()
432 spin_unlock_irq(&rdev->wiphy_work_lock); in cfg80211_wiphy_work()
434 trace_wiphy_work_run(&rdev->wiphy, wk); in cfg80211_wiphy_work()
435 wk->func(&rdev->wiphy, wk); in cfg80211_wiphy_work()
437 spin_unlock_irq(&rdev->wiphy_work_lock); in cfg80211_wiphy_work()
451 WARN_ON(ops->add_key && (!ops->del_key || !ops->set_default_key)); in wiphy_new_nm()
452 WARN_ON(ops->auth && (!ops->assoc || !ops->deauth || !ops->disassoc)); in wiphy_new_nm()
453 WARN_ON(ops->connect && !ops->disconnect); in wiphy_new_nm()
454 WARN_ON(ops->join_ibss && !ops->leave_ibss); in wiphy_new_nm()
455 WARN_ON(ops->add_virtual_intf && !ops->del_virtual_intf); in wiphy_new_nm()
456 WARN_ON(ops->add_station && !ops->del_station); in wiphy_new_nm()
457 WARN_ON(ops->add_mpath && !ops->del_mpath); in wiphy_new_nm()
458 WARN_ON(ops->join_mesh && !ops->leave_mesh); in wiphy_new_nm()
459 WARN_ON(ops->start_p2p_device && !ops->stop_p2p_device); in wiphy_new_nm()
460 WARN_ON(ops->start_ap && !ops->stop_ap); in wiphy_new_nm()
461 WARN_ON(ops->join_ocb && !ops->leave_ocb); in wiphy_new_nm()
462 WARN_ON(ops->suspend && !ops->resume); in wiphy_new_nm()
463 WARN_ON(ops->sched_scan_start && !ops->sched_scan_stop); in wiphy_new_nm()
464 WARN_ON(ops->remain_on_channel && !ops->cancel_remain_on_channel); in wiphy_new_nm()
465 WARN_ON(ops->tdls_channel_switch && !ops->tdls_cancel_channel_switch); in wiphy_new_nm()
466 WARN_ON(ops->add_tx_ts && !ops->del_tx_ts); in wiphy_new_nm()
474 rdev->ops = ops; in wiphy_new_nm()
476 rdev->wiphy_idx = atomic_inc_return(&wiphy_counter); in wiphy_new_nm()
478 if (unlikely(rdev->wiphy_idx < 0)) { in wiphy_new_nm()
486 rdev->wiphy_idx--; in wiphy_new_nm()
500 rv = dev_set_name(&rdev->wiphy.dev, "%s", requested_name); in wiphy_new_nm()
514 rv = dev_set_name(&rdev->wiphy.dev, PHY_NAME "%d", rdev->wiphy_idx); in wiphy_new_nm()
521 mutex_init(&rdev->wiphy.mtx); in wiphy_new_nm()
522 INIT_LIST_HEAD(&rdev->wiphy.wdev_list); in wiphy_new_nm()
523 INIT_LIST_HEAD(&rdev->beacon_registrations); in wiphy_new_nm()
524 spin_lock_init(&rdev->beacon_registrations_lock); in wiphy_new_nm()
525 spin_lock_init(&rdev->bss_lock); in wiphy_new_nm()
526 INIT_LIST_HEAD(&rdev->bss_list); in wiphy_new_nm()
527 INIT_LIST_HEAD(&rdev->sched_scan_req_list); in wiphy_new_nm()
528 wiphy_work_init(&rdev->scan_done_wk, __cfg80211_scan_done); in wiphy_new_nm()
529 INIT_DELAYED_WORK(&rdev->dfs_update_channels_wk, in wiphy_new_nm()
532 rdev->wiphy.wext = &cfg80211_wext_handler; in wiphy_new_nm()
535 device_initialize(&rdev->wiphy.dev); in wiphy_new_nm()
536 rdev->wiphy.dev.class = &ieee80211_class; in wiphy_new_nm()
537 rdev->wiphy.dev.platform_data = rdev; in wiphy_new_nm()
538 device_enable_async_suspend(&rdev->wiphy.dev); in wiphy_new_nm()
540 INIT_WORK(&rdev->destroy_work, cfg80211_destroy_iface_wk); in wiphy_new_nm()
541 wiphy_work_init(&rdev->sched_scan_stop_wk, cfg80211_sched_scan_stop_wk); in wiphy_new_nm()
542 INIT_WORK(&rdev->sched_scan_res_wk, cfg80211_sched_scan_results_wk); in wiphy_new_nm()
543 INIT_WORK(&rdev->propagate_radar_detect_wk, in wiphy_new_nm()
545 INIT_WORK(&rdev->propagate_cac_done_wk, cfg80211_propagate_cac_done_wk); in wiphy_new_nm()
546 INIT_WORK(&rdev->mgmt_registrations_update_wk, in wiphy_new_nm()
548 spin_lock_init(&rdev->mgmt_registrations_lock); in wiphy_new_nm()
549 INIT_WORK(&rdev->wiphy_work, cfg80211_wiphy_work); in wiphy_new_nm()
550 INIT_LIST_HEAD(&rdev->wiphy_work_list); in wiphy_new_nm()
551 spin_lock_init(&rdev->wiphy_work_lock); in wiphy_new_nm()
554 rdev->wiphy.flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT; in wiphy_new_nm()
557 wiphy_net_set(&rdev->wiphy, &init_net); in wiphy_new_nm()
559 rdev->rfkill_ops.set_block = cfg80211_rfkill_set_block; in wiphy_new_nm()
560 rdev->wiphy.rfkill = rfkill_alloc(dev_name(&rdev->wiphy.dev), in wiphy_new_nm()
561 &rdev->wiphy.dev, RFKILL_TYPE_WLAN, in wiphy_new_nm()
562 &rdev->rfkill_ops, rdev); in wiphy_new_nm()
564 if (!rdev->wiphy.rfkill) { in wiphy_new_nm()
565 wiphy_free(&rdev->wiphy); in wiphy_new_nm()
569 INIT_WORK(&rdev->rfkill_block, cfg80211_rfkill_block_work); in wiphy_new_nm()
570 INIT_WORK(&rdev->conn_work, cfg80211_conn_work); in wiphy_new_nm()
571 INIT_WORK(&rdev->event_work, cfg80211_event_work); in wiphy_new_nm()
572 INIT_WORK(&rdev->background_cac_abort_wk, in wiphy_new_nm()
574 INIT_DELAYED_WORK(&rdev->background_cac_done_wk, in wiphy_new_nm()
577 init_waitqueue_head(&rdev->dev_wait); in wiphy_new_nm()
582 * special -1 value. in wiphy_new_nm()
584 rdev->wiphy.retry_short = 7; in wiphy_new_nm()
585 rdev->wiphy.retry_long = 4; in wiphy_new_nm()
586 rdev->wiphy.frag_threshold = (u32) -1; in wiphy_new_nm()
587 rdev->wiphy.rts_threshold = (u32) -1; in wiphy_new_nm()
588 rdev->wiphy.coverage_class = 0; in wiphy_new_nm()
590 rdev->wiphy.max_num_csa_counters = 1; in wiphy_new_nm()
592 rdev->wiphy.max_sched_scan_plans = 1; in wiphy_new_nm()
593 rdev->wiphy.max_sched_scan_plan_interval = U32_MAX; in wiphy_new_nm()
595 return &rdev->wiphy; in wiphy_new_nm()
618 if (WARN_ON((c->max_interfaces < 2) && !c->radar_detect_widths)) in wiphy_verify_iface_combinations()
619 return -EINVAL; in wiphy_verify_iface_combinations()
622 if (WARN_ON(!c->num_different_channels)) in wiphy_verify_iface_combinations()
623 return -EINVAL; in wiphy_verify_iface_combinations()
626 * for multi-radio global combination, since it hold in wiphy_verify_iface_combinations()
630 WARN_ON(c->radar_detect_widths && in wiphy_verify_iface_combinations()
631 c->num_different_channels > 1)) in wiphy_verify_iface_combinations()
632 return -EINVAL; in wiphy_verify_iface_combinations()
634 if (WARN_ON(!c->n_limits)) in wiphy_verify_iface_combinations()
635 return -EINVAL; in wiphy_verify_iface_combinations()
637 for (j = 0; j < c->n_limits; j++) { in wiphy_verify_iface_combinations()
638 u16 types = c->limits[j].types; in wiphy_verify_iface_combinations()
642 return -EINVAL; in wiphy_verify_iface_combinations()
645 if (WARN_ON(!c->limits[j].max)) in wiphy_verify_iface_combinations()
646 return -EINVAL; in wiphy_verify_iface_combinations()
649 if (WARN_ON(wiphy->software_iftypes & types)) in wiphy_verify_iface_combinations()
650 return -EINVAL; in wiphy_verify_iface_combinations()
653 * check for multi-radio global combination, since it in wiphy_verify_iface_combinations()
658 c->limits[j].max > 1)) in wiphy_verify_iface_combinations()
659 return -EINVAL; in wiphy_verify_iface_combinations()
662 * check for multi-radio global combination, since it in wiphy_verify_iface_combinations()
667 c->limits[j].max > 1)) in wiphy_verify_iface_combinations()
668 return -EINVAL; in wiphy_verify_iface_combinations()
671 * This isn't well-defined right now. If you have an in wiphy_verify_iface_combinations()
681 c->beacon_int_min_gcd)) { in wiphy_verify_iface_combinations()
682 return -EINVAL; in wiphy_verify_iface_combinations()
685 cnt += c->limits[j].max; in wiphy_verify_iface_combinations()
690 if (WARN_ON((wiphy->interface_modes & types) != types)) in wiphy_verify_iface_combinations()
691 return -EINVAL; in wiphy_verify_iface_combinations()
695 return -EINVAL; in wiphy_verify_iface_combinations()
698 if (WARN_ON(cnt < c->max_interfaces)) in wiphy_verify_iface_combinations()
699 return -EINVAL; in wiphy_verify_iface_combinations()
710 if (wiphy->n_radio) { in wiphy_verify_combinations()
711 for (i = 0; i < wiphy->n_radio; i++) { in wiphy_verify_combinations()
712 const struct wiphy_radio *radio = &wiphy->radio[i]; in wiphy_verify_combinations()
715 radio->iface_combinations, in wiphy_verify_combinations()
716 radio->n_iface_combinations, in wiphy_verify_combinations()
726 wiphy->iface_combinations, in wiphy_verify_combinations()
727 wiphy->n_iface_combinations, in wiphy_verify_combinations()
741 u16 ifmodes = wiphy->interface_modes; in wiphy_register()
744 if (WARN_ON(wiphy->wowlan && in wiphy_register()
745 (wiphy->wowlan->flags & WIPHY_WOWLAN_GTK_REKEY_FAILURE) && in wiphy_register()
746 !(wiphy->wowlan->flags & WIPHY_WOWLAN_SUPPORTS_GTK_REKEY))) in wiphy_register()
747 return -EINVAL; in wiphy_register()
748 if (WARN_ON(wiphy->wowlan && in wiphy_register()
749 !wiphy->wowlan->flags && !wiphy->wowlan->n_patterns && in wiphy_register()
750 !wiphy->wowlan->tcp)) in wiphy_register()
751 return -EINVAL; in wiphy_register()
753 if (WARN_ON((wiphy->features & NL80211_FEATURE_TDLS_CHANNEL_SWITCH) && in wiphy_register()
754 (!rdev->ops->tdls_channel_switch || in wiphy_register()
755 !rdev->ops->tdls_cancel_channel_switch))) in wiphy_register()
756 return -EINVAL; in wiphy_register()
758 if (WARN_ON((wiphy->interface_modes & BIT(NL80211_IFTYPE_NAN)) && in wiphy_register()
759 (!rdev->ops->start_nan || !rdev->ops->stop_nan || in wiphy_register()
760 !rdev->ops->add_nan_func || !rdev->ops->del_nan_func || in wiphy_register()
761 !(wiphy->nan_supported_bands & BIT(NL80211_BAND_2GHZ))))) in wiphy_register()
762 return -EINVAL; in wiphy_register()
764 if (WARN_ON(wiphy->interface_modes & BIT(NL80211_IFTYPE_WDS))) in wiphy_register()
765 return -EINVAL; in wiphy_register()
767 if (WARN_ON(wiphy->pmsr_capa && !wiphy->pmsr_capa->ftm.supported)) in wiphy_register()
768 return -EINVAL; in wiphy_register()
770 if (wiphy->pmsr_capa && wiphy->pmsr_capa->ftm.supported) { in wiphy_register()
771 if (WARN_ON(!wiphy->pmsr_capa->ftm.asap && in wiphy_register()
772 !wiphy->pmsr_capa->ftm.non_asap)) in wiphy_register()
773 return -EINVAL; in wiphy_register()
774 if (WARN_ON(!wiphy->pmsr_capa->ftm.preambles || in wiphy_register()
775 !wiphy->pmsr_capa->ftm.bandwidths)) in wiphy_register()
776 return -EINVAL; in wiphy_register()
777 if (WARN_ON(wiphy->pmsr_capa->ftm.preambles & in wiphy_register()
783 return -EINVAL; in wiphy_register()
784 if (WARN_ON((wiphy->pmsr_capa->ftm.trigger_based || in wiphy_register()
785 wiphy->pmsr_capa->ftm.non_trigger_based) && in wiphy_register()
786 !(wiphy->pmsr_capa->ftm.preambles & in wiphy_register()
788 return -EINVAL; in wiphy_register()
789 if (WARN_ON(wiphy->pmsr_capa->ftm.bandwidths & in wiphy_register()
798 return -EINVAL; in wiphy_register()
801 if (WARN_ON((wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED) && in wiphy_register()
802 (wiphy->regulatory_flags & in wiphy_register()
807 return -EINVAL; in wiphy_register()
809 if (WARN_ON(wiphy->coalesce && in wiphy_register()
810 (!wiphy->coalesce->n_rules || in wiphy_register()
811 !wiphy->coalesce->n_patterns) && in wiphy_register()
812 (!wiphy->coalesce->pattern_min_len || in wiphy_register()
813 wiphy->coalesce->pattern_min_len > in wiphy_register()
814 wiphy->coalesce->pattern_max_len))) in wiphy_register()
815 return -EINVAL; in wiphy_register()
817 if (WARN_ON(wiphy->ap_sme_capa && in wiphy_register()
818 !(wiphy->flags & WIPHY_FLAG_HAVE_AP_SME))) in wiphy_register()
819 return -EINVAL; in wiphy_register()
821 if (WARN_ON(wiphy->addresses && !wiphy->n_addresses)) in wiphy_register()
822 return -EINVAL; in wiphy_register()
824 if (WARN_ON(wiphy->addresses && in wiphy_register()
825 !is_zero_ether_addr(wiphy->perm_addr) && in wiphy_register()
826 memcmp(wiphy->perm_addr, wiphy->addresses[0].addr, in wiphy_register()
828 return -EINVAL; in wiphy_register()
830 if (WARN_ON(wiphy->max_acl_mac_addrs && in wiphy_register()
831 (!(wiphy->flags & WIPHY_FLAG_HAVE_AP_SME) || in wiphy_register()
832 !rdev->ops->set_mac_acl))) in wiphy_register()
833 return -EINVAL; in wiphy_register()
838 if (WARN_ON(wiphy->bss_select_support && in wiphy_register()
839 (wiphy->bss_select_support & ~(BIT(__NL80211_BSS_SELECT_ATTR_AFTER_LAST) - 2)))) in wiphy_register()
840 return -EINVAL; in wiphy_register()
842 if (WARN_ON(wiphy_ext_feature_isset(&rdev->wiphy, in wiphy_register()
844 (!rdev->ops->set_pmk || !rdev->ops->del_pmk))) in wiphy_register()
845 return -EINVAL; in wiphy_register()
847 if (WARN_ON(!(rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_FW_ROAM) && in wiphy_register()
848 rdev->ops->update_connect_params)) in wiphy_register()
849 return -EINVAL; in wiphy_register()
851 if (wiphy->addresses) in wiphy_register()
852 memcpy(wiphy->perm_addr, wiphy->addresses[0].addr, ETH_ALEN); in wiphy_register()
856 ifmodes &= ((1 << NUM_NL80211_IFTYPES) - 1) & ~1; in wiphy_register()
857 if (WARN_ON(ifmodes != wiphy->interface_modes)) in wiphy_register()
858 wiphy->interface_modes = ifmodes; in wiphy_register()
870 sband = wiphy->bands[band]; in wiphy_register()
874 sband->band = band; in wiphy_register()
875 if (WARN_ON(!sband->n_channels)) in wiphy_register()
876 return -EINVAL; in wiphy_register()
878 * on 60GHz or sub-1Ghz band, there are no legacy rates, so in wiphy_register()
883 !sband->n_bitrates)) in wiphy_register()
884 return -EINVAL; in wiphy_register()
887 (sband->ht_cap.ht_supported || in wiphy_register()
888 sband->vht_cap.vht_supported))) in wiphy_register()
889 return -EINVAL; in wiphy_register()
898 sband->ht_cap.ht_supported) { in wiphy_register()
899 sband->ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; in wiphy_register()
900 sband->ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40; in wiphy_register()
908 if (WARN_ON(sband->n_bitrates > 32)) in wiphy_register()
909 return -EINVAL; in wiphy_register()
911 for (i = 0; i < sband->n_channels; i++) { in wiphy_register()
912 sband->channels[i].orig_flags = in wiphy_register()
913 sband->channels[i].flags; in wiphy_register()
914 sband->channels[i].orig_mag = INT_MAX; in wiphy_register()
915 sband->channels[i].orig_mpwr = in wiphy_register()
916 sband->channels[i].max_power; in wiphy_register()
917 sband->channels[i].band = band; in wiphy_register()
919 if (WARN_ON(sband->channels[i].freq_offset >= 1000)) in wiphy_register()
920 return -EINVAL; in wiphy_register()
928 if (WARN_ON(!iftd->types_mask)) in wiphy_register()
929 return -EINVAL; in wiphy_register()
930 if (WARN_ON(types & iftd->types_mask)) in wiphy_register()
931 return -EINVAL; in wiphy_register()
934 if (WARN_ON(!iftd->he_cap.has_he)) in wiphy_register()
935 return -EINVAL; in wiphy_register()
937 types |= iftd->types_mask; in wiphy_register()
940 have_he = iftd->he_cap.has_he; in wiphy_register()
943 iftd->he_cap.has_he; in wiphy_register()
945 has_ap = iftd->types_mask & ap_bits; in wiphy_register()
946 has_non_ap = iftd->types_mask & ~ap_bits; in wiphy_register()
951 * only if AP and non-AP were mentioned at the same time, in wiphy_register()
954 if (WARN_ON(iftd->eht_cap.has_eht && in wiphy_register()
956 return -EINVAL; in wiphy_register()
960 return -EINVAL; in wiphy_register()
967 return -EINVAL; in wiphy_register()
970 for (i = 0; i < rdev->wiphy.n_vendor_commands; i++) { in wiphy_register()
973 * VENDOR_CMD_RAW_DATA which is non-NULL) and also that in wiphy_register()
976 if (WARN_ON(!rdev->wiphy.vendor_commands[i].policy)) in wiphy_register()
977 return -EINVAL; in wiphy_register()
978 if (WARN_ON(!rdev->wiphy.vendor_commands[i].doit && in wiphy_register()
979 !rdev->wiphy.vendor_commands[i].dumpit)) in wiphy_register()
980 return -EINVAL; in wiphy_register()
984 if (WARN_ON(rdev->wiphy.wowlan && rdev->wiphy.wowlan->n_patterns && in wiphy_register()
985 (!rdev->wiphy.wowlan->pattern_min_len || in wiphy_register()
986 rdev->wiphy.wowlan->pattern_min_len > in wiphy_register()
987 rdev->wiphy.wowlan->pattern_max_len))) in wiphy_register()
988 return -EINVAL; in wiphy_register()
991 if (!wiphy->max_num_akm_suites) in wiphy_register()
992 wiphy->max_num_akm_suites = NL80211_MAX_NR_AKM_SUITES; in wiphy_register()
993 else if (wiphy->max_num_akm_suites < NL80211_MAX_NR_AKM_SUITES || in wiphy_register()
994 wiphy->max_num_akm_suites > CFG80211_MAX_NUM_AKM_SUITES) in wiphy_register()
995 return -EINVAL; in wiphy_register()
1000 rdev->wiphy.features |= NL80211_FEATURE_SCAN_FLUSH; in wiphy_register()
1003 wiphy_lock(&rdev->wiphy); in wiphy_register()
1004 res = device_add(&rdev->wiphy.dev); in wiphy_register()
1006 wiphy_unlock(&rdev->wiphy); in wiphy_register()
1011 list_add_rcu(&rdev->list, &cfg80211_rdev_list); in wiphy_register()
1015 rdev->wiphy.debugfsdir = debugfs_create_dir(wiphy_name(&rdev->wiphy), in wiphy_register()
1020 wiphy_unlock(&rdev->wiphy); in wiphy_register()
1025 if (wiphy->regulatory_flags & REGULATORY_CUSTOM_REG) { in wiphy_register()
1039 if (wiphy->extended_capabilities_len && in wiphy_register()
1040 wiphy->num_iftype_ext_capab && in wiphy_register()
1041 wiphy->iftype_ext_capab) { in wiphy_register()
1045 capab = wiphy->iftype_ext_capab; in wiphy_register()
1046 for (j = 0; j < wiphy->extended_capabilities_len; j++) { in wiphy_register()
1052 for (i = 1; i < wiphy->num_iftype_ext_capab; i++) { in wiphy_register()
1060 if (WARN_ON(wiphy->extended_capabilities[j] & in wiphy_register()
1066 rdev->wiphy.registered = true; in wiphy_register()
1069 res = rfkill_register(rdev->wiphy.rfkill); in wiphy_register()
1071 rfkill_destroy(rdev->wiphy.rfkill); in wiphy_register()
1072 rdev->wiphy.rfkill = NULL; in wiphy_register()
1073 wiphy_unregister(&rdev->wiphy); in wiphy_register()
1085 if (!rdev->ops->rfkill_poll) in wiphy_rfkill_start_polling()
1087 rdev->rfkill_ops.poll = cfg80211_rfkill_poll; in wiphy_rfkill_start_polling()
1088 rfkill_resume_polling(wiphy->rfkill); in wiphy_rfkill_start_polling()
1098 lockdep_assert_held(&rdev->wiphy.mtx); in cfg80211_process_wiphy_works()
1100 spin_lock_irqsave(&rdev->wiphy_work_lock, flags); in cfg80211_process_wiphy_works()
1101 while (!list_empty(&rdev->wiphy_work_list)) { in cfg80211_process_wiphy_works()
1104 wk = list_first_entry(&rdev->wiphy_work_list, in cfg80211_process_wiphy_works()
1106 list_del_init(&wk->entry); in cfg80211_process_wiphy_works()
1107 spin_unlock_irqrestore(&rdev->wiphy_work_lock, flags); in cfg80211_process_wiphy_works()
1109 trace_wiphy_work_run(&rdev->wiphy, wk); in cfg80211_process_wiphy_works()
1110 wk->func(&rdev->wiphy, wk); in cfg80211_process_wiphy_works()
1112 spin_lock_irqsave(&rdev->wiphy_work_lock, flags); in cfg80211_process_wiphy_works()
1117 if (WARN_ON(--runaway_limit == 0)) in cfg80211_process_wiphy_works()
1118 INIT_LIST_HEAD(&rdev->wiphy_work_list); in cfg80211_process_wiphy_works()
1120 spin_unlock_irqrestore(&rdev->wiphy_work_lock, flags); in cfg80211_process_wiphy_works()
1127 wait_event(rdev->dev_wait, ({ in wiphy_unregister()
1129 wiphy_lock(&rdev->wiphy); in wiphy_unregister()
1130 __count = rdev->opencount; in wiphy_unregister()
1131 wiphy_unlock(&rdev->wiphy); in wiphy_unregister()
1134 if (rdev->wiphy.rfkill) in wiphy_unregister()
1135 rfkill_unregister(rdev->wiphy.rfkill); in wiphy_unregister()
1138 wiphy_lock(&rdev->wiphy); in wiphy_unregister()
1140 rdev->wiphy.registered = false; in wiphy_unregister()
1142 WARN_ON(!list_empty(&rdev->wiphy.wdev_list)); in wiphy_unregister()
1148 debugfs_remove_recursive(rdev->wiphy.debugfsdir); in wiphy_unregister()
1149 list_del_rcu(&rdev->list); in wiphy_unregister()
1159 device_del(&rdev->wiphy.dev); in wiphy_unregister()
1162 if (rdev->wiphy.wowlan_config && rdev->ops->set_wakeup) in wiphy_unregister()
1168 wiphy_unlock(&rdev->wiphy); in wiphy_unregister()
1172 cancel_work_sync(&rdev->wiphy_work); in wiphy_unregister()
1174 cancel_work_sync(&rdev->conn_work); in wiphy_unregister()
1175 flush_work(&rdev->event_work); in wiphy_unregister()
1176 cancel_delayed_work_sync(&rdev->dfs_update_channels_wk); in wiphy_unregister()
1177 cancel_delayed_work_sync(&rdev->background_cac_done_wk); in wiphy_unregister()
1178 flush_work(&rdev->destroy_work); in wiphy_unregister()
1179 flush_work(&rdev->propagate_radar_detect_wk); in wiphy_unregister()
1180 flush_work(&rdev->propagate_cac_done_wk); in wiphy_unregister()
1181 flush_work(&rdev->mgmt_registrations_update_wk); in wiphy_unregister()
1182 flush_work(&rdev->background_cac_abort_wk); in wiphy_unregister()
1185 cfg80211_free_coalesce(rdev->coalesce); in wiphy_unregister()
1186 rdev->coalesce = NULL; in wiphy_unregister()
1196 spin_lock_irqsave(&rdev->wiphy_work_lock, flags); in cfg80211_dev_free()
1197 WARN_ON(!list_empty(&rdev->wiphy_work_list)); in cfg80211_dev_free()
1198 spin_unlock_irqrestore(&rdev->wiphy_work_lock, flags); in cfg80211_dev_free()
1199 cancel_work_sync(&rdev->wiphy_work); in cfg80211_dev_free()
1201 rfkill_destroy(rdev->wiphy.rfkill); in cfg80211_dev_free()
1202 list_for_each_entry_safe(reg, treg, &rdev->beacon_registrations, list) { in cfg80211_dev_free()
1203 list_del(®->list); in cfg80211_dev_free()
1206 list_for_each_entry_safe(scan, tmp, &rdev->bss_list, list) in cfg80211_dev_free()
1207 cfg80211_put_bss(&rdev->wiphy, &scan->pub); in cfg80211_dev_free()
1208 mutex_destroy(&rdev->wiphy.mtx); in cfg80211_dev_free()
1211 * The 'regd' can only be non-NULL if we never finished in cfg80211_dev_free()
1213 * unregister path - e.g. in failure scenarios. Thus, it in cfg80211_dev_free()
1214 * cannot have been visible to anyone if non-NULL, so we in cfg80211_dev_free()
1217 kfree(rcu_dereference_raw(rdev->wiphy.regd)); in cfg80211_dev_free()
1224 put_device(&wiphy->dev); in wiphy_free()
1233 if (rfkill_set_hw_state_reason(wiphy->rfkill, blocked, reason)) in wiphy_rfkill_set_hw_state_reason()
1234 schedule_work(&rdev->rfkill_block); in wiphy_rfkill_set_hw_state_reason()
1241 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in _cfg80211_unregister_wdev()
1246 lockdep_assert_held(&rdev->wiphy.mtx); in _cfg80211_unregister_wdev()
1250 wdev->registered = false; in _cfg80211_unregister_wdev()
1252 if (wdev->netdev) { in _cfg80211_unregister_wdev()
1253 sysfs_remove_link(&wdev->netdev->dev.kobj, "phy80211"); in _cfg80211_unregister_wdev()
1255 unregister_netdevice(wdev->netdev); in _cfg80211_unregister_wdev()
1258 list_del_rcu(&wdev->list); in _cfg80211_unregister_wdev()
1260 rdev->devlist_generation++; in _cfg80211_unregister_wdev()
1264 switch (wdev->iftype) { in _cfg80211_unregister_wdev()
1276 kfree_sensitive(wdev->wext.keys); in _cfg80211_unregister_wdev()
1277 wdev->wext.keys = NULL; in _cfg80211_unregister_wdev()
1279 wiphy_work_cancel(wdev->wiphy, &wdev->cqm_rssi_work); in _cfg80211_unregister_wdev()
1281 cqm_config = rcu_access_pointer(wdev->cqm_config); in _cfg80211_unregister_wdev()
1283 RCU_INIT_POINTER(wdev->cqm_config, NULL); in _cfg80211_unregister_wdev()
1291 if (wdev->iftype == NL80211_IFTYPE_STATION || in _cfg80211_unregister_wdev()
1292 wdev->iftype == NL80211_IFTYPE_P2P_CLIENT) { in _cfg80211_unregister_wdev()
1293 for (link_id = 0; link_id < ARRAY_SIZE(wdev->links); link_id++) { in _cfg80211_unregister_wdev()
1296 curbss = wdev->links[link_id].client.current_bss; in _cfg80211_unregister_wdev()
1300 cfg80211_put_bss(wdev->wiphy, &curbss->pub); in _cfg80211_unregister_wdev()
1301 wdev->links[link_id].client.current_bss = NULL; in _cfg80211_unregister_wdev()
1306 wdev->connected = false; in _cfg80211_unregister_wdev()
1322 lockdep_assert_held(&rdev->wiphy.mtx); in cfg80211_update_iface_num()
1324 rdev->num_running_ifaces += num; in cfg80211_update_iface_num()
1326 rdev->num_running_monitor_ifaces += num; in cfg80211_update_iface_num()
1332 struct net_device *dev = wdev->netdev; in cfg80211_leave()
1335 lockdep_assert_held(&rdev->wiphy.mtx); in cfg80211_leave()
1341 switch (wdev->iftype) { in cfg80211_leave()
1347 list_for_each_entry_safe(pos, tmp, &rdev->sched_scan_req_list, in cfg80211_leave()
1349 if (dev == pos->dev) in cfg80211_leave()
1354 kfree(wdev->wext.ie); in cfg80211_leave()
1355 wdev->wext.ie = NULL; in cfg80211_leave()
1356 wdev->wext.ie_len = 0; in cfg80211_leave()
1357 wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC; in cfg80211_leave()
1367 cfg80211_stop_ap(rdev, dev, -1, true); in cfg80211_leave()
1401 ev->type = EVENT_STOPPED; in cfg80211_stop_iface()
1403 spin_lock_irqsave(&wdev->event_lock, flags); in cfg80211_stop_iface()
1404 list_add_tail(&ev->list, &wdev->event_list); in cfg80211_stop_iface()
1405 spin_unlock_irqrestore(&wdev->event_lock, flags); in cfg80211_stop_iface()
1406 queue_work(cfg80211_wq, &rdev->event_work); in cfg80211_stop_iface()
1412 INIT_LIST_HEAD(&wdev->event_list); in cfg80211_init_wdev()
1413 spin_lock_init(&wdev->event_lock); in cfg80211_init_wdev()
1414 INIT_LIST_HEAD(&wdev->mgmt_registrations); in cfg80211_init_wdev()
1415 INIT_LIST_HEAD(&wdev->pmsr_list); in cfg80211_init_wdev()
1416 spin_lock_init(&wdev->pmsr_lock); in cfg80211_init_wdev()
1417 INIT_WORK(&wdev->pmsr_free_wk, cfg80211_pmsr_free_wk); in cfg80211_init_wdev()
1420 wdev->wext.default_key = -1; in cfg80211_init_wdev()
1421 wdev->wext.default_mgmt_key = -1; in cfg80211_init_wdev()
1422 wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC; in cfg80211_init_wdev()
1425 wiphy_work_init(&wdev->cqm_rssi_work, cfg80211_cqm_rssi_notify_work); in cfg80211_init_wdev()
1427 if (wdev->wiphy->flags & WIPHY_FLAG_PS_ON_BY_DEFAULT) in cfg80211_init_wdev()
1428 wdev->ps = true; in cfg80211_init_wdev()
1430 wdev->ps = false; in cfg80211_init_wdev()
1432 wdev->ps_timeout = -1; in cfg80211_init_wdev()
1434 wdev->radio_mask = BIT(wdev->wiphy->n_radio) - 1; in cfg80211_init_wdev()
1436 if ((wdev->iftype == NL80211_IFTYPE_STATION || in cfg80211_init_wdev()
1437 wdev->iftype == NL80211_IFTYPE_P2P_CLIENT || in cfg80211_init_wdev()
1438 wdev->iftype == NL80211_IFTYPE_ADHOC) && !wdev->use_4addr) in cfg80211_init_wdev()
1439 wdev->netdev->priv_flags |= IFF_DONT_BRIDGE; in cfg80211_init_wdev()
1441 INIT_WORK(&wdev->disconnect_wk, cfg80211_autodisconnect_wk); in cfg80211_init_wdev()
1448 lockdep_assert_held(&rdev->wiphy.mtx); in cfg80211_register_wdev()
1455 * 0-initialized. in cfg80211_register_wdev()
1457 if (!wdev->identifier) in cfg80211_register_wdev()
1458 wdev->identifier = ++rdev->wdev_id; in cfg80211_register_wdev()
1459 list_add_rcu(&wdev->list, &rdev->wiphy.wdev_list); in cfg80211_register_wdev()
1460 rdev->devlist_generation++; in cfg80211_register_wdev()
1461 wdev->registered = true; in cfg80211_register_wdev()
1463 if (wdev->netdev && in cfg80211_register_wdev()
1464 sysfs_create_link(&wdev->netdev->dev.kobj, &rdev->wiphy.dev.kobj, in cfg80211_register_wdev()
1473 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_register_netdevice()
1480 return -EINVAL; in cfg80211_register_netdevice()
1482 rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_register_netdevice()
1484 lockdep_assert_held(&rdev->wiphy.mtx); in cfg80211_register_netdevice()
1487 wdev->registered = true; in cfg80211_register_netdevice()
1488 wdev->registering = true; in cfg80211_register_netdevice()
1496 wdev->registering = false; in cfg80211_register_netdevice()
1498 wdev->registered = false; in cfg80211_register_netdevice()
1507 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_netdev_notifier_call()
1514 rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_netdev_notifier_call()
1516 WARN_ON(wdev->iftype == NL80211_IFTYPE_UNSPECIFIED); in cfg80211_netdev_notifier_call()
1521 wdev->netdev = dev; in cfg80211_netdev_notifier_call()
1523 dev->netns_local = true; in cfg80211_netdev_notifier_call()
1528 if (!wdev->registered) { in cfg80211_netdev_notifier_call()
1529 guard(wiphy)(&rdev->wiphy); in cfg80211_netdev_notifier_call()
1537 * so check wdev->registered. in cfg80211_netdev_notifier_call()
1539 if (wdev->registered && !wdev->registering) { in cfg80211_netdev_notifier_call()
1540 guard(wiphy)(&rdev->wiphy); in cfg80211_netdev_notifier_call()
1546 scoped_guard(wiphy, &rdev->wiphy) { in cfg80211_netdev_notifier_call()
1551 cancel_work_sync(&wdev->disconnect_wk); in cfg80211_netdev_notifier_call()
1552 cancel_work_sync(&wdev->pmsr_free_wk); in cfg80211_netdev_notifier_call()
1555 wiphy_lock(&rdev->wiphy); in cfg80211_netdev_notifier_call()
1556 cfg80211_update_iface_num(rdev, wdev->iftype, -1); in cfg80211_netdev_notifier_call()
1557 if (rdev->scan_req && rdev->scan_req->wdev == wdev) { in cfg80211_netdev_notifier_call()
1558 if (WARN_ON(!rdev->scan_req->notified && in cfg80211_netdev_notifier_call()
1559 (!rdev->int_scan_req || in cfg80211_netdev_notifier_call()
1560 !rdev->int_scan_req->notified))) in cfg80211_netdev_notifier_call()
1561 rdev->scan_req->info.aborted = true; in cfg80211_netdev_notifier_call()
1566 &rdev->sched_scan_req_list, list) { in cfg80211_netdev_notifier_call()
1567 if (WARN_ON(pos->dev == wdev->netdev)) in cfg80211_netdev_notifier_call()
1571 rdev->opencount--; in cfg80211_netdev_notifier_call()
1572 wiphy_unlock(&rdev->wiphy); in cfg80211_netdev_notifier_call()
1573 wake_up(&rdev->dev_wait); in cfg80211_netdev_notifier_call()
1576 wiphy_lock(&rdev->wiphy); in cfg80211_netdev_notifier_call()
1577 cfg80211_update_iface_num(rdev, wdev->iftype, 1); in cfg80211_netdev_notifier_call()
1578 switch (wdev->iftype) { in cfg80211_netdev_notifier_call()
1595 setup.mesh_id = wdev->u.mesh.id; in cfg80211_netdev_notifier_call()
1596 setup.mesh_id_len = wdev->u.mesh.id_up_len; in cfg80211_netdev_notifier_call()
1597 if (wdev->u.mesh.id_up_len) in cfg80211_netdev_notifier_call()
1607 rdev->opencount++; in cfg80211_netdev_notifier_call()
1613 if ((wdev->iftype == NL80211_IFTYPE_STATION || in cfg80211_netdev_notifier_call()
1614 wdev->iftype == NL80211_IFTYPE_P2P_CLIENT) && in cfg80211_netdev_notifier_call()
1615 rdev->ops->set_power_mgmt && in cfg80211_netdev_notifier_call()
1616 rdev_set_power_mgmt(rdev, dev, wdev->ps, in cfg80211_netdev_notifier_call()
1617 wdev->ps_timeout)) { in cfg80211_netdev_notifier_call()
1619 wdev->ps = false; in cfg80211_netdev_notifier_call()
1621 wiphy_unlock(&rdev->wiphy); in cfg80211_netdev_notifier_call()
1624 if (!cfg80211_iftype_allowed(wdev->wiphy, wdev->iftype, in cfg80211_netdev_notifier_call()
1625 wdev->use_4addr, 0)) in cfg80211_netdev_notifier_call()
1626 return notifier_from_errno(-EOPNOTSUPP); in cfg80211_netdev_notifier_call()
1628 if (rfkill_blocked(rdev->wiphy.rfkill)) in cfg80211_netdev_notifier_call()
1629 return notifier_from_errno(-ERFKILL); in cfg80211_netdev_notifier_call()
1650 if (net_eq(wiphy_net(&rdev->wiphy), net)) in cfg80211_pernet_exit()
1667 spin_lock_irqsave(&rdev->wiphy_work_lock, flags); in wiphy_work_queue()
1668 if (list_empty(&work->entry)) in wiphy_work_queue()
1669 list_add_tail(&work->entry, &rdev->wiphy_work_list); in wiphy_work_queue()
1670 spin_unlock_irqrestore(&rdev->wiphy_work_lock, flags); in wiphy_work_queue()
1672 queue_work(system_unbound_wq, &rdev->wiphy_work); in wiphy_work_queue()
1681 lockdep_assert_held(&wiphy->mtx); in wiphy_work_cancel()
1685 spin_lock_irqsave(&rdev->wiphy_work_lock, flags); in wiphy_work_cancel()
1686 if (!list_empty(&work->entry)) in wiphy_work_cancel()
1687 list_del_init(&work->entry); in wiphy_work_cancel()
1688 spin_unlock_irqrestore(&rdev->wiphy_work_lock, flags); in wiphy_work_cancel()
1700 spin_lock_irqsave(&rdev->wiphy_work_lock, flags); in wiphy_work_flush()
1701 run = !work || !list_empty(&work->entry); in wiphy_work_flush()
1702 spin_unlock_irqrestore(&rdev->wiphy_work_lock, flags); in wiphy_work_flush()
1711 struct wiphy_delayed_work *dwork = from_timer(dwork, t, timer); in wiphy_delayed_work_timer()
1713 wiphy_work_queue(dwork->wiphy, &dwork->work); in wiphy_delayed_work_timer()
1721 trace_wiphy_delayed_work_queue(wiphy, &dwork->work, delay); in wiphy_delayed_work_queue()
1724 del_timer(&dwork->timer); in wiphy_delayed_work_queue()
1725 wiphy_work_queue(wiphy, &dwork->work); in wiphy_delayed_work_queue()
1729 dwork->wiphy = wiphy; in wiphy_delayed_work_queue()
1730 mod_timer(&dwork->timer, jiffies + delay); in wiphy_delayed_work_queue()
1737 lockdep_assert_held(&wiphy->mtx); in wiphy_delayed_work_cancel()
1739 del_timer_sync(&dwork->timer); in wiphy_delayed_work_cancel()
1740 wiphy_work_cancel(wiphy, &dwork->work); in wiphy_delayed_work_cancel()
1747 lockdep_assert_held(&wiphy->mtx); in wiphy_delayed_work_flush()
1749 del_timer_sync(&dwork->timer); in wiphy_delayed_work_flush()
1750 wiphy_work_flush(wiphy, &dwork->work); in wiphy_delayed_work_flush()
1757 return timer_pending(&dwork->timer); in wiphy_delayed_work_pending()
1789 err = -ENOMEM; in cfg80211_init()