mac80211: use multi-queue master netdevice
[deliverable/linux.git] / net / mac80211 / tx.c
index 1d7dd54aacef31120fa744bef928bd7075ad72c2..9273651d3d7c939a37e1002e4ce12d5f82009c69 100644 (file)
@@ -91,11 +91,12 @@ static u16 ieee80211_duration(struct ieee80211_tx_data *tx, int group_addr,
                              int next_frag_len)
 {
        int rate, mrate, erp, dur, i;
-       struct ieee80211_rate *txrate = tx->rate;
+       struct ieee80211_rate *txrate;
        struct ieee80211_local *local = tx->local;
        struct ieee80211_supported_band *sband;
 
-       sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
+       sband = local->hw.wiphy->bands[tx->channel->band];
+       txrate = &sband->bitrates[tx->rate_idx];
 
        erp = 0;
        if (tx->sdata->flags & IEEE80211_SDATA_OPERATING_GMODE)
@@ -212,18 +213,6 @@ static u16 ieee80211_duration(struct ieee80211_tx_data *tx, int group_addr,
        return dur;
 }
 
-static inline int __ieee80211_queue_stopped(const struct ieee80211_local *local,
-                                           int queue)
-{
-       return test_bit(IEEE80211_LINK_STATE_XOFF, &local->state[queue]);
-}
-
-static inline int __ieee80211_queue_pending(const struct ieee80211_local *local,
-                                           int queue)
-{
-       return test_bit(IEEE80211_LINK_STATE_PENDING, &local->state[queue]);
-}
-
 static int inline is_ieee80211_device(struct net_device *dev,
                                      struct net_device *master)
 {
@@ -237,12 +226,12 @@ static ieee80211_tx_result
 ieee80211_tx_h_check_assoc(struct ieee80211_tx_data *tx)
 {
 #ifdef CONFIG_MAC80211_VERBOSE_DEBUG
-       struct sk_buff *skb = tx->skb;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
 #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
+       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
        u32 sta_flags;
 
-       if (unlikely(tx->flags & IEEE80211_TX_INJECTED))
+       if (unlikely(info->flags & IEEE80211_TX_CTL_INJECTED))
                return TX_CONTINUE;
 
        if (unlikely(tx->local->sta_sw_scanning) &&
@@ -256,7 +245,7 @@ ieee80211_tx_h_check_assoc(struct ieee80211_tx_data *tx)
        if (tx->flags & IEEE80211_TX_PS_BUFFERED)
                return TX_CONTINUE;
 
-       sta_flags = tx->sta ? tx->sta->flags : 0;
+       sta_flags = tx->sta ? get_sta_flags(tx->sta) : 0;
 
        if (likely(tx->flags & IEEE80211_TX_UNICAST)) {
                if (unlikely(!(sta_flags & WLAN_STA_ASSOC) &&
@@ -347,6 +336,8 @@ static void purge_old_ps_buffers(struct ieee80211_local *local)
 static ieee80211_tx_result
 ieee80211_tx_h_multicast_ps_buf(struct ieee80211_tx_data *tx)
 {
+       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
+
        /*
         * broadcast/multicast frame
         *
@@ -382,7 +373,7 @@ ieee80211_tx_h_multicast_ps_buf(struct ieee80211_tx_data *tx)
        }
 
        /* buffered in hardware */
-       tx->control->flags |= IEEE80211_TXCTL_SEND_AFTER_DTIM;
+       info->flags |= IEEE80211_TX_CTL_SEND_AFTER_DTIM;
 
        return TX_CONTINUE;
 }
@@ -391,6 +382,8 @@ static ieee80211_tx_result
 ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx)
 {
        struct sta_info *sta = tx->sta;
+       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
+       u32 staflags;
        DECLARE_MAC_BUF(mac);
 
        if (unlikely(!sta ||
@@ -398,9 +391,10 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx)
                      (tx->fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PROBE_RESP)))
                return TX_CONTINUE;
 
-       if (unlikely((sta->flags & WLAN_STA_PS) &&
-                    !(sta->flags & WLAN_STA_PSPOLL))) {
-               struct ieee80211_tx_packet_data *pkt_data;
+       staflags = get_sta_flags(sta);
+
+       if (unlikely((staflags & WLAN_STA_PS) &&
+                    !(staflags & WLAN_STA_PSPOLL))) {
 #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
                printk(KERN_DEBUG "STA %s aid %d: PS buffer (entries "
                       "before %d)\n",
@@ -424,19 +418,18 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx)
                if (skb_queue_empty(&sta->ps_tx_buf))
                        sta_info_set_tim_bit(sta);
 
-               pkt_data = (struct ieee80211_tx_packet_data *)tx->skb->cb;
-               pkt_data->jiffies = jiffies;
+               info->control.jiffies = jiffies;
                skb_queue_tail(&sta->ps_tx_buf, tx->skb);
                return TX_QUEUED;
        }
 #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
-       else if (unlikely(sta->flags & WLAN_STA_PS)) {
+       else if (unlikely(test_sta_flags(sta, WLAN_STA_PS))) {
                printk(KERN_DEBUG "%s: STA %s in PS mode, but pspoll "
                       "set -> send frame\n", tx->dev->name,
                       print_mac(mac, sta->addr));
        }
 #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
-       sta->flags &= ~WLAN_STA_PSPOLL;
+       clear_sta_flags(sta, WLAN_STA_PSPOLL);
 
        return TX_CONTINUE;
 }
@@ -457,17 +450,18 @@ static ieee80211_tx_result
 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(tx->control->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT))
+       if (unlikely(info->flags & IEEE80211_TX_CTL_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 &&
-                !(tx->control->flags & IEEE80211_TXCTL_EAPOL_FRAME) &&
-                !(tx->flags & IEEE80211_TX_INJECTED)) {
+                !(info->flags & IEEE80211_TX_CTL_EAPOL_FRAME) &&
+                !(info->flags & IEEE80211_TX_CTL_INJECTED)) {
                I802_DEBUG_INC(tx->local->tx_handlers_drop_unencrypted);
                return TX_DROP;
        } else
@@ -496,7 +490,159 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
        }
 
        if (!tx->key || !(tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
-               tx->control->flags |= IEEE80211_TXCTL_DO_NOT_ENCRYPT;
+               info->flags |= IEEE80211_TX_CTL_DO_NOT_ENCRYPT;
+
+       return TX_CONTINUE;
+}
+
+static ieee80211_tx_result
+ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx)
+{
+       struct rate_selection rsel;
+       struct ieee80211_supported_band *sband;
+       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
+
+       sband = tx->local->hw.wiphy->bands[tx->channel->band];
+
+       if (likely(tx->rate_idx < 0)) {
+               rate_control_get_rate(tx->dev, sband, tx->skb, &rsel);
+               tx->rate_idx = rsel.rate_idx;
+               if (unlikely(rsel.probe_idx >= 0)) {
+                       info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
+                       tx->flags |= IEEE80211_TX_PROBE_LAST_FRAG;
+                       info->control.alt_retry_rate_idx = tx->rate_idx;
+                       tx->rate_idx = rsel.probe_idx;
+               } else
+                       info->control.alt_retry_rate_idx = -1;
+
+               if (unlikely(tx->rate_idx < 0))
+                       return TX_DROP;
+       } else
+               info->control.alt_retry_rate_idx = -1;
+
+       if (tx->sdata->bss_conf.use_cts_prot &&
+           (tx->flags & IEEE80211_TX_FRAGMENTED) && (rsel.nonerp_idx >= 0)) {
+               tx->last_frag_rate_idx = tx->rate_idx;
+               if (rsel.probe_idx >= 0)
+                       tx->flags &= ~IEEE80211_TX_PROBE_LAST_FRAG;
+               else
+                       tx->flags |= IEEE80211_TX_PROBE_LAST_FRAG;
+               tx->rate_idx = rsel.nonerp_idx;
+               info->tx_rate_idx = rsel.nonerp_idx;
+               info->flags &= ~IEEE80211_TX_CTL_RATE_CTRL_PROBE;
+       } else {
+               tx->last_frag_rate_idx = tx->rate_idx;
+               info->tx_rate_idx = tx->rate_idx;
+       }
+       info->tx_rate_idx = tx->rate_idx;
+
+       return TX_CONTINUE;
+}
+
+static ieee80211_tx_result
+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_tx_info *info = IEEE80211_SKB_CB(tx->skb);
+       struct ieee80211_supported_band *sband;
+
+       sband = tx->local->hw.wiphy->bands[tx->channel->band];
+
+       if (tx->sta)
+               info->control.aid = tx->sta->aid;
+
+       if (!info->control.retry_limit) {
+               if (!is_multicast_ether_addr(hdr->addr1)) {
+                       int len = min_t(int, tx->skb->len + FCS_LEN,
+                                       tx->local->fragmentation_threshold);
+                       if (len > tx->local->rts_threshold
+                           && tx->local->rts_threshold <
+                                               IEEE80211_MAX_RTS_THRESHOLD) {
+                               info->flags |= IEEE80211_TX_CTL_USE_RTS_CTS;
+                               info->flags |=
+                                       IEEE80211_TX_CTL_LONG_RETRY_LIMIT;
+                               info->control.retry_limit =
+                                       tx->local->long_retry_limit;
+                       } else {
+                               info->control.retry_limit =
+                                       tx->local->short_retry_limit;
+                       }
+               } else {
+                       info->control.retry_limit = 1;
+               }
+       }
+
+       if (tx->flags & IEEE80211_TX_FRAGMENTED) {
+               /* Do not use multiple retry rates when sending fragmented
+                * frames.
+                * TODO: The last fragment could still use multiple retry
+                * rates. */
+               info->control.alt_retry_rate_idx = -1;
+       }
+
+       /* Use CTS protection for unicast frames sent using extended rates if
+        * there are associated non-ERP stations and RTS/CTS is not configured
+        * for the frame. */
+       if ((tx->sdata->flags & IEEE80211_SDATA_OPERATING_GMODE) &&
+           (sband->bitrates[tx->rate_idx].flags & IEEE80211_RATE_ERP_G) &&
+           (tx->flags & IEEE80211_TX_UNICAST) &&
+           tx->sdata->bss_conf.use_cts_prot &&
+           !(info->flags & IEEE80211_TX_CTL_USE_RTS_CTS))
+               info->flags |= IEEE80211_TX_CTL_USE_CTS_PROTECT;
+
+       /* 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) &&
+           (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_supported_band *sband;
+               struct ieee80211_rate *rate;
+               s8 baserate = -1;
+               int idx;
+
+               sband = tx->local->hw.wiphy->bands[tx->channel->band];
+
+               /* Do not use multiple retry rates when using RTS/CTS */
+               info->control.alt_retry_rate_idx = -1;
+
+               /* Use min(data rate, max base rate) as CTS/RTS rate */
+               rate = &sband->bitrates[tx->rate_idx];
+
+               for (idx = 0; idx < sband->n_bitrates; idx++) {
+                       if (sband->bitrates[idx].bitrate > rate->bitrate)
+                               continue;
+                       if (tx->sdata->basic_rates & BIT(idx) &&
+                           (baserate < 0 ||
+                            (sband->bitrates[baserate].bitrate
+                             < sband->bitrates[idx].bitrate)))
+                               baserate = idx;
+               }
+
+               if (baserate >= 0)
+                       info->control.rts_cts_rate_idx = baserate;
+               else
+                       info->control.rts_cts_rate_idx = 0;
+       }
+
+       if (tx->sta)
+               info->control.aid = tx->sta->aid;
 
        return TX_CONTINUE;
 }
@@ -515,6 +661,17 @@ ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx)
        if (!(tx->flags & IEEE80211_TX_FRAGMENTED))
                return TX_CONTINUE;
 
+       /*
+        * Warn when submitting a fragmented A-MPDU frame and drop it.
+        * This is an error and needs to be fixed elsewhere, but when
+        * done needs to take care of monitor interfaces (injection)
+        * etc.
+        */
+       if (WARN_ON(tx->flags & IEEE80211_TX_CTL_AMPDU ||
+                   skb_get_queue_mapping(tx->skb) >=
+                       ieee80211_num_regular_queues(&tx->local->hw)))
+               return TX_DROP;
+
        first = tx->skb;
 
        hdrlen = ieee80211_get_hdrlen(tx->fc);
@@ -602,170 +759,18 @@ ieee80211_tx_h_encrypt(struct ieee80211_tx_data *tx)
 }
 
 static ieee80211_tx_result
-ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx)
-{
-       struct rate_selection rsel;
-       struct ieee80211_supported_band *sband;
-
-       sband = tx->local->hw.wiphy->bands[tx->local->hw.conf.channel->band];
-
-       if (likely(!tx->rate)) {
-               rate_control_get_rate(tx->dev, sband, tx->skb, &rsel);
-               tx->rate = rsel.rate;
-               if (unlikely(rsel.probe)) {
-                       tx->control->flags |=
-                               IEEE80211_TXCTL_RATE_CTRL_PROBE;
-                       tx->flags |= IEEE80211_TX_PROBE_LAST_FRAG;
-                       tx->control->alt_retry_rate = tx->rate;
-                       tx->rate = rsel.probe;
-               } else
-                       tx->control->alt_retry_rate = NULL;
-
-               if (!tx->rate)
-                       return TX_DROP;
-       } else
-               tx->control->alt_retry_rate = NULL;
-
-       if (tx->sdata->bss_conf.use_cts_prot &&
-           (tx->flags & IEEE80211_TX_FRAGMENTED) && rsel.nonerp) {
-               tx->last_frag_rate = tx->rate;
-               if (rsel.probe)
-                       tx->flags &= ~IEEE80211_TX_PROBE_LAST_FRAG;
-               else
-                       tx->flags |= IEEE80211_TX_PROBE_LAST_FRAG;
-               tx->rate = rsel.nonerp;
-               tx->control->tx_rate = rsel.nonerp;
-               tx->control->flags &= ~IEEE80211_TXCTL_RATE_CTRL_PROBE;
-       } else {
-               tx->last_frag_rate = tx->rate;
-               tx->control->tx_rate = tx->rate;
-       }
-       tx->control->tx_rate = tx->rate;
-
-       return TX_CONTINUE;
-}
-
-static ieee80211_tx_result
-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_tx_control *control = tx->control;
-
-       if (!control->retry_limit) {
-               if (!is_multicast_ether_addr(hdr->addr1)) {
-                       if (tx->skb->len + FCS_LEN > tx->local->rts_threshold
-                           && tx->local->rts_threshold <
-                                       IEEE80211_MAX_RTS_THRESHOLD) {
-                               control->flags |=
-                                       IEEE80211_TXCTL_USE_RTS_CTS;
-                               control->flags |=
-                                       IEEE80211_TXCTL_LONG_RETRY_LIMIT;
-                               control->retry_limit =
-                                       tx->local->long_retry_limit;
-                       } else {
-                               control->retry_limit =
-                                       tx->local->short_retry_limit;
-                       }
-               } else {
-                       control->retry_limit = 1;
-               }
-       }
-
-       if (tx->flags & IEEE80211_TX_FRAGMENTED) {
-               /* Do not use multiple retry rates when sending fragmented
-                * frames.
-                * TODO: The last fragment could still use multiple retry
-                * rates. */
-               control->alt_retry_rate = NULL;
-       }
-
-       /* Use CTS protection for unicast frames sent using extended rates if
-        * there are associated non-ERP stations and RTS/CTS is not configured
-        * for the frame. */
-       if ((tx->sdata->flags & IEEE80211_SDATA_OPERATING_GMODE) &&
-           (tx->rate->flags & IEEE80211_RATE_ERP_G) &&
-           (tx->flags & IEEE80211_TX_UNICAST) &&
-           tx->sdata->bss_conf.use_cts_prot &&
-           !(control->flags & IEEE80211_TXCTL_USE_RTS_CTS))
-               control->flags |= IEEE80211_TXCTL_USE_CTS_PROTECT;
-
-       /* 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) &&
-           (tx->rate->flags & IEEE80211_RATE_SHORT_PREAMBLE) &&
-           tx->sdata->bss_conf.use_short_preamble &&
-           (!tx->sta || (tx->sta->flags & WLAN_STA_SHORT_PREAMBLE))) {
-               tx->control->flags |= IEEE80211_TXCTL_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 ((control->flags & IEEE80211_TXCTL_USE_RTS_CTS) ||
-           (control->flags & IEEE80211_TXCTL_USE_CTS_PROTECT)) {
-               struct ieee80211_supported_band *sband;
-               struct ieee80211_rate *rate, *baserate;
-               int idx;
-
-               sband = tx->local->hw.wiphy->bands[
-                               tx->local->hw.conf.channel->band];
-
-               /* Do not use multiple retry rates when using RTS/CTS */
-               control->alt_retry_rate = NULL;
-
-               /* Use min(data rate, max base rate) as CTS/RTS rate */
-               rate = tx->rate;
-               baserate = NULL;
-
-               for (idx = 0; idx < sband->n_bitrates; idx++) {
-                       if (sband->bitrates[idx].bitrate > rate->bitrate)
-                               continue;
-                       if (tx->sdata->basic_rates & BIT(idx) &&
-                           (!baserate ||
-                            (baserate->bitrate < sband->bitrates[idx].bitrate)))
-                               baserate = &sband->bitrates[idx];
-               }
-
-               if (baserate)
-                       control->rts_cts_rate = baserate;
-               else
-                       control->rts_cts_rate = &sband->bitrates[0];
-       }
-
-       if (tx->sta) {
-               control->aid = tx->sta->aid;
-               tx->sta->tx_packets++;
-               tx->sta->tx_fragments++;
-               tx->sta->tx_bytes += tx->skb->len;
-               if (tx->extra_frag) {
-                       int i;
-                       tx->sta->tx_fragments += tx->num_extra_frag;
-                       for (i = 0; i < tx->num_extra_frag; i++) {
-                               tx->sta->tx_bytes +=
-                                       tx->extra_frag[i]->len;
-                       }
-               }
-       }
-
-       return TX_CONTINUE;
-}
-
-static ieee80211_tx_result
-ieee80211_tx_h_load_stats(struct ieee80211_tx_data *tx)
+ieee80211_tx_h_stats(struct ieee80211_tx_data *tx)
 {
        struct ieee80211_local *local = tx->local;
        struct sk_buff *skb = tx->skb;
        struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
        u32 load = 0, hdrtime;
-       struct ieee80211_rate *rate = tx->rate;
+       struct ieee80211_rate *rate;
+       struct ieee80211_supported_band *sband;
+       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+
+       sband = tx->local->hw.wiphy->bands[tx->channel->band];
+       rate = &sband->bitrates[tx->rate_idx];
 
        /* TODO: this could be part of tx_status handling, so that the number
         * of retries would be known; TX rate should in that case be stored
@@ -787,9 +792,9 @@ ieee80211_tx_h_load_stats(struct ieee80211_tx_data *tx)
        if (!is_multicast_ether_addr(hdr->addr1))
                load += hdrtime;
 
-       if (tx->control->flags & IEEE80211_TXCTL_USE_RTS_CTS)
+       if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS)
                load += 2 * hdrtime;
-       else if (tx->control->flags & IEEE80211_TXCTL_USE_CTS_PROTECT)
+       else if (info->flags & IEEE80211_TX_CTL_USE_CTS_PROTECT)
                load += hdrtime;
 
        /* TODO: optimise again */
@@ -800,7 +805,7 @@ ieee80211_tx_h_load_stats(struct ieee80211_tx_data *tx)
                for (i = 0; i < tx->num_extra_frag; i++) {
                        load += 2 * hdrtime;
                        load += tx->extra_frag[i]->len *
-                               tx->rate->bitrate;
+                               rate->bitrate;
                }
        }
 
