diff options
author | Stephen Douthit <stephen.douthit@gmail.com> | 2023-02-13 21:40:24 +0100 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2023-09-13 16:24:05 +0200 |
commit | 3e99b4d282195435a9271fb738c4b146a9d35a5a (patch) | |
tree | 04b78bced61fdd8907513e4abfcb2e44f41202f1 /net | |
parent | wifi: iwlwifi: mvm: add a debug print when we get a BAR (diff) | |
download | linux-3e99b4d282195435a9271fb738c4b146a9d35a5a.tar.xz linux-3e99b4d282195435a9271fb738c4b146a9d35a5a.zip |
wifi: mac80211: Sanity check tx bitrate if not provided by driver
If the driver doesn't fill NL80211_STA_INFO_TX_BITRATE in sta_set_sinfo()
then as a fallback sta->deflink.tx_stats.last_rate is used. Unfortunately
there's no guarantee that this has actually been set before it's used.
Originally found when 'iw <dev> link' would always return a tx rate of
6Mbps regardless of actual link speed for the QCA9337 running firmware
WLAN.TF.2.1-00021-QCARMSWP-1 in my netbook.
Use the sanity check logic from ieee80211_fill_rx_status() and refactor
that to use the new inline function.
Signed-off-by: Stephen Douthit <stephen.douthit@gmail.com>
Link: https://lore.kernel.org/r/20230213204024.3377-1-stephen.douthit@gmail.com
[change to bool ..._rate_valid() instead of int ..._rate_invalid()]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/mac80211/airtime.c | 2 | ||||
-rw-r--r-- | net/mac80211/sta_info.c | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/net/mac80211/airtime.c b/net/mac80211/airtime.c index 14be7b526f1d..fdf8b658fede 100644 --- a/net/mac80211/airtime.c +++ b/net/mac80211/airtime.c @@ -557,7 +557,7 @@ static int ieee80211_fill_rx_status(struct ieee80211_rx_status *stat, if (ieee80211_fill_rate_info(hw, stat, band, ri)) return 0; - if (rate->idx < 0 || !rate->count) + if (!ieee80211_rate_valid(rate)) return -1; if (rate->flags & IEEE80211_TX_RC_160_MHZ_WIDTH) diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index 7243c6aa2161..ba36fc29e532 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -2703,7 +2703,8 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo, } if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_BITRATE)) && - !sta->sta.valid_links) { + !sta->sta.valid_links && + ieee80211_rate_valid(&sta->deflink.tx_stats.last_rate)) { sta_set_rate_info_tx(sta, &sta->deflink.tx_stats.last_rate, &sinfo->txrate); sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE); |