1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Sat, 26 Dec 2020 13:56:42 +0100
3 Subject: [PATCH] mac80211: minstrel_ht: add support for OFDM rates on
6 The legacy minstrel code is essentially unmaintained and receives only very
7 little testing. In order to bring the significant algorithm improvements from
8 minstrel_ht to legacy clients, this patch adds support for OFDM rates to
9 minstrel_ht and removes the fallback to the legacy codepath.
10 This also makes it work much better on hardware with rate selection constraints,
13 Signed-off-by: Felix Fietkau <nbd@nbd.name>
16 --- a/net/mac80211/rc80211_minstrel.h
17 +++ b/net/mac80211/rc80211_minstrel.h
18 @@ -152,6 +152,7 @@ struct minstrel_priv {
19 unsigned int lookaround_rate_mrr;
22 + u8 ofdm_rates[NUM_NL80211_BANDS][8];
24 #ifdef CPTCFG_MAC80211_DEBUGFS
26 --- a/net/mac80211/rc80211_minstrel_ht.c
27 +++ b/net/mac80211/rc80211_minstrel_ht.c
30 #define CCK_GROUP __CCK_GROUP(CCK_GROUP_SHIFT)
32 +#define OFDM_DURATION(_bitrate) \
33 + (1000 * (16 /* SIFS + signal ext */ + \
34 + 16 /* T_PREAMBLE */ + \
35 + 4 /* T_SIGNAL */ + \
36 + 4 * (((16 + 80 * (AVG_PKT_SIZE + 4) + 6) / \
37 + ((_bitrate) * 4)))))
39 +#define OFDM_DURATION_LIST(_s) \
40 + OFDM_DURATION(60) >> _s, \
41 + OFDM_DURATION(90) >> _s, \
42 + OFDM_DURATION(120) >> _s, \
43 + OFDM_DURATION(180) >> _s, \
44 + OFDM_DURATION(240) >> _s, \
45 + OFDM_DURATION(360) >> _s, \
46 + OFDM_DURATION(480) >> _s, \
47 + OFDM_DURATION(540) >> _s
49 +#define __OFDM_GROUP(_s) \
50 + [MINSTREL_OFDM_GROUP] = { \
55 + OFDM_DURATION_LIST(_s), \
59 +#define OFDM_GROUP_SHIFT \
60 + GROUP_SHIFT(OFDM_DURATION(60))
62 +#define OFDM_GROUP __OFDM_GROUP(OFDM_GROUP_SHIFT)
65 static bool minstrel_vht_only = true;
66 module_param(minstrel_vht_only, bool, 0644);
67 @@ -199,6 +231,7 @@ const struct mcs_group minstrel_mcs_grou
68 MCS_GROUP(4, 1, BW_40),
73 VHT_GROUP(1, 0, BW_20),
74 VHT_GROUP(2, 0, BW_20),
75 @@ -231,6 +264,8 @@ const struct mcs_group minstrel_mcs_grou
76 VHT_GROUP(4, 1, BW_80),
79 +const s16 minstrel_cck_bitrates[4] = { 10, 20, 55, 110 };
80 +const s16 minstrel_ofdm_bitrates[8] = { 60, 90, 120, 180, 240, 360, 480, 540 };
81 static u8 sample_table[SAMPLE_COLUMNS][MCS_GROUP_RATES] __read_mostly;
84 @@ -275,6 +310,13 @@ minstrel_get_valid_vht_rates(int bw, int
89 +minstrel_ht_is_legacy_group(int group)
91 + return group == MINSTREL_CCK_GROUP ||
92 + group == MINSTREL_OFDM_GROUP;
96 * Look up an MCS group index based on mac80211 rate information
98 @@ -304,21 +346,34 @@ minstrel_ht_get_stats(struct minstrel_pr
99 if (rate->flags & IEEE80211_TX_RC_MCS) {
100 group = minstrel_ht_get_group_idx(rate);
102 - } else if (rate->flags & IEEE80211_TX_RC_VHT_MCS) {
106 + if (rate->flags & IEEE80211_TX_RC_VHT_MCS) {
107 group = minstrel_vht_get_group_idx(rate);
108 idx = ieee80211_rate_get_vht_mcs(rate);
110 - group = MINSTREL_CCK_GROUP;
114 - for (idx = 0; idx < ARRAY_SIZE(mp->cck_rates); idx++)
115 - if (rate->idx == mp->cck_rates[idx])
117 + group = MINSTREL_CCK_GROUP;
118 + for (idx = 0; idx < ARRAY_SIZE(mp->cck_rates); idx++) {
119 + if (rate->idx != mp->cck_rates[idx])
123 if ((mi->supported[group] & BIT(idx + 4)) &&
124 (rate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE))
130 + group = MINSTREL_OFDM_GROUP;
131 + for (idx = 0; idx < ARRAY_SIZE(mp->ofdm_rates[0]); idx++)
132 + if (rate->idx == mp->ofdm_rates[mi->band][idx])
137 return &mi->groups[group].rates[idx];
140 @@ -352,7 +407,7 @@ minstrel_ht_get_tp_avg(struct minstrel_h
141 if (prob_avg < MINSTREL_FRAC(10, 100))
144 - if (group == MINSTREL_CCK_GROUP)
145 + if (minstrel_ht_is_legacy_group(group))
146 overhead = mi->overhead_legacy;
148 ampdu_len = minstrel_ht_avg_ampdu_len(mi);
149 @@ -439,8 +494,8 @@ minstrel_ht_set_best_prob_rate(struct mi
150 /* if max_tp_rate[0] is from MCS_GROUP max_prob_rate get selected from
151 * MCS_GROUP as well as CCK_GROUP rates do not allow aggregation */
152 max_tp_group = mi->max_tp_rate[0] / MCS_GROUP_RATES;
153 - if((index / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) &&
154 - (max_tp_group != MINSTREL_CCK_GROUP))
155 + if (minstrel_ht_is_legacy_group(index / MCS_GROUP_RATES) &&
156 + !minstrel_ht_is_legacy_group(max_tp_group))
159 max_gpr_group = mg->max_group_prob_rate / MCS_GROUP_RATES;
160 @@ -476,13 +531,13 @@ minstrel_ht_set_best_prob_rate(struct mi
162 minstrel_ht_assign_best_tp_rates(struct minstrel_ht_sta *mi,
163 u16 tmp_mcs_tp_rate[MAX_THR_RATES],
164 - u16 tmp_cck_tp_rate[MAX_THR_RATES])
165 + u16 tmp_legacy_tp_rate[MAX_THR_RATES])
167 unsigned int tmp_group, tmp_idx, tmp_cck_tp, tmp_mcs_tp, tmp_prob;
170 - tmp_group = tmp_cck_tp_rate[0] / MCS_GROUP_RATES;
171 - tmp_idx = tmp_cck_tp_rate[0] % MCS_GROUP_RATES;
172 + tmp_group = tmp_legacy_tp_rate[0] / MCS_GROUP_RATES;
173 + tmp_idx = tmp_legacy_tp_rate[0] % MCS_GROUP_RATES;
174 tmp_prob = mi->groups[tmp_group].rates[tmp_idx].prob_avg;
175 tmp_cck_tp = minstrel_ht_get_tp_avg(mi, tmp_group, tmp_idx, tmp_prob);
177 @@ -493,7 +548,7 @@ minstrel_ht_assign_best_tp_rates(struct
179 if (tmp_cck_tp > tmp_mcs_tp) {
180 for(i = 0; i < MAX_THR_RATES; i++) {
181 - minstrel_ht_sort_best_tp_rates(mi, tmp_cck_tp_rate[i],
182 + minstrel_ht_sort_best_tp_rates(mi, tmp_legacy_tp_rate[i],
186 @@ -511,6 +566,9 @@ minstrel_ht_prob_rate_reduce_streams(str
187 int tmp_max_streams, group, tmp_idx, tmp_prob;
190 + if (!mi->sta->ht_cap.ht_supported)
193 tmp_max_streams = minstrel_mcs_groups[mi->max_tp_rate[0] /
194 MCS_GROUP_RATES].streams;
195 for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) {
196 @@ -675,7 +733,8 @@ minstrel_ht_update_stats(struct minstrel
197 struct minstrel_rate_stats *mrs;
198 int group, i, j, cur_prob;
199 u16 tmp_mcs_tp_rate[MAX_THR_RATES], tmp_group_tp_rate[MAX_THR_RATES];
200 - u16 tmp_cck_tp_rate[MAX_THR_RATES], index;
201 + u16 tmp_legacy_tp_rate[MAX_THR_RATES], index;
202 + bool ht_supported = mi->sta->ht_cap.ht_supported;
204 mi->sample_mode = MINSTREL_SAMPLE_IDLE;
206 @@ -704,21 +763,29 @@ minstrel_ht_update_stats(struct minstrel
207 mi->sample_count = 0;
209 memset(tmp_mcs_tp_rate, 0, sizeof(tmp_mcs_tp_rate));
210 - memset(tmp_cck_tp_rate, 0, sizeof(tmp_cck_tp_rate));
211 + memset(tmp_legacy_tp_rate, 0, sizeof(tmp_legacy_tp_rate));
212 if (mi->supported[MINSTREL_CCK_GROUP])
213 - for (j = 0; j < ARRAY_SIZE(tmp_cck_tp_rate); j++)
214 - tmp_cck_tp_rate[j] = MINSTREL_CCK_GROUP * MCS_GROUP_RATES;
215 + for (j = 0; j < ARRAY_SIZE(tmp_legacy_tp_rate); j++)
216 + tmp_legacy_tp_rate[j] = MINSTREL_CCK_GROUP * MCS_GROUP_RATES;
217 + else if (mi->supported[MINSTREL_OFDM_GROUP])
218 + for (j = 0; j < ARRAY_SIZE(tmp_legacy_tp_rate); j++)
219 + tmp_legacy_tp_rate[j] = MINSTREL_OFDM_GROUP * MCS_GROUP_RATES;
221 if (mi->supported[MINSTREL_VHT_GROUP_0])
222 index = MINSTREL_VHT_GROUP_0 * MCS_GROUP_RATES;
224 + else if (ht_supported)
225 index = MINSTREL_HT_GROUP_0 * MCS_GROUP_RATES;
226 + else if (mi->supported[MINSTREL_CCK_GROUP])
227 + index = MINSTREL_CCK_GROUP * MCS_GROUP_RATES;
229 + index = MINSTREL_OFDM_GROUP * MCS_GROUP_RATES;
231 for (j = 0; j < ARRAY_SIZE(tmp_mcs_tp_rate); j++)
232 tmp_mcs_tp_rate[j] = index;
234 /* Find best rate sets within all MCS groups*/
235 for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) {
236 + u16 *tp_rate = tmp_mcs_tp_rate;
238 mg = &mi->groups[group];
239 if (!mi->supported[group])
240 @@ -730,6 +797,9 @@ minstrel_ht_update_stats(struct minstrel
241 for(j = 0; j < MAX_THR_RATES; j++)
242 tmp_group_tp_rate[j] = MCS_GROUP_RATES * group;
244 + if (group == MINSTREL_CCK_GROUP && ht_supported)
245 + tp_rate = tmp_legacy_tp_rate;
247 for (i = 0; i < MCS_GROUP_RATES; i++) {
248 if (!(mi->supported[group] & BIT(i)))
250 @@ -745,13 +815,7 @@ minstrel_ht_update_stats(struct minstrel
253 /* Find max throughput rate set */
254 - if (group != MINSTREL_CCK_GROUP) {
255 - minstrel_ht_sort_best_tp_rates(mi, index,
257 - } else if (group == MINSTREL_CCK_GROUP) {
258 - minstrel_ht_sort_best_tp_rates(mi, index,
261 + minstrel_ht_sort_best_tp_rates(mi, index, tp_rate);
263 /* Find max throughput rate set within a group */
264 minstrel_ht_sort_best_tp_rates(mi, index,
265 @@ -766,7 +830,8 @@ minstrel_ht_update_stats(struct minstrel
268 /* Assign new rate set per sta */
269 - minstrel_ht_assign_best_tp_rates(mi, tmp_mcs_tp_rate, tmp_cck_tp_rate);
270 + minstrel_ht_assign_best_tp_rates(mi, tmp_mcs_tp_rate,
271 + tmp_legacy_tp_rate);
272 memcpy(mi->max_tp_rate, tmp_mcs_tp_rate, sizeof(mi->max_tp_rate));
274 /* Try to increase robustness of max_prob_rate*/
275 @@ -795,8 +860,11 @@ minstrel_ht_update_stats(struct minstrel
279 -minstrel_ht_txstat_valid(struct minstrel_priv *mp, struct ieee80211_tx_rate *rate)
280 +minstrel_ht_txstat_valid(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
281 + struct ieee80211_tx_rate *rate)
288 @@ -807,10 +875,15 @@ minstrel_ht_txstat_valid(struct minstrel
289 rate->flags & IEEE80211_TX_RC_VHT_MCS)
292 - return rate->idx == mp->cck_rates[0] ||
293 - rate->idx == mp->cck_rates[1] ||
294 - rate->idx == mp->cck_rates[2] ||
295 - rate->idx == mp->cck_rates[3];
296 + for (i = 0; i < ARRAY_SIZE(mp->cck_rates); i++)
297 + if (rate->idx == mp->cck_rates[i])
300 + for (i = 0; i < ARRAY_SIZE(mp->ofdm_rates[0]); i++)
301 + if (rate->idx == mp->ofdm_rates[mi->band][i])
308 @@ -897,11 +970,6 @@ minstrel_ht_tx_status(void *priv, struct
309 bool sample_status = false;
313 - return mac80211_minstrel.tx_status_ext(priv, sband,
317 /* This packet was aggregated but doesn't carry status info */
318 if ((info->flags & IEEE80211_TX_CTL_AMPDU) &&
319 !(info->flags & IEEE80211_TX_STAT_AMPDU))
320 @@ -930,10 +998,10 @@ minstrel_ht_tx_status(void *priv, struct
321 if (mi->sample_mode != MINSTREL_SAMPLE_IDLE)
322 rate_sample = minstrel_get_ratestats(mi, mi->sample_rate);
324 - last = !minstrel_ht_txstat_valid(mp, &ar[0]);
325 + last = !minstrel_ht_txstat_valid(mp, mi, &ar[0]);
326 for (i = 0; !last; i++) {
327 last = (i == IEEE80211_TX_MAX_RATES - 1) ||
328 - !minstrel_ht_txstat_valid(mp, &ar[i + 1]);
329 + !minstrel_ht_txstat_valid(mp, mi, &ar[i + 1]);
331 rate = minstrel_ht_get_stats(mp, mi, &ar[i]);
332 if (rate == rate_sample)
333 @@ -1031,7 +1099,7 @@ minstrel_calc_retransmit(struct minstrel
334 ctime += (t_slot * cw) >> 1;
335 cw = min((cw << 1) | 1, mp->cw_max);
337 - if (index / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) {
338 + if (minstrel_ht_is_legacy_group(index / MCS_GROUP_RATES)) {
339 overhead = mi->overhead_legacy;
340 overhead_rtscts = mi->overhead_legacy_rtscts;
342 @@ -1064,7 +1132,8 @@ static void
343 minstrel_ht_set_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
344 struct ieee80211_sta_rates *ratetbl, int offset, int index)
346 - const struct mcs_group *group = &minstrel_mcs_groups[index / MCS_GROUP_RATES];
347 + int group_idx = index / MCS_GROUP_RATES;
348 + const struct mcs_group *group = &minstrel_mcs_groups[group_idx];
349 struct minstrel_rate_stats *mrs;
351 u16 flags = group->flags;
352 @@ -1083,13 +1152,17 @@ minstrel_ht_set_rate(struct minstrel_pri
353 ratetbl->rate[offset].count_rts = mrs->retry_count_rtscts;
356 - if (index / MCS_GROUP_RATES == MINSTREL_CCK_GROUP)
357 + index %= MCS_GROUP_RATES;
358 + if (group_idx == MINSTREL_CCK_GROUP)
359 idx = mp->cck_rates[index % ARRAY_SIZE(mp->cck_rates)];
360 + else if (group_idx == MINSTREL_OFDM_GROUP)
361 + idx = mp->ofdm_rates[mi->band][index %
362 + ARRAY_SIZE(mp->ofdm_rates[0])];
363 else if (flags & IEEE80211_TX_RC_VHT_MCS)
364 idx = ((group->streams - 1) << 4) |
365 - ((index % MCS_GROUP_RATES) & 0xF);
368 - idx = index % MCS_GROUP_RATES + (group->streams - 1) * 8;
369 + idx = index + (group->streams - 1) * 8;
371 /* enable RTS/CTS if needed:
372 * - if station is in dynamic SMPS (and streams > 1)
373 @@ -1304,11 +1377,8 @@ minstrel_ht_get_rate(void *priv, struct
374 struct minstrel_priv *mp = priv;
378 - return mac80211_minstrel.get_rate(priv, sta, &msp->legacy, txrc);
380 if (!(info->flags & IEEE80211_TX_CTL_AMPDU) &&
381 - mi->max_prob_rate / MCS_GROUP_RATES != MINSTREL_CCK_GROUP)
382 + !minstrel_ht_is_legacy_group(mi->max_prob_rate / MCS_GROUP_RATES))
383 minstrel_aggr_check(sta, txrc->skb);
385 info->flags |= mi->tx_flags;
386 @@ -1349,6 +1419,9 @@ minstrel_ht_get_rate(void *priv, struct
387 if (sample_group == &minstrel_mcs_groups[MINSTREL_CCK_GROUP]) {
388 int idx = sample_idx % ARRAY_SIZE(mp->cck_rates);
389 rate->idx = mp->cck_rates[idx];
390 + } else if (sample_group == &minstrel_mcs_groups[MINSTREL_OFDM_GROUP]) {
391 + int idx = sample_idx % ARRAY_SIZE(mp->ofdm_rates[0]);
392 + rate->idx = mp->ofdm_rates[mi->band][idx];
393 } else if (sample_group->flags & IEEE80211_TX_RC_VHT_MCS) {
394 ieee80211_rate_set_vht(rate, sample_idx % MCS_GROUP_RATES,
395 sample_group->streams);
396 @@ -1369,11 +1442,13 @@ minstrel_ht_update_cck(struct minstrel_p
397 if (sband->band != NL80211_BAND_2GHZ)
400 - if (!ieee80211_hw_check(mp->hw, SUPPORTS_HT_CCK_RATES))
401 + if (sta->ht_cap.ht_supported &&
402 + !ieee80211_hw_check(mp->hw, SUPPORTS_HT_CCK_RATES))
405 for (i = 0; i < 4; i++) {
406 - if (!rate_supported(sta, sband->band, mp->cck_rates[i]))
407 + if (mp->cck_rates[i] == 0xff ||
408 + !rate_supported(sta, sband->band, mp->cck_rates[i]))
411 mi->supported[MINSTREL_CCK_GROUP] |= BIT(i);
412 @@ -1383,9 +1458,30 @@ minstrel_ht_update_cck(struct minstrel_p
416 +minstrel_ht_update_ofdm(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
417 + struct ieee80211_supported_band *sband,
418 + struct ieee80211_sta *sta)
423 + if (sta->ht_cap.ht_supported)
426 + rates = mp->ofdm_rates[sband->band];
427 + for (i = 0; i < ARRAY_SIZE(mp->ofdm_rates[0]); i++) {
428 + if (rates[i] == 0xff ||
429 + !rate_supported(sta, sband->band, rates[i]))
432 + mi->supported[MINSTREL_OFDM_GROUP] |= BIT(i);
437 minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband,
438 struct cfg80211_chan_def *chandef,
439 - struct ieee80211_sta *sta, void *priv_sta)
440 + struct ieee80211_sta *sta, void *priv_sta)
442 struct minstrel_priv *mp = priv;
443 struct minstrel_ht_sta_priv *msp = priv_sta;
444 @@ -1401,10 +1497,6 @@ minstrel_ht_update_caps(void *priv, stru
448 - /* fall back to the old minstrel for legacy stations */
449 - if (!sta->ht_cap.ht_supported)
452 BUILD_BUG_ON(ARRAY_SIZE(minstrel_mcs_groups) != MINSTREL_GROUPS_NB);
454 if (vht_cap->vht_supported)
455 @@ -1412,10 +1504,10 @@ minstrel_ht_update_caps(void *priv, stru
460 memset(mi, 0, sizeof(*mi));
463 + mi->band = sband->band;
464 mi->last_stats_update = jiffies;
466 ack_dur = ieee80211_frame_duration(sband->band, 10, 60, 1, 1, 0);
467 @@ -1464,10 +1556,8 @@ minstrel_ht_update_caps(void *priv, stru
470 mi->supported[i] = 0;
471 - if (i == MINSTREL_CCK_GROUP) {
472 - minstrel_ht_update_cck(mp, mi, sband, sta);
473 + if (minstrel_ht_is_legacy_group(i))
477 if (gflags & IEEE80211_TX_RC_SHORT_GI) {
478 if (gflags & IEEE80211_TX_RC_40_MHZ_WIDTH) {
479 @@ -1528,22 +1618,12 @@ minstrel_ht_update_caps(void *priv, stru
485 + minstrel_ht_update_cck(mp, mi, sband, sta);
486 + minstrel_ht_update_ofdm(mp, mi, sband, sta);
488 /* create an initial rate table with the lowest supported rates */
489 minstrel_ht_update_stats(mp, mi, true);
490 minstrel_ht_update_rates(mp, mi);
495 - msp->is_ht = false;
496 - memset(&msp->legacy, 0, sizeof(msp->legacy));
497 - msp->legacy.r = msp->ratelist;
498 - msp->legacy.sample_table = msp->sample_table;
499 - return mac80211_minstrel.rate_init(priv, sband, chandef, sta,
504 @@ -1611,40 +1691,70 @@ minstrel_ht_free_sta(void *priv, struct
508 -minstrel_ht_init_cck_rates(struct minstrel_priv *mp)
509 +minstrel_ht_fill_rate_array(u8 *dest, struct ieee80211_supported_band *sband,
510 + const s16 *bitrates, int n_rates, u32 rate_flags)
512 - static const int bitrates[4] = { 10, 20, 55, 110 };
513 - struct ieee80211_supported_band *sband;
514 - u32 rate_flags = ieee80211_chandef_rate_flags(&mp->hw->conf.chandef);
517 - sband = mp->hw->wiphy->bands[NL80211_BAND_2GHZ];
521 for (i = 0; i < sband->n_bitrates; i++) {
522 struct ieee80211_rate *rate = &sband->bitrates[i];
524 - if (rate->flags & IEEE80211_RATE_ERP_G)
527 if ((rate_flags & sband->bitrates[i].flags) != rate_flags)
530 - for (j = 0; j < ARRAY_SIZE(bitrates); j++) {
531 + for (j = 0; j < n_rates; j++) {
532 if (rate->bitrate != bitrates[j])
535 - mp->cck_rates[j] = i;
543 +minstrel_ht_init_cck_rates(struct minstrel_priv *mp)
545 + static const s16 bitrates[4] = { 10, 20, 55, 110 };
546 + struct ieee80211_supported_band *sband;
547 + u32 rate_flags = ieee80211_chandef_rate_flags(&mp->hw->conf.chandef);
549 + memset(mp->cck_rates, 0xff, sizeof(mp->cck_rates));
550 + sband = mp->hw->wiphy->bands[NL80211_BAND_2GHZ];
554 + BUILD_BUG_ON(ARRAY_SIZE(mp->cck_rates) != ARRAY_SIZE(bitrates));
555 + minstrel_ht_fill_rate_array(mp->cck_rates, sband,
556 + minstrel_cck_bitrates,
557 + ARRAY_SIZE(minstrel_cck_bitrates),
562 +minstrel_ht_init_ofdm_rates(struct minstrel_priv *mp, enum nl80211_band band)
564 + static const s16 bitrates[8] = { 60, 90, 120, 180, 240, 360, 480, 540 };
565 + struct ieee80211_supported_band *sband;
566 + u32 rate_flags = ieee80211_chandef_rate_flags(&mp->hw->conf.chandef);
568 + memset(mp->ofdm_rates[band], 0xff, sizeof(mp->ofdm_rates[band]));
569 + sband = mp->hw->wiphy->bands[band];
573 + BUILD_BUG_ON(ARRAY_SIZE(mp->ofdm_rates[band]) != ARRAY_SIZE(bitrates));
574 + minstrel_ht_fill_rate_array(mp->ofdm_rates[band], sband,
575 + minstrel_ofdm_bitrates,
576 + ARRAY_SIZE(minstrel_ofdm_bitrates),
581 minstrel_ht_alloc(struct ieee80211_hw *hw)
583 struct minstrel_priv *mp;
586 mp = kzalloc(sizeof(struct minstrel_priv), GFP_ATOMIC);
588 @@ -1681,6 +1791,8 @@ minstrel_ht_alloc(struct ieee80211_hw *h
591 minstrel_ht_init_cck_rates(mp);
592 + for (i = 0; i < ARRAY_SIZE(mp->hw->wiphy->bands); i++)
593 + minstrel_ht_init_ofdm_rates(mp, i);
597 @@ -1713,9 +1825,6 @@ static u32 minstrel_ht_get_expected_thro
598 struct minstrel_ht_sta *mi = &msp->ht;
599 int i, j, prob, tp_avg;
602 - return mac80211_minstrel.get_expected_throughput(priv_sta);
604 i = mi->max_tp_rate[0] / MCS_GROUP_RATES;
605 j = mi->max_tp_rate[0] % MCS_GROUP_RATES;
606 prob = mi->groups[i].rates[j].prob_avg;
607 --- a/net/mac80211/rc80211_minstrel_ht.h
608 +++ b/net/mac80211/rc80211_minstrel_ht.h
610 MINSTREL_HT_STREAM_GROUPS)
611 #define MINSTREL_VHT_GROUPS_NB (MINSTREL_MAX_STREAMS * \
612 MINSTREL_VHT_STREAM_GROUPS)
613 -#define MINSTREL_CCK_GROUPS_NB 1
614 +#define MINSTREL_LEGACY_GROUPS_NB 2
615 #define MINSTREL_GROUPS_NB (MINSTREL_HT_GROUPS_NB + \
616 MINSTREL_VHT_GROUPS_NB + \
617 - MINSTREL_CCK_GROUPS_NB)
618 + MINSTREL_LEGACY_GROUPS_NB)
620 #define MINSTREL_HT_GROUP_0 0
621 #define MINSTREL_CCK_GROUP (MINSTREL_HT_GROUP_0 + MINSTREL_HT_GROUPS_NB)
622 -#define MINSTREL_VHT_GROUP_0 (MINSTREL_CCK_GROUP + 1)
623 +#define MINSTREL_OFDM_GROUP (MINSTREL_CCK_GROUP + 1)
624 +#define MINSTREL_VHT_GROUP_0 (MINSTREL_OFDM_GROUP + 1)
626 #define MCS_GROUP_RATES 10
628 @@ -37,6 +38,8 @@ struct mcs_group {
629 u16 duration[MCS_GROUP_RATES];
632 +extern const s16 minstrel_cck_bitrates[4];
633 +extern const s16 minstrel_ofdm_bitrates[8];
634 extern const struct mcs_group minstrel_mcs_groups[];
636 struct minstrel_mcs_group_data {
637 @@ -99,6 +102,8 @@ struct minstrel_ht_sta {
638 /* current MCS group to be sampled */
643 /* Bitfield of supported MCS rates of all groups */
644 u16 supported[MINSTREL_GROUPS_NB];
646 @@ -107,13 +112,9 @@ struct minstrel_ht_sta {
649 struct minstrel_ht_sta_priv {
651 - struct minstrel_ht_sta ht;
652 - struct minstrel_sta_info legacy;
654 + struct minstrel_ht_sta ht;
660 void minstrel_ht_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir);
661 --- a/net/mac80211/rc80211_minstrel_ht_debugfs.c
662 +++ b/net/mac80211/rc80211_minstrel_ht_debugfs.c
663 @@ -52,7 +52,6 @@ minstrel_ht_stats_dump(struct minstrel_h
665 for (j = 0; j < MCS_GROUP_RATES; j++) {
666 struct minstrel_rate_stats *mrs = &mi->groups[i].rates[j];
667 - static const int bitrates[4] = { 10, 20, 55, 110 };
668 int idx = i * MCS_GROUP_RATES + j;
669 unsigned int duration;
671 @@ -67,6 +66,9 @@ minstrel_ht_stats_dump(struct minstrel_h
672 p += sprintf(p, "VHT%c0 ", htmode);
673 p += sprintf(p, "%cGI ", gimode);
674 p += sprintf(p, "%d ", mg->streams);
675 + } else if (i == MINSTREL_OFDM_GROUP) {
676 + p += sprintf(p, "OFDM ");
677 + p += sprintf(p, "1 ");
679 p += sprintf(p, "CCK ");
680 p += sprintf(p, "%cP ", j < 4 ? 'L' : 'S');
681 @@ -84,7 +86,12 @@ minstrel_ht_stats_dump(struct minstrel_h
682 } else if (gflags & IEEE80211_TX_RC_VHT_MCS) {
683 p += sprintf(p, " MCS%-1u/%1u", j, mg->streams);
685 - int r = bitrates[j % 4];
688 + if (i == MINSTREL_OFDM_GROUP)
689 + r = minstrel_ofdm_bitrates[j % 8];
691 + r = minstrel_cck_bitrates[j % 4];
693 p += sprintf(p, " %2u.%1uM", r / 10, r % 10);
695 @@ -124,16 +131,8 @@ minstrel_ht_stats_open(struct inode *ino
696 struct minstrel_ht_sta *mi = &msp->ht;
697 struct minstrel_debugfs_info *ms;
703 - inode->i_private = &msp->legacy;
704 - ret = minstrel_stats_open(inode, file);
705 - inode->i_private = msp;
709 ms = kmalloc(32768, GFP_KERNEL);
712 @@ -199,7 +198,6 @@ minstrel_ht_stats_csv_dump(struct minstr
714 for (j = 0; j < MCS_GROUP_RATES; j++) {
715 struct minstrel_rate_stats *mrs = &mi->groups[i].rates[j];
716 - static const int bitrates[4] = { 10, 20, 55, 110 };
717 int idx = i * MCS_GROUP_RATES + j;
718 unsigned int duration;
720 @@ -214,6 +212,8 @@ minstrel_ht_stats_csv_dump(struct minstr
721 p += sprintf(p, "VHT%c0,", htmode);
722 p += sprintf(p, "%cGI,", gimode);
723 p += sprintf(p, "%d,", mg->streams);
724 + } else if (i == MINSTREL_OFDM_GROUP) {
725 + p += sprintf(p, "OFDM,,1,");
727 p += sprintf(p, "CCK,");
728 p += sprintf(p, "%cP,", j < 4 ? 'L' : 'S');
729 @@ -231,7 +231,13 @@ minstrel_ht_stats_csv_dump(struct minstr
730 } else if (gflags & IEEE80211_TX_RC_VHT_MCS) {
731 p += sprintf(p, ",MCS%-1u/%1u,", j, mg->streams);
733 - int r = bitrates[j % 4];
736 + if (i == MINSTREL_OFDM_GROUP)
737 + r = minstrel_ofdm_bitrates[j % 8];
739 + r = minstrel_cck_bitrates[j % 4];
741 p += sprintf(p, ",%2u.%1uM,", r / 10, r % 10);
744 @@ -274,18 +280,9 @@ minstrel_ht_stats_csv_open(struct inode
745 struct minstrel_ht_sta *mi = &msp->ht;
746 struct minstrel_debugfs_info *ms;
752 - inode->i_private = &msp->legacy;
753 - ret = minstrel_stats_csv_open(inode, file);
754 - inode->i_private = msp;
758 ms = kmalloc(32768, GFP_KERNEL);