@@ -811,6 +816,20 @@ ieee80211_tx_h_load_stats(struct ieee80211_tx_data *tx)
                tx->sta->channel_use_raw += load;
        tx->sdata->channel_use_raw += load;
 
+       if (tx->sta) {
+               tx->sta->tx_packets++;
+               tx->sta->tx_fragments++;
+               tx->sta->tx_bytes += tx->skb->len;
+               if (tx->extra_frag) {
+                       int i;
+                       tx->sta->tx_fragments += tx->num_extra_frag;
+                       for (i = 0; i < tx->num_extra_frag; i++) {
+                               tx->sta->tx_bytes +=
+                                       tx->extra_frag[i]->len;
+                       }
+               }
+       }
+
        return TX_CONTINUE;
 }
 
@@ -823,11 +842,12 @@ static ieee80211_tx_handler ieee80211_tx_handlers[] =
        ieee80211_tx_h_ps_buf,
        ieee80211_tx_h_select_key,
        ieee80211_tx_h_michael_mic_add,
-       ieee80211_tx_h_fragment,
-       ieee80211_tx_h_encrypt,
        ieee80211_tx_h_rate_ctrl,
        ieee80211_tx_h_misc,
-       ieee80211_tx_h_load_stats,
+       ieee80211_tx_h_fragment,
+       /* handlers after fragment must be aware of tx info fragmentation! */
+       ieee80211_tx_h_encrypt,
+       ieee80211_tx_h_stats,
        NULL
 };
 
