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-2022 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 ret = ieee80211_if_change_type(sdata, type);
221 if (type == NL80211_IFTYPE_AP_VLAN && params->use_4addr == 0) {
222 RCU_INIT_POINTER(sdata->u.vlan.sta, NULL);
223 ieee80211_check_fast_rx_iface(sdata);
224 } else if (type == NL80211_IFTYPE_STATION && params->use_4addr >= 0) {
225 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
227 if (params->use_4addr == ifmgd->use_4addr)
230 /* FIXME: no support for 4-addr MLO yet */
231 if (ieee80211_vif_is_mld(&sdata->vif))
234 sdata->u.mgd.use_4addr = params->use_4addr;
235 if (!ifmgd->associated)
238 mutex_lock(&local->sta_mtx);
239 sta = sta_info_get(sdata, sdata->deflink.u.mgd.bssid);
241 drv_sta_set_4addr(local, sdata, &sta->sta,
243 mutex_unlock(&local->sta_mtx);
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 mutex_lock(&sdata->local->chanctx_mtx);
265 ret = ieee80211_check_combinations(sdata, NULL, 0, 0);
266 mutex_unlock(&sdata->local->chanctx_mtx);
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 mutex_lock(&sdata->local->chanctx_mtx);
287 ret = ieee80211_check_combinations(sdata, NULL, 0, 0);
288 mutex_unlock(&sdata->local->chanctx_mtx);
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 mutex_lock(&local->key_mtx);
456 key = key_mtx_dereference(local, sta->ptk[key_idx]);
458 if (key && key->conf.flags & IEEE80211_KEY_FLAG_NO_AUTO_TX)
459 ret = ieee80211_set_tx_key(key);
461 mutex_unlock(&local->key_mtx);
465 static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
466 int link_id, u8 key_idx, bool pairwise,
467 const u8 *mac_addr, struct key_params *params)
469 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
470 struct ieee80211_link_data *link =
471 ieee80211_link_or_deflink(sdata, link_id, false);
472 struct ieee80211_local *local = sdata->local;
473 struct sta_info *sta = NULL;
474 struct ieee80211_key *key;
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;
513 mutex_lock(&local->sta_mtx);
516 sta = sta_info_get_bss(sdata, mac_addr);
518 * The ASSOC test makes sure the driver is ready to
519 * receive the key. When wpa_supplicant has roamed
520 * using FT, it attempts to set the key before
521 * association has completed, this rejects that attempt
522 * so it will set the key again after association.
524 * TODO: accept the key if we have a station entry and
525 * add it to the device after the station.
527 if (!sta || !test_sta_flag(sta, WLAN_STA_ASSOC)) {
528 ieee80211_key_free_unused(key);
534 switch (sdata->vif.type) {
535 case NL80211_IFTYPE_STATION:
536 if (sdata->u.mgd.mfp != IEEE80211_MFP_DISABLED)
537 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
539 case NL80211_IFTYPE_AP:
540 case NL80211_IFTYPE_AP_VLAN:
541 /* Keys without a station are used for TX only */
542 if (sta && test_sta_flag(sta, WLAN_STA_MFP))
543 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
545 case NL80211_IFTYPE_ADHOC:
548 case NL80211_IFTYPE_MESH_POINT:
549 #ifdef CONFIG_MAC80211_MESH
550 if (sdata->u.mesh.security != IEEE80211_MESH_SEC_NONE)
551 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
554 case NL80211_IFTYPE_WDS:
555 case NL80211_IFTYPE_MONITOR:
556 case NL80211_IFTYPE_P2P_DEVICE:
557 case NL80211_IFTYPE_NAN:
558 case NL80211_IFTYPE_UNSPECIFIED:
559 case NUM_NL80211_IFTYPES:
560 case NL80211_IFTYPE_P2P_CLIENT:
561 case NL80211_IFTYPE_P2P_GO:
562 case NL80211_IFTYPE_OCB:
563 /* shouldn't happen */
568 err = ieee80211_key_link(key, link, sta);
569 /* KRACK protection, shouldn't happen but just silently accept key */
570 if (err == -EALREADY)
574 mutex_unlock(&local->sta_mtx);
579 static struct ieee80211_key *
580 ieee80211_lookup_key(struct ieee80211_sub_if_data *sdata, int link_id,
581 u8 key_idx, bool pairwise, const u8 *mac_addr)
583 struct ieee80211_local *local __maybe_unused = sdata->local;
584 struct ieee80211_link_data *link = &sdata->deflink;
585 struct ieee80211_key *key;
588 link = rcu_dereference_check(sdata->link[link_id],
589 lockdep_is_held(&sdata->wdev.mtx));
595 struct sta_info *sta;
596 struct link_sta_info *link_sta;
598 sta = sta_info_get_bss(sdata, mac_addr);
603 link_sta = rcu_dereference_check(sta->link[link_id],
604 lockdep_is_held(&local->sta_mtx));
608 link_sta = &sta->deflink;
611 if (pairwise && key_idx < NUM_DEFAULT_KEYS)
612 return rcu_dereference_check_key_mtx(local,
616 key_idx < NUM_DEFAULT_KEYS +
617 NUM_DEFAULT_MGMT_KEYS +
618 NUM_DEFAULT_BEACON_KEYS)
619 return rcu_dereference_check_key_mtx(local,
620 link_sta->gtk[key_idx]);
625 if (pairwise && key_idx < NUM_DEFAULT_KEYS)
626 return rcu_dereference_check_key_mtx(local,
627 sdata->keys[key_idx]);
629 key = rcu_dereference_check_key_mtx(local, link->gtk[key_idx]);
633 /* or maybe it was a WEP key */
634 if (key_idx < NUM_DEFAULT_KEYS)
635 return rcu_dereference_check_key_mtx(local, sdata->keys[key_idx]);
640 static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
641 int link_id, u8 key_idx, bool pairwise,
644 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
645 struct ieee80211_local *local = sdata->local;
646 struct ieee80211_key *key;
649 mutex_lock(&local->sta_mtx);
650 mutex_lock(&local->key_mtx);
652 key = ieee80211_lookup_key(sdata, link_id, key_idx, pairwise, mac_addr);
658 ieee80211_key_free(key, sdata->vif.type == NL80211_IFTYPE_STATION);
662 mutex_unlock(&local->key_mtx);
663 mutex_unlock(&local->sta_mtx);
668 static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
669 int link_id, u8 key_idx, bool pairwise,
670 const u8 *mac_addr, void *cookie,
671 void (*callback)(void *cookie,
672 struct key_params *params))
674 struct ieee80211_sub_if_data *sdata;
676 struct key_params params;
677 struct ieee80211_key *key;
682 struct ieee80211_key_seq kseq = {};
684 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
688 key = ieee80211_lookup_key(sdata, link_id, key_idx, pairwise, mac_addr);
692 memset(¶ms, 0, sizeof(params));
694 params.cipher = key->conf.cipher;
696 switch (key->conf.cipher) {
697 case WLAN_CIPHER_SUITE_TKIP:
698 pn64 = atomic64_read(&key->conf.tx_pn);
699 iv32 = TKIP_PN_TO_IV32(pn64);
700 iv16 = TKIP_PN_TO_IV16(pn64);
702 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE &&
703 !(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
704 drv_get_key_seq(sdata->local, key, &kseq);
705 iv32 = kseq.tkip.iv32;
706 iv16 = kseq.tkip.iv16;
709 seq[0] = iv16 & 0xff;
710 seq[1] = (iv16 >> 8) & 0xff;
711 seq[2] = iv32 & 0xff;
712 seq[3] = (iv32 >> 8) & 0xff;
713 seq[4] = (iv32 >> 16) & 0xff;
714 seq[5] = (iv32 >> 24) & 0xff;
718 case WLAN_CIPHER_SUITE_CCMP:
719 case WLAN_CIPHER_SUITE_CCMP_256:
720 case WLAN_CIPHER_SUITE_AES_CMAC:
721 case WLAN_CIPHER_SUITE_BIP_CMAC_256:
722 BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
723 offsetof(typeof(kseq), aes_cmac));
725 case WLAN_CIPHER_SUITE_BIP_GMAC_128:
726 case WLAN_CIPHER_SUITE_BIP_GMAC_256:
727 BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
728 offsetof(typeof(kseq), aes_gmac));
730 case WLAN_CIPHER_SUITE_GCMP:
731 case WLAN_CIPHER_SUITE_GCMP_256:
732 BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
733 offsetof(typeof(kseq), gcmp));
735 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE &&
736 !(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
737 drv_get_key_seq(sdata->local, key, &kseq);
738 memcpy(seq, kseq.ccmp.pn, 6);
740 pn64 = atomic64_read(&key->conf.tx_pn);
752 if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
754 if (WARN_ON(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV))
756 drv_get_key_seq(sdata->local, key, &kseq);
757 params.seq = kseq.hw.seq;
758 params.seq_len = kseq.hw.seq_len;
762 params.key = key->conf.key;
763 params.key_len = key->conf.keylen;
765 callback(cookie, ¶ms);
773 static int ieee80211_config_default_key(struct wiphy *wiphy,
774 struct net_device *dev,
775 int link_id, u8 key_idx, bool uni,
778 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
779 struct ieee80211_link_data *link =
780 ieee80211_link_or_deflink(sdata, link_id, false);
783 return PTR_ERR(link);
785 ieee80211_set_default_key(link, key_idx, uni, multi);
790 static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy,
791 struct net_device *dev,
792 int link_id, u8 key_idx)
794 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
795 struct ieee80211_link_data *link =
796 ieee80211_link_or_deflink(sdata, link_id, true);
799 return PTR_ERR(link);
801 ieee80211_set_default_mgmt_key(link, key_idx);
806 static int ieee80211_config_default_beacon_key(struct wiphy *wiphy,
807 struct net_device *dev,
808 int link_id, u8 key_idx)
810 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
811 struct ieee80211_link_data *link =
812 ieee80211_link_or_deflink(sdata, link_id, true);
815 return PTR_ERR(link);
817 ieee80211_set_default_beacon_key(link, key_idx);
822 void sta_set_rate_info_tx(struct sta_info *sta,
823 const struct ieee80211_tx_rate *rate,
824 struct rate_info *rinfo)
827 if (rate->flags & IEEE80211_TX_RC_MCS) {
828 rinfo->flags |= RATE_INFO_FLAGS_MCS;
829 rinfo->mcs = rate->idx;
830 } else if (rate->flags & IEEE80211_TX_RC_VHT_MCS) {
831 rinfo->flags |= RATE_INFO_FLAGS_VHT_MCS;
832 rinfo->mcs = ieee80211_rate_get_vht_mcs(rate);
833 rinfo->nss = ieee80211_rate_get_vht_nss(rate);
835 struct ieee80211_supported_band *sband;
836 int shift = ieee80211_vif_get_shift(&sta->sdata->vif);
839 sband = ieee80211_get_sband(sta->sdata);
840 WARN_ON_ONCE(sband && !sband->bitrates);
841 if (sband && sband->bitrates) {
842 brate = sband->bitrates[rate->idx].bitrate;
843 rinfo->legacy = DIV_ROUND_UP(brate, 1 << shift);
846 if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
847 rinfo->bw = RATE_INFO_BW_40;
848 else if (rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH)
849 rinfo->bw = RATE_INFO_BW_80;
850 else if (rate->flags & IEEE80211_TX_RC_160_MHZ_WIDTH)
851 rinfo->bw = RATE_INFO_BW_160;
853 rinfo->bw = RATE_INFO_BW_20;
854 if (rate->flags & IEEE80211_TX_RC_SHORT_GI)
855 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI;
858 static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev,
859 int idx, u8 *mac, struct station_info *sinfo)
861 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
862 struct ieee80211_local *local = sdata->local;
863 struct sta_info *sta;
866 mutex_lock(&local->sta_mtx);
868 sta = sta_info_get_by_idx(sdata, idx);
871 memcpy(mac, sta->sta.addr, ETH_ALEN);
872 sta_set_sinfo(sta, sinfo, true);
875 mutex_unlock(&local->sta_mtx);
880 static int ieee80211_dump_survey(struct wiphy *wiphy, struct net_device *dev,
881 int idx, struct survey_info *survey)
883 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
885 return drv_get_survey(local, idx, survey);
888 static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev,
889 const u8 *mac, struct station_info *sinfo)
891 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
892 struct ieee80211_local *local = sdata->local;
893 struct sta_info *sta;
896 mutex_lock(&local->sta_mtx);
898 sta = sta_info_get_bss(sdata, mac);
901 sta_set_sinfo(sta, sinfo, true);
904 mutex_unlock(&local->sta_mtx);
909 static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
910 struct cfg80211_chan_def *chandef)
912 struct ieee80211_local *local = wiphy_priv(wiphy);
913 struct ieee80211_sub_if_data *sdata;
916 if (cfg80211_chandef_identical(&local->monitor_chandef, chandef))
919 if (local->use_chanctx) {
920 sdata = wiphy_dereference(local->hw.wiphy,
921 local->monitor_sdata);
924 mutex_lock(&local->mtx);
925 ieee80211_link_release_channel(&sdata->deflink);
926 ret = ieee80211_link_use_channel(&sdata->deflink,
928 IEEE80211_CHANCTX_EXCLUSIVE);
929 mutex_unlock(&local->mtx);
933 mutex_lock(&local->mtx);
934 if (local->open_count == local->monitors) {
935 local->_oper_chandef = *chandef;
936 ieee80211_hw_config(local, 0);
938 mutex_unlock(&local->mtx);
942 local->monitor_chandef = *chandef;
948 ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata,
949 const u8 *resp, size_t resp_len,
950 const struct ieee80211_csa_settings *csa,
951 const struct ieee80211_color_change_settings *cca,
952 struct ieee80211_link_data *link)
954 struct probe_resp *new, *old;
956 if (!resp || !resp_len)
959 old = sdata_dereference(link->u.ap.probe_resp, sdata);
961 new = kzalloc(sizeof(struct probe_resp) + resp_len, GFP_KERNEL);
966 memcpy(new->data, resp, resp_len);
969 memcpy(new->cntdwn_counter_offsets, csa->counter_offsets_presp,
970 csa->n_counter_offsets_presp *
971 sizeof(new->cntdwn_counter_offsets[0]));
973 new->cntdwn_counter_offsets[0] = cca->counter_offset_presp;
975 rcu_assign_pointer(link->u.ap.probe_resp, new);
977 kfree_rcu(old, rcu_head);
982 static int ieee80211_set_fils_discovery(struct ieee80211_sub_if_data *sdata,
983 struct cfg80211_fils_discovery *params,
984 struct ieee80211_link_data *link,
985 struct ieee80211_bss_conf *link_conf)
987 struct fils_discovery_data *new, *old = NULL;
988 struct ieee80211_fils_discovery *fd;
990 if (!params->tmpl || !params->tmpl_len)
993 fd = &link_conf->fils_discovery;
994 fd->min_interval = params->min_interval;
995 fd->max_interval = params->max_interval;
997 old = sdata_dereference(link->u.ap.fils_discovery, sdata);
998 new = kzalloc(sizeof(*new) + params->tmpl_len, GFP_KERNEL);
1001 new->len = params->tmpl_len;
1002 memcpy(new->data, params->tmpl, params->tmpl_len);
1003 rcu_assign_pointer(link->u.ap.fils_discovery, new);
1006 kfree_rcu(old, rcu_head);
1012 ieee80211_set_unsol_bcast_probe_resp(struct ieee80211_sub_if_data *sdata,
1013 struct cfg80211_unsol_bcast_probe_resp *params,
1014 struct ieee80211_link_data *link,
1015 struct ieee80211_bss_conf *link_conf)
1017 struct unsol_bcast_probe_resp_data *new, *old = NULL;
1019 if (!params->tmpl || !params->tmpl_len)
1022 old = sdata_dereference(link->u.ap.unsol_bcast_probe_resp, sdata);
1023 new = kzalloc(sizeof(*new) + params->tmpl_len, GFP_KERNEL);
1026 new->len = params->tmpl_len;
1027 memcpy(new->data, params->tmpl, params->tmpl_len);
1028 rcu_assign_pointer(link->u.ap.unsol_bcast_probe_resp, new);
1031 kfree_rcu(old, rcu_head);
1033 link_conf->unsol_bcast_probe_resp_interval = params->interval;
1038 static int ieee80211_set_ftm_responder_params(
1039 struct ieee80211_sub_if_data *sdata,
1040 const u8 *lci, size_t lci_len,
1041 const u8 *civicloc, size_t civicloc_len,
1042 struct ieee80211_bss_conf *link_conf)
1044 struct ieee80211_ftm_responder_params *new, *old;
1048 if (!lci_len && !civicloc_len)
1051 old = link_conf->ftmr_params;
1052 len = lci_len + civicloc_len;
1054 new = kzalloc(sizeof(*new) + len, GFP_KERNEL);
1058 pos = (u8 *)(new + 1);
1060 new->lci_len = lci_len;
1062 memcpy(pos, lci, lci_len);
1067 new->civicloc_len = civicloc_len;
1068 new->civicloc = pos;
1069 memcpy(pos, civicloc, civicloc_len);
1070 pos += civicloc_len;
1073 link_conf->ftmr_params = new;
1080 ieee80211_copy_mbssid_beacon(u8 *pos, struct cfg80211_mbssid_elems *dst,
1081 struct cfg80211_mbssid_elems *src)
1085 for (i = 0; i < src->cnt; i++) {
1086 memcpy(pos + offset, src->elem[i].data, src->elem[i].len);
1087 dst->elem[i].len = src->elem[i].len;
1088 dst->elem[i].data = pos + offset;
1089 offset += dst->elem[i].len;
1091 dst->cnt = src->cnt;
1097 ieee80211_copy_rnr_beacon(u8 *pos, struct cfg80211_rnr_elems *dst,
1098 struct cfg80211_rnr_elems *src)
1102 for (i = 0; i < src->cnt; i++) {
1103 memcpy(pos + offset, src->elem[i].data, src->elem[i].len);
1104 dst->elem[i].len = src->elem[i].len;
1105 dst->elem[i].data = pos + offset;
1106 offset += dst->elem[i].len;
1108 dst->cnt = src->cnt;
1114 ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
1115 struct ieee80211_link_data *link,
1116 struct cfg80211_beacon_data *params,
1117 const struct ieee80211_csa_settings *csa,
1118 const struct ieee80211_color_change_settings *cca,
1121 struct cfg80211_mbssid_elems *mbssid = NULL;
1122 struct cfg80211_rnr_elems *rnr = NULL;
1123 struct beacon_data *new, *old;
1124 int new_head_len, new_tail_len;
1126 u64 _changed = BSS_CHANGED_BEACON;
1127 struct ieee80211_bss_conf *link_conf = link->conf;
1129 old = sdata_dereference(link->u.ap.beacon, sdata);
1131 /* Need to have a beacon head if we don't have one yet */
1132 if (!params->head && !old)
1135 /* new or old head? */
1137 new_head_len = params->head_len;
1139 new_head_len = old->head_len;
1141 /* new or old tail? */
1142 if (params->tail || !old)
1143 /* params->tail_len will be zero for !params->tail */
1144 new_tail_len = params->tail_len;
1146 new_tail_len = old->tail_len;
1148 size = sizeof(*new) + new_head_len + new_tail_len;
1150 /* new or old multiple BSSID elements? */
1151 if (params->mbssid_ies) {
1152 mbssid = params->mbssid_ies;
1153 size += struct_size(new->mbssid_ies, elem, mbssid->cnt);
1154 if (params->rnr_ies) {
1155 rnr = params->rnr_ies;
1156 size += struct_size(new->rnr_ies, elem, rnr->cnt);
1158 size += ieee80211_get_mbssid_beacon_len(mbssid, rnr,
1160 } else if (old && old->mbssid_ies) {
1161 mbssid = old->mbssid_ies;
1162 size += struct_size(new->mbssid_ies, elem, mbssid->cnt);
1163 if (old && old->rnr_ies) {
1165 size += struct_size(new->rnr_ies, elem, rnr->cnt);
1167 size += ieee80211_get_mbssid_beacon_len(mbssid, rnr,
1171 new = kzalloc(size, GFP_KERNEL);
1175 /* start filling the new info now */
1178 * pointers go into the block we allocated,
1179 * memory is | beacon_data | head | tail | mbssid_ies | rnr_ies
1181 new->head = ((u8 *) new) + sizeof(*new);
1182 new->tail = new->head + new_head_len;
1183 new->head_len = new_head_len;
1184 new->tail_len = new_tail_len;
1185 /* copy in optional mbssid_ies */
1187 u8 *pos = new->tail + new->tail_len;
1189 new->mbssid_ies = (void *)pos;
1190 pos += struct_size(new->mbssid_ies, elem, mbssid->cnt);
1191 pos += ieee80211_copy_mbssid_beacon(pos, new->mbssid_ies,
1194 new->rnr_ies = (void *)pos;
1195 pos += struct_size(new->rnr_ies, elem, rnr->cnt);
1196 ieee80211_copy_rnr_beacon(pos, new->rnr_ies, rnr);
1198 /* update bssid_indicator */
1199 link_conf->bssid_indicator =
1200 ilog2(__roundup_pow_of_two(mbssid->cnt + 1));
1204 new->cntdwn_current_counter = csa->count;
1205 memcpy(new->cntdwn_counter_offsets, csa->counter_offsets_beacon,
1206 csa->n_counter_offsets_beacon *
1207 sizeof(new->cntdwn_counter_offsets[0]));
1209 new->cntdwn_current_counter = cca->count;
1210 new->cntdwn_counter_offsets[0] = cca->counter_offset_beacon;
1215 memcpy(new->head, params->head, new_head_len);
1217 memcpy(new->head, old->head, new_head_len);
1219 /* copy in optional tail */
1221 memcpy(new->tail, params->tail, new_tail_len);
1224 memcpy(new->tail, old->tail, new_tail_len);
1226 err = ieee80211_set_probe_resp(sdata, params->probe_resp,
1227 params->probe_resp_len, csa, cca, link);
1233 _changed |= BSS_CHANGED_AP_PROBE_RESP;
1235 if (params->ftm_responder != -1) {
1236 link_conf->ftm_responder = params->ftm_responder;
1237 err = ieee80211_set_ftm_responder_params(sdata,
1241 params->civicloc_len,
1249 _changed |= BSS_CHANGED_FTM_RESPONDER;
1252 rcu_assign_pointer(link->u.ap.beacon, new);
1253 sdata->u.ap.active = true;
1256 kfree_rcu(old, rcu_head);
1258 *changed |= _changed;
1262 static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
1263 struct cfg80211_ap_settings *params)
1265 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1266 struct ieee80211_local *local = sdata->local;
1267 struct beacon_data *old;
1268 struct ieee80211_sub_if_data *vlan;
1269 u64 changed = BSS_CHANGED_BEACON_INT |
1270 BSS_CHANGED_BEACON_ENABLED |
1271 BSS_CHANGED_BEACON |
1272 BSS_CHANGED_P2P_PS |
1273 BSS_CHANGED_TXPOWER |
1276 int prev_beacon_int;
1277 unsigned int link_id = params->beacon.link_id;
1278 struct ieee80211_link_data *link;
1279 struct ieee80211_bss_conf *link_conf;
1281 link = sdata_dereference(sdata->link[link_id], sdata);
1285 link_conf = link->conf;
1287 old = sdata_dereference(link->u.ap.beacon, sdata);
1291 if (params->smps_mode != NL80211_SMPS_OFF)
1294 link->smps_mode = IEEE80211_SMPS_OFF;
1296 link->needed_rx_chains = sdata->local->rx_chains;
1298 prev_beacon_int = link_conf->beacon_int;
1299 link_conf->beacon_int = params->beacon_interval;
1302 link_conf->ht_ldpc =
1303 params->ht_cap->cap_info &
1304 cpu_to_le16(IEEE80211_HT_CAP_LDPC_CODING);
1306 if (params->vht_cap) {
1307 link_conf->vht_ldpc =
1308 params->vht_cap->vht_cap_info &
1309 cpu_to_le32(IEEE80211_VHT_CAP_RXLDPC);
1310 link_conf->vht_su_beamformer =
1311 params->vht_cap->vht_cap_info &
1312 cpu_to_le32(IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE);
1313 link_conf->vht_su_beamformee =
1314 params->vht_cap->vht_cap_info &
1315 cpu_to_le32(IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE);
1316 link_conf->vht_mu_beamformer =
1317 params->vht_cap->vht_cap_info &
1318 cpu_to_le32(IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE);
1319 link_conf->vht_mu_beamformee =
1320 params->vht_cap->vht_cap_info &
1321 cpu_to_le32(IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE);
1324 if (params->he_cap && params->he_oper) {
1325 link_conf->he_support = true;
1326 link_conf->htc_trig_based_pkt_ext =
1327 le32_get_bits(params->he_oper->he_oper_params,
1328 IEEE80211_HE_OPERATION_DFLT_PE_DURATION_MASK);
1329 link_conf->frame_time_rts_th =
1330 le32_get_bits(params->he_oper->he_oper_params,
1331 IEEE80211_HE_OPERATION_RTS_THRESHOLD_MASK);
1332 changed |= BSS_CHANGED_HE_OBSS_PD;
1334 if (params->beacon.he_bss_color.enabled)
1335 changed |= BSS_CHANGED_HE_BSS_COLOR;
1338 if (params->he_cap) {
1339 link_conf->he_ldpc =
1340 params->he_cap->phy_cap_info[1] &
1341 IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD;
1342 link_conf->he_su_beamformer =
1343 params->he_cap->phy_cap_info[3] &
1344 IEEE80211_HE_PHY_CAP3_SU_BEAMFORMER;
1345 link_conf->he_su_beamformee =
1346 params->he_cap->phy_cap_info[4] &
1347 IEEE80211_HE_PHY_CAP4_SU_BEAMFORMEE;
1348 link_conf->he_mu_beamformer =
1349 params->he_cap->phy_cap_info[4] &
1350 IEEE80211_HE_PHY_CAP4_MU_BEAMFORMER;
1351 link_conf->he_full_ul_mumimo =
1352 params->he_cap->phy_cap_info[2] &
1353 IEEE80211_HE_PHY_CAP2_UL_MU_FULL_MU_MIMO;
1356 if (params->eht_cap) {
1357 if (!link_conf->he_support)
1360 link_conf->eht_support = true;
1361 link_conf->eht_puncturing = params->punct_bitmap;
1362 changed |= BSS_CHANGED_EHT_PUNCTURING;
1364 link_conf->eht_su_beamformer =
1365 params->eht_cap->fixed.phy_cap_info[0] &
1366 IEEE80211_EHT_PHY_CAP0_SU_BEAMFORMER;
1367 link_conf->eht_su_beamformee =
1368 params->eht_cap->fixed.phy_cap_info[0] &
1369 IEEE80211_EHT_PHY_CAP0_SU_BEAMFORMEE;
1370 link_conf->eht_mu_beamformer =
1371 params->eht_cap->fixed.phy_cap_info[7] &
1372 (IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_80MHZ |
1373 IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_160MHZ |
1374 IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_320MHZ);
1376 link_conf->eht_su_beamformer = false;
1377 link_conf->eht_su_beamformee = false;
1378 link_conf->eht_mu_beamformer = false;
1381 if (sdata->vif.type == NL80211_IFTYPE_AP &&
1382 params->mbssid_config.tx_wdev) {
1383 err = ieee80211_set_ap_mbssid_options(sdata,
1384 params->mbssid_config,
1390 mutex_lock(&local->mtx);
1391 err = ieee80211_link_use_channel(link, ¶ms->chandef,
1392 IEEE80211_CHANCTX_SHARED);
1394 ieee80211_link_copy_chanctx_to_vlans(link, false);
1395 mutex_unlock(&local->mtx);
1397 link_conf->beacon_int = prev_beacon_int;
1402 * Apply control port protocol, this allows us to
1403 * not encrypt dynamic WEP control frames.
1405 sdata->control_port_protocol = params->crypto.control_port_ethertype;
1406 sdata->control_port_no_encrypt = params->crypto.control_port_no_encrypt;
1407 sdata->control_port_over_nl80211 =
1408 params->crypto.control_port_over_nl80211;
1409 sdata->control_port_no_preauth =
1410 params->crypto.control_port_no_preauth;
1412 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) {
1413 vlan->control_port_protocol =
1414 params->crypto.control_port_ethertype;
1415 vlan->control_port_no_encrypt =
1416 params->crypto.control_port_no_encrypt;
1417 vlan->control_port_over_nl80211 =
1418 params->crypto.control_port_over_nl80211;
1419 vlan->control_port_no_preauth =
1420 params->crypto.control_port_no_preauth;
1423 link_conf->dtim_period = params->dtim_period;
1424 link_conf->enable_beacon = true;
1425 link_conf->allow_p2p_go_ps = sdata->vif.p2p;
1426 link_conf->twt_responder = params->twt_responder;
1427 link_conf->he_obss_pd = params->he_obss_pd;
1428 link_conf->he_bss_color = params->beacon.he_bss_color;
1429 sdata->vif.cfg.s1g = params->chandef.chan->band ==
1432 sdata->vif.cfg.ssid_len = params->ssid_len;
1433 if (params->ssid_len)
1434 memcpy(sdata->vif.cfg.ssid, params->ssid,
1436 link_conf->hidden_ssid =
1437 (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE);
1439 memset(&link_conf->p2p_noa_attr, 0,
1440 sizeof(link_conf->p2p_noa_attr));
1441 link_conf->p2p_noa_attr.oppps_ctwindow =
1442 params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
1443 if (params->p2p_opp_ps)
1444 link_conf->p2p_noa_attr.oppps_ctwindow |=
1445 IEEE80211_P2P_OPPPS_ENABLE_BIT;
1447 sdata->beacon_rate_set = false;
1448 if (wiphy_ext_feature_isset(local->hw.wiphy,
1449 NL80211_EXT_FEATURE_BEACON_RATE_LEGACY)) {
1450 for (i = 0; i < NUM_NL80211_BANDS; i++) {
1451 sdata->beacon_rateidx_mask[i] =
1452 params->beacon_rate.control[i].legacy;
1453 if (sdata->beacon_rateidx_mask[i])
1454 sdata->beacon_rate_set = true;
1458 if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL))
1459 link_conf->beacon_tx_rate = params->beacon_rate;
1461 err = ieee80211_assign_beacon(sdata, link, ¶ms->beacon, NULL, NULL,
1466 if (params->fils_discovery.max_interval) {
1467 err = ieee80211_set_fils_discovery(sdata,
1468 ¶ms->fils_discovery,
1472 changed |= BSS_CHANGED_FILS_DISCOVERY;
1475 if (params->unsol_bcast_probe_resp.interval) {
1476 err = ieee80211_set_unsol_bcast_probe_resp(sdata,
1477 ¶ms->unsol_bcast_probe_resp,
1481 changed |= BSS_CHANGED_UNSOL_BCAST_PROBE_RESP;
1484 err = drv_start_ap(sdata->local, sdata, link_conf);
1486 old = sdata_dereference(link->u.ap.beacon, sdata);
1489 kfree_rcu(old, rcu_head);
1490 RCU_INIT_POINTER(link->u.ap.beacon, NULL);
1491 sdata->u.ap.active = false;
1495 ieee80211_recalc_dtim(local, sdata);
1496 ieee80211_vif_cfg_change_notify(sdata, BSS_CHANGED_SSID);
1497 ieee80211_link_info_change_notify(sdata, link, changed);
1499 netif_carrier_on(dev);
1500 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
1501 netif_carrier_on(vlan->dev);
1506 mutex_lock(&local->mtx);
1507 ieee80211_link_release_channel(link);
1508 mutex_unlock(&local->mtx);
1513 static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev,
1514 struct cfg80211_beacon_data *params)
1516 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1517 struct ieee80211_link_data *link;
1518 struct beacon_data *old;
1520 struct ieee80211_bss_conf *link_conf;
1523 sdata_assert_lock(sdata);
1525 link = sdata_dereference(sdata->link[params->link_id], sdata);
1529 link_conf = link->conf;
1531 /* don't allow changing the beacon while a countdown is in place - offset
1532 * of channel switch counter may change
1534 if (link_conf->csa_active || link_conf->color_change_active)
1537 old = sdata_dereference(link->u.ap.beacon, sdata);
1541 err = ieee80211_assign_beacon(sdata, link, params, NULL, NULL,
1546 if (params->he_bss_color_valid &&
1547 params->he_bss_color.enabled != link_conf->he_bss_color.enabled) {
1548 link_conf->he_bss_color.enabled = params->he_bss_color.enabled;
1549 changed |= BSS_CHANGED_HE_BSS_COLOR;
1552 ieee80211_link_info_change_notify(sdata, link, changed);
1556 static void ieee80211_free_next_beacon(struct ieee80211_link_data *link)
1558 if (!link->u.ap.next_beacon)
1561 kfree(link->u.ap.next_beacon->mbssid_ies);
1562 kfree(link->u.ap.next_beacon->rnr_ies);
1563 kfree(link->u.ap.next_beacon);
1564 link->u.ap.next_beacon = NULL;
1567 static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev,
1568 unsigned int link_id)
1570 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1571 struct ieee80211_sub_if_data *vlan;
1572 struct ieee80211_local *local = sdata->local;
1573 struct beacon_data *old_beacon;
1574 struct probe_resp *old_probe_resp;
1575 struct fils_discovery_data *old_fils_discovery;
1576 struct unsol_bcast_probe_resp_data *old_unsol_bcast_probe_resp;
1577 struct cfg80211_chan_def chandef;
1578 struct ieee80211_link_data *link =
1579 sdata_dereference(sdata->link[link_id], sdata);
1580 struct ieee80211_bss_conf *link_conf = link->conf;
1582 sdata_assert_lock(sdata);
1584 old_beacon = sdata_dereference(link->u.ap.beacon, sdata);
1587 old_probe_resp = sdata_dereference(link->u.ap.probe_resp,
1589 old_fils_discovery = sdata_dereference(link->u.ap.fils_discovery,
1591 old_unsol_bcast_probe_resp =
1592 sdata_dereference(link->u.ap.unsol_bcast_probe_resp,
1595 /* abort any running channel switch or color change */
1596 mutex_lock(&local->mtx);
1597 link_conf->csa_active = false;
1598 link_conf->color_change_active = false;
1599 if (link->csa_block_tx) {
1600 ieee80211_wake_vif_queues(local, sdata,
1601 IEEE80211_QUEUE_STOP_REASON_CSA);
1602 link->csa_block_tx = false;
1605 mutex_unlock(&local->mtx);
1607 ieee80211_free_next_beacon(link);
1609 /* turn off carrier for this interface and dependent VLANs */
1610 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
1611 netif_carrier_off(vlan->dev);
1612 netif_carrier_off(dev);
1614 /* remove beacon and probe response */
1615 sdata->u.ap.active = false;
1616 RCU_INIT_POINTER(link->u.ap.beacon, NULL);
1617 RCU_INIT_POINTER(link->u.ap.probe_resp, NULL);
1618 RCU_INIT_POINTER(link->u.ap.fils_discovery, NULL);
1619 RCU_INIT_POINTER(link->u.ap.unsol_bcast_probe_resp, NULL);
1620 kfree_rcu(old_beacon, rcu_head);
1622 kfree_rcu(old_probe_resp, rcu_head);
1623 if (old_fils_discovery)
1624 kfree_rcu(old_fils_discovery, rcu_head);
1625 if (old_unsol_bcast_probe_resp)
1626 kfree_rcu(old_unsol_bcast_probe_resp, rcu_head);
1628 kfree(link_conf->ftmr_params);
1629 link_conf->ftmr_params = NULL;
1631 sdata->vif.mbssid_tx_vif = NULL;
1632 link_conf->bssid_index = 0;
1633 link_conf->nontransmitted = false;
1634 link_conf->ema_ap = false;
1635 link_conf->bssid_indicator = 0;
1637 __sta_info_flush(sdata, true);
1638 ieee80211_free_keys(sdata, true);
1640 link_conf->enable_beacon = false;
1641 sdata->beacon_rate_set = false;
1642 sdata->vif.cfg.ssid_len = 0;
1643 clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state);
1644 ieee80211_link_info_change_notify(sdata, link,
1645 BSS_CHANGED_BEACON_ENABLED);
1647 if (sdata->wdev.cac_started) {
1648 chandef = link_conf->chandef;
1649 cancel_delayed_work_sync(&link->dfs_cac_timer_work);
1650 cfg80211_cac_event(sdata->dev, &chandef,
1651 NL80211_RADAR_CAC_ABORTED,
1655 drv_stop_ap(sdata->local, sdata, link_conf);
1657 /* free all potentially still buffered bcast frames */
1658 local->total_ps_buffered -= skb_queue_len(&sdata->u.ap.ps.bc_buf);
1659 ieee80211_purge_tx_queue(&local->hw, &sdata->u.ap.ps.bc_buf);
1661 mutex_lock(&local->mtx);
1662 ieee80211_link_copy_chanctx_to_vlans(link, true);
1663 ieee80211_link_release_channel(link);
1664 mutex_unlock(&local->mtx);
1669 static int sta_apply_auth_flags(struct ieee80211_local *local,
1670 struct sta_info *sta,
1675 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
1676 set & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
1677 !test_sta_flag(sta, WLAN_STA_AUTH)) {
1678 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
1683 if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
1684 set & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
1685 !test_sta_flag(sta, WLAN_STA_ASSOC)) {
1687 * When peer becomes associated, init rate control as
1688 * well. Some drivers require rate control initialized
1689 * before drv_sta_state() is called.
1691 if (!test_sta_flag(sta, WLAN_STA_RATE_CONTROL))
1692 rate_control_rate_init(sta);
1694 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
1699 if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
1700 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED))
1701 ret = sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED);
1702 else if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
1703 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
1710 if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
1711 !(set & BIT(NL80211_STA_FLAG_ASSOCIATED)) &&
1712 test_sta_flag(sta, WLAN_STA_ASSOC)) {
1713 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
1718 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
1719 !(set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) &&
1720 test_sta_flag(sta, WLAN_STA_AUTH)) {
1721 ret = sta_info_move_state(sta, IEEE80211_STA_NONE);
1729 static void sta_apply_mesh_params(struct ieee80211_local *local,
1730 struct sta_info *sta,
1731 struct station_parameters *params)
1733 #ifdef CONFIG_MAC80211_MESH
1734 struct ieee80211_sub_if_data *sdata = sta->sdata;
1737 if (params->sta_modify_mask & STATION_PARAM_APPLY_PLINK_STATE) {
1738 switch (params->plink_state) {
1739 case NL80211_PLINK_ESTAB:
1740 if (sta->mesh->plink_state != NL80211_PLINK_ESTAB)
1741 changed = mesh_plink_inc_estab_count(sdata);
1742 sta->mesh->plink_state = params->plink_state;
1743 sta->mesh->aid = params->peer_aid;
1745 ieee80211_mps_sta_status_update(sta);
1746 changed |= ieee80211_mps_set_sta_local_pm(sta,
1747 sdata->u.mesh.mshcfg.power_mode);
1749 ewma_mesh_tx_rate_avg_init(&sta->mesh->tx_rate_avg);
1750 /* init at low value */
1751 ewma_mesh_tx_rate_avg_add(&sta->mesh->tx_rate_avg, 10);
1754 case NL80211_PLINK_LISTEN:
1755 case NL80211_PLINK_BLOCKED:
1756 case NL80211_PLINK_OPN_SNT:
1757 case NL80211_PLINK_OPN_RCVD:
1758 case NL80211_PLINK_CNF_RCVD:
1759 case NL80211_PLINK_HOLDING:
1760 if (sta->mesh->plink_state == NL80211_PLINK_ESTAB)
1761 changed = mesh_plink_dec_estab_count(sdata);
1762 sta->mesh->plink_state = params->plink_state;
1764 ieee80211_mps_sta_status_update(sta);
1765 changed |= ieee80211_mps_set_sta_local_pm(sta,
1766 NL80211_MESH_POWER_UNKNOWN);
1774 switch (params->plink_action) {
1775 case NL80211_PLINK_ACTION_NO_ACTION:
1778 case NL80211_PLINK_ACTION_OPEN:
1779 changed |= mesh_plink_open(sta);
1781 case NL80211_PLINK_ACTION_BLOCK:
1782 changed |= mesh_plink_block(sta);
1786 if (params->local_pm)
1787 changed |= ieee80211_mps_set_sta_local_pm(sta,
1790 ieee80211_mbss_info_change_notify(sdata, changed);
1794 static int sta_link_apply_parameters(struct ieee80211_local *local,
1795 struct sta_info *sta, bool new_link,
1796 struct link_station_parameters *params)
1799 struct ieee80211_supported_band *sband;
1800 struct ieee80211_sub_if_data *sdata = sta->sdata;
1801 u32 link_id = params->link_id < 0 ? 0 : params->link_id;
1802 struct ieee80211_link_data *link =
1803 sdata_dereference(sdata->link[link_id], sdata);
1804 struct link_sta_info *link_sta =
1805 rcu_dereference_protected(sta->link[link_id],
1806 lockdep_is_held(&local->sta_mtx));
1809 * If there are no changes, then accept a link that doesn't exist,
1810 * unless it's a new link.
1812 if (params->link_id < 0 && !new_link &&
1813 !params->link_mac && !params->txpwr_set &&
1814 !params->supported_rates_len &&
1815 !params->ht_capa && !params->vht_capa &&
1816 !params->he_capa && !params->eht_capa &&
1817 !params->opmode_notif_used)
1820 if (!link || !link_sta)
1823 sband = ieee80211_get_link_sband(link);
1827 if (params->link_mac) {
1829 memcpy(link_sta->addr, params->link_mac, ETH_ALEN);
1830 memcpy(link_sta->pub->addr, params->link_mac, ETH_ALEN);
1831 } else if (!ether_addr_equal(link_sta->addr,
1832 params->link_mac)) {
1835 } else if (new_link) {
1839 if (params->txpwr_set) {
1840 link_sta->pub->txpwr.type = params->txpwr.type;
1841 if (params->txpwr.type == NL80211_TX_POWER_LIMITED)
1842 link_sta->pub->txpwr.power = params->txpwr.power;
1843 ret = drv_sta_set_txpwr(local, sdata, sta);
1848 if (params->supported_rates &&
1849 params->supported_rates_len) {
1850 ieee80211_parse_bitrates(link->conf->chandef.width,
1851 sband, params->supported_rates,
1852 params->supported_rates_len,
1853 &link_sta->pub->supp_rates[sband->band]);
1856 if (params->ht_capa)
1857 ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
1858 params->ht_capa, link_sta);
1860 /* VHT can override some HT caps such as the A-MSDU max length */
1861 if (params->vht_capa)
1862 ieee80211_vht_cap_ie_to_sta_vht_cap(sdata, sband,
1863 params->vht_capa, NULL,
1866 if (params->he_capa)
1867 ieee80211_he_cap_ie_to_sta_he_cap(sdata, sband,
1868 (void *)params->he_capa,
1869 params->he_capa_len,
1870 (void *)params->he_6ghz_capa,
1873 if (params->he_capa && params->eht_capa)
1874 ieee80211_eht_cap_ie_to_sta_eht_cap(sdata, sband,
1875 (u8 *)params->he_capa,
1876 params->he_capa_len,
1878 params->eht_capa_len,
1881 if (params->opmode_notif_used) {
1882 /* returned value is only needed for rc update, but the
1883 * rc isn't initialized here yet, so ignore it
1885 __ieee80211_vht_handle_opmode(sdata, link_sta,
1886 params->opmode_notif,
1893 static int sta_apply_parameters(struct ieee80211_local *local,
1894 struct sta_info *sta,
1895 struct station_parameters *params)
1897 struct ieee80211_sub_if_data *sdata = sta->sdata;
1901 mask = params->sta_flags_mask;
1902 set = params->sta_flags_set;
1904 if (ieee80211_vif_is_mesh(&sdata->vif)) {
1906 * In mesh mode, ASSOCIATED isn't part of the nl80211
1907 * API but must follow AUTHENTICATED for driver state.
1909 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED))
1910 mask |= BIT(NL80211_STA_FLAG_ASSOCIATED);
1911 if (set & BIT(NL80211_STA_FLAG_AUTHENTICATED))
1912 set |= BIT(NL80211_STA_FLAG_ASSOCIATED);
1913 } else if (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
1915 * TDLS -- everything follows authorized, but
1916 * only becoming authorized is possible, not
1919 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
1920 set |= BIT(NL80211_STA_FLAG_AUTHENTICATED) |
1921 BIT(NL80211_STA_FLAG_ASSOCIATED);
1922 mask |= BIT(NL80211_STA_FLAG_AUTHENTICATED) |
1923 BIT(NL80211_STA_FLAG_ASSOCIATED);
1927 if (mask & BIT(NL80211_STA_FLAG_WME) &&
1928 local->hw.queues >= IEEE80211_NUM_ACS)
1929 sta->sta.wme = set & BIT(NL80211_STA_FLAG_WME);
1931 /* auth flags will be set later for TDLS,
1932 * and for unassociated stations that move to associated */
1933 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1934 !((mask & BIT(NL80211_STA_FLAG_ASSOCIATED)) &&
1935 (set & BIT(NL80211_STA_FLAG_ASSOCIATED)))) {
1936 ret = sta_apply_auth_flags(local, sta, mask, set);
1941 if (mask & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) {
1942 if (set & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE))
1943 set_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
1945 clear_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
1948 if (mask & BIT(NL80211_STA_FLAG_MFP)) {
1949 sta->sta.mfp = !!(set & BIT(NL80211_STA_FLAG_MFP));
1950 if (set & BIT(NL80211_STA_FLAG_MFP))
1951 set_sta_flag(sta, WLAN_STA_MFP);
1953 clear_sta_flag(sta, WLAN_STA_MFP);
1956 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
1957 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER))
1958 set_sta_flag(sta, WLAN_STA_TDLS_PEER);
1960 clear_sta_flag(sta, WLAN_STA_TDLS_PEER);
1963 /* mark TDLS channel switch support, if the AP allows it */
1964 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1965 !sdata->deflink.u.mgd.tdls_chan_switch_prohibited &&
1966 params->ext_capab_len >= 4 &&
1967 params->ext_capab[3] & WLAN_EXT_CAPA4_TDLS_CHAN_SWITCH)
1968 set_sta_flag(sta, WLAN_STA_TDLS_CHAN_SWITCH);
1970 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1971 !sdata->u.mgd.tdls_wider_bw_prohibited &&
1972 ieee80211_hw_check(&local->hw, TDLS_WIDER_BW) &&
1973 params->ext_capab_len >= 8 &&
1974 params->ext_capab[7] & WLAN_EXT_CAPA8_TDLS_WIDE_BW_ENABLED)
1975 set_sta_flag(sta, WLAN_STA_TDLS_WIDER_BW);
1977 if (params->sta_modify_mask & STATION_PARAM_APPLY_UAPSD) {
1978 sta->sta.uapsd_queues = params->uapsd_queues;
1979 sta->sta.max_sp = params->max_sp;
1982 ieee80211_sta_set_max_amsdu_subframes(sta, params->ext_capab,
1983 params->ext_capab_len);
1986 * cfg80211 validates this (1-2007) and allows setting the AID
1987 * only when creating a new station entry
1990 sta->sta.aid = params->aid;
1993 * Some of the following updates would be racy if called on an
1994 * existing station, via ieee80211_change_station(). However,
1995 * all such changes are rejected by cfg80211 except for updates
1996 * changing the supported rates on an existing but not yet used
2000 if (params->listen_interval >= 0)
2001 sta->listen_interval = params->listen_interval;
2003 ret = sta_link_apply_parameters(local, sta, false,
2004 ¶ms->link_sta_params);
2008 if (params->support_p2p_ps >= 0)
2009 sta->sta.support_p2p_ps = params->support_p2p_ps;
2011 if (ieee80211_vif_is_mesh(&sdata->vif))
2012 sta_apply_mesh_params(local, sta, params);
2014 if (params->airtime_weight)
2015 sta->airtime_weight = params->airtime_weight;
2017 /* set the STA state after all sta info from usermode has been set */
2018 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) ||
2019 set & BIT(NL80211_STA_FLAG_ASSOCIATED)) {
2020 ret = sta_apply_auth_flags(local, sta, mask, set);
2025 /* Mark the STA as MLO if MLD MAC address is available */
2026 if (params->link_sta_params.mld_mac)
2027 sta->sta.mlo = true;
2032 static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
2034 struct station_parameters *params)
2036 struct ieee80211_local *local = wiphy_priv(wiphy);
2037 struct sta_info *sta;
2038 struct ieee80211_sub_if_data *sdata;
2042 sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
2044 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
2045 sdata->vif.type != NL80211_IFTYPE_AP)
2048 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2050 if (ether_addr_equal(mac, sdata->vif.addr))
2053 if (!is_valid_ether_addr(mac))
2056 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER) &&
2057 sdata->vif.type == NL80211_IFTYPE_STATION &&
2058 !sdata->u.mgd.associated)
2062 * If we have a link ID, it can be a non-MLO station on an AP MLD,
2063 * but we need to have a link_mac in that case as well, so use the
2064 * STA's MAC address in that case.
2066 if (params->link_sta_params.link_id >= 0)
2067 sta = sta_info_alloc_with_link(sdata, mac,
2068 params->link_sta_params.link_id,
2069 params->link_sta_params.link_mac ?: mac,
2072 sta = sta_info_alloc(sdata, mac, GFP_KERNEL);
2077 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))
2078 sta->sta.tdls = true;
2080 /* Though the mutex is not needed here (since the station is not
2081 * visible yet), sta_apply_parameters (and inner functions) require
2082 * the mutex due to other paths.
2084 mutex_lock(&local->sta_mtx);
2085 err = sta_apply_parameters(local, sta, params);
2086 mutex_unlock(&local->sta_mtx);
2088 sta_info_free(local, sta);
2093 * for TDLS and for unassociated station, rate control should be
2094 * initialized only when rates are known and station is marked
2095 * authorized/associated
2097 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
2098 test_sta_flag(sta, WLAN_STA_ASSOC))
2099 rate_control_rate_init(sta);
2101 return sta_info_insert(sta);
2104 static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev,
2105 struct station_del_parameters *params)
2107 struct ieee80211_sub_if_data *sdata;
2109 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2112 return sta_info_destroy_addr_bss(sdata, params->mac);
2114 sta_info_flush(sdata);
2118 static int ieee80211_change_station(struct wiphy *wiphy,
2119 struct net_device *dev, const u8 *mac,
2120 struct station_parameters *params)
2122 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2123 struct ieee80211_local *local = wiphy_priv(wiphy);
2124 struct sta_info *sta;
2125 struct ieee80211_sub_if_data *vlansdata;
2126 enum cfg80211_station_type statype;
2129 mutex_lock(&local->sta_mtx);
2131 sta = sta_info_get_bss(sdata, mac);
2137 switch (sdata->vif.type) {
2138 case NL80211_IFTYPE_MESH_POINT:
2139 if (sdata->u.mesh.user_mpm)
2140 statype = CFG80211_STA_MESH_PEER_USER;
2142 statype = CFG80211_STA_MESH_PEER_KERNEL;
2144 case NL80211_IFTYPE_ADHOC:
2145 statype = CFG80211_STA_IBSS;
2147 case NL80211_IFTYPE_STATION:
2148 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
2149 statype = CFG80211_STA_AP_STA;
2152 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
2153 statype = CFG80211_STA_TDLS_PEER_ACTIVE;
2155 statype = CFG80211_STA_TDLS_PEER_SETUP;
2157 case NL80211_IFTYPE_AP:
2158 case NL80211_IFTYPE_AP_VLAN:
2159 if (test_sta_flag(sta, WLAN_STA_ASSOC))
2160 statype = CFG80211_STA_AP_CLIENT;
2162 statype = CFG80211_STA_AP_CLIENT_UNASSOC;
2169 err = cfg80211_check_station_change(wiphy, params, statype);
2173 if (params->vlan && params->vlan != sta->sdata->dev) {
2174 vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
2176 if (params->vlan->ieee80211_ptr->use_4addr) {
2177 if (vlansdata->u.vlan.sta) {
2182 rcu_assign_pointer(vlansdata->u.vlan.sta, sta);
2183 __ieee80211_check_fast_rx_iface(vlansdata);
2184 drv_sta_set_4addr(local, sta->sdata, &sta->sta, true);
2187 if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
2188 sta->sdata->u.vlan.sta) {
2189 ieee80211_clear_fast_rx(sta);
2190 RCU_INIT_POINTER(sta->sdata->u.vlan.sta, NULL);
2193 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
2194 ieee80211_vif_dec_num_mcast(sta->sdata);
2196 sta->sdata = vlansdata;
2197 ieee80211_check_fast_xmit(sta);
2199 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED)) {
2200 ieee80211_vif_inc_num_mcast(sta->sdata);
2201 cfg80211_send_layer2_update(sta->sdata->dev,
2206 /* we use sta_info_get_bss() so this might be different */
2207 if (sdata != sta->sdata) {
2208 mutex_lock_nested(&sta->sdata->wdev.mtx, 1);
2209 err = sta_apply_parameters(local, sta, params);
2210 mutex_unlock(&sta->sdata->wdev.mtx);
2212 err = sta_apply_parameters(local, sta, params);
2217 mutex_unlock(&local->sta_mtx);
2219 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
2220 params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
2221 ieee80211_recalc_ps(local);
2222 ieee80211_recalc_ps_vif(sdata);
2227 mutex_unlock(&local->sta_mtx);
2231 #ifdef CONFIG_MAC80211_MESH
2232 static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev,
2233 const u8 *dst, const u8 *next_hop)
2235 struct ieee80211_sub_if_data *sdata;
2236 struct mesh_path *mpath;
2237 struct sta_info *sta;
2239 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2242 sta = sta_info_get(sdata, next_hop);
2248 mpath = mesh_path_add(sdata, dst);
2249 if (IS_ERR(mpath)) {
2251 return PTR_ERR(mpath);
2254 mesh_path_fix_nexthop(mpath, sta);
2260 static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev,
2263 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2266 return mesh_path_del(sdata, dst);
2268 mesh_path_flush_by_iface(sdata);
2272 static int ieee80211_change_mpath(struct wiphy *wiphy, struct net_device *dev,
2273 const u8 *dst, const u8 *next_hop)
2275 struct ieee80211_sub_if_data *sdata;
2276 struct mesh_path *mpath;
2277 struct sta_info *sta;
2279 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2283 sta = sta_info_get(sdata, next_hop);
2289 mpath = mesh_path_lookup(sdata, dst);
2295 mesh_path_fix_nexthop(mpath, sta);
2301 static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop,
2302 struct mpath_info *pinfo)
2304 struct sta_info *next_hop_sta = rcu_dereference(mpath->next_hop);
2307 memcpy(next_hop, next_hop_sta->sta.addr, ETH_ALEN);
2309 eth_zero_addr(next_hop);
2311 memset(pinfo, 0, sizeof(*pinfo));
2313 pinfo->generation = mpath->sdata->u.mesh.mesh_paths_generation;
2315 pinfo->filled = MPATH_INFO_FRAME_QLEN |
2318 MPATH_INFO_EXPTIME |
2319 MPATH_INFO_DISCOVERY_TIMEOUT |
2320 MPATH_INFO_DISCOVERY_RETRIES |
2322 MPATH_INFO_HOP_COUNT |
2323 MPATH_INFO_PATH_CHANGE;
2325 pinfo->frame_qlen = mpath->frame_queue.qlen;
2326 pinfo->sn = mpath->sn;
2327 pinfo->metric = mpath->metric;
2328 if (time_before(jiffies, mpath->exp_time))
2329 pinfo->exptime = jiffies_to_msecs(mpath->exp_time - jiffies);
2330 pinfo->discovery_timeout =
2331 jiffies_to_msecs(mpath->discovery_timeout);
2332 pinfo->discovery_retries = mpath->discovery_retries;
2333 if (mpath->flags & MESH_PATH_ACTIVE)
2334 pinfo->flags |= NL80211_MPATH_FLAG_ACTIVE;
2335 if (mpath->flags & MESH_PATH_RESOLVING)
2336 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING;
2337 if (mpath->flags & MESH_PATH_SN_VALID)
2338 pinfo->flags |= NL80211_MPATH_FLAG_SN_VALID;
2339 if (mpath->flags & MESH_PATH_FIXED)
2340 pinfo->flags |= NL80211_MPATH_FLAG_FIXED;
2341 if (mpath->flags & MESH_PATH_RESOLVED)
2342 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVED;
2343 pinfo->hop_count = mpath->hop_count;
2344 pinfo->path_change_count = mpath->path_change_count;
2347 static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev,
2348 u8 *dst, u8 *next_hop, struct mpath_info *pinfo)
2351 struct ieee80211_sub_if_data *sdata;
2352 struct mesh_path *mpath;
2354 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2357 mpath = mesh_path_lookup(sdata, dst);
2362 memcpy(dst, mpath->dst, ETH_ALEN);
2363 mpath_set_pinfo(mpath, next_hop, pinfo);
2368 static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev,
2369 int idx, u8 *dst, u8 *next_hop,
2370 struct mpath_info *pinfo)
2372 struct ieee80211_sub_if_data *sdata;
2373 struct mesh_path *mpath;
2375 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2378 mpath = mesh_path_lookup_by_idx(sdata, idx);
2383 memcpy(dst, mpath->dst, ETH_ALEN);
2384 mpath_set_pinfo(mpath, next_hop, pinfo);
2389 static void mpp_set_pinfo(struct mesh_path *mpath, u8 *mpp,
2390 struct mpath_info *pinfo)
2392 memset(pinfo, 0, sizeof(*pinfo));
2393 memcpy(mpp, mpath->mpp, ETH_ALEN);
2395 pinfo->generation = mpath->sdata->u.mesh.mpp_paths_generation;
2398 static int ieee80211_get_mpp(struct wiphy *wiphy, struct net_device *dev,
2399 u8 *dst, u8 *mpp, struct mpath_info *pinfo)
2402 struct ieee80211_sub_if_data *sdata;
2403 struct mesh_path *mpath;
2405 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2408 mpath = mpp_path_lookup(sdata, dst);
2413 memcpy(dst, mpath->dst, ETH_ALEN);
2414 mpp_set_pinfo(mpath, mpp, pinfo);
2419 static int ieee80211_dump_mpp(struct wiphy *wiphy, struct net_device *dev,
2420 int idx, u8 *dst, u8 *mpp,
2421 struct mpath_info *pinfo)
2423 struct ieee80211_sub_if_data *sdata;
2424 struct mesh_path *mpath;
2426 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2429 mpath = mpp_path_lookup_by_idx(sdata, idx);
2434 memcpy(dst, mpath->dst, ETH_ALEN);
2435 mpp_set_pinfo(mpath, mpp, pinfo);
2440 static int ieee80211_get_mesh_config(struct wiphy *wiphy,
2441 struct net_device *dev,
2442 struct mesh_config *conf)
2444 struct ieee80211_sub_if_data *sdata;
2445 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2447 memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config));
2451 static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask)
2453 return (mask >> (parm-1)) & 0x1;
2456 static int copy_mesh_setup(struct ieee80211_if_mesh *ifmsh,
2457 const struct mesh_setup *setup)
2460 struct ieee80211_sub_if_data *sdata = container_of(ifmsh,
2461 struct ieee80211_sub_if_data, u.mesh);
2464 /* allocate information elements */
2467 if (setup->ie_len) {
2468 new_ie = kmemdup(setup->ie, setup->ie_len,
2473 ifmsh->ie_len = setup->ie_len;
2476 /* now copy the rest of the setup parameters */
2477 ifmsh->mesh_id_len = setup->mesh_id_len;
2478 memcpy(ifmsh->mesh_id, setup->mesh_id, ifmsh->mesh_id_len);
2479 ifmsh->mesh_sp_id = setup->sync_method;
2480 ifmsh->mesh_pp_id = setup->path_sel_proto;
2481 ifmsh->mesh_pm_id = setup->path_metric;
2482 ifmsh->user_mpm = setup->user_mpm;
2483 ifmsh->mesh_auth_id = setup->auth_id;
2484 ifmsh->security = IEEE80211_MESH_SEC_NONE;
2485 ifmsh->userspace_handles_dfs = setup->userspace_handles_dfs;
2486 if (setup->is_authenticated)
2487 ifmsh->security |= IEEE80211_MESH_SEC_AUTHED;
2488 if (setup->is_secure)
2489 ifmsh->security |= IEEE80211_MESH_SEC_SECURED;
2491 /* mcast rate setting in Mesh Node */
2492 memcpy(sdata->vif.bss_conf.mcast_rate, setup->mcast_rate,
2493 sizeof(setup->mcast_rate));
2494 sdata->vif.bss_conf.basic_rates = setup->basic_rates;
2496 sdata->vif.bss_conf.beacon_int = setup->beacon_interval;
2497 sdata->vif.bss_conf.dtim_period = setup->dtim_period;
2499 sdata->beacon_rate_set = false;
2500 if (wiphy_ext_feature_isset(sdata->local->hw.wiphy,
2501 NL80211_EXT_FEATURE_BEACON_RATE_LEGACY)) {
2502 for (i = 0; i < NUM_NL80211_BANDS; i++) {
2503 sdata->beacon_rateidx_mask[i] =
2504 setup->beacon_rate.control[i].legacy;
2505 if (sdata->beacon_rateidx_mask[i])
2506 sdata->beacon_rate_set = true;
2513 static int ieee80211_update_mesh_config(struct wiphy *wiphy,
2514 struct net_device *dev, u32 mask,
2515 const struct mesh_config *nconf)
2517 struct mesh_config *conf;
2518 struct ieee80211_sub_if_data *sdata;
2519 struct ieee80211_if_mesh *ifmsh;
2521 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2522 ifmsh = &sdata->u.mesh;
2524 /* Set the config options which we are interested in setting */
2525 conf = &(sdata->u.mesh.mshcfg);
2526 if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask))
2527 conf->dot11MeshRetryTimeout = nconf->dot11MeshRetryTimeout;
2528 if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT, mask))
2529 conf->dot11MeshConfirmTimeout = nconf->dot11MeshConfirmTimeout;
2530 if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT, mask))
2531 conf->dot11MeshHoldingTimeout = nconf->dot11MeshHoldingTimeout;
2532 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS, mask))
2533 conf->dot11MeshMaxPeerLinks = nconf->dot11MeshMaxPeerLinks;
2534 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES, mask))
2535 conf->dot11MeshMaxRetries = nconf->dot11MeshMaxRetries;
2536 if (_chg_mesh_attr(NL80211_MESHCONF_TTL, mask))
2537 conf->dot11MeshTTL = nconf->dot11MeshTTL;
2538 if (_chg_mesh_attr(NL80211_MESHCONF_ELEMENT_TTL, mask))
2539 conf->element_ttl = nconf->element_ttl;
2540 if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask)) {
2541 if (ifmsh->user_mpm)
2543 conf->auto_open_plinks = nconf->auto_open_plinks;
2545 if (_chg_mesh_attr(NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR, mask))
2546 conf->dot11MeshNbrOffsetMaxNeighbor =
2547 nconf->dot11MeshNbrOffsetMaxNeighbor;
2548 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, mask))
2549 conf->dot11MeshHWMPmaxPREQretries =
2550 nconf->dot11MeshHWMPmaxPREQretries;
2551 if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME, mask))
2552 conf->path_refresh_time = nconf->path_refresh_time;
2553 if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, mask))
2554 conf->min_discovery_timeout = nconf->min_discovery_timeout;
2555 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, mask))
2556 conf->dot11MeshHWMPactivePathTimeout =
2557 nconf->dot11MeshHWMPactivePathTimeout;
2558 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, mask))
2559 conf->dot11MeshHWMPpreqMinInterval =
2560 nconf->dot11MeshHWMPpreqMinInterval;
2561 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL, mask))
2562 conf->dot11MeshHWMPperrMinInterval =
2563 nconf->dot11MeshHWMPperrMinInterval;
2564 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
2566 conf->dot11MeshHWMPnetDiameterTraversalTime =
2567 nconf->dot11MeshHWMPnetDiameterTraversalTime;
2568 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOTMODE, mask)) {
2569 conf->dot11MeshHWMPRootMode = nconf->dot11MeshHWMPRootMode;
2570 ieee80211_mesh_root_setup(ifmsh);
2572 if (_chg_mesh_attr(NL80211_MESHCONF_GATE_ANNOUNCEMENTS, mask)) {
2573 /* our current gate announcement implementation rides on root
2574 * announcements, so require this ifmsh to also be a root node
2576 if (nconf->dot11MeshGateAnnouncementProtocol &&
2577 !(conf->dot11MeshHWMPRootMode > IEEE80211_ROOTMODE_ROOT)) {
2578 conf->dot11MeshHWMPRootMode = IEEE80211_PROACTIVE_RANN;
2579 ieee80211_mesh_root_setup(ifmsh);
2581 conf->dot11MeshGateAnnouncementProtocol =
2582 nconf->dot11MeshGateAnnouncementProtocol;
2584 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_RANN_INTERVAL, mask))
2585 conf->dot11MeshHWMPRannInterval =
2586 nconf->dot11MeshHWMPRannInterval;
2587 if (_chg_mesh_attr(NL80211_MESHCONF_FORWARDING, mask))
2588 conf->dot11MeshForwarding = nconf->dot11MeshForwarding;
2589 if (_chg_mesh_attr(NL80211_MESHCONF_RSSI_THRESHOLD, mask)) {
2590 /* our RSSI threshold implementation is supported only for
2591 * devices that report signal in dBm.
2593 if (!ieee80211_hw_check(&sdata->local->hw, SIGNAL_DBM))
2595 conf->rssi_threshold = nconf->rssi_threshold;
2597 if (_chg_mesh_attr(NL80211_MESHCONF_HT_OPMODE, mask)) {
2598 conf->ht_opmode = nconf->ht_opmode;
2599 sdata->vif.bss_conf.ht_operation_mode = nconf->ht_opmode;
2600 ieee80211_link_info_change_notify(sdata, &sdata->deflink,
2603 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT, mask))
2604 conf->dot11MeshHWMPactivePathToRootTimeout =
2605 nconf->dot11MeshHWMPactivePathToRootTimeout;
2606 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOT_INTERVAL, mask))
2607 conf->dot11MeshHWMProotInterval =
2608 nconf->dot11MeshHWMProotInterval;
2609 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL, mask))
2610 conf->dot11MeshHWMPconfirmationInterval =
2611 nconf->dot11MeshHWMPconfirmationInterval;
2612 if (_chg_mesh_attr(NL80211_MESHCONF_POWER_MODE, mask)) {
2613 conf->power_mode = nconf->power_mode;
2614 ieee80211_mps_local_status_update(sdata);
2616 if (_chg_mesh_attr(NL80211_MESHCONF_AWAKE_WINDOW, mask))
2617 conf->dot11MeshAwakeWindowDuration =
2618 nconf->dot11MeshAwakeWindowDuration;
2619 if (_chg_mesh_attr(NL80211_MESHCONF_PLINK_TIMEOUT, mask))
2620 conf->plink_timeout = nconf->plink_timeout;
2621 if (_chg_mesh_attr(NL80211_MESHCONF_CONNECTED_TO_GATE, mask))
2622 conf->dot11MeshConnectedToMeshGate =
2623 nconf->dot11MeshConnectedToMeshGate;
2624 if (_chg_mesh_attr(NL80211_MESHCONF_NOLEARN, mask))
2625 conf->dot11MeshNolearn = nconf->dot11MeshNolearn;
2626 if (_chg_mesh_attr(NL80211_MESHCONF_CONNECTED_TO_AS, mask))
2627 conf->dot11MeshConnectedToAuthServer =
2628 nconf->dot11MeshConnectedToAuthServer;
2629 ieee80211_mbss_info_change_notify(sdata, BSS_CHANGED_BEACON);
2633 static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev,
2634 const struct mesh_config *conf,
2635 const struct mesh_setup *setup)
2637 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2638 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
2641 memcpy(&ifmsh->mshcfg, conf, sizeof(struct mesh_config));
2642 err = copy_mesh_setup(ifmsh, setup);
2646 sdata->control_port_over_nl80211 = setup->control_port_over_nl80211;
2648 /* can mesh use other SMPS modes? */
2649 sdata->deflink.smps_mode = IEEE80211_SMPS_OFF;
2650 sdata->deflink.needed_rx_chains = sdata->local->rx_chains;
2652 mutex_lock(&sdata->local->mtx);
2653 err = ieee80211_link_use_channel(&sdata->deflink, &setup->chandef,
2654 IEEE80211_CHANCTX_SHARED);
2655 mutex_unlock(&sdata->local->mtx);
2659 return ieee80211_start_mesh(sdata);
2662 static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev)
2664 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2666 ieee80211_stop_mesh(sdata);
2667 mutex_lock(&sdata->local->mtx);
2668 ieee80211_link_release_channel(&sdata->deflink);
2669 kfree(sdata->u.mesh.ie);
2670 mutex_unlock(&sdata->local->mtx);
2676 static int ieee80211_change_bss(struct wiphy *wiphy,
2677 struct net_device *dev,
2678 struct bss_parameters *params)
2680 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2681 struct ieee80211_link_data *link;
2682 struct ieee80211_supported_band *sband;
2685 link = ieee80211_link_or_deflink(sdata, params->link_id, true);
2687 return PTR_ERR(link);
2689 if (!sdata_dereference(link->u.ap.beacon, sdata))
2692 sband = ieee80211_get_link_sband(link);
2696 if (params->basic_rates) {
2697 if (!ieee80211_parse_bitrates(link->conf->chandef.width,
2698 wiphy->bands[sband->band],
2699 params->basic_rates,
2700 params->basic_rates_len,
2701 &link->conf->basic_rates))
2703 changed |= BSS_CHANGED_BASIC_RATES;
2704 ieee80211_check_rate_mask(link);
2707 if (params->use_cts_prot >= 0) {
2708 link->conf->use_cts_prot = params->use_cts_prot;
2709 changed |= BSS_CHANGED_ERP_CTS_PROT;
2711 if (params->use_short_preamble >= 0) {
2712 link->conf->use_short_preamble = params->use_short_preamble;
2713 changed |= BSS_CHANGED_ERP_PREAMBLE;
2716 if (!link->conf->use_short_slot &&
2717 (sband->band == NL80211_BAND_5GHZ ||
2718 sband->band == NL80211_BAND_6GHZ)) {
2719 link->conf->use_short_slot = true;
2720 changed |= BSS_CHANGED_ERP_SLOT;
2723 if (params->use_short_slot_time >= 0) {
2724 link->conf->use_short_slot = params->use_short_slot_time;
2725 changed |= BSS_CHANGED_ERP_SLOT;
2728 if (params->ap_isolate >= 0) {
2729 if (params->ap_isolate)
2730 sdata->flags |= IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
2732 sdata->flags &= ~IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
2733 ieee80211_check_fast_rx_iface(sdata);
2736 if (params->ht_opmode >= 0) {
2737 link->conf->ht_operation_mode = (u16)params->ht_opmode;
2738 changed |= BSS_CHANGED_HT;
2741 if (params->p2p_ctwindow >= 0) {
2742 link->conf->p2p_noa_attr.oppps_ctwindow &=
2743 ~IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
2744 link->conf->p2p_noa_attr.oppps_ctwindow |=
2745 params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
2746 changed |= BSS_CHANGED_P2P_PS;
2749 if (params->p2p_opp_ps > 0) {
2750 link->conf->p2p_noa_attr.oppps_ctwindow |=
2751 IEEE80211_P2P_OPPPS_ENABLE_BIT;
2752 changed |= BSS_CHANGED_P2P_PS;
2753 } else if (params->p2p_opp_ps == 0) {
2754 link->conf->p2p_noa_attr.oppps_ctwindow &=
2755 ~IEEE80211_P2P_OPPPS_ENABLE_BIT;
2756 changed |= BSS_CHANGED_P2P_PS;
2759 ieee80211_link_info_change_notify(sdata, link, changed);
2764 static int ieee80211_set_txq_params(struct wiphy *wiphy,
2765 struct net_device *dev,
2766 struct ieee80211_txq_params *params)
2768 struct ieee80211_local *local = wiphy_priv(wiphy);
2769 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2770 struct ieee80211_link_data *link =
2771 ieee80211_link_or_deflink(sdata, params->link_id, true);
2772 struct ieee80211_tx_queue_params p;
2774 if (!local->ops->conf_tx)
2777 if (local->hw.queues < IEEE80211_NUM_ACS)
2781 return PTR_ERR(link);
2783 memset(&p, 0, sizeof(p));
2784 p.aifs = params->aifs;
2785 p.cw_max = params->cwmax;
2786 p.cw_min = params->cwmin;
2787 p.txop = params->txop;
2790 * Setting tx queue params disables u-apsd because it's only
2791 * called in master mode.
2795 ieee80211_regulatory_limit_wmm_params(sdata, &p, params->ac);
2797 link->tx_conf[params->ac] = p;
2798 if (drv_conf_tx(local, link, params->ac, &p)) {
2799 wiphy_debug(local->hw.wiphy,
2800 "failed to set TX queue parameters for AC %d\n",
2805 ieee80211_link_info_change_notify(sdata, link,
2812 static int ieee80211_suspend(struct wiphy *wiphy,
2813 struct cfg80211_wowlan *wowlan)
2815 return __ieee80211_suspend(wiphy_priv(wiphy), wowlan);
2818 static int ieee80211_resume(struct wiphy *wiphy)
2820 return __ieee80211_resume(wiphy_priv(wiphy));
2823 #define ieee80211_suspend NULL
2824 #define ieee80211_resume NULL
2827 static int ieee80211_scan(struct wiphy *wiphy,
2828 struct cfg80211_scan_request *req)
2830 struct ieee80211_sub_if_data *sdata;
2832 sdata = IEEE80211_WDEV_TO_SUB_IF(req->wdev);
2834 switch (ieee80211_vif_type_p2p(&sdata->vif)) {
2835 case NL80211_IFTYPE_STATION:
2836 case NL80211_IFTYPE_ADHOC:
2837 case NL80211_IFTYPE_MESH_POINT:
2838 case NL80211_IFTYPE_P2P_CLIENT:
2839 case NL80211_IFTYPE_P2P_DEVICE:
2841 case NL80211_IFTYPE_P2P_GO:
2842 if (sdata->local->ops->hw_scan)
2845 * FIXME: implement NoA while scanning in software,
2846 * for now fall through to allow scanning only when
2847 * beaconing hasn't been configured yet
2850 case NL80211_IFTYPE_AP:
2852 * If the scan has been forced (and the driver supports
2853 * forcing), don't care about being beaconing already.
2854 * This will create problems to the attached stations (e.g. all
2855 * the frames sent while scanning on other channel will be
2858 if (sdata->deflink.u.ap.beacon &&
2859 (!(wiphy->features & NL80211_FEATURE_AP_SCAN) ||
2860 !(req->flags & NL80211_SCAN_FLAG_AP)))
2863 case NL80211_IFTYPE_NAN:
2868 return ieee80211_request_scan(sdata, req);
2871 static void ieee80211_abort_scan(struct wiphy *wiphy, struct wireless_dev *wdev)
2873 ieee80211_scan_cancel(wiphy_priv(wiphy));
2877 ieee80211_sched_scan_start(struct wiphy *wiphy,
2878 struct net_device *dev,
2879 struct cfg80211_sched_scan_request *req)
2881 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2883 if (!sdata->local->ops->sched_scan_start)
2886 return ieee80211_request_sched_scan_start(sdata, req);
2890 ieee80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev,
2893 struct ieee80211_local *local = wiphy_priv(wiphy);
2895 if (!local->ops->sched_scan_stop)
2898 return ieee80211_request_sched_scan_stop(local);
2901 static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev,
2902 struct cfg80211_auth_request *req)
2904 return ieee80211_mgd_auth(IEEE80211_DEV_TO_SUB_IF(dev), req);
2907 static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev,
2908 struct cfg80211_assoc_request *req)
2910 return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
2913 static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev,
2914 struct cfg80211_deauth_request *req)
2916 return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev), req);
2919 static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
2920 struct cfg80211_disassoc_request *req)
2922 return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
2925 static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
2926 struct cfg80211_ibss_params *params)
2928 return ieee80211_ibss_join(IEEE80211_DEV_TO_SUB_IF(dev), params);
2931 static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
2933 return ieee80211_ibss_leave(IEEE80211_DEV_TO_SUB_IF(dev));
2936 static int ieee80211_join_ocb(struct wiphy *wiphy, struct net_device *dev,
2937 struct ocb_setup *setup)
2939 return ieee80211_ocb_join(IEEE80211_DEV_TO_SUB_IF(dev), setup);
2942 static int ieee80211_leave_ocb(struct wiphy *wiphy, struct net_device *dev)
2944 return ieee80211_ocb_leave(IEEE80211_DEV_TO_SUB_IF(dev));
2947 static int ieee80211_set_mcast_rate(struct wiphy *wiphy, struct net_device *dev,
2948 int rate[NUM_NL80211_BANDS])
2950 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2952 memcpy(sdata->vif.bss_conf.mcast_rate, rate,
2953 sizeof(int) * NUM_NL80211_BANDS);
2955 ieee80211_link_info_change_notify(sdata, &sdata->deflink,
2956 BSS_CHANGED_MCAST_RATE);
2961 static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
2963 struct ieee80211_local *local = wiphy_priv(wiphy);
2966 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
2967 ieee80211_check_fast_xmit_all(local);
2969 err = drv_set_frag_threshold(local, wiphy->frag_threshold);
2972 ieee80211_check_fast_xmit_all(local);
2977 if ((changed & WIPHY_PARAM_COVERAGE_CLASS) ||
2978 (changed & WIPHY_PARAM_DYN_ACK)) {
2981 coverage_class = changed & WIPHY_PARAM_COVERAGE_CLASS ?
2982 wiphy->coverage_class : -1;
2983 err = drv_set_coverage_class(local, coverage_class);
2989 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
2990 err = drv_set_rts_threshold(local, wiphy->rts_threshold);
2996 if (changed & WIPHY_PARAM_RETRY_SHORT) {
2997 if (wiphy->retry_short > IEEE80211_MAX_TX_RETRY)
2999 local->hw.conf.short_frame_max_tx_count = wiphy->retry_short;
3001 if (changed & WIPHY_PARAM_RETRY_LONG) {
3002 if (wiphy->retry_long > IEEE80211_MAX_TX_RETRY)
3004 local->hw.conf.long_frame_max_tx_count = wiphy->retry_long;
3007 (WIPHY_PARAM_RETRY_SHORT | WIPHY_PARAM_RETRY_LONG))
3008 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS);
3010 if (changed & (WIPHY_PARAM_TXQ_LIMIT |
3011 WIPHY_PARAM_TXQ_MEMORY_LIMIT |
3012 WIPHY_PARAM_TXQ_QUANTUM))
3013 ieee80211_txq_set_params(local);
3018 static int ieee80211_set_tx_power(struct wiphy *wiphy,
3019 struct wireless_dev *wdev,
3020 enum nl80211_tx_power_setting type, int mbm)
3022 struct ieee80211_local *local = wiphy_priv(wiphy);
3023 struct ieee80211_sub_if_data *sdata;
3024 enum nl80211_tx_power_setting txp_type = type;
3025 bool update_txp_type = false;
3026 bool has_monitor = false;
3029 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
3031 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) {
3032 sdata = wiphy_dereference(local->hw.wiphy,
3033 local->monitor_sdata);
3039 case NL80211_TX_POWER_AUTOMATIC:
3040 sdata->deflink.user_power_level =
3041 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 sdata->deflink.user_power_level = MBM_TO_DBM(mbm);
3052 if (txp_type != sdata->vif.bss_conf.txpower_type) {
3053 update_txp_type = true;
3054 sdata->vif.bss_conf.txpower_type = txp_type;
3057 ieee80211_recalc_txpower(sdata, update_txp_type);
3063 case NL80211_TX_POWER_AUTOMATIC:
3064 local->user_power_level = IEEE80211_UNSET_POWER_LEVEL;
3065 txp_type = NL80211_TX_POWER_LIMITED;
3067 case NL80211_TX_POWER_LIMITED:
3068 case NL80211_TX_POWER_FIXED:
3069 if (mbm < 0 || (mbm % 100))
3071 local->user_power_level = MBM_TO_DBM(mbm);
3075 mutex_lock(&local->iflist_mtx);
3076 list_for_each_entry(sdata, &local->interfaces, list) {
3077 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) {
3081 sdata->deflink.user_power_level = local->user_power_level;
3082 if (txp_type != sdata->vif.bss_conf.txpower_type)
3083 update_txp_type = true;
3084 sdata->vif.bss_conf.txpower_type = txp_type;
3086 list_for_each_entry(sdata, &local->interfaces, list) {
3087 if (sdata->vif.type == NL80211_IFTYPE_MONITOR)
3089 ieee80211_recalc_txpower(sdata, update_txp_type);
3091 mutex_unlock(&local->iflist_mtx);
3094 sdata = wiphy_dereference(local->hw.wiphy,
3095 local->monitor_sdata);
3097 sdata->deflink.user_power_level = local->user_power_level;
3098 if (txp_type != sdata->vif.bss_conf.txpower_type)
3099 update_txp_type = true;
3100 sdata->vif.bss_conf.txpower_type = txp_type;
3102 ieee80211_recalc_txpower(sdata, update_txp_type);
3109 static int ieee80211_get_tx_power(struct wiphy *wiphy,
3110 struct wireless_dev *wdev,
3113 struct ieee80211_local *local = wiphy_priv(wiphy);
3114 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
3116 if (local->ops->get_txpower)
3117 return drv_get_txpower(local, sdata, dbm);
3119 if (!local->use_chanctx)
3120 *dbm = local->hw.conf.power_level;
3122 *dbm = sdata->vif.bss_conf.txpower;
3127 static void ieee80211_rfkill_poll(struct wiphy *wiphy)
3129 struct ieee80211_local *local = wiphy_priv(wiphy);
3131 drv_rfkill_poll(local);
3134 #ifdef CONFIG_NL80211_TESTMODE
3135 static int ieee80211_testmode_cmd(struct wiphy *wiphy,
3136 struct wireless_dev *wdev,
3137 void *data, int len)
3139 struct ieee80211_local *local = wiphy_priv(wiphy);
3140 struct ieee80211_vif *vif = NULL;
3142 if (!local->ops->testmode_cmd)
3146 struct ieee80211_sub_if_data *sdata;
3148 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
3149 if (sdata->flags & IEEE80211_SDATA_IN_DRIVER)
3153 return local->ops->testmode_cmd(&local->hw, vif, data, len);
3156 static int ieee80211_testmode_dump(struct wiphy *wiphy,
3157 struct sk_buff *skb,
3158 struct netlink_callback *cb,
3159 void *data, int len)
3161 struct ieee80211_local *local = wiphy_priv(wiphy);
3163 if (!local->ops->testmode_dump)
3166 return local->ops->testmode_dump(&local->hw, skb, cb, data, len);
3170 int __ieee80211_request_smps_mgd(struct ieee80211_sub_if_data *sdata,
3171 struct ieee80211_link_data *link,
3172 enum ieee80211_smps_mode smps_mode)
3175 enum ieee80211_smps_mode old_req;
3177 struct sta_info *sta;
3178 bool tdls_peer_found = false;
3180 lockdep_assert_held(&sdata->wdev.mtx);
3182 if (WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION))
3185 old_req = link->u.mgd.req_smps;
3186 link->u.mgd.req_smps = smps_mode;
3188 if (old_req == smps_mode &&
3189 smps_mode != IEEE80211_SMPS_AUTOMATIC)
3193 * If not associated, or current association is not an HT
3194 * association, there's no need to do anything, just store
3195 * the new value until we associate.
3197 if (!sdata->u.mgd.associated ||
3198 link->conf->chandef.width == NL80211_CHAN_WIDTH_20_NOHT)
3201 ap = link->u.mgd.bssid;
3204 list_for_each_entry_rcu(sta, &sdata->local->sta_list, list) {
3205 if (!sta->sta.tdls || sta->sdata != sdata || !sta->uploaded ||
3206 !test_sta_flag(sta, WLAN_STA_AUTHORIZED))
3209 tdls_peer_found = true;
3214 if (smps_mode == IEEE80211_SMPS_AUTOMATIC) {
3215 if (tdls_peer_found || !sdata->u.mgd.powersave)
3216 smps_mode = IEEE80211_SMPS_OFF;
3218 smps_mode = IEEE80211_SMPS_DYNAMIC;
3221 /* send SM PS frame to AP */
3222 err = ieee80211_send_smps_action(sdata, smps_mode,
3225 link->u.mgd.req_smps = old_req;
3226 else if (smps_mode != IEEE80211_SMPS_OFF && tdls_peer_found)
3227 ieee80211_teardown_tdls_peers(sdata);
3232 static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
3233 bool enabled, int timeout)
3235 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3236 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
3237 unsigned int link_id;
3239 if (sdata->vif.type != NL80211_IFTYPE_STATION)
3242 if (!ieee80211_hw_check(&local->hw, SUPPORTS_PS))
3245 if (enabled == sdata->u.mgd.powersave &&
3246 timeout == local->dynamic_ps_forced_timeout)
3249 sdata->u.mgd.powersave = enabled;
3250 local->dynamic_ps_forced_timeout = timeout;
3252 /* no change, but if automatic follow powersave */
3254 for (link_id = 0; link_id < ARRAY_SIZE(sdata->link); link_id++) {
3255 struct ieee80211_link_data *link;
3257 link = sdata_dereference(sdata->link[link_id], sdata);
3261 __ieee80211_request_smps_mgd(sdata, link,
3262 link->u.mgd.req_smps);
3264 sdata_unlock(sdata);
3266 if (ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS))
3267 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
3269 ieee80211_recalc_ps(local);
3270 ieee80211_recalc_ps_vif(sdata);
3271 ieee80211_check_fast_rx_iface(sdata);
3276 static int ieee80211_set_cqm_rssi_config(struct wiphy *wiphy,
3277 struct net_device *dev,
3278 s32 rssi_thold, u32 rssi_hyst)
3280 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3281 struct ieee80211_vif *vif = &sdata->vif;
3282 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
3284 if (rssi_thold == bss_conf->cqm_rssi_thold &&
3285 rssi_hyst == bss_conf->cqm_rssi_hyst)
3288 if (sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER &&
3289 !(sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI))
3292 bss_conf->cqm_rssi_thold = rssi_thold;
3293 bss_conf->cqm_rssi_hyst = rssi_hyst;
3294 bss_conf->cqm_rssi_low = 0;
3295 bss_conf->cqm_rssi_high = 0;
3296 sdata->deflink.u.mgd.last_cqm_event_signal = 0;
3298 /* tell the driver upon association, unless already associated */
3299 if (sdata->u.mgd.associated &&
3300 sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)
3301 ieee80211_link_info_change_notify(sdata, &sdata->deflink,
3307 static int ieee80211_set_cqm_rssi_range_config(struct wiphy *wiphy,
3308 struct net_device *dev,
3309 s32 rssi_low, s32 rssi_high)
3311 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3312 struct ieee80211_vif *vif = &sdata->vif;
3313 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
3315 if (sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER)
3318 bss_conf->cqm_rssi_low = rssi_low;
3319 bss_conf->cqm_rssi_high = rssi_high;
3320 bss_conf->cqm_rssi_thold = 0;
3321 bss_conf->cqm_rssi_hyst = 0;
3322 sdata->deflink.u.mgd.last_cqm_event_signal = 0;
3324 /* tell the driver upon association, unless already associated */
3325 if (sdata->u.mgd.associated &&
3326 sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)
3327 ieee80211_link_info_change_notify(sdata, &sdata->deflink,
3333 static int ieee80211_set_bitrate_mask(struct wiphy *wiphy,
3334 struct net_device *dev,
3335 unsigned int link_id,
3337 const struct cfg80211_bitrate_mask *mask)
3339 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3340 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
3343 if (!ieee80211_sdata_running(sdata))
3347 * If active validate the setting and reject it if it doesn't leave
3348 * at least one basic rate usable, since we really have to be able
3349 * to send something, and if we're an AP we have to be able to do
3350 * so at a basic rate so that all clients can receive it.
3352 if (rcu_access_pointer(sdata->vif.bss_conf.chanctx_conf) &&
3353 sdata->vif.bss_conf.chandef.chan) {
3354 u32 basic_rates = sdata->vif.bss_conf.basic_rates;
3355 enum nl80211_band band = sdata->vif.bss_conf.chandef.chan->band;
3357 if (!(mask->control[band].legacy & basic_rates))
3361 if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) {
3362 ret = drv_set_bitrate_mask(local, sdata, mask);
3367 for (i = 0; i < NUM_NL80211_BANDS; i++) {
3368 struct ieee80211_supported_band *sband = wiphy->bands[i];
3371 sdata->rc_rateidx_mask[i] = mask->control[i].legacy;
3372 memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].ht_mcs,
3373 sizeof(mask->control[i].ht_mcs));
3374 memcpy(sdata->rc_rateidx_vht_mcs_mask[i],
3375 mask->control[i].vht_mcs,
3376 sizeof(mask->control[i].vht_mcs));
3378 sdata->rc_has_mcs_mask[i] = false;
3379 sdata->rc_has_vht_mcs_mask[i] = false;
3383 for (j = 0; j < IEEE80211_HT_MCS_MASK_LEN; j++) {
3384 if (sdata->rc_rateidx_mcs_mask[i][j] != 0xff) {
3385 sdata->rc_has_mcs_mask[i] = true;
3390 for (j = 0; j < NL80211_VHT_NSS_MAX; j++) {
3391 if (sdata->rc_rateidx_vht_mcs_mask[i][j] != 0xffff) {
3392 sdata->rc_has_vht_mcs_mask[i] = true;
3401 static int ieee80211_start_radar_detection(struct wiphy *wiphy,
3402 struct net_device *dev,
3403 struct cfg80211_chan_def *chandef,
3406 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3407 struct ieee80211_local *local = sdata->local;
3410 mutex_lock(&local->mtx);
3411 if (!list_empty(&local->roc_list) || local->scanning) {
3416 /* whatever, but channel contexts should not complain about that one */
3417 sdata->deflink.smps_mode = IEEE80211_SMPS_OFF;
3418 sdata->deflink.needed_rx_chains = local->rx_chains;
3420 err = ieee80211_link_use_channel(&sdata->deflink, chandef,
3421 IEEE80211_CHANCTX_SHARED);
3425 ieee80211_queue_delayed_work(&sdata->local->hw,
3426 &sdata->deflink.dfs_cac_timer_work,
3427 msecs_to_jiffies(cac_time_ms));
3430 mutex_unlock(&local->mtx);
3434 static void ieee80211_end_cac(struct wiphy *wiphy,
3435 struct net_device *dev)
3437 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3438 struct ieee80211_local *local = sdata->local;
3440 mutex_lock(&local->mtx);
3441 list_for_each_entry(sdata, &local->interfaces, list) {
3442 /* it might be waiting for the local->mtx, but then
3443 * by the time it gets it, sdata->wdev.cac_started
3444 * will no longer be true
3446 cancel_delayed_work(&sdata->deflink.dfs_cac_timer_work);
3448 if (sdata->wdev.cac_started) {
3449 ieee80211_link_release_channel(&sdata->deflink);
3450 sdata->wdev.cac_started = false;
3453 mutex_unlock(&local->mtx);
3456 static struct cfg80211_beacon_data *
3457 cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon)
3459 struct cfg80211_beacon_data *new_beacon;
3463 len = beacon->head_len + beacon->tail_len + beacon->beacon_ies_len +
3464 beacon->proberesp_ies_len + beacon->assocresp_ies_len +
3465 beacon->probe_resp_len + beacon->lci_len + beacon->civicloc_len;
3467 if (beacon->mbssid_ies)
3468 len += ieee80211_get_mbssid_beacon_len(beacon->mbssid_ies,
3470 beacon->mbssid_ies->cnt);
3472 new_beacon = kzalloc(sizeof(*new_beacon) + len, GFP_KERNEL);
3476 if (beacon->mbssid_ies && beacon->mbssid_ies->cnt) {
3477 new_beacon->mbssid_ies =
3478 kzalloc(struct_size(new_beacon->mbssid_ies,
3479 elem, beacon->mbssid_ies->cnt),
3481 if (!new_beacon->mbssid_ies) {
3486 if (beacon->rnr_ies && beacon->rnr_ies->cnt) {
3487 new_beacon->rnr_ies =
3488 kzalloc(struct_size(new_beacon->rnr_ies,
3489 elem, beacon->rnr_ies->cnt),
3491 if (!new_beacon->rnr_ies) {
3492 kfree(new_beacon->mbssid_ies);
3499 pos = (u8 *)(new_beacon + 1);
3500 if (beacon->head_len) {
3501 new_beacon->head_len = beacon->head_len;
3502 new_beacon->head = pos;
3503 memcpy(pos, beacon->head, beacon->head_len);
3504 pos += beacon->head_len;
3506 if (beacon->tail_len) {
3507 new_beacon->tail_len = beacon->tail_len;
3508 new_beacon->tail = pos;
3509 memcpy(pos, beacon->tail, beacon->tail_len);
3510 pos += beacon->tail_len;
3512 if (beacon->beacon_ies_len) {
3513 new_beacon->beacon_ies_len = beacon->beacon_ies_len;
3514 new_beacon->beacon_ies = pos;
3515 memcpy(pos, beacon->beacon_ies, beacon->beacon_ies_len);
3516 pos += beacon->beacon_ies_len;
3518 if (beacon->proberesp_ies_len) {
3519 new_beacon->proberesp_ies_len = beacon->proberesp_ies_len;
3520 new_beacon->proberesp_ies = pos;
3521 memcpy(pos, beacon->proberesp_ies, beacon->proberesp_ies_len);
3522 pos += beacon->proberesp_ies_len;
3524 if (beacon->assocresp_ies_len) {
3525 new_beacon->assocresp_ies_len = beacon->assocresp_ies_len;
3526 new_beacon->assocresp_ies = pos;
3527 memcpy(pos, beacon->assocresp_ies, beacon->assocresp_ies_len);
3528 pos += beacon->assocresp_ies_len;
3530 if (beacon->probe_resp_len) {
3531 new_beacon->probe_resp_len = beacon->probe_resp_len;
3532 new_beacon->probe_resp = pos;
3533 memcpy(pos, beacon->probe_resp, beacon->probe_resp_len);
3534 pos += beacon->probe_resp_len;
3536 if (beacon->mbssid_ies && beacon->mbssid_ies->cnt) {
3537 pos += ieee80211_copy_mbssid_beacon(pos,
3538 new_beacon->mbssid_ies,
3539 beacon->mbssid_ies);
3540 if (beacon->rnr_ies && beacon->rnr_ies->cnt)
3541 pos += ieee80211_copy_rnr_beacon(pos,
3542 new_beacon->rnr_ies,
3546 /* might copy -1, meaning no changes requested */
3547 new_beacon->ftm_responder = beacon->ftm_responder;
3549 new_beacon->lci_len = beacon->lci_len;
3550 new_beacon->lci = pos;
3551 memcpy(pos, beacon->lci, beacon->lci_len);
3552 pos += beacon->lci_len;
3554 if (beacon->civicloc) {
3555 new_beacon->civicloc_len = beacon->civicloc_len;
3556 new_beacon->civicloc = pos;
3557 memcpy(pos, beacon->civicloc, beacon->civicloc_len);
3558 pos += beacon->civicloc_len;
3564 void ieee80211_csa_finish(struct ieee80211_vif *vif)
3566 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
3567 struct ieee80211_local *local = sdata->local;
3571 if (vif->mbssid_tx_vif == vif) {
3572 /* Trigger ieee80211_csa_finish() on the non-transmitting
3573 * interfaces when channel switch is received on
3574 * transmitting interface
3576 struct ieee80211_sub_if_data *iter;
3578 list_for_each_entry_rcu(iter, &local->interfaces, list) {
3579 if (!ieee80211_sdata_running(iter))
3582 if (iter == sdata || iter->vif.mbssid_tx_vif != vif)
3585 ieee80211_queue_work(&iter->local->hw,
3586 &iter->deflink.csa_finalize_work);
3589 ieee80211_queue_work(&local->hw, &sdata->deflink.csa_finalize_work);
3593 EXPORT_SYMBOL(ieee80211_csa_finish);
3595 void ieee80211_channel_switch_disconnect(struct ieee80211_vif *vif, bool block_tx)
3597 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
3598 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
3599 struct ieee80211_local *local = sdata->local;
3601 sdata->deflink.csa_block_tx = block_tx;
3602 sdata_info(sdata, "channel switch failed, disconnecting\n");
3603 wiphy_work_queue(local->hw.wiphy, &ifmgd->csa_connection_drop_work);
3605 EXPORT_SYMBOL(ieee80211_channel_switch_disconnect);
3607 static int ieee80211_set_after_csa_beacon(struct ieee80211_sub_if_data *sdata,
3612 switch (sdata->vif.type) {
3613 case NL80211_IFTYPE_AP:
3614 if (!sdata->deflink.u.ap.next_beacon)
3617 err = ieee80211_assign_beacon(sdata, &sdata->deflink,
3618 sdata->deflink.u.ap.next_beacon,
3619 NULL, NULL, changed);
3620 ieee80211_free_next_beacon(&sdata->deflink);
3625 case NL80211_IFTYPE_ADHOC:
3626 err = ieee80211_ibss_finish_csa(sdata, changed);
3630 #ifdef CONFIG_MAC80211_MESH
3631 case NL80211_IFTYPE_MESH_POINT:
3632 err = ieee80211_mesh_finish_csa(sdata, changed);
3645 static int __ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata)
3647 struct ieee80211_local *local = sdata->local;
3651 sdata_assert_lock(sdata);
3652 lockdep_assert_held(&local->mtx);
3653 lockdep_assert_held(&local->chanctx_mtx);
3656 * using reservation isn't immediate as it may be deferred until later
3657 * with multi-vif. once reservation is complete it will re-schedule the
3658 * work with no reserved_chanctx so verify chandef to check if it
3659 * completed successfully
3662 if (sdata->deflink.reserved_chanctx) {
3664 * with multi-vif csa driver may call ieee80211_csa_finish()
3665 * many times while waiting for other interfaces to use their
3668 if (sdata->deflink.reserved_ready)
3671 return ieee80211_link_use_reserved_context(&sdata->deflink);
3674 if (!cfg80211_chandef_identical(&sdata->vif.bss_conf.chandef,
3675 &sdata->deflink.csa_chandef))
3678 sdata->vif.bss_conf.csa_active = false;
3680 err = ieee80211_set_after_csa_beacon(sdata, &changed);
3684 if (sdata->vif.bss_conf.eht_puncturing != sdata->vif.bss_conf.csa_punct_bitmap) {
3685 sdata->vif.bss_conf.eht_puncturing =
3686 sdata->vif.bss_conf.csa_punct_bitmap;
3687 changed |= BSS_CHANGED_EHT_PUNCTURING;
3690 ieee80211_link_info_change_notify(sdata, &sdata->deflink, changed);
3692 if (sdata->deflink.csa_block_tx) {
3693 ieee80211_wake_vif_queues(local, sdata,
3694 IEEE80211_QUEUE_STOP_REASON_CSA);
3695 sdata->deflink.csa_block_tx = false;
3698 err = drv_post_channel_switch(sdata);
3702 cfg80211_ch_switch_notify(sdata->dev, &sdata->deflink.csa_chandef, 0,
3703 sdata->vif.bss_conf.eht_puncturing);
3708 static void ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata)
3710 if (__ieee80211_csa_finalize(sdata)) {
3711 sdata_info(sdata, "failed to finalize CSA, disconnecting\n");
3712 cfg80211_stop_iface(sdata->local->hw.wiphy, &sdata->wdev,
3717 void ieee80211_csa_finalize_work(struct work_struct *work)
3719 struct ieee80211_sub_if_data *sdata =
3720 container_of(work, struct ieee80211_sub_if_data,
3721 deflink.csa_finalize_work);
3722 struct ieee80211_local *local = sdata->local;
3725 mutex_lock(&local->mtx);
3726 mutex_lock(&local->chanctx_mtx);
3728 /* AP might have been stopped while waiting for the lock. */
3729 if (!sdata->vif.bss_conf.csa_active)
3732 if (!ieee80211_sdata_running(sdata))
3735 ieee80211_csa_finalize(sdata);
3738 mutex_unlock(&local->chanctx_mtx);
3739 mutex_unlock(&local->mtx);
3740 sdata_unlock(sdata);
3743 static int ieee80211_set_csa_beacon(struct ieee80211_sub_if_data *sdata,
3744 struct cfg80211_csa_settings *params,
3747 struct ieee80211_csa_settings csa = {};
3750 switch (sdata->vif.type) {
3751 case NL80211_IFTYPE_AP:
3752 sdata->deflink.u.ap.next_beacon =
3753 cfg80211_beacon_dup(¶ms->beacon_after);
3754 if (!sdata->deflink.u.ap.next_beacon)
3758 * With a count of 0, we don't have to wait for any
3759 * TBTT before switching, so complete the CSA
3760 * immediately. In theory, with a count == 1 we
3761 * should delay the switch until just before the next
3762 * TBTT, but that would complicate things so we switch
3763 * immediately too. If we would delay the switch
3764 * until the next TBTT, we would have to set the probe
3767 * TODO: A channel switch with count <= 1 without
3768 * sending a CSA action frame is kind of useless,
3769 * because the clients won't know we're changing
3770 * channels. The action frame must be implemented
3771 * either here or in the userspace.
3773 if (params->count <= 1)
3776 if ((params->n_counter_offsets_beacon >
3777 IEEE80211_MAX_CNTDWN_COUNTERS_NUM) ||
3778 (params->n_counter_offsets_presp >
3779 IEEE80211_MAX_CNTDWN_COUNTERS_NUM)) {
3780 ieee80211_free_next_beacon(&sdata->deflink);
3784 csa.counter_offsets_beacon = params->counter_offsets_beacon;
3785 csa.counter_offsets_presp = params->counter_offsets_presp;
3786 csa.n_counter_offsets_beacon = params->n_counter_offsets_beacon;
3787 csa.n_counter_offsets_presp = params->n_counter_offsets_presp;
3788 csa.count = params->count;
3790 err = ieee80211_assign_beacon(sdata, &sdata->deflink,
3791 ¶ms->beacon_csa, &csa,
3794 ieee80211_free_next_beacon(&sdata->deflink);
3799 case NL80211_IFTYPE_ADHOC:
3800 if (!sdata->vif.cfg.ibss_joined)
3803 if (params->chandef.width != sdata->u.ibss.chandef.width)
3806 switch (params->chandef.width) {
3807 case NL80211_CHAN_WIDTH_40:
3808 if (cfg80211_get_chandef_type(¶ms->chandef) !=
3809 cfg80211_get_chandef_type(&sdata->u.ibss.chandef))
3812 case NL80211_CHAN_WIDTH_5:
3813 case NL80211_CHAN_WIDTH_10:
3814 case NL80211_CHAN_WIDTH_20_NOHT:
3815 case NL80211_CHAN_WIDTH_20:
3821 /* changes into another band are not supported */
3822 if (sdata->u.ibss.chandef.chan->band !=
3823 params->chandef.chan->band)
3826 /* see comments in the NL80211_IFTYPE_AP block */
3827 if (params->count > 1) {
3828 err = ieee80211_ibss_csa_beacon(sdata, params, changed);
3833 ieee80211_send_action_csa(sdata, params);
3836 #ifdef CONFIG_MAC80211_MESH
3837 case NL80211_IFTYPE_MESH_POINT: {
3838 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
3840 /* changes into another band are not supported */
3841 if (sdata->vif.bss_conf.chandef.chan->band !=
3842 params->chandef.chan->band)
3845 if (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_NONE) {
3846 ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_INIT;
3847 if (!ifmsh->pre_value)
3848 ifmsh->pre_value = 1;
3853 /* see comments in the NL80211_IFTYPE_AP block */
3854 if (params->count > 1) {
3855 err = ieee80211_mesh_csa_beacon(sdata, params, changed);
3857 ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_NONE;
3862 if (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_INIT)
3863 ieee80211_send_action_csa(sdata, params);
3875 static void ieee80211_color_change_abort(struct ieee80211_sub_if_data *sdata)
3877 sdata->vif.bss_conf.color_change_active = false;
3879 ieee80211_free_next_beacon(&sdata->deflink);
3881 cfg80211_color_change_aborted_notify(sdata->dev);
3885 __ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
3886 struct cfg80211_csa_settings *params)
3888 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3889 struct ieee80211_local *local = sdata->local;
3890 struct ieee80211_channel_switch ch_switch;
3891 struct ieee80211_chanctx_conf *conf;
3892 struct ieee80211_chanctx *chanctx;
3896 sdata_assert_lock(sdata);
3897 lockdep_assert_held(&local->mtx);
3899 if (!list_empty(&local->roc_list) || local->scanning)
3902 if (sdata->wdev.cac_started)
3905 if (cfg80211_chandef_identical(¶ms->chandef,
3906 &sdata->vif.bss_conf.chandef))
3909 /* don't allow another channel switch if one is already active. */
3910 if (sdata->vif.bss_conf.csa_active)
3913 mutex_lock(&local->chanctx_mtx);
3914 conf = rcu_dereference_protected(sdata->vif.bss_conf.chanctx_conf,
3915 lockdep_is_held(&local->chanctx_mtx));
3921 if (params->chandef.chan->freq_offset) {
3922 /* this may work, but is untested */
3927 chanctx = container_of(conf, struct ieee80211_chanctx, conf);
3929 ch_switch.timestamp = 0;
3930 ch_switch.device_timestamp = 0;
3931 ch_switch.block_tx = params->block_tx;
3932 ch_switch.chandef = params->chandef;
3933 ch_switch.count = params->count;
3935 err = drv_pre_channel_switch(sdata, &ch_switch);
3939 err = ieee80211_link_reserve_chanctx(&sdata->deflink, ¶ms->chandef,
3941 params->radar_required);
3945 /* if reservation is invalid then this will fail */
3946 err = ieee80211_check_combinations(sdata, NULL, chanctx->mode, 0);
3948 ieee80211_link_unreserve_chanctx(&sdata->deflink);
3952 /* if there is a color change in progress, abort it */
3953 if (sdata->vif.bss_conf.color_change_active)
3954 ieee80211_color_change_abort(sdata);
3956 err = ieee80211_set_csa_beacon(sdata, params, &changed);
3958 ieee80211_link_unreserve_chanctx(&sdata->deflink);
3962 if (params->punct_bitmap && !sdata->vif.bss_conf.eht_support)
3965 sdata->deflink.csa_chandef = params->chandef;
3966 sdata->deflink.csa_block_tx = params->block_tx;
3967 sdata->vif.bss_conf.csa_active = true;
3968 sdata->vif.bss_conf.csa_punct_bitmap = params->punct_bitmap;
3970 if (sdata->deflink.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 &sdata->deflink.csa_chandef, 0,
3976 params->count, params->block_tx,
3977 sdata->vif.bss_conf.csa_punct_bitmap);
3980 ieee80211_link_info_change_notify(sdata, &sdata->deflink,
3982 drv_channel_switch_beacon(sdata, ¶ms->chandef);
3984 /* if the beacon didn't change, we can finalize immediately */
3985 ieee80211_csa_finalize(sdata);
3989 mutex_unlock(&local->chanctx_mtx);
3993 int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
3994 struct cfg80211_csa_settings *params)
3996 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3997 struct ieee80211_local *local = sdata->local;
4000 mutex_lock(&local->mtx);
4001 err = __ieee80211_channel_switch(wiphy, dev, params);
4002 mutex_unlock(&local->mtx);
4007 u64 ieee80211_mgmt_tx_cookie(struct ieee80211_local *local)
4009 lockdep_assert_held(&local->mtx);
4011 local->roc_cookie_counter++;
4013 /* wow, you wrapped 64 bits ... more likely a bug */
4014 if (WARN_ON(local->roc_cookie_counter == 0))
4015 local->roc_cookie_counter++;
4017 return local->roc_cookie_counter;
4020 int ieee80211_attach_ack_skb(struct ieee80211_local *local, struct sk_buff *skb,
4021 u64 *cookie, gfp_t gfp)
4023 unsigned long spin_flags;
4024 struct sk_buff *ack_skb;
4027 ack_skb = skb_copy(skb, gfp);
4031 spin_lock_irqsave(&local->ack_status_lock, spin_flags);
4032 id = idr_alloc(&local->ack_status_frames, ack_skb,
4033 1, 0x2000, GFP_ATOMIC);
4034 spin_unlock_irqrestore(&local->ack_status_lock, spin_flags);
4041 IEEE80211_SKB_CB(skb)->ack_frame_id = id;
4043 *cookie = ieee80211_mgmt_tx_cookie(local);
4044 IEEE80211_SKB_CB(ack_skb)->ack.cookie = *cookie;
4050 ieee80211_update_mgmt_frame_registrations(struct wiphy *wiphy,
4051 struct wireless_dev *wdev,
4052 struct mgmt_frame_regs *upd)
4054 struct ieee80211_local *local = wiphy_priv(wiphy);
4055 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
4056 u32 preq_mask = BIT(IEEE80211_STYPE_PROBE_REQ >> 4);
4057 u32 action_mask = BIT(IEEE80211_STYPE_ACTION >> 4);
4058 bool global_change, intf_change;
4061 (local->probe_req_reg != !!(upd->global_stypes & preq_mask)) ||
4062 (local->rx_mcast_action_reg !=
4063 !!(upd->global_mcast_stypes & action_mask));
4064 local->probe_req_reg = upd->global_stypes & preq_mask;
4065 local->rx_mcast_action_reg = upd->global_mcast_stypes & action_mask;
4067 intf_change = (sdata->vif.probe_req_reg !=
4068 !!(upd->interface_stypes & preq_mask)) ||
4069 (sdata->vif.rx_mcast_action_reg !=
4070 !!(upd->interface_mcast_stypes & action_mask));
4071 sdata->vif.probe_req_reg = upd->interface_stypes & preq_mask;
4072 sdata->vif.rx_mcast_action_reg =
4073 upd->interface_mcast_stypes & action_mask;
4075 if (!local->open_count)
4078 if (intf_change && ieee80211_sdata_running(sdata))
4079 drv_config_iface_filter(local, sdata,
4080 sdata->vif.probe_req_reg ?
4085 ieee80211_configure_filter(local);
4088 static int ieee80211_set_antenna(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant)
4090 struct ieee80211_local *local = wiphy_priv(wiphy);
4095 return drv_set_antenna(local, tx_ant, rx_ant);
4098 static int ieee80211_get_antenna(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant)
4100 struct ieee80211_local *local = wiphy_priv(wiphy);
4102 return drv_get_antenna(local, tx_ant, rx_ant);
4105 static int ieee80211_set_rekey_data(struct wiphy *wiphy,
4106 struct net_device *dev,
4107 struct cfg80211_gtk_rekey_data *data)
4109 struct ieee80211_local *local = wiphy_priv(wiphy);
4110 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4112 if (!local->ops->set_rekey_data)
4115 drv_set_rekey_data(local, sdata, data);
4120 static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev,
4121 const u8 *peer, u64 *cookie)
4123 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4124 struct ieee80211_local *local = sdata->local;
4125 struct ieee80211_qos_hdr *nullfunc;
4126 struct sk_buff *skb;
4127 int size = sizeof(*nullfunc);
4130 struct ieee80211_tx_info *info;
4131 struct sta_info *sta;
4132 struct ieee80211_chanctx_conf *chanctx_conf;
4133 enum nl80211_band band;
4136 /* the lock is needed to assign the cookie later */
4137 mutex_lock(&local->mtx);
4140 sta = sta_info_get_bss(sdata, peer);
4148 chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf);
4149 if (WARN_ON(!chanctx_conf)) {
4153 band = chanctx_conf->def.chan->band;
4156 fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
4157 IEEE80211_STYPE_QOS_NULLFUNC |
4158 IEEE80211_FCTL_FROMDS);
4161 fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
4162 IEEE80211_STYPE_NULLFUNC |
4163 IEEE80211_FCTL_FROMDS);
4166 skb = dev_alloc_skb(local->hw.extra_tx_headroom + size);
4174 skb_reserve(skb, local->hw.extra_tx_headroom);
4176 nullfunc = skb_put(skb, size);
4177 nullfunc->frame_control = fc;
4178 nullfunc->duration_id = 0;
4179 memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN);
4180 memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN);
4181 memcpy(nullfunc->addr3, sdata->vif.addr, ETH_ALEN);
4182 nullfunc->seq_ctrl = 0;
4184 info = IEEE80211_SKB_CB(skb);
4186 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS |
4187 IEEE80211_TX_INTFL_NL80211_FRAME_TX;
4190 skb_set_queue_mapping(skb, IEEE80211_AC_VO);
4193 nullfunc->qos_ctrl = cpu_to_le16(7);
4195 ret = ieee80211_attach_ack_skb(local, skb, cookie, GFP_ATOMIC);
4202 ieee80211_xmit(sdata, sta, skb);
4208 mutex_unlock(&local->mtx);
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->chandef;
4235 } else if (local->open_count > 0 &&
4236 local->open_count == local->monitors &&
4237 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
4238 if (local->use_chanctx)
4239 *chandef = local->monitor_chandef;
4241 *chandef = local->_oper_chandef;
4251 static void ieee80211_set_wakeup(struct wiphy *wiphy, bool enabled)
4253 drv_set_wakeup(wiphy_priv(wiphy), enabled);
4257 static int ieee80211_set_qos_map(struct wiphy *wiphy,
4258 struct net_device *dev,
4259 struct cfg80211_qos_map *qos_map)
4261 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4262 struct mac80211_qos_map *new_qos_map, *old_qos_map;
4265 new_qos_map = kzalloc(sizeof(*new_qos_map), GFP_KERNEL);
4268 memcpy(&new_qos_map->qos_map, qos_map, sizeof(*qos_map));
4270 /* A NULL qos_map was passed to disable QoS mapping */
4274 old_qos_map = sdata_dereference(sdata->qos_map, sdata);
4275 rcu_assign_pointer(sdata->qos_map, new_qos_map);
4277 kfree_rcu(old_qos_map, rcu_head);
4282 static int ieee80211_set_ap_chanwidth(struct wiphy *wiphy,
4283 struct net_device *dev,
4284 unsigned int link_id,
4285 struct cfg80211_chan_def *chandef)
4287 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4288 struct ieee80211_link_data *link;
4292 link = sdata_dereference(sdata->link[link_id], sdata);
4294 ret = ieee80211_link_change_bandwidth(link, chandef, &changed);
4296 ieee80211_link_info_change_notify(sdata, link, changed);
4301 static int ieee80211_add_tx_ts(struct wiphy *wiphy, struct net_device *dev,
4302 u8 tsid, const u8 *peer, u8 up,
4305 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4306 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
4307 int ac = ieee802_1d_to_ac[up];
4309 if (sdata->vif.type != NL80211_IFTYPE_STATION)
4312 if (!(sdata->wmm_acm & BIT(up)))
4315 if (ifmgd->tx_tspec[ac].admitted_time)
4318 if (admitted_time) {
4319 ifmgd->tx_tspec[ac].admitted_time = 32 * admitted_time;
4320 ifmgd->tx_tspec[ac].tsid = tsid;
4321 ifmgd->tx_tspec[ac].up = up;
4327 static int ieee80211_del_tx_ts(struct wiphy *wiphy, struct net_device *dev,
4328 u8 tsid, const u8 *peer)
4330 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4331 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
4332 struct ieee80211_local *local = wiphy_priv(wiphy);
4335 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
4336 struct ieee80211_sta_tx_tspec *tx_tspec = &ifmgd->tx_tspec[ac];
4338 /* skip unused entries */
4339 if (!tx_tspec->admitted_time)
4342 if (tx_tspec->tsid != tsid)
4345 /* due to this new packets will be reassigned to non-ACM ACs */
4348 /* Make sure that all packets have been sent to avoid to
4349 * restore the QoS params on packets that are still on the
4353 ieee80211_flush_queues(local, sdata, false);
4355 /* restore the normal QoS parameters
4356 * (unconditionally to avoid races)
4358 tx_tspec->action = TX_TSPEC_ACTION_STOP_DOWNGRADE;
4359 tx_tspec->downgraded = false;
4360 ieee80211_sta_handle_tspec_ac_params(sdata);
4362 /* finally clear all the data */
4363 memset(tx_tspec, 0, sizeof(*tx_tspec));
4371 void ieee80211_nan_func_terminated(struct ieee80211_vif *vif,
4373 enum nl80211_nan_func_term_reason reason,
4376 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
4377 struct cfg80211_nan_func *func;
4380 if (WARN_ON(vif->type != NL80211_IFTYPE_NAN))
4383 spin_lock_bh(&sdata->u.nan.func_lock);
4385 func = idr_find(&sdata->u.nan.function_inst_ids, inst_id);
4386 if (WARN_ON(!func)) {
4387 spin_unlock_bh(&sdata->u.nan.func_lock);
4391 cookie = func->cookie;
4392 idr_remove(&sdata->u.nan.function_inst_ids, inst_id);
4394 spin_unlock_bh(&sdata->u.nan.func_lock);
4396 cfg80211_free_nan_func(func);
4398 cfg80211_nan_func_terminated(ieee80211_vif_to_wdev(vif), inst_id,
4399 reason, cookie, gfp);
4401 EXPORT_SYMBOL(ieee80211_nan_func_terminated);
4403 void ieee80211_nan_func_match(struct ieee80211_vif *vif,
4404 struct cfg80211_nan_match_params *match,
4407 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
4408 struct cfg80211_nan_func *func;
4410 if (WARN_ON(vif->type != NL80211_IFTYPE_NAN))
4413 spin_lock_bh(&sdata->u.nan.func_lock);
4415 func = idr_find(&sdata->u.nan.function_inst_ids, match->inst_id);
4416 if (WARN_ON(!func)) {
4417 spin_unlock_bh(&sdata->u.nan.func_lock);
4420 match->cookie = func->cookie;
4422 spin_unlock_bh(&sdata->u.nan.func_lock);
4424 cfg80211_nan_match(ieee80211_vif_to_wdev(vif), match, gfp);
4426 EXPORT_SYMBOL(ieee80211_nan_func_match);
4428 static int ieee80211_set_multicast_to_unicast(struct wiphy *wiphy,
4429 struct net_device *dev,
4432 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4434 sdata->u.ap.multicast_to_unicast = enabled;
4439 void ieee80211_fill_txq_stats(struct cfg80211_txq_stats *txqstats,
4440 struct txq_info *txqi)
4442 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_BACKLOG_BYTES))) {
4443 txqstats->filled |= BIT(NL80211_TXQ_STATS_BACKLOG_BYTES);
4444 txqstats->backlog_bytes = txqi->tin.backlog_bytes;
4447 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_BACKLOG_PACKETS))) {
4448 txqstats->filled |= BIT(NL80211_TXQ_STATS_BACKLOG_PACKETS);
4449 txqstats->backlog_packets = txqi->tin.backlog_packets;
4452 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_FLOWS))) {
4453 txqstats->filled |= BIT(NL80211_TXQ_STATS_FLOWS);
4454 txqstats->flows = txqi->tin.flows;
4457 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_DROPS))) {
4458 txqstats->filled |= BIT(NL80211_TXQ_STATS_DROPS);
4459 txqstats->drops = txqi->cstats.drop_count;
4462 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_ECN_MARKS))) {
4463 txqstats->filled |= BIT(NL80211_TXQ_STATS_ECN_MARKS);
4464 txqstats->ecn_marks = txqi->cstats.ecn_mark;
4467 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_OVERLIMIT))) {
4468 txqstats->filled |= BIT(NL80211_TXQ_STATS_OVERLIMIT);
4469 txqstats->overlimit = txqi->tin.overlimit;
4472 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_COLLISIONS))) {
4473 txqstats->filled |= BIT(NL80211_TXQ_STATS_COLLISIONS);
4474 txqstats->collisions = txqi->tin.collisions;
4477 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_TX_BYTES))) {
4478 txqstats->filled |= BIT(NL80211_TXQ_STATS_TX_BYTES);
4479 txqstats->tx_bytes = txqi->tin.tx_bytes;
4482 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_TX_PACKETS))) {
4483 txqstats->filled |= BIT(NL80211_TXQ_STATS_TX_PACKETS);
4484 txqstats->tx_packets = txqi->tin.tx_packets;
4488 static int ieee80211_get_txq_stats(struct wiphy *wiphy,
4489 struct wireless_dev *wdev,
4490 struct cfg80211_txq_stats *txqstats)
4492 struct ieee80211_local *local = wiphy_priv(wiphy);
4493 struct ieee80211_sub_if_data *sdata;
4496 spin_lock_bh(&local->fq.lock);
4500 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
4501 if (!sdata->vif.txq) {
4505 ieee80211_fill_txq_stats(txqstats, to_txq_info(sdata->vif.txq));
4508 txqstats->filled |= BIT(NL80211_TXQ_STATS_BACKLOG_PACKETS) |
4509 BIT(NL80211_TXQ_STATS_BACKLOG_BYTES) |
4510 BIT(NL80211_TXQ_STATS_OVERLIMIT) |
4511 BIT(NL80211_TXQ_STATS_OVERMEMORY) |
4512 BIT(NL80211_TXQ_STATS_COLLISIONS) |
4513 BIT(NL80211_TXQ_STATS_MAX_FLOWS);
4514 txqstats->backlog_packets = local->fq.backlog;
4515 txqstats->backlog_bytes = local->fq.memory_usage;
4516 txqstats->overlimit = local->fq.overlimit;
4517 txqstats->overmemory = local->fq.overmemory;
4518 txqstats->collisions = local->fq.collisions;
4519 txqstats->max_flows = local->fq.flows_cnt;
4524 spin_unlock_bh(&local->fq.lock);
4530 ieee80211_get_ftm_responder_stats(struct wiphy *wiphy,
4531 struct net_device *dev,
4532 struct cfg80211_ftm_responder_stats *ftm_stats)
4534 struct ieee80211_local *local = wiphy_priv(wiphy);
4535 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4537 return drv_get_ftm_responder_stats(local, sdata, ftm_stats);
4541 ieee80211_start_pmsr(struct wiphy *wiphy, struct wireless_dev *dev,
4542 struct cfg80211_pmsr_request *request)
4544 struct ieee80211_local *local = wiphy_priv(wiphy);
4545 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(dev);
4547 return drv_start_pmsr(local, sdata, request);
4551 ieee80211_abort_pmsr(struct wiphy *wiphy, struct wireless_dev *dev,
4552 struct cfg80211_pmsr_request *request)
4554 struct ieee80211_local *local = wiphy_priv(wiphy);
4555 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(dev);
4557 return drv_abort_pmsr(local, sdata, request);
4560 static int ieee80211_set_tid_config(struct wiphy *wiphy,
4561 struct net_device *dev,
4562 struct cfg80211_tid_config *tid_conf)
4564 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4565 struct sta_info *sta;
4568 if (!sdata->local->ops->set_tid_config)
4571 if (!tid_conf->peer)
4572 return drv_set_tid_config(sdata->local, sdata, NULL, tid_conf);
4574 mutex_lock(&sdata->local->sta_mtx);
4575 sta = sta_info_get_bss(sdata, tid_conf->peer);
4577 mutex_unlock(&sdata->local->sta_mtx);
4581 ret = drv_set_tid_config(sdata->local, sdata, &sta->sta, tid_conf);
4582 mutex_unlock(&sdata->local->sta_mtx);
4587 static int ieee80211_reset_tid_config(struct wiphy *wiphy,
4588 struct net_device *dev,
4589 const u8 *peer, u8 tids)
4591 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4592 struct sta_info *sta;
4595 if (!sdata->local->ops->reset_tid_config)
4599 return drv_reset_tid_config(sdata->local, sdata, NULL, tids);
4601 mutex_lock(&sdata->local->sta_mtx);
4602 sta = sta_info_get_bss(sdata, peer);
4604 mutex_unlock(&sdata->local->sta_mtx);
4608 ret = drv_reset_tid_config(sdata->local, sdata, &sta->sta, tids);
4609 mutex_unlock(&sdata->local->sta_mtx);
4614 static int ieee80211_set_sar_specs(struct wiphy *wiphy,
4615 struct cfg80211_sar_specs *sar)
4617 struct ieee80211_local *local = wiphy_priv(wiphy);
4619 if (!local->ops->set_sar_specs)
4622 return local->ops->set_sar_specs(&local->hw, sar);
4626 ieee80211_set_after_color_change_beacon(struct ieee80211_sub_if_data *sdata,
4629 switch (sdata->vif.type) {
4630 case NL80211_IFTYPE_AP: {
4633 if (!sdata->deflink.u.ap.next_beacon)
4636 ret = ieee80211_assign_beacon(sdata, &sdata->deflink,
4637 sdata->deflink.u.ap.next_beacon,
4638 NULL, NULL, changed);
4639 ieee80211_free_next_beacon(&sdata->deflink);
4655 ieee80211_set_color_change_beacon(struct ieee80211_sub_if_data *sdata,
4656 struct cfg80211_color_change_settings *params,
4659 struct ieee80211_color_change_settings color_change = {};
4662 switch (sdata->vif.type) {
4663 case NL80211_IFTYPE_AP:
4664 sdata->deflink.u.ap.next_beacon =
4665 cfg80211_beacon_dup(¶ms->beacon_next);
4666 if (!sdata->deflink.u.ap.next_beacon)
4669 if (params->count <= 1)
4672 color_change.counter_offset_beacon =
4673 params->counter_offset_beacon;
4674 color_change.counter_offset_presp =
4675 params->counter_offset_presp;
4676 color_change.count = params->count;
4678 err = ieee80211_assign_beacon(sdata, &sdata->deflink,
4679 ¶ms->beacon_color_change,
4680 NULL, &color_change, changed);
4682 ieee80211_free_next_beacon(&sdata->deflink);
4694 ieee80211_color_change_bss_config_notify(struct ieee80211_sub_if_data *sdata,
4695 u8 color, int enable, u64 changed)
4697 sdata->vif.bss_conf.he_bss_color.color = color;
4698 sdata->vif.bss_conf.he_bss_color.enabled = enable;
4699 changed |= BSS_CHANGED_HE_BSS_COLOR;
4701 ieee80211_link_info_change_notify(sdata, &sdata->deflink, changed);
4703 if (!sdata->vif.bss_conf.nontransmitted && sdata->vif.mbssid_tx_vif) {
4704 struct ieee80211_sub_if_data *child;
4706 mutex_lock(&sdata->local->iflist_mtx);
4707 list_for_each_entry(child, &sdata->local->interfaces, list) {
4708 if (child != sdata && child->vif.mbssid_tx_vif == &sdata->vif) {
4709 child->vif.bss_conf.he_bss_color.color = color;
4710 child->vif.bss_conf.he_bss_color.enabled = enable;
4711 ieee80211_link_info_change_notify(child,
4713 BSS_CHANGED_HE_BSS_COLOR);
4716 mutex_unlock(&sdata->local->iflist_mtx);
4720 static int ieee80211_color_change_finalize(struct ieee80211_sub_if_data *sdata)
4722 struct ieee80211_local *local = sdata->local;
4726 sdata_assert_lock(sdata);
4727 lockdep_assert_held(&local->mtx);
4729 sdata->vif.bss_conf.color_change_active = false;
4731 err = ieee80211_set_after_color_change_beacon(sdata, &changed);
4733 cfg80211_color_change_aborted_notify(sdata->dev);
4737 ieee80211_color_change_bss_config_notify(sdata,
4738 sdata->vif.bss_conf.color_change_color,
4740 cfg80211_color_change_notify(sdata->dev);
4745 void ieee80211_color_change_finalize_work(struct work_struct *work)
4747 struct ieee80211_sub_if_data *sdata =
4748 container_of(work, struct ieee80211_sub_if_data,
4749 deflink.color_change_finalize_work);
4750 struct ieee80211_local *local = sdata->local;
4753 mutex_lock(&local->mtx);
4755 /* AP might have been stopped while waiting for the lock. */
4756 if (!sdata->vif.bss_conf.color_change_active)
4759 if (!ieee80211_sdata_running(sdata))
4762 ieee80211_color_change_finalize(sdata);
4765 mutex_unlock(&local->mtx);
4766 sdata_unlock(sdata);
4769 void ieee80211_color_collision_detection_work(struct work_struct *work)
4771 struct delayed_work *delayed_work = to_delayed_work(work);
4772 struct ieee80211_link_data *link =
4773 container_of(delayed_work, struct ieee80211_link_data,
4774 color_collision_detect_work);
4775 struct ieee80211_sub_if_data *sdata = link->sdata;
4778 cfg80211_obss_color_collision_notify(sdata->dev, link->color_bitmap);
4779 sdata_unlock(sdata);
4782 void ieee80211_color_change_finish(struct ieee80211_vif *vif)
4784 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
4786 ieee80211_queue_work(&sdata->local->hw,
4787 &sdata->deflink.color_change_finalize_work);
4789 EXPORT_SYMBOL_GPL(ieee80211_color_change_finish);
4792 ieee80211_obss_color_collision_notify(struct ieee80211_vif *vif,
4793 u64 color_bitmap, gfp_t gfp)
4795 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
4796 struct ieee80211_link_data *link = &sdata->deflink;
4798 if (sdata->vif.bss_conf.color_change_active || sdata->vif.bss_conf.csa_active)
4801 if (delayed_work_pending(&link->color_collision_detect_work))
4804 link->color_bitmap = color_bitmap;
4805 /* queue the color collision detection event every 500 ms in order to
4806 * avoid sending too much netlink messages to userspace.
4808 ieee80211_queue_delayed_work(&sdata->local->hw,
4809 &link->color_collision_detect_work,
4810 msecs_to_jiffies(500));
4812 EXPORT_SYMBOL_GPL(ieee80211_obss_color_collision_notify);
4815 ieee80211_color_change(struct wiphy *wiphy, struct net_device *dev,
4816 struct cfg80211_color_change_settings *params)
4818 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4819 struct ieee80211_local *local = sdata->local;
4823 sdata_assert_lock(sdata);
4825 if (sdata->vif.bss_conf.nontransmitted)
4828 mutex_lock(&local->mtx);
4830 /* don't allow another color change if one is already active or if csa
4833 if (sdata->vif.bss_conf.color_change_active || sdata->vif.bss_conf.csa_active) {
4838 err = ieee80211_set_color_change_beacon(sdata, params, &changed);
4842 sdata->vif.bss_conf.color_change_active = true;
4843 sdata->vif.bss_conf.color_change_color = params->color;
4845 cfg80211_color_change_started_notify(sdata->dev, params->count);
4848 ieee80211_color_change_bss_config_notify(sdata, 0, 0, changed);
4850 /* if the beacon didn't change, we can finalize immediately */
4851 ieee80211_color_change_finalize(sdata);
4854 mutex_unlock(&local->mtx);
4860 ieee80211_set_radar_background(struct wiphy *wiphy,
4861 struct cfg80211_chan_def *chandef)
4863 struct ieee80211_local *local = wiphy_priv(wiphy);
4865 if (!local->ops->set_radar_background)
4868 return local->ops->set_radar_background(&local->hw, chandef);
4871 static int ieee80211_add_intf_link(struct wiphy *wiphy,
4872 struct wireless_dev *wdev,
4873 unsigned int link_id)
4875 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
4878 if (wdev->use_4addr)
4881 mutex_lock(&sdata->local->mtx);
4882 res = ieee80211_vif_set_links(sdata, wdev->valid_links, 0);
4883 mutex_unlock(&sdata->local->mtx);
4888 static void ieee80211_del_intf_link(struct wiphy *wiphy,
4889 struct wireless_dev *wdev,
4890 unsigned int link_id)
4892 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
4894 mutex_lock(&sdata->local->mtx);
4895 ieee80211_vif_set_links(sdata, wdev->valid_links, 0);
4896 mutex_unlock(&sdata->local->mtx);
4899 static int sta_add_link_station(struct ieee80211_local *local,
4900 struct ieee80211_sub_if_data *sdata,
4901 struct link_station_parameters *params)
4903 struct sta_info *sta;
4906 sta = sta_info_get_bss(sdata, params->mld_mac);
4910 if (!sta->sta.valid_links)
4913 if (sta->sta.valid_links & BIT(params->link_id))
4916 ret = ieee80211_sta_allocate_link(sta, params->link_id);
4920 ret = sta_link_apply_parameters(local, sta, true, params);
4922 ieee80211_sta_free_link(sta, params->link_id);
4926 /* ieee80211_sta_activate_link frees the link upon failure */
4927 return ieee80211_sta_activate_link(sta, params->link_id);
4931 ieee80211_add_link_station(struct wiphy *wiphy, struct net_device *dev,
4932 struct link_station_parameters *params)
4934 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4935 struct ieee80211_local *local = wiphy_priv(wiphy);
4938 mutex_lock(&sdata->local->sta_mtx);
4939 ret = sta_add_link_station(local, sdata, params);
4940 mutex_unlock(&sdata->local->sta_mtx);
4945 static int sta_mod_link_station(struct ieee80211_local *local,
4946 struct ieee80211_sub_if_data *sdata,
4947 struct link_station_parameters *params)
4949 struct sta_info *sta;
4951 sta = sta_info_get_bss(sdata, params->mld_mac);
4955 if (!(sta->sta.valid_links & BIT(params->link_id)))
4958 return sta_link_apply_parameters(local, sta, false, params);
4962 ieee80211_mod_link_station(struct wiphy *wiphy, struct net_device *dev,
4963 struct link_station_parameters *params)
4965 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4966 struct ieee80211_local *local = wiphy_priv(wiphy);
4969 mutex_lock(&sdata->local->sta_mtx);
4970 ret = sta_mod_link_station(local, sdata, params);
4971 mutex_unlock(&sdata->local->sta_mtx);
4976 static int sta_del_link_station(struct ieee80211_sub_if_data *sdata,
4977 struct link_station_del_parameters *params)
4979 struct sta_info *sta;
4981 sta = sta_info_get_bss(sdata, params->mld_mac);
4985 if (!(sta->sta.valid_links & BIT(params->link_id)))
4988 /* must not create a STA without links */
4989 if (sta->sta.valid_links == BIT(params->link_id))
4992 ieee80211_sta_remove_link(sta, params->link_id);
4998 ieee80211_del_link_station(struct wiphy *wiphy, struct net_device *dev,
4999 struct link_station_del_parameters *params)
5001 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
5004 mutex_lock(&sdata->local->sta_mtx);
5005 ret = sta_del_link_station(sdata, params);
5006 mutex_unlock(&sdata->local->sta_mtx);
5011 static int ieee80211_set_hw_timestamp(struct wiphy *wiphy,
5012 struct net_device *dev,
5013 struct cfg80211_set_hw_timestamp *hwts)
5015 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
5016 struct ieee80211_local *local = sdata->local;
5018 if (!local->ops->set_hw_timestamp)
5021 if (!check_sdata_in_driver(sdata))
5024 return local->ops->set_hw_timestamp(&local->hw, &sdata->vif, hwts);
5027 const struct cfg80211_ops mac80211_config_ops = {
5028 .add_virtual_intf = ieee80211_add_iface,
5029 .del_virtual_intf = ieee80211_del_iface,
5030 .change_virtual_intf = ieee80211_change_iface,
5031 .start_p2p_device = ieee80211_start_p2p_device,
5032 .stop_p2p_device = ieee80211_stop_p2p_device,
5033 .add_key = ieee80211_add_key,
5034 .del_key = ieee80211_del_key,
5035 .get_key = ieee80211_get_key,
5036 .set_default_key = ieee80211_config_default_key,
5037 .set_default_mgmt_key = ieee80211_config_default_mgmt_key,
5038 .set_default_beacon_key = ieee80211_config_default_beacon_key,
5039 .start_ap = ieee80211_start_ap,
5040 .change_beacon = ieee80211_change_beacon,
5041 .stop_ap = ieee80211_stop_ap,
5042 .add_station = ieee80211_add_station,
5043 .del_station = ieee80211_del_station,
5044 .change_station = ieee80211_change_station,
5045 .get_station = ieee80211_get_station,
5046 .dump_station = ieee80211_dump_station,
5047 .dump_survey = ieee80211_dump_survey,
5048 #ifdef CONFIG_MAC80211_MESH
5049 .add_mpath = ieee80211_add_mpath,
5050 .del_mpath = ieee80211_del_mpath,
5051 .change_mpath = ieee80211_change_mpath,
5052 .get_mpath = ieee80211_get_mpath,
5053 .dump_mpath = ieee80211_dump_mpath,
5054 .get_mpp = ieee80211_get_mpp,
5055 .dump_mpp = ieee80211_dump_mpp,
5056 .update_mesh_config = ieee80211_update_mesh_config,
5057 .get_mesh_config = ieee80211_get_mesh_config,
5058 .join_mesh = ieee80211_join_mesh,
5059 .leave_mesh = ieee80211_leave_mesh,
5061 .join_ocb = ieee80211_join_ocb,
5062 .leave_ocb = ieee80211_leave_ocb,
5063 .change_bss = ieee80211_change_bss,
5064 .inform_bss = ieee80211_inform_bss,
5065 .set_txq_params = ieee80211_set_txq_params,
5066 .set_monitor_channel = ieee80211_set_monitor_channel,
5067 .suspend = ieee80211_suspend,
5068 .resume = ieee80211_resume,
5069 .scan = ieee80211_scan,
5070 .abort_scan = ieee80211_abort_scan,
5071 .sched_scan_start = ieee80211_sched_scan_start,
5072 .sched_scan_stop = ieee80211_sched_scan_stop,
5073 .auth = ieee80211_auth,
5074 .assoc = ieee80211_assoc,
5075 .deauth = ieee80211_deauth,
5076 .disassoc = ieee80211_disassoc,
5077 .join_ibss = ieee80211_join_ibss,
5078 .leave_ibss = ieee80211_leave_ibss,
5079 .set_mcast_rate = ieee80211_set_mcast_rate,
5080 .set_wiphy_params = ieee80211_set_wiphy_params,
5081 .set_tx_power = ieee80211_set_tx_power,
5082 .get_tx_power = ieee80211_get_tx_power,
5083 .rfkill_poll = ieee80211_rfkill_poll,
5084 CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd)
5085 CFG80211_TESTMODE_DUMP(ieee80211_testmode_dump)
5086 .set_power_mgmt = ieee80211_set_power_mgmt,
5087 .set_bitrate_mask = ieee80211_set_bitrate_mask,
5088 .remain_on_channel = ieee80211_remain_on_channel,
5089 .cancel_remain_on_channel = ieee80211_cancel_remain_on_channel,
5090 .mgmt_tx = ieee80211_mgmt_tx,
5091 .mgmt_tx_cancel_wait = ieee80211_mgmt_tx_cancel_wait,
5092 .set_cqm_rssi_config = ieee80211_set_cqm_rssi_config,
5093 .set_cqm_rssi_range_config = ieee80211_set_cqm_rssi_range_config,
5094 .update_mgmt_frame_registrations =
5095 ieee80211_update_mgmt_frame_registrations,
5096 .set_antenna = ieee80211_set_antenna,
5097 .get_antenna = ieee80211_get_antenna,
5098 .set_rekey_data = ieee80211_set_rekey_data,
5099 .tdls_oper = ieee80211_tdls_oper,
5100 .tdls_mgmt = ieee80211_tdls_mgmt,
5101 .tdls_channel_switch = ieee80211_tdls_channel_switch,
5102 .tdls_cancel_channel_switch = ieee80211_tdls_cancel_channel_switch,
5103 .probe_client = ieee80211_probe_client,
5104 .set_noack_map = ieee80211_set_noack_map,
5106 .set_wakeup = ieee80211_set_wakeup,
5108 .get_channel = ieee80211_cfg_get_channel,
5109 .start_radar_detection = ieee80211_start_radar_detection,
5110 .end_cac = ieee80211_end_cac,
5111 .channel_switch = ieee80211_channel_switch,
5112 .set_qos_map = ieee80211_set_qos_map,
5113 .set_ap_chanwidth = ieee80211_set_ap_chanwidth,
5114 .add_tx_ts = ieee80211_add_tx_ts,
5115 .del_tx_ts = ieee80211_del_tx_ts,
5116 .start_nan = ieee80211_start_nan,
5117 .stop_nan = ieee80211_stop_nan,
5118 .nan_change_conf = ieee80211_nan_change_conf,
5119 .add_nan_func = ieee80211_add_nan_func,
5120 .del_nan_func = ieee80211_del_nan_func,
5121 .set_multicast_to_unicast = ieee80211_set_multicast_to_unicast,
5122 .tx_control_port = ieee80211_tx_control_port,
5123 .get_txq_stats = ieee80211_get_txq_stats,
5124 .get_ftm_responder_stats = ieee80211_get_ftm_responder_stats,
5125 .start_pmsr = ieee80211_start_pmsr,
5126 .abort_pmsr = ieee80211_abort_pmsr,
5127 .probe_mesh_link = ieee80211_probe_mesh_link,
5128 .set_tid_config = ieee80211_set_tid_config,
5129 .reset_tid_config = ieee80211_reset_tid_config,
5130 .set_sar_specs = ieee80211_set_sar_specs,
5131 .color_change = ieee80211_color_change,
5132 .set_radar_background = ieee80211_set_radar_background,
5133 .add_intf_link = ieee80211_add_intf_link,
5134 .del_intf_link = ieee80211_del_intf_link,
5135 .add_link_station = ieee80211_add_link_station,
5136 .mod_link_station = ieee80211_mod_link_station,
5137 .del_link_station = ieee80211_del_link_station,
5138 .set_hw_timestamp = ieee80211_set_hw_timestamp,