1 // SPDX-License-Identifier: GPL-2.0-only
3 * mac80211 configuration hooks for cfg80211
5 * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
6 * Copyright 2013-2015 Intel Mobile Communications GmbH
7 * Copyright (C) 2015-2017 Intel Deutschland GmbH
8 * Copyright (C) 2018-2024 Intel Corporation
11 #include <linux/ieee80211.h>
12 #include <linux/nl80211.h>
13 #include <linux/rtnetlink.h>
14 #include <linux/slab.h>
15 #include <net/net_namespace.h>
16 #include <linux/rcupdate.h>
17 #include <linux/fips.h>
18 #include <linux/if_ether.h>
19 #include <net/cfg80211.h>
20 #include "ieee80211_i.h"
21 #include "driver-ops.h"
26 static struct ieee80211_link_data *
27 ieee80211_link_or_deflink(struct ieee80211_sub_if_data *sdata, int link_id,
30 struct ieee80211_link_data *link;
34 * For keys, if sdata is not an MLD, we might not use
35 * the return value at all (if it's not a pairwise key),
36 * so in that case (require_valid==false) don't error.
38 if (require_valid && ieee80211_vif_is_mld(&sdata->vif))
39 return ERR_PTR(-EINVAL);
41 return &sdata->deflink;
44 link = sdata_dereference(sdata->link[link_id], sdata);
46 return ERR_PTR(-ENOLINK);
50 static void ieee80211_set_mu_mimo_follow(struct ieee80211_sub_if_data *sdata,
51 struct vif_params *params)
53 bool mu_mimo_groups = false;
54 bool mu_mimo_follow = false;
56 if (params->vht_mumimo_groups) {
59 BUILD_BUG_ON(sizeof(membership) != WLAN_MEMBERSHIP_LEN);
61 memcpy(sdata->vif.bss_conf.mu_group.membership,
62 params->vht_mumimo_groups, WLAN_MEMBERSHIP_LEN);
63 memcpy(sdata->vif.bss_conf.mu_group.position,
64 params->vht_mumimo_groups + WLAN_MEMBERSHIP_LEN,
65 WLAN_USER_POSITION_LEN);
66 ieee80211_link_info_change_notify(sdata, &sdata->deflink,
67 BSS_CHANGED_MU_GROUPS);
68 /* don't care about endianness - just check for 0 */
69 memcpy(&membership, params->vht_mumimo_groups,
71 mu_mimo_groups = membership != 0;
74 if (params->vht_mumimo_follow_addr) {
76 is_valid_ether_addr(params->vht_mumimo_follow_addr);
77 ether_addr_copy(sdata->u.mntr.mu_follow_addr,
78 params->vht_mumimo_follow_addr);
81 sdata->vif.bss_conf.mu_mimo_owner = mu_mimo_groups || mu_mimo_follow;
84 static int ieee80211_set_mon_options(struct ieee80211_sub_if_data *sdata,
85 struct vif_params *params)
87 struct ieee80211_local *local = sdata->local;
88 struct ieee80211_sub_if_data *monitor_sdata;
90 /* check flags first */
91 if (params->flags && ieee80211_sdata_running(sdata)) {
92 u32 mask = MONITOR_FLAG_COOK_FRAMES | MONITOR_FLAG_ACTIVE;
95 * Prohibit MONITOR_FLAG_COOK_FRAMES and
96 * MONITOR_FLAG_ACTIVE to be changed while the
98 * Else we would need to add a lot of cruft
99 * to update everything:
100 * cooked_mntrs, monitor and all fif_* counters
101 * reconfigure hardware
103 if ((params->flags & mask) != (sdata->u.mntr.flags & mask))
107 /* also validate MU-MIMO change */
108 monitor_sdata = wiphy_dereference(local->hw.wiphy,
109 local->monitor_sdata);
111 if (!monitor_sdata &&
112 (params->vht_mumimo_groups || params->vht_mumimo_follow_addr))
115 /* apply all changes now - no failures allowed */
118 ieee80211_set_mu_mimo_follow(monitor_sdata, params);
121 if (ieee80211_sdata_running(sdata)) {
122 ieee80211_adjust_monitor_flags(sdata, -1);
123 sdata->u.mntr.flags = params->flags;
124 ieee80211_adjust_monitor_flags(sdata, 1);
126 ieee80211_configure_filter(local);
129 * Because the interface is down, ieee80211_do_stop
130 * and ieee80211_do_open take care of "everything"
131 * mentioned in the comment above.
133 sdata->u.mntr.flags = params->flags;
140 static int ieee80211_set_ap_mbssid_options(struct ieee80211_sub_if_data *sdata,
141 struct cfg80211_mbssid_config params,
142 struct ieee80211_bss_conf *link_conf)
144 struct ieee80211_sub_if_data *tx_sdata;
146 sdata->vif.mbssid_tx_vif = NULL;
147 link_conf->bssid_index = 0;
148 link_conf->nontransmitted = false;
149 link_conf->ema_ap = false;
150 link_conf->bssid_indicator = 0;
152 if (sdata->vif.type != NL80211_IFTYPE_AP || !params.tx_wdev)
155 tx_sdata = IEEE80211_WDEV_TO_SUB_IF(params.tx_wdev);
159 if (tx_sdata == sdata) {
160 sdata->vif.mbssid_tx_vif = &sdata->vif;
162 sdata->vif.mbssid_tx_vif = &tx_sdata->vif;
163 link_conf->nontransmitted = true;
164 link_conf->bssid_index = params.index;
167 link_conf->ema_ap = true;
172 static struct wireless_dev *ieee80211_add_iface(struct wiphy *wiphy,
174 unsigned char name_assign_type,
175 enum nl80211_iftype type,
176 struct vif_params *params)
178 struct ieee80211_local *local = wiphy_priv(wiphy);
179 struct wireless_dev *wdev;
180 struct ieee80211_sub_if_data *sdata;
183 err = ieee80211_if_add(local, name, name_assign_type, &wdev, type, params);
187 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
189 if (type == NL80211_IFTYPE_MONITOR) {
190 err = ieee80211_set_mon_options(sdata, params);
192 ieee80211_if_remove(sdata);
200 static int ieee80211_del_iface(struct wiphy *wiphy, struct wireless_dev *wdev)
202 ieee80211_if_remove(IEEE80211_WDEV_TO_SUB_IF(wdev));
207 static int ieee80211_change_iface(struct wiphy *wiphy,
208 struct net_device *dev,
209 enum nl80211_iftype type,
210 struct vif_params *params)
212 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
213 struct ieee80211_local *local = sdata->local;
214 struct sta_info *sta;
217 lockdep_assert_wiphy(local->hw.wiphy);
219 ret = ieee80211_if_change_type(sdata, type);
223 if (type == NL80211_IFTYPE_AP_VLAN && params->use_4addr == 0) {
224 RCU_INIT_POINTER(sdata->u.vlan.sta, NULL);
225 ieee80211_check_fast_rx_iface(sdata);
226 } else if (type == NL80211_IFTYPE_STATION && params->use_4addr >= 0) {
227 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
229 if (params->use_4addr == ifmgd->use_4addr)
232 /* FIXME: no support for 4-addr MLO yet */
233 if (ieee80211_vif_is_mld(&sdata->vif))
236 sdata->u.mgd.use_4addr = params->use_4addr;
237 if (!ifmgd->associated)
240 sta = sta_info_get(sdata, sdata->deflink.u.mgd.bssid);
242 drv_sta_set_4addr(local, sdata, &sta->sta,
245 if (params->use_4addr)
246 ieee80211_send_4addr_nullfunc(local, sdata);
249 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) {
250 ret = ieee80211_set_mon_options(sdata, params);
258 static int ieee80211_start_p2p_device(struct wiphy *wiphy,
259 struct wireless_dev *wdev)
261 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
264 lockdep_assert_wiphy(sdata->local->hw.wiphy);
266 ret = ieee80211_check_combinations(sdata, NULL, 0, 0);
270 return ieee80211_do_open(wdev, true);
273 static void ieee80211_stop_p2p_device(struct wiphy *wiphy,
274 struct wireless_dev *wdev)
276 ieee80211_sdata_stop(IEEE80211_WDEV_TO_SUB_IF(wdev));
279 static int ieee80211_start_nan(struct wiphy *wiphy,
280 struct wireless_dev *wdev,
281 struct cfg80211_nan_conf *conf)
283 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
286 lockdep_assert_wiphy(sdata->local->hw.wiphy);
288 ret = ieee80211_check_combinations(sdata, NULL, 0, 0);
292 ret = ieee80211_do_open(wdev, true);
296 ret = drv_start_nan(sdata->local, sdata, conf);
298 ieee80211_sdata_stop(sdata);
300 sdata->u.nan.conf = *conf;
305 static void ieee80211_stop_nan(struct wiphy *wiphy,
306 struct wireless_dev *wdev)
308 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
310 drv_stop_nan(sdata->local, sdata);
311 ieee80211_sdata_stop(sdata);
314 static int ieee80211_nan_change_conf(struct wiphy *wiphy,
315 struct wireless_dev *wdev,
316 struct cfg80211_nan_conf *conf,
319 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
320 struct cfg80211_nan_conf new_conf;
323 if (sdata->vif.type != NL80211_IFTYPE_NAN)
326 if (!ieee80211_sdata_running(sdata))
329 new_conf = sdata->u.nan.conf;
331 if (changes & CFG80211_NAN_CONF_CHANGED_PREF)
332 new_conf.master_pref = conf->master_pref;
334 if (changes & CFG80211_NAN_CONF_CHANGED_BANDS)
335 new_conf.bands = conf->bands;
337 ret = drv_nan_change_conf(sdata->local, sdata, &new_conf, changes);
339 sdata->u.nan.conf = new_conf;
344 static int ieee80211_add_nan_func(struct wiphy *wiphy,
345 struct wireless_dev *wdev,
346 struct cfg80211_nan_func *nan_func)
348 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
351 if (sdata->vif.type != NL80211_IFTYPE_NAN)
354 if (!ieee80211_sdata_running(sdata))
357 spin_lock_bh(&sdata->u.nan.func_lock);
359 ret = idr_alloc(&sdata->u.nan.function_inst_ids,
360 nan_func, 1, sdata->local->hw.max_nan_de_entries + 1,
362 spin_unlock_bh(&sdata->u.nan.func_lock);
367 nan_func->instance_id = ret;
369 WARN_ON(nan_func->instance_id == 0);
371 ret = drv_add_nan_func(sdata->local, sdata, nan_func);
373 spin_lock_bh(&sdata->u.nan.func_lock);
374 idr_remove(&sdata->u.nan.function_inst_ids,
375 nan_func->instance_id);
376 spin_unlock_bh(&sdata->u.nan.func_lock);
382 static struct cfg80211_nan_func *
383 ieee80211_find_nan_func_by_cookie(struct ieee80211_sub_if_data *sdata,
386 struct cfg80211_nan_func *func;
389 lockdep_assert_held(&sdata->u.nan.func_lock);
391 idr_for_each_entry(&sdata->u.nan.function_inst_ids, func, id) {
392 if (func->cookie == cookie)
399 static void ieee80211_del_nan_func(struct wiphy *wiphy,
400 struct wireless_dev *wdev, u64 cookie)
402 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
403 struct cfg80211_nan_func *func;
406 if (sdata->vif.type != NL80211_IFTYPE_NAN ||
407 !ieee80211_sdata_running(sdata))
410 spin_lock_bh(&sdata->u.nan.func_lock);
412 func = ieee80211_find_nan_func_by_cookie(sdata, cookie);
414 instance_id = func->instance_id;
416 spin_unlock_bh(&sdata->u.nan.func_lock);
419 drv_del_nan_func(sdata->local, sdata, instance_id);
422 static int ieee80211_set_noack_map(struct wiphy *wiphy,
423 struct net_device *dev,
426 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
428 sdata->noack_map = noack_map;
430 ieee80211_check_fast_xmit_iface(sdata);
435 static int ieee80211_set_tx(struct ieee80211_sub_if_data *sdata,
436 const u8 *mac_addr, u8 key_idx)
438 struct ieee80211_local *local = sdata->local;
439 struct ieee80211_key *key;
440 struct sta_info *sta;
443 if (!wiphy_ext_feature_isset(local->hw.wiphy,
444 NL80211_EXT_FEATURE_EXT_KEY_ID))
447 sta = sta_info_get_bss(sdata, mac_addr);
452 if (sta->ptk_idx == key_idx)
455 key = wiphy_dereference(local->hw.wiphy, sta->ptk[key_idx]);
457 if (key && key->conf.flags & IEEE80211_KEY_FLAG_NO_AUTO_TX)
458 ret = ieee80211_set_tx_key(key);
463 static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
464 int link_id, u8 key_idx, bool pairwise,
465 const u8 *mac_addr, struct key_params *params)
467 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
468 struct ieee80211_link_data *link =
469 ieee80211_link_or_deflink(sdata, link_id, false);
470 struct ieee80211_local *local = sdata->local;
471 struct sta_info *sta = NULL;
472 struct ieee80211_key *key;
475 lockdep_assert_wiphy(local->hw.wiphy);
477 if (!ieee80211_sdata_running(sdata))
481 return PTR_ERR(link);
483 if (pairwise && params->mode == NL80211_KEY_SET_TX)
484 return ieee80211_set_tx(sdata, mac_addr, key_idx);
486 /* reject WEP and TKIP keys if WEP failed to initialize */
487 switch (params->cipher) {
488 case WLAN_CIPHER_SUITE_WEP40:
489 case WLAN_CIPHER_SUITE_TKIP:
490 case WLAN_CIPHER_SUITE_WEP104:
493 if (WARN_ON_ONCE(fips_enabled))
500 key = ieee80211_key_alloc(params->cipher, key_idx, params->key_len,
501 params->key, params->seq_len, params->seq);
505 key->conf.link_id = link_id;
508 key->conf.flags |= IEEE80211_KEY_FLAG_PAIRWISE;
510 if (params->mode == NL80211_KEY_NO_TX)
511 key->conf.flags |= IEEE80211_KEY_FLAG_NO_AUTO_TX;
514 sta = sta_info_get_bss(sdata, mac_addr);
516 * The ASSOC test makes sure the driver is ready to
517 * receive the key. When wpa_supplicant has roamed
518 * using FT, it attempts to set the key before
519 * association has completed, this rejects that attempt
520 * so it will set the key again after association.
522 * TODO: accept the key if we have a station entry and
523 * add it to the device after the station.
525 if (!sta || !test_sta_flag(sta, WLAN_STA_ASSOC)) {
526 ieee80211_key_free_unused(key);
531 switch (sdata->vif.type) {
532 case NL80211_IFTYPE_STATION:
533 if (sdata->u.mgd.mfp != IEEE80211_MFP_DISABLED)
534 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
536 case NL80211_IFTYPE_AP:
537 case NL80211_IFTYPE_AP_VLAN:
538 /* Keys without a station are used for TX only */
539 if (sta && test_sta_flag(sta, WLAN_STA_MFP))
540 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
542 case NL80211_IFTYPE_ADHOC:
545 case NL80211_IFTYPE_MESH_POINT:
546 #ifdef CONFIG_MAC80211_MESH
547 if (sdata->u.mesh.security != IEEE80211_MESH_SEC_NONE)
548 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
551 case NL80211_IFTYPE_WDS:
552 case NL80211_IFTYPE_MONITOR:
553 case NL80211_IFTYPE_P2P_DEVICE:
554 case NL80211_IFTYPE_NAN:
555 case NL80211_IFTYPE_UNSPECIFIED:
556 case NUM_NL80211_IFTYPES:
557 case NL80211_IFTYPE_P2P_CLIENT:
558 case NL80211_IFTYPE_P2P_GO:
559 case NL80211_IFTYPE_OCB:
560 /* shouldn't happen */
565 err = ieee80211_key_link(key, link, sta);
566 /* KRACK protection, shouldn't happen but just silently accept key */
567 if (err == -EALREADY)
573 static struct ieee80211_key *
574 ieee80211_lookup_key(struct ieee80211_sub_if_data *sdata, int link_id,
575 u8 key_idx, bool pairwise, const u8 *mac_addr)
577 struct ieee80211_local *local __maybe_unused = sdata->local;
578 struct ieee80211_link_data *link = &sdata->deflink;
579 struct ieee80211_key *key;
582 link = sdata_dereference(sdata->link[link_id], sdata);
588 struct sta_info *sta;
589 struct link_sta_info *link_sta;
591 sta = sta_info_get_bss(sdata, mac_addr);
596 link_sta = rcu_dereference_check(sta->link[link_id],
597 lockdep_is_held(&local->hw.wiphy->mtx));
601 link_sta = &sta->deflink;
604 if (pairwise && key_idx < NUM_DEFAULT_KEYS)
605 return wiphy_dereference(local->hw.wiphy,
609 key_idx < NUM_DEFAULT_KEYS +
610 NUM_DEFAULT_MGMT_KEYS +
611 NUM_DEFAULT_BEACON_KEYS)
612 return wiphy_dereference(local->hw.wiphy,
613 link_sta->gtk[key_idx]);
618 if (pairwise && key_idx < NUM_DEFAULT_KEYS)
619 return wiphy_dereference(local->hw.wiphy, sdata->keys[key_idx]);
621 key = wiphy_dereference(local->hw.wiphy, link->gtk[key_idx]);
625 /* or maybe it was a WEP key */
626 if (key_idx < NUM_DEFAULT_KEYS)
627 return wiphy_dereference(local->hw.wiphy, sdata->keys[key_idx]);
632 static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
633 int link_id, u8 key_idx, bool pairwise,
636 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
637 struct ieee80211_local *local = sdata->local;
638 struct ieee80211_key *key;
640 lockdep_assert_wiphy(local->hw.wiphy);
642 key = ieee80211_lookup_key(sdata, link_id, key_idx, pairwise, mac_addr);
646 ieee80211_key_free(key, sdata->vif.type == NL80211_IFTYPE_STATION);
651 static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
652 int link_id, u8 key_idx, bool pairwise,
653 const u8 *mac_addr, void *cookie,
654 void (*callback)(void *cookie,
655 struct key_params *params))
657 struct ieee80211_sub_if_data *sdata;
659 struct key_params params;
660 struct ieee80211_key *key;
665 struct ieee80211_key_seq kseq = {};
667 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
671 key = ieee80211_lookup_key(sdata, link_id, key_idx, pairwise, mac_addr);
675 memset(¶ms, 0, sizeof(params));
677 params.cipher = key->conf.cipher;
679 switch (key->conf.cipher) {
680 case WLAN_CIPHER_SUITE_TKIP:
681 pn64 = atomic64_read(&key->conf.tx_pn);
682 iv32 = TKIP_PN_TO_IV32(pn64);
683 iv16 = TKIP_PN_TO_IV16(pn64);
685 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE &&
686 !(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
687 drv_get_key_seq(sdata->local, key, &kseq);
688 iv32 = kseq.tkip.iv32;
689 iv16 = kseq.tkip.iv16;
692 seq[0] = iv16 & 0xff;
693 seq[1] = (iv16 >> 8) & 0xff;
694 seq[2] = iv32 & 0xff;
695 seq[3] = (iv32 >> 8) & 0xff;
696 seq[4] = (iv32 >> 16) & 0xff;
697 seq[5] = (iv32 >> 24) & 0xff;
701 case WLAN_CIPHER_SUITE_CCMP:
702 case WLAN_CIPHER_SUITE_CCMP_256:
703 case WLAN_CIPHER_SUITE_AES_CMAC:
704 case WLAN_CIPHER_SUITE_BIP_CMAC_256:
705 BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
706 offsetof(typeof(kseq), aes_cmac));
708 case WLAN_CIPHER_SUITE_BIP_GMAC_128:
709 case WLAN_CIPHER_SUITE_BIP_GMAC_256:
710 BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
711 offsetof(typeof(kseq), aes_gmac));
713 case WLAN_CIPHER_SUITE_GCMP:
714 case WLAN_CIPHER_SUITE_GCMP_256:
715 BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
716 offsetof(typeof(kseq), gcmp));
718 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE &&
719 !(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
720 drv_get_key_seq(sdata->local, key, &kseq);
721 memcpy(seq, kseq.ccmp.pn, 6);
723 pn64 = atomic64_read(&key->conf.tx_pn);
735 if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
737 if (WARN_ON(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV))
739 drv_get_key_seq(sdata->local, key, &kseq);
740 params.seq = kseq.hw.seq;
741 params.seq_len = kseq.hw.seq_len;
745 params.key = key->conf.key;
746 params.key_len = key->conf.keylen;
748 callback(cookie, ¶ms);
756 static int ieee80211_config_default_key(struct wiphy *wiphy,
757 struct net_device *dev,
758 int link_id, u8 key_idx, bool uni,
761 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
762 struct ieee80211_link_data *link =
763 ieee80211_link_or_deflink(sdata, link_id, false);
766 return PTR_ERR(link);
768 ieee80211_set_default_key(link, key_idx, uni, multi);
773 static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy,
774 struct net_device *dev,
775 int link_id, u8 key_idx)
777 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
778 struct ieee80211_link_data *link =
779 ieee80211_link_or_deflink(sdata, link_id, true);
782 return PTR_ERR(link);
784 ieee80211_set_default_mgmt_key(link, key_idx);
789 static int ieee80211_config_default_beacon_key(struct wiphy *wiphy,
790 struct net_device *dev,
791 int link_id, u8 key_idx)
793 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
794 struct ieee80211_link_data *link =
795 ieee80211_link_or_deflink(sdata, link_id, true);
798 return PTR_ERR(link);
800 ieee80211_set_default_beacon_key(link, key_idx);
805 void sta_set_rate_info_tx(struct sta_info *sta,
806 const struct ieee80211_tx_rate *rate,
807 struct rate_info *rinfo)
810 if (rate->flags & IEEE80211_TX_RC_MCS) {
811 rinfo->flags |= RATE_INFO_FLAGS_MCS;
812 rinfo->mcs = rate->idx;
813 } else if (rate->flags & IEEE80211_TX_RC_VHT_MCS) {
814 rinfo->flags |= RATE_INFO_FLAGS_VHT_MCS;
815 rinfo->mcs = ieee80211_rate_get_vht_mcs(rate);
816 rinfo->nss = ieee80211_rate_get_vht_nss(rate);
818 struct ieee80211_supported_band *sband;
820 sband = ieee80211_get_sband(sta->sdata);
821 WARN_ON_ONCE(sband && !sband->bitrates);
822 if (sband && sband->bitrates)
823 rinfo->legacy = sband->bitrates[rate->idx].bitrate;
825 if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
826 rinfo->bw = RATE_INFO_BW_40;
827 else if (rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH)
828 rinfo->bw = RATE_INFO_BW_80;
829 else if (rate->flags & IEEE80211_TX_RC_160_MHZ_WIDTH)
830 rinfo->bw = RATE_INFO_BW_160;
832 rinfo->bw = RATE_INFO_BW_20;
833 if (rate->flags & IEEE80211_TX_RC_SHORT_GI)
834 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI;
837 static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev,
838 int idx, u8 *mac, struct station_info *sinfo)
840 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
841 struct ieee80211_local *local = sdata->local;
842 struct sta_info *sta;
845 lockdep_assert_wiphy(local->hw.wiphy);
847 sta = sta_info_get_by_idx(sdata, idx);
850 memcpy(mac, sta->sta.addr, ETH_ALEN);
851 sta_set_sinfo(sta, sinfo, true);
857 static int ieee80211_dump_survey(struct wiphy *wiphy, struct net_device *dev,
858 int idx, struct survey_info *survey)
860 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
862 return drv_get_survey(local, idx, survey);
865 static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev,
866 const u8 *mac, struct station_info *sinfo)
868 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
869 struct ieee80211_local *local = sdata->local;
870 struct sta_info *sta;
873 lockdep_assert_wiphy(local->hw.wiphy);
875 sta = sta_info_get_bss(sdata, mac);
878 sta_set_sinfo(sta, sinfo, true);
884 static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
885 struct cfg80211_chan_def *chandef)
887 struct ieee80211_local *local = wiphy_priv(wiphy);
888 struct ieee80211_sub_if_data *sdata;
889 struct ieee80211_chan_req chanreq = { .oper = *chandef };
892 lockdep_assert_wiphy(local->hw.wiphy);
894 if (cfg80211_chandef_identical(&local->monitor_chanreq.oper,
898 sdata = wiphy_dereference(local->hw.wiphy,
899 local->monitor_sdata);
903 if (cfg80211_chandef_identical(&sdata->vif.bss_conf.chanreq.oper,
907 ieee80211_link_release_channel(&sdata->deflink);
908 ret = ieee80211_link_use_channel(&sdata->deflink, &chanreq,
909 IEEE80211_CHANCTX_EXCLUSIVE);
913 local->monitor_chanreq = chanreq;
918 ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata,
919 const u8 *resp, size_t resp_len,
920 const struct ieee80211_csa_settings *csa,
921 const struct ieee80211_color_change_settings *cca,
922 struct ieee80211_link_data *link)
924 struct probe_resp *new, *old;
926 if (!resp || !resp_len)
929 old = sdata_dereference(link->u.ap.probe_resp, sdata);
931 new = kzalloc(sizeof(struct probe_resp) + resp_len, GFP_KERNEL);
936 memcpy(new->data, resp, resp_len);
939 memcpy(new->cntdwn_counter_offsets, csa->counter_offsets_presp,
940 csa->n_counter_offsets_presp *
941 sizeof(new->cntdwn_counter_offsets[0]));
943 new->cntdwn_counter_offsets[0] = cca->counter_offset_presp;
945 rcu_assign_pointer(link->u.ap.probe_resp, new);
947 kfree_rcu(old, rcu_head);
952 static int ieee80211_set_fils_discovery(struct ieee80211_sub_if_data *sdata,
953 struct cfg80211_fils_discovery *params,
954 struct ieee80211_link_data *link,
955 struct ieee80211_bss_conf *link_conf,
958 struct fils_discovery_data *new, *old = NULL;
959 struct ieee80211_fils_discovery *fd;
964 fd = &link_conf->fils_discovery;
965 fd->min_interval = params->min_interval;
966 fd->max_interval = params->max_interval;
968 old = sdata_dereference(link->u.ap.fils_discovery, sdata);
970 kfree_rcu(old, rcu_head);
972 if (params->tmpl && params->tmpl_len) {
973 new = kzalloc(sizeof(*new) + params->tmpl_len, GFP_KERNEL);
976 new->len = params->tmpl_len;
977 memcpy(new->data, params->tmpl, params->tmpl_len);
978 rcu_assign_pointer(link->u.ap.fils_discovery, new);
980 RCU_INIT_POINTER(link->u.ap.fils_discovery, NULL);
983 *changed |= BSS_CHANGED_FILS_DISCOVERY;
988 ieee80211_set_unsol_bcast_probe_resp(struct ieee80211_sub_if_data *sdata,
989 struct cfg80211_unsol_bcast_probe_resp *params,
990 struct ieee80211_link_data *link,
991 struct ieee80211_bss_conf *link_conf,
994 struct unsol_bcast_probe_resp_data *new, *old = NULL;
999 link_conf->unsol_bcast_probe_resp_interval = params->interval;
1001 old = sdata_dereference(link->u.ap.unsol_bcast_probe_resp, sdata);
1003 kfree_rcu(old, rcu_head);
1005 if (params->tmpl && params->tmpl_len) {
1006 new = kzalloc(sizeof(*new) + params->tmpl_len, GFP_KERNEL);
1009 new->len = params->tmpl_len;
1010 memcpy(new->data, params->tmpl, params->tmpl_len);
1011 rcu_assign_pointer(link->u.ap.unsol_bcast_probe_resp, new);
1013 RCU_INIT_POINTER(link->u.ap.unsol_bcast_probe_resp, NULL);
1016 *changed |= BSS_CHANGED_UNSOL_BCAST_PROBE_RESP;
1020 static int ieee80211_set_ftm_responder_params(
1021 struct ieee80211_sub_if_data *sdata,
1022 const u8 *lci, size_t lci_len,
1023 const u8 *civicloc, size_t civicloc_len,
1024 struct ieee80211_bss_conf *link_conf)
1026 struct ieee80211_ftm_responder_params *new, *old;
1030 if (!lci_len && !civicloc_len)
1033 old = link_conf->ftmr_params;
1034 len = lci_len + civicloc_len;
1036 new = kzalloc(sizeof(*new) + len, GFP_KERNEL);
1040 pos = (u8 *)(new + 1);
1042 new->lci_len = lci_len;
1044 memcpy(pos, lci, lci_len);
1049 new->civicloc_len = civicloc_len;
1050 new->civicloc = pos;
1051 memcpy(pos, civicloc, civicloc_len);
1052 pos += civicloc_len;
1055 link_conf->ftmr_params = new;
1062 ieee80211_copy_mbssid_beacon(u8 *pos, struct cfg80211_mbssid_elems *dst,
1063 struct cfg80211_mbssid_elems *src)
1067 for (i = 0; i < src->cnt; i++) {
1068 memcpy(pos + offset, src->elem[i].data, src->elem[i].len);
1069 dst->elem[i].len = src->elem[i].len;
1070 dst->elem[i].data = pos + offset;
1071 offset += dst->elem[i].len;
1073 dst->cnt = src->cnt;
1079 ieee80211_copy_rnr_beacon(u8 *pos, struct cfg80211_rnr_elems *dst,
1080 struct cfg80211_rnr_elems *src)
1084 for (i = 0; i < src->cnt; i++) {
1085 memcpy(pos + offset, src->elem[i].data, src->elem[i].len);
1086 dst->elem[i].len = src->elem[i].len;
1087 dst->elem[i].data = pos + offset;
1088 offset += dst->elem[i].len;
1090 dst->cnt = src->cnt;
1096 ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
1097 struct ieee80211_link_data *link,
1098 struct cfg80211_beacon_data *params,
1099 const struct ieee80211_csa_settings *csa,
1100 const struct ieee80211_color_change_settings *cca,
1103 struct cfg80211_mbssid_elems *mbssid = NULL;
1104 struct cfg80211_rnr_elems *rnr = NULL;
1105 struct beacon_data *new, *old;
1106 int new_head_len, new_tail_len;
1108 u64 _changed = BSS_CHANGED_BEACON;
1109 struct ieee80211_bss_conf *link_conf = link->conf;
1111 old = sdata_dereference(link->u.ap.beacon, sdata);
1113 /* Need to have a beacon head if we don't have one yet */
1114 if (!params->head && !old)
1117 /* new or old head? */
1119 new_head_len = params->head_len;
1121 new_head_len = old->head_len;
1123 /* new or old tail? */
1124 if (params->tail || !old)
1125 /* params->tail_len will be zero for !params->tail */
1126 new_tail_len = params->tail_len;
1128 new_tail_len = old->tail_len;
1130 size = sizeof(*new) + new_head_len + new_tail_len;
1132 /* new or old multiple BSSID elements? */
1133 if (params->mbssid_ies) {
1134 mbssid = params->mbssid_ies;
1135 size += struct_size(new->mbssid_ies, elem, mbssid->cnt);
1136 if (params->rnr_ies) {
1137 rnr = params->rnr_ies;
1138 size += struct_size(new->rnr_ies, elem, rnr->cnt);
1140 size += ieee80211_get_mbssid_beacon_len(mbssid, rnr,
1142 } else if (old && old->mbssid_ies) {
1143 mbssid = old->mbssid_ies;
1144 size += struct_size(new->mbssid_ies, elem, mbssid->cnt);
1145 if (old && old->rnr_ies) {
1147 size += struct_size(new->rnr_ies, elem, rnr->cnt);
1149 size += ieee80211_get_mbssid_beacon_len(mbssid, rnr,
1153 new = kzalloc(size, GFP_KERNEL);
1157 /* start filling the new info now */
1160 * pointers go into the block we allocated,
1161 * memory is | beacon_data | head | tail | mbssid_ies | rnr_ies
1163 new->head = ((u8 *) new) + sizeof(*new);
1164 new->tail = new->head + new_head_len;
1165 new->head_len = new_head_len;
1166 new->tail_len = new_tail_len;
1167 /* copy in optional mbssid_ies */
1169 u8 *pos = new->tail + new->tail_len;
1171 new->mbssid_ies = (void *)pos;
1172 pos += struct_size(new->mbssid_ies, elem, mbssid->cnt);
1173 pos += ieee80211_copy_mbssid_beacon(pos, new->mbssid_ies,
1176 new->rnr_ies = (void *)pos;
1177 pos += struct_size(new->rnr_ies, elem, rnr->cnt);
1178 ieee80211_copy_rnr_beacon(pos, new->rnr_ies, rnr);
1180 /* update bssid_indicator */
1181 link_conf->bssid_indicator =
1182 ilog2(__roundup_pow_of_two(mbssid->cnt + 1));
1186 new->cntdwn_current_counter = csa->count;
1187 memcpy(new->cntdwn_counter_offsets, csa->counter_offsets_beacon,
1188 csa->n_counter_offsets_beacon *
1189 sizeof(new->cntdwn_counter_offsets[0]));
1191 new->cntdwn_current_counter = cca->count;
1192 new->cntdwn_counter_offsets[0] = cca->counter_offset_beacon;
1197 memcpy(new->head, params->head, new_head_len);
1199 memcpy(new->head, old->head, new_head_len);
1201 /* copy in optional tail */
1203 memcpy(new->tail, params->tail, new_tail_len);
1206 memcpy(new->tail, old->tail, new_tail_len);
1208 err = ieee80211_set_probe_resp(sdata, params->probe_resp,
1209 params->probe_resp_len, csa, cca, link);
1215 _changed |= BSS_CHANGED_AP_PROBE_RESP;
1217 if (params->ftm_responder != -1) {
1218 link_conf->ftm_responder = params->ftm_responder;
1219 err = ieee80211_set_ftm_responder_params(sdata,
1223 params->civicloc_len,
1231 _changed |= BSS_CHANGED_FTM_RESPONDER;
1234 rcu_assign_pointer(link->u.ap.beacon, new);
1235 sdata->u.ap.active = true;
1238 kfree_rcu(old, rcu_head);
1240 *changed |= _changed;
1244 static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
1245 struct cfg80211_ap_settings *params)
1247 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1248 struct ieee80211_local *local = sdata->local;
1249 struct beacon_data *old;
1250 struct ieee80211_sub_if_data *vlan;
1251 u64 changed = BSS_CHANGED_BEACON_INT |
1252 BSS_CHANGED_BEACON_ENABLED |
1253 BSS_CHANGED_BEACON |
1254 BSS_CHANGED_P2P_PS |
1255 BSS_CHANGED_TXPOWER |
1258 int prev_beacon_int;
1259 unsigned int link_id = params->beacon.link_id;
1260 struct ieee80211_link_data *link;
1261 struct ieee80211_bss_conf *link_conf;
1262 struct ieee80211_chan_req chanreq = { .oper = params->chandef };
1264 lockdep_assert_wiphy(local->hw.wiphy);
1266 link = sdata_dereference(sdata->link[link_id], sdata);
1270 link_conf = link->conf;
1272 old = sdata_dereference(link->u.ap.beacon, sdata);
1276 if (params->smps_mode != NL80211_SMPS_OFF)
1279 link->smps_mode = IEEE80211_SMPS_OFF;
1281 link->needed_rx_chains = sdata->local->rx_chains;
1283 prev_beacon_int = link_conf->beacon_int;
1284 link_conf->beacon_int = params->beacon_interval;
1287 link_conf->ht_ldpc =
1288 params->ht_cap->cap_info &
1289 cpu_to_le16(IEEE80211_HT_CAP_LDPC_CODING);
1291 if (params->vht_cap) {
1292 link_conf->vht_ldpc =
1293 params->vht_cap->vht_cap_info &
1294 cpu_to_le32(IEEE80211_VHT_CAP_RXLDPC);
1295 link_conf->vht_su_beamformer =
1296 params->vht_cap->vht_cap_info &
1297 cpu_to_le32(IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE);
1298 link_conf->vht_su_beamformee =
1299 params->vht_cap->vht_cap_info &
1300 cpu_to_le32(IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE);
1301 link_conf->vht_mu_beamformer =
1302 params->vht_cap->vht_cap_info &
1303 cpu_to_le32(IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE);
1304 link_conf->vht_mu_beamformee =
1305 params->vht_cap->vht_cap_info &
1306 cpu_to_le32(IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE);
1309 if (params->he_cap && params->he_oper) {
1310 link_conf->he_support = true;
1311 link_conf->htc_trig_based_pkt_ext =
1312 le32_get_bits(params->he_oper->he_oper_params,
1313 IEEE80211_HE_OPERATION_DFLT_PE_DURATION_MASK);
1314 link_conf->frame_time_rts_th =
1315 le32_get_bits(params->he_oper->he_oper_params,
1316 IEEE80211_HE_OPERATION_RTS_THRESHOLD_MASK);
1317 changed |= BSS_CHANGED_HE_OBSS_PD;
1319 if (params->beacon.he_bss_color.enabled)
1320 changed |= BSS_CHANGED_HE_BSS_COLOR;
1323 if (params->he_cap) {
1324 link_conf->he_ldpc =
1325 params->he_cap->phy_cap_info[1] &
1326 IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD;
1327 link_conf->he_su_beamformer =
1328 params->he_cap->phy_cap_info[3] &
1329 IEEE80211_HE_PHY_CAP3_SU_BEAMFORMER;
1330 link_conf->he_su_beamformee =
1331 params->he_cap->phy_cap_info[4] &
1332 IEEE80211_HE_PHY_CAP4_SU_BEAMFORMEE;
1333 link_conf->he_mu_beamformer =
1334 params->he_cap->phy_cap_info[4] &
1335 IEEE80211_HE_PHY_CAP4_MU_BEAMFORMER;
1336 link_conf->he_full_ul_mumimo =
1337 params->he_cap->phy_cap_info[2] &
1338 IEEE80211_HE_PHY_CAP2_UL_MU_FULL_MU_MIMO;
1341 if (params->eht_cap) {
1342 if (!link_conf->he_support)
1345 link_conf->eht_support = true;
1347 link_conf->eht_su_beamformer =
1348 params->eht_cap->fixed.phy_cap_info[0] &
1349 IEEE80211_EHT_PHY_CAP0_SU_BEAMFORMER;
1350 link_conf->eht_su_beamformee =
1351 params->eht_cap->fixed.phy_cap_info[0] &
1352 IEEE80211_EHT_PHY_CAP0_SU_BEAMFORMEE;
1353 link_conf->eht_mu_beamformer =
1354 params->eht_cap->fixed.phy_cap_info[7] &
1355 (IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_80MHZ |
1356 IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_160MHZ |
1357 IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_320MHZ);
1359 link_conf->eht_su_beamformer = false;
1360 link_conf->eht_su_beamformee = false;
1361 link_conf->eht_mu_beamformer = false;
1364 if (sdata->vif.type == NL80211_IFTYPE_AP &&
1365 params->mbssid_config.tx_wdev) {
1366 err = ieee80211_set_ap_mbssid_options(sdata,
1367 params->mbssid_config,
1373 err = ieee80211_link_use_channel(link, &chanreq,
1374 IEEE80211_CHANCTX_SHARED);
1376 ieee80211_link_copy_chanctx_to_vlans(link, false);
1378 link_conf->beacon_int = prev_beacon_int;
1383 * Apply control port protocol, this allows us to
1384 * not encrypt dynamic WEP control frames.
1386 sdata->control_port_protocol = params->crypto.control_port_ethertype;
1387 sdata->control_port_no_encrypt = params->crypto.control_port_no_encrypt;
1388 sdata->control_port_over_nl80211 =
1389 params->crypto.control_port_over_nl80211;
1390 sdata->control_port_no_preauth =
1391 params->crypto.control_port_no_preauth;
1393 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) {
1394 vlan->control_port_protocol =
1395 params->crypto.control_port_ethertype;
1396 vlan->control_port_no_encrypt =
1397 params->crypto.control_port_no_encrypt;
1398 vlan->control_port_over_nl80211 =
1399 params->crypto.control_port_over_nl80211;
1400 vlan->control_port_no_preauth =
1401 params->crypto.control_port_no_preauth;
1404 link_conf->dtim_period = params->dtim_period;
1405 link_conf->enable_beacon = true;
1406 link_conf->allow_p2p_go_ps = sdata->vif.p2p;
1407 link_conf->twt_responder = params->twt_responder;
1408 link_conf->he_obss_pd = params->he_obss_pd;
1409 link_conf->he_bss_color = params->beacon.he_bss_color;
1410 sdata->vif.cfg.s1g = params->chandef.chan->band ==
1413 sdata->vif.cfg.ssid_len = params->ssid_len;
1414 if (params->ssid_len)
1415 memcpy(sdata->vif.cfg.ssid, params->ssid,
1417 link_conf->hidden_ssid =
1418 (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE);
1420 memset(&link_conf->p2p_noa_attr, 0,
1421 sizeof(link_conf->p2p_noa_attr));
1422 link_conf->p2p_noa_attr.oppps_ctwindow =
1423 params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
1424 if (params->p2p_opp_ps)
1425 link_conf->p2p_noa_attr.oppps_ctwindow |=
1426 IEEE80211_P2P_OPPPS_ENABLE_BIT;
1428 sdata->beacon_rate_set = false;
1429 if (wiphy_ext_feature_isset(local->hw.wiphy,
1430 NL80211_EXT_FEATURE_BEACON_RATE_LEGACY)) {
1431 for (i = 0; i < NUM_NL80211_BANDS; i++) {
1432 sdata->beacon_rateidx_mask[i] =
1433 params->beacon_rate.control[i].legacy;
1434 if (sdata->beacon_rateidx_mask[i])
1435 sdata->beacon_rate_set = true;
1439 if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL))
1440 link_conf->beacon_tx_rate = params->beacon_rate;
1442 err = ieee80211_assign_beacon(sdata, link, ¶ms->beacon, NULL, NULL,
1447 err = ieee80211_set_fils_discovery(sdata, ¶ms->fils_discovery,
1448 link, link_conf, &changed);
1452 err = ieee80211_set_unsol_bcast_probe_resp(sdata,
1453 ¶ms->unsol_bcast_probe_resp,
1454 link, link_conf, &changed);
1458 err = drv_start_ap(sdata->local, sdata, link_conf);
1460 old = sdata_dereference(link->u.ap.beacon, sdata);
1463 kfree_rcu(old, rcu_head);
1464 RCU_INIT_POINTER(link->u.ap.beacon, NULL);
1465 sdata->u.ap.active = false;
1469 ieee80211_recalc_dtim(local, sdata);
1470 ieee80211_vif_cfg_change_notify(sdata, BSS_CHANGED_SSID);
1471 ieee80211_link_info_change_notify(sdata, link, changed);
1473 netif_carrier_on(dev);
1474 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
1475 netif_carrier_on(vlan->dev);
1480 ieee80211_link_release_channel(link);
1485 static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev,
1486 struct cfg80211_ap_update *params)
1489 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1490 struct ieee80211_link_data *link;
1491 struct cfg80211_beacon_data *beacon = ¶ms->beacon;
1492 struct beacon_data *old;
1494 struct ieee80211_bss_conf *link_conf;
1497 lockdep_assert_wiphy(wiphy);
1499 link = sdata_dereference(sdata->link[beacon->link_id], sdata);
1503 link_conf = link->conf;
1505 /* don't allow changing the beacon while a countdown is in place - offset
1506 * of channel switch counter may change
1508 if (link_conf->csa_active || link_conf->color_change_active)
1511 old = sdata_dereference(link->u.ap.beacon, sdata);
1515 err = ieee80211_assign_beacon(sdata, link, beacon, NULL, NULL,
1520 err = ieee80211_set_fils_discovery(sdata, ¶ms->fils_discovery,
1521 link, link_conf, &changed);
1525 err = ieee80211_set_unsol_bcast_probe_resp(sdata,
1526 ¶ms->unsol_bcast_probe_resp,
1527 link, link_conf, &changed);
1531 if (beacon->he_bss_color_valid &&
1532 beacon->he_bss_color.enabled != link_conf->he_bss_color.enabled) {
1533 link_conf->he_bss_color.enabled = beacon->he_bss_color.enabled;
1534 changed |= BSS_CHANGED_HE_BSS_COLOR;
1537 ieee80211_link_info_change_notify(sdata, link, changed);
1541 static void ieee80211_free_next_beacon(struct ieee80211_link_data *link)
1543 if (!link->u.ap.next_beacon)
1546 kfree(link->u.ap.next_beacon->mbssid_ies);
1547 kfree(link->u.ap.next_beacon->rnr_ies);
1548 kfree(link->u.ap.next_beacon);
1549 link->u.ap.next_beacon = NULL;
1552 static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev,
1553 unsigned int link_id)
1555 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1556 struct ieee80211_sub_if_data *vlan;
1557 struct ieee80211_local *local = sdata->local;
1558 struct beacon_data *old_beacon;
1559 struct probe_resp *old_probe_resp;
1560 struct fils_discovery_data *old_fils_discovery;
1561 struct unsol_bcast_probe_resp_data *old_unsol_bcast_probe_resp;
1562 struct cfg80211_chan_def chandef;
1563 struct ieee80211_link_data *link =
1564 sdata_dereference(sdata->link[link_id], sdata);
1565 struct ieee80211_bss_conf *link_conf = link->conf;
1568 lockdep_assert_wiphy(local->hw.wiphy);
1570 old_beacon = sdata_dereference(link->u.ap.beacon, sdata);
1573 old_probe_resp = sdata_dereference(link->u.ap.probe_resp,
1575 old_fils_discovery = sdata_dereference(link->u.ap.fils_discovery,
1577 old_unsol_bcast_probe_resp =
1578 sdata_dereference(link->u.ap.unsol_bcast_probe_resp,
1581 /* abort any running channel switch or color change */
1582 link_conf->csa_active = false;
1583 link_conf->color_change_active = false;
1584 if (link->csa_block_tx) {
1585 ieee80211_wake_vif_queues(local, sdata,
1586 IEEE80211_QUEUE_STOP_REASON_CSA);
1587 link->csa_block_tx = false;
1590 ieee80211_free_next_beacon(link);
1592 /* turn off carrier for this interface and dependent VLANs */
1593 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
1594 netif_carrier_off(vlan->dev);
1595 netif_carrier_off(dev);
1597 /* remove beacon and probe response */
1598 sdata->u.ap.active = false;
1599 RCU_INIT_POINTER(link->u.ap.beacon, NULL);
1600 RCU_INIT_POINTER(link->u.ap.probe_resp, NULL);
1601 RCU_INIT_POINTER(link->u.ap.fils_discovery, NULL);
1602 RCU_INIT_POINTER(link->u.ap.unsol_bcast_probe_resp, NULL);
1603 kfree_rcu(old_beacon, rcu_head);
1605 kfree_rcu(old_probe_resp, rcu_head);
1606 if (old_fils_discovery)
1607 kfree_rcu(old_fils_discovery, rcu_head);
1608 if (old_unsol_bcast_probe_resp)
1609 kfree_rcu(old_unsol_bcast_probe_resp, rcu_head);
1611 kfree(link_conf->ftmr_params);
1612 link_conf->ftmr_params = NULL;
1614 sdata->vif.mbssid_tx_vif = NULL;
1615 link_conf->bssid_index = 0;
1616 link_conf->nontransmitted = false;
1617 link_conf->ema_ap = false;
1618 link_conf->bssid_indicator = 0;
1620 __sta_info_flush(sdata, true, link_id);
1622 ieee80211_remove_link_keys(link, &keys);
1623 if (!list_empty(&keys)) {
1625 ieee80211_free_key_list(local, &keys);
1628 link_conf->enable_beacon = false;
1629 sdata->beacon_rate_set = false;
1630 sdata->vif.cfg.ssid_len = 0;
1631 clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state);
1632 ieee80211_link_info_change_notify(sdata, link,
1633 BSS_CHANGED_BEACON_ENABLED);
1635 if (sdata->wdev.cac_started) {
1636 chandef = link_conf->chanreq.oper;
1637 wiphy_delayed_work_cancel(wiphy, &link->dfs_cac_timer_work);
1638 cfg80211_cac_event(sdata->dev, &chandef,
1639 NL80211_RADAR_CAC_ABORTED,
1643 drv_stop_ap(sdata->local, sdata, link_conf);
1645 /* free all potentially still buffered bcast frames */
1646 local->total_ps_buffered -= skb_queue_len(&sdata->u.ap.ps.bc_buf);
1647 ieee80211_purge_tx_queue(&local->hw, &sdata->u.ap.ps.bc_buf);
1649 ieee80211_link_copy_chanctx_to_vlans(link, true);
1650 ieee80211_link_release_channel(link);
1655 static int sta_apply_auth_flags(struct ieee80211_local *local,
1656 struct sta_info *sta,
1661 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
1662 set & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
1663 !test_sta_flag(sta, WLAN_STA_AUTH)) {
1664 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
1669 if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
1670 set & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
1671 !test_sta_flag(sta, WLAN_STA_ASSOC)) {
1673 * When peer becomes associated, init rate control as
1674 * well. Some drivers require rate control initialized
1675 * before drv_sta_state() is called.
1677 if (!test_sta_flag(sta, WLAN_STA_RATE_CONTROL))
1678 rate_control_rate_init(sta);
1680 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
1685 if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
1686 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED))
1687 ret = sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED);
1688 else if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
1689 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
1696 if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
1697 !(set & BIT(NL80211_STA_FLAG_ASSOCIATED)) &&
1698 test_sta_flag(sta, WLAN_STA_ASSOC)) {
1699 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
1704 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
1705 !(set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) &&
1706 test_sta_flag(sta, WLAN_STA_AUTH)) {
1707 ret = sta_info_move_state(sta, IEEE80211_STA_NONE);
1715 static void sta_apply_mesh_params(struct ieee80211_local *local,
1716 struct sta_info *sta,
1717 struct station_parameters *params)
1719 #ifdef CONFIG_MAC80211_MESH
1720 struct ieee80211_sub_if_data *sdata = sta->sdata;
1723 if (params->sta_modify_mask & STATION_PARAM_APPLY_PLINK_STATE) {
1724 switch (params->plink_state) {
1725 case NL80211_PLINK_ESTAB:
1726 if (sta->mesh->plink_state != NL80211_PLINK_ESTAB)
1727 changed = mesh_plink_inc_estab_count(sdata);
1728 sta->mesh->plink_state = params->plink_state;
1729 sta->mesh->aid = params->peer_aid;
1731 ieee80211_mps_sta_status_update(sta);
1732 changed |= ieee80211_mps_set_sta_local_pm(sta,
1733 sdata->u.mesh.mshcfg.power_mode);
1735 ewma_mesh_tx_rate_avg_init(&sta->mesh->tx_rate_avg);
1736 /* init at low value */
1737 ewma_mesh_tx_rate_avg_add(&sta->mesh->tx_rate_avg, 10);
1740 case NL80211_PLINK_LISTEN:
1741 case NL80211_PLINK_BLOCKED:
1742 case NL80211_PLINK_OPN_SNT:
1743 case NL80211_PLINK_OPN_RCVD:
1744 case NL80211_PLINK_CNF_RCVD:
1745 case NL80211_PLINK_HOLDING:
1746 if (sta->mesh->plink_state == NL80211_PLINK_ESTAB)
1747 changed = mesh_plink_dec_estab_count(sdata);
1748 sta->mesh->plink_state = params->plink_state;
1750 ieee80211_mps_sta_status_update(sta);
1751 changed |= ieee80211_mps_set_sta_local_pm(sta,
1752 NL80211_MESH_POWER_UNKNOWN);
1760 switch (params->plink_action) {
1761 case NL80211_PLINK_ACTION_NO_ACTION:
1764 case NL80211_PLINK_ACTION_OPEN:
1765 changed |= mesh_plink_open(sta);
1767 case NL80211_PLINK_ACTION_BLOCK:
1768 changed |= mesh_plink_block(sta);
1772 if (params->local_pm)
1773 changed |= ieee80211_mps_set_sta_local_pm(sta,
1776 ieee80211_mbss_info_change_notify(sdata, changed);
1780 static int sta_link_apply_parameters(struct ieee80211_local *local,
1781 struct sta_info *sta, bool new_link,
1782 struct link_station_parameters *params)
1785 struct ieee80211_supported_band *sband;
1786 struct ieee80211_sub_if_data *sdata = sta->sdata;
1787 u32 link_id = params->link_id < 0 ? 0 : params->link_id;
1788 struct ieee80211_link_data *link =
1789 sdata_dereference(sdata->link[link_id], sdata);
1790 struct link_sta_info *link_sta =
1791 rcu_dereference_protected(sta->link[link_id],
1792 lockdep_is_held(&local->hw.wiphy->mtx));
1795 * If there are no changes, then accept a link that exist,
1796 * unless it's a new link.
1798 if (params->link_id >= 0 && !new_link &&
1799 !params->link_mac && !params->txpwr_set &&
1800 !params->supported_rates_len &&
1801 !params->ht_capa && !params->vht_capa &&
1802 !params->he_capa && !params->eht_capa &&
1803 !params->opmode_notif_used)
1806 if (!link || !link_sta)
1809 sband = ieee80211_get_link_sband(link);
1813 if (params->link_mac) {
1815 memcpy(link_sta->addr, params->link_mac, ETH_ALEN);
1816 memcpy(link_sta->pub->addr, params->link_mac, ETH_ALEN);
1817 } else if (!ether_addr_equal(link_sta->addr,
1818 params->link_mac)) {
1821 } else if (new_link) {
1825 if (params->txpwr_set) {
1826 link_sta->pub->txpwr.type = params->txpwr.type;
1827 if (params->txpwr.type == NL80211_TX_POWER_LIMITED)
1828 link_sta->pub->txpwr.power = params->txpwr.power;
1829 ret = drv_sta_set_txpwr(local, sdata, sta);
1834 if (params->supported_rates &&
1835 params->supported_rates_len) {
1836 ieee80211_parse_bitrates(link->conf->chanreq.oper.width,
1837 sband, params->supported_rates,
1838 params->supported_rates_len,
1839 &link_sta->pub->supp_rates[sband->band]);
1842 if (params->ht_capa)
1843 ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
1844 params->ht_capa, link_sta);
1846 /* VHT can override some HT caps such as the A-MSDU max length */
1847 if (params->vht_capa)
1848 ieee80211_vht_cap_ie_to_sta_vht_cap(sdata, sband,
1849 params->vht_capa, NULL,
1852 if (params->he_capa)
1853 ieee80211_he_cap_ie_to_sta_he_cap(sdata, sband,
1854 (void *)params->he_capa,
1855 params->he_capa_len,
1856 (void *)params->he_6ghz_capa,
1859 if (params->he_capa && params->eht_capa)
1860 ieee80211_eht_cap_ie_to_sta_eht_cap(sdata, sband,
1861 (u8 *)params->he_capa,
1862 params->he_capa_len,
1864 params->eht_capa_len,
1867 if (params->opmode_notif_used) {
1868 /* returned value is only needed for rc update, but the
1869 * rc isn't initialized here yet, so ignore it
1871 __ieee80211_vht_handle_opmode(sdata, link_sta,
1872 params->opmode_notif,
1876 ieee80211_sta_init_nss(link_sta);
1881 static int sta_apply_parameters(struct ieee80211_local *local,
1882 struct sta_info *sta,
1883 struct station_parameters *params)
1885 struct ieee80211_sub_if_data *sdata = sta->sdata;
1889 mask = params->sta_flags_mask;
1890 set = params->sta_flags_set;
1892 if (ieee80211_vif_is_mesh(&sdata->vif)) {
1894 * In mesh mode, ASSOCIATED isn't part of the nl80211
1895 * API but must follow AUTHENTICATED for driver state.
1897 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED))
1898 mask |= BIT(NL80211_STA_FLAG_ASSOCIATED);
1899 if (set & BIT(NL80211_STA_FLAG_AUTHENTICATED))
1900 set |= BIT(NL80211_STA_FLAG_ASSOCIATED);
1901 } else if (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
1903 * TDLS -- everything follows authorized, but
1904 * only becoming authorized is possible, not
1907 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
1908 set |= BIT(NL80211_STA_FLAG_AUTHENTICATED) |
1909 BIT(NL80211_STA_FLAG_ASSOCIATED);
1910 mask |= BIT(NL80211_STA_FLAG_AUTHENTICATED) |
1911 BIT(NL80211_STA_FLAG_ASSOCIATED);
1915 if (mask & BIT(NL80211_STA_FLAG_WME) &&
1916 local->hw.queues >= IEEE80211_NUM_ACS)
1917 sta->sta.wme = set & BIT(NL80211_STA_FLAG_WME);
1919 /* auth flags will be set later for TDLS,
1920 * and for unassociated stations that move to associated */
1921 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1922 !((mask & BIT(NL80211_STA_FLAG_ASSOCIATED)) &&
1923 (set & BIT(NL80211_STA_FLAG_ASSOCIATED)))) {
1924 ret = sta_apply_auth_flags(local, sta, mask, set);
1929 if (mask & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) {
1930 if (set & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE))
1931 set_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
1933 clear_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
1936 if (mask & BIT(NL80211_STA_FLAG_MFP)) {
1937 sta->sta.mfp = !!(set & BIT(NL80211_STA_FLAG_MFP));
1938 if (set & BIT(NL80211_STA_FLAG_MFP))
1939 set_sta_flag(sta, WLAN_STA_MFP);
1941 clear_sta_flag(sta, WLAN_STA_MFP);
1944 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
1945 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER))
1946 set_sta_flag(sta, WLAN_STA_TDLS_PEER);
1948 clear_sta_flag(sta, WLAN_STA_TDLS_PEER);
1951 if (mask & BIT(NL80211_STA_FLAG_SPP_AMSDU))
1952 sta->sta.spp_amsdu = set & BIT(NL80211_STA_FLAG_SPP_AMSDU);
1954 /* mark TDLS channel switch support, if the AP allows it */
1955 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1956 !sdata->deflink.u.mgd.tdls_chan_switch_prohibited &&
1957 params->ext_capab_len >= 4 &&
1958 params->ext_capab[3] & WLAN_EXT_CAPA4_TDLS_CHAN_SWITCH)
1959 set_sta_flag(sta, WLAN_STA_TDLS_CHAN_SWITCH);
1961 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1962 !sdata->u.mgd.tdls_wider_bw_prohibited &&
1963 ieee80211_hw_check(&local->hw, TDLS_WIDER_BW) &&
1964 params->ext_capab_len >= 8 &&
1965 params->ext_capab[7] & WLAN_EXT_CAPA8_TDLS_WIDE_BW_ENABLED)
1966 set_sta_flag(sta, WLAN_STA_TDLS_WIDER_BW);
1968 if (params->sta_modify_mask & STATION_PARAM_APPLY_UAPSD) {
1969 sta->sta.uapsd_queues = params->uapsd_queues;
1970 sta->sta.max_sp = params->max_sp;
1973 ieee80211_sta_set_max_amsdu_subframes(sta, params->ext_capab,
1974 params->ext_capab_len);
1977 * cfg80211 validates this (1-2007) and allows setting the AID
1978 * only when creating a new station entry
1981 sta->sta.aid = params->aid;
1984 * Some of the following updates would be racy if called on an
1985 * existing station, via ieee80211_change_station(). However,
1986 * all such changes are rejected by cfg80211 except for updates
1987 * changing the supported rates on an existing but not yet used
1991 if (params->listen_interval >= 0)
1992 sta->listen_interval = params->listen_interval;
1994 ret = sta_link_apply_parameters(local, sta, false,
1995 ¶ms->link_sta_params);
1999 if (params->support_p2p_ps >= 0)
2000 sta->sta.support_p2p_ps = params->support_p2p_ps;
2002 if (ieee80211_vif_is_mesh(&sdata->vif))
2003 sta_apply_mesh_params(local, sta, params);
2005 if (params->airtime_weight)
2006 sta->airtime_weight = params->airtime_weight;
2008 /* set the STA state after all sta info from usermode has been set */
2009 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) ||
2010 set & BIT(NL80211_STA_FLAG_ASSOCIATED)) {
2011 ret = sta_apply_auth_flags(local, sta, mask, set);
2016 /* Mark the STA as MLO if MLD MAC address is available */
2017 if (params->link_sta_params.mld_mac)
2018 sta->sta.mlo = true;
2023 static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
2025 struct station_parameters *params)
2027 struct ieee80211_local *local = wiphy_priv(wiphy);
2028 struct sta_info *sta;
2029 struct ieee80211_sub_if_data *sdata;
2032 lockdep_assert_wiphy(local->hw.wiphy);
2035 sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
2037 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
2038 sdata->vif.type != NL80211_IFTYPE_AP)
2041 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2043 if (ether_addr_equal(mac, sdata->vif.addr))
2046 if (!is_valid_ether_addr(mac))
2049 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER) &&
2050 sdata->vif.type == NL80211_IFTYPE_STATION &&
2051 !sdata->u.mgd.associated)
2055 * If we have a link ID, it can be a non-MLO station on an AP MLD,
2056 * but we need to have a link_mac in that case as well, so use the
2057 * STA's MAC address in that case.
2059 if (params->link_sta_params.link_id >= 0)
2060 sta = sta_info_alloc_with_link(sdata, mac,
2061 params->link_sta_params.link_id,
2062 params->link_sta_params.link_mac ?: mac,
2065 sta = sta_info_alloc(sdata, mac, GFP_KERNEL);
2070 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))
2071 sta->sta.tdls = true;
2073 /* Though the mutex is not needed here (since the station is not
2074 * visible yet), sta_apply_parameters (and inner functions) require
2075 * the mutex due to other paths.
2077 err = sta_apply_parameters(local, sta, params);
2079 sta_info_free(local, sta);
2084 * for TDLS and for unassociated station, rate control should be
2085 * initialized only when rates are known and station is marked
2086 * authorized/associated
2088 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
2089 test_sta_flag(sta, WLAN_STA_ASSOC))
2090 rate_control_rate_init(sta);
2092 return sta_info_insert(sta);
2095 static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev,
2096 struct station_del_parameters *params)
2098 struct ieee80211_sub_if_data *sdata;
2100 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2103 return sta_info_destroy_addr_bss(sdata, params->mac);
2105 sta_info_flush(sdata, params->link_id);
2109 static int ieee80211_change_station(struct wiphy *wiphy,
2110 struct net_device *dev, const u8 *mac,
2111 struct station_parameters *params)
2113 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2114 struct ieee80211_local *local = wiphy_priv(wiphy);
2115 struct sta_info *sta;
2116 struct ieee80211_sub_if_data *vlansdata;
2117 enum cfg80211_station_type statype;
2120 lockdep_assert_wiphy(local->hw.wiphy);
2122 sta = sta_info_get_bss(sdata, mac);
2126 switch (sdata->vif.type) {
2127 case NL80211_IFTYPE_MESH_POINT:
2128 if (sdata->u.mesh.user_mpm)
2129 statype = CFG80211_STA_MESH_PEER_USER;
2131 statype = CFG80211_STA_MESH_PEER_KERNEL;
2133 case NL80211_IFTYPE_ADHOC:
2134 statype = CFG80211_STA_IBSS;
2136 case NL80211_IFTYPE_STATION:
2137 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
2138 statype = CFG80211_STA_AP_STA;
2141 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
2142 statype = CFG80211_STA_TDLS_PEER_ACTIVE;
2144 statype = CFG80211_STA_TDLS_PEER_SETUP;
2146 case NL80211_IFTYPE_AP:
2147 case NL80211_IFTYPE_AP_VLAN:
2148 if (test_sta_flag(sta, WLAN_STA_ASSOC))
2149 statype = CFG80211_STA_AP_CLIENT;
2151 statype = CFG80211_STA_AP_CLIENT_UNASSOC;
2157 err = cfg80211_check_station_change(wiphy, params, statype);
2161 if (params->vlan && params->vlan != sta->sdata->dev) {
2162 vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
2164 if (params->vlan->ieee80211_ptr->use_4addr) {
2165 if (vlansdata->u.vlan.sta)
2168 rcu_assign_pointer(vlansdata->u.vlan.sta, sta);
2169 __ieee80211_check_fast_rx_iface(vlansdata);
2170 drv_sta_set_4addr(local, sta->sdata, &sta->sta, true);
2173 if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
2174 sta->sdata->u.vlan.sta) {
2175 ieee80211_clear_fast_rx(sta);
2176 RCU_INIT_POINTER(sta->sdata->u.vlan.sta, NULL);
2179 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
2180 ieee80211_vif_dec_num_mcast(sta->sdata);
2182 sta->sdata = vlansdata;
2183 ieee80211_check_fast_xmit(sta);
2185 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED)) {
2186 ieee80211_vif_inc_num_mcast(sta->sdata);
2187 cfg80211_send_layer2_update(sta->sdata->dev,
2192 err = sta_apply_parameters(local, sta, params);
2196 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
2197 params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
2198 ieee80211_recalc_ps(local);
2199 ieee80211_recalc_ps_vif(sdata);
2205 #ifdef CONFIG_MAC80211_MESH
2206 static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev,
2207 const u8 *dst, const u8 *next_hop)
2209 struct ieee80211_sub_if_data *sdata;
2210 struct mesh_path *mpath;
2211 struct sta_info *sta;
2213 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2216 sta = sta_info_get(sdata, next_hop);
2222 mpath = mesh_path_add(sdata, dst);
2223 if (IS_ERR(mpath)) {
2225 return PTR_ERR(mpath);
2228 mesh_path_fix_nexthop(mpath, sta);
2234 static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev,
2237 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2240 return mesh_path_del(sdata, dst);
2242 mesh_path_flush_by_iface(sdata);
2246 static int ieee80211_change_mpath(struct wiphy *wiphy, struct net_device *dev,
2247 const u8 *dst, const u8 *next_hop)
2249 struct ieee80211_sub_if_data *sdata;
2250 struct mesh_path *mpath;
2251 struct sta_info *sta;
2253 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2257 sta = sta_info_get(sdata, next_hop);
2263 mpath = mesh_path_lookup(sdata, dst);
2269 mesh_path_fix_nexthop(mpath, sta);
2275 static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop,
2276 struct mpath_info *pinfo)
2278 struct sta_info *next_hop_sta = rcu_dereference(mpath->next_hop);
2281 memcpy(next_hop, next_hop_sta->sta.addr, ETH_ALEN);
2283 eth_zero_addr(next_hop);
2285 memset(pinfo, 0, sizeof(*pinfo));
2287 pinfo->generation = mpath->sdata->u.mesh.mesh_paths_generation;
2289 pinfo->filled = MPATH_INFO_FRAME_QLEN |
2292 MPATH_INFO_EXPTIME |
2293 MPATH_INFO_DISCOVERY_TIMEOUT |
2294 MPATH_INFO_DISCOVERY_RETRIES |
2296 MPATH_INFO_HOP_COUNT |
2297 MPATH_INFO_PATH_CHANGE;
2299 pinfo->frame_qlen = mpath->frame_queue.qlen;
2300 pinfo->sn = mpath->sn;
2301 pinfo->metric = mpath->metric;
2302 if (time_before(jiffies, mpath->exp_time))
2303 pinfo->exptime = jiffies_to_msecs(mpath->exp_time - jiffies);
2304 pinfo->discovery_timeout =
2305 jiffies_to_msecs(mpath->discovery_timeout);
2306 pinfo->discovery_retries = mpath->discovery_retries;
2307 if (mpath->flags & MESH_PATH_ACTIVE)
2308 pinfo->flags |= NL80211_MPATH_FLAG_ACTIVE;
2309 if (mpath->flags & MESH_PATH_RESOLVING)
2310 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING;
2311 if (mpath->flags & MESH_PATH_SN_VALID)
2312 pinfo->flags |= NL80211_MPATH_FLAG_SN_VALID;
2313 if (mpath->flags & MESH_PATH_FIXED)
2314 pinfo->flags |= NL80211_MPATH_FLAG_FIXED;
2315 if (mpath->flags & MESH_PATH_RESOLVED)
2316 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVED;
2317 pinfo->hop_count = mpath->hop_count;
2318 pinfo->path_change_count = mpath->path_change_count;
2321 static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev,
2322 u8 *dst, u8 *next_hop, struct mpath_info *pinfo)
2325 struct ieee80211_sub_if_data *sdata;
2326 struct mesh_path *mpath;
2328 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2331 mpath = mesh_path_lookup(sdata, dst);
2336 memcpy(dst, mpath->dst, ETH_ALEN);
2337 mpath_set_pinfo(mpath, next_hop, pinfo);
2342 static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev,
2343 int idx, u8 *dst, u8 *next_hop,
2344 struct mpath_info *pinfo)
2346 struct ieee80211_sub_if_data *sdata;
2347 struct mesh_path *mpath;
2349 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2352 mpath = mesh_path_lookup_by_idx(sdata, idx);
2357 memcpy(dst, mpath->dst, ETH_ALEN);
2358 mpath_set_pinfo(mpath, next_hop, pinfo);
2363 static void mpp_set_pinfo(struct mesh_path *mpath, u8 *mpp,
2364 struct mpath_info *pinfo)
2366 memset(pinfo, 0, sizeof(*pinfo));
2367 memcpy(mpp, mpath->mpp, ETH_ALEN);
2369 pinfo->generation = mpath->sdata->u.mesh.mpp_paths_generation;
2372 static int ieee80211_get_mpp(struct wiphy *wiphy, struct net_device *dev,
2373 u8 *dst, u8 *mpp, struct mpath_info *pinfo)
2376 struct ieee80211_sub_if_data *sdata;
2377 struct mesh_path *mpath;
2379 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2382 mpath = mpp_path_lookup(sdata, dst);
2387 memcpy(dst, mpath->dst, ETH_ALEN);
2388 mpp_set_pinfo(mpath, mpp, pinfo);
2393 static int ieee80211_dump_mpp(struct wiphy *wiphy, struct net_device *dev,
2394 int idx, u8 *dst, u8 *mpp,
2395 struct mpath_info *pinfo)
2397 struct ieee80211_sub_if_data *sdata;
2398 struct mesh_path *mpath;
2400 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2403 mpath = mpp_path_lookup_by_idx(sdata, idx);
2408 memcpy(dst, mpath->dst, ETH_ALEN);
2409 mpp_set_pinfo(mpath, mpp, pinfo);
2414 static int ieee80211_get_mesh_config(struct wiphy *wiphy,
2415 struct net_device *dev,
2416 struct mesh_config *conf)
2418 struct ieee80211_sub_if_data *sdata;
2419 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2421 memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config));
2425 static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask)
2427 return (mask >> (parm-1)) & 0x1;
2430 static int copy_mesh_setup(struct ieee80211_if_mesh *ifmsh,
2431 const struct mesh_setup *setup)
2434 struct ieee80211_sub_if_data *sdata = container_of(ifmsh,
2435 struct ieee80211_sub_if_data, u.mesh);
2438 /* allocate information elements */
2441 if (setup->ie_len) {
2442 new_ie = kmemdup(setup->ie, setup->ie_len,
2447 ifmsh->ie_len = setup->ie_len;
2450 /* now copy the rest of the setup parameters */
2451 ifmsh->mesh_id_len = setup->mesh_id_len;
2452 memcpy(ifmsh->mesh_id, setup->mesh_id, ifmsh->mesh_id_len);
2453 ifmsh->mesh_sp_id = setup->sync_method;
2454 ifmsh->mesh_pp_id = setup->path_sel_proto;
2455 ifmsh->mesh_pm_id = setup->path_metric;
2456 ifmsh->user_mpm = setup->user_mpm;
2457 ifmsh->mesh_auth_id = setup->auth_id;
2458 ifmsh->security = IEEE80211_MESH_SEC_NONE;
2459 ifmsh->userspace_handles_dfs = setup->userspace_handles_dfs;
2460 if (setup->is_authenticated)
2461 ifmsh->security |= IEEE80211_MESH_SEC_AUTHED;
2462 if (setup->is_secure)
2463 ifmsh->security |= IEEE80211_MESH_SEC_SECURED;
2465 /* mcast rate setting in Mesh Node */
2466 memcpy(sdata->vif.bss_conf.mcast_rate, setup->mcast_rate,
2467 sizeof(setup->mcast_rate));
2468 sdata->vif.bss_conf.basic_rates = setup->basic_rates;
2470 sdata->vif.bss_conf.beacon_int = setup->beacon_interval;
2471 sdata->vif.bss_conf.dtim_period = setup->dtim_period;
2473 sdata->beacon_rate_set = false;
2474 if (wiphy_ext_feature_isset(sdata->local->hw.wiphy,
2475 NL80211_EXT_FEATURE_BEACON_RATE_LEGACY)) {
2476 for (i = 0; i < NUM_NL80211_BANDS; i++) {
2477 sdata->beacon_rateidx_mask[i] =
2478 setup->beacon_rate.control[i].legacy;
2479 if (sdata->beacon_rateidx_mask[i])
2480 sdata->beacon_rate_set = true;
2487 static int ieee80211_update_mesh_config(struct wiphy *wiphy,
2488 struct net_device *dev, u32 mask,
2489 const struct mesh_config *nconf)
2491 struct mesh_config *conf;
2492 struct ieee80211_sub_if_data *sdata;
2493 struct ieee80211_if_mesh *ifmsh;
2495 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2496 ifmsh = &sdata->u.mesh;
2498 /* Set the config options which we are interested in setting */
2499 conf = &(sdata->u.mesh.mshcfg);
2500 if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask))
2501 conf->dot11MeshRetryTimeout = nconf->dot11MeshRetryTimeout;
2502 if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT, mask))
2503 conf->dot11MeshConfirmTimeout = nconf->dot11MeshConfirmTimeout;
2504 if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT, mask))
2505 conf->dot11MeshHoldingTimeout = nconf->dot11MeshHoldingTimeout;
2506 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS, mask))
2507 conf->dot11MeshMaxPeerLinks = nconf->dot11MeshMaxPeerLinks;
2508 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES, mask))
2509 conf->dot11MeshMaxRetries = nconf->dot11MeshMaxRetries;
2510 if (_chg_mesh_attr(NL80211_MESHCONF_TTL, mask))
2511 conf->dot11MeshTTL = nconf->dot11MeshTTL;
2512 if (_chg_mesh_attr(NL80211_MESHCONF_ELEMENT_TTL, mask))
2513 conf->element_ttl = nconf->element_ttl;
2514 if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask)) {
2515 if (ifmsh->user_mpm)
2517 conf->auto_open_plinks = nconf->auto_open_plinks;
2519 if (_chg_mesh_attr(NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR, mask))
2520 conf->dot11MeshNbrOffsetMaxNeighbor =
2521 nconf->dot11MeshNbrOffsetMaxNeighbor;
2522 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, mask))
2523 conf->dot11MeshHWMPmaxPREQretries =
2524 nconf->dot11MeshHWMPmaxPREQretries;
2525 if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME, mask))
2526 conf->path_refresh_time = nconf->path_refresh_time;
2527 if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, mask))
2528 conf->min_discovery_timeout = nconf->min_discovery_timeout;
2529 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, mask))
2530 conf->dot11MeshHWMPactivePathTimeout =
2531 nconf->dot11MeshHWMPactivePathTimeout;
2532 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, mask))
2533 conf->dot11MeshHWMPpreqMinInterval =
2534 nconf->dot11MeshHWMPpreqMinInterval;
2535 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL, mask))
2536 conf->dot11MeshHWMPperrMinInterval =
2537 nconf->dot11MeshHWMPperrMinInterval;
2538 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
2540 conf->dot11MeshHWMPnetDiameterTraversalTime =
2541 nconf->dot11MeshHWMPnetDiameterTraversalTime;
2542 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOTMODE, mask)) {
2543 conf->dot11MeshHWMPRootMode = nconf->dot11MeshHWMPRootMode;
2544 ieee80211_mesh_root_setup(ifmsh);
2546 if (_chg_mesh_attr(NL80211_MESHCONF_GATE_ANNOUNCEMENTS, mask)) {
2547 /* our current gate announcement implementation rides on root
2548 * announcements, so require this ifmsh to also be a root node
2550 if (nconf->dot11MeshGateAnnouncementProtocol &&
2551 !(conf->dot11MeshHWMPRootMode > IEEE80211_ROOTMODE_ROOT)) {
2552 conf->dot11MeshHWMPRootMode = IEEE80211_PROACTIVE_RANN;
2553 ieee80211_mesh_root_setup(ifmsh);
2555 conf->dot11MeshGateAnnouncementProtocol =
2556 nconf->dot11MeshGateAnnouncementProtocol;
2558 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_RANN_INTERVAL, mask))
2559 conf->dot11MeshHWMPRannInterval =
2560 nconf->dot11MeshHWMPRannInterval;
2561 if (_chg_mesh_attr(NL80211_MESHCONF_FORWARDING, mask))
2562 conf->dot11MeshForwarding = nconf->dot11MeshForwarding;
2563 if (_chg_mesh_attr(NL80211_MESHCONF_RSSI_THRESHOLD, mask)) {
2564 /* our RSSI threshold implementation is supported only for
2565 * devices that report signal in dBm.
2567 if (!ieee80211_hw_check(&sdata->local->hw, SIGNAL_DBM))
2569 conf->rssi_threshold = nconf->rssi_threshold;
2571 if (_chg_mesh_attr(NL80211_MESHCONF_HT_OPMODE, mask)) {
2572 conf->ht_opmode = nconf->ht_opmode;
2573 sdata->vif.bss_conf.ht_operation_mode = nconf->ht_opmode;
2574 ieee80211_link_info_change_notify(sdata, &sdata->deflink,
2577 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT, mask))
2578 conf->dot11MeshHWMPactivePathToRootTimeout =
2579 nconf->dot11MeshHWMPactivePathToRootTimeout;
2580 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOT_INTERVAL, mask))
2581 conf->dot11MeshHWMProotInterval =
2582 nconf->dot11MeshHWMProotInterval;
2583 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL, mask))
2584 conf->dot11MeshHWMPconfirmationInterval =
2585 nconf->dot11MeshHWMPconfirmationInterval;
2586 if (_chg_mesh_attr(NL80211_MESHCONF_POWER_MODE, mask)) {
2587 conf->power_mode = nconf->power_mode;
2588 ieee80211_mps_local_status_update(sdata);
2590 if (_chg_mesh_attr(NL80211_MESHCONF_AWAKE_WINDOW, mask))
2591 conf->dot11MeshAwakeWindowDuration =
2592 nconf->dot11MeshAwakeWindowDuration;
2593 if (_chg_mesh_attr(NL80211_MESHCONF_PLINK_TIMEOUT, mask))
2594 conf->plink_timeout = nconf->plink_timeout;
2595 if (_chg_mesh_attr(NL80211_MESHCONF_CONNECTED_TO_GATE, mask))
2596 conf->dot11MeshConnectedToMeshGate =
2597 nconf->dot11MeshConnectedToMeshGate;
2598 if (_chg_mesh_attr(NL80211_MESHCONF_NOLEARN, mask))
2599 conf->dot11MeshNolearn = nconf->dot11MeshNolearn;
2600 if (_chg_mesh_attr(NL80211_MESHCONF_CONNECTED_TO_AS, mask))
2601 conf->dot11MeshConnectedToAuthServer =
2602 nconf->dot11MeshConnectedToAuthServer;
2603 ieee80211_mbss_info_change_notify(sdata, BSS_CHANGED_BEACON);
2607 static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev,
2608 const struct mesh_config *conf,
2609 const struct mesh_setup *setup)
2611 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2612 struct ieee80211_chan_req chanreq = { .oper = setup->chandef };
2613 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
2616 lockdep_assert_wiphy(sdata->local->hw.wiphy);
2618 memcpy(&ifmsh->mshcfg, conf, sizeof(struct mesh_config));
2619 err = copy_mesh_setup(ifmsh, setup);
2623 sdata->control_port_over_nl80211 = setup->control_port_over_nl80211;
2625 /* can mesh use other SMPS modes? */
2626 sdata->deflink.smps_mode = IEEE80211_SMPS_OFF;
2627 sdata->deflink.needed_rx_chains = sdata->local->rx_chains;
2629 err = ieee80211_link_use_channel(&sdata->deflink, &chanreq,
2630 IEEE80211_CHANCTX_SHARED);
2634 return ieee80211_start_mesh(sdata);
2637 static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev)
2639 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2641 lockdep_assert_wiphy(sdata->local->hw.wiphy);
2643 ieee80211_stop_mesh(sdata);
2644 ieee80211_link_release_channel(&sdata->deflink);
2645 kfree(sdata->u.mesh.ie);
2651 static int ieee80211_change_bss(struct wiphy *wiphy,
2652 struct net_device *dev,
2653 struct bss_parameters *params)
2655 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2656 struct ieee80211_link_data *link;
2657 struct ieee80211_supported_band *sband;
2660 link = ieee80211_link_or_deflink(sdata, params->link_id, true);
2662 return PTR_ERR(link);
2664 if (!sdata_dereference(link->u.ap.beacon, sdata))
2667 sband = ieee80211_get_link_sband(link);
2671 if (params->basic_rates) {
2672 if (!ieee80211_parse_bitrates(link->conf->chanreq.oper.width,
2673 wiphy->bands[sband->band],
2674 params->basic_rates,
2675 params->basic_rates_len,
2676 &link->conf->basic_rates))
2678 changed |= BSS_CHANGED_BASIC_RATES;
2679 ieee80211_check_rate_mask(link);
2682 if (params->use_cts_prot >= 0) {
2683 link->conf->use_cts_prot = params->use_cts_prot;
2684 changed |= BSS_CHANGED_ERP_CTS_PROT;
2686 if (params->use_short_preamble >= 0) {
2687 link->conf->use_short_preamble = params->use_short_preamble;
2688 changed |= BSS_CHANGED_ERP_PREAMBLE;
2691 if (!link->conf->use_short_slot &&
2692 (sband->band == NL80211_BAND_5GHZ ||
2693 sband->band == NL80211_BAND_6GHZ)) {
2694 link->conf->use_short_slot = true;
2695 changed |= BSS_CHANGED_ERP_SLOT;
2698 if (params->use_short_slot_time >= 0) {
2699 link->conf->use_short_slot = params->use_short_slot_time;
2700 changed |= BSS_CHANGED_ERP_SLOT;
2703 if (params->ap_isolate >= 0) {
2704 if (params->ap_isolate)
2705 sdata->flags |= IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
2707 sdata->flags &= ~IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
2708 ieee80211_check_fast_rx_iface(sdata);
2711 if (params->ht_opmode >= 0) {
2712 link->conf->ht_operation_mode = (u16)params->ht_opmode;
2713 changed |= BSS_CHANGED_HT;
2716 if (params->p2p_ctwindow >= 0) {
2717 link->conf->p2p_noa_attr.oppps_ctwindow &=
2718 ~IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
2719 link->conf->p2p_noa_attr.oppps_ctwindow |=
2720 params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
2721 changed |= BSS_CHANGED_P2P_PS;
2724 if (params->p2p_opp_ps > 0) {
2725 link->conf->p2p_noa_attr.oppps_ctwindow |=
2726 IEEE80211_P2P_OPPPS_ENABLE_BIT;
2727 changed |= BSS_CHANGED_P2P_PS;
2728 } else if (params->p2p_opp_ps == 0) {
2729 link->conf->p2p_noa_attr.oppps_ctwindow &=
2730 ~IEEE80211_P2P_OPPPS_ENABLE_BIT;
2731 changed |= BSS_CHANGED_P2P_PS;
2734 ieee80211_link_info_change_notify(sdata, link, changed);
2739 static int ieee80211_set_txq_params(struct wiphy *wiphy,
2740 struct net_device *dev,
2741 struct ieee80211_txq_params *params)
2743 struct ieee80211_local *local = wiphy_priv(wiphy);
2744 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2745 struct ieee80211_link_data *link =
2746 ieee80211_link_or_deflink(sdata, params->link_id, true);
2747 struct ieee80211_tx_queue_params p;
2749 if (!local->ops->conf_tx)
2752 if (local->hw.queues < IEEE80211_NUM_ACS)
2756 return PTR_ERR(link);
2758 memset(&p, 0, sizeof(p));
2759 p.aifs = params->aifs;
2760 p.cw_max = params->cwmax;
2761 p.cw_min = params->cwmin;
2762 p.txop = params->txop;
2765 * Setting tx queue params disables u-apsd because it's only
2766 * called in master mode.
2770 ieee80211_regulatory_limit_wmm_params(sdata, &p, params->ac);
2772 link->tx_conf[params->ac] = p;
2773 if (drv_conf_tx(local, link, params->ac, &p)) {
2774 wiphy_debug(local->hw.wiphy,
2775 "failed to set TX queue parameters for AC %d\n",
2780 ieee80211_link_info_change_notify(sdata, link,
2787 static int ieee80211_suspend(struct wiphy *wiphy,
2788 struct cfg80211_wowlan *wowlan)
2790 return __ieee80211_suspend(wiphy_priv(wiphy), wowlan);
2793 static int ieee80211_resume(struct wiphy *wiphy)
2795 return __ieee80211_resume(wiphy_priv(wiphy));
2798 #define ieee80211_suspend NULL
2799 #define ieee80211_resume NULL
2802 static int ieee80211_scan(struct wiphy *wiphy,
2803 struct cfg80211_scan_request *req)
2805 struct ieee80211_sub_if_data *sdata;
2807 sdata = IEEE80211_WDEV_TO_SUB_IF(req->wdev);
2809 switch (ieee80211_vif_type_p2p(&sdata->vif)) {
2810 case NL80211_IFTYPE_STATION:
2811 case NL80211_IFTYPE_ADHOC:
2812 case NL80211_IFTYPE_MESH_POINT:
2813 case NL80211_IFTYPE_P2P_CLIENT:
2814 case NL80211_IFTYPE_P2P_DEVICE:
2816 case NL80211_IFTYPE_P2P_GO:
2817 if (sdata->local->ops->hw_scan)
2820 * FIXME: implement NoA while scanning in software,
2821 * for now fall through to allow scanning only when
2822 * beaconing hasn't been configured yet
2825 case NL80211_IFTYPE_AP:
2827 * If the scan has been forced (and the driver supports
2828 * forcing), don't care about being beaconing already.
2829 * This will create problems to the attached stations (e.g. all
2830 * the frames sent while scanning on other channel will be
2833 if (sdata->deflink.u.ap.beacon &&
2834 (!(wiphy->features & NL80211_FEATURE_AP_SCAN) ||
2835 !(req->flags & NL80211_SCAN_FLAG_AP)))
2838 case NL80211_IFTYPE_NAN:
2843 return ieee80211_request_scan(sdata, req);
2846 static void ieee80211_abort_scan(struct wiphy *wiphy, struct wireless_dev *wdev)
2848 ieee80211_scan_cancel(wiphy_priv(wiphy));
2852 ieee80211_sched_scan_start(struct wiphy *wiphy,
2853 struct net_device *dev,
2854 struct cfg80211_sched_scan_request *req)
2856 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2858 if (!sdata->local->ops->sched_scan_start)
2861 return ieee80211_request_sched_scan_start(sdata, req);
2865 ieee80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev,
2868 struct ieee80211_local *local = wiphy_priv(wiphy);
2870 if (!local->ops->sched_scan_stop)
2873 return ieee80211_request_sched_scan_stop(local);
2876 static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev,
2877 struct cfg80211_auth_request *req)
2879 return ieee80211_mgd_auth(IEEE80211_DEV_TO_SUB_IF(dev), req);
2882 static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev,
2883 struct cfg80211_assoc_request *req)
2885 return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
2888 static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev,
2889 struct cfg80211_deauth_request *req)
2891 return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev), req);
2894 static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
2895 struct cfg80211_disassoc_request *req)
2897 return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
2900 static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
2901 struct cfg80211_ibss_params *params)
2903 return ieee80211_ibss_join(IEEE80211_DEV_TO_SUB_IF(dev), params);
2906 static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
2908 return ieee80211_ibss_leave(IEEE80211_DEV_TO_SUB_IF(dev));
2911 static int ieee80211_join_ocb(struct wiphy *wiphy, struct net_device *dev,
2912 struct ocb_setup *setup)
2914 return ieee80211_ocb_join(IEEE80211_DEV_TO_SUB_IF(dev), setup);
2917 static int ieee80211_leave_ocb(struct wiphy *wiphy, struct net_device *dev)
2919 return ieee80211_ocb_leave(IEEE80211_DEV_TO_SUB_IF(dev));
2922 static int ieee80211_set_mcast_rate(struct wiphy *wiphy, struct net_device *dev,
2923 int rate[NUM_NL80211_BANDS])
2925 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2927 memcpy(sdata->vif.bss_conf.mcast_rate, rate,
2928 sizeof(int) * NUM_NL80211_BANDS);
2930 ieee80211_link_info_change_notify(sdata, &sdata->deflink,
2931 BSS_CHANGED_MCAST_RATE);
2936 static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
2938 struct ieee80211_local *local = wiphy_priv(wiphy);
2941 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
2942 ieee80211_check_fast_xmit_all(local);
2944 err = drv_set_frag_threshold(local, wiphy->frag_threshold);
2947 ieee80211_check_fast_xmit_all(local);
2952 if ((changed & WIPHY_PARAM_COVERAGE_CLASS) ||
2953 (changed & WIPHY_PARAM_DYN_ACK)) {
2956 coverage_class = changed & WIPHY_PARAM_COVERAGE_CLASS ?
2957 wiphy->coverage_class : -1;
2958 err = drv_set_coverage_class(local, coverage_class);
2964 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
2965 err = drv_set_rts_threshold(local, wiphy->rts_threshold);
2971 if (changed & WIPHY_PARAM_RETRY_SHORT) {
2972 if (wiphy->retry_short > IEEE80211_MAX_TX_RETRY)
2974 local->hw.conf.short_frame_max_tx_count = wiphy->retry_short;
2976 if (changed & WIPHY_PARAM_RETRY_LONG) {
2977 if (wiphy->retry_long > IEEE80211_MAX_TX_RETRY)
2979 local->hw.conf.long_frame_max_tx_count = wiphy->retry_long;
2982 (WIPHY_PARAM_RETRY_SHORT | WIPHY_PARAM_RETRY_LONG))
2983 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS);
2985 if (changed & (WIPHY_PARAM_TXQ_LIMIT |
2986 WIPHY_PARAM_TXQ_MEMORY_LIMIT |
2987 WIPHY_PARAM_TXQ_QUANTUM))
2988 ieee80211_txq_set_params(local);
2993 static int ieee80211_set_tx_power(struct wiphy *wiphy,
2994 struct wireless_dev *wdev,
2995 enum nl80211_tx_power_setting type, int mbm)
2997 struct ieee80211_local *local = wiphy_priv(wiphy);
2998 struct ieee80211_sub_if_data *sdata;
2999 enum nl80211_tx_power_setting txp_type = type;
3000 bool update_txp_type = false;
3001 bool has_monitor = false;
3003 lockdep_assert_wiphy(local->hw.wiphy);
3006 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
3008 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) {
3009 sdata = wiphy_dereference(local->hw.wiphy,
3010 local->monitor_sdata);
3016 case NL80211_TX_POWER_AUTOMATIC:
3017 sdata->deflink.user_power_level =
3018 IEEE80211_UNSET_POWER_LEVEL;
3019 txp_type = NL80211_TX_POWER_LIMITED;
3021 case NL80211_TX_POWER_LIMITED:
3022 case NL80211_TX_POWER_FIXED:
3023 if (mbm < 0 || (mbm % 100))
3025 sdata->deflink.user_power_level = MBM_TO_DBM(mbm);
3029 if (txp_type != sdata->vif.bss_conf.txpower_type) {
3030 update_txp_type = true;
3031 sdata->vif.bss_conf.txpower_type = txp_type;
3034 ieee80211_recalc_txpower(sdata, update_txp_type);
3040 case NL80211_TX_POWER_AUTOMATIC:
3041 local->user_power_level = IEEE80211_UNSET_POWER_LEVEL;
3042 txp_type = NL80211_TX_POWER_LIMITED;
3044 case NL80211_TX_POWER_LIMITED:
3045 case NL80211_TX_POWER_FIXED:
3046 if (mbm < 0 || (mbm % 100))
3048 local->user_power_level = MBM_TO_DBM(mbm);
3052 list_for_each_entry(sdata, &local->interfaces, list) {
3053 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) {
3057 sdata->deflink.user_power_level = local->user_power_level;
3058 if (txp_type != sdata->vif.bss_conf.txpower_type)
3059 update_txp_type = true;
3060 sdata->vif.bss_conf.txpower_type = txp_type;
3062 list_for_each_entry(sdata, &local->interfaces, list) {
3063 if (sdata->vif.type == NL80211_IFTYPE_MONITOR)
3065 ieee80211_recalc_txpower(sdata, update_txp_type);
3069 sdata = wiphy_dereference(local->hw.wiphy,
3070 local->monitor_sdata);
3072 sdata->deflink.user_power_level = local->user_power_level;
3073 if (txp_type != sdata->vif.bss_conf.txpower_type)
3074 update_txp_type = true;
3075 sdata->vif.bss_conf.txpower_type = txp_type;
3077 ieee80211_recalc_txpower(sdata, update_txp_type);
3084 static int ieee80211_get_tx_power(struct wiphy *wiphy,
3085 struct wireless_dev *wdev,
3088 struct ieee80211_local *local = wiphy_priv(wiphy);
3089 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
3091 if (local->ops->get_txpower)
3092 return drv_get_txpower(local, sdata, dbm);
3094 if (local->emulate_chanctx)
3095 *dbm = local->hw.conf.power_level;
3097 *dbm = sdata->vif.bss_conf.txpower;
3099 /* INT_MIN indicates no power level was set yet */
3100 if (*dbm == INT_MIN)
3106 static void ieee80211_rfkill_poll(struct wiphy *wiphy)
3108 struct ieee80211_local *local = wiphy_priv(wiphy);
3110 drv_rfkill_poll(local);
3113 #ifdef CONFIG_NL80211_TESTMODE
3114 static int ieee80211_testmode_cmd(struct wiphy *wiphy,
3115 struct wireless_dev *wdev,
3116 void *data, int len)
3118 struct ieee80211_local *local = wiphy_priv(wiphy);
3119 struct ieee80211_vif *vif = NULL;
3121 if (!local->ops->testmode_cmd)
3125 struct ieee80211_sub_if_data *sdata;
3127 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
3128 if (sdata->flags & IEEE80211_SDATA_IN_DRIVER)
3132 return local->ops->testmode_cmd(&local->hw, vif, data, len);
3135 static int ieee80211_testmode_dump(struct wiphy *wiphy,
3136 struct sk_buff *skb,
3137 struct netlink_callback *cb,
3138 void *data, int len)
3140 struct ieee80211_local *local = wiphy_priv(wiphy);
3142 if (!local->ops->testmode_dump)
3145 return local->ops->testmode_dump(&local->hw, skb, cb, data, len);
3149 int __ieee80211_request_smps_mgd(struct ieee80211_sub_if_data *sdata,
3150 struct ieee80211_link_data *link,
3151 enum ieee80211_smps_mode smps_mode)
3154 enum ieee80211_smps_mode old_req;
3156 struct sta_info *sta;
3157 bool tdls_peer_found = false;
3159 lockdep_assert_wiphy(sdata->local->hw.wiphy);
3161 if (WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION))
3164 if (ieee80211_vif_is_mld(&sdata->vif) &&
3165 !(sdata->vif.active_links & BIT(link->link_id)))
3168 old_req = link->u.mgd.req_smps;
3169 link->u.mgd.req_smps = smps_mode;
3171 /* The driver indicated that EML is enabled for the interface, which
3172 * implies that SMPS flows towards the AP should be stopped.
3174 if (sdata->vif.driver_flags & IEEE80211_VIF_EML_ACTIVE)
3177 if (old_req == smps_mode &&
3178 smps_mode != IEEE80211_SMPS_AUTOMATIC)
3182 * If not associated, or current association is not an HT
3183 * association, there's no need to do anything, just store
3184 * the new value until we associate.
3186 if (!sdata->u.mgd.associated ||
3187 link->conf->chanreq.oper.width == NL80211_CHAN_WIDTH_20_NOHT)
3190 ap = sdata->vif.cfg.ap_addr;
3193 list_for_each_entry_rcu(sta, &sdata->local->sta_list, list) {
3194 if (!sta->sta.tdls || sta->sdata != sdata || !sta->uploaded ||
3195 !test_sta_flag(sta, WLAN_STA_AUTHORIZED))
3198 tdls_peer_found = true;
3203 if (smps_mode == IEEE80211_SMPS_AUTOMATIC) {
3204 if (tdls_peer_found || !sdata->u.mgd.powersave)
3205 smps_mode = IEEE80211_SMPS_OFF;
3207 smps_mode = IEEE80211_SMPS_DYNAMIC;
3210 /* send SM PS frame to AP */
3211 err = ieee80211_send_smps_action(sdata, smps_mode,
3213 ieee80211_vif_is_mld(&sdata->vif) ?
3214 link->link_id : -1);
3216 link->u.mgd.req_smps = old_req;
3217 else if (smps_mode != IEEE80211_SMPS_OFF && tdls_peer_found)
3218 ieee80211_teardown_tdls_peers(sdata);
3223 static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
3224 bool enabled, int timeout)
3226 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3227 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
3228 unsigned int link_id;
3230 if (sdata->vif.type != NL80211_IFTYPE_STATION)
3233 if (!ieee80211_hw_check(&local->hw, SUPPORTS_PS))
3236 if (enabled == sdata->u.mgd.powersave &&
3237 timeout == local->dynamic_ps_forced_timeout)
3240 sdata->u.mgd.powersave = enabled;
3241 local->dynamic_ps_forced_timeout = timeout;
3243 /* no change, but if automatic follow powersave */
3244 for (link_id = 0; link_id < ARRAY_SIZE(sdata->link); link_id++) {
3245 struct ieee80211_link_data *link;
3247 link = sdata_dereference(sdata->link[link_id], sdata);
3251 __ieee80211_request_smps_mgd(sdata, link,
3252 link->u.mgd.req_smps);
3255 if (ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS))
3256 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
3258 ieee80211_recalc_ps(local);
3259 ieee80211_recalc_ps_vif(sdata);
3260 ieee80211_check_fast_rx_iface(sdata);
3265 static int ieee80211_set_cqm_rssi_config(struct wiphy *wiphy,
3266 struct net_device *dev,
3267 s32 rssi_thold, u32 rssi_hyst)
3269 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3270 struct ieee80211_vif *vif = &sdata->vif;
3271 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
3273 if (rssi_thold == bss_conf->cqm_rssi_thold &&
3274 rssi_hyst == bss_conf->cqm_rssi_hyst)
3277 if (sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER &&
3278 !(sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI))
3281 bss_conf->cqm_rssi_thold = rssi_thold;
3282 bss_conf->cqm_rssi_hyst = rssi_hyst;
3283 bss_conf->cqm_rssi_low = 0;
3284 bss_conf->cqm_rssi_high = 0;
3285 sdata->deflink.u.mgd.last_cqm_event_signal = 0;
3287 /* tell the driver upon association, unless already associated */
3288 if (sdata->u.mgd.associated &&
3289 sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)
3290 ieee80211_link_info_change_notify(sdata, &sdata->deflink,
3296 static int ieee80211_set_cqm_rssi_range_config(struct wiphy *wiphy,
3297 struct net_device *dev,
3298 s32 rssi_low, s32 rssi_high)
3300 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3301 struct ieee80211_vif *vif = &sdata->vif;
3302 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
3304 if (sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER)
3307 bss_conf->cqm_rssi_low = rssi_low;
3308 bss_conf->cqm_rssi_high = rssi_high;
3309 bss_conf->cqm_rssi_thold = 0;
3310 bss_conf->cqm_rssi_hyst = 0;
3311 sdata->deflink.u.mgd.last_cqm_event_signal = 0;
3313 /* tell the driver upon association, unless already associated */
3314 if (sdata->u.mgd.associated &&
3315 sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)
3316 ieee80211_link_info_change_notify(sdata, &sdata->deflink,
3322 static int ieee80211_set_bitrate_mask(struct wiphy *wiphy,
3323 struct net_device *dev,
3324 unsigned int link_id,
3326 const struct cfg80211_bitrate_mask *mask)
3328 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3329 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
3332 if (!ieee80211_sdata_running(sdata))
3336 * If active validate the setting and reject it if it doesn't leave
3337 * at least one basic rate usable, since we really have to be able
3338 * to send something, and if we're an AP we have to be able to do
3339 * so at a basic rate so that all clients can receive it.
3341 if (rcu_access_pointer(sdata->vif.bss_conf.chanctx_conf) &&
3342 sdata->vif.bss_conf.chanreq.oper.chan) {
3343 u32 basic_rates = sdata->vif.bss_conf.basic_rates;
3344 enum nl80211_band band;
3346 band = sdata->vif.bss_conf.chanreq.oper.chan->band;
3348 if (!(mask->control[band].legacy & basic_rates))
3352 if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) {
3353 ret = drv_set_bitrate_mask(local, sdata, mask);
3358 for (i = 0; i < NUM_NL80211_BANDS; i++) {
3359 struct ieee80211_supported_band *sband = wiphy->bands[i];
3362 sdata->rc_rateidx_mask[i] = mask->control[i].legacy;
3363 memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].ht_mcs,
3364 sizeof(mask->control[i].ht_mcs));
3365 memcpy(sdata->rc_rateidx_vht_mcs_mask[i],
3366 mask->control[i].vht_mcs,
3367 sizeof(mask->control[i].vht_mcs));
3369 sdata->rc_has_mcs_mask[i] = false;
3370 sdata->rc_has_vht_mcs_mask[i] = false;
3374 for (j = 0; j < IEEE80211_HT_MCS_MASK_LEN; j++) {
3375 if (sdata->rc_rateidx_mcs_mask[i][j] != 0xff) {
3376 sdata->rc_has_mcs_mask[i] = true;
3381 for (j = 0; j < NL80211_VHT_NSS_MAX; j++) {
3382 if (sdata->rc_rateidx_vht_mcs_mask[i][j] != 0xffff) {
3383 sdata->rc_has_vht_mcs_mask[i] = true;
3392 static int ieee80211_start_radar_detection(struct wiphy *wiphy,
3393 struct net_device *dev,
3394 struct cfg80211_chan_def *chandef,
3397 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3398 struct ieee80211_chan_req chanreq = { .oper = *chandef };
3399 struct ieee80211_local *local = sdata->local;
3402 lockdep_assert_wiphy(local->hw.wiphy);
3404 if (!list_empty(&local->roc_list) || local->scanning) {
3409 /* whatever, but channel contexts should not complain about that one */
3410 sdata->deflink.smps_mode = IEEE80211_SMPS_OFF;
3411 sdata->deflink.needed_rx_chains = local->rx_chains;
3413 err = ieee80211_link_use_channel(&sdata->deflink, &chanreq,
3414 IEEE80211_CHANCTX_SHARED);
3418 wiphy_delayed_work_queue(wiphy, &sdata->deflink.dfs_cac_timer_work,
3419 msecs_to_jiffies(cac_time_ms));
3425 static void ieee80211_end_cac(struct wiphy *wiphy,
3426 struct net_device *dev)
3428 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3429 struct ieee80211_local *local = sdata->local;
3431 lockdep_assert_wiphy(local->hw.wiphy);
3433 list_for_each_entry(sdata, &local->interfaces, list) {
3434 /* it might be waiting for the local->mtx, but then
3435 * by the time it gets it, sdata->wdev.cac_started
3436 * will no longer be true
3438 wiphy_delayed_work_cancel(wiphy,
3439 &sdata->deflink.dfs_cac_timer_work);
3441 if (sdata->wdev.cac_started) {
3442 ieee80211_link_release_channel(&sdata->deflink);
3443 sdata->wdev.cac_started = false;
3448 static struct cfg80211_beacon_data *
3449 cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon)
3451 struct cfg80211_beacon_data *new_beacon;
3455 len = beacon->head_len + beacon->tail_len + beacon->beacon_ies_len +
3456 beacon->proberesp_ies_len + beacon->assocresp_ies_len +
3457 beacon->probe_resp_len + beacon->lci_len + beacon->civicloc_len;
3459 if (beacon->mbssid_ies)
3460 len += ieee80211_get_mbssid_beacon_len(beacon->mbssid_ies,
3462 beacon->mbssid_ies->cnt);
3464 new_beacon = kzalloc(sizeof(*new_beacon) + len, GFP_KERNEL);
3468 if (beacon->mbssid_ies && beacon->mbssid_ies->cnt) {
3469 new_beacon->mbssid_ies =
3470 kzalloc(struct_size(new_beacon->mbssid_ies,
3471 elem, beacon->mbssid_ies->cnt),
3473 if (!new_beacon->mbssid_ies) {
3478 if (beacon->rnr_ies && beacon->rnr_ies->cnt) {
3479 new_beacon->rnr_ies =
3480 kzalloc(struct_size(new_beacon->rnr_ies,
3481 elem, beacon->rnr_ies->cnt),
3483 if (!new_beacon->rnr_ies) {
3484 kfree(new_beacon->mbssid_ies);
3491 pos = (u8 *)(new_beacon + 1);
3492 if (beacon->head_len) {
3493 new_beacon->head_len = beacon->head_len;
3494 new_beacon->head = pos;
3495 memcpy(pos, beacon->head, beacon->head_len);
3496 pos += beacon->head_len;
3498 if (beacon->tail_len) {
3499 new_beacon->tail_len = beacon->tail_len;
3500 new_beacon->tail = pos;
3501 memcpy(pos, beacon->tail, beacon->tail_len);
3502 pos += beacon->tail_len;
3504 if (beacon->beacon_ies_len) {
3505 new_beacon->beacon_ies_len = beacon->beacon_ies_len;
3506 new_beacon->beacon_ies = pos;
3507 memcpy(pos, beacon->beacon_ies, beacon->beacon_ies_len);
3508 pos += beacon->beacon_ies_len;
3510 if (beacon->proberesp_ies_len) {
3511 new_beacon->proberesp_ies_len = beacon->proberesp_ies_len;
3512 new_beacon->proberesp_ies = pos;
3513 memcpy(pos, beacon->proberesp_ies, beacon->proberesp_ies_len);
3514 pos += beacon->proberesp_ies_len;
3516 if (beacon->assocresp_ies_len) {
3517 new_beacon->assocresp_ies_len = beacon->assocresp_ies_len;
3518 new_beacon->assocresp_ies = pos;
3519 memcpy(pos, beacon->assocresp_ies, beacon->assocresp_ies_len);
3520 pos += beacon->assocresp_ies_len;
3522 if (beacon->probe_resp_len) {
3523 new_beacon->probe_resp_len = beacon->probe_resp_len;
3524 new_beacon->probe_resp = pos;
3525 memcpy(pos, beacon->probe_resp, beacon->probe_resp_len);
3526 pos += beacon->probe_resp_len;
3528 if (beacon->mbssid_ies && beacon->mbssid_ies->cnt) {
3529 pos += ieee80211_copy_mbssid_beacon(pos,
3530 new_beacon->mbssid_ies,
3531 beacon->mbssid_ies);
3532 if (beacon->rnr_ies && beacon->rnr_ies->cnt)
3533 pos += ieee80211_copy_rnr_beacon(pos,
3534 new_beacon->rnr_ies,
3538 /* might copy -1, meaning no changes requested */
3539 new_beacon->ftm_responder = beacon->ftm_responder;
3541 new_beacon->lci_len = beacon->lci_len;
3542 new_beacon->lci = pos;
3543 memcpy(pos, beacon->lci, beacon->lci_len);
3544 pos += beacon->lci_len;
3546 if (beacon->civicloc) {
3547 new_beacon->civicloc_len = beacon->civicloc_len;
3548 new_beacon->civicloc = pos;
3549 memcpy(pos, beacon->civicloc, beacon->civicloc_len);
3550 pos += beacon->civicloc_len;
3556 void ieee80211_csa_finish(struct ieee80211_vif *vif, unsigned int link_id)
3558 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
3559 struct ieee80211_local *local = sdata->local;
3560 struct ieee80211_link_data *link_data;
3562 if (WARN_ON(link_id >= IEEE80211_MLD_MAX_NUM_LINKS))
3567 link_data = rcu_dereference(sdata->link[link_id]);
3568 if (WARN_ON(!link_data)) {
3573 /* TODO: MBSSID with MLO changes */
3574 if (vif->mbssid_tx_vif == vif) {
3575 /* Trigger ieee80211_csa_finish() on the non-transmitting
3576 * interfaces when channel switch is received on
3577 * transmitting interface
3579 struct ieee80211_sub_if_data *iter;
3581 list_for_each_entry_rcu(iter, &local->interfaces, list) {
3582 if (!ieee80211_sdata_running(iter))
3585 if (iter == sdata || iter->vif.mbssid_tx_vif != vif)
3588 wiphy_work_queue(iter->local->hw.wiphy,
3589 &iter->deflink.csa_finalize_work);
3592 wiphy_work_queue(local->hw.wiphy, &link_data->csa_finalize_work);
3596 EXPORT_SYMBOL(ieee80211_csa_finish);
3598 void ieee80211_channel_switch_disconnect(struct ieee80211_vif *vif, bool block_tx)
3600 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
3601 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
3602 struct ieee80211_local *local = sdata->local;
3604 sdata->deflink.csa_block_tx = block_tx;
3605 sdata_info(sdata, "channel switch failed, disconnecting\n");
3606 wiphy_work_queue(local->hw.wiphy, &ifmgd->csa_connection_drop_work);
3608 EXPORT_SYMBOL(ieee80211_channel_switch_disconnect);
3610 static int ieee80211_set_after_csa_beacon(struct ieee80211_link_data *link_data,
3613 struct ieee80211_sub_if_data *sdata = link_data->sdata;
3616 switch (sdata->vif.type) {
3617 case NL80211_IFTYPE_AP:
3618 if (!link_data->u.ap.next_beacon)
3621 err = ieee80211_assign_beacon(sdata, link_data,
3622 link_data->u.ap.next_beacon,
3623 NULL, NULL, changed);
3624 ieee80211_free_next_beacon(link_data);
3629 case NL80211_IFTYPE_ADHOC:
3630 err = ieee80211_ibss_finish_csa(sdata, changed);
3634 #ifdef CONFIG_MAC80211_MESH
3635 case NL80211_IFTYPE_MESH_POINT:
3636 err = ieee80211_mesh_finish_csa(sdata, changed);
3649 static int __ieee80211_csa_finalize(struct ieee80211_link_data *link_data)
3651 struct ieee80211_sub_if_data *sdata = link_data->sdata;
3652 struct ieee80211_local *local = sdata->local;
3653 struct ieee80211_bss_conf *link_conf = link_data->conf;
3657 lockdep_assert_wiphy(local->hw.wiphy);
3660 * using reservation isn't immediate as it may be deferred until later
3661 * with multi-vif. once reservation is complete it will re-schedule the
3662 * work with no reserved_chanctx so verify chandef to check if it
3663 * completed successfully
3666 if (link_data->reserved_chanctx) {
3668 * with multi-vif csa driver may call ieee80211_csa_finish()
3669 * many times while waiting for other interfaces to use their
3672 if (link_data->reserved_ready)
3675 return ieee80211_link_use_reserved_context(link_data);
3678 if (!cfg80211_chandef_identical(&link_conf->chanreq.oper,
3679 &link_data->csa_chanreq.oper))
3682 link_conf->csa_active = false;
3684 err = ieee80211_set_after_csa_beacon(link_data, &changed);
3688 ieee80211_link_info_change_notify(sdata, link_data, changed);
3690 if (link_data->csa_block_tx) {
3691 ieee80211_wake_vif_queues(local, sdata,
3692 IEEE80211_QUEUE_STOP_REASON_CSA);
3693 link_data->csa_block_tx = false;
3696 err = drv_post_channel_switch(link_data);
3700 cfg80211_ch_switch_notify(sdata->dev, &link_data->csa_chanreq.oper,
3701 link_data->link_id);
3706 static void ieee80211_csa_finalize(struct ieee80211_link_data *link_data)
3708 struct ieee80211_sub_if_data *sdata = link_data->sdata;
3710 if (__ieee80211_csa_finalize(link_data)) {
3711 sdata_info(sdata, "failed to finalize CSA on link %d, disconnecting\n",
3712 link_data->link_id);
3713 cfg80211_stop_iface(sdata->local->hw.wiphy, &sdata->wdev,
3718 void ieee80211_csa_finalize_work(struct wiphy *wiphy, struct wiphy_work *work)
3720 struct ieee80211_link_data *link =
3721 container_of(work, struct ieee80211_link_data, csa_finalize_work);
3722 struct ieee80211_sub_if_data *sdata = link->sdata;
3723 struct ieee80211_local *local = sdata->local;
3725 lockdep_assert_wiphy(local->hw.wiphy);
3727 /* AP might have been stopped while waiting for the lock. */
3728 if (!link->conf->csa_active)
3731 if (!ieee80211_sdata_running(sdata))
3734 ieee80211_csa_finalize(link);
3737 static int ieee80211_set_csa_beacon(struct ieee80211_link_data *link_data,
3738 struct cfg80211_csa_settings *params,
3741 struct ieee80211_sub_if_data *sdata = link_data->sdata;
3742 struct ieee80211_csa_settings csa = {};
3745 switch (sdata->vif.type) {
3746 case NL80211_IFTYPE_AP:
3747 link_data->u.ap.next_beacon =
3748 cfg80211_beacon_dup(¶ms->beacon_after);
3749 if (!link_data->u.ap.next_beacon)
3753 * With a count of 0, we don't have to wait for any
3754 * TBTT before switching, so complete the CSA
3755 * immediately. In theory, with a count == 1 we
3756 * should delay the switch until just before the next
3757 * TBTT, but that would complicate things so we switch
3758 * immediately too. If we would delay the switch
3759 * until the next TBTT, we would have to set the probe
3762 * TODO: A channel switch with count <= 1 without
3763 * sending a CSA action frame is kind of useless,
3764 * because the clients won't know we're changing
3765 * channels. The action frame must be implemented
3766 * either here or in the userspace.
3768 if (params->count <= 1)
3771 if ((params->n_counter_offsets_beacon >
3772 IEEE80211_MAX_CNTDWN_COUNTERS_NUM) ||
3773 (params->n_counter_offsets_presp >
3774 IEEE80211_MAX_CNTDWN_COUNTERS_NUM)) {
3775 ieee80211_free_next_beacon(link_data);
3779 csa.counter_offsets_beacon = params->counter_offsets_beacon;
3780 csa.counter_offsets_presp = params->counter_offsets_presp;
3781 csa.n_counter_offsets_beacon = params->n_counter_offsets_beacon;
3782 csa.n_counter_offsets_presp = params->n_counter_offsets_presp;
3783 csa.count = params->count;
3785 err = ieee80211_assign_beacon(sdata, link_data,
3786 ¶ms->beacon_csa, &csa,
3789 ieee80211_free_next_beacon(link_data);
3794 case NL80211_IFTYPE_ADHOC:
3795 if (!sdata->vif.cfg.ibss_joined)
3798 if (params->chandef.width != sdata->u.ibss.chandef.width)
3801 switch (params->chandef.width) {
3802 case NL80211_CHAN_WIDTH_40:
3803 if (cfg80211_get_chandef_type(¶ms->chandef) !=
3804 cfg80211_get_chandef_type(&sdata->u.ibss.chandef))
3807 case NL80211_CHAN_WIDTH_5:
3808 case NL80211_CHAN_WIDTH_10:
3809 case NL80211_CHAN_WIDTH_20_NOHT:
3810 case NL80211_CHAN_WIDTH_20:
3816 /* changes into another band are not supported */
3817 if (sdata->u.ibss.chandef.chan->band !=
3818 params->chandef.chan->band)
3821 /* see comments in the NL80211_IFTYPE_AP block */
3822 if (params->count > 1) {
3823 err = ieee80211_ibss_csa_beacon(sdata, params, changed);
3828 ieee80211_send_action_csa(sdata, params);
3831 #ifdef CONFIG_MAC80211_MESH
3832 case NL80211_IFTYPE_MESH_POINT: {
3833 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
3835 /* changes into another band are not supported */
3836 if (sdata->vif.bss_conf.chanreq.oper.chan->band !=
3837 params->chandef.chan->band)
3840 if (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_NONE) {
3841 ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_INIT;
3842 if (!ifmsh->pre_value)
3843 ifmsh->pre_value = 1;
3848 /* see comments in the NL80211_IFTYPE_AP block */
3849 if (params->count > 1) {
3850 err = ieee80211_mesh_csa_beacon(sdata, params, changed);
3852 ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_NONE;
3857 if (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_INIT)
3858 ieee80211_send_action_csa(sdata, params);
3870 static void ieee80211_color_change_abort(struct ieee80211_sub_if_data *sdata)
3872 sdata->vif.bss_conf.color_change_active = false;
3874 ieee80211_free_next_beacon(&sdata->deflink);
3876 cfg80211_color_change_aborted_notify(sdata->dev);
3880 __ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
3881 struct cfg80211_csa_settings *params)
3883 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3884 struct ieee80211_chan_req chanreq = { .oper = params->chandef };
3885 struct ieee80211_local *local = sdata->local;
3886 struct ieee80211_channel_switch ch_switch;
3887 struct ieee80211_chanctx_conf *conf;
3888 struct ieee80211_chanctx *chanctx;
3889 struct ieee80211_bss_conf *link_conf;
3890 struct ieee80211_link_data *link_data;
3892 u8 link_id = params->link_id;
3895 lockdep_assert_wiphy(local->hw.wiphy);
3897 if (!list_empty(&local->roc_list) || local->scanning)
3900 if (sdata->wdev.cac_started)
3903 if (WARN_ON(link_id >= IEEE80211_MLD_MAX_NUM_LINKS))
3906 link_data = wiphy_dereference(wiphy, sdata->link[link_id]);
3910 link_conf = link_data->conf;
3912 if (chanreq.oper.punctured && !link_conf->eht_support)
3915 /* don't allow another channel switch if one is already active. */
3916 if (link_conf->csa_active)
3919 conf = wiphy_dereference(wiphy, link_conf->chanctx_conf);
3925 if (params->chandef.chan->freq_offset) {
3926 /* this may work, but is untested */
3931 chanctx = container_of(conf, struct ieee80211_chanctx, conf);
3933 ch_switch.timestamp = 0;
3934 ch_switch.device_timestamp = 0;
3935 ch_switch.block_tx = params->block_tx;
3936 ch_switch.chandef = chanreq.oper;
3937 ch_switch.count = params->count;
3939 err = drv_pre_channel_switch(sdata, &ch_switch);
3943 err = ieee80211_link_reserve_chanctx(link_data, &chanreq,
3945 params->radar_required);
3949 /* if reservation is invalid then this will fail */
3950 err = ieee80211_check_combinations(sdata, NULL, chanctx->mode, 0);
3952 ieee80211_link_unreserve_chanctx(link_data);
3956 /* if there is a color change in progress, abort it */
3957 if (link_conf->color_change_active)
3958 ieee80211_color_change_abort(sdata);
3960 err = ieee80211_set_csa_beacon(link_data, params, &changed);
3962 ieee80211_link_unreserve_chanctx(link_data);
3966 link_data->csa_chanreq = chanreq;
3967 link_data->csa_block_tx = params->block_tx;
3968 link_conf->csa_active = true;
3970 if (link_data->csa_block_tx)
3971 ieee80211_stop_vif_queues(local, sdata,
3972 IEEE80211_QUEUE_STOP_REASON_CSA);
3974 cfg80211_ch_switch_started_notify(sdata->dev,
3975 &link_data->csa_chanreq.oper, 0,
3976 params->count, params->block_tx);
3979 ieee80211_link_info_change_notify(sdata, link_data, changed);
3980 drv_channel_switch_beacon(sdata, &link_data->csa_chanreq.oper);
3982 /* if the beacon didn't change, we can finalize immediately */
3983 ieee80211_csa_finalize(link_data);
3990 int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
3991 struct cfg80211_csa_settings *params)
3993 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3994 struct ieee80211_local *local = sdata->local;
3996 lockdep_assert_wiphy(local->hw.wiphy);
3998 return __ieee80211_channel_switch(wiphy, dev, params);
4001 u64 ieee80211_mgmt_tx_cookie(struct ieee80211_local *local)
4003 lockdep_assert_wiphy(local->hw.wiphy);
4005 local->roc_cookie_counter++;
4007 /* wow, you wrapped 64 bits ... more likely a bug */
4008 if (WARN_ON(local->roc_cookie_counter == 0))
4009 local->roc_cookie_counter++;
4011 return local->roc_cookie_counter;
4014 int ieee80211_attach_ack_skb(struct ieee80211_local *local, struct sk_buff *skb,
4015 u64 *cookie, gfp_t gfp)
4017 unsigned long spin_flags;
4018 struct sk_buff *ack_skb;
4021 ack_skb = skb_copy(skb, gfp);
4025 spin_lock_irqsave(&local->ack_status_lock, spin_flags);
4026 id = idr_alloc(&local->ack_status_frames, ack_skb,
4027 1, 0x2000, GFP_ATOMIC);
4028 spin_unlock_irqrestore(&local->ack_status_lock, spin_flags);
4035 IEEE80211_SKB_CB(skb)->status_data_idr = 1;
4036 IEEE80211_SKB_CB(skb)->status_data = id;
4038 *cookie = ieee80211_mgmt_tx_cookie(local);
4039 IEEE80211_SKB_CB(ack_skb)->ack.cookie = *cookie;
4045 ieee80211_update_mgmt_frame_registrations(struct wiphy *wiphy,
4046 struct wireless_dev *wdev,
4047 struct mgmt_frame_regs *upd)
4049 struct ieee80211_local *local = wiphy_priv(wiphy);
4050 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
4051 u32 preq_mask = BIT(IEEE80211_STYPE_PROBE_REQ >> 4);
4052 u32 action_mask = BIT(IEEE80211_STYPE_ACTION >> 4);
4053 bool global_change, intf_change;
4056 (local->probe_req_reg != !!(upd->global_stypes & preq_mask)) ||
4057 (local->rx_mcast_action_reg !=
4058 !!(upd->global_mcast_stypes & action_mask));
4059 local->probe_req_reg = upd->global_stypes & preq_mask;
4060 local->rx_mcast_action_reg = upd->global_mcast_stypes & action_mask;
4062 intf_change = (sdata->vif.probe_req_reg !=
4063 !!(upd->interface_stypes & preq_mask)) ||
4064 (sdata->vif.rx_mcast_action_reg !=
4065 !!(upd->interface_mcast_stypes & action_mask));
4066 sdata->vif.probe_req_reg = upd->interface_stypes & preq_mask;
4067 sdata->vif.rx_mcast_action_reg =
4068 upd->interface_mcast_stypes & action_mask;
4070 if (!local->open_count)
4073 if (intf_change && ieee80211_sdata_running(sdata))
4074 drv_config_iface_filter(local, sdata,
4075 sdata->vif.probe_req_reg ?
4080 ieee80211_configure_filter(local);
4083 static int ieee80211_set_antenna(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant)
4085 struct ieee80211_local *local = wiphy_priv(wiphy);
4091 ret = drv_set_antenna(local, tx_ant, rx_ant);
4095 local->rx_chains = hweight8(rx_ant);
4099 static int ieee80211_get_antenna(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant)
4101 struct ieee80211_local *local = wiphy_priv(wiphy);
4103 return drv_get_antenna(local, tx_ant, rx_ant);
4106 static int ieee80211_set_rekey_data(struct wiphy *wiphy,
4107 struct net_device *dev,
4108 struct cfg80211_gtk_rekey_data *data)
4110 struct ieee80211_local *local = wiphy_priv(wiphy);
4111 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4113 if (!local->ops->set_rekey_data)
4116 drv_set_rekey_data(local, sdata, data);
4121 static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev,
4122 const u8 *peer, u64 *cookie)
4124 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4125 struct ieee80211_local *local = sdata->local;
4126 struct ieee80211_qos_hdr *nullfunc;
4127 struct sk_buff *skb;
4128 int size = sizeof(*nullfunc);
4131 struct ieee80211_tx_info *info;
4132 struct sta_info *sta;
4133 struct ieee80211_chanctx_conf *chanctx_conf;
4134 enum nl80211_band band;
4137 /* the lock is needed to assign the cookie later */
4138 lockdep_assert_wiphy(local->hw.wiphy);
4141 sta = sta_info_get_bss(sdata, peer);
4149 chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf);
4150 if (WARN_ON(!chanctx_conf)) {
4154 band = chanctx_conf->def.chan->band;
4157 fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
4158 IEEE80211_STYPE_QOS_NULLFUNC |
4159 IEEE80211_FCTL_FROMDS);
4162 fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
4163 IEEE80211_STYPE_NULLFUNC |
4164 IEEE80211_FCTL_FROMDS);
4167 skb = dev_alloc_skb(local->hw.extra_tx_headroom + size);
4175 skb_reserve(skb, local->hw.extra_tx_headroom);
4177 nullfunc = skb_put(skb, size);
4178 nullfunc->frame_control = fc;
4179 nullfunc->duration_id = 0;
4180 memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN);
4181 memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN);
4182 memcpy(nullfunc->addr3, sdata->vif.addr, ETH_ALEN);
4183 nullfunc->seq_ctrl = 0;
4185 info = IEEE80211_SKB_CB(skb);
4187 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS |
4188 IEEE80211_TX_INTFL_NL80211_FRAME_TX;
4191 skb_set_queue_mapping(skb, IEEE80211_AC_VO);
4194 nullfunc->qos_ctrl = cpu_to_le16(7);
4196 ret = ieee80211_attach_ack_skb(local, skb, cookie, GFP_ATOMIC);
4203 ieee80211_xmit(sdata, sta, skb);
4213 static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
4214 struct wireless_dev *wdev,
4215 unsigned int link_id,
4216 struct cfg80211_chan_def *chandef)
4218 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
4219 struct ieee80211_local *local = wiphy_priv(wiphy);
4220 struct ieee80211_chanctx_conf *chanctx_conf;
4221 struct ieee80211_link_data *link;
4225 link = rcu_dereference(sdata->link[link_id]);
4231 chanctx_conf = rcu_dereference(link->conf->chanctx_conf);
4233 *chandef = link->conf->chanreq.oper;
4235 } else if (local->open_count > 0 &&
4236 local->open_count == local->monitors &&
4237 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
4238 *chandef = local->monitor_chanreq.oper;
4248 static void ieee80211_set_wakeup(struct wiphy *wiphy, bool enabled)
4250 drv_set_wakeup(wiphy_priv(wiphy), enabled);
4254 static int ieee80211_set_qos_map(struct wiphy *wiphy,
4255 struct net_device *dev,
4256 struct cfg80211_qos_map *qos_map)
4258 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4259 struct mac80211_qos_map *new_qos_map, *old_qos_map;
4262 new_qos_map = kzalloc(sizeof(*new_qos_map), GFP_KERNEL);
4265 memcpy(&new_qos_map->qos_map, qos_map, sizeof(*qos_map));
4267 /* A NULL qos_map was passed to disable QoS mapping */
4271 old_qos_map = sdata_dereference(sdata->qos_map, sdata);
4272 rcu_assign_pointer(sdata->qos_map, new_qos_map);
4274 kfree_rcu(old_qos_map, rcu_head);
4279 static int ieee80211_set_ap_chanwidth(struct wiphy *wiphy,
4280 struct net_device *dev,
4281 unsigned int link_id,
4282 struct cfg80211_chan_def *chandef)
4284 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4285 struct ieee80211_link_data *link;
4286 struct ieee80211_chan_req chanreq = { .oper = *chandef };
4290 link = sdata_dereference(sdata->link[link_id], sdata);
4292 ret = ieee80211_link_change_chanreq(link, &chanreq, &changed);
4294 ieee80211_link_info_change_notify(sdata, link, changed);
4299 static int ieee80211_add_tx_ts(struct wiphy *wiphy, struct net_device *dev,
4300 u8 tsid, const u8 *peer, u8 up,
4303 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4304 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
4305 int ac = ieee802_1d_to_ac[up];
4307 if (sdata->vif.type != NL80211_IFTYPE_STATION)
4310 if (!(sdata->wmm_acm & BIT(up)))
4313 if (ifmgd->tx_tspec[ac].admitted_time)
4316 if (admitted_time) {
4317 ifmgd->tx_tspec[ac].admitted_time = 32 * admitted_time;
4318 ifmgd->tx_tspec[ac].tsid = tsid;
4319 ifmgd->tx_tspec[ac].up = up;
4325 static int ieee80211_del_tx_ts(struct wiphy *wiphy, struct net_device *dev,
4326 u8 tsid, const u8 *peer)
4328 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4329 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
4330 struct ieee80211_local *local = wiphy_priv(wiphy);
4333 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
4334 struct ieee80211_sta_tx_tspec *tx_tspec = &ifmgd->tx_tspec[ac];
4336 /* skip unused entries */
4337 if (!tx_tspec->admitted_time)
4340 if (tx_tspec->tsid != tsid)
4343 /* due to this new packets will be reassigned to non-ACM ACs */
4346 /* Make sure that all packets have been sent to avoid to
4347 * restore the QoS params on packets that are still on the
4351 ieee80211_flush_queues(local, sdata, false);
4353 /* restore the normal QoS parameters
4354 * (unconditionally to avoid races)
4356 tx_tspec->action = TX_TSPEC_ACTION_STOP_DOWNGRADE;
4357 tx_tspec->downgraded = false;
4358 ieee80211_sta_handle_tspec_ac_params(sdata);
4360 /* finally clear all the data */
4361 memset(tx_tspec, 0, sizeof(*tx_tspec));
4369 void ieee80211_nan_func_terminated(struct ieee80211_vif *vif,
4371 enum nl80211_nan_func_term_reason reason,
4374 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
4375 struct cfg80211_nan_func *func;
4378 if (WARN_ON(vif->type != NL80211_IFTYPE_NAN))
4381 spin_lock_bh(&sdata->u.nan.func_lock);
4383 func = idr_find(&sdata->u.nan.function_inst_ids, inst_id);
4384 if (WARN_ON(!func)) {
4385 spin_unlock_bh(&sdata->u.nan.func_lock);
4389 cookie = func->cookie;
4390 idr_remove(&sdata->u.nan.function_inst_ids, inst_id);
4392 spin_unlock_bh(&sdata->u.nan.func_lock);
4394 cfg80211_free_nan_func(func);
4396 cfg80211_nan_func_terminated(ieee80211_vif_to_wdev(vif), inst_id,
4397 reason, cookie, gfp);
4399 EXPORT_SYMBOL(ieee80211_nan_func_terminated);
4401 void ieee80211_nan_func_match(struct ieee80211_vif *vif,
4402 struct cfg80211_nan_match_params *match,
4405 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
4406 struct cfg80211_nan_func *func;
4408 if (WARN_ON(vif->type != NL80211_IFTYPE_NAN))
4411 spin_lock_bh(&sdata->u.nan.func_lock);
4413 func = idr_find(&sdata->u.nan.function_inst_ids, match->inst_id);
4414 if (WARN_ON(!func)) {
4415 spin_unlock_bh(&sdata->u.nan.func_lock);
4418 match->cookie = func->cookie;
4420 spin_unlock_bh(&sdata->u.nan.func_lock);
4422 cfg80211_nan_match(ieee80211_vif_to_wdev(vif), match, gfp);
4424 EXPORT_SYMBOL(ieee80211_nan_func_match);
4426 static int ieee80211_set_multicast_to_unicast(struct wiphy *wiphy,
4427 struct net_device *dev,
4430 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4432 sdata->u.ap.multicast_to_unicast = enabled;
4437 void ieee80211_fill_txq_stats(struct cfg80211_txq_stats *txqstats,
4438 struct txq_info *txqi)
4440 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_BACKLOG_BYTES))) {
4441 txqstats->filled |= BIT(NL80211_TXQ_STATS_BACKLOG_BYTES);
4442 txqstats->backlog_bytes = txqi->tin.backlog_bytes;
4445 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_BACKLOG_PACKETS))) {
4446 txqstats->filled |= BIT(NL80211_TXQ_STATS_BACKLOG_PACKETS);
4447 txqstats->backlog_packets = txqi->tin.backlog_packets;
4450 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_FLOWS))) {
4451 txqstats->filled |= BIT(NL80211_TXQ_STATS_FLOWS);
4452 txqstats->flows = txqi->tin.flows;
4455 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_DROPS))) {
4456 txqstats->filled |= BIT(NL80211_TXQ_STATS_DROPS);
4457 txqstats->drops = txqi->cstats.drop_count;
4460 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_ECN_MARKS))) {
4461 txqstats->filled |= BIT(NL80211_TXQ_STATS_ECN_MARKS);
4462 txqstats->ecn_marks = txqi->cstats.ecn_mark;
4465 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_OVERLIMIT))) {
4466 txqstats->filled |= BIT(NL80211_TXQ_STATS_OVERLIMIT);
4467 txqstats->overlimit = txqi->tin.overlimit;
4470 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_COLLISIONS))) {
4471 txqstats->filled |= BIT(NL80211_TXQ_STATS_COLLISIONS);
4472 txqstats->collisions = txqi->tin.collisions;
4475 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_TX_BYTES))) {
4476 txqstats->filled |= BIT(NL80211_TXQ_STATS_TX_BYTES);
4477 txqstats->tx_bytes = txqi->tin.tx_bytes;
4480 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_TX_PACKETS))) {
4481 txqstats->filled |= BIT(NL80211_TXQ_STATS_TX_PACKETS);
4482 txqstats->tx_packets = txqi->tin.tx_packets;
4486 static int ieee80211_get_txq_stats(struct wiphy *wiphy,
4487 struct wireless_dev *wdev,
4488 struct cfg80211_txq_stats *txqstats)
4490 struct ieee80211_local *local = wiphy_priv(wiphy);
4491 struct ieee80211_sub_if_data *sdata;
4494 spin_lock_bh(&local->fq.lock);
4498 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
4499 if (!sdata->vif.txq) {
4503 ieee80211_fill_txq_stats(txqstats, to_txq_info(sdata->vif.txq));
4506 txqstats->filled |= BIT(NL80211_TXQ_STATS_BACKLOG_PACKETS) |
4507 BIT(NL80211_TXQ_STATS_BACKLOG_BYTES) |
4508 BIT(NL80211_TXQ_STATS_OVERLIMIT) |
4509 BIT(NL80211_TXQ_STATS_OVERMEMORY) |
4510 BIT(NL80211_TXQ_STATS_COLLISIONS) |
4511 BIT(NL80211_TXQ_STATS_MAX_FLOWS);
4512 txqstats->backlog_packets = local->fq.backlog;
4513 txqstats->backlog_bytes = local->fq.memory_usage;
4514 txqstats->overlimit = local->fq.overlimit;
4515 txqstats->overmemory = local->fq.overmemory;
4516 txqstats->collisions = local->fq.collisions;
4517 txqstats->max_flows = local->fq.flows_cnt;
4522 spin_unlock_bh(&local->fq.lock);
4528 ieee80211_get_ftm_responder_stats(struct wiphy *wiphy,
4529 struct net_device *dev,
4530 struct cfg80211_ftm_responder_stats *ftm_stats)
4532 struct ieee80211_local *local = wiphy_priv(wiphy);
4533 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4535 return drv_get_ftm_responder_stats(local, sdata, ftm_stats);
4539 ieee80211_start_pmsr(struct wiphy *wiphy, struct wireless_dev *dev,
4540 struct cfg80211_pmsr_request *request)
4542 struct ieee80211_local *local = wiphy_priv(wiphy);
4543 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(dev);
4545 return drv_start_pmsr(local, sdata, request);
4549 ieee80211_abort_pmsr(struct wiphy *wiphy, struct wireless_dev *dev,
4550 struct cfg80211_pmsr_request *request)
4552 struct ieee80211_local *local = wiphy_priv(wiphy);
4553 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(dev);
4555 return drv_abort_pmsr(local, sdata, request);
4558 static int ieee80211_set_tid_config(struct wiphy *wiphy,
4559 struct net_device *dev,
4560 struct cfg80211_tid_config *tid_conf)
4562 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4563 struct sta_info *sta;
4565 lockdep_assert_wiphy(sdata->local->hw.wiphy);
4567 if (!sdata->local->ops->set_tid_config)
4570 if (!tid_conf->peer)
4571 return drv_set_tid_config(sdata->local, sdata, NULL, tid_conf);
4573 sta = sta_info_get_bss(sdata, tid_conf->peer);
4577 return drv_set_tid_config(sdata->local, sdata, &sta->sta, tid_conf);
4580 static int ieee80211_reset_tid_config(struct wiphy *wiphy,
4581 struct net_device *dev,
4582 const u8 *peer, u8 tids)
4584 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4585 struct sta_info *sta;
4587 lockdep_assert_wiphy(sdata->local->hw.wiphy);
4589 if (!sdata->local->ops->reset_tid_config)
4593 return drv_reset_tid_config(sdata->local, sdata, NULL, tids);
4595 sta = sta_info_get_bss(sdata, peer);
4599 return drv_reset_tid_config(sdata->local, sdata, &sta->sta, tids);
4602 static int ieee80211_set_sar_specs(struct wiphy *wiphy,
4603 struct cfg80211_sar_specs *sar)
4605 struct ieee80211_local *local = wiphy_priv(wiphy);
4607 if (!local->ops->set_sar_specs)
4610 return local->ops->set_sar_specs(&local->hw, sar);
4614 ieee80211_set_after_color_change_beacon(struct ieee80211_sub_if_data *sdata,
4617 switch (sdata->vif.type) {
4618 case NL80211_IFTYPE_AP: {
4621 if (!sdata->deflink.u.ap.next_beacon)
4624 ret = ieee80211_assign_beacon(sdata, &sdata->deflink,
4625 sdata->deflink.u.ap.next_beacon,
4626 NULL, NULL, changed);
4627 ieee80211_free_next_beacon(&sdata->deflink);
4643 ieee80211_set_color_change_beacon(struct ieee80211_sub_if_data *sdata,
4644 struct cfg80211_color_change_settings *params,
4647 struct ieee80211_color_change_settings color_change = {};
4650 switch (sdata->vif.type) {
4651 case NL80211_IFTYPE_AP:
4652 sdata->deflink.u.ap.next_beacon =
4653 cfg80211_beacon_dup(¶ms->beacon_next);
4654 if (!sdata->deflink.u.ap.next_beacon)
4657 if (params->count <= 1)
4660 color_change.counter_offset_beacon =
4661 params->counter_offset_beacon;
4662 color_change.counter_offset_presp =
4663 params->counter_offset_presp;
4664 color_change.count = params->count;
4666 err = ieee80211_assign_beacon(sdata, &sdata->deflink,
4667 ¶ms->beacon_color_change,
4668 NULL, &color_change, changed);
4670 ieee80211_free_next_beacon(&sdata->deflink);
4682 ieee80211_color_change_bss_config_notify(struct ieee80211_sub_if_data *sdata,
4683 u8 color, int enable, u64 changed)
4685 lockdep_assert_wiphy(sdata->local->hw.wiphy);
4687 sdata->vif.bss_conf.he_bss_color.color = color;
4688 sdata->vif.bss_conf.he_bss_color.enabled = enable;
4689 changed |= BSS_CHANGED_HE_BSS_COLOR;
4691 ieee80211_link_info_change_notify(sdata, &sdata->deflink, changed);
4693 if (!sdata->vif.bss_conf.nontransmitted && sdata->vif.mbssid_tx_vif) {
4694 struct ieee80211_sub_if_data *child;
4696 list_for_each_entry(child, &sdata->local->interfaces, list) {
4697 if (child != sdata && child->vif.mbssid_tx_vif == &sdata->vif) {
4698 child->vif.bss_conf.he_bss_color.color = color;
4699 child->vif.bss_conf.he_bss_color.enabled = enable;
4700 ieee80211_link_info_change_notify(child,
4702 BSS_CHANGED_HE_BSS_COLOR);
4708 static int ieee80211_color_change_finalize(struct ieee80211_sub_if_data *sdata)
4710 struct ieee80211_local *local = sdata->local;
4714 lockdep_assert_wiphy(local->hw.wiphy);
4716 sdata->vif.bss_conf.color_change_active = false;
4718 err = ieee80211_set_after_color_change_beacon(sdata, &changed);
4720 cfg80211_color_change_aborted_notify(sdata->dev);
4724 ieee80211_color_change_bss_config_notify(sdata,
4725 sdata->vif.bss_conf.color_change_color,
4727 cfg80211_color_change_notify(sdata->dev);
4732 void ieee80211_color_change_finalize_work(struct wiphy *wiphy,
4733 struct wiphy_work *work)
4735 struct ieee80211_sub_if_data *sdata =
4736 container_of(work, struct ieee80211_sub_if_data,
4737 deflink.color_change_finalize_work);
4738 struct ieee80211_local *local = sdata->local;
4740 lockdep_assert_wiphy(local->hw.wiphy);
4742 /* AP might have been stopped while waiting for the lock. */
4743 if (!sdata->vif.bss_conf.color_change_active)
4746 if (!ieee80211_sdata_running(sdata))
4749 ieee80211_color_change_finalize(sdata);
4752 void ieee80211_color_collision_detection_work(struct work_struct *work)
4754 struct delayed_work *delayed_work = to_delayed_work(work);
4755 struct ieee80211_link_data *link =
4756 container_of(delayed_work, struct ieee80211_link_data,
4757 color_collision_detect_work);
4758 struct ieee80211_sub_if_data *sdata = link->sdata;
4760 cfg80211_obss_color_collision_notify(sdata->dev, link->color_bitmap);
4763 void ieee80211_color_change_finish(struct ieee80211_vif *vif)
4765 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
4767 wiphy_work_queue(sdata->local->hw.wiphy,
4768 &sdata->deflink.color_change_finalize_work);
4770 EXPORT_SYMBOL_GPL(ieee80211_color_change_finish);
4773 ieee80211_obss_color_collision_notify(struct ieee80211_vif *vif,
4776 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
4777 struct ieee80211_link_data *link = &sdata->deflink;
4779 if (sdata->vif.bss_conf.color_change_active || sdata->vif.bss_conf.csa_active)
4782 if (delayed_work_pending(&link->color_collision_detect_work))
4785 link->color_bitmap = color_bitmap;
4786 /* queue the color collision detection event every 500 ms in order to
4787 * avoid sending too much netlink messages to userspace.
4789 ieee80211_queue_delayed_work(&sdata->local->hw,
4790 &link->color_collision_detect_work,
4791 msecs_to_jiffies(500));
4793 EXPORT_SYMBOL_GPL(ieee80211_obss_color_collision_notify);
4796 ieee80211_color_change(struct wiphy *wiphy, struct net_device *dev,
4797 struct cfg80211_color_change_settings *params)
4799 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4800 struct ieee80211_local *local = sdata->local;
4804 lockdep_assert_wiphy(local->hw.wiphy);
4806 if (sdata->vif.bss_conf.nontransmitted)
4809 /* don't allow another color change if one is already active or if csa
4812 if (sdata->vif.bss_conf.color_change_active || sdata->vif.bss_conf.csa_active) {
4817 err = ieee80211_set_color_change_beacon(sdata, params, &changed);
4821 sdata->vif.bss_conf.color_change_active = true;
4822 sdata->vif.bss_conf.color_change_color = params->color;
4824 cfg80211_color_change_started_notify(sdata->dev, params->count);
4827 ieee80211_color_change_bss_config_notify(sdata, 0, 0, changed);
4829 /* if the beacon didn't change, we can finalize immediately */
4830 ieee80211_color_change_finalize(sdata);
4838 ieee80211_set_radar_background(struct wiphy *wiphy,
4839 struct cfg80211_chan_def *chandef)
4841 struct ieee80211_local *local = wiphy_priv(wiphy);
4843 if (!local->ops->set_radar_background)
4846 return local->ops->set_radar_background(&local->hw, chandef);
4849 static int ieee80211_add_intf_link(struct wiphy *wiphy,
4850 struct wireless_dev *wdev,
4851 unsigned int link_id)
4853 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
4855 lockdep_assert_wiphy(sdata->local->hw.wiphy);
4857 if (wdev->use_4addr)
4860 return ieee80211_vif_set_links(sdata, wdev->valid_links, 0);
4863 static void ieee80211_del_intf_link(struct wiphy *wiphy,
4864 struct wireless_dev *wdev,
4865 unsigned int link_id)
4867 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
4869 lockdep_assert_wiphy(sdata->local->hw.wiphy);
4871 ieee80211_vif_set_links(sdata, wdev->valid_links, 0);
4874 static int sta_add_link_station(struct ieee80211_local *local,
4875 struct ieee80211_sub_if_data *sdata,
4876 struct link_station_parameters *params)
4878 struct sta_info *sta;
4881 sta = sta_info_get_bss(sdata, params->mld_mac);
4885 if (!sta->sta.valid_links)
4888 if (sta->sta.valid_links & BIT(params->link_id))
4891 ret = ieee80211_sta_allocate_link(sta, params->link_id);
4895 ret = sta_link_apply_parameters(local, sta, true, params);
4897 ieee80211_sta_free_link(sta, params->link_id);
4901 /* ieee80211_sta_activate_link frees the link upon failure */
4902 return ieee80211_sta_activate_link(sta, params->link_id);
4906 ieee80211_add_link_station(struct wiphy *wiphy, struct net_device *dev,
4907 struct link_station_parameters *params)
4909 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4910 struct ieee80211_local *local = wiphy_priv(wiphy);
4912 lockdep_assert_wiphy(sdata->local->hw.wiphy);
4914 return sta_add_link_station(local, sdata, params);
4917 static int sta_mod_link_station(struct ieee80211_local *local,
4918 struct ieee80211_sub_if_data *sdata,
4919 struct link_station_parameters *params)
4921 struct sta_info *sta;
4923 sta = sta_info_get_bss(sdata, params->mld_mac);
4927 if (!(sta->sta.valid_links & BIT(params->link_id)))
4930 return sta_link_apply_parameters(local, sta, false, params);
4934 ieee80211_mod_link_station(struct wiphy *wiphy, struct net_device *dev,
4935 struct link_station_parameters *params)
4937 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4938 struct ieee80211_local *local = wiphy_priv(wiphy);
4940 lockdep_assert_wiphy(sdata->local->hw.wiphy);
4942 return sta_mod_link_station(local, sdata, params);
4945 static int sta_del_link_station(struct ieee80211_sub_if_data *sdata,
4946 struct link_station_del_parameters *params)
4948 struct sta_info *sta;
4950 sta = sta_info_get_bss(sdata, params->mld_mac);
4954 if (!(sta->sta.valid_links & BIT(params->link_id)))
4957 /* must not create a STA without links */
4958 if (sta->sta.valid_links == BIT(params->link_id))
4961 ieee80211_sta_remove_link(sta, params->link_id);
4967 ieee80211_del_link_station(struct wiphy *wiphy, struct net_device *dev,
4968 struct link_station_del_parameters *params)
4970 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4972 lockdep_assert_wiphy(sdata->local->hw.wiphy);
4974 return sta_del_link_station(sdata, params);
4977 static int ieee80211_set_hw_timestamp(struct wiphy *wiphy,
4978 struct net_device *dev,
4979 struct cfg80211_set_hw_timestamp *hwts)
4981 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4982 struct ieee80211_local *local = sdata->local;
4984 if (!local->ops->set_hw_timestamp)
4987 if (!check_sdata_in_driver(sdata))
4990 return local->ops->set_hw_timestamp(&local->hw, &sdata->vif, hwts);
4994 ieee80211_set_ttlm(struct wiphy *wiphy, struct net_device *dev,
4995 struct cfg80211_ttlm_params *params)
4997 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4999 lockdep_assert_wiphy(sdata->local->hw.wiphy);
5001 return ieee80211_req_neg_ttlm(sdata, params);
5004 const struct cfg80211_ops mac80211_config_ops = {
5005 .add_virtual_intf = ieee80211_add_iface,
5006 .del_virtual_intf = ieee80211_del_iface,
5007 .change_virtual_intf = ieee80211_change_iface,
5008 .start_p2p_device = ieee80211_start_p2p_device,
5009 .stop_p2p_device = ieee80211_stop_p2p_device,
5010 .add_key = ieee80211_add_key,
5011 .del_key = ieee80211_del_key,
5012 .get_key = ieee80211_get_key,
5013 .set_default_key = ieee80211_config_default_key,
5014 .set_default_mgmt_key = ieee80211_config_default_mgmt_key,
5015 .set_default_beacon_key = ieee80211_config_default_beacon_key,
5016 .start_ap = ieee80211_start_ap,
5017 .change_beacon = ieee80211_change_beacon,
5018 .stop_ap = ieee80211_stop_ap,
5019 .add_station = ieee80211_add_station,
5020 .del_station = ieee80211_del_station,
5021 .change_station = ieee80211_change_station,
5022 .get_station = ieee80211_get_station,
5023 .dump_station = ieee80211_dump_station,
5024 .dump_survey = ieee80211_dump_survey,
5025 #ifdef CONFIG_MAC80211_MESH
5026 .add_mpath = ieee80211_add_mpath,
5027 .del_mpath = ieee80211_del_mpath,
5028 .change_mpath = ieee80211_change_mpath,
5029 .get_mpath = ieee80211_get_mpath,
5030 .dump_mpath = ieee80211_dump_mpath,
5031 .get_mpp = ieee80211_get_mpp,
5032 .dump_mpp = ieee80211_dump_mpp,
5033 .update_mesh_config = ieee80211_update_mesh_config,
5034 .get_mesh_config = ieee80211_get_mesh_config,
5035 .join_mesh = ieee80211_join_mesh,
5036 .leave_mesh = ieee80211_leave_mesh,
5038 .join_ocb = ieee80211_join_ocb,
5039 .leave_ocb = ieee80211_leave_ocb,
5040 .change_bss = ieee80211_change_bss,
5041 .inform_bss = ieee80211_inform_bss,
5042 .set_txq_params = ieee80211_set_txq_params,
5043 .set_monitor_channel = ieee80211_set_monitor_channel,
5044 .suspend = ieee80211_suspend,
5045 .resume = ieee80211_resume,
5046 .scan = ieee80211_scan,
5047 .abort_scan = ieee80211_abort_scan,
5048 .sched_scan_start = ieee80211_sched_scan_start,
5049 .sched_scan_stop = ieee80211_sched_scan_stop,
5050 .auth = ieee80211_auth,
5051 .assoc = ieee80211_assoc,
5052 .deauth = ieee80211_deauth,
5053 .disassoc = ieee80211_disassoc,
5054 .join_ibss = ieee80211_join_ibss,
5055 .leave_ibss = ieee80211_leave_ibss,
5056 .set_mcast_rate = ieee80211_set_mcast_rate,
5057 .set_wiphy_params = ieee80211_set_wiphy_params,
5058 .set_tx_power = ieee80211_set_tx_power,
5059 .get_tx_power = ieee80211_get_tx_power,
5060 .rfkill_poll = ieee80211_rfkill_poll,
5061 CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd)
5062 CFG80211_TESTMODE_DUMP(ieee80211_testmode_dump)
5063 .set_power_mgmt = ieee80211_set_power_mgmt,
5064 .set_bitrate_mask = ieee80211_set_bitrate_mask,
5065 .remain_on_channel = ieee80211_remain_on_channel,
5066 .cancel_remain_on_channel = ieee80211_cancel_remain_on_channel,
5067 .mgmt_tx = ieee80211_mgmt_tx,
5068 .mgmt_tx_cancel_wait = ieee80211_mgmt_tx_cancel_wait,
5069 .set_cqm_rssi_config = ieee80211_set_cqm_rssi_config,
5070 .set_cqm_rssi_range_config = ieee80211_set_cqm_rssi_range_config,
5071 .update_mgmt_frame_registrations =
5072 ieee80211_update_mgmt_frame_registrations,
5073 .set_antenna = ieee80211_set_antenna,
5074 .get_antenna = ieee80211_get_antenna,
5075 .set_rekey_data = ieee80211_set_rekey_data,
5076 .tdls_oper = ieee80211_tdls_oper,
5077 .tdls_mgmt = ieee80211_tdls_mgmt,
5078 .tdls_channel_switch = ieee80211_tdls_channel_switch,
5079 .tdls_cancel_channel_switch = ieee80211_tdls_cancel_channel_switch,
5080 .probe_client = ieee80211_probe_client,
5081 .set_noack_map = ieee80211_set_noack_map,
5083 .set_wakeup = ieee80211_set_wakeup,
5085 .get_channel = ieee80211_cfg_get_channel,
5086 .start_radar_detection = ieee80211_start_radar_detection,
5087 .end_cac = ieee80211_end_cac,
5088 .channel_switch = ieee80211_channel_switch,
5089 .set_qos_map = ieee80211_set_qos_map,
5090 .set_ap_chanwidth = ieee80211_set_ap_chanwidth,
5091 .add_tx_ts = ieee80211_add_tx_ts,
5092 .del_tx_ts = ieee80211_del_tx_ts,
5093 .start_nan = ieee80211_start_nan,
5094 .stop_nan = ieee80211_stop_nan,
5095 .nan_change_conf = ieee80211_nan_change_conf,
5096 .add_nan_func = ieee80211_add_nan_func,
5097 .del_nan_func = ieee80211_del_nan_func,
5098 .set_multicast_to_unicast = ieee80211_set_multicast_to_unicast,
5099 .tx_control_port = ieee80211_tx_control_port,
5100 .get_txq_stats = ieee80211_get_txq_stats,
5101 .get_ftm_responder_stats = ieee80211_get_ftm_responder_stats,
5102 .start_pmsr = ieee80211_start_pmsr,
5103 .abort_pmsr = ieee80211_abort_pmsr,
5104 .probe_mesh_link = ieee80211_probe_mesh_link,
5105 .set_tid_config = ieee80211_set_tid_config,
5106 .reset_tid_config = ieee80211_reset_tid_config,
5107 .set_sar_specs = ieee80211_set_sar_specs,
5108 .color_change = ieee80211_color_change,
5109 .set_radar_background = ieee80211_set_radar_background,
5110 .add_intf_link = ieee80211_add_intf_link,
5111 .del_intf_link = ieee80211_del_intf_link,
5112 .add_link_station = ieee80211_add_link_station,
5113 .mod_link_station = ieee80211_mod_link_station,
5114 .del_link_station = ieee80211_del_link_station,
5115 .set_hw_timestamp = ieee80211_set_hw_timestamp,
5116 .set_ttlm = ieee80211_set_ttlm,