2 * BSS client mode implementation
3 * Copyright 2003-2008, Jouni Malinen <j@w1.fi>
4 * Copyright 2004, Instant802 Networks, Inc.
5 * Copyright 2005, Devicescape Software, Inc.
6 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
7 * Copyright 2007, Michael Wu <flamingice@sourmilk.net>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
14 #include <linux/delay.h>
15 #include <linux/if_ether.h>
16 #include <linux/skbuff.h>
17 #include <linux/if_arp.h>
18 #include <linux/etherdevice.h>
19 #include <linux/moduleparam.h>
20 #include <linux/rtnetlink.h>
21 #include <linux/pm_qos.h>
22 #include <linux/crc32.h>
23 #include <linux/slab.h>
24 #include <linux/export.h>
25 #include <net/mac80211.h>
26 #include <asm/unaligned.h>
28 #include "ieee80211_i.h"
29 #include "driver-ops.h"
33 #define IEEE80211_AUTH_TIMEOUT (HZ / 5)
34 #define IEEE80211_AUTH_TIMEOUT_SHORT (HZ / 10)
35 #define IEEE80211_AUTH_MAX_TRIES 3
36 #define IEEE80211_AUTH_WAIT_ASSOC (HZ * 5)
37 #define IEEE80211_ASSOC_TIMEOUT (HZ / 5)
38 #define IEEE80211_ASSOC_TIMEOUT_SHORT (HZ / 10)
39 #define IEEE80211_ASSOC_MAX_TRIES 3
41 static int max_nullfunc_tries
= 2;
42 module_param(max_nullfunc_tries
, int, 0644);
43 MODULE_PARM_DESC(max_nullfunc_tries
,
44 "Maximum nullfunc tx tries before disconnecting (reason 4).");
46 static int max_probe_tries
= 5;
47 module_param(max_probe_tries
, int, 0644);
48 MODULE_PARM_DESC(max_probe_tries
,
49 "Maximum probe tries before disconnecting (reason 4).");
52 * Beacon loss timeout is calculated as N frames times the
53 * advertised beacon interval. This may need to be somewhat
54 * higher than what hardware might detect to account for
55 * delays in the host processing frames. But since we also
56 * probe on beacon miss before declaring the connection lost
57 * default to what we want.
59 #define IEEE80211_BEACON_LOSS_COUNT 7
62 * Time the connection can be idle before we probe
63 * it to see if we can still talk to the AP.
65 #define IEEE80211_CONNECTION_IDLE_TIME (30 * HZ)
67 * Time we wait for a probe response after sending
68 * a probe request because of beacon loss or for
69 * checking the connection still works.
71 static int probe_wait_ms
= 500;
72 module_param(probe_wait_ms
, int, 0644);
73 MODULE_PARM_DESC(probe_wait_ms
,
74 "Maximum time(ms) to wait for probe response"
75 " before disconnecting (reason 4).");
78 * Weight given to the latest Beacon frame when calculating average signal
79 * strength for Beacon frames received in the current BSS. This must be
82 #define IEEE80211_SIGNAL_AVE_WEIGHT 3
85 * How many Beacon frames need to have been used in average signal strength
86 * before starting to indicate signal change events.
88 #define IEEE80211_SIGNAL_AVE_MIN_COUNT 4
90 #define TMR_RUNNING_TIMER 0
91 #define TMR_RUNNING_CHANSW 1
94 * All cfg80211 functions have to be called outside a locked
95 * section so that they can acquire a lock themselves... This
96 * is much simpler than queuing up things in cfg80211, but we
97 * do need some indirection for that here.
100 /* no action required */
103 /* caller must call cfg80211_send_deauth() */
104 RX_MGMT_CFG80211_DEAUTH
,
106 /* caller must call cfg80211_send_disassoc() */
107 RX_MGMT_CFG80211_DISASSOC
,
109 /* caller must call cfg80211_send_rx_auth() */
110 RX_MGMT_CFG80211_RX_AUTH
,
112 /* caller must call cfg80211_send_rx_assoc() */
113 RX_MGMT_CFG80211_RX_ASSOC
,
115 /* caller must call cfg80211_send_assoc_timeout() */
116 RX_MGMT_CFG80211_ASSOC_TIMEOUT
,
118 /* used when a processed beacon causes a deauth */
119 RX_MGMT_CFG80211_TX_DEAUTH
,
123 static inline void ASSERT_MGD_MTX(struct ieee80211_if_managed
*ifmgd
)
125 lockdep_assert_held(&ifmgd
->mtx
);
129 * We can have multiple work items (and connection probing)
130 * scheduling this timer, but we need to take care to only
131 * reschedule it when it should fire _earlier_ than it was
132 * asked for before, or if it's not pending right now. This
133 * function ensures that. Note that it then is required to
134 * run this function for all timeouts after the first one
135 * has happened -- the work that runs from this timer will
138 static void run_again(struct ieee80211_if_managed
*ifmgd
, unsigned long timeout
)
140 ASSERT_MGD_MTX(ifmgd
);
142 if (!timer_pending(&ifmgd
->timer
) ||
143 time_before(timeout
, ifmgd
->timer
.expires
))
144 mod_timer(&ifmgd
->timer
, timeout
);
147 void ieee80211_sta_reset_beacon_monitor(struct ieee80211_sub_if_data
*sdata
)
149 if (sdata
->vif
.driver_flags
& IEEE80211_VIF_BEACON_FILTER
)
152 if (sdata
->local
->hw
.flags
& IEEE80211_HW_CONNECTION_MONITOR
)
155 mod_timer(&sdata
->u
.mgd
.bcn_mon_timer
,
156 round_jiffies_up(jiffies
+ sdata
->u
.mgd
.beacon_timeout
));
159 void ieee80211_sta_reset_conn_monitor(struct ieee80211_sub_if_data
*sdata
)
161 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
163 if (unlikely(!sdata
->u
.mgd
.associated
))
166 if (sdata
->local
->hw
.flags
& IEEE80211_HW_CONNECTION_MONITOR
)
169 mod_timer(&sdata
->u
.mgd
.conn_mon_timer
,
170 round_jiffies_up(jiffies
+ IEEE80211_CONNECTION_IDLE_TIME
));
172 ifmgd
->probe_send_count
= 0;
175 static int ecw2cw(int ecw
)
177 return (1 << ecw
) - 1;
180 static u32
chandef_downgrade(struct cfg80211_chan_def
*c
)
186 case NL80211_CHAN_WIDTH_20
:
187 c
->width
= NL80211_CHAN_WIDTH_20_NOHT
;
188 ret
= IEEE80211_STA_DISABLE_HT
| IEEE80211_STA_DISABLE_VHT
;
190 case NL80211_CHAN_WIDTH_40
:
191 c
->width
= NL80211_CHAN_WIDTH_20
;
192 c
->center_freq1
= c
->chan
->center_freq
;
193 ret
= IEEE80211_STA_DISABLE_40MHZ
|
194 IEEE80211_STA_DISABLE_VHT
;
196 case NL80211_CHAN_WIDTH_80
:
197 tmp
= (30 + c
->chan
->center_freq
- c
->center_freq1
)/20;
201 c
->center_freq1
= c
->center_freq1
- 20 + 40 * tmp
;
202 c
->width
= NL80211_CHAN_WIDTH_40
;
203 ret
= IEEE80211_STA_DISABLE_VHT
;
205 case NL80211_CHAN_WIDTH_80P80
:
207 c
->width
= NL80211_CHAN_WIDTH_80
;
208 ret
= IEEE80211_STA_DISABLE_80P80MHZ
|
209 IEEE80211_STA_DISABLE_160MHZ
;
211 case NL80211_CHAN_WIDTH_160
:
213 tmp
= (70 + c
->chan
->center_freq
- c
->center_freq1
)/20;
216 c
->center_freq1
= c
->center_freq1
- 40 + 80 * tmp
;
217 c
->width
= NL80211_CHAN_WIDTH_80
;
218 ret
= IEEE80211_STA_DISABLE_80P80MHZ
|
219 IEEE80211_STA_DISABLE_160MHZ
;
222 case NL80211_CHAN_WIDTH_20_NOHT
:
224 c
->width
= NL80211_CHAN_WIDTH_20_NOHT
;
225 ret
= IEEE80211_STA_DISABLE_HT
| IEEE80211_STA_DISABLE_VHT
;
229 WARN_ON_ONCE(!cfg80211_chandef_valid(c
));
235 ieee80211_determine_chantype(struct ieee80211_sub_if_data
*sdata
,
236 struct ieee80211_supported_band
*sband
,
237 struct ieee80211_channel
*channel
,
238 const struct ieee80211_ht_operation
*ht_oper
,
239 const struct ieee80211_vht_operation
*vht_oper
,
240 struct cfg80211_chan_def
*chandef
, bool verbose
)
242 struct cfg80211_chan_def vht_chandef
;
245 chandef
->chan
= channel
;
246 chandef
->width
= NL80211_CHAN_WIDTH_20_NOHT
;
247 chandef
->center_freq1
= channel
->center_freq
;
248 chandef
->center_freq2
= 0;
250 if (!ht_oper
|| !sband
->ht_cap
.ht_supported
) {
251 ret
= IEEE80211_STA_DISABLE_HT
| IEEE80211_STA_DISABLE_VHT
;
255 chandef
->width
= NL80211_CHAN_WIDTH_20
;
257 ht_cfreq
= ieee80211_channel_to_frequency(ht_oper
->primary_chan
,
259 /* check that channel matches the right operating channel */
260 if (channel
->center_freq
!= ht_cfreq
) {
262 * It's possible that some APs are confused here;
263 * Netgear WNDR3700 sometimes reports 4 higher than
264 * the actual channel in association responses, but
265 * since we look at probe response/beacon data here
270 "Wrong control channel: center-freq: %d ht-cfreq: %d ht->primary_chan: %d band: %d - Disabling HT\n",
271 channel
->center_freq
, ht_cfreq
,
272 ht_oper
->primary_chan
, channel
->band
);
273 ret
= IEEE80211_STA_DISABLE_HT
| IEEE80211_STA_DISABLE_VHT
;
277 /* check 40 MHz support, if we have it */
278 if (sband
->ht_cap
.cap
& IEEE80211_HT_CAP_SUP_WIDTH_20_40
) {
279 switch (ht_oper
->ht_param
& IEEE80211_HT_PARAM_CHA_SEC_OFFSET
) {
280 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE
:
281 chandef
->width
= NL80211_CHAN_WIDTH_40
;
282 chandef
->center_freq1
+= 10;
284 case IEEE80211_HT_PARAM_CHA_SEC_BELOW
:
285 chandef
->width
= NL80211_CHAN_WIDTH_40
;
286 chandef
->center_freq1
-= 10;
290 /* 40 MHz (and 80 MHz) must be supported for VHT */
291 ret
= IEEE80211_STA_DISABLE_VHT
;
295 if (!vht_oper
|| !sband
->vht_cap
.vht_supported
) {
296 ret
= IEEE80211_STA_DISABLE_VHT
;
300 vht_chandef
.chan
= channel
;
301 vht_chandef
.center_freq1
=
302 ieee80211_channel_to_frequency(vht_oper
->center_freq_seg1_idx
,
304 vht_chandef
.center_freq2
= 0;
306 if (vht_oper
->center_freq_seg2_idx
)
307 vht_chandef
.center_freq2
=
308 ieee80211_channel_to_frequency(
309 vht_oper
->center_freq_seg2_idx
,
312 switch (vht_oper
->chan_width
) {
313 case IEEE80211_VHT_CHANWIDTH_USE_HT
:
314 vht_chandef
.width
= chandef
->width
;
316 case IEEE80211_VHT_CHANWIDTH_80MHZ
:
317 vht_chandef
.width
= NL80211_CHAN_WIDTH_80
;
319 case IEEE80211_VHT_CHANWIDTH_160MHZ
:
320 vht_chandef
.width
= NL80211_CHAN_WIDTH_160
;
322 case IEEE80211_VHT_CHANWIDTH_80P80MHZ
:
323 vht_chandef
.width
= NL80211_CHAN_WIDTH_80P80
;
328 "AP VHT operation IE has invalid channel width (%d), disable VHT\n",
329 vht_oper
->chan_width
);
330 ret
= IEEE80211_STA_DISABLE_VHT
;
334 if (!cfg80211_chandef_valid(&vht_chandef
)) {
337 "AP VHT information is invalid, disable VHT\n");
338 ret
= IEEE80211_STA_DISABLE_VHT
;
342 if (cfg80211_chandef_identical(chandef
, &vht_chandef
)) {
347 if (!cfg80211_chandef_compatible(chandef
, &vht_chandef
)) {
350 "AP VHT information doesn't match HT, disable VHT\n");
351 ret
= IEEE80211_STA_DISABLE_VHT
;
355 *chandef
= vht_chandef
;
360 /* don't print the message below for VHT mismatch if VHT is disabled */
361 if (ret
& IEEE80211_STA_DISABLE_VHT
)
362 vht_chandef
= *chandef
;
364 while (!cfg80211_chandef_usable(sdata
->local
->hw
.wiphy
, chandef
,
365 IEEE80211_CHAN_DISABLED
)) {
366 if (WARN_ON(chandef
->width
== NL80211_CHAN_WIDTH_20_NOHT
)) {
367 ret
= IEEE80211_STA_DISABLE_HT
|
368 IEEE80211_STA_DISABLE_VHT
;
372 ret
|= chandef_downgrade(chandef
);
375 if (chandef
->width
!= vht_chandef
.width
&& verbose
)
377 "capabilities/regulatory prevented using AP HT/VHT configuration, downgraded\n");
379 WARN_ON_ONCE(!cfg80211_chandef_valid(chandef
));
383 static int ieee80211_config_bw(struct ieee80211_sub_if_data
*sdata
,
384 struct sta_info
*sta
,
385 const struct ieee80211_ht_operation
*ht_oper
,
386 const struct ieee80211_vht_operation
*vht_oper
,
387 const u8
*bssid
, u32
*changed
)
389 struct ieee80211_local
*local
= sdata
->local
;
390 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
391 struct ieee80211_supported_band
*sband
;
392 struct ieee80211_channel
*chan
;
393 struct cfg80211_chan_def chandef
;
396 enum ieee80211_sta_rx_bandwidth new_sta_bw
;
399 /* if HT was/is disabled, don't track any bandwidth changes */
400 if (ifmgd
->flags
& IEEE80211_STA_DISABLE_HT
|| !ht_oper
)
403 /* don't check VHT if we associated as non-VHT station */
404 if (ifmgd
->flags
& IEEE80211_STA_DISABLE_VHT
)
407 if (WARN_ON_ONCE(!sta
))
410 chan
= sdata
->vif
.bss_conf
.chandef
.chan
;
411 sband
= local
->hw
.wiphy
->bands
[chan
->band
];
413 /* calculate new channel (type) based on HT/VHT operation IEs */
414 flags
= ieee80211_determine_chantype(sdata
, sband
, chan
, ht_oper
,
415 vht_oper
, &chandef
, false);
418 * Downgrade the new channel if we associated with restricted
419 * capabilities. For example, if we associated as a 20 MHz STA
420 * to a 40 MHz AP (due to regulatory, capabilities or config
421 * reasons) then switching to a 40 MHz channel now won't do us
422 * any good -- we couldn't use it with the AP.
424 if (ifmgd
->flags
& IEEE80211_STA_DISABLE_80P80MHZ
&&
425 chandef
.width
== NL80211_CHAN_WIDTH_80P80
)
426 flags
|= chandef_downgrade(&chandef
);
427 if (ifmgd
->flags
& IEEE80211_STA_DISABLE_160MHZ
&&
428 chandef
.width
== NL80211_CHAN_WIDTH_160
)
429 flags
|= chandef_downgrade(&chandef
);
430 if (ifmgd
->flags
& IEEE80211_STA_DISABLE_40MHZ
&&
431 chandef
.width
> NL80211_CHAN_WIDTH_20
)
432 flags
|= chandef_downgrade(&chandef
);
434 if (cfg80211_chandef_identical(&chandef
, &sdata
->vif
.bss_conf
.chandef
))
438 "AP %pM changed bandwidth, new config is %d MHz, width %d (%d/%d MHz)\n",
439 ifmgd
->bssid
, chandef
.chan
->center_freq
, chandef
.width
,
440 chandef
.center_freq1
, chandef
.center_freq2
);
442 if (flags
!= (ifmgd
->flags
& (IEEE80211_STA_DISABLE_HT
|
443 IEEE80211_STA_DISABLE_VHT
|
444 IEEE80211_STA_DISABLE_40MHZ
|
445 IEEE80211_STA_DISABLE_80P80MHZ
|
446 IEEE80211_STA_DISABLE_160MHZ
)) ||
447 !cfg80211_chandef_valid(&chandef
)) {
449 "AP %pM changed bandwidth in a way we can't support - disconnect\n",
454 switch (chandef
.width
) {
455 case NL80211_CHAN_WIDTH_20_NOHT
:
456 case NL80211_CHAN_WIDTH_20
:
457 new_sta_bw
= IEEE80211_STA_RX_BW_20
;
459 case NL80211_CHAN_WIDTH_40
:
460 new_sta_bw
= IEEE80211_STA_RX_BW_40
;
462 case NL80211_CHAN_WIDTH_80
:
463 new_sta_bw
= IEEE80211_STA_RX_BW_80
;
465 case NL80211_CHAN_WIDTH_80P80
:
466 case NL80211_CHAN_WIDTH_160
:
467 new_sta_bw
= IEEE80211_STA_RX_BW_160
;
473 if (new_sta_bw
> sta
->cur_max_bandwidth
)
474 new_sta_bw
= sta
->cur_max_bandwidth
;
476 if (new_sta_bw
< sta
->sta
.bandwidth
) {
477 sta
->sta
.bandwidth
= new_sta_bw
;
478 rate_control_rate_update(local
, sband
, sta
,
479 IEEE80211_RC_BW_CHANGED
);
482 ret
= ieee80211_vif_change_bandwidth(sdata
, &chandef
, changed
);
485 "AP %pM changed bandwidth to incompatible one - disconnect\n",
490 if (new_sta_bw
> sta
->sta
.bandwidth
) {
491 sta
->sta
.bandwidth
= new_sta_bw
;
492 rate_control_rate_update(local
, sband
, sta
,
493 IEEE80211_RC_BW_CHANGED
);
496 ht_opmode
= le16_to_cpu(ht_oper
->operation_mode
);
498 /* if bss configuration changed store the new one */
499 if (sdata
->vif
.bss_conf
.ht_operation_mode
!= ht_opmode
) {
500 *changed
|= BSS_CHANGED_HT
;
501 sdata
->vif
.bss_conf
.ht_operation_mode
= ht_opmode
;
507 /* frame sending functions */
509 static int ieee80211_compatible_rates(const u8
*supp_rates
, int supp_rates_len
,
510 struct ieee80211_supported_band
*sband
,
516 for (i
= 0; i
< supp_rates_len
; i
++) {
517 int rate
= (supp_rates
[i
] & 0x7F) * 5;
519 for (j
= 0; j
< sband
->n_bitrates
; j
++)
520 if (sband
->bitrates
[j
].bitrate
== rate
) {
530 static void ieee80211_add_ht_ie(struct ieee80211_sub_if_data
*sdata
,
531 struct sk_buff
*skb
, u8 ap_ht_param
,
532 struct ieee80211_supported_band
*sband
,
533 struct ieee80211_channel
*channel
,
534 enum ieee80211_smps_mode smps
)
537 u32 flags
= channel
->flags
;
539 struct ieee80211_sta_ht_cap ht_cap
;
541 BUILD_BUG_ON(sizeof(ht_cap
) != sizeof(sband
->ht_cap
));
543 memcpy(&ht_cap
, &sband
->ht_cap
, sizeof(ht_cap
));
544 ieee80211_apply_htcap_overrides(sdata
, &ht_cap
);
546 /* determine capability flags */
549 switch (ap_ht_param
& IEEE80211_HT_PARAM_CHA_SEC_OFFSET
) {
550 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE
:
551 if (flags
& IEEE80211_CHAN_NO_HT40PLUS
) {
552 cap
&= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
553 cap
&= ~IEEE80211_HT_CAP_SGI_40
;
556 case IEEE80211_HT_PARAM_CHA_SEC_BELOW
:
557 if (flags
& IEEE80211_CHAN_NO_HT40MINUS
) {
558 cap
&= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
559 cap
&= ~IEEE80211_HT_CAP_SGI_40
;
565 * If 40 MHz was disabled associate as though we weren't
566 * capable of 40 MHz -- some broken APs will never fall
567 * back to trying to transmit in 20 MHz.
569 if (sdata
->u
.mgd
.flags
& IEEE80211_STA_DISABLE_40MHZ
) {
570 cap
&= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
571 cap
&= ~IEEE80211_HT_CAP_SGI_40
;
574 /* set SM PS mode properly */
575 cap
&= ~IEEE80211_HT_CAP_SM_PS
;
577 case IEEE80211_SMPS_AUTOMATIC
:
578 case IEEE80211_SMPS_NUM_MODES
:
580 case IEEE80211_SMPS_OFF
:
581 cap
|= WLAN_HT_CAP_SM_PS_DISABLED
<<
582 IEEE80211_HT_CAP_SM_PS_SHIFT
;
584 case IEEE80211_SMPS_STATIC
:
585 cap
|= WLAN_HT_CAP_SM_PS_STATIC
<<
586 IEEE80211_HT_CAP_SM_PS_SHIFT
;
588 case IEEE80211_SMPS_DYNAMIC
:
589 cap
|= WLAN_HT_CAP_SM_PS_DYNAMIC
<<
590 IEEE80211_HT_CAP_SM_PS_SHIFT
;
594 /* reserve and fill IE */
595 pos
= skb_put(skb
, sizeof(struct ieee80211_ht_cap
) + 2);
596 ieee80211_ie_build_ht_cap(pos
, &ht_cap
, cap
);
599 static void ieee80211_add_vht_ie(struct ieee80211_sub_if_data
*sdata
,
601 struct ieee80211_supported_band
*sband
,
602 struct ieee80211_vht_cap
*ap_vht_cap
)
606 struct ieee80211_sta_vht_cap vht_cap
;
609 BUILD_BUG_ON(sizeof(vht_cap
) != sizeof(sband
->vht_cap
));
611 memcpy(&vht_cap
, &sband
->vht_cap
, sizeof(vht_cap
));
613 /* determine capability flags */
616 if (sdata
->u
.mgd
.flags
& IEEE80211_STA_DISABLE_80P80MHZ
) {
617 cap
&= ~IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ
;
618 cap
|= IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ
;
621 if (sdata
->u
.mgd
.flags
& IEEE80211_STA_DISABLE_160MHZ
) {
622 cap
&= ~IEEE80211_VHT_CAP_SHORT_GI_160
;
623 cap
&= ~IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ
;
627 * Some APs apparently get confused if our capabilities are better
628 * than theirs, so restrict what we advertise in the assoc request.
630 if (!(ap_vht_cap
->vht_cap_info
&
631 cpu_to_le32(IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE
)))
632 cap
&= ~IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE
;
634 if (!(ap_vht_cap
->vht_cap_info
&
635 cpu_to_le32(IEEE80211_VHT_CAP_TXSTBC
)))
636 cap
&= ~(IEEE80211_VHT_CAP_RXSTBC_1
|
637 IEEE80211_VHT_CAP_RXSTBC_3
|
638 IEEE80211_VHT_CAP_RXSTBC_4
);
640 for (i
= 0; i
< 8; i
++) {
642 u16 mask
= IEEE80211_VHT_MCS_NOT_SUPPORTED
<< shift
;
645 ap_mcs
= (le16_to_cpu(ap_vht_cap
->supp_mcs
.tx_mcs_map
) &
647 our_mcs
= (le16_to_cpu(vht_cap
.vht_mcs
.rx_mcs_map
) &
650 if (our_mcs
== IEEE80211_VHT_MCS_NOT_SUPPORTED
)
655 if (our_mcs
<= ap_mcs
)
658 case IEEE80211_VHT_MCS_NOT_SUPPORTED
:
659 vht_cap
.vht_mcs
.rx_mcs_map
&= cpu_to_le16(~mask
);
660 vht_cap
.vht_mcs
.rx_mcs_map
|=
661 cpu_to_le16(ap_mcs
<< shift
);
665 /* reserve and fill IE */
666 pos
= skb_put(skb
, sizeof(struct ieee80211_vht_cap
) + 2);
667 ieee80211_ie_build_vht_cap(pos
, &vht_cap
, cap
);
670 static void ieee80211_send_assoc(struct ieee80211_sub_if_data
*sdata
)
672 struct ieee80211_local
*local
= sdata
->local
;
673 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
674 struct ieee80211_mgd_assoc_data
*assoc_data
= ifmgd
->assoc_data
;
676 struct ieee80211_mgmt
*mgmt
;
678 size_t offset
= 0, noffset
;
679 int i
, count
, rates_len
, supp_rates_len
;
681 struct ieee80211_supported_band
*sband
;
682 struct ieee80211_chanctx_conf
*chanctx_conf
;
683 struct ieee80211_channel
*chan
;
686 lockdep_assert_held(&ifmgd
->mtx
);
689 chanctx_conf
= rcu_dereference(sdata
->vif
.chanctx_conf
);
690 if (WARN_ON(!chanctx_conf
)) {
694 chan
= chanctx_conf
->def
.chan
;
696 sband
= local
->hw
.wiphy
->bands
[chan
->band
];
698 if (assoc_data
->supp_rates_len
) {
700 * Get all rates supported by the device and the AP as
701 * some APs don't like getting a superset of their rates
702 * in the association request (e.g. D-Link DAP 1353 in
705 rates_len
= ieee80211_compatible_rates(assoc_data
->supp_rates
,
706 assoc_data
->supp_rates_len
,
710 * In case AP not provide any supported rates information
711 * before association, we send information element(s) with
712 * all rates that we support.
715 rates_len
= sband
->n_bitrates
;
718 skb
= alloc_skb(local
->hw
.extra_tx_headroom
+
719 sizeof(*mgmt
) + /* bit too much but doesn't matter */
720 2 + assoc_data
->ssid_len
+ /* SSID */
721 4 + rates_len
+ /* (extended) rates */
722 4 + /* power capability */
723 2 + 2 * sband
->n_channels
+ /* supported channels */
724 2 + sizeof(struct ieee80211_ht_cap
) + /* HT */
725 2 + sizeof(struct ieee80211_vht_cap
) + /* VHT */
726 assoc_data
->ie_len
+ /* extra IEs */
732 skb_reserve(skb
, local
->hw
.extra_tx_headroom
);
734 capab
= WLAN_CAPABILITY_ESS
;
736 if (sband
->band
== IEEE80211_BAND_2GHZ
) {
737 if (!(local
->hw
.flags
& IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE
))
738 capab
|= WLAN_CAPABILITY_SHORT_SLOT_TIME
;
739 if (!(local
->hw
.flags
& IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE
))
740 capab
|= WLAN_CAPABILITY_SHORT_PREAMBLE
;
743 if (assoc_data
->capability
& WLAN_CAPABILITY_PRIVACY
)
744 capab
|= WLAN_CAPABILITY_PRIVACY
;
746 if ((assoc_data
->capability
& WLAN_CAPABILITY_SPECTRUM_MGMT
) &&
747 (local
->hw
.flags
& IEEE80211_HW_SPECTRUM_MGMT
))
748 capab
|= WLAN_CAPABILITY_SPECTRUM_MGMT
;
750 mgmt
= (struct ieee80211_mgmt
*) skb_put(skb
, 24);
752 memcpy(mgmt
->da
, assoc_data
->bss
->bssid
, ETH_ALEN
);
753 memcpy(mgmt
->sa
, sdata
->vif
.addr
, ETH_ALEN
);
754 memcpy(mgmt
->bssid
, assoc_data
->bss
->bssid
, ETH_ALEN
);
756 if (!is_zero_ether_addr(assoc_data
->prev_bssid
)) {
758 mgmt
->frame_control
= cpu_to_le16(IEEE80211_FTYPE_MGMT
|
759 IEEE80211_STYPE_REASSOC_REQ
);
760 mgmt
->u
.reassoc_req
.capab_info
= cpu_to_le16(capab
);
761 mgmt
->u
.reassoc_req
.listen_interval
=
762 cpu_to_le16(local
->hw
.conf
.listen_interval
);
763 memcpy(mgmt
->u
.reassoc_req
.current_ap
, assoc_data
->prev_bssid
,
767 mgmt
->frame_control
= cpu_to_le16(IEEE80211_FTYPE_MGMT
|
768 IEEE80211_STYPE_ASSOC_REQ
);
769 mgmt
->u
.assoc_req
.capab_info
= cpu_to_le16(capab
);
770 mgmt
->u
.assoc_req
.listen_interval
=
771 cpu_to_le16(local
->hw
.conf
.listen_interval
);
775 pos
= skb_put(skb
, 2 + assoc_data
->ssid_len
);
776 *pos
++ = WLAN_EID_SSID
;
777 *pos
++ = assoc_data
->ssid_len
;
778 memcpy(pos
, assoc_data
->ssid
, assoc_data
->ssid_len
);
780 /* add all rates which were marked to be used above */
781 supp_rates_len
= rates_len
;
782 if (supp_rates_len
> 8)
785 pos
= skb_put(skb
, supp_rates_len
+ 2);
786 *pos
++ = WLAN_EID_SUPP_RATES
;
787 *pos
++ = supp_rates_len
;
790 for (i
= 0; i
< sband
->n_bitrates
; i
++) {
791 if (BIT(i
) & rates
) {
792 int rate
= sband
->bitrates
[i
].bitrate
;
793 *pos
++ = (u8
) (rate
/ 5);
799 if (rates_len
> count
) {
800 pos
= skb_put(skb
, rates_len
- count
+ 2);
801 *pos
++ = WLAN_EID_EXT_SUPP_RATES
;
802 *pos
++ = rates_len
- count
;
804 for (i
++; i
< sband
->n_bitrates
; i
++) {
805 if (BIT(i
) & rates
) {
806 int rate
= sband
->bitrates
[i
].bitrate
;
807 *pos
++ = (u8
) (rate
/ 5);
812 if (capab
& WLAN_CAPABILITY_SPECTRUM_MGMT
) {
813 /* 1. power capabilities */
814 pos
= skb_put(skb
, 4);
815 *pos
++ = WLAN_EID_PWR_CAPABILITY
;
817 *pos
++ = 0; /* min tx power */
818 *pos
++ = chan
->max_power
; /* max tx power */
820 /* 2. supported channels */
821 /* TODO: get this in reg domain format */
822 pos
= skb_put(skb
, 2 * sband
->n_channels
+ 2);
823 *pos
++ = WLAN_EID_SUPPORTED_CHANNELS
;
824 *pos
++ = 2 * sband
->n_channels
;
825 for (i
= 0; i
< sband
->n_channels
; i
++) {
826 *pos
++ = ieee80211_frequency_to_channel(
827 sband
->channels
[i
].center_freq
);
828 *pos
++ = 1; /* one channel in the subband*/
832 /* if present, add any custom IEs that go before HT */
833 if (assoc_data
->ie_len
&& assoc_data
->ie
) {
834 static const u8 before_ht
[] = {
837 WLAN_EID_EXT_SUPP_RATES
,
838 WLAN_EID_PWR_CAPABILITY
,
839 WLAN_EID_SUPPORTED_CHANNELS
,
842 WLAN_EID_RRM_ENABLED_CAPABILITIES
,
843 WLAN_EID_MOBILITY_DOMAIN
,
844 WLAN_EID_SUPPORTED_REGULATORY_CLASSES
,
846 noffset
= ieee80211_ie_split(assoc_data
->ie
, assoc_data
->ie_len
,
847 before_ht
, ARRAY_SIZE(before_ht
),
849 pos
= skb_put(skb
, noffset
- offset
);
850 memcpy(pos
, assoc_data
->ie
+ offset
, noffset
- offset
);
854 if (WARN_ON_ONCE((ifmgd
->flags
& IEEE80211_STA_DISABLE_HT
) &&
855 !(ifmgd
->flags
& IEEE80211_STA_DISABLE_VHT
)))
856 ifmgd
->flags
|= IEEE80211_STA_DISABLE_VHT
;
858 if (!(ifmgd
->flags
& IEEE80211_STA_DISABLE_HT
))
859 ieee80211_add_ht_ie(sdata
, skb
, assoc_data
->ap_ht_param
,
860 sband
, chan
, sdata
->smps_mode
);
862 if (!(ifmgd
->flags
& IEEE80211_STA_DISABLE_VHT
))
863 ieee80211_add_vht_ie(sdata
, skb
, sband
,
864 &assoc_data
->ap_vht_cap
);
866 /* if present, add any custom non-vendor IEs that go after HT */
867 if (assoc_data
->ie_len
&& assoc_data
->ie
) {
868 noffset
= ieee80211_ie_split_vendor(assoc_data
->ie
,
871 pos
= skb_put(skb
, noffset
- offset
);
872 memcpy(pos
, assoc_data
->ie
+ offset
, noffset
- offset
);
876 if (assoc_data
->wmm
) {
877 if (assoc_data
->uapsd
) {
878 qos_info
= ifmgd
->uapsd_queues
;
879 qos_info
|= (ifmgd
->uapsd_max_sp_len
<<
880 IEEE80211_WMM_IE_STA_QOSINFO_SP_SHIFT
);
885 pos
= skb_put(skb
, 9);
886 *pos
++ = WLAN_EID_VENDOR_SPECIFIC
;
887 *pos
++ = 7; /* len */
888 *pos
++ = 0x00; /* Microsoft OUI 00:50:F2 */
891 *pos
++ = 2; /* WME */
892 *pos
++ = 0; /* WME info */
893 *pos
++ = 1; /* WME ver */
897 /* add any remaining custom (i.e. vendor specific here) IEs */
898 if (assoc_data
->ie_len
&& assoc_data
->ie
) {
899 noffset
= assoc_data
->ie_len
;
900 pos
= skb_put(skb
, noffset
- offset
);
901 memcpy(pos
, assoc_data
->ie
+ offset
, noffset
- offset
);
904 drv_mgd_prepare_tx(local
, sdata
);
906 IEEE80211_SKB_CB(skb
)->flags
|= IEEE80211_TX_INTFL_DONT_ENCRYPT
;
907 if (local
->hw
.flags
& IEEE80211_HW_REPORTS_TX_ACK_STATUS
)
908 IEEE80211_SKB_CB(skb
)->flags
|= IEEE80211_TX_CTL_REQ_TX_STATUS
|
909 IEEE80211_TX_INTFL_MLME_CONN_TX
;
910 ieee80211_tx_skb(sdata
, skb
);
913 void ieee80211_send_pspoll(struct ieee80211_local
*local
,
914 struct ieee80211_sub_if_data
*sdata
)
916 struct ieee80211_pspoll
*pspoll
;
919 skb
= ieee80211_pspoll_get(&local
->hw
, &sdata
->vif
);
923 pspoll
= (struct ieee80211_pspoll
*) skb
->data
;
924 pspoll
->frame_control
|= cpu_to_le16(IEEE80211_FCTL_PM
);
926 IEEE80211_SKB_CB(skb
)->flags
|= IEEE80211_TX_INTFL_DONT_ENCRYPT
;
927 ieee80211_tx_skb(sdata
, skb
);
930 void ieee80211_send_nullfunc(struct ieee80211_local
*local
,
931 struct ieee80211_sub_if_data
*sdata
,
935 struct ieee80211_hdr_3addr
*nullfunc
;
936 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
938 skb
= ieee80211_nullfunc_get(&local
->hw
, &sdata
->vif
);
942 nullfunc
= (struct ieee80211_hdr_3addr
*) skb
->data
;
944 nullfunc
->frame_control
|= cpu_to_le16(IEEE80211_FCTL_PM
);
946 IEEE80211_SKB_CB(skb
)->flags
|= IEEE80211_TX_INTFL_DONT_ENCRYPT
|
947 IEEE80211_TX_INTFL_OFFCHAN_TX_OK
;
948 if (ifmgd
->flags
& (IEEE80211_STA_BEACON_POLL
|
949 IEEE80211_STA_CONNECTION_POLL
))
950 IEEE80211_SKB_CB(skb
)->flags
|= IEEE80211_TX_CTL_USE_MINRATE
;
952 ieee80211_tx_skb(sdata
, skb
);
955 static void ieee80211_send_4addr_nullfunc(struct ieee80211_local
*local
,
956 struct ieee80211_sub_if_data
*sdata
)
959 struct ieee80211_hdr
*nullfunc
;
962 if (WARN_ON(sdata
->vif
.type
!= NL80211_IFTYPE_STATION
))
965 skb
= dev_alloc_skb(local
->hw
.extra_tx_headroom
+ 30);
969 skb_reserve(skb
, local
->hw
.extra_tx_headroom
);
971 nullfunc
= (struct ieee80211_hdr
*) skb_put(skb
, 30);
972 memset(nullfunc
, 0, 30);
973 fc
= cpu_to_le16(IEEE80211_FTYPE_DATA
| IEEE80211_STYPE_NULLFUNC
|
974 IEEE80211_FCTL_FROMDS
| IEEE80211_FCTL_TODS
);
975 nullfunc
->frame_control
= fc
;
976 memcpy(nullfunc
->addr1
, sdata
->u
.mgd
.bssid
, ETH_ALEN
);
977 memcpy(nullfunc
->addr2
, sdata
->vif
.addr
, ETH_ALEN
);
978 memcpy(nullfunc
->addr3
, sdata
->u
.mgd
.bssid
, ETH_ALEN
);
979 memcpy(nullfunc
->addr4
, sdata
->vif
.addr
, ETH_ALEN
);
981 IEEE80211_SKB_CB(skb
)->flags
|= IEEE80211_TX_INTFL_DONT_ENCRYPT
;
982 ieee80211_tx_skb(sdata
, skb
);
985 /* spectrum management related things */
986 static void ieee80211_chswitch_work(struct work_struct
*work
)
988 struct ieee80211_sub_if_data
*sdata
=
989 container_of(work
, struct ieee80211_sub_if_data
, u
.mgd
.chswitch_work
);
990 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
992 if (!ieee80211_sdata_running(sdata
))
995 mutex_lock(&ifmgd
->mtx
);
996 if (!ifmgd
->associated
)
999 sdata
->local
->_oper_channel
= sdata
->local
->csa_channel
;
1000 if (!sdata
->local
->ops
->channel_switch
) {
1001 /* call "hw_config" only if doing sw channel switch */
1002 ieee80211_hw_config(sdata
->local
,
1003 IEEE80211_CONF_CHANGE_CHANNEL
);
1005 /* update the device channel directly */
1006 sdata
->local
->hw
.conf
.channel
= sdata
->local
->_oper_channel
;
1009 /* XXX: shouldn't really modify cfg80211-owned data! */
1010 ifmgd
->associated
->channel
= sdata
->local
->_oper_channel
;
1012 /* XXX: wait for a beacon first? */
1013 ieee80211_wake_queues_by_reason(&sdata
->local
->hw
,
1014 IEEE80211_QUEUE_STOP_REASON_CSA
);
1016 ifmgd
->flags
&= ~IEEE80211_STA_CSA_RECEIVED
;
1017 mutex_unlock(&ifmgd
->mtx
);
1020 void ieee80211_chswitch_done(struct ieee80211_vif
*vif
, bool success
)
1022 struct ieee80211_sub_if_data
*sdata
= vif_to_sdata(vif
);
1023 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
1025 trace_api_chswitch_done(sdata
, success
);
1028 "driver channel switch failed, disconnecting\n");
1029 ieee80211_queue_work(&sdata
->local
->hw
,
1030 &ifmgd
->csa_connection_drop_work
);
1032 ieee80211_queue_work(&sdata
->local
->hw
, &ifmgd
->chswitch_work
);
1035 EXPORT_SYMBOL(ieee80211_chswitch_done
);
1037 static void ieee80211_chswitch_timer(unsigned long data
)
1039 struct ieee80211_sub_if_data
*sdata
=
1040 (struct ieee80211_sub_if_data
*) data
;
1041 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
1043 if (sdata
->local
->quiescing
) {
1044 set_bit(TMR_RUNNING_CHANSW
, &ifmgd
->timers_running
);
1048 ieee80211_queue_work(&sdata
->local
->hw
, &ifmgd
->chswitch_work
);
1052 ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data
*sdata
,
1053 const struct ieee80211_channel_sw_ie
*sw_elem
,
1054 struct ieee80211_bss
*bss
, u64 timestamp
)
1056 struct cfg80211_bss
*cbss
=
1057 container_of((void *)bss
, struct cfg80211_bss
, priv
);
1058 struct ieee80211_channel
*new_ch
;
1059 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
1060 int new_freq
= ieee80211_channel_to_frequency(sw_elem
->new_ch_num
,
1061 cbss
->channel
->band
);
1062 struct ieee80211_chanctx
*chanctx
;
1064 ASSERT_MGD_MTX(ifmgd
);
1066 if (!ifmgd
->associated
)
1069 if (sdata
->local
->scanning
)
1072 /* Disregard subsequent beacons if we are already running a timer
1075 if (ifmgd
->flags
& IEEE80211_STA_CSA_RECEIVED
)
1078 new_ch
= ieee80211_get_channel(sdata
->local
->hw
.wiphy
, new_freq
);
1079 if (!new_ch
|| new_ch
->flags
& IEEE80211_CHAN_DISABLED
) {
1081 "AP %pM switches to unsupported channel (%d MHz), disconnecting\n",
1082 ifmgd
->associated
->bssid
, new_freq
);
1083 ieee80211_queue_work(&sdata
->local
->hw
,
1084 &ifmgd
->csa_connection_drop_work
);
1088 ifmgd
->flags
|= IEEE80211_STA_CSA_RECEIVED
;
1090 if (sdata
->local
->use_chanctx
) {
1092 "not handling channel switch with channel contexts\n");
1093 ieee80211_queue_work(&sdata
->local
->hw
,
1094 &ifmgd
->csa_connection_drop_work
);
1098 mutex_lock(&sdata
->local
->chanctx_mtx
);
1099 if (WARN_ON(!rcu_access_pointer(sdata
->vif
.chanctx_conf
))) {
1100 mutex_unlock(&sdata
->local
->chanctx_mtx
);
1103 chanctx
= container_of(rcu_access_pointer(sdata
->vif
.chanctx_conf
),
1104 struct ieee80211_chanctx
, conf
);
1105 if (chanctx
->refcount
> 1) {
1107 "channel switch with multiple interfaces on the same channel, disconnecting\n");
1108 ieee80211_queue_work(&sdata
->local
->hw
,
1109 &ifmgd
->csa_connection_drop_work
);
1110 mutex_unlock(&sdata
->local
->chanctx_mtx
);
1113 mutex_unlock(&sdata
->local
->chanctx_mtx
);
1115 sdata
->local
->csa_channel
= new_ch
;
1118 ieee80211_stop_queues_by_reason(&sdata
->local
->hw
,
1119 IEEE80211_QUEUE_STOP_REASON_CSA
);
1121 if (sdata
->local
->ops
->channel_switch
) {
1122 /* use driver's channel switch callback */
1123 struct ieee80211_channel_switch ch_switch
= {
1124 .timestamp
= timestamp
,
1125 .block_tx
= sw_elem
->mode
,
1127 .count
= sw_elem
->count
,
1130 drv_channel_switch(sdata
->local
, &ch_switch
);
1134 /* channel switch handled in software */
1135 if (sw_elem
->count
<= 1)
1136 ieee80211_queue_work(&sdata
->local
->hw
, &ifmgd
->chswitch_work
);
1138 mod_timer(&ifmgd
->chswitch_timer
,
1139 TU_TO_EXP_TIME(sw_elem
->count
*
1140 cbss
->beacon_interval
));
1143 static u32
ieee80211_handle_pwr_constr(struct ieee80211_sub_if_data
*sdata
,
1144 struct ieee80211_channel
*channel
,
1145 const u8
*country_ie
, u8 country_ie_len
,
1146 const u8
*pwr_constr_elem
)
1148 struct ieee80211_country_ie_triplet
*triplet
;
1149 int chan
= ieee80211_frequency_to_channel(channel
->center_freq
);
1150 int i
, chan_pwr
, chan_increment
, new_ap_level
;
1151 bool have_chan_pwr
= false;
1154 if (country_ie_len
% 2 || country_ie_len
< IEEE80211_COUNTRY_IE_MIN_LEN
)
1157 triplet
= (void *)(country_ie
+ 3);
1158 country_ie_len
-= 3;
1160 switch (channel
->band
) {
1164 case IEEE80211_BAND_2GHZ
:
1165 case IEEE80211_BAND_60GHZ
:
1168 case IEEE80211_BAND_5GHZ
:
1174 while (country_ie_len
>= 3) {
1175 u8 first_channel
= triplet
->chans
.first_channel
;
1177 if (first_channel
>= IEEE80211_COUNTRY_EXTENSION_ID
)
1180 for (i
= 0; i
< triplet
->chans
.num_channels
; i
++) {
1181 if (first_channel
+ i
* chan_increment
== chan
) {
1182 have_chan_pwr
= true;
1183 chan_pwr
= triplet
->chans
.max_power
;
1192 country_ie_len
-= 3;
1198 new_ap_level
= max_t(int, 0, chan_pwr
- *pwr_constr_elem
);
1200 if (sdata
->ap_power_level
== new_ap_level
)
1204 "Limiting TX power to %d (%d - %d) dBm as advertised by %pM\n",
1205 new_ap_level
, chan_pwr
, *pwr_constr_elem
,
1206 sdata
->u
.mgd
.bssid
);
1207 sdata
->ap_power_level
= new_ap_level
;
1208 if (__ieee80211_recalc_txpower(sdata
))
1209 return BSS_CHANGED_TXPOWER
;
1214 static void ieee80211_enable_ps(struct ieee80211_local
*local
,
1215 struct ieee80211_sub_if_data
*sdata
)
1217 struct ieee80211_conf
*conf
= &local
->hw
.conf
;
1220 * If we are scanning right now then the parameters will
1221 * take effect when scan finishes.
1223 if (local
->scanning
)
1226 if (conf
->dynamic_ps_timeout
> 0 &&
1227 !(local
->hw
.flags
& IEEE80211_HW_SUPPORTS_DYNAMIC_PS
)) {
1228 mod_timer(&local
->dynamic_ps_timer
, jiffies
+
1229 msecs_to_jiffies(conf
->dynamic_ps_timeout
));
1231 if (local
->hw
.flags
& IEEE80211_HW_PS_NULLFUNC_STACK
)
1232 ieee80211_send_nullfunc(local
, sdata
, 1);
1234 if ((local
->hw
.flags
& IEEE80211_HW_PS_NULLFUNC_STACK
) &&
1235 (local
->hw
.flags
& IEEE80211_HW_REPORTS_TX_ACK_STATUS
))
1238 conf
->flags
|= IEEE80211_CONF_PS
;
1239 ieee80211_hw_config(local
, IEEE80211_CONF_CHANGE_PS
);
1243 static void ieee80211_change_ps(struct ieee80211_local
*local
)
1245 struct ieee80211_conf
*conf
= &local
->hw
.conf
;
1247 if (local
->ps_sdata
) {
1248 ieee80211_enable_ps(local
, local
->ps_sdata
);
1249 } else if (conf
->flags
& IEEE80211_CONF_PS
) {
1250 conf
->flags
&= ~IEEE80211_CONF_PS
;
1251 ieee80211_hw_config(local
, IEEE80211_CONF_CHANGE_PS
);
1252 del_timer_sync(&local
->dynamic_ps_timer
);
1253 cancel_work_sync(&local
->dynamic_ps_enable_work
);
1257 static bool ieee80211_powersave_allowed(struct ieee80211_sub_if_data
*sdata
)
1259 struct ieee80211_if_managed
*mgd
= &sdata
->u
.mgd
;
1260 struct sta_info
*sta
= NULL
;
1261 bool authorized
= false;
1263 if (!mgd
->powersave
)
1269 if (!mgd
->associated
)
1272 if (mgd
->flags
& (IEEE80211_STA_BEACON_POLL
|
1273 IEEE80211_STA_CONNECTION_POLL
))
1277 sta
= sta_info_get(sdata
, mgd
->bssid
);
1279 authorized
= test_sta_flag(sta
, WLAN_STA_AUTHORIZED
);
1285 /* need to hold RTNL or interface lock */
1286 void ieee80211_recalc_ps(struct ieee80211_local
*local
, s32 latency
)
1288 struct ieee80211_sub_if_data
*sdata
, *found
= NULL
;
1292 if (!(local
->hw
.flags
& IEEE80211_HW_SUPPORTS_PS
)) {
1293 local
->ps_sdata
= NULL
;
1297 list_for_each_entry(sdata
, &local
->interfaces
, list
) {
1298 if (!ieee80211_sdata_running(sdata
))
1300 if (sdata
->vif
.type
== NL80211_IFTYPE_AP
) {
1301 /* If an AP vif is found, then disable PS
1302 * by setting the count to zero thereby setting
1308 if (sdata
->vif
.type
!= NL80211_IFTYPE_STATION
)
1314 if (count
== 1 && ieee80211_powersave_allowed(found
)) {
1318 latency
= pm_qos_request(PM_QOS_NETWORK_LATENCY
);
1320 beaconint_us
= ieee80211_tu_to_usec(
1321 found
->vif
.bss_conf
.beacon_int
);
1323 timeout
= local
->dynamic_ps_forced_timeout
;
1326 * Go to full PSM if the user configures a very low
1327 * latency requirement.
1328 * The 2000 second value is there for compatibility
1329 * until the PM_QOS_NETWORK_LATENCY is configured
1332 if (latency
> (1900 * USEC_PER_MSEC
) &&
1333 latency
!= (2000 * USEC_PER_SEC
))
1338 local
->hw
.conf
.dynamic_ps_timeout
= timeout
;
1340 if (beaconint_us
> latency
) {
1341 local
->ps_sdata
= NULL
;
1344 u8 dtimper
= found
->u
.mgd
.dtim_period
;
1346 /* If the TIM IE is invalid, pretend the value is 1 */
1349 else if (dtimper
> 1)
1350 maxslp
= min_t(int, dtimper
,
1351 latency
/ beaconint_us
);
1353 local
->hw
.conf
.max_sleep_period
= maxslp
;
1354 local
->hw
.conf
.ps_dtim_period
= dtimper
;
1355 local
->ps_sdata
= found
;
1358 local
->ps_sdata
= NULL
;
1361 ieee80211_change_ps(local
);
1364 void ieee80211_recalc_ps_vif(struct ieee80211_sub_if_data
*sdata
)
1366 bool ps_allowed
= ieee80211_powersave_allowed(sdata
);
1368 if (sdata
->vif
.bss_conf
.ps
!= ps_allowed
) {
1369 sdata
->vif
.bss_conf
.ps
= ps_allowed
;
1370 ieee80211_bss_info_change_notify(sdata
, BSS_CHANGED_PS
);
1374 void ieee80211_dynamic_ps_disable_work(struct work_struct
*work
)
1376 struct ieee80211_local
*local
=
1377 container_of(work
, struct ieee80211_local
,
1378 dynamic_ps_disable_work
);
1380 if (local
->hw
.conf
.flags
& IEEE80211_CONF_PS
) {
1381 local
->hw
.conf
.flags
&= ~IEEE80211_CONF_PS
;
1382 ieee80211_hw_config(local
, IEEE80211_CONF_CHANGE_PS
);
1385 ieee80211_wake_queues_by_reason(&local
->hw
,
1386 IEEE80211_QUEUE_STOP_REASON_PS
);
1389 void ieee80211_dynamic_ps_enable_work(struct work_struct
*work
)
1391 struct ieee80211_local
*local
=
1392 container_of(work
, struct ieee80211_local
,
1393 dynamic_ps_enable_work
);
1394 struct ieee80211_sub_if_data
*sdata
= local
->ps_sdata
;
1395 struct ieee80211_if_managed
*ifmgd
;
1396 unsigned long flags
;
1399 /* can only happen when PS was just disabled anyway */
1403 ifmgd
= &sdata
->u
.mgd
;
1405 if (local
->hw
.conf
.flags
& IEEE80211_CONF_PS
)
1408 if (local
->hw
.conf
.dynamic_ps_timeout
> 0) {
1409 /* don't enter PS if TX frames are pending */
1410 if (drv_tx_frames_pending(local
)) {
1411 mod_timer(&local
->dynamic_ps_timer
, jiffies
+
1413 local
->hw
.conf
.dynamic_ps_timeout
));
1418 * transmission can be stopped by others which leads to
1419 * dynamic_ps_timer expiry. Postpone the ps timer if it
1420 * is not the actual idle state.
1422 spin_lock_irqsave(&local
->queue_stop_reason_lock
, flags
);
1423 for (q
= 0; q
< local
->hw
.queues
; q
++) {
1424 if (local
->queue_stop_reasons
[q
]) {
1425 spin_unlock_irqrestore(&local
->queue_stop_reason_lock
,
1427 mod_timer(&local
->dynamic_ps_timer
, jiffies
+
1429 local
->hw
.conf
.dynamic_ps_timeout
));
1433 spin_unlock_irqrestore(&local
->queue_stop_reason_lock
, flags
);
1436 if ((local
->hw
.flags
& IEEE80211_HW_PS_NULLFUNC_STACK
) &&
1437 !(ifmgd
->flags
& IEEE80211_STA_NULLFUNC_ACKED
)) {
1438 netif_tx_stop_all_queues(sdata
->dev
);
1440 if (drv_tx_frames_pending(local
))
1441 mod_timer(&local
->dynamic_ps_timer
, jiffies
+
1443 local
->hw
.conf
.dynamic_ps_timeout
));
1445 ieee80211_send_nullfunc(local
, sdata
, 1);
1446 /* Flush to get the tx status of nullfunc frame */
1447 drv_flush(local
, false);
1451 if (!((local
->hw
.flags
& IEEE80211_HW_REPORTS_TX_ACK_STATUS
) &&
1452 (local
->hw
.flags
& IEEE80211_HW_PS_NULLFUNC_STACK
)) ||
1453 (ifmgd
->flags
& IEEE80211_STA_NULLFUNC_ACKED
)) {
1454 ifmgd
->flags
&= ~IEEE80211_STA_NULLFUNC_ACKED
;
1455 local
->hw
.conf
.flags
|= IEEE80211_CONF_PS
;
1456 ieee80211_hw_config(local
, IEEE80211_CONF_CHANGE_PS
);
1459 if (local
->hw
.flags
& IEEE80211_HW_PS_NULLFUNC_STACK
)
1460 netif_tx_wake_all_queues(sdata
->dev
);
1463 void ieee80211_dynamic_ps_timer(unsigned long data
)
1465 struct ieee80211_local
*local
= (void *) data
;
1467 if (local
->quiescing
|| local
->suspended
)
1470 ieee80211_queue_work(&local
->hw
, &local
->dynamic_ps_enable_work
);
1473 void ieee80211_dfs_cac_timer_work(struct work_struct
*work
)
1475 struct delayed_work
*delayed_work
=
1476 container_of(work
, struct delayed_work
, work
);
1477 struct ieee80211_sub_if_data
*sdata
=
1478 container_of(delayed_work
, struct ieee80211_sub_if_data
,
1479 dfs_cac_timer_work
);
1481 ieee80211_vif_release_channel(sdata
);
1483 cfg80211_cac_event(sdata
->dev
, NL80211_RADAR_CAC_FINISHED
, GFP_KERNEL
);
1487 static bool ieee80211_sta_wmm_params(struct ieee80211_local
*local
,
1488 struct ieee80211_sub_if_data
*sdata
,
1489 const u8
*wmm_param
, size_t wmm_param_len
)
1491 struct ieee80211_tx_queue_params params
;
1492 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
1496 u8 uapsd_queues
= 0;
1498 if (!local
->ops
->conf_tx
)
1501 if (local
->hw
.queues
< IEEE80211_NUM_ACS
)
1507 if (wmm_param_len
< 8 || wmm_param
[5] /* version */ != 1)
1510 if (ifmgd
->flags
& IEEE80211_STA_UAPSD_ENABLED
)
1511 uapsd_queues
= ifmgd
->uapsd_queues
;
1513 count
= wmm_param
[6] & 0x0f;
1514 if (count
== ifmgd
->wmm_last_param_set
)
1516 ifmgd
->wmm_last_param_set
= count
;
1518 pos
= wmm_param
+ 8;
1519 left
= wmm_param_len
- 8;
1521 memset(¶ms
, 0, sizeof(params
));
1524 for (; left
>= 4; left
-= 4, pos
+= 4) {
1525 int aci
= (pos
[0] >> 5) & 0x03;
1526 int acm
= (pos
[0] >> 4) & 0x01;
1534 sdata
->wmm_acm
|= BIT(1) | BIT(2); /* BK/- */
1535 if (uapsd_queues
& IEEE80211_WMM_IE_STA_QOSINFO_AC_BK
)
1541 sdata
->wmm_acm
|= BIT(4) | BIT(5); /* CL/VI */
1542 if (uapsd_queues
& IEEE80211_WMM_IE_STA_QOSINFO_AC_VI
)
1548 sdata
->wmm_acm
|= BIT(6) | BIT(7); /* VO/NC */
1549 if (uapsd_queues
& IEEE80211_WMM_IE_STA_QOSINFO_AC_VO
)
1556 sdata
->wmm_acm
|= BIT(0) | BIT(3); /* BE/EE */
1557 if (uapsd_queues
& IEEE80211_WMM_IE_STA_QOSINFO_AC_BE
)
1562 params
.aifs
= pos
[0] & 0x0f;
1563 params
.cw_max
= ecw2cw((pos
[1] & 0xf0) >> 4);
1564 params
.cw_min
= ecw2cw(pos
[1] & 0x0f);
1565 params
.txop
= get_unaligned_le16(pos
+ 2);
1566 params
.uapsd
= uapsd
;
1569 "WMM queue=%d aci=%d acm=%d aifs=%d cWmin=%d cWmax=%d txop=%d uapsd=%d\n",
1571 params
.aifs
, params
.cw_min
, params
.cw_max
,
1572 params
.txop
, params
.uapsd
);
1573 sdata
->tx_conf
[queue
] = params
;
1574 if (drv_conf_tx(local
, sdata
, queue
, ¶ms
))
1576 "failed to set TX queue parameters for queue %d\n",
1580 /* enable WMM or activate new settings */
1581 sdata
->vif
.bss_conf
.qos
= true;
1585 static void __ieee80211_stop_poll(struct ieee80211_sub_if_data
*sdata
)
1587 lockdep_assert_held(&sdata
->local
->mtx
);
1589 sdata
->u
.mgd
.flags
&= ~(IEEE80211_STA_CONNECTION_POLL
|
1590 IEEE80211_STA_BEACON_POLL
);
1591 ieee80211_run_deferred_scan(sdata
->local
);
1594 static void ieee80211_stop_poll(struct ieee80211_sub_if_data
*sdata
)
1596 mutex_lock(&sdata
->local
->mtx
);
1597 __ieee80211_stop_poll(sdata
);
1598 mutex_unlock(&sdata
->local
->mtx
);
1601 static u32
ieee80211_handle_bss_capability(struct ieee80211_sub_if_data
*sdata
,
1602 u16 capab
, bool erp_valid
, u8 erp
)
1604 struct ieee80211_bss_conf
*bss_conf
= &sdata
->vif
.bss_conf
;
1606 bool use_protection
;
1607 bool use_short_preamble
;
1608 bool use_short_slot
;
1611 use_protection
= (erp
& WLAN_ERP_USE_PROTECTION
) != 0;
1612 use_short_preamble
= (erp
& WLAN_ERP_BARKER_PREAMBLE
) == 0;
1614 use_protection
= false;
1615 use_short_preamble
= !!(capab
& WLAN_CAPABILITY_SHORT_PREAMBLE
);
1618 use_short_slot
= !!(capab
& WLAN_CAPABILITY_SHORT_SLOT_TIME
);
1619 if (ieee80211_get_sdata_band(sdata
) == IEEE80211_BAND_5GHZ
)
1620 use_short_slot
= true;
1622 if (use_protection
!= bss_conf
->use_cts_prot
) {
1623 bss_conf
->use_cts_prot
= use_protection
;
1624 changed
|= BSS_CHANGED_ERP_CTS_PROT
;
1627 if (use_short_preamble
!= bss_conf
->use_short_preamble
) {
1628 bss_conf
->use_short_preamble
= use_short_preamble
;
1629 changed
|= BSS_CHANGED_ERP_PREAMBLE
;
1632 if (use_short_slot
!= bss_conf
->use_short_slot
) {
1633 bss_conf
->use_short_slot
= use_short_slot
;
1634 changed
|= BSS_CHANGED_ERP_SLOT
;
1640 static void ieee80211_set_associated(struct ieee80211_sub_if_data
*sdata
,
1641 struct cfg80211_bss
*cbss
,
1642 u32 bss_info_changed
)
1644 struct ieee80211_bss
*bss
= (void *)cbss
->priv
;
1645 struct ieee80211_local
*local
= sdata
->local
;
1646 struct ieee80211_bss_conf
*bss_conf
= &sdata
->vif
.bss_conf
;
1648 bss_info_changed
|= BSS_CHANGED_ASSOC
;
1649 bss_info_changed
|= ieee80211_handle_bss_capability(sdata
,
1650 bss_conf
->assoc_capability
, bss
->has_erp_value
, bss
->erp_value
);
1652 sdata
->u
.mgd
.beacon_timeout
= usecs_to_jiffies(ieee80211_tu_to_usec(
1653 IEEE80211_BEACON_LOSS_COUNT
* bss_conf
->beacon_int
));
1655 sdata
->u
.mgd
.associated
= cbss
;
1656 memcpy(sdata
->u
.mgd
.bssid
, cbss
->bssid
, ETH_ALEN
);
1658 sdata
->u
.mgd
.flags
|= IEEE80211_STA_RESET_SIGNAL_AVE
;
1660 if (sdata
->vif
.p2p
) {
1661 const struct cfg80211_bss_ies
*ies
;
1664 ies
= rcu_dereference(cbss
->ies
);
1669 ret
= cfg80211_get_p2p_attr(
1670 ies
->data
, ies
->len
,
1671 IEEE80211_P2P_ATTR_ABSENCE_NOTICE
,
1674 bss_conf
->p2p_oppps
= noa
[1] & 0x80;
1675 bss_conf
->p2p_ctwindow
= noa
[1] & 0x7f;
1676 bss_info_changed
|= BSS_CHANGED_P2P_PS
;
1677 sdata
->u
.mgd
.p2p_noa_index
= noa
[0];
1683 /* just to be sure */
1684 ieee80211_stop_poll(sdata
);
1686 ieee80211_led_assoc(local
, 1);
1688 if (sdata
->u
.mgd
.assoc_data
->have_beacon
) {
1690 * If the AP is buggy we may get here with no DTIM period
1691 * known, so assume it's 1 which is the only safe assumption
1692 * in that case, although if the TIM IE is broken powersave
1693 * probably just won't work at all.
1695 bss_conf
->dtim_period
= sdata
->u
.mgd
.dtim_period
?: 1;
1696 bss_info_changed
|= BSS_CHANGED_DTIM_PERIOD
;
1698 bss_conf
->dtim_period
= 0;
1701 bss_conf
->assoc
= 1;
1703 /* Tell the driver to monitor connection quality (if supported) */
1704 if (sdata
->vif
.driver_flags
& IEEE80211_VIF_SUPPORTS_CQM_RSSI
&&
1705 bss_conf
->cqm_rssi_thold
)
1706 bss_info_changed
|= BSS_CHANGED_CQM
;
1708 /* Enable ARP filtering */
1709 if (bss_conf
->arp_addr_cnt
)
1710 bss_info_changed
|= BSS_CHANGED_ARP_FILTER
;
1712 ieee80211_bss_info_change_notify(sdata
, bss_info_changed
);
1714 mutex_lock(&local
->iflist_mtx
);
1715 ieee80211_recalc_ps(local
, -1);
1716 mutex_unlock(&local
->iflist_mtx
);
1718 ieee80211_recalc_smps(sdata
);
1719 ieee80211_recalc_ps_vif(sdata
);
1721 netif_tx_start_all_queues(sdata
->dev
);
1722 netif_carrier_on(sdata
->dev
);
1725 static void ieee80211_set_disassoc(struct ieee80211_sub_if_data
*sdata
,
1726 u16 stype
, u16 reason
, bool tx
,
1729 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
1730 struct ieee80211_local
*local
= sdata
->local
;
1733 ASSERT_MGD_MTX(ifmgd
);
1735 if (WARN_ON_ONCE(tx
&& !frame_buf
))
1738 if (WARN_ON(!ifmgd
->associated
))
1741 ieee80211_stop_poll(sdata
);
1743 ifmgd
->associated
= NULL
;
1746 * we need to commit the associated = NULL change because the
1747 * scan code uses that to determine whether this iface should
1748 * go to/wake up from powersave or not -- and could otherwise
1749 * wake the queues erroneously.
1754 * Thus, we can only afterwards stop the queues -- to account
1755 * for the case where another CPU is finishing a scan at this
1756 * time -- we don't want the scan code to enable queues.
1759 netif_tx_stop_all_queues(sdata
->dev
);
1760 netif_carrier_off(sdata
->dev
);
1763 * if we want to get out of ps before disassoc (why?) we have
1764 * to do it before sending disassoc, as otherwise the null-packet
1767 if (local
->hw
.conf
.flags
& IEEE80211_CONF_PS
) {
1768 local
->hw
.conf
.flags
&= ~IEEE80211_CONF_PS
;
1769 ieee80211_hw_config(local
, IEEE80211_CONF_CHANGE_PS
);
1771 local
->ps_sdata
= NULL
;
1773 /* disable per-vif ps */
1774 ieee80211_recalc_ps_vif(sdata
);
1776 /* flush out any pending frame (e.g. DELBA) before deauth/disassoc */
1778 drv_flush(local
, false);
1780 /* deauthenticate/disassociate now */
1781 if (tx
|| frame_buf
)
1782 ieee80211_send_deauth_disassoc(sdata
, ifmgd
->bssid
, stype
,
1783 reason
, tx
, frame_buf
);
1785 /* flush out frame */
1787 drv_flush(local
, false);
1789 /* clear bssid only after building the needed mgmt frames */
1790 memset(ifmgd
->bssid
, 0, ETH_ALEN
);
1792 /* remove AP and TDLS peers */
1793 sta_info_flush_defer(sdata
);
1795 /* finally reset all BSS / config parameters */
1796 changed
|= ieee80211_reset_erp_info(sdata
);
1798 ieee80211_led_assoc(local
, 0);
1799 changed
|= BSS_CHANGED_ASSOC
;
1800 sdata
->vif
.bss_conf
.assoc
= false;
1802 sdata
->vif
.bss_conf
.p2p_ctwindow
= 0;
1803 sdata
->vif
.bss_conf
.p2p_oppps
= false;
1805 /* on the next assoc, re-program HT parameters */
1806 memset(&ifmgd
->ht_capa
, 0, sizeof(ifmgd
->ht_capa
));
1807 memset(&ifmgd
->ht_capa_mask
, 0, sizeof(ifmgd
->ht_capa_mask
));
1809 sdata
->ap_power_level
= IEEE80211_UNSET_POWER_LEVEL
;
1811 del_timer_sync(&local
->dynamic_ps_timer
);
1812 cancel_work_sync(&local
->dynamic_ps_enable_work
);
1814 /* Disable ARP filtering */
1815 if (sdata
->vif
.bss_conf
.arp_addr_cnt
)
1816 changed
|= BSS_CHANGED_ARP_FILTER
;
1818 sdata
->vif
.bss_conf
.qos
= false;
1819 changed
|= BSS_CHANGED_QOS
;
1821 /* The BSSID (not really interesting) and HT changed */
1822 changed
|= BSS_CHANGED_BSSID
| BSS_CHANGED_HT
;
1823 ieee80211_bss_info_change_notify(sdata
, changed
);
1825 /* disassociated - set to defaults now */
1826 ieee80211_set_wmm_default(sdata
, false);
1828 del_timer_sync(&sdata
->u
.mgd
.conn_mon_timer
);
1829 del_timer_sync(&sdata
->u
.mgd
.bcn_mon_timer
);
1830 del_timer_sync(&sdata
->u
.mgd
.timer
);
1831 del_timer_sync(&sdata
->u
.mgd
.chswitch_timer
);
1833 sdata
->u
.mgd
.timers_running
= 0;
1835 sdata
->vif
.bss_conf
.dtim_period
= 0;
1838 ieee80211_vif_release_channel(sdata
);
1841 void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data
*sdata
,
1842 struct ieee80211_hdr
*hdr
)
1845 * We can postpone the mgd.timer whenever receiving unicast frames
1846 * from AP because we know that the connection is working both ways
1847 * at that time. But multicast frames (and hence also beacons) must
1848 * be ignored here, because we need to trigger the timer during
1849 * data idle periods for sending the periodic probe request to the
1850 * AP we're connected to.
1852 if (is_multicast_ether_addr(hdr
->addr1
))
1855 ieee80211_sta_reset_conn_monitor(sdata
);
1858 static void ieee80211_reset_ap_probe(struct ieee80211_sub_if_data
*sdata
)
1860 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
1861 struct ieee80211_local
*local
= sdata
->local
;
1863 mutex_lock(&local
->mtx
);
1864 if (!(ifmgd
->flags
& (IEEE80211_STA_BEACON_POLL
|
1865 IEEE80211_STA_CONNECTION_POLL
))) {
1866 mutex_unlock(&local
->mtx
);
1870 __ieee80211_stop_poll(sdata
);
1872 mutex_lock(&local
->iflist_mtx
);
1873 ieee80211_recalc_ps(local
, -1);
1874 mutex_unlock(&local
->iflist_mtx
);
1876 if (sdata
->local
->hw
.flags
& IEEE80211_HW_CONNECTION_MONITOR
)
1880 * We've received a probe response, but are not sure whether
1881 * we have or will be receiving any beacons or data, so let's
1882 * schedule the timers again, just in case.
1884 ieee80211_sta_reset_beacon_monitor(sdata
);
1886 mod_timer(&ifmgd
->conn_mon_timer
,
1887 round_jiffies_up(jiffies
+
1888 IEEE80211_CONNECTION_IDLE_TIME
));
1890 mutex_unlock(&local
->mtx
);
1893 void ieee80211_sta_tx_notify(struct ieee80211_sub_if_data
*sdata
,
1894 struct ieee80211_hdr
*hdr
, bool ack
)
1896 if (!ieee80211_is_data(hdr
->frame_control
))
1899 if (ieee80211_is_nullfunc(hdr
->frame_control
) &&
1900 sdata
->u
.mgd
.probe_send_count
> 0) {
1902 ieee80211_sta_reset_conn_monitor(sdata
);
1904 sdata
->u
.mgd
.nullfunc_failed
= true;
1905 ieee80211_queue_work(&sdata
->local
->hw
, &sdata
->work
);
1910 ieee80211_sta_reset_conn_monitor(sdata
);
1913 static void ieee80211_mgd_probe_ap_send(struct ieee80211_sub_if_data
*sdata
)
1915 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
1917 u8
*dst
= ifmgd
->associated
->bssid
;
1918 u8 unicast_limit
= max(1, max_probe_tries
- 3);
1921 * Try sending broadcast probe requests for the last three
1922 * probe requests after the first ones failed since some
1923 * buggy APs only support broadcast probe requests.
1925 if (ifmgd
->probe_send_count
>= unicast_limit
)
1929 * When the hardware reports an accurate Tx ACK status, it's
1930 * better to send a nullfunc frame instead of a probe request,
1931 * as it will kick us off the AP quickly if we aren't associated
1932 * anymore. The timeout will be reset if the frame is ACKed by
1935 ifmgd
->probe_send_count
++;
1937 if (sdata
->local
->hw
.flags
& IEEE80211_HW_REPORTS_TX_ACK_STATUS
) {
1938 ifmgd
->nullfunc_failed
= false;
1939 ieee80211_send_nullfunc(sdata
->local
, sdata
, 0);
1944 ssid
= ieee80211_bss_get_ie(ifmgd
->associated
, WLAN_EID_SSID
);
1945 if (WARN_ON_ONCE(ssid
== NULL
))
1950 ieee80211_send_probe_req(sdata
, dst
, ssid
+ 2, ssid_len
, NULL
,
1951 0, (u32
) -1, true, 0,
1952 ifmgd
->associated
->channel
, false);
1956 ifmgd
->probe_timeout
= jiffies
+ msecs_to_jiffies(probe_wait_ms
);
1957 run_again(ifmgd
, ifmgd
->probe_timeout
);
1958 if (sdata
->local
->hw
.flags
& IEEE80211_HW_REPORTS_TX_ACK_STATUS
)
1959 drv_flush(sdata
->local
, false);
1962 static void ieee80211_mgd_probe_ap(struct ieee80211_sub_if_data
*sdata
,
1965 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
1966 bool already
= false;
1968 if (!ieee80211_sdata_running(sdata
))
1971 mutex_lock(&ifmgd
->mtx
);
1973 if (!ifmgd
->associated
)
1976 mutex_lock(&sdata
->local
->mtx
);
1978 if (sdata
->local
->tmp_channel
|| sdata
->local
->scanning
) {
1979 mutex_unlock(&sdata
->local
->mtx
);
1984 mlme_dbg_ratelimited(sdata
,
1985 "detected beacon loss from AP - probing\n");
1987 ieee80211_cqm_rssi_notify(&sdata
->vif
,
1988 NL80211_CQM_RSSI_BEACON_LOSS_EVENT
, GFP_KERNEL
);
1991 * The driver/our work has already reported this event or the
1992 * connection monitoring has kicked in and we have already sent
1993 * a probe request. Or maybe the AP died and the driver keeps
1994 * reporting until we disassociate...
1996 * In either case we have to ignore the current call to this
1997 * function (except for setting the correct probe reason bit)
1998 * because otherwise we would reset the timer every time and
1999 * never check whether we received a probe response!
2001 if (ifmgd
->flags
& (IEEE80211_STA_BEACON_POLL
|
2002 IEEE80211_STA_CONNECTION_POLL
))
2006 ifmgd
->flags
|= IEEE80211_STA_BEACON_POLL
;
2008 ifmgd
->flags
|= IEEE80211_STA_CONNECTION_POLL
;
2010 mutex_unlock(&sdata
->local
->mtx
);
2015 mutex_lock(&sdata
->local
->iflist_mtx
);
2016 ieee80211_recalc_ps(sdata
->local
, -1);
2017 mutex_unlock(&sdata
->local
->iflist_mtx
);
2019 ifmgd
->probe_send_count
= 0;
2020 ieee80211_mgd_probe_ap_send(sdata
);
2022 mutex_unlock(&ifmgd
->mtx
);
2025 struct sk_buff
*ieee80211_ap_probereq_get(struct ieee80211_hw
*hw
,
2026 struct ieee80211_vif
*vif
)
2028 struct ieee80211_sub_if_data
*sdata
= vif_to_sdata(vif
);
2029 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
2030 struct cfg80211_bss
*cbss
;
2031 struct sk_buff
*skb
;
2035 if (WARN_ON(sdata
->vif
.type
!= NL80211_IFTYPE_STATION
))
2038 ASSERT_MGD_MTX(ifmgd
);
2040 if (ifmgd
->associated
)
2041 cbss
= ifmgd
->associated
;
2042 else if (ifmgd
->auth_data
)
2043 cbss
= ifmgd
->auth_data
->bss
;
2044 else if (ifmgd
->assoc_data
)
2045 cbss
= ifmgd
->assoc_data
->bss
;
2050 ssid
= ieee80211_bss_get_ie(cbss
, WLAN_EID_SSID
);
2051 if (WARN_ON_ONCE(ssid
== NULL
))
2056 skb
= ieee80211_build_probe_req(sdata
, cbss
->bssid
,
2057 (u32
) -1, cbss
->channel
,
2064 EXPORT_SYMBOL(ieee80211_ap_probereq_get
);
2066 static void __ieee80211_disconnect(struct ieee80211_sub_if_data
*sdata
)
2068 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
2069 u8 frame_buf
[IEEE80211_DEAUTH_FRAME_LEN
];
2071 mutex_lock(&ifmgd
->mtx
);
2072 if (!ifmgd
->associated
) {
2073 mutex_unlock(&ifmgd
->mtx
);
2077 ieee80211_set_disassoc(sdata
, IEEE80211_STYPE_DEAUTH
,
2078 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY
,
2080 ifmgd
->flags
&= ~IEEE80211_STA_CSA_RECEIVED
;
2081 ieee80211_wake_queues_by_reason(&sdata
->local
->hw
,
2082 IEEE80211_QUEUE_STOP_REASON_CSA
);
2083 mutex_unlock(&ifmgd
->mtx
);
2086 * must be outside lock due to cfg80211,
2087 * but that's not a problem.
2089 cfg80211_send_deauth(sdata
->dev
, frame_buf
, IEEE80211_DEAUTH_FRAME_LEN
);
2092 static void ieee80211_beacon_connection_loss_work(struct work_struct
*work
)
2094 struct ieee80211_sub_if_data
*sdata
=
2095 container_of(work
, struct ieee80211_sub_if_data
,
2096 u
.mgd
.beacon_connection_loss_work
);
2097 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
2098 struct sta_info
*sta
;
2100 if (ifmgd
->associated
) {
2102 sta
= sta_info_get(sdata
, ifmgd
->bssid
);
2104 sta
->beacon_loss_count
++;
2108 if (ifmgd
->connection_loss
) {
2109 sdata_info(sdata
, "Connection to AP %pM lost\n",
2111 __ieee80211_disconnect(sdata
);
2113 ieee80211_mgd_probe_ap(sdata
, true);
2117 static void ieee80211_csa_connection_drop_work(struct work_struct
*work
)
2119 struct ieee80211_sub_if_data
*sdata
=
2120 container_of(work
, struct ieee80211_sub_if_data
,
2121 u
.mgd
.csa_connection_drop_work
);
2123 __ieee80211_disconnect(sdata
);
2126 void ieee80211_beacon_loss(struct ieee80211_vif
*vif
)
2128 struct ieee80211_sub_if_data
*sdata
= vif_to_sdata(vif
);
2129 struct ieee80211_hw
*hw
= &sdata
->local
->hw
;
2131 trace_api_beacon_loss(sdata
);
2133 WARN_ON(hw
->flags
& IEEE80211_HW_CONNECTION_MONITOR
);
2134 sdata
->u
.mgd
.connection_loss
= false;
2135 ieee80211_queue_work(hw
, &sdata
->u
.mgd
.beacon_connection_loss_work
);
2137 EXPORT_SYMBOL(ieee80211_beacon_loss
);
2139 void ieee80211_connection_loss(struct ieee80211_vif
*vif
)
2141 struct ieee80211_sub_if_data
*sdata
= vif_to_sdata(vif
);
2142 struct ieee80211_hw
*hw
= &sdata
->local
->hw
;
2144 trace_api_connection_loss(sdata
);
2146 sdata
->u
.mgd
.connection_loss
= true;
2147 ieee80211_queue_work(hw
, &sdata
->u
.mgd
.beacon_connection_loss_work
);
2149 EXPORT_SYMBOL(ieee80211_connection_loss
);
2152 static void ieee80211_destroy_auth_data(struct ieee80211_sub_if_data
*sdata
,
2155 struct ieee80211_mgd_auth_data
*auth_data
= sdata
->u
.mgd
.auth_data
;
2157 lockdep_assert_held(&sdata
->u
.mgd
.mtx
);
2160 sta_info_destroy_addr(sdata
, auth_data
->bss
->bssid
);
2162 memset(sdata
->u
.mgd
.bssid
, 0, ETH_ALEN
);
2163 ieee80211_bss_info_change_notify(sdata
, BSS_CHANGED_BSSID
);
2164 sdata
->u
.mgd
.flags
= 0;
2165 ieee80211_vif_release_channel(sdata
);
2168 cfg80211_put_bss(sdata
->local
->hw
.wiphy
, auth_data
->bss
);
2170 sdata
->u
.mgd
.auth_data
= NULL
;
2173 static void ieee80211_auth_challenge(struct ieee80211_sub_if_data
*sdata
,
2174 struct ieee80211_mgmt
*mgmt
, size_t len
)
2176 struct ieee80211_local
*local
= sdata
->local
;
2177 struct ieee80211_mgd_auth_data
*auth_data
= sdata
->u
.mgd
.auth_data
;
2179 struct ieee802_11_elems elems
;
2182 pos
= mgmt
->u
.auth
.variable
;
2183 ieee802_11_parse_elems(pos
, len
- (pos
- (u8
*) mgmt
), &elems
);
2184 if (!elems
.challenge
)
2186 auth_data
->expected_transaction
= 4;
2187 drv_mgd_prepare_tx(sdata
->local
, sdata
);
2188 if (local
->hw
.flags
& IEEE80211_HW_REPORTS_TX_ACK_STATUS
)
2189 tx_flags
= IEEE80211_TX_CTL_REQ_TX_STATUS
|
2190 IEEE80211_TX_INTFL_MLME_CONN_TX
;
2191 ieee80211_send_auth(sdata
, 3, auth_data
->algorithm
, 0,
2192 elems
.challenge
- 2, elems
.challenge_len
+ 2,
2193 auth_data
->bss
->bssid
, auth_data
->bss
->bssid
,
2194 auth_data
->key
, auth_data
->key_len
,
2195 auth_data
->key_idx
, tx_flags
);
2198 static enum rx_mgmt_action __must_check
2199 ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data
*sdata
,
2200 struct ieee80211_mgmt
*mgmt
, size_t len
)
2202 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
2204 u16 auth_alg
, auth_transaction
, status_code
;
2205 struct sta_info
*sta
;
2207 lockdep_assert_held(&ifmgd
->mtx
);
2210 return RX_MGMT_NONE
;
2212 if (!ifmgd
->auth_data
|| ifmgd
->auth_data
->done
)
2213 return RX_MGMT_NONE
;
2215 memcpy(bssid
, ifmgd
->auth_data
->bss
->bssid
, ETH_ALEN
);
2217 if (!ether_addr_equal(bssid
, mgmt
->bssid
))
2218 return RX_MGMT_NONE
;
2220 auth_alg
= le16_to_cpu(mgmt
->u
.auth
.auth_alg
);
2221 auth_transaction
= le16_to_cpu(mgmt
->u
.auth
.auth_transaction
);
2222 status_code
= le16_to_cpu(mgmt
->u
.auth
.status_code
);
2224 if (auth_alg
!= ifmgd
->auth_data
->algorithm
||
2225 auth_transaction
!= ifmgd
->auth_data
->expected_transaction
) {
2226 sdata_info(sdata
, "%pM unexpected authentication state: alg %d (expected %d) transact %d (expected %d)\n",
2227 mgmt
->sa
, auth_alg
, ifmgd
->auth_data
->algorithm
,
2229 ifmgd
->auth_data
->expected_transaction
);
2230 return RX_MGMT_NONE
;
2233 if (status_code
!= WLAN_STATUS_SUCCESS
) {
2234 sdata_info(sdata
, "%pM denied authentication (status %d)\n",
2235 mgmt
->sa
, status_code
);
2236 ieee80211_destroy_auth_data(sdata
, false);
2237 return RX_MGMT_CFG80211_RX_AUTH
;
2240 switch (ifmgd
->auth_data
->algorithm
) {
2241 case WLAN_AUTH_OPEN
:
2242 case WLAN_AUTH_LEAP
:
2246 case WLAN_AUTH_SHARED_KEY
:
2247 if (ifmgd
->auth_data
->expected_transaction
!= 4) {
2248 ieee80211_auth_challenge(sdata
, mgmt
, len
);
2249 /* need another frame */
2250 return RX_MGMT_NONE
;
2254 WARN_ONCE(1, "invalid auth alg %d",
2255 ifmgd
->auth_data
->algorithm
);
2256 return RX_MGMT_NONE
;
2259 sdata_info(sdata
, "authenticated\n");
2260 ifmgd
->auth_data
->done
= true;
2261 ifmgd
->auth_data
->timeout
= jiffies
+ IEEE80211_AUTH_WAIT_ASSOC
;
2262 ifmgd
->auth_data
->timeout_started
= true;
2263 run_again(ifmgd
, ifmgd
->auth_data
->timeout
);
2265 if (ifmgd
->auth_data
->algorithm
== WLAN_AUTH_SAE
&&
2266 ifmgd
->auth_data
->expected_transaction
!= 2) {
2268 * Report auth frame to user space for processing since another
2269 * round of Authentication frames is still needed.
2271 return RX_MGMT_CFG80211_RX_AUTH
;
2274 /* move station state to auth */
2275 mutex_lock(&sdata
->local
->sta_mtx
);
2276 sta
= sta_info_get(sdata
, bssid
);
2278 WARN_ONCE(1, "%s: STA %pM not found", sdata
->name
, bssid
);
2281 if (sta_info_move_state(sta
, IEEE80211_STA_AUTH
)) {
2282 sdata_info(sdata
, "failed moving %pM to auth\n", bssid
);
2285 mutex_unlock(&sdata
->local
->sta_mtx
);
2287 return RX_MGMT_CFG80211_RX_AUTH
;
2289 mutex_unlock(&sdata
->local
->sta_mtx
);
2290 /* ignore frame -- wait for timeout */
2291 return RX_MGMT_NONE
;
2295 static enum rx_mgmt_action __must_check
2296 ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data
*sdata
,
2297 struct ieee80211_mgmt
*mgmt
, size_t len
)
2299 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
2300 const u8
*bssid
= NULL
;
2303 lockdep_assert_held(&ifmgd
->mtx
);
2306 return RX_MGMT_NONE
;
2308 if (!ifmgd
->associated
||
2309 !ether_addr_equal(mgmt
->bssid
, ifmgd
->associated
->bssid
))
2310 return RX_MGMT_NONE
;
2312 bssid
= ifmgd
->associated
->bssid
;
2314 reason_code
= le16_to_cpu(mgmt
->u
.deauth
.reason_code
);
2316 sdata_info(sdata
, "deauthenticated from %pM (Reason: %u)\n",
2317 bssid
, reason_code
);
2319 ieee80211_set_disassoc(sdata
, 0, 0, false, NULL
);
2321 return RX_MGMT_CFG80211_DEAUTH
;
2325 static enum rx_mgmt_action __must_check
2326 ieee80211_rx_mgmt_disassoc(struct ieee80211_sub_if_data
*sdata
,
2327 struct ieee80211_mgmt
*mgmt
, size_t len
)
2329 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
2332 lockdep_assert_held(&ifmgd
->mtx
);
2335 return RX_MGMT_NONE
;
2337 if (!ifmgd
->associated
||
2338 !ether_addr_equal(mgmt
->bssid
, ifmgd
->associated
->bssid
))
2339 return RX_MGMT_NONE
;
2341 reason_code
= le16_to_cpu(mgmt
->u
.disassoc
.reason_code
);
2343 sdata_info(sdata
, "disassociated from %pM (Reason: %u)\n",
2344 mgmt
->sa
, reason_code
);
2346 ieee80211_set_disassoc(sdata
, 0, 0, false, NULL
);
2348 return RX_MGMT_CFG80211_DISASSOC
;
2351 static void ieee80211_get_rates(struct ieee80211_supported_band
*sband
,
2352 u8
*supp_rates
, unsigned int supp_rates_len
,
2353 u32
*rates
, u32
*basic_rates
,
2354 bool *have_higher_than_11mbit
,
2355 int *min_rate
, int *min_rate_index
)
2359 for (i
= 0; i
< supp_rates_len
; i
++) {
2360 int rate
= (supp_rates
[i
] & 0x7f) * 5;
2361 bool is_basic
= !!(supp_rates
[i
] & 0x80);
2364 *have_higher_than_11mbit
= true;
2367 * BSS_MEMBERSHIP_SELECTOR_HT_PHY is defined in 802.11n-2009
2368 * 7.3.2.2 as a magic value instead of a rate. Hence, skip it.
2370 * Note: Even through the membership selector and the basic
2371 * rate flag share the same bit, they are not exactly
2374 if (!!(supp_rates
[i
] & 0x80) &&
2375 (supp_rates
[i
] & 0x7f) == BSS_MEMBERSHIP_SELECTOR_HT_PHY
)
2378 for (j
= 0; j
< sband
->n_bitrates
; j
++) {
2379 if (sband
->bitrates
[j
].bitrate
== rate
) {
2382 *basic_rates
|= BIT(j
);
2383 if (rate
< *min_rate
) {
2385 *min_rate_index
= j
;
2393 static void ieee80211_destroy_assoc_data(struct ieee80211_sub_if_data
*sdata
,
2396 struct ieee80211_mgd_assoc_data
*assoc_data
= sdata
->u
.mgd
.assoc_data
;
2398 lockdep_assert_held(&sdata
->u
.mgd
.mtx
);
2401 sta_info_destroy_addr(sdata
, assoc_data
->bss
->bssid
);
2403 memset(sdata
->u
.mgd
.bssid
, 0, ETH_ALEN
);
2404 ieee80211_bss_info_change_notify(sdata
, BSS_CHANGED_BSSID
);
2405 sdata
->u
.mgd
.flags
= 0;
2406 ieee80211_vif_release_channel(sdata
);
2410 sdata
->u
.mgd
.assoc_data
= NULL
;
2413 static bool ieee80211_assoc_success(struct ieee80211_sub_if_data
*sdata
,
2414 struct cfg80211_bss
*cbss
,
2415 struct ieee80211_mgmt
*mgmt
, size_t len
)
2417 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
2418 struct ieee80211_local
*local
= sdata
->local
;
2419 struct ieee80211_supported_band
*sband
;
2420 struct sta_info
*sta
;
2422 u16 capab_info
, aid
;
2423 struct ieee802_11_elems elems
;
2424 struct ieee80211_bss_conf
*bss_conf
= &sdata
->vif
.bss_conf
;
2428 /* AssocResp and ReassocResp have identical structure */
2430 aid
= le16_to_cpu(mgmt
->u
.assoc_resp
.aid
);
2431 capab_info
= le16_to_cpu(mgmt
->u
.assoc_resp
.capab_info
);
2433 if ((aid
& (BIT(15) | BIT(14))) != (BIT(15) | BIT(14)))
2434 sdata_info(sdata
, "invalid AID value 0x%x; bits 15:14 not set\n",
2436 aid
&= ~(BIT(15) | BIT(14));
2438 ifmgd
->broken_ap
= false;
2440 if (aid
== 0 || aid
> IEEE80211_MAX_AID
) {
2441 sdata_info(sdata
, "invalid AID value %d (out of range), turn off PS\n",
2444 ifmgd
->broken_ap
= true;
2447 pos
= mgmt
->u
.assoc_resp
.variable
;
2448 ieee802_11_parse_elems(pos
, len
- (pos
- (u8
*) mgmt
), &elems
);
2450 if (!elems
.supp_rates
) {
2451 sdata_info(sdata
, "no SuppRates element in AssocResp\n");
2458 * We previously checked these in the beacon/probe response, so
2459 * they should be present here. This is just a safety net.
2461 if (!(ifmgd
->flags
& IEEE80211_STA_DISABLE_HT
) &&
2462 (!elems
.wmm_param
|| !elems
.ht_cap_elem
|| !elems
.ht_operation
)) {
2464 "HT AP is missing WMM params or HT capability/operation in AssocResp\n");
2468 if (!(ifmgd
->flags
& IEEE80211_STA_DISABLE_VHT
) &&
2469 (!elems
.vht_cap_elem
|| !elems
.vht_operation
)) {
2471 "VHT AP is missing VHT capability/operation in AssocResp\n");
2475 mutex_lock(&sdata
->local
->sta_mtx
);
2477 * station info was already allocated and inserted before
2478 * the association and should be available to us
2480 sta
= sta_info_get(sdata
, cbss
->bssid
);
2481 if (WARN_ON(!sta
)) {
2482 mutex_unlock(&sdata
->local
->sta_mtx
);
2486 sband
= local
->hw
.wiphy
->bands
[ieee80211_get_sdata_band(sdata
)];
2488 /* Set up internal HT/VHT capabilities */
2489 if (elems
.ht_cap_elem
&& !(ifmgd
->flags
& IEEE80211_STA_DISABLE_HT
))
2490 ieee80211_ht_cap_ie_to_sta_ht_cap(sdata
, sband
,
2491 elems
.ht_cap_elem
, sta
);
2493 if (elems
.vht_cap_elem
&& !(ifmgd
->flags
& IEEE80211_STA_DISABLE_VHT
))
2494 ieee80211_vht_cap_ie_to_sta_vht_cap(sdata
, sband
,
2495 elems
.vht_cap_elem
, sta
);
2498 * Some APs, e.g. Netgear WNDR3700, report invalid HT operation data
2499 * in their association response, so ignore that data for our own
2500 * configuration. If it changed since the last beacon, we'll get the
2501 * next beacon and update then.
2505 * If an operating mode notification IE is present, override the
2506 * NSS calculation (that would be done in rate_control_rate_init())
2507 * and use the # of streams from that element.
2509 if (elems
.opmode_notif
&&
2510 !(*elems
.opmode_notif
& IEEE80211_OPMODE_NOTIF_RX_NSS_TYPE_BF
)) {
2513 nss
= *elems
.opmode_notif
& IEEE80211_OPMODE_NOTIF_RX_NSS_MASK
;
2514 nss
>>= IEEE80211_OPMODE_NOTIF_RX_NSS_SHIFT
;
2516 sta
->sta
.rx_nss
= nss
;
2519 rate_control_rate_init(sta
);
2521 if (ifmgd
->flags
& IEEE80211_STA_MFP_ENABLED
)
2522 set_sta_flag(sta
, WLAN_STA_MFP
);
2524 if (elems
.wmm_param
)
2525 set_sta_flag(sta
, WLAN_STA_WME
);
2527 err
= sta_info_move_state(sta
, IEEE80211_STA_ASSOC
);
2528 if (!err
&& !(ifmgd
->flags
& IEEE80211_STA_CONTROL_PORT
))
2529 err
= sta_info_move_state(sta
, IEEE80211_STA_AUTHORIZED
);
2532 "failed to move station %pM to desired state\n",
2534 WARN_ON(__sta_info_destroy(sta
));
2535 mutex_unlock(&sdata
->local
->sta_mtx
);
2539 mutex_unlock(&sdata
->local
->sta_mtx
);
2542 * Always handle WMM once after association regardless
2543 * of the first value the AP uses. Setting -1 here has
2544 * that effect because the AP values is an unsigned
2547 ifmgd
->wmm_last_param_set
= -1;
2549 if (elems
.wmm_param
)
2550 ieee80211_sta_wmm_params(local
, sdata
, elems
.wmm_param
,
2551 elems
.wmm_param_len
);
2553 ieee80211_set_wmm_default(sdata
, false);
2554 changed
|= BSS_CHANGED_QOS
;
2556 /* set AID and assoc capability,
2557 * ieee80211_set_associated() will tell the driver */
2558 bss_conf
->aid
= aid
;
2559 bss_conf
->assoc_capability
= capab_info
;
2560 ieee80211_set_associated(sdata
, cbss
, changed
);
2563 * If we're using 4-addr mode, let the AP know that we're
2564 * doing so, so that it can create the STA VLAN on its side
2566 if (ifmgd
->use_4addr
)
2567 ieee80211_send_4addr_nullfunc(local
, sdata
);
2570 * Start timer to probe the connection to the AP now.
2571 * Also start the timer that will detect beacon loss.
2573 ieee80211_sta_rx_notify(sdata
, (struct ieee80211_hdr
*)mgmt
);
2574 ieee80211_sta_reset_beacon_monitor(sdata
);
2579 static enum rx_mgmt_action __must_check
2580 ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data
*sdata
,
2581 struct ieee80211_mgmt
*mgmt
, size_t len
,
2582 struct cfg80211_bss
**bss
)
2584 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
2585 struct ieee80211_mgd_assoc_data
*assoc_data
= ifmgd
->assoc_data
;
2586 u16 capab_info
, status_code
, aid
;
2587 struct ieee802_11_elems elems
;
2591 lockdep_assert_held(&ifmgd
->mtx
);
2594 return RX_MGMT_NONE
;
2595 if (!ether_addr_equal(assoc_data
->bss
->bssid
, mgmt
->bssid
))
2596 return RX_MGMT_NONE
;
2599 * AssocResp and ReassocResp have identical structure, so process both
2600 * of them in this function.
2604 return RX_MGMT_NONE
;
2606 reassoc
= ieee80211_is_reassoc_req(mgmt
->frame_control
);
2607 capab_info
= le16_to_cpu(mgmt
->u
.assoc_resp
.capab_info
);
2608 status_code
= le16_to_cpu(mgmt
->u
.assoc_resp
.status_code
);
2609 aid
= le16_to_cpu(mgmt
->u
.assoc_resp
.aid
);
2612 "RX %sssocResp from %pM (capab=0x%x status=%d aid=%d)\n",
2613 reassoc
? "Rea" : "A", mgmt
->sa
,
2614 capab_info
, status_code
, (u16
)(aid
& ~(BIT(15) | BIT(14))));
2616 pos
= mgmt
->u
.assoc_resp
.variable
;
2617 ieee802_11_parse_elems(pos
, len
- (pos
- (u8
*) mgmt
), &elems
);
2619 if (status_code
== WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY
&&
2620 elems
.timeout_int
&& elems
.timeout_int_len
== 5 &&
2621 elems
.timeout_int
[0] == WLAN_TIMEOUT_ASSOC_COMEBACK
) {
2623 tu
= get_unaligned_le32(elems
.timeout_int
+ 1);
2624 ms
= tu
* 1024 / 1000;
2626 "%pM rejected association temporarily; comeback duration %u TU (%u ms)\n",
2628 assoc_data
->timeout
= jiffies
+ msecs_to_jiffies(ms
);
2629 assoc_data
->timeout_started
= true;
2630 if (ms
> IEEE80211_ASSOC_TIMEOUT
)
2631 run_again(ifmgd
, assoc_data
->timeout
);
2632 return RX_MGMT_NONE
;
2635 *bss
= assoc_data
->bss
;
2637 if (status_code
!= WLAN_STATUS_SUCCESS
) {
2638 sdata_info(sdata
, "%pM denied association (code=%d)\n",
2639 mgmt
->sa
, status_code
);
2640 ieee80211_destroy_assoc_data(sdata
, false);
2642 if (!ieee80211_assoc_success(sdata
, *bss
, mgmt
, len
)) {
2643 /* oops -- internal error -- send timeout for now */
2644 ieee80211_destroy_assoc_data(sdata
, false);
2645 cfg80211_put_bss(sdata
->local
->hw
.wiphy
, *bss
);
2646 return RX_MGMT_CFG80211_ASSOC_TIMEOUT
;
2648 sdata_info(sdata
, "associated\n");
2651 * destroy assoc_data afterwards, as otherwise an idle
2652 * recalc after assoc_data is NULL but before associated
2653 * is set can cause the interface to go idle
2655 ieee80211_destroy_assoc_data(sdata
, true);
2658 return RX_MGMT_CFG80211_RX_ASSOC
;
2661 static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data
*sdata
,
2662 struct ieee80211_mgmt
*mgmt
, size_t len
,
2663 struct ieee80211_rx_status
*rx_status
,
2664 struct ieee802_11_elems
*elems
)
2666 struct ieee80211_local
*local
= sdata
->local
;
2668 struct ieee80211_bss
*bss
;
2669 struct ieee80211_channel
*channel
;
2670 bool need_ps
= false;
2672 if ((sdata
->u
.mgd
.associated
&&
2673 ether_addr_equal(mgmt
->bssid
, sdata
->u
.mgd
.associated
->bssid
)) ||
2674 (sdata
->u
.mgd
.assoc_data
&&
2675 ether_addr_equal(mgmt
->bssid
,
2676 sdata
->u
.mgd
.assoc_data
->bss
->bssid
))) {
2677 /* not previously set so we may need to recalc */
2678 need_ps
= sdata
->u
.mgd
.associated
&& !sdata
->u
.mgd
.dtim_period
;
2680 if (elems
->tim
&& !elems
->parse_error
) {
2681 const struct ieee80211_tim_ie
*tim_ie
= elems
->tim
;
2682 sdata
->u
.mgd
.dtim_period
= tim_ie
->dtim_period
;
2686 if (elems
->ds_params
&& elems
->ds_params_len
== 1)
2687 freq
= ieee80211_channel_to_frequency(elems
->ds_params
[0],
2690 freq
= rx_status
->freq
;
2692 channel
= ieee80211_get_channel(local
->hw
.wiphy
, freq
);
2694 if (!channel
|| channel
->flags
& IEEE80211_CHAN_DISABLED
)
2697 bss
= ieee80211_bss_info_update(local
, rx_status
, mgmt
, len
, elems
,
2700 ieee80211_rx_bss_put(local
, bss
);
2702 if (!sdata
->u
.mgd
.associated
)
2706 mutex_lock(&local
->iflist_mtx
);
2707 ieee80211_recalc_ps(local
, -1);
2708 mutex_unlock(&local
->iflist_mtx
);
2711 if (elems
->ch_switch_ie
&&
2712 memcmp(mgmt
->bssid
, sdata
->u
.mgd
.associated
->bssid
, ETH_ALEN
) == 0)
2713 ieee80211_sta_process_chanswitch(sdata
, elems
->ch_switch_ie
,
2714 bss
, rx_status
->mactime
);
2718 static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data
*sdata
,
2719 struct sk_buff
*skb
)
2721 struct ieee80211_mgmt
*mgmt
= (void *)skb
->data
;
2722 struct ieee80211_if_managed
*ifmgd
;
2723 struct ieee80211_rx_status
*rx_status
= (void *) skb
->cb
;
2724 size_t baselen
, len
= skb
->len
;
2725 struct ieee802_11_elems elems
;
2727 ifmgd
= &sdata
->u
.mgd
;
2729 ASSERT_MGD_MTX(ifmgd
);
2731 if (!ether_addr_equal(mgmt
->da
, sdata
->vif
.addr
))
2732 return; /* ignore ProbeResp to foreign address */
2734 baselen
= (u8
*) mgmt
->u
.probe_resp
.variable
- (u8
*) mgmt
;
2738 ieee802_11_parse_elems(mgmt
->u
.probe_resp
.variable
, len
- baselen
,
2741 ieee80211_rx_bss_info(sdata
, mgmt
, len
, rx_status
, &elems
);
2743 if (ifmgd
->associated
&&
2744 ether_addr_equal(mgmt
->bssid
, ifmgd
->associated
->bssid
))
2745 ieee80211_reset_ap_probe(sdata
);
2747 if (ifmgd
->auth_data
&& !ifmgd
->auth_data
->bss
->proberesp_ies
&&
2748 ether_addr_equal(mgmt
->bssid
, ifmgd
->auth_data
->bss
->bssid
)) {
2749 /* got probe response, continue with auth */
2750 sdata_info(sdata
, "direct probe responded\n");
2751 ifmgd
->auth_data
->tries
= 0;
2752 ifmgd
->auth_data
->timeout
= jiffies
;
2753 ifmgd
->auth_data
->timeout_started
= true;
2754 run_again(ifmgd
, ifmgd
->auth_data
->timeout
);
2759 * This is the canonical list of information elements we care about,
2760 * the filter code also gives us all changes to the Microsoft OUI
2761 * (00:50:F2) vendor IE which is used for WMM which we need to track.
2763 * We implement beacon filtering in software since that means we can
2764 * avoid processing the frame here and in cfg80211, and userspace
2765 * will not be able to tell whether the hardware supports it or not.
2767 * XXX: This list needs to be dynamic -- userspace needs to be able to
2768 * add items it requires. It also needs to be able to tell us to
2769 * look out for other vendor IEs.
2771 static const u64 care_about_ies
=
2772 (1ULL << WLAN_EID_COUNTRY
) |
2773 (1ULL << WLAN_EID_ERP_INFO
) |
2774 (1ULL << WLAN_EID_CHANNEL_SWITCH
) |
2775 (1ULL << WLAN_EID_PWR_CONSTRAINT
) |
2776 (1ULL << WLAN_EID_HT_CAPABILITY
) |
2777 (1ULL << WLAN_EID_HT_OPERATION
);
2779 static enum rx_mgmt_action
2780 ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data
*sdata
,
2781 struct ieee80211_mgmt
*mgmt
, size_t len
,
2782 u8
*deauth_buf
, struct ieee80211_rx_status
*rx_status
)
2784 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
2785 struct ieee80211_bss_conf
*bss_conf
= &sdata
->vif
.bss_conf
;
2787 struct ieee802_11_elems elems
;
2788 struct ieee80211_local
*local
= sdata
->local
;
2789 struct ieee80211_chanctx_conf
*chanctx_conf
;
2790 struct ieee80211_channel
*chan
;
2791 struct sta_info
*sta
;
2798 lockdep_assert_held(&ifmgd
->mtx
);
2800 /* Process beacon from the current BSS */
2801 baselen
= (u8
*) mgmt
->u
.beacon
.variable
- (u8
*) mgmt
;
2803 return RX_MGMT_NONE
;
2806 chanctx_conf
= rcu_dereference(sdata
->vif
.chanctx_conf
);
2807 if (!chanctx_conf
) {
2809 return RX_MGMT_NONE
;
2812 if (rx_status
->freq
!= chanctx_conf
->def
.chan
->center_freq
) {
2814 return RX_MGMT_NONE
;
2816 chan
= chanctx_conf
->def
.chan
;
2819 if (ifmgd
->assoc_data
&& ifmgd
->assoc_data
->need_beacon
&&
2820 ether_addr_equal(mgmt
->bssid
, ifmgd
->assoc_data
->bss
->bssid
)) {
2821 ieee802_11_parse_elems(mgmt
->u
.beacon
.variable
,
2822 len
- baselen
, &elems
);
2824 ieee80211_rx_bss_info(sdata
, mgmt
, len
, rx_status
, &elems
);
2825 ifmgd
->assoc_data
->have_beacon
= true;
2826 ifmgd
->assoc_data
->need_beacon
= false;
2827 if (local
->hw
.flags
& IEEE80211_HW_TIMING_BEACON_ONLY
) {
2828 sdata
->vif
.bss_conf
.sync_tsf
=
2829 le64_to_cpu(mgmt
->u
.beacon
.timestamp
);
2830 sdata
->vif
.bss_conf
.sync_device_ts
=
2831 rx_status
->device_timestamp
;
2833 sdata
->vif
.bss_conf
.sync_dtim_count
=
2834 elems
.tim
->dtim_count
;
2836 sdata
->vif
.bss_conf
.sync_dtim_count
= 0;
2838 /* continue assoc process */
2839 ifmgd
->assoc_data
->timeout
= jiffies
;
2840 ifmgd
->assoc_data
->timeout_started
= true;
2841 run_again(ifmgd
, ifmgd
->assoc_data
->timeout
);
2842 return RX_MGMT_NONE
;
2845 if (!ifmgd
->associated
||
2846 !ether_addr_equal(mgmt
->bssid
, ifmgd
->associated
->bssid
))
2847 return RX_MGMT_NONE
;
2848 bssid
= ifmgd
->associated
->bssid
;
2850 /* Track average RSSI from the Beacon frames of the current AP */
2851 ifmgd
->last_beacon_signal
= rx_status
->signal
;
2852 if (ifmgd
->flags
& IEEE80211_STA_RESET_SIGNAL_AVE
) {
2853 ifmgd
->flags
&= ~IEEE80211_STA_RESET_SIGNAL_AVE
;
2854 ifmgd
->ave_beacon_signal
= rx_status
->signal
* 16;
2855 ifmgd
->last_cqm_event_signal
= 0;
2856 ifmgd
->count_beacon_signal
= 1;
2857 ifmgd
->last_ave_beacon_signal
= 0;
2859 ifmgd
->ave_beacon_signal
=
2860 (IEEE80211_SIGNAL_AVE_WEIGHT
* rx_status
->signal
* 16 +
2861 (16 - IEEE80211_SIGNAL_AVE_WEIGHT
) *
2862 ifmgd
->ave_beacon_signal
) / 16;
2863 ifmgd
->count_beacon_signal
++;
2866 if (ifmgd
->rssi_min_thold
!= ifmgd
->rssi_max_thold
&&
2867 ifmgd
->count_beacon_signal
>= IEEE80211_SIGNAL_AVE_MIN_COUNT
) {
2868 int sig
= ifmgd
->ave_beacon_signal
;
2869 int last_sig
= ifmgd
->last_ave_beacon_signal
;
2872 * if signal crosses either of the boundaries, invoke callback
2873 * with appropriate parameters
2875 if (sig
> ifmgd
->rssi_max_thold
&&
2876 (last_sig
<= ifmgd
->rssi_min_thold
|| last_sig
== 0)) {
2877 ifmgd
->last_ave_beacon_signal
= sig
;
2878 drv_rssi_callback(local
, sdata
, RSSI_EVENT_HIGH
);
2879 } else if (sig
< ifmgd
->rssi_min_thold
&&
2880 (last_sig
>= ifmgd
->rssi_max_thold
||
2882 ifmgd
->last_ave_beacon_signal
= sig
;
2883 drv_rssi_callback(local
, sdata
, RSSI_EVENT_LOW
);
2887 if (bss_conf
->cqm_rssi_thold
&&
2888 ifmgd
->count_beacon_signal
>= IEEE80211_SIGNAL_AVE_MIN_COUNT
&&
2889 !(sdata
->vif
.driver_flags
& IEEE80211_VIF_SUPPORTS_CQM_RSSI
)) {
2890 int sig
= ifmgd
->ave_beacon_signal
/ 16;
2891 int last_event
= ifmgd
->last_cqm_event_signal
;
2892 int thold
= bss_conf
->cqm_rssi_thold
;
2893 int hyst
= bss_conf
->cqm_rssi_hyst
;
2895 (last_event
== 0 || sig
< last_event
- hyst
)) {
2896 ifmgd
->last_cqm_event_signal
= sig
;
2897 ieee80211_cqm_rssi_notify(
2899 NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW
,
2901 } else if (sig
> thold
&&
2902 (last_event
== 0 || sig
> last_event
+ hyst
)) {
2903 ifmgd
->last_cqm_event_signal
= sig
;
2904 ieee80211_cqm_rssi_notify(
2906 NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH
,
2911 if (ifmgd
->flags
& IEEE80211_STA_BEACON_POLL
) {
2912 mlme_dbg_ratelimited(sdata
,
2913 "cancelling AP probe due to a received beacon\n");
2914 mutex_lock(&local
->mtx
);
2915 ifmgd
->flags
&= ~IEEE80211_STA_BEACON_POLL
;
2916 ieee80211_run_deferred_scan(local
);
2917 mutex_unlock(&local
->mtx
);
2919 mutex_lock(&local
->iflist_mtx
);
2920 ieee80211_recalc_ps(local
, -1);
2921 mutex_unlock(&local
->iflist_mtx
);
2925 * Push the beacon loss detection into the future since
2926 * we are processing a beacon from the AP just now.
2928 ieee80211_sta_reset_beacon_monitor(sdata
);
2930 ncrc
= crc32_be(0, (void *)&mgmt
->u
.beacon
.beacon_int
, 4);
2931 ncrc
= ieee802_11_parse_elems_crc(mgmt
->u
.beacon
.variable
,
2932 len
- baselen
, &elems
,
2933 care_about_ies
, ncrc
);
2935 if (local
->hw
.flags
& IEEE80211_HW_PS_NULLFUNC_STACK
) {
2936 bool directed_tim
= ieee80211_check_tim(elems
.tim
,
2940 if (local
->hw
.conf
.dynamic_ps_timeout
> 0) {
2941 if (local
->hw
.conf
.flags
& IEEE80211_CONF_PS
) {
2942 local
->hw
.conf
.flags
&= ~IEEE80211_CONF_PS
;
2943 ieee80211_hw_config(local
,
2944 IEEE80211_CONF_CHANGE_PS
);
2946 ieee80211_send_nullfunc(local
, sdata
, 0);
2947 } else if (!local
->pspolling
&& sdata
->u
.mgd
.powersave
) {
2948 local
->pspolling
= true;
2951 * Here is assumed that the driver will be
2952 * able to send ps-poll frame and receive a
2953 * response even though power save mode is
2954 * enabled, but some drivers might require
2955 * to disable power save here. This needs
2956 * to be investigated.
2958 ieee80211_send_pspoll(local
, sdata
);
2963 if (sdata
->vif
.p2p
) {
2967 ret
= cfg80211_get_p2p_attr(mgmt
->u
.beacon
.variable
,
2969 IEEE80211_P2P_ATTR_ABSENCE_NOTICE
,
2971 if (ret
>= 2 && sdata
->u
.mgd
.p2p_noa_index
!= noa
[0]) {
2972 bss_conf
->p2p_oppps
= noa
[1] & 0x80;
2973 bss_conf
->p2p_ctwindow
= noa
[1] & 0x7f;
2974 changed
|= BSS_CHANGED_P2P_PS
;
2975 sdata
->u
.mgd
.p2p_noa_index
= noa
[0];
2977 * make sure we update all information, the CRC
2978 * mechanism doesn't look at P2P attributes.
2980 ifmgd
->beacon_crc_valid
= false;
2984 if (ncrc
== ifmgd
->beacon_crc
&& ifmgd
->beacon_crc_valid
)
2985 return RX_MGMT_NONE
;
2986 ifmgd
->beacon_crc
= ncrc
;
2987 ifmgd
->beacon_crc_valid
= true;
2989 ieee80211_rx_bss_info(sdata
, mgmt
, len
, rx_status
, &elems
);
2991 if (ieee80211_sta_wmm_params(local
, sdata
, elems
.wmm_param
,
2992 elems
.wmm_param_len
))
2993 changed
|= BSS_CHANGED_QOS
;
2996 * If we haven't had a beacon before, tell the driver about the
2997 * DTIM period (and beacon timing if desired) now.
2999 if (!bss_conf
->dtim_period
) {
3000 /* a few bogus AP send dtim_period = 0 or no TIM IE */
3002 bss_conf
->dtim_period
= elems
.tim
->dtim_period
?: 1;
3004 bss_conf
->dtim_period
= 1;
3006 if (local
->hw
.flags
& IEEE80211_HW_TIMING_BEACON_ONLY
) {
3007 sdata
->vif
.bss_conf
.sync_tsf
=
3008 le64_to_cpu(mgmt
->u
.beacon
.timestamp
);
3009 sdata
->vif
.bss_conf
.sync_device_ts
=
3010 rx_status
->device_timestamp
;
3012 sdata
->vif
.bss_conf
.sync_dtim_count
=
3013 elems
.tim
->dtim_count
;
3015 sdata
->vif
.bss_conf
.sync_dtim_count
= 0;
3018 changed
|= BSS_CHANGED_DTIM_PERIOD
;
3021 if (elems
.erp_info
&& elems
.erp_info_len
>= 1) {
3023 erp_value
= elems
.erp_info
[0];
3027 changed
|= ieee80211_handle_bss_capability(sdata
,
3028 le16_to_cpu(mgmt
->u
.beacon
.capab_info
),
3029 erp_valid
, erp_value
);
3031 mutex_lock(&local
->sta_mtx
);
3032 sta
= sta_info_get(sdata
, bssid
);
3034 if (ieee80211_config_bw(sdata
, sta
, elems
.ht_operation
,
3035 elems
.vht_operation
, bssid
, &changed
)) {
3036 mutex_unlock(&local
->sta_mtx
);
3037 ieee80211_set_disassoc(sdata
, IEEE80211_STYPE_DEAUTH
,
3038 WLAN_REASON_DEAUTH_LEAVING
,
3040 return RX_MGMT_CFG80211_TX_DEAUTH
;
3043 if (sta
&& elems
.opmode_notif
)
3044 ieee80211_vht_handle_opmode(sdata
, sta
, *elems
.opmode_notif
,
3045 rx_status
->band
, true);
3046 mutex_unlock(&local
->sta_mtx
);
3048 if (elems
.country_elem
&& elems
.pwr_constr_elem
&&
3049 mgmt
->u
.probe_resp
.capab_info
&
3050 cpu_to_le16(WLAN_CAPABILITY_SPECTRUM_MGMT
))
3051 changed
|= ieee80211_handle_pwr_constr(sdata
, chan
,
3053 elems
.country_elem_len
,
3054 elems
.pwr_constr_elem
);
3056 ieee80211_bss_info_change_notify(sdata
, changed
);
3058 return RX_MGMT_NONE
;
3061 void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data
*sdata
,
3062 struct sk_buff
*skb
)
3064 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
3065 struct ieee80211_rx_status
*rx_status
;
3066 struct ieee80211_mgmt
*mgmt
;
3067 struct cfg80211_bss
*bss
= NULL
;
3068 enum rx_mgmt_action rma
= RX_MGMT_NONE
;
3069 u8 deauth_buf
[IEEE80211_DEAUTH_FRAME_LEN
];
3072 rx_status
= (struct ieee80211_rx_status
*) skb
->cb
;
3073 mgmt
= (struct ieee80211_mgmt
*) skb
->data
;
3074 fc
= le16_to_cpu(mgmt
->frame_control
);
3076 mutex_lock(&ifmgd
->mtx
);
3078 switch (fc
& IEEE80211_FCTL_STYPE
) {
3079 case IEEE80211_STYPE_BEACON
:
3080 rma
= ieee80211_rx_mgmt_beacon(sdata
, mgmt
, skb
->len
,
3081 deauth_buf
, rx_status
);
3083 case IEEE80211_STYPE_PROBE_RESP
:
3084 ieee80211_rx_mgmt_probe_resp(sdata
, skb
);
3086 case IEEE80211_STYPE_AUTH
:
3087 rma
= ieee80211_rx_mgmt_auth(sdata
, mgmt
, skb
->len
);
3089 case IEEE80211_STYPE_DEAUTH
:
3090 rma
= ieee80211_rx_mgmt_deauth(sdata
, mgmt
, skb
->len
);
3092 case IEEE80211_STYPE_DISASSOC
:
3093 rma
= ieee80211_rx_mgmt_disassoc(sdata
, mgmt
, skb
->len
);
3095 case IEEE80211_STYPE_ASSOC_RESP
:
3096 case IEEE80211_STYPE_REASSOC_RESP
:
3097 rma
= ieee80211_rx_mgmt_assoc_resp(sdata
, mgmt
, skb
->len
, &bss
);
3099 case IEEE80211_STYPE_ACTION
:
3100 switch (mgmt
->u
.action
.category
) {
3101 case WLAN_CATEGORY_SPECTRUM_MGMT
:
3102 ieee80211_sta_process_chanswitch(sdata
,
3103 &mgmt
->u
.action
.u
.chan_switch
.sw_elem
,
3104 (void *)ifmgd
->associated
->priv
,
3105 rx_status
->mactime
);
3109 mutex_unlock(&ifmgd
->mtx
);
3115 case RX_MGMT_CFG80211_DEAUTH
:
3116 cfg80211_send_deauth(sdata
->dev
, (u8
*)mgmt
, skb
->len
);
3118 case RX_MGMT_CFG80211_DISASSOC
:
3119 cfg80211_send_disassoc(sdata
->dev
, (u8
*)mgmt
, skb
->len
);
3121 case RX_MGMT_CFG80211_RX_AUTH
:
3122 cfg80211_send_rx_auth(sdata
->dev
, (u8
*)mgmt
, skb
->len
);
3124 case RX_MGMT_CFG80211_RX_ASSOC
:
3125 cfg80211_send_rx_assoc(sdata
->dev
, bss
, (u8
*)mgmt
, skb
->len
);
3127 case RX_MGMT_CFG80211_ASSOC_TIMEOUT
:
3128 cfg80211_send_assoc_timeout(sdata
->dev
, mgmt
->bssid
);
3130 case RX_MGMT_CFG80211_TX_DEAUTH
:
3131 cfg80211_send_deauth(sdata
->dev
, deauth_buf
,
3132 sizeof(deauth_buf
));
3135 WARN(1, "unexpected: %d", rma
);
3139 static void ieee80211_sta_timer(unsigned long data
)
3141 struct ieee80211_sub_if_data
*sdata
=
3142 (struct ieee80211_sub_if_data
*) data
;
3143 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
3144 struct ieee80211_local
*local
= sdata
->local
;
3146 if (local
->quiescing
) {
3147 set_bit(TMR_RUNNING_TIMER
, &ifmgd
->timers_running
);
3151 ieee80211_queue_work(&local
->hw
, &sdata
->work
);
3154 static void ieee80211_sta_connection_lost(struct ieee80211_sub_if_data
*sdata
,
3155 u8
*bssid
, u8 reason
, bool tx
)
3157 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
3158 u8 frame_buf
[IEEE80211_DEAUTH_FRAME_LEN
];
3160 ieee80211_set_disassoc(sdata
, IEEE80211_STYPE_DEAUTH
, reason
,
3162 mutex_unlock(&ifmgd
->mtx
);
3165 * must be outside lock due to cfg80211,
3166 * but that's not a problem.
3168 cfg80211_send_deauth(sdata
->dev
, frame_buf
, IEEE80211_DEAUTH_FRAME_LEN
);
3170 mutex_lock(&ifmgd
->mtx
);
3173 static int ieee80211_probe_auth(struct ieee80211_sub_if_data
*sdata
)
3175 struct ieee80211_local
*local
= sdata
->local
;
3176 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
3177 struct ieee80211_mgd_auth_data
*auth_data
= ifmgd
->auth_data
;
3180 lockdep_assert_held(&ifmgd
->mtx
);
3182 if (WARN_ON_ONCE(!auth_data
))
3185 if (local
->hw
.flags
& IEEE80211_HW_REPORTS_TX_ACK_STATUS
)
3186 tx_flags
= IEEE80211_TX_CTL_REQ_TX_STATUS
|
3187 IEEE80211_TX_INTFL_MLME_CONN_TX
;
3191 if (auth_data
->tries
> IEEE80211_AUTH_MAX_TRIES
) {
3192 sdata_info(sdata
, "authentication with %pM timed out\n",
3193 auth_data
->bss
->bssid
);
3196 * Most likely AP is not in the range so remove the
3197 * bss struct for that AP.
3199 cfg80211_unlink_bss(local
->hw
.wiphy
, auth_data
->bss
);
3204 drv_mgd_prepare_tx(local
, sdata
);
3206 if (auth_data
->bss
->proberesp_ies
) {
3210 sdata_info(sdata
, "send auth to %pM (try %d/%d)\n",
3211 auth_data
->bss
->bssid
, auth_data
->tries
,
3212 IEEE80211_AUTH_MAX_TRIES
);
3214 auth_data
->expected_transaction
= 2;
3216 if (auth_data
->algorithm
== WLAN_AUTH_SAE
) {
3217 trans
= auth_data
->sae_trans
;
3218 status
= auth_data
->sae_status
;
3219 auth_data
->expected_transaction
= trans
;
3222 ieee80211_send_auth(sdata
, trans
, auth_data
->algorithm
, status
,
3223 auth_data
->data
, auth_data
->data_len
,
3224 auth_data
->bss
->bssid
,
3225 auth_data
->bss
->bssid
, NULL
, 0, 0,
3230 sdata_info(sdata
, "direct probe to %pM (try %d/%i)\n",
3231 auth_data
->bss
->bssid
, auth_data
->tries
,
3232 IEEE80211_AUTH_MAX_TRIES
);
3235 ssidie
= ieee80211_bss_get_ie(auth_data
->bss
, WLAN_EID_SSID
);
3241 * Direct probe is sent to broadcast address as some APs
3242 * will not answer to direct packet in unassociated state.
3244 ieee80211_send_probe_req(sdata
, NULL
, ssidie
+ 2, ssidie
[1],
3245 NULL
, 0, (u32
) -1, true, tx_flags
,
3246 auth_data
->bss
->channel
, false);
3250 if (!(local
->hw
.flags
& IEEE80211_HW_REPORTS_TX_ACK_STATUS
)) {
3251 auth_data
->timeout
= jiffies
+ IEEE80211_AUTH_TIMEOUT
;
3252 ifmgd
->auth_data
->timeout_started
= true;
3253 run_again(ifmgd
, auth_data
->timeout
);
3255 auth_data
->timeout_started
= false;
3261 static int ieee80211_do_assoc(struct ieee80211_sub_if_data
*sdata
)
3263 struct ieee80211_mgd_assoc_data
*assoc_data
= sdata
->u
.mgd
.assoc_data
;
3264 struct ieee80211_local
*local
= sdata
->local
;
3266 lockdep_assert_held(&sdata
->u
.mgd
.mtx
);
3268 assoc_data
->tries
++;
3269 if (assoc_data
->tries
> IEEE80211_ASSOC_MAX_TRIES
) {
3270 sdata_info(sdata
, "association with %pM timed out\n",
3271 assoc_data
->bss
->bssid
);
3274 * Most likely AP is not in the range so remove the
3275 * bss struct for that AP.
3277 cfg80211_unlink_bss(local
->hw
.wiphy
, assoc_data
->bss
);
3282 sdata_info(sdata
, "associate with %pM (try %d/%d)\n",
3283 assoc_data
->bss
->bssid
, assoc_data
->tries
,
3284 IEEE80211_ASSOC_MAX_TRIES
);
3285 ieee80211_send_assoc(sdata
);
3287 if (!(local
->hw
.flags
& IEEE80211_HW_REPORTS_TX_ACK_STATUS
)) {
3288 assoc_data
->timeout
= jiffies
+ IEEE80211_ASSOC_TIMEOUT
;
3289 assoc_data
->timeout_started
= true;
3290 run_again(&sdata
->u
.mgd
, assoc_data
->timeout
);
3292 assoc_data
->timeout_started
= false;
3298 void ieee80211_mgd_conn_tx_status(struct ieee80211_sub_if_data
*sdata
,
3299 __le16 fc
, bool acked
)
3301 struct ieee80211_local
*local
= sdata
->local
;
3303 sdata
->u
.mgd
.status_fc
= fc
;
3304 sdata
->u
.mgd
.status_acked
= acked
;
3305 sdata
->u
.mgd
.status_received
= true;
3307 ieee80211_queue_work(&local
->hw
, &sdata
->work
);
3310 void ieee80211_sta_work(struct ieee80211_sub_if_data
*sdata
)
3312 struct ieee80211_local
*local
= sdata
->local
;
3313 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
3315 mutex_lock(&ifmgd
->mtx
);
3317 if (ifmgd
->status_received
) {
3318 __le16 fc
= ifmgd
->status_fc
;
3319 bool status_acked
= ifmgd
->status_acked
;
3321 ifmgd
->status_received
= false;
3322 if (ifmgd
->auth_data
&&
3323 (ieee80211_is_probe_req(fc
) || ieee80211_is_auth(fc
))) {
3325 ifmgd
->auth_data
->timeout
=
3326 jiffies
+ IEEE80211_AUTH_TIMEOUT_SHORT
;
3327 run_again(ifmgd
, ifmgd
->auth_data
->timeout
);
3329 ifmgd
->auth_data
->timeout
= jiffies
- 1;
3331 ifmgd
->auth_data
->timeout_started
= true;
3332 } else if (ifmgd
->assoc_data
&&
3333 (ieee80211_is_assoc_req(fc
) ||
3334 ieee80211_is_reassoc_req(fc
))) {
3336 ifmgd
->assoc_data
->timeout
=
3337 jiffies
+ IEEE80211_ASSOC_TIMEOUT_SHORT
;
3338 run_again(ifmgd
, ifmgd
->assoc_data
->timeout
);
3340 ifmgd
->assoc_data
->timeout
= jiffies
- 1;
3342 ifmgd
->assoc_data
->timeout_started
= true;
3346 if (ifmgd
->auth_data
&& ifmgd
->auth_data
->timeout_started
&&
3347 time_after(jiffies
, ifmgd
->auth_data
->timeout
)) {
3348 if (ifmgd
->auth_data
->done
) {
3350 * ok ... we waited for assoc but userspace didn't,
3351 * so let's just kill the auth data
3353 ieee80211_destroy_auth_data(sdata
, false);
3354 } else if (ieee80211_probe_auth(sdata
)) {
3357 memcpy(bssid
, ifmgd
->auth_data
->bss
->bssid
, ETH_ALEN
);
3359 ieee80211_destroy_auth_data(sdata
, false);
3361 mutex_unlock(&ifmgd
->mtx
);
3362 cfg80211_send_auth_timeout(sdata
->dev
, bssid
);
3363 mutex_lock(&ifmgd
->mtx
);
3365 } else if (ifmgd
->auth_data
&& ifmgd
->auth_data
->timeout_started
)
3366 run_again(ifmgd
, ifmgd
->auth_data
->timeout
);
3368 if (ifmgd
->assoc_data
&& ifmgd
->assoc_data
->timeout_started
&&
3369 time_after(jiffies
, ifmgd
->assoc_data
->timeout
)) {
3370 if ((ifmgd
->assoc_data
->need_beacon
&&
3371 !ifmgd
->assoc_data
->have_beacon
) ||
3372 ieee80211_do_assoc(sdata
)) {
3375 memcpy(bssid
, ifmgd
->assoc_data
->bss
->bssid
, ETH_ALEN
);
3377 ieee80211_destroy_assoc_data(sdata
, false);
3379 mutex_unlock(&ifmgd
->mtx
);
3380 cfg80211_send_assoc_timeout(sdata
->dev
, bssid
);
3381 mutex_lock(&ifmgd
->mtx
);
3383 } else if (ifmgd
->assoc_data
&& ifmgd
->assoc_data
->timeout_started
)
3384 run_again(ifmgd
, ifmgd
->assoc_data
->timeout
);
3386 if (ifmgd
->flags
& (IEEE80211_STA_BEACON_POLL
|
3387 IEEE80211_STA_CONNECTION_POLL
) &&
3388 ifmgd
->associated
) {
3392 memcpy(bssid
, ifmgd
->associated
->bssid
, ETH_ALEN
);
3394 if (local
->hw
.flags
& IEEE80211_HW_REPORTS_TX_ACK_STATUS
)
3395 max_tries
= max_nullfunc_tries
;
3397 max_tries
= max_probe_tries
;
3399 /* ACK received for nullfunc probing frame */
3400 if (!ifmgd
->probe_send_count
)
3401 ieee80211_reset_ap_probe(sdata
);
3402 else if (ifmgd
->nullfunc_failed
) {
3403 if (ifmgd
->probe_send_count
< max_tries
) {
3405 "No ack for nullfunc frame to AP %pM, try %d/%i\n",
3406 bssid
, ifmgd
->probe_send_count
,
3408 ieee80211_mgd_probe_ap_send(sdata
);
3411 "No ack for nullfunc frame to AP %pM, disconnecting.\n",
3413 ieee80211_sta_connection_lost(sdata
, bssid
,
3414 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY
,
3417 } else if (time_is_after_jiffies(ifmgd
->probe_timeout
))
3418 run_again(ifmgd
, ifmgd
->probe_timeout
);
3419 else if (local
->hw
.flags
& IEEE80211_HW_REPORTS_TX_ACK_STATUS
) {
3421 "Failed to send nullfunc to AP %pM after %dms, disconnecting\n",
3422 bssid
, probe_wait_ms
);
3423 ieee80211_sta_connection_lost(sdata
, bssid
,
3424 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY
, false);
3425 } else if (ifmgd
->probe_send_count
< max_tries
) {
3427 "No probe response from AP %pM after %dms, try %d/%i\n",
3428 bssid
, probe_wait_ms
,
3429 ifmgd
->probe_send_count
, max_tries
);
3430 ieee80211_mgd_probe_ap_send(sdata
);
3433 * We actually lost the connection ... or did we?
3436 wiphy_debug(local
->hw
.wiphy
,
3437 "%s: No probe response from AP %pM"
3438 " after %dms, disconnecting.\n",
3440 bssid
, probe_wait_ms
);
3442 ieee80211_sta_connection_lost(sdata
, bssid
,
3443 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY
, false);
3447 mutex_unlock(&ifmgd
->mtx
);
3450 static void ieee80211_sta_bcn_mon_timer(unsigned long data
)
3452 struct ieee80211_sub_if_data
*sdata
=
3453 (struct ieee80211_sub_if_data
*) data
;
3454 struct ieee80211_local
*local
= sdata
->local
;
3456 if (local
->quiescing
)
3459 sdata
->u
.mgd
.connection_loss
= false;
3460 ieee80211_queue_work(&sdata
->local
->hw
,
3461 &sdata
->u
.mgd
.beacon_connection_loss_work
);
3464 static void ieee80211_sta_conn_mon_timer(unsigned long data
)
3466 struct ieee80211_sub_if_data
*sdata
=
3467 (struct ieee80211_sub_if_data
*) data
;
3468 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
3469 struct ieee80211_local
*local
= sdata
->local
;
3471 if (local
->quiescing
)
3474 ieee80211_queue_work(&local
->hw
, &ifmgd
->monitor_work
);
3477 static void ieee80211_sta_monitor_work(struct work_struct
*work
)
3479 struct ieee80211_sub_if_data
*sdata
=
3480 container_of(work
, struct ieee80211_sub_if_data
,
3481 u
.mgd
.monitor_work
);
3483 ieee80211_mgd_probe_ap(sdata
, false);
3486 static void ieee80211_restart_sta_timer(struct ieee80211_sub_if_data
*sdata
)
3490 if (sdata
->vif
.type
== NL80211_IFTYPE_STATION
) {
3491 __ieee80211_stop_poll(sdata
);
3493 /* let's probe the connection once */
3494 flags
= sdata
->local
->hw
.flags
;
3495 if (!(flags
& IEEE80211_HW_CONNECTION_MONITOR
))
3496 ieee80211_queue_work(&sdata
->local
->hw
,
3497 &sdata
->u
.mgd
.monitor_work
);
3498 /* and do all the other regular work too */
3499 ieee80211_queue_work(&sdata
->local
->hw
, &sdata
->work
);
3504 void ieee80211_sta_quiesce(struct ieee80211_sub_if_data
*sdata
)
3506 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
3509 * Stop timers before deleting work items, as timers
3510 * could race and re-add the work-items. They will be
3511 * re-established on connection.
3513 del_timer_sync(&ifmgd
->conn_mon_timer
);
3514 del_timer_sync(&ifmgd
->bcn_mon_timer
);
3517 * we need to use atomic bitops for the running bits
3518 * only because both timers might fire at the same
3519 * time -- the code here is properly synchronised.
3522 cancel_work_sync(&ifmgd
->request_smps_work
);
3524 cancel_work_sync(&ifmgd
->monitor_work
);
3525 cancel_work_sync(&ifmgd
->beacon_connection_loss_work
);
3526 cancel_work_sync(&ifmgd
->csa_connection_drop_work
);
3527 if (del_timer_sync(&ifmgd
->timer
))
3528 set_bit(TMR_RUNNING_TIMER
, &ifmgd
->timers_running
);
3530 if (del_timer_sync(&ifmgd
->chswitch_timer
))
3531 set_bit(TMR_RUNNING_CHANSW
, &ifmgd
->timers_running
);
3532 cancel_work_sync(&ifmgd
->chswitch_work
);
3535 void ieee80211_sta_restart(struct ieee80211_sub_if_data
*sdata
)
3537 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
3539 mutex_lock(&ifmgd
->mtx
);
3540 if (!ifmgd
->associated
) {
3541 mutex_unlock(&ifmgd
->mtx
);
3545 if (sdata
->flags
& IEEE80211_SDATA_DISCONNECT_RESUME
) {
3546 sdata
->flags
&= ~IEEE80211_SDATA_DISCONNECT_RESUME
;
3547 mlme_dbg(sdata
, "driver requested disconnect after resume\n");
3548 ieee80211_sta_connection_lost(sdata
,
3549 ifmgd
->associated
->bssid
,
3550 WLAN_REASON_UNSPECIFIED
,
3552 mutex_unlock(&ifmgd
->mtx
);
3555 mutex_unlock(&ifmgd
->mtx
);
3557 if (test_and_clear_bit(TMR_RUNNING_TIMER
, &ifmgd
->timers_running
))
3558 add_timer(&ifmgd
->timer
);
3559 if (test_and_clear_bit(TMR_RUNNING_CHANSW
, &ifmgd
->timers_running
))
3560 add_timer(&ifmgd
->chswitch_timer
);
3561 ieee80211_sta_reset_beacon_monitor(sdata
);
3563 mutex_lock(&sdata
->local
->mtx
);
3564 ieee80211_restart_sta_timer(sdata
);
3565 mutex_unlock(&sdata
->local
->mtx
);
3569 /* interface setup */
3570 void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data
*sdata
)
3572 struct ieee80211_if_managed
*ifmgd
;
3574 ifmgd
= &sdata
->u
.mgd
;
3575 INIT_WORK(&ifmgd
->monitor_work
, ieee80211_sta_monitor_work
);
3576 INIT_WORK(&ifmgd
->chswitch_work
, ieee80211_chswitch_work
);
3577 INIT_WORK(&ifmgd
->beacon_connection_loss_work
,
3578 ieee80211_beacon_connection_loss_work
);
3579 INIT_WORK(&ifmgd
->csa_connection_drop_work
,
3580 ieee80211_csa_connection_drop_work
);
3581 INIT_WORK(&ifmgd
->request_smps_work
, ieee80211_request_smps_work
);
3582 setup_timer(&ifmgd
->timer
, ieee80211_sta_timer
,
3583 (unsigned long) sdata
);
3584 setup_timer(&ifmgd
->bcn_mon_timer
, ieee80211_sta_bcn_mon_timer
,
3585 (unsigned long) sdata
);
3586 setup_timer(&ifmgd
->conn_mon_timer
, ieee80211_sta_conn_mon_timer
,
3587 (unsigned long) sdata
);
3588 setup_timer(&ifmgd
->chswitch_timer
, ieee80211_chswitch_timer
,
3589 (unsigned long) sdata
);
3592 ifmgd
->powersave
= sdata
->wdev
.ps
;
3593 ifmgd
->uapsd_queues
= IEEE80211_DEFAULT_UAPSD_QUEUES
;
3594 ifmgd
->uapsd_max_sp_len
= IEEE80211_DEFAULT_MAX_SP_LEN
;
3596 mutex_init(&ifmgd
->mtx
);
3598 if (sdata
->local
->hw
.flags
& IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS
)
3599 ifmgd
->req_smps
= IEEE80211_SMPS_AUTOMATIC
;
3601 ifmgd
->req_smps
= IEEE80211_SMPS_OFF
;
3604 /* scan finished notification */
3605 void ieee80211_mlme_notify_scan_completed(struct ieee80211_local
*local
)
3607 struct ieee80211_sub_if_data
*sdata
;
3609 /* Restart STA timers */
3611 list_for_each_entry_rcu(sdata
, &local
->interfaces
, list
) {
3612 if (ieee80211_sdata_running(sdata
))
3613 ieee80211_restart_sta_timer(sdata
);
3618 int ieee80211_max_network_latency(struct notifier_block
*nb
,
3619 unsigned long data
, void *dummy
)
3621 s32 latency_usec
= (s32
) data
;
3622 struct ieee80211_local
*local
=
3623 container_of(nb
, struct ieee80211_local
,
3624 network_latency_notifier
);
3626 mutex_lock(&local
->iflist_mtx
);
3627 ieee80211_recalc_ps(local
, latency_usec
);
3628 mutex_unlock(&local
->iflist_mtx
);
3633 static u8
ieee80211_ht_vht_rx_chains(struct ieee80211_sub_if_data
*sdata
,
3634 struct cfg80211_bss
*cbss
)
3636 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
3637 const u8
*ht_cap_ie
, *vht_cap_ie
;
3638 const struct ieee80211_ht_cap
*ht_cap
;
3639 const struct ieee80211_vht_cap
*vht_cap
;
3642 if (ifmgd
->flags
& IEEE80211_STA_DISABLE_HT
)
3645 ht_cap_ie
= ieee80211_bss_get_ie(cbss
, WLAN_EID_HT_CAPABILITY
);
3646 if (ht_cap_ie
&& ht_cap_ie
[1] >= sizeof(*ht_cap
)) {
3647 ht_cap
= (void *)(ht_cap_ie
+ 2);
3648 chains
= ieee80211_mcs_to_chains(&ht_cap
->mcs
);
3650 * TODO: use "Tx Maximum Number Spatial Streams Supported" and
3651 * "Tx Unequal Modulation Supported" fields.
3655 if (ifmgd
->flags
& IEEE80211_STA_DISABLE_VHT
)
3658 vht_cap_ie
= ieee80211_bss_get_ie(cbss
, WLAN_EID_VHT_CAPABILITY
);
3659 if (vht_cap_ie
&& vht_cap_ie
[1] >= sizeof(*vht_cap
)) {
3663 vht_cap
= (void *)(vht_cap_ie
+ 2);
3664 tx_mcs_map
= le16_to_cpu(vht_cap
->supp_mcs
.tx_mcs_map
);
3665 for (nss
= 8; nss
> 0; nss
--) {
3666 if (((tx_mcs_map
>> (2 * (nss
- 1))) & 3) !=
3667 IEEE80211_VHT_MCS_NOT_SUPPORTED
)
3670 /* TODO: use "Tx Highest Supported Long GI Data Rate" field? */
3671 chains
= max(chains
, nss
);
3677 static int ieee80211_prep_channel(struct ieee80211_sub_if_data
*sdata
,
3678 struct cfg80211_bss
*cbss
)
3680 struct ieee80211_local
*local
= sdata
->local
;
3681 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
3682 const struct ieee80211_ht_operation
*ht_oper
= NULL
;
3683 const struct ieee80211_vht_operation
*vht_oper
= NULL
;
3684 struct ieee80211_supported_band
*sband
;
3685 struct cfg80211_chan_def chandef
;
3688 sband
= local
->hw
.wiphy
->bands
[cbss
->channel
->band
];
3690 ifmgd
->flags
&= ~(IEEE80211_STA_DISABLE_40MHZ
|
3691 IEEE80211_STA_DISABLE_80P80MHZ
|
3692 IEEE80211_STA_DISABLE_160MHZ
);
3696 if (!(ifmgd
->flags
& IEEE80211_STA_DISABLE_HT
) &&
3697 sband
->ht_cap
.ht_supported
) {
3698 const u8
*ht_oper_ie
, *ht_cap
;
3700 ht_oper_ie
= ieee80211_bss_get_ie(cbss
, WLAN_EID_HT_OPERATION
);
3701 if (ht_oper_ie
&& ht_oper_ie
[1] >= sizeof(*ht_oper
))
3702 ht_oper
= (void *)(ht_oper_ie
+ 2);
3704 ht_cap
= ieee80211_bss_get_ie(cbss
, WLAN_EID_HT_CAPABILITY
);
3705 if (!ht_cap
|| ht_cap
[1] < sizeof(struct ieee80211_ht_cap
)) {
3706 ifmgd
->flags
|= IEEE80211_STA_DISABLE_HT
;
3711 if (!(ifmgd
->flags
& IEEE80211_STA_DISABLE_VHT
) &&
3712 sband
->vht_cap
.vht_supported
) {
3713 const u8
*vht_oper_ie
, *vht_cap
;
3715 vht_oper_ie
= ieee80211_bss_get_ie(cbss
,
3716 WLAN_EID_VHT_OPERATION
);
3717 if (vht_oper_ie
&& vht_oper_ie
[1] >= sizeof(*vht_oper
))
3718 vht_oper
= (void *)(vht_oper_ie
+ 2);
3719 if (vht_oper
&& !ht_oper
) {
3722 "AP advertised VHT without HT, disabling both\n");
3723 ifmgd
->flags
|= IEEE80211_STA_DISABLE_HT
;
3724 ifmgd
->flags
|= IEEE80211_STA_DISABLE_VHT
;
3727 vht_cap
= ieee80211_bss_get_ie(cbss
, WLAN_EID_VHT_CAPABILITY
);
3728 if (!vht_cap
|| vht_cap
[1] < sizeof(struct ieee80211_vht_cap
)) {
3729 ifmgd
->flags
|= IEEE80211_STA_DISABLE_VHT
;
3734 ifmgd
->flags
|= ieee80211_determine_chantype(sdata
, sband
,
3739 sdata
->needed_rx_chains
= min(ieee80211_ht_vht_rx_chains(sdata
, cbss
),
3744 /* will change later if needed */
3745 sdata
->smps_mode
= IEEE80211_SMPS_OFF
;
3748 * If this fails (possibly due to channel context sharing
3749 * on incompatible channels, e.g. 80+80 and 160 sharing the
3750 * same control channel) try to use a smaller bandwidth.
3752 ret
= ieee80211_vif_use_channel(sdata
, &chandef
,
3753 IEEE80211_CHANCTX_SHARED
);
3754 while (ret
&& chandef
.width
!= NL80211_CHAN_WIDTH_20_NOHT
) {
3755 ifmgd
->flags
|= chandef_downgrade(&chandef
);
3756 ret
= ieee80211_vif_use_channel(sdata
, &chandef
,
3757 IEEE80211_CHANCTX_SHARED
);
3762 static int ieee80211_prep_connection(struct ieee80211_sub_if_data
*sdata
,
3763 struct cfg80211_bss
*cbss
, bool assoc
)
3765 struct ieee80211_local
*local
= sdata
->local
;
3766 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
3767 struct ieee80211_bss
*bss
= (void *)cbss
->priv
;
3768 struct sta_info
*new_sta
= NULL
;
3769 bool have_sta
= false;
3772 if (WARN_ON(!ifmgd
->auth_data
&& !ifmgd
->assoc_data
))
3777 have_sta
= sta_info_get(sdata
, cbss
->bssid
);
3782 new_sta
= sta_info_alloc(sdata
, cbss
->bssid
, GFP_KERNEL
);
3788 u32 rates
= 0, basic_rates
= 0;
3789 bool have_higher_than_11mbit
;
3790 int min_rate
= INT_MAX
, min_rate_index
= -1;
3791 struct ieee80211_supported_band
*sband
;
3792 const struct cfg80211_bss_ies
*ies
;
3794 sband
= local
->hw
.wiphy
->bands
[cbss
->channel
->band
];
3796 err
= ieee80211_prep_channel(sdata
, cbss
);
3798 sta_info_free(local
, new_sta
);
3802 ieee80211_get_rates(sband
, bss
->supp_rates
,
3803 bss
->supp_rates_len
,
3804 &rates
, &basic_rates
,
3805 &have_higher_than_11mbit
,
3806 &min_rate
, &min_rate_index
);
3809 * This used to be a workaround for basic rates missing
3810 * in the association response frame. Now that we no
3811 * longer use the basic rates from there, it probably
3812 * doesn't happen any more, but keep the workaround so
3813 * in case some *other* APs are buggy in different ways
3814 * we can connect -- with a warning.
3816 if (!basic_rates
&& min_rate_index
>= 0) {
3818 "No basic rates, using min rate instead\n");
3819 basic_rates
= BIT(min_rate_index
);
3822 new_sta
->sta
.supp_rates
[cbss
->channel
->band
] = rates
;
3823 sdata
->vif
.bss_conf
.basic_rates
= basic_rates
;
3825 /* cf. IEEE 802.11 9.2.12 */
3826 if (cbss
->channel
->band
== IEEE80211_BAND_2GHZ
&&
3827 have_higher_than_11mbit
)
3828 sdata
->flags
|= IEEE80211_SDATA_OPERATING_GMODE
;
3830 sdata
->flags
&= ~IEEE80211_SDATA_OPERATING_GMODE
;
3832 memcpy(ifmgd
->bssid
, cbss
->bssid
, ETH_ALEN
);
3834 /* set timing information */
3835 sdata
->vif
.bss_conf
.beacon_int
= cbss
->beacon_interval
;
3837 ies
= rcu_dereference(cbss
->beacon_ies
);
3841 sdata
->vif
.bss_conf
.sync_tsf
= ies
->tsf
;
3842 sdata
->vif
.bss_conf
.sync_device_ts
=
3843 bss
->device_ts_beacon
;
3844 tim_ie
= cfg80211_find_ie(WLAN_EID_TIM
,
3845 ies
->data
, ies
->len
);
3846 if (tim_ie
&& tim_ie
[1] >= 2)
3847 sdata
->vif
.bss_conf
.sync_dtim_count
= tim_ie
[2];
3849 sdata
->vif
.bss_conf
.sync_dtim_count
= 0;
3850 } else if (!(local
->hw
.flags
&
3851 IEEE80211_HW_TIMING_BEACON_ONLY
)) {
3852 ies
= rcu_dereference(cbss
->proberesp_ies
);
3853 /* must be non-NULL since beacon IEs were NULL */
3854 sdata
->vif
.bss_conf
.sync_tsf
= ies
->tsf
;
3855 sdata
->vif
.bss_conf
.sync_device_ts
=
3856 bss
->device_ts_presp
;
3857 sdata
->vif
.bss_conf
.sync_dtim_count
= 0;
3859 sdata
->vif
.bss_conf
.sync_tsf
= 0;
3860 sdata
->vif
.bss_conf
.sync_device_ts
= 0;
3861 sdata
->vif
.bss_conf
.sync_dtim_count
= 0;
3865 /* tell driver about BSSID, basic rates and timing */
3866 ieee80211_bss_info_change_notify(sdata
,
3867 BSS_CHANGED_BSSID
| BSS_CHANGED_BASIC_RATES
|
3868 BSS_CHANGED_BEACON_INT
);
3871 sta_info_pre_move_state(new_sta
, IEEE80211_STA_AUTH
);
3873 err
= sta_info_insert(new_sta
);
3877 "failed to insert STA entry for the AP (error %d)\n",
3882 WARN_ON_ONCE(!ether_addr_equal(ifmgd
->bssid
, cbss
->bssid
));
3888 int ieee80211_mgd_auth(struct ieee80211_sub_if_data
*sdata
,
3889 struct cfg80211_auth_request
*req
)
3891 struct ieee80211_local
*local
= sdata
->local
;
3892 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
3893 struct ieee80211_mgd_auth_data
*auth_data
;
3897 /* prepare auth data structure */
3899 switch (req
->auth_type
) {
3900 case NL80211_AUTHTYPE_OPEN_SYSTEM
:
3901 auth_alg
= WLAN_AUTH_OPEN
;
3903 case NL80211_AUTHTYPE_SHARED_KEY
:
3904 if (IS_ERR(local
->wep_tx_tfm
))
3906 auth_alg
= WLAN_AUTH_SHARED_KEY
;
3908 case NL80211_AUTHTYPE_FT
:
3909 auth_alg
= WLAN_AUTH_FT
;
3911 case NL80211_AUTHTYPE_NETWORK_EAP
:
3912 auth_alg
= WLAN_AUTH_LEAP
;
3914 case NL80211_AUTHTYPE_SAE
:
3915 auth_alg
= WLAN_AUTH_SAE
;
3921 auth_data
= kzalloc(sizeof(*auth_data
) + req
->sae_data_len
+
3922 req
->ie_len
, GFP_KERNEL
);
3926 auth_data
->bss
= req
->bss
;
3928 if (req
->sae_data_len
>= 4) {
3929 __le16
*pos
= (__le16
*) req
->sae_data
;
3930 auth_data
->sae_trans
= le16_to_cpu(pos
[0]);
3931 auth_data
->sae_status
= le16_to_cpu(pos
[1]);
3932 memcpy(auth_data
->data
, req
->sae_data
+ 4,
3933 req
->sae_data_len
- 4);
3934 auth_data
->data_len
+= req
->sae_data_len
- 4;
3937 if (req
->ie
&& req
->ie_len
) {
3938 memcpy(&auth_data
->data
[auth_data
->data_len
],
3939 req
->ie
, req
->ie_len
);
3940 auth_data
->data_len
+= req
->ie_len
;
3943 if (req
->key
&& req
->key_len
) {
3944 auth_data
->key_len
= req
->key_len
;
3945 auth_data
->key_idx
= req
->key_idx
;
3946 memcpy(auth_data
->key
, req
->key
, req
->key_len
);
3949 auth_data
->algorithm
= auth_alg
;
3951 /* try to authenticate/probe */
3953 mutex_lock(&ifmgd
->mtx
);
3955 if ((ifmgd
->auth_data
&& !ifmgd
->auth_data
->done
) ||
3956 ifmgd
->assoc_data
) {
3961 if (ifmgd
->auth_data
)
3962 ieee80211_destroy_auth_data(sdata
, false);
3964 /* prep auth_data so we don't go into idle on disassoc */
3965 ifmgd
->auth_data
= auth_data
;
3967 if (ifmgd
->associated
)
3968 ieee80211_set_disassoc(sdata
, 0, 0, false, NULL
);
3970 sdata_info(sdata
, "authenticate with %pM\n", req
->bss
->bssid
);
3972 err
= ieee80211_prep_connection(sdata
, req
->bss
, false);
3976 err
= ieee80211_probe_auth(sdata
);
3978 sta_info_destroy_addr(sdata
, req
->bss
->bssid
);
3982 /* hold our own reference */
3983 cfg80211_ref_bss(local
->hw
.wiphy
, auth_data
->bss
);
3988 memset(ifmgd
->bssid
, 0, ETH_ALEN
);
3989 ieee80211_bss_info_change_notify(sdata
, BSS_CHANGED_BSSID
);
3990 ifmgd
->auth_data
= NULL
;
3994 mutex_unlock(&ifmgd
->mtx
);
3999 int ieee80211_mgd_assoc(struct ieee80211_sub_if_data
*sdata
,
4000 struct cfg80211_assoc_request
*req
)
4002 struct ieee80211_local
*local
= sdata
->local
;
4003 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
4004 struct ieee80211_bss
*bss
= (void *)req
->bss
->priv
;
4005 struct ieee80211_mgd_assoc_data
*assoc_data
;
4006 const struct cfg80211_bss_ies
*beacon_ies
;
4007 struct ieee80211_supported_band
*sband
;
4008 const u8
*ssidie
, *ht_ie
, *vht_ie
;
4011 assoc_data
= kzalloc(sizeof(*assoc_data
) + req
->ie_len
, GFP_KERNEL
);
4016 ssidie
= ieee80211_bss_get_ie(req
->bss
, WLAN_EID_SSID
);
4022 memcpy(assoc_data
->ssid
, ssidie
+ 2, ssidie
[1]);
4023 assoc_data
->ssid_len
= ssidie
[1];
4026 mutex_lock(&ifmgd
->mtx
);
4028 if (ifmgd
->associated
)
4029 ieee80211_set_disassoc(sdata
, 0, 0, false, NULL
);
4031 if (ifmgd
->auth_data
&& !ifmgd
->auth_data
->done
) {
4036 if (ifmgd
->assoc_data
) {
4041 if (ifmgd
->auth_data
) {
4044 /* keep sta info, bssid if matching */
4045 match
= ether_addr_equal(ifmgd
->bssid
, req
->bss
->bssid
);
4046 ieee80211_destroy_auth_data(sdata
, match
);
4049 /* prepare assoc data */
4051 ifmgd
->beacon_crc_valid
= false;
4054 * IEEE802.11n does not allow TKIP/WEP as pairwise ciphers in HT mode.
4055 * We still associate in non-HT mode (11a/b/g) if any one of these
4056 * ciphers is configured as pairwise.
4057 * We can set this to true for non-11n hardware, that'll be checked
4058 * separately along with the peer capabilities.
4060 for (i
= 0; i
< req
->crypto
.n_ciphers_pairwise
; i
++) {
4061 if (req
->crypto
.ciphers_pairwise
[i
] == WLAN_CIPHER_SUITE_WEP40
||
4062 req
->crypto
.ciphers_pairwise
[i
] == WLAN_CIPHER_SUITE_TKIP
||
4063 req
->crypto
.ciphers_pairwise
[i
] == WLAN_CIPHER_SUITE_WEP104
) {
4064 ifmgd
->flags
|= IEEE80211_STA_DISABLE_HT
;
4065 ifmgd
->flags
|= IEEE80211_STA_DISABLE_VHT
;
4066 netdev_info(sdata
->dev
,
4067 "disabling HT/VHT due to WEP/TKIP use\n");
4071 if (req
->flags
& ASSOC_REQ_DISABLE_HT
) {
4072 ifmgd
->flags
|= IEEE80211_STA_DISABLE_HT
;
4073 ifmgd
->flags
|= IEEE80211_STA_DISABLE_VHT
;
4076 /* Also disable HT if we don't support it or the AP doesn't use WMM */
4077 sband
= local
->hw
.wiphy
->bands
[req
->bss
->channel
->band
];
4078 if (!sband
->ht_cap
.ht_supported
||
4079 local
->hw
.queues
< IEEE80211_NUM_ACS
|| !bss
->wmm_used
) {
4080 ifmgd
->flags
|= IEEE80211_STA_DISABLE_HT
;
4082 netdev_info(sdata
->dev
,
4083 "disabling HT as WMM/QoS is not supported by the AP\n");
4086 /* disable VHT if we don't support it or the AP doesn't use WMM */
4087 if (!sband
->vht_cap
.vht_supported
||
4088 local
->hw
.queues
< IEEE80211_NUM_ACS
|| !bss
->wmm_used
) {
4089 ifmgd
->flags
|= IEEE80211_STA_DISABLE_VHT
;
4091 netdev_info(sdata
->dev
,
4092 "disabling VHT as WMM/QoS is not supported by the AP\n");
4095 memcpy(&ifmgd
->ht_capa
, &req
->ht_capa
, sizeof(ifmgd
->ht_capa
));
4096 memcpy(&ifmgd
->ht_capa_mask
, &req
->ht_capa_mask
,
4097 sizeof(ifmgd
->ht_capa_mask
));
4099 if (req
->ie
&& req
->ie_len
) {
4100 memcpy(assoc_data
->ie
, req
->ie
, req
->ie_len
);
4101 assoc_data
->ie_len
= req
->ie_len
;
4104 assoc_data
->bss
= req
->bss
;
4106 if (ifmgd
->req_smps
== IEEE80211_SMPS_AUTOMATIC
) {
4107 if (ifmgd
->powersave
)
4108 sdata
->smps_mode
= IEEE80211_SMPS_DYNAMIC
;
4110 sdata
->smps_mode
= IEEE80211_SMPS_OFF
;
4112 sdata
->smps_mode
= ifmgd
->req_smps
;
4114 assoc_data
->capability
= req
->bss
->capability
;
4115 assoc_data
->wmm
= bss
->wmm_used
&&
4116 (local
->hw
.queues
>= IEEE80211_NUM_ACS
);
4117 assoc_data
->supp_rates
= bss
->supp_rates
;
4118 assoc_data
->supp_rates_len
= bss
->supp_rates_len
;
4121 ht_ie
= ieee80211_bss_get_ie(req
->bss
, WLAN_EID_HT_OPERATION
);
4122 if (ht_ie
&& ht_ie
[1] >= sizeof(struct ieee80211_ht_operation
))
4123 assoc_data
->ap_ht_param
=
4124 ((struct ieee80211_ht_operation
*)(ht_ie
+ 2))->ht_param
;
4126 ifmgd
->flags
|= IEEE80211_STA_DISABLE_HT
;
4127 vht_ie
= ieee80211_bss_get_ie(req
->bss
, WLAN_EID_VHT_CAPABILITY
);
4128 if (vht_ie
&& vht_ie
[1] >= sizeof(struct ieee80211_vht_cap
))
4129 memcpy(&assoc_data
->ap_vht_cap
, vht_ie
+ 2,
4130 sizeof(struct ieee80211_vht_cap
));
4132 ifmgd
->flags
|= IEEE80211_STA_DISABLE_VHT
;
4135 if (bss
->wmm_used
&& bss
->uapsd_supported
&&
4136 (sdata
->local
->hw
.flags
& IEEE80211_HW_SUPPORTS_UAPSD
)) {
4137 assoc_data
->uapsd
= true;
4138 ifmgd
->flags
|= IEEE80211_STA_UAPSD_ENABLED
;
4140 assoc_data
->uapsd
= false;
4141 ifmgd
->flags
&= ~IEEE80211_STA_UAPSD_ENABLED
;
4144 if (req
->prev_bssid
)
4145 memcpy(assoc_data
->prev_bssid
, req
->prev_bssid
, ETH_ALEN
);
4148 ifmgd
->mfp
= IEEE80211_MFP_REQUIRED
;
4149 ifmgd
->flags
|= IEEE80211_STA_MFP_ENABLED
;
4151 ifmgd
->mfp
= IEEE80211_MFP_DISABLED
;
4152 ifmgd
->flags
&= ~IEEE80211_STA_MFP_ENABLED
;
4155 if (req
->crypto
.control_port
)
4156 ifmgd
->flags
|= IEEE80211_STA_CONTROL_PORT
;
4158 ifmgd
->flags
&= ~IEEE80211_STA_CONTROL_PORT
;
4160 sdata
->control_port_protocol
= req
->crypto
.control_port_ethertype
;
4161 sdata
->control_port_no_encrypt
= req
->crypto
.control_port_no_encrypt
;
4163 /* kick off associate process */
4165 ifmgd
->assoc_data
= assoc_data
;
4166 ifmgd
->dtim_period
= 0;
4168 err
= ieee80211_prep_connection(sdata
, req
->bss
, true);
4173 beacon_ies
= rcu_dereference(req
->bss
->beacon_ies
);
4175 if (sdata
->local
->hw
.flags
& IEEE80211_HW_NEED_DTIM_BEFORE_ASSOC
&&
4178 * Wait up to one beacon interval ...
4179 * should this be more if we miss one?
4181 sdata_info(sdata
, "waiting for beacon from %pM\n",
4183 assoc_data
->timeout
= TU_TO_EXP_TIME(req
->bss
->beacon_interval
);
4184 assoc_data
->timeout_started
= true;
4185 assoc_data
->need_beacon
= true;
4186 } else if (beacon_ies
) {
4187 const u8
*tim_ie
= cfg80211_find_ie(WLAN_EID_TIM
,
4192 if (tim_ie
&& tim_ie
[1] >= sizeof(struct ieee80211_tim_ie
)) {
4193 const struct ieee80211_tim_ie
*tim
;
4194 tim
= (void *)(tim_ie
+ 2);
4195 ifmgd
->dtim_period
= tim
->dtim_period
;
4196 dtim_count
= tim
->dtim_count
;
4198 assoc_data
->have_beacon
= true;
4199 assoc_data
->timeout
= jiffies
;
4200 assoc_data
->timeout_started
= true;
4202 if (local
->hw
.flags
& IEEE80211_HW_TIMING_BEACON_ONLY
) {
4203 sdata
->vif
.bss_conf
.sync_tsf
= beacon_ies
->tsf
;
4204 sdata
->vif
.bss_conf
.sync_device_ts
=
4205 bss
->device_ts_beacon
;
4206 sdata
->vif
.bss_conf
.sync_dtim_count
= dtim_count
;
4209 assoc_data
->timeout
= jiffies
;
4210 assoc_data
->timeout_started
= true;
4214 run_again(ifmgd
, assoc_data
->timeout
);
4216 if (bss
->corrupt_data
) {
4217 char *corrupt_type
= "data";
4218 if (bss
->corrupt_data
& IEEE80211_BSS_CORRUPT_BEACON
) {
4219 if (bss
->corrupt_data
&
4220 IEEE80211_BSS_CORRUPT_PROBE_RESP
)
4221 corrupt_type
= "beacon and probe response";
4223 corrupt_type
= "beacon";
4224 } else if (bss
->corrupt_data
& IEEE80211_BSS_CORRUPT_PROBE_RESP
)
4225 corrupt_type
= "probe response";
4226 sdata_info(sdata
, "associating with AP with corrupt %s\n",
4233 memset(ifmgd
->bssid
, 0, ETH_ALEN
);
4234 ieee80211_bss_info_change_notify(sdata
, BSS_CHANGED_BSSID
);
4235 ifmgd
->assoc_data
= NULL
;
4239 mutex_unlock(&ifmgd
->mtx
);
4244 int ieee80211_mgd_deauth(struct ieee80211_sub_if_data
*sdata
,
4245 struct cfg80211_deauth_request
*req
)
4247 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
4248 u8 frame_buf
[IEEE80211_DEAUTH_FRAME_LEN
];
4249 bool tx
= !req
->local_state_change
;
4250 bool sent_frame
= false;
4252 mutex_lock(&ifmgd
->mtx
);
4255 "deauthenticating from %pM by local choice (reason=%d)\n",
4256 req
->bssid
, req
->reason_code
);
4258 if (ifmgd
->auth_data
) {
4259 drv_mgd_prepare_tx(sdata
->local
, sdata
);
4260 ieee80211_send_deauth_disassoc(sdata
, req
->bssid
,
4261 IEEE80211_STYPE_DEAUTH
,
4262 req
->reason_code
, tx
,
4264 ieee80211_destroy_auth_data(sdata
, false);
4265 mutex_unlock(&ifmgd
->mtx
);
4271 if (ifmgd
->associated
&&
4272 ether_addr_equal(ifmgd
->associated
->bssid
, req
->bssid
)) {
4273 ieee80211_set_disassoc(sdata
, IEEE80211_STYPE_DEAUTH
,
4274 req
->reason_code
, tx
, frame_buf
);
4277 mutex_unlock(&ifmgd
->mtx
);
4281 __cfg80211_send_deauth(sdata
->dev
, frame_buf
,
4282 IEEE80211_DEAUTH_FRAME_LEN
);
4287 int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data
*sdata
,
4288 struct cfg80211_disassoc_request
*req
)
4290 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
4292 u8 frame_buf
[IEEE80211_DEAUTH_FRAME_LEN
];
4294 mutex_lock(&ifmgd
->mtx
);
4297 * cfg80211 should catch this ... but it's racy since
4298 * we can receive a disassoc frame, process it, hand it
4299 * to cfg80211 while that's in a locked section already
4300 * trying to tell us that the user wants to disconnect.
4302 if (ifmgd
->associated
!= req
->bss
) {
4303 mutex_unlock(&ifmgd
->mtx
);
4308 "disassociating from %pM by local choice (reason=%d)\n",
4309 req
->bss
->bssid
, req
->reason_code
);
4311 memcpy(bssid
, req
->bss
->bssid
, ETH_ALEN
);
4312 ieee80211_set_disassoc(sdata
, IEEE80211_STYPE_DISASSOC
,
4313 req
->reason_code
, !req
->local_state_change
,
4315 mutex_unlock(&ifmgd
->mtx
);
4317 __cfg80211_send_disassoc(sdata
->dev
, frame_buf
,
4318 IEEE80211_DEAUTH_FRAME_LEN
);
4323 void ieee80211_mgd_stop(struct ieee80211_sub_if_data
*sdata
)
4325 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
4328 * Make sure some work items will not run after this,
4329 * they will not do anything but might not have been
4330 * cancelled when disconnecting.
4332 cancel_work_sync(&ifmgd
->monitor_work
);
4333 cancel_work_sync(&ifmgd
->beacon_connection_loss_work
);
4334 cancel_work_sync(&ifmgd
->request_smps_work
);
4335 cancel_work_sync(&ifmgd
->csa_connection_drop_work
);
4336 cancel_work_sync(&ifmgd
->chswitch_work
);
4338 mutex_lock(&ifmgd
->mtx
);
4339 if (ifmgd
->assoc_data
)
4340 ieee80211_destroy_assoc_data(sdata
, false);
4341 if (ifmgd
->auth_data
)
4342 ieee80211_destroy_auth_data(sdata
, false);
4343 del_timer_sync(&ifmgd
->timer
);
4344 mutex_unlock(&ifmgd
->mtx
);
4347 void ieee80211_cqm_rssi_notify(struct ieee80211_vif
*vif
,
4348 enum nl80211_cqm_rssi_threshold_event rssi_event
,
4351 struct ieee80211_sub_if_data
*sdata
= vif_to_sdata(vif
);
4353 trace_api_cqm_rssi_notify(sdata
, rssi_event
);
4355 cfg80211_cqm_rssi_notify(sdata
->dev
, rssi_event
, gfp
);
4357 EXPORT_SYMBOL(ieee80211_cqm_rssi_notify
);