mac80211: Use IWEVASSOCREQIE instead of IWEVCUSTOM
[safe/jmp/linux-2.6] / net / mac80211 / tx.c
index 52ab85c..4788f7b 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)
@@ -220,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
@@ -274,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_hdrlen(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
@@ -303,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);
@@ -327,8 +305,10 @@ static void purge_old_ps_buffers(struct ieee80211_local *local)
        rcu_read_unlock();
 
        local->total_ps_buffered = total;
+#ifdef CONFIG_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
@@ -344,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 */
@@ -358,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 CONFIG_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++;
@@ -403,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 CONFIG_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++;
@@ -432,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))
@@ -444,21 +432,21 @@ 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;
        struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
        u16 fc = tx->fc;
 
-       if (unlikely(info->flags & IEEE80211_TX_CTL_DO_NOT_ENCRYPT))
+       if (unlikely(tx->skb->do_not_encrypt))
                tx->key = NULL;
        else if (tx->sta && (key = rcu_dereference(tx->sta->key)))
                tx->key = key;
        else if ((key = rcu_dereference(tx->sdata->default_key)))
                tx->key = key;
        else if (tx->sdata->drop_unencrypted &&
-                !(info->flags & IEEE80211_TX_CTL_EAPOL_FRAME) &&
+                (tx->skb->protocol != cpu_to_be16(ETH_P_PAE)) &&
                 !(info->flags & IEEE80211_TX_CTL_INJECTED)) {
                I802_DEBUG_INC(tx->local->tx_handlers_drop_unencrypted);
                return TX_DROP;
@@ -488,12 +476,12 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
        }
 
        if (!tx->key || !(tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
-               info->flags |= IEEE80211_TX_CTL_DO_NOT_ENCRYPT;
+               tx->skb->do_not_encrypt = 1;
 
        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;
@@ -537,7 +525,7 @@ 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;
@@ -632,7 +620,50 @@ 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;
@@ -701,6 +732,7 @@ ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx)
                memcpy(skb_put(frag, copylen), pos, copylen);
                memcpy(frag->cb, first->cb, sizeof(frag->cb));
                skb_copy_queue_mapping(frag, first);
+               frag->do_not_encrypt = first->do_not_encrypt;
 
                pos += copylen;
                left -= copylen;
@@ -713,7 +745,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])
@@ -724,7 +755,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)
@@ -744,7 +775,7 @@ 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;
@@ -774,7 +805,7 @@ ieee80211_tx_h_calculate_duration(struct ieee80211_tx_data *tx)
        return TX_CONTINUE;
 }
 