@@ -854,12 +874,12 @@ __ieee80211_parse_tx_radiotap(struct ieee80211_tx_data *tx,
                (struct ieee80211_radiotap_header *) skb->data;
        struct ieee80211_supported_band *sband;
        int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len);
-       struct ieee80211_tx_control *control = tx->control;
+       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
 
-       sband = tx->local->hw.wiphy->bands[tx->local->hw.conf.channel->band];
+       sband = tx->local->hw.wiphy->bands[tx->channel->band];
 
-       control->flags |= IEEE80211_TXCTL_DO_NOT_ENCRYPT;
-       tx->flags |= IEEE80211_TX_INJECTED;
+       info->flags |= IEEE80211_TX_CTL_DO_NOT_ENCRYPT;
+       info->flags |= IEEE80211_TX_CTL_INJECTED;
        tx->flags &= ~IEEE80211_TX_FRAGMENTED;
 
        /*
@@ -896,7 +916,7 @@ __ieee80211_parse_tx_radiotap(struct ieee80211_tx_data *tx,
                                r = &sband->bitrates[i];
 
                                if (r->bitrate == target_rate) {
-                                       tx->rate = r;
+                                       tx->rate_idx = i;
                                        break;
                                }
                        }
@@ -907,7 +927,7 @@ __ieee80211_parse_tx_radiotap(struct ieee80211_tx_data *tx,
                         * radiotap uses 0 for 1st ant, mac80211 is 1 for
                         * 1st ant
                         */
