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"
24 static struct wireless_dev
*ieee80211_add_iface(struct wiphy
*wiphy
,
26 enum nl80211_iftype type
,
28 struct vif_params
*params
)
30 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
31 struct wireless_dev
*wdev
;
32 struct ieee80211_sub_if_data
*sdata
;
35 err
= ieee80211_if_add(local
, name
, &wdev
, type
, params
);
39 if (type
== NL80211_IFTYPE_MONITOR
&& flags
) {
40 sdata
= IEEE80211_WDEV_TO_SUB_IF(wdev
);
41 sdata
->u
.mntr_flags
= *flags
;
47 static int ieee80211_del_iface(struct wiphy
*wiphy
, struct wireless_dev
*wdev
)
49 ieee80211_if_remove(IEEE80211_WDEV_TO_SUB_IF(wdev
));
54 static int ieee80211_change_iface(struct wiphy
*wiphy
,
55 struct net_device
*dev
,
56 enum nl80211_iftype type
, u32
*flags
,
57 struct vif_params
*params
)
59 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
62 ret
= ieee80211_if_change_type(sdata
, type
);
66 if (type
== NL80211_IFTYPE_AP_VLAN
&&
67 params
&& params
->use_4addr
== 0)
68 RCU_INIT_POINTER(sdata
->u
.vlan
.sta
, NULL
);
69 else if (type
== NL80211_IFTYPE_STATION
&&
70 params
&& params
->use_4addr
>= 0)
71 sdata
->u
.mgd
.use_4addr
= params
->use_4addr
;
73 if (sdata
->vif
.type
== NL80211_IFTYPE_MONITOR
&& flags
) {
74 struct ieee80211_local
*local
= sdata
->local
;
76 if (ieee80211_sdata_running(sdata
)) {
77 u32 mask
= MONITOR_FLAG_COOK_FRAMES
|
81 * Prohibit MONITOR_FLAG_COOK_FRAMES and
82 * MONITOR_FLAG_ACTIVE to be changed while the
84 * Else we would need to add a lot of cruft
85 * to update everything:
86 * cooked_mntrs, monitor and all fif_* counters
87 * reconfigure hardware
89 if ((*flags
& mask
) != (sdata
->u
.mntr_flags
& mask
))
92 ieee80211_adjust_monitor_flags(sdata
, -1);
93 sdata
->u
.mntr_flags
= *flags
;
94 ieee80211_adjust_monitor_flags(sdata
, 1);
96 ieee80211_configure_filter(local
);
99 * Because the interface is down, ieee80211_do_stop
100 * and ieee80211_do_open take care of "everything"
101 * mentioned in the comment above.
103 sdata
->u
.mntr_flags
= *flags
;
110 static int ieee80211_start_p2p_device(struct wiphy
*wiphy
,
111 struct wireless_dev
*wdev
)
113 struct ieee80211_sub_if_data
*sdata
= IEEE80211_WDEV_TO_SUB_IF(wdev
);
116 mutex_lock(&sdata
->local
->chanctx_mtx
);
117 ret
= ieee80211_check_combinations(sdata
, NULL
, 0, 0);
118 mutex_unlock(&sdata
->local
->chanctx_mtx
);
122 return ieee80211_do_open(wdev
, true);
125 static void ieee80211_stop_p2p_device(struct wiphy
*wiphy
,
126 struct wireless_dev
*wdev
)
128 ieee80211_sdata_stop(IEEE80211_WDEV_TO_SUB_IF(wdev
));
131 static int ieee80211_set_noack_map(struct wiphy
*wiphy
,
132 struct net_device
*dev
,
135 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
137 sdata
->noack_map
= noack_map
;
141 static int ieee80211_add_key(struct wiphy
*wiphy
, struct net_device
*dev
,
142 u8 key_idx
, bool pairwise
, const u8
*mac_addr
,
143 struct key_params
*params
)
145 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
146 struct ieee80211_local
*local
= sdata
->local
;
147 struct sta_info
*sta
= NULL
;
148 const struct ieee80211_cipher_scheme
*cs
= NULL
;
149 struct ieee80211_key
*key
;
152 if (!ieee80211_sdata_running(sdata
))
155 /* reject WEP and TKIP keys if WEP failed to initialize */
156 switch (params
->cipher
) {
157 case WLAN_CIPHER_SUITE_WEP40
:
158 case WLAN_CIPHER_SUITE_TKIP
:
159 case WLAN_CIPHER_SUITE_WEP104
:
160 if (IS_ERR(local
->wep_tx_tfm
))
163 case WLAN_CIPHER_SUITE_CCMP
:
164 case WLAN_CIPHER_SUITE_AES_CMAC
:
165 case WLAN_CIPHER_SUITE_GCMP
:
168 cs
= ieee80211_cs_get(local
, params
->cipher
, sdata
->vif
.type
);
172 key
= ieee80211_key_alloc(params
->cipher
, key_idx
, params
->key_len
,
173 params
->key
, params
->seq_len
, params
->seq
,
179 key
->conf
.flags
|= IEEE80211_KEY_FLAG_PAIRWISE
;
181 mutex_lock(&local
->sta_mtx
);
184 if (ieee80211_vif_is_mesh(&sdata
->vif
))
185 sta
= sta_info_get(sdata
, mac_addr
);
187 sta
= sta_info_get_bss(sdata
, mac_addr
);
189 * The ASSOC test makes sure the driver is ready to
190 * receive the key. When wpa_supplicant has roamed
191 * using FT, it attempts to set the key before
192 * association has completed, this rejects that attempt
193 * so it will set the key again after assocation.
195 * TODO: accept the key if we have a station entry and
196 * add it to the device after the station.
198 if (!sta
|| !test_sta_flag(sta
, WLAN_STA_ASSOC
)) {
199 ieee80211_key_free_unused(key
);
205 switch (sdata
->vif
.type
) {
206 case NL80211_IFTYPE_STATION
:
207 if (sdata
->u
.mgd
.mfp
!= IEEE80211_MFP_DISABLED
)
208 key
->conf
.flags
|= IEEE80211_KEY_FLAG_RX_MGMT
;
210 case NL80211_IFTYPE_AP
:
211 case NL80211_IFTYPE_AP_VLAN
:
212 /* Keys without a station are used for TX only */
213 if (key
->sta
&& test_sta_flag(key
->sta
, WLAN_STA_MFP
))
214 key
->conf
.flags
|= IEEE80211_KEY_FLAG_RX_MGMT
;
216 case NL80211_IFTYPE_ADHOC
:
219 case NL80211_IFTYPE_MESH_POINT
:
220 #ifdef CONFIG_MAC80211_MESH
221 if (sdata
->u
.mesh
.security
!= IEEE80211_MESH_SEC_NONE
)
222 key
->conf
.flags
|= IEEE80211_KEY_FLAG_RX_MGMT
;
225 case NL80211_IFTYPE_WDS
:
226 case NL80211_IFTYPE_MONITOR
:
227 case NL80211_IFTYPE_P2P_DEVICE
:
228 case NL80211_IFTYPE_UNSPECIFIED
:
229 case NUM_NL80211_IFTYPES
:
230 case NL80211_IFTYPE_P2P_CLIENT
:
231 case NL80211_IFTYPE_P2P_GO
:
232 /* shouldn't happen */
238 sta
->cipher_scheme
= cs
;
240 err
= ieee80211_key_link(key
, sdata
, sta
);
243 mutex_unlock(&local
->sta_mtx
);
248 static int ieee80211_del_key(struct wiphy
*wiphy
, struct net_device
*dev
,
249 u8 key_idx
, bool pairwise
, const u8
*mac_addr
)
251 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
252 struct ieee80211_local
*local
= sdata
->local
;
253 struct sta_info
*sta
;
254 struct ieee80211_key
*key
= NULL
;
257 mutex_lock(&local
->sta_mtx
);
258 mutex_lock(&local
->key_mtx
);
263 sta
= sta_info_get_bss(sdata
, mac_addr
);
268 key
= key_mtx_dereference(local
, sta
->ptk
[key_idx
]);
270 key
= key_mtx_dereference(local
, sta
->gtk
[key_idx
]);
272 key
= key_mtx_dereference(local
, sdata
->keys
[key_idx
]);
279 ieee80211_key_free(key
, true);
283 mutex_unlock(&local
->key_mtx
);
284 mutex_unlock(&local
->sta_mtx
);
289 static int ieee80211_get_key(struct wiphy
*wiphy
, struct net_device
*dev
,
290 u8 key_idx
, bool pairwise
, const u8
*mac_addr
,
292 void (*callback
)(void *cookie
,
293 struct key_params
*params
))
295 struct ieee80211_sub_if_data
*sdata
;
296 struct sta_info
*sta
= NULL
;
298 struct key_params params
;
299 struct ieee80211_key
*key
= NULL
;
305 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
310 sta
= sta_info_get_bss(sdata
, mac_addr
);
314 if (pairwise
&& key_idx
< NUM_DEFAULT_KEYS
)
315 key
= rcu_dereference(sta
->ptk
[key_idx
]);
316 else if (!pairwise
&&
317 key_idx
< NUM_DEFAULT_KEYS
+ NUM_DEFAULT_MGMT_KEYS
)
318 key
= rcu_dereference(sta
->gtk
[key_idx
]);
320 key
= rcu_dereference(sdata
->keys
[key_idx
]);
325 memset(¶ms
, 0, sizeof(params
));
327 params
.cipher
= key
->conf
.cipher
;
329 switch (key
->conf
.cipher
) {
330 case WLAN_CIPHER_SUITE_TKIP
:
331 iv32
= key
->u
.tkip
.tx
.iv32
;
332 iv16
= key
->u
.tkip
.tx
.iv16
;
334 if (key
->flags
& KEY_FLAG_UPLOADED_TO_HARDWARE
)
335 drv_get_tkip_seq(sdata
->local
,
336 key
->conf
.hw_key_idx
,
339 seq
[0] = iv16
& 0xff;
340 seq
[1] = (iv16
>> 8) & 0xff;
341 seq
[2] = iv32
& 0xff;
342 seq
[3] = (iv32
>> 8) & 0xff;
343 seq
[4] = (iv32
>> 16) & 0xff;
344 seq
[5] = (iv32
>> 24) & 0xff;
348 case WLAN_CIPHER_SUITE_CCMP
:
349 pn64
= atomic64_read(&key
->u
.ccmp
.tx_pn
);
359 case WLAN_CIPHER_SUITE_AES_CMAC
:
360 pn64
= atomic64_read(&key
->u
.aes_cmac
.tx_pn
);
372 params
.key
= key
->conf
.key
;
373 params
.key_len
= key
->conf
.keylen
;
375 callback(cookie
, ¶ms
);
383 static int ieee80211_config_default_key(struct wiphy
*wiphy
,
384 struct net_device
*dev
,
385 u8 key_idx
, bool uni
,
388 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
390 ieee80211_set_default_key(sdata
, key_idx
, uni
, multi
);
395 static int ieee80211_config_default_mgmt_key(struct wiphy
*wiphy
,
396 struct net_device
*dev
,
399 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
401 ieee80211_set_default_mgmt_key(sdata
, key_idx
);
406 void sta_set_rate_info_tx(struct sta_info
*sta
,
407 const struct ieee80211_tx_rate
*rate
,
408 struct rate_info
*rinfo
)
411 if (rate
->flags
& IEEE80211_TX_RC_MCS
) {
412 rinfo
->flags
|= RATE_INFO_FLAGS_MCS
;
413 rinfo
->mcs
= rate
->idx
;
414 } else if (rate
->flags
& IEEE80211_TX_RC_VHT_MCS
) {
415 rinfo
->flags
|= RATE_INFO_FLAGS_VHT_MCS
;
416 rinfo
->mcs
= ieee80211_rate_get_vht_mcs(rate
);
417 rinfo
->nss
= ieee80211_rate_get_vht_nss(rate
);
419 struct ieee80211_supported_band
*sband
;
420 int shift
= ieee80211_vif_get_shift(&sta
->sdata
->vif
);
423 sband
= sta
->local
->hw
.wiphy
->bands
[
424 ieee80211_get_sdata_band(sta
->sdata
)];
425 brate
= sband
->bitrates
[rate
->idx
].bitrate
;
426 rinfo
->legacy
= DIV_ROUND_UP(brate
, 1 << shift
);
428 if (rate
->flags
& IEEE80211_TX_RC_40_MHZ_WIDTH
)
429 rinfo
->flags
|= RATE_INFO_FLAGS_40_MHZ_WIDTH
;
430 if (rate
->flags
& IEEE80211_TX_RC_80_MHZ_WIDTH
)
431 rinfo
->flags
|= RATE_INFO_FLAGS_80_MHZ_WIDTH
;
432 if (rate
->flags
& IEEE80211_TX_RC_160_MHZ_WIDTH
)
433 rinfo
->flags
|= RATE_INFO_FLAGS_160_MHZ_WIDTH
;
434 if (rate
->flags
& IEEE80211_TX_RC_SHORT_GI
)
435 rinfo
->flags
|= RATE_INFO_FLAGS_SHORT_GI
;
438 void sta_set_rate_info_rx(struct sta_info
*sta
, struct rate_info
*rinfo
)
442 if (sta
->last_rx_rate_flag
& RX_FLAG_HT
) {
443 rinfo
->flags
|= RATE_INFO_FLAGS_MCS
;
444 rinfo
->mcs
= sta
->last_rx_rate_idx
;
445 } else if (sta
->last_rx_rate_flag
& RX_FLAG_VHT
) {
446 rinfo
->flags
|= RATE_INFO_FLAGS_VHT_MCS
;
447 rinfo
->nss
= sta
->last_rx_rate_vht_nss
;
448 rinfo
->mcs
= sta
->last_rx_rate_idx
;
450 struct ieee80211_supported_band
*sband
;
451 int shift
= ieee80211_vif_get_shift(&sta
->sdata
->vif
);
454 sband
= sta
->local
->hw
.wiphy
->bands
[
455 ieee80211_get_sdata_band(sta
->sdata
)];
456 brate
= sband
->bitrates
[sta
->last_rx_rate_idx
].bitrate
;
457 rinfo
->legacy
= DIV_ROUND_UP(brate
, 1 << shift
);
460 if (sta
->last_rx_rate_flag
& RX_FLAG_40MHZ
)
461 rinfo
->flags
|= RATE_INFO_FLAGS_40_MHZ_WIDTH
;
462 if (sta
->last_rx_rate_flag
& RX_FLAG_SHORT_GI
)
463 rinfo
->flags
|= RATE_INFO_FLAGS_SHORT_GI
;
464 if (sta
->last_rx_rate_vht_flag
& RX_VHT_FLAG_80MHZ
)
465 rinfo
->flags
|= RATE_INFO_FLAGS_80_MHZ_WIDTH
;
466 if (sta
->last_rx_rate_vht_flag
& RX_VHT_FLAG_80P80MHZ
)
467 rinfo
->flags
|= RATE_INFO_FLAGS_80P80_MHZ_WIDTH
;
468 if (sta
->last_rx_rate_vht_flag
& RX_VHT_FLAG_160MHZ
)
469 rinfo
->flags
|= RATE_INFO_FLAGS_160_MHZ_WIDTH
;
472 static int ieee80211_dump_station(struct wiphy
*wiphy
, struct net_device
*dev
,
473 int idx
, u8
*mac
, struct station_info
*sinfo
)
475 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
476 struct ieee80211_local
*local
= sdata
->local
;
477 struct sta_info
*sta
;
480 mutex_lock(&local
->sta_mtx
);
482 sta
= sta_info_get_by_idx(sdata
, idx
);
485 memcpy(mac
, sta
->sta
.addr
, ETH_ALEN
);
486 sta_set_sinfo(sta
, sinfo
);
489 mutex_unlock(&local
->sta_mtx
);
494 static int ieee80211_dump_survey(struct wiphy
*wiphy
, struct net_device
*dev
,
495 int idx
, struct survey_info
*survey
)
497 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
499 return drv_get_survey(local
, idx
, survey
);
502 static int ieee80211_get_station(struct wiphy
*wiphy
, struct net_device
*dev
,
503 const u8
*mac
, struct station_info
*sinfo
)
505 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
506 struct ieee80211_local
*local
= sdata
->local
;
507 struct sta_info
*sta
;
510 mutex_lock(&local
->sta_mtx
);
512 sta
= sta_info_get_bss(sdata
, mac
);
515 sta_set_sinfo(sta
, sinfo
);
518 mutex_unlock(&local
->sta_mtx
);
523 static int ieee80211_set_monitor_channel(struct wiphy
*wiphy
,
524 struct cfg80211_chan_def
*chandef
)
526 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
527 struct ieee80211_sub_if_data
*sdata
;
530 if (cfg80211_chandef_identical(&local
->monitor_chandef
, chandef
))
533 mutex_lock(&local
->mtx
);
534 mutex_lock(&local
->iflist_mtx
);
535 if (local
->use_chanctx
) {
536 sdata
= rcu_dereference_protected(
537 local
->monitor_sdata
,
538 lockdep_is_held(&local
->iflist_mtx
));
540 ieee80211_vif_release_channel(sdata
);
541 ret
= ieee80211_vif_use_channel(sdata
, chandef
,
542 IEEE80211_CHANCTX_EXCLUSIVE
);
544 } else if (local
->open_count
== local
->monitors
) {
545 local
->_oper_chandef
= *chandef
;
546 ieee80211_hw_config(local
, 0);
550 local
->monitor_chandef
= *chandef
;
551 mutex_unlock(&local
->iflist_mtx
);
552 mutex_unlock(&local
->mtx
);
557 static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data
*sdata
,
558 const u8
*resp
, size_t resp_len
,
559 const struct ieee80211_csa_settings
*csa
)
561 struct probe_resp
*new, *old
;
563 if (!resp
|| !resp_len
)
566 old
= sdata_dereference(sdata
->u
.ap
.probe_resp
, sdata
);
568 new = kzalloc(sizeof(struct probe_resp
) + resp_len
, GFP_KERNEL
);
573 memcpy(new->data
, resp
, resp_len
);
576 memcpy(new->csa_counter_offsets
, csa
->counter_offsets_presp
,
577 csa
->n_counter_offsets_presp
*
578 sizeof(new->csa_counter_offsets
[0]));
580 rcu_assign_pointer(sdata
->u
.ap
.probe_resp
, new);
582 kfree_rcu(old
, rcu_head
);
587 static int ieee80211_assign_beacon(struct ieee80211_sub_if_data
*sdata
,
588 struct cfg80211_beacon_data
*params
,
589 const struct ieee80211_csa_settings
*csa
)
591 struct beacon_data
*new, *old
;
592 int new_head_len
, new_tail_len
;
594 u32 changed
= BSS_CHANGED_BEACON
;
596 old
= sdata_dereference(sdata
->u
.ap
.beacon
, sdata
);
599 /* Need to have a beacon head if we don't have one yet */
600 if (!params
->head
&& !old
)
603 /* new or old head? */
605 new_head_len
= params
->head_len
;
607 new_head_len
= old
->head_len
;
609 /* new or old tail? */
610 if (params
->tail
|| !old
)
611 /* params->tail_len will be zero for !params->tail */
612 new_tail_len
= params
->tail_len
;
614 new_tail_len
= old
->tail_len
;
616 size
= sizeof(*new) + new_head_len
+ new_tail_len
;
618 new = kzalloc(size
, GFP_KERNEL
);
622 /* start filling the new info now */
625 * pointers go into the block we allocated,
626 * memory is | beacon_data | head | tail |
628 new->head
= ((u8
*) new) + sizeof(*new);
629 new->tail
= new->head
+ new_head_len
;
630 new->head_len
= new_head_len
;
631 new->tail_len
= new_tail_len
;
634 new->csa_current_counter
= csa
->count
;
635 memcpy(new->csa_counter_offsets
, csa
->counter_offsets_beacon
,
636 csa
->n_counter_offsets_beacon
*
637 sizeof(new->csa_counter_offsets
[0]));
642 memcpy(new->head
, params
->head
, new_head_len
);
644 memcpy(new->head
, old
->head
, new_head_len
);
646 /* copy in optional tail */
648 memcpy(new->tail
, params
->tail
, new_tail_len
);
651 memcpy(new->tail
, old
->tail
, new_tail_len
);
653 err
= ieee80211_set_probe_resp(sdata
, params
->probe_resp
,
654 params
->probe_resp_len
, csa
);
658 changed
|= BSS_CHANGED_AP_PROBE_RESP
;
660 rcu_assign_pointer(sdata
->u
.ap
.beacon
, new);
663 kfree_rcu(old
, rcu_head
);
668 static int ieee80211_start_ap(struct wiphy
*wiphy
, struct net_device
*dev
,
669 struct cfg80211_ap_settings
*params
)
671 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
672 struct ieee80211_local
*local
= sdata
->local
;
673 struct beacon_data
*old
;
674 struct ieee80211_sub_if_data
*vlan
;
675 u32 changed
= BSS_CHANGED_BEACON_INT
|
676 BSS_CHANGED_BEACON_ENABLED
|
682 old
= sdata_dereference(sdata
->u
.ap
.beacon
, sdata
);
686 switch (params
->smps_mode
) {
687 case NL80211_SMPS_OFF
:
688 sdata
->smps_mode
= IEEE80211_SMPS_OFF
;
690 case NL80211_SMPS_STATIC
:
691 sdata
->smps_mode
= IEEE80211_SMPS_STATIC
;
693 case NL80211_SMPS_DYNAMIC
:
694 sdata
->smps_mode
= IEEE80211_SMPS_DYNAMIC
;
699 sdata
->needed_rx_chains
= sdata
->local
->rx_chains
;
701 mutex_lock(&local
->mtx
);
702 err
= ieee80211_vif_use_channel(sdata
, ¶ms
->chandef
,
703 IEEE80211_CHANCTX_SHARED
);
705 ieee80211_vif_copy_chanctx_to_vlans(sdata
, false);
706 mutex_unlock(&local
->mtx
);
711 * Apply control port protocol, this allows us to
712 * not encrypt dynamic WEP control frames.
714 sdata
->control_port_protocol
= params
->crypto
.control_port_ethertype
;
715 sdata
->control_port_no_encrypt
= params
->crypto
.control_port_no_encrypt
;
716 sdata
->encrypt_headroom
= ieee80211_cs_headroom(sdata
->local
,
720 list_for_each_entry(vlan
, &sdata
->u
.ap
.vlans
, u
.vlan
.list
) {
721 vlan
->control_port_protocol
=
722 params
->crypto
.control_port_ethertype
;
723 vlan
->control_port_no_encrypt
=
724 params
->crypto
.control_port_no_encrypt
;
725 vlan
->encrypt_headroom
=
726 ieee80211_cs_headroom(sdata
->local
,
731 sdata
->vif
.bss_conf
.beacon_int
= params
->beacon_interval
;
732 sdata
->vif
.bss_conf
.dtim_period
= params
->dtim_period
;
733 sdata
->vif
.bss_conf
.enable_beacon
= true;
735 sdata
->vif
.bss_conf
.ssid_len
= params
->ssid_len
;
736 if (params
->ssid_len
)
737 memcpy(sdata
->vif
.bss_conf
.ssid
, params
->ssid
,
739 sdata
->vif
.bss_conf
.hidden_ssid
=
740 (params
->hidden_ssid
!= NL80211_HIDDEN_SSID_NOT_IN_USE
);
742 memset(&sdata
->vif
.bss_conf
.p2p_noa_attr
, 0,
743 sizeof(sdata
->vif
.bss_conf
.p2p_noa_attr
));
744 sdata
->vif
.bss_conf
.p2p_noa_attr
.oppps_ctwindow
=
745 params
->p2p_ctwindow
& IEEE80211_P2P_OPPPS_CTWINDOW_MASK
;
746 if (params
->p2p_opp_ps
)
747 sdata
->vif
.bss_conf
.p2p_noa_attr
.oppps_ctwindow
|=
748 IEEE80211_P2P_OPPPS_ENABLE_BIT
;
750 err
= ieee80211_assign_beacon(sdata
, ¶ms
->beacon
, NULL
);
752 ieee80211_vif_release_channel(sdata
);
757 err
= drv_start_ap(sdata
->local
, sdata
);
759 old
= sdata_dereference(sdata
->u
.ap
.beacon
, sdata
);
762 kfree_rcu(old
, rcu_head
);
763 RCU_INIT_POINTER(sdata
->u
.ap
.beacon
, NULL
);
764 ieee80211_vif_release_channel(sdata
);
768 ieee80211_recalc_dtim(local
, sdata
);
769 ieee80211_bss_info_change_notify(sdata
, changed
);
771 netif_carrier_on(dev
);
772 list_for_each_entry(vlan
, &sdata
->u
.ap
.vlans
, u
.vlan
.list
)
773 netif_carrier_on(vlan
->dev
);
778 static int ieee80211_change_beacon(struct wiphy
*wiphy
, struct net_device
*dev
,
779 struct cfg80211_beacon_data
*params
)
781 struct ieee80211_sub_if_data
*sdata
;
782 struct beacon_data
*old
;
785 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
786 sdata_assert_lock(sdata
);
788 /* don't allow changing the beacon while CSA is in place - offset
789 * of channel switch counter may change
791 if (sdata
->vif
.csa_active
)
794 old
= sdata_dereference(sdata
->u
.ap
.beacon
, sdata
);
798 err
= ieee80211_assign_beacon(sdata
, params
, NULL
);
801 ieee80211_bss_info_change_notify(sdata
, err
);
805 static int ieee80211_stop_ap(struct wiphy
*wiphy
, struct net_device
*dev
)
807 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
808 struct ieee80211_sub_if_data
*vlan
;
809 struct ieee80211_local
*local
= sdata
->local
;
810 struct beacon_data
*old_beacon
;
811 struct probe_resp
*old_probe_resp
;
812 struct cfg80211_chan_def chandef
;
814 sdata_assert_lock(sdata
);
816 old_beacon
= sdata_dereference(sdata
->u
.ap
.beacon
, sdata
);
819 old_probe_resp
= sdata_dereference(sdata
->u
.ap
.probe_resp
, sdata
);
821 /* abort any running channel switch */
822 mutex_lock(&local
->mtx
);
823 sdata
->vif
.csa_active
= false;
824 if (sdata
->csa_block_tx
) {
825 ieee80211_wake_vif_queues(local
, sdata
,
826 IEEE80211_QUEUE_STOP_REASON_CSA
);
827 sdata
->csa_block_tx
= false;
830 mutex_unlock(&local
->mtx
);
832 kfree(sdata
->u
.ap
.next_beacon
);
833 sdata
->u
.ap
.next_beacon
= NULL
;
835 /* turn off carrier for this interface and dependent VLANs */
836 list_for_each_entry(vlan
, &sdata
->u
.ap
.vlans
, u
.vlan
.list
)
837 netif_carrier_off(vlan
->dev
);
838 netif_carrier_off(dev
);
840 /* remove beacon and probe response */
841 RCU_INIT_POINTER(sdata
->u
.ap
.beacon
, NULL
);
842 RCU_INIT_POINTER(sdata
->u
.ap
.probe_resp
, NULL
);
843 kfree_rcu(old_beacon
, rcu_head
);
845 kfree_rcu(old_probe_resp
, rcu_head
);
846 sdata
->u
.ap
.driver_smps_mode
= IEEE80211_SMPS_OFF
;
848 __sta_info_flush(sdata
, true);
849 ieee80211_free_keys(sdata
, true);
851 sdata
->vif
.bss_conf
.enable_beacon
= false;
852 sdata
->vif
.bss_conf
.ssid_len
= 0;
853 clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED
, &sdata
->state
);
854 ieee80211_bss_info_change_notify(sdata
, BSS_CHANGED_BEACON_ENABLED
);
856 if (sdata
->wdev
.cac_started
) {
857 chandef
= sdata
->vif
.bss_conf
.chandef
;
858 cancel_delayed_work_sync(&sdata
->dfs_cac_timer_work
);
859 cfg80211_cac_event(sdata
->dev
, &chandef
,
860 NL80211_RADAR_CAC_ABORTED
,
864 drv_stop_ap(sdata
->local
, sdata
);
866 /* free all potentially still buffered bcast frames */
867 local
->total_ps_buffered
-= skb_queue_len(&sdata
->u
.ap
.ps
.bc_buf
);
868 skb_queue_purge(&sdata
->u
.ap
.ps
.bc_buf
);
870 mutex_lock(&local
->mtx
);
871 ieee80211_vif_copy_chanctx_to_vlans(sdata
, true);
872 ieee80211_vif_release_channel(sdata
);
873 mutex_unlock(&local
->mtx
);
878 /* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */
879 struct iapp_layer2_update
{
880 u8 da
[ETH_ALEN
]; /* broadcast */
881 u8 sa
[ETH_ALEN
]; /* STA addr */
889 static void ieee80211_send_layer2_update(struct sta_info
*sta
)
891 struct iapp_layer2_update
*msg
;
894 /* Send Level 2 Update Frame to update forwarding tables in layer 2
897 skb
= dev_alloc_skb(sizeof(*msg
));
900 msg
= (struct iapp_layer2_update
*)skb_put(skb
, sizeof(*msg
));
902 /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID)
903 * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */
905 eth_broadcast_addr(msg
->da
);
906 memcpy(msg
->sa
, sta
->sta
.addr
, ETH_ALEN
);
909 msg
->ssap
= 0x01; /* NULL LSAP, CR Bit: Response */
910 msg
->control
= 0xaf; /* XID response lsb.1111F101.
911 * F=0 (no poll command; unsolicited frame) */
912 msg
->xid_info
[0] = 0x81; /* XID format identifier */
913 msg
->xid_info
[1] = 1; /* LLC types/classes: Type 1 LLC */
914 msg
->xid_info
[2] = 0; /* XID sender's receive window size (RW) */
916 skb
->dev
= sta
->sdata
->dev
;
917 skb
->protocol
= eth_type_trans(skb
, sta
->sdata
->dev
);
918 memset(skb
->cb
, 0, sizeof(skb
->cb
));
922 static int sta_apply_auth_flags(struct ieee80211_local
*local
,
923 struct sta_info
*sta
,
928 if (mask
& BIT(NL80211_STA_FLAG_AUTHENTICATED
) &&
929 set
& BIT(NL80211_STA_FLAG_AUTHENTICATED
) &&
930 !test_sta_flag(sta
, WLAN_STA_AUTH
)) {
931 ret
= sta_info_move_state(sta
, IEEE80211_STA_AUTH
);
936 if (mask
& BIT(NL80211_STA_FLAG_ASSOCIATED
) &&
937 set
& BIT(NL80211_STA_FLAG_ASSOCIATED
) &&
938 !test_sta_flag(sta
, WLAN_STA_ASSOC
)) {
939 ret
= sta_info_move_state(sta
, IEEE80211_STA_ASSOC
);
944 if (mask
& BIT(NL80211_STA_FLAG_AUTHORIZED
)) {
945 if (set
& BIT(NL80211_STA_FLAG_AUTHORIZED
))
946 ret
= sta_info_move_state(sta
, IEEE80211_STA_AUTHORIZED
);
947 else if (test_sta_flag(sta
, WLAN_STA_AUTHORIZED
))
948 ret
= sta_info_move_state(sta
, IEEE80211_STA_ASSOC
);
955 if (mask
& BIT(NL80211_STA_FLAG_ASSOCIATED
) &&
956 !(set
& BIT(NL80211_STA_FLAG_ASSOCIATED
)) &&
957 test_sta_flag(sta
, WLAN_STA_ASSOC
)) {
958 ret
= sta_info_move_state(sta
, IEEE80211_STA_AUTH
);
963 if (mask
& BIT(NL80211_STA_FLAG_AUTHENTICATED
) &&
964 !(set
& BIT(NL80211_STA_FLAG_AUTHENTICATED
)) &&
965 test_sta_flag(sta
, WLAN_STA_AUTH
)) {
966 ret
= sta_info_move_state(sta
, IEEE80211_STA_NONE
);
974 static int sta_apply_parameters(struct ieee80211_local
*local
,
975 struct sta_info
*sta
,
976 struct station_parameters
*params
)
979 struct ieee80211_supported_band
*sband
;
980 struct ieee80211_sub_if_data
*sdata
= sta
->sdata
;
981 enum ieee80211_band band
= ieee80211_get_sdata_band(sdata
);
984 sband
= local
->hw
.wiphy
->bands
[band
];
986 mask
= params
->sta_flags_mask
;
987 set
= params
->sta_flags_set
;
989 if (ieee80211_vif_is_mesh(&sdata
->vif
)) {
991 * In mesh mode, ASSOCIATED isn't part of the nl80211
992 * API but must follow AUTHENTICATED for driver state.
994 if (mask
& BIT(NL80211_STA_FLAG_AUTHENTICATED
))
995 mask
|= BIT(NL80211_STA_FLAG_ASSOCIATED
);
996 if (set
& BIT(NL80211_STA_FLAG_AUTHENTICATED
))
997 set
|= BIT(NL80211_STA_FLAG_ASSOCIATED
);
998 } else if (test_sta_flag(sta
, WLAN_STA_TDLS_PEER
)) {
1000 * TDLS -- everything follows authorized, but
1001 * only becoming authorized is possible, not
1004 if (set
& BIT(NL80211_STA_FLAG_AUTHORIZED
)) {
1005 set
|= BIT(NL80211_STA_FLAG_AUTHENTICATED
) |
1006 BIT(NL80211_STA_FLAG_ASSOCIATED
);
1007 mask
|= BIT(NL80211_STA_FLAG_AUTHENTICATED
) |
1008 BIT(NL80211_STA_FLAG_ASSOCIATED
);
1012 /* auth flags will be set later for TDLS stations */
1013 if (!test_sta_flag(sta
, WLAN_STA_TDLS_PEER
)) {
1014 ret
= sta_apply_auth_flags(local
, sta
, mask
, set
);
1019 if (mask
& BIT(NL80211_STA_FLAG_SHORT_PREAMBLE
)) {
1020 if (set
& BIT(NL80211_STA_FLAG_SHORT_PREAMBLE
))
1021 set_sta_flag(sta
, WLAN_STA_SHORT_PREAMBLE
);
1023 clear_sta_flag(sta
, WLAN_STA_SHORT_PREAMBLE
);
1026 if (mask
& BIT(NL80211_STA_FLAG_WME
))
1027 sta
->sta
.wme
= set
& BIT(NL80211_STA_FLAG_WME
);
1029 if (mask
& BIT(NL80211_STA_FLAG_MFP
)) {
1030 if (set
& BIT(NL80211_STA_FLAG_MFP
))
1031 set_sta_flag(sta
, WLAN_STA_MFP
);
1033 clear_sta_flag(sta
, WLAN_STA_MFP
);
1036 if (mask
& BIT(NL80211_STA_FLAG_TDLS_PEER
)) {
1037 if (set
& BIT(NL80211_STA_FLAG_TDLS_PEER
))
1038 set_sta_flag(sta
, WLAN_STA_TDLS_PEER
);
1040 clear_sta_flag(sta
, WLAN_STA_TDLS_PEER
);
1043 if (params
->sta_modify_mask
& STATION_PARAM_APPLY_UAPSD
) {
1044 sta
->sta
.uapsd_queues
= params
->uapsd_queues
;
1045 sta
->sta
.max_sp
= params
->max_sp
;
1049 * cfg80211 validates this (1-2007) and allows setting the AID
1050 * only when creating a new station entry
1053 sta
->sta
.aid
= params
->aid
;
1056 * Some of the following updates would be racy if called on an
1057 * existing station, via ieee80211_change_station(). However,
1058 * all such changes are rejected by cfg80211 except for updates
1059 * changing the supported rates on an existing but not yet used
1063 if (params
->listen_interval
>= 0)
1064 sta
->listen_interval
= params
->listen_interval
;
1066 if (params
->supported_rates
) {
1067 ieee80211_parse_bitrates(&sdata
->vif
.bss_conf
.chandef
,
1068 sband
, params
->supported_rates
,
1069 params
->supported_rates_len
,
1070 &sta
->sta
.supp_rates
[band
]);
1073 if (params
->ht_capa
)
1074 ieee80211_ht_cap_ie_to_sta_ht_cap(sdata
, sband
,
1075 params
->ht_capa
, sta
);
1077 if (params
->vht_capa
)
1078 ieee80211_vht_cap_ie_to_sta_vht_cap(sdata
, sband
,
1079 params
->vht_capa
, sta
);
1081 if (params
->opmode_notif_used
) {
1082 /* returned value is only needed for rc update, but the
1083 * rc isn't initialized here yet, so ignore it
1085 __ieee80211_vht_handle_opmode(sdata
, sta
,
1086 params
->opmode_notif
,
1090 if (ieee80211_vif_is_mesh(&sdata
->vif
)) {
1091 #ifdef CONFIG_MAC80211_MESH
1094 if (params
->sta_modify_mask
& STATION_PARAM_APPLY_PLINK_STATE
) {
1095 switch (params
->plink_state
) {
1096 case NL80211_PLINK_ESTAB
:
1097 if (sta
->plink_state
!= NL80211_PLINK_ESTAB
)
1098 changed
= mesh_plink_inc_estab_count(
1100 sta
->plink_state
= params
->plink_state
;
1102 ieee80211_mps_sta_status_update(sta
);
1103 changed
|= ieee80211_mps_set_sta_local_pm(sta
,
1104 sdata
->u
.mesh
.mshcfg
.power_mode
);
1106 case NL80211_PLINK_LISTEN
:
1107 case NL80211_PLINK_BLOCKED
:
1108 case NL80211_PLINK_OPN_SNT
:
1109 case NL80211_PLINK_OPN_RCVD
:
1110 case NL80211_PLINK_CNF_RCVD
:
1111 case NL80211_PLINK_HOLDING
:
1112 if (sta
->plink_state
== NL80211_PLINK_ESTAB
)
1113 changed
= mesh_plink_dec_estab_count(
1115 sta
->plink_state
= params
->plink_state
;
1117 ieee80211_mps_sta_status_update(sta
);
1118 changed
|= ieee80211_mps_set_sta_local_pm(sta
,
1119 NL80211_MESH_POWER_UNKNOWN
);
1127 switch (params
->plink_action
) {
1128 case NL80211_PLINK_ACTION_NO_ACTION
:
1131 case NL80211_PLINK_ACTION_OPEN
:
1132 changed
|= mesh_plink_open(sta
);
1134 case NL80211_PLINK_ACTION_BLOCK
:
1135 changed
|= mesh_plink_block(sta
);
1139 if (params
->local_pm
)
1141 ieee80211_mps_set_sta_local_pm(sta
,
1143 ieee80211_mbss_info_change_notify(sdata
, changed
);
1147 /* set the STA state after all sta info from usermode has been set */
1148 if (test_sta_flag(sta
, WLAN_STA_TDLS_PEER
)) {
1149 ret
= sta_apply_auth_flags(local
, sta
, mask
, set
);
1157 static int ieee80211_add_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1159 struct station_parameters
*params
)
1161 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
1162 struct sta_info
*sta
;
1163 struct ieee80211_sub_if_data
*sdata
;
1168 sdata
= IEEE80211_DEV_TO_SUB_IF(params
->vlan
);
1170 if (sdata
->vif
.type
!= NL80211_IFTYPE_AP_VLAN
&&
1171 sdata
->vif
.type
!= NL80211_IFTYPE_AP
)
1174 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1176 if (ether_addr_equal(mac
, sdata
->vif
.addr
))
1179 if (is_multicast_ether_addr(mac
))
1182 sta
= sta_info_alloc(sdata
, mac
, GFP_KERNEL
);
1187 * defaults -- if userspace wants something else we'll
1188 * change it accordingly in sta_apply_parameters()
1190 if (!(params
->sta_flags_set
& BIT(NL80211_STA_FLAG_TDLS_PEER
))) {
1191 sta_info_pre_move_state(sta
, IEEE80211_STA_AUTH
);
1192 sta_info_pre_move_state(sta
, IEEE80211_STA_ASSOC
);
1194 sta
->sta
.tdls
= true;
1197 err
= sta_apply_parameters(local
, sta
, params
);
1199 sta_info_free(local
, sta
);
1204 * for TDLS, rate control should be initialized only when
1205 * rates are known and station is marked authorized
1207 if (!test_sta_flag(sta
, WLAN_STA_TDLS_PEER
))
1208 rate_control_rate_init(sta
);
1210 layer2_update
= sdata
->vif
.type
== NL80211_IFTYPE_AP_VLAN
||
1211 sdata
->vif
.type
== NL80211_IFTYPE_AP
;
1213 err
= sta_info_insert_rcu(sta
);
1220 ieee80211_send_layer2_update(sta
);
1227 static int ieee80211_del_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1230 struct ieee80211_sub_if_data
*sdata
;
1232 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1235 return sta_info_destroy_addr_bss(sdata
, mac
);
1237 sta_info_flush(sdata
);
1241 static int ieee80211_change_station(struct wiphy
*wiphy
,
1242 struct net_device
*dev
, const u8
*mac
,
1243 struct station_parameters
*params
)
1245 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1246 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
1247 struct sta_info
*sta
;
1248 struct ieee80211_sub_if_data
*vlansdata
;
1249 enum cfg80211_station_type statype
;
1252 mutex_lock(&local
->sta_mtx
);
1254 sta
= sta_info_get_bss(sdata
, mac
);
1260 switch (sdata
->vif
.type
) {
1261 case NL80211_IFTYPE_MESH_POINT
:
1262 if (sdata
->u
.mesh
.user_mpm
)
1263 statype
= CFG80211_STA_MESH_PEER_USER
;
1265 statype
= CFG80211_STA_MESH_PEER_KERNEL
;
1267 case NL80211_IFTYPE_ADHOC
:
1268 statype
= CFG80211_STA_IBSS
;
1270 case NL80211_IFTYPE_STATION
:
1271 if (!test_sta_flag(sta
, WLAN_STA_TDLS_PEER
)) {
1272 statype
= CFG80211_STA_AP_STA
;
1275 if (test_sta_flag(sta
, WLAN_STA_AUTHORIZED
))
1276 statype
= CFG80211_STA_TDLS_PEER_ACTIVE
;
1278 statype
= CFG80211_STA_TDLS_PEER_SETUP
;
1280 case NL80211_IFTYPE_AP
:
1281 case NL80211_IFTYPE_AP_VLAN
:
1282 statype
= CFG80211_STA_AP_CLIENT
;
1289 err
= cfg80211_check_station_change(wiphy
, params
, statype
);
1293 if (params
->vlan
&& params
->vlan
!= sta
->sdata
->dev
) {
1294 bool prev_4addr
= false;
1295 bool new_4addr
= false;
1297 vlansdata
= IEEE80211_DEV_TO_SUB_IF(params
->vlan
);
1299 if (params
->vlan
->ieee80211_ptr
->use_4addr
) {
1300 if (vlansdata
->u
.vlan
.sta
) {
1305 rcu_assign_pointer(vlansdata
->u
.vlan
.sta
, sta
);
1309 if (sta
->sdata
->vif
.type
== NL80211_IFTYPE_AP_VLAN
&&
1310 sta
->sdata
->u
.vlan
.sta
) {
1311 RCU_INIT_POINTER(sta
->sdata
->u
.vlan
.sta
, NULL
);
1315 sta
->sdata
= vlansdata
;
1317 if (sta
->sta_state
== IEEE80211_STA_AUTHORIZED
&&
1318 prev_4addr
!= new_4addr
) {
1320 atomic_dec(&sta
->sdata
->bss
->num_mcast_sta
);
1322 atomic_inc(&sta
->sdata
->bss
->num_mcast_sta
);
1325 ieee80211_send_layer2_update(sta
);
1328 err
= sta_apply_parameters(local
, sta
, params
);
1332 /* When peer becomes authorized, init rate control as well */
1333 if (test_sta_flag(sta
, WLAN_STA_TDLS_PEER
) &&
1334 test_sta_flag(sta
, WLAN_STA_AUTHORIZED
))
1335 rate_control_rate_init(sta
);
1337 mutex_unlock(&local
->sta_mtx
);
1339 if ((sdata
->vif
.type
== NL80211_IFTYPE_AP
||
1340 sdata
->vif
.type
== NL80211_IFTYPE_AP_VLAN
) &&
1341 sta
->known_smps_mode
!= sta
->sdata
->bss
->req_smps
&&
1342 test_sta_flag(sta
, WLAN_STA_AUTHORIZED
) &&
1343 sta_info_tx_streams(sta
) != 1) {
1345 "%pM just authorized and MIMO capable - update SMPS\n",
1347 ieee80211_send_smps_action(sta
->sdata
,
1348 sta
->sdata
->bss
->req_smps
,
1350 sta
->sdata
->vif
.bss_conf
.bssid
);
1353 if (sdata
->vif
.type
== NL80211_IFTYPE_STATION
&&
1354 params
->sta_flags_mask
& BIT(NL80211_STA_FLAG_AUTHORIZED
)) {
1355 ieee80211_recalc_ps(local
, -1);
1356 ieee80211_recalc_ps_vif(sdata
);
1361 mutex_unlock(&local
->sta_mtx
);
1365 #ifdef CONFIG_MAC80211_MESH
1366 static int ieee80211_add_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
1367 const u8
*dst
, const u8
*next_hop
)
1369 struct ieee80211_sub_if_data
*sdata
;
1370 struct mesh_path
*mpath
;
1371 struct sta_info
*sta
;
1373 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1376 sta
= sta_info_get(sdata
, next_hop
);
1382 mpath
= mesh_path_add(sdata
, dst
);
1383 if (IS_ERR(mpath
)) {
1385 return PTR_ERR(mpath
);
1388 mesh_path_fix_nexthop(mpath
, sta
);
1394 static int ieee80211_del_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
1397 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1400 return mesh_path_del(sdata
, dst
);
1402 mesh_path_flush_by_iface(sdata
);
1406 static int ieee80211_change_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
1407 const u8
*dst
, const u8
*next_hop
)
1409 struct ieee80211_sub_if_data
*sdata
;
1410 struct mesh_path
*mpath
;
1411 struct sta_info
*sta
;
1413 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1417 sta
= sta_info_get(sdata
, next_hop
);
1423 mpath
= mesh_path_lookup(sdata
, dst
);
1429 mesh_path_fix_nexthop(mpath
, sta
);
1435 static void mpath_set_pinfo(struct mesh_path
*mpath
, u8
*next_hop
,
1436 struct mpath_info
*pinfo
)
1438 struct sta_info
*next_hop_sta
= rcu_dereference(mpath
->next_hop
);
1441 memcpy(next_hop
, next_hop_sta
->sta
.addr
, ETH_ALEN
);
1443 memset(next_hop
, 0, ETH_ALEN
);
1445 memset(pinfo
, 0, sizeof(*pinfo
));
1447 pinfo
->generation
= mesh_paths_generation
;
1449 pinfo
->filled
= MPATH_INFO_FRAME_QLEN
|
1452 MPATH_INFO_EXPTIME
|
1453 MPATH_INFO_DISCOVERY_TIMEOUT
|
1454 MPATH_INFO_DISCOVERY_RETRIES
|
1457 pinfo
->frame_qlen
= mpath
->frame_queue
.qlen
;
1458 pinfo
->sn
= mpath
->sn
;
1459 pinfo
->metric
= mpath
->metric
;
1460 if (time_before(jiffies
, mpath
->exp_time
))
1461 pinfo
->exptime
= jiffies_to_msecs(mpath
->exp_time
- jiffies
);
1462 pinfo
->discovery_timeout
=
1463 jiffies_to_msecs(mpath
->discovery_timeout
);
1464 pinfo
->discovery_retries
= mpath
->discovery_retries
;
1465 if (mpath
->flags
& MESH_PATH_ACTIVE
)
1466 pinfo
->flags
|= NL80211_MPATH_FLAG_ACTIVE
;
1467 if (mpath
->flags
& MESH_PATH_RESOLVING
)
1468 pinfo
->flags
|= NL80211_MPATH_FLAG_RESOLVING
;
1469 if (mpath
->flags
& MESH_PATH_SN_VALID
)
1470 pinfo
->flags
|= NL80211_MPATH_FLAG_SN_VALID
;
1471 if (mpath
->flags
& MESH_PATH_FIXED
)
1472 pinfo
->flags
|= NL80211_MPATH_FLAG_FIXED
;
1473 if (mpath
->flags
& MESH_PATH_RESOLVED
)
1474 pinfo
->flags
|= NL80211_MPATH_FLAG_RESOLVED
;
1477 static int ieee80211_get_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
1478 u8
*dst
, u8
*next_hop
, struct mpath_info
*pinfo
)
1481 struct ieee80211_sub_if_data
*sdata
;
1482 struct mesh_path
*mpath
;
1484 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1487 mpath
= mesh_path_lookup(sdata
, dst
);
1492 memcpy(dst
, mpath
->dst
, ETH_ALEN
);
1493 mpath_set_pinfo(mpath
, next_hop
, pinfo
);
1498 static int ieee80211_dump_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
1499 int idx
, u8
*dst
, u8
*next_hop
,
1500 struct mpath_info
*pinfo
)
1502 struct ieee80211_sub_if_data
*sdata
;
1503 struct mesh_path
*mpath
;
1505 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1508 mpath
= mesh_path_lookup_by_idx(sdata
, idx
);
1513 memcpy(dst
, mpath
->dst
, ETH_ALEN
);
1514 mpath_set_pinfo(mpath
, next_hop
, pinfo
);
1519 static void mpp_set_pinfo(struct mesh_path
*mpath
, u8
*mpp
,
1520 struct mpath_info
*pinfo
)
1522 memset(pinfo
, 0, sizeof(*pinfo
));
1523 memcpy(mpp
, mpath
->mpp
, ETH_ALEN
);
1525 pinfo
->generation
= mpp_paths_generation
;
1528 static int ieee80211_get_mpp(struct wiphy
*wiphy
, struct net_device
*dev
,
1529 u8
*dst
, u8
*mpp
, struct mpath_info
*pinfo
)
1532 struct ieee80211_sub_if_data
*sdata
;
1533 struct mesh_path
*mpath
;
1535 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1538 mpath
= mpp_path_lookup(sdata
, dst
);
1543 memcpy(dst
, mpath
->dst
, ETH_ALEN
);
1544 mpp_set_pinfo(mpath
, mpp
, pinfo
);
1549 static int ieee80211_dump_mpp(struct wiphy
*wiphy
, struct net_device
*dev
,
1550 int idx
, u8
*dst
, u8
*mpp
,
1551 struct mpath_info
*pinfo
)
1553 struct ieee80211_sub_if_data
*sdata
;
1554 struct mesh_path
*mpath
;
1556 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1559 mpath
= mpp_path_lookup_by_idx(sdata
, idx
);
1564 memcpy(dst
, mpath
->dst
, ETH_ALEN
);
1565 mpp_set_pinfo(mpath
, mpp
, pinfo
);
1570 static int ieee80211_get_mesh_config(struct wiphy
*wiphy
,
1571 struct net_device
*dev
,
1572 struct mesh_config
*conf
)
1574 struct ieee80211_sub_if_data
*sdata
;
1575 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1577 memcpy(conf
, &(sdata
->u
.mesh
.mshcfg
), sizeof(struct mesh_config
));
1581 static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm
, u32 mask
)
1583 return (mask
>> (parm
-1)) & 0x1;
1586 static int copy_mesh_setup(struct ieee80211_if_mesh
*ifmsh
,
1587 const struct mesh_setup
*setup
)
1591 struct ieee80211_sub_if_data
*sdata
= container_of(ifmsh
,
1592 struct ieee80211_sub_if_data
, u
.mesh
);
1594 /* allocate information elements */
1598 if (setup
->ie_len
) {
1599 new_ie
= kmemdup(setup
->ie
, setup
->ie_len
,
1604 ifmsh
->ie_len
= setup
->ie_len
;
1608 /* now copy the rest of the setup parameters */
1609 ifmsh
->mesh_id_len
= setup
->mesh_id_len
;
1610 memcpy(ifmsh
->mesh_id
, setup
->mesh_id
, ifmsh
->mesh_id_len
);
1611 ifmsh
->mesh_sp_id
= setup
->sync_method
;
1612 ifmsh
->mesh_pp_id
= setup
->path_sel_proto
;
1613 ifmsh
->mesh_pm_id
= setup
->path_metric
;
1614 ifmsh
->user_mpm
= setup
->user_mpm
;
1615 ifmsh
->mesh_auth_id
= setup
->auth_id
;
1616 ifmsh
->security
= IEEE80211_MESH_SEC_NONE
;
1617 if (setup
->is_authenticated
)
1618 ifmsh
->security
|= IEEE80211_MESH_SEC_AUTHED
;
1619 if (setup
->is_secure
)
1620 ifmsh
->security
|= IEEE80211_MESH_SEC_SECURED
;
1622 /* mcast rate setting in Mesh Node */
1623 memcpy(sdata
->vif
.bss_conf
.mcast_rate
, setup
->mcast_rate
,
1624 sizeof(setup
->mcast_rate
));
1625 sdata
->vif
.bss_conf
.basic_rates
= setup
->basic_rates
;
1627 sdata
->vif
.bss_conf
.beacon_int
= setup
->beacon_interval
;
1628 sdata
->vif
.bss_conf
.dtim_period
= setup
->dtim_period
;
1633 static int ieee80211_update_mesh_config(struct wiphy
*wiphy
,
1634 struct net_device
*dev
, u32 mask
,
1635 const struct mesh_config
*nconf
)
1637 struct mesh_config
*conf
;
1638 struct ieee80211_sub_if_data
*sdata
;
1639 struct ieee80211_if_mesh
*ifmsh
;
1641 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1642 ifmsh
= &sdata
->u
.mesh
;
1644 /* Set the config options which we are interested in setting */
1645 conf
= &(sdata
->u
.mesh
.mshcfg
);
1646 if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT
, mask
))
1647 conf
->dot11MeshRetryTimeout
= nconf
->dot11MeshRetryTimeout
;
1648 if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT
, mask
))
1649 conf
->dot11MeshConfirmTimeout
= nconf
->dot11MeshConfirmTimeout
;
1650 if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT
, mask
))
1651 conf
->dot11MeshHoldingTimeout
= nconf
->dot11MeshHoldingTimeout
;
1652 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS
, mask
))
1653 conf
->dot11MeshMaxPeerLinks
= nconf
->dot11MeshMaxPeerLinks
;
1654 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES
, mask
))
1655 conf
->dot11MeshMaxRetries
= nconf
->dot11MeshMaxRetries
;
1656 if (_chg_mesh_attr(NL80211_MESHCONF_TTL
, mask
))
1657 conf
->dot11MeshTTL
= nconf
->dot11MeshTTL
;
1658 if (_chg_mesh_attr(NL80211_MESHCONF_ELEMENT_TTL
, mask
))
1659 conf
->element_ttl
= nconf
->element_ttl
;
1660 if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS
, mask
)) {
1661 if (ifmsh
->user_mpm
)
1663 conf
->auto_open_plinks
= nconf
->auto_open_plinks
;
1665 if (_chg_mesh_attr(NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR
, mask
))
1666 conf
->dot11MeshNbrOffsetMaxNeighbor
=
1667 nconf
->dot11MeshNbrOffsetMaxNeighbor
;
1668 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES
, mask
))
1669 conf
->dot11MeshHWMPmaxPREQretries
=
1670 nconf
->dot11MeshHWMPmaxPREQretries
;
1671 if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME
, mask
))
1672 conf
->path_refresh_time
= nconf
->path_refresh_time
;
1673 if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT
, mask
))
1674 conf
->min_discovery_timeout
= nconf
->min_discovery_timeout
;
1675 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT
, mask
))
1676 conf
->dot11MeshHWMPactivePathTimeout
=
1677 nconf
->dot11MeshHWMPactivePathTimeout
;
1678 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL
, mask
))
1679 conf
->dot11MeshHWMPpreqMinInterval
=
1680 nconf
->dot11MeshHWMPpreqMinInterval
;
1681 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL
, mask
))
1682 conf
->dot11MeshHWMPperrMinInterval
=
1683 nconf
->dot11MeshHWMPperrMinInterval
;
1684 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME
,
1686 conf
->dot11MeshHWMPnetDiameterTraversalTime
=
1687 nconf
->dot11MeshHWMPnetDiameterTraversalTime
;
1688 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOTMODE
, mask
)) {
1689 conf
->dot11MeshHWMPRootMode
= nconf
->dot11MeshHWMPRootMode
;
1690 ieee80211_mesh_root_setup(ifmsh
);
1692 if (_chg_mesh_attr(NL80211_MESHCONF_GATE_ANNOUNCEMENTS
, mask
)) {
1693 /* our current gate announcement implementation rides on root
1694 * announcements, so require this ifmsh to also be a root node
1696 if (nconf
->dot11MeshGateAnnouncementProtocol
&&
1697 !(conf
->dot11MeshHWMPRootMode
> IEEE80211_ROOTMODE_ROOT
)) {
1698 conf
->dot11MeshHWMPRootMode
= IEEE80211_PROACTIVE_RANN
;
1699 ieee80211_mesh_root_setup(ifmsh
);
1701 conf
->dot11MeshGateAnnouncementProtocol
=
1702 nconf
->dot11MeshGateAnnouncementProtocol
;
1704 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_RANN_INTERVAL
, mask
))
1705 conf
->dot11MeshHWMPRannInterval
=
1706 nconf
->dot11MeshHWMPRannInterval
;
1707 if (_chg_mesh_attr(NL80211_MESHCONF_FORWARDING
, mask
))
1708 conf
->dot11MeshForwarding
= nconf
->dot11MeshForwarding
;
1709 if (_chg_mesh_attr(NL80211_MESHCONF_RSSI_THRESHOLD
, mask
)) {
1710 /* our RSSI threshold implementation is supported only for
1711 * devices that report signal in dBm.
1713 if (!(sdata
->local
->hw
.flags
& IEEE80211_HW_SIGNAL_DBM
))
1715 conf
->rssi_threshold
= nconf
->rssi_threshold
;
1717 if (_chg_mesh_attr(NL80211_MESHCONF_HT_OPMODE
, mask
)) {
1718 conf
->ht_opmode
= nconf
->ht_opmode
;
1719 sdata
->vif
.bss_conf
.ht_operation_mode
= nconf
->ht_opmode
;
1720 ieee80211_bss_info_change_notify(sdata
, BSS_CHANGED_HT
);
1722 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT
, mask
))
1723 conf
->dot11MeshHWMPactivePathToRootTimeout
=
1724 nconf
->dot11MeshHWMPactivePathToRootTimeout
;
1725 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOT_INTERVAL
, mask
))
1726 conf
->dot11MeshHWMProotInterval
=
1727 nconf
->dot11MeshHWMProotInterval
;
1728 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL
, mask
))
1729 conf
->dot11MeshHWMPconfirmationInterval
=
1730 nconf
->dot11MeshHWMPconfirmationInterval
;
1731 if (_chg_mesh_attr(NL80211_MESHCONF_POWER_MODE
, mask
)) {
1732 conf
->power_mode
= nconf
->power_mode
;
1733 ieee80211_mps_local_status_update(sdata
);
1735 if (_chg_mesh_attr(NL80211_MESHCONF_AWAKE_WINDOW
, mask
))
1736 conf
->dot11MeshAwakeWindowDuration
=
1737 nconf
->dot11MeshAwakeWindowDuration
;
1738 if (_chg_mesh_attr(NL80211_MESHCONF_PLINK_TIMEOUT
, mask
))
1739 conf
->plink_timeout
= nconf
->plink_timeout
;
1740 ieee80211_mbss_info_change_notify(sdata
, BSS_CHANGED_BEACON
);
1744 static int ieee80211_join_mesh(struct wiphy
*wiphy
, struct net_device
*dev
,
1745 const struct mesh_config
*conf
,
1746 const struct mesh_setup
*setup
)
1748 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1749 struct ieee80211_if_mesh
*ifmsh
= &sdata
->u
.mesh
;
1752 memcpy(&ifmsh
->mshcfg
, conf
, sizeof(struct mesh_config
));
1753 err
= copy_mesh_setup(ifmsh
, setup
);
1757 /* can mesh use other SMPS modes? */
1758 sdata
->smps_mode
= IEEE80211_SMPS_OFF
;
1759 sdata
->needed_rx_chains
= sdata
->local
->rx_chains
;
1761 mutex_lock(&sdata
->local
->mtx
);
1762 err
= ieee80211_vif_use_channel(sdata
, &setup
->chandef
,
1763 IEEE80211_CHANCTX_SHARED
);
1764 mutex_unlock(&sdata
->local
->mtx
);
1768 return ieee80211_start_mesh(sdata
);
1771 static int ieee80211_leave_mesh(struct wiphy
*wiphy
, struct net_device
*dev
)
1773 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1775 ieee80211_stop_mesh(sdata
);
1776 mutex_lock(&sdata
->local
->mtx
);
1777 ieee80211_vif_release_channel(sdata
);
1778 mutex_unlock(&sdata
->local
->mtx
);
1784 static int ieee80211_change_bss(struct wiphy
*wiphy
,
1785 struct net_device
*dev
,
1786 struct bss_parameters
*params
)
1788 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1789 enum ieee80211_band band
;
1792 if (!sdata_dereference(sdata
->u
.ap
.beacon
, sdata
))
1795 band
= ieee80211_get_sdata_band(sdata
);
1797 if (params
->use_cts_prot
>= 0) {
1798 sdata
->vif
.bss_conf
.use_cts_prot
= params
->use_cts_prot
;
1799 changed
|= BSS_CHANGED_ERP_CTS_PROT
;
1801 if (params
->use_short_preamble
>= 0) {
1802 sdata
->vif
.bss_conf
.use_short_preamble
=
1803 params
->use_short_preamble
;
1804 changed
|= BSS_CHANGED_ERP_PREAMBLE
;
1807 if (!sdata
->vif
.bss_conf
.use_short_slot
&&
1808 band
== IEEE80211_BAND_5GHZ
) {
1809 sdata
->vif
.bss_conf
.use_short_slot
= true;
1810 changed
|= BSS_CHANGED_ERP_SLOT
;
1813 if (params
->use_short_slot_time
>= 0) {
1814 sdata
->vif
.bss_conf
.use_short_slot
=
1815 params
->use_short_slot_time
;
1816 changed
|= BSS_CHANGED_ERP_SLOT
;
1819 if (params
->basic_rates
) {
1820 ieee80211_parse_bitrates(&sdata
->vif
.bss_conf
.chandef
,
1822 params
->basic_rates
,
1823 params
->basic_rates_len
,
1824 &sdata
->vif
.bss_conf
.basic_rates
);
1825 changed
|= BSS_CHANGED_BASIC_RATES
;
1828 if (params
->ap_isolate
>= 0) {
1829 if (params
->ap_isolate
)
1830 sdata
->flags
|= IEEE80211_SDATA_DONT_BRIDGE_PACKETS
;
1832 sdata
->flags
&= ~IEEE80211_SDATA_DONT_BRIDGE_PACKETS
;
1835 if (params
->ht_opmode
>= 0) {
1836 sdata
->vif
.bss_conf
.ht_operation_mode
=
1837 (u16
) params
->ht_opmode
;
1838 changed
|= BSS_CHANGED_HT
;
1841 if (params
->p2p_ctwindow
>= 0) {
1842 sdata
->vif
.bss_conf
.p2p_noa_attr
.oppps_ctwindow
&=
1843 ~IEEE80211_P2P_OPPPS_CTWINDOW_MASK
;
1844 sdata
->vif
.bss_conf
.p2p_noa_attr
.oppps_ctwindow
|=
1845 params
->p2p_ctwindow
& IEEE80211_P2P_OPPPS_CTWINDOW_MASK
;
1846 changed
|= BSS_CHANGED_P2P_PS
;
1849 if (params
->p2p_opp_ps
> 0) {
1850 sdata
->vif
.bss_conf
.p2p_noa_attr
.oppps_ctwindow
|=
1851 IEEE80211_P2P_OPPPS_ENABLE_BIT
;
1852 changed
|= BSS_CHANGED_P2P_PS
;
1853 } else if (params
->p2p_opp_ps
== 0) {
1854 sdata
->vif
.bss_conf
.p2p_noa_attr
.oppps_ctwindow
&=
1855 ~IEEE80211_P2P_OPPPS_ENABLE_BIT
;
1856 changed
|= BSS_CHANGED_P2P_PS
;
1859 ieee80211_bss_info_change_notify(sdata
, changed
);
1864 static int ieee80211_set_txq_params(struct wiphy
*wiphy
,
1865 struct net_device
*dev
,
1866 struct ieee80211_txq_params
*params
)
1868 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
1869 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1870 struct ieee80211_tx_queue_params p
;
1872 if (!local
->ops
->conf_tx
)
1875 if (local
->hw
.queues
< IEEE80211_NUM_ACS
)
1878 memset(&p
, 0, sizeof(p
));
1879 p
.aifs
= params
->aifs
;
1880 p
.cw_max
= params
->cwmax
;
1881 p
.cw_min
= params
->cwmin
;
1882 p
.txop
= params
->txop
;
1885 * Setting tx queue params disables u-apsd because it's only
1886 * called in master mode.
1890 sdata
->tx_conf
[params
->ac
] = p
;
1891 if (drv_conf_tx(local
, sdata
, params
->ac
, &p
)) {
1892 wiphy_debug(local
->hw
.wiphy
,
1893 "failed to set TX queue parameters for AC %d\n",
1898 ieee80211_bss_info_change_notify(sdata
, BSS_CHANGED_QOS
);
1904 static int ieee80211_suspend(struct wiphy
*wiphy
,
1905 struct cfg80211_wowlan
*wowlan
)
1907 return __ieee80211_suspend(wiphy_priv(wiphy
), wowlan
);
1910 static int ieee80211_resume(struct wiphy
*wiphy
)
1912 return __ieee80211_resume(wiphy_priv(wiphy
));
1915 #define ieee80211_suspend NULL
1916 #define ieee80211_resume NULL
1919 static int ieee80211_scan(struct wiphy
*wiphy
,
1920 struct cfg80211_scan_request
*req
)
1922 struct ieee80211_sub_if_data
*sdata
;
1924 sdata
= IEEE80211_WDEV_TO_SUB_IF(req
->wdev
);
1926 switch (ieee80211_vif_type_p2p(&sdata
->vif
)) {
1927 case NL80211_IFTYPE_STATION
:
1928 case NL80211_IFTYPE_ADHOC
:
1929 case NL80211_IFTYPE_MESH_POINT
:
1930 case NL80211_IFTYPE_P2P_CLIENT
:
1931 case NL80211_IFTYPE_P2P_DEVICE
:
1933 case NL80211_IFTYPE_P2P_GO
:
1934 if (sdata
->local
->ops
->hw_scan
)
1937 * FIXME: implement NoA while scanning in software,
1938 * for now fall through to allow scanning only when
1939 * beaconing hasn't been configured yet
1941 case NL80211_IFTYPE_AP
:
1943 * If the scan has been forced (and the driver supports
1944 * forcing), don't care about being beaconing already.
1945 * This will create problems to the attached stations (e.g. all
1946 * the frames sent while scanning on other channel will be
1949 if (sdata
->u
.ap
.beacon
&&
1950 (!(wiphy
->features
& NL80211_FEATURE_AP_SCAN
) ||
1951 !(req
->flags
& NL80211_SCAN_FLAG_AP
)))
1958 return ieee80211_request_scan(sdata
, req
);
1962 ieee80211_sched_scan_start(struct wiphy
*wiphy
,
1963 struct net_device
*dev
,
1964 struct cfg80211_sched_scan_request
*req
)
1966 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1968 if (!sdata
->local
->ops
->sched_scan_start
)
1971 return ieee80211_request_sched_scan_start(sdata
, req
);
1975 ieee80211_sched_scan_stop(struct wiphy
*wiphy
, struct net_device
*dev
)
1977 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1979 if (!sdata
->local
->ops
->sched_scan_stop
)
1982 return ieee80211_request_sched_scan_stop(sdata
);
1985 static int ieee80211_auth(struct wiphy
*wiphy
, struct net_device
*dev
,
1986 struct cfg80211_auth_request
*req
)
1988 return ieee80211_mgd_auth(IEEE80211_DEV_TO_SUB_IF(dev
), req
);
1991 static int ieee80211_assoc(struct wiphy
*wiphy
, struct net_device
*dev
,
1992 struct cfg80211_assoc_request
*req
)
1994 return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev
), req
);
1997 static int ieee80211_deauth(struct wiphy
*wiphy
, struct net_device
*dev
,
1998 struct cfg80211_deauth_request
*req
)
2000 return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev
), req
);
2003 static int ieee80211_disassoc(struct wiphy
*wiphy
, struct net_device
*dev
,
2004 struct cfg80211_disassoc_request
*req
)
2006 return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev
), req
);
2009 static int ieee80211_join_ibss(struct wiphy
*wiphy
, struct net_device
*dev
,
2010 struct cfg80211_ibss_params
*params
)
2012 return ieee80211_ibss_join(IEEE80211_DEV_TO_SUB_IF(dev
), params
);
2015 static int ieee80211_leave_ibss(struct wiphy
*wiphy
, struct net_device
*dev
)
2017 return ieee80211_ibss_leave(IEEE80211_DEV_TO_SUB_IF(dev
));
2020 static int ieee80211_set_mcast_rate(struct wiphy
*wiphy
, struct net_device
*dev
,
2021 int rate
[IEEE80211_NUM_BANDS
])
2023 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
2025 memcpy(sdata
->vif
.bss_conf
.mcast_rate
, rate
,
2026 sizeof(int) * IEEE80211_NUM_BANDS
);
2031 static int ieee80211_set_wiphy_params(struct wiphy
*wiphy
, u32 changed
)
2033 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
2036 if (changed
& WIPHY_PARAM_FRAG_THRESHOLD
) {
2037 err
= drv_set_frag_threshold(local
, wiphy
->frag_threshold
);
2043 if ((changed
& WIPHY_PARAM_COVERAGE_CLASS
) ||
2044 (changed
& WIPHY_PARAM_DYN_ACK
)) {
2047 coverage_class
= changed
& WIPHY_PARAM_COVERAGE_CLASS
?
2048 wiphy
->coverage_class
: -1;
2049 err
= drv_set_coverage_class(local
, coverage_class
);
2055 if (changed
& WIPHY_PARAM_RTS_THRESHOLD
) {
2056 err
= drv_set_rts_threshold(local
, wiphy
->rts_threshold
);
2062 if (changed
& WIPHY_PARAM_RETRY_SHORT
) {
2063 if (wiphy
->retry_short
> IEEE80211_MAX_TX_RETRY
)
2065 local
->hw
.conf
.short_frame_max_tx_count
= wiphy
->retry_short
;
2067 if (changed
& WIPHY_PARAM_RETRY_LONG
) {
2068 if (wiphy
->retry_long
> IEEE80211_MAX_TX_RETRY
)
2070 local
->hw
.conf
.long_frame_max_tx_count
= wiphy
->retry_long
;
2073 (WIPHY_PARAM_RETRY_SHORT
| WIPHY_PARAM_RETRY_LONG
))
2074 ieee80211_hw_config(local
, IEEE80211_CONF_CHANGE_RETRY_LIMITS
);
2079 static int ieee80211_set_tx_power(struct wiphy
*wiphy
,
2080 struct wireless_dev
*wdev
,
2081 enum nl80211_tx_power_setting type
, int mbm
)
2083 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
2084 struct ieee80211_sub_if_data
*sdata
;
2087 sdata
= IEEE80211_WDEV_TO_SUB_IF(wdev
);
2090 case NL80211_TX_POWER_AUTOMATIC
:
2091 sdata
->user_power_level
= IEEE80211_UNSET_POWER_LEVEL
;
2093 case NL80211_TX_POWER_LIMITED
:
2094 case NL80211_TX_POWER_FIXED
:
2095 if (mbm
< 0 || (mbm
% 100))
2097 sdata
->user_power_level
= MBM_TO_DBM(mbm
);
2101 ieee80211_recalc_txpower(sdata
);
2107 case NL80211_TX_POWER_AUTOMATIC
:
2108 local
->user_power_level
= IEEE80211_UNSET_POWER_LEVEL
;
2110 case NL80211_TX_POWER_LIMITED
:
2111 case NL80211_TX_POWER_FIXED
:
2112 if (mbm
< 0 || (mbm
% 100))
2114 local
->user_power_level
= MBM_TO_DBM(mbm
);
2118 mutex_lock(&local
->iflist_mtx
);
2119 list_for_each_entry(sdata
, &local
->interfaces
, list
)
2120 sdata
->user_power_level
= local
->user_power_level
;
2121 list_for_each_entry(sdata
, &local
->interfaces
, list
)
2122 ieee80211_recalc_txpower(sdata
);
2123 mutex_unlock(&local
->iflist_mtx
);
2128 static int ieee80211_get_tx_power(struct wiphy
*wiphy
,
2129 struct wireless_dev
*wdev
,
2132 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
2133 struct ieee80211_sub_if_data
*sdata
= IEEE80211_WDEV_TO_SUB_IF(wdev
);
2135 if (!local
->use_chanctx
)
2136 *dbm
= local
->hw
.conf
.power_level
;
2138 *dbm
= sdata
->vif
.bss_conf
.txpower
;
2143 static int ieee80211_set_wds_peer(struct wiphy
*wiphy
, struct net_device
*dev
,
2146 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
2148 memcpy(&sdata
->u
.wds
.remote_addr
, addr
, ETH_ALEN
);
2153 static void ieee80211_rfkill_poll(struct wiphy
*wiphy
)
2155 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
2157 drv_rfkill_poll(local
);
2160 #ifdef CONFIG_NL80211_TESTMODE
2161 static int ieee80211_testmode_cmd(struct wiphy
*wiphy
,
2162 struct wireless_dev
*wdev
,
2163 void *data
, int len
)
2165 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
2166 struct ieee80211_vif
*vif
= NULL
;
2168 if (!local
->ops
->testmode_cmd
)
2172 struct ieee80211_sub_if_data
*sdata
;
2174 sdata
= IEEE80211_WDEV_TO_SUB_IF(wdev
);
2175 if (sdata
->flags
& IEEE80211_SDATA_IN_DRIVER
)
2179 return local
->ops
->testmode_cmd(&local
->hw
, vif
, data
, len
);
2182 static int ieee80211_testmode_dump(struct wiphy
*wiphy
,
2183 struct sk_buff
*skb
,
2184 struct netlink_callback
*cb
,
2185 void *data
, int len
)
2187 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
2189 if (!local
->ops
->testmode_dump
)
2192 return local
->ops
->testmode_dump(&local
->hw
, skb
, cb
, data
, len
);
2196 int __ieee80211_request_smps_ap(struct ieee80211_sub_if_data
*sdata
,
2197 enum ieee80211_smps_mode smps_mode
)
2199 struct sta_info
*sta
;
2200 enum ieee80211_smps_mode old_req
;
2203 if (WARN_ON_ONCE(sdata
->vif
.type
!= NL80211_IFTYPE_AP
))
2206 if (sdata
->vif
.bss_conf
.chandef
.width
== NL80211_CHAN_WIDTH_20_NOHT
)
2209 old_req
= sdata
->u
.ap
.req_smps
;
2210 sdata
->u
.ap
.req_smps
= smps_mode
;
2212 /* AUTOMATIC doesn't mean much for AP - don't allow it */
2213 if (old_req
== smps_mode
||
2214 smps_mode
== IEEE80211_SMPS_AUTOMATIC
)
2217 /* If no associated stations, there's no need to do anything */
2218 if (!atomic_read(&sdata
->u
.ap
.num_mcast_sta
)) {
2219 sdata
->smps_mode
= smps_mode
;
2220 ieee80211_queue_work(&sdata
->local
->hw
, &sdata
->recalc_smps
);
2225 "SMSP %d requested in AP mode, sending Action frame to %d stations\n",
2226 smps_mode
, atomic_read(&sdata
->u
.ap
.num_mcast_sta
));
2228 mutex_lock(&sdata
->local
->sta_mtx
);
2229 for (i
= 0; i
< STA_HASH_SIZE
; i
++) {
2230 for (sta
= rcu_dereference_protected(sdata
->local
->sta_hash
[i
],
2231 lockdep_is_held(&sdata
->local
->sta_mtx
));
2233 sta
= rcu_dereference_protected(sta
->hnext
,
2234 lockdep_is_held(&sdata
->local
->sta_mtx
))) {
2236 * Only stations associated to our AP and
2239 if (sta
->sdata
->bss
!= &sdata
->u
.ap
)
2242 /* This station doesn't support MIMO - skip it */
2243 if (sta_info_tx_streams(sta
) == 1)
2247 * Don't wake up a STA just to send the action frame
2248 * unless we are getting more restrictive.
2250 if (test_sta_flag(sta
, WLAN_STA_PS_STA
) &&
2251 !ieee80211_smps_is_restrictive(sta
->known_smps_mode
,
2254 "Won't send SMPS to sleeping STA %pM\n",
2260 * If the STA is not authorized, wait until it gets
2261 * authorized and the action frame will be sent then.
2263 if (!test_sta_flag(sta
, WLAN_STA_AUTHORIZED
))
2266 ht_dbg(sdata
, "Sending SMPS to %pM\n", sta
->sta
.addr
);
2267 ieee80211_send_smps_action(sdata
, smps_mode
,
2269 sdata
->vif
.bss_conf
.bssid
);
2272 mutex_unlock(&sdata
->local
->sta_mtx
);
2274 sdata
->smps_mode
= smps_mode
;
2275 ieee80211_queue_work(&sdata
->local
->hw
, &sdata
->recalc_smps
);
2280 int __ieee80211_request_smps_mgd(struct ieee80211_sub_if_data
*sdata
,
2281 enum ieee80211_smps_mode smps_mode
)
2284 enum ieee80211_smps_mode old_req
;
2287 lockdep_assert_held(&sdata
->wdev
.mtx
);
2289 if (WARN_ON_ONCE(sdata
->vif
.type
!= NL80211_IFTYPE_STATION
))
2292 old_req
= sdata
->u
.mgd
.req_smps
;
2293 sdata
->u
.mgd
.req_smps
= smps_mode
;
2295 if (old_req
== smps_mode
&&
2296 smps_mode
!= IEEE80211_SMPS_AUTOMATIC
)
2300 * If not associated, or current association is not an HT
2301 * association, there's no need to do anything, just store
2302 * the new value until we associate.
2304 if (!sdata
->u
.mgd
.associated
||
2305 sdata
->vif
.bss_conf
.chandef
.width
== NL80211_CHAN_WIDTH_20_NOHT
)
2308 ap
= sdata
->u
.mgd
.associated
->bssid
;
2310 if (smps_mode
== IEEE80211_SMPS_AUTOMATIC
) {
2311 if (sdata
->u
.mgd
.powersave
)
2312 smps_mode
= IEEE80211_SMPS_DYNAMIC
;
2314 smps_mode
= IEEE80211_SMPS_OFF
;
2317 /* send SM PS frame to AP */
2318 err
= ieee80211_send_smps_action(sdata
, smps_mode
,
2321 sdata
->u
.mgd
.req_smps
= old_req
;
2326 static int ieee80211_set_power_mgmt(struct wiphy
*wiphy
, struct net_device
*dev
,
2327 bool enabled
, int timeout
)
2329 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
2330 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
2332 if (sdata
->vif
.type
!= NL80211_IFTYPE_STATION
)
2335 if (!(local
->hw
.flags
& IEEE80211_HW_SUPPORTS_PS
))
2338 if (enabled
== sdata
->u
.mgd
.powersave
&&
2339 timeout
== local
->dynamic_ps_forced_timeout
)
2342 sdata
->u
.mgd
.powersave
= enabled
;
2343 local
->dynamic_ps_forced_timeout
= timeout
;
2345 /* no change, but if automatic follow powersave */
2347 __ieee80211_request_smps_mgd(sdata
, sdata
->u
.mgd
.req_smps
);
2348 sdata_unlock(sdata
);
2350 if (local
->hw
.flags
& IEEE80211_HW_SUPPORTS_DYNAMIC_PS
)
2351 ieee80211_hw_config(local
, IEEE80211_CONF_CHANGE_PS
);
2353 ieee80211_recalc_ps(local
, -1);
2354 ieee80211_recalc_ps_vif(sdata
);
2359 static int ieee80211_set_cqm_rssi_config(struct wiphy
*wiphy
,
2360 struct net_device
*dev
,
2361 s32 rssi_thold
, u32 rssi_hyst
)
2363 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
2364 struct ieee80211_vif
*vif
= &sdata
->vif
;
2365 struct ieee80211_bss_conf
*bss_conf
= &vif
->bss_conf
;
2367 if (rssi_thold
== bss_conf
->cqm_rssi_thold
&&
2368 rssi_hyst
== bss_conf
->cqm_rssi_hyst
)
2371 bss_conf
->cqm_rssi_thold
= rssi_thold
;
2372 bss_conf
->cqm_rssi_hyst
= rssi_hyst
;
2374 /* tell the driver upon association, unless already associated */
2375 if (sdata
->u
.mgd
.associated
&&
2376 sdata
->vif
.driver_flags
& IEEE80211_VIF_SUPPORTS_CQM_RSSI
)
2377 ieee80211_bss_info_change_notify(sdata
, BSS_CHANGED_CQM
);
2382 static int ieee80211_set_bitrate_mask(struct wiphy
*wiphy
,
2383 struct net_device
*dev
,
2385 const struct cfg80211_bitrate_mask
*mask
)
2387 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
2388 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
2391 if (!ieee80211_sdata_running(sdata
))
2394 if (local
->hw
.flags
& IEEE80211_HW_HAS_RATE_CONTROL
) {
2395 ret
= drv_set_bitrate_mask(local
, sdata
, mask
);
2400 for (i
= 0; i
< IEEE80211_NUM_BANDS
; i
++) {
2401 struct ieee80211_supported_band
*sband
= wiphy
->bands
[i
];
2404 sdata
->rc_rateidx_mask
[i
] = mask
->control
[i
].legacy
;
2405 memcpy(sdata
->rc_rateidx_mcs_mask
[i
], mask
->control
[i
].ht_mcs
,
2406 sizeof(mask
->control
[i
].ht_mcs
));
2408 sdata
->rc_has_mcs_mask
[i
] = false;
2412 for (j
= 0; j
< IEEE80211_HT_MCS_MASK_LEN
; j
++)
2413 if (~sdata
->rc_rateidx_mcs_mask
[i
][j
]) {
2414 sdata
->rc_has_mcs_mask
[i
] = true;
2422 static bool ieee80211_coalesce_started_roc(struct ieee80211_local
*local
,
2423 struct ieee80211_roc_work
*new_roc
,
2424 struct ieee80211_roc_work
*cur_roc
)
2426 unsigned long j
= jiffies
;
2427 unsigned long cur_roc_end
= cur_roc
->hw_start_time
+
2428 msecs_to_jiffies(cur_roc
->duration
);
2429 struct ieee80211_roc_work
*next_roc
;
2432 if (WARN_ON(!cur_roc
->started
|| !cur_roc
->hw_begun
))
2435 if (time_after(j
+ IEEE80211_ROC_MIN_LEFT
, cur_roc_end
))
2438 ieee80211_handle_roc_started(new_roc
);
2440 new_dur
= new_roc
->duration
- jiffies_to_msecs(cur_roc_end
- j
);
2442 /* cur_roc is long enough - add new_roc to the dependents list. */
2444 list_add_tail(&new_roc
->list
, &cur_roc
->dependents
);
2448 new_roc
->duration
= new_dur
;
2451 * if cur_roc was already coalesced before, we might
2452 * want to extend the next roc instead of adding
2455 next_roc
= list_entry(cur_roc
->list
.next
,
2456 struct ieee80211_roc_work
, list
);
2457 if (&next_roc
->list
!= &local
->roc_list
&&
2458 next_roc
->chan
== new_roc
->chan
&&
2459 next_roc
->sdata
== new_roc
->sdata
&&
2460 !WARN_ON(next_roc
->started
)) {
2461 list_add_tail(&new_roc
->list
, &next_roc
->dependents
);
2462 next_roc
->duration
= max(next_roc
->duration
,
2464 next_roc
->type
= max(next_roc
->type
, new_roc
->type
);
2468 /* add right after cur_roc */
2469 list_add(&new_roc
->list
, &cur_roc
->list
);
2474 static int ieee80211_start_roc_work(struct ieee80211_local
*local
,
2475 struct ieee80211_sub_if_data
*sdata
,
2476 struct ieee80211_channel
*channel
,
2477 unsigned int duration
, u64
*cookie
,
2478 struct sk_buff
*txskb
,
2479 enum ieee80211_roc_type type
)
2481 struct ieee80211_roc_work
*roc
, *tmp
;
2482 bool queued
= false;
2485 lockdep_assert_held(&local
->mtx
);
2487 if (local
->use_chanctx
&& !local
->ops
->remain_on_channel
)
2490 roc
= kzalloc(sizeof(*roc
), GFP_KERNEL
);
2495 * If the duration is zero, then the driver
2496 * wouldn't actually do anything. Set it to
2499 * TODO: cancel the off-channel operation
2500 * when we get the SKB's TX status and
2501 * the wait time was zero before.
2506 roc
->chan
= channel
;
2507 roc
->duration
= duration
;
2508 roc
->req_duration
= duration
;
2511 roc
->mgmt_tx_cookie
= (unsigned long)txskb
;
2513 INIT_DELAYED_WORK(&roc
->work
, ieee80211_sw_roc_work
);
2514 INIT_LIST_HEAD(&roc
->dependents
);
2517 * cookie is either the roc cookie (for normal roc)
2518 * or the SKB (for mgmt TX)
2521 /* local->mtx protects this */
2522 local
->roc_cookie_counter
++;
2523 roc
->cookie
= local
->roc_cookie_counter
;
2524 /* wow, you wrapped 64 bits ... more likely a bug */
2525 if (WARN_ON(roc
->cookie
== 0)) {
2527 local
->roc_cookie_counter
++;
2529 *cookie
= roc
->cookie
;
2531 *cookie
= (unsigned long)txskb
;
2534 /* if there's one pending or we're scanning, queue this one */
2535 if (!list_empty(&local
->roc_list
) ||
2536 local
->scanning
|| local
->radar_detect_enabled
)
2537 goto out_check_combine
;
2539 /* if not HW assist, just queue & schedule work */
2540 if (!local
->ops
->remain_on_channel
) {
2541 ieee80211_queue_delayed_work(&local
->hw
, &roc
->work
, 0);
2545 /* otherwise actually kick it off here (for error handling) */
2547 ret
= drv_remain_on_channel(local
, sdata
, channel
, duration
, type
);
2553 roc
->started
= true;
2557 list_for_each_entry(tmp
, &local
->roc_list
, list
) {
2558 if (tmp
->chan
!= channel
|| tmp
->sdata
!= sdata
)
2562 * Extend this ROC if possible:
2564 * If it hasn't started yet, just increase the duration
2565 * and add the new one to the list of dependents.
2566 * If the type of the new ROC has higher priority, modify the
2567 * type of the previous one to match that of the new one.
2569 if (!tmp
->started
) {
2570 list_add_tail(&roc
->list
, &tmp
->dependents
);
2571 tmp
->duration
= max(tmp
->duration
, roc
->duration
);
2572 tmp
->type
= max(tmp
->type
, roc
->type
);
2577 /* If it has already started, it's more difficult ... */
2578 if (local
->ops
->remain_on_channel
) {
2580 * In the offloaded ROC case, if it hasn't begun, add
2581 * this new one to the dependent list to be handled
2582 * when the master one begins. If it has begun,
2583 * check that there's still a minimum time left and
2584 * if so, start this one, transmitting the frame, but
2585 * add it to the list directly after this one with
2586 * a reduced time so we'll ask the driver to execute
2587 * it right after finishing the previous one, in the
2588 * hope that it'll also be executed right afterwards,
2589 * effectively extending the old one.
2590 * If there's no minimum time left, just add it to the
2592 * TODO: the ROC type is ignored here, assuming that it
2593 * is better to immediately use the current ROC.
2595 if (!tmp
->hw_begun
) {
2596 list_add_tail(&roc
->list
, &tmp
->dependents
);
2601 if (ieee80211_coalesce_started_roc(local
, roc
, tmp
))
2603 } else if (del_timer_sync(&tmp
->work
.timer
)) {
2604 unsigned long new_end
;
2607 * In the software ROC case, cancel the timer, if
2608 * that fails then the finish work is already
2609 * queued/pending and thus we queue the new ROC
2610 * normally, if that succeeds then we can extend
2611 * the timer duration and TX the frame (if any.)
2614 list_add_tail(&roc
->list
, &tmp
->dependents
);
2617 new_end
= jiffies
+ msecs_to_jiffies(roc
->duration
);
2619 /* ok, it was started & we canceled timer */
2620 if (time_after(new_end
, tmp
->work
.timer
.expires
))
2621 mod_timer(&tmp
->work
.timer
, new_end
);
2623 add_timer(&tmp
->work
.timer
);
2625 ieee80211_handle_roc_started(roc
);
2632 list_add_tail(&roc
->list
, &local
->roc_list
);
2637 static int ieee80211_remain_on_channel(struct wiphy
*wiphy
,
2638 struct wireless_dev
*wdev
,
2639 struct ieee80211_channel
*chan
,
2640 unsigned int duration
,
2643 struct ieee80211_sub_if_data
*sdata
= IEEE80211_WDEV_TO_SUB_IF(wdev
);
2644 struct ieee80211_local
*local
= sdata
->local
;
2647 mutex_lock(&local
->mtx
);
2648 ret
= ieee80211_start_roc_work(local
, sdata
, chan
,
2649 duration
, cookie
, NULL
,
2650 IEEE80211_ROC_TYPE_NORMAL
);
2651 mutex_unlock(&local
->mtx
);
2656 static int ieee80211_cancel_roc(struct ieee80211_local
*local
,
2657 u64 cookie
, bool mgmt_tx
)
2659 struct ieee80211_roc_work
*roc
, *tmp
, *found
= NULL
;
2662 mutex_lock(&local
->mtx
);
2663 list_for_each_entry_safe(roc
, tmp
, &local
->roc_list
, list
) {
2664 struct ieee80211_roc_work
*dep
, *tmp2
;
2666 list_for_each_entry_safe(dep
, tmp2
, &roc
->dependents
, list
) {
2667 if (!mgmt_tx
&& dep
->cookie
!= cookie
)
2669 else if (mgmt_tx
&& dep
->mgmt_tx_cookie
!= cookie
)
2671 /* found dependent item -- just remove it */
2672 list_del(&dep
->list
);
2673 mutex_unlock(&local
->mtx
);
2675 ieee80211_roc_notify_destroy(dep
, true);
2679 if (!mgmt_tx
&& roc
->cookie
!= cookie
)
2681 else if (mgmt_tx
&& roc
->mgmt_tx_cookie
!= cookie
)
2689 mutex_unlock(&local
->mtx
);
2694 * We found the item to cancel, so do that. Note that it
2695 * may have dependents, which we also cancel (and send
2696 * the expired signal for.) Not doing so would be quite
2697 * tricky here, but we may need to fix it later.
2700 if (local
->ops
->remain_on_channel
) {
2701 if (found
->started
) {
2702 ret
= drv_cancel_remain_on_channel(local
);
2703 if (WARN_ON_ONCE(ret
)) {
2704 mutex_unlock(&local
->mtx
);
2709 list_del(&found
->list
);
2712 ieee80211_start_next_roc(local
);
2713 mutex_unlock(&local
->mtx
);
2715 ieee80211_roc_notify_destroy(found
, true);
2717 /* work may be pending so use it all the time */
2718 found
->abort
= true;
2719 ieee80211_queue_delayed_work(&local
->hw
, &found
->work
, 0);
2721 mutex_unlock(&local
->mtx
);
2723 /* work will clean up etc */
2724 flush_delayed_work(&found
->work
);
2725 WARN_ON(!found
->to_be_freed
);
2732 static int ieee80211_cancel_remain_on_channel(struct wiphy
*wiphy
,
2733 struct wireless_dev
*wdev
,
2736 struct ieee80211_sub_if_data
*sdata
= IEEE80211_WDEV_TO_SUB_IF(wdev
);
2737 struct ieee80211_local
*local
= sdata
->local
;
2739 return ieee80211_cancel_roc(local
, cookie
, false);
2742 static int ieee80211_start_radar_detection(struct wiphy
*wiphy
,
2743 struct net_device
*dev
,
2744 struct cfg80211_chan_def
*chandef
,
2747 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
2748 struct ieee80211_local
*local
= sdata
->local
;
2751 mutex_lock(&local
->mtx
);
2752 if (!list_empty(&local
->roc_list
) || local
->scanning
) {
2757 /* whatever, but channel contexts should not complain about that one */
2758 sdata
->smps_mode
= IEEE80211_SMPS_OFF
;
2759 sdata
->needed_rx_chains
= local
->rx_chains
;
2761 err
= ieee80211_vif_use_channel(sdata
, chandef
,
2762 IEEE80211_CHANCTX_SHARED
);
2766 ieee80211_queue_delayed_work(&sdata
->local
->hw
,
2767 &sdata
->dfs_cac_timer_work
,
2768 msecs_to_jiffies(cac_time_ms
));
2771 mutex_unlock(&local
->mtx
);
2775 static struct cfg80211_beacon_data
*
2776 cfg80211_beacon_dup(struct cfg80211_beacon_data
*beacon
)
2778 struct cfg80211_beacon_data
*new_beacon
;
2782 len
= beacon
->head_len
+ beacon
->tail_len
+ beacon
->beacon_ies_len
+
2783 beacon
->proberesp_ies_len
+ beacon
->assocresp_ies_len
+
2784 beacon
->probe_resp_len
;
2786 new_beacon
= kzalloc(sizeof(*new_beacon
) + len
, GFP_KERNEL
);
2790 pos
= (u8
*)(new_beacon
+ 1);
2791 if (beacon
->head_len
) {
2792 new_beacon
->head_len
= beacon
->head_len
;
2793 new_beacon
->head
= pos
;
2794 memcpy(pos
, beacon
->head
, beacon
->head_len
);
2795 pos
+= beacon
->head_len
;
2797 if (beacon
->tail_len
) {
2798 new_beacon
->tail_len
= beacon
->tail_len
;
2799 new_beacon
->tail
= pos
;
2800 memcpy(pos
, beacon
->tail
, beacon
->tail_len
);
2801 pos
+= beacon
->tail_len
;
2803 if (beacon
->beacon_ies_len
) {
2804 new_beacon
->beacon_ies_len
= beacon
->beacon_ies_len
;
2805 new_beacon
->beacon_ies
= pos
;
2806 memcpy(pos
, beacon
->beacon_ies
, beacon
->beacon_ies_len
);
2807 pos
+= beacon
->beacon_ies_len
;
2809 if (beacon
->proberesp_ies_len
) {
2810 new_beacon
->proberesp_ies_len
= beacon
->proberesp_ies_len
;
2811 new_beacon
->proberesp_ies
= pos
;
2812 memcpy(pos
, beacon
->proberesp_ies
, beacon
->proberesp_ies_len
);
2813 pos
+= beacon
->proberesp_ies_len
;
2815 if (beacon
->assocresp_ies_len
) {
2816 new_beacon
->assocresp_ies_len
= beacon
->assocresp_ies_len
;
2817 new_beacon
->assocresp_ies
= pos
;
2818 memcpy(pos
, beacon
->assocresp_ies
, beacon
->assocresp_ies_len
);
2819 pos
+= beacon
->assocresp_ies_len
;
2821 if (beacon
->probe_resp_len
) {
2822 new_beacon
->probe_resp_len
= beacon
->probe_resp_len
;
2823 beacon
->probe_resp
= pos
;
2824 memcpy(pos
, beacon
->probe_resp
, beacon
->probe_resp_len
);
2825 pos
+= beacon
->probe_resp_len
;
2831 void ieee80211_csa_finish(struct ieee80211_vif
*vif
)
2833 struct ieee80211_sub_if_data
*sdata
= vif_to_sdata(vif
);
2835 ieee80211_queue_work(&sdata
->local
->hw
,
2836 &sdata
->csa_finalize_work
);
2838 EXPORT_SYMBOL(ieee80211_csa_finish
);
2840 static int ieee80211_set_after_csa_beacon(struct ieee80211_sub_if_data
*sdata
,
2845 switch (sdata
->vif
.type
) {
2846 case NL80211_IFTYPE_AP
:
2847 err
= ieee80211_assign_beacon(sdata
, sdata
->u
.ap
.next_beacon
,
2849 kfree(sdata
->u
.ap
.next_beacon
);
2850 sdata
->u
.ap
.next_beacon
= NULL
;
2856 case NL80211_IFTYPE_ADHOC
:
2857 err
= ieee80211_ibss_finish_csa(sdata
);
2862 #ifdef CONFIG_MAC80211_MESH
2863 case NL80211_IFTYPE_MESH_POINT
:
2864 err
= ieee80211_mesh_finish_csa(sdata
);
2878 static int __ieee80211_csa_finalize(struct ieee80211_sub_if_data
*sdata
)
2880 struct ieee80211_local
*local
= sdata
->local
;
2884 sdata_assert_lock(sdata
);
2885 lockdep_assert_held(&local
->mtx
);
2886 lockdep_assert_held(&local
->chanctx_mtx
);
2889 * using reservation isn't immediate as it may be deferred until later
2890 * with multi-vif. once reservation is complete it will re-schedule the
2891 * work with no reserved_chanctx so verify chandef to check if it
2892 * completed successfully
2895 if (sdata
->reserved_chanctx
) {
2897 * with multi-vif csa driver may call ieee80211_csa_finish()
2898 * many times while waiting for other interfaces to use their
2901 if (sdata
->reserved_ready
)
2904 return ieee80211_vif_use_reserved_context(sdata
);
2907 if (!cfg80211_chandef_identical(&sdata
->vif
.bss_conf
.chandef
,
2908 &sdata
->csa_chandef
))
2911 sdata
->vif
.csa_active
= false;
2913 err
= ieee80211_set_after_csa_beacon(sdata
, &changed
);
2917 ieee80211_bss_info_change_notify(sdata
, changed
);
2919 if (sdata
->csa_block_tx
) {
2920 ieee80211_wake_vif_queues(local
, sdata
,
2921 IEEE80211_QUEUE_STOP_REASON_CSA
);
2922 sdata
->csa_block_tx
= false;
2925 err
= drv_post_channel_switch(sdata
);
2929 cfg80211_ch_switch_notify(sdata
->dev
, &sdata
->csa_chandef
);
2934 static void ieee80211_csa_finalize(struct ieee80211_sub_if_data
*sdata
)
2936 if (__ieee80211_csa_finalize(sdata
)) {
2937 sdata_info(sdata
, "failed to finalize CSA, disconnecting\n");
2938 cfg80211_stop_iface(sdata
->local
->hw
.wiphy
, &sdata
->wdev
,
2943 void ieee80211_csa_finalize_work(struct work_struct
*work
)
2945 struct ieee80211_sub_if_data
*sdata
=
2946 container_of(work
, struct ieee80211_sub_if_data
,
2948 struct ieee80211_local
*local
= sdata
->local
;
2951 mutex_lock(&local
->mtx
);
2952 mutex_lock(&local
->chanctx_mtx
);
2954 /* AP might have been stopped while waiting for the lock. */
2955 if (!sdata
->vif
.csa_active
)
2958 if (!ieee80211_sdata_running(sdata
))
2961 ieee80211_csa_finalize(sdata
);
2964 mutex_unlock(&local
->chanctx_mtx
);
2965 mutex_unlock(&local
->mtx
);
2966 sdata_unlock(sdata
);
2969 static int ieee80211_set_csa_beacon(struct ieee80211_sub_if_data
*sdata
,
2970 struct cfg80211_csa_settings
*params
,
2973 struct ieee80211_csa_settings csa
= {};
2976 switch (sdata
->vif
.type
) {
2977 case NL80211_IFTYPE_AP
:
2978 sdata
->u
.ap
.next_beacon
=
2979 cfg80211_beacon_dup(¶ms
->beacon_after
);
2980 if (!sdata
->u
.ap
.next_beacon
)
2984 * With a count of 0, we don't have to wait for any
2985 * TBTT before switching, so complete the CSA
2986 * immediately. In theory, with a count == 1 we
2987 * should delay the switch until just before the next
2988 * TBTT, but that would complicate things so we switch
2989 * immediately too. If we would delay the switch
2990 * until the next TBTT, we would have to set the probe
2993 * TODO: A channel switch with count <= 1 without
2994 * sending a CSA action frame is kind of useless,
2995 * because the clients won't know we're changing
2996 * channels. The action frame must be implemented
2997 * either here or in the userspace.
2999 if (params
->count
<= 1)
3002 if ((params
->n_counter_offsets_beacon
>
3003 IEEE80211_MAX_CSA_COUNTERS_NUM
) ||
3004 (params
->n_counter_offsets_presp
>
3005 IEEE80211_MAX_CSA_COUNTERS_NUM
))
3008 csa
.counter_offsets_beacon
= params
->counter_offsets_beacon
;
3009 csa
.counter_offsets_presp
= params
->counter_offsets_presp
;
3010 csa
.n_counter_offsets_beacon
= params
->n_counter_offsets_beacon
;
3011 csa
.n_counter_offsets_presp
= params
->n_counter_offsets_presp
;
3012 csa
.count
= params
->count
;
3014 err
= ieee80211_assign_beacon(sdata
, ¶ms
->beacon_csa
, &csa
);
3016 kfree(sdata
->u
.ap
.next_beacon
);
3022 case NL80211_IFTYPE_ADHOC
:
3023 if (!sdata
->vif
.bss_conf
.ibss_joined
)
3026 if (params
->chandef
.width
!= sdata
->u
.ibss
.chandef
.width
)
3029 switch (params
->chandef
.width
) {
3030 case NL80211_CHAN_WIDTH_40
:
3031 if (cfg80211_get_chandef_type(¶ms
->chandef
) !=
3032 cfg80211_get_chandef_type(&sdata
->u
.ibss
.chandef
))
3034 case NL80211_CHAN_WIDTH_5
:
3035 case NL80211_CHAN_WIDTH_10
:
3036 case NL80211_CHAN_WIDTH_20_NOHT
:
3037 case NL80211_CHAN_WIDTH_20
:
3043 /* changes into another band are not supported */
3044 if (sdata
->u
.ibss
.chandef
.chan
->band
!=
3045 params
->chandef
.chan
->band
)
3048 /* see comments in the NL80211_IFTYPE_AP block */
3049 if (params
->count
> 1) {
3050 err
= ieee80211_ibss_csa_beacon(sdata
, params
);
3056 ieee80211_send_action_csa(sdata
, params
);
3059 #ifdef CONFIG_MAC80211_MESH
3060 case NL80211_IFTYPE_MESH_POINT
: {
3061 struct ieee80211_if_mesh
*ifmsh
= &sdata
->u
.mesh
;
3063 if (params
->chandef
.width
!= sdata
->vif
.bss_conf
.chandef
.width
)
3066 /* changes into another band are not supported */
3067 if (sdata
->vif
.bss_conf
.chandef
.chan
->band
!=
3068 params
->chandef
.chan
->band
)
3071 if (ifmsh
->csa_role
== IEEE80211_MESH_CSA_ROLE_NONE
) {
3072 ifmsh
->csa_role
= IEEE80211_MESH_CSA_ROLE_INIT
;
3073 if (!ifmsh
->pre_value
)
3074 ifmsh
->pre_value
= 1;
3079 /* see comments in the NL80211_IFTYPE_AP block */
3080 if (params
->count
> 1) {
3081 err
= ieee80211_mesh_csa_beacon(sdata
, params
);
3083 ifmsh
->csa_role
= IEEE80211_MESH_CSA_ROLE_NONE
;
3089 if (ifmsh
->csa_role
== IEEE80211_MESH_CSA_ROLE_INIT
)
3090 ieee80211_send_action_csa(sdata
, params
);
3103 __ieee80211_channel_switch(struct wiphy
*wiphy
, struct net_device
*dev
,
3104 struct cfg80211_csa_settings
*params
)
3106 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
3107 struct ieee80211_local
*local
= sdata
->local
;
3108 struct ieee80211_channel_switch ch_switch
;
3109 struct ieee80211_chanctx_conf
*conf
;
3110 struct ieee80211_chanctx
*chanctx
;
3111 int err
, changed
= 0;
3113 sdata_assert_lock(sdata
);
3114 lockdep_assert_held(&local
->mtx
);
3116 if (!list_empty(&local
->roc_list
) || local
->scanning
)
3119 if (sdata
->wdev
.cac_started
)
3122 if (cfg80211_chandef_identical(¶ms
->chandef
,
3123 &sdata
->vif
.bss_conf
.chandef
))
3126 /* don't allow another channel switch if one is already active. */
3127 if (sdata
->vif
.csa_active
)
3130 mutex_lock(&local
->chanctx_mtx
);
3131 conf
= rcu_dereference_protected(sdata
->vif
.chanctx_conf
,
3132 lockdep_is_held(&local
->chanctx_mtx
));
3138 chanctx
= container_of(conf
, struct ieee80211_chanctx
, conf
);
3144 err
= drv_pre_channel_switch(sdata
, &ch_switch
);
3148 err
= ieee80211_vif_reserve_chanctx(sdata
, ¶ms
->chandef
,
3150 params
->radar_required
);
3154 /* if reservation is invalid then this will fail */
3155 err
= ieee80211_check_combinations(sdata
, NULL
, chanctx
->mode
, 0);
3157 ieee80211_vif_unreserve_chanctx(sdata
);
3161 ch_switch
.timestamp
= 0;
3162 ch_switch
.device_timestamp
= 0;
3163 ch_switch
.block_tx
= params
->block_tx
;
3164 ch_switch
.chandef
= params
->chandef
;
3165 ch_switch
.count
= params
->count
;
3167 err
= ieee80211_set_csa_beacon(sdata
, params
, &changed
);
3169 ieee80211_vif_unreserve_chanctx(sdata
);
3173 sdata
->csa_chandef
= params
->chandef
;
3174 sdata
->csa_block_tx
= params
->block_tx
;
3175 sdata
->vif
.csa_active
= true;
3177 if (sdata
->csa_block_tx
)
3178 ieee80211_stop_vif_queues(local
, sdata
,
3179 IEEE80211_QUEUE_STOP_REASON_CSA
);
3182 ieee80211_bss_info_change_notify(sdata
, changed
);
3183 drv_channel_switch_beacon(sdata
, ¶ms
->chandef
);
3185 /* if the beacon didn't change, we can finalize immediately */
3186 ieee80211_csa_finalize(sdata
);
3190 mutex_unlock(&local
->chanctx_mtx
);
3194 int ieee80211_channel_switch(struct wiphy
*wiphy
, struct net_device
*dev
,
3195 struct cfg80211_csa_settings
*params
)
3197 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
3198 struct ieee80211_local
*local
= sdata
->local
;
3201 mutex_lock(&local
->mtx
);
3202 err
= __ieee80211_channel_switch(wiphy
, dev
, params
);
3203 mutex_unlock(&local
->mtx
);
3208 static int ieee80211_mgmt_tx(struct wiphy
*wiphy
, struct wireless_dev
*wdev
,
3209 struct cfg80211_mgmt_tx_params
*params
,
3212 struct ieee80211_sub_if_data
*sdata
= IEEE80211_WDEV_TO_SUB_IF(wdev
);
3213 struct ieee80211_local
*local
= sdata
->local
;
3214 struct sk_buff
*skb
;
3215 struct sta_info
*sta
;
3216 const struct ieee80211_mgmt
*mgmt
= (void *)params
->buf
;
3217 bool need_offchan
= false;
3222 if (params
->dont_wait_for_ack
)
3223 flags
= IEEE80211_TX_CTL_NO_ACK
;
3225 flags
= IEEE80211_TX_INTFL_NL80211_FRAME_TX
|
3226 IEEE80211_TX_CTL_REQ_TX_STATUS
;
3229 flags
|= IEEE80211_TX_CTL_NO_CCK_RATE
;
3231 switch (sdata
->vif
.type
) {
3232 case NL80211_IFTYPE_ADHOC
:
3233 if (!sdata
->vif
.bss_conf
.ibss_joined
)
3234 need_offchan
= true;
3236 #ifdef CONFIG_MAC80211_MESH
3237 case NL80211_IFTYPE_MESH_POINT
:
3238 if (ieee80211_vif_is_mesh(&sdata
->vif
) &&
3239 !sdata
->u
.mesh
.mesh_id_len
)
3240 need_offchan
= true;
3243 case NL80211_IFTYPE_AP
:
3244 case NL80211_IFTYPE_AP_VLAN
:
3245 case NL80211_IFTYPE_P2P_GO
:
3246 if (sdata
->vif
.type
!= NL80211_IFTYPE_ADHOC
&&
3247 !ieee80211_vif_is_mesh(&sdata
->vif
) &&
3248 !rcu_access_pointer(sdata
->bss
->beacon
))
3249 need_offchan
= true;
3250 if (!ieee80211_is_action(mgmt
->frame_control
) ||
3251 mgmt
->u
.action
.category
== WLAN_CATEGORY_PUBLIC
||
3252 mgmt
->u
.action
.category
== WLAN_CATEGORY_SELF_PROTECTED
||
3253 mgmt
->u
.action
.category
== WLAN_CATEGORY_SPECTRUM_MGMT
)
3256 sta
= sta_info_get(sdata
, mgmt
->da
);
3261 case NL80211_IFTYPE_STATION
:
3262 case NL80211_IFTYPE_P2P_CLIENT
:
3263 if (!sdata
->u
.mgd
.associated
)
3264 need_offchan
= true;
3266 case NL80211_IFTYPE_P2P_DEVICE
:
3267 need_offchan
= true;
3273 /* configurations requiring offchan cannot work if no channel has been
3276 if (need_offchan
&& !params
->chan
)
3279 mutex_lock(&local
->mtx
);
3281 /* Check if the operating channel is the requested channel */
3282 if (!need_offchan
) {
3283 struct ieee80211_chanctx_conf
*chanctx_conf
;
3286 chanctx_conf
= rcu_dereference(sdata
->vif
.chanctx_conf
);
3289 need_offchan
= params
->chan
&&
3291 chanctx_conf
->def
.chan
);
3292 } else if (!params
->chan
) {
3297 need_offchan
= true;
3302 if (need_offchan
&& !params
->offchan
) {
3307 skb
= dev_alloc_skb(local
->hw
.extra_tx_headroom
+ params
->len
);
3312 skb_reserve(skb
, local
->hw
.extra_tx_headroom
);
3314 data
= skb_put(skb
, params
->len
);
3315 memcpy(data
, params
->buf
, params
->len
);
3317 /* Update CSA counters */
3318 if (sdata
->vif
.csa_active
&&
3319 (sdata
->vif
.type
== NL80211_IFTYPE_AP
||
3320 sdata
->vif
.type
== NL80211_IFTYPE_ADHOC
) &&
3321 params
->n_csa_offsets
) {
3323 struct beacon_data
*beacon
= NULL
;
3327 if (sdata
->vif
.type
== NL80211_IFTYPE_AP
)
3328 beacon
= rcu_dereference(sdata
->u
.ap
.beacon
);
3329 else if (sdata
->vif
.type
== NL80211_IFTYPE_ADHOC
)
3330 beacon
= rcu_dereference(sdata
->u
.ibss
.presp
);
3331 else if (ieee80211_vif_is_mesh(&sdata
->vif
))
3332 beacon
= rcu_dereference(sdata
->u
.mesh
.beacon
);
3335 for (i
= 0; i
< params
->n_csa_offsets
; i
++)
3336 data
[params
->csa_offsets
[i
]] =
3337 beacon
->csa_current_counter
;
3342 IEEE80211_SKB_CB(skb
)->flags
= flags
;
3344 skb
->dev
= sdata
->dev
;
3346 if (!need_offchan
) {
3347 *cookie
= (unsigned long) skb
;
3348 ieee80211_tx_skb(sdata
, skb
);
3353 IEEE80211_SKB_CB(skb
)->flags
|= IEEE80211_TX_CTL_TX_OFFCHAN
|
3354 IEEE80211_TX_INTFL_OFFCHAN_TX_OK
;
3355 if (local
->hw
.flags
& IEEE80211_HW_QUEUE_CONTROL
)
3356 IEEE80211_SKB_CB(skb
)->hw_queue
=
3357 local
->hw
.offchannel_tx_hw_queue
;
3359 /* This will handle all kinds of coalescing and immediate TX */
3360 ret
= ieee80211_start_roc_work(local
, sdata
, params
->chan
,
3361 params
->wait
, cookie
, skb
,
3362 IEEE80211_ROC_TYPE_MGMT_TX
);
3366 mutex_unlock(&local
->mtx
);
3370 static int ieee80211_mgmt_tx_cancel_wait(struct wiphy
*wiphy
,
3371 struct wireless_dev
*wdev
,
3374 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
3376 return ieee80211_cancel_roc(local
, cookie
, true);
3379 static void ieee80211_mgmt_frame_register(struct wiphy
*wiphy
,
3380 struct wireless_dev
*wdev
,
3381 u16 frame_type
, bool reg
)
3383 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
3385 switch (frame_type
) {
3386 case IEEE80211_FTYPE_MGMT
| IEEE80211_STYPE_PROBE_REQ
:
3388 local
->probe_req_reg
++;
3390 local
->probe_req_reg
--;
3392 if (!local
->open_count
)
3395 ieee80211_queue_work(&local
->hw
, &local
->reconfig_filter
);
3402 static int ieee80211_set_antenna(struct wiphy
*wiphy
, u32 tx_ant
, u32 rx_ant
)
3404 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
3409 return drv_set_antenna(local
, tx_ant
, rx_ant
);
3412 static int ieee80211_get_antenna(struct wiphy
*wiphy
, u32
*tx_ant
, u32
*rx_ant
)
3414 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
3416 return drv_get_antenna(local
, tx_ant
, rx_ant
);
3419 static int ieee80211_set_rekey_data(struct wiphy
*wiphy
,
3420 struct net_device
*dev
,
3421 struct cfg80211_gtk_rekey_data
*data
)
3423 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
3424 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
3426 if (!local
->ops
->set_rekey_data
)
3429 drv_set_rekey_data(local
, sdata
, data
);
3434 static int ieee80211_probe_client(struct wiphy
*wiphy
, struct net_device
*dev
,
3435 const u8
*peer
, u64
*cookie
)
3437 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
3438 struct ieee80211_local
*local
= sdata
->local
;
3439 struct ieee80211_qos_hdr
*nullfunc
;
3440 struct sk_buff
*skb
;
3441 int size
= sizeof(*nullfunc
);
3444 struct ieee80211_tx_info
*info
;
3445 struct sta_info
*sta
;
3446 struct ieee80211_chanctx_conf
*chanctx_conf
;
3447 enum ieee80211_band band
;
3450 chanctx_conf
= rcu_dereference(sdata
->vif
.chanctx_conf
);
3451 if (WARN_ON(!chanctx_conf
)) {
3455 band
= chanctx_conf
->def
.chan
->band
;
3456 sta
= sta_info_get_bss(sdata
, peer
);
3465 fc
= cpu_to_le16(IEEE80211_FTYPE_DATA
|
3466 IEEE80211_STYPE_QOS_NULLFUNC
|
3467 IEEE80211_FCTL_FROMDS
);
3470 fc
= cpu_to_le16(IEEE80211_FTYPE_DATA
|
3471 IEEE80211_STYPE_NULLFUNC
|
3472 IEEE80211_FCTL_FROMDS
);
3475 skb
= dev_alloc_skb(local
->hw
.extra_tx_headroom
+ size
);
3483 skb_reserve(skb
, local
->hw
.extra_tx_headroom
);
3485 nullfunc
= (void *) skb_put(skb
, size
);
3486 nullfunc
->frame_control
= fc
;
3487 nullfunc
->duration_id
= 0;
3488 memcpy(nullfunc
->addr1
, sta
->sta
.addr
, ETH_ALEN
);
3489 memcpy(nullfunc
->addr2
, sdata
->vif
.addr
, ETH_ALEN
);
3490 memcpy(nullfunc
->addr3
, sdata
->vif
.addr
, ETH_ALEN
);
3491 nullfunc
->seq_ctrl
= 0;
3493 info
= IEEE80211_SKB_CB(skb
);
3495 info
->flags
|= IEEE80211_TX_CTL_REQ_TX_STATUS
|
3496 IEEE80211_TX_INTFL_NL80211_FRAME_TX
;
3498 skb_set_queue_mapping(skb
, IEEE80211_AC_VO
);
3501 nullfunc
->qos_ctrl
= cpu_to_le16(7);
3504 ieee80211_xmit(sdata
, skb
, band
);
3508 *cookie
= (unsigned long) skb
;
3512 static int ieee80211_cfg_get_channel(struct wiphy
*wiphy
,
3513 struct wireless_dev
*wdev
,
3514 struct cfg80211_chan_def
*chandef
)
3516 struct ieee80211_sub_if_data
*sdata
= IEEE80211_WDEV_TO_SUB_IF(wdev
);
3517 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
3518 struct ieee80211_chanctx_conf
*chanctx_conf
;
3522 chanctx_conf
= rcu_dereference(sdata
->vif
.chanctx_conf
);
3524 *chandef
= chanctx_conf
->def
;
3526 } else if (local
->open_count
> 0 &&
3527 local
->open_count
== local
->monitors
&&
3528 sdata
->vif
.type
== NL80211_IFTYPE_MONITOR
) {
3529 if (local
->use_chanctx
)
3530 *chandef
= local
->monitor_chandef
;
3532 *chandef
= local
->_oper_chandef
;
3541 static void ieee80211_set_wakeup(struct wiphy
*wiphy
, bool enabled
)
3543 drv_set_wakeup(wiphy_priv(wiphy
), enabled
);
3547 static int ieee80211_set_qos_map(struct wiphy
*wiphy
,
3548 struct net_device
*dev
,
3549 struct cfg80211_qos_map
*qos_map
)
3551 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
3552 struct mac80211_qos_map
*new_qos_map
, *old_qos_map
;
3555 new_qos_map
= kzalloc(sizeof(*new_qos_map
), GFP_KERNEL
);
3558 memcpy(&new_qos_map
->qos_map
, qos_map
, sizeof(*qos_map
));
3560 /* A NULL qos_map was passed to disable QoS mapping */
3564 old_qos_map
= sdata_dereference(sdata
->qos_map
, sdata
);
3565 rcu_assign_pointer(sdata
->qos_map
, new_qos_map
);
3567 kfree_rcu(old_qos_map
, rcu_head
);
3572 static int ieee80211_set_ap_chanwidth(struct wiphy
*wiphy
,
3573 struct net_device
*dev
,
3574 struct cfg80211_chan_def
*chandef
)
3576 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
3580 ret
= ieee80211_vif_change_bandwidth(sdata
, chandef
, &changed
);
3582 ieee80211_bss_info_change_notify(sdata
, changed
);
3587 const struct cfg80211_ops mac80211_config_ops
= {
3588 .add_virtual_intf
= ieee80211_add_iface
,
3589 .del_virtual_intf
= ieee80211_del_iface
,
3590 .change_virtual_intf
= ieee80211_change_iface
,
3591 .start_p2p_device
= ieee80211_start_p2p_device
,
3592 .stop_p2p_device
= ieee80211_stop_p2p_device
,
3593 .add_key
= ieee80211_add_key
,
3594 .del_key
= ieee80211_del_key
,
3595 .get_key
= ieee80211_get_key
,
3596 .set_default_key
= ieee80211_config_default_key
,
3597 .set_default_mgmt_key
= ieee80211_config_default_mgmt_key
,
3598 .start_ap
= ieee80211_start_ap
,
3599 .change_beacon
= ieee80211_change_beacon
,
3600 .stop_ap
= ieee80211_stop_ap
,
3601 .add_station
= ieee80211_add_station
,
3602 .del_station
= ieee80211_del_station
,
3603 .change_station
= ieee80211_change_station
,
3604 .get_station
= ieee80211_get_station
,
3605 .dump_station
= ieee80211_dump_station
,
3606 .dump_survey
= ieee80211_dump_survey
,
3607 #ifdef CONFIG_MAC80211_MESH
3608 .add_mpath
= ieee80211_add_mpath
,
3609 .del_mpath
= ieee80211_del_mpath
,
3610 .change_mpath
= ieee80211_change_mpath
,
3611 .get_mpath
= ieee80211_get_mpath
,
3612 .dump_mpath
= ieee80211_dump_mpath
,
3613 .get_mpp
= ieee80211_get_mpp
,
3614 .dump_mpp
= ieee80211_dump_mpp
,
3615 .update_mesh_config
= ieee80211_update_mesh_config
,
3616 .get_mesh_config
= ieee80211_get_mesh_config
,
3617 .join_mesh
= ieee80211_join_mesh
,
3618 .leave_mesh
= ieee80211_leave_mesh
,
3620 .change_bss
= ieee80211_change_bss
,
3621 .set_txq_params
= ieee80211_set_txq_params
,
3622 .set_monitor_channel
= ieee80211_set_monitor_channel
,
3623 .suspend
= ieee80211_suspend
,
3624 .resume
= ieee80211_resume
,
3625 .scan
= ieee80211_scan
,
3626 .sched_scan_start
= ieee80211_sched_scan_start
,
3627 .sched_scan_stop
= ieee80211_sched_scan_stop
,
3628 .auth
= ieee80211_auth
,
3629 .assoc
= ieee80211_assoc
,
3630 .deauth
= ieee80211_deauth
,
3631 .disassoc
= ieee80211_disassoc
,
3632 .join_ibss
= ieee80211_join_ibss
,
3633 .leave_ibss
= ieee80211_leave_ibss
,
3634 .set_mcast_rate
= ieee80211_set_mcast_rate
,
3635 .set_wiphy_params
= ieee80211_set_wiphy_params
,
3636 .set_tx_power
= ieee80211_set_tx_power
,
3637 .get_tx_power
= ieee80211_get_tx_power
,
3638 .set_wds_peer
= ieee80211_set_wds_peer
,
3639 .rfkill_poll
= ieee80211_rfkill_poll
,
3640 CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd
)
3641 CFG80211_TESTMODE_DUMP(ieee80211_testmode_dump
)
3642 .set_power_mgmt
= ieee80211_set_power_mgmt
,
3643 .set_bitrate_mask
= ieee80211_set_bitrate_mask
,
3644 .remain_on_channel
= ieee80211_remain_on_channel
,
3645 .cancel_remain_on_channel
= ieee80211_cancel_remain_on_channel
,
3646 .mgmt_tx
= ieee80211_mgmt_tx
,
3647 .mgmt_tx_cancel_wait
= ieee80211_mgmt_tx_cancel_wait
,
3648 .set_cqm_rssi_config
= ieee80211_set_cqm_rssi_config
,
3649 .mgmt_frame_register
= ieee80211_mgmt_frame_register
,
3650 .set_antenna
= ieee80211_set_antenna
,
3651 .get_antenna
= ieee80211_get_antenna
,
3652 .set_rekey_data
= ieee80211_set_rekey_data
,
3653 .tdls_oper
= ieee80211_tdls_oper
,
3654 .tdls_mgmt
= ieee80211_tdls_mgmt
,
3655 .probe_client
= ieee80211_probe_client
,
3656 .set_noack_map
= ieee80211_set_noack_map
,
3658 .set_wakeup
= ieee80211_set_wakeup
,
3660 .get_channel
= ieee80211_cfg_get_channel
,
3661 .start_radar_detection
= ieee80211_start_radar_detection
,
3662 .channel_switch
= ieee80211_channel_switch
,
3663 .set_qos_map
= ieee80211_set_qos_map
,
3664 .set_ap_chanwidth
= ieee80211_set_ap_chanwidth
,