Lines Matching +full:local +full:- +full:cap +full:- +full:size

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright 2002-2005, Instant802 Networks, Inc.
4 * Copyright 2005-2006, Devicescape Software, Inc.
5 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
6 * Copyright 2013-2014 Intel Mobile Communications GmbH
8 * Copyright (C) 2018 - 2019 Intel Corporation
29 #include "driver-ops.h"
36 void ieee80211_configure_filter(struct ieee80211_local *local) in ieee80211_configure_filter() argument
42 if (atomic_read(&local->iff_allmultis)) in ieee80211_configure_filter()
45 if (local->monitors || test_bit(SCAN_SW_SCANNING, &local->scanning) || in ieee80211_configure_filter()
46 test_bit(SCAN_ONCHANNEL_SCANNING, &local->scanning)) in ieee80211_configure_filter()
49 if (local->fif_probe_req || local->probe_req_reg) in ieee80211_configure_filter()
52 if (local->fif_fcsfail) in ieee80211_configure_filter()
55 if (local->fif_plcpfail) in ieee80211_configure_filter()
58 if (local->fif_control) in ieee80211_configure_filter()
61 if (local->fif_other_bss) in ieee80211_configure_filter()
64 if (local->fif_pspoll) in ieee80211_configure_filter()
67 if (local->rx_mcast_action_reg) in ieee80211_configure_filter()
70 spin_lock_bh(&local->filter_lock); in ieee80211_configure_filter()
71 changed_flags = local->filter_flags ^ new_flags; in ieee80211_configure_filter()
73 mc = drv_prepare_multicast(local, &local->mc_list); in ieee80211_configure_filter()
74 spin_unlock_bh(&local->filter_lock); in ieee80211_configure_filter()
79 drv_configure_filter(local, changed_flags, &new_flags, mc); in ieee80211_configure_filter()
83 local->filter_flags = new_flags & ~(1<<31); in ieee80211_configure_filter()
88 struct ieee80211_local *local = in ieee80211_reconfig_filter() local
91 ieee80211_configure_filter(local); in ieee80211_reconfig_filter()
94 static u32 ieee80211_hw_conf_chan(struct ieee80211_local *local) in ieee80211_hw_conf_chan() argument
102 offchannel_flag = local->hw.conf.flags & IEEE80211_CONF_OFFCHANNEL; in ieee80211_hw_conf_chan()
104 if (local->scan_chandef.chan) { in ieee80211_hw_conf_chan()
105 chandef = local->scan_chandef; in ieee80211_hw_conf_chan()
106 } else if (local->tmp_channel) { in ieee80211_hw_conf_chan()
107 chandef.chan = local->tmp_channel; in ieee80211_hw_conf_chan()
109 chandef.center_freq1 = chandef.chan->center_freq; in ieee80211_hw_conf_chan()
110 chandef.freq1_offset = chandef.chan->freq_offset; in ieee80211_hw_conf_chan()
112 chandef = local->_oper_chandef; in ieee80211_hw_conf_chan()
116 chandef.chan->center_freq, chandef.chan->freq_offset, in ieee80211_hw_conf_chan()
120 if (!cfg80211_chandef_identical(&chandef, &local->_oper_chandef)) in ieee80211_hw_conf_chan()
121 local->hw.conf.flags |= IEEE80211_CONF_OFFCHANNEL; in ieee80211_hw_conf_chan()
123 local->hw.conf.flags &= ~IEEE80211_CONF_OFFCHANNEL; in ieee80211_hw_conf_chan()
125 offchannel_flag ^= local->hw.conf.flags & IEEE80211_CONF_OFFCHANNEL; in ieee80211_hw_conf_chan()
128 !cfg80211_chandef_identical(&local->hw.conf.chandef, in ieee80211_hw_conf_chan()
129 &local->_oper_chandef)) { in ieee80211_hw_conf_chan()
130 local->hw.conf.chandef = chandef; in ieee80211_hw_conf_chan()
134 if (!conf_is_ht(&local->hw.conf)) { in ieee80211_hw_conf_chan()
140 local->hw.conf.smps_mode = IEEE80211_SMPS_STATIC; in ieee80211_hw_conf_chan()
141 } else if (local->hw.conf.smps_mode != local->smps_mode) { in ieee80211_hw_conf_chan()
142 local->hw.conf.smps_mode = local->smps_mode; in ieee80211_hw_conf_chan()
149 list_for_each_entry_rcu(sdata, &local->interfaces, list) { in ieee80211_hw_conf_chan()
150 if (!rcu_access_pointer(sdata->vif.chanctx_conf)) in ieee80211_hw_conf_chan()
152 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_hw_conf_chan()
154 if (sdata->vif.bss_conf.txpower == INT_MIN) in ieee80211_hw_conf_chan()
156 power = min(power, sdata->vif.bss_conf.txpower); in ieee80211_hw_conf_chan()
160 if (local->hw.conf.power_level != power) { in ieee80211_hw_conf_chan()
162 local->hw.conf.power_level = power; in ieee80211_hw_conf_chan()
168 int ieee80211_hw_config(struct ieee80211_local *local, u32 changed) in ieee80211_hw_config() argument
174 if (!local->use_chanctx) in ieee80211_hw_config()
175 changed |= ieee80211_hw_conf_chan(local); in ieee80211_hw_config()
180 if (changed && local->open_count) { in ieee80211_hw_config()
181 ret = drv_config(local, changed); in ieee80211_hw_config()
205 struct ieee80211_local *local = sdata->local; in ieee80211_bss_info_change_notify() local
207 if (!changed || sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_bss_info_change_notify()
210 drv_bss_info_changed(local, sdata, &sdata->vif.bss_conf, changed); in ieee80211_bss_info_change_notify()
215 sdata->vif.bss_conf.use_cts_prot = false; in ieee80211_reset_erp_info()
216 sdata->vif.bss_conf.use_short_preamble = false; in ieee80211_reset_erp_info()
217 sdata->vif.bss_conf.use_short_slot = false; in ieee80211_reset_erp_info()
225 struct ieee80211_local *local = (struct ieee80211_local *) data; in ieee80211_tasklet_handler() local
228 while ((skb = skb_dequeue(&local->skb_queue)) || in ieee80211_tasklet_handler()
229 (skb = skb_dequeue(&local->skb_queue_unreliable))) { in ieee80211_tasklet_handler()
230 switch (skb->pkt_type) { in ieee80211_tasklet_handler()
232 /* Clear skb->pkt_type in order to not confuse kernel in ieee80211_tasklet_handler()
234 skb->pkt_type = 0; in ieee80211_tasklet_handler()
235 ieee80211_rx(&local->hw, skb); in ieee80211_tasklet_handler()
238 skb->pkt_type = 0; in ieee80211_tasklet_handler()
239 ieee80211_tx_status(&local->hw, skb); in ieee80211_tasklet_handler()
243 skb->pkt_type); in ieee80211_tasklet_handler()
252 struct ieee80211_local *local = in ieee80211_restart_work() local
257 flush_workqueue(local->workqueue); in ieee80211_restart_work()
258 flush_work(&local->sched_scan_stopped_work); in ieee80211_restart_work()
260 WARN(test_bit(SCAN_HW_SCANNING, &local->scanning), in ieee80211_restart_work()
263 flush_work(&local->radar_detected_work); in ieee80211_restart_work()
265 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_restart_work()
274 if (sdata->vif.type == NL80211_IFTYPE_STATION) { in ieee80211_restart_work()
282 cancel_work_sync(&sdata->u.mgd.csa_connection_drop_work); in ieee80211_restart_work()
284 flush_delayed_work(&sdata->dec_tailroom_needed_wk); in ieee80211_restart_work()
286 ieee80211_scan_cancel(local); in ieee80211_restart_work()
288 /* make sure any new ROC will consider local->in_reconfig */ in ieee80211_restart_work()
289 flush_delayed_work(&local->roc_work); in ieee80211_restart_work()
290 flush_work(&local->hw_roc_done); in ieee80211_restart_work()
295 ieee80211_reconfig(local); in ieee80211_restart_work()
301 struct ieee80211_local *local = hw_to_local(hw); in ieee80211_restart_hw() local
303 trace_api_restart_hw(local); in ieee80211_restart_hw()
305 wiphy_info(hw->wiphy, in ieee80211_restart_hw()
317 local->in_reconfig = true; in ieee80211_restart_hw()
320 queue_work(system_freezable_wq, &local->restart_work); in ieee80211_restart_hw()
329 struct ieee80211_local *local = in ieee80211_ifa_changed() local
332 struct net_device *ndev = ifa->ifa_dev->dev; in ieee80211_ifa_changed()
333 struct wireless_dev *wdev = ndev->ieee80211_ptr; in ieee80211_ifa_changed()
344 if (wdev->wiphy != local->hw.wiphy) in ieee80211_ifa_changed()
348 bss_conf = &sdata->vif.bss_conf; in ieee80211_ifa_changed()
351 if (sdata->vif.type != NL80211_IFTYPE_STATION) in ieee80211_ifa_changed()
354 idev = __in_dev_get_rtnl(sdata->dev); in ieee80211_ifa_changed()
358 ifmgd = &sdata->u.mgd; in ieee80211_ifa_changed()
362 ifa = rtnl_dereference(idev->ifa_list); in ieee80211_ifa_changed()
365 bss_conf->arp_addr_list[c] = ifa->ifa_address; in ieee80211_ifa_changed()
366 ifa = rtnl_dereference(ifa->ifa_next); in ieee80211_ifa_changed()
370 bss_conf->arp_addr_cnt = c; in ieee80211_ifa_changed()
373 if (ifmgd->associated) in ieee80211_ifa_changed()
388 struct inet6_dev *idev = ifa->idev; in ieee80211_ifa6_changed()
389 struct net_device *ndev = ifa->idev->dev; in ieee80211_ifa6_changed()
390 struct ieee80211_local *local = in ieee80211_ifa6_changed() local
392 struct wireless_dev *wdev = ndev->ieee80211_ptr; in ieee80211_ifa6_changed()
396 if (!wdev || wdev->wiphy != local->hw.wiphy) in ieee80211_ifa6_changed()
405 if (sdata->vif.type != NL80211_IFTYPE_STATION) in ieee80211_ifa6_changed()
408 drv_ipv6_addr_change(local, sdata, idev); in ieee80211_ifa6_changed()
531 struct ieee80211_local *local; in ieee80211_alloc_hw_nm() local
536 if (WARN_ON(!ops->tx || !ops->start || !ops->stop || !ops->config || in ieee80211_alloc_hw_nm()
537 !ops->add_interface || !ops->remove_interface || in ieee80211_alloc_hw_nm()
538 !ops->configure_filter)) in ieee80211_alloc_hw_nm()
541 if (WARN_ON(ops->sta_state && (ops->sta_add || ops->sta_remove))) in ieee80211_alloc_hw_nm()
545 i = !!ops->add_chanctx + !!ops->remove_chanctx + in ieee80211_alloc_hw_nm()
546 !!ops->change_chanctx + !!ops->assign_vif_chanctx + in ieee80211_alloc_hw_nm()
547 !!ops->unassign_vif_chanctx; in ieee80211_alloc_hw_nm()
552 /* Ensure 32-byte alignment of our private data and hw private data. in ieee80211_alloc_hw_nm()
558 * +-------------------------+ in ieee80211_alloc_hw_nm()
560 * +-------------------------+ in ieee80211_alloc_hw_nm()
562 * +-------------------------+ in ieee80211_alloc_hw_nm()
564 * +-------------------------+ in ieee80211_alloc_hw_nm()
567 priv_size = ALIGN(sizeof(*local), NETDEV_ALIGN) + priv_data_len; in ieee80211_alloc_hw_nm()
574 wiphy->mgmt_stypes = ieee80211_default_mgmt_stypes; in ieee80211_alloc_hw_nm()
576 wiphy->privid = mac80211_wiphy_privid; in ieee80211_alloc_hw_nm()
578 wiphy->flags |= WIPHY_FLAG_NETNS_OK | in ieee80211_alloc_hw_nm()
584 if (!use_chanctx || ops->remain_on_channel) in ieee80211_alloc_hw_nm()
585 wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; in ieee80211_alloc_hw_nm()
587 wiphy->features |= NL80211_FEATURE_SK_TX_STATUS | in ieee80211_alloc_hw_nm()
604 if (!ops->hw_scan) { in ieee80211_alloc_hw_nm()
605 wiphy->features |= NL80211_FEATURE_LOW_PRIORITY_SCAN | in ieee80211_alloc_hw_nm()
610 * supported even with hw scan - but let drivers opt in. in ieee80211_alloc_hw_nm()
618 if (!ops->set_key) in ieee80211_alloc_hw_nm()
619 wiphy->flags |= WIPHY_FLAG_IBSS_RSN; in ieee80211_alloc_hw_nm()
621 if (ops->wake_tx_queue) in ieee80211_alloc_hw_nm()
626 wiphy->bss_priv_size = sizeof(struct ieee80211_bss); in ieee80211_alloc_hw_nm()
628 local = wiphy_priv(wiphy); in ieee80211_alloc_hw_nm()
630 if (sta_info_init(local)) in ieee80211_alloc_hw_nm()
633 local->hw.wiphy = wiphy; in ieee80211_alloc_hw_nm()
635 local->hw.priv = (char *)local + ALIGN(sizeof(*local), NETDEV_ALIGN); in ieee80211_alloc_hw_nm()
637 local->ops = ops; in ieee80211_alloc_hw_nm()
638 local->use_chanctx = use_chanctx; in ieee80211_alloc_hw_nm()
643 * to be queued in the stack. The value is a bit-shift of 1 in ieee80211_alloc_hw_nm()
644 * second, so 7 is ~8ms of queued data. Only affects local TCP in ieee80211_alloc_hw_nm()
646 * This is the default, anyhow - drivers may need to override it in ieee80211_alloc_hw_nm()
647 * for local reasons (longer buffers, longer completion time, or in ieee80211_alloc_hw_nm()
650 local->hw.tx_sk_pacing_shift = 7; in ieee80211_alloc_hw_nm()
653 local->hw.queues = 1; in ieee80211_alloc_hw_nm()
654 local->hw.max_rates = 1; in ieee80211_alloc_hw_nm()
655 local->hw.max_report_rates = 0; in ieee80211_alloc_hw_nm()
656 local->hw.max_rx_aggregation_subframes = IEEE80211_MAX_AMPDU_BUF_HT; in ieee80211_alloc_hw_nm()
657 local->hw.max_tx_aggregation_subframes = IEEE80211_MAX_AMPDU_BUF_HT; in ieee80211_alloc_hw_nm()
658 local->hw.offchannel_tx_hw_queue = IEEE80211_INVAL_HW_QUEUE; in ieee80211_alloc_hw_nm()
659 local->hw.conf.long_frame_max_tx_count = wiphy->retry_long; in ieee80211_alloc_hw_nm()
660 local->hw.conf.short_frame_max_tx_count = wiphy->retry_short; in ieee80211_alloc_hw_nm()
661 local->hw.radiotap_mcs_details = IEEE80211_RADIOTAP_MCS_HAVE_MCS | in ieee80211_alloc_hw_nm()
664 local->hw.radiotap_vht_details = IEEE80211_RADIOTAP_VHT_KNOWN_GI | in ieee80211_alloc_hw_nm()
666 local->hw.uapsd_queues = IEEE80211_DEFAULT_UAPSD_QUEUES; in ieee80211_alloc_hw_nm()
667 local->hw.uapsd_max_sp_len = IEEE80211_DEFAULT_MAX_SP_LEN; in ieee80211_alloc_hw_nm()
668 local->hw.max_mtu = IEEE80211_MAX_DATA_LEN; in ieee80211_alloc_hw_nm()
669 local->user_power_level = IEEE80211_UNSET_POWER_LEVEL; in ieee80211_alloc_hw_nm()
670 wiphy->ht_capa_mod_mask = &mac80211_ht_capa_mod_mask; in ieee80211_alloc_hw_nm()
671 wiphy->vht_capa_mod_mask = &mac80211_vht_capa_mod_mask; in ieee80211_alloc_hw_nm()
673 local->ext_capa[7] = WLAN_EXT_CAPA8_OPMODE_NOTIF; in ieee80211_alloc_hw_nm()
675 wiphy->extended_capabilities = local->ext_capa; in ieee80211_alloc_hw_nm()
676 wiphy->extended_capabilities_mask = local->ext_capa; in ieee80211_alloc_hw_nm()
677 wiphy->extended_capabilities_len = in ieee80211_alloc_hw_nm()
678 ARRAY_SIZE(local->ext_capa); in ieee80211_alloc_hw_nm()
680 INIT_LIST_HEAD(&local->interfaces); in ieee80211_alloc_hw_nm()
681 INIT_LIST_HEAD(&local->mon_list); in ieee80211_alloc_hw_nm()
683 __hw_addr_init(&local->mc_list); in ieee80211_alloc_hw_nm()
685 mutex_init(&local->iflist_mtx); in ieee80211_alloc_hw_nm()
686 mutex_init(&local->mtx); in ieee80211_alloc_hw_nm()
688 mutex_init(&local->key_mtx); in ieee80211_alloc_hw_nm()
689 spin_lock_init(&local->filter_lock); in ieee80211_alloc_hw_nm()
690 spin_lock_init(&local->rx_path_lock); in ieee80211_alloc_hw_nm()
691 spin_lock_init(&local->queue_stop_reason_lock); in ieee80211_alloc_hw_nm()
694 INIT_LIST_HEAD(&local->active_txqs[i]); in ieee80211_alloc_hw_nm()
695 spin_lock_init(&local->active_txq_lock[i]); in ieee80211_alloc_hw_nm()
696 local->aql_txq_limit_low[i] = IEEE80211_DEFAULT_AQL_TXQ_LIMIT_L; in ieee80211_alloc_hw_nm()
697 local->aql_txq_limit_high[i] = in ieee80211_alloc_hw_nm()
701 local->airtime_flags = AIRTIME_USE_TX | AIRTIME_USE_RX; in ieee80211_alloc_hw_nm()
702 local->aql_threshold = IEEE80211_AQL_THRESHOLD; in ieee80211_alloc_hw_nm()
703 atomic_set(&local->aql_total_pending_airtime, 0); in ieee80211_alloc_hw_nm()
705 INIT_LIST_HEAD(&local->chanctx_list); in ieee80211_alloc_hw_nm()
706 mutex_init(&local->chanctx_mtx); in ieee80211_alloc_hw_nm()
708 INIT_DELAYED_WORK(&local->scan_work, ieee80211_scan_work); in ieee80211_alloc_hw_nm()
710 INIT_WORK(&local->restart_work, ieee80211_restart_work); in ieee80211_alloc_hw_nm()
712 INIT_WORK(&local->radar_detected_work, in ieee80211_alloc_hw_nm()
715 INIT_WORK(&local->reconfig_filter, ieee80211_reconfig_filter); in ieee80211_alloc_hw_nm()
716 local->smps_mode = IEEE80211_SMPS_OFF; in ieee80211_alloc_hw_nm()
718 INIT_WORK(&local->dynamic_ps_enable_work, in ieee80211_alloc_hw_nm()
720 INIT_WORK(&local->dynamic_ps_disable_work, in ieee80211_alloc_hw_nm()
722 timer_setup(&local->dynamic_ps_timer, ieee80211_dynamic_ps_timer, 0); in ieee80211_alloc_hw_nm()
724 INIT_WORK(&local->sched_scan_stopped_work, in ieee80211_alloc_hw_nm()
727 INIT_WORK(&local->tdls_chsw_work, ieee80211_tdls_chsw_work); in ieee80211_alloc_hw_nm()
729 spin_lock_init(&local->ack_status_lock); in ieee80211_alloc_hw_nm()
730 idr_init(&local->ack_status_frames); in ieee80211_alloc_hw_nm()
733 skb_queue_head_init(&local->pending[i]); in ieee80211_alloc_hw_nm()
734 atomic_set(&local->agg_queue_stop[i], 0); in ieee80211_alloc_hw_nm()
736 tasklet_init(&local->tx_pending_tasklet, ieee80211_tx_pending, in ieee80211_alloc_hw_nm()
737 (unsigned long)local); in ieee80211_alloc_hw_nm()
739 if (ops->wake_tx_queue) in ieee80211_alloc_hw_nm()
740 tasklet_init(&local->wake_txqs_tasklet, ieee80211_wake_txqs, in ieee80211_alloc_hw_nm()
741 (unsigned long)local); in ieee80211_alloc_hw_nm()
743 tasklet_init(&local->tasklet, in ieee80211_alloc_hw_nm()
745 (unsigned long) local); in ieee80211_alloc_hw_nm()
747 skb_queue_head_init(&local->skb_queue); in ieee80211_alloc_hw_nm()
748 skb_queue_head_init(&local->skb_queue_unreliable); in ieee80211_alloc_hw_nm()
749 skb_queue_head_init(&local->skb_queue_tdls_chsw); in ieee80211_alloc_hw_nm()
751 ieee80211_alloc_led_names(local); in ieee80211_alloc_hw_nm()
753 ieee80211_roc_setup(local); in ieee80211_alloc_hw_nm()
755 local->hw.radiotap_timestamp.units_pos = -1; in ieee80211_alloc_hw_nm()
756 local->hw.radiotap_timestamp.accuracy = -1; in ieee80211_alloc_hw_nm()
758 return &local->hw; in ieee80211_alloc_hw_nm()
765 static int ieee80211_init_cipher_suites(struct ieee80211_local *local) in ieee80211_init_cipher_suites() argument
768 bool have_mfp = ieee80211_hw_check(&local->hw, MFP_CAPABLE); in ieee80211_init_cipher_suites()
781 /* keep last -- depends on hw flags! */ in ieee80211_init_cipher_suites()
788 if (ieee80211_hw_check(&local->hw, SW_CRYPTO_CONTROL) || in ieee80211_init_cipher_suites()
789 local->hw.wiphy->cipher_suites) { in ieee80211_init_cipher_suites()
797 if (!local->hw.wiphy->n_cipher_suites) in ieee80211_init_cipher_suites()
801 suites = kmemdup(local->hw.wiphy->cipher_suites, in ieee80211_init_cipher_suites()
802 sizeof(u32) * local->hw.wiphy->n_cipher_suites, in ieee80211_init_cipher_suites()
805 return -ENOMEM; in ieee80211_init_cipher_suites()
807 for (r = 0; r < local->hw.wiphy->n_cipher_suites; r++) { in ieee80211_init_cipher_suites()
808 u32 suite = local->hw.wiphy->cipher_suites[r]; in ieee80211_init_cipher_suites()
815 } else if (!local->hw.cipher_schemes) { in ieee80211_init_cipher_suites()
820 local->hw.wiphy->cipher_suites = cipher_suites; in ieee80211_init_cipher_suites()
821 local->hw.wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites); in ieee80211_init_cipher_suites()
824 local->hw.wiphy->n_cipher_suites -= 4; in ieee80211_init_cipher_suites()
827 local->hw.wiphy->cipher_suites += 2; in ieee80211_init_cipher_suites()
828 local->hw.wiphy->n_cipher_suites -= 2; in ieee80211_init_cipher_suites()
836 cs = local->hw.cipher_schemes; in ieee80211_init_cipher_suites()
842 * CCMP-256, GCMP, and GCMP-256 in ieee80211_init_cipher_suites()
844 n_suites = local->hw.n_cipher_schemes + 5; in ieee80211_init_cipher_suites()
850 /* check if we have AES_CMAC, BIP-CMAC-256, BIP-GMAC-128, in ieee80211_init_cipher_suites()
851 * BIP-GMAC-256 in ieee80211_init_cipher_suites()
858 return -ENOMEM; in ieee80211_init_cipher_suites()
878 for (r = 0; r < local->hw.n_cipher_schemes; r++) { in ieee80211_init_cipher_suites()
882 return -EINVAL; in ieee80211_init_cipher_suites()
887 local->hw.wiphy->cipher_suites = suites; in ieee80211_init_cipher_suites()
888 local->hw.wiphy->n_cipher_suites = w; in ieee80211_init_cipher_suites()
889 local->wiphy_ciphers_allocated = true; in ieee80211_init_cipher_suites()
896 struct ieee80211_local *local = hw_to_local(hw); in ieee80211_register_hw() local
904 (local->hw.offchannel_tx_hw_queue == IEEE80211_INVAL_HW_QUEUE || in ieee80211_register_hw()
905 local->hw.offchannel_tx_hw_queue >= local->hw.queues)) in ieee80211_register_hw()
906 return -EINVAL; in ieee80211_register_hw()
908 if ((hw->wiphy->features & NL80211_FEATURE_TDLS_CHANNEL_SWITCH) && in ieee80211_register_hw()
909 (!local->ops->tdls_channel_switch || in ieee80211_register_hw()
910 !local->ops->tdls_cancel_channel_switch || in ieee80211_register_hw()
911 !local->ops->tdls_recv_channel_switch)) in ieee80211_register_hw()
912 return -EOPNOTSUPP; in ieee80211_register_hw()
915 !local->ops->set_frag_threshold)) in ieee80211_register_hw()
916 return -EINVAL; in ieee80211_register_hw()
918 if (WARN_ON(local->hw.wiphy->interface_modes & in ieee80211_register_hw()
920 (!local->ops->start_nan || !local->ops->stop_nan))) in ieee80211_register_hw()
921 return -EINVAL; in ieee80211_register_hw()
924 if (hw->wiphy->wowlan && (!local->ops->suspend || !local->ops->resume)) in ieee80211_register_hw()
925 return -EINVAL; in ieee80211_register_hw()
928 if (!local->use_chanctx) { in ieee80211_register_hw()
929 for (i = 0; i < local->hw.wiphy->n_iface_combinations; i++) { in ieee80211_register_hw()
932 comb = &local->hw.wiphy->iface_combinations[i]; in ieee80211_register_hw()
934 if (comb->num_different_channels > 1) in ieee80211_register_hw()
935 return -EINVAL; in ieee80211_register_hw()
943 if (local->hw.wiphy->interface_modes & BIT(NL80211_IFTYPE_WDS)) in ieee80211_register_hw()
944 return -EINVAL; in ieee80211_register_hw()
946 /* DFS is not supported with multi-channel combinations yet */ in ieee80211_register_hw()
947 for (i = 0; i < local->hw.wiphy->n_iface_combinations; i++) { in ieee80211_register_hw()
950 comb = &local->hw.wiphy->iface_combinations[i]; in ieee80211_register_hw()
952 if (comb->radar_detect_widths && in ieee80211_register_hw()
953 comb->num_different_channels > 1) in ieee80211_register_hw()
954 return -EINVAL; in ieee80211_register_hw()
959 if (WARN_ON(hw->netdev_features & ~MAC80211_SUPPORTED_FEATURES)) in ieee80211_register_hw()
960 return -EINVAL; in ieee80211_register_hw()
962 if (hw->max_report_rates == 0) in ieee80211_register_hw()
963 hw->max_report_rates = hw->max_rates; in ieee80211_register_hw()
965 local->rx_chains = 1; in ieee80211_register_hw()
980 sband = local->hw.wiphy->bands[band]; in ieee80211_register_hw()
986 &sband->channels[0], in ieee80211_register_hw()
989 if (!local->use_chanctx && !local->_oper_chandef.chan) { in ieee80211_register_hw()
990 local->hw.conf.chandef = dflt_chandef; in ieee80211_register_hw()
991 local->_oper_chandef = dflt_chandef; in ieee80211_register_hw()
993 local->monitor_chandef = dflt_chandef; in ieee80211_register_hw()
996 channels += sband->n_channels; in ieee80211_register_hw()
998 if (max_bitrates < sband->n_bitrates) in ieee80211_register_hw()
999 max_bitrates = sband->n_bitrates; in ieee80211_register_hw()
1000 supp_ht = supp_ht || sband->ht_cap.ht_supported; in ieee80211_register_hw()
1001 supp_vht = supp_vht || sband->vht_cap.vht_supported; in ieee80211_register_hw()
1007 if (WARN_ON(local->hw.queues < IEEE80211_NUM_ACS && in ieee80211_register_hw()
1009 return -EINVAL; in ieee80211_register_hw()
1011 if (!sband->ht_cap.ht_supported) in ieee80211_register_hw()
1015 local->rx_chains = in ieee80211_register_hw()
1016 max(ieee80211_mcs_to_chains(&sband->ht_cap.mcs), in ieee80211_register_hw()
1017 local->rx_chains); in ieee80211_register_hw()
1020 sband->ht_cap.cap |= WLAN_HT_CAP_SM_PS_DISABLED << in ieee80211_register_hw()
1024 /* if low-level driver supports AP, we also support VLAN. in ieee80211_register_hw()
1028 if (local->hw.wiphy->interface_modes & BIT(NL80211_IFTYPE_AP) && in ieee80211_register_hw()
1029 !ieee80211_hw_check(&local->hw, SW_CRYPTO_CONTROL)) { in ieee80211_register_hw()
1030 hw->wiphy->interface_modes |= BIT(NL80211_IFTYPE_AP_VLAN); in ieee80211_register_hw()
1031 hw->wiphy->software_iftypes |= BIT(NL80211_IFTYPE_AP_VLAN); in ieee80211_register_hw()
1035 hw->wiphy->interface_modes |= BIT(NL80211_IFTYPE_MONITOR); in ieee80211_register_hw()
1036 hw->wiphy->software_iftypes |= BIT(NL80211_IFTYPE_MONITOR); in ieee80211_register_hw()
1039 for (i = 0; i < hw->wiphy->n_iface_combinations; i++) { in ieee80211_register_hw()
1043 c = &hw->wiphy->iface_combinations[i]; in ieee80211_register_hw()
1045 for (j = 0; j < c->n_limits; j++) in ieee80211_register_hw()
1046 if ((c->limits[j].types & BIT(NL80211_IFTYPE_ADHOC)) && in ieee80211_register_hw()
1047 c->limits[j].max > 1) in ieee80211_register_hw()
1048 return -EINVAL; in ieee80211_register_hw()
1051 local->int_scan_req = kzalloc(sizeof(*local->int_scan_req) + in ieee80211_register_hw()
1053 if (!local->int_scan_req) in ieee80211_register_hw()
1054 return -ENOMEM; in ieee80211_register_hw()
1057 if (!local->hw.wiphy->bands[band]) in ieee80211_register_hw()
1059 local->int_scan_req->rates[band] = (u32) -1; in ieee80211_register_hw()
1064 local->hw.wiphy->interface_modes &= ~BIT(NL80211_IFTYPE_MESH_POINT); in ieee80211_register_hw()
1069 if (local->hw.wiphy->interface_modes & BIT(NL80211_IFTYPE_MESH_POINT)) in ieee80211_register_hw()
1070 local->hw.wiphy->flags |= WIPHY_FLAG_MESH_AUTH; in ieee80211_register_hw()
1073 local->hw.wiphy->flags |= WIPHY_FLAG_CONTROL_PORT_PROTOCOL; in ieee80211_register_hw()
1075 if (ieee80211_hw_check(&local->hw, SIGNAL_DBM)) { in ieee80211_register_hw()
1076 local->hw.wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; in ieee80211_register_hw()
1077 } else if (ieee80211_hw_check(&local->hw, SIGNAL_UNSPEC)) { in ieee80211_register_hw()
1078 local->hw.wiphy->signal_type = CFG80211_SIGNAL_TYPE_UNSPEC; in ieee80211_register_hw()
1079 if (hw->max_signal <= 0) { in ieee80211_register_hw()
1080 result = -EINVAL; in ieee80211_register_hw()
1088 if (!local->ops->set_key) { in ieee80211_register_hw()
1089 wiphy_ext_feature_set(local->hw.wiphy, in ieee80211_register_hw()
1091 wiphy_ext_feature_set(local->hw.wiphy, in ieee80211_register_hw()
1095 if (local->hw.wiphy->interface_modes & BIT(NL80211_IFTYPE_ADHOC)) in ieee80211_register_hw()
1096 wiphy_ext_feature_set(local->hw.wiphy, in ieee80211_register_hw()
1100 * Calculate scan IE length -- we need this to alloc in ieee80211_register_hw()
1103 * information -- SSID is the driver's responsibility. in ieee80211_register_hw()
1105 local->scan_ies_len = 4 + max_bitrates /* (ext) supp rates */ + in ieee80211_register_hw()
1108 local->scan_ies_len += 2 + sizeof(struct ieee80211_ht_cap); in ieee80211_register_hw()
1111 local->scan_ies_len += in ieee80211_register_hw()
1114 /* HE cap element is variable in size - set len to allow max size */ in ieee80211_register_hw()
1121 local->scan_ies_len += in ieee80211_register_hw()
1126 if (!local->ops->hw_scan) { in ieee80211_register_hw()
1128 local->hw.wiphy->max_scan_ssids = 4; in ieee80211_register_hw()
1129 local->hw.wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN; in ieee80211_register_hw()
1139 if (local->hw.wiphy->max_scan_ie_len) in ieee80211_register_hw()
1140 local->hw.wiphy->max_scan_ie_len -= local->scan_ies_len; in ieee80211_register_hw()
1142 WARN_ON(!ieee80211_cs_list_valid(local->hw.cipher_schemes, in ieee80211_register_hw()
1143 local->hw.n_cipher_schemes)); in ieee80211_register_hw()
1145 result = ieee80211_init_cipher_suites(local); in ieee80211_register_hw()
1149 if (!local->ops->remain_on_channel) in ieee80211_register_hw()
1150 local->hw.wiphy->max_remain_on_channel_duration = 5000; in ieee80211_register_hw()
1153 if (local->hw.wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS) in ieee80211_register_hw()
1154 local->hw.wiphy->flags |= WIPHY_FLAG_TDLS_EXTERNAL_SETUP; in ieee80211_register_hw()
1157 if (ieee80211_hw_check(&local->hw, CHANCTX_STA_CSA)) in ieee80211_register_hw()
1158 local->ext_capa[0] |= WLAN_EXT_CAPA1_EXT_CHANNEL_SWITCHING; in ieee80211_register_hw()
1161 if (ieee80211_hw_check(&local->hw, SUPPORTS_MULTI_BSSID)) { in ieee80211_register_hw()
1162 local->hw.wiphy->support_mbssid = true; in ieee80211_register_hw()
1163 if (ieee80211_hw_check(&local->hw, in ieee80211_register_hw()
1165 local->hw.wiphy->support_only_he_mbssid = true; in ieee80211_register_hw()
1167 local->ext_capa[2] |= in ieee80211_register_hw()
1171 local->hw.wiphy->max_num_csa_counters = IEEE80211_MAX_CNTDWN_COUNTERS_NUM; in ieee80211_register_hw()
1177 if (hw->queues > IEEE80211_MAX_QUEUES) in ieee80211_register_hw()
1178 hw->queues = IEEE80211_MAX_QUEUES; in ieee80211_register_hw()
1180 local->workqueue = in ieee80211_register_hw()
1181 alloc_ordered_workqueue("%s", 0, wiphy_name(local->hw.wiphy)); in ieee80211_register_hw()
1182 if (!local->workqueue) { in ieee80211_register_hw()
1183 result = -ENOMEM; in ieee80211_register_hw()
1192 local->tx_headroom = max_t(unsigned int , local->hw.extra_tx_headroom, in ieee80211_register_hw()
1199 if (local->hw.max_listen_interval == 0) in ieee80211_register_hw()
1200 local->hw.max_listen_interval = 5; in ieee80211_register_hw()
1202 local->hw.conf.listen_interval = local->hw.max_listen_interval; in ieee80211_register_hw()
1204 local->dynamic_ps_forced_timeout = -1; in ieee80211_register_hw()
1206 if (!local->hw.max_nan_de_entries) in ieee80211_register_hw()
1207 local->hw.max_nan_de_entries = IEEE80211_MAX_NAN_INSTANCE_ID; in ieee80211_register_hw()
1209 if (!local->hw.weight_multiplier) in ieee80211_register_hw()
1210 local->hw.weight_multiplier = 1; in ieee80211_register_hw()
1212 ieee80211_wep_init(local); in ieee80211_register_hw()
1214 local->hw.conf.flags = IEEE80211_CONF_IDLE; in ieee80211_register_hw()
1216 ieee80211_led_init(local); in ieee80211_register_hw()
1218 result = ieee80211_txq_setup_flows(local); in ieee80211_register_hw()
1223 result = ieee80211_init_rate_ctrl_alg(local, in ieee80211_register_hw()
1224 hw->rate_control_algorithm); in ieee80211_register_hw()
1227 wiphy_debug(local->hw.wiphy, in ieee80211_register_hw()
1232 if (local->rate_ctrl) { in ieee80211_register_hw()
1233 clear_bit(IEEE80211_HW_SUPPORTS_VHT_EXT_NSS_BW, hw->flags); in ieee80211_register_hw()
1234 if (local->rate_ctrl->ops->capa & RATE_CTRL_CAPA_VHT_EXT_NSS_BW) in ieee80211_register_hw()
1246 BUILD_BUG_ON(NUM_NL80211_BANDS > 8 * sizeof(local->sband_allocated)); in ieee80211_register_hw()
1253 sband = local->hw.wiphy->bands[band]; in ieee80211_register_hw()
1254 if (!sband || !sband->vht_cap.vht_supported) in ieee80211_register_hw()
1257 ie_cap = !!(sband->vht_cap.vht_mcs.tx_highest & in ieee80211_register_hw()
1265 result = -ENOMEM; in ieee80211_register_hw()
1269 wiphy_dbg(hw->wiphy, "copying sband (band %d) due to VHT EXT NSS BW flag\n", in ieee80211_register_hw()
1272 sband->vht_cap.vht_mcs.tx_highest ^= in ieee80211_register_hw()
1275 local->hw.wiphy->bands[band] = sband; in ieee80211_register_hw()
1276 local->sband_allocated |= BIT(band); in ieee80211_register_hw()
1279 result = wiphy_register(local->hw.wiphy); in ieee80211_register_hw()
1283 debugfs_hw_add(local); in ieee80211_register_hw()
1284 rate_control_add_debugfs(local); in ieee80211_register_hw()
1289 if (local->hw.wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION) && in ieee80211_register_hw()
1293 result = ieee80211_if_add(local, "wlan%d", NET_NAME_ENUM, NULL, in ieee80211_register_hw()
1296 wiphy_warn(local->hw.wiphy, in ieee80211_register_hw()
1303 local->ifa_notifier.notifier_call = ieee80211_ifa_changed; in ieee80211_register_hw()
1304 result = register_inetaddr_notifier(&local->ifa_notifier); in ieee80211_register_hw()
1310 local->ifa6_notifier.notifier_call = ieee80211_ifa6_changed; in ieee80211_register_hw()
1311 result = register_inet6addr_notifier(&local->ifa6_notifier); in ieee80211_register_hw()
1321 unregister_inetaddr_notifier(&local->ifa_notifier); in ieee80211_register_hw()
1327 wiphy_unregister(local->hw.wiphy); in ieee80211_register_hw()
1330 rate_control_deinitialize(local); in ieee80211_register_hw()
1331 ieee80211_remove_interfaces(local); in ieee80211_register_hw()
1335 ieee80211_led_exit(local); in ieee80211_register_hw()
1336 destroy_workqueue(local->workqueue); in ieee80211_register_hw()
1338 if (local->wiphy_ciphers_allocated) in ieee80211_register_hw()
1339 kfree(local->hw.wiphy->cipher_suites); in ieee80211_register_hw()
1340 kfree(local->int_scan_req); in ieee80211_register_hw()
1347 struct ieee80211_local *local = hw_to_local(hw); in ieee80211_unregister_hw() local
1349 tasklet_kill(&local->tx_pending_tasklet); in ieee80211_unregister_hw()
1350 tasklet_kill(&local->tasklet); in ieee80211_unregister_hw()
1353 unregister_inetaddr_notifier(&local->ifa_notifier); in ieee80211_unregister_hw()
1356 unregister_inet6addr_notifier(&local->ifa6_notifier); in ieee80211_unregister_hw()
1366 ieee80211_remove_interfaces(local); in ieee80211_unregister_hw()
1370 cancel_delayed_work_sync(&local->roc_work); in ieee80211_unregister_hw()
1371 cancel_work_sync(&local->restart_work); in ieee80211_unregister_hw()
1372 cancel_work_sync(&local->reconfig_filter); in ieee80211_unregister_hw()
1373 cancel_work_sync(&local->tdls_chsw_work); in ieee80211_unregister_hw()
1374 flush_work(&local->sched_scan_stopped_work); in ieee80211_unregister_hw()
1375 flush_work(&local->radar_detected_work); in ieee80211_unregister_hw()
1377 ieee80211_clear_tx_pending(local); in ieee80211_unregister_hw()
1378 rate_control_deinitialize(local); in ieee80211_unregister_hw()
1380 if (skb_queue_len(&local->skb_queue) || in ieee80211_unregister_hw()
1381 skb_queue_len(&local->skb_queue_unreliable)) in ieee80211_unregister_hw()
1382 wiphy_warn(local->hw.wiphy, "skb_queue not empty\n"); in ieee80211_unregister_hw()
1383 skb_queue_purge(&local->skb_queue); in ieee80211_unregister_hw()
1384 skb_queue_purge(&local->skb_queue_unreliable); in ieee80211_unregister_hw()
1385 skb_queue_purge(&local->skb_queue_tdls_chsw); in ieee80211_unregister_hw()
1387 wiphy_unregister(local->hw.wiphy); in ieee80211_unregister_hw()
1388 destroy_workqueue(local->workqueue); in ieee80211_unregister_hw()
1389 ieee80211_led_exit(local); in ieee80211_unregister_hw()
1390 kfree(local->int_scan_req); in ieee80211_unregister_hw()
1403 struct ieee80211_local *local = hw_to_local(hw); in ieee80211_free_hw() local
1406 mutex_destroy(&local->iflist_mtx); in ieee80211_free_hw()
1407 mutex_destroy(&local->mtx); in ieee80211_free_hw()
1409 if (local->wiphy_ciphers_allocated) in ieee80211_free_hw()
1410 kfree(local->hw.wiphy->cipher_suites); in ieee80211_free_hw()
1412 idr_for_each(&local->ack_status_frames, in ieee80211_free_hw()
1414 idr_destroy(&local->ack_status_frames); in ieee80211_free_hw()
1416 sta_info_stop(local); in ieee80211_free_hw()
1418 ieee80211_free_led_names(local); in ieee80211_free_hw()
1421 if (!(local->sband_allocated & BIT(band))) in ieee80211_free_hw()
1423 kfree(local->hw.wiphy->bands[band]); in ieee80211_free_hw()
1426 wiphy_free(local->hw.wiphy); in ieee80211_free_hw()
1435 BUILD_BUG_ON(sizeof(struct ieee80211_tx_info) > sizeof(skb->cb)); in ieee80211_init()
1437 IEEE80211_TX_INFO_DRIVER_DATA_SIZE > sizeof(skb->cb)); in ieee80211_init()