-                       control->antenna_sel_tx = (*iterator.this_arg) + 1;
+                       info->antenna_sel_tx = (*iterator.this_arg) + 1;
                        break;
 
 #if 0
@@ -931,8 +951,8 @@ __ieee80211_parse_tx_radiotap(struct ieee80211_tx_data *tx,
                                skb_trim(skb, skb->len - FCS_LEN);
                        }
                        if (*iterator.this_arg & IEEE80211_RADIOTAP_F_WEP)
-                               control->flags &=
-                                       ~IEEE80211_TXCTL_DO_NOT_ENCRYPT;
+                               info->flags &=
+                                       ~IEEE80211_TX_CTL_DO_NOT_ENCRYPT;
                        if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FRAG)
                                tx->flags |= IEEE80211_TX_FRAGMENTED;
                        break;
@@ -967,12 +987,12 @@ __ieee80211_parse_tx_radiotap(struct ieee80211_tx_data *tx,
 static ieee80211_tx_result
 __ieee80211_tx_prepare(struct ieee80211_tx_data *tx,
                       struct sk_buff *skb,
-                      struct net_device *dev,
-                      struct ieee80211_tx_control *control)
+                      struct net_device *dev)
 {
        struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
        struct ieee80211_hdr *hdr;
        struct ieee80211_sub_if_data *sdata;
+       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
 
        int hdrlen;
 
@@ -981,7 +1001,7 @@ __ieee80211_tx_prepare(struct ieee80211_tx_data *tx,
        tx->dev = dev; /* use original interface */
        tx->local = local;
        tx->sdata = IEEE80211_DEV_TO_SUB_IF(dev);
-       tx->control = control;
+       tx->channel = local->hw.conf.channel;
        /*
         * Set this flag (used below to indicate "automatic fragmentation"),
         * it will be cleared/left by radiotap as desired.
@@ -1008,10 +1028,10 @@ __ieee80211_tx_prepare(struct ieee80211_tx_data *tx,
 
        if (is_multicast_ether_addr(hdr->addr1)) {
                tx->flags &= ~IEEE80211_TX_UNICAST;
-               control->flags |= IEEE80211_TXCTL_NO_ACK;
+               info->flags |= IEEE80211_TX_CTL_NO_ACK;
        } else {
                tx->flags |= IEEE80211_TX_UNICAST;
-               control->flags &= ~IEEE80211_TXCTL_NO_ACK;
+               info->flags &= ~IEEE80211_TX_CTL_NO_ACK;
        }
 
        if (tx->flags & IEEE80211_TX_FRAGMENTED) {
@@ -1024,18 +1044,16 @@ __ieee80211_tx_prepare(struct ieee80211_tx_data *tx,
        }
 
        if (!tx->sta)
-               control->flags |= IEEE80211_TXCTL_CLEAR_PS_FILT;
-       else if (tx->sta->flags & WLAN_STA_CLEAR_PS_FILT) {
-               control->flags |= IEEE80211_TXCTL_CLEAR_PS_FILT;
-               tx->sta->flags &= ~WLAN_STA_CLEAR_PS_FILT;
-       }
+               info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT;
+       else if (test_and_clear_sta_flags(tx->sta, WLAN_STA_CLEAR_PS_FILT))
+               info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT;
 
        hdrlen = ieee80211_get_hdrlen(tx->fc);
        if (skb->len > hdrlen + sizeof(rfc1042_header) + 2) {
                u8 *pos = &skb->data[hdrlen + sizeof(rfc1042_header)];
                tx->ethertype = (pos[0] << 8) | pos[1];
        }
-       control->flags |= IEEE80211_TXCTL_FIRST_FRAGMENT;
+       info->flags |= IEEE80211_TX_CTL_FIRST_FRAGMENT;
 
        return TX_CONTINUE;
 }
@@ -1045,14 +1063,12 @@ __ieee80211_tx_prepare(struct ieee80211_tx_data *tx,
  */
 static int ieee80211_tx_prepare(struct ieee80211_tx_data *tx,
                                struct sk_buff *skb,
-                               struct net_device *mdev,
-                               struct ieee80211_tx_control *control)
+                               struct net_device *mdev)
 {
-       struct ieee80211_tx_packet_data *pkt_data;
+       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
        struct net_device *dev;
 
-       pkt_data = (struct ieee80211_tx_packet_data *)skb->cb;
-       dev = dev_get_by_index(&init_net, pkt_data->ifindex);
+       dev = dev_get_by_index(&init_net, info->control.ifindex);
        if (unlikely(dev && !is_ieee80211_device(dev, mdev))) {
                dev_put(dev);
                dev = NULL;
@@ -1060,7 +1076,7 @@ static int ieee80211_tx_prepare(struct ieee80211_tx_data *tx,
        if (unlikely(!dev))
                return -ENODEV;
        /* initialises tx with control */
-       __ieee80211_tx_prepare(tx, skb, dev, control);
+       __ieee80211_tx_prepare(tx, skb, dev);
        dev_put(dev);
        return 0;
 }
@@ -1068,50 +1084,49 @@ 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_control *control = tx->control;
+       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
        int ret, i;
 
-       if (!ieee80211_qdisc_installed(local->mdev) &&
-           __ieee80211_queue_stopped(local, 0)) {
-               netif_stop_queue(local->mdev);
+       if (netif_subqueue_stopped(local->mdev, skb))
                return IEEE80211_TX_AGAIN;
-       }
+
        if (skb) {
                ieee80211_dump_frame(wiphy_name(local->hw.wiphy),
                                     "TX to low-level driver", skb);
-               ret = local->ops->tx(local_to_hw(local), skb, control);
+               ret = local->ops->tx(local_to_hw(local), skb);
                if (ret)
                        return IEEE80211_TX_AGAIN;
                local->mdev->trans_start = jiffies;
                ieee80211_led_tx(local, 1);
        }
        if (tx->extra_frag) {
-               control->flags &= ~(IEEE80211_TXCTL_USE_RTS_CTS |
-                                   IEEE80211_TXCTL_USE_CTS_PROTECT |
-                                   IEEE80211_TXCTL_CLEAR_PS_FILT |
-                                   IEEE80211_TXCTL_FIRST_FRAGMENT);
                for (i = 0; i < tx->num_extra_frag; i++) {
                        if (!tx->extra_frag[i])
                                continue;
-                       if (__ieee80211_queue_stopped(local, control->queue))
+                       info = IEEE80211_SKB_CB(tx->extra_frag[i]);
+                       info->flags &= ~(IEEE80211_TX_CTL_USE_RTS_CTS |
+                                        IEEE80211_TX_CTL_USE_CTS_PROTECT |
+                                        IEEE80211_TX_CTL_CLEAR_PS_FILT |
+                                        IEEE80211_TX_CTL_FIRST_FRAGMENT);
+                       if (netif_subqueue_stopped(local->mdev,
+                                                  tx->extra_frag[i]))
                                return IEEE80211_TX_FRAG_AGAIN;
                        if (i == tx->num_extra_frag) {
-                               control->tx_rate = tx->last_frag_rate;
+                               info->tx_rate_idx = tx->last_frag_rate_idx;
 
                                if (tx->flags & IEEE80211_TX_PROBE_LAST_FRAG)
-                                       control->flags |=
-                                               IEEE80211_TXCTL_RATE_CTRL_PROBE;
+                                       info->flags |=
+                                               IEEE80211_TX_CTL_RATE_CTRL_PROBE;
                                else
-                                       control->flags &=
-                                               ~IEEE80211_TXCTL_RATE_CTRL_PROBE;
+                                       info->flags &=
+                                               ~IEEE80211_TX_CTL_RATE_CTRL_PROBE;
                        }
 
                        ieee80211_dump_frame(wiphy_name(local->hw.wiphy),
                                             "TX to low-level driver",
                                             tx->extra_frag[i]);
                        ret = local->ops->tx(local_to_hw(local),
-                                           tx->extra_frag[i],
-                                           control);
+                                           tx->extra_frag[i]);
                        if (ret)
                                return IEEE80211_TX_FRAG_AGAIN;
                        local->mdev->trans_start = jiffies;
@@ -1124,17 +1139,20 @@ static int __ieee80211_tx(struct ieee80211_local *local, struct sk_buff *skb,
        return IEEE80211_TX_OK;
 }
 
-static int ieee80211_tx(struct net_device *dev, struct sk_buff *skb,
-                       struct ieee80211_tx_control *control)
+static int ieee80211_tx(struct net_device *dev, struct sk_buff *skb)
 {
        struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
        struct sta_info *sta;
        ieee80211_tx_handler *handler;
        struct ieee80211_tx_data tx;
        ieee80211_tx_result res = TX_DROP, res_prepare;
+       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
        int ret, i;
+       u16 queue;
 
-       WARN_ON(__ieee80211_queue_pending(local, control->queue));
+       queue = skb_get_queue_mapping(skb);
+
+       WARN_ON(test_bit(queue, local->queues_pending));
 
        if (unlikely(skb->len < 10)) {
                dev_kfree_skb(skb);
@@ -1144,7 +1162,7 @@ static int ieee80211_tx(struct net_device *dev, struct sk_buff *skb,
        rcu_read_lock();
 
        /* initialises tx */
-       res_prepare = __ieee80211_tx_prepare(&tx, skb, dev, control);
+       res_prepare = __ieee80211_tx_prepare(&tx, skb, dev);
 
        if (res_prepare == TX_DROP) {
                dev_kfree_skb(skb);
@@ -1154,6 +1172,7 @@ static int ieee80211_tx(struct net_device *dev, struct sk_buff *skb,
 
        sta = tx.sta;
        tx.channel = local->hw.conf.channel;
+       info->band = tx.channel->band;
 
        for (handler = ieee80211_tx_handlers; *handler != NULL;
             handler++) {
@@ -1162,7 +1181,8 @@ static int ieee80211_tx(struct net_device *dev, struct sk_buff *skb,
                        break;
        }
 
-       skb = tx.skb; /* handlers are allowed to change skb */
+       if (WARN_ON(tx.skb != skb))
+               goto drop;
 
        if (unlikely(res == TX_DROP)) {
                I802_DEBUG_INC(local->tx_handlers_drop);
@@ -1186,7 +1206,7 @@ static int ieee80211_tx(struct net_device *dev, struct sk_buff *skb,
                                next_len = tx.extra_frag[i + 1]->len;
                        } else {
                                next_len = 0;
-                               tx.rate = tx.last_frag_rate;
+                               tx.rate_idx = tx.last_frag_rate_idx;
                        }
                        dur = ieee80211_duration(&tx, 0, next_len);
                        hdr->duration_id = cpu_to_le16(dur);
@@ -1196,34 +1216,41 @@ static int ieee80211_tx(struct net_device *dev, struct sk_buff *skb,
 retry:
        ret = __ieee80211_tx(local, skb, &tx);
        if (ret) {
-               struct ieee80211_tx_stored_packet *store =
-                       &local->pending_packet[control->queue];
+               struct ieee80211_tx_stored_packet *store;
+
+               /*
+                * Since there are no fragmented frames on A-MPDU
+                * queues, there's no reason for a driver to reject
+                * a frame there, warn and drop it.
+                */
+               if (WARN_ON(queue >= ieee80211_num_regular_queues(&local->hw)))
+                       goto drop;
+
+               store = &local->pending_packet[queue];
 
                if (ret == IEEE80211_TX_FRAG_AGAIN)
                        skb = NULL;
-               set_bit(IEEE80211_LINK_STATE_PENDING,
-                       &local->state[control->queue]);
+               set_bit(queue, local->queues_pending);
                smp_mb();
-               /* When the driver gets out of buffers during sending of
-                * fragments and calls ieee80211_stop_queue, there is
-                * a small window between IEEE80211_LINK_STATE_XOFF and
-                * IEEE80211_LINK_STATE_PENDING flags are set. If a buffer
+               /*
+                * When the driver gets out of buffers during sending of
+                * fragments and calls ieee80211_stop_queue, the netif
+                * subqueue is stopped. There is, however, a small window
+                * in which the PENDING bit is not yet set. If a buffer
                 * gets available in that window (i.e. driver calls
                 * ieee80211_wake_queue), we would end up with ieee80211_tx
-                * called with IEEE80211_LINK_STATE_PENDING. Prevent this by
+                * called with the PENDING bit still set. Prevent this by
                 * continuing transmitting here when that situation is
-                * possible to have happened. */
-               if (!__ieee80211_queue_stopped(local, control->queue)) {
-                       clear_bit(IEEE80211_LINK_STATE_PENDING,
-                                 &local->state[control->queue]);
+                * possible to have happened.
+                */
+               if (!__netif_subqueue_stopped(local->mdev, queue)) {
+                       clear_bit(queue, local->queues_pending);
                        goto retry;
                }
-               memcpy(&store->control, control,
-                      sizeof(struct ieee80211_tx_control));
                store->skb = skb;
                store->extra_frag = tx.extra_frag;
                store->num_extra_frag = tx.num_extra_frag;
-               store->last_frag_rate = tx.last_frag_rate;
+               store->last_frag_rate_idx = tx.last_frag_rate_idx;
                store->last_frag_rate_ctrl_probe =
                        !!(tx.flags & IEEE80211_TX_PROBE_LAST_FRAG);
        }
@@ -1246,21 +1273,14 @@ retry:
 int ieee80211_master_start_xmit(struct sk_buff *skb,
                                struct net_device *dev)
 {
-       struct ieee80211_tx_control control;
-       struct ieee80211_tx_packet_data *pkt_data;
+       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
        struct net_device *odev = NULL;
        struct ieee80211_sub_if_data *osdata;
        int headroom;
        int ret;
 
-       /*
-        * copy control out of the skb so other people can use skb->cb
-        */
-       pkt_data = (struct ieee80211_tx_packet_data *)skb->cb;
-       memset(&control, 0, sizeof(struct ieee80211_tx_control));
-
-       if (pkt_data->ifindex)
-               odev = dev_get_by_index(&init_net, pkt_data->ifindex);
+       if (info->control.ifindex)
+               odev = dev_get_by_index(&init_net, info->control.ifindex);
        if (unlikely(odev && !is_ieee80211_device(odev, dev))) {
                dev_put(odev);
                odev = NULL;
@@ -1273,6 +1293,7 @@ int ieee80211_master_start_xmit(struct sk_buff *skb,
                dev_kfree_skb(skb);
                return 0;
        }
+
        osdata = IEEE80211_DEV_TO_SUB_IF(odev);
 
        headroom = osdata->local->tx_headroom + IEEE80211_ENCRYPT_HEADROOM;
@@ -1284,21 +1305,8 @@ int ieee80211_master_start_xmit(struct sk_buff *skb,
                }
        }
 
-       control.vif = &osdata->vif;
-       control.type = osdata->vif.type;
-       if (pkt_data->flags & IEEE80211_TXPD_REQ_TX_STATUS)
-               control.flags |= IEEE80211_TXCTL_REQ_TX_STATUS;
-       if (pkt_data->flags & IEEE80211_TXPD_DO_NOT_ENCRYPT)
-               control.flags |= IEEE80211_TXCTL_DO_NOT_ENCRYPT;
-       if (pkt_data->flags & IEEE80211_TXPD_REQUEUE)
-               control.flags |= IEEE80211_TXCTL_REQUEUE;
-       if (pkt_data->flags & IEEE80211_TXPD_EAPOL_FRAME)
-               control.flags |= IEEE80211_TXCTL_EAPOL_FRAME;
-       if (pkt_data->flags & IEEE80211_TXPD_AMPDU)
-               control.flags |= IEEE80211_TXCTL_AMPDU;
-       control.queue = pkt_data->queue;
-
-       ret = ieee80211_tx(odev, skb, &control);
+       info->control.vif = &osdata->vif;
+       ret = ieee80211_tx(odev, skb);
        dev_put(odev);
 
        return ret;
@@ -1308,7 +1316,7 @@ 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_packet_data *pkt_data;
+       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
        struct ieee80211_radiotap_header *prthdr =
                (struct ieee80211_radiotap_header *)skb->data;
        u16 len_rthdr;
@@ -1330,12 +1338,12 @@ int ieee80211_monitor_start_xmit(struct sk_buff *skb,
 
        skb->dev = local->mdev;
 
-       pkt_data = (struct ieee80211_tx_packet_data *)skb->cb;
-       memset(pkt_data, 0, sizeof(*pkt_data));
        /* needed because we set skb device to master */
-       pkt_data->ifindex = dev->ifindex;
+       info->control.ifindex = dev->ifindex;
 
-       pkt_data->flags |= IEEE80211_TXPD_DO_NOT_ENCRYPT;
+       info->flags |= IEEE80211_TX_CTL_DO_NOT_ENCRYPT;
+       /* Interfaces should always request a status report */
+       info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS;
 
        /*
         * fix up the pointers accounting for the radiotap
@@ -1379,7 +1387,7 @@ 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_packet_data *pkt_data;
+       struct ieee80211_tx_info *info;
        struct ieee80211_sub_if_data *sdata;
        int ret = 1, head_need;
        u16 ethertype, hdrlen,  meshhdrlen = 0, fc;
@@ -1486,12 +1494,13 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
                rcu_read_lock();
                sta = sta_info_get(local, hdr.addr1);
                if (sta)
-                       sta_flags = sta->flags;
+                       sta_flags = get_sta_flags(sta);
                rcu_read_unlock();
        }
 
-       /* receiver is QoS enabled, use a QoS type frame */
-       if (sta_flags & WLAN_STA_WME) {
+       /* 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;
                hdrlen += 2;
        }
@@ -1611,11 +1620,14 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
        nh_pos += hdrlen;
        h_pos += hdrlen;
 
-       pkt_data = (struct ieee80211_tx_packet_data *)skb->cb;
-       memset(pkt_data, 0, sizeof(struct ieee80211_tx_packet_data));
-       pkt_data->ifindex = dev->ifindex;
+       info = IEEE80211_SKB_CB(skb);
+       memset(info, 0, sizeof(*info));
+       info->control.ifindex = dev->ifindex;
        if (ethertype == ETH_P_PAE)
-               pkt_data->flags |= IEEE80211_TXPD_EAPOL_FRAME;
+               info->flags |= IEEE80211_TX_CTL_EAPOL_FRAME;
+
+       /* Interfaces should always request a status report */
+       info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS;
 
        skb->dev = local->mdev;
        dev->stats.tx_packets++;
@@ -1640,46 +1652,55 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
        return ret;
 }
 
-/* helper functions for pending packets for when queues are stopped */
 
+/*
+ * ieee80211_clear_tx_pending may not be called in a context where
+ * it is possible that it packets could come in again.
+ */
 void ieee80211_clear_tx_pending(struct ieee80211_local *local)
 {
        int i, j;
        struct ieee80211_tx_stored_packet *store;
 
-       for (i = 0; i < local->hw.queues; i++) {
-               if (!__ieee80211_queue_pending(local, i))
+       for (i = 0; i < ieee80211_num_regular_queues(&local->hw); i++) {
+               if (!test_bit(i, local->queues_pending))
                        continue;
                store = &local->pending_packet[i];
                kfree_skb(store->skb);
                for (j = 0; j < store->num_extra_frag; j++)
                        kfree_skb(store->extra_frag[j]);
                kfree(store->extra_frag);
-               clear_bit(IEEE80211_LINK_STATE_PENDING, &local->state[i]);
+               clear_bit(i, local->queues_pending);
        }
 }
 
+/*
+ * Transmit all pending packets. Called from tasklet, locks master device
+ * TX lock so that no new packets can come in.
+ */
 void ieee80211_tx_pending(unsigned long data)
 {
        struct ieee80211_local *local = (struct ieee80211_local *)data;
        struct net_device *dev = local->mdev;
        struct ieee80211_tx_stored_packet *store;
        struct ieee80211_tx_data tx;
-       int i, ret, reschedule = 0;
+       int i, ret;
 
        netif_tx_lock_bh(dev);
-       for (i = 0; i < local->hw.queues; i++) {
-               if (__ieee80211_queue_stopped(local, i))
+       for (i = 0; i < ieee80211_num_regular_queues(&local->hw); i++) {
+               /* Check that this queue is ok */
+               if (__netif_subqueue_stopped(local->mdev, i))
                        continue;
-               if (!__ieee80211_queue_pending(local, i)) {
-                       reschedule = 1;
+
+               if (!test_bit(i, local->queues_pending)) {
+                       ieee80211_wake_queue(&local->hw, i);
                        continue;
                }
+
                store = &local->pending_packet[i];
-               tx.control = &store->control;
                tx.extra_frag = store->extra_frag;
                tx.num_extra_frag = store->num_extra_frag;
-               tx.last_frag_rate = store->last_frag_rate;
+               tx.last_frag_rate_idx = store->last_frag_rate_idx;
                tx.flags = 0;
                if (store->last_frag_rate_ctrl_probe)
                        tx.flags |= IEEE80211_TX_PROBE_LAST_FRAG;
@@ -1688,19 +1709,11 @@ void ieee80211_tx_pending(unsigned long data)
                        if (ret == IEEE80211_TX_FRAG_AGAIN)
                                store->skb = NULL;
                } else {
-                       clear_bit(IEEE80211_LINK_STATE_PENDING,
-                                 &local->state[i]);
-                       reschedule = 1;
+                       clear_bit(i, local->queues_pending);
+                       ieee80211_wake_queue(&local->hw, i);
                }
        }
        netif_tx_unlock_bh(dev);
-       if (reschedule) {
-               if (!ieee80211_qdisc_installed(dev)) {
-                       if (!__ieee80211_queue_stopped(local, 0))
-                               netif_wake_queue(dev);
-               } else
-                       netif_schedule(dev);
-       }
 }
 
 /* functions for drivers to get certain frames */
@@ -1769,11 +1782,11 @@ static void ieee80211_beacon_add_tim(struct ieee80211_local *local,
 }
 
 struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
-                                    struct ieee80211_vif *vif,
-                                    struct ieee80211_tx_control *control)
+                                    struct ieee80211_vif *vif)
 {
        struct ieee80211_local *local = hw_to_local(hw);
        struct sk_buff *skb;
+       struct ieee80211_tx_info *info;
        struct net_device *bdev;
        struct ieee80211_sub_if_data *sdata = NULL;
        struct ieee80211_if_ap *ap = NULL;
@@ -1783,9 +1796,10 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
        struct ieee80211_mgmt *mgmt;
        int *num_beacons;
        bool err = true;
+       enum ieee80211_band band = local->hw.conf.channel->band;
        u8 *pos;
 
-       sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
+       sband = local->hw.wiphy->bands[band];
 
        rcu_read_lock();
 
@@ -1878,30 +1892,32 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
                goto out;
        }
 
-       if (control) {
-               rate_control_get_rate(local->mdev, sband, skb, &rsel);
-               if (!rsel.rate) {
-                       if (net_ratelimit()) {
-                               printk(KERN_DEBUG "%s: ieee80211_beacon_get: "
-                                      "no rate found\n",
-                                      wiphy_name(local->hw.wiphy));
-                       }
-                       dev_kfree_skb(skb);
-                       skb = NULL;
-                       goto out;
-               }
+       info = IEEE80211_SKB_CB(skb);
+
+       info->band = band;
+       rate_control_get_rate(local->mdev, sband, skb, &rsel);
 
-               control->vif = vif;
-               control->tx_rate = rsel.rate;
-               if (sdata->bss_conf.use_short_preamble &&
-                   rsel.rate->flags & IEEE80211_RATE_SHORT_PREAMBLE)
-                       control->flags |= IEEE80211_TXCTL_SHORT_PREAMBLE;
-               control->antenna_sel_tx = local->hw.conf.antenna_sel_tx;
-               control->flags |= IEEE80211_TXCTL_NO_ACK;
-               control->flags |= IEEE80211_TXCTL_DO_NOT_ENCRYPT;
-               control->retry_limit = 1;
-               control->flags |= IEEE80211_TXCTL_CLEAR_PS_FILT;
+       if (unlikely(rsel.rate_idx < 0)) {
+               if (net_ratelimit()) {
+                       printk(KERN_DEBUG "%s: ieee80211_beacon_get: "
+                              "no rate found\n",
+                              wiphy_name(local->hw.wiphy));
+               }
+               dev_kfree_skb(skb);
+               skb = NULL;
+               goto out;
        }
+
+       info->control.vif = vif;
+       info->tx_rate_idx = rsel.rate_idx;
+       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();
@@ -1911,7 +1927,7 @@ EXPORT_SYMBOL(ieee80211_beacon_get);
 
 void ieee80211_rts_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
                       const void *frame, size_t frame_len,
-                      const struct ieee80211_tx_control *frame_txctl,
+                      const struct ieee80211_tx_info *frame_txctl,
                       struct ieee80211_rts *rts)
 {
        const struct ieee80211_hdr *hdr = frame;
@@ -1928,7 +1944,7 @@ EXPORT_SYMBOL(ieee80211_rts_get);
 
 void ieee80211_ctstoself_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
                             const void *frame, size_t frame_len,
-                            const struct ieee80211_tx_control *frame_txctl,
+                            const struct ieee80211_tx_info *frame_txctl,
                             struct ieee80211_cts *cts)
 {
        const struct ieee80211_hdr *hdr = frame;
@@ -1944,8 +1960,7 @@ EXPORT_SYMBOL(ieee80211_ctstoself_get);
 
 struct sk_buff *
 ieee80211_get_buffered_bc(struct ieee80211_hw *hw,
-                         struct ieee80211_vif *vif,
-                         struct ieee80211_tx_control *control)
+                         struct ieee80211_vif *vif)
 {
        struct ieee80211_local *local = hw_to_local(hw);
        struct sk_buff *skb;
@@ -1957,6 +1972,7 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw,
        struct ieee80211_sub_if_data *sdata;
        struct ieee80211_if_ap *bss = NULL;
        struct beacon_data *beacon;
+       struct ieee80211_tx_info *info;
 
        sdata = vif_to_sdata(vif);
        bdev = sdata->dev;
@@ -1976,7 +1992,7 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw,
 
        if (bss->dtim_count != 0)
                return NULL; /* send buffered bc/mc only after DTIM beacon */
-       memset(control, 0, sizeof(*control));
+
        while (1) {
                skb = skb_dequeue(&bss->ps_bc_buf);
                if (!skb)
@@ -1993,20 +2009,26 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw,
                                cpu_to_le16(IEEE80211_FCTL_MOREDATA);
                }
 
-               if (!ieee80211_tx_prepare(&tx, skb, local->mdev, control))
+               if (!ieee80211_tx_prepare(&tx, skb, local->mdev))
                        break;
                dev_kfree_skb_any(skb);
        }
+
+       info = IEEE80211_SKB_CB(skb);
+
        sta = tx.sta;
        tx.flags |= IEEE80211_TX_PS_BUFFERED;
        tx.channel = local->hw.conf.channel;
+       info->band = tx.channel->band;
 
        for (handler = ieee80211_tx_handlers; *handler != NULL; handler++) {
                res = (*handler)(&tx);
                if (res == TX_DROP || res == TX_QUEUED)
                        break;
        }
-       skb = tx.skb; /* handlers are allowed to change skb */
+
+       if (WARN_ON(tx.skb != skb))
+               return NULL;
 
        if (res == TX_DROP) {
                I802_DEBUG_INC(local->tx_handlers_drop);
This page took 0.040055 seconds and 5 git commands to generate.