Skip to content

Commit

Permalink
mac80211: minstrel: merge with minstrel_ht, always enable VHT support
Browse files Browse the repository at this point in the history
Legacy-only devices are not very common and the overhead of the extra
code for HT and VHT rates is not big enough to justify all those extra
lines of code to make it optional.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  • Loading branch information
Felix Fietkau authored and Johannes Berg committed Oct 11, 2018
1 parent 5b5e873 commit b1c4f68
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 258 deletions.
17 changes: 1 addition & 16 deletions net/mac80211/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,6 @@ config MAC80211_RC_MINSTREL
---help---
This option enables the 'minstrel' TX rate control algorithm

config MAC80211_RC_MINSTREL_HT
bool "Minstrel 802.11n support" if EXPERT
depends on MAC80211_RC_MINSTREL
default y
---help---
This option enables the 'minstrel_ht' TX rate control algorithm

config MAC80211_RC_MINSTREL_VHT
bool "Minstrel 802.11ac support" if EXPERT
depends on MAC80211_RC_MINSTREL_HT
default n
---help---
This option enables VHT in the 'minstrel_ht' TX rate control algorithm

choice
prompt "Default rate control algorithm"
depends on MAC80211_HAS_RC
Expand All @@ -62,8 +48,7 @@ endchoice

config MAC80211_RC_DEFAULT
string
default "minstrel_ht" if MAC80211_RC_DEFAULT_MINSTREL && MAC80211_RC_MINSTREL_HT
default "minstrel" if MAC80211_RC_DEFAULT_MINSTREL
default "minstrel_ht" if MAC80211_RC_DEFAULT_MINSTREL
default ""

endif
Expand Down
11 changes: 6 additions & 5 deletions net/mac80211/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,14 @@ mac80211-$(CONFIG_PM) += pm.o

CFLAGS_trace.o := -I$(src)

rc80211_minstrel-y := rc80211_minstrel.o
rc80211_minstrel-$(CONFIG_MAC80211_DEBUGFS) += rc80211_minstrel_debugfs.o
rc80211_minstrel-y := \
rc80211_minstrel.o \
rc80211_minstrel_ht.o

rc80211_minstrel_ht-y := rc80211_minstrel_ht.o
rc80211_minstrel_ht-$(CONFIG_MAC80211_DEBUGFS) += rc80211_minstrel_ht_debugfs.o
rc80211_minstrel-$(CONFIG_MAC80211_DEBUGFS) += \
rc80211_minstrel_debugfs.o \
rc80211_minstrel_ht_debugfs.o

mac80211-$(CONFIG_MAC80211_RC_MINSTREL) += $(rc80211_minstrel-y)
mac80211-$(CONFIG_MAC80211_RC_MINSTREL_HT) += $(rc80211_minstrel_ht-y)

ccflags-y += -DDEBUG
7 changes: 0 additions & 7 deletions net/mac80211/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1375,26 +1375,19 @@ static int __init ieee80211_init(void)
if (ret)
return ret;

ret = rc80211_minstrel_ht_init();
if (ret)
goto err_minstrel;

ret = ieee80211_iface_init();
if (ret)
goto err_netdev;

return 0;
err_netdev:
rc80211_minstrel_ht_exit();
err_minstrel:
rc80211_minstrel_exit();

return ret;
}

static void __exit ieee80211_exit(void)
{
rc80211_minstrel_ht_exit();
rc80211_minstrel_exit();

ieee80211s_stop();
Expand Down
13 changes: 0 additions & 13 deletions net/mac80211/rate.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,5 @@ static inline void rc80211_minstrel_exit(void)
}
#endif

#ifdef CONFIG_MAC80211_RC_MINSTREL_HT
int rc80211_minstrel_ht_init(void);
void rc80211_minstrel_ht_exit(void);
#else
static inline int rc80211_minstrel_ht_init(void)
{
return 0;
}
static inline void rc80211_minstrel_ht_exit(void)
{
}
#endif


#endif /* IEEE80211_RATE_H */
152 changes: 0 additions & 152 deletions net/mac80211/rc80211_minstrel.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,138 +572,6 @@ minstrel_rate_init(void *priv, struct ieee80211_supported_band *sband,
minstrel_update_rates(mp, mi);
}

static void *
minstrel_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp)
{
struct ieee80211_supported_band *sband;
struct minstrel_sta_info *mi;
struct minstrel_priv *mp = priv;
struct ieee80211_hw *hw = mp->hw;
int max_rates = 0;
int i;

mi = kzalloc(sizeof(struct minstrel_sta_info), gfp);
if (!mi)
return NULL;

for (i = 0; i < NUM_NL80211_BANDS; i++) {
sband = hw->wiphy->bands[i];
if (sband && sband->n_bitrates > max_rates)
max_rates = sband->n_bitrates;
}

mi->r = kcalloc(max_rates, sizeof(struct minstrel_rate), gfp);
if (!mi->r)
goto error;

mi->sample_table = kmalloc_array(max_rates, SAMPLE_COLUMNS, gfp);
if (!mi->sample_table)
goto error1;

mi->last_stats_update = jiffies;
return mi;

error1:
kfree(mi->r);
error:
kfree(mi);
return NULL;
}

static void
minstrel_free_sta(void *priv, struct ieee80211_sta *sta, void *priv_sta)
{
struct minstrel_sta_info *mi = priv_sta;

kfree(mi->sample_table);
kfree(mi->r);
kfree(mi);
}

