2 * mac80211 configuration hooks for cfg80211
4 * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
5 * Copyright 2013-2014 Intel Mobile Communications GmbH
7 * This file is GPLv2 as found in COPYING.
10 #include <linux/ieee80211.h>
11 #include <linux/nl80211.h>
12 #include <linux/rtnetlink.h>
13 #include <linux/slab.h>
14 #include <net/net_namespace.h>
15 #include <linux/rcupdate.h>
16 #include <linux/if_ether.h>
17 #include <net/cfg80211.h>
18 #include "ieee80211_i.h"
19 #include "driver-ops.h"
25 static struct wireless_dev *ieee80211_add_iface(struct wiphy *wiphy,
27 enum nl80211_iftype type,
29 struct vif_params *params)
31 struct ieee80211_local *local = wiphy_priv(wiphy);
32 struct wireless_dev *wdev;
33 struct ieee80211_sub_if_data *sdata;
36 err = ieee80211_if_add(local, name, &wdev, type, params);
40 if (type == NL80211_IFTYPE_MONITOR && flags) {
41 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
42 sdata->u.mntr_flags = *flags;
48 static int ieee80211_del_iface(struct wiphy *wiphy, struct wireless_dev *wdev)
50 ieee80211_if_remove(IEEE80211_WDEV_TO_SUB_IF(wdev));
55 static int ieee80211_change_iface(struct wiphy *wiphy,
56 struct net_device *dev,
57 enum nl80211_iftype type, u32 *flags,
58 struct vif_params *params)
60 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
63 ret = ieee80211_if_change_type(sdata, type);
67 if (type == NL80211_IFTYPE_AP_VLAN &&
68 params && params->use_4addr == 0)
69 RCU_INIT_POINTER(sdata->u.vlan.sta, NULL);
70 else if (type == NL80211_IFTYPE_STATION &&
71 params && params->use_4addr >= 0)
72 sdata->u.mgd.use_4addr = params->use_4addr;
74 if (sdata->vif.type == NL80211_IFTYPE_MONITOR && flags) {
75 struct ieee80211_local *local = sdata->local;
77 if (ieee80211_sdata_running(sdata)) {
78 u32 mask = MONITOR_FLAG_COOK_FRAMES |
82 * Prohibit MONITOR_FLAG_COOK_FRAMES and
83 * MONITOR_FLAG_ACTIVE to be changed while the
85 * Else we would need to add a lot of cruft
86 * to update everything:
87 * cooked_mntrs, monitor and all fif_* counters
88 * reconfigure hardware
90 if ((*flags & mask) != (sdata->u.mntr_flags & mask))
93 ieee80211_adjust_monitor_flags(sdata, -1);
94 sdata->u.mntr_flags = *flags;
95 ieee80211_adjust_monitor_flags(sdata, 1);
97 ieee80211_configure_filter(local);
100 * Because the interface is down, ieee80211_do_stop
101 * and ieee80211_do_open take care of "everything"
102 * mentioned in the comment above.
104 sdata->u.mntr_flags = *flags;
111 static int ieee80211_start_p2p_device(struct wiphy *wiphy,
112 struct wireless_dev *wdev)
114 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
117 mutex_lock(&sdata->local->chanctx_mtx);
118 ret = ieee80211_check_combinations(sdata, NULL, 0, 0);
119 mutex_unlock(&sdata->local->chanctx_mtx);
123 return ieee80211_do_open(wdev, true);
126 static void ieee80211_stop_p2p_device(struct wiphy *wiphy,
127 struct wireless_dev *wdev)
129 ieee80211_sdata_stop(IEEE80211_WDEV_TO_SUB_IF(wdev));
132 static int ieee80211_set_noack_map(struct wiphy *wiphy,
133 struct net_device *dev,
136 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
138 sdata->noack_map = noack_map;
142 static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
143 u8 key_idx, bool pairwise, const u8 *mac_addr,
144 struct key_params *params)
146 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
147 struct ieee80211_local *local = sdata->local;
148 struct sta_info *sta = NULL;
149 const struct ieee80211_cipher_scheme *cs = NULL;
150 struct ieee80211_key *key;
153 if (!ieee80211_sdata_running(sdata))
156 /* reject WEP and TKIP keys if WEP failed to initialize */
157 switch (params->cipher) {
158 case WLAN_CIPHER_SUITE_WEP40:
159 case WLAN_CIPHER_SUITE_TKIP:
160 case WLAN_CIPHER_SUITE_WEP104:
161 if (IS_ERR(local->wep_tx_tfm))
164 case WLAN_CIPHER_SUITE_CCMP:
165 case WLAN_CIPHER_SUITE_AES_CMAC:
166 case WLAN_CIPHER_SUITE_GCMP:
169 cs = ieee80211_cs_get(local, params->cipher, sdata->vif.type);
173 key = ieee80211_key_alloc(params->cipher, key_idx, params->key_len,
174 params->key, params->seq_len, params->seq,
180 key->conf.flags |= IEEE80211_KEY_FLAG_PAIRWISE;
182 mutex_lock(&local->sta_mtx);
185 if (ieee80211_vif_is_mesh(&sdata->vif))
186 sta = sta_info_get(sdata, mac_addr);
188 sta = sta_info_get_bss(sdata, mac_addr);
190 * The ASSOC test makes sure the driver is ready to
191 * receive the key. When wpa_supplicant has roamed
192 * using FT, it attempts to set the key before
193 * association has completed, this rejects that attempt
194 * so it will set the key again after association.
196 * TODO: accept the key if we have a station entry and
197 * add it to the device after the station.
199 if (!sta || !test_sta_flag(sta, WLAN_STA_ASSOC)) {
200 ieee80211_key_free_unused(key);
206 switch (sdata->vif.type) {
207 case NL80211_IFTYPE_STATION:
208 if (sdata->u.mgd.mfp != IEEE80211_MFP_DISABLED)
209 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
211 case NL80211_IFTYPE_AP:
212 case NL80211_IFTYPE_AP_VLAN:
213 /* Keys without a station are used for TX only */
214 if (key->sta && test_sta_flag(key->sta, WLAN_STA_MFP))
215 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
217 case NL80211_IFTYPE_ADHOC:
220 case NL80211_IFTYPE_MESH_POINT:
221 #ifdef CONFIG_MAC80211_MESH
222 if (sdata->u.mesh.security != IEEE80211_MESH_SEC_NONE)
223 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
226 case NL80211_IFTYPE_WDS:
227 case NL80211_IFTYPE_MONITOR:
228 case NL80211_IFTYPE_P2P_DEVICE:
229 case NL80211_IFTYPE_UNSPECIFIED:
230 case NUM_NL80211_IFTYPES:
231 case NL80211_IFTYPE_P2P_CLIENT:
232 case NL80211_IFTYPE_P2P_GO:
233 case NL80211_IFTYPE_OCB:
234 /* shouldn't happen */
240 sta->cipher_scheme = cs;
242 err = ieee80211_key_link(key, sdata, sta);
245 mutex_unlock(&local->sta_mtx);
250 static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
251 u8 key_idx, bool pairwise, const u8 *mac_addr)
253 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
254 struct ieee80211_local *local = sdata->local;
255 struct sta_info *sta;
256 struct ieee80211_key *key = NULL;
259 mutex_lock(&local->sta_mtx);
260 mutex_lock(&local->key_mtx);
265 sta = sta_info_get_bss(sdata, mac_addr);
270 key = key_mtx_dereference(local, sta->ptk[key_idx]);
272 key = key_mtx_dereference(local, sta->gtk[key_idx]);
274 key = key_mtx_dereference(local, sdata->keys[key_idx]);
281 ieee80211_key_free(key, true);
285 mutex_unlock(&local->key_mtx);
286 mutex_unlock(&local->sta_mtx);
291 static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
292 u8 key_idx, bool pairwise, const u8 *mac_addr,
294 void (*callback)(void *cookie,
295 struct key_params *params))
297 struct ieee80211_sub_if_data *sdata;
298 struct sta_info *sta = NULL;
300 struct key_params params;
301 struct ieee80211_key *key = NULL;
307 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
312 sta = sta_info_get_bss(sdata, mac_addr);
316 if (pairwise && key_idx < NUM_DEFAULT_KEYS)
317 key = rcu_dereference(sta->ptk[key_idx]);
318 else if (!pairwise &&
319 key_idx < NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS)
320 key = rcu_dereference(sta->gtk[key_idx]);
322 key = rcu_dereference(sdata->keys[key_idx]);
327 memset(¶ms, 0, sizeof(params));
329 params.cipher = key->conf.cipher;
331 switch (key->conf.cipher) {
332 case WLAN_CIPHER_SUITE_TKIP:
333 iv32 = key->u.tkip.tx.iv32;
334 iv16 = key->u.tkip.tx.iv16;
336 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)
337 drv_get_tkip_seq(sdata->local,
338 key->conf.hw_key_idx,
341 seq[0] = iv16 & 0xff;
342 seq[1] = (iv16 >> 8) & 0xff;
343 seq[2] = iv32 & 0xff;
344 seq[3] = (iv32 >> 8) & 0xff;
345 seq[4] = (iv32 >> 16) & 0xff;
346 seq[5] = (iv32 >> 24) & 0xff;
350 case WLAN_CIPHER_SUITE_CCMP:
351 pn64 = atomic64_read(&key->u.ccmp.tx_pn);
361 case WLAN_CIPHER_SUITE_AES_CMAC:
362 pn64 = atomic64_read(&key->u.aes_cmac.tx_pn);
374 params.key = key->conf.key;
375 params.key_len = key->conf.keylen;
377 callback(cookie, ¶ms);
385 static int ieee80211_config_default_key(struct wiphy *wiphy,
386 struct net_device *dev,
387 u8 key_idx, bool uni,
390 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
392 ieee80211_set_default_key(sdata, key_idx, uni, multi);
397 static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy,
398 struct net_device *dev,
401 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
403 ieee80211_set_default_mgmt_key(sdata, key_idx);
408 void sta_set_rate_info_tx(struct sta_info *sta,
409 const struct ieee80211_tx_rate *rate,
410 struct rate_info *rinfo)
413 if (rate->flags & IEEE80211_TX_RC_MCS) {
414 rinfo->flags |= RATE_INFO_FLAGS_MCS;
415 rinfo->mcs = rate->idx;
416 } else if (rate->flags & IEEE80211_TX_RC_VHT_MCS) {
417 rinfo->flags |= RATE_INFO_FLAGS_VHT_MCS;
418 rinfo->mcs = ieee80211_rate_get_vht_mcs(rate);
419 rinfo->nss = ieee80211_rate_get_vht_nss(rate);
421 struct ieee80211_supported_band *sband;
422 int shift = ieee80211_vif_get_shift(&sta->sdata->vif);
425 sband = sta->local->hw.wiphy->bands[
426 ieee80211_get_sdata_band(sta->sdata)];
427 brate = sband->bitrates[rate->idx].bitrate;
428 rinfo->legacy = DIV_ROUND_UP(brate, 1 << shift);
430 if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
431 rinfo->bw = RATE_INFO_BW_40;
432 else if (rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH)
433 rinfo->bw = RATE_INFO_BW_80;
434 else if (rate->flags & IEEE80211_TX_RC_160_MHZ_WIDTH)
435 rinfo->bw = RATE_INFO_BW_160;
437 rinfo->bw = RATE_INFO_BW_20;
438 if (rate->flags & IEEE80211_TX_RC_SHORT_GI)
439 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI;
442 void sta_set_rate_info_rx(struct sta_info *sta, struct rate_info *rinfo)
446 if (sta->last_rx_rate_flag & RX_FLAG_HT) {
447 rinfo->flags |= RATE_INFO_FLAGS_MCS;
448 rinfo->mcs = sta->last_rx_rate_idx;
449 } else if (sta->last_rx_rate_flag & RX_FLAG_VHT) {
450 rinfo->flags |= RATE_INFO_FLAGS_VHT_MCS;
451 rinfo->nss = sta->last_rx_rate_vht_nss;
452 rinfo->mcs = sta->last_rx_rate_idx;
454 struct ieee80211_supported_band *sband;
455 int shift = ieee80211_vif_get_shift(&sta->sdata->vif);
458 sband = sta->local->hw.wiphy->bands[
459 ieee80211_get_sdata_band(sta->sdata)];
460 brate = sband->bitrates[sta->last_rx_rate_idx].bitrate;
461 rinfo->legacy = DIV_ROUND_UP(brate, 1 << shift);
464 if (sta->last_rx_rate_flag & RX_FLAG_SHORT_GI)
465 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI;
467 if (sta->last_rx_rate_flag & RX_FLAG_5MHZ)
468 rinfo->bw = RATE_INFO_BW_5;
469 else if (sta->last_rx_rate_flag & RX_FLAG_10MHZ)
470 rinfo->bw = RATE_INFO_BW_10;
471 else if (sta->last_rx_rate_flag & RX_FLAG_40MHZ)
472 rinfo->bw = RATE_INFO_BW_40;
473 else if (sta->last_rx_rate_vht_flag & RX_VHT_FLAG_80MHZ)
474 rinfo->bw = RATE_INFO_BW_80;
475 else if (sta->last_rx_rate_vht_flag & RX_VHT_FLAG_160MHZ)
476 rinfo->bw = RATE_INFO_BW_160;
478 rinfo->bw = RATE_INFO_BW_20;
481 static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev,
482 int idx, u8 *mac, struct station_info *sinfo)
484 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
485 struct ieee80211_local *local = sdata->local;
486 struct sta_info *sta;
489 mutex_lock(&local->sta_mtx);
491 sta = sta_info_get_by_idx(sdata, idx);
494 memcpy(mac, sta->sta.addr, ETH_ALEN);
495 sta_set_sinfo(sta, sinfo);
498 mutex_unlock(&local->sta_mtx);
503 static int ieee80211_dump_survey(struct wiphy *wiphy, struct net_device *dev,
504 int idx, struct survey_info *survey)
506 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
508 return drv_get_survey(local, idx, survey);
511 static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev,
512 const u8 *mac, struct station_info *sinfo)
514 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
515 struct ieee80211_local *local = sdata->local;
516 struct sta_info *sta;
519 mutex_lock(&local->sta_mtx);
521 sta = sta_info_get_bss(sdata, mac);
524 sta_set_sinfo(sta, sinfo);
527 mutex_unlock(&local->sta_mtx);
532 static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
533 struct cfg80211_chan_def *chandef)
535 struct ieee80211_local *local = wiphy_priv(wiphy);
536 struct ieee80211_sub_if_data *sdata;
539 if (cfg80211_chandef_identical(&local->monitor_chandef, chandef))
542 mutex_lock(&local->mtx);
543 mutex_lock(&local->iflist_mtx);
544 if (local->use_chanctx) {
545 sdata = rcu_dereference_protected(
546 local->monitor_sdata,
547 lockdep_is_held(&local->iflist_mtx));
549 ieee80211_vif_release_channel(sdata);
550 ret = ieee80211_vif_use_channel(sdata, chandef,
551 IEEE80211_CHANCTX_EXCLUSIVE);
553 } else if (local->open_count == local->monitors) {
554 local->_oper_chandef = *chandef;
555 ieee80211_hw_config(local, 0);
559 local->monitor_chandef = *chandef;
560 mutex_unlock(&local->iflist_mtx);
561 mutex_unlock(&local->mtx);
566 static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata,
567 const u8 *resp, size_t resp_len,
568 const struct ieee80211_csa_settings *csa)
570 struct probe_resp *new, *old;
572 if (!resp || !resp_len)
575 old = sdata_dereference(sdata->u.ap.probe_resp, sdata);
577 new = kzalloc(sizeof(struct probe_resp) + resp_len, GFP_KERNEL);
582 memcpy(new->data, resp, resp_len);
585 memcpy(new->csa_counter_offsets, csa->counter_offsets_presp,
586 csa->n_counter_offsets_presp *
587 sizeof(new->csa_counter_offsets[0]));
589 rcu_assign_pointer(sdata->u.ap.probe_resp, new);
591 kfree_rcu(old, rcu_head);
596 static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
597 struct cfg80211_beacon_data *params,
598 const struct ieee80211_csa_settings *csa)
600 struct beacon_data *new, *old;
601 int new_head_len, new_tail_len;
603 u32 changed = BSS_CHANGED_BEACON;
605 old = sdata_dereference(sdata->u.ap.beacon, sdata);
608 /* Need to have a beacon head if we don't have one yet */
609 if (!params->head && !old)
612 /* new or old head? */
614 new_head_len = params->head_len;
616 new_head_len = old->head_len;
618 /* new or old tail? */
619 if (params->tail || !old)
620 /* params->tail_len will be zero for !params->tail */
621 new_tail_len = params->tail_len;
623 new_tail_len = old->tail_len;
625 size = sizeof(*new) + new_head_len + new_tail_len;
627 new = kzalloc(size, GFP_KERNEL);
631 /* start filling the new info now */
634 * pointers go into the block we allocated,
635 * memory is | beacon_data | head | tail |
637 new->head = ((u8 *) new) + sizeof(*new);
638 new->tail = new->head + new_head_len;
639 new->head_len = new_head_len;
640 new->tail_len = new_tail_len;
643 new->csa_current_counter = csa->count;
644 memcpy(new->csa_counter_offsets, csa->counter_offsets_beacon,
645 csa->n_counter_offsets_beacon *
646 sizeof(new->csa_counter_offsets[0]));
651 memcpy(new->head, params->head, new_head_len);
653 memcpy(new->head, old->head, new_head_len);
655 /* copy in optional tail */
657 memcpy(new->tail, params->tail, new_tail_len);
660 memcpy(new->tail, old->tail, new_tail_len);
662 err = ieee80211_set_probe_resp(sdata, params->probe_resp,
663 params->probe_resp_len, csa);
667 changed |= BSS_CHANGED_AP_PROBE_RESP;
669 rcu_assign_pointer(sdata->u.ap.beacon, new);
672 kfree_rcu(old, rcu_head);
677 static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
678 struct cfg80211_ap_settings *params)
680 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
681 struct ieee80211_local *local = sdata->local;
682 struct beacon_data *old;
683 struct ieee80211_sub_if_data *vlan;
684 u32 changed = BSS_CHANGED_BEACON_INT |
685 BSS_CHANGED_BEACON_ENABLED |
692 old = sdata_dereference(sdata->u.ap.beacon, sdata);
696 switch (params->smps_mode) {
697 case NL80211_SMPS_OFF:
698 sdata->smps_mode = IEEE80211_SMPS_OFF;
700 case NL80211_SMPS_STATIC:
701 sdata->smps_mode = IEEE80211_SMPS_STATIC;
703 case NL80211_SMPS_DYNAMIC:
704 sdata->smps_mode = IEEE80211_SMPS_DYNAMIC;
709 sdata->needed_rx_chains = sdata->local->rx_chains;
711 mutex_lock(&local->mtx);
712 err = ieee80211_vif_use_channel(sdata, ¶ms->chandef,
713 IEEE80211_CHANCTX_SHARED);
715 ieee80211_vif_copy_chanctx_to_vlans(sdata, false);
716 mutex_unlock(&local->mtx);
721 * Apply control port protocol, this allows us to
722 * not encrypt dynamic WEP control frames.
724 sdata->control_port_protocol = params->crypto.control_port_ethertype;
725 sdata->control_port_no_encrypt = params->crypto.control_port_no_encrypt;
726 sdata->encrypt_headroom = ieee80211_cs_headroom(sdata->local,
730 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) {
731 vlan->control_port_protocol =
732 params->crypto.control_port_ethertype;
733 vlan->control_port_no_encrypt =
734 params->crypto.control_port_no_encrypt;
735 vlan->encrypt_headroom =
736 ieee80211_cs_headroom(sdata->local,
741 sdata->vif.bss_conf.beacon_int = params->beacon_interval;
742 sdata->vif.bss_conf.dtim_period = params->dtim_period;
743 sdata->vif.bss_conf.enable_beacon = true;
745 sdata->vif.bss_conf.ssid_len = params->ssid_len;
746 if (params->ssid_len)
747 memcpy(sdata->vif.bss_conf.ssid, params->ssid,
749 sdata->vif.bss_conf.hidden_ssid =
750 (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE);
752 memset(&sdata->vif.bss_conf.p2p_noa_attr, 0,
753 sizeof(sdata->vif.bss_conf.p2p_noa_attr));
754 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow =
755 params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
756 if (params->p2p_opp_ps)
757 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |=
758 IEEE80211_P2P_OPPPS_ENABLE_BIT;
760 err = ieee80211_assign_beacon(sdata, ¶ms->beacon, NULL);
762 ieee80211_vif_release_channel(sdata);
767 err = drv_start_ap(sdata->local, sdata);
769 old = sdata_dereference(sdata->u.ap.beacon, sdata);
772 kfree_rcu(old, rcu_head);
773 RCU_INIT_POINTER(sdata->u.ap.beacon, NULL);
774 ieee80211_vif_release_channel(sdata);
778 ieee80211_recalc_dtim(local, sdata);
779 ieee80211_bss_info_change_notify(sdata, changed);
781 netif_carrier_on(dev);
782 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
783 netif_carrier_on(vlan->dev);
788 static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev,
789 struct cfg80211_beacon_data *params)
791 struct ieee80211_sub_if_data *sdata;
792 struct beacon_data *old;
795 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
796 sdata_assert_lock(sdata);
798 /* don't allow changing the beacon while CSA is in place - offset
799 * of channel switch counter may change
801 if (sdata->vif.csa_active)
804 old = sdata_dereference(sdata->u.ap.beacon, sdata);
808 err = ieee80211_assign_beacon(sdata, params, NULL);
811 ieee80211_bss_info_change_notify(sdata, err);
815 static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev)
817 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
818 struct ieee80211_sub_if_data *vlan;
819 struct ieee80211_local *local = sdata->local;
820 struct beacon_data *old_beacon;
821 struct probe_resp *old_probe_resp;
822 struct cfg80211_chan_def chandef;
824 sdata_assert_lock(sdata);
826 old_beacon = sdata_dereference(sdata->u.ap.beacon, sdata);
829 old_probe_resp = sdata_dereference(sdata->u.ap.probe_resp, sdata);
831 /* abort any running channel switch */
832 mutex_lock(&local->mtx);
833 sdata->vif.csa_active = false;
834 if (sdata->csa_block_tx) {
835 ieee80211_wake_vif_queues(local, sdata,
836 IEEE80211_QUEUE_STOP_REASON_CSA);
837 sdata->csa_block_tx = false;
840 mutex_unlock(&local->mtx);
842 kfree(sdata->u.ap.next_beacon);
843 sdata->u.ap.next_beacon = NULL;
845 /* turn off carrier for this interface and dependent VLANs */
846 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
847 netif_carrier_off(vlan->dev);
848 netif_carrier_off(dev);
850 /* remove beacon and probe response */
851 RCU_INIT_POINTER(sdata->u.ap.beacon, NULL);
852 RCU_INIT_POINTER(sdata->u.ap.probe_resp, NULL);
853 kfree_rcu(old_beacon, rcu_head);
855 kfree_rcu(old_probe_resp, rcu_head);
856 sdata->u.ap.driver_smps_mode = IEEE80211_SMPS_OFF;
858 __sta_info_flush(sdata, true);
859 ieee80211_free_keys(sdata, true);
861 sdata->vif.bss_conf.enable_beacon = false;
862 sdata->vif.bss_conf.ssid_len = 0;
863 clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state);
864 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
866 if (sdata->wdev.cac_started) {
867 chandef = sdata->vif.bss_conf.chandef;
868 cancel_delayed_work_sync(&sdata->dfs_cac_timer_work);
869 cfg80211_cac_event(sdata->dev, &chandef,
870 NL80211_RADAR_CAC_ABORTED,
874 drv_stop_ap(sdata->local, sdata);
876 /* free all potentially still buffered bcast frames */
877 local->total_ps_buffered -= skb_queue_len(&sdata->u.ap.ps.bc_buf);
878 skb_queue_purge(&sdata->u.ap.ps.bc_buf);
880 mutex_lock(&local->mtx);
881 ieee80211_vif_copy_chanctx_to_vlans(sdata, true);
882 ieee80211_vif_release_channel(sdata);
883 mutex_unlock(&local->mtx);
888 /* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */
889 struct iapp_layer2_update {
890 u8 da[ETH_ALEN]; /* broadcast */
891 u8 sa[ETH_ALEN]; /* STA addr */
899 static void ieee80211_send_layer2_update(struct sta_info *sta)
901 struct iapp_layer2_update *msg;
904 /* Send Level 2 Update Frame to update forwarding tables in layer 2
907 skb = dev_alloc_skb(sizeof(*msg));
910 msg = (struct iapp_layer2_update *)skb_put(skb, sizeof(*msg));
912 /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID)
913 * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */
915 eth_broadcast_addr(msg->da);
916 memcpy(msg->sa, sta->sta.addr, ETH_ALEN);
919 msg->ssap = 0x01; /* NULL LSAP, CR Bit: Response */
920 msg->control = 0xaf; /* XID response lsb.1111F101.
921 * F=0 (no poll command; unsolicited frame) */
922 msg->xid_info[0] = 0x81; /* XID format identifier */
923 msg->xid_info[1] = 1; /* LLC types/classes: Type 1 LLC */
924 msg->xid_info[2] = 0; /* XID sender's receive window size (RW) */
926 skb->dev = sta->sdata->dev;
927 skb->protocol = eth_type_trans(skb, sta->sdata->dev);
928 memset(skb->cb, 0, sizeof(skb->cb));
932 static int sta_apply_auth_flags(struct ieee80211_local *local,
933 struct sta_info *sta,
938 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
939 set & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
940 !test_sta_flag(sta, WLAN_STA_AUTH)) {
941 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
946 if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
947 set & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
948 !test_sta_flag(sta, WLAN_STA_ASSOC)) {
949 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
954 if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
955 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED))
956 ret = sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED);
957 else if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
958 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
965 if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
966 !(set & BIT(NL80211_STA_FLAG_ASSOCIATED)) &&
967 test_sta_flag(sta, WLAN_STA_ASSOC)) {
968 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
973 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
974 !(set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) &&
975 test_sta_flag(sta, WLAN_STA_AUTH)) {
976 ret = sta_info_move_state(sta, IEEE80211_STA_NONE);
984 static int sta_apply_parameters(struct ieee80211_local *local,
985 struct sta_info *sta,
986 struct station_parameters *params)
989 struct ieee80211_supported_band *sband;
990 struct ieee80211_sub_if_data *sdata = sta->sdata;
991 enum ieee80211_band band = ieee80211_get_sdata_band(sdata);
994 sband = local->hw.wiphy->bands[band];
996 mask = params->sta_flags_mask;
997 set = params->sta_flags_set;
999 if (ieee80211_vif_is_mesh(&sdata->vif)) {
1001 * In mesh mode, ASSOCIATED isn't part of the nl80211
1002 * API but must follow AUTHENTICATED for driver state.
1004 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED))
1005 mask |= BIT(NL80211_STA_FLAG_ASSOCIATED);
1006 if (set & BIT(NL80211_STA_FLAG_AUTHENTICATED))
1007 set |= BIT(NL80211_STA_FLAG_ASSOCIATED);
1008 } else if (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
1010 * TDLS -- everything follows authorized, but
1011 * only becoming authorized is possible, not
1014 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
1015 set |= BIT(NL80211_STA_FLAG_AUTHENTICATED) |
1016 BIT(NL80211_STA_FLAG_ASSOCIATED);
1017 mask |= BIT(NL80211_STA_FLAG_AUTHENTICATED) |
1018 BIT(NL80211_STA_FLAG_ASSOCIATED);
1022 /* auth flags will be set later for TDLS stations */
1023 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
1024 ret = sta_apply_auth_flags(local, sta, mask, set);
1029 if (mask & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) {
1030 if (set & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE))
1031 set_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
1033 clear_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
1036 if (mask & BIT(NL80211_STA_FLAG_WME))
1037 sta->sta.wme = set & BIT(NL80211_STA_FLAG_WME);
1039 if (mask & BIT(NL80211_STA_FLAG_MFP)) {
1040 if (set & BIT(NL80211_STA_FLAG_MFP))
1041 set_sta_flag(sta, WLAN_STA_MFP);
1043 clear_sta_flag(sta, WLAN_STA_MFP);
1046 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
1047 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER))
1048 set_sta_flag(sta, WLAN_STA_TDLS_PEER);
1050 clear_sta_flag(sta, WLAN_STA_TDLS_PEER);
1053 /* mark TDLS channel switch support, if the AP allows it */
1054 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1055 !sdata->u.mgd.tdls_chan_switch_prohibited &&
1056 params->ext_capab_len >= 4 &&
1057 params->ext_capab[3] & WLAN_EXT_CAPA4_TDLS_CHAN_SWITCH)
1058 set_sta_flag(sta, WLAN_STA_TDLS_CHAN_SWITCH);
1060 if (params->sta_modify_mask & STATION_PARAM_APPLY_UAPSD) {
1061 sta->sta.uapsd_queues = params->uapsd_queues;
1062 sta->sta.max_sp = params->max_sp;
1066 * cfg80211 validates this (1-2007) and allows setting the AID
1067 * only when creating a new station entry
1070 sta->sta.aid = params->aid;
1073 * Some of the following updates would be racy if called on an
1074 * existing station, via ieee80211_change_station(). However,
1075 * all such changes are rejected by cfg80211 except for updates
1076 * changing the supported rates on an existing but not yet used
1080 if (params->listen_interval >= 0)
1081 sta->listen_interval = params->listen_interval;
1083 if (params->supported_rates) {
1084 ieee80211_parse_bitrates(&sdata->vif.bss_conf.chandef,
1085 sband, params->supported_rates,
1086 params->supported_rates_len,
1087 &sta->sta.supp_rates[band]);
1090 if (params->ht_capa)
1091 ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
1092 params->ht_capa, sta);
1094 if (params->vht_capa)
1095 ieee80211_vht_cap_ie_to_sta_vht_cap(sdata, sband,
1096 params->vht_capa, sta);
1098 if (params->opmode_notif_used) {
1099 /* returned value is only needed for rc update, but the
1100 * rc isn't initialized here yet, so ignore it
1102 __ieee80211_vht_handle_opmode(sdata, sta,
1103 params->opmode_notif,
1107 if (ieee80211_vif_is_mesh(&sdata->vif)) {
1108 #ifdef CONFIG_MAC80211_MESH
1111 if (params->sta_modify_mask & STATION_PARAM_APPLY_PLINK_STATE) {
1112 switch (params->plink_state) {
1113 case NL80211_PLINK_ESTAB:
1114 if (sta->plink_state != NL80211_PLINK_ESTAB)
1115 changed = mesh_plink_inc_estab_count(
1117 sta->plink_state = params->plink_state;
1119 ieee80211_mps_sta_status_update(sta);
1120 changed |= ieee80211_mps_set_sta_local_pm(sta,
1121 sdata->u.mesh.mshcfg.power_mode);
1123 case NL80211_PLINK_LISTEN:
1124 case NL80211_PLINK_BLOCKED:
1125 case NL80211_PLINK_OPN_SNT:
1126 case NL80211_PLINK_OPN_RCVD:
1127 case NL80211_PLINK_CNF_RCVD:
1128 case NL80211_PLINK_HOLDING:
1129 if (sta->plink_state == NL80211_PLINK_ESTAB)
1130 changed = mesh_plink_dec_estab_count(
1132 sta->plink_state = params->plink_state;
1134 ieee80211_mps_sta_status_update(sta);
1135 changed |= ieee80211_mps_set_sta_local_pm(sta,
1136 NL80211_MESH_POWER_UNKNOWN);
1144 switch (params->plink_action) {
1145 case NL80211_PLINK_ACTION_NO_ACTION:
1148 case NL80211_PLINK_ACTION_OPEN:
1149 changed |= mesh_plink_open(sta);
1151 case NL80211_PLINK_ACTION_BLOCK:
1152 changed |= mesh_plink_block(sta);
1156 if (params->local_pm)
1158 ieee80211_mps_set_sta_local_pm(sta,
1160 ieee80211_mbss_info_change_notify(sdata, changed);
1164 /* set the STA state after all sta info from usermode has been set */
1165 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
1166 ret = sta_apply_auth_flags(local, sta, mask, set);
1174 static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
1176 struct station_parameters *params)
1178 struct ieee80211_local *local = wiphy_priv(wiphy);
1179 struct sta_info *sta;
1180 struct ieee80211_sub_if_data *sdata;
1185 sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
1187 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
1188 sdata->vif.type != NL80211_IFTYPE_AP)
1191 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1193 if (ether_addr_equal(mac, sdata->vif.addr))
1196 if (is_multicast_ether_addr(mac))
1199 sta = sta_info_alloc(sdata, mac, GFP_KERNEL);
1204 * defaults -- if userspace wants something else we'll
1205 * change it accordingly in sta_apply_parameters()
1207 if (!(params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))) {
1208 sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
1209 sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
1211 sta->sta.tdls = true;
1214 err = sta_apply_parameters(local, sta, params);
1216 sta_info_free(local, sta);
1221 * for TDLS, rate control should be initialized only when
1222 * rates are known and station is marked authorized
1224 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER))
1225 rate_control_rate_init(sta);
1227 layer2_update = sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
1228 sdata->vif.type == NL80211_IFTYPE_AP;
1230 err = sta_info_insert_rcu(sta);
1237 ieee80211_send_layer2_update(sta);
1244 static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev,
1245 struct station_del_parameters *params)
1247 struct ieee80211_sub_if_data *sdata;
1249 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1252 return sta_info_destroy_addr_bss(sdata, params->mac);
1254 sta_info_flush(sdata);
1258 static int ieee80211_change_station(struct wiphy *wiphy,
1259 struct net_device *dev, const u8 *mac,
1260 struct station_parameters *params)
1262 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1263 struct ieee80211_local *local = wiphy_priv(wiphy);
1264 struct sta_info *sta;
1265 struct ieee80211_sub_if_data *vlansdata;
1266 enum cfg80211_station_type statype;
1269 mutex_lock(&local->sta_mtx);
1271 sta = sta_info_get_bss(sdata, mac);
1277 switch (sdata->vif.type) {
1278 case NL80211_IFTYPE_MESH_POINT:
1279 if (sdata->u.mesh.user_mpm)
1280 statype = CFG80211_STA_MESH_PEER_USER;
1282 statype = CFG80211_STA_MESH_PEER_KERNEL;
1284 case NL80211_IFTYPE_ADHOC:
1285 statype = CFG80211_STA_IBSS;
1287 case NL80211_IFTYPE_STATION:
1288 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
1289 statype = CFG80211_STA_AP_STA;
1292 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
1293 statype = CFG80211_STA_TDLS_PEER_ACTIVE;
1295 statype = CFG80211_STA_TDLS_PEER_SETUP;
1297 case NL80211_IFTYPE_AP:
1298 case NL80211_IFTYPE_AP_VLAN:
1299 statype = CFG80211_STA_AP_CLIENT;
1306 err = cfg80211_check_station_change(wiphy, params, statype);
1310 if (params->vlan && params->vlan != sta->sdata->dev) {
1311 bool prev_4addr = false;
1312 bool new_4addr = false;
1314 vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
1316 if (params->vlan->ieee80211_ptr->use_4addr) {
1317 if (vlansdata->u.vlan.sta) {
1322 rcu_assign_pointer(vlansdata->u.vlan.sta, sta);
1326 if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
1327 sta->sdata->u.vlan.sta) {
1328 RCU_INIT_POINTER(sta->sdata->u.vlan.sta, NULL);
1332 sta->sdata = vlansdata;
1334 if (sta->sta_state == IEEE80211_STA_AUTHORIZED &&
1335 prev_4addr != new_4addr) {
1337 atomic_dec(&sta->sdata->bss->num_mcast_sta);
1339 atomic_inc(&sta->sdata->bss->num_mcast_sta);
1342 ieee80211_send_layer2_update(sta);
1345 err = sta_apply_parameters(local, sta, params);
1349 /* When peer becomes authorized, init rate control as well */
1350 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
1351 test_sta_flag(sta, WLAN_STA_AUTHORIZED))
1352 rate_control_rate_init(sta);
1354 mutex_unlock(&local->sta_mtx);
1356 if ((sdata->vif.type == NL80211_IFTYPE_AP ||
1357 sdata->vif.type == NL80211_IFTYPE_AP_VLAN) &&
1358 sta->known_smps_mode != sta->sdata->bss->req_smps &&
1359 test_sta_flag(sta, WLAN_STA_AUTHORIZED) &&
1360 sta_info_tx_streams(sta) != 1) {
1362 "%pM just authorized and MIMO capable - update SMPS\n",
1364 ieee80211_send_smps_action(sta->sdata,
1365 sta->sdata->bss->req_smps,
1367 sta->sdata->vif.bss_conf.bssid);
1370 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
1371 params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
1372 ieee80211_recalc_ps(local, -1);
1373 ieee80211_recalc_ps_vif(sdata);
1378 mutex_unlock(&local->sta_mtx);
1382 #ifdef CONFIG_MAC80211_MESH
1383 static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev,
1384 const u8 *dst, const u8 *next_hop)
1386 struct ieee80211_sub_if_data *sdata;
1387 struct mesh_path *mpath;
1388 struct sta_info *sta;
1390 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1393 sta = sta_info_get(sdata, next_hop);
1399 mpath = mesh_path_add(sdata, dst);
1400 if (IS_ERR(mpath)) {
1402 return PTR_ERR(mpath);
1405 mesh_path_fix_nexthop(mpath, sta);
1411 static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev,
1414 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1417 return mesh_path_del(sdata, dst);
1419 mesh_path_flush_by_iface(sdata);
1423 static int ieee80211_change_mpath(struct wiphy *wiphy, struct net_device *dev,
1424 const u8 *dst, const u8 *next_hop)
1426 struct ieee80211_sub_if_data *sdata;
1427 struct mesh_path *mpath;
1428 struct sta_info *sta;
1430 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1434 sta = sta_info_get(sdata, next_hop);
1440 mpath = mesh_path_lookup(sdata, dst);
1446 mesh_path_fix_nexthop(mpath, sta);
1452 static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop,
1453 struct mpath_info *pinfo)
1455 struct sta_info *next_hop_sta = rcu_dereference(mpath->next_hop);
1458 memcpy(next_hop, next_hop_sta->sta.addr, ETH_ALEN);
1460 memset(next_hop, 0, ETH_ALEN);
1462 memset(pinfo, 0, sizeof(*pinfo));
1464 pinfo->generation = mesh_paths_generation;
1466 pinfo->filled = MPATH_INFO_FRAME_QLEN |
1469 MPATH_INFO_EXPTIME |
1470 MPATH_INFO_DISCOVERY_TIMEOUT |
1471 MPATH_INFO_DISCOVERY_RETRIES |
1474 pinfo->frame_qlen = mpath->frame_queue.qlen;
1475 pinfo->sn = mpath->sn;
1476 pinfo->metric = mpath->metric;
1477 if (time_before(jiffies, mpath->exp_time))
1478 pinfo->exptime = jiffies_to_msecs(mpath->exp_time - jiffies);
1479 pinfo->discovery_timeout =
1480 jiffies_to_msecs(mpath->discovery_timeout);
1481 pinfo->discovery_retries = mpath->discovery_retries;
1482 if (mpath->flags & MESH_PATH_ACTIVE)
1483 pinfo->flags |= NL80211_MPATH_FLAG_ACTIVE;
1484 if (mpath->flags & MESH_PATH_RESOLVING)
1485 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING;
1486 if (mpath->flags & MESH_PATH_SN_VALID)
1487 pinfo->flags |= NL80211_MPATH_FLAG_SN_VALID;
1488 if (mpath->flags & MESH_PATH_FIXED)
1489 pinfo->flags |= NL80211_MPATH_FLAG_FIXED;
1490 if (mpath->flags & MESH_PATH_RESOLVED)
1491 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVED;
1494 static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev,
1495 u8 *dst, u8 *next_hop, struct mpath_info *pinfo)
1498 struct ieee80211_sub_if_data *sdata;
1499 struct mesh_path *mpath;
1501 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1504 mpath = mesh_path_lookup(sdata, dst);
1509 memcpy(dst, mpath->dst, ETH_ALEN);
1510 mpath_set_pinfo(mpath, next_hop, pinfo);
1515 static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev,
1516 int idx, u8 *dst, u8 *next_hop,
1517 struct mpath_info *pinfo)
1519 struct ieee80211_sub_if_data *sdata;
1520 struct mesh_path *mpath;
1522 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1525 mpath = mesh_path_lookup_by_idx(sdata, idx);
1530 memcpy(dst, mpath->dst, ETH_ALEN);
1531 mpath_set_pinfo(mpath, next_hop, pinfo);
1536 static void mpp_set_pinfo(struct mesh_path *mpath, u8 *mpp,
1537 struct mpath_info *pinfo)
1539 memset(pinfo, 0, sizeof(*pinfo));
1540 memcpy(mpp, mpath->mpp, ETH_ALEN);
1542 pinfo->generation = mpp_paths_generation;
1545 static int ieee80211_get_mpp(struct wiphy *wiphy, struct net_device *dev,
1546 u8 *dst, u8 *mpp, struct mpath_info *pinfo)
1549 struct ieee80211_sub_if_data *sdata;
1550 struct mesh_path *mpath;
1552 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1555 mpath = mpp_path_lookup(sdata, dst);
1560 memcpy(dst, mpath->dst, ETH_ALEN);
1561 mpp_set_pinfo(mpath, mpp, pinfo);
1566 static int ieee80211_dump_mpp(struct wiphy *wiphy, struct net_device *dev,
1567 int idx, u8 *dst, u8 *mpp,
1568 struct mpath_info *pinfo)
1570 struct ieee80211_sub_if_data *sdata;
1571 struct mesh_path *mpath;
1573 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1576 mpath = mpp_path_lookup_by_idx(sdata, idx);
1581 memcpy(dst, mpath->dst, ETH_ALEN);
1582 mpp_set_pinfo(mpath, mpp, pinfo);
1587 static int ieee80211_get_mesh_config(struct wiphy *wiphy,
1588 struct net_device *dev,
1589 struct mesh_config *conf)
1591 struct ieee80211_sub_if_data *sdata;
1592 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1594 memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config));
1598 static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask)
1600 return (mask >> (parm-1)) & 0x1;
1603 static int copy_mesh_setup(struct ieee80211_if_mesh *ifmsh,
1604 const struct mesh_setup *setup)
1608 struct ieee80211_sub_if_data *sdata = container_of(ifmsh,
1609 struct ieee80211_sub_if_data, u.mesh);
1611 /* allocate information elements */
1615 if (setup->ie_len) {
1616 new_ie = kmemdup(setup->ie, setup->ie_len,
1621 ifmsh->ie_len = setup->ie_len;
1625 /* now copy the rest of the setup parameters */
1626 ifmsh->mesh_id_len = setup->mesh_id_len;
1627 memcpy(ifmsh->mesh_id, setup->mesh_id, ifmsh->mesh_id_len);
1628 ifmsh->mesh_sp_id = setup->sync_method;
1629 ifmsh->mesh_pp_id = setup->path_sel_proto;
1630 ifmsh->mesh_pm_id = setup->path_metric;
1631 ifmsh->user_mpm = setup->user_mpm;
1632 ifmsh->mesh_auth_id = setup->auth_id;
1633 ifmsh->security = IEEE80211_MESH_SEC_NONE;
1634 if (setup->is_authenticated)
1635 ifmsh->security |= IEEE80211_MESH_SEC_AUTHED;
1636 if (setup->is_secure)
1637 ifmsh->security |= IEEE80211_MESH_SEC_SECURED;
1639 /* mcast rate setting in Mesh Node */
1640 memcpy(sdata->vif.bss_conf.mcast_rate, setup->mcast_rate,
1641 sizeof(setup->mcast_rate));
1642 sdata->vif.bss_conf.basic_rates = setup->basic_rates;
1644 sdata->vif.bss_conf.beacon_int = setup->beacon_interval;
1645 sdata->vif.bss_conf.dtim_period = setup->dtim_period;
1650 static int ieee80211_update_mesh_config(struct wiphy *wiphy,
1651 struct net_device *dev, u32 mask,
1652 const struct mesh_config *nconf)
1654 struct mesh_config *conf;
1655 struct ieee80211_sub_if_data *sdata;
1656 struct ieee80211_if_mesh *ifmsh;
1658 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1659 ifmsh = &sdata->u.mesh;
1661 /* Set the config options which we are interested in setting */
1662 conf = &(sdata->u.mesh.mshcfg);
1663 if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask))
1664 conf->dot11MeshRetryTimeout = nconf->dot11MeshRetryTimeout;
1665 if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT, mask))
1666 conf->dot11MeshConfirmTimeout = nconf->dot11MeshConfirmTimeout;
1667 if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT, mask))
1668 conf->dot11MeshHoldingTimeout = nconf->dot11MeshHoldingTimeout;
1669 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS, mask))
1670 conf->dot11MeshMaxPeerLinks = nconf->dot11MeshMaxPeerLinks;
1671 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES, mask))
1672 conf->dot11MeshMaxRetries = nconf->dot11MeshMaxRetries;
1673 if (_chg_mesh_attr(NL80211_MESHCONF_TTL, mask))
1674 conf->dot11MeshTTL = nconf->dot11MeshTTL;
1675 if (_chg_mesh_attr(NL80211_MESHCONF_ELEMENT_TTL, mask))
1676 conf->element_ttl = nconf->element_ttl;
1677 if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask)) {
1678 if (ifmsh->user_mpm)
1680 conf->auto_open_plinks = nconf->auto_open_plinks;
1682 if (_chg_mesh_attr(NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR, mask))
1683 conf->dot11MeshNbrOffsetMaxNeighbor =
1684 nconf->dot11MeshNbrOffsetMaxNeighbor;
1685 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, mask))
1686 conf->dot11MeshHWMPmaxPREQretries =
1687 nconf->dot11MeshHWMPmaxPREQretries;
1688 if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME, mask))
1689 conf->path_refresh_time = nconf->path_refresh_time;
1690 if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, mask))
1691 conf->min_discovery_timeout = nconf->min_discovery_timeout;
1692 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, mask))
1693 conf->dot11MeshHWMPactivePathTimeout =
1694 nconf->dot11MeshHWMPactivePathTimeout;
1695 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, mask))
1696 conf->dot11MeshHWMPpreqMinInterval =
1697 nconf->dot11MeshHWMPpreqMinInterval;
1698 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL, mask))
1699 conf->dot11MeshHWMPperrMinInterval =
1700 nconf->dot11MeshHWMPperrMinInterval;
1701 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
1703 conf->dot11MeshHWMPnetDiameterTraversalTime =
1704 nconf->dot11MeshHWMPnetDiameterTraversalTime;
1705 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOTMODE, mask)) {
1706 conf->dot11MeshHWMPRootMode = nconf->dot11MeshHWMPRootMode;
1707 ieee80211_mesh_root_setup(ifmsh);
1709 if (_chg_mesh_attr(NL80211_MESHCONF_GATE_ANNOUNCEMENTS, mask)) {
1710 /* our current gate announcement implementation rides on root
1711 * announcements, so require this ifmsh to also be a root node
1713 if (nconf->dot11MeshGateAnnouncementProtocol &&
1714 !(conf->dot11MeshHWMPRootMode > IEEE80211_ROOTMODE_ROOT)) {
1715 conf->dot11MeshHWMPRootMode = IEEE80211_PROACTIVE_RANN;
1716 ieee80211_mesh_root_setup(ifmsh);
1718 conf->dot11MeshGateAnnouncementProtocol =
1719 nconf->dot11MeshGateAnnouncementProtocol;
1721 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_RANN_INTERVAL, mask))
1722 conf->dot11MeshHWMPRannInterval =
1723 nconf->dot11MeshHWMPRannInterval;
1724 if (_chg_mesh_attr(NL80211_MESHCONF_FORWARDING, mask))
1725 conf->dot11MeshForwarding = nconf->dot11MeshForwarding;
1726 if (_chg_mesh_attr(NL80211_MESHCONF_RSSI_THRESHOLD, mask)) {
1727 /* our RSSI threshold implementation is supported only for
1728 * devices that report signal in dBm.
1730 if (!(sdata->local->hw.flags & IEEE80211_HW_SIGNAL_DBM))
1732 conf->rssi_threshold = nconf->rssi_threshold;
1734 if (_chg_mesh_attr(NL80211_MESHCONF_HT_OPMODE, mask)) {
1735 conf->ht_opmode = nconf->ht_opmode;
1736 sdata->vif.bss_conf.ht_operation_mode = nconf->ht_opmode;
1737 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_HT);
1739 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT, mask))
1740 conf->dot11MeshHWMPactivePathToRootTimeout =
1741 nconf->dot11MeshHWMPactivePathToRootTimeout;
1742 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOT_INTERVAL, mask))
1743 conf->dot11MeshHWMProotInterval =
1744 nconf->dot11MeshHWMProotInterval;
1745 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL, mask))
1746 conf->dot11MeshHWMPconfirmationInterval =
1747 nconf->dot11MeshHWMPconfirmationInterval;
1748 if (_chg_mesh_attr(NL80211_MESHCONF_POWER_MODE, mask)) {
1749 conf->power_mode = nconf->power_mode;
1750 ieee80211_mps_local_status_update(sdata);
1752 if (_chg_mesh_attr(NL80211_MESHCONF_AWAKE_WINDOW, mask))
1753 conf->dot11MeshAwakeWindowDuration =
1754 nconf->dot11MeshAwakeWindowDuration;
1755 if (_chg_mesh_attr(NL80211_MESHCONF_PLINK_TIMEOUT, mask))
1756 conf->plink_timeout = nconf->plink_timeout;
1757 ieee80211_mbss_info_change_notify(sdata, BSS_CHANGED_BEACON);
1761 static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev,
1762 const struct mesh_config *conf,
1763 const struct mesh_setup *setup)
1765 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1766 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
1769 memcpy(&ifmsh->mshcfg, conf, sizeof(struct mesh_config));
1770 err = copy_mesh_setup(ifmsh, setup);
1774 /* can mesh use other SMPS modes? */
1775 sdata->smps_mode = IEEE80211_SMPS_OFF;
1776 sdata->needed_rx_chains = sdata->local->rx_chains;
1778 mutex_lock(&sdata->local->mtx);
1779 err = ieee80211_vif_use_channel(sdata, &setup->chandef,
1780 IEEE80211_CHANCTX_SHARED);
1781 mutex_unlock(&sdata->local->mtx);
1785 return ieee80211_start_mesh(sdata);
1788 static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev)
1790 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1792 ieee80211_stop_mesh(sdata);
1793 mutex_lock(&sdata->local->mtx);
1794 ieee80211_vif_release_channel(sdata);
1795 mutex_unlock(&sdata->local->mtx);
1801 static int ieee80211_change_bss(struct wiphy *wiphy,
1802 struct net_device *dev,
1803 struct bss_parameters *params)
1805 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1806 enum ieee80211_band band;
1809 if (!sdata_dereference(sdata->u.ap.beacon, sdata))
1812 band = ieee80211_get_sdata_band(sdata);
1814 if (params->use_cts_prot >= 0) {
1815 sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot;
1816 changed |= BSS_CHANGED_ERP_CTS_PROT;
1818 if (params->use_short_preamble >= 0) {
1819 sdata->vif.bss_conf.use_short_preamble =
1820 params->use_short_preamble;
1821 changed |= BSS_CHANGED_ERP_PREAMBLE;
1824 if (!sdata->vif.bss_conf.use_short_slot &&
1825 band == IEEE80211_BAND_5GHZ) {
1826 sdata->vif.bss_conf.use_short_slot = true;
1827 changed |= BSS_CHANGED_ERP_SLOT;
1830 if (params->use_short_slot_time >= 0) {
1831 sdata->vif.bss_conf.use_short_slot =
1832 params->use_short_slot_time;
1833 changed |= BSS_CHANGED_ERP_SLOT;
1836 if (params->basic_rates) {
1837 ieee80211_parse_bitrates(&sdata->vif.bss_conf.chandef,
1839 params->basic_rates,
1840 params->basic_rates_len,
1841 &sdata->vif.bss_conf.basic_rates);
1842 changed |= BSS_CHANGED_BASIC_RATES;
1845 if (params->ap_isolate >= 0) {
1846 if (params->ap_isolate)
1847 sdata->flags |= IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
1849 sdata->flags &= ~IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
1852 if (params->ht_opmode >= 0) {
1853 sdata->vif.bss_conf.ht_operation_mode =
1854 (u16) params->ht_opmode;
1855 changed |= BSS_CHANGED_HT;
1858 if (params->p2p_ctwindow >= 0) {
1859 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow &=
1860 ~IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
1861 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |=
1862 params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
1863 changed |= BSS_CHANGED_P2P_PS;
1866 if (params->p2p_opp_ps > 0) {
1867 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |=
1868 IEEE80211_P2P_OPPPS_ENABLE_BIT;
1869 changed |= BSS_CHANGED_P2P_PS;
1870 } else if (params->p2p_opp_ps == 0) {
1871 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow &=
1872 ~IEEE80211_P2P_OPPPS_ENABLE_BIT;
1873 changed |= BSS_CHANGED_P2P_PS;
1876 ieee80211_bss_info_change_notify(sdata, changed);
1881 static int ieee80211_set_txq_params(struct wiphy *wiphy,
1882 struct net_device *dev,
1883 struct ieee80211_txq_params *params)
1885 struct ieee80211_local *local = wiphy_priv(wiphy);
1886 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1887 struct ieee80211_tx_queue_params p;
1889 if (!local->ops->conf_tx)
1892 if (local->hw.queues < IEEE80211_NUM_ACS)
1895 memset(&p, 0, sizeof(p));
1896 p.aifs = params->aifs;
1897 p.cw_max = params->cwmax;
1898 p.cw_min = params->cwmin;
1899 p.txop = params->txop;
1902 * Setting tx queue params disables u-apsd because it's only
1903 * called in master mode.
1907 sdata->tx_conf[params->ac] = p;
1908 if (drv_conf_tx(local, sdata, params->ac, &p)) {
1909 wiphy_debug(local->hw.wiphy,
1910 "failed to set TX queue parameters for AC %d\n",
1915 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_QOS);
1921 static int ieee80211_suspend(struct wiphy *wiphy,
1922 struct cfg80211_wowlan *wowlan)
1924 return __ieee80211_suspend(wiphy_priv(wiphy), wowlan);
1927 static int ieee80211_resume(struct wiphy *wiphy)
1929 return __ieee80211_resume(wiphy_priv(wiphy));
1932 #define ieee80211_suspend NULL
1933 #define ieee80211_resume NULL
1936 static int ieee80211_scan(struct wiphy *wiphy,
1937 struct cfg80211_scan_request *req)
1939 struct ieee80211_sub_if_data *sdata;
1941 sdata = IEEE80211_WDEV_TO_SUB_IF(req->wdev);
1943 switch (ieee80211_vif_type_p2p(&sdata->vif)) {
1944 case NL80211_IFTYPE_STATION:
1945 case NL80211_IFTYPE_ADHOC:
1946 case NL80211_IFTYPE_MESH_POINT:
1947 case NL80211_IFTYPE_P2P_CLIENT:
1948 case NL80211_IFTYPE_P2P_DEVICE:
1950 case NL80211_IFTYPE_P2P_GO:
1951 if (sdata->local->ops->hw_scan)
1954 * FIXME: implement NoA while scanning in software,
1955 * for now fall through to allow scanning only when
1956 * beaconing hasn't been configured yet
1958 case NL80211_IFTYPE_AP:
1960 * If the scan has been forced (and the driver supports
1961 * forcing), don't care about being beaconing already.
1962 * This will create problems to the attached stations (e.g. all
1963 * the frames sent while scanning on other channel will be
1966 if (sdata->u.ap.beacon &&
1967 (!(wiphy->features & NL80211_FEATURE_AP_SCAN) ||
1968 !(req->flags & NL80211_SCAN_FLAG_AP)))
1975 return ieee80211_request_scan(sdata, req);
1979 ieee80211_sched_scan_start(struct wiphy *wiphy,
1980 struct net_device *dev,
1981 struct cfg80211_sched_scan_request *req)
1983 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1985 if (!sdata->local->ops->sched_scan_start)
1988 return ieee80211_request_sched_scan_start(sdata, req);
1992 ieee80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev)
1994 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1996 if (!sdata->local->ops->sched_scan_stop)
1999 return ieee80211_request_sched_scan_stop(sdata);
2002 static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev,
2003 struct cfg80211_auth_request *req)
2005 return ieee80211_mgd_auth(IEEE80211_DEV_TO_SUB_IF(dev), req);
2008 static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev,
2009 struct cfg80211_assoc_request *req)
2011 return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
2014 static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev,
2015 struct cfg80211_deauth_request *req)
2017 return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev), req);
2020 static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
2021 struct cfg80211_disassoc_request *req)
2023 return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
2026 static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
2027 struct cfg80211_ibss_params *params)
2029 return ieee80211_ibss_join(IEEE80211_DEV_TO_SUB_IF(dev), params);
2032 static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
2034 return ieee80211_ibss_leave(IEEE80211_DEV_TO_SUB_IF(dev));
2037 static int ieee80211_join_ocb(struct wiphy *wiphy, struct net_device *dev,
2038 struct ocb_setup *setup)
2040 return ieee80211_ocb_join(IEEE80211_DEV_TO_SUB_IF(dev), setup);
2043 static int ieee80211_leave_ocb(struct wiphy *wiphy, struct net_device *dev)
2045 return ieee80211_ocb_leave(IEEE80211_DEV_TO_SUB_IF(dev));
2048 static int ieee80211_set_mcast_rate(struct wiphy *wiphy, struct net_device *dev,
2049 int rate[IEEE80211_NUM_BANDS])
2051 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2053 memcpy(sdata->vif.bss_conf.mcast_rate, rate,
2054 sizeof(int) * IEEE80211_NUM_BANDS);
2059 static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
2061 struct ieee80211_local *local = wiphy_priv(wiphy);
2064 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
2065 err = drv_set_frag_threshold(local, wiphy->frag_threshold);
2071 if ((changed & WIPHY_PARAM_COVERAGE_CLASS) ||
2072 (changed & WIPHY_PARAM_DYN_ACK)) {
2075 coverage_class = changed & WIPHY_PARAM_COVERAGE_CLASS ?
2076 wiphy->coverage_class : -1;
2077 err = drv_set_coverage_class(local, coverage_class);
2083 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
2084 err = drv_set_rts_threshold(local, wiphy->rts_threshold);
2090 if (changed & WIPHY_PARAM_RETRY_SHORT) {
2091 if (wiphy->retry_short > IEEE80211_MAX_TX_RETRY)
2093 local->hw.conf.short_frame_max_tx_count = wiphy->retry_short;
2095 if (changed & WIPHY_PARAM_RETRY_LONG) {
2096 if (wiphy->retry_long > IEEE80211_MAX_TX_RETRY)
2098 local->hw.conf.long_frame_max_tx_count = wiphy->retry_long;
2101 (WIPHY_PARAM_RETRY_SHORT | WIPHY_PARAM_RETRY_LONG))
2102 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS);
2107 static int ieee80211_set_tx_power(struct wiphy *wiphy,
2108 struct wireless_dev *wdev,
2109 enum nl80211_tx_power_setting type, int mbm)
2111 struct ieee80211_local *local = wiphy_priv(wiphy);
2112 struct ieee80211_sub_if_data *sdata;
2115 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
2118 case NL80211_TX_POWER_AUTOMATIC:
2119 sdata->user_power_level = IEEE80211_UNSET_POWER_LEVEL;
2121 case NL80211_TX_POWER_LIMITED:
2122 case NL80211_TX_POWER_FIXED:
2123 if (mbm < 0 || (mbm % 100))
2125 sdata->user_power_level = MBM_TO_DBM(mbm);
2129 ieee80211_recalc_txpower(sdata);
2135 case NL80211_TX_POWER_AUTOMATIC:
2136 local->user_power_level = IEEE80211_UNSET_POWER_LEVEL;
2138 case NL80211_TX_POWER_LIMITED:
2139 case NL80211_TX_POWER_FIXED:
2140 if (mbm < 0 || (mbm % 100))
2142 local->user_power_level = MBM_TO_DBM(mbm);
2146 mutex_lock(&local->iflist_mtx);
2147 list_for_each_entry(sdata, &local->interfaces, list)
2148 sdata->user_power_level = local->user_power_level;
2149 list_for_each_entry(sdata, &local->interfaces, list)
2150 ieee80211_recalc_txpower(sdata);
2151 mutex_unlock(&local->iflist_mtx);
2156 static int ieee80211_get_tx_power(struct wiphy *wiphy,
2157 struct wireless_dev *wdev,
2160 struct ieee80211_local *local = wiphy_priv(wiphy);
2161 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
2163 if (local->ops->get_txpower)
2164 return drv_get_txpower(local, sdata, dbm);
2166 if (!local->use_chanctx)
2167 *dbm = local->hw.conf.power_level;
2169 *dbm = sdata->vif.bss_conf.txpower;
2174 static int ieee80211_set_wds_peer(struct wiphy *wiphy, struct net_device *dev,
2177 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2179 memcpy(&sdata->u.wds.remote_addr, addr, ETH_ALEN);
2184 static void ieee80211_rfkill_poll(struct wiphy *wiphy)
2186 struct ieee80211_local *local = wiphy_priv(wiphy);
2188 drv_rfkill_poll(local);
2191 #ifdef CONFIG_NL80211_TESTMODE
2192 static int ieee80211_testmode_cmd(struct wiphy *wiphy,
2193 struct wireless_dev *wdev,
2194 void *data, int len)
2196 struct ieee80211_local *local = wiphy_priv(wiphy);
2197 struct ieee80211_vif *vif = NULL;
2199 if (!local->ops->testmode_cmd)
2203 struct ieee80211_sub_if_data *sdata;
2205 sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
2206 if (sdata->flags & IEEE80211_SDATA_IN_DRIVER)
2210 return local->ops->testmode_cmd(&local->hw, vif, data, len);
2213 static int ieee80211_testmode_dump(struct wiphy *wiphy,
2214 struct sk_buff *skb,
2215 struct netlink_callback *cb,
2216 void *data, int len)
2218 struct ieee80211_local *local = wiphy_priv(wiphy);
2220 if (!local->ops->testmode_dump)
2223 return local->ops->testmode_dump(&local->hw, skb, cb, data, len);
2227 int __ieee80211_request_smps_ap(struct ieee80211_sub_if_data *sdata,
2228 enum ieee80211_smps_mode smps_mode)
2230 struct sta_info *sta;
2231 enum ieee80211_smps_mode old_req;
2234 if (WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_AP))
2237 if (sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT)
2240 old_req = sdata->u.ap.req_smps;
2241 sdata->u.ap.req_smps = smps_mode;
2243 /* AUTOMATIC doesn't mean much for AP - don't allow it */
2244 if (old_req == smps_mode ||
2245 smps_mode == IEEE80211_SMPS_AUTOMATIC)
2248 /* If no associated stations, there's no need to do anything */
2249 if (!atomic_read(&sdata->u.ap.num_mcast_sta)) {
2250 sdata->smps_mode = smps_mode;
2251 ieee80211_queue_work(&sdata->local->hw, &sdata->recalc_smps);
2256 "SMSP %d requested in AP mode, sending Action frame to %d stations\n",
2257 smps_mode, atomic_read(&sdata->u.ap.num_mcast_sta));
2259 mutex_lock(&sdata->local->sta_mtx);
2260 for (i = 0; i < STA_HASH_SIZE; i++) {
2261 for (sta = rcu_dereference_protected(sdata->local->sta_hash[i],
2262 lockdep_is_held(&sdata->local->sta_mtx));
2264 sta = rcu_dereference_protected(sta->hnext,
2265 lockdep_is_held(&sdata->local->sta_mtx))) {
2267 * Only stations associated to our AP and
2270 if (sta->sdata->bss != &sdata->u.ap)
2273 /* This station doesn't support MIMO - skip it */
2274 if (sta_info_tx_streams(sta) == 1)
2278 * Don't wake up a STA just to send the action frame
2279 * unless we are getting more restrictive.
2281 if (test_sta_flag(sta, WLAN_STA_PS_STA) &&
2282 !ieee80211_smps_is_restrictive(sta->known_smps_mode,
2285 "Won't send SMPS to sleeping STA %pM\n",
2291 * If the STA is not authorized, wait until it gets
2292 * authorized and the action frame will be sent then.
2294 if (!test_sta_flag(sta, WLAN_STA_AUTHORIZED))
2297 ht_dbg(sdata, "Sending SMPS to %pM\n", sta->sta.addr);
2298 ieee80211_send_smps_action(sdata, smps_mode,
2300 sdata->vif.bss_conf.bssid);
2303 mutex_unlock(&sdata->local->sta_mtx);
2305 sdata->smps_mode = smps_mode;
2306 ieee80211_queue_work(&sdata->local->hw, &sdata->recalc_smps);
2311 int __ieee80211_request_smps_mgd(struct ieee80211_sub_if_data *sdata,
2312 enum ieee80211_smps_mode smps_mode)
2315 enum ieee80211_smps_mode old_req;
2318 lockdep_assert_held(&sdata->wdev.mtx);
2320 if (WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION))
2323 old_req = sdata->u.mgd.req_smps;
2324 sdata->u.mgd.req_smps = smps_mode;
2326 if (old_req == smps_mode &&
2327 smps_mode != IEEE80211_SMPS_AUTOMATIC)
2331 * If not associated, or current association is not an HT
2332 * association, there's no need to do anything, just store
2333 * the new value until we associate.
2335 if (!sdata->u.mgd.associated ||
2336 sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT)
2339 ap = sdata->u.mgd.associated->bssid;
2341 if (smps_mode == IEEE80211_SMPS_AUTOMATIC) {
2342 if (sdata->u.mgd.powersave)
2343 smps_mode = IEEE80211_SMPS_DYNAMIC;
2345 smps_mode = IEEE80211_SMPS_OFF;
2348 /* send SM PS frame to AP */
2349 err = ieee80211_send_smps_action(sdata, smps_mode,
2352 sdata->u.mgd.req_smps = old_req;
2357 static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
2358 bool enabled, int timeout)
2360 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2361 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2363 if (sdata->vif.type != NL80211_IFTYPE_STATION)
2366 if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS))
2369 if (enabled == sdata->u.mgd.powersave &&
2370 timeout == local->dynamic_ps_forced_timeout)
2373 sdata->u.mgd.powersave = enabled;
2374 local->dynamic_ps_forced_timeout = timeout;
2376 /* no change, but if automatic follow powersave */
2378 __ieee80211_request_smps_mgd(sdata, sdata->u.mgd.req_smps);
2379 sdata_unlock(sdata);
2381 if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS)
2382 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
2384 ieee80211_recalc_ps(local, -1);
2385 ieee80211_recalc_ps_vif(sdata);
2390 static int ieee80211_set_cqm_rssi_config(struct wiphy *wiphy,
2391 struct net_device *dev,
2392 s32 rssi_thold, u32 rssi_hyst)
2394 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2395 struct ieee80211_vif *vif = &sdata->vif;
2396 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
2398 if (rssi_thold == bss_conf->cqm_rssi_thold &&
2399 rssi_hyst == bss_conf->cqm_rssi_hyst)
2402 bss_conf->cqm_rssi_thold = rssi_thold;
2403 bss_conf->cqm_rssi_hyst = rssi_hyst;
2405 /* tell the driver upon association, unless already associated */
2406 if (sdata->u.mgd.associated &&
2407 sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)
2408 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_CQM);
2413 static int ieee80211_set_bitrate_mask(struct wiphy *wiphy,
2414 struct net_device *dev,
2416 const struct cfg80211_bitrate_mask *mask)
2418 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2419 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2422 if (!ieee80211_sdata_running(sdata))
2425 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
2426 ret = drv_set_bitrate_mask(local, sdata, mask);
2431 for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
2432 struct ieee80211_supported_band *sband = wiphy->bands[i];
2435 sdata->rc_rateidx_mask[i] = mask->control[i].legacy;
2436 memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].ht_mcs,
2437 sizeof(mask->control[i].ht_mcs));
2439 sdata->rc_has_mcs_mask[i] = false;
2443 for (j = 0; j < IEEE80211_HT_MCS_MASK_LEN; j++)
2444 if (~sdata->rc_rateidx_mcs_mask[i][j]) {
2445 sdata->rc_has_mcs_mask[i] = true;
2453 static bool ieee80211_coalesce_started_roc(struct ieee80211_local *local,
2454 struct ieee80211_roc_work *new_roc,
2455 struct ieee80211_roc_work *cur_roc)
2457 unsigned long j = jiffies;
2458 unsigned long cur_roc_end = cur_roc->hw_start_time +
2459 msecs_to_jiffies(cur_roc->duration);
2460 struct ieee80211_roc_work *next_roc;
2463 if (WARN_ON(!cur_roc->started || !cur_roc->hw_begun))
2466 if (time_after(j + IEEE80211_ROC_MIN_LEFT, cur_roc_end))
2469 ieee80211_handle_roc_started(new_roc);
2471 new_dur = new_roc->duration - jiffies_to_msecs(cur_roc_end - j);
2473 /* cur_roc is long enough - add new_roc to the dependents list. */
2475 list_add_tail(&new_roc->list, &cur_roc->dependents);
2479 new_roc->duration = new_dur;
2482 * if cur_roc was already coalesced before, we might
2483 * want to extend the next roc instead of adding
2486 next_roc = list_entry(cur_roc->list.next,
2487 struct ieee80211_roc_work, list);
2488 if (&next_roc->list != &local->roc_list &&
2489 next_roc->chan == new_roc->chan &&
2490 next_roc->sdata == new_roc->sdata &&
2491 !WARN_ON(next_roc->started)) {
2492 list_add_tail(&new_roc->list, &next_roc->dependents);
2493 next_roc->duration = max(next_roc->duration,
2495 next_roc->type = max(next_roc->type, new_roc->type);
2499 /* add right after cur_roc */
2500 list_add(&new_roc->list, &cur_roc->list);
2505 static int ieee80211_start_roc_work(struct ieee80211_local *local,
2506 struct ieee80211_sub_if_data *sdata,
2507 struct ieee80211_channel *channel,
2508 unsigned int duration, u64 *cookie,
2509 struct sk_buff *txskb,
2510 enum ieee80211_roc_type type)
2512 struct ieee80211_roc_work *roc, *tmp;
2513 bool queued = false;
2516 lockdep_assert_held(&local->mtx);
2518 if (local->use_chanctx && !local->ops->remain_on_channel)
2521 roc = kzalloc(sizeof(*roc), GFP_KERNEL);
2526 * If the duration is zero, then the driver
2527 * wouldn't actually do anything. Set it to
2530 * TODO: cancel the off-channel operation
2531 * when we get the SKB's TX status and
2532 * the wait time was zero before.
2537 roc->chan = channel;
2538 roc->duration = duration;
2539 roc->req_duration = duration;
2542 roc->mgmt_tx_cookie = (unsigned long)txskb;
2544 INIT_DELAYED_WORK(&roc->work, ieee80211_sw_roc_work);
2545 INIT_LIST_HEAD(&roc->dependents);
2548 * cookie is either the roc cookie (for normal roc)
2549 * or the SKB (for mgmt TX)
2552 /* local->mtx protects this */
2553 local->roc_cookie_counter++;
2554 roc->cookie = local->roc_cookie_counter;
2555 /* wow, you wrapped 64 bits ... more likely a bug */
2556 if (WARN_ON(roc->cookie == 0)) {
2558 local->roc_cookie_counter++;
2560 *cookie = roc->cookie;
2562 *cookie = (unsigned long)txskb;
2565 /* if there's one pending or we're scanning, queue this one */
2566 if (!list_empty(&local->roc_list) ||
2567 local->scanning || ieee80211_is_radar_required(local))
2568 goto out_check_combine;
2570 /* if not HW assist, just queue & schedule work */
2571 if (!local->ops->remain_on_channel) {
2572 ieee80211_queue_delayed_work(&local->hw, &roc->work, 0);
2576 /* otherwise actually kick it off here (for error handling) */
2578 ret = drv_remain_on_channel(local, sdata, channel, duration, type);
2584 roc->started = true;
2588 list_for_each_entry(tmp, &local->roc_list, list) {
2589 if (tmp->chan != channel || tmp->sdata != sdata)
2593 * Extend this ROC if possible:
2595 * If it hasn't started yet, just increase the duration
2596 * and add the new one to the list of dependents.
2597 * If the type of the new ROC has higher priority, modify the
2598 * type of the previous one to match that of the new one.
2600 if (!tmp->started) {
2601 list_add_tail(&roc->list, &tmp->dependents);
2602 tmp->duration = max(tmp->duration, roc->duration);
2603 tmp->type = max(tmp->type, roc->type);
2608 /* If it has already started, it's more difficult ... */
2609 if (local->ops->remain_on_channel) {
2611 * In the offloaded ROC case, if it hasn't begun, add
2612 * this new one to the dependent list to be handled
2613 * when the master one begins. If it has begun,
2614 * check that there's still a minimum time left and
2615 * if so, start this one, transmitting the frame, but
2616 * add it to the list directly after this one with
2617 * a reduced time so we'll ask the driver to execute
2618 * it right after finishing the previous one, in the
2619 * hope that it'll also be executed right afterwards,
2620 * effectively extending the old one.
2621 * If there's no minimum time left, just add it to the
2623 * TODO: the ROC type is ignored here, assuming that it
2624 * is better to immediately use the current ROC.
2626 if (!tmp->hw_begun) {
2627 list_add_tail(&roc->list, &tmp->dependents);
2632 if (ieee80211_coalesce_started_roc(local, roc, tmp))
2634 } else if (del_timer_sync(&tmp->work.timer)) {
2635 unsigned long new_end;
2638 * In the software ROC case, cancel the timer, if
2639 * that fails then the finish work is already
2640 * queued/pending and thus we queue the new ROC
2641 * normally, if that succeeds then we can extend
2642 * the timer duration and TX the frame (if any.)
2645 list_add_tail(&roc->list, &tmp->dependents);
2648 new_end = jiffies + msecs_to_jiffies(roc->duration);
2650 /* ok, it was started & we canceled timer */
2651 if (time_after(new_end, tmp->work.timer.expires))
2652 mod_timer(&tmp->work.timer, new_end);
2654 add_timer(&tmp->work.timer);
2656 ieee80211_handle_roc_started(roc);
2663 list_add_tail(&roc->list, &local->roc_list);
2668 static int ieee80211_remain_on_channel(struct wiphy *wiphy,
2669 struct wireless_dev *wdev,
2670 struct ieee80211_channel *chan,
2671 unsigned int duration,
2674 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
2675 struct ieee80211_local *local = sdata->local;
2678 mutex_lock(&local->mtx);
2679 ret = ieee80211_start_roc_work(local, sdata, chan,
2680 duration, cookie, NULL,
2681 IEEE80211_ROC_TYPE_NORMAL);
2682 mutex_unlock(&local->mtx);
2687 static int ieee80211_cancel_roc(struct ieee80211_local *local,
2688 u64 cookie, bool mgmt_tx)
2690 struct ieee80211_roc_work *roc, *tmp, *found = NULL;
2693 mutex_lock(&local->mtx);
2694 list_for_each_entry_safe(roc, tmp, &local->roc_list, list) {
2695 struct ieee80211_roc_work *dep, *tmp2;
2697 list_for_each_entry_safe(dep, tmp2, &roc->dependents, list) {
2698 if (!mgmt_tx && dep->cookie != cookie)
2700 else if (mgmt_tx && dep->mgmt_tx_cookie != cookie)
2702 /* found dependent item -- just remove it */
2703 list_del(&dep->list);
2704 mutex_unlock(&local->mtx);
2706 ieee80211_roc_notify_destroy(dep, true);
2710 if (!mgmt_tx && roc->cookie != cookie)
2712 else if (mgmt_tx && roc->mgmt_tx_cookie != cookie)
2720 mutex_unlock(&local->mtx);
2725 * We found the item to cancel, so do that. Note that it
2726 * may have dependents, which we also cancel (and send
2727 * the expired signal for.) Not doing so would be quite
2728 * tricky here, but we may need to fix it later.
2731 if (local->ops->remain_on_channel) {
2732 if (found->started) {
2733 ret = drv_cancel_remain_on_channel(local);
2734 if (WARN_ON_ONCE(ret)) {
2735 mutex_unlock(&local->mtx);
2740 list_del(&found->list);
2743 ieee80211_start_next_roc(local);
2744 mutex_unlock(&local->mtx);
2746 ieee80211_roc_notify_destroy(found, true);
2748 /* work may be pending so use it all the time */
2749 found->abort = true;
2750 ieee80211_queue_delayed_work(&local->hw, &found->work, 0);
2752 mutex_unlock(&local->mtx);
2754 /* work will clean up etc */
2755 flush_delayed_work(&found->work);
2756 WARN_ON(!found->to_be_freed);
2763 static int ieee80211_cancel_remain_on_channel(struct wiphy *wiphy,
2764 struct wireless_dev *wdev,
2767 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
2768 struct ieee80211_local *local = sdata->local;
2770 return ieee80211_cancel_roc(local, cookie, false);
2773 static int ieee80211_start_radar_detection(struct wiphy *wiphy,
2774 struct net_device *dev,
2775 struct cfg80211_chan_def *chandef,
2778 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2779 struct ieee80211_local *local = sdata->local;
2782 mutex_lock(&local->mtx);
2783 if (!list_empty(&local->roc_list) || local->scanning) {
2788 /* whatever, but channel contexts should not complain about that one */
2789 sdata->smps_mode = IEEE80211_SMPS_OFF;
2790 sdata->needed_rx_chains = local->rx_chains;
2792 err = ieee80211_vif_use_channel(sdata, chandef,
2793 IEEE80211_CHANCTX_SHARED);
2797 ieee80211_queue_delayed_work(&sdata->local->hw,
2798 &sdata->dfs_cac_timer_work,
2799 msecs_to_jiffies(cac_time_ms));
2802 mutex_unlock(&local->mtx);
2806 static struct cfg80211_beacon_data *
2807 cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon)
2809 struct cfg80211_beacon_data *new_beacon;
2813 len = beacon->head_len + beacon->tail_len + beacon->beacon_ies_len +
2814 beacon->proberesp_ies_len + beacon->assocresp_ies_len +
2815 beacon->probe_resp_len;
2817 new_beacon = kzalloc(sizeof(*new_beacon) + len, GFP_KERNEL);
2821 pos = (u8 *)(new_beacon + 1);
2822 if (beacon->head_len) {
2823 new_beacon->head_len = beacon->head_len;
2824 new_beacon->head = pos;
2825 memcpy(pos, beacon->head, beacon->head_len);
2826 pos += beacon->head_len;
2828 if (beacon->tail_len) {
2829 new_beacon->tail_len = beacon->tail_len;
2830 new_beacon->tail = pos;
2831 memcpy(pos, beacon->tail, beacon->tail_len);
2832 pos += beacon->tail_len;
2834 if (beacon->beacon_ies_len) {
2835 new_beacon->beacon_ies_len = beacon->beacon_ies_len;
2836 new_beacon->beacon_ies = pos;
2837 memcpy(pos, beacon->beacon_ies, beacon->beacon_ies_len);
2838 pos += beacon->beacon_ies_len;
2840 if (beacon->proberesp_ies_len) {
2841 new_beacon->proberesp_ies_len = beacon->proberesp_ies_len;
2842 new_beacon->proberesp_ies = pos;
2843 memcpy(pos, beacon->proberesp_ies, beacon->proberesp_ies_len);
2844 pos += beacon->proberesp_ies_len;
2846 if (beacon->assocresp_ies_len) {
2847 new_beacon->assocresp_ies_len = beacon->assocresp_ies_len;
2848 new_beacon->assocresp_ies = pos;
2849 memcpy(pos, beacon->assocresp_ies, beacon->assocresp_ies_len);
2850 pos += beacon->assocresp_ies_len;
2852 if (beacon->probe_resp_len) {
2853 new_beacon->probe_resp_len = beacon->probe_resp_len;
2854 beacon->probe_resp = pos;
2855 memcpy(pos, beacon->probe_resp, beacon->probe_resp_len);
2856 pos += beacon->probe_resp_len;
2862 void ieee80211_csa_finish(struct ieee80211_vif *vif)
2864 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
2866 ieee80211_queue_work(&sdata->local->hw,
2867 &sdata->csa_finalize_work);
2869 EXPORT_SYMBOL(ieee80211_csa_finish);
2871 static int ieee80211_set_after_csa_beacon(struct ieee80211_sub_if_data *sdata,
2876 switch (sdata->vif.type) {
2877 case NL80211_IFTYPE_AP:
2878 err = ieee80211_assign_beacon(sdata, sdata->u.ap.next_beacon,
2880 kfree(sdata->u.ap.next_beacon);
2881 sdata->u.ap.next_beacon = NULL;
2887 case NL80211_IFTYPE_ADHOC:
2888 err = ieee80211_ibss_finish_csa(sdata);
2893 #ifdef CONFIG_MAC80211_MESH
2894 case NL80211_IFTYPE_MESH_POINT:
2895 err = ieee80211_mesh_finish_csa(sdata);
2909 static int __ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata)
2911 struct ieee80211_local *local = sdata->local;
2915 sdata_assert_lock(sdata);
2916 lockdep_assert_held(&local->mtx);
2917 lockdep_assert_held(&local->chanctx_mtx);
2920 * using reservation isn't immediate as it may be deferred until later
2921 * with multi-vif. once reservation is complete it will re-schedule the
2922 * work with no reserved_chanctx so verify chandef to check if it
2923 * completed successfully
2926 if (sdata->reserved_chanctx) {
2928 * with multi-vif csa driver may call ieee80211_csa_finish()
2929 * many times while waiting for other interfaces to use their
2932 if (sdata->reserved_ready)
2935 return ieee80211_vif_use_reserved_context(sdata);
2938 if (!cfg80211_chandef_identical(&sdata->vif.bss_conf.chandef,
2939 &sdata->csa_chandef))
2942 sdata->vif.csa_active = false;
2944 err = ieee80211_set_after_csa_beacon(sdata, &changed);
2948 ieee80211_bss_info_change_notify(sdata, changed);
2950 if (sdata->csa_block_tx) {
2951 ieee80211_wake_vif_queues(local, sdata,
2952 IEEE80211_QUEUE_STOP_REASON_CSA);
2953 sdata->csa_block_tx = false;
2956 err = drv_post_channel_switch(sdata);
2960 cfg80211_ch_switch_notify(sdata->dev, &sdata->csa_chandef);
2965 static void ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata)
2967 if (__ieee80211_csa_finalize(sdata)) {
2968 sdata_info(sdata, "failed to finalize CSA, disconnecting\n");
2969 cfg80211_stop_iface(sdata->local->hw.wiphy, &sdata->wdev,
2974 void ieee80211_csa_finalize_work(struct work_struct *work)
2976 struct ieee80211_sub_if_data *sdata =
2977 container_of(work, struct ieee80211_sub_if_data,
2979 struct ieee80211_local *local = sdata->local;
2982 mutex_lock(&local->mtx);
2983 mutex_lock(&local->chanctx_mtx);
2985 /* AP might have been stopped while waiting for the lock. */
2986 if (!sdata->vif.csa_active)
2989 if (!ieee80211_sdata_running(sdata))
2992 ieee80211_csa_finalize(sdata);
2995 mutex_unlock(&local->chanctx_mtx);
2996 mutex_unlock(&local->mtx);
2997 sdata_unlock(sdata);
3000 static int ieee80211_set_csa_beacon(struct ieee80211_sub_if_data *sdata,
3001 struct cfg80211_csa_settings *params,
3004 struct ieee80211_csa_settings csa = {};
3007 switch (sdata->vif.type) {
3008 case NL80211_IFTYPE_AP:
3009 sdata->u.ap.next_beacon =
3010 cfg80211_beacon_dup(¶ms->beacon_after);
3011 if (!sdata->u.ap.next_beacon)
3015 * With a count of 0, we don't have to wait for any
3016 * TBTT before switching, so complete the CSA
3017 * immediately. In theory, with a count == 1 we
3018 * should delay the switch until just before the next
3019 * TBTT, but that would complicate things so we switch
3020 * immediately too. If we would delay the switch
3021 * until the next TBTT, we would have to set the probe
3024 * TODO: A channel switch with count <= 1 without
3025 * sending a CSA action frame is kind of useless,
3026 * because the clients won't know we're changing
3027 * channels. The action frame must be implemented
3028 * either here or in the userspace.
3030 if (params->count <= 1)
3033 if ((params->n_counter_offsets_beacon >
3034 IEEE80211_MAX_CSA_COUNTERS_NUM) ||
3035 (params->n_counter_offsets_presp >
3036 IEEE80211_MAX_CSA_COUNTERS_NUM))
3039 csa.counter_offsets_beacon = params->counter_offsets_beacon;
3040 csa.counter_offsets_presp = params->counter_offsets_presp;
3041 csa.n_counter_offsets_beacon = params->n_counter_offsets_beacon;
3042 csa.n_counter_offsets_presp = params->n_counter_offsets_presp;
3043 csa.count = params->count;
3045 err = ieee80211_assign_beacon(sdata, ¶ms->beacon_csa, &csa);
3047 kfree(sdata->u.ap.next_beacon);
3053 case NL80211_IFTYPE_ADHOC:
3054 if (!sdata->vif.bss_conf.ibss_joined)
3057 if (params->chandef.width != sdata->u.ibss.chandef.width)
3060 switch (params->chandef.width) {
3061 case NL80211_CHAN_WIDTH_40:
3062 if (cfg80211_get_chandef_type(¶ms->chandef) !=
3063 cfg80211_get_chandef_type(&sdata->u.ibss.chandef))
3065 case NL80211_CHAN_WIDTH_5:
3066 case NL80211_CHAN_WIDTH_10:
3067 case NL80211_CHAN_WIDTH_20_NOHT:
3068 case NL80211_CHAN_WIDTH_20:
3074 /* changes into another band are not supported */
3075 if (sdata->u.ibss.chandef.chan->band !=
3076 params->chandef.chan->band)
3079 /* see comments in the NL80211_IFTYPE_AP block */
3080 if (params->count > 1) {
3081 err = ieee80211_ibss_csa_beacon(sdata, params);
3087 ieee80211_send_action_csa(sdata, params);
3090 #ifdef CONFIG_MAC80211_MESH
3091 case NL80211_IFTYPE_MESH_POINT: {
3092 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
3094 if (params->chandef.width != sdata->vif.bss_conf.chandef.width)
3097 /* changes into another band are not supported */
3098 if (sdata->vif.bss_conf.chandef.chan->band !=
3099 params->chandef.chan->band)
3102 if (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_NONE) {
3103 ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_INIT;
3104 if (!ifmsh->pre_value)
3105 ifmsh->pre_value = 1;
3110 /* see comments in the NL80211_IFTYPE_AP block */
3111 if (params->count > 1) {
3112 err = ieee80211_mesh_csa_beacon(sdata, params);
3114 ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_NONE;
3120 if (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_INIT)
3121 ieee80211_send_action_csa(sdata, params);
3134 __ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
3135 struct cfg80211_csa_settings *params)
3137 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3138 struct ieee80211_local *local = sdata->local;
3139 struct ieee80211_channel_switch ch_switch;
3140 struct ieee80211_chanctx_conf *conf;
3141 struct ieee80211_chanctx *chanctx;
3145 sdata_assert_lock(sdata);
3146 lockdep_assert_held(&local->mtx);
3148 if (!list_empty(&local->roc_list) || local->scanning)
3151 if (sdata->wdev.cac_started)
3154 if (cfg80211_chandef_identical(¶ms->chandef,
3155 &sdata->vif.bss_conf.chandef))
3158 /* don't allow another channel switch if one is already active. */
3159 if (sdata->vif.csa_active)
3162 mutex_lock(&local->chanctx_mtx);
3163 conf = rcu_dereference_protected(sdata->vif.chanctx_conf,
3164 lockdep_is_held(&local->chanctx_mtx));
3170 chanctx = container_of(conf, struct ieee80211_chanctx, conf);
3176 ch_switch.timestamp = 0;
3177 ch_switch.device_timestamp = 0;
3178 ch_switch.block_tx = params->block_tx;
3179 ch_switch.chandef = params->chandef;
3180 ch_switch.count = params->count;
3182 err = drv_pre_channel_switch(sdata, &ch_switch);
3186 err = ieee80211_vif_reserve_chanctx(sdata, ¶ms->chandef,
3188 params->radar_required);
3192 /* if reservation is invalid then this will fail */
3193 err = ieee80211_check_combinations(sdata, NULL, chanctx->mode, 0);
3195 ieee80211_vif_unreserve_chanctx(sdata);
3199 err = ieee80211_set_csa_beacon(sdata, params, &changed);
3201 ieee80211_vif_unreserve_chanctx(sdata);
3205 sdata->csa_chandef = params->chandef;
3206 sdata->csa_block_tx = params->block_tx;
3207 sdata->vif.csa_active = true;
3209 if (sdata->csa_block_tx)
3210 ieee80211_stop_vif_queues(local, sdata,
3211 IEEE80211_QUEUE_STOP_REASON_CSA);
3213 cfg80211_ch_switch_started_notify(sdata->dev, &sdata->csa_chandef,
3217 ieee80211_bss_info_change_notify(sdata, changed);
3218 drv_channel_switch_beacon(sdata, ¶ms->chandef);
3220 /* if the beacon didn't change, we can finalize immediately */
3221 ieee80211_csa_finalize(sdata);
3225 mutex_unlock(&local->chanctx_mtx);
3229 int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
3230 struct cfg80211_csa_settings *params)
3232 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3233 struct ieee80211_local *local = sdata->local;
3236 mutex_lock(&local->mtx);
3237 err = __ieee80211_channel_switch(wiphy, dev, params);
3238 mutex_unlock(&local->mtx);
3243 static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
3244 struct cfg80211_mgmt_tx_params *params,
3247 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
3248 struct ieee80211_local *local = sdata->local;
3249 struct sk_buff *skb;
3250 struct sta_info *sta;
3251 const struct ieee80211_mgmt *mgmt = (void *)params->buf;
3252 bool need_offchan = false;
3257 if (params->dont_wait_for_ack)
3258 flags = IEEE80211_TX_CTL_NO_ACK;
3260 flags = IEEE80211_TX_INTFL_NL80211_FRAME_TX |
3261 IEEE80211_TX_CTL_REQ_TX_STATUS;
3264 flags |= IEEE80211_TX_CTL_NO_CCK_RATE;
3266 switch (sdata->vif.type) {
3267 case NL80211_IFTYPE_ADHOC:
3268 if (!sdata->vif.bss_conf.ibss_joined)
3269 need_offchan = true;
3271 #ifdef CONFIG_MAC80211_MESH
3272 case NL80211_IFTYPE_MESH_POINT:
3273 if (ieee80211_vif_is_mesh(&sdata->vif) &&
3274 !sdata->u.mesh.mesh_id_len)
3275 need_offchan = true;
3278 case NL80211_IFTYPE_AP:
3279 case NL80211_IFTYPE_AP_VLAN:
3280 case NL80211_IFTYPE_P2P_GO:
3281 if (sdata->vif.type != NL80211_IFTYPE_ADHOC &&
3282 !ieee80211_vif_is_mesh(&sdata->vif) &&
3283 !rcu_access_pointer(sdata->bss->beacon))
3284 need_offchan = true;
3285 if (!ieee80211_is_action(mgmt->frame_control) ||
3286 mgmt->u.action.category == WLAN_CATEGORY_PUBLIC ||
3287 mgmt->u.action.category == WLAN_CATEGORY_SELF_PROTECTED ||
3288 mgmt->u.action.category == WLAN_CATEGORY_SPECTRUM_MGMT)
3291 sta = sta_info_get(sdata, mgmt->da);
3296 case NL80211_IFTYPE_STATION:
3297 case NL80211_IFTYPE_P2P_CLIENT:
3298 if (!sdata->u.mgd.associated)
3299 need_offchan = true;
3301 case NL80211_IFTYPE_P2P_DEVICE:
3302 need_offchan = true;
3308 /* configurations requiring offchan cannot work if no channel has been
3311 if (need_offchan && !params->chan)
3314 mutex_lock(&local->mtx);
3316 /* Check if the operating channel is the requested channel */
3317 if (!need_offchan) {
3318 struct ieee80211_chanctx_conf *chanctx_conf;
3321 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
3324 need_offchan = params->chan &&
3326 chanctx_conf->def.chan);
3327 } else if (!params->chan) {
3332 need_offchan = true;
3337 if (need_offchan && !params->offchan) {
3342 skb = dev_alloc_skb(local->hw.extra_tx_headroom + params->len);
3347 skb_reserve(skb, local->hw.extra_tx_headroom);
3349 data = skb_put(skb, params->len);
3350 memcpy(data, params->buf, params->len);
3352 /* Update CSA counters */
3353 if (sdata->vif.csa_active &&
3354 (sdata->vif.type == NL80211_IFTYPE_AP ||
3355 sdata->vif.type == NL80211_IFTYPE_ADHOC) &&
3356 params->n_csa_offsets) {
3358 struct beacon_data *beacon = NULL;
3362 if (sdata->vif.type == NL80211_IFTYPE_AP)
3363 beacon = rcu_dereference(sdata->u.ap.beacon);
3364 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
3365 beacon = rcu_dereference(sdata->u.ibss.presp);
3366 else if (ieee80211_vif_is_mesh(&sdata->vif))
3367 beacon = rcu_dereference(sdata->u.mesh.beacon);
3370 for (i = 0; i < params->n_csa_offsets; i++)
3371 data[params->csa_offsets[i]] =
3372 beacon->csa_current_counter;
3377 IEEE80211_SKB_CB(skb)->flags = flags;
3379 skb->dev = sdata->dev;
3381 if (!need_offchan) {
3382 *cookie = (unsigned long) skb;
3383 ieee80211_tx_skb(sdata, skb);
3388 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_TX_OFFCHAN |
3389 IEEE80211_TX_INTFL_OFFCHAN_TX_OK;
3390 if (local->hw.flags & IEEE80211_HW_QUEUE_CONTROL)
3391 IEEE80211_SKB_CB(skb)->hw_queue =
3392 local->hw.offchannel_tx_hw_queue;
3394 /* This will handle all kinds of coalescing and immediate TX */
3395 ret = ieee80211_start_roc_work(local, sdata, params->chan,
3396 params->wait, cookie, skb,
3397 IEEE80211_ROC_TYPE_MGMT_TX);
3401 mutex_unlock(&local->mtx);
3405 static int ieee80211_mgmt_tx_cancel_wait(struct wiphy *wiphy,
3406 struct wireless_dev *wdev,
3409 struct ieee80211_local *local = wiphy_priv(wiphy);
3411 return ieee80211_cancel_roc(local, cookie, true);
3414 static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
3415 struct wireless_dev *wdev,
3416 u16 frame_type, bool reg)
3418 struct ieee80211_local *local = wiphy_priv(wiphy);
3420 switch (frame_type) {
3421 case IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ:
3423 local->probe_req_reg++;
3425 local->probe_req_reg--;
3427 if (!local->open_count)
3430 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
3437 static int ieee80211_set_antenna(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant)
3439 struct ieee80211_local *local = wiphy_priv(wiphy);
3444 return drv_set_antenna(local, tx_ant, rx_ant);
3447 static int ieee80211_get_antenna(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant)
3449 struct ieee80211_local *local = wiphy_priv(wiphy);
3451 return drv_get_antenna(local, tx_ant, rx_ant);
3454 static int ieee80211_set_rekey_data(struct wiphy *wiphy,
3455 struct net_device *dev,
3456 struct cfg80211_gtk_rekey_data *data)
3458 struct ieee80211_local *local = wiphy_priv(wiphy);
3459 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3461 if (!local->ops->set_rekey_data)
3464 drv_set_rekey_data(local, sdata, data);
3469 static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev,
3470 const u8 *peer, u64 *cookie)
3472 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3473 struct ieee80211_local *local = sdata->local;
3474 struct ieee80211_qos_hdr *nullfunc;
3475 struct sk_buff *skb;
3476 int size = sizeof(*nullfunc);
3479 struct ieee80211_tx_info *info;
3480 struct sta_info *sta;
3481 struct ieee80211_chanctx_conf *chanctx_conf;
3482 enum ieee80211_band band;
3485 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
3486 if (WARN_ON(!chanctx_conf)) {
3490 band = chanctx_conf->def.chan->band;
3491 sta = sta_info_get_bss(sdata, peer);
3500 fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
3501 IEEE80211_STYPE_QOS_NULLFUNC |
3502 IEEE80211_FCTL_FROMDS);
3505 fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
3506 IEEE80211_STYPE_NULLFUNC |
3507 IEEE80211_FCTL_FROMDS);
3510 skb = dev_alloc_skb(local->hw.extra_tx_headroom + size);
3518 skb_reserve(skb, local->hw.extra_tx_headroom);
3520 nullfunc = (void *) skb_put(skb, size);
3521 nullfunc->frame_control = fc;
3522 nullfunc->duration_id = 0;
3523 memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN);
3524 memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN);
3525 memcpy(nullfunc->addr3, sdata->vif.addr, ETH_ALEN);
3526 nullfunc->seq_ctrl = 0;
3528 info = IEEE80211_SKB_CB(skb);
3530 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS |
3531 IEEE80211_TX_INTFL_NL80211_FRAME_TX;
3534 skb_set_queue_mapping(skb, IEEE80211_AC_VO);
3537 nullfunc->qos_ctrl = cpu_to_le16(7);
3540 ieee80211_xmit(sdata, skb);
3544 *cookie = (unsigned long) skb;
3548 static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
3549 struct wireless_dev *wdev,
3550 struct cfg80211_chan_def *chandef)
3552 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
3553 struct ieee80211_local *local = wiphy_priv(wiphy);
3554 struct ieee80211_chanctx_conf *chanctx_conf;
3558 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
3560 *chandef = sdata->vif.bss_conf.chandef;
3562 } else if (local->open_count > 0 &&
3563 local->open_count == local->monitors &&
3564 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
3565 if (local->use_chanctx)
3566 *chandef = local->monitor_chandef;
3568 *chandef = local->_oper_chandef;
3577 static void ieee80211_set_wakeup(struct wiphy *wiphy, bool enabled)
3579 drv_set_wakeup(wiphy_priv(wiphy), enabled);
3583 static int ieee80211_set_qos_map(struct wiphy *wiphy,
3584 struct net_device *dev,
3585 struct cfg80211_qos_map *qos_map)
3587 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3588 struct mac80211_qos_map *new_qos_map, *old_qos_map;
3591 new_qos_map = kzalloc(sizeof(*new_qos_map), GFP_KERNEL);
3594 memcpy(&new_qos_map->qos_map, qos_map, sizeof(*qos_map));
3596 /* A NULL qos_map was passed to disable QoS mapping */
3600 old_qos_map = sdata_dereference(sdata->qos_map, sdata);
3601 rcu_assign_pointer(sdata->qos_map, new_qos_map);
3603 kfree_rcu(old_qos_map, rcu_head);
3608 static int ieee80211_set_ap_chanwidth(struct wiphy *wiphy,
3609 struct net_device *dev,
3610 struct cfg80211_chan_def *chandef)
3612 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3616 ret = ieee80211_vif_change_bandwidth(sdata, chandef, &changed);
3618 ieee80211_bss_info_change_notify(sdata, changed);
3623 static int ieee80211_add_tx_ts(struct wiphy *wiphy, struct net_device *dev,
3624 u8 tsid, const u8 *peer, u8 up,
3627 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3628 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
3629 int ac = ieee802_1d_to_ac[up];
3631 if (sdata->vif.type != NL80211_IFTYPE_STATION)
3634 if (!(sdata->wmm_acm & BIT(up)))
3637 if (ifmgd->tx_tspec[ac].admitted_time)
3640 if (admitted_time) {
3641 ifmgd->tx_tspec[ac].admitted_time = 32 * admitted_time;
3642 ifmgd->tx_tspec[ac].tsid = tsid;
3643 ifmgd->tx_tspec[ac].up = up;
3649 static int ieee80211_del_tx_ts(struct wiphy *wiphy, struct net_device *dev,
3650 u8 tsid, const u8 *peer)
3652 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3653 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
3654 struct ieee80211_local *local = wiphy_priv(wiphy);
3657 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
3658 struct ieee80211_sta_tx_tspec *tx_tspec = &ifmgd->tx_tspec[ac];
3660 /* skip unused entries */
3661 if (!tx_tspec->admitted_time)
3664 if (tx_tspec->tsid != tsid)
3667 /* due to this new packets will be reassigned to non-ACM ACs */
3670 /* Make sure that all packets have been sent to avoid to
3671 * restore the QoS params on packets that are still on the
3675 ieee80211_flush_queues(local, sdata, false);
3677 /* restore the normal QoS parameters
3678 * (unconditionally to avoid races)
3680 tx_tspec->action = TX_TSPEC_ACTION_STOP_DOWNGRADE;
3681 tx_tspec->downgraded = false;
3682 ieee80211_sta_handle_tspec_ac_params(sdata);
3684 /* finally clear all the data */
3685 memset(tx_tspec, 0, sizeof(*tx_tspec));
3693 const struct cfg80211_ops mac80211_config_ops = {
3694 .add_virtual_intf = ieee80211_add_iface,
3695 .del_virtual_intf = ieee80211_del_iface,
3696 .change_virtual_intf = ieee80211_change_iface,
3697 .start_p2p_device = ieee80211_start_p2p_device,
3698 .stop_p2p_device = ieee80211_stop_p2p_device,
3699 .add_key = ieee80211_add_key,
3700 .del_key = ieee80211_del_key,
3701 .get_key = ieee80211_get_key,
3702 .set_default_key = ieee80211_config_default_key,
3703 .set_default_mgmt_key = ieee80211_config_default_mgmt_key,
3704 .start_ap = ieee80211_start_ap,
3705 .change_beacon = ieee80211_change_beacon,
3706 .stop_ap = ieee80211_stop_ap,
3707 .add_station = ieee80211_add_station,
3708 .del_station = ieee80211_del_station,
3709 .change_station = ieee80211_change_station,
3710 .get_station = ieee80211_get_station,
3711 .dump_station = ieee80211_dump_station,
3712 .dump_survey = ieee80211_dump_survey,
3713 #ifdef CONFIG_MAC80211_MESH
3714 .add_mpath = ieee80211_add_mpath,
3715 .del_mpath = ieee80211_del_mpath,
3716 .change_mpath = ieee80211_change_mpath,
3717 .get_mpath = ieee80211_get_mpath,
3718 .dump_mpath = ieee80211_dump_mpath,
3719 .get_mpp = ieee80211_get_mpp,
3720 .dump_mpp = ieee80211_dump_mpp,
3721 .update_mesh_config = ieee80211_update_mesh_config,
3722 .get_mesh_config = ieee80211_get_mesh_config,
3723 .join_mesh = ieee80211_join_mesh,
3724 .leave_mesh = ieee80211_leave_mesh,
3726 .join_ocb = ieee80211_join_ocb,
3727 .leave_ocb = ieee80211_leave_ocb,
3728 .change_bss = ieee80211_change_bss,
3729 .set_txq_params = ieee80211_set_txq_params,
3730 .set_monitor_channel = ieee80211_set_monitor_channel,
3731 .suspend = ieee80211_suspend,
3732 .resume = ieee80211_resume,
3733 .scan = ieee80211_scan,
3734 .sched_scan_start = ieee80211_sched_scan_start,
3735 .sched_scan_stop = ieee80211_sched_scan_stop,
3736 .auth = ieee80211_auth,
3737 .assoc = ieee80211_assoc,
3738 .deauth = ieee80211_deauth,
3739 .disassoc = ieee80211_disassoc,
3740 .join_ibss = ieee80211_join_ibss,
3741 .leave_ibss = ieee80211_leave_ibss,
3742 .set_mcast_rate = ieee80211_set_mcast_rate,
3743 .set_wiphy_params = ieee80211_set_wiphy_params,
3744 .set_tx_power = ieee80211_set_tx_power,
3745 .get_tx_power = ieee80211_get_tx_power,
3746 .set_wds_peer = ieee80211_set_wds_peer,
3747 .rfkill_poll = ieee80211_rfkill_poll,
3748 CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd)
3749 CFG80211_TESTMODE_DUMP(ieee80211_testmode_dump)
3750 .set_power_mgmt = ieee80211_set_power_mgmt,
3751 .set_bitrate_mask = ieee80211_set_bitrate_mask,
3752 .remain_on_channel = ieee80211_remain_on_channel,
3753 .cancel_remain_on_channel = ieee80211_cancel_remain_on_channel,
3754 .mgmt_tx = ieee80211_mgmt_tx,
3755 .mgmt_tx_cancel_wait = ieee80211_mgmt_tx_cancel_wait,
3756 .set_cqm_rssi_config = ieee80211_set_cqm_rssi_config,
3757 .mgmt_frame_register = ieee80211_mgmt_frame_register,
3758 .set_antenna = ieee80211_set_antenna,
3759 .get_antenna = ieee80211_get_antenna,
3760 .set_rekey_data = ieee80211_set_rekey_data,
3761 .tdls_oper = ieee80211_tdls_oper,
3762 .tdls_mgmt = ieee80211_tdls_mgmt,
3763 .tdls_channel_switch = ieee80211_tdls_channel_switch,
3764 .tdls_cancel_channel_switch = ieee80211_tdls_cancel_channel_switch,
3765 .probe_client = ieee80211_probe_client,
3766 .set_noack_map = ieee80211_set_noack_map,
3768 .set_wakeup = ieee80211_set_wakeup,
3770 .get_channel = ieee80211_cfg_get_channel,
3771 .start_radar_detection = ieee80211_start_radar_detection,
3772 .channel_switch = ieee80211_channel_switch,
3773 .set_qos_map = ieee80211_set_qos_map,
3774 .set_ap_chanwidth = ieee80211_set_ap_chanwidth,
3775 .add_tx_ts = ieee80211_add_tx_ts,
3776 .del_tx_ts = ieee80211_del_tx_ts,