}
/*
-@@ -243,6 +246,7 @@ minstrel_ht_update_stats(struct minstrel
- struct minstrel_rate_stats *mr;
- int cur_prob, cur_prob_tp, cur_tp, cur_tp2;
- int group, i, index;
-+ int prob_max_streams = 1;
-
- if (mi->ampdu_packets > 0) {
- mi->avg_ampdu_len = minstrel_ewma(mi->avg_ampdu_len,
-@@ -308,8 +312,8 @@ minstrel_ht_update_stats(struct minstrel
+@@ -308,8 +311,8 @@ minstrel_ht_update_stats(struct minstrel
}
}
cur_prob = 0;
cur_prob_tp = 0;
-@@ -320,20 +324,13 @@ minstrel_ht_update_stats(struct minstrel
+@@ -320,20 +323,13 @@ minstrel_ht_update_stats(struct minstrel
if (!mg->supported)
continue;
cur_tp2 = cur_tp;
mi->max_tp_rate = mg->max_tp_rate;
cur_tp = mr->cur_tp;
-+ prob_max_streams = minstrel_mcs_groups[group].streams - 1;
++ mi->max_prob_streams = minstrel_mcs_groups[group].streams - 1;
}
mr = minstrel_get_ratestats(mi, mg->max_tp_rate2);
-@@ -343,6 +340,23 @@ minstrel_ht_update_stats(struct minstrel
+@@ -343,6 +339,23 @@ minstrel_ht_update_stats(struct minstrel
}
}
-+ if (prob_max_streams < 1)
-+ prob_max_streams = 1;
++ if (mi->max_prob_streams < 1)
++ mi->max_prob_streams = 1;
+
+ for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) {
+ mg = &mi->groups[group];
+ continue;
+ mr = minstrel_get_ratestats(mi, mg->max_prob_rate);
+ if (cur_prob_tp < mr->cur_tp &&
-+ minstrel_mcs_groups[group].streams <= prob_max_streams) {
++ minstrel_mcs_groups[group].streams <= mi->max_prob_streams) {
+ mi->max_prob_rate = mg->max_prob_rate;
+ cur_prob = mr->cur_prob;
+ cur_prob_tp = mr->cur_tp;
mi->stats_update = jiffies;
}
-@@ -536,7 +550,7 @@ minstrel_calc_retransmit(struct minstrel
+@@ -536,7 +549,7 @@ minstrel_calc_retransmit(struct minstrel
mr->retry_updated = true;
group = &minstrel_mcs_groups[index / MCS_GROUP_RATES];
/* Contention time for first 2 tries */
ctime = (t_slot * cw) >> 1;
+@@ -616,6 +629,7 @@ minstrel_get_sample_rate(struct minstrel
+ {
+ struct minstrel_rate_stats *mr;
+ struct minstrel_mcs_group_data *mg;
++ unsigned int sample_dur, sample_group;
+ int sample_idx = 0;
+
+ if (mi->sample_wait > 0) {
+@@ -626,11 +640,11 @@ minstrel_get_sample_rate(struct minstrel
+ if (!mi->sample_tries)
+ return -1;
+
+- mi->sample_tries--;
+ mg = &mi->groups[mi->sample_group];
+ sample_idx = sample_table[mg->column][mg->index];
+ mr = &mg->rates[sample_idx];
+- sample_idx += mi->sample_group * MCS_GROUP_RATES;
++ sample_group = mi->sample_group;
++ sample_idx += sample_group * MCS_GROUP_RATES;
+ minstrel_next_sample_idx(mi);
+
+ /*
+@@ -651,14 +665,18 @@ minstrel_get_sample_rate(struct minstrel
+ * Make sure that lower rates get sampled only occasionally,
+ * if the link is working perfectly.
+ */
+- if (minstrel_get_duration(sample_idx) >
+- minstrel_get_duration(mi->max_tp_rate)) {
++ sample_dur = minstrel_get_duration(sample_idx);
++ if (sample_dur >= minstrel_get_duration(mi->max_tp_rate2) &&
++ (mi->max_prob_streams <
++ minstrel_mcs_groups[sample_group].streams ||
++ sample_dur >= minstrel_get_duration(mi->max_prob_rate))) {
+ if (mr->sample_skipped < 20)
+ return -1;
+
+ if (mi->sample_slow++ > 2)
+ return -1;
+ }
++ mi->sample_tries--;
+
+ return sample_idx;
+ }
+--- a/net/mac80211/rc80211_minstrel_ht.h
++++ b/net/mac80211/rc80211_minstrel_ht.h
+@@ -85,6 +85,7 @@ struct minstrel_ht_sta {
+
+ /* best probability rate */
+ unsigned int max_prob_rate;
++ unsigned int max_prob_streams;
+
+ /* time of last status update */
+ unsigned long stats_update;