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/jiffies.h>
13 #include <linux/kernel.h>
14 #include <linux/skbuff.h>
15 #include <linux/netdevice.h>
16 #include <linux/etherdevice.h>
17 #include <linux/rcupdate.h>
18 #include <net/mac80211.h>
19 #include <net/ieee80211_radiotap.h>
21 #include "ieee80211_i.h"
22 #include "ieee80211_led.h"
28 u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw,
29 struct tid_ampdu_rx *tid_agg_rx,
30 struct sk_buff *skb, u16 mpdu_seq_num,
33 * monitor mode reception
35 * This function cleans up the SKB, i.e. it removes all the stuff
36 * only useful for monitoring.
38 static struct sk_buff *remove_monitor_info(struct ieee80211_local *local,
42 skb_pull(skb, rtap_len);
44 if (local->hw.flags & IEEE80211_HW_RX_INCLUDES_FCS) {
45 if (likely(skb->len > FCS_LEN))
46 skb_trim(skb, skb->len - FCS_LEN);
58 static inline int should_drop_frame(struct ieee80211_rx_status *status,
63 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
65 if (status->flag & (RX_FLAG_FAILED_FCS_CRC | RX_FLAG_FAILED_PLCP_CRC))
67 if (unlikely(skb->len < 16 + present_fcs_len + radiotap_len))
69 if (((hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
70 cpu_to_le16(IEEE80211_FTYPE_CTL)) &&
71 ((hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE)) !=
72 cpu_to_le16(IEEE80211_STYPE_PSPOLL)) &&
73 ((hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE)) !=
74 cpu_to_le16(IEEE80211_STYPE_BACK_REQ)))
80 * This function copies a received frame to all monitor interfaces and
81 * returns a cleaned-up SKB that no longer includes the FCS nor the
82 * radiotap header the driver might have added.
84 static struct sk_buff *
85 ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb,
86 struct ieee80211_rx_status *status,
87 struct ieee80211_rate *rate)
89 struct ieee80211_sub_if_data *sdata;
90 int needed_headroom = 0;
91 struct ieee80211_radiotap_header *rthdr;
92 __le64 *rttsft = NULL;
93 struct ieee80211_rtap_fixed_data {
99 u8 padding_for_rxflags;
101 } __attribute__ ((packed)) *rtfixed;
102 struct sk_buff *skb, *skb2;
103 struct net_device *prev_dev = NULL;
104 int present_fcs_len = 0;
108 * First, we may need to make a copy of the skb because
109 * (1) we need to modify it for radiotap (if not present), and
110 * (2) the other RX handlers will modify the skb we got.
112 * We don't need to, of course, if we aren't going to return
113 * the SKB because it has a bad FCS/PLCP checksum.
115 if (status->flag & RX_FLAG_RADIOTAP)
116 rtap_len = ieee80211_get_radiotap_len(origskb->data);
118 /* room for radiotap header, always present fields and TSFT */
119 needed_headroom = sizeof(*rthdr) + sizeof(*rtfixed) + 8;
121 if (local->hw.flags & IEEE80211_HW_RX_INCLUDES_FCS)
122 present_fcs_len = FCS_LEN;
124 if (!local->monitors) {
125 if (should_drop_frame(status, origskb, present_fcs_len,
127 dev_kfree_skb(origskb);
131 return remove_monitor_info(local, origskb, rtap_len);
134 if (should_drop_frame(status, origskb, present_fcs_len, rtap_len)) {
135 /* only need to expand headroom if necessary */
140 * This shouldn't trigger often because most devices have an
141 * RX header they pull before we get here, and that should
142 * be big enough for our radiotap information. We should
143 * probably export the length to drivers so that we can have
144 * them allocate enough headroom to start with.
146 if (skb_headroom(skb) < needed_headroom &&
147 pskb_expand_head(skb, needed_headroom, 0, GFP_ATOMIC)) {
153 * Need to make a copy and possibly remove radiotap header
154 * and FCS from the original.
156 skb = skb_copy_expand(origskb, needed_headroom, 0, GFP_ATOMIC);
158 origskb = remove_monitor_info(local, origskb, rtap_len);
164 /* if necessary, prepend radiotap information */
165 if (!(status->flag & RX_FLAG_RADIOTAP)) {
166 rtfixed = (void *) skb_push(skb, sizeof(*rtfixed));
167 rtap_len = sizeof(*rthdr) + sizeof(*rtfixed);
168 if (status->flag & RX_FLAG_TSFT) {
169 rttsft = (void *) skb_push(skb, sizeof(*rttsft));
172 rthdr = (void *) skb_push(skb, sizeof(*rthdr));
173 memset(rthdr, 0, sizeof(*rthdr));
174 memset(rtfixed, 0, sizeof(*rtfixed));
176 cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) |
177 (1 << IEEE80211_RADIOTAP_RATE) |
178 (1 << IEEE80211_RADIOTAP_CHANNEL) |
179 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL) |
180 (1 << IEEE80211_RADIOTAP_RX_FLAGS));
182 if (local->hw.flags & IEEE80211_HW_RX_INCLUDES_FCS)
183 rtfixed->flags |= IEEE80211_RADIOTAP_F_FCS;
186 *rttsft = cpu_to_le64(status->mactime);
188 cpu_to_le32(1 << IEEE80211_RADIOTAP_TSFT);
191 /* FIXME: when radiotap gets a 'bad PLCP' flag use it here */
192 rtfixed->rx_flags = 0;
194 (RX_FLAG_FAILED_FCS_CRC | RX_FLAG_FAILED_PLCP_CRC))
196 cpu_to_le16(IEEE80211_RADIOTAP_F_RX_BADFCS);
198 rtfixed->rate = rate->bitrate / 5;
200 rtfixed->chan_freq = cpu_to_le16(status->freq);
202 if (status->band == IEEE80211_BAND_5GHZ)
203 rtfixed->chan_flags =
204 cpu_to_le16(IEEE80211_CHAN_OFDM |
205 IEEE80211_CHAN_5GHZ);
207 rtfixed->chan_flags =
208 cpu_to_le16(IEEE80211_CHAN_DYN |
209 IEEE80211_CHAN_2GHZ);
211 rtfixed->antsignal = status->ssi;
212 rthdr->it_len = cpu_to_le16(rtap_len);
215 skb_reset_mac_header(skb);
216 skb->ip_summed = CHECKSUM_UNNECESSARY;
217 skb->pkt_type = PACKET_OTHERHOST;
218 skb->protocol = htons(ETH_P_802_2);
220 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
221 if (!netif_running(sdata->dev))
224 if (sdata->vif.type != IEEE80211_IF_TYPE_MNTR)
227 if (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES)
231 skb2 = skb_clone(skb, GFP_ATOMIC);
233 skb2->dev = prev_dev;
238 prev_dev = sdata->dev;
239 sdata->dev->stats.rx_packets++;
240 sdata->dev->stats.rx_bytes += skb->len;
253 static void ieee80211_parse_qos(struct ieee80211_txrx_data *rx)
255 u8 *data = rx->skb->data;
258 /* does the frame have a qos control field? */
259 if (WLAN_FC_IS_QOS_DATA(rx->fc)) {
260 u8 *qc = data + ieee80211_get_hdrlen(rx->fc) - QOS_CONTROL_LEN;
261 /* frame has qos control */
262 tid = qc[0] & QOS_CONTROL_TID_MASK;
263 if (qc[0] & IEEE80211_QOS_CONTROL_A_MSDU_PRESENT)
264 rx->flags |= IEEE80211_TXRXD_RX_AMSDU;
266 rx->flags &= ~IEEE80211_TXRXD_RX_AMSDU;
268 if (unlikely((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT)) {
269 /* Separate TID for management frames */
270 tid = NUM_RX_DATA_QUEUES - 1;
272 /* no qos control present */
273 tid = 0; /* 802.1d - Best Effort */
277 I802_DEBUG_INC(rx->local->wme_rx_queue[tid]);
278 /* only a debug counter, sta might not be assigned properly yet */
280 I802_DEBUG_INC(rx->sta->wme_rx_queue[tid]);
282 rx->u.rx.queue = tid;
283 /* Set skb->priority to 1d tag if highest order bit of TID is not set.
284 * For now, set skb->priority to 0 for other cases. */
285 rx->skb->priority = (tid > 7) ? 0 : tid;
288 static void ieee80211_verify_ip_alignment(struct ieee80211_txrx_data *rx)
290 #ifdef CONFIG_MAC80211_DEBUG_PACKET_ALIGNMENT
293 if (!WLAN_FC_DATA_PRESENT(rx->fc))
297 * Drivers are required to align the payload data in a way that
298 * guarantees that the contained IP header is aligned to a four-
299 * byte boundary. In the case of regular frames, this simply means
300 * aligning the payload to a four-byte boundary (because either
301 * the IP header is directly contained, or IV/RFC1042 headers that
302 * have a length divisible by four are in front of it.
304 * With A-MSDU frames, however, the payload data address must
305 * yield two modulo four because there are 14-byte 802.3 headers
306 * within the A-MSDU frames that push the IP header further back
307 * to a multiple of four again. Thankfully, the specs were sane
308 * enough this time around to require padding each A-MSDU subframe
309 * to a length that is a multiple of four.
311 * Padding like atheros hardware adds which is inbetween the 802.11
312 * header and the payload is not supported, the driver is required
313 * to move the 802.11 header further back in that case.
315 hdrlen = ieee80211_get_hdrlen(rx->fc);
316 if (rx->flags & IEEE80211_TXRXD_RX_AMSDU)
318 WARN_ON_ONCE(((unsigned long)(rx->skb->data + hdrlen)) & 3);
323 static u32 ieee80211_rx_load_stats(struct ieee80211_local *local,
325 struct ieee80211_rx_status *status,
326 struct ieee80211_rate *rate)
328 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
329 u32 load = 0, hdrtime;
331 /* Estimate total channel use caused by this frame */
333 /* 1 bit at 1 Mbit/s takes 1 usec; in channel_use values,
334 * 1 usec = 1/8 * (1080 / 10) = 13.5 */
336 if (status->band == IEEE80211_BAND_5GHZ ||
337 (status->band == IEEE80211_BAND_5GHZ &&
338 rate->flags & IEEE80211_RATE_ERP_G))
339 hdrtime = CHAN_UTIL_HDR_SHORT;
341 hdrtime = CHAN_UTIL_HDR_LONG;
344 if (!is_multicast_ether_addr(hdr->addr1))
347 /* TODO: optimise again */
348 load += skb->len * CHAN_UTIL_RATE_LCM / rate->bitrate;
350 /* Divide channel_use by 8 to avoid wrapping around the counter */
351 load >>= CHAN_UTIL_SHIFT;
358 static ieee80211_rx_result
359 ieee80211_rx_h_if_stats(struct ieee80211_txrx_data *rx)
362 rx->sta->channel_use_raw += rx->u.rx.load;
363 rx->sdata->channel_use_raw += rx->u.rx.load;
367 static ieee80211_rx_result
368 ieee80211_rx_h_passive_scan(struct ieee80211_txrx_data *rx)
370 struct ieee80211_local *local = rx->local;
371 struct sk_buff *skb = rx->skb;
373 if (unlikely(local->sta_hw_scanning))
374 return ieee80211_sta_rx_scan(rx->dev, skb, rx->u.rx.status);
376 if (unlikely(local->sta_sw_scanning)) {
377 /* drop all the other packets during a software scan anyway */
378 if (ieee80211_sta_rx_scan(rx->dev, skb, rx->u.rx.status)
384 if (unlikely(rx->flags & IEEE80211_TXRXD_RXIN_SCAN)) {
385 /* scanning finished during invoking of handlers */
386 I802_DEBUG_INC(local->rx_handlers_drop_passive_scan);
387 return RX_DROP_UNUSABLE;
393 static ieee80211_rx_result
394 ieee80211_rx_h_check(struct ieee80211_txrx_data *rx)
396 struct ieee80211_hdr *hdr;
397 hdr = (struct ieee80211_hdr *) rx->skb->data;
399 /* Drop duplicate 802.11 retransmissions (IEEE 802.11 Chap. 9.2.9) */
400 if (rx->sta && !is_multicast_ether_addr(hdr->addr1)) {
401 if (unlikely(rx->fc & IEEE80211_FCTL_RETRY &&
402 rx->sta->last_seq_ctrl[rx->u.rx.queue] ==
404 if (rx->flags & IEEE80211_TXRXD_RXRA_MATCH) {
405 rx->local->dot11FrameDuplicateCount++;
406 rx->sta->num_duplicates++;
408 return RX_DROP_MONITOR;
410 rx->sta->last_seq_ctrl[rx->u.rx.queue] = hdr->seq_ctrl;
413 if (unlikely(rx->skb->len < 16)) {
414 I802_DEBUG_INC(rx->local->rx_handlers_drop_short);
415 return RX_DROP_MONITOR;
418 /* Drop disallowed frame classes based on STA auth/assoc state;
419 * IEEE 802.11, Chap 5.5.
421 * 80211.o does filtering only based on association state, i.e., it
422 * drops Class 3 frames from not associated stations. hostapd sends
423 * deauth/disassoc frames when needed. In addition, hostapd is
424 * responsible for filtering on both auth and assoc states.
426 if (unlikely(((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA ||
427 ((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL &&
428 (rx->fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PSPOLL)) &&
429 rx->sdata->vif.type != IEEE80211_IF_TYPE_IBSS &&
430 (!rx->sta || !(rx->sta->flags & WLAN_STA_ASSOC)))) {
431 if ((!(rx->fc & IEEE80211_FCTL_FROMDS) &&
432 !(rx->fc & IEEE80211_FCTL_TODS) &&
433 (rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA)
434 || !(rx->flags & IEEE80211_TXRXD_RXRA_MATCH)) {
435 /* Drop IBSS frames and frames for other hosts
437 return RX_DROP_MONITOR;
440 return RX_DROP_MONITOR;
447 static ieee80211_rx_result
448 ieee80211_rx_h_decrypt(struct ieee80211_txrx_data *rx)
450 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data;
453 ieee80211_rx_result result = RX_DROP_UNUSABLE;
454 struct ieee80211_key *stakey = NULL;
459 * There are three types of keys:
461 * - PTK (pairwise keys)
462 * - STK (station-to-station pairwise keys)
464 * When selecting a key, we have to distinguish between multicast
465 * (including broadcast) and unicast frames, the latter can only
466 * use PTKs and STKs while the former always use GTKs. Unless, of
467 * course, actual WEP keys ("pre-RSNA") are used, then unicast
468 * frames can also use key indizes like GTKs. Hence, if we don't
469 * have a PTK/STK we check the key index for a WEP key.
471 * Note that in a regular BSS, multicast frames are sent by the
472 * AP only, associated stations unicast the frame to the AP first
473 * which then multicasts it on their behalf.
475 * There is also a slight problem in IBSS mode: GTKs are negotiated
476 * with each station, that is something we don't currently handle.
477 * The spec seems to expect that one negotiates the same key with
478 * every station but there's no such requirement; VLANs could be
482 if (!(rx->fc & IEEE80211_FCTL_PROTECTED))
486 * No point in finding a key and decrypting if the frame is neither
487 * addressed to us nor a multicast frame.
489 if (!(rx->flags & IEEE80211_TXRXD_RXRA_MATCH))
493 stakey = rcu_dereference(rx->sta->key);
495 if (!is_multicast_ether_addr(hdr->addr1) && stakey) {
499 * The device doesn't give us the IV so we won't be
500 * able to look up the key. That's ok though, we
501 * don't need to decrypt the frame, we just won't
502 * be able to keep statistics accurate.
503 * Except for key threshold notifications, should
504 * we somehow allow the driver to tell us which key
505 * the hardware used if this flag is set?
507 if ((rx->u.rx.status->flag & RX_FLAG_DECRYPTED) &&
508 (rx->u.rx.status->flag & RX_FLAG_IV_STRIPPED))
511 hdrlen = ieee80211_get_hdrlen(rx->fc);
513 if (rx->skb->len < 8 + hdrlen)
514 return RX_DROP_UNUSABLE; /* TODO: count this? */
517 * no need to call ieee80211_wep_get_keyidx,
518 * it verifies a bunch of things we've done already
520 keyidx = rx->skb->data[hdrlen + 3] >> 6;
522 rx->key = rcu_dereference(rx->sdata->keys[keyidx]);
525 * RSNA-protected unicast frames should always be sent with
526 * pairwise or station-to-station keys, but for WEP we allow
527 * using a key index as well.
529 if (rx->key && rx->key->conf.alg != ALG_WEP &&
530 !is_multicast_ether_addr(hdr->addr1))
535 rx->key->tx_rx_count++;
536 /* TODO: add threshold stuff again */
538 #ifdef CONFIG_MAC80211_DEBUG
540 printk(KERN_DEBUG "%s: RX protected frame,"
541 " but have no key\n", rx->dev->name);
542 #endif /* CONFIG_MAC80211_DEBUG */
543 return RX_DROP_MONITOR;
546 /* Check for weak IVs if possible */
547 if (rx->sta && rx->key->conf.alg == ALG_WEP &&
548 ((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) &&
549 (!(rx->u.rx.status->flag & RX_FLAG_IV_STRIPPED) ||
550 !(rx->u.rx.status->flag & RX_FLAG_DECRYPTED)) &&
551 ieee80211_wep_is_weak_iv(rx->skb, rx->key))
552 rx->sta->wep_weak_iv_count++;
554 switch (rx->key->conf.alg) {
556 result = ieee80211_crypto_wep_decrypt(rx);
559 result = ieee80211_crypto_tkip_decrypt(rx);
562 result = ieee80211_crypto_ccmp_decrypt(rx);
566 /* either the frame has been decrypted or will be dropped */
567 rx->u.rx.status->flag |= RX_FLAG_DECRYPTED;
572 static void ap_sta_ps_start(struct net_device *dev, struct sta_info *sta)
574 struct ieee80211_sub_if_data *sdata;
575 DECLARE_MAC_BUF(mac);
577 sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
580 atomic_inc(&sdata->bss->num_sta_ps);
581 sta->flags |= WLAN_STA_PS;
582 sta->flags &= ~WLAN_STA_PSPOLL;
583 #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
584 printk(KERN_DEBUG "%s: STA %s aid %d enters power save mode\n",
585 dev->name, print_mac(mac, sta->addr), sta->aid);
586 #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
589 static int ap_sta_ps_end(struct net_device *dev, struct sta_info *sta)
591 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
594 struct ieee80211_sub_if_data *sdata;
595 struct ieee80211_tx_packet_data *pkt_data;
596 DECLARE_MAC_BUF(mac);
598 sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
600 atomic_dec(&sdata->bss->num_sta_ps);
601 sta->flags &= ~(WLAN_STA_PS | WLAN_STA_TIM | WLAN_STA_PSPOLL);
602 if (!skb_queue_empty(&sta->ps_tx_buf)) {
603 if (local->ops->set_tim)
604 local->ops->set_tim(local_to_hw(local), sta->aid, 0);
606 bss_tim_clear(local, sdata->bss, sta->aid);
608 #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
609 printk(KERN_DEBUG "%s: STA %s aid %d exits power save mode\n",
610 dev->name, print_mac(mac, sta->addr), sta->aid);
611 #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
612 /* Send all buffered frames to the station */
613 while ((skb = skb_dequeue(&sta->tx_filtered)) != NULL) {
614 pkt_data = (struct ieee80211_tx_packet_data *) skb->cb;
616 pkt_data->flags |= IEEE80211_TXPD_REQUEUE;
619 while ((skb = skb_dequeue(&sta->ps_tx_buf)) != NULL) {
620 pkt_data = (struct ieee80211_tx_packet_data *) skb->cb;
621 local->total_ps_buffered--;
623 #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
624 printk(KERN_DEBUG "%s: STA %s aid %d send PS frame "
625 "since STA not sleeping anymore\n", dev->name,
626 print_mac(mac, sta->addr), sta->aid);
627 #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
628 pkt_data->flags |= IEEE80211_TXPD_REQUEUE;
635 static ieee80211_rx_result
636 ieee80211_rx_h_sta_process(struct ieee80211_txrx_data *rx)
638 struct sta_info *sta = rx->sta;
639 struct net_device *dev = rx->dev;
640 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data;
645 /* Update last_rx only for IBSS packets which are for the current
646 * BSSID to avoid keeping the current IBSS network alive in cases where
647 * other STAs are using different BSSID. */
648 if (rx->sdata->vif.type == IEEE80211_IF_TYPE_IBSS) {
649 u8 *bssid = ieee80211_get_bssid(hdr, rx->skb->len,
650 IEEE80211_IF_TYPE_IBSS);
651 if (compare_ether_addr(bssid, rx->sdata->u.sta.bssid) == 0)
652 sta->last_rx = jiffies;
654 if (!is_multicast_ether_addr(hdr->addr1) ||
655 rx->sdata->vif.type == IEEE80211_IF_TYPE_STA) {
656 /* Update last_rx only for unicast frames in order to prevent
657 * the Probe Request frames (the only broadcast frames from a
658 * STA in infrastructure mode) from keeping a connection alive.
660 sta->last_rx = jiffies;
663 if (!(rx->flags & IEEE80211_TXRXD_RXRA_MATCH))
667 sta->rx_bytes += rx->skb->len;
668 sta->last_rssi = rx->u.rx.status->ssi;
669 sta->last_signal = rx->u.rx.status->signal;
670 sta->last_noise = rx->u.rx.status->noise;
672 if (!(rx->fc & IEEE80211_FCTL_MOREFRAGS)) {
673 /* Change STA power saving mode only in the end of a frame
674 * exchange sequence */
675 if ((sta->flags & WLAN_STA_PS) && !(rx->fc & IEEE80211_FCTL_PM))
676 rx->u.rx.sent_ps_buffered += ap_sta_ps_end(dev, sta);
677 else if (!(sta->flags & WLAN_STA_PS) &&
678 (rx->fc & IEEE80211_FCTL_PM))
679 ap_sta_ps_start(dev, sta);
682 /* Drop data::nullfunc frames silently, since they are used only to
683 * control station power saving mode. */
684 if ((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA &&
685 (rx->fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_NULLFUNC) {
686 I802_DEBUG_INC(rx->local->rx_handlers_drop_nullfunc);
687 /* Update counter and free packet here to avoid counting this
688 * as a dropped packed. */
690 dev_kfree_skb(rx->skb);
695 } /* ieee80211_rx_h_sta_process */
697 static inline struct ieee80211_fragment_entry *
698 ieee80211_reassemble_add(struct ieee80211_sub_if_data *sdata,
699 unsigned int frag, unsigned int seq, int rx_queue,
700 struct sk_buff **skb)
702 struct ieee80211_fragment_entry *entry;
705 idx = sdata->fragment_next;
706 entry = &sdata->fragments[sdata->fragment_next++];
707 if (sdata->fragment_next >= IEEE80211_FRAGMENT_MAX)
708 sdata->fragment_next = 0;
710 if (!skb_queue_empty(&entry->skb_list)) {
711 #ifdef CONFIG_MAC80211_DEBUG
712 struct ieee80211_hdr *hdr =
713 (struct ieee80211_hdr *) entry->skb_list.next->data;
714 DECLARE_MAC_BUF(mac);
715 DECLARE_MAC_BUF(mac2);
716 printk(KERN_DEBUG "%s: RX reassembly removed oldest "
717 "fragment entry (idx=%d age=%lu seq=%d last_frag=%d "
718 "addr1=%s addr2=%s\n",
719 sdata->dev->name, idx,
720 jiffies - entry->first_frag_time, entry->seq,
721 entry->last_frag, print_mac(mac, hdr->addr1),
722 print_mac(mac2, hdr->addr2));
723 #endif /* CONFIG_MAC80211_DEBUG */
724 __skb_queue_purge(&entry->skb_list);
727 __skb_queue_tail(&entry->skb_list, *skb); /* no need for locking */
729 entry->first_frag_time = jiffies;
731 entry->rx_queue = rx_queue;
732 entry->last_frag = frag;
734 entry->extra_len = 0;
739 static inline struct ieee80211_fragment_entry *
740 ieee80211_reassemble_find(struct ieee80211_sub_if_data *sdata,
741 u16 fc, unsigned int frag, unsigned int seq,
742 int rx_queue, struct ieee80211_hdr *hdr)
744 struct ieee80211_fragment_entry *entry;
747 idx = sdata->fragment_next;
748 for (i = 0; i < IEEE80211_FRAGMENT_MAX; i++) {
749 struct ieee80211_hdr *f_hdr;
754 idx = IEEE80211_FRAGMENT_MAX - 1;
756 entry = &sdata->fragments[idx];
757 if (skb_queue_empty(&entry->skb_list) || entry->seq != seq ||
758 entry->rx_queue != rx_queue ||
759 entry->last_frag + 1 != frag)
762 f_hdr = (struct ieee80211_hdr *) entry->skb_list.next->data;
763 f_fc = le16_to_cpu(f_hdr->frame_control);
765 if ((fc & IEEE80211_FCTL_FTYPE) != (f_fc & IEEE80211_FCTL_FTYPE) ||
766 compare_ether_addr(hdr->addr1, f_hdr->addr1) != 0 ||
767 compare_ether_addr(hdr->addr2, f_hdr->addr2) != 0)
770 if (time_after(jiffies, entry->first_frag_time + 2 * HZ)) {
771 __skb_queue_purge(&entry->skb_list);
780 static ieee80211_rx_result
781 ieee80211_rx_h_defragment(struct ieee80211_txrx_data *rx)
783 struct ieee80211_hdr *hdr;
785 unsigned int frag, seq;
786 struct ieee80211_fragment_entry *entry;
788 DECLARE_MAC_BUF(mac);
790 hdr = (struct ieee80211_hdr *) rx->skb->data;
791 sc = le16_to_cpu(hdr->seq_ctrl);
792 frag = sc & IEEE80211_SCTL_FRAG;
794 if (likely((!(rx->fc & IEEE80211_FCTL_MOREFRAGS) && frag == 0) ||
795 (rx->skb)->len < 24 ||
796 is_multicast_ether_addr(hdr->addr1))) {
800 I802_DEBUG_INC(rx->local->rx_handlers_fragments);
802 seq = (sc & IEEE80211_SCTL_SEQ) >> 4;
805 /* This is the first fragment of a new frame. */
806 entry = ieee80211_reassemble_add(rx->sdata, frag, seq,
807 rx->u.rx.queue, &(rx->skb));
808 if (rx->key && rx->key->conf.alg == ALG_CCMP &&
809 (rx->fc & IEEE80211_FCTL_PROTECTED)) {
810 /* Store CCMP PN so that we can verify that the next
811 * fragment has a sequential PN value. */
813 memcpy(entry->last_pn,
814 rx->key->u.ccmp.rx_pn[rx->u.rx.queue],
820 /* This is a fragment for a frame that should already be pending in
821 * fragment cache. Add this fragment to the end of the pending entry.
823 entry = ieee80211_reassemble_find(rx->sdata, rx->fc, frag, seq,
824 rx->u.rx.queue, hdr);
826 I802_DEBUG_INC(rx->local->rx_handlers_drop_defrag);
827 return RX_DROP_MONITOR;
830 /* Verify that MPDUs within one MSDU have sequential PN values.
831 * (IEEE 802.11i, 8.3.3.4.5) */
834 u8 pn[CCMP_PN_LEN], *rpn;
835 if (!rx->key || rx->key->conf.alg != ALG_CCMP)
836 return RX_DROP_UNUSABLE;
837 memcpy(pn, entry->last_pn, CCMP_PN_LEN);
838 for (i = CCMP_PN_LEN - 1; i >= 0; i--) {
843 rpn = rx->key->u.ccmp.rx_pn[rx->u.rx.queue];
844 if (memcmp(pn, rpn, CCMP_PN_LEN) != 0) {
846 printk(KERN_DEBUG "%s: defrag: CCMP PN not "
848 " PN=%02x%02x%02x%02x%02x%02x "
849 "(expected %02x%02x%02x%02x%02x%02x)\n",
850 rx->dev->name, print_mac(mac, hdr->addr2),
851 rpn[0], rpn[1], rpn[2], rpn[3], rpn[4],
852 rpn[5], pn[0], pn[1], pn[2], pn[3],
854 return RX_DROP_UNUSABLE;
856 memcpy(entry->last_pn, pn, CCMP_PN_LEN);
859 skb_pull(rx->skb, ieee80211_get_hdrlen(rx->fc));
860 __skb_queue_tail(&entry->skb_list, rx->skb);
861 entry->last_frag = frag;
862 entry->extra_len += rx->skb->len;
863 if (rx->fc & IEEE80211_FCTL_MOREFRAGS) {
868 rx->skb = __skb_dequeue(&entry->skb_list);
869 if (skb_tailroom(rx->skb) < entry->extra_len) {
870 I802_DEBUG_INC(rx->local->rx_expand_skb_head2);
871 if (unlikely(pskb_expand_head(rx->skb, 0, entry->extra_len,
873 I802_DEBUG_INC(rx->local->rx_handlers_drop_defrag);
874 __skb_queue_purge(&entry->skb_list);
875 return RX_DROP_UNUSABLE;
878 while ((skb = __skb_dequeue(&entry->skb_list))) {
879 memcpy(skb_put(rx->skb, skb->len), skb->data, skb->len);
883 /* Complete frame has been reassembled - process it now */
884 rx->flags |= IEEE80211_TXRXD_FRAGMENTED;
888 rx->sta->rx_packets++;
889 if (is_multicast_ether_addr(hdr->addr1))
890 rx->local->dot11MulticastReceivedFrameCount++;
892 ieee80211_led_rx(rx->local);
896 static ieee80211_rx_result
897 ieee80211_rx_h_ps_poll(struct ieee80211_txrx_data *rx)
899 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev);
902 DECLARE_MAC_BUF(mac);
904 if (likely(!rx->sta ||
905 (rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_CTL ||
906 (rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_PSPOLL ||
907 !(rx->flags & IEEE80211_TXRXD_RXRA_MATCH)))
910 if ((sdata->vif.type != IEEE80211_IF_TYPE_AP) &&
911 (sdata->vif.type != IEEE80211_IF_TYPE_VLAN))
912 return RX_DROP_UNUSABLE;
914 skb = skb_dequeue(&rx->sta->tx_filtered);
916 skb = skb_dequeue(&rx->sta->ps_tx_buf);
918 rx->local->total_ps_buffered--;
920 no_pending_pkts = skb_queue_empty(&rx->sta->tx_filtered) &&
921 skb_queue_empty(&rx->sta->ps_tx_buf);
924 struct ieee80211_hdr *hdr =
925 (struct ieee80211_hdr *) skb->data;
928 * Tell TX path to send one frame even though the STA may
929 * still remain is PS mode after this frame exchange.
931 rx->sta->flags |= WLAN_STA_PSPOLL;
933 #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
934 printk(KERN_DEBUG "STA %s aid %d: PS Poll (entries after %d)\n",
935 print_mac(mac, rx->sta->addr), rx->sta->aid,
936 skb_queue_len(&rx->sta->ps_tx_buf));
937 #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
939 /* Use MoreData flag to indicate whether there are more
940 * buffered frames for this STA */
941 if (no_pending_pkts) {
942 hdr->frame_control &= cpu_to_le16(~IEEE80211_FCTL_MOREDATA);
943 rx->sta->flags &= ~WLAN_STA_TIM;
945 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA);
949 if (no_pending_pkts) {
950 if (rx->local->ops->set_tim)
951 rx->local->ops->set_tim(local_to_hw(rx->local),
954 bss_tim_clear(rx->local, rx->sdata->bss, rx->sta->aid);
956 #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
957 } else if (!rx->u.rx.sent_ps_buffered) {
958 printk(KERN_DEBUG "%s: STA %s sent PS Poll even "
959 "though there is no buffered frames for it\n",
960 rx->dev->name, print_mac(mac, rx->sta->addr));
961 #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
965 /* Free PS Poll skb here instead of returning RX_DROP that would
966 * count as an dropped frame. */
967 dev_kfree_skb(rx->skb);
972 static ieee80211_rx_result
973 ieee80211_rx_h_remove_qos_control(struct ieee80211_txrx_data *rx)
976 u8 *data = rx->skb->data;
977 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) data;
979 if (!WLAN_FC_IS_QOS_DATA(fc))
982 /* remove the qos control field, update frame type and meta-data */
983 memmove(data + 2, data, ieee80211_get_hdrlen(fc) - 2);
984 hdr = (struct ieee80211_hdr *) skb_pull(rx->skb, 2);
985 /* change frame type to non QOS */
986 rx->fc = fc &= ~IEEE80211_STYPE_QOS_DATA;
987 hdr->frame_control = cpu_to_le16(fc);
993 ieee80211_802_1x_port_control(struct ieee80211_txrx_data *rx)
995 if (unlikely(!rx->sta || !(rx->sta->flags & WLAN_STA_AUTHORIZED))) {
996 #ifdef CONFIG_MAC80211_DEBUG
998 printk(KERN_DEBUG "%s: dropped frame "
999 "(unauthorized port)\n", rx->dev->name);
1000 #endif /* CONFIG_MAC80211_DEBUG */
1008 ieee80211_drop_unencrypted(struct ieee80211_txrx_data *rx)
1011 * Pass through unencrypted frames if the hardware has
1012 * decrypted them already.
1014 if (rx->u.rx.status->flag & RX_FLAG_DECRYPTED)
1017 /* Drop unencrypted frames if key is set. */
1018 if (unlikely(!(rx->fc & IEEE80211_FCTL_PROTECTED) &&
1019 (rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA &&
1020 (rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_NULLFUNC &&
1021 (rx->key || rx->sdata->drop_unencrypted))) {
1022 if (net_ratelimit())
1023 printk(KERN_DEBUG "%s: RX non-WEP frame, but expected "
1024 "encryption\n", rx->dev->name);
1031 ieee80211_data_to_8023(struct ieee80211_txrx_data *rx)
1033 struct net_device *dev = rx->dev;
1034 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data;
1035 u16 fc, hdrlen, ethertype;
1039 struct sk_buff *skb = rx->skb;
1040 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1041 DECLARE_MAC_BUF(mac);
1042 DECLARE_MAC_BUF(mac2);
1043 DECLARE_MAC_BUF(mac3);
1044 DECLARE_MAC_BUF(mac4);
1048 if (unlikely(!WLAN_FC_DATA_PRESENT(fc)))
1051 hdrlen = ieee80211_get_hdrlen(fc);
1053 /* convert IEEE 802.11 header + possible LLC headers into Ethernet
1055 * IEEE 802.11 address fields:
1056 * ToDS FromDS Addr1 Addr2 Addr3 Addr4
1057 * 0 0 DA SA BSSID n/a
1058 * 0 1 DA BSSID SA n/a
1059 * 1 0 BSSID SA DA n/a
1063 switch (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) {
1064 case IEEE80211_FCTL_TODS:
1066 memcpy(dst, hdr->addr3, ETH_ALEN);
1067 memcpy(src, hdr->addr2, ETH_ALEN);
1069 if (unlikely(sdata->vif.type != IEEE80211_IF_TYPE_AP &&
1070 sdata->vif.type != IEEE80211_IF_TYPE_VLAN)) {
1071 if (net_ratelimit())
1072 printk(KERN_DEBUG "%s: dropped ToDS frame "
1073 "(BSSID=%s SA=%s DA=%s)\n",
1075 print_mac(mac, hdr->addr1),
1076 print_mac(mac2, hdr->addr2),
1077 print_mac(mac3, hdr->addr3));
1081 case (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS):
1083 memcpy(dst, hdr->addr3, ETH_ALEN);
1084 memcpy(src, hdr->addr4, ETH_ALEN);
1086 if (unlikely(sdata->vif.type != IEEE80211_IF_TYPE_WDS)) {
1087 if (net_ratelimit())
1088 printk(KERN_DEBUG "%s: dropped FromDS&ToDS "
1089 "frame (RA=%s TA=%s DA=%s SA=%s)\n",
1091 print_mac(mac, hdr->addr1),
1092 print_mac(mac2, hdr->addr2),
1093 print_mac(mac3, hdr->addr3),
1094 print_mac(mac4, hdr->addr4));
1098 case IEEE80211_FCTL_FROMDS:
1100 memcpy(dst, hdr->addr1, ETH_ALEN);
1101 memcpy(src, hdr->addr3, ETH_ALEN);
1103 if (sdata->vif.type != IEEE80211_IF_TYPE_STA ||
1104 (is_multicast_ether_addr(dst) &&
1105 !compare_ether_addr(src, dev->dev_addr)))
1110 memcpy(dst, hdr->addr1, ETH_ALEN);
1111 memcpy(src, hdr->addr2, ETH_ALEN);
1113 if (sdata->vif.type != IEEE80211_IF_TYPE_IBSS) {
1114 if (net_ratelimit()) {
1115 printk(KERN_DEBUG "%s: dropped IBSS frame "
1116 "(DA=%s SA=%s BSSID=%s)\n",
1118 print_mac(mac, hdr->addr1),
1119 print_mac(mac2, hdr->addr2),
1120 print_mac(mac3, hdr->addr3));
1127 if (unlikely(skb->len - hdrlen < 8)) {
1128 if (net_ratelimit()) {
1129 printk(KERN_DEBUG "%s: RX too short data frame "
1130 "payload\n", dev->name);
1135 payload = skb->data + hdrlen;
1136 ethertype = (payload[6] << 8) | payload[7];
1138 if (likely((compare_ether_addr(payload, rfc1042_header) == 0 &&
1139 ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
1140 compare_ether_addr(payload, bridge_tunnel_header) == 0)) {
1141 /* remove RFC1042 or Bridge-Tunnel encapsulation and
1142 * replace EtherType */
1143 skb_pull(skb, hdrlen + 6);
1144 memcpy(skb_push(skb, ETH_ALEN), src, ETH_ALEN);
1145 memcpy(skb_push(skb, ETH_ALEN), dst, ETH_ALEN);
1147 struct ethhdr *ehdr;
1150 skb_pull(skb, hdrlen);
1151 len = htons(skb->len);
1152 ehdr = (struct ethhdr *) skb_push(skb, sizeof(struct ethhdr));
1153 memcpy(ehdr->h_dest, dst, ETH_ALEN);
1154 memcpy(ehdr->h_source, src, ETH_ALEN);
1155 ehdr->h_proto = len;
1161 * requires that rx->skb is a frame with ethernet header
1163 static bool ieee80211_frame_allowed(struct ieee80211_txrx_data *rx)
1165 static const u8 pae_group_addr[ETH_ALEN]
1166 = { 0x01, 0x80, 0xC2, 0x00, 0x00, 0x03 };
1167 struct ethhdr *ehdr = (struct ethhdr *) rx->skb->data;
1170 * Allow EAPOL frames to us/the PAE group address regardless
1171 * of whether the frame was encrypted or not.
1173 if (ehdr->h_proto == htons(ETH_P_PAE) &&
1174 (compare_ether_addr(ehdr->h_dest, rx->dev->dev_addr) == 0 ||
1175 compare_ether_addr(ehdr->h_dest, pae_group_addr) == 0))
1178 if (ieee80211_802_1x_port_control(rx) ||
1179 ieee80211_drop_unencrypted(rx))
1186 * requires that rx->skb is a frame with ethernet header
1189 ieee80211_deliver_skb(struct ieee80211_txrx_data *rx)
1191 struct net_device *dev = rx->dev;
1192 struct ieee80211_local *local = rx->local;
1193 struct sk_buff *skb, *xmit_skb;
1194 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1195 struct ethhdr *ehdr = (struct ethhdr *) rx->skb->data;
1196 struct sta_info *dsta;
1201 if (local->bridge_packets && (sdata->vif.type == IEEE80211_IF_TYPE_AP ||
1202 sdata->vif.type == IEEE80211_IF_TYPE_VLAN) &&
1203 (rx->flags & IEEE80211_TXRXD_RXRA_MATCH)) {
1204 if (is_multicast_ether_addr(ehdr->h_dest)) {
1206 * send multicast frames both to higher layers in
1207 * local net stack and back to the wireless medium
1209 xmit_skb = skb_copy(skb, GFP_ATOMIC);
1210 if (!xmit_skb && net_ratelimit())
1211 printk(KERN_DEBUG "%s: failed to clone "
1212 "multicast frame\n", dev->name);
1214 dsta = sta_info_get(local, skb->data);
1215 if (dsta && dsta->dev == dev) {
1217 * The destination station is associated to
1218 * this AP (in this VLAN), so send the frame
1219 * directly to it and do not pass it to local
1231 /* deliver to local stack */
1232 skb->protocol = eth_type_trans(skb, dev);
1233 memset(skb->cb, 0, sizeof(skb->cb));
1238 /* send to wireless media */
1239 xmit_skb->protocol = htons(ETH_P_802_3);
1240 skb_reset_network_header(xmit_skb);
1241 skb_reset_mac_header(xmit_skb);
1242 dev_queue_xmit(xmit_skb);
1246 static ieee80211_rx_result
1247 ieee80211_rx_h_amsdu(struct ieee80211_txrx_data *rx)
1249 struct net_device *dev = rx->dev;
1250 struct ieee80211_local *local = rx->local;
1253 struct sk_buff *skb = rx->skb, *frame = NULL;
1254 const struct ethhdr *eth;
1258 DECLARE_MAC_BUF(mac);
1261 if (unlikely((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA))
1264 if (unlikely(!WLAN_FC_DATA_PRESENT(fc)))
1265 return RX_DROP_MONITOR;
1267 if (!(rx->flags & IEEE80211_TXRXD_RX_AMSDU))
1270 err = ieee80211_data_to_8023(rx);
1272 return RX_DROP_UNUSABLE;
1276 dev->stats.rx_packets++;
1277 dev->stats.rx_bytes += skb->len;
1279 /* skip the wrapping header */
1280 eth = (struct ethhdr *) skb_pull(skb, sizeof(struct ethhdr));
1282 return RX_DROP_UNUSABLE;
1284 while (skb != frame) {
1286 __be16 len = eth->h_proto;
1287 unsigned int subframe_len = sizeof(struct ethhdr) + ntohs(len);
1289 remaining = skb->len;
1290 memcpy(dst, eth->h_dest, ETH_ALEN);
1291 memcpy(src, eth->h_source, ETH_ALEN);
1293 padding = ((4 - subframe_len) & 0x3);
1294 /* the last MSDU has no padding */
1295 if (subframe_len > remaining) {
1296 printk(KERN_DEBUG "%s: wrong buffer size", dev->name);
1297 return RX_DROP_UNUSABLE;
1300 skb_pull(skb, sizeof(struct ethhdr));
1301 /* if last subframe reuse skb */
1302 if (remaining <= subframe_len + padding)
1305 frame = dev_alloc_skb(local->hw.extra_tx_headroom +
1309 return RX_DROP_UNUSABLE;
1311 skb_reserve(frame, local->hw.extra_tx_headroom +
1312 sizeof(struct ethhdr));
1313 memcpy(skb_put(frame, ntohs(len)), skb->data,
1316 eth = (struct ethhdr *) skb_pull(skb, ntohs(len) +
1319 printk(KERN_DEBUG "%s: wrong buffer size ",
1321 dev_kfree_skb(frame);
1322 return RX_DROP_UNUSABLE;
1326 skb_reset_network_header(frame);
1328 frame->priority = skb->priority;
1331 payload = frame->data;
1332 ethertype = (payload[6] << 8) | payload[7];
1334 if (likely((compare_ether_addr(payload, rfc1042_header) == 0 &&
1335 ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
1336 compare_ether_addr(payload,
1337 bridge_tunnel_header) == 0)) {
1338 /* remove RFC1042 or Bridge-Tunnel
1339 * encapsulation and replace EtherType */
1341 memcpy(skb_push(frame, ETH_ALEN), src, ETH_ALEN);
1342 memcpy(skb_push(frame, ETH_ALEN), dst, ETH_ALEN);
1344 memcpy(skb_push(frame, sizeof(__be16)),
1345 &len, sizeof(__be16));
1346 memcpy(skb_push(frame, ETH_ALEN), src, ETH_ALEN);
1347 memcpy(skb_push(frame, ETH_ALEN), dst, ETH_ALEN);
1350 if (!ieee80211_frame_allowed(rx)) {
1351 if (skb == frame) /* last frame */
1352 return RX_DROP_UNUSABLE;
1353 dev_kfree_skb(frame);
1357 ieee80211_deliver_skb(rx);
1363 static ieee80211_rx_result
1364 ieee80211_rx_h_data(struct ieee80211_txrx_data *rx)
1366 struct net_device *dev = rx->dev;
1371 if (unlikely((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA))
1374 if (unlikely(!WLAN_FC_DATA_PRESENT(fc)))
1375 return RX_DROP_MONITOR;
1377 err = ieee80211_data_to_8023(rx);
1379 return RX_DROP_UNUSABLE;
1381 if (!ieee80211_frame_allowed(rx))
1382 return RX_DROP_MONITOR;
1386 dev->stats.rx_packets++;
1387 dev->stats.rx_bytes += rx->skb->len;
1389 ieee80211_deliver_skb(rx);
1394 static ieee80211_rx_result
1395 ieee80211_rx_h_ctrl(struct ieee80211_txrx_data *rx)
1397 struct ieee80211_local *local = rx->local;
1398 struct ieee80211_hw *hw = &local->hw;
1399 struct sk_buff *skb = rx->skb;
1400 struct ieee80211_bar *bar = (struct ieee80211_bar *) skb->data;
1401 struct tid_ampdu_rx *tid_agg_rx;
1405 if (likely((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_CTL))
1408 if ((rx->fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_BACK_REQ) {
1411 tid = le16_to_cpu(bar->control) >> 12;
1412 tid_agg_rx = &(rx->sta->ampdu_mlme.tid_rx[tid]);
1413 if (tid_agg_rx->state != HT_AGG_STATE_OPERATIONAL)
1416 start_seq_num = le16_to_cpu(bar->start_seq_num) >> 4;
1418 /* reset session timer */
1419 if (tid_agg_rx->timeout) {
1420 unsigned long expires =
1421 jiffies + (tid_agg_rx->timeout / 1000) * HZ;
1422 mod_timer(&tid_agg_rx->session_timer, expires);
1425 /* manage reordering buffer according to requested */
1426 /* sequence number */
1428 ieee80211_sta_manage_reorder_buf(hw, tid_agg_rx, NULL,
1431 return RX_DROP_UNUSABLE;
1437 static ieee80211_rx_result
1438 ieee80211_rx_h_mgmt(struct ieee80211_txrx_data *rx)
1440 struct ieee80211_sub_if_data *sdata;
1442 if (!(rx->flags & IEEE80211_TXRXD_RXRA_MATCH))
1443 return RX_DROP_MONITOR;
1445 sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev);
1446 if ((sdata->vif.type == IEEE80211_IF_TYPE_STA ||
1447 sdata->vif.type == IEEE80211_IF_TYPE_IBSS) &&
1448 !(sdata->flags & IEEE80211_SDATA_USERSPACE_MLME))
1449 ieee80211_sta_rx_mgmt(rx->dev, rx->skb, rx->u.rx.status);
1451 return RX_DROP_MONITOR;
1456 static void ieee80211_rx_michael_mic_report(struct net_device *dev,
1457 struct ieee80211_hdr *hdr,
1458 struct ieee80211_txrx_data *rx)
1461 DECLARE_MAC_BUF(mac);
1462 DECLARE_MAC_BUF(mac2);
1464 hdrlen = ieee80211_get_hdrlen_from_skb(rx->skb);
1465 if (rx->skb->len >= hdrlen + 4)
1466 keyidx = rx->skb->data[hdrlen + 3] >> 6;
1470 if (net_ratelimit())
1471 printk(KERN_DEBUG "%s: TKIP hwaccel reported Michael MIC "
1472 "failure from %s to %s keyidx=%d\n",
1473 dev->name, print_mac(mac, hdr->addr2),
1474 print_mac(mac2, hdr->addr1), keyidx);
1478 * Some hardware seem to generate incorrect Michael MIC
1479 * reports; ignore them to avoid triggering countermeasures.
1481 if (net_ratelimit())
1482 printk(KERN_DEBUG "%s: ignored spurious Michael MIC "
1483 "error for unknown address %s\n",
1484 dev->name, print_mac(mac, hdr->addr2));
1488 if (!(rx->fc & IEEE80211_FCTL_PROTECTED)) {
1489 if (net_ratelimit())
1490 printk(KERN_DEBUG "%s: ignored spurious Michael MIC "
1491 "error for a frame with no PROTECTED flag (src "
1492 "%s)\n", dev->name, print_mac(mac, hdr->addr2));
1496 if (rx->sdata->vif.type == IEEE80211_IF_TYPE_AP && keyidx) {
1498 * APs with pairwise keys should never receive Michael MIC
1499 * errors for non-zero keyidx because these are reserved for
1500 * group keys and only the AP is sending real multicast
1501 * frames in the BSS.
1503 if (net_ratelimit())
1504 printk(KERN_DEBUG "%s: ignored Michael MIC error for "
1505 "a frame with non-zero keyidx (%d)"
1506 " (src %s)\n", dev->name, keyidx,
1507 print_mac(mac, hdr->addr2));
1511 if ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA &&
1512 ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_MGMT ||
1513 (rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_AUTH)) {
1514 if (net_ratelimit())
1515 printk(KERN_DEBUG "%s: ignored spurious Michael MIC "
1516 "error for a frame that cannot be encrypted "
1517 "(fc=0x%04x) (src %s)\n",
1518 dev->name, rx->fc, print_mac(mac, hdr->addr2));
1522 mac80211_ev_michael_mic_failure(rx->dev, keyidx, hdr);
1524 dev_kfree_skb(rx->skb);
1528 static void ieee80211_rx_cooked_monitor(struct ieee80211_txrx_data *rx)
1530 struct ieee80211_sub_if_data *sdata;
1531 struct ieee80211_local *local = rx->local;
1532 struct ieee80211_rtap_hdr {
1533 struct ieee80211_radiotap_header hdr;
1538 } __attribute__ ((packed)) *rthdr;
1539 struct sk_buff *skb = rx->skb, *skb2;
1540 struct net_device *prev_dev = NULL;
1541 struct ieee80211_rx_status *status = rx->u.rx.status;
1543 if (rx->flags & IEEE80211_TXRXD_RX_CMNTR_REPORTED)
1546 if (skb_headroom(skb) < sizeof(*rthdr) &&
1547 pskb_expand_head(skb, sizeof(*rthdr), 0, GFP_ATOMIC))
1550 rthdr = (void *)skb_push(skb, sizeof(*rthdr));
1551 memset(rthdr, 0, sizeof(*rthdr));
1552 rthdr->hdr.it_len = cpu_to_le16(sizeof(*rthdr));
1553 rthdr->hdr.it_present =
1554 cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) |
1555 (1 << IEEE80211_RADIOTAP_RATE) |
1556 (1 << IEEE80211_RADIOTAP_CHANNEL));
1558 rthdr->rate = rx->u.rx.rate->bitrate / 5;
1559 rthdr->chan_freq = cpu_to_le16(status->freq);
1561 if (status->band == IEEE80211_BAND_5GHZ)
1562 rthdr->chan_flags = cpu_to_le16(IEEE80211_CHAN_OFDM |
1563 IEEE80211_CHAN_5GHZ);
1565 rthdr->chan_flags = cpu_to_le16(IEEE80211_CHAN_DYN |
1566 IEEE80211_CHAN_2GHZ);
1568 skb_set_mac_header(skb, 0);
1569 skb->ip_summed = CHECKSUM_UNNECESSARY;
1570 skb->pkt_type = PACKET_OTHERHOST;
1571 skb->protocol = htons(ETH_P_802_2);
1573 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
1574 if (!netif_running(sdata->dev))
1577 if (sdata->vif.type != IEEE80211_IF_TYPE_MNTR ||
1578 !(sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES))
1582 skb2 = skb_clone(skb, GFP_ATOMIC);
1584 skb2->dev = prev_dev;
1589 prev_dev = sdata->dev;
1590 sdata->dev->stats.rx_packets++;
1591 sdata->dev->stats.rx_bytes += skb->len;
1595 skb->dev = prev_dev;
1601 rx->flags |= IEEE80211_TXRXD_RX_CMNTR_REPORTED;
1608 typedef ieee80211_rx_result (*ieee80211_rx_handler)(struct ieee80211_txrx_data *);
1609 static ieee80211_rx_handler ieee80211_rx_handlers[] =
1611 ieee80211_rx_h_if_stats,
1612 ieee80211_rx_h_passive_scan,
1613 ieee80211_rx_h_check,
1614 ieee80211_rx_h_decrypt,
1615 ieee80211_rx_h_sta_process,
1616 ieee80211_rx_h_defragment,
1617 ieee80211_rx_h_ps_poll,
1618 ieee80211_rx_h_michael_mic_verify,
1619 /* this must be after decryption - so header is counted in MPDU mic
1620 * must be before pae and data, so QOS_DATA format frames
1621 * are not passed to user space by these functions
1623 ieee80211_rx_h_remove_qos_control,
1624 ieee80211_rx_h_amsdu,
1625 ieee80211_rx_h_data,
1626 ieee80211_rx_h_ctrl,
1627 ieee80211_rx_h_mgmt,
1631 static void ieee80211_invoke_rx_handlers(struct ieee80211_sub_if_data *sdata,
1632 struct ieee80211_txrx_data *rx,
1633 struct sk_buff *skb)
1635 ieee80211_rx_handler *handler;
1636 ieee80211_rx_result res = RX_DROP_MONITOR;
1640 rx->dev = sdata->dev;
1642 for (handler = ieee80211_rx_handlers; *handler != NULL; handler++) {
1643 res = (*handler)(rx);
1648 case RX_DROP_UNUSABLE:
1649 case RX_DROP_MONITOR:
1650 I802_DEBUG_INC(sdata->local->rx_handlers_drop);
1652 rx->sta->rx_dropped++;
1655 I802_DEBUG_INC(sdata->local->rx_handlers_queued);
1663 case RX_DROP_MONITOR:
1664 ieee80211_rx_cooked_monitor(rx);
1666 case RX_DROP_UNUSABLE:
1667 dev_kfree_skb(rx->skb);
1672 /* main receive path */
1674 static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata,
1675 u8 *bssid, struct ieee80211_txrx_data *rx,
1676 struct ieee80211_hdr *hdr)
1678 int multicast = is_multicast_ether_addr(hdr->addr1);
1680 switch (sdata->vif.type) {
1681 case IEEE80211_IF_TYPE_STA:
1684 if (!ieee80211_bssid_match(bssid, sdata->u.sta.bssid)) {
1685 if (!(rx->flags & IEEE80211_TXRXD_RXIN_SCAN))
1687 rx->flags &= ~IEEE80211_TXRXD_RXRA_MATCH;
1688 } else if (!multicast &&
1689 compare_ether_addr(sdata->dev->dev_addr,
1691 if (!(sdata->dev->flags & IFF_PROMISC))
1693 rx->flags &= ~IEEE80211_TXRXD_RXRA_MATCH;
1696 case IEEE80211_IF_TYPE_IBSS:
1699 if ((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT &&
1700 (rx->fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_BEACON)
1702 else if (!ieee80211_bssid_match(bssid, sdata->u.sta.bssid)) {
1703 if (!(rx->flags & IEEE80211_TXRXD_RXIN_SCAN))
1705 rx->flags &= ~IEEE80211_TXRXD_RXRA_MATCH;
1706 } else if (!multicast &&
1707 compare_ether_addr(sdata->dev->dev_addr,
1709 if (!(sdata->dev->flags & IFF_PROMISC))
1711 rx->flags &= ~IEEE80211_TXRXD_RXRA_MATCH;
1712 } else if (!rx->sta)
1713 rx->sta = ieee80211_ibss_add_sta(sdata->dev, rx->skb,
1716 case IEEE80211_IF_TYPE_VLAN:
1717 case IEEE80211_IF_TYPE_AP:
1719 if (compare_ether_addr(sdata->dev->dev_addr,
1722 } else if (!ieee80211_bssid_match(bssid,
1723 sdata->dev->dev_addr)) {
1724 if (!(rx->flags & IEEE80211_TXRXD_RXIN_SCAN))
1726 rx->flags &= ~IEEE80211_TXRXD_RXRA_MATCH;
1728 if (sdata->dev == sdata->local->mdev &&
1729 !(rx->flags & IEEE80211_TXRXD_RXIN_SCAN))
1730 /* do not receive anything via
1731 * master device when not scanning */
1734 case IEEE80211_IF_TYPE_WDS:
1736 (rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)
1738 if (compare_ether_addr(sdata->u.wds.remote_addr, hdr->addr2))
1741 case IEEE80211_IF_TYPE_MNTR:
1742 /* take everything */
1744 case IEEE80211_IF_TYPE_INVALID:
1745 /* should never get here */
1754 * This is the actual Rx frames handler. as it blongs to Rx path it must
1755 * be called with rcu_read_lock protection.
1757 static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
1758 struct sk_buff *skb,
1759 struct ieee80211_rx_status *status,
1761 struct ieee80211_rate *rate)
1763 struct ieee80211_local *local = hw_to_local(hw);
1764 struct ieee80211_sub_if_data *sdata;
1765 struct ieee80211_hdr *hdr;
1766 struct ieee80211_txrx_data rx;
1769 struct ieee80211_sub_if_data *prev = NULL;
1770 struct sk_buff *skb_new;
1773 hdr = (struct ieee80211_hdr *) skb->data;
1774 memset(&rx, 0, sizeof(rx));
1778 rx.u.rx.status = status;
1779 rx.u.rx.load = load;
1780 rx.u.rx.rate = rate;
1781 rx.fc = le16_to_cpu(hdr->frame_control);
1782 type = rx.fc & IEEE80211_FCTL_FTYPE;
1784 if (type == IEEE80211_FTYPE_DATA || type == IEEE80211_FTYPE_MGMT)
1785 local->dot11ReceivedFragmentCount++;
1787 rx.sta = sta_info_get(local, hdr->addr2);
1789 rx.dev = rx.sta->dev;
1790 rx.sdata = IEEE80211_DEV_TO_SUB_IF(rx.dev);
1793 if ((status->flag & RX_FLAG_MMIC_ERROR)) {
1794 ieee80211_rx_michael_mic_report(local->mdev, hdr, &rx);
1798 if (unlikely(local->sta_sw_scanning || local->sta_hw_scanning))
1799 rx.flags |= IEEE80211_TXRXD_RXIN_SCAN;
1801 ieee80211_parse_qos(&rx);
1802 ieee80211_verify_ip_alignment(&rx);
1806 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
1807 if (!netif_running(sdata->dev))
1810 if (sdata->vif.type == IEEE80211_IF_TYPE_MNTR)
1813 bssid = ieee80211_get_bssid(hdr, skb->len, sdata->vif.type);
1814 rx.flags |= IEEE80211_TXRXD_RXRA_MATCH;
1815 prepares = prepare_for_handlers(sdata, bssid, &rx, hdr);
1821 * frame is destined for this interface, but if it's not
1822 * also for the previous one we handle that after the
1823 * loop to avoid copying the SKB once too much
1832 * frame was destined for the previous interface
1833 * so invoke RX handlers for it
1836 skb_new = skb_copy(skb, GFP_ATOMIC);
1838 if (net_ratelimit())
1839 printk(KERN_DEBUG "%s: failed to copy "
1840 "multicast frame for %s",
1841 wiphy_name(local->hw.wiphy),
1845 rx.fc = le16_to_cpu(hdr->frame_control);
1846 ieee80211_invoke_rx_handlers(prev, &rx, skb_new);
1850 rx.fc = le16_to_cpu(hdr->frame_control);
1851 ieee80211_invoke_rx_handlers(prev, &rx, skb);
1857 sta_info_put(rx.sta);
1860 #define SEQ_MODULO 0x1000
1861 #define SEQ_MASK 0xfff
1863 static inline int seq_less(u16 sq1, u16 sq2)
1865 return (((sq1 - sq2) & SEQ_MASK) > (SEQ_MODULO >> 1));
1868 static inline u16 seq_inc(u16 sq)
1870 return ((sq + 1) & SEQ_MASK);
1873 static inline u16 seq_sub(u16 sq1, u16 sq2)
1875 return ((sq1 - sq2) & SEQ_MASK);
1880 * As it function blongs to Rx path it must be called with
1881 * the proper rcu_read_lock protection for its flow.
1883 u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw,
1884 struct tid_ampdu_rx *tid_agg_rx,
1885 struct sk_buff *skb, u16 mpdu_seq_num,
1888 struct ieee80211_local *local = hw_to_local(hw);
1889 struct ieee80211_rx_status status;
1890 u16 head_seq_num, buf_size;
1893 struct ieee80211_supported_band *sband;
1894 struct ieee80211_rate *rate;
1896 buf_size = tid_agg_rx->buf_size;
1897 head_seq_num = tid_agg_rx->head_seq_num;
1899 /* frame with out of date sequence number */
1900 if (seq_less(mpdu_seq_num, head_seq_num)) {
1905 /* if frame sequence number exceeds our buffering window size or
1906 * block Ack Request arrived - release stored frames */
1907 if ((!seq_less(mpdu_seq_num, head_seq_num + buf_size)) || (bar_req)) {
1908 /* new head to the ordering buffer */
1910 head_seq_num = mpdu_seq_num;
1913 seq_inc(seq_sub(mpdu_seq_num, buf_size));
1914 /* release stored frames up to new head to stack */
1915 while (seq_less(tid_agg_rx->head_seq_num, head_seq_num)) {
1916 index = seq_sub(tid_agg_rx->head_seq_num,
1918 % tid_agg_rx->buf_size;
1920 if (tid_agg_rx->reorder_buf[index]) {
1921 /* release the reordered frames to stack */
1923 tid_agg_rx->reorder_buf[index]->cb,
1925 sband = local->hw.wiphy->bands[status.band];
1926 rate = &sband->bitrates[status.rate_idx];
1927 pkt_load = ieee80211_rx_load_stats(local,
1928 tid_agg_rx->reorder_buf[index],
1930 __ieee80211_rx_handle_packet(hw,
1931 tid_agg_rx->reorder_buf[index],
1932 &status, pkt_load, rate);
1933 tid_agg_rx->stored_mpdu_num--;
1934 tid_agg_rx->reorder_buf[index] = NULL;
1936 tid_agg_rx->head_seq_num =
1937 seq_inc(tid_agg_rx->head_seq_num);
1943 /* now the new frame is always in the range of the reordering */
1945 index = seq_sub(mpdu_seq_num, tid_agg_rx->ssn)
1946 % tid_agg_rx->buf_size;
1947 /* check if we already stored this frame */
1948 if (tid_agg_rx->reorder_buf[index]) {
1953 /* if arrived mpdu is in the right order and nothing else stored */
1954 /* release it immediately */
1955 if (mpdu_seq_num == tid_agg_rx->head_seq_num &&
1956 tid_agg_rx->stored_mpdu_num == 0) {
1957 tid_agg_rx->head_seq_num =
1958 seq_inc(tid_agg_rx->head_seq_num);
1962 /* put the frame in the reordering buffer */
1963 tid_agg_rx->reorder_buf[index] = skb;
1964 tid_agg_rx->stored_mpdu_num++;
1965 /* release the buffer until next missing frame */
1966 index = seq_sub(tid_agg_rx->head_seq_num, tid_agg_rx->ssn)
1967 % tid_agg_rx->buf_size;
1968 while (tid_agg_rx->reorder_buf[index]) {
1969 /* release the reordered frame back to stack */
1970 memcpy(&status, tid_agg_rx->reorder_buf[index]->cb,
1972 sband = local->hw.wiphy->bands[status.band];
1973 rate = &sband->bitrates[status.rate_idx];
1974 pkt_load = ieee80211_rx_load_stats(local,
1975 tid_agg_rx->reorder_buf[index],
1977 __ieee80211_rx_handle_packet(hw, tid_agg_rx->reorder_buf[index],
1978 &status, pkt_load, rate);
1979 tid_agg_rx->stored_mpdu_num--;
1980 tid_agg_rx->reorder_buf[index] = NULL;
1981 tid_agg_rx->head_seq_num = seq_inc(tid_agg_rx->head_seq_num);
1982 index = seq_sub(tid_agg_rx->head_seq_num,
1983 tid_agg_rx->ssn) % tid_agg_rx->buf_size;
1988 static u8 ieee80211_rx_reorder_ampdu(struct ieee80211_local *local,
1989 struct sk_buff *skb)
1991 struct ieee80211_hw *hw = &local->hw;
1992 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
1993 struct sta_info *sta;
1994 struct tid_ampdu_rx *tid_agg_rx;
2000 sta = sta_info_get(local, hdr->addr2);
2004 fc = le16_to_cpu(hdr->frame_control);
2006 /* filter the QoS data rx stream according to
2007 * STA/TID and check if this STA/TID is on aggregation */
2008 if (!WLAN_FC_IS_QOS_DATA(fc))
2011 qc = skb->data + ieee80211_get_hdrlen(fc) - QOS_CONTROL_LEN;
2012 tid = qc[0] & QOS_CONTROL_TID_MASK;
2013 tid_agg_rx = &(sta->ampdu_mlme.tid_rx[tid]);
2015 if (tid_agg_rx->state != HT_AGG_STATE_OPERATIONAL)
2018 /* null data frames are excluded */
2019 if (unlikely(fc & IEEE80211_STYPE_NULLFUNC))
2022 /* new un-ordered ampdu frame - process it */
2024 /* reset session timer */
2025 if (tid_agg_rx->timeout) {
2026 unsigned long expires =
2027 jiffies + (tid_agg_rx->timeout / 1000) * HZ;
2028 mod_timer(&tid_agg_rx->session_timer, expires);
2031 /* if this mpdu is fragmented - terminate rx aggregation session */
2032 sc = le16_to_cpu(hdr->seq_ctrl);
2033 if (sc & IEEE80211_SCTL_FRAG) {
2034 ieee80211_sta_stop_rx_ba_session(sta->dev, sta->addr,
2035 tid, 0, WLAN_REASON_QSTA_REQUIRE_SETUP);
2040 /* according to mpdu sequence number deal with reordering buffer */
2041 mpdu_seq_num = (sc & IEEE80211_SCTL_SEQ) >> 4;
2042 ret = ieee80211_sta_manage_reorder_buf(hw, tid_agg_rx, skb,
2051 * This is the receive path handler. It is called by a low level driver when an
2052 * 802.11 MPDU is received from the hardware.
2054 void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
2055 struct ieee80211_rx_status *status)
2057 struct ieee80211_local *local = hw_to_local(hw);
2059 struct ieee80211_rate *rate = NULL;
2060 struct ieee80211_supported_band *sband;
2062 if (status->band < 0 ||
2063 status->band > IEEE80211_NUM_BANDS) {
2068 sband = local->hw.wiphy->bands[status->band];
2071 status->rate_idx < 0 ||
2072 status->rate_idx >= sband->n_bitrates) {
2077 rate = &sband->bitrates[status->rate_idx];
2080 * key references and virtual interfaces are protected using RCU
2081 * and this requires that we are in a read-side RCU section during
2082 * receive processing
2087 * Frames with failed FCS/PLCP checksum are not returned,
2088 * all other frames are returned without radiotap header
2089 * if it was previously present.
2090 * Also, frames with less than 16 bytes are dropped.
2092 skb = ieee80211_rx_monitor(local, skb, status, rate);
2098 pkt_load = ieee80211_rx_load_stats(local, skb, status, rate);
2099 local->channel_use_raw += pkt_load;
2101 if (!ieee80211_rx_reorder_ampdu(local, skb))
2102 __ieee80211_rx_handle_packet(hw, skb, status, pkt_load, rate);
2106 EXPORT_SYMBOL(__ieee80211_rx);
2108 /* This is a version of the rx handler that can be called from hard irq
2109 * context. Post the skb on the queue and schedule the tasklet */
2110 void ieee80211_rx_irqsafe(struct ieee80211_hw *hw, struct sk_buff *skb,
2111 struct ieee80211_rx_status *status)
2113 struct ieee80211_local *local = hw_to_local(hw);
2115 BUILD_BUG_ON(sizeof(struct ieee80211_rx_status) > sizeof(skb->cb));
2117 skb->dev = local->mdev;
2118 /* copy status into skb->cb for use by tasklet */
2119 memcpy(skb->cb, status, sizeof(*status));
2120 skb->pkt_type = IEEE80211_RX_MSG;
2121 skb_queue_tail(&local->skb_queue, skb);
2122 tasklet_schedule(&local->tasklet);
2124 EXPORT_SYMBOL(ieee80211_rx_irqsafe);