Lines Matching +full:ieee80211 +full:- +full:freq +full:- +full:limit

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>
7 * Copyright 2013-2014 Intel Mobile Communications GmbH
8 * Copyright (C) 2015-2017 Intel Deutschland GmbH
9 * Copyright (C) 2018-2021 Intel Corporation
29 #include "driver-ops.h"
44 return &local->hw; in wiphy_to_ieee80211_hw()
51 __le16 fc = hdr->frame_control; in ieee80211_get_bssid()
60 return hdr->addr1; in ieee80211_get_bssid()
62 return hdr->addr2; in ieee80211_get_bssid()
64 return hdr->addr3; in ieee80211_get_bssid()
70 return ext->u.s1g_beacon.sa; in ieee80211_get_bssid()
76 return hdr->addr3; in ieee80211_get_bssid()
81 return hdr->addr1; in ieee80211_get_bssid()
86 return hdr->addr2; in ieee80211_get_bssid()
89 return hdr->addr1; in ieee80211_get_bssid()
105 skb_queue_walk(&tx->skbs, skb) { in ieee80211_tx_set_protected()
106 hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_tx_set_protected()
107 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); in ieee80211_tx_set_protected()
139 * 802.11a - 18.5.2: aSIFSTime = 16 usec in ieee80211_frame_duration()
140 * 802.11g - 19.8.4: aSIFSTime = 10 usec + in ieee80211_frame_duration()
144 dur += 16; /* IEEE 802.11-2012 18.3.2.4: T_PREAMBLE = 16 usec */ in ieee80211_frame_duration()
145 dur += 4; /* IEEE 802.11-2012 18.3.2.4: T_SIGNAL = 4 usec */ in ieee80211_frame_duration()
147 /* IEEE 802.11-2012 18.3.2.4: all values above are: in ieee80211_frame_duration()
193 short_preamble = sdata->vif.bss_conf.use_short_preamble; in ieee80211_generic_frame_duration()
194 if (sdata->flags & IEEE80211_SDATA_OPERATING_GMODE) in ieee80211_generic_frame_duration()
195 erp = rate->flags & IEEE80211_RATE_ERP_G; in ieee80211_generic_frame_duration()
199 dur = ieee80211_frame_duration(band, frame_len, rate->bitrate, erp, in ieee80211_generic_frame_duration()
218 sband = local->hw.wiphy->bands[frame_txctl->band]; in ieee80211_rts_duration()
222 rate = &sband->bitrates[frame_txctl->control.rts_cts_rate_idx]; in ieee80211_rts_duration()
227 short_preamble = sdata->vif.bss_conf.use_short_preamble; in ieee80211_rts_duration()
228 if (sdata->flags & IEEE80211_SDATA_OPERATING_GMODE) in ieee80211_rts_duration()
229 erp = rate->flags & IEEE80211_RATE_ERP_G; in ieee80211_rts_duration()
233 bitrate = DIV_ROUND_UP(rate->bitrate, 1 << shift); in ieee80211_rts_duration()
236 dur = ieee80211_frame_duration(sband->band, 10, bitrate, in ieee80211_rts_duration()
239 dur += ieee80211_frame_duration(sband->band, frame_len, bitrate, in ieee80211_rts_duration()
242 dur += ieee80211_frame_duration(sband->band, 10, bitrate, in ieee80211_rts_duration()
262 sband = local->hw.wiphy->bands[frame_txctl->band]; in ieee80211_ctstoself_duration()
266 rate = &sband->bitrates[frame_txctl->control.rts_cts_rate_idx]; in ieee80211_ctstoself_duration()
270 short_preamble = sdata->vif.bss_conf.use_short_preamble; in ieee80211_ctstoself_duration()
271 if (sdata->flags & IEEE80211_SDATA_OPERATING_GMODE) in ieee80211_ctstoself_duration()
272 erp = rate->flags & IEEE80211_RATE_ERP_G; in ieee80211_ctstoself_duration()
276 bitrate = DIV_ROUND_UP(rate->bitrate, 1 << shift); in ieee80211_ctstoself_duration()
279 dur = ieee80211_frame_duration(sband->band, frame_len, bitrate, in ieee80211_ctstoself_duration()
281 if (!(frame_txctl->flags & IEEE80211_TX_CTL_NO_ACK)) { in ieee80211_ctstoself_duration()
283 dur += ieee80211_frame_duration(sband->band, 10, bitrate, in ieee80211_ctstoself_duration()
293 struct ieee80211_local *local = sdata->local; in __ieee80211_wake_txqs()
294 struct ieee80211_vif *vif = &sdata->vif; in __ieee80211_wake_txqs()
295 struct fq *fq = &local->fq; in __ieee80211_wake_txqs()
302 spin_lock(&fq->lock); in __ieee80211_wake_txqs()
304 if (sdata->vif.type == NL80211_IFTYPE_AP) in __ieee80211_wake_txqs()
305 ps = &sdata->bss->ps; in __ieee80211_wake_txqs()
307 sdata->vif.txqs_stopped[ac] = false; in __ieee80211_wake_txqs()
309 list_for_each_entry_rcu(sta, &local->sta_list, list) { in __ieee80211_wake_txqs()
310 if (sdata != sta->sdata) in __ieee80211_wake_txqs()
313 for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) { in __ieee80211_wake_txqs()
314 struct ieee80211_txq *txq = sta->sta.txq[i]; in __ieee80211_wake_txqs()
321 if (ac != txq->ac) in __ieee80211_wake_txqs()
325 &txqi->flags)) in __ieee80211_wake_txqs()
328 spin_unlock(&fq->lock); in __ieee80211_wake_txqs()
330 spin_lock(&fq->lock); in __ieee80211_wake_txqs()
334 if (!vif->txq) in __ieee80211_wake_txqs()
337 txqi = to_txq_info(vif->txq); in __ieee80211_wake_txqs()
339 if (!test_and_clear_bit(IEEE80211_TXQ_STOP_NETIF_TX, &txqi->flags) || in __ieee80211_wake_txqs()
340 (ps && atomic_read(&ps->num_sta_ps)) || ac != vif->txq->ac) in __ieee80211_wake_txqs()
343 spin_unlock(&fq->lock); in __ieee80211_wake_txqs()
349 spin_unlock(&fq->lock); in __ieee80211_wake_txqs()
354 __releases(&local->queue_stop_reason_lock)
355 __acquires(&local->queue_stop_reason_lock)
364 if (local->hw.queues < IEEE80211_NUM_ACS) in _ieee80211_wake_txqs()
367 for (i = 0; i < local->hw.queues; i++) { in _ieee80211_wake_txqs()
368 if (local->queue_stop_reasons[i]) in _ieee80211_wake_txqs()
371 spin_unlock_irqrestore(&local->queue_stop_reason_lock, *flags); in _ieee80211_wake_txqs()
372 list_for_each_entry_rcu(sdata, &local->interfaces, list) { in _ieee80211_wake_txqs()
376 int ac_queue = sdata->vif.hw_queue[ac]; in _ieee80211_wake_txqs()
379 sdata->vif.cab_queue == i) in _ieee80211_wake_txqs()
383 spin_lock_irqsave(&local->queue_stop_reason_lock, *flags); in _ieee80211_wake_txqs()
395 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_wake_txqs()
397 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_wake_txqs()
405 if (local->ops->wake_tx_queue) in ieee80211_propagate_queue_wake()
408 if (local->hw.queues < IEEE80211_NUM_ACS) in ieee80211_propagate_queue_wake()
411 list_for_each_entry_rcu(sdata, &local->interfaces, list) { in ieee80211_propagate_queue_wake()
414 if (!sdata->dev) in ieee80211_propagate_queue_wake()
417 if (sdata->vif.cab_queue != IEEE80211_INVAL_HW_QUEUE && in ieee80211_propagate_queue_wake()
418 local->queue_stop_reasons[sdata->vif.cab_queue] != 0) in ieee80211_propagate_queue_wake()
422 int ac_queue = sdata->vif.hw_queue[ac]; in ieee80211_propagate_queue_wake()
425 (sdata->vif.cab_queue == queue && in ieee80211_propagate_queue_wake()
426 local->queue_stop_reasons[ac_queue] == 0 && in ieee80211_propagate_queue_wake()
427 skb_queue_empty(&local->pending[ac_queue]))) in ieee80211_propagate_queue_wake()
428 netif_wake_subqueue(sdata->dev, ac); in ieee80211_propagate_queue_wake()
442 if (WARN_ON(queue >= hw->queues)) in __ieee80211_wake_queue()
445 if (!test_bit(reason, &local->queue_stop_reasons[queue])) in __ieee80211_wake_queue()
449 local->q_stop_reasons[queue][reason] = 0; in __ieee80211_wake_queue()
451 local->q_stop_reasons[queue][reason]--; in __ieee80211_wake_queue()
452 if (WARN_ON(local->q_stop_reasons[queue][reason] < 0)) in __ieee80211_wake_queue()
453 local->q_stop_reasons[queue][reason] = 0; in __ieee80211_wake_queue()
456 if (local->q_stop_reasons[queue][reason] == 0) in __ieee80211_wake_queue()
457 __clear_bit(reason, &local->queue_stop_reasons[queue]); in __ieee80211_wake_queue()
459 if (local->queue_stop_reasons[queue] != 0) in __ieee80211_wake_queue()
463 if (skb_queue_empty(&local->pending[queue])) { in __ieee80211_wake_queue()
468 tasklet_schedule(&local->tx_pending_tasklet); in __ieee80211_wake_queue()
477 if (local->ops->wake_tx_queue) { in __ieee80211_wake_queue()
479 tasklet_schedule(&local->wake_txqs_tasklet); in __ieee80211_wake_queue()
492 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_wake_queue_by_reason()
494 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_wake_queue_by_reason()
515 if (WARN_ON(queue >= hw->queues)) in __ieee80211_stop_queue()
519 local->q_stop_reasons[queue][reason] = 1; in __ieee80211_stop_queue()
521 local->q_stop_reasons[queue][reason]++; in __ieee80211_stop_queue()
523 if (__test_and_set_bit(reason, &local->queue_stop_reasons[queue])) in __ieee80211_stop_queue()
526 if (local->hw.queues < IEEE80211_NUM_ACS) in __ieee80211_stop_queue()
530 list_for_each_entry_rcu(sdata, &local->interfaces, list) { in __ieee80211_stop_queue()
533 if (!sdata->dev) in __ieee80211_stop_queue()
537 if (sdata->vif.hw_queue[ac] == queue || in __ieee80211_stop_queue()
538 sdata->vif.cab_queue == queue) { in __ieee80211_stop_queue()
539 if (!local->ops->wake_tx_queue) { in __ieee80211_stop_queue()
540 netif_stop_subqueue(sdata->dev, ac); in __ieee80211_stop_queue()
543 spin_lock(&local->fq.lock); in __ieee80211_stop_queue()
544 sdata->vif.txqs_stopped[ac] = true; in __ieee80211_stop_queue()
545 spin_unlock(&local->fq.lock); in __ieee80211_stop_queue()
559 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_stop_queue_by_reason()
561 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_stop_queue_by_reason()
575 struct ieee80211_hw *hw = &local->hw; in ieee80211_add_pending_skb()
578 int queue = info->hw_queue; in ieee80211_add_pending_skb()
580 if (WARN_ON(!info->control.vif)) { in ieee80211_add_pending_skb()
581 ieee80211_free_txskb(&local->hw, skb); in ieee80211_add_pending_skb()
585 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_add_pending_skb()
588 __skb_queue_tail(&local->pending[queue], skb); in ieee80211_add_pending_skb()
591 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_add_pending_skb()
597 struct ieee80211_hw *hw = &local->hw; in ieee80211_add_pending_skbs()
602 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_add_pending_skbs()
606 if (WARN_ON(!info->control.vif)) { in ieee80211_add_pending_skbs()
607 ieee80211_free_txskb(&local->hw, skb); in ieee80211_add_pending_skbs()
611 queue = info->hw_queue; in ieee80211_add_pending_skbs()
617 __skb_queue_tail(&local->pending[queue], skb); in ieee80211_add_pending_skbs()
620 for (i = 0; i < hw->queues; i++) in ieee80211_add_pending_skbs()
624 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_add_pending_skbs()
636 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_stop_queues_by_reason()
638 for_each_set_bit(i, &queues, hw->queues) in ieee80211_stop_queues_by_reason()
641 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_stop_queues_by_reason()
658 if (WARN_ON(queue >= hw->queues)) in ieee80211_queue_stopped()
661 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_queue_stopped()
663 &local->queue_stop_reasons[queue]); in ieee80211_queue_stopped()
664 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_queue_stopped()
678 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_wake_queues_by_reason()
680 for_each_set_bit(i, &queues, hw->queues) in ieee80211_wake_queues_by_reason()
683 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_wake_queues_by_reason()
700 if (sdata && ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) { in ieee80211_get_vif_queues()
706 queues |= BIT(sdata->vif.hw_queue[ac]); in ieee80211_get_vif_queues()
707 if (sdata->vif.cab_queue != IEEE80211_INVAL_HW_QUEUE) in ieee80211_get_vif_queues()
708 queues |= BIT(sdata->vif.cab_queue); in ieee80211_get_vif_queues()
711 queues = BIT(local->hw.queues) - 1; in ieee80211_get_vif_queues()
721 if (!local->ops->flush) in __ieee80211_flush_queues()
726 * IEEE80211_HW_QUEUE_CONTROL - flush all queues in __ieee80211_flush_queues()
728 if (!queues || !ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) in __ieee80211_flush_queues()
731 ieee80211_stop_queues_by_reason(&local->hw, queues, in __ieee80211_flush_queues()
737 ieee80211_wake_queues_by_reason(&local->hw, queues, in __ieee80211_flush_queues()
752 ieee80211_stop_queues_by_reason(&local->hw, in ieee80211_stop_vif_queues()
761 ieee80211_wake_queues_by_reason(&local->hw, in ieee80211_wake_vif_queues()
775 list_for_each_entry_rcu(sdata, &local->interfaces, list) { in __iterate_interfaces()
776 switch (sdata->vif.type) { in __iterate_interfaces()
778 if (!(sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE)) in __iterate_interfaces()
787 active_only && !(sdata->flags & IEEE80211_SDATA_IN_DRIVER)) in __iterate_interfaces()
790 !(sdata->flags & IEEE80211_SDATA_IN_DRIVER)) in __iterate_interfaces()
793 iterator(data, sdata->vif.addr, in __iterate_interfaces()
794 &sdata->vif); in __iterate_interfaces()
797 sdata = rcu_dereference_check(local->monitor_sdata, in __iterate_interfaces()
798 lockdep_is_held(&local->iflist_mtx) || in __iterate_interfaces()
802 sdata->flags & IEEE80211_SDATA_IN_DRIVER)) in __iterate_interfaces()
803 iterator(data, sdata->vif.addr, &sdata->vif); in __iterate_interfaces()
814 mutex_lock(&local->iflist_mtx); in ieee80211_iterate_interfaces()
816 mutex_unlock(&local->iflist_mtx); in ieee80211_iterate_interfaces()
843 lockdep_assert_wiphy(hw->wiphy); in ieee80211_iterate_active_interfaces_mtx()
857 list_for_each_entry_rcu(sta, &local->sta_list, list) { in __iterate_stations()
858 if (!sta->uploaded) in __iterate_stations()
861 iterator(data, &sta->sta); in __iterate_stations()
883 !(sdata->flags & IEEE80211_SDATA_IN_DRIVER)) in wdev_to_ieee80211_vif()
885 return &sdata->vif; in wdev_to_ieee80211_vif()
894 return &vif_to_sdata(vif)->wdev; in ieee80211_vif_to_wdev()
900 * the suspend->resume cycle. Since we can't check each caller
909 if (local->quiescing || (local->suspended && !local->resuming)) { in ieee80211_can_queue_work()
910 pr_warn("queueing ieee80211 work while going to suspend\n"); in ieee80211_can_queue_work()
924 queue_work(local->workqueue, work); in ieee80211_queue_work()
937 queue_delayed_work(local->workqueue, dwork, delay); in ieee80211_queue_delayed_work()
945 const void *data = elem->data + 1; in ieee80211_parse_extension_element()
946 u8 len = elem->datalen - 1; in ieee80211_parse_extension_element()
948 switch (elem->data[0]) { in ieee80211_parse_extension_element()
950 if (len >= sizeof(*elems->mu_edca_param_set)) { in ieee80211_parse_extension_element()
951 elems->mu_edca_param_set = data; in ieee80211_parse_extension_element()
954 elem->datalen + 2); in ieee80211_parse_extension_element()
958 elems->he_cap = data; in ieee80211_parse_extension_element()
959 elems->he_cap_len = len; in ieee80211_parse_extension_element()
962 if (len >= sizeof(*elems->he_operation) && in ieee80211_parse_extension_element()
963 len >= ieee80211_he_oper_size(data) - 1) { in ieee80211_parse_extension_element()
966 elem->datalen + 2); in ieee80211_parse_extension_element()
967 elems->he_operation = data; in ieee80211_parse_extension_element()
972 elems->uora_element = data; in ieee80211_parse_extension_element()
976 elems->max_channel_switch_time = data; in ieee80211_parse_extension_element()
979 if (len >= sizeof(*elems->mbssid_config_ie)) in ieee80211_parse_extension_element()
980 elems->mbssid_config_ie = data; in ieee80211_parse_extension_element()
983 if (len >= sizeof(*elems->he_spr) && in ieee80211_parse_extension_element()
985 elems->he_spr = data; in ieee80211_parse_extension_element()
988 if (len >= sizeof(*elems->he_6ghz_capa)) in ieee80211_parse_extension_element()
989 elems->he_6ghz_capa = data; in ieee80211_parse_extension_element()
1009 u8 id = elem->id; in _ieee802_11_parse_elems_crc()
1010 u8 elen = elem->datalen; in _ieee802_11_parse_elems_crc()
1011 const u8 *pos = elem->data; in _ieee802_11_parse_elems_crc()
1060 * not listing WLAN_EID_CHANNEL_SWITCH_WRAPPER -- it seems possible in _ieee802_11_parse_elems_crc()
1064 elems->parse_error = true; in _ieee802_11_parse_elems_crc()
1071 crc = crc32_be(crc, pos - 2, elen + 2); in _ieee802_11_parse_elems_crc()
1081 elems->lnk_id = (void *)(pos - 2); in _ieee802_11_parse_elems_crc()
1088 elems->ch_sw_timing = (void *)pos; in _ieee802_11_parse_elems_crc()
1091 elems->ext_capab = pos; in _ieee802_11_parse_elems_crc()
1092 elems->ext_capab_len = elen; in _ieee802_11_parse_elems_crc()
1095 elems->ssid = pos; in _ieee802_11_parse_elems_crc()
1096 elems->ssid_len = elen; in _ieee802_11_parse_elems_crc()
1099 elems->supp_rates = pos; in _ieee802_11_parse_elems_crc()
1100 elems->supp_rates_len = elen; in _ieee802_11_parse_elems_crc()
1104 elems->ds_params = pos; in _ieee802_11_parse_elems_crc()
1110 elems->tim = (void *)pos; in _ieee802_11_parse_elems_crc()
1111 elems->tim_len = elen; in _ieee802_11_parse_elems_crc()
1116 elems->challenge = pos; in _ieee802_11_parse_elems_crc()
1117 elems->challenge_len = elen; in _ieee802_11_parse_elems_crc()
1125 crc = crc32_be(crc, pos - 2, elen + 2); in _ieee802_11_parse_elems_crc()
1128 /* OUI Type 2 - WMM IE */ in _ieee802_11_parse_elems_crc()
1130 elems->wmm_info = pos; in _ieee802_11_parse_elems_crc()
1131 elems->wmm_info_len = elen; in _ieee802_11_parse_elems_crc()
1133 elems->wmm_param = pos; in _ieee802_11_parse_elems_crc()
1134 elems->wmm_param_len = elen; in _ieee802_11_parse_elems_crc()
1140 elems->rsn = pos; in _ieee802_11_parse_elems_crc()
1141 elems->rsn_len = elen; in _ieee802_11_parse_elems_crc()
1145 elems->erp_info = pos; in _ieee802_11_parse_elems_crc()
1150 elems->ext_supp_rates = pos; in _ieee802_11_parse_elems_crc()
1151 elems->ext_supp_rates_len = elen; in _ieee802_11_parse_elems_crc()
1155 elems->ht_cap_elem = (void *)pos; in _ieee802_11_parse_elems_crc()
1161 elems->ht_operation = (void *)pos; in _ieee802_11_parse_elems_crc()
1167 elems->vht_cap_elem = (void *)pos; in _ieee802_11_parse_elems_crc()
1173 elems->vht_operation = (void *)pos; in _ieee802_11_parse_elems_crc()
1175 crc = crc32_be(crc, pos - 2, elen + 2); in _ieee802_11_parse_elems_crc()
1182 elems->opmode_notif = pos; in _ieee802_11_parse_elems_crc()
1184 crc = crc32_be(crc, pos - 2, elen + 2); in _ieee802_11_parse_elems_crc()
1190 elems->mesh_id = pos; in _ieee802_11_parse_elems_crc()
1191 elems->mesh_id_len = elen; in _ieee802_11_parse_elems_crc()
1195 elems->mesh_config = (void *)pos; in _ieee802_11_parse_elems_crc()
1200 elems->peering = pos; in _ieee802_11_parse_elems_crc()
1201 elems->peering_len = elen; in _ieee802_11_parse_elems_crc()
1205 elems->awake_window = (void *)pos; in _ieee802_11_parse_elems_crc()
1208 elems->preq = pos; in _ieee802_11_parse_elems_crc()
1209 elems->preq_len = elen; in _ieee802_11_parse_elems_crc()
1212 elems->prep = pos; in _ieee802_11_parse_elems_crc()
1213 elems->prep_len = elen; in _ieee802_11_parse_elems_crc()
1216 elems->perr = pos; in _ieee802_11_parse_elems_crc()
1217 elems->perr_len = elen; in _ieee802_11_parse_elems_crc()
1221 elems->rann = (void *)pos; in _ieee802_11_parse_elems_crc()
1230 elems->ch_switch_ie = (void *)pos; in _ieee802_11_parse_elems_crc()
1237 elems->ext_chansw_ie = (void *)pos; in _ieee802_11_parse_elems_crc()
1244 elems->sec_chan_offs = (void *)pos; in _ieee802_11_parse_elems_crc()
1248 sizeof(*elems->mesh_chansw_params_ie)) { in _ieee802_11_parse_elems_crc()
1252 elems->mesh_chansw_params_ie = (void *)pos; in _ieee802_11_parse_elems_crc()
1256 elen < sizeof(*elems->wide_bw_chansw_ie)) { in _ieee802_11_parse_elems_crc()
1260 elems->wide_bw_chansw_ie = (void *)pos; in _ieee802_11_parse_elems_crc()
1275 if (ie[1] >= sizeof(*elems->wide_bw_chansw_ie)) in _ieee802_11_parse_elems_crc()
1276 elems->wide_bw_chansw_ie = in _ieee802_11_parse_elems_crc()
1283 elems->country_elem = pos; in _ieee802_11_parse_elems_crc()
1284 elems->country_elem_len = elen; in _ieee802_11_parse_elems_crc()
1291 elems->pwr_constr_elem = pos; in _ieee802_11_parse_elems_crc()
1314 crc = crc32_be(crc, pos - 2, elen + 2); in _ieee802_11_parse_elems_crc()
1316 elems->cisco_dtpc_elem = pos; in _ieee802_11_parse_elems_crc()
1323 elems->addba_ext_ie = (void *)pos; in _ieee802_11_parse_elems_crc()
1327 elems->timeout_int = (void *)pos; in _ieee802_11_parse_elems_crc()
1332 if (elen >= sizeof(*elems->max_idle_period_ie)) in _ieee802_11_parse_elems_crc()
1333 elems->max_idle_period_ie = (void *)pos; in _ieee802_11_parse_elems_crc()
1336 elems->rsnx = pos; in _ieee802_11_parse_elems_crc()
1337 elems->rsnx_len = elen; in _ieee802_11_parse_elems_crc()
1344 if (elems->tx_pwr_env_num >= ARRAY_SIZE(elems->tx_pwr_env)) in _ieee802_11_parse_elems_crc()
1347 elems->tx_pwr_env[elems->tx_pwr_env_num] = (void *)pos; in _ieee802_11_parse_elems_crc()
1348 elems->tx_pwr_env_len[elems->tx_pwr_env_num] = elen; in _ieee802_11_parse_elems_crc()
1349 elems->tx_pwr_env_num++; in _ieee802_11_parse_elems_crc()
1357 if (elen >= sizeof(*elems->s1g_capab)) in _ieee802_11_parse_elems_crc()
1358 elems->s1g_capab = (void *)pos; in _ieee802_11_parse_elems_crc()
1363 if (elen == sizeof(*elems->s1g_oper)) in _ieee802_11_parse_elems_crc()
1364 elems->s1g_oper = (void *)pos; in _ieee802_11_parse_elems_crc()
1369 if (elen == sizeof(*elems->s1g_bcn_compat)) in _ieee802_11_parse_elems_crc()
1370 elems->s1g_bcn_compat = (void *)pos; in _ieee802_11_parse_elems_crc()
1376 elems->aid_resp = (void *)pos; in _ieee802_11_parse_elems_crc()
1385 elems->parse_error = true; in _ieee802_11_parse_elems_crc()
1391 elems->parse_error = true; in _ieee802_11_parse_elems_crc()
1410 if (elem->datalen < 2) in ieee802_11_find_bssid_profile()
1413 for_each_element(sub, elem->data + 1, elem->datalen - 1) { in ieee802_11_find_bssid_profile()
1417 if (sub->id != 0 || sub->datalen < 4) { in ieee802_11_find_bssid_profile()
1422 if (sub->data[0] != WLAN_EID_NON_TX_BSSID_CAP || in ieee802_11_find_bssid_profile()
1423 sub->data[1] != 2) { in ieee802_11_find_bssid_profile()
1449 elem->data[0], in ieee802_11_find_bssid_profile()
1454 elems->bssid_index_len = index[1]; in ieee802_11_find_bssid_profile()
1455 elems->bssid_index = (void *)&index[2]; in ieee802_11_find_bssid_profile()
1474 elems->ie_start = start; in ieee802_11_parse_elems_crc()
1475 elems->total_len = len; in ieee802_11_parse_elems_crc()
1499 if (elems->tim && !elems->parse_error) { in ieee802_11_parse_elems_crc()
1500 const struct ieee80211_tim_ie *tim_ie = elems->tim; in ieee802_11_parse_elems_crc()
1502 elems->dtim_period = tim_ie->dtim_period; in ieee802_11_parse_elems_crc()
1503 elems->dtim_count = tim_ie->dtim_count; in ieee802_11_parse_elems_crc()
1507 if (elems->bssid_index && in ieee802_11_parse_elems_crc()
1508 elems->bssid_index_len >= in ieee802_11_parse_elems_crc()
1510 elems->dtim_period = elems->bssid_index->dtim_period; in ieee802_11_parse_elems_crc()
1512 if (elems->bssid_index && in ieee802_11_parse_elems_crc()
1513 elems->bssid_index_len >= in ieee802_11_parse_elems_crc()
1515 elems->dtim_count = elems->bssid_index->dtim_count; in ieee802_11_parse_elems_crc()
1531 if (sdata->vif.type != NL80211_IFTYPE_AP && in ieee80211_regulatory_limit_wmm_params()
1532 sdata->vif.type != NL80211_IFTYPE_STATION) in ieee80211_regulatory_limit_wmm_params()
1536 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_regulatory_limit_wmm_params()
1538 center_freq = chanctx_conf->def.chan->center_freq; in ieee80211_regulatory_limit_wmm_params()
1545 rrule = freq_reg_info(sdata->wdev.wiphy, MHZ_TO_KHZ(center_freq)); in ieee80211_regulatory_limit_wmm_params()
1547 if (IS_ERR_OR_NULL(rrule) || !rrule->has_wmm) { in ieee80211_regulatory_limit_wmm_params()
1552 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_regulatory_limit_wmm_params()
1553 wmm_ac = &rrule->wmm_rule.ap[ac]; in ieee80211_regulatory_limit_wmm_params()
1555 wmm_ac = &rrule->wmm_rule.client[ac]; in ieee80211_regulatory_limit_wmm_params()
1556 qparam->cw_min = max_t(u16, qparam->cw_min, wmm_ac->cw_min); in ieee80211_regulatory_limit_wmm_params()
1557 qparam->cw_max = max_t(u16, qparam->cw_max, wmm_ac->cw_max); in ieee80211_regulatory_limit_wmm_params()
1558 qparam->aifs = max_t(u8, qparam->aifs, wmm_ac->aifsn); in ieee80211_regulatory_limit_wmm_params()
1559 qparam->txop = min_t(u16, qparam->txop, wmm_ac->cot / 32); in ieee80211_regulatory_limit_wmm_params()
1566 struct ieee80211_local *local = sdata->local; in ieee80211_set_wmm_default()
1574 if (!local->ops->conf_tx) in ieee80211_set_wmm_default()
1577 if (local->hw.queues < IEEE80211_NUM_ACS) in ieee80211_set_wmm_default()
1583 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_set_wmm_default()
1585 chanctx_conf->def.chan->band == NL80211_BAND_2GHZ) && in ieee80211_set_wmm_default()
1586 !(sdata->flags & IEEE80211_SDATA_OPERATING_GMODE); in ieee80211_set_wmm_default()
1589 is_ocb = (sdata->vif.type == NL80211_IFTYPE_OCB); in ieee80211_set_wmm_default()
1591 /* Set defaults according to 802.11-2007 Table 7-37 */ in ieee80211_set_wmm_default()
1630 qparam.cw_min = (aCWmin + 1) / 2 - 1; in ieee80211_set_wmm_default()
1644 qparam.cw_max = (aCWmin + 1) / 2 - 1; in ieee80211_set_wmm_default()
1645 qparam.cw_min = (aCWmin + 1) / 4 - 1; in ieee80211_set_wmm_default()
1660 sdata->tx_conf[ac] = qparam; in ieee80211_set_wmm_default()
1664 if (sdata->vif.type != NL80211_IFTYPE_MONITOR && in ieee80211_set_wmm_default()
1665 sdata->vif.type != NL80211_IFTYPE_P2P_DEVICE && in ieee80211_set_wmm_default()
1666 sdata->vif.type != NL80211_IFTYPE_NAN) { in ieee80211_set_wmm_default()
1667 sdata->vif.bss_conf.qos = enable_qos; in ieee80211_set_wmm_default()
1680 struct ieee80211_local *local = sdata->local; in ieee80211_send_auth()
1686 skb = dev_alloc_skb(local->hw.extra_tx_headroom + IEEE80211_WEP_IV_LEN + in ieee80211_send_auth()
1691 skb_reserve(skb, local->hw.extra_tx_headroom + IEEE80211_WEP_IV_LEN); in ieee80211_send_auth()
1694 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | in ieee80211_send_auth()
1696 memcpy(mgmt->da, da, ETH_ALEN); in ieee80211_send_auth()
1697 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); in ieee80211_send_auth()
1698 memcpy(mgmt->bssid, bssid, ETH_ALEN); in ieee80211_send_auth()
1699 mgmt->u.auth.auth_alg = cpu_to_le16(auth_alg); in ieee80211_send_auth()
1700 mgmt->u.auth.auth_transaction = cpu_to_le16(transaction); in ieee80211_send_auth()
1701 mgmt->u.auth.status_code = cpu_to_le16(status); in ieee80211_send_auth()
1706 mgmt->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); in ieee80211_send_auth()
1714 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT | in ieee80211_send_auth()
1724 struct ieee80211_local *local = sdata->local; in ieee80211_send_deauth_disassoc()
1729 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | stype); in ieee80211_send_deauth_disassoc()
1730 mgmt->duration = 0; /* initialize only */ in ieee80211_send_deauth_disassoc()
1731 mgmt->seq_ctrl = 0; /* initialize only */ in ieee80211_send_deauth_disassoc()
1732 memcpy(mgmt->da, da, ETH_ALEN); in ieee80211_send_deauth_disassoc()
1733 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); in ieee80211_send_deauth_disassoc()
1734 memcpy(mgmt->bssid, bssid, ETH_ALEN); in ieee80211_send_deauth_disassoc()
1736 mgmt->u.deauth.reason_code = cpu_to_le16(reason); in ieee80211_send_deauth_disassoc()
1739 skb = dev_alloc_skb(local->hw.extra_tx_headroom + in ieee80211_send_deauth_disassoc()
1744 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_send_deauth_disassoc()
1749 if (sdata->vif.type != NL80211_IFTYPE_STATION || in ieee80211_send_deauth_disassoc()
1750 !(sdata->u.mgd.flags & IEEE80211_STA_MFP_ENABLED)) in ieee80211_send_deauth_disassoc()
1751 IEEE80211_SKB_CB(skb)->flags |= in ieee80211_send_deauth_disassoc()
1760 if ((end - pos) < 5) in ieee80211_write_he_6ghz_cap()
1779 struct ieee80211_local *local = sdata->local; in ieee80211_build_preq_ies_band()
1794 sband = local->hw.wiphy->bands[band]; in ieee80211_build_preq_ies_band()
1802 for (i = 0; i < sband->n_bitrates; i++) { in ieee80211_build_preq_ies_band()
1805 if ((rate_flags & sband->bitrates[i].flags) != rate_flags) in ieee80211_build_preq_ies_band()
1809 (u8) DIV_ROUND_UP(sband->bitrates[i].bitrate, in ieee80211_build_preq_ies_band()
1815 if (end - pos < 2 + supp_rates_len) in ieee80211_build_preq_ies_band()
1833 if (end - pos < noffset - *offset) in ieee80211_build_preq_ies_band()
1835 memcpy(pos, ie + *offset, noffset - *offset); in ieee80211_build_preq_ies_band()
1836 pos += noffset - *offset; in ieee80211_build_preq_ies_band()
1840 ext_rates_len = num_rates - supp_rates_len; in ieee80211_build_preq_ies_band()
1842 if (end - pos < 2 + ext_rates_len) in ieee80211_build_preq_ies_band()
1850 if (chandef->chan && sband->band == NL80211_BAND_2GHZ) { in ieee80211_build_preq_ies_band()
1851 if (end - pos < 3) in ieee80211_build_preq_ies_band()
1856 chandef->chan->center_freq); in ieee80211_build_preq_ies_band()
1875 if (end - pos < noffset - *offset) in ieee80211_build_preq_ies_band()
1877 memcpy(pos, ie + *offset, noffset - *offset); in ieee80211_build_preq_ies_band()
1878 pos += noffset - *offset; in ieee80211_build_preq_ies_band()
1882 if (sband->ht_cap.ht_supported) { in ieee80211_build_preq_ies_band()
1883 if (end - pos < 2 + sizeof(struct ieee80211_ht_cap)) in ieee80211_build_preq_ies_band()
1885 pos = ieee80211_ie_build_ht_cap(pos, &sband->ht_cap, in ieee80211_build_preq_ies_band()
1886 sband->ht_cap.cap); in ieee80211_build_preq_ies_band()
1902 /* 60 GHz (Multi-band, DMG, MMS) can't happen */ in ieee80211_build_preq_ies_band()
1907 if (end - pos < noffset - *offset) in ieee80211_build_preq_ies_band()
1909 memcpy(pos, ie + *offset, noffset - *offset); in ieee80211_build_preq_ies_band()
1910 pos += noffset - *offset; in ieee80211_build_preq_ies_band()
1915 for (i = 0; i < sband->n_channels; i++) { in ieee80211_build_preq_ies_band()
1916 if (sband->channels[i].flags & (IEEE80211_CHAN_DISABLED | in ieee80211_build_preq_ies_band()
1924 if (sband->vht_cap.vht_supported && have_80mhz) { in ieee80211_build_preq_ies_band()
1925 if (end - pos < 2 + sizeof(struct ieee80211_vht_cap)) in ieee80211_build_preq_ies_band()
1927 pos = ieee80211_ie_build_vht_cap(pos, &sband->vht_cap, in ieee80211_build_preq_ies_band()
1928 sband->vht_cap.cap); in ieee80211_build_preq_ies_band()
1945 if (end - pos < noffset - *offset) in ieee80211_build_preq_ies_band()
1947 memcpy(pos, ie + *offset, noffset - *offset); in ieee80211_build_preq_ies_band()
1948 pos += noffset - *offset; in ieee80211_build_preq_ies_band()
1953 ieee80211_vif_type_p2p(&sdata->vif)); in ieee80211_build_preq_ies_band()
1955 cfg80211_any_usable_channels(local->hw.wiphy, BIT(sband->band), in ieee80211_build_preq_ies_band()
1962 if (cfg80211_any_usable_channels(local->hw.wiphy, in ieee80211_build_preq_ies_band()
1967 sband6 = local->hw.wiphy->bands[NL80211_BAND_6GHZ]; in ieee80211_build_preq_ies_band()
1969 ieee80211_vif_type_p2p(&sdata->vif)); in ieee80211_build_preq_ies_band()
1973 ieee80211_vif_type_p2p(&sdata->vif); in ieee80211_build_preq_ies_band()
1982 * that calculates local->scan_ies_len. in ieee80211_build_preq_ies_band()
1985 return pos - buffer; in ieee80211_build_preq_ies_band()
1989 return pos - buffer; in ieee80211_build_preq_ies_band()
2009 buffer_len - pos, in ieee80211_build_preq_ies()
2015 ie_desc->ies[i] = buffer + old_pos; in ieee80211_build_preq_ies()
2016 ie_desc->len[i] = pos - old_pos; in ieee80211_build_preq_ies()
2023 if (WARN_ONCE(buffer_len - pos < ie_len - custom_ie_offset, in ieee80211_build_preq_ies()
2027 ie_len - custom_ie_offset); in ieee80211_build_preq_ies()
2028 ie_desc->common_ies = buffer + pos; in ieee80211_build_preq_ies()
2029 ie_desc->common_ie_len = ie_len - custom_ie_offset; in ieee80211_build_preq_ies()
2030 pos += ie_len - custom_ie_offset; in ieee80211_build_preq_ies()
2044 struct ieee80211_local *local = sdata->local; in ieee80211_build_probe_req()
2055 * badly-behaved APs don't respond when this parameter is included. in ieee80211_build_probe_req()
2057 chandef.width = sdata->vif.bss_conf.chandef.width; in ieee80211_build_probe_req()
2063 skb = ieee80211_probereq_get(&local->hw, src, ssid, ssid_len, in ieee80211_build_probe_req()
2068 rate_masks[chan->band] = ratemask; in ieee80211_build_probe_req()
2071 ie, ie_len, BIT(chan->band), in ieee80211_build_probe_req()
2076 mgmt = (struct ieee80211_mgmt *) skb->data; in ieee80211_build_probe_req()
2077 memcpy(mgmt->da, dst, ETH_ALEN); in ieee80211_build_probe_req()
2078 memcpy(mgmt->bssid, dst, ETH_ALEN); in ieee80211_build_probe_req()
2081 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; in ieee80211_build_probe_req()
2095 sband = sdata->local->hw.wiphy->bands[band]; in ieee80211_sta_get_rates()
2099 rate_flags = ieee80211_chandef_rate_flags(&sdata->vif.bss_conf.chandef); in ieee80211_sta_get_rates()
2100 shift = ieee80211_vif_get_shift(&sdata->vif); in ieee80211_sta_get_rates()
2102 num_rates = sband->n_bitrates; in ieee80211_sta_get_rates()
2104 for (i = 0; i < elems->supp_rates_len + in ieee80211_sta_get_rates()
2105 elems->ext_supp_rates_len; i++) { in ieee80211_sta_get_rates()
2109 if (i < elems->supp_rates_len) in ieee80211_sta_get_rates()
2110 rate = elems->supp_rates[i]; in ieee80211_sta_get_rates()
2111 else if (elems->ext_supp_rates) in ieee80211_sta_get_rates()
2112 rate = elems->ext_supp_rates in ieee80211_sta_get_rates()
2113 [i - elems->supp_rates_len]; in ieee80211_sta_get_rates()
2122 if ((rate_flags & sband->bitrates[j].flags) in ieee80211_sta_get_rates()
2126 brate = DIV_ROUND_UP(sband->bitrates[j].bitrate, in ieee80211_sta_get_rates()
2144 cancel_work_sync(&local->reconfig_filter); in ieee80211_stop_device()
2146 flush_workqueue(local->workqueue); in ieee80211_stop_device()
2160 if (test_bit(SCAN_COMPLETED, &local->scanning)) { in ieee80211_flush_completed_scan()
2162 * we don't attempt to continue a partial HW scan - which is in ieee80211_flush_completed_scan()
2167 set_bit(SCAN_ABORTED, &local->scanning); in ieee80211_flush_completed_scan()
2168 ieee80211_queue_delayed_work(&local->hw, &local->scan_work, 0); in ieee80211_flush_completed_scan()
2169 flush_delayed_work(&local->scan_work); in ieee80211_flush_completed_scan()
2188 local->resuming = false; in ieee80211_handle_reconfig_failure()
2189 local->suspended = false; in ieee80211_handle_reconfig_failure()
2190 local->in_reconfig = false; in ieee80211_handle_reconfig_failure()
2199 list_for_each_entry(sdata, &local->interfaces, list) in ieee80211_handle_reconfig_failure()
2200 sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER; in ieee80211_handle_reconfig_failure()
2205 mutex_lock(&local->chanctx_mtx); in ieee80211_handle_reconfig_failure()
2206 list_for_each_entry(ctx, &local->chanctx_list, list) in ieee80211_handle_reconfig_failure()
2207 ctx->driver_present = false; in ieee80211_handle_reconfig_failure()
2208 mutex_unlock(&local->chanctx_mtx); in ieee80211_handle_reconfig_failure()
2217 if (!local->use_chanctx) in ieee80211_assign_chanctx()
2220 mutex_lock(&local->chanctx_mtx); in ieee80211_assign_chanctx()
2221 conf = rcu_dereference_protected(sdata->vif.chanctx_conf, in ieee80211_assign_chanctx()
2222 lockdep_is_held(&local->chanctx_mtx)); in ieee80211_assign_chanctx()
2227 mutex_unlock(&local->chanctx_mtx); in ieee80211_assign_chanctx()
2232 struct ieee80211_local *local = sdata->local; in ieee80211_reconfig_stations()
2236 mutex_lock(&local->sta_mtx); in ieee80211_reconfig_stations()
2237 list_for_each_entry(sta, &local->sta_list, list) { in ieee80211_reconfig_stations()
2240 if (!sta->uploaded || sta->sdata != sdata) in ieee80211_reconfig_stations()
2244 state < sta->sta_state; state++) in ieee80211_reconfig_stations()
2245 WARN_ON(drv_sta_state(local, sta->sdata, sta, state, in ieee80211_reconfig_stations()
2248 mutex_unlock(&local->sta_mtx); in ieee80211_reconfig_stations()
2256 res = drv_start_nan(sdata->local, sdata, in ieee80211_reconfig_nan()
2257 &sdata->u.nan.conf); in ieee80211_reconfig_nan()
2261 funcs = kcalloc(sdata->local->hw.max_nan_de_entries + 1, in ieee80211_reconfig_nan()
2265 return -ENOMEM; in ieee80211_reconfig_nan()
2271 spin_lock_bh(&sdata->u.nan.func_lock); in ieee80211_reconfig_nan()
2273 idr_for_each_entry(&sdata->u.nan.function_inst_ids, func, id) in ieee80211_reconfig_nan()
2276 spin_unlock_bh(&sdata->u.nan.func_lock); in ieee80211_reconfig_nan()
2279 res = drv_add_nan_func(sdata->local, sdata, funcs[i]); in ieee80211_reconfig_nan()
2281 ieee80211_nan_func_terminated(&sdata->vif, in ieee80211_reconfig_nan()
2282 funcs[i]->instance_id, in ieee80211_reconfig_nan()
2294 struct ieee80211_hw *hw = &local->hw; in ieee80211_reconfig()
2303 bool suspended = local->suspended; in ieee80211_reconfig()
2306 if (!local->open_count) in ieee80211_reconfig()
2311 local->resuming = true; in ieee80211_reconfig()
2313 if (local->wowlan) { in ieee80211_reconfig()
2317 * clear local->suspended so the device could operate in ieee80211_reconfig()
2320 local->suspended = false; in ieee80211_reconfig()
2322 local->wowlan = false; in ieee80211_reconfig()
2324 local->resuming = false; in ieee80211_reconfig()
2333 * restore local->suspended in this case. in ieee80211_reconfig()
2336 local->suspended = true; in ieee80211_reconfig()
2347 if (suspended && local->in_reconfig && !reconfig_due_to_wowlan) in ieee80211_reconfig()
2348 cancel_work_sync(&local->restart_work); in ieee80211_reconfig()
2350 local->started = false; in ieee80211_reconfig()
2369 drv_set_frag_threshold(local, hw->wiphy->frag_threshold); in ieee80211_reconfig()
2372 drv_set_rts_threshold(local, hw->wiphy->rts_threshold); in ieee80211_reconfig()
2375 drv_set_coverage_class(local, hw->wiphy->coverage_class); in ieee80211_reconfig()
2382 sdata = rtnl_dereference(local->monitor_sdata); in ieee80211_reconfig()
2385 WARN_ON(local->resuming); in ieee80211_reconfig()
2388 RCU_INIT_POINTER(local->monitor_sdata, NULL); in ieee80211_reconfig()
2394 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_reconfig()
2395 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN && in ieee80211_reconfig()
2396 sdata->vif.type != NL80211_IFTYPE_MONITOR && in ieee80211_reconfig()
2408 list_for_each_entry_continue_reverse(sdata, &local->interfaces, in ieee80211_reconfig()
2410 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN && in ieee80211_reconfig()
2411 sdata->vif.type != NL80211_IFTYPE_MONITOR && in ieee80211_reconfig()
2419 if (local->use_chanctx) { in ieee80211_reconfig()
2420 mutex_lock(&local->chanctx_mtx); in ieee80211_reconfig()
2421 list_for_each_entry(ctx, &local->chanctx_list, list) in ieee80211_reconfig()
2422 if (ctx->replace_state != in ieee80211_reconfig()
2425 mutex_unlock(&local->chanctx_mtx); in ieee80211_reconfig()
2427 sdata = rtnl_dereference(local->monitor_sdata); in ieee80211_reconfig()
2438 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_reconfig()
2446 switch (sdata->vif.type) { in ieee80211_reconfig()
2451 if (sdata->vif.bss_conf.ibss_joined) in ieee80211_reconfig()
2460 &sdata->tx_conf[i]); in ieee80211_reconfig()
2478 if (sdata->vif.mu_mimo_owner) in ieee80211_reconfig()
2481 switch (sdata->vif.type) { in ieee80211_reconfig()
2487 /* Re-send beacon info report to the driver */ in ieee80211_reconfig()
2488 if (sdata->u.mgd.have_beacon) in ieee80211_reconfig()
2491 if (sdata->vif.bss_conf.max_idle_period || in ieee80211_reconfig()
2492 sdata->vif.bss_conf.protected_keep_alive) in ieee80211_reconfig()
2509 if (sdata->vif.bss_conf.ftm_responder == 1 && in ieee80211_reconfig()
2510 wiphy_ext_feature_isset(sdata->local->hw.wiphy, in ieee80211_reconfig()
2514 if (sdata->vif.type == NL80211_IFTYPE_AP) { in ieee80211_reconfig()
2517 if (rcu_access_pointer(sdata->u.ap.beacon)) in ieee80211_reconfig()
2522 if (sdata->vif.bss_conf.enable_beacon) { in ieee80211_reconfig()
2558 if (!(local->hw.conf.flags & IEEE80211_CONF_PS)) { in ieee80211_reconfig()
2559 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_reconfig()
2560 if (sdata->vif.type != NL80211_IFTYPE_STATION) in ieee80211_reconfig()
2562 if (!sdata->u.mgd.associated) in ieee80211_reconfig()
2570 mutex_lock(&local->sta_mtx); in ieee80211_reconfig()
2571 list_for_each_entry(sta, &local->sta_list, list) { in ieee80211_reconfig()
2574 if (!sta->uploaded) in ieee80211_reconfig()
2577 if (sta->sdata->vif.type != NL80211_IFTYPE_AP && in ieee80211_reconfig()
2578 sta->sdata->vif.type != NL80211_IFTYPE_AP_VLAN) in ieee80211_reconfig()
2582 state < sta->sta_state; state++) in ieee80211_reconfig()
2583 WARN_ON(drv_sta_state(local, sta->sdata, sta, state, in ieee80211_reconfig()
2586 mutex_unlock(&local->sta_mtx); in ieee80211_reconfig()
2589 list_for_each_entry(sdata, &local->interfaces, list) in ieee80211_reconfig()
2593 mutex_lock(&local->mtx); in ieee80211_reconfig()
2594 sched_scan_sdata = rcu_dereference_protected(local->sched_scan_sdata, in ieee80211_reconfig()
2595 lockdep_is_held(&local->mtx)); in ieee80211_reconfig()
2596 sched_scan_req = rcu_dereference_protected(local->sched_scan_req, in ieee80211_reconfig()
2597 lockdep_is_held(&local->mtx)); in ieee80211_reconfig()
2606 if (sched_scan_req->n_scan_plans > 1 || in ieee80211_reconfig()
2609 RCU_INIT_POINTER(local->sched_scan_sdata, NULL); in ieee80211_reconfig()
2610 RCU_INIT_POINTER(local->sched_scan_req, NULL); in ieee80211_reconfig()
2613 mutex_unlock(&local->mtx); in ieee80211_reconfig()
2616 cfg80211_sched_scan_stopped_locked(local->hw.wiphy, 0); in ieee80211_reconfig()
2620 if (local->monitors == local->open_count && local->monitors > 0) in ieee80211_reconfig()
2634 mutex_lock(&local->sta_mtx); in ieee80211_reconfig()
2636 list_for_each_entry(sta, &local->sta_list, list) { in ieee80211_reconfig()
2637 if (!local->resuming) in ieee80211_reconfig()
2643 mutex_unlock(&local->sta_mtx); in ieee80211_reconfig()
2646 if (local->in_reconfig) { in ieee80211_reconfig()
2647 local->in_reconfig = false; in ieee80211_reconfig()
2651 mutex_lock(&local->mtx); in ieee80211_reconfig()
2653 mutex_unlock(&local->mtx); in ieee80211_reconfig()
2656 list_for_each_entry(sdata, &local->interfaces, list) in ieee80211_reconfig()
2657 ieee80211_queue_work(&local->hw, &sdata->work); in ieee80211_reconfig()
2668 if (local->open_count && (!suspended || reconfig_due_to_wowlan)) in ieee80211_reconfig()
2676 local->suspended = false; in ieee80211_reconfig()
2678 local->resuming = false; in ieee80211_reconfig()
2682 if (local->open_count && !reconfig_due_to_wowlan) in ieee80211_reconfig()
2685 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_reconfig()
2688 if (sdata->vif.type == NL80211_IFTYPE_STATION) in ieee80211_reconfig()
2692 mod_timer(&local->sta_cleanup, jiffies + 1); in ieee80211_reconfig()
2710 local = sdata->local; in ieee80211_resume_disconnect()
2712 if (WARN_ON(!local->resuming)) in ieee80211_resume_disconnect()
2715 if (WARN_ON(vif->type != NL80211_IFTYPE_STATION)) in ieee80211_resume_disconnect()
2718 sdata->flags |= IEEE80211_SDATA_DISCONNECT_RESUME; in ieee80211_resume_disconnect()
2720 mutex_lock(&local->key_mtx); in ieee80211_resume_disconnect()
2721 list_for_each_entry(key, &sdata->key_list, list) in ieee80211_resume_disconnect()
2722 key->flags |= KEY_FLAG_TAINTED; in ieee80211_resume_disconnect()
2723 mutex_unlock(&local->key_mtx); in ieee80211_resume_disconnect()
2729 struct ieee80211_local *local = sdata->local; in ieee80211_recalc_smps()
2733 mutex_lock(&local->chanctx_mtx); in ieee80211_recalc_smps()
2735 chanctx_conf = rcu_dereference_protected(sdata->vif.chanctx_conf, in ieee80211_recalc_smps()
2736 lockdep_is_held(&local->chanctx_mtx)); in ieee80211_recalc_smps()
2750 mutex_unlock(&local->chanctx_mtx); in ieee80211_recalc_smps()
2755 struct ieee80211_local *local = sdata->local; in ieee80211_recalc_min_chandef()
2759 mutex_lock(&local->chanctx_mtx); in ieee80211_recalc_min_chandef()
2761 chanctx_conf = rcu_dereference_protected(sdata->vif.chanctx_conf, in ieee80211_recalc_min_chandef()
2762 lockdep_is_held(&local->chanctx_mtx)); in ieee80211_recalc_min_chandef()
2770 mutex_unlock(&local->chanctx_mtx); in ieee80211_recalc_min_chandef()
2789 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION)) in _ieee80211_enable_rssi_reports()
2797 sdata->u.mgd.rssi_min_thold = rssi_min_thold*16; in _ieee80211_enable_rssi_reports()
2798 sdata->u.mgd.rssi_max_thold = rssi_max_thold*16; in _ieee80211_enable_rssi_reports()
2838 *pos++ = ht_cap->ampdu_factor | in ieee80211_ie_build_ht_cap()
2839 (ht_cap->ampdu_density << in ieee80211_ie_build_ht_cap()
2843 memcpy(pos, &ht_cap->mcs, sizeof(ht_cap->mcs)); in ieee80211_ie_build_ht_cap()
2844 pos += sizeof(ht_cap->mcs); in ieee80211_ie_build_ht_cap()
2873 memcpy(pos, &vht_cap->vht_mcs, sizeof(vht_cap->vht_mcs)); in ieee80211_ie_build_vht_cap()
2874 pos += sizeof(vht_cap->vht_mcs); in ieee80211_ie_build_vht_cap()
2893 n = ieee80211_he_mcs_nss_size(&he_cap->he_cap_elem); in ieee80211_ie_len_he_cap()
2895 sizeof(he_cap->he_cap_elem) + n + in ieee80211_ie_len_he_cap()
2896 ieee80211_he_ppe_size(he_cap->ppe_thres[0], in ieee80211_ie_len_he_cap()
2897 he_cap->he_cap_elem.phy_cap_info); in ieee80211_ie_len_he_cap()
2916 n = ieee80211_he_mcs_nss_size(&he_cap->he_cap_elem); in ieee80211_ie_build_he_cap()
2918 sizeof(he_cap->he_cap_elem) + n + in ieee80211_ie_build_he_cap()
2919 ieee80211_he_ppe_size(he_cap->ppe_thres[0], in ieee80211_ie_build_he_cap()
2920 he_cap->he_cap_elem.phy_cap_info); in ieee80211_ie_build_he_cap()
2922 if ((end - pos) < ie_len) in ieee80211_ie_build_he_cap()
2930 memcpy(pos, &he_cap->he_cap_elem, sizeof(he_cap->he_cap_elem)); in ieee80211_ie_build_he_cap()
2931 pos += sizeof(he_cap->he_cap_elem); in ieee80211_ie_build_he_cap()
2933 memcpy(pos, &he_cap->he_mcs_nss_supp, n); in ieee80211_ie_build_he_cap()
2937 if ((he_cap->he_cap_elem.phy_cap_info[6] & in ieee80211_ie_build_he_cap()
2945 n = hweight8(he_cap->ppe_thres[0] & in ieee80211_ie_build_he_cap()
2947 n *= (1 + ((he_cap->ppe_thres[0] & IEEE80211_PPE_THRES_NSS_MASK) >> in ieee80211_ie_build_he_cap()
2958 memcpy(pos, &he_cap->ppe_thres, n); in ieee80211_ie_build_he_cap()
2962 orig_pos[1] = (pos - orig_pos) - 2; in ieee80211_ie_build_he_cap()
2971 enum nl80211_iftype iftype = ieee80211_vif_type_p2p(&sdata->vif); in ieee80211_ie_build_he_6ghz_cap()
2975 if (!cfg80211_any_usable_channels(sdata->local->hw.wiphy, in ieee80211_ie_build_he_6ghz_cap()
2980 sband = sdata->local->hw.wiphy->bands[NL80211_BAND_6GHZ]; in ieee80211_ie_build_he_6ghz_cap()
2987 if (!iftd->he_6ghz_capa.capa) in ieee80211_ie_build_he_6ghz_cap()
2990 cap = le16_to_cpu(iftd->he_6ghz_capa.capa); in ieee80211_ie_build_he_6ghz_cap()
2993 switch (sdata->smps_mode) { in ieee80211_ie_build_he_6ghz_cap()
3026 ht_oper->primary_chan = ieee80211_frequency_to_channel( in ieee80211_ie_build_ht_oper()
3027 chandef->chan->center_freq); in ieee80211_ie_build_ht_oper()
3028 switch (chandef->width) { in ieee80211_ie_build_ht_oper()
3033 if (chandef->center_freq1 > chandef->chan->center_freq) in ieee80211_ie_build_ht_oper()
3034 ht_oper->ht_param = IEEE80211_HT_PARAM_CHA_SEC_ABOVE; in ieee80211_ie_build_ht_oper()
3036 ht_oper->ht_param = IEEE80211_HT_PARAM_CHA_SEC_BELOW; in ieee80211_ie_build_ht_oper()
3039 ht_oper->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE; in ieee80211_ie_build_ht_oper()
3042 if (ht_cap->cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40 && in ieee80211_ie_build_ht_oper()
3043 chandef->width != NL80211_CHAN_WIDTH_20_NOHT && in ieee80211_ie_build_ht_oper()
3044 chandef->width != NL80211_CHAN_WIDTH_20) in ieee80211_ie_build_ht_oper()
3045 ht_oper->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY; in ieee80211_ie_build_ht_oper()
3048 ht_oper->ht_param |= IEEE80211_HT_PARAM_RIFS_MODE; in ieee80211_ie_build_ht_oper()
3050 ht_oper->operation_mode = cpu_to_le16(prot_mode); in ieee80211_ie_build_ht_oper()
3051 ht_oper->stbc_param = 0x0000; in ieee80211_ie_build_ht_oper()
3055 memset(&ht_oper->basic_set, 0, 16); in ieee80211_ie_build_ht_oper()
3056 memcpy(&ht_oper->basic_set, &ht_cap->mcs, 10); in ieee80211_ie_build_ht_oper()
3067 switch (chandef->width) { in ieee80211_ie_build_wide_bw_cs()
3082 *pos++ = ieee80211_frequency_to_channel(chandef->center_freq1); in ieee80211_ie_build_wide_bw_cs()
3084 if (chandef->center_freq2) in ieee80211_ie_build_wide_bw_cs()
3085 *pos++ = ieee80211_frequency_to_channel(chandef->center_freq2); in ieee80211_ie_build_wide_bw_cs()
3098 vht_oper->center_freq_seg0_idx = ieee80211_frequency_to_channel( in ieee80211_ie_build_vht_oper()
3099 chandef->center_freq1); in ieee80211_ie_build_vht_oper()
3100 if (chandef->center_freq2) in ieee80211_ie_build_vht_oper()
3101 vht_oper->center_freq_seg1_idx = in ieee80211_ie_build_vht_oper()
3102 ieee80211_frequency_to_channel(chandef->center_freq2); in ieee80211_ie_build_vht_oper()
3104 vht_oper->center_freq_seg1_idx = 0x00; in ieee80211_ie_build_vht_oper()
3106 switch (chandef->width) { in ieee80211_ie_build_vht_oper()
3112 vht_oper->chan_width = IEEE80211_VHT_CHANWIDTH_80MHZ; in ieee80211_ie_build_vht_oper()
3113 vht_oper->center_freq_seg1_idx = vht_oper->center_freq_seg0_idx; in ieee80211_ie_build_vht_oper()
3114 if (chandef->chan->center_freq < chandef->center_freq1) in ieee80211_ie_build_vht_oper()
3115 vht_oper->center_freq_seg0_idx -= 8; in ieee80211_ie_build_vht_oper()
3117 vht_oper->center_freq_seg0_idx += 8; in ieee80211_ie_build_vht_oper()
3124 vht_oper->chan_width = IEEE80211_VHT_CHANWIDTH_80MHZ; in ieee80211_ie_build_vht_oper()
3127 vht_oper->chan_width = IEEE80211_VHT_CHANWIDTH_80MHZ; in ieee80211_ie_build_vht_oper()
3130 vht_oper->chan_width = IEEE80211_VHT_CHANWIDTH_USE_HT; in ieee80211_ie_build_vht_oper()
3135 vht_oper->basic_mcs_set = cpu_to_le16(0xffff); in ieee80211_ie_build_vht_oper()
3147 if (chandef->chan->band == NL80211_BAND_6GHZ) in ieee80211_ie_build_he_oper()
3161 if (chandef->chan->band == NL80211_BAND_6GHZ) in ieee80211_ie_build_he_oper()
3166 he_oper->he_oper_params = cpu_to_le32(he_oper_params); in ieee80211_ie_build_he_oper()
3169 he_oper->he_mcs_nss_set = cpu_to_le16(0xffff); in ieee80211_ie_build_he_oper()
3172 if (chandef->chan->band != NL80211_BAND_6GHZ) in ieee80211_ie_build_he_oper()
3177 he_6ghz_op->minrate = 6; /* 6 Mbps */ in ieee80211_ie_build_he_oper()
3178 he_6ghz_op->primary = in ieee80211_ie_build_he_oper()
3179 ieee80211_frequency_to_channel(chandef->chan->center_freq); in ieee80211_ie_build_he_oper()
3180 he_6ghz_op->ccfs0 = in ieee80211_ie_build_he_oper()
3181 ieee80211_frequency_to_channel(chandef->center_freq1); in ieee80211_ie_build_he_oper()
3182 if (chandef->center_freq2) in ieee80211_ie_build_he_oper()
3183 he_6ghz_op->ccfs1 = in ieee80211_ie_build_he_oper()
3184 ieee80211_frequency_to_channel(chandef->center_freq2); in ieee80211_ie_build_he_oper()
3186 he_6ghz_op->ccfs1 = 0; in ieee80211_ie_build_he_oper()
3188 switch (chandef->width) { in ieee80211_ie_build_he_oper()
3193 he_6ghz_op->control = in ieee80211_ie_build_he_oper()
3195 he_6ghz_op->ccfs1 = he_6ghz_op->ccfs0; in ieee80211_ie_build_he_oper()
3196 if (chandef->chan->center_freq < chandef->center_freq1) in ieee80211_ie_build_he_oper()
3197 he_6ghz_op->ccfs0 -= 8; in ieee80211_ie_build_he_oper()
3199 he_6ghz_op->ccfs0 += 8; in ieee80211_ie_build_he_oper()
3202 he_6ghz_op->control = in ieee80211_ie_build_he_oper()
3206 he_6ghz_op->control = in ieee80211_ie_build_he_oper()
3210 he_6ghz_op->control = in ieee80211_ie_build_he_oper()
3214 he_6ghz_op->control = in ieee80211_ie_build_he_oper()
3233 switch (ht_oper->ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET) { in ieee80211_chandef_ht_oper()
3248 cfg80211_chandef_create(chandef, chandef->chan, channel_type); in ieee80211_chandef_ht_oper()
3272 vht_cap = hw->wiphy->bands[chandef->chan->band]->vht_cap.cap; in ieee80211_chandef_vht_oper()
3281 ccfs0 = oper->center_freq_seg0_idx; in ieee80211_chandef_vht_oper()
3282 ccfs1 = oper->center_freq_seg1_idx; in ieee80211_chandef_vht_oper()
3283 ccfs2 = (le16_to_cpu(htop->operation_mode) & in ieee80211_chandef_vht_oper()
3294 * Cf. IEEE 802.11 Table 9-250 in ieee80211_chandef_vht_oper()
3330 cf0 = ieee80211_channel_to_frequency(ccf0, chandef->chan->band); in ieee80211_chandef_vht_oper()
3331 cf1 = ieee80211_channel_to_frequency(ccf1, chandef->chan->band); in ieee80211_chandef_vht_oper()
3333 switch (oper->chan_width) { in ieee80211_chandef_vht_oper()
3344 diff = abs(ccf1 - ccf0); in ieee80211_chandef_vht_oper()
3380 struct ieee80211_local *local = sdata->local; in ieee80211_chandef_he_6ghz_oper()
3382 enum nl80211_iftype iftype = ieee80211_vif_type_p2p(&sdata->vif); in ieee80211_chandef_he_6ghz_oper()
3388 u32 freq; in ieee80211_chandef_he_6ghz_oper() local
3390 if (chandef->chan->band != NL80211_BAND_6GHZ) in ieee80211_chandef_he_6ghz_oper()
3393 sband = local->hw.wiphy->bands[NL80211_BAND_6GHZ]; in ieee80211_chandef_he_6ghz_oper()
3401 he_phy_cap = he_cap->he_cap_elem.phy_cap_info[0]; in ieee80211_chandef_he_6ghz_oper()
3412 chandef->chan->center_freq); in ieee80211_chandef_he_6ghz_oper()
3421 chandef->chan->center_freq); in ieee80211_chandef_he_6ghz_oper()
3425 freq = ieee80211_channel_to_frequency(he_6ghz_oper->primary, in ieee80211_chandef_he_6ghz_oper()
3427 he_chandef.chan = ieee80211_get_channel(sdata->local->hw.wiphy, freq); in ieee80211_chandef_he_6ghz_oper()
3429 switch (u8_get_bits(he_6ghz_oper->control, in ieee80211_chandef_he_6ghz_oper()
3442 if (!he_6ghz_oper->ccfs1) in ieee80211_chandef_he_6ghz_oper()
3444 if (abs(he_6ghz_oper->ccfs1 - he_6ghz_oper->ccfs0) == 8) { in ieee80211_chandef_he_6ghz_oper()
3456 ieee80211_channel_to_frequency(he_6ghz_oper->ccfs1, in ieee80211_chandef_he_6ghz_oper()
3460 ieee80211_channel_to_frequency(he_6ghz_oper->ccfs0, in ieee80211_chandef_he_6ghz_oper()
3464 ieee80211_channel_to_frequency(he_6ghz_oper->ccfs1, in ieee80211_chandef_he_6ghz_oper()
3471 he_chandef.chan ? he_chandef.chan->center_freq : 0, in ieee80211_chandef_he_6ghz_oper()
3491 switch (FIELD_GET(S1G_OPER_CH_WIDTH_OPER, oper->ch_width)) { in ieee80211_chandef_s1g_oper()
3493 chandef->width = NL80211_CHAN_WIDTH_1; in ieee80211_chandef_s1g_oper()
3496 chandef->width = NL80211_CHAN_WIDTH_2; in ieee80211_chandef_s1g_oper()
3499 chandef->width = NL80211_CHAN_WIDTH_4; in ieee80211_chandef_s1g_oper()
3502 chandef->width = NL80211_CHAN_WIDTH_8; in ieee80211_chandef_s1g_oper()
3505 chandef->width = NL80211_CHAN_WIDTH_16; in ieee80211_chandef_s1g_oper()
3511 oper_freq = ieee80211_channel_to_freq_khz(oper->oper_ch, in ieee80211_chandef_s1g_oper()
3513 chandef->center_freq1 = KHZ_TO_MHZ(oper_freq); in ieee80211_chandef_s1g_oper()
3514 chandef->freq1_offset = oper_freq % 1000; in ieee80211_chandef_s1g_oper()
3533 for (j = 0; j < sband->n_bitrates; j++) { in ieee80211_parse_bitrates()
3534 br = &sband->bitrates[j]; in ieee80211_parse_bitrates()
3535 if ((rate_flags & br->flags) != rate_flags) in ieee80211_parse_bitrates()
3538 brate = DIV_ROUND_UP(br->bitrate, (1 << shift) * 5); in ieee80211_parse_bitrates()
3553 struct ieee80211_local *local = sdata->local; in ieee80211_add_srates_ie()
3557 u32 basic_rates = sdata->vif.bss_conf.basic_rates; in ieee80211_add_srates_ie()
3560 shift = ieee80211_vif_get_shift(&sdata->vif); in ieee80211_add_srates_ie()
3561 rate_flags = ieee80211_chandef_rate_flags(&sdata->vif.bss_conf.chandef); in ieee80211_add_srates_ie()
3562 sband = local->hw.wiphy->bands[band]; in ieee80211_add_srates_ie()
3564 for (i = 0; i < sband->n_bitrates; i++) { in ieee80211_add_srates_ie()
3565 if ((rate_flags & sband->bitrates[i].flags) != rate_flags) in ieee80211_add_srates_ie()
3573 return -ENOMEM; in ieee80211_add_srates_ie()
3580 if ((rate_flags & sband->bitrates[i].flags) != rate_flags) in ieee80211_add_srates_ie()
3585 rate = DIV_ROUND_UP(sband->bitrates[i].bitrate, in ieee80211_add_srates_ie()
3597 struct ieee80211_local *local = sdata->local; in ieee80211_add_ext_srates_ie()
3601 u32 basic_rates = sdata->vif.bss_conf.basic_rates; in ieee80211_add_ext_srates_ie()
3604 rate_flags = ieee80211_chandef_rate_flags(&sdata->vif.bss_conf.chandef); in ieee80211_add_ext_srates_ie()
3605 shift = ieee80211_vif_get_shift(&sdata->vif); in ieee80211_add_ext_srates_ie()
3607 sband = local->hw.wiphy->bands[band]; in ieee80211_add_ext_srates_ie()
3609 for (i = 0; i < sband->n_bitrates; i++) { in ieee80211_add_ext_srates_ie()
3610 if ((rate_flags & sband->bitrates[i].flags) != rate_flags) in ieee80211_add_ext_srates_ie()
3616 exrates -= 8; in ieee80211_add_ext_srates_ie()
3621 return -ENOMEM; in ieee80211_add_ext_srates_ie()
3627 for (i = 8; i < sband->n_bitrates; i++) { in ieee80211_add_ext_srates_ie()
3629 if ((rate_flags & sband->bitrates[i].flags) in ieee80211_add_ext_srates_ie()
3634 rate = DIV_ROUND_UP(sband->bitrates[i].bitrate, in ieee80211_add_ext_srates_ie()
3645 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_ave_rssi()
3647 if (WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION)) { in ieee80211_ave_rssi()
3648 /* non-managed type inferfaces */ in ieee80211_ave_rssi()
3651 return -ewma_beacon_signal_read(&ifmgd->ave_beacon_signal); in ieee80211_ave_rssi()
3662 if (mcs->rx_mask[3]) in ieee80211_mcs_to_chains()
3664 if (mcs->rx_mask[2]) in ieee80211_mcs_to_chains()
3666 if (mcs->rx_mask[1]) in ieee80211_mcs_to_chains()
3672 * ieee80211_calculate_rx_timestamp - calculate timestamp in frame
3687 u64 ts = status->mactime; in ieee80211_calculate_rx_timestamp()
3697 ri.bw = status->bw; in ieee80211_calculate_rx_timestamp()
3700 switch (status->encoding) { in ieee80211_calculate_rx_timestamp()
3703 ri.mcs = status->rate_idx; in ieee80211_calculate_rx_timestamp()
3704 ri.nss = status->nss; in ieee80211_calculate_rx_timestamp()
3705 ri.he_ru_alloc = status->he_ru; in ieee80211_calculate_rx_timestamp()
3706 if (status->enc_flags & RX_ENC_FLAG_SHORT_GI) in ieee80211_calculate_rx_timestamp()
3713 if (status->flag & RX_FLAG_MACTIME_PLCP_START) { in ieee80211_calculate_rx_timestamp()
3719 * For HE MU PPDU, add the HE-SIG-B. in ieee80211_calculate_rx_timestamp()
3720 * For HE ER PPDU, add 8us for the HE-SIG-A. in ieee80211_calculate_rx_timestamp()
3721 * For HE TB PPDU, add 4us for the HE-STF. in ieee80211_calculate_rx_timestamp()
3722 * Add the HE-LTF durations - variable. in ieee80211_calculate_rx_timestamp()
3728 ri.mcs = status->rate_idx; in ieee80211_calculate_rx_timestamp()
3730 if (status->enc_flags & RX_ENC_FLAG_SHORT_GI) in ieee80211_calculate_rx_timestamp()
3737 if (status->flag & RX_FLAG_MACTIME_PLCP_START) { in ieee80211_calculate_rx_timestamp()
3739 if (status->enc_flags & RX_ENC_FLAG_HT_GF) in ieee80211_calculate_rx_timestamp()
3745 * Add Data HT-LTFs per streams in ieee80211_calculate_rx_timestamp()
3746 * TODO: add Extension HT-LTFs, 4us per LTF in ieee80211_calculate_rx_timestamp()
3756 ri.mcs = status->rate_idx; in ieee80211_calculate_rx_timestamp()
3757 ri.nss = status->nss; in ieee80211_calculate_rx_timestamp()
3758 if (status->enc_flags & RX_ENC_FLAG_SHORT_GI) in ieee80211_calculate_rx_timestamp()
3765 if (status->flag & RX_FLAG_MACTIME_PLCP_START) { in ieee80211_calculate_rx_timestamp()
3770 * Add VHT-LTFs per streams in ieee80211_calculate_rx_timestamp()
3786 switch (status->bw) { in ieee80211_calculate_rx_timestamp()
3795 sband = local->hw.wiphy->bands[status->band]; in ieee80211_calculate_rx_timestamp()
3796 bitrate = sband->bitrates[status->rate_idx].bitrate; in ieee80211_calculate_rx_timestamp()
3799 if (status->flag & RX_FLAG_MACTIME_PLCP_START) { in ieee80211_calculate_rx_timestamp()
3800 if (status->band == NL80211_BAND_5GHZ) { in ieee80211_calculate_rx_timestamp()
3803 } else if (status->enc_flags & RX_ENC_FLAG_SHORTPRE) { in ieee80211_calculate_rx_timestamp()
3816 (unsigned long long)status->flag, status->rate_idx, in ieee80211_calculate_rx_timestamp()
3817 status->nss)) in ieee80211_calculate_rx_timestamp()
3821 if (status->flag & RX_FLAG_MACTIME_END) in ieee80211_calculate_rx_timestamp()
3822 ts -= mpdu_len * 8 * 10 / rate; in ieee80211_calculate_rx_timestamp()
3835 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_dfs_cac_cancel()
3837 mutex_lock(&local->mtx); in ieee80211_dfs_cac_cancel()
3838 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_dfs_cac_cancel()
3839 /* it might be waiting for the local->mtx, but then in ieee80211_dfs_cac_cancel()
3840 * by the time it gets it, sdata->wdev.cac_started in ieee80211_dfs_cac_cancel()
3843 cancel_delayed_work(&sdata->dfs_cac_timer_work); in ieee80211_dfs_cac_cancel()
3845 if (sdata->wdev.cac_started) { in ieee80211_dfs_cac_cancel()
3846 chandef = sdata->vif.bss_conf.chandef; in ieee80211_dfs_cac_cancel()
3848 cfg80211_cac_event(sdata->dev, in ieee80211_dfs_cac_cancel()
3854 mutex_unlock(&local->mtx); in ieee80211_dfs_cac_cancel()
3861 struct cfg80211_chan_def chandef = local->hw.conf.chandef; in ieee80211_dfs_radar_detected_work()
3865 mutex_lock(&local->chanctx_mtx); in ieee80211_dfs_radar_detected_work()
3866 list_for_each_entry(ctx, &local->chanctx_list, list) { in ieee80211_dfs_radar_detected_work()
3867 if (ctx->replace_state == IEEE80211_CHANCTX_REPLACES_OTHER) in ieee80211_dfs_radar_detected_work()
3871 chandef = ctx->conf.def; in ieee80211_dfs_radar_detected_work()
3873 mutex_unlock(&local->chanctx_mtx); in ieee80211_dfs_radar_detected_work()
3875 wiphy_lock(local->hw.wiphy); in ieee80211_dfs_radar_detected_work()
3877 wiphy_unlock(local->hw.wiphy); in ieee80211_dfs_radar_detected_work()
3880 /* XXX: multi-channel is not supported yet */ in ieee80211_dfs_radar_detected_work()
3883 cfg80211_radar_event(local->hw.wiphy, &chandef, GFP_KERNEL); in ieee80211_dfs_radar_detected_work()
3892 schedule_work(&local->radar_detected_work); in ieee80211_radar_detected()
3901 switch (c->width) { in ieee80211_chandef_downgrade()
3903 c->width = NL80211_CHAN_WIDTH_20_NOHT; in ieee80211_chandef_downgrade()
3907 c->width = NL80211_CHAN_WIDTH_20; in ieee80211_chandef_downgrade()
3908 c->center_freq1 = c->chan->center_freq; in ieee80211_chandef_downgrade()
3913 tmp = (30 + c->chan->center_freq - c->center_freq1)/20; in ieee80211_chandef_downgrade()
3917 c->center_freq1 = c->center_freq1 - 20 + 40 * tmp; in ieee80211_chandef_downgrade()
3918 c->width = NL80211_CHAN_WIDTH_40; in ieee80211_chandef_downgrade()
3922 c->center_freq2 = 0; in ieee80211_chandef_downgrade()
3923 c->width = NL80211_CHAN_WIDTH_80; in ieee80211_chandef_downgrade()
3929 tmp = (70 + c->chan->center_freq - c->center_freq1)/20; in ieee80211_chandef_downgrade()
3932 c->center_freq1 = c->center_freq1 - 40 + 80 * tmp; in ieee80211_chandef_downgrade()
3933 c->width = NL80211_CHAN_WIDTH_80; in ieee80211_chandef_downgrade()
3940 c->width = NL80211_CHAN_WIDTH_20_NOHT; in ieee80211_chandef_downgrade()
3951 /* keep c->width */ in ieee80211_chandef_downgrade()
3991 struct ieee80211_local *local = sdata->local; in ieee80211_send_action_csa()
3992 int freq; in ieee80211_send_action_csa() local
3997 if (sdata->vif.type != NL80211_IFTYPE_ADHOC && in ieee80211_send_action_csa()
3998 sdata->vif.type != NL80211_IFTYPE_MESH_POINT) in ieee80211_send_action_csa()
3999 return -EOPNOTSUPP; in ieee80211_send_action_csa()
4001 skb = dev_alloc_skb(local->tx_headroom + hdr_len + in ieee80211_send_action_csa()
4007 return -ENOMEM; in ieee80211_send_action_csa()
4009 skb_reserve(skb, local->tx_headroom); in ieee80211_send_action_csa()
4011 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | in ieee80211_send_action_csa()
4014 eth_broadcast_addr(mgmt->da); in ieee80211_send_action_csa()
4015 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); in ieee80211_send_action_csa()
4016 if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_send_action_csa()
4017 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN); in ieee80211_send_action_csa()
4019 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; in ieee80211_send_action_csa()
4020 memcpy(mgmt->bssid, ifibss->bssid, ETH_ALEN); in ieee80211_send_action_csa()
4022 mgmt->u.action.category = WLAN_CATEGORY_SPECTRUM_MGMT; in ieee80211_send_action_csa()
4023 mgmt->u.action.u.chan_switch.action_code = WLAN_ACTION_SPCT_CHL_SWITCH; in ieee80211_send_action_csa()
4027 *pos++ = csa_settings->block_tx ? 1 : 0; /* CSA mode */ in ieee80211_send_action_csa()
4028 freq = csa_settings->chandef.chan->center_freq; in ieee80211_send_action_csa()
4029 *pos++ = ieee80211_frequency_to_channel(freq); /* channel */ in ieee80211_send_action_csa()
4030 *pos++ = csa_settings->count; /* count */ in ieee80211_send_action_csa()
4032 if (csa_settings->chandef.width == NL80211_CHAN_WIDTH_40) { in ieee80211_send_action_csa()
4038 ch_type = cfg80211_get_chandef_type(&csa_settings->chandef); in ieee80211_send_action_csa()
4045 if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_send_action_csa()
4046 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; in ieee80211_send_action_csa()
4051 *pos++ = sdata->u.mesh.mshcfg.dot11MeshTTL; /* Mesh TTL */ in ieee80211_send_action_csa()
4054 *pos++ |= csa_settings->block_tx ? in ieee80211_send_action_csa()
4058 put_unaligned_le16(ifmsh->pre_value, pos);/* Precedence Value */ in ieee80211_send_action_csa()
4062 if (csa_settings->chandef.width == NL80211_CHAN_WIDTH_80 || in ieee80211_send_action_csa()
4063 csa_settings->chandef.width == NL80211_CHAN_WIDTH_80P80 || in ieee80211_send_action_csa()
4064 csa_settings->chandef.width == NL80211_CHAN_WIDTH_160) { in ieee80211_send_action_csa()
4066 ieee80211_ie_build_wide_bw_cs(pos, &csa_settings->chandef); in ieee80211_send_action_csa()
4075 return !(cs == NULL || cs->cipher == 0 || in ieee80211_cs_valid()
4076 cs->hdr_len < cs->pn_len + cs->pn_off || in ieee80211_cs_valid()
4077 cs->hdr_len <= cs->key_idx_off || in ieee80211_cs_valid()
4078 cs->key_idx_shift > 7 || in ieee80211_cs_valid()
4079 cs->key_idx_mask == 0); in ieee80211_cs_valid()
4100 const struct ieee80211_cipher_scheme *l = local->hw.cipher_schemes; in ieee80211_cs_get()
4101 int n = local->hw.n_cipher_schemes; in ieee80211_cs_get()
4112 if (!cs || !(cs->iftype & BIT(iftype))) in ieee80211_cs_get()
4126 for (i = 0; i < crypto->n_ciphers_pairwise; i++) { in ieee80211_cs_headroom()
4127 cs = ieee80211_cs_get(local, crypto->ciphers_pairwise[i], in ieee80211_cs_headroom()
4130 if (cs && headroom < cs->hdr_len) in ieee80211_cs_headroom()
4131 headroom = cs->hdr_len; in ieee80211_cs_headroom()
4134 cs = ieee80211_cs_get(local, crypto->cipher_group, iftype); in ieee80211_cs_headroom()
4135 if (cs && headroom < cs->hdr_len) in ieee80211_cs_headroom()
4136 headroom = cs->hdr_len; in ieee80211_cs_headroom()
4144 s32 end = data->desc[i].start + data->desc[i].duration - (tsf + 1); in ieee80211_extend_noa_desc()
4151 if (data->count[i] == 1) in ieee80211_extend_noa_desc()
4154 if (data->desc[i].interval == 0) in ieee80211_extend_noa_desc()
4158 skip = DIV_ROUND_UP(-end, data->desc[i].interval); in ieee80211_extend_noa_desc()
4159 if (data->count[i] < 255) { in ieee80211_extend_noa_desc()
4160 if (data->count[i] <= skip) { in ieee80211_extend_noa_desc()
4161 data->count[i] = 0; in ieee80211_extend_noa_desc()
4165 data->count[i] -= skip; in ieee80211_extend_noa_desc()
4168 data->desc[i].start += skip * data->desc[i].interval; in ieee80211_extend_noa_desc()
4183 if (!data->count[i]) in ieee80211_extend_absent_time()
4189 cur = data->desc[i].start - tsf; in ieee80211_extend_absent_time()
4193 cur = data->desc[i].start + data->desc[i].duration - tsf; in ieee80211_extend_absent_time()
4207 * arbitrary limit, used to avoid infinite loops when combined NoA in ieee80211_get_noa_absent_time()
4225 u32 next_offset = BIT(31) - 1; in ieee80211_update_p2p_noa()
4228 data->absent = 0; in ieee80211_update_p2p_noa()
4229 data->has_next_tsf = false; in ieee80211_update_p2p_noa()
4233 if (!data->count[i]) in ieee80211_update_p2p_noa()
4237 start = data->desc[i].start - tsf; in ieee80211_update_p2p_noa()
4239 data->absent |= BIT(i); in ieee80211_update_p2p_noa()
4244 data->has_next_tsf = true; in ieee80211_update_p2p_noa()
4247 if (data->absent) in ieee80211_update_p2p_noa()
4250 data->next_tsf = tsf + next_offset; in ieee80211_update_p2p_noa()
4263 const struct ieee80211_p2p_noa_desc *desc = &attr->desc[i]; in ieee80211_parse_p2p_noa()
4265 if (!desc->count || !desc->duration) in ieee80211_parse_p2p_noa()
4268 data->count[i] = desc->count; in ieee80211_parse_p2p_noa()
4269 data->desc[i].start = le32_to_cpu(desc->start_time); in ieee80211_parse_p2p_noa()
4270 data->desc[i].duration = le32_to_cpu(desc->duration); in ieee80211_parse_p2p_noa()
4271 data->desc[i].interval = le32_to_cpu(desc->interval); in ieee80211_parse_p2p_noa()
4273 if (data->count[i] > 1 && in ieee80211_parse_p2p_noa()
4274 data->desc[i].interval < data->desc[i].duration) in ieee80211_parse_p2p_noa()
4293 u16 beacon_int = sdata->vif.bss_conf.beacon_int * 1024; in ieee80211_recalc_dtim()
4294 u8 dtim_period = sdata->vif.bss_conf.dtim_period; in ieee80211_recalc_dtim()
4298 if (tsf == -1ULL || !beacon_int || !dtim_period) in ieee80211_recalc_dtim()
4301 if (sdata->vif.type == NL80211_IFTYPE_AP || in ieee80211_recalc_dtim()
4302 sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in ieee80211_recalc_dtim()
4303 if (!sdata->bss) in ieee80211_recalc_dtim()
4306 ps = &sdata->bss->ps; in ieee80211_recalc_dtim()
4307 } else if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_recalc_dtim()
4308 ps = &sdata->u.mesh.ps; in ieee80211_recalc_dtim()
4316 * dtim_count = dtim_period - (tsf / bcn_int) % dtim_period in ieee80211_recalc_dtim()
4324 dtim_count = dtim_period - bcns_from_dtim; in ieee80211_recalc_dtim()
4326 ps->dtim_count = dtim_count; in ieee80211_recalc_dtim()
4335 lockdep_assert_held(&local->chanctx_mtx); in ieee80211_chanctx_radar_detect()
4337 if (WARN_ON(ctx->replace_state == IEEE80211_CHANCTX_WILL_BE_REPLACED)) in ieee80211_chanctx_radar_detect()
4340 list_for_each_entry(sdata, &ctx->reserved_vifs, reserved_chanctx_list) in ieee80211_chanctx_radar_detect()
4341 if (sdata->reserved_radar_required) in ieee80211_chanctx_radar_detect()
4342 radar_detect |= BIT(sdata->reserved_chandef.width); in ieee80211_chanctx_radar_detect()
4345 * An in-place reservation context should not have any assigned vifs in ieee80211_chanctx_radar_detect()
4348 WARN_ON(ctx->replace_state == IEEE80211_CHANCTX_REPLACES_OTHER && in ieee80211_chanctx_radar_detect()
4349 !list_empty(&ctx->assigned_vifs)); in ieee80211_chanctx_radar_detect()
4351 list_for_each_entry(sdata, &ctx->assigned_vifs, assigned_chanctx_list) in ieee80211_chanctx_radar_detect()
4352 if (sdata->radar_required) in ieee80211_chanctx_radar_detect()
4353 radar_detect |= BIT(sdata->vif.bss_conf.chandef.width); in ieee80211_chanctx_radar_detect()
4363 struct ieee80211_local *local = sdata->local; in ieee80211_check_combinations()
4365 enum nl80211_iftype iftype = sdata->wdev.iftype; in ieee80211_check_combinations()
4372 lockdep_assert_held(&local->chanctx_mtx); in ieee80211_check_combinations()
4375 return -EINVAL; in ieee80211_check_combinations()
4378 !chandef->chan)) in ieee80211_check_combinations()
4379 return -EINVAL; in ieee80211_check_combinations()
4382 return -EINVAL; in ieee80211_check_combinations()
4384 if (sdata->vif.type == NL80211_IFTYPE_AP || in ieee80211_check_combinations()
4385 sdata->vif.type == NL80211_IFTYPE_MESH_POINT) { in ieee80211_check_combinations()
4391 params.new_beacon_int = sdata->vif.bss_conf.beacon_int; in ieee80211_check_combinations()
4395 if (cfg80211_iftype_allowed(local->hw.wiphy, iftype, 0, 1)) { in ieee80211_check_combinations()
4397 return -EINVAL; in ieee80211_check_combinations()
4407 list_for_each_entry(ctx, &local->chanctx_list, list) { in ieee80211_check_combinations()
4408 if (ctx->replace_state == IEEE80211_CHANCTX_WILL_BE_REPLACED) in ieee80211_check_combinations()
4412 if (ctx->mode == IEEE80211_CHANCTX_EXCLUSIVE) { in ieee80211_check_combinations()
4418 &ctx->conf.def)) in ieee80211_check_combinations()
4423 list_for_each_entry_rcu(sdata_iter, &local->interfaces, list) { in ieee80211_check_combinations()
4426 wdev_iter = &sdata_iter->wdev; in ieee80211_check_combinations()
4430 cfg80211_iftype_allowed(local->hw.wiphy, in ieee80211_check_combinations()
4431 wdev_iter->iftype, 0, 1)) in ieee80211_check_combinations()
4434 params.iftype_num[wdev_iter->iftype]++; in ieee80211_check_combinations()
4441 return cfg80211_check_combinations(local->hw.wiphy, &params); in ieee80211_check_combinations()
4451 c->num_different_channels); in ieee80211_iter_max_chans()
4462 lockdep_assert_held(&local->chanctx_mtx); in ieee80211_max_num_channels()
4464 list_for_each_entry(ctx, &local->chanctx_list, list) { in ieee80211_max_num_channels()
4465 if (ctx->replace_state == IEEE80211_CHANCTX_WILL_BE_REPLACED) in ieee80211_max_num_channels()
4474 list_for_each_entry_rcu(sdata, &local->interfaces, list) in ieee80211_max_num_channels()
4475 params.iftype_num[sdata->wdev.iftype]++; in ieee80211_max_num_channels()
4477 err = cfg80211_iter_combinations(local->hw.wiphy, &params, in ieee80211_max_num_channels()
4490 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_add_s1g_capab_ie()
4495 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION)) in ieee80211_add_s1g_capab_ie()
4498 if (!caps->s1g) in ieee80211_add_s1g_capab_ie()
4501 memcpy(s1g_capab.capab_info, caps->cap, sizeof(caps->cap)); in ieee80211_add_s1g_capab_ie()
4502 memcpy(s1g_capab.supp_mcs_nss, caps->nss_mcs, sizeof(caps->nss_mcs)); in ieee80211_add_s1g_capab_ie()
4505 for (i = 0; i < sizeof(ifmgd->s1g_capa.capab_info); i++) { in ieee80211_add_s1g_capab_ie()
4506 u8 mask = ifmgd->s1g_capa_mask.capab_info[i]; in ieee80211_add_s1g_capab_ie()
4509 s1g_capab.capab_info[i] |= ifmgd->s1g_capa.capab_info[i] & mask; in ieee80211_add_s1g_capab_ie()
4513 for (i = 0; i < sizeof(ifmgd->s1g_capa.supp_mcs_nss); i++) { in ieee80211_add_s1g_capab_ie()
4514 u8 mask = ifmgd->s1g_capa_mask.supp_mcs_nss[i]; in ieee80211_add_s1g_capab_ie()
4518 ifmgd->s1g_capa.supp_mcs_nss[i] & mask; in ieee80211_add_s1g_capab_ie()
4548 *buf++ = qosinfo; /* U-APSD no in use */ in ieee80211_add_wmm_info_ie()
4561 skb_queue_walk(&txqi->frags, skb) { in ieee80211_txq_get_depth()
4563 frag_bytes += skb->len; in ieee80211_txq_get_depth()
4567 *frame_cnt = txqi->tin.backlog_packets + frag_cnt; in ieee80211_txq_get_depth()
4570 *byte_cnt = txqi->tin.backlog_bytes + frag_bytes; in ieee80211_txq_get_depth()