2 * Copyright 2002-2005, Instant802 Networks, Inc.
3 * Copyright 2005-2006, Devicescape Software, Inc.
4 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
5 * Copyright 2007-2010 Johannes Berg <johannes@sipsolutions.net>
6 * Copyright 2013-2014 Intel Mobile Communications GmbH
7 * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
8 * Copyright (C) 2018 Intel Corporation
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
15 #include <linux/jiffies.h>
16 #include <linux/slab.h>
17 #include <linux/kernel.h>
18 #include <linux/skbuff.h>
19 #include <linux/netdevice.h>
20 #include <linux/etherdevice.h>
21 #include <linux/rcupdate.h>
22 #include <linux/export.h>
23 #include <linux/bitops.h>
24 #include <net/mac80211.h>
25 #include <net/ieee80211_radiotap.h>
26 #include <asm/unaligned.h>
28 #include "ieee80211_i.h"
29 #include "driver-ops.h"
38 static inline void ieee80211_rx_stats(struct net_device
*dev
, u32 len
)
40 struct pcpu_sw_netstats
*tstats
= this_cpu_ptr(dev
->tstats
);
42 u64_stats_update_begin(&tstats
->syncp
);
44 tstats
->rx_bytes
+= len
;
45 u64_stats_update_end(&tstats
->syncp
);
48 static u8
*ieee80211_get_bssid(struct ieee80211_hdr
*hdr
, size_t len
,
49 enum nl80211_iftype type
)
51 __le16 fc
= hdr
->frame_control
;
53 if (ieee80211_is_data(fc
)) {
54 if (len
< 24) /* drop incorrect hdr len (data) */
57 if (ieee80211_has_a4(fc
))
59 if (ieee80211_has_tods(fc
))
61 if (ieee80211_has_fromds(fc
))
67 if (ieee80211_is_mgmt(fc
)) {
68 if (len
< 24) /* drop incorrect hdr len (mgmt) */
73 if (ieee80211_is_ctl(fc
)) {
74 if (ieee80211_is_pspoll(fc
))
77 if (ieee80211_is_back_req(fc
)) {
79 case NL80211_IFTYPE_STATION
:
81 case NL80211_IFTYPE_AP
:
82 case NL80211_IFTYPE_AP_VLAN
:
85 break; /* fall through to the return */
94 * monitor mode reception
96 * This function cleans up the SKB, i.e. it removes all the stuff
97 * only useful for monitoring.
99 static void remove_monitor_info(struct sk_buff
*skb
,
100 unsigned int present_fcs_len
,
101 unsigned int rtap_space
)
104 __pskb_trim(skb
, skb
->len
- present_fcs_len
);
105 __pskb_pull(skb
, rtap_space
);
108 static inline bool should_drop_frame(struct sk_buff
*skb
, int present_fcs_len
,
109 unsigned int rtap_space
)
111 struct ieee80211_rx_status
*status
= IEEE80211_SKB_RXCB(skb
);
112 struct ieee80211_hdr
*hdr
;
114 hdr
= (void *)(skb
->data
+ rtap_space
);
116 if (status
->flag
& (RX_FLAG_FAILED_FCS_CRC
|
117 RX_FLAG_FAILED_PLCP_CRC
|
118 RX_FLAG_ONLY_MONITOR
|
122 if (unlikely(skb
->len
< 16 + present_fcs_len
+ rtap_space
))
125 if (ieee80211_is_ctl(hdr
->frame_control
) &&
126 !ieee80211_is_pspoll(hdr
->frame_control
) &&
127 !ieee80211_is_back_req(hdr
->frame_control
))
134 ieee80211_rx_radiotap_hdrlen(struct ieee80211_local
*local
,
135 struct ieee80211_rx_status
*status
,
140 /* always present fields */
141 len
= sizeof(struct ieee80211_radiotap_header
) + 8;
143 /* allocate extra bitmaps */
145 len
+= 4 * hweight8(status
->chains
);
146 /* vendor presence bitmap */
147 if (status
->flag
& RX_FLAG_RADIOTAP_VENDOR_DATA
)
150 if (ieee80211_have_rx_timestamp(status
)) {
154 if (ieee80211_hw_check(&local
->hw
, SIGNAL_DBM
))
157 /* antenna field, if we don't have per-chain info */
161 /* padding for RX_FLAGS if necessary */
164 if (status
->encoding
== RX_ENC_HT
) /* HT info */
167 if (status
->flag
& RX_FLAG_AMPDU_DETAILS
) {
172 if (status
->encoding
== RX_ENC_VHT
) {
177 if (local
->hw
.radiotap_timestamp
.units_pos
>= 0) {
182 if (status
->encoding
== RX_ENC_HE
&&
183 status
->flag
& RX_FLAG_RADIOTAP_HE
) {
186 BUILD_BUG_ON(sizeof(struct ieee80211_radiotap_he
) != 12);
189 if (status
->encoding
== RX_ENC_HE
&&
190 status
->flag
& RX_FLAG_RADIOTAP_HE_MU
) {
193 BUILD_BUG_ON(sizeof(struct ieee80211_radiotap_he_mu
) != 12);
196 if (status
->flag
& RX_FLAG_NO_PSDU
)
199 if (status
->flag
& RX_FLAG_RADIOTAP_LSIG
) {
202 BUILD_BUG_ON(sizeof(struct ieee80211_radiotap_lsig
) != 4);
205 if (status
->chains
) {
206 /* antenna and antenna signal fields */
207 len
+= 2 * hweight8(status
->chains
);
210 if (status
->flag
& RX_FLAG_RADIOTAP_VENDOR_DATA
) {
211 struct ieee80211_vendor_radiotap
*rtap
= (void *)skb
->data
;
213 /* alignment for fixed 6-byte vendor data header */
215 /* vendor data header */
217 if (WARN_ON(rtap
->align
== 0))
219 len
= ALIGN(len
, rtap
->align
);
220 len
+= rtap
->len
+ rtap
->pad
;
226 static void ieee80211_handle_mu_mimo_mon(struct ieee80211_sub_if_data
*sdata
,
231 struct ieee80211_hdr_3addr hdr
;
239 BUILD_BUG_ON(sizeof(action
) != IEEE80211_MIN_ACTION_SIZE
+ 1);
241 if (skb
->len
< rtap_space
+ sizeof(action
) +
242 VHT_MUMIMO_GROUPS_DATA_LEN
)
245 if (!is_valid_ether_addr(sdata
->u
.mntr
.mu_follow_addr
))
248 skb_copy_bits(skb
, rtap_space
, &action
, sizeof(action
));
250 if (!ieee80211_is_action(action
.hdr
.frame_control
))
253 if (action
.category
!= WLAN_CATEGORY_VHT
)
256 if (action
.action_code
!= WLAN_VHT_ACTION_GROUPID_MGMT
)
259 if (!ether_addr_equal(action
.hdr
.addr1
, sdata
->u
.mntr
.mu_follow_addr
))
262 skb
= skb_copy(skb
, GFP_ATOMIC
);
266 skb_queue_tail(&sdata
->skb_queue
, skb
);
267 ieee80211_queue_work(&sdata
->local
->hw
, &sdata
->work
);
271 * ieee80211_add_rx_radiotap_header - add radiotap header
273 * add a radiotap header containing all the fields which the hardware provided.
276 ieee80211_add_rx_radiotap_header(struct ieee80211_local
*local
,
278 struct ieee80211_rate
*rate
,
279 int rtap_len
, bool has_fcs
)
281 struct ieee80211_rx_status
*status
= IEEE80211_SKB_RXCB(skb
);
282 struct ieee80211_radiotap_header
*rthdr
;
287 u16 channel_flags
= 0;
289 unsigned long chains
= status
->chains
;
290 struct ieee80211_vendor_radiotap rtap
= {};
291 struct ieee80211_radiotap_he he
= {};
292 struct ieee80211_radiotap_he_mu he_mu
= {};
293 struct ieee80211_radiotap_lsig lsig
= {};
295 if (status
->flag
& RX_FLAG_RADIOTAP_HE
) {
296 he
= *(struct ieee80211_radiotap_he
*)skb
->data
;
297 skb_pull(skb
, sizeof(he
));
298 WARN_ON_ONCE(status
->encoding
!= RX_ENC_HE
);
301 if (status
->flag
& RX_FLAG_RADIOTAP_HE_MU
) {
302 he_mu
= *(struct ieee80211_radiotap_he_mu
*)skb
->data
;
303 skb_pull(skb
, sizeof(he_mu
));
306 if (status
->flag
& RX_FLAG_RADIOTAP_LSIG
) {
307 lsig
= *(struct ieee80211_radiotap_lsig
*)skb
->data
;
308 skb_pull(skb
, sizeof(lsig
));
311 if (status
->flag
& RX_FLAG_RADIOTAP_VENDOR_DATA
) {
312 rtap
= *(struct ieee80211_vendor_radiotap
*)skb
->data
;
313 /* rtap.len and rtap.pad are undone immediately */
314 skb_pull(skb
, sizeof(rtap
) + rtap
.len
+ rtap
.pad
);
318 if (!(has_fcs
&& ieee80211_hw_check(&local
->hw
, RX_INCLUDES_FCS
)))
321 rthdr
= skb_push(skb
, rtap_len
);
322 memset(rthdr
, 0, rtap_len
- rtap
.len
- rtap
.pad
);
323 it_present
= &rthdr
->it_present
;
325 /* radiotap header, set always present flags */
326 rthdr
->it_len
= cpu_to_le16(rtap_len
);
327 it_present_val
= BIT(IEEE80211_RADIOTAP_FLAGS
) |
328 BIT(IEEE80211_RADIOTAP_CHANNEL
) |
329 BIT(IEEE80211_RADIOTAP_RX_FLAGS
);
332 it_present_val
|= BIT(IEEE80211_RADIOTAP_ANTENNA
);
334 for_each_set_bit(chain
, &chains
, IEEE80211_MAX_CHAINS
) {
336 BIT(IEEE80211_RADIOTAP_EXT
) |
337 BIT(IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE
);
338 put_unaligned_le32(it_present_val
, it_present
);
340 it_present_val
= BIT(IEEE80211_RADIOTAP_ANTENNA
) |
341 BIT(IEEE80211_RADIOTAP_DBM_ANTSIGNAL
);
344 if (status
->flag
& RX_FLAG_RADIOTAP_VENDOR_DATA
) {
345 it_present_val
|= BIT(IEEE80211_RADIOTAP_VENDOR_NAMESPACE
) |
346 BIT(IEEE80211_RADIOTAP_EXT
);
347 put_unaligned_le32(it_present_val
, it_present
);
349 it_present_val
= rtap
.present
;
352 put_unaligned_le32(it_present_val
, it_present
);
354 pos
= (void *)(it_present
+ 1);
356 /* the order of the following fields is important */
358 /* IEEE80211_RADIOTAP_TSFT */
359 if (ieee80211_have_rx_timestamp(status
)) {
361 while ((pos
- (u8
*)rthdr
) & 7)
364 ieee80211_calculate_rx_timestamp(local
, status
,
367 rthdr
->it_present
|= cpu_to_le32(1 << IEEE80211_RADIOTAP_TSFT
);
371 /* IEEE80211_RADIOTAP_FLAGS */
372 if (has_fcs
&& ieee80211_hw_check(&local
->hw
, RX_INCLUDES_FCS
))
373 *pos
|= IEEE80211_RADIOTAP_F_FCS
;
374 if (status
->flag
& (RX_FLAG_FAILED_FCS_CRC
| RX_FLAG_FAILED_PLCP_CRC
))
375 *pos
|= IEEE80211_RADIOTAP_F_BADFCS
;
376 if (status
->enc_flags
& RX_ENC_FLAG_SHORTPRE
)
377 *pos
|= IEEE80211_RADIOTAP_F_SHORTPRE
;
380 /* IEEE80211_RADIOTAP_RATE */
381 if (!rate
|| status
->encoding
!= RX_ENC_LEGACY
) {
383 * Without rate information don't add it. If we have,
384 * MCS information is a separate field in radiotap,
385 * added below. The byte here is needed as padding
386 * for the channel though, so initialise it to 0.
391 rthdr
->it_present
|= cpu_to_le32(1 << IEEE80211_RADIOTAP_RATE
);
392 if (status
->bw
== RATE_INFO_BW_10
)
394 else if (status
->bw
== RATE_INFO_BW_5
)
396 *pos
= DIV_ROUND_UP(rate
->bitrate
, 5 * (1 << shift
));
400 /* IEEE80211_RADIOTAP_CHANNEL */
401 put_unaligned_le16(status
->freq
, pos
);
403 if (status
->bw
== RATE_INFO_BW_10
)
404 channel_flags
|= IEEE80211_CHAN_HALF
;
405 else if (status
->bw
== RATE_INFO_BW_5
)
406 channel_flags
|= IEEE80211_CHAN_QUARTER
;
408 if (status
->band
== NL80211_BAND_5GHZ
)
409 channel_flags
|= IEEE80211_CHAN_OFDM
| IEEE80211_CHAN_5GHZ
;
410 else if (status
->encoding
!= RX_ENC_LEGACY
)
411 channel_flags
|= IEEE80211_CHAN_DYN
| IEEE80211_CHAN_2GHZ
;
412 else if (rate
&& rate
->flags
& IEEE80211_RATE_ERP_G
)
413 channel_flags
|= IEEE80211_CHAN_OFDM
| IEEE80211_CHAN_2GHZ
;
415 channel_flags
|= IEEE80211_CHAN_CCK
| IEEE80211_CHAN_2GHZ
;
417 channel_flags
|= IEEE80211_CHAN_2GHZ
;
418 put_unaligned_le16(channel_flags
, pos
);
421 /* IEEE80211_RADIOTAP_DBM_ANTSIGNAL */
422 if (ieee80211_hw_check(&local
->hw
, SIGNAL_DBM
) &&
423 !(status
->flag
& RX_FLAG_NO_SIGNAL_VAL
)) {
424 *pos
= status
->signal
;
426 cpu_to_le32(1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL
);
430 /* IEEE80211_RADIOTAP_LOCK_QUALITY is missing */
432 if (!status
->chains
) {
433 /* IEEE80211_RADIOTAP_ANTENNA */
434 *pos
= status
->antenna
;
438 /* IEEE80211_RADIOTAP_DB_ANTNOISE is not used */
440 /* IEEE80211_RADIOTAP_RX_FLAGS */
441 /* ensure 2 byte alignment for the 2 byte field as required */
442 if ((pos
- (u8
*)rthdr
) & 1)
444 if (status
->flag
& RX_FLAG_FAILED_PLCP_CRC
)
445 rx_flags
|= IEEE80211_RADIOTAP_F_RX_BADPLCP
;
446 put_unaligned_le16(rx_flags
, pos
);
449 if (status
->encoding
== RX_ENC_HT
) {
452 rthdr
->it_present
|= cpu_to_le32(1 << IEEE80211_RADIOTAP_MCS
);
453 *pos
++ = local
->hw
.radiotap_mcs_details
;
455 if (status
->enc_flags
& RX_ENC_FLAG_SHORT_GI
)
456 *pos
|= IEEE80211_RADIOTAP_MCS_SGI
;
457 if (status
->bw
== RATE_INFO_BW_40
)
458 *pos
|= IEEE80211_RADIOTAP_MCS_BW_40
;
459 if (status
->enc_flags
& RX_ENC_FLAG_HT_GF
)
460 *pos
|= IEEE80211_RADIOTAP_MCS_FMT_GF
;
461 if (status
->enc_flags
& RX_ENC_FLAG_LDPC
)
462 *pos
|= IEEE80211_RADIOTAP_MCS_FEC_LDPC
;
463 stbc
= (status
->enc_flags
& RX_ENC_FLAG_STBC_MASK
) >> RX_ENC_FLAG_STBC_SHIFT
;
464 *pos
|= stbc
<< IEEE80211_RADIOTAP_MCS_STBC_SHIFT
;
466 *pos
++ = status
->rate_idx
;
469 if (status
->flag
& RX_FLAG_AMPDU_DETAILS
) {
472 /* ensure 4 byte alignment */
473 while ((pos
- (u8
*)rthdr
) & 3)
476 cpu_to_le32(1 << IEEE80211_RADIOTAP_AMPDU_STATUS
);
477 put_unaligned_le32(status
->ampdu_reference
, pos
);
479 if (status
->flag
& RX_FLAG_AMPDU_LAST_KNOWN
)
480 flags
|= IEEE80211_RADIOTAP_AMPDU_LAST_KNOWN
;
481 if (status
->flag
& RX_FLAG_AMPDU_IS_LAST
)
482 flags
|= IEEE80211_RADIOTAP_AMPDU_IS_LAST
;
483 if (status
->flag
& RX_FLAG_AMPDU_DELIM_CRC_ERROR
)
484 flags
|= IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_ERR
;
485 if (status
->flag
& RX_FLAG_AMPDU_DELIM_CRC_KNOWN
)
486 flags
|= IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_KNOWN
;
487 if (status
->flag
& RX_FLAG_AMPDU_EOF_BIT_KNOWN
)
488 flags
|= IEEE80211_RADIOTAP_AMPDU_EOF_KNOWN
;
489 if (status
->flag
& RX_FLAG_AMPDU_EOF_BIT
)
490 flags
|= IEEE80211_RADIOTAP_AMPDU_EOF
;
491 put_unaligned_le16(flags
, pos
);
493 if (status
->flag
& RX_FLAG_AMPDU_DELIM_CRC_KNOWN
)
494 *pos
++ = status
->ampdu_delimiter_crc
;
500 if (status
->encoding
== RX_ENC_VHT
) {
501 u16 known
= local
->hw
.radiotap_vht_details
;
503 rthdr
->it_present
|= cpu_to_le32(1 << IEEE80211_RADIOTAP_VHT
);
504 put_unaligned_le16(known
, pos
);
507 if (status
->enc_flags
& RX_ENC_FLAG_SHORT_GI
)
508 *pos
|= IEEE80211_RADIOTAP_VHT_FLAG_SGI
;
509 /* in VHT, STBC is binary */
510 if (status
->enc_flags
& RX_ENC_FLAG_STBC_MASK
)
511 *pos
|= IEEE80211_RADIOTAP_VHT_FLAG_STBC
;
512 if (status
->enc_flags
& RX_ENC_FLAG_BF
)
513 *pos
|= IEEE80211_RADIOTAP_VHT_FLAG_BEAMFORMED
;
516 switch (status
->bw
) {
517 case RATE_INFO_BW_80
:
520 case RATE_INFO_BW_160
:
523 case RATE_INFO_BW_40
:
530 *pos
= (status
->rate_idx
<< 4) | status
->nss
;
533 if (status
->enc_flags
& RX_ENC_FLAG_LDPC
)
534 *pos
|= IEEE80211_RADIOTAP_CODING_LDPC_USER0
;
542 if (local
->hw
.radiotap_timestamp
.units_pos
>= 0) {
544 u8 flags
= IEEE80211_RADIOTAP_TIMESTAMP_FLAG_32BIT
;
547 cpu_to_le32(1 << IEEE80211_RADIOTAP_TIMESTAMP
);
549 /* ensure 8 byte alignment */
550 while ((pos
- (u8
*)rthdr
) & 7)
553 put_unaligned_le64(status
->device_timestamp
, pos
);
556 if (local
->hw
.radiotap_timestamp
.accuracy
>= 0) {
557 accuracy
= local
->hw
.radiotap_timestamp
.accuracy
;
558 flags
|= IEEE80211_RADIOTAP_TIMESTAMP_FLAG_ACCURACY
;
560 put_unaligned_le16(accuracy
, pos
);
563 *pos
++ = local
->hw
.radiotap_timestamp
.units_pos
;
567 if (status
->encoding
== RX_ENC_HE
&&
568 status
->flag
& RX_FLAG_RADIOTAP_HE
) {
569 #define HE_PREP(f, val) le16_encode_bits(val, IEEE80211_RADIOTAP_HE_##f)
571 if (status
->enc_flags
& RX_ENC_FLAG_STBC_MASK
) {
572 he
.data6
|= HE_PREP(DATA6_NSTS
,
573 FIELD_GET(RX_ENC_FLAG_STBC_MASK
,
575 he
.data3
|= HE_PREP(DATA3_STBC
, 1);
577 he
.data6
|= HE_PREP(DATA6_NSTS
, status
->nss
);
580 #define CHECK_GI(s) \
581 BUILD_BUG_ON(IEEE80211_RADIOTAP_HE_DATA5_GI_##s != \
582 (int)NL80211_RATE_INFO_HE_GI_##s)
588 he
.data3
|= HE_PREP(DATA3_DATA_MCS
, status
->rate_idx
);
589 he
.data3
|= HE_PREP(DATA3_DATA_DCM
, status
->he_dcm
);
590 he
.data3
|= HE_PREP(DATA3_CODING
,
591 !!(status
->enc_flags
& RX_ENC_FLAG_LDPC
));
593 he
.data5
|= HE_PREP(DATA5_GI
, status
->he_gi
);
595 switch (status
->bw
) {
596 case RATE_INFO_BW_20
:
597 he
.data5
|= HE_PREP(DATA5_DATA_BW_RU_ALLOC
,
598 IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_20MHZ
);
600 case RATE_INFO_BW_40
:
601 he
.data5
|= HE_PREP(DATA5_DATA_BW_RU_ALLOC
,
602 IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_40MHZ
);
604 case RATE_INFO_BW_80
:
605 he
.data5
|= HE_PREP(DATA5_DATA_BW_RU_ALLOC
,
606 IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_80MHZ
);
608 case RATE_INFO_BW_160
:
609 he
.data5
|= HE_PREP(DATA5_DATA_BW_RU_ALLOC
,
610 IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_160MHZ
);
612 case RATE_INFO_BW_HE_RU
:
613 #define CHECK_RU_ALLOC(s) \
614 BUILD_BUG_ON(IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_##s##T != \
615 NL80211_RATE_INFO_HE_RU_ALLOC_##s + 4)
623 CHECK_RU_ALLOC(2x996
);
625 he
.data5
|= HE_PREP(DATA5_DATA_BW_RU_ALLOC
,
629 WARN_ONCE(1, "Invalid SU BW %d\n", status
->bw
);
632 /* ensure 2 byte alignment */
633 while ((pos
- (u8
*)rthdr
) & 1)
635 rthdr
->it_present
|= cpu_to_le32(1 << IEEE80211_RADIOTAP_HE
);
636 memcpy(pos
, &he
, sizeof(he
));
640 if (status
->encoding
== RX_ENC_HE
&&
641 status
->flag
& RX_FLAG_RADIOTAP_HE_MU
) {
642 /* ensure 2 byte alignment */
643 while ((pos
- (u8
*)rthdr
) & 1)
645 rthdr
->it_present
|= cpu_to_le32(1 << IEEE80211_RADIOTAP_HE_MU
);
646 memcpy(pos
, &he_mu
, sizeof(he_mu
));
647 pos
+= sizeof(he_mu
);
650 if (status
->flag
& RX_FLAG_NO_PSDU
) {
652 cpu_to_le32(1 << IEEE80211_RADIOTAP_ZERO_LEN_PSDU
);
653 *pos
++ = status
->zero_length_psdu_type
;
656 if (status
->flag
& RX_FLAG_RADIOTAP_LSIG
) {
657 /* ensure 2 byte alignment */
658 while ((pos
- (u8
*)rthdr
) & 1)
660 rthdr
->it_present
|= cpu_to_le32(1 << IEEE80211_RADIOTAP_LSIG
);
661 memcpy(pos
, &lsig
, sizeof(lsig
));
665 for_each_set_bit(chain
, &chains
, IEEE80211_MAX_CHAINS
) {
666 *pos
++ = status
->chain_signal
[chain
];
670 if (status
->flag
& RX_FLAG_RADIOTAP_VENDOR_DATA
) {
671 /* ensure 2 byte alignment for the vendor field as required */
672 if ((pos
- (u8
*)rthdr
) & 1)
674 *pos
++ = rtap
.oui
[0];
675 *pos
++ = rtap
.oui
[1];
676 *pos
++ = rtap
.oui
[2];
678 put_unaligned_le16(rtap
.len
, pos
);
680 /* align the actual payload as requested */
681 while ((pos
- (u8
*)rthdr
) & (rtap
.align
- 1))
683 /* data (and possible padding) already follows */
687 static struct sk_buff
*
688 ieee80211_make_monitor_skb(struct ieee80211_local
*local
,
689 struct sk_buff
**origskb
,
690 struct ieee80211_rate
*rate
,
691 int rtap_space
, bool use_origskb
)
693 struct ieee80211_rx_status
*status
= IEEE80211_SKB_RXCB(*origskb
);
694 int rt_hdrlen
, needed_headroom
;
697 /* room for the radiotap header based on driver features */
698 rt_hdrlen
= ieee80211_rx_radiotap_hdrlen(local
, status
, *origskb
);
699 needed_headroom
= rt_hdrlen
- rtap_space
;
702 /* only need to expand headroom if necessary */
707 * This shouldn't trigger often because most devices have an
708 * RX header they pull before we get here, and that should
709 * be big enough for our radiotap information. We should
710 * probably export the length to drivers so that we can have
711 * them allocate enough headroom to start with.
713 if (skb_headroom(skb
) < needed_headroom
&&
714 pskb_expand_head(skb
, needed_headroom
, 0, GFP_ATOMIC
)) {
720 * Need to make a copy and possibly remove radiotap header
721 * and FCS from the original.
723 skb
= skb_copy_expand(*origskb
, needed_headroom
, 0, GFP_ATOMIC
);
729 /* prepend radiotap information */
730 ieee80211_add_rx_radiotap_header(local
, skb
, rate
, rt_hdrlen
, true);
732 skb_reset_mac_header(skb
);
733 skb
->ip_summed
= CHECKSUM_UNNECESSARY
;
734 skb
->pkt_type
= PACKET_OTHERHOST
;
735 skb
->protocol
= htons(ETH_P_802_2
);
741 * This function copies a received frame to all monitor interfaces and
742 * returns a cleaned-up SKB that no longer includes the FCS nor the
743 * radiotap header the driver might have added.
745 static struct sk_buff
*
746 ieee80211_rx_monitor(struct ieee80211_local
*local
, struct sk_buff
*origskb
,
747 struct ieee80211_rate
*rate
)
749 struct ieee80211_rx_status
*status
= IEEE80211_SKB_RXCB(origskb
);
750 struct ieee80211_sub_if_data
*sdata
;
751 struct sk_buff
*monskb
= NULL
;
752 int present_fcs_len
= 0;
753 unsigned int rtap_space
= 0;
754 struct ieee80211_sub_if_data
*monitor_sdata
=
755 rcu_dereference(local
->monitor_sdata
);
756 bool only_monitor
= false;
757 unsigned int min_head_len
;
759 if (status
->flag
& RX_FLAG_RADIOTAP_HE
)
760 rtap_space
+= sizeof(struct ieee80211_radiotap_he
);
762 if (status
->flag
& RX_FLAG_RADIOTAP_HE_MU
)
763 rtap_space
+= sizeof(struct ieee80211_radiotap_he_mu
);
765 if (status
->flag
& RX_FLAG_RADIOTAP_LSIG
)
766 rtap_space
+= sizeof(struct ieee80211_radiotap_lsig
);
768 if (unlikely(status
->flag
& RX_FLAG_RADIOTAP_VENDOR_DATA
)) {
769 struct ieee80211_vendor_radiotap
*rtap
=
770 (void *)(origskb
->data
+ rtap_space
);
772 rtap_space
+= sizeof(*rtap
) + rtap
->len
+ rtap
->pad
;
775 min_head_len
= rtap_space
;
778 * First, we may need to make a copy of the skb because
779 * (1) we need to modify it for radiotap (if not present), and
780 * (2) the other RX handlers will modify the skb we got.
782 * We don't need to, of course, if we aren't going to return
783 * the SKB because it has a bad FCS/PLCP checksum.
786 if (!(status
->flag
& RX_FLAG_NO_PSDU
)) {
787 if (ieee80211_hw_check(&local
->hw
, RX_INCLUDES_FCS
)) {
788 if (unlikely(origskb
->len
<= FCS_LEN
+ rtap_space
)) {
791 dev_kfree_skb(origskb
);
794 present_fcs_len
= FCS_LEN
;
797 /* also consider the hdr->frame_control */
801 /* ensure that the expected data elements are in skb head */
802 if (!pskb_may_pull(origskb
, min_head_len
)) {
803 dev_kfree_skb(origskb
);
807 only_monitor
= should_drop_frame(origskb
, present_fcs_len
, rtap_space
);
809 if (!local
->monitors
|| (status
->flag
& RX_FLAG_SKIP_MONITOR
)) {
811 dev_kfree_skb(origskb
);
815 remove_monitor_info(origskb
, present_fcs_len
, rtap_space
);
819 ieee80211_handle_mu_mimo_mon(monitor_sdata
, origskb
, rtap_space
);
821 list_for_each_entry_rcu(sdata
, &local
->mon_list
, u
.mntr
.list
) {
822 bool last_monitor
= list_is_last(&sdata
->u
.mntr
.list
,
826 monskb
= ieee80211_make_monitor_skb(local
, &origskb
,
838 skb
= skb_clone(monskb
, GFP_ATOMIC
);
842 skb
->dev
= sdata
->dev
;
843 ieee80211_rx_stats(skb
->dev
, skb
->len
);
844 netif_receive_skb(skb
);
852 /* this happens if last_monitor was erroneously false */
853 dev_kfree_skb(monskb
);
859 remove_monitor_info(origskb
, present_fcs_len
, rtap_space
);
863 static void ieee80211_parse_qos(struct ieee80211_rx_data
*rx
)
865 struct ieee80211_hdr
*hdr
= (struct ieee80211_hdr
*)rx
->skb
->data
;
866 struct ieee80211_rx_status
*status
= IEEE80211_SKB_RXCB(rx
->skb
);
867 int tid
, seqno_idx
, security_idx
;
869 /* does the frame have a qos control field? */
870 if (ieee80211_is_data_qos(hdr
->frame_control
)) {
871 u8
*qc
= ieee80211_get_qos_ctl(hdr
);
872 /* frame has qos control */
873 tid
= *qc
& IEEE80211_QOS_CTL_TID_MASK
;
874 if (*qc
& IEEE80211_QOS_CTL_A_MSDU_PRESENT
)
875 status
->rx_flags
|= IEEE80211_RX_AMSDU
;
881 * IEEE 802.11-2007, 7.1.3.4.1 ("Sequence Number field"):
883 * Sequence numbers for management frames, QoS data
884 * frames with a broadcast/multicast address in the
885 * Address 1 field, and all non-QoS data frames sent
886 * by QoS STAs are assigned using an additional single
887 * modulo-4096 counter, [...]
889 * We also use that counter for non-QoS STAs.
891 seqno_idx
= IEEE80211_NUM_TIDS
;
893 if (ieee80211_is_mgmt(hdr
->frame_control
))
894 security_idx
= IEEE80211_NUM_TIDS
;
898 rx
->seqno_idx
= seqno_idx
;
899 rx
->security_idx
= security_idx
;
900 /* Set skb->priority to 1d tag if highest order bit of TID is not set.
901 * For now, set skb->priority to 0 for other cases. */
902 rx
->skb
->priority
= (tid
> 7) ? 0 : tid
;
906 * DOC: Packet alignment
908 * Drivers always need to pass packets that are aligned to two-byte boundaries
911 * Additionally, should, if possible, align the payload data in a way that
912 * guarantees that the contained IP header is aligned to a four-byte
913 * boundary. In the case of regular frames, this simply means aligning the
914 * payload to a four-byte boundary (because either the IP header is directly
915 * contained, or IV/RFC1042 headers that have a length divisible by four are
916 * in front of it). If the payload data is not properly aligned and the
917 * architecture doesn't support efficient unaligned operations, mac80211
918 * will align the data.
920 * With A-MSDU frames, however, the payload data address must yield two modulo
921 * four because there are 14-byte 802.3 headers within the A-MSDU frames that
922 * push the IP header further back to a multiple of four again. Thankfully, the
923 * specs were sane enough this time around to require padding each A-MSDU
924 * subframe to a length that is a multiple of four.
926 * Padding like Atheros hardware adds which is between the 802.11 header and
927 * the payload is not supported, the driver is required to move the 802.11
928 * header to be directly in front of the payload in that case.
930 static void ieee80211_verify_alignment(struct ieee80211_rx_data
*rx
)
932 #ifdef CONFIG_MAC80211_VERBOSE_DEBUG
933 WARN_ON_ONCE((unsigned long)rx
->skb
->data
& 1);
940 static int ieee80211_is_unicast_robust_mgmt_frame(struct sk_buff
*skb
)
942 struct ieee80211_hdr
*hdr
= (struct ieee80211_hdr
*) skb
->data
;
944 if (is_multicast_ether_addr(hdr
->addr1
))
947 return ieee80211_is_robust_mgmt_frame(skb
);
951 static int ieee80211_is_multicast_robust_mgmt_frame(struct sk_buff
*skb
)
953 struct ieee80211_hdr
*hdr
= (struct ieee80211_hdr
*) skb
->data
;
955 if (!is_multicast_ether_addr(hdr
->addr1
))
958 return ieee80211_is_robust_mgmt_frame(skb
);
962 /* Get the BIP key index from MMIE; return -1 if this is not a BIP frame */
963 static int ieee80211_get_mmie_keyidx(struct sk_buff
*skb
)
965 struct ieee80211_mgmt
*hdr
= (struct ieee80211_mgmt
*) skb
->data
;
966 struct ieee80211_mmie
*mmie
;
967 struct ieee80211_mmie_16
*mmie16
;
969 if (skb
->len
< 24 + sizeof(*mmie
) || !is_multicast_ether_addr(hdr
->da
))
972 if (!ieee80211_is_robust_mgmt_frame(skb
))
973 return -1; /* not a robust management frame */
975 mmie
= (struct ieee80211_mmie
*)
976 (skb
->data
+ skb
->len
- sizeof(*mmie
));
977 if (mmie
->element_id
== WLAN_EID_MMIE
&&
978 mmie
->length
== sizeof(*mmie
) - 2)
979 return le16_to_cpu(mmie
->key_id
);
981 mmie16
= (struct ieee80211_mmie_16
*)
982 (skb
->data
+ skb
->len
- sizeof(*mmie16
));
983 if (skb
->len
>= 24 + sizeof(*mmie16
) &&
984 mmie16
->element_id
== WLAN_EID_MMIE
&&
985 mmie16
->length
== sizeof(*mmie16
) - 2)
986 return le16_to_cpu(mmie16
->key_id
);
991 static int ieee80211_get_cs_keyid(const struct ieee80211_cipher_scheme
*cs
,
994 struct ieee80211_hdr
*hdr
= (struct ieee80211_hdr
*)skb
->data
;
999 fc
= hdr
->frame_control
;
1000 hdrlen
= ieee80211_hdrlen(fc
);
1002 if (skb
->len
< hdrlen
+ cs
->hdr_len
)
1005 skb_copy_bits(skb
, hdrlen
+ cs
->key_idx_off
, &keyid
, 1);
1006 keyid
&= cs
->key_idx_mask
;
1007 keyid
>>= cs
->key_idx_shift
;
1012 static ieee80211_rx_result
ieee80211_rx_mesh_check(struct ieee80211_rx_data
*rx
)
1014 struct ieee80211_hdr
*hdr
= (struct ieee80211_hdr
*)rx
->skb
->data
;
1015 char *dev_addr
= rx
->sdata
->vif
.addr
;
1017 if (ieee80211_is_data(hdr
->frame_control
)) {
1018 if (is_multicast_ether_addr(hdr
->addr1
)) {
1019 if (ieee80211_has_tods(hdr
->frame_control
) ||
1020 !ieee80211_has_fromds(hdr
->frame_control
))
1021 return RX_DROP_MONITOR
;
1022 if (ether_addr_equal(hdr
->addr3
, dev_addr
))
1023 return RX_DROP_MONITOR
;
1025 if (!ieee80211_has_a4(hdr
->frame_control
))
1026 return RX_DROP_MONITOR
;
1027 if (ether_addr_equal(hdr
->addr4
, dev_addr
))
1028 return RX_DROP_MONITOR
;
1032 /* If there is not an established peer link and this is not a peer link
1033 * establisment frame, beacon or probe, drop the frame.
1036 if (!rx
->sta
|| sta_plink_state(rx
->sta
) != NL80211_PLINK_ESTAB
) {
1037 struct ieee80211_mgmt
*mgmt
;
1039 if (!ieee80211_is_mgmt(hdr
->frame_control
))
1040 return RX_DROP_MONITOR
;
1042 if (ieee80211_is_action(hdr
->frame_control
)) {
1045 /* make sure category field is present */
1046 if (rx
->skb
->len
< IEEE80211_MIN_ACTION_SIZE
)
1047 return RX_DROP_MONITOR
;
1049 mgmt
= (struct ieee80211_mgmt
*)hdr
;
1050 category
= mgmt
->u
.action
.category
;
1051 if (category
!= WLAN_CATEGORY_MESH_ACTION
&&
1052 category
!= WLAN_CATEGORY_SELF_PROTECTED
)
1053 return RX_DROP_MONITOR
;
1057 if (ieee80211_is_probe_req(hdr
->frame_control
) ||
1058 ieee80211_is_probe_resp(hdr
->frame_control
) ||
1059 ieee80211_is_beacon(hdr
->frame_control
) ||
1060 ieee80211_is_auth(hdr
->frame_control
))
1063 return RX_DROP_MONITOR
;
1069 static inline bool ieee80211_rx_reorder_ready(struct tid_ampdu_rx
*tid_agg_rx
,
1072 struct sk_buff_head
*frames
= &tid_agg_rx
->reorder_buf
[index
];
1073 struct sk_buff
*tail
= skb_peek_tail(frames
);
1074 struct ieee80211_rx_status
*status
;
1076 if (tid_agg_rx
->reorder_buf_filtered
& BIT_ULL(index
))
1082 status
= IEEE80211_SKB_RXCB(tail
);
1083 if (status
->flag
& RX_FLAG_AMSDU_MORE
)
1089 static void ieee80211_release_reorder_frame(struct ieee80211_sub_if_data
*sdata
,
1090 struct tid_ampdu_rx
*tid_agg_rx
,
1092 struct sk_buff_head
*frames
)
1094 struct sk_buff_head
*skb_list
= &tid_agg_rx
->reorder_buf
[index
];
1095 struct sk_buff
*skb
;
1096 struct ieee80211_rx_status
*status
;
1098 lockdep_assert_held(&tid_agg_rx
->reorder_lock
);
1100 if (skb_queue_empty(skb_list
))
1103 if (!ieee80211_rx_reorder_ready(tid_agg_rx
, index
)) {
1104 __skb_queue_purge(skb_list
);
1108 /* release frames from the reorder ring buffer */
1109 tid_agg_rx
->stored_mpdu_num
--;
1110 while ((skb
= __skb_dequeue(skb_list
))) {
1111 status
= IEEE80211_SKB_RXCB(skb
);
1112 status
->rx_flags
|= IEEE80211_RX_DEFERRED_RELEASE
;
1113 __skb_queue_tail(frames
, skb
);
1117 tid_agg_rx
->reorder_buf_filtered
&= ~BIT_ULL(index
);
1118 tid_agg_rx
->head_seq_num
= ieee80211_sn_inc(tid_agg_rx
->head_seq_num
);
1121 static void ieee80211_release_reorder_frames(struct ieee80211_sub_if_data
*sdata
,
1122 struct tid_ampdu_rx
*tid_agg_rx
,
1124 struct sk_buff_head
*frames
)
1128 lockdep_assert_held(&tid_agg_rx
->reorder_lock
);
1130 while (ieee80211_sn_less(tid_agg_rx
->head_seq_num
, head_seq_num
)) {
1131 index
= tid_agg_rx
->head_seq_num
% tid_agg_rx
->buf_size
;
1132 ieee80211_release_reorder_frame(sdata
, tid_agg_rx
, index
,
1138 * Timeout (in jiffies) for skb's that are waiting in the RX reorder buffer. If
1139 * the skb was added to the buffer longer than this time ago, the earlier
1140 * frames that have not yet been received are assumed to be lost and the skb
1141 * can be released for processing. This may also release other skb's from the
1142 * reorder buffer if there are no additional gaps between the frames.
1144 * Callers must hold tid_agg_rx->reorder_lock.
1146 #define HT_RX_REORDER_BUF_TIMEOUT (HZ / 10)
1148 static void ieee80211_sta_reorder_release(struct ieee80211_sub_if_data
*sdata
,
1149 struct tid_ampdu_rx
*tid_agg_rx
,
1150 struct sk_buff_head
*frames
)
1154 lockdep_assert_held(&tid_agg_rx
->reorder_lock
);
1156 /* release the buffer until next missing frame */
1157 index
= tid_agg_rx
->head_seq_num
% tid_agg_rx
->buf_size
;
1158 if (!ieee80211_rx_reorder_ready(tid_agg_rx
, index
) &&
1159 tid_agg_rx
->stored_mpdu_num
) {
1161 * No buffers ready to be released, but check whether any
1162 * frames in the reorder buffer have timed out.
1165 for (j
= (index
+ 1) % tid_agg_rx
->buf_size
; j
!= index
;
1166 j
= (j
+ 1) % tid_agg_rx
->buf_size
) {
1167 if (!ieee80211_rx_reorder_ready(tid_agg_rx
, j
)) {
1172 !time_after(jiffies
, tid_agg_rx
->reorder_time
[j
] +
1173 HT_RX_REORDER_BUF_TIMEOUT
))
1174 goto set_release_timer
;
1176 /* don't leave incomplete A-MSDUs around */
1177 for (i
= (index
+ 1) % tid_agg_rx
->buf_size
; i
!= j
;
1178 i
= (i
+ 1) % tid_agg_rx
->buf_size
)
1179 __skb_queue_purge(&tid_agg_rx
->reorder_buf
[i
]);
1181 ht_dbg_ratelimited(sdata
,
1182 "release an RX reorder frame due to timeout on earlier frames\n");
1183 ieee80211_release_reorder_frame(sdata
, tid_agg_rx
, j
,
1187 * Increment the head seq# also for the skipped slots.
1189 tid_agg_rx
->head_seq_num
=
1190 (tid_agg_rx
->head_seq_num
+
1191 skipped
) & IEEE80211_SN_MASK
;
1194 } else while (ieee80211_rx_reorder_ready(tid_agg_rx
, index
)) {
1195 ieee80211_release_reorder_frame(sdata
, tid_agg_rx
, index
,
1197 index
= tid_agg_rx
->head_seq_num
% tid_agg_rx
->buf_size
;
1200 if (tid_agg_rx
->stored_mpdu_num
) {
1201 j
= index
= tid_agg_rx
->head_seq_num
% tid_agg_rx
->buf_size
;
1203 for (; j
!= (index
- 1) % tid_agg_rx
->buf_size
;
1204 j
= (j
+ 1) % tid_agg_rx
->buf_size
) {
1205 if (ieee80211_rx_reorder_ready(tid_agg_rx
, j
))
1211 if (!tid_agg_rx
->removed
)
1212 mod_timer(&tid_agg_rx
->reorder_timer
,
1213 tid_agg_rx
->reorder_time
[j
] + 1 +
1214 HT_RX_REORDER_BUF_TIMEOUT
);
1216 del_timer(&tid_agg_rx
->reorder_timer
);
1221 * As this function belongs to the RX path it must be under
1222 * rcu_read_lock protection. It returns false if the frame
1223 * can be processed immediately, true if it was consumed.
1225 static bool ieee80211_sta_manage_reorder_buf(struct ieee80211_sub_if_data
*sdata
,
1226 struct tid_ampdu_rx
*tid_agg_rx
,
1227 struct sk_buff
*skb
,
1228 struct sk_buff_head
*frames
)
1230 struct ieee80211_hdr
*hdr
= (struct ieee80211_hdr
*) skb
->data
;
1231 struct ieee80211_rx_status
*status
= IEEE80211_SKB_RXCB(skb
);
1232 u16 sc
= le16_to_cpu(hdr
->seq_ctrl
);
1233 u16 mpdu_seq_num
= (sc
& IEEE80211_SCTL_SEQ
) >> 4;
1234 u16 head_seq_num
, buf_size
;
1238 spin_lock(&tid_agg_rx
->reorder_lock
);
1241 * Offloaded BA sessions have no known starting sequence number so pick
1242 * one from first Rxed frame for this tid after BA was started.
1244 if (unlikely(tid_agg_rx
->auto_seq
)) {
1245 tid_agg_rx
->auto_seq
= false;
1246 tid_agg_rx
->ssn
= mpdu_seq_num
;
1247 tid_agg_rx
->head_seq_num
= mpdu_seq_num
;
1250 buf_size
= tid_agg_rx
->buf_size
;
1251 head_seq_num
= tid_agg_rx
->head_seq_num
;
1254 * If the current MPDU's SN is smaller than the SSN, it shouldn't
1257 if (unlikely(!tid_agg_rx
->started
)) {
1258 if (ieee80211_sn_less(mpdu_seq_num
, head_seq_num
)) {
1262 tid_agg_rx
->started
= true;
1265 /* frame with out of date sequence number */
1266 if (ieee80211_sn_less(mpdu_seq_num
, head_seq_num
)) {
1272 * If frame the sequence number exceeds our buffering window
1273 * size release some previous frames to make room for this one.
1275 if (!ieee80211_sn_less(mpdu_seq_num
, head_seq_num
+ buf_size
)) {
1276 head_seq_num
= ieee80211_sn_inc(
1277 ieee80211_sn_sub(mpdu_seq_num
, buf_size
));
1278 /* release stored frames up to new head to stack */
1279 ieee80211_release_reorder_frames(sdata
, tid_agg_rx
,
1280 head_seq_num
, frames
);
1283 /* Now the new frame is always in the range of the reordering buffer */
1285 index
= mpdu_seq_num
% tid_agg_rx
->buf_size
;
1287 /* check if we already stored this frame */
1288 if (ieee80211_rx_reorder_ready(tid_agg_rx
, index
)) {
1294 * If the current MPDU is in the right order and nothing else
1295 * is stored we can process it directly, no need to buffer it.
1296 * If it is first but there's something stored, we may be able
1297 * to release frames after this one.
1299 if (mpdu_seq_num
== tid_agg_rx
->head_seq_num
&&
1300 tid_agg_rx
->stored_mpdu_num
== 0) {
1301 if (!(status
->flag
& RX_FLAG_AMSDU_MORE
))
1302 tid_agg_rx
->head_seq_num
=
1303 ieee80211_sn_inc(tid_agg_rx
->head_seq_num
);
1308 /* put the frame in the reordering buffer */
1309 __skb_queue_tail(&tid_agg_rx
->reorder_buf
[index
], skb
);
1310 if (!(status
->flag
& RX_FLAG_AMSDU_MORE
)) {
1311 tid_agg_rx
->reorder_time
[index
] = jiffies
;
1312 tid_agg_rx
->stored_mpdu_num
++;
1313 ieee80211_sta_reorder_release(sdata
, tid_agg_rx
, frames
);
1317 spin_unlock(&tid_agg_rx
->reorder_lock
);
1322 * Reorder MPDUs from A-MPDUs, keeping them on a buffer. Returns
1323 * true if the MPDU was buffered, false if it should be processed.
1325 static void ieee80211_rx_reorder_ampdu(struct ieee80211_rx_data
*rx
,
1326 struct sk_buff_head
*frames
)
1328 struct sk_buff
*skb
= rx
->skb
;
1329 struct ieee80211_local
*local
= rx
->local
;
1330 struct ieee80211_hdr
*hdr
= (struct ieee80211_hdr
*) skb
->data
;
1331 struct sta_info
*sta
= rx
->sta
;
1332 struct tid_ampdu_rx
*tid_agg_rx
;
1336 if (!ieee80211_is_data_qos(hdr
->frame_control
) ||
1337 is_multicast_ether_addr(hdr
->addr1
))
1341 * filter the QoS data rx stream according to
1342 * STA/TID and check if this STA/TID is on aggregation
1348 ack_policy
= *ieee80211_get_qos_ctl(hdr
) &
1349 IEEE80211_QOS_CTL_ACK_POLICY_MASK
;
1350 tid
= ieee80211_get_tid(hdr
);
1352 tid_agg_rx
= rcu_dereference(sta
->ampdu_mlme
.tid_rx
[tid
]);
1354 if (ack_policy
== IEEE80211_QOS_CTL_ACK_POLICY_BLOCKACK
&&
1355 !test_bit(tid
, rx
->sta
->ampdu_mlme
.agg_session_valid
) &&
1356 !test_and_set_bit(tid
, rx
->sta
->ampdu_mlme
.unexpected_agg
))
1357 ieee80211_send_delba(rx
->sdata
, rx
->sta
->sta
.addr
, tid
,
1358 WLAN_BACK_RECIPIENT
,
1359 WLAN_REASON_QSTA_REQUIRE_SETUP
);
1363 /* qos null data frames are excluded */
1364 if (unlikely(hdr
->frame_control
& cpu_to_le16(IEEE80211_STYPE_NULLFUNC
)))
1367 /* not part of a BA session */
1368 if (ack_policy
!= IEEE80211_QOS_CTL_ACK_POLICY_BLOCKACK
&&
1369 ack_policy
!= IEEE80211_QOS_CTL_ACK_POLICY_NORMAL
)
1372 /* new, potentially un-ordered, ampdu frame - process it */
1374 /* reset session timer */
1375 if (tid_agg_rx
->timeout
)
1376 tid_agg_rx
->last_rx
= jiffies
;
1378 /* if this mpdu is fragmented - terminate rx aggregation session */
1379 sc
= le16_to_cpu(hdr
->seq_ctrl
);
1380 if (sc
& IEEE80211_SCTL_FRAG
) {
1381 skb_queue_tail(&rx
->sdata
->skb_queue
, skb
);
1382 ieee80211_queue_work(&local
->hw
, &rx
->sdata
->work
);
1387 * No locking needed -- we will only ever process one
1388 * RX packet at a time, and thus own tid_agg_rx. All
1389 * other code manipulating it needs to (and does) make
1390 * sure that we cannot get to it any more before doing
1393 if (ieee80211_sta_manage_reorder_buf(rx
->sdata
, tid_agg_rx
, skb
,
1398 __skb_queue_tail(frames
, skb
);
1401 static ieee80211_rx_result debug_noinline
1402 ieee80211_rx_h_check_dup(struct ieee80211_rx_data
*rx
)
1404 struct ieee80211_hdr
*hdr
= (struct ieee80211_hdr
*)rx
->skb
->data
;
1405 struct ieee80211_rx_status
*status
= IEEE80211_SKB_RXCB(rx
->skb
);
1407 if (status
->flag
& RX_FLAG_DUP_VALIDATED
)
1411 * Drop duplicate 802.11 retransmissions
1412 * (IEEE 802.11-2012: 9.3.2.10 "Duplicate detection and recovery")
1415 if (rx
->skb
->len
< 24)
1418 if (ieee80211_is_ctl(hdr
->frame_control
) ||
1419 ieee80211_is_nullfunc(hdr
->frame_control
) ||
1420 ieee80211_is_qos_nullfunc(hdr
->frame_control
) ||
1421 is_multicast_ether_addr(hdr
->addr1
))
1427 if (unlikely(ieee80211_has_retry(hdr
->frame_control
) &&
1428 rx
->sta
->last_seq_ctrl
[rx
->seqno_idx
] == hdr
->seq_ctrl
)) {
1429 I802_DEBUG_INC(rx
->local
->dot11FrameDuplicateCount
);
1430 rx
->sta
->rx_stats
.num_duplicates
++;
1431 return RX_DROP_UNUSABLE
;
1432 } else if (!(status
->flag
& RX_FLAG_AMSDU_MORE
)) {
1433 rx
->sta
->last_seq_ctrl
[rx
->seqno_idx
] = hdr
->seq_ctrl
;
1439 static ieee80211_rx_result debug_noinline
1440 ieee80211_rx_h_check(struct ieee80211_rx_data
*rx
)
1442 struct ieee80211_hdr
*hdr
= (struct ieee80211_hdr
*)rx
->skb
->data
;
1444 /* Drop disallowed frame classes based on STA auth/assoc state;
1445 * IEEE 802.11, Chap 5.5.
1447 * mac80211 filters only based on association state, i.e. it drops
1448 * Class 3 frames from not associated stations. hostapd sends
1449 * deauth/disassoc frames when needed. In addition, hostapd is
1450 * responsible for filtering on both auth and assoc states.
1453 if (ieee80211_vif_is_mesh(&rx
->sdata
->vif
))
1454 return ieee80211_rx_mesh_check(rx
);
1456 if (unlikely((ieee80211_is_data(hdr
->frame_control
) ||
1457 ieee80211_is_pspoll(hdr
->frame_control
)) &&
1458 rx
->sdata
->vif
.type
!= NL80211_IFTYPE_ADHOC
&&
1459 rx
->sdata
->vif
.type
!= NL80211_IFTYPE_WDS
&&
1460 rx
->sdata
->vif
.type
!= NL80211_IFTYPE_OCB
&&
1461 (!rx
->sta
|| !test_sta_flag(rx
->sta
, WLAN_STA_ASSOC
)))) {
1463 * accept port control frames from the AP even when it's not
1464 * yet marked ASSOC to prevent a race where we don't set the
1465 * assoc bit quickly enough before it sends the first frame
1467 if (rx
->sta
&& rx
->sdata
->vif
.type
== NL80211_IFTYPE_STATION
&&
1468 ieee80211_is_data_present(hdr
->frame_control
)) {
1469 unsigned int hdrlen
;
1472 hdrlen
= ieee80211_hdrlen(hdr
->frame_control
);
1474 if (rx
->skb
->len
< hdrlen
+ 8)
1475 return RX_DROP_MONITOR
;
1477 skb_copy_bits(rx
->skb
, hdrlen
+ 6, ðertype
, 2);
1478 if (ethertype
== rx
->sdata
->control_port_protocol
)
1482 if (rx
->sdata
->vif
.type
== NL80211_IFTYPE_AP
&&
1483 cfg80211_rx_spurious_frame(rx
->sdata
->dev
,
1486 return RX_DROP_UNUSABLE
;
1488 return RX_DROP_MONITOR
;
1495 static ieee80211_rx_result debug_noinline
1496 ieee80211_rx_h_check_more_data(struct ieee80211_rx_data
*rx
)
1498 struct ieee80211_local
*local
;
1499 struct ieee80211_hdr
*hdr
;
1500 struct sk_buff
*skb
;
1504 hdr
= (struct ieee80211_hdr
*) skb
->data
;
1506 if (!local
->pspolling
)
1509 if (!ieee80211_has_fromds(hdr
->frame_control
))
1510 /* this is not from AP */
1513 if (!ieee80211_is_data(hdr
->frame_control
))
1516 if (!ieee80211_has_moredata(hdr
->frame_control
)) {
1517 /* AP has no more frames buffered for us */
1518 local
->pspolling
= false;
1522 /* more data bit is set, let's request a new frame from the AP */
1523 ieee80211_send_pspoll(local
, rx
->sdata
);
1528 static void sta_ps_start(struct sta_info
*sta
)
1530 struct ieee80211_sub_if_data
*sdata
= sta
->sdata
;
1531 struct ieee80211_local
*local
= sdata
->local
;
1535 if (sta
->sdata
->vif
.type
== NL80211_IFTYPE_AP
||
1536 sta
->sdata
->vif
.type
== NL80211_IFTYPE_AP_VLAN
)
1537 ps
= &sdata
->bss
->ps
;
1541 atomic_inc(&ps
->num_sta_ps
);
1542 set_sta_flag(sta
, WLAN_STA_PS_STA
);
1543 if (!ieee80211_hw_check(&local
->hw
, AP_LINK_PS
))
1544 drv_sta_notify(local
, sdata
, STA_NOTIFY_SLEEP
, &sta
->sta
);
1545 ps_dbg(sdata
, "STA %pM aid %d enters power save mode\n",
1546 sta
->sta
.addr
, sta
->sta
.aid
);
1548 ieee80211_clear_fast_xmit(sta
);
1550 if (!sta
->sta
.txq
[0])
1553 for (tid
= 0; tid
< IEEE80211_NUM_TIDS
; tid
++) {
1554 if (txq_has_queue(sta
->sta
.txq
[tid
]))
1555 set_bit(tid
, &sta
->txq_buffered_tids
);
1557 clear_bit(tid
, &sta
->txq_buffered_tids
);
1561 static void sta_ps_end(struct sta_info
*sta
)
1563 ps_dbg(sta
->sdata
, "STA %pM aid %d exits power save mode\n",
1564 sta
->sta
.addr
, sta
->sta
.aid
);
1566 if (test_sta_flag(sta
, WLAN_STA_PS_DRIVER
)) {
1568 * Clear the flag only if the other one is still set
1569 * so that the TX path won't start TX'ing new frames
1570 * directly ... In the case that the driver flag isn't
1571 * set ieee80211_sta_ps_deliver_wakeup() will clear it.
1573 clear_sta_flag(sta
, WLAN_STA_PS_STA
);
1574 ps_dbg(sta
->sdata
, "STA %pM aid %d driver-ps-blocked\n",
1575 sta
->sta
.addr
, sta
->sta
.aid
);
1579 set_sta_flag(sta
, WLAN_STA_PS_DELIVER
);
1580 clear_sta_flag(sta
, WLAN_STA_PS_STA
);
1581 ieee80211_sta_ps_deliver_wakeup(sta
);
1584 int ieee80211_sta_ps_transition(struct ieee80211_sta
*pubsta
, bool start
)
1586 struct sta_info
*sta
= container_of(pubsta
, struct sta_info
, sta
);
1589 WARN_ON(!ieee80211_hw_check(&sta
->local
->hw
, AP_LINK_PS
));
1591 /* Don't let the same PS state be set twice */
1592 in_ps
= test_sta_flag(sta
, WLAN_STA_PS_STA
);
1593 if ((start
&& in_ps
) || (!start
&& !in_ps
))
1603 EXPORT_SYMBOL(ieee80211_sta_ps_transition
);
1605 void ieee80211_sta_pspoll(struct ieee80211_sta
*pubsta
)
1607 struct sta_info
*sta
= container_of(pubsta
, struct sta_info
, sta
);
1609 if (test_sta_flag(sta
, WLAN_STA_SP
))
1612 if (!test_sta_flag(sta
, WLAN_STA_PS_DRIVER
))
1613 ieee80211_sta_ps_deliver_poll_response(sta
);
1615 set_sta_flag(sta
, WLAN_STA_PSPOLL
);
1617 EXPORT_SYMBOL(ieee80211_sta_pspoll
);
1619 void ieee80211_sta_uapsd_trigger(struct ieee80211_sta
*pubsta
, u8 tid
)
1621 struct sta_info
*sta
= container_of(pubsta
, struct sta_info
, sta
);
1622 int ac
= ieee80211_ac_from_tid(tid
);
1625 * If this AC is not trigger-enabled do nothing unless the
1626 * driver is calling us after it already checked.
1628 * NB: This could/should check a separate bitmap of trigger-
1629 * enabled queues, but for now we only implement uAPSD w/o
1630 * TSPEC changes to the ACs, so they're always the same.
1632 if (!(sta
->sta
.uapsd_queues
& ieee80211_ac_to_qos_mask
[ac
]) &&
1633 tid
!= IEEE80211_NUM_TIDS
)
1636 /* if we are in a service period, do nothing */
1637 if (test_sta_flag(sta
, WLAN_STA_SP
))
1640 if (!test_sta_flag(sta
, WLAN_STA_PS_DRIVER
))
1641 ieee80211_sta_ps_deliver_uapsd(sta
);
1643 set_sta_flag(sta
, WLAN_STA_UAPSD
);
1645 EXPORT_SYMBOL(ieee80211_sta_uapsd_trigger
);
1647 static ieee80211_rx_result debug_noinline
1648 ieee80211_rx_h_uapsd_and_pspoll(struct ieee80211_rx_data
*rx
)
1650 struct ieee80211_sub_if_data
*sdata
= rx
->sdata
;
1651 struct ieee80211_hdr
*hdr
= (void *)rx
->skb
->data
;
1652 struct ieee80211_rx_status
*status
= IEEE80211_SKB_RXCB(rx
->skb
);
1657 if (sdata
->vif
.type
!= NL80211_IFTYPE_AP
&&
1658 sdata
->vif
.type
!= NL80211_IFTYPE_AP_VLAN
)
1662 * The device handles station powersave, so don't do anything about
1663 * uAPSD and PS-Poll frames (the latter shouldn't even come up from
1664 * it to mac80211 since they're handled.)
1666 if (ieee80211_hw_check(&sdata
->local
->hw
, AP_LINK_PS
))
1670 * Don't do anything if the station isn't already asleep. In
1671 * the uAPSD case, the station will probably be marked asleep,
1672 * in the PS-Poll case the station must be confused ...
1674 if (!test_sta_flag(rx
->sta
, WLAN_STA_PS_STA
))
1677 if (unlikely(ieee80211_is_pspoll(hdr
->frame_control
))) {
1678 ieee80211_sta_pspoll(&rx
->sta
->sta
);
1680 /* Free PS Poll skb here instead of returning RX_DROP that would
1681 * count as an dropped frame. */
1682 dev_kfree_skb(rx
->skb
);
1685 } else if (!ieee80211_has_morefrags(hdr
->frame_control
) &&
1686 !(status
->rx_flags
& IEEE80211_RX_DEFERRED_RELEASE
) &&
1687 ieee80211_has_pm(hdr
->frame_control
) &&
1688 (ieee80211_is_data_qos(hdr
->frame_control
) ||
1689 ieee80211_is_qos_nullfunc(hdr
->frame_control
))) {
1690 u8 tid
= ieee80211_get_tid(hdr
);
1692 ieee80211_sta_uapsd_trigger(&rx
->sta
->sta
, tid
);
1698 static ieee80211_rx_result debug_noinline
1699 ieee80211_rx_h_sta_process(struct ieee80211_rx_data
*rx
)
1701 struct sta_info
*sta
= rx
->sta
;
1702 struct sk_buff
*skb
= rx
->skb
;
1703 struct ieee80211_rx_status
*status
= IEEE80211_SKB_RXCB(skb
);
1704 struct ieee80211_hdr
*hdr
= (struct ieee80211_hdr
*)skb
->data
;
1711 * Update last_rx only for IBSS packets which are for the current
1712 * BSSID and for station already AUTHORIZED to avoid keeping the
1713 * current IBSS network alive in cases where other STAs start
1714 * using different BSSID. This will also give the station another
1715 * chance to restart the authentication/authorization in case
1716 * something went wrong the first time.
1718 if (rx
->sdata
->vif
.type
== NL80211_IFTYPE_ADHOC
) {
1719 u8
*bssid
= ieee80211_get_bssid(hdr
, rx
->skb
->len
,
1720 NL80211_IFTYPE_ADHOC
);
1721 if (ether_addr_equal(bssid
, rx
->sdata
->u
.ibss
.bssid
) &&
1722 test_sta_flag(sta
, WLAN_STA_AUTHORIZED
)) {
1723 sta
->rx_stats
.last_rx
= jiffies
;
1724 if (ieee80211_is_data(hdr
->frame_control
) &&
1725 !is_multicast_ether_addr(hdr
->addr1
))
1726 sta
->rx_stats
.last_rate
=
1727 sta_stats_encode_rate(status
);
1729 } else if (rx
->sdata
->vif
.type
== NL80211_IFTYPE_OCB
) {
1730 sta
->rx_stats
.last_rx
= jiffies
;
1731 } else if (!is_multicast_ether_addr(hdr
->addr1
)) {
1733 * Mesh beacons will update last_rx when if they are found to
1734 * match the current local configuration when processed.
1736 sta
->rx_stats
.last_rx
= jiffies
;
1737 if (ieee80211_is_data(hdr
->frame_control
))
1738 sta
->rx_stats
.last_rate
= sta_stats_encode_rate(status
);
1741 if (rx
->sdata
->vif
.type
== NL80211_IFTYPE_STATION
)
1742 ieee80211_sta_rx_notify(rx
->sdata
, hdr
);
1744 sta
->rx_stats
.fragments
++;
1746 u64_stats_update_begin(&rx
->sta
->rx_stats
.syncp
);
1747 sta
->rx_stats
.bytes
+= rx
->skb
->len
;
1748 u64_stats_update_end(&rx
->sta
->rx_stats
.syncp
);
1750 if (!(status
->flag
& RX_FLAG_NO_SIGNAL_VAL
)) {
1751 sta
->rx_stats
.last_signal
= status
->signal
;
1752 ewma_signal_add(&sta
->rx_stats_avg
.signal
, -status
->signal
);
1755 if (status
->chains
) {
1756 sta
->rx_stats
.chains
= status
->chains
;
1757 for (i
= 0; i
< ARRAY_SIZE(status
->chain_signal
); i
++) {
1758 int signal
= status
->chain_signal
[i
];
1760 if (!(status
->chains
& BIT(i
)))
1763 sta
->rx_stats
.chain_signal_last
[i
] = signal
;
1764 ewma_signal_add(&sta
->rx_stats_avg
.chain_signal
[i
],
1770 * Change STA power saving mode only at the end of a frame
1771 * exchange sequence, and only for a data or management
1772 * frame as specified in IEEE 802.11-2016 11.2.3.2
1774 if (!ieee80211_hw_check(&sta
->local
->hw
, AP_LINK_PS
) &&
1775 !ieee80211_has_morefrags(hdr
->frame_control
) &&
1776 !is_multicast_ether_addr(hdr
->addr1
) &&
1777 (ieee80211_is_mgmt(hdr
->frame_control
) ||
1778 ieee80211_is_data(hdr
->frame_control
)) &&
1779 !(status
->rx_flags
& IEEE80211_RX_DEFERRED_RELEASE
) &&
1780 (rx
->sdata
->vif
.type
== NL80211_IFTYPE_AP
||
1781 rx
->sdata
->vif
.type
== NL80211_IFTYPE_AP_VLAN
)) {
1782 if (test_sta_flag(sta
, WLAN_STA_PS_STA
)) {
1783 if (!ieee80211_has_pm(hdr
->frame_control
))
1786 if (ieee80211_has_pm(hdr
->frame_control
))
1791 /* mesh power save support */
1792 if (ieee80211_vif_is_mesh(&rx
->sdata
->vif
))
1793 ieee80211_mps_rx_h_sta_process(sta
, hdr
);
1796 * Drop (qos-)data::nullfunc frames silently, since they
1797 * are used only to control station power saving mode.
1799 if (ieee80211_is_nullfunc(hdr
->frame_control
) ||
1800 ieee80211_is_qos_nullfunc(hdr
->frame_control
)) {
1801 I802_DEBUG_INC(rx
->local
->rx_handlers_drop_nullfunc
);
1804 * If we receive a 4-addr nullfunc frame from a STA
1805 * that was not moved to a 4-addr STA vlan yet send
1806 * the event to userspace and for older hostapd drop
1807 * the frame to the monitor interface.
1809 if (ieee80211_has_a4(hdr
->frame_control
) &&
1810 (rx
->sdata
->vif
.type
== NL80211_IFTYPE_AP
||
1811 (rx
->sdata
->vif
.type
== NL80211_IFTYPE_AP_VLAN
&&
1812 !rx
->sdata
->u
.vlan
.sta
))) {
1813 if (!test_and_set_sta_flag(sta
, WLAN_STA_4ADDR_EVENT
))
1814 cfg80211_rx_unexpected_4addr_frame(
1815 rx
->sdata
->dev
, sta
->sta
.addr
,
1817 return RX_DROP_MONITOR
;
1820 * Update counter and free packet here to avoid
1821 * counting this as a dropped packed.
1823 sta
->rx_stats
.packets
++;
1824 dev_kfree_skb(rx
->skb
);
1829 } /* ieee80211_rx_h_sta_process */
1831 static ieee80211_rx_result debug_noinline
1832 ieee80211_rx_h_decrypt(struct ieee80211_rx_data
*rx
)
1834 struct sk_buff
*skb
= rx
->skb
;
1835 struct ieee80211_rx_status
*status
= IEEE80211_SKB_RXCB(skb
);
1836 struct ieee80211_hdr
*hdr
= (struct ieee80211_hdr
*)skb
->data
;
1839 ieee80211_rx_result result
= RX_DROP_UNUSABLE
;
1840 struct ieee80211_key
*sta_ptk
= NULL
;
1841 int mmie_keyidx
= -1;
1843 const struct ieee80211_cipher_scheme
*cs
= NULL
;
1848 * There are four types of keys:
1849 * - GTK (group keys)
1850 * - IGTK (group keys for management frames)
1851 * - PTK (pairwise keys)
1852 * - STK (station-to-station pairwise keys)
1854 * When selecting a key, we have to distinguish between multicast
1855 * (including broadcast) and unicast frames, the latter can only
1856 * use PTKs and STKs while the former always use GTKs and IGTKs.
1857 * Unless, of course, actual WEP keys ("pre-RSNA") are used, then
1858 * unicast frames can also use key indices like GTKs. Hence, if we
1859 * don't have a PTK/STK we check the key index for a WEP key.
1861 * Note that in a regular BSS, multicast frames are sent by the
1862 * AP only, associated stations unicast the frame to the AP first
1863 * which then multicasts it on their behalf.
1865 * There is also a slight problem in IBSS mode: GTKs are negotiated
1866 * with each station, that is something we don't currently handle.
1867 * The spec seems to expect that one negotiates the same key with
1868 * every station but there's no such requirement; VLANs could be
1872 /* start without a key */
1874 fc
= hdr
->frame_control
;
1877 int keyid
= rx
->sta
->ptk_idx
;
1879 if (ieee80211_has_protected(fc
) && rx
->sta
->cipher_scheme
) {
1880 cs
= rx
->sta
->cipher_scheme
;
1881 keyid
= ieee80211_get_cs_keyid(cs
, rx
->skb
);
1882 if (unlikely(keyid
< 0))
1883 return RX_DROP_UNUSABLE
;
1885 sta_ptk
= rcu_dereference(rx
->sta
->ptk
[keyid
]);
1888 if (!ieee80211_has_protected(fc
))
1889 mmie_keyidx
= ieee80211_get_mmie_keyidx(rx
->skb
);
1891 if (!is_multicast_ether_addr(hdr
->addr1
) && sta_ptk
) {
1893 if ((status
->flag
& RX_FLAG_DECRYPTED
) &&
1894 (status
->flag
& RX_FLAG_IV_STRIPPED
))
1896 /* Skip decryption if the frame is not protected. */
1897 if (!ieee80211_has_protected(fc
))
1899 } else if (mmie_keyidx
>= 0) {
1900 /* Broadcast/multicast robust management frame / BIP */
1901 if ((status
->flag
& RX_FLAG_DECRYPTED
) &&
1902 (status
->flag
& RX_FLAG_IV_STRIPPED
))
1905 if (mmie_keyidx
< NUM_DEFAULT_KEYS
||
1906 mmie_keyidx
>= NUM_DEFAULT_KEYS
+ NUM_DEFAULT_MGMT_KEYS
)
1907 return RX_DROP_MONITOR
; /* unexpected BIP keyidx */
1909 if (ieee80211_is_group_privacy_action(skb
) &&
1910 test_sta_flag(rx
->sta
, WLAN_STA_MFP
))
1911 return RX_DROP_MONITOR
;
1913 rx
->key
= rcu_dereference(rx
->sta
->gtk
[mmie_keyidx
]);
1916 rx
->key
= rcu_dereference(rx
->sdata
->keys
[mmie_keyidx
]);
1917 } else if (!ieee80211_has_protected(fc
)) {
1919 * The frame was not protected, so skip decryption. However, we
1920 * need to set rx->key if there is a key that could have been
1921 * used so that the frame may be dropped if encryption would
1922 * have been expected.
1924 struct ieee80211_key
*key
= NULL
;
1925 struct ieee80211_sub_if_data
*sdata
= rx
->sdata
;
1928 if (ieee80211_is_mgmt(fc
) &&
1929 is_multicast_ether_addr(hdr
->addr1
) &&
1930 (key
= rcu_dereference(rx
->sdata
->default_mgmt_key
)))
1934 for (i
= 0; i
< NUM_DEFAULT_KEYS
; i
++) {
1935 key
= rcu_dereference(rx
->sta
->gtk
[i
]);
1941 for (i
= 0; i
< NUM_DEFAULT_KEYS
; i
++) {
1942 key
= rcu_dereference(sdata
->keys
[i
]);
1955 * The device doesn't give us the IV so we won't be
1956 * able to look up the key. That's ok though, we
1957 * don't need to decrypt the frame, we just won't
1958 * be able to keep statistics accurate.
1959 * Except for key threshold notifications, should
1960 * we somehow allow the driver to tell us which key
1961 * the hardware used if this flag is set?
1963 if ((status
->flag
& RX_FLAG_DECRYPTED
) &&
1964 (status
->flag
& RX_FLAG_IV_STRIPPED
))
1967 hdrlen
= ieee80211_hdrlen(fc
);
1970 keyidx
= ieee80211_get_cs_keyid(cs
, rx
->skb
);
1972 if (unlikely(keyidx
< 0))
1973 return RX_DROP_UNUSABLE
;
1975 if (rx
->skb
->len
< 8 + hdrlen
)
1976 return RX_DROP_UNUSABLE
; /* TODO: count this? */
1978 * no need to call ieee80211_wep_get_keyidx,
1979 * it verifies a bunch of things we've done already
1981 skb_copy_bits(rx
->skb
, hdrlen
+ 3, &keyid
, 1);
1982 keyidx
= keyid
>> 6;
1985 /* check per-station GTK first, if multicast packet */
1986 if (is_multicast_ether_addr(hdr
->addr1
) && rx
->sta
)
1987 rx
->key
= rcu_dereference(rx
->sta
->gtk
[keyidx
]);
1989 /* if not found, try default key */
1991 rx
->key
= rcu_dereference(rx
->sdata
->keys
[keyidx
]);
1994 * RSNA-protected unicast frames should always be
1995 * sent with pairwise or station-to-station keys,
1996 * but for WEP we allow using a key index as well.
1999 rx
->key
->conf
.cipher
!= WLAN_CIPHER_SUITE_WEP40
&&
2000 rx
->key
->conf
.cipher
!= WLAN_CIPHER_SUITE_WEP104
&&
2001 !is_multicast_ether_addr(hdr
->addr1
))
2007 if (unlikely(rx
->key
->flags
& KEY_FLAG_TAINTED
))
2008 return RX_DROP_MONITOR
;
2010 /* TODO: add threshold stuff again */
2012 return RX_DROP_MONITOR
;
2015 switch (rx
->key
->conf
.cipher
) {
2016 case WLAN_CIPHER_SUITE_WEP40
:
2017 case WLAN_CIPHER_SUITE_WEP104
:
2018 result
= ieee80211_crypto_wep_decrypt(rx
);
2020 case WLAN_CIPHER_SUITE_TKIP
:
2021 result
= ieee80211_crypto_tkip_decrypt(rx
);
2023 case WLAN_CIPHER_SUITE_CCMP
:
2024 result
= ieee80211_crypto_ccmp_decrypt(
2025 rx
, IEEE80211_CCMP_MIC_LEN
);
2027 case WLAN_CIPHER_SUITE_CCMP_256
:
2028 result
= ieee80211_crypto_ccmp_decrypt(
2029 rx
, IEEE80211_CCMP_256_MIC_LEN
);
2031 case WLAN_CIPHER_SUITE_AES_CMAC
:
2032 result
= ieee80211_crypto_aes_cmac_decrypt(rx
);
2034 case WLAN_CIPHER_SUITE_BIP_CMAC_256
:
2035 result
= ieee80211_crypto_aes_cmac_256_decrypt(rx
);
2037 case WLAN_CIPHER_SUITE_BIP_GMAC_128
:
2038 case WLAN_CIPHER_SUITE_BIP_GMAC_256
:
2039 result
= ieee80211_crypto_aes_gmac_decrypt(rx
);
2041 case WLAN_CIPHER_SUITE_GCMP
:
2042 case WLAN_CIPHER_SUITE_GCMP_256
:
2043 result
= ieee80211_crypto_gcmp_decrypt(rx
);
2046 result
= ieee80211_crypto_hw_decrypt(rx
);
2049 /* the hdr variable is invalid after the decrypt handlers */
2051 /* either the frame has been decrypted or will be dropped */
2052 status
->flag
|= RX_FLAG_DECRYPTED
;
2057 static inline struct ieee80211_fragment_entry
*
2058 ieee80211_reassemble_add(struct ieee80211_sub_if_data
*sdata
,
2059 unsigned int frag
, unsigned int seq
, int rx_queue
,
2060 struct sk_buff
**skb
)
2062 struct ieee80211_fragment_entry
*entry
;
2064 entry
= &sdata
->fragments
[sdata
->fragment_next
++];
2065 if (sdata
->fragment_next
>= IEEE80211_FRAGMENT_MAX
)
2066 sdata
->fragment_next
= 0;
2068 if (!skb_queue_empty(&entry
->skb_list
))
2069 __skb_queue_purge(&entry
->skb_list
);
2071 __skb_queue_tail(&entry
->skb_list
, *skb
); /* no need for locking */
2073 entry
->first_frag_time
= jiffies
;
2075 entry
->rx_queue
= rx_queue
;
2076 entry
->last_frag
= frag
;
2077 entry
->check_sequential_pn
= false;
2078 entry
->extra_len
= 0;
2083 static inline struct ieee80211_fragment_entry
*
2084 ieee80211_reassemble_find(struct ieee80211_sub_if_data
*sdata
,
2085 unsigned int frag
, unsigned int seq
,
2086 int rx_queue
, struct ieee80211_hdr
*hdr
)
2088 struct ieee80211_fragment_entry
*entry
;
2091 idx
= sdata
->fragment_next
;
2092 for (i
= 0; i
< IEEE80211_FRAGMENT_MAX
; i
++) {
2093 struct ieee80211_hdr
*f_hdr
;
2094 struct sk_buff
*f_skb
;
2098 idx
= IEEE80211_FRAGMENT_MAX
- 1;
2100 entry
= &sdata
->fragments
[idx
];
2101 if (skb_queue_empty(&entry
->skb_list
) || entry
->seq
!= seq
||
2102 entry
->rx_queue
!= rx_queue
||
2103 entry
->last_frag
+ 1 != frag
)
2106 f_skb
= __skb_peek(&entry
->skb_list
);
2107 f_hdr
= (struct ieee80211_hdr
*) f_skb
->data
;
2110 * Check ftype and addresses are equal, else check next fragment
2112 if (((hdr
->frame_control
^ f_hdr
->frame_control
) &
2113 cpu_to_le16(IEEE80211_FCTL_FTYPE
)) ||
2114 !ether_addr_equal(hdr
->addr1
, f_hdr
->addr1
) ||
2115 !ether_addr_equal(hdr
->addr2
, f_hdr
->addr2
))
2118 if (time_after(jiffies
, entry
->first_frag_time
+ 2 * HZ
)) {
2119 __skb_queue_purge(&entry
->skb_list
);
2128 static ieee80211_rx_result debug_noinline
2129 ieee80211_rx_h_defragment(struct ieee80211_rx_data
*rx
)
2131 struct ieee80211_hdr
*hdr
;
2134 unsigned int frag
, seq
;
2135 struct ieee80211_fragment_entry
*entry
;
2136 struct sk_buff
*skb
;
2138 hdr
= (struct ieee80211_hdr
*)rx
->skb
->data
;
2139 fc
= hdr
->frame_control
;
2141 if (ieee80211_is_ctl(fc
))
2144 sc
= le16_to_cpu(hdr
->seq_ctrl
);
2145 frag
= sc
& IEEE80211_SCTL_FRAG
;
2147 if (is_multicast_ether_addr(hdr
->addr1
)) {
2148 I802_DEBUG_INC(rx
->local
->dot11MulticastReceivedFrameCount
);
2152 if (likely(!ieee80211_has_morefrags(fc
) && frag
== 0))
2155 I802_DEBUG_INC(rx
->local
->rx_handlers_fragments
);
2157 if (skb_linearize(rx
->skb
))
2158 return RX_DROP_UNUSABLE
;
2161 * skb_linearize() might change the skb->data and
2162 * previously cached variables (in this case, hdr) need to
2163 * be refreshed with the new data.
2165 hdr
= (struct ieee80211_hdr
*)rx
->skb
->data
;
2166 seq
= (sc
& IEEE80211_SCTL_SEQ
) >> 4;
2169 /* This is the first fragment of a new frame. */
2170 entry
= ieee80211_reassemble_add(rx
->sdata
, frag
, seq
,
2171 rx
->seqno_idx
, &(rx
->skb
));
2173 (rx
->key
->conf
.cipher
== WLAN_CIPHER_SUITE_CCMP
||
2174 rx
->key
->conf
.cipher
== WLAN_CIPHER_SUITE_CCMP_256
||
2175 rx
->key
->conf
.cipher
== WLAN_CIPHER_SUITE_GCMP
||
2176 rx
->key
->conf
.cipher
== WLAN_CIPHER_SUITE_GCMP_256
) &&
2177 ieee80211_has_protected(fc
)) {
2178 int queue
= rx
->security_idx
;
2180 /* Store CCMP/GCMP PN so that we can verify that the
2181 * next fragment has a sequential PN value.
2183 entry
->check_sequential_pn
= true;
2184 memcpy(entry
->last_pn
,
2185 rx
->key
->u
.ccmp
.rx_pn
[queue
],
2186 IEEE80211_CCMP_PN_LEN
);
2187 BUILD_BUG_ON(offsetof(struct ieee80211_key
,
2189 offsetof(struct ieee80211_key
,
2191 BUILD_BUG_ON(sizeof(rx
->key
->u
.ccmp
.rx_pn
[queue
]) !=
2192 sizeof(rx
->key
->u
.gcmp
.rx_pn
[queue
]));
2193 BUILD_BUG_ON(IEEE80211_CCMP_PN_LEN
!=
2194 IEEE80211_GCMP_PN_LEN
);
2199 /* This is a fragment for a frame that should already be pending in
2200 * fragment cache. Add this fragment to the end of the pending entry.
2202 entry
= ieee80211_reassemble_find(rx
->sdata
, frag
, seq
,
2203 rx
->seqno_idx
, hdr
);
2205 I802_DEBUG_INC(rx
->local
->rx_handlers_drop_defrag
);
2206 return RX_DROP_MONITOR
;
2209 /* "The receiver shall discard MSDUs and MMPDUs whose constituent
2210 * MPDU PN values are not incrementing in steps of 1."
2211 * see IEEE P802.11-REVmc/D5.0, 12.5.3.4.4, item d (for CCMP)
2212 * and IEEE P802.11-REVmc/D5.0, 12.5.5.4.4, item d (for GCMP)
2214 if (entry
->check_sequential_pn
) {
2216 u8 pn
[IEEE80211_CCMP_PN_LEN
], *rpn
;
2220 (rx
->key
->conf
.cipher
!= WLAN_CIPHER_SUITE_CCMP
&&
2221 rx
->key
->conf
.cipher
!= WLAN_CIPHER_SUITE_CCMP_256
&&
2222 rx
->key
->conf
.cipher
!= WLAN_CIPHER_SUITE_GCMP
&&
2223 rx
->key
->conf
.cipher
!= WLAN_CIPHER_SUITE_GCMP_256
))
2224 return RX_DROP_UNUSABLE
;
2225 memcpy(pn
, entry
->last_pn
, IEEE80211_CCMP_PN_LEN
);
2226 for (i
= IEEE80211_CCMP_PN_LEN
- 1; i
>= 0; i
--) {
2231 queue
= rx
->security_idx
;
2232 rpn
= rx
->key
->u
.ccmp
.rx_pn
[queue
];
2233 if (memcmp(pn
, rpn
, IEEE80211_CCMP_PN_LEN
))
2234 return RX_DROP_UNUSABLE
;
2235 memcpy(entry
->last_pn
, pn
, IEEE80211_CCMP_PN_LEN
);
2238 skb_pull(rx
->skb
, ieee80211_hdrlen(fc
));
2239 __skb_queue_tail(&entry
->skb_list
, rx
->skb
);
2240 entry
->last_frag
= frag
;
2241 entry
->extra_len
+= rx
->skb
->len
;
2242 if (ieee80211_has_morefrags(fc
)) {
2247 rx
->skb
= __skb_dequeue(&entry
->skb_list
);
2248 if (skb_tailroom(rx
->skb
) < entry
->extra_len
) {
2249 I802_DEBUG_INC(rx
->local
->rx_expand_skb_head_defrag
);
2250 if (unlikely(pskb_expand_head(rx
->skb
, 0, entry
->extra_len
,
2252 I802_DEBUG_INC(rx
->local
->rx_handlers_drop_defrag
);
2253 __skb_queue_purge(&entry
->skb_list
);
2254 return RX_DROP_UNUSABLE
;
2257 while ((skb
= __skb_dequeue(&entry
->skb_list
))) {
2258 skb_put_data(rx
->skb
, skb
->data
, skb
->len
);
2263 ieee80211_led_rx(rx
->local
);
2266 rx
->sta
->rx_stats
.packets
++;
2270 static int ieee80211_802_1x_port_control(struct ieee80211_rx_data
*rx
)
2272 if (unlikely(!rx
->sta
|| !test_sta_flag(rx
->sta
, WLAN_STA_AUTHORIZED
)))
2278 static int ieee80211_drop_unencrypted(struct ieee80211_rx_data
*rx
, __le16 fc
)
2280 struct sk_buff
*skb
= rx
->skb
;
2281 struct ieee80211_rx_status
*status
= IEEE80211_SKB_RXCB(skb
);
2284 * Pass through unencrypted frames if the hardware has
2285 * decrypted them already.
2287 if (status
->flag
& RX_FLAG_DECRYPTED
)
2290 /* Drop unencrypted frames if key is set. */
2291 if (unlikely(!ieee80211_has_protected(fc
) &&
2292 !ieee80211_is_nullfunc(fc
) &&
2293 ieee80211_is_data(fc
) && rx
->key
))
2299 static int ieee80211_drop_unencrypted_mgmt(struct ieee80211_rx_data
*rx
)
2301 struct ieee80211_hdr
*hdr
= (struct ieee80211_hdr
*)rx
->skb
->data
;
2302 struct ieee80211_rx_status
*status
= IEEE80211_SKB_RXCB(rx
->skb
);
2303 __le16 fc
= hdr
->frame_control
;
2306 * Pass through unencrypted frames if the hardware has
2307 * decrypted them already.
2309 if (status
->flag
& RX_FLAG_DECRYPTED
)
2312 if (rx
->sta
&& test_sta_flag(rx
->sta
, WLAN_STA_MFP
)) {
2313 if (unlikely(!ieee80211_has_protected(fc
) &&
2314 ieee80211_is_unicast_robust_mgmt_frame(rx
->skb
) &&
2316 if (ieee80211_is_deauth(fc
) ||
2317 ieee80211_is_disassoc(fc
))
2318 cfg80211_rx_unprot_mlme_mgmt(rx
->sdata
->dev
,
2323 /* BIP does not use Protected field, so need to check MMIE */
2324 if (unlikely(ieee80211_is_multicast_robust_mgmt_frame(rx
->skb
) &&
2325 ieee80211_get_mmie_keyidx(rx
->skb
) < 0)) {
2326 if (ieee80211_is_deauth(fc
) ||
2327 ieee80211_is_disassoc(fc
))
2328 cfg80211_rx_unprot_mlme_mgmt(rx
->sdata
->dev
,
2334 * When using MFP, Action frames are not allowed prior to
2335 * having configured keys.
2337 if (unlikely(ieee80211_is_action(fc
) && !rx
->key
&&
2338 ieee80211_is_robust_mgmt_frame(rx
->skb
)))
2346 __ieee80211_data_to_8023(struct ieee80211_rx_data
*rx
, bool *port_control
)
2348 struct ieee80211_sub_if_data
*sdata
= rx
->sdata
;
2349 struct ieee80211_hdr
*hdr
= (struct ieee80211_hdr
*)rx
->skb
->data
;
2350 bool check_port_control
= false;
2351 struct ethhdr
*ehdr
;
2354 *port_control
= false;
2355 if (ieee80211_has_a4(hdr
->frame_control
) &&
2356 sdata
->vif
.type
== NL80211_IFTYPE_AP_VLAN
&& !sdata
->u
.vlan
.sta
)
2359 if (sdata
->vif
.type
== NL80211_IFTYPE_STATION
&&
2360 !!sdata
->u
.mgd
.use_4addr
!= !!ieee80211_has_a4(hdr
->frame_control
)) {
2362 if (!sdata
->u
.mgd
.use_4addr
)
2364 else if (!ether_addr_equal(hdr
->addr1
, sdata
->vif
.addr
))
2365 check_port_control
= true;
2368 if (is_multicast_ether_addr(hdr
->addr1
) &&
2369 sdata
->vif
.type
== NL80211_IFTYPE_AP_VLAN
&& sdata
->u
.vlan
.sta
)
2372 ret
= ieee80211_data_to_8023(rx
->skb
, sdata
->vif
.addr
, sdata
->vif
.type
);
2376 ehdr
= (struct ethhdr
*) rx
->skb
->data
;
2377 if (ehdr
->h_proto
== rx
->sdata
->control_port_protocol
)
2378 *port_control
= true;
2379 else if (check_port_control
)
2386 * requires that rx->skb is a frame with ethernet header
2388 static bool ieee80211_frame_allowed(struct ieee80211_rx_data
*rx
, __le16 fc
)
2390 static const u8 pae_group_addr
[ETH_ALEN
] __aligned(2)
2391 = { 0x01, 0x80, 0xC2, 0x00, 0x00, 0x03 };
2392 struct ethhdr
*ehdr
= (struct ethhdr
*) rx
->skb
->data
;
2395 * Allow EAPOL frames to us/the PAE group address regardless
2396 * of whether the frame was encrypted or not.
2398 if (ehdr
->h_proto
== rx
->sdata
->control_port_protocol
&&
2399 (ether_addr_equal(ehdr
->h_dest
, rx
->sdata
->vif
.addr
) ||
2400 ether_addr_equal(ehdr
->h_dest
, pae_group_addr
)))
2403 if (ieee80211_802_1x_port_control(rx
) ||
2404 ieee80211_drop_unencrypted(rx
, fc
))
2410 static void ieee80211_deliver_skb_to_local_stack(struct sk_buff
*skb
,
2411 struct ieee80211_rx_data
*rx
)
2413 struct ieee80211_sub_if_data
*sdata
= rx
->sdata
;
2414 struct net_device
*dev
= sdata
->dev
;
2416 if (unlikely((skb
->protocol
== sdata
->control_port_protocol
||
2417 skb
->protocol
== cpu_to_be16(ETH_P_PREAUTH
)) &&
2418 sdata
->control_port_over_nl80211
)) {
2419 struct ieee80211_rx_status
*status
= IEEE80211_SKB_RXCB(skb
);
2420 bool noencrypt
= status
->flag
& RX_FLAG_DECRYPTED
;
2422 cfg80211_rx_control_port(dev
, skb
, noencrypt
);
2425 /* deliver to local stack */
2427 napi_gro_receive(rx
->napi
, skb
);
2429 netif_receive_skb(skb
);
2434 * requires that rx->skb is a frame with ethernet header
2437 ieee80211_deliver_skb(struct ieee80211_rx_data
*rx
)
2439 struct ieee80211_sub_if_data
*sdata
= rx
->sdata
;
2440 struct net_device
*dev
= sdata
->dev
;
2441 struct sk_buff
*skb
, *xmit_skb
;
2442 struct ethhdr
*ehdr
= (struct ethhdr
*) rx
->skb
->data
;
2443 struct sta_info
*dsta
;
2448 ieee80211_rx_stats(dev
, skb
->len
);
2451 /* The seqno index has the same property as needed
2452 * for the rx_msdu field, i.e. it is IEEE80211_NUM_TIDS
2453 * for non-QoS-data frames. Here we know it's a data
2454 * frame, so count MSDUs.
2456 u64_stats_update_begin(&rx
->sta
->rx_stats
.syncp
);
2457 rx
->sta
->rx_stats
.msdu
[rx
->seqno_idx
]++;
2458 u64_stats_update_end(&rx
->sta
->rx_stats
.syncp
);
2461 if ((sdata
->vif
.type
== NL80211_IFTYPE_AP
||
2462 sdata
->vif
.type
== NL80211_IFTYPE_AP_VLAN
) &&
2463 !(sdata
->flags
& IEEE80211_SDATA_DONT_BRIDGE_PACKETS
) &&
2464 (sdata
->vif
.type
!= NL80211_IFTYPE_AP_VLAN
|| !sdata
->u
.vlan
.sta
)) {
2465 if (is_multicast_ether_addr(ehdr
->h_dest
) &&
2466 ieee80211_vif_get_num_mcast_if(sdata
) != 0) {
2468 * send multicast frames both to higher layers in
2469 * local net stack and back to the wireless medium
2471 xmit_skb
= skb_copy(skb
, GFP_ATOMIC
);
2473 net_info_ratelimited("%s: failed to clone multicast frame\n",
2475 } else if (!is_multicast_ether_addr(ehdr
->h_dest
) &&
2476 !ether_addr_equal(ehdr
->h_dest
, ehdr
->h_source
)) {
2477 dsta
= sta_info_get(sdata
, ehdr
->h_dest
);
2480 * The destination station is associated to
2481 * this AP (in this VLAN), so send the frame
2482 * directly to it and do not pass it to local
2491 #ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
2493 /* 'align' will only take the values 0 or 2 here since all
2494 * frames are required to be aligned to 2-byte boundaries
2495 * when being passed to mac80211; the code here works just
2496 * as well if that isn't true, but mac80211 assumes it can
2497 * access fields as 2-byte aligned (e.g. for ether_addr_equal)
2501 align
= (unsigned long)(skb
->data
+ sizeof(struct ethhdr
)) & 3;
2503 if (WARN_ON(skb_headroom(skb
) < 3)) {
2507 u8
*data
= skb
->data
;
2508 size_t len
= skb_headlen(skb
);
2510 memmove(skb
->data
, data
, len
);
2511 skb_set_tail_pointer(skb
, len
);
2518 skb
->protocol
= eth_type_trans(skb
, dev
);
2519 memset(skb
->cb
, 0, sizeof(skb
->cb
));
2521 ieee80211_deliver_skb_to_local_stack(skb
, rx
);
2526 * Send to wireless media and increase priority by 256 to
2527 * keep the received priority instead of reclassifying
2528 * the frame (see cfg80211_classify8021d).
2530 xmit_skb
->priority
+= 256;
2531 xmit_skb
->protocol
= htons(ETH_P_802_3
);
2532 skb_reset_network_header(xmit_skb
);
2533 skb_reset_mac_header(xmit_skb
);
2534 dev_queue_xmit(xmit_skb
);
2538 static ieee80211_rx_result debug_noinline
2539 __ieee80211_rx_h_amsdu(struct ieee80211_rx_data
*rx
, u8 data_offset
)
2541 struct net_device
*dev
= rx
->sdata
->dev
;
2542 struct sk_buff
*skb
= rx
->skb
;
2543 struct ieee80211_hdr
*hdr
= (struct ieee80211_hdr
*)skb
->data
;
2544 __le16 fc
= hdr
->frame_control
;
2545 struct sk_buff_head frame_list
;
2546 struct ethhdr ethhdr
;
2547 const u8
*check_da
= ethhdr
.h_dest
, *check_sa
= ethhdr
.h_source
;
2549 if (unlikely(ieee80211_has_a4(hdr
->frame_control
))) {
2552 } else switch (rx
->sdata
->vif
.type
) {
2553 case NL80211_IFTYPE_AP
:
2554 case NL80211_IFTYPE_AP_VLAN
:
2557 case NL80211_IFTYPE_STATION
:
2559 !test_sta_flag(rx
->sta
, WLAN_STA_TDLS_PEER
))
2562 case NL80211_IFTYPE_MESH_POINT
:
2570 __skb_queue_head_init(&frame_list
);
2572 if (ieee80211_data_to_8023_exthdr(skb
, ðhdr
,
2573 rx
->sdata
->vif
.addr
,
2574 rx
->sdata
->vif
.type
,
2576 return RX_DROP_UNUSABLE
;
2578 ieee80211_amsdu_to_8023s(skb
, &frame_list
, dev
->dev_addr
,
2579 rx
->sdata
->vif
.type
,
2580 rx
->local
->hw
.extra_tx_headroom
,
2581 check_da
, check_sa
);
2583 while (!skb_queue_empty(&frame_list
)) {
2584 rx
->skb
= __skb_dequeue(&frame_list
);
2586 if (!ieee80211_frame_allowed(rx
, fc
)) {
2587 dev_kfree_skb(rx
->skb
);
2591 ieee80211_deliver_skb(rx
);
2597 static ieee80211_rx_result debug_noinline
2598 ieee80211_rx_h_amsdu(struct ieee80211_rx_data
*rx
)
2600 struct sk_buff
*skb
= rx
->skb
;
2601 struct ieee80211_rx_status
*status
= IEEE80211_SKB_RXCB(skb
);
2602 struct ieee80211_hdr
*hdr
= (struct ieee80211_hdr
*)skb
->data
;
2603 __le16 fc
= hdr
->frame_control
;
2605 if (!(status
->rx_flags
& IEEE80211_RX_AMSDU
))
2608 if (unlikely(!ieee80211_is_data(fc
)))
2611 if (unlikely(!ieee80211_is_data_present(fc
)))
2612 return RX_DROP_MONITOR
;
2614 if (unlikely(ieee80211_has_a4(hdr
->frame_control
))) {
2615 switch (rx
->sdata
->vif
.type
) {
2616 case NL80211_IFTYPE_AP_VLAN
:
2617 if (!rx
->sdata
->u
.vlan
.sta
)
2618 return RX_DROP_UNUSABLE
;
2620 case NL80211_IFTYPE_STATION
:
2621 if (!rx
->sdata
->u
.mgd
.use_4addr
)
2622 return RX_DROP_UNUSABLE
;
2625 return RX_DROP_UNUSABLE
;
2629 if (is_multicast_ether_addr(hdr
->addr1
))
2630 return RX_DROP_UNUSABLE
;
2632 return __ieee80211_rx_h_amsdu(rx
, 0);
2635 #ifdef CONFIG_MAC80211_MESH
2636 static ieee80211_rx_result
2637 ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data
*rx
)
2639 struct ieee80211_hdr
*fwd_hdr
, *hdr
;
2640 struct ieee80211_tx_info
*info
;
2641 struct ieee80211s_hdr
*mesh_hdr
;
2642 struct sk_buff
*skb
= rx
->skb
, *fwd_skb
;
2643 struct ieee80211_local
*local
= rx
->local
;
2644 struct ieee80211_sub_if_data
*sdata
= rx
->sdata
;
2645 struct ieee80211_if_mesh
*ifmsh
= &sdata
->u
.mesh
;
2648 hdr
= (struct ieee80211_hdr
*) skb
->data
;
2649 hdrlen
= ieee80211_hdrlen(hdr
->frame_control
);
2651 /* make sure fixed part of mesh header is there, also checks skb len */
2652 if (!pskb_may_pull(rx
->skb
, hdrlen
+ 6))
2653 return RX_DROP_MONITOR
;
2655 mesh_hdr
= (struct ieee80211s_hdr
*) (skb
->data
+ hdrlen
);
2657 /* make sure full mesh header is there, also checks skb len */
2658 if (!pskb_may_pull(rx
->skb
,
2659 hdrlen
+ ieee80211_get_mesh_hdrlen(mesh_hdr
)))
2660 return RX_DROP_MONITOR
;
2662 /* reload pointers */
2663 hdr
= (struct ieee80211_hdr
*) skb
->data
;
2664 mesh_hdr
= (struct ieee80211s_hdr
*) (skb
->data
+ hdrlen
);
2666 if (ieee80211_drop_unencrypted(rx
, hdr
->frame_control
))
2667 return RX_DROP_MONITOR
;
2669 /* frame is in RMC, don't forward */
2670 if (ieee80211_is_data(hdr
->frame_control
) &&
2671 is_multicast_ether_addr(hdr
->addr1
) &&
2672 mesh_rmc_check(rx
->sdata
, hdr
->addr3
, mesh_hdr
))
2673 return RX_DROP_MONITOR
;
2675 if (!ieee80211_is_data(hdr
->frame_control
))
2679 return RX_DROP_MONITOR
;
2681 if (mesh_hdr
->flags
& MESH_FLAGS_AE
) {
2682 struct mesh_path
*mppath
;
2686 if (is_multicast_ether_addr(hdr
->addr1
)) {
2687 mpp_addr
= hdr
->addr3
;
2688 proxied_addr
= mesh_hdr
->eaddr1
;
2689 } else if ((mesh_hdr
->flags
& MESH_FLAGS_AE
) ==
2690 MESH_FLAGS_AE_A5_A6
) {
2691 /* has_a4 already checked in ieee80211_rx_mesh_check */
2692 mpp_addr
= hdr
->addr4
;
2693 proxied_addr
= mesh_hdr
->eaddr2
;
2695 return RX_DROP_MONITOR
;
2699 mppath
= mpp_path_lookup(sdata
, proxied_addr
);
2701 mpp_path_add(sdata
, proxied_addr
, mpp_addr
);
2703 spin_lock_bh(&mppath
->state_lock
);
2704 if (!ether_addr_equal(mppath
->mpp
, mpp_addr
))
2705 memcpy(mppath
->mpp
, mpp_addr
, ETH_ALEN
);
2706 mppath
->exp_time
= jiffies
;
2707 spin_unlock_bh(&mppath
->state_lock
);
2712 /* Frame has reached destination. Don't forward */
2713 if (!is_multicast_ether_addr(hdr
->addr1
) &&
2714 ether_addr_equal(sdata
->vif
.addr
, hdr
->addr3
))
2717 ac
= ieee80211_select_queue_80211(sdata
, skb
, hdr
);
2718 q
= sdata
->vif
.hw_queue
[ac
];
2719 if (ieee80211_queue_stopped(&local
->hw
, q
)) {
2720 IEEE80211_IFSTA_MESH_CTR_INC(ifmsh
, dropped_frames_congestion
);
2721 return RX_DROP_MONITOR
;
2723 skb_set_queue_mapping(skb
, q
);
2725 if (!--mesh_hdr
->ttl
) {
2726 IEEE80211_IFSTA_MESH_CTR_INC(ifmsh
, dropped_frames_ttl
);
2730 if (!ifmsh
->mshcfg
.dot11MeshForwarding
)
2733 fwd_skb
= skb_copy_expand(skb
, local
->tx_headroom
+
2734 sdata
->encrypt_headroom
, 0, GFP_ATOMIC
);
2738 fwd_hdr
= (struct ieee80211_hdr
*) fwd_skb
->data
;
2739 fwd_hdr
->frame_control
&= ~cpu_to_le16(IEEE80211_FCTL_RETRY
);
2740 info
= IEEE80211_SKB_CB(fwd_skb
);
2741 memset(info
, 0, sizeof(*info
));
2742 info
->flags
|= IEEE80211_TX_INTFL_NEED_TXPROCESSING
;
2743 info
->control
.vif
= &rx
->sdata
->vif
;
2744 info
->control
.jiffies
= jiffies
;
2745 if (is_multicast_ether_addr(fwd_hdr
->addr1
)) {
2746 IEEE80211_IFSTA_MESH_CTR_INC(ifmsh
, fwded_mcast
);
2747 memcpy(fwd_hdr
->addr2
, sdata
->vif
.addr
, ETH_ALEN
);
2748 /* update power mode indication when forwarding */
2749 ieee80211_mps_set_frame_flags(sdata
, NULL
, fwd_hdr
);
2750 } else if (!mesh_nexthop_lookup(sdata
, fwd_skb
)) {
2751 /* mesh power mode flags updated in mesh_nexthop_lookup */
2752 IEEE80211_IFSTA_MESH_CTR_INC(ifmsh
, fwded_unicast
);
2754 /* unable to resolve next hop */
2755 mesh_path_error_tx(sdata
, ifmsh
->mshcfg
.element_ttl
,
2757 WLAN_REASON_MESH_PATH_NOFORWARD
,
2759 IEEE80211_IFSTA_MESH_CTR_INC(ifmsh
, dropped_frames_no_route
);
2761 return RX_DROP_MONITOR
;
2764 IEEE80211_IFSTA_MESH_CTR_INC(ifmsh
, fwded_frames
);
2765 ieee80211_add_pending_skb(local
, fwd_skb
);
2767 if (is_multicast_ether_addr(hdr
->addr1
))
2769 return RX_DROP_MONITOR
;
2773 static ieee80211_rx_result debug_noinline
2774 ieee80211_rx_h_data(struct ieee80211_rx_data
*rx
)
2776 struct ieee80211_sub_if_data
*sdata
= rx
->sdata
;
2777 struct ieee80211_local
*local
= rx
->local
;
2778 struct net_device
*dev
= sdata
->dev
;
2779 struct ieee80211_hdr
*hdr
= (struct ieee80211_hdr
*)rx
->skb
->data
;
2780 __le16 fc
= hdr
->frame_control
;
2784 if (unlikely(!ieee80211_is_data(hdr
->frame_control
)))
2787 if (unlikely(!ieee80211_is_data_present(hdr
->frame_control
)))
2788 return RX_DROP_MONITOR
;
2791 * Send unexpected-4addr-frame event to hostapd. For older versions,
2792 * also drop the frame to cooked monitor interfaces.
2794 if (ieee80211_has_a4(hdr
->frame_control
) &&
2795 sdata
->vif
.type
== NL80211_IFTYPE_AP
) {
2797 !test_and_set_sta_flag(rx
->sta
, WLAN_STA_4ADDR_EVENT
))
2798 cfg80211_rx_unexpected_4addr_frame(
2799 rx
->sdata
->dev
, rx
->sta
->sta
.addr
, GFP_ATOMIC
);
2800 return RX_DROP_MONITOR
;
2803 err
= __ieee80211_data_to_8023(rx
, &port_control
);
2805 return RX_DROP_UNUSABLE
;
2807 if (!ieee80211_frame_allowed(rx
, fc
))
2808 return RX_DROP_MONITOR
;
2810 /* directly handle TDLS channel switch requests/responses */
2811 if (unlikely(((struct ethhdr
*)rx
->skb
->data
)->h_proto
==
2812 cpu_to_be16(ETH_P_TDLS
))) {
2813 struct ieee80211_tdls_data
*tf
= (void *)rx
->skb
->data
;
2815 if (pskb_may_pull(rx
->skb
,
2816 offsetof(struct ieee80211_tdls_data
, u
)) &&
2817 tf
->payload_type
== WLAN_TDLS_SNAP_RFTYPE
&&
2818 tf
->category
== WLAN_CATEGORY_TDLS
&&
2819 (tf
->action_code
== WLAN_TDLS_CHANNEL_SWITCH_REQUEST
||
2820 tf
->action_code
== WLAN_TDLS_CHANNEL_SWITCH_RESPONSE
)) {
2821 skb_queue_tail(&local
->skb_queue_tdls_chsw
, rx
->skb
);
2822 schedule_work(&local
->tdls_chsw_work
);
2824 rx
->sta
->rx_stats
.packets
++;
2830 if (rx
->sdata
->vif
.type
== NL80211_IFTYPE_AP_VLAN
&&
2831 unlikely(port_control
) && sdata
->bss
) {
2832 sdata
= container_of(sdata
->bss
, struct ieee80211_sub_if_data
,
2840 if (!ieee80211_hw_check(&local
->hw
, SUPPORTS_DYNAMIC_PS
) &&
2841 local
->ps_sdata
&& local
->hw
.conf
.dynamic_ps_timeout
> 0 &&
2842 !is_multicast_ether_addr(
2843 ((struct ethhdr
*)rx
->skb
->data
)->h_dest
) &&
2844 (!local
->scanning
&&
2845 !test_bit(SDATA_STATE_OFFCHANNEL
, &sdata
->state
)))
2846 mod_timer(&local
->dynamic_ps_timer
, jiffies
+
2847 msecs_to_jiffies(local
->hw
.conf
.dynamic_ps_timeout
));
2849 ieee80211_deliver_skb(rx
);
2854 static ieee80211_rx_result debug_noinline
2855 ieee80211_rx_h_ctrl(struct ieee80211_rx_data
*rx
, struct sk_buff_head
*frames
)
2857 struct sk_buff
*skb
= rx
->skb
;
2858 struct ieee80211_bar
*bar
= (struct ieee80211_bar
*)skb
->data
;
2859 struct tid_ampdu_rx
*tid_agg_rx
;
2863 if (likely(!ieee80211_is_ctl(bar
->frame_control
)))
2866 if (ieee80211_is_back_req(bar
->frame_control
)) {
2868 __le16 control
, start_seq_num
;
2869 } __packed bar_data
;
2870 struct ieee80211_event event
= {
2871 .type
= BAR_RX_EVENT
,
2875 return RX_DROP_MONITOR
;
2877 if (skb_copy_bits(skb
, offsetof(struct ieee80211_bar
, control
),
2878 &bar_data
, sizeof(bar_data
)))
2879 return RX_DROP_MONITOR
;
2881 tid
= le16_to_cpu(bar_data
.control
) >> 12;
2883 if (!test_bit(tid
, rx
->sta
->ampdu_mlme
.agg_session_valid
) &&
2884 !test_and_set_bit(tid
, rx
->sta
->ampdu_mlme
.unexpected_agg
))
2885 ieee80211_send_delba(rx
->sdata
, rx
->sta
->sta
.addr
, tid
,
2886 WLAN_BACK_RECIPIENT
,
2887 WLAN_REASON_QSTA_REQUIRE_SETUP
);
2889 tid_agg_rx
= rcu_dereference(rx
->sta
->ampdu_mlme
.tid_rx
[tid
]);
2891 return RX_DROP_MONITOR
;
2893 start_seq_num
= le16_to_cpu(bar_data
.start_seq_num
) >> 4;
2894 event
.u
.ba
.tid
= tid
;
2895 event
.u
.ba
.ssn
= start_seq_num
;
2896 event
.u
.ba
.sta
= &rx
->sta
->sta
;
2898 /* reset session timer */
2899 if (tid_agg_rx
->timeout
)
2900 mod_timer(&tid_agg_rx
->session_timer
,
2901 TU_TO_EXP_TIME(tid_agg_rx
->timeout
));
2903 spin_lock(&tid_agg_rx
->reorder_lock
);
2904 /* release stored frames up to start of BAR */
2905 ieee80211_release_reorder_frames(rx
->sdata
, tid_agg_rx
,
2906 start_seq_num
, frames
);
2907 spin_unlock(&tid_agg_rx
->reorder_lock
);
2909 drv_event_callback(rx
->local
, rx
->sdata
, &event
);
2916 * After this point, we only want management frames,
2917 * so we can drop all remaining control frames to
2918 * cooked monitor interfaces.
2920 return RX_DROP_MONITOR
;
2923 static void ieee80211_process_sa_query_req(struct ieee80211_sub_if_data
*sdata
,
2924 struct ieee80211_mgmt
*mgmt
,
2927 struct ieee80211_local
*local
= sdata
->local
;
2928 struct sk_buff
*skb
;
2929 struct ieee80211_mgmt
*resp
;
2931 if (!ether_addr_equal(mgmt
->da
, sdata
->vif
.addr
)) {
2932 /* Not to own unicast address */
2936 if (!ether_addr_equal(mgmt
->sa
, sdata
->u
.mgd
.bssid
) ||
2937 !ether_addr_equal(mgmt
->bssid
, sdata
->u
.mgd
.bssid
)) {
2938 /* Not from the current AP or not associated yet. */
2942 if (len
< 24 + 1 + sizeof(resp
->u
.action
.u
.sa_query
)) {
2943 /* Too short SA Query request frame */
2947 skb
= dev_alloc_skb(sizeof(*resp
) + local
->hw
.extra_tx_headroom
);
2951 skb_reserve(skb
, local
->hw
.extra_tx_headroom
);
2952 resp
= skb_put_zero(skb
, 24);
2953 memcpy(resp
->da
, mgmt
->sa
, ETH_ALEN
);
2954 memcpy(resp
->sa
, sdata
->vif
.addr
, ETH_ALEN
);
2955 memcpy(resp
->bssid
, sdata
->u
.mgd
.bssid
, ETH_ALEN
);
2956 resp
->frame_control
= cpu_to_le16(IEEE80211_FTYPE_MGMT
|
2957 IEEE80211_STYPE_ACTION
);
2958 skb_put(skb
, 1 + sizeof(resp
->u
.action
.u
.sa_query
));
2959 resp
->u
.action
.category
= WLAN_CATEGORY_SA_QUERY
;
2960 resp
->u
.action
.u
.sa_query
.action
= WLAN_ACTION_SA_QUERY_RESPONSE
;
2961 memcpy(resp
->u
.action
.u
.sa_query
.trans_id
,
2962 mgmt
->u
.action
.u
.sa_query
.trans_id
,
2963 WLAN_SA_QUERY_TR_ID_LEN
);
2965 ieee80211_tx_skb(sdata
, skb
);
2968 static ieee80211_rx_result debug_noinline
2969 ieee80211_rx_h_mgmt_check(struct ieee80211_rx_data
*rx
)
2971 struct ieee80211_mgmt
*mgmt
= (struct ieee80211_mgmt
*) rx
->skb
->data
;
2972 struct ieee80211_rx_status
*status
= IEEE80211_SKB_RXCB(rx
->skb
);
2975 * From here on, look only at management frames.
2976 * Data and control frames are already handled,
2977 * and unknown (reserved) frames are useless.
2979 if (rx
->skb
->len
< 24)
2980 return RX_DROP_MONITOR
;
2982 if (!ieee80211_is_mgmt(mgmt
->frame_control
))
2983 return RX_DROP_MONITOR
;
2985 if (rx
->sdata
->vif
.type
== NL80211_IFTYPE_AP
&&
2986 ieee80211_is_beacon(mgmt
->frame_control
) &&
2987 !(rx
->flags
& IEEE80211_RX_BEACON_REPORTED
)) {
2990 if (ieee80211_hw_check(&rx
->local
->hw
, SIGNAL_DBM
) &&
2991 !(status
->flag
& RX_FLAG_NO_SIGNAL_VAL
))
2992 sig
= status
->signal
;
2994 cfg80211_report_obss_beacon(rx
->local
->hw
.wiphy
,
2995 rx
->skb
->data
, rx
->skb
->len
,
2997 rx
->flags
|= IEEE80211_RX_BEACON_REPORTED
;
3000 if (ieee80211_drop_unencrypted_mgmt(rx
))
3001 return RX_DROP_UNUSABLE
;
3006 static ieee80211_rx_result debug_noinline
3007 ieee80211_rx_h_action(struct ieee80211_rx_data
*rx
)
3009 struct ieee80211_local
*local
= rx
->local
;
3010 struct ieee80211_sub_if_data
*sdata
= rx
->sdata
;
3011 struct ieee80211_mgmt
*mgmt
= (struct ieee80211_mgmt
*) rx
->skb
->data
;
3012 struct ieee80211_rx_status
*status
= IEEE80211_SKB_RXCB(rx
->skb
);
3013 int len
= rx
->skb
->len
;
3015 if (!ieee80211_is_action(mgmt
->frame_control
))
3018 /* drop too small frames */
3019 if (len
< IEEE80211_MIN_ACTION_SIZE
)
3020 return RX_DROP_UNUSABLE
;
3022 if (!rx
->sta
&& mgmt
->u
.action
.category
!= WLAN_CATEGORY_PUBLIC
&&
3023 mgmt
->u
.action
.category
!= WLAN_CATEGORY_SELF_PROTECTED
&&
3024 mgmt
->u
.action
.category
!= WLAN_CATEGORY_SPECTRUM_MGMT
)
3025 return RX_DROP_UNUSABLE
;
3027 switch (mgmt
->u
.action
.category
) {
3028 case WLAN_CATEGORY_HT
:
3029 /* reject HT action frames from stations not supporting HT */
3030 if (!rx
->sta
->sta
.ht_cap
.ht_supported
)
3033 if (sdata
->vif
.type
!= NL80211_IFTYPE_STATION
&&
3034 sdata
->vif
.type
!= NL80211_IFTYPE_MESH_POINT
&&
3035 sdata
->vif
.type
!= NL80211_IFTYPE_AP_VLAN
&&
3036 sdata
->vif
.type
!= NL80211_IFTYPE_AP
&&
3037 sdata
->vif
.type
!= NL80211_IFTYPE_ADHOC
)
3040 /* verify action & smps_control/chanwidth are present */
3041 if (len
< IEEE80211_MIN_ACTION_SIZE
+ 2)
3044 switch (mgmt
->u
.action
.u
.ht_smps
.action
) {
3045 case WLAN_HT_ACTION_SMPS
: {
3046 struct ieee80211_supported_band
*sband
;
3047 enum ieee80211_smps_mode smps_mode
;
3048 struct sta_opmode_info sta_opmode
= {};
3050 /* convert to HT capability */
3051 switch (mgmt
->u
.action
.u
.ht_smps
.smps_control
) {
3052 case WLAN_HT_SMPS_CONTROL_DISABLED
:
3053 smps_mode
= IEEE80211_SMPS_OFF
;
3055 case WLAN_HT_SMPS_CONTROL_STATIC
:
3056 smps_mode
= IEEE80211_SMPS_STATIC
;
3058 case WLAN_HT_SMPS_CONTROL_DYNAMIC
:
3059 smps_mode
= IEEE80211_SMPS_DYNAMIC
;
3065 /* if no change do nothing */
3066 if (rx
->sta
->sta
.smps_mode
== smps_mode
)
3068 rx
->sta
->sta
.smps_mode
= smps_mode
;
3069 sta_opmode
.smps_mode
=
3070 ieee80211_smps_mode_to_smps_mode(smps_mode
);
3071 sta_opmode
.changed
= STA_OPMODE_SMPS_MODE_CHANGED
;
3073 sband
= rx
->local
->hw
.wiphy
->bands
[status
->band
];
3075 rate_control_rate_update(local
, sband
, rx
->sta
,
3076 IEEE80211_RC_SMPS_CHANGED
);
3077 cfg80211_sta_opmode_change_notify(sdata
->dev
,
3083 case WLAN_HT_ACTION_NOTIFY_CHANWIDTH
: {
3084 struct ieee80211_supported_band
*sband
;
3085 u8 chanwidth
= mgmt
->u
.action
.u
.ht_notify_cw
.chanwidth
;
3086 enum ieee80211_sta_rx_bandwidth max_bw
, new_bw
;
3087 struct sta_opmode_info sta_opmode
= {};
3089 /* If it doesn't support 40 MHz it can't change ... */
3090 if (!(rx
->sta
->sta
.ht_cap
.cap
&
3091 IEEE80211_HT_CAP_SUP_WIDTH_20_40
))
3094 if (chanwidth
== IEEE80211_HT_CHANWIDTH_20MHZ
)
3095 max_bw
= IEEE80211_STA_RX_BW_20
;
3097 max_bw
= ieee80211_sta_cap_rx_bw(rx
->sta
);
3099 /* set cur_max_bandwidth and recalc sta bw */
3100 rx
->sta
->cur_max_bandwidth
= max_bw
;
3101 new_bw
= ieee80211_sta_cur_vht_bw(rx
->sta
);
3103 if (rx
->sta
->sta
.bandwidth
== new_bw
)
3106 rx
->sta
->sta
.bandwidth
= new_bw
;
3107 sband
= rx
->local
->hw
.wiphy
->bands
[status
->band
];
3109 ieee80211_sta_rx_bw_to_chan_width(rx
->sta
);
3110 sta_opmode
.changed
= STA_OPMODE_MAX_BW_CHANGED
;
3112 rate_control_rate_update(local
, sband
, rx
->sta
,
3113 IEEE80211_RC_BW_CHANGED
);
3114 cfg80211_sta_opmode_change_notify(sdata
->dev
,
3125 case WLAN_CATEGORY_PUBLIC
:
3126 if (len
< IEEE80211_MIN_ACTION_SIZE
+ 1)
3128 if (sdata
->vif
.type
!= NL80211_IFTYPE_STATION
)
3132 if (!ether_addr_equal(mgmt
->bssid
, sdata
->u
.mgd
.bssid
))
3134 if (mgmt
->u
.action
.u
.ext_chan_switch
.action_code
!=
3135 WLAN_PUB_ACTION_EXT_CHANSW_ANN
)
3137 if (len
< offsetof(struct ieee80211_mgmt
,
3138 u
.action
.u
.ext_chan_switch
.variable
))
3141 case WLAN_CATEGORY_VHT
:
3142 if (sdata
->vif
.type
!= NL80211_IFTYPE_STATION
&&
3143 sdata
->vif
.type
!= NL80211_IFTYPE_MESH_POINT
&&
3144 sdata
->vif
.type
!= NL80211_IFTYPE_AP_VLAN
&&
3145 sdata
->vif
.type
!= NL80211_IFTYPE_AP
&&
3146 sdata
->vif
.type
!= NL80211_IFTYPE_ADHOC
)
3149 /* verify action code is present */
3150 if (len
< IEEE80211_MIN_ACTION_SIZE
+ 1)
3153 switch (mgmt
->u
.action
.u
.vht_opmode_notif
.action_code
) {
3154 case WLAN_VHT_ACTION_OPMODE_NOTIF
: {
3155 /* verify opmode is present */
3156 if (len
< IEEE80211_MIN_ACTION_SIZE
+ 2)
3160 case WLAN_VHT_ACTION_GROUPID_MGMT
: {
3161 if (len
< IEEE80211_MIN_ACTION_SIZE
+ 25)
3169 case WLAN_CATEGORY_BACK
:
3170 if (sdata
->vif
.type
!= NL80211_IFTYPE_STATION
&&
3171 sdata
->vif
.type
!= NL80211_IFTYPE_MESH_POINT
&&
3172 sdata
->vif
.type
!= NL80211_IFTYPE_AP_VLAN
&&
3173 sdata
->vif
.type
!= NL80211_IFTYPE_AP
&&
3174 sdata
->vif
.type
!= NL80211_IFTYPE_ADHOC
)
3177 /* verify action_code is present */
3178 if (len
< IEEE80211_MIN_ACTION_SIZE
+ 1)
3181 switch (mgmt
->u
.action
.u
.addba_req
.action_code
) {
3182 case WLAN_ACTION_ADDBA_REQ
:
3183 if (len
< (IEEE80211_MIN_ACTION_SIZE
+
3184 sizeof(mgmt
->u
.action
.u
.addba_req
)))
3187 case WLAN_ACTION_ADDBA_RESP
:
3188 if (len
< (IEEE80211_MIN_ACTION_SIZE
+
3189 sizeof(mgmt
->u
.action
.u
.addba_resp
)))
3192 case WLAN_ACTION_DELBA
:
3193 if (len
< (IEEE80211_MIN_ACTION_SIZE
+
3194 sizeof(mgmt
->u
.action
.u
.delba
)))
3202 case WLAN_CATEGORY_SPECTRUM_MGMT
:
3203 /* verify action_code is present */
3204 if (len
< IEEE80211_MIN_ACTION_SIZE
+ 1)
3207 switch (mgmt
->u
.action
.u
.measurement
.action_code
) {
3208 case WLAN_ACTION_SPCT_MSR_REQ
:
3209 if (status
->band
!= NL80211_BAND_5GHZ
)
3212 if (len
< (IEEE80211_MIN_ACTION_SIZE
+
3213 sizeof(mgmt
->u
.action
.u
.measurement
)))
3216 if (sdata
->vif
.type
!= NL80211_IFTYPE_STATION
)
3219 ieee80211_process_measurement_req(sdata
, mgmt
, len
);
3221 case WLAN_ACTION_SPCT_CHL_SWITCH
: {
3223 if (len
< (IEEE80211_MIN_ACTION_SIZE
+
3224 sizeof(mgmt
->u
.action
.u
.chan_switch
)))
3227 if (sdata
->vif
.type
!= NL80211_IFTYPE_STATION
&&
3228 sdata
->vif
.type
!= NL80211_IFTYPE_ADHOC
&&
3229 sdata
->vif
.type
!= NL80211_IFTYPE_MESH_POINT
)
3232 if (sdata
->vif
.type
== NL80211_IFTYPE_STATION
)
3233 bssid
= sdata
->u
.mgd
.bssid
;
3234 else if (sdata
->vif
.type
== NL80211_IFTYPE_ADHOC
)
3235 bssid
= sdata
->u
.ibss
.bssid
;
3236 else if (sdata
->vif
.type
== NL80211_IFTYPE_MESH_POINT
)
3241 if (!ether_addr_equal(mgmt
->bssid
, bssid
))
3248 case WLAN_CATEGORY_SA_QUERY
:
3249 if (len
< (IEEE80211_MIN_ACTION_SIZE
+
3250 sizeof(mgmt
->u
.action
.u
.sa_query
)))
3253 switch (mgmt
->u
.action
.u
.sa_query
.action
) {
3254 case WLAN_ACTION_SA_QUERY_REQUEST
:
3255 if (sdata
->vif
.type
!= NL80211_IFTYPE_STATION
)
3257 ieee80211_process_sa_query_req(sdata
, mgmt
, len
);
3261 case WLAN_CATEGORY_SELF_PROTECTED
:
3262 if (len
< (IEEE80211_MIN_ACTION_SIZE
+
3263 sizeof(mgmt
->u
.action
.u
.self_prot
.action_code
)))
3266 switch (mgmt
->u
.action
.u
.self_prot
.action_code
) {
3267 case WLAN_SP_MESH_PEERING_OPEN
:
3268 case WLAN_SP_MESH_PEERING_CLOSE
:
3269 case WLAN_SP_MESH_PEERING_CONFIRM
:
3270 if (!ieee80211_vif_is_mesh(&sdata
->vif
))
3272 if (sdata
->u
.mesh
.user_mpm
)
3273 /* userspace handles this frame */
3276 case WLAN_SP_MGK_INFORM
:
3277 case WLAN_SP_MGK_ACK
:
3278 if (!ieee80211_vif_is_mesh(&sdata
->vif
))
3283 case WLAN_CATEGORY_MESH_ACTION
:
3284 if (len
< (IEEE80211_MIN_ACTION_SIZE
+
3285 sizeof(mgmt
->u
.action
.u
.mesh_action
.action_code
)))
3288 if (!ieee80211_vif_is_mesh(&sdata
->vif
))
3290 if (mesh_action_is_path_sel(mgmt
) &&
3291 !mesh_path_sel_is_hwmp(sdata
))
3299 status
->rx_flags
|= IEEE80211_RX_MALFORMED_ACTION_FRM
;
3300 /* will return in the next handlers */
3305 rx
->sta
->rx_stats
.packets
++;
3306 dev_kfree_skb(rx
->skb
);
3310 skb_queue_tail(&sdata
->skb_queue
, rx
->skb
);
3311 ieee80211_queue_work(&local
->hw
, &sdata
->work
);
3313 rx
->sta
->rx_stats
.packets
++;
3317 static ieee80211_rx_result debug_noinline
3318 ieee80211_rx_h_userspace_mgmt(struct ieee80211_rx_data
*rx
)
3320 struct ieee80211_rx_status
*status
= IEEE80211_SKB_RXCB(rx
->skb
);
3323 /* skip known-bad action frames and return them in the next handler */
3324 if (status
->rx_flags
& IEEE80211_RX_MALFORMED_ACTION_FRM
)
3328 * Getting here means the kernel doesn't know how to handle
3329 * it, but maybe userspace does ... include returned frames
3330 * so userspace can register for those to know whether ones
3331 * it transmitted were processed or returned.
3334 if (ieee80211_hw_check(&rx
->local
->hw
, SIGNAL_DBM
) &&
3335 !(status
->flag
& RX_FLAG_NO_SIGNAL_VAL
))
3336 sig
= status
->signal
;
3338 if (cfg80211_rx_mgmt(&rx
->sdata
->wdev
, status
->freq
, sig
,
3339 rx
->skb
->data
, rx
->skb
->len
, 0)) {
3341 rx
->sta
->rx_stats
.packets
++;
3342 dev_kfree_skb(rx
->skb
);
3349 static ieee80211_rx_result debug_noinline
3350 ieee80211_rx_h_action_return(struct ieee80211_rx_data
*rx
)
3352 struct ieee80211_local
*local
= rx
->local
;
3353 struct ieee80211_mgmt
*mgmt
= (struct ieee80211_mgmt
*) rx
->skb
->data
;
3354 struct sk_buff
*nskb
;
3355 struct ieee80211_sub_if_data
*sdata
= rx
->sdata
;
3356 struct ieee80211_rx_status
*status
= IEEE80211_SKB_RXCB(rx
->skb
);
3358 if (!ieee80211_is_action(mgmt
->frame_control
))
3362 * For AP mode, hostapd is responsible for handling any action
3363 * frames that we didn't handle, including returning unknown
3364 * ones. For all other modes we will return them to the sender,
3365 * setting the 0x80 bit in the action category, as required by
3366 * 802.11-2012 9.24.4.
3367 * Newer versions of hostapd shall also use the management frame
3368 * registration mechanisms, but older ones still use cooked
3369 * monitor interfaces so push all frames there.
3371 if (!(status
->rx_flags
& IEEE80211_RX_MALFORMED_ACTION_FRM
) &&
3372 (sdata
->vif
.type
== NL80211_IFTYPE_AP
||
3373 sdata
->vif
.type
== NL80211_IFTYPE_AP_VLAN
))
3374 return RX_DROP_MONITOR
;
3376 if (is_multicast_ether_addr(mgmt
->da
))
3377 return RX_DROP_MONITOR
;
3379 /* do not return rejected action frames */
3380 if (mgmt
->u
.action
.category
& 0x80)
3381 return RX_DROP_UNUSABLE
;
3383 nskb
= skb_copy_expand(rx
->skb
, local
->hw
.extra_tx_headroom
, 0,
3386 struct ieee80211_mgmt
*nmgmt
= (void *)nskb
->data
;
3388 nmgmt
->u
.action
.category
|= 0x80;
3389 memcpy(nmgmt
->da
, nmgmt
->sa
, ETH_ALEN
);
3390 memcpy(nmgmt
->sa
, rx
->sdata
->vif
.addr
, ETH_ALEN
);
3392 memset(nskb
->cb
, 0, sizeof(nskb
->cb
));
3394 if (rx
->sdata
->vif
.type
== NL80211_IFTYPE_P2P_DEVICE
) {
3395 struct ieee80211_tx_info
*info
= IEEE80211_SKB_CB(nskb
);
3397 info
->flags
= IEEE80211_TX_CTL_TX_OFFCHAN
|
3398 IEEE80211_TX_INTFL_OFFCHAN_TX_OK
|
3399 IEEE80211_TX_CTL_NO_CCK_RATE
;
3400 if (ieee80211_hw_check(&local
->hw
, QUEUE_CONTROL
))
3402 local
->hw
.offchannel_tx_hw_queue
;
3405 __ieee80211_tx_skb_tid_band(rx
->sdata
, nskb
, 7,
3408 dev_kfree_skb(rx
->skb
);
3412 static ieee80211_rx_result debug_noinline
3413 ieee80211_rx_h_mgmt(struct ieee80211_rx_data
*rx
)
3415 struct ieee80211_sub_if_data
*sdata
= rx
->sdata
;
3416 struct ieee80211_mgmt
*mgmt
= (void *)rx
->skb
->data
;
3419 stype
= mgmt
->frame_control
& cpu_to_le16(IEEE80211_FCTL_STYPE
);
3421 if (!ieee80211_vif_is_mesh(&sdata
->vif
) &&
3422 sdata
->vif
.type
!= NL80211_IFTYPE_ADHOC
&&
3423 sdata
->vif
.type
!= NL80211_IFTYPE_OCB
&&
3424 sdata
->vif
.type
!= NL80211_IFTYPE_STATION
)
3425 return RX_DROP_MONITOR
;
3428 case cpu_to_le16(IEEE80211_STYPE_AUTH
):
3429 case cpu_to_le16(IEEE80211_STYPE_BEACON
):
3430 case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP
):
3431 /* process for all: mesh, mlme, ibss */
3433 case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP
):
3434 case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP
):
3435 case cpu_to_le16(IEEE80211_STYPE_DEAUTH
):
3436 case cpu_to_le16(IEEE80211_STYPE_DISASSOC
):
3437 if (is_multicast_ether_addr(mgmt
->da
) &&
3438 !is_broadcast_ether_addr(mgmt
->da
))
3439 return RX_DROP_MONITOR
;
3441 /* process only for station */
3442 if (sdata
->vif
.type
!= NL80211_IFTYPE_STATION
)
3443 return RX_DROP_MONITOR
;
3445 case cpu_to_le16(IEEE80211_STYPE_PROBE_REQ
):
3446 /* process only for ibss and mesh */
3447 if (sdata
->vif
.type
!= NL80211_IFTYPE_ADHOC
&&
3448 sdata
->vif
.type
!= NL80211_IFTYPE_MESH_POINT
)
3449 return RX_DROP_MONITOR
;
3452 return RX_DROP_MONITOR
;
3455 /* queue up frame and kick off work to process it */
3456 skb_queue_tail(&sdata
->skb_queue
, rx
->skb
);
3457 ieee80211_queue_work(&rx
->local
->hw
, &sdata
->work
);
3459 rx
->sta
->rx_stats
.packets
++;
3464 static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data
*rx
,
3465 struct ieee80211_rate
*rate
)
3467 struct ieee80211_sub_if_data
*sdata
;
3468 struct ieee80211_local
*local
= rx
->local
;
3469 struct sk_buff
*skb
= rx
->skb
, *skb2
;
3470 struct net_device
*prev_dev
= NULL
;
3471 struct ieee80211_rx_status
*status
= IEEE80211_SKB_RXCB(skb
);
3472 int needed_headroom
;
3475 * If cooked monitor has been processed already, then
3476 * don't do it again. If not, set the flag.
3478 if (rx
->flags
& IEEE80211_RX_CMNTR
)
3480 rx
->flags
|= IEEE80211_RX_CMNTR
;
3482 /* If there are no cooked monitor interfaces, just free the SKB */
3483 if (!local
->cooked_mntrs
)
3486 /* vendor data is long removed here */
3487 status
->flag
&= ~RX_FLAG_RADIOTAP_VENDOR_DATA
;
3488 /* room for the radiotap header based on driver features */
3489 needed_headroom
= ieee80211_rx_radiotap_hdrlen(local
, status
, skb
);
3491 if (skb_headroom(skb
) < needed_headroom
&&
3492 pskb_expand_head(skb
, needed_headroom
, 0, GFP_ATOMIC
))
3495 /* prepend radiotap information */
3496 ieee80211_add_rx_radiotap_header(local
, skb
, rate
, needed_headroom
,
3499 skb_reset_mac_header(skb
);
3500 skb
->ip_summed
= CHECKSUM_UNNECESSARY
;
3501 skb
->pkt_type
= PACKET_OTHERHOST
;
3502 skb
->protocol
= htons(ETH_P_802_2
);
3504 list_for_each_entry_rcu(sdata
, &local
->interfaces
, list
) {
3505 if (!ieee80211_sdata_running(sdata
))
3508 if (sdata
->vif
.type
!= NL80211_IFTYPE_MONITOR
||
3509 !(sdata
->u
.mntr
.flags
& MONITOR_FLAG_COOK_FRAMES
))
3513 skb2
= skb_clone(skb
, GFP_ATOMIC
);
3515 skb2
->dev
= prev_dev
;
3516 netif_receive_skb(skb2
);
3520 prev_dev
= sdata
->dev
;
3521 ieee80211_rx_stats(sdata
->dev
, skb
->len
);
3525 skb
->dev
= prev_dev
;
3526 netif_receive_skb(skb
);
3534 static void ieee80211_rx_handlers_result(struct ieee80211_rx_data
*rx
,
3535 ieee80211_rx_result res
)
3538 case RX_DROP_MONITOR
:
3539 I802_DEBUG_INC(rx
->sdata
->local
->rx_handlers_drop
);
3541 rx
->sta
->rx_stats
.dropped
++;
3544 struct ieee80211_rate
*rate
= NULL
;
3545 struct ieee80211_supported_band
*sband
;
3546 struct ieee80211_rx_status
*status
;
3548 status
= IEEE80211_SKB_RXCB((rx
->skb
));
3550 sband
= rx
->local
->hw
.wiphy
->bands
[status
->band
];
3551 if (status
->encoding
== RX_ENC_LEGACY
)
3552 rate
= &sband
->bitrates
[status
->rate_idx
];
3554 ieee80211_rx_cooked_monitor(rx
, rate
);
3557 case RX_DROP_UNUSABLE
:
3558 I802_DEBUG_INC(rx
->sdata
->local
->rx_handlers_drop
);
3560 rx
->sta
->rx_stats
.dropped
++;
3561 dev_kfree_skb(rx
->skb
);
3564 I802_DEBUG_INC(rx
->sdata
->local
->rx_handlers_queued
);
3569 static void ieee80211_rx_handlers(struct ieee80211_rx_data
*rx
,
3570 struct sk_buff_head
*frames
)
3572 ieee80211_rx_result res
= RX_DROP_MONITOR
;
3573 struct sk_buff
*skb
;
3575 #define CALL_RXH(rxh) \
3578 if (res != RX_CONTINUE) \
3582 /* Lock here to avoid hitting all of the data used in the RX
3583 * path (e.g. key data, station data, ...) concurrently when
3584 * a frame is released from the reorder buffer due to timeout
3585 * from the timer, potentially concurrently with RX from the
3588 spin_lock_bh(&rx
->local
->rx_path_lock
);
3590 while ((skb
= __skb_dequeue(frames
))) {
3592 * all the other fields are valid across frames
3593 * that belong to an aMPDU since they are on the
3594 * same TID from the same station
3598 CALL_RXH(ieee80211_rx_h_check_more_data
);
3599 CALL_RXH(ieee80211_rx_h_uapsd_and_pspoll
);
3600 CALL_RXH(ieee80211_rx_h_sta_process
);
3601 CALL_RXH(ieee80211_rx_h_decrypt
);
3602 CALL_RXH(ieee80211_rx_h_defragment
);
3603 CALL_RXH(ieee80211_rx_h_michael_mic_verify
);
3604 /* must be after MMIC verify so header is counted in MPDU mic */
3605 #ifdef CONFIG_MAC80211_MESH
3606 if (ieee80211_vif_is_mesh(&rx
->sdata
->vif
))
3607 CALL_RXH(ieee80211_rx_h_mesh_fwding
);
3609 CALL_RXH(ieee80211_rx_h_amsdu
);
3610 CALL_RXH(ieee80211_rx_h_data
);
3612 /* special treatment -- needs the queue */
3613 res
= ieee80211_rx_h_ctrl(rx
, frames
);
3614 if (res
!= RX_CONTINUE
)
3617 CALL_RXH(ieee80211_rx_h_mgmt_check
);
3618 CALL_RXH(ieee80211_rx_h_action
);
3619 CALL_RXH(ieee80211_rx_h_userspace_mgmt
);
3620 CALL_RXH(ieee80211_rx_h_action_return
);
3621 CALL_RXH(ieee80211_rx_h_mgmt
);
3624 ieee80211_rx_handlers_result(rx
, res
);
3629 spin_unlock_bh(&rx
->local
->rx_path_lock
);
3632 static void ieee80211_invoke_rx_handlers(struct ieee80211_rx_data
*rx
)
3634 struct sk_buff_head reorder_release
;
3635 ieee80211_rx_result res
= RX_DROP_MONITOR
;
3637 __skb_queue_head_init(&reorder_release
);
3639 #define CALL_RXH(rxh) \
3642 if (res != RX_CONTINUE) \
3646 CALL_RXH(ieee80211_rx_h_check_dup
);
3647 CALL_RXH(ieee80211_rx_h_check
);
3649 ieee80211_rx_reorder_ampdu(rx
, &reorder_release
);
3651 ieee80211_rx_handlers(rx
, &reorder_release
);
3655 ieee80211_rx_handlers_result(rx
, res
);
3661 * This function makes calls into the RX path, therefore
3662 * it has to be invoked under RCU read lock.
3664 void ieee80211_release_reorder_timeout(struct sta_info
*sta
, int tid
)
3666 struct sk_buff_head frames
;
3667 struct ieee80211_rx_data rx
= {
3669 .sdata
= sta
->sdata
,
3670 .local
= sta
->local
,
3671 /* This is OK -- must be QoS data frame */
3672 .security_idx
= tid
,
3674 .napi
= NULL
, /* must be NULL to not have races */
3676 struct tid_ampdu_rx
*tid_agg_rx
;
3678 tid_agg_rx
= rcu_dereference(sta
->ampdu_mlme
.tid_rx
[tid
]);
3682 __skb_queue_head_init(&frames
);
3684 spin_lock(&tid_agg_rx
->reorder_lock
);
3685 ieee80211_sta_reorder_release(sta
->sdata
, tid_agg_rx
, &frames
);
3686 spin_unlock(&tid_agg_rx
->reorder_lock
);
3688 if (!skb_queue_empty(&frames
)) {
3689 struct ieee80211_event event
= {
3690 .type
= BA_FRAME_TIMEOUT
,
3692 .u
.ba
.sta
= &sta
->sta
,
3694 drv_event_callback(rx
.local
, rx
.sdata
, &event
);
3697 ieee80211_rx_handlers(&rx
, &frames
);
3700 void ieee80211_mark_rx_ba_filtered_frames(struct ieee80211_sta
*pubsta
, u8 tid
,
3701 u16 ssn
, u64 filtered
,
3704 struct sta_info
*sta
;
3705 struct tid_ampdu_rx
*tid_agg_rx
;
3706 struct sk_buff_head frames
;
3707 struct ieee80211_rx_data rx
= {
3708 /* This is OK -- must be QoS data frame */
3709 .security_idx
= tid
,
3714 if (WARN_ON(!pubsta
|| tid
>= IEEE80211_NUM_TIDS
))
3717 __skb_queue_head_init(&frames
);
3719 sta
= container_of(pubsta
, struct sta_info
, sta
);
3722 rx
.sdata
= sta
->sdata
;
3723 rx
.local
= sta
->local
;
3726 tid_agg_rx
= rcu_dereference(sta
->ampdu_mlme
.tid_rx
[tid
]);
3730 spin_lock_bh(&tid_agg_rx
->reorder_lock
);
3732 if (received_mpdus
>= IEEE80211_SN_MODULO
>> 1) {
3735 /* release all frames in the reorder buffer */
3736 release
= (tid_agg_rx
->head_seq_num
+ tid_agg_rx
->buf_size
) %
3737 IEEE80211_SN_MODULO
;
3738 ieee80211_release_reorder_frames(sta
->sdata
, tid_agg_rx
,
3740 /* update ssn to match received ssn */
3741 tid_agg_rx
->head_seq_num
= ssn
;
3743 ieee80211_release_reorder_frames(sta
->sdata
, tid_agg_rx
, ssn
,
3747 /* handle the case that received ssn is behind the mac ssn.
3748 * it can be tid_agg_rx->buf_size behind and still be valid */
3749 diff
= (tid_agg_rx
->head_seq_num
- ssn
) & IEEE80211_SN_MASK
;
3750 if (diff
>= tid_agg_rx
->buf_size
) {
3751 tid_agg_rx
->reorder_buf_filtered
= 0;
3754 filtered
= filtered
>> diff
;
3758 for (i
= 0; i
< tid_agg_rx
->buf_size
; i
++) {
3759 int index
= (ssn
+ i
) % tid_agg_rx
->buf_size
;
3761 tid_agg_rx
->reorder_buf_filtered
&= ~BIT_ULL(index
);
3762 if (filtered
& BIT_ULL(i
))
3763 tid_agg_rx
->reorder_buf_filtered
|= BIT_ULL(index
);
3766 /* now process also frames that the filter marking released */
3767 ieee80211_sta_reorder_release(sta
->sdata
, tid_agg_rx
, &frames
);
3770 spin_unlock_bh(&tid_agg_rx
->reorder_lock
);
3772 ieee80211_rx_handlers(&rx
, &frames
);
3777 EXPORT_SYMBOL(ieee80211_mark_rx_ba_filtered_frames
);
3779 /* main receive path */
3781 static bool ieee80211_accept_frame(struct ieee80211_rx_data
*rx
)
3783 struct ieee80211_sub_if_data
*sdata
= rx
->sdata
;
3784 struct sk_buff
*skb
= rx
->skb
;
3785 struct ieee80211_hdr
*hdr
= (void *)skb
->data
;
3786 struct ieee80211_rx_status
*status
= IEEE80211_SKB_RXCB(skb
);
3787 u8
*bssid
= ieee80211_get_bssid(hdr
, skb
->len
, sdata
->vif
.type
);
3788 bool multicast
= is_multicast_ether_addr(hdr
->addr1
);
3790 switch (sdata
->vif
.type
) {
3791 case NL80211_IFTYPE_STATION
:
3792 if (!bssid
&& !sdata
->u
.mgd
.use_4addr
)
3796 return ether_addr_equal(sdata
->vif
.addr
, hdr
->addr1
);
3797 case NL80211_IFTYPE_ADHOC
:
3800 if (ether_addr_equal(sdata
->vif
.addr
, hdr
->addr2
) ||
3801 ether_addr_equal(sdata
->u
.ibss
.bssid
, hdr
->addr2
))
3803 if (ieee80211_is_beacon(hdr
->frame_control
))
3805 if (!ieee80211_bssid_match(bssid
, sdata
->u
.ibss
.bssid
))
3808 !ether_addr_equal(sdata
->vif
.addr
, hdr
->addr1
))
3812 if (status
->encoding
!= RX_ENC_LEGACY
)
3813 rate_idx
= 0; /* TODO: HT/VHT rates */
3815 rate_idx
= status
->rate_idx
;
3816 ieee80211_ibss_rx_no_sta(sdata
, bssid
, hdr
->addr2
,
3820 case NL80211_IFTYPE_OCB
:
3823 if (!ieee80211_is_data_present(hdr
->frame_control
))
3825 if (!is_broadcast_ether_addr(bssid
))
3828 !ether_addr_equal(sdata
->dev
->dev_addr
, hdr
->addr1
))
3832 if (status
->encoding
!= RX_ENC_LEGACY
)
3833 rate_idx
= 0; /* TODO: HT rates */
3835 rate_idx
= status
->rate_idx
;
3836 ieee80211_ocb_rx_no_sta(sdata
, bssid
, hdr
->addr2
,
3840 case NL80211_IFTYPE_MESH_POINT
:
3841 if (ether_addr_equal(sdata
->vif
.addr
, hdr
->addr2
))
3845 return ether_addr_equal(sdata
->vif
.addr
, hdr
->addr1
);
3846 case NL80211_IFTYPE_AP_VLAN
:
3847 case NL80211_IFTYPE_AP
:
3849 return ether_addr_equal(sdata
->vif
.addr
, hdr
->addr1
);
3851 if (!ieee80211_bssid_match(bssid
, sdata
->vif
.addr
)) {
3853 * Accept public action frames even when the
3854 * BSSID doesn't match, this is used for P2P
3855 * and location updates. Note that mac80211
3856 * itself never looks at these frames.
3859 !ether_addr_equal(sdata
->vif
.addr
, hdr
->addr1
))
3861 if (ieee80211_is_public_action(hdr
, skb
->len
))
3863 return ieee80211_is_beacon(hdr
->frame_control
);
3866 if (!ieee80211_has_tods(hdr
->frame_control
)) {
3867 /* ignore data frames to TDLS-peers */
3868 if (ieee80211_is_data(hdr
->frame_control
))
3870 /* ignore action frames to TDLS-peers */
3871 if (ieee80211_is_action(hdr
->frame_control
) &&
3872 !is_broadcast_ether_addr(bssid
) &&
3873 !ether_addr_equal(bssid
, hdr
->addr1
))
3878 * 802.11-2016 Table 9-26 says that for data frames, A1 must be
3879 * the BSSID - we've checked that already but may have accepted
3880 * the wildcard (ff:ff:ff:ff:ff:ff).
3883 * The BSSID of the Data frame is determined as follows:
3884 * a) If the STA is contained within an AP or is associated
3885 * with an AP, the BSSID is the address currently in use
3886 * by the STA contained in the AP.
3888 * So we should not accept data frames with an address that's
3891 * Accepting it also opens a security problem because stations
3892 * could encrypt it with the GTK and inject traffic that way.
3894 if (ieee80211_is_data(hdr
->frame_control
) && multicast
)
3898 case NL80211_IFTYPE_WDS
:
3899 if (bssid
|| !ieee80211_is_data(hdr
->frame_control
))
3901 return ether_addr_equal(sdata
->u
.wds
.remote_addr
, hdr
->addr2
);
3902 case NL80211_IFTYPE_P2P_DEVICE
:
3903 return ieee80211_is_public_action(hdr
, skb
->len
) ||
3904 ieee80211_is_probe_req(hdr
->frame_control
) ||
3905 ieee80211_is_probe_resp(hdr
->frame_control
) ||
3906 ieee80211_is_beacon(hdr
->frame_control
);
3907 case NL80211_IFTYPE_NAN
:
3908 /* Currently no frames on NAN interface are allowed */
3918 void ieee80211_check_fast_rx(struct sta_info
*sta
)
3920 struct ieee80211_sub_if_data
*sdata
= sta
->sdata
;
3921 struct ieee80211_local
*local
= sdata
->local
;
3922 struct ieee80211_key
*key
;
3923 struct ieee80211_fast_rx fastrx
= {
3925 .vif_type
= sdata
->vif
.type
,
3926 .control_port_protocol
= sdata
->control_port_protocol
,
3927 }, *old
, *new = NULL
;
3928 bool assign
= false;
3930 /* use sparse to check that we don't return without updating */
3931 __acquire(check_fast_rx
);
3933 BUILD_BUG_ON(sizeof(fastrx
.rfc1042_hdr
) != sizeof(rfc1042_header
));
3934 BUILD_BUG_ON(sizeof(fastrx
.rfc1042_hdr
) != ETH_ALEN
);
3935 ether_addr_copy(fastrx
.rfc1042_hdr
, rfc1042_header
);
3936 ether_addr_copy(fastrx
.vif_addr
, sdata
->vif
.addr
);
3938 fastrx
.uses_rss
= ieee80211_hw_check(&local
->hw
, USES_RSS
);
3940 /* fast-rx doesn't do reordering */
3941 if (ieee80211_hw_check(&local
->hw
, AMPDU_AGGREGATION
) &&
3942 !ieee80211_hw_check(&local
->hw
, SUPPORTS_REORDERING_BUFFER
))
3945 switch (sdata
->vif
.type
) {
3946 case NL80211_IFTYPE_STATION
:
3947 if (sta
->sta
.tdls
) {
3948 fastrx
.da_offs
= offsetof(struct ieee80211_hdr
, addr1
);
3949 fastrx
.sa_offs
= offsetof(struct ieee80211_hdr
, addr2
);
3950 fastrx
.expected_ds_bits
= 0;
3952 fastrx
.sta_notify
= sdata
->u
.mgd
.probe_send_count
> 0;
3953 fastrx
.da_offs
= offsetof(struct ieee80211_hdr
, addr1
);
3954 fastrx
.sa_offs
= offsetof(struct ieee80211_hdr
, addr3
);
3955 fastrx
.expected_ds_bits
=
3956 cpu_to_le16(IEEE80211_FCTL_FROMDS
);
3959 if (sdata
->u
.mgd
.use_4addr
&& !sta
->sta
.tdls
) {
3960 fastrx
.expected_ds_bits
|=
3961 cpu_to_le16(IEEE80211_FCTL_TODS
);
3962 fastrx
.da_offs
= offsetof(struct ieee80211_hdr
, addr3
);
3963 fastrx
.sa_offs
= offsetof(struct ieee80211_hdr
, addr4
);
3966 if (!sdata
->u
.mgd
.powersave
)
3969 /* software powersave is a huge mess, avoid all of it */
3970 if (ieee80211_hw_check(&local
->hw
, PS_NULLFUNC_STACK
))
3972 if (ieee80211_hw_check(&local
->hw
, SUPPORTS_PS
) &&
3973 !ieee80211_hw_check(&local
->hw
, SUPPORTS_DYNAMIC_PS
))
3976 case NL80211_IFTYPE_AP_VLAN
:
3977 case NL80211_IFTYPE_AP
:
3978 /* parallel-rx requires this, at least with calls to
3979 * ieee80211_sta_ps_transition()
3981 if (!ieee80211_hw_check(&local
->hw
, AP_LINK_PS
))
3983 fastrx
.da_offs
= offsetof(struct ieee80211_hdr
, addr3
);
3984 fastrx
.sa_offs
= offsetof(struct ieee80211_hdr
, addr2
);
3985 fastrx
.expected_ds_bits
= cpu_to_le16(IEEE80211_FCTL_TODS
);
3987 fastrx
.internal_forward
=
3988 !(sdata
->flags
& IEEE80211_SDATA_DONT_BRIDGE_PACKETS
) &&
3989 (sdata
->vif
.type
!= NL80211_IFTYPE_AP_VLAN
||
3990 !sdata
->u
.vlan
.sta
);
3992 if (sdata
->vif
.type
== NL80211_IFTYPE_AP_VLAN
&&
3993 sdata
->u
.vlan
.sta
) {
3994 fastrx
.expected_ds_bits
|=
3995 cpu_to_le16(IEEE80211_FCTL_FROMDS
);
3996 fastrx
.sa_offs
= offsetof(struct ieee80211_hdr
, addr4
);
3997 fastrx
.internal_forward
= 0;
4005 if (!test_sta_flag(sta
, WLAN_STA_AUTHORIZED
))
4009 key
= rcu_dereference(sta
->ptk
[sta
->ptk_idx
]);
4011 switch (key
->conf
.cipher
) {
4012 case WLAN_CIPHER_SUITE_TKIP
:
4013 /* we don't want to deal with MMIC in fast-rx */
4015 case WLAN_CIPHER_SUITE_CCMP
:
4016 case WLAN_CIPHER_SUITE_CCMP_256
:
4017 case WLAN_CIPHER_SUITE_GCMP
:
4018 case WLAN_CIPHER_SUITE_GCMP_256
:
4021 /* we also don't want to deal with WEP or cipher scheme
4022 * since those require looking up the key idx in the
4023 * frame, rather than assuming the PTK is used
4024 * (we need to revisit this once we implement the real
4025 * PTK index, which is now valid in the spec, but we
4026 * haven't implemented that part yet)
4032 fastrx
.icv_len
= key
->conf
.icv_len
;
4039 __release(check_fast_rx
);
4042 new = kmemdup(&fastrx
, sizeof(fastrx
), GFP_KERNEL
);
4044 spin_lock_bh(&sta
->lock
);
4045 old
= rcu_dereference_protected(sta
->fast_rx
, true);
4046 rcu_assign_pointer(sta
->fast_rx
, new);
4047 spin_unlock_bh(&sta
->lock
);
4050 kfree_rcu(old
, rcu_head
);
4053 void ieee80211_clear_fast_rx(struct sta_info
*sta
)
4055 struct ieee80211_fast_rx
*old
;
4057 spin_lock_bh(&sta
->lock
);
4058 old
= rcu_dereference_protected(sta
->fast_rx
, true);
4059 RCU_INIT_POINTER(sta
->fast_rx
, NULL
);
4060 spin_unlock_bh(&sta
->lock
);
4063 kfree_rcu(old
, rcu_head
);
4066 void __ieee80211_check_fast_rx_iface(struct ieee80211_sub_if_data
*sdata
)
4068 struct ieee80211_local
*local
= sdata
->local
;
4069 struct sta_info
*sta
;
4071 lockdep_assert_held(&local
->sta_mtx
);
4073 list_for_each_entry_rcu(sta
, &local
->sta_list
, list
) {
4074 if (sdata
!= sta
->sdata
&&
4075 (!sta
->sdata
->bss
|| sta
->sdata
->bss
!= sdata
->bss
))
4077 ieee80211_check_fast_rx(sta
);
4081 void ieee80211_check_fast_rx_iface(struct ieee80211_sub_if_data
*sdata
)
4083 struct ieee80211_local
*local
= sdata
->local
;
4085 mutex_lock(&local
->sta_mtx
);
4086 __ieee80211_check_fast_rx_iface(sdata
);
4087 mutex_unlock(&local
->sta_mtx
);
4090 static bool ieee80211_invoke_fast_rx(struct ieee80211_rx_data
*rx
,
4091 struct ieee80211_fast_rx
*fast_rx
)
4093 struct sk_buff
*skb
= rx
->skb
;
4094 struct ieee80211_hdr
*hdr
= (void *)skb
->data
;
4095 struct ieee80211_rx_status
*status
= IEEE80211_SKB_RXCB(skb
);
4096 struct sta_info
*sta
= rx
->sta
;
4097 int orig_len
= skb
->len
;
4098 int hdrlen
= ieee80211_hdrlen(hdr
->frame_control
);
4099 int snap_offs
= hdrlen
;
4101 u8 snap
[sizeof(rfc1042_header
)];
4103 } *payload
__aligned(2);
4107 } addrs
__aligned(2);
4108 struct ieee80211_sta_rx_stats
*stats
= &sta
->rx_stats
;
4110 if (fast_rx
->uses_rss
)
4111 stats
= this_cpu_ptr(sta
->pcpu_rx_stats
);
4113 /* for parallel-rx, we need to have DUP_VALIDATED, otherwise we write
4114 * to a common data structure; drivers can implement that per queue
4115 * but we don't have that information in mac80211
4117 if (!(status
->flag
& RX_FLAG_DUP_VALIDATED
))
4120 #define FAST_RX_CRYPT_FLAGS (RX_FLAG_PN_VALIDATED | RX_FLAG_DECRYPTED)
4122 /* If using encryption, we also need to have:
4123 * - PN_VALIDATED: similar, but the implementation is tricky
4124 * - DECRYPTED: necessary for PN_VALIDATED
4127 (status
->flag
& FAST_RX_CRYPT_FLAGS
) != FAST_RX_CRYPT_FLAGS
)
4130 if (unlikely(!ieee80211_is_data_present(hdr
->frame_control
)))
4133 if (unlikely(ieee80211_is_frag(hdr
)))
4136 /* Since our interface address cannot be multicast, this
4137 * implicitly also rejects multicast frames without the
4140 * We shouldn't get any *data* frames not addressed to us
4141 * (AP mode will accept multicast *management* frames), but
4142 * punting here will make it go through the full checks in
4143 * ieee80211_accept_frame().
4145 if (!ether_addr_equal(fast_rx
->vif_addr
, hdr
->addr1
))
4148 if ((hdr
->frame_control
& cpu_to_le16(IEEE80211_FCTL_FROMDS
|
4149 IEEE80211_FCTL_TODS
)) !=
4150 fast_rx
->expected_ds_bits
)
4153 /* assign the key to drop unencrypted frames (later)
4154 * and strip the IV/MIC if necessary
4156 if (fast_rx
->key
&& !(status
->flag
& RX_FLAG_IV_STRIPPED
)) {
4157 /* GCMP header length is the same */
4158 snap_offs
+= IEEE80211_CCMP_HDR_LEN
;
4161 if (!(status
->rx_flags
& IEEE80211_RX_AMSDU
)) {
4162 if (!pskb_may_pull(skb
, snap_offs
+ sizeof(*payload
)))
4165 payload
= (void *)(skb
->data
+ snap_offs
);
4167 if (!ether_addr_equal(payload
->snap
, fast_rx
->rfc1042_hdr
))
4170 /* Don't handle these here since they require special code.
4171 * Accept AARP and IPX even though they should come with a
4172 * bridge-tunnel header - but if we get them this way then
4173 * there's little point in discarding them.
4175 if (unlikely(payload
->proto
== cpu_to_be16(ETH_P_TDLS
) ||
4176 payload
->proto
== fast_rx
->control_port_protocol
))
4180 /* after this point, don't punt to the slowpath! */
4182 if (rx
->key
&& !(status
->flag
& RX_FLAG_MIC_STRIPPED
) &&
4183 pskb_trim(skb
, skb
->len
- fast_rx
->icv_len
))
4186 if (unlikely(fast_rx
->sta_notify
)) {
4187 ieee80211_sta_rx_notify(rx
->sdata
, hdr
);
4188 fast_rx
->sta_notify
= false;
4191 /* statistics part of ieee80211_rx_h_sta_process() */
4192 if (!(status
->flag
& RX_FLAG_NO_SIGNAL_VAL
)) {
4193 stats
->last_signal
= status
->signal
;
4194 if (!fast_rx
->uses_rss
)
4195 ewma_signal_add(&sta
->rx_stats_avg
.signal
,
4199 if (status
->chains
) {
4202 stats
->chains
= status
->chains
;
4203 for (i
= 0; i
< ARRAY_SIZE(status
->chain_signal
); i
++) {
4204 int signal
= status
->chain_signal
[i
];
4206 if (!(status
->chains
& BIT(i
)))
4209 stats
->chain_signal_last
[i
] = signal
;
4210 if (!fast_rx
->uses_rss
)
4211 ewma_signal_add(&sta
->rx_stats_avg
.chain_signal
[i
],
4215 /* end of statistics */
4217 if (rx
->key
&& !ieee80211_has_protected(hdr
->frame_control
))
4220 if (status
->rx_flags
& IEEE80211_RX_AMSDU
) {
4221 if (__ieee80211_rx_h_amsdu(rx
, snap_offs
- hdrlen
) !=
4228 stats
->last_rx
= jiffies
;
4229 stats
->last_rate
= sta_stats_encode_rate(status
);
4234 /* do the header conversion - first grab the addresses */
4235 ether_addr_copy(addrs
.da
, skb
->data
+ fast_rx
->da_offs
);
4236 ether_addr_copy(addrs
.sa
, skb
->data
+ fast_rx
->sa_offs
);
4237 /* remove the SNAP but leave the ethertype */
4238 skb_pull(skb
, snap_offs
+ sizeof(rfc1042_header
));
4239 /* push the addresses in front */
4240 memcpy(skb_push(skb
, sizeof(addrs
)), &addrs
, sizeof(addrs
));
4242 skb
->dev
= fast_rx
->dev
;
4244 ieee80211_rx_stats(fast_rx
->dev
, skb
->len
);
4246 /* The seqno index has the same property as needed
4247 * for the rx_msdu field, i.e. it is IEEE80211_NUM_TIDS
4248 * for non-QoS-data frames. Here we know it's a data
4249 * frame, so count MSDUs.
4251 u64_stats_update_begin(&stats
->syncp
);
4252 stats
->msdu
[rx
->seqno_idx
]++;
4253 stats
->bytes
+= orig_len
;
4254 u64_stats_update_end(&stats
->syncp
);
4256 if (fast_rx
->internal_forward
) {
4257 struct sk_buff
*xmit_skb
= NULL
;
4258 if (is_multicast_ether_addr(addrs
.da
)) {
4259 xmit_skb
= skb_copy(skb
, GFP_ATOMIC
);
4260 } else if (!ether_addr_equal(addrs
.da
, addrs
.sa
) &&
4261 sta_info_get(rx
->sdata
, addrs
.da
)) {
4268 * Send to wireless media and increase priority by 256
4269 * to keep the received priority instead of
4270 * reclassifying the frame (see cfg80211_classify8021d).
4272 xmit_skb
->priority
+= 256;
4273 xmit_skb
->protocol
= htons(ETH_P_802_3
);
4274 skb_reset_network_header(xmit_skb
);
4275 skb_reset_mac_header(xmit_skb
);
4276 dev_queue_xmit(xmit_skb
);
4283 /* deliver to local stack */
4284 skb
->protocol
= eth_type_trans(skb
, fast_rx
->dev
);
4285 memset(skb
->cb
, 0, sizeof(skb
->cb
));
4287 napi_gro_receive(rx
->napi
, skb
);
4289 netif_receive_skb(skb
);
4299 * This function returns whether or not the SKB
4300 * was destined for RX processing or not, which,
4301 * if consume is true, is equivalent to whether
4302 * or not the skb was consumed.
4304 static bool ieee80211_prepare_and_rx_handle(struct ieee80211_rx_data
*rx
,
4305 struct sk_buff
*skb
, bool consume
)
4307 struct ieee80211_local
*local
= rx
->local
;
4308 struct ieee80211_sub_if_data
*sdata
= rx
->sdata
;
4312 /* See if we can do fast-rx; if we have to copy we already lost,
4313 * so punt in that case. We should never have to deliver a data
4314 * frame to multiple interfaces anyway.
4316 * We skip the ieee80211_accept_frame() call and do the necessary
4317 * checking inside ieee80211_invoke_fast_rx().
4319 if (consume
&& rx
->sta
) {
4320 struct ieee80211_fast_rx
*fast_rx
;
4322 fast_rx
= rcu_dereference(rx
->sta
->fast_rx
);
4323 if (fast_rx
&& ieee80211_invoke_fast_rx(rx
, fast_rx
))
4327 if (!ieee80211_accept_frame(rx
))
4331 skb
= skb_copy(skb
, GFP_ATOMIC
);
4333 if (net_ratelimit())
4334 wiphy_debug(local
->hw
.wiphy
,
4335 "failed to copy skb for %s\n",
4343 ieee80211_invoke_rx_handlers(rx
);
4348 * This is the actual Rx frames handler. as it belongs to Rx path it must
4349 * be called with rcu_read_lock protection.
4351 static void __ieee80211_rx_handle_packet(struct ieee80211_hw
*hw
,
4352 struct ieee80211_sta
*pubsta
,
4353 struct sk_buff
*skb
,
4354 struct napi_struct
*napi
)
4356 struct ieee80211_local
*local
= hw_to_local(hw
);
4357 struct ieee80211_sub_if_data
*sdata
;
4358 struct ieee80211_hdr
*hdr
;
4360 struct ieee80211_rx_data rx
;
4361 struct ieee80211_sub_if_data
*prev
;
4362 struct rhlist_head
*tmp
;
4365 fc
= ((struct ieee80211_hdr
*)skb
->data
)->frame_control
;
4366 memset(&rx
, 0, sizeof(rx
));
4371 if (ieee80211_is_data(fc
) || ieee80211_is_mgmt(fc
))
4372 I802_DEBUG_INC(local
->dot11ReceivedFragmentCount
);
4374 if (ieee80211_is_mgmt(fc
)) {
4375 /* drop frame if too short for header */
4376 if (skb
->len
< ieee80211_hdrlen(fc
))
4379 err
= skb_linearize(skb
);
4381 err
= !pskb_may_pull(skb
, ieee80211_hdrlen(fc
));
4389 hdr
= (struct ieee80211_hdr
*)skb
->data
;
4390 ieee80211_parse_qos(&rx
);
4391 ieee80211_verify_alignment(&rx
);
4393 if (unlikely(ieee80211_is_probe_resp(hdr
->frame_control
) ||
4394 ieee80211_is_beacon(hdr
->frame_control
)))
4395 ieee80211_scan_rx(local
, skb
);
4397 if (ieee80211_is_data(fc
)) {
4398 struct sta_info
*sta
, *prev_sta
;
4401 rx
.sta
= container_of(pubsta
, struct sta_info
, sta
);
4402 rx
.sdata
= rx
.sta
->sdata
;
4403 if (ieee80211_prepare_and_rx_handle(&rx
, skb
, true))
4410 for_each_sta_info(local
, hdr
->addr2
, sta
, tmp
) {
4417 rx
.sdata
= prev_sta
->sdata
;
4418 ieee80211_prepare_and_rx_handle(&rx
, skb
, false);
4425 rx
.sdata
= prev_sta
->sdata
;
4427 if (ieee80211_prepare_and_rx_handle(&rx
, skb
, true))
4435 list_for_each_entry_rcu(sdata
, &local
->interfaces
, list
) {
4436 if (!ieee80211_sdata_running(sdata
))
4439 if (sdata
->vif
.type
== NL80211_IFTYPE_MONITOR
||
4440 sdata
->vif
.type
== NL80211_IFTYPE_AP_VLAN
)
4444 * frame is destined for this interface, but if it's
4445 * not also for the previous one we handle that after
4446 * the loop to avoid copying the SKB once too much
4454 rx
.sta
= sta_info_get_bss(prev
, hdr
->addr2
);
4456 ieee80211_prepare_and_rx_handle(&rx
, skb
, false);
4462 rx
.sta
= sta_info_get_bss(prev
, hdr
->addr2
);
4465 if (ieee80211_prepare_and_rx_handle(&rx
, skb
, true))
4474 * This is the receive path handler. It is called by a low level driver when an
4475 * 802.11 MPDU is received from the hardware.
4477 void ieee80211_rx_napi(struct ieee80211_hw
*hw
, struct ieee80211_sta
*pubsta
,
4478 struct sk_buff
*skb
, struct napi_struct
*napi
)
4480 struct ieee80211_local
*local
= hw_to_local(hw
);
4481 struct ieee80211_rate
*rate
= NULL
;
4482 struct ieee80211_supported_band
*sband
;
4483 struct ieee80211_rx_status
*status
= IEEE80211_SKB_RXCB(skb
);
4485 WARN_ON_ONCE(softirq_count() == 0);
4487 if (WARN_ON(status
->band
>= NUM_NL80211_BANDS
))
4490 sband
= local
->hw
.wiphy
->bands
[status
->band
];
4491 if (WARN_ON(!sband
))
4495 * If we're suspending, it is possible although not too likely
4496 * that we'd be receiving frames after having already partially
4497 * quiesced the stack. We can't process such frames then since
4498 * that might, for example, cause stations to be added or other
4499 * driver callbacks be invoked.
4501 if (unlikely(local
->quiescing
|| local
->suspended
))
4504 /* We might be during a HW reconfig, prevent Rx for the same reason */
4505 if (unlikely(local
->in_reconfig
))
4509 * The same happens when we're not even started,
4510 * but that's worth a warning.
4512 if (WARN_ON(!local
->started
))
4515 if (likely(!(status
->flag
& RX_FLAG_FAILED_PLCP_CRC
))) {
4517 * Validate the rate, unless a PLCP error means that
4518 * we probably can't have a valid rate here anyway.
4521 switch (status
->encoding
) {
4524 * rate_idx is MCS index, which can be [0-76]
4527 * http://wireless.kernel.org/en/developers/Documentation/ieee80211/802.11n
4529 * Anything else would be some sort of driver or
4530 * hardware error. The driver should catch hardware
4533 if (WARN(status
->rate_idx
> 76,
4534 "Rate marked as an HT rate but passed "
4535 "status->rate_idx is not "
4536 "an MCS index [0-76]: %d (0x%02x)\n",
4542 if (WARN_ONCE(status
->rate_idx
> 9 ||
4545 "Rate marked as a VHT rate but data is invalid: MCS: %d, NSS: %d\n",
4546 status
->rate_idx
, status
->nss
))
4550 if (WARN_ONCE(status
->rate_idx
> 11 ||
4553 "Rate marked as an HE rate but data is invalid: MCS: %d, NSS: %d\n",
4554 status
->rate_idx
, status
->nss
))
4561 if (WARN_ON(status
->rate_idx
>= sband
->n_bitrates
))
4563 rate
= &sband
->bitrates
[status
->rate_idx
];
4567 status
->rx_flags
= 0;
4570 * key references and virtual interfaces are protected using RCU
4571 * and this requires that we are in a read-side RCU section during
4572 * receive processing
4577 * Frames with failed FCS/PLCP checksum are not returned,
4578 * all other frames are returned without radiotap header
4579 * if it was previously present.
4580 * Also, frames with less than 16 bytes are dropped.
4582 skb
= ieee80211_rx_monitor(local
, skb
, rate
);
4588 ieee80211_tpt_led_trig_rx(local
,
4589 ((struct ieee80211_hdr
*)skb
->data
)->frame_control
,
4592 __ieee80211_rx_handle_packet(hw
, pubsta
, skb
, napi
);
4600 EXPORT_SYMBOL(ieee80211_rx_napi
);
4602 /* This is a version of the rx handler that can be called from hard irq
4603 * context. Post the skb on the queue and schedule the tasklet */
4604 void ieee80211_rx_irqsafe(struct ieee80211_hw
*hw
, struct sk_buff
*skb
)
4606 struct ieee80211_local
*local
= hw_to_local(hw
);
4608 BUILD_BUG_ON(sizeof(struct ieee80211_rx_status
) > sizeof(skb
->cb
));
4610 skb
->pkt_type
= IEEE80211_RX_MSG
;
4611 skb_queue_tail(&local
->skb_queue
, skb
);
4612 tasklet_schedule(&local
->tasklet
);
4614 EXPORT_SYMBOL(ieee80211_rx_irqsafe
);