-static ieee80211_tx_result
+static ieee80211_tx_result debug_noinline
 ieee80211_tx_h_stats(struct ieee80211_tx_data *tx)
 {
        int i;
@@ -795,24 +826,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_calculate_duration,
-       ieee80211_tx_h_stats,
-       NULL
-};
-
 /* actual transmit path */
 
 /*
@@ -840,7 +853,7 @@ __ieee80211_parse_tx_radiotap(struct ieee80211_tx_data *tx,
 
        sband = tx->local->hw.wiphy->bands[tx->channel->band];
 
-       info->flags |= IEEE80211_TX_CTL_DO_NOT_ENCRYPT;
+       skb->do_not_encrypt = 1;
        info->flags |= IEEE80211_TX_CTL_INJECTED;
        tx->flags &= ~IEEE80211_TX_FRAGMENTED;
 
@@ -913,8 +926,7 @@ __ieee80211_parse_tx_radiotap(struct ieee80211_tx_data *tx,
                                skb_trim(skb, skb->len - FCS_LEN);
                        }
                        if (*iterator.this_arg & IEEE80211_RADIOTAP_F_WEP)
-                               info->flags &=
-                                       ~IEEE80211_TX_CTL_DO_NOT_ENCRYPT;
+                               tx->skb->do_not_encrypt = 0;
                        if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FRAG)
                                tx->flags |= IEEE80211_TX_FRAGMENTED;
                        break;
@@ -1030,10 +1042,9 @@ static int ieee80211_tx_prepare(struct ieee80211_tx_data *tx,
                                struct sk_buff *skb,
                                struct net_device *mdev)
 {
-       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
        struct net_device *dev;
 
-       dev = dev_get_by_index(&init_net, info->control.ifindex);
+       dev = dev_get_by_index(&init_net, skb->iif);
        if (unlikely(dev && !is_ieee80211_device(dev, mdev))) {
                dev_put(dev);
                dev = NULL;
@@ -1049,13 +1060,14 @@ static int ieee80211_tx_prepare(struct ieee80211_tx_data *tx,
 static int __ieee80211_tx(struct ieee80211_local *local, struct sk_buff *skb,
                          struct ieee80211_tx_data *tx)
 {
-       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+       struct ieee80211_tx_info *info;
        int ret, i;
 
-       if (netif_subqueue_stopped(local->mdev, skb))
-               return IEEE80211_TX_AGAIN;
-
        if (skb) {
+               if (netif_subqueue_stopped(local->mdev, skb))
+                       return IEEE80211_TX_AGAIN;
+               info =  IEEE80211_SKB_CB(skb);
+
                ieee80211_dump_frame(wiphy_name(local->hw.wiphy),
                                     "TX to low-level driver", skb);
                ret = local->ops->tx(local_to_hw(local), skb);
@@ -1110,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])
@@ -1131,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;
        }
 
@@ -1192,6 +1216,7 @@ retry:
 
                if (ret == IEEE80211_TX_FRAG_AGAIN)
                        skb = NULL;
+
                set_bit(queue, local->queues_pending);
                smp_mb();
                /*
@@ -1276,14 +1301,15 @@ int ieee80211_master_start_xmit(struct sk_buff *skb,
                                struct net_device *dev)
 {
        struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
        struct net_device *odev = NULL;
        struct ieee80211_sub_if_data *osdata;
        int headroom;
        bool may_encrypt;
        int ret;
 
-       if (info->control.ifindex)
-               odev = dev_get_by_index(&init_net, info->control.ifindex);
+       if (skb->iif)
+               odev = dev_get_by_index(&init_net, skb->iif);
        if (unlikely(odev && !is_ieee80211_device(odev, dev))) {
                dev_put(odev);
                odev = NULL;
@@ -1297,9 +1323,27 @@ int ieee80211_master_start_xmit(struct sk_buff *skb,
                return 0;
        }
 
+       memset(info, 0, sizeof(*info));
+
+       info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS;
+
        osdata = IEEE80211_DEV_TO_SUB_IF(odev);
 
-       may_encrypt = !(info->flags & IEEE80211_TX_CTL_DO_NOT_ENCRYPT);
+       if (ieee80211_vif_is_mesh(&osdata->vif) &&
+           ieee80211_is_data(hdr->frame_control)) {
+               if (ieee80211_is_data(hdr->frame_control)) {
+                       if (is_multicast_ether_addr(hdr->addr3))
+                               memcpy(hdr->addr1, hdr->addr3, ETH_ALEN);
+                       else
+                               if (mesh_nexthop_lookup(skb, odev))
+                                       return  0;
+                       if (memcmp(odev->dev_addr, hdr->addr4, ETH_ALEN) != 0)
+                               IEEE80211_IFSTA_MESH_CTR_INC(&osdata->u.sta,
+                                                            fwded_frames);
+               }
+       }
+
+       may_encrypt = !skb->do_not_encrypt;
 
        headroom = osdata->local->tx_headroom;
        if (may_encrypt)
@@ -1324,7 +1368,6 @@ int ieee80211_monitor_start_xmit(struct sk_buff *skb,
                                 struct net_device *dev)
 {
        struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
-       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
        struct ieee80211_radiotap_header *prthdr =
                (struct ieee80211_radiotap_header *)skb->data;
        u16 len_rthdr;
@@ -1347,11 +1390,11 @@ int ieee80211_monitor_start_xmit(struct sk_buff *skb,
        skb->dev = local->mdev;
 
        /* needed because we set skb device to master */
-       info->control.ifindex = dev->ifindex;
+       skb->iif = dev->ifindex;
 
