]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/mac80211/tx.c
net: Print the module name as part of the watchdog message
[linux-2.6-omap-h63xx.git] / net / mac80211 / tx.c
index 7a14a39ebd788624bdb26fb455aa9d1493fddfa1..0fbadd8b983c821df9de353217e998058565718f 100644 (file)
 
 /* misc utils */
 
-static inline void ieee80211_include_sequence(struct ieee80211_sub_if_data *sdata,
-                                             struct ieee80211_hdr *hdr)
-{
-       /* Set the sequence number for this frame. */
-       hdr->seq_ctrl = cpu_to_le16(sdata->sequence);
-
-       /* Increase the sequence number. */
-       sdata->sequence = (sdata->sequence + 0x10) & IEEE80211_SCTL_SEQ;
-}
-
 #ifdef CONFIG_MAC80211_LOWTX_FRAME_DUMP
 static void ieee80211_dump_frame(const char *ifname, const char *title,
                                 const struct sk_buff *skb)
 {
-       const struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
-       u16 fc;
-       int hdrlen;
+       const struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+       unsigned int hdrlen;
        DECLARE_MAC_BUF(mac);
 
        printk(KERN_DEBUG "%s: %s (len=%d)", ifname, title, skb->len);
@@ -63,13 +52,12 @@ static void ieee80211_dump_frame(const char *ifname, const char *title,
                return;
        }
 
-       fc = le16_to_cpu(hdr->frame_control);
-       hdrlen = ieee80211_get_hdrlen(fc);
+       hdrlen = ieee80211_hdrlen(hdr->frame_control);
        if (hdrlen > skb->len)
                hdrlen = skb->len;
        if (hdrlen >= 4)
                printk(" FC=0x%04x DUR=0x%04x",
-                      fc, le16_to_cpu(hdr->duration_id));
+                   le16_to_cpu(hdr->frame_control), le16_to_cpu(hdr->duration_id));
        if (hdrlen >= 10)
                printk(" A1=%s", print_mac(mac, hdr->addr1));
        if (hdrlen >= 16)
@@ -87,8 +75,8 @@ static inline void ieee80211_dump_frame(const char *ifname, const char *title,
 }
 #endif /* CONFIG_MAC80211_LOWTX_FRAME_DUMP */
 
-static u16 ieee80211_duration(struct ieee80211_tx_data *tx, int group_addr,
-                             int next_frag_len)
+static __le16 ieee80211_duration(struct ieee80211_tx_data *tx, int group_addr,
+                                int next_frag_len)
 {
        int rate, mrate, erp, dur, i;
        struct ieee80211_rate *txrate;
@@ -140,7 +128,7 @@ static u16 ieee80211_duration(struct ieee80211_tx_data *tx, int group_addr,
 
        /* data/mgmt */
        if (0 /* FIX: data/mgmt during CFP */)
-               return 32768;
+               return cpu_to_le16(32768);
 
        if (group_addr) /* Group address as the destination - no ACK */
                return 0;
@@ -210,7 +198,7 @@ static u16 ieee80211_duration(struct ieee80211_tx_data *tx, int group_addr,
                                tx->sdata->bss_conf.use_short_preamble);
        }
 
-       return dur;
+       return cpu_to_le16(dur);
 }
 
 static int inline is_ieee80211_device(struct net_device *dev,
@@ -222,7 +210,7 @@ static int inline is_ieee80211_device(struct net_device *dev,
 
 /* tx handlers */
 
-static ieee80211_tx_result
+static ieee80211_tx_result debug_noinline
 ieee80211_tx_h_check_assoc(struct ieee80211_tx_data *tx)
 {
 #ifdef CONFIG_MAC80211_VERBOSE_DEBUG
@@ -276,17 +264,6 @@ ieee80211_tx_h_check_assoc(struct ieee80211_tx_data *tx)
        return TX_CONTINUE;
 }
 
-static ieee80211_tx_result
-ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx)
-{
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
-
-       if (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control)) >= 24)
-               ieee80211_include_sequence(tx->sdata, hdr);
-
-       return TX_CONTINUE;
-}
-
 /* This function is called whenever the AP is about to exceed the maximum limit
  * of buffered frames for power saving STAs. This situation should not really
  * happen often during normal operation, so dropping the oldest buffered packet
@@ -305,8 +282,7 @@ static void purge_old_ps_buffers(struct ieee80211_local *local)
 
        list_for_each_entry_rcu(sdata, &local->interfaces, list) {
                struct ieee80211_if_ap *ap;
-               if (sdata->dev == local->mdev ||
-                   sdata->vif.type != IEEE80211_IF_TYPE_AP)
+               if (sdata->vif.type != IEEE80211_IF_TYPE_AP)
                        continue;
                ap = &sdata->u.ap;
                skb = skb_dequeue(&ap->ps_bc_buf);
@@ -329,8 +305,10 @@ static void purge_old_ps_buffers(struct ieee80211_local *local)
        rcu_read_unlock();
 
        local->total_ps_buffered = total;
+#ifdef MAC80211_VERBOSE_PS_DEBUG
        printk(KERN_DEBUG "%s: PS buffers full - purged %d frames\n",
               wiphy_name(local->hw.wiphy), purged);
+#endif
 }
 
 static ieee80211_tx_result
@@ -346,8 +324,12 @@ ieee80211_tx_h_multicast_ps_buf(struct ieee80211_tx_data *tx)
         * This is done either by the hardware or us.
         */
 
