Merge branch 'for-linville' of git://github.com/lucacoelho/wl12xx
[pandora-kernel.git] / net / mac80211 / status.c
index 1658efa..1426846 100644 (file)
@@ -127,12 +127,32 @@ static void ieee80211_handle_filtered_frame(struct ieee80211_local *local,
        dev_kfree_skb(skb);
 }
 
+static void ieee80211_check_pending_bar(struct sta_info *sta, u8 *addr, u8 tid)
+{
+       struct tid_ampdu_tx *tid_tx;
+
+       tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]);
+       if (!tid_tx || !tid_tx->bar_pending)
+               return;
+
+       tid_tx->bar_pending = false;
+       ieee80211_send_bar(&sta->sdata->vif, addr, tid, tid_tx->failed_bar_ssn);
+}
+
 static void ieee80211_frame_acked(struct sta_info *sta, struct sk_buff *skb)
 {
        struct ieee80211_mgmt *mgmt = (void *) skb->data;
        struct ieee80211_local *local = sta->local;
        struct ieee80211_sub_if_data *sdata = sta->sdata;
 
+       if (ieee80211_is_data_qos(mgmt->frame_control)) {
+               struct ieee80211_hdr *hdr = (void *) skb->data;
+               u8 *qc = ieee80211_get_qos_ctl(hdr);
+               u16 tid = qc[0] & 0xf;
+
+               ieee80211_check_pending_bar(sta, hdr->addr1, tid);
+       }
+
        if (ieee80211_is_action(mgmt->frame_control) &&
            sdata->vif.type == NL80211_IFTYPE_STATION &&
            mgmt->u.action.category == WLAN_CATEGORY_HT &&
@@ -161,6 +181,18 @@ static void ieee80211_frame_acked(struct sta_info *sta, struct sk_buff *skb)
        }
 }
 
+static void ieee80211_set_bar_pending(struct sta_info *sta, u8 tid, u16 ssn)
+{
+       struct tid_ampdu_tx *tid_tx;
+
+       tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]);
+       if (!tid_tx)
+               return;
+
+       tid_tx->failed_bar_ssn = ssn;
+       tid_tx->bar_pending = true;
+}
+
 /*
  * Use a static threshold for now, best value to be determined
  * by testing ...
@@ -187,6 +219,8 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
        int rates_idx = -1;
        bool send_to_cooked;
        bool acked;
+       struct ieee80211_bar *bar;
+       u16 tid;
 
        for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
                if (info->status.rates[i].idx < 0) {
@@ -239,10 +273,29 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
                        tid = qc[0] & 0xf;
                        ssn = ((le16_to_cpu(hdr->seq_ctrl) + 0x10)
                                                & IEEE80211_SCTL_SEQ);
-                       ieee80211_send_bar(sta->sdata, hdr->addr1,
+                       ieee80211_send_bar(&sta->sdata->vif, hdr->addr1,
                                           tid, ssn);
                }
 
+               if (!acked && ieee80211_is_back_req(fc)) {
+                       /*
+                        * BAR failed, let's tear down the BA session as a
+                        * last resort as some STAs (Intel 5100 on Windows)
+                        * can get stuck when the BA window isn't flushed
+                        * correctly.
+                        */
+                       bar = (struct ieee80211_bar *) skb->data;
+                       if (!(bar->control & IEEE80211_BAR_CTRL_MULTI_TID)) {
+                               u16 ssn = le16_to_cpu(bar->start_seq_num);
+
+                               tid = (bar->control &
+                                      IEEE80211_BAR_CTRL_TID_INFO_MASK) >>
+                                     IEEE80211_BAR_CTRL_TID_INFO_SHIFT;
+
+                               ieee80211_set_bar_pending(sta, tid, ssn);
+                       }
+               }
+
                if (info->flags & IEEE80211_TX_STAT_TX_FILTERED) {
                        ieee80211_handle_filtered_frame(local, sta, skb);
                        rcu_read_unlock();
@@ -345,9 +398,6 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
                        local->hw_roc_skb_for_status = NULL;
                }
 
-               if (cookie == local->hw_offchan_tx_cookie)
-                       local->hw_offchan_tx_cookie = 0;
-
                cfg80211_mgmt_tx_status(
                        skb->dev, cookie, skb->data, skb->len,
                        !!(info->flags & IEEE80211_TX_STAT_ACK), GFP_ATOMIC);