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-2020 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 void ieee80211_set_mu_mimo_follow(struct ieee80211_sub_if_data *sdata,
27 struct vif_params *params)
29 bool mu_mimo_groups = false;
30 bool mu_mimo_follow = false;
32 if (params->vht_mumimo_groups) {
35 BUILD_BUG_ON(sizeof(membership) != WLAN_MEMBERSHIP_LEN);
37 memcpy(sdata->vif.bss_conf.mu_group.membership,
38 params->vht_mumimo_groups, WLAN_MEMBERSHIP_LEN);
39 memcpy(sdata->vif.bss_conf.mu_group.position,
40 params->vht_mumimo_groups + WLAN_MEMBERSHIP_LEN,
41 WLAN_USER_POSITION_LEN);
42 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_MU_GROUPS);
43 /* don't care about endianness - just check for 0 */
44 memcpy(&membership, params->vht_mumimo_groups,
46 mu_mimo_groups = membership != 0;
49 if (params->vht_mumimo_follow_addr) {
51 is_valid_ether_addr(params->vht_mumimo_follow_addr);
52 ether_addr_copy(sdata->u.mntr.mu_follow_addr,
53 params->vht_mumimo_follow_addr);
56 sdata->vif.mu_mimo_owner = mu_mimo_groups || mu_mimo_follow;
59 static int ieee80211_set_mon_options(struct ieee80211_sub_if_data *sdata,
60 struct vif_params *params)
62 struct ieee80211_local *local = sdata->local;
63 struct ieee80211_sub_if_data *monitor_sdata;
65 /* check flags first */
66 if (params->flags && ieee80211_sdata_running(sdata)) {
67 u32 mask = MONITOR_FLAG_COOK_FRAMES | MONITOR_FLAG_ACTIVE;
70 * Prohibit MONITOR_FLAG_COOK_FRAMES and
71 * MONITOR_FLAG_ACTIVE to be changed while the
73 * Else we would need to add a lot of cruft
74 * to update everything:
75 * cooked_mntrs, monitor and all fif_* counters
76 * reconfigure hardware
78 if ((params->flags & mask) != (sdata->u.mntr.flags & mask))
82 /* also validate MU-MIMO change */
83 monitor_sdata = wiphy_dereference(local->hw.wiphy,
84 local->monitor_sdata);
87 (params->vht_mumimo_groups || params->vht_mumimo_follow_addr))
90 /* apply all changes now - no failures allowed */
93 ieee80211_set_mu_mimo_follow(monitor_sdata, params);
96 if (ieee80211_sdata_running(sdata)) {
97 ieee80211_adjust_monitor_flags(sdata, -1);
98 sdata->u.mntr.flags = params->flags;
99 ieee80211_adjust_monitor_flags(sdata, 1);
101 ieee80211_configure_filter(local);
104 * Because the interface is down, ieee80211_do_stop
105 * and ieee80211_do_open take care of "everything"
106 * mentioned in the comment above.
108 sdata->u.mntr.flags = params->flags;
115 static struct wireless_dev *ieee80211_add_iface(struct wiphy *wiphy,
117 unsigned char name_assign_type,
118 enum nl80211_iftype type,
119 struct vif_params *params)
121 struct ieee80211_local *local = wiphy_priv(wiphy);
122 struct wireless_dev *wdev;
123 struct ieee80211_sub_if_data *sdata;
126 err = ieee80211_if_add(local, name, name_assign_type, &wdev, type, params);
130 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
132 if (type == NL80211_IFTYPE_MONITOR) {
133 err = ieee80211_set_mon_options(sdata, params);
135 ieee80211_if_remove(sdata);
143 static int ieee80211_del_iface(struct wiphy *wiphy, struct wireless_dev *wdev)
145 ieee80211_if_remove(IEEE80211_WDEV_TO_SUB_IF(wdev));
150 static int ieee80211_change_iface(struct wiphy *wiphy,
151 struct net_device *dev,
152 enum nl80211_iftype type,
153 struct vif_params *params)
155 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
156 struct ieee80211_local *local = sdata->local;
157 struct sta_info *sta;
160 ret = ieee80211_if_change_type(sdata, type);
164 if (type == NL80211_IFTYPE_AP_VLAN && params->use_4addr == 0) {
165 RCU_INIT_POINTER(sdata->u.vlan.sta, NULL);
166 ieee80211_check_fast_rx_iface(sdata);
167 } else if (type == NL80211_IFTYPE_STATION && params->use_4addr >= 0) {
168 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
170 if (params->use_4addr == ifmgd->use_4addr)
173 sdata->u.mgd.use_4addr = params->use_4addr;
174 if (!ifmgd->associated)
177 mutex_lock(&local->sta_mtx);
178 sta = sta_info_get(sdata, ifmgd->bssid);
180 drv_sta_set_4addr(local, sdata, &sta->sta,
182 mutex_unlock(&local->sta_mtx);
184 if (params->use_4addr)
185 ieee80211_send_4addr_nullfunc(local, sdata);
188 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) {
189 ret = ieee80211_set_mon_options(sdata, params);
197 static int ieee80211_start_p2p_device(struct wiphy *wiphy,
198 struct wireless_dev *wdev)
200 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
203 mutex_lock(&sdata->local->chanctx_mtx);
204 ret = ieee80211_check_combinations(sdata, NULL, 0, 0);
205 mutex_unlock(&sdata->local->chanctx_mtx);
209 return ieee80211_do_open(wdev, true);
212 static void ieee80211_stop_p2p_device(struct wiphy *wiphy,
213 struct wireless_dev *wdev)
215 ieee80211_sdata_stop(IEEE80211_WDEV_TO_SUB_IF(wdev));
218 static int ieee80211_start_nan(struct wiphy *wiphy,
219 struct wireless_dev *wdev,
220 struct cfg80211_nan_conf *conf)
222 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
225 mutex_lock(&sdata->local->chanctx_mtx);
226 ret = ieee80211_check_combinations(sdata, NULL, 0, 0);
227 mutex_unlock(&sdata->local->chanctx_mtx);
231 ret = ieee80211_do_open(wdev, true);
235 ret = drv_start_nan(sdata->local, sdata, conf);
237 ieee80211_sdata_stop(sdata);
239 sdata->u.nan.conf = *conf;
244 static void ieee80211_stop_nan(struct wiphy *wiphy,
245 struct wireless_dev *wdev)
247 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
249 drv_stop_nan(sdata->local, sdata);
250 ieee80211_sdata_stop(sdata);
253 static int ieee80211_nan_change_conf(struct wiphy *wiphy,
254 struct wireless_dev *wdev,
255 struct cfg80211_nan_conf *conf,
258 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
259 struct cfg80211_nan_conf new_conf;
262 if (sdata->vif.type != NL80211_IFTYPE_NAN)
265 if (!ieee80211_sdata_running(sdata))
268 new_conf = sdata->u.nan.conf;
270 if (changes & CFG80211_NAN_CONF_CHANGED_PREF)
271 new_conf.master_pref = conf->master_pref;
273 if (changes & CFG80211_NAN_CONF_CHANGED_BANDS)
274 new_conf.bands = conf->bands;
276 ret = drv_nan_change_conf(sdata->local, sdata, &new_conf, changes);
278 sdata->u.nan.conf = new_conf;
283 static int ieee80211_add_nan_func(struct wiphy *wiphy,
284 struct wireless_dev *wdev,
285 struct cfg80211_nan_func *nan_func)
287 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
290 if (sdata->vif.type != NL80211_IFTYPE_NAN)
293 if (!ieee80211_sdata_running(sdata))
296 spin_lock_bh(&sdata->u.nan.func_lock);
298 ret = idr_alloc(&sdata->u.nan.function_inst_ids,
299 nan_func, 1, sdata->local->hw.max_nan_de_entries + 1,
301 spin_unlock_bh(&sdata->u.nan.func_lock);
306 nan_func->instance_id = ret;
308 WARN_ON(nan_func->instance_id == 0);
310 ret = drv_add_nan_func(sdata->local, sdata, nan_func);
312 spin_lock_bh(&sdata->u.nan.func_lock);
313 idr_remove(&sdata->u.nan.function_inst_ids,
314 nan_func->instance_id);
315 spin_unlock_bh(&sdata->u.nan.func_lock);
321 static struct cfg80211_nan_func *
322 ieee80211_find_nan_func_by_cookie(struct ieee80211_sub_if_data *sdata,
325 struct cfg80211_nan_func *func;
328 lockdep_assert_held(&sdata->u.nan.func_lock);
330 idr_for_each_entry(&sdata->u.nan.function_inst_ids, func, id) {
331 if (func->cookie == cookie)
338 static void ieee80211_del_nan_func(struct wiphy *wiphy,
339 struct wireless_dev *wdev, u64 cookie)
341 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
342 struct cfg80211_nan_func *func;
345 if (sdata->vif.type != NL80211_IFTYPE_NAN ||
346 !ieee80211_sdata_running(sdata))
349 spin_lock_bh(&sdata->u.nan.func_lock);
351 func = ieee80211_find_nan_func_by_cookie(sdata, cookie);
353 instance_id = func->instance_id;
355 spin_unlock_bh(&sdata->u.nan.func_lock);
358 drv_del_nan_func(sdata->local, sdata, instance_id);
361 static int ieee80211_set_noack_map(struct wiphy *wiphy,
362 struct net_device *dev,
365 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
367 sdata->noack_map = noack_map;
369 ieee80211_check_fast_xmit_iface(sdata);
374 static int ieee80211_set_tx(struct ieee80211_sub_if_data *sdata,
375 const u8 *mac_addr, u8 key_idx)
377 struct ieee80211_local *local = sdata->local;
378 struct ieee80211_key *key;
379 struct sta_info *sta;
382 if (!wiphy_ext_feature_isset(local->hw.wiphy,
383 NL80211_EXT_FEATURE_EXT_KEY_ID))
386 sta = sta_info_get_bss(sdata, mac_addr);
391 if (sta->ptk_idx == key_idx)
394 mutex_lock(&local->key_mtx);
395 key = key_mtx_dereference(local, sta->ptk[key_idx]);
397 if (key && key->conf.flags & IEEE80211_KEY_FLAG_NO_AUTO_TX)
398 ret = ieee80211_set_tx_key(key);
400 mutex_unlock(&local->key_mtx);
404 static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
405 u8 key_idx, bool pairwise, const u8 *mac_addr,
406 struct key_params *params)
408 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
409 struct ieee80211_local *local = sdata->local;
410 struct sta_info *sta = NULL;
411 const struct ieee80211_cipher_scheme *cs = NULL;
412 struct ieee80211_key *key;
415 if (!ieee80211_sdata_running(sdata))
418 if (pairwise && params->mode == NL80211_KEY_SET_TX)
419 return ieee80211_set_tx(sdata, mac_addr, key_idx);
421 /* reject WEP and TKIP keys if WEP failed to initialize */
422 switch (params->cipher) {
423 case WLAN_CIPHER_SUITE_WEP40:
424 case WLAN_CIPHER_SUITE_TKIP:
425 case WLAN_CIPHER_SUITE_WEP104:
426 if (WARN_ON_ONCE(fips_enabled))
429 case WLAN_CIPHER_SUITE_CCMP:
430 case WLAN_CIPHER_SUITE_CCMP_256:
431 case WLAN_CIPHER_SUITE_AES_CMAC:
432 case WLAN_CIPHER_SUITE_BIP_CMAC_256:
433 case WLAN_CIPHER_SUITE_BIP_GMAC_128:
434 case WLAN_CIPHER_SUITE_BIP_GMAC_256:
435 case WLAN_CIPHER_SUITE_GCMP:
436 case WLAN_CIPHER_SUITE_GCMP_256:
439 cs = ieee80211_cs_get(local, params->cipher, sdata->vif.type);
443 key = ieee80211_key_alloc(params->cipher, key_idx, params->key_len,
444 params->key, params->seq_len, params->seq,
450 key->conf.flags |= IEEE80211_KEY_FLAG_PAIRWISE;
452 if (params->mode == NL80211_KEY_NO_TX)
453 key->conf.flags |= IEEE80211_KEY_FLAG_NO_AUTO_TX;
455 mutex_lock(&local->sta_mtx);
458 sta = sta_info_get_bss(sdata, mac_addr);
460 * The ASSOC test makes sure the driver is ready to
461 * receive the key. When wpa_supplicant has roamed
462 * using FT, it attempts to set the key before
463 * association has completed, this rejects that attempt
464 * so it will set the key again after association.
466 * TODO: accept the key if we have a station entry and
467 * add it to the device after the station.
469 if (!sta || !test_sta_flag(sta, WLAN_STA_ASSOC)) {
470 ieee80211_key_free_unused(key);
476 switch (sdata->vif.type) {
477 case NL80211_IFTYPE_STATION:
478 if (sdata->u.mgd.mfp != IEEE80211_MFP_DISABLED)
479 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
481 case NL80211_IFTYPE_AP:
482 case NL80211_IFTYPE_AP_VLAN:
483 /* Keys without a station are used for TX only */
484 if (sta && test_sta_flag(sta, WLAN_STA_MFP))
485 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
487 case NL80211_IFTYPE_ADHOC:
490 case NL80211_IFTYPE_MESH_POINT:
491 #ifdef CONFIG_MAC80211_MESH
492 if (sdata->u.mesh.security != IEEE80211_MESH_SEC_NONE)
493 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
496 case NL80211_IFTYPE_WDS:
497 case NL80211_IFTYPE_MONITOR:
498 case NL80211_IFTYPE_P2P_DEVICE:
499 case NL80211_IFTYPE_NAN:
500 case NL80211_IFTYPE_UNSPECIFIED:
501 case NUM_NL80211_IFTYPES:
502 case NL80211_IFTYPE_P2P_CLIENT:
503 case NL80211_IFTYPE_P2P_GO:
504 case NL80211_IFTYPE_OCB:
505 /* shouldn't happen */
511 sta->cipher_scheme = cs;
513 err = ieee80211_key_link(key, sdata, sta);
516 mutex_unlock(&local->sta_mtx);
521 static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
522 u8 key_idx, bool pairwise, const u8 *mac_addr)
524 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
525 struct ieee80211_local *local = sdata->local;
526 struct sta_info *sta;
527 struct ieee80211_key *key = NULL;
530 mutex_lock(&local->sta_mtx);
531 mutex_lock(&local->key_mtx);
536 sta = sta_info_get_bss(sdata, mac_addr);
541 key = key_mtx_dereference(local, sta->ptk[key_idx]);
543 key = key_mtx_dereference(local, sta->gtk[key_idx]);
545 key = key_mtx_dereference(local, sdata->keys[key_idx]);
552 ieee80211_key_free(key, sdata->vif.type == NL80211_IFTYPE_STATION);
556 mutex_unlock(&local->key_mtx);
557 mutex_unlock(&local->sta_mtx);
562 static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
563 u8 key_idx, bool pairwise, const u8 *mac_addr,
565 void (*callback)(void *cookie,
566 struct key_params *params))
568 struct ieee80211_sub_if_data *sdata;
569 struct sta_info *sta = NULL;
571 struct key_params params;
572 struct ieee80211_key *key = NULL;
577 struct ieee80211_key_seq kseq = {};
579 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
584 sta = sta_info_get_bss(sdata, mac_addr);
588 if (pairwise && key_idx < NUM_DEFAULT_KEYS)
589 key = rcu_dereference(sta->ptk[key_idx]);
590 else if (!pairwise &&
591 key_idx < NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS +
592 NUM_DEFAULT_BEACON_KEYS)
593 key = rcu_dereference(sta->gtk[key_idx]);
595 key = rcu_dereference(sdata->keys[key_idx]);
600 memset(¶ms, 0, sizeof(params));
602 params.cipher = key->conf.cipher;
604 switch (key->conf.cipher) {
605 case WLAN_CIPHER_SUITE_TKIP:
606 pn64 = atomic64_read(&key->conf.tx_pn);
607 iv32 = TKIP_PN_TO_IV32(pn64);
608 iv16 = TKIP_PN_TO_IV16(pn64);
610 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE &&
611 !(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
612 drv_get_key_seq(sdata->local, key, &kseq);
613 iv32 = kseq.tkip.iv32;
614 iv16 = kseq.tkip.iv16;
617 seq[0] = iv16 & 0xff;
618 seq[1] = (iv16 >> 8) & 0xff;
619 seq[2] = iv32 & 0xff;
620 seq[3] = (iv32 >> 8) & 0xff;
621 seq[4] = (iv32 >> 16) & 0xff;
622 seq[5] = (iv32 >> 24) & 0xff;
626 case WLAN_CIPHER_SUITE_CCMP:
627 case WLAN_CIPHER_SUITE_CCMP_256:
628 case WLAN_CIPHER_SUITE_AES_CMAC:
629 case WLAN_CIPHER_SUITE_BIP_CMAC_256:
630 BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
631 offsetof(typeof(kseq), aes_cmac));
633 case WLAN_CIPHER_SUITE_BIP_GMAC_128:
634 case WLAN_CIPHER_SUITE_BIP_GMAC_256:
635 BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
636 offsetof(typeof(kseq), aes_gmac));
638 case WLAN_CIPHER_SUITE_GCMP:
639 case WLAN_CIPHER_SUITE_GCMP_256:
640 BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
641 offsetof(typeof(kseq), gcmp));
643 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE &&
644 !(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
645 drv_get_key_seq(sdata->local, key, &kseq);
646 memcpy(seq, kseq.ccmp.pn, 6);
648 pn64 = atomic64_read(&key->conf.tx_pn);
660 if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
662 if (WARN_ON(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV))
664 drv_get_key_seq(sdata->local, key, &kseq);
665 params.seq = kseq.hw.seq;
666 params.seq_len = kseq.hw.seq_len;
670 params.key = key->conf.key;
671 params.key_len = key->conf.keylen;
673 callback(cookie, ¶ms);
681 static int ieee80211_config_default_key(struct wiphy *wiphy,
682 struct net_device *dev,
683 u8 key_idx, bool uni,
686 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
688 ieee80211_set_default_key(sdata, key_idx, uni, multi);
693 static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy,
694 struct net_device *dev,
697 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
699 ieee80211_set_default_mgmt_key(sdata, key_idx);
704 static int ieee80211_config_default_beacon_key(struct wiphy *wiphy,
705 struct net_device *dev,
708 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
710 ieee80211_set_default_beacon_key(sdata, key_idx);
715 void sta_set_rate_info_tx(struct sta_info *sta,
716 const struct ieee80211_tx_rate *rate,
717 struct rate_info *rinfo)
720 if (rate->flags & IEEE80211_TX_RC_MCS) {
721 rinfo->flags |= RATE_INFO_FLAGS_MCS;
722 rinfo->mcs = rate->idx;
723 } else if (rate->flags & IEEE80211_TX_RC_VHT_MCS) {
724 rinfo->flags |= RATE_INFO_FLAGS_VHT_MCS;
725 rinfo->mcs = ieee80211_rate_get_vht_mcs(rate);
726 rinfo->nss = ieee80211_rate_get_vht_nss(rate);
728 struct ieee80211_supported_band *sband;
729 int shift = ieee80211_vif_get_shift(&sta->sdata->vif);
732 sband = ieee80211_get_sband(sta->sdata);
733 WARN_ON_ONCE(sband && !sband->bitrates);
734 if (sband && sband->bitrates) {
735 brate = sband->bitrates[rate->idx].bitrate;
736 rinfo->legacy = DIV_ROUND_UP(brate, 1 << shift);
739 if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
740 rinfo->bw = RATE_INFO_BW_40;
741 else if (rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH)
742 rinfo->bw = RATE_INFO_BW_80;
743 else if (rate->flags & IEEE80211_TX_RC_160_MHZ_WIDTH)
744 rinfo->bw = RATE_INFO_BW_160;
746 rinfo->bw = RATE_INFO_BW_20;
747 if (rate->flags & IEEE80211_TX_RC_SHORT_GI)
748 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI;
751 static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev,
752 int idx, u8 *mac, struct station_info *sinfo)
754 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
755 struct ieee80211_local *local = sdata->local;
756 struct sta_info *sta;
759 mutex_lock(&local->sta_mtx);
761 sta = sta_info_get_by_idx(sdata, idx);
764 memcpy(mac, sta->sta.addr, ETH_ALEN);
765 sta_set_sinfo(sta, sinfo, true);
768 mutex_unlock(&local->sta_mtx);
773 static int ieee80211_dump_survey(struct wiphy *wiphy, struct net_device *dev,
774 int idx, struct survey_info *survey)
776 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
778 return drv_get_survey(local, idx, survey);
781 static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev,
782 const u8 *mac, struct station_info *sinfo)
784 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
785 struct ieee80211_local *local = sdata->local;
786 struct sta_info *sta;
789 mutex_lock(&local->sta_mtx);
791 sta = sta_info_get_bss(sdata, mac);
794 sta_set_sinfo(sta, sinfo, true);
797 mutex_unlock(&local->sta_mtx);
802 static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
803 struct cfg80211_chan_def *chandef)
805 struct ieee80211_local *local = wiphy_priv(wiphy);
806 struct ieee80211_sub_if_data *sdata;
809 if (cfg80211_chandef_identical(&local->monitor_chandef, chandef))
812 mutex_lock(&local->mtx);
813 if (local->use_chanctx) {
814 sdata = wiphy_dereference(local->hw.wiphy,
815 local->monitor_sdata);
817 ieee80211_vif_release_channel(sdata);
818 ret = ieee80211_vif_use_channel(sdata, chandef,
819 IEEE80211_CHANCTX_EXCLUSIVE);
821 } else if (local->open_count == local->monitors) {
822 local->_oper_chandef = *chandef;
823 ieee80211_hw_config(local, 0);
827 local->monitor_chandef = *chandef;
828 mutex_unlock(&local->mtx);
834 ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata,
835 const u8 *resp, size_t resp_len,
836 const struct ieee80211_csa_settings *csa,
837 const struct ieee80211_color_change_settings *cca)
839 struct probe_resp *new, *old;
841 if (!resp || !resp_len)
844 old = sdata_dereference(sdata->u.ap.probe_resp, sdata);
846 new = kzalloc(sizeof(struct probe_resp) + resp_len, GFP_KERNEL);
851 memcpy(new->data, resp, resp_len);
854 memcpy(new->cntdwn_counter_offsets, csa->counter_offsets_presp,
855 csa->n_counter_offsets_presp *
856 sizeof(new->cntdwn_counter_offsets[0]));
858 new->cntdwn_counter_offsets[0] = cca->counter_offset_presp;
860 rcu_assign_pointer(sdata->u.ap.probe_resp, new);
862 kfree_rcu(old, rcu_head);
867 static int ieee80211_set_fils_discovery(struct ieee80211_sub_if_data *sdata,
868 struct cfg80211_fils_discovery *params)
870 struct fils_discovery_data *new, *old = NULL;
871 struct ieee80211_fils_discovery *fd;
873 if (!params->tmpl || !params->tmpl_len)
876 fd = &sdata->vif.bss_conf.fils_discovery;
877 fd->min_interval = params->min_interval;
878 fd->max_interval = params->max_interval;
880 old = sdata_dereference(sdata->u.ap.fils_discovery, sdata);
881 new = kzalloc(sizeof(*new) + params->tmpl_len, GFP_KERNEL);
884 new->len = params->tmpl_len;
885 memcpy(new->data, params->tmpl, params->tmpl_len);
886 rcu_assign_pointer(sdata->u.ap.fils_discovery, new);
889 kfree_rcu(old, rcu_head);
895 ieee80211_set_unsol_bcast_probe_resp(struct ieee80211_sub_if_data *sdata,
896 struct cfg80211_unsol_bcast_probe_resp *params)
898 struct unsol_bcast_probe_resp_data *new, *old = NULL;
900 if (!params->tmpl || !params->tmpl_len)
903 old = sdata_dereference(sdata->u.ap.unsol_bcast_probe_resp, sdata);
904 new = kzalloc(sizeof(*new) + params->tmpl_len, GFP_KERNEL);
907 new->len = params->tmpl_len;
908 memcpy(new->data, params->tmpl, params->tmpl_len);
909 rcu_assign_pointer(sdata->u.ap.unsol_bcast_probe_resp, new);
912 kfree_rcu(old, rcu_head);
914 sdata->vif.bss_conf.unsol_bcast_probe_resp_interval =
920 static int ieee80211_set_ftm_responder_params(
921 struct ieee80211_sub_if_data *sdata,
922 const u8 *lci, size_t lci_len,
923 const u8 *civicloc, size_t civicloc_len)
925 struct ieee80211_ftm_responder_params *new, *old;
926 struct ieee80211_bss_conf *bss_conf;
930 if (!lci_len && !civicloc_len)
933 bss_conf = &sdata->vif.bss_conf;
934 old = bss_conf->ftmr_params;
935 len = lci_len + civicloc_len;
937 new = kzalloc(sizeof(*new) + len, GFP_KERNEL);
941 pos = (u8 *)(new + 1);
943 new->lci_len = lci_len;
945 memcpy(pos, lci, lci_len);
950 new->civicloc_len = civicloc_len;
952 memcpy(pos, civicloc, civicloc_len);
956 bss_conf->ftmr_params = new;
962 static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
963 struct cfg80211_beacon_data *params,
964 const struct ieee80211_csa_settings *csa,
965 const struct ieee80211_color_change_settings *cca)
967 struct beacon_data *new, *old;
968 int new_head_len, new_tail_len;
970 u32 changed = BSS_CHANGED_BEACON;
972 old = sdata_dereference(sdata->u.ap.beacon, sdata);
975 /* Need to have a beacon head if we don't have one yet */
976 if (!params->head && !old)
979 /* new or old head? */
981 new_head_len = params->head_len;
983 new_head_len = old->head_len;
985 /* new or old tail? */
986 if (params->tail || !old)
987 /* params->tail_len will be zero for !params->tail */
988 new_tail_len = params->tail_len;
990 new_tail_len = old->tail_len;
992 size = sizeof(*new) + new_head_len + new_tail_len;
994 new = kzalloc(size, GFP_KERNEL);
998 /* start filling the new info now */
1001 * pointers go into the block we allocated,
1002 * memory is | beacon_data | head | tail |
1004 new->head = ((u8 *) new) + sizeof(*new);
1005 new->tail = new->head + new_head_len;
1006 new->head_len = new_head_len;
1007 new->tail_len = new_tail_len;
1010 new->cntdwn_current_counter = csa->count;
1011 memcpy(new->cntdwn_counter_offsets, csa->counter_offsets_beacon,
1012 csa->n_counter_offsets_beacon *
1013 sizeof(new->cntdwn_counter_offsets[0]));
1015 new->cntdwn_current_counter = cca->count;
1016 new->cntdwn_counter_offsets[0] = cca->counter_offset_beacon;
1021 memcpy(new->head, params->head, new_head_len);
1023 memcpy(new->head, old->head, new_head_len);
1025 /* copy in optional tail */
1027 memcpy(new->tail, params->tail, new_tail_len);
1030 memcpy(new->tail, old->tail, new_tail_len);
1032 err = ieee80211_set_probe_resp(sdata, params->probe_resp,
1033 params->probe_resp_len, csa, cca);
1039 changed |= BSS_CHANGED_AP_PROBE_RESP;
1041 if (params->ftm_responder != -1) {
1042 sdata->vif.bss_conf.ftm_responder = params->ftm_responder;
1043 err = ieee80211_set_ftm_responder_params(sdata,
1047 params->civicloc_len);
1054 changed |= BSS_CHANGED_FTM_RESPONDER;
1057 rcu_assign_pointer(sdata->u.ap.beacon, new);
1060 kfree_rcu(old, rcu_head);
1065 static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
1066 struct cfg80211_ap_settings *params)
1068 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1069 struct ieee80211_local *local = sdata->local;
1070 struct beacon_data *old;
1071 struct ieee80211_sub_if_data *vlan;
1072 u32 changed = BSS_CHANGED_BEACON_INT |
1073 BSS_CHANGED_BEACON_ENABLED |
1074 BSS_CHANGED_BEACON |
1076 BSS_CHANGED_P2P_PS |
1077 BSS_CHANGED_TXPOWER |
1080 int prev_beacon_int;
1082 old = sdata_dereference(sdata->u.ap.beacon, sdata);
1086 if (params->smps_mode != NL80211_SMPS_OFF)
1089 sdata->smps_mode = IEEE80211_SMPS_OFF;
1091 sdata->needed_rx_chains = sdata->local->rx_chains;
1093 prev_beacon_int = sdata->vif.bss_conf.beacon_int;
1094 sdata->vif.bss_conf.beacon_int = params->beacon_interval;
1096 if (params->he_cap && params->he_oper) {
1097 sdata->vif.bss_conf.he_support = true;
1098 sdata->vif.bss_conf.htc_trig_based_pkt_ext =
1099 le32_get_bits(params->he_oper->he_oper_params,
1100 IEEE80211_HE_OPERATION_DFLT_PE_DURATION_MASK);
1101 sdata->vif.bss_conf.frame_time_rts_th =
1102 le32_get_bits(params->he_oper->he_oper_params,
1103 IEEE80211_HE_OPERATION_RTS_THRESHOLD_MASK);
1104 changed |= BSS_CHANGED_HE_OBSS_PD;
1106 if (params->he_bss_color.enabled)
1107 changed |= BSS_CHANGED_HE_BSS_COLOR;
1110 mutex_lock(&local->mtx);
1111 err = ieee80211_vif_use_channel(sdata, ¶ms->chandef,
1112 IEEE80211_CHANCTX_SHARED);
1114 ieee80211_vif_copy_chanctx_to_vlans(sdata, false);
1115 mutex_unlock(&local->mtx);
1117 sdata->vif.bss_conf.beacon_int = prev_beacon_int;
1122 * Apply control port protocol, this allows us to
1123 * not encrypt dynamic WEP control frames.
1125 sdata->control_port_protocol = params->crypto.control_port_ethertype;
1126 sdata->control_port_no_encrypt = params->crypto.control_port_no_encrypt;
1127 sdata->control_port_over_nl80211 =
1128 params->crypto.control_port_over_nl80211;
1129 sdata->control_port_no_preauth =
1130 params->crypto.control_port_no_preauth;
1131 sdata->encrypt_headroom = ieee80211_cs_headroom(sdata->local,
1135 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) {
1136 vlan->control_port_protocol =
1137 params->crypto.control_port_ethertype;
1138 vlan->control_port_no_encrypt =
1139 params->crypto.control_port_no_encrypt;
1140 vlan->control_port_over_nl80211 =
1141 params->crypto.control_port_over_nl80211;
1142 vlan->control_port_no_preauth =
1143 params->crypto.control_port_no_preauth;
1144 vlan->encrypt_headroom =
1145 ieee80211_cs_headroom(sdata->local,
1150 sdata->vif.bss_conf.dtim_period = params->dtim_period;
1151 sdata->vif.bss_conf.enable_beacon = true;
1152 sdata->vif.bss_conf.allow_p2p_go_ps = sdata->vif.p2p;
1153 sdata->vif.bss_conf.twt_responder = params->twt_responder;
1154 sdata->vif.bss_conf.he_obss_pd = params->he_obss_pd;
1155 sdata->vif.bss_conf.he_bss_color = params->he_bss_color;
1156 sdata->vif.bss_conf.s1g = params->chandef.chan->band ==
1159 sdata->vif.bss_conf.ssid_len = params->ssid_len;
1160 if (params->ssid_len)
1161 memcpy(sdata->vif.bss_conf.ssid, params->ssid,
1163 sdata->vif.bss_conf.hidden_ssid =
1164 (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE);
1166 memset(&sdata->vif.bss_conf.p2p_noa_attr, 0,
1167 sizeof(sdata->vif.bss_conf.p2p_noa_attr));
1168 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow =
1169 params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
1170 if (params->p2p_opp_ps)
1171 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |=
1172 IEEE80211_P2P_OPPPS_ENABLE_BIT;
1174 sdata->beacon_rate_set = false;
1175 if (wiphy_ext_feature_isset(local->hw.wiphy,
1176 NL80211_EXT_FEATURE_BEACON_RATE_LEGACY)) {
1177 for (i = 0; i < NUM_NL80211_BANDS; i++) {
1178 sdata->beacon_rateidx_mask[i] =
1179 params->beacon_rate.control[i].legacy;
1180 if (sdata->beacon_rateidx_mask[i])
1181 sdata->beacon_rate_set = true;
1185 if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL))
1186 sdata->vif.bss_conf.beacon_tx_rate = params->beacon_rate;
1188 err = ieee80211_assign_beacon(sdata, ¶ms->beacon, NULL, NULL);
1193 if (params->fils_discovery.max_interval) {
1194 err = ieee80211_set_fils_discovery(sdata,
1195 ¶ms->fils_discovery);
1198 changed |= BSS_CHANGED_FILS_DISCOVERY;
1201 if (params->unsol_bcast_probe_resp.interval) {
1202 err = ieee80211_set_unsol_bcast_probe_resp(sdata,
1203 ¶ms->unsol_bcast_probe_resp);
1206 changed |= BSS_CHANGED_UNSOL_BCAST_PROBE_RESP;
1209 err = drv_start_ap(sdata->local, sdata);
1211 old = sdata_dereference(sdata->u.ap.beacon, sdata);
1214 kfree_rcu(old, rcu_head);
1215 RCU_INIT_POINTER(sdata->u.ap.beacon, NULL);
1219 ieee80211_recalc_dtim(local, sdata);
1220 ieee80211_bss_info_change_notify(sdata, changed);
1222 netif_carrier_on(dev);
1223 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
1224 netif_carrier_on(vlan->dev);
1229 mutex_lock(&local->mtx);
1230 ieee80211_vif_release_channel(sdata);
1231 mutex_unlock(&local->mtx);
1236 static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev,
1237 struct cfg80211_beacon_data *params)
1239 struct ieee80211_sub_if_data *sdata;
1240 struct beacon_data *old;
1243 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1244 sdata_assert_lock(sdata);
1246 /* don't allow changing the beacon while a countdown is in place - offset
1247 * of channel switch counter may change
1249 if (sdata->vif.csa_active || sdata->vif.color_change_active)
1252 old = sdata_dereference(sdata->u.ap.beacon, sdata);
1256 err = ieee80211_assign_beacon(sdata, params, NULL, NULL);
1259 ieee80211_bss_info_change_notify(sdata, err);
1263 static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev)
1265 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1266 struct ieee80211_sub_if_data *vlan;
1267 struct ieee80211_local *local = sdata->local;
1268 struct beacon_data *old_beacon;
1269 struct probe_resp *old_probe_resp;
1270 struct fils_discovery_data *old_fils_discovery;
1271 struct unsol_bcast_probe_resp_data *old_unsol_bcast_probe_resp;
1272 struct cfg80211_chan_def chandef;
1274 sdata_assert_lock(sdata);
1276 old_beacon = sdata_dereference(sdata->u.ap.beacon, sdata);
1279 old_probe_resp = sdata_dereference(sdata->u.ap.probe_resp, sdata);
1280 old_fils_discovery = sdata_dereference(sdata->u.ap.fils_discovery,
1282 old_unsol_bcast_probe_resp =
1283 sdata_dereference(sdata->u.ap.unsol_bcast_probe_resp,
1286 /* abort any running channel switch */
1287 mutex_lock(&local->mtx);
1288 sdata->vif.csa_active = false;
1289 if (sdata->csa_block_tx) {
1290 ieee80211_wake_vif_queues(local, sdata,
1291 IEEE80211_QUEUE_STOP_REASON_CSA);
1292 sdata->csa_block_tx = false;
1295 mutex_unlock(&local->mtx);
1297 kfree(sdata->u.ap.next_beacon);
1298 sdata->u.ap.next_beacon = NULL;
1300 /* turn off carrier for this interface and dependent VLANs */
1301 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
1302 netif_carrier_off(vlan->dev);
1303 netif_carrier_off(dev);
1305 /* remove beacon and probe response */
1306 RCU_INIT_POINTER(sdata->u.ap.beacon, NULL);
1307 RCU_INIT_POINTER(sdata->u.ap.probe_resp, NULL);
1308 RCU_INIT_POINTER(sdata->u.ap.fils_discovery, NULL);
1309 RCU_INIT_POINTER(sdata->u.ap.unsol_bcast_probe_resp, NULL);
1310 kfree_rcu(old_beacon, rcu_head);
1312 kfree_rcu(old_probe_resp, rcu_head);
1313 if (old_fils_discovery)
1314 kfree_rcu(old_fils_discovery, rcu_head);
1315 if (old_unsol_bcast_probe_resp)
1316 kfree_rcu(old_unsol_bcast_probe_resp, rcu_head);
1318 kfree(sdata->vif.bss_conf.ftmr_params);
1319 sdata->vif.bss_conf.ftmr_params = NULL;
1321 __sta_info_flush(sdata, true);
1322 ieee80211_free_keys(sdata, true);
1324 sdata->vif.bss_conf.enable_beacon = false;
1325 sdata->beacon_rate_set = false;
1326 sdata->vif.bss_conf.ssid_len = 0;
1327 clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state);
1328 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
1330 if (sdata->wdev.cac_started) {
1331 chandef = sdata->vif.bss_conf.chandef;
1332 cancel_delayed_work_sync(&sdata->dfs_cac_timer_work);
1333 cfg80211_cac_event(sdata->dev, &chandef,
1334 NL80211_RADAR_CAC_ABORTED,
1338 drv_stop_ap(sdata->local, sdata);
1340 /* free all potentially still buffered bcast frames */
1341 local->total_ps_buffered -= skb_queue_len(&sdata->u.ap.ps.bc_buf);
1342 ieee80211_purge_tx_queue(&local->hw, &sdata->u.ap.ps.bc_buf);
1344 mutex_lock(&local->mtx);
1345 ieee80211_vif_copy_chanctx_to_vlans(sdata, true);
1346 ieee80211_vif_release_channel(sdata);
1347 mutex_unlock(&local->mtx);
1352 static int sta_apply_auth_flags(struct ieee80211_local *local,
1353 struct sta_info *sta,
1358 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
1359 set & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
1360 !test_sta_flag(sta, WLAN_STA_AUTH)) {
1361 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
1366 if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
1367 set & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
1368 !test_sta_flag(sta, WLAN_STA_ASSOC)) {
1370 * When peer becomes associated, init rate control as
1371 * well. Some drivers require rate control initialized
1372 * before drv_sta_state() is called.
1374 if (!test_sta_flag(sta, WLAN_STA_RATE_CONTROL))
1375 rate_control_rate_init(sta);
1377 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
1382 if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
1383 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED))
1384 ret = sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED);
1385 else if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
1386 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
1393 if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
1394 !(set & BIT(NL80211_STA_FLAG_ASSOCIATED)) &&
1395 test_sta_flag(sta, WLAN_STA_ASSOC)) {
1396 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
1401 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
1402 !(set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) &&
1403 test_sta_flag(sta, WLAN_STA_AUTH)) {
1404 ret = sta_info_move_state(sta, IEEE80211_STA_NONE);
1412 static void sta_apply_mesh_params(struct ieee80211_local *local,
1413 struct sta_info *sta,
1414 struct station_parameters *params)
1416 #ifdef CONFIG_MAC80211_MESH
1417 struct ieee80211_sub_if_data *sdata = sta->sdata;
1420 if (params->sta_modify_mask & STATION_PARAM_APPLY_PLINK_STATE) {
1421 switch (params->plink_state) {
1422 case NL80211_PLINK_ESTAB:
1423 if (sta->mesh->plink_state != NL80211_PLINK_ESTAB)
1424 changed = mesh_plink_inc_estab_count(sdata);
1425 sta->mesh->plink_state = params->plink_state;
1426 sta->mesh->aid = params->peer_aid;
1428 ieee80211_mps_sta_status_update(sta);
1429 changed |= ieee80211_mps_set_sta_local_pm(sta,
1430 sdata->u.mesh.mshcfg.power_mode);
1432 ewma_mesh_tx_rate_avg_init(&sta->mesh->tx_rate_avg);
1433 /* init at low value */
1434 ewma_mesh_tx_rate_avg_add(&sta->mesh->tx_rate_avg, 10);
1437 case NL80211_PLINK_LISTEN:
1438 case NL80211_PLINK_BLOCKED:
1439 case NL80211_PLINK_OPN_SNT:
1440 case NL80211_PLINK_OPN_RCVD:
1441 case NL80211_PLINK_CNF_RCVD:
1442 case NL80211_PLINK_HOLDING:
1443 if (sta->mesh->plink_state == NL80211_PLINK_ESTAB)
1444 changed = mesh_plink_dec_estab_count(sdata);
1445 sta->mesh->plink_state = params->plink_state;
1447 ieee80211_mps_sta_status_update(sta);
1448 changed |= ieee80211_mps_set_sta_local_pm(sta,
1449 NL80211_MESH_POWER_UNKNOWN);
1457 switch (params->plink_action) {
1458 case NL80211_PLINK_ACTION_NO_ACTION:
1461 case NL80211_PLINK_ACTION_OPEN:
1462 changed |= mesh_plink_open(sta);
1464 case NL80211_PLINK_ACTION_BLOCK:
1465 changed |= mesh_plink_block(sta);
1469 if (params->local_pm)
1470 changed |= ieee80211_mps_set_sta_local_pm(sta,
1473 ieee80211_mbss_info_change_notify(sdata, changed);
1477 static void sta_apply_airtime_params(struct ieee80211_local *local,
1478 struct sta_info *sta,
1479 struct station_parameters *params)
1483 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
1484 struct airtime_sched_info *air_sched = &local->airtime[ac];
1485 struct airtime_info *air_info = &sta->airtime[ac];
1486 struct txq_info *txqi;
1489 spin_lock_bh(&air_sched->lock);
1490 for (tid = 0; tid < IEEE80211_NUM_TIDS + 1; tid++) {
1491 if (air_info->weight == params->airtime_weight ||
1492 !sta->sta.txq[tid] ||
1493 ac != ieee80211_ac_from_tid(tid))
1496 airtime_weight_set(air_info, params->airtime_weight);
1498 txqi = to_txq_info(sta->sta.txq[tid]);
1499 if (RB_EMPTY_NODE(&txqi->schedule_order))
1502 ieee80211_update_airtime_weight(local, air_sched,
1505 spin_unlock_bh(&air_sched->lock);
1509 static int sta_apply_parameters(struct ieee80211_local *local,
1510 struct sta_info *sta,
1511 struct station_parameters *params)
1514 struct ieee80211_supported_band *sband;
1515 struct ieee80211_sub_if_data *sdata = sta->sdata;
1518 sband = ieee80211_get_sband(sdata);
1522 mask = params->sta_flags_mask;
1523 set = params->sta_flags_set;
1525 if (ieee80211_vif_is_mesh(&sdata->vif)) {
1527 * In mesh mode, ASSOCIATED isn't part of the nl80211
1528 * API but must follow AUTHENTICATED for driver state.
1530 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED))
1531 mask |= BIT(NL80211_STA_FLAG_ASSOCIATED);
1532 if (set & BIT(NL80211_STA_FLAG_AUTHENTICATED))
1533 set |= BIT(NL80211_STA_FLAG_ASSOCIATED);
1534 } else if (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
1536 * TDLS -- everything follows authorized, but
1537 * only becoming authorized is possible, not
1540 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
1541 set |= BIT(NL80211_STA_FLAG_AUTHENTICATED) |
1542 BIT(NL80211_STA_FLAG_ASSOCIATED);
1543 mask |= BIT(NL80211_STA_FLAG_AUTHENTICATED) |
1544 BIT(NL80211_STA_FLAG_ASSOCIATED);
1548 if (mask & BIT(NL80211_STA_FLAG_WME) &&
1549 local->hw.queues >= IEEE80211_NUM_ACS)
1550 sta->sta.wme = set & BIT(NL80211_STA_FLAG_WME);
1552 /* auth flags will be set later for TDLS,
1553 * and for unassociated stations that move to associated */
1554 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1555 !((mask & BIT(NL80211_STA_FLAG_ASSOCIATED)) &&
1556 (set & BIT(NL80211_STA_FLAG_ASSOCIATED)))) {
1557 ret = sta_apply_auth_flags(local, sta, mask, set);
1562 if (mask & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) {
1563 if (set & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE))
1564 set_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
1566 clear_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
1569 if (mask & BIT(NL80211_STA_FLAG_MFP)) {
1570 sta->sta.mfp = !!(set & BIT(NL80211_STA_FLAG_MFP));
1571 if (set & BIT(NL80211_STA_FLAG_MFP))
1572 set_sta_flag(sta, WLAN_STA_MFP);
1574 clear_sta_flag(sta, WLAN_STA_MFP);
1577 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
1578 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER))
1579 set_sta_flag(sta, WLAN_STA_TDLS_PEER);
1581 clear_sta_flag(sta, WLAN_STA_TDLS_PEER);
1584 /* mark TDLS channel switch support, if the AP allows it */
1585 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1586 !sdata->u.mgd.tdls_chan_switch_prohibited &&
1587 params->ext_capab_len >= 4 &&
1588 params->ext_capab[3] & WLAN_EXT_CAPA4_TDLS_CHAN_SWITCH)
1589 set_sta_flag(sta, WLAN_STA_TDLS_CHAN_SWITCH);
1591 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1592 !sdata->u.mgd.tdls_wider_bw_prohibited &&
1593 ieee80211_hw_check(&local->hw, TDLS_WIDER_BW) &&
1594 params->ext_capab_len >= 8 &&
1595 params->ext_capab[7] & WLAN_EXT_CAPA8_TDLS_WIDE_BW_ENABLED)
1596 set_sta_flag(sta, WLAN_STA_TDLS_WIDER_BW);
1598 if (params->sta_modify_mask & STATION_PARAM_APPLY_UAPSD) {
1599 sta->sta.uapsd_queues = params->uapsd_queues;
1600 sta->sta.max_sp = params->max_sp;
1603 /* The sender might not have sent the last bit, consider it to be 0 */
1604 if (params->ext_capab_len >= 8) {
1605 u8 val = (params->ext_capab[7] &
1606 WLAN_EXT_CAPA8_MAX_MSDU_IN_AMSDU_LSB) >> 7;
1608 /* we did get all the bits, take the MSB as well */
1609 if (params->ext_capab_len >= 9) {
1610 u8 val_msb = params->ext_capab[8] &
1611 WLAN_EXT_CAPA9_MAX_MSDU_IN_AMSDU_MSB;
1618 sta->sta.max_amsdu_subframes = 32;
1621 sta->sta.max_amsdu_subframes = 16;
1624 sta->sta.max_amsdu_subframes = 8;
1627 sta->sta.max_amsdu_subframes = 0;
1632 * cfg80211 validates this (1-2007) and allows setting the AID
1633 * only when creating a new station entry
1636 sta->sta.aid = params->aid;
1639 * Some of the following updates would be racy if called on an
1640 * existing station, via ieee80211_change_station(). However,
1641 * all such changes are rejected by cfg80211 except for updates
1642 * changing the supported rates on an existing but not yet used
1646 if (params->listen_interval >= 0)
1647 sta->listen_interval = params->listen_interval;
1649 if (params->sta_modify_mask & STATION_PARAM_APPLY_STA_TXPOWER) {
1650 sta->sta.txpwr.type = params->txpwr.type;
1651 if (params->txpwr.type == NL80211_TX_POWER_LIMITED)
1652 sta->sta.txpwr.power = params->txpwr.power;
1653 ret = drv_sta_set_txpwr(local, sdata, sta);
1658 if (params->supported_rates && params->supported_rates_len) {
1659 ieee80211_parse_bitrates(&sdata->vif.bss_conf.chandef,
1660 sband, params->supported_rates,
1661 params->supported_rates_len,
1662 &sta->sta.supp_rates[sband->band]);
1665 if (params->ht_capa)
1666 ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
1667 params->ht_capa, sta);
1669 /* VHT can override some HT caps such as the A-MSDU max length */
1670 if (params->vht_capa)
1671 ieee80211_vht_cap_ie_to_sta_vht_cap(sdata, sband,
1672 params->vht_capa, sta);
1674 if (params->he_capa)
1675 ieee80211_he_cap_ie_to_sta_he_cap(sdata, sband,
1676 (void *)params->he_capa,
1677 params->he_capa_len,
1678 (void *)params->he_6ghz_capa,
1681 if (params->opmode_notif_used) {
1682 /* returned value is only needed for rc update, but the
1683 * rc isn't initialized here yet, so ignore it
1685 __ieee80211_vht_handle_opmode(sdata, sta, params->opmode_notif,
1689 if (params->support_p2p_ps >= 0)
1690 sta->sta.support_p2p_ps = params->support_p2p_ps;
1692 if (ieee80211_vif_is_mesh(&sdata->vif))
1693 sta_apply_mesh_params(local, sta, params);
1695 if (params->airtime_weight)
1696 sta_apply_airtime_params(local, sta, params);
1699 /* set the STA state after all sta info from usermode has been set */
1700 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) ||
1701 set & BIT(NL80211_STA_FLAG_ASSOCIATED)) {
1702 ret = sta_apply_auth_flags(local, sta, mask, set);
1710 static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
1712 struct station_parameters *params)
1714 struct ieee80211_local *local = wiphy_priv(wiphy);
1715 struct sta_info *sta;
1716 struct ieee80211_sub_if_data *sdata;
1720 sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
1722 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
1723 sdata->vif.type != NL80211_IFTYPE_AP)
1726 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1728 if (ether_addr_equal(mac, sdata->vif.addr))
1731 if (!is_valid_ether_addr(mac))
1734 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER) &&
1735 sdata->vif.type == NL80211_IFTYPE_STATION &&
1736 !sdata->u.mgd.associated)
1739 sta = sta_info_alloc(sdata, mac, GFP_KERNEL);
1743 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))
1744 sta->sta.tdls = true;
1746 err = sta_apply_parameters(local, sta, params);
1748 sta_info_free(local, sta);
1753 * for TDLS and for unassociated station, rate control should be
1754 * initialized only when rates are known and station is marked
1755 * authorized/associated
1757 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1758 test_sta_flag(sta, WLAN_STA_ASSOC))
1759 rate_control_rate_init(sta);
1761 return sta_info_insert(sta);
1764 static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev,
1765 struct station_del_parameters *params)
1767 struct ieee80211_sub_if_data *sdata;
1769 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1772 return sta_info_destroy_addr_bss(sdata, params->mac);
1774 sta_info_flush(sdata);
1778 static int ieee80211_change_station(struct wiphy *wiphy,
1779 struct net_device *dev, const u8 *mac,
1780 struct station_parameters *params)
1782 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1783 struct ieee80211_local *local = wiphy_priv(wiphy);
1784 struct sta_info *sta;
1785 struct ieee80211_sub_if_data *vlansdata;
1786 enum cfg80211_station_type statype;
1789 mutex_lock(&local->sta_mtx);
1791 sta = sta_info_get_bss(sdata, mac);
1797 switch (sdata->vif.type) {
1798 case NL80211_IFTYPE_MESH_POINT:
1799 if (sdata->u.mesh.user_mpm)
1800 statype = CFG80211_STA_MESH_PEER_USER;
1802 statype = CFG80211_STA_MESH_PEER_KERNEL;
1804 case NL80211_IFTYPE_ADHOC:
1805 statype = CFG80211_STA_IBSS;
1807 case NL80211_IFTYPE_STATION:
1808 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
1809 statype = CFG80211_STA_AP_STA;
1812 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
1813 statype = CFG80211_STA_TDLS_PEER_ACTIVE;
1815 statype = CFG80211_STA_TDLS_PEER_SETUP;
1817 case NL80211_IFTYPE_AP:
1818 case NL80211_IFTYPE_AP_VLAN:
1819 if (test_sta_flag(sta, WLAN_STA_ASSOC))
1820 statype = CFG80211_STA_AP_CLIENT;
1822 statype = CFG80211_STA_AP_CLIENT_UNASSOC;
1829 err = cfg80211_check_station_change(wiphy, params, statype);
1833 if (params->vlan && params->vlan != sta->sdata->dev) {
1834 vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
1836 if (params->vlan->ieee80211_ptr->use_4addr) {
1837 if (vlansdata->u.vlan.sta) {
1842 rcu_assign_pointer(vlansdata->u.vlan.sta, sta);
1843 __ieee80211_check_fast_rx_iface(vlansdata);
1844 drv_sta_set_4addr(local, sta->sdata, &sta->sta, true);
1847 if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
1848 sta->sdata->u.vlan.sta) {
1849 ieee80211_clear_fast_rx(sta);
1850 RCU_INIT_POINTER(sta->sdata->u.vlan.sta, NULL);
1853 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
1854 ieee80211_vif_dec_num_mcast(sta->sdata);
1856 sta->sdata = vlansdata;
1857 ieee80211_check_fast_xmit(sta);
1859 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED)) {
1860 ieee80211_vif_inc_num_mcast(sta->sdata);
1861 cfg80211_send_layer2_update(sta->sdata->dev,
1866 err = sta_apply_parameters(local, sta, params);
1870 mutex_unlock(&local->sta_mtx);
1872 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
1873 params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
1874 ieee80211_recalc_ps(local);
1875 ieee80211_recalc_ps_vif(sdata);
1880 mutex_unlock(&local->sta_mtx);
1884 #ifdef CONFIG_MAC80211_MESH
1885 static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev,
1886 const u8 *dst, const u8 *next_hop)
1888 struct ieee80211_sub_if_data *sdata;
1889 struct mesh_path *mpath;
1890 struct sta_info *sta;
1892 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1895 sta = sta_info_get(sdata, next_hop);
1901 mpath = mesh_path_add(sdata, dst);
1902 if (IS_ERR(mpath)) {
1904 return PTR_ERR(mpath);
1907 mesh_path_fix_nexthop(mpath, sta);
1913 static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev,
1916 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1919 return mesh_path_del(sdata, dst);
1921 mesh_path_flush_by_iface(sdata);
1925 static int ieee80211_change_mpath(struct wiphy *wiphy, struct net_device *dev,
1926 const u8 *dst, const u8 *next_hop)
1928 struct ieee80211_sub_if_data *sdata;
1929 struct mesh_path *mpath;
1930 struct sta_info *sta;
1932 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1936 sta = sta_info_get(sdata, next_hop);
1942 mpath = mesh_path_lookup(sdata, dst);
1948 mesh_path_fix_nexthop(mpath, sta);
1954 static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop,
1955 struct mpath_info *pinfo)
1957 struct sta_info *next_hop_sta = rcu_dereference(mpath->next_hop);
1960 memcpy(next_hop, next_hop_sta->sta.addr, ETH_ALEN);
1962 eth_zero_addr(next_hop);
1964 memset(pinfo, 0, sizeof(*pinfo));
1966 pinfo->generation = mpath->sdata->u.mesh.mesh_paths_generation;
1968 pinfo->filled = MPATH_INFO_FRAME_QLEN |
1971 MPATH_INFO_EXPTIME |
1972 MPATH_INFO_DISCOVERY_TIMEOUT |
1973 MPATH_INFO_DISCOVERY_RETRIES |
1975 MPATH_INFO_HOP_COUNT |
1976 MPATH_INFO_PATH_CHANGE;
1978 pinfo->frame_qlen = mpath->frame_queue.qlen;
1979 pinfo->sn = mpath->sn;
1980 pinfo->metric = mpath->metric;
1981 if (time_before(jiffies, mpath->exp_time))
1982 pinfo->exptime = jiffies_to_msecs(mpath->exp_time - jiffies);
1983 pinfo->discovery_timeout =
1984 jiffies_to_msecs(mpath->discovery_timeout);
1985 pinfo->discovery_retries = mpath->discovery_retries;
1986 if (mpath->flags & MESH_PATH_ACTIVE)
1987 pinfo->flags |= NL80211_MPATH_FLAG_ACTIVE;
1988 if (mpath->flags & MESH_PATH_RESOLVING)
1989 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING;
1990 if (mpath->flags & MESH_PATH_SN_VALID)
1991 pinfo->flags |= NL80211_MPATH_FLAG_SN_VALID;
1992 if (mpath->flags & MESH_PATH_FIXED)
1993 pinfo->flags |= NL80211_MPATH_FLAG_FIXED;
1994 if (mpath->flags & MESH_PATH_RESOLVED)
1995 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVED;
1996 pinfo->hop_count = mpath->hop_count;
1997 pinfo->path_change_count = mpath->path_change_count;
2000 static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev,
2001 u8 *dst, u8 *next_hop, struct mpath_info *pinfo)
2004 struct ieee80211_sub_if_data *sdata;
2005 struct mesh_path *mpath;
2007 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2010 mpath = mesh_path_lookup(sdata, dst);
2015 memcpy(dst, mpath->dst, ETH_ALEN);
2016 mpath_set_pinfo(mpath, next_hop, pinfo);
2021 static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev,
2022 int idx, u8 *dst, u8 *next_hop,
2023 struct mpath_info *pinfo)
2025 struct ieee80211_sub_if_data *sdata;
2026 struct mesh_path *mpath;
2028 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2031 mpath = mesh_path_lookup_by_idx(sdata, idx);
2036 memcpy(dst, mpath->dst, ETH_ALEN);
2037 mpath_set_pinfo(mpath, next_hop, pinfo);
2042 static void mpp_set_pinfo(struct mesh_path *mpath, u8 *mpp,
2043 struct mpath_info *pinfo)
2045 memset(pinfo, 0, sizeof(*pinfo));
2046 memcpy(mpp, mpath->mpp, ETH_ALEN);
2048 pinfo->generation = mpath->sdata->u.mesh.mpp_paths_generation;
2051 static int ieee80211_get_mpp(struct wiphy *wiphy, struct net_device *dev,
2052 u8 *dst, u8 *mpp, struct mpath_info *pinfo)
2055 struct ieee80211_sub_if_data *sdata;
2056 struct mesh_path *mpath;
2058 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2061 mpath = mpp_path_lookup(sdata, dst);
2066 memcpy(dst, mpath->dst, ETH_ALEN);
2067 mpp_set_pinfo(mpath, mpp, pinfo);
2072 static int ieee80211_dump_mpp(struct wiphy *wiphy, struct net_device *dev,
2073 int idx, u8 *dst, u8 *mpp,
2074 struct mpath_info *pinfo)
2076 struct ieee80211_sub_if_data *sdata;
2077 struct mesh_path *mpath;
2079 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2082 mpath = mpp_path_lookup_by_idx(sdata, idx);
2087 memcpy(dst, mpath->dst, ETH_ALEN);
2088 mpp_set_pinfo(mpath, mpp, pinfo);
2093 static int ieee80211_get_mesh_config(struct wiphy *wiphy,
2094 struct net_device *dev,
2095 struct mesh_config *conf)
2097 struct ieee80211_sub_if_data *sdata;
2098 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2100 memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config));
2104 static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask)
2106 return (mask >> (parm-1)) & 0x1;
2109 static int copy_mesh_setup(struct ieee80211_if_mesh *ifmsh,
2110 const struct mesh_setup *setup)
2113 struct ieee80211_sub_if_data *sdata = container_of(ifmsh,
2114 struct ieee80211_sub_if_data, u.mesh);
2117 /* allocate information elements */
2120 if (setup->ie_len) {
2121 new_ie = kmemdup(setup->ie, setup->ie_len,
2126 ifmsh->ie_len = setup->ie_len;
2129 /* now copy the rest of the setup parameters */
2130 ifmsh->mesh_id_len = setup->mesh_id_len;
2131 memcpy(ifmsh->mesh_id, setup->mesh_id, ifmsh->mesh_id_len);
2132 ifmsh->mesh_sp_id = setup->sync_method;
2133 ifmsh->mesh_pp_id = setup->path_sel_proto;
2134 ifmsh->mesh_pm_id = setup->path_metric;
2135 ifmsh->user_mpm = setup->user_mpm;
2136 ifmsh->mesh_auth_id = setup->auth_id;
2137 ifmsh->security = IEEE80211_MESH_SEC_NONE;
2138 ifmsh->userspace_handles_dfs = setup->userspace_handles_dfs;
2139 if (setup->is_authenticated)
2140 ifmsh->security |= IEEE80211_MESH_SEC_AUTHED;
2141 if (setup->is_secure)
2142 ifmsh->security |= IEEE80211_MESH_SEC_SECURED;
2144 /* mcast rate setting in Mesh Node */
2145 memcpy(sdata->vif.bss_conf.mcast_rate, setup->mcast_rate,
2146 sizeof(setup->mcast_rate));
2147 sdata->vif.bss_conf.basic_rates = setup->basic_rates;
2149 sdata->vif.bss_conf.beacon_int = setup->beacon_interval;
2150 sdata->vif.bss_conf.dtim_period = setup->dtim_period;
2152 sdata->beacon_rate_set = false;
2153 if (wiphy_ext_feature_isset(sdata->local->hw.wiphy,
2154 NL80211_EXT_FEATURE_BEACON_RATE_LEGACY)) {
2155 for (i = 0; i < NUM_NL80211_BANDS; i++) {
2156 sdata->beacon_rateidx_mask[i] =
2157 setup->beacon_rate.control[i].legacy;
2158 if (sdata->beacon_rateidx_mask[i])
2159 sdata->beacon_rate_set = true;
2166 static int ieee80211_update_mesh_config(struct wiphy *wiphy,
2167 struct net_device *dev, u32 mask,
2168 const struct mesh_config *nconf)
2170 struct mesh_config *conf;
2171 struct ieee80211_sub_if_data *sdata;
2172 struct ieee80211_if_mesh *ifmsh;
2174 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2175 ifmsh = &sdata->u.mesh;
2177 /* Set the config options which we are interested in setting */
2178 conf = &(sdata->u.mesh.mshcfg);
2179 if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask))
2180 conf->dot11MeshRetryTimeout = nconf->dot11MeshRetryTimeout;
2181 if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT, mask))
2182 conf->dot11MeshConfirmTimeout = nconf->dot11MeshConfirmTimeout;
2183 if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT, mask))
2184 conf->dot11MeshHoldingTimeout = nconf->dot11MeshHoldingTimeout;
2185 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS, mask))
2186 conf->dot11MeshMaxPeerLinks = nconf->dot11MeshMaxPeerLinks;
2187 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES, mask))
2188 conf->dot11MeshMaxRetries = nconf->dot11MeshMaxRetries;
2189 if (_chg_mesh_attr(NL80211_MESHCONF_TTL, mask))
2190 conf->dot11MeshTTL = nconf->dot11MeshTTL;
2191 if (_chg_mesh_attr(NL80211_MESHCONF_ELEMENT_TTL, mask))
2192 conf->element_ttl = nconf->element_ttl;
2193 if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask)) {
2194 if (ifmsh->user_mpm)
2196 conf->auto_open_plinks = nconf->auto_open_plinks;
2198 if (_chg_mesh_attr(NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR, mask))
2199 conf->dot11MeshNbrOffsetMaxNeighbor =
2200 nconf->dot11MeshNbrOffsetMaxNeighbor;
2201 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, mask))
2202 conf->dot11MeshHWMPmaxPREQretries =
2203 nconf->dot11MeshHWMPmaxPREQretries;
2204 if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME, mask))
2205 conf->path_refresh_time = nconf->path_refresh_time;
2206 if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, mask))
2207 conf->min_discovery_timeout = nconf->min_discovery_timeout;
2208 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, mask))
2209 conf->dot11MeshHWMPactivePathTimeout =
2210 nconf->dot11MeshHWMPactivePathTimeout;
2211 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, mask))
2212 conf->dot11MeshHWMPpreqMinInterval =
2213 nconf->dot11MeshHWMPpreqMinInterval;
2214 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL, mask))
2215 conf->dot11MeshHWMPperrMinInterval =
2216 nconf->dot11MeshHWMPperrMinInterval;
2217 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
2219 conf->dot11MeshHWMPnetDiameterTraversalTime =
2220 nconf->dot11MeshHWMPnetDiameterTraversalTime;
2221 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOTMODE, mask)) {
2222 conf->dot11MeshHWMPRootMode = nconf->dot11MeshHWMPRootMode;
2223 ieee80211_mesh_root_setup(ifmsh);
2225 if (_chg_mesh_attr(NL80211_MESHCONF_GATE_ANNOUNCEMENTS, mask)) {
2226 /* our current gate announcement implementation rides on root
2227 * announcements, so require this ifmsh to also be a root node
2229 if (nconf->dot11MeshGateAnnouncementProtocol &&
2230 !(conf->dot11MeshHWMPRootMode > IEEE80211_ROOTMODE_ROOT)) {
2231 conf->dot11MeshHWMPRootMode = IEEE80211_PROACTIVE_RANN;
2232 ieee80211_mesh_root_setup(ifmsh);
2234 conf->dot11MeshGateAnnouncementProtocol =
2235 nconf->dot11MeshGateAnnouncementProtocol;
2237 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_RANN_INTERVAL, mask))
2238 conf->dot11MeshHWMPRannInterval =
2239 nconf->dot11MeshHWMPRannInterval;
2240 if (_chg_mesh_attr(NL80211_MESHCONF_FORWARDING, mask))
2241 conf->dot11MeshForwarding = nconf->dot11MeshForwarding;
2242 if (_chg_mesh_attr(NL80211_MESHCONF_RSSI_THRESHOLD, mask)) {
2243 /* our RSSI threshold implementation is supported only for
2244 * devices that report signal in dBm.
2246 if (!ieee80211_hw_check(&sdata->local->hw, SIGNAL_DBM))
2248 conf->rssi_threshold = nconf->rssi_threshold;
2250 if (_chg_mesh_attr(NL80211_MESHCONF_HT_OPMODE, mask)) {
2251 conf->ht_opmode = nconf->ht_opmode;
2252 sdata->vif.bss_conf.ht_operation_mode = nconf->ht_opmode;
2253 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_HT);
2255 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT, mask))
2256 conf->dot11MeshHWMPactivePathToRootTimeout =
2257 nconf->dot11MeshHWMPactivePathToRootTimeout;
2258 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOT_INTERVAL, mask))
2259 conf->dot11MeshHWMProotInterval =
2260 nconf->dot11MeshHWMProotInterval;
2261 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL, mask))
2262 conf->dot11MeshHWMPconfirmationInterval =
2263 nconf->dot11MeshHWMPconfirmationInterval;
2264 if (_chg_mesh_attr(NL80211_MESHCONF_POWER_MODE, mask)) {
2265 conf->power_mode = nconf->power_mode;
2266 ieee80211_mps_local_status_update(sdata);
2268 if (_chg_mesh_attr(NL80211_MESHCONF_AWAKE_WINDOW, mask))
2269 conf->dot11MeshAwakeWindowDuration =
2270 nconf->dot11MeshAwakeWindowDuration;
2271 if (_chg_mesh_attr(NL80211_MESHCONF_PLINK_TIMEOUT, mask))
2272 conf->plink_timeout = nconf->plink_timeout;
2273 if (_chg_mesh_attr(NL80211_MESHCONF_CONNECTED_TO_GATE, mask))
2274 conf->dot11MeshConnectedToMeshGate =
2275 nconf->dot11MeshConnectedToMeshGate;
2276 if (_chg_mesh_attr(NL80211_MESHCONF_NOLEARN, mask))
2277 conf->dot11MeshNolearn = nconf->dot11MeshNolearn;
2278 if (_chg_mesh_attr(NL80211_MESHCONF_CONNECTED_TO_AS, mask))
2279 conf->dot11MeshConnectedToAuthServer =
2280 nconf->dot11MeshConnectedToAuthServer;
2281 ieee80211_mbss_info_change_notify(sdata, BSS_CHANGED_BEACON);
2285 static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev,
2286 const struct mesh_config *conf,
2287 const struct mesh_setup *setup)
2289 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2290 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
2293 memcpy(&ifmsh->mshcfg, conf, sizeof(struct mesh_config));
2294 err = copy_mesh_setup(ifmsh, setup);
2298 sdata->control_port_over_nl80211 = setup->control_port_over_nl80211;
2300 /* can mesh use other SMPS modes? */
2301 sdata->smps_mode = IEEE80211_SMPS_OFF;
2302 sdata->needed_rx_chains = sdata->local->rx_chains;
2304 mutex_lock(&sdata->local->mtx);
2305 err = ieee80211_vif_use_channel(sdata, &setup->chandef,
2306 IEEE80211_CHANCTX_SHARED);
2307 mutex_unlock(&sdata->local->mtx);
2311 return ieee80211_start_mesh(sdata);
2314 static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev)
2316 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2318 ieee80211_stop_mesh(sdata);
2319 mutex_lock(&sdata->local->mtx);
2320 ieee80211_vif_release_channel(sdata);
2321 kfree(sdata->u.mesh.ie);
2322 mutex_unlock(&sdata->local->mtx);
2328 static int ieee80211_change_bss(struct wiphy *wiphy,
2329 struct net_device *dev,
2330 struct bss_parameters *params)
2332 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2333 struct ieee80211_supported_band *sband;
2336 if (!sdata_dereference(sdata->u.ap.beacon, sdata))
2339 sband = ieee80211_get_sband(sdata);
2343 if (params->use_cts_prot >= 0) {
2344 sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot;
2345 changed |= BSS_CHANGED_ERP_CTS_PROT;
2347 if (params->use_short_preamble >= 0) {
2348 sdata->vif.bss_conf.use_short_preamble =
2349 params->use_short_preamble;
2350 changed |= BSS_CHANGED_ERP_PREAMBLE;
2353 if (!sdata->vif.bss_conf.use_short_slot &&
2354 (sband->band == NL80211_BAND_5GHZ ||
2355 sband->band == NL80211_BAND_6GHZ)) {
2356 sdata->vif.bss_conf.use_short_slot = true;
2357 changed |= BSS_CHANGED_ERP_SLOT;
2360 if (params->use_short_slot_time >= 0) {
2361 sdata->vif.bss_conf.use_short_slot =
2362 params->use_short_slot_time;
2363 changed |= BSS_CHANGED_ERP_SLOT;
2366 if (params->basic_rates) {
2367 ieee80211_parse_bitrates(&sdata->vif.bss_conf.chandef,
2368 wiphy->bands[sband->band],
2369 params->basic_rates,
2370 params->basic_rates_len,
2371 &sdata->vif.bss_conf.basic_rates);
2372 changed |= BSS_CHANGED_BASIC_RATES;
2373 ieee80211_check_rate_mask(sdata);
2376 if (params->ap_isolate >= 0) {
2377 if (params->ap_isolate)
2378 sdata->flags |= IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
2380 sdata->flags &= ~IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
2381 ieee80211_check_fast_rx_iface(sdata);
2384 if (params->ht_opmode >= 0) {
2385 sdata->vif.bss_conf.ht_operation_mode =
2386 (u16) params->ht_opmode;
2387 changed |= BSS_CHANGED_HT;
2390 if (params->p2p_ctwindow >= 0) {
2391 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow &=
2392 ~IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
2393 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |=
2394 params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
2395 changed |= BSS_CHANGED_P2P_PS;
2398 if (params->p2p_opp_ps > 0) {
2399 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |=
2400 IEEE80211_P2P_OPPPS_ENABLE_BIT;
2401 changed |= BSS_CHANGED_P2P_PS;
2402 } else if (params->p2p_opp_ps == 0) {
2403 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow &=
2404 ~IEEE80211_P2P_OPPPS_ENABLE_BIT;
2405 changed |= BSS_CHANGED_P2P_PS;
2408 ieee80211_bss_info_change_notify(sdata, changed);
2413 static int ieee80211_set_txq_params(struct wiphy *wiphy,
2414 struct net_device *dev,
2415 struct ieee80211_txq_params *params)
2417 struct ieee80211_local *local = wiphy_priv(wiphy);
2418 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2419 struct ieee80211_tx_queue_params p;
2421 if (!local->ops->conf_tx)
2424 if (local->hw.queues < IEEE80211_NUM_ACS)
2427 memset(&p, 0, sizeof(p));
2428 p.aifs = params->aifs;
2429 p.cw_max = params->cwmax;
2430 p.cw_min = params->cwmin;
2431 p.txop = params->txop;
2434 * Setting tx queue params disables u-apsd because it's only
2435 * called in master mode.
2439 ieee80211_regulatory_limit_wmm_params(sdata, &p, params->ac);
2441 sdata->tx_conf[params->ac] = p;
2442 if (drv_conf_tx(local, sdata, params->ac, &p)) {
2443 wiphy_debug(local->hw.wiphy,
2444 "failed to set TX queue parameters for AC %d\n",
2449 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_QOS);
2455 static int ieee80211_suspend(struct wiphy *wiphy,
2456 struct cfg80211_wowlan *wowlan)
2458 return __ieee80211_suspend(wiphy_priv(wiphy), wowlan);
2461 static int ieee80211_resume(struct wiphy *wiphy)
2463 return __ieee80211_resume(wiphy_priv(wiphy));
2466 #define ieee80211_suspend NULL
2467 #define ieee80211_resume NULL
2470 static int ieee80211_scan(struct wiphy *wiphy,
2471 struct cfg80211_scan_request *req)
2473 struct ieee80211_sub_if_data *sdata;
2475 sdata = IEEE80211_WDEV_TO_SUB_IF(req->wdev);
2477 switch (ieee80211_vif_type_p2p(&sdata->vif)) {
2478 case NL80211_IFTYPE_STATION:
2479 case NL80211_IFTYPE_ADHOC:
2480 case NL80211_IFTYPE_MESH_POINT:
2481 case NL80211_IFTYPE_P2P_CLIENT:
2482 case NL80211_IFTYPE_P2P_DEVICE:
2484 case NL80211_IFTYPE_P2P_GO:
2485 if (sdata->local->ops->hw_scan)
2488 * FIXME: implement NoA while scanning in software,
2489 * for now fall through to allow scanning only when
2490 * beaconing hasn't been configured yet
2493 case NL80211_IFTYPE_AP:
2495 * If the scan has been forced (and the driver supports
2496 * forcing), don't care about being beaconing already.
2497 * This will create problems to the attached stations (e.g. all
2498 * the frames sent while scanning on other channel will be
2501 if (sdata->u.ap.beacon &&
2502 (!(wiphy->features & NL80211_FEATURE_AP_SCAN) ||
2503 !(req->flags & NL80211_SCAN_FLAG_AP)))
2506 case NL80211_IFTYPE_NAN:
2511 return ieee80211_request_scan(sdata, req);
2514 static void ieee80211_abort_scan(struct wiphy *wiphy, struct wireless_dev *wdev)
2516 ieee80211_scan_cancel(wiphy_priv(wiphy));
2520 ieee80211_sched_scan_start(struct wiphy *wiphy,
2521 struct net_device *dev,
2522 struct cfg80211_sched_scan_request *req)
2524 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2526 if (!sdata->local->ops->sched_scan_start)
2529 return ieee80211_request_sched_scan_start(sdata, req);
2533 ieee80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev,
2536 struct ieee80211_local *local = wiphy_priv(wiphy);
2538 if (!local->ops->sched_scan_stop)
2541 return ieee80211_request_sched_scan_stop(local);
2544 static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev,
2545 struct cfg80211_auth_request *req)
2547 return ieee80211_mgd_auth(IEEE80211_DEV_TO_SUB_IF(dev), req);
2550 static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev,
2551 struct cfg80211_assoc_request *req)
2553 return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
2556 static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev,
2557 struct cfg80211_deauth_request *req)
2559 return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev), req);
2562 static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
2563 struct cfg80211_disassoc_request *req)
2565 return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
2568 static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
2569 struct cfg80211_ibss_params *params)
2571 return ieee80211_ibss_join(IEEE80211_DEV_TO_SUB_IF(dev), params);
2574 static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
2576 return ieee80211_ibss_leave(IEEE80211_DEV_TO_SUB_IF(dev));
2579 static int ieee80211_join_ocb(struct wiphy *wiphy, struct net_device *dev,
2580 struct ocb_setup *setup)
2582 return ieee80211_ocb_join(IEEE80211_DEV_TO_SUB_IF(dev), setup);
2585 static int ieee80211_leave_ocb(struct wiphy *wiphy, struct net_device *dev)
2587 return ieee80211_ocb_leave(IEEE80211_DEV_TO_SUB_IF(dev));
2590 static int ieee80211_set_mcast_rate(struct wiphy *wiphy, struct net_device *dev,
2591 int rate[NUM_NL80211_BANDS])
2593 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2595 memcpy(sdata->vif.bss_conf.mcast_rate, rate,
2596 sizeof(int) * NUM_NL80211_BANDS);
2598 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_MCAST_RATE);
2603 static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
2605 struct ieee80211_local *local = wiphy_priv(wiphy);
2608 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
2609 ieee80211_check_fast_xmit_all(local);
2611 err = drv_set_frag_threshold(local, wiphy->frag_threshold);
2614 ieee80211_check_fast_xmit_all(local);
2619 if ((changed & WIPHY_PARAM_COVERAGE_CLASS) ||
2620 (changed & WIPHY_PARAM_DYN_ACK)) {
2623 coverage_class = changed & WIPHY_PARAM_COVERAGE_CLASS ?
2624 wiphy->coverage_class : -1;
2625 err = drv_set_coverage_class(local, coverage_class);
2631 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
2632 err = drv_set_rts_threshold(local, wiphy->rts_threshold);
2638 if (changed & WIPHY_PARAM_RETRY_SHORT) {
2639 if (wiphy->retry_short > IEEE80211_MAX_TX_RETRY)
2641 local->hw.conf.short_frame_max_tx_count = wiphy->retry_short;
2643 if (changed & WIPHY_PARAM_RETRY_LONG) {
2644 if (wiphy->retry_long > IEEE80211_MAX_TX_RETRY)
2646 local->hw.conf.long_frame_max_tx_count = wiphy->retry_long;
2649 (WIPHY_PARAM_RETRY_SHORT | WIPHY_PARAM_RETRY_LONG))
2650 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS);
2652 if (changed & (WIPHY_PARAM_TXQ_LIMIT |
2653 WIPHY_PARAM_TXQ_MEMORY_LIMIT |
2654 WIPHY_PARAM_TXQ_QUANTUM))
2655 ieee80211_txq_set_params(local);
2660 static int ieee80211_set_tx_power(struct wiphy *wiphy,
2661 struct wireless_dev *wdev,
2662 enum nl80211_tx_power_setting type, int mbm)
2664 struct ieee80211_local *local = wiphy_priv(wiphy);
2665 struct ieee80211_sub_if_data *sdata;
2666 enum nl80211_tx_power_setting txp_type = type;
2667 bool update_txp_type = false;
2668 bool has_monitor = false;
2671 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
2673 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) {
2674 sdata = wiphy_dereference(local->hw.wiphy,
2675 local->monitor_sdata);
2681 case NL80211_TX_POWER_AUTOMATIC:
2682 sdata->user_power_level = IEEE80211_UNSET_POWER_LEVEL;
2683 txp_type = NL80211_TX_POWER_LIMITED;
2685 case NL80211_TX_POWER_LIMITED:
2686 case NL80211_TX_POWER_FIXED:
2687 if (mbm < 0 || (mbm % 100))
2689 sdata->user_power_level = MBM_TO_DBM(mbm);
2693 if (txp_type != sdata->vif.bss_conf.txpower_type) {
2694 update_txp_type = true;
2695 sdata->vif.bss_conf.txpower_type = txp_type;
2698 ieee80211_recalc_txpower(sdata, update_txp_type);
2704 case NL80211_TX_POWER_AUTOMATIC:
2705 local->user_power_level = IEEE80211_UNSET_POWER_LEVEL;
2706 txp_type = NL80211_TX_POWER_LIMITED;
2708 case NL80211_TX_POWER_LIMITED:
2709 case NL80211_TX_POWER_FIXED:
2710 if (mbm < 0 || (mbm % 100))
2712 local->user_power_level = MBM_TO_DBM(mbm);
2716 mutex_lock(&local->iflist_mtx);
2717 list_for_each_entry(sdata, &local->interfaces, list) {
2718 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) {
2722 sdata->user_power_level = local->user_power_level;
2723 if (txp_type != sdata->vif.bss_conf.txpower_type)
2724 update_txp_type = true;
2725 sdata->vif.bss_conf.txpower_type = txp_type;
2727 list_for_each_entry(sdata, &local->interfaces, list) {
2728 if (sdata->vif.type == NL80211_IFTYPE_MONITOR)
2730 ieee80211_recalc_txpower(sdata, update_txp_type);
2732 mutex_unlock(&local->iflist_mtx);
2735 sdata = wiphy_dereference(local->hw.wiphy,
2736 local->monitor_sdata);
2738 sdata->user_power_level = local->user_power_level;
2739 if (txp_type != sdata->vif.bss_conf.txpower_type)
2740 update_txp_type = true;
2741 sdata->vif.bss_conf.txpower_type = txp_type;
2743 ieee80211_recalc_txpower(sdata, update_txp_type);
2750 static int ieee80211_get_tx_power(struct wiphy *wiphy,
2751 struct wireless_dev *wdev,
2754 struct ieee80211_local *local = wiphy_priv(wiphy);
2755 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
2757 if (local->ops->get_txpower)
2758 return drv_get_txpower(local, sdata, dbm);
2760 if (!local->use_chanctx)
2761 *dbm = local->hw.conf.power_level;
2763 *dbm = sdata->vif.bss_conf.txpower;
2768 static void ieee80211_rfkill_poll(struct wiphy *wiphy)
2770 struct ieee80211_local *local = wiphy_priv(wiphy);
2772 drv_rfkill_poll(local);
2775 #ifdef CONFIG_NL80211_TESTMODE
2776 static int ieee80211_testmode_cmd(struct wiphy *wiphy,
2777 struct wireless_dev *wdev,
2778 void *data, int len)
2780 struct ieee80211_local *local = wiphy_priv(wiphy);
2781 struct ieee80211_vif *vif = NULL;
2783 if (!local->ops->testmode_cmd)
2787 struct ieee80211_sub_if_data *sdata;
2789 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
2790 if (sdata->flags & IEEE80211_SDATA_IN_DRIVER)
2794 return local->ops->testmode_cmd(&local->hw, vif, data, len);
2797 static int ieee80211_testmode_dump(struct wiphy *wiphy,
2798 struct sk_buff *skb,
2799 struct netlink_callback *cb,
2800 void *data, int len)
2802 struct ieee80211_local *local = wiphy_priv(wiphy);
2804 if (!local->ops->testmode_dump)
2807 return local->ops->testmode_dump(&local->hw, skb, cb, data, len);
2811 int __ieee80211_request_smps_mgd(struct ieee80211_sub_if_data *sdata,
2812 enum ieee80211_smps_mode smps_mode)
2815 enum ieee80211_smps_mode old_req;
2817 struct sta_info *sta;
2818 bool tdls_peer_found = false;
2820 lockdep_assert_held(&sdata->wdev.mtx);
2822 if (WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION))
2825 old_req = sdata->u.mgd.req_smps;
2826 sdata->u.mgd.req_smps = smps_mode;
2828 if (old_req == smps_mode &&
2829 smps_mode != IEEE80211_SMPS_AUTOMATIC)
2833 * If not associated, or current association is not an HT
2834 * association, there's no need to do anything, just store
2835 * the new value until we associate.
2837 if (!sdata->u.mgd.associated ||
2838 sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT)
2841 ap = sdata->u.mgd.associated->bssid;
2844 list_for_each_entry_rcu(sta, &sdata->local->sta_list, list) {
2845 if (!sta->sta.tdls || sta->sdata != sdata || !sta->uploaded ||
2846 !test_sta_flag(sta, WLAN_STA_AUTHORIZED))
2849 tdls_peer_found = true;
2854 if (smps_mode == IEEE80211_SMPS_AUTOMATIC) {
2855 if (tdls_peer_found || !sdata->u.mgd.powersave)
2856 smps_mode = IEEE80211_SMPS_OFF;
2858 smps_mode = IEEE80211_SMPS_DYNAMIC;
2861 /* send SM PS frame to AP */
2862 err = ieee80211_send_smps_action(sdata, smps_mode,
2865 sdata->u.mgd.req_smps = old_req;
2866 else if (smps_mode != IEEE80211_SMPS_OFF && tdls_peer_found)
2867 ieee80211_teardown_tdls_peers(sdata);
2872 static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
2873 bool enabled, int timeout)
2875 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2876 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2878 if (sdata->vif.type != NL80211_IFTYPE_STATION)
2881 if (!ieee80211_hw_check(&local->hw, SUPPORTS_PS))
2884 if (enabled == sdata->u.mgd.powersave &&
2885 timeout == local->dynamic_ps_forced_timeout)
2888 sdata->u.mgd.powersave = enabled;
2889 local->dynamic_ps_forced_timeout = timeout;
2891 /* no change, but if automatic follow powersave */
2893 __ieee80211_request_smps_mgd(sdata, sdata->u.mgd.req_smps);
2894 sdata_unlock(sdata);
2896 if (ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS))
2897 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
2899 ieee80211_recalc_ps(local);
2900 ieee80211_recalc_ps_vif(sdata);
2901 ieee80211_check_fast_rx_iface(sdata);
2906 static int ieee80211_set_cqm_rssi_config(struct wiphy *wiphy,
2907 struct net_device *dev,
2908 s32 rssi_thold, u32 rssi_hyst)
2910 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2911 struct ieee80211_vif *vif = &sdata->vif;
2912 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
2914 if (rssi_thold == bss_conf->cqm_rssi_thold &&
2915 rssi_hyst == bss_conf->cqm_rssi_hyst)
2918 if (sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER &&
2919 !(sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI))
2922 bss_conf->cqm_rssi_thold = rssi_thold;
2923 bss_conf->cqm_rssi_hyst = rssi_hyst;
2924 bss_conf->cqm_rssi_low = 0;
2925 bss_conf->cqm_rssi_high = 0;
2926 sdata->u.mgd.last_cqm_event_signal = 0;
2928 /* tell the driver upon association, unless already associated */
2929 if (sdata->u.mgd.associated &&
2930 sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)
2931 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_CQM);
2936 static int ieee80211_set_cqm_rssi_range_config(struct wiphy *wiphy,
2937 struct net_device *dev,
2938 s32 rssi_low, s32 rssi_high)
2940 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2941 struct ieee80211_vif *vif = &sdata->vif;
2942 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
2944 if (sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER)
2947 bss_conf->cqm_rssi_low = rssi_low;
2948 bss_conf->cqm_rssi_high = rssi_high;
2949 bss_conf->cqm_rssi_thold = 0;
2950 bss_conf->cqm_rssi_hyst = 0;
2951 sdata->u.mgd.last_cqm_event_signal = 0;
2953 /* tell the driver upon association, unless already associated */
2954 if (sdata->u.mgd.associated &&
2955 sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)
2956 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_CQM);
2961 static int ieee80211_set_bitrate_mask(struct wiphy *wiphy,
2962 struct net_device *dev,
2964 const struct cfg80211_bitrate_mask *mask)
2966 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2967 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2970 if (!ieee80211_sdata_running(sdata))
2974 * If active validate the setting and reject it if it doesn't leave
2975 * at least one basic rate usable, since we really have to be able
2976 * to send something, and if we're an AP we have to be able to do
2977 * so at a basic rate so that all clients can receive it.
2979 if (rcu_access_pointer(sdata->vif.chanctx_conf) &&
2980 sdata->vif.bss_conf.chandef.chan) {
2981 u32 basic_rates = sdata->vif.bss_conf.basic_rates;
2982 enum nl80211_band band = sdata->vif.bss_conf.chandef.chan->band;
2984 if (!(mask->control[band].legacy & basic_rates))
2988 if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) {
2989 ret = drv_set_bitrate_mask(local, sdata, mask);
2994 for (i = 0; i < NUM_NL80211_BANDS; i++) {
2995 struct ieee80211_supported_band *sband = wiphy->bands[i];
2998 sdata->rc_rateidx_mask[i] = mask->control[i].legacy;
2999 memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].ht_mcs,
3000 sizeof(mask->control[i].ht_mcs));
3001 memcpy(sdata->rc_rateidx_vht_mcs_mask[i],
3002 mask->control[i].vht_mcs,
3003 sizeof(mask->control[i].vht_mcs));
3005 sdata->rc_has_mcs_mask[i] = false;
3006 sdata->rc_has_vht_mcs_mask[i] = false;
3010 for (j = 0; j < IEEE80211_HT_MCS_MASK_LEN; j++) {
3011 if (sdata->rc_rateidx_mcs_mask[i][j] != 0xff) {
3012 sdata->rc_has_mcs_mask[i] = true;
3017 for (j = 0; j < NL80211_VHT_NSS_MAX; j++) {
3018 if (sdata->rc_rateidx_vht_mcs_mask[i][j] != 0xffff) {
3019 sdata->rc_has_vht_mcs_mask[i] = true;
3028 static int ieee80211_start_radar_detection(struct wiphy *wiphy,
3029 struct net_device *dev,
3030 struct cfg80211_chan_def *chandef,
3033 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3034 struct ieee80211_local *local = sdata->local;
3037 mutex_lock(&local->mtx);
3038 if (!list_empty(&local->roc_list) || local->scanning) {
3043 /* whatever, but channel contexts should not complain about that one */
3044 sdata->smps_mode = IEEE80211_SMPS_OFF;
3045 sdata->needed_rx_chains = local->rx_chains;
3047 err = ieee80211_vif_use_channel(sdata, chandef,
3048 IEEE80211_CHANCTX_SHARED);
3052 ieee80211_queue_delayed_work(&sdata->local->hw,
3053 &sdata->dfs_cac_timer_work,
3054 msecs_to_jiffies(cac_time_ms));
3057 mutex_unlock(&local->mtx);
3061 static void ieee80211_end_cac(struct wiphy *wiphy,
3062 struct net_device *dev)
3064 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3065 struct ieee80211_local *local = sdata->local;
3067 mutex_lock(&local->mtx);
3068 list_for_each_entry(sdata, &local->interfaces, list) {
3069 /* it might be waiting for the local->mtx, but then
3070 * by the time it gets it, sdata->wdev.cac_started
3071 * will no longer be true
3073 cancel_delayed_work(&sdata->dfs_cac_timer_work);
3075 if (sdata->wdev.cac_started) {
3076 ieee80211_vif_release_channel(sdata);
3077 sdata->wdev.cac_started = false;
3080 mutex_unlock(&local->mtx);
3083 static struct cfg80211_beacon_data *
3084 cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon)
3086 struct cfg80211_beacon_data *new_beacon;
3090 len = beacon->head_len + beacon->tail_len + beacon->beacon_ies_len +
3091 beacon->proberesp_ies_len + beacon->assocresp_ies_len +
3092 beacon->probe_resp_len + beacon->lci_len + beacon->civicloc_len;
3094 new_beacon = kzalloc(sizeof(*new_beacon) + len, GFP_KERNEL);
3098 pos = (u8 *)(new_beacon + 1);
3099 if (beacon->head_len) {
3100 new_beacon->head_len = beacon->head_len;
3101 new_beacon->head = pos;
3102 memcpy(pos, beacon->head, beacon->head_len);
3103 pos += beacon->head_len;
3105 if (beacon->tail_len) {
3106 new_beacon->tail_len = beacon->tail_len;
3107 new_beacon->tail = pos;
3108 memcpy(pos, beacon->tail, beacon->tail_len);
3109 pos += beacon->tail_len;
3111 if (beacon->beacon_ies_len) {
3112 new_beacon->beacon_ies_len = beacon->beacon_ies_len;
3113 new_beacon->beacon_ies = pos;
3114 memcpy(pos, beacon->beacon_ies, beacon->beacon_ies_len);
3115 pos += beacon->beacon_ies_len;
3117 if (beacon->proberesp_ies_len) {
3118 new_beacon->proberesp_ies_len = beacon->proberesp_ies_len;
3119 new_beacon->proberesp_ies = pos;
3120 memcpy(pos, beacon->proberesp_ies, beacon->proberesp_ies_len);
3121 pos += beacon->proberesp_ies_len;
3123 if (beacon->assocresp_ies_len) {
3124 new_beacon->assocresp_ies_len = beacon->assocresp_ies_len;
3125 new_beacon->assocresp_ies = pos;
3126 memcpy(pos, beacon->assocresp_ies, beacon->assocresp_ies_len);
3127 pos += beacon->assocresp_ies_len;
3129 if (beacon->probe_resp_len) {
3130 new_beacon->probe_resp_len = beacon->probe_resp_len;
3131 new_beacon->probe_resp = pos;
3132 memcpy(pos, beacon->probe_resp, beacon->probe_resp_len);
3133 pos += beacon->probe_resp_len;
3136 /* might copy -1, meaning no changes requested */
3137 new_beacon->ftm_responder = beacon->ftm_responder;
3139 new_beacon->lci_len = beacon->lci_len;
3140 new_beacon->lci = pos;
3141 memcpy(pos, beacon->lci, beacon->lci_len);
3142 pos += beacon->lci_len;
3144 if (beacon->civicloc) {
3145 new_beacon->civicloc_len = beacon->civicloc_len;
3146 new_beacon->civicloc = pos;
3147 memcpy(pos, beacon->civicloc, beacon->civicloc_len);
3148 pos += beacon->civicloc_len;
3154 void ieee80211_csa_finish(struct ieee80211_vif *vif)
3156 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
3158 ieee80211_queue_work(&sdata->local->hw,
3159 &sdata->csa_finalize_work);
3161 EXPORT_SYMBOL(ieee80211_csa_finish);
3163 static int ieee80211_set_after_csa_beacon(struct ieee80211_sub_if_data *sdata,
3168 switch (sdata->vif.type) {
3169 case NL80211_IFTYPE_AP:
3170 err = ieee80211_assign_beacon(sdata, sdata->u.ap.next_beacon,
3172 kfree(sdata->u.ap.next_beacon);
3173 sdata->u.ap.next_beacon = NULL;
3179 case NL80211_IFTYPE_ADHOC:
3180 err = ieee80211_ibss_finish_csa(sdata);
3185 #ifdef CONFIG_MAC80211_MESH
3186 case NL80211_IFTYPE_MESH_POINT:
3187 err = ieee80211_mesh_finish_csa(sdata);
3201 static int __ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata)
3203 struct ieee80211_local *local = sdata->local;
3207 sdata_assert_lock(sdata);
3208 lockdep_assert_held(&local->mtx);
3209 lockdep_assert_held(&local->chanctx_mtx);
3212 * using reservation isn't immediate as it may be deferred until later
3213 * with multi-vif. once reservation is complete it will re-schedule the
3214 * work with no reserved_chanctx so verify chandef to check if it
3215 * completed successfully
3218 if (sdata->reserved_chanctx) {
3220 * with multi-vif csa driver may call ieee80211_csa_finish()
3221 * many times while waiting for other interfaces to use their
3224 if (sdata->reserved_ready)
3227 return ieee80211_vif_use_reserved_context(sdata);
3230 if (!cfg80211_chandef_identical(&sdata->vif.bss_conf.chandef,
3231 &sdata->csa_chandef))
3234 sdata->vif.csa_active = false;
3236 err = ieee80211_set_after_csa_beacon(sdata, &changed);
3240 ieee80211_bss_info_change_notify(sdata, changed);
3242 if (sdata->csa_block_tx) {
3243 ieee80211_wake_vif_queues(local, sdata,
3244 IEEE80211_QUEUE_STOP_REASON_CSA);
3245 sdata->csa_block_tx = false;
3248 err = drv_post_channel_switch(sdata);
3252 cfg80211_ch_switch_notify(sdata->dev, &sdata->csa_chandef);
3257 static void ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata)
3259 if (__ieee80211_csa_finalize(sdata)) {
3260 sdata_info(sdata, "failed to finalize CSA, disconnecting\n");
3261 cfg80211_stop_iface(sdata->local->hw.wiphy, &sdata->wdev,
3266 void ieee80211_csa_finalize_work(struct work_struct *work)
3268 struct ieee80211_sub_if_data *sdata =
3269 container_of(work, struct ieee80211_sub_if_data,
3271 struct ieee80211_local *local = sdata->local;
3274 mutex_lock(&local->mtx);
3275 mutex_lock(&local->chanctx_mtx);
3277 /* AP might have been stopped while waiting for the lock. */
3278 if (!sdata->vif.csa_active)
3281 if (!ieee80211_sdata_running(sdata))
3284 ieee80211_csa_finalize(sdata);
3287 mutex_unlock(&local->chanctx_mtx);
3288 mutex_unlock(&local->mtx);
3289 sdata_unlock(sdata);
3292 static int ieee80211_set_csa_beacon(struct ieee80211_sub_if_data *sdata,
3293 struct cfg80211_csa_settings *params,
3296 struct ieee80211_csa_settings csa = {};
3299 switch (sdata->vif.type) {
3300 case NL80211_IFTYPE_AP:
3301 sdata->u.ap.next_beacon =
3302 cfg80211_beacon_dup(¶ms->beacon_after);
3303 if (!sdata->u.ap.next_beacon)
3307 * With a count of 0, we don't have to wait for any
3308 * TBTT before switching, so complete the CSA
3309 * immediately. In theory, with a count == 1 we
3310 * should delay the switch until just before the next
3311 * TBTT, but that would complicate things so we switch
3312 * immediately too. If we would delay the switch
3313 * until the next TBTT, we would have to set the probe
3316 * TODO: A channel switch with count <= 1 without
3317 * sending a CSA action frame is kind of useless,
3318 * because the clients won't know we're changing
3319 * channels. The action frame must be implemented
3320 * either here or in the userspace.
3322 if (params->count <= 1)
3325 if ((params->n_counter_offsets_beacon >
3326 IEEE80211_MAX_CNTDWN_COUNTERS_NUM) ||
3327 (params->n_counter_offsets_presp >
3328 IEEE80211_MAX_CNTDWN_COUNTERS_NUM))
3331 csa.counter_offsets_beacon = params->counter_offsets_beacon;
3332 csa.counter_offsets_presp = params->counter_offsets_presp;
3333 csa.n_counter_offsets_beacon = params->n_counter_offsets_beacon;
3334 csa.n_counter_offsets_presp = params->n_counter_offsets_presp;
3335 csa.count = params->count;
3337 err = ieee80211_assign_beacon(sdata, ¶ms->beacon_csa, &csa, NULL);
3339 kfree(sdata->u.ap.next_beacon);
3345 case NL80211_IFTYPE_ADHOC:
3346 if (!sdata->vif.bss_conf.ibss_joined)
3349 if (params->chandef.width != sdata->u.ibss.chandef.width)
3352 switch (params->chandef.width) {
3353 case NL80211_CHAN_WIDTH_40:
3354 if (cfg80211_get_chandef_type(¶ms->chandef) !=
3355 cfg80211_get_chandef_type(&sdata->u.ibss.chandef))
3358 case NL80211_CHAN_WIDTH_5:
3359 case NL80211_CHAN_WIDTH_10:
3360 case NL80211_CHAN_WIDTH_20_NOHT:
3361 case NL80211_CHAN_WIDTH_20:
3367 /* changes into another band are not supported */
3368 if (sdata->u.ibss.chandef.chan->band !=
3369 params->chandef.chan->band)
3372 /* see comments in the NL80211_IFTYPE_AP block */
3373 if (params->count > 1) {
3374 err = ieee80211_ibss_csa_beacon(sdata, params);
3380 ieee80211_send_action_csa(sdata, params);
3383 #ifdef CONFIG_MAC80211_MESH
3384 case NL80211_IFTYPE_MESH_POINT: {
3385 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
3387 /* changes into another band are not supported */
3388 if (sdata->vif.bss_conf.chandef.chan->band !=
3389 params->chandef.chan->band)
3392 if (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_NONE) {
3393 ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_INIT;
3394 if (!ifmsh->pre_value)
3395 ifmsh->pre_value = 1;
3400 /* see comments in the NL80211_IFTYPE_AP block */
3401 if (params->count > 1) {
3402 err = ieee80211_mesh_csa_beacon(sdata, params);
3404 ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_NONE;
3410 if (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_INIT)
3411 ieee80211_send_action_csa(sdata, params);
3423 static void ieee80211_color_change_abort(struct ieee80211_sub_if_data *sdata)
3425 sdata->vif.color_change_active = false;
3426 kfree(sdata->u.ap.next_beacon);
3427 sdata->u.ap.next_beacon = NULL;
3429 cfg80211_color_change_aborted_notify(sdata->dev);
3433 __ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
3434 struct cfg80211_csa_settings *params)
3436 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3437 struct ieee80211_local *local = sdata->local;
3438 struct ieee80211_channel_switch ch_switch;
3439 struct ieee80211_chanctx_conf *conf;
3440 struct ieee80211_chanctx *chanctx;
3444 sdata_assert_lock(sdata);
3445 lockdep_assert_held(&local->mtx);
3447 if (!list_empty(&local->roc_list) || local->scanning)
3450 if (sdata->wdev.cac_started)
3453 if (cfg80211_chandef_identical(¶ms->chandef,
3454 &sdata->vif.bss_conf.chandef))
3457 /* don't allow another channel switch if one is already active. */
3458 if (sdata->vif.csa_active)
3461 mutex_lock(&local->chanctx_mtx);
3462 conf = rcu_dereference_protected(sdata->vif.chanctx_conf,
3463 lockdep_is_held(&local->chanctx_mtx));
3469 if (params->chandef.chan->freq_offset) {
3470 /* this may work, but is untested */
3475 chanctx = container_of(conf, struct ieee80211_chanctx, conf);
3477 ch_switch.timestamp = 0;
3478 ch_switch.device_timestamp = 0;
3479 ch_switch.block_tx = params->block_tx;
3480 ch_switch.chandef = params->chandef;
3481 ch_switch.count = params->count;
3483 err = drv_pre_channel_switch(sdata, &ch_switch);
3487 err = ieee80211_vif_reserve_chanctx(sdata, ¶ms->chandef,
3489 params->radar_required);
3493 /* if reservation is invalid then this will fail */
3494 err = ieee80211_check_combinations(sdata, NULL, chanctx->mode, 0);
3496 ieee80211_vif_unreserve_chanctx(sdata);
3500 /* if there is a color change in progress, abort it */
3501 if (sdata->vif.color_change_active)
3502 ieee80211_color_change_abort(sdata);
3504 err = ieee80211_set_csa_beacon(sdata, params, &changed);
3506 ieee80211_vif_unreserve_chanctx(sdata);
3510 sdata->csa_chandef = params->chandef;
3511 sdata->csa_block_tx = params->block_tx;
3512 sdata->vif.csa_active = true;
3514 if (sdata->csa_block_tx)
3515 ieee80211_stop_vif_queues(local, sdata,
3516 IEEE80211_QUEUE_STOP_REASON_CSA);
3518 cfg80211_ch_switch_started_notify(sdata->dev, &sdata->csa_chandef,
3519 params->count, params->block_tx);
3522 ieee80211_bss_info_change_notify(sdata, changed);
3523 drv_channel_switch_beacon(sdata, ¶ms->chandef);
3525 /* if the beacon didn't change, we can finalize immediately */
3526 ieee80211_csa_finalize(sdata);
3530 mutex_unlock(&local->chanctx_mtx);
3534 int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
3535 struct cfg80211_csa_settings *params)
3537 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3538 struct ieee80211_local *local = sdata->local;
3541 mutex_lock(&local->mtx);
3542 err = __ieee80211_channel_switch(wiphy, dev, params);
3543 mutex_unlock(&local->mtx);
3548 u64 ieee80211_mgmt_tx_cookie(struct ieee80211_local *local)
3550 lockdep_assert_held(&local->mtx);
3552 local->roc_cookie_counter++;
3554 /* wow, you wrapped 64 bits ... more likely a bug */
3555 if (WARN_ON(local->roc_cookie_counter == 0))
3556 local->roc_cookie_counter++;
3558 return local->roc_cookie_counter;
3561 int ieee80211_attach_ack_skb(struct ieee80211_local *local, struct sk_buff *skb,
3562 u64 *cookie, gfp_t gfp)
3564 unsigned long spin_flags;
3565 struct sk_buff *ack_skb;
3568 ack_skb = skb_copy(skb, gfp);
3572 spin_lock_irqsave(&local->ack_status_lock, spin_flags);
3573 id = idr_alloc(&local->ack_status_frames, ack_skb,
3574 1, 0x2000, GFP_ATOMIC);
3575 spin_unlock_irqrestore(&local->ack_status_lock, spin_flags);
3582 IEEE80211_SKB_CB(skb)->ack_frame_id = id;
3584 *cookie = ieee80211_mgmt_tx_cookie(local);
3585 IEEE80211_SKB_CB(ack_skb)->ack.cookie = *cookie;
3591 ieee80211_update_mgmt_frame_registrations(struct wiphy *wiphy,
3592 struct wireless_dev *wdev,
3593 struct mgmt_frame_regs *upd)
3595 struct ieee80211_local *local = wiphy_priv(wiphy);
3596 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
3597 u32 preq_mask = BIT(IEEE80211_STYPE_PROBE_REQ >> 4);
3598 u32 action_mask = BIT(IEEE80211_STYPE_ACTION >> 4);
3599 bool global_change, intf_change;
3602 (local->probe_req_reg != !!(upd->global_stypes & preq_mask)) ||
3603 (local->rx_mcast_action_reg !=
3604 !!(upd->global_mcast_stypes & action_mask));
3605 local->probe_req_reg = upd->global_stypes & preq_mask;
3606 local->rx_mcast_action_reg = upd->global_mcast_stypes & action_mask;
3608 intf_change = (sdata->vif.probe_req_reg !=
3609 !!(upd->interface_stypes & preq_mask)) ||
3610 (sdata->vif.rx_mcast_action_reg !=
3611 !!(upd->interface_mcast_stypes & action_mask));
3612 sdata->vif.probe_req_reg = upd->interface_stypes & preq_mask;
3613 sdata->vif.rx_mcast_action_reg =
3614 upd->interface_mcast_stypes & action_mask;
3616 if (!local->open_count)
3619 if (intf_change && ieee80211_sdata_running(sdata))
3620 drv_config_iface_filter(local, sdata,
3621 sdata->vif.probe_req_reg ?
3626 ieee80211_configure_filter(local);
3629 static int ieee80211_set_antenna(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant)
3631 struct ieee80211_local *local = wiphy_priv(wiphy);
3636 return drv_set_antenna(local, tx_ant, rx_ant);
3639 static int ieee80211_get_antenna(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant)
3641 struct ieee80211_local *local = wiphy_priv(wiphy);
3643 return drv_get_antenna(local, tx_ant, rx_ant);
3646 static int ieee80211_set_rekey_data(struct wiphy *wiphy,
3647 struct net_device *dev,
3648 struct cfg80211_gtk_rekey_data *data)
3650 struct ieee80211_local *local = wiphy_priv(wiphy);
3651 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3653 if (!local->ops->set_rekey_data)
3656 drv_set_rekey_data(local, sdata, data);
3661 static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev,
3662 const u8 *peer, u64 *cookie)
3664 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3665 struct ieee80211_local *local = sdata->local;
3666 struct ieee80211_qos_hdr *nullfunc;
3667 struct sk_buff *skb;
3668 int size = sizeof(*nullfunc);
3671 struct ieee80211_tx_info *info;
3672 struct sta_info *sta;
3673 struct ieee80211_chanctx_conf *chanctx_conf;
3674 enum nl80211_band band;
3677 /* the lock is needed to assign the cookie later */
3678 mutex_lock(&local->mtx);
3681 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
3682 if (WARN_ON(!chanctx_conf)) {
3686 band = chanctx_conf->def.chan->band;
3687 sta = sta_info_get_bss(sdata, peer);
3696 fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
3697 IEEE80211_STYPE_QOS_NULLFUNC |
3698 IEEE80211_FCTL_FROMDS);
3701 fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
3702 IEEE80211_STYPE_NULLFUNC |
3703 IEEE80211_FCTL_FROMDS);
3706 skb = dev_alloc_skb(local->hw.extra_tx_headroom + size);
3714 skb_reserve(skb, local->hw.extra_tx_headroom);
3716 nullfunc = skb_put(skb, size);
3717 nullfunc->frame_control = fc;
3718 nullfunc->duration_id = 0;
3719 memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN);
3720 memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN);
3721 memcpy(nullfunc->addr3, sdata->vif.addr, ETH_ALEN);
3722 nullfunc->seq_ctrl = 0;
3724 info = IEEE80211_SKB_CB(skb);
3726 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS |
3727 IEEE80211_TX_INTFL_NL80211_FRAME_TX;
3730 skb_set_queue_mapping(skb, IEEE80211_AC_VO);
3733 nullfunc->qos_ctrl = cpu_to_le16(7);
3735 ret = ieee80211_attach_ack_skb(local, skb, cookie, GFP_ATOMIC);
3742 ieee80211_xmit(sdata, sta, skb);
3748 mutex_unlock(&local->mtx);
3753 static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
3754 struct wireless_dev *wdev,
3755 struct cfg80211_chan_def *chandef)
3757 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
3758 struct ieee80211_local *local = wiphy_priv(wiphy);
3759 struct ieee80211_chanctx_conf *chanctx_conf;
3763 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
3765 *chandef = sdata->vif.bss_conf.chandef;
3767 } else if (local->open_count > 0 &&
3768 local->open_count == local->monitors &&
3769 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
3770 if (local->use_chanctx)
3771 *chandef = local->monitor_chandef;
3773 *chandef = local->_oper_chandef;
3782 static void ieee80211_set_wakeup(struct wiphy *wiphy, bool enabled)
3784 drv_set_wakeup(wiphy_priv(wiphy), enabled);
3788 static int ieee80211_set_qos_map(struct wiphy *wiphy,
3789 struct net_device *dev,
3790 struct cfg80211_qos_map *qos_map)
3792 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3793 struct mac80211_qos_map *new_qos_map, *old_qos_map;
3796 new_qos_map = kzalloc(sizeof(*new_qos_map), GFP_KERNEL);
3799 memcpy(&new_qos_map->qos_map, qos_map, sizeof(*qos_map));
3801 /* A NULL qos_map was passed to disable QoS mapping */
3805 old_qos_map = sdata_dereference(sdata->qos_map, sdata);
3806 rcu_assign_pointer(sdata->qos_map, new_qos_map);
3808 kfree_rcu(old_qos_map, rcu_head);
3813 static int ieee80211_set_ap_chanwidth(struct wiphy *wiphy,
3814 struct net_device *dev,
3815 struct cfg80211_chan_def *chandef)
3817 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3821 ret = ieee80211_vif_change_bandwidth(sdata, chandef, &changed);
3823 ieee80211_bss_info_change_notify(sdata, changed);
3828 static int ieee80211_add_tx_ts(struct wiphy *wiphy, struct net_device *dev,
3829 u8 tsid, const u8 *peer, u8 up,
3832 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3833 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
3834 int ac = ieee802_1d_to_ac[up];
3836 if (sdata->vif.type != NL80211_IFTYPE_STATION)
3839 if (!(sdata->wmm_acm & BIT(up)))
3842 if (ifmgd->tx_tspec[ac].admitted_time)
3845 if (admitted_time) {
3846 ifmgd->tx_tspec[ac].admitted_time = 32 * admitted_time;
3847 ifmgd->tx_tspec[ac].tsid = tsid;
3848 ifmgd->tx_tspec[ac].up = up;
3854 static int ieee80211_del_tx_ts(struct wiphy *wiphy, struct net_device *dev,
3855 u8 tsid, const u8 *peer)
3857 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3858 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
3859 struct ieee80211_local *local = wiphy_priv(wiphy);
3862 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
3863 struct ieee80211_sta_tx_tspec *tx_tspec = &ifmgd->tx_tspec[ac];
3865 /* skip unused entries */
3866 if (!tx_tspec->admitted_time)
3869 if (tx_tspec->tsid != tsid)
3872 /* due to this new packets will be reassigned to non-ACM ACs */
3875 /* Make sure that all packets have been sent to avoid to
3876 * restore the QoS params on packets that are still on the
3880 ieee80211_flush_queues(local, sdata, false);
3882 /* restore the normal QoS parameters
3883 * (unconditionally to avoid races)
3885 tx_tspec->action = TX_TSPEC_ACTION_STOP_DOWNGRADE;
3886 tx_tspec->downgraded = false;
3887 ieee80211_sta_handle_tspec_ac_params(sdata);
3889 /* finally clear all the data */
3890 memset(tx_tspec, 0, sizeof(*tx_tspec));
3898 void ieee80211_nan_func_terminated(struct ieee80211_vif *vif,
3900 enum nl80211_nan_func_term_reason reason,
3903 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
3904 struct cfg80211_nan_func *func;
3907 if (WARN_ON(vif->type != NL80211_IFTYPE_NAN))
3910 spin_lock_bh(&sdata->u.nan.func_lock);
3912 func = idr_find(&sdata->u.nan.function_inst_ids, inst_id);
3913 if (WARN_ON(!func)) {
3914 spin_unlock_bh(&sdata->u.nan.func_lock);
3918 cookie = func->cookie;
3919 idr_remove(&sdata->u.nan.function_inst_ids, inst_id);
3921 spin_unlock_bh(&sdata->u.nan.func_lock);
3923 cfg80211_free_nan_func(func);
3925 cfg80211_nan_func_terminated(ieee80211_vif_to_wdev(vif), inst_id,
3926 reason, cookie, gfp);
3928 EXPORT_SYMBOL(ieee80211_nan_func_terminated);
3930 void ieee80211_nan_func_match(struct ieee80211_vif *vif,
3931 struct cfg80211_nan_match_params *match,
3934 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
3935 struct cfg80211_nan_func *func;
3937 if (WARN_ON(vif->type != NL80211_IFTYPE_NAN))
3940 spin_lock_bh(&sdata->u.nan.func_lock);
3942 func = idr_find(&sdata->u.nan.function_inst_ids, match->inst_id);
3943 if (WARN_ON(!func)) {
3944 spin_unlock_bh(&sdata->u.nan.func_lock);
3947 match->cookie = func->cookie;
3949 spin_unlock_bh(&sdata->u.nan.func_lock);
3951 cfg80211_nan_match(ieee80211_vif_to_wdev(vif), match, gfp);
3953 EXPORT_SYMBOL(ieee80211_nan_func_match);
3955 static int ieee80211_set_multicast_to_unicast(struct wiphy *wiphy,
3956 struct net_device *dev,
3959 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3961 sdata->u.ap.multicast_to_unicast = enabled;
3966 void ieee80211_fill_txq_stats(struct cfg80211_txq_stats *txqstats,
3967 struct txq_info *txqi)
3969 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_BACKLOG_BYTES))) {
3970 txqstats->filled |= BIT(NL80211_TXQ_STATS_BACKLOG_BYTES);
3971 txqstats->backlog_bytes = txqi->tin.backlog_bytes;
3974 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_BACKLOG_PACKETS))) {
3975 txqstats->filled |= BIT(NL80211_TXQ_STATS_BACKLOG_PACKETS);
3976 txqstats->backlog_packets = txqi->tin.backlog_packets;
3979 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_FLOWS))) {
3980 txqstats->filled |= BIT(NL80211_TXQ_STATS_FLOWS);
3981 txqstats->flows = txqi->tin.flows;
3984 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_DROPS))) {
3985 txqstats->filled |= BIT(NL80211_TXQ_STATS_DROPS);
3986 txqstats->drops = txqi->cstats.drop_count;
3989 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_ECN_MARKS))) {
3990 txqstats->filled |= BIT(NL80211_TXQ_STATS_ECN_MARKS);
3991 txqstats->ecn_marks = txqi->cstats.ecn_mark;
3994 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_OVERLIMIT))) {
3995 txqstats->filled |= BIT(NL80211_TXQ_STATS_OVERLIMIT);
3996 txqstats->overlimit = txqi->tin.overlimit;
3999 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_COLLISIONS))) {
4000 txqstats->filled |= BIT(NL80211_TXQ_STATS_COLLISIONS);
4001 txqstats->collisions = txqi->tin.collisions;
4004 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_TX_BYTES))) {
4005 txqstats->filled |= BIT(NL80211_TXQ_STATS_TX_BYTES);
4006 txqstats->tx_bytes = txqi->tin.tx_bytes;
4009 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_TX_PACKETS))) {
4010 txqstats->filled |= BIT(NL80211_TXQ_STATS_TX_PACKETS);
4011 txqstats->tx_packets = txqi->tin.tx_packets;
4015 static int ieee80211_get_txq_stats(struct wiphy *wiphy,
4016 struct wireless_dev *wdev,
4017 struct cfg80211_txq_stats *txqstats)
4019 struct ieee80211_local *local = wiphy_priv(wiphy);
4020 struct ieee80211_sub_if_data *sdata;
4023 if (!local->ops->wake_tx_queue)
4026 spin_lock_bh(&local->fq.lock);
4030 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
4031 if (!sdata->vif.txq) {
4035 ieee80211_fill_txq_stats(txqstats, to_txq_info(sdata->vif.txq));
4038 txqstats->filled |= BIT(NL80211_TXQ_STATS_BACKLOG_PACKETS) |
4039 BIT(NL80211_TXQ_STATS_BACKLOG_BYTES) |
4040 BIT(NL80211_TXQ_STATS_OVERLIMIT) |
4041 BIT(NL80211_TXQ_STATS_OVERMEMORY) |
4042 BIT(NL80211_TXQ_STATS_COLLISIONS) |
4043 BIT(NL80211_TXQ_STATS_MAX_FLOWS);
4044 txqstats->backlog_packets = local->fq.backlog;
4045 txqstats->backlog_bytes = local->fq.memory_usage;
4046 txqstats->overlimit = local->fq.overlimit;
4047 txqstats->overmemory = local->fq.overmemory;
4048 txqstats->collisions = local->fq.collisions;
4049 txqstats->max_flows = local->fq.flows_cnt;
4054 spin_unlock_bh(&local->fq.lock);
4060 ieee80211_get_ftm_responder_stats(struct wiphy *wiphy,
4061 struct net_device *dev,
4062 struct cfg80211_ftm_responder_stats *ftm_stats)
4064 struct ieee80211_local *local = wiphy_priv(wiphy);
4065 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4067 return drv_get_ftm_responder_stats(local, sdata, ftm_stats);
4071 ieee80211_start_pmsr(struct wiphy *wiphy, struct wireless_dev *dev,
4072 struct cfg80211_pmsr_request *request)
4074 struct ieee80211_local *local = wiphy_priv(wiphy);
4075 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(dev);
4077 return drv_start_pmsr(local, sdata, request);
4081 ieee80211_abort_pmsr(struct wiphy *wiphy, struct wireless_dev *dev,
4082 struct cfg80211_pmsr_request *request)
4084 struct ieee80211_local *local = wiphy_priv(wiphy);
4085 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(dev);
4087 return drv_abort_pmsr(local, sdata, request);
4090 static int ieee80211_set_tid_config(struct wiphy *wiphy,
4091 struct net_device *dev,
4092 struct cfg80211_tid_config *tid_conf)
4094 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4095 struct sta_info *sta;
4098 if (!sdata->local->ops->set_tid_config)
4101 if (!tid_conf->peer)
4102 return drv_set_tid_config(sdata->local, sdata, NULL, tid_conf);
4104 mutex_lock(&sdata->local->sta_mtx);
4105 sta = sta_info_get_bss(sdata, tid_conf->peer);
4107 mutex_unlock(&sdata->local->sta_mtx);
4111 ret = drv_set_tid_config(sdata->local, sdata, &sta->sta, tid_conf);
4112 mutex_unlock(&sdata->local->sta_mtx);
4117 static int ieee80211_reset_tid_config(struct wiphy *wiphy,
4118 struct net_device *dev,
4119 const u8 *peer, u8 tids)
4121 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4122 struct sta_info *sta;
4125 if (!sdata->local->ops->reset_tid_config)
4129 return drv_reset_tid_config(sdata->local, sdata, NULL, tids);
4131 mutex_lock(&sdata->local->sta_mtx);
4132 sta = sta_info_get_bss(sdata, peer);
4134 mutex_unlock(&sdata->local->sta_mtx);
4138 ret = drv_reset_tid_config(sdata->local, sdata, &sta->sta, tids);
4139 mutex_unlock(&sdata->local->sta_mtx);
4144 static int ieee80211_set_sar_specs(struct wiphy *wiphy,
4145 struct cfg80211_sar_specs *sar)
4147 struct ieee80211_local *local = wiphy_priv(wiphy);
4149 if (!local->ops->set_sar_specs)
4152 return local->ops->set_sar_specs(&local->hw, sar);
4156 ieee80211_set_after_color_change_beacon(struct ieee80211_sub_if_data *sdata,
4159 switch (sdata->vif.type) {
4160 case NL80211_IFTYPE_AP: {
4163 ret = ieee80211_assign_beacon(sdata, sdata->u.ap.next_beacon,
4165 kfree(sdata->u.ap.next_beacon);
4166 sdata->u.ap.next_beacon = NULL;
4183 ieee80211_set_color_change_beacon(struct ieee80211_sub_if_data *sdata,
4184 struct cfg80211_color_change_settings *params,
4187 struct ieee80211_color_change_settings color_change = {};
4190 switch (sdata->vif.type) {
4191 case NL80211_IFTYPE_AP:
4192 sdata->u.ap.next_beacon =
4193 cfg80211_beacon_dup(¶ms->beacon_next);
4194 if (!sdata->u.ap.next_beacon)
4197 if (params->count <= 1)
4200 color_change.counter_offset_beacon =
4201 params->counter_offset_beacon;
4202 color_change.counter_offset_presp =
4203 params->counter_offset_presp;
4204 color_change.count = params->count;
4206 err = ieee80211_assign_beacon(sdata, ¶ms->beacon_color_change,
4207 NULL, &color_change);
4209 kfree(sdata->u.ap.next_beacon);
4222 ieee80211_color_change_bss_config_notify(struct ieee80211_sub_if_data *sdata,
4223 u8 color, int enable, u32 changed)
4225 sdata->vif.bss_conf.he_bss_color.color = color;
4226 sdata->vif.bss_conf.he_bss_color.enabled = enable;
4227 changed |= BSS_CHANGED_HE_BSS_COLOR;
4229 ieee80211_bss_info_change_notify(sdata, changed);
4232 static int ieee80211_color_change_finalize(struct ieee80211_sub_if_data *sdata)
4234 struct ieee80211_local *local = sdata->local;
4238 sdata_assert_lock(sdata);
4239 lockdep_assert_held(&local->mtx);
4241 sdata->vif.color_change_active = false;
4243 err = ieee80211_set_after_color_change_beacon(sdata, &changed);
4245 cfg80211_color_change_aborted_notify(sdata->dev);
4249 ieee80211_color_change_bss_config_notify(sdata,
4250 sdata->vif.color_change_color,
4252 cfg80211_color_change_notify(sdata->dev);
4257 void ieee80211_color_change_finalize_work(struct work_struct *work)
4259 struct ieee80211_sub_if_data *sdata =
4260 container_of(work, struct ieee80211_sub_if_data,
4261 color_change_finalize_work);
4262 struct ieee80211_local *local = sdata->local;
4265 mutex_lock(&local->mtx);
4267 /* AP might have been stopped while waiting for the lock. */
4268 if (!sdata->vif.color_change_active)
4271 if (!ieee80211_sdata_running(sdata))
4274 ieee80211_color_change_finalize(sdata);
4277 mutex_unlock(&local->mtx);
4278 sdata_unlock(sdata);
4281 void ieee80211_color_change_finish(struct ieee80211_vif *vif)
4283 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
4285 ieee80211_queue_work(&sdata->local->hw,
4286 &sdata->color_change_finalize_work);
4288 EXPORT_SYMBOL_GPL(ieee80211_color_change_finish);
4291 ieeee80211_obss_color_collision_notify(struct ieee80211_vif *vif,
4294 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
4296 if (sdata->vif.color_change_active || sdata->vif.csa_active)
4299 cfg80211_obss_color_collision_notify(sdata->dev, color_bitmap);
4301 EXPORT_SYMBOL_GPL(ieeee80211_obss_color_collision_notify);
4304 ieee80211_color_change(struct wiphy *wiphy, struct net_device *dev,
4305 struct cfg80211_color_change_settings *params)
4307 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4308 struct ieee80211_local *local = sdata->local;
4312 sdata_assert_lock(sdata);
4314 mutex_lock(&local->mtx);
4316 /* don't allow another color change if one is already active or if csa
4319 if (sdata->vif.color_change_active || sdata->vif.csa_active) {
4324 err = ieee80211_set_color_change_beacon(sdata, params, &changed);
4328 sdata->vif.color_change_active = true;
4329 sdata->vif.color_change_color = params->color;
4331 cfg80211_color_change_started_notify(sdata->dev, params->count);
4334 ieee80211_color_change_bss_config_notify(sdata, 0, 0, changed);
4336 /* if the beacon didn't change, we can finalize immediately */
4337 ieee80211_color_change_finalize(sdata);
4340 mutex_unlock(&local->mtx);
4345 const struct cfg80211_ops mac80211_config_ops = {
4346 .add_virtual_intf = ieee80211_add_iface,
4347 .del_virtual_intf = ieee80211_del_iface,
4348 .change_virtual_intf = ieee80211_change_iface,
4349 .start_p2p_device = ieee80211_start_p2p_device,
4350 .stop_p2p_device = ieee80211_stop_p2p_device,
4351 .add_key = ieee80211_add_key,
4352 .del_key = ieee80211_del_key,
4353 .get_key = ieee80211_get_key,
4354 .set_default_key = ieee80211_config_default_key,
4355 .set_default_mgmt_key = ieee80211_config_default_mgmt_key,
4356 .set_default_beacon_key = ieee80211_config_default_beacon_key,
4357 .start_ap = ieee80211_start_ap,
4358 .change_beacon = ieee80211_change_beacon,
4359 .stop_ap = ieee80211_stop_ap,
4360 .add_station = ieee80211_add_station,
4361 .del_station = ieee80211_del_station,
4362 .change_station = ieee80211_change_station,
4363 .get_station = ieee80211_get_station,
4364 .dump_station = ieee80211_dump_station,
4365 .dump_survey = ieee80211_dump_survey,
4366 #ifdef CONFIG_MAC80211_MESH
4367 .add_mpath = ieee80211_add_mpath,
4368 .del_mpath = ieee80211_del_mpath,
4369 .change_mpath = ieee80211_change_mpath,
4370 .get_mpath = ieee80211_get_mpath,
4371 .dump_mpath = ieee80211_dump_mpath,
4372 .get_mpp = ieee80211_get_mpp,
4373 .dump_mpp = ieee80211_dump_mpp,
4374 .update_mesh_config = ieee80211_update_mesh_config,
4375 .get_mesh_config = ieee80211_get_mesh_config,
4376 .join_mesh = ieee80211_join_mesh,
4377 .leave_mesh = ieee80211_leave_mesh,
4379 .join_ocb = ieee80211_join_ocb,
4380 .leave_ocb = ieee80211_leave_ocb,
4381 .change_bss = ieee80211_change_bss,
4382 .set_txq_params = ieee80211_set_txq_params,
4383 .set_monitor_channel = ieee80211_set_monitor_channel,
4384 .suspend = ieee80211_suspend,
4385 .resume = ieee80211_resume,
4386 .scan = ieee80211_scan,
4387 .abort_scan = ieee80211_abort_scan,
4388 .sched_scan_start = ieee80211_sched_scan_start,
4389 .sched_scan_stop = ieee80211_sched_scan_stop,
4390 .auth = ieee80211_auth,
4391 .assoc = ieee80211_assoc,
4392 .deauth = ieee80211_deauth,
4393 .disassoc = ieee80211_disassoc,
4394 .join_ibss = ieee80211_join_ibss,
4395 .leave_ibss = ieee80211_leave_ibss,
4396 .set_mcast_rate = ieee80211_set_mcast_rate,
4397 .set_wiphy_params = ieee80211_set_wiphy_params,
4398 .set_tx_power = ieee80211_set_tx_power,
4399 .get_tx_power = ieee80211_get_tx_power,
4400 .rfkill_poll = ieee80211_rfkill_poll,
4401 CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd)
4402 CFG80211_TESTMODE_DUMP(ieee80211_testmode_dump)
4403 .set_power_mgmt = ieee80211_set_power_mgmt,
4404 .set_bitrate_mask = ieee80211_set_bitrate_mask,
4405 .remain_on_channel = ieee80211_remain_on_channel,
4406 .cancel_remain_on_channel = ieee80211_cancel_remain_on_channel,
4407 .mgmt_tx = ieee80211_mgmt_tx,
4408 .mgmt_tx_cancel_wait = ieee80211_mgmt_tx_cancel_wait,
4409 .set_cqm_rssi_config = ieee80211_set_cqm_rssi_config,
4410 .set_cqm_rssi_range_config = ieee80211_set_cqm_rssi_range_config,
4411 .update_mgmt_frame_registrations =
4412 ieee80211_update_mgmt_frame_registrations,
4413 .set_antenna = ieee80211_set_antenna,
4414 .get_antenna = ieee80211_get_antenna,
4415 .set_rekey_data = ieee80211_set_rekey_data,
4416 .tdls_oper = ieee80211_tdls_oper,
4417 .tdls_mgmt = ieee80211_tdls_mgmt,
4418 .tdls_channel_switch = ieee80211_tdls_channel_switch,
4419 .tdls_cancel_channel_switch = ieee80211_tdls_cancel_channel_switch,
4420 .probe_client = ieee80211_probe_client,
4421 .set_noack_map = ieee80211_set_noack_map,
4423 .set_wakeup = ieee80211_set_wakeup,
4425 .get_channel = ieee80211_cfg_get_channel,
4426 .start_radar_detection = ieee80211_start_radar_detection,
4427 .end_cac = ieee80211_end_cac,
4428 .channel_switch = ieee80211_channel_switch,
4429 .set_qos_map = ieee80211_set_qos_map,
4430 .set_ap_chanwidth = ieee80211_set_ap_chanwidth,
4431 .add_tx_ts = ieee80211_add_tx_ts,
4432 .del_tx_ts = ieee80211_del_tx_ts,
4433 .start_nan = ieee80211_start_nan,
4434 .stop_nan = ieee80211_stop_nan,
4435 .nan_change_conf = ieee80211_nan_change_conf,
4436 .add_nan_func = ieee80211_add_nan_func,
4437 .del_nan_func = ieee80211_del_nan_func,
4438 .set_multicast_to_unicast = ieee80211_set_multicast_to_unicast,
4439 .tx_control_port = ieee80211_tx_control_port,
4440 .get_txq_stats = ieee80211_get_txq_stats,
4441 .get_ftm_responder_stats = ieee80211_get_ftm_responder_stats,
4442 .start_pmsr = ieee80211_start_pmsr,
4443 .abort_pmsr = ieee80211_abort_pmsr,
4444 .probe_mesh_link = ieee80211_probe_mesh_link,
4445 .set_tid_config = ieee80211_set_tid_config,
4446 .reset_tid_config = ieee80211_reset_tid_config,
4447 .set_sar_specs = ieee80211_set_sar_specs,
4448 .color_change = ieee80211_color_change,