generic: replace simple AQR hack patch with upstream version
[openwrt/staging/jow.git] / package / kernel / mac80211 / patches / ath11k / 0008-wifi-ath11k-Consistently-use-ath11k_vif_to_arvif.patch
1 From 9476cda44c136089f14f8951ae5197d63e91735c Mon Sep 17 00:00:00 2001
2 From: Jeff Johnson <quic_jjohnson@quicinc.com>
3 Date: Mon, 21 Aug 2023 07:13:36 -0700
4 Subject: [PATCH] wifi: ath11k: Consistently use ath11k_vif_to_arvif()
5
6 Helper function ath11k_vif_to_arvif() exists to retrieve a struct
7 ath11k_vif from a struct ieee80211_vif. However, in multiple places
8 this logic is open-coded with inline typecasting. Since the
9 typecasting prevents the compiler from type-checking the source and
10 destination, update the driver to consistently use the helper
11 function.
12
13 No functional changes, compile tested only.
14
15 Signed-off-by: Jeff Johnson <quic_jjohnson@quicinc.com>
16 Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
17 Link: https://lore.kernel.org/r/20230821-ath11k_vif_to_arvif-v1-1-fa2c3b60b5cf@quicinc.com
18 ---
19 drivers/net/wireless/ath/ath11k/mac.c | 64 +++++++++++-----------
20 drivers/net/wireless/ath/ath11k/testmode.c | 2 +-
21 2 files changed, 33 insertions(+), 33 deletions(-)
22
23 --- a/drivers/net/wireless/ath/ath11k/mac.c
24 +++ b/drivers/net/wireless/ath/ath11k/mac.c
25 @@ -566,7 +566,7 @@ static void ath11k_get_arvif_iter(void *
26 struct ieee80211_vif *vif)
27 {
28 struct ath11k_vif_iter *arvif_iter = data;
29 - struct ath11k_vif *arvif = (void *)vif->drv_priv;
30 + struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
31
32 if (arvif->vdev_id == arvif_iter->vdev_id)
33 arvif_iter->arvif = arvif;
34 @@ -1464,7 +1464,7 @@ static int ath11k_mac_setup_bcn_tmpl_ema
35 u32 params = 0;
36 u8 i = 0;
37
38 - tx_arvif = (void *)arvif->vif->mbssid_tx_vif->drv_priv;
39 + tx_arvif = ath11k_vif_to_arvif(arvif->vif->mbssid_tx_vif);
40
41 beacons = ieee80211_beacon_get_template_ema_list(tx_arvif->ar->hw,
42 tx_arvif->vif, 0);
43 @@ -1520,8 +1520,8 @@ static int ath11k_mac_setup_bcn_tmpl_mbs
44 struct sk_buff *bcn;
45 int ret;
46
47 - if (arvif->vif->mbssid_tx_vif) {
48 - tx_arvif = (void *)arvif->vif->mbssid_tx_vif->drv_priv;
49 + if (vif->mbssid_tx_vif) {
50 + tx_arvif = ath11k_vif_to_arvif(vif->mbssid_tx_vif);
51 if (tx_arvif != arvif) {
52 ar = tx_arvif->ar;
53 ab = ar->ab;
54 @@ -1562,7 +1562,7 @@ static int ath11k_mac_setup_bcn_tmpl(str
55 * non-transmitting interfaces, and results in a crash if sent.
56 */
57 if (vif->mbssid_tx_vif &&
58 - arvif != (void *)vif->mbssid_tx_vif->drv_priv && arvif->is_up)
59 + arvif != ath11k_vif_to_arvif(vif->mbssid_tx_vif) && arvif->is_up)
60 return 0;
61
62 if (vif->bss_conf.ema_ap && vif->mbssid_tx_vif)
63 @@ -1626,7 +1626,7 @@ static void ath11k_control_beaconing(str
64 ether_addr_copy(arvif->bssid, info->bssid);
65
66 if (arvif->vif->mbssid_tx_vif)
67 - tx_arvif = (struct ath11k_vif *)arvif->vif->mbssid_tx_vif->drv_priv;
68 + tx_arvif = ath11k_vif_to_arvif(arvif->vif->mbssid_tx_vif);
69
70 ret = ath11k_wmi_vdev_up(arvif->ar, arvif->vdev_id, arvif->aid,
71 arvif->bssid,
72 @@ -1649,7 +1649,7 @@ static void ath11k_mac_handle_beacon_ite
73 {
74 struct sk_buff *skb = data;
75 struct ieee80211_mgmt *mgmt = (void *)skb->data;
76 - struct ath11k_vif *arvif = (void *)vif->drv_priv;
77 + struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
78
79 if (vif->type != NL80211_IFTYPE_STATION)
80 return;
81 @@ -1672,7 +1672,7 @@ static void ath11k_mac_handle_beacon_mis
82 struct ieee80211_vif *vif)
83 {
84 u32 *vdev_id = data;
85 - struct ath11k_vif *arvif = (void *)vif->drv_priv;
86 + struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
87 struct ath11k *ar = arvif->ar;
88 struct ieee80211_hw *hw = ar->hw;
89
90 @@ -1718,7 +1718,7 @@ static void ath11k_peer_assoc_h_basic(st
91 struct ieee80211_sta *sta,
92 struct peer_assoc_params *arg)
93 {
94 - struct ath11k_vif *arvif = (void *)vif->drv_priv;
95 + struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
96 u32 aid;
97
98 lockdep_assert_held(&ar->conf_mutex);
99 @@ -1746,7 +1746,7 @@ static void ath11k_peer_assoc_h_crypto(s
100 struct ieee80211_bss_conf *info = &vif->bss_conf;
101 struct cfg80211_chan_def def;
102 struct cfg80211_bss *bss;
103 - struct ath11k_vif *arvif = (struct ath11k_vif *)vif->drv_priv;
104 + struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
105 const u8 *rsnie = NULL;
106 const u8 *wpaie = NULL;
107
108 @@ -1804,7 +1804,7 @@ static void ath11k_peer_assoc_h_rates(st
109 struct ieee80211_sta *sta,
110 struct peer_assoc_params *arg)
111 {
112 - struct ath11k_vif *arvif = (void *)vif->drv_priv;
113 + struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
114 struct wmi_rate_set_arg *rateset = &arg->peer_legacy_rates;
115 struct cfg80211_chan_def def;
116 const struct ieee80211_supported_band *sband;
117 @@ -1867,7 +1867,7 @@ static void ath11k_peer_assoc_h_ht(struc
118 struct peer_assoc_params *arg)
119 {
120 const struct ieee80211_sta_ht_cap *ht_cap = &sta->deflink.ht_cap;
121 - struct ath11k_vif *arvif = (void *)vif->drv_priv;
122 + struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
123 struct cfg80211_chan_def def;
124 enum nl80211_band band;
125 const u8 *ht_mcs_mask;
126 @@ -2064,7 +2064,7 @@ static void ath11k_peer_assoc_h_vht(stru
127 struct peer_assoc_params *arg)
128 {
129 const struct ieee80211_sta_vht_cap *vht_cap = &sta->deflink.vht_cap;
130 - struct ath11k_vif *arvif = (void *)vif->drv_priv;
131 + struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
132 struct cfg80211_chan_def def;
133 enum nl80211_band band;
134 u16 *vht_mcs_mask;
135 @@ -2261,7 +2261,7 @@ static void ath11k_peer_assoc_h_he(struc
136 struct ieee80211_sta *sta,
137 struct peer_assoc_params *arg)
138 {
139 - struct ath11k_vif *arvif = (void *)vif->drv_priv;
140 + struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
141 struct cfg80211_chan_def def;
142 const struct ieee80211_sta_he_cap *he_cap = &sta->deflink.he_cap;
143 enum nl80211_band band;
144 @@ -2584,7 +2584,7 @@ static void ath11k_peer_assoc_h_qos(stru
145 struct ieee80211_sta *sta,
146 struct peer_assoc_params *arg)
147 {
148 - struct ath11k_vif *arvif = (void *)vif->drv_priv;
149 + struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
150
151 switch (arvif->vdev_type) {
152 case WMI_VDEV_TYPE_AP:
153 @@ -2747,7 +2747,7 @@ static void ath11k_peer_assoc_h_phymode(
154 struct ieee80211_sta *sta,
155 struct peer_assoc_params *arg)
156 {
157 - struct ath11k_vif *arvif = (void *)vif->drv_priv;
158 + struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
159 struct cfg80211_chan_def def;
160 enum nl80211_band band;
161 const u8 *ht_mcs_mask;
162 @@ -2933,7 +2933,7 @@ static bool ath11k_mac_vif_recalc_sta_he
163 struct ieee80211_vif *vif,
164 struct ieee80211_sta_he_cap *he_cap)
165 {
166 - struct ath11k_vif *arvif = (void *)vif->drv_priv;
167 + struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
168 struct ieee80211_he_cap_elem he_cap_elem = {0};
169 struct ieee80211_sta_he_cap *cap_band = NULL;
170 struct cfg80211_chan_def def;
171 @@ -2995,7 +2995,7 @@ static void ath11k_bss_assoc(struct ieee
172 struct ieee80211_bss_conf *bss_conf)
173 {
174 struct ath11k *ar = hw->priv;
175 - struct ath11k_vif *arvif = (void *)vif->drv_priv;
176 + struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
177 struct peer_assoc_params peer_arg;
178 struct ieee80211_sta *ap_sta;
179 struct ath11k_peer *peer;
180 @@ -3111,7 +3111,7 @@ static void ath11k_bss_disassoc(struct i
181 struct ieee80211_vif *vif)
182 {
183 struct ath11k *ar = hw->priv;
184 - struct ath11k_vif *arvif = (void *)vif->drv_priv;
185 + struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
186 int ret;
187
188 lockdep_assert_held(&ar->conf_mutex);
189 @@ -3160,7 +3160,7 @@ static void ath11k_recalculate_mgmt_rate
190 struct ieee80211_vif *vif,
191 struct cfg80211_chan_def *def)
192 {
193 - struct ath11k_vif *arvif = (void *)vif->drv_priv;
194 + struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
195 const struct ieee80211_supported_band *sband;
196 u8 basic_rate_idx;
197 int hw_rate_code;
198 @@ -4632,7 +4632,7 @@ static int ath11k_station_disassoc(struc
199 struct ieee80211_vif *vif,
200 struct ieee80211_sta *sta)
201 {
202 - struct ath11k_vif *arvif = (void *)vif->drv_priv;
203 + struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
204 int ret = 0;
205
206 lockdep_assert_held(&ar->conf_mutex);
207 @@ -5160,7 +5160,7 @@ static int ath11k_mac_op_sta_set_txpwr(s
208 struct ieee80211_sta *sta)
209 {
210 struct ath11k *ar = hw->priv;
211 - struct ath11k_vif *arvif = (void *)vif->drv_priv;
212 + struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
213 int ret = 0;
214 s16 txpwr;
215
216 @@ -5210,7 +5210,7 @@ static void ath11k_mac_op_sta_rc_update(
217 {
218 struct ath11k *ar = hw->priv;
219 struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
220 - struct ath11k_vif *arvif = (void *)vif->drv_priv;
221 + struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
222 struct ath11k_peer *peer;
223 u32 bw, smps;
224
225 @@ -5337,7 +5337,7 @@ static int ath11k_mac_op_conf_tx(struct
226 const struct ieee80211_tx_queue_params *params)
227 {
228 struct ath11k *ar = hw->priv;
229 - struct ath11k_vif *arvif = (void *)vif->drv_priv;
230 + struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
231 struct wmi_wmm_params_arg *p = NULL;
232 int ret;
233
234 @@ -6458,7 +6458,7 @@ static int ath11k_mac_setup_vdev_params_
235 return 0;
236 }
237
238 - tx_arvif = (void *)tx_vif->drv_priv;
239 + tx_arvif = ath11k_vif_to_arvif(tx_vif);
240
241 if (arvif->vif->bss_conf.nontransmitted) {
242 if (ar->hw->wiphy != ieee80211_vif_to_wdev(tx_vif)->wiphy)
243 @@ -7411,7 +7411,7 @@ ath11k_mac_update_vif_chan(struct ath11k
244 /* TODO: Update ar->rx_channel */
245
246 for (i = 0; i < n_vifs; i++) {
247 - arvif = (void *)vifs[i].vif->drv_priv;
248 + arvif = ath11k_vif_to_arvif(vifs[i].vif);
249
250 if (WARN_ON(!arvif->is_started))
251 continue;
252 @@ -7453,7 +7453,7 @@ ath11k_mac_update_vif_chan(struct ath11k
253
254 mbssid_tx_vif = arvif->vif->mbssid_tx_vif;
255 if (mbssid_tx_vif)
256 - tx_arvif = (struct ath11k_vif *)mbssid_tx_vif->drv_priv;
257 + tx_arvif = ath11k_vif_to_arvif(mbssid_tx_vif);
258
259 ret = ath11k_wmi_vdev_up(arvif->ar, arvif->vdev_id, arvif->aid,
260 arvif->bssid,
261 @@ -7549,7 +7549,7 @@ static int ath11k_start_vdev_delay(struc
262 {
263 struct ath11k *ar = hw->priv;
264 struct ath11k_base *ab = ar->ab;
265 - struct ath11k_vif *arvif = (void *)vif->drv_priv;
266 + struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
267 int ret;
268
269 if (WARN_ON(arvif->is_started))
270 @@ -7599,7 +7599,7 @@ ath11k_mac_op_assign_vif_chanctx(struct
271 {
272 struct ath11k *ar = hw->priv;
273 struct ath11k_base *ab = ar->ab;
274 - struct ath11k_vif *arvif = (void *)vif->drv_priv;
275 + struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
276 int ret;
277 struct peer_create_params param;
278
279 @@ -7689,7 +7689,7 @@ ath11k_mac_op_unassign_vif_chanctx(struc
280 {
281 struct ath11k *ar = hw->priv;
282 struct ath11k_base *ab = ar->ab;
283 - struct ath11k_vif *arvif = (void *)vif->drv_priv;
284 + struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
285 struct ath11k_peer *peer;
286 int ret;
287
288 @@ -8310,7 +8310,7 @@ ath11k_mac_op_set_bitrate_mask(struct ie
289 struct ieee80211_vif *vif,
290 const struct cfg80211_bitrate_mask *mask)
291 {
292 - struct ath11k_vif *arvif = (void *)vif->drv_priv;
293 + struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
294 struct cfg80211_chan_def def;
295 struct ath11k_pdev_cap *cap;
296 struct ath11k *ar = arvif->ar;
297 @@ -8907,7 +8907,7 @@ static int ath11k_mac_op_remain_on_chann
298 enum ieee80211_roc_type type)
299 {
300 struct ath11k *ar = hw->priv;
301 - struct ath11k_vif *arvif = (void *)vif->drv_priv;
302 + struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
303 struct scan_req_params arg;
304 int ret;
305 u32 scan_time_msec;
306 --- a/drivers/net/wireless/ath/ath11k/testmode.c
307 +++ b/drivers/net/wireless/ath/ath11k/testmode.c
308 @@ -350,7 +350,7 @@ static int ath11k_tm_cmd_wmi(struct ath1
309 if (ar->ab->fw_mode != ATH11K_FIRMWARE_MODE_FTM &&
310 (tag == WMI_TAG_VDEV_SET_PARAM_CMD || tag == WMI_TAG_UNIT_TEST_CMD)) {
311 if (vif) {
312 - arvif = (struct ath11k_vif *)vif->drv_priv;
313 + arvif = ath11k_vif_to_arvif(vif);
314 *ptr = arvif->vdev_id;
315 } else {
316 ret = -EINVAL;