Skip to contentSkip to conversation

mac80211: minstrel_ht: add basic support for VHT rates <= 80MHz

RFC In review Karl Beldan 1 participant 7 messages Nov 12, 2013 – Nov 13, 2013 mac80211

lore
Share & tools
lore
#0 lore raw

RFC 1/2 mac80211: minstrel_ht: add basic support for VHT rates <= 80MHz

From: Karl Beldan <[email protected]>

Helps feel current minstrel and stack rate-control API limits. Helped trigger some bugs in vht tx code path in the past. Some ppl were interested in checking that out.
some TODOs:
- Optimize rate-indexes loops and sampling holes
- The txinfo flags for vht STAs

VHT rates support depends on a new CONFIG_MAC80211_RC_MINSTREL_VHT.

---
 net/mac80211/Kconfig                       |   7 +
 net/mac80211/rc80211_minstrel_ht.c         | 235 ++++++++++++++++++++++++-----
 net/mac80211/rc80211_minstrel_ht.h         |  33 +++-
 net/mac80211/rc80211_minstrel_ht_debugfs.c |  30 ++--
 4 files changed, 248 insertions(+), 57 deletions(-)
net/mac80211/Kconfig +7 -0
index 62535fe..190b59e 100644
@@ -40,6 +40,13 @@ config MAC80211_RC_MINSTREL_HT
 	---help---
 	  This option enables the 'minstrel_ht' TX rate control algorithm
 
+config MAC80211_RC_MINSTREL_VHT
+	bool "Minstrel 802.11vht 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
net/mac80211/rc80211_minstrel_ht.c +195 -40

354 lines not on this page · raw message

net/mac80211/rc80211_minstrel_ht.h +28 -5
index d655586..71f5a13 100644
@@ -13,10 +13,33 @@
  * 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
+#ifdef CONFIG_MAC80211_RC_MINSTREL_VHT
+#define MINSTREL_VHT_MAX_STREAMS	2
+#else
+#define MINSTREL_VHT_MAX_STREAMS	0
+#endif
+#define MINSTREL_VHT_STREAM_GROUPS	6 /* BW(=3)*SGI(=2)*/
+
+#define MINSTREL_HT_MAX_STREAMS		3
+#define MINSTREL_HT_STREAM_GROUPS	4
+
 
