mac80211: minstrel: fix sampling/reporting of CCK rates in HT mode
authorFelix Fietkau <nbd@nbd.name>
Sat, 6 Oct 2018 17:35:05 +0000 (19:35 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 11 Oct 2018 14:01:03 +0000 (16:01 +0200)
Long/short preamble selection cannot be sampled separately, since it
depends on the BSS state. Because of that, sampling attempts to
currently not used preamble modes are not counted in the statistics,
which leads to CCK rates being sampled too often.

Fix statistics accounting for long/short preamble by increasing the
index where necessary.
Fix excessive CCK rate sampling by dropping unsupported sample attempts.

This improves throughput on 2.4 GHz channels

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/rc80211_minstrel_ht.c

index 6cc28ca5d4a612d7d6206fcd42f27cd695f02937..fdcb4e9b4560eb381e83be62f0f66f49934d9f25 100644 (file)
@@ -281,7 +281,8 @@ minstrel_ht_get_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
                                break;
 
                /* short preamble */
-               if (!(mi->supported[group] & BIT(idx)))
+               if ((mi->supported[group] & BIT(idx + 4)) &&
+                   (rate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE))
                        idx += 4;
        }
        return &mi->groups[group].rates[idx];
@@ -1080,18 +1081,23 @@ minstrel_ht_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
                return;
 
        sample_group = &minstrel_mcs_groups[sample_idx / MCS_GROUP_RATES];
+       sample_idx %= MCS_GROUP_RATES;
+
+       if (sample_group == &minstrel_mcs_groups[MINSTREL_CCK_GROUP] &&
+           (sample_idx >= 4) != txrc->short_preamble)
+               return;
+
        info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
        rate->count = 1;
 
-       if (sample_idx / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) {
+       if (sample_group == &minstrel_mcs_groups[MINSTREL_CCK_GROUP]) {
                int idx = sample_idx % ARRAY_SIZE(mp->cck_rates);
                rate->idx = mp->cck_rates[idx];
        } else if (sample_group->flags & IEEE80211_TX_RC_VHT_MCS) {
                ieee80211_rate_set_vht(rate, sample_idx % MCS_GROUP_RATES,
                                       sample_group->streams);
        } else {
-               rate->idx = sample_idx % MCS_GROUP_RATES +
-                           (sample_group->streams - 1) * 8;
+               rate->idx = sample_idx + (sample_group->streams - 1) * 8;
        }
 
        rate->flags = sample_group->flags;