Commit cbda98c7 authored by Felix Fietkau's avatar Felix Fietkau Committed by Johannes Berg

mac80211: remove legacy minstrel rate control

Now that minstrel_ht supports legacy rates, it is no longer needed
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
Link: https://lore.kernel.org/r/20210115120242.89616-4-nbd@nbd.nameSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent a7844a53
...@@ -56,11 +56,9 @@ mac80211-$(CONFIG_PM) += pm.o ...@@ -56,11 +56,9 @@ mac80211-$(CONFIG_PM) += pm.o
CFLAGS_trace.o := -I$(src) CFLAGS_trace.o := -I$(src)
rc80211_minstrel-y := \ rc80211_minstrel-y := \
rc80211_minstrel.o \
rc80211_minstrel_ht.o rc80211_minstrel_ht.o
rc80211_minstrel-$(CONFIG_MAC80211_DEBUGFS) += \ rc80211_minstrel-$(CONFIG_MAC80211_DEBUGFS) += \
rc80211_minstrel_debugfs.o \
rc80211_minstrel_ht_debugfs.o rc80211_minstrel_ht_debugfs.o
mac80211-$(CONFIG_MAC80211_RC_MINSTREL) += $(rc80211_minstrel-y) mac80211-$(CONFIG_MAC80211_RC_MINSTREL) += $(rc80211_minstrel-y)
......
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
*/
#ifndef __RC_MINSTREL_H
#define __RC_MINSTREL_H
#define EWMA_LEVEL 96 /* ewma weighting factor [/EWMA_DIV] */
#define EWMA_DIV 128
#define SAMPLE_COLUMNS 10 /* number of columns in sample table */
/* scaled fraction values */
#define MINSTREL_SCALE 12
#define MINSTREL_FRAC(val, div) (((val) << MINSTREL_SCALE) / div)
#define MINSTREL_TRUNC(val) ((val) >> MINSTREL_SCALE)
/* number of highest throughput rates to consider*/
#define MAX_THR_RATES 4
/*
* Coefficients for moving average with noise filter (period=16),
* scaled by 10 bits
*
* a1 = exp(-pi * sqrt(2) / period)
* coeff2 = 2 * a1 * cos(sqrt(2) * 2 * pi / period)
* coeff3 = -sqr(a1)
* coeff1 = 1 - coeff2 - coeff3
*/
#define MINSTREL_AVG_COEFF1 (MINSTREL_FRAC(1, 1) - \
MINSTREL_AVG_COEFF2 - \
MINSTREL_AVG_COEFF3)
#define MINSTREL_AVG_COEFF2 0x00001499
#define MINSTREL_AVG_COEFF3 -0x0000092e
/*
* Perform EWMA (Exponentially Weighted Moving Average) calculation
*/
static inline int
minstrel_ewma(int old, int new, int weight)
{
int diff, incr;
diff = new - old;
incr = (EWMA_DIV - weight) * diff / EWMA_DIV;
return old + incr;
}
static inline int minstrel_filter_avg_add(u16 *prev_1, u16 *prev_2, s32 in)
{
s32 out_1 = *prev_1;
s32 out_2 = *prev_2;
s32 val;
if (!in)
in += 1;
if (!out_1) {
val = out_1 = in;
goto out;
}
val = MINSTREL_AVG_COEFF1 * in;
val += MINSTREL_AVG_COEFF2 * out_1;
val += MINSTREL_AVG_COEFF3 * out_2;
val >>= MINSTREL_SCALE;
if (val > 1 << MINSTREL_SCALE)
val = 1 << MINSTREL_SCALE;
if (val < 0)
val = 1;
out:
*prev_2 = out_1;
*prev_1 = val;
return val;
}
struct minstrel_rate_stats {
/* current / last sampling period attempts/success counters */
u16 attempts, last_attempts;
u16 success, last_success;
/* total attempts/success counters */
u32 att_hist, succ_hist;
/* prob_avg - moving average of prob */
u16 prob_avg;
u16 prob_avg_1;
/* maximum retry counts */
u8 retry_count;
u8 retry_count_rtscts;
u8 sample_skipped;
bool retry_updated;
};
struct minstrel_rate {
int bitrate;
s8 rix;
u8 retry_count_cts;
u8 adjusted_retry_count;
unsigned int perfect_tx_time;
unsigned int ack_time;
int sample_limit;
struct minstrel_rate_stats stats;
};
struct minstrel_sta_info {
struct ieee80211_sta *sta;
unsigned long last_stats_update;
unsigned int sp_ack_dur;
unsigned int rate_avg;
unsigned int lowest_rix;
u8 max_tp_rate[MAX_THR_RATES];
u8 max_prob_rate;
unsigned int total_packets;
unsigned int sample_packets;
unsigned int sample_row;
unsigned int sample_column;
int n_rates;
struct minstrel_rate *r;
bool prev_sample;
/* sampling table */
u8 *sample_table;
};
struct minstrel_priv {
struct ieee80211_hw *hw;
bool has_mrr;
bool new_avg;
u32 sample_switch;
unsigned int cw_min;
unsigned int cw_max;
unsigned int max_retry;
unsigned int segment_size;
unsigned int update_interval;
unsigned int lookaround_rate;
unsigned int lookaround_rate_mrr;
u8 cck_rates[4];
u8 ofdm_rates[NUM_NL80211_BANDS][8];
#ifdef CONFIG_MAC80211_DEBUGFS
/*
* enable fixed rate processing per RC
* - write static index to debugfs:ieee80211/phyX/rc/fixed_rate_idx
* - write -1 to enable RC processing again
* - setting will be applied on next update
*/
u32 fixed_rate_idx;
#endif
};
struct minstrel_debugfs_info {
size_t len;
char buf[];
};
extern const struct rate_control_ops mac80211_minstrel;
void minstrel_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir);
/* Recalculate success probabilities and counters for a given rate using EWMA */
void minstrel_calc_rate_stats(struct minstrel_priv *mp,
struct minstrel_rate_stats *mrs);
int minstrel_get_tp_avg(struct minstrel_rate *mr, int prob_avg);
/* debugfs */
int minstrel_stats_open(struct inode *inode, struct file *file);
int minstrel_stats_csv_open(struct inode *inode, struct file *file);
#endif
/*
* Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* Based on minstrel.c:
* Copyright (C) 2005-2007 Derek Smithies <derek@indranet.co.nz>
* Sponsored by Indranet Technologies Ltd
*
* Based on sample.c:
* Copyright (c) 2005 John Bicket
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
* redistribution must be conditioned upon including a substantially
* similar Disclaimer requirement for further binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGES.
*/
#include <linux/netdevice.h>
#include <linux/types.h>
#include <linux/skbuff.h>
#include <linux/debugfs.h>
#include <linux/ieee80211.h>
#include <linux/slab.h>
#include <linux/export.h>
#include <net/mac80211.h>
#include "rc80211_minstrel.h"
int
minstrel_stats_open(struct inode *inode, struct file *file)
{
struct minstrel_sta_info *mi = inode->i_private;
struct minstrel_debugfs_info *ms;
unsigned int i, tp_max, tp_avg, eprob;
char *p;
ms = kmalloc(2048, GFP_KERNEL);
if (!ms)
return -ENOMEM;
file->private_data = ms;
p = ms->buf;
p += sprintf(p, "\n");
p += sprintf(p,
"best __________rate_________ ____statistics___ ____last_____ ______sum-of________\n");
p += sprintf(p,
"rate [name idx airtime max_tp] [avg(tp) avg(prob)] [retry|suc|att] [#success | #attempts]\n");
for (i = 0; i < mi->n_rates; i++) {
struct minstrel_rate *mr = &mi->r[i];
struct minstrel_rate_stats *mrs = &mi->r[i].stats;
*(p++) = (i == mi->max_tp_rate[0]) ? 'A' : ' ';
*(p++) = (i == mi->max_tp_rate[1]) ? 'B' : ' ';
*(p++) = (i == mi->max_tp_rate[2]) ? 'C' : ' ';
*(p++) = (i == mi->max_tp_rate[3]) ? 'D' : ' ';
*(p++) = (i == mi->max_prob_rate) ? 'P' : ' ';
p += sprintf(p, " %3u%s ", mr->bitrate / 2,
(mr->bitrate & 1 ? ".5" : " "));
p += sprintf(p, "%3u ", i);
p += sprintf(p, "%6u ", mr->perfect_tx_time);
tp_max = minstrel_get_tp_avg(mr, MINSTREL_FRAC(100,100));
tp_avg = minstrel_get_tp_avg(mr, mrs->prob_avg);
eprob = MINSTREL_TRUNC(mrs->prob_avg * 1000);
p += sprintf(p, "%4u.%1u %4u.%1u %3u.%1u"
" %3u %3u %-3u "
"%9llu %-9llu\n",
tp_max / 10, tp_max % 10,
tp_avg / 10, tp_avg % 10,
eprob / 10, eprob % 10,
mrs->retry_count,
mrs->last_success,
mrs->last_attempts,
(unsigned long long)mrs->succ_hist,
(unsigned long long)mrs->att_hist);
}
p += sprintf(p, "\nTotal packet count:: ideal %d "
"lookaround %d\n\n",
mi->total_packets - mi->sample_packets,
mi->sample_packets);
ms->len = p - ms->buf;
WARN_ON(ms->len + sizeof(*ms) > 2048);
return 0;
}
int
minstrel_stats_csv_open(struct inode *inode, struct file *file)
{
struct minstrel_sta_info *mi = inode->i_private;
struct minstrel_debugfs_info *ms;
unsigned int i, tp_max, tp_avg, eprob;
char *p;
ms = kmalloc(2048, GFP_KERNEL);
if (!ms)
return -ENOMEM;
file->private_data = ms;
p = ms->buf;
for (i = 0; i < mi->n_rates; i++) {
struct minstrel_rate *mr = &mi->r[i];
struct minstrel_rate_stats *mrs = &mi->r[i].stats;
p += sprintf(p, "%s" ,((i == mi->max_tp_rate[0]) ? "A" : ""));
p += sprintf(p, "%s" ,((i == mi->max_tp_rate[1]) ? "B" : ""));
p += sprintf(p, "%s" ,((i == mi->max_tp_rate[2]) ? "C" : ""));
p += sprintf(p, "%s" ,((i == mi->max_tp_rate[3]) ? "D" : ""));
p += sprintf(p, "%s" ,((i == mi->max_prob_rate) ? "P" : ""));
p += sprintf(p, ",%u%s", mr->bitrate / 2,
(mr->bitrate & 1 ? ".5," : ","));
p += sprintf(p, "%u,", i);
p += sprintf(p, "%u,",mr->perfect_tx_time);
tp_max = minstrel_get_tp_avg(mr, MINSTREL_FRAC(100,100));
tp_avg = minstrel_get_tp_avg(mr, mrs->prob_avg);
eprob = MINSTREL_TRUNC(mrs->prob_avg * 1000);
p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u,%u,%u,"
"%llu,%llu,%d,%d\n",
tp_max / 10, tp_max % 10,
tp_avg / 10, tp_avg % 10,
eprob / 10, eprob % 10,
mrs->retry_count,
mrs->last_success,
mrs->last_attempts,
(unsigned long long)mrs->succ_hist,
(unsigned long long)mrs->att_hist,
mi->total_packets - mi->sample_packets,
mi->sample_packets);
}
ms->len = p - ms->buf;
WARN_ON(ms->len + sizeof(*ms) > 2048);
return 0;
}
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include <net/mac80211.h> #include <net/mac80211.h>
#include "rate.h" #include "rate.h"
#include "sta_info.h" #include "sta_info.h"
#include "rc80211_minstrel.h"
#include "rc80211_minstrel_ht.h" #include "rc80211_minstrel_ht.h"
#define AVG_AMPDU_SIZE 16 #define AVG_AMPDU_SIZE 16
...@@ -716,6 +715,83 @@ minstrel_ht_rate_sample_switch(struct minstrel_priv *mp, ...@@ -716,6 +715,83 @@ minstrel_ht_rate_sample_switch(struct minstrel_priv *mp,
mi->sample_mode = MINSTREL_SAMPLE_ACTIVE; mi->sample_mode = MINSTREL_SAMPLE_ACTIVE;
} }
static inline int
minstrel_ewma(int old, int new, int weight)
{
int diff, incr;
diff = new - old;
incr = (EWMA_DIV - weight) * diff / EWMA_DIV;
return old + incr;
}
static inline int minstrel_filter_avg_add(u16 *prev_1, u16 *prev_2, s32 in)
{
s32 out_1 = *prev_1;
s32 out_2 = *prev_2;
s32 val;
if (!in)
in += 1;
if (!out_1) {
val = out_1 = in;
goto out;
}
val = MINSTREL_AVG_COEFF1 * in;
val += MINSTREL_AVG_COEFF2 * out_1;
val += MINSTREL_AVG_COEFF3 * out_2;
val >>= MINSTREL_SCALE;
if (val > 1 << MINSTREL_SCALE)
val = 1 << MINSTREL_SCALE;
if (val < 0)
val = 1;
out:
*prev_2 = out_1;
*prev_1 = val;
return val;
}
/*
* Recalculate statistics and counters of a given rate
*/
static void
minstrel_ht_calc_rate_stats(struct minstrel_priv *mp,
struct minstrel_rate_stats *mrs)
{
unsigned int cur_prob;
if (unlikely(mrs->attempts > 0)) {
mrs->sample_skipped = 0;
cur_prob = MINSTREL_FRAC(mrs->success, mrs->attempts);
if (mp->new_avg) {
minstrel_filter_avg_add(&mrs->prob_avg,
&mrs->prob_avg_1, cur_prob);
} else if (unlikely(!mrs->att_hist)) {
mrs->prob_avg = cur_prob;
} else {
/*update exponential weighted moving avarage */
mrs->prob_avg = minstrel_ewma(mrs->prob_avg,
cur_prob,
EWMA_LEVEL);
}
mrs->att_hist += mrs->attempts;
mrs->succ_hist += mrs->success;
} else {
mrs->sample_skipped++;
}
mrs->last_success = mrs->success;
mrs->last_attempts = mrs->attempts;
mrs->success = 0;
mrs->attempts = 0;
}
/* /*
* Update rate statistics and select new primary rates * Update rate statistics and select new primary rates
* *
...@@ -808,7 +884,7 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi, ...@@ -808,7 +884,7 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
mrs = &mg->rates[i]; mrs = &mg->rates[i];
mrs->retry_updated = false; mrs->retry_updated = false;
minstrel_calc_rate_stats(mp, mrs); minstrel_ht_calc_rate_stats(mp, mrs);
cur_prob = mrs->prob_avg; cur_prob = mrs->prob_avg;
if (minstrel_ht_get_tp_avg(mi, group, i, cur_prob) == 0) if (minstrel_ht_get_tp_avg(mi, group, i, cur_prob) == 0)
...@@ -960,8 +1036,7 @@ minstrel_ht_tx_status(void *priv, struct ieee80211_supported_band *sband, ...@@ -960,8 +1036,7 @@ minstrel_ht_tx_status(void *priv, struct ieee80211_supported_band *sband,
void *priv_sta, struct ieee80211_tx_status *st) void *priv_sta, struct ieee80211_tx_status *st)
{ {
struct ieee80211_tx_info *info = st->info; struct ieee80211_tx_info *info = st->info;
struct minstrel_ht_sta_priv *msp = priv_sta; struct minstrel_ht_sta *mi = priv_sta;
struct minstrel_ht_sta *mi = &msp->ht;
struct ieee80211_tx_rate *ar = info->status.rates; struct ieee80211_tx_rate *ar = info->status.rates;
struct minstrel_rate_stats *rate, *rate2, *rate_sample = NULL; struct minstrel_rate_stats *rate, *rate2, *rate_sample = NULL;
struct minstrel_priv *mp = priv; struct minstrel_priv *mp = priv;
...@@ -1372,8 +1447,7 @@ minstrel_ht_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta, ...@@ -1372,8 +1447,7 @@ minstrel_ht_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
const struct mcs_group *sample_group; const struct mcs_group *sample_group;
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb); struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb);
struct ieee80211_tx_rate *rate = &info->status.rates[0]; struct ieee80211_tx_rate *rate = &info->status.rates[0];
struct minstrel_ht_sta_priv *msp = priv_sta; struct minstrel_ht_sta *mi = priv_sta;
struct minstrel_ht_sta *mi = &msp->ht;
struct minstrel_priv *mp = priv; struct minstrel_priv *mp = priv;
int sample_idx; int sample_idx;
...@@ -1484,8 +1558,7 @@ minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband, ...@@ -1484,8 +1558,7 @@ minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband,
struct ieee80211_sta *sta, void *priv_sta) struct ieee80211_sta *sta, void *priv_sta)
{ {
struct minstrel_priv *mp = priv; struct minstrel_priv *mp = priv;
struct minstrel_ht_sta_priv *msp = priv_sta; struct minstrel_ht_sta *mi = priv_sta;
struct minstrel_ht_sta *mi = &msp->ht;
struct ieee80211_mcs_info *mcs = &sta->ht_cap.mcs; struct ieee80211_mcs_info *mcs = &sta->ht_cap.mcs;
u16 ht_cap = sta->ht_cap.cap; u16 ht_cap = sta->ht_cap.cap;
struct ieee80211_sta_vht_cap *vht_cap = &sta->vht_cap; struct ieee80211_sta_vht_cap *vht_cap = &sta->vht_cap;
...@@ -1647,7 +1720,7 @@ static void * ...@@ -1647,7 +1720,7 @@ static void *
minstrel_ht_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp) minstrel_ht_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp)
{ {
struct ieee80211_supported_band *sband; struct ieee80211_supported_band *sband;
struct minstrel_ht_sta_priv *msp; struct minstrel_ht_sta *mi;
struct minstrel_priv *mp = priv; struct minstrel_priv *mp = priv;
struct ieee80211_hw *hw = mp->hw; struct ieee80211_hw *hw = mp->hw;
int max_rates = 0; int max_rates = 0;
...@@ -1659,35 +1732,13 @@ minstrel_ht_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp) ...@@ -1659,35 +1732,13 @@ minstrel_ht_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp)
max_rates = sband->n_bitrates; max_rates = sband->n_bitrates;
} }
msp = kzalloc(sizeof(*msp), gfp); return kzalloc(sizeof(*mi), gfp);
if (!msp)
return NULL;
msp->ratelist = kcalloc(max_rates, sizeof(struct minstrel_rate), gfp);
if (!msp->ratelist)
goto error;
msp->sample_table = kmalloc_array(max_rates, SAMPLE_COLUMNS, gfp);
if (!msp->sample_table)
goto error1;
return msp;
error1:
kfree(msp->ratelist);
error:
kfree(msp);
return NULL;
} }
static void static void
minstrel_ht_free_sta(void *priv, struct ieee80211_sta *sta, void *priv_sta) minstrel_ht_free_sta(void *priv, struct ieee80211_sta *sta, void *priv_sta)
{ {
struct minstrel_ht_sta_priv *msp = priv_sta; kfree(priv_sta);
kfree(msp->sample_table);
kfree(msp->ratelist);
kfree(msp);
} }
static void static void
...@@ -1768,12 +1819,6 @@ minstrel_ht_alloc(struct ieee80211_hw *hw) ...@@ -1768,12 +1819,6 @@ minstrel_ht_alloc(struct ieee80211_hw *hw)
mp->cw_min = 15; mp->cw_min = 15;
mp->cw_max = 1023; mp->cw_max = 1023;
/* number of packets (in %) to use for sampling other rates
* sample less often for non-mrr packets, because the overhead
* is much higher than with mrr */
mp->lookaround_rate = 5;
mp->lookaround_rate_mrr = 10;
/* 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;
...@@ -1821,8 +1866,7 @@ minstrel_ht_free(void *priv) ...@@ -1821,8 +1866,7 @@ minstrel_ht_free(void *priv)
static u32 minstrel_ht_get_expected_throughput(void *priv_sta) static u32 minstrel_ht_get_expected_throughput(void *priv_sta)
{ {
struct minstrel_ht_sta_priv *msp = priv_sta; struct minstrel_ht_sta *mi = priv_sta;
struct minstrel_ht_sta *mi = &msp->ht;
int i, j, prob, tp_avg; int i, j, prob, tp_avg;
i = mi->max_tp_rate[0] / MCS_GROUP_RATES; i = mi->max_tp_rate[0] / MCS_GROUP_RATES;
......
...@@ -6,6 +6,33 @@ ...@@ -6,6 +6,33 @@
#ifndef __RC_MINSTREL_HT_H #ifndef __RC_MINSTREL_HT_H
#define __RC_MINSTREL_HT_H #define __RC_MINSTREL_HT_H
/* number of highest throughput rates to consider*/
#define MAX_THR_RATES 4
#define SAMPLE_COLUMNS 10 /* number of columns in sample table */
/* scaled fraction values */
#define MINSTREL_SCALE 12
#define MINSTREL_FRAC(val, div) (((val) << MINSTREL_SCALE) / div)
#define MINSTREL_TRUNC(val) ((val) >> MINSTREL_SCALE)
#define EWMA_LEVEL 96 /* ewma weighting factor [/EWMA_DIV] */
#define EWMA_DIV 128
/*
* Coefficients for moving average with noise filter (period=16),
* scaled by 10 bits
*
* a1 = exp(-pi * sqrt(2) / period)
* coeff2 = 2 * a1 * cos(sqrt(2) * 2 * pi / period)
* coeff3 = -sqr(a1)
* coeff1 = 1 - coeff2 - coeff3
*/
#define MINSTREL_AVG_COEFF1 (MINSTREL_FRAC(1, 1) - \
MINSTREL_AVG_COEFF2 - \
MINSTREL_AVG_COEFF3)
#define MINSTREL_AVG_COEFF2 0x00001499
#define MINSTREL_AVG_COEFF3 -0x0000092e
/* /*
* The number of streams can be changed to 2 to reduce code * The number of streams can be changed to 2 to reduce code
* size and memory footprint. * size and memory footprint.
...@@ -30,6 +57,32 @@ ...@@ -30,6 +57,32 @@
#define MCS_GROUP_RATES 10 #define MCS_GROUP_RATES 10
struct minstrel_priv {
struct ieee80211_hw *hw;
bool has_mrr;
bool new_avg;
u32 sample_switch;
unsigned int cw_min;
unsigned int cw_max;
unsigned int max_retry;
unsigned int segment_size;
unsigned int update_interval;
u8 cck_rates[4];
u8 ofdm_rates[NUM_NL80211_BANDS][8];
#ifdef CONFIG_MAC80211_DEBUGFS
/*
* enable fixed rate processing per RC
* - write static index to debugfs:ieee80211/phyX/rc/fixed_rate_idx
* - write -1 to enable RC processing again
* - setting will be applied on next update
*/
u32 fixed_rate_idx;
#endif
};
struct mcs_group { struct mcs_group {
u16 flags; u16 flags;
u8 streams; u8 streams;
...@@ -42,6 +95,26 @@ extern const s16 minstrel_cck_bitrates[4]; ...@@ -42,6 +95,26 @@ extern const s16 minstrel_cck_bitrates[4];
extern const s16 minstrel_ofdm_bitrates[8]; extern const s16 minstrel_ofdm_bitrates[8];
extern const struct mcs_group minstrel_mcs_groups[]; extern const struct mcs_group minstrel_mcs_groups[];
struct minstrel_rate_stats {
/* current / last sampling period attempts/success counters */
u16 attempts, last_attempts;
u16 success, last_success;
/* total attempts/success counters */
u32 att_hist, succ_hist;
/* prob_avg - moving average of prob */
u16 prob_avg;
u16 prob_avg_1;
/* maximum retry counts */
u8 retry_count;
u8 retry_count_rtscts;
u8 sample_skipped;
bool retry_updated;
};
struct minstrel_mcs_group_data { struct minstrel_mcs_group_data {
u8 index; u8 index;
u8 column; u8 column;
...@@ -111,12 +184,6 @@ struct minstrel_ht_sta { ...@@ -111,12 +184,6 @@ struct minstrel_ht_sta {
struct minstrel_mcs_group_data groups[MINSTREL_GROUPS_NB]; struct minstrel_mcs_group_data groups[MINSTREL_GROUPS_NB];
}; };
struct minstrel_ht_sta_priv {
struct minstrel_ht_sta ht;
void *ratelist;
void *sample_table;
};
void minstrel_ht_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir); void minstrel_ht_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir);
int minstrel_ht_get_tp_avg(struct minstrel_ht_sta *mi, int group, int rate, int minstrel_ht_get_tp_avg(struct minstrel_ht_sta *mi, int group, int rate,
int prob_avg); int prob_avg);
......
...@@ -9,9 +9,13 @@ ...@@ -9,9 +9,13 @@
#include <linux/ieee80211.h> #include <linux/ieee80211.h>
#include <linux/export.h> #include <linux/export.h>
#include <net/mac80211.h> #include <net/mac80211.h>
#include "rc80211_minstrel.h"
#include "rc80211_minstrel_ht.h" #include "rc80211_minstrel_ht.h"
struct minstrel_debugfs_info {
size_t len;
char buf[];
};
static ssize_t static ssize_t
minstrel_stats_read(struct file *file, char __user *buf, size_t len, loff_t *ppos) minstrel_stats_read(struct file *file, char __user *buf, size_t len, loff_t *ppos)
{ {
...@@ -127,8 +131,7 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p) ...@@ -127,8 +131,7 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p)
static int static int
minstrel_ht_stats_open(struct inode *inode, struct file *file) minstrel_ht_stats_open(struct inode *inode, struct file *file)
{ {
struct minstrel_ht_sta_priv *msp = inode->i_private; struct minstrel_ht_sta *mi = inode->i_private;
struct minstrel_ht_sta *mi = &msp->ht;
struct minstrel_debugfs_info *ms; struct minstrel_debugfs_info *ms;
unsigned int i; unsigned int i;
char *p; char *p;
...@@ -276,8 +279,7 @@ minstrel_ht_stats_csv_dump(struct minstrel_ht_sta *mi, int i, char *p) ...@@ -276,8 +279,7 @@ minstrel_ht_stats_csv_dump(struct minstrel_ht_sta *mi, int i, char *p)
static int static int
minstrel_ht_stats_csv_open(struct inode *inode, struct file *file) minstrel_ht_stats_csv_open(struct inode *inode, struct file *file)
{ {
struct minstrel_ht_sta_priv *msp = inode->i_private; struct minstrel_ht_sta *mi = inode->i_private;
struct minstrel_ht_sta *mi = &msp->ht;
struct minstrel_debugfs_info *ms; struct minstrel_debugfs_info *ms;
unsigned int i; unsigned int i;
char *p; char *p;
...@@ -313,10 +315,8 @@ static const struct file_operations minstrel_ht_stat_csv_fops = { ...@@ -313,10 +315,8 @@ static const struct file_operations minstrel_ht_stat_csv_fops = {
void void
minstrel_ht_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir) minstrel_ht_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir)
{ {
struct minstrel_ht_sta_priv *msp = priv_sta; debugfs_create_file("rc_stats", 0444, dir, priv_sta,
debugfs_create_file("rc_stats", 0444, dir, msp,
&minstrel_ht_stat_fops); &minstrel_ht_stat_fops);
debugfs_create_file("rc_stats_csv", 0444, dir, msp, debugfs_create_file("rc_stats_csv", 0444, dir, priv_sta,
&minstrel_ht_stat_csv_fops); &minstrel_ht_stat_csv_fops);
} }
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