-       /* not AP/IBSS or ordered frame */
-       if (!tx->sdata->bss || (tx->fc & IEEE80211_FCTL_ORDER))
+       /* powersaving STAs only in AP/VLAN mode */
+       if (!tx->sdata->bss)
+               return TX_CONTINUE;
+
+       /* no buffering for ordered frames */
+       if (tx->fc & IEEE80211_FCTL_ORDER)
                return TX_CONTINUE;
 
        /* no stations in PS mode */
@@ -360,11 +342,13 @@ ieee80211_tx_h_multicast_ps_buf(struct ieee80211_tx_data *tx)
                        purge_old_ps_buffers(tx->local);
                if (skb_queue_len(&tx->sdata->bss->ps_bc_buf) >=
                    AP_MAX_BC_BUFFER) {
+#ifdef MAC80211_VERBOSE_PS_DEBUG
                        if (net_ratelimit()) {
                                printk(KERN_DEBUG "%s: BC TX buffer full - "
                                       "dropping the oldest frame\n",
                                       tx->dev->name);
                        }
+#endif
                        dev_kfree_skb(skb_dequeue(&tx->sdata->bss->ps_bc_buf));
                } else
                        tx->local->total_ps_buffered++;
@@ -405,11 +389,13 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx)
                        purge_old_ps_buffers(tx->local);
                if (skb_queue_len(&sta->ps_tx_buf) >= STA_MAX_TX_BUFFER) {
                        struct sk_buff *old = skb_dequeue(&sta->ps_tx_buf);
+#ifdef MAC80211_VERBOSE_PS_DEBUG
                        if (net_ratelimit()) {
                                printk(KERN_DEBUG "%s: STA %s TX "
                                       "buffer full - dropping oldest frame\n",
                                       tx->dev->name, print_mac(mac, sta->addr));
                        }
+#endif
                        dev_kfree_skb(old);
                } else
                        tx->local->total_ps_buffered++;
@@ -434,7 +420,7 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx)
        return TX_CONTINUE;
 }
 
-static ieee80211_tx_result
+static ieee80211_tx_result debug_noinline
 ieee80211_tx_h_ps_buf(struct ieee80211_tx_data *tx)
 {
        if (unlikely(tx->flags & IEEE80211_TX_PS_BUFFERED))
@@ -446,7 +432,7 @@ ieee80211_tx_h_ps_buf(struct ieee80211_tx_data *tx)
                return ieee80211_tx_h_multicast_ps_buf(tx);
 }
 
