Commit 8ec7886b authored by Karl Beldan's avatar Karl Beldan Committed by Johannes Berg

mac80211: minstrel_ht: use group flags instead of index to display rates

When displaying a rate through debugfs minstrel_ht guesses its flags
comparing group indexes.  Since 3ec373c4 ("mac80211: minstrel_ht:
include type (cck/ht) in rates flag"), the rate flags of interest are
present in the mcs_group-s, so use it.
While improving the code, this also fixes a smatch false positive
"error: testing array offset 'i' after use" in minstrel_ht_stats_dump.
This warning only triggers after 9208247d ("mac80211: minstrel_ht:
add basic support for VHT rates <= 3SS@80MHz") with
CONFIG_MAC80211_RC_MINSTREL_VHT unset because then MINSTREL_VHT_GROUP_0
is above MINSTREL_GROUPS_NB and smatch only barks when the "testing
array offset" seems to prevent possible out of bonds accesses (which
does not happen here since i < ARRAY_SIZE(mi->groups)).
Signed-off-by: default avatarKarl Beldan <karl.beldan@rivierawaves.com>
Cc: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 4619194a
...@@ -22,16 +22,19 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p) ...@@ -22,16 +22,19 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p)
unsigned int j, tp, prob, eprob; unsigned int j, tp, prob, eprob;
char htmode = '2'; char htmode = '2';
char gimode = 'L'; char gimode = 'L';
u32 gflags;
if (!mi->groups[i].supported) if (!mi->groups[i].supported)
return p; return p;
mg = &minstrel_mcs_groups[i]; mg = &minstrel_mcs_groups[i];
if (mg->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) gflags = mg->flags;
if (gflags & IEEE80211_TX_RC_40_MHZ_WIDTH)
htmode = '4'; htmode = '4';
else if (mg->flags & IEEE80211_TX_RC_80_MHZ_WIDTH) else if (gflags & IEEE80211_TX_RC_80_MHZ_WIDTH)
htmode = '8'; htmode = '8';
if (mg->flags & IEEE80211_TX_RC_SHORT_GI) if (gflags & IEEE80211_TX_RC_SHORT_GI)
gimode = 'S'; gimode = 'S';
for (j = 0; j < MCS_GROUP_RATES; j++) { for (j = 0; j < MCS_GROUP_RATES; j++) {
...@@ -42,12 +45,12 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p) ...@@ -42,12 +45,12 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p)
if (!(mi->groups[i].supported & BIT(j))) if (!(mi->groups[i].supported & BIT(j)))
continue; continue;
if (i == MINSTREL_CCK_GROUP) if (gflags & IEEE80211_TX_RC_MCS)
p += sprintf(p, " CCK/%cP ", j < 4 ? 'L' : 'S'); p += sprintf(p, " HT%c0/%cGI ", htmode, gimode);
else if (i >= MINSTREL_VHT_GROUP_0) else if (gflags & IEEE80211_TX_RC_VHT_MCS)
p += sprintf(p, "VHT%c0/%cGI ", htmode, gimode); p += sprintf(p, "VHT%c0/%cGI ", htmode, gimode);
else else
p += sprintf(p, " HT%c0/%cGI ", htmode, gimode); p += sprintf(p, " CCK/%cP ", j < 4 ? 'L' : 'S');
*(p++) = (idx == mi->max_tp_rate[0]) ? 'A' : ' '; *(p++) = (idx == mi->max_tp_rate[0]) ? 'A' : ' ';
*(p++) = (idx == mi->max_tp_rate[1]) ? 'B' : ' '; *(p++) = (idx == mi->max_tp_rate[1]) ? 'B' : ' ';
...@@ -55,13 +58,14 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p) ...@@ -55,13 +58,14 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p)
*(p++) = (idx == mi->max_tp_rate[3]) ? 'D' : ' '; *(p++) = (idx == mi->max_tp_rate[3]) ? 'D' : ' ';
*(p++) = (idx == mi->max_prob_rate) ? 'P' : ' '; *(p++) = (idx == mi->max_prob_rate) ? 'P' : ' ';
if (i == MINSTREL_CCK_GROUP) { if (gflags & IEEE80211_TX_RC_MCS) {
int r = bitrates[j % 4]; p += sprintf(p, " MCS%-2u ", (mg->streams - 1) * 8 + j);
p += sprintf(p, " %2u.%1uM ", r / 10, r % 10); } else if (gflags & IEEE80211_TX_RC_VHT_MCS) {
} else if (i >= MINSTREL_VHT_GROUP_0) {
p += sprintf(p, " MCS%-1u/%1u", j, mg->streams); p += sprintf(p, " MCS%-1u/%1u", j, mg->streams);
} else { } else {
p += sprintf(p, " MCS%-2u ", (mg->streams - 1) * 8 + j); int r = bitrates[j % 4];
p += sprintf(p, " %2u.%1uM ", r / 10, r % 10);
} }
tp = mr->cur_tp / 10; tp = mr->cur_tp / 10;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment