提交 ec8aa669 编写于 作者: F Felix Fietkau 提交者: John W. Linville

mac80211: add the minstrel_ht rate control algorithm

Signed-off-by: NFelix Fietkau <nbd@openwrt.org>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
上级 b4df4708
......@@ -33,6 +33,13 @@ 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 EMBEDDED
depends on MAC80211_RC_MINSTREL
default y
---help---
This option enables the 'minstrel_ht' TX rate control algorithm
choice
prompt "Default rate control algorithm"
depends on MAC80211_HAS_RC
......
......@@ -51,7 +51,11 @@ rc80211_pid-$(CONFIG_MAC80211_DEBUGFS) += rc80211_pid_debugfs.o
rc80211_minstrel-y := rc80211_minstrel.o
rc80211_minstrel-$(CONFIG_MAC80211_DEBUGFS) += rc80211_minstrel_debugfs.o
rc80211_minstrel_ht-y := rc80211_minstrel_ht.o
rc80211_minstrel_ht-$(CONFIG_MAC80211_DEBUGFS) += rc80211_minstrel_ht_debugfs.o
mac80211-$(CONFIG_MAC80211_RC_PID) += $(rc80211_pid-y)
mac80211-$(CONFIG_MAC80211_RC_MINSTREL) += $(rc80211_minstrel-y)
mac80211-$(CONFIG_MAC80211_RC_MINSTREL_HT) += $(rc80211_minstrel_ht-y)
ccflags-y += -D__CHECK_ENDIAN__
......@@ -704,6 +704,10 @@ static int __init ieee80211_init(void)
if (ret)
return ret;
ret = rc80211_minstrel_ht_init();
if (ret)
goto err_minstrel;
ret = rc80211_pid_init();
if (ret)
goto err_pid;
......@@ -716,6 +720,8 @@ static int __init ieee80211_init(void)
err_netdev:
rc80211_pid_exit();
err_pid:
rc80211_minstrel_ht_exit();
err_minstrel:
rc80211_minstrel_exit();
return ret;
......@@ -724,6 +730,7 @@ static int __init ieee80211_init(void)
static void __exit ieee80211_exit(void)
{
rc80211_pid_exit();
rc80211_minstrel_ht_exit();
rc80211_minstrel_exit();
/*
......
......@@ -147,5 +147,18 @@ static inline void rc80211_minstrel_exit(void)
}
#endif
#ifdef CONFIG_MAC80211_RC_MINSTREL_HT
extern int rc80211_minstrel_ht_init(void);
extern 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 */
此差异已折叠。
/*
* Copyright (C) 2010 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.
*/
#ifndef __RC_MINSTREL_HT_H
#define __RC_MINSTREL_HT_H
/*
* The number of streams can be changed to 2 to reduce code
* size and memory footprint.
*/
#define MINSTREL_MAX_STREAMS 3
#define MINSTREL_STREAM_GROUPS 4
/* scaled fraction values */
#define MINSTREL_SCALE 16
#define MINSTREL_FRAC(val, div) (((val) << MINSTREL_SCALE) / div)
#define MINSTREL_TRUNC(val) ((val) >> MINSTREL_SCALE)
#define MCS_GROUP_RATES 8
struct mcs_group {
u32 flags;
unsigned int streams;
unsigned int duration[MCS_GROUP_RATES];
};
struct minstrel_rate_stats {
/* current / last sampling period attempts/success counters */
unsigned int attempts, last_attempts;
unsigned int success, last_success;
/* total attempts/success counters */
u64 att_hist, succ_hist;
/* current throughput */
unsigned int cur_tp;
/* packet delivery probabilities */
unsigned int cur_prob, probability;
/* maximum retry counts */
unsigned int retry_count;
unsigned int retry_count_rtscts;
bool retry_updated;
u8 sample_skipped;
};
struct minstrel_mcs_group_data {
u8 index;
u8 column;
/* bitfield of supported MCS rates of this group */
u8 supported;
/* selected primary rates */
unsigned int max_tp_rate;
unsigned int max_tp_rate2;
unsigned int max_prob_rate;
/* MCS rate statistics */
struct minstrel_rate_stats rates[MCS_GROUP_RATES];
};
struct minstrel_ht_sta {
/* ampdu length (average, per sampling interval) */
unsigned int ampdu_len;
unsigned int ampdu_packets;
/* ampdu length (EWMA) */
unsigned int avg_ampdu_len;
/* best throughput rate */
unsigned int max_tp_rate;
/* second best throughput rate */
unsigned int max_tp_rate2;
/* best probability rate */
unsigned int max_prob_rate;
/* time of last status update */
unsigned long stats_update;
/* overhead time in usec for each frame */
unsigned int overhead;
unsigned int overhead_rtscts;
unsigned int total_packets;
unsigned int sample_packets;
/* tx flags to add for frames for this sta */
u32 tx_flags;
u8 sample_wait;
u8 sample_tries;
u8 sample_count;
u8 sample_slow;
/* current MCS group to be sampled */
u8 sample_group;
/* MCS rate group info and statistics */
struct minstrel_mcs_group_data groups[MINSTREL_MAX_STREAMS * MINSTREL_STREAM_GROUPS];
};
struct minstrel_ht_sta_priv {
union {
struct minstrel_ht_sta ht;
struct minstrel_sta_info legacy;
};
#ifdef CONFIG_MAC80211_DEBUGFS
struct dentry *dbg_stats;
#endif
void *ratelist;
void *sample_table;
bool is_ht;
};
void minstrel_ht_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir);
void minstrel_ht_remove_sta_debugfs(void *priv, void *priv_sta);
#endif
/*
* Copyright (C) 2010 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.
*/
#include <linux/netdevice.h>
#include <linux/types.h>
#include <linux/skbuff.h>
#include <linux/debugfs.h>
#include <linux/ieee80211.h>
#include <net/mac80211.h>
#include "rc80211_minstrel.h"
#include "rc80211_minstrel_ht.h"
extern const struct mcs_group minstrel_mcs_groups[];
static int
minstrel_ht_stats_open(struct inode *inode, struct file *file)
{
struct minstrel_ht_sta_priv *msp = inode->i_private;
struct minstrel_ht_sta *mi = &msp->ht;
struct minstrel_debugfs_info *ms;
unsigned int i, j, tp, prob, eprob;
char *p;
int ret;
if (!msp->is_ht) {
inode->i_private = &msp->legacy;
ret = minstrel_stats_open(inode, file);
inode->i_private = msp;
return ret;
}
ms = kmalloc(sizeof(*ms) + 8192, GFP_KERNEL);
if (!ms)
return -ENOMEM;
file->private_data = ms;
p = ms->buf;
p += sprintf(p, "type rate throughput ewma prob this prob "
"this succ/attempt success attempts\n");
for (i = 0; i < MINSTREL_MAX_STREAMS * MINSTREL_STREAM_GROUPS; i++) {
char htmode = '2';
char gimode = 'L';
if (!mi->groups[i].supported)
continue;
if (minstrel_mcs_groups[i].flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
htmode = '4';
if (minstrel_mcs_groups[i].flags & IEEE80211_TX_RC_SHORT_GI)
gimode = 'S';
for (j = 0; j < MCS_GROUP_RATES; j++) {
struct minstrel_rate_stats *mr = &mi->groups[i].rates[j];
int idx = i * MCS_GROUP_RATES + j;
if (!(mi->groups[i].supported & BIT(j)))
continue;
p += sprintf(p, "HT%c0/%cGI ", htmode, gimode);
*(p++) = (idx == mi->max_tp_rate) ? 'T' : ' ';
*(p++) = (idx == mi->max_tp_rate2) ? 't' : ' ';
*(p++) = (idx == mi->max_prob_rate) ? 'P' : ' ';
p += sprintf(p, "MCS%-2u", (minstrel_mcs_groups[i].streams - 1) *
MCS_GROUP_RATES + j);
tp = mr->cur_tp / 10;
prob = MINSTREL_TRUNC(mr->cur_prob * 1000);
eprob = MINSTREL_TRUNC(mr->probability * 1000);
p += sprintf(p, " %6u.%1u %6u.%1u %6u.%1u "
"%3u(%3u) %8llu %8llu\n",
tp / 10, tp % 10,
eprob / 10, eprob % 10,
prob / 10, prob % 10,
mr->last_success,
mr->last_attempts,
(unsigned long long)mr->succ_hist,
(unsigned long long)mr->att_hist);
}
}
p += sprintf(p, "\nTotal packet count:: ideal %d "
"lookaround %d\n",
max(0, (int) mi->total_packets - (int) mi->sample_packets),
mi->sample_packets);
p += sprintf(p, "Average A-MPDU length: %d.%d\n",
MINSTREL_TRUNC(mi->avg_ampdu_len),
MINSTREL_TRUNC(mi->avg_ampdu_len * 10) % 10);
ms->len = p - ms->buf;
return 0;
}
static const struct file_operations minstrel_ht_stat_fops = {
.owner = THIS_MODULE,
.open = minstrel_ht_stats_open,
.read = minstrel_stats_read,
.release = minstrel_stats_release,
};
void
minstrel_ht_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir)
{
struct minstrel_ht_sta_priv *msp = priv_sta;
msp->dbg_stats = debugfs_create_file("rc_stats", S_IRUGO, dir, msp,
&minstrel_ht_stat_fops);
}
void
minstrel_ht_remove_sta_debugfs(void *priv, void *priv_sta)
{
struct minstrel_ht_sta_priv *msp = priv_sta;
debugfs_remove(msp->dbg_stats);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册