-#define MCS_GROUP_RATES	8
+#define MINSTREL_HT_GROUPS_NB	(MINSTREL_HT_MAX_STREAMS * MINSTREL_HT_STREAM_GROUPS)
+#define MINSTREL_VHT_GROUPS_NB  (MINSTREL_VHT_MAX_STREAMS * MINSTREL_VHT_STREAM_GROUPS)
+#define MINSTREL_CCK_GROUPS_NB	1
+#define MINSTREL_GROUPS_NB	(MINSTREL_HT_GROUPS_NB +	\
+				 MINSTREL_VHT_GROUPS_NB +	\
+				 MINSTREL_CCK_GROUPS_NB)
+
+#define MINSTREL_HT_GROUP_0	0
+#define MINSTREL_CCK_GROUP	(MINSTREL_HT_GROUP_0 + MINSTREL_HT_GROUPS_NB)
+#define MINSTREL_VHT_GROUP_0	(MINSTREL_CCK_GROUP + 1)
+
+#ifdef CONFIG_MAC80211_RC_MINSTREL_VHT
+#define MCS_GROUP_RATES		10
+#else
+#define MCS_GROUP_RATES		8
+#endif
 
 struct mcs_group {
 	u32 flags;
@@ -53,7 +76,7 @@ struct minstrel_mcs_group_data {
 	u8 column;
 
 	/* bitfield of supported MCS rates of this group */
-	u8 supported;
+	u16 supported;
 
 	/* selected primary rates */
 	unsigned int max_tp_rate;
@@ -109,7 +132,7 @@ struct minstrel_ht_sta {
 	u8 cck_supported_short;
 
 	/* MCS rate group info and statistics */
-	struct minstrel_mcs_group_data groups[MINSTREL_MAX_STREAMS * MINSTREL_STREAM_GROUPS + 1];
+	struct minstrel_mcs_group_data groups[MINSTREL_GROUPS_NB];
 };
 
 struct minstrel_ht_sta_priv {
net/mac80211/rc80211_minstrel_ht_debugfs.c +18 -12
index 3e7d793..cac3ada 100644
@@ -18,7 +18,6 @@
 static char *
 minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p)
 {
-	unsigned int max_mcs = MINSTREL_MAX_STREAMS * MINSTREL_STREAM_GROUPS;
 	const struct mcs_group *mg;
 	unsigned int j, tp, prob, eprob;
 	char htmode = '2';
@@ -30,6 +29,8 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p)
 	mg = &minstrel_mcs_groups[i];
 	if (mg->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
 		htmode = '4';
+	else if (mg->flags & IEEE80211_TX_RC_80_MHZ_WIDTH)
+		htmode = '8';
 	if (mg->flags & IEEE80211_TX_RC_SHORT_GI)
 		gimode = 'S';
 
@@ -41,27 +42,31 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p)
 		if (!(mi->groups[i].supported & BIT(j)))
 			continue;
 
-		if (i == max_mcs)
-			p += sprintf(p, "CCK/%cP   ", j < 4 ? 'L' : 'S');
+		if (i == MINSTREL_CCK_GROUP)
+			p += sprintf(p, " CCK/%cP   ", j < 4 ? 'L' : 'S');
+		else if (i >= MINSTREL_VHT_GROUP_0)
+			p += sprintf(p, "VHT%c0/%cGI ", htmode, gimode);
 		else
-			p += sprintf(p, "HT%c0/%cGI ", htmode, gimode);
+			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' : ' ';
 
-		if (i == max_mcs) {
+		if (i == MINSTREL_CCK_GROUP) {
 			int r = bitrates[j % 4];
-			p += sprintf(p, " %2u.%1uM", r / 10, r % 10);
+			p += sprintf(p, " %2u.%1uM    ", r / 10, r % 10);
+		} else if (i >= MINSTREL_VHT_GROUP_0) {
+			p += sprintf(p, " MCS%-2u   %1u", j, mg->streams);
 		} else {
-			p += sprintf(p, " MCS%-2u", (mg->streams - 1) * 8 + j);
+			p += sprintf(p, " MCS%-2u    ", (mg->streams - 1) * 8 + 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    "
+		p += sprintf(p, "    %6u.%1u   %6u.%1u    %6u.%1u    "
 				"%3u            %3u(%3u)  %8llu    %8llu\n",
 				tp / 10, tp % 10,
 				eprob / 10, eprob % 10,
@@ -83,7 +88,6 @@ minstrel_ht_stats_open(struct inode *inode, struct file *file)
 	struct minstrel_ht_sta *mi = &msp->ht;
 	struct minstrel_debugfs_info *ms;
 	unsigned int i;
-	unsigned int max_mcs = MINSTREL_MAX_STREAMS * MINSTREL_STREAM_GROUPS;
 	char *p;
 	int ret;
 
@@ -100,11 +104,13 @@ minstrel_ht_stats_open(struct inode *inode, struct file *file)
 
 	file->private_data = ms;
 	p = ms->buf;
-	p += sprintf(p, "type         rate     throughput  ewma prob   this prob  "
+	p += sprintf(p, "     type      rate nss  throughput  ewma prob   this prob  "
 			"retry   this succ/attempt   success    attempts\n");
 
-	p = minstrel_ht_stats_dump(mi, max_mcs, p);
-	for (i = 0; i < max_mcs; i++)
+	p = minstrel_ht_stats_dump(mi, MINSTREL_CCK_GROUP, p);
+	for (i = 0; i < MINSTREL_CCK_GROUP; i++)
+		p = minstrel_ht_stats_dump(mi, i, p);
+	for (i++; i < ARRAY_SIZE(mi->groups); i++)
 		p = minstrel_ht_stats_dump(mi, i, p);
 
 	p += sprintf(p, "\nTotal packet count::    ideal %d      "
Signature · 1 line
1.8.2
#1 lore raw

RFC 2/2 fixup! mac80211: minstrel_ht: add basic support for VHT rates <= 80MHz

From: Karl Beldan <[email protected]>

---
 net/mac80211/rc80211_minstrel_ht.c | 34 ++++++++++++++--------------------
 1 file changed, 14 insertions(+), 20 deletions(-)
net/mac80211/rc80211_minstrel_ht.c +14 -20
index dd81516..c3aa1a9 100644
@@ -52,6 +52,7 @@
 	[GROUP_IDX(_streams, _sgi, _ht40)] = {				\
 	.streams = _streams,						\
 	.flags =							\
+		IEEE80211_TX_RC_MCS |					\
 		(_sgi ? IEEE80211_TX_RC_SHORT_GI : 0) |			\
 		(_ht40 ? IEEE80211_TX_RC_40_MHZ_WIDTH : 0),		\
 	.duration = {							\
@@ -79,6 +80,7 @@
 	[VHT_GROUP_IDX(_streams, _sgi, _bw)] = {				\
 	.streams = _streams,							\
 	.flags =								\
+		IEEE80211_TX_RC_VHT_MCS |					\
 		(_sgi ? IEEE80211_TX_RC_SHORT_GI : 0) |				\
 		(_bw == BW_80 ? IEEE80211_TX_RC_80_MHZ_WIDTH :			\
 		 _bw == BW_40 ? IEEE80211_TX_RC_40_MHZ_WIDTH : 0),		\
@@ -115,6 +117,7 @@
 #define CCK_GROUP					\
 	[MINSTREL_CCK_GROUP] = {			\
 		.streams = 0,				\
+		.flags = 0,				\
 		.duration = {				\
 			CCK_DURATION_LIST(false),	\
 			CCK_DURATION_LIST(true)		\
@@ -721,7 +724,7 @@ minstrel_ht_set_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
 	const struct mcs_group *group = &minstrel_mcs_groups[index / MCS_GROUP_RATES];
 	struct minstrel_rate_stats *mr;
 	u8 idx;
-	u16 flags;
+	u16 flags = group->flags;
 
 	mr = minstrel_get_ratestats(mi, index);
 	if (!mr->retry_updated)
@@ -737,17 +740,13 @@ minstrel_ht_set_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
 		ratetbl->rate[offset].count_rts = mr->retry_count_rtscts;
 	}
 
-	if (index / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) {
+	if (index / MCS_GROUP_RATES == MINSTREL_CCK_GROUP)
 		idx = mp->cck_rates[index % ARRAY_SIZE(mp->cck_rates)];
-		flags = 0;
-	} else if (index / MCS_GROUP_RATES >= MINSTREL_VHT_GROUP_0) {
+	else if (flags & IEEE80211_TX_RC_VHT_MCS)
 		idx = ((group->streams - 1) << 4) |
 		      ((index % MCS_GROUP_RATES) & ~0xF);
-		flags = IEEE80211_TX_RC_VHT_MCS | group->flags;
-	} else {
+	else
 		idx = index % MCS_GROUP_RATES + (group->streams - 1) * 8;
-		flags = IEEE80211_TX_RC_MCS | group->flags;
-	}
 
 	if (offset > 0) {
 		ratetbl->rate[offset].count = ratetbl->rate[offset].count_rts;
@@ -924,18 +923,15 @@ minstrel_ht_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
 	if (sample_idx / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) {
 		int idx = sample_idx % ARRAY_SIZE(mp->cck_rates);
 		rate->idx = mp->cck_rates[idx];
-		rate->flags = 0;
-		return;
-	} else if (sample_idx / MCS_GROUP_RATES >= MINSTREL_VHT_GROUP_0) {
-		rate->flags = IEEE80211_TX_RC_VHT_MCS | sample_group->flags;
+	} else if (sample_group->flags & IEEE80211_TX_RC_VHT_MCS) {
 		ieee80211_rate_set_vht(rate, sample_idx % MCS_GROUP_RATES,
 				       sample_group->streams);
-		return;
+	} else {
+		rate->idx = sample_idx % MCS_GROUP_RATES +
+			(sample_group->streams - 1) * 8;
 	}
 
-	rate->idx = sample_idx % MCS_GROUP_RATES +
-		    (sample_group->streams - 1) * 8;
-	rate->flags = IEEE80211_TX_RC_MCS | sample_group->flags;
+	rate->flags = sample_group->flags;
 }
 
 static void
@@ -1033,10 +1029,8 @@ minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband,
 			continue;
 		}
 
-#ifdef CONFIG_MAC80211_RC_MINSTREL_VHT /* FIXME otherwise MINSTREL_VHT_GROUP_0 is 0 */
-		if (vht_only && i < MINSTREL_VHT_GROUP_0)
+		if (vht_only && !(gflags & IEEE80211_TX_RC_VHT_MCS))
 			continue;
-#endif
 
 		if (gflags & IEEE80211_TX_RC_SHORT_GI) {
 			if (gflags & IEEE80211_TX_RC_40_MHZ_WIDTH) {
@@ -1057,7 +1051,7 @@ minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband,
 		    minstrel_mcs_groups[i].streams > 1)
 			continue;
 
-		if (i >= MINSTREL_VHT_GROUP_0) {
+		if (gflags & IEEE80211_TX_RC_VHT_MCS) {
 			int bw;
 			if (!vht_cap->vht_supported)
 				continue;
Signature · 1 line
1.8.2
#2 lore raw
In reply to Karl Beldan
Quoted 11 lines · Karl Beldan

From: Karl Beldan <[email protected]>

Helps feel current minstrel and stack rate-control API limits. Helped trigger some bugs in vht tx code path in the past. Some ppl were interested in checking that out.
some TODOs:
- Optimize rate-indexes loops and sampling holes
- The txinfo flags for vht STAs

VHT rates support depends on a new CONFIG_MAC80211_RC_MINSTREL_VHT.

Quoted 8 lines
---
 net/mac80211/Kconfig                       |   7 +
 net/mac80211/rc80211_minstrel_ht.c         | 235 ++++++++++++++++++++++++-----
 net/mac80211/rc80211_minstrel_ht.h         |  33 +++-
 net/mac80211/rc80211_minstrel_ht_debugfs.c |  30 ++--
 4 files changed, 248 insertions(+), 57 deletions(-)

This commit log is temporary as I am sure I'll have to respin.

Karl

#3 lore raw
In reply to Karl Beldan
Quoted 11 lines · Karl Beldan

From: Karl Beldan <[email protected]>

Helps feel current minstrel and stack rate-control API limits. Helped trigger some bugs in vht tx code path in the past. Some ppl were interested in checking that out.
some TODOs:
- Optimize rate-indexes loops and sampling holes
- The txinfo flags for vht STAs

VHT rates support depends on a new CONFIG_MAC80211_RC_MINSTREL_VHT.

This relies on
[mac80211: minstrel_ht: replace some occurences of MCS_GROUP_RATES]
http://marc.info/?l=linux-wireless&m=138418939213230&w=2

Karl

#4 lore raw

PATCH 1/1 squash! mac80211: minstrel_ht: add basic support for VHT rates <= 80MHz

In reply to Karl Beldan

From: Karl Beldan <[email protected]>

For v2:
- In case vht is supported but CONFIG_MAC80211_RC_MINSTREL_VHT is not set or the sta vht tx map has no rate supported (not sure the latter can happen) set vht_only to 0 to not fallback to legacy.

---
 net/mac80211/rc80211_minstrel_ht.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
net/mac80211/rc80211_minstrel_ht.c +7 -1
index a1f3f75..88c932e 100644
@@ -985,7 +985,13 @@ minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband,
 	BUILD_BUG_ON(ARRAY_SIZE(minstrel_mcs_groups) != MINSTREL_GROUPS_NB);
 
 	/* For the moment be less verbose and disable ht rates for a vht sta */
-	vht_only = vht_cap->vht_supported;
+#ifdef CONFIG_MAC80211_RC_MINSTREL_VHT
+       if (vht_cap->vht_supported)
+               vht_only = vht_cap->vht_mcs.tx_mcs_map != cpu_to_le16(~0);
+       else
+#endif
+	vht_only = 0;
+
 
 	msp->is_ht = true;
 	memset(mi, 0, sizeof(*mi));
Signature · 1 line
1.8.2
#5 lore raw

RFC 1/1 squash! mac80211: minstrel_ht: add basic support for VHT rates <= 80MHz

In reply to Karl Beldan

From: Karl Beldan <[email protected]>

For v2:
- Don't test for IEEE80211_HT_CAP_LDPC_CODING when using vht_only

---
 net/mac80211/rc80211_minstrel_ht.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
net/mac80211/rc80211_minstrel_ht.c +2 -3
index 6c173a2..04c35cd 100644
@@ -1022,11 +1022,10 @@ minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband,
 		stbc = (sta_cap & IEEE80211_HT_CAP_RX_STBC) >>
 			IEEE80211_HT_CAP_RX_STBC_SHIFT;
 		mi->tx_flags |= stbc << IEEE80211_TX_CTL_STBC_SHIFT;
+		if (sta_cap & IEEE80211_HT_CAP_LDPC_CODING)
+			mi->tx_flags |= IEEE80211_TX_CTL_LDPC;
 	}
 
-	if (sta_cap & IEEE80211_HT_CAP_LDPC_CODING)
-		mi->tx_flags |= IEEE80211_TX_CTL_LDPC;
-
 	for (i = 0; i < ARRAY_SIZE(mi->groups); i++) {
 		u32 gflags = minstrel_mcs_groups[i].flags;
 
Signature · 1 line
1.8.2
#6 lore raw

RFC 1/1 squash! mac80211: minstrel_ht: add basic support for VHT rates <= 80MHz

In reply to Karl Beldan

From: Karl Beldan <[email protected]>

For v2:
- typo in vht mcs mask in minstrel_ht_set_rate

---
 net/mac80211/rc80211_minstrel_ht.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/rc80211_minstrel_ht.c +1 -1
index 520da45..8572b8f 100644
@@ -745,7 +745,7 @@ minstrel_ht_set_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
 		idx = mp->cck_rates[index % ARRAY_SIZE(mp->cck_rates)];
 	else if (flags & IEEE80211_TX_RC_VHT_MCS)
 		idx = ((group->streams - 1) << 4) |
-		      ((index % MCS_GROUP_RATES) & ~0xF);
+		      ((index % MCS_GROUP_RATES) & 0xF);
 	else
 		idx = index % MCS_GROUP_RATES + (group->streams - 1) * 8;
 
Signature · 1 line
1.8.2