-static ieee80211_tx_result
+static ieee80211_tx_result debug_noinline
 ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
 {
        struct ieee80211_key *key;
@@ -495,7 +481,7 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
        return TX_CONTINUE;
 }
 
-static ieee80211_tx_result
+static ieee80211_tx_result debug_noinline
 ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx)
 {
        struct rate_selection rsel;
@@ -539,12 +525,10 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx)
        return TX_CONTINUE;
 }
 
-static ieee80211_tx_result
+static ieee80211_tx_result debug_noinline
 ieee80211_tx_h_misc(struct ieee80211_tx_data *tx)
 {
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data;
-       u16 fc = le16_to_cpu(hdr->frame_control);
-       u16 dur;
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
        struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
        struct ieee80211_supported_band *sband;
 
@@ -595,21 +579,13 @@ ieee80211_tx_h_misc(struct ieee80211_tx_data *tx)
        /* Transmit data frames using short preambles if the driver supports
         * short preambles at the selected rate and short preambles are
         * available on the network at the current point in time. */
-       if (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) &&
+       if (ieee80211_is_data(hdr->frame_control) &&
            (sband->bitrates[tx->rate_idx].flags & IEEE80211_RATE_SHORT_PREAMBLE) &&
            tx->sdata->bss_conf.use_short_preamble &&
            (!tx->sta || test_sta_flags(tx->sta, WLAN_STA_SHORT_PREAMBLE))) {
                info->flags |= IEEE80211_TX_CTL_SHORT_PREAMBLE;
        }
 
-       /* Setup duration field for the first fragment of the frame. Duration
-        * for remaining fragments will be updated when they are being sent
-        * to low-level driver in ieee80211_tx(). */
-       dur = ieee80211_duration(tx, is_multicast_ether_addr(hdr->addr1),
-                                (tx->flags & IEEE80211_TX_FRAGMENTED) ?
-                                tx->extra_frag[0]->len : 0);
-       hdr->duration_id = cpu_to_le16(dur);
-
        if ((info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) ||
            (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT)) {
                struct ieee80211_rate *rate;
@@ -644,10 +620,53 @@ ieee80211_tx_h_misc(struct ieee80211_tx_data *tx)
        return TX_CONTINUE;
 }
 
-static ieee80211_tx_result
+static ieee80211_tx_result debug_noinline
+ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx)
+{
+       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
+       u16 *seq;
+       u8 *qc;
+       int tid;
+
+       /* only for injected frames */
+       if (unlikely(ieee80211_is_ctl(hdr->frame_control)))
+               return TX_CONTINUE;
+
+       if (ieee80211_hdrlen(hdr->frame_control) < 24)
+               return TX_CONTINUE;
+
+       if (!ieee80211_is_data_qos(hdr->frame_control)) {
+               info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ;
+               return TX_CONTINUE;
+       }
+
+       /*
+        * This should be true for injected/management frames only, for
+        * management frames we have set the IEEE80211_TX_CTL_ASSIGN_SEQ
+        * above since they are not QoS-data frames.
+        */
+       if (!tx->sta)
+               return TX_CONTINUE;
+
+       /* include per-STA, per-TID sequence counter */
+
+       qc = ieee80211_get_qos_ctl(hdr);
+       tid = *qc & IEEE80211_QOS_CTL_TID_MASK;
+       seq = &tx->sta->tid_seq[tid];
+
+       hdr->seq_ctrl = cpu_to_le16(*seq);
+
+       /* Increase the sequence number. */
+       *seq = (*seq + 0x10) & IEEE80211_SCTL_SEQ;
+
+       return TX_CONTINUE;
+}
+
+static ieee80211_tx_result debug_noinline
 ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx)
 {
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data;
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
        size_t hdrlen, per_fragm, num_fragm, payload_len, left;
        struct sk_buff **frags, *first, *frag;
        int i;
@@ -670,7 +689,7 @@ ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx)
 
        first = tx->skb;
 
-       hdrlen = ieee80211_get_hdrlen(tx->fc);
+       hdrlen = ieee80211_hdrlen(hdr->frame_control);
        payload_len = first->len - hdrlen;
        per_fragm = frag_threshold - hdrlen - FCS_LEN;
        num_fragm = DIV_ROUND_UP(payload_len, per_fragm);
@@ -711,6 +730,8 @@ ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx)
                fhdr->seq_ctrl = cpu_to_le16(seq | ((i + 1) & IEEE80211_SCTL_FRAG));
                copylen = left > per_fragm ? per_fragm : left;
                memcpy(skb_put(frag, copylen), pos, copylen);
+               memcpy(frag->cb, first->cb, sizeof(frag->cb));
+               skb_copy_queue_mapping(frag, first);
 
                pos += copylen;
                left -= copylen;
@@ -723,7 +744,6 @@ ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx)
        return TX_CONTINUE;
 
  fail:
-       printk(KERN_DEBUG "%s: failed to fragment frame\n", tx->dev->name);
        if (frags) {
                for (i = 0; i < num_fragm - 1; i++)
                        if (frags[i])
@@ -734,7 +754,7 @@ ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx)
        return TX_DROP;
 }
 
-static ieee80211_tx_result
+static ieee80211_tx_result debug_noinline
 ieee80211_tx_h_encrypt(struct ieee80211_tx_data *tx)
 {
        if (!tx->key)
@@ -754,7 +774,37 @@ ieee80211_tx_h_encrypt(struct ieee80211_tx_data *tx)
        return TX_DROP;
 }
 
-static ieee80211_tx_result
+static ieee80211_tx_result debug_noinline
+ieee80211_tx_h_calculate_duration(struct ieee80211_tx_data *tx)
+{
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
+       int next_len, i;
+       int group_addr = is_multicast_ether_addr(hdr->addr1);
+
+       if (!(tx->flags & IEEE80211_TX_FRAGMENTED)) {
+               hdr->duration_id = ieee80211_duration(tx, group_addr, 0);
+               return TX_CONTINUE;
+       }
+
+       hdr->duration_id = ieee80211_duration(tx, group_addr,
+                                             tx->extra_frag[0]->len);
+
+       for (i = 0; i < tx->num_extra_frag; i++) {
+               if (i + 1 < tx->num_extra_frag) {
+                       next_len = tx->extra_frag[i + 1]->len;
+               } else {
+                       next_len = 0;
+                       tx->rate_idx = tx->last_frag_rate_idx;
+               }
+
+               hdr = (struct ieee80211_hdr *)tx->extra_frag[i]->data;
+               hdr->duration_id = ieee80211_duration(tx, 0, next_len);
+       }
+
+       return TX_CONTINUE;
+}
+
+static ieee80211_tx_result debug_noinline
 ieee80211_tx_h_stats(struct ieee80211_tx_data *tx)
 {
        int i;
@@ -775,23 +825,6 @@ ieee80211_tx_h_stats(struct ieee80211_tx_data *tx)
 }
 
 