static void
minstrel_init_cck_rates(struct minstrel_priv *mp)
{
static const int bitrates[4] = { 10, 20, 55, 110 };
struct ieee80211_supported_band *sband;
u32 rate_flags = ieee80211_chandef_rate_flags(&mp->hw->conf.chandef);
int i, j;

sband = mp->hw->wiphy->bands[NL80211_BAND_2GHZ];
if (!sband)
return;

for (i = 0; i < sband->n_bitrates; i++) {
struct ieee80211_rate *rate = &sband->bitrates[i];

if (rate->flags & IEEE80211_RATE_ERP_G)
continue;

if ((rate_flags & sband->bitrates[i].flags) != rate_flags)
continue;

for (j = 0; j < ARRAY_SIZE(bitrates); j++) {
if (rate->bitrate != bitrates[j])
continue;

mp->cck_rates[j] = i;
break;
}
}
}

static void *
minstrel_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir)
{
struct minstrel_priv *mp;

mp = kzalloc(sizeof(struct minstrel_priv), GFP_ATOMIC);
if (!mp)
return NULL;

/* contention window settings
* Just an approximation. Using the per-queue values would complicate
* the calculations and is probably unnecessary */
mp->cw_min = 15;
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 */
mp->segment_size = 6000;

if (hw->max_rate_tries > 0)
mp->max_retry = hw->max_rate_tries;
else
/* safe default, does not necessarily have to match hw properties */
mp->max_retry = 7;

if (hw->max_rates >= 4)
mp->has_mrr = true;

mp->hw = hw;
mp->update_interval = 100;

#ifdef CONFIG_MAC80211_DEBUGFS
mp->fixed_rate_idx = (u32) -1;
debugfs_create_u32("fixed_rate_idx", 0666, debugfsdir,
&mp->fixed_rate_idx);
#endif

minstrel_init_cck_rates(mp);

return mp;
}

static void
minstrel_free(void *priv)
{
kfree(priv);
}

static u32 minstrel_get_expected_throughput(void *priv_sta)
{
struct minstrel_sta_info *mi = priv_sta;
Expand All @@ -722,28 +590,8 @@ static u32 minstrel_get_expected_throughput(void *priv_sta)
}

const struct rate_control_ops mac80211_minstrel = {
.name = "minstrel",
.tx_status_ext = minstrel_tx_status,
.get_rate = minstrel_get_rate,
.rate_init = minstrel_rate_init,
.alloc = minstrel_alloc,
.free = minstrel_free,
.alloc_sta = minstrel_alloc_sta,
.free_sta = minstrel_free_sta,
#ifdef CONFIG_MAC80211_DEBUGFS
.add_sta_debugfs = minstrel_add_sta_debugfs,
#endif
.get_expected_throughput = minstrel_get_expected_throughput,
};

int __init
rc80211_minstrel_init(void)
{
return ieee80211_rate_control_register(&mac80211_minstrel);
}

void
rc80211_minstrel_exit(void)
{
ieee80211_rate_control_unregister(&mac80211_minstrel);
}
2 changes: 0 additions & 2 deletions net/mac80211/rc80211_minstrel.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,5 @@ int minstrel_get_tp_avg(struct minstrel_rate *mr, int prob_ewma);
/* debugfs */
int minstrel_stats_open(struct inode *inode, struct file *file);
int minstrel_stats_csv_open(struct inode *inode, struct file *file);
ssize_t minstrel_stats_read(struct file *file, char __user *buf, size_t len, loff_t *ppos);
int minstrel_stats_release(struct inode *inode, struct file *file);

#endif
42 changes: 0 additions & 42 deletions net/mac80211/rc80211_minstrel_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,6 @@
#include <net/mac80211.h>
#include "rc80211_minstrel.h"

ssize_t
minstrel_stats_read(struct file *file, char __user *buf, size_t len, loff_t *ppos)
{
struct minstrel_debugfs_info *ms;

ms = file->private_data;
return simple_read_from_buffer(buf, len, ppos, ms->buf, ms->len);
}

int
minstrel_stats_release(struct inode *inode, struct file *file)
{
kfree(file->private_data);
return 0;
}

int
minstrel_stats_open(struct inode *inode, struct file *file)
{
Expand Down Expand Up @@ -135,14 +119,6 @@ minstrel_stats_open(struct inode *inode, struct file *file)
return 0;
}

static const struct file_operations minstrel_stat_fops = {
.owner = THIS_MODULE,
.open = minstrel_stats_open,
.read = minstrel_stats_read,
.release = minstrel_stats_release,
.llseek = default_llseek,
};

int
minstrel_stats_csv_open(struct inode *inode, struct file *file)
{
Expand Down Expand Up @@ -200,21 +176,3 @@ minstrel_stats_csv_open(struct inode *inode, struct file *file)

return 0;
}

static const struct file_operations minstrel_stat_csv_fops = {
.owner = THIS_MODULE,
.open = minstrel_stats_csv_open,
.read = minstrel_stats_read,
.release = minstrel_stats_release,
.llseek = default_llseek,
};

void
minstrel_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir)
{
struct minstrel_sta_info *mi = priv_sta;

debugfs_create_file("rc_stats", 0444, dir, mi, &minstrel_stat_fops);
debugfs_create_file("rc_stats_csv", 0444, dir, mi,
&minstrel_stat_csv_fops);
}
Loading

0 comments on commit b1c4f68

Please sign in to comment.