Commit 9134073b authored by Thomas Huehn's avatar Thomas Huehn Committed by Johannes Berg

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: default avatarThomas Huehn <thomas@net.t-labs.tu-berlin.de>
Acked-by: default avatarFelix Fietkau <nbd@openwrt.org>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent f62838bc
...@@ -137,9 +137,9 @@ minstrel_calc_rate_stats(struct minstrel_rate_stats *mrs) ...@@ -137,9 +137,9 @@ minstrel_calc_rate_stats(struct minstrel_rate_stats *mrs)
mrs->sample_skipped = 0; mrs->sample_skipped = 0;
mrs->cur_prob = MINSTREL_FRAC(mrs->success, mrs->attempts); mrs->cur_prob = MINSTREL_FRAC(mrs->success, mrs->attempts);
if (unlikely(!mrs->att_hist)) if (unlikely(!mrs->att_hist))
mrs->probability = mrs->cur_prob; mrs->prob_ewma = mrs->cur_prob;
else else
mrs->probability = minstrel_ewma(mrs->probability, mrs->prob_ewma = minstrel_ewma(mrs->prob_ewma,
mrs->cur_prob, EWMA_LEVEL); mrs->cur_prob, EWMA_LEVEL);
mrs->att_hist += mrs->attempts; mrs->att_hist += mrs->attempts;
mrs->succ_hist += mrs->success; mrs->succ_hist += mrs->success;
...@@ -176,15 +176,15 @@ minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi) ...@@ -176,15 +176,15 @@ minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
minstrel_calc_rate_stats(mrs); minstrel_calc_rate_stats(mrs);
/* Update throughput per rate, reset thr. below 10% success */ /* Update throughput per rate, reset thr. below 10% success */
if (mrs->probability < MINSTREL_FRAC(10, 100)) if (mrs->prob_ewma < MINSTREL_FRAC(10, 100))
mrs->cur_tp = 0; mrs->cur_tp = 0;
else else
mrs->cur_tp = mrs->probability * (1000000 / usecs); mrs->cur_tp = mrs->prob_ewma * (1000000 / usecs);
/* Sample less often below the 10% chance of success. /* Sample less often below the 10% chance of success.
* Sample less often above the 95% chance of success. */ * Sample less often above the 95% chance of success. */
if (mrs->probability > MINSTREL_FRAC(95, 100) || if (mrs->prob_ewma > MINSTREL_FRAC(95, 100) ||
mrs->probability < MINSTREL_FRAC(10, 100)) { mrs->prob_ewma < MINSTREL_FRAC(10, 100)) {
mr->adjusted_retry_count = mrs->retry_count >> 1; mr->adjusted_retry_count = mrs->retry_count >> 1;
if (mr->adjusted_retry_count > 2) if (mr->adjusted_retry_count > 2)
mr->adjusted_retry_count = 2; mr->adjusted_retry_count = 2;
...@@ -204,11 +204,11 @@ minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi) ...@@ -204,11 +204,11 @@ minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
* choose the maximum throughput rate as max_prob_rate * choose the maximum throughput rate as max_prob_rate
* (2) if all success probabilities < 95%, the rate with * (2) if all success probabilities < 95%, the rate with
* highest success probability is chosen as max_prob_rate */ * highest success probability is chosen as max_prob_rate */
if (mrs->probability >= MINSTREL_FRAC(95, 100)) { if (mrs->prob_ewma >= MINSTREL_FRAC(95, 100)) {
if (mrs->cur_tp >= mi->r[tmp_prob_rate].stats.cur_tp) if (mrs->cur_tp >= mi->r[tmp_prob_rate].stats.cur_tp)
tmp_prob_rate = i; tmp_prob_rate = i;
} else { } else {
if (mrs->probability >= mi->r[tmp_prob_rate].stats.probability) if (mrs->prob_ewma >= mi->r[tmp_prob_rate].stats.prob_ewma)
tmp_prob_rate = i; tmp_prob_rate = i;
} }
} }
...@@ -227,7 +227,7 @@ minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi) ...@@ -227,7 +227,7 @@ minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
#endif #endif
/* Reset update timer */ /* Reset update timer */
mi->stats_update = jiffies; mi->last_stats_update = jiffies;
minstrel_update_rates(mp, mi); minstrel_update_rates(mp, mi);
} }
...@@ -265,7 +265,7 @@ minstrel_tx_status(void *priv, struct ieee80211_supported_band *sband, ...@@ -265,7 +265,7 @@ minstrel_tx_status(void *priv, struct ieee80211_supported_band *sband,
if (mi->sample_deferred > 0) if (mi->sample_deferred > 0)
mi->sample_deferred--; mi->sample_deferred--;
if (time_after(jiffies, mi->stats_update + if (time_after(jiffies, mi->last_stats_update +
(mp->update_interval * HZ) / 1000)) (mp->update_interval * HZ) / 1000))
minstrel_update_stats(mp, mi); minstrel_update_stats(mp, mi);
} }
...@@ -397,7 +397,7 @@ minstrel_get_rate(void *priv, struct ieee80211_sta *sta, ...@@ -397,7 +397,7 @@ minstrel_get_rate(void *priv, struct ieee80211_sta *sta,
* has a probability of >95%, we shouldn't be attempting * has a probability of >95%, we shouldn't be attempting
* to use it, as this only wastes precious airtime */ * to use it, as this only wastes precious airtime */
if (!mrr_capable && if (!mrr_capable &&
(mi->r[ndx].stats.probability > MINSTREL_FRAC(95, 100))) (mi->r[ndx].stats.prob_ewma > MINSTREL_FRAC(95, 100)))
return; return;
mi->prev_sample = true; mi->prev_sample = true;
...@@ -531,7 +531,7 @@ minstrel_rate_init(void *priv, struct ieee80211_supported_band *sband, ...@@ -531,7 +531,7 @@ minstrel_rate_init(void *priv, struct ieee80211_supported_band *sband,
} }
mi->n_rates = n; mi->n_rates = n;
mi->stats_update = jiffies; mi->last_stats_update = jiffies;
init_sample_table(mi); init_sample_table(mi);
minstrel_update_rates(mp, mi); minstrel_update_rates(mp, mi);
...@@ -565,7 +565,7 @@ minstrel_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp) ...@@ -565,7 +565,7 @@ minstrel_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp)
if (!mi->sample_table) if (!mi->sample_table)
goto error1; goto error1;
mi->stats_update = jiffies; mi->last_stats_update = jiffies;
return mi; return mi;
error1: error1:
......
...@@ -38,11 +38,14 @@ struct minstrel_rate_stats { ...@@ -38,11 +38,14 @@ struct minstrel_rate_stats {
/* total attempts/success counters */ /* total attempts/success counters */
u64 att_hist, succ_hist; u64 att_hist, succ_hist;
/* current throughput */ /* current EWMA of rate throughput */
unsigned int cur_tp; unsigned int cur_tp;
/* packet delivery probabilities */ /* statistis of packet delivery probability
unsigned int cur_prob, probability; * cur_prob - current prob within last update intervall
* prob_ewma - exponential weighted moving average of prob */
unsigned int cur_prob;
unsigned int prob_ewma;
/* maximum retry counts */ /* maximum retry counts */
u8 retry_count; u8 retry_count;
...@@ -70,7 +73,7 @@ struct minstrel_rate { ...@@ -70,7 +73,7 @@ struct minstrel_rate {
struct minstrel_sta_info { struct minstrel_sta_info {
struct ieee80211_sta *sta; struct ieee80211_sta *sta;
unsigned long stats_update; unsigned long last_stats_update;
unsigned int sp_ack_dur; unsigned int sp_ack_dur;
unsigned int rate_avg; unsigned int rate_avg;
...@@ -133,7 +136,7 @@ void minstrel_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir); ...@@ -133,7 +136,7 @@ void minstrel_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir);
void minstrel_remove_sta_debugfs(void *priv, void *priv_sta); void minstrel_remove_sta_debugfs(void *priv, void *priv_sta);
/* Recalculate success probabilities and counters for a given rate using EWMA */ /* Recalculate success probabilities and counters for a given rate using EWMA */
void minstrel_calc_rate_stats(struct minstrel_rate_stats *mr); void minstrel_calc_rate_stats(struct minstrel_rate_stats *mrs);
/* debugfs */ /* debugfs */
int minstrel_stats_open(struct inode *inode, struct file *file); int minstrel_stats_open(struct inode *inode, struct file *file);
......
...@@ -107,7 +107,7 @@ minstrel_stats_open(struct inode *inode, struct file *file) ...@@ -107,7 +107,7 @@ minstrel_stats_open(struct inode *inode, struct file *file)
tp = MINSTREL_TRUNC(mrs->cur_tp / 10); tp = MINSTREL_TRUNC(mrs->cur_tp / 10);
prob = MINSTREL_TRUNC(mrs->cur_prob * 1000); prob = MINSTREL_TRUNC(mrs->cur_prob * 1000);
eprob = MINSTREL_TRUNC(mrs->probability * 1000); eprob = MINSTREL_TRUNC(mrs->prob_ewma * 1000);
p += sprintf(p, " %4u.%1u %3u.%1u %3u.%1u %3u" p += sprintf(p, " %4u.%1u %3u.%1u %3u.%1u %3u"
" %3u %-3u %9llu %-9llu\n", " %3u %-3u %9llu %-9llu\n",
...@@ -171,7 +171,7 @@ minstrel_stats_csv_open(struct inode *inode, struct file *file) ...@@ -171,7 +171,7 @@ minstrel_stats_csv_open(struct inode *inode, struct file *file)
tp = MINSTREL_TRUNC(mrs->cur_tp / 10); tp = MINSTREL_TRUNC(mrs->cur_tp / 10);
prob = MINSTREL_TRUNC(mrs->cur_prob * 1000); prob = MINSTREL_TRUNC(mrs->cur_prob * 1000);
eprob = MINSTREL_TRUNC(mrs->probability * 1000); eprob = MINSTREL_TRUNC(mrs->prob_ewma * 1000);
p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u,%u,%u," p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u,%u,%u,"
"%llu,%llu,%d,%d\n", "%llu,%llu,%d,%d\n",
......
This diff is collapsed.
...@@ -78,7 +78,7 @@ struct minstrel_ht_sta { ...@@ -78,7 +78,7 @@ struct minstrel_ht_sta {
u16 max_prob_rate; u16 max_prob_rate;
/* time of last status update */ /* time of last status update */
unsigned long stats_update; unsigned long last_stats_update;
/* overhead time in usec for each frame */ /* overhead time in usec for each frame */
unsigned int overhead; unsigned int overhead;
......
...@@ -38,7 +38,7 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p) ...@@ -38,7 +38,7 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p)
gimode = 'S'; gimode = 'S';
for (j = 0; j < MCS_GROUP_RATES; j++) { for (j = 0; j < MCS_GROUP_RATES; j++) {
struct minstrel_rate_stats *mr = &mi->groups[i].rates[j]; struct minstrel_rate_stats *mrs = &mi->groups[i].rates[j];
static const int bitrates[4] = { 10, 20, 55, 110 }; static const int bitrates[4] = { 10, 20, 55, 110 };
int idx = i * MCS_GROUP_RATES + j; int idx = i * MCS_GROUP_RATES + j;
...@@ -81,20 +81,20 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p) ...@@ -81,20 +81,20 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p)
tx_time = DIV_ROUND_CLOSEST(mg->duration[j], 1000); tx_time = DIV_ROUND_CLOSEST(mg->duration[j], 1000);
p += sprintf(p, "%6u ", tx_time); p += sprintf(p, "%6u ", tx_time);
tp = mr->cur_tp / 10; tp = mrs->cur_tp / 10;
prob = MINSTREL_TRUNC(mr->cur_prob * 1000); prob = MINSTREL_TRUNC(mrs->cur_prob * 1000);
eprob = MINSTREL_TRUNC(mr->probability * 1000); eprob = MINSTREL_TRUNC(mrs->prob_ewma * 1000);
p += sprintf(p, "%4u.%1u %3u.%1u %3u.%1u " p += sprintf(p, "%4u.%1u %3u.%1u %3u.%1u "
"%3u %3u %-3u %9llu %-9llu\n", "%3u %3u %-3u %9llu %-9llu\n",
tp / 10, tp % 10, tp / 10, tp % 10,
eprob / 10, eprob % 10, eprob / 10, eprob % 10,
prob / 10, prob % 10, prob / 10, prob % 10,
mr->retry_count, mrs->retry_count,
mr->last_success, mrs->last_success,
mr->last_attempts, mrs->last_attempts,
(unsigned long long)mr->succ_hist, (unsigned long long)mrs->succ_hist,
(unsigned long long)mr->att_hist); (unsigned long long)mrs->att_hist);
} }
return p; return p;
...@@ -182,7 +182,7 @@ minstrel_ht_stats_csv_dump(struct minstrel_ht_sta *mi, int i, char *p) ...@@ -182,7 +182,7 @@ minstrel_ht_stats_csv_dump(struct minstrel_ht_sta *mi, int i, char *p)
gimode = 'S'; gimode = 'S';
for (j = 0; j < MCS_GROUP_RATES; j++) { for (j = 0; j < MCS_GROUP_RATES; j++) {
struct minstrel_rate_stats *mr = &mi->groups[i].rates[j]; struct minstrel_rate_stats *mrs = &mi->groups[i].rates[j];
static const int bitrates[4] = { 10, 20, 55, 110 }; static const int bitrates[4] = { 10, 20, 55, 110 };
int idx = i * MCS_GROUP_RATES + j; int idx = i * MCS_GROUP_RATES + j;
...@@ -222,19 +222,19 @@ minstrel_ht_stats_csv_dump(struct minstrel_ht_sta *mi, int i, char *p) ...@@ -222,19 +222,19 @@ minstrel_ht_stats_csv_dump(struct minstrel_ht_sta *mi, int i, char *p)
tx_time = DIV_ROUND_CLOSEST(mg->duration[j], 1000); tx_time = DIV_ROUND_CLOSEST(mg->duration[j], 1000);
p += sprintf(p, "%u,", tx_time); p += sprintf(p, "%u,", tx_time);
tp = mr->cur_tp / 10; tp = mrs->cur_tp / 10;
prob = MINSTREL_TRUNC(mr->cur_prob * 1000); prob = MINSTREL_TRUNC(mrs->cur_prob * 1000);
eprob = MINSTREL_TRUNC(mr->probability * 1000); eprob = MINSTREL_TRUNC(mrs->prob_ewma * 1000);
p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u,%u,%u,%llu,%llu,", p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u,%u,%u,%llu,%llu,",
tp / 10, tp % 10, tp / 10, tp % 10,
eprob / 10, eprob % 10, eprob / 10, eprob % 10,
prob / 10, prob % 10, prob / 10, prob % 10,
mr->retry_count, mrs->retry_count,
mr->last_success, mrs->last_success,
mr->last_attempts, mrs->last_attempts,
(unsigned long long)mr->succ_hist, (unsigned long long)mrs->succ_hist,
(unsigned long long)mr->att_hist); (unsigned long long)mrs->att_hist);
p += sprintf(p, "%d,%d,%d.%d\n", p += sprintf(p, "%d,%d,%d.%d\n",
max(0, (int) mi->total_packets - max(0, (int) mi->total_packets -
(int) mi->sample_packets), (int) mi->sample_packets),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment