Lines Matching +full:rates +full:- +full:mcs
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;
57 __le16 fc = hdr->frame_control;
66 return hdr->addr1;
68 return hdr->addr2;
70 return hdr->addr3;
76 return ext->u.s1g_beacon.sa;
82 return hdr->addr3;
87 return hdr->addr1;
92 return hdr->addr2;
95 return hdr->addr1;
111 skb_queue_walk(&tx->skbs, skb) {
112 hdr = (struct ieee80211_hdr *) skb->data;
113 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
141 * 802.11a - 18.5.2: aSIFSTime = 16 usec
142 * 802.11g - 19.8.4: aSIFSTime = 10 usec +
146 dur += 16; /* IEEE 802.11-2012 18.3.2.4: T_PREAMBLE = 16 usec */
147 dur += 4; /* IEEE 802.11-2012 18.3.2.4: T_SIGNAL = 4 usec */
149 /* rates should already consider the channel bandwidth,
189 short_preamble = sdata->vif.bss_conf.use_short_preamble;
190 if (sdata->deflink.operating_11g_mode)
191 erp = rate->flags & IEEE80211_RATE_ERP_G;
194 dur = ieee80211_frame_duration(band, frame_len, rate->bitrate, erp,
213 sband = local->hw.wiphy->bands[frame_txctl->band];
217 rate = &sband->bitrates[frame_txctl->control.rts_cts_rate_idx];
222 short_preamble = sdata->vif.bss_conf.use_short_preamble;
223 if (sdata->deflink.operating_11g_mode)
224 erp = rate->flags & IEEE80211_RATE_ERP_G;
227 bitrate = rate->bitrate;
230 dur = ieee80211_frame_duration(sband->band, 10, bitrate,
233 dur += ieee80211_frame_duration(sband->band, frame_len, bitrate,
236 dur += ieee80211_frame_duration(sband->band, 10, bitrate,
256 sband = local->hw.wiphy->bands[frame_txctl->band];
260 rate = &sband->bitrates[frame_txctl->control.rts_cts_rate_idx];
264 short_preamble = sdata->vif.bss_conf.use_short_preamble;
265 if (sdata->deflink.operating_11g_mode)
266 erp = rate->flags & IEEE80211_RATE_ERP_G;
269 bitrate = rate->bitrate;
272 dur = ieee80211_frame_duration(sband->band, frame_len, bitrate,
274 if (!(frame_txctl->flags & IEEE80211_TX_CTL_NO_ACK)) {
276 dur += ieee80211_frame_duration(sband->band, 10, bitrate,
289 .sta = queue->sta,
294 skb = ieee80211_tx_dequeue(&local->hw, queue);
307 struct ieee80211_sub_if_data *sdata = vif_to_sdata(txq->vif);
310 spin_lock(&local->handle_wake_tx_queue_lock);
313 ieee80211_txq_schedule_start(hw, txq->ac);
314 while ((queue = ieee80211_next_txq(hw, txq->ac))) {
318 ieee80211_txq_schedule_end(hw, txq->ac);
319 spin_unlock(&local->handle_wake_tx_queue_lock);
325 struct ieee80211_local *local = sdata->local;
326 struct ieee80211_vif *vif = &sdata->vif;
327 struct fq *fq = &local->fq;
334 spin_lock(&fq->lock);
336 if (!test_bit(SDATA_STATE_RUNNING, &sdata->state))
339 if (sdata->vif.type == NL80211_IFTYPE_AP)
340 ps = &sdata->bss->ps;
342 list_for_each_entry_rcu(sta, &local->sta_list, list) {
343 if (sdata != sta->sdata)
346 for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) {
347 struct ieee80211_txq *txq = sta->sta.txq[i];
354 if (ac != txq->ac)
358 &txqi->flags))
361 spin_unlock(&fq->lock);
363 spin_lock(&fq->lock);
367 if (!vif->txq)
370 txqi = to_txq_info(vif->txq);
372 if (!test_and_clear_bit(IEEE80211_TXQ_DIRTY, &txqi->flags) ||
373 (ps && atomic_read(&ps->num_sta_ps)) || ac != vif->txq->ac)
376 spin_unlock(&fq->lock);
382 spin_unlock(&fq->lock);
387 __releases(&local->queue_stop_reason_lock)
388 __acquires(&local->queue_stop_reason_lock)
397 if (local->hw.queues < IEEE80211_NUM_ACS)
400 for (i = 0; i < local->hw.queues; i++) {
401 if (local->queue_stop_reasons[i])
404 spin_unlock_irqrestore(&local->queue_stop_reason_lock, *flags);
405 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
409 int ac_queue = sdata->vif.hw_queue[ac];
412 sdata->vif.cab_queue == i)
416 spin_lock_irqsave(&local->queue_stop_reason_lock, *flags);
428 spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
430 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
440 if (WARN_ON(queue >= hw->queues))
443 if (!test_bit(reason, &local->queue_stop_reasons[queue]))
447 local->q_stop_reasons[queue][reason] = 0;
449 local->q_stop_reasons[queue][reason]--;
450 if (WARN_ON(local->q_stop_reasons[queue][reason] < 0))
451 local->q_stop_reasons[queue][reason] = 0;
454 if (local->q_stop_reasons[queue][reason] == 0)
455 __clear_bit(reason, &local->queue_stop_reasons[queue]);
458 local->q_stop_reasons[queue][reason]);
460 if (local->queue_stop_reasons[queue] != 0)
464 if (!skb_queue_empty(&local->pending[queue]))
465 tasklet_schedule(&local->tx_pending_tasklet);
475 tasklet_schedule(&local->wake_txqs_tasklet);
487 spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
489 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
506 if (WARN_ON(queue >= hw->queues))
510 local->q_stop_reasons[queue][reason] = 1;
512 local->q_stop_reasons[queue][reason]++;
515 local->q_stop_reasons[queue][reason]);
517 set_bit(reason, &local->queue_stop_reasons[queue]);
527 spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
529 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
543 struct ieee80211_hw *hw = &local->hw;
546 int queue = info->hw_queue;
548 if (WARN_ON(!info->control.vif)) {
549 ieee80211_free_txskb(&local->hw, skb);
553 spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
556 __skb_queue_tail(&local->pending[queue], skb);
559 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
565 struct ieee80211_hw *hw = &local->hw;
570 spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
574 if (WARN_ON(!info->control.vif)) {
575 ieee80211_free_txskb(&local->hw, skb);
579 queue = info->hw_queue;
585 __skb_queue_tail(&local->pending[queue], skb);
588 for (i = 0; i < hw->queues; i++)
592 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
604 spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
606 for_each_set_bit(i, &queues, hw->queues)
609 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
626 if (WARN_ON(queue >= hw->queues))
629 spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
631 &local->queue_stop_reasons[queue]);
632 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
646 spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
648 for_each_set_bit(i, &queues, hw->queues)
651 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
668 if (sdata && ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) {
674 if (sdata->vif.hw_queue[ac] != IEEE80211_INVAL_HW_QUEUE)
675 queues |= BIT(sdata->vif.hw_queue[ac]);
676 if (sdata->vif.cab_queue != IEEE80211_INVAL_HW_QUEUE)
677 queues |= BIT(sdata->vif.cab_queue);
680 queues = BIT(local->hw.queues) - 1;
690 if (!local->ops->flush && !drop)
695 * IEEE80211_HW_QUEUE_CONTROL - flush all queues
697 if (!queues || !ieee80211_hw_check(&local->hw, QUEUE_CONTROL))
700 ieee80211_stop_queues_by_reason(&local->hw, queues,
710 list_for_each_entry(sta, &local->sta_list, list) {
711 if (sdata != sta->sdata)
717 if (local->ops->flush)
720 ieee80211_wake_queues_by_reason(&local->hw, queues,
740 list_for_each_entry_rcu(sdata, &local->interfaces, list,
741 lockdep_is_held(&local->iflist_mtx) ||
742 lockdep_is_held(&local->hw.wiphy->mtx)) {
743 switch (sdata->vif.type) {
745 if (!(sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE) &&
746 !ieee80211_hw_check(&local->hw, NO_VIRTUAL_MONITOR))
755 active_only && !(sdata->flags & IEEE80211_SDATA_IN_DRIVER))
758 !(sdata->flags & IEEE80211_SDATA_IN_DRIVER))
761 iterator(data, sdata->vif.addr,
762 &sdata->vif);
765 sdata = rcu_dereference_check(local->monitor_sdata,
766 lockdep_is_held(&local->iflist_mtx) ||
767 lockdep_is_held(&local->hw.wiphy->mtx));
768 if (sdata && ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF) &&
770 sdata->flags & IEEE80211_SDATA_IN_DRIVER))
771 iterator(data, sdata->vif.addr, &sdata->vif);
782 mutex_lock(&local->iflist_mtx);
784 mutex_unlock(&local->iflist_mtx);
811 lockdep_assert_wiphy(hw->wiphy);
825 list_for_each_entry_rcu(sta, &local->sta_list, list,
826 lockdep_is_held(&local->hw.wiphy->mtx)) {
827 if (!sta->uploaded)
830 iterator(data, &sta->sta);
854 lockdep_assert_wiphy(local->hw.wiphy);
865 !(sdata->flags & IEEE80211_SDATA_IN_DRIVER))
867 return &sdata->vif;
876 return &vif_to_sdata(vif)->wdev;
882 * the suspend->resume cycle. Since we can't check each caller
891 if (local->quiescing || (local->suspended && !local->resuming)) {
906 queue_work(local->workqueue, work);
919 queue_delayed_work(local->workqueue, dwork, delay);
932 if (sdata->vif.type != NL80211_IFTYPE_AP &&
933 sdata->vif.type != NL80211_IFTYPE_STATION)
937 chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf);
939 center_freq = chanctx_conf->def.chan->center_freq;
946 rrule = freq_reg_info(sdata->wdev.wiphy, MHZ_TO_KHZ(center_freq));
948 if (IS_ERR_OR_NULL(rrule) || !rrule->has_wmm) {
953 if (sdata->vif.type == NL80211_IFTYPE_AP)
954 wmm_ac = &rrule->wmm_rule.ap[ac];
956 wmm_ac = &rrule->wmm_rule.client[ac];
957 qparam->cw_min = max_t(u16, qparam->cw_min, wmm_ac->cw_min);
958 qparam->cw_max = max_t(u16, qparam->cw_max, wmm_ac->cw_max);
959 qparam->aifs = max_t(u8, qparam->aifs, wmm_ac->aifsn);
960 qparam->txop = min_t(u16, qparam->txop, wmm_ac->cot / 32);
967 struct ieee80211_sub_if_data *sdata = link->sdata;
968 struct ieee80211_local *local = sdata->local;
976 if (!local->ops->conf_tx)
979 if (local->hw.queues < IEEE80211_NUM_ACS)
985 chanctx_conf = rcu_dereference(link->conf->chanctx_conf);
987 chanctx_conf->def.chan->band == NL80211_BAND_2GHZ) &&
988 !link->operating_11g_mode;
991 is_ocb = (sdata->vif.type == NL80211_IFTYPE_OCB);
993 /* Set defaults according to 802.11-2007 Table 7-37 */
1032 qparam.cw_min = (aCWmin + 1) / 2 - 1;
1046 qparam.cw_max = (aCWmin + 1) / 2 - 1;
1047 qparam.cw_min = (aCWmin + 1) / 4 - 1;
1062 link->tx_conf[ac] = qparam;
1066 if (sdata->vif.type != NL80211_IFTYPE_MONITOR &&
1067 sdata->vif.type != NL80211_IFTYPE_P2P_DEVICE &&
1068 sdata->vif.type != NL80211_IFTYPE_NAN) {
1069 link->conf->qos = enable_qos;
1082 struct ieee80211_local *local = sdata->local;
1085 bool multi_link = ieee80211_vif_is_mld(&sdata->vif);
1094 .len = sizeof(mle) - 2,
1101 memcpy(mle.basic.mld_mac_addr, sdata->vif.addr, ETH_ALEN);
1104 skb = dev_alloc_skb(local->hw.extra_tx_headroom + IEEE80211_WEP_IV_LEN +
1110 skb_reserve(skb, local->hw.extra_tx_headroom + IEEE80211_WEP_IV_LEN);
1113 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
1115 memcpy(mgmt->da, da, ETH_ALEN);
1116 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
1117 memcpy(mgmt->bssid, bssid, ETH_ALEN);
1118 mgmt->u.auth.auth_alg = cpu_to_le16(auth_alg);
1119 mgmt->u.auth.auth_transaction = cpu_to_le16(transaction);
1120 mgmt->u.auth.status_code = cpu_to_le16(status);
1127 mgmt->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
1135 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT |
1145 struct ieee80211_local *local = sdata->local;
1150 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | stype);
1151 mgmt->duration = 0; /* initialize only */
1152 mgmt->seq_ctrl = 0; /* initialize only */
1153 memcpy(mgmt->da, da, ETH_ALEN);
1154 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
1155 memcpy(mgmt->bssid, bssid, ETH_ALEN);
1157 mgmt->u.deauth.reason_code = cpu_to_le16(reason);
1160 skb = dev_alloc_skb(local->hw.extra_tx_headroom +
1165 skb_reserve(skb, local->hw.extra_tx_headroom);
1170 if (sdata->vif.type != NL80211_IFTYPE_STATION ||
1171 !(sdata->u.mgd.flags & IEEE80211_STA_MFP_ENABLED))
1172 IEEE80211_SKB_CB(skb)->flags |=
1183 return -ENOBUFS;
1188 skb_put_data(skb, &s1g_cap->cap, sizeof(s1g_cap->cap));
1189 skb_put_data(skb, &s1g_cap->nss_mcs, sizeof(s1g_cap->nss_mcs));
1203 struct ieee80211_local *local = sdata->local;
1211 sband = local->hw.wiphy->bands[band];
1217 return ieee80211_put_s1g_cap(skb, &sband->s1g_cap);
1235 if (skb_tailroom(skb) < noffset - *offset)
1236 return -ENOBUFS;
1237 skb_put_data(skb, ie + *offset, noffset - *offset);
1246 if (chandef->chan && sband->band == NL80211_BAND_2GHZ) {
1248 return -ENOBUFS;
1252 ieee80211_frequency_to_channel(chandef->chan->center_freq));
1271 if (skb_tailroom(skb) < noffset - *offset)
1272 return -ENOBUFS;
1273 skb_put_data(skb, ie + *offset, noffset - *offset);
1277 if (sband->ht_cap.ht_supported) {
1281 return -ENOBUFS;
1284 ieee80211_ie_build_ht_cap(pos, &sband->ht_cap,
1285 sband->ht_cap.cap);
1301 /* 60 GHz (Multi-band, DMG, MMS) can't happen */
1306 if (skb_tailroom(skb) < noffset - *offset)
1307 return -ENOBUFS;
1308 skb_put_data(skb, ie + *offset, noffset - *offset);
1313 for (i = 0; i < sband->n_channels; i++) {
1314 if (sband->channels[i].flags & (IEEE80211_CHAN_DISABLED |
1322 if (sband->vht_cap.vht_supported && have_80mhz) {
1326 return -ENOBUFS;
1329 ieee80211_ie_build_vht_cap(pos, &sband->vht_cap,
1330 sband->vht_cap.cap);
1347 if (skb_tailroom(skb) < noffset - *offset)
1348 return -ENOBUFS;
1349 skb_put_data(skb, ie + *offset, noffset - *offset);
1353 if (cfg80211_any_usable_channels(local->hw.wiphy, BIT(sband->band),
1360 if (cfg80211_any_usable_channels(local->hw.wiphy, BIT(sband->band),
1374 * that calculates local->scan_ies_len.
1395 ie_desc->ies[i] = skb_tail_pointer(skb);
1403 ie_desc->len[i] = skb_tail_pointer(skb) -
1404 ie_desc->ies[i];
1410 if (WARN_ONCE(skb_tailroom(skb) < ie_len - custom_ie_offset,
1412 return -ENOBUFS;
1413 ie_desc->common_ies = skb_tail_pointer(skb);
1415 ie_len - custom_ie_offset);
1416 ie_desc->common_ie_len = skb_tail_pointer(skb) -
1417 ie_desc->common_ies;
1437 return -ENOMEM;
1448 if (skb->len > buffer_len) {
1449 ret = -ENOBUFS;
1453 memcpy(buffer, start, skb->len);
1457 offs = ie_desc->ies[i] - start;
1458 ie_desc->ies[i] = buffer + offs;
1460 offs = ie_desc->common_ies - start;
1461 ie_desc->common_ies = buffer + offs;
1463 ret = skb->len;
1477 struct ieee80211_local *local = sdata->local;
1487 * badly-behaved APs don't respond when this parameter is included.
1489 chandef.width = sdata->vif.bss_conf.chanreq.oper.width;
1495 skb = ieee80211_probereq_get(&local->hw, src, ssid, ssid_len,
1496 local->scan_ies_len + ie_len);
1500 rate_masks[chan->band] = ratemask;
1502 ie, ie_len, BIT(chan->band),
1506 mgmt = (struct ieee80211_mgmt *) skb->data;
1507 memcpy(mgmt->da, dst, ETH_ALEN);
1508 memcpy(mgmt->bssid, dst, ETH_ALEN);
1511 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT;
1525 sband = sdata->local->hw.wiphy->bands[band];
1529 num_rates = sband->n_bitrates;
1531 for (i = 0; i < elems->supp_rates_len +
1532 elems->ext_supp_rates_len; i++) {
1536 if (i < elems->supp_rates_len)
1537 rate = elems->supp_rates[i];
1538 else if (elems->ext_supp_rates)
1539 rate = elems->ext_supp_rates
1540 [i - elems->supp_rates_len];
1548 int brate = sband->bitrates[j].bitrate;
1569 wiphy_work_cancel(local->hw.wiphy, &local->reconfig_filter);
1571 flush_workqueue(local->workqueue);
1572 wiphy_work_flush(local->hw.wiphy, NULL);
1586 if (test_bit(SCAN_COMPLETED, &local->scanning)) {
1588 * we don't attempt to continue a partial HW scan - which is
1593 set_bit(SCAN_ABORTED, &local->scanning);
1594 wiphy_delayed_work_queue(local->hw.wiphy, &local->scan_work, 0);
1595 wiphy_delayed_work_flush(local->hw.wiphy, &local->scan_work);
1604 lockdep_assert_wiphy(local->hw.wiphy);
1616 local->resuming = false;
1617 local->suspended = false;
1618 local->in_reconfig = false;
1619 local->reconfig_failure = true;
1628 list_for_each_entry(sdata, &local->interfaces, list)
1629 sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER;
1634 list_for_each_entry(ctx, &local->chanctx_list, list)
1635 ctx->driver_present = false;
1645 lockdep_assert_wiphy(local->hw.wiphy);
1647 conf = rcu_dereference_protected(link->conf->chanctx_conf,
1648 lockdep_is_held(&local->hw.wiphy->mtx));
1651 drv_assign_vif_chanctx(local, sdata, link->conf, ctx);
1657 struct ieee80211_local *local = sdata->local;
1660 lockdep_assert_wiphy(local->hw.wiphy);
1663 list_for_each_entry(sta, &local->sta_list, list) {
1666 if (!sta->uploaded || sta->sdata != sdata)
1670 state < sta->sta_state; state++)
1671 WARN_ON(drv_sta_state(local, sta->sdata, sta, state,
1681 res = drv_start_nan(sdata->local, sdata,
1682 &sdata->u.nan.conf);
1686 funcs = kcalloc(sdata->local->hw.max_nan_de_entries + 1,
1690 return -ENOMEM;
1696 spin_lock_bh(&sdata->u.nan.func_lock);
1698 idr_for_each_entry(&sdata->u.nan.function_inst_ids, func, id)
1701 spin_unlock_bh(&sdata->u.nan.func_lock);
1704 res = drv_add_nan_func(sdata->local, sdata, funcs[i]);
1706 ieee80211_nan_func_terminated(&sdata->vif,
1707 funcs[i]->instance_id,
1723 for (link_id = 0; link_id < ARRAY_SIZE(sdata->link); link_id++) {
1726 if (!(sdata->vif.active_links & BIT(link_id)))
1729 link = sdata_dereference(sdata->link[link_id], sdata);
1733 if (rcu_access_pointer(link->u.ap.beacon))
1734 drv_start_ap(local, sdata, link->conf);
1736 if (!link->conf->enable_beacon)
1748 struct ieee80211_hw *hw = &local->hw;
1757 bool suspended = local->suspended;
1760 lockdep_assert_wiphy(local->hw.wiphy);
1763 if (!local->open_count)
1768 local->resuming = true;
1770 if (local->wowlan) {
1774 * clear local->suspended so the device could operate
1777 local->suspended = false;
1779 local->wowlan = false;
1781 local->resuming = false;
1790 * restore local->suspended in this case.
1793 local->suspended = true;
1804 if (suspended && local->in_reconfig && !reconfig_due_to_wowlan)
1805 cancel_work_sync(&local->restart_work);
1807 local->started = false;
1829 drv_set_frag_threshold(local, -1, hw->wiphy->frag_threshold);
1832 if (hw->wiphy->n_radio > 0) {
1833 for (i = 0; i < hw->wiphy->n_radio; i++) {
1835 hw->wiphy->radio_cfg[i].rts_threshold;
1840 drv_set_rts_threshold(local, -1, hw->wiphy->rts_threshold);
1844 drv_set_coverage_class(local, -1, hw->wiphy->coverage_class);
1851 sdata = wiphy_dereference(local->hw.wiphy, local->monitor_sdata);
1852 if (sdata && ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF)) {
1854 WARN_ON(local->resuming);
1857 RCU_INIT_POINTER(local->monitor_sdata, NULL);
1863 list_for_each_entry(sdata, &local->interfaces, list) {
1864 if (sdata->vif.type == NL80211_IFTYPE_MONITOR &&
1865 !ieee80211_hw_check(&local->hw, NO_VIRTUAL_MONITOR))
1867 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
1879 list_for_each_entry_continue_reverse(sdata, &local->interfaces,
1881 if (sdata->vif.type == NL80211_IFTYPE_MONITOR &&
1882 !ieee80211_hw_check(&local->hw, NO_VIRTUAL_MONITOR))
1884 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
1893 list_for_each_entry(ctx, &local->chanctx_list, list)
1894 if (ctx->replace_state != IEEE80211_CHANCTX_REPLACES_OTHER)
1897 sdata = wiphy_dereference(local->hw.wiphy, local->monitor_sdata);
1899 ieee80211_assign_chanctx(local, sdata, &sdata->deflink);
1902 ieee80211_hw_config(local, -1, IEEE80211_CONF_CHANGE_LISTEN_INTERVAL |
1911 list_for_each_entry(sdata, &local->interfaces, list) {
1912 /* common change flags for all interface types - link only */
1931 if (ieee80211_vif_is_mld(&sdata->vif)) {
1933 [0] = &sdata->vif.bss_conf,
1936 if (sdata->vif.type == NL80211_IFTYPE_STATION) {
1938 active_links = sdata->vif.active_links;
1939 link_id = ffs(active_links) - 1;
1940 sdata->vif.active_links = BIT(link_id);
1944 sdata->vif.active_links,
1948 sdata->restart_active_links = active_links;
1951 link_id < ARRAY_SIZE(sdata->vif.link_conf);
1953 if (!ieee80211_vif_link_active(&sdata->vif, link_id))
1956 link = sdata_dereference(sdata->link[link_id], sdata);
1963 switch (sdata->vif.type) {
1968 if (sdata->vif.cfg.ibss_joined)
1976 drv_conf_tx(local, &sdata->deflink, i,
1977 &sdata->deflink.tx_conf[i]);
1981 if (sdata->vif.bss_conf.mu_mimo_owner)
1984 if (!ieee80211_vif_is_mld(&sdata->vif))
1987 switch (sdata->vif.type) {
1989 if (!ieee80211_vif_is_mld(&sdata->vif)) {
1994 /* Re-send beacon info report to the driver */
1995 if (sdata->deflink.u.mgd.have_beacon)
1998 if (sdata->vif.bss_conf.max_idle_period ||
1999 sdata->vif.bss_conf.protected_keep_alive)
2024 if (ieee80211_vif_is_mld(&sdata->vif))
2030 if (sdata->vif.bss_conf.ftm_responder == 1 &&
2031 wiphy_ext_feature_isset(sdata->local->hw.wiphy,
2035 if (sdata->vif.type == NL80211_IFTYPE_AP) {
2038 if (ieee80211_vif_is_mld(&sdata->vif)) {
2045 if (rcu_access_pointer(sdata->deflink.u.ap.beacon))
2047 sdata->deflink.conf);
2051 if (sdata->vif.bss_conf.enable_beacon) {
2087 if (!(local->hw.conf.flags & IEEE80211_CONF_PS)) {
2088 list_for_each_entry(sdata, &local->interfaces, list) {
2089 if (sdata->vif.type != NL80211_IFTYPE_STATION)
2091 if (!sdata->u.mgd.associated)
2099 list_for_each_entry(sdata, &local->interfaces, list) {
2103 switch (sdata->vif.type) {
2114 list_for_each_entry(sdata, &local->interfaces, list)
2117 /* re-enable multi-link for client interfaces */
2118 list_for_each_entry(sdata, &local->interfaces, list) {
2119 if (sdata->restart_active_links)
2120 ieee80211_set_active_links(&sdata->vif,
2121 sdata->restart_active_links);
2124 * before reconfig, it will do nothing, so re-schedule.
2126 if (sdata->desired_active_links)
2127 wiphy_work_queue(sdata->local->hw.wiphy,
2128 &sdata->activate_links_work);
2132 sched_scan_sdata = rcu_dereference_protected(local->sched_scan_sdata,
2133 lockdep_is_held(&local->hw.wiphy->mtx));
2134 sched_scan_req = rcu_dereference_protected(local->sched_scan_req,
2135 lockdep_is_held(&local->hw.wiphy->mtx));
2144 if (sched_scan_req->n_scan_plans > 1 ||
2147 RCU_INIT_POINTER(local->sched_scan_sdata, NULL);
2148 RCU_INIT_POINTER(local->sched_scan_req, NULL);
2153 cfg80211_sched_scan_stopped_locked(local->hw.wiphy, 0);
2167 list_for_each_entry(sta, &local->sta_list, list) {
2168 if (!local->resuming)
2179 if (local->open_count && (!suspended || reconfig_due_to_wowlan))
2182 if (local->in_reconfig) {
2183 in_reconfig = local->in_reconfig;
2184 local->in_reconfig = false;
2190 list_for_each_entry(sdata, &local->interfaces, list) {
2192 wiphy_work_queue(local->hw.wiphy, &sdata->work);
2201 list_for_each_entry(sdata, &local->interfaces, list) {
2204 if (sdata->vif.type == NL80211_IFTYPE_STATION)
2209 if (local->virt_monitors > 0 &&
2210 local->virt_monitors == local->open_count)
2218 local->suspended = false;
2220 local->resuming = false;
2224 if (local->open_count && !reconfig_due_to_wowlan)
2227 list_for_each_entry(sdata, &local->interfaces, list) {
2230 if (sdata->vif.type == NL80211_IFTYPE_STATION)
2234 mod_timer(&local->sta_cleanup, jiffies + 1);
2252 local = sdata->local;
2254 lockdep_assert_wiphy(local->hw.wiphy);
2257 !local->resuming))
2261 !local->in_reconfig))
2264 if (WARN_ON(vif->type != NL80211_IFTYPE_STATION))
2267 sdata->flags |= flag;
2269 list_for_each_entry(key, &sdata->key_list, list)
2270 key->flags |= KEY_FLAG_TAINTED;
2288 struct ieee80211_local *local = sdata->local;
2292 lockdep_assert_wiphy(local->hw.wiphy);
2294 chanctx_conf = rcu_dereference_protected(link->conf->chanctx_conf,
2295 lockdep_is_held(&local->hw.wiphy->mtx));
2313 struct ieee80211_local *local = sdata->local;
2318 lockdep_assert_wiphy(local->hw.wiphy);
2320 for (i = 0; i < ARRAY_SIZE(sdata->vif.link_conf); i++) {
2327 bss_conf = rcu_dereference(sdata->vif.link_conf[i]);
2333 chanctx_conf = rcu_dereference_protected(bss_conf->chanctx_conf,
2334 lockdep_is_held(&local->hw.wiphy->mtx));
2339 * the mutex. Just the way we reached it could - in
2340 * theory - go away, but we don't really care and
2379 *pos++ = ht_cap->ampdu_factor |
2380 (ht_cap->ampdu_density <<
2383 /* MCS set */
2384 memcpy(pos, &ht_cap->mcs, sizeof(ht_cap->mcs));
2385 pos += sizeof(ht_cap->mcs);
2413 /* VHT MCS set */
2414 memcpy(pos, &vht_cap->vht_mcs, sizeof(vht_cap->vht_mcs));
2415 pos += sizeof(vht_cap->vht_mcs);
2431 he_cap = ieee80211_get_he_iftype_cap_vif(sband, &sdata->vif);
2435 n = ieee80211_he_mcs_nss_size(&he_cap->he_cap_elem);
2437 sizeof(he_cap->he_cap_elem) + n +
2438 ieee80211_he_ppe_size(he_cap->ppe_thres[0],
2439 he_cap->he_cap_elem.phy_cap_info);
2449 *elem = he_cap->he_cap_elem;
2451 switch (conn->bw_limit) {
2466 max_ru = elem->phy_cap_info[8] & IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_MASK;
2468 elem->phy_cap_info[8] &= ~IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_MASK;
2469 elem->phy_cap_info[8] |= max_ru;
2471 if (conn->bw_limit < IEEE80211_CONN_BW_LIMIT_40) {
2472 elem->phy_cap_info[0] &=
2475 elem->phy_cap_info[9] &=
2479 if (conn->bw_limit < IEEE80211_CONN_BW_LIMIT_160) {
2480 elem->phy_cap_info[0] &=
2483 elem->phy_cap_info[5] &=
2485 elem->phy_cap_info[7] &=
2505 he_cap = ieee80211_get_he_iftype_cap_vif(sband, &sdata->vif);
2514 sizeof(he_cap->he_cap_elem) + n +
2515 ieee80211_he_ppe_size(he_cap->ppe_thres[0],
2516 he_cap->he_cap_elem.phy_cap_info);
2519 return -ENOBUFS;
2528 skb_put_data(skb, &he_cap->he_mcs_nss_supp, n);
2531 if ((he_cap->he_cap_elem.phy_cap_info[6] &
2539 n = hweight8(he_cap->ppe_thres[0] &
2541 n *= (1 + ((he_cap->ppe_thres[0] & IEEE80211_PPE_THRES_NSS_MASK) >>
2552 skb_put_data(skb, &he_cap->ppe_thres, n);
2555 *len = skb_tail_pointer(skb) - len - 1;
2582 enum nl80211_iftype iftype = ieee80211_vif_type_p2p(&sdata->vif);
2585 if (!cfg80211_any_usable_channels(sdata->local->hw.wiphy,
2590 sband = sdata->local->hw.wiphy->bands[NL80211_BAND_6GHZ];
2597 if (!iftd->he_6ghz_capa.capa)
2600 cap = iftd->he_6ghz_capa.capa;
2623 return -ENOBUFS;
2641 ht_oper->primary_chan = ieee80211_frequency_to_channel(
2642 chandef->chan->center_freq);
2643 switch (chandef->width) {
2648 if (chandef->center_freq1 > chandef->chan->center_freq)
2649 ht_oper->ht_param = IEEE80211_HT_PARAM_CHA_SEC_ABOVE;
2651 ht_oper->ht_param = IEEE80211_HT_PARAM_CHA_SEC_BELOW;
2658 ht_oper->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE;
2661 if (ht_cap->cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40 &&
2662 chandef->width != NL80211_CHAN_WIDTH_20_NOHT &&
2663 chandef->width != NL80211_CHAN_WIDTH_20)
2664 ht_oper->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY;
2667 ht_oper->ht_param |= IEEE80211_HT_PARAM_RIFS_MODE;
2669 ht_oper->operation_mode = cpu_to_le16(prot_mode);
2670 ht_oper->stbc_param = 0x0000;
2672 /* It seems that Basic MCS set and Supported MCS set
2674 memset(&ht_oper->basic_set, 0, 16);
2675 memcpy(&ht_oper->basic_set, &ht_cap->mcs, 10);
2686 switch (chandef->width) {
2705 *pos++ = ieee80211_frequency_to_channel(chandef->center_freq1);
2707 if (chandef->center_freq2)
2708 *pos++ = ieee80211_frequency_to_channel(chandef->center_freq2);
2721 vht_oper->center_freq_seg0_idx = ieee80211_frequency_to_channel(
2722 chandef->center_freq1);
2723 if (chandef->center_freq2)
2724 vht_oper->center_freq_seg1_idx =
2725 ieee80211_frequency_to_channel(chandef->center_freq2);
2727 vht_oper->center_freq_seg1_idx = 0x00;
2729 switch (chandef->width) {
2735 vht_oper->chan_width = IEEE80211_VHT_CHANWIDTH_80MHZ;
2736 vht_oper->center_freq_seg1_idx = vht_oper->center_freq_seg0_idx;
2737 if (chandef->chan->center_freq < chandef->center_freq1)
2738 vht_oper->center_freq_seg0_idx -= 8;
2740 vht_oper->center_freq_seg0_idx += 8;
2747 vht_oper->chan_width = IEEE80211_VHT_CHANWIDTH_80MHZ;
2750 vht_oper->chan_width = IEEE80211_VHT_CHANWIDTH_80MHZ;
2757 vht_oper->chan_width = IEEE80211_VHT_CHANWIDTH_USE_HT;
2761 /* don't require special VHT peer rates */
2762 vht_oper->basic_mcs_set = cpu_to_le16(0xffff);
2775 if (chandef->chan->band == NL80211_BAND_6GHZ)
2789 if (chandef->chan->band == NL80211_BAND_6GHZ)
2794 he_oper->he_oper_params = cpu_to_le32(he_oper_params);
2796 /* don't require special HE peer rates */
2797 he_oper->he_mcs_nss_set = cpu_to_le16(0xffff);
2800 if (chandef->chan->band != NL80211_BAND_6GHZ)
2803 cfg80211_chandef_create(&he_chandef, chandef->chan, NL80211_CHAN_NO_HT);
2804 he_chandef.center_freq1 = chandef->center_freq1;
2805 he_chandef.center_freq2 = chandef->center_freq2;
2806 he_chandef.width = chandef->width;
2810 he_6ghz_op->minrate = 6; /* 6 Mbps */
2811 he_6ghz_op->primary =
2812 ieee80211_frequency_to_channel(he_chandef.chan->center_freq);
2813 he_6ghz_op->ccfs0 =
2816 he_6ghz_op->ccfs1 =
2819 he_6ghz_op->ccfs1 = 0;
2827 he_6ghz_op->ccfs0 =
2834 he_6ghz_op->control =
2836 he_6ghz_op->ccfs1 = he_6ghz_op->ccfs0;
2837 if (he_chandef.chan->center_freq < he_chandef.center_freq1)
2838 he_6ghz_op->ccfs0 -= 8;
2840 he_6ghz_op->ccfs0 += 8;
2843 he_6ghz_op->control =
2847 he_6ghz_op->control =
2851 he_6ghz_op->control =
2855 he_6ghz_op->control =
2871 &eht_cap->eht_mcs_nss_supp.only_20mhz;
2885 memcpy(&eht_oper->basic_mcs_nss, eht_mcs_nss, sizeof(*eht_mcs_nss));
2886 eht_oper->params |= IEEE80211_EHT_OPER_INFO_PRESENT;
2890 (struct ieee80211_eht_operation_info *)eht_oper->optional;
2892 eht_oper_info->ccfs0 =
2893 ieee80211_frequency_to_channel(chandef->center_freq1);
2894 if (chandef->center_freq2)
2895 eht_oper_info->ccfs1 =
2896 ieee80211_frequency_to_channel(chandef->center_freq2);
2898 eht_oper_info->ccfs1 = 0;
2900 switch (chandef->width) {
2903 eht_oper_info->ccfs1 = eht_oper_info->ccfs0;
2904 if (chandef->chan->center_freq < chandef->center_freq1)
2905 eht_oper_info->ccfs0 -= 16;
2907 eht_oper_info->ccfs0 += 16;
2910 eht_oper_info->ccfs1 = eht_oper_info->ccfs0;
2911 if (chandef->chan->center_freq < chandef->center_freq1)
2912 eht_oper_info->ccfs0 -= 8;
2914 eht_oper_info->ccfs0 += 8;
2929 eht_oper_info->control = chan_width;
2932 /* TODO: eht_oper_info->optional */
2945 switch (ht_oper->ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET) {
2959 cfg80211_chandef_create(chandef, chandef->chan, channel_type);
2983 vht_cap = hw->wiphy->bands[chandef->chan->band]->vht_cap.cap;
2992 ccfs0 = oper->center_freq_seg0_idx;
2993 ccfs1 = oper->center_freq_seg1_idx;
2994 ccfs2 = (le16_to_cpu(htop->operation_mode) &
3005 * Cf. IEEE 802.11 Table 9-250
3041 cf0 = ieee80211_channel_to_frequency(ccf0, chandef->chan->band);
3042 cf1 = ieee80211_channel_to_frequency(ccf1, chandef->chan->band);
3044 switch (oper->chan_width) {
3055 diff = abs(ccf1 - ccf0);
3090 chandef->center_freq1 =
3091 ieee80211_channel_to_frequency(info->ccfs0,
3092 chandef->chan->band);
3094 switch (u8_get_bits(info->control,
3097 chandef->width = NL80211_CHAN_WIDTH_20;
3100 chandef->width = NL80211_CHAN_WIDTH_40;
3103 chandef->width = NL80211_CHAN_WIDTH_80;
3106 chandef->width = NL80211_CHAN_WIDTH_160;
3107 chandef->center_freq1 =
3108 ieee80211_channel_to_frequency(info->ccfs1,
3109 chandef->chan->band);
3112 chandef->width = NL80211_CHAN_WIDTH_320;
3113 chandef->center_freq1 =
3114 ieee80211_channel_to_frequency(info->ccfs1,
3115 chandef->chan->band);
3129 if (chandef->chan->band != NL80211_BAND_6GHZ)
3144 freq = ieee80211_channel_to_frequency(he_6ghz_oper->primary,
3146 he_chandef.chan = ieee80211_get_channel(local->hw.wiphy, freq);
3152 !(eht_oper->params & IEEE80211_EHT_OPER_INFO_PRESENT)) {
3153 switch (u8_get_bits(he_6ghz_oper->control,
3166 if (!he_6ghz_oper->ccfs1)
3168 if (abs(he_6ghz_oper->ccfs1 - he_6ghz_oper->ccfs0) == 8)
3177 ieee80211_channel_to_frequency(he_6ghz_oper->ccfs1,
3181 ieee80211_channel_to_frequency(he_6ghz_oper->ccfs0,
3184 ieee80211_channel_to_frequency(he_6ghz_oper->ccfs1,
3188 ieee80211_chandef_eht_oper((const void *)eht_oper->optional,
3211 switch (FIELD_GET(S1G_OPER_CH_WIDTH_OPER, oper->ch_width)) {
3213 chandef->width = NL80211_CHAN_WIDTH_1;
3216 chandef->width = NL80211_CHAN_WIDTH_2;
3219 chandef->width = NL80211_CHAN_WIDTH_4;
3222 chandef->width = NL80211_CHAN_WIDTH_8;
3225 chandef->width = NL80211_CHAN_WIDTH_16;
3231 chandef->s1g_primary_2mhz = false;
3233 switch (u8_get_bits(oper->ch_width, S1G_OPER_CH_WIDTH_PRIMARY)) {
3236 oper->primary_ch, NL80211_BAND_S1GHZ);
3239 chandef->s1g_primary_2mhz = true;
3241 oper->primary_ch, NL80211_BAND_S1GHZ);
3243 if (u8_get_bits(oper->ch_width, S1G_OPER_CH_PRIMARY_LOCATION) ==
3245 pri_1mhz_khz = pri_2mhz_khz - 500;
3253 oper_khz = ieee80211_channel_to_freq_khz(oper->oper_ch,
3255 chandef->center_freq1 = KHZ_TO_MHZ(oper_khz);
3256 chandef->freq1_offset = oper_khz % 1000;
3257 chandef->chan =
3258 ieee80211_get_channel_khz(local->hw.wiphy, pri_1mhz_khz);
3260 return chandef->chan;
3268 u8 i, rates, skip;
3270 rates = 0;
3271 for (i = 0; i < sband->n_bitrates; i++) {
3274 rates++;
3278 rates = min_t(u8, rates, 8);
3282 if (rates <= skip)
3284 rates -= skip;
3287 if (skb_tailroom(skb) < rates + 2)
3288 return -ENOBUFS;
3291 skb_put_u8(skb, rates);
3293 for (i = 0; i < sband->n_bitrates && rates; i++) {
3301 skip--;
3307 rate = DIV_ROUND_UP(sband->bitrates[i].bitrate, 5);
3309 rates--;
3312 WARN(rates > 0, "rates confused: rates:%d, element:%d\n",
3313 rates, element_id);
3323 if (WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION))
3327 link_data = &sdata->deflink;
3329 link_data = wiphy_dereference(sdata->local->hw.wiphy,
3330 sdata->link[link_id]);
3333 return -99;
3335 return -ewma_beacon_signal_read(&link_data->u.mgd.ave_beacon_signal);
3339 u8 ieee80211_mcs_to_chains(const struct ieee80211_mcs_info *mcs)
3341 if (!mcs)
3346 if (mcs->rx_mask[3])
3348 if (mcs->rx_mask[2])
3350 if (mcs->rx_mask[1])
3356 * ieee80211_calculate_rx_timestamp - calculate timestamp in frame
3373 u64 ts = status->mactime;
3382 mactime_plcp_start = (status->flag & RX_FLAG_MACTIME) ==
3387 ri.bw = status->bw;
3390 switch (status->encoding) {
3393 ri.mcs = status->rate_idx;
3394 ri.nss = status->nss;
3395 ri.eht_ru_alloc = status->eht.ru;
3396 if (status->enc_flags & RX_ENC_FLAG_SHORT_GI)
3406 ri.mcs = status->rate_idx;
3407 ri.nss = status->nss;
3408 ri.he_ru_alloc = status->he_ru;
3409 if (status->enc_flags & RX_ENC_FLAG_SHORT_GI)
3422 * For HE MU PPDU, add the HE-SIG-B.
3423 * For HE ER PPDU, add 8us for the HE-SIG-A.
3424 * For HE TB PPDU, add 4us for the HE-STF.
3425 * Add the HE-LTF durations - variable.
3431 ri.mcs = status->rate_idx;
3433 if (status->enc_flags & RX_ENC_FLAG_SHORT_GI)
3442 if (status->enc_flags & RX_ENC_FLAG_HT_GF)
3448 * Add Data HT-LTFs per streams
3449 * TODO: add Extension HT-LTFs, 4us per LTF
3451 n_ltf = ((ri.mcs >> 3) & 3) + 1;
3459 ri.mcs = status->rate_idx;
3460 ri.nss = status->nss;
3461 if (status->enc_flags & RX_ENC_FLAG_SHORT_GI)
3473 * Add VHT-LTFs per streams
3487 sband = local->hw.wiphy->bands[status->band];
3488 ri.legacy = sband->bitrates[status->rate_idx].bitrate;
3491 if (status->band == NL80211_BAND_5GHZ) {
3494 } else if (status->enc_flags & RX_ENC_FLAG_SHORTPRE) {
3507 (unsigned long long)status->flag, status->rate_idx,
3508 status->nss))
3512 if ((status->flag & RX_FLAG_MACTIME) == RX_FLAG_MACTIME_END)
3513 ts -= mpdu_len * 8 * 10 / rate;
3532 lockdep_assert_wiphy(local->hw.wiphy);
3534 list_for_each_entry(sdata, &local->interfaces, list) {
3537 link = sdata_dereference(sdata->link[link_id],
3542 chanctx_conf = sdata_dereference(link->conf->chanctx_conf,
3544 if (ctx && &ctx->conf != chanctx_conf)
3547 wiphy_delayed_work_cancel(local->hw.wiphy,
3548 &link->dfs_cac_timer_work);
3550 if (!sdata->wdev.links[link_id].cac_started)
3553 chandef = link->conf->chanreq.oper;
3555 cfg80211_cac_event(sdata->dev, &chandef,
3570 lockdep_assert_wiphy(local->hw.wiphy);
3572 list_for_each_entry(ctx, &local->chanctx_list, list) {
3573 if (ctx->replace_state == IEEE80211_CHANCTX_REPLACES_OTHER)
3576 if (!ctx->radar_detected)
3579 ctx->radar_detected = false;
3581 chandef = ctx->conf.def;
3584 cfg80211_radar_event(local->hw.wiphy, &chandef, GFP_KERNEL);
3597 if (ctx->replace_state == IEEE80211_CHANCTX_REPLACES_OTHER)
3603 ctx->radar_detected = true;
3616 wiphy_work_queue(hw->wiphy, &local->radar_detected_work);
3631 /* no-HT indicates nothing to do */
3634 switch (c->width) {
3640 c->width = NL80211_CHAN_WIDTH_20_NOHT;
3641 conn->mode = IEEE80211_CONN_MODE_LEGACY;
3642 conn->bw_limit = IEEE80211_CONN_BW_LIMIT_20;
3643 c->punctured = 0;
3646 c->width = NL80211_CHAN_WIDTH_20;
3647 c->center_freq1 = c->chan->center_freq;
3648 if (conn->mode == IEEE80211_CONN_MODE_VHT)
3649 conn->mode = IEEE80211_CONN_MODE_HT;
3650 conn->bw_limit = IEEE80211_CONN_BW_LIMIT_20;
3651 c->punctured = 0;
3655 if (conn->mode == IEEE80211_CONN_MODE_VHT)
3656 conn->mode = IEEE80211_CONN_MODE_HT;
3657 conn->bw_limit = IEEE80211_CONN_BW_LIMIT_40;
3660 c->center_freq2 = 0;
3661 c->width = NL80211_CHAN_WIDTH_80;
3662 conn->bw_limit = IEEE80211_CONN_BW_LIMIT_80;
3666 conn->bw_limit = IEEE80211_CONN_BW_LIMIT_80;
3670 conn->bw_limit = IEEE80211_CONN_BW_LIMIT_160;
3678 /* keep c->width */
3679 conn->mode = IEEE80211_CONN_MODE_S1G;
3680 conn->bw_limit = IEEE80211_CONN_BW_LIMIT_20;
3685 /* keep c->width */
3686 conn->mode = IEEE80211_CONN_MODE_LEGACY;
3687 conn->bw_limit = IEEE80211_CONN_BW_LIMIT_20;
3692 c->center_freq1 = cfg80211_chandef_primary(c, new_primary_width,
3693 &c->punctured);
3694 c->width = new_primary_width;
3702 if (!cfg80211_chandef_valid(c) && c->punctured)
3713 struct ieee80211_local *local = sdata->local;
3719 if (sdata->vif.type != NL80211_IFTYPE_ADHOC &&
3720 sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
3721 return -EOPNOTSUPP;
3723 skb = dev_alloc_skb(local->tx_headroom + hdr_len +
3729 return -ENOMEM;
3731 skb_reserve(skb, local->tx_headroom);
3733 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
3736 eth_broadcast_addr(mgmt->da);
3737 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
3738 if (ieee80211_vif_is_mesh(&sdata->vif)) {
3739 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
3741 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
3742 memcpy(mgmt->bssid, ifibss->bssid, ETH_ALEN);
3744 mgmt->u.action.category = WLAN_CATEGORY_SPECTRUM_MGMT;
3745 mgmt->u.action.u.chan_switch.action_code = WLAN_ACTION_SPCT_CHL_SWITCH;
3749 *pos++ = csa_settings->block_tx ? 1 : 0; /* CSA mode */
3750 freq = csa_settings->chandef.chan->center_freq;
3752 *pos++ = csa_settings->count; /* count */
3754 if (csa_settings->chandef.width == NL80211_CHAN_WIDTH_40) {
3760 ch_type = cfg80211_get_chandef_type(&csa_settings->chandef);
3767 if (ieee80211_vif_is_mesh(&sdata->vif)) {
3768 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
3773 *pos++ = sdata->u.mesh.mshcfg.dot11MeshTTL; /* Mesh TTL */
3776 *pos++ |= csa_settings->block_tx ?
3780 put_unaligned_le16(ifmsh->pre_value, pos);/* Precedence Value */
3784 if (csa_settings->chandef.width == NL80211_CHAN_WIDTH_80 ||
3785 csa_settings->chandef.width == NL80211_CHAN_WIDTH_80P80 ||
3786 csa_settings->chandef.width == NL80211_CHAN_WIDTH_160) {
3788 ieee80211_ie_build_wide_bw_cs(pos, &csa_settings->chandef);
3798 s32 end = data->desc[i].start + data->desc[i].duration - (tsf + 1);
3805 if (data->count[i] == 1)
3808 if (data->desc[i].interval == 0)
3812 skip = DIV_ROUND_UP(-end, data->desc[i].interval);
3813 if (data->count[i] < 255) {
3814 if (data->count[i] <= skip) {
3815 data->count[i] = 0;
3819 data->count[i] -= skip;
3822 data->desc[i].start += skip * data->desc[i].interval;
3837 if (!data->count[i])
3843 cur = data->desc[i].start - tsf;
3847 cur = data->desc[i].start + data->desc[i].duration - tsf;
3879 u32 next_offset = BIT(31) - 1;
3882 data->absent = 0;
3883 data->has_next_tsf = false;
3887 if (!data->count[i])
3891 start = data->desc[i].start - tsf;
3893 data->absent |= BIT(i);
3898 data->has_next_tsf = true;
3901 if (data->absent)
3904 data->next_tsf = tsf + next_offset;
3917 const struct ieee80211_p2p_noa_desc *desc = &attr->desc[i];
3919 if (!desc->count || !desc->duration)
3922 data->count[i] = desc->count;
3923 data->desc[i].start = le32_to_cpu(desc->start_time);
3924 data->desc[i].duration = le32_to_cpu(desc->duration);
3925 data->desc[i].interval = le32_to_cpu(desc->interval);
3927 if (data->count[i] > 1 &&
3928 data->desc[i].interval < data->desc[i].duration)
3945 u32 beacon_int = sdata->vif.bss_conf.beacon_int * 1024;
3946 u8 dtim_period = sdata->vif.bss_conf.dtim_period;
3950 if (tsf == -1ULL || !beacon_int || !dtim_period)
3953 if (sdata->vif.type == NL80211_IFTYPE_AP ||
3954 sdata->vif.type == NL80211_IFTYPE_AP_VLAN) {
3955 if (!sdata->bss)
3958 ps = &sdata->bss->ps;
3959 } else if (ieee80211_vif_is_mesh(&sdata->vif)) {
3960 ps = &sdata->u.mesh.ps;
3968 * dtim_count = dtim_period - (tsf / bcn_int) % dtim_period
3976 dtim_count = dtim_period - bcns_from_dtim;
3978 ps->dtim_count = dtim_count;
3990 struct ps_data *ps = &sdata->bss->ps;
3991 u8 lb_period = sdata->vif.bss_conf.s1g_long_beacon_period;
3992 u32 beacon_int = sdata->vif.bss_conf.beacon_int * 1024;
3995 if (tsf == -1ULL || !lb_period ||
3996 (sdata->vif.type != NL80211_IFTYPE_AP &&
3997 sdata->vif.type != NL80211_IFTYPE_AP_VLAN))
4005 ps->sb_count = sb_idx ? lb_period - sb_idx : 0;
4014 lockdep_assert_wiphy(local->hw.wiphy);
4016 if (WARN_ON(ctx->replace_state == IEEE80211_CHANCTX_WILL_BE_REPLACED))
4019 list_for_each_entry(link, &ctx->reserved_links, reserved_chanctx_list)
4020 if (link->reserved_radar_required)
4021 radar_detect |= BIT(link->reserved.oper.width);
4024 * An in-place reservation context should not have any assigned vifs
4027 WARN_ON(ctx->replace_state == IEEE80211_CHANCTX_REPLACES_OTHER &&
4028 !list_empty(&ctx->assigned_links));
4030 list_for_each_entry(link, &ctx->assigned_links, assigned_chanctx_list) {
4031 if (!link->radar_required)
4035 BIT(link->conf->chanreq.oper.width);
4048 for (i = 0; i < scan_req->n_channels; i++) {
4049 chan = scan_req->channels[i];
4053 * occurred. For example, if radio-level information is
4055 * typically implies a single-radio setup, in which case
4073 for_each_vif_active_link(&sdata->vif, link_conf, link_id) {
4074 conf = sdata_dereference(link_conf->chanctx_conf, sdata);
4075 if (!conf || conf->radio_idx < 0)
4078 mask |= BIT(conf->radio_idx);
4110 list_for_each_entry(ctx, &local->chanctx_list, list) {
4111 if (ctx->replace_state == IEEE80211_CHANCTX_WILL_BE_REPLACED)
4114 if (params->radio_idx >= 0 &&
4115 ctx->conf.radio_idx != params->radio_idx)
4118 params->radar_detect |=
4121 if (chandef && ctx->mode != IEEE80211_CHANCTX_EXCLUSIVE &&
4122 cfg80211_chandef_compatible(chandef, &ctx->conf.def))
4125 params->num_different_channels++;
4128 list_for_each_entry(sdata_iter, &local->interfaces, list) {
4131 wdev_iter = &sdata_iter->wdev;
4135 cfg80211_iftype_allowed(local->hw.wiphy,
4136 wdev_iter->iftype, 0, 1))
4139 if (!ieee80211_sdata_uses_radio(sdata_iter, params->radio_idx))
4142 params->iftype_num[wdev_iter->iftype]++;
4155 struct ieee80211_local *local = sdata->local;
4156 enum nl80211_iftype iftype = sdata->wdev.iftype;
4163 lockdep_assert_wiphy(local->hw.wiphy);
4166 return -EINVAL;
4169 !chandef->chan))
4170 return -EINVAL;
4173 return -EINVAL;
4175 if (sdata->vif.type == NL80211_IFTYPE_AP ||
4176 sdata->vif.type == NL80211_IFTYPE_MESH_POINT) {
4182 params.new_beacon_int = sdata->vif.bss_conf.beacon_int;
4186 if (cfg80211_iftype_allowed(local->hw.wiphy, iftype, 0, 1)) {
4188 return -EINVAL;
4204 return cfg80211_check_combinations(local->hw.wiphy, ¶ms);
4214 c->num_different_channels);
4225 lockdep_assert_wiphy(local->hw.wiphy);
4229 err = cfg80211_iter_combinations(local->hw.wiphy, ¶ms,
4242 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
4247 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION))
4250 if (!caps->s1g)
4253 memcpy(s1g_capab.capab_info, caps->cap, sizeof(caps->cap));
4254 memcpy(s1g_capab.supp_mcs_nss, caps->nss_mcs, sizeof(caps->nss_mcs));
4257 for (i = 0; i < sizeof(ifmgd->s1g_capa.capab_info); i++) {
4258 u8 mask = ifmgd->s1g_capa_mask.capab_info[i];
4261 s1g_capab.capab_info[i] |= ifmgd->s1g_capa.capab_info[i] & mask;
4264 /* then MCS and NSS set */
4265 for (i = 0; i < sizeof(ifmgd->s1g_capa.supp_mcs_nss); i++) {
4266 u8 mask = ifmgd->s1g_capa_mask.supp_mcs_nss[i];
4270 ifmgd->s1g_capa.supp_mcs_nss[i] & mask;
4300 *buf++ = qosinfo; /* U-APSD no in use */
4313 skb_queue_walk(&txqi->frags, skb) {
4315 frag_bytes += skb->len;
4319 *frame_cnt = txqi->tin.backlog_packets + frag_cnt;
4322 *byte_cnt = txqi->tin.backlog_bytes + frag_bytes;
4367 he_cap = ieee80211_get_he_iftype_cap_vif(sband, &sdata->vif);
4368 eht_cap = ieee80211_get_eht_iftype_cap_vif(sband, &sdata->vif);
4372 is_ap = sdata->vif.type == NL80211_IFTYPE_AP;
4374 n = ieee80211_eht_mcs_nss_size(&he_cap->he_cap_elem,
4375 &eht_cap->eht_cap_elem,
4378 sizeof(eht_cap->eht_cap_elem) + n +
4379 ieee80211_eht_ppe_size(eht_cap->eht_ppe_thres[0],
4380 eht_cap->eht_cap_elem.phy_cap_info);
4390 ieee80211_get_he_iftype_cap_vif(sband, &sdata->vif);
4392 ieee80211_get_eht_iftype_cap_vif(sband, &sdata->vif);
4393 bool for_ap = sdata->vif.type == NL80211_IFTYPE_AP;
4407 orig_mcs_nss_len = ieee80211_eht_mcs_nss_size(&he_cap->he_cap_elem,
4408 &eht_cap->eht_cap_elem,
4413 fixed = eht_cap->eht_cap_elem;
4415 if (conn->bw_limit < IEEE80211_CONN_BW_LIMIT_80)
4419 if (conn->bw_limit < IEEE80211_CONN_BW_LIMIT_160) {
4428 if (conn->bw_limit < IEEE80211_CONN_BW_LIMIT_320) {
4439 if (conn->bw_limit == IEEE80211_CONN_BW_LIMIT_20)
4444 ppet_len = ieee80211_eht_ppe_size(eht_cap->eht_ppe_thres[0],
4447 ie_len = 2 + 1 + sizeof(eht_cap->eht_cap_elem) + mcs_nss_len + ppet_len;
4449 return -ENOBUFS;
4452 skb_put_u8(skb, ie_len - 2);
4458 * If the (non-AP) STA became 20 MHz only, then convert from
4459 * <=80 to 20-MHz-only format, where MCSes are indicated in
4460 * the groups 0-7, 8-9, 10-11, 12-13 rather than just 0-9,
4461 * 10-11, 12-13. Thus, use 0-9 for 0-7 and 8-9.
4463 skb_put_u8(skb, eht_cap->eht_mcs_nss_supp.bw._80.rx_tx_mcs9_max_nss);
4464 skb_put_u8(skb, eht_cap->eht_mcs_nss_supp.bw._80.rx_tx_mcs9_max_nss);
4465 skb_put_u8(skb, eht_cap->eht_mcs_nss_supp.bw._80.rx_tx_mcs11_max_nss);
4466 skb_put_u8(skb, eht_cap->eht_mcs_nss_supp.bw._80.rx_tx_mcs13_max_nss);
4468 skb_put_data(skb, &eht_cap->eht_mcs_nss_supp, mcs_nss_len);
4472 skb_put_data(skb, &eht_cap->eht_ppe_thres, ppet_len);
4497 switch (chandef->width) {
4511 WARN(1, "unhandled chandef width %d\n", chandef->width);
4519 tpe->max_local[i].valid = false;
4520 memset(tpe->max_local[i].power,
4522 sizeof(tpe->max_local[i].power));
4524 tpe->max_reg_client[i].valid = false;
4525 memset(tpe->max_reg_client[i].power,
4527 sizeof(tpe->max_reg_client[i].power));
4529 tpe->psd_local[i].valid = false;
4530 memset(tpe->psd_local[i].power,
4532 sizeof(tpe->psd_local[i].power));
4534 tpe->psd_reg_client[i].valid = false;
4535 memset(tpe->psd_reg_client[i].power,
4537 sizeof(tpe->psd_reg_client[i].power));
4545 return vif->type == NL80211_IFTYPE_NAN && sdata->u.nan.started;