On 2013-03-03 12:49 +0100, Felix Fietkau wrote linux-wireless@xxxxxxxxxxxxxxx: Hi, in my case this two patches cause throughput drop, withous it i have 50-55Mbs with it applied only 35-40. FF>If a rate is below the max_tp_rate, sample it frequently if: FF>- it is above max_tp_rate2, or FF>- it is above max_prob_rate and is a candidate for max_prob_rate FF> (has fewer streams than max_tp_rate). FF>This helps the retry chain recover more quickly from bad statistics FF>caused by collisions or interference, and slightly reduces throughput FF>fluctuations with higher rates. FF> FF>Signed-off-by: Felix Fietkau <nbd@xxxxxxxxxxx> FF>--- FF> net/mac80211/rc80211_minstrel_ht.c | 20 ++++++++++++-------- FF> net/mac80211/rc80211_minstrel_ht.h | 1 + FF> 2 files changed, 13 insertions(+), 8 deletions(-) FF> FF>diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c FF>index 4d35bc5..1b69924 100644 FF>--- a/net/mac80211/rc80211_minstrel_ht.c FF>+++ b/net/mac80211/rc80211_minstrel_ht.c FF>@@ -246,7 +246,6 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) FF> struct minstrel_rate_stats *mr; FF> int cur_prob, cur_prob_tp, cur_tp, cur_tp2; FF> int group, i, index; FF>- int prob_max_streams = 1; FF> FF> if (mi->ampdu_packets > 0) { FF> mi->avg_ampdu_len = minstrel_ewma(mi->avg_ampdu_len, FF>@@ -330,7 +329,7 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) FF> cur_tp2 = cur_tp; FF> mi->max_tp_rate = mg->max_tp_rate; FF> cur_tp = mr->cur_tp; FF>- prob_max_streams = minstrel_mcs_groups[group].streams - 1; FF>+ mi->max_prob_streams = minstrel_mcs_groups[group].streams - 1; FF> } FF> FF> mr = minstrel_get_ratestats(mi, mg->max_tp_rate2); FF>@@ -340,8 +339,8 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) FF> } FF> } FF> FF>- if (prob_max_streams < 1) FF>- prob_max_streams = 1; FF>+ if (mi->max_prob_streams < 1) FF>+ mi->max_prob_streams = 1; FF> FF> for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) { FF> mg = &mi->groups[group]; FF>@@ -349,7 +348,7 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) FF> continue; FF> mr = minstrel_get_ratestats(mi, mg->max_prob_rate); FF> if (cur_prob_tp < mr->cur_tp && FF>- minstrel_mcs_groups[group].streams <= prob_max_streams) { FF>+ minstrel_mcs_groups[group].streams <= mi->max_prob_streams) { FF> mi->max_prob_rate = mg->max_prob_rate; FF> cur_prob = mr->cur_prob; FF> cur_prob_tp = mr->cur_tp; FF>@@ -630,6 +629,7 @@ minstrel_get_sample_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) FF> { FF> struct minstrel_rate_stats *mr; FF> struct minstrel_mcs_group_data *mg; FF>+ unsigned int sample_dur, sample_group; FF> int sample_idx = 0; FF> FF> if (mi->sample_wait > 0) { FF>@@ -644,7 +644,8 @@ minstrel_get_sample_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) FF> mg = &mi->groups[mi->sample_group]; FF> sample_idx = sample_table[mg->column][mg->index]; FF> mr = &mg->rates[sample_idx]; FF>- sample_idx += mi->sample_group * MCS_GROUP_RATES; FF>+ sample_group = mi->sample_group; FF>+ sample_idx += sample_group * MCS_GROUP_RATES; FF> minstrel_next_sample_idx(mi); FF> FF> /* FF>@@ -665,8 +666,11 @@ minstrel_get_sample_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) FF> * Make sure that lower rates get sampled only occasionally, FF> * if the link is working perfectly. FF> */ FF>- if (minstrel_get_duration(sample_idx) > FF>- minstrel_get_duration(mi->max_tp_rate)) { FF>+ sample_dur = minstrel_get_duration(sample_idx); FF>+ if (sample_dur >= minstrel_get_duration(mi->max_tp_rate2) && FF>+ (mi->max_prob_streams < FF>+ minstrel_mcs_groups[sample_group].streams || FF>+ sample_dur >= minstrel_get_duration(mi->max_prob_rate))) { FF> if (mr->sample_skipped < 20) FF> return -1; FF> FF>diff --git a/net/mac80211/rc80211_minstrel_ht.h b/net/mac80211/rc80211_minstrel_ht.h FF>index 302dbd5..c6d6a0d 100644 FF>--- a/net/mac80211/rc80211_minstrel_ht.h FF>+++ b/net/mac80211/rc80211_minstrel_ht.h FF>@@ -85,6 +85,7 @@ struct minstrel_ht_sta { FF> FF> /* best probability rate */ FF> unsigned int max_prob_rate; FF>+ unsigned int max_prob_streams; FF> FF> /* time of last status update */ FF> unsigned long stats_update; FF> C уважением With Best Regards Георгиевский Юрий. Georgiewskiy Yuriy +7 4872 711666 +7 4872 711666 факс +7 4872 711143 fax +7 4872 711143 Компания ООО "Ай Ти Сервис" IT Service Ltd http://nkoort.ru http://nkoort.ru JID: GHhost@xxxxxxxxxx JID: GHhost@xxxxxxxxxx YG129-RIPE YG129-RIPE