1 // SPDX-License-Identifier: GPL-2.0-only
3 * mac80211 configuration hooks for cfg80211
5 * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
6 * Copyright 2013-2015 Intel Mobile Communications GmbH
7 * Copyright (C) 2015-2017 Intel Deutschland GmbH
8 * Copyright (C) 2018-2022 Intel Corporation
11 #include <linux/ieee80211.h>
12 #include <linux/nl80211.h>
13 #include <linux/rtnetlink.h>
14 #include <linux/slab.h>
15 #include <net/net_namespace.h>
16 #include <linux/rcupdate.h>
17 #include <linux/fips.h>
18 #include <linux/if_ether.h>
19 #include <net/cfg80211.h>
20 #include "ieee80211_i.h"
21 #include "driver-ops.h"
26 static struct ieee80211_link_data *
27 ieee80211_link_or_deflink(struct ieee80211_sub_if_data *sdata, int link_id,
30 struct ieee80211_link_data *link;
34 * For keys, if sdata is not an MLD, we might not use
35 * the return value at all (if it's not a pairwise key),
36 * so in that case (require_valid==false) don't error.
38 if (require_valid && ieee80211_vif_is_mld(&sdata->vif))
39 return ERR_PTR(-EINVAL);
41 return &sdata->deflink;
44 link = sdata_dereference(sdata->link[link_id], sdata);
46 return ERR_PTR(-ENOLINK);
50 static void ieee80211_set_mu_mimo_follow(struct ieee80211_sub_if_data *sdata,
51 struct vif_params *params)
53 bool mu_mimo_groups = false;
54 bool mu_mimo_follow = false;
56 if (params->vht_mumimo_groups) {
59 BUILD_BUG_ON(sizeof(membership) != WLAN_MEMBERSHIP_LEN);
61 memcpy(sdata->vif.bss_conf.mu_group.membership,
62 params->vht_mumimo_groups, WLAN_MEMBERSHIP_LEN);
63 memcpy(sdata->vif.bss_conf.mu_group.position,
64 params->vht_mumimo_groups + WLAN_MEMBERSHIP_LEN,
65 WLAN_USER_POSITION_LEN);
66 ieee80211_link_info_change_notify(sdata, &sdata->deflink,
67 BSS_CHANGED_MU_GROUPS);
68 /* don't care about endianness - just check for 0 */
69 memcpy(&membership, params->vht_mumimo_groups,
71 mu_mimo_groups = membership != 0;
74 if (params->vht_mumimo_follow_addr) {
76 is_valid_ether_addr(params->vht_mumimo_follow_addr);
77 ether_addr_copy(sdata->u.mntr.mu_follow_addr,
78 params->vht_mumimo_follow_addr);
81 sdata->vif.bss_conf.mu_mimo_owner = mu_mimo_groups || mu_mimo_follow;
84 static int ieee80211_set_mon_options(struct ieee80211_sub_if_data *sdata,
85 struct vif_params *params)
87 struct ieee80211_local *local = sdata->local;
88 struct ieee80211_sub_if_data *monitor_sdata;
90 /* check flags first */
91 if (params->flags && ieee80211_sdata_running(sdata)) {
92 u32 mask = MONITOR_FLAG_COOK_FRAMES | MONITOR_FLAG_ACTIVE;
95 * Prohibit MONITOR_FLAG_COOK_FRAMES and
96 * MONITOR_FLAG_ACTIVE to be changed while the
98 * Else we would need to add a lot of cruft
99 * to update everything:
100 * cooked_mntrs, monitor and all fif_* counters
101 * reconfigure hardware
103 if ((params->flags & mask) != (sdata->u.mntr.flags & mask))
107 /* also validate MU-MIMO change */
108 monitor_sdata = wiphy_dereference(local->hw.wiphy,
109 local->monitor_sdata);
111 if (!monitor_sdata &&
112 (params->vht_mumimo_groups || params->vht_mumimo_follow_addr))
115 /* apply all changes now - no failures allowed */
118 ieee80211_set_mu_mimo_follow(monitor_sdata, params);
121 if (ieee80211_sdata_running(sdata)) {
122 ieee80211_adjust_monitor_flags(sdata, -1);
123 sdata->u.mntr.flags = params->flags;
124 ieee80211_adjust_monitor_flags(sdata, 1);
126 ieee80211_configure_filter(local);
129 * Because the interface is down, ieee80211_do_stop
130 * and ieee80211_do_open take care of "everything"
131 * mentioned in the comment above.
133 sdata->u.mntr.flags = params->flags;
140 static int ieee80211_set_ap_mbssid_options(struct ieee80211_sub_if_data *sdata,
141 struct cfg80211_mbssid_config params,
142 struct ieee80211_bss_conf *link_conf)
144 struct ieee80211_sub_if_data *tx_sdata;
146 sdata->vif.mbssid_tx_vif = NULL;
147 link_conf->bssid_index = 0;
148 link_conf->nontransmitted = false;
149 link_conf->ema_ap = false;
150 link_conf->bssid_indicator = 0;
152 if (sdata->vif.type != NL80211_IFTYPE_AP || !params.tx_wdev)
155 tx_sdata = IEEE80211_WDEV_TO_SUB_IF(params.tx_wdev);
159 if (tx_sdata == sdata) {
160 sdata->vif.mbssid_tx_vif = &sdata->vif;
162 sdata->vif.mbssid_tx_vif = &tx_sdata->vif;
163 link_conf->nontransmitted = true;
164 link_conf->bssid_index = params.index;
167 link_conf->ema_ap = true;
172 static struct wireless_dev *ieee80211_add_iface(struct wiphy *wiphy,
174 unsigned char name_assign_type,
175 enum nl80211_iftype type,
176 struct vif_params *params)
178 struct ieee80211_local *local = wiphy_priv(wiphy);
179 struct wireless_dev *wdev;
180 struct ieee80211_sub_if_data *sdata;
183 err = ieee80211_if_add(local, name, name_assign_type, &wdev, type, params);
187 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
189 if (type == NL80211_IFTYPE_MONITOR) {
190 err = ieee80211_set_mon_options(sdata, params);
192 ieee80211_if_remove(sdata);
200 static int ieee80211_del_iface(struct wiphy *wiphy, struct wireless_dev *wdev)
202 ieee80211_if_remove(IEEE80211_WDEV_TO_SUB_IF(wdev));
207 static int ieee80211_change_iface(struct wiphy *wiphy,
208 struct net_device *dev,
209 enum nl80211_iftype type,
210 struct vif_params *params)
212 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
213 struct ieee80211_local *local = sdata->local;
214 struct sta_info *sta;
217 lockdep_assert_wiphy(local->hw.wiphy);
219 ret = ieee80211_if_change_type(sdata, type);
223 if (type == NL80211_IFTYPE_AP_VLAN && params->use_4addr == 0) {
224 RCU_INIT_POINTER(sdata->u.vlan.sta, NULL);
225 ieee80211_check_fast_rx_iface(sdata);
226 } else if (type == NL80211_IFTYPE_STATION && params->use_4addr >= 0) {
227 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
229 if (params->use_4addr == ifmgd->use_4addr)
232 /* FIXME: no support for 4-addr MLO yet */
233 if (ieee80211_vif_is_mld(&sdata->vif))
236 sdata->u.mgd.use_4addr = params->use_4addr;
237 if (!ifmgd->associated)
240 sta = sta_info_get(sdata, sdata->deflink.u.mgd.bssid);
242 drv_sta_set_4addr(local, sdata, &sta->sta,
245 if (params->use_4addr)
246 ieee80211_send_4addr_nullfunc(local, sdata);
249 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) {
250 ret = ieee80211_set_mon_options(sdata, params);
258 static int ieee80211_start_p2p_device(struct wiphy *wiphy,
259 struct wireless_dev *wdev)
261 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
264 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 key = wiphy_dereference(local->hw.wiphy, sta->ptk[key_idx]);
457 if (key && key->conf.flags & IEEE80211_KEY_FLAG_NO_AUTO_TX)
458 ret = ieee80211_set_tx_key(key);
463 static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
464 int link_id, u8 key_idx, bool pairwise,
465 const u8 *mac_addr, struct key_params *params)
467 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
468 struct ieee80211_link_data *link =
469 ieee80211_link_or_deflink(sdata, link_id, false);
470 struct ieee80211_local *local = sdata->local;
471 struct sta_info *sta = NULL;
472 struct ieee80211_key *key;
474 lockdep_assert_wiphy(local->hw.wiphy);
476 if (!ieee80211_sdata_running(sdata))
480 return PTR_ERR(link);
482 if (pairwise && params->mode == NL80211_KEY_SET_TX)
483 return ieee80211_set_tx(sdata, mac_addr, key_idx);
485 /* reject WEP and TKIP keys if WEP failed to initialize */
486 switch (params->cipher) {
487 case WLAN_CIPHER_SUITE_WEP40:
488 case WLAN_CIPHER_SUITE_TKIP:
489 case WLAN_CIPHER_SUITE_WEP104:
492 if (WARN_ON_ONCE(fips_enabled))
499 key = ieee80211_key_alloc(params->cipher, key_idx, params->key_len,
500 params->key, params->seq_len, params->seq);
504 key->conf.link_id = link_id;
507 key->conf.flags |= IEEE80211_KEY_FLAG_PAIRWISE;
509 if (params->mode == NL80211_KEY_NO_TX)
510 key->conf.flags |= IEEE80211_KEY_FLAG_NO_AUTO_TX;
513 sta = sta_info_get_bss(sdata, mac_addr);
515 * The ASSOC test makes sure the driver is ready to
516 * receive the key. When wpa_supplicant has roamed
517 * using FT, it attempts to set the key before
518 * association has completed, this rejects that attempt
519 * so it will set the key again after association.
521 * TODO: accept the key if we have a station entry and
522 * add it to the device after the station.
524 if (!sta || !test_sta_flag(sta, WLAN_STA_ASSOC)) {
525 ieee80211_key_free_unused(key);
530 switch (sdata->vif.type) {
531 case NL80211_IFTYPE_STATION:
532 if (sdata->u.mgd.mfp != IEEE80211_MFP_DISABLED)
533 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
535 case NL80211_IFTYPE_AP:
536 case NL80211_IFTYPE_AP_VLAN:
537 /* Keys without a station are used for TX only */
538 if (sta && test_sta_flag(sta, WLAN_STA_MFP))
539 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
541 case NL80211_IFTYPE_ADHOC:
544 case NL80211_IFTYPE_MESH_POINT:
545 #ifdef CONFIG_MAC80211_MESH
546 if (sdata->u.mesh.security != IEEE80211_MESH_SEC_NONE)
547 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
550 case NL80211_IFTYPE_WDS:
551 case NL80211_IFTYPE_MONITOR:
552 case NL80211_IFTYPE_P2P_DEVICE:
553 case NL80211_IFTYPE_NAN:
554 case NL80211_IFTYPE_UNSPECIFIED:
555 case NUM_NL80211_IFTYPES:
556 case NL80211_IFTYPE_P2P_CLIENT:
557 case NL80211_IFTYPE_P2P_GO:
558 case NL80211_IFTYPE_OCB:
559 /* shouldn't happen */
564 return ieee80211_key_link(key, link, sta);
567 static struct ieee80211_key *
568 ieee80211_lookup_key(struct ieee80211_sub_if_data *sdata, int link_id,
569 u8 key_idx, bool pairwise, const u8 *mac_addr)
571 struct ieee80211_local *local __maybe_unused = sdata->local;
572 struct ieee80211_link_data *link = &sdata->deflink;
573 struct ieee80211_key *key;
576 link = rcu_dereference_check(sdata->link[link_id],
577 lockdep_is_held(&sdata->wdev.mtx));
583 struct sta_info *sta;
584 struct link_sta_info *link_sta;
586 sta = sta_info_get_bss(sdata, mac_addr);
591 link_sta = rcu_dereference_check(sta->link[link_id],
592 lockdep_is_held(&local->hw.wiphy->mtx));
596 link_sta = &sta->deflink;
599 if (pairwise && key_idx < NUM_DEFAULT_KEYS)
600 return wiphy_dereference(local->hw.wiphy,
604 key_idx < NUM_DEFAULT_KEYS +
605 NUM_DEFAULT_MGMT_KEYS +
606 NUM_DEFAULT_BEACON_KEYS)
607 return wiphy_dereference(local->hw.wiphy,
608 link_sta->gtk[key_idx]);
613 if (pairwise && key_idx < NUM_DEFAULT_KEYS)
614 return wiphy_dereference(local->hw.wiphy, sdata->keys[key_idx]);
616 key = wiphy_dereference(local->hw.wiphy, link->gtk[key_idx]);
620 /* or maybe it was a WEP key */
621 if (key_idx < NUM_DEFAULT_KEYS)
622 return wiphy_dereference(local->hw.wiphy, sdata->keys[key_idx]);
627 static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
628 int link_id, u8 key_idx, bool pairwise,
631 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
632 struct ieee80211_local *local = sdata->local;
633 struct ieee80211_key *key;
635 lockdep_assert_wiphy(local->hw.wiphy);
637 key = ieee80211_lookup_key(sdata, link_id, key_idx, pairwise, mac_addr);
641 ieee80211_key_free(key, sdata->vif.type == NL80211_IFTYPE_STATION);
646 static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
647 int link_id, u8 key_idx, bool pairwise,
648 const u8 *mac_addr, void *cookie,
649 void (*callback)(void *cookie,
650 struct key_params *params))
652 struct ieee80211_sub_if_data *sdata;
654 struct key_params params;
655 struct ieee80211_key *key;
660 struct ieee80211_key_seq kseq = {};
662 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
666 key = ieee80211_lookup_key(sdata, link_id, key_idx, pairwise, mac_addr);
670 memset(¶ms, 0, sizeof(params));
672 params.cipher = key->conf.cipher;
674 switch (key->conf.cipher) {
675 case WLAN_CIPHER_SUITE_TKIP:
676 pn64 = atomic64_read(&key->conf.tx_pn);
677 iv32 = TKIP_PN_TO_IV32(pn64);
678 iv16 = TKIP_PN_TO_IV16(pn64);
680 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE &&
681 !(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
682 drv_get_key_seq(sdata->local, key, &kseq);
683 iv32 = kseq.tkip.iv32;
684 iv16 = kseq.tkip.iv16;
687 seq[0] = iv16 & 0xff;
688 seq[1] = (iv16 >> 8) & 0xff;
689 seq[2] = iv32 & 0xff;
690 seq[3] = (iv32 >> 8) & 0xff;
691 seq[4] = (iv32 >> 16) & 0xff;
692 seq[5] = (iv32 >> 24) & 0xff;
696 case WLAN_CIPHER_SUITE_CCMP:
697 case WLAN_CIPHER_SUITE_CCMP_256:
698 case WLAN_CIPHER_SUITE_AES_CMAC:
699 case WLAN_CIPHER_SUITE_BIP_CMAC_256:
700 BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
701 offsetof(typeof(kseq), aes_cmac));
703 case WLAN_CIPHER_SUITE_BIP_GMAC_128:
704 case WLAN_CIPHER_SUITE_BIP_GMAC_256:
705 BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
706 offsetof(typeof(kseq), aes_gmac));
708 case WLAN_CIPHER_SUITE_GCMP:
709 case WLAN_CIPHER_SUITE_GCMP_256:
710 BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
711 offsetof(typeof(kseq), gcmp));
713 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE &&
714 !(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
715 drv_get_key_seq(sdata->local, key, &kseq);
716 memcpy(seq, kseq.ccmp.pn, 6);
718 pn64 = atomic64_read(&key->conf.tx_pn);
730 if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
732 if (WARN_ON(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV))
734 drv_get_key_seq(sdata->local, key, &kseq);
735 params.seq = kseq.hw.seq;
736 params.seq_len = kseq.hw.seq_len;
740 params.key = key->conf.key;
741 params.key_len = key->conf.keylen;
743 callback(cookie, ¶ms);
751 static int ieee80211_config_default_key(struct wiphy *wiphy,
752 struct net_device *dev,
753 int link_id, u8 key_idx, bool uni,
756 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
757 struct ieee80211_link_data *link =
758 ieee80211_link_or_deflink(sdata, link_id, false);
761 return PTR_ERR(link);
763 ieee80211_set_default_key(link, key_idx, uni, multi);
768 static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy,
769 struct net_device *dev,
770 int link_id, u8 key_idx)
772 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
773 struct ieee80211_link_data *link =
774 ieee80211_link_or_deflink(sdata, link_id, true);
777 return PTR_ERR(link);
779 ieee80211_set_default_mgmt_key(link, key_idx);
784 static int ieee80211_config_default_beacon_key(struct wiphy *wiphy,
785 struct net_device *dev,
786 int link_id, u8 key_idx)
788 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
789 struct ieee80211_link_data *link =
790 ieee80211_link_or_deflink(sdata, link_id, true);
793 return PTR_ERR(link);
795 ieee80211_set_default_beacon_key(link, key_idx);
800 void sta_set_rate_info_tx(struct sta_info *sta,
801 const struct ieee80211_tx_rate *rate,
802 struct rate_info *rinfo)
805 if (rate->flags & IEEE80211_TX_RC_MCS) {
806 rinfo->flags |= RATE_INFO_FLAGS_MCS;
807 rinfo->mcs = rate->idx;
808 } else if (rate->flags & IEEE80211_TX_RC_VHT_MCS) {
809 rinfo->flags |= RATE_INFO_FLAGS_VHT_MCS;
810 rinfo->mcs = ieee80211_rate_get_vht_mcs(rate);
811 rinfo->nss = ieee80211_rate_get_vht_nss(rate);
813 struct ieee80211_supported_band *sband;
814 int shift = ieee80211_vif_get_shift(&sta->sdata->vif);
817 sband = ieee80211_get_sband(sta->sdata);
818 WARN_ON_ONCE(sband && !sband->bitrates);
819 if (sband && sband->bitrates) {
820 brate = sband->bitrates[rate->idx].bitrate;
821 rinfo->legacy = DIV_ROUND_UP(brate, 1 << shift);
824 if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
825 rinfo->bw = RATE_INFO_BW_40;
826 else if (rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH)
827 rinfo->bw = RATE_INFO_BW_80;
828 else if (rate->flags & IEEE80211_TX_RC_160_MHZ_WIDTH)
829 rinfo->bw = RATE_INFO_BW_160;
831 rinfo->bw = RATE_INFO_BW_20;
832 if (rate->flags & IEEE80211_TX_RC_SHORT_GI)
833 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI;
836 static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev,
837 int idx, u8 *mac, struct station_info *sinfo)
839 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
840 struct ieee80211_local *local = sdata->local;
841 struct sta_info *sta;
844 lockdep_assert_wiphy(local->hw.wiphy);
846 sta = sta_info_get_by_idx(sdata, idx);
849 memcpy(mac, sta->sta.addr, ETH_ALEN);
850 sta_set_sinfo(sta, sinfo, true);
856 static int ieee80211_dump_survey(struct wiphy *wiphy, struct net_device *dev,
857 int idx, struct survey_info *survey)
859 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
861 return drv_get_survey(local, idx, survey);
864 static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev,
865 const u8 *mac, struct station_info *sinfo)
867 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
868 struct ieee80211_local *local = sdata->local;
869 struct sta_info *sta;
872 lockdep_assert_wiphy(local->hw.wiphy);
874 sta = sta_info_get_bss(sdata, mac);
877 sta_set_sinfo(sta, sinfo, true);
883 static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
884 struct cfg80211_chan_def *chandef)
886 struct ieee80211_local *local = wiphy_priv(wiphy);
887 struct ieee80211_sub_if_data *sdata;
890 if (cfg80211_chandef_identical(&local->monitor_chandef, chandef))
893 if (local->use_chanctx) {
894 sdata = wiphy_dereference(local->hw.wiphy,
895 local->monitor_sdata);
898 mutex_lock(&local->mtx);
899 ieee80211_link_release_channel(&sdata->deflink);
900 ret = ieee80211_link_use_channel(&sdata->deflink,
902 IEEE80211_CHANCTX_EXCLUSIVE);
903 mutex_unlock(&local->mtx);
907 mutex_lock(&local->mtx);
908 if (local->open_count == local->monitors) {
909 local->_oper_chandef = *chandef;
910 ieee80211_hw_config(local, 0);
912 mutex_unlock(&local->mtx);
916 local->monitor_chandef = *chandef;
922 ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata,
923 const u8 *resp, size_t resp_len,
924 const struct ieee80211_csa_settings *csa,
925 const struct ieee80211_color_change_settings *cca,
926 struct ieee80211_link_data *link)
928 struct probe_resp *new, *old;
930 if (!resp || !resp_len)
933 old = sdata_dereference(link->u.ap.probe_resp, sdata);
935 new = kzalloc(sizeof(struct probe_resp) + resp_len, GFP_KERNEL);
940 memcpy(new->data, resp, resp_len);
943 memcpy(new->cntdwn_counter_offsets, csa->counter_offsets_presp,
944 csa->n_counter_offsets_presp *
945 sizeof(new->cntdwn_counter_offsets[0]));
947 new->cntdwn_counter_offsets[0] = cca->counter_offset_presp;
949 rcu_assign_pointer(link->u.ap.probe_resp, new);
951 kfree_rcu(old, rcu_head);
956 static int ieee80211_set_fils_discovery(struct ieee80211_sub_if_data *sdata,
957 struct cfg80211_fils_discovery *params,
958 struct ieee80211_link_data *link,
959 struct ieee80211_bss_conf *link_conf)
961 struct fils_discovery_data *new, *old = NULL;
962 struct ieee80211_fils_discovery *fd;
964 if (!params->tmpl || !params->tmpl_len)
967 fd = &link_conf->fils_discovery;
968 fd->min_interval = params->min_interval;
969 fd->max_interval = params->max_interval;
971 old = sdata_dereference(link->u.ap.fils_discovery, sdata);
972 new = kzalloc(sizeof(*new) + params->tmpl_len, GFP_KERNEL);
975 new->len = params->tmpl_len;
976 memcpy(new->data, params->tmpl, params->tmpl_len);
977 rcu_assign_pointer(link->u.ap.fils_discovery, new);
980 kfree_rcu(old, rcu_head);
986 ieee80211_set_unsol_bcast_probe_resp(struct ieee80211_sub_if_data *sdata,
987 struct cfg80211_unsol_bcast_probe_resp *params,
988 struct ieee80211_link_data *link,
989 struct ieee80211_bss_conf *link_conf)
991 struct unsol_bcast_probe_resp_data *new, *old = NULL;
993 if (!params->tmpl || !params->tmpl_len)
996 old = sdata_dereference(link->u.ap.unsol_bcast_probe_resp, sdata);
997 new = kzalloc(sizeof(*new) + params->tmpl_len, GFP_KERNEL);
1000 new->len = params->tmpl_len;
1001 memcpy(new->data, params->tmpl, params->tmpl_len);
1002 rcu_assign_pointer(link->u.ap.unsol_bcast_probe_resp, new);
1005 kfree_rcu(old, rcu_head);
1007 link_conf->unsol_bcast_probe_resp_interval = params->interval;
1012 static int ieee80211_set_ftm_responder_params(
1013 struct ieee80211_sub_if_data *sdata,
1014 const u8 *lci, size_t lci_len,
1015 const u8 *civicloc, size_t civicloc_len,
1016 struct ieee80211_bss_conf *link_conf)
1018 struct ieee80211_ftm_responder_params *new, *old;
1022 if (!lci_len && !civicloc_len)
1025 old = link_conf->ftmr_params;
1026 len = lci_len + civicloc_len;
1028 new = kzalloc(sizeof(*new) + len, GFP_KERNEL);
1032 pos = (u8 *)(new + 1);
1034 new->lci_len = lci_len;
1036 memcpy(pos, lci, lci_len);
1041 new->civicloc_len = civicloc_len;
1042 new->civicloc = pos;
1043 memcpy(pos, civicloc, civicloc_len);
1044 pos += civicloc_len;
1047 link_conf->ftmr_params = new;
1054 ieee80211_copy_mbssid_beacon(u8 *pos, struct cfg80211_mbssid_elems *dst,
1055 struct cfg80211_mbssid_elems *src)
1059 for (i = 0; i < src->cnt; i++) {
1060 memcpy(pos + offset, src->elem[i].data, src->elem[i].len);
1061 dst->elem[i].len = src->elem[i].len;
1062 dst->elem[i].data = pos + offset;
1063 offset += dst->elem[i].len;
1065 dst->cnt = src->cnt;
1071 ieee80211_copy_rnr_beacon(u8 *pos, struct cfg80211_rnr_elems *dst,
1072 struct cfg80211_rnr_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_assign_beacon(struct ieee80211_sub_if_data *sdata,
1089 struct ieee80211_link_data *link,
1090 struct cfg80211_beacon_data *params,
1091 const struct ieee80211_csa_settings *csa,
1092 const struct ieee80211_color_change_settings *cca,
1095 struct cfg80211_mbssid_elems *mbssid = NULL;
1096 struct cfg80211_rnr_elems *rnr = NULL;
1097 struct beacon_data *new, *old;
1098 int new_head_len, new_tail_len;
1100 u64 _changed = BSS_CHANGED_BEACON;
1101 struct ieee80211_bss_conf *link_conf = link->conf;
1103 old = sdata_dereference(link->u.ap.beacon, sdata);
1105 /* Need to have a beacon head if we don't have one yet */
1106 if (!params->head && !old)
1109 /* new or old head? */
1111 new_head_len = params->head_len;
1113 new_head_len = old->head_len;
1115 /* new or old tail? */
1116 if (params->tail || !old)
1117 /* params->tail_len will be zero for !params->tail */
1118 new_tail_len = params->tail_len;
1120 new_tail_len = old->tail_len;
1122 size = sizeof(*new) + new_head_len + new_tail_len;
1124 /* new or old multiple BSSID elements? */
1125 if (params->mbssid_ies) {
1126 mbssid = params->mbssid_ies;
1127 size += struct_size(new->mbssid_ies, elem, mbssid->cnt);
1128 if (params->rnr_ies) {
1129 rnr = params->rnr_ies;
1130 size += struct_size(new->rnr_ies, elem, rnr->cnt);
1132 size += ieee80211_get_mbssid_beacon_len(mbssid, rnr,
1134 } else if (old && old->mbssid_ies) {
1135 mbssid = old->mbssid_ies;
1136 size += struct_size(new->mbssid_ies, elem, mbssid->cnt);
1137 if (old && old->rnr_ies) {
1139 size += struct_size(new->rnr_ies, elem, rnr->cnt);
1141 size += ieee80211_get_mbssid_beacon_len(mbssid, rnr,
1145 new = kzalloc(size, GFP_KERNEL);
1149 /* start filling the new info now */
1152 * pointers go into the block we allocated,
1153 * memory is | beacon_data | head | tail | mbssid_ies | rnr_ies
1155 new->head = ((u8 *) new) + sizeof(*new);
1156 new->tail = new->head + new_head_len;
1157 new->head_len = new_head_len;
1158 new->tail_len = new_tail_len;
1159 /* copy in optional mbssid_ies */
1161 u8 *pos = new->tail + new->tail_len;
1163 new->mbssid_ies = (void *)pos;
1164 pos += struct_size(new->mbssid_ies, elem, mbssid->cnt);
1165 pos += ieee80211_copy_mbssid_beacon(pos, new->mbssid_ies,
1168 new->rnr_ies = (void *)pos;
1169 pos += struct_size(new->rnr_ies, elem, rnr->cnt);
1170 ieee80211_copy_rnr_beacon(pos, new->rnr_ies, rnr);
1172 /* update bssid_indicator */
1173 link_conf->bssid_indicator =
1174 ilog2(__roundup_pow_of_two(mbssid->cnt + 1));
1178 new->cntdwn_current_counter = csa->count;
1179 memcpy(new->cntdwn_counter_offsets, csa->counter_offsets_beacon,
1180 csa->n_counter_offsets_beacon *
1181 sizeof(new->cntdwn_counter_offsets[0]));
1183 new->cntdwn_current_counter = cca->count;
1184 new->cntdwn_counter_offsets[0] = cca->counter_offset_beacon;
1189 memcpy(new->head, params->head, new_head_len);
1191 memcpy(new->head, old->head, new_head_len);
1193 /* copy in optional tail */
1195 memcpy(new->tail, params->tail, new_tail_len);
1198 memcpy(new->tail, old->tail, new_tail_len);
1200 err = ieee80211_set_probe_resp(sdata, params->probe_resp,
1201 params->probe_resp_len, csa, cca, link);
1207 _changed |= BSS_CHANGED_AP_PROBE_RESP;
1209 if (params->ftm_responder != -1) {
1210 link_conf->ftm_responder = params->ftm_responder;
1211 err = ieee80211_set_ftm_responder_params(sdata,
1215 params->civicloc_len,
1223 _changed |= BSS_CHANGED_FTM_RESPONDER;
1226 rcu_assign_pointer(link->u.ap.beacon, new);
1227 sdata->u.ap.active = true;
1230 kfree_rcu(old, rcu_head);
1232 *changed |= _changed;
1236 static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
1237 struct cfg80211_ap_settings *params)
1239 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1240 struct ieee80211_local *local = sdata->local;
1241 struct beacon_data *old;
1242 struct ieee80211_sub_if_data *vlan;
1243 u64 changed = BSS_CHANGED_BEACON_INT |
1244 BSS_CHANGED_BEACON_ENABLED |
1245 BSS_CHANGED_BEACON |
1246 BSS_CHANGED_P2P_PS |
1247 BSS_CHANGED_TXPOWER |
1250 int prev_beacon_int;
1251 unsigned int link_id = params->beacon.link_id;
1252 struct ieee80211_link_data *link;
1253 struct ieee80211_bss_conf *link_conf;
1255 link = sdata_dereference(sdata->link[link_id], sdata);
1259 link_conf = link->conf;
1261 old = sdata_dereference(link->u.ap.beacon, sdata);
1265 if (params->smps_mode != NL80211_SMPS_OFF)
1268 link->smps_mode = IEEE80211_SMPS_OFF;
1270 link->needed_rx_chains = sdata->local->rx_chains;
1272 prev_beacon_int = link_conf->beacon_int;
1273 link_conf->beacon_int = params->beacon_interval;
1276 link_conf->ht_ldpc =
1277 params->ht_cap->cap_info &
1278 cpu_to_le16(IEEE80211_HT_CAP_LDPC_CODING);
1280 if (params->vht_cap) {
1281 link_conf->vht_ldpc =
1282 params->vht_cap->vht_cap_info &
1283 cpu_to_le32(IEEE80211_VHT_CAP_RXLDPC);
1284 link_conf->vht_su_beamformer =
1285 params->vht_cap->vht_cap_info &
1286 cpu_to_le32(IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE);
1287 link_conf->vht_su_beamformee =
1288 params->vht_cap->vht_cap_info &
1289 cpu_to_le32(IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE);
1290 link_conf->vht_mu_beamformer =
1291 params->vht_cap->vht_cap_info &
1292 cpu_to_le32(IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE);
1293 link_conf->vht_mu_beamformee =
1294 params->vht_cap->vht_cap_info &
1295 cpu_to_le32(IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE);
1298 if (params->he_cap && params->he_oper) {
1299 link_conf->he_support = true;
1300 link_conf->htc_trig_based_pkt_ext =
1301 le32_get_bits(params->he_oper->he_oper_params,
1302 IEEE80211_HE_OPERATION_DFLT_PE_DURATION_MASK);
1303 link_conf->frame_time_rts_th =
1304 le32_get_bits(params->he_oper->he_oper_params,
1305 IEEE80211_HE_OPERATION_RTS_THRESHOLD_MASK);
1306 changed |= BSS_CHANGED_HE_OBSS_PD;
1308 if (params->beacon.he_bss_color.enabled)
1309 changed |= BSS_CHANGED_HE_BSS_COLOR;
1312 if (params->he_cap) {
1313 link_conf->he_ldpc =
1314 params->he_cap->phy_cap_info[1] &
1315 IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD;
1316 link_conf->he_su_beamformer =
1317 params->he_cap->phy_cap_info[3] &
1318 IEEE80211_HE_PHY_CAP3_SU_BEAMFORMER;
1319 link_conf->he_su_beamformee =
1320 params->he_cap->phy_cap_info[4] &
1321 IEEE80211_HE_PHY_CAP4_SU_BEAMFORMEE;
1322 link_conf->he_mu_beamformer =
1323 params->he_cap->phy_cap_info[4] &
1324 IEEE80211_HE_PHY_CAP4_MU_BEAMFORMER;
1325 link_conf->he_full_ul_mumimo =
1326 params->he_cap->phy_cap_info[2] &
1327 IEEE80211_HE_PHY_CAP2_UL_MU_FULL_MU_MIMO;
1330 if (params->eht_cap) {
1331 if (!link_conf->he_support)
1334 link_conf->eht_support = true;
1335 link_conf->eht_puncturing = params->punct_bitmap;
1336 changed |= BSS_CHANGED_EHT_PUNCTURING;
1338 link_conf->eht_su_beamformer =
1339 params->eht_cap->fixed.phy_cap_info[0] &
1340 IEEE80211_EHT_PHY_CAP0_SU_BEAMFORMER;
1341 link_conf->eht_su_beamformee =
1342 params->eht_cap->fixed.phy_cap_info[0] &
1343 IEEE80211_EHT_PHY_CAP0_SU_BEAMFORMEE;
1344 link_conf->eht_mu_beamformer =
1345 params->eht_cap->fixed.phy_cap_info[7] &
1346 (IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_80MHZ |
1347 IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_160MHZ |
1348 IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_320MHZ);
1350 link_conf->eht_su_beamformer = false;
1351 link_conf->eht_su_beamformee = false;
1352 link_conf->eht_mu_beamformer = false;
1355 if (sdata->vif.type == NL80211_IFTYPE_AP &&
1356 params->mbssid_config.tx_wdev) {
1357 err = ieee80211_set_ap_mbssid_options(sdata,
1358 params->mbssid_config,
1364 mutex_lock(&local->mtx);
1365 err = ieee80211_link_use_channel(link, ¶ms->chandef,
1366 IEEE80211_CHANCTX_SHARED);
1368 ieee80211_link_copy_chanctx_to_vlans(link, false);
1369 mutex_unlock(&local->mtx);
1371 link_conf->beacon_int = prev_beacon_int;
1376 * Apply control port protocol, this allows us to
1377 * not encrypt dynamic WEP control frames.
1379 sdata->control_port_protocol = params->crypto.control_port_ethertype;
1380 sdata->control_port_no_encrypt = params->crypto.control_port_no_encrypt;
1381 sdata->control_port_over_nl80211 =
1382 params->crypto.control_port_over_nl80211;
1383 sdata->control_port_no_preauth =
1384 params->crypto.control_port_no_preauth;
1386 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) {
1387 vlan->control_port_protocol =
1388 params->crypto.control_port_ethertype;
1389 vlan->control_port_no_encrypt =
1390 params->crypto.control_port_no_encrypt;
1391 vlan->control_port_over_nl80211 =
1392 params->crypto.control_port_over_nl80211;
1393 vlan->control_port_no_preauth =
1394 params->crypto.control_port_no_preauth;
1397 link_conf->dtim_period = params->dtim_period;
1398 link_conf->enable_beacon = true;
1399 link_conf->allow_p2p_go_ps = sdata->vif.p2p;
1400 link_conf->twt_responder = params->twt_responder;
1401 link_conf->he_obss_pd = params->he_obss_pd;
1402 link_conf->he_bss_color = params->beacon.he_bss_color;
1403 sdata->vif.cfg.s1g = params->chandef.chan->band ==
1406 sdata->vif.cfg.ssid_len = params->ssid_len;
1407 if (params->ssid_len)
1408 memcpy(sdata->vif.cfg.ssid, params->ssid,
1410 link_conf->hidden_ssid =
1411 (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE);
1413 memset(&link_conf->p2p_noa_attr, 0,
1414 sizeof(link_conf->p2p_noa_attr));
1415 link_conf->p2p_noa_attr.oppps_ctwindow =
1416 params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
1417 if (params->p2p_opp_ps)
1418 link_conf->p2p_noa_attr.oppps_ctwindow |=
1419 IEEE80211_P2P_OPPPS_ENABLE_BIT;
1421 sdata->beacon_rate_set = false;
1422 if (wiphy_ext_feature_isset(local->hw.wiphy,
1423 NL80211_EXT_FEATURE_BEACON_RATE_LEGACY)) {
1424 for (i = 0; i < NUM_NL80211_BANDS; i++) {
1425 sdata->beacon_rateidx_mask[i] =
1426 params->beacon_rate.control[i].legacy;
1427 if (sdata->beacon_rateidx_mask[i])
1428 sdata->beacon_rate_set = true;
1432 if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL))
1433 link_conf->beacon_tx_rate = params->beacon_rate;
1435 err = ieee80211_assign_beacon(sdata, link, ¶ms->beacon, NULL, NULL,
1440 if (params->fils_discovery.max_interval) {
1441 err = ieee80211_set_fils_discovery(sdata,
1442 ¶ms->fils_discovery,
1446 changed |= BSS_CHANGED_FILS_DISCOVERY;
1449 if (params->unsol_bcast_probe_resp.interval) {
1450 err = ieee80211_set_unsol_bcast_probe_resp(sdata,
1451 ¶ms->unsol_bcast_probe_resp,
1455 changed |= BSS_CHANGED_UNSOL_BCAST_PROBE_RESP;
1458 err = drv_start_ap(sdata->local, sdata, link_conf);
1460 old = sdata_dereference(link->u.ap.beacon, sdata);
1463 kfree_rcu(old, rcu_head);
1464 RCU_INIT_POINTER(link->u.ap.beacon, NULL);
1465 sdata->u.ap.active = false;
1469 ieee80211_recalc_dtim(local, sdata);
1470 ieee80211_vif_cfg_change_notify(sdata, BSS_CHANGED_SSID);
1471 ieee80211_link_info_change_notify(sdata, link, changed);
1473 netif_carrier_on(dev);
1474 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
1475 netif_carrier_on(vlan->dev);
1480 mutex_lock(&local->mtx);
1481 ieee80211_link_release_channel(link);
1482 mutex_unlock(&local->mtx);
1487 static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev,
1488 struct cfg80211_beacon_data *params)
1490 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1491 struct ieee80211_link_data *link;
1492 struct beacon_data *old;
1494 struct ieee80211_bss_conf *link_conf;
1497 sdata_assert_lock(sdata);
1499 link = sdata_dereference(sdata->link[params->link_id], sdata);
1503 link_conf = link->conf;
1505 /* don't allow changing the beacon while a countdown is in place - offset
1506 * of channel switch counter may change
1508 if (link_conf->csa_active || link_conf->color_change_active)
1511 old = sdata_dereference(link->u.ap.beacon, sdata);
1515 err = ieee80211_assign_beacon(sdata, link, params, NULL, NULL,
1520 if (params->he_bss_color_valid &&
1521 params->he_bss_color.enabled != link_conf->he_bss_color.enabled) {
1522 link_conf->he_bss_color.enabled = params->he_bss_color.enabled;
1523 changed |= BSS_CHANGED_HE_BSS_COLOR;
1526 ieee80211_link_info_change_notify(sdata, link, changed);
1530 static void ieee80211_free_next_beacon(struct ieee80211_link_data *link)
1532 if (!link->u.ap.next_beacon)
1535 kfree(link->u.ap.next_beacon->mbssid_ies);
1536 kfree(link->u.ap.next_beacon->rnr_ies);
1537 kfree(link->u.ap.next_beacon);
1538 link->u.ap.next_beacon = NULL;
1541 static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev,
1542 unsigned int link_id)
1544 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1545 struct ieee80211_sub_if_data *vlan;
1546 struct ieee80211_local *local = sdata->local;
1547 struct beacon_data *old_beacon;
1548 struct probe_resp *old_probe_resp;
1549 struct fils_discovery_data *old_fils_discovery;
1550 struct unsol_bcast_probe_resp_data *old_unsol_bcast_probe_resp;
1551 struct cfg80211_chan_def chandef;
1552 struct ieee80211_link_data *link =
1553 sdata_dereference(sdata->link[link_id], sdata);
1554 struct ieee80211_bss_conf *link_conf = link->conf;
1556 sdata_assert_lock(sdata);
1558 old_beacon = sdata_dereference(link->u.ap.beacon, sdata);
1561 old_probe_resp = sdata_dereference(link->u.ap.probe_resp,
1563 old_fils_discovery = sdata_dereference(link->u.ap.fils_discovery,
1565 old_unsol_bcast_probe_resp =
1566 sdata_dereference(link->u.ap.unsol_bcast_probe_resp,
1569 /* abort any running channel switch or color change */
1570 mutex_lock(&local->mtx);
1571 link_conf->csa_active = false;
1572 link_conf->color_change_active = false;
1573 if (link->csa_block_tx) {
1574 ieee80211_wake_vif_queues(local, sdata,
1575 IEEE80211_QUEUE_STOP_REASON_CSA);
1576 link->csa_block_tx = false;
1579 mutex_unlock(&local->mtx);
1581 ieee80211_free_next_beacon(link);
1583 /* turn off carrier for this interface and dependent VLANs */
1584 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
1585 netif_carrier_off(vlan->dev);
1586 netif_carrier_off(dev);
1588 /* remove beacon and probe response */
1589 sdata->u.ap.active = false;
1590 RCU_INIT_POINTER(link->u.ap.beacon, NULL);
1591 RCU_INIT_POINTER(link->u.ap.probe_resp, NULL);
1592 RCU_INIT_POINTER(link->u.ap.fils_discovery, NULL);
1593 RCU_INIT_POINTER(link->u.ap.unsol_bcast_probe_resp, NULL);
1594 kfree_rcu(old_beacon, rcu_head);
1596 kfree_rcu(old_probe_resp, rcu_head);
1597 if (old_fils_discovery)
1598 kfree_rcu(old_fils_discovery, rcu_head);
1599 if (old_unsol_bcast_probe_resp)
1600 kfree_rcu(old_unsol_bcast_probe_resp, rcu_head);
1602 kfree(link_conf->ftmr_params);
1603 link_conf->ftmr_params = NULL;
1605 sdata->vif.mbssid_tx_vif = NULL;
1606 link_conf->bssid_index = 0;
1607 link_conf->nontransmitted = false;
1608 link_conf->ema_ap = false;
1609 link_conf->bssid_indicator = 0;
1611 __sta_info_flush(sdata, true);
1612 ieee80211_free_keys(sdata, true);
1614 link_conf->enable_beacon = false;
1615 sdata->beacon_rate_set = false;
1616 sdata->vif.cfg.ssid_len = 0;
1617 clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state);
1618 ieee80211_link_info_change_notify(sdata, link,
1619 BSS_CHANGED_BEACON_ENABLED);
1621 if (sdata->wdev.cac_started) {
1622 chandef = link_conf->chandef;
1623 wiphy_delayed_work_cancel(wiphy, &link->dfs_cac_timer_work);
1624 cfg80211_cac_event(sdata->dev, &chandef,
1625 NL80211_RADAR_CAC_ABORTED,
1629 drv_stop_ap(sdata->local, sdata, link_conf);
1631 /* free all potentially still buffered bcast frames */
1632 local->total_ps_buffered -= skb_queue_len(&sdata->u.ap.ps.bc_buf);
1633 ieee80211_purge_tx_queue(&local->hw, &sdata->u.ap.ps.bc_buf);
1635 mutex_lock(&local->mtx);
1636 ieee80211_link_copy_chanctx_to_vlans(link, true);
1637 ieee80211_link_release_channel(link);
1638 mutex_unlock(&local->mtx);
1643 static int sta_apply_auth_flags(struct ieee80211_local *local,
1644 struct sta_info *sta,
1649 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
1650 set & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
1651 !test_sta_flag(sta, WLAN_STA_AUTH)) {
1652 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
1657 if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
1658 set & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
1659 !test_sta_flag(sta, WLAN_STA_ASSOC)) {
1661 * When peer becomes associated, init rate control as
1662 * well. Some drivers require rate control initialized
1663 * before drv_sta_state() is called.
1665 if (!test_sta_flag(sta, WLAN_STA_RATE_CONTROL))
1666 rate_control_rate_init(sta);
1668 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
1673 if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
1674 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED))
1675 ret = sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED);
1676 else if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
1677 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
1684 if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
1685 !(set & BIT(NL80211_STA_FLAG_ASSOCIATED)) &&
1686 test_sta_flag(sta, WLAN_STA_ASSOC)) {
1687 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
1692 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
1693 !(set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) &&
1694 test_sta_flag(sta, WLAN_STA_AUTH)) {
1695 ret = sta_info_move_state(sta, IEEE80211_STA_NONE);
1703 static void sta_apply_mesh_params(struct ieee80211_local *local,
1704 struct sta_info *sta,
1705 struct station_parameters *params)
1707 #ifdef CONFIG_MAC80211_MESH
1708 struct ieee80211_sub_if_data *sdata = sta->sdata;
1711 if (params->sta_modify_mask & STATION_PARAM_APPLY_PLINK_STATE) {
1712 switch (params->plink_state) {
1713 case NL80211_PLINK_ESTAB:
1714 if (sta->mesh->plink_state != NL80211_PLINK_ESTAB)
1715 changed = mesh_plink_inc_estab_count(sdata);
1716 sta->mesh->plink_state = params->plink_state;
1717 sta->mesh->aid = params->peer_aid;
1719 ieee80211_mps_sta_status_update(sta);
1720 changed |= ieee80211_mps_set_sta_local_pm(sta,
1721 sdata->u.mesh.mshcfg.power_mode);
1723 ewma_mesh_tx_rate_avg_init(&sta->mesh->tx_rate_avg);
1724 /* init at low value */
1725 ewma_mesh_tx_rate_avg_add(&sta->mesh->tx_rate_avg, 10);
1728 case NL80211_PLINK_LISTEN:
1729 case NL80211_PLINK_BLOCKED:
1730 case NL80211_PLINK_OPN_SNT:
1731 case NL80211_PLINK_OPN_RCVD:
1732 case NL80211_PLINK_CNF_RCVD:
1733 case NL80211_PLINK_HOLDING:
1734 if (sta->mesh->plink_state == NL80211_PLINK_ESTAB)
1735 changed = mesh_plink_dec_estab_count(sdata);
1736 sta->mesh->plink_state = params->plink_state;
1738 ieee80211_mps_sta_status_update(sta);
1739 changed |= ieee80211_mps_set_sta_local_pm(sta,
1740 NL80211_MESH_POWER_UNKNOWN);
1748 switch (params->plink_action) {
1749 case NL80211_PLINK_ACTION_NO_ACTION:
1752 case NL80211_PLINK_ACTION_OPEN:
1753 changed |= mesh_plink_open(sta);
1755 case NL80211_PLINK_ACTION_BLOCK:
1756 changed |= mesh_plink_block(sta);
1760 if (params->local_pm)
1761 changed |= ieee80211_mps_set_sta_local_pm(sta,
1764 ieee80211_mbss_info_change_notify(sdata, changed);
1768 static int sta_link_apply_parameters(struct ieee80211_local *local,
1769 struct sta_info *sta, bool new_link,
1770 struct link_station_parameters *params)
1773 struct ieee80211_supported_band *sband;
1774 struct ieee80211_sub_if_data *sdata = sta->sdata;
1775 u32 link_id = params->link_id < 0 ? 0 : params->link_id;
1776 struct ieee80211_link_data *link =
1777 sdata_dereference(sdata->link[link_id], sdata);
1778 struct link_sta_info *link_sta =
1779 rcu_dereference_protected(sta->link[link_id],
1780 lockdep_is_held(&local->hw.wiphy->mtx));
1783 * If there are no changes, then accept a link that doesn't exist,
1784 * unless it's a new link.
1786 if (params->link_id < 0 && !new_link &&
1787 !params->link_mac && !params->txpwr_set &&
1788 !params->supported_rates_len &&
1789 !params->ht_capa && !params->vht_capa &&
1790 !params->he_capa && !params->eht_capa &&
1791 !params->opmode_notif_used)
1794 if (!link || !link_sta)
1797 sband = ieee80211_get_link_sband(link);
1801 if (params->link_mac) {
1803 memcpy(link_sta->addr, params->link_mac, ETH_ALEN);
1804 memcpy(link_sta->pub->addr, params->link_mac, ETH_ALEN);
1805 } else if (!ether_addr_equal(link_sta->addr,
1806 params->link_mac)) {
1809 } else if (new_link) {
1813 if (params->txpwr_set) {
1814 link_sta->pub->txpwr.type = params->txpwr.type;
1815 if (params->txpwr.type == NL80211_TX_POWER_LIMITED)
1816 link_sta->pub->txpwr.power = params->txpwr.power;
1817 ret = drv_sta_set_txpwr(local, sdata, sta);
1822 if (params->supported_rates &&
1823 params->supported_rates_len) {
1824 ieee80211_parse_bitrates(link->conf->chandef.width,
1825 sband, params->supported_rates,
1826 params->supported_rates_len,
1827 &link_sta->pub->supp_rates[sband->band]);
1830 if (params->ht_capa)
1831 ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
1832 params->ht_capa, link_sta);
1834 /* VHT can override some HT caps such as the A-MSDU max length */
1835 if (params->vht_capa)
1836 ieee80211_vht_cap_ie_to_sta_vht_cap(sdata, sband,
1837 params->vht_capa, link_sta);
1839 if (params->he_capa)
1840 ieee80211_he_cap_ie_to_sta_he_cap(sdata, sband,
1841 (void *)params->he_capa,
1842 params->he_capa_len,
1843 (void *)params->he_6ghz_capa,
1846 if (params->he_capa && params->eht_capa)
1847 ieee80211_eht_cap_ie_to_sta_eht_cap(sdata, sband,
1848 (u8 *)params->he_capa,
1849 params->he_capa_len,
1851 params->eht_capa_len,
1854 if (params->opmode_notif_used) {
1855 /* returned value is only needed for rc update, but the
1856 * rc isn't initialized here yet, so ignore it
1858 __ieee80211_vht_handle_opmode(sdata, link_sta,
1859 params->opmode_notif,
1866 static int sta_apply_parameters(struct ieee80211_local *local,
1867 struct sta_info *sta,
1868 struct station_parameters *params)
1870 struct ieee80211_sub_if_data *sdata = sta->sdata;
1874 mask = params->sta_flags_mask;
1875 set = params->sta_flags_set;
1877 if (ieee80211_vif_is_mesh(&sdata->vif)) {
1879 * In mesh mode, ASSOCIATED isn't part of the nl80211
1880 * API but must follow AUTHENTICATED for driver state.
1882 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED))
1883 mask |= BIT(NL80211_STA_FLAG_ASSOCIATED);
1884 if (set & BIT(NL80211_STA_FLAG_AUTHENTICATED))
1885 set |= BIT(NL80211_STA_FLAG_ASSOCIATED);
1886 } else if (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
1888 * TDLS -- everything follows authorized, but
1889 * only becoming authorized is possible, not
1892 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
1893 set |= BIT(NL80211_STA_FLAG_AUTHENTICATED) |
1894 BIT(NL80211_STA_FLAG_ASSOCIATED);
1895 mask |= BIT(NL80211_STA_FLAG_AUTHENTICATED) |
1896 BIT(NL80211_STA_FLAG_ASSOCIATED);
1900 if (mask & BIT(NL80211_STA_FLAG_WME) &&
1901 local->hw.queues >= IEEE80211_NUM_ACS)
1902 sta->sta.wme = set & BIT(NL80211_STA_FLAG_WME);
1904 /* auth flags will be set later for TDLS,
1905 * and for unassociated stations that move to associated */
1906 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1907 !((mask & BIT(NL80211_STA_FLAG_ASSOCIATED)) &&
1908 (set & BIT(NL80211_STA_FLAG_ASSOCIATED)))) {
1909 ret = sta_apply_auth_flags(local, sta, mask, set);
1914 if (mask & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) {
1915 if (set & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE))
1916 set_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
1918 clear_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
1921 if (mask & BIT(NL80211_STA_FLAG_MFP)) {
1922 sta->sta.mfp = !!(set & BIT(NL80211_STA_FLAG_MFP));
1923 if (set & BIT(NL80211_STA_FLAG_MFP))
1924 set_sta_flag(sta, WLAN_STA_MFP);
1926 clear_sta_flag(sta, WLAN_STA_MFP);
1929 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
1930 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER))
1931 set_sta_flag(sta, WLAN_STA_TDLS_PEER);
1933 clear_sta_flag(sta, WLAN_STA_TDLS_PEER);
1936 /* mark TDLS channel switch support, if the AP allows it */
1937 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1938 !sdata->deflink.u.mgd.tdls_chan_switch_prohibited &&
1939 params->ext_capab_len >= 4 &&
1940 params->ext_capab[3] & WLAN_EXT_CAPA4_TDLS_CHAN_SWITCH)
1941 set_sta_flag(sta, WLAN_STA_TDLS_CHAN_SWITCH);
1943 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1944 !sdata->u.mgd.tdls_wider_bw_prohibited &&
1945 ieee80211_hw_check(&local->hw, TDLS_WIDER_BW) &&
1946 params->ext_capab_len >= 8 &&
1947 params->ext_capab[7] & WLAN_EXT_CAPA8_TDLS_WIDE_BW_ENABLED)
1948 set_sta_flag(sta, WLAN_STA_TDLS_WIDER_BW);
1950 if (params->sta_modify_mask & STATION_PARAM_APPLY_UAPSD) {
1951 sta->sta.uapsd_queues = params->uapsd_queues;
1952 sta->sta.max_sp = params->max_sp;
1955 ieee80211_sta_set_max_amsdu_subframes(sta, params->ext_capab,
1956 params->ext_capab_len);
1959 * cfg80211 validates this (1-2007) and allows setting the AID
1960 * only when creating a new station entry
1963 sta->sta.aid = params->aid;
1966 * Some of the following updates would be racy if called on an
1967 * existing station, via ieee80211_change_station(). However,
1968 * all such changes are rejected by cfg80211 except for updates
1969 * changing the supported rates on an existing but not yet used
1973 if (params->listen_interval >= 0)
1974 sta->listen_interval = params->listen_interval;
1976 ret = sta_link_apply_parameters(local, sta, false,
1977 ¶ms->link_sta_params);
1981 if (params->support_p2p_ps >= 0)
1982 sta->sta.support_p2p_ps = params->support_p2p_ps;
1984 if (ieee80211_vif_is_mesh(&sdata->vif))
1985 sta_apply_mesh_params(local, sta, params);
1987 if (params->airtime_weight)
1988 sta->airtime_weight = params->airtime_weight;
1990 /* set the STA state after all sta info from usermode has been set */
1991 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) ||
1992 set & BIT(NL80211_STA_FLAG_ASSOCIATED)) {
1993 ret = sta_apply_auth_flags(local, sta, mask, set);
1998 /* Mark the STA as MLO if MLD MAC address is available */
1999 if (params->link_sta_params.mld_mac)
2000 sta->sta.mlo = true;
2005 static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
2007 struct station_parameters *params)
2009 struct ieee80211_local *local = wiphy_priv(wiphy);
2010 struct sta_info *sta;
2011 struct ieee80211_sub_if_data *sdata;
2014 lockdep_assert_wiphy(local->hw.wiphy);
2017 sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
2019 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
2020 sdata->vif.type != NL80211_IFTYPE_AP)
2023 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2025 if (ether_addr_equal(mac, sdata->vif.addr))
2028 if (!is_valid_ether_addr(mac))
2031 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER) &&
2032 sdata->vif.type == NL80211_IFTYPE_STATION &&
2033 !sdata->u.mgd.associated)
2037 * If we have a link ID, it can be a non-MLO station on an AP MLD,
2038 * but we need to have a link_mac in that case as well, so use the
2039 * STA's MAC address in that case.
2041 if (params->link_sta_params.link_id >= 0)
2042 sta = sta_info_alloc_with_link(sdata, mac,
2043 params->link_sta_params.link_id,
2044 params->link_sta_params.link_mac ?: mac,
2047 sta = sta_info_alloc(sdata, mac, GFP_KERNEL);
2052 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))
2053 sta->sta.tdls = true;
2055 /* Though the mutex is not needed here (since the station is not
2056 * visible yet), sta_apply_parameters (and inner functions) require
2057 * the mutex due to other paths.
2059 err = sta_apply_parameters(local, sta, params);
2061 sta_info_free(local, sta);
2066 * for TDLS and for unassociated station, rate control should be
2067 * initialized only when rates are known and station is marked
2068 * authorized/associated
2070 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
2071 test_sta_flag(sta, WLAN_STA_ASSOC))
2072 rate_control_rate_init(sta);
2074 return sta_info_insert(sta);
2077 static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev,
2078 struct station_del_parameters *params)
2080 struct ieee80211_sub_if_data *sdata;
2082 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2085 return sta_info_destroy_addr_bss(sdata, params->mac);
2087 sta_info_flush(sdata);
2091 static int ieee80211_change_station(struct wiphy *wiphy,
2092 struct net_device *dev, const u8 *mac,
2093 struct station_parameters *params)
2095 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2096 struct ieee80211_local *local = wiphy_priv(wiphy);
2097 struct sta_info *sta;
2098 struct ieee80211_sub_if_data *vlansdata;
2099 enum cfg80211_station_type statype;
2102 lockdep_assert_wiphy(local->hw.wiphy);
2104 sta = sta_info_get_bss(sdata, mac);
2108 switch (sdata->vif.type) {
2109 case NL80211_IFTYPE_MESH_POINT:
2110 if (sdata->u.mesh.user_mpm)
2111 statype = CFG80211_STA_MESH_PEER_USER;
2113 statype = CFG80211_STA_MESH_PEER_KERNEL;
2115 case NL80211_IFTYPE_ADHOC:
2116 statype = CFG80211_STA_IBSS;
2118 case NL80211_IFTYPE_STATION:
2119 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
2120 statype = CFG80211_STA_AP_STA;
2123 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
2124 statype = CFG80211_STA_TDLS_PEER_ACTIVE;
2126 statype = CFG80211_STA_TDLS_PEER_SETUP;
2128 case NL80211_IFTYPE_AP:
2129 case NL80211_IFTYPE_AP_VLAN:
2130 if (test_sta_flag(sta, WLAN_STA_ASSOC))
2131 statype = CFG80211_STA_AP_CLIENT;
2133 statype = CFG80211_STA_AP_CLIENT_UNASSOC;
2139 err = cfg80211_check_station_change(wiphy, params, statype);
2143 if (params->vlan && params->vlan != sta->sdata->dev) {
2144 vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
2146 if (params->vlan->ieee80211_ptr->use_4addr) {
2147 if (vlansdata->u.vlan.sta)
2150 rcu_assign_pointer(vlansdata->u.vlan.sta, sta);
2151 __ieee80211_check_fast_rx_iface(vlansdata);
2152 drv_sta_set_4addr(local, sta->sdata, &sta->sta, true);
2155 if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
2156 sta->sdata->u.vlan.sta) {
2157 ieee80211_clear_fast_rx(sta);
2158 RCU_INIT_POINTER(sta->sdata->u.vlan.sta, NULL);
2161 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
2162 ieee80211_vif_dec_num_mcast(sta->sdata);
2164 sta->sdata = vlansdata;
2165 ieee80211_check_fast_xmit(sta);
2167 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED)) {
2168 ieee80211_vif_inc_num_mcast(sta->sdata);
2169 cfg80211_send_layer2_update(sta->sdata->dev,
2174 /* we use sta_info_get_bss() so this might be different */
2175 if (sdata != sta->sdata) {
2176 mutex_lock_nested(&sta->sdata->wdev.mtx, 1);
2177 err = sta_apply_parameters(local, sta, params);
2178 mutex_unlock(&sta->sdata->wdev.mtx);
2180 err = sta_apply_parameters(local, sta, params);
2185 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
2186 params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
2187 ieee80211_recalc_ps(local);
2188 ieee80211_recalc_ps_vif(sdata);
2194 #ifdef CONFIG_MAC80211_MESH
2195 static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev,
2196 const u8 *dst, const u8 *next_hop)
2198 struct ieee80211_sub_if_data *sdata;
2199 struct mesh_path *mpath;
2200 struct sta_info *sta;
2202 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2205 sta = sta_info_get(sdata, next_hop);
2211 mpath = mesh_path_add(sdata, dst);
2212 if (IS_ERR(mpath)) {
2214 return PTR_ERR(mpath);
2217 mesh_path_fix_nexthop(mpath, sta);
2223 static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev,
2226 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2229 return mesh_path_del(sdata, dst);
2231 mesh_path_flush_by_iface(sdata);
2235 static int ieee80211_change_mpath(struct wiphy *wiphy, struct net_device *dev,
2236 const u8 *dst, const u8 *next_hop)
2238 struct ieee80211_sub_if_data *sdata;
2239 struct mesh_path *mpath;
2240 struct sta_info *sta;
2242 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2246 sta = sta_info_get(sdata, next_hop);
2252 mpath = mesh_path_lookup(sdata, dst);
2258 mesh_path_fix_nexthop(mpath, sta);
2264 static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop,
2265 struct mpath_info *pinfo)
2267 struct sta_info *next_hop_sta = rcu_dereference(mpath->next_hop);
2270 memcpy(next_hop, next_hop_sta->sta.addr, ETH_ALEN);
2272 eth_zero_addr(next_hop);
2274 memset(pinfo, 0, sizeof(*pinfo));
2276 pinfo->generation = mpath->sdata->u.mesh.mesh_paths_generation;
2278 pinfo->filled = MPATH_INFO_FRAME_QLEN |
2281 MPATH_INFO_EXPTIME |
2282 MPATH_INFO_DISCOVERY_TIMEOUT |
2283 MPATH_INFO_DISCOVERY_RETRIES |
2285 MPATH_INFO_HOP_COUNT |
2286 MPATH_INFO_PATH_CHANGE;
2288 pinfo->frame_qlen = mpath->frame_queue.qlen;
2289 pinfo->sn = mpath->sn;
2290 pinfo->metric = mpath->metric;
2291 if (time_before(jiffies, mpath->exp_time))
2292 pinfo->exptime = jiffies_to_msecs(mpath->exp_time - jiffies);
2293 pinfo->discovery_timeout =
2294 jiffies_to_msecs(mpath->discovery_timeout);
2295 pinfo->discovery_retries = mpath->discovery_retries;
2296 if (mpath->flags & MESH_PATH_ACTIVE)
2297 pinfo->flags |= NL80211_MPATH_FLAG_ACTIVE;
2298 if (mpath->flags & MESH_PATH_RESOLVING)
2299 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING;
2300 if (mpath->flags & MESH_PATH_SN_VALID)
2301 pinfo->flags |= NL80211_MPATH_FLAG_SN_VALID;
2302 if (mpath->flags & MESH_PATH_FIXED)
2303 pinfo->flags |= NL80211_MPATH_FLAG_FIXED;
2304 if (mpath->flags & MESH_PATH_RESOLVED)
2305 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVED;
2306 pinfo->hop_count = mpath->hop_count;
2307 pinfo->path_change_count = mpath->path_change_count;
2310 static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev,
2311 u8 *dst, u8 *next_hop, struct mpath_info *pinfo)
2314 struct ieee80211_sub_if_data *sdata;
2315 struct mesh_path *mpath;
2317 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2320 mpath = mesh_path_lookup(sdata, dst);
2325 memcpy(dst, mpath->dst, ETH_ALEN);
2326 mpath_set_pinfo(mpath, next_hop, pinfo);
2331 static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev,
2332 int idx, u8 *dst, u8 *next_hop,
2333 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_by_idx(sdata, idx);
2346 memcpy(dst, mpath->dst, ETH_ALEN);
2347 mpath_set_pinfo(mpath, next_hop, pinfo);
2352 static void mpp_set_pinfo(struct mesh_path *mpath, u8 *mpp,
2353 struct mpath_info *pinfo)
2355 memset(pinfo, 0, sizeof(*pinfo));
2356 memcpy(mpp, mpath->mpp, ETH_ALEN);
2358 pinfo->generation = mpath->sdata->u.mesh.mpp_paths_generation;
2361 static int ieee80211_get_mpp(struct wiphy *wiphy, struct net_device *dev,
2362 u8 *dst, u8 *mpp, struct mpath_info *pinfo)
2365 struct ieee80211_sub_if_data *sdata;
2366 struct mesh_path *mpath;
2368 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2371 mpath = mpp_path_lookup(sdata, dst);
2376 memcpy(dst, mpath->dst, ETH_ALEN);
2377 mpp_set_pinfo(mpath, mpp, pinfo);
2382 static int ieee80211_dump_mpp(struct wiphy *wiphy, struct net_device *dev,
2383 int idx, u8 *dst, u8 *mpp,
2384 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_by_idx(sdata, idx);
2397 memcpy(dst, mpath->dst, ETH_ALEN);
2398 mpp_set_pinfo(mpath, mpp, pinfo);
2403 static int ieee80211_get_mesh_config(struct wiphy *wiphy,
2404 struct net_device *dev,
2405 struct mesh_config *conf)
2407 struct ieee80211_sub_if_data *sdata;
2408 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2410 memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config));
2414 static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask)
2416 return (mask >> (parm-1)) & 0x1;
2419 static int copy_mesh_setup(struct ieee80211_if_mesh *ifmsh,
2420 const struct mesh_setup *setup)
2423 struct ieee80211_sub_if_data *sdata = container_of(ifmsh,
2424 struct ieee80211_sub_if_data, u.mesh);
2427 /* allocate information elements */
2430 if (setup->ie_len) {
2431 new_ie = kmemdup(setup->ie, setup->ie_len,
2436 ifmsh->ie_len = setup->ie_len;
2439 /* now copy the rest of the setup parameters */
2440 ifmsh->mesh_id_len = setup->mesh_id_len;
2441 memcpy(ifmsh->mesh_id, setup->mesh_id, ifmsh->mesh_id_len);
2442 ifmsh->mesh_sp_id = setup->sync_method;
2443 ifmsh->mesh_pp_id = setup->path_sel_proto;
2444 ifmsh->mesh_pm_id = setup->path_metric;
2445 ifmsh->user_mpm = setup->user_mpm;
2446 ifmsh->mesh_auth_id = setup->auth_id;
2447 ifmsh->security = IEEE80211_MESH_SEC_NONE;
2448 ifmsh->userspace_handles_dfs = setup->userspace_handles_dfs;
2449 if (setup->is_authenticated)
2450 ifmsh->security |= IEEE80211_MESH_SEC_AUTHED;
2451 if (setup->is_secure)
2452 ifmsh->security |= IEEE80211_MESH_SEC_SECURED;
2454 /* mcast rate setting in Mesh Node */
2455 memcpy(sdata->vif.bss_conf.mcast_rate, setup->mcast_rate,
2456 sizeof(setup->mcast_rate));
2457 sdata->vif.bss_conf.basic_rates = setup->basic_rates;
2459 sdata->vif.bss_conf.beacon_int = setup->beacon_interval;
2460 sdata->vif.bss_conf.dtim_period = setup->dtim_period;
2462 sdata->beacon_rate_set = false;
2463 if (wiphy_ext_feature_isset(sdata->local->hw.wiphy,
2464 NL80211_EXT_FEATURE_BEACON_RATE_LEGACY)) {
2465 for (i = 0; i < NUM_NL80211_BANDS; i++) {
2466 sdata->beacon_rateidx_mask[i] =
2467 setup->beacon_rate.control[i].legacy;
2468 if (sdata->beacon_rateidx_mask[i])
2469 sdata->beacon_rate_set = true;
2476 static int ieee80211_update_mesh_config(struct wiphy *wiphy,
2477 struct net_device *dev, u32 mask,
2478 const struct mesh_config *nconf)
2480 struct mesh_config *conf;
2481 struct ieee80211_sub_if_data *sdata;
2482 struct ieee80211_if_mesh *ifmsh;
2484 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2485 ifmsh = &sdata->u.mesh;
2487 /* Set the config options which we are interested in setting */
2488 conf = &(sdata->u.mesh.mshcfg);
2489 if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask))
2490 conf->dot11MeshRetryTimeout = nconf->dot11MeshRetryTimeout;
2491 if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT, mask))
2492 conf->dot11MeshConfirmTimeout = nconf->dot11MeshConfirmTimeout;
2493 if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT, mask))
2494 conf->dot11MeshHoldingTimeout = nconf->dot11MeshHoldingTimeout;
2495 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS, mask))
2496 conf->dot11MeshMaxPeerLinks = nconf->dot11MeshMaxPeerLinks;
2497 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES, mask))
2498 conf->dot11MeshMaxRetries = nconf->dot11MeshMaxRetries;
2499 if (_chg_mesh_attr(NL80211_MESHCONF_TTL, mask))
2500 conf->dot11MeshTTL = nconf->dot11MeshTTL;
2501 if (_chg_mesh_attr(NL80211_MESHCONF_ELEMENT_TTL, mask))
2502 conf->element_ttl = nconf->element_ttl;
2503 if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask)) {
2504 if (ifmsh->user_mpm)
2506 conf->auto_open_plinks = nconf->auto_open_plinks;
2508 if (_chg_mesh_attr(NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR, mask))
2509 conf->dot11MeshNbrOffsetMaxNeighbor =
2510 nconf->dot11MeshNbrOffsetMaxNeighbor;
2511 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, mask))
2512 conf->dot11MeshHWMPmaxPREQretries =
2513 nconf->dot11MeshHWMPmaxPREQretries;
2514 if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME, mask))
2515 conf->path_refresh_time = nconf->path_refresh_time;
2516 if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, mask))
2517 conf->min_discovery_timeout = nconf->min_discovery_timeout;
2518 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, mask))
2519 conf->dot11MeshHWMPactivePathTimeout =
2520 nconf->dot11MeshHWMPactivePathTimeout;
2521 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, mask))
2522 conf->dot11MeshHWMPpreqMinInterval =
2523 nconf->dot11MeshHWMPpreqMinInterval;
2524 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL, mask))
2525 conf->dot11MeshHWMPperrMinInterval =
2526 nconf->dot11MeshHWMPperrMinInterval;
2527 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
2529 conf->dot11MeshHWMPnetDiameterTraversalTime =
2530 nconf->dot11MeshHWMPnetDiameterTraversalTime;
2531 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOTMODE, mask)) {
2532 conf->dot11MeshHWMPRootMode = nconf->dot11MeshHWMPRootMode;
2533 ieee80211_mesh_root_setup(ifmsh);
2535 if (_chg_mesh_attr(NL80211_MESHCONF_GATE_ANNOUNCEMENTS, mask)) {
2536 /* our current gate announcement implementation rides on root
2537 * announcements, so require this ifmsh to also be a root node
2539 if (nconf->dot11MeshGateAnnouncementProtocol &&
2540 !(conf->dot11MeshHWMPRootMode > IEEE80211_ROOTMODE_ROOT)) {
2541 conf->dot11MeshHWMPRootMode = IEEE80211_PROACTIVE_RANN;
2542 ieee80211_mesh_root_setup(ifmsh);
2544 conf->dot11MeshGateAnnouncementProtocol =
2545 nconf->dot11MeshGateAnnouncementProtocol;
2547 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_RANN_INTERVAL, mask))
2548 conf->dot11MeshHWMPRannInterval =
2549 nconf->dot11MeshHWMPRannInterval;
2550 if (_chg_mesh_attr(NL80211_MESHCONF_FORWARDING, mask))
2551 conf->dot11MeshForwarding = nconf->dot11MeshForwarding;
2552 if (_chg_mesh_attr(NL80211_MESHCONF_RSSI_THRESHOLD, mask)) {
2553 /* our RSSI threshold implementation is supported only for
2554 * devices that report signal in dBm.
2556 if (!ieee80211_hw_check(&sdata->local->hw, SIGNAL_DBM))
2558 conf->rssi_threshold = nconf->rssi_threshold;
2560 if (_chg_mesh_attr(NL80211_MESHCONF_HT_OPMODE, mask)) {
2561 conf->ht_opmode = nconf->ht_opmode;
2562 sdata->vif.bss_conf.ht_operation_mode = nconf->ht_opmode;
2563 ieee80211_link_info_change_notify(sdata, &sdata->deflink,
2566 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT, mask))
2567 conf->dot11MeshHWMPactivePathToRootTimeout =
2568 nconf->dot11MeshHWMPactivePathToRootTimeout;
2569 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOT_INTERVAL, mask))
2570 conf->dot11MeshHWMProotInterval =
2571 nconf->dot11MeshHWMProotInterval;
2572 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL, mask))
2573 conf->dot11MeshHWMPconfirmationInterval =
2574 nconf->dot11MeshHWMPconfirmationInterval;
2575 if (_chg_mesh_attr(NL80211_MESHCONF_POWER_MODE, mask)) {
2576 conf->power_mode = nconf->power_mode;
2577 ieee80211_mps_local_status_update(sdata);
2579 if (_chg_mesh_attr(NL80211_MESHCONF_AWAKE_WINDOW, mask))
2580 conf->dot11MeshAwakeWindowDuration =
2581 nconf->dot11MeshAwakeWindowDuration;
2582 if (_chg_mesh_attr(NL80211_MESHCONF_PLINK_TIMEOUT, mask))
2583 conf->plink_timeout = nconf->plink_timeout;
2584 if (_chg_mesh_attr(NL80211_MESHCONF_CONNECTED_TO_GATE, mask))
2585 conf->dot11MeshConnectedToMeshGate =
2586 nconf->dot11MeshConnectedToMeshGate;
2587 if (_chg_mesh_attr(NL80211_MESHCONF_NOLEARN, mask))
2588 conf->dot11MeshNolearn = nconf->dot11MeshNolearn;
2589 if (_chg_mesh_attr(NL80211_MESHCONF_CONNECTED_TO_AS, mask))
2590 conf->dot11MeshConnectedToAuthServer =
2591 nconf->dot11MeshConnectedToAuthServer;
2592 ieee80211_mbss_info_change_notify(sdata, BSS_CHANGED_BEACON);
2596 static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev,
2597 const struct mesh_config *conf,
2598 const struct mesh_setup *setup)
2600 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2601 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
2604 memcpy(&ifmsh->mshcfg, conf, sizeof(struct mesh_config));
2605 err = copy_mesh_setup(ifmsh, setup);
2609 sdata->control_port_over_nl80211 = setup->control_port_over_nl80211;
2611 /* can mesh use other SMPS modes? */
2612 sdata->deflink.smps_mode = IEEE80211_SMPS_OFF;
2613 sdata->deflink.needed_rx_chains = sdata->local->rx_chains;
2615 mutex_lock(&sdata->local->mtx);
2616 err = ieee80211_link_use_channel(&sdata->deflink, &setup->chandef,
2617 IEEE80211_CHANCTX_SHARED);
2618 mutex_unlock(&sdata->local->mtx);
2622 return ieee80211_start_mesh(sdata);
2625 static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev)
2627 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2629 ieee80211_stop_mesh(sdata);
2630 mutex_lock(&sdata->local->mtx);
2631 ieee80211_link_release_channel(&sdata->deflink);
2632 kfree(sdata->u.mesh.ie);
2633 mutex_unlock(&sdata->local->mtx);
2639 static int ieee80211_change_bss(struct wiphy *wiphy,
2640 struct net_device *dev,
2641 struct bss_parameters *params)
2643 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2644 struct ieee80211_link_data *link;
2645 struct ieee80211_supported_band *sband;
2648 link = ieee80211_link_or_deflink(sdata, params->link_id, true);
2650 return PTR_ERR(link);
2652 if (!sdata_dereference(link->u.ap.beacon, sdata))
2655 sband = ieee80211_get_link_sband(link);
2659 if (params->basic_rates) {
2660 if (!ieee80211_parse_bitrates(link->conf->chandef.width,
2661 wiphy->bands[sband->band],
2662 params->basic_rates,
2663 params->basic_rates_len,
2664 &link->conf->basic_rates))
2666 changed |= BSS_CHANGED_BASIC_RATES;
2667 ieee80211_check_rate_mask(link);
2670 if (params->use_cts_prot >= 0) {
2671 link->conf->use_cts_prot = params->use_cts_prot;
2672 changed |= BSS_CHANGED_ERP_CTS_PROT;
2674 if (params->use_short_preamble >= 0) {
2675 link->conf->use_short_preamble = params->use_short_preamble;
2676 changed |= BSS_CHANGED_ERP_PREAMBLE;
2679 if (!link->conf->use_short_slot &&
2680 (sband->band == NL80211_BAND_5GHZ ||
2681 sband->band == NL80211_BAND_6GHZ)) {
2682 link->conf->use_short_slot = true;
2683 changed |= BSS_CHANGED_ERP_SLOT;
2686 if (params->use_short_slot_time >= 0) {
2687 link->conf->use_short_slot = params->use_short_slot_time;
2688 changed |= BSS_CHANGED_ERP_SLOT;
2691 if (params->ap_isolate >= 0) {
2692 if (params->ap_isolate)
2693 sdata->flags |= IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
2695 sdata->flags &= ~IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
2696 ieee80211_check_fast_rx_iface(sdata);
2699 if (params->ht_opmode >= 0) {
2700 link->conf->ht_operation_mode = (u16)params->ht_opmode;
2701 changed |= BSS_CHANGED_HT;
2704 if (params->p2p_ctwindow >= 0) {
2705 link->conf->p2p_noa_attr.oppps_ctwindow &=
2706 ~IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
2707 link->conf->p2p_noa_attr.oppps_ctwindow |=
2708 params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
2709 changed |= BSS_CHANGED_P2P_PS;
2712 if (params->p2p_opp_ps > 0) {
2713 link->conf->p2p_noa_attr.oppps_ctwindow |=
2714 IEEE80211_P2P_OPPPS_ENABLE_BIT;
2715 changed |= BSS_CHANGED_P2P_PS;
2716 } else if (params->p2p_opp_ps == 0) {
2717 link->conf->p2p_noa_attr.oppps_ctwindow &=
2718 ~IEEE80211_P2P_OPPPS_ENABLE_BIT;
2719 changed |= BSS_CHANGED_P2P_PS;
2722 ieee80211_link_info_change_notify(sdata, link, changed);
2727 static int ieee80211_set_txq_params(struct wiphy *wiphy,
2728 struct net_device *dev,
2729 struct ieee80211_txq_params *params)
2731 struct ieee80211_local *local = wiphy_priv(wiphy);
2732 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2733 struct ieee80211_link_data *link =
2734 ieee80211_link_or_deflink(sdata, params->link_id, true);
2735 struct ieee80211_tx_queue_params p;
2737 if (!local->ops->conf_tx)
2740 if (local->hw.queues < IEEE80211_NUM_ACS)
2744 return PTR_ERR(link);
2746 memset(&p, 0, sizeof(p));
2747 p.aifs = params->aifs;
2748 p.cw_max = params->cwmax;
2749 p.cw_min = params->cwmin;
2750 p.txop = params->txop;
2753 * Setting tx queue params disables u-apsd because it's only
2754 * called in master mode.
2758 ieee80211_regulatory_limit_wmm_params(sdata, &p, params->ac);
2760 link->tx_conf[params->ac] = p;
2761 if (drv_conf_tx(local, link, params->ac, &p)) {
2762 wiphy_debug(local->hw.wiphy,
2763 "failed to set TX queue parameters for AC %d\n",
2768 ieee80211_link_info_change_notify(sdata, link,
2775 static int ieee80211_suspend(struct wiphy *wiphy,
2776 struct cfg80211_wowlan *wowlan)
2778 return __ieee80211_suspend(wiphy_priv(wiphy), wowlan);
2781 static int ieee80211_resume(struct wiphy *wiphy)
2783 return __ieee80211_resume(wiphy_priv(wiphy));
2786 #define ieee80211_suspend NULL
2787 #define ieee80211_resume NULL
2790 static int ieee80211_scan(struct wiphy *wiphy,
2791 struct cfg80211_scan_request *req)
2793 struct ieee80211_sub_if_data *sdata;
2795 sdata = IEEE80211_WDEV_TO_SUB_IF(req->wdev);
2797 switch (ieee80211_vif_type_p2p(&sdata->vif)) {
2798 case NL80211_IFTYPE_STATION:
2799 case NL80211_IFTYPE_ADHOC:
2800 case NL80211_IFTYPE_MESH_POINT:
2801 case NL80211_IFTYPE_P2P_CLIENT:
2802 case NL80211_IFTYPE_P2P_DEVICE:
2804 case NL80211_IFTYPE_P2P_GO:
2805 if (sdata->local->ops->hw_scan)
2808 * FIXME: implement NoA while scanning in software,
2809 * for now fall through to allow scanning only when
2810 * beaconing hasn't been configured yet
2813 case NL80211_IFTYPE_AP:
2815 * If the scan has been forced (and the driver supports
2816 * forcing), don't care about being beaconing already.
2817 * This will create problems to the attached stations (e.g. all
2818 * the frames sent while scanning on other channel will be
2821 if (sdata->deflink.u.ap.beacon &&
2822 (!(wiphy->features & NL80211_FEATURE_AP_SCAN) ||
2823 !(req->flags & NL80211_SCAN_FLAG_AP)))
2826 case NL80211_IFTYPE_NAN:
2831 return ieee80211_request_scan(sdata, req);
2834 static void ieee80211_abort_scan(struct wiphy *wiphy, struct wireless_dev *wdev)
2836 ieee80211_scan_cancel(wiphy_priv(wiphy));
2840 ieee80211_sched_scan_start(struct wiphy *wiphy,
2841 struct net_device *dev,
2842 struct cfg80211_sched_scan_request *req)
2844 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2846 if (!sdata->local->ops->sched_scan_start)
2849 return ieee80211_request_sched_scan_start(sdata, req);
2853 ieee80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev,
2856 struct ieee80211_local *local = wiphy_priv(wiphy);
2858 if (!local->ops->sched_scan_stop)
2861 return ieee80211_request_sched_scan_stop(local);
2864 static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev,
2865 struct cfg80211_auth_request *req)
2867 return ieee80211_mgd_auth(IEEE80211_DEV_TO_SUB_IF(dev), req);
2870 static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev,
2871 struct cfg80211_assoc_request *req)
2873 return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
2876 static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev,
2877 struct cfg80211_deauth_request *req)
2879 return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev), req);
2882 static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
2883 struct cfg80211_disassoc_request *req)
2885 return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
2888 static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
2889 struct cfg80211_ibss_params *params)
2891 return ieee80211_ibss_join(IEEE80211_DEV_TO_SUB_IF(dev), params);
2894 static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
2896 return ieee80211_ibss_leave(IEEE80211_DEV_TO_SUB_IF(dev));
2899 static int ieee80211_join_ocb(struct wiphy *wiphy, struct net_device *dev,
2900 struct ocb_setup *setup)
2902 return ieee80211_ocb_join(IEEE80211_DEV_TO_SUB_IF(dev), setup);
2905 static int ieee80211_leave_ocb(struct wiphy *wiphy, struct net_device *dev)
2907 return ieee80211_ocb_leave(IEEE80211_DEV_TO_SUB_IF(dev));
2910 static int ieee80211_set_mcast_rate(struct wiphy *wiphy, struct net_device *dev,
2911 int rate[NUM_NL80211_BANDS])
2913 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2915 memcpy(sdata->vif.bss_conf.mcast_rate, rate,
2916 sizeof(int) * NUM_NL80211_BANDS);
2918 ieee80211_link_info_change_notify(sdata, &sdata->deflink,
2919 BSS_CHANGED_MCAST_RATE);
2924 static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
2926 struct ieee80211_local *local = wiphy_priv(wiphy);
2929 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
2930 ieee80211_check_fast_xmit_all(local);
2932 err = drv_set_frag_threshold(local, wiphy->frag_threshold);
2935 ieee80211_check_fast_xmit_all(local);
2940 if ((changed & WIPHY_PARAM_COVERAGE_CLASS) ||
2941 (changed & WIPHY_PARAM_DYN_ACK)) {
2944 coverage_class = changed & WIPHY_PARAM_COVERAGE_CLASS ?
2945 wiphy->coverage_class : -1;
2946 err = drv_set_coverage_class(local, coverage_class);
2952 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
2953 err = drv_set_rts_threshold(local, wiphy->rts_threshold);
2959 if (changed & WIPHY_PARAM_RETRY_SHORT) {
2960 if (wiphy->retry_short > IEEE80211_MAX_TX_RETRY)
2962 local->hw.conf.short_frame_max_tx_count = wiphy->retry_short;
2964 if (changed & WIPHY_PARAM_RETRY_LONG) {
2965 if (wiphy->retry_long > IEEE80211_MAX_TX_RETRY)
2967 local->hw.conf.long_frame_max_tx_count = wiphy->retry_long;
2970 (WIPHY_PARAM_RETRY_SHORT | WIPHY_PARAM_RETRY_LONG))
2971 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS);
2973 if (changed & (WIPHY_PARAM_TXQ_LIMIT |
2974 WIPHY_PARAM_TXQ_MEMORY_LIMIT |
2975 WIPHY_PARAM_TXQ_QUANTUM))
2976 ieee80211_txq_set_params(local);
2981 static int ieee80211_set_tx_power(struct wiphy *wiphy,
2982 struct wireless_dev *wdev,
2983 enum nl80211_tx_power_setting type, int mbm)
2985 struct ieee80211_local *local = wiphy_priv(wiphy);
2986 struct ieee80211_sub_if_data *sdata;
2987 enum nl80211_tx_power_setting txp_type = type;
2988 bool update_txp_type = false;
2989 bool has_monitor = false;
2992 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
2994 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) {
2995 sdata = wiphy_dereference(local->hw.wiphy,
2996 local->monitor_sdata);
3002 case NL80211_TX_POWER_AUTOMATIC:
3003 sdata->deflink.user_power_level =
3004 IEEE80211_UNSET_POWER_LEVEL;
3005 txp_type = NL80211_TX_POWER_LIMITED;
3007 case NL80211_TX_POWER_LIMITED:
3008 case NL80211_TX_POWER_FIXED:
3009 if (mbm < 0 || (mbm % 100))
3011 sdata->deflink.user_power_level = MBM_TO_DBM(mbm);
3015 if (txp_type != sdata->vif.bss_conf.txpower_type) {
3016 update_txp_type = true;
3017 sdata->vif.bss_conf.txpower_type = txp_type;
3020 ieee80211_recalc_txpower(sdata, update_txp_type);
3026 case NL80211_TX_POWER_AUTOMATIC:
3027 local->user_power_level = IEEE80211_UNSET_POWER_LEVEL;
3028 txp_type = NL80211_TX_POWER_LIMITED;
3030 case NL80211_TX_POWER_LIMITED:
3031 case NL80211_TX_POWER_FIXED:
3032 if (mbm < 0 || (mbm % 100))
3034 local->user_power_level = MBM_TO_DBM(mbm);
3038 mutex_lock(&local->iflist_mtx);
3039 list_for_each_entry(sdata, &local->interfaces, list) {
3040 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) {
3044 sdata->deflink.user_power_level = local->user_power_level;
3045 if (txp_type != sdata->vif.bss_conf.txpower_type)
3046 update_txp_type = true;
3047 sdata->vif.bss_conf.txpower_type = txp_type;
3049 list_for_each_entry(sdata, &local->interfaces, list) {
3050 if (sdata->vif.type == NL80211_IFTYPE_MONITOR)
3052 ieee80211_recalc_txpower(sdata, update_txp_type);
3054 mutex_unlock(&local->iflist_mtx);
3057 sdata = wiphy_dereference(local->hw.wiphy,
3058 local->monitor_sdata);
3060 sdata->deflink.user_power_level = local->user_power_level;
3061 if (txp_type != sdata->vif.bss_conf.txpower_type)
3062 update_txp_type = true;
3063 sdata->vif.bss_conf.txpower_type = txp_type;
3065 ieee80211_recalc_txpower(sdata, update_txp_type);
3072 static int ieee80211_get_tx_power(struct wiphy *wiphy,
3073 struct wireless_dev *wdev,
3076 struct ieee80211_local *local = wiphy_priv(wiphy);
3077 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
3079 if (local->ops->get_txpower)
3080 return drv_get_txpower(local, sdata, dbm);
3082 if (!local->use_chanctx)
3083 *dbm = local->hw.conf.power_level;
3085 *dbm = sdata->vif.bss_conf.txpower;
3090 static void ieee80211_rfkill_poll(struct wiphy *wiphy)
3092 struct ieee80211_local *local = wiphy_priv(wiphy);
3094 drv_rfkill_poll(local);
3097 #ifdef CONFIG_NL80211_TESTMODE
3098 static int ieee80211_testmode_cmd(struct wiphy *wiphy,
3099 struct wireless_dev *wdev,
3100 void *data, int len)
3102 struct ieee80211_local *local = wiphy_priv(wiphy);
3103 struct ieee80211_vif *vif = NULL;
3105 if (!local->ops->testmode_cmd)
3109 struct ieee80211_sub_if_data *sdata;
3111 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
3112 if (sdata->flags & IEEE80211_SDATA_IN_DRIVER)
3116 return local->ops->testmode_cmd(&local->hw, vif, data, len);
3119 static int ieee80211_testmode_dump(struct wiphy *wiphy,
3120 struct sk_buff *skb,
3121 struct netlink_callback *cb,
3122 void *data, int len)
3124 struct ieee80211_local *local = wiphy_priv(wiphy);
3126 if (!local->ops->testmode_dump)
3129 return local->ops->testmode_dump(&local->hw, skb, cb, data, len);
3133 int __ieee80211_request_smps_mgd(struct ieee80211_sub_if_data *sdata,
3134 struct ieee80211_link_data *link,
3135 enum ieee80211_smps_mode smps_mode)
3138 enum ieee80211_smps_mode old_req;
3140 struct sta_info *sta;
3141 bool tdls_peer_found = false;
3143 lockdep_assert_held(&sdata->wdev.mtx);
3145 if (WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION))
3148 if (ieee80211_vif_is_mld(&sdata->vif) &&
3149 !(sdata->vif.active_links & BIT(link->link_id)))
3152 old_req = link->u.mgd.req_smps;
3153 link->u.mgd.req_smps = smps_mode;
3155 if (old_req == smps_mode &&
3156 smps_mode != IEEE80211_SMPS_AUTOMATIC)
3160 * If not associated, or current association is not an HT
3161 * association, there's no need to do anything, just store
3162 * the new value until we associate.
3164 if (!sdata->u.mgd.associated ||
3165 link->conf->chandef.width == NL80211_CHAN_WIDTH_20_NOHT)
3168 ap = sdata->vif.cfg.ap_addr;
3171 list_for_each_entry_rcu(sta, &sdata->local->sta_list, list) {
3172 if (!sta->sta.tdls || sta->sdata != sdata || !sta->uploaded ||
3173 !test_sta_flag(sta, WLAN_STA_AUTHORIZED))
3176 tdls_peer_found = true;
3181 if (smps_mode == IEEE80211_SMPS_AUTOMATIC) {
3182 if (tdls_peer_found || !sdata->u.mgd.powersave)
3183 smps_mode = IEEE80211_SMPS_OFF;
3185 smps_mode = IEEE80211_SMPS_DYNAMIC;
3188 /* send SM PS frame to AP */
3189 err = ieee80211_send_smps_action(sdata, smps_mode,
3191 ieee80211_vif_is_mld(&sdata->vif) ?
3192 link->link_id : -1);
3194 link->u.mgd.req_smps = old_req;
3195 else if (smps_mode != IEEE80211_SMPS_OFF && tdls_peer_found)
3196 ieee80211_teardown_tdls_peers(sdata);
3201 static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
3202 bool enabled, int timeout)
3204 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3205 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
3206 unsigned int link_id;
3208 if (sdata->vif.type != NL80211_IFTYPE_STATION)
3211 if (!ieee80211_hw_check(&local->hw, SUPPORTS_PS))
3214 if (enabled == sdata->u.mgd.powersave &&
3215 timeout == local->dynamic_ps_forced_timeout)
3218 sdata->u.mgd.powersave = enabled;
3219 local->dynamic_ps_forced_timeout = timeout;
3221 /* no change, but if automatic follow powersave */
3223 for (link_id = 0; link_id < ARRAY_SIZE(sdata->link); link_id++) {
3224 struct ieee80211_link_data *link;
3226 link = sdata_dereference(sdata->link[link_id], sdata);
3230 __ieee80211_request_smps_mgd(sdata, link,
3231 link->u.mgd.req_smps);
3233 sdata_unlock(sdata);
3235 if (ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS))
3236 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
3238 ieee80211_recalc_ps(local);
3239 ieee80211_recalc_ps_vif(sdata);
3240 ieee80211_check_fast_rx_iface(sdata);
3245 static int ieee80211_set_cqm_rssi_config(struct wiphy *wiphy,
3246 struct net_device *dev,
3247 s32 rssi_thold, u32 rssi_hyst)
3249 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3250 struct ieee80211_vif *vif = &sdata->vif;
3251 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
3253 if (rssi_thold == bss_conf->cqm_rssi_thold &&
3254 rssi_hyst == bss_conf->cqm_rssi_hyst)
3257 if (sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER &&
3258 !(sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI))
3261 bss_conf->cqm_rssi_thold = rssi_thold;
3262 bss_conf->cqm_rssi_hyst = rssi_hyst;
3263 bss_conf->cqm_rssi_low = 0;
3264 bss_conf->cqm_rssi_high = 0;
3265 sdata->deflink.u.mgd.last_cqm_event_signal = 0;
3267 /* tell the driver upon association, unless already associated */
3268 if (sdata->u.mgd.associated &&
3269 sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)
3270 ieee80211_link_info_change_notify(sdata, &sdata->deflink,
3276 static int ieee80211_set_cqm_rssi_range_config(struct wiphy *wiphy,
3277 struct net_device *dev,
3278 s32 rssi_low, s32 rssi_high)
3280 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3281 struct ieee80211_vif *vif = &sdata->vif;
3282 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
3284 if (sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER)
3287 bss_conf->cqm_rssi_low = rssi_low;
3288 bss_conf->cqm_rssi_high = rssi_high;
3289 bss_conf->cqm_rssi_thold = 0;
3290 bss_conf->cqm_rssi_hyst = 0;
3291 sdata->deflink.u.mgd.last_cqm_event_signal = 0;
3293 /* tell the driver upon association, unless already associated */
3294 if (sdata->u.mgd.associated &&
3295 sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)
3296 ieee80211_link_info_change_notify(sdata, &sdata->deflink,
3302 static int ieee80211_set_bitrate_mask(struct wiphy *wiphy,
3303 struct net_device *dev,
3304 unsigned int link_id,
3306 const struct cfg80211_bitrate_mask *mask)
3308 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3309 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
3312 if (!ieee80211_sdata_running(sdata))
3316 * If active validate the setting and reject it if it doesn't leave
3317 * at least one basic rate usable, since we really have to be able
3318 * to send something, and if we're an AP we have to be able to do
3319 * so at a basic rate so that all clients can receive it.
3321 if (rcu_access_pointer(sdata->vif.bss_conf.chanctx_conf) &&
3322 sdata->vif.bss_conf.chandef.chan) {
3323 u32 basic_rates = sdata->vif.bss_conf.basic_rates;
3324 enum nl80211_band band = sdata->vif.bss_conf.chandef.chan->band;
3326 if (!(mask->control[band].legacy & basic_rates))
3330 if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) {
3331 ret = drv_set_bitrate_mask(local, sdata, mask);
3336 for (i = 0; i < NUM_NL80211_BANDS; i++) {
3337 struct ieee80211_supported_band *sband = wiphy->bands[i];
3340 sdata->rc_rateidx_mask[i] = mask->control[i].legacy;
3341 memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].ht_mcs,
3342 sizeof(mask->control[i].ht_mcs));
3343 memcpy(sdata->rc_rateidx_vht_mcs_mask[i],
3344 mask->control[i].vht_mcs,
3345 sizeof(mask->control[i].vht_mcs));
3347 sdata->rc_has_mcs_mask[i] = false;
3348 sdata->rc_has_vht_mcs_mask[i] = false;
3352 for (j = 0; j < IEEE80211_HT_MCS_MASK_LEN; j++) {
3353 if (sdata->rc_rateidx_mcs_mask[i][j] != 0xff) {
3354 sdata->rc_has_mcs_mask[i] = true;
3359 for (j = 0; j < NL80211_VHT_NSS_MAX; j++) {
3360 if (sdata->rc_rateidx_vht_mcs_mask[i][j] != 0xffff) {
3361 sdata->rc_has_vht_mcs_mask[i] = true;
3370 static int ieee80211_start_radar_detection(struct wiphy *wiphy,
3371 struct net_device *dev,
3372 struct cfg80211_chan_def *chandef,
3375 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3376 struct ieee80211_local *local = sdata->local;
3379 mutex_lock(&local->mtx);
3380 if (!list_empty(&local->roc_list) || local->scanning) {
3385 /* whatever, but channel contexts should not complain about that one */
3386 sdata->deflink.smps_mode = IEEE80211_SMPS_OFF;
3387 sdata->deflink.needed_rx_chains = local->rx_chains;
3389 err = ieee80211_link_use_channel(&sdata->deflink, chandef,
3390 IEEE80211_CHANCTX_SHARED);
3394 wiphy_delayed_work_queue(wiphy, &sdata->deflink.dfs_cac_timer_work,
3395 msecs_to_jiffies(cac_time_ms));
3398 mutex_unlock(&local->mtx);
3402 static void ieee80211_end_cac(struct wiphy *wiphy,
3403 struct net_device *dev)
3405 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3406 struct ieee80211_local *local = sdata->local;
3408 mutex_lock(&local->mtx);
3409 list_for_each_entry(sdata, &local->interfaces, list) {
3410 /* it might be waiting for the local->mtx, but then
3411 * by the time it gets it, sdata->wdev.cac_started
3412 * will no longer be true
3414 wiphy_delayed_work_cancel(wiphy,
3415 &sdata->deflink.dfs_cac_timer_work);
3417 if (sdata->wdev.cac_started) {
3418 ieee80211_link_release_channel(&sdata->deflink);
3419 sdata->wdev.cac_started = false;
3422 mutex_unlock(&local->mtx);
3425 static struct cfg80211_beacon_data *
3426 cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon)
3428 struct cfg80211_beacon_data *new_beacon;
3432 len = beacon->head_len + beacon->tail_len + beacon->beacon_ies_len +
3433 beacon->proberesp_ies_len + beacon->assocresp_ies_len +
3434 beacon->probe_resp_len + beacon->lci_len + beacon->civicloc_len;
3436 if (beacon->mbssid_ies)
3437 len += ieee80211_get_mbssid_beacon_len(beacon->mbssid_ies,
3439 beacon->mbssid_ies->cnt);
3441 new_beacon = kzalloc(sizeof(*new_beacon) + len, GFP_KERNEL);
3445 if (beacon->mbssid_ies && beacon->mbssid_ies->cnt) {
3446 new_beacon->mbssid_ies =
3447 kzalloc(struct_size(new_beacon->mbssid_ies,
3448 elem, beacon->mbssid_ies->cnt),
3450 if (!new_beacon->mbssid_ies) {
3455 if (beacon->rnr_ies && beacon->rnr_ies->cnt) {
3456 new_beacon->rnr_ies =
3457 kzalloc(struct_size(new_beacon->rnr_ies,
3458 elem, beacon->rnr_ies->cnt),
3460 if (!new_beacon->rnr_ies) {
3461 kfree(new_beacon->mbssid_ies);
3468 pos = (u8 *)(new_beacon + 1);
3469 if (beacon->head_len) {
3470 new_beacon->head_len = beacon->head_len;
3471 new_beacon->head = pos;
3472 memcpy(pos, beacon->head, beacon->head_len);
3473 pos += beacon->head_len;
3475 if (beacon->tail_len) {
3476 new_beacon->tail_len = beacon->tail_len;
3477 new_beacon->tail = pos;
3478 memcpy(pos, beacon->tail, beacon->tail_len);
3479 pos += beacon->tail_len;
3481 if (beacon->beacon_ies_len) {
3482 new_beacon->beacon_ies_len = beacon->beacon_ies_len;
3483 new_beacon->beacon_ies = pos;
3484 memcpy(pos, beacon->beacon_ies, beacon->beacon_ies_len);
3485 pos += beacon->beacon_ies_len;
3487 if (beacon->proberesp_ies_len) {
3488 new_beacon->proberesp_ies_len = beacon->proberesp_ies_len;
3489 new_beacon->proberesp_ies = pos;
3490 memcpy(pos, beacon->proberesp_ies, beacon->proberesp_ies_len);
3491 pos += beacon->proberesp_ies_len;
3493 if (beacon->assocresp_ies_len) {
3494 new_beacon->assocresp_ies_len = beacon->assocresp_ies_len;
3495 new_beacon->assocresp_ies = pos;
3496 memcpy(pos, beacon->assocresp_ies, beacon->assocresp_ies_len);
3497 pos += beacon->assocresp_ies_len;
3499 if (beacon->probe_resp_len) {
3500 new_beacon->probe_resp_len = beacon->probe_resp_len;
3501 new_beacon->probe_resp = pos;
3502 memcpy(pos, beacon->probe_resp, beacon->probe_resp_len);
3503 pos += beacon->probe_resp_len;
3505 if (beacon->mbssid_ies && beacon->mbssid_ies->cnt) {
3506 pos += ieee80211_copy_mbssid_beacon(pos,
3507 new_beacon->mbssid_ies,
3508 beacon->mbssid_ies);
3509 if (beacon->rnr_ies && beacon->rnr_ies->cnt)
3510 pos += ieee80211_copy_rnr_beacon(pos,
3511 new_beacon->rnr_ies,
3515 /* might copy -1, meaning no changes requested */
3516 new_beacon->ftm_responder = beacon->ftm_responder;
3518 new_beacon->lci_len = beacon->lci_len;
3519 new_beacon->lci = pos;
3520 memcpy(pos, beacon->lci, beacon->lci_len);
3521 pos += beacon->lci_len;
3523 if (beacon->civicloc) {
3524 new_beacon->civicloc_len = beacon->civicloc_len;
3525 new_beacon->civicloc = pos;
3526 memcpy(pos, beacon->civicloc, beacon->civicloc_len);
3527 pos += beacon->civicloc_len;
3533 void ieee80211_csa_finish(struct ieee80211_vif *vif)
3535 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
3536 struct ieee80211_local *local = sdata->local;
3540 if (vif->mbssid_tx_vif == vif) {
3541 /* Trigger ieee80211_csa_finish() on the non-transmitting
3542 * interfaces when channel switch is received on
3543 * transmitting interface
3545 struct ieee80211_sub_if_data *iter;
3547 list_for_each_entry_rcu(iter, &local->interfaces, list) {
3548 if (!ieee80211_sdata_running(iter))
3551 if (iter == sdata || iter->vif.mbssid_tx_vif != vif)
3554 wiphy_work_queue(iter->local->hw.wiphy,
3555 &iter->deflink.csa_finalize_work);
3558 wiphy_work_queue(local->hw.wiphy, &sdata->deflink.csa_finalize_work);
3562 EXPORT_SYMBOL(ieee80211_csa_finish);
3564 void ieee80211_channel_switch_disconnect(struct ieee80211_vif *vif, bool block_tx)
3566 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
3567 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
3568 struct ieee80211_local *local = sdata->local;
3570 sdata->deflink.csa_block_tx = block_tx;
3571 sdata_info(sdata, "channel switch failed, disconnecting\n");
3572 wiphy_work_queue(local->hw.wiphy, &ifmgd->csa_connection_drop_work);
3574 EXPORT_SYMBOL(ieee80211_channel_switch_disconnect);
3576 static int ieee80211_set_after_csa_beacon(struct ieee80211_sub_if_data *sdata,
3581 switch (sdata->vif.type) {
3582 case NL80211_IFTYPE_AP:
3583 if (!sdata->deflink.u.ap.next_beacon)
3586 err = ieee80211_assign_beacon(sdata, &sdata->deflink,
3587 sdata->deflink.u.ap.next_beacon,
3588 NULL, NULL, changed);
3589 ieee80211_free_next_beacon(&sdata->deflink);
3594 case NL80211_IFTYPE_ADHOC:
3595 err = ieee80211_ibss_finish_csa(sdata, changed);
3599 #ifdef CONFIG_MAC80211_MESH
3600 case NL80211_IFTYPE_MESH_POINT:
3601 err = ieee80211_mesh_finish_csa(sdata, changed);
3614 static int __ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata)
3616 struct ieee80211_local *local = sdata->local;
3620 sdata_assert_lock(sdata);
3621 lockdep_assert_held(&local->mtx);
3622 lockdep_assert_held(&local->chanctx_mtx);
3625 * using reservation isn't immediate as it may be deferred until later
3626 * with multi-vif. once reservation is complete it will re-schedule the
3627 * work with no reserved_chanctx so verify chandef to check if it
3628 * completed successfully
3631 if (sdata->deflink.reserved_chanctx) {
3633 * with multi-vif csa driver may call ieee80211_csa_finish()
3634 * many times while waiting for other interfaces to use their
3637 if (sdata->deflink.reserved_ready)
3640 return ieee80211_link_use_reserved_context(&sdata->deflink);
3643 if (!cfg80211_chandef_identical(&sdata->vif.bss_conf.chandef,
3644 &sdata->deflink.csa_chandef))
3647 sdata->vif.bss_conf.csa_active = false;
3649 err = ieee80211_set_after_csa_beacon(sdata, &changed);
3653 if (sdata->vif.bss_conf.eht_puncturing != sdata->vif.bss_conf.csa_punct_bitmap) {
3654 sdata->vif.bss_conf.eht_puncturing =
3655 sdata->vif.bss_conf.csa_punct_bitmap;
3656 changed |= BSS_CHANGED_EHT_PUNCTURING;
3659 ieee80211_link_info_change_notify(sdata, &sdata->deflink, changed);
3661 if (sdata->deflink.csa_block_tx) {
3662 ieee80211_wake_vif_queues(local, sdata,
3663 IEEE80211_QUEUE_STOP_REASON_CSA);
3664 sdata->deflink.csa_block_tx = false;
3667 err = drv_post_channel_switch(sdata);
3671 cfg80211_ch_switch_notify(sdata->dev, &sdata->deflink.csa_chandef, 0,
3672 sdata->vif.bss_conf.eht_puncturing);
3677 static void ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata)
3679 if (__ieee80211_csa_finalize(sdata)) {
3680 sdata_info(sdata, "failed to finalize CSA, disconnecting\n");
3681 cfg80211_stop_iface(sdata->local->hw.wiphy, &sdata->wdev,
3686 void ieee80211_csa_finalize_work(struct wiphy *wiphy, struct wiphy_work *work)
3688 struct ieee80211_sub_if_data *sdata =
3689 container_of(work, struct ieee80211_sub_if_data,
3690 deflink.csa_finalize_work);
3691 struct ieee80211_local *local = sdata->local;
3694 mutex_lock(&local->mtx);
3695 mutex_lock(&local->chanctx_mtx);
3697 /* AP might have been stopped while waiting for the lock. */
3698 if (!sdata->vif.bss_conf.csa_active)
3701 if (!ieee80211_sdata_running(sdata))
3704 ieee80211_csa_finalize(sdata);
3707 mutex_unlock(&local->chanctx_mtx);
3708 mutex_unlock(&local->mtx);
3709 sdata_unlock(sdata);
3712 static int ieee80211_set_csa_beacon(struct ieee80211_sub_if_data *sdata,
3713 struct cfg80211_csa_settings *params,
3716 struct ieee80211_csa_settings csa = {};
3719 switch (sdata->vif.type) {
3720 case NL80211_IFTYPE_AP:
3721 sdata->deflink.u.ap.next_beacon =
3722 cfg80211_beacon_dup(¶ms->beacon_after);
3723 if (!sdata->deflink.u.ap.next_beacon)
3727 * With a count of 0, we don't have to wait for any
3728 * TBTT before switching, so complete the CSA
3729 * immediately. In theory, with a count == 1 we
3730 * should delay the switch until just before the next
3731 * TBTT, but that would complicate things so we switch
3732 * immediately too. If we would delay the switch
3733 * until the next TBTT, we would have to set the probe
3736 * TODO: A channel switch with count <= 1 without
3737 * sending a CSA action frame is kind of useless,
3738 * because the clients won't know we're changing
3739 * channels. The action frame must be implemented
3740 * either here or in the userspace.
3742 if (params->count <= 1)
3745 if ((params->n_counter_offsets_beacon >
3746 IEEE80211_MAX_CNTDWN_COUNTERS_NUM) ||
3747 (params->n_counter_offsets_presp >
3748 IEEE80211_MAX_CNTDWN_COUNTERS_NUM)) {
3749 ieee80211_free_next_beacon(&sdata->deflink);
3753 csa.counter_offsets_beacon = params->counter_offsets_beacon;
3754 csa.counter_offsets_presp = params->counter_offsets_presp;
3755 csa.n_counter_offsets_beacon = params->n_counter_offsets_beacon;
3756 csa.n_counter_offsets_presp = params->n_counter_offsets_presp;
3757 csa.count = params->count;
3759 err = ieee80211_assign_beacon(sdata, &sdata->deflink,
3760 ¶ms->beacon_csa, &csa,
3763 ieee80211_free_next_beacon(&sdata->deflink);
3768 case NL80211_IFTYPE_ADHOC:
3769 if (!sdata->vif.cfg.ibss_joined)
3772 if (params->chandef.width != sdata->u.ibss.chandef.width)
3775 switch (params->chandef.width) {
3776 case NL80211_CHAN_WIDTH_40:
3777 if (cfg80211_get_chandef_type(¶ms->chandef) !=
3778 cfg80211_get_chandef_type(&sdata->u.ibss.chandef))
3781 case NL80211_CHAN_WIDTH_5:
3782 case NL80211_CHAN_WIDTH_10:
3783 case NL80211_CHAN_WIDTH_20_NOHT:
3784 case NL80211_CHAN_WIDTH_20:
3790 /* changes into another band are not supported */
3791 if (sdata->u.ibss.chandef.chan->band !=
3792 params->chandef.chan->band)
3795 /* see comments in the NL80211_IFTYPE_AP block */
3796 if (params->count > 1) {
3797 err = ieee80211_ibss_csa_beacon(sdata, params, changed);
3802 ieee80211_send_action_csa(sdata, params);
3805 #ifdef CONFIG_MAC80211_MESH
3806 case NL80211_IFTYPE_MESH_POINT: {
3807 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
3809 /* changes into another band are not supported */
3810 if (sdata->vif.bss_conf.chandef.chan->band !=
3811 params->chandef.chan->band)
3814 if (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_NONE) {
3815 ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_INIT;
3816 if (!ifmsh->pre_value)
3817 ifmsh->pre_value = 1;
3822 /* see comments in the NL80211_IFTYPE_AP block */
3823 if (params->count > 1) {
3824 err = ieee80211_mesh_csa_beacon(sdata, params, changed);
3826 ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_NONE;
3831 if (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_INIT)
3832 ieee80211_send_action_csa(sdata, params);
3844 static void ieee80211_color_change_abort(struct ieee80211_sub_if_data *sdata)
3846 sdata->vif.bss_conf.color_change_active = false;
3848 ieee80211_free_next_beacon(&sdata->deflink);
3850 cfg80211_color_change_aborted_notify(sdata->dev);
3854 __ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
3855 struct cfg80211_csa_settings *params)
3857 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3858 struct ieee80211_local *local = sdata->local;
3859 struct ieee80211_channel_switch ch_switch;
3860 struct ieee80211_chanctx_conf *conf;
3861 struct ieee80211_chanctx *chanctx;
3865 sdata_assert_lock(sdata);
3866 lockdep_assert_held(&local->mtx);
3868 if (!list_empty(&local->roc_list) || local->scanning)
3871 if (sdata->wdev.cac_started)
3874 if (cfg80211_chandef_identical(¶ms->chandef,
3875 &sdata->vif.bss_conf.chandef))
3878 /* don't allow another channel switch if one is already active. */
3879 if (sdata->vif.bss_conf.csa_active)
3882 mutex_lock(&local->chanctx_mtx);
3883 conf = rcu_dereference_protected(sdata->vif.bss_conf.chanctx_conf,
3884 lockdep_is_held(&local->chanctx_mtx));
3890 if (params->chandef.chan->freq_offset) {
3891 /* this may work, but is untested */
3896 chanctx = container_of(conf, struct ieee80211_chanctx, conf);
3898 ch_switch.timestamp = 0;
3899 ch_switch.device_timestamp = 0;
3900 ch_switch.block_tx = params->block_tx;
3901 ch_switch.chandef = params->chandef;
3902 ch_switch.count = params->count;
3904 err = drv_pre_channel_switch(sdata, &ch_switch);
3908 err = ieee80211_link_reserve_chanctx(&sdata->deflink, ¶ms->chandef,
3910 params->radar_required);
3914 /* if reservation is invalid then this will fail */
3915 err = ieee80211_check_combinations(sdata, NULL, chanctx->mode, 0);
3917 ieee80211_link_unreserve_chanctx(&sdata->deflink);
3921 /* if there is a color change in progress, abort it */
3922 if (sdata->vif.bss_conf.color_change_active)
3923 ieee80211_color_change_abort(sdata);
3925 err = ieee80211_set_csa_beacon(sdata, params, &changed);
3927 ieee80211_link_unreserve_chanctx(&sdata->deflink);
3931 if (params->punct_bitmap && !sdata->vif.bss_conf.eht_support)
3934 sdata->deflink.csa_chandef = params->chandef;
3935 sdata->deflink.csa_block_tx = params->block_tx;
3936 sdata->vif.bss_conf.csa_active = true;
3937 sdata->vif.bss_conf.csa_punct_bitmap = params->punct_bitmap;
3939 if (sdata->deflink.csa_block_tx)
3940 ieee80211_stop_vif_queues(local, sdata,
3941 IEEE80211_QUEUE_STOP_REASON_CSA);
3943 cfg80211_ch_switch_started_notify(sdata->dev,
3944 &sdata->deflink.csa_chandef, 0,
3945 params->count, params->block_tx,
3946 sdata->vif.bss_conf.csa_punct_bitmap);
3949 ieee80211_link_info_change_notify(sdata, &sdata->deflink,
3951 drv_channel_switch_beacon(sdata, ¶ms->chandef);
3953 /* if the beacon didn't change, we can finalize immediately */
3954 ieee80211_csa_finalize(sdata);
3958 mutex_unlock(&local->chanctx_mtx);
3962 int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
3963 struct cfg80211_csa_settings *params)
3965 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3966 struct ieee80211_local *local = sdata->local;
3969 mutex_lock(&local->mtx);
3970 err = __ieee80211_channel_switch(wiphy, dev, params);
3971 mutex_unlock(&local->mtx);
3976 u64 ieee80211_mgmt_tx_cookie(struct ieee80211_local *local)
3978 lockdep_assert_held(&local->mtx);
3980 local->roc_cookie_counter++;
3982 /* wow, you wrapped 64 bits ... more likely a bug */
3983 if (WARN_ON(local->roc_cookie_counter == 0))
3984 local->roc_cookie_counter++;
3986 return local->roc_cookie_counter;
3989 int ieee80211_attach_ack_skb(struct ieee80211_local *local, struct sk_buff *skb,
3990 u64 *cookie, gfp_t gfp)
3992 unsigned long spin_flags;
3993 struct sk_buff *ack_skb;
3996 ack_skb = skb_copy(skb, gfp);
4000 spin_lock_irqsave(&local->ack_status_lock, spin_flags);
4001 id = idr_alloc(&local->ack_status_frames, ack_skb,
4002 1, 0x2000, GFP_ATOMIC);
4003 spin_unlock_irqrestore(&local->ack_status_lock, spin_flags);
4010 IEEE80211_SKB_CB(skb)->status_data_idr = 1;
4011 IEEE80211_SKB_CB(skb)->status_data = id;
4013 *cookie = ieee80211_mgmt_tx_cookie(local);
4014 IEEE80211_SKB_CB(ack_skb)->ack.cookie = *cookie;
4020 ieee80211_update_mgmt_frame_registrations(struct wiphy *wiphy,
4021 struct wireless_dev *wdev,
4022 struct mgmt_frame_regs *upd)
4024 struct ieee80211_local *local = wiphy_priv(wiphy);
4025 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
4026 u32 preq_mask = BIT(IEEE80211_STYPE_PROBE_REQ >> 4);
4027 u32 action_mask = BIT(IEEE80211_STYPE_ACTION >> 4);
4028 bool global_change, intf_change;
4031 (local->probe_req_reg != !!(upd->global_stypes & preq_mask)) ||
4032 (local->rx_mcast_action_reg !=
4033 !!(upd->global_mcast_stypes & action_mask));
4034 local->probe_req_reg = upd->global_stypes & preq_mask;
4035 local->rx_mcast_action_reg = upd->global_mcast_stypes & action_mask;
4037 intf_change = (sdata->vif.probe_req_reg !=
4038 !!(upd->interface_stypes & preq_mask)) ||
4039 (sdata->vif.rx_mcast_action_reg !=
4040 !!(upd->interface_mcast_stypes & action_mask));
4041 sdata->vif.probe_req_reg = upd->interface_stypes & preq_mask;
4042 sdata->vif.rx_mcast_action_reg =
4043 upd->interface_mcast_stypes & action_mask;
4045 if (!local->open_count)
4048 if (intf_change && ieee80211_sdata_running(sdata))
4049 drv_config_iface_filter(local, sdata,
4050 sdata->vif.probe_req_reg ?
4055 ieee80211_configure_filter(local);
4058 static int ieee80211_set_antenna(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant)
4060 struct ieee80211_local *local = wiphy_priv(wiphy);
4065 return drv_set_antenna(local, tx_ant, rx_ant);
4068 static int ieee80211_get_antenna(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant)
4070 struct ieee80211_local *local = wiphy_priv(wiphy);
4072 return drv_get_antenna(local, tx_ant, rx_ant);
4075 static int ieee80211_set_rekey_data(struct wiphy *wiphy,
4076 struct net_device *dev,
4077 struct cfg80211_gtk_rekey_data *data)
4079 struct ieee80211_local *local = wiphy_priv(wiphy);
4080 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4082 if (!local->ops->set_rekey_data)
4085 drv_set_rekey_data(local, sdata, data);
4090 static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev,
4091 const u8 *peer, u64 *cookie)
4093 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4094 struct ieee80211_local *local = sdata->local;
4095 struct ieee80211_qos_hdr *nullfunc;
4096 struct sk_buff *skb;
4097 int size = sizeof(*nullfunc);
4100 struct ieee80211_tx_info *info;
4101 struct sta_info *sta;
4102 struct ieee80211_chanctx_conf *chanctx_conf;
4103 enum nl80211_band band;
4106 /* the lock is needed to assign the cookie later */
4107 mutex_lock(&local->mtx);
4110 sta = sta_info_get_bss(sdata, peer);
4118 chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf);
4119 if (WARN_ON(!chanctx_conf)) {
4123 band = chanctx_conf->def.chan->band;
4126 fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
4127 IEEE80211_STYPE_QOS_NULLFUNC |
4128 IEEE80211_FCTL_FROMDS);
4131 fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
4132 IEEE80211_STYPE_NULLFUNC |
4133 IEEE80211_FCTL_FROMDS);
4136 skb = dev_alloc_skb(local->hw.extra_tx_headroom + size);
4144 skb_reserve(skb, local->hw.extra_tx_headroom);
4146 nullfunc = skb_put(skb, size);
4147 nullfunc->frame_control = fc;
4148 nullfunc->duration_id = 0;
4149 memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN);
4150 memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN);
4151 memcpy(nullfunc->addr3, sdata->vif.addr, ETH_ALEN);
4152 nullfunc->seq_ctrl = 0;
4154 info = IEEE80211_SKB_CB(skb);
4156 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS |
4157 IEEE80211_TX_INTFL_NL80211_FRAME_TX;
4160 skb_set_queue_mapping(skb, IEEE80211_AC_VO);
4163 nullfunc->qos_ctrl = cpu_to_le16(7);
4165 ret = ieee80211_attach_ack_skb(local, skb, cookie, GFP_ATOMIC);
4172 ieee80211_xmit(sdata, sta, skb);
4178 mutex_unlock(&local->mtx);
4183 static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
4184 struct wireless_dev *wdev,
4185 unsigned int link_id,
4186 struct cfg80211_chan_def *chandef)
4188 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
4189 struct ieee80211_local *local = wiphy_priv(wiphy);
4190 struct ieee80211_chanctx_conf *chanctx_conf;
4191 struct ieee80211_link_data *link;
4195 link = rcu_dereference(sdata->link[link_id]);
4201 chanctx_conf = rcu_dereference(link->conf->chanctx_conf);
4203 *chandef = link->conf->chandef;
4205 } else if (local->open_count > 0 &&
4206 local->open_count == local->monitors &&
4207 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
4208 if (local->use_chanctx)
4209 *chandef = local->monitor_chandef;
4211 *chandef = local->_oper_chandef;
4221 static void ieee80211_set_wakeup(struct wiphy *wiphy, bool enabled)
4223 drv_set_wakeup(wiphy_priv(wiphy), enabled);
4227 static int ieee80211_set_qos_map(struct wiphy *wiphy,
4228 struct net_device *dev,
4229 struct cfg80211_qos_map *qos_map)
4231 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4232 struct mac80211_qos_map *new_qos_map, *old_qos_map;
4235 new_qos_map = kzalloc(sizeof(*new_qos_map), GFP_KERNEL);
4238 memcpy(&new_qos_map->qos_map, qos_map, sizeof(*qos_map));
4240 /* A NULL qos_map was passed to disable QoS mapping */
4244 old_qos_map = sdata_dereference(sdata->qos_map, sdata);
4245 rcu_assign_pointer(sdata->qos_map, new_qos_map);
4247 kfree_rcu(old_qos_map, rcu_head);
4252 static int ieee80211_set_ap_chanwidth(struct wiphy *wiphy,
4253 struct net_device *dev,
4254 unsigned int link_id,
4255 struct cfg80211_chan_def *chandef)
4257 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4258 struct ieee80211_link_data *link;
4262 link = sdata_dereference(sdata->link[link_id], sdata);
4264 ret = ieee80211_link_change_bandwidth(link, chandef, &changed);
4266 ieee80211_link_info_change_notify(sdata, link, changed);
4271 static int ieee80211_add_tx_ts(struct wiphy *wiphy, struct net_device *dev,
4272 u8 tsid, const u8 *peer, u8 up,
4275 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4276 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
4277 int ac = ieee802_1d_to_ac[up];
4279 if (sdata->vif.type != NL80211_IFTYPE_STATION)
4282 if (!(sdata->wmm_acm & BIT(up)))
4285 if (ifmgd->tx_tspec[ac].admitted_time)
4288 if (admitted_time) {
4289 ifmgd->tx_tspec[ac].admitted_time = 32 * admitted_time;
4290 ifmgd->tx_tspec[ac].tsid = tsid;
4291 ifmgd->tx_tspec[ac].up = up;
4297 static int ieee80211_del_tx_ts(struct wiphy *wiphy, struct net_device *dev,
4298 u8 tsid, const u8 *peer)
4300 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4301 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
4302 struct ieee80211_local *local = wiphy_priv(wiphy);
4305 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
4306 struct ieee80211_sta_tx_tspec *tx_tspec = &ifmgd->tx_tspec[ac];
4308 /* skip unused entries */
4309 if (!tx_tspec->admitted_time)
4312 if (tx_tspec->tsid != tsid)
4315 /* due to this new packets will be reassigned to non-ACM ACs */
4318 /* Make sure that all packets have been sent to avoid to
4319 * restore the QoS params on packets that are still on the
4323 ieee80211_flush_queues(local, sdata, false);
4325 /* restore the normal QoS parameters
4326 * (unconditionally to avoid races)
4328 tx_tspec->action = TX_TSPEC_ACTION_STOP_DOWNGRADE;
4329 tx_tspec->downgraded = false;
4330 ieee80211_sta_handle_tspec_ac_params(sdata);
4332 /* finally clear all the data */
4333 memset(tx_tspec, 0, sizeof(*tx_tspec));
4341 void ieee80211_nan_func_terminated(struct ieee80211_vif *vif,
4343 enum nl80211_nan_func_term_reason reason,
4346 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
4347 struct cfg80211_nan_func *func;
4350 if (WARN_ON(vif->type != NL80211_IFTYPE_NAN))
4353 spin_lock_bh(&sdata->u.nan.func_lock);
4355 func = idr_find(&sdata->u.nan.function_inst_ids, inst_id);
4356 if (WARN_ON(!func)) {
4357 spin_unlock_bh(&sdata->u.nan.func_lock);
4361 cookie = func->cookie;
4362 idr_remove(&sdata->u.nan.function_inst_ids, inst_id);
4364 spin_unlock_bh(&sdata->u.nan.func_lock);
4366 cfg80211_free_nan_func(func);
4368 cfg80211_nan_func_terminated(ieee80211_vif_to_wdev(vif), inst_id,
4369 reason, cookie, gfp);
4371 EXPORT_SYMBOL(ieee80211_nan_func_terminated);
4373 void ieee80211_nan_func_match(struct ieee80211_vif *vif,
4374 struct cfg80211_nan_match_params *match,
4377 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
4378 struct cfg80211_nan_func *func;
4380 if (WARN_ON(vif->type != NL80211_IFTYPE_NAN))
4383 spin_lock_bh(&sdata->u.nan.func_lock);
4385 func = idr_find(&sdata->u.nan.function_inst_ids, match->inst_id);
4386 if (WARN_ON(!func)) {
4387 spin_unlock_bh(&sdata->u.nan.func_lock);
4390 match->cookie = func->cookie;
4392 spin_unlock_bh(&sdata->u.nan.func_lock);
4394 cfg80211_nan_match(ieee80211_vif_to_wdev(vif), match, gfp);
4396 EXPORT_SYMBOL(ieee80211_nan_func_match);
4398 static int ieee80211_set_multicast_to_unicast(struct wiphy *wiphy,
4399 struct net_device *dev,
4402 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4404 sdata->u.ap.multicast_to_unicast = enabled;
4409 void ieee80211_fill_txq_stats(struct cfg80211_txq_stats *txqstats,
4410 struct txq_info *txqi)
4412 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_BACKLOG_BYTES))) {
4413 txqstats->filled |= BIT(NL80211_TXQ_STATS_BACKLOG_BYTES);
4414 txqstats->backlog_bytes = txqi->tin.backlog_bytes;
4417 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_BACKLOG_PACKETS))) {
4418 txqstats->filled |= BIT(NL80211_TXQ_STATS_BACKLOG_PACKETS);
4419 txqstats->backlog_packets = txqi->tin.backlog_packets;
4422 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_FLOWS))) {
4423 txqstats->filled |= BIT(NL80211_TXQ_STATS_FLOWS);
4424 txqstats->flows = txqi->tin.flows;
4427 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_DROPS))) {
4428 txqstats->filled |= BIT(NL80211_TXQ_STATS_DROPS);
4429 txqstats->drops = txqi->cstats.drop_count;
4432 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_ECN_MARKS))) {
4433 txqstats->filled |= BIT(NL80211_TXQ_STATS_ECN_MARKS);
4434 txqstats->ecn_marks = txqi->cstats.ecn_mark;
4437 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_OVERLIMIT))) {
4438 txqstats->filled |= BIT(NL80211_TXQ_STATS_OVERLIMIT);
4439 txqstats->overlimit = txqi->tin.overlimit;
4442 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_COLLISIONS))) {
4443 txqstats->filled |= BIT(NL80211_TXQ_STATS_COLLISIONS);
4444 txqstats->collisions = txqi->tin.collisions;
4447 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_TX_BYTES))) {
4448 txqstats->filled |= BIT(NL80211_TXQ_STATS_TX_BYTES);
4449 txqstats->tx_bytes = txqi->tin.tx_bytes;
4452 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_TX_PACKETS))) {
4453 txqstats->filled |= BIT(NL80211_TXQ_STATS_TX_PACKETS);
4454 txqstats->tx_packets = txqi->tin.tx_packets;
4458 static int ieee80211_get_txq_stats(struct wiphy *wiphy,
4459 struct wireless_dev *wdev,
4460 struct cfg80211_txq_stats *txqstats)
4462 struct ieee80211_local *local = wiphy_priv(wiphy);
4463 struct ieee80211_sub_if_data *sdata;
4466 spin_lock_bh(&local->fq.lock);
4470 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
4471 if (!sdata->vif.txq) {
4475 ieee80211_fill_txq_stats(txqstats, to_txq_info(sdata->vif.txq));
4478 txqstats->filled |= BIT(NL80211_TXQ_STATS_BACKLOG_PACKETS) |
4479 BIT(NL80211_TXQ_STATS_BACKLOG_BYTES) |
4480 BIT(NL80211_TXQ_STATS_OVERLIMIT) |
4481 BIT(NL80211_TXQ_STATS_OVERMEMORY) |
4482 BIT(NL80211_TXQ_STATS_COLLISIONS) |
4483 BIT(NL80211_TXQ_STATS_MAX_FLOWS);
4484 txqstats->backlog_packets = local->fq.backlog;
4485 txqstats->backlog_bytes = local->fq.memory_usage;
4486 txqstats->overlimit = local->fq.overlimit;
4487 txqstats->overmemory = local->fq.overmemory;
4488 txqstats->collisions = local->fq.collisions;
4489 txqstats->max_flows = local->fq.flows_cnt;
4494 spin_unlock_bh(&local->fq.lock);
4500 ieee80211_get_ftm_responder_stats(struct wiphy *wiphy,
4501 struct net_device *dev,
4502 struct cfg80211_ftm_responder_stats *ftm_stats)
4504 struct ieee80211_local *local = wiphy_priv(wiphy);
4505 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4507 return drv_get_ftm_responder_stats(local, sdata, ftm_stats);
4511 ieee80211_start_pmsr(struct wiphy *wiphy, struct wireless_dev *dev,
4512 struct cfg80211_pmsr_request *request)
4514 struct ieee80211_local *local = wiphy_priv(wiphy);
4515 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(dev);
4517 return drv_start_pmsr(local, sdata, request);
4521 ieee80211_abort_pmsr(struct wiphy *wiphy, struct wireless_dev *dev,
4522 struct cfg80211_pmsr_request *request)
4524 struct ieee80211_local *local = wiphy_priv(wiphy);
4525 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(dev);
4527 return drv_abort_pmsr(local, sdata, request);
4530 static int ieee80211_set_tid_config(struct wiphy *wiphy,
4531 struct net_device *dev,
4532 struct cfg80211_tid_config *tid_conf)
4534 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4535 struct sta_info *sta;
4537 lockdep_assert_wiphy(sdata->local->hw.wiphy);
4539 if (!sdata->local->ops->set_tid_config)
4542 if (!tid_conf->peer)
4543 return drv_set_tid_config(sdata->local, sdata, NULL, tid_conf);
4545 sta = sta_info_get_bss(sdata, tid_conf->peer);
4549 return drv_set_tid_config(sdata->local, sdata, &sta->sta, tid_conf);
4552 static int ieee80211_reset_tid_config(struct wiphy *wiphy,
4553 struct net_device *dev,
4554 const u8 *peer, u8 tids)
4556 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4557 struct sta_info *sta;
4559 lockdep_assert_wiphy(sdata->local->hw.wiphy);
4561 if (!sdata->local->ops->reset_tid_config)
4565 return drv_reset_tid_config(sdata->local, sdata, NULL, tids);
4567 sta = sta_info_get_bss(sdata, peer);
4571 return drv_reset_tid_config(sdata->local, sdata, &sta->sta, tids);
4574 static int ieee80211_set_sar_specs(struct wiphy *wiphy,
4575 struct cfg80211_sar_specs *sar)
4577 struct ieee80211_local *local = wiphy_priv(wiphy);
4579 if (!local->ops->set_sar_specs)
4582 return local->ops->set_sar_specs(&local->hw, sar);
4586 ieee80211_set_after_color_change_beacon(struct ieee80211_sub_if_data *sdata,
4589 switch (sdata->vif.type) {
4590 case NL80211_IFTYPE_AP: {
4593 if (!sdata->deflink.u.ap.next_beacon)
4596 ret = ieee80211_assign_beacon(sdata, &sdata->deflink,
4597 sdata->deflink.u.ap.next_beacon,
4598 NULL, NULL, changed);
4599 ieee80211_free_next_beacon(&sdata->deflink);
4615 ieee80211_set_color_change_beacon(struct ieee80211_sub_if_data *sdata,
4616 struct cfg80211_color_change_settings *params,
4619 struct ieee80211_color_change_settings color_change = {};
4622 switch (sdata->vif.type) {
4623 case NL80211_IFTYPE_AP:
4624 sdata->deflink.u.ap.next_beacon =
4625 cfg80211_beacon_dup(¶ms->beacon_next);
4626 if (!sdata->deflink.u.ap.next_beacon)
4629 if (params->count <= 1)
4632 color_change.counter_offset_beacon =
4633 params->counter_offset_beacon;
4634 color_change.counter_offset_presp =
4635 params->counter_offset_presp;
4636 color_change.count = params->count;
4638 err = ieee80211_assign_beacon(sdata, &sdata->deflink,
4639 ¶ms->beacon_color_change,
4640 NULL, &color_change, changed);
4642 ieee80211_free_next_beacon(&sdata->deflink);
4654 ieee80211_color_change_bss_config_notify(struct ieee80211_sub_if_data *sdata,
4655 u8 color, int enable, u64 changed)
4657 sdata->vif.bss_conf.he_bss_color.color = color;
4658 sdata->vif.bss_conf.he_bss_color.enabled = enable;
4659 changed |= BSS_CHANGED_HE_BSS_COLOR;
4661 ieee80211_link_info_change_notify(sdata, &sdata->deflink, changed);
4663 if (!sdata->vif.bss_conf.nontransmitted && sdata->vif.mbssid_tx_vif) {
4664 struct ieee80211_sub_if_data *child;
4666 mutex_lock(&sdata->local->iflist_mtx);
4667 list_for_each_entry(child, &sdata->local->interfaces, list) {
4668 if (child != sdata && child->vif.mbssid_tx_vif == &sdata->vif) {
4669 child->vif.bss_conf.he_bss_color.color = color;
4670 child->vif.bss_conf.he_bss_color.enabled = enable;
4671 ieee80211_link_info_change_notify(child,
4673 BSS_CHANGED_HE_BSS_COLOR);
4676 mutex_unlock(&sdata->local->iflist_mtx);
4680 static int ieee80211_color_change_finalize(struct ieee80211_sub_if_data *sdata)
4682 struct ieee80211_local *local = sdata->local;
4686 sdata_assert_lock(sdata);
4687 lockdep_assert_held(&local->mtx);
4689 sdata->vif.bss_conf.color_change_active = false;
4691 err = ieee80211_set_after_color_change_beacon(sdata, &changed);
4693 cfg80211_color_change_aborted_notify(sdata->dev);
4697 ieee80211_color_change_bss_config_notify(sdata,
4698 sdata->vif.bss_conf.color_change_color,
4700 cfg80211_color_change_notify(sdata->dev);
4705 void ieee80211_color_change_finalize_work(struct wiphy *wiphy,
4706 struct wiphy_work *work)
4708 struct ieee80211_sub_if_data *sdata =
4709 container_of(work, struct ieee80211_sub_if_data,
4710 deflink.color_change_finalize_work);
4711 struct ieee80211_local *local = sdata->local;
4714 mutex_lock(&local->mtx);
4716 /* AP might have been stopped while waiting for the lock. */
4717 if (!sdata->vif.bss_conf.color_change_active)
4720 if (!ieee80211_sdata_running(sdata))
4723 ieee80211_color_change_finalize(sdata);
4726 mutex_unlock(&local->mtx);
4727 sdata_unlock(sdata);
4730 void ieee80211_color_collision_detection_work(struct work_struct *work)
4732 struct delayed_work *delayed_work = to_delayed_work(work);
4733 struct ieee80211_link_data *link =
4734 container_of(delayed_work, struct ieee80211_link_data,
4735 color_collision_detect_work);
4736 struct ieee80211_sub_if_data *sdata = link->sdata;
4739 cfg80211_obss_color_collision_notify(sdata->dev, link->color_bitmap);
4740 sdata_unlock(sdata);
4743 void ieee80211_color_change_finish(struct ieee80211_vif *vif)
4745 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
4747 wiphy_work_queue(sdata->local->hw.wiphy,
4748 &sdata->deflink.color_change_finalize_work);
4750 EXPORT_SYMBOL_GPL(ieee80211_color_change_finish);
4753 ieee80211_obss_color_collision_notify(struct ieee80211_vif *vif,
4754 u64 color_bitmap, gfp_t gfp)
4756 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
4757 struct ieee80211_link_data *link = &sdata->deflink;
4759 if (sdata->vif.bss_conf.color_change_active || sdata->vif.bss_conf.csa_active)
4762 if (delayed_work_pending(&link->color_collision_detect_work))
4765 link->color_bitmap = color_bitmap;
4766 /* queue the color collision detection event every 500 ms in order to
4767 * avoid sending too much netlink messages to userspace.
4769 ieee80211_queue_delayed_work(&sdata->local->hw,
4770 &link->color_collision_detect_work,
4771 msecs_to_jiffies(500));
4773 EXPORT_SYMBOL_GPL(ieee80211_obss_color_collision_notify);
4776 ieee80211_color_change(struct wiphy *wiphy, struct net_device *dev,
4777 struct cfg80211_color_change_settings *params)
4779 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4780 struct ieee80211_local *local = sdata->local;
4784 sdata_assert_lock(sdata);
4786 if (sdata->vif.bss_conf.nontransmitted)
4789 mutex_lock(&local->mtx);
4791 /* don't allow another color change if one is already active or if csa
4794 if (sdata->vif.bss_conf.color_change_active || sdata->vif.bss_conf.csa_active) {
4799 err = ieee80211_set_color_change_beacon(sdata, params, &changed);
4803 sdata->vif.bss_conf.color_change_active = true;
4804 sdata->vif.bss_conf.color_change_color = params->color;
4806 cfg80211_color_change_started_notify(sdata->dev, params->count);
4809 ieee80211_color_change_bss_config_notify(sdata, 0, 0, changed);
4811 /* if the beacon didn't change, we can finalize immediately */
4812 ieee80211_color_change_finalize(sdata);
4815 mutex_unlock(&local->mtx);
4821 ieee80211_set_radar_background(struct wiphy *wiphy,
4822 struct cfg80211_chan_def *chandef)
4824 struct ieee80211_local *local = wiphy_priv(wiphy);
4826 if (!local->ops->set_radar_background)
4829 return local->ops->set_radar_background(&local->hw, chandef);
4832 static int ieee80211_add_intf_link(struct wiphy *wiphy,
4833 struct wireless_dev *wdev,
4834 unsigned int link_id)
4836 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
4839 if (wdev->use_4addr)
4842 mutex_lock(&sdata->local->mtx);
4843 res = ieee80211_vif_set_links(sdata, wdev->valid_links, 0);
4844 mutex_unlock(&sdata->local->mtx);
4849 static void ieee80211_del_intf_link(struct wiphy *wiphy,
4850 struct wireless_dev *wdev,
4851 unsigned int link_id)
4853 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
4855 mutex_lock(&sdata->local->mtx);
4856 ieee80211_vif_set_links(sdata, wdev->valid_links, 0);
4857 mutex_unlock(&sdata->local->mtx);
4860 static int sta_add_link_station(struct ieee80211_local *local,
4861 struct ieee80211_sub_if_data *sdata,
4862 struct link_station_parameters *params)
4864 struct sta_info *sta;
4867 sta = sta_info_get_bss(sdata, params->mld_mac);
4871 if (!sta->sta.valid_links)
4874 if (sta->sta.valid_links & BIT(params->link_id))
4877 ret = ieee80211_sta_allocate_link(sta, params->link_id);
4881 ret = sta_link_apply_parameters(local, sta, true, params);
4883 ieee80211_sta_free_link(sta, params->link_id);
4887 /* ieee80211_sta_activate_link frees the link upon failure */
4888 return ieee80211_sta_activate_link(sta, params->link_id);
4892 ieee80211_add_link_station(struct wiphy *wiphy, struct net_device *dev,
4893 struct link_station_parameters *params)
4895 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4896 struct ieee80211_local *local = wiphy_priv(wiphy);
4898 lockdep_assert_wiphy(sdata->local->hw.wiphy);
4900 return sta_add_link_station(local, sdata, params);
4903 static int sta_mod_link_station(struct ieee80211_local *local,
4904 struct ieee80211_sub_if_data *sdata,
4905 struct link_station_parameters *params)
4907 struct sta_info *sta;
4909 sta = sta_info_get_bss(sdata, params->mld_mac);
4913 if (!(sta->sta.valid_links & BIT(params->link_id)))
4916 return sta_link_apply_parameters(local, sta, false, params);
4920 ieee80211_mod_link_station(struct wiphy *wiphy, struct net_device *dev,
4921 struct link_station_parameters *params)
4923 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4924 struct ieee80211_local *local = wiphy_priv(wiphy);
4926 lockdep_assert_wiphy(sdata->local->hw.wiphy);
4928 return sta_mod_link_station(local, sdata, params);
4931 static int sta_del_link_station(struct ieee80211_sub_if_data *sdata,
4932 struct link_station_del_parameters *params)
4934 struct sta_info *sta;
4936 sta = sta_info_get_bss(sdata, params->mld_mac);
4940 if (!(sta->sta.valid_links & BIT(params->link_id)))
4943 /* must not create a STA without links */
4944 if (sta->sta.valid_links == BIT(params->link_id))
4947 ieee80211_sta_remove_link(sta, params->link_id);
4953 ieee80211_del_link_station(struct wiphy *wiphy, struct net_device *dev,
4954 struct link_station_del_parameters *params)
4956 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4958 lockdep_assert_wiphy(sdata->local->hw.wiphy);
4960 return sta_del_link_station(sdata, params);
4963 static int ieee80211_set_hw_timestamp(struct wiphy *wiphy,
4964 struct net_device *dev,
4965 struct cfg80211_set_hw_timestamp *hwts)
4967 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4968 struct ieee80211_local *local = sdata->local;
4970 if (!local->ops->set_hw_timestamp)
4973 if (!check_sdata_in_driver(sdata))
4976 return local->ops->set_hw_timestamp(&local->hw, &sdata->vif, hwts);
4979 const struct cfg80211_ops mac80211_config_ops = {
4980 .add_virtual_intf = ieee80211_add_iface,
4981 .del_virtual_intf = ieee80211_del_iface,
4982 .change_virtual_intf = ieee80211_change_iface,
4983 .start_p2p_device = ieee80211_start_p2p_device,
4984 .stop_p2p_device = ieee80211_stop_p2p_device,
4985 .add_key = ieee80211_add_key,
4986 .del_key = ieee80211_del_key,
4987 .get_key = ieee80211_get_key,
4988 .set_default_key = ieee80211_config_default_key,
4989 .set_default_mgmt_key = ieee80211_config_default_mgmt_key,
4990 .set_default_beacon_key = ieee80211_config_default_beacon_key,
4991 .start_ap = ieee80211_start_ap,
4992 .change_beacon = ieee80211_change_beacon,
4993 .stop_ap = ieee80211_stop_ap,
4994 .add_station = ieee80211_add_station,
4995 .del_station = ieee80211_del_station,
4996 .change_station = ieee80211_change_station,
4997 .get_station = ieee80211_get_station,
4998 .dump_station = ieee80211_dump_station,
4999 .dump_survey = ieee80211_dump_survey,
5000 #ifdef CONFIG_MAC80211_MESH
5001 .add_mpath = ieee80211_add_mpath,
5002 .del_mpath = ieee80211_del_mpath,
5003 .change_mpath = ieee80211_change_mpath,
5004 .get_mpath = ieee80211_get_mpath,
5005 .dump_mpath = ieee80211_dump_mpath,
5006 .get_mpp = ieee80211_get_mpp,
5007 .dump_mpp = ieee80211_dump_mpp,
5008 .update_mesh_config = ieee80211_update_mesh_config,
5009 .get_mesh_config = ieee80211_get_mesh_config,
5010 .join_mesh = ieee80211_join_mesh,
5011 .leave_mesh = ieee80211_leave_mesh,
5013 .join_ocb = ieee80211_join_ocb,
5014 .leave_ocb = ieee80211_leave_ocb,
5015 .change_bss = ieee80211_change_bss,
5016 .inform_bss = ieee80211_inform_bss,
5017 .set_txq_params = ieee80211_set_txq_params,
5018 .set_monitor_channel = ieee80211_set_monitor_channel,
5019 .suspend = ieee80211_suspend,
5020 .resume = ieee80211_resume,
5021 .scan = ieee80211_scan,
5022 .abort_scan = ieee80211_abort_scan,
5023 .sched_scan_start = ieee80211_sched_scan_start,
5024 .sched_scan_stop = ieee80211_sched_scan_stop,
5025 .auth = ieee80211_auth,
5026 .assoc = ieee80211_assoc,
5027 .deauth = ieee80211_deauth,
5028 .disassoc = ieee80211_disassoc,
5029 .join_ibss = ieee80211_join_ibss,
5030 .leave_ibss = ieee80211_leave_ibss,
5031 .set_mcast_rate = ieee80211_set_mcast_rate,
5032 .set_wiphy_params = ieee80211_set_wiphy_params,
5033 .set_tx_power = ieee80211_set_tx_power,
5034 .get_tx_power = ieee80211_get_tx_power,
5035 .rfkill_poll = ieee80211_rfkill_poll,
5036 CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd)
5037 CFG80211_TESTMODE_DUMP(ieee80211_testmode_dump)
5038 .set_power_mgmt = ieee80211_set_power_mgmt,
5039 .set_bitrate_mask = ieee80211_set_bitrate_mask,
5040 .remain_on_channel = ieee80211_remain_on_channel,
5041 .cancel_remain_on_channel = ieee80211_cancel_remain_on_channel,
5042 .mgmt_tx = ieee80211_mgmt_tx,
5043 .mgmt_tx_cancel_wait = ieee80211_mgmt_tx_cancel_wait,
5044 .set_cqm_rssi_config = ieee80211_set_cqm_rssi_config,
5045 .set_cqm_rssi_range_config = ieee80211_set_cqm_rssi_range_config,
5046 .update_mgmt_frame_registrations =
5047 ieee80211_update_mgmt_frame_registrations,
5048 .set_antenna = ieee80211_set_antenna,
5049 .get_antenna = ieee80211_get_antenna,
5050 .set_rekey_data = ieee80211_set_rekey_data,
5051 .tdls_oper = ieee80211_tdls_oper,
5052 .tdls_mgmt = ieee80211_tdls_mgmt,
5053 .tdls_channel_switch = ieee80211_tdls_channel_switch,
5054 .tdls_cancel_channel_switch = ieee80211_tdls_cancel_channel_switch,
5055 .probe_client = ieee80211_probe_client,
5056 .set_noack_map = ieee80211_set_noack_map,
5058 .set_wakeup = ieee80211_set_wakeup,
5060 .get_channel = ieee80211_cfg_get_channel,
5061 .start_radar_detection = ieee80211_start_radar_detection,
5062 .end_cac = ieee80211_end_cac,
5063 .channel_switch = ieee80211_channel_switch,
5064 .set_qos_map = ieee80211_set_qos_map,
5065 .set_ap_chanwidth = ieee80211_set_ap_chanwidth,
5066 .add_tx_ts = ieee80211_add_tx_ts,
5067 .del_tx_ts = ieee80211_del_tx_ts,
5068 .start_nan = ieee80211_start_nan,
5069 .stop_nan = ieee80211_stop_nan,
5070 .nan_change_conf = ieee80211_nan_change_conf,
5071 .add_nan_func = ieee80211_add_nan_func,
5072 .del_nan_func = ieee80211_del_nan_func,
5073 .set_multicast_to_unicast = ieee80211_set_multicast_to_unicast,
5074 .tx_control_port = ieee80211_tx_control_port,
5075 .get_txq_stats = ieee80211_get_txq_stats,
5076 .get_ftm_responder_stats = ieee80211_get_ftm_responder_stats,
5077 .start_pmsr = ieee80211_start_pmsr,
5078 .abort_pmsr = ieee80211_abort_pmsr,
5079 .probe_mesh_link = ieee80211_probe_mesh_link,
5080 .set_tid_config = ieee80211_set_tid_config,
5081 .reset_tid_config = ieee80211_reset_tid_config,
5082 .set_sar_specs = ieee80211_set_sar_specs,
5083 .color_change = ieee80211_color_change,
5084 .set_radar_background = ieee80211_set_radar_background,
5085 .add_intf_link = ieee80211_add_intf_link,
5086 .del_intf_link = ieee80211_del_intf_link,
5087 .add_link_station = ieee80211_add_link_station,
5088 .mod_link_station = ieee80211_mod_link_station,
5089 .del_link_station = ieee80211_del_link_station,
5090 .set_hw_timestamp = ieee80211_set_hw_timestamp,