aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211
diff options
context:
space:
mode:
authorThomas Huehn <thomas@net.t-labs.tu-berlin.de>2015-03-24 16:09:39 -0400
committerJohannes Berg <johannes.berg@intel.com>2015-04-01 14:44:31 -0400
commit9134073bc693633b5e1f1a7252c93b3fb262aae4 (patch)
treebc3d44c87bbcf5006f45f0afbd45da209a2101ee /net/mac80211
parentf62838bcc5f58f580961aaf8c9fe59036b7be825 (diff)
mac80211: improve Minstrel variable & function naming
This patch ensures a consistent usage of variable names for type "minstrel_rate_stats" to be used as "mrs" and from type minstrel_rate as "mr" across both Minstrel & Minstrel-HT. In addition some variable and function names got changed to more meaningful ones. Signed-off-by: Thomas Huehn <thomas@net.t-labs.tu-berlin.de> Acked-by: Felix Fietkau <nbd@openwrt.org> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211')
-rw-r--r--net/mac80211/rc80211_minstrel.c26
-rw-r--r--net/mac80211/rc80211_minstrel.h13
-rw-r--r--net/mac80211/rc80211_minstrel_debugfs.c4
-rw-r--r--net/mac80211/rc80211_minstrel_ht.c112
-rw-r--r--net/mac80211/rc80211_minstrel_ht.h2
-rw-r--r--net/mac80211/rc80211_minstrel_ht_debugfs.c36
6 files changed, 98 insertions, 95 deletions
diff --git a/net/mac80211/rc80211_minstrel.c b/net/mac80211/rc80211_minstrel.c
index 5528037021ad..c86e42b67908 100644
--- a/net/mac80211/rc80211_minstrel.c
+++ b/net/mac80211/rc80211_minstrel.c
@@ -137,9 +137,9 @@ minstrel_calc_rate_stats(struct minstrel_rate_stats *mrs)
137 mrs->sample_skipped = 0; 137 mrs->sample_skipped = 0;
138 mrs->cur_prob = MINSTREL_FRAC(mrs->success, mrs->attempts); 138 mrs->cur_prob = MINSTREL_FRAC(mrs->success, mrs->attempts);
139 if (unlikely(!mrs->att_hist)) 139 if (unlikely(!mrs->att_hist))
140 mrs->probability = mrs->cur_prob; 140 mrs->prob_ewma = mrs->cur_prob;
141 else 141 else
142 mrs->probability = minstrel_ewma(mrs->probability, 142 mrs->prob_ewma = minstrel_ewma(mrs->prob_ewma,
143 mrs->cur_prob, EWMA_LEVEL); 143 mrs->cur_prob, EWMA_LEVEL);
144 mrs->att_hist += mrs->attempts; 144 mrs->att_hist += mrs->attempts;
145 mrs->succ_hist += mrs->success; 145 mrs->succ_hist += mrs->success;
@@ -176,15 +176,15 @@ minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
176 minstrel_calc_rate_stats(mrs); 176 minstrel_calc_rate_stats(mrs);
177 177
178 /* Update throughput per rate, reset thr. below 10% success */ 178 /* Update throughput per rate, reset thr. below 10% success */
179 if (mrs->probability < MINSTREL_FRAC(10, 100)) 179 if (mrs->prob_ewma < MINSTREL_FRAC(10, 100))
180 mrs->cur_tp = 0; 180 mrs->cur_tp = 0;
181 else 181 else
182 mrs->cur_tp = mrs->probability * (1000000 / usecs); 182 mrs->cur_tp = mrs->prob_ewma * (1000000 / usecs);
183 183
184 /* Sample less often below the 10% chance of success. 184 /* Sample less often below the 10% chance of success.
185 * Sample less often above the 95% chance of success. */ 185 * Sample less often above the 95% chance of success. */
186 if (mrs->probability > MINSTREL_FRAC(95, 100) || 186 if (mrs->prob_ewma > MINSTREL_FRAC(95, 100) ||
187 mrs->probability < MINSTREL_FRAC(10, 100)) { 187 mrs->prob_ewma < MINSTREL_FRAC(10, 100)) {
188 mr->adjusted_retry_count = mrs->retry_count >> 1; 188 mr->adjusted_retry_count = mrs->retry_count >> 1;
189 if (mr->adjusted_retry_count > 2) 189 if (mr->adjusted_retry_count > 2)
190 mr->adjusted_retry_count = 2; 190 mr->adjusted_retry_count = 2;
@@ -204,11 +204,11 @@ minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
204 * choose the maximum throughput rate as max_prob_rate 204 * choose the maximum throughput rate as max_prob_rate
205 * (2) if all success probabilities < 95%, the rate with 205 * (2) if all success probabilities < 95%, the rate with
206 * highest success probability is chosen as max_prob_rate */ 206 * highest success probability is chosen as max_prob_rate */
207 if (mrs->probability >= MINSTREL_FRAC(95, 100)) { 207 if (mrs->prob_ewma >= MINSTREL_FRAC(95, 100)) {
208 if (mrs->cur_tp >= mi->r[tmp_prob_rate].stats.cur_tp) 208 if (mrs->cur_tp >= mi->r[tmp_prob_rate].stats.cur_tp)
209 tmp_prob_rate = i; 209 tmp_prob_rate = i;
210 } else { 210 } else {
211 if (mrs->probability >= mi->r[tmp_prob_rate].stats.probability) 211 if (mrs->prob_ewma >= mi->r[tmp_prob_rate].stats.prob_ewma)
212 tmp_prob_rate = i; 212 tmp_prob_rate = i;
213 } 213 }
214 } 214 }
@@ -227,7 +227,7 @@ minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
227#endif 227#endif
228 228
229 /* Reset update timer */ 229 /* Reset update timer */
230 mi->stats_update = jiffies; 230 mi->last_stats_update = jiffies;
231 231
232 minstrel_update_rates(mp, mi); 232 minstrel_update_rates(mp, mi);
233} 233}
@@ -265,7 +265,7 @@ minstrel_tx_status(void *priv, struct ieee80211_supported_band *sband,
265 if (mi->sample_deferred > 0) 265 if (mi->sample_deferred > 0)
266 mi->sample_deferred--; 266 mi->sample_deferred--;
267 267
268 if (time_after(jiffies, mi->stats_update + 268 if (time_after(jiffies, mi->last_stats_update +
269 (mp->update_interval * HZ) / 1000)) 269 (mp->update_interval * HZ) / 1000))
270 minstrel_update_stats(mp, mi); 270 minstrel_update_stats(mp, mi);
271} 271}
@@ -397,7 +397,7 @@ minstrel_get_rate(void *priv, struct ieee80211_sta *sta,
397 * has a probability of >95%, we shouldn't be attempting 397 * has a probability of >95%, we shouldn't be attempting
398 * to use it, as this only wastes precious airtime */ 398 * to use it, as this only wastes precious airtime */
399 if (!mrr_capable && 399 if (!mrr_capable &&
400 (mi->r[ndx].stats.probability > MINSTREL_FRAC(95, 100))) 400 (mi->r[ndx].stats.prob_ewma > MINSTREL_FRAC(95, 100)))
401 return; 401 return;
402 402
403 mi->prev_sample = true; 403 mi->prev_sample = true;
@@ -531,7 +531,7 @@ minstrel_rate_init(void *priv, struct ieee80211_supported_band *sband,
531 } 531 }
532 532
533 mi->n_rates = n; 533 mi->n_rates = n;
534 mi->stats_update = jiffies; 534 mi->last_stats_update = jiffies;
535 535
536 init_sample_table(mi); 536 init_sample_table(mi);
537 minstrel_update_rates(mp, mi); 537 minstrel_update_rates(mp, mi);
@@ -565,7 +565,7 @@ minstrel_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp)
565 if (!mi->sample_table) 565 if (!mi->sample_table)
566 goto error1; 566 goto error1;
567 567
568 mi->stats_update = jiffies; 568 mi->last_stats_update = jiffies;
569 return mi; 569 return mi;
570 570
571error1: 571error1:
diff --git a/net/mac80211/rc80211_minstrel.h b/net/mac80211/rc80211_minstrel.h
index 728144c8df3f..58f287028437 100644
--- a/net/mac80211/rc80211_minstrel.h
+++ b/net/mac80211/rc80211_minstrel.h
@@ -38,11 +38,14 @@ struct minstrel_rate_stats {
38 /* total attempts/success counters */ 38 /* total attempts/success counters */
39 u64 att_hist, succ_hist; 39 u64 att_hist, succ_hist;
40 40
41 /* current throughput */ 41 /* current EWMA of rate throughput */
42 unsigned int cur_tp; 42 unsigned int cur_tp;
43 43
44 /* packet delivery probabilities */ 44 /* statistis of packet delivery probability
45 unsigned int cur_prob, probability; 45 * cur_prob - current prob within last update intervall
46 * prob_ewma - exponential weighted moving average of prob */
47 unsigned int cur_prob;
48 unsigned int prob_ewma;
46 49
47 /* maximum retry counts */ 50 /* maximum retry counts */
48 u8 retry_count; 51 u8 retry_count;
@@ -70,7 +73,7 @@ struct minstrel_rate {
70struct minstrel_sta_info { 73struct minstrel_sta_info {
71 struct ieee80211_sta *sta; 74 struct ieee80211_sta *sta;
72 75
73 unsigned long stats_update; 76 unsigned long last_stats_update;
74 unsigned int sp_ack_dur; 77 unsigned int sp_ack_dur;
75 unsigned int rate_avg; 78 unsigned int rate_avg;
76 79
@@ -133,7 +136,7 @@ void minstrel_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir);
133void minstrel_remove_sta_debugfs(void *priv, void *priv_sta); 136void minstrel_remove_sta_debugfs(void *priv, void *priv_sta);
134 137
135/* Recalculate success probabilities and counters for a given rate using EWMA */ 138/* Recalculate success probabilities and counters for a given rate using EWMA */
136void minstrel_calc_rate_stats(struct minstrel_rate_stats *mr); 139void minstrel_calc_rate_stats(struct minstrel_rate_stats *mrs);
137 140
138/* debugfs */ 141/* debugfs */
139int minstrel_stats_open(struct inode *inode, struct file *file); 142int minstrel_stats_open(struct inode *inode, struct file *file);
diff --git a/net/mac80211/rc80211_minstrel_debugfs.c b/net/mac80211/rc80211_minstrel_debugfs.c
index 97d118dab5e2..8a0b73eda99a 100644
--- a/net/mac80211/rc80211_minstrel_debugfs.c
+++ b/net/mac80211/rc80211_minstrel_debugfs.c
@@ -107,7 +107,7 @@ minstrel_stats_open(struct inode *inode, struct file *file)
107 107
108 tp = MINSTREL_TRUNC(mrs->cur_tp / 10); 108 tp = MINSTREL_TRUNC(mrs->cur_tp / 10);
109 prob = MINSTREL_TRUNC(mrs->cur_prob * 1000); 109 prob = MINSTREL_TRUNC(mrs->cur_prob * 1000);
110 eprob = MINSTREL_TRUNC(mrs->probability * 1000); 110 eprob = MINSTREL_TRUNC(mrs->prob_ewma * 1000);
111 111
112 p += sprintf(p, " %4u.%1u %3u.%1u %3u.%1u %3u" 112 p += sprintf(p, " %4u.%1u %3u.%1u %3u.%1u %3u"
113 " %3u %-3u %9llu %-9llu\n", 113 " %3u %-3u %9llu %-9llu\n",
@@ -171,7 +171,7 @@ minstrel_stats_csv_open(struct inode *inode, struct file *file)
171 171
172 tp = MINSTREL_TRUNC(mrs->cur_tp / 10); 172 tp = MINSTREL_TRUNC(mrs->cur_tp / 10);
173 prob = MINSTREL_TRUNC(mrs->cur_prob * 1000); 173 prob = MINSTREL_TRUNC(mrs->cur_prob * 1000);
174 eprob = MINSTREL_TRUNC(mrs->probability * 1000); 174 eprob = MINSTREL_TRUNC(mrs->prob_ewma * 1000);
175 175
176 p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u,%u,%u," 176 p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u,%u,%u,"
177 "%llu,%llu,%d,%d\n", 177 "%llu,%llu,%d,%d\n",
diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c
index 7afa5623a5ee..aca8b642661c 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -320,16 +320,16 @@ minstrel_get_ratestats(struct minstrel_ht_sta *mi, int index)
320static void 320static void
321minstrel_ht_calc_tp(struct minstrel_ht_sta *mi, int group, int rate) 321minstrel_ht_calc_tp(struct minstrel_ht_sta *mi, int group, int rate)
322{ 322{
323 struct minstrel_rate_stats *mr; 323 struct minstrel_rate_stats *mrs;
324 unsigned int nsecs = 0; 324 unsigned int nsecs = 0;
325 unsigned int tp; 325 unsigned int tmp_prob_ewma;
326 unsigned int prob;
327 326
328 mr = &mi->groups[group].rates[rate]; 327 mrs = &mi->groups[group].rates[rate];
329 prob = mr->probability; 328 tmp_prob_ewma = mrs->prob_ewma;
330 329
331 if (prob < MINSTREL_FRAC(1, 10)) { 330 /* do not account throughput if sucess prob is below 10% */
332 mr->cur_tp = 0; 331 if (mrs->prob_ewma < MINSTREL_FRAC(10, 100)) {
332 mrs->cur_tp = 0;
333 return; 333 return;
334 } 334 }
335 335
@@ -337,8 +337,8 @@ minstrel_ht_calc_tp(struct minstrel_ht_sta *mi, int group, int rate)
337 * For the throughput calculation, limit the probability value to 90% to 337 * For the throughput calculation, limit the probability value to 90% to
338 * account for collision related packet error rate fluctuation 338 * account for collision related packet error rate fluctuation
339 */ 339 */
340 if (prob > MINSTREL_FRAC(9, 10)) 340 if (mrs->prob_ewma > MINSTREL_FRAC(90, 100))
341 prob = MINSTREL_FRAC(9, 10); 341 tmp_prob_ewma = MINSTREL_FRAC(90, 100);
342 342
343 if (group != MINSTREL_CCK_GROUP) 343 if (group != MINSTREL_CCK_GROUP)
344 nsecs = 1000 * mi->overhead / MINSTREL_TRUNC(mi->avg_ampdu_len); 344 nsecs = 1000 * mi->overhead / MINSTREL_TRUNC(mi->avg_ampdu_len);
@@ -346,8 +346,7 @@ minstrel_ht_calc_tp(struct minstrel_ht_sta *mi, int group, int rate)
346 nsecs += minstrel_mcs_groups[group].duration[rate]; 346 nsecs += minstrel_mcs_groups[group].duration[rate];
347 347
348 /* prob is scaled - see MINSTREL_FRAC above */ 348 /* prob is scaled - see MINSTREL_FRAC above */
349 tp = 1000000 * ((prob * 1000) / nsecs); 349 mrs->cur_tp = MINSTREL_TRUNC(1000000 * ((tmp_prob_ewma * 1000) / nsecs));
350 mr->cur_tp = MINSTREL_TRUNC(tp);
351} 350}
352 351
353/* 352/*
@@ -368,13 +367,13 @@ minstrel_ht_sort_best_tp_rates(struct minstrel_ht_sta *mi, u16 index,
368 cur_group = index / MCS_GROUP_RATES; 367 cur_group = index / MCS_GROUP_RATES;
369 cur_idx = index % MCS_GROUP_RATES; 368 cur_idx = index % MCS_GROUP_RATES;
370 cur_thr = mi->groups[cur_group].rates[cur_idx].cur_tp; 369 cur_thr = mi->groups[cur_group].rates[cur_idx].cur_tp;
371 cur_prob = mi->groups[cur_group].rates[cur_idx].probability; 370 cur_prob = mi->groups[cur_group].rates[cur_idx].prob_ewma;
372 371
373 do { 372 do {
374 tmp_group = tp_list[j - 1] / MCS_GROUP_RATES; 373 tmp_group = tp_list[j - 1] / MCS_GROUP_RATES;
375 tmp_idx = tp_list[j - 1] % MCS_GROUP_RATES; 374 tmp_idx = tp_list[j - 1] % MCS_GROUP_RATES;
376 tmp_thr = mi->groups[tmp_group].rates[tmp_idx].cur_tp; 375 tmp_thr = mi->groups[tmp_group].rates[tmp_idx].cur_tp;
377 tmp_prob = mi->groups[tmp_group].rates[tmp_idx].probability; 376 tmp_prob = mi->groups[tmp_group].rates[tmp_idx].prob_ewma;
378 if (cur_thr < tmp_thr || 377 if (cur_thr < tmp_thr ||
379 (cur_thr == tmp_thr && cur_prob <= tmp_prob)) 378 (cur_thr == tmp_thr && cur_prob <= tmp_prob))
380 break; 379 break;
@@ -396,16 +395,16 @@ static void
396minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, u16 index) 395minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, u16 index)
397{ 396{
398 struct minstrel_mcs_group_data *mg; 397 struct minstrel_mcs_group_data *mg;
399 struct minstrel_rate_stats *mr; 398 struct minstrel_rate_stats *mrs;
400 int tmp_group, tmp_idx, tmp_tp, tmp_prob, max_tp_group; 399 int tmp_group, tmp_idx, tmp_tp, tmp_prob, max_tp_group;
401 400
402 mg = &mi->groups[index / MCS_GROUP_RATES]; 401 mg = &mi->groups[index / MCS_GROUP_RATES];
403 mr = &mg->rates[index % MCS_GROUP_RATES]; 402 mrs = &mg->rates[index % MCS_GROUP_RATES];
404 403
405 tmp_group = mi->max_prob_rate / MCS_GROUP_RATES; 404 tmp_group = mi->max_prob_rate / MCS_GROUP_RATES;
406 tmp_idx = mi->max_prob_rate % MCS_GROUP_RATES; 405 tmp_idx = mi->max_prob_rate % MCS_GROUP_RATES;
407 tmp_tp = mi->groups[tmp_group].rates[tmp_idx].cur_tp; 406 tmp_tp = mi->groups[tmp_group].rates[tmp_idx].cur_tp;
408 tmp_prob = mi->groups[tmp_group].rates[tmp_idx].probability; 407 tmp_prob = mi->groups[tmp_group].rates[tmp_idx].prob_ewma;
409 408
410 /* if max_tp_rate[0] is from MCS_GROUP max_prob_rate get selected from 409 /* if max_tp_rate[0] is from MCS_GROUP max_prob_rate get selected from
411 * MCS_GROUP as well as CCK_GROUP rates do not allow aggregation */ 410 * MCS_GROUP as well as CCK_GROUP rates do not allow aggregation */
@@ -414,15 +413,15 @@ minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, u16 index)
414 (max_tp_group != MINSTREL_CCK_GROUP)) 413 (max_tp_group != MINSTREL_CCK_GROUP))
415 return; 414 return;
416 415
417 if (mr->probability > MINSTREL_FRAC(75, 100)) { 416 if (mrs->prob_ewma > MINSTREL_FRAC(75, 100)) {
418 if (mr->cur_tp > tmp_tp) 417 if (mrs->cur_tp > tmp_tp)
419 mi->max_prob_rate = index; 418 mi->max_prob_rate = index;
420 if (mr->cur_tp > mg->rates[mg->max_group_prob_rate].cur_tp) 419 if (mrs->cur_tp > mg->rates[mg->max_group_prob_rate].cur_tp)
421 mg->max_group_prob_rate = index; 420 mg->max_group_prob_rate = index;
422 } else { 421 } else {
423 if (mr->probability > tmp_prob) 422 if (mrs->prob_ewma > tmp_prob)
424 mi->max_prob_rate = index; 423 mi->max_prob_rate = index;
425 if (mr->probability > mg->rates[mg->max_group_prob_rate].probability) 424 if (mrs->prob_ewma > mg->rates[mg->max_group_prob_rate].prob_ewma)
426 mg->max_group_prob_rate = index; 425 mg->max_group_prob_rate = index;
427 } 426 }
428} 427}
@@ -467,7 +466,7 @@ static inline void
467minstrel_ht_prob_rate_reduce_streams(struct minstrel_ht_sta *mi) 466minstrel_ht_prob_rate_reduce_streams(struct minstrel_ht_sta *mi)
468{ 467{
469 struct minstrel_mcs_group_data *mg; 468 struct minstrel_mcs_group_data *mg;
470 struct minstrel_rate_stats *mr; 469 struct minstrel_rate_stats *mrs;
471 int tmp_max_streams, group; 470 int tmp_max_streams, group;
472 int tmp_tp = 0; 471 int tmp_tp = 0;
473 472
@@ -477,11 +476,11 @@ minstrel_ht_prob_rate_reduce_streams(struct minstrel_ht_sta *mi)
477 mg = &mi->groups[group]; 476 mg = &mi->groups[group];
478 if (!mg->supported || group == MINSTREL_CCK_GROUP) 477 if (!mg->supported || group == MINSTREL_CCK_GROUP)
479 continue; 478 continue;
480 mr = minstrel_get_ratestats(mi, mg->max_group_prob_rate); 479 mrs = minstrel_get_ratestats(mi, mg->max_group_prob_rate);
481 if (tmp_tp < mr->cur_tp && 480 if (tmp_tp < mrs->cur_tp &&
482 (minstrel_mcs_groups[group].streams < tmp_max_streams)) { 481 (minstrel_mcs_groups[group].streams < tmp_max_streams)) {
483 mi->max_prob_rate = mg->max_group_prob_rate; 482 mi->max_prob_rate = mg->max_group_prob_rate;
484 tmp_tp = mr->cur_tp; 483 tmp_tp = mrs->cur_tp;
485 } 484 }
486 } 485 }
487} 486}
@@ -499,7 +498,7 @@ static void
499minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) 498minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
500{ 499{
501 struct minstrel_mcs_group_data *mg; 500 struct minstrel_mcs_group_data *mg;
502 struct minstrel_rate_stats *mr; 501 struct minstrel_rate_stats *mrs;
503 int group, i, j; 502 int group, i, j;
504 u16 tmp_mcs_tp_rate[MAX_THR_RATES], tmp_group_tp_rate[MAX_THR_RATES]; 503 u16 tmp_mcs_tp_rate[MAX_THR_RATES], tmp_group_tp_rate[MAX_THR_RATES];
505 u16 tmp_cck_tp_rate[MAX_THR_RATES], index; 504 u16 tmp_cck_tp_rate[MAX_THR_RATES], index;
@@ -539,12 +538,12 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
539 538
540 index = MCS_GROUP_RATES * group + i; 539 index = MCS_GROUP_RATES * group + i;
541 540
542 mr = &mg->rates[i]; 541 mrs = &mg->rates[i];
543 mr->retry_updated = false; 542 mrs->retry_updated = false;
544 minstrel_calc_rate_stats(mr); 543 minstrel_calc_rate_stats(mrs);
545 minstrel_ht_calc_tp(mi, group, i); 544 minstrel_ht_calc_tp(mi, group, i);
546 545
547 if (!mr->cur_tp) 546 if (!mrs->cur_tp)
548 continue; 547 continue;
549 548
550 /* Find max throughput rate set */ 549 /* Find max throughput rate set */
@@ -588,7 +587,7 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
588#endif 587#endif
589 588
590 /* Reset update timer */ 589 /* Reset update timer */
591 mi->stats_update = jiffies; 590 mi->last_stats_update = jiffies;
592} 591}
593 592
594static bool 593static bool
@@ -611,7 +610,7 @@ minstrel_ht_txstat_valid(struct minstrel_priv *mp, struct ieee80211_tx_rate *rat
611} 610}
612 611
613static void 612static void
614minstrel_next_sample_idx(struct minstrel_ht_sta *mi) 613minstrel_set_next_sample_idx(struct minstrel_ht_sta *mi)
615{ 614{
616 struct minstrel_mcs_group_data *mg; 615 struct minstrel_mcs_group_data *mg;
617 616
@@ -752,7 +751,8 @@ minstrel_ht_tx_status(void *priv, struct ieee80211_supported_band *sband,
752 update = true; 751 update = true;
753 } 752 }
754 753
755 if (time_after(jiffies, mi->stats_update + (mp->update_interval / 2 * HZ) / 1000)) { 754 if (time_after(jiffies, mi->last_stats_update +
755 (mp->update_interval / 2 * HZ) / 1000)) {
756 update = true; 756 update = true;
757 minstrel_ht_update_stats(mp, mi); 757 minstrel_ht_update_stats(mp, mi);
758 } 758 }
@@ -765,7 +765,7 @@ static void
765minstrel_calc_retransmit(struct minstrel_priv *mp, struct minstrel_ht_sta *mi, 765minstrel_calc_retransmit(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
766 int index) 766 int index)
767{ 767{
768 struct minstrel_rate_stats *mr; 768 struct minstrel_rate_stats *mrs;
769 const struct mcs_group *group; 769 const struct mcs_group *group;
770 unsigned int tx_time, tx_time_rtscts, tx_time_data; 770 unsigned int tx_time, tx_time_rtscts, tx_time_data;
771 unsigned int cw = mp->cw_min; 771 unsigned int cw = mp->cw_min;
@@ -774,16 +774,16 @@ minstrel_calc_retransmit(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
774 unsigned int ampdu_len = MINSTREL_TRUNC(mi->avg_ampdu_len); 774 unsigned int ampdu_len = MINSTREL_TRUNC(mi->avg_ampdu_len);
775 unsigned int overhead = 0, overhead_rtscts = 0; 775 unsigned int overhead = 0, overhead_rtscts = 0;
776 776
777 mr = minstrel_get_ratestats(mi, index); 777 mrs = minstrel_get_ratestats(mi, index);
778 if (mr->probability < MINSTREL_FRAC(1, 10)) { 778 if (mrs->prob_ewma < MINSTREL_FRAC(1, 10)) {
779 mr->retry_count = 1; 779 mrs->retry_count = 1;
780 mr->retry_count_rtscts = 1; 780 mrs->retry_count_rtscts = 1;
781 return; 781 return;
782 } 782 }
783 783
784 mr->retry_count = 2; 784 mrs->retry_count = 2;
785 mr->retry_count_rtscts = 2; 785 mrs->retry_count_rtscts = 2;
786 mr->retry_updated = true; 786 mrs->retry_updated = true;
787 787
788 group = &minstrel_mcs_groups[index / MCS_GROUP_RATES]; 788 group = &minstrel_mcs_groups[index / MCS_GROUP_RATES];
789 tx_time_data = group->duration[index % MCS_GROUP_RATES] * ampdu_len / 1000; 789 tx_time_data = group->duration[index % MCS_GROUP_RATES] * ampdu_len / 1000;
@@ -814,9 +814,9 @@ minstrel_calc_retransmit(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
814 tx_time_rtscts += ctime + overhead_rtscts + tx_time_data; 814 tx_time_rtscts += ctime + overhead_rtscts + tx_time_data;
815 815
816 if (tx_time_rtscts < mp->segment_size) 816 if (tx_time_rtscts < mp->segment_size)
817 mr->retry_count_rtscts++; 817 mrs->retry_count_rtscts++;
818 } while ((tx_time < mp->segment_size) && 818 } while ((tx_time < mp->segment_size) &&
819 (++mr->retry_count < mp->max_retry)); 819 (++mrs->retry_count < mp->max_retry));
820} 820}
821 821
822 822
@@ -825,22 +825,22 @@ minstrel_ht_set_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
825 struct ieee80211_sta_rates *ratetbl, int offset, int index) 825 struct ieee80211_sta_rates *ratetbl, int offset, int index)
826{ 826{
827 const struct mcs_group *group = &minstrel_mcs_groups[index / MCS_GROUP_RATES]; 827 const struct mcs_group *group = &minstrel_mcs_groups[index / MCS_GROUP_RATES];
828 struct minstrel_rate_stats *mr; 828 struct minstrel_rate_stats *mrs;
829 u8 idx; 829 u8 idx;
830 u16 flags = group->flags; 830 u16 flags = group->flags;
831 831
832 mr = minstrel_get_ratestats(mi, index); 832 mrs = minstrel_get_ratestats(mi, index);
833 if (!mr->retry_updated) 833 if (!mrs->retry_updated)
834 minstrel_calc_retransmit(mp, mi, index); 834 minstrel_calc_retransmit(mp, mi, index);
835 835
836 if (mr->probability < MINSTREL_FRAC(20, 100) || !mr->retry_count) { 836 if (mrs->prob_ewma < MINSTREL_FRAC(20, 100) || !mrs->retry_count) {
837 ratetbl->rate[offset].count = 2; 837 ratetbl->rate[offset].count = 2;
838 ratetbl->rate[offset].count_rts = 2; 838 ratetbl->rate[offset].count_rts = 2;
839 ratetbl->rate[offset].count_cts = 2; 839 ratetbl->rate[offset].count_cts = 2;
840 } else { 840 } else {
841 ratetbl->rate[offset].count = mr->retry_count; 841 ratetbl->rate[offset].count = mrs->retry_count;
842 ratetbl->rate[offset].count_cts = mr->retry_count; 842 ratetbl->rate[offset].count_cts = mrs->retry_count;
843 ratetbl->rate[offset].count_rts = mr->retry_count_rtscts; 843 ratetbl->rate[offset].count_rts = mrs->retry_count_rtscts;
844 } 844 }
845 845
846 if (index / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) 846 if (index / MCS_GROUP_RATES == MINSTREL_CCK_GROUP)
@@ -898,7 +898,7 @@ minstrel_get_duration(int index)
898static int 898static int
899minstrel_get_sample_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) 899minstrel_get_sample_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
900{ 900{
901 struct minstrel_rate_stats *mr; 901 struct minstrel_rate_stats *mrs;
902 struct minstrel_mcs_group_data *mg; 902 struct minstrel_mcs_group_data *mg;
903 unsigned int sample_dur, sample_group, cur_max_tp_streams; 903 unsigned int sample_dur, sample_group, cur_max_tp_streams;
904 int sample_idx = 0; 904 int sample_idx = 0;
@@ -914,12 +914,12 @@ minstrel_get_sample_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
914 sample_group = mi->sample_group; 914 sample_group = mi->sample_group;
915 mg = &mi->groups[sample_group]; 915 mg = &mi->groups[sample_group];
916 sample_idx = sample_table[mg->column][mg->index]; 916 sample_idx = sample_table[mg->column][mg->index];
917 minstrel_next_sample_idx(mi); 917 minstrel_set_next_sample_idx(mi);
918 918
919 if (!(mg->supported & BIT(sample_idx))) 919 if (!(mg->supported & BIT(sample_idx)))
920 return -1; 920 return -1;
921 921
922 mr = &mg->rates[sample_idx]; 922 mrs = &mg->rates[sample_idx];
923 sample_idx += sample_group * MCS_GROUP_RATES; 923 sample_idx += sample_group * MCS_GROUP_RATES;
924 924
925 /* 925 /*
@@ -936,7 +936,7 @@ minstrel_get_sample_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
936 * Do not sample if the probability is already higher than 95% 936 * Do not sample if the probability is already higher than 95%
937 * to avoid wasting airtime. 937 * to avoid wasting airtime.
938 */ 938 */
939 if (mr->probability > MINSTREL_FRAC(95, 100)) 939 if (mrs->prob_ewma > MINSTREL_FRAC(95, 100))
940 return -1; 940 return -1;
941 941
942 /* 942 /*
@@ -951,7 +951,7 @@ minstrel_get_sample_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
951 (cur_max_tp_streams - 1 < 951 (cur_max_tp_streams - 1 <
952 minstrel_mcs_groups[sample_group].streams || 952 minstrel_mcs_groups[sample_group].streams ||
953 sample_dur >= minstrel_get_duration(mi->max_prob_rate))) { 953 sample_dur >= minstrel_get_duration(mi->max_prob_rate))) {
954 if (mr->sample_skipped < 20) 954 if (mrs->sample_skipped < 20)
955 return -1; 955 return -1;
956 956
957 if (mi->sample_slow++ > 2) 957 if (mi->sample_slow++ > 2)
@@ -1105,7 +1105,7 @@ minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband,
1105 memset(mi, 0, sizeof(*mi)); 1105 memset(mi, 0, sizeof(*mi));
1106 1106
1107 mi->sta = sta; 1107 mi->sta = sta;
1108 mi->stats_update = jiffies; 1108 mi->last_stats_update = jiffies;
1109 1109
1110 ack_dur = ieee80211_frame_duration(sband->band, 10, 60, 1, 1, 0); 1110 ack_dur = ieee80211_frame_duration(sband->band, 10, 60, 1, 1, 0);
1111 mi->overhead = ieee80211_frame_duration(sband->band, 0, 60, 1, 1, 0); 1111 mi->overhead = ieee80211_frame_duration(sband->band, 0, 60, 1, 1, 0);
diff --git a/net/mac80211/rc80211_minstrel_ht.h b/net/mac80211/rc80211_minstrel_ht.h
index 3cc30e8f0613..fa21a82b72c4 100644
--- a/net/mac80211/rc80211_minstrel_ht.h
+++ b/net/mac80211/rc80211_minstrel_ht.h
@@ -78,7 +78,7 @@ struct minstrel_ht_sta {
78 u16 max_prob_rate; 78 u16 max_prob_rate;
79 79
80 /* time of last status update */ 80 /* time of last status update */
81 unsigned long stats_update; 81 unsigned long last_stats_update;
82 82
83 /* overhead time in usec for each frame */ 83 /* overhead time in usec for each frame */
84 unsigned int overhead; 84 unsigned int overhead;
diff --git a/net/mac80211/rc80211_minstrel_ht_debugfs.c b/net/mac80211/rc80211_minstrel_ht_debugfs.c
index 95731e639d4e..84183dee9ef2 100644
--- a/net/mac80211/rc80211_minstrel_ht_debugfs.c
+++ b/net/mac80211/rc80211_minstrel_ht_debugfs.c
@@ -38,7 +38,7 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p)
38 gimode = 'S'; 38 gimode = 'S';
39 39
40 for (j = 0; j < MCS_GROUP_RATES; j++) { 40 for (j = 0; j < MCS_GROUP_RATES; j++) {
41 struct minstrel_rate_stats *mr = &mi->groups[i].rates[j]; 41 struct minstrel_rate_stats *mrs = &mi->groups[i].rates[j];
42 static const int bitrates[4] = { 10, 20, 55, 110 }; 42 static const int bitrates[4] = { 10, 20, 55, 110 };
43 int idx = i * MCS_GROUP_RATES + j; 43 int idx = i * MCS_GROUP_RATES + j;
44 44
@@ -81,20 +81,20 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p)
81 tx_time = DIV_ROUND_CLOSEST(mg->duration[j], 1000); 81 tx_time = DIV_ROUND_CLOSEST(mg->duration[j], 1000);
82 p += sprintf(p, "%6u ", tx_time); 82 p += sprintf(p, "%6u ", tx_time);
83 83
84 tp = mr->cur_tp / 10; 84 tp = mrs->cur_tp / 10;
85 prob = MINSTREL_TRUNC(mr->cur_prob * 1000); 85 prob = MINSTREL_TRUNC(mrs->cur_prob * 1000);
86 eprob = MINSTREL_TRUNC(mr->probability * 1000); 86 eprob = MINSTREL_TRUNC(mrs->prob_ewma * 1000);
87 87
88 p += sprintf(p, "%4u.%1u %3u.%1u %3u.%1u " 88 p += sprintf(p, "%4u.%1u %3u.%1u %3u.%1u "
89 "%3u %3u %-3u %9llu %-9llu\n", 89 "%3u %3u %-3u %9llu %-9llu\n",
90 tp / 10, tp % 10, 90 tp / 10, tp % 10,
91 eprob / 10, eprob % 10, 91 eprob / 10, eprob % 10,
92 prob / 10, prob % 10, 92 prob / 10, prob % 10,
93 mr->retry_count, 93 mrs->retry_count,
94 mr->last_success, 94 mrs->last_success,
95 mr->last_attempts, 95 mrs->last_attempts,
96 (unsigned long long)mr->succ_hist, 96 (unsigned long long)mrs->succ_hist,
97 (unsigned long long)mr->att_hist); 97 (unsigned long long)mrs->att_hist);
98 } 98 }
99 99
100 return p; 100 return p;
@@ -182,7 +182,7 @@ minstrel_ht_stats_csv_dump(struct minstrel_ht_sta *mi, int i, char *p)
182 gimode = 'S'; 182 gimode = 'S';
183 183
184 for (j = 0; j < MCS_GROUP_RATES; j++) { 184 for (j = 0; j < MCS_GROUP_RATES; j++) {
185 struct minstrel_rate_stats *mr = &mi->groups[i].rates[j]; 185 struct minstrel_rate_stats *mrs = &mi->groups[i].rates[j];
186 static const int bitrates[4] = { 10, 20, 55, 110 }; 186 static const int bitrates[4] = { 10, 20, 55, 110 };
187 int idx = i * MCS_GROUP_RATES + j; 187 int idx = i * MCS_GROUP_RATES + j;
188 188
@@ -222,19 +222,19 @@ minstrel_ht_stats_csv_dump(struct minstrel_ht_sta *mi, int i, char *p)
222 tx_time = DIV_ROUND_CLOSEST(mg->duration[j], 1000); 222 tx_time = DIV_ROUND_CLOSEST(mg->duration[j], 1000);
223 p += sprintf(p, "%u,", tx_time); 223 p += sprintf(p, "%u,", tx_time);
224 224
225 tp = mr->cur_tp / 10; 225 tp = mrs->cur_tp / 10;
226 prob = MINSTREL_TRUNC(mr->cur_prob * 1000); 226 prob = MINSTREL_TRUNC(mrs->cur_prob * 1000);
227 eprob = MINSTREL_TRUNC(mr->probability * 1000); 227 eprob = MINSTREL_TRUNC(mrs->prob_ewma * 1000);
228 228
229 p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u,%u,%u,%llu,%llu,", 229 p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u,%u,%u,%llu,%llu,",
230 tp / 10, tp % 10, 230 tp / 10, tp % 10,
231 eprob / 10, eprob % 10, 231 eprob / 10, eprob % 10,
232 prob / 10, prob % 10, 232 prob / 10, prob % 10,
233 mr->retry_count, 233 mrs->retry_count,
234 mr->last_success, 234 mrs->last_success,
235 mr->last_attempts, 235 mrs->last_attempts,
236 (unsigned long long)mr->succ_hist, 236 (unsigned long long)mrs->succ_hist,
237 (unsigned long long)mr->att_hist); 237 (unsigned long long)mrs->att_hist);
238 p += sprintf(p, "%d,%d,%d.%d\n", 238 p += sprintf(p, "%d,%d,%d.%d\n",
239 max(0, (int) mi->total_packets - 239 max(0, (int) mi->total_packets -
240 (int) mi->sample_packets), 240 (int) mi->sample_packets),