-       info->flags |= IEEE80211_TX_CTL_DO_NOT_ENCRYPT;
-       /* Interfaces should always request a status report */
-       info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS;
+       /* sometimes we do encrypt injected frames, will be fixed
+        * up in radiotap parser if not wanted */
+       skb->do_not_encrypt = 0;
 
        /*
         * fix up the pointers accounting for the radiotap
@@ -1395,7 +1438,6 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
                               struct net_device *dev)
 {
        struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
-       struct ieee80211_tx_info *info;
        struct ieee80211_sub_if_data *sdata;
        int ret = 1, head_need;
        u16 ethertype, hdrlen,  meshhdrlen = 0;
@@ -1410,8 +1452,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;
        }
@@ -1447,30 +1487,17 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
        case IEEE80211_IF_TYPE_MESH_POINT:
                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);
-               else if (mesh_nexthop_lookup(hdr.addr1, skb, dev))
-                               return 0;
+               memset(hdr.addr1, 0, ETH_ALEN);
                memcpy(hdr.addr2, dev->dev_addr, ETH_ALEN);
                memcpy(hdr.addr3, skb->data, ETH_ALEN);
                memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN);
-               if (skb->pkt_type == PACKET_OTHERHOST) {
-                       /* Forwarded frame, keep mesh ttl and seqnum */
-                       struct ieee80211s_hdr *prev_meshhdr;
-                       prev_meshhdr = ((struct ieee80211s_hdr *)skb->cb);
-                       meshhdrlen = ieee80211_get_mesh_hdrlen(prev_meshhdr);
-                       memcpy(&mesh_hdr, prev_meshhdr, meshhdrlen);
-                       sdata->u.sta.mshstats.fwded_frames++;
-               } else {
-                       if (!sdata->u.sta.mshcfg.dot11MeshTTL) {
-                               /* Do not send frames with mesh_ttl == 0 */
-                               sdata->u.sta.mshstats.dropped_frames_ttl++;
-                               ret = 0;
-                               goto fail;
-                       }
-                       meshhdrlen = ieee80211_new_mesh_header(&mesh_hdr,
-                                                              sdata);
+               if (!sdata->u.sta.mshcfg.dot11MeshTTL) {
+                       /* Do not send frames with mesh_ttl == 0 */
+                       sdata->u.sta.mshstats.dropped_frames_ttl++;
+                       ret = 0;
+                       goto fail;
                }
+               meshhdrlen = ieee80211_new_mesh_header(&mesh_hdr, sdata);
                hdrlen = 30;
                break;
 #endif
@@ -1518,7 +1545,8 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
         * Drop unicast frames to unauthorised stations unless they are
         * EAPOL frames from the local station.
         */
-       if (unlikely(!is_multicast_ether_addr(hdr.addr1) &&
+       if (!ieee80211_vif_is_mesh(&sdata->vif) &&
+               unlikely(!is_multicast_ether_addr(hdr.addr1) &&
                      !(sta_flags & WLAN_STA_AUTHORIZED) &&
                      !(ethertype == ETH_P_PAE &&
                       compare_ether_addr(dev->dev_addr,
@@ -1623,14 +1651,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
        nh_pos += hdrlen;
        h_pos += hdrlen;
 
-       info = IEEE80211_SKB_CB(skb);
-       memset(info, 0, sizeof(*info));
-       info->control.ifindex = dev->ifindex;
-       if (ethertype == ETH_P_PAE)
-               info->flags |= IEEE80211_TX_CTL_EAPOL_FRAME;
-
-       /* Interfaces should always request a status report */
-       info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS;
+       skb->iif = dev->ifindex;
 
        skb->dev = local->mdev;
        dev->stats.tx_packets++;
@@ -1692,14 +1713,19 @@ void ieee80211_tx_pending(unsigned long data)
        netif_tx_lock_bh(dev);
        for (i = 0; i < ieee80211_num_regular_queues(&local->hw); i++) {
                /* Check that this queue is ok */
-               if (__netif_subqueue_stopped(local->mdev, i))
+               if (__netif_subqueue_stopped(local->mdev, i) &&
+                   !test_bit(i, local->queues_pending_run))
                        continue;
 
                if (!test_bit(i, local->queues_pending)) {
+                       clear_bit(i, local->queues_pending_run);
                        ieee80211_wake_queue(&local->hw, i);
                        continue;
                }
 
+               clear_bit(i, local->queues_pending_run);
+               netif_start_subqueue(local->mdev, i);
+
                store = &local->pending_packet[i];
                tx.extra_frag = store->extra_frag;
                tx.num_extra_frag = store->num_extra_frag;
@@ -1788,17 +1814,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;
 
@@ -1827,9 +1853,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()
@@ -1852,9 +1875,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);
@@ -1881,22 +1919,15 @@ 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;
        }
 
        info = IEEE80211_SKB_CB(skb);
 
+       skb->do_not_encrypt = 1;
+
        info->band = band;
        rate_control_get_rate(local->mdev, sband, skb, &rsel);
 
@@ -1906,21 +1937,24 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
                               "no rate found\n",
                               wiphy_name(local->hw.wiphy));
                }
-               dev_kfree_skb(skb);
+               dev_kfree_skb_any(skb);
                skb = NULL;
                goto out;
        }
 
        info->control.vif = vif;
        info->tx_rate_idx = rsel.rate_idx;
+
+       info->flags |= IEEE80211_TX_CTL_NO_ACK;
+       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();