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 sta = sta_info_get_bss(sdata, mac_addr);
362 * The ASSOC test makes sure the driver is ready to
363 * receive the key. When wpa_supplicant has roamed
364 * using FT, it attempts to set the key before
365 * association has completed, this rejects that attempt
366 * so it will set the key again after association.
368 * TODO: accept the key if we have a station entry and
369 * add it to the device after the station.
371 if (!sta || !test_sta_flag(sta, WLAN_STA_ASSOC)) {
372 ieee80211_key_free_unused(key);
378 switch (sdata->vif.type) {
379 case NL80211_IFTYPE_STATION:
380 if (sdata->u.mgd.mfp != IEEE80211_MFP_DISABLED)
381 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
383 case NL80211_IFTYPE_AP:
384 case NL80211_IFTYPE_AP_VLAN:
385 /* Keys without a station are used for TX only */
386 if (key->sta && test_sta_flag(key->sta, WLAN_STA_MFP))
387 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
389 case NL80211_IFTYPE_ADHOC:
392 case NL80211_IFTYPE_MESH_POINT:
393 #ifdef CONFIG_MAC80211_MESH
394 if (sdata->u.mesh.security != IEEE80211_MESH_SEC_NONE)
395 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
398 case NL80211_IFTYPE_WDS:
399 case NL80211_IFTYPE_MONITOR:
400 case NL80211_IFTYPE_P2P_DEVICE:
401 case NL80211_IFTYPE_NAN:
402 case NL80211_IFTYPE_UNSPECIFIED:
403 case NUM_NL80211_IFTYPES:
404 case NL80211_IFTYPE_P2P_CLIENT:
405 case NL80211_IFTYPE_P2P_GO:
406 case NL80211_IFTYPE_OCB:
407 /* shouldn't happen */
413 sta->cipher_scheme = cs;
415 err = ieee80211_key_link(key, sdata, sta);
418 mutex_unlock(&local->sta_mtx);
423 static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
424 u8 key_idx, bool pairwise, const u8 *mac_addr)
426 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
427 struct ieee80211_local *local = sdata->local;
428 struct sta_info *sta;
429 struct ieee80211_key *key = NULL;
432 mutex_lock(&local->sta_mtx);
433 mutex_lock(&local->key_mtx);
438 sta = sta_info_get_bss(sdata, mac_addr);
443 key = key_mtx_dereference(local, sta->ptk[key_idx]);
445 key = key_mtx_dereference(local, sta->gtk[key_idx]);
447 key = key_mtx_dereference(local, sdata->keys[key_idx]);
454 ieee80211_key_free(key, true);
458 mutex_unlock(&local->key_mtx);
459 mutex_unlock(&local->sta_mtx);
464 static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
465 u8 key_idx, bool pairwise, const u8 *mac_addr,
467 void (*callback)(void *cookie,
468 struct key_params *params))
470 struct ieee80211_sub_if_data *sdata;
471 struct sta_info *sta = NULL;
473 struct key_params params;
474 struct ieee80211_key *key = NULL;
479 struct ieee80211_key_seq kseq = {};
481 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
486 sta = sta_info_get_bss(sdata, mac_addr);
490 if (pairwise && key_idx < NUM_DEFAULT_KEYS)
491 key = rcu_dereference(sta->ptk[key_idx]);
492 else if (!pairwise &&
493 key_idx < NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS)
494 key = rcu_dereference(sta->gtk[key_idx]);
496 key = rcu_dereference(sdata->keys[key_idx]);
501 memset(¶ms, 0, sizeof(params));
503 params.cipher = key->conf.cipher;
505 switch (key->conf.cipher) {
506 case WLAN_CIPHER_SUITE_TKIP:
507 pn64 = atomic64_read(&key->conf.tx_pn);
508 iv32 = TKIP_PN_TO_IV32(pn64);
509 iv16 = TKIP_PN_TO_IV16(pn64);
511 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE &&
512 !(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
513 drv_get_key_seq(sdata->local, key, &kseq);
514 iv32 = kseq.tkip.iv32;
515 iv16 = kseq.tkip.iv16;
518 seq[0] = iv16 & 0xff;
519 seq[1] = (iv16 >> 8) & 0xff;
520 seq[2] = iv32 & 0xff;
521 seq[3] = (iv32 >> 8) & 0xff;
522 seq[4] = (iv32 >> 16) & 0xff;
523 seq[5] = (iv32 >> 24) & 0xff;
527 case WLAN_CIPHER_SUITE_CCMP:
528 case WLAN_CIPHER_SUITE_CCMP_256:
529 case WLAN_CIPHER_SUITE_AES_CMAC:
530 case WLAN_CIPHER_SUITE_BIP_CMAC_256:
531 BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
532 offsetof(typeof(kseq), aes_cmac));
533 case WLAN_CIPHER_SUITE_BIP_GMAC_128:
534 case WLAN_CIPHER_SUITE_BIP_GMAC_256:
535 BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
536 offsetof(typeof(kseq), aes_gmac));
537 case WLAN_CIPHER_SUITE_GCMP:
538 case WLAN_CIPHER_SUITE_GCMP_256:
539 BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
540 offsetof(typeof(kseq), gcmp));
542 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE &&
543 !(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
544 drv_get_key_seq(sdata->local, key, &kseq);
545 memcpy(seq, kseq.ccmp.pn, 6);
547 pn64 = atomic64_read(&key->conf.tx_pn);
559 if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
561 if (WARN_ON(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV))
563 drv_get_key_seq(sdata->local, key, &kseq);
564 params.seq = kseq.hw.seq;
565 params.seq_len = kseq.hw.seq_len;
569 params.key = key->conf.key;
570 params.key_len = key->conf.keylen;
572 callback(cookie, ¶ms);
580 static int ieee80211_config_default_key(struct wiphy *wiphy,
581 struct net_device *dev,
582 u8 key_idx, bool uni,
585 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
587 ieee80211_set_default_key(sdata, key_idx, uni, multi);
592 static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy,
593 struct net_device *dev,
596 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
598 ieee80211_set_default_mgmt_key(sdata, key_idx);
603 void sta_set_rate_info_tx(struct sta_info *sta,
604 const struct ieee80211_tx_rate *rate,
605 struct rate_info *rinfo)
608 if (rate->flags & IEEE80211_TX_RC_MCS) {
609 rinfo->flags |= RATE_INFO_FLAGS_MCS;
610 rinfo->mcs = rate->idx;
611 } else if (rate->flags & IEEE80211_TX_RC_VHT_MCS) {
612 rinfo->flags |= RATE_INFO_FLAGS_VHT_MCS;
613 rinfo->mcs = ieee80211_rate_get_vht_mcs(rate);
614 rinfo->nss = ieee80211_rate_get_vht_nss(rate);
616 struct ieee80211_supported_band *sband;
617 int shift = ieee80211_vif_get_shift(&sta->sdata->vif);
620 sband = sta->local->hw.wiphy->bands[
621 ieee80211_get_sdata_band(sta->sdata)];
622 brate = sband->bitrates[rate->idx].bitrate;
623 rinfo->legacy = DIV_ROUND_UP(brate, 1 << shift);
625 if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
626 rinfo->bw = RATE_INFO_BW_40;
627 else if (rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH)
628 rinfo->bw = RATE_INFO_BW_80;
629 else if (rate->flags & IEEE80211_TX_RC_160_MHZ_WIDTH)
630 rinfo->bw = RATE_INFO_BW_160;
632 rinfo->bw = RATE_INFO_BW_20;
633 if (rate->flags & IEEE80211_TX_RC_SHORT_GI)
634 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI;
637 static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev,
638 int idx, u8 *mac, struct station_info *sinfo)
640 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
641 struct ieee80211_local *local = sdata->local;
642 struct sta_info *sta;
645 mutex_lock(&local->sta_mtx);
647 sta = sta_info_get_by_idx(sdata, idx);
650 memcpy(mac, sta->sta.addr, ETH_ALEN);
651 sta_set_sinfo(sta, sinfo);
654 mutex_unlock(&local->sta_mtx);
659 static int ieee80211_dump_survey(struct wiphy *wiphy, struct net_device *dev,
660 int idx, struct survey_info *survey)
662 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
664 return drv_get_survey(local, idx, survey);
667 static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev,
668 const u8 *mac, struct station_info *sinfo)
670 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
671 struct ieee80211_local *local = sdata->local;
672 struct sta_info *sta;
675 mutex_lock(&local->sta_mtx);
677 sta = sta_info_get_bss(sdata, mac);
680 sta_set_sinfo(sta, sinfo);
683 mutex_unlock(&local->sta_mtx);
688 static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
689 struct cfg80211_chan_def *chandef)
691 struct ieee80211_local *local = wiphy_priv(wiphy);
692 struct ieee80211_sub_if_data *sdata;
695 if (cfg80211_chandef_identical(&local->monitor_chandef, chandef))
698 mutex_lock(&local->mtx);
699 mutex_lock(&local->iflist_mtx);
700 if (local->use_chanctx) {
701 sdata = rcu_dereference_protected(
702 local->monitor_sdata,
703 lockdep_is_held(&local->iflist_mtx));
705 ieee80211_vif_release_channel(sdata);
706 ret = ieee80211_vif_use_channel(sdata, chandef,
707 IEEE80211_CHANCTX_EXCLUSIVE);
709 } else if (local->open_count == local->monitors) {
710 local->_oper_chandef = *chandef;
711 ieee80211_hw_config(local, 0);
715 local->monitor_chandef = *chandef;
716 mutex_unlock(&local->iflist_mtx);
717 mutex_unlock(&local->mtx);
722 static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata,
723 const u8 *resp, size_t resp_len,
724 const struct ieee80211_csa_settings *csa)
726 struct probe_resp *new, *old;
728 if (!resp || !resp_len)
731 old = sdata_dereference(sdata->u.ap.probe_resp, sdata);
733 new = kzalloc(sizeof(struct probe_resp) + resp_len, GFP_KERNEL);
738 memcpy(new->data, resp, resp_len);
741 memcpy(new->csa_counter_offsets, csa->counter_offsets_presp,
742 csa->n_counter_offsets_presp *
743 sizeof(new->csa_counter_offsets[0]));
745 rcu_assign_pointer(sdata->u.ap.probe_resp, new);
747 kfree_rcu(old, rcu_head);
752 static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
753 struct cfg80211_beacon_data *params,
754 const struct ieee80211_csa_settings *csa)
756 struct beacon_data *new, *old;
757 int new_head_len, new_tail_len;
759 u32 changed = BSS_CHANGED_BEACON;
761 old = sdata_dereference(sdata->u.ap.beacon, sdata);
764 /* Need to have a beacon head if we don't have one yet */
765 if (!params->head && !old)
768 /* new or old head? */
770 new_head_len = params->head_len;
772 new_head_len = old->head_len;
774 /* new or old tail? */
775 if (params->tail || !old)
776 /* params->tail_len will be zero for !params->tail */
777 new_tail_len = params->tail_len;
779 new_tail_len = old->tail_len;
781 size = sizeof(*new) + new_head_len + new_tail_len;
783 new = kzalloc(size, GFP_KERNEL);
787 /* start filling the new info now */
790 * pointers go into the block we allocated,
791 * memory is | beacon_data | head | tail |
793 new->head = ((u8 *) new) + sizeof(*new);
794 new->tail = new->head + new_head_len;
795 new->head_len = new_head_len;
796 new->tail_len = new_tail_len;
799 new->csa_current_counter = csa->count;
800 memcpy(new->csa_counter_offsets, csa->counter_offsets_beacon,
801 csa->n_counter_offsets_beacon *
802 sizeof(new->csa_counter_offsets[0]));
807 memcpy(new->head, params->head, new_head_len);
809 memcpy(new->head, old->head, new_head_len);
811 /* copy in optional tail */
813 memcpy(new->tail, params->tail, new_tail_len);
816 memcpy(new->tail, old->tail, new_tail_len);
818 err = ieee80211_set_probe_resp(sdata, params->probe_resp,
819 params->probe_resp_len, csa);
823 changed |= BSS_CHANGED_AP_PROBE_RESP;
825 rcu_assign_pointer(sdata->u.ap.beacon, new);
828 kfree_rcu(old, rcu_head);
833 static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
834 struct cfg80211_ap_settings *params)
836 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
837 struct ieee80211_local *local = sdata->local;
838 struct beacon_data *old;
839 struct ieee80211_sub_if_data *vlan;
840 u32 changed = BSS_CHANGED_BEACON_INT |
841 BSS_CHANGED_BEACON_ENABLED |
848 old = sdata_dereference(sdata->u.ap.beacon, sdata);
852 switch (params->smps_mode) {
853 case NL80211_SMPS_OFF:
854 sdata->smps_mode = IEEE80211_SMPS_OFF;
856 case NL80211_SMPS_STATIC:
857 sdata->smps_mode = IEEE80211_SMPS_STATIC;
859 case NL80211_SMPS_DYNAMIC:
860 sdata->smps_mode = IEEE80211_SMPS_DYNAMIC;
865 sdata->needed_rx_chains = sdata->local->rx_chains;
867 mutex_lock(&local->mtx);
868 err = ieee80211_vif_use_channel(sdata, ¶ms->chandef,
869 IEEE80211_CHANCTX_SHARED);
871 ieee80211_vif_copy_chanctx_to_vlans(sdata, false);
872 mutex_unlock(&local->mtx);
877 * Apply control port protocol, this allows us to
878 * not encrypt dynamic WEP control frames.
880 sdata->control_port_protocol = params->crypto.control_port_ethertype;
881 sdata->control_port_no_encrypt = params->crypto.control_port_no_encrypt;
882 sdata->encrypt_headroom = ieee80211_cs_headroom(sdata->local,
886 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) {
887 vlan->control_port_protocol =
888 params->crypto.control_port_ethertype;
889 vlan->control_port_no_encrypt =
890 params->crypto.control_port_no_encrypt;
891 vlan->encrypt_headroom =
892 ieee80211_cs_headroom(sdata->local,
897 sdata->vif.bss_conf.beacon_int = params->beacon_interval;
898 sdata->vif.bss_conf.dtim_period = params->dtim_period;
899 sdata->vif.bss_conf.enable_beacon = true;
900 sdata->vif.bss_conf.allow_p2p_go_ps = sdata->vif.p2p;
902 sdata->vif.bss_conf.ssid_len = params->ssid_len;
903 if (params->ssid_len)
904 memcpy(sdata->vif.bss_conf.ssid, params->ssid,
906 sdata->vif.bss_conf.hidden_ssid =
907 (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE);
909 memset(&sdata->vif.bss_conf.p2p_noa_attr, 0,
910 sizeof(sdata->vif.bss_conf.p2p_noa_attr));
911 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow =
912 params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
913 if (params->p2p_opp_ps)
914 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |=
915 IEEE80211_P2P_OPPPS_ENABLE_BIT;
917 err = ieee80211_assign_beacon(sdata, ¶ms->beacon, NULL);
919 ieee80211_vif_release_channel(sdata);
924 err = drv_start_ap(sdata->local, sdata);
926 old = sdata_dereference(sdata->u.ap.beacon, sdata);
929 kfree_rcu(old, rcu_head);
930 RCU_INIT_POINTER(sdata->u.ap.beacon, NULL);
931 ieee80211_vif_release_channel(sdata);
935 ieee80211_recalc_dtim(local, sdata);
936 ieee80211_bss_info_change_notify(sdata, changed);
938 netif_carrier_on(dev);
939 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
940 netif_carrier_on(vlan->dev);
945 static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev,
946 struct cfg80211_beacon_data *params)
948 struct ieee80211_sub_if_data *sdata;
949 struct beacon_data *old;
952 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
953 sdata_assert_lock(sdata);
955 /* don't allow changing the beacon while CSA is in place - offset
956 * of channel switch counter may change
958 if (sdata->vif.csa_active)
961 old = sdata_dereference(sdata->u.ap.beacon, sdata);
965 err = ieee80211_assign_beacon(sdata, params, NULL);
968 ieee80211_bss_info_change_notify(sdata, err);
972 static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev)
974 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
975 struct ieee80211_sub_if_data *vlan;
976 struct ieee80211_local *local = sdata->local;
977 struct beacon_data *old_beacon;
978 struct probe_resp *old_probe_resp;
979 struct cfg80211_chan_def chandef;
981 sdata_assert_lock(sdata);
983 old_beacon = sdata_dereference(sdata->u.ap.beacon, sdata);
986 old_probe_resp = sdata_dereference(sdata->u.ap.probe_resp, sdata);
988 /* abort any running channel switch */
989 mutex_lock(&local->mtx);
990 sdata->vif.csa_active = false;
991 if (sdata->csa_block_tx) {
992 ieee80211_wake_vif_queues(local, sdata,
993 IEEE80211_QUEUE_STOP_REASON_CSA);
994 sdata->csa_block_tx = false;
997 mutex_unlock(&local->mtx);
999 kfree(sdata->u.ap.next_beacon);
1000 sdata->u.ap.next_beacon = NULL;
1002 /* turn off carrier for this interface and dependent VLANs */
1003 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
1004 netif_carrier_off(vlan->dev);
1005 netif_carrier_off(dev);
1007 /* remove beacon and probe response */
1008 RCU_INIT_POINTER(sdata->u.ap.beacon, NULL);
1009 RCU_INIT_POINTER(sdata->u.ap.probe_resp, NULL);
1010 kfree_rcu(old_beacon, rcu_head);
1012 kfree_rcu(old_probe_resp, rcu_head);
1013 sdata->u.ap.driver_smps_mode = IEEE80211_SMPS_OFF;
1015 __sta_info_flush(sdata, true);
1016 ieee80211_free_keys(sdata, true);
1018 sdata->vif.bss_conf.enable_beacon = false;
1019 sdata->vif.bss_conf.ssid_len = 0;
1020 clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state);
1021 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
1023 if (sdata->wdev.cac_started) {
1024 chandef = sdata->vif.bss_conf.chandef;
1025 cancel_delayed_work_sync(&sdata->dfs_cac_timer_work);
1026 cfg80211_cac_event(sdata->dev, &chandef,
1027 NL80211_RADAR_CAC_ABORTED,
1031 drv_stop_ap(sdata->local, sdata);
1033 /* free all potentially still buffered bcast frames */
1034 local->total_ps_buffered -= skb_queue_len(&sdata->u.ap.ps.bc_buf);
1035 ieee80211_purge_tx_queue(&local->hw, &sdata->u.ap.ps.bc_buf);
1037 mutex_lock(&local->mtx);
1038 ieee80211_vif_copy_chanctx_to_vlans(sdata, true);
1039 ieee80211_vif_release_channel(sdata);
1040 mutex_unlock(&local->mtx);
1045 /* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */
1046 struct iapp_layer2_update {
1047 u8 da[ETH_ALEN]; /* broadcast */
1048 u8 sa[ETH_ALEN]; /* STA addr */
1056 static void ieee80211_send_layer2_update(struct sta_info *sta)
1058 struct iapp_layer2_update *msg;
1059 struct sk_buff *skb;
1061 /* Send Level 2 Update Frame to update forwarding tables in layer 2
1064 skb = dev_alloc_skb(sizeof(*msg));
1067 msg = (struct iapp_layer2_update *)skb_put(skb, sizeof(*msg));
1069 /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID)
1070 * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */
1072 eth_broadcast_addr(msg->da);
1073 memcpy(msg->sa, sta->sta.addr, ETH_ALEN);
1074 msg->len = htons(6);
1076 msg->ssap = 0x01; /* NULL LSAP, CR Bit: Response */
1077 msg->control = 0xaf; /* XID response lsb.1111F101.
1078 * F=0 (no poll command; unsolicited frame) */
1079 msg->xid_info[0] = 0x81; /* XID format identifier */
1080 msg->xid_info[1] = 1; /* LLC types/classes: Type 1 LLC */
1081 msg->xid_info[2] = 0; /* XID sender's receive window size (RW) */
1083 skb->dev = sta->sdata->dev;
1084 skb->protocol = eth_type_trans(skb, sta->sdata->dev);
1085 memset(skb->cb, 0, sizeof(skb->cb));
1089 static int sta_apply_auth_flags(struct ieee80211_local *local,
1090 struct sta_info *sta,
1095 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
1096 set & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
1097 !test_sta_flag(sta, WLAN_STA_AUTH)) {
1098 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
1103 if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
1104 set & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
1105 !test_sta_flag(sta, WLAN_STA_ASSOC)) {
1107 * When peer becomes associated, init rate control as
1108 * well. Some drivers require rate control initialized
1109 * before drv_sta_state() is called.
1111 if (!test_sta_flag(sta, WLAN_STA_RATE_CONTROL))
1112 rate_control_rate_init(sta);
1114 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
1119 if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
1120 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED))
1121 ret = sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED);
1122 else if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
1123 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
1130 if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
1131 !(set & BIT(NL80211_STA_FLAG_ASSOCIATED)) &&
1132 test_sta_flag(sta, WLAN_STA_ASSOC)) {
1133 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
1138 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
1139 !(set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) &&
1140 test_sta_flag(sta, WLAN_STA_AUTH)) {
1141 ret = sta_info_move_state(sta, IEEE80211_STA_NONE);
1149 static void sta_apply_mesh_params(struct ieee80211_local *local,
1150 struct sta_info *sta,
1151 struct station_parameters *params)
1153 #ifdef CONFIG_MAC80211_MESH
1154 struct ieee80211_sub_if_data *sdata = sta->sdata;
1157 if (params->sta_modify_mask & STATION_PARAM_APPLY_PLINK_STATE) {
1158 switch (params->plink_state) {
1159 case NL80211_PLINK_ESTAB:
1160 if (sta->mesh->plink_state != NL80211_PLINK_ESTAB)
1161 changed = mesh_plink_inc_estab_count(sdata);
1162 sta->mesh->plink_state = params->plink_state;
1163 sta->mesh->aid = params->peer_aid;
1165 ieee80211_mps_sta_status_update(sta);
1166 changed |= ieee80211_mps_set_sta_local_pm(sta,
1167 sdata->u.mesh.mshcfg.power_mode);
1169 case NL80211_PLINK_LISTEN:
1170 case NL80211_PLINK_BLOCKED:
1171 case NL80211_PLINK_OPN_SNT:
1172 case NL80211_PLINK_OPN_RCVD:
1173 case NL80211_PLINK_CNF_RCVD:
1174 case NL80211_PLINK_HOLDING:
1175 if (sta->mesh->plink_state == NL80211_PLINK_ESTAB)
1176 changed = mesh_plink_dec_estab_count(sdata);
1177 sta->mesh->plink_state = params->plink_state;
1179 ieee80211_mps_sta_status_update(sta);
1180 changed |= ieee80211_mps_set_sta_local_pm(sta,
1181 NL80211_MESH_POWER_UNKNOWN);
1189 switch (params->plink_action) {
1190 case NL80211_PLINK_ACTION_NO_ACTION:
1193 case NL80211_PLINK_ACTION_OPEN:
1194 changed |= mesh_plink_open(sta);
1196 case NL80211_PLINK_ACTION_BLOCK:
1197 changed |= mesh_plink_block(sta);
1201 if (params->local_pm)
1202 changed |= ieee80211_mps_set_sta_local_pm(sta,
1205 ieee80211_mbss_info_change_notify(sdata, changed);
1209 static int sta_apply_parameters(struct ieee80211_local *local,
1210 struct sta_info *sta,
1211 struct station_parameters *params)
1214 struct ieee80211_supported_band *sband;
1215 struct ieee80211_sub_if_data *sdata = sta->sdata;
1216 enum nl80211_band band = ieee80211_get_sdata_band(sdata);
1219 sband = local->hw.wiphy->bands[band];
1221 mask = params->sta_flags_mask;
1222 set = params->sta_flags_set;
1224 if (ieee80211_vif_is_mesh(&sdata->vif)) {
1226 * In mesh mode, ASSOCIATED isn't part of the nl80211
1227 * API but must follow AUTHENTICATED for driver state.
1229 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED))
1230 mask |= BIT(NL80211_STA_FLAG_ASSOCIATED);
1231 if (set & BIT(NL80211_STA_FLAG_AUTHENTICATED))
1232 set |= BIT(NL80211_STA_FLAG_ASSOCIATED);
1233 } else if (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
1235 * TDLS -- everything follows authorized, but
1236 * only becoming authorized is possible, not
1239 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
1240 set |= BIT(NL80211_STA_FLAG_AUTHENTICATED) |
1241 BIT(NL80211_STA_FLAG_ASSOCIATED);
1242 mask |= BIT(NL80211_STA_FLAG_AUTHENTICATED) |
1243 BIT(NL80211_STA_FLAG_ASSOCIATED);
1247 if (mask & BIT(NL80211_STA_FLAG_WME) &&
1248 local->hw.queues >= IEEE80211_NUM_ACS)
1249 sta->sta.wme = set & BIT(NL80211_STA_FLAG_WME);
1251 /* auth flags will be set later for TDLS,
1252 * and for unassociated stations that move to assocaited */
1253 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1254 !((mask & BIT(NL80211_STA_FLAG_ASSOCIATED)) &&
1255 (set & BIT(NL80211_STA_FLAG_ASSOCIATED)))) {
1256 ret = sta_apply_auth_flags(local, sta, mask, set);
1261 if (mask & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) {
1262 if (set & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE))
1263 set_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
1265 clear_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
1268 if (mask & BIT(NL80211_STA_FLAG_MFP)) {
1269 sta->sta.mfp = !!(set & BIT(NL80211_STA_FLAG_MFP));
1270 if (set & BIT(NL80211_STA_FLAG_MFP))
1271 set_sta_flag(sta, WLAN_STA_MFP);
1273 clear_sta_flag(sta, WLAN_STA_MFP);
1276 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
1277 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER))
1278 set_sta_flag(sta, WLAN_STA_TDLS_PEER);
1280 clear_sta_flag(sta, WLAN_STA_TDLS_PEER);
1283 /* mark TDLS channel switch support, if the AP allows it */
1284 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1285 !sdata->u.mgd.tdls_chan_switch_prohibited &&
1286 params->ext_capab_len >= 4 &&
1287 params->ext_capab[3] & WLAN_EXT_CAPA4_TDLS_CHAN_SWITCH)
1288 set_sta_flag(sta, WLAN_STA_TDLS_CHAN_SWITCH);
1290 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1291 !sdata->u.mgd.tdls_wider_bw_prohibited &&
1292 ieee80211_hw_check(&local->hw, TDLS_WIDER_BW) &&
1293 params->ext_capab_len >= 8 &&
1294 params->ext_capab[7] & WLAN_EXT_CAPA8_TDLS_WIDE_BW_ENABLED)
1295 set_sta_flag(sta, WLAN_STA_TDLS_WIDER_BW);
1297 if (params->sta_modify_mask & STATION_PARAM_APPLY_UAPSD) {
1298 sta->sta.uapsd_queues = params->uapsd_queues;
1299 sta->sta.max_sp = params->max_sp;
1302 /* The sender might not have sent the last bit, consider it to be 0 */
1303 if (params->ext_capab_len >= 8) {
1304 u8 val = (params->ext_capab[7] &
1305 WLAN_EXT_CAPA8_MAX_MSDU_IN_AMSDU_LSB) >> 7;
1307 /* we did get all the bits, take the MSB as well */
1308 if (params->ext_capab_len >= 9) {
1309 u8 val_msb = params->ext_capab[8] &
1310 WLAN_EXT_CAPA9_MAX_MSDU_IN_AMSDU_MSB;
1317 sta->sta.max_amsdu_subframes = 32;
1320 sta->sta.max_amsdu_subframes = 16;
1323 sta->sta.max_amsdu_subframes = 8;
1326 sta->sta.max_amsdu_subframes = 0;
1331 * cfg80211 validates this (1-2007) and allows setting the AID
1332 * only when creating a new station entry
1335 sta->sta.aid = params->aid;
1338 * Some of the following updates would be racy if called on an
1339 * existing station, via ieee80211_change_station(). However,
1340 * all such changes are rejected by cfg80211 except for updates
1341 * changing the supported rates on an existing but not yet used
1345 if (params->listen_interval >= 0)
1346 sta->listen_interval = params->listen_interval;
1348 if (params->supported_rates) {
1349 ieee80211_parse_bitrates(&sdata->vif.bss_conf.chandef,
1350 sband, params->supported_rates,
1351 params->supported_rates_len,
1352 &sta->sta.supp_rates[band]);
1355 if (params->ht_capa)
1356 ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
1357 params->ht_capa, sta);
1359 /* VHT can override some HT caps such as the A-MSDU max length */
1360 if (params->vht_capa)
1361 ieee80211_vht_cap_ie_to_sta_vht_cap(sdata, sband,
1362 params->vht_capa, sta);
1364 if (params->opmode_notif_used) {
1365 /* returned value is only needed for rc update, but the
1366 * rc isn't initialized here yet, so ignore it
1368 __ieee80211_vht_handle_opmode(sdata, sta,
1369 params->opmode_notif, band);
1372 if (params->support_p2p_ps >= 0)
1373 sta->sta.support_p2p_ps = params->support_p2p_ps;
1375 if (ieee80211_vif_is_mesh(&sdata->vif))
1376 sta_apply_mesh_params(local, sta, params);
1378 /* set the STA state after all sta info from usermode has been set */
1379 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) ||
1380 set & BIT(NL80211_STA_FLAG_ASSOCIATED)) {
1381 ret = sta_apply_auth_flags(local, sta, mask, set);
1389 static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
1391 struct station_parameters *params)
1393 struct ieee80211_local *local = wiphy_priv(wiphy);
1394 struct sta_info *sta;
1395 struct ieee80211_sub_if_data *sdata;
1400 sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
1402 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
1403 sdata->vif.type != NL80211_IFTYPE_AP)
1406 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1408 if (ether_addr_equal(mac, sdata->vif.addr))
1411 if (is_multicast_ether_addr(mac))
1414 sta = sta_info_alloc(sdata, mac, GFP_KERNEL);
1418 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))
1419 sta->sta.tdls = true;
1421 err = sta_apply_parameters(local, sta, params);
1423 sta_info_free(local, sta);
1428 * for TDLS and for unassociated station, rate control should be
1429 * initialized only when rates are known and station is marked
1430 * authorized/associated
1432 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1433 test_sta_flag(sta, WLAN_STA_ASSOC))
1434 rate_control_rate_init(sta);
1436 layer2_update = sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
1437 sdata->vif.type == NL80211_IFTYPE_AP;
1439 err = sta_info_insert_rcu(sta);
1446 ieee80211_send_layer2_update(sta);
1453 static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev,
1454 struct station_del_parameters *params)
1456 struct ieee80211_sub_if_data *sdata;
1458 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1461 return sta_info_destroy_addr_bss(sdata, params->mac);
1463 sta_info_flush(sdata);
1467 static int ieee80211_change_station(struct wiphy *wiphy,
1468 struct net_device *dev, const u8 *mac,
1469 struct station_parameters *params)
1471 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1472 struct ieee80211_local *local = wiphy_priv(wiphy);
1473 struct sta_info *sta;
1474 struct ieee80211_sub_if_data *vlansdata;
1475 enum cfg80211_station_type statype;
1478 mutex_lock(&local->sta_mtx);
1480 sta = sta_info_get_bss(sdata, mac);
1486 switch (sdata->vif.type) {
1487 case NL80211_IFTYPE_MESH_POINT:
1488 if (sdata->u.mesh.user_mpm)
1489 statype = CFG80211_STA_MESH_PEER_USER;
1491 statype = CFG80211_STA_MESH_PEER_KERNEL;
1493 case NL80211_IFTYPE_ADHOC:
1494 statype = CFG80211_STA_IBSS;
1496 case NL80211_IFTYPE_STATION:
1497 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
1498 statype = CFG80211_STA_AP_STA;
1501 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
1502 statype = CFG80211_STA_TDLS_PEER_ACTIVE;
1504 statype = CFG80211_STA_TDLS_PEER_SETUP;
1506 case NL80211_IFTYPE_AP:
1507 case NL80211_IFTYPE_AP_VLAN:
1508 if (test_sta_flag(sta, WLAN_STA_ASSOC))
1509 statype = CFG80211_STA_AP_CLIENT;
1511 statype = CFG80211_STA_AP_CLIENT_UNASSOC;
1518 err = cfg80211_check_station_change(wiphy, params, statype);
1522 if (params->vlan && params->vlan != sta->sdata->dev) {
1523 bool prev_4addr = false;
1524 bool new_4addr = false;
1526 vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
1528 if (params->vlan->ieee80211_ptr->use_4addr) {
1529 if (vlansdata->u.vlan.sta) {
1534 rcu_assign_pointer(vlansdata->u.vlan.sta, sta);
1536 __ieee80211_check_fast_rx_iface(vlansdata);
1539 if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
1540 sta->sdata->u.vlan.sta) {
1541 RCU_INIT_POINTER(sta->sdata->u.vlan.sta, NULL);
1545 sta->sdata = vlansdata;
1546 ieee80211_check_fast_xmit(sta);
1548 if (sta->sta_state == IEEE80211_STA_AUTHORIZED &&
1549 prev_4addr != new_4addr) {
1551 atomic_dec(&sta->sdata->bss->num_mcast_sta);
1553 atomic_inc(&sta->sdata->bss->num_mcast_sta);
1556 ieee80211_send_layer2_update(sta);
1559 err = sta_apply_parameters(local, sta, params);
1563 mutex_unlock(&local->sta_mtx);
1565 if ((sdata->vif.type == NL80211_IFTYPE_AP ||
1566 sdata->vif.type == NL80211_IFTYPE_AP_VLAN) &&
1567 sta->known_smps_mode != sta->sdata->bss->req_smps &&
1568 test_sta_flag(sta, WLAN_STA_AUTHORIZED) &&
1569 sta_info_tx_streams(sta) != 1) {
1571 "%pM just authorized and MIMO capable - update SMPS\n",
1573 ieee80211_send_smps_action(sta->sdata,
1574 sta->sdata->bss->req_smps,
1576 sta->sdata->vif.bss_conf.bssid);
1579 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
1580 params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
1581 ieee80211_recalc_ps(local);
1582 ieee80211_recalc_ps_vif(sdata);
1587 mutex_unlock(&local->sta_mtx);
1591 #ifdef CONFIG_MAC80211_MESH
1592 static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev,
1593 const u8 *dst, const u8 *next_hop)
1595 struct ieee80211_sub_if_data *sdata;
1596 struct mesh_path *mpath;
1597 struct sta_info *sta;
1599 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1602 sta = sta_info_get(sdata, next_hop);
1608 mpath = mesh_path_add(sdata, dst);
1609 if (IS_ERR(mpath)) {
1611 return PTR_ERR(mpath);
1614 mesh_path_fix_nexthop(mpath, sta);
1620 static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev,
1623 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1626 return mesh_path_del(sdata, dst);
1628 mesh_path_flush_by_iface(sdata);
1632 static int ieee80211_change_mpath(struct wiphy *wiphy, struct net_device *dev,
1633 const u8 *dst, const u8 *next_hop)
1635 struct ieee80211_sub_if_data *sdata;
1636 struct mesh_path *mpath;
1637 struct sta_info *sta;
1639 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1643 sta = sta_info_get(sdata, next_hop);
1649 mpath = mesh_path_lookup(sdata, dst);
1655 mesh_path_fix_nexthop(mpath, sta);
1661 static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop,
1662 struct mpath_info *pinfo)
1664 struct sta_info *next_hop_sta = rcu_dereference(mpath->next_hop);
1667 memcpy(next_hop, next_hop_sta->sta.addr, ETH_ALEN);
1669 eth_zero_addr(next_hop);
1671 memset(pinfo, 0, sizeof(*pinfo));
1673 pinfo->generation = mpath->sdata->u.mesh.mesh_paths_generation;
1675 pinfo->filled = MPATH_INFO_FRAME_QLEN |
1678 MPATH_INFO_EXPTIME |
1679 MPATH_INFO_DISCOVERY_TIMEOUT |
1680 MPATH_INFO_DISCOVERY_RETRIES |
1683 pinfo->frame_qlen = mpath->frame_queue.qlen;
1684 pinfo->sn = mpath->sn;
1685 pinfo->metric = mpath->metric;
1686 if (time_before(jiffies, mpath->exp_time))
1687 pinfo->exptime = jiffies_to_msecs(mpath->exp_time - jiffies);
1688 pinfo->discovery_timeout =
1689 jiffies_to_msecs(mpath->discovery_timeout);
1690 pinfo->discovery_retries = mpath->discovery_retries;
1691 if (mpath->flags & MESH_PATH_ACTIVE)
1692 pinfo->flags |= NL80211_MPATH_FLAG_ACTIVE;
1693 if (mpath->flags & MESH_PATH_RESOLVING)
1694 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING;
1695 if (mpath->flags & MESH_PATH_SN_VALID)
1696 pinfo->flags |= NL80211_MPATH_FLAG_SN_VALID;
1697 if (mpath->flags & MESH_PATH_FIXED)
1698 pinfo->flags |= NL80211_MPATH_FLAG_FIXED;
1699 if (mpath->flags & MESH_PATH_RESOLVED)
1700 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVED;
1703 static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev,
1704 u8 *dst, u8 *next_hop, struct mpath_info *pinfo)
1707 struct ieee80211_sub_if_data *sdata;
1708 struct mesh_path *mpath;
1710 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1713 mpath = mesh_path_lookup(sdata, dst);
1718 memcpy(dst, mpath->dst, ETH_ALEN);
1719 mpath_set_pinfo(mpath, next_hop, pinfo);
1724 static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev,
1725 int idx, u8 *dst, u8 *next_hop,
1726 struct mpath_info *pinfo)
1728 struct ieee80211_sub_if_data *sdata;
1729 struct mesh_path *mpath;
1731 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1734 mpath = mesh_path_lookup_by_idx(sdata, idx);
1739 memcpy(dst, mpath->dst, ETH_ALEN);
1740 mpath_set_pinfo(mpath, next_hop, pinfo);
1745 static void mpp_set_pinfo(struct mesh_path *mpath, u8 *mpp,
1746 struct mpath_info *pinfo)
1748 memset(pinfo, 0, sizeof(*pinfo));
1749 memcpy(mpp, mpath->mpp, ETH_ALEN);
1751 pinfo->generation = mpath->sdata->u.mesh.mpp_paths_generation;
1754 static int ieee80211_get_mpp(struct wiphy *wiphy, struct net_device *dev,
1755 u8 *dst, u8 *mpp, struct mpath_info *pinfo)
1758 struct ieee80211_sub_if_data *sdata;
1759 struct mesh_path *mpath;
1761 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1764 mpath = mpp_path_lookup(sdata, dst);
1769 memcpy(dst, mpath->dst, ETH_ALEN);
1770 mpp_set_pinfo(mpath, mpp, pinfo);
1775 static int ieee80211_dump_mpp(struct wiphy *wiphy, struct net_device *dev,
1776 int idx, u8 *dst, u8 *mpp,
1777 struct mpath_info *pinfo)
1779 struct ieee80211_sub_if_data *sdata;
1780 struct mesh_path *mpath;
1782 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1785 mpath = mpp_path_lookup_by_idx(sdata, idx);
1790 memcpy(dst, mpath->dst, ETH_ALEN);
1791 mpp_set_pinfo(mpath, mpp, pinfo);
1796 static int ieee80211_get_mesh_config(struct wiphy *wiphy,
1797 struct net_device *dev,
1798 struct mesh_config *conf)
1800 struct ieee80211_sub_if_data *sdata;
1801 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1803 memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config));
1807 static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask)
1809 return (mask >> (parm-1)) & 0x1;
1812 static int copy_mesh_setup(struct ieee80211_if_mesh *ifmsh,
1813 const struct mesh_setup *setup)
1817 struct ieee80211_sub_if_data *sdata = container_of(ifmsh,
1818 struct ieee80211_sub_if_data, u.mesh);
1820 /* allocate information elements */
1824 if (setup->ie_len) {
1825 new_ie = kmemdup(setup->ie, setup->ie_len,
1830 ifmsh->ie_len = setup->ie_len;
1834 /* now copy the rest of the setup parameters */
1835 ifmsh->mesh_id_len = setup->mesh_id_len;
1836 memcpy(ifmsh->mesh_id, setup->mesh_id, ifmsh->mesh_id_len);
1837 ifmsh->mesh_sp_id = setup->sync_method;
1838 ifmsh->mesh_pp_id = setup->path_sel_proto;
1839 ifmsh->mesh_pm_id = setup->path_metric;
1840 ifmsh->user_mpm = setup->user_mpm;
1841 ifmsh->mesh_auth_id = setup->auth_id;
1842 ifmsh->security = IEEE80211_MESH_SEC_NONE;
1843 if (setup->is_authenticated)
1844 ifmsh->security |= IEEE80211_MESH_SEC_AUTHED;
1845 if (setup->is_secure)
1846 ifmsh->security |= IEEE80211_MESH_SEC_SECURED;
1848 /* mcast rate setting in Mesh Node */
1849 memcpy(sdata->vif.bss_conf.mcast_rate, setup->mcast_rate,
1850 sizeof(setup->mcast_rate));
1851 sdata->vif.bss_conf.basic_rates = setup->basic_rates;
1853 sdata->vif.bss_conf.beacon_int = setup->beacon_interval;
1854 sdata->vif.bss_conf.dtim_period = setup->dtim_period;
1859 static int ieee80211_update_mesh_config(struct wiphy *wiphy,
1860 struct net_device *dev, u32 mask,
1861 const struct mesh_config *nconf)
1863 struct mesh_config *conf;
1864 struct ieee80211_sub_if_data *sdata;
1865 struct ieee80211_if_mesh *ifmsh;
1867 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1868 ifmsh = &sdata->u.mesh;
1870 /* Set the config options which we are interested in setting */
1871 conf = &(sdata->u.mesh.mshcfg);
1872 if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask))
1873 conf->dot11MeshRetryTimeout = nconf->dot11MeshRetryTimeout;
1874 if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT, mask))
1875 conf->dot11MeshConfirmTimeout = nconf->dot11MeshConfirmTimeout;
1876 if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT, mask))
1877 conf->dot11MeshHoldingTimeout = nconf->dot11MeshHoldingTimeout;
1878 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS, mask))
1879 conf->dot11MeshMaxPeerLinks = nconf->dot11MeshMaxPeerLinks;
1880 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES, mask))
1881 conf->dot11MeshMaxRetries = nconf->dot11MeshMaxRetries;
1882 if (_chg_mesh_attr(NL80211_MESHCONF_TTL, mask))
1883 conf->dot11MeshTTL = nconf->dot11MeshTTL;
1884 if (_chg_mesh_attr(NL80211_MESHCONF_ELEMENT_TTL, mask))
1885 conf->element_ttl = nconf->element_ttl;
1886 if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask)) {
1887 if (ifmsh->user_mpm)
1889 conf->auto_open_plinks = nconf->auto_open_plinks;
1891 if (_chg_mesh_attr(NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR, mask))
1892 conf->dot11MeshNbrOffsetMaxNeighbor =
1893 nconf->dot11MeshNbrOffsetMaxNeighbor;
1894 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, mask))
1895 conf->dot11MeshHWMPmaxPREQretries =
1896 nconf->dot11MeshHWMPmaxPREQretries;
1897 if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME, mask))
1898 conf->path_refresh_time = nconf->path_refresh_time;
1899 if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, mask))
1900 conf->min_discovery_timeout = nconf->min_discovery_timeout;
1901 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, mask))
1902 conf->dot11MeshHWMPactivePathTimeout =
1903 nconf->dot11MeshHWMPactivePathTimeout;
1904 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, mask))
1905 conf->dot11MeshHWMPpreqMinInterval =
1906 nconf->dot11MeshHWMPpreqMinInterval;
1907 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL, mask))
1908 conf->dot11MeshHWMPperrMinInterval =
1909 nconf->dot11MeshHWMPperrMinInterval;
1910 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
1912 conf->dot11MeshHWMPnetDiameterTraversalTime =
1913 nconf->dot11MeshHWMPnetDiameterTraversalTime;
1914 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOTMODE, mask)) {
1915 conf->dot11MeshHWMPRootMode = nconf->dot11MeshHWMPRootMode;
1916 ieee80211_mesh_root_setup(ifmsh);
1918 if (_chg_mesh_attr(NL80211_MESHCONF_GATE_ANNOUNCEMENTS, mask)) {
1919 /* our current gate announcement implementation rides on root
1920 * announcements, so require this ifmsh to also be a root node
1922 if (nconf->dot11MeshGateAnnouncementProtocol &&
1923 !(conf->dot11MeshHWMPRootMode > IEEE80211_ROOTMODE_ROOT)) {
1924 conf->dot11MeshHWMPRootMode = IEEE80211_PROACTIVE_RANN;
1925 ieee80211_mesh_root_setup(ifmsh);
1927 conf->dot11MeshGateAnnouncementProtocol =
1928 nconf->dot11MeshGateAnnouncementProtocol;
1930 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_RANN_INTERVAL, mask))
1931 conf->dot11MeshHWMPRannInterval =
1932 nconf->dot11MeshHWMPRannInterval;
1933 if (_chg_mesh_attr(NL80211_MESHCONF_FORWARDING, mask))
1934 conf->dot11MeshForwarding = nconf->dot11MeshForwarding;
1935 if (_chg_mesh_attr(NL80211_MESHCONF_RSSI_THRESHOLD, mask)) {
1936 /* our RSSI threshold implementation is supported only for
1937 * devices that report signal in dBm.
1939 if (!ieee80211_hw_check(&sdata->local->hw, SIGNAL_DBM))
1941 conf->rssi_threshold = nconf->rssi_threshold;
1943 if (_chg_mesh_attr(NL80211_MESHCONF_HT_OPMODE, mask)) {
1944 conf->ht_opmode = nconf->ht_opmode;
1945 sdata->vif.bss_conf.ht_operation_mode = nconf->ht_opmode;
1946 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_HT);
1948 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT, mask))
1949 conf->dot11MeshHWMPactivePathToRootTimeout =
1950 nconf->dot11MeshHWMPactivePathToRootTimeout;
1951 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOT_INTERVAL, mask))
1952 conf->dot11MeshHWMProotInterval =
1953 nconf->dot11MeshHWMProotInterval;
1954 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL, mask))
1955 conf->dot11MeshHWMPconfirmationInterval =
1956 nconf->dot11MeshHWMPconfirmationInterval;
1957 if (_chg_mesh_attr(NL80211_MESHCONF_POWER_MODE, mask)) {
1958 conf->power_mode = nconf->power_mode;
1959 ieee80211_mps_local_status_update(sdata);
1961 if (_chg_mesh_attr(NL80211_MESHCONF_AWAKE_WINDOW, mask))
1962 conf->dot11MeshAwakeWindowDuration =
1963 nconf->dot11MeshAwakeWindowDuration;
1964 if (_chg_mesh_attr(NL80211_MESHCONF_PLINK_TIMEOUT, mask))
1965 conf->plink_timeout = nconf->plink_timeout;
1966 ieee80211_mbss_info_change_notify(sdata, BSS_CHANGED_BEACON);
1970 static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev,
1971 const struct mesh_config *conf,
1972 const struct mesh_setup *setup)
1974 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1975 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
1978 memcpy(&ifmsh->mshcfg, conf, sizeof(struct mesh_config));
1979 err = copy_mesh_setup(ifmsh, setup);
1983 /* can mesh use other SMPS modes? */
1984 sdata->smps_mode = IEEE80211_SMPS_OFF;
1985 sdata->needed_rx_chains = sdata->local->rx_chains;
1987 mutex_lock(&sdata->local->mtx);
1988 err = ieee80211_vif_use_channel(sdata, &setup->chandef,
1989 IEEE80211_CHANCTX_SHARED);
1990 mutex_unlock(&sdata->local->mtx);
1994 return ieee80211_start_mesh(sdata);
1997 static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev)
1999 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2001 ieee80211_stop_mesh(sdata);
2002 mutex_lock(&sdata->local->mtx);
2003 ieee80211_vif_release_channel(sdata);
2004 mutex_unlock(&sdata->local->mtx);
2010 static int ieee80211_change_bss(struct wiphy *wiphy,
2011 struct net_device *dev,
2012 struct bss_parameters *params)
2014 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2015 enum nl80211_band band;
2018 if (!sdata_dereference(sdata->u.ap.beacon, sdata))
2021 band = ieee80211_get_sdata_band(sdata);
2023 if (params->use_cts_prot >= 0) {
2024 sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot;
2025 changed |= BSS_CHANGED_ERP_CTS_PROT;
2027 if (params->use_short_preamble >= 0) {
2028 sdata->vif.bss_conf.use_short_preamble =
2029 params->use_short_preamble;
2030 changed |= BSS_CHANGED_ERP_PREAMBLE;
2033 if (!sdata->vif.bss_conf.use_short_slot &&
2034 band == NL80211_BAND_5GHZ) {
2035 sdata->vif.bss_conf.use_short_slot = true;
2036 changed |= BSS_CHANGED_ERP_SLOT;
2039 if (params->use_short_slot_time >= 0) {
2040 sdata->vif.bss_conf.use_short_slot =
2041 params->use_short_slot_time;
2042 changed |= BSS_CHANGED_ERP_SLOT;
2045 if (params->basic_rates) {
2046 ieee80211_parse_bitrates(&sdata->vif.bss_conf.chandef,
2048 params->basic_rates,
2049 params->basic_rates_len,
2050 &sdata->vif.bss_conf.basic_rates);
2051 changed |= BSS_CHANGED_BASIC_RATES;
2054 if (params->ap_isolate >= 0) {
2055 if (params->ap_isolate)
2056 sdata->flags |= IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
2058 sdata->flags &= ~IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
2059 ieee80211_check_fast_rx_iface(sdata);
2062 if (params->ht_opmode >= 0) {
2063 sdata->vif.bss_conf.ht_operation_mode =
2064 (u16) params->ht_opmode;
2065 changed |= BSS_CHANGED_HT;
2068 if (params->p2p_ctwindow >= 0) {
2069 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow &=
2070 ~IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
2071 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |=
2072 params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
2073 changed |= BSS_CHANGED_P2P_PS;
2076 if (params->p2p_opp_ps > 0) {
2077 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |=
2078 IEEE80211_P2P_OPPPS_ENABLE_BIT;
2079 changed |= BSS_CHANGED_P2P_PS;
2080 } else if (params->p2p_opp_ps == 0) {
2081 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow &=
2082 ~IEEE80211_P2P_OPPPS_ENABLE_BIT;
2083 changed |= BSS_CHANGED_P2P_PS;
2086 ieee80211_bss_info_change_notify(sdata, changed);
2091 static int ieee80211_set_txq_params(struct wiphy *wiphy,
2092 struct net_device *dev,
2093 struct ieee80211_txq_params *params)
2095 struct ieee80211_local *local = wiphy_priv(wiphy);
2096 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2097 struct ieee80211_tx_queue_params p;
2099 if (!local->ops->conf_tx)
2102 if (local->hw.queues < IEEE80211_NUM_ACS)
2105 memset(&p, 0, sizeof(p));
2106 p.aifs = params->aifs;
2107 p.cw_max = params->cwmax;
2108 p.cw_min = params->cwmin;
2109 p.txop = params->txop;
2112 * Setting tx queue params disables u-apsd because it's only
2113 * called in master mode.
2117 sdata->tx_conf[params->ac] = p;
2118 if (drv_conf_tx(local, sdata, params->ac, &p)) {
2119 wiphy_debug(local->hw.wiphy,
2120 "failed to set TX queue parameters for AC %d\n",
2125 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_QOS);
2131 static int ieee80211_suspend(struct wiphy *wiphy,
2132 struct cfg80211_wowlan *wowlan)
2134 return __ieee80211_suspend(wiphy_priv(wiphy), wowlan);
2137 static int ieee80211_resume(struct wiphy *wiphy)
2139 return __ieee80211_resume(wiphy_priv(wiphy));
2142 #define ieee80211_suspend NULL
2143 #define ieee80211_resume NULL
2146 static int ieee80211_scan(struct wiphy *wiphy,
2147 struct cfg80211_scan_request *req)
2149 struct ieee80211_sub_if_data *sdata;
2151 sdata = IEEE80211_WDEV_TO_SUB_IF(req->wdev);
2153 switch (ieee80211_vif_type_p2p(&sdata->vif)) {
2154 case NL80211_IFTYPE_STATION:
2155 case NL80211_IFTYPE_ADHOC:
2156 case NL80211_IFTYPE_MESH_POINT:
2157 case NL80211_IFTYPE_P2P_CLIENT:
2158 case NL80211_IFTYPE_P2P_DEVICE:
2160 case NL80211_IFTYPE_P2P_GO:
2161 if (sdata->local->ops->hw_scan)
2164 * FIXME: implement NoA while scanning in software,
2165 * for now fall through to allow scanning only when
2166 * beaconing hasn't been configured yet
2168 case NL80211_IFTYPE_AP:
2170 * If the scan has been forced (and the driver supports
2171 * forcing), don't care about being beaconing already.
2172 * This will create problems to the attached stations (e.g. all
2173 * the frames sent while scanning on other channel will be
2176 if (sdata->u.ap.beacon &&
2177 (!(wiphy->features & NL80211_FEATURE_AP_SCAN) ||
2178 !(req->flags & NL80211_SCAN_FLAG_AP)))
2181 case NL80211_IFTYPE_NAN:
2186 return ieee80211_request_scan(sdata, req);
2189 static void ieee80211_abort_scan(struct wiphy *wiphy, struct wireless_dev *wdev)
2191 ieee80211_scan_cancel(wiphy_priv(wiphy));
2195 ieee80211_sched_scan_start(struct wiphy *wiphy,
2196 struct net_device *dev,
2197 struct cfg80211_sched_scan_request *req)
2199 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2201 if (!sdata->local->ops->sched_scan_start)
2204 return ieee80211_request_sched_scan_start(sdata, req);
2208 ieee80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev)
2210 struct ieee80211_local *local = wiphy_priv(wiphy);
2212 if (!local->ops->sched_scan_stop)
2215 return ieee80211_request_sched_scan_stop(local);
2218 static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev,
2219 struct cfg80211_auth_request *req)
2221 return ieee80211_mgd_auth(IEEE80211_DEV_TO_SUB_IF(dev), req);
2224 static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev,
2225 struct cfg80211_assoc_request *req)
2227 return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
2230 static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev,
2231 struct cfg80211_deauth_request *req)
2233 return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev), req);
2236 static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
2237 struct cfg80211_disassoc_request *req)
2239 return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
2242 static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
2243 struct cfg80211_ibss_params *params)
2245 return ieee80211_ibss_join(IEEE80211_DEV_TO_SUB_IF(dev), params);
2248 static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
2250 return ieee80211_ibss_leave(IEEE80211_DEV_TO_SUB_IF(dev));
2253 static int ieee80211_join_ocb(struct wiphy *wiphy, struct net_device *dev,
2254 struct ocb_setup *setup)
2256 return ieee80211_ocb_join(IEEE80211_DEV_TO_SUB_IF(dev), setup);
2259 static int ieee80211_leave_ocb(struct wiphy *wiphy, struct net_device *dev)
2261 return ieee80211_ocb_leave(IEEE80211_DEV_TO_SUB_IF(dev));
2264 static int ieee80211_set_mcast_rate(struct wiphy *wiphy, struct net_device *dev,
2265 int rate[NUM_NL80211_BANDS])
2267 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2269 memcpy(sdata->vif.bss_conf.mcast_rate, rate,
2270 sizeof(int) * NUM_NL80211_BANDS);
2275 static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
2277 struct ieee80211_local *local = wiphy_priv(wiphy);
2280 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
2281 ieee80211_check_fast_xmit_all(local);
2283 err = drv_set_frag_threshold(local, wiphy->frag_threshold);
2286 ieee80211_check_fast_xmit_all(local);
2291 if ((changed & WIPHY_PARAM_COVERAGE_CLASS) ||
2292 (changed & WIPHY_PARAM_DYN_ACK)) {
2295 coverage_class = changed & WIPHY_PARAM_COVERAGE_CLASS ?
2296 wiphy->coverage_class : -1;
2297 err = drv_set_coverage_class(local, coverage_class);
2303 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
2304 err = drv_set_rts_threshold(local, wiphy->rts_threshold);
2310 if (changed & WIPHY_PARAM_RETRY_SHORT) {
2311 if (wiphy->retry_short > IEEE80211_MAX_TX_RETRY)
2313 local->hw.conf.short_frame_max_tx_count = wiphy->retry_short;
2315 if (changed & WIPHY_PARAM_RETRY_LONG) {
2316 if (wiphy->retry_long > IEEE80211_MAX_TX_RETRY)
2318 local->hw.conf.long_frame_max_tx_count = wiphy->retry_long;
2321 (WIPHY_PARAM_RETRY_SHORT | WIPHY_PARAM_RETRY_LONG))
2322 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS);
2327 static int ieee80211_set_tx_power(struct wiphy *wiphy,
2328 struct wireless_dev *wdev,
2329 enum nl80211_tx_power_setting type, int mbm)
2331 struct ieee80211_local *local = wiphy_priv(wiphy);
2332 struct ieee80211_sub_if_data *sdata;
2333 enum nl80211_tx_power_setting txp_type = type;
2334 bool update_txp_type = false;
2337 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
2340 case NL80211_TX_POWER_AUTOMATIC:
2341 sdata->user_power_level = IEEE80211_UNSET_POWER_LEVEL;
2342 txp_type = NL80211_TX_POWER_LIMITED;
2344 case NL80211_TX_POWER_LIMITED:
2345 case NL80211_TX_POWER_FIXED:
2346 if (mbm < 0 || (mbm % 100))
2348 sdata->user_power_level = MBM_TO_DBM(mbm);
2352 if (txp_type != sdata->vif.bss_conf.txpower_type) {
2353 update_txp_type = true;
2354 sdata->vif.bss_conf.txpower_type = txp_type;
2357 ieee80211_recalc_txpower(sdata, update_txp_type);
2363 case NL80211_TX_POWER_AUTOMATIC:
2364 local->user_power_level = IEEE80211_UNSET_POWER_LEVEL;
2365 txp_type = NL80211_TX_POWER_LIMITED;
2367 case NL80211_TX_POWER_LIMITED:
2368 case NL80211_TX_POWER_FIXED:
2369 if (mbm < 0 || (mbm % 100))
2371 local->user_power_level = MBM_TO_DBM(mbm);
2375 mutex_lock(&local->iflist_mtx);
2376 list_for_each_entry(sdata, &local->interfaces, list) {
2377 sdata->user_power_level = local->user_power_level;
2378 if (txp_type != sdata->vif.bss_conf.txpower_type)
2379 update_txp_type = true;
2380 sdata->vif.bss_conf.txpower_type = txp_type;
2382 list_for_each_entry(sdata, &local->interfaces, list)
2383 ieee80211_recalc_txpower(sdata, update_txp_type);
2384 mutex_unlock(&local->iflist_mtx);
2389 static int ieee80211_get_tx_power(struct wiphy *wiphy,
2390 struct wireless_dev *wdev,
2393 struct ieee80211_local *local = wiphy_priv(wiphy);
2394 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
2396 if (local->ops->get_txpower)
2397 return drv_get_txpower(local, sdata, dbm);
2399 if (!local->use_chanctx)
2400 *dbm = local->hw.conf.power_level;
2402 *dbm = sdata->vif.bss_conf.txpower;
2407 static int ieee80211_set_wds_peer(struct wiphy *wiphy, struct net_device *dev,
2410 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2412 memcpy(&sdata->u.wds.remote_addr, addr, ETH_ALEN);
2417 static void ieee80211_rfkill_poll(struct wiphy *wiphy)
2419 struct ieee80211_local *local = wiphy_priv(wiphy);
2421 drv_rfkill_poll(local);
2424 #ifdef CONFIG_NL80211_TESTMODE
2425 static int ieee80211_testmode_cmd(struct wiphy *wiphy,
2426 struct wireless_dev *wdev,
2427 void *data, int len)
2429 struct ieee80211_local *local = wiphy_priv(wiphy);
2430 struct ieee80211_vif *vif = NULL;
2432 if (!local->ops->testmode_cmd)
2436 struct ieee80211_sub_if_data *sdata;
2438 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
2439 if (sdata->flags & IEEE80211_SDATA_IN_DRIVER)
2443 return local->ops->testmode_cmd(&local->hw, vif, data, len);
2446 static int ieee80211_testmode_dump(struct wiphy *wiphy,
2447 struct sk_buff *skb,
2448 struct netlink_callback *cb,
2449 void *data, int len)
2451 struct ieee80211_local *local = wiphy_priv(wiphy);
2453 if (!local->ops->testmode_dump)
2456 return local->ops->testmode_dump(&local->hw, skb, cb, data, len);
2460 int __ieee80211_request_smps_ap(struct ieee80211_sub_if_data *sdata,
2461 enum ieee80211_smps_mode smps_mode)
2463 struct sta_info *sta;
2464 enum ieee80211_smps_mode old_req;
2466 if (WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_AP))
2469 if (sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT)
2472 old_req = sdata->u.ap.req_smps;
2473 sdata->u.ap.req_smps = smps_mode;
2475 /* AUTOMATIC doesn't mean much for AP - don't allow it */
2476 if (old_req == smps_mode ||
2477 smps_mode == IEEE80211_SMPS_AUTOMATIC)
2480 /* If no associated stations, there's no need to do anything */
2481 if (!atomic_read(&sdata->u.ap.num_mcast_sta)) {
2482 sdata->smps_mode = smps_mode;
2483 ieee80211_queue_work(&sdata->local->hw, &sdata->recalc_smps);
2488 "SMPS %d requested in AP mode, sending Action frame to %d stations\n",
2489 smps_mode, atomic_read(&sdata->u.ap.num_mcast_sta));
2491 mutex_lock(&sdata->local->sta_mtx);
2492 list_for_each_entry(sta, &sdata->local->sta_list, list) {
2494 * Only stations associated to our AP and
2497 if (sta->sdata->bss != &sdata->u.ap)
2500 /* This station doesn't support MIMO - skip it */
2501 if (sta_info_tx_streams(sta) == 1)
2505 * Don't wake up a STA just to send the action frame
2506 * unless we are getting more restrictive.
2508 if (test_sta_flag(sta, WLAN_STA_PS_STA) &&
2509 !ieee80211_smps_is_restrictive(sta->known_smps_mode,
2511 ht_dbg(sdata, "Won't send SMPS to sleeping STA %pM\n",
2517 * If the STA is not authorized, wait until it gets
2518 * authorized and the action frame will be sent then.
2520 if (!test_sta_flag(sta, WLAN_STA_AUTHORIZED))
2523 ht_dbg(sdata, "Sending SMPS to %pM\n", sta->sta.addr);
2524 ieee80211_send_smps_action(sdata, smps_mode, sta->sta.addr,
2525 sdata->vif.bss_conf.bssid);
2527 mutex_unlock(&sdata->local->sta_mtx);
2529 sdata->smps_mode = smps_mode;
2530 ieee80211_queue_work(&sdata->local->hw, &sdata->recalc_smps);
2535 int __ieee80211_request_smps_mgd(struct ieee80211_sub_if_data *sdata,
2536 enum ieee80211_smps_mode smps_mode)
2539 enum ieee80211_smps_mode old_req;
2541 struct sta_info *sta;
2542 bool tdls_peer_found = false;
2544 lockdep_assert_held(&sdata->wdev.mtx);
2546 if (WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION))
2549 old_req = sdata->u.mgd.req_smps;
2550 sdata->u.mgd.req_smps = smps_mode;
2552 if (old_req == smps_mode &&
2553 smps_mode != IEEE80211_SMPS_AUTOMATIC)
2557 * If not associated, or current association is not an HT
2558 * association, there's no need to do anything, just store
2559 * the new value until we associate.
2561 if (!sdata->u.mgd.associated ||
2562 sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT)
2565 ap = sdata->u.mgd.associated->bssid;
2568 list_for_each_entry_rcu(sta, &sdata->local->sta_list, list) {
2569 if (!sta->sta.tdls || sta->sdata != sdata || !sta->uploaded ||
2570 !test_sta_flag(sta, WLAN_STA_AUTHORIZED))
2573 tdls_peer_found = true;
2578 if (smps_mode == IEEE80211_SMPS_AUTOMATIC) {
2579 if (tdls_peer_found || !sdata->u.mgd.powersave)
2580 smps_mode = IEEE80211_SMPS_OFF;
2582 smps_mode = IEEE80211_SMPS_DYNAMIC;
2585 /* send SM PS frame to AP */
2586 err = ieee80211_send_smps_action(sdata, smps_mode,
2589 sdata->u.mgd.req_smps = old_req;
2590 else if (smps_mode != IEEE80211_SMPS_OFF && tdls_peer_found)
2591 ieee80211_teardown_tdls_peers(sdata);
2596 static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
2597 bool enabled, int timeout)
2599 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2600 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2602 if (sdata->vif.type != NL80211_IFTYPE_STATION)
2605 if (!ieee80211_hw_check(&local->hw, SUPPORTS_PS))
2608 if (enabled == sdata->u.mgd.powersave &&
2609 timeout == local->dynamic_ps_forced_timeout)
2612 sdata->u.mgd.powersave = enabled;
2613 local->dynamic_ps_forced_timeout = timeout;
2615 /* no change, but if automatic follow powersave */
2617 __ieee80211_request_smps_mgd(sdata, sdata->u.mgd.req_smps);
2618 sdata_unlock(sdata);
2620 if (ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS))
2621 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
2623 ieee80211_recalc_ps(local);
2624 ieee80211_recalc_ps_vif(sdata);
2629 static int ieee80211_set_cqm_rssi_config(struct wiphy *wiphy,
2630 struct net_device *dev,
2631 s32 rssi_thold, u32 rssi_hyst)
2633 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2634 struct ieee80211_vif *vif = &sdata->vif;
2635 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
2637 if (rssi_thold == bss_conf->cqm_rssi_thold &&
2638 rssi_hyst == bss_conf->cqm_rssi_hyst)
2641 if (sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER &&
2642 !(sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI))
2645 bss_conf->cqm_rssi_thold = rssi_thold;
2646 bss_conf->cqm_rssi_hyst = rssi_hyst;
2647 sdata->u.mgd.last_cqm_event_signal = 0;
2649 /* tell the driver upon association, unless already associated */
2650 if (sdata->u.mgd.associated &&
2651 sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)
2652 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_CQM);
2657 static int ieee80211_set_bitrate_mask(struct wiphy *wiphy,
2658 struct net_device *dev,
2660 const struct cfg80211_bitrate_mask *mask)
2662 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2663 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2666 if (!ieee80211_sdata_running(sdata))
2669 if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) {
2670 ret = drv_set_bitrate_mask(local, sdata, mask);
2675 for (i = 0; i < NUM_NL80211_BANDS; i++) {
2676 struct ieee80211_supported_band *sband = wiphy->bands[i];
2679 sdata->rc_rateidx_mask[i] = mask->control[i].legacy;
2680 memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].ht_mcs,
2681 sizeof(mask->control[i].ht_mcs));
2682 memcpy(sdata->rc_rateidx_vht_mcs_mask[i],
2683 mask->control[i].vht_mcs,
2684 sizeof(mask->control[i].vht_mcs));
2686 sdata->rc_has_mcs_mask[i] = false;
2687 sdata->rc_has_vht_mcs_mask[i] = false;
2691 for (j = 0; j < IEEE80211_HT_MCS_MASK_LEN; j++) {
2692 if (~sdata->rc_rateidx_mcs_mask[i][j]) {
2693 sdata->rc_has_mcs_mask[i] = true;
2698 for (j = 0; j < NL80211_VHT_NSS_MAX; j++) {
2699 if (~sdata->rc_rateidx_vht_mcs_mask[i][j]) {
2700 sdata->rc_has_vht_mcs_mask[i] = true;
2709 static int ieee80211_start_radar_detection(struct wiphy *wiphy,
2710 struct net_device *dev,
2711 struct cfg80211_chan_def *chandef,
2714 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2715 struct ieee80211_local *local = sdata->local;
2718 mutex_lock(&local->mtx);
2719 if (!list_empty(&local->roc_list) || local->scanning) {
2724 /* whatever, but channel contexts should not complain about that one */
2725 sdata->smps_mode = IEEE80211_SMPS_OFF;
2726 sdata->needed_rx_chains = local->rx_chains;
2728 err = ieee80211_vif_use_channel(sdata, chandef,
2729 IEEE80211_CHANCTX_SHARED);
2733 ieee80211_queue_delayed_work(&sdata->local->hw,
2734 &sdata->dfs_cac_timer_work,
2735 msecs_to_jiffies(cac_time_ms));
2738 mutex_unlock(&local->mtx);
2742 static struct cfg80211_beacon_data *
2743 cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon)
2745 struct cfg80211_beacon_data *new_beacon;
2749 len = beacon->head_len + beacon->tail_len + beacon->beacon_ies_len +
2750 beacon->proberesp_ies_len + beacon->assocresp_ies_len +
2751 beacon->probe_resp_len;
2753 new_beacon = kzalloc(sizeof(*new_beacon) + len, GFP_KERNEL);
2757 pos = (u8 *)(new_beacon + 1);
2758 if (beacon->head_len) {
2759 new_beacon->head_len = beacon->head_len;
2760 new_beacon->head = pos;
2761 memcpy(pos, beacon->head, beacon->head_len);
2762 pos += beacon->head_len;
2764 if (beacon->tail_len) {
2765 new_beacon->tail_len = beacon->tail_len;
2766 new_beacon->tail = pos;
2767 memcpy(pos, beacon->tail, beacon->tail_len);
2768 pos += beacon->tail_len;
2770 if (beacon->beacon_ies_len) {
2771 new_beacon->beacon_ies_len = beacon->beacon_ies_len;
2772 new_beacon->beacon_ies = pos;
2773 memcpy(pos, beacon->beacon_ies, beacon->beacon_ies_len);
2774 pos += beacon->beacon_ies_len;
2776 if (beacon->proberesp_ies_len) {
2777 new_beacon->proberesp_ies_len = beacon->proberesp_ies_len;
2778 new_beacon->proberesp_ies = pos;
2779 memcpy(pos, beacon->proberesp_ies, beacon->proberesp_ies_len);
2780 pos += beacon->proberesp_ies_len;
2782 if (beacon->assocresp_ies_len) {
2783 new_beacon->assocresp_ies_len = beacon->assocresp_ies_len;
2784 new_beacon->assocresp_ies = pos;
2785 memcpy(pos, beacon->assocresp_ies, beacon->assocresp_ies_len);
2786 pos += beacon->assocresp_ies_len;
2788 if (beacon->probe_resp_len) {
2789 new_beacon->probe_resp_len = beacon->probe_resp_len;
2790 beacon->probe_resp = pos;
2791 memcpy(pos, beacon->probe_resp, beacon->probe_resp_len);
2792 pos += beacon->probe_resp_len;
2798 void ieee80211_csa_finish(struct ieee80211_vif *vif)
2800 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
2802 ieee80211_queue_work(&sdata->local->hw,
2803 &sdata->csa_finalize_work);
2805 EXPORT_SYMBOL(ieee80211_csa_finish);
2807 static int ieee80211_set_after_csa_beacon(struct ieee80211_sub_if_data *sdata,
2812 switch (sdata->vif.type) {
2813 case NL80211_IFTYPE_AP:
2814 err = ieee80211_assign_beacon(sdata, sdata->u.ap.next_beacon,
2816 kfree(sdata->u.ap.next_beacon);
2817 sdata->u.ap.next_beacon = NULL;
2823 case NL80211_IFTYPE_ADHOC:
2824 err = ieee80211_ibss_finish_csa(sdata);
2829 #ifdef CONFIG_MAC80211_MESH
2830 case NL80211_IFTYPE_MESH_POINT:
2831 err = ieee80211_mesh_finish_csa(sdata);
2845 static int __ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata)
2847 struct ieee80211_local *local = sdata->local;
2851 sdata_assert_lock(sdata);
2852 lockdep_assert_held(&local->mtx);
2853 lockdep_assert_held(&local->chanctx_mtx);
2856 * using reservation isn't immediate as it may be deferred until later
2857 * with multi-vif. once reservation is complete it will re-schedule the
2858 * work with no reserved_chanctx so verify chandef to check if it
2859 * completed successfully
2862 if (sdata->reserved_chanctx) {
2864 * with multi-vif csa driver may call ieee80211_csa_finish()
2865 * many times while waiting for other interfaces to use their
2868 if (sdata->reserved_ready)
2871 return ieee80211_vif_use_reserved_context(sdata);
2874 if (!cfg80211_chandef_identical(&sdata->vif.bss_conf.chandef,
2875 &sdata->csa_chandef))
2878 sdata->vif.csa_active = false;
2880 err = ieee80211_set_after_csa_beacon(sdata, &changed);
2884 ieee80211_bss_info_change_notify(sdata, changed);
2886 if (sdata->csa_block_tx) {
2887 ieee80211_wake_vif_queues(local, sdata,
2888 IEEE80211_QUEUE_STOP_REASON_CSA);
2889 sdata->csa_block_tx = false;
2892 err = drv_post_channel_switch(sdata);
2896 cfg80211_ch_switch_notify(sdata->dev, &sdata->csa_chandef);
2901 static void ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata)
2903 if (__ieee80211_csa_finalize(sdata)) {
2904 sdata_info(sdata, "failed to finalize CSA, disconnecting\n");
2905 cfg80211_stop_iface(sdata->local->hw.wiphy, &sdata->wdev,
2910 void ieee80211_csa_finalize_work(struct work_struct *work)
2912 struct ieee80211_sub_if_data *sdata =
2913 container_of(work, struct ieee80211_sub_if_data,
2915 struct ieee80211_local *local = sdata->local;
2918 mutex_lock(&local->mtx);
2919 mutex_lock(&local->chanctx_mtx);
2921 /* AP might have been stopped while waiting for the lock. */
2922 if (!sdata->vif.csa_active)
2925 if (!ieee80211_sdata_running(sdata))
2928 ieee80211_csa_finalize(sdata);
2931 mutex_unlock(&local->chanctx_mtx);
2932 mutex_unlock(&local->mtx);
2933 sdata_unlock(sdata);
2936 static int ieee80211_set_csa_beacon(struct ieee80211_sub_if_data *sdata,
2937 struct cfg80211_csa_settings *params,
2940 struct ieee80211_csa_settings csa = {};
2943 switch (sdata->vif.type) {
2944 case NL80211_IFTYPE_AP:
2945 sdata->u.ap.next_beacon =
2946 cfg80211_beacon_dup(¶ms->beacon_after);
2947 if (!sdata->u.ap.next_beacon)
2951 * With a count of 0, we don't have to wait for any
2952 * TBTT before switching, so complete the CSA
2953 * immediately. In theory, with a count == 1 we
2954 * should delay the switch until just before the next
2955 * TBTT, but that would complicate things so we switch
2956 * immediately too. If we would delay the switch
2957 * until the next TBTT, we would have to set the probe
2960 * TODO: A channel switch with count <= 1 without
2961 * sending a CSA action frame is kind of useless,
2962 * because the clients won't know we're changing
2963 * channels. The action frame must be implemented
2964 * either here or in the userspace.
2966 if (params->count <= 1)
2969 if ((params->n_counter_offsets_beacon >
2970 IEEE80211_MAX_CSA_COUNTERS_NUM) ||
2971 (params->n_counter_offsets_presp >
2972 IEEE80211_MAX_CSA_COUNTERS_NUM))
2975 csa.counter_offsets_beacon = params->counter_offsets_beacon;
2976 csa.counter_offsets_presp = params->counter_offsets_presp;
2977 csa.n_counter_offsets_beacon = params->n_counter_offsets_beacon;
2978 csa.n_counter_offsets_presp = params->n_counter_offsets_presp;
2979 csa.count = params->count;
2981 err = ieee80211_assign_beacon(sdata, ¶ms->beacon_csa, &csa);
2983 kfree(sdata->u.ap.next_beacon);
2989 case NL80211_IFTYPE_ADHOC:
2990 if (!sdata->vif.bss_conf.ibss_joined)
2993 if (params->chandef.width != sdata->u.ibss.chandef.width)
2996 switch (params->chandef.width) {
2997 case NL80211_CHAN_WIDTH_40:
2998 if (cfg80211_get_chandef_type(¶ms->chandef) !=
2999 cfg80211_get_chandef_type(&sdata->u.ibss.chandef))
3001 case NL80211_CHAN_WIDTH_5:
3002 case NL80211_CHAN_WIDTH_10:
3003 case NL80211_CHAN_WIDTH_20_NOHT:
3004 case NL80211_CHAN_WIDTH_20:
3010 /* changes into another band are not supported */
3011 if (sdata->u.ibss.chandef.chan->band !=
3012 params->chandef.chan->band)
3015 /* see comments in the NL80211_IFTYPE_AP block */
3016 if (params->count > 1) {
3017 err = ieee80211_ibss_csa_beacon(sdata, params);
3023 ieee80211_send_action_csa(sdata, params);
3026 #ifdef CONFIG_MAC80211_MESH
3027 case NL80211_IFTYPE_MESH_POINT: {
3028 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
3030 if (params->chandef.width != sdata->vif.bss_conf.chandef.width)
3033 /* changes into another band are not supported */
3034 if (sdata->vif.bss_conf.chandef.chan->band !=
3035 params->chandef.chan->band)
3038 if (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_NONE) {
3039 ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_INIT;
3040 if (!ifmsh->pre_value)
3041 ifmsh->pre_value = 1;
3046 /* see comments in the NL80211_IFTYPE_AP block */
3047 if (params->count > 1) {
3048 err = ieee80211_mesh_csa_beacon(sdata, params);
3050 ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_NONE;
3056 if (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_INIT)
3057 ieee80211_send_action_csa(sdata, params);
3070 __ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
3071 struct cfg80211_csa_settings *params)
3073 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3074 struct ieee80211_local *local = sdata->local;
3075 struct ieee80211_channel_switch ch_switch;
3076 struct ieee80211_chanctx_conf *conf;
3077 struct ieee80211_chanctx *chanctx;
3081 sdata_assert_lock(sdata);
3082 lockdep_assert_held(&local->mtx);
3084 if (!list_empty(&local->roc_list) || local->scanning)
3087 if (sdata->wdev.cac_started)
3090 if (cfg80211_chandef_identical(¶ms->chandef,
3091 &sdata->vif.bss_conf.chandef))
3094 /* don't allow another channel switch if one is already active. */
3095 if (sdata->vif.csa_active)
3098 mutex_lock(&local->chanctx_mtx);
3099 conf = rcu_dereference_protected(sdata->vif.chanctx_conf,
3100 lockdep_is_held(&local->chanctx_mtx));
3106 chanctx = container_of(conf, struct ieee80211_chanctx, conf);
3108 ch_switch.timestamp = 0;
3109 ch_switch.device_timestamp = 0;
3110 ch_switch.block_tx = params->block_tx;
3111 ch_switch.chandef = params->chandef;
3112 ch_switch.count = params->count;
3114 err = drv_pre_channel_switch(sdata, &ch_switch);
3118 err = ieee80211_vif_reserve_chanctx(sdata, ¶ms->chandef,
3120 params->radar_required);
3124 /* if reservation is invalid then this will fail */
3125 err = ieee80211_check_combinations(sdata, NULL, chanctx->mode, 0);
3127 ieee80211_vif_unreserve_chanctx(sdata);
3131 err = ieee80211_set_csa_beacon(sdata, params, &changed);
3133 ieee80211_vif_unreserve_chanctx(sdata);
3137 sdata->csa_chandef = params->chandef;
3138 sdata->csa_block_tx = params->block_tx;
3139 sdata->vif.csa_active = true;
3141 if (sdata->csa_block_tx)
3142 ieee80211_stop_vif_queues(local, sdata,
3143 IEEE80211_QUEUE_STOP_REASON_CSA);
3145 cfg80211_ch_switch_started_notify(sdata->dev, &sdata->csa_chandef,
3149 ieee80211_bss_info_change_notify(sdata, changed);
3150 drv_channel_switch_beacon(sdata, ¶ms->chandef);
3152 /* if the beacon didn't change, we can finalize immediately */
3153 ieee80211_csa_finalize(sdata);
3157 mutex_unlock(&local->chanctx_mtx);
3161 int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
3162 struct cfg80211_csa_settings *params)
3164 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3165 struct ieee80211_local *local = sdata->local;
3168 mutex_lock(&local->mtx);
3169 err = __ieee80211_channel_switch(wiphy, dev, params);
3170 mutex_unlock(&local->mtx);
3175 u64 ieee80211_mgmt_tx_cookie(struct ieee80211_local *local)
3177 lockdep_assert_held(&local->mtx);
3179 local->roc_cookie_counter++;
3181 /* wow, you wrapped 64 bits ... more likely a bug */
3182 if (WARN_ON(local->roc_cookie_counter == 0))
3183 local->roc_cookie_counter++;
3185 return local->roc_cookie_counter;
3188 int ieee80211_attach_ack_skb(struct ieee80211_local *local, struct sk_buff *skb,
3189 u64 *cookie, gfp_t gfp)
3191 unsigned long spin_flags;
3192 struct sk_buff *ack_skb;
3195 ack_skb = skb_copy(skb, gfp);
3199 spin_lock_irqsave(&local->ack_status_lock, spin_flags);
3200 id = idr_alloc(&local->ack_status_frames, ack_skb,
3201 1, 0x10000, GFP_ATOMIC);
3202 spin_unlock_irqrestore(&local->ack_status_lock, spin_flags);
3209 IEEE80211_SKB_CB(skb)->ack_frame_id = id;
3211 *cookie = ieee80211_mgmt_tx_cookie(local);
3212 IEEE80211_SKB_CB(ack_skb)->ack.cookie = *cookie;
3217 static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
3218 struct wireless_dev *wdev,
3219 u16 frame_type, bool reg)
3221 struct ieee80211_local *local = wiphy_priv(wiphy);
3222 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
3224 switch (frame_type) {
3225 case IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ:
3227 local->probe_req_reg++;
3228 sdata->vif.probe_req_reg++;
3230 if (local->probe_req_reg)
3231 local->probe_req_reg--;
3233 if (sdata->vif.probe_req_reg)
3234 sdata->vif.probe_req_reg--;
3237 if (!local->open_count)
3240 if (sdata->vif.probe_req_reg == 1)
3241 drv_config_iface_filter(local, sdata, FIF_PROBE_REQ,
3243 else if (sdata->vif.probe_req_reg == 0)
3244 drv_config_iface_filter(local, sdata, 0,
3247 ieee80211_configure_filter(local);
3254 static int ieee80211_set_antenna(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant)
3256 struct ieee80211_local *local = wiphy_priv(wiphy);
3261 return drv_set_antenna(local, tx_ant, rx_ant);
3264 static int ieee80211_get_antenna(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant)
3266 struct ieee80211_local *local = wiphy_priv(wiphy);
3268 return drv_get_antenna(local, tx_ant, rx_ant);
3271 static int ieee80211_set_rekey_data(struct wiphy *wiphy,
3272 struct net_device *dev,
3273 struct cfg80211_gtk_rekey_data *data)
3275 struct ieee80211_local *local = wiphy_priv(wiphy);
3276 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3278 if (!local->ops->set_rekey_data)
3281 drv_set_rekey_data(local, sdata, data);
3286 static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev,
3287 const u8 *peer, u64 *cookie)
3289 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3290 struct ieee80211_local *local = sdata->local;
3291 struct ieee80211_qos_hdr *nullfunc;
3292 struct sk_buff *skb;
3293 int size = sizeof(*nullfunc);
3296 struct ieee80211_tx_info *info;
3297 struct sta_info *sta;
3298 struct ieee80211_chanctx_conf *chanctx_conf;
3299 enum nl80211_band band;
3302 /* the lock is needed to assign the cookie later */
3303 mutex_lock(&local->mtx);
3306 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
3307 if (WARN_ON(!chanctx_conf)) {
3311 band = chanctx_conf->def.chan->band;
3312 sta = sta_info_get_bss(sdata, peer);
3321 fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
3322 IEEE80211_STYPE_QOS_NULLFUNC |
3323 IEEE80211_FCTL_FROMDS);
3326 fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
3327 IEEE80211_STYPE_NULLFUNC |
3328 IEEE80211_FCTL_FROMDS);
3331 skb = dev_alloc_skb(local->hw.extra_tx_headroom + size);
3339 skb_reserve(skb, local->hw.extra_tx_headroom);
3341 nullfunc = (void *) skb_put(skb, size);
3342 nullfunc->frame_control = fc;
3343 nullfunc->duration_id = 0;
3344 memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN);
3345 memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN);
3346 memcpy(nullfunc->addr3, sdata->vif.addr, ETH_ALEN);
3347 nullfunc->seq_ctrl = 0;
3349 info = IEEE80211_SKB_CB(skb);
3351 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS |
3352 IEEE80211_TX_INTFL_NL80211_FRAME_TX;
3355 skb_set_queue_mapping(skb, IEEE80211_AC_VO);
3358 nullfunc->qos_ctrl = cpu_to_le16(7);
3360 ret = ieee80211_attach_ack_skb(local, skb, cookie, GFP_ATOMIC);
3367 ieee80211_xmit(sdata, sta, skb);
3373 mutex_unlock(&local->mtx);
3378 static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
3379 struct wireless_dev *wdev,
3380 struct cfg80211_chan_def *chandef)
3382 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
3383 struct ieee80211_local *local = wiphy_priv(wiphy);
3384 struct ieee80211_chanctx_conf *chanctx_conf;
3388 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
3390 *chandef = sdata->vif.bss_conf.chandef;
3392 } else if (local->open_count > 0 &&
3393 local->open_count == local->monitors &&
3394 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
3395 if (local->use_chanctx)
3396 *chandef = local->monitor_chandef;
3398 *chandef = local->_oper_chandef;
3407 static void ieee80211_set_wakeup(struct wiphy *wiphy, bool enabled)
3409 drv_set_wakeup(wiphy_priv(wiphy), enabled);
3413 static int ieee80211_set_qos_map(struct wiphy *wiphy,
3414 struct net_device *dev,
3415 struct cfg80211_qos_map *qos_map)
3417 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3418 struct mac80211_qos_map *new_qos_map, *old_qos_map;
3421 new_qos_map = kzalloc(sizeof(*new_qos_map), GFP_KERNEL);
3424 memcpy(&new_qos_map->qos_map, qos_map, sizeof(*qos_map));
3426 /* A NULL qos_map was passed to disable QoS mapping */
3430 old_qos_map = sdata_dereference(sdata->qos_map, sdata);
3431 rcu_assign_pointer(sdata->qos_map, new_qos_map);
3433 kfree_rcu(old_qos_map, rcu_head);
3438 static int ieee80211_set_ap_chanwidth(struct wiphy *wiphy,
3439 struct net_device *dev,
3440 struct cfg80211_chan_def *chandef)
3442 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3446 ret = ieee80211_vif_change_bandwidth(sdata, chandef, &changed);
3448 ieee80211_bss_info_change_notify(sdata, changed);
3453 static int ieee80211_add_tx_ts(struct wiphy *wiphy, struct net_device *dev,
3454 u8 tsid, const u8 *peer, u8 up,
3457 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3458 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
3459 int ac = ieee802_1d_to_ac[up];
3461 if (sdata->vif.type != NL80211_IFTYPE_STATION)
3464 if (!(sdata->wmm_acm & BIT(up)))
3467 if (ifmgd->tx_tspec[ac].admitted_time)
3470 if (admitted_time) {
3471 ifmgd->tx_tspec[ac].admitted_time = 32 * admitted_time;
3472 ifmgd->tx_tspec[ac].tsid = tsid;
3473 ifmgd->tx_tspec[ac].up = up;
3479 static int ieee80211_del_tx_ts(struct wiphy *wiphy, struct net_device *dev,
3480 u8 tsid, const u8 *peer)
3482 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3483 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
3484 struct ieee80211_local *local = wiphy_priv(wiphy);
3487 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
3488 struct ieee80211_sta_tx_tspec *tx_tspec = &ifmgd->tx_tspec[ac];
3490 /* skip unused entries */
3491 if (!tx_tspec->admitted_time)
3494 if (tx_tspec->tsid != tsid)
3497 /* due to this new packets will be reassigned to non-ACM ACs */
3500 /* Make sure that all packets have been sent to avoid to
3501 * restore the QoS params on packets that are still on the
3505 ieee80211_flush_queues(local, sdata, false);
3507 /* restore the normal QoS parameters
3508 * (unconditionally to avoid races)
3510 tx_tspec->action = TX_TSPEC_ACTION_STOP_DOWNGRADE;
3511 tx_tspec->downgraded = false;
3512 ieee80211_sta_handle_tspec_ac_params(sdata);
3514 /* finally clear all the data */
3515 memset(tx_tspec, 0, sizeof(*tx_tspec));
3523 void ieee80211_nan_func_terminated(struct ieee80211_vif *vif,
3525 enum nl80211_nan_func_term_reason reason,
3528 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
3529 struct cfg80211_nan_func *func;
3532 if (WARN_ON(vif->type != NL80211_IFTYPE_NAN))
3535 spin_lock_bh(&sdata->u.nan.func_lock);
3537 func = idr_find(&sdata->u.nan.function_inst_ids, inst_id);
3538 if (WARN_ON(!func)) {
3539 spin_unlock_bh(&sdata->u.nan.func_lock);
3543 cookie = func->cookie;
3544 idr_remove(&sdata->u.nan.function_inst_ids, inst_id);
3546 spin_unlock_bh(&sdata->u.nan.func_lock);
3548 cfg80211_free_nan_func(func);
3550 cfg80211_nan_func_terminated(ieee80211_vif_to_wdev(vif), inst_id,
3551 reason, cookie, gfp);
3553 EXPORT_SYMBOL(ieee80211_nan_func_terminated);
3555 void ieee80211_nan_func_match(struct ieee80211_vif *vif,
3556 struct cfg80211_nan_match_params *match,
3559 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
3560 struct cfg80211_nan_func *func;
3562 if (WARN_ON(vif->type != NL80211_IFTYPE_NAN))
3565 spin_lock_bh(&sdata->u.nan.func_lock);
3567 func = idr_find(&sdata->u.nan.function_inst_ids, match->inst_id);
3568 if (WARN_ON(!func)) {
3569 spin_unlock_bh(&sdata->u.nan.func_lock);
3572 match->cookie = func->cookie;
3574 spin_unlock_bh(&sdata->u.nan.func_lock);
3576 cfg80211_nan_match(ieee80211_vif_to_wdev(vif), match, gfp);
3578 EXPORT_SYMBOL(ieee80211_nan_func_match);
3580 const struct cfg80211_ops mac80211_config_ops = {
3581 .add_virtual_intf = ieee80211_add_iface,
3582 .del_virtual_intf = ieee80211_del_iface,
3583 .change_virtual_intf = ieee80211_change_iface,
3584 .start_p2p_device = ieee80211_start_p2p_device,
3585 .stop_p2p_device = ieee80211_stop_p2p_device,
3586 .add_key = ieee80211_add_key,
3587 .del_key = ieee80211_del_key,
3588 .get_key = ieee80211_get_key,
3589 .set_default_key = ieee80211_config_default_key,
3590 .set_default_mgmt_key = ieee80211_config_default_mgmt_key,
3591 .start_ap = ieee80211_start_ap,
3592 .change_beacon = ieee80211_change_beacon,
3593 .stop_ap = ieee80211_stop_ap,
3594 .add_station = ieee80211_add_station,
3595 .del_station = ieee80211_del_station,
3596 .change_station = ieee80211_change_station,
3597 .get_station = ieee80211_get_station,
3598 .dump_station = ieee80211_dump_station,
3599 .dump_survey = ieee80211_dump_survey,
3600 #ifdef CONFIG_MAC80211_MESH
3601 .add_mpath = ieee80211_add_mpath,
3602 .del_mpath = ieee80211_del_mpath,
3603 .change_mpath = ieee80211_change_mpath,
3604 .get_mpath = ieee80211_get_mpath,
3605 .dump_mpath = ieee80211_dump_mpath,
3606 .get_mpp = ieee80211_get_mpp,
3607 .dump_mpp = ieee80211_dump_mpp,
3608 .update_mesh_config = ieee80211_update_mesh_config,
3609 .get_mesh_config = ieee80211_get_mesh_config,
3610 .join_mesh = ieee80211_join_mesh,
3611 .leave_mesh = ieee80211_leave_mesh,
3613 .join_ocb = ieee80211_join_ocb,
3614 .leave_ocb = ieee80211_leave_ocb,
3615 .change_bss = ieee80211_change_bss,
3616 .set_txq_params = ieee80211_set_txq_params,
3617 .set_monitor_channel = ieee80211_set_monitor_channel,
3618 .suspend = ieee80211_suspend,
3619 .resume = ieee80211_resume,
3620 .scan = ieee80211_scan,
3621 .abort_scan = ieee80211_abort_scan,
3622 .sched_scan_start = ieee80211_sched_scan_start,
3623 .sched_scan_stop = ieee80211_sched_scan_stop,
3624 .auth = ieee80211_auth,
3625 .assoc = ieee80211_assoc,
3626 .deauth = ieee80211_deauth,
3627 .disassoc = ieee80211_disassoc,
3628 .join_ibss = ieee80211_join_ibss,
3629 .leave_ibss = ieee80211_leave_ibss,
3630 .set_mcast_rate = ieee80211_set_mcast_rate,
3631 .set_wiphy_params = ieee80211_set_wiphy_params,
3632 .set_tx_power = ieee80211_set_tx_power,
3633 .get_tx_power = ieee80211_get_tx_power,
3634 .set_wds_peer = ieee80211_set_wds_peer,
3635 .rfkill_poll = ieee80211_rfkill_poll,
3636 CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd)
3637 CFG80211_TESTMODE_DUMP(ieee80211_testmode_dump)
3638 .set_power_mgmt = ieee80211_set_power_mgmt,
3639 .set_bitrate_mask = ieee80211_set_bitrate_mask,
3640 .remain_on_channel = ieee80211_remain_on_channel,
3641 .cancel_remain_on_channel = ieee80211_cancel_remain_on_channel,
3642 .mgmt_tx = ieee80211_mgmt_tx,
3643 .mgmt_tx_cancel_wait = ieee80211_mgmt_tx_cancel_wait,
3644 .set_cqm_rssi_config = ieee80211_set_cqm_rssi_config,
3645 .mgmt_frame_register = ieee80211_mgmt_frame_register,
3646 .set_antenna = ieee80211_set_antenna,
3647 .get_antenna = ieee80211_get_antenna,
3648 .set_rekey_data = ieee80211_set_rekey_data,
3649 .tdls_oper = ieee80211_tdls_oper,
3650 .tdls_mgmt = ieee80211_tdls_mgmt,
3651 .tdls_channel_switch = ieee80211_tdls_channel_switch,
3652 .tdls_cancel_channel_switch = ieee80211_tdls_cancel_channel_switch,
3653 .probe_client = ieee80211_probe_client,
3654 .set_noack_map = ieee80211_set_noack_map,
3656 .set_wakeup = ieee80211_set_wakeup,
3658 .get_channel = ieee80211_cfg_get_channel,
3659 .start_radar_detection = ieee80211_start_radar_detection,
3660 .channel_switch = ieee80211_channel_switch,
3661 .set_qos_map = ieee80211_set_qos_map,
3662 .set_ap_chanwidth = ieee80211_set_ap_chanwidth,
3663 .add_tx_ts = ieee80211_add_tx_ts,
3664 .del_tx_ts = ieee80211_del_tx_ts,
3665 .start_nan = ieee80211_start_nan,
3666 .stop_nan = ieee80211_stop_nan,
3667 .nan_change_conf = ieee80211_nan_change_conf,
3668 .add_nan_func = ieee80211_add_nan_func,
3669 .del_nan_func = ieee80211_del_nan_func,