Skip to contentSkip to conversation

mac80211: minstrel_ht: fix per-group max throughput rate initialization

PATCH New Felix Fietkau 1 participant 4 messages Aug 20, 2019 mac80211

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 mac80211: minstrel_ht: fix per-group max throughput rate initialization

The group number needs to be multiplied by the number of rates per group to get the full rate index

Fixes 5935839ad73583 ("mac80211: improve minstrel_ht rate sorting by throughput & probability")
---
 net/mac80211/rc80211_minstrel_ht.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/rc80211_minstrel_ht.c +1 -1
index 5a882da82f0e..ba230b037257 100644
@@ -575,7 +575,7 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
 
 		/* (re)Initialize group rate indexes */
 		for(j = 0; j < MAX_THR_RATES; j++)
-			tmp_group_tp_rate[j] = group;
+			tmp_group_tp_rate[j] = MCS_GROUP_RATES * group;
 
 		for (i = 0; i < MCS_GROUP_RATES; i++) {
 			if (!(mi->supported[group] & BIT(i)))
Signature · 1 line
2.17.0
#1 lore raw

PATCH 2/4 mac80211: minstrel_ht: reduce unnecessary rate probing attempts

On hardware with static fallback tables (e.g. mt76x2), rate probing attempts can be very expensive.
On such devices, avoid sampling rates slower than the per-group max throughput rate, based on the assumption that the fallback table will take care of probing lower rates within that group if the higher rates fail.
To make this work, this also fixes a wrong initialization in the previously unused per-group sorted rate array.
To further reduce unnecessary probing attempts, skip duplicate attempts on rates slower than the max throughput rate.

---
 net/mac80211/rc80211_minstrel_ht.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
net/mac80211/rc80211_minstrel_ht.c +15 -0
index ba230b037257..ad5da9a71da0 100644
@@ -1059,6 +1059,21 @@ minstrel_get_sample_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
 	    minstrel_get_duration(mi->max_prob_rate) * 3 < sample_dur)
 		return -1;
 
