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 && sdata->vif.valid_links)
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 (sdata->vif.valid_links)
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);
571 mutex_unlock(&local->sta_mtx);
576 static struct ieee80211_key *
577 ieee80211_lookup_key(struct ieee80211_sub_if_data *sdata, int link_id,
578 u8 key_idx, bool pairwise, const u8 *mac_addr)
580 struct ieee80211_local *local __maybe_unused = sdata->local;
581 struct ieee80211_link_data *link = &sdata->deflink;
582 struct ieee80211_key *key;
585 link = rcu_dereference_check(sdata->link[link_id],
586 lockdep_is_held(&sdata->wdev.mtx));
592 struct sta_info *sta;
593 struct link_sta_info *link_sta;
595 sta = sta_info_get_bss(sdata, mac_addr);
600 link_sta = rcu_dereference_check(sta->link[link_id],
601 lockdep_is_held(&local->sta_mtx));
605 link_sta = &sta->deflink;
608 if (pairwise && key_idx < NUM_DEFAULT_KEYS)
609 return rcu_dereference_check_key_mtx(local,
613 key_idx < NUM_DEFAULT_KEYS +
614 NUM_DEFAULT_MGMT_KEYS +
615 NUM_DEFAULT_BEACON_KEYS)
616 return rcu_dereference_check_key_mtx(local,
617 link_sta->gtk[key_idx]);
622 if (pairwise && key_idx < NUM_DEFAULT_KEYS)
623 return rcu_dereference_check_key_mtx(local,
624 sdata->keys[key_idx]);
626 key = rcu_dereference_check_key_mtx(local, link->gtk[key_idx]);
630 /* or maybe it was a WEP key */
631 if (key_idx < NUM_DEFAULT_KEYS)
632 return rcu_dereference_check_key_mtx(local, sdata->keys[key_idx]);
637 static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
638 int link_id, u8 key_idx, bool pairwise,
641 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
642 struct ieee80211_local *local = sdata->local;
643 struct ieee80211_key *key;
646 mutex_lock(&local->sta_mtx);
647 mutex_lock(&local->key_mtx);
649 key = ieee80211_lookup_key(sdata, link_id, key_idx, pairwise, mac_addr);
655 ieee80211_key_free(key, sdata->vif.type == NL80211_IFTYPE_STATION);
659 mutex_unlock(&local->key_mtx);
660 mutex_unlock(&local->sta_mtx);
665 static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
666 int link_id, u8 key_idx, bool pairwise,
667 const u8 *mac_addr, void *cookie,
668 void (*callback)(void *cookie,
669 struct key_params *params))
671 struct ieee80211_sub_if_data *sdata;
673 struct key_params params;
674 struct ieee80211_key *key;
679 struct ieee80211_key_seq kseq = {};
681 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
685 key = ieee80211_lookup_key(sdata, link_id, key_idx, pairwise, mac_addr);
689 memset(¶ms, 0, sizeof(params));
691 params.cipher = key->conf.cipher;
693 switch (key->conf.cipher) {
694 case WLAN_CIPHER_SUITE_TKIP:
695 pn64 = atomic64_read(&key->conf.tx_pn);
696 iv32 = TKIP_PN_TO_IV32(pn64);
697 iv16 = TKIP_PN_TO_IV16(pn64);
699 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE &&
700 !(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
701 drv_get_key_seq(sdata->local, key, &kseq);
702 iv32 = kseq.tkip.iv32;
703 iv16 = kseq.tkip.iv16;
706 seq[0] = iv16 & 0xff;
707 seq[1] = (iv16 >> 8) & 0xff;
708 seq[2] = iv32 & 0xff;
709 seq[3] = (iv32 >> 8) & 0xff;
710 seq[4] = (iv32 >> 16) & 0xff;
711 seq[5] = (iv32 >> 24) & 0xff;
715 case WLAN_CIPHER_SUITE_CCMP:
716 case WLAN_CIPHER_SUITE_CCMP_256:
717 case WLAN_CIPHER_SUITE_AES_CMAC:
718 case WLAN_CIPHER_SUITE_BIP_CMAC_256:
719 BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
720 offsetof(typeof(kseq), aes_cmac));
722 case WLAN_CIPHER_SUITE_BIP_GMAC_128:
723 case WLAN_CIPHER_SUITE_BIP_GMAC_256:
724 BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
725 offsetof(typeof(kseq), aes_gmac));
727 case WLAN_CIPHER_SUITE_GCMP:
728 case WLAN_CIPHER_SUITE_GCMP_256:
729 BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
730 offsetof(typeof(kseq), gcmp));
732 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE &&
733 !(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
734 drv_get_key_seq(sdata->local, key, &kseq);
735 memcpy(seq, kseq.ccmp.pn, 6);
737 pn64 = atomic64_read(&key->conf.tx_pn);
749 if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
751 if (WARN_ON(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV))
753 drv_get_key_seq(sdata->local, key, &kseq);
754 params.seq = kseq.hw.seq;
755 params.seq_len = kseq.hw.seq_len;
759 params.key = key->conf.key;
760 params.key_len = key->conf.keylen;
762 callback(cookie, ¶ms);
770 static int ieee80211_config_default_key(struct wiphy *wiphy,
771 struct net_device *dev,
772 int link_id, u8 key_idx, bool uni,
775 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
776 struct ieee80211_link_data *link =
777 ieee80211_link_or_deflink(sdata, link_id, false);
780 return PTR_ERR(link);
782 ieee80211_set_default_key(link, key_idx, uni, multi);
787 static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy,
788 struct net_device *dev,
789 int link_id, u8 key_idx)
791 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
792 struct ieee80211_link_data *link =
793 ieee80211_link_or_deflink(sdata, link_id, true);
796 return PTR_ERR(link);
798 ieee80211_set_default_mgmt_key(link, key_idx);
803 static int ieee80211_config_default_beacon_key(struct wiphy *wiphy,
804 struct net_device *dev,
805 int link_id, u8 key_idx)
807 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
808 struct ieee80211_link_data *link =
809 ieee80211_link_or_deflink(sdata, link_id, true);
812 return PTR_ERR(link);
814 ieee80211_set_default_beacon_key(link, key_idx);
819 void sta_set_rate_info_tx(struct sta_info *sta,
820 const struct ieee80211_tx_rate *rate,
821 struct rate_info *rinfo)
824 if (rate->flags & IEEE80211_TX_RC_MCS) {
825 rinfo->flags |= RATE_INFO_FLAGS_MCS;
826 rinfo->mcs = rate->idx;
827 } else if (rate->flags & IEEE80211_TX_RC_VHT_MCS) {
828 rinfo->flags |= RATE_INFO_FLAGS_VHT_MCS;
829 rinfo->mcs = ieee80211_rate_get_vht_mcs(rate);
830 rinfo->nss = ieee80211_rate_get_vht_nss(rate);
832 struct ieee80211_supported_band *sband;
833 int shift = ieee80211_vif_get_shift(&sta->sdata->vif);
836 sband = ieee80211_get_sband(sta->sdata);
837 WARN_ON_ONCE(sband && !sband->bitrates);
838 if (sband && sband->bitrates) {
839 brate = sband->bitrates[rate->idx].bitrate;
840 rinfo->legacy = DIV_ROUND_UP(brate, 1 << shift);
843 if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
844 rinfo->bw = RATE_INFO_BW_40;
845 else if (rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH)
846 rinfo->bw = RATE_INFO_BW_80;
847 else if (rate->flags & IEEE80211_TX_RC_160_MHZ_WIDTH)
848 rinfo->bw = RATE_INFO_BW_160;
850 rinfo->bw = RATE_INFO_BW_20;
851 if (rate->flags & IEEE80211_TX_RC_SHORT_GI)
852 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI;
855 static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev,
856 int idx, u8 *mac, struct station_info *sinfo)
858 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
859 struct ieee80211_local *local = sdata->local;
860 struct sta_info *sta;
863 mutex_lock(&local->sta_mtx);
865 sta = sta_info_get_by_idx(sdata, idx);
868 memcpy(mac, sta->sta.addr, ETH_ALEN);
869 sta_set_sinfo(sta, sinfo, true);
872 mutex_unlock(&local->sta_mtx);
877 static int ieee80211_dump_survey(struct wiphy *wiphy, struct net_device *dev,
878 int idx, struct survey_info *survey)
880 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
882 return drv_get_survey(local, idx, survey);
885 static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev,
886 const u8 *mac, struct station_info *sinfo)
888 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
889 struct ieee80211_local *local = sdata->local;
890 struct sta_info *sta;
893 mutex_lock(&local->sta_mtx);
895 sta = sta_info_get_bss(sdata, mac);
898 sta_set_sinfo(sta, sinfo, true);
901 mutex_unlock(&local->sta_mtx);
906 static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
907 struct cfg80211_chan_def *chandef)
909 struct ieee80211_local *local = wiphy_priv(wiphy);
910 struct ieee80211_sub_if_data *sdata;
913 if (cfg80211_chandef_identical(&local->monitor_chandef, chandef))
916 mutex_lock(&local->mtx);
917 if (local->use_chanctx) {
918 sdata = wiphy_dereference(local->hw.wiphy,
919 local->monitor_sdata);
921 ieee80211_link_release_channel(&sdata->deflink);
922 ret = ieee80211_link_use_channel(&sdata->deflink,
924 IEEE80211_CHANCTX_EXCLUSIVE);
926 } else if (local->open_count == local->monitors) {
927 local->_oper_chandef = *chandef;
928 ieee80211_hw_config(local, 0);
932 local->monitor_chandef = *chandef;
933 mutex_unlock(&local->mtx);
939 ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata,
940 const u8 *resp, size_t resp_len,
941 const struct ieee80211_csa_settings *csa,
942 const struct ieee80211_color_change_settings *cca,
943 struct ieee80211_link_data *link)
945 struct probe_resp *new, *old;
947 if (!resp || !resp_len)
950 old = sdata_dereference(link->u.ap.probe_resp, sdata);
952 new = kzalloc(sizeof(struct probe_resp) + resp_len, GFP_KERNEL);
957 memcpy(new->data, resp, resp_len);
960 memcpy(new->cntdwn_counter_offsets, csa->counter_offsets_presp,
961 csa->n_counter_offsets_presp *
962 sizeof(new->cntdwn_counter_offsets[0]));
964 new->cntdwn_counter_offsets[0] = cca->counter_offset_presp;
966 rcu_assign_pointer(link->u.ap.probe_resp, new);
968 kfree_rcu(old, rcu_head);
973 static int ieee80211_set_fils_discovery(struct ieee80211_sub_if_data *sdata,
974 struct cfg80211_fils_discovery *params,
975 struct ieee80211_link_data *link,
976 struct ieee80211_bss_conf *link_conf)
978 struct fils_discovery_data *new, *old = NULL;
979 struct ieee80211_fils_discovery *fd;
981 if (!params->tmpl || !params->tmpl_len)
984 fd = &link_conf->fils_discovery;
985 fd->min_interval = params->min_interval;
986 fd->max_interval = params->max_interval;
988 old = sdata_dereference(link->u.ap.fils_discovery, sdata);
989 new = kzalloc(sizeof(*new) + params->tmpl_len, GFP_KERNEL);
992 new->len = params->tmpl_len;
993 memcpy(new->data, params->tmpl, params->tmpl_len);
994 rcu_assign_pointer(link->u.ap.fils_discovery, new);
997 kfree_rcu(old, rcu_head);
1003 ieee80211_set_unsol_bcast_probe_resp(struct ieee80211_sub_if_data *sdata,
1004 struct cfg80211_unsol_bcast_probe_resp *params,
1005 struct ieee80211_link_data *link,
1006 struct ieee80211_bss_conf *link_conf)
1008 struct unsol_bcast_probe_resp_data *new, *old = NULL;
1010 if (!params->tmpl || !params->tmpl_len)
1013 old = sdata_dereference(link->u.ap.unsol_bcast_probe_resp, sdata);
1014 new = kzalloc(sizeof(*new) + params->tmpl_len, GFP_KERNEL);
1017 new->len = params->tmpl_len;
1018 memcpy(new->data, params->tmpl, params->tmpl_len);
1019 rcu_assign_pointer(link->u.ap.unsol_bcast_probe_resp, new);
1022 kfree_rcu(old, rcu_head);
1024 link_conf->unsol_bcast_probe_resp_interval = params->interval;
1029 static int ieee80211_set_ftm_responder_params(
1030 struct ieee80211_sub_if_data *sdata,
1031 const u8 *lci, size_t lci_len,
1032 const u8 *civicloc, size_t civicloc_len,
1033 struct ieee80211_bss_conf *link_conf)
1035 struct ieee80211_ftm_responder_params *new, *old;
1039 if (!lci_len && !civicloc_len)
1042 old = link_conf->ftmr_params;
1043 len = lci_len + civicloc_len;
1045 new = kzalloc(sizeof(*new) + len, GFP_KERNEL);
1049 pos = (u8 *)(new + 1);
1051 new->lci_len = lci_len;
1053 memcpy(pos, lci, lci_len);
1058 new->civicloc_len = civicloc_len;
1059 new->civicloc = pos;
1060 memcpy(pos, civicloc, civicloc_len);
1061 pos += civicloc_len;
1064 link_conf->ftmr_params = new;
1071 ieee80211_copy_mbssid_beacon(u8 *pos, struct cfg80211_mbssid_elems *dst,
1072 struct cfg80211_mbssid_elems *src)
1076 for (i = 0; i < src->cnt; i++) {
1077 memcpy(pos + offset, src->elem[i].data, src->elem[i].len);
1078 dst->elem[i].len = src->elem[i].len;
1079 dst->elem[i].data = pos + offset;
1080 offset += dst->elem[i].len;
1082 dst->cnt = src->cnt;
1088 ieee80211_copy_rnr_beacon(u8 *pos, struct cfg80211_rnr_elems *dst,
1089 struct cfg80211_rnr_elems *src)
1093 for (i = 0; i < src->cnt; i++) {
1094 memcpy(pos + offset, src->elem[i].data, src->elem[i].len);
1095 dst->elem[i].len = src->elem[i].len;
1096 dst->elem[i].data = pos + offset;
1097 offset += dst->elem[i].len;
1099 dst->cnt = src->cnt;
1104 static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
1105 struct ieee80211_link_data *link,
1106 struct cfg80211_beacon_data *params,
1107 const struct ieee80211_csa_settings *csa,
1108 const struct ieee80211_color_change_settings *cca)
1110 struct cfg80211_mbssid_elems *mbssid = NULL;
1111 struct cfg80211_rnr_elems *rnr = NULL;
1112 struct beacon_data *new, *old;
1113 int new_head_len, new_tail_len;
1115 u32 changed = BSS_CHANGED_BEACON;
1116 struct ieee80211_bss_conf *link_conf = link->conf;
1118 old = sdata_dereference(link->u.ap.beacon, sdata);
1120 /* Need to have a beacon head if we don't have one yet */
1121 if (!params->head && !old)
1124 /* new or old head? */
1126 new_head_len = params->head_len;
1128 new_head_len = old->head_len;
1130 /* new or old tail? */
1131 if (params->tail || !old)
1132 /* params->tail_len will be zero for !params->tail */
1133 new_tail_len = params->tail_len;
1135 new_tail_len = old->tail_len;
1137 size = sizeof(*new) + new_head_len + new_tail_len;
1139 /* new or old multiple BSSID elements? */
1140 if (params->mbssid_ies) {
1141 mbssid = params->mbssid_ies;
1142 size += struct_size(new->mbssid_ies, elem, mbssid->cnt);
1143 if (params->rnr_ies) {
1144 rnr = params->rnr_ies;
1145 size += struct_size(new->rnr_ies, elem, rnr->cnt);
1147 size += ieee80211_get_mbssid_beacon_len(mbssid, rnr,
1149 } else if (old && old->mbssid_ies) {
1150 mbssid = old->mbssid_ies;
1151 size += struct_size(new->mbssid_ies, elem, mbssid->cnt);
1152 if (old && old->rnr_ies) {
1154 size += struct_size(new->rnr_ies, elem, rnr->cnt);
1156 size += ieee80211_get_mbssid_beacon_len(mbssid, rnr,
1160 new = kzalloc(size, GFP_KERNEL);
1164 /* start filling the new info now */
1167 * pointers go into the block we allocated,
1168 * memory is | beacon_data | head | tail | mbssid_ies | rnr_ies
1170 new->head = ((u8 *) new) + sizeof(*new);
1171 new->tail = new->head + new_head_len;
1172 new->head_len = new_head_len;
1173 new->tail_len = new_tail_len;
1174 /* copy in optional mbssid_ies */
1176 u8 *pos = new->tail + new->tail_len;
1178 new->mbssid_ies = (void *)pos;
1179 pos += struct_size(new->mbssid_ies, elem, mbssid->cnt);
1180 pos += ieee80211_copy_mbssid_beacon(pos, new->mbssid_ies,
1183 new->rnr_ies = (void *)pos;
1184 pos += struct_size(new->rnr_ies, elem, rnr->cnt);
1185 ieee80211_copy_rnr_beacon(pos, new->rnr_ies, rnr);
1187 /* update bssid_indicator */
1188 link_conf->bssid_indicator =
1189 ilog2(__roundup_pow_of_two(mbssid->cnt + 1));
1193 new->cntdwn_current_counter = csa->count;
1194 memcpy(new->cntdwn_counter_offsets, csa->counter_offsets_beacon,
1195 csa->n_counter_offsets_beacon *
1196 sizeof(new->cntdwn_counter_offsets[0]));
1198 new->cntdwn_current_counter = cca->count;
1199 new->cntdwn_counter_offsets[0] = cca->counter_offset_beacon;
1204 memcpy(new->head, params->head, new_head_len);
1206 memcpy(new->head, old->head, new_head_len);
1208 /* copy in optional tail */
1210 memcpy(new->tail, params->tail, new_tail_len);
1213 memcpy(new->tail, old->tail, new_tail_len);
1215 err = ieee80211_set_probe_resp(sdata, params->probe_resp,
1216 params->probe_resp_len, csa, cca, link);
1222 changed |= BSS_CHANGED_AP_PROBE_RESP;
1224 if (params->ftm_responder != -1) {
1225 link_conf->ftm_responder = params->ftm_responder;
1226 err = ieee80211_set_ftm_responder_params(sdata,
1230 params->civicloc_len,
1238 changed |= BSS_CHANGED_FTM_RESPONDER;
1241 rcu_assign_pointer(link->u.ap.beacon, new);
1242 sdata->u.ap.active = true;
1245 kfree_rcu(old, rcu_head);
1250 static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
1251 struct cfg80211_ap_settings *params)
1253 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1254 struct ieee80211_local *local = sdata->local;
1255 struct beacon_data *old;
1256 struct ieee80211_sub_if_data *vlan;
1257 u64 changed = BSS_CHANGED_BEACON_INT |
1258 BSS_CHANGED_BEACON_ENABLED |
1259 BSS_CHANGED_BEACON |
1260 BSS_CHANGED_P2P_PS |
1261 BSS_CHANGED_TXPOWER |
1264 int prev_beacon_int;
1265 unsigned int link_id = params->beacon.link_id;
1266 struct ieee80211_link_data *link;
1267 struct ieee80211_bss_conf *link_conf;
1269 link = sdata_dereference(sdata->link[link_id], sdata);
1273 link_conf = link->conf;
1275 old = sdata_dereference(link->u.ap.beacon, sdata);
1279 if (params->smps_mode != NL80211_SMPS_OFF)
1282 link->smps_mode = IEEE80211_SMPS_OFF;
1284 link->needed_rx_chains = sdata->local->rx_chains;
1286 prev_beacon_int = link_conf->beacon_int;
1287 link_conf->beacon_int = params->beacon_interval;
1290 link_conf->ht_ldpc =
1291 params->ht_cap->cap_info &
1292 cpu_to_le16(IEEE80211_HT_CAP_LDPC_CODING);
1294 if (params->vht_cap) {
1295 link_conf->vht_ldpc =
1296 params->vht_cap->vht_cap_info &
1297 cpu_to_le32(IEEE80211_VHT_CAP_RXLDPC);
1298 link_conf->vht_su_beamformer =
1299 params->vht_cap->vht_cap_info &
1300 cpu_to_le32(IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE);
1301 link_conf->vht_su_beamformee =
1302 params->vht_cap->vht_cap_info &
1303 cpu_to_le32(IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE);
1304 link_conf->vht_mu_beamformer =
1305 params->vht_cap->vht_cap_info &
1306 cpu_to_le32(IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE);
1307 link_conf->vht_mu_beamformee =
1308 params->vht_cap->vht_cap_info &
1309 cpu_to_le32(IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE);
1312 if (params->he_cap && params->he_oper) {
1313 link_conf->he_support = true;
1314 link_conf->htc_trig_based_pkt_ext =
1315 le32_get_bits(params->he_oper->he_oper_params,
1316 IEEE80211_HE_OPERATION_DFLT_PE_DURATION_MASK);
1317 link_conf->frame_time_rts_th =
1318 le32_get_bits(params->he_oper->he_oper_params,
1319 IEEE80211_HE_OPERATION_RTS_THRESHOLD_MASK);
1320 changed |= BSS_CHANGED_HE_OBSS_PD;
1322 if (params->beacon.he_bss_color.enabled)
1323 changed |= BSS_CHANGED_HE_BSS_COLOR;
1326 if (params->he_cap) {
1327 link_conf->he_ldpc =
1328 params->he_cap->phy_cap_info[1] &
1329 IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD;
1330 link_conf->he_su_beamformer =
1331 params->he_cap->phy_cap_info[3] &
1332 IEEE80211_HE_PHY_CAP3_SU_BEAMFORMER;
1333 link_conf->he_su_beamformee =
1334 params->he_cap->phy_cap_info[4] &
1335 IEEE80211_HE_PHY_CAP4_SU_BEAMFORMEE;
1336 link_conf->he_mu_beamformer =
1337 params->he_cap->phy_cap_info[4] &
1338 IEEE80211_HE_PHY_CAP4_MU_BEAMFORMER;
1339 link_conf->he_full_ul_mumimo =
1340 params->he_cap->phy_cap_info[2] &
1341 IEEE80211_HE_PHY_CAP2_UL_MU_FULL_MU_MIMO;
1344 if (params->eht_cap) {
1345 if (!link_conf->he_support)
1348 link_conf->eht_support = true;
1349 link_conf->eht_puncturing = params->punct_bitmap;
1350 changed |= BSS_CHANGED_EHT_PUNCTURING;
1352 link_conf->eht_su_beamformer =
1353 params->eht_cap->fixed.phy_cap_info[0] &
1354 IEEE80211_EHT_PHY_CAP0_SU_BEAMFORMER;
1355 link_conf->eht_su_beamformee =
1356 params->eht_cap->fixed.phy_cap_info[0] &
1357 IEEE80211_EHT_PHY_CAP0_SU_BEAMFORMEE;
1358 link_conf->eht_mu_beamformer =
1359 params->eht_cap->fixed.phy_cap_info[7] &
1360 (IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_80MHZ |
1361 IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_160MHZ |
1362 IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_320MHZ);
1364 link_conf->eht_su_beamformer = false;
1365 link_conf->eht_su_beamformee = false;
1366 link_conf->eht_mu_beamformer = false;
1369 if (sdata->vif.type == NL80211_IFTYPE_AP &&
1370 params->mbssid_config.tx_wdev) {
1371 err = ieee80211_set_ap_mbssid_options(sdata,
1372 params->mbssid_config,
1378 mutex_lock(&local->mtx);
1379 err = ieee80211_link_use_channel(link, ¶ms->chandef,
1380 IEEE80211_CHANCTX_SHARED);
1382 ieee80211_link_copy_chanctx_to_vlans(link, false);
1383 mutex_unlock(&local->mtx);
1385 link_conf->beacon_int = prev_beacon_int;
1390 * Apply control port protocol, this allows us to
1391 * not encrypt dynamic WEP control frames.
1393 sdata->control_port_protocol = params->crypto.control_port_ethertype;
1394 sdata->control_port_no_encrypt = params->crypto.control_port_no_encrypt;
1395 sdata->control_port_over_nl80211 =
1396 params->crypto.control_port_over_nl80211;
1397 sdata->control_port_no_preauth =
1398 params->crypto.control_port_no_preauth;
1400 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) {
1401 vlan->control_port_protocol =
1402 params->crypto.control_port_ethertype;
1403 vlan->control_port_no_encrypt =
1404 params->crypto.control_port_no_encrypt;
1405 vlan->control_port_over_nl80211 =
1406 params->crypto.control_port_over_nl80211;
1407 vlan->control_port_no_preauth =
1408 params->crypto.control_port_no_preauth;
1411 link_conf->dtim_period = params->dtim_period;
1412 link_conf->enable_beacon = true;
1413 link_conf->allow_p2p_go_ps = sdata->vif.p2p;
1414 link_conf->twt_responder = params->twt_responder;
1415 link_conf->he_obss_pd = params->he_obss_pd;
1416 link_conf->he_bss_color = params->beacon.he_bss_color;
1417 sdata->vif.cfg.s1g = params->chandef.chan->band ==
1420 sdata->vif.cfg.ssid_len = params->ssid_len;
1421 if (params->ssid_len)
1422 memcpy(sdata->vif.cfg.ssid, params->ssid,
1424 link_conf->hidden_ssid =
1425 (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE);
1427 memset(&link_conf->p2p_noa_attr, 0,
1428 sizeof(link_conf->p2p_noa_attr));
1429 link_conf->p2p_noa_attr.oppps_ctwindow =
1430 params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
1431 if (params->p2p_opp_ps)
1432 link_conf->p2p_noa_attr.oppps_ctwindow |=
1433 IEEE80211_P2P_OPPPS_ENABLE_BIT;
1435 sdata->beacon_rate_set = false;
1436 if (wiphy_ext_feature_isset(local->hw.wiphy,
1437 NL80211_EXT_FEATURE_BEACON_RATE_LEGACY)) {
1438 for (i = 0; i < NUM_NL80211_BANDS; i++) {
1439 sdata->beacon_rateidx_mask[i] =
1440 params->beacon_rate.control[i].legacy;
1441 if (sdata->beacon_rateidx_mask[i])
1442 sdata->beacon_rate_set = true;
1446 if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL))
1447 link_conf->beacon_tx_rate = params->beacon_rate;
1449 err = ieee80211_assign_beacon(sdata, link, ¶ms->beacon, NULL, NULL);
1454 if (params->fils_discovery.max_interval) {
1455 err = ieee80211_set_fils_discovery(sdata,
1456 ¶ms->fils_discovery,
1460 changed |= BSS_CHANGED_FILS_DISCOVERY;
1463 if (params->unsol_bcast_probe_resp.interval) {
1464 err = ieee80211_set_unsol_bcast_probe_resp(sdata,
1465 ¶ms->unsol_bcast_probe_resp,
1469 changed |= BSS_CHANGED_UNSOL_BCAST_PROBE_RESP;
1472 err = drv_start_ap(sdata->local, sdata, link_conf);
1474 old = sdata_dereference(link->u.ap.beacon, sdata);
1477 kfree_rcu(old, rcu_head);
1478 RCU_INIT_POINTER(link->u.ap.beacon, NULL);
1479 sdata->u.ap.active = false;
1483 ieee80211_recalc_dtim(local, sdata);
1484 ieee80211_vif_cfg_change_notify(sdata, BSS_CHANGED_SSID);
1485 ieee80211_link_info_change_notify(sdata, link, changed);
1487 netif_carrier_on(dev);
1488 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
1489 netif_carrier_on(vlan->dev);
1494 mutex_lock(&local->mtx);
1495 ieee80211_link_release_channel(link);
1496 mutex_unlock(&local->mtx);
1501 static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev,
1502 struct cfg80211_beacon_data *params)
1504 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1505 struct ieee80211_link_data *link;
1506 struct beacon_data *old;
1508 struct ieee80211_bss_conf *link_conf;
1510 sdata_assert_lock(sdata);
1512 link = sdata_dereference(sdata->link[params->link_id], sdata);
1516 link_conf = link->conf;
1518 /* don't allow changing the beacon while a countdown is in place - offset
1519 * of channel switch counter may change
1521 if (link_conf->csa_active || link_conf->color_change_active)
1524 old = sdata_dereference(link->u.ap.beacon, sdata);
1528 err = ieee80211_assign_beacon(sdata, link, params, NULL, NULL);
1532 if (params->he_bss_color_valid &&
1533 params->he_bss_color.enabled != link_conf->he_bss_color.enabled) {
1534 link_conf->he_bss_color.enabled = params->he_bss_color.enabled;
1535 err |= BSS_CHANGED_HE_BSS_COLOR;
1538 ieee80211_link_info_change_notify(sdata, link, err);
1542 static void ieee80211_free_next_beacon(struct ieee80211_link_data *link)
1544 if (!link->u.ap.next_beacon)
1547 kfree(link->u.ap.next_beacon->mbssid_ies);
1548 kfree(link->u.ap.next_beacon->rnr_ies);
1549 kfree(link->u.ap.next_beacon);
1550 link->u.ap.next_beacon = NULL;
1553 static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev,
1554 unsigned int link_id)
1556 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1557 struct ieee80211_sub_if_data *vlan;
1558 struct ieee80211_local *local = sdata->local;
1559 struct beacon_data *old_beacon;
1560 struct probe_resp *old_probe_resp;
1561 struct fils_discovery_data *old_fils_discovery;
1562 struct unsol_bcast_probe_resp_data *old_unsol_bcast_probe_resp;
1563 struct cfg80211_chan_def chandef;
1564 struct ieee80211_link_data *link =
1565 sdata_dereference(sdata->link[link_id], sdata);
1566 struct ieee80211_bss_conf *link_conf = link->conf;
1568 sdata_assert_lock(sdata);
1570 old_beacon = sdata_dereference(link->u.ap.beacon, sdata);
1573 old_probe_resp = sdata_dereference(link->u.ap.probe_resp,
1575 old_fils_discovery = sdata_dereference(link->u.ap.fils_discovery,
1577 old_unsol_bcast_probe_resp =
1578 sdata_dereference(link->u.ap.unsol_bcast_probe_resp,
1581 /* abort any running channel switch */
1582 mutex_lock(&local->mtx);
1583 link_conf->csa_active = false;
1584 if (link->csa_block_tx) {
1585 ieee80211_wake_vif_queues(local, sdata,
1586 IEEE80211_QUEUE_STOP_REASON_CSA);
1587 link->csa_block_tx = false;
1590 mutex_unlock(&local->mtx);
1592 ieee80211_free_next_beacon(link);
1594 /* turn off carrier for this interface and dependent VLANs */
1595 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
1596 netif_carrier_off(vlan->dev);
1597 netif_carrier_off(dev);
1599 /* remove beacon and probe response */
1600 sdata->u.ap.active = false;
1601 RCU_INIT_POINTER(link->u.ap.beacon, NULL);
1602 RCU_INIT_POINTER(link->u.ap.probe_resp, NULL);
1603 RCU_INIT_POINTER(link->u.ap.fils_discovery, NULL);
1604 RCU_INIT_POINTER(link->u.ap.unsol_bcast_probe_resp, NULL);
1605 kfree_rcu(old_beacon, rcu_head);
1607 kfree_rcu(old_probe_resp, rcu_head);
1608 if (old_fils_discovery)
1609 kfree_rcu(old_fils_discovery, rcu_head);
1610 if (old_unsol_bcast_probe_resp)
1611 kfree_rcu(old_unsol_bcast_probe_resp, rcu_head);
1613 kfree(link_conf->ftmr_params);
1614 link_conf->ftmr_params = NULL;
1616 sdata->vif.mbssid_tx_vif = NULL;
1617 link_conf->bssid_index = 0;
1618 link_conf->nontransmitted = false;
1619 link_conf->ema_ap = false;
1620 link_conf->bssid_indicator = 0;
1622 __sta_info_flush(sdata, true);
1623 ieee80211_free_keys(sdata, true);
1625 link_conf->enable_beacon = false;
1626 sdata->beacon_rate_set = false;
1627 sdata->vif.cfg.ssid_len = 0;
1628 clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state);
1629 ieee80211_link_info_change_notify(sdata, link,
1630 BSS_CHANGED_BEACON_ENABLED);
1632 if (sdata->wdev.cac_started) {
1633 chandef = link_conf->chandef;
1634 cancel_delayed_work_sync(&link->dfs_cac_timer_work);
1635 cfg80211_cac_event(sdata->dev, &chandef,
1636 NL80211_RADAR_CAC_ABORTED,
1640 drv_stop_ap(sdata->local, sdata, link_conf);
1642 /* free all potentially still buffered bcast frames */
1643 local->total_ps_buffered -= skb_queue_len(&sdata->u.ap.ps.bc_buf);
1644 ieee80211_purge_tx_queue(&local->hw, &sdata->u.ap.ps.bc_buf);
1646 mutex_lock(&local->mtx);
1647 ieee80211_link_copy_chanctx_to_vlans(link, true);
1648 ieee80211_link_release_channel(link);
1649 mutex_unlock(&local->mtx);
1654 static int sta_apply_auth_flags(struct ieee80211_local *local,
1655 struct sta_info *sta,
1660 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
1661 set & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
1662 !test_sta_flag(sta, WLAN_STA_AUTH)) {
1663 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
1668 if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
1669 set & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
1670 !test_sta_flag(sta, WLAN_STA_ASSOC)) {
1672 * When peer becomes associated, init rate control as
1673 * well. Some drivers require rate control initialized
1674 * before drv_sta_state() is called.
1676 if (!test_sta_flag(sta, WLAN_STA_RATE_CONTROL))
1677 rate_control_rate_init(sta);
1679 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
1684 if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
1685 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED))
1686 ret = sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED);
1687 else if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
1688 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
1695 if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
1696 !(set & BIT(NL80211_STA_FLAG_ASSOCIATED)) &&
1697 test_sta_flag(sta, WLAN_STA_ASSOC)) {
1698 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
1703 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
1704 !(set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) &&
1705 test_sta_flag(sta, WLAN_STA_AUTH)) {
1706 ret = sta_info_move_state(sta, IEEE80211_STA_NONE);
1714 static void sta_apply_mesh_params(struct ieee80211_local *local,
1715 struct sta_info *sta,
1716 struct station_parameters *params)
1718 #ifdef CONFIG_MAC80211_MESH
1719 struct ieee80211_sub_if_data *sdata = sta->sdata;
1722 if (params->sta_modify_mask & STATION_PARAM_APPLY_PLINK_STATE) {
1723 switch (params->plink_state) {
1724 case NL80211_PLINK_ESTAB:
1725 if (sta->mesh->plink_state != NL80211_PLINK_ESTAB)
1726 changed = mesh_plink_inc_estab_count(sdata);
1727 sta->mesh->plink_state = params->plink_state;
1728 sta->mesh->aid = params->peer_aid;
1730 ieee80211_mps_sta_status_update(sta);
1731 changed |= ieee80211_mps_set_sta_local_pm(sta,
1732 sdata->u.mesh.mshcfg.power_mode);
1734 ewma_mesh_tx_rate_avg_init(&sta->mesh->tx_rate_avg);
1735 /* init at low value */
1736 ewma_mesh_tx_rate_avg_add(&sta->mesh->tx_rate_avg, 10);
1739 case NL80211_PLINK_LISTEN:
1740 case NL80211_PLINK_BLOCKED:
1741 case NL80211_PLINK_OPN_SNT:
1742 case NL80211_PLINK_OPN_RCVD:
1743 case NL80211_PLINK_CNF_RCVD:
1744 case NL80211_PLINK_HOLDING:
1745 if (sta->mesh->plink_state == NL80211_PLINK_ESTAB)
1746 changed = mesh_plink_dec_estab_count(sdata);
1747 sta->mesh->plink_state = params->plink_state;
1749 ieee80211_mps_sta_status_update(sta);
1750 changed |= ieee80211_mps_set_sta_local_pm(sta,
1751 NL80211_MESH_POWER_UNKNOWN);
1759 switch (params->plink_action) {
1760 case NL80211_PLINK_ACTION_NO_ACTION:
1763 case NL80211_PLINK_ACTION_OPEN:
1764 changed |= mesh_plink_open(sta);
1766 case NL80211_PLINK_ACTION_BLOCK:
1767 changed |= mesh_plink_block(sta);
1771 if (params->local_pm)
1772 changed |= ieee80211_mps_set_sta_local_pm(sta,
1775 ieee80211_mbss_info_change_notify(sdata, changed);
1779 static int sta_link_apply_parameters(struct ieee80211_local *local,
1780 struct sta_info *sta, bool new_link,
1781 struct link_station_parameters *params)
1784 struct ieee80211_supported_band *sband;
1785 struct ieee80211_sub_if_data *sdata = sta->sdata;
1786 u32 link_id = params->link_id < 0 ? 0 : params->link_id;
1787 struct ieee80211_link_data *link =
1788 sdata_dereference(sdata->link[link_id], sdata);
1789 struct link_sta_info *link_sta =
1790 rcu_dereference_protected(sta->link[link_id],
1791 lockdep_is_held(&local->sta_mtx));
1794 * If there are no changes, then accept a link that doesn't exist,
1795 * unless it's a new link.
1797 if (params->link_id < 0 && !new_link &&
1798 !params->link_mac && !params->txpwr_set &&
1799 !params->supported_rates_len &&
1800 !params->ht_capa && !params->vht_capa &&
1801 !params->he_capa && !params->eht_capa &&
1802 !params->opmode_notif_used)
1805 if (!link || !link_sta)
1808 sband = ieee80211_get_link_sband(link);
1812 if (params->link_mac) {
1814 memcpy(link_sta->addr, params->link_mac, ETH_ALEN);
1815 memcpy(link_sta->pub->addr, params->link_mac, ETH_ALEN);
1816 } else if (!ether_addr_equal(link_sta->addr,
1817 params->link_mac)) {
1820 } else if (new_link) {
1824 if (params->txpwr_set) {
1825 link_sta->pub->txpwr.type = params->txpwr.type;
1826 if (params->txpwr.type == NL80211_TX_POWER_LIMITED)
1827 link_sta->pub->txpwr.power = params->txpwr.power;
1828 ret = drv_sta_set_txpwr(local, sdata, sta);
1833 if (params->supported_rates &&
1834 params->supported_rates_len) {
1835 ieee80211_parse_bitrates(link->conf->chandef.width,
1836 sband, params->supported_rates,
1837 params->supported_rates_len,
1838 &link_sta->pub->supp_rates[sband->band]);
1841 if (params->ht_capa)
1842 ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
1843 params->ht_capa, link_sta);
1845 /* VHT can override some HT caps such as the A-MSDU max length */
1846 if (params->vht_capa)
1847 ieee80211_vht_cap_ie_to_sta_vht_cap(sdata, sband,
1848 params->vht_capa, link_sta);
1850 if (params->he_capa)
1851 ieee80211_he_cap_ie_to_sta_he_cap(sdata, sband,
1852 (void *)params->he_capa,
1853 params->he_capa_len,
1854 (void *)params->he_6ghz_capa,
1857 if (params->he_capa && params->eht_capa)
1858 ieee80211_eht_cap_ie_to_sta_eht_cap(sdata, sband,
1859 (u8 *)params->he_capa,
1860 params->he_capa_len,
1862 params->eht_capa_len,
1865 if (params->opmode_notif_used) {
1866 /* returned value is only needed for rc update, but the
1867 * rc isn't initialized here yet, so ignore it
1869 __ieee80211_vht_handle_opmode(sdata, link_sta,
1870 params->opmode_notif,
1877 static int sta_apply_parameters(struct ieee80211_local *local,
1878 struct sta_info *sta,
1879 struct station_parameters *params)
1881 struct ieee80211_sub_if_data *sdata = sta->sdata;
1885 mask = params->sta_flags_mask;
1886 set = params->sta_flags_set;
1888 if (ieee80211_vif_is_mesh(&sdata->vif)) {
1890 * In mesh mode, ASSOCIATED isn't part of the nl80211
1891 * API but must follow AUTHENTICATED for driver state.
1893 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED))
1894 mask |= BIT(NL80211_STA_FLAG_ASSOCIATED);
1895 if (set & BIT(NL80211_STA_FLAG_AUTHENTICATED))
1896 set |= BIT(NL80211_STA_FLAG_ASSOCIATED);
1897 } else if (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
1899 * TDLS -- everything follows authorized, but
1900 * only becoming authorized is possible, not
1903 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
1904 set |= BIT(NL80211_STA_FLAG_AUTHENTICATED) |
1905 BIT(NL80211_STA_FLAG_ASSOCIATED);
1906 mask |= BIT(NL80211_STA_FLAG_AUTHENTICATED) |
1907 BIT(NL80211_STA_FLAG_ASSOCIATED);
1911 if (mask & BIT(NL80211_STA_FLAG_WME) &&
1912 local->hw.queues >= IEEE80211_NUM_ACS)
1913 sta->sta.wme = set & BIT(NL80211_STA_FLAG_WME);
1915 /* auth flags will be set later for TDLS,
1916 * and for unassociated stations that move to associated */
1917 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1918 !((mask & BIT(NL80211_STA_FLAG_ASSOCIATED)) &&
1919 (set & BIT(NL80211_STA_FLAG_ASSOCIATED)))) {
1920 ret = sta_apply_auth_flags(local, sta, mask, set);
1925 if (mask & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) {
1926 if (set & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE))
1927 set_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
1929 clear_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
1932 if (mask & BIT(NL80211_STA_FLAG_MFP)) {
1933 sta->sta.mfp = !!(set & BIT(NL80211_STA_FLAG_MFP));
1934 if (set & BIT(NL80211_STA_FLAG_MFP))
1935 set_sta_flag(sta, WLAN_STA_MFP);
1937 clear_sta_flag(sta, WLAN_STA_MFP);
1940 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
1941 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER))
1942 set_sta_flag(sta, WLAN_STA_TDLS_PEER);
1944 clear_sta_flag(sta, WLAN_STA_TDLS_PEER);
1947 /* mark TDLS channel switch support, if the AP allows it */
1948 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1949 !sdata->deflink.u.mgd.tdls_chan_switch_prohibited &&
1950 params->ext_capab_len >= 4 &&
1951 params->ext_capab[3] & WLAN_EXT_CAPA4_TDLS_CHAN_SWITCH)
1952 set_sta_flag(sta, WLAN_STA_TDLS_CHAN_SWITCH);
1954 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1955 !sdata->u.mgd.tdls_wider_bw_prohibited &&
1956 ieee80211_hw_check(&local->hw, TDLS_WIDER_BW) &&
1957 params->ext_capab_len >= 8 &&
1958 params->ext_capab[7] & WLAN_EXT_CAPA8_TDLS_WIDE_BW_ENABLED)
1959 set_sta_flag(sta, WLAN_STA_TDLS_WIDER_BW);
1961 if (params->sta_modify_mask & STATION_PARAM_APPLY_UAPSD) {
1962 sta->sta.uapsd_queues = params->uapsd_queues;
1963 sta->sta.max_sp = params->max_sp;
1966 ieee80211_sta_set_max_amsdu_subframes(sta, params->ext_capab,
1967 params->ext_capab_len);
1970 * cfg80211 validates this (1-2007) and allows setting the AID
1971 * only when creating a new station entry
1974 sta->sta.aid = params->aid;
1977 * Some of the following updates would be racy if called on an
1978 * existing station, via ieee80211_change_station(). However,
1979 * all such changes are rejected by cfg80211 except for updates
1980 * changing the supported rates on an existing but not yet used
1984 if (params->listen_interval >= 0)
1985 sta->listen_interval = params->listen_interval;
1987 ret = sta_link_apply_parameters(local, sta, false,
1988 ¶ms->link_sta_params);
1992 if (params->support_p2p_ps >= 0)
1993 sta->sta.support_p2p_ps = params->support_p2p_ps;
1995 if (ieee80211_vif_is_mesh(&sdata->vif))
1996 sta_apply_mesh_params(local, sta, params);
1998 if (params->airtime_weight)
1999 sta->airtime_weight = params->airtime_weight;
2001 /* set the STA state after all sta info from usermode has been set */
2002 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) ||
2003 set & BIT(NL80211_STA_FLAG_ASSOCIATED)) {
2004 ret = sta_apply_auth_flags(local, sta, mask, set);
2009 /* Mark the STA as MLO if MLD MAC address is available */
2010 if (params->link_sta_params.mld_mac)
2011 sta->sta.mlo = true;
2016 static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
2018 struct station_parameters *params)
2020 struct ieee80211_local *local = wiphy_priv(wiphy);
2021 struct sta_info *sta;
2022 struct ieee80211_sub_if_data *sdata;
2026 sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
2028 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
2029 sdata->vif.type != NL80211_IFTYPE_AP)
2032 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2034 if (ether_addr_equal(mac, sdata->vif.addr))
2037 if (!is_valid_ether_addr(mac))
2040 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER) &&
2041 sdata->vif.type == NL80211_IFTYPE_STATION &&
2042 !sdata->u.mgd.associated)
2046 * If we have a link ID, it can be a non-MLO station on an AP MLD,
2047 * but we need to have a link_mac in that case as well, so use the
2048 * STA's MAC address in that case.
2050 if (params->link_sta_params.link_id >= 0)
2051 sta = sta_info_alloc_with_link(sdata, mac,
2052 params->link_sta_params.link_id,
2053 params->link_sta_params.link_mac ?: mac,
2056 sta = sta_info_alloc(sdata, mac, GFP_KERNEL);
2061 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))
2062 sta->sta.tdls = true;
2064 /* Though the mutex is not needed here (since the station is not
2065 * visible yet), sta_apply_parameters (and inner functions) require
2066 * the mutex due to other paths.
2068 mutex_lock(&local->sta_mtx);
2069 err = sta_apply_parameters(local, sta, params);
2070 mutex_unlock(&local->sta_mtx);
2072 sta_info_free(local, sta);
2077 * for TDLS and for unassociated station, rate control should be
2078 * initialized only when rates are known and station is marked
2079 * authorized/associated
2081 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
2082 test_sta_flag(sta, WLAN_STA_ASSOC))
2083 rate_control_rate_init(sta);
2085 return sta_info_insert(sta);
2088 static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev,
2089 struct station_del_parameters *params)
2091 struct ieee80211_sub_if_data *sdata;
2093 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2096 return sta_info_destroy_addr_bss(sdata, params->mac);
2098 sta_info_flush(sdata);
2102 static int ieee80211_change_station(struct wiphy *wiphy,
2103 struct net_device *dev, const u8 *mac,
2104 struct station_parameters *params)
2106 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2107 struct ieee80211_local *local = wiphy_priv(wiphy);
2108 struct sta_info *sta;
2109 struct ieee80211_sub_if_data *vlansdata;
2110 enum cfg80211_station_type statype;
2113 mutex_lock(&local->sta_mtx);
2115 sta = sta_info_get_bss(sdata, mac);
2121 switch (sdata->vif.type) {
2122 case NL80211_IFTYPE_MESH_POINT:
2123 if (sdata->u.mesh.user_mpm)
2124 statype = CFG80211_STA_MESH_PEER_USER;
2126 statype = CFG80211_STA_MESH_PEER_KERNEL;
2128 case NL80211_IFTYPE_ADHOC:
2129 statype = CFG80211_STA_IBSS;
2131 case NL80211_IFTYPE_STATION:
2132 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
2133 statype = CFG80211_STA_AP_STA;
2136 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
2137 statype = CFG80211_STA_TDLS_PEER_ACTIVE;
2139 statype = CFG80211_STA_TDLS_PEER_SETUP;
2141 case NL80211_IFTYPE_AP:
2142 case NL80211_IFTYPE_AP_VLAN:
2143 if (test_sta_flag(sta, WLAN_STA_ASSOC))
2144 statype = CFG80211_STA_AP_CLIENT;
2146 statype = CFG80211_STA_AP_CLIENT_UNASSOC;
2153 err = cfg80211_check_station_change(wiphy, params, statype);
2157 if (params->vlan && params->vlan != sta->sdata->dev) {
2158 vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
2160 if (params->vlan->ieee80211_ptr->use_4addr) {
2161 if (vlansdata->u.vlan.sta) {
2166 rcu_assign_pointer(vlansdata->u.vlan.sta, sta);
2167 __ieee80211_check_fast_rx_iface(vlansdata);
2168 drv_sta_set_4addr(local, sta->sdata, &sta->sta, true);
2171 if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
2172 sta->sdata->u.vlan.sta) {
2173 ieee80211_clear_fast_rx(sta);
2174 RCU_INIT_POINTER(sta->sdata->u.vlan.sta, NULL);
2177 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
2178 ieee80211_vif_dec_num_mcast(sta->sdata);
2180 sta->sdata = vlansdata;
2181 ieee80211_check_fast_xmit(sta);
2183 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED)) {
2184 ieee80211_vif_inc_num_mcast(sta->sdata);
2185 cfg80211_send_layer2_update(sta->sdata->dev,
2190 /* we use sta_info_get_bss() so this might be different */
2191 if (sdata != sta->sdata) {
2192 mutex_lock_nested(&sta->sdata->wdev.mtx, 1);
2193 err = sta_apply_parameters(local, sta, params);
2194 mutex_unlock(&sta->sdata->wdev.mtx);
2196 err = sta_apply_parameters(local, sta, params);
2201 mutex_unlock(&local->sta_mtx);
2203 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
2204 params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
2205 ieee80211_recalc_ps(local);
2206 ieee80211_recalc_ps_vif(sdata);
2211 mutex_unlock(&local->sta_mtx);
2215 #ifdef CONFIG_MAC80211_MESH
2216 static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev,
2217 const u8 *dst, const u8 *next_hop)
2219 struct ieee80211_sub_if_data *sdata;
2220 struct mesh_path *mpath;
2221 struct sta_info *sta;
2223 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2226 sta = sta_info_get(sdata, next_hop);
2232 mpath = mesh_path_add(sdata, dst);
2233 if (IS_ERR(mpath)) {
2235 return PTR_ERR(mpath);
2238 mesh_path_fix_nexthop(mpath, sta);
2244 static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev,
2247 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2250 return mesh_path_del(sdata, dst);
2252 mesh_path_flush_by_iface(sdata);
2256 static int ieee80211_change_mpath(struct wiphy *wiphy, struct net_device *dev,
2257 const u8 *dst, const u8 *next_hop)
2259 struct ieee80211_sub_if_data *sdata;
2260 struct mesh_path *mpath;
2261 struct sta_info *sta;
2263 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2267 sta = sta_info_get(sdata, next_hop);
2273 mpath = mesh_path_lookup(sdata, dst);
2279 mesh_path_fix_nexthop(mpath, sta);
2285 static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop,
2286 struct mpath_info *pinfo)
2288 struct sta_info *next_hop_sta = rcu_dereference(mpath->next_hop);
2291 memcpy(next_hop, next_hop_sta->sta.addr, ETH_ALEN);
2293 eth_zero_addr(next_hop);
2295 memset(pinfo, 0, sizeof(*pinfo));
2297 pinfo->generation = mpath->sdata->u.mesh.mesh_paths_generation;
2299 pinfo->filled = MPATH_INFO_FRAME_QLEN |
2302 MPATH_INFO_EXPTIME |
2303 MPATH_INFO_DISCOVERY_TIMEOUT |
2304 MPATH_INFO_DISCOVERY_RETRIES |
2306 MPATH_INFO_HOP_COUNT |
2307 MPATH_INFO_PATH_CHANGE;
2309 pinfo->frame_qlen = mpath->frame_queue.qlen;
2310 pinfo->sn = mpath->sn;
2311 pinfo->metric = mpath->metric;
2312 if (time_before(jiffies, mpath->exp_time))
2313 pinfo->exptime = jiffies_to_msecs(mpath->exp_time - jiffies);
2314 pinfo->discovery_timeout =
2315 jiffies_to_msecs(mpath->discovery_timeout);
2316 pinfo->discovery_retries = mpath->discovery_retries;
2317 if (mpath->flags & MESH_PATH_ACTIVE)
2318 pinfo->flags |= NL80211_MPATH_FLAG_ACTIVE;
2319 if (mpath->flags & MESH_PATH_RESOLVING)
2320 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING;
2321 if (mpath->flags & MESH_PATH_SN_VALID)
2322 pinfo->flags |= NL80211_MPATH_FLAG_SN_VALID;
2323 if (mpath->flags & MESH_PATH_FIXED)
2324 pinfo->flags |= NL80211_MPATH_FLAG_FIXED;
2325 if (mpath->flags & MESH_PATH_RESOLVED)
2326 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVED;
2327 pinfo->hop_count = mpath->hop_count;
2328 pinfo->path_change_count = mpath->path_change_count;
2331 static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev,
2332 u8 *dst, u8 *next_hop, struct mpath_info *pinfo)
2335 struct ieee80211_sub_if_data *sdata;
2336 struct mesh_path *mpath;
2338 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2341 mpath = mesh_path_lookup(sdata, dst);
2346 memcpy(dst, mpath->dst, ETH_ALEN);
2347 mpath_set_pinfo(mpath, next_hop, pinfo);
2352 static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev,
2353 int idx, u8 *dst, u8 *next_hop,
2354 struct mpath_info *pinfo)
2356 struct ieee80211_sub_if_data *sdata;
2357 struct mesh_path *mpath;
2359 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2362 mpath = mesh_path_lookup_by_idx(sdata, idx);
2367 memcpy(dst, mpath->dst, ETH_ALEN);
2368 mpath_set_pinfo(mpath, next_hop, pinfo);
2373 static void mpp_set_pinfo(struct mesh_path *mpath, u8 *mpp,
2374 struct mpath_info *pinfo)
2376 memset(pinfo, 0, sizeof(*pinfo));
2377 memcpy(mpp, mpath->mpp, ETH_ALEN);
2379 pinfo->generation = mpath->sdata->u.mesh.mpp_paths_generation;
2382 static int ieee80211_get_mpp(struct wiphy *wiphy, struct net_device *dev,
2383 u8 *dst, u8 *mpp, struct mpath_info *pinfo)
2386 struct ieee80211_sub_if_data *sdata;
2387 struct mesh_path *mpath;
2389 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2392 mpath = mpp_path_lookup(sdata, dst);
2397 memcpy(dst, mpath->dst, ETH_ALEN);
2398 mpp_set_pinfo(mpath, mpp, pinfo);
2403 static int ieee80211_dump_mpp(struct wiphy *wiphy, struct net_device *dev,
2404 int idx, u8 *dst, u8 *mpp,
2405 struct mpath_info *pinfo)
2407 struct ieee80211_sub_if_data *sdata;
2408 struct mesh_path *mpath;
2410 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2413 mpath = mpp_path_lookup_by_idx(sdata, idx);
2418 memcpy(dst, mpath->dst, ETH_ALEN);
2419 mpp_set_pinfo(mpath, mpp, pinfo);
2424 static int ieee80211_get_mesh_config(struct wiphy *wiphy,
2425 struct net_device *dev,
2426 struct mesh_config *conf)
2428 struct ieee80211_sub_if_data *sdata;
2429 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2431 memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config));
2435 static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask)
2437 return (mask >> (parm-1)) & 0x1;
2440 static int copy_mesh_setup(struct ieee80211_if_mesh *ifmsh,
2441 const struct mesh_setup *setup)
2444 struct ieee80211_sub_if_data *sdata = container_of(ifmsh,
2445 struct ieee80211_sub_if_data, u.mesh);
2448 /* allocate information elements */
2451 if (setup->ie_len) {
2452 new_ie = kmemdup(setup->ie, setup->ie_len,
2457 ifmsh->ie_len = setup->ie_len;
2460 /* now copy the rest of the setup parameters */
2461 ifmsh->mesh_id_len = setup->mesh_id_len;
2462 memcpy(ifmsh->mesh_id, setup->mesh_id, ifmsh->mesh_id_len);
2463 ifmsh->mesh_sp_id = setup->sync_method;
2464 ifmsh->mesh_pp_id = setup->path_sel_proto;
2465 ifmsh->mesh_pm_id = setup->path_metric;
2466 ifmsh->user_mpm = setup->user_mpm;
2467 ifmsh->mesh_auth_id = setup->auth_id;
2468 ifmsh->security = IEEE80211_MESH_SEC_NONE;
2469 ifmsh->userspace_handles_dfs = setup->userspace_handles_dfs;
2470 if (setup->is_authenticated)
2471 ifmsh->security |= IEEE80211_MESH_SEC_AUTHED;
2472 if (setup->is_secure)
2473 ifmsh->security |= IEEE80211_MESH_SEC_SECURED;
2475 /* mcast rate setting in Mesh Node */
2476 memcpy(sdata->vif.bss_conf.mcast_rate, setup->mcast_rate,
2477 sizeof(setup->mcast_rate));
2478 sdata->vif.bss_conf.basic_rates = setup->basic_rates;
2480 sdata->vif.bss_conf.beacon_int = setup->beacon_interval;
2481 sdata->vif.bss_conf.dtim_period = setup->dtim_period;
2483 sdata->beacon_rate_set = false;
2484 if (wiphy_ext_feature_isset(sdata->local->hw.wiphy,
2485 NL80211_EXT_FEATURE_BEACON_RATE_LEGACY)) {
2486 for (i = 0; i < NUM_NL80211_BANDS; i++) {
2487 sdata->beacon_rateidx_mask[i] =
2488 setup->beacon_rate.control[i].legacy;
2489 if (sdata->beacon_rateidx_mask[i])
2490 sdata->beacon_rate_set = true;
2497 static int ieee80211_update_mesh_config(struct wiphy *wiphy,
2498 struct net_device *dev, u32 mask,
2499 const struct mesh_config *nconf)
2501 struct mesh_config *conf;
2502 struct ieee80211_sub_if_data *sdata;
2503 struct ieee80211_if_mesh *ifmsh;
2505 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2506 ifmsh = &sdata->u.mesh;
2508 /* Set the config options which we are interested in setting */
2509 conf = &(sdata->u.mesh.mshcfg);
2510 if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask))
2511 conf->dot11MeshRetryTimeout = nconf->dot11MeshRetryTimeout;
2512 if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT, mask))
2513 conf->dot11MeshConfirmTimeout = nconf->dot11MeshConfirmTimeout;
2514 if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT, mask))
2515 conf->dot11MeshHoldingTimeout = nconf->dot11MeshHoldingTimeout;
2516 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS, mask))
2517 conf->dot11MeshMaxPeerLinks = nconf->dot11MeshMaxPeerLinks;
2518 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES, mask))
2519 conf->dot11MeshMaxRetries = nconf->dot11MeshMaxRetries;
2520 if (_chg_mesh_attr(NL80211_MESHCONF_TTL, mask))
2521 conf->dot11MeshTTL = nconf->dot11MeshTTL;
2522 if (_chg_mesh_attr(NL80211_MESHCONF_ELEMENT_TTL, mask))
2523 conf->element_ttl = nconf->element_ttl;
2524 if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask)) {
2525 if (ifmsh->user_mpm)
2527 conf->auto_open_plinks = nconf->auto_open_plinks;
2529 if (_chg_mesh_attr(NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR, mask))
2530 conf->dot11MeshNbrOffsetMaxNeighbor =
2531 nconf->dot11MeshNbrOffsetMaxNeighbor;
2532 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, mask))
2533 conf->dot11MeshHWMPmaxPREQretries =
2534 nconf->dot11MeshHWMPmaxPREQretries;
2535 if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME, mask))
2536 conf->path_refresh_time = nconf->path_refresh_time;
2537 if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, mask))
2538 conf->min_discovery_timeout = nconf->min_discovery_timeout;
2539 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, mask))
2540 conf->dot11MeshHWMPactivePathTimeout =
2541 nconf->dot11MeshHWMPactivePathTimeout;
2542 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, mask))
2543 conf->dot11MeshHWMPpreqMinInterval =
2544 nconf->dot11MeshHWMPpreqMinInterval;
2545 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL, mask))
2546 conf->dot11MeshHWMPperrMinInterval =
2547 nconf->dot11MeshHWMPperrMinInterval;
2548 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
2550 conf->dot11MeshHWMPnetDiameterTraversalTime =
2551 nconf->dot11MeshHWMPnetDiameterTraversalTime;
2552 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOTMODE, mask)) {
2553 conf->dot11MeshHWMPRootMode = nconf->dot11MeshHWMPRootMode;
2554 ieee80211_mesh_root_setup(ifmsh);
2556 if (_chg_mesh_attr(NL80211_MESHCONF_GATE_ANNOUNCEMENTS, mask)) {
2557 /* our current gate announcement implementation rides on root
2558 * announcements, so require this ifmsh to also be a root node
2560 if (nconf->dot11MeshGateAnnouncementProtocol &&
2561 !(conf->dot11MeshHWMPRootMode > IEEE80211_ROOTMODE_ROOT)) {
2562 conf->dot11MeshHWMPRootMode = IEEE80211_PROACTIVE_RANN;
2563 ieee80211_mesh_root_setup(ifmsh);
2565 conf->dot11MeshGateAnnouncementProtocol =
2566 nconf->dot11MeshGateAnnouncementProtocol;
2568 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_RANN_INTERVAL, mask))
2569 conf->dot11MeshHWMPRannInterval =
2570 nconf->dot11MeshHWMPRannInterval;
2571 if (_chg_mesh_attr(NL80211_MESHCONF_FORWARDING, mask))
2572 conf->dot11MeshForwarding = nconf->dot11MeshForwarding;
2573 if (_chg_mesh_attr(NL80211_MESHCONF_RSSI_THRESHOLD, mask)) {
2574 /* our RSSI threshold implementation is supported only for
2575 * devices that report signal in dBm.
2577 if (!ieee80211_hw_check(&sdata->local->hw, SIGNAL_DBM))
2579 conf->rssi_threshold = nconf->rssi_threshold;
2581 if (_chg_mesh_attr(NL80211_MESHCONF_HT_OPMODE, mask)) {
2582 conf->ht_opmode = nconf->ht_opmode;
2583 sdata->vif.bss_conf.ht_operation_mode = nconf->ht_opmode;
2584 ieee80211_link_info_change_notify(sdata, &sdata->deflink,
2587 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT, mask))
2588 conf->dot11MeshHWMPactivePathToRootTimeout =
2589 nconf->dot11MeshHWMPactivePathToRootTimeout;
2590 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOT_INTERVAL, mask))
2591 conf->dot11MeshHWMProotInterval =
2592 nconf->dot11MeshHWMProotInterval;
2593 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL, mask))
2594 conf->dot11MeshHWMPconfirmationInterval =
2595 nconf->dot11MeshHWMPconfirmationInterval;
2596 if (_chg_mesh_attr(NL80211_MESHCONF_POWER_MODE, mask)) {
2597 conf->power_mode = nconf->power_mode;
2598 ieee80211_mps_local_status_update(sdata);
2600 if (_chg_mesh_attr(NL80211_MESHCONF_AWAKE_WINDOW, mask))
2601 conf->dot11MeshAwakeWindowDuration =
2602 nconf->dot11MeshAwakeWindowDuration;
2603 if (_chg_mesh_attr(NL80211_MESHCONF_PLINK_TIMEOUT, mask))
2604 conf->plink_timeout = nconf->plink_timeout;
2605 if (_chg_mesh_attr(NL80211_MESHCONF_CONNECTED_TO_GATE, mask))
2606 conf->dot11MeshConnectedToMeshGate =
2607 nconf->dot11MeshConnectedToMeshGate;
2608 if (_chg_mesh_attr(NL80211_MESHCONF_NOLEARN, mask))
2609 conf->dot11MeshNolearn = nconf->dot11MeshNolearn;
2610 if (_chg_mesh_attr(NL80211_MESHCONF_CONNECTED_TO_AS, mask))
2611 conf->dot11MeshConnectedToAuthServer =
2612 nconf->dot11MeshConnectedToAuthServer;
2613 ieee80211_mbss_info_change_notify(sdata, BSS_CHANGED_BEACON);
2617 static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev,
2618 const struct mesh_config *conf,
2619 const struct mesh_setup *setup)
2621 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2622 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
2625 memcpy(&ifmsh->mshcfg, conf, sizeof(struct mesh_config));
2626 err = copy_mesh_setup(ifmsh, setup);
2630 sdata->control_port_over_nl80211 = setup->control_port_over_nl80211;
2632 /* can mesh use other SMPS modes? */
2633 sdata->deflink.smps_mode = IEEE80211_SMPS_OFF;
2634 sdata->deflink.needed_rx_chains = sdata->local->rx_chains;
2636 mutex_lock(&sdata->local->mtx);
2637 err = ieee80211_link_use_channel(&sdata->deflink, &setup->chandef,
2638 IEEE80211_CHANCTX_SHARED);
2639 mutex_unlock(&sdata->local->mtx);
2643 return ieee80211_start_mesh(sdata);
2646 static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev)
2648 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2650 ieee80211_stop_mesh(sdata);
2651 mutex_lock(&sdata->local->mtx);
2652 ieee80211_link_release_channel(&sdata->deflink);
2653 kfree(sdata->u.mesh.ie);
2654 mutex_unlock(&sdata->local->mtx);
2660 static int ieee80211_change_bss(struct wiphy *wiphy,
2661 struct net_device *dev,
2662 struct bss_parameters *params)
2664 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2665 struct ieee80211_link_data *link;
2666 struct ieee80211_supported_band *sband;
2669 link = ieee80211_link_or_deflink(sdata, params->link_id, true);
2671 return PTR_ERR(link);
2673 if (!sdata_dereference(link->u.ap.beacon, sdata))
2676 sband = ieee80211_get_link_sband(link);
2680 if (params->basic_rates) {
2681 if (!ieee80211_parse_bitrates(link->conf->chandef.width,
2682 wiphy->bands[sband->band],
2683 params->basic_rates,
2684 params->basic_rates_len,
2685 &link->conf->basic_rates))
2687 changed |= BSS_CHANGED_BASIC_RATES;
2688 ieee80211_check_rate_mask(link);
2691 if (params->use_cts_prot >= 0) {
2692 link->conf->use_cts_prot = params->use_cts_prot;
2693 changed |= BSS_CHANGED_ERP_CTS_PROT;
2695 if (params->use_short_preamble >= 0) {
2696 link->conf->use_short_preamble = params->use_short_preamble;
2697 changed |= BSS_CHANGED_ERP_PREAMBLE;
2700 if (!link->conf->use_short_slot &&
2701 (sband->band == NL80211_BAND_5GHZ ||
2702 sband->band == NL80211_BAND_6GHZ)) {
2703 link->conf->use_short_slot = true;
2704 changed |= BSS_CHANGED_ERP_SLOT;
2707 if (params->use_short_slot_time >= 0) {
2708 link->conf->use_short_slot = params->use_short_slot_time;
2709 changed |= BSS_CHANGED_ERP_SLOT;
2712 if (params->ap_isolate >= 0) {
2713 if (params->ap_isolate)
2714 sdata->flags |= IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
2716 sdata->flags &= ~IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
2717 ieee80211_check_fast_rx_iface(sdata);
2720 if (params->ht_opmode >= 0) {
2721 link->conf->ht_operation_mode = (u16)params->ht_opmode;
2722 changed |= BSS_CHANGED_HT;
2725 if (params->p2p_ctwindow >= 0) {
2726 link->conf->p2p_noa_attr.oppps_ctwindow &=
2727 ~IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
2728 link->conf->p2p_noa_attr.oppps_ctwindow |=
2729 params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
2730 changed |= BSS_CHANGED_P2P_PS;
2733 if (params->p2p_opp_ps > 0) {
2734 link->conf->p2p_noa_attr.oppps_ctwindow |=
2735 IEEE80211_P2P_OPPPS_ENABLE_BIT;
2736 changed |= BSS_CHANGED_P2P_PS;
2737 } else if (params->p2p_opp_ps == 0) {
2738 link->conf->p2p_noa_attr.oppps_ctwindow &=
2739 ~IEEE80211_P2P_OPPPS_ENABLE_BIT;
2740 changed |= BSS_CHANGED_P2P_PS;
2743 ieee80211_link_info_change_notify(sdata, link, changed);
2748 static int ieee80211_set_txq_params(struct wiphy *wiphy,
2749 struct net_device *dev,
2750 struct ieee80211_txq_params *params)
2752 struct ieee80211_local *local = wiphy_priv(wiphy);
2753 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2754 struct ieee80211_link_data *link =
2755 ieee80211_link_or_deflink(sdata, params->link_id, true);
2756 struct ieee80211_tx_queue_params p;
2758 if (!local->ops->conf_tx)
2761 if (local->hw.queues < IEEE80211_NUM_ACS)
2765 return PTR_ERR(link);
2767 memset(&p, 0, sizeof(p));
2768 p.aifs = params->aifs;
2769 p.cw_max = params->cwmax;
2770 p.cw_min = params->cwmin;
2771 p.txop = params->txop;
2774 * Setting tx queue params disables u-apsd because it's only
2775 * called in master mode.
2779 ieee80211_regulatory_limit_wmm_params(sdata, &p, params->ac);
2781 link->tx_conf[params->ac] = p;
2782 if (drv_conf_tx(local, link, params->ac, &p)) {
2783 wiphy_debug(local->hw.wiphy,
2784 "failed to set TX queue parameters for AC %d\n",
2789 ieee80211_link_info_change_notify(sdata, link,
2796 static int ieee80211_suspend(struct wiphy *wiphy,
2797 struct cfg80211_wowlan *wowlan)
2799 return __ieee80211_suspend(wiphy_priv(wiphy), wowlan);
2802 static int ieee80211_resume(struct wiphy *wiphy)
2804 return __ieee80211_resume(wiphy_priv(wiphy));
2807 #define ieee80211_suspend NULL
2808 #define ieee80211_resume NULL
2811 static int ieee80211_scan(struct wiphy *wiphy,
2812 struct cfg80211_scan_request *req)
2814 struct ieee80211_sub_if_data *sdata;
2816 sdata = IEEE80211_WDEV_TO_SUB_IF(req->wdev);
2818 switch (ieee80211_vif_type_p2p(&sdata->vif)) {
2819 case NL80211_IFTYPE_STATION:
2820 case NL80211_IFTYPE_ADHOC:
2821 case NL80211_IFTYPE_MESH_POINT:
2822 case NL80211_IFTYPE_P2P_CLIENT:
2823 case NL80211_IFTYPE_P2P_DEVICE:
2825 case NL80211_IFTYPE_P2P_GO:
2826 if (sdata->local->ops->hw_scan)
2829 * FIXME: implement NoA while scanning in software,
2830 * for now fall through to allow scanning only when
2831 * beaconing hasn't been configured yet
2834 case NL80211_IFTYPE_AP:
2836 * If the scan has been forced (and the driver supports
2837 * forcing), don't care about being beaconing already.
2838 * This will create problems to the attached stations (e.g. all
2839 * the frames sent while scanning on other channel will be
2842 if (sdata->deflink.u.ap.beacon &&
2843 (!(wiphy->features & NL80211_FEATURE_AP_SCAN) ||
2844 !(req->flags & NL80211_SCAN_FLAG_AP)))
2847 case NL80211_IFTYPE_NAN:
2852 return ieee80211_request_scan(sdata, req);
2855 static void ieee80211_abort_scan(struct wiphy *wiphy, struct wireless_dev *wdev)
2857 ieee80211_scan_cancel(wiphy_priv(wiphy));
2861 ieee80211_sched_scan_start(struct wiphy *wiphy,
2862 struct net_device *dev,
2863 struct cfg80211_sched_scan_request *req)
2865 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2867 if (!sdata->local->ops->sched_scan_start)
2870 return ieee80211_request_sched_scan_start(sdata, req);
2874 ieee80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev,
2877 struct ieee80211_local *local = wiphy_priv(wiphy);
2879 if (!local->ops->sched_scan_stop)
2882 return ieee80211_request_sched_scan_stop(local);
2885 static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev,
2886 struct cfg80211_auth_request *req)
2888 return ieee80211_mgd_auth(IEEE80211_DEV_TO_SUB_IF(dev), req);
2891 static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev,
2892 struct cfg80211_assoc_request *req)
2894 return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
2897 static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev,
2898 struct cfg80211_deauth_request *req)
2900 return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev), req);
2903 static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
2904 struct cfg80211_disassoc_request *req)
2906 return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
2909 static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
2910 struct cfg80211_ibss_params *params)
2912 return ieee80211_ibss_join(IEEE80211_DEV_TO_SUB_IF(dev), params);
2915 static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
2917 return ieee80211_ibss_leave(IEEE80211_DEV_TO_SUB_IF(dev));
2920 static int ieee80211_join_ocb(struct wiphy *wiphy, struct net_device *dev,
2921 struct ocb_setup *setup)
2923 return ieee80211_ocb_join(IEEE80211_DEV_TO_SUB_IF(dev), setup);
2926 static int ieee80211_leave_ocb(struct wiphy *wiphy, struct net_device *dev)
2928 return ieee80211_ocb_leave(IEEE80211_DEV_TO_SUB_IF(dev));
2931 static int ieee80211_set_mcast_rate(struct wiphy *wiphy, struct net_device *dev,
2932 int rate[NUM_NL80211_BANDS])
2934 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2936 memcpy(sdata->vif.bss_conf.mcast_rate, rate,
2937 sizeof(int) * NUM_NL80211_BANDS);
2939 ieee80211_link_info_change_notify(sdata, &sdata->deflink,
2940 BSS_CHANGED_MCAST_RATE);
2945 static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
2947 struct ieee80211_local *local = wiphy_priv(wiphy);
2950 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
2951 ieee80211_check_fast_xmit_all(local);
2953 err = drv_set_frag_threshold(local, wiphy->frag_threshold);
2956 ieee80211_check_fast_xmit_all(local);
2961 if ((changed & WIPHY_PARAM_COVERAGE_CLASS) ||
2962 (changed & WIPHY_PARAM_DYN_ACK)) {
2965 coverage_class = changed & WIPHY_PARAM_COVERAGE_CLASS ?
2966 wiphy->coverage_class : -1;
2967 err = drv_set_coverage_class(local, coverage_class);
2973 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
2974 err = drv_set_rts_threshold(local, wiphy->rts_threshold);
2980 if (changed & WIPHY_PARAM_RETRY_SHORT) {
2981 if (wiphy->retry_short > IEEE80211_MAX_TX_RETRY)
2983 local->hw.conf.short_frame_max_tx_count = wiphy->retry_short;
2985 if (changed & WIPHY_PARAM_RETRY_LONG) {
2986 if (wiphy->retry_long > IEEE80211_MAX_TX_RETRY)
2988 local->hw.conf.long_frame_max_tx_count = wiphy->retry_long;
2991 (WIPHY_PARAM_RETRY_SHORT | WIPHY_PARAM_RETRY_LONG))
2992 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS);
2994 if (changed & (WIPHY_PARAM_TXQ_LIMIT |
2995 WIPHY_PARAM_TXQ_MEMORY_LIMIT |
2996 WIPHY_PARAM_TXQ_QUANTUM))
2997 ieee80211_txq_set_params(local);
3002 static int ieee80211_set_tx_power(struct wiphy *wiphy,
3003 struct wireless_dev *wdev,
3004 enum nl80211_tx_power_setting type, int mbm)
3006 struct ieee80211_local *local = wiphy_priv(wiphy);
3007 struct ieee80211_sub_if_data *sdata;
3008 enum nl80211_tx_power_setting txp_type = type;
3009 bool update_txp_type = false;
3010 bool has_monitor = false;
3013 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
3015 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) {
3016 sdata = wiphy_dereference(local->hw.wiphy,
3017 local->monitor_sdata);
3023 case NL80211_TX_POWER_AUTOMATIC:
3024 sdata->deflink.user_power_level =
3025 IEEE80211_UNSET_POWER_LEVEL;
3026 txp_type = NL80211_TX_POWER_LIMITED;
3028 case NL80211_TX_POWER_LIMITED:
3029 case NL80211_TX_POWER_FIXED:
3030 if (mbm < 0 || (mbm % 100))
3032 sdata->deflink.user_power_level = MBM_TO_DBM(mbm);
3036 if (txp_type != sdata->vif.bss_conf.txpower_type) {
3037 update_txp_type = true;
3038 sdata->vif.bss_conf.txpower_type = txp_type;
3041 ieee80211_recalc_txpower(sdata, update_txp_type);
3047 case NL80211_TX_POWER_AUTOMATIC:
3048 local->user_power_level = IEEE80211_UNSET_POWER_LEVEL;
3049 txp_type = NL80211_TX_POWER_LIMITED;
3051 case NL80211_TX_POWER_LIMITED:
3052 case NL80211_TX_POWER_FIXED:
3053 if (mbm < 0 || (mbm % 100))
3055 local->user_power_level = MBM_TO_DBM(mbm);
3059 mutex_lock(&local->iflist_mtx);
3060 list_for_each_entry(sdata, &local->interfaces, list) {
3061 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) {
3065 sdata->deflink.user_power_level = local->user_power_level;
3066 if (txp_type != sdata->vif.bss_conf.txpower_type)
3067 update_txp_type = true;
3068 sdata->vif.bss_conf.txpower_type = txp_type;
3070 list_for_each_entry(sdata, &local->interfaces, list) {
3071 if (sdata->vif.type == NL80211_IFTYPE_MONITOR)
3073 ieee80211_recalc_txpower(sdata, update_txp_type);
3075 mutex_unlock(&local->iflist_mtx);
3078 sdata = wiphy_dereference(local->hw.wiphy,
3079 local->monitor_sdata);
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 ieee80211_recalc_txpower(sdata, update_txp_type);
3093 static int ieee80211_get_tx_power(struct wiphy *wiphy,
3094 struct wireless_dev *wdev,
3097 struct ieee80211_local *local = wiphy_priv(wiphy);
3098 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
3100 if (local->ops->get_txpower)
3101 return drv_get_txpower(local, sdata, dbm);
3103 if (!local->use_chanctx)
3104 *dbm = local->hw.conf.power_level;
3106 *dbm = sdata->vif.bss_conf.txpower;
3111 static void ieee80211_rfkill_poll(struct wiphy *wiphy)
3113 struct ieee80211_local *local = wiphy_priv(wiphy);
3115 drv_rfkill_poll(local);
3118 #ifdef CONFIG_NL80211_TESTMODE
3119 static int ieee80211_testmode_cmd(struct wiphy *wiphy,
3120 struct wireless_dev *wdev,
3121 void *data, int len)
3123 struct ieee80211_local *local = wiphy_priv(wiphy);
3124 struct ieee80211_vif *vif = NULL;
3126 if (!local->ops->testmode_cmd)
3130 struct ieee80211_sub_if_data *sdata;
3132 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
3133 if (sdata->flags & IEEE80211_SDATA_IN_DRIVER)
3137 return local->ops->testmode_cmd(&local->hw, vif, data, len);
3140 static int ieee80211_testmode_dump(struct wiphy *wiphy,
3141 struct sk_buff *skb,
3142 struct netlink_callback *cb,
3143 void *data, int len)
3145 struct ieee80211_local *local = wiphy_priv(wiphy);
3147 if (!local->ops->testmode_dump)
3150 return local->ops->testmode_dump(&local->hw, skb, cb, data, len);
3154 int __ieee80211_request_smps_mgd(struct ieee80211_sub_if_data *sdata,
3155 struct ieee80211_link_data *link,
3156 enum ieee80211_smps_mode smps_mode)
3159 enum ieee80211_smps_mode old_req;
3161 struct sta_info *sta;
3162 bool tdls_peer_found = false;
3164 lockdep_assert_held(&sdata->wdev.mtx);
3166 if (WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION))
3169 old_req = link->u.mgd.req_smps;
3170 link->u.mgd.req_smps = smps_mode;
3172 if (old_req == smps_mode &&
3173 smps_mode != IEEE80211_SMPS_AUTOMATIC)
3177 * If not associated, or current association is not an HT
3178 * association, there's no need to do anything, just store
3179 * the new value until we associate.
3181 if (!sdata->u.mgd.associated ||
3182 link->conf->chandef.width == NL80211_CHAN_WIDTH_20_NOHT)
3185 ap = link->u.mgd.bssid;
3188 list_for_each_entry_rcu(sta, &sdata->local->sta_list, list) {
3189 if (!sta->sta.tdls || sta->sdata != sdata || !sta->uploaded ||
3190 !test_sta_flag(sta, WLAN_STA_AUTHORIZED))
3193 tdls_peer_found = true;
3198 if (smps_mode == IEEE80211_SMPS_AUTOMATIC) {
3199 if (tdls_peer_found || !sdata->u.mgd.powersave)
3200 smps_mode = IEEE80211_SMPS_OFF;
3202 smps_mode = IEEE80211_SMPS_DYNAMIC;
3205 /* send SM PS frame to AP */
3206 err = ieee80211_send_smps_action(sdata, smps_mode,
3209 link->u.mgd.req_smps = old_req;
3210 else if (smps_mode != IEEE80211_SMPS_OFF && tdls_peer_found)
3211 ieee80211_teardown_tdls_peers(sdata);
3216 static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
3217 bool enabled, int timeout)
3219 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3220 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
3221 unsigned int link_id;
3223 if (sdata->vif.type != NL80211_IFTYPE_STATION)
3226 if (!ieee80211_hw_check(&local->hw, SUPPORTS_PS))
3229 if (enabled == sdata->u.mgd.powersave &&
3230 timeout == local->dynamic_ps_forced_timeout)
3233 sdata->u.mgd.powersave = enabled;
3234 local->dynamic_ps_forced_timeout = timeout;
3236 /* no change, but if automatic follow powersave */
3238 for (link_id = 0; link_id < ARRAY_SIZE(sdata->link); link_id++) {
3239 struct ieee80211_link_data *link;
3241 link = sdata_dereference(sdata->link[link_id], sdata);
3245 __ieee80211_request_smps_mgd(sdata, link,
3246 link->u.mgd.req_smps);
3248 sdata_unlock(sdata);
3250 if (ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS))
3251 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
3253 ieee80211_recalc_ps(local);
3254 ieee80211_recalc_ps_vif(sdata);
3255 ieee80211_check_fast_rx_iface(sdata);
3260 static int ieee80211_set_cqm_rssi_config(struct wiphy *wiphy,
3261 struct net_device *dev,
3262 s32 rssi_thold, u32 rssi_hyst)
3264 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3265 struct ieee80211_vif *vif = &sdata->vif;
3266 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
3268 if (rssi_thold == bss_conf->cqm_rssi_thold &&
3269 rssi_hyst == bss_conf->cqm_rssi_hyst)
3272 if (sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER &&
3273 !(sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI))
3276 bss_conf->cqm_rssi_thold = rssi_thold;
3277 bss_conf->cqm_rssi_hyst = rssi_hyst;
3278 bss_conf->cqm_rssi_low = 0;
3279 bss_conf->cqm_rssi_high = 0;
3280 sdata->deflink.u.mgd.last_cqm_event_signal = 0;
3282 /* tell the driver upon association, unless already associated */
3283 if (sdata->u.mgd.associated &&
3284 sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)
3285 ieee80211_link_info_change_notify(sdata, &sdata->deflink,
3291 static int ieee80211_set_cqm_rssi_range_config(struct wiphy *wiphy,
3292 struct net_device *dev,
3293 s32 rssi_low, s32 rssi_high)
3295 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3296 struct ieee80211_vif *vif = &sdata->vif;
3297 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
3299 if (sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER)
3302 bss_conf->cqm_rssi_low = rssi_low;
3303 bss_conf->cqm_rssi_high = rssi_high;
3304 bss_conf->cqm_rssi_thold = 0;
3305 bss_conf->cqm_rssi_hyst = 0;
3306 sdata->deflink.u.mgd.last_cqm_event_signal = 0;
3308 /* tell the driver upon association, unless already associated */
3309 if (sdata->u.mgd.associated &&
3310 sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)
3311 ieee80211_link_info_change_notify(sdata, &sdata->deflink,
3317 static int ieee80211_set_bitrate_mask(struct wiphy *wiphy,
3318 struct net_device *dev,
3319 unsigned int link_id,
3321 const struct cfg80211_bitrate_mask *mask)
3323 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3324 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
3327 if (!ieee80211_sdata_running(sdata))
3331 * If active validate the setting and reject it if it doesn't leave
3332 * at least one basic rate usable, since we really have to be able
3333 * to send something, and if we're an AP we have to be able to do
3334 * so at a basic rate so that all clients can receive it.
3336 if (rcu_access_pointer(sdata->vif.bss_conf.chanctx_conf) &&
3337 sdata->vif.bss_conf.chandef.chan) {
3338 u32 basic_rates = sdata->vif.bss_conf.basic_rates;
3339 enum nl80211_band band = sdata->vif.bss_conf.chandef.chan->band;
3341 if (!(mask->control[band].legacy & basic_rates))
3345 if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) {
3346 ret = drv_set_bitrate_mask(local, sdata, mask);
3351 for (i = 0; i < NUM_NL80211_BANDS; i++) {
3352 struct ieee80211_supported_band *sband = wiphy->bands[i];
3355 sdata->rc_rateidx_mask[i] = mask->control[i].legacy;
3356 memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].ht_mcs,
3357 sizeof(mask->control[i].ht_mcs));
3358 memcpy(sdata->rc_rateidx_vht_mcs_mask[i],
3359 mask->control[i].vht_mcs,
3360 sizeof(mask->control[i].vht_mcs));
3362 sdata->rc_has_mcs_mask[i] = false;
3363 sdata->rc_has_vht_mcs_mask[i] = false;
3367 for (j = 0; j < IEEE80211_HT_MCS_MASK_LEN; j++) {
3368 if (sdata->rc_rateidx_mcs_mask[i][j] != 0xff) {
3369 sdata->rc_has_mcs_mask[i] = true;
3374 for (j = 0; j < NL80211_VHT_NSS_MAX; j++) {
3375 if (sdata->rc_rateidx_vht_mcs_mask[i][j] != 0xffff) {
3376 sdata->rc_has_vht_mcs_mask[i] = true;
3385 static int ieee80211_start_radar_detection(struct wiphy *wiphy,
3386 struct net_device *dev,
3387 struct cfg80211_chan_def *chandef,
3390 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3391 struct ieee80211_local *local = sdata->local;
3394 mutex_lock(&local->mtx);
3395 if (!list_empty(&local->roc_list) || local->scanning) {
3400 /* whatever, but channel contexts should not complain about that one */
3401 sdata->deflink.smps_mode = IEEE80211_SMPS_OFF;
3402 sdata->deflink.needed_rx_chains = local->rx_chains;
3404 err = ieee80211_link_use_channel(&sdata->deflink, chandef,
3405 IEEE80211_CHANCTX_SHARED);
3409 ieee80211_queue_delayed_work(&sdata->local->hw,
3410 &sdata->deflink.dfs_cac_timer_work,
3411 msecs_to_jiffies(cac_time_ms));
3414 mutex_unlock(&local->mtx);
3418 static void ieee80211_end_cac(struct wiphy *wiphy,
3419 struct net_device *dev)
3421 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3422 struct ieee80211_local *local = sdata->local;
3424 mutex_lock(&local->mtx);
3425 list_for_each_entry(sdata, &local->interfaces, list) {
3426 /* it might be waiting for the local->mtx, but then
3427 * by the time it gets it, sdata->wdev.cac_started
3428 * will no longer be true
3430 cancel_delayed_work(&sdata->deflink.dfs_cac_timer_work);
3432 if (sdata->wdev.cac_started) {
3433 ieee80211_link_release_channel(&sdata->deflink);
3434 sdata->wdev.cac_started = false;
3437 mutex_unlock(&local->mtx);
3440 static struct cfg80211_beacon_data *
3441 cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon)
3443 struct cfg80211_beacon_data *new_beacon;
3447 len = beacon->head_len + beacon->tail_len + beacon->beacon_ies_len +
3448 beacon->proberesp_ies_len + beacon->assocresp_ies_len +
3449 beacon->probe_resp_len + beacon->lci_len + beacon->civicloc_len;
3451 if (beacon->mbssid_ies)
3452 len += ieee80211_get_mbssid_beacon_len(beacon->mbssid_ies,
3454 beacon->mbssid_ies->cnt);
3456 new_beacon = kzalloc(sizeof(*new_beacon) + len, GFP_KERNEL);
3460 if (beacon->mbssid_ies && beacon->mbssid_ies->cnt) {
3461 new_beacon->mbssid_ies =
3462 kzalloc(struct_size(new_beacon->mbssid_ies,
3463 elem, beacon->mbssid_ies->cnt),
3465 if (!new_beacon->mbssid_ies) {
3470 if (beacon->rnr_ies && beacon->rnr_ies->cnt) {
3471 new_beacon->rnr_ies =
3472 kzalloc(struct_size(new_beacon->rnr_ies,
3473 elem, beacon->rnr_ies->cnt),
3475 if (!new_beacon->rnr_ies) {
3476 kfree(new_beacon->mbssid_ies);
3483 pos = (u8 *)(new_beacon + 1);
3484 if (beacon->head_len) {
3485 new_beacon->head_len = beacon->head_len;
3486 new_beacon->head = pos;
3487 memcpy(pos, beacon->head, beacon->head_len);
3488 pos += beacon->head_len;
3490 if (beacon->tail_len) {
3491 new_beacon->tail_len = beacon->tail_len;
3492 new_beacon->tail = pos;
3493 memcpy(pos, beacon->tail, beacon->tail_len);
3494 pos += beacon->tail_len;
3496 if (beacon->beacon_ies_len) {
3497 new_beacon->beacon_ies_len = beacon->beacon_ies_len;
3498 new_beacon->beacon_ies = pos;
3499 memcpy(pos, beacon->beacon_ies, beacon->beacon_ies_len);
3500 pos += beacon->beacon_ies_len;
3502 if (beacon->proberesp_ies_len) {
3503 new_beacon->proberesp_ies_len = beacon->proberesp_ies_len;
3504 new_beacon->proberesp_ies = pos;
3505 memcpy(pos, beacon->proberesp_ies, beacon->proberesp_ies_len);
3506 pos += beacon->proberesp_ies_len;
3508 if (beacon->assocresp_ies_len) {
3509 new_beacon->assocresp_ies_len = beacon->assocresp_ies_len;
3510 new_beacon->assocresp_ies = pos;
3511 memcpy(pos, beacon->assocresp_ies, beacon->assocresp_ies_len);
3512 pos += beacon->assocresp_ies_len;
3514 if (beacon->probe_resp_len) {
3515 new_beacon->probe_resp_len = beacon->probe_resp_len;
3516 new_beacon->probe_resp = pos;
3517 memcpy(pos, beacon->probe_resp, beacon->probe_resp_len);
3518 pos += beacon->probe_resp_len;
3520 if (beacon->mbssid_ies && beacon->mbssid_ies->cnt) {
3521 pos += ieee80211_copy_mbssid_beacon(pos,
3522 new_beacon->mbssid_ies,
3523 beacon->mbssid_ies);
3524 if (beacon->rnr_ies && beacon->rnr_ies->cnt)
3525 pos += ieee80211_copy_rnr_beacon(pos,
3526 new_beacon->rnr_ies,
3530 /* might copy -1, meaning no changes requested */
3531 new_beacon->ftm_responder = beacon->ftm_responder;
3533 new_beacon->lci_len = beacon->lci_len;
3534 new_beacon->lci = pos;
3535 memcpy(pos, beacon->lci, beacon->lci_len);
3536 pos += beacon->lci_len;
3538 if (beacon->civicloc) {
3539 new_beacon->civicloc_len = beacon->civicloc_len;
3540 new_beacon->civicloc = pos;
3541 memcpy(pos, beacon->civicloc, beacon->civicloc_len);
3542 pos += beacon->civicloc_len;
3548 void ieee80211_csa_finish(struct ieee80211_vif *vif)
3550 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
3551 struct ieee80211_local *local = sdata->local;
3555 if (vif->mbssid_tx_vif == vif) {
3556 /* Trigger ieee80211_csa_finish() on the non-transmitting
3557 * interfaces when channel switch is received on
3558 * transmitting interface
3560 struct ieee80211_sub_if_data *iter;
3562 list_for_each_entry_rcu(iter, &local->interfaces, list) {
3563 if (!ieee80211_sdata_running(iter))
3566 if (iter == sdata || iter->vif.mbssid_tx_vif != vif)
3569 ieee80211_queue_work(&iter->local->hw,
3570 &iter->deflink.csa_finalize_work);
3573 ieee80211_queue_work(&local->hw, &sdata->deflink.csa_finalize_work);
3577 EXPORT_SYMBOL(ieee80211_csa_finish);
3579 void ieee80211_channel_switch_disconnect(struct ieee80211_vif *vif, bool block_tx)
3581 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
3582 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
3583 struct ieee80211_local *local = sdata->local;
3585 sdata->deflink.csa_block_tx = block_tx;
3586 sdata_info(sdata, "channel switch failed, disconnecting\n");
3587 ieee80211_queue_work(&local->hw, &ifmgd->csa_connection_drop_work);
3589 EXPORT_SYMBOL(ieee80211_channel_switch_disconnect);
3591 static int ieee80211_set_after_csa_beacon(struct ieee80211_sub_if_data *sdata,
3596 switch (sdata->vif.type) {
3597 case NL80211_IFTYPE_AP:
3598 if (!sdata->deflink.u.ap.next_beacon)
3601 err = ieee80211_assign_beacon(sdata, &sdata->deflink,
3602 sdata->deflink.u.ap.next_beacon,
3604 ieee80211_free_next_beacon(&sdata->deflink);
3610 case NL80211_IFTYPE_ADHOC:
3611 err = ieee80211_ibss_finish_csa(sdata);
3616 #ifdef CONFIG_MAC80211_MESH
3617 case NL80211_IFTYPE_MESH_POINT:
3618 err = ieee80211_mesh_finish_csa(sdata);
3632 static int __ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata)
3634 struct ieee80211_local *local = sdata->local;
3638 sdata_assert_lock(sdata);
3639 lockdep_assert_held(&local->mtx);
3640 lockdep_assert_held(&local->chanctx_mtx);
3642 if (sdata->vif.bss_conf.eht_puncturing != sdata->vif.bss_conf.csa_punct_bitmap) {
3643 sdata->vif.bss_conf.eht_puncturing =
3644 sdata->vif.bss_conf.csa_punct_bitmap;
3645 changed |= BSS_CHANGED_EHT_PUNCTURING;
3649 * using reservation isn't immediate as it may be deferred until later
3650 * with multi-vif. once reservation is complete it will re-schedule the
3651 * work with no reserved_chanctx so verify chandef to check if it
3652 * completed successfully
3655 if (sdata->deflink.reserved_chanctx) {
3657 * with multi-vif csa driver may call ieee80211_csa_finish()
3658 * many times while waiting for other interfaces to use their
3661 if (sdata->deflink.reserved_ready)
3664 return ieee80211_link_use_reserved_context(&sdata->deflink);
3667 if (!cfg80211_chandef_identical(&sdata->vif.bss_conf.chandef,
3668 &sdata->deflink.csa_chandef))
3671 sdata->vif.bss_conf.csa_active = false;
3673 err = ieee80211_set_after_csa_beacon(sdata, &changed);
3677 ieee80211_link_info_change_notify(sdata, &sdata->deflink, changed);
3679 if (sdata->deflink.csa_block_tx) {
3680 ieee80211_wake_vif_queues(local, sdata,
3681 IEEE80211_QUEUE_STOP_REASON_CSA);
3682 sdata->deflink.csa_block_tx = false;
3685 err = drv_post_channel_switch(sdata);
3689 cfg80211_ch_switch_notify(sdata->dev, &sdata->deflink.csa_chandef, 0,
3690 sdata->vif.bss_conf.eht_puncturing);
3695 static void ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata)
3697 if (__ieee80211_csa_finalize(sdata)) {
3698 sdata_info(sdata, "failed to finalize CSA, disconnecting\n");
3699 cfg80211_stop_iface(sdata->local->hw.wiphy, &sdata->wdev,
3704 void ieee80211_csa_finalize_work(struct work_struct *work)
3706 struct ieee80211_sub_if_data *sdata =
3707 container_of(work, struct ieee80211_sub_if_data,
3708 deflink.csa_finalize_work);
3709 struct ieee80211_local *local = sdata->local;
3712 mutex_lock(&local->mtx);
3713 mutex_lock(&local->chanctx_mtx);
3715 /* AP might have been stopped while waiting for the lock. */
3716 if (!sdata->vif.bss_conf.csa_active)
3719 if (!ieee80211_sdata_running(sdata))
3722 ieee80211_csa_finalize(sdata);
3725 mutex_unlock(&local->chanctx_mtx);
3726 mutex_unlock(&local->mtx);
3727 sdata_unlock(sdata);
3730 static int ieee80211_set_csa_beacon(struct ieee80211_sub_if_data *sdata,
3731 struct cfg80211_csa_settings *params,
3734 struct ieee80211_csa_settings csa = {};
3737 switch (sdata->vif.type) {
3738 case NL80211_IFTYPE_AP:
3739 sdata->deflink.u.ap.next_beacon =
3740 cfg80211_beacon_dup(¶ms->beacon_after);
3741 if (!sdata->deflink.u.ap.next_beacon)
3745 * With a count of 0, we don't have to wait for any
3746 * TBTT before switching, so complete the CSA
3747 * immediately. In theory, with a count == 1 we
3748 * should delay the switch until just before the next
3749 * TBTT, but that would complicate things so we switch
3750 * immediately too. If we would delay the switch
3751 * until the next TBTT, we would have to set the probe
3754 * TODO: A channel switch with count <= 1 without
3755 * sending a CSA action frame is kind of useless,
3756 * because the clients won't know we're changing
3757 * channels. The action frame must be implemented
3758 * either here or in the userspace.
3760 if (params->count <= 1)
3763 if ((params->n_counter_offsets_beacon >
3764 IEEE80211_MAX_CNTDWN_COUNTERS_NUM) ||
3765 (params->n_counter_offsets_presp >
3766 IEEE80211_MAX_CNTDWN_COUNTERS_NUM)) {
3767 ieee80211_free_next_beacon(&sdata->deflink);
3771 csa.counter_offsets_beacon = params->counter_offsets_beacon;
3772 csa.counter_offsets_presp = params->counter_offsets_presp;
3773 csa.n_counter_offsets_beacon = params->n_counter_offsets_beacon;
3774 csa.n_counter_offsets_presp = params->n_counter_offsets_presp;
3775 csa.count = params->count;
3777 err = ieee80211_assign_beacon(sdata, &sdata->deflink,
3778 ¶ms->beacon_csa, &csa,
3781 ieee80211_free_next_beacon(&sdata->deflink);
3787 case NL80211_IFTYPE_ADHOC:
3788 if (!sdata->vif.cfg.ibss_joined)
3791 if (params->chandef.width != sdata->u.ibss.chandef.width)
3794 switch (params->chandef.width) {
3795 case NL80211_CHAN_WIDTH_40:
3796 if (cfg80211_get_chandef_type(¶ms->chandef) !=
3797 cfg80211_get_chandef_type(&sdata->u.ibss.chandef))
3800 case NL80211_CHAN_WIDTH_5:
3801 case NL80211_CHAN_WIDTH_10:
3802 case NL80211_CHAN_WIDTH_20_NOHT:
3803 case NL80211_CHAN_WIDTH_20:
3809 /* changes into another band are not supported */
3810 if (sdata->u.ibss.chandef.chan->band !=
3811 params->chandef.chan->band)
3814 /* see comments in the NL80211_IFTYPE_AP block */
3815 if (params->count > 1) {
3816 err = ieee80211_ibss_csa_beacon(sdata, params);
3822 ieee80211_send_action_csa(sdata, params);
3825 #ifdef CONFIG_MAC80211_MESH
3826 case NL80211_IFTYPE_MESH_POINT: {
3827 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
3829 /* changes into another band are not supported */
3830 if (sdata->vif.bss_conf.chandef.chan->band !=
3831 params->chandef.chan->band)
3834 if (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_NONE) {
3835 ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_INIT;
3836 if (!ifmsh->pre_value)
3837 ifmsh->pre_value = 1;
3842 /* see comments in the NL80211_IFTYPE_AP block */
3843 if (params->count > 1) {
3844 err = ieee80211_mesh_csa_beacon(sdata, params);
3846 ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_NONE;
3852 if (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_INIT)
3853 ieee80211_send_action_csa(sdata, params);
3865 static void ieee80211_color_change_abort(struct ieee80211_sub_if_data *sdata)
3867 sdata->vif.bss_conf.color_change_active = false;
3869 ieee80211_free_next_beacon(&sdata->deflink);
3871 cfg80211_color_change_aborted_notify(sdata->dev);
3875 __ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
3876 struct cfg80211_csa_settings *params)
3878 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3879 struct ieee80211_local *local = sdata->local;
3880 struct ieee80211_channel_switch ch_switch;
3881 struct ieee80211_chanctx_conf *conf;
3882 struct ieee80211_chanctx *chanctx;
3886 sdata_assert_lock(sdata);
3887 lockdep_assert_held(&local->mtx);
3889 if (!list_empty(&local->roc_list) || local->scanning)
3892 if (sdata->wdev.cac_started)
3895 if (cfg80211_chandef_identical(¶ms->chandef,
3896 &sdata->vif.bss_conf.chandef))
3899 /* don't allow another channel switch if one is already active. */
3900 if (sdata->vif.bss_conf.csa_active)
3903 mutex_lock(&local->chanctx_mtx);
3904 conf = rcu_dereference_protected(sdata->vif.bss_conf.chanctx_conf,
3905 lockdep_is_held(&local->chanctx_mtx));
3911 if (params->chandef.chan->freq_offset) {
3912 /* this may work, but is untested */
3917 chanctx = container_of(conf, struct ieee80211_chanctx, conf);
3919 ch_switch.timestamp = 0;
3920 ch_switch.device_timestamp = 0;
3921 ch_switch.block_tx = params->block_tx;
3922 ch_switch.chandef = params->chandef;
3923 ch_switch.count = params->count;
3925 err = drv_pre_channel_switch(sdata, &ch_switch);
3929 err = ieee80211_link_reserve_chanctx(&sdata->deflink, ¶ms->chandef,
3931 params->radar_required);
3935 /* if reservation is invalid then this will fail */
3936 err = ieee80211_check_combinations(sdata, NULL, chanctx->mode, 0);
3938 ieee80211_link_unreserve_chanctx(&sdata->deflink);
3942 /* if there is a color change in progress, abort it */
3943 if (sdata->vif.bss_conf.color_change_active)
3944 ieee80211_color_change_abort(sdata);
3946 err = ieee80211_set_csa_beacon(sdata, params, &changed);
3948 ieee80211_link_unreserve_chanctx(&sdata->deflink);
3952 if (params->punct_bitmap && !sdata->vif.bss_conf.eht_support)
3955 sdata->deflink.csa_chandef = params->chandef;
3956 sdata->deflink.csa_block_tx = params->block_tx;
3957 sdata->vif.bss_conf.csa_active = true;
3958 sdata->vif.bss_conf.csa_punct_bitmap = params->punct_bitmap;
3960 if (sdata->deflink.csa_block_tx)
3961 ieee80211_stop_vif_queues(local, sdata,
3962 IEEE80211_QUEUE_STOP_REASON_CSA);
3964 cfg80211_ch_switch_started_notify(sdata->dev,
3965 &sdata->deflink.csa_chandef, 0,
3966 params->count, params->block_tx,
3967 sdata->vif.bss_conf.csa_punct_bitmap);
3970 ieee80211_link_info_change_notify(sdata, &sdata->deflink,
3972 drv_channel_switch_beacon(sdata, ¶ms->chandef);
3974 /* if the beacon didn't change, we can finalize immediately */
3975 ieee80211_csa_finalize(sdata);
3979 mutex_unlock(&local->chanctx_mtx);
3983 int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
3984 struct cfg80211_csa_settings *params)
3986 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3987 struct ieee80211_local *local = sdata->local;
3990 mutex_lock(&local->mtx);
3991 err = __ieee80211_channel_switch(wiphy, dev, params);
3992 mutex_unlock(&local->mtx);
3997 u64 ieee80211_mgmt_tx_cookie(struct ieee80211_local *local)
3999 lockdep_assert_held(&local->mtx);
4001 local->roc_cookie_counter++;
4003 /* wow, you wrapped 64 bits ... more likely a bug */
4004 if (WARN_ON(local->roc_cookie_counter == 0))
4005 local->roc_cookie_counter++;
4007 return local->roc_cookie_counter;
4010 int ieee80211_attach_ack_skb(struct ieee80211_local *local, struct sk_buff *skb,
4011 u64 *cookie, gfp_t gfp)
4013 unsigned long spin_flags;
4014 struct sk_buff *ack_skb;
4017 ack_skb = skb_copy(skb, gfp);
4021 spin_lock_irqsave(&local->ack_status_lock, spin_flags);
4022 id = idr_alloc(&local->ack_status_frames, ack_skb,
4023 1, 0x2000, GFP_ATOMIC);
4024 spin_unlock_irqrestore(&local->ack_status_lock, spin_flags);
4031 IEEE80211_SKB_CB(skb)->ack_frame_id = id;
4033 *cookie = ieee80211_mgmt_tx_cookie(local);
4034 IEEE80211_SKB_CB(ack_skb)->ack.cookie = *cookie;
4040 ieee80211_update_mgmt_frame_registrations(struct wiphy *wiphy,
4041 struct wireless_dev *wdev,
4042 struct mgmt_frame_regs *upd)
4044 struct ieee80211_local *local = wiphy_priv(wiphy);
4045 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
4046 u32 preq_mask = BIT(IEEE80211_STYPE_PROBE_REQ >> 4);
4047 u32 action_mask = BIT(IEEE80211_STYPE_ACTION >> 4);
4048 bool global_change, intf_change;
4051 (local->probe_req_reg != !!(upd->global_stypes & preq_mask)) ||
4052 (local->rx_mcast_action_reg !=
4053 !!(upd->global_mcast_stypes & action_mask));
4054 local->probe_req_reg = upd->global_stypes & preq_mask;
4055 local->rx_mcast_action_reg = upd->global_mcast_stypes & action_mask;
4057 intf_change = (sdata->vif.probe_req_reg !=
4058 !!(upd->interface_stypes & preq_mask)) ||
4059 (sdata->vif.rx_mcast_action_reg !=
4060 !!(upd->interface_mcast_stypes & action_mask));
4061 sdata->vif.probe_req_reg = upd->interface_stypes & preq_mask;
4062 sdata->vif.rx_mcast_action_reg =
4063 upd->interface_mcast_stypes & action_mask;
4065 if (!local->open_count)
4068 if (intf_change && ieee80211_sdata_running(sdata))
4069 drv_config_iface_filter(local, sdata,
4070 sdata->vif.probe_req_reg ?
4075 ieee80211_configure_filter(local);
4078 static int ieee80211_set_antenna(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant)
4080 struct ieee80211_local *local = wiphy_priv(wiphy);
4085 return drv_set_antenna(local, tx_ant, rx_ant);
4088 static int ieee80211_get_antenna(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant)
4090 struct ieee80211_local *local = wiphy_priv(wiphy);
4092 return drv_get_antenna(local, tx_ant, rx_ant);
4095 static int ieee80211_set_rekey_data(struct wiphy *wiphy,
4096 struct net_device *dev,
4097 struct cfg80211_gtk_rekey_data *data)
4099 struct ieee80211_local *local = wiphy_priv(wiphy);
4100 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4102 if (!local->ops->set_rekey_data)
4105 drv_set_rekey_data(local, sdata, data);
4110 static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev,
4111 const u8 *peer, u64 *cookie)
4113 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4114 struct ieee80211_local *local = sdata->local;
4115 struct ieee80211_qos_hdr *nullfunc;
4116 struct sk_buff *skb;
4117 int size = sizeof(*nullfunc);
4120 struct ieee80211_tx_info *info;
4121 struct sta_info *sta;
4122 struct ieee80211_chanctx_conf *chanctx_conf;
4123 enum nl80211_band band;
4126 /* the lock is needed to assign the cookie later */
4127 mutex_lock(&local->mtx);
4130 chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf);
4131 if (WARN_ON(!chanctx_conf)) {
4135 band = chanctx_conf->def.chan->band;
4136 sta = sta_info_get_bss(sdata, peer);
4145 fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
4146 IEEE80211_STYPE_QOS_NULLFUNC |
4147 IEEE80211_FCTL_FROMDS);
4150 fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
4151 IEEE80211_STYPE_NULLFUNC |
4152 IEEE80211_FCTL_FROMDS);
4155 skb = dev_alloc_skb(local->hw.extra_tx_headroom + size);
4163 skb_reserve(skb, local->hw.extra_tx_headroom);
4165 nullfunc = skb_put(skb, size);
4166 nullfunc->frame_control = fc;
4167 nullfunc->duration_id = 0;
4168 memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN);
4169 memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN);
4170 memcpy(nullfunc->addr3, sdata->vif.addr, ETH_ALEN);
4171 nullfunc->seq_ctrl = 0;
4173 info = IEEE80211_SKB_CB(skb);
4175 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS |
4176 IEEE80211_TX_INTFL_NL80211_FRAME_TX;
4179 skb_set_queue_mapping(skb, IEEE80211_AC_VO);
4182 nullfunc->qos_ctrl = cpu_to_le16(7);
4184 ret = ieee80211_attach_ack_skb(local, skb, cookie, GFP_ATOMIC);
4191 ieee80211_xmit(sdata, sta, skb);
4197 mutex_unlock(&local->mtx);
4202 static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
4203 struct wireless_dev *wdev,
4204 unsigned int link_id,
4205 struct cfg80211_chan_def *chandef)
4207 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
4208 struct ieee80211_local *local = wiphy_priv(wiphy);
4209 struct ieee80211_chanctx_conf *chanctx_conf;
4210 struct ieee80211_link_data *link;
4214 link = rcu_dereference(sdata->link[link_id]);
4220 chanctx_conf = rcu_dereference(link->conf->chanctx_conf);
4222 *chandef = link->conf->chandef;
4224 } else if (local->open_count > 0 &&
4225 local->open_count == local->monitors &&
4226 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
4227 if (local->use_chanctx)
4228 *chandef = local->monitor_chandef;
4230 *chandef = local->_oper_chandef;
4240 static void ieee80211_set_wakeup(struct wiphy *wiphy, bool enabled)
4242 drv_set_wakeup(wiphy_priv(wiphy), enabled);
4246 static int ieee80211_set_qos_map(struct wiphy *wiphy,
4247 struct net_device *dev,
4248 struct cfg80211_qos_map *qos_map)
4250 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4251 struct mac80211_qos_map *new_qos_map, *old_qos_map;
4254 new_qos_map = kzalloc(sizeof(*new_qos_map), GFP_KERNEL);
4257 memcpy(&new_qos_map->qos_map, qos_map, sizeof(*qos_map));
4259 /* A NULL qos_map was passed to disable QoS mapping */
4263 old_qos_map = sdata_dereference(sdata->qos_map, sdata);
4264 rcu_assign_pointer(sdata->qos_map, new_qos_map);
4266 kfree_rcu(old_qos_map, rcu_head);
4271 static int ieee80211_set_ap_chanwidth(struct wiphy *wiphy,
4272 struct net_device *dev,
4273 unsigned int link_id,
4274 struct cfg80211_chan_def *chandef)
4276 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4277 struct ieee80211_link_data *link;
4281 link = sdata_dereference(sdata->link[link_id], sdata);
4283 ret = ieee80211_link_change_bandwidth(link, chandef, &changed);
4285 ieee80211_link_info_change_notify(sdata, link, changed);
4290 static int ieee80211_add_tx_ts(struct wiphy *wiphy, struct net_device *dev,
4291 u8 tsid, const u8 *peer, u8 up,
4294 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4295 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
4296 int ac = ieee802_1d_to_ac[up];
4298 if (sdata->vif.type != NL80211_IFTYPE_STATION)
4301 if (!(sdata->wmm_acm & BIT(up)))
4304 if (ifmgd->tx_tspec[ac].admitted_time)
4307 if (admitted_time) {
4308 ifmgd->tx_tspec[ac].admitted_time = 32 * admitted_time;
4309 ifmgd->tx_tspec[ac].tsid = tsid;
4310 ifmgd->tx_tspec[ac].up = up;
4316 static int ieee80211_del_tx_ts(struct wiphy *wiphy, struct net_device *dev,
4317 u8 tsid, const u8 *peer)
4319 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4320 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
4321 struct ieee80211_local *local = wiphy_priv(wiphy);
4324 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
4325 struct ieee80211_sta_tx_tspec *tx_tspec = &ifmgd->tx_tspec[ac];
4327 /* skip unused entries */
4328 if (!tx_tspec->admitted_time)
4331 if (tx_tspec->tsid != tsid)
4334 /* due to this new packets will be reassigned to non-ACM ACs */
4337 /* Make sure that all packets have been sent to avoid to
4338 * restore the QoS params on packets that are still on the
4342 ieee80211_flush_queues(local, sdata, false);
4344 /* restore the normal QoS parameters
4345 * (unconditionally to avoid races)
4347 tx_tspec->action = TX_TSPEC_ACTION_STOP_DOWNGRADE;
4348 tx_tspec->downgraded = false;
4349 ieee80211_sta_handle_tspec_ac_params(sdata);
4351 /* finally clear all the data */
4352 memset(tx_tspec, 0, sizeof(*tx_tspec));
4360 void ieee80211_nan_func_terminated(struct ieee80211_vif *vif,
4362 enum nl80211_nan_func_term_reason reason,
4365 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
4366 struct cfg80211_nan_func *func;
4369 if (WARN_ON(vif->type != NL80211_IFTYPE_NAN))
4372 spin_lock_bh(&sdata->u.nan.func_lock);
4374 func = idr_find(&sdata->u.nan.function_inst_ids, inst_id);
4375 if (WARN_ON(!func)) {
4376 spin_unlock_bh(&sdata->u.nan.func_lock);
4380 cookie = func->cookie;
4381 idr_remove(&sdata->u.nan.function_inst_ids, inst_id);
4383 spin_unlock_bh(&sdata->u.nan.func_lock);
4385 cfg80211_free_nan_func(func);
4387 cfg80211_nan_func_terminated(ieee80211_vif_to_wdev(vif), inst_id,
4388 reason, cookie, gfp);
4390 EXPORT_SYMBOL(ieee80211_nan_func_terminated);
4392 void ieee80211_nan_func_match(struct ieee80211_vif *vif,
4393 struct cfg80211_nan_match_params *match,
4396 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
4397 struct cfg80211_nan_func *func;
4399 if (WARN_ON(vif->type != NL80211_IFTYPE_NAN))
4402 spin_lock_bh(&sdata->u.nan.func_lock);
4404 func = idr_find(&sdata->u.nan.function_inst_ids, match->inst_id);
4405 if (WARN_ON(!func)) {
4406 spin_unlock_bh(&sdata->u.nan.func_lock);
4409 match->cookie = func->cookie;
4411 spin_unlock_bh(&sdata->u.nan.func_lock);
4413 cfg80211_nan_match(ieee80211_vif_to_wdev(vif), match, gfp);
4415 EXPORT_SYMBOL(ieee80211_nan_func_match);
4417 static int ieee80211_set_multicast_to_unicast(struct wiphy *wiphy,
4418 struct net_device *dev,
4421 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4423 sdata->u.ap.multicast_to_unicast = enabled;
4428 void ieee80211_fill_txq_stats(struct cfg80211_txq_stats *txqstats,
4429 struct txq_info *txqi)
4431 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_BACKLOG_BYTES))) {
4432 txqstats->filled |= BIT(NL80211_TXQ_STATS_BACKLOG_BYTES);
4433 txqstats->backlog_bytes = txqi->tin.backlog_bytes;
4436 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_BACKLOG_PACKETS))) {
4437 txqstats->filled |= BIT(NL80211_TXQ_STATS_BACKLOG_PACKETS);
4438 txqstats->backlog_packets = txqi->tin.backlog_packets;
4441 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_FLOWS))) {
4442 txqstats->filled |= BIT(NL80211_TXQ_STATS_FLOWS);
4443 txqstats->flows = txqi->tin.flows;
4446 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_DROPS))) {
4447 txqstats->filled |= BIT(NL80211_TXQ_STATS_DROPS);
4448 txqstats->drops = txqi->cstats.drop_count;
4451 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_ECN_MARKS))) {
4452 txqstats->filled |= BIT(NL80211_TXQ_STATS_ECN_MARKS);
4453 txqstats->ecn_marks = txqi->cstats.ecn_mark;
4456 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_OVERLIMIT))) {
4457 txqstats->filled |= BIT(NL80211_TXQ_STATS_OVERLIMIT);
4458 txqstats->overlimit = txqi->tin.overlimit;
4461 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_COLLISIONS))) {
4462 txqstats->filled |= BIT(NL80211_TXQ_STATS_COLLISIONS);
4463 txqstats->collisions = txqi->tin.collisions;
4466 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_TX_BYTES))) {
4467 txqstats->filled |= BIT(NL80211_TXQ_STATS_TX_BYTES);
4468 txqstats->tx_bytes = txqi->tin.tx_bytes;
4471 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_TX_PACKETS))) {
4472 txqstats->filled |= BIT(NL80211_TXQ_STATS_TX_PACKETS);
4473 txqstats->tx_packets = txqi->tin.tx_packets;
4477 static int ieee80211_get_txq_stats(struct wiphy *wiphy,
4478 struct wireless_dev *wdev,
4479 struct cfg80211_txq_stats *txqstats)
4481 struct ieee80211_local *local = wiphy_priv(wiphy);
4482 struct ieee80211_sub_if_data *sdata;
4485 spin_lock_bh(&local->fq.lock);
4489 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
4490 if (!sdata->vif.txq) {
4494 ieee80211_fill_txq_stats(txqstats, to_txq_info(sdata->vif.txq));
4497 txqstats->filled |= BIT(NL80211_TXQ_STATS_BACKLOG_PACKETS) |
4498 BIT(NL80211_TXQ_STATS_BACKLOG_BYTES) |
4499 BIT(NL80211_TXQ_STATS_OVERLIMIT) |
4500 BIT(NL80211_TXQ_STATS_OVERMEMORY) |
4501 BIT(NL80211_TXQ_STATS_COLLISIONS) |
4502 BIT(NL80211_TXQ_STATS_MAX_FLOWS);
4503 txqstats->backlog_packets = local->fq.backlog;
4504 txqstats->backlog_bytes = local->fq.memory_usage;
4505 txqstats->overlimit = local->fq.overlimit;
4506 txqstats->overmemory = local->fq.overmemory;
4507 txqstats->collisions = local->fq.collisions;
4508 txqstats->max_flows = local->fq.flows_cnt;
4513 spin_unlock_bh(&local->fq.lock);
4519 ieee80211_get_ftm_responder_stats(struct wiphy *wiphy,
4520 struct net_device *dev,
4521 struct cfg80211_ftm_responder_stats *ftm_stats)
4523 struct ieee80211_local *local = wiphy_priv(wiphy);
4524 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4526 return drv_get_ftm_responder_stats(local, sdata, ftm_stats);
4530 ieee80211_start_pmsr(struct wiphy *wiphy, struct wireless_dev *dev,
4531 struct cfg80211_pmsr_request *request)
4533 struct ieee80211_local *local = wiphy_priv(wiphy);
4534 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(dev);
4536 return drv_start_pmsr(local, sdata, request);
4540 ieee80211_abort_pmsr(struct wiphy *wiphy, struct wireless_dev *dev,
4541 struct cfg80211_pmsr_request *request)
4543 struct ieee80211_local *local = wiphy_priv(wiphy);
4544 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(dev);
4546 return drv_abort_pmsr(local, sdata, request);
4549 static int ieee80211_set_tid_config(struct wiphy *wiphy,
4550 struct net_device *dev,
4551 struct cfg80211_tid_config *tid_conf)
4553 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4554 struct sta_info *sta;
4557 if (!sdata->local->ops->set_tid_config)
4560 if (!tid_conf->peer)
4561 return drv_set_tid_config(sdata->local, sdata, NULL, tid_conf);
4563 mutex_lock(&sdata->local->sta_mtx);
4564 sta = sta_info_get_bss(sdata, tid_conf->peer);
4566 mutex_unlock(&sdata->local->sta_mtx);
4570 ret = drv_set_tid_config(sdata->local, sdata, &sta->sta, tid_conf);
4571 mutex_unlock(&sdata->local->sta_mtx);
4576 static int ieee80211_reset_tid_config(struct wiphy *wiphy,
4577 struct net_device *dev,
4578 const u8 *peer, u8 tids)
4580 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4581 struct sta_info *sta;
4584 if (!sdata->local->ops->reset_tid_config)
4588 return drv_reset_tid_config(sdata->local, sdata, NULL, tids);
4590 mutex_lock(&sdata->local->sta_mtx);
4591 sta = sta_info_get_bss(sdata, peer);
4593 mutex_unlock(&sdata->local->sta_mtx);
4597 ret = drv_reset_tid_config(sdata->local, sdata, &sta->sta, tids);
4598 mutex_unlock(&sdata->local->sta_mtx);
4603 static int ieee80211_set_sar_specs(struct wiphy *wiphy,
4604 struct cfg80211_sar_specs *sar)
4606 struct ieee80211_local *local = wiphy_priv(wiphy);
4608 if (!local->ops->set_sar_specs)
4611 return local->ops->set_sar_specs(&local->hw, sar);
4615 ieee80211_set_after_color_change_beacon(struct ieee80211_sub_if_data *sdata,
4618 switch (sdata->vif.type) {
4619 case NL80211_IFTYPE_AP: {
4622 if (!sdata->deflink.u.ap.next_beacon)
4625 ret = ieee80211_assign_beacon(sdata, &sdata->deflink,
4626 sdata->deflink.u.ap.next_beacon,
4628 ieee80211_free_next_beacon(&sdata->deflink);
4645 ieee80211_set_color_change_beacon(struct ieee80211_sub_if_data *sdata,
4646 struct cfg80211_color_change_settings *params,
4649 struct ieee80211_color_change_settings color_change = {};
4652 switch (sdata->vif.type) {
4653 case NL80211_IFTYPE_AP:
4654 sdata->deflink.u.ap.next_beacon =
4655 cfg80211_beacon_dup(¶ms->beacon_next);
4656 if (!sdata->deflink.u.ap.next_beacon)
4659 if (params->count <= 1)
4662 color_change.counter_offset_beacon =
4663 params->counter_offset_beacon;
4664 color_change.counter_offset_presp =
4665 params->counter_offset_presp;
4666 color_change.count = params->count;
4668 err = ieee80211_assign_beacon(sdata, &sdata->deflink,
4669 ¶ms->beacon_color_change,
4670 NULL, &color_change);
4672 ieee80211_free_next_beacon(&sdata->deflink);
4685 ieee80211_color_change_bss_config_notify(struct ieee80211_sub_if_data *sdata,
4686 u8 color, int enable, u32 changed)
4688 sdata->vif.bss_conf.he_bss_color.color = color;
4689 sdata->vif.bss_conf.he_bss_color.enabled = enable;
4690 changed |= BSS_CHANGED_HE_BSS_COLOR;
4692 ieee80211_link_info_change_notify(sdata, &sdata->deflink, changed);
4694 if (!sdata->vif.bss_conf.nontransmitted && sdata->vif.mbssid_tx_vif) {
4695 struct ieee80211_sub_if_data *child;
4697 mutex_lock(&sdata->local->iflist_mtx);
4698 list_for_each_entry(child, &sdata->local->interfaces, list) {
4699 if (child != sdata && child->vif.mbssid_tx_vif == &sdata->vif) {
4700 child->vif.bss_conf.he_bss_color.color = color;
4701 child->vif.bss_conf.he_bss_color.enabled = enable;
4702 ieee80211_link_info_change_notify(child,
4704 BSS_CHANGED_HE_BSS_COLOR);
4707 mutex_unlock(&sdata->local->iflist_mtx);
4711 static int ieee80211_color_change_finalize(struct ieee80211_sub_if_data *sdata)
4713 struct ieee80211_local *local = sdata->local;
4717 sdata_assert_lock(sdata);
4718 lockdep_assert_held(&local->mtx);
4720 sdata->vif.bss_conf.color_change_active = false;
4722 err = ieee80211_set_after_color_change_beacon(sdata, &changed);
4724 cfg80211_color_change_aborted_notify(sdata->dev);
4728 ieee80211_color_change_bss_config_notify(sdata,
4729 sdata->vif.bss_conf.color_change_color,
4731 cfg80211_color_change_notify(sdata->dev);
4736 void ieee80211_color_change_finalize_work(struct work_struct *work)
4738 struct ieee80211_sub_if_data *sdata =
4739 container_of(work, struct ieee80211_sub_if_data,
4740 deflink.color_change_finalize_work);
4741 struct ieee80211_local *local = sdata->local;
4744 mutex_lock(&local->mtx);
4746 /* AP might have been stopped while waiting for the lock. */
4747 if (!sdata->vif.bss_conf.color_change_active)
4750 if (!ieee80211_sdata_running(sdata))
4753 ieee80211_color_change_finalize(sdata);
4756 mutex_unlock(&local->mtx);
4757 sdata_unlock(sdata);
4760 void ieee80211_color_collision_detection_work(struct work_struct *work)
4762 struct delayed_work *delayed_work = to_delayed_work(work);
4763 struct ieee80211_link_data *link =
4764 container_of(delayed_work, struct ieee80211_link_data,
4765 color_collision_detect_work);
4766 struct ieee80211_sub_if_data *sdata = link->sdata;
4769 cfg80211_obss_color_collision_notify(sdata->dev, link->color_bitmap);
4770 sdata_unlock(sdata);
4773 void ieee80211_color_change_finish(struct ieee80211_vif *vif)
4775 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
4777 ieee80211_queue_work(&sdata->local->hw,
4778 &sdata->deflink.color_change_finalize_work);
4780 EXPORT_SYMBOL_GPL(ieee80211_color_change_finish);
4783 ieee80211_obss_color_collision_notify(struct ieee80211_vif *vif,
4784 u64 color_bitmap, gfp_t gfp)
4786 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
4787 struct ieee80211_link_data *link = &sdata->deflink;
4789 if (sdata->vif.bss_conf.color_change_active || sdata->vif.bss_conf.csa_active)
4792 if (delayed_work_pending(&link->color_collision_detect_work))
4795 link->color_bitmap = color_bitmap;
4796 /* queue the color collision detection event every 500 ms in order to
4797 * avoid sending too much netlink messages to userspace.
4799 ieee80211_queue_delayed_work(&sdata->local->hw,
4800 &link->color_collision_detect_work,
4801 msecs_to_jiffies(500));
4803 EXPORT_SYMBOL_GPL(ieee80211_obss_color_collision_notify);
4806 ieee80211_color_change(struct wiphy *wiphy, struct net_device *dev,
4807 struct cfg80211_color_change_settings *params)
4809 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4810 struct ieee80211_local *local = sdata->local;
4814 sdata_assert_lock(sdata);
4816 if (sdata->vif.bss_conf.nontransmitted)
4819 mutex_lock(&local->mtx);
4821 /* don't allow another color change if one is already active or if csa
4824 if (sdata->vif.bss_conf.color_change_active || sdata->vif.bss_conf.csa_active) {
4829 err = ieee80211_set_color_change_beacon(sdata, params, &changed);
4833 sdata->vif.bss_conf.color_change_active = true;
4834 sdata->vif.bss_conf.color_change_color = params->color;
4836 cfg80211_color_change_started_notify(sdata->dev, params->count);
4839 ieee80211_color_change_bss_config_notify(sdata, 0, 0, changed);
4841 /* if the beacon didn't change, we can finalize immediately */
4842 ieee80211_color_change_finalize(sdata);
4845 mutex_unlock(&local->mtx);
4851 ieee80211_set_radar_background(struct wiphy *wiphy,
4852 struct cfg80211_chan_def *chandef)
4854 struct ieee80211_local *local = wiphy_priv(wiphy);
4856 if (!local->ops->set_radar_background)
4859 return local->ops->set_radar_background(&local->hw, chandef);
4862 static int ieee80211_add_intf_link(struct wiphy *wiphy,
4863 struct wireless_dev *wdev,
4864 unsigned int link_id)
4866 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
4868 if (wdev->use_4addr)
4871 return ieee80211_vif_set_links(sdata, wdev->valid_links);
4874 static void ieee80211_del_intf_link(struct wiphy *wiphy,
4875 struct wireless_dev *wdev,
4876 unsigned int link_id)
4878 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
4880 ieee80211_vif_set_links(sdata, wdev->valid_links);
4883 static int sta_add_link_station(struct ieee80211_local *local,
4884 struct ieee80211_sub_if_data *sdata,
4885 struct link_station_parameters *params)
4887 struct sta_info *sta;
4890 sta = sta_info_get_bss(sdata, params->mld_mac);
4894 if (!sta->sta.valid_links)
4897 if (sta->sta.valid_links & BIT(params->link_id))
4900 ret = ieee80211_sta_allocate_link(sta, params->link_id);
4904 ret = sta_link_apply_parameters(local, sta, true, params);
4906 ieee80211_sta_free_link(sta, params->link_id);
4910 /* ieee80211_sta_activate_link frees the link upon failure */
4911 return ieee80211_sta_activate_link(sta, params->link_id);
4915 ieee80211_add_link_station(struct wiphy *wiphy, struct net_device *dev,
4916 struct link_station_parameters *params)
4918 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4919 struct ieee80211_local *local = wiphy_priv(wiphy);
4922 mutex_lock(&sdata->local->sta_mtx);
4923 ret = sta_add_link_station(local, sdata, params);
4924 mutex_unlock(&sdata->local->sta_mtx);
4929 static int sta_mod_link_station(struct ieee80211_local *local,
4930 struct ieee80211_sub_if_data *sdata,
4931 struct link_station_parameters *params)
4933 struct sta_info *sta;
4935 sta = sta_info_get_bss(sdata, params->mld_mac);
4939 if (!(sta->sta.valid_links & BIT(params->link_id)))
4942 return sta_link_apply_parameters(local, sta, false, params);
4946 ieee80211_mod_link_station(struct wiphy *wiphy, struct net_device *dev,
4947 struct link_station_parameters *params)
4949 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4950 struct ieee80211_local *local = wiphy_priv(wiphy);
4953 mutex_lock(&sdata->local->sta_mtx);
4954 ret = sta_mod_link_station(local, sdata, params);
4955 mutex_unlock(&sdata->local->sta_mtx);
4960 static int sta_del_link_station(struct ieee80211_sub_if_data *sdata,
4961 struct link_station_del_parameters *params)
4963 struct sta_info *sta;
4965 sta = sta_info_get_bss(sdata, params->mld_mac);
4969 if (!(sta->sta.valid_links & BIT(params->link_id)))
4972 /* must not create a STA without links */
4973 if (sta->sta.valid_links == BIT(params->link_id))
4976 ieee80211_sta_remove_link(sta, params->link_id);
4982 ieee80211_del_link_station(struct wiphy *wiphy, struct net_device *dev,
4983 struct link_station_del_parameters *params)
4985 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4988 mutex_lock(&sdata->local->sta_mtx);
4989 ret = sta_del_link_station(sdata, params);
4990 mutex_unlock(&sdata->local->sta_mtx);
4995 static int ieee80211_set_hw_timestamp(struct wiphy *wiphy,
4996 struct net_device *dev,
4997 struct cfg80211_set_hw_timestamp *hwts)
4999 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
5000 struct ieee80211_local *local = sdata->local;
5002 if (!local->ops->set_hw_timestamp)
5005 if (!check_sdata_in_driver(sdata))
5008 return local->ops->set_hw_timestamp(&local->hw, &sdata->vif, hwts);
5011 const struct cfg80211_ops mac80211_config_ops = {
5012 .add_virtual_intf = ieee80211_add_iface,
5013 .del_virtual_intf = ieee80211_del_iface,
5014 .change_virtual_intf = ieee80211_change_iface,
5015 .start_p2p_device = ieee80211_start_p2p_device,
5016 .stop_p2p_device = ieee80211_stop_p2p_device,
5017 .add_key = ieee80211_add_key,
5018 .del_key = ieee80211_del_key,
5019 .get_key = ieee80211_get_key,
5020 .set_default_key = ieee80211_config_default_key,
5021 .set_default_mgmt_key = ieee80211_config_default_mgmt_key,
5022 .set_default_beacon_key = ieee80211_config_default_beacon_key,
5023 .start_ap = ieee80211_start_ap,
5024 .change_beacon = ieee80211_change_beacon,
5025 .stop_ap = ieee80211_stop_ap,
5026 .add_station = ieee80211_add_station,
5027 .del_station = ieee80211_del_station,
5028 .change_station = ieee80211_change_station,
5029 .get_station = ieee80211_get_station,
5030 .dump_station = ieee80211_dump_station,
5031 .dump_survey = ieee80211_dump_survey,
5032 #ifdef CONFIG_MAC80211_MESH
5033 .add_mpath = ieee80211_add_mpath,
5034 .del_mpath = ieee80211_del_mpath,
5035 .change_mpath = ieee80211_change_mpath,
5036 .get_mpath = ieee80211_get_mpath,
5037 .dump_mpath = ieee80211_dump_mpath,
5038 .get_mpp = ieee80211_get_mpp,
5039 .dump_mpp = ieee80211_dump_mpp,
5040 .update_mesh_config = ieee80211_update_mesh_config,
5041 .get_mesh_config = ieee80211_get_mesh_config,
5042 .join_mesh = ieee80211_join_mesh,
5043 .leave_mesh = ieee80211_leave_mesh,
5045 .join_ocb = ieee80211_join_ocb,
5046 .leave_ocb = ieee80211_leave_ocb,
5047 .change_bss = ieee80211_change_bss,
5048 .set_txq_params = ieee80211_set_txq_params,
5049 .set_monitor_channel = ieee80211_set_monitor_channel,
5050 .suspend = ieee80211_suspend,
5051 .resume = ieee80211_resume,
5052 .scan = ieee80211_scan,
5053 .abort_scan = ieee80211_abort_scan,
5054 .sched_scan_start = ieee80211_sched_scan_start,
5055 .sched_scan_stop = ieee80211_sched_scan_stop,
5056 .auth = ieee80211_auth,
5057 .assoc = ieee80211_assoc,
5058 .deauth = ieee80211_deauth,
5059 .disassoc = ieee80211_disassoc,
5060 .join_ibss = ieee80211_join_ibss,
5061 .leave_ibss = ieee80211_leave_ibss,
5062 .set_mcast_rate = ieee80211_set_mcast_rate,
5063 .set_wiphy_params = ieee80211_set_wiphy_params,
5064 .set_tx_power = ieee80211_set_tx_power,
5065 .get_tx_power = ieee80211_get_tx_power,
5066 .rfkill_poll = ieee80211_rfkill_poll,
5067 CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd)
5068 CFG80211_TESTMODE_DUMP(ieee80211_testmode_dump)
5069 .set_power_mgmt = ieee80211_set_power_mgmt,
5070 .set_bitrate_mask = ieee80211_set_bitrate_mask,
5071 .remain_on_channel = ieee80211_remain_on_channel,
5072 .cancel_remain_on_channel = ieee80211_cancel_remain_on_channel,
5073 .mgmt_tx = ieee80211_mgmt_tx,
5074 .mgmt_tx_cancel_wait = ieee80211_mgmt_tx_cancel_wait,
5075 .set_cqm_rssi_config = ieee80211_set_cqm_rssi_config,
5076 .set_cqm_rssi_range_config = ieee80211_set_cqm_rssi_range_config,
5077 .update_mgmt_frame_registrations =
5078 ieee80211_update_mgmt_frame_registrations,
5079 .set_antenna = ieee80211_set_antenna,
5080 .get_antenna = ieee80211_get_antenna,
5081 .set_rekey_data = ieee80211_set_rekey_data,
5082 .tdls_oper = ieee80211_tdls_oper,
5083 .tdls_mgmt = ieee80211_tdls_mgmt,
5084 .tdls_channel_switch = ieee80211_tdls_channel_switch,
5085 .tdls_cancel_channel_switch = ieee80211_tdls_cancel_channel_switch,
5086 .probe_client = ieee80211_probe_client,
5087 .set_noack_map = ieee80211_set_noack_map,
5089 .set_wakeup = ieee80211_set_wakeup,
5091 .get_channel = ieee80211_cfg_get_channel,
5092 .start_radar_detection = ieee80211_start_radar_detection,
5093 .end_cac = ieee80211_end_cac,
5094 .channel_switch = ieee80211_channel_switch,
5095 .set_qos_map = ieee80211_set_qos_map,
5096 .set_ap_chanwidth = ieee80211_set_ap_chanwidth,
5097 .add_tx_ts = ieee80211_add_tx_ts,
5098 .del_tx_ts = ieee80211_del_tx_ts,
5099 .start_nan = ieee80211_start_nan,
5100 .stop_nan = ieee80211_stop_nan,
5101 .nan_change_conf = ieee80211_nan_change_conf,
5102 .add_nan_func = ieee80211_add_nan_func,
5103 .del_nan_func = ieee80211_del_nan_func,
5104 .set_multicast_to_unicast = ieee80211_set_multicast_to_unicast,
5105 .tx_control_port = ieee80211_tx_control_port,
5106 .get_txq_stats = ieee80211_get_txq_stats,
5107 .get_ftm_responder_stats = ieee80211_get_ftm_responder_stats,
5108 .start_pmsr = ieee80211_start_pmsr,
5109 .abort_pmsr = ieee80211_abort_pmsr,
5110 .probe_mesh_link = ieee80211_probe_mesh_link,
5111 .set_tid_config = ieee80211_set_tid_config,
5112 .reset_tid_config = ieee80211_reset_tid_config,
5113 .set_sar_specs = ieee80211_set_sar_specs,
5114 .color_change = ieee80211_color_change,
5115 .set_radar_background = ieee80211_set_radar_background,
5116 .add_intf_link = ieee80211_add_intf_link,
5117 .del_intf_link = ieee80211_del_intf_link,
5118 .add_link_station = ieee80211_add_link_station,
5119 .mod_link_station = ieee80211_mod_link_station,
5120 .del_link_station = ieee80211_del_link_station,
5121 .set_hw_timestamp = ieee80211_set_hw_timestamp,