-typedef ieee80211_tx_result (*ieee80211_tx_handler)(struct ieee80211_tx_data *);
-static ieee80211_tx_handler ieee80211_tx_handlers[] =
-{
-       ieee80211_tx_h_check_assoc,
-       ieee80211_tx_h_sequence,
-       ieee80211_tx_h_ps_buf,
-       ieee80211_tx_h_select_key,
-       ieee80211_tx_h_michael_mic_add,
-       ieee80211_tx_h_rate_ctrl,
-       ieee80211_tx_h_misc,
-       ieee80211_tx_h_fragment,
-       /* handlers after fragment must be aware of tx info fragmentation! */
-       ieee80211_tx_h_encrypt,
-       ieee80211_tx_h_stats,
-       NULL
-};
-
 /* actual transmit path */
 
 /*
@@ -1089,20 +1122,32 @@ static int __ieee80211_tx(struct ieee80211_local *local, struct sk_buff *skb,
  */
 static int invoke_tx_handlers(struct ieee80211_tx_data *tx)
 {
-       struct ieee80211_local *local = tx->local;
        struct sk_buff *skb = tx->skb;
-       ieee80211_tx_handler *handler;
        ieee80211_tx_result res = TX_DROP;
        int i;
 
-       for (handler = ieee80211_tx_handlers; *handler != NULL; handler++) {
-               res = (*handler)(tx);
-               if (res != TX_CONTINUE)
-                       break;
-       }
+#define CALL_TXH(txh)          \
+       res = txh(tx);          \
+       if (res != TX_CONTINUE) \
+               goto txh_done;
+
+       CALL_TXH(ieee80211_tx_h_check_assoc)
+       CALL_TXH(ieee80211_tx_h_ps_buf)
+       CALL_TXH(ieee80211_tx_h_select_key)
+       CALL_TXH(ieee80211_tx_h_michael_mic_add)
+       CALL_TXH(ieee80211_tx_h_rate_ctrl)
+       CALL_TXH(ieee80211_tx_h_misc)
+       CALL_TXH(ieee80211_tx_h_sequence)
+       CALL_TXH(ieee80211_tx_h_fragment)
+       /* handlers after fragment must be aware of tx info fragmentation! */
+       CALL_TXH(ieee80211_tx_h_encrypt)
+       CALL_TXH(ieee80211_tx_h_calculate_duration)
+       CALL_TXH(ieee80211_tx_h_stats)
+#undef CALL_TXH
 
+ txh_done:
        if (unlikely(res == TX_DROP)) {
-               I802_DEBUG_INC(local->tx_handlers_drop);
+               I802_DEBUG_INC(tx->local->tx_handlers_drop);
                dev_kfree_skb(skb);
                for (i = 0; i < tx->num_extra_frag; i++)
                        if (tx->extra_frag[i])
@@ -1110,7 +1155,7 @@ static int invoke_tx_handlers(struct ieee80211_tx_data *tx)
                kfree(tx->extra_frag);
                return -1;
        } else if (unlikely(res == TX_QUEUED)) {
-               I802_DEBUG_INC(local->tx_handlers_queued);
+               I802_DEBUG_INC(tx->local->tx_handlers_queued);
                return -1;
        }
 
@@ -1154,24 +1199,6 @@ static int ieee80211_tx(struct net_device *dev, struct sk_buff *skb)
        if (invoke_tx_handlers(&tx))
                goto out;
 
-       if (tx.extra_frag) {
-               for (i = 0; i < tx.num_extra_frag; i++) {
-                       int next_len, dur;
-                       struct ieee80211_hdr *hdr =
-                               (struct ieee80211_hdr *)
-                               tx.extra_frag[i]->data;
-
-                       if (i + 1 < tx.num_extra_frag) {
-                               next_len = tx.extra_frag[i + 1]->len;
-                       } else {
-                               next_len = 0;
-                               tx.rate_idx = tx.last_frag_rate_idx;
-                       }
-                       dur = ieee80211_duration(&tx, 0, next_len);
-                       hdr->duration_id = cpu_to_le16(dur);
-               }
-       }
-
 retry:
        ret = __ieee80211_tx(local, skb, &tx);
        if (ret) {
@@ -1395,7 +1422,8 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
        struct ieee80211_tx_info *info;
        struct ieee80211_sub_if_data *sdata;
        int ret = 1, head_need;
-       u16 ethertype, hdrlen,  meshhdrlen = 0, fc;
+       u16 ethertype, hdrlen,  meshhdrlen = 0;
+       __le16 fc;
        struct ieee80211_hdr hdr;
        struct ieee80211s_hdr mesh_hdr;
        const u8 *encaps_data;
@@ -1406,8 +1434,6 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
 
        sdata = IEEE80211_DEV_TO_SUB_IF(dev);
        if (unlikely(skb->len < ETH_HLEN)) {
-               printk(KERN_DEBUG "%s: short skb (len=%d)\n",
-                      dev->name, skb->len);
                ret = 0;
                goto fail;
        }
@@ -1418,12 +1444,12 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
        /* convert Ethernet header to proper 802.11 header (based on
         * operation mode) */
        ethertype = (skb->data[12] << 8) | skb->data[13];
-       fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA;
+       fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA);
 
        switch (sdata->vif.type) {
        case IEEE80211_IF_TYPE_AP:
        case IEEE80211_IF_TYPE_VLAN:
-               fc |= IEEE80211_FCTL_FROMDS;
+               fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS);
                /* DA BSSID SA */
                memcpy(hdr.addr1, skb->data, ETH_ALEN);
                memcpy(hdr.addr2, dev->dev_addr, ETH_ALEN);
@@ -1431,7 +1457,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
                hdrlen = 24;
                break;
        case IEEE80211_IF_TYPE_WDS:
-               fc |= IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS;
+               fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS);
                /* RA TA DA SA */
                memcpy(hdr.addr1, sdata->u.wds.remote_addr, ETH_ALEN);
                memcpy(hdr.addr2, dev->dev_addr, ETH_ALEN);
