Lines Matching +full:ri +full:- +full:override
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-2020 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()
394 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_wake_txqs()
396 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_wake_txqs()
404 if (local->ops->wake_tx_queue) in ieee80211_propagate_queue_wake()
407 if (local->hw.queues < IEEE80211_NUM_ACS) in ieee80211_propagate_queue_wake()
410 list_for_each_entry_rcu(sdata, &local->interfaces, list) { in ieee80211_propagate_queue_wake()
413 if (!sdata->dev) in ieee80211_propagate_queue_wake()
416 if (sdata->vif.cab_queue != IEEE80211_INVAL_HW_QUEUE && in ieee80211_propagate_queue_wake()
417 local->queue_stop_reasons[sdata->vif.cab_queue] != 0) in ieee80211_propagate_queue_wake()
421 int ac_queue = sdata->vif.hw_queue[ac]; in ieee80211_propagate_queue_wake()
424 (sdata->vif.cab_queue == queue && in ieee80211_propagate_queue_wake()
425 local->queue_stop_reasons[ac_queue] == 0 && in ieee80211_propagate_queue_wake()
426 skb_queue_empty(&local->pending[ac_queue]))) in ieee80211_propagate_queue_wake()
427 netif_wake_subqueue(sdata->dev, ac); in ieee80211_propagate_queue_wake()
441 if (WARN_ON(queue >= hw->queues)) in __ieee80211_wake_queue()
444 if (!test_bit(reason, &local->queue_stop_reasons[queue])) in __ieee80211_wake_queue()
448 local->q_stop_reasons[queue][reason] = 0; in __ieee80211_wake_queue()
450 local->q_stop_reasons[queue][reason]--; in __ieee80211_wake_queue()
451 if (WARN_ON(local->q_stop_reasons[queue][reason] < 0)) in __ieee80211_wake_queue()
452 local->q_stop_reasons[queue][reason] = 0; in __ieee80211_wake_queue()
455 if (local->q_stop_reasons[queue][reason] == 0) in __ieee80211_wake_queue()
456 __clear_bit(reason, &local->queue_stop_reasons[queue]); in __ieee80211_wake_queue()
458 if (local->queue_stop_reasons[queue] != 0) in __ieee80211_wake_queue()
462 if (skb_queue_empty(&local->pending[queue])) { in __ieee80211_wake_queue()
467 tasklet_schedule(&local->tx_pending_tasklet); in __ieee80211_wake_queue()
476 if (local->ops->wake_tx_queue) { in __ieee80211_wake_queue()
478 tasklet_schedule(&local->wake_txqs_tasklet); in __ieee80211_wake_queue()
491 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_wake_queue_by_reason()
493 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_wake_queue_by_reason()
514 if (WARN_ON(queue >= hw->queues)) in __ieee80211_stop_queue()
518 local->q_stop_reasons[queue][reason] = 1; in __ieee80211_stop_queue()
520 local->q_stop_reasons[queue][reason]++; in __ieee80211_stop_queue()
522 if (__test_and_set_bit(reason, &local->queue_stop_reasons[queue])) in __ieee80211_stop_queue()
525 if (local->hw.queues < IEEE80211_NUM_ACS) in __ieee80211_stop_queue()
529 list_for_each_entry_rcu(sdata, &local->interfaces, list) { in __ieee80211_stop_queue()
532 if (!sdata->dev) in __ieee80211_stop_queue()
536 if (sdata->vif.hw_queue[ac] == queue || in __ieee80211_stop_queue()
537 sdata->vif.cab_queue == queue) { in __ieee80211_stop_queue()
538 if (!local->ops->wake_tx_queue) { in __ieee80211_stop_queue()
539 netif_stop_subqueue(sdata->dev, ac); in __ieee80211_stop_queue()
542 spin_lock(&local->fq.lock); in __ieee80211_stop_queue()
543 sdata->vif.txqs_stopped[ac] = true; in __ieee80211_stop_queue()
544 spin_unlock(&local->fq.lock); in __ieee80211_stop_queue()
558 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_stop_queue_by_reason()
560 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_stop_queue_by_reason()
574 struct ieee80211_hw *hw = &local->hw; in ieee80211_add_pending_skb()
577 int queue = info->hw_queue; in ieee80211_add_pending_skb()
579 if (WARN_ON(!info->control.vif)) { in ieee80211_add_pending_skb()
580 ieee80211_free_txskb(&local->hw, skb); in ieee80211_add_pending_skb()
584 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_add_pending_skb()
587 __skb_queue_tail(&local->pending[queue], skb); in ieee80211_add_pending_skb()
590 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_add_pending_skb()
596 struct ieee80211_hw *hw = &local->hw; in ieee80211_add_pending_skbs()
601 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_add_pending_skbs()
605 if (WARN_ON(!info->control.vif)) { in ieee80211_add_pending_skbs()
606 ieee80211_free_txskb(&local->hw, skb); in ieee80211_add_pending_skbs()
610 queue = info->hw_queue; in ieee80211_add_pending_skbs()
616 __skb_queue_tail(&local->pending[queue], skb); in ieee80211_add_pending_skbs()
619 for (i = 0; i < hw->queues; i++) in ieee80211_add_pending_skbs()
623 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_add_pending_skbs()
635 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_stop_queues_by_reason()
637 for_each_set_bit(i, &queues, hw->queues) in ieee80211_stop_queues_by_reason()
640 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_stop_queues_by_reason()
657 if (WARN_ON(queue >= hw->queues)) in ieee80211_queue_stopped()
660 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_queue_stopped()
662 &local->queue_stop_reasons[queue]); in ieee80211_queue_stopped()
663 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_queue_stopped()
677 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_wake_queues_by_reason()
679 for_each_set_bit(i, &queues, hw->queues) in ieee80211_wake_queues_by_reason()
682 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_wake_queues_by_reason()
699 if (sdata && ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) { in ieee80211_get_vif_queues()
705 queues |= BIT(sdata->vif.hw_queue[ac]); in ieee80211_get_vif_queues()
706 if (sdata->vif.cab_queue != IEEE80211_INVAL_HW_QUEUE) in ieee80211_get_vif_queues()
707 queues |= BIT(sdata->vif.cab_queue); in ieee80211_get_vif_queues()
710 queues = BIT(local->hw.queues) - 1; in ieee80211_get_vif_queues()
720 if (!local->ops->flush) in __ieee80211_flush_queues()
725 * IEEE80211_HW_QUEUE_CONTROL - flush all queues in __ieee80211_flush_queues()
727 if (!queues || !ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) in __ieee80211_flush_queues()
730 ieee80211_stop_queues_by_reason(&local->hw, queues, in __ieee80211_flush_queues()
736 ieee80211_wake_queues_by_reason(&local->hw, queues, in __ieee80211_flush_queues()
751 ieee80211_stop_queues_by_reason(&local->hw, in ieee80211_stop_vif_queues()
760 ieee80211_wake_queues_by_reason(&local->hw, in ieee80211_wake_vif_queues()
774 list_for_each_entry_rcu(sdata, &local->interfaces, list) { in __iterate_interfaces()
775 switch (sdata->vif.type) { in __iterate_interfaces()
777 if (!(sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE)) in __iterate_interfaces()
786 active_only && !(sdata->flags & IEEE80211_SDATA_IN_DRIVER)) in __iterate_interfaces()
789 !(sdata->flags & IEEE80211_SDATA_IN_DRIVER)) in __iterate_interfaces()
792 iterator(data, sdata->vif.addr, in __iterate_interfaces()
793 &sdata->vif); in __iterate_interfaces()
796 sdata = rcu_dereference_check(local->monitor_sdata, in __iterate_interfaces()
797 lockdep_is_held(&local->iflist_mtx) || in __iterate_interfaces()
801 sdata->flags & IEEE80211_SDATA_IN_DRIVER)) in __iterate_interfaces()
802 iterator(data, sdata->vif.addr, &sdata->vif); in __iterate_interfaces()
813 mutex_lock(&local->iflist_mtx); in ieee80211_iterate_interfaces()
815 mutex_unlock(&local->iflist_mtx); in ieee80211_iterate_interfaces()
856 list_for_each_entry_rcu(sta, &local->sta_list, list) { in __iterate_stations()
857 if (!sta->uploaded) in __iterate_stations()
860 iterator(data, &sta->sta); in __iterate_stations()
882 !(sdata->flags & IEEE80211_SDATA_IN_DRIVER)) in wdev_to_ieee80211_vif()
884 return &sdata->vif; in wdev_to_ieee80211_vif()
898 !(sdata->flags & IEEE80211_SDATA_IN_DRIVER)) in ieee80211_vif_to_wdev()
901 return &sdata->wdev; in ieee80211_vif_to_wdev()
907 * the suspend->resume cycle. Since we can't check each caller
916 if (local->quiescing || (local->suspended && !local->resuming)) { in ieee80211_can_queue_work()
931 queue_work(local->workqueue, work); in ieee80211_queue_work()
944 queue_delayed_work(local->workqueue, dwork, delay); in ieee80211_queue_delayed_work()
952 const void *data = elem->data + 1; in ieee80211_parse_extension_element()
955 if (!elem->datalen) in ieee80211_parse_extension_element()
958 len = elem->datalen - 1; in ieee80211_parse_extension_element()
960 switch (elem->data[0]) { in ieee80211_parse_extension_element()
962 if (len >= sizeof(*elems->mu_edca_param_set)) { in ieee80211_parse_extension_element()
963 elems->mu_edca_param_set = data; in ieee80211_parse_extension_element()
966 elem->datalen + 2); in ieee80211_parse_extension_element()
970 elems->he_cap = data; in ieee80211_parse_extension_element()
971 elems->he_cap_len = len; in ieee80211_parse_extension_element()
974 if (len >= sizeof(*elems->he_operation) && in ieee80211_parse_extension_element()
975 len >= ieee80211_he_oper_size(data) - 1) { in ieee80211_parse_extension_element()
978 elem->datalen + 2); in ieee80211_parse_extension_element()
979 elems->he_operation = data; in ieee80211_parse_extension_element()
984 elems->uora_element = data; in ieee80211_parse_extension_element()
988 elems->max_channel_switch_time = data; in ieee80211_parse_extension_element()
991 if (len >= sizeof(*elems->mbssid_config_ie)) in ieee80211_parse_extension_element()
992 elems->mbssid_config_ie = data; in ieee80211_parse_extension_element()
995 if (len >= sizeof(*elems->he_spr) && in ieee80211_parse_extension_element()
997 elems->he_spr = data; in ieee80211_parse_extension_element()
1000 if (len >= sizeof(*elems->he_6ghz_capa)) in ieee80211_parse_extension_element()
1001 elems->he_6ghz_capa = data; in ieee80211_parse_extension_element()
1021 u8 id = elem->id; in _ieee802_11_parse_elems_crc()
1022 u8 elen = elem->datalen; in _ieee802_11_parse_elems_crc()
1023 const u8 *pos = elem->data; in _ieee802_11_parse_elems_crc()
1072 * not listing WLAN_EID_CHANNEL_SWITCH_WRAPPER -- it seems possible in _ieee802_11_parse_elems_crc()
1076 elems->parse_error = true; in _ieee802_11_parse_elems_crc()
1083 crc = crc32_be(crc, pos - 2, elen + 2); in _ieee802_11_parse_elems_crc()
1093 elems->lnk_id = (void *)(pos - 2); in _ieee802_11_parse_elems_crc()
1100 elems->ch_sw_timing = (void *)pos; in _ieee802_11_parse_elems_crc()
1103 elems->ext_capab = pos; in _ieee802_11_parse_elems_crc()
1104 elems->ext_capab_len = elen; in _ieee802_11_parse_elems_crc()
1107 elems->ssid = pos; in _ieee802_11_parse_elems_crc()
1108 elems->ssid_len = elen; in _ieee802_11_parse_elems_crc()
1111 elems->supp_rates = pos; in _ieee802_11_parse_elems_crc()
1112 elems->supp_rates_len = elen; in _ieee802_11_parse_elems_crc()
1116 elems->ds_params = pos; in _ieee802_11_parse_elems_crc()
1122 elems->tim = (void *)pos; in _ieee802_11_parse_elems_crc()
1123 elems->tim_len = elen; in _ieee802_11_parse_elems_crc()
1128 elems->challenge = pos; in _ieee802_11_parse_elems_crc()
1129 elems->challenge_len = elen; in _ieee802_11_parse_elems_crc()
1137 crc = crc32_be(crc, pos - 2, elen + 2); in _ieee802_11_parse_elems_crc()
1140 /* OUI Type 2 - WMM IE */ in _ieee802_11_parse_elems_crc()
1142 elems->wmm_info = pos; in _ieee802_11_parse_elems_crc()
1143 elems->wmm_info_len = elen; in _ieee802_11_parse_elems_crc()
1145 elems->wmm_param = pos; in _ieee802_11_parse_elems_crc()
1146 elems->wmm_param_len = elen; in _ieee802_11_parse_elems_crc()
1152 elems->rsn = pos; in _ieee802_11_parse_elems_crc()
1153 elems->rsn_len = elen; in _ieee802_11_parse_elems_crc()
1157 elems->erp_info = pos; in _ieee802_11_parse_elems_crc()
1162 elems->ext_supp_rates = pos; in _ieee802_11_parse_elems_crc()
1163 elems->ext_supp_rates_len = elen; in _ieee802_11_parse_elems_crc()
1167 elems->ht_cap_elem = (void *)pos; in _ieee802_11_parse_elems_crc()
1173 elems->ht_operation = (void *)pos; in _ieee802_11_parse_elems_crc()
1179 elems->vht_cap_elem = (void *)pos; in _ieee802_11_parse_elems_crc()
1185 elems->vht_operation = (void *)pos; in _ieee802_11_parse_elems_crc()
1187 crc = crc32_be(crc, pos - 2, elen + 2); in _ieee802_11_parse_elems_crc()
1194 elems->opmode_notif = pos; in _ieee802_11_parse_elems_crc()
1196 crc = crc32_be(crc, pos - 2, elen + 2); in _ieee802_11_parse_elems_crc()
1202 elems->mesh_id = pos; in _ieee802_11_parse_elems_crc()
1203 elems->mesh_id_len = elen; in _ieee802_11_parse_elems_crc()
1207 elems->mesh_config = (void *)pos; in _ieee802_11_parse_elems_crc()
1212 elems->peering = pos; in _ieee802_11_parse_elems_crc()
1213 elems->peering_len = elen; in _ieee802_11_parse_elems_crc()
1217 elems->awake_window = (void *)pos; in _ieee802_11_parse_elems_crc()
1220 elems->preq = pos; in _ieee802_11_parse_elems_crc()
1221 elems->preq_len = elen; in _ieee802_11_parse_elems_crc()
1224 elems->prep = pos; in _ieee802_11_parse_elems_crc()
1225 elems->prep_len = elen; in _ieee802_11_parse_elems_crc()
1228 elems->perr = pos; in _ieee802_11_parse_elems_crc()
1229 elems->perr_len = elen; in _ieee802_11_parse_elems_crc()
1233 elems->rann = (void *)pos; in _ieee802_11_parse_elems_crc()
1242 elems->ch_switch_ie = (void *)pos; in _ieee802_11_parse_elems_crc()
1249 elems->ext_chansw_ie = (void *)pos; in _ieee802_11_parse_elems_crc()
1256 elems->sec_chan_offs = (void *)pos; in _ieee802_11_parse_elems_crc()
1260 sizeof(*elems->mesh_chansw_params_ie)) { in _ieee802_11_parse_elems_crc()
1264 elems->mesh_chansw_params_ie = (void *)pos; in _ieee802_11_parse_elems_crc()
1268 elen < sizeof(*elems->wide_bw_chansw_ie)) { in _ieee802_11_parse_elems_crc()
1272 elems->wide_bw_chansw_ie = (void *)pos; in _ieee802_11_parse_elems_crc()
1287 if (ie[1] >= sizeof(*elems->wide_bw_chansw_ie)) in _ieee802_11_parse_elems_crc()
1288 elems->wide_bw_chansw_ie = in _ieee802_11_parse_elems_crc()
1295 elems->country_elem = pos; in _ieee802_11_parse_elems_crc()
1296 elems->country_elem_len = elen; in _ieee802_11_parse_elems_crc()
1303 elems->pwr_constr_elem = pos; in _ieee802_11_parse_elems_crc()
1326 crc = crc32_be(crc, pos - 2, elen + 2); in _ieee802_11_parse_elems_crc()
1328 elems->cisco_dtpc_elem = pos; in _ieee802_11_parse_elems_crc()
1335 elems->addba_ext_ie = (void *)pos; in _ieee802_11_parse_elems_crc()
1339 elems->timeout_int = (void *)pos; in _ieee802_11_parse_elems_crc()
1344 if (elen >= sizeof(*elems->max_idle_period_ie)) in _ieee802_11_parse_elems_crc()
1345 elems->max_idle_period_ie = (void *)pos; in _ieee802_11_parse_elems_crc()
1348 elems->rsnx = pos; in _ieee802_11_parse_elems_crc()
1349 elems->rsnx_len = elen; 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()
1498 /* Override with nontransmitted profile, if found */ in ieee802_11_parse_elems_crc()
1504 if (elems->tim && !elems->parse_error) { in ieee802_11_parse_elems_crc()
1505 const struct ieee80211_tim_ie *tim_ie = elems->tim; in ieee802_11_parse_elems_crc()
1507 elems->dtim_period = tim_ie->dtim_period; in ieee802_11_parse_elems_crc()
1508 elems->dtim_count = tim_ie->dtim_count; in ieee802_11_parse_elems_crc()
1511 /* Override DTIM period and count if needed */ 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_period = elems->bssid_index->dtim_period; in ieee802_11_parse_elems_crc()
1517 if (elems->bssid_index && in ieee802_11_parse_elems_crc()
1518 elems->bssid_index_len >= in ieee802_11_parse_elems_crc()
1520 elems->dtim_count = elems->bssid_index->dtim_count; in ieee802_11_parse_elems_crc()
1522 elems->nontx_profile = nontransmitted_profile; in ieee802_11_parse_elems_crc()
1536 if (sdata->vif.type != NL80211_IFTYPE_AP && in ieee80211_regulatory_limit_wmm_params()
1537 sdata->vif.type != NL80211_IFTYPE_STATION) in ieee80211_regulatory_limit_wmm_params()
1541 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_regulatory_limit_wmm_params()
1543 center_freq = chanctx_conf->def.chan->center_freq; in ieee80211_regulatory_limit_wmm_params()
1550 rrule = freq_reg_info(sdata->wdev.wiphy, MHZ_TO_KHZ(center_freq)); in ieee80211_regulatory_limit_wmm_params()
1552 if (IS_ERR_OR_NULL(rrule) || !rrule->has_wmm) { in ieee80211_regulatory_limit_wmm_params()
1557 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_regulatory_limit_wmm_params()
1558 wmm_ac = &rrule->wmm_rule.ap[ac]; in ieee80211_regulatory_limit_wmm_params()
1560 wmm_ac = &rrule->wmm_rule.client[ac]; in ieee80211_regulatory_limit_wmm_params()
1561 qparam->cw_min = max_t(u16, qparam->cw_min, wmm_ac->cw_min); in ieee80211_regulatory_limit_wmm_params()
1562 qparam->cw_max = max_t(u16, qparam->cw_max, wmm_ac->cw_max); in ieee80211_regulatory_limit_wmm_params()
1563 qparam->aifs = max_t(u8, qparam->aifs, wmm_ac->aifsn); in ieee80211_regulatory_limit_wmm_params()
1564 qparam->txop = min_t(u16, qparam->txop, wmm_ac->cot / 32); in ieee80211_regulatory_limit_wmm_params()
1571 struct ieee80211_local *local = sdata->local; in ieee80211_set_wmm_default()
1579 if (!local->ops->conf_tx) in ieee80211_set_wmm_default()
1582 if (local->hw.queues < IEEE80211_NUM_ACS) in ieee80211_set_wmm_default()
1588 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_set_wmm_default()
1590 chanctx_conf->def.chan->band == NL80211_BAND_2GHZ) && in ieee80211_set_wmm_default()
1591 !(sdata->flags & IEEE80211_SDATA_OPERATING_GMODE); in ieee80211_set_wmm_default()
1594 is_ocb = (sdata->vif.type == NL80211_IFTYPE_OCB); in ieee80211_set_wmm_default()
1596 /* Set defaults according to 802.11-2007 Table 7-37 */ in ieee80211_set_wmm_default()
1635 qparam.cw_min = (aCWmin + 1) / 2 - 1; in ieee80211_set_wmm_default()
1649 qparam.cw_max = (aCWmin + 1) / 2 - 1; in ieee80211_set_wmm_default()
1650 qparam.cw_min = (aCWmin + 1) / 4 - 1; in ieee80211_set_wmm_default()
1665 sdata->tx_conf[ac] = qparam; in ieee80211_set_wmm_default()
1669 if (sdata->vif.type != NL80211_IFTYPE_MONITOR && in ieee80211_set_wmm_default()
1670 sdata->vif.type != NL80211_IFTYPE_P2P_DEVICE && in ieee80211_set_wmm_default()
1671 sdata->vif.type != NL80211_IFTYPE_NAN) { in ieee80211_set_wmm_default()
1672 sdata->vif.bss_conf.qos = enable_qos; in ieee80211_set_wmm_default()
1685 struct ieee80211_local *local = sdata->local; in ieee80211_send_auth()
1691 skb = dev_alloc_skb(local->hw.extra_tx_headroom + IEEE80211_WEP_IV_LEN + in ieee80211_send_auth()
1696 skb_reserve(skb, local->hw.extra_tx_headroom + IEEE80211_WEP_IV_LEN); in ieee80211_send_auth()
1699 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | in ieee80211_send_auth()
1701 memcpy(mgmt->da, da, ETH_ALEN); in ieee80211_send_auth()
1702 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); in ieee80211_send_auth()
1703 memcpy(mgmt->bssid, bssid, ETH_ALEN); in ieee80211_send_auth()
1704 mgmt->u.auth.auth_alg = cpu_to_le16(auth_alg); in ieee80211_send_auth()
1705 mgmt->u.auth.auth_transaction = cpu_to_le16(transaction); in ieee80211_send_auth()
1706 mgmt->u.auth.status_code = cpu_to_le16(status); in ieee80211_send_auth()
1711 mgmt->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); in ieee80211_send_auth()
1716 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT | in ieee80211_send_auth()
1726 struct ieee80211_local *local = sdata->local; in ieee80211_send_deauth_disassoc()
1731 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | stype); in ieee80211_send_deauth_disassoc()
1732 mgmt->duration = 0; /* initialize only */ in ieee80211_send_deauth_disassoc()
1733 mgmt->seq_ctrl = 0; /* initialize only */ in ieee80211_send_deauth_disassoc()
1734 memcpy(mgmt->da, da, ETH_ALEN); in ieee80211_send_deauth_disassoc()
1735 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); in ieee80211_send_deauth_disassoc()
1736 memcpy(mgmt->bssid, bssid, ETH_ALEN); in ieee80211_send_deauth_disassoc()
1738 mgmt->u.deauth.reason_code = cpu_to_le16(reason); in ieee80211_send_deauth_disassoc()
1741 skb = dev_alloc_skb(local->hw.extra_tx_headroom + in ieee80211_send_deauth_disassoc()
1746 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_send_deauth_disassoc()
1751 if (sdata->vif.type != NL80211_IFTYPE_STATION || in ieee80211_send_deauth_disassoc()
1752 !(sdata->u.mgd.flags & IEEE80211_STA_MFP_ENABLED)) in ieee80211_send_deauth_disassoc()
1753 IEEE80211_SKB_CB(skb)->flags |= in ieee80211_send_deauth_disassoc()
1762 if ((end - pos) < 5) in ieee80211_write_he_6ghz_cap()
1781 struct ieee80211_local *local = sdata->local; in ieee80211_build_preq_ies_band()
1796 sband = local->hw.wiphy->bands[band]; in ieee80211_build_preq_ies_band()
1804 for (i = 0; i < sband->n_bitrates; i++) { in ieee80211_build_preq_ies_band()
1807 if ((rate_flags & sband->bitrates[i].flags) != rate_flags) in ieee80211_build_preq_ies_band()
1811 (u8) DIV_ROUND_UP(sband->bitrates[i].bitrate, in ieee80211_build_preq_ies_band()
1817 if (end - pos < 2 + supp_rates_len) in ieee80211_build_preq_ies_band()
1835 if (end - pos < noffset - *offset) in ieee80211_build_preq_ies_band()
1837 memcpy(pos, ie + *offset, noffset - *offset); in ieee80211_build_preq_ies_band()
1838 pos += noffset - *offset; in ieee80211_build_preq_ies_band()
1842 ext_rates_len = num_rates - supp_rates_len; in ieee80211_build_preq_ies_band()
1844 if (end - pos < 2 + ext_rates_len) in ieee80211_build_preq_ies_band()
1852 if (chandef->chan && sband->band == NL80211_BAND_2GHZ) { in ieee80211_build_preq_ies_band()
1853 if (end - pos < 3) in ieee80211_build_preq_ies_band()
1858 chandef->chan->center_freq); in ieee80211_build_preq_ies_band()
1877 if (end - pos < noffset - *offset) in ieee80211_build_preq_ies_band()
1879 memcpy(pos, ie + *offset, noffset - *offset); in ieee80211_build_preq_ies_band()
1880 pos += noffset - *offset; in ieee80211_build_preq_ies_band()
1884 if (sband->ht_cap.ht_supported) { in ieee80211_build_preq_ies_band()
1885 if (end - pos < 2 + sizeof(struct ieee80211_ht_cap)) in ieee80211_build_preq_ies_band()
1887 pos = ieee80211_ie_build_ht_cap(pos, &sband->ht_cap, in ieee80211_build_preq_ies_band()
1888 sband->ht_cap.cap); in ieee80211_build_preq_ies_band()
1904 /* 60 GHz (Multi-band, DMG, MMS) can't happen */ in ieee80211_build_preq_ies_band()
1909 if (end - pos < noffset - *offset) in ieee80211_build_preq_ies_band()
1911 memcpy(pos, ie + *offset, noffset - *offset); in ieee80211_build_preq_ies_band()
1912 pos += noffset - *offset; in ieee80211_build_preq_ies_band()
1917 for (i = 0; i < sband->n_channels; i++) { in ieee80211_build_preq_ies_band()
1918 if (sband->channels[i].flags & (IEEE80211_CHAN_DISABLED | in ieee80211_build_preq_ies_band()
1926 if (sband->vht_cap.vht_supported && have_80mhz) { in ieee80211_build_preq_ies_band()
1927 if (end - pos < 2 + sizeof(struct ieee80211_vht_cap)) in ieee80211_build_preq_ies_band()
1929 pos = ieee80211_ie_build_vht_cap(pos, &sband->vht_cap, in ieee80211_build_preq_ies_band()
1930 sband->vht_cap.cap); in ieee80211_build_preq_ies_band()
1947 if (end - pos < noffset - *offset) in ieee80211_build_preq_ies_band()
1949 memcpy(pos, ie + *offset, noffset - *offset); in ieee80211_build_preq_ies_band()
1950 pos += noffset - *offset; in ieee80211_build_preq_ies_band()
1960 if (sband->band == NL80211_BAND_6GHZ) { in ieee80211_build_preq_ies_band()
1962 ieee80211_vif_type_p2p(&sdata->vif); in ieee80211_build_preq_ies_band()
1971 * that calculates local->scan_ies_len. in ieee80211_build_preq_ies_band()
1974 return pos - buffer; in ieee80211_build_preq_ies_band()
1978 return pos - buffer; in ieee80211_build_preq_ies_band()
1998 buffer_len - pos, in ieee80211_build_preq_ies()
2004 ie_desc->ies[i] = buffer + old_pos; in ieee80211_build_preq_ies()
2005 ie_desc->len[i] = pos - old_pos; in ieee80211_build_preq_ies()
2012 if (WARN_ONCE(buffer_len - pos < ie_len - custom_ie_offset, in ieee80211_build_preq_ies()
2016 ie_len - custom_ie_offset); in ieee80211_build_preq_ies()
2017 ie_desc->common_ies = buffer + pos; in ieee80211_build_preq_ies()
2018 ie_desc->common_ie_len = ie_len - custom_ie_offset; in ieee80211_build_preq_ies()
2019 pos += ie_len - custom_ie_offset; in ieee80211_build_preq_ies()
2033 struct ieee80211_local *local = sdata->local; in ieee80211_build_probe_req()
2044 * badly-behaved APs don't respond when this parameter is included. in ieee80211_build_probe_req()
2046 chandef.width = sdata->vif.bss_conf.chandef.width; in ieee80211_build_probe_req()
2052 skb = ieee80211_probereq_get(&local->hw, src, ssid, ssid_len, in ieee80211_build_probe_req()
2057 rate_masks[chan->band] = ratemask; in ieee80211_build_probe_req()
2060 ie, ie_len, BIT(chan->band), in ieee80211_build_probe_req()
2065 mgmt = (struct ieee80211_mgmt *) skb->data; in ieee80211_build_probe_req()
2066 memcpy(mgmt->da, dst, ETH_ALEN); in ieee80211_build_probe_req()
2067 memcpy(mgmt->bssid, dst, ETH_ALEN); in ieee80211_build_probe_req()
2070 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; in ieee80211_build_probe_req()
2084 sband = sdata->local->hw.wiphy->bands[band]; in ieee80211_sta_get_rates()
2088 rate_flags = ieee80211_chandef_rate_flags(&sdata->vif.bss_conf.chandef); in ieee80211_sta_get_rates()
2089 shift = ieee80211_vif_get_shift(&sdata->vif); in ieee80211_sta_get_rates()
2091 num_rates = sband->n_bitrates; in ieee80211_sta_get_rates()
2093 for (i = 0; i < elems->supp_rates_len + in ieee80211_sta_get_rates()
2094 elems->ext_supp_rates_len; i++) { in ieee80211_sta_get_rates()
2098 if (i < elems->supp_rates_len) in ieee80211_sta_get_rates()
2099 rate = elems->supp_rates[i]; in ieee80211_sta_get_rates()
2100 else if (elems->ext_supp_rates) in ieee80211_sta_get_rates()
2101 rate = elems->ext_supp_rates in ieee80211_sta_get_rates()
2102 [i - elems->supp_rates_len]; in ieee80211_sta_get_rates()
2111 if ((rate_flags & sband->bitrates[j].flags) in ieee80211_sta_get_rates()
2115 brate = DIV_ROUND_UP(sband->bitrates[j].bitrate, in ieee80211_sta_get_rates()
2133 cancel_work_sync(&local->reconfig_filter); in ieee80211_stop_device()
2135 flush_workqueue(local->workqueue); in ieee80211_stop_device()
2149 if (test_bit(SCAN_COMPLETED, &local->scanning)) { in ieee80211_flush_completed_scan()
2151 * we don't attempt to continue a partial HW scan - which is in ieee80211_flush_completed_scan()
2156 set_bit(SCAN_ABORTED, &local->scanning); in ieee80211_flush_completed_scan()
2157 ieee80211_queue_delayed_work(&local->hw, &local->scan_work, 0); in ieee80211_flush_completed_scan()
2158 flush_delayed_work(&local->scan_work); in ieee80211_flush_completed_scan()
2177 local->resuming = false; in ieee80211_handle_reconfig_failure()
2178 local->suspended = false; in ieee80211_handle_reconfig_failure()
2179 local->in_reconfig = false; in ieee80211_handle_reconfig_failure()
2188 list_for_each_entry(sdata, &local->interfaces, list) in ieee80211_handle_reconfig_failure()
2189 sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER; in ieee80211_handle_reconfig_failure()
2194 mutex_lock(&local->chanctx_mtx); in ieee80211_handle_reconfig_failure()
2195 list_for_each_entry(ctx, &local->chanctx_list, list) in ieee80211_handle_reconfig_failure()
2196 ctx->driver_present = false; in ieee80211_handle_reconfig_failure()
2197 mutex_unlock(&local->chanctx_mtx); in ieee80211_handle_reconfig_failure()
2199 cfg80211_shutdown_all_interfaces(local->hw.wiphy); in ieee80211_handle_reconfig_failure()
2208 if (!local->use_chanctx) in ieee80211_assign_chanctx()
2211 mutex_lock(&local->chanctx_mtx); in ieee80211_assign_chanctx()
2212 conf = rcu_dereference_protected(sdata->vif.chanctx_conf, in ieee80211_assign_chanctx()
2213 lockdep_is_held(&local->chanctx_mtx)); in ieee80211_assign_chanctx()
2218 mutex_unlock(&local->chanctx_mtx); in ieee80211_assign_chanctx()
2223 struct ieee80211_local *local = sdata->local; in ieee80211_reconfig_stations()
2227 mutex_lock(&local->sta_mtx); in ieee80211_reconfig_stations()
2228 list_for_each_entry(sta, &local->sta_list, list) { in ieee80211_reconfig_stations()
2231 if (!sta->uploaded || sta->sdata != sdata) in ieee80211_reconfig_stations()
2235 state < sta->sta_state; state++) in ieee80211_reconfig_stations()
2236 WARN_ON(drv_sta_state(local, sta->sdata, sta, state, in ieee80211_reconfig_stations()
2239 mutex_unlock(&local->sta_mtx); in ieee80211_reconfig_stations()
2247 res = drv_start_nan(sdata->local, sdata, in ieee80211_reconfig_nan()
2248 &sdata->u.nan.conf); in ieee80211_reconfig_nan()
2252 funcs = kcalloc(sdata->local->hw.max_nan_de_entries + 1, in ieee80211_reconfig_nan()
2256 return -ENOMEM; in ieee80211_reconfig_nan()
2262 spin_lock_bh(&sdata->u.nan.func_lock); in ieee80211_reconfig_nan()
2264 idr_for_each_entry(&sdata->u.nan.function_inst_ids, func, id) in ieee80211_reconfig_nan()
2267 spin_unlock_bh(&sdata->u.nan.func_lock); in ieee80211_reconfig_nan()
2270 res = drv_add_nan_func(sdata->local, sdata, funcs[i]); in ieee80211_reconfig_nan()
2272 ieee80211_nan_func_terminated(&sdata->vif, in ieee80211_reconfig_nan()
2273 funcs[i]->instance_id, in ieee80211_reconfig_nan()
2285 struct ieee80211_hw *hw = &local->hw; in ieee80211_reconfig()
2294 bool suspended = local->suspended; in ieee80211_reconfig()
2297 if (!local->open_count) in ieee80211_reconfig()
2302 local->resuming = true; in ieee80211_reconfig()
2304 if (local->wowlan) { in ieee80211_reconfig()
2308 * clear local->suspended so the device could operate in ieee80211_reconfig()
2311 local->suspended = false; in ieee80211_reconfig()
2313 local->wowlan = false; in ieee80211_reconfig()
2315 local->resuming = false; in ieee80211_reconfig()
2324 * restore local->suspended in this case. in ieee80211_reconfig()
2327 local->suspended = true; in ieee80211_reconfig()
2338 if (suspended && local->in_reconfig && !reconfig_due_to_wowlan) in ieee80211_reconfig()
2339 cancel_work_sync(&local->restart_work); in ieee80211_reconfig()
2341 local->started = false; in ieee80211_reconfig()
2360 drv_set_frag_threshold(local, hw->wiphy->frag_threshold); in ieee80211_reconfig()
2363 drv_set_rts_threshold(local, hw->wiphy->rts_threshold); in ieee80211_reconfig()
2366 drv_set_coverage_class(local, hw->wiphy->coverage_class); in ieee80211_reconfig()
2373 sdata = rtnl_dereference(local->monitor_sdata); in ieee80211_reconfig()
2376 WARN_ON(local->resuming); in ieee80211_reconfig()
2379 RCU_INIT_POINTER(local->monitor_sdata, NULL); in ieee80211_reconfig()
2385 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_reconfig()
2386 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN && in ieee80211_reconfig()
2387 sdata->vif.type != NL80211_IFTYPE_MONITOR && in ieee80211_reconfig()
2399 list_for_each_entry_continue_reverse(sdata, &local->interfaces, in ieee80211_reconfig()
2401 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN && in ieee80211_reconfig()
2402 sdata->vif.type != NL80211_IFTYPE_MONITOR && in ieee80211_reconfig()
2410 if (local->use_chanctx) { in ieee80211_reconfig()
2411 mutex_lock(&local->chanctx_mtx); in ieee80211_reconfig()
2412 list_for_each_entry(ctx, &local->chanctx_list, list) in ieee80211_reconfig()
2413 if (ctx->replace_state != in ieee80211_reconfig()
2416 mutex_unlock(&local->chanctx_mtx); in ieee80211_reconfig()
2418 sdata = rtnl_dereference(local->monitor_sdata); in ieee80211_reconfig()
2429 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_reconfig()
2437 switch (sdata->vif.type) { in ieee80211_reconfig()
2442 if (sdata->vif.bss_conf.ibss_joined) in ieee80211_reconfig()
2451 &sdata->tx_conf[i]); in ieee80211_reconfig()
2469 if (sdata->vif.mu_mimo_owner) in ieee80211_reconfig()
2472 switch (sdata->vif.type) { in ieee80211_reconfig()
2478 /* Re-send beacon info report to the driver */ in ieee80211_reconfig()
2479 if (sdata->u.mgd.have_beacon) in ieee80211_reconfig()
2482 if (sdata->vif.bss_conf.max_idle_period || in ieee80211_reconfig()
2483 sdata->vif.bss_conf.protected_keep_alive) in ieee80211_reconfig()
2500 if (sdata->vif.bss_conf.ftm_responder == 1 && in ieee80211_reconfig()
2501 wiphy_ext_feature_isset(sdata->local->hw.wiphy, in ieee80211_reconfig()
2505 if (sdata->vif.type == NL80211_IFTYPE_AP) { in ieee80211_reconfig()
2508 if (rcu_access_pointer(sdata->u.ap.beacon)) in ieee80211_reconfig()
2513 if (sdata->vif.bss_conf.enable_beacon) { in ieee80211_reconfig()
2549 if (!(local->hw.conf.flags & IEEE80211_CONF_PS)) { in ieee80211_reconfig()
2550 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_reconfig()
2551 if (sdata->vif.type != NL80211_IFTYPE_STATION) in ieee80211_reconfig()
2553 if (!sdata->u.mgd.associated) in ieee80211_reconfig()
2561 mutex_lock(&local->sta_mtx); in ieee80211_reconfig()
2562 list_for_each_entry(sta, &local->sta_list, list) { in ieee80211_reconfig()
2565 if (!sta->uploaded) in ieee80211_reconfig()
2568 if (sta->sdata->vif.type != NL80211_IFTYPE_AP && in ieee80211_reconfig()
2569 sta->sdata->vif.type != NL80211_IFTYPE_AP_VLAN) in ieee80211_reconfig()
2573 state < sta->sta_state; state++) in ieee80211_reconfig()
2574 WARN_ON(drv_sta_state(local, sta->sdata, sta, state, in ieee80211_reconfig()
2577 mutex_unlock(&local->sta_mtx); in ieee80211_reconfig()
2580 list_for_each_entry(sdata, &local->interfaces, list) in ieee80211_reconfig()
2584 mutex_lock(&local->mtx); in ieee80211_reconfig()
2585 sched_scan_sdata = rcu_dereference_protected(local->sched_scan_sdata, in ieee80211_reconfig()
2586 lockdep_is_held(&local->mtx)); in ieee80211_reconfig()
2587 sched_scan_req = rcu_dereference_protected(local->sched_scan_req, in ieee80211_reconfig()
2588 lockdep_is_held(&local->mtx)); in ieee80211_reconfig()
2597 if (sched_scan_req->n_scan_plans > 1 || in ieee80211_reconfig()
2600 RCU_INIT_POINTER(local->sched_scan_sdata, NULL); in ieee80211_reconfig()
2601 RCU_INIT_POINTER(local->sched_scan_req, NULL); in ieee80211_reconfig()
2604 mutex_unlock(&local->mtx); in ieee80211_reconfig()
2607 cfg80211_sched_scan_stopped_rtnl(local->hw.wiphy, 0); in ieee80211_reconfig()
2611 if (local->monitors == local->open_count && local->monitors > 0) in ieee80211_reconfig()
2625 mutex_lock(&local->sta_mtx); in ieee80211_reconfig()
2627 list_for_each_entry(sta, &local->sta_list, list) { in ieee80211_reconfig()
2628 if (!local->resuming) in ieee80211_reconfig()
2634 mutex_unlock(&local->sta_mtx); in ieee80211_reconfig()
2637 if (local->in_reconfig) { in ieee80211_reconfig()
2638 local->in_reconfig = false; in ieee80211_reconfig()
2642 mutex_lock(&local->mtx); in ieee80211_reconfig()
2644 mutex_unlock(&local->mtx); in ieee80211_reconfig()
2647 list_for_each_entry(sdata, &local->interfaces, list) in ieee80211_reconfig()
2648 ieee80211_queue_work(&local->hw, &sdata->work); in ieee80211_reconfig()
2659 if (local->open_count && (!suspended || reconfig_due_to_wowlan)) in ieee80211_reconfig()
2667 local->suspended = false; in ieee80211_reconfig()
2669 local->resuming = false; in ieee80211_reconfig()
2673 if (local->open_count && !reconfig_due_to_wowlan) in ieee80211_reconfig()
2676 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_reconfig()
2679 if (sdata->vif.type == NL80211_IFTYPE_STATION) in ieee80211_reconfig()
2683 mod_timer(&local->sta_cleanup, jiffies + 1); in ieee80211_reconfig()
2701 local = sdata->local; in ieee80211_resume_disconnect()
2703 if (WARN_ON(!local->resuming)) in ieee80211_resume_disconnect()
2706 if (WARN_ON(vif->type != NL80211_IFTYPE_STATION)) in ieee80211_resume_disconnect()
2709 sdata->flags |= IEEE80211_SDATA_DISCONNECT_RESUME; in ieee80211_resume_disconnect()
2711 mutex_lock(&local->key_mtx); in ieee80211_resume_disconnect()
2712 list_for_each_entry(key, &sdata->key_list, list) in ieee80211_resume_disconnect()
2713 key->flags |= KEY_FLAG_TAINTED; in ieee80211_resume_disconnect()
2714 mutex_unlock(&local->key_mtx); in ieee80211_resume_disconnect()
2720 struct ieee80211_local *local = sdata->local; in ieee80211_recalc_smps()
2724 mutex_lock(&local->chanctx_mtx); in ieee80211_recalc_smps()
2726 chanctx_conf = rcu_dereference_protected(sdata->vif.chanctx_conf, in ieee80211_recalc_smps()
2727 lockdep_is_held(&local->chanctx_mtx)); in ieee80211_recalc_smps()
2741 mutex_unlock(&local->chanctx_mtx); in ieee80211_recalc_smps()
2746 struct ieee80211_local *local = sdata->local; in ieee80211_recalc_min_chandef()
2750 mutex_lock(&local->chanctx_mtx); in ieee80211_recalc_min_chandef()
2752 chanctx_conf = rcu_dereference_protected(sdata->vif.chanctx_conf, in ieee80211_recalc_min_chandef()
2753 lockdep_is_held(&local->chanctx_mtx)); in ieee80211_recalc_min_chandef()
2761 mutex_unlock(&local->chanctx_mtx); in ieee80211_recalc_min_chandef()
2780 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION)) in _ieee80211_enable_rssi_reports()
2788 sdata->u.mgd.rssi_min_thold = rssi_min_thold*16; in _ieee80211_enable_rssi_reports()
2789 sdata->u.mgd.rssi_max_thold = rssi_max_thold*16; in _ieee80211_enable_rssi_reports()
2829 *pos++ = ht_cap->ampdu_factor | in ieee80211_ie_build_ht_cap()
2830 (ht_cap->ampdu_density << in ieee80211_ie_build_ht_cap()
2834 memcpy(pos, &ht_cap->mcs, sizeof(ht_cap->mcs)); in ieee80211_ie_build_ht_cap()
2835 pos += sizeof(ht_cap->mcs); in ieee80211_ie_build_ht_cap()
2864 memcpy(pos, &vht_cap->vht_mcs, sizeof(vht_cap->vht_mcs)); in ieee80211_ie_build_vht_cap()
2865 pos += sizeof(vht_cap->vht_mcs); in ieee80211_ie_build_vht_cap()
2884 n = ieee80211_he_mcs_nss_size(&he_cap->he_cap_elem); in ieee80211_ie_len_he_cap()
2886 sizeof(he_cap->he_cap_elem) + n + in ieee80211_ie_len_he_cap()
2887 ieee80211_he_ppe_size(he_cap->ppe_thres[0], in ieee80211_ie_len_he_cap()
2888 he_cap->he_cap_elem.phy_cap_info); in ieee80211_ie_len_he_cap()
2907 n = ieee80211_he_mcs_nss_size(&he_cap->he_cap_elem); in ieee80211_ie_build_he_cap()
2909 sizeof(he_cap->he_cap_elem) + n + in ieee80211_ie_build_he_cap()
2910 ieee80211_he_ppe_size(he_cap->ppe_thres[0], in ieee80211_ie_build_he_cap()
2911 he_cap->he_cap_elem.phy_cap_info); in ieee80211_ie_build_he_cap()
2913 if ((end - pos) < ie_len) in ieee80211_ie_build_he_cap()
2921 memcpy(pos, &he_cap->he_cap_elem, sizeof(he_cap->he_cap_elem)); in ieee80211_ie_build_he_cap()
2922 pos += sizeof(he_cap->he_cap_elem); in ieee80211_ie_build_he_cap()
2924 memcpy(pos, &he_cap->he_mcs_nss_supp, n); in ieee80211_ie_build_he_cap()
2928 if ((he_cap->he_cap_elem.phy_cap_info[6] & in ieee80211_ie_build_he_cap()
2936 n = hweight8(he_cap->ppe_thres[0] & in ieee80211_ie_build_he_cap()
2938 n *= (1 + ((he_cap->ppe_thres[0] & IEEE80211_PPE_THRES_NSS_MASK) >> in ieee80211_ie_build_he_cap()
2949 memcpy(pos, &he_cap->ppe_thres, n); in ieee80211_ie_build_he_cap()
2953 orig_pos[1] = (pos - orig_pos) - 2; in ieee80211_ie_build_he_cap()
2962 enum nl80211_iftype iftype = ieee80211_vif_type_p2p(&sdata->vif); in ieee80211_ie_build_he_6ghz_cap()
2975 if (!iftd->he_6ghz_capa.capa) in ieee80211_ie_build_he_6ghz_cap()
2978 cap = le16_to_cpu(iftd->he_6ghz_capa.capa); in ieee80211_ie_build_he_6ghz_cap()
2981 switch (sdata->smps_mode) { in ieee80211_ie_build_he_6ghz_cap()
3014 ht_oper->primary_chan = ieee80211_frequency_to_channel( in ieee80211_ie_build_ht_oper()
3015 chandef->chan->center_freq); in ieee80211_ie_build_ht_oper()
3016 switch (chandef->width) { in ieee80211_ie_build_ht_oper()
3021 if (chandef->center_freq1 > chandef->chan->center_freq) in ieee80211_ie_build_ht_oper()
3022 ht_oper->ht_param = IEEE80211_HT_PARAM_CHA_SEC_ABOVE; in ieee80211_ie_build_ht_oper()
3024 ht_oper->ht_param = IEEE80211_HT_PARAM_CHA_SEC_BELOW; in ieee80211_ie_build_ht_oper()
3027 ht_oper->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE; in ieee80211_ie_build_ht_oper()
3030 if (ht_cap->cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40 && in ieee80211_ie_build_ht_oper()
3031 chandef->width != NL80211_CHAN_WIDTH_20_NOHT && in ieee80211_ie_build_ht_oper()
3032 chandef->width != NL80211_CHAN_WIDTH_20) in ieee80211_ie_build_ht_oper()
3033 ht_oper->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY; in ieee80211_ie_build_ht_oper()
3036 ht_oper->ht_param |= IEEE80211_HT_PARAM_RIFS_MODE; in ieee80211_ie_build_ht_oper()
3038 ht_oper->operation_mode = cpu_to_le16(prot_mode); in ieee80211_ie_build_ht_oper()
3039 ht_oper->stbc_param = 0x0000; in ieee80211_ie_build_ht_oper()
3043 memset(&ht_oper->basic_set, 0, 16); in ieee80211_ie_build_ht_oper()
3044 memcpy(&ht_oper->basic_set, &ht_cap->mcs, 10); in ieee80211_ie_build_ht_oper()
3055 switch (chandef->width) { in ieee80211_ie_build_wide_bw_cs()
3070 *pos++ = ieee80211_frequency_to_channel(chandef->center_freq1); in ieee80211_ie_build_wide_bw_cs()
3072 if (chandef->center_freq2) in ieee80211_ie_build_wide_bw_cs()
3073 *pos++ = ieee80211_frequency_to_channel(chandef->center_freq2); in ieee80211_ie_build_wide_bw_cs()
3086 vht_oper->center_freq_seg0_idx = ieee80211_frequency_to_channel( in ieee80211_ie_build_vht_oper()
3087 chandef->center_freq1); in ieee80211_ie_build_vht_oper()
3088 if (chandef->center_freq2) in ieee80211_ie_build_vht_oper()
3089 vht_oper->center_freq_seg1_idx = in ieee80211_ie_build_vht_oper()
3090 ieee80211_frequency_to_channel(chandef->center_freq2); in ieee80211_ie_build_vht_oper()
3092 vht_oper->center_freq_seg1_idx = 0x00; in ieee80211_ie_build_vht_oper()
3094 switch (chandef->width) { in ieee80211_ie_build_vht_oper()
3100 vht_oper->chan_width = IEEE80211_VHT_CHANWIDTH_80MHZ; in ieee80211_ie_build_vht_oper()
3101 vht_oper->center_freq_seg1_idx = vht_oper->center_freq_seg0_idx; in ieee80211_ie_build_vht_oper()
3102 if (chandef->chan->center_freq < chandef->center_freq1) in ieee80211_ie_build_vht_oper()
3103 vht_oper->center_freq_seg0_idx -= 8; in ieee80211_ie_build_vht_oper()
3105 vht_oper->center_freq_seg0_idx += 8; in ieee80211_ie_build_vht_oper()
3112 vht_oper->chan_width = IEEE80211_VHT_CHANWIDTH_80MHZ; in ieee80211_ie_build_vht_oper()
3115 vht_oper->chan_width = IEEE80211_VHT_CHANWIDTH_80MHZ; in ieee80211_ie_build_vht_oper()
3118 vht_oper->chan_width = IEEE80211_VHT_CHANWIDTH_USE_HT; in ieee80211_ie_build_vht_oper()
3123 vht_oper->basic_mcs_set = cpu_to_le16(0xffff); in ieee80211_ie_build_vht_oper()
3135 if (chandef->chan->band == NL80211_BAND_6GHZ) in ieee80211_ie_build_he_oper()
3149 if (chandef->chan->band == NL80211_BAND_6GHZ) in ieee80211_ie_build_he_oper()
3154 he_oper->he_oper_params = cpu_to_le32(he_oper_params); in ieee80211_ie_build_he_oper()
3157 he_oper->he_mcs_nss_set = cpu_to_le16(0xffff); in ieee80211_ie_build_he_oper()
3160 if (chandef->chan->band != NL80211_BAND_6GHZ) in ieee80211_ie_build_he_oper()
3165 he_6ghz_op->minrate = 6; /* 6 Mbps */ in ieee80211_ie_build_he_oper()
3166 he_6ghz_op->primary = in ieee80211_ie_build_he_oper()
3167 ieee80211_frequency_to_channel(chandef->chan->center_freq); in ieee80211_ie_build_he_oper()
3168 he_6ghz_op->ccfs0 = in ieee80211_ie_build_he_oper()
3169 ieee80211_frequency_to_channel(chandef->center_freq1); in ieee80211_ie_build_he_oper()
3170 if (chandef->center_freq2) in ieee80211_ie_build_he_oper()
3171 he_6ghz_op->ccfs1 = in ieee80211_ie_build_he_oper()
3172 ieee80211_frequency_to_channel(chandef->center_freq2); in ieee80211_ie_build_he_oper()
3174 he_6ghz_op->ccfs1 = 0; in ieee80211_ie_build_he_oper()
3176 switch (chandef->width) { in ieee80211_ie_build_he_oper()
3181 he_6ghz_op->control = in ieee80211_ie_build_he_oper()
3183 he_6ghz_op->ccfs1 = he_6ghz_op->ccfs0; in ieee80211_ie_build_he_oper()
3184 if (chandef->chan->center_freq < chandef->center_freq1) in ieee80211_ie_build_he_oper()
3185 he_6ghz_op->ccfs0 -= 8; in ieee80211_ie_build_he_oper()
3187 he_6ghz_op->ccfs0 += 8; in ieee80211_ie_build_he_oper()
3190 he_6ghz_op->control = in ieee80211_ie_build_he_oper()
3194 he_6ghz_op->control = in ieee80211_ie_build_he_oper()
3198 he_6ghz_op->control = in ieee80211_ie_build_he_oper()
3202 he_6ghz_op->control = in ieee80211_ie_build_he_oper()
3221 switch (ht_oper->ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET) { in ieee80211_chandef_ht_oper()
3236 cfg80211_chandef_create(chandef, chandef->chan, channel_type); in ieee80211_chandef_ht_oper()
3260 vht_cap = hw->wiphy->bands[chandef->chan->band]->vht_cap.cap; in ieee80211_chandef_vht_oper()
3269 ccfs0 = oper->center_freq_seg0_idx; in ieee80211_chandef_vht_oper()
3270 ccfs1 = oper->center_freq_seg1_idx; in ieee80211_chandef_vht_oper()
3271 ccfs2 = (le16_to_cpu(htop->operation_mode) & in ieee80211_chandef_vht_oper()
3282 * Cf. IEEE 802.11 Table 9-250 in ieee80211_chandef_vht_oper()
3318 cf0 = ieee80211_channel_to_frequency(ccf0, chandef->chan->band); in ieee80211_chandef_vht_oper()
3319 cf1 = ieee80211_channel_to_frequency(ccf1, chandef->chan->band); in ieee80211_chandef_vht_oper()
3321 switch (oper->chan_width) { in ieee80211_chandef_vht_oper()
3332 diff = abs(ccf1 - ccf0); in ieee80211_chandef_vht_oper()
3368 struct ieee80211_local *local = sdata->local; in ieee80211_chandef_he_6ghz_oper()
3370 enum nl80211_iftype iftype = ieee80211_vif_type_p2p(&sdata->vif); in ieee80211_chandef_he_6ghz_oper()
3378 if (chandef->chan->band != NL80211_BAND_6GHZ) in ieee80211_chandef_he_6ghz_oper()
3381 sband = local->hw.wiphy->bands[NL80211_BAND_6GHZ]; in ieee80211_chandef_he_6ghz_oper()
3389 he_phy_cap = he_cap->he_cap_elem.phy_cap_info[0]; in ieee80211_chandef_he_6ghz_oper()
3400 chandef->chan->center_freq); in ieee80211_chandef_he_6ghz_oper()
3409 chandef->chan->center_freq); in ieee80211_chandef_he_6ghz_oper()
3413 freq = ieee80211_channel_to_frequency(he_6ghz_oper->primary, in ieee80211_chandef_he_6ghz_oper()
3415 he_chandef.chan = ieee80211_get_channel(sdata->local->hw.wiphy, freq); in ieee80211_chandef_he_6ghz_oper()
3417 switch (u8_get_bits(he_6ghz_oper->control, in ieee80211_chandef_he_6ghz_oper()
3430 if (!he_6ghz_oper->ccfs1) in ieee80211_chandef_he_6ghz_oper()
3432 if (abs(he_6ghz_oper->ccfs1 - he_6ghz_oper->ccfs0) == 8) { in ieee80211_chandef_he_6ghz_oper()
3444 ieee80211_channel_to_frequency(he_6ghz_oper->ccfs1, in ieee80211_chandef_he_6ghz_oper()
3448 ieee80211_channel_to_frequency(he_6ghz_oper->ccfs0, in ieee80211_chandef_he_6ghz_oper()
3452 ieee80211_channel_to_frequency(he_6ghz_oper->ccfs1, in ieee80211_chandef_he_6ghz_oper()
3459 he_chandef.chan ? he_chandef.chan->center_freq : 0, in ieee80211_chandef_he_6ghz_oper()
3479 switch (FIELD_GET(S1G_OPER_CH_WIDTH_OPER, oper->ch_width)) { in ieee80211_chandef_s1g_oper()
3481 chandef->width = NL80211_CHAN_WIDTH_1; in ieee80211_chandef_s1g_oper()
3484 chandef->width = NL80211_CHAN_WIDTH_2; in ieee80211_chandef_s1g_oper()
3487 chandef->width = NL80211_CHAN_WIDTH_4; in ieee80211_chandef_s1g_oper()
3490 chandef->width = NL80211_CHAN_WIDTH_8; in ieee80211_chandef_s1g_oper()
3493 chandef->width = NL80211_CHAN_WIDTH_16; in ieee80211_chandef_s1g_oper()
3499 oper_freq = ieee80211_channel_to_freq_khz(oper->oper_ch, in ieee80211_chandef_s1g_oper()
3501 chandef->center_freq1 = KHZ_TO_MHZ(oper_freq); in ieee80211_chandef_s1g_oper()
3502 chandef->freq1_offset = oper_freq % 1000; in ieee80211_chandef_s1g_oper()
3521 for (j = 0; j < sband->n_bitrates; j++) { in ieee80211_parse_bitrates()
3522 br = &sband->bitrates[j]; in ieee80211_parse_bitrates()
3523 if ((rate_flags & br->flags) != rate_flags) in ieee80211_parse_bitrates()
3526 brate = DIV_ROUND_UP(br->bitrate, (1 << shift) * 5); in ieee80211_parse_bitrates()
3541 struct ieee80211_local *local = sdata->local; in ieee80211_add_srates_ie()
3545 u32 basic_rates = sdata->vif.bss_conf.basic_rates; in ieee80211_add_srates_ie()
3548 shift = ieee80211_vif_get_shift(&sdata->vif); in ieee80211_add_srates_ie()
3549 rate_flags = ieee80211_chandef_rate_flags(&sdata->vif.bss_conf.chandef); in ieee80211_add_srates_ie()
3550 sband = local->hw.wiphy->bands[band]; in ieee80211_add_srates_ie()
3552 for (i = 0; i < sband->n_bitrates; i++) { in ieee80211_add_srates_ie()
3553 if ((rate_flags & sband->bitrates[i].flags) != rate_flags) in ieee80211_add_srates_ie()
3561 return -ENOMEM; in ieee80211_add_srates_ie()
3568 if ((rate_flags & sband->bitrates[i].flags) != rate_flags) in ieee80211_add_srates_ie()
3573 rate = DIV_ROUND_UP(sband->bitrates[i].bitrate, in ieee80211_add_srates_ie()
3585 struct ieee80211_local *local = sdata->local; in ieee80211_add_ext_srates_ie()
3589 u32 basic_rates = sdata->vif.bss_conf.basic_rates; in ieee80211_add_ext_srates_ie()
3592 rate_flags = ieee80211_chandef_rate_flags(&sdata->vif.bss_conf.chandef); in ieee80211_add_ext_srates_ie()
3593 shift = ieee80211_vif_get_shift(&sdata->vif); in ieee80211_add_ext_srates_ie()
3595 sband = local->hw.wiphy->bands[band]; in ieee80211_add_ext_srates_ie()
3597 for (i = 0; i < sband->n_bitrates; i++) { in ieee80211_add_ext_srates_ie()
3598 if ((rate_flags & sband->bitrates[i].flags) != rate_flags) in ieee80211_add_ext_srates_ie()
3604 exrates -= 8; in ieee80211_add_ext_srates_ie()
3609 return -ENOMEM; in ieee80211_add_ext_srates_ie()
3615 for (i = 8; i < sband->n_bitrates; i++) { in ieee80211_add_ext_srates_ie()
3617 if ((rate_flags & sband->bitrates[i].flags) in ieee80211_add_ext_srates_ie()
3622 rate = DIV_ROUND_UP(sband->bitrates[i].bitrate, in ieee80211_add_ext_srates_ie()
3633 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_ave_rssi()
3635 if (WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION)) { in ieee80211_ave_rssi()
3636 /* non-managed type inferfaces */ in ieee80211_ave_rssi()
3639 return -ewma_beacon_signal_read(&ifmgd->ave_beacon_signal); in ieee80211_ave_rssi()
3650 if (mcs->rx_mask[3]) in ieee80211_mcs_to_chains()
3652 if (mcs->rx_mask[2]) in ieee80211_mcs_to_chains()
3654 if (mcs->rx_mask[1]) in ieee80211_mcs_to_chains()
3660 * ieee80211_calculate_rx_timestamp - calculate timestamp in frame
3675 u64 ts = status->mactime; in ieee80211_calculate_rx_timestamp()
3676 struct rate_info ri; in ieee80211_calculate_rx_timestamp() local
3682 memset(&ri, 0, sizeof(ri)); in ieee80211_calculate_rx_timestamp()
3684 ri.bw = status->bw; in ieee80211_calculate_rx_timestamp()
3687 switch (status->encoding) { in ieee80211_calculate_rx_timestamp()
3689 ri.mcs = status->rate_idx; in ieee80211_calculate_rx_timestamp()
3690 ri.flags |= RATE_INFO_FLAGS_MCS; in ieee80211_calculate_rx_timestamp()
3691 if (status->enc_flags & RX_ENC_FLAG_SHORT_GI) in ieee80211_calculate_rx_timestamp()
3692 ri.flags |= RATE_INFO_FLAGS_SHORT_GI; in ieee80211_calculate_rx_timestamp()
3695 ri.flags |= RATE_INFO_FLAGS_VHT_MCS; in ieee80211_calculate_rx_timestamp()
3696 ri.mcs = status->rate_idx; in ieee80211_calculate_rx_timestamp()
3697 ri.nss = status->nss; in ieee80211_calculate_rx_timestamp()
3698 if (status->enc_flags & RX_ENC_FLAG_SHORT_GI) in ieee80211_calculate_rx_timestamp()
3699 ri.flags |= RATE_INFO_FLAGS_SHORT_GI; in ieee80211_calculate_rx_timestamp()
3709 switch (status->bw) { in ieee80211_calculate_rx_timestamp()
3718 sband = local->hw.wiphy->bands[status->band]; in ieee80211_calculate_rx_timestamp()
3719 bitrate = sband->bitrates[status->rate_idx].bitrate; in ieee80211_calculate_rx_timestamp()
3720 ri.legacy = DIV_ROUND_UP(bitrate, (1 << shift)); in ieee80211_calculate_rx_timestamp()
3722 if (status->flag & RX_FLAG_MACTIME_PLCP_START) { in ieee80211_calculate_rx_timestamp()
3724 if (status->band == NL80211_BAND_5GHZ) { in ieee80211_calculate_rx_timestamp()
3727 } else if (status->enc_flags & RX_ENC_FLAG_SHORTPRE) { in ieee80211_calculate_rx_timestamp()
3737 rate = cfg80211_calculate_bitrate(&ri); in ieee80211_calculate_rx_timestamp()
3740 (unsigned long long)status->flag, status->rate_idx, in ieee80211_calculate_rx_timestamp()
3741 status->nss)) in ieee80211_calculate_rx_timestamp()
3745 if (status->flag & RX_FLAG_MACTIME_END) in ieee80211_calculate_rx_timestamp()
3746 ts -= mpdu_len * 8 * 10 / rate; in ieee80211_calculate_rx_timestamp()
3761 mutex_lock(&local->mtx); in ieee80211_dfs_cac_cancel()
3762 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_dfs_cac_cancel()
3763 /* it might be waiting for the local->mtx, but then in ieee80211_dfs_cac_cancel()
3764 * by the time it gets it, sdata->wdev.cac_started in ieee80211_dfs_cac_cancel()
3767 cancel_delayed_work(&sdata->dfs_cac_timer_work); in ieee80211_dfs_cac_cancel()
3769 if (sdata->wdev.cac_started) { in ieee80211_dfs_cac_cancel()
3770 chandef = sdata->vif.bss_conf.chandef; in ieee80211_dfs_cac_cancel()
3772 cfg80211_cac_event(sdata->dev, in ieee80211_dfs_cac_cancel()
3778 mutex_unlock(&local->mtx); in ieee80211_dfs_cac_cancel()
3785 struct cfg80211_chan_def chandef = local->hw.conf.chandef; in ieee80211_dfs_radar_detected_work()
3789 mutex_lock(&local->chanctx_mtx); in ieee80211_dfs_radar_detected_work()
3790 list_for_each_entry(ctx, &local->chanctx_list, list) { in ieee80211_dfs_radar_detected_work()
3791 if (ctx->replace_state == IEEE80211_CHANCTX_REPLACES_OTHER) in ieee80211_dfs_radar_detected_work()
3795 chandef = ctx->conf.def; in ieee80211_dfs_radar_detected_work()
3797 mutex_unlock(&local->chanctx_mtx); in ieee80211_dfs_radar_detected_work()
3804 /* XXX: multi-channel is not supported yet */ in ieee80211_dfs_radar_detected_work()
3807 cfg80211_radar_event(local->hw.wiphy, &chandef, GFP_KERNEL); in ieee80211_dfs_radar_detected_work()
3816 schedule_work(&local->radar_detected_work); in ieee80211_radar_detected()
3825 switch (c->width) { in ieee80211_chandef_downgrade()
3827 c->width = NL80211_CHAN_WIDTH_20_NOHT; in ieee80211_chandef_downgrade()
3831 c->width = NL80211_CHAN_WIDTH_20; in ieee80211_chandef_downgrade()
3832 c->center_freq1 = c->chan->center_freq; in ieee80211_chandef_downgrade()
3837 tmp = (30 + c->chan->center_freq - c->center_freq1)/20; in ieee80211_chandef_downgrade()
3841 c->center_freq1 = c->center_freq1 - 20 + 40 * tmp; in ieee80211_chandef_downgrade()
3842 c->width = NL80211_CHAN_WIDTH_40; in ieee80211_chandef_downgrade()
3846 c->center_freq2 = 0; in ieee80211_chandef_downgrade()
3847 c->width = NL80211_CHAN_WIDTH_80; in ieee80211_chandef_downgrade()
3853 tmp = (70 + c->chan->center_freq - c->center_freq1)/20; in ieee80211_chandef_downgrade()
3856 c->center_freq1 = c->center_freq1 - 40 + 80 * tmp; in ieee80211_chandef_downgrade()
3857 c->width = NL80211_CHAN_WIDTH_80; in ieee80211_chandef_downgrade()
3864 c->width = NL80211_CHAN_WIDTH_20_NOHT; in ieee80211_chandef_downgrade()
3875 /* keep c->width */ in ieee80211_chandef_downgrade()
3915 struct ieee80211_local *local = sdata->local; in ieee80211_send_action_csa()
3921 if (sdata->vif.type != NL80211_IFTYPE_ADHOC && in ieee80211_send_action_csa()
3922 sdata->vif.type != NL80211_IFTYPE_MESH_POINT) in ieee80211_send_action_csa()
3923 return -EOPNOTSUPP; in ieee80211_send_action_csa()
3925 skb = dev_alloc_skb(local->tx_headroom + hdr_len + in ieee80211_send_action_csa()
3931 return -ENOMEM; in ieee80211_send_action_csa()
3933 skb_reserve(skb, local->tx_headroom); in ieee80211_send_action_csa()
3935 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | in ieee80211_send_action_csa()
3938 eth_broadcast_addr(mgmt->da); in ieee80211_send_action_csa()
3939 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); in ieee80211_send_action_csa()
3940 if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_send_action_csa()
3941 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN); in ieee80211_send_action_csa()
3943 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; in ieee80211_send_action_csa()
3944 memcpy(mgmt->bssid, ifibss->bssid, ETH_ALEN); in ieee80211_send_action_csa()
3946 mgmt->u.action.category = WLAN_CATEGORY_SPECTRUM_MGMT; in ieee80211_send_action_csa()
3947 mgmt->u.action.u.chan_switch.action_code = WLAN_ACTION_SPCT_CHL_SWITCH; in ieee80211_send_action_csa()
3951 *pos++ = csa_settings->block_tx ? 1 : 0; /* CSA mode */ in ieee80211_send_action_csa()
3952 freq = csa_settings->chandef.chan->center_freq; in ieee80211_send_action_csa()
3954 *pos++ = csa_settings->count; /* count */ in ieee80211_send_action_csa()
3956 if (csa_settings->chandef.width == NL80211_CHAN_WIDTH_40) { in ieee80211_send_action_csa()
3962 ch_type = cfg80211_get_chandef_type(&csa_settings->chandef); in ieee80211_send_action_csa()
3969 if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_send_action_csa()
3970 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; in ieee80211_send_action_csa()
3975 *pos++ = sdata->u.mesh.mshcfg.dot11MeshTTL; /* Mesh TTL */ in ieee80211_send_action_csa()
3978 *pos++ |= csa_settings->block_tx ? in ieee80211_send_action_csa()
3982 put_unaligned_le16(ifmsh->pre_value, pos);/* Precedence Value */ in ieee80211_send_action_csa()
3986 if (csa_settings->chandef.width == NL80211_CHAN_WIDTH_80 || in ieee80211_send_action_csa()
3987 csa_settings->chandef.width == NL80211_CHAN_WIDTH_80P80 || in ieee80211_send_action_csa()
3988 csa_settings->chandef.width == NL80211_CHAN_WIDTH_160) { in ieee80211_send_action_csa()
3990 ieee80211_ie_build_wide_bw_cs(pos, &csa_settings->chandef); in ieee80211_send_action_csa()
3999 return !(cs == NULL || cs->cipher == 0 || in ieee80211_cs_valid()
4000 cs->hdr_len < cs->pn_len + cs->pn_off || in ieee80211_cs_valid()
4001 cs->hdr_len <= cs->key_idx_off || in ieee80211_cs_valid()
4002 cs->key_idx_shift > 7 || in ieee80211_cs_valid()
4003 cs->key_idx_mask == 0); in ieee80211_cs_valid()
4024 const struct ieee80211_cipher_scheme *l = local->hw.cipher_schemes; in ieee80211_cs_get()
4025 int n = local->hw.n_cipher_schemes; in ieee80211_cs_get()
4036 if (!cs || !(cs->iftype & BIT(iftype))) in ieee80211_cs_get()
4050 for (i = 0; i < crypto->n_ciphers_pairwise; i++) { in ieee80211_cs_headroom()
4051 cs = ieee80211_cs_get(local, crypto->ciphers_pairwise[i], in ieee80211_cs_headroom()
4054 if (cs && headroom < cs->hdr_len) in ieee80211_cs_headroom()
4055 headroom = cs->hdr_len; in ieee80211_cs_headroom()
4058 cs = ieee80211_cs_get(local, crypto->cipher_group, iftype); in ieee80211_cs_headroom()
4059 if (cs && headroom < cs->hdr_len) in ieee80211_cs_headroom()
4060 headroom = cs->hdr_len; in ieee80211_cs_headroom()
4068 s32 end = data->desc[i].start + data->desc[i].duration - (tsf + 1); in ieee80211_extend_noa_desc()
4075 if (data->count[i] == 1) in ieee80211_extend_noa_desc()
4078 if (data->desc[i].interval == 0) in ieee80211_extend_noa_desc()
4082 skip = DIV_ROUND_UP(-end, data->desc[i].interval); in ieee80211_extend_noa_desc()
4083 if (data->count[i] < 255) { in ieee80211_extend_noa_desc()
4084 if (data->count[i] <= skip) { in ieee80211_extend_noa_desc()
4085 data->count[i] = 0; in ieee80211_extend_noa_desc()
4089 data->count[i] -= skip; in ieee80211_extend_noa_desc()
4092 data->desc[i].start += skip * data->desc[i].interval; in ieee80211_extend_noa_desc()
4107 if (!data->count[i]) in ieee80211_extend_absent_time()
4113 cur = data->desc[i].start - tsf; in ieee80211_extend_absent_time()
4117 cur = data->desc[i].start + data->desc[i].duration - tsf; in ieee80211_extend_absent_time()
4149 u32 next_offset = BIT(31) - 1; in ieee80211_update_p2p_noa()
4152 data->absent = 0; in ieee80211_update_p2p_noa()
4153 data->has_next_tsf = false; in ieee80211_update_p2p_noa()
4157 if (!data->count[i]) in ieee80211_update_p2p_noa()
4161 start = data->desc[i].start - tsf; in ieee80211_update_p2p_noa()
4163 data->absent |= BIT(i); in ieee80211_update_p2p_noa()
4168 data->has_next_tsf = true; in ieee80211_update_p2p_noa()
4171 if (data->absent) in ieee80211_update_p2p_noa()
4174 data->next_tsf = tsf + next_offset; in ieee80211_update_p2p_noa()
4187 const struct ieee80211_p2p_noa_desc *desc = &attr->desc[i]; in ieee80211_parse_p2p_noa()
4189 if (!desc->count || !desc->duration) in ieee80211_parse_p2p_noa()
4192 data->count[i] = desc->count; in ieee80211_parse_p2p_noa()
4193 data->desc[i].start = le32_to_cpu(desc->start_time); in ieee80211_parse_p2p_noa()
4194 data->desc[i].duration = le32_to_cpu(desc->duration); in ieee80211_parse_p2p_noa()
4195 data->desc[i].interval = le32_to_cpu(desc->interval); in ieee80211_parse_p2p_noa()
4197 if (data->count[i] > 1 && in ieee80211_parse_p2p_noa()
4198 data->desc[i].interval < data->desc[i].duration) in ieee80211_parse_p2p_noa()
4217 u16 beacon_int = sdata->vif.bss_conf.beacon_int * 1024; in ieee80211_recalc_dtim()
4218 u8 dtim_period = sdata->vif.bss_conf.dtim_period; in ieee80211_recalc_dtim()
4222 if (tsf == -1ULL || !beacon_int || !dtim_period) in ieee80211_recalc_dtim()
4225 if (sdata->vif.type == NL80211_IFTYPE_AP || in ieee80211_recalc_dtim()
4226 sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in ieee80211_recalc_dtim()
4227 if (!sdata->bss) in ieee80211_recalc_dtim()
4230 ps = &sdata->bss->ps; in ieee80211_recalc_dtim()
4231 } else if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_recalc_dtim()
4232 ps = &sdata->u.mesh.ps; in ieee80211_recalc_dtim()
4240 * dtim_count = dtim_period - (tsf / bcn_int) % dtim_period in ieee80211_recalc_dtim()
4248 dtim_count = dtim_period - bcns_from_dtim; in ieee80211_recalc_dtim()
4250 ps->dtim_count = dtim_count; in ieee80211_recalc_dtim()
4259 lockdep_assert_held(&local->chanctx_mtx); in ieee80211_chanctx_radar_detect()
4261 if (WARN_ON(ctx->replace_state == IEEE80211_CHANCTX_WILL_BE_REPLACED)) in ieee80211_chanctx_radar_detect()
4264 list_for_each_entry(sdata, &ctx->reserved_vifs, reserved_chanctx_list) in ieee80211_chanctx_radar_detect()
4265 if (sdata->reserved_radar_required) in ieee80211_chanctx_radar_detect()
4266 radar_detect |= BIT(sdata->reserved_chandef.width); in ieee80211_chanctx_radar_detect()
4269 * An in-place reservation context should not have any assigned vifs in ieee80211_chanctx_radar_detect()
4272 WARN_ON(ctx->replace_state == IEEE80211_CHANCTX_REPLACES_OTHER && in ieee80211_chanctx_radar_detect()
4273 !list_empty(&ctx->assigned_vifs)); in ieee80211_chanctx_radar_detect()
4275 list_for_each_entry(sdata, &ctx->assigned_vifs, assigned_chanctx_list) in ieee80211_chanctx_radar_detect()
4276 if (sdata->radar_required) in ieee80211_chanctx_radar_detect()
4277 radar_detect |= BIT(sdata->vif.bss_conf.chandef.width); in ieee80211_chanctx_radar_detect()
4287 struct ieee80211_local *local = sdata->local; in ieee80211_check_combinations()
4289 enum nl80211_iftype iftype = sdata->wdev.iftype; in ieee80211_check_combinations()
4296 lockdep_assert_held(&local->chanctx_mtx); in ieee80211_check_combinations()
4299 return -EINVAL; in ieee80211_check_combinations()
4302 !chandef->chan)) in ieee80211_check_combinations()
4303 return -EINVAL; in ieee80211_check_combinations()
4306 return -EINVAL; in ieee80211_check_combinations()
4308 if (sdata->vif.type == NL80211_IFTYPE_AP || in ieee80211_check_combinations()
4309 sdata->vif.type == NL80211_IFTYPE_MESH_POINT) { in ieee80211_check_combinations()
4315 params.new_beacon_int = sdata->vif.bss_conf.beacon_int; in ieee80211_check_combinations()
4319 if (cfg80211_iftype_allowed(local->hw.wiphy, iftype, 0, 1)) { in ieee80211_check_combinations()
4321 return -EINVAL; in ieee80211_check_combinations()
4331 list_for_each_entry(ctx, &local->chanctx_list, list) { in ieee80211_check_combinations()
4332 if (ctx->replace_state == IEEE80211_CHANCTX_WILL_BE_REPLACED) in ieee80211_check_combinations()
4336 if (ctx->mode == IEEE80211_CHANCTX_EXCLUSIVE) { in ieee80211_check_combinations()
4342 &ctx->conf.def)) in ieee80211_check_combinations()
4347 list_for_each_entry_rcu(sdata_iter, &local->interfaces, list) { in ieee80211_check_combinations()
4350 wdev_iter = &sdata_iter->wdev; in ieee80211_check_combinations()
4354 cfg80211_iftype_allowed(local->hw.wiphy, in ieee80211_check_combinations()
4355 wdev_iter->iftype, 0, 1)) in ieee80211_check_combinations()
4358 params.iftype_num[wdev_iter->iftype]++; in ieee80211_check_combinations()
4365 return cfg80211_check_combinations(local->hw.wiphy, ¶ms); in ieee80211_check_combinations()
4375 c->num_different_channels); in ieee80211_iter_max_chans()
4386 lockdep_assert_held(&local->chanctx_mtx); in ieee80211_max_num_channels()
4388 list_for_each_entry(ctx, &local->chanctx_list, list) { in ieee80211_max_num_channels()
4389 if (ctx->replace_state == IEEE80211_CHANCTX_WILL_BE_REPLACED) in ieee80211_max_num_channels()
4398 list_for_each_entry_rcu(sdata, &local->interfaces, list) in ieee80211_max_num_channels()
4399 params.iftype_num[sdata->wdev.iftype]++; in ieee80211_max_num_channels()
4401 err = cfg80211_iter_combinations(local->hw.wiphy, ¶ms, in ieee80211_max_num_channels()
4414 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_add_s1g_capab_ie()
4419 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION)) in ieee80211_add_s1g_capab_ie()
4422 if (!caps->s1g) in ieee80211_add_s1g_capab_ie()
4425 memcpy(s1g_capab.capab_info, caps->cap, sizeof(caps->cap)); in ieee80211_add_s1g_capab_ie()
4426 memcpy(s1g_capab.supp_mcs_nss, caps->nss_mcs, sizeof(caps->nss_mcs)); in ieee80211_add_s1g_capab_ie()
4428 /* override the capability info */ in ieee80211_add_s1g_capab_ie()
4429 for (i = 0; i < sizeof(ifmgd->s1g_capa.capab_info); i++) { in ieee80211_add_s1g_capab_ie()
4430 u8 mask = ifmgd->s1g_capa_mask.capab_info[i]; in ieee80211_add_s1g_capab_ie()
4433 s1g_capab.capab_info[i] |= ifmgd->s1g_capa.capab_info[i] & mask; in ieee80211_add_s1g_capab_ie()
4437 for (i = 0; i < sizeof(ifmgd->s1g_capa.supp_mcs_nss); i++) { in ieee80211_add_s1g_capab_ie()
4438 u8 mask = ifmgd->s1g_capa_mask.supp_mcs_nss[i]; in ieee80211_add_s1g_capab_ie()
4442 ifmgd->s1g_capa.supp_mcs_nss[i] & mask; in ieee80211_add_s1g_capab_ie()
4472 *buf++ = qosinfo; /* U-APSD no in use */ in ieee80211_add_wmm_info_ie()
4485 skb_queue_walk(&txqi->frags, skb) { in ieee80211_txq_get_depth()
4487 frag_bytes += skb->len; in ieee80211_txq_get_depth()
4491 *frame_cnt = txqi->tin.backlog_packets + frag_cnt; in ieee80211_txq_get_depth()
4494 *byte_cnt = txqi->tin.backlog_bytes + frag_bytes; in ieee80211_txq_get_depth()