ath10k-ct: fix bandwidth conversion bug
[openwrt/openwrt.git] / package / kernel / ath10k-ct / patches / 210-ath10k-fix-recent-bandwidth-conversion-bug.patch
1 From 91493e8e10f0f495b04a5c32096d56ea1f254c93 Mon Sep 17 00:00:00 2001
2 From: Christian Lamparter <chunkeey@gmail.com>
3 Date: Wed, 28 Mar 2018 12:19:55 +0300
4 Subject: [PATCH] ath10k: fix recent bandwidth conversion bug
5
6 The commit "cfg80211: make RATE_INFO_BW_20 the default" changed
7 the index of RATE_INFO_BW_20, but the updates to ath10k missed
8 the special bandwidth calculation case in
9 ath10k_update_per_peer_tx_stats().
10
11 This will fix below warning,
12
13 WARNING: CPU: 0 PID: 609 at net/wireless/util.c:1254
14 cfg80211_calculate_bitrate+0x174/0x220
15 invalid rate bw=1, mcs=9, nss=2
16
17 (unwind_backtrace) from
18 (cfg80211_calculate_bitrate+0x174/0x220)
19 (cfg80211_calculate_bitrate) from
20 (nl80211_put_sta_rate+0x44/0x1dc)from
21 (nl80211_put_sta_rate) from
22 (nl80211_send_station+0x388/0xaf0)
23 (nl80211_get_station+0xa8/0xec)
24 [ end trace da8257d6a850e91a ]
25
26 Fixes: 842be75c77cb ("cfg80211: make RATE_INFO_BW_20 the default")
27 Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
28 Signed-off-by: Anilkumar Kolli <akolli@codeaurora.org>
29 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
30 ---
31 ath10k-4.16/htt_rx.c | 42 ++++++++++++++++++--------------
32 1 file changed, 24 insertions(+), 18 deletions(-)
33
34 --- a/ath10k-4.16/htt_rx.c
35 +++ b/ath10k-4.16/htt_rx.c
36 @@ -734,6 +734,28 @@ struct amsdu_subframe_hdr {
37
38 #define GROUP_ID_IS_SU_MIMO(x) ((x) == 0 || (x) == 63)
39
40 +static inline u8 ath10k_bw_to_mac80211_bw(u8 bw)
41 +{
42 + u8 ret = 0;
43 +
44 + switch (bw) {
45 + case 0:
46 + ret = RATE_INFO_BW_20;
47 + break;
48 + case 1:
49 + ret = RATE_INFO_BW_40;
50 + break;
51 + case 2:
52 + ret = RATE_INFO_BW_80;
53 + break;
54 + case 3:
55 + ret = RATE_INFO_BW_160;
56 + break;
57 + }
58 +
59 + return ret;
60 +}
61 +
62 static void ath10k_htt_rx_h_rates(struct ath10k *ar,
63 struct ieee80211_rx_status *status,
64 struct htt_rx_desc *rxd)
65 @@ -836,23 +858,7 @@ static void ath10k_htt_rx_h_rates(struct
66 if (sgi)
67 status->enc_flags |= RX_ENC_FLAG_SHORT_GI;
68
69 - switch (bw) {
70 - /* 20MHZ */
71 - case 0:
72 - break;
73 - /* 40MHZ */
74 - case 1:
75 - status->bw = RATE_INFO_BW_40;
76 - break;
77 - /* 80MHZ */
78 - case 2:
79 - status->bw = RATE_INFO_BW_80;
80 - break;
81 - case 3:
82 - status->bw = RATE_INFO_BW_160;
83 - break;
84 - }
85 -
86 + status->bw = ath10k_bw_to_mac80211_bw(bw);
87 status->encoding = RX_ENC_VHT;
88 break;
89 default:
90 @@ -2623,7 +2629,7 @@ ath10k_update_per_peer_tx_stats(struct a
91 arsta->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
92
93 arsta->txrate.nss = txrate.nss;
94 - arsta->txrate.bw = txrate.bw + RATE_INFO_BW_20;
95 + arsta->txrate.bw = ath10k_bw_to_mac80211_bw(txrate.bw);
96 }
97
98 static void ath10k_htt_fetch_peer_stats(struct ath10k *ar,