+
+	/*
+	 * For devices with no configurable multi-rate retry, skip sampling
+	 * below the per-group max throughput rate, and only use one sampling
+	 * attempt per rate
+	 */
+	if (mp->hw->max_rates == 1 &&
+	    (minstrel_get_duration(mg->max_group_tp_rate[0]) < sample_dur ||
+	     mrs->attempts))
+		return -1;
+
+	/* Skip already sampled slow rates */
+	if (sample_dur >= minstrel_get_duration(tp_rate1) && mrs->attempts)
+		return -1;
+
 	/*
 	 * Make sure that lower rates get sampled only occasionally,
 	 * if the link is working perfectly.
Signature · 1 line
2.17.0
#2 lore raw

PATCH 3/4 mac80211: minstrel_ht: fix default max throughput rate indexes

In reply to Felix Fietkau

Use the first supported rate instead of 0 (which can be invalid)

---
 net/mac80211/rc80211_minstrel_ht.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
net/mac80211/rc80211_minstrel_ht.c +14 -6
index ad5da9a71da0..c5868a1de306 100644
@@ -486,7 +486,7 @@ minstrel_ht_assign_best_tp_rates(struct minstrel_ht_sta *mi,
 	tmp_prob = mi->groups[tmp_group].rates[tmp_idx].prob_ewma;
 	tmp_mcs_tp = minstrel_ht_get_tp_avg(mi, tmp_group, tmp_idx, tmp_prob);
 
-	if (tmp_cck_tp > tmp_mcs_tp) {
+	if (tmp_cck_tp_rate && tmp_cck_tp > tmp_mcs_tp) {
 		for(i = 0; i < MAX_THR_RATES; i++) {
 			minstrel_ht_sort_best_tp_rates(mi, tmp_cck_tp_rate[i],
 						       tmp_mcs_tp_rate);
@@ -558,11 +558,19 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
 	mi->sample_slow = 0;
 	mi->sample_count = 0;
 
-	/* Initialize global rate indexes */
-	for(j = 0; j < MAX_THR_RATES; j++){
-		tmp_mcs_tp_rate[j] = 0;
-		tmp_cck_tp_rate[j] = 0;
-	}
+	memset(tmp_mcs_tp_rate, 0, sizeof(tmp_mcs_tp_rate));
+	memset(tmp_cck_tp_rate, 0, sizeof(tmp_cck_tp_rate));
+	if (mi->supported[MINSTREL_CCK_GROUP])
+		for (j = 0; j < ARRAY_SIZE(tmp_cck_tp_rate); j++)
+			tmp_cck_tp_rate[j] = MINSTREL_CCK_GROUP * MCS_GROUP_RATES;
+
+	if (mi->supported[MINSTREL_VHT_GROUP_0])
+		index = MINSTREL_VHT_GROUP_0 * MCS_GROUP_RATES;
+	else
+		index = MINSTREL_HT_GROUP_0 * MCS_GROUP_RATES;
+
+	for (j = 0; j < ARRAY_SIZE(tmp_mcs_tp_rate); j++)
+		tmp_mcs_tp_rate[j] = index;
 
 	/* Find best rate sets within all MCS groups*/
 	for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) {
Signature · 1 line
2.17.0
#3 lore raw

PATCH 4/4 mac80211: minstrel_ht: improve rate probing for devices with static fallback

In reply to Felix Fietkau

On some devices that only support static rate fallback tables sending rate control probing packets can be really expensive.
Probing lower rates can already hurt throughput quite a bit. What hurts even more is the fact that on mt76x0/mt76x2, single probing packets can only be forced by directing packets at a different internal hardware queue, which causes some heavy reordering and extra latency.
The reordering issue is mainly problematic while pushing lots of packets to a particular station. If there is little activity, the overhead of probing is neglegible.

The static fallback behavior is designed to pretty much only handle rate control algorithms that use only a very limited set of rates on which the algorithm switches up/down based on packet error rate.

In order to better support that kind of hardware, this patch implements a different approach to rate probing where it switches to a slightly higher rate, waits for tx status feedback, then updates the stats and switches back to the new max throughput rate. This only triggers above a packet rate of 100 per stats interval (~50ms).
For that kind of probing, the code has to reduce the set of probing rates a lot more compared to single packet probing, so it uses only one packet per MCS group which is either slightly faster, or as close as possible to the max throughput rate.
This allows switching between similar rates with different numbers of streams. The algorithm assumes that the hardware will work its way lower within an MCS group in case of retransmissions, so that lower rates don't have to be probed by the high packets per second rate probing code.

To further reduce the search space, it also does not probe rates with lower channel bandwidth than the max throughput rate.

At the moment, these changes will only affect mt76x0/mt76x2.

---
 net/mac80211/rc80211_minstrel.h    |   1 +
 net/mac80211/rc80211_minstrel_ht.c | 240 +++++++++++++++++++++++++----
 net/mac80211/rc80211_minstrel_ht.h |  12 ++
 3 files changed, 225 insertions(+), 28 deletions(-)
net/mac80211/rc80211_minstrel.h +1 -0
index 3c96a853adbd..51d8b2c846e7 100644
@@ -95,6 +95,7 @@ struct minstrel_sta_info {
 struct minstrel_priv {
 	struct ieee80211_hw *hw;
 	bool has_mrr;
+	u32 sample_switch;
 	unsigned int cw_min;
 	unsigned int cw_max;
 	unsigned int max_retry;
net/mac80211/rc80211_minstrel_ht.c +212 -28

371 lines not on this page · raw message

net/mac80211/rc80211_minstrel_ht.h +12 -0
index 80296268c778..f938701e7ab7 100644
@@ -33,6 +33,7 @@ struct mcs_group {
 	u16 flags;
 	u8 streams;
 	u8 shift;
+	u8 bw;
 	u16 duration[MCS_GROUP_RATES];
 };
 
@@ -50,6 +51,12 @@ struct minstrel_mcs_group_data {
 	struct minstrel_rate_stats rates[MCS_GROUP_RATES];
 };
 
+enum minstrel_sample_mode {
+	MINSTREL_SAMPLE_IDLE,
+	MINSTREL_SAMPLE_ACTIVE,
+	MINSTREL_SAMPLE_PENDING,
+};
+
 struct minstrel_ht_sta {
 	struct ieee80211_sta *sta;
 
@@ -71,6 +78,8 @@ struct minstrel_ht_sta {
 	unsigned int overhead;
 	unsigned int overhead_rtscts;
 
+	unsigned int total_packets_last;
+	unsigned int total_packets_cur;
 	unsigned int total_packets;
 	unsigned int sample_packets;
 
@@ -82,6 +91,9 @@ struct minstrel_ht_sta {
 	u8 sample_count;
 	u8 sample_slow;
 
+	enum minstrel_sample_mode sample_mode;
+	u16 sample_rate;
+
 	/* current MCS group to be sampled */
 	u8 sample_group;
 
Signature · 1 line
2.17.0