2 * mac80211 configuration hooks for cfg80211
4 * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
5 * Copyright 2013-2015 Intel Mobile Communications GmbH
6 * Copyright (C) 2015-2016 Intel Deutschland GmbH
8 * This file is GPLv2 as found in COPYING.
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/if_ether.h>
18 #include <net/cfg80211.h>
19 #include "ieee80211_i.h"
20 #include "driver-ops.h"
25 static struct wireless_dev *ieee80211_add_iface(struct wiphy *wiphy,
27 unsigned char name_assign_type,
28 enum nl80211_iftype type,
30 struct vif_params *params)
32 struct ieee80211_local *local = wiphy_priv(wiphy);
33 struct wireless_dev *wdev;
34 struct ieee80211_sub_if_data *sdata;
37 err = ieee80211_if_add(local, name, name_assign_type, &wdev, type, params);
41 if (type == NL80211_IFTYPE_MONITOR && flags) {
42 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
43 sdata->u.mntr.flags = *flags;
49 static int ieee80211_del_iface(struct wiphy *wiphy, struct wireless_dev *wdev)
51 ieee80211_if_remove(IEEE80211_WDEV_TO_SUB_IF(wdev));
56 static int ieee80211_change_iface(struct wiphy *wiphy,
57 struct net_device *dev,
58 enum nl80211_iftype type, u32 *flags,
59 struct vif_params *params)
61 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
64 ret = ieee80211_if_change_type(sdata, type);
68 if (type == NL80211_IFTYPE_AP_VLAN &&
69 params && params->use_4addr == 0) {
70 RCU_INIT_POINTER(sdata->u.vlan.sta, NULL);
71 ieee80211_check_fast_rx_iface(sdata);
72 } else if (type == NL80211_IFTYPE_STATION &&
73 params && params->use_4addr >= 0) {
74 sdata->u.mgd.use_4addr = params->use_4addr;
77 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) {
78 struct ieee80211_local *local = sdata->local;
79 struct ieee80211_sub_if_data *monitor_sdata;
80 u32 mu_mntr_cap_flag = NL80211_EXT_FEATURE_MU_MIMO_AIR_SNIFFER;
82 monitor_sdata = rtnl_dereference(local->monitor_sdata);
84 wiphy_ext_feature_isset(wiphy, mu_mntr_cap_flag)) {
85 memcpy(monitor_sdata->vif.bss_conf.mu_group.membership,
86 params->vht_mumimo_groups, WLAN_MEMBERSHIP_LEN);
87 memcpy(monitor_sdata->vif.bss_conf.mu_group.position,
88 params->vht_mumimo_groups + WLAN_MEMBERSHIP_LEN,
89 WLAN_USER_POSITION_LEN);
90 monitor_sdata->vif.mu_mimo_owner = true;
91 ieee80211_bss_info_change_notify(monitor_sdata,
92 BSS_CHANGED_MU_GROUPS);
94 ether_addr_copy(monitor_sdata->u.mntr.mu_follow_addr,
101 if (ieee80211_sdata_running(sdata)) {
102 u32 mask = MONITOR_FLAG_COOK_FRAMES |
106 * Prohibit MONITOR_FLAG_COOK_FRAMES and
107 * MONITOR_FLAG_ACTIVE to be changed while the
109 * Else we would need to add a lot of cruft
110 * to update everything:
111 * cooked_mntrs, monitor and all fif_* counters
112 * reconfigure hardware
114 if ((*flags & mask) != (sdata->u.mntr.flags & mask))
117 ieee80211_adjust_monitor_flags(sdata, -1);
118 sdata->u.mntr.flags = *flags;
119 ieee80211_adjust_monitor_flags(sdata, 1);
121 ieee80211_configure_filter(local);
124 * Because the interface is down, ieee80211_do_stop
125 * and ieee80211_do_open take care of "everything"
126 * mentioned in the comment above.
128 sdata->u.mntr.flags = *flags;
135 static int ieee80211_start_p2p_device(struct wiphy *wiphy,
136 struct wireless_dev *wdev)
138 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
141 mutex_lock(&sdata->local->chanctx_mtx);
142 ret = ieee80211_check_combinations(sdata, NULL, 0, 0);
143 mutex_unlock(&sdata->local->chanctx_mtx);
147 return ieee80211_do_open(wdev, true);
150 static void ieee80211_stop_p2p_device(struct wiphy *wiphy,
151 struct wireless_dev *wdev)
153 ieee80211_sdata_stop(IEEE80211_WDEV_TO_SUB_IF(wdev));
156 static int ieee80211_start_nan(struct wiphy *wiphy,
157 struct wireless_dev *wdev,
158 struct cfg80211_nan_conf *conf)
160 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
163 mutex_lock(&sdata->local->chanctx_mtx);
164 ret = ieee80211_check_combinations(sdata, NULL, 0, 0);
165 mutex_unlock(&sdata->local->chanctx_mtx);
169 ret = ieee80211_do_open(wdev, true);
173 ret = drv_start_nan(sdata->local, sdata, conf);
175 ieee80211_sdata_stop(sdata);
177 sdata->u.nan.conf = *conf;
182 static void ieee80211_stop_nan(struct wiphy *wiphy,
183 struct wireless_dev *wdev)
185 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
187 drv_stop_nan(sdata->local, sdata);
188 ieee80211_sdata_stop(sdata);
191 static int ieee80211_nan_change_conf(struct wiphy *wiphy,
192 struct wireless_dev *wdev,
193 struct cfg80211_nan_conf *conf,
196 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
197 struct cfg80211_nan_conf new_conf;
200 if (sdata->vif.type != NL80211_IFTYPE_NAN)
203 if (!ieee80211_sdata_running(sdata))
206 new_conf = sdata->u.nan.conf;
208 if (changes & CFG80211_NAN_CONF_CHANGED_PREF)
209 new_conf.master_pref = conf->master_pref;
211 if (changes & CFG80211_NAN_CONF_CHANGED_DUAL)
212 new_conf.dual = conf->dual;
214 ret = drv_nan_change_conf(sdata->local, sdata, &new_conf, changes);
216 sdata->u.nan.conf = new_conf;
221 static int ieee80211_add_nan_func(struct wiphy *wiphy,
222 struct wireless_dev *wdev,
223 struct cfg80211_nan_func *nan_func)
225 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
228 if (sdata->vif.type != NL80211_IFTYPE_NAN)
231 if (!ieee80211_sdata_running(sdata))
234 spin_lock_bh(&sdata->u.nan.func_lock);
236 ret = idr_alloc(&sdata->u.nan.function_inst_ids,
237 nan_func, 1, sdata->local->hw.max_nan_de_entries + 1,
239 spin_unlock_bh(&sdata->u.nan.func_lock);
244 nan_func->instance_id = ret;
246 WARN_ON(nan_func->instance_id == 0);
248 ret = drv_add_nan_func(sdata->local, sdata, nan_func);
250 spin_lock_bh(&sdata->u.nan.func_lock);
251 idr_remove(&sdata->u.nan.function_inst_ids,
252 nan_func->instance_id);
253 spin_unlock_bh(&sdata->u.nan.func_lock);
259 static struct cfg80211_nan_func *
260 ieee80211_find_nan_func_by_cookie(struct ieee80211_sub_if_data *sdata,
263 struct cfg80211_nan_func *func;
266 lockdep_assert_held(&sdata->u.nan.func_lock);
268 idr_for_each_entry(&sdata->u.nan.function_inst_ids, func, id) {
269 if (func->cookie == cookie)
276 static void ieee80211_del_nan_func(struct wiphy *wiphy,
277 struct wireless_dev *wdev, u64 cookie)
279 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
280 struct cfg80211_nan_func *func;
283 if (sdata->vif.type != NL80211_IFTYPE_NAN ||
284 !ieee80211_sdata_running(sdata))
287 spin_lock_bh(&sdata->u.nan.func_lock);
289 func = ieee80211_find_nan_func_by_cookie(sdata, cookie);
291 instance_id = func->instance_id;
293 spin_unlock_bh(&sdata->u.nan.func_lock);
296 drv_del_nan_func(sdata->local, sdata, instance_id);
299 static int ieee80211_set_noack_map(struct wiphy *wiphy,
300 struct net_device *dev,
303 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
305 sdata->noack_map = noack_map;
307 ieee80211_check_fast_xmit_iface(sdata);
312 static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
313 u8 key_idx, bool pairwise, const u8 *mac_addr,
314 struct key_params *params)
316 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
317 struct ieee80211_local *local = sdata->local;
318 struct sta_info *sta = NULL;
319 const struct ieee80211_cipher_scheme *cs = NULL;
320 struct ieee80211_key *key;
323 if (!ieee80211_sdata_running(sdata))
326 /* reject WEP and TKIP keys if WEP failed to initialize */
327 switch (params->cipher) {
328 case WLAN_CIPHER_SUITE_WEP40:
329 case WLAN_CIPHER_SUITE_TKIP:
330 case WLAN_CIPHER_SUITE_WEP104:
331 if (IS_ERR(local->wep_tx_tfm))
334 case WLAN_CIPHER_SUITE_CCMP:
335 case WLAN_CIPHER_SUITE_CCMP_256:
336 case WLAN_CIPHER_SUITE_AES_CMAC:
337 case WLAN_CIPHER_SUITE_BIP_CMAC_256:
338 case WLAN_CIPHER_SUITE_BIP_GMAC_128:
339 case WLAN_CIPHER_SUITE_BIP_GMAC_256:
340 case WLAN_CIPHER_SUITE_GCMP:
341 case WLAN_CIPHER_SUITE_GCMP_256:
344 cs = ieee80211_cs_get(local, params->cipher, sdata->vif.type);
348 key = ieee80211_key_alloc(params->cipher, key_idx, params->key_len,
349 params->key, params->seq_len, params->seq,
355 key->conf.flags |= IEEE80211_KEY_FLAG_PAIRWISE;
357 mutex_lock(&local->sta_mtx);
360 if (ieee80211_vif_is_mesh(&sdata->vif))
361 sta = sta_info_get(sdata, mac_addr);
363 sta = sta_info_get_bss(sdata, mac_addr);
365 * The ASSOC test makes sure the driver is ready to
366 * receive the key. When wpa_supplicant has roamed
367 * using FT, it attempts to set the key before
368 * association has completed, this rejects that attempt
369 * so it will set the key again after association.
371 * TODO: accept the key if we have a station entry and
372 * add it to the device after the station.
374 if (!sta || !test_sta_flag(sta, WLAN_STA_ASSOC)) {
375 ieee80211_key_free_unused(key);
381 switch (sdata->vif.type) {
382 case NL80211_IFTYPE_STATION:
383 if (sdata->u.mgd.mfp != IEEE80211_MFP_DISABLED)
384 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
386 case NL80211_IFTYPE_AP:
387 case NL80211_IFTYPE_AP_VLAN:
388 /* Keys without a station are used for TX only */
389 if (sta && test_sta_flag(sta, WLAN_STA_MFP))
390 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
392 case NL80211_IFTYPE_ADHOC:
395 case NL80211_IFTYPE_MESH_POINT:
396 #ifdef CONFIG_MAC80211_MESH
397 if (sdata->u.mesh.security != IEEE80211_MESH_SEC_NONE)
398 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
401 case NL80211_IFTYPE_WDS:
402 case NL80211_IFTYPE_MONITOR:
403 case NL80211_IFTYPE_P2P_DEVICE:
404 case NL80211_IFTYPE_NAN:
405 case NL80211_IFTYPE_UNSPECIFIED:
406 case NUM_NL80211_IFTYPES:
407 case NL80211_IFTYPE_P2P_CLIENT:
408 case NL80211_IFTYPE_P2P_GO:
409 case NL80211_IFTYPE_OCB:
410 /* shouldn't happen */
416 sta->cipher_scheme = cs;
418 err = ieee80211_key_link(key, sdata, sta);
421 mutex_unlock(&local->sta_mtx);
426 static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
427 u8 key_idx, bool pairwise, const u8 *mac_addr)
429 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
430 struct ieee80211_local *local = sdata->local;
431 struct sta_info *sta;
432 struct ieee80211_key *key = NULL;
435 mutex_lock(&local->sta_mtx);
436 mutex_lock(&local->key_mtx);
441 sta = sta_info_get_bss(sdata, mac_addr);
446 key = key_mtx_dereference(local, sta->ptk[key_idx]);
448 key = key_mtx_dereference(local, sta->gtk[key_idx]);
450 key = key_mtx_dereference(local, sdata->keys[key_idx]);
457 ieee80211_key_free(key, sdata->vif.type == NL80211_IFTYPE_STATION);
461 mutex_unlock(&local->key_mtx);
462 mutex_unlock(&local->sta_mtx);
467 static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
468 u8 key_idx, bool pairwise, const u8 *mac_addr,
470 void (*callback)(void *cookie,
471 struct key_params *params))
473 struct ieee80211_sub_if_data *sdata;
474 struct sta_info *sta = NULL;
476 struct key_params params;
477 struct ieee80211_key *key = NULL;
482 struct ieee80211_key_seq kseq = {};
484 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
489 sta = sta_info_get_bss(sdata, mac_addr);
493 if (pairwise && key_idx < NUM_DEFAULT_KEYS)
494 key = rcu_dereference(sta->ptk[key_idx]);
495 else if (!pairwise &&
496 key_idx < NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS)
497 key = rcu_dereference(sta->gtk[key_idx]);
499 key = rcu_dereference(sdata->keys[key_idx]);
504 memset(¶ms, 0, sizeof(params));
506 params.cipher = key->conf.cipher;
508 switch (key->conf.cipher) {
509 case WLAN_CIPHER_SUITE_TKIP:
510 pn64 = atomic64_read(&key->conf.tx_pn);
511 iv32 = TKIP_PN_TO_IV32(pn64);
512 iv16 = TKIP_PN_TO_IV16(pn64);
514 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE &&
515 !(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
516 drv_get_key_seq(sdata->local, key, &kseq);
517 iv32 = kseq.tkip.iv32;
518 iv16 = kseq.tkip.iv16;
521 seq[0] = iv16 & 0xff;
522 seq[1] = (iv16 >> 8) & 0xff;
523 seq[2] = iv32 & 0xff;
524 seq[3] = (iv32 >> 8) & 0xff;
525 seq[4] = (iv32 >> 16) & 0xff;
526 seq[5] = (iv32 >> 24) & 0xff;
530 case WLAN_CIPHER_SUITE_CCMP:
531 case WLAN_CIPHER_SUITE_CCMP_256:
532 case WLAN_CIPHER_SUITE_AES_CMAC:
533 case WLAN_CIPHER_SUITE_BIP_CMAC_256:
534 BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
535 offsetof(typeof(kseq), aes_cmac));
536 case WLAN_CIPHER_SUITE_BIP_GMAC_128:
537 case WLAN_CIPHER_SUITE_BIP_GMAC_256:
538 BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
539 offsetof(typeof(kseq), aes_gmac));
540 case WLAN_CIPHER_SUITE_GCMP:
541 case WLAN_CIPHER_SUITE_GCMP_256:
542 BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
543 offsetof(typeof(kseq), gcmp));
545 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE &&
546 !(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
547 drv_get_key_seq(sdata->local, key, &kseq);
548 memcpy(seq, kseq.ccmp.pn, 6);
550 pn64 = atomic64_read(&key->conf.tx_pn);
562 if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
564 if (WARN_ON(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV))
566 drv_get_key_seq(sdata->local, key, &kseq);
567 params.seq = kseq.hw.seq;
568 params.seq_len = kseq.hw.seq_len;
572 params.key = key->conf.key;
573 params.key_len = key->conf.keylen;
575 callback(cookie, ¶ms);
583 static int ieee80211_config_default_key(struct wiphy *wiphy,
584 struct net_device *dev,
585 u8 key_idx, bool uni,
588 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
590 ieee80211_set_default_key(sdata, key_idx, uni, multi);
595 static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy,
596 struct net_device *dev,
599 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
601 ieee80211_set_default_mgmt_key(sdata, key_idx);
606 void sta_set_rate_info_tx(struct sta_info *sta,
607 const struct ieee80211_tx_rate *rate,
608 struct rate_info *rinfo)
611 if (rate->flags & IEEE80211_TX_RC_MCS) {
612 rinfo->flags |= RATE_INFO_FLAGS_MCS;
613 rinfo->mcs = rate->idx;
614 } else if (rate->flags & IEEE80211_TX_RC_VHT_MCS) {
615 rinfo->flags |= RATE_INFO_FLAGS_VHT_MCS;
616 rinfo->mcs = ieee80211_rate_get_vht_mcs(rate);
617 rinfo->nss = ieee80211_rate_get_vht_nss(rate);
619 struct ieee80211_supported_band *sband;
620 int shift = ieee80211_vif_get_shift(&sta->sdata->vif);
623 sband = ieee80211_get_sband(sta->sdata);
625 brate = sband->bitrates[rate->idx].bitrate;
626 rinfo->legacy = DIV_ROUND_UP(brate, 1 << shift);
629 if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
630 rinfo->bw = RATE_INFO_BW_40;
631 else if (rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH)
632 rinfo->bw = RATE_INFO_BW_80;
633 else if (rate->flags & IEEE80211_TX_RC_160_MHZ_WIDTH)
634 rinfo->bw = RATE_INFO_BW_160;
636 rinfo->bw = RATE_INFO_BW_20;
637 if (rate->flags & IEEE80211_TX_RC_SHORT_GI)
638 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI;
641 static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev,
642 int idx, u8 *mac, struct station_info *sinfo)
644 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
645 struct ieee80211_local *local = sdata->local;
646 struct sta_info *sta;
649 mutex_lock(&local->sta_mtx);
651 sta = sta_info_get_by_idx(sdata, idx);
654 memcpy(mac, sta->sta.addr, ETH_ALEN);
655 sta_set_sinfo(sta, sinfo);
658 mutex_unlock(&local->sta_mtx);
663 static int ieee80211_dump_survey(struct wiphy *wiphy, struct net_device *dev,
664 int idx, struct survey_info *survey)
666 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
668 return drv_get_survey(local, idx, survey);
671 static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev,
672 const u8 *mac, struct station_info *sinfo)
674 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
675 struct ieee80211_local *local = sdata->local;
676 struct sta_info *sta;
679 mutex_lock(&local->sta_mtx);
681 sta = sta_info_get_bss(sdata, mac);
684 sta_set_sinfo(sta, sinfo);
687 mutex_unlock(&local->sta_mtx);
692 static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
693 struct cfg80211_chan_def *chandef)
695 struct ieee80211_local *local = wiphy_priv(wiphy);
696 struct ieee80211_sub_if_data *sdata;
699 if (cfg80211_chandef_identical(&local->monitor_chandef, chandef))
702 mutex_lock(&local->mtx);
703 mutex_lock(&local->iflist_mtx);
704 if (local->use_chanctx) {
705 sdata = rcu_dereference_protected(
706 local->monitor_sdata,
707 lockdep_is_held(&local->iflist_mtx));
709 ieee80211_vif_release_channel(sdata);
710 ret = ieee80211_vif_use_channel(sdata, chandef,
711 IEEE80211_CHANCTX_EXCLUSIVE);
713 } else if (local->open_count == local->monitors) {
714 local->_oper_chandef = *chandef;
715 ieee80211_hw_config(local, 0);
719 local->monitor_chandef = *chandef;
720 mutex_unlock(&local->iflist_mtx);
721 mutex_unlock(&local->mtx);
726 static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata,
727 const u8 *resp, size_t resp_len,
728 const struct ieee80211_csa_settings *csa)
730 struct probe_resp *new, *old;
732 if (!resp || !resp_len)
735 old = sdata_dereference(sdata->u.ap.probe_resp, sdata);
737 new = kzalloc(sizeof(struct probe_resp) + resp_len, GFP_KERNEL);
742 memcpy(new->data, resp, resp_len);
745 memcpy(new->csa_counter_offsets, csa->counter_offsets_presp,
746 csa->n_counter_offsets_presp *
747 sizeof(new->csa_counter_offsets[0]));
749 rcu_assign_pointer(sdata->u.ap.probe_resp, new);
751 kfree_rcu(old, rcu_head);
756 static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
757 struct cfg80211_beacon_data *params,
758 const struct ieee80211_csa_settings *csa)
760 struct beacon_data *new, *old;
761 int new_head_len, new_tail_len;
763 u32 changed = BSS_CHANGED_BEACON;
765 old = sdata_dereference(sdata->u.ap.beacon, sdata);
768 /* Need to have a beacon head if we don't have one yet */
769 if (!params->head && !old)
772 /* new or old head? */
774 new_head_len = params->head_len;
776 new_head_len = old->head_len;
778 /* new or old tail? */
779 if (params->tail || !old)
780 /* params->tail_len will be zero for !params->tail */
781 new_tail_len = params->tail_len;
783 new_tail_len = old->tail_len;
785 size = sizeof(*new) + new_head_len + new_tail_len;
787 new = kzalloc(size, GFP_KERNEL);
791 /* start filling the new info now */
794 * pointers go into the block we allocated,
795 * memory is | beacon_data | head | tail |
797 new->head = ((u8 *) new) + sizeof(*new);
798 new->tail = new->head + new_head_len;
799 new->head_len = new_head_len;
800 new->tail_len = new_tail_len;
803 new->csa_current_counter = csa->count;
804 memcpy(new->csa_counter_offsets, csa->counter_offsets_beacon,
805 csa->n_counter_offsets_beacon *
806 sizeof(new->csa_counter_offsets[0]));
811 memcpy(new->head, params->head, new_head_len);
813 memcpy(new->head, old->head, new_head_len);
815 /* copy in optional tail */
817 memcpy(new->tail, params->tail, new_tail_len);
820 memcpy(new->tail, old->tail, new_tail_len);
822 err = ieee80211_set_probe_resp(sdata, params->probe_resp,
823 params->probe_resp_len, csa);
827 changed |= BSS_CHANGED_AP_PROBE_RESP;
829 rcu_assign_pointer(sdata->u.ap.beacon, new);
832 kfree_rcu(old, rcu_head);
837 static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
838 struct cfg80211_ap_settings *params)
840 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
841 struct ieee80211_local *local = sdata->local;
842 struct beacon_data *old;
843 struct ieee80211_sub_if_data *vlan;
844 u32 changed = BSS_CHANGED_BEACON_INT |
845 BSS_CHANGED_BEACON_ENABLED |
852 old = sdata_dereference(sdata->u.ap.beacon, sdata);
856 switch (params->smps_mode) {
857 case NL80211_SMPS_OFF:
858 sdata->smps_mode = IEEE80211_SMPS_OFF;
860 case NL80211_SMPS_STATIC:
861 sdata->smps_mode = IEEE80211_SMPS_STATIC;
863 case NL80211_SMPS_DYNAMIC:
864 sdata->smps_mode = IEEE80211_SMPS_DYNAMIC;
869 sdata->u.ap.req_smps = sdata->smps_mode;
871 sdata->needed_rx_chains = sdata->local->rx_chains;
873 mutex_lock(&local->mtx);
874 err = ieee80211_vif_use_channel(sdata, ¶ms->chandef,
875 IEEE80211_CHANCTX_SHARED);
877 ieee80211_vif_copy_chanctx_to_vlans(sdata, false);
878 mutex_unlock(&local->mtx);
883 * Apply control port protocol, this allows us to
884 * not encrypt dynamic WEP control frames.
886 sdata->control_port_protocol = params->crypto.control_port_ethertype;
887 sdata->control_port_no_encrypt = params->crypto.control_port_no_encrypt;
888 sdata->encrypt_headroom = ieee80211_cs_headroom(sdata->local,
892 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) {
893 vlan->control_port_protocol =
894 params->crypto.control_port_ethertype;
895 vlan->control_port_no_encrypt =
896 params->crypto.control_port_no_encrypt;
897 vlan->encrypt_headroom =
898 ieee80211_cs_headroom(sdata->local,
903 sdata->vif.bss_conf.beacon_int = params->beacon_interval;
904 sdata->vif.bss_conf.dtim_period = params->dtim_period;
905 sdata->vif.bss_conf.enable_beacon = true;
906 sdata->vif.bss_conf.allow_p2p_go_ps = sdata->vif.p2p;
908 sdata->vif.bss_conf.ssid_len = params->ssid_len;
909 if (params->ssid_len)
910 memcpy(sdata->vif.bss_conf.ssid, params->ssid,
912 sdata->vif.bss_conf.hidden_ssid =
913 (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE);
915 memset(&sdata->vif.bss_conf.p2p_noa_attr, 0,
916 sizeof(sdata->vif.bss_conf.p2p_noa_attr));
917 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow =
918 params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
919 if (params->p2p_opp_ps)
920 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |=
921 IEEE80211_P2P_OPPPS_ENABLE_BIT;
923 err = ieee80211_assign_beacon(sdata, ¶ms->beacon, NULL);
925 ieee80211_vif_release_channel(sdata);
930 err = drv_start_ap(sdata->local, sdata);
932 old = sdata_dereference(sdata->u.ap.beacon, sdata);
935 kfree_rcu(old, rcu_head);
936 RCU_INIT_POINTER(sdata->u.ap.beacon, NULL);
937 ieee80211_vif_release_channel(sdata);
941 ieee80211_recalc_dtim(local, sdata);
942 ieee80211_bss_info_change_notify(sdata, changed);
944 netif_carrier_on(dev);
945 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
946 netif_carrier_on(vlan->dev);
951 static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev,
952 struct cfg80211_beacon_data *params)
954 struct ieee80211_sub_if_data *sdata;
955 struct beacon_data *old;
958 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
959 sdata_assert_lock(sdata);
961 /* don't allow changing the beacon while CSA is in place - offset
962 * of channel switch counter may change
964 if (sdata->vif.csa_active)
967 old = sdata_dereference(sdata->u.ap.beacon, sdata);
971 err = ieee80211_assign_beacon(sdata, params, NULL);
974 ieee80211_bss_info_change_notify(sdata, err);
978 static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev)
980 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
981 struct ieee80211_sub_if_data *vlan;
982 struct ieee80211_local *local = sdata->local;
983 struct beacon_data *old_beacon;
984 struct probe_resp *old_probe_resp;
985 struct cfg80211_chan_def chandef;
987 sdata_assert_lock(sdata);
989 old_beacon = sdata_dereference(sdata->u.ap.beacon, sdata);
992 old_probe_resp = sdata_dereference(sdata->u.ap.probe_resp, sdata);
994 /* abort any running channel switch */
995 mutex_lock(&local->mtx);
996 sdata->vif.csa_active = false;
997 if (sdata->csa_block_tx) {
998 ieee80211_wake_vif_queues(local, sdata,
999 IEEE80211_QUEUE_STOP_REASON_CSA);
1000 sdata->csa_block_tx = false;
1003 mutex_unlock(&local->mtx);
1005 kfree(sdata->u.ap.next_beacon);
1006 sdata->u.ap.next_beacon = NULL;
1008 /* turn off carrier for this interface and dependent VLANs */
1009 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
1010 netif_carrier_off(vlan->dev);
1011 netif_carrier_off(dev);
1013 /* remove beacon and probe response */
1014 RCU_INIT_POINTER(sdata->u.ap.beacon, NULL);
1015 RCU_INIT_POINTER(sdata->u.ap.probe_resp, NULL);
1016 kfree_rcu(old_beacon, rcu_head);
1018 kfree_rcu(old_probe_resp, rcu_head);
1019 sdata->u.ap.driver_smps_mode = IEEE80211_SMPS_OFF;
1021 __sta_info_flush(sdata, true);
1022 ieee80211_free_keys(sdata, true);
1024 sdata->vif.bss_conf.enable_beacon = false;
1025 sdata->vif.bss_conf.ssid_len = 0;
1026 clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state);
1027 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
1029 if (sdata->wdev.cac_started) {
1030 chandef = sdata->vif.bss_conf.chandef;
1031 cancel_delayed_work_sync(&sdata->dfs_cac_timer_work);
1032 cfg80211_cac_event(sdata->dev, &chandef,
1033 NL80211_RADAR_CAC_ABORTED,
1037 drv_stop_ap(sdata->local, sdata);
1039 /* free all potentially still buffered bcast frames */
1040 local->total_ps_buffered -= skb_queue_len(&sdata->u.ap.ps.bc_buf);
1041 ieee80211_purge_tx_queue(&local->hw, &sdata->u.ap.ps.bc_buf);
1043 mutex_lock(&local->mtx);
1044 ieee80211_vif_copy_chanctx_to_vlans(sdata, true);
1045 ieee80211_vif_release_channel(sdata);
1046 mutex_unlock(&local->mtx);
1051 static int sta_apply_auth_flags(struct ieee80211_local *local,
1052 struct sta_info *sta,
1057 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
1058 set & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
1059 !test_sta_flag(sta, WLAN_STA_AUTH)) {
1060 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
1065 if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
1066 set & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
1067 !test_sta_flag(sta, WLAN_STA_ASSOC)) {
1069 * When peer becomes associated, init rate control as
1070 * well. Some drivers require rate control initialized
1071 * before drv_sta_state() is called.
1073 if (!test_sta_flag(sta, WLAN_STA_RATE_CONTROL))
1074 rate_control_rate_init(sta);
1076 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
1081 if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
1082 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED))
1083 ret = sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED);
1084 else if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
1085 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
1092 if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
1093 !(set & BIT(NL80211_STA_FLAG_ASSOCIATED)) &&
1094 test_sta_flag(sta, WLAN_STA_ASSOC)) {
1095 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
1100 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
1101 !(set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) &&
1102 test_sta_flag(sta, WLAN_STA_AUTH)) {
1103 ret = sta_info_move_state(sta, IEEE80211_STA_NONE);
1111 static void sta_apply_mesh_params(struct ieee80211_local *local,
1112 struct sta_info *sta,
1113 struct station_parameters *params)
1115 #ifdef CONFIG_MAC80211_MESH
1116 struct ieee80211_sub_if_data *sdata = sta->sdata;
1119 if (params->sta_modify_mask & STATION_PARAM_APPLY_PLINK_STATE) {
1120 switch (params->plink_state) {
1121 case NL80211_PLINK_ESTAB:
1122 if (sta->mesh->plink_state != NL80211_PLINK_ESTAB)
1123 changed = mesh_plink_inc_estab_count(sdata);
1124 sta->mesh->plink_state = params->plink_state;
1125 sta->mesh->aid = params->peer_aid;
1127 ieee80211_mps_sta_status_update(sta);
1128 changed |= ieee80211_mps_set_sta_local_pm(sta,
1129 sdata->u.mesh.mshcfg.power_mode);
1131 case NL80211_PLINK_LISTEN:
1132 case NL80211_PLINK_BLOCKED:
1133 case NL80211_PLINK_OPN_SNT:
1134 case NL80211_PLINK_OPN_RCVD:
1135 case NL80211_PLINK_CNF_RCVD:
1136 case NL80211_PLINK_HOLDING:
1137 if (sta->mesh->plink_state == NL80211_PLINK_ESTAB)
1138 changed = mesh_plink_dec_estab_count(sdata);
1139 sta->mesh->plink_state = params->plink_state;
1141 ieee80211_mps_sta_status_update(sta);
1142 changed |= ieee80211_mps_set_sta_local_pm(sta,
1143 NL80211_MESH_POWER_UNKNOWN);
1151 switch (params->plink_action) {
1152 case NL80211_PLINK_ACTION_NO_ACTION:
1155 case NL80211_PLINK_ACTION_OPEN:
1156 changed |= mesh_plink_open(sta);
1158 case NL80211_PLINK_ACTION_BLOCK:
1159 changed |= mesh_plink_block(sta);
1163 if (params->local_pm)
1164 changed |= ieee80211_mps_set_sta_local_pm(sta,
1167 ieee80211_mbss_info_change_notify(sdata, changed);
1171 static int sta_apply_parameters(struct ieee80211_local *local,
1172 struct sta_info *sta,
1173 struct station_parameters *params)
1176 struct ieee80211_supported_band *sband;
1177 struct ieee80211_sub_if_data *sdata = sta->sdata;
1180 sband = ieee80211_get_sband(sdata);
1184 mask = params->sta_flags_mask;
1185 set = params->sta_flags_set;
1187 if (ieee80211_vif_is_mesh(&sdata->vif)) {
1189 * In mesh mode, ASSOCIATED isn't part of the nl80211
1190 * API but must follow AUTHENTICATED for driver state.
1192 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED))
1193 mask |= BIT(NL80211_STA_FLAG_ASSOCIATED);
1194 if (set & BIT(NL80211_STA_FLAG_AUTHENTICATED))
1195 set |= BIT(NL80211_STA_FLAG_ASSOCIATED);
1196 } else if (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
1198 * TDLS -- everything follows authorized, but
1199 * only becoming authorized is possible, not
1202 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
1203 set |= BIT(NL80211_STA_FLAG_AUTHENTICATED) |
1204 BIT(NL80211_STA_FLAG_ASSOCIATED);
1205 mask |= BIT(NL80211_STA_FLAG_AUTHENTICATED) |
1206 BIT(NL80211_STA_FLAG_ASSOCIATED);
1210 if (mask & BIT(NL80211_STA_FLAG_WME) &&
1211 local->hw.queues >= IEEE80211_NUM_ACS)
1212 sta->sta.wme = set & BIT(NL80211_STA_FLAG_WME);
1214 /* auth flags will be set later for TDLS,
1215 * and for unassociated stations that move to assocaited */
1216 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1217 !((mask & BIT(NL80211_STA_FLAG_ASSOCIATED)) &&
1218 (set & BIT(NL80211_STA_FLAG_ASSOCIATED)))) {
1219 ret = sta_apply_auth_flags(local, sta, mask, set);
1224 if (mask & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) {
1225 if (set & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE))
1226 set_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
1228 clear_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
1231 if (mask & BIT(NL80211_STA_FLAG_MFP)) {
1232 sta->sta.mfp = !!(set & BIT(NL80211_STA_FLAG_MFP));
1233 if (set & BIT(NL80211_STA_FLAG_MFP))
1234 set_sta_flag(sta, WLAN_STA_MFP);
1236 clear_sta_flag(sta, WLAN_STA_MFP);
1239 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
1240 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER))
1241 set_sta_flag(sta, WLAN_STA_TDLS_PEER);
1243 clear_sta_flag(sta, WLAN_STA_TDLS_PEER);
1246 /* mark TDLS channel switch support, if the AP allows it */
1247 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1248 !sdata->u.mgd.tdls_chan_switch_prohibited &&
1249 params->ext_capab_len >= 4 &&
1250 params->ext_capab[3] & WLAN_EXT_CAPA4_TDLS_CHAN_SWITCH)
1251 set_sta_flag(sta, WLAN_STA_TDLS_CHAN_SWITCH);
1253 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1254 !sdata->u.mgd.tdls_wider_bw_prohibited &&
1255 ieee80211_hw_check(&local->hw, TDLS_WIDER_BW) &&
1256 params->ext_capab_len >= 8 &&
1257 params->ext_capab[7] & WLAN_EXT_CAPA8_TDLS_WIDE_BW_ENABLED)
1258 set_sta_flag(sta, WLAN_STA_TDLS_WIDER_BW);
1260 if (params->sta_modify_mask & STATION_PARAM_APPLY_UAPSD) {
1261 sta->sta.uapsd_queues = params->uapsd_queues;
1262 sta->sta.max_sp = params->max_sp;
1265 /* The sender might not have sent the last bit, consider it to be 0 */
1266 if (params->ext_capab_len >= 8) {
1267 u8 val = (params->ext_capab[7] &
1268 WLAN_EXT_CAPA8_MAX_MSDU_IN_AMSDU_LSB) >> 7;
1270 /* we did get all the bits, take the MSB as well */
1271 if (params->ext_capab_len >= 9) {
1272 u8 val_msb = params->ext_capab[8] &
1273 WLAN_EXT_CAPA9_MAX_MSDU_IN_AMSDU_MSB;
1280 sta->sta.max_amsdu_subframes = 32;
1283 sta->sta.max_amsdu_subframes = 16;
1286 sta->sta.max_amsdu_subframes = 8;
1289 sta->sta.max_amsdu_subframes = 0;
1294 * cfg80211 validates this (1-2007) and allows setting the AID
1295 * only when creating a new station entry
1298 sta->sta.aid = params->aid;
1301 * Some of the following updates would be racy if called on an
1302 * existing station, via ieee80211_change_station(). However,
1303 * all such changes are rejected by cfg80211 except for updates
1304 * changing the supported rates on an existing but not yet used
1308 if (params->listen_interval >= 0)
1309 sta->listen_interval = params->listen_interval;
1311 if (params->supported_rates) {
1312 ieee80211_parse_bitrates(&sdata->vif.bss_conf.chandef,
1313 sband, params->supported_rates,
1314 params->supported_rates_len,
1315 &sta->sta.supp_rates[sband->band]);
1318 if (params->ht_capa)
1319 ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
1320 params->ht_capa, sta);
1322 /* VHT can override some HT caps such as the A-MSDU max length */
1323 if (params->vht_capa)
1324 ieee80211_vht_cap_ie_to_sta_vht_cap(sdata, sband,
1325 params->vht_capa, sta);
1327 if (params->opmode_notif_used) {
1328 /* returned value is only needed for rc update, but the
1329 * rc isn't initialized here yet, so ignore it
1331 __ieee80211_vht_handle_opmode(sdata, sta, params->opmode_notif,
1335 if (params->support_p2p_ps >= 0)
1336 sta->sta.support_p2p_ps = params->support_p2p_ps;
1338 if (ieee80211_vif_is_mesh(&sdata->vif))
1339 sta_apply_mesh_params(local, sta, params);
1341 /* set the STA state after all sta info from usermode has been set */
1342 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) ||
1343 set & BIT(NL80211_STA_FLAG_ASSOCIATED)) {
1344 ret = sta_apply_auth_flags(local, sta, mask, set);
1352 static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
1354 struct station_parameters *params)
1356 struct ieee80211_local *local = wiphy_priv(wiphy);
1357 struct sta_info *sta;
1358 struct ieee80211_sub_if_data *sdata;
1362 sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
1364 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
1365 sdata->vif.type != NL80211_IFTYPE_AP)
1368 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1370 if (ether_addr_equal(mac, sdata->vif.addr))
1373 if (is_multicast_ether_addr(mac))
1376 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER) &&
1377 sdata->vif.type == NL80211_IFTYPE_STATION &&
1378 !sdata->u.mgd.associated)
1381 sta = sta_info_alloc(sdata, mac, GFP_KERNEL);
1385 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))
1386 sta->sta.tdls = true;
1388 err = sta_apply_parameters(local, sta, params);
1390 sta_info_free(local, sta);
1395 * for TDLS and for unassociated station, rate control should be
1396 * initialized only when rates are known and station is marked
1397 * authorized/associated
1399 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1400 test_sta_flag(sta, WLAN_STA_ASSOC))
1401 rate_control_rate_init(sta);
1403 err = sta_info_insert_rcu(sta);
1414 static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev,
1415 struct station_del_parameters *params)
1417 struct ieee80211_sub_if_data *sdata;
1419 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1422 return sta_info_destroy_addr_bss(sdata, params->mac);
1424 sta_info_flush(sdata);
1428 static int ieee80211_change_station(struct wiphy *wiphy,
1429 struct net_device *dev, const u8 *mac,
1430 struct station_parameters *params)
1432 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1433 struct ieee80211_local *local = wiphy_priv(wiphy);
1434 struct sta_info *sta;
1435 struct ieee80211_sub_if_data *vlansdata;
1436 enum cfg80211_station_type statype;
1439 mutex_lock(&local->sta_mtx);
1441 sta = sta_info_get_bss(sdata, mac);
1447 switch (sdata->vif.type) {
1448 case NL80211_IFTYPE_MESH_POINT:
1449 if (sdata->u.mesh.user_mpm)
1450 statype = CFG80211_STA_MESH_PEER_USER;
1452 statype = CFG80211_STA_MESH_PEER_KERNEL;
1454 case NL80211_IFTYPE_ADHOC:
1455 statype = CFG80211_STA_IBSS;
1457 case NL80211_IFTYPE_STATION:
1458 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
1459 statype = CFG80211_STA_AP_STA;
1462 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
1463 statype = CFG80211_STA_TDLS_PEER_ACTIVE;
1465 statype = CFG80211_STA_TDLS_PEER_SETUP;
1467 case NL80211_IFTYPE_AP:
1468 case NL80211_IFTYPE_AP_VLAN:
1469 if (test_sta_flag(sta, WLAN_STA_ASSOC))
1470 statype = CFG80211_STA_AP_CLIENT;
1472 statype = CFG80211_STA_AP_CLIENT_UNASSOC;
1479 err = cfg80211_check_station_change(wiphy, params, statype);
1483 if (params->vlan && params->vlan != sta->sdata->dev) {
1484 bool prev_4addr = false;
1485 bool new_4addr = false;
1487 vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
1489 if (params->vlan->ieee80211_ptr->use_4addr) {
1490 if (vlansdata->u.vlan.sta) {
1495 rcu_assign_pointer(vlansdata->u.vlan.sta, sta);
1497 __ieee80211_check_fast_rx_iface(vlansdata);
1500 if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
1501 sta->sdata->u.vlan.sta) {
1502 RCU_INIT_POINTER(sta->sdata->u.vlan.sta, NULL);
1506 sta->sdata = vlansdata;
1507 ieee80211_check_fast_xmit(sta);
1509 if (sta->sta_state == IEEE80211_STA_AUTHORIZED &&
1510 prev_4addr != new_4addr) {
1512 atomic_dec(&sta->sdata->bss->num_mcast_sta);
1514 atomic_inc(&sta->sdata->bss->num_mcast_sta);
1517 if (sta->sta_state == IEEE80211_STA_AUTHORIZED)
1518 cfg80211_send_layer2_update(sta->sdata->dev,
1522 err = sta_apply_parameters(local, sta, params);
1526 mutex_unlock(&local->sta_mtx);
1528 if ((sdata->vif.type == NL80211_IFTYPE_AP ||
1529 sdata->vif.type == NL80211_IFTYPE_AP_VLAN) &&
1530 sta->known_smps_mode != sta->sdata->bss->req_smps &&
1531 test_sta_flag(sta, WLAN_STA_AUTHORIZED) &&
1532 sta_info_tx_streams(sta) != 1) {
1534 "%pM just authorized and MIMO capable - update SMPS\n",
1536 ieee80211_send_smps_action(sta->sdata,
1537 sta->sdata->bss->req_smps,
1539 sta->sdata->vif.bss_conf.bssid);
1542 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
1543 params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
1544 ieee80211_recalc_ps(local);
1545 ieee80211_recalc_ps_vif(sdata);
1550 mutex_unlock(&local->sta_mtx);
1554 #ifdef CONFIG_MAC80211_MESH
1555 static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev,
1556 const u8 *dst, const u8 *next_hop)
1558 struct ieee80211_sub_if_data *sdata;
1559 struct mesh_path *mpath;
1560 struct sta_info *sta;
1562 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1565 sta = sta_info_get(sdata, next_hop);
1571 mpath = mesh_path_add(sdata, dst);
1572 if (IS_ERR(mpath)) {
1574 return PTR_ERR(mpath);
1577 mesh_path_fix_nexthop(mpath, sta);
1583 static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev,
1586 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1589 return mesh_path_del(sdata, dst);
1591 mesh_path_flush_by_iface(sdata);
1595 static int ieee80211_change_mpath(struct wiphy *wiphy, struct net_device *dev,
1596 const u8 *dst, const u8 *next_hop)
1598 struct ieee80211_sub_if_data *sdata;
1599 struct mesh_path *mpath;
1600 struct sta_info *sta;
1602 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1606 sta = sta_info_get(sdata, next_hop);
1612 mpath = mesh_path_lookup(sdata, dst);
1618 mesh_path_fix_nexthop(mpath, sta);
1624 static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop,
1625 struct mpath_info *pinfo)
1627 struct sta_info *next_hop_sta = rcu_dereference(mpath->next_hop);
1630 memcpy(next_hop, next_hop_sta->sta.addr, ETH_ALEN);
1632 eth_zero_addr(next_hop);
1634 memset(pinfo, 0, sizeof(*pinfo));
1636 pinfo->generation = mpath->sdata->u.mesh.mesh_paths_generation;
1638 pinfo->filled = MPATH_INFO_FRAME_QLEN |
1641 MPATH_INFO_EXPTIME |
1642 MPATH_INFO_DISCOVERY_TIMEOUT |
1643 MPATH_INFO_DISCOVERY_RETRIES |
1646 pinfo->frame_qlen = mpath->frame_queue.qlen;
1647 pinfo->sn = mpath->sn;
1648 pinfo->metric = mpath->metric;
1649 if (time_before(jiffies, mpath->exp_time))
1650 pinfo->exptime = jiffies_to_msecs(mpath->exp_time - jiffies);
1651 pinfo->discovery_timeout =
1652 jiffies_to_msecs(mpath->discovery_timeout);
1653 pinfo->discovery_retries = mpath->discovery_retries;
1654 if (mpath->flags & MESH_PATH_ACTIVE)
1655 pinfo->flags |= NL80211_MPATH_FLAG_ACTIVE;
1656 if (mpath->flags & MESH_PATH_RESOLVING)
1657 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING;
1658 if (mpath->flags & MESH_PATH_SN_VALID)
1659 pinfo->flags |= NL80211_MPATH_FLAG_SN_VALID;
1660 if (mpath->flags & MESH_PATH_FIXED)
1661 pinfo->flags |= NL80211_MPATH_FLAG_FIXED;
1662 if (mpath->flags & MESH_PATH_RESOLVED)
1663 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVED;
1666 static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev,
1667 u8 *dst, u8 *next_hop, struct mpath_info *pinfo)
1670 struct ieee80211_sub_if_data *sdata;
1671 struct mesh_path *mpath;
1673 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1676 mpath = mesh_path_lookup(sdata, dst);
1681 memcpy(dst, mpath->dst, ETH_ALEN);
1682 mpath_set_pinfo(mpath, next_hop, pinfo);
1687 static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev,
1688 int idx, u8 *dst, u8 *next_hop,
1689 struct mpath_info *pinfo)
1691 struct ieee80211_sub_if_data *sdata;
1692 struct mesh_path *mpath;
1694 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1697 mpath = mesh_path_lookup_by_idx(sdata, idx);
1702 memcpy(dst, mpath->dst, ETH_ALEN);
1703 mpath_set_pinfo(mpath, next_hop, pinfo);
1708 static void mpp_set_pinfo(struct mesh_path *mpath, u8 *mpp,
1709 struct mpath_info *pinfo)
1711 memset(pinfo, 0, sizeof(*pinfo));
1712 memcpy(mpp, mpath->mpp, ETH_ALEN);
1714 pinfo->generation = mpath->sdata->u.mesh.mpp_paths_generation;
1717 static int ieee80211_get_mpp(struct wiphy *wiphy, struct net_device *dev,
1718 u8 *dst, u8 *mpp, struct mpath_info *pinfo)
1721 struct ieee80211_sub_if_data *sdata;
1722 struct mesh_path *mpath;
1724 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1727 mpath = mpp_path_lookup(sdata, dst);
1732 memcpy(dst, mpath->dst, ETH_ALEN);
1733 mpp_set_pinfo(mpath, mpp, pinfo);
1738 static int ieee80211_dump_mpp(struct wiphy *wiphy, struct net_device *dev,
1739 int idx, u8 *dst, u8 *mpp,
1740 struct mpath_info *pinfo)
1742 struct ieee80211_sub_if_data *sdata;
1743 struct mesh_path *mpath;
1745 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1748 mpath = mpp_path_lookup_by_idx(sdata, idx);
1753 memcpy(dst, mpath->dst, ETH_ALEN);
1754 mpp_set_pinfo(mpath, mpp, pinfo);
1759 static int ieee80211_get_mesh_config(struct wiphy *wiphy,
1760 struct net_device *dev,
1761 struct mesh_config *conf)
1763 struct ieee80211_sub_if_data *sdata;
1764 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1766 memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config));
1770 static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask)
1772 return (mask >> (parm-1)) & 0x1;
1775 static int copy_mesh_setup(struct ieee80211_if_mesh *ifmsh,
1776 const struct mesh_setup *setup)
1779 struct ieee80211_sub_if_data *sdata = container_of(ifmsh,
1780 struct ieee80211_sub_if_data, u.mesh);
1782 /* allocate information elements */
1785 if (setup->ie_len) {
1786 new_ie = kmemdup(setup->ie, setup->ie_len,
1791 ifmsh->ie_len = setup->ie_len;
1794 /* now copy the rest of the setup parameters */
1795 ifmsh->mesh_id_len = setup->mesh_id_len;
1796 memcpy(ifmsh->mesh_id, setup->mesh_id, ifmsh->mesh_id_len);
1797 ifmsh->mesh_sp_id = setup->sync_method;
1798 ifmsh->mesh_pp_id = setup->path_sel_proto;
1799 ifmsh->mesh_pm_id = setup->path_metric;
1800 ifmsh->user_mpm = setup->user_mpm;
1801 ifmsh->mesh_auth_id = setup->auth_id;
1802 ifmsh->security = IEEE80211_MESH_SEC_NONE;
1803 if (setup->is_authenticated)
1804 ifmsh->security |= IEEE80211_MESH_SEC_AUTHED;
1805 if (setup->is_secure)
1806 ifmsh->security |= IEEE80211_MESH_SEC_SECURED;
1808 /* mcast rate setting in Mesh Node */
1809 memcpy(sdata->vif.bss_conf.mcast_rate, setup->mcast_rate,
1810 sizeof(setup->mcast_rate));
1811 sdata->vif.bss_conf.basic_rates = setup->basic_rates;
1813 sdata->vif.bss_conf.beacon_int = setup->beacon_interval;
1814 sdata->vif.bss_conf.dtim_period = setup->dtim_period;
1819 static int ieee80211_update_mesh_config(struct wiphy *wiphy,
1820 struct net_device *dev, u32 mask,
1821 const struct mesh_config *nconf)
1823 struct mesh_config *conf;
1824 struct ieee80211_sub_if_data *sdata;
1825 struct ieee80211_if_mesh *ifmsh;
1827 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1828 ifmsh = &sdata->u.mesh;
1830 /* Set the config options which we are interested in setting */
1831 conf = &(sdata->u.mesh.mshcfg);
1832 if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask))
1833 conf->dot11MeshRetryTimeout = nconf->dot11MeshRetryTimeout;
1834 if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT, mask))
1835 conf->dot11MeshConfirmTimeout = nconf->dot11MeshConfirmTimeout;
1836 if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT, mask))
1837 conf->dot11MeshHoldingTimeout = nconf->dot11MeshHoldingTimeout;
1838 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS, mask))
1839 conf->dot11MeshMaxPeerLinks = nconf->dot11MeshMaxPeerLinks;
1840 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES, mask))
1841 conf->dot11MeshMaxRetries = nconf->dot11MeshMaxRetries;
1842 if (_chg_mesh_attr(NL80211_MESHCONF_TTL, mask))
1843 conf->dot11MeshTTL = nconf->dot11MeshTTL;
1844 if (_chg_mesh_attr(NL80211_MESHCONF_ELEMENT_TTL, mask))
1845 conf->element_ttl = nconf->element_ttl;
1846 if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask)) {
1847 if (ifmsh->user_mpm)
1849 conf->auto_open_plinks = nconf->auto_open_plinks;
1851 if (_chg_mesh_attr(NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR, mask))
1852 conf->dot11MeshNbrOffsetMaxNeighbor =
1853 nconf->dot11MeshNbrOffsetMaxNeighbor;
1854 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, mask))
1855 conf->dot11MeshHWMPmaxPREQretries =
1856 nconf->dot11MeshHWMPmaxPREQretries;
1857 if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME, mask))
1858 conf->path_refresh_time = nconf->path_refresh_time;
1859 if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, mask))
1860 conf->min_discovery_timeout = nconf->min_discovery_timeout;
1861 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, mask))
1862 conf->dot11MeshHWMPactivePathTimeout =
1863 nconf->dot11MeshHWMPactivePathTimeout;
1864 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, mask))
1865 conf->dot11MeshHWMPpreqMinInterval =
1866 nconf->dot11MeshHWMPpreqMinInterval;
1867 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL, mask))
1868 conf->dot11MeshHWMPperrMinInterval =
1869 nconf->dot11MeshHWMPperrMinInterval;
1870 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
1872 conf->dot11MeshHWMPnetDiameterTraversalTime =
1873 nconf->dot11MeshHWMPnetDiameterTraversalTime;
1874 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOTMODE, mask)) {
1875 conf->dot11MeshHWMPRootMode = nconf->dot11MeshHWMPRootMode;
1876 ieee80211_mesh_root_setup(ifmsh);
1878 if (_chg_mesh_attr(NL80211_MESHCONF_GATE_ANNOUNCEMENTS, mask)) {
1879 /* our current gate announcement implementation rides on root
1880 * announcements, so require this ifmsh to also be a root node
1882 if (nconf->dot11MeshGateAnnouncementProtocol &&
1883 !(conf->dot11MeshHWMPRootMode > IEEE80211_ROOTMODE_ROOT)) {
1884 conf->dot11MeshHWMPRootMode = IEEE80211_PROACTIVE_RANN;
1885 ieee80211_mesh_root_setup(ifmsh);
1887 conf->dot11MeshGateAnnouncementProtocol =
1888 nconf->dot11MeshGateAnnouncementProtocol;
1890 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_RANN_INTERVAL, mask))
1891 conf->dot11MeshHWMPRannInterval =
1892 nconf->dot11MeshHWMPRannInterval;
1893 if (_chg_mesh_attr(NL80211_MESHCONF_FORWARDING, mask))
1894 conf->dot11MeshForwarding = nconf->dot11MeshForwarding;
1895 if (_chg_mesh_attr(NL80211_MESHCONF_RSSI_THRESHOLD, mask)) {
1896 /* our RSSI threshold implementation is supported only for
1897 * devices that report signal in dBm.
1899 if (!ieee80211_hw_check(&sdata->local->hw, SIGNAL_DBM))
1901 conf->rssi_threshold = nconf->rssi_threshold;
1903 if (_chg_mesh_attr(NL80211_MESHCONF_HT_OPMODE, mask)) {
1904 conf->ht_opmode = nconf->ht_opmode;
1905 sdata->vif.bss_conf.ht_operation_mode = nconf->ht_opmode;
1906 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_HT);
1908 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT, mask))
1909 conf->dot11MeshHWMPactivePathToRootTimeout =
1910 nconf->dot11MeshHWMPactivePathToRootTimeout;
1911 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOT_INTERVAL, mask))
1912 conf->dot11MeshHWMProotInterval =
1913 nconf->dot11MeshHWMProotInterval;
1914 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL, mask))
1915 conf->dot11MeshHWMPconfirmationInterval =
1916 nconf->dot11MeshHWMPconfirmationInterval;
1917 if (_chg_mesh_attr(NL80211_MESHCONF_POWER_MODE, mask)) {
1918 conf->power_mode = nconf->power_mode;
1919 ieee80211_mps_local_status_update(sdata);
1921 if (_chg_mesh_attr(NL80211_MESHCONF_AWAKE_WINDOW, mask))
1922 conf->dot11MeshAwakeWindowDuration =
1923 nconf->dot11MeshAwakeWindowDuration;
1924 if (_chg_mesh_attr(NL80211_MESHCONF_PLINK_TIMEOUT, mask))
1925 conf->plink_timeout = nconf->plink_timeout;
1926 ieee80211_mbss_info_change_notify(sdata, BSS_CHANGED_BEACON);
1930 static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev,
1931 const struct mesh_config *conf,
1932 const struct mesh_setup *setup)
1934 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1935 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
1938 memcpy(&ifmsh->mshcfg, conf, sizeof(struct mesh_config));
1939 err = copy_mesh_setup(ifmsh, setup);
1943 /* can mesh use other SMPS modes? */
1944 sdata->smps_mode = IEEE80211_SMPS_OFF;
1945 sdata->needed_rx_chains = sdata->local->rx_chains;
1947 mutex_lock(&sdata->local->mtx);
1948 err = ieee80211_vif_use_channel(sdata, &setup->chandef,
1949 IEEE80211_CHANCTX_SHARED);
1950 mutex_unlock(&sdata->local->mtx);
1954 return ieee80211_start_mesh(sdata);
1957 static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev)
1959 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1961 ieee80211_stop_mesh(sdata);
1962 mutex_lock(&sdata->local->mtx);
1963 ieee80211_vif_release_channel(sdata);
1964 kfree(sdata->u.mesh.ie);
1965 mutex_unlock(&sdata->local->mtx);
1971 static int ieee80211_change_bss(struct wiphy *wiphy,
1972 struct net_device *dev,
1973 struct bss_parameters *params)
1975 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1976 struct ieee80211_supported_band *sband;
1979 if (!sdata_dereference(sdata->u.ap.beacon, sdata))
1982 sband = ieee80211_get_sband(sdata);
1986 if (params->use_cts_prot >= 0) {
1987 sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot;
1988 changed |= BSS_CHANGED_ERP_CTS_PROT;
1990 if (params->use_short_preamble >= 0) {
1991 sdata->vif.bss_conf.use_short_preamble =
1992 params->use_short_preamble;
1993 changed |= BSS_CHANGED_ERP_PREAMBLE;
1996 if (!sdata->vif.bss_conf.use_short_slot &&
1997 sband->band == NL80211_BAND_5GHZ) {
1998 sdata->vif.bss_conf.use_short_slot = true;
1999 changed |= BSS_CHANGED_ERP_SLOT;
2002 if (params->use_short_slot_time >= 0) {
2003 sdata->vif.bss_conf.use_short_slot =
2004 params->use_short_slot_time;
2005 changed |= BSS_CHANGED_ERP_SLOT;
2008 if (params->basic_rates) {
2009 ieee80211_parse_bitrates(&sdata->vif.bss_conf.chandef,
2010 wiphy->bands[sband->band],
2011 params->basic_rates,
2012 params->basic_rates_len,
2013 &sdata->vif.bss_conf.basic_rates);
2014 changed |= BSS_CHANGED_BASIC_RATES;
2017 if (params->ap_isolate >= 0) {
2018 if (params->ap_isolate)
2019 sdata->flags |= IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
2021 sdata->flags &= ~IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
2022 ieee80211_check_fast_rx_iface(sdata);
2025 if (params->ht_opmode >= 0) {
2026 sdata->vif.bss_conf.ht_operation_mode =
2027 (u16) params->ht_opmode;
2028 changed |= BSS_CHANGED_HT;
2031 if (params->p2p_ctwindow >= 0) {
2032 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow &=
2033 ~IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
2034 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |=
2035 params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
2036 changed |= BSS_CHANGED_P2P_PS;
2039 if (params->p2p_opp_ps > 0) {
2040 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |=
2041 IEEE80211_P2P_OPPPS_ENABLE_BIT;
2042 changed |= BSS_CHANGED_P2P_PS;
2043 } else if (params->p2p_opp_ps == 0) {
2044 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow &=
2045 ~IEEE80211_P2P_OPPPS_ENABLE_BIT;
2046 changed |= BSS_CHANGED_P2P_PS;
2049 ieee80211_bss_info_change_notify(sdata, changed);
2054 static int ieee80211_set_txq_params(struct wiphy *wiphy,
2055 struct net_device *dev,
2056 struct ieee80211_txq_params *params)
2058 struct ieee80211_local *local = wiphy_priv(wiphy);
2059 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2060 struct ieee80211_tx_queue_params p;
2062 if (!local->ops->conf_tx)
2065 if (local->hw.queues < IEEE80211_NUM_ACS)
2068 memset(&p, 0, sizeof(p));
2069 p.aifs = params->aifs;
2070 p.cw_max = params->cwmax;
2071 p.cw_min = params->cwmin;
2072 p.txop = params->txop;
2075 * Setting tx queue params disables u-apsd because it's only
2076 * called in master mode.
2080 sdata->tx_conf[params->ac] = p;
2081 if (drv_conf_tx(local, sdata, params->ac, &p)) {
2082 wiphy_debug(local->hw.wiphy,
2083 "failed to set TX queue parameters for AC %d\n",
2088 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_QOS);
2094 static int ieee80211_suspend(struct wiphy *wiphy,
2095 struct cfg80211_wowlan *wowlan)
2097 return __ieee80211_suspend(wiphy_priv(wiphy), wowlan);
2100 static int ieee80211_resume(struct wiphy *wiphy)
2102 return __ieee80211_resume(wiphy_priv(wiphy));
2105 #define ieee80211_suspend NULL
2106 #define ieee80211_resume NULL
2109 static int ieee80211_scan(struct wiphy *wiphy,
2110 struct cfg80211_scan_request *req)
2112 struct ieee80211_sub_if_data *sdata;
2114 sdata = IEEE80211_WDEV_TO_SUB_IF(req->wdev);
2116 switch (ieee80211_vif_type_p2p(&sdata->vif)) {
2117 case NL80211_IFTYPE_STATION:
2118 case NL80211_IFTYPE_ADHOC:
2119 case NL80211_IFTYPE_MESH_POINT:
2120 case NL80211_IFTYPE_P2P_CLIENT:
2121 case NL80211_IFTYPE_P2P_DEVICE:
2123 case NL80211_IFTYPE_P2P_GO:
2124 if (sdata->local->ops->hw_scan)
2127 * FIXME: implement NoA while scanning in software,
2128 * for now fall through to allow scanning only when
2129 * beaconing hasn't been configured yet
2131 case NL80211_IFTYPE_AP:
2133 * If the scan has been forced (and the driver supports
2134 * forcing), don't care about being beaconing already.
2135 * This will create problems to the attached stations (e.g. all
2136 * the frames sent while scanning on other channel will be
2139 if (sdata->u.ap.beacon &&
2140 (!(wiphy->features & NL80211_FEATURE_AP_SCAN) ||
2141 !(req->flags & NL80211_SCAN_FLAG_AP)))
2144 case NL80211_IFTYPE_NAN:
2149 return ieee80211_request_scan(sdata, req);
2152 static void ieee80211_abort_scan(struct wiphy *wiphy, struct wireless_dev *wdev)
2154 ieee80211_scan_cancel(wiphy_priv(wiphy));
2158 ieee80211_sched_scan_start(struct wiphy *wiphy,
2159 struct net_device *dev,
2160 struct cfg80211_sched_scan_request *req)
2162 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2164 if (!sdata->local->ops->sched_scan_start)
2167 return ieee80211_request_sched_scan_start(sdata, req);
2171 ieee80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev)
2173 struct ieee80211_local *local = wiphy_priv(wiphy);
2175 if (!local->ops->sched_scan_stop)
2178 return ieee80211_request_sched_scan_stop(local);
2181 static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev,
2182 struct cfg80211_auth_request *req)
2184 return ieee80211_mgd_auth(IEEE80211_DEV_TO_SUB_IF(dev), req);
2187 static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev,
2188 struct cfg80211_assoc_request *req)
2190 return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
2193 static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev,
2194 struct cfg80211_deauth_request *req)
2196 return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev), req);
2199 static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
2200 struct cfg80211_disassoc_request *req)
2202 return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
2205 static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
2206 struct cfg80211_ibss_params *params)
2208 return ieee80211_ibss_join(IEEE80211_DEV_TO_SUB_IF(dev), params);
2211 static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
2213 return ieee80211_ibss_leave(IEEE80211_DEV_TO_SUB_IF(dev));
2216 static int ieee80211_join_ocb(struct wiphy *wiphy, struct net_device *dev,
2217 struct ocb_setup *setup)
2219 return ieee80211_ocb_join(IEEE80211_DEV_TO_SUB_IF(dev), setup);
2222 static int ieee80211_leave_ocb(struct wiphy *wiphy, struct net_device *dev)
2224 return ieee80211_ocb_leave(IEEE80211_DEV_TO_SUB_IF(dev));
2227 static int ieee80211_set_mcast_rate(struct wiphy *wiphy, struct net_device *dev,
2228 int rate[NUM_NL80211_BANDS])
2230 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2232 memcpy(sdata->vif.bss_conf.mcast_rate, rate,
2233 sizeof(int) * NUM_NL80211_BANDS);
2238 static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
2240 struct ieee80211_local *local = wiphy_priv(wiphy);
2243 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
2244 ieee80211_check_fast_xmit_all(local);
2246 err = drv_set_frag_threshold(local, wiphy->frag_threshold);
2249 ieee80211_check_fast_xmit_all(local);
2254 if ((changed & WIPHY_PARAM_COVERAGE_CLASS) ||
2255 (changed & WIPHY_PARAM_DYN_ACK)) {
2258 coverage_class = changed & WIPHY_PARAM_COVERAGE_CLASS ?
2259 wiphy->coverage_class : -1;
2260 err = drv_set_coverage_class(local, coverage_class);
2266 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
2267 err = drv_set_rts_threshold(local, wiphy->rts_threshold);
2273 if (changed & WIPHY_PARAM_RETRY_SHORT) {
2274 if (wiphy->retry_short > IEEE80211_MAX_TX_RETRY)
2276 local->hw.conf.short_frame_max_tx_count = wiphy->retry_short;
2278 if (changed & WIPHY_PARAM_RETRY_LONG) {
2279 if (wiphy->retry_long > IEEE80211_MAX_TX_RETRY)
2281 local->hw.conf.long_frame_max_tx_count = wiphy->retry_long;
2284 (WIPHY_PARAM_RETRY_SHORT | WIPHY_PARAM_RETRY_LONG))
2285 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS);
2290 static int ieee80211_set_tx_power(struct wiphy *wiphy,
2291 struct wireless_dev *wdev,
2292 enum nl80211_tx_power_setting type, int mbm)
2294 struct ieee80211_local *local = wiphy_priv(wiphy);
2295 struct ieee80211_sub_if_data *sdata;
2296 enum nl80211_tx_power_setting txp_type = type;
2297 bool update_txp_type = false;
2298 bool has_monitor = false;
2301 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
2303 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) {
2304 sdata = rtnl_dereference(local->monitor_sdata);
2310 case NL80211_TX_POWER_AUTOMATIC:
2311 sdata->user_power_level = IEEE80211_UNSET_POWER_LEVEL;
2312 txp_type = NL80211_TX_POWER_LIMITED;
2314 case NL80211_TX_POWER_LIMITED:
2315 case NL80211_TX_POWER_FIXED:
2316 if (mbm < 0 || (mbm % 100))
2318 sdata->user_power_level = MBM_TO_DBM(mbm);
2322 if (txp_type != sdata->vif.bss_conf.txpower_type) {
2323 update_txp_type = true;
2324 sdata->vif.bss_conf.txpower_type = txp_type;
2327 ieee80211_recalc_txpower(sdata, update_txp_type);
2333 case NL80211_TX_POWER_AUTOMATIC:
2334 local->user_power_level = IEEE80211_UNSET_POWER_LEVEL;
2335 txp_type = NL80211_TX_POWER_LIMITED;
2337 case NL80211_TX_POWER_LIMITED:
2338 case NL80211_TX_POWER_FIXED:
2339 if (mbm < 0 || (mbm % 100))
2341 local->user_power_level = MBM_TO_DBM(mbm);
2345 mutex_lock(&local->iflist_mtx);
2346 list_for_each_entry(sdata, &local->interfaces, list) {
2347 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) {
2351 sdata->user_power_level = local->user_power_level;
2352 if (txp_type != sdata->vif.bss_conf.txpower_type)
2353 update_txp_type = true;
2354 sdata->vif.bss_conf.txpower_type = txp_type;
2356 list_for_each_entry(sdata, &local->interfaces, list) {
2357 if (sdata->vif.type == NL80211_IFTYPE_MONITOR)
2359 ieee80211_recalc_txpower(sdata, update_txp_type);
2361 mutex_unlock(&local->iflist_mtx);
2364 sdata = rtnl_dereference(local->monitor_sdata);
2366 sdata->user_power_level = local->user_power_level;
2367 if (txp_type != sdata->vif.bss_conf.txpower_type)
2368 update_txp_type = true;
2369 sdata->vif.bss_conf.txpower_type = txp_type;
2371 ieee80211_recalc_txpower(sdata, update_txp_type);
2378 static int ieee80211_get_tx_power(struct wiphy *wiphy,
2379 struct wireless_dev *wdev,
2382 struct ieee80211_local *local = wiphy_priv(wiphy);
2383 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
2385 if (local->ops->get_txpower)
2386 return drv_get_txpower(local, sdata, dbm);
2388 if (!local->use_chanctx)
2389 *dbm = local->hw.conf.power_level;
2391 *dbm = sdata->vif.bss_conf.txpower;
2396 static int ieee80211_set_wds_peer(struct wiphy *wiphy, struct net_device *dev,
2399 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2401 memcpy(&sdata->u.wds.remote_addr, addr, ETH_ALEN);
2406 static void ieee80211_rfkill_poll(struct wiphy *wiphy)
2408 struct ieee80211_local *local = wiphy_priv(wiphy);
2410 drv_rfkill_poll(local);
2413 #ifdef CONFIG_NL80211_TESTMODE
2414 static int ieee80211_testmode_cmd(struct wiphy *wiphy,
2415 struct wireless_dev *wdev,
2416 void *data, int len)
2418 struct ieee80211_local *local = wiphy_priv(wiphy);
2419 struct ieee80211_vif *vif = NULL;
2421 if (!local->ops->testmode_cmd)
2425 struct ieee80211_sub_if_data *sdata;
2427 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
2428 if (sdata->flags & IEEE80211_SDATA_IN_DRIVER)
2432 return local->ops->testmode_cmd(&local->hw, vif, data, len);
2435 static int ieee80211_testmode_dump(struct wiphy *wiphy,
2436 struct sk_buff *skb,
2437 struct netlink_callback *cb,
2438 void *data, int len)
2440 struct ieee80211_local *local = wiphy_priv(wiphy);
2442 if (!local->ops->testmode_dump)
2445 return local->ops->testmode_dump(&local->hw, skb, cb, data, len);
2449 int __ieee80211_request_smps_ap(struct ieee80211_sub_if_data *sdata,
2450 enum ieee80211_smps_mode smps_mode)
2452 struct sta_info *sta;
2453 enum ieee80211_smps_mode old_req;
2455 if (WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_AP))
2458 if (sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT)
2461 old_req = sdata->u.ap.req_smps;
2462 sdata->u.ap.req_smps = smps_mode;
2464 /* AUTOMATIC doesn't mean much for AP - don't allow it */
2465 if (old_req == smps_mode ||
2466 smps_mode == IEEE80211_SMPS_AUTOMATIC)
2469 /* If no associated stations, there's no need to do anything */
2470 if (!atomic_read(&sdata->u.ap.num_mcast_sta)) {
2471 sdata->smps_mode = smps_mode;
2472 ieee80211_queue_work(&sdata->local->hw, &sdata->recalc_smps);
2477 "SMPS %d requested in AP mode, sending Action frame to %d stations\n",
2478 smps_mode, atomic_read(&sdata->u.ap.num_mcast_sta));
2480 mutex_lock(&sdata->local->sta_mtx);
2481 list_for_each_entry(sta, &sdata->local->sta_list, list) {
2483 * Only stations associated to our AP and
2486 if (sta->sdata->bss != &sdata->u.ap)
2489 /* This station doesn't support MIMO - skip it */
2490 if (sta_info_tx_streams(sta) == 1)
2494 * Don't wake up a STA just to send the action frame
2495 * unless we are getting more restrictive.
2497 if (test_sta_flag(sta, WLAN_STA_PS_STA) &&
2498 !ieee80211_smps_is_restrictive(sta->known_smps_mode,
2500 ht_dbg(sdata, "Won't send SMPS to sleeping STA %pM\n",
2506 * If the STA is not authorized, wait until it gets
2507 * authorized and the action frame will be sent then.
2509 if (!test_sta_flag(sta, WLAN_STA_AUTHORIZED))
2512 ht_dbg(sdata, "Sending SMPS to %pM\n", sta->sta.addr);
2513 ieee80211_send_smps_action(sdata, smps_mode, sta->sta.addr,
2514 sdata->vif.bss_conf.bssid);
2516 mutex_unlock(&sdata->local->sta_mtx);
2518 sdata->smps_mode = smps_mode;
2519 ieee80211_queue_work(&sdata->local->hw, &sdata->recalc_smps);
2524 int __ieee80211_request_smps_mgd(struct ieee80211_sub_if_data *sdata,
2525 enum ieee80211_smps_mode smps_mode)
2528 enum ieee80211_smps_mode old_req;
2530 struct sta_info *sta;
2531 bool tdls_peer_found = false;
2533 lockdep_assert_held(&sdata->wdev.mtx);
2535 if (WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION))
2538 old_req = sdata->u.mgd.req_smps;
2539 sdata->u.mgd.req_smps = smps_mode;
2541 if (old_req == smps_mode &&
2542 smps_mode != IEEE80211_SMPS_AUTOMATIC)
2546 * If not associated, or current association is not an HT
2547 * association, there's no need to do anything, just store
2548 * the new value until we associate.
2550 if (!sdata->u.mgd.associated ||
2551 sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT)
2554 ap = sdata->u.mgd.associated->bssid;
2557 list_for_each_entry_rcu(sta, &sdata->local->sta_list, list) {
2558 if (!sta->sta.tdls || sta->sdata != sdata || !sta->uploaded ||
2559 !test_sta_flag(sta, WLAN_STA_AUTHORIZED))
2562 tdls_peer_found = true;
2567 if (smps_mode == IEEE80211_SMPS_AUTOMATIC) {
2568 if (tdls_peer_found || !sdata->u.mgd.powersave)
2569 smps_mode = IEEE80211_SMPS_OFF;
2571 smps_mode = IEEE80211_SMPS_DYNAMIC;
2574 /* send SM PS frame to AP */
2575 err = ieee80211_send_smps_action(sdata, smps_mode,
2578 sdata->u.mgd.req_smps = old_req;
2579 else if (smps_mode != IEEE80211_SMPS_OFF && tdls_peer_found)
2580 ieee80211_teardown_tdls_peers(sdata);
2585 static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
2586 bool enabled, int timeout)
2588 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2589 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2591 if (sdata->vif.type != NL80211_IFTYPE_STATION)
2594 if (!ieee80211_hw_check(&local->hw, SUPPORTS_PS))
2597 if (enabled == sdata->u.mgd.powersave &&
2598 timeout == local->dynamic_ps_forced_timeout)
2601 sdata->u.mgd.powersave = enabled;
2602 local->dynamic_ps_forced_timeout = timeout;
2604 /* no change, but if automatic follow powersave */
2606 __ieee80211_request_smps_mgd(sdata, sdata->u.mgd.req_smps);
2607 sdata_unlock(sdata);
2609 if (ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS))
2610 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
2612 ieee80211_recalc_ps(local);
2613 ieee80211_recalc_ps_vif(sdata);
2618 static int ieee80211_set_cqm_rssi_config(struct wiphy *wiphy,
2619 struct net_device *dev,
2620 s32 rssi_thold, u32 rssi_hyst)
2622 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2623 struct ieee80211_vif *vif = &sdata->vif;
2624 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
2626 if (rssi_thold == bss_conf->cqm_rssi_thold &&
2627 rssi_hyst == bss_conf->cqm_rssi_hyst)
2630 if (sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER &&
2631 !(sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI))
2634 bss_conf->cqm_rssi_thold = rssi_thold;
2635 bss_conf->cqm_rssi_hyst = rssi_hyst;
2636 sdata->u.mgd.last_cqm_event_signal = 0;
2638 /* tell the driver upon association, unless already associated */
2639 if (sdata->u.mgd.associated &&
2640 sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)
2641 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_CQM);
2646 static int ieee80211_set_bitrate_mask(struct wiphy *wiphy,
2647 struct net_device *dev,
2649 const struct cfg80211_bitrate_mask *mask)
2651 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2652 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2655 if (!ieee80211_sdata_running(sdata))
2658 if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) {
2659 ret = drv_set_bitrate_mask(local, sdata, mask);
2664 for (i = 0; i < NUM_NL80211_BANDS; i++) {
2665 struct ieee80211_supported_band *sband = wiphy->bands[i];
2668 sdata->rc_rateidx_mask[i] = mask->control[i].legacy;
2669 memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].ht_mcs,
2670 sizeof(mask->control[i].ht_mcs));
2671 memcpy(sdata->rc_rateidx_vht_mcs_mask[i],
2672 mask->control[i].vht_mcs,
2673 sizeof(mask->control[i].vht_mcs));
2675 sdata->rc_has_mcs_mask[i] = false;
2676 sdata->rc_has_vht_mcs_mask[i] = false;
2680 for (j = 0; j < IEEE80211_HT_MCS_MASK_LEN; j++) {
2681 if (sdata->rc_rateidx_mcs_mask[i][j] != 0xff) {
2682 sdata->rc_has_mcs_mask[i] = true;
2687 for (j = 0; j < NL80211_VHT_NSS_MAX; j++) {
2688 if (sdata->rc_rateidx_vht_mcs_mask[i][j] != 0xffff) {
2689 sdata->rc_has_vht_mcs_mask[i] = true;
2698 static int ieee80211_start_radar_detection(struct wiphy *wiphy,
2699 struct net_device *dev,
2700 struct cfg80211_chan_def *chandef,
2703 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2704 struct ieee80211_local *local = sdata->local;
2707 mutex_lock(&local->mtx);
2708 if (!list_empty(&local->roc_list) || local->scanning) {
2713 /* whatever, but channel contexts should not complain about that one */
2714 sdata->smps_mode = IEEE80211_SMPS_OFF;
2715 sdata->needed_rx_chains = local->rx_chains;
2717 err = ieee80211_vif_use_channel(sdata, chandef,
2718 IEEE80211_CHANCTX_SHARED);
2722 ieee80211_queue_delayed_work(&sdata->local->hw,
2723 &sdata->dfs_cac_timer_work,
2724 msecs_to_jiffies(cac_time_ms));
2727 mutex_unlock(&local->mtx);
2731 static struct cfg80211_beacon_data *
2732 cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon)
2734 struct cfg80211_beacon_data *new_beacon;
2738 len = beacon->head_len + beacon->tail_len + beacon->beacon_ies_len +
2739 beacon->proberesp_ies_len + beacon->assocresp_ies_len +
2740 beacon->probe_resp_len;
2742 new_beacon = kzalloc(sizeof(*new_beacon) + len, GFP_KERNEL);
2746 pos = (u8 *)(new_beacon + 1);
2747 if (beacon->head_len) {
2748 new_beacon->head_len = beacon->head_len;
2749 new_beacon->head = pos;
2750 memcpy(pos, beacon->head, beacon->head_len);
2751 pos += beacon->head_len;
2753 if (beacon->tail_len) {
2754 new_beacon->tail_len = beacon->tail_len;
2755 new_beacon->tail = pos;
2756 memcpy(pos, beacon->tail, beacon->tail_len);
2757 pos += beacon->tail_len;
2759 if (beacon->beacon_ies_len) {
2760 new_beacon->beacon_ies_len = beacon->beacon_ies_len;
2761 new_beacon->beacon_ies = pos;
2762 memcpy(pos, beacon->beacon_ies, beacon->beacon_ies_len);
2763 pos += beacon->beacon_ies_len;
2765 if (beacon->proberesp_ies_len) {
2766 new_beacon->proberesp_ies_len = beacon->proberesp_ies_len;
2767 new_beacon->proberesp_ies = pos;
2768 memcpy(pos, beacon->proberesp_ies, beacon->proberesp_ies_len);
2769 pos += beacon->proberesp_ies_len;
2771 if (beacon->assocresp_ies_len) {
2772 new_beacon->assocresp_ies_len = beacon->assocresp_ies_len;
2773 new_beacon->assocresp_ies = pos;
2774 memcpy(pos, beacon->assocresp_ies, beacon->assocresp_ies_len);
2775 pos += beacon->assocresp_ies_len;
2777 if (beacon->probe_resp_len) {
2778 new_beacon->probe_resp_len = beacon->probe_resp_len;
2779 new_beacon->probe_resp = pos;
2780 memcpy(pos, beacon->probe_resp, beacon->probe_resp_len);
2781 pos += beacon->probe_resp_len;
2787 void ieee80211_csa_finish(struct ieee80211_vif *vif)
2789 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
2791 ieee80211_queue_work(&sdata->local->hw,
2792 &sdata->csa_finalize_work);
2794 EXPORT_SYMBOL(ieee80211_csa_finish);
2796 static int ieee80211_set_after_csa_beacon(struct ieee80211_sub_if_data *sdata,
2801 switch (sdata->vif.type) {
2802 case NL80211_IFTYPE_AP:
2803 err = ieee80211_assign_beacon(sdata, sdata->u.ap.next_beacon,
2805 kfree(sdata->u.ap.next_beacon);
2806 sdata->u.ap.next_beacon = NULL;
2812 case NL80211_IFTYPE_ADHOC:
2813 err = ieee80211_ibss_finish_csa(sdata);
2818 #ifdef CONFIG_MAC80211_MESH
2819 case NL80211_IFTYPE_MESH_POINT:
2820 err = ieee80211_mesh_finish_csa(sdata);
2834 static int __ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata)
2836 struct ieee80211_local *local = sdata->local;
2840 sdata_assert_lock(sdata);
2841 lockdep_assert_held(&local->mtx);
2842 lockdep_assert_held(&local->chanctx_mtx);
2845 * using reservation isn't immediate as it may be deferred until later
2846 * with multi-vif. once reservation is complete it will re-schedule the
2847 * work with no reserved_chanctx so verify chandef to check if it
2848 * completed successfully
2851 if (sdata->reserved_chanctx) {
2853 * with multi-vif csa driver may call ieee80211_csa_finish()
2854 * many times while waiting for other interfaces to use their
2857 if (sdata->reserved_ready)
2860 return ieee80211_vif_use_reserved_context(sdata);
2863 if (!cfg80211_chandef_identical(&sdata->vif.bss_conf.chandef,
2864 &sdata->csa_chandef))
2867 sdata->vif.csa_active = false;
2869 err = ieee80211_set_after_csa_beacon(sdata, &changed);
2873 ieee80211_bss_info_change_notify(sdata, changed);
2875 if (sdata->csa_block_tx) {
2876 ieee80211_wake_vif_queues(local, sdata,
2877 IEEE80211_QUEUE_STOP_REASON_CSA);
2878 sdata->csa_block_tx = false;
2881 err = drv_post_channel_switch(sdata);
2885 cfg80211_ch_switch_notify(sdata->dev, &sdata->csa_chandef);
2890 static void ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata)
2892 if (__ieee80211_csa_finalize(sdata)) {
2893 sdata_info(sdata, "failed to finalize CSA, disconnecting\n");
2894 cfg80211_stop_iface(sdata->local->hw.wiphy, &sdata->wdev,
2899 void ieee80211_csa_finalize_work(struct work_struct *work)
2901 struct ieee80211_sub_if_data *sdata =
2902 container_of(work, struct ieee80211_sub_if_data,
2904 struct ieee80211_local *local = sdata->local;
2907 mutex_lock(&local->mtx);
2908 mutex_lock(&local->chanctx_mtx);
2910 /* AP might have been stopped while waiting for the lock. */
2911 if (!sdata->vif.csa_active)
2914 if (!ieee80211_sdata_running(sdata))
2917 ieee80211_csa_finalize(sdata);
2920 mutex_unlock(&local->chanctx_mtx);
2921 mutex_unlock(&local->mtx);
2922 sdata_unlock(sdata);
2925 static int ieee80211_set_csa_beacon(struct ieee80211_sub_if_data *sdata,
2926 struct cfg80211_csa_settings *params,
2929 struct ieee80211_csa_settings csa = {};
2932 switch (sdata->vif.type) {
2933 case NL80211_IFTYPE_AP:
2934 sdata->u.ap.next_beacon =
2935 cfg80211_beacon_dup(¶ms->beacon_after);
2936 if (!sdata->u.ap.next_beacon)
2940 * With a count of 0, we don't have to wait for any
2941 * TBTT before switching, so complete the CSA
2942 * immediately. In theory, with a count == 1 we
2943 * should delay the switch until just before the next
2944 * TBTT, but that would complicate things so we switch
2945 * immediately too. If we would delay the switch
2946 * until the next TBTT, we would have to set the probe
2949 * TODO: A channel switch with count <= 1 without
2950 * sending a CSA action frame is kind of useless,
2951 * because the clients won't know we're changing
2952 * channels. The action frame must be implemented
2953 * either here or in the userspace.
2955 if (params->count <= 1)
2958 if ((params->n_counter_offsets_beacon >
2959 IEEE80211_MAX_CSA_COUNTERS_NUM) ||
2960 (params->n_counter_offsets_presp >
2961 IEEE80211_MAX_CSA_COUNTERS_NUM))
2964 csa.counter_offsets_beacon = params->counter_offsets_beacon;
2965 csa.counter_offsets_presp = params->counter_offsets_presp;
2966 csa.n_counter_offsets_beacon = params->n_counter_offsets_beacon;
2967 csa.n_counter_offsets_presp = params->n_counter_offsets_presp;
2968 csa.count = params->count;
2970 err = ieee80211_assign_beacon(sdata, ¶ms->beacon_csa, &csa);
2972 kfree(sdata->u.ap.next_beacon);
2978 case NL80211_IFTYPE_ADHOC:
2979 if (!sdata->vif.bss_conf.ibss_joined)
2982 if (params->chandef.width != sdata->u.ibss.chandef.width)
2985 switch (params->chandef.width) {
2986 case NL80211_CHAN_WIDTH_40:
2987 if (cfg80211_get_chandef_type(¶ms->chandef) !=
2988 cfg80211_get_chandef_type(&sdata->u.ibss.chandef))
2990 case NL80211_CHAN_WIDTH_5:
2991 case NL80211_CHAN_WIDTH_10:
2992 case NL80211_CHAN_WIDTH_20_NOHT:
2993 case NL80211_CHAN_WIDTH_20:
2999 /* changes into another band are not supported */
3000 if (sdata->u.ibss.chandef.chan->band !=
3001 params->chandef.chan->band)
3004 /* see comments in the NL80211_IFTYPE_AP block */
3005 if (params->count > 1) {
3006 err = ieee80211_ibss_csa_beacon(sdata, params);
3012 ieee80211_send_action_csa(sdata, params);
3015 #ifdef CONFIG_MAC80211_MESH
3016 case NL80211_IFTYPE_MESH_POINT: {
3017 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
3019 if (params->chandef.width != sdata->vif.bss_conf.chandef.width)
3022 /* changes into another band are not supported */
3023 if (sdata->vif.bss_conf.chandef.chan->band !=
3024 params->chandef.chan->band)
3027 if (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_NONE) {
3028 ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_INIT;
3029 if (!ifmsh->pre_value)
3030 ifmsh->pre_value = 1;
3035 /* see comments in the NL80211_IFTYPE_AP block */
3036 if (params->count > 1) {
3037 err = ieee80211_mesh_csa_beacon(sdata, params);
3039 ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_NONE;
3045 if (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_INIT)
3046 ieee80211_send_action_csa(sdata, params);
3059 __ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
3060 struct cfg80211_csa_settings *params)
3062 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3063 struct ieee80211_local *local = sdata->local;
3064 struct ieee80211_channel_switch ch_switch;
3065 struct ieee80211_chanctx_conf *conf;
3066 struct ieee80211_chanctx *chanctx;
3070 sdata_assert_lock(sdata);
3071 lockdep_assert_held(&local->mtx);
3073 if (!list_empty(&local->roc_list) || local->scanning)
3076 if (sdata->wdev.cac_started)
3079 if (cfg80211_chandef_identical(¶ms->chandef,
3080 &sdata->vif.bss_conf.chandef))
3083 /* don't allow another channel switch if one is already active. */
3084 if (sdata->vif.csa_active)
3087 mutex_lock(&local->chanctx_mtx);
3088 conf = rcu_dereference_protected(sdata->vif.chanctx_conf,
3089 lockdep_is_held(&local->chanctx_mtx));
3095 chanctx = container_of(conf, struct ieee80211_chanctx, conf);
3097 ch_switch.timestamp = 0;
3098 ch_switch.device_timestamp = 0;
3099 ch_switch.block_tx = params->block_tx;
3100 ch_switch.chandef = params->chandef;
3101 ch_switch.count = params->count;
3103 err = drv_pre_channel_switch(sdata, &ch_switch);
3107 err = ieee80211_vif_reserve_chanctx(sdata, ¶ms->chandef,
3109 params->radar_required);
3113 /* if reservation is invalid then this will fail */
3114 err = ieee80211_check_combinations(sdata, NULL, chanctx->mode, 0);
3116 ieee80211_vif_unreserve_chanctx(sdata);
3120 err = ieee80211_set_csa_beacon(sdata, params, &changed);
3122 ieee80211_vif_unreserve_chanctx(sdata);
3126 sdata->csa_chandef = params->chandef;
3127 sdata->csa_block_tx = params->block_tx;
3128 sdata->vif.csa_active = true;
3130 if (sdata->csa_block_tx)
3131 ieee80211_stop_vif_queues(local, sdata,
3132 IEEE80211_QUEUE_STOP_REASON_CSA);
3134 cfg80211_ch_switch_started_notify(sdata->dev, &sdata->csa_chandef,
3138 ieee80211_bss_info_change_notify(sdata, changed);
3139 drv_channel_switch_beacon(sdata, ¶ms->chandef);
3141 /* if the beacon didn't change, we can finalize immediately */
3142 ieee80211_csa_finalize(sdata);
3146 mutex_unlock(&local->chanctx_mtx);
3150 int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
3151 struct cfg80211_csa_settings *params)
3153 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3154 struct ieee80211_local *local = sdata->local;
3157 mutex_lock(&local->mtx);
3158 err = __ieee80211_channel_switch(wiphy, dev, params);
3159 mutex_unlock(&local->mtx);
3164 u64 ieee80211_mgmt_tx_cookie(struct ieee80211_local *local)
3166 lockdep_assert_held(&local->mtx);
3168 local->roc_cookie_counter++;
3170 /* wow, you wrapped 64 bits ... more likely a bug */
3171 if (WARN_ON(local->roc_cookie_counter == 0))
3172 local->roc_cookie_counter++;
3174 return local->roc_cookie_counter;
3177 int ieee80211_attach_ack_skb(struct ieee80211_local *local, struct sk_buff *skb,
3178 u64 *cookie, gfp_t gfp)
3180 unsigned long spin_flags;
3181 struct sk_buff *ack_skb;
3184 ack_skb = skb_copy(skb, gfp);
3188 spin_lock_irqsave(&local->ack_status_lock, spin_flags);
3189 id = idr_alloc(&local->ack_status_frames, ack_skb,
3190 1, 0x10000, GFP_ATOMIC);
3191 spin_unlock_irqrestore(&local->ack_status_lock, spin_flags);
3198 IEEE80211_SKB_CB(skb)->ack_frame_id = id;
3200 *cookie = ieee80211_mgmt_tx_cookie(local);
3201 IEEE80211_SKB_CB(ack_skb)->ack.cookie = *cookie;
3206 static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
3207 struct wireless_dev *wdev,
3208 u16 frame_type, bool reg)
3210 struct ieee80211_local *local = wiphy_priv(wiphy);
3211 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
3213 switch (frame_type) {
3214 case IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ:
3216 local->probe_req_reg++;
3217 sdata->vif.probe_req_reg++;
3219 if (local->probe_req_reg)
3220 local->probe_req_reg--;
3222 if (sdata->vif.probe_req_reg)
3223 sdata->vif.probe_req_reg--;
3226 if (!local->open_count)
3229 if (sdata->vif.probe_req_reg == 1)
3230 drv_config_iface_filter(local, sdata, FIF_PROBE_REQ,
3232 else if (sdata->vif.probe_req_reg == 0)
3233 drv_config_iface_filter(local, sdata, 0,
3236 ieee80211_configure_filter(local);
3243 static int ieee80211_set_antenna(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant)
3245 struct ieee80211_local *local = wiphy_priv(wiphy);
3250 return drv_set_antenna(local, tx_ant, rx_ant);
3253 static int ieee80211_get_antenna(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant)
3255 struct ieee80211_local *local = wiphy_priv(wiphy);
3257 return drv_get_antenna(local, tx_ant, rx_ant);
3260 static int ieee80211_set_rekey_data(struct wiphy *wiphy,
3261 struct net_device *dev,
3262 struct cfg80211_gtk_rekey_data *data)
3264 struct ieee80211_local *local = wiphy_priv(wiphy);
3265 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3267 if (!local->ops->set_rekey_data)
3270 drv_set_rekey_data(local, sdata, data);
3275 static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev,
3276 const u8 *peer, u64 *cookie)
3278 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3279 struct ieee80211_local *local = sdata->local;
3280 struct ieee80211_qos_hdr *nullfunc;
3281 struct sk_buff *skb;
3282 int size = sizeof(*nullfunc);
3285 struct ieee80211_tx_info *info;
3286 struct sta_info *sta;
3287 struct ieee80211_chanctx_conf *chanctx_conf;
3288 enum nl80211_band band;
3291 /* the lock is needed to assign the cookie later */
3292 mutex_lock(&local->mtx);
3295 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
3296 if (WARN_ON(!chanctx_conf)) {
3300 band = chanctx_conf->def.chan->band;
3301 sta = sta_info_get_bss(sdata, peer);
3310 fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
3311 IEEE80211_STYPE_QOS_NULLFUNC |
3312 IEEE80211_FCTL_FROMDS);
3315 fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
3316 IEEE80211_STYPE_NULLFUNC |
3317 IEEE80211_FCTL_FROMDS);
3320 skb = dev_alloc_skb(local->hw.extra_tx_headroom + size);
3328 skb_reserve(skb, local->hw.extra_tx_headroom);
3330 nullfunc = (void *) skb_put(skb, size);
3331 nullfunc->frame_control = fc;
3332 nullfunc->duration_id = 0;
3333 memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN);
3334 memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN);
3335 memcpy(nullfunc->addr3, sdata->vif.addr, ETH_ALEN);
3336 nullfunc->seq_ctrl = 0;
3338 info = IEEE80211_SKB_CB(skb);
3340 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS |
3341 IEEE80211_TX_INTFL_NL80211_FRAME_TX;
3344 skb_set_queue_mapping(skb, IEEE80211_AC_VO);
3347 nullfunc->qos_ctrl = cpu_to_le16(7);
3349 ret = ieee80211_attach_ack_skb(local, skb, cookie, GFP_ATOMIC);
3356 ieee80211_xmit(sdata, sta, skb);
3362 mutex_unlock(&local->mtx);
3367 static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
3368 struct wireless_dev *wdev,
3369 struct cfg80211_chan_def *chandef)
3371 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
3372 struct ieee80211_local *local = wiphy_priv(wiphy);
3373 struct ieee80211_chanctx_conf *chanctx_conf;
3377 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
3379 *chandef = sdata->vif.bss_conf.chandef;
3381 } else if (local->open_count > 0 &&
3382 local->open_count == local->monitors &&
3383 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
3384 if (local->use_chanctx)
3385 *chandef = local->monitor_chandef;
3387 *chandef = local->_oper_chandef;
3396 static void ieee80211_set_wakeup(struct wiphy *wiphy, bool enabled)
3398 drv_set_wakeup(wiphy_priv(wiphy), enabled);
3402 static int ieee80211_set_qos_map(struct wiphy *wiphy,
3403 struct net_device *dev,
3404 struct cfg80211_qos_map *qos_map)
3406 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3407 struct mac80211_qos_map *new_qos_map, *old_qos_map;
3410 new_qos_map = kzalloc(sizeof(*new_qos_map), GFP_KERNEL);
3413 memcpy(&new_qos_map->qos_map, qos_map, sizeof(*qos_map));
3415 /* A NULL qos_map was passed to disable QoS mapping */
3419 old_qos_map = sdata_dereference(sdata->qos_map, sdata);
3420 rcu_assign_pointer(sdata->qos_map, new_qos_map);
3422 kfree_rcu(old_qos_map, rcu_head);
3427 static int ieee80211_set_ap_chanwidth(struct wiphy *wiphy,
3428 struct net_device *dev,
3429 struct cfg80211_chan_def *chandef)
3431 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3435 ret = ieee80211_vif_change_bandwidth(sdata, chandef, &changed);
3437 ieee80211_bss_info_change_notify(sdata, changed);
3442 static int ieee80211_add_tx_ts(struct wiphy *wiphy, struct net_device *dev,
3443 u8 tsid, const u8 *peer, u8 up,
3446 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3447 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
3448 int ac = ieee802_1d_to_ac[up];
3450 if (sdata->vif.type != NL80211_IFTYPE_STATION)
3453 if (!(sdata->wmm_acm & BIT(up)))
3456 if (ifmgd->tx_tspec[ac].admitted_time)
3459 if (admitted_time) {
3460 ifmgd->tx_tspec[ac].admitted_time = 32 * admitted_time;
3461 ifmgd->tx_tspec[ac].tsid = tsid;
3462 ifmgd->tx_tspec[ac].up = up;
3468 static int ieee80211_del_tx_ts(struct wiphy *wiphy, struct net_device *dev,
3469 u8 tsid, const u8 *peer)
3471 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3472 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
3473 struct ieee80211_local *local = wiphy_priv(wiphy);
3476 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
3477 struct ieee80211_sta_tx_tspec *tx_tspec = &ifmgd->tx_tspec[ac];
3479 /* skip unused entries */
3480 if (!tx_tspec->admitted_time)
3483 if (tx_tspec->tsid != tsid)
3486 /* due to this new packets will be reassigned to non-ACM ACs */
3489 /* Make sure that all packets have been sent to avoid to
3490 * restore the QoS params on packets that are still on the
3494 ieee80211_flush_queues(local, sdata, false);
3496 /* restore the normal QoS parameters
3497 * (unconditionally to avoid races)
3499 tx_tspec->action = TX_TSPEC_ACTION_STOP_DOWNGRADE;
3500 tx_tspec->downgraded = false;
3501 ieee80211_sta_handle_tspec_ac_params(sdata);
3503 /* finally clear all the data */
3504 memset(tx_tspec, 0, sizeof(*tx_tspec));
3512 void ieee80211_nan_func_terminated(struct ieee80211_vif *vif,
3514 enum nl80211_nan_func_term_reason reason,
3517 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
3518 struct cfg80211_nan_func *func;
3521 if (WARN_ON(vif->type != NL80211_IFTYPE_NAN))
3524 spin_lock_bh(&sdata->u.nan.func_lock);
3526 func = idr_find(&sdata->u.nan.function_inst_ids, inst_id);
3527 if (WARN_ON(!func)) {
3528 spin_unlock_bh(&sdata->u.nan.func_lock);
3532 cookie = func->cookie;
3533 idr_remove(&sdata->u.nan.function_inst_ids, inst_id);
3535 spin_unlock_bh(&sdata->u.nan.func_lock);
3537 cfg80211_free_nan_func(func);
3539 cfg80211_nan_func_terminated(ieee80211_vif_to_wdev(vif), inst_id,
3540 reason, cookie, gfp);
3542 EXPORT_SYMBOL(ieee80211_nan_func_terminated);
3544 void ieee80211_nan_func_match(struct ieee80211_vif *vif,
3545 struct cfg80211_nan_match_params *match,
3548 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
3549 struct cfg80211_nan_func *func;
3551 if (WARN_ON(vif->type != NL80211_IFTYPE_NAN))
3554 spin_lock_bh(&sdata->u.nan.func_lock);
3556 func = idr_find(&sdata->u.nan.function_inst_ids, match->inst_id);
3557 if (WARN_ON(!func)) {
3558 spin_unlock_bh(&sdata->u.nan.func_lock);
3561 match->cookie = func->cookie;
3563 spin_unlock_bh(&sdata->u.nan.func_lock);
3565 cfg80211_nan_match(ieee80211_vif_to_wdev(vif), match, gfp);
3567 EXPORT_SYMBOL(ieee80211_nan_func_match);
3569 const struct cfg80211_ops mac80211_config_ops = {
3570 .add_virtual_intf = ieee80211_add_iface,
3571 .del_virtual_intf = ieee80211_del_iface,
3572 .change_virtual_intf = ieee80211_change_iface,
3573 .start_p2p_device = ieee80211_start_p2p_device,
3574 .stop_p2p_device = ieee80211_stop_p2p_device,
3575 .add_key = ieee80211_add_key,
3576 .del_key = ieee80211_del_key,
3577 .get_key = ieee80211_get_key,
3578 .set_default_key = ieee80211_config_default_key,
3579 .set_default_mgmt_key = ieee80211_config_default_mgmt_key,
3580 .start_ap = ieee80211_start_ap,
3581 .change_beacon = ieee80211_change_beacon,
3582 .stop_ap = ieee80211_stop_ap,
3583 .add_station = ieee80211_add_station,
3584 .del_station = ieee80211_del_station,
3585 .change_station = ieee80211_change_station,
3586 .get_station = ieee80211_get_station,
3587 .dump_station = ieee80211_dump_station,
3588 .dump_survey = ieee80211_dump_survey,
3589 #ifdef CONFIG_MAC80211_MESH
3590 .add_mpath = ieee80211_add_mpath,
3591 .del_mpath = ieee80211_del_mpath,
3592 .change_mpath = ieee80211_change_mpath,
3593 .get_mpath = ieee80211_get_mpath,
3594 .dump_mpath = ieee80211_dump_mpath,
3595 .get_mpp = ieee80211_get_mpp,
3596 .dump_mpp = ieee80211_dump_mpp,
3597 .update_mesh_config = ieee80211_update_mesh_config,
3598 .get_mesh_config = ieee80211_get_mesh_config,
3599 .join_mesh = ieee80211_join_mesh,
3600 .leave_mesh = ieee80211_leave_mesh,
3602 .join_ocb = ieee80211_join_ocb,
3603 .leave_ocb = ieee80211_leave_ocb,
3604 .change_bss = ieee80211_change_bss,
3605 .set_txq_params = ieee80211_set_txq_params,
3606 .set_monitor_channel = ieee80211_set_monitor_channel,
3607 .suspend = ieee80211_suspend,
3608 .resume = ieee80211_resume,
3609 .scan = ieee80211_scan,
3610 .abort_scan = ieee80211_abort_scan,
3611 .sched_scan_start = ieee80211_sched_scan_start,
3612 .sched_scan_stop = ieee80211_sched_scan_stop,
3613 .auth = ieee80211_auth,
3614 .assoc = ieee80211_assoc,
3615 .deauth = ieee80211_deauth,
3616 .disassoc = ieee80211_disassoc,
3617 .join_ibss = ieee80211_join_ibss,
3618 .leave_ibss = ieee80211_leave_ibss,
3619 .set_mcast_rate = ieee80211_set_mcast_rate,
3620 .set_wiphy_params = ieee80211_set_wiphy_params,
3621 .set_tx_power = ieee80211_set_tx_power,
3622 .get_tx_power = ieee80211_get_tx_power,
3623 .set_wds_peer = ieee80211_set_wds_peer,
3624 .rfkill_poll = ieee80211_rfkill_poll,
3625 CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd)
3626 CFG80211_TESTMODE_DUMP(ieee80211_testmode_dump)
3627 .set_power_mgmt = ieee80211_set_power_mgmt,
3628 .set_bitrate_mask = ieee80211_set_bitrate_mask,
3629 .remain_on_channel = ieee80211_remain_on_channel,
3630 .cancel_remain_on_channel = ieee80211_cancel_remain_on_channel,
3631 .mgmt_tx = ieee80211_mgmt_tx,
3632 .mgmt_tx_cancel_wait = ieee80211_mgmt_tx_cancel_wait,
3633 .set_cqm_rssi_config = ieee80211_set_cqm_rssi_config,
3634 .mgmt_frame_register = ieee80211_mgmt_frame_register,
3635 .set_antenna = ieee80211_set_antenna,
3636 .get_antenna = ieee80211_get_antenna,
3637 .set_rekey_data = ieee80211_set_rekey_data,
3638 .tdls_oper = ieee80211_tdls_oper,
3639 .tdls_mgmt = ieee80211_tdls_mgmt,
3640 .tdls_channel_switch = ieee80211_tdls_channel_switch,
3641 .tdls_cancel_channel_switch = ieee80211_tdls_cancel_channel_switch,
3642 .probe_client = ieee80211_probe_client,
3643 .set_noack_map = ieee80211_set_noack_map,
3645 .set_wakeup = ieee80211_set_wakeup,
3647 .get_channel = ieee80211_cfg_get_channel,
3648 .start_radar_detection = ieee80211_start_radar_detection,
3649 .channel_switch = ieee80211_channel_switch,
3650 .set_qos_map = ieee80211_set_qos_map,
3651 .set_ap_chanwidth = ieee80211_set_ap_chanwidth,
3652 .add_tx_ts = ieee80211_add_tx_ts,
3653 .del_tx_ts = ieee80211_del_tx_ts,
3654 .start_nan = ieee80211_start_nan,
3655 .stop_nan = ieee80211_stop_nan,
3656 .nan_change_conf = ieee80211_nan_change_conf,
3657 .add_nan_func = ieee80211_add_nan_func,
3658 .del_nan_func = ieee80211_del_nan_func,