Skip to content

Commit 9134073

Browse files
thuehnjmberg-intel
authored andcommitted
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 <[email protected]> Acked-by: Felix Fietkau <[email protected]> Signed-off-by: Johannes Berg <[email protected]>
1 parent f62838b commit 9134073

File tree

6 files changed

+98
-95
lines changed

6 files changed

+98
-95
lines changed

net/mac80211/rc80211_minstrel.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ minstrel_calc_rate_stats(struct minstrel_rate_stats *mrs)
137137
mrs->sample_skipped = 0;
138138
mrs->cur_prob = MINSTREL_FRAC(mrs->success, mrs->attempts);
139139
if (unlikely(!mrs->att_hist))
140-
mrs->probability = mrs->cur_prob;
140+
mrs->prob_ewma = mrs->cur_prob;
141141
else
142-
mrs->probability = minstrel_ewma(mrs->probability,
142+
mrs->prob_ewma = minstrel_ewma(mrs->prob_ewma,
143143
mrs->cur_prob, EWMA_LEVEL);
144144
mrs->att_hist += mrs->attempts;
145145
mrs->succ_hist += mrs->success;
@@ -176,15 +176,15 @@ minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
176176
minstrel_calc_rate_stats(mrs);
177177

178178
/* 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))
180180
mrs->cur_tp = 0;
181181
else
182-
mrs->cur_tp = mrs->probability * (1000000 / usecs);
182+
mrs->cur_tp = mrs->prob_ewma * (1000000 / usecs);
183183

184184
/* Sample less often below the 10% chance of success.
185185
* Sample less often above the 95% chance of success. */
186-
if (mrs->probability > MINSTREL_FRAC(95, 100) ||
187-
mrs->probability < MINSTREL_FRAC(10, 100)) {
186+
if (mrs->prob_ewma > MINSTREL_FRAC(95, 100) ||
187+
mrs->prob_ewma < MINSTREL_FRAC(10, 100)) {
188188
mr->adjusted_retry_count = mrs->retry_count >> 1;
189189
if (mr->adjusted_retry_count > 2)
190190
mr->adjusted_retry_count = 2;
@@ -204,11 +204,11 @@ minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
204204
* choose the maximum throughput rate as max_prob_rate
205205
* (2) if all success probabilities < 95%, the rate with
206206
* 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)) {
208208
if (mrs->cur_tp >= mi->r[tmp_prob_rate].stats.cur_tp)
209209
tmp_prob_rate = i;
210210
} 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)
212212
tmp_prob_rate = i;
213213
}
214214
}
@@ -227,7 +227,7 @@ minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
227227
#endif
228228

229229
/* Reset update timer */
230-
mi->stats_update = jiffies;
230+
mi->last_stats_update = jiffies;
231231

232232
minstrel_update_rates(mp, mi);
233233
}
@@ -265,7 +265,7 @@ minstrel_tx_status(void *priv, struct ieee80211_supported_band *sband,
265265
if (mi->sample_deferred > 0)
266266
mi->sample_deferred--;
267267

268-
if (time_after(jiffies, mi->stats_update +
268+
if (time_after(jiffies, mi->last_stats_update +
269269
(mp->update_interval * HZ) / 1000))
270270
minstrel_update_stats(mp, mi);
271271
}
@@ -397,7 +397,7 @@ minstrel_get_rate(void *priv, struct ieee80211_sta *sta,
397397
* has a probability of >95%, we shouldn't be attempting
398398
* to use it, as this only wastes precious airtime */
399399
if (!mrr_capable &&
400-
(mi->r[ndx].stats.probability > MINSTREL_FRAC(95, 100)))
400+
(mi->r[ndx].stats.prob_ewma > MINSTREL_FRAC(95, 100)))
401401
return;
402402

403403
mi->prev_sample = true;
@@ -531,7 +531,7 @@ minstrel_rate_init(void *priv, struct ieee80211_supported_band *sband,
531531
}
532532

533533
mi->n_rates = n;
534-
mi->stats_update = jiffies;
534+
mi->last_stats_update = jiffies;
535535

536536
init_sample_table(mi);
537537
minstrel_update_rates(mp, mi);
@@ -565,7 +565,7 @@ minstrel_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp)
565565
if (!mi->sample_table)
566566
goto error1;
567567

568-
mi->stats_update = jiffies;
568+
mi->last_stats_update = jiffies;
569569
return mi;
570570

571571
error1:

net/mac80211/rc80211_minstrel.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,14 @@ struct minstrel_rate_stats {
3838
/* total attempts/success counters */
3939
u64 att_hist, succ_hist;
4040

41-
/* current throughput */
41+
/* current EWMA of rate throughput */
4242
unsigned int cur_tp;
4343

44-
/* packet delivery probabilities */
45-
unsigned int cur_prob, probability;
44+
/* statistis of packet delivery 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;
4649

4750
/* maximum retry counts */
4851
u8 retry_count;
@@ -70,7 +73,7 @@ struct minstrel_rate {
7073
struct minstrel_sta_info {
7174
struct ieee80211_sta *sta;
7275

73-
unsigned long stats_update;
76+
unsigned long last_stats_update;
7477
unsigned int sp_ack_dur;
7578
unsigned int rate_avg;
7679

@@ -133,7 +136,7 @@ void minstrel_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir);
133136
void minstrel_remove_sta_debugfs(void *priv, void *priv_sta);
134137

135138
/* Recalculate success probabilities and counters for a given rate using EWMA */
136-
void minstrel_calc_rate_stats(struct minstrel_rate_stats *mr);
139+
void minstrel_calc_rate_stats(struct minstrel_rate_stats *mrs);
137140

138141
/* debugfs */
139142
int minstrel_stats_open(struct inode *inode, struct file *file);

net/mac80211/rc80211_minstrel_debugfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ minstrel_stats_open(struct inode *inode, struct file *file)
107107

108108
tp = MINSTREL_TRUNC(mrs->cur_tp / 10);
109109
prob = MINSTREL_TRUNC(mrs->cur_prob * 1000);
110-
eprob = MINSTREL_TRUNC(mrs->probability * 1000);
110+
eprob = MINSTREL_TRUNC(mrs->prob_ewma * 1000);
111111

112112
p += sprintf(p, " %4u.%1u %3u.%1u %3u.%1u %3u"
113113
" %3u %-3u %9llu %-9llu\n",
@@ -171,7 +171,7 @@ minstrel_stats_csv_open(struct inode *inode, struct file *file)
171171

172172
tp = MINSTREL_TRUNC(mrs->cur_tp / 10);
173173
prob = MINSTREL_TRUNC(mrs->cur_prob * 1000);
174-
eprob = MINSTREL_TRUNC(mrs->probability * 1000);
174+
eprob = MINSTREL_TRUNC(mrs->prob_ewma * 1000);
175175

176176
p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u,%u,%u,"
177177
"%llu,%llu,%d,%d\n",

0 commit comments

Comments
 (0)