Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a512d4b5 authored by Thomas Huehn's avatar Thomas Huehn Committed by Johannes Berg
Browse files

mac80211: merge EWMA calculation of minstrel_ht and minstrel



Both rate control algorithms (minstrel and minstrel_ht) calculate
averages based on EWMA. Shift function minstrel_ewma() into
rc80211_minstrel.h and make use of it in both minstrel version.
Also shift the default EWMA level (75%) definition to the header file
and clean up variable usage.

Acked-by: default avatarFelix Fietkau <nbd@openwrt.org>
Signed-off-by: default avatarThomas Huehn <thomas@net.t-labs.tu-berlin.de>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 52c00a37
Loading
Loading
Loading
Loading
+5 −10
Original line number Original line Diff line number Diff line
@@ -76,7 +76,6 @@ minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
	u32 max_tp = 0, index_max_tp = 0, index_max_tp2 = 0;
	u32 max_tp = 0, index_max_tp = 0, index_max_tp2 = 0;
	u32 max_prob = 0, index_max_prob = 0;
	u32 max_prob = 0, index_max_prob = 0;
	u32 usecs;
	u32 usecs;
	u32 p;
	int i;
	int i;


	mi->stats_update = jiffies;
	mi->stats_update = jiffies;
@@ -90,14 +89,13 @@ minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
		/* To avoid rounding issues, probabilities scale from 0 (0%)
		/* To avoid rounding issues, probabilities scale from 0 (0%)
		 * to 18000 (100%) */
		 * to 18000 (100%) */
		if (mr->attempts) {
		if (mr->attempts) {
			p = (mr->success * 18000) / mr->attempts;
			mr->cur_prob = (mr->success * 18000) / mr->attempts;
			mr->succ_hist += mr->success;
			mr->succ_hist += mr->success;
			mr->att_hist += mr->attempts;
			mr->att_hist += mr->attempts;
			mr->cur_prob = p;
			mr->probability = minstrel_ewma(mr->probability,
			p = ((p * (100 - mp->ewma_level)) + (mr->probability *
							mr->cur_prob,
				mp->ewma_level)) / 100;
							EWMA_LEVEL);
			mr->probability = p;
			mr->cur_tp = mr->probability * (1000000 / usecs);
			mr->cur_tp = p * (1000000 / usecs);
		}
		}


		mr->last_success = mr->success;
		mr->last_success = mr->success;
@@ -542,9 +540,6 @@ minstrel_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir)
	mp->lookaround_rate = 5;
	mp->lookaround_rate = 5;
	mp->lookaround_rate_mrr = 10;
	mp->lookaround_rate_mrr = 10;


	/* moving average weight for EWMA */
	mp->ewma_level = 75;

	/* maximum time that the hw is allowed to stay in one MRR segment */
	/* maximum time that the hw is allowed to stay in one MRR segment */
	mp->segment_size = 6000;
	mp->segment_size = 6000;


+12 −1
Original line number Original line Diff line number Diff line
@@ -9,6 +9,18 @@
#ifndef __RC_MINSTREL_H
#ifndef __RC_MINSTREL_H
#define __RC_MINSTREL_H
#define __RC_MINSTREL_H


#define EWMA_LEVEL 75	/* ewma weighting factor [%] */

/*
 * Perform EWMA (Exponentially Weighted Moving Average) calculation
  */
static inline int
minstrel_ewma(int old, int new, int weight)
{
	return (new * (100 - weight) + old * weight) / 100;
}


struct minstrel_rate {
struct minstrel_rate {
	int bitrate;
	int bitrate;
	int rix;
	int rix;
@@ -73,7 +85,6 @@ struct minstrel_priv {
	unsigned int cw_min;
	unsigned int cw_min;
	unsigned int cw_max;
	unsigned int cw_max;
	unsigned int max_retry;
	unsigned int max_retry;
	unsigned int ewma_level;
	unsigned int segment_size;
	unsigned int segment_size;
	unsigned int update_interval;
	unsigned int update_interval;
	unsigned int lookaround_rate;
	unsigned int lookaround_rate;
+0 −10
Original line number Original line Diff line number Diff line
@@ -18,7 +18,6 @@


#define AVG_PKT_SIZE	1200
#define AVG_PKT_SIZE	1200
#define SAMPLE_COLUMNS	10
#define SAMPLE_COLUMNS	10
#define EWMA_LEVEL		75


/* Number of bits for an average sized packet */
/* Number of bits for an average sized packet */
#define MCS_NBITS (AVG_PKT_SIZE << 3)
#define MCS_NBITS (AVG_PKT_SIZE << 3)
@@ -128,15 +127,6 @@ const struct mcs_group minstrel_mcs_groups[] = {


static u8 sample_table[SAMPLE_COLUMNS][MCS_GROUP_RATES];
static u8 sample_table[SAMPLE_COLUMNS][MCS_GROUP_RATES];


/*
 * Perform EWMA (Exponentially Weighted Moving Average) calculation
 */
static int
minstrel_ewma(int old, int new, int weight)
{
	return (new * (100 - weight) + old * weight) / 100;
}

/*
/*
 * Look up an MCS group index based on mac80211 rate information
 * Look up an MCS group index based on mac80211 rate information
 */
 */