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 int ieee80211_set_ap_mbssid_options(struct ieee80211_sub_if_data *sdata,
116 struct cfg80211_mbssid_config params)
118 struct ieee80211_sub_if_data *tx_sdata;
120 sdata->vif.mbssid_tx_vif = NULL;
121 sdata->vif.bss_conf.bssid_index = 0;
122 sdata->vif.bss_conf.nontransmitted = false;
123 sdata->vif.bss_conf.ema_ap = false;
125 if (sdata->vif.type != NL80211_IFTYPE_AP || !params.tx_wdev)
128 tx_sdata = IEEE80211_WDEV_TO_SUB_IF(params.tx_wdev);
132 if (tx_sdata == sdata) {
133 sdata->vif.mbssid_tx_vif = &sdata->vif;
135 sdata->vif.mbssid_tx_vif = &tx_sdata->vif;
136 sdata->vif.bss_conf.nontransmitted = true;
137 sdata->vif.bss_conf.bssid_index = params.index;
140 sdata->vif.bss_conf.ema_ap = true;
145 static struct wireless_dev *ieee80211_add_iface(struct wiphy *wiphy,
147 unsigned char name_assign_type,
148 enum nl80211_iftype type,
149 struct vif_params *params)
151 struct ieee80211_local *local = wiphy_priv(wiphy);
152 struct wireless_dev *wdev;
153 struct ieee80211_sub_if_data *sdata;
156 err = ieee80211_if_add(local, name, name_assign_type, &wdev, type, params);
160 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
162 if (type == NL80211_IFTYPE_MONITOR) {
163 err = ieee80211_set_mon_options(sdata, params);
165 ieee80211_if_remove(sdata);
173 static int ieee80211_del_iface(struct wiphy *wiphy, struct wireless_dev *wdev)
175 ieee80211_if_remove(IEEE80211_WDEV_TO_SUB_IF(wdev));
180 static int ieee80211_change_iface(struct wiphy *wiphy,
181 struct net_device *dev,
182 enum nl80211_iftype type,
183 struct vif_params *params)
185 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
186 struct ieee80211_local *local = sdata->local;
187 struct sta_info *sta;
190 ret = ieee80211_if_change_type(sdata, type);
194 if (type == NL80211_IFTYPE_AP_VLAN && params->use_4addr == 0) {
195 RCU_INIT_POINTER(sdata->u.vlan.sta, NULL);
196 ieee80211_check_fast_rx_iface(sdata);
197 } else if (type == NL80211_IFTYPE_STATION && params->use_4addr >= 0) {
198 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
200 if (params->use_4addr == ifmgd->use_4addr)
203 sdata->u.mgd.use_4addr = params->use_4addr;
204 if (!ifmgd->associated)
207 mutex_lock(&local->sta_mtx);
208 sta = sta_info_get(sdata, ifmgd->bssid);
210 drv_sta_set_4addr(local, sdata, &sta->sta,
212 mutex_unlock(&local->sta_mtx);
214 if (params->use_4addr)
215 ieee80211_send_4addr_nullfunc(local, sdata);
218 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) {
219 ret = ieee80211_set_mon_options(sdata, params);
227 static int ieee80211_start_p2p_device(struct wiphy *wiphy,
228 struct wireless_dev *wdev)
230 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
233 mutex_lock(&sdata->local->chanctx_mtx);
234 ret = ieee80211_check_combinations(sdata, NULL, 0, 0);
235 mutex_unlock(&sdata->local->chanctx_mtx);
239 return ieee80211_do_open(wdev, true);
242 static void ieee80211_stop_p2p_device(struct wiphy *wiphy,
243 struct wireless_dev *wdev)
245 ieee80211_sdata_stop(IEEE80211_WDEV_TO_SUB_IF(wdev));
248 static int ieee80211_start_nan(struct wiphy *wiphy,
249 struct wireless_dev *wdev,
250 struct cfg80211_nan_conf *conf)
252 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
255 mutex_lock(&sdata->local->chanctx_mtx);
256 ret = ieee80211_check_combinations(sdata, NULL, 0, 0);
257 mutex_unlock(&sdata->local->chanctx_mtx);
261 ret = ieee80211_do_open(wdev, true);
265 ret = drv_start_nan(sdata->local, sdata, conf);
267 ieee80211_sdata_stop(sdata);
269 sdata->u.nan.conf = *conf;
274 static void ieee80211_stop_nan(struct wiphy *wiphy,
275 struct wireless_dev *wdev)
277 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
279 drv_stop_nan(sdata->local, sdata);
280 ieee80211_sdata_stop(sdata);
283 static int ieee80211_nan_change_conf(struct wiphy *wiphy,
284 struct wireless_dev *wdev,
285 struct cfg80211_nan_conf *conf,
288 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
289 struct cfg80211_nan_conf new_conf;
292 if (sdata->vif.type != NL80211_IFTYPE_NAN)
295 if (!ieee80211_sdata_running(sdata))
298 new_conf = sdata->u.nan.conf;
300 if (changes & CFG80211_NAN_CONF_CHANGED_PREF)
301 new_conf.master_pref = conf->master_pref;
303 if (changes & CFG80211_NAN_CONF_CHANGED_BANDS)
304 new_conf.bands = conf->bands;
306 ret = drv_nan_change_conf(sdata->local, sdata, &new_conf, changes);
308 sdata->u.nan.conf = new_conf;
313 static int ieee80211_add_nan_func(struct wiphy *wiphy,
314 struct wireless_dev *wdev,
315 struct cfg80211_nan_func *nan_func)
317 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
320 if (sdata->vif.type != NL80211_IFTYPE_NAN)
323 if (!ieee80211_sdata_running(sdata))
326 spin_lock_bh(&sdata->u.nan.func_lock);
328 ret = idr_alloc(&sdata->u.nan.function_inst_ids,
329 nan_func, 1, sdata->local->hw.max_nan_de_entries + 1,
331 spin_unlock_bh(&sdata->u.nan.func_lock);
336 nan_func->instance_id = ret;
338 WARN_ON(nan_func->instance_id == 0);
340 ret = drv_add_nan_func(sdata->local, sdata, nan_func);
342 spin_lock_bh(&sdata->u.nan.func_lock);
343 idr_remove(&sdata->u.nan.function_inst_ids,
344 nan_func->instance_id);
345 spin_unlock_bh(&sdata->u.nan.func_lock);
351 static struct cfg80211_nan_func *
352 ieee80211_find_nan_func_by_cookie(struct ieee80211_sub_if_data *sdata,
355 struct cfg80211_nan_func *func;
358 lockdep_assert_held(&sdata->u.nan.func_lock);
360 idr_for_each_entry(&sdata->u.nan.function_inst_ids, func, id) {
361 if (func->cookie == cookie)
368 static void ieee80211_del_nan_func(struct wiphy *wiphy,
369 struct wireless_dev *wdev, u64 cookie)
371 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
372 struct cfg80211_nan_func *func;
375 if (sdata->vif.type != NL80211_IFTYPE_NAN ||
376 !ieee80211_sdata_running(sdata))
379 spin_lock_bh(&sdata->u.nan.func_lock);
381 func = ieee80211_find_nan_func_by_cookie(sdata, cookie);
383 instance_id = func->instance_id;
385 spin_unlock_bh(&sdata->u.nan.func_lock);
388 drv_del_nan_func(sdata->local, sdata, instance_id);
391 static int ieee80211_set_noack_map(struct wiphy *wiphy,
392 struct net_device *dev,
395 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
397 sdata->noack_map = noack_map;
399 ieee80211_check_fast_xmit_iface(sdata);
404 static int ieee80211_set_tx(struct ieee80211_sub_if_data *sdata,
405 const u8 *mac_addr, u8 key_idx)
407 struct ieee80211_local *local = sdata->local;
408 struct ieee80211_key *key;
409 struct sta_info *sta;
412 if (!wiphy_ext_feature_isset(local->hw.wiphy,
413 NL80211_EXT_FEATURE_EXT_KEY_ID))
416 sta = sta_info_get_bss(sdata, mac_addr);
421 if (sta->ptk_idx == key_idx)
424 mutex_lock(&local->key_mtx);
425 key = key_mtx_dereference(local, sta->ptk[key_idx]);
427 if (key && key->conf.flags & IEEE80211_KEY_FLAG_NO_AUTO_TX)
428 ret = ieee80211_set_tx_key(key);
430 mutex_unlock(&local->key_mtx);
434 static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
435 u8 key_idx, bool pairwise, const u8 *mac_addr,
436 struct key_params *params)
438 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
439 struct ieee80211_local *local = sdata->local;
440 struct sta_info *sta = NULL;
441 const struct ieee80211_cipher_scheme *cs = NULL;
442 struct ieee80211_key *key;
445 if (!ieee80211_sdata_running(sdata))
448 if (pairwise && params->mode == NL80211_KEY_SET_TX)
449 return ieee80211_set_tx(sdata, mac_addr, key_idx);
451 /* reject WEP and TKIP keys if WEP failed to initialize */
452 switch (params->cipher) {
453 case WLAN_CIPHER_SUITE_WEP40:
454 case WLAN_CIPHER_SUITE_TKIP:
455 case WLAN_CIPHER_SUITE_WEP104:
456 if (WARN_ON_ONCE(fips_enabled))
459 case WLAN_CIPHER_SUITE_CCMP:
460 case WLAN_CIPHER_SUITE_CCMP_256:
461 case WLAN_CIPHER_SUITE_AES_CMAC:
462 case WLAN_CIPHER_SUITE_BIP_CMAC_256:
463 case WLAN_CIPHER_SUITE_BIP_GMAC_128:
464 case WLAN_CIPHER_SUITE_BIP_GMAC_256:
465 case WLAN_CIPHER_SUITE_GCMP:
466 case WLAN_CIPHER_SUITE_GCMP_256:
469 cs = ieee80211_cs_get(local, params->cipher, sdata->vif.type);
473 key = ieee80211_key_alloc(params->cipher, key_idx, params->key_len,
474 params->key, params->seq_len, params->seq,
480 key->conf.flags |= IEEE80211_KEY_FLAG_PAIRWISE;
482 if (params->mode == NL80211_KEY_NO_TX)
483 key->conf.flags |= IEEE80211_KEY_FLAG_NO_AUTO_TX;
485 mutex_lock(&local->sta_mtx);
488 sta = sta_info_get_bss(sdata, mac_addr);
490 * The ASSOC test makes sure the driver is ready to
491 * receive the key. When wpa_supplicant has roamed
492 * using FT, it attempts to set the key before
493 * association has completed, this rejects that attempt
494 * so it will set the key again after association.
496 * TODO: accept the key if we have a station entry and
497 * add it to the device after the station.
499 if (!sta || !test_sta_flag(sta, WLAN_STA_ASSOC)) {
500 ieee80211_key_free_unused(key);
506 switch (sdata->vif.type) {
507 case NL80211_IFTYPE_STATION:
508 if (sdata->u.mgd.mfp != IEEE80211_MFP_DISABLED)
509 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
511 case NL80211_IFTYPE_AP:
512 case NL80211_IFTYPE_AP_VLAN:
513 /* Keys without a station are used for TX only */
514 if (sta && test_sta_flag(sta, WLAN_STA_MFP))
515 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
517 case NL80211_IFTYPE_ADHOC:
520 case NL80211_IFTYPE_MESH_POINT:
521 #ifdef CONFIG_MAC80211_MESH
522 if (sdata->u.mesh.security != IEEE80211_MESH_SEC_NONE)
523 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
526 case NL80211_IFTYPE_WDS:
527 case NL80211_IFTYPE_MONITOR:
528 case NL80211_IFTYPE_P2P_DEVICE:
529 case NL80211_IFTYPE_NAN:
530 case NL80211_IFTYPE_UNSPECIFIED:
531 case NUM_NL80211_IFTYPES:
532 case NL80211_IFTYPE_P2P_CLIENT:
533 case NL80211_IFTYPE_P2P_GO:
534 case NL80211_IFTYPE_OCB:
535 /* shouldn't happen */
541 sta->cipher_scheme = cs;
543 err = ieee80211_key_link(key, sdata, sta);
546 mutex_unlock(&local->sta_mtx);
551 static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
552 u8 key_idx, bool pairwise, const u8 *mac_addr)
554 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
555 struct ieee80211_local *local = sdata->local;
556 struct sta_info *sta;
557 struct ieee80211_key *key = NULL;
560 mutex_lock(&local->sta_mtx);
561 mutex_lock(&local->key_mtx);
566 sta = sta_info_get_bss(sdata, mac_addr);
571 key = key_mtx_dereference(local, sta->ptk[key_idx]);
573 key = key_mtx_dereference(local, sta->gtk[key_idx]);
575 key = key_mtx_dereference(local, sdata->keys[key_idx]);
582 ieee80211_key_free(key, sdata->vif.type == NL80211_IFTYPE_STATION);
586 mutex_unlock(&local->key_mtx);
587 mutex_unlock(&local->sta_mtx);
592 static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
593 u8 key_idx, bool pairwise, const u8 *mac_addr,
595 void (*callback)(void *cookie,
596 struct key_params *params))
598 struct ieee80211_sub_if_data *sdata;
599 struct sta_info *sta = NULL;
601 struct key_params params;
602 struct ieee80211_key *key = NULL;
607 struct ieee80211_key_seq kseq = {};
609 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
614 sta = sta_info_get_bss(sdata, mac_addr);
618 if (pairwise && key_idx < NUM_DEFAULT_KEYS)
619 key = rcu_dereference(sta->ptk[key_idx]);
620 else if (!pairwise &&
621 key_idx < NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS +
622 NUM_DEFAULT_BEACON_KEYS)
623 key = rcu_dereference(sta->gtk[key_idx]);
625 key = rcu_dereference(sdata->keys[key_idx]);
630 memset(¶ms, 0, sizeof(params));
632 params.cipher = key->conf.cipher;
634 switch (key->conf.cipher) {
635 case WLAN_CIPHER_SUITE_TKIP:
636 pn64 = atomic64_read(&key->conf.tx_pn);
637 iv32 = TKIP_PN_TO_IV32(pn64);
638 iv16 = TKIP_PN_TO_IV16(pn64);
640 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE &&
641 !(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
642 drv_get_key_seq(sdata->local, key, &kseq);
643 iv32 = kseq.tkip.iv32;
644 iv16 = kseq.tkip.iv16;
647 seq[0] = iv16 & 0xff;
648 seq[1] = (iv16 >> 8) & 0xff;
649 seq[2] = iv32 & 0xff;
650 seq[3] = (iv32 >> 8) & 0xff;
651 seq[4] = (iv32 >> 16) & 0xff;
652 seq[5] = (iv32 >> 24) & 0xff;
656 case WLAN_CIPHER_SUITE_CCMP:
657 case WLAN_CIPHER_SUITE_CCMP_256:
658 case WLAN_CIPHER_SUITE_AES_CMAC:
659 case WLAN_CIPHER_SUITE_BIP_CMAC_256:
660 BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
661 offsetof(typeof(kseq), aes_cmac));
663 case WLAN_CIPHER_SUITE_BIP_GMAC_128:
664 case WLAN_CIPHER_SUITE_BIP_GMAC_256:
665 BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
666 offsetof(typeof(kseq), aes_gmac));
668 case WLAN_CIPHER_SUITE_GCMP:
669 case WLAN_CIPHER_SUITE_GCMP_256:
670 BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
671 offsetof(typeof(kseq), gcmp));
673 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE &&
674 !(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
675 drv_get_key_seq(sdata->local, key, &kseq);
676 memcpy(seq, kseq.ccmp.pn, 6);
678 pn64 = atomic64_read(&key->conf.tx_pn);
690 if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
692 if (WARN_ON(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV))
694 drv_get_key_seq(sdata->local, key, &kseq);
695 params.seq = kseq.hw.seq;
696 params.seq_len = kseq.hw.seq_len;
700 params.key = key->conf.key;
701 params.key_len = key->conf.keylen;
703 callback(cookie, ¶ms);
711 static int ieee80211_config_default_key(struct wiphy *wiphy,
712 struct net_device *dev,
713 u8 key_idx, bool uni,
716 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
718 ieee80211_set_default_key(sdata, key_idx, uni, multi);
723 static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy,
724 struct net_device *dev,
727 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
729 ieee80211_set_default_mgmt_key(sdata, key_idx);
734 static int ieee80211_config_default_beacon_key(struct wiphy *wiphy,
735 struct net_device *dev,
738 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
740 ieee80211_set_default_beacon_key(sdata, key_idx);
745 void sta_set_rate_info_tx(struct sta_info *sta,
746 const struct ieee80211_tx_rate *rate,
747 struct rate_info *rinfo)
750 if (rate->flags & IEEE80211_TX_RC_MCS) {
751 rinfo->flags |= RATE_INFO_FLAGS_MCS;
752 rinfo->mcs = rate->idx;
753 } else if (rate->flags & IEEE80211_TX_RC_VHT_MCS) {
754 rinfo->flags |= RATE_INFO_FLAGS_VHT_MCS;
755 rinfo->mcs = ieee80211_rate_get_vht_mcs(rate);
756 rinfo->nss = ieee80211_rate_get_vht_nss(rate);
758 struct ieee80211_supported_band *sband;
759 int shift = ieee80211_vif_get_shift(&sta->sdata->vif);
762 sband = ieee80211_get_sband(sta->sdata);
763 WARN_ON_ONCE(sband && !sband->bitrates);
764 if (sband && sband->bitrates) {
765 brate = sband->bitrates[rate->idx].bitrate;
766 rinfo->legacy = DIV_ROUND_UP(brate, 1 << shift);
769 if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
770 rinfo->bw = RATE_INFO_BW_40;
771 else if (rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH)
772 rinfo->bw = RATE_INFO_BW_80;
773 else if (rate->flags & IEEE80211_TX_RC_160_MHZ_WIDTH)
774 rinfo->bw = RATE_INFO_BW_160;
776 rinfo->bw = RATE_INFO_BW_20;
777 if (rate->flags & IEEE80211_TX_RC_SHORT_GI)
778 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI;
781 static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev,
782 int idx, 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_by_idx(sdata, idx);
794 memcpy(mac, sta->sta.addr, ETH_ALEN);
795 sta_set_sinfo(sta, sinfo, true);
798 mutex_unlock(&local->sta_mtx);
803 static int ieee80211_dump_survey(struct wiphy *wiphy, struct net_device *dev,
804 int idx, struct survey_info *survey)
806 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
808 return drv_get_survey(local, idx, survey);
811 static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev,
812 const u8 *mac, struct station_info *sinfo)
814 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
815 struct ieee80211_local *local = sdata->local;
816 struct sta_info *sta;
819 mutex_lock(&local->sta_mtx);
821 sta = sta_info_get_bss(sdata, mac);
824 sta_set_sinfo(sta, sinfo, true);
827 mutex_unlock(&local->sta_mtx);
832 static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
833 struct cfg80211_chan_def *chandef)
835 struct ieee80211_local *local = wiphy_priv(wiphy);
836 struct ieee80211_sub_if_data *sdata;
839 if (cfg80211_chandef_identical(&local->monitor_chandef, chandef))
842 mutex_lock(&local->mtx);
843 if (local->use_chanctx) {
844 sdata = wiphy_dereference(local->hw.wiphy,
845 local->monitor_sdata);
847 ieee80211_vif_release_channel(sdata);
848 ret = ieee80211_vif_use_channel(sdata, chandef,
849 IEEE80211_CHANCTX_EXCLUSIVE);
851 } else if (local->open_count == local->monitors) {
852 local->_oper_chandef = *chandef;
853 ieee80211_hw_config(local, 0);
857 local->monitor_chandef = *chandef;
858 mutex_unlock(&local->mtx);
864 ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata,
865 const u8 *resp, size_t resp_len,
866 const struct ieee80211_csa_settings *csa,
867 const struct ieee80211_color_change_settings *cca)
869 struct probe_resp *new, *old;
871 if (!resp || !resp_len)
874 old = sdata_dereference(sdata->u.ap.probe_resp, sdata);
876 new = kzalloc(sizeof(struct probe_resp) + resp_len, GFP_KERNEL);
881 memcpy(new->data, resp, resp_len);
884 memcpy(new->cntdwn_counter_offsets, csa->counter_offsets_presp,
885 csa->n_counter_offsets_presp *
886 sizeof(new->cntdwn_counter_offsets[0]));
888 new->cntdwn_counter_offsets[0] = cca->counter_offset_presp;
890 rcu_assign_pointer(sdata->u.ap.probe_resp, new);
892 kfree_rcu(old, rcu_head);
897 static int ieee80211_set_fils_discovery(struct ieee80211_sub_if_data *sdata,
898 struct cfg80211_fils_discovery *params)
900 struct fils_discovery_data *new, *old = NULL;
901 struct ieee80211_fils_discovery *fd;
903 if (!params->tmpl || !params->tmpl_len)
906 fd = &sdata->vif.bss_conf.fils_discovery;
907 fd->min_interval = params->min_interval;
908 fd->max_interval = params->max_interval;
910 old = sdata_dereference(sdata->u.ap.fils_discovery, sdata);
911 new = kzalloc(sizeof(*new) + params->tmpl_len, GFP_KERNEL);
914 new->len = params->tmpl_len;
915 memcpy(new->data, params->tmpl, params->tmpl_len);
916 rcu_assign_pointer(sdata->u.ap.fils_discovery, new);
919 kfree_rcu(old, rcu_head);
925 ieee80211_set_unsol_bcast_probe_resp(struct ieee80211_sub_if_data *sdata,
926 struct cfg80211_unsol_bcast_probe_resp *params)
928 struct unsol_bcast_probe_resp_data *new, *old = NULL;
930 if (!params->tmpl || !params->tmpl_len)
933 old = sdata_dereference(sdata->u.ap.unsol_bcast_probe_resp, sdata);
934 new = kzalloc(sizeof(*new) + params->tmpl_len, GFP_KERNEL);
937 new->len = params->tmpl_len;
938 memcpy(new->data, params->tmpl, params->tmpl_len);
939 rcu_assign_pointer(sdata->u.ap.unsol_bcast_probe_resp, new);
942 kfree_rcu(old, rcu_head);
944 sdata->vif.bss_conf.unsol_bcast_probe_resp_interval =
950 static int ieee80211_set_ftm_responder_params(
951 struct ieee80211_sub_if_data *sdata,
952 const u8 *lci, size_t lci_len,
953 const u8 *civicloc, size_t civicloc_len)
955 struct ieee80211_ftm_responder_params *new, *old;
956 struct ieee80211_bss_conf *bss_conf;
960 if (!lci_len && !civicloc_len)
963 bss_conf = &sdata->vif.bss_conf;
964 old = bss_conf->ftmr_params;
965 len = lci_len + civicloc_len;
967 new = kzalloc(sizeof(*new) + len, GFP_KERNEL);
971 pos = (u8 *)(new + 1);
973 new->lci_len = lci_len;
975 memcpy(pos, lci, lci_len);
980 new->civicloc_len = civicloc_len;
982 memcpy(pos, civicloc, civicloc_len);
986 bss_conf->ftmr_params = new;
992 static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
993 struct cfg80211_beacon_data *params,
994 const struct ieee80211_csa_settings *csa,
995 const struct ieee80211_color_change_settings *cca)
997 struct beacon_data *new, *old;
998 int new_head_len, new_tail_len;
1000 u32 changed = BSS_CHANGED_BEACON;
1002 old = sdata_dereference(sdata->u.ap.beacon, sdata);
1005 /* Need to have a beacon head if we don't have one yet */
1006 if (!params->head && !old)
1009 /* new or old head? */
1011 new_head_len = params->head_len;
1013 new_head_len = old->head_len;
1015 /* new or old tail? */
1016 if (params->tail || !old)
1017 /* params->tail_len will be zero for !params->tail */
1018 new_tail_len = params->tail_len;
1020 new_tail_len = old->tail_len;
1022 size = sizeof(*new) + new_head_len + new_tail_len;
1024 new = kzalloc(size, GFP_KERNEL);
1028 /* start filling the new info now */
1031 * pointers go into the block we allocated,
1032 * memory is | beacon_data | head | tail |
1034 new->head = ((u8 *) new) + sizeof(*new);
1035 new->tail = new->head + new_head_len;
1036 new->head_len = new_head_len;
1037 new->tail_len = new_tail_len;
1040 new->cntdwn_current_counter = csa->count;
1041 memcpy(new->cntdwn_counter_offsets, csa->counter_offsets_beacon,
1042 csa->n_counter_offsets_beacon *
1043 sizeof(new->cntdwn_counter_offsets[0]));
1045 new->cntdwn_current_counter = cca->count;
1046 new->cntdwn_counter_offsets[0] = cca->counter_offset_beacon;
1051 memcpy(new->head, params->head, new_head_len);
1053 memcpy(new->head, old->head, new_head_len);
1055 /* copy in optional tail */
1057 memcpy(new->tail, params->tail, new_tail_len);
1060 memcpy(new->tail, old->tail, new_tail_len);
1062 err = ieee80211_set_probe_resp(sdata, params->probe_resp,
1063 params->probe_resp_len, csa, cca);
1069 changed |= BSS_CHANGED_AP_PROBE_RESP;
1071 if (params->ftm_responder != -1) {
1072 sdata->vif.bss_conf.ftm_responder = params->ftm_responder;
1073 err = ieee80211_set_ftm_responder_params(sdata,
1077 params->civicloc_len);
1084 changed |= BSS_CHANGED_FTM_RESPONDER;
1087 rcu_assign_pointer(sdata->u.ap.beacon, new);
1090 kfree_rcu(old, rcu_head);
1095 static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
1096 struct cfg80211_ap_settings *params)
1098 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1099 struct ieee80211_local *local = sdata->local;
1100 struct beacon_data *old;
1101 struct ieee80211_sub_if_data *vlan;
1102 u32 changed = BSS_CHANGED_BEACON_INT |
1103 BSS_CHANGED_BEACON_ENABLED |
1104 BSS_CHANGED_BEACON |
1106 BSS_CHANGED_P2P_PS |
1107 BSS_CHANGED_TXPOWER |
1110 int prev_beacon_int;
1112 old = sdata_dereference(sdata->u.ap.beacon, sdata);
1116 if (params->smps_mode != NL80211_SMPS_OFF)
1119 sdata->smps_mode = IEEE80211_SMPS_OFF;
1121 sdata->needed_rx_chains = sdata->local->rx_chains;
1123 prev_beacon_int = sdata->vif.bss_conf.beacon_int;
1124 sdata->vif.bss_conf.beacon_int = params->beacon_interval;
1126 if (params->he_cap && params->he_oper) {
1127 sdata->vif.bss_conf.he_support = true;
1128 sdata->vif.bss_conf.htc_trig_based_pkt_ext =
1129 le32_get_bits(params->he_oper->he_oper_params,
1130 IEEE80211_HE_OPERATION_DFLT_PE_DURATION_MASK);
1131 sdata->vif.bss_conf.frame_time_rts_th =
1132 le32_get_bits(params->he_oper->he_oper_params,
1133 IEEE80211_HE_OPERATION_RTS_THRESHOLD_MASK);
1134 changed |= BSS_CHANGED_HE_OBSS_PD;
1136 if (params->he_bss_color.enabled)
1137 changed |= BSS_CHANGED_HE_BSS_COLOR;
1140 if (sdata->vif.type == NL80211_IFTYPE_AP &&
1141 params->mbssid_config.tx_wdev) {
1142 err = ieee80211_set_ap_mbssid_options(sdata,
1143 params->mbssid_config);
1148 mutex_lock(&local->mtx);
1149 err = ieee80211_vif_use_channel(sdata, ¶ms->chandef,
1150 IEEE80211_CHANCTX_SHARED);
1152 ieee80211_vif_copy_chanctx_to_vlans(sdata, false);
1153 mutex_unlock(&local->mtx);
1155 sdata->vif.bss_conf.beacon_int = prev_beacon_int;
1160 * Apply control port protocol, this allows us to
1161 * not encrypt dynamic WEP control frames.
1163 sdata->control_port_protocol = params->crypto.control_port_ethertype;
1164 sdata->control_port_no_encrypt = params->crypto.control_port_no_encrypt;
1165 sdata->control_port_over_nl80211 =
1166 params->crypto.control_port_over_nl80211;
1167 sdata->control_port_no_preauth =
1168 params->crypto.control_port_no_preauth;
1169 sdata->encrypt_headroom = ieee80211_cs_headroom(sdata->local,
1173 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) {
1174 vlan->control_port_protocol =
1175 params->crypto.control_port_ethertype;
1176 vlan->control_port_no_encrypt =
1177 params->crypto.control_port_no_encrypt;
1178 vlan->control_port_over_nl80211 =
1179 params->crypto.control_port_over_nl80211;
1180 vlan->control_port_no_preauth =
1181 params->crypto.control_port_no_preauth;
1182 vlan->encrypt_headroom =
1183 ieee80211_cs_headroom(sdata->local,
1188 sdata->vif.bss_conf.dtim_period = params->dtim_period;
1189 sdata->vif.bss_conf.enable_beacon = true;
1190 sdata->vif.bss_conf.allow_p2p_go_ps = sdata->vif.p2p;
1191 sdata->vif.bss_conf.twt_responder = params->twt_responder;
1192 sdata->vif.bss_conf.he_obss_pd = params->he_obss_pd;
1193 sdata->vif.bss_conf.he_bss_color = params->he_bss_color;
1194 sdata->vif.bss_conf.s1g = params->chandef.chan->band ==
1197 sdata->vif.bss_conf.ssid_len = params->ssid_len;
1198 if (params->ssid_len)
1199 memcpy(sdata->vif.bss_conf.ssid, params->ssid,
1201 sdata->vif.bss_conf.hidden_ssid =
1202 (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE);
1204 memset(&sdata->vif.bss_conf.p2p_noa_attr, 0,
1205 sizeof(sdata->vif.bss_conf.p2p_noa_attr));
1206 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow =
1207 params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
1208 if (params->p2p_opp_ps)
1209 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |=
1210 IEEE80211_P2P_OPPPS_ENABLE_BIT;
1212 sdata->beacon_rate_set = false;
1213 if (wiphy_ext_feature_isset(local->hw.wiphy,
1214 NL80211_EXT_FEATURE_BEACON_RATE_LEGACY)) {
1215 for (i = 0; i < NUM_NL80211_BANDS; i++) {
1216 sdata->beacon_rateidx_mask[i] =
1217 params->beacon_rate.control[i].legacy;
1218 if (sdata->beacon_rateidx_mask[i])
1219 sdata->beacon_rate_set = true;
1223 if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL))
1224 sdata->vif.bss_conf.beacon_tx_rate = params->beacon_rate;
1226 err = ieee80211_assign_beacon(sdata, ¶ms->beacon, NULL, NULL);
1231 if (params->fils_discovery.max_interval) {
1232 err = ieee80211_set_fils_discovery(sdata,
1233 ¶ms->fils_discovery);
1236 changed |= BSS_CHANGED_FILS_DISCOVERY;
1239 if (params->unsol_bcast_probe_resp.interval) {
1240 err = ieee80211_set_unsol_bcast_probe_resp(sdata,
1241 ¶ms->unsol_bcast_probe_resp);
1244 changed |= BSS_CHANGED_UNSOL_BCAST_PROBE_RESP;
1247 err = drv_start_ap(sdata->local, sdata);
1249 old = sdata_dereference(sdata->u.ap.beacon, sdata);
1252 kfree_rcu(old, rcu_head);
1253 RCU_INIT_POINTER(sdata->u.ap.beacon, NULL);
1257 ieee80211_recalc_dtim(local, sdata);
1258 ieee80211_bss_info_change_notify(sdata, changed);
1260 netif_carrier_on(dev);
1261 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
1262 netif_carrier_on(vlan->dev);
1267 ieee80211_vif_release_channel(sdata);
1271 static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev,
1272 struct cfg80211_beacon_data *params)
1274 struct ieee80211_sub_if_data *sdata;
1275 struct beacon_data *old;
1278 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1279 sdata_assert_lock(sdata);
1281 /* don't allow changing the beacon while a countdown is in place - offset
1282 * of channel switch counter may change
1284 if (sdata->vif.csa_active || sdata->vif.color_change_active)
1287 old = sdata_dereference(sdata->u.ap.beacon, sdata);
1291 err = ieee80211_assign_beacon(sdata, params, NULL, NULL);
1294 ieee80211_bss_info_change_notify(sdata, err);
1298 static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev)
1300 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1301 struct ieee80211_sub_if_data *vlan;
1302 struct ieee80211_local *local = sdata->local;
1303 struct beacon_data *old_beacon;
1304 struct probe_resp *old_probe_resp;
1305 struct fils_discovery_data *old_fils_discovery;
1306 struct unsol_bcast_probe_resp_data *old_unsol_bcast_probe_resp;
1307 struct cfg80211_chan_def chandef;
1309 sdata_assert_lock(sdata);
1311 old_beacon = sdata_dereference(sdata->u.ap.beacon, sdata);
1314 old_probe_resp = sdata_dereference(sdata->u.ap.probe_resp, sdata);
1315 old_fils_discovery = sdata_dereference(sdata->u.ap.fils_discovery,
1317 old_unsol_bcast_probe_resp =
1318 sdata_dereference(sdata->u.ap.unsol_bcast_probe_resp,
1321 /* abort any running channel switch */
1322 mutex_lock(&local->mtx);
1323 sdata->vif.csa_active = false;
1324 if (sdata->csa_block_tx) {
1325 ieee80211_wake_vif_queues(local, sdata,
1326 IEEE80211_QUEUE_STOP_REASON_CSA);
1327 sdata->csa_block_tx = false;
1330 mutex_unlock(&local->mtx);
1332 kfree(sdata->u.ap.next_beacon);
1333 sdata->u.ap.next_beacon = NULL;
1335 /* turn off carrier for this interface and dependent VLANs */
1336 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
1337 netif_carrier_off(vlan->dev);
1338 netif_carrier_off(dev);
1340 /* remove beacon and probe response */
1341 RCU_INIT_POINTER(sdata->u.ap.beacon, NULL);
1342 RCU_INIT_POINTER(sdata->u.ap.probe_resp, NULL);
1343 RCU_INIT_POINTER(sdata->u.ap.fils_discovery, NULL);
1344 RCU_INIT_POINTER(sdata->u.ap.unsol_bcast_probe_resp, NULL);
1345 kfree_rcu(old_beacon, rcu_head);
1347 kfree_rcu(old_probe_resp, rcu_head);
1348 if (old_fils_discovery)
1349 kfree_rcu(old_fils_discovery, rcu_head);
1350 if (old_unsol_bcast_probe_resp)
1351 kfree_rcu(old_unsol_bcast_probe_resp, rcu_head);
1353 kfree(sdata->vif.bss_conf.ftmr_params);
1354 sdata->vif.bss_conf.ftmr_params = NULL;
1356 __sta_info_flush(sdata, true);
1357 ieee80211_free_keys(sdata, true);
1359 sdata->vif.bss_conf.enable_beacon = false;
1360 sdata->beacon_rate_set = false;
1361 sdata->vif.bss_conf.ssid_len = 0;
1362 clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state);
1363 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
1365 if (sdata->wdev.cac_started) {
1366 chandef = sdata->vif.bss_conf.chandef;
1367 cancel_delayed_work_sync(&sdata->dfs_cac_timer_work);
1368 cfg80211_cac_event(sdata->dev, &chandef,
1369 NL80211_RADAR_CAC_ABORTED,
1373 drv_stop_ap(sdata->local, sdata);
1375 /* free all potentially still buffered bcast frames */
1376 local->total_ps_buffered -= skb_queue_len(&sdata->u.ap.ps.bc_buf);
1377 ieee80211_purge_tx_queue(&local->hw, &sdata->u.ap.ps.bc_buf);
1379 mutex_lock(&local->mtx);
1380 ieee80211_vif_copy_chanctx_to_vlans(sdata, true);
1381 ieee80211_vif_release_channel(sdata);
1382 mutex_unlock(&local->mtx);
1387 static int sta_apply_auth_flags(struct ieee80211_local *local,
1388 struct sta_info *sta,
1393 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
1394 set & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
1395 !test_sta_flag(sta, WLAN_STA_AUTH)) {
1396 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
1401 if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
1402 set & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
1403 !test_sta_flag(sta, WLAN_STA_ASSOC)) {
1405 * When peer becomes associated, init rate control as
1406 * well. Some drivers require rate control initialized
1407 * before drv_sta_state() is called.
1409 if (!test_sta_flag(sta, WLAN_STA_RATE_CONTROL))
1410 rate_control_rate_init(sta);
1412 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
1417 if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
1418 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED))
1419 ret = sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED);
1420 else if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
1421 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
1428 if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
1429 !(set & BIT(NL80211_STA_FLAG_ASSOCIATED)) &&
1430 test_sta_flag(sta, WLAN_STA_ASSOC)) {
1431 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
1436 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
1437 !(set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) &&
1438 test_sta_flag(sta, WLAN_STA_AUTH)) {
1439 ret = sta_info_move_state(sta, IEEE80211_STA_NONE);
1447 static void sta_apply_mesh_params(struct ieee80211_local *local,
1448 struct sta_info *sta,
1449 struct station_parameters *params)
1451 #ifdef CONFIG_MAC80211_MESH
1452 struct ieee80211_sub_if_data *sdata = sta->sdata;
1455 if (params->sta_modify_mask & STATION_PARAM_APPLY_PLINK_STATE) {
1456 switch (params->plink_state) {
1457 case NL80211_PLINK_ESTAB:
1458 if (sta->mesh->plink_state != NL80211_PLINK_ESTAB)
1459 changed = mesh_plink_inc_estab_count(sdata);
1460 sta->mesh->plink_state = params->plink_state;
1461 sta->mesh->aid = params->peer_aid;
1463 ieee80211_mps_sta_status_update(sta);
1464 changed |= ieee80211_mps_set_sta_local_pm(sta,
1465 sdata->u.mesh.mshcfg.power_mode);
1467 ewma_mesh_tx_rate_avg_init(&sta->mesh->tx_rate_avg);
1468 /* init at low value */
1469 ewma_mesh_tx_rate_avg_add(&sta->mesh->tx_rate_avg, 10);
1472 case NL80211_PLINK_LISTEN:
1473 case NL80211_PLINK_BLOCKED:
1474 case NL80211_PLINK_OPN_SNT:
1475 case NL80211_PLINK_OPN_RCVD:
1476 case NL80211_PLINK_CNF_RCVD:
1477 case NL80211_PLINK_HOLDING:
1478 if (sta->mesh->plink_state == NL80211_PLINK_ESTAB)
1479 changed = mesh_plink_dec_estab_count(sdata);
1480 sta->mesh->plink_state = params->plink_state;
1482 ieee80211_mps_sta_status_update(sta);
1483 changed |= ieee80211_mps_set_sta_local_pm(sta,
1484 NL80211_MESH_POWER_UNKNOWN);
1492 switch (params->plink_action) {
1493 case NL80211_PLINK_ACTION_NO_ACTION:
1496 case NL80211_PLINK_ACTION_OPEN:
1497 changed |= mesh_plink_open(sta);
1499 case NL80211_PLINK_ACTION_BLOCK:
1500 changed |= mesh_plink_block(sta);
1504 if (params->local_pm)
1505 changed |= ieee80211_mps_set_sta_local_pm(sta,
1508 ieee80211_mbss_info_change_notify(sdata, changed);
1512 static void sta_apply_airtime_params(struct ieee80211_local *local,
1513 struct sta_info *sta,
1514 struct station_parameters *params)
1518 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
1519 struct airtime_sched_info *air_sched = &local->airtime[ac];
1520 struct airtime_info *air_info = &sta->airtime[ac];
1521 struct txq_info *txqi;
1524 spin_lock_bh(&air_sched->lock);
1525 for (tid = 0; tid < IEEE80211_NUM_TIDS + 1; tid++) {
1526 if (air_info->weight == params->airtime_weight ||
1527 !sta->sta.txq[tid] ||
1528 ac != ieee80211_ac_from_tid(tid))
1531 airtime_weight_set(air_info, params->airtime_weight);
1533 txqi = to_txq_info(sta->sta.txq[tid]);
1534 if (RB_EMPTY_NODE(&txqi->schedule_order))
1537 ieee80211_update_airtime_weight(local, air_sched,
1540 spin_unlock_bh(&air_sched->lock);
1544 static int sta_apply_parameters(struct ieee80211_local *local,
1545 struct sta_info *sta,
1546 struct station_parameters *params)
1549 struct ieee80211_supported_band *sband;
1550 struct ieee80211_sub_if_data *sdata = sta->sdata;
1553 sband = ieee80211_get_sband(sdata);
1557 mask = params->sta_flags_mask;
1558 set = params->sta_flags_set;
1560 if (ieee80211_vif_is_mesh(&sdata->vif)) {
1562 * In mesh mode, ASSOCIATED isn't part of the nl80211
1563 * API but must follow AUTHENTICATED for driver state.
1565 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED))
1566 mask |= BIT(NL80211_STA_FLAG_ASSOCIATED);
1567 if (set & BIT(NL80211_STA_FLAG_AUTHENTICATED))
1568 set |= BIT(NL80211_STA_FLAG_ASSOCIATED);
1569 } else if (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
1571 * TDLS -- everything follows authorized, but
1572 * only becoming authorized is possible, not
1575 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
1576 set |= BIT(NL80211_STA_FLAG_AUTHENTICATED) |
1577 BIT(NL80211_STA_FLAG_ASSOCIATED);
1578 mask |= BIT(NL80211_STA_FLAG_AUTHENTICATED) |
1579 BIT(NL80211_STA_FLAG_ASSOCIATED);
1583 if (mask & BIT(NL80211_STA_FLAG_WME) &&
1584 local->hw.queues >= IEEE80211_NUM_ACS)
1585 sta->sta.wme = set & BIT(NL80211_STA_FLAG_WME);
1587 /* auth flags will be set later for TDLS,
1588 * and for unassociated stations that move to associated */
1589 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1590 !((mask & BIT(NL80211_STA_FLAG_ASSOCIATED)) &&
1591 (set & BIT(NL80211_STA_FLAG_ASSOCIATED)))) {
1592 ret = sta_apply_auth_flags(local, sta, mask, set);
1597 if (mask & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) {
1598 if (set & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE))
1599 set_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
1601 clear_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
1604 if (mask & BIT(NL80211_STA_FLAG_MFP)) {
1605 sta->sta.mfp = !!(set & BIT(NL80211_STA_FLAG_MFP));
1606 if (set & BIT(NL80211_STA_FLAG_MFP))
1607 set_sta_flag(sta, WLAN_STA_MFP);
1609 clear_sta_flag(sta, WLAN_STA_MFP);
1612 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
1613 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER))
1614 set_sta_flag(sta, WLAN_STA_TDLS_PEER);
1616 clear_sta_flag(sta, WLAN_STA_TDLS_PEER);
1619 /* mark TDLS channel switch support, if the AP allows it */
1620 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1621 !sdata->u.mgd.tdls_chan_switch_prohibited &&
1622 params->ext_capab_len >= 4 &&
1623 params->ext_capab[3] & WLAN_EXT_CAPA4_TDLS_CHAN_SWITCH)
1624 set_sta_flag(sta, WLAN_STA_TDLS_CHAN_SWITCH);
1626 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1627 !sdata->u.mgd.tdls_wider_bw_prohibited &&
1628 ieee80211_hw_check(&local->hw, TDLS_WIDER_BW) &&
1629 params->ext_capab_len >= 8 &&
1630 params->ext_capab[7] & WLAN_EXT_CAPA8_TDLS_WIDE_BW_ENABLED)
1631 set_sta_flag(sta, WLAN_STA_TDLS_WIDER_BW);
1633 if (params->sta_modify_mask & STATION_PARAM_APPLY_UAPSD) {
1634 sta->sta.uapsd_queues = params->uapsd_queues;
1635 sta->sta.max_sp = params->max_sp;
1638 /* The sender might not have sent the last bit, consider it to be 0 */
1639 if (params->ext_capab_len >= 8) {
1640 u8 val = (params->ext_capab[7] &
1641 WLAN_EXT_CAPA8_MAX_MSDU_IN_AMSDU_LSB) >> 7;
1643 /* we did get all the bits, take the MSB as well */
1644 if (params->ext_capab_len >= 9) {
1645 u8 val_msb = params->ext_capab[8] &
1646 WLAN_EXT_CAPA9_MAX_MSDU_IN_AMSDU_MSB;
1653 sta->sta.max_amsdu_subframes = 32;
1656 sta->sta.max_amsdu_subframes = 16;
1659 sta->sta.max_amsdu_subframes = 8;
1662 sta->sta.max_amsdu_subframes = 0;
1667 * cfg80211 validates this (1-2007) and allows setting the AID
1668 * only when creating a new station entry
1671 sta->sta.aid = params->aid;
1674 * Some of the following updates would be racy if called on an
1675 * existing station, via ieee80211_change_station(). However,
1676 * all such changes are rejected by cfg80211 except for updates
1677 * changing the supported rates on an existing but not yet used
1681 if (params->listen_interval >= 0)
1682 sta->listen_interval = params->listen_interval;
1684 if (params->sta_modify_mask & STATION_PARAM_APPLY_STA_TXPOWER) {
1685 sta->sta.txpwr.type = params->txpwr.type;
1686 if (params->txpwr.type == NL80211_TX_POWER_LIMITED)
1687 sta->sta.txpwr.power = params->txpwr.power;
1688 ret = drv_sta_set_txpwr(local, sdata, sta);
1693 if (params->supported_rates && params->supported_rates_len) {
1694 ieee80211_parse_bitrates(&sdata->vif.bss_conf.chandef,
1695 sband, params->supported_rates,
1696 params->supported_rates_len,
1697 &sta->sta.supp_rates[sband->band]);
1700 if (params->ht_capa)
1701 ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
1702 params->ht_capa, sta);
1704 /* VHT can override some HT caps such as the A-MSDU max length */
1705 if (params->vht_capa)
1706 ieee80211_vht_cap_ie_to_sta_vht_cap(sdata, sband,
1707 params->vht_capa, sta);
1709 if (params->he_capa)
1710 ieee80211_he_cap_ie_to_sta_he_cap(sdata, sband,
1711 (void *)params->he_capa,
1712 params->he_capa_len,
1713 (void *)params->he_6ghz_capa,
1716 if (params->opmode_notif_used) {
1717 /* returned value is only needed for rc update, but the
1718 * rc isn't initialized here yet, so ignore it
1720 __ieee80211_vht_handle_opmode(sdata, sta, params->opmode_notif,
1724 if (params->support_p2p_ps >= 0)
1725 sta->sta.support_p2p_ps = params->support_p2p_ps;
1727 if (ieee80211_vif_is_mesh(&sdata->vif))
1728 sta_apply_mesh_params(local, sta, params);
1730 if (params->airtime_weight)
1731 sta_apply_airtime_params(local, sta, params);
1734 /* set the STA state after all sta info from usermode has been set */
1735 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) ||
1736 set & BIT(NL80211_STA_FLAG_ASSOCIATED)) {
1737 ret = sta_apply_auth_flags(local, sta, mask, set);
1745 static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
1747 struct station_parameters *params)
1749 struct ieee80211_local *local = wiphy_priv(wiphy);
1750 struct sta_info *sta;
1751 struct ieee80211_sub_if_data *sdata;
1755 sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
1757 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
1758 sdata->vif.type != NL80211_IFTYPE_AP)
1761 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1763 if (ether_addr_equal(mac, sdata->vif.addr))
1766 if (!is_valid_ether_addr(mac))
1769 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER) &&
1770 sdata->vif.type == NL80211_IFTYPE_STATION &&
1771 !sdata->u.mgd.associated)
1774 sta = sta_info_alloc(sdata, mac, GFP_KERNEL);
1778 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))
1779 sta->sta.tdls = true;
1781 err = sta_apply_parameters(local, sta, params);
1783 sta_info_free(local, sta);
1788 * for TDLS and for unassociated station, rate control should be
1789 * initialized only when rates are known and station is marked
1790 * authorized/associated
1792 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1793 test_sta_flag(sta, WLAN_STA_ASSOC))
1794 rate_control_rate_init(sta);
1796 return sta_info_insert(sta);
1799 static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev,
1800 struct station_del_parameters *params)
1802 struct ieee80211_sub_if_data *sdata;
1804 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1807 return sta_info_destroy_addr_bss(sdata, params->mac);
1809 sta_info_flush(sdata);
1813 static int ieee80211_change_station(struct wiphy *wiphy,
1814 struct net_device *dev, const u8 *mac,
1815 struct station_parameters *params)
1817 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1818 struct ieee80211_local *local = wiphy_priv(wiphy);
1819 struct sta_info *sta;
1820 struct ieee80211_sub_if_data *vlansdata;
1821 enum cfg80211_station_type statype;
1824 mutex_lock(&local->sta_mtx);
1826 sta = sta_info_get_bss(sdata, mac);
1832 switch (sdata->vif.type) {
1833 case NL80211_IFTYPE_MESH_POINT:
1834 if (sdata->u.mesh.user_mpm)
1835 statype = CFG80211_STA_MESH_PEER_USER;
1837 statype = CFG80211_STA_MESH_PEER_KERNEL;
1839 case NL80211_IFTYPE_ADHOC:
1840 statype = CFG80211_STA_IBSS;
1842 case NL80211_IFTYPE_STATION:
1843 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
1844 statype = CFG80211_STA_AP_STA;
1847 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
1848 statype = CFG80211_STA_TDLS_PEER_ACTIVE;
1850 statype = CFG80211_STA_TDLS_PEER_SETUP;
1852 case NL80211_IFTYPE_AP:
1853 case NL80211_IFTYPE_AP_VLAN:
1854 if (test_sta_flag(sta, WLAN_STA_ASSOC))
1855 statype = CFG80211_STA_AP_CLIENT;
1857 statype = CFG80211_STA_AP_CLIENT_UNASSOC;
1864 err = cfg80211_check_station_change(wiphy, params, statype);
1868 if (params->vlan && params->vlan != sta->sdata->dev) {
1869 vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
1871 if (params->vlan->ieee80211_ptr->use_4addr) {
1872 if (vlansdata->u.vlan.sta) {
1877 rcu_assign_pointer(vlansdata->u.vlan.sta, sta);
1878 __ieee80211_check_fast_rx_iface(vlansdata);
1879 drv_sta_set_4addr(local, sta->sdata, &sta->sta, true);
1882 if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
1883 sta->sdata->u.vlan.sta) {
1884 ieee80211_clear_fast_rx(sta);
1885 RCU_INIT_POINTER(sta->sdata->u.vlan.sta, NULL);
1888 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
1889 ieee80211_vif_dec_num_mcast(sta->sdata);
1891 sta->sdata = vlansdata;
1892 ieee80211_check_fast_xmit(sta);
1894 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED)) {
1895 ieee80211_vif_inc_num_mcast(sta->sdata);
1896 cfg80211_send_layer2_update(sta->sdata->dev,
1901 err = sta_apply_parameters(local, sta, params);
1905 mutex_unlock(&local->sta_mtx);
1907 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
1908 params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
1909 ieee80211_recalc_ps(local);
1910 ieee80211_recalc_ps_vif(sdata);
1915 mutex_unlock(&local->sta_mtx);
1919 #ifdef CONFIG_MAC80211_MESH
1920 static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev,
1921 const u8 *dst, const u8 *next_hop)
1923 struct ieee80211_sub_if_data *sdata;
1924 struct mesh_path *mpath;
1925 struct sta_info *sta;
1927 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1930 sta = sta_info_get(sdata, next_hop);
1936 mpath = mesh_path_add(sdata, dst);
1937 if (IS_ERR(mpath)) {
1939 return PTR_ERR(mpath);
1942 mesh_path_fix_nexthop(mpath, sta);
1948 static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev,
1951 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1954 return mesh_path_del(sdata, dst);
1956 mesh_path_flush_by_iface(sdata);
1960 static int ieee80211_change_mpath(struct wiphy *wiphy, struct net_device *dev,
1961 const u8 *dst, const u8 *next_hop)
1963 struct ieee80211_sub_if_data *sdata;
1964 struct mesh_path *mpath;
1965 struct sta_info *sta;
1967 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1971 sta = sta_info_get(sdata, next_hop);
1977 mpath = mesh_path_lookup(sdata, dst);
1983 mesh_path_fix_nexthop(mpath, sta);
1989 static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop,
1990 struct mpath_info *pinfo)
1992 struct sta_info *next_hop_sta = rcu_dereference(mpath->next_hop);
1995 memcpy(next_hop, next_hop_sta->sta.addr, ETH_ALEN);
1997 eth_zero_addr(next_hop);
1999 memset(pinfo, 0, sizeof(*pinfo));
2001 pinfo->generation = mpath->sdata->u.mesh.mesh_paths_generation;
2003 pinfo->filled = MPATH_INFO_FRAME_QLEN |
2006 MPATH_INFO_EXPTIME |
2007 MPATH_INFO_DISCOVERY_TIMEOUT |
2008 MPATH_INFO_DISCOVERY_RETRIES |
2010 MPATH_INFO_HOP_COUNT |
2011 MPATH_INFO_PATH_CHANGE;
2013 pinfo->frame_qlen = mpath->frame_queue.qlen;
2014 pinfo->sn = mpath->sn;
2015 pinfo->metric = mpath->metric;
2016 if (time_before(jiffies, mpath->exp_time))
2017 pinfo->exptime = jiffies_to_msecs(mpath->exp_time - jiffies);
2018 pinfo->discovery_timeout =
2019 jiffies_to_msecs(mpath->discovery_timeout);
2020 pinfo->discovery_retries = mpath->discovery_retries;
2021 if (mpath->flags & MESH_PATH_ACTIVE)
2022 pinfo->flags |= NL80211_MPATH_FLAG_ACTIVE;
2023 if (mpath->flags & MESH_PATH_RESOLVING)
2024 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING;
2025 if (mpath->flags & MESH_PATH_SN_VALID)
2026 pinfo->flags |= NL80211_MPATH_FLAG_SN_VALID;
2027 if (mpath->flags & MESH_PATH_FIXED)
2028 pinfo->flags |= NL80211_MPATH_FLAG_FIXED;
2029 if (mpath->flags & MESH_PATH_RESOLVED)
2030 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVED;
2031 pinfo->hop_count = mpath->hop_count;
2032 pinfo->path_change_count = mpath->path_change_count;
2035 static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev,
2036 u8 *dst, u8 *next_hop, struct mpath_info *pinfo)
2039 struct ieee80211_sub_if_data *sdata;
2040 struct mesh_path *mpath;
2042 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2045 mpath = mesh_path_lookup(sdata, dst);
2050 memcpy(dst, mpath->dst, ETH_ALEN);
2051 mpath_set_pinfo(mpath, next_hop, pinfo);
2056 static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev,
2057 int idx, u8 *dst, u8 *next_hop,
2058 struct mpath_info *pinfo)
2060 struct ieee80211_sub_if_data *sdata;
2061 struct mesh_path *mpath;
2063 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2066 mpath = mesh_path_lookup_by_idx(sdata, idx);
2071 memcpy(dst, mpath->dst, ETH_ALEN);
2072 mpath_set_pinfo(mpath, next_hop, pinfo);
2077 static void mpp_set_pinfo(struct mesh_path *mpath, u8 *mpp,
2078 struct mpath_info *pinfo)
2080 memset(pinfo, 0, sizeof(*pinfo));
2081 memcpy(mpp, mpath->mpp, ETH_ALEN);
2083 pinfo->generation = mpath->sdata->u.mesh.mpp_paths_generation;
2086 static int ieee80211_get_mpp(struct wiphy *wiphy, struct net_device *dev,
2087 u8 *dst, u8 *mpp, struct mpath_info *pinfo)
2090 struct ieee80211_sub_if_data *sdata;
2091 struct mesh_path *mpath;
2093 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2096 mpath = mpp_path_lookup(sdata, dst);
2101 memcpy(dst, mpath->dst, ETH_ALEN);
2102 mpp_set_pinfo(mpath, mpp, pinfo);
2107 static int ieee80211_dump_mpp(struct wiphy *wiphy, struct net_device *dev,
2108 int idx, u8 *dst, u8 *mpp,
2109 struct mpath_info *pinfo)
2111 struct ieee80211_sub_if_data *sdata;
2112 struct mesh_path *mpath;
2114 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2117 mpath = mpp_path_lookup_by_idx(sdata, idx);
2122 memcpy(dst, mpath->dst, ETH_ALEN);
2123 mpp_set_pinfo(mpath, mpp, pinfo);
2128 static int ieee80211_get_mesh_config(struct wiphy *wiphy,
2129 struct net_device *dev,
2130 struct mesh_config *conf)
2132 struct ieee80211_sub_if_data *sdata;
2133 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2135 memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config));
2139 static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask)
2141 return (mask >> (parm-1)) & 0x1;
2144 static int copy_mesh_setup(struct ieee80211_if_mesh *ifmsh,
2145 const struct mesh_setup *setup)
2149 struct ieee80211_sub_if_data *sdata = container_of(ifmsh,
2150 struct ieee80211_sub_if_data, u.mesh);
2153 /* allocate information elements */
2157 if (setup->ie_len) {
2158 new_ie = kmemdup(setup->ie, setup->ie_len,
2163 ifmsh->ie_len = setup->ie_len;
2167 /* now copy the rest of the setup parameters */
2168 ifmsh->mesh_id_len = setup->mesh_id_len;
2169 memcpy(ifmsh->mesh_id, setup->mesh_id, ifmsh->mesh_id_len);
2170 ifmsh->mesh_sp_id = setup->sync_method;
2171 ifmsh->mesh_pp_id = setup->path_sel_proto;
2172 ifmsh->mesh_pm_id = setup->path_metric;
2173 ifmsh->user_mpm = setup->user_mpm;
2174 ifmsh->mesh_auth_id = setup->auth_id;
2175 ifmsh->security = IEEE80211_MESH_SEC_NONE;
2176 ifmsh->userspace_handles_dfs = setup->userspace_handles_dfs;
2177 if (setup->is_authenticated)
2178 ifmsh->security |= IEEE80211_MESH_SEC_AUTHED;
2179 if (setup->is_secure)
2180 ifmsh->security |= IEEE80211_MESH_SEC_SECURED;
2182 /* mcast rate setting in Mesh Node */
2183 memcpy(sdata->vif.bss_conf.mcast_rate, setup->mcast_rate,
2184 sizeof(setup->mcast_rate));
2185 sdata->vif.bss_conf.basic_rates = setup->basic_rates;
2187 sdata->vif.bss_conf.beacon_int = setup->beacon_interval;
2188 sdata->vif.bss_conf.dtim_period = setup->dtim_period;
2190 sdata->beacon_rate_set = false;
2191 if (wiphy_ext_feature_isset(sdata->local->hw.wiphy,
2192 NL80211_EXT_FEATURE_BEACON_RATE_LEGACY)) {
2193 for (i = 0; i < NUM_NL80211_BANDS; i++) {
2194 sdata->beacon_rateidx_mask[i] =
2195 setup->beacon_rate.control[i].legacy;
2196 if (sdata->beacon_rateidx_mask[i])
2197 sdata->beacon_rate_set = true;
2204 static int ieee80211_update_mesh_config(struct wiphy *wiphy,
2205 struct net_device *dev, u32 mask,
2206 const struct mesh_config *nconf)
2208 struct mesh_config *conf;
2209 struct ieee80211_sub_if_data *sdata;
2210 struct ieee80211_if_mesh *ifmsh;
2212 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2213 ifmsh = &sdata->u.mesh;
2215 /* Set the config options which we are interested in setting */
2216 conf = &(sdata->u.mesh.mshcfg);
2217 if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask))
2218 conf->dot11MeshRetryTimeout = nconf->dot11MeshRetryTimeout;
2219 if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT, mask))
2220 conf->dot11MeshConfirmTimeout = nconf->dot11MeshConfirmTimeout;
2221 if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT, mask))
2222 conf->dot11MeshHoldingTimeout = nconf->dot11MeshHoldingTimeout;
2223 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS, mask))
2224 conf->dot11MeshMaxPeerLinks = nconf->dot11MeshMaxPeerLinks;
2225 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES, mask))
2226 conf->dot11MeshMaxRetries = nconf->dot11MeshMaxRetries;
2227 if (_chg_mesh_attr(NL80211_MESHCONF_TTL, mask))
2228 conf->dot11MeshTTL = nconf->dot11MeshTTL;
2229 if (_chg_mesh_attr(NL80211_MESHCONF_ELEMENT_TTL, mask))
2230 conf->element_ttl = nconf->element_ttl;
2231 if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask)) {
2232 if (ifmsh->user_mpm)
2234 conf->auto_open_plinks = nconf->auto_open_plinks;
2236 if (_chg_mesh_attr(NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR, mask))
2237 conf->dot11MeshNbrOffsetMaxNeighbor =
2238 nconf->dot11MeshNbrOffsetMaxNeighbor;
2239 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, mask))
2240 conf->dot11MeshHWMPmaxPREQretries =
2241 nconf->dot11MeshHWMPmaxPREQretries;
2242 if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME, mask))
2243 conf->path_refresh_time = nconf->path_refresh_time;
2244 if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, mask))
2245 conf->min_discovery_timeout = nconf->min_discovery_timeout;
2246 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, mask))
2247 conf->dot11MeshHWMPactivePathTimeout =
2248 nconf->dot11MeshHWMPactivePathTimeout;
2249 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, mask))
2250 conf->dot11MeshHWMPpreqMinInterval =
2251 nconf->dot11MeshHWMPpreqMinInterval;
2252 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL, mask))
2253 conf->dot11MeshHWMPperrMinInterval =
2254 nconf->dot11MeshHWMPperrMinInterval;
2255 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
2257 conf->dot11MeshHWMPnetDiameterTraversalTime =
2258 nconf->dot11MeshHWMPnetDiameterTraversalTime;
2259 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOTMODE, mask)) {
2260 conf->dot11MeshHWMPRootMode = nconf->dot11MeshHWMPRootMode;
2261 ieee80211_mesh_root_setup(ifmsh);
2263 if (_chg_mesh_attr(NL80211_MESHCONF_GATE_ANNOUNCEMENTS, mask)) {
2264 /* our current gate announcement implementation rides on root
2265 * announcements, so require this ifmsh to also be a root node
2267 if (nconf->dot11MeshGateAnnouncementProtocol &&
2268 !(conf->dot11MeshHWMPRootMode > IEEE80211_ROOTMODE_ROOT)) {
2269 conf->dot11MeshHWMPRootMode = IEEE80211_PROACTIVE_RANN;
2270 ieee80211_mesh_root_setup(ifmsh);
2272 conf->dot11MeshGateAnnouncementProtocol =
2273 nconf->dot11MeshGateAnnouncementProtocol;
2275 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_RANN_INTERVAL, mask))
2276 conf->dot11MeshHWMPRannInterval =
2277 nconf->dot11MeshHWMPRannInterval;
2278 if (_chg_mesh_attr(NL80211_MESHCONF_FORWARDING, mask))
2279 conf->dot11MeshForwarding = nconf->dot11MeshForwarding;
2280 if (_chg_mesh_attr(NL80211_MESHCONF_RSSI_THRESHOLD, mask)) {
2281 /* our RSSI threshold implementation is supported only for
2282 * devices that report signal in dBm.
2284 if (!ieee80211_hw_check(&sdata->local->hw, SIGNAL_DBM))
2286 conf->rssi_threshold = nconf->rssi_threshold;
2288 if (_chg_mesh_attr(NL80211_MESHCONF_HT_OPMODE, mask)) {
2289 conf->ht_opmode = nconf->ht_opmode;
2290 sdata->vif.bss_conf.ht_operation_mode = nconf->ht_opmode;
2291 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_HT);
2293 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT, mask))
2294 conf->dot11MeshHWMPactivePathToRootTimeout =
2295 nconf->dot11MeshHWMPactivePathToRootTimeout;
2296 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOT_INTERVAL, mask))
2297 conf->dot11MeshHWMProotInterval =
2298 nconf->dot11MeshHWMProotInterval;
2299 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL, mask))
2300 conf->dot11MeshHWMPconfirmationInterval =
2301 nconf->dot11MeshHWMPconfirmationInterval;
2302 if (_chg_mesh_attr(NL80211_MESHCONF_POWER_MODE, mask)) {
2303 conf->power_mode = nconf->power_mode;
2304 ieee80211_mps_local_status_update(sdata);
2306 if (_chg_mesh_attr(NL80211_MESHCONF_AWAKE_WINDOW, mask))
2307 conf->dot11MeshAwakeWindowDuration =
2308 nconf->dot11MeshAwakeWindowDuration;
2309 if (_chg_mesh_attr(NL80211_MESHCONF_PLINK_TIMEOUT, mask))
2310 conf->plink_timeout = nconf->plink_timeout;
2311 if (_chg_mesh_attr(NL80211_MESHCONF_CONNECTED_TO_GATE, mask))
2312 conf->dot11MeshConnectedToMeshGate =
2313 nconf->dot11MeshConnectedToMeshGate;
2314 if (_chg_mesh_attr(NL80211_MESHCONF_NOLEARN, mask))
2315 conf->dot11MeshNolearn = nconf->dot11MeshNolearn;
2316 if (_chg_mesh_attr(NL80211_MESHCONF_CONNECTED_TO_AS, mask))
2317 conf->dot11MeshConnectedToAuthServer =
2318 nconf->dot11MeshConnectedToAuthServer;
2319 ieee80211_mbss_info_change_notify(sdata, BSS_CHANGED_BEACON);
2323 static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev,
2324 const struct mesh_config *conf,
2325 const struct mesh_setup *setup)
2327 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2328 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
2331 memcpy(&ifmsh->mshcfg, conf, sizeof(struct mesh_config));
2332 err = copy_mesh_setup(ifmsh, setup);
2336 sdata->control_port_over_nl80211 = setup->control_port_over_nl80211;
2338 /* can mesh use other SMPS modes? */
2339 sdata->smps_mode = IEEE80211_SMPS_OFF;
2340 sdata->needed_rx_chains = sdata->local->rx_chains;
2342 mutex_lock(&sdata->local->mtx);
2343 err = ieee80211_vif_use_channel(sdata, &setup->chandef,
2344 IEEE80211_CHANCTX_SHARED);
2345 mutex_unlock(&sdata->local->mtx);
2349 return ieee80211_start_mesh(sdata);
2352 static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev)
2354 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2356 ieee80211_stop_mesh(sdata);
2357 mutex_lock(&sdata->local->mtx);
2358 ieee80211_vif_release_channel(sdata);
2359 kfree(sdata->u.mesh.ie);
2360 mutex_unlock(&sdata->local->mtx);
2366 static int ieee80211_change_bss(struct wiphy *wiphy,
2367 struct net_device *dev,
2368 struct bss_parameters *params)
2370 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2371 struct ieee80211_supported_band *sband;
2374 if (!sdata_dereference(sdata->u.ap.beacon, sdata))
2377 sband = ieee80211_get_sband(sdata);
2381 if (params->use_cts_prot >= 0) {
2382 sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot;
2383 changed |= BSS_CHANGED_ERP_CTS_PROT;
2385 if (params->use_short_preamble >= 0) {
2386 sdata->vif.bss_conf.use_short_preamble =
2387 params->use_short_preamble;
2388 changed |= BSS_CHANGED_ERP_PREAMBLE;
2391 if (!sdata->vif.bss_conf.use_short_slot &&
2392 (sband->band == NL80211_BAND_5GHZ ||
2393 sband->band == NL80211_BAND_6GHZ)) {
2394 sdata->vif.bss_conf.use_short_slot = true;
2395 changed |= BSS_CHANGED_ERP_SLOT;
2398 if (params->use_short_slot_time >= 0) {
2399 sdata->vif.bss_conf.use_short_slot =
2400 params->use_short_slot_time;
2401 changed |= BSS_CHANGED_ERP_SLOT;
2404 if (params->basic_rates) {
2405 ieee80211_parse_bitrates(&sdata->vif.bss_conf.chandef,
2406 wiphy->bands[sband->band],
2407 params->basic_rates,
2408 params->basic_rates_len,
2409 &sdata->vif.bss_conf.basic_rates);
2410 changed |= BSS_CHANGED_BASIC_RATES;
2411 ieee80211_check_rate_mask(sdata);
2414 if (params->ap_isolate >= 0) {
2415 if (params->ap_isolate)
2416 sdata->flags |= IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
2418 sdata->flags &= ~IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
2419 ieee80211_check_fast_rx_iface(sdata);
2422 if (params->ht_opmode >= 0) {
2423 sdata->vif.bss_conf.ht_operation_mode =
2424 (u16) params->ht_opmode;
2425 changed |= BSS_CHANGED_HT;
2428 if (params->p2p_ctwindow >= 0) {
2429 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow &=
2430 ~IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
2431 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |=
2432 params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
2433 changed |= BSS_CHANGED_P2P_PS;
2436 if (params->p2p_opp_ps > 0) {
2437 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |=
2438 IEEE80211_P2P_OPPPS_ENABLE_BIT;
2439 changed |= BSS_CHANGED_P2P_PS;
2440 } else if (params->p2p_opp_ps == 0) {
2441 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow &=
2442 ~IEEE80211_P2P_OPPPS_ENABLE_BIT;
2443 changed |= BSS_CHANGED_P2P_PS;
2446 ieee80211_bss_info_change_notify(sdata, changed);
2451 static int ieee80211_set_txq_params(struct wiphy *wiphy,
2452 struct net_device *dev,
2453 struct ieee80211_txq_params *params)
2455 struct ieee80211_local *local = wiphy_priv(wiphy);
2456 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2457 struct ieee80211_tx_queue_params p;
2459 if (!local->ops->conf_tx)
2462 if (local->hw.queues < IEEE80211_NUM_ACS)
2465 memset(&p, 0, sizeof(p));
2466 p.aifs = params->aifs;
2467 p.cw_max = params->cwmax;
2468 p.cw_min = params->cwmin;
2469 p.txop = params->txop;
2472 * Setting tx queue params disables u-apsd because it's only
2473 * called in master mode.
2477 ieee80211_regulatory_limit_wmm_params(sdata, &p, params->ac);
2479 sdata->tx_conf[params->ac] = p;
2480 if (drv_conf_tx(local, sdata, params->ac, &p)) {
2481 wiphy_debug(local->hw.wiphy,
2482 "failed to set TX queue parameters for AC %d\n",
2487 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_QOS);
2493 static int ieee80211_suspend(struct wiphy *wiphy,
2494 struct cfg80211_wowlan *wowlan)
2496 return __ieee80211_suspend(wiphy_priv(wiphy), wowlan);
2499 static int ieee80211_resume(struct wiphy *wiphy)
2501 return __ieee80211_resume(wiphy_priv(wiphy));
2504 #define ieee80211_suspend NULL
2505 #define ieee80211_resume NULL
2508 static int ieee80211_scan(struct wiphy *wiphy,
2509 struct cfg80211_scan_request *req)
2511 struct ieee80211_sub_if_data *sdata;
2513 sdata = IEEE80211_WDEV_TO_SUB_IF(req->wdev);
2515 switch (ieee80211_vif_type_p2p(&sdata->vif)) {
2516 case NL80211_IFTYPE_STATION:
2517 case NL80211_IFTYPE_ADHOC:
2518 case NL80211_IFTYPE_MESH_POINT:
2519 case NL80211_IFTYPE_P2P_CLIENT:
2520 case NL80211_IFTYPE_P2P_DEVICE:
2522 case NL80211_IFTYPE_P2P_GO:
2523 if (sdata->local->ops->hw_scan)
2526 * FIXME: implement NoA while scanning in software,
2527 * for now fall through to allow scanning only when
2528 * beaconing hasn't been configured yet
2531 case NL80211_IFTYPE_AP:
2533 * If the scan has been forced (and the driver supports
2534 * forcing), don't care about being beaconing already.
2535 * This will create problems to the attached stations (e.g. all
2536 * the frames sent while scanning on other channel will be
2539 if (sdata->u.ap.beacon &&
2540 (!(wiphy->features & NL80211_FEATURE_AP_SCAN) ||
2541 !(req->flags & NL80211_SCAN_FLAG_AP)))
2544 case NL80211_IFTYPE_NAN:
2549 return ieee80211_request_scan(sdata, req);
2552 static void ieee80211_abort_scan(struct wiphy *wiphy, struct wireless_dev *wdev)
2554 ieee80211_scan_cancel(wiphy_priv(wiphy));
2558 ieee80211_sched_scan_start(struct wiphy *wiphy,
2559 struct net_device *dev,
2560 struct cfg80211_sched_scan_request *req)
2562 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2564 if (!sdata->local->ops->sched_scan_start)
2567 return ieee80211_request_sched_scan_start(sdata, req);
2571 ieee80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev,
2574 struct ieee80211_local *local = wiphy_priv(wiphy);
2576 if (!local->ops->sched_scan_stop)
2579 return ieee80211_request_sched_scan_stop(local);
2582 static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev,
2583 struct cfg80211_auth_request *req)
2585 return ieee80211_mgd_auth(IEEE80211_DEV_TO_SUB_IF(dev), req);
2588 static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev,
2589 struct cfg80211_assoc_request *req)
2591 return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
2594 static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev,
2595 struct cfg80211_deauth_request *req)
2597 return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev), req);
2600 static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
2601 struct cfg80211_disassoc_request *req)
2603 return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
2606 static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
2607 struct cfg80211_ibss_params *params)
2609 return ieee80211_ibss_join(IEEE80211_DEV_TO_SUB_IF(dev), params);
2612 static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
2614 return ieee80211_ibss_leave(IEEE80211_DEV_TO_SUB_IF(dev));
2617 static int ieee80211_join_ocb(struct wiphy *wiphy, struct net_device *dev,
2618 struct ocb_setup *setup)
2620 return ieee80211_ocb_join(IEEE80211_DEV_TO_SUB_IF(dev), setup);
2623 static int ieee80211_leave_ocb(struct wiphy *wiphy, struct net_device *dev)
2625 return ieee80211_ocb_leave(IEEE80211_DEV_TO_SUB_IF(dev));
2628 static int ieee80211_set_mcast_rate(struct wiphy *wiphy, struct net_device *dev,
2629 int rate[NUM_NL80211_BANDS])
2631 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2633 memcpy(sdata->vif.bss_conf.mcast_rate, rate,
2634 sizeof(int) * NUM_NL80211_BANDS);
2636 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_MCAST_RATE);
2641 static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
2643 struct ieee80211_local *local = wiphy_priv(wiphy);
2646 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
2647 ieee80211_check_fast_xmit_all(local);
2649 err = drv_set_frag_threshold(local, wiphy->frag_threshold);
2652 ieee80211_check_fast_xmit_all(local);
2657 if ((changed & WIPHY_PARAM_COVERAGE_CLASS) ||
2658 (changed & WIPHY_PARAM_DYN_ACK)) {
2661 coverage_class = changed & WIPHY_PARAM_COVERAGE_CLASS ?
2662 wiphy->coverage_class : -1;
2663 err = drv_set_coverage_class(local, coverage_class);
2669 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
2670 err = drv_set_rts_threshold(local, wiphy->rts_threshold);
2676 if (changed & WIPHY_PARAM_RETRY_SHORT) {
2677 if (wiphy->retry_short > IEEE80211_MAX_TX_RETRY)
2679 local->hw.conf.short_frame_max_tx_count = wiphy->retry_short;
2681 if (changed & WIPHY_PARAM_RETRY_LONG) {
2682 if (wiphy->retry_long > IEEE80211_MAX_TX_RETRY)
2684 local->hw.conf.long_frame_max_tx_count = wiphy->retry_long;
2687 (WIPHY_PARAM_RETRY_SHORT | WIPHY_PARAM_RETRY_LONG))
2688 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS);
2690 if (changed & (WIPHY_PARAM_TXQ_LIMIT |
2691 WIPHY_PARAM_TXQ_MEMORY_LIMIT |
2692 WIPHY_PARAM_TXQ_QUANTUM))
2693 ieee80211_txq_set_params(local);
2698 static int ieee80211_set_tx_power(struct wiphy *wiphy,
2699 struct wireless_dev *wdev,
2700 enum nl80211_tx_power_setting type, int mbm)
2702 struct ieee80211_local *local = wiphy_priv(wiphy);
2703 struct ieee80211_sub_if_data *sdata;
2704 enum nl80211_tx_power_setting txp_type = type;
2705 bool update_txp_type = false;
2706 bool has_monitor = false;
2709 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
2711 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) {
2712 sdata = wiphy_dereference(local->hw.wiphy,
2713 local->monitor_sdata);
2719 case NL80211_TX_POWER_AUTOMATIC:
2720 sdata->user_power_level = IEEE80211_UNSET_POWER_LEVEL;
2721 txp_type = NL80211_TX_POWER_LIMITED;
2723 case NL80211_TX_POWER_LIMITED:
2724 case NL80211_TX_POWER_FIXED:
2725 if (mbm < 0 || (mbm % 100))
2727 sdata->user_power_level = MBM_TO_DBM(mbm);
2731 if (txp_type != sdata->vif.bss_conf.txpower_type) {
2732 update_txp_type = true;
2733 sdata->vif.bss_conf.txpower_type = txp_type;
2736 ieee80211_recalc_txpower(sdata, update_txp_type);
2742 case NL80211_TX_POWER_AUTOMATIC:
2743 local->user_power_level = IEEE80211_UNSET_POWER_LEVEL;
2744 txp_type = NL80211_TX_POWER_LIMITED;
2746 case NL80211_TX_POWER_LIMITED:
2747 case NL80211_TX_POWER_FIXED:
2748 if (mbm < 0 || (mbm % 100))
2750 local->user_power_level = MBM_TO_DBM(mbm);
2754 mutex_lock(&local->iflist_mtx);
2755 list_for_each_entry(sdata, &local->interfaces, list) {
2756 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) {
2760 sdata->user_power_level = local->user_power_level;
2761 if (txp_type != sdata->vif.bss_conf.txpower_type)
2762 update_txp_type = true;
2763 sdata->vif.bss_conf.txpower_type = txp_type;
2765 list_for_each_entry(sdata, &local->interfaces, list) {
2766 if (sdata->vif.type == NL80211_IFTYPE_MONITOR)
2768 ieee80211_recalc_txpower(sdata, update_txp_type);
2770 mutex_unlock(&local->iflist_mtx);
2773 sdata = wiphy_dereference(local->hw.wiphy,
2774 local->monitor_sdata);
2776 sdata->user_power_level = local->user_power_level;
2777 if (txp_type != sdata->vif.bss_conf.txpower_type)
2778 update_txp_type = true;
2779 sdata->vif.bss_conf.txpower_type = txp_type;
2781 ieee80211_recalc_txpower(sdata, update_txp_type);
2788 static int ieee80211_get_tx_power(struct wiphy *wiphy,
2789 struct wireless_dev *wdev,
2792 struct ieee80211_local *local = wiphy_priv(wiphy);
2793 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
2795 if (local->ops->get_txpower)
2796 return drv_get_txpower(local, sdata, dbm);
2798 if (!local->use_chanctx)
2799 *dbm = local->hw.conf.power_level;
2801 *dbm = sdata->vif.bss_conf.txpower;
2806 static void ieee80211_rfkill_poll(struct wiphy *wiphy)
2808 struct ieee80211_local *local = wiphy_priv(wiphy);
2810 drv_rfkill_poll(local);
2813 #ifdef CONFIG_NL80211_TESTMODE
2814 static int ieee80211_testmode_cmd(struct wiphy *wiphy,
2815 struct wireless_dev *wdev,
2816 void *data, int len)
2818 struct ieee80211_local *local = wiphy_priv(wiphy);
2819 struct ieee80211_vif *vif = NULL;
2821 if (!local->ops->testmode_cmd)
2825 struct ieee80211_sub_if_data *sdata;
2827 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
2828 if (sdata->flags & IEEE80211_SDATA_IN_DRIVER)
2832 return local->ops->testmode_cmd(&local->hw, vif, data, len);
2835 static int ieee80211_testmode_dump(struct wiphy *wiphy,
2836 struct sk_buff *skb,
2837 struct netlink_callback *cb,
2838 void *data, int len)
2840 struct ieee80211_local *local = wiphy_priv(wiphy);
2842 if (!local->ops->testmode_dump)
2845 return local->ops->testmode_dump(&local->hw, skb, cb, data, len);
2849 int __ieee80211_request_smps_mgd(struct ieee80211_sub_if_data *sdata,
2850 enum ieee80211_smps_mode smps_mode)
2853 enum ieee80211_smps_mode old_req;
2855 struct sta_info *sta;
2856 bool tdls_peer_found = false;
2858 lockdep_assert_held(&sdata->wdev.mtx);
2860 if (WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION))
2863 old_req = sdata->u.mgd.req_smps;
2864 sdata->u.mgd.req_smps = smps_mode;
2866 if (old_req == smps_mode &&
2867 smps_mode != IEEE80211_SMPS_AUTOMATIC)
2871 * If not associated, or current association is not an HT
2872 * association, there's no need to do anything, just store
2873 * the new value until we associate.
2875 if (!sdata->u.mgd.associated ||
2876 sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT)
2879 ap = sdata->u.mgd.associated->bssid;
2882 list_for_each_entry_rcu(sta, &sdata->local->sta_list, list) {
2883 if (!sta->sta.tdls || sta->sdata != sdata || !sta->uploaded ||
2884 !test_sta_flag(sta, WLAN_STA_AUTHORIZED))
2887 tdls_peer_found = true;
2892 if (smps_mode == IEEE80211_SMPS_AUTOMATIC) {
2893 if (tdls_peer_found || !sdata->u.mgd.powersave)
2894 smps_mode = IEEE80211_SMPS_OFF;
2896 smps_mode = IEEE80211_SMPS_DYNAMIC;
2899 /* send SM PS frame to AP */
2900 err = ieee80211_send_smps_action(sdata, smps_mode,
2903 sdata->u.mgd.req_smps = old_req;
2904 else if (smps_mode != IEEE80211_SMPS_OFF && tdls_peer_found)
2905 ieee80211_teardown_tdls_peers(sdata);
2910 static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
2911 bool enabled, int timeout)
2913 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2914 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2916 if (sdata->vif.type != NL80211_IFTYPE_STATION)
2919 if (!ieee80211_hw_check(&local->hw, SUPPORTS_PS))
2922 if (enabled == sdata->u.mgd.powersave &&
2923 timeout == local->dynamic_ps_forced_timeout)
2926 sdata->u.mgd.powersave = enabled;
2927 local->dynamic_ps_forced_timeout = timeout;
2929 /* no change, but if automatic follow powersave */
2931 __ieee80211_request_smps_mgd(sdata, sdata->u.mgd.req_smps);
2932 sdata_unlock(sdata);
2934 if (ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS))
2935 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
2937 ieee80211_recalc_ps(local);
2938 ieee80211_recalc_ps_vif(sdata);
2939 ieee80211_check_fast_rx_iface(sdata);
2944 static int ieee80211_set_cqm_rssi_config(struct wiphy *wiphy,
2945 struct net_device *dev,
2946 s32 rssi_thold, u32 rssi_hyst)
2948 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2949 struct ieee80211_vif *vif = &sdata->vif;
2950 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
2952 if (rssi_thold == bss_conf->cqm_rssi_thold &&
2953 rssi_hyst == bss_conf->cqm_rssi_hyst)
2956 if (sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER &&
2957 !(sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI))
2960 bss_conf->cqm_rssi_thold = rssi_thold;
2961 bss_conf->cqm_rssi_hyst = rssi_hyst;
2962 bss_conf->cqm_rssi_low = 0;
2963 bss_conf->cqm_rssi_high = 0;
2964 sdata->u.mgd.last_cqm_event_signal = 0;
2966 /* tell the driver upon association, unless already associated */
2967 if (sdata->u.mgd.associated &&
2968 sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)
2969 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_CQM);
2974 static int ieee80211_set_cqm_rssi_range_config(struct wiphy *wiphy,
2975 struct net_device *dev,
2976 s32 rssi_low, s32 rssi_high)
2978 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2979 struct ieee80211_vif *vif = &sdata->vif;
2980 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
2982 if (sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER)
2985 bss_conf->cqm_rssi_low = rssi_low;
2986 bss_conf->cqm_rssi_high = rssi_high;
2987 bss_conf->cqm_rssi_thold = 0;
2988 bss_conf->cqm_rssi_hyst = 0;
2989 sdata->u.mgd.last_cqm_event_signal = 0;
2991 /* tell the driver upon association, unless already associated */
2992 if (sdata->u.mgd.associated &&
2993 sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)
2994 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_CQM);
2999 static int ieee80211_set_bitrate_mask(struct wiphy *wiphy,
3000 struct net_device *dev,
3002 const struct cfg80211_bitrate_mask *mask)
3004 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3005 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
3008 if (!ieee80211_sdata_running(sdata))
3012 * If active validate the setting and reject it if it doesn't leave
3013 * at least one basic rate usable, since we really have to be able
3014 * to send something, and if we're an AP we have to be able to do
3015 * so at a basic rate so that all clients can receive it.
3017 if (rcu_access_pointer(sdata->vif.chanctx_conf) &&
3018 sdata->vif.bss_conf.chandef.chan) {
3019 u32 basic_rates = sdata->vif.bss_conf.basic_rates;
3020 enum nl80211_band band = sdata->vif.bss_conf.chandef.chan->band;
3022 if (!(mask->control[band].legacy & basic_rates))
3026 if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) {
3027 ret = drv_set_bitrate_mask(local, sdata, mask);
3032 for (i = 0; i < NUM_NL80211_BANDS; i++) {
3033 struct ieee80211_supported_band *sband = wiphy->bands[i];
3036 sdata->rc_rateidx_mask[i] = mask->control[i].legacy;
3037 memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].ht_mcs,
3038 sizeof(mask->control[i].ht_mcs));
3039 memcpy(sdata->rc_rateidx_vht_mcs_mask[i],
3040 mask->control[i].vht_mcs,
3041 sizeof(mask->control[i].vht_mcs));
3043 sdata->rc_has_mcs_mask[i] = false;
3044 sdata->rc_has_vht_mcs_mask[i] = false;
3048 for (j = 0; j < IEEE80211_HT_MCS_MASK_LEN; j++) {
3049 if (sdata->rc_rateidx_mcs_mask[i][j] != 0xff) {
3050 sdata->rc_has_mcs_mask[i] = true;
3055 for (j = 0; j < NL80211_VHT_NSS_MAX; j++) {
3056 if (sdata->rc_rateidx_vht_mcs_mask[i][j] != 0xffff) {
3057 sdata->rc_has_vht_mcs_mask[i] = true;
3066 static int ieee80211_start_radar_detection(struct wiphy *wiphy,
3067 struct net_device *dev,
3068 struct cfg80211_chan_def *chandef,
3071 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3072 struct ieee80211_local *local = sdata->local;
3075 mutex_lock(&local->mtx);
3076 if (!list_empty(&local->roc_list) || local->scanning) {
3081 /* whatever, but channel contexts should not complain about that one */
3082 sdata->smps_mode = IEEE80211_SMPS_OFF;
3083 sdata->needed_rx_chains = local->rx_chains;
3085 err = ieee80211_vif_use_channel(sdata, chandef,
3086 IEEE80211_CHANCTX_SHARED);
3090 ieee80211_queue_delayed_work(&sdata->local->hw,
3091 &sdata->dfs_cac_timer_work,
3092 msecs_to_jiffies(cac_time_ms));
3095 mutex_unlock(&local->mtx);
3099 static void ieee80211_end_cac(struct wiphy *wiphy,
3100 struct net_device *dev)
3102 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3103 struct ieee80211_local *local = sdata->local;
3105 mutex_lock(&local->mtx);
3106 list_for_each_entry(sdata, &local->interfaces, list) {
3107 /* it might be waiting for the local->mtx, but then
3108 * by the time it gets it, sdata->wdev.cac_started
3109 * will no longer be true
3111 cancel_delayed_work(&sdata->dfs_cac_timer_work);
3113 if (sdata->wdev.cac_started) {
3114 ieee80211_vif_release_channel(sdata);
3115 sdata->wdev.cac_started = false;
3118 mutex_unlock(&local->mtx);
3121 static struct cfg80211_beacon_data *
3122 cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon)
3124 struct cfg80211_beacon_data *new_beacon;
3128 len = beacon->head_len + beacon->tail_len + beacon->beacon_ies_len +
3129 beacon->proberesp_ies_len + beacon->assocresp_ies_len +
3130 beacon->probe_resp_len + beacon->lci_len + beacon->civicloc_len;
3132 new_beacon = kzalloc(sizeof(*new_beacon) + len, GFP_KERNEL);
3136 pos = (u8 *)(new_beacon + 1);
3137 if (beacon->head_len) {
3138 new_beacon->head_len = beacon->head_len;
3139 new_beacon->head = pos;
3140 memcpy(pos, beacon->head, beacon->head_len);
3141 pos += beacon->head_len;
3143 if (beacon->tail_len) {
3144 new_beacon->tail_len = beacon->tail_len;
3145 new_beacon->tail = pos;
3146 memcpy(pos, beacon->tail, beacon->tail_len);
3147 pos += beacon->tail_len;
3149 if (beacon->beacon_ies_len) {
3150 new_beacon->beacon_ies_len = beacon->beacon_ies_len;
3151 new_beacon->beacon_ies = pos;
3152 memcpy(pos, beacon->beacon_ies, beacon->beacon_ies_len);
3153 pos += beacon->beacon_ies_len;
3155 if (beacon->proberesp_ies_len) {
3156 new_beacon->proberesp_ies_len = beacon->proberesp_ies_len;
3157 new_beacon->proberesp_ies = pos;
3158 memcpy(pos, beacon->proberesp_ies, beacon->proberesp_ies_len);
3159 pos += beacon->proberesp_ies_len;
3161 if (beacon->assocresp_ies_len) {
3162 new_beacon->assocresp_ies_len = beacon->assocresp_ies_len;
3163 new_beacon->assocresp_ies = pos;
3164 memcpy(pos, beacon->assocresp_ies, beacon->assocresp_ies_len);
3165 pos += beacon->assocresp_ies_len;
3167 if (beacon->probe_resp_len) {
3168 new_beacon->probe_resp_len = beacon->probe_resp_len;
3169 new_beacon->probe_resp = pos;
3170 memcpy(pos, beacon->probe_resp, beacon->probe_resp_len);
3171 pos += beacon->probe_resp_len;
3174 /* might copy -1, meaning no changes requested */
3175 new_beacon->ftm_responder = beacon->ftm_responder;
3177 new_beacon->lci_len = beacon->lci_len;
3178 new_beacon->lci = pos;
3179 memcpy(pos, beacon->lci, beacon->lci_len);
3180 pos += beacon->lci_len;
3182 if (beacon->civicloc) {
3183 new_beacon->civicloc_len = beacon->civicloc_len;
3184 new_beacon->civicloc = pos;
3185 memcpy(pos, beacon->civicloc, beacon->civicloc_len);
3186 pos += beacon->civicloc_len;
3192 void ieee80211_csa_finish(struct ieee80211_vif *vif)
3194 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
3196 ieee80211_queue_work(&sdata->local->hw,
3197 &sdata->csa_finalize_work);
3199 EXPORT_SYMBOL(ieee80211_csa_finish);
3201 static int ieee80211_set_after_csa_beacon(struct ieee80211_sub_if_data *sdata,
3206 switch (sdata->vif.type) {
3207 case NL80211_IFTYPE_AP:
3208 err = ieee80211_assign_beacon(sdata, sdata->u.ap.next_beacon,
3210 kfree(sdata->u.ap.next_beacon);
3211 sdata->u.ap.next_beacon = NULL;
3217 case NL80211_IFTYPE_ADHOC:
3218 err = ieee80211_ibss_finish_csa(sdata);
3223 #ifdef CONFIG_MAC80211_MESH
3224 case NL80211_IFTYPE_MESH_POINT:
3225 err = ieee80211_mesh_finish_csa(sdata);
3239 static int __ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata)
3241 struct ieee80211_local *local = sdata->local;
3245 sdata_assert_lock(sdata);
3246 lockdep_assert_held(&local->mtx);
3247 lockdep_assert_held(&local->chanctx_mtx);
3250 * using reservation isn't immediate as it may be deferred until later
3251 * with multi-vif. once reservation is complete it will re-schedule the
3252 * work with no reserved_chanctx so verify chandef to check if it
3253 * completed successfully
3256 if (sdata->reserved_chanctx) {
3258 * with multi-vif csa driver may call ieee80211_csa_finish()
3259 * many times while waiting for other interfaces to use their
3262 if (sdata->reserved_ready)
3265 return ieee80211_vif_use_reserved_context(sdata);
3268 if (!cfg80211_chandef_identical(&sdata->vif.bss_conf.chandef,
3269 &sdata->csa_chandef))
3272 sdata->vif.csa_active = false;
3274 err = ieee80211_set_after_csa_beacon(sdata, &changed);
3278 ieee80211_bss_info_change_notify(sdata, changed);
3280 if (sdata->csa_block_tx) {
3281 ieee80211_wake_vif_queues(local, sdata,
3282 IEEE80211_QUEUE_STOP_REASON_CSA);
3283 sdata->csa_block_tx = false;
3286 err = drv_post_channel_switch(sdata);
3290 cfg80211_ch_switch_notify(sdata->dev, &sdata->csa_chandef);
3295 static void ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata)
3297 if (__ieee80211_csa_finalize(sdata)) {
3298 sdata_info(sdata, "failed to finalize CSA, disconnecting\n");
3299 cfg80211_stop_iface(sdata->local->hw.wiphy, &sdata->wdev,
3304 void ieee80211_csa_finalize_work(struct work_struct *work)
3306 struct ieee80211_sub_if_data *sdata =
3307 container_of(work, struct ieee80211_sub_if_data,
3309 struct ieee80211_local *local = sdata->local;
3312 mutex_lock(&local->mtx);
3313 mutex_lock(&local->chanctx_mtx);
3315 /* AP might have been stopped while waiting for the lock. */
3316 if (!sdata->vif.csa_active)
3319 if (!ieee80211_sdata_running(sdata))
3322 ieee80211_csa_finalize(sdata);
3325 mutex_unlock(&local->chanctx_mtx);
3326 mutex_unlock(&local->mtx);
3327 sdata_unlock(sdata);
3330 static int ieee80211_set_csa_beacon(struct ieee80211_sub_if_data *sdata,
3331 struct cfg80211_csa_settings *params,
3334 struct ieee80211_csa_settings csa = {};
3337 switch (sdata->vif.type) {
3338 case NL80211_IFTYPE_AP:
3339 sdata->u.ap.next_beacon =
3340 cfg80211_beacon_dup(¶ms->beacon_after);
3341 if (!sdata->u.ap.next_beacon)
3345 * With a count of 0, we don't have to wait for any
3346 * TBTT before switching, so complete the CSA
3347 * immediately. In theory, with a count == 1 we
3348 * should delay the switch until just before the next
3349 * TBTT, but that would complicate things so we switch
3350 * immediately too. If we would delay the switch
3351 * until the next TBTT, we would have to set the probe
3354 * TODO: A channel switch with count <= 1 without
3355 * sending a CSA action frame is kind of useless,
3356 * because the clients won't know we're changing
3357 * channels. The action frame must be implemented
3358 * either here or in the userspace.
3360 if (params->count <= 1)
3363 if ((params->n_counter_offsets_beacon >
3364 IEEE80211_MAX_CNTDWN_COUNTERS_NUM) ||
3365 (params->n_counter_offsets_presp >
3366 IEEE80211_MAX_CNTDWN_COUNTERS_NUM))
3369 csa.counter_offsets_beacon = params->counter_offsets_beacon;
3370 csa.counter_offsets_presp = params->counter_offsets_presp;
3371 csa.n_counter_offsets_beacon = params->n_counter_offsets_beacon;
3372 csa.n_counter_offsets_presp = params->n_counter_offsets_presp;
3373 csa.count = params->count;
3375 err = ieee80211_assign_beacon(sdata, ¶ms->beacon_csa, &csa, NULL);
3377 kfree(sdata->u.ap.next_beacon);
3383 case NL80211_IFTYPE_ADHOC:
3384 if (!sdata->vif.bss_conf.ibss_joined)
3387 if (params->chandef.width != sdata->u.ibss.chandef.width)
3390 switch (params->chandef.width) {
3391 case NL80211_CHAN_WIDTH_40:
3392 if (cfg80211_get_chandef_type(¶ms->chandef) !=
3393 cfg80211_get_chandef_type(&sdata->u.ibss.chandef))
3396 case NL80211_CHAN_WIDTH_5:
3397 case NL80211_CHAN_WIDTH_10:
3398 case NL80211_CHAN_WIDTH_20_NOHT:
3399 case NL80211_CHAN_WIDTH_20:
3405 /* changes into another band are not supported */
3406 if (sdata->u.ibss.chandef.chan->band !=
3407 params->chandef.chan->band)
3410 /* see comments in the NL80211_IFTYPE_AP block */
3411 if (params->count > 1) {
3412 err = ieee80211_ibss_csa_beacon(sdata, params);
3418 ieee80211_send_action_csa(sdata, params);
3421 #ifdef CONFIG_MAC80211_MESH
3422 case NL80211_IFTYPE_MESH_POINT: {
3423 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
3425 if (params->chandef.width != sdata->vif.bss_conf.chandef.width)
3428 /* changes into another band are not supported */
3429 if (sdata->vif.bss_conf.chandef.chan->band !=
3430 params->chandef.chan->band)
3433 if (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_NONE) {
3434 ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_INIT;
3435 if (!ifmsh->pre_value)
3436 ifmsh->pre_value = 1;
3441 /* see comments in the NL80211_IFTYPE_AP block */
3442 if (params->count > 1) {
3443 err = ieee80211_mesh_csa_beacon(sdata, params);
3445 ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_NONE;
3451 if (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_INIT)
3452 ieee80211_send_action_csa(sdata, params);
3464 static void ieee80211_color_change_abort(struct ieee80211_sub_if_data *sdata)
3466 sdata->vif.color_change_active = false;
3467 kfree(sdata->u.ap.next_beacon);
3468 sdata->u.ap.next_beacon = NULL;
3470 cfg80211_color_change_aborted_notify(sdata->dev);
3474 __ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
3475 struct cfg80211_csa_settings *params)
3477 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3478 struct ieee80211_local *local = sdata->local;
3479 struct ieee80211_channel_switch ch_switch;
3480 struct ieee80211_chanctx_conf *conf;
3481 struct ieee80211_chanctx *chanctx;
3485 sdata_assert_lock(sdata);
3486 lockdep_assert_held(&local->mtx);
3488 if (!list_empty(&local->roc_list) || local->scanning)
3491 if (sdata->wdev.cac_started)
3494 if (cfg80211_chandef_identical(¶ms->chandef,
3495 &sdata->vif.bss_conf.chandef))
3498 /* don't allow another channel switch if one is already active. */
3499 if (sdata->vif.csa_active)
3502 mutex_lock(&local->chanctx_mtx);
3503 conf = rcu_dereference_protected(sdata->vif.chanctx_conf,
3504 lockdep_is_held(&local->chanctx_mtx));
3510 if (params->chandef.chan->freq_offset) {
3511 /* this may work, but is untested */
3516 chanctx = container_of(conf, struct ieee80211_chanctx, conf);
3518 ch_switch.timestamp = 0;
3519 ch_switch.device_timestamp = 0;
3520 ch_switch.block_tx = params->block_tx;
3521 ch_switch.chandef = params->chandef;
3522 ch_switch.count = params->count;
3524 err = drv_pre_channel_switch(sdata, &ch_switch);
3528 err = ieee80211_vif_reserve_chanctx(sdata, ¶ms->chandef,
3530 params->radar_required);
3534 /* if reservation is invalid then this will fail */
3535 err = ieee80211_check_combinations(sdata, NULL, chanctx->mode, 0);
3537 ieee80211_vif_unreserve_chanctx(sdata);
3541 /* if there is a color change in progress, abort it */
3542 if (sdata->vif.color_change_active)
3543 ieee80211_color_change_abort(sdata);
3545 err = ieee80211_set_csa_beacon(sdata, params, &changed);
3547 ieee80211_vif_unreserve_chanctx(sdata);
3551 sdata->csa_chandef = params->chandef;
3552 sdata->csa_block_tx = params->block_tx;
3553 sdata->vif.csa_active = true;
3555 if (sdata->csa_block_tx)
3556 ieee80211_stop_vif_queues(local, sdata,
3557 IEEE80211_QUEUE_STOP_REASON_CSA);
3559 cfg80211_ch_switch_started_notify(sdata->dev, &sdata->csa_chandef,
3560 params->count, params->block_tx);
3563 ieee80211_bss_info_change_notify(sdata, changed);
3564 drv_channel_switch_beacon(sdata, ¶ms->chandef);
3566 /* if the beacon didn't change, we can finalize immediately */
3567 ieee80211_csa_finalize(sdata);
3571 mutex_unlock(&local->chanctx_mtx);
3575 int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
3576 struct cfg80211_csa_settings *params)
3578 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3579 struct ieee80211_local *local = sdata->local;
3582 mutex_lock(&local->mtx);
3583 err = __ieee80211_channel_switch(wiphy, dev, params);
3584 mutex_unlock(&local->mtx);
3589 u64 ieee80211_mgmt_tx_cookie(struct ieee80211_local *local)
3591 lockdep_assert_held(&local->mtx);
3593 local->roc_cookie_counter++;
3595 /* wow, you wrapped 64 bits ... more likely a bug */
3596 if (WARN_ON(local->roc_cookie_counter == 0))
3597 local->roc_cookie_counter++;
3599 return local->roc_cookie_counter;
3602 int ieee80211_attach_ack_skb(struct ieee80211_local *local, struct sk_buff *skb,
3603 u64 *cookie, gfp_t gfp)
3605 unsigned long spin_flags;
3606 struct sk_buff *ack_skb;
3609 ack_skb = skb_copy(skb, gfp);
3613 spin_lock_irqsave(&local->ack_status_lock, spin_flags);
3614 id = idr_alloc(&local->ack_status_frames, ack_skb,
3615 1, 0x2000, GFP_ATOMIC);
3616 spin_unlock_irqrestore(&local->ack_status_lock, spin_flags);
3623 IEEE80211_SKB_CB(skb)->ack_frame_id = id;
3625 *cookie = ieee80211_mgmt_tx_cookie(local);
3626 IEEE80211_SKB_CB(ack_skb)->ack.cookie = *cookie;
3632 ieee80211_update_mgmt_frame_registrations(struct wiphy *wiphy,
3633 struct wireless_dev *wdev,
3634 struct mgmt_frame_regs *upd)
3636 struct ieee80211_local *local = wiphy_priv(wiphy);
3637 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
3638 u32 preq_mask = BIT(IEEE80211_STYPE_PROBE_REQ >> 4);
3639 u32 action_mask = BIT(IEEE80211_STYPE_ACTION >> 4);
3640 bool global_change, intf_change;
3643 (local->probe_req_reg != !!(upd->global_stypes & preq_mask)) ||
3644 (local->rx_mcast_action_reg !=
3645 !!(upd->global_mcast_stypes & action_mask));
3646 local->probe_req_reg = upd->global_stypes & preq_mask;
3647 local->rx_mcast_action_reg = upd->global_mcast_stypes & action_mask;
3649 intf_change = (sdata->vif.probe_req_reg !=
3650 !!(upd->interface_stypes & preq_mask)) ||
3651 (sdata->vif.rx_mcast_action_reg !=
3652 !!(upd->interface_mcast_stypes & action_mask));
3653 sdata->vif.probe_req_reg = upd->interface_stypes & preq_mask;
3654 sdata->vif.rx_mcast_action_reg =
3655 upd->interface_mcast_stypes & action_mask;
3657 if (!local->open_count)
3660 if (intf_change && ieee80211_sdata_running(sdata))
3661 drv_config_iface_filter(local, sdata,
3662 sdata->vif.probe_req_reg ?
3667 ieee80211_configure_filter(local);
3670 static int ieee80211_set_antenna(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant)
3672 struct ieee80211_local *local = wiphy_priv(wiphy);
3677 return drv_set_antenna(local, tx_ant, rx_ant);
3680 static int ieee80211_get_antenna(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant)
3682 struct ieee80211_local *local = wiphy_priv(wiphy);
3684 return drv_get_antenna(local, tx_ant, rx_ant);
3687 static int ieee80211_set_rekey_data(struct wiphy *wiphy,
3688 struct net_device *dev,
3689 struct cfg80211_gtk_rekey_data *data)
3691 struct ieee80211_local *local = wiphy_priv(wiphy);
3692 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3694 if (!local->ops->set_rekey_data)
3697 drv_set_rekey_data(local, sdata, data);
3702 static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev,
3703 const u8 *peer, u64 *cookie)
3705 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3706 struct ieee80211_local *local = sdata->local;
3707 struct ieee80211_qos_hdr *nullfunc;
3708 struct sk_buff *skb;
3709 int size = sizeof(*nullfunc);
3712 struct ieee80211_tx_info *info;
3713 struct sta_info *sta;
3714 struct ieee80211_chanctx_conf *chanctx_conf;
3715 enum nl80211_band band;
3718 /* the lock is needed to assign the cookie later */
3719 mutex_lock(&local->mtx);
3722 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
3723 if (WARN_ON(!chanctx_conf)) {
3727 band = chanctx_conf->def.chan->band;
3728 sta = sta_info_get_bss(sdata, peer);
3737 fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
3738 IEEE80211_STYPE_QOS_NULLFUNC |
3739 IEEE80211_FCTL_FROMDS);
3742 fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
3743 IEEE80211_STYPE_NULLFUNC |
3744 IEEE80211_FCTL_FROMDS);
3747 skb = dev_alloc_skb(local->hw.extra_tx_headroom + size);
3755 skb_reserve(skb, local->hw.extra_tx_headroom);
3757 nullfunc = skb_put(skb, size);
3758 nullfunc->frame_control = fc;
3759 nullfunc->duration_id = 0;
3760 memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN);
3761 memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN);
3762 memcpy(nullfunc->addr3, sdata->vif.addr, ETH_ALEN);
3763 nullfunc->seq_ctrl = 0;
3765 info = IEEE80211_SKB_CB(skb);
3767 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS |
3768 IEEE80211_TX_INTFL_NL80211_FRAME_TX;
3771 skb_set_queue_mapping(skb, IEEE80211_AC_VO);
3774 nullfunc->qos_ctrl = cpu_to_le16(7);
3776 ret = ieee80211_attach_ack_skb(local, skb, cookie, GFP_ATOMIC);
3783 ieee80211_xmit(sdata, sta, skb);
3789 mutex_unlock(&local->mtx);
3794 static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
3795 struct wireless_dev *wdev,
3796 struct cfg80211_chan_def *chandef)
3798 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
3799 struct ieee80211_local *local = wiphy_priv(wiphy);
3800 struct ieee80211_chanctx_conf *chanctx_conf;
3804 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
3806 *chandef = sdata->vif.bss_conf.chandef;
3808 } else if (local->open_count > 0 &&
3809 local->open_count == local->monitors &&
3810 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
3811 if (local->use_chanctx)
3812 *chandef = local->monitor_chandef;
3814 *chandef = local->_oper_chandef;
3823 static void ieee80211_set_wakeup(struct wiphy *wiphy, bool enabled)
3825 drv_set_wakeup(wiphy_priv(wiphy), enabled);
3829 static int ieee80211_set_qos_map(struct wiphy *wiphy,
3830 struct net_device *dev,
3831 struct cfg80211_qos_map *qos_map)
3833 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3834 struct mac80211_qos_map *new_qos_map, *old_qos_map;
3837 new_qos_map = kzalloc(sizeof(*new_qos_map), GFP_KERNEL);
3840 memcpy(&new_qos_map->qos_map, qos_map, sizeof(*qos_map));
3842 /* A NULL qos_map was passed to disable QoS mapping */
3846 old_qos_map = sdata_dereference(sdata->qos_map, sdata);
3847 rcu_assign_pointer(sdata->qos_map, new_qos_map);
3849 kfree_rcu(old_qos_map, rcu_head);
3854 static int ieee80211_set_ap_chanwidth(struct wiphy *wiphy,
3855 struct net_device *dev,
3856 struct cfg80211_chan_def *chandef)
3858 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3862 ret = ieee80211_vif_change_bandwidth(sdata, chandef, &changed);
3864 ieee80211_bss_info_change_notify(sdata, changed);
3869 static int ieee80211_add_tx_ts(struct wiphy *wiphy, struct net_device *dev,
3870 u8 tsid, const u8 *peer, u8 up,
3873 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3874 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
3875 int ac = ieee802_1d_to_ac[up];
3877 if (sdata->vif.type != NL80211_IFTYPE_STATION)
3880 if (!(sdata->wmm_acm & BIT(up)))
3883 if (ifmgd->tx_tspec[ac].admitted_time)
3886 if (admitted_time) {
3887 ifmgd->tx_tspec[ac].admitted_time = 32 * admitted_time;
3888 ifmgd->tx_tspec[ac].tsid = tsid;
3889 ifmgd->tx_tspec[ac].up = up;
3895 static int ieee80211_del_tx_ts(struct wiphy *wiphy, struct net_device *dev,
3896 u8 tsid, const u8 *peer)
3898 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3899 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
3900 struct ieee80211_local *local = wiphy_priv(wiphy);
3903 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
3904 struct ieee80211_sta_tx_tspec *tx_tspec = &ifmgd->tx_tspec[ac];
3906 /* skip unused entries */
3907 if (!tx_tspec->admitted_time)
3910 if (tx_tspec->tsid != tsid)
3913 /* due to this new packets will be reassigned to non-ACM ACs */
3916 /* Make sure that all packets have been sent to avoid to
3917 * restore the QoS params on packets that are still on the
3921 ieee80211_flush_queues(local, sdata, false);
3923 /* restore the normal QoS parameters
3924 * (unconditionally to avoid races)
3926 tx_tspec->action = TX_TSPEC_ACTION_STOP_DOWNGRADE;
3927 tx_tspec->downgraded = false;
3928 ieee80211_sta_handle_tspec_ac_params(sdata);
3930 /* finally clear all the data */
3931 memset(tx_tspec, 0, sizeof(*tx_tspec));
3939 void ieee80211_nan_func_terminated(struct ieee80211_vif *vif,
3941 enum nl80211_nan_func_term_reason reason,
3944 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
3945 struct cfg80211_nan_func *func;
3948 if (WARN_ON(vif->type != NL80211_IFTYPE_NAN))
3951 spin_lock_bh(&sdata->u.nan.func_lock);
3953 func = idr_find(&sdata->u.nan.function_inst_ids, inst_id);
3954 if (WARN_ON(!func)) {
3955 spin_unlock_bh(&sdata->u.nan.func_lock);
3959 cookie = func->cookie;
3960 idr_remove(&sdata->u.nan.function_inst_ids, inst_id);
3962 spin_unlock_bh(&sdata->u.nan.func_lock);
3964 cfg80211_free_nan_func(func);
3966 cfg80211_nan_func_terminated(ieee80211_vif_to_wdev(vif), inst_id,
3967 reason, cookie, gfp);
3969 EXPORT_SYMBOL(ieee80211_nan_func_terminated);
3971 void ieee80211_nan_func_match(struct ieee80211_vif *vif,
3972 struct cfg80211_nan_match_params *match,
3975 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
3976 struct cfg80211_nan_func *func;
3978 if (WARN_ON(vif->type != NL80211_IFTYPE_NAN))
3981 spin_lock_bh(&sdata->u.nan.func_lock);
3983 func = idr_find(&sdata->u.nan.function_inst_ids, match->inst_id);
3984 if (WARN_ON(!func)) {
3985 spin_unlock_bh(&sdata->u.nan.func_lock);
3988 match->cookie = func->cookie;
3990 spin_unlock_bh(&sdata->u.nan.func_lock);
3992 cfg80211_nan_match(ieee80211_vif_to_wdev(vif), match, gfp);
3994 EXPORT_SYMBOL(ieee80211_nan_func_match);
3996 static int ieee80211_set_multicast_to_unicast(struct wiphy *wiphy,
3997 struct net_device *dev,
4000 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4002 sdata->u.ap.multicast_to_unicast = enabled;
4007 void ieee80211_fill_txq_stats(struct cfg80211_txq_stats *txqstats,
4008 struct txq_info *txqi)
4010 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_BACKLOG_BYTES))) {
4011 txqstats->filled |= BIT(NL80211_TXQ_STATS_BACKLOG_BYTES);
4012 txqstats->backlog_bytes = txqi->tin.backlog_bytes;
4015 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_BACKLOG_PACKETS))) {
4016 txqstats->filled |= BIT(NL80211_TXQ_STATS_BACKLOG_PACKETS);
4017 txqstats->backlog_packets = txqi->tin.backlog_packets;
4020 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_FLOWS))) {
4021 txqstats->filled |= BIT(NL80211_TXQ_STATS_FLOWS);
4022 txqstats->flows = txqi->tin.flows;
4025 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_DROPS))) {
4026 txqstats->filled |= BIT(NL80211_TXQ_STATS_DROPS);
4027 txqstats->drops = txqi->cstats.drop_count;
4030 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_ECN_MARKS))) {
4031 txqstats->filled |= BIT(NL80211_TXQ_STATS_ECN_MARKS);
4032 txqstats->ecn_marks = txqi->cstats.ecn_mark;
4035 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_OVERLIMIT))) {
4036 txqstats->filled |= BIT(NL80211_TXQ_STATS_OVERLIMIT);
4037 txqstats->overlimit = txqi->tin.overlimit;
4040 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_COLLISIONS))) {
4041 txqstats->filled |= BIT(NL80211_TXQ_STATS_COLLISIONS);
4042 txqstats->collisions = txqi->tin.collisions;
4045 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_TX_BYTES))) {
4046 txqstats->filled |= BIT(NL80211_TXQ_STATS_TX_BYTES);
4047 txqstats->tx_bytes = txqi->tin.tx_bytes;
4050 if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_TX_PACKETS))) {
4051 txqstats->filled |= BIT(NL80211_TXQ_STATS_TX_PACKETS);
4052 txqstats->tx_packets = txqi->tin.tx_packets;
4056 static int ieee80211_get_txq_stats(struct wiphy *wiphy,
4057 struct wireless_dev *wdev,
4058 struct cfg80211_txq_stats *txqstats)
4060 struct ieee80211_local *local = wiphy_priv(wiphy);
4061 struct ieee80211_sub_if_data *sdata;
4064 if (!local->ops->wake_tx_queue)
4067 spin_lock_bh(&local->fq.lock);
4071 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
4072 if (!sdata->vif.txq) {
4076 ieee80211_fill_txq_stats(txqstats, to_txq_info(sdata->vif.txq));
4079 txqstats->filled |= BIT(NL80211_TXQ_STATS_BACKLOG_PACKETS) |
4080 BIT(NL80211_TXQ_STATS_BACKLOG_BYTES) |
4081 BIT(NL80211_TXQ_STATS_OVERLIMIT) |
4082 BIT(NL80211_TXQ_STATS_OVERMEMORY) |
4083 BIT(NL80211_TXQ_STATS_COLLISIONS) |
4084 BIT(NL80211_TXQ_STATS_MAX_FLOWS);
4085 txqstats->backlog_packets = local->fq.backlog;
4086 txqstats->backlog_bytes = local->fq.memory_usage;
4087 txqstats->overlimit = local->fq.overlimit;
4088 txqstats->overmemory = local->fq.overmemory;
4089 txqstats->collisions = local->fq.collisions;
4090 txqstats->max_flows = local->fq.flows_cnt;
4095 spin_unlock_bh(&local->fq.lock);
4101 ieee80211_get_ftm_responder_stats(struct wiphy *wiphy,
4102 struct net_device *dev,
4103 struct cfg80211_ftm_responder_stats *ftm_stats)
4105 struct ieee80211_local *local = wiphy_priv(wiphy);
4106 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4108 return drv_get_ftm_responder_stats(local, sdata, ftm_stats);
4112 ieee80211_start_pmsr(struct wiphy *wiphy, struct wireless_dev *dev,
4113 struct cfg80211_pmsr_request *request)
4115 struct ieee80211_local *local = wiphy_priv(wiphy);
4116 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(dev);
4118 return drv_start_pmsr(local, sdata, request);
4122 ieee80211_abort_pmsr(struct wiphy *wiphy, struct wireless_dev *dev,
4123 struct cfg80211_pmsr_request *request)
4125 struct ieee80211_local *local = wiphy_priv(wiphy);
4126 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(dev);
4128 return drv_abort_pmsr(local, sdata, request);
4131 static int ieee80211_set_tid_config(struct wiphy *wiphy,
4132 struct net_device *dev,
4133 struct cfg80211_tid_config *tid_conf)
4135 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4136 struct sta_info *sta;
4139 if (!sdata->local->ops->set_tid_config)
4142 if (!tid_conf->peer)
4143 return drv_set_tid_config(sdata->local, sdata, NULL, tid_conf);
4145 mutex_lock(&sdata->local->sta_mtx);
4146 sta = sta_info_get_bss(sdata, tid_conf->peer);
4148 mutex_unlock(&sdata->local->sta_mtx);
4152 ret = drv_set_tid_config(sdata->local, sdata, &sta->sta, tid_conf);
4153 mutex_unlock(&sdata->local->sta_mtx);
4158 static int ieee80211_reset_tid_config(struct wiphy *wiphy,
4159 struct net_device *dev,
4160 const u8 *peer, u8 tids)
4162 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4163 struct sta_info *sta;
4166 if (!sdata->local->ops->reset_tid_config)
4170 return drv_reset_tid_config(sdata->local, sdata, NULL, tids);
4172 mutex_lock(&sdata->local->sta_mtx);
4173 sta = sta_info_get_bss(sdata, peer);
4175 mutex_unlock(&sdata->local->sta_mtx);
4179 ret = drv_reset_tid_config(sdata->local, sdata, &sta->sta, tids);
4180 mutex_unlock(&sdata->local->sta_mtx);
4185 static int ieee80211_set_sar_specs(struct wiphy *wiphy,
4186 struct cfg80211_sar_specs *sar)
4188 struct ieee80211_local *local = wiphy_priv(wiphy);
4190 if (!local->ops->set_sar_specs)
4193 return local->ops->set_sar_specs(&local->hw, sar);
4197 ieee80211_set_after_color_change_beacon(struct ieee80211_sub_if_data *sdata,
4200 switch (sdata->vif.type) {
4201 case NL80211_IFTYPE_AP: {
4204 ret = ieee80211_assign_beacon(sdata, sdata->u.ap.next_beacon,
4206 kfree(sdata->u.ap.next_beacon);
4207 sdata->u.ap.next_beacon = NULL;
4224 ieee80211_set_color_change_beacon(struct ieee80211_sub_if_data *sdata,
4225 struct cfg80211_color_change_settings *params,
4228 struct ieee80211_color_change_settings color_change = {};
4231 switch (sdata->vif.type) {
4232 case NL80211_IFTYPE_AP:
4233 sdata->u.ap.next_beacon =
4234 cfg80211_beacon_dup(¶ms->beacon_next);
4235 if (!sdata->u.ap.next_beacon)
4238 if (params->count <= 1)
4241 color_change.counter_offset_beacon =
4242 params->counter_offset_beacon;
4243 color_change.counter_offset_presp =
4244 params->counter_offset_presp;
4245 color_change.count = params->count;
4247 err = ieee80211_assign_beacon(sdata, ¶ms->beacon_color_change,
4248 NULL, &color_change);
4250 kfree(sdata->u.ap.next_beacon);
4263 ieee80211_color_change_bss_config_notify(struct ieee80211_sub_if_data *sdata,
4264 u8 color, int enable, u32 changed)
4266 sdata->vif.bss_conf.he_bss_color.color = color;
4267 sdata->vif.bss_conf.he_bss_color.enabled = enable;
4268 changed |= BSS_CHANGED_HE_BSS_COLOR;
4270 ieee80211_bss_info_change_notify(sdata, changed);
4273 static int ieee80211_color_change_finalize(struct ieee80211_sub_if_data *sdata)
4275 struct ieee80211_local *local = sdata->local;
4279 sdata_assert_lock(sdata);
4280 lockdep_assert_held(&local->mtx);
4282 sdata->vif.color_change_active = false;
4284 err = ieee80211_set_after_color_change_beacon(sdata, &changed);
4286 cfg80211_color_change_aborted_notify(sdata->dev);
4290 ieee80211_color_change_bss_config_notify(sdata,
4291 sdata->vif.color_change_color,
4293 cfg80211_color_change_notify(sdata->dev);
4298 void ieee80211_color_change_finalize_work(struct work_struct *work)
4300 struct ieee80211_sub_if_data *sdata =
4301 container_of(work, struct ieee80211_sub_if_data,
4302 color_change_finalize_work);
4303 struct ieee80211_local *local = sdata->local;
4306 mutex_lock(&local->mtx);
4308 /* AP might have been stopped while waiting for the lock. */
4309 if (!sdata->vif.color_change_active)
4312 if (!ieee80211_sdata_running(sdata))
4315 ieee80211_color_change_finalize(sdata);
4318 mutex_unlock(&local->mtx);
4319 sdata_unlock(sdata);
4322 void ieee80211_color_change_finish(struct ieee80211_vif *vif)
4324 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
4326 ieee80211_queue_work(&sdata->local->hw,
4327 &sdata->color_change_finalize_work);
4329 EXPORT_SYMBOL_GPL(ieee80211_color_change_finish);
4332 ieeee80211_obss_color_collision_notify(struct ieee80211_vif *vif,
4335 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
4337 if (sdata->vif.color_change_active || sdata->vif.csa_active)
4340 cfg80211_obss_color_collision_notify(sdata->dev, color_bitmap);
4342 EXPORT_SYMBOL_GPL(ieeee80211_obss_color_collision_notify);
4345 ieee80211_color_change(struct wiphy *wiphy, struct net_device *dev,
4346 struct cfg80211_color_change_settings *params)
4348 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4349 struct ieee80211_local *local = sdata->local;
4353 sdata_assert_lock(sdata);
4355 mutex_lock(&local->mtx);
4357 /* don't allow another color change if one is already active or if csa
4360 if (sdata->vif.color_change_active || sdata->vif.csa_active) {
4365 err = ieee80211_set_color_change_beacon(sdata, params, &changed);
4369 sdata->vif.color_change_active = true;
4370 sdata->vif.color_change_color = params->color;
4372 cfg80211_color_change_started_notify(sdata->dev, params->count);
4375 ieee80211_color_change_bss_config_notify(sdata, 0, 0, changed);
4377 /* if the beacon didn't change, we can finalize immediately */
4378 ieee80211_color_change_finalize(sdata);
4381 mutex_unlock(&local->mtx);
4386 const struct cfg80211_ops mac80211_config_ops = {
4387 .add_virtual_intf = ieee80211_add_iface,
4388 .del_virtual_intf = ieee80211_del_iface,
4389 .change_virtual_intf = ieee80211_change_iface,
4390 .start_p2p_device = ieee80211_start_p2p_device,
4391 .stop_p2p_device = ieee80211_stop_p2p_device,
4392 .add_key = ieee80211_add_key,
4393 .del_key = ieee80211_del_key,
4394 .get_key = ieee80211_get_key,
4395 .set_default_key = ieee80211_config_default_key,
4396 .set_default_mgmt_key = ieee80211_config_default_mgmt_key,
4397 .set_default_beacon_key = ieee80211_config_default_beacon_key,
4398 .start_ap = ieee80211_start_ap,
4399 .change_beacon = ieee80211_change_beacon,
4400 .stop_ap = ieee80211_stop_ap,
4401 .add_station = ieee80211_add_station,
4402 .del_station = ieee80211_del_station,
4403 .change_station = ieee80211_change_station,
4404 .get_station = ieee80211_get_station,
4405 .dump_station = ieee80211_dump_station,
4406 .dump_survey = ieee80211_dump_survey,
4407 #ifdef CONFIG_MAC80211_MESH
4408 .add_mpath = ieee80211_add_mpath,
4409 .del_mpath = ieee80211_del_mpath,
4410 .change_mpath = ieee80211_change_mpath,
4411 .get_mpath = ieee80211_get_mpath,
4412 .dump_mpath = ieee80211_dump_mpath,
4413 .get_mpp = ieee80211_get_mpp,
4414 .dump_mpp = ieee80211_dump_mpp,
4415 .update_mesh_config = ieee80211_update_mesh_config,
4416 .get_mesh_config = ieee80211_get_mesh_config,
4417 .join_mesh = ieee80211_join_mesh,
4418 .leave_mesh = ieee80211_leave_mesh,
4420 .join_ocb = ieee80211_join_ocb,
4421 .leave_ocb = ieee80211_leave_ocb,
4422 .change_bss = ieee80211_change_bss,
4423 .set_txq_params = ieee80211_set_txq_params,
4424 .set_monitor_channel = ieee80211_set_monitor_channel,
4425 .suspend = ieee80211_suspend,
4426 .resume = ieee80211_resume,
4427 .scan = ieee80211_scan,
4428 .abort_scan = ieee80211_abort_scan,
4429 .sched_scan_start = ieee80211_sched_scan_start,
4430 .sched_scan_stop = ieee80211_sched_scan_stop,
4431 .auth = ieee80211_auth,
4432 .assoc = ieee80211_assoc,
4433 .deauth = ieee80211_deauth,
4434 .disassoc = ieee80211_disassoc,
4435 .join_ibss = ieee80211_join_ibss,
4436 .leave_ibss = ieee80211_leave_ibss,
4437 .set_mcast_rate = ieee80211_set_mcast_rate,
4438 .set_wiphy_params = ieee80211_set_wiphy_params,
4439 .set_tx_power = ieee80211_set_tx_power,
4440 .get_tx_power = ieee80211_get_tx_power,
4441 .rfkill_poll = ieee80211_rfkill_poll,
4442 CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd)
4443 CFG80211_TESTMODE_DUMP(ieee80211_testmode_dump)
4444 .set_power_mgmt = ieee80211_set_power_mgmt,
4445 .set_bitrate_mask = ieee80211_set_bitrate_mask,
4446 .remain_on_channel = ieee80211_remain_on_channel,
4447 .cancel_remain_on_channel = ieee80211_cancel_remain_on_channel,
4448 .mgmt_tx = ieee80211_mgmt_tx,
4449 .mgmt_tx_cancel_wait = ieee80211_mgmt_tx_cancel_wait,
4450 .set_cqm_rssi_config = ieee80211_set_cqm_rssi_config,
4451 .set_cqm_rssi_range_config = ieee80211_set_cqm_rssi_range_config,
4452 .update_mgmt_frame_registrations =
4453 ieee80211_update_mgmt_frame_registrations,
4454 .set_antenna = ieee80211_set_antenna,
4455 .get_antenna = ieee80211_get_antenna,
4456 .set_rekey_data = ieee80211_set_rekey_data,
4457 .tdls_oper = ieee80211_tdls_oper,
4458 .tdls_mgmt = ieee80211_tdls_mgmt,
4459 .tdls_channel_switch = ieee80211_tdls_channel_switch,
4460 .tdls_cancel_channel_switch = ieee80211_tdls_cancel_channel_switch,
4461 .probe_client = ieee80211_probe_client,
4462 .set_noack_map = ieee80211_set_noack_map,
4464 .set_wakeup = ieee80211_set_wakeup,
4466 .get_channel = ieee80211_cfg_get_channel,
4467 .start_radar_detection = ieee80211_start_radar_detection,
4468 .end_cac = ieee80211_end_cac,
4469 .channel_switch = ieee80211_channel_switch,
4470 .set_qos_map = ieee80211_set_qos_map,
4471 .set_ap_chanwidth = ieee80211_set_ap_chanwidth,
4472 .add_tx_ts = ieee80211_add_tx_ts,
4473 .del_tx_ts = ieee80211_del_tx_ts,
4474 .start_nan = ieee80211_start_nan,
4475 .stop_nan = ieee80211_stop_nan,
4476 .nan_change_conf = ieee80211_nan_change_conf,
4477 .add_nan_func = ieee80211_add_nan_func,
4478 .del_nan_func = ieee80211_del_nan_func,
4479 .set_multicast_to_unicast = ieee80211_set_multicast_to_unicast,
4480 .tx_control_port = ieee80211_tx_control_port,
4481 .get_txq_stats = ieee80211_get_txq_stats,
4482 .get_ftm_responder_stats = ieee80211_get_ftm_responder_stats,
4483 .start_pmsr = ieee80211_start_pmsr,
4484 .abort_pmsr = ieee80211_abort_pmsr,
4485 .probe_mesh_link = ieee80211_probe_mesh_link,
4486 .set_tid_config = ieee80211_set_tid_config,
4487 .reset_tid_config = ieee80211_reset_tid_config,
4488 .set_sar_specs = ieee80211_set_sar_specs,
4489 .color_change = ieee80211_color_change,