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 lockdep_assert_wiphy(sdata->local->hw.wiphy);
266 ret = ieee80211_check_combinations(sdata, NULL, 0, 0);
270 return ieee80211_do_open(wdev, true);
273 static void ieee80211_stop_p2p_device(struct wiphy *wiphy,
274 struct wireless_dev *wdev)
276 ieee80211_sdata_stop(IEEE80211_WDEV_TO_SUB_IF(wdev));
279 static int ieee80211_start_nan(struct wiphy *wiphy,
280 struct wireless_dev *wdev,
281 struct cfg80211_nan_conf *conf)
283 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
286 lockdep_assert_wiphy(sdata->local->hw.wiphy);
288 ret = ieee80211_check_combinations(sdata, NULL, 0, 0);
292 ret = ieee80211_do_open(wdev, true);
296 ret = drv_start_nan(sdata->local, sdata, conf);
298 ieee80211_sdata_stop(sdata);
300 sdata->u.nan.conf = *conf;
305 static void ieee80211_stop_nan(struct wiphy *wiphy,
306 struct wireless_dev *wdev)
308 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
310 drv_stop_nan(sdata->local, sdata);
311 ieee80211_sdata_stop(sdata);
314 static int ieee80211_nan_change_conf(struct wiphy *wiphy,
315 struct wireless_dev *wdev,
316 struct cfg80211_nan_conf *conf,
319 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
320 struct cfg80211_nan_conf new_conf;
323 if (sdata->vif.type != NL80211_IFTYPE_NAN)
326 if (!ieee80211_sdata_running(sdata))
329 new_conf = sdata->u.nan.conf;
331 if (changes & CFG80211_NAN_CONF_CHANGED_PREF)
332 new_conf.master_pref = conf->master_pref;
334 if (changes & CFG80211_NAN_CONF_CHANGED_BANDS)
335 new_conf.bands = conf->bands;
337 ret = drv_nan_change_conf(sdata->local, sdata, &new_conf, changes);
339 sdata->u.nan.conf = new_conf;
344 static int ieee80211_add_nan_func(struct wiphy *wiphy,
345 struct wireless_dev *wdev,
346 struct cfg80211_nan_func *nan_func)
348 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
351 if (sdata->vif.type != NL80211_IFTYPE_NAN)
354 if (!ieee80211_sdata_running(sdata))
357 spin_lock_bh(&sdata->u.nan.func_lock);
359 ret = idr_alloc(&sdata->u.nan.function_inst_ids,
360 nan_func, 1, sdata->local->hw.max_nan_de_entries + 1,
362 spin_unlock_bh(&sdata->u.nan.func_lock);
367 nan_func->instance_id = ret;
369 WARN_ON(nan_func->instance_id == 0);
371 ret = drv_add_nan_func(sdata->local, sdata, nan_func);
373 spin_lock_bh(&sdata->u.nan.func_lock);
374 idr_remove(&sdata->u.nan.function_inst_ids,
375 nan_func->instance_id);
376 spin_unlock_bh(&sdata->u.nan.func_lock);
382 static struct cfg80211_nan_func *
383 ieee80211_find_nan_func_by_cookie(struct ieee80211_sub_if_data *sdata,
386 struct cfg80211_nan_func *func;
389 lockdep_assert_held(&sdata->u.nan.func_lock);
391 idr_for_each_entry(&sdata->u.nan.function_inst_ids, func, id) {
392 if (func->cookie == cookie)
399 static void ieee80211_del_nan_func(struct wiphy *wiphy,
400 struct wireless_dev *wdev, u64 cookie)
402 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
403 struct cfg80211_nan_func *func;
406 if (sdata->vif.type != NL80211_IFTYPE_NAN ||
407 !ieee80211_sdata_running(sdata))
410 spin_lock_bh(&sdata->u.nan.func_lock);
412 func = ieee80211_find_nan_func_by_cookie(sdata, cookie);
414 instance_id = func->instance_id;
416 spin_unlock_bh(&sdata->u.nan.func_lock);
419 drv_del_nan_func(sdata->local, sdata, instance_id);
422 static int ieee80211_set_noack_map(struct wiphy *wiphy,
423 struct net_device *dev,
426 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
428 sdata->noack_map = noack_map;
430 ieee80211_check_fast_xmit_iface(sdata);
435 static int ieee80211_set_tx(struct ieee80211_sub_if_data *sdata,
436 const u8 *mac_addr, u8 key_idx)
438 struct ieee80211_local *local = sdata->local;
439 struct ieee80211_key *key;
440 struct sta_info *sta;
443 if (!wiphy_ext_feature_isset(local->hw.wiphy,
444 NL80211_EXT_FEATURE_EXT_KEY_ID))
447 sta = sta_info_get_bss(sdata, mac_addr);
452 if (sta->ptk_idx == key_idx)
455 key = wiphy_dereference(local->hw.wiphy, sta->ptk[key_idx]);
457 if (key && key->conf.flags & IEEE80211_KEY_FLAG_NO_AUTO_TX)
458 ret = ieee80211_set_tx_key(key);
463 static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
464 int link_id, u8 key_idx, bool pairwise,
465 const u8 *mac_addr, struct key_params *params)
467 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
468 struct ieee80211_link_data *link =
469 ieee80211_link_or_deflink(sdata, link_id, false);
470 struct ieee80211_local *local = sdata->local;
471 struct sta_info *sta = NULL;
472 struct ieee80211_key *key;
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 = sdata_dereference(sdata->link[link_id], sdata);
582 struct sta_info *sta;
583 struct link_sta_info *link_sta;
585 sta = sta_info_get_bss(sdata, mac_addr);
590 link_sta = rcu_dereference_check(sta->link[link_id],
591 lockdep_is_held(&local->hw.wiphy->mtx));
595 link_sta = &sta->deflink;
598 if (pairwise && key_idx < NUM_DEFAULT_KEYS)
599 return wiphy_dereference(local->hw.wiphy,
603 key_idx < NUM_DEFAULT_KEYS +
604 NUM_DEFAULT_MGMT_KEYS +
605 NUM_DEFAULT_BEACON_KEYS)
606 return wiphy_dereference(local->hw.wiphy,
607 link_sta->gtk[key_idx]);
612 if (pairwise && key_idx < NUM_DEFAULT_KEYS)
613 return wiphy_dereference(local->hw.wiphy, sdata->keys[key_idx]);
615 key = wiphy_dereference(local->hw.wiphy, link->gtk[key_idx]);
619 /* or maybe it was a WEP key */
620 if (key_idx < NUM_DEFAULT_KEYS)
621 return wiphy_dereference(local->hw.wiphy, sdata->keys[key_idx]);
626 static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
627 int link_id, u8 key_idx, bool pairwise,
630 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
631 struct ieee80211_local *local = sdata->local;
632 struct ieee80211_key *key;
634 lockdep_assert_wiphy(local->hw.wiphy);
636 key = ieee80211_lookup_key(sdata, link_id, key_idx, pairwise, mac_addr);
640 ieee80211_key_free(key, sdata->vif.type == NL80211_IFTYPE_STATION);
645 static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
646 int link_id, u8 key_idx, bool pairwise,
647 const u8 *mac_addr, void *cookie,
648 void (*callback)(void *cookie,
649 struct key_params *params))
651 struct ieee80211_sub_if_data *sdata;
653 struct key_params params;
654 struct ieee80211_key *key;
659 struct ieee80211_key_seq kseq = {};
661 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
665 key = ieee80211_lookup_key(sdata, link_id, key_idx, pairwise, mac_addr);
669 memset(¶ms, 0, sizeof(params));
671 params.cipher = key->conf.cipher;
673 switch (key->conf.cipher) {
674 case WLAN_CIPHER_SUITE_TKIP:
675 pn64 = atomic64_read(&key->conf.tx_pn);
676 iv32 = TKIP_PN_TO_IV32(pn64);
677 iv16 = TKIP_PN_TO_IV16(pn64);
679 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE &&
680 !(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
681 drv_get_key_seq(sdata->local, key, &kseq);
682 iv32 = kseq.tkip.iv32;
683 iv16 = kseq.tkip.iv16;
686 seq[0] = iv16 & 0xff;
687 seq[1] = (iv16 >> 8) & 0xff;
688 seq[2] = iv32 & 0xff;
689 seq[3] = (iv32 >> 8) & 0xff;
690 seq[4] = (iv32 >> 16) & 0xff;
691 seq[5] = (iv32 >> 24) & 0xff;
695 case WLAN_CIPHER_SUITE_CCMP:
696 case WLAN_CIPHER_SUITE_CCMP_256:
697 case WLAN_CIPHER_SUITE_AES_CMAC:
698 case WLAN_CIPHER_SUITE_BIP_CMAC_256:
699 BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
700 offsetof(typeof(kseq), aes_cmac));
702 case WLAN_CIPHER_SUITE_BIP_GMAC_128:
703 case WLAN_CIPHER_SUITE_BIP_GMAC_256:
704 BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
705 offsetof(typeof(kseq), aes_gmac));
707 case WLAN_CIPHER_SUITE_GCMP:
708 case WLAN_CIPHER_SUITE_GCMP_256:
709 BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
710 offsetof(typeof(kseq), gcmp));
712 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE &&
713 !(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
714 drv_get_key_seq(sdata->local, key, &kseq);
715 memcpy(seq, kseq.ccmp.pn, 6);
717 pn64 = atomic64_read(&key->conf.tx_pn);
729 if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
731 if (WARN_ON(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV))
733 drv_get_key_seq(sdata->local, key, &kseq);
734 params.seq = kseq.hw.seq;
735 params.seq_len = kseq.hw.seq_len;
739 params.key = key->conf.key;
740 params.key_len = key->conf.keylen;
742 callback(cookie, ¶ms);
750 static int ieee80211_config_default_key(struct wiphy *wiphy,
751 struct net_device *dev,
752 int link_id, u8 key_idx, bool uni,
755 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
756 struct ieee80211_link_data *link =
757 ieee80211_link_or_deflink(sdata, link_id, false);
760 return PTR_ERR(link);
762 ieee80211_set_default_key(link, key_idx, uni, multi);
767 static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy,
768 struct net_device *dev,
769 int link_id, u8 key_idx)
771 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
772 struct ieee80211_link_data *link =
773 ieee80211_link_or_deflink(sdata, link_id, true);
776 return PTR_ERR(link);
778 ieee80211_set_default_mgmt_key(link, key_idx);
783 static int ieee80211_config_default_beacon_key(struct wiphy *wiphy,
784 struct net_device *dev,
785 int link_id, u8 key_idx)
787 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
788 struct ieee80211_link_data *link =
789 ieee80211_link_or_deflink(sdata, link_id, true);
792 return PTR_ERR(link);
794 ieee80211_set_default_beacon_key(link, key_idx);
799 void sta_set_rate_info_tx(struct sta_info *sta,
800 const struct ieee80211_tx_rate *rate,
801 struct rate_info *rinfo)
804 if (rate->flags & IEEE80211_TX_RC_MCS) {
805 rinfo->flags |= RATE_INFO_FLAGS_MCS;
806 rinfo->mcs = rate->idx;
807 } else if (rate->flags & IEEE80211_TX_RC_VHT_MCS) {
808 rinfo->flags |= RATE_INFO_FLAGS_VHT_MCS;
809 rinfo->mcs = ieee80211_rate_get_vht_mcs(rate);
810 rinfo->nss = ieee80211_rate_get_vht_nss(rate);
812 struct ieee80211_supported_band *sband;
814 sband = ieee80211_get_sband(sta->sdata);
815 WARN_ON_ONCE(sband && !sband->bitrates);
816 if (sband && sband->bitrates)
817 rinfo->legacy = sband->bitrates[rate->idx].bitrate;
819 if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
820 rinfo->bw = RATE_INFO_BW_40;
821 else if (rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH)
822 rinfo->bw = RATE_INFO_BW_80;
823 else if (rate->flags & IEEE80211_TX_RC_160_MHZ_WIDTH)
824 rinfo->bw = RATE_INFO_BW_160;
826 rinfo->bw = RATE_INFO_BW_20;
827 if (rate->flags & IEEE80211_TX_RC_SHORT_GI)
828 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI;
831 static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev,
832 int idx, u8 *mac, struct station_info *sinfo)
834 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
835 struct ieee80211_local *local = sdata->local;
836 struct sta_info *sta;
839 lockdep_assert_wiphy(local->hw.wiphy);
841 sta = sta_info_get_by_idx(sdata, idx);
844 memcpy(mac, sta->sta.addr, ETH_ALEN);
845 sta_set_sinfo(sta, sinfo, true);
851 static int ieee80211_dump_survey(struct wiphy *wiphy, struct net_device *dev,
852 int idx, struct survey_info *survey)
854 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
856 return drv_get_survey(local, idx, survey);
859 static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev,
860 const u8 *mac, struct station_info *sinfo)
862 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
863 struct ieee80211_local *local = sdata->local;
864 struct sta_info *sta;
867 lockdep_assert_wiphy(local->hw.wiphy);
869 sta = sta_info_get_bss(sdata, mac);
872 sta_set_sinfo(sta, sinfo, true);
878 static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
879 struct cfg80211_chan_def *chandef)
881 struct ieee80211_local *local = wiphy_priv(wiphy);
882 struct ieee80211_sub_if_data *sdata;
885 lockdep_assert_wiphy(local->hw.wiphy);
887 if (cfg80211_chandef_identical(&local->monitor_chandef, chandef))
890 if (local->use_chanctx) {
891 sdata = wiphy_dereference(local->hw.wiphy,
892 local->monitor_sdata);
894 ieee80211_link_release_channel(&sdata->deflink);
895 ret = ieee80211_link_use_channel(&sdata->deflink,
897 IEEE80211_CHANCTX_EXCLUSIVE);
900 if (local->open_count == local->monitors) {
901 local->_oper_chandef = *chandef;
902 ieee80211_hw_config(local, 0);
907 local->monitor_chandef = *chandef;
913 ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata,
914 const u8 *resp, size_t resp_len,
915 const struct ieee80211_csa_settings *csa,
916 const struct ieee80211_color_change_settings *cca,
917 struct ieee80211_link_data *link)
919 struct probe_resp *new, *old;
921 if (!resp || !resp_len)
924 old = sdata_dereference(link->u.ap.probe_resp, sdata);
926 new = kzalloc(sizeof(struct probe_resp) + resp_len, GFP_KERNEL);
931 memcpy(new->data, resp, resp_len);
934 memcpy(new->cntdwn_counter_offsets, csa->counter_offsets_presp,
935 csa->n_counter_offsets_presp *
936 sizeof(new->cntdwn_counter_offsets[0]));
938 new->cntdwn_counter_offsets[0] = cca->counter_offset_presp;
940 rcu_assign_pointer(link->u.ap.probe_resp, new);
942 kfree_rcu(old, rcu_head);
947 static int ieee80211_set_fils_discovery(struct ieee80211_sub_if_data *sdata,
948 struct cfg80211_fils_discovery *params,
949 struct ieee80211_link_data *link,
950 struct ieee80211_bss_conf *link_conf)
952 struct fils_discovery_data *new, *old = NULL;
953 struct ieee80211_fils_discovery *fd;
958 fd = &link_conf->fils_discovery;
959 fd->min_interval = params->min_interval;
960 fd->max_interval = params->max_interval;
962 old = sdata_dereference(link->u.ap.fils_discovery, sdata);
964 kfree_rcu(old, rcu_head);
966 if (params->tmpl && params->tmpl_len) {
967 new = kzalloc(sizeof(*new) + params->tmpl_len, GFP_KERNEL);
970 new->len = params->tmpl_len;
971 memcpy(new->data, params->tmpl, params->tmpl_len);
972 rcu_assign_pointer(link->u.ap.fils_discovery, new);
974 RCU_INIT_POINTER(link->u.ap.fils_discovery, NULL);
977 return BSS_CHANGED_FILS_DISCOVERY;
981 ieee80211_set_unsol_bcast_probe_resp(struct ieee80211_sub_if_data *sdata,
982 struct cfg80211_unsol_bcast_probe_resp *params,
983 struct ieee80211_link_data *link,
984 struct ieee80211_bss_conf *link_conf)
986 struct unsol_bcast_probe_resp_data *new, *old = NULL;
991 link_conf->unsol_bcast_probe_resp_interval = params->interval;
993 old = sdata_dereference(link->u.ap.unsol_bcast_probe_resp, sdata);
995 kfree_rcu(old, rcu_head);
997 if (params->tmpl && params->tmpl_len) {
998 new = kzalloc(sizeof(*new) + params->tmpl_len, GFP_KERNEL);
1001 new->len = params->tmpl_len;
1002 memcpy(new->data, params->tmpl, params->tmpl_len);
1003 rcu_assign_pointer(link->u.ap.unsol_bcast_probe_resp, new);
1005 RCU_INIT_POINTER(link->u.ap.unsol_bcast_probe_resp, NULL);
1008 return BSS_CHANGED_UNSOL_BCAST_PROBE_RESP;
1011 static int ieee80211_set_ftm_responder_params(
1012 struct ieee80211_sub_if_data *sdata,
1013 const u8 *lci, size_t lci_len,
1014 const u8 *civicloc, size_t civicloc_len,
1015 struct ieee80211_bss_conf *link_conf)
1017 struct ieee80211_ftm_responder_params *new, *old;
1021 if (!lci_len && !civicloc_len)
1024 old = link_conf->ftmr_params;
1025 len = lci_len + civicloc_len;
1027 new = kzalloc(sizeof(*new) + len, GFP_KERNEL);
1031 pos = (u8 *)(new + 1);
1033 new->lci_len = lci_len;
1035 memcpy(pos, lci, lci_len);
1040 new->civicloc_len = civicloc_len;
1041 new->civicloc = pos;
1042 memcpy(pos, civicloc, civicloc_len);
1043 pos += civicloc_len;
1046 link_conf->ftmr_params = new;
1053 ieee80211_copy_mbssid_beacon(u8 *pos, struct cfg80211_mbssid_elems *dst,
1054 struct cfg80211_mbssid_elems *src)
1058 for (i = 0; i < src->cnt; i++) {
1059 memcpy(pos + offset, src->elem[i].data, src->elem[i].len);
1060 dst->elem[i].len = src->elem[i].len;
1061 dst->elem[i].data = pos + offset;
1062 offset += dst->elem[i].len;
1064 dst->cnt = src->cnt;
1070 ieee80211_copy_rnr_beacon(u8 *pos, struct cfg80211_rnr_elems *dst,
1071 struct cfg80211_rnr_elems *src)
1075 for (i = 0; i < src->cnt; i++) {
1076 memcpy(pos + offset, src->elem[i].data, src->elem[i].len);
1077 dst->elem[i].len = src->elem[i].len;
1078 dst->elem[i].data = pos + offset;
1079 offset += dst->elem[i].len;
1081 dst->cnt = src->cnt;
1087 ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
1088 struct ieee80211_link_data *link,
1089 struct cfg80211_beacon_data *params,
1090 const struct ieee80211_csa_settings *csa,
1091 const struct ieee80211_color_change_settings *cca,
1094 struct cfg80211_mbssid_elems *mbssid = NULL;
1095 struct cfg80211_rnr_elems *rnr = NULL;
1096 struct beacon_data *new, *old;
1097 int new_head_len, new_tail_len;
1099 u64 _changed = BSS_CHANGED_BEACON;
1100 struct ieee80211_bss_conf *link_conf = link->conf;
1102 old = sdata_dereference(link->u.ap.beacon, sdata);
1104 /* Need to have a beacon head if we don't have one yet */
1105 if (!params->head && !old)
1108 /* new or old head? */
1110 new_head_len = params->head_len;
1112 new_head_len = old->head_len;
1114 /* new or old tail? */
1115 if (params->tail || !old)
1116 /* params->tail_len will be zero for !params->tail */
1117 new_tail_len = params->tail_len;
1119 new_tail_len = old->tail_len;
1121 size = sizeof(*new) + new_head_len + new_tail_len;
1123 /* new or old multiple BSSID elements? */
1124 if (params->mbssid_ies) {
1125 mbssid = params->mbssid_ies;
1126 size += struct_size(new->mbssid_ies, elem, mbssid->cnt);
1127 if (params->rnr_ies) {
1128 rnr = params->rnr_ies;
1129 size += struct_size(new->rnr_ies, elem, rnr->cnt);
1131 size += ieee80211_get_mbssid_beacon_len(mbssid, rnr,
1133 } else if (old && old->mbssid_ies) {
1134 mbssid = old->mbssid_ies;
1135 size += struct_size(new->mbssid_ies, elem, mbssid->cnt);
1136 if (old && old->rnr_ies) {
1138 size += struct_size(new->rnr_ies, elem, rnr->cnt);
1140 size += ieee80211_get_mbssid_beacon_len(mbssid, rnr,
1144 new = kzalloc(size, GFP_KERNEL);
1148 /* start filling the new info now */
1151 * pointers go into the block we allocated,
1152 * memory is | beacon_data | head | tail | mbssid_ies | rnr_ies
1154 new->head = ((u8 *) new) + sizeof(*new);
1155 new->tail = new->head + new_head_len;
1156 new->head_len = new_head_len;
1157 new->tail_len = new_tail_len;
1158 /* copy in optional mbssid_ies */
1160 u8 *pos = new->tail + new->tail_len;
1162 new->mbssid_ies = (void *)pos;
1163 pos += struct_size(new->mbssid_ies, elem, mbssid->cnt);
1164 pos += ieee80211_copy_mbssid_beacon(pos, new->mbssid_ies,
1167 new->rnr_ies = (void *)pos;
1168 pos += struct_size(new->rnr_ies, elem, rnr->cnt);
1169 ieee80211_copy_rnr_beacon(pos, new->rnr_ies, rnr);
1171 /* update bssid_indicator */
1172 link_conf->bssid_indicator =
1173 ilog2(__roundup_pow_of_two(mbssid->cnt + 1));
1177 new->cntdwn_current_counter = csa->count;
1178 memcpy(new->cntdwn_counter_offsets, csa->counter_offsets_beacon,
1179 csa->n_counter_offsets_beacon *
1180 sizeof(new->cntdwn_counter_offsets[0]));
1182 new->cntdwn_current_counter = cca->count;
1183 new->cntdwn_counter_offsets[0] = cca->counter_offset_beacon;
1188 memcpy(new->head, params->head, new_head_len);
1190 memcpy(new->head, old->head, new_head_len);
1192 /* copy in optional tail */
1194 memcpy(new->tail, params->tail, new_tail_len);
1197 memcpy(new->tail, old->tail, new_tail_len);
1199 err = ieee80211_set_probe_resp(sdata, params->probe_resp,
1200 params->probe_resp_len, csa, cca, link);
1206 _changed |= BSS_CHANGED_AP_PROBE_RESP;
1208 if (params->ftm_responder != -1) {
1209 link_conf->ftm_responder = params->ftm_responder;
1210 err = ieee80211_set_ftm_responder_params(sdata,
1214 params->civicloc_len,
1222 _changed |= BSS_CHANGED_FTM_RESPONDER;
1225 rcu_assign_pointer(link->u.ap.beacon, new);
1226 sdata->u.ap.active = true;
1229 kfree_rcu(old, rcu_head);
1231 *changed |= _changed;
1235 static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
1236 struct cfg80211_ap_settings *params)
1238 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1239 struct ieee80211_local *local = sdata->local;
1240 struct beacon_data *old;
1241 struct ieee80211_sub_if_data *vlan;
1242 u64 changed = BSS_CHANGED_BEACON_INT |
1243 BSS_CHANGED_BEACON_ENABLED |
1244 BSS_CHANGED_BEACON |
1245 BSS_CHANGED_P2P_PS |
1246 BSS_CHANGED_TXPOWER |
1249 int prev_beacon_int;
1250 unsigned int link_id = params->beacon.link_id;
1251 struct ieee80211_link_data *link;
1252 struct ieee80211_bss_conf *link_conf;
1254 lockdep_assert_wiphy(local->hw.wiphy);
1256 link = sdata_dereference(sdata->link[link_id], sdata);
1260 link_conf = link->conf;
1262 old = sdata_dereference(link->u.ap.beacon, sdata);
1266 if (params->smps_mode != NL80211_SMPS_OFF)
1269 link->smps_mode = IEEE80211_SMPS_OFF;
1271 link->needed_rx_chains = sdata->local->rx_chains;
1273 prev_beacon_int = link_conf->beacon_int;
1274 link_conf->beacon_int = params->beacon_interval;
1277 link_conf->ht_ldpc =
1278 params->ht_cap->cap_info &
1279 cpu_to_le16(IEEE80211_HT_CAP_LDPC_CODING);
1281 if (params->vht_cap) {
1282 link_conf->vht_ldpc =
1283 params->vht_cap->vht_cap_info &
1284 cpu_to_le32(IEEE80211_VHT_CAP_RXLDPC);
1285 link_conf->vht_su_beamformer =
1286 params->vht_cap->vht_cap_info &
1287 cpu_to_le32(IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE);
1288 link_conf->vht_su_beamformee =
1289 params->vht_cap->vht_cap_info &
1290 cpu_to_le32(IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE);
1291 link_conf->vht_mu_beamformer =
1292 params->vht_cap->vht_cap_info &
1293 cpu_to_le32(IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE);
1294 link_conf->vht_mu_beamformee =
1295 params->vht_cap->vht_cap_info &
1296 cpu_to_le32(IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE);
1299 if (params->he_cap && params->he_oper) {
1300 link_conf->he_support = true;
1301 link_conf->htc_trig_based_pkt_ext =
1302 le32_get_bits(params->he_oper->he_oper_params,
1303 IEEE80211_HE_OPERATION_DFLT_PE_DURATION_MASK);
1304 link_conf->frame_time_rts_th =
1305 le32_get_bits(params->he_oper->he_oper_params,
1306 IEEE80211_HE_OPERATION_RTS_THRESHOLD_MASK);
1307 changed |= BSS_CHANGED_HE_OBSS_PD;
1309 if (params->beacon.he_bss_color.enabled)
1310 changed |= BSS_CHANGED_HE_BSS_COLOR;
1313 if (params->he_cap) {
1314 link_conf->he_ldpc =
1315 params->he_cap->phy_cap_info[1] &
1316 IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD;
1317 link_conf->he_su_beamformer =
1318 params->he_cap->phy_cap_info[3] &
1319 IEEE80211_HE_PHY_CAP3_SU_BEAMFORMER;
1320 link_conf->he_su_beamformee =
1321 params->he_cap->phy_cap_info[4] &
1322 IEEE80211_HE_PHY_CAP4_SU_BEAMFORMEE;
1323 link_conf->he_mu_beamformer =
1324 params->he_cap->phy_cap_info[4] &
1325 IEEE80211_HE_PHY_CAP4_MU_BEAMFORMER;
1326 link_conf->he_full_ul_mumimo =
1327 params->he_cap->phy_cap_info[2] &
1328 IEEE80211_HE_PHY_CAP2_UL_MU_FULL_MU_MIMO;
1331 if (params->eht_cap) {
1332 if (!link_conf->he_support)
1335 link_conf->eht_support = true;
1336 link_conf->eht_puncturing = params->punct_bitmap;
1337 changed |= BSS_CHANGED_EHT_PUNCTURING;
1339 link_conf->eht_su_beamformer =
1340 params->eht_cap->fixed.phy_cap_info[0] &
1341 IEEE80211_EHT_PHY_CAP0_SU_BEAMFORMER;
1342 link_conf->eht_su_beamformee =
1343 params->eht_cap->fixed.phy_cap_info[0] &
1344 IEEE80211_EHT_PHY_CAP0_SU_BEAMFORMEE;
1345 link_conf->eht_mu_beamformer =
1346 params->eht_cap->fixed.phy_cap_info[7] &
1347 (IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_80MHZ |
1348 IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_160MHZ |
1349 IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_320MHZ);
1351 link_conf->eht_su_beamformer = false;
1352 link_conf->eht_su_beamformee = false;
1353 link_conf->eht_mu_beamformer = false;
1356 if (sdata->vif.type == NL80211_IFTYPE_AP &&
1357 params->mbssid_config.tx_wdev) {
1358 err = ieee80211_set_ap_mbssid_options(sdata,
1359 params->mbssid_config,
1365 err = ieee80211_link_use_channel(link, ¶ms->chandef,
1366 IEEE80211_CHANCTX_SHARED);
1368 ieee80211_link_copy_chanctx_to_vlans(link, false);
1370 link_conf->beacon_int = prev_beacon_int;
1375 * Apply control port protocol, this allows us to
1376 * not encrypt dynamic WEP control frames.
1378 sdata->control_port_protocol = params->crypto.control_port_ethertype;
1379 sdata->control_port_no_encrypt = params->crypto.control_port_no_encrypt;
1380 sdata->control_port_over_nl80211 =
1381 params->crypto.control_port_over_nl80211;
1382 sdata->control_port_no_preauth =
1383 params->crypto.control_port_no_preauth;
1385 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) {
1386 vlan->control_port_protocol =
1387 params->crypto.control_port_ethertype;
1388 vlan->control_port_no_encrypt =
1389 params->crypto.control_port_no_encrypt;
1390 vlan->control_port_over_nl80211 =
1391 params->crypto.control_port_over_nl80211;
1392 vlan->control_port_no_preauth =
1393 params->crypto.control_port_no_preauth;
1396 link_conf->dtim_period = params->dtim_period;
1397 link_conf->enable_beacon = true;
1398 link_conf->allow_p2p_go_ps = sdata->vif.p2p;
1399 link_conf->twt_responder = params->twt_responder;
1400 link_conf->he_obss_pd = params->he_obss_pd;
1401 link_conf->he_bss_color = params->beacon.he_bss_color;
1402 sdata->vif.cfg.s1g = params->chandef.chan->band ==
1405 sdata->vif.cfg.ssid_len = params->ssid_len;
1406 if (params->ssid_len)
1407 memcpy(sdata->vif.cfg.ssid, params->ssid,
1409 link_conf->hidden_ssid =
1410 (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE);
1412 memset(&link_conf->p2p_noa_attr, 0,
1413 sizeof(link_conf->p2p_noa_attr));
1414 link_conf->p2p_noa_attr.oppps_ctwindow =
1415 params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
1416 if (params->p2p_opp_ps)
1417 link_conf->p2p_noa_attr.oppps_ctwindow |=
1418 IEEE80211_P2P_OPPPS_ENABLE_BIT;
1420 sdata->beacon_rate_set = false;
1421 if (wiphy_ext_feature_isset(local->hw.wiphy,
1422 NL80211_EXT_FEATURE_BEACON_RATE_LEGACY)) {
1423 for (i = 0; i < NUM_NL80211_BANDS; i++) {
1424 sdata->beacon_rateidx_mask[i] =
1425 params->beacon_rate.control[i].legacy;
1426 if (sdata->beacon_rateidx_mask[i])
1427 sdata->beacon_rate_set = true;
1431 if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL))
1432 link_conf->beacon_tx_rate = params->beacon_rate;
1434 err = ieee80211_assign_beacon(sdata, link, ¶ms->beacon, NULL, NULL,
1439 err = ieee80211_set_fils_discovery(sdata, ¶ms->fils_discovery,
1445 err = ieee80211_set_unsol_bcast_probe_resp(sdata,
1446 ¶ms->unsol_bcast_probe_resp,
1452 err = drv_start_ap(sdata->local, sdata, link_conf);
1454 old = sdata_dereference(link->u.ap.beacon, sdata);
1457 kfree_rcu(old, rcu_head);
1458 RCU_INIT_POINTER(link->u.ap.beacon, NULL);
1459 sdata->u.ap.active = false;
1463 ieee80211_recalc_dtim(local, sdata);
1464 ieee80211_vif_cfg_change_notify(sdata, BSS_CHANGED_SSID);
1465 ieee80211_link_info_change_notify(sdata, link, changed);
1467 netif_carrier_on(dev);
1468 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
1469 netif_carrier_on(vlan->dev);
1474 ieee80211_link_release_channel(link);
1479 static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev,
1480 struct cfg80211_ap_update *params)
1483 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1484 struct ieee80211_link_data *link;
1485 struct cfg80211_beacon_data *beacon = ¶ms->beacon;
1486 struct beacon_data *old;
1488 struct ieee80211_bss_conf *link_conf;
1491 lockdep_assert_wiphy(wiphy);
1493 link = sdata_dereference(sdata->link[beacon->link_id], sdata);
1497 link_conf = link->conf;
1499 /* don't allow changing the beacon while a countdown is in place - offset
1500 * of channel switch counter may change
1502 if (link_conf->csa_active || link_conf->color_change_active)
1505 old = sdata_dereference(link->u.ap.beacon, sdata);
1509 err = ieee80211_assign_beacon(sdata, link, beacon, NULL, NULL,
1514 err = ieee80211_set_fils_discovery(sdata, ¶ms->fils_discovery,
1520 err = ieee80211_set_unsol_bcast_probe_resp(sdata,
1521 ¶ms->unsol_bcast_probe_resp,
1527 if (beacon->he_bss_color_valid &&
1528 beacon->he_bss_color.enabled != link_conf->he_bss_color.enabled) {
1529 link_conf->he_bss_color.enabled = beacon->he_bss_color.enabled;
1530 changed |= BSS_CHANGED_HE_BSS_COLOR;
1533 ieee80211_link_info_change_notify(sdata, link, changed);
1537 static void ieee80211_free_next_beacon(struct ieee80211_link_data *link)
1539 if (!link->u.ap.next_beacon)
1542 kfree(link->u.ap.next_beacon->mbssid_ies);
1543 kfree(link->u.ap.next_beacon->rnr_ies);
1544 kfree(link->u.ap.next_beacon);
1545 link->u.ap.next_beacon = NULL;
1548 static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev,
1549 unsigned int link_id)
1551 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1552 struct ieee80211_sub_if_data *vlan;
1553 struct ieee80211_local *local = sdata->local;
1554 struct beacon_data *old_beacon;
1555 struct probe_resp *old_probe_resp;
1556 struct fils_discovery_data *old_fils_discovery;
1557 struct unsol_bcast_probe_resp_data *old_unsol_bcast_probe_resp;
1558 struct cfg80211_chan_def chandef;
1559 struct ieee80211_link_data *link =
1560 sdata_dereference(sdata->link[link_id], sdata);
1561 struct ieee80211_bss_conf *link_conf = link->conf;
1563 lockdep_assert_wiphy(local->hw.wiphy);
1565 old_beacon = sdata_dereference(link->u.ap.beacon, sdata);
1568 old_probe_resp = sdata_dereference(link->u.ap.probe_resp,
1570 old_fils_discovery = sdata_dereference(link->u.ap.fils_discovery,
1572 old_unsol_bcast_probe_resp =
1573 sdata_dereference(link->u.ap.unsol_bcast_probe_resp,
1576 /* abort any running channel switch or color change */
1577 link_conf->csa_active = false;
1578 link_conf->color_change_active = false;
1579 if (link->csa_block_tx) {
1580 ieee80211_wake_vif_queues(local, sdata,
1581 IEEE80211_QUEUE_STOP_REASON_CSA);
1582 link->csa_block_tx = false;
1585 ieee80211_free_next_beacon(link);
1587 /* turn off carrier for this interface and dependent VLANs */
1588 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
1589 netif_carrier_off(vlan->dev);
1590 netif_carrier_off(dev);
1592 /* remove beacon and probe response */
1593 sdata->u.ap.active = false;
1594 RCU_INIT_POINTER(link->u.ap.beacon, NULL);
1595 RCU_INIT_POINTER(link->u.ap.probe_resp, NULL);
1596 RCU_INIT_POINTER(link->u.ap.fils_discovery, NULL);
1597 RCU_INIT_POINTER(link->u.ap.unsol_bcast_probe_resp, NULL);
1598 kfree_rcu(old_beacon, rcu_head);
1600 kfree_rcu(old_probe_resp, rcu_head);
1601 if (old_fils_discovery)
1602 kfree_rcu(old_fils_discovery, rcu_head);
1603 if (old_unsol_bcast_probe_resp)
1604 kfree_rcu(old_unsol_bcast_probe_resp, rcu_head);
1606 kfree(link_conf->ftmr_params);
1607 link_conf->ftmr_params = NULL;
1609 sdata->vif.mbssid_tx_vif = NULL;
1610 link_conf->bssid_index = 0;
1611 link_conf->nontransmitted = false;
1612 link_conf->ema_ap = false;
1613 link_conf->bssid_indicator = 0;
1615 __sta_info_flush(sdata, true);
1616 ieee80211_free_keys(sdata, true);
1618 link_conf->enable_beacon = false;
1619 sdata->beacon_rate_set = false;
1620 sdata->vif.cfg.ssid_len = 0;
1621 clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state);
1622 ieee80211_link_info_change_notify(sdata, link,
1623 BSS_CHANGED_BEACON_ENABLED);
1625 if (sdata->wdev.cac_started) {
1626 chandef = link_conf->chandef;
1627 wiphy_delayed_work_cancel(wiphy, &link->dfs_cac_timer_work);
1628 cfg80211_cac_event(sdata->dev, &chandef,
1629 NL80211_RADAR_CAC_ABORTED,
1633 drv_stop_ap(sdata->local, sdata, link_conf);
1635 /* free all potentially still buffered bcast frames */
1636 local->total_ps_buffered -= skb_queue_len(&sdata->u.ap.ps.bc_buf);
1637 ieee80211_purge_tx_queue(&local->hw, &sdata->u.ap.ps.bc_buf);
1639 ieee80211_link_copy_chanctx_to_vlans(link, true);
1640 ieee80211_link_release_channel(link);
1645 static int sta_apply_auth_flags(struct ieee80211_local *local,
1646 struct sta_info *sta,
1651 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
1652 set & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
1653 !test_sta_flag(sta, WLAN_STA_AUTH)) {
1654 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
1659 if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
1660 set & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
1661 !test_sta_flag(sta, WLAN_STA_ASSOC)) {
1663 * When peer becomes associated, init rate control as
1664 * well. Some drivers require rate control initialized
1665 * before drv_sta_state() is called.
1667 if (!test_sta_flag(sta, WLAN_STA_RATE_CONTROL))
1668 rate_control_rate_init(sta);
1670 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
1675 if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
1676 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED))
1677 ret = sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED);
1678 else if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
1679 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
1686 if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
1687 !(set & BIT(NL80211_STA_FLAG_ASSOCIATED)) &&
1688 test_sta_flag(sta, WLAN_STA_ASSOC)) {
1689 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
1694 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
1695 !(set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) &&
1696 test_sta_flag(sta, WLAN_STA_AUTH)) {
1697 ret = sta_info_move_state(sta, IEEE80211_STA_NONE);
1705 static void sta_apply_mesh_params(struct ieee80211_local *local,
1706 struct sta_info *sta,
1707 struct station_parameters *params)
1709 #ifdef CONFIG_MAC80211_MESH
1710 struct ieee80211_sub_if_data *sdata = sta->sdata;
1713 if (params->sta_modify_mask & STATION_PARAM_APPLY_PLINK_STATE) {
1714 switch (params->plink_state) {
1715 case NL80211_PLINK_ESTAB:
1716 if (sta->mesh->plink_state != NL80211_PLINK_ESTAB)
1717 changed = mesh_plink_inc_estab_count(sdata);
1718 sta->mesh->plink_state = params->plink_state;
1719 sta->mesh->aid = params->peer_aid;
1721 ieee80211_mps_sta_status_update(sta);
1722 changed |= ieee80211_mps_set_sta_local_pm(sta,
1723 sdata->u.mesh.mshcfg.power_mode);
1725 ewma_mesh_tx_rate_avg_init(&sta->mesh->tx_rate_avg);
1726 /* init at low value */
1727 ewma_mesh_tx_rate_avg_add(&sta->mesh->tx_rate_avg, 10);
1730 case NL80211_PLINK_LISTEN:
1731 case NL80211_PLINK_BLOCKED:
1732 case NL80211_PLINK_OPN_SNT:
1733 case NL80211_PLINK_OPN_RCVD:
1734 case NL80211_PLINK_CNF_RCVD:
1735 case NL80211_PLINK_HOLDING:
1736 if (sta->mesh->plink_state == NL80211_PLINK_ESTAB)
1737 changed = mesh_plink_dec_estab_count(sdata);
1738 sta->mesh->plink_state = params->plink_state;
1740 ieee80211_mps_sta_status_update(sta);
1741 changed |= ieee80211_mps_set_sta_local_pm(sta,
1742 NL80211_MESH_POWER_UNKNOWN);
1750 switch (params->plink_action) {
1751 case NL80211_PLINK_ACTION_NO_ACTION:
1754 case NL80211_PLINK_ACTION_OPEN:
1755 changed |= mesh_plink_open(sta);
1757 case NL80211_PLINK_ACTION_BLOCK:
1758 changed |= mesh_plink_block(sta);
1762 if (params->local_pm)
1763 changed |= ieee80211_mps_set_sta_local_pm(sta,
1766 ieee80211_mbss_info_change_notify(sdata, changed);
1770 static int sta_link_apply_parameters(struct ieee80211_local *local,
1771 struct sta_info *sta, bool new_link,
1772 struct link_station_parameters *params)
1775 struct ieee80211_supported_band *sband;
1776 struct ieee80211_sub_if_data *sdata = sta->sdata;
1777 u32 link_id = params->link_id < 0 ? 0 : params->link_id;
1778 struct ieee80211_link_data *link =
1779 sdata_dereference(sdata->link[link_id], sdata);
1780 struct link_sta_info *link_sta =
1781 rcu_dereference_protected(sta->link[link_id],
1782 lockdep_is_held(&local->hw.wiphy->mtx));
1785 * If there are no changes, then accept a link that doesn't exist,
1786 * unless it's a new link.
1788 if (params->link_id < 0 && !new_link &&
1789 !params->link_mac && !params->txpwr_set &&
1790 !params->supported_rates_len &&
1791 !params->ht_capa && !params->vht_capa &&
1792 !params->he_capa && !params->eht_capa &&
1793 !params->opmode_notif_used)
1796 if (!link || !link_sta)
1799 sband = ieee80211_get_link_sband(link);
1803 if (params->link_mac) {
1805 memcpy(link_sta->addr, params->link_mac, ETH_ALEN);
1806 memcpy(link_sta->pub->addr, params->link_mac, ETH_ALEN);
1807 } else if (!ether_addr_equal(link_sta->addr,
1808 params->link_mac)) {
1811 } else if (new_link) {
1815 if (params->txpwr_set) {
1816 link_sta->pub->txpwr.type = params->txpwr.type;
1817 if (params->txpwr.type == NL80211_TX_POWER_LIMITED)
1818 link_sta->pub->txpwr.power = params->txpwr.power;
1819 ret = drv_sta_set_txpwr(local, sdata, sta);
1824 if (params->supported_rates &&
1825 params->supported_rates_len) {
1826 ieee80211_parse_bitrates(link->conf->chandef.width,
1827 sband, params->supported_rates,
1828 params->supported_rates_len,
1829 &link_sta->pub->supp_rates[sband->band]);
1832 if (params->ht_capa)
1833 ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
1834 params->ht_capa, link_sta);
1836 /* VHT can override some HT caps such as the A-MSDU max length */
1837 if (params->vht_capa)
1838 ieee80211_vht_cap_ie_to_sta_vht_cap(sdata, sband,
1839 params->vht_capa, link_sta);
1841 if (params->he_capa)
1842 ieee80211_he_cap_ie_to_sta_he_cap(sdata, sband,
1843 (void *)params->he_capa,
1844 params->he_capa_len,
1845 (void *)params->he_6ghz_capa,
1848 if (params->he_capa && params->eht_capa)
1849 ieee80211_eht_cap_ie_to_sta_eht_cap(sdata, sband,
1850 (u8 *)params->he_capa,
1851 params->he_capa_len,
1853 params->eht_capa_len,
1856 if (params->opmode_notif_used) {
1857 /* returned value is only needed for rc update, but the
1858 * rc isn't initialized here yet, so ignore it
1860 __ieee80211_vht_handle_opmode(sdata, link_sta,
1861 params->opmode_notif,
1868 static int sta_apply_parameters(struct ieee80211_local *local,
1869 struct sta_info *sta,
1870 struct station_parameters *params)
1872 struct ieee80211_sub_if_data *sdata = sta->sdata;
1876 mask = params->sta_flags_mask;
1877 set = params->sta_flags_set;
1879 if (ieee80211_vif_is_mesh(&sdata->vif)) {
1881 * In mesh mode, ASSOCIATED isn't part of the nl80211
1882 * API but must follow AUTHENTICATED for driver state.
1884 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED))
1885 mask |= BIT(NL80211_STA_FLAG_ASSOCIATED);
1886 if (set & BIT(NL80211_STA_FLAG_AUTHENTICATED))
1887 set |= BIT(NL80211_STA_FLAG_ASSOCIATED);
1888 } else if (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
1890 * TDLS -- everything follows authorized, but
1891 * only becoming authorized is possible, not
1894 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
1895 set |= BIT(NL80211_STA_FLAG_AUTHENTICATED) |
1896 BIT(NL80211_STA_FLAG_ASSOCIATED);
1897 mask |= BIT(NL80211_STA_FLAG_AUTHENTICATED) |
1898 BIT(NL80211_STA_FLAG_ASSOCIATED);
1902 if (mask & BIT(NL80211_STA_FLAG_WME) &&
1903 local->hw.queues >= IEEE80211_NUM_ACS)
1904 sta->sta.wme = set & BIT(NL80211_STA_FLAG_WME);
1906 /* auth flags will be set later for TDLS,
1907 * and for unassociated stations that move to associated */
1908 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1909 !((mask & BIT(NL80211_STA_FLAG_ASSOCIATED)) &&
1910 (set & BIT(NL80211_STA_FLAG_ASSOCIATED)))) {
1911 ret = sta_apply_auth_flags(local, sta, mask, set);
1916 if (mask & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) {
1917 if (set & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE))
1918 set_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
1920 clear_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
1923 if (mask & BIT(NL80211_STA_FLAG_MFP)) {
1924 sta->sta.mfp = !!(set & BIT(NL80211_STA_FLAG_MFP));
1925 if (set & BIT(NL80211_STA_FLAG_MFP))
1926 set_sta_flag(sta, WLAN_STA_MFP);
1928 clear_sta_flag(sta, WLAN_STA_MFP);
1931 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
1932 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER))
1933 set_sta_flag(sta, WLAN_STA_TDLS_PEER);
1935 clear_sta_flag(sta, WLAN_STA_TDLS_PEER);
1938 /* mark TDLS channel switch support, if the AP allows it */
1939 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1940 !sdata->deflink.u.mgd.tdls_chan_switch_prohibited &&
1941 params->ext_capab_len >= 4 &&
1942 params->ext_capab[3] & WLAN_EXT_CAPA4_TDLS_CHAN_SWITCH)
1943 set_sta_flag(sta, WLAN_STA_TDLS_CHAN_SWITCH);
1945 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1946 !sdata->u.mgd.tdls_wider_bw_prohibited &&
1947 ieee80211_hw_check(&local->hw, TDLS_WIDER_BW) &&
1948 params->ext_capab_len >= 8 &&
1949 params->ext_capab[7] & WLAN_EXT_CAPA8_TDLS_WIDE_BW_ENABLED)
1950 set_sta_flag(sta, WLAN_STA_TDLS_WIDER_BW);
1952 if (params->sta_modify_mask & STATION_PARAM_APPLY_UAPSD) {
1953 sta->sta.uapsd_queues = params->uapsd_queues;
1954 sta->sta.max_sp = params->max_sp;
1957 ieee80211_sta_set_max_amsdu_subframes(sta, params->ext_capab,
1958 params->ext_capab_len);
1961 * cfg80211 validates this (1-2007) and allows setting the AID
1962 * only when creating a new station entry
1965 sta->sta.aid = params->aid;
1968 * Some of the following updates would be racy if called on an
1969 * existing station, via ieee80211_change_station(). However,
1970 * all such changes are rejected by cfg80211 except for updates
1971 * changing the supported rates on an existing but not yet used
1975 if (params->listen_interval >= 0)
1976 sta->listen_interval = params->listen_interval;
1978 ret = sta_link_apply_parameters(local, sta, false,
1979 ¶ms->link_sta_params);
1983 if (params->support_p2p_ps >= 0)
1984 sta->sta.support_p2p_ps = params->support_p2p_ps;
1986 if (ieee80211_vif_is_mesh(&sdata->vif))
1987 sta_apply_mesh_params(local, sta, params);
1989 if (params->airtime_weight)
1990 sta->airtime_weight = params->airtime_weight;
1992 /* set the STA state after all sta info from usermode has been set */
1993 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) ||
1994 set & BIT(NL80211_STA_FLAG_ASSOCIATED)) {
1995 ret = sta_apply_auth_flags(local, sta, mask, set);
2000 /* Mark the STA as MLO if MLD MAC address is available */
2001 if (params->link_sta_params.mld_mac)
2002 sta->sta.mlo = true;
2007 static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
2009 struct station_parameters *params)
2011 struct ieee80211_local *local = wiphy_priv(wiphy);
2012 struct sta_info *sta;
2013 struct ieee80211_sub_if_data *sdata;
2016 lockdep_assert_wiphy(local->hw.wiphy);
2019 sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
2021 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
2022 sdata->vif.type != NL80211_IFTYPE_AP)
2025 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2027 if (ether_addr_equal(mac, sdata->vif.addr))
2030 if (!is_valid_ether_addr(mac))
2033 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER) &&
2034 sdata->vif.type == NL80211_IFTYPE_STATION &&
2035 !sdata->u.mgd.associated)
2039 * If we have a link ID, it can be a non-MLO station on an AP MLD,
2040 * but we need to have a link_mac in that case as well, so use the
2041 * STA's MAC address in that case.
2043 if (params->link_sta_params.link_id >= 0)
2044 sta = sta_info_alloc_with_link(sdata, mac,
2045 params->link_sta_params.link_id,
2046 params->link_sta_params.link_mac ?: mac,
2049 sta = sta_info_alloc(sdata, mac, GFP_KERNEL);
2054 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))
2055 sta->sta.tdls = true;
2057 /* Though the mutex is not needed here (since the station is not
2058 * visible yet), sta_apply_parameters (and inner functions) require
2059 * the mutex due to other paths.
2061 err = sta_apply_parameters(local, sta, params);
2063 sta_info_free(local, sta);
2068 * for TDLS and for unassociated station, rate control should be
2069 * initialized only when rates are known and station is marked
2070 * authorized/associated
2072 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
2073 test_sta_flag(sta, WLAN_STA_ASSOC))
2074 rate_control_rate_init(sta);
2076 return sta_info_insert(sta);
2079 static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev,
2080 struct station_del_parameters *params)
2082 struct ieee80211_sub_if_data *sdata;
2084 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2087 return sta_info_destroy_addr_bss(sdata, params->mac);
2089 sta_info_flush(sdata);
2093 static int ieee80211_change_station(struct wiphy *wiphy,
2094 struct net_device *dev, const u8 *mac,
2095 struct station_parameters *params)
2097 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2098 struct ieee80211_local *local = wiphy_priv(wiphy);
2099 struct sta_info *sta;
2100 struct ieee80211_sub_if_data *vlansdata;
2101 enum cfg80211_station_type statype;
2104 lockdep_assert_wiphy(local->hw.wiphy);
2106 sta = sta_info_get_bss(sdata, mac);
2110 switch (sdata->vif.type) {
2111 case NL80211_IFTYPE_MESH_POINT:
2112 if (sdata->u.mesh.user_mpm)
2113 statype = CFG80211_STA_MESH_PEER_USER;
2115 statype = CFG80211_STA_MESH_PEER_KERNEL;
2117 case NL80211_IFTYPE_ADHOC:
2118 statype = CFG80211_STA_IBSS;
2120 case NL80211_IFTYPE_STATION:
2121 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
2122 statype = CFG80211_STA_AP_STA;
2125 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
2126 statype = CFG80211_STA_TDLS_PEER_ACTIVE;
2128 statype = CFG80211_STA_TDLS_PEER_SETUP;
2130 case NL80211_IFTYPE_AP:
2131 case NL80211_IFTYPE_AP_VLAN:
2132 if (test_sta_flag(sta, WLAN_STA_ASSOC))
2133 statype = CFG80211_STA_AP_CLIENT;
2135 statype = CFG80211_STA_AP_CLIENT_UNASSOC;
2141 err = cfg80211_check_station_change(wiphy, params, statype);
2145 if (params->vlan && params->vlan != sta->sdata->dev) {
2146 vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
2148 if (params->vlan->ieee80211_ptr->use_4addr) {
2149 if (vlansdata->u.vlan.sta)
2152 rcu_assign_pointer(vlansdata->u.vlan.sta, sta);
2153 __ieee80211_check_fast_rx_iface(vlansdata);
2154 drv_sta_set_4addr(local, sta->sdata, &sta->sta, true);
2157 if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
2158 sta->sdata->u.vlan.sta) {
2159 ieee80211_clear_fast_rx(sta);
2160 RCU_INIT_POINTER(sta->sdata->u.vlan.sta, NULL);
2163 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
2164 ieee80211_vif_dec_num_mcast(sta->sdata);
2166 sta->sdata = vlansdata;
2167 ieee80211_check_fast_xmit(sta);
2169 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED)) {
2170 ieee80211_vif_inc_num_mcast(sta->sdata);
2171 cfg80211_send_layer2_update(sta->sdata->dev,
2176 err = sta_apply_parameters(local, sta, params);
2180 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
2181 params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
2182 ieee80211_recalc_ps(local);
2183 ieee80211_recalc_ps_vif(sdata);
2189 #ifdef CONFIG_MAC80211_MESH
2190 static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev,
2191 const u8 *dst, const u8 *next_hop)
2193 struct ieee80211_sub_if_data *sdata;
2194 struct mesh_path *mpath;
2195 struct sta_info *sta;
2197 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2200 sta = sta_info_get(sdata, next_hop);
2206 mpath = mesh_path_add(sdata, dst);
2207 if (IS_ERR(mpath)) {
2209 return PTR_ERR(mpath);
2212 mesh_path_fix_nexthop(mpath, sta);
2218 static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev,
2221 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2224 return mesh_path_del(sdata, dst);
2226 mesh_path_flush_by_iface(sdata);
2230 static int ieee80211_change_mpath(struct wiphy *wiphy, struct net_device *dev,
2231 const u8 *dst, const u8 *next_hop)
2233 struct ieee80211_sub_if_data *sdata;
2234 struct mesh_path *mpath;
2235 struct sta_info *sta;
2237 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2241 sta = sta_info_get(sdata, next_hop);
2247 mpath = mesh_path_lookup(sdata, dst);
2253 mesh_path_fix_nexthop(mpath, sta);
2259 static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop,
2260 struct mpath_info *pinfo)
2262 struct sta_info *next_hop_sta = rcu_dereference(mpath->next_hop);
2265 memcpy(next_hop, next_hop_sta->sta.addr, ETH_ALEN);
2267 eth_zero_addr(next_hop);
2269 memset(pinfo, 0, sizeof(*pinfo));
2271 pinfo->generation = mpath->sdata->u.mesh.mesh_paths_generation;
2273 pinfo->filled = MPATH_INFO_FRAME_QLEN |
2276 MPATH_INFO_EXPTIME |
2277 MPATH_INFO_DISCOVERY_TIMEOUT |
2278 MPATH_INFO_DISCOVERY_RETRIES |
2280 MPATH_INFO_HOP_COUNT |
2281 MPATH_INFO_PATH_CHANGE;
2283 pinfo->frame_qlen = mpath->frame_queue.qlen;
2284 pinfo->sn = mpath->sn;
2285 pinfo->metric = mpath->metric;
2286 if (time_before(jiffies, mpath->exp_time))
2287 pinfo->exptime = jiffies_to_msecs(mpath->exp_time - jiffies);
2288 pinfo->discovery_timeout =
2289 jiffies_to_msecs(mpath->discovery_timeout);
2290 pinfo->discovery_retries = mpath->discovery_retries;
2291 if (mpath->flags & MESH_PATH_ACTIVE)
2292 pinfo->flags |= NL80211_MPATH_FLAG_ACTIVE;
2293 if (mpath->flags & MESH_PATH_RESOLVING)
2294 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING;
2295 if (mpath->flags & MESH_PATH_SN_VALID)
2296 pinfo->flags |= NL80211_MPATH_FLAG_SN_VALID;
2297 if (mpath->flags & MESH_PATH_FIXED)
2298 pinfo->flags |= NL80211_MPATH_FLAG_FIXED;
2299 if (mpath->flags & MESH_PATH_RESOLVED)
2300 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVED;
2301 pinfo->hop_count = mpath->hop_count;
2302 pinfo->path_change_count = mpath->path_change_count;
2305 static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev,
2306 u8 *dst, u8 *next_hop, struct mpath_info *pinfo)
2309 struct ieee80211_sub_if_data *sdata;
2310 struct mesh_path *mpath;
2312 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2315 mpath = mesh_path_lookup(sdata, dst);
2320 memcpy(dst, mpath->dst, ETH_ALEN);
2321 mpath_set_pinfo(mpath, next_hop, pinfo);
2326 static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev,
2327 int idx, u8 *dst, u8 *next_hop,
2328 struct mpath_info *pinfo)
2330 struct ieee80211_sub_if_data *sdata;
2331 struct mesh_path *mpath;
2333 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2336 mpath = mesh_path_lookup_by_idx(sdata, idx);
2341 memcpy(dst, mpath->dst, ETH_ALEN);
2342 mpath_set_pinfo(mpath, next_hop, pinfo);
2347 static void mpp_set_pinfo(struct mesh_path *mpath, u8 *mpp,
2348 struct mpath_info *pinfo)
2350 memset(pinfo, 0, sizeof(*pinfo));
2351 memcpy(mpp, mpath->mpp, ETH_ALEN);
2353 pinfo->generation = mpath->sdata->u.mesh.mpp_paths_generation;
2356 static int ieee80211_get_mpp(struct wiphy *wiphy, struct net_device *dev,
2357 u8 *dst, u8 *mpp, struct mpath_info *pinfo)
2360 struct ieee80211_sub_if_data *sdata;
2361 struct mesh_path *mpath;
2363 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2366 mpath = mpp_path_lookup(sdata, dst);
2371 memcpy(dst, mpath->dst, ETH_ALEN);
2372 mpp_set_pinfo(mpath, mpp, pinfo);
2377 static int ieee80211_dump_mpp(struct wiphy *wiphy, struct net_device *dev,
2378 int idx, u8 *dst, u8 *mpp,
2379 struct mpath_info *pinfo)
2381 struct ieee80211_sub_if_data *sdata;
2382 struct mesh_path *mpath;
2384 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2387 mpath = mpp_path_lookup_by_idx(sdata, idx);
2392 memcpy(dst, mpath->dst, ETH_ALEN);
2393 mpp_set_pinfo(mpath, mpp, pinfo);
2398 static int ieee80211_get_mesh_config(struct wiphy *wiphy,
2399 struct net_device *dev,
2400 struct mesh_config *conf)
2402 struct ieee80211_sub_if_data *sdata;
2403 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2405 memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config));
2409 static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask)
2411 return (mask >> (parm-1)) & 0x1;
2414 static int copy_mesh_setup(struct ieee80211_if_mesh *ifmsh,
2415 const struct mesh_setup *setup)
2418 struct ieee80211_sub_if_data *sdata = container_of(ifmsh,
2419 struct ieee80211_sub_if_data, u.mesh);
2422 /* allocate information elements */
2425 if (setup->ie_len) {
2426 new_ie = kmemdup(setup->ie, setup->ie_len,
2431 ifmsh->ie_len = setup->ie_len;
2434 /* now copy the rest of the setup parameters */
2435 ifmsh->mesh_id_len = setup->mesh_id_len;
2436 memcpy(ifmsh->mesh_id, setup->mesh_id, ifmsh->mesh_id_len);
2437 ifmsh->mesh_sp_id = setup->sync_method;
2438 ifmsh->mesh_pp_id = setup->path_sel_proto;
2439 ifmsh->mesh_pm_id = setup->path_metric;
2440 ifmsh->user_mpm = setup->user_mpm;
2441 ifmsh->mesh_auth_id = setup->auth_id;
2442 ifmsh->security = IEEE80211_MESH_SEC_NONE;
2443 ifmsh->userspace_handles_dfs = setup->userspace_handles_dfs;
2444 if (setup->is_authenticated)
2445 ifmsh->security |= IEEE80211_MESH_SEC_AUTHED;
2446 if (setup->is_secure)
2447 ifmsh->security |= IEEE80211_MESH_SEC_SECURED;
2449 /* mcast rate setting in Mesh Node */
2450 memcpy(sdata->vif.bss_conf.mcast_rate, setup->mcast_rate,
2451 sizeof(setup->mcast_rate));
2452 sdata->vif.bss_conf.basic_rates = setup->basic_rates;
2454 sdata->vif.bss_conf.beacon_int = setup->beacon_interval;
2455 sdata->vif.bss_conf.dtim_period = setup->dtim_period;
2457 sdata->beacon_rate_set = false;
2458 if (wiphy_ext_feature_isset(sdata->local->hw.wiphy,
2459 NL80211_EXT_FEATURE_BEACON_RATE_LEGACY)) {
2460 for (i = 0; i < NUM_NL80211_BANDS; i++) {
2461 sdata->beacon_rateidx_mask[i] =
2462 setup->beacon_rate.control[i].legacy;
2463 if (sdata->beacon_rateidx_mask[i])
2464 sdata->beacon_rate_set = true;
2471 static int ieee80211_update_mesh_config(struct wiphy *wiphy,
2472 struct net_device *dev, u32 mask,
2473 const struct mesh_config *nconf)
2475 struct mesh_config *conf;
2476 struct ieee80211_sub_if_data *sdata;
2477 struct ieee80211_if_mesh *ifmsh;
2479 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2480 ifmsh = &sdata->u.mesh;
2482 /* Set the config options which we are interested in setting */
2483 conf = &(sdata->u.mesh.mshcfg);
2484 if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask))
2485 conf->dot11MeshRetryTimeout = nconf->dot11MeshRetryTimeout;
2486 if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT, mask))
2487 conf->dot11MeshConfirmTimeout = nconf->dot11MeshConfirmTimeout;
2488 if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT, mask))
2489 conf->dot11MeshHoldingTimeout = nconf->dot11MeshHoldingTimeout;
2490 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS, mask))
2491 conf->dot11MeshMaxPeerLinks = nconf->dot11MeshMaxPeerLinks;
2492 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES, mask))
2493 conf->dot11MeshMaxRetries = nconf->dot11MeshMaxRetries;
2494 if (_chg_mesh_attr(NL80211_MESHCONF_TTL, mask))
2495 conf->dot11MeshTTL = nconf->dot11MeshTTL;
2496 if (_chg_mesh_attr(NL80211_MESHCONF_ELEMENT_TTL, mask))
2497 conf->element_ttl = nconf->element_ttl;
2498 if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask)) {
2499 if (ifmsh->user_mpm)
2501 conf->auto_open_plinks = nconf->auto_open_plinks;
2503 if (_chg_mesh_attr(NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR, mask))
2504 conf->dot11MeshNbrOffsetMaxNeighbor =
2505 nconf->dot11MeshNbrOffsetMaxNeighbor;
2506 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, mask))
2507 conf->dot11MeshHWMPmaxPREQretries =
2508 nconf->dot11MeshHWMPmaxPREQretries;
2509 if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME, mask))
2510 conf->path_refresh_time = nconf->path_refresh_time;
2511 if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, mask))
2512 conf->min_discovery_timeout = nconf->min_discovery_timeout;
2513 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, mask))
2514 conf->dot11MeshHWMPactivePathTimeout =
2515 nconf->dot11MeshHWMPactivePathTimeout;
2516 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, mask))
2517 conf->dot11MeshHWMPpreqMinInterval =
2518 nconf->dot11MeshHWMPpreqMinInterval;
2519 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL, mask))
2520 conf->dot11MeshHWMPperrMinInterval =
2521 nconf->dot11MeshHWMPperrMinInterval;
2522 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
2524 conf->dot11MeshHWMPnetDiameterTraversalTime =
2525 nconf->dot11MeshHWMPnetDiameterTraversalTime;
2526 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOTMODE, mask)) {
2527 conf->dot11MeshHWMPRootMode = nconf->dot11MeshHWMPRootMode;
2528 ieee80211_mesh_root_setup(ifmsh);
2530 if (_chg_mesh_attr(NL80211_MESHCONF_GATE_ANNOUNCEMENTS, mask)) {
2531 /* our current gate announcement implementation rides on root
2532 * announcements, so require this ifmsh to also be a root node
2534 if (nconf->dot11MeshGateAnnouncementProtocol &&
2535 !(conf->dot11MeshHWMPRootMode > IEEE80211_ROOTMODE_ROOT)) {
2536 conf->dot11MeshHWMPRootMode = IEEE80211_PROACTIVE_RANN;
2537 ieee80211_mesh_root_setup(ifmsh);
2539 conf->dot11MeshGateAnnouncementProtocol =
2540 nconf->dot11MeshGateAnnouncementProtocol;
2542 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_RANN_INTERVAL, mask))
2543 conf->dot11MeshHWMPRannInterval =
2544 nconf->dot11MeshHWMPRannInterval;
2545 if (_chg_mesh_attr(NL80211_MESHCONF_FORWARDING, mask))
2546 conf->dot11MeshForwarding = nconf->dot11MeshForwarding;
2547 if (_chg_mesh_attr(NL80211_MESHCONF_RSSI_THRESHOLD, mask)) {
2548 /* our RSSI threshold implementation is supported only for
2549 * devices that report signal in dBm.
2551 if (!ieee80211_hw_check(&sdata->local->hw, SIGNAL_DBM))
2553 conf->rssi_threshold = nconf->rssi_threshold;
2555 if (_chg_mesh_attr(NL80211_MESHCONF_HT_OPMODE, mask)) {
2556 conf->ht_opmode = nconf->ht_opmode;
2557 sdata->vif.bss_conf.ht_operation_mode = nconf->ht_opmode;
2558 ieee80211_link_info_change_notify(sdata, &sdata->deflink,
2561 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT, mask))
2562 conf->dot11MeshHWMPactivePathToRootTimeout =
2563 nconf->dot11MeshHWMPactivePathToRootTimeout;
2564 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOT_INTERVAL, mask))
2565 conf->dot11MeshHWMProotInterval =
2566 nconf->dot11MeshHWMProotInterval;
2567 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL, mask))
2568 conf->dot11MeshHWMPconfirmationInterval =
2569 nconf->dot11MeshHWMPconfirmationInterval;
2570 if (_chg_mesh_attr(NL80211_MESHCONF_POWER_MODE, mask)) {
2571 conf->power_mode = nconf->power_mode;
2572 ieee80211_mps_local_status_update(sdata);
2574 if (_chg_mesh_attr(NL80211_MESHCONF_AWAKE_WINDOW, mask))
2575 conf->dot11MeshAwakeWindowDuration =
2576 nconf->dot11MeshAwakeWindowDuration;
2577 if (_chg_mesh_attr(NL80211_MESHCONF_PLINK_TIMEOUT, mask))
2578 conf->plink_timeout = nconf->plink_timeout;
2579 if (_chg_mesh_attr(NL80211_MESHCONF_CONNECTED_TO_GATE, mask))
2580 conf->dot11MeshConnectedToMeshGate =
2581 nconf->dot11MeshConnectedToMeshGate;
2582 if (_chg_mesh_attr(NL80211_MESHCONF_NOLEARN, mask))
2583 conf->dot11MeshNolearn = nconf->dot11MeshNolearn;
2584 if (_chg_mesh_attr(NL80211_MESHCONF_CONNECTED_TO_AS, mask))
2585 conf->dot11MeshConnectedToAuthServer =
2586 nconf->dot11MeshConnectedToAuthServer;
2587 ieee80211_mbss_info_change_notify(sdata, BSS_CHANGED_BEACON);
2591 static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev,
2592 const struct mesh_config *conf,
2593 const struct mesh_setup *setup)
2595 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2596 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
2599 lockdep_assert_wiphy(sdata->local->hw.wiphy);
2601 memcpy(&ifmsh->mshcfg, conf, sizeof(struct mesh_config));
2602 err = copy_mesh_setup(ifmsh, setup);
2606 sdata->control_port_over_nl80211 = setup->control_port_over_nl80211;
2608 /* can mesh use other SMPS modes? */
2609 sdata->deflink.smps_mode = IEEE80211_SMPS_OFF;
2610 sdata->deflink.needed_rx_chains = sdata->local->rx_chains;
2612 err = ieee80211_link_use_channel(&sdata->deflink, &setup->chandef,
2613 IEEE80211_CHANCTX_SHARED);
2617 return ieee80211_start_mesh(sdata);
2620 static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev)
2622 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2624 lockdep_assert_wiphy(sdata->local->hw.wiphy);
2626 ieee80211_stop_mesh(sdata);
2627 ieee80211_link_release_channel(&sdata->deflink);
2628 kfree(sdata->u.mesh.ie);
2634 static int ieee80211_change_bss(struct wiphy *wiphy,
2635 struct net_device *dev,
2636 struct bss_parameters *params)
2638 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2639 struct ieee80211_link_data *link;
2640 struct ieee80211_supported_band *sband;
2643 link = ieee80211_link_or_deflink(sdata, params->link_id, true);
2645 return PTR_ERR(link);
2647 if (!sdata_dereference(link->u.ap.beacon, sdata))
2650 sband = ieee80211_get_link_sband(link);
2654 if (params->basic_rates) {
2655 if (!ieee80211_parse_bitrates(link->conf->chandef.width,
2656 wiphy->bands[sband->band],
2657 params->basic_rates,
2658 params->basic_rates_len,
2659 &link->conf->basic_rates))
2661 changed |= BSS_CHANGED_BASIC_RATES;
2662 ieee80211_check_rate_mask(link);
2665 if (params->use_cts_prot >= 0) {
2666 link->conf->use_cts_prot = params->use_cts_prot;
2667 changed |= BSS_CHANGED_ERP_CTS_PROT;
2669 if (params->use_short_preamble >= 0) {
2670 link->conf->use_short_preamble = params->use_short_preamble;
2671 changed |= BSS_CHANGED_ERP_PREAMBLE;
2674 if (!link->conf->use_short_slot &&
2675 (sband->band == NL80211_BAND_5GHZ ||
2676 sband->band == NL80211_BAND_6GHZ)) {
2677 link->conf->use_short_slot = true;
2678 changed |= BSS_CHANGED_ERP_SLOT;
2681 if (params->use_short_slot_time >= 0) {
2682 link->conf->use_short_slot = params->use_short_slot_time;
2683 changed |= BSS_CHANGED_ERP_SLOT;
2686 if (params->ap_isolate >= 0) {
2687 if (params->ap_isolate)
2688 sdata->flags |= IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
2690 sdata->flags &= ~IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
2691 ieee80211_check_fast_rx_iface(sdata);
2694 if (params->ht_opmode >= 0) {
2695 link->conf->ht_operation_mode = (u16)params->ht_opmode;
2696 changed |= BSS_CHANGED_HT;
2699 if (params->p2p_ctwindow >= 0) {
2700 link->conf->p2p_noa_attr.oppps_ctwindow &=
2701 ~IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
2702 link->conf->p2p_noa_attr.oppps_ctwindow |=
2703 params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
2704 changed |= BSS_CHANGED_P2P_PS;
2707 if (params->p2p_opp_ps > 0) {
2708 link->conf->p2p_noa_attr.oppps_ctwindow |=
2709 IEEE80211_P2P_OPPPS_ENABLE_BIT;
2710 changed |= BSS_CHANGED_P2P_PS;
2711 } else if (params->p2p_opp_ps == 0) {
2712 link->conf->p2p_noa_attr.oppps_ctwindow &=
2713 ~IEEE80211_P2P_OPPPS_ENABLE_BIT;
2714 changed |= BSS_CHANGED_P2P_PS;
2717 ieee80211_link_info_change_notify(sdata, link, changed);
2722 static int ieee80211_set_txq_params(struct wiphy *wiphy,
2723 struct net_device *dev,
2724 struct ieee80211_txq_params *params)
2726 struct ieee80211_local *local = wiphy_priv(wiphy);
2727 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2728 struct ieee80211_link_data *link =
2729 ieee80211_link_or_deflink(sdata, params->link_id, true);
2730 struct ieee80211_tx_queue_params p;
2732 if (!local->ops->conf_tx)
2735 if (local->hw.queues < IEEE80211_NUM_ACS)
2739 return PTR_ERR(link);
2741 memset(&p, 0, sizeof(p));
2742 p.aifs = params->aifs;
2743 p.cw_max = params->cwmax;
2744 p.cw_min = params->cwmin;
2745 p.txop = params->txop;
2748 * Setting tx queue params disables u-apsd because it's only
2749 * called in master mode.
2753 ieee80211_regulatory_limit_wmm_params(sdata, &p, params->ac);
2755 link->tx_conf[params->ac] = p;
2756 if (drv_conf_tx(local, link, params->ac, &p)) {
2757 wiphy_debug(local->hw.wiphy,
2758 "failed to set TX queue parameters for AC %d\n",
2763 ieee80211_link_info_change_notify(sdata, link,
2770 static int ieee80211_suspend(struct wiphy *wiphy,
2771 struct cfg80211_wowlan *wowlan)
2773 return __ieee80211_suspend(wiphy_priv(wiphy), wowlan);
2776 static int ieee80211_resume(struct wiphy *wiphy)
2778 return __ieee80211_resume(wiphy_priv(wiphy));
2781 #define ieee80211_suspend NULL
2782 #define ieee80211_resume NULL
2785 static int ieee80211_scan(struct wiphy *wiphy,
2786 struct cfg80211_scan_request *req)
2788 struct ieee80211_sub_if_data *sdata;
2790 sdata = IEEE80211_WDEV_TO_SUB_IF(req->wdev);
2792 switch (ieee80211_vif_type_p2p(&sdata->vif)) {
2793 case NL80211_IFTYPE_STATION:
2794 case NL80211_IFTYPE_ADHOC:
2795 case NL80211_IFTYPE_MESH_POINT:
2796 case NL80211_IFTYPE_P2P_CLIENT:
2797 case NL80211_IFTYPE_P2P_DEVICE:
2799 case NL80211_IFTYPE_P2P_GO:
2800 if (sdata->local->ops->hw_scan)
2803 * FIXME: implement NoA while scanning in software,
2804 * for now fall through to allow scanning only when
2805 * beaconing hasn't been configured yet
2808 case NL80211_IFTYPE_AP:
2810 * If the scan has been forced (and the driver supports
2811 * forcing), don't care about being beaconing already.
2812 * This will create problems to the attached stations (e.g. all
2813 * the frames sent while scanning on other channel will be
2816 if (sdata->deflink.u.ap.beacon &&
2817 (!(wiphy->features & NL80211_FEATURE_AP_SCAN) ||
2818 !(req->flags & NL80211_SCAN_FLAG_AP)))
2821 case NL80211_IFTYPE_NAN:
2826 return ieee80211_request_scan(sdata, req);
2829 static void ieee80211_abort_scan(struct wiphy *wiphy, struct wireless_dev *wdev)
2831 ieee80211_scan_cancel(wiphy_priv(wiphy));
2835 ieee80211_sched_scan_start(struct wiphy *wiphy,
2836 struct net_device *dev,
2837 struct cfg80211_sched_scan_request *req)
2839 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2841 if (!sdata->local->ops->sched_scan_start)
2844 return ieee80211_request_sched_scan_start(sdata, req);
2848 ieee80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev,
2851 struct ieee80211_local *local = wiphy_priv(wiphy);
2853 if (!local->ops->sched_scan_stop)
2856 return ieee80211_request_sched_scan_stop(local);
2859 static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev,
2860 struct cfg80211_auth_request *req)
2862 return ieee80211_mgd_auth(IEEE80211_DEV_TO_SUB_IF(dev), req);
2865 static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev,
2866 struct cfg80211_assoc_request *req)
2868 return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
2871 static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev,
2872 struct cfg80211_deauth_request *req)
2874 return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev), req);
2877 static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
2878 struct cfg80211_disassoc_request *req)
2880 return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
2883 static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
2884 struct cfg80211_ibss_params *params)
2886 return ieee80211_ibss_join(IEEE80211_DEV_TO_SUB_IF(dev), params);
2889 static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
2891 return ieee80211_ibss_leave(IEEE80211_DEV_TO_SUB_IF(dev));
2894 static int ieee80211_join_ocb(struct wiphy *wiphy, struct net_device *dev,
2895 struct ocb_setup *setup)
2897 return ieee80211_ocb_join(IEEE80211_DEV_TO_SUB_IF(dev), setup);
2900 static int ieee80211_leave_ocb(struct wiphy *wiphy, struct net_device *dev)
2902 return ieee80211_ocb_leave(IEEE80211_DEV_TO_SUB_IF(dev));
2905 static int ieee80211_set_mcast_rate(struct wiphy *wiphy, struct net_device *dev,
2906 int rate[NUM_NL80211_BANDS])
2908 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2910 memcpy(sdata->vif.bss_conf.mcast_rate, rate,
2911 sizeof(int) * NUM_NL80211_BANDS);
2913 ieee80211_link_info_change_notify(sdata, &sdata->deflink,
2914 BSS_CHANGED_MCAST_RATE);
2919 static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
2921 struct ieee80211_local *local = wiphy_priv(wiphy);
2924 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
2925 ieee80211_check_fast_xmit_all(local);
2927 err = drv_set_frag_threshold(local, wiphy->frag_threshold);
2930 ieee80211_check_fast_xmit_all(local);
2935 if ((changed & WIPHY_PARAM_COVERAGE_CLASS) ||
2936 (changed & WIPHY_PARAM_DYN_ACK)) {
2939 coverage_class = changed & WIPHY_PARAM_COVERAGE_CLASS ?
2940 wiphy->coverage_class : -1;
2941 err = drv_set_coverage_class(local, coverage_class);
2947 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
2948 err = drv_set_rts_threshold(local, wiphy->rts_threshold);
2954 if (changed & WIPHY_PARAM_RETRY_SHORT) {
2955 if (wiphy->retry_short > IEEE80211_MAX_TX_RETRY)
2957 local->hw.conf.short_frame_max_tx_count = wiphy->retry_short;
2959 if (changed & WIPHY_PARAM_RETRY_LONG) {
2960 if (wiphy->retry_long > IEEE80211_MAX_TX_RETRY)
2962 local->hw.conf.long_frame_max_tx_count = wiphy->retry_long;
2965 (WIPHY_PARAM_RETRY_SHORT | WIPHY_PARAM_RETRY_LONG))
2966 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS);
2968 if (changed & (WIPHY_PARAM_TXQ_LIMIT |
2969 WIPHY_PARAM_TXQ_MEMORY_LIMIT |
2970 WIPHY_PARAM_TXQ_QUANTUM))
2971 ieee80211_txq_set_params(local);
2976 static int ieee80211_set_tx_power(struct wiphy *wiphy,
2977 struct wireless_dev *wdev,
2978 enum nl80211_tx_power_setting type, int mbm)
2980 struct ieee80211_local *local = wiphy_priv(wiphy);
2981 struct ieee80211_sub_if_data *sdata;
2982 enum nl80211_tx_power_setting txp_type = type;
2983 bool update_txp_type = false;
2984 bool has_monitor = false;
2986 lockdep_assert_wiphy(local->hw.wiphy);
2989 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
2991 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) {
2992 sdata = wiphy_dereference(local->hw.wiphy,
2993 local->monitor_sdata);
2999 case NL80211_TX_POWER_AUTOMATIC:
3000 sdata->deflink.user_power_level =
3001 IEEE80211_UNSET_POWER_LEVEL;
3002 txp_type = NL80211_TX_POWER_LIMITED;
3004 case NL80211_TX_POWER_LIMITED:
3005 case NL80211_TX_POWER_FIXED:
3006 if (mbm < 0 || (mbm % 100))
3008 sdata->deflink.user_power_level = MBM_TO_DBM(mbm);
3012 if (txp_type != sdata->vif.bss_conf.txpower_type) {
3013 update_txp_type = true;
3014 sdata->vif.bss_conf.txpower_type = txp_type;
3017 ieee80211_recalc_txpower(sdata, update_txp_type);
3023 case NL80211_TX_POWER_AUTOMATIC:
3024 local->user_power_level = IEEE80211_UNSET_POWER_LEVEL;
3025 txp_type = NL80211_TX_POWER_LIMITED;
3027 case NL80211_TX_POWER_LIMITED:
3028 case NL80211_TX_POWER_FIXED:
3029 if (mbm < 0 || (mbm % 100))
3031 local->user_power_level = MBM_TO_DBM(mbm);
3035 list_for_each_entry(sdata, &local->interfaces, list) {
3036 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) {
3040 sdata->deflink.user_power_level = local->user_power_level;
3041 if (txp_type != sdata->vif.bss_conf.txpower_type)
3042 update_txp_type = true;
3043 sdata->vif.bss_conf.txpower_type = txp_type;
3045 list_for_each_entry(sdata, &local->interfaces, list) {
3046 if (sdata->vif.type == NL80211_IFTYPE_MONITOR)
3048 ieee80211_recalc_txpower(sdata, update_txp_type);
3052 sdata = wiphy_dereference(local->hw.wiphy,
3053 local->monitor_sdata);
3055 sdata->deflink.user_power_level = local->user_power_level;
3056 if (txp_type != sdata->vif.bss_conf.txpower_type)
3057 update_txp_type = true;
3058 sdata->vif.bss_conf.txpower_type = txp_type;
3060 ieee80211_recalc_txpower(sdata, update_txp_type);
3067 static int ieee80211_get_tx_power(struct wiphy *wiphy,
3068 struct wireless_dev *wdev,
3071 struct ieee80211_local *local = wiphy_priv(wiphy);
3072 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
3074 if (local->ops->get_txpower)
3075 return drv_get_txpower(local, sdata, dbm);
3077 if (!local->use_chanctx)
3078 *dbm = local->hw.conf.power_level;
3080 *dbm = sdata->vif.bss_conf.txpower;
3082 /* INT_MIN indicates no power level was set yet */
3083 if (*dbm == INT_MIN)
3089 static void ieee80211_rfkill_poll(struct wiphy *wiphy)
3091 struct ieee80211_local *local = wiphy_priv(wiphy);
3093 drv_rfkill_poll(local);
3096 #ifdef CONFIG_NL80211_TESTMODE
3097 static int ieee80211_testmode_cmd(struct wiphy *wiphy,
3098 struct wireless_dev *wdev,
3099 void *data, int len)
3101 struct ieee80211_local *local = wiphy_priv(wiphy);
3102 struct ieee80211_vif *vif = NULL;
3104 if (!local->ops->testmode_cmd)
3108 struct ieee80211_sub_if_data *sdata;
3110 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
3111 if (sdata->flags & IEEE80211_SDATA_IN_DRIVER)
3115 return local->ops->testmode_cmd(&local->hw, vif, data, len);
3118 static int ieee80211_testmode_dump(struct wiphy *wiphy,
3119 struct sk_buff *skb,
3120 struct netlink_callback *cb,
3121 void *data, int len)
3123 struct ieee80211_local *local = wiphy_priv(wiphy);
3125 if (!local->ops->testmode_dump)
3128 return local->ops->testmode_dump(&local->hw, skb, cb, data, len);
3132 int __ieee80211_request_smps_mgd(struct ieee80211_sub_if_data *sdata,
3133 struct ieee80211_link_data *link,
3134 enum ieee80211_smps_mode smps_mode)
3137 enum ieee80211_smps_mode old_req;
3139 struct sta_info *sta;
3140 bool tdls_peer_found = false;
3142 lockdep_assert_wiphy(sdata->local->hw.wiphy);
3144 if (WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION))
3147 if (ieee80211_vif_is_mld(&sdata->vif) &&
3148 !(sdata->vif.active_links & BIT(link->link_id)))
3151 old_req = link->u.mgd.req_smps;
3152 link->u.mgd.req_smps = smps_mode;
3154 if (old_req == smps_mode &&
3155 smps_mode != IEEE80211_SMPS_AUTOMATIC)
3159 * If not associated, or current association is not an HT
3160 * association, there's no need to do anything, just store
3161 * the new value until we associate.
3163 if (!sdata->u.mgd.associated ||
3164 link->conf->chandef.width == NL80211_CHAN_WIDTH_20_NOHT)
3167 ap = sdata->vif.cfg.ap_addr;
3170 list_for_each_entry_rcu(sta, &sdata->local->sta_list, list) {
3171 if (!sta->sta.tdls || sta->sdata != sdata || !sta->uploaded ||
3172 !test_sta_flag(sta, WLAN_STA_AUTHORIZED))
3175 tdls_peer_found = true;
3180 if (smps_mode == IEEE80211_SMPS_AUTOMATIC) {
3181 if (tdls_peer_found || !sdata->u.mgd.powersave)
3182 smps_mode = IEEE80211_SMPS_OFF;
3184 smps_mode = IEEE80211_SMPS_DYNAMIC;
3187 /* send SM PS frame to AP */
3188 err = ieee80211_send_smps_action(sdata, smps_mode,
3190 ieee80211_vif_is_mld(&sdata->vif) ?
3191 link->link_id : -1);
3193 link->u.mgd.req_smps = old_req;
3194 else if (smps_mode != IEEE80211_SMPS_OFF && tdls_peer_found)
3195 ieee80211_teardown_tdls_peers(sdata);
3200 static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
3201 bool enabled, int timeout)
3203 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3204 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
3205 unsigned int link_id;
3207 if (sdata->vif.type != NL80211_IFTYPE_STATION)
3210 if (!ieee80211_hw_check(&local->hw, SUPPORTS_PS))
3213 if (enabled == sdata->u.mgd.powersave &&
3214 timeout == local->dynamic_ps_forced_timeout)
3217 sdata->u.mgd.powersave = enabled;
3218 local->dynamic_ps_forced_timeout = timeout;
3220 /* no change, but if automatic follow powersave */
3221 for (link_id = 0; link_id < ARRAY_SIZE(sdata->link); link_id++) {
3222 struct ieee80211_link_data *link;
3224 link = sdata_dereference(sdata->link[link_id], sdata);
3228 __ieee80211_request_smps_mgd(sdata, link,
3229 link->u.mgd.req_smps);
3232 if (ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS))
3233 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
3235 ieee80211_recalc_ps(local);
3236 ieee80211_recalc_ps_vif(sdata);
3237 ieee80211_check_fast_rx_iface(sdata);
3242 static int ieee80211_set_cqm_rssi_config(struct wiphy *wiphy,
3243 struct net_device *dev,
3244 s32 rssi_thold, u32 rssi_hyst)
3246 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3247 struct ieee80211_vif *vif = &sdata->vif;
3248 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
3250 if (rssi_thold == bss_conf->cqm_rssi_thold &&
3251 rssi_hyst == bss_conf->cqm_rssi_hyst)
3254 if (sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER &&
3255 !(sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI))
3258 bss_conf->cqm_rssi_thold = rssi_thold;
3259 bss_conf->cqm_rssi_hyst = rssi_hyst;
3260 bss_conf->cqm_rssi_low = 0;
3261 bss_conf->cqm_rssi_high = 0;
3262 sdata->deflink.u.mgd.last_cqm_event_signal = 0;
3264 /* tell the driver upon association, unless already associated */
3265 if (sdata->u.mgd.associated &&
3266 sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)
3267 ieee80211_link_info_change_notify(sdata, &sdata->deflink,
3273 static int ieee80211_set_cqm_rssi_range_config(struct wiphy *wiphy,
3274 struct net_device *dev,
3275 s32 rssi_low, s32 rssi_high)
3277 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3278 struct ieee80211_vif *vif = &sdata->vif;
3279 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
3281 if (sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER)
3284 bss_conf->cqm_rssi_low = rssi_low;
3285 bss_conf->cqm_rssi_high = rssi_high;
3286 bss_conf->cqm_rssi_thold = 0;
3287 bss_conf->cqm_rssi_hyst = 0;
3288 sdata->deflink.u.mgd.last_cqm_event_signal = 0;
3290 /* tell the driver upon association, unless already associated */
3291 if (sdata->u.mgd.associated &&
3292 sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)
3293 ieee80211_link_info_change_notify(sdata, &sdata->deflink,
3299 static int ieee80211_set_bitrate_mask(struct wiphy *wiphy,
3300 struct net_device *dev,
3301 unsigned int link_id,
3303 const struct cfg80211_bitrate_mask *mask)
3305 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3306 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
3309 if (!ieee80211_sdata_running(sdata))
3313 * If active validate the setting and reject it if it doesn't leave
3314 * at least one basic rate usable, since we really have to be able
3315 * to send something, and if we're an AP we have to be able to do
3316 * so at a basic rate so that all clients can receive it.
3318 if (rcu_access_pointer(sdata->vif.bss_conf.chanctx_conf) &&
3319 sdata->vif.bss_conf.chandef.chan) {
3320 u32 basic_rates = sdata->vif.bss_conf.basic_rates;
3321 enum nl80211_band band = sdata->vif.bss_conf.chandef.chan->band;
3323 if (!(mask->control[band].legacy & basic_rates))
3327 if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) {
3328 ret = drv_set_bitrate_mask(local, sdata, mask);
3333 for (i = 0; i < NUM_NL80211_BANDS; i++) {
3334 struct ieee80211_supported_band *sband = wiphy->bands[i];
3337 sdata->rc_rateidx_mask[i] = mask->control[i].legacy;
3338 memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].ht_mcs,
3339 sizeof(mask->control[i].ht_mcs));
3340 memcpy(sdata->rc_rateidx_vht_mcs_mask[i],
3341 mask->control[i].vht_mcs,
3342 sizeof(mask->control[i].vht_mcs));
3344 sdata->rc_has_mcs_mask[i] = false;
3345 sdata->rc_has_vht_mcs_mask[i] = false;
3349 for (j = 0; j < IEEE80211_HT_MCS_MASK_LEN; j++) {
3350 if (sdata->rc_rateidx_mcs_mask[i][j] != 0xff) {
3351 sdata->rc_has_mcs_mask[i] = true;
3356 for (j = 0; j < NL80211_VHT_NSS_MAX; j++) {
3357 if (sdata->rc_rateidx_vht_mcs_mask[i][j] != 0xffff) {
3358 sdata->rc_has_vht_mcs_mask[i] = true;
3367 static int ieee80211_start_radar_detection(struct wiphy *wiphy,
3368 struct net_device *dev,
3369 struct cfg80211_chan_def *chandef,
3372 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3373 struct ieee80211_local *local = sdata->local;
3376 lockdep_assert_wiphy(local->hw.wiphy);
3378 if (!list_empty(&local->roc_list) || local->scanning) {
3383 /* whatever, but channel contexts should not complain about that one */
3384 sdata->deflink.smps_mode = IEEE80211_SMPS_OFF;
3385 sdata->deflink.needed_rx_chains = local->rx_chains;
3387 err = ieee80211_link_use_channel(&sdata->deflink, chandef,
3388 IEEE80211_CHANCTX_SHARED);
3392 wiphy_delayed_work_queue(wiphy, &sdata->deflink.dfs_cac_timer_work,
3393 msecs_to_jiffies(cac_time_ms));
3399 static void ieee80211_end_cac(struct wiphy *wiphy,
3400 struct net_device *dev)
3402 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3403 struct ieee80211_local *local = sdata->local;
3405 lockdep_assert_wiphy(local->hw.wiphy);
3407 list_for_each_entry(sdata, &local->interfaces, list) {
3408 /* it might be waiting for the local->mtx, but then
3409 * by the time it gets it, sdata->wdev.cac_started
3410 * will no longer be true
3412 wiphy_delayed_work_cancel(wiphy,
3413 &sdata->deflink.dfs_cac_timer_work);
3415 if (sdata->wdev.cac_started) {
3416 ieee80211_link_release_channel(&sdata->deflink);
3417 sdata->wdev.cac_started = false;
3422 static struct cfg80211_beacon_data *
3423 cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon)
3425 struct cfg80211_beacon_data *new_beacon;
3429 len = beacon->head_len + beacon->tail_len + beacon->beacon_ies_len +
3430 beacon->proberesp_ies_len + beacon->assocresp_ies_len +
3431 beacon->probe_resp_len + beacon->lci_len + beacon->civicloc_len;
3433 if (beacon->mbssid_ies)
3434 len += ieee80211_get_mbssid_beacon_len(beacon->mbssid_ies,
3436 beacon->mbssid_ies->cnt);
3438 new_beacon = kzalloc(sizeof(*new_beacon) + len, GFP_KERNEL);
3442 if (beacon->mbssid_ies && beacon->mbssid_ies->cnt) {
3443 new_beacon->mbssid_ies =
3444 kzalloc(struct_size(new_beacon->mbssid_ies,
3445 elem, beacon->mbssid_ies->cnt),
3447 if (!new_beacon->mbssid_ies) {
3452 if (beacon->rnr_ies && beacon->rnr_ies->cnt) {
3453 new_beacon->rnr_ies =
3454 kzalloc(struct_size(new_beacon->rnr_ies,
3455 elem, beacon->rnr_ies->cnt),
3457 if (!new_beacon->rnr_ies) {
3458 kfree(new_beacon->mbssid_ies);
3465 pos = (u8 *)(new_beacon + 1);
3466 if (beacon->head_len) {
3467 new_beacon->head_len = beacon->head_len;
3468 new_beacon->head = pos;
3469 memcpy(pos, beacon->head, beacon->head_len);
3470 pos += beacon->head_len;
3472 if (beacon->tail_len) {
3473 new_beacon->tail_len = beacon->tail_len;
3474 new_beacon->tail = pos;
3475 memcpy(pos, beacon->tail, beacon->tail_len);
3476 pos += beacon->tail_len;
3478 if (beacon->beacon_ies_len) {
3479 new_beacon->beacon_ies_len = beacon->beacon_ies_len;
3480 new_beacon->beacon_ies = pos;
3481 memcpy(pos, beacon->beacon_ies, beacon->beacon_ies_len);
3482 pos += beacon->beacon_ies_len;
3484 if (beacon->proberesp_ies_len) {
3485 new_beacon->proberesp_ies_len = beacon->proberesp_ies_len;
3486 new_beacon->proberesp_ies = pos;
3487 memcpy(pos, beacon->proberesp_ies, beacon->proberesp_ies_len);
3488 pos += beacon->proberesp_ies_len;
3490 if (beacon->assocresp_ies_len) {
3491 new_beacon->assocresp_ies_len = beacon->assocresp_ies_len;
3492 new_beacon->assocresp_ies = pos;
3493 memcpy(pos, beacon->assocresp_ies, beacon->assocresp_ies_len);
3494 pos += beacon->assocresp_ies_len;
3496 if (beacon->probe_resp_len) {
3497 new_beacon->probe_resp_len = beacon->probe_resp_len;
3498 new_beacon->probe_resp = pos;
3499 memcpy(pos, beacon->probe_resp, beacon->probe_resp_len);
3500 pos += beacon->probe_resp_len;
3502 if (beacon->mbssid_ies && beacon->mbssid_ies->cnt) {
3503 pos += ieee80211_copy_mbssid_beacon(pos,
3504 new_beacon->mbssid_ies,
3505 beacon->mbssid_ies);
3506 if (beacon->rnr_ies && beacon->rnr_ies->cnt)
3507 pos += ieee80211_copy_rnr_beacon(pos,
3508 new_beacon->rnr_ies,
3512 /* might copy -1, meaning no changes requested */
3513 new_beacon->ftm_responder = beacon->ftm_responder;
3515 new_beacon->lci_len = beacon->lci_len;
3516 new_beacon->lci = pos;
3517 memcpy(pos, beacon->lci, beacon->lci_len);
3518 pos += beacon->lci_len;
3520 if (beacon->civicloc) {
3521 new_beacon->civicloc_len = beacon->civicloc_len;
3522 new_beacon->civicloc = pos;
3523 memcpy(pos, beacon->civicloc, beacon->civicloc_len);
3524 pos += beacon->civicloc_len;
3530 void ieee80211_csa_finish(struct ieee80211_vif *vif)
3532 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
3533 struct ieee80211_local *local = sdata->local;
3537 if (vif->mbssid_tx_vif == vif) {
3538 /* Trigger ieee80211_csa_finish() on the non-transmitting
3539 * interfaces when channel switch is received on
3540 * transmitting interface
3542 struct ieee80211_sub_if_data *iter;
3544 list_for_each_entry_rcu(iter, &local->interfaces, list) {
3545 if (!ieee80211_sdata_running(iter))
3548 if (iter == sdata || iter->vif.mbssid_tx_vif != vif)
3551 wiphy_work_queue(iter->local->hw.wiphy,
3552 &iter->deflink.csa_finalize_work);
3555 wiphy_work_queue(local->hw.wiphy, &sdata->deflink.csa_finalize_work);
3559 EXPORT_SYMBOL(ieee80211_csa_finish);
3561 void ieee80211_channel_switch_disconnect(struct ieee80211_vif *vif, bool block_tx)
3563 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
3564 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
3565 struct ieee80211_local *local = sdata->local;
3567 sdata->deflink.csa_block_tx = block_tx;
3568 sdata_info(sdata, "channel switch failed, disconnecting\n");
3569 wiphy_work_queue(local->hw.wiphy, &ifmgd->csa_connection_drop_work);
3571 EXPORT_SYMBOL(ieee80211_channel_switch_disconnect);
3573 static int ieee80211_set_after_csa_beacon(struct ieee80211_sub_if_data *sdata,
3578 switch (sdata->vif.type) {
3579 case NL80211_IFTYPE_AP:
3580 if (!sdata->deflink.u.ap.next_beacon)
3583 err = ieee80211_assign_beacon(sdata, &sdata->deflink,
3584 sdata->deflink.u.ap.next_beacon,
3585 NULL, NULL, changed);
3586 ieee80211_free_next_beacon(&sdata->deflink);
3591 case NL80211_IFTYPE_ADHOC:
3592 err = ieee80211_ibss_finish_csa(sdata, changed);
3596 #ifdef CONFIG_MAC80211_MESH
3597 case NL80211_IFTYPE_MESH_POINT:
3598 err = ieee80211_mesh_finish_csa(sdata, changed);
3611 static int __ieee80211_csa_finalize(struct ieee80211_link_data *link_data)
3613 struct ieee80211_sub_if_data *sdata = link_data->sdata;
3614 struct ieee80211_local *local = sdata->local;
3618 lockdep_assert_wiphy(local->hw.wiphy);
3621 * using reservation isn't immediate as it may be deferred until later
3622 * with multi-vif. once reservation is complete it will re-schedule the
3623 * work with no reserved_chanctx so verify chandef to check if it
3624 * completed successfully
3627 if (link_data->reserved_chanctx) {
3629 * with multi-vif csa driver may call ieee80211_csa_finish()
3630 * many times while waiting for other interfaces to use their
3633 if (link_data->reserved_ready)
3636 return ieee80211_link_use_reserved_context(&sdata->deflink);
3639 if (!cfg80211_chandef_identical(&link_data->conf->chandef,
3640 &link_data->csa_chandef))
3643 sdata->vif.bss_conf.csa_active = false;
3645 err = ieee80211_set_after_csa_beacon(sdata, &changed);
3649 if (sdata->vif.bss_conf.eht_puncturing != sdata->vif.bss_conf.csa_punct_bitmap) {
3650 sdata->vif.bss_conf.eht_puncturing =
3651 sdata->vif.bss_conf.csa_punct_bitmap;
3652 changed |= BSS_CHANGED_EHT_PUNCTURING;
3655 ieee80211_link_info_change_notify(sdata, link_data, changed);
3657 if (link_data->csa_block_tx) {
3658 ieee80211_wake_vif_queues(local, sdata,
3659 IEEE80211_QUEUE_STOP_REASON_CSA);
3660 link_data->csa_block_tx = false;
3663 err = drv_post_channel_switch(link_data);
3667 cfg80211_ch_switch_notify(sdata->dev, &link_data->csa_chandef,
3669 link_data->conf->eht_puncturing);
3674 static void ieee80211_csa_finalize(struct ieee80211_link_data *link_data)
3676 struct ieee80211_sub_if_data *sdata = link_data->sdata;
3678 if (__ieee80211_csa_finalize(link_data)) {
3679 sdata_info(sdata, "failed to finalize CSA, disconnecting\n");
3680 cfg80211_stop_iface(sdata->local->hw.wiphy, &sdata->wdev,
3685 void ieee80211_csa_finalize_work(struct wiphy *wiphy, struct wiphy_work *work)
3687 struct ieee80211_link_data *link =
3688 container_of(work, struct ieee80211_link_data, csa_finalize_work);
3689 struct ieee80211_sub_if_data *sdata = link->sdata;
3690 struct ieee80211_local *local = sdata->local;
3692 lockdep_assert_wiphy(local->hw.wiphy);
3694 /* AP might have been stopped while waiting for the lock. */
3695 if (!link->conf->csa_active)
3698 if (!ieee80211_sdata_running(sdata))
3701 ieee80211_csa_finalize(link);
3704 static int ieee80211_set_csa_beacon(struct ieee80211_sub_if_data *sdata,
3705 struct cfg80211_csa_settings *params,
3708 struct ieee80211_csa_settings csa = {};
3711 switch (sdata->vif.type) {
3712 case NL80211_IFTYPE_AP:
3713 sdata->deflink.u.ap.next_beacon =
3714 cfg80211_beacon_dup(¶ms->beacon_after);
3715 if (!sdata->deflink.u.ap.next_beacon)
3719 * With a count of 0, we don't have to wait for any
3720 * TBTT before switching, so complete the CSA
3721 * immediately. In theory, with a count == 1 we
3722 * should delay the switch until just before the next
3723 * TBTT, but that would complicate things so we switch
3724 * immediately too. If we would delay the switch
3725 * until the next TBTT, we would have to set the probe
3728 * TODO: A channel switch with count <= 1 without
3729 * sending a CSA action frame is kind of useless,
3730 * because the clients won't know we're changing
3731 * channels. The action frame must be implemented
3732 * either here or in the userspace.
3734 if (params->count <= 1)
3737 if ((params->n_counter_offsets_beacon >
3738 IEEE80211_MAX_CNTDWN_COUNTERS_NUM) ||
3739 (params->n_counter_offsets_presp >
3740 IEEE80211_MAX_CNTDWN_COUNTERS_NUM)) {
3741 ieee80211_free_next_beacon(&sdata->deflink);
3745 csa.counter_offsets_beacon = params->counter_offsets_beacon;
3746 csa.counter_offsets_presp = params->counter_offsets_presp;
3747 csa.n_counter_offsets_beacon = params->n_counter_offsets_beacon;
3748 csa.n_counter_offsets_presp = params->n_counter_offsets_presp;
3749 csa.count = params->count;
3751 err = ieee80211_assign_beacon(sdata, &sdata->deflink,
3752 ¶ms->beacon_csa, &csa,
3755 ieee80211_free_next_beacon(&sdata->deflink);
3760 case NL80211_IFTYPE_ADHOC:
3761 if (!sdata->vif.cfg.ibss_joined)
3764 if (params->chandef.width != sdata->u.ibss.chandef.width)
3767 switch (params->chandef.width) {
3768 case NL80211_CHAN_WIDTH_40:
3769 if (cfg80211_get_chandef_type(¶ms->chandef) !=
3770 cfg80211_get_chandef_type(&sdata->u.ibss.chandef))
3773 case NL80211_CHAN_WIDTH_5:
3774 case NL80211_CHAN_WIDTH_10:
3775 case NL80211_CHAN_WIDTH_20_NOHT:
3776 case NL80211_CHAN_WIDTH_20:
3782 /* changes into another band are not supported */
3783 if (sdata->u.ibss.chandef.chan->band !=
3784 params->chandef.chan->band)
3787 /* see comments in the NL80211_IFTYPE_AP block */
3788 if (params->count > 1) {
3789 err = ieee80211_ibss_csa_beacon(sdata, params, changed);
3794 ieee80211_send_action_csa(sdata, params);
3797 #ifdef CONFIG_MAC80211_MESH
3798 case NL80211_IFTYPE_MESH_POINT: {
3799 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
3801 /* changes into another band are not supported */
3802 if (sdata->vif.bss_conf.chandef.chan->band !=
3803 params->chandef.chan->band)
3806 if (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_NONE) {
3807 ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_INIT;
3808 if (!ifmsh->pre_value)
3809 ifmsh->pre_value = 1;
3814 /* see comments in the NL80211_IFTYPE_AP block */
3815 if (params->count > 1) {
3816 err = ieee80211_mesh_csa_beacon(sdata, params, changed);
3818 ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_NONE;
3823 if (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_INIT)
3824 ieee80211_send_action_csa(sdata, params);
3836 static void ieee80211_color_change_abort(struct ieee80211_sub_if_data *sdata)
3838 sdata->vif.bss_conf.color_change_active = false;
3840 ieee80211_free_next_beacon(&sdata->deflink);
3842 cfg80211_color_change_aborted_notify(sdata->dev);
3846 __ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
3847 struct cfg80211_csa_settings *params)
3849 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3850 struct ieee80211_local *local = sdata->local;
3851 struct ieee80211_channel_switch ch_switch;
3852 struct ieee80211_chanctx_conf *conf;
3853 struct ieee80211_chanctx *chanctx;
3857 lockdep_assert_wiphy(local->hw.wiphy);
3859 if (!list_empty(&local->roc_list) || local->scanning)
3862 if (sdata->wdev.cac_started)
3865 if (cfg80211_chandef_identical(¶ms->chandef,
3866 &sdata->vif.bss_conf.chandef))
3869 /* don't allow another channel switch if one is already active. */
3870 if (sdata->vif.bss_conf.csa_active)
3873 conf = rcu_dereference_protected(sdata->vif.bss_conf.chanctx_conf,
3874 lockdep_is_held(&local->hw.wiphy->mtx));
3880 if (params->chandef.chan->freq_offset) {
3881 /* this may work, but is untested */
3886 chanctx = container_of(conf, struct ieee80211_chanctx, conf);
3888 ch_switch.timestamp = 0;
3889 ch_switch.device_timestamp = 0;
3890 ch_switch.block_tx = params->block_tx;
3891 ch_switch.chandef = params->chandef;
3892 ch_switch.count = params->count;
3894 err = drv_pre_channel_switch(sdata, &ch_switch);
3898 err = ieee80211_link_reserve_chanctx(&sdata->deflink, ¶ms->chandef,
3900 params->radar_required);
3904 /* if reservation is invalid then this will fail */
3905 err = ieee80211_check_combinations(sdata, NULL, chanctx->mode, 0);
3907 ieee80211_link_unreserve_chanctx(&sdata->deflink);
3911 /* if there is a color change in progress, abort it */
3912 if (sdata->vif.bss_conf.color_change_active)
3913 ieee80211_color_change_abort(sdata);
3915 err = ieee80211_set_csa_beacon(sdata, params, &changed);
3917 ieee80211_link_unreserve_chanctx(&sdata->deflink);
3921 if (params->punct_bitmap && !sdata->vif.bss_conf.eht_support)
3924 sdata->deflink.csa_chandef = params->chandef;
3925 sdata->deflink.csa_block_tx = params->block_tx;
3926 sdata->vif.bss_conf.csa_active = true;
3927 sdata->vif.bss_conf.csa_punct_bitmap = params->punct_bitmap;
3929 if (sdata->deflink.csa_block_tx)
3930 ieee80211_stop_vif_queues(local, sdata,
3931 IEEE80211_QUEUE_STOP_REASON_CSA);
3933 cfg80211_ch_switch_started_notify(sdata->dev,
3934 &sdata->deflink.csa_chandef, 0,
3935 params->count, params->block_tx,
3936 sdata->vif.bss_conf.csa_punct_bitmap);
3939 ieee80211_link_info_change_notify(sdata, &sdata->deflink,
3941 drv_channel_switch_beacon(sdata, ¶ms->chandef);
3943 /* if the beacon didn't change, we can finalize immediately */
3944 ieee80211_csa_finalize(&sdata->deflink);
3951 int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
3952 struct cfg80211_csa_settings *params)
3954 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3955 struct ieee80211_local *local = sdata->local;
3957 lockdep_assert_wiphy(local->hw.wiphy);
3959 return __ieee80211_channel_switch(wiphy, dev, params);
3962 u64 ieee80211_mgmt_tx_cookie(struct ieee80211_local *local)
3964 lockdep_assert_wiphy(local->hw.wiphy);
3966 local->roc_cookie_counter++;
3968 /* wow, you wrapped 64 bits ... more likely a bug */
3969 if (WARN_ON(local->roc_cookie_counter == 0))
3970 local->roc_cookie_counter++;
3972 return local->roc_cookie_counter;
3975 int ieee80211_attach_ack_skb(struct ieee80211_local *local, struct sk_buff *skb,
3976 u64 *cookie, gfp_t gfp)
3978 unsigned long spin_flags;
3979 struct sk_buff *ack_skb;
3982 ack_skb = skb_copy(skb, gfp);
3986 spin_lock_irqsave(&local->ack_status_lock, spin_flags);
3987 id = idr_alloc(&local->ack_status_frames, ack_skb,
3988 1, 0x2000, GFP_ATOMIC);
3989 spin_unlock_irqrestore(&local->ack_status_lock, spin_flags);
3996 IEEE80211_SKB_CB(skb)->status_data_idr = 1;
3997 IEEE80211_SKB_CB(skb)->status_data = id;
3999 *cookie = ieee80211_mgmt_tx_cookie(local);
4000 IEEE80211_SKB_CB(ack_skb)->ack.cookie = *cookie;
4006 ieee80211_update_mgmt_frame_registrations(struct wiphy *wiphy,
4007 struct wireless_dev *wdev,
4008 struct mgmt_frame_regs *upd)
4010 struct ieee80211_local *local = wiphy_priv(wiphy);
4011 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
4012 u32 preq_mask = BIT(IEEE80211_STYPE_PROBE_REQ >> 4);
4013 u32 action_mask = BIT(IEEE80211_STYPE_ACTION >> 4);
4014 bool global_change, intf_change;
4017 (local->probe_req_reg != !!(upd->global_stypes & preq_mask)) ||
4018 (local->rx_mcast_action_reg !=
4019 !!(upd->global_mcast_stypes & action_mask));
4020 local->probe_req_reg = upd->global_stypes & preq_mask;
4021 local->rx_mcast_action_reg = upd->global_mcast_stypes & action_mask;
4023 intf_change = (sdata->vif.probe_req_reg !=
4024 !!(upd->interface_stypes & preq_mask)) ||
4025 (sdata->vif.rx_mcast_action_reg !=
4026 !!(upd->interface_mcast_stypes & action_mask));
4027 sdata->vif.probe_req_reg = upd->interface_stypes & preq_mask;
4028 sdata->vif.rx_mcast_action_reg =
4029 upd->interface_mcast_stypes & action_mask;
4031 if (!local->open_count)
4034 if (intf_change && ieee80211_sdata_running(sdata))
4035 drv_config_iface_filter(local, sdata,
4036 sdata->vif.probe_req_reg ?
4041 ieee80211_configure_filter(local);
4044 static int ieee80211_set_antenna(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant)
4046 struct ieee80211_local *local = wiphy_priv(wiphy);
4051 return drv_set_antenna(local, tx_ant, rx_ant);
4054 static int ieee80211_get_antenna(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant)
4056 struct ieee80211_local *local = wiphy_priv(wiphy);
4058 return drv_get_antenna(local, tx_ant, rx_ant);
4061 static int ieee80211_set_rekey_data(struct wiphy *wiphy,
4062 struct net_device *dev,
4063 struct cfg80211_gtk_rekey_data *data)
4065 struct ieee80211_local *local = wiphy_priv(wiphy);
4066 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4068 if (!local->ops->set_rekey_data)
4071 drv_set_rekey_data(local, sdata, data);
4076 static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev,
4077 const u8 *peer, u64 *cookie)
4079 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4080 struct ieee80211_local *local = sdata->local;
4081 struct ieee80211_qos_hdr *nullfunc;
4082 struct sk_buff *skb;
4083 int size = sizeof(*nullfunc);
4086 struct ieee80211_tx_info *info;
4087 struct sta_info *sta;
4088 struct ieee80211_chanctx_conf *chanctx_conf;
4089 enum nl80211_band band;
4092 /* the lock is needed to assign the cookie later */
4093 lockdep_assert_wiphy(local->hw.wiphy);
4096 sta = sta_info_get_bss(sdata, peer);
4104 chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf);
4105 if (WARN_ON(!chanctx_conf)) {
4109 band = chanctx_conf->def.chan->band;
4112 fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
4113 IEEE80211_STYPE_QOS_NULLFUNC |
4114 IEEE80211_FCTL_FROMDS);
4117 fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
4118 IEEE80211_STYPE_NULLFUNC |
4119 IEEE80211_FCTL_FROMDS);
4122 skb = dev_alloc_skb(local->hw.extra_tx_headroom + size);
4130 skb_reserve(skb, local->hw.extra_tx_headroom);
4132 nullfunc = skb_put(skb, size);
4133 nullfunc->frame_control = fc;
4134 nullfunc->duration_id = 0;
4135 memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN);
4136 memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN);
4137 memcpy(nullfunc->addr3, sdata->vif.addr, ETH_ALEN);
4138 nullfunc->seq_ctrl = 0;
4140 info = IEEE80211_SKB_CB(skb);
4142 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS |
4143 IEEE80211_TX_INTFL_NL80211_FRAME_TX;
4146 skb_set_queue_mapping(skb, IEEE80211_AC_VO);
4149 nullfunc->qos_ctrl = cpu_to_le16(7);
4151 ret = ieee80211_attach_ack_skb(local, skb, cookie, GFP_ATOMIC);
4158 ieee80211_xmit(sdata, sta, skb);
4168 static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
4169 struct wireless_dev *wdev,
4170 unsigned int link_id,
4171 struct cfg80211_chan_def *chandef)
4173 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
4174 struct ieee80211_local *local = wiphy_priv(wiphy);
4175 struct ieee80211_chanctx_conf *chanctx_conf;
4176 struct ieee80211_link_data *link;
4180 link = rcu_dereference(sdata->link[link_id]);
4186 chanctx_conf = rcu_dereference(link->conf->chanctx_conf);
4188 *chandef = link->conf->chandef;
4190 } else if (local->open_count > 0 &&
4191 local->open_count == local->monitors &&
4192 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
4193 if (local->use_chanctx)
4194 *chandef = local->monitor_chandef;
4196 *chandef = local->_oper_chandef;
4206 static void ieee80211_set_wakeup(struct wiphy *wiphy, bool enabled)
4208 drv_set_wakeup(wiphy_priv(wiphy), enabled);
4212 static int ieee80211_set_qos_map(struct wiphy *wiphy,
4213 struct net_device *dev,
4214 struct cfg80211_qos_map *qos_map)
4216 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4217 struct mac80211_qos_map *new_qos_map, *old_qos_map;
4220 new_qos_map = kzalloc(sizeof(*new_qos_map), GFP_KERNEL);
4223 memcpy(&new_qos_map->qos_map, qos_map, sizeof(*qos_map));
4225 /* A NULL qos_map was passed to disable QoS mapping */
4229 old_qos_map = sdata_dereference(sdata->qos_map, sdata);
4230 rcu_assign_pointer(sdata->qos_map, new_qos_map);
4232 kfree_rcu(old_qos_map, rcu_head);
4237 static int ieee80211_set_ap_chanwidth(struct wiphy *wiphy,
4238 struct net_device *dev,
4239 unsigned int link_id,
4240 struct cfg80211_chan_def *chandef)
4242 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4243 struct ieee80211_link_data *link;
4247 link = sdata_dereference(sdata->link[link_id], sdata);
4249 ret = ieee80211_link_change_bandwidth(link, chandef, &changed);
4251 ieee80211_link_info_change_notify(sdata, link, changed);
4256 static int ieee80211_add_tx_ts(struct wiphy *wiphy, struct net_device *dev,
4257 u8 tsid, const u8 *peer, u8 up,
4260 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4261 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
4262 int ac = ieee802_1d_to_ac[up];
4264 if (sdata->vif.type != NL80211_IFTYPE_STATION)
4267 if (!(sdata->wmm_acm & BIT(up)))
4270 if (ifmgd->tx_tspec[ac].admitted_time)
4273 if (admitted_time) {
4274 ifmgd->tx_tspec[ac].admitted_time = 32 * admitted_time;
4275 ifmgd->tx_tspec[ac].tsid = tsid;
4276 ifmgd->tx_tspec[ac].up = up;
4282 static int ieee80211_del_tx_ts(struct wiphy *wiphy, struct net_device *dev,
4283 u8 tsid, const u8 *peer)
4285 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4286 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
4287 struct ieee80211_local *local = wiphy_priv(wiphy);
4290 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
4291 struct ieee80211_sta_tx_tspec *tx_tspec = &ifmgd->tx_tspec[ac];
4293 /* skip unused entries */
4294 if (!tx_tspec->admitted_time)
4297 if (tx_tspec->tsid != tsid)
4300 /* due to this new packets will be reassigned to non-ACM ACs */
4303 /* Make sure that all packets have been sent to avoid to
4304 * restore the QoS params on packets that are still on the
4308 ieee80211_flush_queues(local, sdata, false);
4310 /* restore the normal QoS parameters
4311 * (unconditionally to avoid races)
4313 tx_tspec->action = TX_TSPEC_ACTION_STOP_DOWNGRADE;
4314 tx_tspec->downgraded = false;
4315 ieee80211_sta_handle_tspec_ac_params(sdata);
4317 /* finally clear all the data */
4318 memset(tx_tspec, 0, sizeof(*tx_tspec));
4326 void ieee80211_nan_func_terminated(struct ieee80211_vif *vif,
4328 enum nl80211_nan_func_term_reason reason,
4331 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
4332 struct cfg80211_nan_func *func;
4335 if (WARN_ON(vif->type != NL80211_IFTYPE_NAN))
4338 spin_lock_bh(&sdata->u.nan.func_lock);
4340 func = idr_find(&sdata->u.nan.function_inst_ids, inst_id);
4341 if (WARN_ON(!func)) {
4342 spin_unlock_bh(&sdata->u.nan.func_lock);
4346 cookie = func->cookie;
4347 idr_remove(&sdata->u.nan.function_inst_ids, inst_id);
4349 spin_unlock_bh(&sdata->u.nan.func_lock);
4351 cfg80211_free_nan_func(func);
4353 cfg80211_nan_func_terminated(ieee80211_vif_to_wdev(vif), inst_id,
4354 reason, cookie, gfp);
4356 EXPORT_SYMBOL(ieee80211_nan_func_terminated);
4358 void ieee80211_nan_func_match(struct ieee80211_vif *vif,
4359 struct cfg80211_nan_match_params *match,
4362 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
4363 struct cfg80211_nan_func *func;
4365 if (WARN_ON(vif->type != NL80211_IFTYPE_NAN))
4368 spin_lock_bh(&sdata->u.nan.func_lock);
4370 func = idr_find(&sdata->u.nan.function_inst_ids, match->inst_id);
4371 if (WARN_ON(!func)) {
4372 spin_unlock_bh(&sdata->u.nan.func_lock);
4375 match->cookie = func->cookie;
4377 spin_unlock_bh(&sdata->u.nan.func_lock);
4379 cfg80211_nan_match(ieee80211_vif_to_wdev(vif), match, gfp);
4381 EXPORT_SYMBOL(ieee80211_nan_func_match);
4383 static int ieee80211_set_multicast_to_unicast(struct wiphy *wiphy,
4384 struct net_device *dev,
4387 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4389 sdata->u.ap.multicast_to_unicast = enabled;
4394 void ieee80211_fill_txq_stats(struct cfg80211_txq_stats *txqstats,
4395 struct txq_info *txqi)
4397 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_BACKLOG_BYTES))) {
4398 txqstats->filled |= BIT(NL80211_TXQ_STATS_BACKLOG_BYTES);
4399 txqstats->backlog_bytes = txqi->tin.backlog_bytes;
4402 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_BACKLOG_PACKETS))) {
4403 txqstats->filled |= BIT(NL80211_TXQ_STATS_BACKLOG_PACKETS);
4404 txqstats->backlog_packets = txqi->tin.backlog_packets;
4407 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_FLOWS))) {
4408 txqstats->filled |= BIT(NL80211_TXQ_STATS_FLOWS);
4409 txqstats->flows = txqi->tin.flows;
4412 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_DROPS))) {
4413 txqstats->filled |= BIT(NL80211_TXQ_STATS_DROPS);
4414 txqstats->drops = txqi->cstats.drop_count;
4417 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_ECN_MARKS))) {
4418 txqstats->filled |= BIT(NL80211_TXQ_STATS_ECN_MARKS);
4419 txqstats->ecn_marks = txqi->cstats.ecn_mark;
4422 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_OVERLIMIT))) {
4423 txqstats->filled |= BIT(NL80211_TXQ_STATS_OVERLIMIT);
4424 txqstats->overlimit = txqi->tin.overlimit;
4427 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_COLLISIONS))) {
4428 txqstats->filled |= BIT(NL80211_TXQ_STATS_COLLISIONS);
4429 txqstats->collisions = txqi->tin.collisions;
4432 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_TX_BYTES))) {
4433 txqstats->filled |= BIT(NL80211_TXQ_STATS_TX_BYTES);
4434 txqstats->tx_bytes = txqi->tin.tx_bytes;
4437 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_TX_PACKETS))) {
4438 txqstats->filled |= BIT(NL80211_TXQ_STATS_TX_PACKETS);
4439 txqstats->tx_packets = txqi->tin.tx_packets;
4443 static int ieee80211_get_txq_stats(struct wiphy *wiphy,
4444 struct wireless_dev *wdev,
4445 struct cfg80211_txq_stats *txqstats)
4447 struct ieee80211_local *local = wiphy_priv(wiphy);
4448 struct ieee80211_sub_if_data *sdata;
4451 spin_lock_bh(&local->fq.lock);
4455 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
4456 if (!sdata->vif.txq) {
4460 ieee80211_fill_txq_stats(txqstats, to_txq_info(sdata->vif.txq));
4463 txqstats->filled |= BIT(NL80211_TXQ_STATS_BACKLOG_PACKETS) |
4464 BIT(NL80211_TXQ_STATS_BACKLOG_BYTES) |
4465 BIT(NL80211_TXQ_STATS_OVERLIMIT) |
4466 BIT(NL80211_TXQ_STATS_OVERMEMORY) |
4467 BIT(NL80211_TXQ_STATS_COLLISIONS) |
4468 BIT(NL80211_TXQ_STATS_MAX_FLOWS);
4469 txqstats->backlog_packets = local->fq.backlog;
4470 txqstats->backlog_bytes = local->fq.memory_usage;
4471 txqstats->overlimit = local->fq.overlimit;
4472 txqstats->overmemory = local->fq.overmemory;
4473 txqstats->collisions = local->fq.collisions;
4474 txqstats->max_flows = local->fq.flows_cnt;
4479 spin_unlock_bh(&local->fq.lock);
4485 ieee80211_get_ftm_responder_stats(struct wiphy *wiphy,
4486 struct net_device *dev,
4487 struct cfg80211_ftm_responder_stats *ftm_stats)
4489 struct ieee80211_local *local = wiphy_priv(wiphy);
4490 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4492 return drv_get_ftm_responder_stats(local, sdata, ftm_stats);
4496 ieee80211_start_pmsr(struct wiphy *wiphy, struct wireless_dev *dev,
4497 struct cfg80211_pmsr_request *request)
4499 struct ieee80211_local *local = wiphy_priv(wiphy);
4500 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(dev);
4502 return drv_start_pmsr(local, sdata, request);
4506 ieee80211_abort_pmsr(struct wiphy *wiphy, struct wireless_dev *dev,
4507 struct cfg80211_pmsr_request *request)
4509 struct ieee80211_local *local = wiphy_priv(wiphy);
4510 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(dev);
4512 return drv_abort_pmsr(local, sdata, request);
4515 static int ieee80211_set_tid_config(struct wiphy *wiphy,
4516 struct net_device *dev,
4517 struct cfg80211_tid_config *tid_conf)
4519 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4520 struct sta_info *sta;
4522 lockdep_assert_wiphy(sdata->local->hw.wiphy);
4524 if (!sdata->local->ops->set_tid_config)
4527 if (!tid_conf->peer)
4528 return drv_set_tid_config(sdata->local, sdata, NULL, tid_conf);
4530 sta = sta_info_get_bss(sdata, tid_conf->peer);
4534 return drv_set_tid_config(sdata->local, sdata, &sta->sta, tid_conf);
4537 static int ieee80211_reset_tid_config(struct wiphy *wiphy,
4538 struct net_device *dev,
4539 const u8 *peer, u8 tids)
4541 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4542 struct sta_info *sta;
4544 lockdep_assert_wiphy(sdata->local->hw.wiphy);
4546 if (!sdata->local->ops->reset_tid_config)
4550 return drv_reset_tid_config(sdata->local, sdata, NULL, tids);
4552 sta = sta_info_get_bss(sdata, peer);
4556 return drv_reset_tid_config(sdata->local, sdata, &sta->sta, tids);
4559 static int ieee80211_set_sar_specs(struct wiphy *wiphy,
4560 struct cfg80211_sar_specs *sar)
4562 struct ieee80211_local *local = wiphy_priv(wiphy);
4564 if (!local->ops->set_sar_specs)
4567 return local->ops->set_sar_specs(&local->hw, sar);
4571 ieee80211_set_after_color_change_beacon(struct ieee80211_sub_if_data *sdata,
4574 switch (sdata->vif.type) {
4575 case NL80211_IFTYPE_AP: {
4578 if (!sdata->deflink.u.ap.next_beacon)
4581 ret = ieee80211_assign_beacon(sdata, &sdata->deflink,
4582 sdata->deflink.u.ap.next_beacon,
4583 NULL, NULL, changed);
4584 ieee80211_free_next_beacon(&sdata->deflink);
4600 ieee80211_set_color_change_beacon(struct ieee80211_sub_if_data *sdata,
4601 struct cfg80211_color_change_settings *params,
4604 struct ieee80211_color_change_settings color_change = {};
4607 switch (sdata->vif.type) {
4608 case NL80211_IFTYPE_AP:
4609 sdata->deflink.u.ap.next_beacon =
4610 cfg80211_beacon_dup(¶ms->beacon_next);
4611 if (!sdata->deflink.u.ap.next_beacon)
4614 if (params->count <= 1)
4617 color_change.counter_offset_beacon =
4618 params->counter_offset_beacon;
4619 color_change.counter_offset_presp =
4620 params->counter_offset_presp;
4621 color_change.count = params->count;
4623 err = ieee80211_assign_beacon(sdata, &sdata->deflink,
4624 ¶ms->beacon_color_change,
4625 NULL, &color_change, changed);
4627 ieee80211_free_next_beacon(&sdata->deflink);
4639 ieee80211_color_change_bss_config_notify(struct ieee80211_sub_if_data *sdata,
4640 u8 color, int enable, u64 changed)
4642 lockdep_assert_wiphy(sdata->local->hw.wiphy);
4644 sdata->vif.bss_conf.he_bss_color.color = color;
4645 sdata->vif.bss_conf.he_bss_color.enabled = enable;
4646 changed |= BSS_CHANGED_HE_BSS_COLOR;
4648 ieee80211_link_info_change_notify(sdata, &sdata->deflink, changed);
4650 if (!sdata->vif.bss_conf.nontransmitted && sdata->vif.mbssid_tx_vif) {
4651 struct ieee80211_sub_if_data *child;
4653 list_for_each_entry(child, &sdata->local->interfaces, list) {
4654 if (child != sdata && child->vif.mbssid_tx_vif == &sdata->vif) {
4655 child->vif.bss_conf.he_bss_color.color = color;
4656 child->vif.bss_conf.he_bss_color.enabled = enable;
4657 ieee80211_link_info_change_notify(child,
4659 BSS_CHANGED_HE_BSS_COLOR);
4665 static int ieee80211_color_change_finalize(struct ieee80211_sub_if_data *sdata)
4667 struct ieee80211_local *local = sdata->local;
4671 lockdep_assert_wiphy(local->hw.wiphy);
4673 sdata->vif.bss_conf.color_change_active = false;
4675 err = ieee80211_set_after_color_change_beacon(sdata, &changed);
4677 cfg80211_color_change_aborted_notify(sdata->dev);
4681 ieee80211_color_change_bss_config_notify(sdata,
4682 sdata->vif.bss_conf.color_change_color,
4684 cfg80211_color_change_notify(sdata->dev);
4689 void ieee80211_color_change_finalize_work(struct wiphy *wiphy,
4690 struct wiphy_work *work)
4692 struct ieee80211_sub_if_data *sdata =
4693 container_of(work, struct ieee80211_sub_if_data,
4694 deflink.color_change_finalize_work);
4695 struct ieee80211_local *local = sdata->local;
4697 lockdep_assert_wiphy(local->hw.wiphy);
4699 /* AP might have been stopped while waiting for the lock. */
4700 if (!sdata->vif.bss_conf.color_change_active)
4703 if (!ieee80211_sdata_running(sdata))
4706 ieee80211_color_change_finalize(sdata);
4709 void ieee80211_color_collision_detection_work(struct work_struct *work)
4711 struct delayed_work *delayed_work = to_delayed_work(work);
4712 struct ieee80211_link_data *link =
4713 container_of(delayed_work, struct ieee80211_link_data,
4714 color_collision_detect_work);
4715 struct ieee80211_sub_if_data *sdata = link->sdata;
4717 cfg80211_obss_color_collision_notify(sdata->dev, link->color_bitmap);
4720 void ieee80211_color_change_finish(struct ieee80211_vif *vif)
4722 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
4724 wiphy_work_queue(sdata->local->hw.wiphy,
4725 &sdata->deflink.color_change_finalize_work);
4727 EXPORT_SYMBOL_GPL(ieee80211_color_change_finish);
4730 ieee80211_obss_color_collision_notify(struct ieee80211_vif *vif,
4731 u64 color_bitmap, gfp_t gfp)
4733 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
4734 struct ieee80211_link_data *link = &sdata->deflink;
4736 if (sdata->vif.bss_conf.color_change_active || sdata->vif.bss_conf.csa_active)
4739 if (delayed_work_pending(&link->color_collision_detect_work))
4742 link->color_bitmap = color_bitmap;
4743 /* queue the color collision detection event every 500 ms in order to
4744 * avoid sending too much netlink messages to userspace.
4746 ieee80211_queue_delayed_work(&sdata->local->hw,
4747 &link->color_collision_detect_work,
4748 msecs_to_jiffies(500));
4750 EXPORT_SYMBOL_GPL(ieee80211_obss_color_collision_notify);
4753 ieee80211_color_change(struct wiphy *wiphy, struct net_device *dev,
4754 struct cfg80211_color_change_settings *params)
4756 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4757 struct ieee80211_local *local = sdata->local;
4761 lockdep_assert_wiphy(local->hw.wiphy);
4763 if (sdata->vif.bss_conf.nontransmitted)
4766 /* don't allow another color change if one is already active or if csa
4769 if (sdata->vif.bss_conf.color_change_active || sdata->vif.bss_conf.csa_active) {
4774 err = ieee80211_set_color_change_beacon(sdata, params, &changed);
4778 sdata->vif.bss_conf.color_change_active = true;
4779 sdata->vif.bss_conf.color_change_color = params->color;
4781 cfg80211_color_change_started_notify(sdata->dev, params->count);
4784 ieee80211_color_change_bss_config_notify(sdata, 0, 0, changed);
4786 /* if the beacon didn't change, we can finalize immediately */
4787 ieee80211_color_change_finalize(sdata);
4795 ieee80211_set_radar_background(struct wiphy *wiphy,
4796 struct cfg80211_chan_def *chandef)
4798 struct ieee80211_local *local = wiphy_priv(wiphy);
4800 if (!local->ops->set_radar_background)
4803 return local->ops->set_radar_background(&local->hw, chandef);
4806 static int ieee80211_add_intf_link(struct wiphy *wiphy,
4807 struct wireless_dev *wdev,
4808 unsigned int link_id)
4810 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
4812 lockdep_assert_wiphy(sdata->local->hw.wiphy);
4814 if (wdev->use_4addr)
4817 return ieee80211_vif_set_links(sdata, wdev->valid_links, 0);
4820 static void ieee80211_del_intf_link(struct wiphy *wiphy,
4821 struct wireless_dev *wdev,
4822 unsigned int link_id)
4824 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
4826 lockdep_assert_wiphy(sdata->local->hw.wiphy);
4828 ieee80211_vif_set_links(sdata, wdev->valid_links, 0);
4831 static int sta_add_link_station(struct ieee80211_local *local,
4832 struct ieee80211_sub_if_data *sdata,
4833 struct link_station_parameters *params)
4835 struct sta_info *sta;
4838 sta = sta_info_get_bss(sdata, params->mld_mac);
4842 if (!sta->sta.valid_links)
4845 if (sta->sta.valid_links & BIT(params->link_id))
4848 ret = ieee80211_sta_allocate_link(sta, params->link_id);
4852 ret = sta_link_apply_parameters(local, sta, true, params);
4854 ieee80211_sta_free_link(sta, params->link_id);
4858 /* ieee80211_sta_activate_link frees the link upon failure */
4859 return ieee80211_sta_activate_link(sta, params->link_id);
4863 ieee80211_add_link_station(struct wiphy *wiphy, struct net_device *dev,
4864 struct link_station_parameters *params)
4866 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4867 struct ieee80211_local *local = wiphy_priv(wiphy);
4869 lockdep_assert_wiphy(sdata->local->hw.wiphy);
4871 return sta_add_link_station(local, sdata, params);
4874 static int sta_mod_link_station(struct ieee80211_local *local,
4875 struct ieee80211_sub_if_data *sdata,
4876 struct link_station_parameters *params)
4878 struct sta_info *sta;
4880 sta = sta_info_get_bss(sdata, params->mld_mac);
4884 if (!(sta->sta.valid_links & BIT(params->link_id)))
4887 return sta_link_apply_parameters(local, sta, false, params);
4891 ieee80211_mod_link_station(struct wiphy *wiphy, struct net_device *dev,
4892 struct link_station_parameters *params)
4894 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4895 struct ieee80211_local *local = wiphy_priv(wiphy);
4897 lockdep_assert_wiphy(sdata->local->hw.wiphy);
4899 return sta_mod_link_station(local, sdata, params);
4902 static int sta_del_link_station(struct ieee80211_sub_if_data *sdata,
4903 struct link_station_del_parameters *params)
4905 struct sta_info *sta;
4907 sta = sta_info_get_bss(sdata, params->mld_mac);
4911 if (!(sta->sta.valid_links & BIT(params->link_id)))
4914 /* must not create a STA without links */
4915 if (sta->sta.valid_links == BIT(params->link_id))
4918 ieee80211_sta_remove_link(sta, params->link_id);
4924 ieee80211_del_link_station(struct wiphy *wiphy, struct net_device *dev,
4925 struct link_station_del_parameters *params)
4927 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4929 lockdep_assert_wiphy(sdata->local->hw.wiphy);
4931 return sta_del_link_station(sdata, params);
4934 static int ieee80211_set_hw_timestamp(struct wiphy *wiphy,
4935 struct net_device *dev,
4936 struct cfg80211_set_hw_timestamp *hwts)
4938 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4939 struct ieee80211_local *local = sdata->local;
4941 if (!local->ops->set_hw_timestamp)
4944 if (!check_sdata_in_driver(sdata))
4947 return local->ops->set_hw_timestamp(&local->hw, &sdata->vif, hwts);
4950 const struct cfg80211_ops mac80211_config_ops = {
4951 .add_virtual_intf = ieee80211_add_iface,
4952 .del_virtual_intf = ieee80211_del_iface,
4953 .change_virtual_intf = ieee80211_change_iface,
4954 .start_p2p_device = ieee80211_start_p2p_device,
4955 .stop_p2p_device = ieee80211_stop_p2p_device,
4956 .add_key = ieee80211_add_key,
4957 .del_key = ieee80211_del_key,
4958 .get_key = ieee80211_get_key,
4959 .set_default_key = ieee80211_config_default_key,
4960 .set_default_mgmt_key = ieee80211_config_default_mgmt_key,
4961 .set_default_beacon_key = ieee80211_config_default_beacon_key,
4962 .start_ap = ieee80211_start_ap,
4963 .change_beacon = ieee80211_change_beacon,
4964 .stop_ap = ieee80211_stop_ap,
4965 .add_station = ieee80211_add_station,
4966 .del_station = ieee80211_del_station,
4967 .change_station = ieee80211_change_station,
4968 .get_station = ieee80211_get_station,
4969 .dump_station = ieee80211_dump_station,
4970 .dump_survey = ieee80211_dump_survey,
4971 #ifdef CONFIG_MAC80211_MESH
4972 .add_mpath = ieee80211_add_mpath,
4973 .del_mpath = ieee80211_del_mpath,
4974 .change_mpath = ieee80211_change_mpath,
4975 .get_mpath = ieee80211_get_mpath,
4976 .dump_mpath = ieee80211_dump_mpath,
4977 .get_mpp = ieee80211_get_mpp,
4978 .dump_mpp = ieee80211_dump_mpp,
4979 .update_mesh_config = ieee80211_update_mesh_config,
4980 .get_mesh_config = ieee80211_get_mesh_config,
4981 .join_mesh = ieee80211_join_mesh,
4982 .leave_mesh = ieee80211_leave_mesh,
4984 .join_ocb = ieee80211_join_ocb,
4985 .leave_ocb = ieee80211_leave_ocb,
4986 .change_bss = ieee80211_change_bss,
4987 .inform_bss = ieee80211_inform_bss,
4988 .set_txq_params = ieee80211_set_txq_params,
4989 .set_monitor_channel = ieee80211_set_monitor_channel,
4990 .suspend = ieee80211_suspend,
4991 .resume = ieee80211_resume,
4992 .scan = ieee80211_scan,
4993 .abort_scan = ieee80211_abort_scan,
4994 .sched_scan_start = ieee80211_sched_scan_start,
4995 .sched_scan_stop = ieee80211_sched_scan_stop,
4996 .auth = ieee80211_auth,
4997 .assoc = ieee80211_assoc,
4998 .deauth = ieee80211_deauth,
4999 .disassoc = ieee80211_disassoc,
5000 .join_ibss = ieee80211_join_ibss,
5001 .leave_ibss = ieee80211_leave_ibss,
5002 .set_mcast_rate = ieee80211_set_mcast_rate,
5003 .set_wiphy_params = ieee80211_set_wiphy_params,
5004 .set_tx_power = ieee80211_set_tx_power,
5005 .get_tx_power = ieee80211_get_tx_power,
5006 .rfkill_poll = ieee80211_rfkill_poll,
5007 CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd)
5008 CFG80211_TESTMODE_DUMP(ieee80211_testmode_dump)
5009 .set_power_mgmt = ieee80211_set_power_mgmt,
5010 .set_bitrate_mask = ieee80211_set_bitrate_mask,
5011 .remain_on_channel = ieee80211_remain_on_channel,
5012 .cancel_remain_on_channel = ieee80211_cancel_remain_on_channel,
5013 .mgmt_tx = ieee80211_mgmt_tx,
5014 .mgmt_tx_cancel_wait = ieee80211_mgmt_tx_cancel_wait,
5015 .set_cqm_rssi_config = ieee80211_set_cqm_rssi_config,
5016 .set_cqm_rssi_range_config = ieee80211_set_cqm_rssi_range_config,
5017 .update_mgmt_frame_registrations =
5018 ieee80211_update_mgmt_frame_registrations,
5019 .set_antenna = ieee80211_set_antenna,
5020 .get_antenna = ieee80211_get_antenna,
5021 .set_rekey_data = ieee80211_set_rekey_data,
5022 .tdls_oper = ieee80211_tdls_oper,
5023 .tdls_mgmt = ieee80211_tdls_mgmt,
5024 .tdls_channel_switch = ieee80211_tdls_channel_switch,
5025 .tdls_cancel_channel_switch = ieee80211_tdls_cancel_channel_switch,
5026 .probe_client = ieee80211_probe_client,
5027 .set_noack_map = ieee80211_set_noack_map,
5029 .set_wakeup = ieee80211_set_wakeup,
5031 .get_channel = ieee80211_cfg_get_channel,
5032 .start_radar_detection = ieee80211_start_radar_detection,
5033 .end_cac = ieee80211_end_cac,
5034 .channel_switch = ieee80211_channel_switch,
5035 .set_qos_map = ieee80211_set_qos_map,
5036 .set_ap_chanwidth = ieee80211_set_ap_chanwidth,
5037 .add_tx_ts = ieee80211_add_tx_ts,
5038 .del_tx_ts = ieee80211_del_tx_ts,
5039 .start_nan = ieee80211_start_nan,
5040 .stop_nan = ieee80211_stop_nan,
5041 .nan_change_conf = ieee80211_nan_change_conf,
5042 .add_nan_func = ieee80211_add_nan_func,
5043 .del_nan_func = ieee80211_del_nan_func,
5044 .set_multicast_to_unicast = ieee80211_set_multicast_to_unicast,
5045 .tx_control_port = ieee80211_tx_control_port,
5046 .get_txq_stats = ieee80211_get_txq_stats,
5047 .get_ftm_responder_stats = ieee80211_get_ftm_responder_stats,
5048 .start_pmsr = ieee80211_start_pmsr,
5049 .abort_pmsr = ieee80211_abort_pmsr,
5050 .probe_mesh_link = ieee80211_probe_mesh_link,
5051 .set_tid_config = ieee80211_set_tid_config,
5052 .reset_tid_config = ieee80211_reset_tid_config,
5053 .set_sar_specs = ieee80211_set_sar_specs,
5054 .color_change = ieee80211_color_change,
5055 .set_radar_background = ieee80211_set_radar_background,
5056 .add_intf_link = ieee80211_add_intf_link,
5057 .del_intf_link = ieee80211_del_intf_link,
5058 .add_link_station = ieee80211_add_link_station,
5059 .mod_link_station = ieee80211_mod_link_station,
5060 .del_link_station = ieee80211_del_link_station,
5061 .set_hw_timestamp = ieee80211_set_hw_timestamp,