wcn36xx: Fix warning due to bad rate_idx
authorLoic Poulain <loic.poulain@linaro.org>
Sat, 29 Aug 2020 03:38:41 +0000 (04:38 +0100)
committerKalle Valo <kvalo@codeaurora.org>
Wed, 2 Sep 2020 08:48:23 +0000 (11:48 +0300)
The rate_idx is the index of the bitrate in the supported rate table.
However the 5Ghz band has a smaller legacy bitrate table than 2.4Ghz
since it does not have the DSSS bitrates (1, 2, 5.5, 11).

So in 5Ghz band the index should adjusted accrodingly (-4).

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
[bod: Made sure fix is only applied if the rate_idx > n_bitrates]
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200829033846.2167619-6-bryan.odonoghue@linaro.org
drivers/net/wireless/ath/wcn36xx/txrx.c

index 90924f6106ee5b6d7a670037a5252a48bad4efb4..19f5e306848b0f0b2f31f5c44cc9026c1abae247 100644 (file)
@@ -230,6 +230,7 @@ int wcn36xx_rx_skb(struct wcn36xx *wcn, struct sk_buff *skb)
        const struct wcn36xx_rate *rate;
        struct ieee80211_hdr *hdr;
        struct wcn36xx_rx_bd *bd;
+       struct ieee80211_supported_band *sband;
        u16 fc, sn;
 
        /*
@@ -270,6 +271,14 @@ int wcn36xx_rx_skb(struct wcn36xx *wcn, struct sk_buff *skb)
                status.enc_flags = rate->encoding_flags;
                status.bw = rate->bw;
                status.rate_idx = rate->mcs_or_legacy_index;
+               sband = wcn->hw->wiphy->bands[status.band];
+
+               if (status.band == NL80211_BAND_5GHZ &&
+                   status.encoding == RX_ENC_LEGACY &&
+                   status.rate_idx >= sband->n_bitrates) {
+                       /* no dsss rates in 5Ghz rates table */
+                       status.rate_idx -= 4;
+               }
        } else {
                status.encoding = 0;
                status.bw = 0;