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()
1212 sband = local->hw.wiphy->bands[band]; in ieee80211_put_preq_ies_band()
1220 return ieee80211_put_s1g_cap(skb, &sband->s1g_cap); in ieee80211_put_preq_ies_band()
1238 if (skb_tailroom(skb) < noffset - *offset) in ieee80211_put_preq_ies_band()
1239 return -ENOBUFS; in ieee80211_put_preq_ies_band()
1240 skb_put_data(skb, ie + *offset, noffset - *offset); in ieee80211_put_preq_ies_band()
1249 if (chandef->chan && sband->band == NL80211_BAND_2GHZ) { in ieee80211_put_preq_ies_band()
1251 return -ENOBUFS; in ieee80211_put_preq_ies_band()
1255 ieee80211_frequency_to_channel(chandef->chan->center_freq)); in ieee80211_put_preq_ies_band()
1274 if (skb_tailroom(skb) < noffset - *offset) in ieee80211_put_preq_ies_band()
1275 return -ENOBUFS; in ieee80211_put_preq_ies_band()
1276 skb_put_data(skb, ie + *offset, noffset - *offset); in ieee80211_put_preq_ies_band()
1280 if (sband->ht_cap.ht_supported) { in ieee80211_put_preq_ies_band()
1284 return -ENOBUFS; in ieee80211_put_preq_ies_band()
1287 ieee80211_ie_build_ht_cap(pos, &sband->ht_cap, in ieee80211_put_preq_ies_band()
1288 sband->ht_cap.cap); in ieee80211_put_preq_ies_band()
1304 /* 60 GHz (Multi-band, DMG, MMS) can't happen */ in ieee80211_put_preq_ies_band()
1309 if (skb_tailroom(skb) < noffset - *offset) in ieee80211_put_preq_ies_band()
1310 return -ENOBUFS; in ieee80211_put_preq_ies_band()
1311 skb_put_data(skb, ie + *offset, noffset - *offset); in ieee80211_put_preq_ies_band()
1316 for (i = 0; i < sband->n_channels; i++) { in ieee80211_put_preq_ies_band()
1317 if (sband->channels[i].flags & (IEEE80211_CHAN_DISABLED | in ieee80211_put_preq_ies_band()
1325 if (sband->vht_cap.vht_supported && have_80mhz) { in ieee80211_put_preq_ies_band()
1329 return -ENOBUFS; in ieee80211_put_preq_ies_band()
1332 ieee80211_ie_build_vht_cap(pos, &sband->vht_cap, in ieee80211_put_preq_ies_band()
1333 sband->vht_cap.cap); in ieee80211_put_preq_ies_band()
1350 if (skb_tailroom(skb) < noffset - *offset) in ieee80211_put_preq_ies_band()
1351 return -ENOBUFS; in ieee80211_put_preq_ies_band()
1352 skb_put_data(skb, ie + *offset, noffset - *offset); in ieee80211_put_preq_ies_band()
1356 if (cfg80211_any_usable_channels(local->hw.wiphy, BIT(sband->band), in ieee80211_put_preq_ies_band()
1363 if (cfg80211_any_usable_channels(local->hw.wiphy, BIT(sband->band), in ieee80211_put_preq_ies_band()
1377 * that calculates local->scan_ies_len. in ieee80211_put_preq_ies_band()
1398 ie_desc->ies[i] = skb_tail_pointer(skb); in ieee80211_put_preq_ies()
1406 ie_desc->len[i] = skb_tail_pointer(skb) - in ieee80211_put_preq_ies()
1407 ie_desc->ies[i]; in ieee80211_put_preq_ies()
1413 if (WARN_ONCE(skb_tailroom(skb) < ie_len - custom_ie_offset, in ieee80211_put_preq_ies()
1415 return -ENOBUFS; in ieee80211_put_preq_ies()
1416 ie_desc->common_ies = skb_tail_pointer(skb); in ieee80211_put_preq_ies()
1418 ie_len - custom_ie_offset); in ieee80211_put_preq_ies()
1419 ie_desc->common_ie_len = skb_tail_pointer(skb) - in ieee80211_put_preq_ies()
1420 ie_desc->common_ies; in ieee80211_put_preq_ies()
1440 return -ENOMEM; in ieee80211_build_preq_ies()
1451 if (skb->len > buffer_len) { in ieee80211_build_preq_ies()
1452 ret = -ENOBUFS; in ieee80211_build_preq_ies()
1456 memcpy(buffer, start, skb->len); in ieee80211_build_preq_ies()
1460 offs = ie_desc->ies[i] - start; in ieee80211_build_preq_ies()
1461 ie_desc->ies[i] = buffer + offs; in ieee80211_build_preq_ies()
1463 offs = ie_desc->common_ies - start; in ieee80211_build_preq_ies()
1464 ie_desc->common_ies = buffer + offs; in ieee80211_build_preq_ies()
1466 ret = skb->len; in ieee80211_build_preq_ies()
1480 struct ieee80211_local *local = sdata->local; in ieee80211_build_probe_req()
1490 * badly-behaved APs don't respond when this parameter is included. in ieee80211_build_probe_req()
1492 chandef.width = sdata->vif.bss_conf.chanreq.oper.width; in ieee80211_build_probe_req()
1498 skb = ieee80211_probereq_get(&local->hw, src, ssid, ssid_len, in ieee80211_build_probe_req()
1499 local->scan_ies_len + ie_len); in ieee80211_build_probe_req()
1503 rate_masks[chan->band] = ratemask; in ieee80211_build_probe_req()
1505 ie, ie_len, BIT(chan->band), in ieee80211_build_probe_req()
1509 mgmt = (struct ieee80211_mgmt *) skb->data; in ieee80211_build_probe_req()
1510 memcpy(mgmt->da, dst, ETH_ALEN); in ieee80211_build_probe_req()
1511 memcpy(mgmt->bssid, dst, ETH_ALEN); in ieee80211_build_probe_req()
1514 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; in ieee80211_build_probe_req()
1528 sband = sdata->local->hw.wiphy->bands[band]; in ieee80211_sta_get_rates()
1533 ieee80211_chandef_rate_flags(&sdata->vif.bss_conf.chanreq.oper); in ieee80211_sta_get_rates()
1535 num_rates = sband->n_bitrates; in ieee80211_sta_get_rates()
1537 for (i = 0; i < elems->supp_rates_len + in ieee80211_sta_get_rates()
1538 elems->ext_supp_rates_len; i++) { in ieee80211_sta_get_rates()
1542 if (i < elems->supp_rates_len) in ieee80211_sta_get_rates()
1543 rate = elems->supp_rates[i]; in ieee80211_sta_get_rates()
1544 else if (elems->ext_supp_rates) in ieee80211_sta_get_rates()
1545 rate = elems->ext_supp_rates in ieee80211_sta_get_rates()
1546 [i - elems->supp_rates_len]; in ieee80211_sta_get_rates()
1555 if ((rate_flags & sband->bitrates[j].flags) in ieee80211_sta_get_rates()
1559 brate = sband->bitrates[j].bitrate; in ieee80211_sta_get_rates()
1580 wiphy_work_cancel(local->hw.wiphy, &local->reconfig_filter); in ieee80211_stop_device()
1582 flush_workqueue(local->workqueue); in ieee80211_stop_device()
1583 wiphy_work_flush(local->hw.wiphy, NULL); in ieee80211_stop_device()
1597 if (test_bit(SCAN_COMPLETED, &local->scanning)) { in ieee80211_flush_completed_scan()
1599 * we don't attempt to continue a partial HW scan - which is in ieee80211_flush_completed_scan()
1604 set_bit(SCAN_ABORTED, &local->scanning); in ieee80211_flush_completed_scan()
1605 wiphy_delayed_work_queue(local->hw.wiphy, &local->scan_work, 0); in ieee80211_flush_completed_scan()
1606 wiphy_delayed_work_flush(local->hw.wiphy, &local->scan_work); in ieee80211_flush_completed_scan()
1615 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_handle_reconfig_failure()
1627 local->resuming = false; in ieee80211_handle_reconfig_failure()
1628 local->suspended = false; in ieee80211_handle_reconfig_failure()
1629 local->in_reconfig = false; in ieee80211_handle_reconfig_failure()
1630 local->reconfig_failure = true; in ieee80211_handle_reconfig_failure()
1639 list_for_each_entry(sdata, &local->interfaces, list) in ieee80211_handle_reconfig_failure()
1640 sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER; in ieee80211_handle_reconfig_failure()
1645 list_for_each_entry(ctx, &local->chanctx_list, list) in ieee80211_handle_reconfig_failure()
1646 ctx->driver_present = false; in ieee80211_handle_reconfig_failure()
1656 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_assign_chanctx()
1658 conf = rcu_dereference_protected(link->conf->chanctx_conf, in ieee80211_assign_chanctx()
1659 lockdep_is_held(&local->hw.wiphy->mtx)); in ieee80211_assign_chanctx()
1662 drv_assign_vif_chanctx(local, sdata, link->conf, ctx); in ieee80211_assign_chanctx()
1668 struct ieee80211_local *local = sdata->local; in ieee80211_reconfig_stations()
1671 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_reconfig_stations()
1674 list_for_each_entry(sta, &local->sta_list, list) { in ieee80211_reconfig_stations()
1677 if (!sta->uploaded || sta->sdata != sdata) in ieee80211_reconfig_stations()
1681 state < sta->sta_state; state++) in ieee80211_reconfig_stations()
1682 WARN_ON(drv_sta_state(local, sta->sdata, sta, state, in ieee80211_reconfig_stations()
1692 res = drv_start_nan(sdata->local, sdata, in ieee80211_reconfig_nan()
1693 &sdata->u.nan.conf); in ieee80211_reconfig_nan()
1697 funcs = kcalloc(sdata->local->hw.max_nan_de_entries + 1, in ieee80211_reconfig_nan()
1701 return -ENOMEM; in ieee80211_reconfig_nan()
1707 spin_lock_bh(&sdata->u.nan.func_lock); in ieee80211_reconfig_nan()
1709 idr_for_each_entry(&sdata->u.nan.function_inst_ids, func, id) in ieee80211_reconfig_nan()
1712 spin_unlock_bh(&sdata->u.nan.func_lock); in ieee80211_reconfig_nan()
1715 res = drv_add_nan_func(sdata->local, sdata, funcs[i]); in ieee80211_reconfig_nan()
1717 ieee80211_nan_func_terminated(&sdata->vif, in ieee80211_reconfig_nan()
1718 funcs[i]->instance_id, in ieee80211_reconfig_nan()
1734 for (link_id = 0; link_id < ARRAY_SIZE(sdata->link); link_id++) { in ieee80211_reconfig_ap_links()
1737 if (!(sdata->vif.active_links & BIT(link_id))) in ieee80211_reconfig_ap_links()
1740 link = sdata_dereference(sdata->link[link_id], sdata); in ieee80211_reconfig_ap_links()
1744 if (rcu_access_pointer(link->u.ap.beacon)) in ieee80211_reconfig_ap_links()
1745 drv_start_ap(local, sdata, link->conf); in ieee80211_reconfig_ap_links()
1747 if (!link->conf->enable_beacon) in ieee80211_reconfig_ap_links()
1759 struct ieee80211_hw *hw = &local->hw; in ieee80211_reconfig()
1768 bool suspended = local->suspended; in ieee80211_reconfig()
1771 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_reconfig()
1774 if (!local->open_count) in ieee80211_reconfig()
1779 local->resuming = true; in ieee80211_reconfig()
1781 if (local->wowlan) { in ieee80211_reconfig()
1785 * clear local->suspended so the device could operate in ieee80211_reconfig()
1788 local->suspended = false; in ieee80211_reconfig()
1790 local->wowlan = false; in ieee80211_reconfig()
1792 local->resuming = false; in ieee80211_reconfig()
1801 * restore local->suspended in this case. in ieee80211_reconfig()
1804 local->suspended = true; in ieee80211_reconfig()
1815 if (suspended && local->in_reconfig && !reconfig_due_to_wowlan) in ieee80211_reconfig()
1816 cancel_work_sync(&local->restart_work); in ieee80211_reconfig()
1818 local->started = false; in ieee80211_reconfig()
1840 drv_set_frag_threshold(local, hw->wiphy->frag_threshold); in ieee80211_reconfig()
1843 drv_set_rts_threshold(local, hw->wiphy->rts_threshold); in ieee80211_reconfig()
1846 drv_set_coverage_class(local, hw->wiphy->coverage_class); in ieee80211_reconfig()
1853 sdata = wiphy_dereference(local->hw.wiphy, local->monitor_sdata); in ieee80211_reconfig()
1854 if (sdata && ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF)) { in ieee80211_reconfig()
1856 WARN_ON(local->resuming); in ieee80211_reconfig()
1859 RCU_INIT_POINTER(local->monitor_sdata, NULL); in ieee80211_reconfig()
1865 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_reconfig()
1866 if (sdata->vif.type == NL80211_IFTYPE_MONITOR && in ieee80211_reconfig()
1867 !ieee80211_hw_check(&local->hw, NO_VIRTUAL_MONITOR)) in ieee80211_reconfig()
1869 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN && in ieee80211_reconfig()
1881 list_for_each_entry_continue_reverse(sdata, &local->interfaces, in ieee80211_reconfig()
1883 if (sdata->vif.type == NL80211_IFTYPE_MONITOR && in ieee80211_reconfig()
1884 !ieee80211_hw_check(&local->hw, NO_VIRTUAL_MONITOR)) in ieee80211_reconfig()
1886 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN && in ieee80211_reconfig()
1895 list_for_each_entry(ctx, &local->chanctx_list, list) in ieee80211_reconfig()
1896 if (ctx->replace_state != IEEE80211_CHANCTX_REPLACES_OTHER) in ieee80211_reconfig()
1899 sdata = wiphy_dereference(local->hw.wiphy, local->monitor_sdata); in ieee80211_reconfig()
1901 ieee80211_assign_chanctx(local, sdata, &sdata->deflink); in ieee80211_reconfig()
1913 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_reconfig()
1914 /* common change flags for all interface types - link only */ in ieee80211_reconfig()
1933 if (ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_reconfig()
1935 [0] = &sdata->vif.bss_conf, in ieee80211_reconfig()
1938 if (sdata->vif.type == NL80211_IFTYPE_STATION) { in ieee80211_reconfig()
1940 active_links = sdata->vif.active_links; in ieee80211_reconfig()
1941 link_id = ffs(active_links) - 1; in ieee80211_reconfig()
1942 sdata->vif.active_links = BIT(link_id); in ieee80211_reconfig()
1946 sdata->vif.active_links, in ieee80211_reconfig()
1950 sdata->restart_active_links = active_links; in ieee80211_reconfig()
1953 link_id < ARRAY_SIZE(sdata->vif.link_conf); in ieee80211_reconfig()
1955 if (!ieee80211_vif_link_active(&sdata->vif, link_id)) in ieee80211_reconfig()
1958 link = sdata_dereference(sdata->link[link_id], sdata); in ieee80211_reconfig()
1965 switch (sdata->vif.type) { in ieee80211_reconfig()
1970 if (sdata->vif.cfg.ibss_joined) in ieee80211_reconfig()
1978 drv_conf_tx(local, &sdata->deflink, i, in ieee80211_reconfig()
1979 &sdata->deflink.tx_conf[i]); in ieee80211_reconfig()
1983 if (sdata->vif.bss_conf.mu_mimo_owner) in ieee80211_reconfig()
1986 if (!ieee80211_vif_is_mld(&sdata->vif)) in ieee80211_reconfig()
1989 switch (sdata->vif.type) { in ieee80211_reconfig()
1991 if (!ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_reconfig()
1996 /* Re-send beacon info report to the driver */ in ieee80211_reconfig()
1997 if (sdata->deflink.u.mgd.have_beacon) in ieee80211_reconfig()
2000 if (sdata->vif.bss_conf.max_idle_period || in ieee80211_reconfig()
2001 sdata->vif.bss_conf.protected_keep_alive) in ieee80211_reconfig()
2026 if (ieee80211_vif_is_mld(&sdata->vif)) in ieee80211_reconfig()
2032 if (sdata->vif.bss_conf.ftm_responder == 1 && in ieee80211_reconfig()
2033 wiphy_ext_feature_isset(sdata->local->hw.wiphy, in ieee80211_reconfig()
2037 if (sdata->vif.type == NL80211_IFTYPE_AP) { in ieee80211_reconfig()
2040 if (ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_reconfig()
2047 if (rcu_access_pointer(sdata->deflink.u.ap.beacon)) in ieee80211_reconfig()
2049 sdata->deflink.conf); in ieee80211_reconfig()
2053 if (sdata->vif.bss_conf.enable_beacon) { in ieee80211_reconfig()
2089 if (!(local->hw.conf.flags & IEEE80211_CONF_PS)) { in ieee80211_reconfig()
2090 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_reconfig()
2091 if (sdata->vif.type != NL80211_IFTYPE_STATION) in ieee80211_reconfig()
2093 if (!sdata->u.mgd.associated) in ieee80211_reconfig()
2101 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_reconfig()
2105 switch (sdata->vif.type) { in ieee80211_reconfig()
2116 list_for_each_entry(sdata, &local->interfaces, list) in ieee80211_reconfig()
2119 /* re-enable multi-link for client interfaces */ in ieee80211_reconfig()
2120 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_reconfig()
2121 if (sdata->restart_active_links) in ieee80211_reconfig()
2122 ieee80211_set_active_links(&sdata->vif, in ieee80211_reconfig()
2123 sdata->restart_active_links); in ieee80211_reconfig()
2126 * before reconfig, it will do nothing, so re-schedule. in ieee80211_reconfig()
2128 if (sdata->desired_active_links) in ieee80211_reconfig()
2129 wiphy_work_queue(sdata->local->hw.wiphy, in ieee80211_reconfig()
2130 &sdata->activate_links_work); in ieee80211_reconfig()
2134 sched_scan_sdata = rcu_dereference_protected(local->sched_scan_sdata, in ieee80211_reconfig()
2135 lockdep_is_held(&local->hw.wiphy->mtx)); in ieee80211_reconfig()
2136 sched_scan_req = rcu_dereference_protected(local->sched_scan_req, in ieee80211_reconfig()
2137 lockdep_is_held(&local->hw.wiphy->mtx)); in ieee80211_reconfig()
2146 if (sched_scan_req->n_scan_plans > 1 || in ieee80211_reconfig()
2149 RCU_INIT_POINTER(local->sched_scan_sdata, NULL); in ieee80211_reconfig()
2150 RCU_INIT_POINTER(local->sched_scan_req, NULL); in ieee80211_reconfig()
2155 cfg80211_sched_scan_stopped_locked(local->hw.wiphy, 0); in ieee80211_reconfig()
2159 if (local->virt_monitors > 0 && in ieee80211_reconfig()
2160 local->virt_monitors == local->open_count) in ieee80211_reconfig()
2174 list_for_each_entry(sta, &local->sta_list, list) { in ieee80211_reconfig()
2175 if (!local->resuming) in ieee80211_reconfig()
2186 if (local->open_count && (!suspended || reconfig_due_to_wowlan)) in ieee80211_reconfig()
2189 if (local->in_reconfig) { in ieee80211_reconfig()
2190 in_reconfig = local->in_reconfig; in ieee80211_reconfig()
2191 local->in_reconfig = false; in ieee80211_reconfig()
2197 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_reconfig()
2199 wiphy_work_queue(local->hw.wiphy, &sdata->work); in ieee80211_reconfig()
2208 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_reconfig()
2211 if (sdata->vif.type == NL80211_IFTYPE_STATION) in ieee80211_reconfig()
2221 local->suspended = false; in ieee80211_reconfig()
2223 local->resuming = false; in ieee80211_reconfig()
2227 if (local->open_count && !reconfig_due_to_wowlan) in ieee80211_reconfig()
2230 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_reconfig()
2233 if (sdata->vif.type == NL80211_IFTYPE_STATION) in ieee80211_reconfig()
2237 mod_timer(&local->sta_cleanup, jiffies + 1); in ieee80211_reconfig()
2255 local = sdata->local; in ieee80211_reconfig_disconnect()
2257 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_reconfig_disconnect()
2260 !local->resuming)) in ieee80211_reconfig_disconnect()
2264 !local->in_reconfig)) in ieee80211_reconfig_disconnect()
2267 if (WARN_ON(vif->type != NL80211_IFTYPE_STATION)) in ieee80211_reconfig_disconnect()
2270 sdata->flags |= flag; in ieee80211_reconfig_disconnect()
2272 list_for_each_entry(key, &sdata->key_list, list) in ieee80211_reconfig_disconnect()
2273 key->flags |= KEY_FLAG_TAINTED; in ieee80211_reconfig_disconnect()
2291 struct ieee80211_local *local = sdata->local; in ieee80211_recalc_smps()
2295 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_recalc_smps()
2297 chanctx_conf = rcu_dereference_protected(link->conf->chanctx_conf, in ieee80211_recalc_smps()
2298 lockdep_is_held(&local->hw.wiphy->mtx)); in ieee80211_recalc_smps()
2316 struct ieee80211_local *local = sdata->local; in ieee80211_recalc_min_chandef()
2321 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_recalc_min_chandef()
2323 for (i = 0; i < ARRAY_SIZE(sdata->vif.link_conf); i++) { in ieee80211_recalc_min_chandef()
2330 bss_conf = rcu_dereference(sdata->vif.link_conf[i]); in ieee80211_recalc_min_chandef()
2336 chanctx_conf = rcu_dereference_protected(bss_conf->chanctx_conf, in ieee80211_recalc_min_chandef()
2337 lockdep_is_held(&local->hw.wiphy->mtx)); in ieee80211_recalc_min_chandef()
2342 * the mutex. Just the way we reached it could - in in ieee80211_recalc_min_chandef()
2343 * theory - go away, but we don't really care and in ieee80211_recalc_min_chandef()
2382 *pos++ = ht_cap->ampdu_factor | in ieee80211_ie_build_ht_cap()
2383 (ht_cap->ampdu_density << in ieee80211_ie_build_ht_cap()
2387 memcpy(pos, &ht_cap->mcs, sizeof(ht_cap->mcs)); in ieee80211_ie_build_ht_cap()
2388 pos += sizeof(ht_cap->mcs); in ieee80211_ie_build_ht_cap()
2417 memcpy(pos, &vht_cap->vht_mcs, sizeof(vht_cap->vht_mcs)); in ieee80211_ie_build_vht_cap()
2418 pos += sizeof(vht_cap->vht_mcs); in ieee80211_ie_build_vht_cap()
2434 he_cap = ieee80211_get_he_iftype_cap_vif(sband, &sdata->vif); in ieee80211_ie_len_he_cap()
2438 n = ieee80211_he_mcs_nss_size(&he_cap->he_cap_elem); in ieee80211_ie_len_he_cap()
2440 sizeof(he_cap->he_cap_elem) + n + in ieee80211_ie_len_he_cap()
2441 ieee80211_he_ppe_size(he_cap->ppe_thres[0], in ieee80211_ie_len_he_cap()
2442 he_cap->he_cap_elem.phy_cap_info); in ieee80211_ie_len_he_cap()
2452 *elem = he_cap->he_cap_elem; in ieee80211_get_adjusted_he_cap()
2454 switch (conn->bw_limit) { in ieee80211_get_adjusted_he_cap()
2469 max_ru = elem->phy_cap_info[8] & IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_MASK; in ieee80211_get_adjusted_he_cap()
2471 elem->phy_cap_info[8] &= ~IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_MASK; in ieee80211_get_adjusted_he_cap()
2472 elem->phy_cap_info[8] |= max_ru; in ieee80211_get_adjusted_he_cap()
2474 if (conn->bw_limit < IEEE80211_CONN_BW_LIMIT_40) { in ieee80211_get_adjusted_he_cap()
2475 elem->phy_cap_info[0] &= in ieee80211_get_adjusted_he_cap()
2478 elem->phy_cap_info[9] &= in ieee80211_get_adjusted_he_cap()
2482 if (conn->bw_limit < IEEE80211_CONN_BW_LIMIT_160) { in ieee80211_get_adjusted_he_cap()
2483 elem->phy_cap_info[0] &= in ieee80211_get_adjusted_he_cap()
2486 elem->phy_cap_info[5] &= in ieee80211_get_adjusted_he_cap()
2488 elem->phy_cap_info[7] &= in ieee80211_get_adjusted_he_cap()
2508 he_cap = ieee80211_get_he_iftype_cap_vif(sband, &sdata->vif); in ieee80211_put_he_cap()
2517 sizeof(he_cap->he_cap_elem) + n + in ieee80211_put_he_cap()
2518 ieee80211_he_ppe_size(he_cap->ppe_thres[0], in ieee80211_put_he_cap()
2519 he_cap->he_cap_elem.phy_cap_info); in ieee80211_put_he_cap()
2522 return -ENOBUFS; in ieee80211_put_he_cap()
2531 skb_put_data(skb, &he_cap->he_mcs_nss_supp, n); in ieee80211_put_he_cap()
2534 if ((he_cap->he_cap_elem.phy_cap_info[6] & in ieee80211_put_he_cap()
2542 n = hweight8(he_cap->ppe_thres[0] & in ieee80211_put_he_cap()
2544 n *= (1 + ((he_cap->ppe_thres[0] & IEEE80211_PPE_THRES_NSS_MASK) >> in ieee80211_put_he_cap()
2555 skb_put_data(skb, &he_cap->ppe_thres, n); in ieee80211_put_he_cap()
2558 *len = skb_tail_pointer(skb) - len - 1; in ieee80211_put_he_cap()
2568 enum nl80211_iftype iftype = ieee80211_vif_type_p2p(&sdata->vif); in ieee80211_put_he_6ghz_cap()
2571 if (!cfg80211_any_usable_channels(sdata->local->hw.wiphy, in ieee80211_put_he_6ghz_cap()
2576 sband = sdata->local->hw.wiphy->bands[NL80211_BAND_6GHZ]; in ieee80211_put_he_6ghz_cap()
2583 if (!iftd->he_6ghz_capa.capa) in ieee80211_put_he_6ghz_cap()
2586 cap = iftd->he_6ghz_capa.capa; in ieee80211_put_he_6ghz_cap()
2609 return -ENOBUFS; in ieee80211_put_he_6ghz_cap()
2627 ht_oper->primary_chan = ieee80211_frequency_to_channel( in ieee80211_ie_build_ht_oper()
2628 chandef->chan->center_freq); in ieee80211_ie_build_ht_oper()
2629 switch (chandef->width) { in ieee80211_ie_build_ht_oper()
2634 if (chandef->center_freq1 > chandef->chan->center_freq) in ieee80211_ie_build_ht_oper()
2635 ht_oper->ht_param = IEEE80211_HT_PARAM_CHA_SEC_ABOVE; in ieee80211_ie_build_ht_oper()
2637 ht_oper->ht_param = IEEE80211_HT_PARAM_CHA_SEC_BELOW; in ieee80211_ie_build_ht_oper()
2644 ht_oper->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE; in ieee80211_ie_build_ht_oper()
2647 if (ht_cap->cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40 && in ieee80211_ie_build_ht_oper()
2648 chandef->width != NL80211_CHAN_WIDTH_20_NOHT && in ieee80211_ie_build_ht_oper()
2649 chandef->width != NL80211_CHAN_WIDTH_20) in ieee80211_ie_build_ht_oper()
2650 ht_oper->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY; in ieee80211_ie_build_ht_oper()
2653 ht_oper->ht_param |= IEEE80211_HT_PARAM_RIFS_MODE; in ieee80211_ie_build_ht_oper()
2655 ht_oper->operation_mode = cpu_to_le16(prot_mode); in ieee80211_ie_build_ht_oper()
2656 ht_oper->stbc_param = 0x0000; in ieee80211_ie_build_ht_oper()
2660 memset(&ht_oper->basic_set, 0, 16); in ieee80211_ie_build_ht_oper()
2661 memcpy(&ht_oper->basic_set, &ht_cap->mcs, 10); in ieee80211_ie_build_ht_oper()
2672 switch (chandef->width) { in ieee80211_ie_build_wide_bw_cs()
2691 *pos++ = ieee80211_frequency_to_channel(chandef->center_freq1); in ieee80211_ie_build_wide_bw_cs()
2693 if (chandef->center_freq2) in ieee80211_ie_build_wide_bw_cs()
2694 *pos++ = ieee80211_frequency_to_channel(chandef->center_freq2); in ieee80211_ie_build_wide_bw_cs()
2707 vht_oper->center_freq_seg0_idx = ieee80211_frequency_to_channel( in ieee80211_ie_build_vht_oper()
2708 chandef->center_freq1); in ieee80211_ie_build_vht_oper()
2709 if (chandef->center_freq2) in ieee80211_ie_build_vht_oper()
2710 vht_oper->center_freq_seg1_idx = in ieee80211_ie_build_vht_oper()
2711 ieee80211_frequency_to_channel(chandef->center_freq2); in ieee80211_ie_build_vht_oper()
2713 vht_oper->center_freq_seg1_idx = 0x00; in ieee80211_ie_build_vht_oper()
2715 switch (chandef->width) { in ieee80211_ie_build_vht_oper()
2721 vht_oper->chan_width = IEEE80211_VHT_CHANWIDTH_80MHZ; in ieee80211_ie_build_vht_oper()
2722 vht_oper->center_freq_seg1_idx = vht_oper->center_freq_seg0_idx; in ieee80211_ie_build_vht_oper()
2723 if (chandef->chan->center_freq < chandef->center_freq1) in ieee80211_ie_build_vht_oper()
2724 vht_oper->center_freq_seg0_idx -= 8; in ieee80211_ie_build_vht_oper()
2726 vht_oper->center_freq_seg0_idx += 8; in ieee80211_ie_build_vht_oper()
2733 vht_oper->chan_width = IEEE80211_VHT_CHANWIDTH_80MHZ; in ieee80211_ie_build_vht_oper()
2736 vht_oper->chan_width = IEEE80211_VHT_CHANWIDTH_80MHZ; in ieee80211_ie_build_vht_oper()
2743 vht_oper->chan_width = IEEE80211_VHT_CHANWIDTH_USE_HT; in ieee80211_ie_build_vht_oper()
2748 vht_oper->basic_mcs_set = cpu_to_le16(0xffff); in ieee80211_ie_build_vht_oper()
2761 if (chandef->chan->band == NL80211_BAND_6GHZ) in ieee80211_ie_build_he_oper()
2775 if (chandef->chan->band == NL80211_BAND_6GHZ) in ieee80211_ie_build_he_oper()
2780 he_oper->he_oper_params = cpu_to_le32(he_oper_params); in ieee80211_ie_build_he_oper()
2783 he_oper->he_mcs_nss_set = cpu_to_le16(0xffff); in ieee80211_ie_build_he_oper()
2786 if (chandef->chan->band != NL80211_BAND_6GHZ) in ieee80211_ie_build_he_oper()
2789 cfg80211_chandef_create(&he_chandef, chandef->chan, NL80211_CHAN_NO_HT); in ieee80211_ie_build_he_oper()
2790 he_chandef.center_freq1 = chandef->center_freq1; in ieee80211_ie_build_he_oper()
2791 he_chandef.center_freq2 = chandef->center_freq2; in ieee80211_ie_build_he_oper()
2792 he_chandef.width = chandef->width; in ieee80211_ie_build_he_oper()
2796 he_6ghz_op->minrate = 6; /* 6 Mbps */ in ieee80211_ie_build_he_oper()
2797 he_6ghz_op->primary = in ieee80211_ie_build_he_oper()
2798 ieee80211_frequency_to_channel(he_chandef.chan->center_freq); in ieee80211_ie_build_he_oper()
2799 he_6ghz_op->ccfs0 = in ieee80211_ie_build_he_oper()
2802 he_6ghz_op->ccfs1 = in ieee80211_ie_build_he_oper()
2805 he_6ghz_op->ccfs1 = 0; in ieee80211_ie_build_he_oper()
2813 he_6ghz_op->ccfs0 = in ieee80211_ie_build_he_oper()
2820 he_6ghz_op->control = in ieee80211_ie_build_he_oper()
2822 he_6ghz_op->ccfs1 = he_6ghz_op->ccfs0; in ieee80211_ie_build_he_oper()
2823 if (he_chandef.chan->center_freq < he_chandef.center_freq1) in ieee80211_ie_build_he_oper()
2824 he_6ghz_op->ccfs0 -= 8; in ieee80211_ie_build_he_oper()
2826 he_6ghz_op->ccfs0 += 8; in ieee80211_ie_build_he_oper()
2829 he_6ghz_op->control = in ieee80211_ie_build_he_oper()
2833 he_6ghz_op->control = in ieee80211_ie_build_he_oper()
2837 he_6ghz_op->control = in ieee80211_ie_build_he_oper()
2841 he_6ghz_op->control = in ieee80211_ie_build_he_oper()
2857 &eht_cap->eht_mcs_nss_supp.only_20mhz; in ieee80211_ie_build_eht_oper()
2871 memcpy(&eht_oper->basic_mcs_nss, eht_mcs_nss, sizeof(*eht_mcs_nss)); in ieee80211_ie_build_eht_oper()
2872 eht_oper->params |= IEEE80211_EHT_OPER_INFO_PRESENT; in ieee80211_ie_build_eht_oper()
2876 (struct ieee80211_eht_operation_info *)eht_oper->optional; in ieee80211_ie_build_eht_oper()
2878 eht_oper_info->ccfs0 = in ieee80211_ie_build_eht_oper()
2879 ieee80211_frequency_to_channel(chandef->center_freq1); in ieee80211_ie_build_eht_oper()
2880 if (chandef->center_freq2) in ieee80211_ie_build_eht_oper()
2881 eht_oper_info->ccfs1 = in ieee80211_ie_build_eht_oper()
2882 ieee80211_frequency_to_channel(chandef->center_freq2); in ieee80211_ie_build_eht_oper()
2884 eht_oper_info->ccfs1 = 0; in ieee80211_ie_build_eht_oper()
2886 switch (chandef->width) { in ieee80211_ie_build_eht_oper()
2889 eht_oper_info->ccfs1 = eht_oper_info->ccfs0; in ieee80211_ie_build_eht_oper()
2890 if (chandef->chan->center_freq < chandef->center_freq1) in ieee80211_ie_build_eht_oper()
2891 eht_oper_info->ccfs0 -= 16; in ieee80211_ie_build_eht_oper()
2893 eht_oper_info->ccfs0 += 16; in ieee80211_ie_build_eht_oper()
2896 eht_oper_info->ccfs1 = eht_oper_info->ccfs0; in ieee80211_ie_build_eht_oper()
2897 if (chandef->chan->center_freq < chandef->center_freq1) in ieee80211_ie_build_eht_oper()
2898 eht_oper_info->ccfs0 -= 8; in ieee80211_ie_build_eht_oper()
2900 eht_oper_info->ccfs0 += 8; in ieee80211_ie_build_eht_oper()
2915 eht_oper_info->control = chan_width; in ieee80211_ie_build_eht_oper()
2918 /* TODO: eht_oper_info->optional */ in ieee80211_ie_build_eht_oper()
2931 switch (ht_oper->ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET) { in ieee80211_chandef_ht_oper()
2945 cfg80211_chandef_create(chandef, chandef->chan, channel_type); in ieee80211_chandef_ht_oper()
2969 vht_cap = hw->wiphy->bands[chandef->chan->band]->vht_cap.cap; in ieee80211_chandef_vht_oper()
2978 ccfs0 = oper->center_freq_seg0_idx; in ieee80211_chandef_vht_oper()
2979 ccfs1 = oper->center_freq_seg1_idx; in ieee80211_chandef_vht_oper()
2980 ccfs2 = (le16_to_cpu(htop->operation_mode) & in ieee80211_chandef_vht_oper()
2991 * Cf. IEEE 802.11 Table 9-250 in ieee80211_chandef_vht_oper()
3027 cf0 = ieee80211_channel_to_frequency(ccf0, chandef->chan->band); in ieee80211_chandef_vht_oper()
3028 cf1 = ieee80211_channel_to_frequency(ccf1, chandef->chan->band); in ieee80211_chandef_vht_oper()
3030 switch (oper->chan_width) { in ieee80211_chandef_vht_oper()
3041 diff = abs(ccf1 - ccf0); in ieee80211_chandef_vht_oper()
3076 chandef->center_freq1 = in ieee80211_chandef_eht_oper()
3077 ieee80211_channel_to_frequency(info->ccfs0, in ieee80211_chandef_eht_oper()
3078 chandef->chan->band); in ieee80211_chandef_eht_oper()
3080 switch (u8_get_bits(info->control, in ieee80211_chandef_eht_oper()
3083 chandef->width = NL80211_CHAN_WIDTH_20; in ieee80211_chandef_eht_oper()
3086 chandef->width = NL80211_CHAN_WIDTH_40; in ieee80211_chandef_eht_oper()
3089 chandef->width = NL80211_CHAN_WIDTH_80; in ieee80211_chandef_eht_oper()
3092 chandef->width = NL80211_CHAN_WIDTH_160; in ieee80211_chandef_eht_oper()
3093 chandef->center_freq1 = in ieee80211_chandef_eht_oper()
3094 ieee80211_channel_to_frequency(info->ccfs1, in ieee80211_chandef_eht_oper()
3095 chandef->chan->band); in ieee80211_chandef_eht_oper()
3098 chandef->width = NL80211_CHAN_WIDTH_320; in ieee80211_chandef_eht_oper()
3099 chandef->center_freq1 = in ieee80211_chandef_eht_oper()
3100 ieee80211_channel_to_frequency(info->ccfs1, in ieee80211_chandef_eht_oper()
3101 chandef->chan->band); in ieee80211_chandef_eht_oper()
3113 u32 freq; in ieee80211_chandef_he_6ghz_oper() local
3115 if (chandef->chan->band != NL80211_BAND_6GHZ) in ieee80211_chandef_he_6ghz_oper()
3130 freq = ieee80211_channel_to_frequency(he_6ghz_oper->primary, in ieee80211_chandef_he_6ghz_oper()
3132 he_chandef.chan = ieee80211_get_channel(local->hw.wiphy, freq); in ieee80211_chandef_he_6ghz_oper()
3138 !(eht_oper->params & IEEE80211_EHT_OPER_INFO_PRESENT)) { in ieee80211_chandef_he_6ghz_oper()
3139 switch (u8_get_bits(he_6ghz_oper->control, in ieee80211_chandef_he_6ghz_oper()
3152 if (!he_6ghz_oper->ccfs1) in ieee80211_chandef_he_6ghz_oper()
3154 if (abs(he_6ghz_oper->ccfs1 - he_6ghz_oper->ccfs0) == 8) in ieee80211_chandef_he_6ghz_oper()
3163 ieee80211_channel_to_frequency(he_6ghz_oper->ccfs1, in ieee80211_chandef_he_6ghz_oper()
3167 ieee80211_channel_to_frequency(he_6ghz_oper->ccfs0, in ieee80211_chandef_he_6ghz_oper()
3170 ieee80211_channel_to_frequency(he_6ghz_oper->ccfs1, in ieee80211_chandef_he_6ghz_oper()
3174 ieee80211_chandef_eht_oper((const void *)eht_oper->optional, in ieee80211_chandef_he_6ghz_oper()
3196 switch (FIELD_GET(S1G_OPER_CH_WIDTH_OPER, oper->ch_width)) { in ieee80211_chandef_s1g_oper()
3198 chandef->width = NL80211_CHAN_WIDTH_1; in ieee80211_chandef_s1g_oper()
3201 chandef->width = NL80211_CHAN_WIDTH_2; in ieee80211_chandef_s1g_oper()
3204 chandef->width = NL80211_CHAN_WIDTH_4; in ieee80211_chandef_s1g_oper()
3207 chandef->width = NL80211_CHAN_WIDTH_8; in ieee80211_chandef_s1g_oper()
3210 chandef->width = NL80211_CHAN_WIDTH_16; in ieee80211_chandef_s1g_oper()
3216 oper_freq = ieee80211_channel_to_freq_khz(oper->oper_ch, in ieee80211_chandef_s1g_oper()
3218 chandef->center_freq1 = KHZ_TO_MHZ(oper_freq); in ieee80211_chandef_s1g_oper()
3219 chandef->freq1_offset = oper_freq % 1000; in ieee80211_chandef_s1g_oper()
3232 for (i = 0; i < sband->n_bitrates; i++) { in ieee80211_put_srates_elem()
3233 if ((rate_flags & sband->bitrates[i].flags) != rate_flags) in ieee80211_put_srates_elem()
3247 rates -= skip; in ieee80211_put_srates_elem()
3251 return -ENOBUFS; in ieee80211_put_srates_elem()
3256 for (i = 0; i < sband->n_bitrates && rates; i++) { in ieee80211_put_srates_elem()
3260 if ((rate_flags & sband->bitrates[i].flags) != rate_flags) in ieee80211_put_srates_elem()
3266 skip--; in ieee80211_put_srates_elem()
3272 rate = DIV_ROUND_UP(sband->bitrates[i].bitrate, 5); in ieee80211_put_srates_elem()
3274 rates--; in ieee80211_put_srates_elem()
3287 if (WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION)) in ieee80211_ave_rssi()
3290 return -ewma_beacon_signal_read(&sdata->deflink.u.mgd.ave_beacon_signal); in ieee80211_ave_rssi()
3301 if (mcs->rx_mask[3]) in ieee80211_mcs_to_chains()
3303 if (mcs->rx_mask[2]) in ieee80211_mcs_to_chains()
3305 if (mcs->rx_mask[1]) in ieee80211_mcs_to_chains()
3311 * ieee80211_calculate_rx_timestamp - calculate timestamp in frame
3328 u64 ts = status->mactime; in ieee80211_calculate_rx_timestamp()
3337 mactime_plcp_start = (status->flag & RX_FLAG_MACTIME) == in ieee80211_calculate_rx_timestamp()
3342 ri.bw = status->bw; in ieee80211_calculate_rx_timestamp()
3345 switch (status->encoding) { in ieee80211_calculate_rx_timestamp()
3348 ri.mcs = status->rate_idx; in ieee80211_calculate_rx_timestamp()
3349 ri.nss = status->nss; in ieee80211_calculate_rx_timestamp()
3350 ri.eht_ru_alloc = status->eht.ru; in ieee80211_calculate_rx_timestamp()
3351 if (status->enc_flags & RX_ENC_FLAG_SHORT_GI) in ieee80211_calculate_rx_timestamp()
3361 ri.mcs = status->rate_idx; in ieee80211_calculate_rx_timestamp()
3362 ri.nss = status->nss; in ieee80211_calculate_rx_timestamp()
3363 ri.he_ru_alloc = status->he_ru; in ieee80211_calculate_rx_timestamp()
3364 if (status->enc_flags & RX_ENC_FLAG_SHORT_GI) in ieee80211_calculate_rx_timestamp()
3377 * For HE MU PPDU, add the HE-SIG-B. in ieee80211_calculate_rx_timestamp()
3378 * For HE ER PPDU, add 8us for the HE-SIG-A. in ieee80211_calculate_rx_timestamp()
3379 * For HE TB PPDU, add 4us for the HE-STF. in ieee80211_calculate_rx_timestamp()
3380 * Add the HE-LTF durations - variable. in ieee80211_calculate_rx_timestamp()
3386 ri.mcs = status->rate_idx; in ieee80211_calculate_rx_timestamp()
3388 if (status->enc_flags & RX_ENC_FLAG_SHORT_GI) in ieee80211_calculate_rx_timestamp()
3397 if (status->enc_flags & RX_ENC_FLAG_HT_GF) in ieee80211_calculate_rx_timestamp()
3403 * Add Data HT-LTFs per streams in ieee80211_calculate_rx_timestamp()
3404 * TODO: add Extension HT-LTFs, 4us per LTF in ieee80211_calculate_rx_timestamp()
3414 ri.mcs = status->rate_idx; in ieee80211_calculate_rx_timestamp()
3415 ri.nss = status->nss; in ieee80211_calculate_rx_timestamp()
3416 if (status->enc_flags & RX_ENC_FLAG_SHORT_GI) in ieee80211_calculate_rx_timestamp()
3428 * Add VHT-LTFs per streams in ieee80211_calculate_rx_timestamp()
3442 sband = local->hw.wiphy->bands[status->band]; in ieee80211_calculate_rx_timestamp()
3443 ri.legacy = sband->bitrates[status->rate_idx].bitrate; in ieee80211_calculate_rx_timestamp()
3446 if (status->band == NL80211_BAND_5GHZ) { in ieee80211_calculate_rx_timestamp()
3449 } else if (status->enc_flags & RX_ENC_FLAG_SHORTPRE) { in ieee80211_calculate_rx_timestamp()
3462 (unsigned long long)status->flag, status->rate_idx, in ieee80211_calculate_rx_timestamp()
3463 status->nss)) in ieee80211_calculate_rx_timestamp()
3467 if ((status->flag & RX_FLAG_MACTIME) == RX_FLAG_MACTIME_END) in ieee80211_calculate_rx_timestamp()
3468 ts -= mpdu_len * 8 * 10 / rate; in ieee80211_calculate_rx_timestamp()
3487 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_dfs_cac_cancel()
3489 list_for_each_entry(sdata, &local->interfaces, list) { in ieee80211_dfs_cac_cancel()
3492 link = sdata_dereference(sdata->link[link_id], in ieee80211_dfs_cac_cancel()
3497 chanctx_conf = sdata_dereference(link->conf->chanctx_conf, in ieee80211_dfs_cac_cancel()
3499 if (ctx && &ctx->conf != chanctx_conf) in ieee80211_dfs_cac_cancel()
3502 wiphy_delayed_work_cancel(local->hw.wiphy, in ieee80211_dfs_cac_cancel()
3503 &link->dfs_cac_timer_work); in ieee80211_dfs_cac_cancel()
3505 if (!sdata->wdev.links[link_id].cac_started) in ieee80211_dfs_cac_cancel()
3508 chandef = link->conf->chanreq.oper; in ieee80211_dfs_cac_cancel()
3510 cfg80211_cac_event(sdata->dev, &chandef, in ieee80211_dfs_cac_cancel()
3525 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_dfs_radar_detected_work()
3527 list_for_each_entry(ctx, &local->chanctx_list, list) { in ieee80211_dfs_radar_detected_work()
3528 if (ctx->replace_state == IEEE80211_CHANCTX_REPLACES_OTHER) in ieee80211_dfs_radar_detected_work()
3531 if (!ctx->radar_detected) in ieee80211_dfs_radar_detected_work()
3534 ctx->radar_detected = false; in ieee80211_dfs_radar_detected_work()
3536 chandef = ctx->conf.def; in ieee80211_dfs_radar_detected_work()
3539 cfg80211_radar_event(local->hw.wiphy, &chandef, GFP_KERNEL); in ieee80211_dfs_radar_detected_work()
3552 if (ctx->replace_state == IEEE80211_CHANCTX_REPLACES_OTHER) in ieee80211_radar_mark_chan_ctx_iterator()
3558 ctx->radar_detected = true; in ieee80211_radar_mark_chan_ctx_iterator()
3571 wiphy_work_queue(hw->wiphy, &local->radar_detected_work); in ieee80211_radar_detected()
3586 /* no-HT indicates nothing to do */ in ieee80211_chandef_downgrade()
3589 switch (c->width) { in ieee80211_chandef_downgrade()
3595 c->width = NL80211_CHAN_WIDTH_20_NOHT; in ieee80211_chandef_downgrade()
3596 conn->mode = IEEE80211_CONN_MODE_LEGACY; in ieee80211_chandef_downgrade()
3597 conn->bw_limit = IEEE80211_CONN_BW_LIMIT_20; in ieee80211_chandef_downgrade()
3598 c->punctured = 0; in ieee80211_chandef_downgrade()
3601 c->width = NL80211_CHAN_WIDTH_20; in ieee80211_chandef_downgrade()
3602 c->center_freq1 = c->chan->center_freq; in ieee80211_chandef_downgrade()
3603 if (conn->mode == IEEE80211_CONN_MODE_VHT) in ieee80211_chandef_downgrade()
3604 conn->mode = IEEE80211_CONN_MODE_HT; in ieee80211_chandef_downgrade()
3605 conn->bw_limit = IEEE80211_CONN_BW_LIMIT_20; in ieee80211_chandef_downgrade()
3606 c->punctured = 0; in ieee80211_chandef_downgrade()
3610 if (conn->mode == IEEE80211_CONN_MODE_VHT) in ieee80211_chandef_downgrade()
3611 conn->mode = IEEE80211_CONN_MODE_HT; in ieee80211_chandef_downgrade()
3612 conn->bw_limit = IEEE80211_CONN_BW_LIMIT_40; in ieee80211_chandef_downgrade()
3615 c->center_freq2 = 0; in ieee80211_chandef_downgrade()
3616 c->width = NL80211_CHAN_WIDTH_80; in ieee80211_chandef_downgrade()
3617 conn->bw_limit = IEEE80211_CONN_BW_LIMIT_80; in ieee80211_chandef_downgrade()
3621 conn->bw_limit = IEEE80211_CONN_BW_LIMIT_80; in ieee80211_chandef_downgrade()
3625 conn->bw_limit = IEEE80211_CONN_BW_LIMIT_160; in ieee80211_chandef_downgrade()
3633 /* keep c->width */ in ieee80211_chandef_downgrade()
3634 conn->mode = IEEE80211_CONN_MODE_S1G; in ieee80211_chandef_downgrade()
3635 conn->bw_limit = IEEE80211_CONN_BW_LIMIT_20; in ieee80211_chandef_downgrade()
3640 /* keep c->width */ in ieee80211_chandef_downgrade()
3641 conn->mode = IEEE80211_CONN_MODE_LEGACY; in ieee80211_chandef_downgrade()
3642 conn->bw_limit = IEEE80211_CONN_BW_LIMIT_20; in ieee80211_chandef_downgrade()
3647 c->center_freq1 = cfg80211_chandef_primary(c, new_primary_width, in ieee80211_chandef_downgrade()
3648 &c->punctured); in ieee80211_chandef_downgrade()
3649 c->width = new_primary_width; in ieee80211_chandef_downgrade()
3657 if (!cfg80211_chandef_valid(c) && c->punctured) in ieee80211_chandef_downgrade()
3668 struct ieee80211_local *local = sdata->local; in ieee80211_send_action_csa()
3669 int freq; in ieee80211_send_action_csa() local
3674 if (sdata->vif.type != NL80211_IFTYPE_ADHOC && in ieee80211_send_action_csa()
3675 sdata->vif.type != NL80211_IFTYPE_MESH_POINT) in ieee80211_send_action_csa()
3676 return -EOPNOTSUPP; in ieee80211_send_action_csa()
3678 skb = dev_alloc_skb(local->tx_headroom + hdr_len + in ieee80211_send_action_csa()
3684 return -ENOMEM; in ieee80211_send_action_csa()
3686 skb_reserve(skb, local->tx_headroom); in ieee80211_send_action_csa()
3688 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | in ieee80211_send_action_csa()
3691 eth_broadcast_addr(mgmt->da); in ieee80211_send_action_csa()
3692 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); in ieee80211_send_action_csa()
3693 if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_send_action_csa()
3694 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN); in ieee80211_send_action_csa()
3696 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; in ieee80211_send_action_csa()
3697 memcpy(mgmt->bssid, ifibss->bssid, ETH_ALEN); in ieee80211_send_action_csa()
3699 mgmt->u.action.category = WLAN_CATEGORY_SPECTRUM_MGMT; in ieee80211_send_action_csa()
3700 mgmt->u.action.u.chan_switch.action_code = WLAN_ACTION_SPCT_CHL_SWITCH; in ieee80211_send_action_csa()
3704 *pos++ = csa_settings->block_tx ? 1 : 0; /* CSA mode */ in ieee80211_send_action_csa()
3705 freq = csa_settings->chandef.chan->center_freq; in ieee80211_send_action_csa()
3706 *pos++ = ieee80211_frequency_to_channel(freq); /* channel */ in ieee80211_send_action_csa()
3707 *pos++ = csa_settings->count; /* count */ in ieee80211_send_action_csa()
3709 if (csa_settings->chandef.width == NL80211_CHAN_WIDTH_40) { in ieee80211_send_action_csa()
3715 ch_type = cfg80211_get_chandef_type(&csa_settings->chandef); in ieee80211_send_action_csa()
3722 if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_send_action_csa()
3723 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; in ieee80211_send_action_csa()
3728 *pos++ = sdata->u.mesh.mshcfg.dot11MeshTTL; /* Mesh TTL */ in ieee80211_send_action_csa()
3731 *pos++ |= csa_settings->block_tx ? in ieee80211_send_action_csa()
3735 put_unaligned_le16(ifmsh->pre_value, pos);/* Precedence Value */ in ieee80211_send_action_csa()
3739 if (csa_settings->chandef.width == NL80211_CHAN_WIDTH_80 || in ieee80211_send_action_csa()
3740 csa_settings->chandef.width == NL80211_CHAN_WIDTH_80P80 || in ieee80211_send_action_csa()
3741 csa_settings->chandef.width == NL80211_CHAN_WIDTH_160) { in ieee80211_send_action_csa()
3743 ieee80211_ie_build_wide_bw_cs(pos, &csa_settings->chandef); in ieee80211_send_action_csa()
3753 s32 end = data->desc[i].start + data->desc[i].duration - (tsf + 1); in ieee80211_extend_noa_desc()
3760 if (data->count[i] == 1) in ieee80211_extend_noa_desc()
3763 if (data->desc[i].interval == 0) in ieee80211_extend_noa_desc()
3767 skip = DIV_ROUND_UP(-end, data->desc[i].interval); in ieee80211_extend_noa_desc()
3768 if (data->count[i] < 255) { in ieee80211_extend_noa_desc()
3769 if (data->count[i] <= skip) { in ieee80211_extend_noa_desc()
3770 data->count[i] = 0; in ieee80211_extend_noa_desc()
3774 data->count[i] -= skip; in ieee80211_extend_noa_desc()
3777 data->desc[i].start += skip * data->desc[i].interval; in ieee80211_extend_noa_desc()
3792 if (!data->count[i]) in ieee80211_extend_absent_time()
3798 cur = data->desc[i].start - tsf; in ieee80211_extend_absent_time()
3802 cur = data->desc[i].start + data->desc[i].duration - tsf; in ieee80211_extend_absent_time()
3816 * arbitrary limit, used to avoid infinite loops when combined NoA in ieee80211_get_noa_absent_time()
3834 u32 next_offset = BIT(31) - 1; in ieee80211_update_p2p_noa()
3837 data->absent = 0; in ieee80211_update_p2p_noa()
3838 data->has_next_tsf = false; in ieee80211_update_p2p_noa()
3842 if (!data->count[i]) in ieee80211_update_p2p_noa()
3846 start = data->desc[i].start - tsf; in ieee80211_update_p2p_noa()
3848 data->absent |= BIT(i); in ieee80211_update_p2p_noa()
3853 data->has_next_tsf = true; in ieee80211_update_p2p_noa()
3856 if (data->absent) in ieee80211_update_p2p_noa()
3859 data->next_tsf = tsf + next_offset; in ieee80211_update_p2p_noa()
3872 const struct ieee80211_p2p_noa_desc *desc = &attr->desc[i]; in ieee80211_parse_p2p_noa()
3874 if (!desc->count || !desc->duration) in ieee80211_parse_p2p_noa()
3877 data->count[i] = desc->count; in ieee80211_parse_p2p_noa()
3878 data->desc[i].start = le32_to_cpu(desc->start_time); in ieee80211_parse_p2p_noa()
3879 data->desc[i].duration = le32_to_cpu(desc->duration); in ieee80211_parse_p2p_noa()
3880 data->desc[i].interval = le32_to_cpu(desc->interval); in ieee80211_parse_p2p_noa()
3882 if (data->count[i] > 1 && in ieee80211_parse_p2p_noa()
3883 data->desc[i].interval < data->desc[i].duration) in ieee80211_parse_p2p_noa()
3902 u16 beacon_int = sdata->vif.bss_conf.beacon_int * 1024; in ieee80211_recalc_dtim()
3903 u8 dtim_period = sdata->vif.bss_conf.dtim_period; in ieee80211_recalc_dtim()
3907 if (tsf == -1ULL || !beacon_int || !dtim_period) in ieee80211_recalc_dtim()
3910 if (sdata->vif.type == NL80211_IFTYPE_AP || in ieee80211_recalc_dtim()
3911 sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in ieee80211_recalc_dtim()
3912 if (!sdata->bss) in ieee80211_recalc_dtim()
3915 ps = &sdata->bss->ps; in ieee80211_recalc_dtim()
3916 } else if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_recalc_dtim()
3917 ps = &sdata->u.mesh.ps; in ieee80211_recalc_dtim()
3925 * dtim_count = dtim_period - (tsf / bcn_int) % dtim_period in ieee80211_recalc_dtim()
3933 dtim_count = dtim_period - bcns_from_dtim; in ieee80211_recalc_dtim()
3935 ps->dtim_count = dtim_count; in ieee80211_recalc_dtim()
3944 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_chanctx_radar_detect()
3946 if (WARN_ON(ctx->replace_state == IEEE80211_CHANCTX_WILL_BE_REPLACED)) in ieee80211_chanctx_radar_detect()
3949 list_for_each_entry(link, &ctx->reserved_links, reserved_chanctx_list) in ieee80211_chanctx_radar_detect()
3950 if (link->reserved_radar_required) in ieee80211_chanctx_radar_detect()
3951 radar_detect |= BIT(link->reserved.oper.width); in ieee80211_chanctx_radar_detect()
3954 * An in-place reservation context should not have any assigned vifs in ieee80211_chanctx_radar_detect()
3957 WARN_ON(ctx->replace_state == IEEE80211_CHANCTX_REPLACES_OTHER && in ieee80211_chanctx_radar_detect()
3958 !list_empty(&ctx->assigned_links)); in ieee80211_chanctx_radar_detect()
3960 list_for_each_entry(link, &ctx->assigned_links, assigned_chanctx_list) { in ieee80211_chanctx_radar_detect()
3961 if (!link->radar_required) in ieee80211_chanctx_radar_detect()
3965 BIT(link->conf->chanreq.oper.width); in ieee80211_chanctx_radar_detect()
3979 for_each_vif_active_link(&sdata->vif, link_conf, link_id) { in __ieee80211_get_radio_mask()
3980 conf = sdata_dereference(link_conf->chanctx_conf, sdata); in __ieee80211_get_radio_mask()
3981 if (!conf || conf->radio_idx < 0) in __ieee80211_get_radio_mask()
3984 mask |= BIT(conf->radio_idx); in __ieee80211_get_radio_mask()
4016 list_for_each_entry(ctx, &local->chanctx_list, list) { in ieee80211_fill_ifcomb_params()
4017 if (ctx->replace_state == IEEE80211_CHANCTX_WILL_BE_REPLACED) in ieee80211_fill_ifcomb_params()
4020 if (params->radio_idx >= 0 && in ieee80211_fill_ifcomb_params()
4021 ctx->conf.radio_idx != params->radio_idx) in ieee80211_fill_ifcomb_params()
4024 params->radar_detect |= in ieee80211_fill_ifcomb_params()
4027 if (chandef && ctx->mode != IEEE80211_CHANCTX_EXCLUSIVE && in ieee80211_fill_ifcomb_params()
4028 cfg80211_chandef_compatible(chandef, &ctx->conf.def)) in ieee80211_fill_ifcomb_params()
4031 params->num_different_channels++; in ieee80211_fill_ifcomb_params()
4034 list_for_each_entry(sdata_iter, &local->interfaces, list) { in ieee80211_fill_ifcomb_params()
4037 wdev_iter = &sdata_iter->wdev; in ieee80211_fill_ifcomb_params()
4041 cfg80211_iftype_allowed(local->hw.wiphy, in ieee80211_fill_ifcomb_params()
4042 wdev_iter->iftype, 0, 1)) in ieee80211_fill_ifcomb_params()
4045 if (!ieee80211_sdata_uses_radio(sdata_iter, params->radio_idx)) in ieee80211_fill_ifcomb_params()
4048 params->iftype_num[wdev_iter->iftype]++; in ieee80211_fill_ifcomb_params()
4061 struct ieee80211_local *local = sdata->local; in ieee80211_check_combinations()
4062 enum nl80211_iftype iftype = sdata->wdev.iftype; in ieee80211_check_combinations()
4069 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_check_combinations()
4072 return -EINVAL; in ieee80211_check_combinations()
4075 !chandef->chan)) in ieee80211_check_combinations()
4076 return -EINVAL; in ieee80211_check_combinations()
4079 return -EINVAL; in ieee80211_check_combinations()
4081 if (sdata->vif.type == NL80211_IFTYPE_AP || in ieee80211_check_combinations()
4082 sdata->vif.type == NL80211_IFTYPE_MESH_POINT) { in ieee80211_check_combinations()
4088 params.new_beacon_int = sdata->vif.bss_conf.beacon_int; in ieee80211_check_combinations()
4092 if (cfg80211_iftype_allowed(local->hw.wiphy, iftype, 0, 1)) { in ieee80211_check_combinations()
4094 return -EINVAL; in ieee80211_check_combinations()
4110 return cfg80211_check_combinations(local->hw.wiphy, ¶ms); in ieee80211_check_combinations()
4120 c->num_different_channels); in ieee80211_iter_max_chans()
4131 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_max_num_channels()
4135 err = cfg80211_iter_combinations(local->hw.wiphy, ¶ms, in ieee80211_max_num_channels()
4148 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; in ieee80211_add_s1g_capab_ie()
4153 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION)) in ieee80211_add_s1g_capab_ie()
4156 if (!caps->s1g) in ieee80211_add_s1g_capab_ie()
4159 memcpy(s1g_capab.capab_info, caps->cap, sizeof(caps->cap)); in ieee80211_add_s1g_capab_ie()
4160 memcpy(s1g_capab.supp_mcs_nss, caps->nss_mcs, sizeof(caps->nss_mcs)); in ieee80211_add_s1g_capab_ie()
4163 for (i = 0; i < sizeof(ifmgd->s1g_capa.capab_info); i++) { in ieee80211_add_s1g_capab_ie()
4164 u8 mask = ifmgd->s1g_capa_mask.capab_info[i]; in ieee80211_add_s1g_capab_ie()
4167 s1g_capab.capab_info[i] |= ifmgd->s1g_capa.capab_info[i] & mask; in ieee80211_add_s1g_capab_ie()
4171 for (i = 0; i < sizeof(ifmgd->s1g_capa.supp_mcs_nss); i++) { in ieee80211_add_s1g_capab_ie()
4172 u8 mask = ifmgd->s1g_capa_mask.supp_mcs_nss[i]; in ieee80211_add_s1g_capab_ie()
4176 ifmgd->s1g_capa.supp_mcs_nss[i] & mask; in ieee80211_add_s1g_capab_ie()
4206 *buf++ = qosinfo; /* U-APSD no in use */ in ieee80211_add_wmm_info_ie()
4219 skb_queue_walk(&txqi->frags, skb) { in ieee80211_txq_get_depth()
4221 frag_bytes += skb->len; in ieee80211_txq_get_depth()
4225 *frame_cnt = txqi->tin.backlog_packets + frag_cnt; in ieee80211_txq_get_depth()
4228 *byte_cnt = txqi->tin.backlog_bytes + frag_bytes; in ieee80211_txq_get_depth()
4273 he_cap = ieee80211_get_he_iftype_cap_vif(sband, &sdata->vif); in ieee80211_ie_len_eht_cap()
4274 eht_cap = ieee80211_get_eht_iftype_cap_vif(sband, &sdata->vif); in ieee80211_ie_len_eht_cap()
4278 is_ap = sdata->vif.type == NL80211_IFTYPE_AP; in ieee80211_ie_len_eht_cap()
4280 n = ieee80211_eht_mcs_nss_size(&he_cap->he_cap_elem, in ieee80211_ie_len_eht_cap()
4281 &eht_cap->eht_cap_elem, in ieee80211_ie_len_eht_cap()
4284 sizeof(eht_cap->eht_cap_elem) + n + in ieee80211_ie_len_eht_cap()
4285 ieee80211_eht_ppe_size(eht_cap->eht_ppe_thres[0], in ieee80211_ie_len_eht_cap()
4286 eht_cap->eht_cap_elem.phy_cap_info); in ieee80211_ie_len_eht_cap()
4296 ieee80211_get_he_iftype_cap_vif(sband, &sdata->vif); in ieee80211_put_eht_cap()
4298 ieee80211_get_eht_iftype_cap_vif(sband, &sdata->vif); in ieee80211_put_eht_cap()
4299 bool for_ap = sdata->vif.type == NL80211_IFTYPE_AP; in ieee80211_put_eht_cap()
4313 orig_mcs_nss_len = ieee80211_eht_mcs_nss_size(&he_cap->he_cap_elem, in ieee80211_put_eht_cap()
4314 &eht_cap->eht_cap_elem, in ieee80211_put_eht_cap()
4319 fixed = eht_cap->eht_cap_elem; in ieee80211_put_eht_cap()
4321 if (conn->bw_limit < IEEE80211_CONN_BW_LIMIT_80) in ieee80211_put_eht_cap()
4325 if (conn->bw_limit < IEEE80211_CONN_BW_LIMIT_160) { in ieee80211_put_eht_cap()
4334 if (conn->bw_limit < IEEE80211_CONN_BW_LIMIT_320) { in ieee80211_put_eht_cap()
4345 if (conn->bw_limit == IEEE80211_CONN_BW_LIMIT_20) in ieee80211_put_eht_cap()
4350 ppet_len = ieee80211_eht_ppe_size(eht_cap->eht_ppe_thres[0], in ieee80211_put_eht_cap()
4353 ie_len = 2 + 1 + sizeof(eht_cap->eht_cap_elem) + mcs_nss_len + ppet_len; in ieee80211_put_eht_cap()
4355 return -ENOBUFS; in ieee80211_put_eht_cap()
4358 skb_put_u8(skb, ie_len - 2); in ieee80211_put_eht_cap()
4364 * If the (non-AP) STA became 20 MHz only, then convert from in ieee80211_put_eht_cap()
4365 * <=80 to 20-MHz-only format, where MCSes are indicated in in ieee80211_put_eht_cap()
4366 * the groups 0-7, 8-9, 10-11, 12-13 rather than just 0-9, in ieee80211_put_eht_cap()
4367 * 10-11, 12-13. Thus, use 0-9 for 0-7 and 8-9. in ieee80211_put_eht_cap()
4369 skb_put_u8(skb, eht_cap->eht_mcs_nss_supp.bw._80.rx_tx_mcs9_max_nss); in ieee80211_put_eht_cap()
4370 skb_put_u8(skb, eht_cap->eht_mcs_nss_supp.bw._80.rx_tx_mcs9_max_nss); in ieee80211_put_eht_cap()
4371 skb_put_u8(skb, eht_cap->eht_mcs_nss_supp.bw._80.rx_tx_mcs11_max_nss); in ieee80211_put_eht_cap()
4372 skb_put_u8(skb, eht_cap->eht_mcs_nss_supp.bw._80.rx_tx_mcs13_max_nss); in ieee80211_put_eht_cap()
4374 skb_put_data(skb, &eht_cap->eht_mcs_nss_supp, mcs_nss_len); in ieee80211_put_eht_cap()
4378 skb_put_data(skb, &eht_cap->eht_ppe_thres, ppet_len); in ieee80211_put_eht_cap()
4403 switch (chandef->width) { in ieee80211_min_bw_limit_from_chandef()
4417 WARN(1, "unhandled chandef width %d\n", chandef->width); in ieee80211_min_bw_limit_from_chandef()
4425 tpe->max_local[i].valid = false; in ieee80211_clear_tpe()
4426 memset(tpe->max_local[i].power, in ieee80211_clear_tpe()
4428 sizeof(tpe->max_local[i].power)); in ieee80211_clear_tpe()
4430 tpe->max_reg_client[i].valid = false; in ieee80211_clear_tpe()
4431 memset(tpe->max_reg_client[i].power, in ieee80211_clear_tpe()
4433 sizeof(tpe->max_reg_client[i].power)); in ieee80211_clear_tpe()
4435 tpe->psd_local[i].valid = false; in ieee80211_clear_tpe()
4436 memset(tpe->psd_local[i].power, in ieee80211_clear_tpe()
4438 sizeof(tpe->psd_local[i].power)); in ieee80211_clear_tpe()
4440 tpe->psd_reg_client[i].valid = false; in ieee80211_clear_tpe()
4441 memset(tpe->psd_reg_client[i].power, in ieee80211_clear_tpe()
4443 sizeof(tpe->psd_reg_client[i].power)); in ieee80211_clear_tpe()