90da6a8c44aff2daf62871866f9cf6a44cf8ea2c
[openwrt/staging/ansuel.git] /
1 From 9e61589ac3c2d23c528d3ffd44604d98553ea1cb Mon Sep 17 00:00:00 2001
2 From: Kalle Valo <quic_kvalo@quicinc.com>
3 Date: Wed, 27 Sep 2023 17:27:08 +0300
4 Subject: [PATCH] wifi: ath11k: mac: fix struct ieee80211_sband_iftype_data
5 handling
6
7 Commit e8c1841278a7 ("wifi: cfg80211: annotate iftype_data pointer with
8 sparse") added sparse checks for struct ieee80211_sband_iftype_data handling
9 which immediately found an issue in ath11k:
10
11 drivers/net/wireless/ath/ath11k/mac.c:7952:22: warning: incorrect type in argument 1 (different address spaces)
12 drivers/net/wireless/ath/ath11k/mac.c:7952:22: expected struct ieee80211_sta_he_cap const *he_cap
13 drivers/net/wireless/ath/ath11k/mac.c:7952:22: got struct ieee80211_sta_he_cap const [noderef] __iftype_data *
14
15 The problem here is that we are accessing sband->iftype_data directly even
16 though we should use for_each_sband_iftype_data() or similar. Fortunately
17 there's ieee80211_get_he_iftype_cap_vif() which is just what we need here so
18 use it to get HE capabilities.
19
20 Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.23
21
22 Reported-by: Johannes Berg <johannes@sipsolutions.net>
23 Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
24 Link: https://lore.kernel.org/r/20230927142708.2897504-2-kvalo@kernel.org
25 ---
26 drivers/net/wireless/ath/ath11k/mac.c | 10 ++++++++--
27 1 file changed, 8 insertions(+), 2 deletions(-)
28
29 --- a/drivers/net/wireless/ath/ath11k/mac.c
30 +++ b/drivers/net/wireless/ath/ath11k/mac.c
31 @@ -7913,12 +7913,14 @@ ath11k_mac_get_tx_mcs_map(const struct i
32
33 static bool
34 ath11k_mac_bitrate_mask_get_single_nss(struct ath11k *ar,
35 + struct ath11k_vif *arvif,
36 enum nl80211_band band,
37 const struct cfg80211_bitrate_mask *mask,
38 int *nss)
39 {
40 struct ieee80211_supported_band *sband = &ar->mac.sbands[band];
41 u16 vht_mcs_map = le16_to_cpu(sband->vht_cap.vht_mcs.tx_mcs_map);
42 + const struct ieee80211_sta_he_cap *he_cap;
43 u16 he_mcs_map = 0;
44 u8 ht_nss_mask = 0;
45 u8 vht_nss_mask = 0;
46 @@ -7949,7 +7951,11 @@ ath11k_mac_bitrate_mask_get_single_nss(s
47 return false;
48 }
49
50 - he_mcs_map = le16_to_cpu(ath11k_mac_get_tx_mcs_map(&sband->iftype_data->he_cap));
51 + he_cap = ieee80211_get_he_iftype_cap_vif(sband, arvif->vif);
52 + if (!he_cap)
53 + return false;
54 +
55 + he_mcs_map = le16_to_cpu(ath11k_mac_get_tx_mcs_map(he_cap));
56
57 for (i = 0; i < ARRAY_SIZE(mask->control[band].he_mcs); i++) {
58 if (mask->control[band].he_mcs[i] == 0)
59 @@ -8365,7 +8371,7 @@ ath11k_mac_op_set_bitrate_mask(struct ie
60 ieee80211_iterate_stations_atomic(ar->hw,
61 ath11k_mac_disable_peer_fixed_rate,
62 arvif);
63 - } else if (ath11k_mac_bitrate_mask_get_single_nss(ar, band, mask,
64 + } else if (ath11k_mac_bitrate_mask_get_single_nss(ar, arvif, band, mask,
65 &single_nss)) {
66 rate = WMI_FIXED_RATE_NONE;
67 nss = single_nss;