mac80211: minstrel_ht A-MPDU fix
[pandora-kernel.git] / net / mac80211 / rc80211_minstrel_ht.c
index c23f082..2a18d66 100644 (file)
@@ -240,6 +240,7 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
                             MINSTREL_FRAC(3, 4)) || mr->probability > cur_prob) {
                                mg->max_prob_rate = index;
                                cur_prob = mr->probability;
+                               cur_prob_tp = mr->cur_tp;
                        }
 
                        if (mr->cur_tp > cur_tp) {
@@ -275,6 +276,7 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
                    minstrel_mcs_groups[group].streams == 1) {
                        mi->max_prob_rate = mg->max_prob_rate;
                        cur_prob = mr->cur_prob;
+                       cur_prob_tp = mr->cur_tp;
                }
 
                mr = minstrel_get_ratestats(mi, mg->max_tp_rate);
@@ -328,7 +330,8 @@ minstrel_next_sample_idx(struct minstrel_ht_sta *mi)
 }
 
 static void
-minstrel_downgrade_rate(struct minstrel_ht_sta *mi, int *idx, bool primary)
+minstrel_downgrade_rate(struct minstrel_ht_sta *mi, unsigned int *idx,
+                       bool primary)
 {
        int group, orig_group;
 
@@ -365,7 +368,7 @@ minstrel_aggr_check(struct minstrel_priv *mp, struct ieee80211_sta *pubsta, stru
                return;
 
        tid = *ieee80211_get_qos_ctl(hdr) & IEEE80211_QOS_CTL_TID_MASK;
-       if (likely(sta->ampdu_mlme.tid_state_tx[tid] != HT_AGG_STATE_IDLE))
+       if (likely(sta->ampdu_mlme.tid_tx[tid]))
                return;
 
        ieee80211_start_tx_ba_session(pubsta, tid);
@@ -394,8 +397,9 @@ minstrel_ht_tx_status(void *priv, struct ieee80211_supported_band *sband,
            !(info->flags & IEEE80211_TX_STAT_AMPDU))
                return;
 
-       if (!info->status.ampdu_len) {
-               info->status.ampdu_ack_len = 1;
+       if (!(info->flags & IEEE80211_TX_STAT_AMPDU)) {
+               info->status.ampdu_ack_len =
+                       (info->flags & IEEE80211_TX_STAT_ACK ? 1 : 0);
                info->status.ampdu_len = 1;
        }
 
@@ -423,7 +427,7 @@ minstrel_ht_tx_status(void *priv, struct ieee80211_supported_band *sband,
                group = minstrel_ht_get_group_idx(&ar[i]);
                rate = &mi->groups[group].rates[ar[i].idx % 8];
 
-               if (last && (info->flags & IEEE80211_TX_STAT_ACK))
+               if (last)
                        rate->success += info->status.ampdu_ack_len;
 
                rate->attempts += ar[i].count * info->status.ampdu_len;
@@ -440,8 +444,8 @@ minstrel_ht_tx_status(void *priv, struct ieee80211_supported_band *sband,
                minstrel_downgrade_rate(mi, &mi->max_tp_rate, true);
 
        rate2 = minstrel_get_ratestats(mi, mi->max_tp_rate2);
-       if (rate->attempts > 30 &&
-           MINSTREL_FRAC(rate->success, rate->attempts) <
+       if (rate2->attempts > 30 &&
+           MINSTREL_FRAC(rate2->success, rate2->attempts) <
            MINSTREL_FRAC(20, 100))
                minstrel_downgrade_rate(mi, &mi->max_tp_rate2, false);
 
@@ -633,7 +637,7 @@ minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband,
        int i;
 
        /* fall back to the old minstrel for legacy stations */
-       if (sta && !sta->ht_cap.ht_supported) {
+       if (!sta->ht_cap.ht_supported) {
                msp->is_ht = false;
                memset(&msp->legacy, 0, sizeof(msp->legacy));
                msp->legacy.r = msp->ratelist;
@@ -745,7 +749,7 @@ minstrel_ht_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp)
        return msp;
 
 error1:
-       kfree(msp->sample_table);
+       kfree(msp->ratelist);
 error:
        kfree(msp);
        return NULL;