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 Johannes Berg <johannes@sipsolutions.net>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
12 #include <linux/kernel.h>
13 #include <linux/skbuff.h>
14 #include <linux/netdevice.h>
15 #include <linux/etherdevice.h>
16 #include <linux/rcupdate.h>
17 #include <net/mac80211.h>
18 #include <net/ieee80211_radiotap.h>
20 #include "ieee80211_i.h"
21 #include "ieee80211_led.h"
27 u8
ieee80211_sta_manage_reorder_buf(struct ieee80211_hw
*hw
,
28 struct tid_ampdu_rx
*tid_agg_rx
,
29 struct sk_buff
*skb
, u16 mpdu_seq_num
,
32 * monitor mode reception
34 * This function cleans up the SKB, i.e. it removes all the stuff
35 * only useful for monitoring.
37 static struct sk_buff
*remove_monitor_info(struct ieee80211_local
*local
,
41 skb_pull(skb
, rtap_len
);
43 if (local
->hw
.flags
& IEEE80211_HW_RX_INCLUDES_FCS
) {
44 if (likely(skb
->len
> FCS_LEN
))
45 skb_trim(skb
, skb
->len
- FCS_LEN
);
57 static inline int should_drop_frame(struct ieee80211_rx_status
*status
,
62 struct ieee80211_hdr
*hdr
= (struct ieee80211_hdr
*) skb
->data
;
64 if (status
->flag
& (RX_FLAG_FAILED_FCS_CRC
| RX_FLAG_FAILED_PLCP_CRC
))
66 if (unlikely(skb
->len
< 16 + present_fcs_len
+ radiotap_len
))
68 if (((hdr
->frame_control
& cpu_to_le16(IEEE80211_FCTL_FTYPE
)) ==
69 cpu_to_le16(IEEE80211_FTYPE_CTL
)) &&
70 ((hdr
->frame_control
& cpu_to_le16(IEEE80211_FCTL_STYPE
)) !=
71 cpu_to_le16(IEEE80211_STYPE_PSPOLL
)) &&
72 ((hdr
->frame_control
& cpu_to_le16(IEEE80211_FCTL_STYPE
)) !=
73 cpu_to_le16(IEEE80211_STYPE_BACK_REQ
)))
79 * This function copies a received frame to all monitor interfaces and
80 * returns a cleaned-up SKB that no longer includes the FCS nor the
81 * radiotap header the driver might have added.
83 static struct sk_buff
*
84 ieee80211_rx_monitor(struct ieee80211_local
*local
, struct sk_buff
*origskb
,
85 struct ieee80211_rx_status
*status
)
87 struct ieee80211_sub_if_data
*sdata
;
88 struct ieee80211_rate
*rate
;
89 int needed_headroom
= 0;
90 struct ieee80211_radiotap_header
*rthdr
;
91 __le64
*rttsft
= NULL
;
92 struct ieee80211_rtap_fixed_data
{
98 u8 padding_for_rxflags
;
100 } __attribute__ ((packed
)) *rtfixed
;
101 struct sk_buff
*skb
, *skb2
;
102 struct net_device
*prev_dev
= NULL
;
103 int present_fcs_len
= 0;
107 * First, we may need to make a copy of the skb because
108 * (1) we need to modify it for radiotap (if not present), and
109 * (2) the other RX handlers will modify the skb we got.
111 * We don't need to, of course, if we aren't going to return
112 * the SKB because it has a bad FCS/PLCP checksum.
114 if (status
->flag
& RX_FLAG_RADIOTAP
)
115 rtap_len
= ieee80211_get_radiotap_len(origskb
->data
);
117 /* room for radiotap header, always present fields and TSFT */
118 needed_headroom
= sizeof(*rthdr
) + sizeof(*rtfixed
) + 8;
120 if (local
->hw
.flags
& IEEE80211_HW_RX_INCLUDES_FCS
)
121 present_fcs_len
= FCS_LEN
;
123 if (!local
->monitors
) {
124 if (should_drop_frame(status
, origskb
, present_fcs_len
,
126 dev_kfree_skb(origskb
);
130 return remove_monitor_info(local
, origskb
, rtap_len
);
133 if (should_drop_frame(status
, origskb
, present_fcs_len
, rtap_len
)) {
134 /* only need to expand headroom if necessary */
139 * This shouldn't trigger often because most devices have an
140 * RX header they pull before we get here, and that should
141 * be big enough for our radiotap information. We should
142 * probably export the length to drivers so that we can have
143 * them allocate enough headroom to start with.
145 if (skb_headroom(skb
) < needed_headroom
&&
146 pskb_expand_head(skb
, needed_headroom
, 0, GFP_ATOMIC
)) {
152 * Need to make a copy and possibly remove radiotap header
153 * and FCS from the original.
155 skb
= skb_copy_expand(origskb
, needed_headroom
, 0, GFP_ATOMIC
);
157 origskb
= remove_monitor_info(local
, origskb
, rtap_len
);
163 /* if necessary, prepend radiotap information */
164 if (!(status
->flag
& RX_FLAG_RADIOTAP
)) {
165 rtfixed
= (void *) skb_push(skb
, sizeof(*rtfixed
));
166 rtap_len
= sizeof(*rthdr
) + sizeof(*rtfixed
);
167 if (status
->flag
& RX_FLAG_TSFT
) {
168 rttsft
= (void *) skb_push(skb
, sizeof(*rttsft
));
171 rthdr
= (void *) skb_push(skb
, sizeof(*rthdr
));
172 memset(rthdr
, 0, sizeof(*rthdr
));
173 memset(rtfixed
, 0, sizeof(*rtfixed
));
175 cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS
) |
176 (1 << IEEE80211_RADIOTAP_RATE
) |
177 (1 << IEEE80211_RADIOTAP_CHANNEL
) |
178 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL
) |
179 (1 << IEEE80211_RADIOTAP_RX_FLAGS
));
181 if (local
->hw
.flags
& IEEE80211_HW_RX_INCLUDES_FCS
)
182 rtfixed
->flags
|= IEEE80211_RADIOTAP_F_FCS
;
185 *rttsft
= cpu_to_le64(status
->mactime
);
187 cpu_to_le32(1 << IEEE80211_RADIOTAP_TSFT
);
190 /* FIXME: when radiotap gets a 'bad PLCP' flag use it here */
191 rtfixed
->rx_flags
= 0;
193 (RX_FLAG_FAILED_FCS_CRC
| RX_FLAG_FAILED_PLCP_CRC
))
195 cpu_to_le16(IEEE80211_RADIOTAP_F_RX_BADFCS
);
197 rate
= ieee80211_get_rate(local
, status
->phymode
,
200 rtfixed
->rate
= rate
->rate
/ 5;
202 rtfixed
->chan_freq
= cpu_to_le16(status
->freq
);
204 if (status
->phymode
== MODE_IEEE80211A
)
205 rtfixed
->chan_flags
=
206 cpu_to_le16(IEEE80211_CHAN_OFDM
|
207 IEEE80211_CHAN_5GHZ
);
209 rtfixed
->chan_flags
=
210 cpu_to_le16(IEEE80211_CHAN_DYN
|
211 IEEE80211_CHAN_2GHZ
);
213 rtfixed
->antsignal
= status
->ssi
;
214 rthdr
->it_len
= cpu_to_le16(rtap_len
);
217 skb_reset_mac_header(skb
);
218 skb
->ip_summed
= CHECKSUM_UNNECESSARY
;
219 skb
->pkt_type
= PACKET_OTHERHOST
;
220 skb
->protocol
= htons(ETH_P_802_2
);
222 list_for_each_entry_rcu(sdata
, &local
->interfaces
, list
) {
223 if (!netif_running(sdata
->dev
))
226 if (sdata
->type
!= IEEE80211_IF_TYPE_MNTR
)
230 skb2
= skb_clone(skb
, GFP_ATOMIC
);
232 skb2
->dev
= prev_dev
;
237 prev_dev
= sdata
->dev
;
238 sdata
->dev
->stats
.rx_packets
++;
239 sdata
->dev
->stats
.rx_bytes
+= skb
->len
;
254 * these don't have dev/sdata fields in the rx data
255 * The sta value should also not be used because it may
256 * be NULL even though a STA (in IBSS mode) will be added.
259 static ieee80211_txrx_result
260 ieee80211_rx_h_parse_qos(struct ieee80211_txrx_data
*rx
)
262 u8
*data
= rx
->skb
->data
;
265 /* does the frame have a qos control field? */
266 if (WLAN_FC_IS_QOS_DATA(rx
->fc
)) {
267 u8
*qc
= data
+ ieee80211_get_hdrlen(rx
->fc
) - QOS_CONTROL_LEN
;
268 /* frame has qos control */
269 tid
= qc
[0] & QOS_CONTROL_TID_MASK
;
270 if (qc
[0] & IEEE80211_QOS_CONTROL_A_MSDU_PRESENT
)
271 rx
->flags
|= IEEE80211_TXRXD_RX_AMSDU
;
273 rx
->flags
&= ~IEEE80211_TXRXD_RX_AMSDU
;
275 if (unlikely((rx
->fc
& IEEE80211_FCTL_FTYPE
) == IEEE80211_FTYPE_MGMT
)) {
276 /* Separate TID for management frames */
277 tid
= NUM_RX_DATA_QUEUES
- 1;
279 /* no qos control present */
280 tid
= 0; /* 802.1d - Best Effort */
284 I802_DEBUG_INC(rx
->local
->wme_rx_queue
[tid
]);
285 /* only a debug counter, sta might not be assigned properly yet */
287 I802_DEBUG_INC(rx
->sta
->wme_rx_queue
[tid
]);
289 rx
->u
.rx
.queue
= tid
;
290 /* Set skb->priority to 1d tag if highest order bit of TID is not set.
291 * For now, set skb->priority to 0 for other cases. */
292 rx
->skb
->priority
= (tid
> 7) ? 0 : tid
;
294 return TXRX_CONTINUE
;
298 u32
ieee80211_rx_load_stats(struct ieee80211_local
*local
,
300 struct ieee80211_rx_status
*status
)
302 struct ieee80211_hdr
*hdr
= (struct ieee80211_hdr
*) skb
->data
;
303 u32 load
= 0, hdrtime
;
304 struct ieee80211_rate
*rate
;
305 struct ieee80211_hw_mode
*mode
= local
->hw
.conf
.mode
;
308 /* Estimate total channel use caused by this frame */
310 if (unlikely(mode
->num_rates
< 0))
311 return TXRX_CONTINUE
;
313 rate
= &mode
->rates
[0];
314 for (i
= 0; i
< mode
->num_rates
; i
++) {
315 if (mode
->rates
[i
].val
== status
->rate
) {
316 rate
= &mode
->rates
[i
];
321 /* 1 bit at 1 Mbit/s takes 1 usec; in channel_use values,
322 * 1 usec = 1/8 * (1080 / 10) = 13.5 */
324 if (mode
->mode
== MODE_IEEE80211A
||
325 (mode
->mode
== MODE_IEEE80211G
&&
326 rate
->flags
& IEEE80211_RATE_ERP
))
327 hdrtime
= CHAN_UTIL_HDR_SHORT
;
329 hdrtime
= CHAN_UTIL_HDR_LONG
;
332 if (!is_multicast_ether_addr(hdr
->addr1
))
335 load
+= skb
->len
* rate
->rate_inv
;
337 /* Divide channel_use by 8 to avoid wrapping around the counter */
338 load
>>= CHAN_UTIL_SHIFT
;
343 ieee80211_rx_handler ieee80211_rx_pre_handlers
[] =
345 ieee80211_rx_h_parse_qos
,
351 static ieee80211_txrx_result
352 ieee80211_rx_h_if_stats(struct ieee80211_txrx_data
*rx
)
355 rx
->sta
->channel_use_raw
+= rx
->u
.rx
.load
;
356 rx
->sdata
->channel_use_raw
+= rx
->u
.rx
.load
;
357 return TXRX_CONTINUE
;
360 static ieee80211_txrx_result
361 ieee80211_rx_h_passive_scan(struct ieee80211_txrx_data
*rx
)
363 struct ieee80211_local
*local
= rx
->local
;
364 struct sk_buff
*skb
= rx
->skb
;
366 if (unlikely(local
->sta_hw_scanning
))
367 return ieee80211_sta_rx_scan(rx
->dev
, skb
, rx
->u
.rx
.status
);
369 if (unlikely(local
->sta_sw_scanning
)) {
370 /* drop all the other packets during a software scan anyway */
371 if (ieee80211_sta_rx_scan(rx
->dev
, skb
, rx
->u
.rx
.status
)
377 if (unlikely(rx
->flags
& IEEE80211_TXRXD_RXIN_SCAN
)) {
378 /* scanning finished during invoking of handlers */
379 I802_DEBUG_INC(local
->rx_handlers_drop_passive_scan
);
383 return TXRX_CONTINUE
;
386 static ieee80211_txrx_result
387 ieee80211_rx_h_check(struct ieee80211_txrx_data
*rx
)
389 struct ieee80211_hdr
*hdr
;
390 hdr
= (struct ieee80211_hdr
*) rx
->skb
->data
;
392 /* Drop duplicate 802.11 retransmissions (IEEE 802.11 Chap. 9.2.9) */
393 if (rx
->sta
&& !is_multicast_ether_addr(hdr
->addr1
)) {
394 if (unlikely(rx
->fc
& IEEE80211_FCTL_RETRY
&&
395 rx
->sta
->last_seq_ctrl
[rx
->u
.rx
.queue
] ==
397 if (rx
->flags
& IEEE80211_TXRXD_RXRA_MATCH
) {
398 rx
->local
->dot11FrameDuplicateCount
++;
399 rx
->sta
->num_duplicates
++;
403 rx
->sta
->last_seq_ctrl
[rx
->u
.rx
.queue
] = hdr
->seq_ctrl
;
406 if (unlikely(rx
->skb
->len
< 16)) {
407 I802_DEBUG_INC(rx
->local
->rx_handlers_drop_short
);
411 /* Drop disallowed frame classes based on STA auth/assoc state;
412 * IEEE 802.11, Chap 5.5.
414 * 80211.o does filtering only based on association state, i.e., it
415 * drops Class 3 frames from not associated stations. hostapd sends
416 * deauth/disassoc frames when needed. In addition, hostapd is
417 * responsible for filtering on both auth and assoc states.
419 if (unlikely(((rx
->fc
& IEEE80211_FCTL_FTYPE
) == IEEE80211_FTYPE_DATA
||
420 ((rx
->fc
& IEEE80211_FCTL_FTYPE
) == IEEE80211_FTYPE_CTL
&&
421 (rx
->fc
& IEEE80211_FCTL_STYPE
) == IEEE80211_STYPE_PSPOLL
)) &&
422 rx
->sdata
->type
!= IEEE80211_IF_TYPE_IBSS
&&
423 (!rx
->sta
|| !(rx
->sta
->flags
& WLAN_STA_ASSOC
)))) {
424 if ((!(rx
->fc
& IEEE80211_FCTL_FROMDS
) &&
425 !(rx
->fc
& IEEE80211_FCTL_TODS
) &&
426 (rx
->fc
& IEEE80211_FCTL_FTYPE
) == IEEE80211_FTYPE_DATA
)
427 || !(rx
->flags
& IEEE80211_TXRXD_RXRA_MATCH
)) {
428 /* Drop IBSS frames and frames for other hosts
436 return TXRX_CONTINUE
;
440 static ieee80211_txrx_result
441 ieee80211_rx_h_decrypt(struct ieee80211_txrx_data
*rx
)
443 struct ieee80211_hdr
*hdr
= (struct ieee80211_hdr
*) rx
->skb
->data
;
446 ieee80211_txrx_result result
= TXRX_DROP
;
447 struct ieee80211_key
*stakey
= NULL
;
452 * There are three types of keys:
454 * - PTK (pairwise keys)
455 * - STK (station-to-station pairwise keys)
457 * When selecting a key, we have to distinguish between multicast
458 * (including broadcast) and unicast frames, the latter can only
459 * use PTKs and STKs while the former always use GTKs. Unless, of
460 * course, actual WEP keys ("pre-RSNA") are used, then unicast
461 * frames can also use key indizes like GTKs. Hence, if we don't
462 * have a PTK/STK we check the key index for a WEP key.
464 * Note that in a regular BSS, multicast frames are sent by the
465 * AP only, associated stations unicast the frame to the AP first
466 * which then multicasts it on their behalf.
468 * There is also a slight problem in IBSS mode: GTKs are negotiated
469 * with each station, that is something we don't currently handle.
470 * The spec seems to expect that one negotiates the same key with
471 * every station but there's no such requirement; VLANs could be
475 if (!(rx
->fc
& IEEE80211_FCTL_PROTECTED
))
476 return TXRX_CONTINUE
;
479 * No point in finding a key and decrypting if the frame is neither
480 * addressed to us nor a multicast frame.
482 if (!(rx
->flags
& IEEE80211_TXRXD_RXRA_MATCH
))
483 return TXRX_CONTINUE
;
486 stakey
= rcu_dereference(rx
->sta
->key
);
488 if (!is_multicast_ether_addr(hdr
->addr1
) && stakey
) {
492 * The device doesn't give us the IV so we won't be
493 * able to look up the key. That's ok though, we
494 * don't need to decrypt the frame, we just won't
495 * be able to keep statistics accurate.
496 * Except for key threshold notifications, should
497 * we somehow allow the driver to tell us which key
498 * the hardware used if this flag is set?
500 if ((rx
->u
.rx
.status
->flag
& RX_FLAG_DECRYPTED
) &&
501 (rx
->u
.rx
.status
->flag
& RX_FLAG_IV_STRIPPED
))
502 return TXRX_CONTINUE
;
504 hdrlen
= ieee80211_get_hdrlen(rx
->fc
);
506 if (rx
->skb
->len
< 8 + hdrlen
)
507 return TXRX_DROP
; /* TODO: count this? */
510 * no need to call ieee80211_wep_get_keyidx,
511 * it verifies a bunch of things we've done already
513 keyidx
= rx
->skb
->data
[hdrlen
+ 3] >> 6;
515 rx
->key
= rcu_dereference(rx
->sdata
->keys
[keyidx
]);
518 * RSNA-protected unicast frames should always be sent with
519 * pairwise or station-to-station keys, but for WEP we allow
520 * using a key index as well.
522 if (rx
->key
&& rx
->key
->conf
.alg
!= ALG_WEP
&&
523 !is_multicast_ether_addr(hdr
->addr1
))
528 rx
->key
->tx_rx_count
++;
529 /* TODO: add threshold stuff again */
531 #ifdef CONFIG_MAC80211_DEBUG
533 printk(KERN_DEBUG
"%s: RX protected frame,"
534 " but have no key\n", rx
->dev
->name
);
535 #endif /* CONFIG_MAC80211_DEBUG */
539 /* Check for weak IVs if possible */
540 if (rx
->sta
&& rx
->key
->conf
.alg
== ALG_WEP
&&
541 ((rx
->fc
& IEEE80211_FCTL_FTYPE
) == IEEE80211_FTYPE_DATA
) &&
542 (!(rx
->u
.rx
.status
->flag
& RX_FLAG_IV_STRIPPED
) ||
543 !(rx
->u
.rx
.status
->flag
& RX_FLAG_DECRYPTED
)) &&
544 ieee80211_wep_is_weak_iv(rx
->skb
, rx
->key
))
545 rx
->sta
->wep_weak_iv_count
++;
547 switch (rx
->key
->conf
.alg
) {
549 result
= ieee80211_crypto_wep_decrypt(rx
);
552 result
= ieee80211_crypto_tkip_decrypt(rx
);
555 result
= ieee80211_crypto_ccmp_decrypt(rx
);
559 /* either the frame has been decrypted or will be dropped */
560 rx
->u
.rx
.status
->flag
|= RX_FLAG_DECRYPTED
;
565 static void ap_sta_ps_start(struct net_device
*dev
, struct sta_info
*sta
)
567 struct ieee80211_sub_if_data
*sdata
;
568 DECLARE_MAC_BUF(mac
);
570 sdata
= IEEE80211_DEV_TO_SUB_IF(sta
->dev
);
573 atomic_inc(&sdata
->bss
->num_sta_ps
);
574 sta
->flags
|= WLAN_STA_PS
;
576 #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
577 printk(KERN_DEBUG
"%s: STA %s aid %d enters power save mode\n",
578 dev
->name
, print_mac(mac
, sta
->addr
), sta
->aid
);
579 #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
582 static int ap_sta_ps_end(struct net_device
*dev
, struct sta_info
*sta
)
584 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
587 struct ieee80211_sub_if_data
*sdata
;
588 struct ieee80211_tx_packet_data
*pkt_data
;
589 DECLARE_MAC_BUF(mac
);
591 sdata
= IEEE80211_DEV_TO_SUB_IF(sta
->dev
);
593 atomic_dec(&sdata
->bss
->num_sta_ps
);
594 sta
->flags
&= ~(WLAN_STA_PS
| WLAN_STA_TIM
);
596 if (!skb_queue_empty(&sta
->ps_tx_buf
)) {
597 if (local
->ops
->set_tim
)
598 local
->ops
->set_tim(local_to_hw(local
), sta
->aid
, 0);
600 bss_tim_clear(local
, sdata
->bss
, sta
->aid
);
602 #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
603 printk(KERN_DEBUG
"%s: STA %s aid %d exits power save mode\n",
604 dev
->name
, print_mac(mac
, sta
->addr
), sta
->aid
);
605 #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
606 /* Send all buffered frames to the station */
607 while ((skb
= skb_dequeue(&sta
->tx_filtered
)) != NULL
) {
608 pkt_data
= (struct ieee80211_tx_packet_data
*) skb
->cb
;
610 pkt_data
->flags
|= IEEE80211_TXPD_REQUEUE
;
613 while ((skb
= skb_dequeue(&sta
->ps_tx_buf
)) != NULL
) {
614 pkt_data
= (struct ieee80211_tx_packet_data
*) skb
->cb
;
615 local
->total_ps_buffered
--;
617 #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
618 printk(KERN_DEBUG
"%s: STA %s aid %d send PS frame "
619 "since STA not sleeping anymore\n", dev
->name
,
620 print_mac(mac
, sta
->addr
), sta
->aid
);
621 #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
622 pkt_data
->flags
|= IEEE80211_TXPD_REQUEUE
;
629 static ieee80211_txrx_result
630 ieee80211_rx_h_sta_process(struct ieee80211_txrx_data
*rx
)
632 struct sta_info
*sta
= rx
->sta
;
633 struct net_device
*dev
= rx
->dev
;
634 struct ieee80211_hdr
*hdr
= (struct ieee80211_hdr
*) rx
->skb
->data
;
637 return TXRX_CONTINUE
;
639 /* Update last_rx only for IBSS packets which are for the current
640 * BSSID to avoid keeping the current IBSS network alive in cases where
641 * other STAs are using different BSSID. */
642 if (rx
->sdata
->type
== IEEE80211_IF_TYPE_IBSS
) {
643 u8
*bssid
= ieee80211_get_bssid(hdr
, rx
->skb
->len
,
644 IEEE80211_IF_TYPE_IBSS
);
645 if (compare_ether_addr(bssid
, rx
->sdata
->u
.sta
.bssid
) == 0)
646 sta
->last_rx
= jiffies
;
648 if (!is_multicast_ether_addr(hdr
->addr1
) ||
649 rx
->sdata
->type
== IEEE80211_IF_TYPE_STA
) {
650 /* Update last_rx only for unicast frames in order to prevent
651 * the Probe Request frames (the only broadcast frames from a
652 * STA in infrastructure mode) from keeping a connection alive.
654 sta
->last_rx
= jiffies
;
657 if (!(rx
->flags
& IEEE80211_TXRXD_RXRA_MATCH
))
658 return TXRX_CONTINUE
;
661 sta
->rx_bytes
+= rx
->skb
->len
;
662 sta
->last_rssi
= rx
->u
.rx
.status
->ssi
;
663 sta
->last_signal
= rx
->u
.rx
.status
->signal
;
664 sta
->last_noise
= rx
->u
.rx
.status
->noise
;
666 if (!(rx
->fc
& IEEE80211_FCTL_MOREFRAGS
)) {
667 /* Change STA power saving mode only in the end of a frame
668 * exchange sequence */
669 if ((sta
->flags
& WLAN_STA_PS
) && !(rx
->fc
& IEEE80211_FCTL_PM
))
670 rx
->u
.rx
.sent_ps_buffered
+= ap_sta_ps_end(dev
, sta
);
671 else if (!(sta
->flags
& WLAN_STA_PS
) &&
672 (rx
->fc
& IEEE80211_FCTL_PM
))
673 ap_sta_ps_start(dev
, sta
);
676 /* Drop data::nullfunc frames silently, since they are used only to
677 * control station power saving mode. */
678 if ((rx
->fc
& IEEE80211_FCTL_FTYPE
) == IEEE80211_FTYPE_DATA
&&
679 (rx
->fc
& IEEE80211_FCTL_STYPE
) == IEEE80211_STYPE_NULLFUNC
) {
680 I802_DEBUG_INC(rx
->local
->rx_handlers_drop_nullfunc
);
681 /* Update counter and free packet here to avoid counting this
682 * as a dropped packed. */
684 dev_kfree_skb(rx
->skb
);
688 return TXRX_CONTINUE
;
689 } /* ieee80211_rx_h_sta_process */
691 static inline struct ieee80211_fragment_entry
*
692 ieee80211_reassemble_add(struct ieee80211_sub_if_data
*sdata
,
693 unsigned int frag
, unsigned int seq
, int rx_queue
,
694 struct sk_buff
**skb
)
696 struct ieee80211_fragment_entry
*entry
;
699 idx
= sdata
->fragment_next
;
700 entry
= &sdata
->fragments
[sdata
->fragment_next
++];
701 if (sdata
->fragment_next
>= IEEE80211_FRAGMENT_MAX
)
702 sdata
->fragment_next
= 0;
704 if (!skb_queue_empty(&entry
->skb_list
)) {
705 #ifdef CONFIG_MAC80211_DEBUG
706 struct ieee80211_hdr
*hdr
=
707 (struct ieee80211_hdr
*) entry
->skb_list
.next
->data
;
708 DECLARE_MAC_BUF(mac
);
709 DECLARE_MAC_BUF(mac2
);
710 printk(KERN_DEBUG
"%s: RX reassembly removed oldest "
711 "fragment entry (idx=%d age=%lu seq=%d last_frag=%d "
712 "addr1=%s addr2=%s\n",
713 sdata
->dev
->name
, idx
,
714 jiffies
- entry
->first_frag_time
, entry
->seq
,
715 entry
->last_frag
, print_mac(mac
, hdr
->addr1
),
716 print_mac(mac2
, hdr
->addr2
));
717 #endif /* CONFIG_MAC80211_DEBUG */
718 __skb_queue_purge(&entry
->skb_list
);
721 __skb_queue_tail(&entry
->skb_list
, *skb
); /* no need for locking */
723 entry
->first_frag_time
= jiffies
;
725 entry
->rx_queue
= rx_queue
;
726 entry
->last_frag
= frag
;
728 entry
->extra_len
= 0;
733 static inline struct ieee80211_fragment_entry
*
734 ieee80211_reassemble_find(struct ieee80211_sub_if_data
*sdata
,
735 u16 fc
, unsigned int frag
, unsigned int seq
,
736 int rx_queue
, struct ieee80211_hdr
*hdr
)
738 struct ieee80211_fragment_entry
*entry
;
741 idx
= sdata
->fragment_next
;
742 for (i
= 0; i
< IEEE80211_FRAGMENT_MAX
; i
++) {
743 struct ieee80211_hdr
*f_hdr
;
748 idx
= IEEE80211_FRAGMENT_MAX
- 1;
750 entry
= &sdata
->fragments
[idx
];
751 if (skb_queue_empty(&entry
->skb_list
) || entry
->seq
!= seq
||
752 entry
->rx_queue
!= rx_queue
||
753 entry
->last_frag
+ 1 != frag
)
756 f_hdr
= (struct ieee80211_hdr
*) entry
->skb_list
.next
->data
;
757 f_fc
= le16_to_cpu(f_hdr
->frame_control
);
759 if ((fc
& IEEE80211_FCTL_FTYPE
) != (f_fc
& IEEE80211_FCTL_FTYPE
) ||
760 compare_ether_addr(hdr
->addr1
, f_hdr
->addr1
) != 0 ||
761 compare_ether_addr(hdr
->addr2
, f_hdr
->addr2
) != 0)
764 if (entry
->first_frag_time
+ 2 * HZ
< jiffies
) {
765 __skb_queue_purge(&entry
->skb_list
);
774 static ieee80211_txrx_result
775 ieee80211_rx_h_defragment(struct ieee80211_txrx_data
*rx
)
777 struct ieee80211_hdr
*hdr
;
779 unsigned int frag
, seq
;
780 struct ieee80211_fragment_entry
*entry
;
782 DECLARE_MAC_BUF(mac
);
784 hdr
= (struct ieee80211_hdr
*) rx
->skb
->data
;
785 sc
= le16_to_cpu(hdr
->seq_ctrl
);
786 frag
= sc
& IEEE80211_SCTL_FRAG
;
788 if (likely((!(rx
->fc
& IEEE80211_FCTL_MOREFRAGS
) && frag
== 0) ||
789 (rx
->skb
)->len
< 24 ||
790 is_multicast_ether_addr(hdr
->addr1
))) {
794 I802_DEBUG_INC(rx
->local
->rx_handlers_fragments
);
796 seq
= (sc
& IEEE80211_SCTL_SEQ
) >> 4;
799 /* This is the first fragment of a new frame. */
800 entry
= ieee80211_reassemble_add(rx
->sdata
, frag
, seq
,
801 rx
->u
.rx
.queue
, &(rx
->skb
));
802 if (rx
->key
&& rx
->key
->conf
.alg
== ALG_CCMP
&&
803 (rx
->fc
& IEEE80211_FCTL_PROTECTED
)) {
804 /* Store CCMP PN so that we can verify that the next
805 * fragment has a sequential PN value. */
807 memcpy(entry
->last_pn
,
808 rx
->key
->u
.ccmp
.rx_pn
[rx
->u
.rx
.queue
],
814 /* This is a fragment for a frame that should already be pending in
815 * fragment cache. Add this fragment to the end of the pending entry.
817 entry
= ieee80211_reassemble_find(rx
->sdata
, rx
->fc
, frag
, seq
,
818 rx
->u
.rx
.queue
, hdr
);
820 I802_DEBUG_INC(rx
->local
->rx_handlers_drop_defrag
);
824 /* Verify that MPDUs within one MSDU have sequential PN values.
825 * (IEEE 802.11i, 8.3.3.4.5) */
828 u8 pn
[CCMP_PN_LEN
], *rpn
;
829 if (!rx
->key
|| rx
->key
->conf
.alg
!= ALG_CCMP
)
831 memcpy(pn
, entry
->last_pn
, CCMP_PN_LEN
);
832 for (i
= CCMP_PN_LEN
- 1; i
>= 0; i
--) {
837 rpn
= rx
->key
->u
.ccmp
.rx_pn
[rx
->u
.rx
.queue
];
838 if (memcmp(pn
, rpn
, CCMP_PN_LEN
) != 0) {
840 printk(KERN_DEBUG
"%s: defrag: CCMP PN not "
842 " PN=%02x%02x%02x%02x%02x%02x "
843 "(expected %02x%02x%02x%02x%02x%02x)\n",
844 rx
->dev
->name
, print_mac(mac
, hdr
->addr2
),
845 rpn
[0], rpn
[1], rpn
[2], rpn
[3], rpn
[4],
846 rpn
[5], pn
[0], pn
[1], pn
[2], pn
[3],
850 memcpy(entry
->last_pn
, pn
, CCMP_PN_LEN
);
853 skb_pull(rx
->skb
, ieee80211_get_hdrlen(rx
->fc
));
854 __skb_queue_tail(&entry
->skb_list
, rx
->skb
);
855 entry
->last_frag
= frag
;
856 entry
->extra_len
+= rx
->skb
->len
;
857 if (rx
->fc
& IEEE80211_FCTL_MOREFRAGS
) {
862 rx
->skb
= __skb_dequeue(&entry
->skb_list
);
863 if (skb_tailroom(rx
->skb
) < entry
->extra_len
) {
864 I802_DEBUG_INC(rx
->local
->rx_expand_skb_head2
);
865 if (unlikely(pskb_expand_head(rx
->skb
, 0, entry
->extra_len
,
867 I802_DEBUG_INC(rx
->local
->rx_handlers_drop_defrag
);
868 __skb_queue_purge(&entry
->skb_list
);
872 while ((skb
= __skb_dequeue(&entry
->skb_list
))) {
873 memcpy(skb_put(rx
->skb
, skb
->len
), skb
->data
, skb
->len
);
877 /* Complete frame has been reassembled - process it now */
878 rx
->flags
|= IEEE80211_TXRXD_FRAGMENTED
;
882 rx
->sta
->rx_packets
++;
883 if (is_multicast_ether_addr(hdr
->addr1
))
884 rx
->local
->dot11MulticastReceivedFrameCount
++;
886 ieee80211_led_rx(rx
->local
);
887 return TXRX_CONTINUE
;
890 static ieee80211_txrx_result
891 ieee80211_rx_h_ps_poll(struct ieee80211_txrx_data
*rx
)
893 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(rx
->dev
);
896 DECLARE_MAC_BUF(mac
);
898 if (likely(!rx
->sta
||
899 (rx
->fc
& IEEE80211_FCTL_FTYPE
) != IEEE80211_FTYPE_CTL
||
900 (rx
->fc
& IEEE80211_FCTL_STYPE
) != IEEE80211_STYPE_PSPOLL
||
901 !(rx
->flags
& IEEE80211_TXRXD_RXRA_MATCH
)))
902 return TXRX_CONTINUE
;
904 if ((sdata
->type
!= IEEE80211_IF_TYPE_AP
) &&
905 (sdata
->type
!= IEEE80211_IF_TYPE_VLAN
))
908 skb
= skb_dequeue(&rx
->sta
->tx_filtered
);
910 skb
= skb_dequeue(&rx
->sta
->ps_tx_buf
);
912 rx
->local
->total_ps_buffered
--;
914 no_pending_pkts
= skb_queue_empty(&rx
->sta
->tx_filtered
) &&
915 skb_queue_empty(&rx
->sta
->ps_tx_buf
);
918 struct ieee80211_hdr
*hdr
=
919 (struct ieee80211_hdr
*) skb
->data
;
921 /* tell TX path to send one frame even though the STA may
922 * still remain is PS mode after this frame exchange */
925 #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
926 printk(KERN_DEBUG
"STA %s aid %d: PS Poll (entries after %d)\n",
927 print_mac(mac
, rx
->sta
->addr
), rx
->sta
->aid
,
928 skb_queue_len(&rx
->sta
->ps_tx_buf
));
929 #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
931 /* Use MoreData flag to indicate whether there are more
932 * buffered frames for this STA */
933 if (no_pending_pkts
) {
934 hdr
->frame_control
&= cpu_to_le16(~IEEE80211_FCTL_MOREDATA
);
935 rx
->sta
->flags
&= ~WLAN_STA_TIM
;
937 hdr
->frame_control
|= cpu_to_le16(IEEE80211_FCTL_MOREDATA
);
941 if (no_pending_pkts
) {
942 if (rx
->local
->ops
->set_tim
)
943 rx
->local
->ops
->set_tim(local_to_hw(rx
->local
),
946 bss_tim_clear(rx
->local
, rx
->sdata
->bss
, rx
->sta
->aid
);
948 #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
949 } else if (!rx
->u
.rx
.sent_ps_buffered
) {
950 printk(KERN_DEBUG
"%s: STA %s sent PS Poll even "
951 "though there is no buffered frames for it\n",
952 rx
->dev
->name
, print_mac(mac
, rx
->sta
->addr
));
953 #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
957 /* Free PS Poll skb here instead of returning TXRX_DROP that would
958 * count as an dropped frame. */
959 dev_kfree_skb(rx
->skb
);
964 static ieee80211_txrx_result
965 ieee80211_rx_h_remove_qos_control(struct ieee80211_txrx_data
*rx
)
968 u8
*data
= rx
->skb
->data
;
969 struct ieee80211_hdr
*hdr
= (struct ieee80211_hdr
*) data
;
971 if (!WLAN_FC_IS_QOS_DATA(fc
))
972 return TXRX_CONTINUE
;
974 /* remove the qos control field, update frame type and meta-data */
975 memmove(data
+ 2, data
, ieee80211_get_hdrlen(fc
) - 2);
976 hdr
= (struct ieee80211_hdr
*) skb_pull(rx
->skb
, 2);
977 /* change frame type to non QOS */
978 rx
->fc
= fc
&= ~IEEE80211_STYPE_QOS_DATA
;
979 hdr
->frame_control
= cpu_to_le16(fc
);
981 return TXRX_CONTINUE
;
985 ieee80211_802_1x_port_control(struct ieee80211_txrx_data
*rx
)
987 if (unlikely(rx
->sdata
->ieee802_1x_pac
&&
988 (!rx
->sta
|| !(rx
->sta
->flags
& WLAN_STA_AUTHORIZED
)))) {
989 #ifdef CONFIG_MAC80211_DEBUG
990 printk(KERN_DEBUG
"%s: dropped frame "
991 "(unauthorized port)\n", rx
->dev
->name
);
992 #endif /* CONFIG_MAC80211_DEBUG */
1000 ieee80211_drop_unencrypted(struct ieee80211_txrx_data
*rx
)
1003 * Pass through unencrypted frames if the hardware has
1004 * decrypted them already.
1006 if (rx
->u
.rx
.status
->flag
& RX_FLAG_DECRYPTED
)
1009 /* Drop unencrypted frames if key is set. */
1010 if (unlikely(!(rx
->fc
& IEEE80211_FCTL_PROTECTED
) &&
1011 (rx
->fc
& IEEE80211_FCTL_FTYPE
) == IEEE80211_FTYPE_DATA
&&
1012 (rx
->fc
& IEEE80211_FCTL_STYPE
) != IEEE80211_STYPE_NULLFUNC
&&
1013 (rx
->key
|| rx
->sdata
->drop_unencrypted
))) {
1014 if (net_ratelimit())
1015 printk(KERN_DEBUG
"%s: RX non-WEP frame, but expected "
1016 "encryption\n", rx
->dev
->name
);
1023 ieee80211_data_to_8023(struct ieee80211_txrx_data
*rx
)
1025 struct net_device
*dev
= rx
->dev
;
1026 struct ieee80211_hdr
*hdr
= (struct ieee80211_hdr
*) rx
->skb
->data
;
1027 u16 fc
, hdrlen
, ethertype
;
1031 struct sk_buff
*skb
= rx
->skb
;
1032 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1033 DECLARE_MAC_BUF(mac
);
1034 DECLARE_MAC_BUF(mac2
);
1035 DECLARE_MAC_BUF(mac3
);
1036 DECLARE_MAC_BUF(mac4
);
1040 if (unlikely(!WLAN_FC_DATA_PRESENT(fc
)))
1043 hdrlen
= ieee80211_get_hdrlen(fc
);
1045 /* convert IEEE 802.11 header + possible LLC headers into Ethernet
1047 * IEEE 802.11 address fields:
1048 * ToDS FromDS Addr1 Addr2 Addr3 Addr4
1049 * 0 0 DA SA BSSID n/a
1050 * 0 1 DA BSSID SA n/a
1051 * 1 0 BSSID SA DA n/a
1055 switch (fc
& (IEEE80211_FCTL_TODS
| IEEE80211_FCTL_FROMDS
)) {
1056 case IEEE80211_FCTL_TODS
:
1058 memcpy(dst
, hdr
->addr3
, ETH_ALEN
);
1059 memcpy(src
, hdr
->addr2
, ETH_ALEN
);
1061 if (unlikely(sdata
->type
!= IEEE80211_IF_TYPE_AP
&&
1062 sdata
->type
!= IEEE80211_IF_TYPE_VLAN
)) {
1063 if (net_ratelimit())
1064 printk(KERN_DEBUG
"%s: dropped ToDS frame "
1065 "(BSSID=%s SA=%s DA=%s)\n",
1067 print_mac(mac
, hdr
->addr1
),
1068 print_mac(mac2
, hdr
->addr2
),
1069 print_mac(mac3
, hdr
->addr3
));
1073 case (IEEE80211_FCTL_TODS
| IEEE80211_FCTL_FROMDS
):
1075 memcpy(dst
, hdr
->addr3
, ETH_ALEN
);
1076 memcpy(src
, hdr
->addr4
, ETH_ALEN
);
1078 if (unlikely(sdata
->type
!= IEEE80211_IF_TYPE_WDS
)) {
1079 if (net_ratelimit())
1080 printk(KERN_DEBUG
"%s: dropped FromDS&ToDS "
1081 "frame (RA=%s TA=%s DA=%s SA=%s)\n",
1083 print_mac(mac
, hdr
->addr1
),
1084 print_mac(mac2
, hdr
->addr2
),
1085 print_mac(mac3
, hdr
->addr3
),
1086 print_mac(mac4
, hdr
->addr4
));
1090 case IEEE80211_FCTL_FROMDS
:
1092 memcpy(dst
, hdr
->addr1
, ETH_ALEN
);
1093 memcpy(src
, hdr
->addr3
, ETH_ALEN
);
1095 if (sdata
->type
!= IEEE80211_IF_TYPE_STA
||
1096 (is_multicast_ether_addr(dst
) &&
1097 !compare_ether_addr(src
, dev
->dev_addr
)))
1102 memcpy(dst
, hdr
->addr1
, ETH_ALEN
);
1103 memcpy(src
, hdr
->addr2
, ETH_ALEN
);
1105 if (sdata
->type
!= IEEE80211_IF_TYPE_IBSS
) {
1106 if (net_ratelimit()) {
1107 printk(KERN_DEBUG
"%s: dropped IBSS frame "
1108 "(DA=%s SA=%s BSSID=%s)\n",
1110 print_mac(mac
, hdr
->addr1
),
1111 print_mac(mac2
, hdr
->addr2
),
1112 print_mac(mac3
, hdr
->addr3
));
1119 if (unlikely(skb
->len
- hdrlen
< 8)) {
1120 if (net_ratelimit()) {
1121 printk(KERN_DEBUG
"%s: RX too short data frame "
1122 "payload\n", dev
->name
);
1127 payload
= skb
->data
+ hdrlen
;
1128 ethertype
= (payload
[6] << 8) | payload
[7];
1130 if (likely((compare_ether_addr(payload
, rfc1042_header
) == 0 &&
1131 ethertype
!= ETH_P_AARP
&& ethertype
!= ETH_P_IPX
) ||
1132 compare_ether_addr(payload
, bridge_tunnel_header
) == 0)) {
1133 /* remove RFC1042 or Bridge-Tunnel encapsulation and
1134 * replace EtherType */
1135 skb_pull(skb
, hdrlen
+ 6);
1136 memcpy(skb_push(skb
, ETH_ALEN
), src
, ETH_ALEN
);
1137 memcpy(skb_push(skb
, ETH_ALEN
), dst
, ETH_ALEN
);
1139 struct ethhdr
*ehdr
;
1142 skb_pull(skb
, hdrlen
);
1143 len
= htons(skb
->len
);
1144 ehdr
= (struct ethhdr
*) skb_push(skb
, sizeof(struct ethhdr
));
1145 memcpy(ehdr
->h_dest
, dst
, ETH_ALEN
);
1146 memcpy(ehdr
->h_source
, src
, ETH_ALEN
);
1147 ehdr
->h_proto
= len
;
1153 * requires that rx->skb is a frame with ethernet header
1155 static bool ieee80211_frame_allowed(struct ieee80211_txrx_data
*rx
)
1157 static const u8 pae_group_addr
[ETH_ALEN
]
1158 = { 0x01, 0x80, 0xC2, 0x00, 0x00, 0x03 };
1159 struct ethhdr
*ehdr
= (struct ethhdr
*) rx
->skb
->data
;
1162 * Allow EAPOL frames to us/the PAE group address regardless
1163 * of whether the frame was encrypted or not.
1165 if (ehdr
->h_proto
== htons(ETH_P_PAE
) &&
1166 (compare_ether_addr(ehdr
->h_dest
, rx
->dev
->dev_addr
) == 0 ||
1167 compare_ether_addr(ehdr
->h_dest
, pae_group_addr
) == 0))
1170 if (ieee80211_802_1x_port_control(rx
) ||
1171 ieee80211_drop_unencrypted(rx
))
1178 * requires that rx->skb is a frame with ethernet header
1181 ieee80211_deliver_skb(struct ieee80211_txrx_data
*rx
)
1183 struct net_device
*dev
= rx
->dev
;
1184 struct ieee80211_local
*local
= rx
->local
;
1185 struct sk_buff
*skb
, *xmit_skb
;
1186 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1187 struct ethhdr
*ehdr
= (struct ethhdr
*) rx
->skb
->data
;
1188 struct sta_info
*dsta
;
1193 if (local
->bridge_packets
&& (sdata
->type
== IEEE80211_IF_TYPE_AP
||
1194 sdata
->type
== IEEE80211_IF_TYPE_VLAN
) &&
1195 (rx
->flags
& IEEE80211_TXRXD_RXRA_MATCH
)) {
1196 if (is_multicast_ether_addr(ehdr
->h_dest
)) {
1198 * send multicast frames both to higher layers in
1199 * local net stack and back to the wireless medium
1201 xmit_skb
= skb_copy(skb
, GFP_ATOMIC
);
1202 if (!xmit_skb
&& net_ratelimit())
1203 printk(KERN_DEBUG
"%s: failed to clone "
1204 "multicast frame\n", dev
->name
);
1206 dsta
= sta_info_get(local
, skb
->data
);
1207 if (dsta
&& dsta
->dev
== dev
) {
1209 * The destination station is associated to
1210 * this AP (in this VLAN), so send the frame
1211 * directly to it and do not pass it to local
1223 /* deliver to local stack */
1224 skb
->protocol
= eth_type_trans(skb
, dev
);
1225 memset(skb
->cb
, 0, sizeof(skb
->cb
));
1230 /* send to wireless media */
1231 xmit_skb
->protocol
= htons(ETH_P_802_3
);
1232 skb_reset_network_header(xmit_skb
);
1233 skb_reset_mac_header(xmit_skb
);
1234 dev_queue_xmit(xmit_skb
);
1238 static ieee80211_txrx_result
1239 ieee80211_rx_h_amsdu(struct ieee80211_txrx_data
*rx
)
1241 struct net_device
*dev
= rx
->dev
;
1242 struct ieee80211_local
*local
= rx
->local
;
1245 struct sk_buff
*skb
= rx
->skb
, *frame
= NULL
;
1246 const struct ethhdr
*eth
;
1250 DECLARE_MAC_BUF(mac
);
1253 if (unlikely((fc
& IEEE80211_FCTL_FTYPE
) != IEEE80211_FTYPE_DATA
))
1254 return TXRX_CONTINUE
;
1256 if (unlikely(!WLAN_FC_DATA_PRESENT(fc
)))
1259 if (!(rx
->flags
& IEEE80211_TXRXD_RX_AMSDU
))
1260 return TXRX_CONTINUE
;
1262 err
= ieee80211_data_to_8023(rx
);
1268 dev
->stats
.rx_packets
++;
1269 dev
->stats
.rx_bytes
+= skb
->len
;
1271 /* skip the wrapping header */
1272 eth
= (struct ethhdr
*) skb_pull(skb
, sizeof(struct ethhdr
));
1276 while (skb
!= frame
) {
1278 __be16 len
= eth
->h_proto
;
1279 unsigned int subframe_len
= sizeof(struct ethhdr
) + ntohs(len
);
1281 remaining
= skb
->len
;
1282 memcpy(dst
, eth
->h_dest
, ETH_ALEN
);
1283 memcpy(src
, eth
->h_source
, ETH_ALEN
);
1285 padding
= ((4 - subframe_len
) & 0x3);
1286 /* the last MSDU has no padding */
1287 if (subframe_len
> remaining
) {
1288 printk(KERN_DEBUG
"%s: wrong buffer size", dev
->name
);
1292 skb_pull(skb
, sizeof(struct ethhdr
));
1293 /* if last subframe reuse skb */
1294 if (remaining
<= subframe_len
+ padding
)
1297 frame
= dev_alloc_skb(local
->hw
.extra_tx_headroom
+
1303 skb_reserve(frame
, local
->hw
.extra_tx_headroom
+
1304 sizeof(struct ethhdr
));
1305 memcpy(skb_put(frame
, ntohs(len
)), skb
->data
,
1308 eth
= (struct ethhdr
*) skb_pull(skb
, ntohs(len
) +
1311 printk(KERN_DEBUG
"%s: wrong buffer size ",
1313 dev_kfree_skb(frame
);
1318 skb_reset_network_header(frame
);
1320 frame
->priority
= skb
->priority
;
1323 payload
= frame
->data
;
1324 ethertype
= (payload
[6] << 8) | payload
[7];
1326 if (likely((compare_ether_addr(payload
, rfc1042_header
) == 0 &&
1327 ethertype
!= ETH_P_AARP
&& ethertype
!= ETH_P_IPX
) ||
1328 compare_ether_addr(payload
,
1329 bridge_tunnel_header
) == 0)) {
1330 /* remove RFC1042 or Bridge-Tunnel
1331 * encapsulation and replace EtherType */
1333 memcpy(skb_push(frame
, ETH_ALEN
), src
, ETH_ALEN
);
1334 memcpy(skb_push(frame
, ETH_ALEN
), dst
, ETH_ALEN
);
1336 memcpy(skb_push(frame
, sizeof(__be16
)),
1337 &len
, sizeof(__be16
));
1338 memcpy(skb_push(frame
, ETH_ALEN
), src
, ETH_ALEN
);
1339 memcpy(skb_push(frame
, ETH_ALEN
), dst
, ETH_ALEN
);
1342 if (!ieee80211_frame_allowed(rx
)) {
1343 if (skb
== frame
) /* last frame */
1345 dev_kfree_skb(frame
);
1349 ieee80211_deliver_skb(rx
);
1355 static ieee80211_txrx_result
1356 ieee80211_rx_h_data(struct ieee80211_txrx_data
*rx
)
1358 struct net_device
*dev
= rx
->dev
;
1363 if (unlikely((fc
& IEEE80211_FCTL_FTYPE
) != IEEE80211_FTYPE_DATA
))
1364 return TXRX_CONTINUE
;
1366 if (unlikely(!WLAN_FC_DATA_PRESENT(fc
)))
1369 err
= ieee80211_data_to_8023(rx
);
1373 if (!ieee80211_frame_allowed(rx
))
1378 dev
->stats
.rx_packets
++;
1379 dev
->stats
.rx_bytes
+= rx
->skb
->len
;
1381 ieee80211_deliver_skb(rx
);
1386 static ieee80211_txrx_result
1387 ieee80211_rx_h_ctrl(struct ieee80211_txrx_data
*rx
)
1389 struct ieee80211_local
*local
= rx
->local
;
1390 struct ieee80211_hw
*hw
= &local
->hw
;
1391 struct sk_buff
*skb
= rx
->skb
;
1392 struct ieee80211_bar
*bar
= (struct ieee80211_bar
*) skb
->data
;
1393 struct tid_ampdu_rx
*tid_agg_rx
;
1397 if (likely((rx
->fc
& IEEE80211_FCTL_FTYPE
) != IEEE80211_FTYPE_CTL
))
1398 return TXRX_CONTINUE
;
1400 if ((rx
->fc
& IEEE80211_FCTL_STYPE
) == IEEE80211_STYPE_BACK_REQ
) {
1402 return TXRX_CONTINUE
;
1403 tid
= le16_to_cpu(bar
->control
) >> 12;
1404 tid_agg_rx
= &(rx
->sta
->ampdu_mlme
.tid_rx
[tid
]);
1405 if (tid_agg_rx
->state
!= HT_AGG_STATE_OPERATIONAL
)
1406 return TXRX_CONTINUE
;
1408 start_seq_num
= le16_to_cpu(bar
->start_seq_num
) >> 4;
1410 /* reset session timer */
1411 if (tid_agg_rx
->timeout
) {
1412 unsigned long expires
=
1413 jiffies
+ (tid_agg_rx
->timeout
/ 1000) * HZ
;
1414 mod_timer(&tid_agg_rx
->session_timer
, expires
);
1417 /* manage reordering buffer according to requested */
1418 /* sequence number */
1420 ieee80211_sta_manage_reorder_buf(hw
, tid_agg_rx
, NULL
,
1426 return TXRX_CONTINUE
;
1429 static ieee80211_txrx_result
1430 ieee80211_rx_h_mgmt(struct ieee80211_txrx_data
*rx
)
1432 struct ieee80211_sub_if_data
*sdata
;
1434 if (!(rx
->flags
& IEEE80211_TXRXD_RXRA_MATCH
))
1437 sdata
= IEEE80211_DEV_TO_SUB_IF(rx
->dev
);
1438 if ((sdata
->type
== IEEE80211_IF_TYPE_STA
||
1439 sdata
->type
== IEEE80211_IF_TYPE_IBSS
) &&
1440 !(sdata
->flags
& IEEE80211_SDATA_USERSPACE_MLME
))
1441 ieee80211_sta_rx_mgmt(rx
->dev
, rx
->skb
, rx
->u
.rx
.status
);
1448 static inline ieee80211_txrx_result
__ieee80211_invoke_rx_handlers(
1449 struct ieee80211_local
*local
,
1450 ieee80211_rx_handler
*handlers
,
1451 struct ieee80211_txrx_data
*rx
,
1452 struct sta_info
*sta
)
1454 ieee80211_rx_handler
*handler
;
1455 ieee80211_txrx_result res
= TXRX_DROP
;
1457 for (handler
= handlers
; *handler
!= NULL
; handler
++) {
1458 res
= (*handler
)(rx
);
1464 I802_DEBUG_INC(local
->rx_handlers_drop
);
1469 I802_DEBUG_INC(local
->rx_handlers_queued
);
1475 if (res
== TXRX_DROP
)
1476 dev_kfree_skb(rx
->skb
);
1480 static inline void ieee80211_invoke_rx_handlers(struct ieee80211_local
*local
,
1481 ieee80211_rx_handler
*handlers
,
1482 struct ieee80211_txrx_data
*rx
,
1483 struct sta_info
*sta
)
1485 if (__ieee80211_invoke_rx_handlers(local
, handlers
, rx
, sta
) ==
1487 dev_kfree_skb(rx
->skb
);
1490 static void ieee80211_rx_michael_mic_report(struct net_device
*dev
,
1491 struct ieee80211_hdr
*hdr
,
1492 struct sta_info
*sta
,
1493 struct ieee80211_txrx_data
*rx
)
1496 DECLARE_MAC_BUF(mac
);
1497 DECLARE_MAC_BUF(mac2
);
1499 hdrlen
= ieee80211_get_hdrlen_from_skb(rx
->skb
);
1500 if (rx
->skb
->len
>= hdrlen
+ 4)
1501 keyidx
= rx
->skb
->data
[hdrlen
+ 3] >> 6;
1505 if (net_ratelimit())
1506 printk(KERN_DEBUG
"%s: TKIP hwaccel reported Michael MIC "
1507 "failure from %s to %s keyidx=%d\n",
1508 dev
->name
, print_mac(mac
, hdr
->addr2
),
1509 print_mac(mac2
, hdr
->addr1
), keyidx
);
1513 * Some hardware seem to generate incorrect Michael MIC
1514 * reports; ignore them to avoid triggering countermeasures.
1516 if (net_ratelimit())
1517 printk(KERN_DEBUG
"%s: ignored spurious Michael MIC "
1518 "error for unknown address %s\n",
1519 dev
->name
, print_mac(mac
, hdr
->addr2
));
1523 if (!(rx
->fc
& IEEE80211_FCTL_PROTECTED
)) {
1524 if (net_ratelimit())
1525 printk(KERN_DEBUG
"%s: ignored spurious Michael MIC "
1526 "error for a frame with no PROTECTED flag (src "
1527 "%s)\n", dev
->name
, print_mac(mac
, hdr
->addr2
));
1531 if (rx
->sdata
->type
== IEEE80211_IF_TYPE_AP
&& keyidx
) {
1533 * APs with pairwise keys should never receive Michael MIC
1534 * errors for non-zero keyidx because these are reserved for
1535 * group keys and only the AP is sending real multicast
1536 * frames in the BSS.
1538 if (net_ratelimit())
1539 printk(KERN_DEBUG
"%s: ignored Michael MIC error for "
1540 "a frame with non-zero keyidx (%d)"
1541 " (src %s)\n", dev
->name
, keyidx
,
1542 print_mac(mac
, hdr
->addr2
));
1546 if ((rx
->fc
& IEEE80211_FCTL_FTYPE
) != IEEE80211_FTYPE_DATA
&&
1547 ((rx
->fc
& IEEE80211_FCTL_FTYPE
) != IEEE80211_FTYPE_MGMT
||
1548 (rx
->fc
& IEEE80211_FCTL_STYPE
) != IEEE80211_STYPE_AUTH
)) {
1549 if (net_ratelimit())
1550 printk(KERN_DEBUG
"%s: ignored spurious Michael MIC "
1551 "error for a frame that cannot be encrypted "
1552 "(fc=0x%04x) (src %s)\n",
1553 dev
->name
, rx
->fc
, print_mac(mac
, hdr
->addr2
));
1557 mac80211_ev_michael_mic_failure(rx
->dev
, keyidx
, hdr
);
1559 dev_kfree_skb(rx
->skb
);
1563 ieee80211_rx_handler ieee80211_rx_handlers
[] =
1565 ieee80211_rx_h_if_stats
,
1566 ieee80211_rx_h_passive_scan
,
1567 ieee80211_rx_h_check
,
1568 ieee80211_rx_h_decrypt
,
1569 ieee80211_rx_h_sta_process
,
1570 ieee80211_rx_h_defragment
,
1571 ieee80211_rx_h_ps_poll
,
1572 ieee80211_rx_h_michael_mic_verify
,
1573 /* this must be after decryption - so header is counted in MPDU mic
1574 * must be before pae and data, so QOS_DATA format frames
1575 * are not passed to user space by these functions
1577 ieee80211_rx_h_remove_qos_control
,
1578 ieee80211_rx_h_amsdu
,
1579 ieee80211_rx_h_data
,
1580 ieee80211_rx_h_ctrl
,
1581 ieee80211_rx_h_mgmt
,
1585 /* main receive path */
1587 static int prepare_for_handlers(struct ieee80211_sub_if_data
*sdata
,
1588 u8
*bssid
, struct ieee80211_txrx_data
*rx
,
1589 struct ieee80211_hdr
*hdr
)
1591 int multicast
= is_multicast_ether_addr(hdr
->addr1
);
1593 switch (sdata
->type
) {
1594 case IEEE80211_IF_TYPE_STA
:
1597 if (!ieee80211_bssid_match(bssid
, sdata
->u
.sta
.bssid
)) {
1598 if (!(rx
->flags
& IEEE80211_TXRXD_RXIN_SCAN
))
1600 rx
->flags
&= ~IEEE80211_TXRXD_RXRA_MATCH
;
1601 } else if (!multicast
&&
1602 compare_ether_addr(sdata
->dev
->dev_addr
,
1604 if (!(sdata
->dev
->flags
& IFF_PROMISC
))
1606 rx
->flags
&= ~IEEE80211_TXRXD_RXRA_MATCH
;
1609 case IEEE80211_IF_TYPE_IBSS
:
1612 if (!ieee80211_bssid_match(bssid
, sdata
->u
.sta
.bssid
)) {
1613 if (!(rx
->flags
& IEEE80211_TXRXD_RXIN_SCAN
))
1615 rx
->flags
&= ~IEEE80211_TXRXD_RXRA_MATCH
;
1616 } else if (!multicast
&&
1617 compare_ether_addr(sdata
->dev
->dev_addr
,
1619 if (!(sdata
->dev
->flags
& IFF_PROMISC
))
1621 rx
->flags
&= ~IEEE80211_TXRXD_RXRA_MATCH
;
1622 } else if (!rx
->sta
)
1623 rx
->sta
= ieee80211_ibss_add_sta(sdata
->dev
, rx
->skb
,
1626 case IEEE80211_IF_TYPE_VLAN
:
1627 case IEEE80211_IF_TYPE_AP
:
1629 if (compare_ether_addr(sdata
->dev
->dev_addr
,
1632 } else if (!ieee80211_bssid_match(bssid
,
1633 sdata
->dev
->dev_addr
)) {
1634 if (!(rx
->flags
& IEEE80211_TXRXD_RXIN_SCAN
))
1636 rx
->flags
&= ~IEEE80211_TXRXD_RXRA_MATCH
;
1638 if (sdata
->dev
== sdata
->local
->mdev
&&
1639 !(rx
->flags
& IEEE80211_TXRXD_RXIN_SCAN
))
1640 /* do not receive anything via
1641 * master device when not scanning */
1644 case IEEE80211_IF_TYPE_WDS
:
1646 (rx
->fc
& IEEE80211_FCTL_FTYPE
) != IEEE80211_FTYPE_DATA
)
1648 if (compare_ether_addr(sdata
->u
.wds
.remote_addr
, hdr
->addr2
))
1651 case IEEE80211_IF_TYPE_MNTR
:
1652 /* take everything */
1654 case IEEE80211_IF_TYPE_INVALID
:
1655 /* should never get here */
1664 * This is the actual Rx frames handler. as it blongs to Rx path it must
1665 * be called with rcu_read_lock protection.
1667 void __ieee80211_rx_handle_packet(struct ieee80211_hw
*hw
, struct sk_buff
*skb
,
1668 struct ieee80211_rx_status
*status
, u32 load
)
1670 struct ieee80211_local
*local
= hw_to_local(hw
);
1671 struct ieee80211_sub_if_data
*sdata
;
1672 struct sta_info
*sta
;
1673 struct ieee80211_hdr
*hdr
;
1674 struct ieee80211_txrx_data rx
;
1677 struct ieee80211_sub_if_data
*prev
= NULL
;
1678 struct sk_buff
*skb_new
;
1682 hdr
= (struct ieee80211_hdr
*) skb
->data
;
1683 memset(&rx
, 0, sizeof(rx
));
1687 rx
.u
.rx
.status
= status
;
1688 rx
.u
.rx
.load
= load
;
1689 rx
.fc
= le16_to_cpu(hdr
->frame_control
);
1690 type
= rx
.fc
& IEEE80211_FCTL_FTYPE
;
1693 * Drivers are required to align the payload data to a four-byte
1694 * boundary, so the last two bits of the address where it starts
1695 * may not be set. The header is required to be directly before
1696 * the payload data, padding like atheros hardware adds which is
1697 * inbetween the 802.11 header and the payload is not supported,
1698 * the driver is required to move the 802.11 header further back
1701 hdrlen
= ieee80211_get_hdrlen(rx
.fc
);
1702 WARN_ON_ONCE(((unsigned long)(skb
->data
+ hdrlen
)) & 3);
1704 if (type
== IEEE80211_FTYPE_DATA
|| type
== IEEE80211_FTYPE_MGMT
)
1705 local
->dot11ReceivedFragmentCount
++;
1707 sta
= rx
.sta
= sta_info_get(local
, hdr
->addr2
);
1709 rx
.dev
= rx
.sta
->dev
;
1710 rx
.sdata
= IEEE80211_DEV_TO_SUB_IF(rx
.dev
);
1713 if ((status
->flag
& RX_FLAG_MMIC_ERROR
)) {
1714 ieee80211_rx_michael_mic_report(local
->mdev
, hdr
, sta
, &rx
);
1718 if (unlikely(local
->sta_sw_scanning
|| local
->sta_hw_scanning
))
1719 rx
.flags
|= IEEE80211_TXRXD_RXIN_SCAN
;
1721 if (__ieee80211_invoke_rx_handlers(local
, local
->rx_pre_handlers
, &rx
,
1722 sta
) != TXRX_CONTINUE
)
1726 if (sta
&& !(sta
->flags
& (WLAN_STA_WDS
| WLAN_STA_ASSOC_AP
)) &&
1727 !atomic_read(&local
->iff_promiscs
) &&
1728 !is_multicast_ether_addr(hdr
->addr1
)) {
1729 rx
.flags
|= IEEE80211_TXRXD_RXRA_MATCH
;
1730 ieee80211_invoke_rx_handlers(local
, local
->rx_handlers
, &rx
,
1737 list_for_each_entry_rcu(sdata
, &local
->interfaces
, list
) {
1738 if (!netif_running(sdata
->dev
))
1741 if (sdata
->type
== IEEE80211_IF_TYPE_MNTR
)
1744 bssid
= ieee80211_get_bssid(hdr
, skb
->len
, sdata
->type
);
1745 rx
.flags
|= IEEE80211_TXRXD_RXRA_MATCH
;
1746 prepares
= prepare_for_handlers(sdata
, bssid
, &rx
, hdr
);
1747 /* prepare_for_handlers can change sta */
1754 * frame is destined for this interface, but if it's not
1755 * also for the previous one we handle that after the
1756 * loop to avoid copying the SKB once too much
1765 * frame was destined for the previous interface
1766 * so invoke RX handlers for it
1769 skb_new
= skb_copy(skb
, GFP_ATOMIC
);
1771 if (net_ratelimit())
1772 printk(KERN_DEBUG
"%s: failed to copy "
1773 "multicast frame for %s",
1774 wiphy_name(local
->hw
.wiphy
),
1778 rx
.fc
= le16_to_cpu(hdr
->frame_control
);
1782 ieee80211_invoke_rx_handlers(local
, local
->rx_handlers
,
1787 rx
.fc
= le16_to_cpu(hdr
->frame_control
);
1791 ieee80211_invoke_rx_handlers(local
, local
->rx_handlers
,
1801 #define SEQ_MODULO 0x1000
1802 #define SEQ_MASK 0xfff
1804 static inline int seq_less(u16 sq1
, u16 sq2
)
1806 return (((sq1
- sq2
) & SEQ_MASK
) > (SEQ_MODULO
>> 1));
1809 static inline u16
seq_inc(u16 sq
)
1811 return ((sq
+ 1) & SEQ_MASK
);
1814 static inline u16
seq_sub(u16 sq1
, u16 sq2
)
1816 return ((sq1
- sq2
) & SEQ_MASK
);
1821 * As it function blongs to Rx path it must be called with
1822 * the proper rcu_read_lock protection for its flow.
1824 u8
ieee80211_sta_manage_reorder_buf(struct ieee80211_hw
*hw
,
1825 struct tid_ampdu_rx
*tid_agg_rx
,
1826 struct sk_buff
*skb
, u16 mpdu_seq_num
,
1829 struct ieee80211_local
*local
= hw_to_local(hw
);
1830 struct ieee80211_rx_status status
;
1831 u16 head_seq_num
, buf_size
;
1835 buf_size
= tid_agg_rx
->buf_size
;
1836 head_seq_num
= tid_agg_rx
->head_seq_num
;
1838 /* frame with out of date sequence number */
1839 if (seq_less(mpdu_seq_num
, head_seq_num
)) {
1844 /* if frame sequence number exceeds our buffering window size or
1845 * block Ack Request arrived - release stored frames */
1846 if ((!seq_less(mpdu_seq_num
, head_seq_num
+ buf_size
)) || (bar_req
)) {
1847 /* new head to the ordering buffer */
1849 head_seq_num
= mpdu_seq_num
;
1852 seq_inc(seq_sub(mpdu_seq_num
, buf_size
));
1853 /* release stored frames up to new head to stack */
1854 while (seq_less(tid_agg_rx
->head_seq_num
, head_seq_num
)) {
1855 index
= seq_sub(tid_agg_rx
->head_seq_num
,
1857 % tid_agg_rx
->buf_size
;
1859 if (tid_agg_rx
->reorder_buf
[index
]) {
1860 /* release the reordered frames to stack */
1862 tid_agg_rx
->reorder_buf
[index
]->cb
,
1864 pkt_load
= ieee80211_rx_load_stats(local
,
1865 tid_agg_rx
->reorder_buf
[index
],
1867 __ieee80211_rx_handle_packet(hw
,
1868 tid_agg_rx
->reorder_buf
[index
],
1870 tid_agg_rx
->stored_mpdu_num
--;
1871 tid_agg_rx
->reorder_buf
[index
] = NULL
;
1873 tid_agg_rx
->head_seq_num
=
1874 seq_inc(tid_agg_rx
->head_seq_num
);
1880 /* now the new frame is always in the range of the reordering */
1882 index
= seq_sub(mpdu_seq_num
, tid_agg_rx
->ssn
)
1883 % tid_agg_rx
->buf_size
;
1884 /* check if we already stored this frame */
1885 if (tid_agg_rx
->reorder_buf
[index
]) {
1890 /* if arrived mpdu is in the right order and nothing else stored */
1891 /* release it immediately */
1892 if (mpdu_seq_num
== tid_agg_rx
->head_seq_num
&&
1893 tid_agg_rx
->stored_mpdu_num
== 0) {
1894 tid_agg_rx
->head_seq_num
=
1895 seq_inc(tid_agg_rx
->head_seq_num
);
1899 /* put the frame in the reordering buffer */
1900 tid_agg_rx
->reorder_buf
[index
] = skb
;
1901 tid_agg_rx
->stored_mpdu_num
++;
1902 /* release the buffer until next missing frame */
1903 index
= seq_sub(tid_agg_rx
->head_seq_num
, tid_agg_rx
->ssn
)
1904 % tid_agg_rx
->buf_size
;
1905 while (tid_agg_rx
->reorder_buf
[index
]) {
1906 /* release the reordered frame back to stack */
1907 memcpy(&status
, tid_agg_rx
->reorder_buf
[index
]->cb
,
1909 pkt_load
= ieee80211_rx_load_stats(local
,
1910 tid_agg_rx
->reorder_buf
[index
],
1912 __ieee80211_rx_handle_packet(hw
, tid_agg_rx
->reorder_buf
[index
],
1914 tid_agg_rx
->stored_mpdu_num
--;
1915 tid_agg_rx
->reorder_buf
[index
] = NULL
;
1916 tid_agg_rx
->head_seq_num
= seq_inc(tid_agg_rx
->head_seq_num
);
1917 index
= seq_sub(tid_agg_rx
->head_seq_num
,
1918 tid_agg_rx
->ssn
) % tid_agg_rx
->buf_size
;
1923 u8
ieee80211_rx_reorder_ampdu(struct ieee80211_local
*local
,
1924 struct sk_buff
*skb
)
1926 struct ieee80211_hw
*hw
= &local
->hw
;
1927 struct ieee80211_hdr
*hdr
= (struct ieee80211_hdr
*) skb
->data
;
1928 struct sta_info
*sta
;
1929 struct tid_ampdu_rx
*tid_agg_rx
;
1935 sta
= sta_info_get(local
, hdr
->addr2
);
1939 fc
= le16_to_cpu(hdr
->frame_control
);
1941 /* filter the QoS data rx stream according to
1942 * STA/TID and check if this STA/TID is on aggregation */
1943 if (!WLAN_FC_IS_QOS_DATA(fc
))
1946 qc
= skb
->data
+ ieee80211_get_hdrlen(fc
) - QOS_CONTROL_LEN
;
1947 tid
= qc
[0] & QOS_CONTROL_TID_MASK
;
1948 tid_agg_rx
= &(sta
->ampdu_mlme
.tid_rx
[tid
]);
1950 if (tid_agg_rx
->state
!= HT_AGG_STATE_OPERATIONAL
)
1953 /* null data frames are excluded */
1954 if (unlikely(fc
& IEEE80211_STYPE_QOS_NULLFUNC
))
1957 /* new un-ordered ampdu frame - process it */
1959 /* reset session timer */
1960 if (tid_agg_rx
->timeout
) {
1961 unsigned long expires
=
1962 jiffies
+ (tid_agg_rx
->timeout
/ 1000) * HZ
;
1963 mod_timer(&tid_agg_rx
->session_timer
, expires
);
1966 /* if this mpdu is fragmented - terminate rx aggregation session */
1967 sc
= le16_to_cpu(hdr
->seq_ctrl
);
1968 if (sc
& IEEE80211_SCTL_FRAG
) {
1969 ieee80211_sta_stop_rx_ba_session(sta
->dev
, sta
->addr
,
1970 tid
, 0, WLAN_REASON_QSTA_REQUIRE_SETUP
);
1975 /* according to mpdu sequence number deal with reordering buffer */
1976 mpdu_seq_num
= (sc
& IEEE80211_SCTL_SEQ
) >> 4;
1977 ret
= ieee80211_sta_manage_reorder_buf(hw
, tid_agg_rx
, skb
,
1986 * This is the receive path handler. It is called by a low level driver when an
1987 * 802.11 MPDU is received from the hardware.
1989 void __ieee80211_rx(struct ieee80211_hw
*hw
, struct sk_buff
*skb
,
1990 struct ieee80211_rx_status
*status
)
1992 struct ieee80211_local
*local
= hw_to_local(hw
);
1996 * key references and virtual interfaces are protected using RCU
1997 * and this requires that we are in a read-side RCU section during
1998 * receive processing
2003 * Frames with failed FCS/PLCP checksum are not returned,
2004 * all other frames are returned without radiotap header
2005 * if it was previously present.
2006 * Also, frames with less than 16 bytes are dropped.
2008 skb
= ieee80211_rx_monitor(local
, skb
, status
);
2014 pkt_load
= ieee80211_rx_load_stats(local
, skb
, status
);
2015 local
->channel_use_raw
+= pkt_load
;
2017 if (!ieee80211_rx_reorder_ampdu(local
, skb
))
2018 __ieee80211_rx_handle_packet(hw
, skb
, status
, pkt_load
);
2022 EXPORT_SYMBOL(__ieee80211_rx
);
2024 /* This is a version of the rx handler that can be called from hard irq
2025 * context. Post the skb on the queue and schedule the tasklet */
2026 void ieee80211_rx_irqsafe(struct ieee80211_hw
*hw
, struct sk_buff
*skb
,
2027 struct ieee80211_rx_status
*status
)
2029 struct ieee80211_local
*local
= hw_to_local(hw
);
2031 BUILD_BUG_ON(sizeof(struct ieee80211_rx_status
) > sizeof(skb
->cb
));
2033 skb
->dev
= local
->mdev
;
2034 /* copy status into skb->cb for use by tasklet */
2035 memcpy(skb
->cb
, status
, sizeof(*status
));
2036 skb
->pkt_type
= IEEE80211_RX_MSG
;
2037 skb_queue_tail(&local
->skb_queue
, skb
);
2038 tasklet_schedule(&local
->tasklet
);
2040 EXPORT_SYMBOL(ieee80211_rx_irqsafe
);