@@ -1441,7 +1467,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
                break;
 #ifdef CONFIG_MAC80211_MESH
        case IEEE80211_IF_TYPE_MESH_POINT:
-               fc |= IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS;
+               fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS);
                /* RA TA DA SA */
                if (is_multicast_ether_addr(skb->data))
                        memcpy(hdr.addr1, skb->data, ETH_ALEN);
@@ -1471,7 +1497,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
                break;
 #endif
        case IEEE80211_IF_TYPE_STA:
-               fc |= IEEE80211_FCTL_TODS;
+               fc |= cpu_to_le16(IEEE80211_FCTL_TODS);
                /* BSSID SA DA */
                memcpy(hdr.addr1, sdata->u.sta.bssid, ETH_ALEN);
                memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN);
@@ -1506,7 +1532,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
        /* receiver and we are QoS enabled, use a QoS type frame */
        if (sta_flags & WLAN_STA_WME &&
            ieee80211_num_regular_queues(&local->hw) >= 4) {
-               fc |= IEEE80211_STYPE_QOS_DATA;
+               fc |= cpu_to_le16(IEEE80211_STYPE_QOS_DATA);
                hdrlen += 2;
        }
 
@@ -1534,7 +1560,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
                goto fail;
        }
 
-       hdr.frame_control = cpu_to_le16(fc);
+       hdr.frame_control = fc;
        hdr.duration_id = 0;
        hdr.seq_ctrl = 0;
 
@@ -1603,7 +1629,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
                h_pos += meshhdrlen;
        }
 
-       if (fc & IEEE80211_STYPE_QOS_DATA) {
+       if (ieee80211_is_data_qos(fc)) {
                __le16 *qos_control;
 
                qos_control = (__le16*) skb_push(skb, 2);
@@ -1784,17 +1810,17 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
                                     struct ieee80211_vif *vif)
 {
        struct ieee80211_local *local = hw_to_local(hw);
-       struct sk_buff *skb;
+       struct sk_buff *skb = NULL;
        struct ieee80211_tx_info *info;
        struct net_device *bdev;
        struct ieee80211_sub_if_data *sdata = NULL;
        struct ieee80211_if_ap *ap = NULL;
+       struct ieee80211_if_sta *ifsta = NULL;
        struct rate_selection rsel;
        struct beacon_data *beacon;
        struct ieee80211_supported_band *sband;
        struct ieee80211_mgmt *mgmt;
        int *num_beacons;
-       bool err = true;
        enum ieee80211_band band = local->hw.conf.channel->band;
        u8 *pos;
 
@@ -1823,9 +1849,6 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
                        memcpy(skb_put(skb, beacon->head_len), beacon->head,
                               beacon->head_len);
 
-                       ieee80211_include_sequence(sdata,
-                                       (struct ieee80211_hdr *)skb->data);
-
                        /*
                         * Not very nice, but we want to allow the driver to call
                         * ieee80211_beacon_get() as a response to the set_tim()
@@ -1848,9 +1871,24 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
                                       beacon->tail, beacon->tail_len);
 
                        num_beacons = &ap->num_beacons;
+               } else
+                       goto out;
+       } else if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS) {
+               struct ieee80211_hdr *hdr;
+               ifsta = &sdata->u.sta;
 
-                       err = false;
-               }
+               if (!ifsta->probe_resp)
+                       goto out;
+
+               skb = skb_copy(ifsta->probe_resp, GFP_ATOMIC);
+               if (!skb)
+                       goto out;
+
+               hdr = (struct ieee80211_hdr *) skb->data;
+               hdr->frame_control = IEEE80211_FC(IEEE80211_FTYPE_MGMT,
+                                                 IEEE80211_STYPE_BEACON);
+
+               num_beacons = &ifsta->num_beacons;
        } else if (ieee80211_vif_is_mesh(&sdata->vif)) {
                /* headroom, head length, tail length and maximum TIM length */
                skb = dev_alloc_skb(local->tx_headroom + 400);
@@ -1861,8 +1899,8 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
                mgmt = (struct ieee80211_mgmt *)
                        skb_put(skb, 24 + sizeof(mgmt->u.beacon));
                memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon));
