PCI: fix pbus_size_mem() resource alignment for CardBus controllers
[safe/jmp/linux-2.6] / net / mac80211 / rx.c
index 1159a43..6db8545 100644 (file)
@@ -61,18 +61,15 @@ static inline int should_drop_frame(struct ieee80211_rx_status *status,
                                    int present_fcs_len,
                                    int radiotap_len)
 {
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
 
        if (status->flag & (RX_FLAG_FAILED_FCS_CRC | RX_FLAG_FAILED_PLCP_CRC))
                return 1;
        if (unlikely(skb->len < 16 + present_fcs_len + radiotap_len))
                return 1;
-       if (((hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
-                       cpu_to_le16(IEEE80211_FTYPE_CTL)) &&
-           ((hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE)) !=
-                       cpu_to_le16(IEEE80211_STYPE_PSPOLL)) &&
-           ((hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE)) !=
-                       cpu_to_le16(IEEE80211_STYPE_BACK_REQ)))
+       if (ieee80211_is_ctl(hdr->frame_control) &&
+           !ieee80211_is_pspoll(hdr->frame_control) &&
+           !ieee80211_is_back_req(hdr->frame_control))
                return 1;
        return 0;
 }
@@ -324,26 +321,31 @@ ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb,
 
 static void ieee80211_parse_qos(struct ieee80211_rx_data *rx)
 {
-       u8 *data = rx->skb->data;
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
        int tid;
 
        /* does the frame have a qos control field? */
-       if (WLAN_FC_IS_QOS_DATA(rx->fc)) {
-               u8 *qc = data + ieee80211_get_hdrlen(rx->fc) - QOS_CONTROL_LEN;
+       if (ieee80211_is_data_qos(hdr->frame_control)) {
+               u8 *qc = ieee80211_get_qos_ctl(hdr);
                /* frame has qos control */
-               tid = qc[0] & QOS_CONTROL_TID_MASK;
-               if (qc[0] & IEEE80211_QOS_CONTROL_A_MSDU_PRESENT)
+               tid = *qc & IEEE80211_QOS_CTL_TID_MASK;
+               if (*qc & IEEE80211_QOS_CONTROL_A_MSDU_PRESENT)
                        rx->flags |= IEEE80211_RX_AMSDU;
                else
                        rx->flags &= ~IEEE80211_RX_AMSDU;
        } else {
-               if (unlikely((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT)) {
-                       /* Separate TID for management frames */
-                       tid = NUM_RX_DATA_QUEUES - 1;
-               } else {
-                       /* no qos control present */
-                       tid = 0; /* 802.1d - Best Effort */
-               }
+               /*
+                * IEEE 802.11-2007, 7.1.3.4.1 ("Sequence Number field"):
+                *
+                *      Sequence numbers for management frames, QoS data
+                *      frames with a broadcast/multicast address in the
+                *      Address 1 field, and all non-QoS data frames sent
+                *      by QoS STAs are assigned using an additional single
+                *      modulo-4096 counter, [...]
+                *
+                * We also use that counter for non-QoS STAs.
+                */
+               tid = NUM_RX_DATA_QUEUES - 1;
        }
 
        rx->queue = tid;
@@ -355,9 +357,10 @@ static void ieee80211_parse_qos(struct ieee80211_rx_data *rx)
 static void ieee80211_verify_ip_alignment(struct ieee80211_rx_data *rx)
 {
 #ifdef CONFIG_MAC80211_DEBUG_PACKET_ALIGNMENT
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
        int hdrlen;
 
-       if (!WLAN_FC_DATA_PRESENT(rx->fc))
+       if (!ieee80211_is_data_present(hdr->frame_control))
                return;
 
        /*
@@ -379,7 +382,7 @@ static void ieee80211_verify_ip_alignment(struct ieee80211_rx_data *rx)
         * header and the payload is not supported, the driver is required
         * to move the 802.11 header further back in that case.
         */
-       hdrlen = ieee80211_get_hdrlen(rx->fc);
+       hdrlen = ieee80211_hdrlen(hdr->frame_control);
        if (rx->flags & IEEE80211_RX_AMSDU)
                hdrlen += ETH_HLEN;
        WARN_ON_ONCE(((unsigned long)(rx->skb->data + hdrlen)) & 3);
@@ -387,51 +390,9 @@ static void ieee80211_verify_ip_alignment(struct ieee80211_rx_data *rx)
 }
 
 
-static u32 ieee80211_rx_load_stats(struct ieee80211_local *local,
-                                  struct sk_buff *skb,
-                                  struct ieee80211_rx_status *status,
-                                  struct ieee80211_rate *rate)
-{
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
-       u32 load = 0, hdrtime;
-
-       /* Estimate total channel use caused by this frame */
-
-       /* 1 bit at 1 Mbit/s takes 1 usec; in channel_use values,
-        * 1 usec = 1/8 * (1080 / 10) = 13.5 */
-
-       if (status->band == IEEE80211_BAND_5GHZ ||
-           (status->band == IEEE80211_BAND_5GHZ &&
-            rate->flags & IEEE80211_RATE_ERP_G))
-               hdrtime = CHAN_UTIL_HDR_SHORT;
-       else
-               hdrtime = CHAN_UTIL_HDR_LONG;
-
-       load = hdrtime;
-       if (!is_multicast_ether_addr(hdr->addr1))
-               load += hdrtime;
-
-       /* TODO: optimise again */
-       load += skb->len * CHAN_UTIL_RATE_LCM / rate->bitrate;
-
-       /* Divide channel_use by 8 to avoid wrapping around the counter */
-       load >>= CHAN_UTIL_SHIFT;
-
-       return load;
-}
-
 /* rx handlers */
 
-static ieee80211_rx_result
-ieee80211_rx_h_if_stats(struct ieee80211_rx_data *rx)
-{
-       if (rx->sta)
-               rx->sta->channel_use_raw += rx->load;
-       rx->sdata->channel_use_raw += rx->load;
-       return RX_CONTINUE;
-}
-
-static ieee80211_rx_result
+static ieee80211_rx_result debug_noinline
 ieee80211_rx_h_passive_scan(struct ieee80211_rx_data *rx)
 {
        struct ieee80211_local *local = rx->local;
@@ -460,14 +421,11 @@ ieee80211_rx_h_passive_scan(struct ieee80211_rx_data *rx)
 static ieee80211_rx_result
 ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx)
 {
-       int hdrlen = ieee80211_get_hdrlen(rx->fc);
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data;
-
-#define msh_h_get(h, l) ((struct ieee80211s_hdr *) ((u8 *)h + l))
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
+       unsigned int hdrlen = ieee80211_hdrlen(hdr->frame_control);
 
-       if ((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) {
-               if (!((rx->fc & IEEE80211_FCTL_FROMDS) &&
-                     (rx->fc & IEEE80211_FCTL_TODS)))
+       if (ieee80211_is_data(hdr->frame_control)) {
+               if (!ieee80211_has_a4(hdr->frame_control))
                        return RX_DROP_MONITOR;
                if (memcmp(hdr->addr4, rx->dev->dev_addr, ETH_ALEN) == 0)
                        return RX_DROP_MONITOR;
@@ -480,27 +438,30 @@ ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx)
        if (!rx->sta || sta_plink_state(rx->sta) != PLINK_ESTAB) {
                struct ieee80211_mgmt *mgmt;
 
-               if ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_MGMT)
+               if (!ieee80211_is_mgmt(hdr->frame_control))
                        return RX_DROP_MONITOR;
 
-               switch (rx->fc & IEEE80211_FCTL_STYPE) {
-               case IEEE80211_STYPE_ACTION:
+               if (ieee80211_is_action(hdr->frame_control)) {
                        mgmt = (struct ieee80211_mgmt *)hdr;
                        if (mgmt->u.action.category != PLINK_CATEGORY)
                                return RX_DROP_MONITOR;
-                       /* fall through on else */
-               case IEEE80211_STYPE_PROBE_REQ:
-               case IEEE80211_STYPE_PROBE_RESP:
-               case IEEE80211_STYPE_BEACON:
                        return RX_CONTINUE;
-                       break;
-               default:
-                       return RX_DROP_MONITOR;
                }
 
-        } else if ((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA &&
-                   is_multicast_ether_addr(hdr->addr1) &&
-                   mesh_rmc_check(hdr->addr4, msh_h_get(hdr, hdrlen), rx->dev))
+               if (ieee80211_is_probe_req(hdr->frame_control) ||
+                   ieee80211_is_probe_resp(hdr->frame_control) ||
+                   ieee80211_is_beacon(hdr->frame_control))
+                       return RX_CONTINUE;
+
+               return RX_DROP_MONITOR;
+
+       }
+
+#define msh_h_get(h, l) ((struct ieee80211s_hdr *) ((u8 *)h + l))
+
+       if (ieee80211_is_data(hdr->frame_control) &&
+           is_multicast_ether_addr(hdr->addr1) &&
+           mesh_rmc_check(hdr->addr4, msh_h_get(hdr, hdrlen), rx->dev))
                return RX_DROP_MONITOR;
 #undef msh_h_get
 
@@ -508,16 +469,14 @@ ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx)
 }
 
 
-static ieee80211_rx_result
+static ieee80211_rx_result debug_noinline
 ieee80211_rx_h_check(struct ieee80211_rx_data *rx)
 {
-       struct ieee80211_hdr *hdr;
-
-       hdr = (struct ieee80211_hdr *) rx->skb->data;
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
 
        /* Drop duplicate 802.11 retransmissions (IEEE 802.11 Chap. 9.2.9) */
        if (rx->sta && !is_multicast_ether_addr(hdr->addr1)) {
-               if (unlikely(rx->fc & IEEE80211_FCTL_RETRY &&
+               if (unlikely(ieee80211_has_retry(hdr->frame_control) &&
                             rx->sta->last_seq_ctrl[rx->queue] ==
                             hdr->seq_ctrl)) {
                        if (rx->flags & IEEE80211_RX_RA_MATCH) {
@@ -546,15 +505,14 @@ ieee80211_rx_h_check(struct ieee80211_rx_data *rx)
        if (ieee80211_vif_is_mesh(&rx->sdata->vif))
                return ieee80211_rx_mesh_check(rx);
 
-       if (unlikely(((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA ||
-                     ((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL &&
-                      (rx->fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PSPOLL)) &&
+       if (unlikely((ieee80211_is_data(hdr->frame_control) ||
+                     ieee80211_is_pspoll(hdr->frame_control)) &&
                     rx->sdata->vif.type != IEEE80211_IF_TYPE_IBSS &&
                     (!rx->sta || !test_sta_flags(rx->sta, WLAN_STA_ASSOC)))) {
-               if ((!(rx->fc & IEEE80211_FCTL_FROMDS) &&
-                    !(rx->fc & IEEE80211_FCTL_TODS) &&
-                    (rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA)
-                   || !(rx->flags & IEEE80211_RX_RA_MATCH)) {
+               if ((!ieee80211_has_fromds(hdr->frame_control) &&
+                    !ieee80211_has_tods(hdr->frame_control) &&
+                    ieee80211_is_data(hdr->frame_control)) ||
+                   !(rx->flags & IEEE80211_RX_RA_MATCH)) {
                        /* Drop IBSS frames and frames for other hosts
                         * silently. */
                        return RX_DROP_MONITOR;
@@ -567,10 +525,10 @@ ieee80211_rx_h_check(struct ieee80211_rx_data *rx)
 }
 
 
-static ieee80211_rx_result
+static ieee80211_rx_result debug_noinline
 ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx)
 {
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data;
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
        int keyidx;
        int hdrlen;
        ieee80211_rx_result result = RX_DROP_UNUSABLE;
@@ -602,7 +560,7 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx)
         * possible.
         */
 
-       if (!(rx->fc & IEEE80211_FCTL_PROTECTED))
+       if (!ieee80211_has_protected(hdr->frame_control))
                return RX_CONTINUE;
 
        /*
@@ -631,7 +589,7 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx)
                    (rx->status->flag & RX_FLAG_IV_STRIPPED))
                        return RX_CONTINUE;
 
-               hdrlen = ieee80211_get_hdrlen(rx->fc);
+               hdrlen = ieee80211_hdrlen(hdr->frame_control);
 
                if (rx->skb->len < 8 + hdrlen)
                        return RX_DROP_UNUSABLE; /* TODO: count this? */
@@ -658,17 +616,12 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx)
                rx->key->tx_rx_count++;
                /* TODO: add threshold stuff again */
        } else {
-#ifdef CONFIG_MAC80211_DEBUG
-               if (net_ratelimit())
-                       printk(KERN_DEBUG "%s: RX protected frame,"
-                              " but have no key\n", rx->dev->name);
-#endif /* CONFIG_MAC80211_DEBUG */
                return RX_DROP_MONITOR;
        }
 
        /* Check for weak IVs if possible */
        if (rx->sta && rx->key->conf.alg == ALG_WEP &&
-           ((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) &&
+           ieee80211_is_data(hdr->frame_control) &&
            (!(rx->status->flag & RX_FLAG_IV_STRIPPED) ||
             !(rx->status->flag & RX_FLAG_DECRYPTED)) &&
            ieee80211_wep_is_weak_iv(rx->skb, rx->key))
@@ -699,8 +652,7 @@ static void ap_sta_ps_start(struct net_device *dev, struct sta_info *sta)
 
        sdata = sta->sdata;
 
-       if (sdata->bss)
-               atomic_inc(&sdata->bss->num_sta_ps);
+       atomic_inc(&sdata->bss->num_sta_ps);
        set_and_clear_sta_flags(sta, WLAN_STA_PS, WLAN_STA_PSPOLL);
 #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
        printk(KERN_DEBUG "%s: STA %s aid %d enters power save mode\n",
@@ -714,13 +666,12 @@ static int ap_sta_ps_end(struct net_device *dev, struct sta_info *sta)
        struct sk_buff *skb;
        int sent = 0;
        struct ieee80211_sub_if_data *sdata;
-       struct ieee80211_tx_packet_data *pkt_data;
+       struct ieee80211_tx_info *info;
        DECLARE_MAC_BUF(mac);
 
        sdata = sta->sdata;
 
-       if (sdata->bss)
-               atomic_dec(&sdata->bss->num_sta_ps);
+       atomic_dec(&sdata->bss->num_sta_ps);
 
        clear_sta_flags(sta, WLAN_STA_PS | WLAN_STA_PSPOLL);
 
@@ -734,13 +685,13 @@ static int ap_sta_ps_end(struct net_device *dev, struct sta_info *sta)
 
        /* Send all buffered frames to the station */
        while ((skb = skb_dequeue(&sta->tx_filtered)) != NULL) {
-               pkt_data = (struct ieee80211_tx_packet_data *) skb->cb;
+               info = IEEE80211_SKB_CB(skb);
                sent++;
-               pkt_data->flags |= IEEE80211_TXPD_REQUEUE;
+               info->flags |= IEEE80211_TX_CTL_REQUEUE;
                dev_queue_xmit(skb);
        }
        while ((skb = skb_dequeue(&sta->ps_tx_buf)) != NULL) {
-               pkt_data = (struct ieee80211_tx_packet_data *) skb->cb;
+               info = IEEE80211_SKB_CB(skb);
                local->total_ps_buffered--;
                sent++;
 #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
@@ -748,19 +699,19 @@ static int ap_sta_ps_end(struct net_device *dev, struct sta_info *sta)
                       "since STA not sleeping anymore\n", dev->name,
                       print_mac(mac, sta->addr), sta->aid);
 #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
-               pkt_data->flags |= IEEE80211_TXPD_REQUEUE;
+               info->flags |= IEEE80211_TX_CTL_REQUEUE;
                dev_queue_xmit(skb);
        }
 
        return sent;
 }
 
-static ieee80211_rx_result
+static ieee80211_rx_result debug_noinline
 ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
 {
        struct sta_info *sta = rx->sta;
        struct net_device *dev = rx->dev;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data;
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
 
        if (!sta)
                return RX_CONTINUE;
@@ -794,21 +745,22 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
        sta->last_qual = rx->status->qual;
        sta->last_noise = rx->status->noise;
 
-       if (!(rx->fc & IEEE80211_FCTL_MOREFRAGS)) {
+       if (!ieee80211_has_morefrags(hdr->frame_control) &&
+           (rx->sdata->vif.type == IEEE80211_IF_TYPE_AP ||
+            rx->sdata->vif.type == IEEE80211_IF_TYPE_VLAN)) {
                /* Change STA power saving mode only in the end of a frame
                 * exchange sequence */
                if (test_sta_flags(sta, WLAN_STA_PS) &&
-                   !(rx->fc & IEEE80211_FCTL_PM))
+                   !ieee80211_has_pm(hdr->frame_control))
                        rx->sent_ps_buffered += ap_sta_ps_end(dev, sta);
                else if (!test_sta_flags(sta, WLAN_STA_PS) &&
-                        (rx->fc & IEEE80211_FCTL_PM))
+                        ieee80211_has_pm(hdr->frame_control))
                        ap_sta_ps_start(dev, sta);
        }
 
        /* Drop data::nullfunc frames silently, since they are used only to
         * control station power saving mode. */
-       if ((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA &&
-           (rx->fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_NULLFUNC) {
+       if (ieee80211_is_nullfunc(hdr->frame_control)) {
                I802_DEBUG_INC(rx->local->rx_handlers_drop_nullfunc);
                /* Update counter and free packet here to avoid counting this
                 * as a dropped packed. */
@@ -834,7 +786,7 @@ ieee80211_reassemble_add(struct ieee80211_sub_if_data *sdata,
                sdata->fragment_next = 0;
 
        if (!skb_queue_empty(&entry->skb_list)) {
-#ifdef CONFIG_MAC80211_DEBUG
+#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
                struct ieee80211_hdr *hdr =
                        (struct ieee80211_hdr *) entry->skb_list.next->data;
                DECLARE_MAC_BUF(mac);
@@ -846,7 +798,7 @@ ieee80211_reassemble_add(struct ieee80211_sub_if_data *sdata,
                       jiffies - entry->first_frag_time, entry->seq,
                       entry->last_frag, print_mac(mac, hdr->addr1),
                       print_mac(mac2, hdr->addr2));
-#endif /* CONFIG_MAC80211_DEBUG */
+#endif
                __skb_queue_purge(&entry->skb_list);
        }
 
@@ -903,7 +855,7 @@ ieee80211_reassemble_find(struct ieee80211_sub_if_data *sdata,
        return NULL;
 }
 
-static ieee80211_rx_result
+static ieee80211_rx_result debug_noinline
 ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
 {
        struct ieee80211_hdr *hdr;
@@ -967,18 +919,8 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
                                break;
                }
                rpn = rx->key->u.ccmp.rx_pn[rx->queue];
-               if (memcmp(pn, rpn, CCMP_PN_LEN) != 0) {
-                       if (net_ratelimit())
-                               printk(KERN_DEBUG "%s: defrag: CCMP PN not "
-                                      "sequential A2=%s"
-                                      " PN=%02x%02x%02x%02x%02x%02x "
-                                      "(expected %02x%02x%02x%02x%02x%02x)\n",
-                                      rx->dev->name, print_mac(mac, hdr->addr2),
-                                      rpn[0], rpn[1], rpn[2], rpn[3], rpn[4],
-                                      rpn[5], pn[0], pn[1], pn[2], pn[3],
-                                      pn[4], pn[5]);
+               if (memcmp(pn, rpn, CCMP_PN_LEN))
                        return RX_DROP_UNUSABLE;
-               }
                memcpy(entry->last_pn, pn, CCMP_PN_LEN);
        }
 
@@ -1019,7 +961,7 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
        return RX_CONTINUE;
 }
 
-static ieee80211_rx_result
+static ieee80211_rx_result debug_noinline
 ieee80211_rx_h_ps_poll(struct ieee80211_rx_data *rx)
 {
        struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev);
@@ -1082,7 +1024,7 @@ ieee80211_rx_h_ps_poll(struct ieee80211_rx_data *rx)
                 *        have nothing buffered for it?
                 */
                printk(KERN_DEBUG "%s: STA %s sent PS Poll even "
-                      "though there is no buffered frames for it\n",
+                      "though there are no buffered frames for it\n",
                       rx->dev->name, print_mac(mac, rx->sta->addr));
 #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
        }
@@ -1094,22 +1036,22 @@ ieee80211_rx_h_ps_poll(struct ieee80211_rx_data *rx)
        return RX_QUEUED;
 }
 
-static ieee80211_rx_result
+static ieee80211_rx_result debug_noinline
 ieee80211_rx_h_remove_qos_control(struct ieee80211_rx_data *rx)
 {
-       u16 fc = rx->fc;
        u8 *data = rx->skb->data;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) data;
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)data;
 
-       if (!WLAN_FC_IS_QOS_DATA(fc))
+       if (!ieee80211_is_data_qos(hdr->frame_control))
                return RX_CONTINUE;
 
        /* remove the qos control field, update frame type and meta-data */
-       memmove(data + 2, data, ieee80211_get_hdrlen(fc) - 2);
-       hdr = (struct ieee80211_hdr *) skb_pull(rx->skb, 2);
+       memmove(data + IEEE80211_QOS_CTL_LEN, data,
+               ieee80211_hdrlen(hdr->frame_control) - IEEE80211_QOS_CTL_LEN);
+       hdr = (struct ieee80211_hdr *)skb_pull(rx->skb, IEEE80211_QOS_CTL_LEN);
        /* change frame type to non QOS */
-       rx->fc = fc &= ~IEEE80211_STYPE_QOS_DATA;
-       hdr->frame_control = cpu_to_le16(fc);
+       rx->fc &= ~IEEE80211_STYPE_QOS_DATA;
+       hdr->frame_control &= ~cpu_to_le16(IEEE80211_STYPE_QOS_DATA);
 
        return RX_CONTINUE;
 }
@@ -1118,14 +1060,8 @@ static int
 ieee80211_802_1x_port_control(struct ieee80211_rx_data *rx)
 {
        if (unlikely(!rx->sta ||
-           !test_sta_flags(rx->sta, WLAN_STA_AUTHORIZED))) {
-#ifdef CONFIG_MAC80211_DEBUG
-               if (net_ratelimit())
-                       printk(KERN_DEBUG "%s: dropped frame "
-                              "(unauthorized port)\n", rx->dev->name);
-#endif /* CONFIG_MAC80211_DEBUG */
+           !test_sta_flags(rx->sta, WLAN_STA_AUTHORIZED)))
                return -EACCES;
-       }
 
        return 0;
 }
@@ -1158,7 +1094,7 @@ ieee80211_data_to_8023(struct ieee80211_rx_data *rx)
        u16 fc, hdrlen, ethertype;
        u8 *payload;
        u8 dst[ETH_ALEN];
-       u8 src[ETH_ALEN];
+       u8 src[ETH_ALEN] __aligned(2);
        struct sk_buff *skb = rx->skb;
        struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
        DECLARE_MAC_BUF(mac);
@@ -1173,20 +1109,9 @@ ieee80211_data_to_8023(struct ieee80211_rx_data *rx)
 
        hdrlen = ieee80211_get_hdrlen(fc);
 
-       if (ieee80211_vif_is_mesh(&sdata->vif)) {
-               int meshhdrlen = ieee80211_get_mesh_hdrlen(
+       if (ieee80211_vif_is_mesh(&sdata->vif))
+               hdrlen += ieee80211_get_mesh_hdrlen(
                                (struct ieee80211s_hdr *) (skb->data + hdrlen));
-               /* Copy on cb:
-                *  - mesh header: to be used for mesh forwarding
-                * decision. It will also be used as mesh header template at
-                * tx.c:ieee80211_subif_start_xmit() if interface
-                * type is mesh and skb->pkt_type == PACKET_OTHERHOST
-                *  - ta: to be used if a RERR needs to be sent.
-                */
-               memcpy(skb->cb, skb->data + hdrlen, meshhdrlen);
-               memcpy(MESH_PREQ(skb), hdr->addr2, ETH_ALEN);
-               hdrlen += meshhdrlen;
-       }
 
        /* convert IEEE 802.11 header + possible LLC headers into Ethernet
         * header
@@ -1205,16 +1130,8 @@ ieee80211_data_to_8023(struct ieee80211_rx_data *rx)
                memcpy(src, hdr->addr2, ETH_ALEN);
 
                if (unlikely(sdata->vif.type != IEEE80211_IF_TYPE_AP &&
-                            sdata->vif.type != IEEE80211_IF_TYPE_VLAN)) {
-                       if (net_ratelimit())
-                               printk(KERN_DEBUG "%s: dropped ToDS frame "
-                                      "(BSSID=%s SA=%s DA=%s)\n",
-                                      dev->name,
-                                      print_mac(mac, hdr->addr1),
-                                      print_mac(mac2, hdr->addr2),
-                                      print_mac(mac3, hdr->addr3));
+                            sdata->vif.type != IEEE80211_IF_TYPE_VLAN))
                        return -1;
-               }
                break;
        case (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS):
                /* RA TA DA SA */
@@ -1222,17 +1139,8 @@ ieee80211_data_to_8023(struct ieee80211_rx_data *rx)
                memcpy(src, hdr->addr4, ETH_ALEN);
 
                 if (unlikely(sdata->vif.type != IEEE80211_IF_TYPE_WDS &&
-                            sdata->vif.type != IEEE80211_IF_TYPE_MESH_POINT)) {
-                        if (net_ratelimit())
-                                printk(KERN_DEBUG "%s: dropped FromDS&ToDS "
-                                      "frame (RA=%s TA=%s DA=%s SA=%s)\n",
-                                      rx->dev->name,
-                                      print_mac(mac, hdr->addr1),
-                                      print_mac(mac2, hdr->addr2),
-                                      print_mac(mac3, hdr->addr3),
-                                      print_mac(mac4, hdr->addr4));
+                            sdata->vif.type != IEEE80211_IF_TYPE_MESH_POINT))
                        return -1;
-               }
                break;
        case IEEE80211_FCTL_FROMDS:
                /* DA BSSID SA */
@@ -1249,27 +1157,13 @@ ieee80211_data_to_8023(struct ieee80211_rx_data *rx)
                memcpy(dst, hdr->addr1, ETH_ALEN);
                memcpy(src, hdr->addr2, ETH_ALEN);
 
-               if (sdata->vif.type != IEEE80211_IF_TYPE_IBSS) {
-                       if (net_ratelimit()) {
-                               printk(KERN_DEBUG "%s: dropped IBSS frame "
-                                      "(DA=%s SA=%s BSSID=%s)\n",
-                                      dev->name,
-                                      print_mac(mac, hdr->addr1),
-                                      print_mac(mac2, hdr->addr2),
-                                      print_mac(mac3, hdr->addr3));
-                       }
+               if (sdata->vif.type != IEEE80211_IF_TYPE_IBSS)
                        return -1;
-               }
                break;
        }
 
-       if (unlikely(skb->len - hdrlen < 8)) {
-               if (net_ratelimit()) {
-                       printk(KERN_DEBUG "%s: RX too short data frame "
-                              "payload\n", dev->name);
-               }
+       if (unlikely(skb->len - hdrlen < 8))
                return -1;
-       }
 
        payload = skb->data + hdrlen;
        ethertype = (payload[6] << 8) | payload[7];
@@ -1301,7 +1195,7 @@ ieee80211_data_to_8023(struct ieee80211_rx_data *rx)
  */
 static bool ieee80211_frame_allowed(struct ieee80211_rx_data *rx)
 {
-       static const u8 pae_group_addr[ETH_ALEN]
+       static const u8 pae_group_addr[ETH_ALEN] __aligned(2)
                = { 0x01, 0x80, 0xC2, 0x00, 0x00, 0x03 };
        struct ethhdr *ehdr = (struct ethhdr *) rx->skb->data;
 
@@ -1364,38 +1258,6 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx)
                }
        }
 
-       /* Mesh forwarding */
-       if (ieee80211_vif_is_mesh(&sdata->vif)) {
-               u8 *mesh_ttl = &((struct ieee80211s_hdr *)skb->cb)->ttl;
-               (*mesh_ttl)--;
-
-               if (is_multicast_ether_addr(skb->data)) {
-                       if (*mesh_ttl > 0) {
-                               xmit_skb = skb_copy(skb, GFP_ATOMIC);
-                               if (!xmit_skb && net_ratelimit())
-                                       printk(KERN_DEBUG "%s: failed to clone "
-                                              "multicast frame\n", dev->name);
-                               else
-                                       xmit_skb->pkt_type = PACKET_OTHERHOST;
-                       } else
-                               IEEE80211_IFSTA_MESH_CTR_INC(&sdata->u.sta,
-                                                            dropped_frames_ttl);
-               } else if (skb->pkt_type != PACKET_OTHERHOST &&
-                       compare_ether_addr(dev->dev_addr, skb->data) != 0) {
-                       if (*mesh_ttl == 0) {
-                               IEEE80211_IFSTA_MESH_CTR_INC(&sdata->u.sta,
-                                                            dropped_frames_ttl);
-                               dev_kfree_skb(skb);
-                               skb = NULL;
-                       } else {
-                               xmit_skb = skb;
-                               xmit_skb->pkt_type = PACKET_OTHERHOST;
-                               if (!(dev->flags & IFF_PROMISC))
-                                       skb  = NULL;
-                       }
-               }
-       }
-
        if (skb) {
                /* deliver to local stack */
                skb->protocol = eth_type_trans(skb, dev);
@@ -1412,7 +1274,7 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx)
        }
 }
 
-static ieee80211_rx_result
+static ieee80211_rx_result debug_noinline
 ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx)
 {
        struct net_device *dev = rx->dev;
@@ -1461,10 +1323,8 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx)
 
                padding = ((4 - subframe_len) & 0x3);
                /* the last MSDU has no padding */
-               if (subframe_len > remaining) {
-                       printk(KERN_DEBUG "%s: wrong buffer size", dev->name);
+               if (subframe_len > remaining)
                        return RX_DROP_UNUSABLE;
-               }
 
                skb_pull(skb, sizeof(struct ethhdr));
                /* if last subframe reuse skb */
@@ -1485,8 +1345,6 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx)
                        eth = (struct ethhdr *) skb_pull(skb, ntohs(len) +
                                                        padding);
                        if (!eth) {
-                               printk(KERN_DEBUG "%s: wrong buffer size ",
-                                      dev->name);
                                dev_kfree_skb(frame);
                                return RX_DROP_UNUSABLE;
                        }
@@ -1529,7 +1387,64 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx)
        return RX_QUEUED;
 }
 
-static ieee80211_rx_result
+static ieee80211_rx_result debug_noinline
+ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
+{
+       struct ieee80211_hdr *hdr;
+       struct ieee80211s_hdr *mesh_hdr;
+       unsigned int hdrlen;
+       struct sk_buff *skb = rx->skb, *fwd_skb;
+
+       hdr = (struct ieee80211_hdr *) skb->data;
+       hdrlen = ieee80211_hdrlen(hdr->frame_control);
+       mesh_hdr = (struct ieee80211s_hdr *) (skb->data + hdrlen);
+
+       if (!ieee80211_is_data(hdr->frame_control))
+               return RX_CONTINUE;
+
+       if (!mesh_hdr->ttl)
+               /* illegal frame */
+               return RX_DROP_MONITOR;
+
+       if (compare_ether_addr(rx->dev->dev_addr, hdr->addr3) == 0)
+               return RX_CONTINUE;
+
+       mesh_hdr->ttl--;
+
+       if (rx->flags & IEEE80211_RX_RA_MATCH) {
+               if (!mesh_hdr->ttl)
+                       IEEE80211_IFSTA_MESH_CTR_INC(&rx->sdata->u.sta,
+                                                    dropped_frames_ttl);
+               else {
+                       struct ieee80211_hdr *fwd_hdr;
+                       fwd_skb = skb_copy(skb, GFP_ATOMIC);
+
+                       if (!fwd_skb && net_ratelimit())
+                               printk(KERN_DEBUG "%s: failed to clone mesh frame\n",
+                                                  rx->dev->name);
+
+                       fwd_hdr =  (struct ieee80211_hdr *) fwd_skb->data;
+                       /*
+                        * Save TA to addr1 to send TA a path error if a
+                        * suitable next hop is not found
+                        */
+                       memcpy(fwd_hdr->addr1, fwd_hdr->addr2, ETH_ALEN);
+                       memcpy(fwd_hdr->addr2, rx->dev->dev_addr, ETH_ALEN);
+                       fwd_skb->dev = rx->local->mdev;
+                       fwd_skb->iif = rx->dev->ifindex;
+                       dev_queue_xmit(fwd_skb);
+               }
+       }
+
+       if (is_multicast_ether_addr(hdr->addr3) ||
+           rx->dev->flags & IFF_PROMISC)
+               return RX_CONTINUE;
+       else
+               return RX_DROP_MONITOR;
+}
+
+
+static ieee80211_rx_result debug_noinline
 ieee80211_rx_h_data(struct ieee80211_rx_data *rx)
 {
        struct net_device *dev = rx->dev;
@@ -1560,21 +1475,21 @@ ieee80211_rx_h_data(struct ieee80211_rx_data *rx)
        return RX_QUEUED;
 }
 
-static ieee80211_rx_result
+static ieee80211_rx_result debug_noinline
 ieee80211_rx_h_ctrl(struct ieee80211_rx_data *rx)
 {
        struct ieee80211_local *local = rx->local;
        struct ieee80211_hw *hw = &local->hw;
        struct sk_buff *skb = rx->skb;
-       struct ieee80211_bar *bar = (struct ieee80211_bar *) skb->data;
+       struct ieee80211_bar *bar = (struct ieee80211_bar *)skb->data;
        struct tid_ampdu_rx *tid_agg_rx;
        u16 start_seq_num;
        u16 tid;
 
-       if (likely((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_CTL))
+       if (likely(!ieee80211_is_ctl(bar->frame_control)))
                return RX_CONTINUE;
 
-       if ((rx->fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_BACK_REQ) {
+       if (ieee80211_is_back_req(bar->frame_control)) {
                if (!rx->sta)
                        return RX_CONTINUE;
                tid = le16_to_cpu(bar->control) >> 12;
@@ -1604,7 +1519,7 @@ ieee80211_rx_h_ctrl(struct ieee80211_rx_data *rx)
        return RX_CONTINUE;
 }
 
-static ieee80211_rx_result
+static ieee80211_rx_result debug_noinline
 ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx)
 {
        struct ieee80211_sub_if_data *sdata;
@@ -1628,41 +1543,27 @@ static void ieee80211_rx_michael_mic_report(struct net_device *dev,
                                            struct ieee80211_hdr *hdr,
                                            struct ieee80211_rx_data *rx)
 {
-       int keyidx, hdrlen;
+       int keyidx;
+       unsigned int hdrlen;
        DECLARE_MAC_BUF(mac);
        DECLARE_MAC_BUF(mac2);
 
-       hdrlen = ieee80211_get_hdrlen_from_skb(rx->skb);
+       hdrlen = ieee80211_hdrlen(hdr->frame_control);
        if (rx->skb->len >= hdrlen + 4)
                keyidx = rx->skb->data[hdrlen + 3] >> 6;
        else
                keyidx = -1;
 
-       if (net_ratelimit())
-               printk(KERN_DEBUG "%s: TKIP hwaccel reported Michael MIC "
-                      "failure from %s to %s keyidx=%d\n",
-                      dev->name, print_mac(mac, hdr->addr2),
-                      print_mac(mac2, hdr->addr1), keyidx);
-
        if (!rx->sta) {
                /*
                 * Some hardware seem to generate incorrect Michael MIC
                 * reports; ignore them to avoid triggering countermeasures.
                 */
-               if (net_ratelimit())
-                       printk(KERN_DEBUG "%s: ignored spurious Michael MIC "
-                              "error for unknown address %s\n",
-                              dev->name, print_mac(mac, hdr->addr2));
                goto ignore;
        }
 
-       if (!(rx->fc & IEEE80211_FCTL_PROTECTED)) {
-               if (net_ratelimit())
-                       printk(KERN_DEBUG "%s: ignored spurious Michael MIC "
-                              "error for a frame with no PROTECTED flag (src "
-                              "%s)\n", dev->name, print_mac(mac, hdr->addr2));
+       if (!ieee80211_has_protected(hdr->frame_control))
                goto ignore;
-       }
 
        if (rx->sdata->vif.type == IEEE80211_IF_TYPE_AP && keyidx) {
                /*
@@ -1671,24 +1572,12 @@ static void ieee80211_rx_michael_mic_report(struct net_device *dev,
                 * group keys and only the AP is sending real multicast
                 * frames in the BSS.
                 */
-               if (net_ratelimit())
-                       printk(KERN_DEBUG "%s: ignored Michael MIC error for "
-                              "a frame with non-zero keyidx (%d)"
-                              " (src %s)\n", dev->name, keyidx,
-                              print_mac(mac, hdr->addr2));
                goto ignore;
        }
 
-       if ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA &&
-           ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_MGMT ||
-            (rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_AUTH)) {
-               if (net_ratelimit())
-                       printk(KERN_DEBUG "%s: ignored spurious Michael MIC "
-                              "error for a frame that cannot be encrypted "
-                              "(fc=0x%04x) (src %s)\n",
-                              dev->name, rx->fc, print_mac(mac, hdr->addr2));
+       if (!ieee80211_is_data(hdr->frame_control) &&
+           !ieee80211_is_auth(hdr->frame_control))
                goto ignore;
-       }
 
        mac80211_ev_michael_mic_failure(rx->dev, keyidx, hdr);
  ignore:
@@ -1777,67 +1666,61 @@ static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data *rx)
        dev_kfree_skb(skb);
 }
 
-typedef ieee80211_rx_result (*ieee80211_rx_handler)(struct ieee80211_rx_data *);
-static ieee80211_rx_handler ieee80211_rx_handlers[] =
-{
-       ieee80211_rx_h_if_stats,
-       ieee80211_rx_h_passive_scan,
-       ieee80211_rx_h_check,
-       ieee80211_rx_h_decrypt,
-       ieee80211_rx_h_sta_process,
-       ieee80211_rx_h_defragment,
-       ieee80211_rx_h_ps_poll,
-       ieee80211_rx_h_michael_mic_verify,
-       /* this must be after decryption - so header is counted in MPDU mic
-        * must be before pae and data, so QOS_DATA format frames
-        * are not passed to user space by these functions
-        */
-       ieee80211_rx_h_remove_qos_control,
-       ieee80211_rx_h_amsdu,
-       ieee80211_rx_h_data,
-       ieee80211_rx_h_ctrl,
-       ieee80211_rx_h_mgmt,
-       NULL
-};
 
 static void ieee80211_invoke_rx_handlers(struct ieee80211_sub_if_data *sdata,
                                         struct ieee80211_rx_data *rx,
                                         struct sk_buff *skb)
 {
-       ieee80211_rx_handler *handler;
        ieee80211_rx_result res = RX_DROP_MONITOR;
 
        rx->skb = skb;
        rx->sdata = sdata;
        rx->dev = sdata->dev;
 
-       for (handler = ieee80211_rx_handlers; *handler != NULL; handler++) {
-               res = (*handler)(rx);
-
-               switch (res) {
-               case RX_CONTINUE:
-                       continue;
-               case RX_DROP_UNUSABLE:
-               case RX_DROP_MONITOR:
-                       I802_DEBUG_INC(sdata->local->rx_handlers_drop);
-                       if (rx->sta)
-                               rx->sta->rx_dropped++;
-                       break;
-               case RX_QUEUED:
-                       I802_DEBUG_INC(sdata->local->rx_handlers_queued);
-                       break;
-               }
-               break;
-       }
-
+#define CALL_RXH(rxh)                  \
+       do {                            \
+               res = rxh(rx);          \
+               if (res != RX_CONTINUE) \
+                       goto rxh_done;  \
+       } while (0);
+
+       CALL_RXH(ieee80211_rx_h_passive_scan)
+       CALL_RXH(ieee80211_rx_h_check)
+       CALL_RXH(ieee80211_rx_h_decrypt)
+       CALL_RXH(ieee80211_rx_h_sta_process)
+       CALL_RXH(ieee80211_rx_h_defragment)
+       CALL_RXH(ieee80211_rx_h_ps_poll)
+       CALL_RXH(ieee80211_rx_h_michael_mic_verify)
+       /* must be after MMIC verify so header is counted in MPDU mic */
+       CALL_RXH(ieee80211_rx_h_remove_qos_control)
+       CALL_RXH(ieee80211_rx_h_amsdu)
+       if (ieee80211_vif_is_mesh(&sdata->vif))
+               CALL_RXH(ieee80211_rx_h_mesh_fwding);
+       CALL_RXH(ieee80211_rx_h_data)
+       CALL_RXH(ieee80211_rx_h_ctrl)
+       CALL_RXH(ieee80211_rx_h_mgmt)
+
+#undef CALL_RXH
+
+ rxh_done:
        switch (res) {
-       case RX_CONTINUE:
        case RX_DROP_MONITOR:
+               I802_DEBUG_INC(sdata->local->rx_handlers_drop);
+               if (rx->sta)
+                       rx->sta->rx_dropped++;
+               /* fall through */
+       case RX_CONTINUE:
                ieee80211_rx_cooked_monitor(rx);
                break;
        case RX_DROP_UNUSABLE:
+               I802_DEBUG_INC(sdata->local->rx_handlers_drop);
+               if (rx->sta)
+                       rx->sta->rx_dropped++;
                dev_kfree_skb(rx->skb);
                break;
+       case RX_QUEUED:
+               I802_DEBUG_INC(sdata->local->rx_handlers_queued);
+               break;
        }
 }
 
@@ -1868,9 +1751,13 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata,
        case IEEE80211_IF_TYPE_IBSS:
                if (!bssid)
                        return 0;
-               if ((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT &&
-                   (rx->fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_BEACON)
+               if (ieee80211_is_beacon(hdr->frame_control)) {
+                       if (!rx->sta)
+                               rx->sta = ieee80211_ibss_add_sta(sdata->dev,
+                                               rx->skb, bssid, hdr->addr2,
+                                               BIT(rx->status->rate_idx));
                        return 1;
+               }
                else if (!ieee80211_bssid_match(bssid, sdata->u.sta.bssid)) {
                        if (!(rx->flags & IEEE80211_RX_IN_SCAN))
                                return 0;
@@ -1883,7 +1770,8 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata,
                        rx->flags &= ~IEEE80211_RX_RA_MATCH;
                } else if (!rx->sta)
                        rx->sta = ieee80211_ibss_add_sta(sdata->dev, rx->skb,
-                                                        bssid, hdr->addr2);
+                                               bssid, hdr->addr2,
+                                               BIT(rx->status->rate_idx));
                break;
        case IEEE80211_IF_TYPE_MESH_POINT:
                if (!multicast &&
@@ -1907,15 +1795,9 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata,
                                return 0;
                        rx->flags &= ~IEEE80211_RX_RA_MATCH;
                }
-               if (sdata->dev == sdata->local->mdev &&
-                   !(rx->flags & IEEE80211_RX_IN_SCAN))
-                       /* do not receive anything via
-                        * master device when not scanning */
-                       return 0;
                break;
        case IEEE80211_IF_TYPE_WDS:
-               if (bssid ||
-                   (rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)
+               if (bssid || !ieee80211_is_data(hdr->frame_control))
                        return 0;
                if (compare_ether_addr(sdata->u.wds.remote_addr, hdr->addr2))
                        return 0;
@@ -1939,7 +1821,6 @@ static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata,
 static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
                                         struct sk_buff *skb,
                                         struct ieee80211_rx_status *status,
-                                        u32 load,
                                         struct ieee80211_rate *rate)
 {
        struct ieee80211_local *local = hw_to_local(hw);
@@ -1958,7 +1839,6 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
        rx.local = local;
 
        rx.status = status;
-       rx.load = load;
        rx.rate = rate;
        rx.fc = le16_to_cpu(hdr->frame_control);
        type = rx.fc & IEEE80211_FCTL_FTYPE;
@@ -2019,7 +1899,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
                if (!skb_new) {
                        if (net_ratelimit())
                                printk(KERN_DEBUG "%s: failed to copy "
-                                      "multicast frame for %s",
+                                      "multicast frame for %s\n",
                                       wiphy_name(local->hw.wiphy),
                                       prev->dev->name);
                        continue;
@@ -2067,7 +1947,6 @@ u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw,
        struct ieee80211_rx_status status;
        u16 head_seq_num, buf_size;
        int index;
-       u32 pkt_load;
        struct ieee80211_supported_band *sband;
        struct ieee80211_rate *rate;
 
@@ -2102,12 +1981,9 @@ u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw,
                                        sizeof(status));
                                sband = local->hw.wiphy->bands[status.band];
                                rate = &sband->bitrates[status.rate_idx];
-                               pkt_load = ieee80211_rx_load_stats(local,
-                                               tid_agg_rx->reorder_buf[index],
-                                               &status, rate);
                                __ieee80211_rx_handle_packet(hw,
                                        tid_agg_rx->reorder_buf[index],
-                                       &status, pkt_load, rate);
+                                       &status, rate);
                                tid_agg_rx->stored_mpdu_num--;
                                tid_agg_rx->reorder_buf[index] = NULL;
                        }
@@ -2149,11 +2025,8 @@ u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw,
                        sizeof(status));
                sband = local->hw.wiphy->bands[status.band];
                rate = &sband->bitrates[status.rate_idx];
-               pkt_load = ieee80211_rx_load_stats(local,
-                                       tid_agg_rx->reorder_buf[index],
-                                       &status, rate);
                __ieee80211_rx_handle_packet(hw, tid_agg_rx->reorder_buf[index],
-                                            &status, pkt_load, rate);
+                                            &status, rate);
                tid_agg_rx->stored_mpdu_num--;
                tid_agg_rx->reorder_buf[index] = NULL;
                tid_agg_rx->head_seq_num = seq_inc(tid_agg_rx->head_seq_num);
@@ -2170,32 +2043,29 @@ static u8 ieee80211_rx_reorder_ampdu(struct ieee80211_local *local,
        struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
        struct sta_info *sta;
        struct tid_ampdu_rx *tid_agg_rx;
-       u16 fc, sc;
+       u16 sc;
        u16 mpdu_seq_num;
-       u8 ret = 0, *qc;
+       u8 ret = 0;
        int tid;
 
        sta = sta_info_get(local, hdr->addr2);
        if (!sta)
                return ret;
 
-       fc = le16_to_cpu(hdr->frame_control);
-
        /* filter the QoS data rx stream according to
         * STA/TID and check if this STA/TID is on aggregation */
-       if (!WLAN_FC_IS_QOS_DATA(fc))
+       if (!ieee80211_is_data_qos(hdr->frame_control))
                goto end_reorder;
 
-       qc = skb->data + ieee80211_get_hdrlen(fc) - QOS_CONTROL_LEN;
-       tid = qc[0] & QOS_CONTROL_TID_MASK;
+       tid = *ieee80211_get_qos_ctl(hdr) & IEEE80211_QOS_CTL_TID_MASK;
 
        if (sta->ampdu_mlme.tid_state_rx[tid] != HT_AGG_STATE_OPERATIONAL)
                goto end_reorder;
 
        tid_agg_rx = sta->ampdu_mlme.tid_rx[tid];
 
-       /* null data frames are excluded */
-       if (unlikely(fc & IEEE80211_STYPE_NULLFUNC))
+       /* qos null data frames are excluded */
+       if (unlikely(hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_NULLFUNC)))
                goto end_reorder;
 
        /* new un-ordered ampdu frame - process it */
@@ -2232,7 +2102,6 @@ void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
                    struct ieee80211_rx_status *status)
 {
        struct ieee80211_local *local = hw_to_local(hw);
-       u32 pkt_load;
        struct ieee80211_rate *rate = NULL;
        struct ieee80211_supported_band *sband;
 
@@ -2272,11 +2141,8 @@ void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
                return;
        }
 
-       pkt_load = ieee80211_rx_load_stats(local, skb, status, rate);
-       local->channel_use_raw += pkt_load;
-
        if (!ieee80211_rx_reorder_ampdu(local, skb))
-               __ieee80211_rx_handle_packet(hw, skb, status, pkt_load, rate);
+               __ieee80211_rx_handle_packet(hw, skb, status, rate);
 
        rcu_read_unlock();
 }