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-2025 Intel Corporation
30 #include "driver-ops.h"
45 return &local->hw; in wiphy_to_ieee80211_hw()
57 __le16 fc = hdr->frame_control; in ieee80211_get_bssid()
66 return hdr->addr1; in ieee80211_get_bssid()
68 return hdr->addr2; in ieee80211_get_bssid()
70 return hdr->addr3; in ieee80211_get_bssid()
76 return ext->u.s1g_beacon.sa; in ieee80211_get_bssid()
82 return hdr->addr3; in ieee80211_get_bssid()
87 return hdr->addr1; in ieee80211_get_bssid()
92 return hdr->addr2; in ieee80211_get_bssid()
95 return hdr->addr1; in ieee80211_get_bssid()
111 skb_queue_walk(&tx->skbs, skb) { in ieee80211_tx_set_protected()
112 hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_tx_set_protected()
113 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); in ieee80211_tx_set_protected()
141 * 802.11a - 18.5.2: aSIFSTime = 16 usec in ieee80211_frame_duration()
142 * 802.11g - 19.8.4: aSIFSTime = 10 usec + in ieee80211_frame_duration()
146 dur += 16; /* IEEE 802.11-2012 18.3.2.4: T_PREAMBLE = 16 usec */ in ieee80211_frame_duration()
147 dur += 4; /* IEEE 802.11-2012 18.3.2.4: T_SIGNAL = 4 usec */ in ieee80211_frame_duration()
189 short_preamble = sdata->vif.bss_conf.use_short_preamble; in ieee80211_generic_frame_duration()
190 if (sdata->deflink.operating_11g_mode) in ieee80211_generic_frame_duration()
191 erp = rate->flags & IEEE80211_RATE_ERP_G; in ieee80211_generic_frame_duration()
194 dur = ieee80211_frame_duration(band, frame_len, rate->bitrate, erp, in ieee80211_generic_frame_duration()
213 sband = local->hw.wiphy->bands[frame_txctl->band]; in ieee80211_rts_duration()
217 rate = &sband->bitrates[frame_txctl->control.rts_cts_rate_idx]; in ieee80211_rts_duration()
222 short_preamble = sdata->vif.bss_conf.use_short_preamble; in ieee80211_rts_duration()
223 if (sdata->deflink.operating_11g_mode) in ieee80211_rts_duration()
224 erp = rate->flags & IEEE80211_RATE_ERP_G; in ieee80211_rts_duration()
227 bitrate = rate->bitrate; in ieee80211_rts_duration()
230 dur = ieee80211_frame_duration(sband->band, 10, bitrate, in ieee80211_rts_duration()
233 dur += ieee80211_frame_duration(sband->band, frame_len, bitrate, in ieee80211_rts_duration()
236 dur += ieee80211_frame_duration(sband->band, 10, bitrate, in ieee80211_rts_duration()
256 sband = local->hw.wiphy->bands[frame_txctl->band]; in ieee80211_ctstoself_duration()
260 rate = &sband->bitrates[frame_txctl->control.rts_cts_rate_idx]; in ieee80211_ctstoself_duration()
264 short_preamble = sdata->vif.bss_conf.use_short_preamble; in ieee80211_ctstoself_duration()
265 if (sdata->deflink.operating_11g_mode) in ieee80211_ctstoself_duration()
266 erp = rate->flags & IEEE80211_RATE_ERP_G; in ieee80211_ctstoself_duration()
269 bitrate = rate->bitrate; in ieee80211_ctstoself_duration()
272 dur = ieee80211_frame_duration(sband->band, frame_len, bitrate, in ieee80211_ctstoself_duration()
274 if (!(frame_txctl->flags & IEEE80211_TX_CTL_NO_ACK)) { in ieee80211_ctstoself_duration()
276 dur += ieee80211_frame_duration(sband->band, 10, bitrate, in ieee80211_ctstoself_duration()
289 .sta = queue->sta, in wake_tx_push_queue()
294 skb = ieee80211_tx_dequeue(&local->hw, queue); in wake_tx_push_queue()
307 struct ieee80211_sub_if_data *sdata = vif_to_sdata(txq->vif); in ieee80211_handle_wake_tx_queue()
310 spin_lock(&local->handle_wake_tx_queue_lock); in ieee80211_handle_wake_tx_queue()
313 ieee80211_txq_schedule_start(hw, txq->ac); in ieee80211_handle_wake_tx_queue()
314 while ((queue = ieee80211_next_txq(hw, txq->ac))) { in ieee80211_handle_wake_tx_queue()
318 ieee80211_txq_schedule_end(hw, txq->ac); in ieee80211_handle_wake_tx_queue()
319 spin_unlock(&local->handle_wake_tx_queue_lock); in ieee80211_handle_wake_tx_queue()
325 struct ieee80211_local *local = sdata->local; in __ieee80211_wake_txqs()
326 struct ieee80211_vif *vif = &sdata->vif; in __ieee80211_wake_txqs()
327 struct fq *fq = &local->fq; in __ieee80211_wake_txqs()
334 spin_lock(&fq->lock); in __ieee80211_wake_txqs()
336 if (!test_bit(SDATA_STATE_RUNNING, &sdata->state)) in __ieee80211_wake_txqs()
339 if (sdata->vif.type == NL80211_IFTYPE_AP) in __ieee80211_wake_txqs()
340 ps = &sdata->bss->ps; in __ieee80211_wake_txqs()
342 list_for_each_entry_rcu(sta, &local->sta_list, list) { in __ieee80211_wake_txqs()
343 if (sdata != sta->sdata) in __ieee80211_wake_txqs()
346 for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) { in __ieee80211_wake_txqs()
347 struct ieee80211_txq *txq = sta->sta.txq[i]; in __ieee80211_wake_txqs()
354 if (ac != txq->ac) in __ieee80211_wake_txqs()
358 &txqi->flags)) in __ieee80211_wake_txqs()
361 spin_unlock(&fq->lock); in __ieee80211_wake_txqs()
363 spin_lock(&fq->lock); in __ieee80211_wake_txqs()
367 if (!vif->txq) in __ieee80211_wake_txqs()
370 txqi = to_txq_info(vif->txq); in __ieee80211_wake_txqs()
372 if (!test_and_clear_bit(IEEE80211_TXQ_DIRTY, &txqi->flags) || in __ieee80211_wake_txqs()
373 (ps && atomic_read(&ps->num_sta_ps)) || ac != vif->txq->ac) in __ieee80211_wake_txqs()
376 spin_unlock(&fq->lock); in __ieee80211_wake_txqs()
382 spin_unlock(&fq->lock); in __ieee80211_wake_txqs()
387 __releases(&local->queue_stop_reason_lock)
388 __acquires(&local->queue_stop_reason_lock)
397 if (local->hw.queues < IEEE80211_NUM_ACS) in _ieee80211_wake_txqs()
400 for (i = 0; i < local->hw.queues; i++) { in _ieee80211_wake_txqs()
401 if (local->queue_stop_reasons[i]) in _ieee80211_wake_txqs()
404 spin_unlock_irqrestore(&local->queue_stop_reason_lock, *flags); in _ieee80211_wake_txqs()
405 list_for_each_entry_rcu(sdata, &local->interfaces, list) { in _ieee80211_wake_txqs()
409 int ac_queue = sdata->vif.hw_queue[ac]; in _ieee80211_wake_txqs()
412 sdata->vif.cab_queue == i) in _ieee80211_wake_txqs()
416 spin_lock_irqsave(&local->queue_stop_reason_lock, *flags); in _ieee80211_wake_txqs()
428 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_wake_txqs()
430 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_wake_txqs()
440 if (WARN_ON(queue >= hw->queues)) in __ieee80211_wake_queue()
443 if (!test_bit(reason, &local->queue_stop_reasons[queue])) in __ieee80211_wake_queue()
447 local->q_stop_reasons[queue][reason] = 0; in __ieee80211_wake_queue()
449 local->q_stop_reasons[queue][reason]--; in __ieee80211_wake_queue()
450 if (WARN_ON(local->q_stop_reasons[queue][reason] < 0)) in __ieee80211_wake_queue()
451 local->q_stop_reasons[queue][reason] = 0; in __ieee80211_wake_queue()
454 if (local->q_stop_reasons[queue][reason] == 0) in __ieee80211_wake_queue()
455 __clear_bit(reason, &local->queue_stop_reasons[queue]); in __ieee80211_wake_queue()
458 local->q_stop_reasons[queue][reason]); in __ieee80211_wake_queue()
460 if (local->queue_stop_reasons[queue] != 0) in __ieee80211_wake_queue()
464 if (!skb_queue_empty(&local->pending[queue])) in __ieee80211_wake_queue()
465 tasklet_schedule(&local->tx_pending_tasklet); in __ieee80211_wake_queue()
475 tasklet_schedule(&local->wake_txqs_tasklet); in __ieee80211_wake_queue()
487 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_wake_queue_by_reason()
489 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_wake_queue_by_reason()
506 if (WARN_ON(queue >= hw->queues)) in __ieee80211_stop_queue()
510 local->q_stop_reasons[queue][reason] = 1; in __ieee80211_stop_queue()
512 local->q_stop_reasons[queue][reason]++; in __ieee80211_stop_queue()
515 local->q_stop_reasons[queue][reason]); in __ieee80211_stop_queue()
517 set_bit(reason, &local->queue_stop_reasons[queue]); in __ieee80211_stop_queue()
527 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_stop_queue_by_reason()
529 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_stop_queue_by_reason()
543 struct ieee80211_hw *hw = &local->hw; in ieee80211_add_pending_skb()
546 int queue = info->hw_queue; in ieee80211_add_pending_skb()
548 if (WARN_ON(!info->control.vif)) { in ieee80211_add_pending_skb()
549 ieee80211_free_txskb(&local->hw, skb); in ieee80211_add_pending_skb()
553 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_add_pending_skb()
556 __skb_queue_tail(&local->pending[queue], skb); in ieee80211_add_pending_skb()
559 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_add_pending_skb()
565 struct ieee80211_hw *hw = &local->hw; in ieee80211_add_pending_skbs()
570 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_add_pending_skbs()
574 if (WARN_ON(!info->control.vif)) { in ieee80211_add_pending_skbs()
575 ieee80211_free_txskb(&local->hw, skb); in ieee80211_add_pending_skbs()
579 queue = info->hw_queue; in ieee80211_add_pending_skbs()
585 __skb_queue_tail(&local->pending[queue], skb); in ieee80211_add_pending_skbs()
588 for (i = 0; i < hw->queues; i++) in ieee80211_add_pending_skbs()
592 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_add_pending_skbs()
604 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_stop_queues_by_reason()
606 for_each_set_bit(i, &queues, hw->queues) in ieee80211_stop_queues_by_reason()
609 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_stop_queues_by_reason()
626 if (WARN_ON(queue >= hw->queues)) in ieee80211_queue_stopped()
629 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_queue_stopped()
631 &local->queue_stop_reasons[queue]); in ieee80211_queue_stopped()
632 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_queue_stopped()
646 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_wake_queues_by_reason()
648 for_each_set_bit(i, &queues, hw->queues) in ieee80211_wake_queues_by_reason()
651 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_wake_queues_by_reason()
668 if (sdata && ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) { in ieee80211_get_vif_queues()
674 if (sdata->vif.hw_queue[ac] != IEEE80211_INVAL_HW_QUEUE) in ieee80211_get_vif_queues()
675 queues |= BIT(sdata->vif.hw_queue[ac]); in ieee80211_get_vif_queues()
676 if (sdata->vif.cab_queue != IEEE80211_INVAL_HW_QUEUE) in ieee80211_get_vif_queues()
677 queues |= BIT(sdata->vif.cab_queue); in ieee80211_get_vif_queues()
680 queues = BIT(local->hw.queues) - 1; in ieee80211_get_vif_queues()
690 if (!local->ops->flush && !drop) in __ieee80211_flush_queues()
695 * IEEE80211_HW_QUEUE_CONTROL - flush all queues in __ieee80211_flush_queues()
697 if (!queues || !ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) in __ieee80211_flush_queues()
700 ieee80211_stop_queues_by_reason(&local->hw, queues, in __ieee80211_flush_queues()
710 list_for_each_entry(sta, &local->sta_list, list) { in __ieee80211_flush_queues()
711 if (sdata != sta->sdata) in __ieee80211_flush_queues()
717 if (local->ops->flush) in __ieee80211_flush_queues()
720 ieee80211_wake_queues_by_reason(&local->hw, queues, in __ieee80211_flush_queues()
740 list_for_each_entry_rcu(sdata, &local->interfaces, list, in __iterate_interfaces()
741 lockdep_is_held(&local->iflist_mtx) || in __iterate_interfaces()
742 lockdep_is_held(&local->hw.wiphy->mtx)) { in __iterate_interfaces()
743 switch (sdata->vif.type) { in __iterate_interfaces()
745 if (!(sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE) && in __iterate_interfaces()
746 !ieee80211_hw_check(&local->hw, NO_VIRTUAL_MONITOR)) in __iterate_interfaces()
755 active_only && !(sdata->flags & IEEE80211_SDATA_IN_DRIVER)) in __iterate_interfaces()
758 !(sdata->flags & IEEE80211_SDATA_IN_DRIVER)) in __iterate_interfaces()
761 iterator(data, sdata->vif.addr, in __iterate_interfaces()
762 &sdata->vif); in __iterate_interfaces()
765 sdata = rcu_dereference_check(local->monitor_sdata, in __iterate_interfaces()
766 lockdep_is_held(&local->iflist_mtx) || in __iterate_interfaces()
767 lockdep_is_held(&local->hw.wiphy->mtx)); in __iterate_interfaces()
768 if (sdata && ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF) && in __iterate_interfaces()
770 sdata->flags & IEEE80211_SDATA_IN_DRIVER)) in __iterate_interfaces()
771 iterator(data, sdata->vif.addr, &sdata->vif); in __iterate_interfaces()
782 mutex_lock(&local->iflist_mtx); in ieee80211_iterate_interfaces()
784 mutex_unlock(&local->iflist_mtx); in ieee80211_iterate_interfaces()
811 lockdep_assert_wiphy(hw->wiphy); in ieee80211_iterate_active_interfaces_mtx()
825 list_for_each_entry_rcu(sta, &local->sta_list, list, in __iterate_stations()
826 lockdep_is_held(&local->hw.wiphy->mtx)) { in __iterate_stations()
827 if (!sta->uploaded) in __iterate_stations()
830 iterator(data, &sta->sta); in __iterate_stations()
854 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_iterate_stations_mtx()
865 !(sdata->flags & IEEE80211_SDATA_IN_DRIVER)) in wdev_to_ieee80211_vif()
867 return &sdata->vif; in wdev_to_ieee80211_vif()
876 return &vif_to_sdata(vif)->wdev; in ieee80211_vif_to_wdev()
882 * the suspend->resume cycle. Since we can't check each caller
891 if (local->quiescing || (local->suspended && !local->resuming)) { in ieee80211_can_queue_work()
892 pr_warn("queueing ieee80211 work while going to suspend\n"); in ieee80211_can_queue_work()
906 queue_work(local->workqueue, work); in ieee80211_queue_work()
919 queue_delayed_work(local->workqueue, dwork, delay); in ieee80211_queue_delayed_work()
932 if (sdata->vif.type != NL80211_IFTYPE_AP && in ieee80211_regulatory_limit_wmm_params()
933 sdata->vif.type != NL80211_IFTYPE_STATION) in ieee80211_regulatory_limit_wmm_params()
937 chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_regulatory_limit_wmm_params()
939 center_freq = chanctx_conf->def.chan->center_freq; in ieee80211_regulatory_limit_wmm_params()
946 rrule = freq_reg_info(sdata->wdev.wiphy, MHZ_TO_KHZ(center_freq)); in ieee80211_regulatory_limit_wmm_params()
948 if (IS_ERR_OR_NULL(rrule) || !rrule->has_wmm) { in ieee80211_regulatory_limit_wmm_params()
953 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_regulatory_limit_wmm_params()
954 wmm_ac = &rrule->wmm_rule.ap[ac]; in ieee80211_regulatory_limit_wmm_params()
956 wmm_ac = &rrule->wmm_rule.client[ac]; in ieee80211_regulatory_limit_wmm_params()
957 qparam->cw_min = max_t(u16, qparam->cw_min, wmm_ac->cw_min); in ieee80211_regulatory_limit_wmm_params()
958 qparam->cw_max = max_t(u16, qparam->cw_max, wmm_ac->cw_max); in ieee80211_regulatory_limit_wmm_params()
959 qparam->aifs = max_t(u8, qparam->aifs, wmm_ac->aifsn); in ieee80211_regulatory_limit_wmm_params()
960 qparam->txop = min_t(u16, qparam->txop, wmm_ac->cot / 32); in ieee80211_regulatory_limit_wmm_params()
967 struct ieee80211_sub_if_data *sdata = link->sdata; in ieee80211_set_wmm_default()
968 struct ieee80211_local *local = sdata->local; in ieee80211_set_wmm_default()
976 if (!local->ops->conf_tx) in ieee80211_set_wmm_default()
979 if (local->hw.queues < IEEE80211_NUM_ACS) in ieee80211_set_wmm_default()
985 chanctx_conf = rcu_dereference(link->conf->chanctx_conf); in ieee80211_set_wmm_default()
987 chanctx_conf->def.chan->band == NL80211_BAND_2GHZ) && in ieee80211_set_wmm_default()
988 !link->operating_11g_mode; in ieee80211_set_wmm_default()
991 is_ocb = (sdata->vif.type == NL80211_IFTYPE_OCB); in ieee80211_set_wmm_default()
993 /* Set defaults according to 802.11-2007 Table 7-37 */ in ieee80211_set_wmm_default()
1032 qparam.cw_min = (aCWmin + 1) / 2 - 1; in ieee80211_set_wmm_default()
1046 qparam.cw_max = (aCWmin + 1) / 2 - 1; in ieee80211_set_wmm_default()
1047 qparam.cw_min = (aCWmin + 1) / 4 - 1; in ieee80211_set_wmm_default()
1062 link->tx_conf[ac] = qparam; in ieee80211_set_wmm_default()
1066 if (sdata->vif.type != NL80211_IFTYPE_MONITOR && in ieee80211_set_wmm_default()
1067 sdata->vif.type != NL80211_IFTYPE_P2P_DEVICE && in ieee80211_set_wmm_default()
1068 sdata->vif.type != NL80211_IFTYPE_NAN) { in ieee80211_set_wmm_default()
1069 link->conf->qos = enable_qos; in ieee80211_set_wmm_default()
1082 struct ieee80211_local *local = sdata->local; in ieee80211_send_auth()
1085 bool multi_link = ieee80211_vif_is_mld(&sdata->vif); in ieee80211_send_auth()
1094 .len = sizeof(mle) - 2, in ieee80211_send_auth()
1101 memcpy(mle.basic.mld_mac_addr, sdata->vif.addr, ETH_ALEN); in ieee80211_send_auth()
1104 skb = dev_alloc_skb(local->hw.extra_tx_headroom + IEEE80211_WEP_IV_LEN + in ieee80211_send_auth()
1110 skb_reserve(skb, local->hw.extra_tx_headroom + IEEE80211_WEP_IV_LEN); in ieee80211_send_auth()
1113 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | in ieee80211_send_auth()
1115 memcpy(mgmt->da, da, ETH_ALEN); in ieee80211_send_auth()
1116 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); in ieee80211_send_auth()
1117 memcpy(mgmt->bssid, bssid, ETH_ALEN); in ieee80211_send_auth()
1118 mgmt->u.auth.auth_alg = cpu_to_le16(auth_alg); in ieee80211_send_auth()
1119 mgmt->u.auth.auth_transaction = cpu_to_le16(transaction); in ieee80211_send_auth()
1120 mgmt->u.auth.status_code = cpu_to_le16(status); in ieee80211_send_auth()
1127 mgmt->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); in ieee80211_send_auth()
1135 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT | in ieee80211_send_auth()
1145 struct ieee80211_local *local = sdata->local; in ieee80211_send_deauth_disassoc()
1150 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | stype); in ieee80211_send_deauth_disassoc()
1151 mgmt->duration = 0; /* initialize only */ in ieee80211_send_deauth_disassoc()
1152 mgmt->seq_ctrl = 0; /* initialize only */ in ieee80211_send_deauth_disassoc()
1153 memcpy(mgmt->da, da, ETH_ALEN); in ieee80211_send_deauth_disassoc()
1154 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); in ieee80211_send_deauth_disassoc()
1155 memcpy(mgmt->bssid, bssid, ETH_ALEN); in ieee80211_send_deauth_disassoc()
1157 mgmt->u.deauth.reason_code = cpu_to_le16(reason); in ieee80211_send_deauth_disassoc()
1160 skb = dev_alloc_skb(local->hw.extra_tx_headroom + in ieee80211_send_deauth_disassoc()
1165 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_send_deauth_disassoc()
1170 if (sdata->vif.type != NL80211_IFTYPE_STATION || in ieee80211_send_deauth_disassoc()
1171 !(sdata->u.mgd.flags & IEEE80211_STA_MFP_ENABLED)) in ieee80211_send_deauth_disassoc()
1172 IEEE80211_SKB_CB(skb)->flags |= in ieee80211_send_deauth_disassoc()
1183 return -ENOBUFS; in ieee80211_put_s1g_cap()
1188 skb_put_data(skb, &s1g_cap->cap, sizeof(s1g_cap->cap)); in ieee80211_put_s1g_cap()
1189 skb_put_data(skb, &s1g_cap->nss_mcs, sizeof(s1g_cap->nss_mcs)); in ieee80211_put_s1g_cap()
1203 struct ieee80211_local *local = sdata->local; in ieee80211_put_preq_ies_band()
1211 sband = local->hw.wiphy->bands[band]; in ieee80211_put_preq_ies_band()
1217 return ieee80211_put_s1g_cap(skb, &sband->s1g_cap); in ieee80211_put_preq_ies_band()
1235 if (skb_tailroom(skb) < noffset - *offset) in ieee80211_put_preq_ies_band()
1236 return -ENOBUFS; in ieee80211_put_preq_ies_band()
1237 skb_put_data(skb, ie + *offset, noffset - *offset); in ieee80211_put_preq_ies_band()
1246 if (chandef->chan && sband->band == NL80211_BAND_2GHZ) { in ieee80211_put_preq_ies_band()
1248 return -ENOBUFS; in ieee80211_put_preq_ies_band()
1252 ieee80211_frequency_to_channel(chandef->chan->center_freq)); in ieee80211_put_preq_ies_band()
1271 if (skb_tailroom(skb) < noffset - *offset) in ieee80211_put_preq_ies_band()
1272 return -ENOBUFS; in ieee80211_put_preq_ies_band()
1273 skb_put_data(skb, ie + *offset, noffset - *offset); in ieee80211_put_preq_ies_band()
1277 if (sband->ht_cap.ht_supported) { in ieee80211_put_preq_ies_band()
1281 return -ENOBUFS; in ieee80211_put_preq_ies_band()
1284 ieee80211_ie_build_ht_cap(pos, &sband->ht_cap, in ieee80211_put_preq_ies_band()
1285 sband->ht_cap.cap); in ieee80211_put_preq_ies_band()
1301 /* 60 GHz (Multi-band, DMG, MMS) can't happen */ in ieee80211_put_preq_ies_band()
1306 if (skb_tailroom(skb) < noffset - *offset) in ieee80211_put_preq_ies_band()
1307 return -ENOBUFS; in ieee80211_put_preq_ies_band()
1308 skb_put_data(skb, ie + *offset, noffset - *offset); in ieee80211_put_preq_ies_band()
1313 for (i = 0; i < sband->n_channels; i++) { in ieee80211_put_preq_ies_band()
1314 if (sband->channels[i].flags & (IEEE80211_CHAN_DISABLED | in ieee80211_put_preq_ies_band()
1322 if (sband->vht_cap.vht_supported && have_80mhz) { in ieee80211_put_preq_ies_band()
1326 return -ENOBUFS; in ieee80211_put_preq_ies_band()
1329 ieee80211_ie_build_vht_cap(pos, &sband->vht_cap, in ieee80211_put_preq_ies_band()
1330 sband->vht_cap.cap); in ieee80211_put_preq_ies_band()
1347 if (skb_tailroom(skb) < noffset - *offset) in ieee80211_put_preq_ies_band()
1348 return -ENOBUFS; in ieee80211_put_preq_ies_band()
1349 skb_put_data(skb, ie + *offset, noffset - *offset); in ieee80211_put_preq_ies_band()
1353 if (cfg80211_any_usable_channels(local->hw.wiphy, BIT(sband->band), in ieee80211_put_preq_ies_band()
1360 if (cfg80211_any_usable_channels(local->hw.wiphy, BIT(sband->band), in ieee80211_put_preq_ies_band()
1374 * that calculates local->scan_ies_len. in ieee80211_put_preq_ies_band()
1395 ie_desc->ies[i] = skb_tail_pointer(skb); in ieee80211_put_preq_ies()
1403 ie_desc->len[i] = skb_tail_pointer(skb) - in ieee80211_put_preq_ies()
1404 ie_desc->ies[i]; in ieee80211_put_preq_ies()
1410 if (WARN_ONCE(skb_tailroom(skb) < ie_len - custom_ie_offset, in ieee80211_put_preq_ies()
1412 return -ENOBUFS; in ieee80211_put_preq_ies()
1413 ie_desc->common_ies = skb_tail_pointer(skb); in ieee80211_put_preq_ies()
1415 ie_len - custom_ie_offset); in ieee80211_put_preq_ies()
1416 ie_desc->common_ie_len = skb_tail_pointer(skb) - in ieee80211_put_preq_ies()
1417 ie_desc->common_ies; in ieee80211_put_preq_ies()
1437 return -ENOMEM; in ieee80211_build_preq_ies()
1448 if (skb->len > buffer_len) { in ieee80211_build_preq_ies()
1449 ret = -ENOBUFS; in ieee80211_build_preq_ies()
1453 memcpy(buffer, start, skb->len); in ieee80211_build_preq_ies()
1457 offs = ie_desc->ies[i] - start; in ieee80211_build_preq_ies()
1458 ie_desc->ies[i] = buffer + offs; in ieee80211_build_preq_ies()
1460 offs = ie_desc->common_ies - start; in ieee80211_build_preq_ies()
1461 ie_desc->common_ies = buffer + offs; in ieee80211_build_preq_ies()
1463 ret = skb->len; in ieee80211_build_preq_ies()
1477 struct ieee80211_local *local = sdata->local; in ieee80211_build_probe_req()
1487 * badly-behaved APs don't respond when this parameter is included. in ieee80211_build_probe_req()
1489 chandef.width = sdata->vif.bss_conf.chanreq.oper.width; in ieee80211_build_probe_req()
1495 skb = ieee80211_probereq_get(&local->hw, src, ssid, ssid_len, in ieee80211_build_probe_req()
1496 local->scan_ies_len + ie_len); in ieee80211_build_probe_req()
1500 rate_masks[chan->band] = ratemask; in ieee80211_build_probe_req()
1502 ie, ie_len, BIT(chan->band), in ieee80211_build_probe_req()
1506 mgmt = (struct ieee80211_mgmt *) skb->data; in ieee80211_build_probe_req()
1507 memcpy(mgmt->da, dst, ETH_ALEN); in ieee80211_build_probe_req()
1508 memcpy(mgmt->bssid, dst, ETH_ALEN); in ieee80211_build_probe_req()
1511 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; in ieee80211_build_probe_req()
1525 sband = sdata->local->hw.wiphy->bands[band]; in ieee80211_sta_get_rates()
1529 num_rates = sband->n_bitrates; in ieee80211_sta_get_rates()
1531 for (i = 0; i < elems->supp_rates_len + in ieee80211_sta_get_rates()
1532 elems->ext_supp_rates_len; i++) { in ieee80211_sta_get_rates()
1536 if (i < elems->supp_rates_len) in ieee80211_sta_get_rates()
1537 rate = elems->supp_rates[i]; in ieee80211_sta_get_rates()
1538 else if (elems->ext_supp_rates) in ieee80211_sta_get_rates()
1539 rate = elems->ext_supp_rates in ieee80211_sta_get_rates()
1540 [i - elems->supp_rates_len]; in ieee80211_sta_get_rates()
1548 int brate = sband->bitrates[j].bitrate; in ieee80211_sta_get_rates()
1569 wiphy_work_cancel(local->hw.wiphy, &local->reconfig_filter); in ieee80211_stop_device()
1571 flush_workqueue(local->workqueue); in ieee80211_stop_device()
1572 wiphy_work_flush(local->hw.wiphy, NULL); in ieee80211_stop_device()
1586 if (test_bit(SCAN_COMPLETED, &local->scanning)) { in ieee80211_flush_completed_scan()
1588 * we don't attempt to continue a partial HW scan - which is in ieee80211_flush_completed_scan()
1593 set_bit(SCAN_ABORTED, &local->scanning); in ieee80211_flush_completed_scan()
1594 wiphy_delayed_work_queue(local->hw.wiphy, &local->scan_work, 0); in ieee80211_flush_completed_scan()
1595 wiphy_delayed_work_flush(local->hw.wiphy, &local->scan_work); in ieee80211_flush_completed_scan()
1604 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_handle_reconfig_failure()
1616 local->resuming = false; in ieee80211_handle_reconfig_failure()
1617 local->suspended = false; in ieee80211_handle_reconfig_failure()
1618 local->in_reconfig = false; in ieee80211_handle_reconfig_failure()
1619 local->reconfig_failure = true; in ieee80211_handle_reconfig_failure()
1628 list_for_each_entry(sdata, &local->interfaces, list) in ieee80211_handle_reconfig_failure()
1629 sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER; in ieee80211_handle_reconfig_failure()
1634 list_for_each_entry(ctx, &local->chanctx_list, list) in ieee80211_handle_reconfig_failure()
1635 ctx->driver_present = false; in ieee80211_handle_reconfig_failure()
1645 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_assign_chanctx()
1647 conf = rcu_dereference_protected(link->conf->chanctx_conf, in ieee80211_assign_chanctx()
1648 lockdep_is_held(&local->hw.wiphy->mtx)); in ieee80211_assign_chanctx()
1651 drv_assign_vif_chanctx(local, sdata, link->conf, ctx); in ieee80211_assign_chanctx()
1657 struct ieee80211_local *local = sdata->local; in ieee80211_reconfig_stations()
1660 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_reconfig_stations()
1663 list_for_each_entry(sta, &local->sta_list, list) { in ieee80211_reconfig_stations()
1666 if (!sta->uploaded || sta->sdata != sdata) in ieee80211_reconfig_stations()
1670 state < sta->sta_state; state++) in ieee80211_reconfig_stations()
1671 WARN_ON(drv_sta_state(local, sta->sdata, sta, state, in ieee80211_reconfig_stations()
1681 res = drv_start_nan(sdata->local, sdata, in ieee80211_reconfig_nan()
1682 &sdata->u.nan.conf); in ieee80211_reconfig_nan()
1686 funcs = kcalloc(sdata->local->hw.max_nan_de_entries + 1, in ieee80211_reconfig_nan()
1690 return -ENOMEM; in ieee80211_reconfig_nan()
1696 spin_lock_bh(&sdata->u.nan.func_lock); in ieee80211_reconfig_nan()
1698 idr_for_each_entry(&sdata->u.nan.function_inst_ids, func, id) in ieee80211_reconfig_nan()
1701 spin_unlock_bh(&sdata->u.nan.func_lock); in ieee80211_reconfig_nan()
1704 res = drv_add_nan_func(sdata->local, sdata, funcs[i]); in ieee80211_reconfig_nan()
1706 ieee80211_nan_func_terminated(&sdata->vif, in ieee80211_reconfig_nan()
1707 funcs[i]->instance_id, in ieee80211_reconfig_nan()
1723 for (link_id = 0; link_id < ARRAY_SIZE(sdata->link); link_id++) { in ieee80211_reconfig_ap_links()
1726 if (!(sdata->vif.active_links & BIT(link_id))) in ieee80211_reconfig_ap_links()
1729 link = sdata_dereference(sdata->link[link_id], sdata); in ieee80211_reconfig_ap_links()
1733 if (rcu_access_pointer(link->u.ap.beacon)) in ieee80211_reconfig_ap_links()
1734 drv_start_ap(local, sdata, link->conf); in ieee80211_reconfig_ap_links()
1736 if (!link->conf->enable_beacon) in ieee80211_reconfig_ap_links()
1748 struct ieee80211_hw *hw = &local->hw; in ieee80211_reconfig()
1757 bool suspended = local->suspended; in ieee80211_reconfig()
1760 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_reconfig()
1763 if (!local->open_count) in ieee80211_reconfig()
1768 local->resuming = true; in ieee80211_reconfig()
1770 if (local->wowlan) { in ieee80211_reconfig()
1774 * clear local->suspended so the device could operate in ieee80211_reconfig()
1777 local->suspended = false; in ieee80211_reconfig()
1779 local->wowlan = false; in ieee80211_reconfig()
1781 local->resuming = false; in ieee80211_reconfig()
1790 * restore local->suspended in this case. in ieee80211_reconfig()
1793 local->suspended = true; in ieee80211_reconfig()
1804 if (suspended && local->in_reconfig && !reconfig_due_to_wowlan) in ieee80211_reconfig()
1805 cancel_work_sync(&local->restart_work); in ieee80211_reconfig()
1807 local->started = false; in ieee80211_reconfig()
1829 drv_set_frag_threshold(local, hw->wiphy->frag_threshold); in ieee80211_reconfig()
1832 drv_set_rts_threshold(local, hw->wiphy->rts_threshold); in ieee80211_reconfig()
1835 drv_set_coverage_class(local, hw->wiphy->coverage_class); in ieee80211_reconfig()
1842 sdata = wiphy_dereference(local->hw.wiphy, local->monitor_sdata); in ieee80211_reconfig()
1843 if (sdata && ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF)) { in ieee80211_reconfig()
1845 WARN_ON(local->resuming); in ieee80211_reconfig()
1848 RCU_INIT_POINTER(local->monitor_sdata, NULL); in ieee80211_reconfig()
1854 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_reconfig()
1855 if (sdata->vif.type == NL80211_IFTYPE_MONITOR && in ieee80211_reconfig()
1856 !ieee80211_hw_check(&local->hw, NO_VIRTUAL_MONITOR)) in ieee80211_reconfig()
1858 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN && in ieee80211_reconfig()
1870 list_for_each_entry_continue_reverse(sdata, &local->interfaces, in ieee80211_reconfig()
1872 if (sdata->vif.type == NL80211_IFTYPE_MONITOR && in ieee80211_reconfig()
1873 !ieee80211_hw_check(&local->hw, NO_VIRTUAL_MONITOR)) in ieee80211_reconfig()
1875 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN && in ieee80211_reconfig()
1884 list_for_each_entry(ctx, &local->chanctx_list, list) in ieee80211_reconfig()
1885 if (ctx->replace_state != IEEE80211_CHANCTX_REPLACES_OTHER) in ieee80211_reconfig()
1888 sdata = wiphy_dereference(local->hw.wiphy, local->monitor_sdata); in ieee80211_reconfig()
1890 ieee80211_assign_chanctx(local, sdata, &sdata->deflink); in ieee80211_reconfig()
1902 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_reconfig()
1903 /* common change flags for all interface types - link only */ in ieee80211_reconfig()
1922 if (ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_reconfig()
1924 [0] = &sdata->vif.bss_conf, in ieee80211_reconfig()
1927 if (sdata->vif.type == NL80211_IFTYPE_STATION) { in ieee80211_reconfig()
1929 active_links = sdata->vif.active_links; in ieee80211_reconfig()
1930 link_id = ffs(active_links) - 1; in ieee80211_reconfig()
1931 sdata->vif.active_links = BIT(link_id); in ieee80211_reconfig()
1935 sdata->vif.active_links, in ieee80211_reconfig()
1939 sdata->restart_active_links = active_links; in ieee80211_reconfig()
1942 link_id < ARRAY_SIZE(sdata->vif.link_conf); in ieee80211_reconfig()
1944 if (!ieee80211_vif_link_active(&sdata->vif, link_id)) in ieee80211_reconfig()
1947 link = sdata_dereference(sdata->link[link_id], sdata); in ieee80211_reconfig()
1954 switch (sdata->vif.type) { in ieee80211_reconfig()
1959 if (sdata->vif.cfg.ibss_joined) in ieee80211_reconfig()
1967 drv_conf_tx(local, &sdata->deflink, i, in ieee80211_reconfig()
1968 &sdata->deflink.tx_conf[i]); in ieee80211_reconfig()
1972 if (sdata->vif.bss_conf.mu_mimo_owner) in ieee80211_reconfig()
1975 if (!ieee80211_vif_is_mld(&sdata->vif)) in ieee80211_reconfig()
1978 switch (sdata->vif.type) { in ieee80211_reconfig()
1980 if (!ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_reconfig()
1985 /* Re-send beacon info report to the driver */ in ieee80211_reconfig()
1986 if (sdata->deflink.u.mgd.have_beacon) in ieee80211_reconfig()
1989 if (sdata->vif.bss_conf.max_idle_period || in ieee80211_reconfig()
1990 sdata->vif.bss_conf.protected_keep_alive) in ieee80211_reconfig()
2015 if (ieee80211_vif_is_mld(&sdata->vif)) in ieee80211_reconfig()
2021 if (sdata->vif.bss_conf.ftm_responder == 1 && in ieee80211_reconfig()
2022 wiphy_ext_feature_isset(sdata->local->hw.wiphy, in ieee80211_reconfig()
2026 if (sdata->vif.type == NL80211_IFTYPE_AP) { in ieee80211_reconfig()
2029 if (ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_reconfig()
2036 if (rcu_access_pointer(sdata->deflink.u.ap.beacon)) in ieee80211_reconfig()
2038 sdata->deflink.conf); in ieee80211_reconfig()
2042 if (sdata->vif.bss_conf.enable_beacon) { in ieee80211_reconfig()
2078 if (!(local->hw.conf.flags & IEEE80211_CONF_PS)) { in ieee80211_reconfig()
2079 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_reconfig()
2080 if (sdata->vif.type != NL80211_IFTYPE_STATION) in ieee80211_reconfig()
2082 if (!sdata->u.mgd.associated) in ieee80211_reconfig()
2090 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_reconfig()
2094 switch (sdata->vif.type) { in ieee80211_reconfig()
2105 list_for_each_entry(sdata, &local->interfaces, list) in ieee80211_reconfig()
2108 /* re-enable multi-link for client interfaces */ in ieee80211_reconfig()
2109 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_reconfig()
2110 if (sdata->restart_active_links) in ieee80211_reconfig()
2111 ieee80211_set_active_links(&sdata->vif, in ieee80211_reconfig()
2112 sdata->restart_active_links); in ieee80211_reconfig()
2115 * before reconfig, it will do nothing, so re-schedule. in ieee80211_reconfig()
2117 if (sdata->desired_active_links) in ieee80211_reconfig()
2118 wiphy_work_queue(sdata->local->hw.wiphy, in ieee80211_reconfig()
2119 &sdata->activate_links_work); in ieee80211_reconfig()
2123 sched_scan_sdata = rcu_dereference_protected(local->sched_scan_sdata, in ieee80211_reconfig()
2124 lockdep_is_held(&local->hw.wiphy->mtx)); in ieee80211_reconfig()
2125 sched_scan_req = rcu_dereference_protected(local->sched_scan_req, in ieee80211_reconfig()
2126 lockdep_is_held(&local->hw.wiphy->mtx)); in ieee80211_reconfig()
2135 if (sched_scan_req->n_scan_plans > 1 || in ieee80211_reconfig()
2138 RCU_INIT_POINTER(local->sched_scan_sdata, NULL); in ieee80211_reconfig()
2139 RCU_INIT_POINTER(local->sched_scan_req, NULL); in ieee80211_reconfig()
2144 cfg80211_sched_scan_stopped_locked(local->hw.wiphy, 0); in ieee80211_reconfig()
2158 list_for_each_entry(sta, &local->sta_list, list) { in ieee80211_reconfig()
2159 if (!local->resuming) in ieee80211_reconfig()
2170 if (local->open_count && (!suspended || reconfig_due_to_wowlan)) in ieee80211_reconfig()
2173 if (local->in_reconfig) { in ieee80211_reconfig()
2174 in_reconfig = local->in_reconfig; in ieee80211_reconfig()
2175 local->in_reconfig = false; in ieee80211_reconfig()
2181 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_reconfig()
2183 wiphy_work_queue(local->hw.wiphy, &sdata->work); in ieee80211_reconfig()
2192 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_reconfig()
2195 if (sdata->vif.type == NL80211_IFTYPE_STATION) in ieee80211_reconfig()
2200 if (local->virt_monitors > 0 && in ieee80211_reconfig()
2201 local->virt_monitors == local->open_count) in ieee80211_reconfig()
2209 local->suspended = false; in ieee80211_reconfig()
2211 local->resuming = false; in ieee80211_reconfig()
2215 if (local->open_count && !reconfig_due_to_wowlan) in ieee80211_reconfig()
2218 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_reconfig()
2221 if (sdata->vif.type == NL80211_IFTYPE_STATION) in ieee80211_reconfig()
2225 mod_timer(&local->sta_cleanup, jiffies + 1); in ieee80211_reconfig()
2243 local = sdata->local; in ieee80211_reconfig_disconnect()
2245 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_reconfig_disconnect()
2248 !local->resuming)) in ieee80211_reconfig_disconnect()
2252 !local->in_reconfig)) in ieee80211_reconfig_disconnect()
2255 if (WARN_ON(vif->type != NL80211_IFTYPE_STATION)) in ieee80211_reconfig_disconnect()
2258 sdata->flags |= flag; in ieee80211_reconfig_disconnect()
2260 list_for_each_entry(key, &sdata->key_list, list) in ieee80211_reconfig_disconnect()
2261 key->flags |= KEY_FLAG_TAINTED; in ieee80211_reconfig_disconnect()
2279 struct ieee80211_local *local = sdata->local; in ieee80211_recalc_smps()
2283 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_recalc_smps()
2285 chanctx_conf = rcu_dereference_protected(link->conf->chanctx_conf, in ieee80211_recalc_smps()
2286 lockdep_is_held(&local->hw.wiphy->mtx)); in ieee80211_recalc_smps()
2304 struct ieee80211_local *local = sdata->local; in ieee80211_recalc_min_chandef()
2309 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_recalc_min_chandef()
2311 for (i = 0; i < ARRAY_SIZE(sdata->vif.link_conf); i++) { in ieee80211_recalc_min_chandef()
2318 bss_conf = rcu_dereference(sdata->vif.link_conf[i]); in ieee80211_recalc_min_chandef()
2324 chanctx_conf = rcu_dereference_protected(bss_conf->chanctx_conf, in ieee80211_recalc_min_chandef()
2325 lockdep_is_held(&local->hw.wiphy->mtx)); in ieee80211_recalc_min_chandef()
2330 * the mutex. Just the way we reached it could - in in ieee80211_recalc_min_chandef()
2331 * theory - go away, but we don't really care and in ieee80211_recalc_min_chandef()
2370 *pos++ = ht_cap->ampdu_factor | in ieee80211_ie_build_ht_cap()
2371 (ht_cap->ampdu_density << in ieee80211_ie_build_ht_cap()
2375 memcpy(pos, &ht_cap->mcs, sizeof(ht_cap->mcs)); in ieee80211_ie_build_ht_cap()
2376 pos += sizeof(ht_cap->mcs); in ieee80211_ie_build_ht_cap()
2405 memcpy(pos, &vht_cap->vht_mcs, sizeof(vht_cap->vht_mcs)); in ieee80211_ie_build_vht_cap()
2406 pos += sizeof(vht_cap->vht_mcs); in ieee80211_ie_build_vht_cap()
2422 he_cap = ieee80211_get_he_iftype_cap_vif(sband, &sdata->vif); in ieee80211_ie_len_he_cap()
2426 n = ieee80211_he_mcs_nss_size(&he_cap->he_cap_elem); in ieee80211_ie_len_he_cap()
2428 sizeof(he_cap->he_cap_elem) + n + in ieee80211_ie_len_he_cap()
2429 ieee80211_he_ppe_size(he_cap->ppe_thres[0], in ieee80211_ie_len_he_cap()
2430 he_cap->he_cap_elem.phy_cap_info); in ieee80211_ie_len_he_cap()
2440 *elem = he_cap->he_cap_elem; in ieee80211_get_adjusted_he_cap()
2442 switch (conn->bw_limit) { in ieee80211_get_adjusted_he_cap()
2457 max_ru = elem->phy_cap_info[8] & IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_MASK; in ieee80211_get_adjusted_he_cap()
2459 elem->phy_cap_info[8] &= ~IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_MASK; in ieee80211_get_adjusted_he_cap()
2460 elem->phy_cap_info[8] |= max_ru; in ieee80211_get_adjusted_he_cap()
2462 if (conn->bw_limit < IEEE80211_CONN_BW_LIMIT_40) { in ieee80211_get_adjusted_he_cap()
2463 elem->phy_cap_info[0] &= in ieee80211_get_adjusted_he_cap()
2466 elem->phy_cap_info[9] &= in ieee80211_get_adjusted_he_cap()
2470 if (conn->bw_limit < IEEE80211_CONN_BW_LIMIT_160) { in ieee80211_get_adjusted_he_cap()
2471 elem->phy_cap_info[0] &= in ieee80211_get_adjusted_he_cap()
2474 elem->phy_cap_info[5] &= in ieee80211_get_adjusted_he_cap()
2476 elem->phy_cap_info[7] &= in ieee80211_get_adjusted_he_cap()
2496 he_cap = ieee80211_get_he_iftype_cap_vif(sband, &sdata->vif); in ieee80211_put_he_cap()
2505 sizeof(he_cap->he_cap_elem) + n + in ieee80211_put_he_cap()
2506 ieee80211_he_ppe_size(he_cap->ppe_thres[0], in ieee80211_put_he_cap()
2507 he_cap->he_cap_elem.phy_cap_info); in ieee80211_put_he_cap()
2510 return -ENOBUFS; in ieee80211_put_he_cap()
2519 skb_put_data(skb, &he_cap->he_mcs_nss_supp, n); in ieee80211_put_he_cap()
2522 if ((he_cap->he_cap_elem.phy_cap_info[6] & in ieee80211_put_he_cap()
2530 n = hweight8(he_cap->ppe_thres[0] & in ieee80211_put_he_cap()
2532 n *= (1 + ((he_cap->ppe_thres[0] & IEEE80211_PPE_THRES_NSS_MASK) >> in ieee80211_put_he_cap()
2543 skb_put_data(skb, &he_cap->ppe_thres, n); in ieee80211_put_he_cap()
2546 *len = skb_tail_pointer(skb) - len - 1; in ieee80211_put_he_cap()
2556 enum nl80211_iftype iftype = ieee80211_vif_type_p2p(&sdata->vif); in ieee80211_put_he_6ghz_cap()
2559 if (!cfg80211_any_usable_channels(sdata->local->hw.wiphy, in ieee80211_put_he_6ghz_cap()
2564 sband = sdata->local->hw.wiphy->bands[NL80211_BAND_6GHZ]; in ieee80211_put_he_6ghz_cap()
2571 if (!iftd->he_6ghz_capa.capa) in ieee80211_put_he_6ghz_cap()
2574 cap = iftd->he_6ghz_capa.capa; in ieee80211_put_he_6ghz_cap()
2597 return -ENOBUFS; in ieee80211_put_he_6ghz_cap()
2615 ht_oper->primary_chan = ieee80211_frequency_to_channel( in ieee80211_ie_build_ht_oper()
2616 chandef->chan->center_freq); in ieee80211_ie_build_ht_oper()
2617 switch (chandef->width) { in ieee80211_ie_build_ht_oper()
2622 if (chandef->center_freq1 > chandef->chan->center_freq) in ieee80211_ie_build_ht_oper()
2623 ht_oper->ht_param = IEEE80211_HT_PARAM_CHA_SEC_ABOVE; in ieee80211_ie_build_ht_oper()
2625 ht_oper->ht_param = IEEE80211_HT_PARAM_CHA_SEC_BELOW; in ieee80211_ie_build_ht_oper()
2632 ht_oper->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE; in ieee80211_ie_build_ht_oper()
2635 if (ht_cap->cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40 && in ieee80211_ie_build_ht_oper()
2636 chandef->width != NL80211_CHAN_WIDTH_20_NOHT && in ieee80211_ie_build_ht_oper()
2637 chandef->width != NL80211_CHAN_WIDTH_20) in ieee80211_ie_build_ht_oper()
2638 ht_oper->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY; in ieee80211_ie_build_ht_oper()
2641 ht_oper->ht_param |= IEEE80211_HT_PARAM_RIFS_MODE; in ieee80211_ie_build_ht_oper()
2643 ht_oper->operation_mode = cpu_to_le16(prot_mode); in ieee80211_ie_build_ht_oper()
2644 ht_oper->stbc_param = 0x0000; in ieee80211_ie_build_ht_oper()
2648 memset(&ht_oper->basic_set, 0, 16); in ieee80211_ie_build_ht_oper()
2649 memcpy(&ht_oper->basic_set, &ht_cap->mcs, 10); in ieee80211_ie_build_ht_oper()
2660 switch (chandef->width) { in ieee80211_ie_build_wide_bw_cs()
2679 *pos++ = ieee80211_frequency_to_channel(chandef->center_freq1); in ieee80211_ie_build_wide_bw_cs()
2681 if (chandef->center_freq2) in ieee80211_ie_build_wide_bw_cs()
2682 *pos++ = ieee80211_frequency_to_channel(chandef->center_freq2); in ieee80211_ie_build_wide_bw_cs()
2695 vht_oper->center_freq_seg0_idx = ieee80211_frequency_to_channel( in ieee80211_ie_build_vht_oper()
2696 chandef->center_freq1); in ieee80211_ie_build_vht_oper()
2697 if (chandef->center_freq2) in ieee80211_ie_build_vht_oper()
2698 vht_oper->center_freq_seg1_idx = in ieee80211_ie_build_vht_oper()
2699 ieee80211_frequency_to_channel(chandef->center_freq2); in ieee80211_ie_build_vht_oper()
2701 vht_oper->center_freq_seg1_idx = 0x00; in ieee80211_ie_build_vht_oper()
2703 switch (chandef->width) { in ieee80211_ie_build_vht_oper()
2709 vht_oper->chan_width = IEEE80211_VHT_CHANWIDTH_80MHZ; in ieee80211_ie_build_vht_oper()
2710 vht_oper->center_freq_seg1_idx = vht_oper->center_freq_seg0_idx; in ieee80211_ie_build_vht_oper()
2711 if (chandef->chan->center_freq < chandef->center_freq1) in ieee80211_ie_build_vht_oper()
2712 vht_oper->center_freq_seg0_idx -= 8; in ieee80211_ie_build_vht_oper()
2714 vht_oper->center_freq_seg0_idx += 8; in ieee80211_ie_build_vht_oper()
2721 vht_oper->chan_width = IEEE80211_VHT_CHANWIDTH_80MHZ; in ieee80211_ie_build_vht_oper()
2724 vht_oper->chan_width = IEEE80211_VHT_CHANWIDTH_80MHZ; in ieee80211_ie_build_vht_oper()
2731 vht_oper->chan_width = IEEE80211_VHT_CHANWIDTH_USE_HT; in ieee80211_ie_build_vht_oper()
2736 vht_oper->basic_mcs_set = cpu_to_le16(0xffff); in ieee80211_ie_build_vht_oper()
2749 if (chandef->chan->band == NL80211_BAND_6GHZ) in ieee80211_ie_build_he_oper()
2763 if (chandef->chan->band == NL80211_BAND_6GHZ) in ieee80211_ie_build_he_oper()
2768 he_oper->he_oper_params = cpu_to_le32(he_oper_params); in ieee80211_ie_build_he_oper()
2771 he_oper->he_mcs_nss_set = cpu_to_le16(0xffff); in ieee80211_ie_build_he_oper()
2774 if (chandef->chan->band != NL80211_BAND_6GHZ) in ieee80211_ie_build_he_oper()
2777 cfg80211_chandef_create(&he_chandef, chandef->chan, NL80211_CHAN_NO_HT); in ieee80211_ie_build_he_oper()
2778 he_chandef.center_freq1 = chandef->center_freq1; in ieee80211_ie_build_he_oper()
2779 he_chandef.center_freq2 = chandef->center_freq2; in ieee80211_ie_build_he_oper()
2780 he_chandef.width = chandef->width; in ieee80211_ie_build_he_oper()
2784 he_6ghz_op->minrate = 6; /* 6 Mbps */ in ieee80211_ie_build_he_oper()
2785 he_6ghz_op->primary = in ieee80211_ie_build_he_oper()
2786 ieee80211_frequency_to_channel(he_chandef.chan->center_freq); in ieee80211_ie_build_he_oper()
2787 he_6ghz_op->ccfs0 = in ieee80211_ie_build_he_oper()
2790 he_6ghz_op->ccfs1 = in ieee80211_ie_build_he_oper()
2793 he_6ghz_op->ccfs1 = 0; in ieee80211_ie_build_he_oper()
2801 he_6ghz_op->ccfs0 = in ieee80211_ie_build_he_oper()
2808 he_6ghz_op->control = in ieee80211_ie_build_he_oper()
2810 he_6ghz_op->ccfs1 = he_6ghz_op->ccfs0; in ieee80211_ie_build_he_oper()
2811 if (he_chandef.chan->center_freq < he_chandef.center_freq1) in ieee80211_ie_build_he_oper()
2812 he_6ghz_op->ccfs0 -= 8; in ieee80211_ie_build_he_oper()
2814 he_6ghz_op->ccfs0 += 8; in ieee80211_ie_build_he_oper()
2817 he_6ghz_op->control = in ieee80211_ie_build_he_oper()
2821 he_6ghz_op->control = in ieee80211_ie_build_he_oper()
2825 he_6ghz_op->control = in ieee80211_ie_build_he_oper()
2829 he_6ghz_op->control = in ieee80211_ie_build_he_oper()
2845 &eht_cap->eht_mcs_nss_supp.only_20mhz; in ieee80211_ie_build_eht_oper()
2859 memcpy(&eht_oper->basic_mcs_nss, eht_mcs_nss, sizeof(*eht_mcs_nss)); in ieee80211_ie_build_eht_oper()
2860 eht_oper->params |= IEEE80211_EHT_OPER_INFO_PRESENT; in ieee80211_ie_build_eht_oper()
2864 (struct ieee80211_eht_operation_info *)eht_oper->optional; in ieee80211_ie_build_eht_oper()
2866 eht_oper_info->ccfs0 = in ieee80211_ie_build_eht_oper()
2867 ieee80211_frequency_to_channel(chandef->center_freq1); in ieee80211_ie_build_eht_oper()
2868 if (chandef->center_freq2) in ieee80211_ie_build_eht_oper()
2869 eht_oper_info->ccfs1 = in ieee80211_ie_build_eht_oper()
2870 ieee80211_frequency_to_channel(chandef->center_freq2); in ieee80211_ie_build_eht_oper()
2872 eht_oper_info->ccfs1 = 0; in ieee80211_ie_build_eht_oper()
2874 switch (chandef->width) { in ieee80211_ie_build_eht_oper()
2877 eht_oper_info->ccfs1 = eht_oper_info->ccfs0; in ieee80211_ie_build_eht_oper()
2878 if (chandef->chan->center_freq < chandef->center_freq1) in ieee80211_ie_build_eht_oper()
2879 eht_oper_info->ccfs0 -= 16; in ieee80211_ie_build_eht_oper()
2881 eht_oper_info->ccfs0 += 16; in ieee80211_ie_build_eht_oper()
2884 eht_oper_info->ccfs1 = eht_oper_info->ccfs0; in ieee80211_ie_build_eht_oper()
2885 if (chandef->chan->center_freq < chandef->center_freq1) in ieee80211_ie_build_eht_oper()
2886 eht_oper_info->ccfs0 -= 8; in ieee80211_ie_build_eht_oper()
2888 eht_oper_info->ccfs0 += 8; in ieee80211_ie_build_eht_oper()
2903 eht_oper_info->control = chan_width; in ieee80211_ie_build_eht_oper()
2906 /* TODO: eht_oper_info->optional */ in ieee80211_ie_build_eht_oper()
2919 switch (ht_oper->ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET) { in ieee80211_chandef_ht_oper()
2933 cfg80211_chandef_create(chandef, chandef->chan, channel_type); in ieee80211_chandef_ht_oper()
2957 vht_cap = hw->wiphy->bands[chandef->chan->band]->vht_cap.cap; in ieee80211_chandef_vht_oper()
2966 ccfs0 = oper->center_freq_seg0_idx; in ieee80211_chandef_vht_oper()
2967 ccfs1 = oper->center_freq_seg1_idx; in ieee80211_chandef_vht_oper()
2968 ccfs2 = (le16_to_cpu(htop->operation_mode) & in ieee80211_chandef_vht_oper()
2979 * Cf. IEEE 802.11 Table 9-250 in ieee80211_chandef_vht_oper()
3015 cf0 = ieee80211_channel_to_frequency(ccf0, chandef->chan->band); in ieee80211_chandef_vht_oper()
3016 cf1 = ieee80211_channel_to_frequency(ccf1, chandef->chan->band); in ieee80211_chandef_vht_oper()
3018 switch (oper->chan_width) { in ieee80211_chandef_vht_oper()
3029 diff = abs(ccf1 - ccf0); in ieee80211_chandef_vht_oper()
3064 chandef->center_freq1 = in ieee80211_chandef_eht_oper()
3065 ieee80211_channel_to_frequency(info->ccfs0, in ieee80211_chandef_eht_oper()
3066 chandef->chan->band); in ieee80211_chandef_eht_oper()
3068 switch (u8_get_bits(info->control, in ieee80211_chandef_eht_oper()
3071 chandef->width = NL80211_CHAN_WIDTH_20; in ieee80211_chandef_eht_oper()
3074 chandef->width = NL80211_CHAN_WIDTH_40; in ieee80211_chandef_eht_oper()
3077 chandef->width = NL80211_CHAN_WIDTH_80; in ieee80211_chandef_eht_oper()
3080 chandef->width = NL80211_CHAN_WIDTH_160; in ieee80211_chandef_eht_oper()
3081 chandef->center_freq1 = in ieee80211_chandef_eht_oper()
3082 ieee80211_channel_to_frequency(info->ccfs1, in ieee80211_chandef_eht_oper()
3083 chandef->chan->band); in ieee80211_chandef_eht_oper()
3086 chandef->width = NL80211_CHAN_WIDTH_320; in ieee80211_chandef_eht_oper()
3087 chandef->center_freq1 = in ieee80211_chandef_eht_oper()
3088 ieee80211_channel_to_frequency(info->ccfs1, in ieee80211_chandef_eht_oper()
3089 chandef->chan->band); in ieee80211_chandef_eht_oper()
3101 u32 freq; in ieee80211_chandef_he_6ghz_oper() local
3103 if (chandef->chan->band != NL80211_BAND_6GHZ) in ieee80211_chandef_he_6ghz_oper()
3118 freq = ieee80211_channel_to_frequency(he_6ghz_oper->primary, in ieee80211_chandef_he_6ghz_oper()
3120 he_chandef.chan = ieee80211_get_channel(local->hw.wiphy, freq); in ieee80211_chandef_he_6ghz_oper()
3126 !(eht_oper->params & IEEE80211_EHT_OPER_INFO_PRESENT)) { in ieee80211_chandef_he_6ghz_oper()
3127 switch (u8_get_bits(he_6ghz_oper->control, in ieee80211_chandef_he_6ghz_oper()
3140 if (!he_6ghz_oper->ccfs1) in ieee80211_chandef_he_6ghz_oper()
3142 if (abs(he_6ghz_oper->ccfs1 - he_6ghz_oper->ccfs0) == 8) in ieee80211_chandef_he_6ghz_oper()
3151 ieee80211_channel_to_frequency(he_6ghz_oper->ccfs1, in ieee80211_chandef_he_6ghz_oper()
3155 ieee80211_channel_to_frequency(he_6ghz_oper->ccfs0, in ieee80211_chandef_he_6ghz_oper()
3158 ieee80211_channel_to_frequency(he_6ghz_oper->ccfs1, in ieee80211_chandef_he_6ghz_oper()
3162 ieee80211_chandef_eht_oper((const void *)eht_oper->optional, in ieee80211_chandef_he_6ghz_oper()
3184 switch (FIELD_GET(S1G_OPER_CH_WIDTH_OPER, oper->ch_width)) { in ieee80211_chandef_s1g_oper()
3186 chandef->width = NL80211_CHAN_WIDTH_1; in ieee80211_chandef_s1g_oper()
3189 chandef->width = NL80211_CHAN_WIDTH_2; in ieee80211_chandef_s1g_oper()
3192 chandef->width = NL80211_CHAN_WIDTH_4; in ieee80211_chandef_s1g_oper()
3195 chandef->width = NL80211_CHAN_WIDTH_8; in ieee80211_chandef_s1g_oper()
3198 chandef->width = NL80211_CHAN_WIDTH_16; in ieee80211_chandef_s1g_oper()
3204 oper_freq = ieee80211_channel_to_freq_khz(oper->oper_ch, in ieee80211_chandef_s1g_oper()
3206 chandef->center_freq1 = KHZ_TO_MHZ(oper_freq); in ieee80211_chandef_s1g_oper()
3207 chandef->freq1_offset = oper_freq % 1000; in ieee80211_chandef_s1g_oper()
3220 for (i = 0; i < sband->n_bitrates; i++) { in ieee80211_put_srates_elem()
3233 rates -= skip; in ieee80211_put_srates_elem()
3237 return -ENOBUFS; in ieee80211_put_srates_elem()
3242 for (i = 0; i < sband->n_bitrates && rates; i++) { in ieee80211_put_srates_elem()
3250 skip--; in ieee80211_put_srates_elem()
3256 rate = DIV_ROUND_UP(sband->bitrates[i].bitrate, 5); in ieee80211_put_srates_elem()
3258 rates--; in ieee80211_put_srates_elem()
3271 if (WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION)) in ieee80211_ave_rssi()
3274 return -ewma_beacon_signal_read(&sdata->deflink.u.mgd.ave_beacon_signal); in ieee80211_ave_rssi()
3285 if (mcs->rx_mask[3]) in ieee80211_mcs_to_chains()
3287 if (mcs->rx_mask[2]) in ieee80211_mcs_to_chains()
3289 if (mcs->rx_mask[1]) in ieee80211_mcs_to_chains()
3295 * ieee80211_calculate_rx_timestamp - calculate timestamp in frame
3312 u64 ts = status->mactime; in ieee80211_calculate_rx_timestamp()
3321 mactime_plcp_start = (status->flag & RX_FLAG_MACTIME) == in ieee80211_calculate_rx_timestamp()
3326 ri.bw = status->bw; in ieee80211_calculate_rx_timestamp()
3329 switch (status->encoding) { in ieee80211_calculate_rx_timestamp()
3332 ri.mcs = status->rate_idx; in ieee80211_calculate_rx_timestamp()
3333 ri.nss = status->nss; in ieee80211_calculate_rx_timestamp()
3334 ri.eht_ru_alloc = status->eht.ru; in ieee80211_calculate_rx_timestamp()
3335 if (status->enc_flags & RX_ENC_FLAG_SHORT_GI) in ieee80211_calculate_rx_timestamp()
3345 ri.mcs = status->rate_idx; in ieee80211_calculate_rx_timestamp()
3346 ri.nss = status->nss; in ieee80211_calculate_rx_timestamp()
3347 ri.he_ru_alloc = status->he_ru; in ieee80211_calculate_rx_timestamp()
3348 if (status->enc_flags & RX_ENC_FLAG_SHORT_GI) in ieee80211_calculate_rx_timestamp()
3361 * For HE MU PPDU, add the HE-SIG-B. in ieee80211_calculate_rx_timestamp()
3362 * For HE ER PPDU, add 8us for the HE-SIG-A. in ieee80211_calculate_rx_timestamp()
3363 * For HE TB PPDU, add 4us for the HE-STF. in ieee80211_calculate_rx_timestamp()
3364 * Add the HE-LTF durations - variable. in ieee80211_calculate_rx_timestamp()
3370 ri.mcs = status->rate_idx; in ieee80211_calculate_rx_timestamp()
3372 if (status->enc_flags & RX_ENC_FLAG_SHORT_GI) in ieee80211_calculate_rx_timestamp()
3381 if (status->enc_flags & RX_ENC_FLAG_HT_GF) in ieee80211_calculate_rx_timestamp()
3387 * Add Data HT-LTFs per streams in ieee80211_calculate_rx_timestamp()
3388 * TODO: add Extension HT-LTFs, 4us per LTF in ieee80211_calculate_rx_timestamp()
3398 ri.mcs = status->rate_idx; in ieee80211_calculate_rx_timestamp()
3399 ri.nss = status->nss; in ieee80211_calculate_rx_timestamp()
3400 if (status->enc_flags & RX_ENC_FLAG_SHORT_GI) in ieee80211_calculate_rx_timestamp()
3412 * Add VHT-LTFs per streams in ieee80211_calculate_rx_timestamp()
3426 sband = local->hw.wiphy->bands[status->band]; in ieee80211_calculate_rx_timestamp()
3427 ri.legacy = sband->bitrates[status->rate_idx].bitrate; in ieee80211_calculate_rx_timestamp()
3430 if (status->band == NL80211_BAND_5GHZ) { in ieee80211_calculate_rx_timestamp()
3433 } else if (status->enc_flags & RX_ENC_FLAG_SHORTPRE) { in ieee80211_calculate_rx_timestamp()
3446 (unsigned long long)status->flag, status->rate_idx, in ieee80211_calculate_rx_timestamp()
3447 status->nss)) in ieee80211_calculate_rx_timestamp()
3451 if ((status->flag & RX_FLAG_MACTIME) == RX_FLAG_MACTIME_END) in ieee80211_calculate_rx_timestamp()
3452 ts -= mpdu_len * 8 * 10 / rate; in ieee80211_calculate_rx_timestamp()
3471 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_dfs_cac_cancel()
3473 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_dfs_cac_cancel()
3476 link = sdata_dereference(sdata->link[link_id], in ieee80211_dfs_cac_cancel()
3481 chanctx_conf = sdata_dereference(link->conf->chanctx_conf, in ieee80211_dfs_cac_cancel()
3483 if (ctx && &ctx->conf != chanctx_conf) in ieee80211_dfs_cac_cancel()
3486 wiphy_delayed_work_cancel(local->hw.wiphy, in ieee80211_dfs_cac_cancel()
3487 &link->dfs_cac_timer_work); in ieee80211_dfs_cac_cancel()
3489 if (!sdata->wdev.links[link_id].cac_started) in ieee80211_dfs_cac_cancel()
3492 chandef = link->conf->chanreq.oper; in ieee80211_dfs_cac_cancel()
3494 cfg80211_cac_event(sdata->dev, &chandef, in ieee80211_dfs_cac_cancel()
3509 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_dfs_radar_detected_work()
3511 list_for_each_entry(ctx, &local->chanctx_list, list) { in ieee80211_dfs_radar_detected_work()
3512 if (ctx->replace_state == IEEE80211_CHANCTX_REPLACES_OTHER) in ieee80211_dfs_radar_detected_work()
3515 if (!ctx->radar_detected) in ieee80211_dfs_radar_detected_work()
3518 ctx->radar_detected = false; in ieee80211_dfs_radar_detected_work()
3520 chandef = ctx->conf.def; in ieee80211_dfs_radar_detected_work()
3523 cfg80211_radar_event(local->hw.wiphy, &chandef, GFP_KERNEL); in ieee80211_dfs_radar_detected_work()
3536 if (ctx->replace_state == IEEE80211_CHANCTX_REPLACES_OTHER) in ieee80211_radar_mark_chan_ctx_iterator()
3542 ctx->radar_detected = true; in ieee80211_radar_mark_chan_ctx_iterator()
3555 wiphy_work_queue(hw->wiphy, &local->radar_detected_work); in ieee80211_radar_detected()
3570 /* no-HT indicates nothing to do */ in ieee80211_chandef_downgrade()
3573 switch (c->width) { in ieee80211_chandef_downgrade()
3579 c->width = NL80211_CHAN_WIDTH_20_NOHT; in ieee80211_chandef_downgrade()
3580 conn->mode = IEEE80211_CONN_MODE_LEGACY; in ieee80211_chandef_downgrade()
3581 conn->bw_limit = IEEE80211_CONN_BW_LIMIT_20; in ieee80211_chandef_downgrade()
3582 c->punctured = 0; in ieee80211_chandef_downgrade()
3585 c->width = NL80211_CHAN_WIDTH_20; in ieee80211_chandef_downgrade()
3586 c->center_freq1 = c->chan->center_freq; in ieee80211_chandef_downgrade()
3587 if (conn->mode == IEEE80211_CONN_MODE_VHT) in ieee80211_chandef_downgrade()
3588 conn->mode = IEEE80211_CONN_MODE_HT; in ieee80211_chandef_downgrade()
3589 conn->bw_limit = IEEE80211_CONN_BW_LIMIT_20; in ieee80211_chandef_downgrade()
3590 c->punctured = 0; in ieee80211_chandef_downgrade()
3594 if (conn->mode == IEEE80211_CONN_MODE_VHT) in ieee80211_chandef_downgrade()
3595 conn->mode = IEEE80211_CONN_MODE_HT; in ieee80211_chandef_downgrade()
3596 conn->bw_limit = IEEE80211_CONN_BW_LIMIT_40; in ieee80211_chandef_downgrade()
3599 c->center_freq2 = 0; in ieee80211_chandef_downgrade()
3600 c->width = NL80211_CHAN_WIDTH_80; in ieee80211_chandef_downgrade()
3601 conn->bw_limit = IEEE80211_CONN_BW_LIMIT_80; in ieee80211_chandef_downgrade()
3605 conn->bw_limit = IEEE80211_CONN_BW_LIMIT_80; in ieee80211_chandef_downgrade()
3609 conn->bw_limit = IEEE80211_CONN_BW_LIMIT_160; in ieee80211_chandef_downgrade()
3617 /* keep c->width */ in ieee80211_chandef_downgrade()
3618 conn->mode = IEEE80211_CONN_MODE_S1G; in ieee80211_chandef_downgrade()
3619 conn->bw_limit = IEEE80211_CONN_BW_LIMIT_20; in ieee80211_chandef_downgrade()
3624 /* keep c->width */ in ieee80211_chandef_downgrade()
3625 conn->mode = IEEE80211_CONN_MODE_LEGACY; in ieee80211_chandef_downgrade()
3626 conn->bw_limit = IEEE80211_CONN_BW_LIMIT_20; in ieee80211_chandef_downgrade()
3631 c->center_freq1 = cfg80211_chandef_primary(c, new_primary_width, in ieee80211_chandef_downgrade()
3632 &c->punctured); in ieee80211_chandef_downgrade()
3633 c->width = new_primary_width; in ieee80211_chandef_downgrade()
3641 if (!cfg80211_chandef_valid(c) && c->punctured) in ieee80211_chandef_downgrade()
3652 struct ieee80211_local *local = sdata->local; in ieee80211_send_action_csa()
3653 int freq; in ieee80211_send_action_csa() local
3658 if (sdata->vif.type != NL80211_IFTYPE_ADHOC && in ieee80211_send_action_csa()
3659 sdata->vif.type != NL80211_IFTYPE_MESH_POINT) in ieee80211_send_action_csa()
3660 return -EOPNOTSUPP; in ieee80211_send_action_csa()
3662 skb = dev_alloc_skb(local->tx_headroom + hdr_len + in ieee80211_send_action_csa()
3668 return -ENOMEM; in ieee80211_send_action_csa()
3670 skb_reserve(skb, local->tx_headroom); in ieee80211_send_action_csa()
3672 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | in ieee80211_send_action_csa()
3675 eth_broadcast_addr(mgmt->da); in ieee80211_send_action_csa()
3676 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); in ieee80211_send_action_csa()
3677 if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_send_action_csa()
3678 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN); in ieee80211_send_action_csa()
3680 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; in ieee80211_send_action_csa()
3681 memcpy(mgmt->bssid, ifibss->bssid, ETH_ALEN); in ieee80211_send_action_csa()
3683 mgmt->u.action.category = WLAN_CATEGORY_SPECTRUM_MGMT; in ieee80211_send_action_csa()
3684 mgmt->u.action.u.chan_switch.action_code = WLAN_ACTION_SPCT_CHL_SWITCH; in ieee80211_send_action_csa()
3688 *pos++ = csa_settings->block_tx ? 1 : 0; /* CSA mode */ in ieee80211_send_action_csa()
3689 freq = csa_settings->chandef.chan->center_freq; in ieee80211_send_action_csa()
3690 *pos++ = ieee80211_frequency_to_channel(freq); /* channel */ in ieee80211_send_action_csa()
3691 *pos++ = csa_settings->count; /* count */ in ieee80211_send_action_csa()
3693 if (csa_settings->chandef.width == NL80211_CHAN_WIDTH_40) { in ieee80211_send_action_csa()
3699 ch_type = cfg80211_get_chandef_type(&csa_settings->chandef); in ieee80211_send_action_csa()
3706 if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_send_action_csa()
3707 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; in ieee80211_send_action_csa()
3712 *pos++ = sdata->u.mesh.mshcfg.dot11MeshTTL; /* Mesh TTL */ in ieee80211_send_action_csa()
3715 *pos++ |= csa_settings->block_tx ? in ieee80211_send_action_csa()
3719 put_unaligned_le16(ifmsh->pre_value, pos);/* Precedence Value */ in ieee80211_send_action_csa()
3723 if (csa_settings->chandef.width == NL80211_CHAN_WIDTH_80 || in ieee80211_send_action_csa()
3724 csa_settings->chandef.width == NL80211_CHAN_WIDTH_80P80 || in ieee80211_send_action_csa()
3725 csa_settings->chandef.width == NL80211_CHAN_WIDTH_160) { in ieee80211_send_action_csa()
3727 ieee80211_ie_build_wide_bw_cs(pos, &csa_settings->chandef); in ieee80211_send_action_csa()
3737 s32 end = data->desc[i].start + data->desc[i].duration - (tsf + 1); in ieee80211_extend_noa_desc()
3744 if (data->count[i] == 1) in ieee80211_extend_noa_desc()
3747 if (data->desc[i].interval == 0) in ieee80211_extend_noa_desc()
3751 skip = DIV_ROUND_UP(-end, data->desc[i].interval); in ieee80211_extend_noa_desc()
3752 if (data->count[i] < 255) { in ieee80211_extend_noa_desc()
3753 if (data->count[i] <= skip) { in ieee80211_extend_noa_desc()
3754 data->count[i] = 0; in ieee80211_extend_noa_desc()
3758 data->count[i] -= skip; in ieee80211_extend_noa_desc()
3761 data->desc[i].start += skip * data->desc[i].interval; in ieee80211_extend_noa_desc()
3776 if (!data->count[i]) in ieee80211_extend_absent_time()
3782 cur = data->desc[i].start - tsf; in ieee80211_extend_absent_time()
3786 cur = data->desc[i].start + data->desc[i].duration - tsf; in ieee80211_extend_absent_time()
3800 * arbitrary limit, used to avoid infinite loops when combined NoA in ieee80211_get_noa_absent_time()
3818 u32 next_offset = BIT(31) - 1; in ieee80211_update_p2p_noa()
3821 data->absent = 0; in ieee80211_update_p2p_noa()
3822 data->has_next_tsf = false; in ieee80211_update_p2p_noa()
3826 if (!data->count[i]) in ieee80211_update_p2p_noa()
3830 start = data->desc[i].start - tsf; in ieee80211_update_p2p_noa()
3832 data->absent |= BIT(i); in ieee80211_update_p2p_noa()
3837 data->has_next_tsf = true; in ieee80211_update_p2p_noa()
3840 if (data->absent) in ieee80211_update_p2p_noa()
3843 data->next_tsf = tsf + next_offset; in ieee80211_update_p2p_noa()
3856 const struct ieee80211_p2p_noa_desc *desc = &attr->desc[i]; in ieee80211_parse_p2p_noa()
3858 if (!desc->count || !desc->duration) in ieee80211_parse_p2p_noa()
3861 data->count[i] = desc->count; in ieee80211_parse_p2p_noa()
3862 data->desc[i].start = le32_to_cpu(desc->start_time); in ieee80211_parse_p2p_noa()
3863 data->desc[i].duration = le32_to_cpu(desc->duration); in ieee80211_parse_p2p_noa()
3864 data->desc[i].interval = le32_to_cpu(desc->interval); in ieee80211_parse_p2p_noa()
3866 if (data->count[i] > 1 && in ieee80211_parse_p2p_noa()
3867 data->desc[i].interval < data->desc[i].duration) in ieee80211_parse_p2p_noa()
3886 u32 beacon_int = sdata->vif.bss_conf.beacon_int * 1024; in ieee80211_recalc_dtim()
3887 u8 dtim_period = sdata->vif.bss_conf.dtim_period; in ieee80211_recalc_dtim()
3891 if (tsf == -1ULL || !beacon_int || !dtim_period) in ieee80211_recalc_dtim()
3894 if (sdata->vif.type == NL80211_IFTYPE_AP || in ieee80211_recalc_dtim()
3895 sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in ieee80211_recalc_dtim()
3896 if (!sdata->bss) in ieee80211_recalc_dtim()
3899 ps = &sdata->bss->ps; in ieee80211_recalc_dtim()
3900 } else if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_recalc_dtim()
3901 ps = &sdata->u.mesh.ps; in ieee80211_recalc_dtim()
3909 * dtim_count = dtim_period - (tsf / bcn_int) % dtim_period in ieee80211_recalc_dtim()
3917 dtim_count = dtim_period - bcns_from_dtim; in ieee80211_recalc_dtim()
3919 ps->dtim_count = dtim_count; in ieee80211_recalc_dtim()
3928 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_chanctx_radar_detect()
3930 if (WARN_ON(ctx->replace_state == IEEE80211_CHANCTX_WILL_BE_REPLACED)) in ieee80211_chanctx_radar_detect()
3933 list_for_each_entry(link, &ctx->reserved_links, reserved_chanctx_list) in ieee80211_chanctx_radar_detect()
3934 if (link->reserved_radar_required) in ieee80211_chanctx_radar_detect()
3935 radar_detect |= BIT(link->reserved.oper.width); in ieee80211_chanctx_radar_detect()
3938 * An in-place reservation context should not have any assigned vifs in ieee80211_chanctx_radar_detect()
3941 WARN_ON(ctx->replace_state == IEEE80211_CHANCTX_REPLACES_OTHER && in ieee80211_chanctx_radar_detect()
3942 !list_empty(&ctx->assigned_links)); in ieee80211_chanctx_radar_detect()
3944 list_for_each_entry(link, &ctx->assigned_links, assigned_chanctx_list) { in ieee80211_chanctx_radar_detect()
3945 if (!link->radar_required) in ieee80211_chanctx_radar_detect()
3949 BIT(link->conf->chanreq.oper.width); in ieee80211_chanctx_radar_detect()
3963 for_each_vif_active_link(&sdata->vif, link_conf, link_id) { in __ieee80211_get_radio_mask()
3964 conf = sdata_dereference(link_conf->chanctx_conf, sdata); in __ieee80211_get_radio_mask()
3965 if (!conf || conf->radio_idx < 0) in __ieee80211_get_radio_mask()
3968 mask |= BIT(conf->radio_idx); in __ieee80211_get_radio_mask()
4000 list_for_each_entry(ctx, &local->chanctx_list, list) { in ieee80211_fill_ifcomb_params()
4001 if (ctx->replace_state == IEEE80211_CHANCTX_WILL_BE_REPLACED) in ieee80211_fill_ifcomb_params()
4004 if (params->radio_idx >= 0 && in ieee80211_fill_ifcomb_params()
4005 ctx->conf.radio_idx != params->radio_idx) in ieee80211_fill_ifcomb_params()
4008 params->radar_detect |= in ieee80211_fill_ifcomb_params()
4011 if (chandef && ctx->mode != IEEE80211_CHANCTX_EXCLUSIVE && in ieee80211_fill_ifcomb_params()
4012 cfg80211_chandef_compatible(chandef, &ctx->conf.def)) in ieee80211_fill_ifcomb_params()
4015 params->num_different_channels++; in ieee80211_fill_ifcomb_params()
4018 list_for_each_entry(sdata_iter, &local->interfaces, list) { in ieee80211_fill_ifcomb_params()
4021 wdev_iter = &sdata_iter->wdev; in ieee80211_fill_ifcomb_params()
4025 cfg80211_iftype_allowed(local->hw.wiphy, in ieee80211_fill_ifcomb_params()
4026 wdev_iter->iftype, 0, 1)) in ieee80211_fill_ifcomb_params()
4029 if (!ieee80211_sdata_uses_radio(sdata_iter, params->radio_idx)) in ieee80211_fill_ifcomb_params()
4032 params->iftype_num[wdev_iter->iftype]++; in ieee80211_fill_ifcomb_params()
4045 struct ieee80211_local *local = sdata->local; in ieee80211_check_combinations()
4046 enum nl80211_iftype iftype = sdata->wdev.iftype; in ieee80211_check_combinations()
4053 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_check_combinations()
4056 return -EINVAL; in ieee80211_check_combinations()
4059 !chandef->chan)) in ieee80211_check_combinations()
4060 return -EINVAL; in ieee80211_check_combinations()
4063 return -EINVAL; in ieee80211_check_combinations()
4065 if (sdata->vif.type == NL80211_IFTYPE_AP || in ieee80211_check_combinations()
4066 sdata->vif.type == NL80211_IFTYPE_MESH_POINT) { in ieee80211_check_combinations()
4072 params.new_beacon_int = sdata->vif.bss_conf.beacon_int; in ieee80211_check_combinations()
4076 if (cfg80211_iftype_allowed(local->hw.wiphy, iftype, 0, 1)) { in ieee80211_check_combinations()
4078 return -EINVAL; in ieee80211_check_combinations()
4094 return cfg80211_check_combinations(local->hw.wiphy, &params); in ieee80211_check_combinations()
4104 c->num_different_channels); in ieee80211_iter_max_chans()
4115 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_max_num_channels()
4119 err = cfg80211_iter_combinations(local->hw.wiphy, &params, in ieee80211_max_num_channels()
4132 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_add_s1g_capab_ie()
4137 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION)) in ieee80211_add_s1g_capab_ie()
4140 if (!caps->s1g) in ieee80211_add_s1g_capab_ie()
4143 memcpy(s1g_capab.capab_info, caps->cap, sizeof(caps->cap)); in ieee80211_add_s1g_capab_ie()
4144 memcpy(s1g_capab.supp_mcs_nss, caps->nss_mcs, sizeof(caps->nss_mcs)); in ieee80211_add_s1g_capab_ie()
4147 for (i = 0; i < sizeof(ifmgd->s1g_capa.capab_info); i++) { in ieee80211_add_s1g_capab_ie()
4148 u8 mask = ifmgd->s1g_capa_mask.capab_info[i]; in ieee80211_add_s1g_capab_ie()
4151 s1g_capab.capab_info[i] |= ifmgd->s1g_capa.capab_info[i] & mask; in ieee80211_add_s1g_capab_ie()
4155 for (i = 0; i < sizeof(ifmgd->s1g_capa.supp_mcs_nss); i++) { in ieee80211_add_s1g_capab_ie()
4156 u8 mask = ifmgd->s1g_capa_mask.supp_mcs_nss[i]; in ieee80211_add_s1g_capab_ie()
4160 ifmgd->s1g_capa.supp_mcs_nss[i] & mask; in ieee80211_add_s1g_capab_ie()
4190 *buf++ = qosinfo; /* U-APSD no in use */ in ieee80211_add_wmm_info_ie()
4203 skb_queue_walk(&txqi->frags, skb) { in ieee80211_txq_get_depth()
4205 frag_bytes += skb->len; in ieee80211_txq_get_depth()
4209 *frame_cnt = txqi->tin.backlog_packets + frag_cnt; in ieee80211_txq_get_depth()
4212 *byte_cnt = txqi->tin.backlog_bytes + frag_bytes; in ieee80211_txq_get_depth()
4257 he_cap = ieee80211_get_he_iftype_cap_vif(sband, &sdata->vif); in ieee80211_ie_len_eht_cap()
4258 eht_cap = ieee80211_get_eht_iftype_cap_vif(sband, &sdata->vif); in ieee80211_ie_len_eht_cap()
4262 is_ap = sdata->vif.type == NL80211_IFTYPE_AP; in ieee80211_ie_len_eht_cap()
4264 n = ieee80211_eht_mcs_nss_size(&he_cap->he_cap_elem, in ieee80211_ie_len_eht_cap()
4265 &eht_cap->eht_cap_elem, in ieee80211_ie_len_eht_cap()
4268 sizeof(eht_cap->eht_cap_elem) + n + in ieee80211_ie_len_eht_cap()
4269 ieee80211_eht_ppe_size(eht_cap->eht_ppe_thres[0], in ieee80211_ie_len_eht_cap()
4270 eht_cap->eht_cap_elem.phy_cap_info); in ieee80211_ie_len_eht_cap()
4280 ieee80211_get_he_iftype_cap_vif(sband, &sdata->vif); in ieee80211_put_eht_cap()
4282 ieee80211_get_eht_iftype_cap_vif(sband, &sdata->vif); in ieee80211_put_eht_cap()
4283 bool for_ap = sdata->vif.type == NL80211_IFTYPE_AP; in ieee80211_put_eht_cap()
4297 orig_mcs_nss_len = ieee80211_eht_mcs_nss_size(&he_cap->he_cap_elem, in ieee80211_put_eht_cap()
4298 &eht_cap->eht_cap_elem, in ieee80211_put_eht_cap()
4303 fixed = eht_cap->eht_cap_elem; in ieee80211_put_eht_cap()
4305 if (conn->bw_limit < IEEE80211_CONN_BW_LIMIT_80) in ieee80211_put_eht_cap()
4309 if (conn->bw_limit < IEEE80211_CONN_BW_LIMIT_160) { in ieee80211_put_eht_cap()
4318 if (conn->bw_limit < IEEE80211_CONN_BW_LIMIT_320) { in ieee80211_put_eht_cap()
4329 if (conn->bw_limit == IEEE80211_CONN_BW_LIMIT_20) in ieee80211_put_eht_cap()
4334 ppet_len = ieee80211_eht_ppe_size(eht_cap->eht_ppe_thres[0], in ieee80211_put_eht_cap()
4337 ie_len = 2 + 1 + sizeof(eht_cap->eht_cap_elem) + mcs_nss_len + ppet_len; in ieee80211_put_eht_cap()
4339 return -ENOBUFS; in ieee80211_put_eht_cap()
4342 skb_put_u8(skb, ie_len - 2); in ieee80211_put_eht_cap()
4348 * If the (non-AP) STA became 20 MHz only, then convert from in ieee80211_put_eht_cap()
4349 * <=80 to 20-MHz-only format, where MCSes are indicated in in ieee80211_put_eht_cap()
4350 * the groups 0-7, 8-9, 10-11, 12-13 rather than just 0-9, in ieee80211_put_eht_cap()
4351 * 10-11, 12-13. Thus, use 0-9 for 0-7 and 8-9. in ieee80211_put_eht_cap()
4353 skb_put_u8(skb, eht_cap->eht_mcs_nss_supp.bw._80.rx_tx_mcs9_max_nss); in ieee80211_put_eht_cap()
4354 skb_put_u8(skb, eht_cap->eht_mcs_nss_supp.bw._80.rx_tx_mcs9_max_nss); in ieee80211_put_eht_cap()
4355 skb_put_u8(skb, eht_cap->eht_mcs_nss_supp.bw._80.rx_tx_mcs11_max_nss); in ieee80211_put_eht_cap()
4356 skb_put_u8(skb, eht_cap->eht_mcs_nss_supp.bw._80.rx_tx_mcs13_max_nss); in ieee80211_put_eht_cap()
4358 skb_put_data(skb, &eht_cap->eht_mcs_nss_supp, mcs_nss_len); in ieee80211_put_eht_cap()
4362 skb_put_data(skb, &eht_cap->eht_ppe_thres, ppet_len); in ieee80211_put_eht_cap()
4387 switch (chandef->width) { in ieee80211_min_bw_limit_from_chandef()
4401 WARN(1, "unhandled chandef width %d\n", chandef->width); in ieee80211_min_bw_limit_from_chandef()
4409 tpe->max_local[i].valid = false; in ieee80211_clear_tpe()
4410 memset(tpe->max_local[i].power, in ieee80211_clear_tpe()
4412 sizeof(tpe->max_local[i].power)); in ieee80211_clear_tpe()
4414 tpe->max_reg_client[i].valid = false; in ieee80211_clear_tpe()
4415 memset(tpe->max_reg_client[i].power, in ieee80211_clear_tpe()
4417 sizeof(tpe->max_reg_client[i].power)); in ieee80211_clear_tpe()
4419 tpe->psd_local[i].valid = false; in ieee80211_clear_tpe()
4420 memset(tpe->psd_local[i].power, in ieee80211_clear_tpe()
4422 sizeof(tpe->psd_local[i].power)); in ieee80211_clear_tpe()
4424 tpe->psd_reg_client[i].valid = false; in ieee80211_clear_tpe()
4425 memset(tpe->psd_reg_client[i].power, in ieee80211_clear_tpe()
4427 sizeof(tpe->psd_reg_client[i].power)); in ieee80211_clear_tpe()