1 --- a/net/mac80211/rc80211_minstrel_ht.h
2 +++ b/net/mac80211/rc80211_minstrel_ht.h
3 @@ -70,6 +70,8 @@ struct minstrel_mcs_group_data {
6 struct minstrel_ht_sta {
7 + struct ieee80211_tx_rate tx_rates[3];
9 /* ampdu length (average, per sampling interval) */
10 unsigned int ampdu_len;
11 unsigned int ampdu_packets;
12 --- a/net/mac80211/rc80211_minstrel_ht.c
13 +++ b/net/mac80211/rc80211_minstrel_ht.c
14 @@ -87,6 +87,10 @@ const struct mcs_group minstrel_mcs_grou
16 static u8 sample_table[SAMPLE_COLUMNS][MCS_GROUP_RATES];
19 +minstrel_ht_set_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
20 + struct ieee80211_tx_rate *rate, int index,
21 + bool sample, bool rtscts);
23 * Perform EWMA (Exponentially Weighted Moving Average) calculation
25 @@ -174,6 +178,17 @@ minstrel_ht_calc_tp(struct minstrel_priv
26 mr->cur_tp = MINSTREL_TRUNC((1000000 / usecs) * mr->probability);
30 +minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
32 + minstrel_ht_set_rate(mp, mi, &mi->tx_rates[0], mi->max_tp_rate,
34 + minstrel_ht_set_rate(mp, mi, &mi->tx_rates[1], mi->max_tp_rate2,
36 + minstrel_ht_set_rate(mp, mi, &mi->tx_rates[2], mi->max_prob_rate,
41 * Update rate statistics and select new primary rates
43 @@ -294,6 +309,7 @@ minstrel_ht_update_stats(struct minstrel
47 + minstrel_ht_update_rates(mp, mi);
48 mi->stats_update = jiffies;
51 @@ -332,8 +348,8 @@ minstrel_next_sample_idx(struct minstrel
55 -minstrel_downgrade_rate(struct minstrel_ht_sta *mi, unsigned int *idx,
57 +minstrel_downgrade_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
58 + unsigned int *idx, bool primary)
60 int group, orig_group;
62 @@ -352,6 +368,7 @@ minstrel_downgrade_rate(struct minstrel_
63 *idx = mi->groups[group].max_tp_rate;
65 *idx = mi->groups[group].max_tp_rate2;
66 + minstrel_ht_update_rates(mp, mi);
70 @@ -452,13 +469,13 @@ minstrel_ht_tx_status(void *priv, struct
71 if (rate->attempts > 30 &&
72 MINSTREL_FRAC(rate->success, rate->attempts) <
73 MINSTREL_FRAC(20, 100))
74 - minstrel_downgrade_rate(mi, &mi->max_tp_rate, true);
75 + minstrel_downgrade_rate(mp, mi, &mi->max_tp_rate, true);
77 rate2 = minstrel_get_ratestats(mi, mi->max_tp_rate2);
78 if (rate2->attempts > 30 &&
79 MINSTREL_FRAC(rate2->success, rate2->attempts) <
80 MINSTREL_FRAC(20, 100))
81 - minstrel_downgrade_rate(mi, &mi->max_tp_rate2, false);
82 + minstrel_downgrade_rate(mp, mi, &mi->max_tp_rate2, false);
84 if (time_after(jiffies, mi->stats_update + (mp->update_interval / 2 * HZ) / 1000)) {
85 minstrel_ht_update_stats(mp, mi);
86 @@ -523,7 +540,6 @@ minstrel_calc_retransmit(struct minstrel
88 minstrel_ht_set_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
89 struct ieee80211_tx_rate *rate, int index,
90 - struct ieee80211_tx_rate_control *txrc,
91 bool sample, bool rtscts)
93 const struct mcs_group *group = &minstrel_mcs_groups[index / MCS_GROUP_RATES];
94 @@ -611,6 +627,7 @@ minstrel_ht_get_rate(void *priv, struct
95 struct minstrel_priv *mp = priv;
100 if (rate_control_send_low(sta, priv_sta, txrc))
102 @@ -636,11 +653,10 @@ minstrel_ht_get_rate(void *priv, struct
103 if (sample_idx >= 0) {
105 minstrel_ht_set_rate(mp, mi, &ar[0], sample_idx,
106 - txrc, true, false);
108 info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
110 - minstrel_ht_set_rate(mp, mi, &ar[0], mi->max_tp_rate,
111 - txrc, false, false);
112 + ar[0] = mi->tx_rates[0];
115 if (mp->hw->max_rates >= 3) {
116 @@ -650,33 +666,27 @@ minstrel_ht_get_rate(void *priv, struct
117 * max_tp_rate -> max_tp_rate2 -> max_prob_rate by default.
120 - minstrel_ht_set_rate(mp, mi, &ar[1], mi->max_tp_rate,
121 - txrc, false, false);
122 + ar[1] = mi->tx_rates[0];
124 - minstrel_ht_set_rate(mp, mi, &ar[1], mi->max_tp_rate2,
125 - txrc, false, true);
127 - minstrel_ht_set_rate(mp, mi, &ar[2], mi->max_prob_rate,
128 - txrc, false, !sample);
129 + ar[1] = mi->tx_rates[1];
133 + ar[2] = mi->tx_rates[2];
135 } else if (mp->hw->max_rates == 2) {
137 * Only 2 tx rates supported, use
138 * sample_rate -> max_prob_rate for sampling and
139 * max_tp_rate -> max_prob_rate by default.
141 - minstrel_ht_set_rate(mp, mi, &ar[1], mi->max_prob_rate,
142 - txrc, false, !sample);
146 + ar[1] = mi->tx_rates[2];
149 /* Not using MRR, only use the first rate */
155 + ar[last].count = 0;
160 @@ -768,6 +778,7 @@ minstrel_ht_update_caps(void *priv, stru
164 + minstrel_ht_update_rates(mp, mi);