-               mgmt->frame_control = IEEE80211_FC(IEEE80211_FTYPE_MGMT,
-                                                  IEEE80211_STYPE_BEACON);
+               mgmt->frame_control =
+                   cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
                memset(mgmt->da, 0xff, ETH_ALEN);
                memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN);
                /* BSSID is left zeroed, wildcard value */
@@ -1877,17 +1915,8 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
                mesh_mgmt_ies_add(skb, sdata->dev);
 
                num_beacons = &sdata->u.sta.num_beacons;
-
-               err = false;
-       }
-
-       if (err) {
-#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
-               if (net_ratelimit())
-                       printk(KERN_DEBUG "no beacon data avail for %s\n",
-                              bdev->name);
-#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
-               skb = NULL;
+       } else {
+               WARN_ON(1);
                goto out;
        }
 
@@ -1909,14 +1938,18 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
 
        info->control.vif = vif;
        info->tx_rate_idx = rsel.rate_idx;
+
+       info->flags |= IEEE80211_TX_CTL_NO_ACK;
+       info->flags |= IEEE80211_TX_CTL_DO_NOT_ENCRYPT;
+       info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT;
+       info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ;
        if (sdata->bss_conf.use_short_preamble &&
            sband->bitrates[rsel.rate_idx].flags & IEEE80211_RATE_SHORT_PREAMBLE)
                info->flags |= IEEE80211_TX_CTL_SHORT_PREAMBLE;
+
        info->antenna_sel_tx = local->hw.conf.antenna_sel_tx;
-       info->flags |= IEEE80211_TX_CTL_NO_ACK;
-       info->flags |= IEEE80211_TX_CTL_DO_NOT_ENCRYPT;
        info->control.retry_limit = 1;
-       info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT;
+
        (*num_beacons)++;
 out:
        rcu_read_unlock();
@@ -1930,10 +1963,9 @@ void ieee80211_rts_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
                       struct ieee80211_rts *rts)
 {
        const struct ieee80211_hdr *hdr = frame;
-       u16 fctl;
 
-       fctl = IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS;
-       rts->frame_control = cpu_to_le16(fctl);
+       rts->frame_control =
+           cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS);
        rts->duration = ieee80211_rts_duration(hw, vif, frame_len,
                                               frame_txctl);
        memcpy(rts->ra, hdr->addr1, sizeof(rts->ra));
@@ -1947,10 +1979,9 @@ void ieee80211_ctstoself_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
                             struct ieee80211_cts *cts)
 {
        const struct ieee80211_hdr *hdr = frame;
-       u16 fctl;
 
-       fctl = IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS;
-       cts->frame_control = cpu_to_le16(fctl);
+       cts->frame_control =
+           cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS);
        cts->duration = ieee80211_ctstoself_duration(hw, vif,
                                                     frame_len, frame_txctl);
        memcpy(cts->ra, hdr->addr1, sizeof(cts->ra));