]>
Commit | Line | Data |
---|---|---|
8ca151b5 JB |
1 | /****************************************************************************** |
2 | * | |
3 | * This file is provided under a dual BSD/GPLv2 license. When using or | |
4 | * redistributing this file, you may do so under either license. | |
5 | * | |
6 | * GPL LICENSE SUMMARY | |
7 | * | |
51368bf7 | 8 | * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. |
26d6c16b SS |
9 | * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH |
10 | * Copyright(c) 2016 - 2017 Intel Deutschland GmbH | |
63dd5d02 | 11 | * Copyright(c) 2018 Intel Corporation |
8ca151b5 JB |
12 | * |
13 | * This program is free software; you can redistribute it and/or modify | |
14 | * it under the terms of version 2 of the GNU General Public License as | |
15 | * published by the Free Software Foundation. | |
16 | * | |
17 | * This program is distributed in the hope that it will be useful, but | |
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
20 | * General Public License for more details. | |
21 | * | |
8ca151b5 | 22 | * The full GNU General Public License is included in this distribution |
410dc5aa | 23 | * in the file called COPYING. |
8ca151b5 JB |
24 | * |
25 | * Contact Information: | |
cb2f8277 | 26 | * Intel Linux Wireless <[email protected]> |
8ca151b5 JB |
27 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
28 | * | |
29 | * BSD LICENSE | |
30 | * | |
51368bf7 | 31 | * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. |
26d6c16b SS |
32 | * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH |
33 | * Copyright(c) 2016 - 2017 Intel Deutschland GmbH | |
514c3069 | 34 | * Copyright(c) 2018 Intel Corporation |
8ca151b5 JB |
35 | * All rights reserved. |
36 | * | |
37 | * Redistribution and use in source and binary forms, with or without | |
38 | * modification, are permitted provided that the following conditions | |
39 | * are met: | |
40 | * | |
41 | * * Redistributions of source code must retain the above copyright | |
42 | * notice, this list of conditions and the following disclaimer. | |
43 | * * Redistributions in binary form must reproduce the above copyright | |
44 | * notice, this list of conditions and the following disclaimer in | |
45 | * the documentation and/or other materials provided with the | |
46 | * distribution. | |
47 | * * Neither the name Intel Corporation nor the names of its | |
48 | * contributors may be used to endorse or promote products derived | |
49 | * from this software without specific prior written permission. | |
50 | * | |
51 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
52 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
53 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
54 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
55 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
56 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
57 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
58 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
59 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
60 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
61 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
62 | * | |
63 | *****************************************************************************/ | |
64 | #include <linux/kernel.h> | |
65 | #include <linux/slab.h> | |
66 | #include <linux/skbuff.h> | |
67 | #include <linux/netdevice.h> | |
68 | #include <linux/etherdevice.h> | |
f0c2646a | 69 | #include <linux/ip.h> |
2ee8f021 | 70 | #include <linux/if_arp.h> |
2f89a5d7 | 71 | #include <linux/time.h> |
8ca151b5 | 72 | #include <net/mac80211.h> |
7b1dd048 | 73 | #include <net/ieee80211_radiotap.h> |
f0c2646a | 74 | #include <net/tcp.h> |
8ca151b5 JB |
75 | |
76 | #include "iwl-op-mode.h" | |
77 | #include "iwl-io.h" | |
78 | #include "mvm.h" | |
79 | #include "sta.h" | |
80 | #include "time-event.h" | |
81 | #include "iwl-eeprom-parse.h" | |
8ca151b5 | 82 | #include "iwl-phy-db.h" |
507cadf2 | 83 | #include "testmode.h" |
d962f9b1 | 84 | #include "fw/error-dump.h" |
655e6d6d | 85 | #include "iwl-prph.h" |
88931cc9 | 86 | #include "iwl-nvm-parse.h" |
8ca151b5 JB |
87 | |
88 | static const struct ieee80211_iface_limit iwl_mvm_limits[] = { | |
89 | { | |
90 | .max = 1, | |
8eb38710 | 91 | .types = BIT(NL80211_IFTYPE_STATION), |
8ca151b5 | 92 | }, |
3c15a0fb JB |
93 | { |
94 | .max = 1, | |
8eb38710 IP |
95 | .types = BIT(NL80211_IFTYPE_AP) | |
96 | BIT(NL80211_IFTYPE_P2P_CLIENT) | | |
3c15a0fb JB |
97 | BIT(NL80211_IFTYPE_P2P_GO), |
98 | }, | |
99 | { | |
100 | .max = 1, | |
101 | .types = BIT(NL80211_IFTYPE_P2P_DEVICE), | |
102 | }, | |
8ca151b5 JB |
103 | }; |
104 | ||
105 | static const struct ieee80211_iface_combination iwl_mvm_iface_combinations[] = { | |
106 | { | |
2624a5ca | 107 | .num_different_channels = 2, |
8ca151b5 JB |
108 | .max_interfaces = 3, |
109 | .limits = iwl_mvm_limits, | |
110 | .n_limits = ARRAY_SIZE(iwl_mvm_limits), | |
111 | }, | |
112 | }; | |
113 | ||
77736923 | 114 | #ifdef CONFIG_IWLWIFI_BCAST_FILTERING |
2ee8f021 EP |
115 | /* |
116 | * Use the reserved field to indicate magic values. | |
117 | * these values will only be used internally by the driver, | |
118 | * and won't make it to the fw (reserved will be 0). | |
119 | * BC_FILTER_MAGIC_IP - configure the val of this attribute to | |
120 | * be the vif's ip address. in case there is not a single | |
121 | * ip address (0, or more than 1), this attribute will | |
122 | * be skipped. | |
123 | * BC_FILTER_MAGIC_MAC - set the val of this attribute to | |
124 | * the LSB bytes of the vif's mac address | |
125 | */ | |
126 | enum { | |
127 | BC_FILTER_MAGIC_NONE = 0, | |
128 | BC_FILTER_MAGIC_IP, | |
129 | BC_FILTER_MAGIC_MAC, | |
130 | }; | |
131 | ||
77736923 EP |
132 | static const struct iwl_fw_bcast_filter iwl_mvm_default_bcast_filters[] = { |
133 | { | |
134 | /* arp */ | |
135 | .discard = 0, | |
136 | .frame_type = BCAST_FILTER_FRAME_TYPE_ALL, | |
137 | .attrs = { | |
138 | { | |
139 | /* frame type - arp, hw type - ethernet */ | |
140 | .offset_type = | |
141 | BCAST_FILTER_OFFSET_PAYLOAD_START, | |
142 | .offset = sizeof(rfc1042_header), | |
143 | .val = cpu_to_be32(0x08060001), | |
144 | .mask = cpu_to_be32(0xffffffff), | |
145 | }, | |
2ee8f021 EP |
146 | { |
147 | /* arp dest ip */ | |
148 | .offset_type = | |
149 | BCAST_FILTER_OFFSET_PAYLOAD_START, | |
150 | .offset = sizeof(rfc1042_header) + 2 + | |
151 | sizeof(struct arphdr) + | |
152 | ETH_ALEN + sizeof(__be32) + | |
153 | ETH_ALEN, | |
154 | .mask = cpu_to_be32(0xffffffff), | |
155 | /* mark it as special field */ | |
156 | .reserved1 = cpu_to_le16(BC_FILTER_MAGIC_IP), | |
157 | }, | |
158 | }, | |
159 | }, | |
160 | { | |
161 | /* dhcp offer bcast */ | |
162 | .discard = 0, | |
163 | .frame_type = BCAST_FILTER_FRAME_TYPE_IPV4, | |
164 | .attrs = { | |
165 | { | |
166 | /* udp dest port - 68 (bootp client)*/ | |
167 | .offset_type = BCAST_FILTER_OFFSET_IP_END, | |
168 | .offset = offsetof(struct udphdr, dest), | |
169 | .val = cpu_to_be32(0x00440000), | |
170 | .mask = cpu_to_be32(0xffff0000), | |
171 | }, | |
172 | { | |
173 | /* dhcp - lsb bytes of client hw address */ | |
174 | .offset_type = BCAST_FILTER_OFFSET_IP_END, | |
175 | .offset = 38, | |
176 | .mask = cpu_to_be32(0xffffffff), | |
177 | /* mark it as special field */ | |
178 | .reserved1 = cpu_to_le16(BC_FILTER_MAGIC_MAC), | |
179 | }, | |
77736923 EP |
180 | }, |
181 | }, | |
182 | /* last filter must be empty */ | |
183 | {}, | |
184 | }; | |
185 | #endif | |
186 | ||
7498cf4c EP |
187 | void iwl_mvm_ref(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type) |
188 | { | |
7bb426ea | 189 | if (!iwl_mvm_is_d0i3_supported(mvm)) |
7498cf4c EP |
190 | return; |
191 | ||
192 | IWL_DEBUG_RPM(mvm, "Take mvm reference - type %d\n", ref_type); | |
576eeee9 EP |
193 | spin_lock_bh(&mvm->refs_lock); |
194 | mvm->refs[ref_type]++; | |
195 | spin_unlock_bh(&mvm->refs_lock); | |
7498cf4c EP |
196 | iwl_trans_ref(mvm->trans); |
197 | } | |
198 | ||
199 | void iwl_mvm_unref(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type) | |
200 | { | |
7bb426ea | 201 | if (!iwl_mvm_is_d0i3_supported(mvm)) |
7498cf4c EP |
202 | return; |
203 | ||
204 | IWL_DEBUG_RPM(mvm, "Leave mvm reference - type %d\n", ref_type); | |
576eeee9 | 205 | spin_lock_bh(&mvm->refs_lock); |
16c45822 SS |
206 | if (WARN_ON(!mvm->refs[ref_type])) { |
207 | spin_unlock_bh(&mvm->refs_lock); | |
208 | return; | |
209 | } | |
210 | mvm->refs[ref_type]--; | |
576eeee9 | 211 | spin_unlock_bh(&mvm->refs_lock); |
7498cf4c EP |
212 | iwl_trans_unref(mvm->trans); |
213 | } | |
214 | ||
576eeee9 EP |
215 | static void iwl_mvm_unref_all_except(struct iwl_mvm *mvm, |
216 | enum iwl_mvm_ref_type except_ref) | |
7498cf4c | 217 | { |
576eeee9 | 218 | int i, j; |
7498cf4c | 219 | |
7bb426ea | 220 | if (!iwl_mvm_is_d0i3_supported(mvm)) |
7498cf4c EP |
221 | return; |
222 | ||
576eeee9 EP |
223 | spin_lock_bh(&mvm->refs_lock); |
224 | for (i = 0; i < IWL_MVM_REF_COUNT; i++) { | |
225 | if (except_ref == i || !mvm->refs[i]) | |
7498cf4c EP |
226 | continue; |
227 | ||
576eeee9 EP |
228 | IWL_DEBUG_RPM(mvm, "Cleanup: remove mvm ref type %d (%d)\n", |
229 | i, mvm->refs[i]); | |
230 | for (j = 0; j < mvm->refs[i]; j++) | |
231 | iwl_trans_unref(mvm->trans); | |
232 | mvm->refs[i] = 0; | |
7498cf4c | 233 | } |
576eeee9 | 234 | spin_unlock_bh(&mvm->refs_lock); |
7498cf4c EP |
235 | } |
236 | ||
f4cf8680 EP |
237 | bool iwl_mvm_ref_taken(struct iwl_mvm *mvm) |
238 | { | |
239 | int i; | |
240 | bool taken = false; | |
241 | ||
242 | if (!iwl_mvm_is_d0i3_supported(mvm)) | |
243 | return true; | |
244 | ||
245 | spin_lock_bh(&mvm->refs_lock); | |
246 | for (i = 0; i < IWL_MVM_REF_COUNT; i++) { | |
247 | if (mvm->refs[i]) { | |
248 | taken = true; | |
249 | break; | |
250 | } | |
251 | } | |
252 | spin_unlock_bh(&mvm->refs_lock); | |
253 | ||
254 | return taken; | |
255 | } | |
256 | ||
576eeee9 | 257 | int iwl_mvm_ref_sync(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type) |
d40fc489 GG |
258 | { |
259 | iwl_mvm_ref(mvm, ref_type); | |
260 | ||
261 | if (!wait_event_timeout(mvm->d0i3_exit_waitq, | |
262 | !test_bit(IWL_MVM_STATUS_IN_D0I3, &mvm->status), | |
263 | HZ)) { | |
264 | WARN_ON_ONCE(1); | |
265 | iwl_mvm_unref(mvm, ref_type); | |
266 | return -EIO; | |
267 | } | |
268 | ||
269 | return 0; | |
270 | } | |
271 | ||
fe0f2de3 IP |
272 | static void iwl_mvm_reset_phy_ctxts(struct iwl_mvm *mvm) |
273 | { | |
274 | int i; | |
275 | ||
276 | memset(mvm->phy_ctxts, 0, sizeof(mvm->phy_ctxts)); | |
277 | for (i = 0; i < NUM_PHY_CTX; i++) { | |
278 | mvm->phy_ctxts[i].id = i; | |
279 | mvm->phy_ctxts[i].ref = 0; | |
280 | } | |
281 | } | |
282 | ||
88931cc9 | 283 | struct ieee80211_regdomain *iwl_mvm_get_regdomain(struct wiphy *wiphy, |
8ba2d7a1 | 284 | const char *alpha2, |
47c8b154 JD |
285 | enum iwl_mcc_source src_id, |
286 | bool *changed) | |
88931cc9 AN |
287 | { |
288 | struct ieee80211_regdomain *regd = NULL; | |
289 | struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); | |
290 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
291 | struct iwl_mcc_update_resp *resp; | |
292 | ||
293 | IWL_DEBUG_LAR(mvm, "Getting regdomain data for %s from FW\n", alpha2); | |
294 | ||
8ba2d7a1 | 295 | lockdep_assert_held(&mvm->mutex); |
88931cc9 | 296 | |
8ba2d7a1 | 297 | resp = iwl_mvm_update_mcc(mvm, alpha2, src_id); |
88931cc9 AN |
298 | if (IS_ERR_OR_NULL(resp)) { |
299 | IWL_DEBUG_LAR(mvm, "Could not get update from FW %d\n", | |
b8c474d9 | 300 | PTR_ERR_OR_ZERO(resp)); |
8ba2d7a1 | 301 | goto out; |
88931cc9 AN |
302 | } |
303 | ||
82715ac7 EG |
304 | if (changed) { |
305 | u32 status = le32_to_cpu(resp->status); | |
306 | ||
307 | *changed = (status == MCC_RESP_NEW_CHAN_PROFILE || | |
308 | status == MCC_RESP_ILLEGAL); | |
309 | } | |
47c8b154 | 310 | |
162ee3c9 | 311 | regd = iwl_parse_nvm_mcc_info(mvm->trans->dev, mvm->cfg, |
88931cc9 AN |
312 | __le32_to_cpu(resp->n_channels), |
313 | resp->channels, | |
77e30e10 HD |
314 | __le16_to_cpu(resp->mcc), |
315 | __le16_to_cpu(resp->geo_info)); | |
8ba2d7a1 EH |
316 | /* Store the return source id */ |
317 | src_id = resp->source_id; | |
88931cc9 AN |
318 | kfree(resp); |
319 | if (IS_ERR_OR_NULL(regd)) { | |
320 | IWL_DEBUG_LAR(mvm, "Could not get parse update from FW %d\n", | |
b8c474d9 | 321 | PTR_ERR_OR_ZERO(regd)); |
8ba2d7a1 | 322 | goto out; |
88931cc9 AN |
323 | } |
324 | ||
8ba2d7a1 EH |
325 | IWL_DEBUG_LAR(mvm, "setting alpha2 from FW to %s (0x%x, 0x%x) src=%d\n", |
326 | regd->alpha2, regd->alpha2[0], regd->alpha2[1], src_id); | |
88931cc9 | 327 | mvm->lar_regdom_set = true; |
8ba2d7a1 | 328 | mvm->mcc_src = src_id; |
88931cc9 | 329 | |
8ba2d7a1 | 330 | out: |
88931cc9 AN |
331 | return regd; |
332 | } | |
333 | ||
47c8b154 JD |
334 | void iwl_mvm_update_changed_regdom(struct iwl_mvm *mvm) |
335 | { | |
336 | bool changed; | |
337 | struct ieee80211_regdomain *regd; | |
338 | ||
339 | if (!iwl_mvm_is_lar_supported(mvm)) | |
340 | return; | |
341 | ||
342 | regd = iwl_mvm_get_current_regdomain(mvm, &changed); | |
343 | if (!IS_ERR_OR_NULL(regd)) { | |
344 | /* only update the regulatory core if changed */ | |
345 | if (changed) | |
346 | regulatory_set_wiphy_regd(mvm->hw->wiphy, regd); | |
347 | ||
348 | kfree(regd); | |
349 | } | |
350 | } | |
351 | ||
352 | struct ieee80211_regdomain *iwl_mvm_get_current_regdomain(struct iwl_mvm *mvm, | |
353 | bool *changed) | |
8ba2d7a1 EH |
354 | { |
355 | return iwl_mvm_get_regdomain(mvm->hw->wiphy, "ZZ", | |
356 | iwl_mvm_is_wifi_mcc_supported(mvm) ? | |
357 | MCC_SOURCE_GET_CURRENT : | |
47c8b154 | 358 | MCC_SOURCE_OLD_FW, changed); |
8ba2d7a1 EH |
359 | } |
360 | ||
361 | int iwl_mvm_init_fw_regd(struct iwl_mvm *mvm) | |
362 | { | |
363 | enum iwl_mcc_source used_src; | |
364 | struct ieee80211_regdomain *regd; | |
b6e160ab AN |
365 | int ret; |
366 | bool changed; | |
8ba2d7a1 EH |
367 | const struct ieee80211_regdomain *r = |
368 | rtnl_dereference(mvm->hw->wiphy->regd); | |
369 | ||
370 | if (!r) | |
b6e160ab | 371 | return -ENOENT; |
8ba2d7a1 EH |
372 | |
373 | /* save the last source in case we overwrite it below */ | |
374 | used_src = mvm->mcc_src; | |
375 | if (iwl_mvm_is_wifi_mcc_supported(mvm)) { | |
376 | /* Notify the firmware we support wifi location updates */ | |
47c8b154 | 377 | regd = iwl_mvm_get_current_regdomain(mvm, NULL); |
8ba2d7a1 EH |
378 | if (!IS_ERR_OR_NULL(regd)) |
379 | kfree(regd); | |
380 | } | |
381 | ||
382 | /* Now set our last stored MCC and source */ | |
b6e160ab AN |
383 | regd = iwl_mvm_get_regdomain(mvm->hw->wiphy, r->alpha2, used_src, |
384 | &changed); | |
8ba2d7a1 EH |
385 | if (IS_ERR_OR_NULL(regd)) |
386 | return -EIO; | |
387 | ||
b6e160ab AN |
388 | /* update cfg80211 if the regdomain was changed */ |
389 | if (changed) | |
390 | ret = regulatory_set_wiphy_regd_sync_rtnl(mvm->hw->wiphy, regd); | |
391 | else | |
392 | ret = 0; | |
8ba2d7a1 | 393 | |
b6e160ab AN |
394 | kfree(regd); |
395 | return ret; | |
8ba2d7a1 EH |
396 | } |
397 | ||
8ca151b5 JB |
398 | int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm) |
399 | { | |
400 | struct ieee80211_hw *hw = mvm->hw; | |
831e85f3 | 401 | int num_mac, ret, i; |
5f4c02e2 JB |
402 | static const u32 mvm_ciphers[] = { |
403 | WLAN_CIPHER_SUITE_WEP40, | |
404 | WLAN_CIPHER_SUITE_WEP104, | |
405 | WLAN_CIPHER_SUITE_TKIP, | |
406 | WLAN_CIPHER_SUITE_CCMP, | |
407 | }; | |
8ca151b5 JB |
408 | |
409 | /* Tell mac80211 our characteristics */ | |
30686bf7 JB |
410 | ieee80211_hw_set(hw, SIGNAL_DBM); |
411 | ieee80211_hw_set(hw, SPECTRUM_MGMT); | |
412 | ieee80211_hw_set(hw, REPORTS_TX_ACK_STATUS); | |
413 | ieee80211_hw_set(hw, QUEUE_CONTROL); | |
414 | ieee80211_hw_set(hw, WANT_MONITOR_VIF); | |
415 | ieee80211_hw_set(hw, SUPPORTS_PS); | |
416 | ieee80211_hw_set(hw, SUPPORTS_DYNAMIC_PS); | |
417 | ieee80211_hw_set(hw, AMPDU_AGGREGATION); | |
418 | ieee80211_hw_set(hw, TIMING_BEACON_ONLY); | |
419 | ieee80211_hw_set(hw, CONNECTION_MONITOR); | |
420 | ieee80211_hw_set(hw, CHANCTX_STA_CSA); | |
421 | ieee80211_hw_set(hw, SUPPORT_FAST_XMIT); | |
422 | ieee80211_hw_set(hw, SUPPORTS_CLONED_SKBS); | |
909ddf0b | 423 | ieee80211_hw_set(hw, SUPPORTS_AMSDU_IN_AMPDU); |
30433d3b | 424 | ieee80211_hw_set(hw, NEEDS_UNIQUE_STA_ADDR); |
d270e7b8 | 425 | ieee80211_hw_set(hw, DEAUTH_NEED_MGD_TX_PREP); |
ecaf71de | 426 | |
4243edb4 | 427 | if (iwl_mvm_has_tlc_offload(mvm)) { |
ecaf71de GG |
428 | ieee80211_hw_set(hw, TX_AMPDU_SETUP_IN_HW); |
429 | ieee80211_hw_set(hw, HAS_RATE_CONTROL); | |
430 | } | |
431 | ||
b915c101 SS |
432 | if (iwl_mvm_has_new_rx_api(mvm)) |
433 | ieee80211_hw_set(hw, SUPPORTS_REORDERING_BUFFER); | |
960f864b JB |
434 | |
435 | if (fw_has_capa(&mvm->fw->ucode_capa, | |
436 | IWL_UCODE_TLV_CAPA_STA_PM_NOTIF)) { | |
65e25482 | 437 | ieee80211_hw_set(hw, AP_LINK_PS); |
960f864b JB |
438 | } else if (WARN_ON(iwl_mvm_has_new_tx_api(mvm))) { |
439 | /* | |
440 | * we absolutely need this for the new TX API since that comes | |
441 | * with many more queues than the current code can deal with | |
442 | * for station powersave | |
443 | */ | |
444 | return -EINVAL; | |
445 | } | |
8ca151b5 | 446 | |
80938abc JB |
447 | if (mvm->trans->num_rx_queues > 1) |
448 | ieee80211_hw_set(hw, USES_RSS); | |
449 | ||
2d7cf549 JB |
450 | if (mvm->trans->max_skb_frags) |
451 | hw->netdev_features = NETIF_F_HIGHDMA | NETIF_F_SG; | |
452 | ||
c8f54701 | 453 | hw->queues = IEEE80211_MAX_QUEUES; |
398e8c6c | 454 | hw->offchannel_tx_hw_queue = IWL_MVM_OFFCHANNEL_QUEUE; |
7b1dd048 EG |
455 | hw->radiotap_mcs_details |= IEEE80211_RADIOTAP_MCS_HAVE_FEC | |
456 | IEEE80211_RADIOTAP_MCS_HAVE_STBC; | |
339b3086 ES |
457 | hw->radiotap_vht_details |= IEEE80211_RADIOTAP_VHT_KNOWN_STBC | |
458 | IEEE80211_RADIOTAP_VHT_KNOWN_BEAMFORMED; | |
371a17ed JB |
459 | |
460 | hw->radiotap_timestamp.units_pos = | |
461 | IEEE80211_RADIOTAP_TIMESTAMP_UNIT_US | | |
462 | IEEE80211_RADIOTAP_TIMESTAMP_SPOS_PLCP_SIG_ACQ; | |
463 | /* this is the case for CCK frames, it's better (only 8) for OFDM */ | |
464 | hw->radiotap_timestamp.accuracy = 22; | |
465 | ||
4243edb4 | 466 | if (!iwl_mvm_has_tlc_offload(mvm)) |
9f66a397 GG |
467 | hw->rate_control_algorithm = RS_NAME; |
468 | ||
848955cc JB |
469 | hw->uapsd_queues = IWL_MVM_UAPSD_QUEUES; |
470 | hw->uapsd_max_sp_len = IWL_UAPSD_MAX_SP; | |
8ca151b5 | 471 | |
8e160ab8 | 472 | BUILD_BUG_ON(ARRAY_SIZE(mvm->ciphers) < ARRAY_SIZE(mvm_ciphers) + 6); |
5f4c02e2 JB |
473 | memcpy(mvm->ciphers, mvm_ciphers, sizeof(mvm_ciphers)); |
474 | hw->wiphy->n_cipher_suites = ARRAY_SIZE(mvm_ciphers); | |
475 | hw->wiphy->cipher_suites = mvm->ciphers; | |
476 | ||
2a53d166 AB |
477 | if (iwl_mvm_has_new_rx_api(mvm)) { |
478 | mvm->ciphers[hw->wiphy->n_cipher_suites] = | |
479 | WLAN_CIPHER_SUITE_GCMP; | |
480 | hw->wiphy->n_cipher_suites++; | |
481 | mvm->ciphers[hw->wiphy->n_cipher_suites] = | |
482 | WLAN_CIPHER_SUITE_GCMP_256; | |
483 | hw->wiphy->n_cipher_suites++; | |
484 | } | |
485 | ||
4b87e5af LC |
486 | /* Enable 11w if software crypto is not enabled (as the |
487 | * firmware will interpret some mgmt packets, so enabling it | |
488 | * with software crypto isn't safe). | |
8ca151b5 | 489 | */ |
3b37f4c9 | 490 | if (!iwlwifi_mod_params.swcrypto) { |
30686bf7 | 491 | ieee80211_hw_set(hw, MFP_CAPABLE); |
5f4c02e2 JB |
492 | mvm->ciphers[hw->wiphy->n_cipher_suites] = |
493 | WLAN_CIPHER_SUITE_AES_CMAC; | |
494 | hw->wiphy->n_cipher_suites++; | |
8e160ab8 AB |
495 | if (iwl_mvm_has_new_rx_api(mvm)) { |
496 | mvm->ciphers[hw->wiphy->n_cipher_suites] = | |
497 | WLAN_CIPHER_SUITE_BIP_GMAC_128; | |
498 | hw->wiphy->n_cipher_suites++; | |
499 | mvm->ciphers[hw->wiphy->n_cipher_suites] = | |
500 | WLAN_CIPHER_SUITE_BIP_GMAC_256; | |
501 | hw->wiphy->n_cipher_suites++; | |
502 | } | |
5f4c02e2 JB |
503 | } |
504 | ||
505 | /* currently FW API supports only one optional cipher scheme */ | |
506 | if (mvm->fw->cs[0].cipher) { | |
24ddddf3 JB |
507 | const struct iwl_fw_cipher_scheme *fwcs = &mvm->fw->cs[0]; |
508 | struct ieee80211_cipher_scheme *cs = &mvm->cs[0]; | |
509 | ||
5f4c02e2 | 510 | mvm->hw->n_cipher_schemes = 1; |
24ddddf3 JB |
511 | |
512 | cs->cipher = le32_to_cpu(fwcs->cipher); | |
513 | cs->iftype = BIT(NL80211_IFTYPE_STATION); | |
514 | cs->hdr_len = fwcs->hdr_len; | |
515 | cs->pn_len = fwcs->pn_len; | |
516 | cs->pn_off = fwcs->pn_off; | |
517 | cs->key_idx_off = fwcs->key_idx_off; | |
518 | cs->key_idx_mask = fwcs->key_idx_mask; | |
519 | cs->key_idx_shift = fwcs->key_idx_shift; | |
520 | cs->mic_len = fwcs->mic_len; | |
521 | ||
522 | mvm->hw->cipher_schemes = mvm->cs; | |
523 | mvm->ciphers[hw->wiphy->n_cipher_suites] = cs->cipher; | |
5f4c02e2 JB |
524 | hw->wiphy->n_cipher_suites++; |
525 | } | |
8ca151b5 | 526 | |
30686bf7 | 527 | ieee80211_hw_set(hw, SINGLE_SCAN_ON_ALL_BANDS); |
1f940386 LC |
528 | hw->wiphy->features |= |
529 | NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR | | |
3db93420 JB |
530 | NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR | |
531 | NL80211_FEATURE_ND_RANDOM_MAC_ADDR; | |
fb98be5e | 532 | |
8ca151b5 JB |
533 | hw->sta_data_size = sizeof(struct iwl_mvm_sta); |
534 | hw->vif_data_size = sizeof(struct iwl_mvm_vif); | |
fe0f2de3 | 535 | hw->chanctx_data_size = sizeof(u16); |
8ca151b5 JB |
536 | |
537 | hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | | |
3c15a0fb JB |
538 | BIT(NL80211_IFTYPE_P2P_CLIENT) | |
539 | BIT(NL80211_IFTYPE_AP) | | |
540 | BIT(NL80211_IFTYPE_P2P_GO) | | |
c13b1725 EG |
541 | BIT(NL80211_IFTYPE_P2P_DEVICE) | |
542 | BIT(NL80211_IFTYPE_ADHOC); | |
5023d966 | 543 | |
a2f73b6c | 544 | hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; |
8ba2d7a1 EH |
545 | hw->wiphy->regulatory_flags |= REGULATORY_ENABLE_RELAX_NO_IR; |
546 | if (iwl_mvm_is_lar_supported(mvm)) | |
547 | hw->wiphy->regulatory_flags |= REGULATORY_WIPHY_SELF_MANAGED; | |
548 | else | |
549 | hw->wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG | | |
550 | REGULATORY_DISABLE_BEACON_HINTS; | |
8ca151b5 | 551 | |
4b87e5af | 552 | hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD; |
94bbed72 | 553 | hw->wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH; |
bd3398e2 | 554 | |
8ca151b5 JB |
555 | hw->wiphy->iface_combinations = iwl_mvm_iface_combinations; |
556 | hw->wiphy->n_iface_combinations = | |
557 | ARRAY_SIZE(iwl_mvm_iface_combinations); | |
558 | ||
c451e6d4 | 559 | hw->wiphy->max_remain_on_channel_duration = 10000; |
8ca151b5 JB |
560 | hw->max_listen_interval = IWL_CONN_MAX_LISTEN_INTERVAL; |
561 | ||
562 | /* Extract MAC address */ | |
563 | memcpy(mvm->addresses[0].addr, mvm->nvm_data->hw_addr, ETH_ALEN); | |
564 | hw->wiphy->addresses = mvm->addresses; | |
565 | hw->wiphy->n_addresses = 1; | |
831e85f3 IP |
566 | |
567 | /* Extract additional MAC addresses if available */ | |
568 | num_mac = (mvm->nvm_data->n_hw_addrs > 1) ? | |
569 | min(IWL_MVM_MAX_ADDRESSES, mvm->nvm_data->n_hw_addrs) : 1; | |
570 | ||
571 | for (i = 1; i < num_mac; i++) { | |
572 | memcpy(mvm->addresses[i].addr, mvm->addresses[i-1].addr, | |
8ca151b5 | 573 | ETH_ALEN); |
831e85f3 | 574 | mvm->addresses[i].addr[5]++; |
8ca151b5 JB |
575 | hw->wiphy->n_addresses++; |
576 | } | |
577 | ||
fe0f2de3 IP |
578 | iwl_mvm_reset_phy_ctxts(mvm); |
579 | ||
999d2568 | 580 | hw->wiphy->max_scan_ie_len = iwl_mvm_max_scan_ie_len(mvm); |
20f1a5de | 581 | |
8ca151b5 JB |
582 | hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX; |
583 | ||
c7d42480 | 584 | BUILD_BUG_ON(IWL_MVM_SCAN_STOPPING_MASK & IWL_MVM_SCAN_MASK); |
507e4cda LC |
585 | BUILD_BUG_ON(IWL_MVM_MAX_UMAC_SCANS > HWEIGHT32(IWL_MVM_SCAN_MASK) || |
586 | IWL_MVM_MAX_LMAC_SCANS > HWEIGHT32(IWL_MVM_SCAN_MASK)); | |
587 | ||
859d914c | 588 | if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN)) |
507e4cda LC |
589 | mvm->max_scans = IWL_MVM_MAX_UMAC_SCANS; |
590 | else | |
591 | mvm->max_scans = IWL_MVM_MAX_LMAC_SCANS; | |
592 | ||
57fbcce3 JB |
593 | if (mvm->nvm_data->bands[NL80211_BAND_2GHZ].n_channels) |
594 | hw->wiphy->bands[NL80211_BAND_2GHZ] = | |
595 | &mvm->nvm_data->bands[NL80211_BAND_2GHZ]; | |
596 | if (mvm->nvm_data->bands[NL80211_BAND_5GHZ].n_channels) { | |
597 | hw->wiphy->bands[NL80211_BAND_5GHZ] = | |
598 | &mvm->nvm_data->bands[NL80211_BAND_5GHZ]; | |
8ca151b5 | 599 | |
859d914c JB |
600 | if (fw_has_capa(&mvm->fw->ucode_capa, |
601 | IWL_UCODE_TLV_CAPA_BEAMFORMER) && | |
602 | fw_has_api(&mvm->fw->ucode_capa, | |
603 | IWL_UCODE_TLV_API_LQ_SS_PARAMS)) | |
57fbcce3 | 604 | hw->wiphy->bands[NL80211_BAND_5GHZ]->vht_cap.cap |= |
3d44eebf ES |
605 | IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE; |
606 | } | |
607 | ||
8ca151b5 JB |
608 | hw->wiphy->hw_version = mvm->trans->hw_id; |
609 | ||
ade50652 | 610 | if (iwlmvm_mod_params.power_scheme != IWL_POWER_SCHEME_CAM) |
8ca151b5 JB |
611 | hw->wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT; |
612 | else | |
613 | hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; | |
614 | ||
ca986ad9 | 615 | hw->wiphy->max_sched_scan_reqs = 1; |
9954b37c EG |
616 | hw->wiphy->max_sched_scan_ssids = PROBE_OPTION_MAX; |
617 | hw->wiphy->max_match_sets = IWL_SCAN_MAX_PROFILES; | |
618 | /* we create the 802.11 header and zero length SSID IE. */ | |
619 | hw->wiphy->max_sched_scan_ie_len = | |
620 | SCAN_OFFLOAD_PROBE_REQ_SIZE - 24 - 2; | |
cd55ccea AS |
621 | hw->wiphy->max_sched_scan_plans = IWL_MAX_SCHED_SCAN_PLANS; |
622 | hw->wiphy->max_sched_scan_plan_interval = U16_MAX; | |
623 | ||
624 | /* | |
625 | * the firmware uses u8 for num of iterations, but 0xff is saved for | |
626 | * infinite loop, so the maximum number of iterations is actually 254. | |
627 | */ | |
628 | hw->wiphy->max_sched_scan_plan_iterations = 254; | |
35a000b7 | 629 | |
8ca151b5 | 630 | hw->wiphy->features |= NL80211_FEATURE_P2P_GO_CTWIN | |
ab480030 | 631 | NL80211_FEATURE_LOW_PRIORITY_SCAN | |
0d8614b4 | 632 | NL80211_FEATURE_P2P_GO_OPPPS | |
a904a08b | 633 | NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE | |
0d8614b4 | 634 | NL80211_FEATURE_DYNAMIC_SMPS | |
9b5452fd EG |
635 | NL80211_FEATURE_STATIC_SMPS | |
636 | NL80211_FEATURE_SUPPORTS_WMM_ADMISSION; | |
8ca151b5 | 637 | |
859d914c JB |
638 | if (fw_has_capa(&mvm->fw->ucode_capa, |
639 | IWL_UCODE_TLV_CAPA_TXPOWER_INSERTION_SUPPORT)) | |
f1daa00e | 640 | hw->wiphy->features |= NL80211_FEATURE_TX_POWER_INSERTION; |
859d914c JB |
641 | if (fw_has_capa(&mvm->fw->ucode_capa, |
642 | IWL_UCODE_TLV_CAPA_QUIET_PERIOD_SUPPORT)) | |
226bcd48 | 643 | hw->wiphy->features |= NL80211_FEATURE_QUIET; |
f1daa00e | 644 | |
859d914c JB |
645 | if (fw_has_capa(&mvm->fw->ucode_capa, |
646 | IWL_UCODE_TLV_CAPA_DS_PARAM_SET_IE_SUPPORT)) | |
73897bd1 AO |
647 | hw->wiphy->features |= |
648 | NL80211_FEATURE_DS_PARAM_SET_IE_IN_PROBES; | |
649 | ||
859d914c JB |
650 | if (fw_has_capa(&mvm->fw->ucode_capa, |
651 | IWL_UCODE_TLV_CAPA_WFA_TPC_REP_IE_SUPPORT)) | |
73897bd1 AO |
652 | hw->wiphy->features |= NL80211_FEATURE_WFA_TPC_IE_IN_PROBES; |
653 | ||
aacf8f18 AS |
654 | if (fw_has_api(&mvm->fw->ucode_capa, |
655 | IWL_UCODE_TLV_API_SCAN_TSF_REPORT)) { | |
656 | wiphy_ext_feature_set(hw->wiphy, | |
657 | NL80211_EXT_FEATURE_SCAN_START_TIME); | |
658 | wiphy_ext_feature_set(hw->wiphy, | |
659 | NL80211_EXT_FEATURE_BSS_PARENT_TSF); | |
660 | wiphy_ext_feature_set(hw->wiphy, | |
661 | NL80211_EXT_FEATURE_SET_SCAN_DWELL); | |
662 | } | |
663 | ||
8f691af9 ZR |
664 | if (iwl_mvm_is_oce_supported(mvm)) { |
665 | wiphy_ext_feature_set(hw->wiphy, | |
666 | NL80211_EXT_FEATURE_ACCEPT_BCAST_PROBE_RESP); | |
667 | wiphy_ext_feature_set(hw->wiphy, | |
668 | NL80211_EXT_FEATURE_FILS_MAX_CHANNEL_TIME); | |
669 | wiphy_ext_feature_set(hw->wiphy, | |
670 | NL80211_EXT_FEATURE_OCE_PROBE_REQ_DEFERRAL_SUPPRESSION); | |
671 | wiphy_ext_feature_set(hw->wiphy, | |
672 | NL80211_EXT_FEATURE_OCE_PROBE_REQ_HIGH_TX_RATE); | |
673 | } | |
674 | ||
8ca151b5 JB |
675 | mvm->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD; |
676 | ||
677 | #ifdef CONFIG_PM_SLEEP | |
d15a747f EP |
678 | if (iwl_mvm_is_d0i3_supported(mvm) && |
679 | device_can_wakeup(mvm->trans->dev)) { | |
680 | mvm->wowlan.flags = WIPHY_WOWLAN_ANY; | |
681 | hw->wiphy->wowlan = &mvm->wowlan; | |
91742449 EP |
682 | } |
683 | ||
eef187a7 | 684 | if (mvm->fw->img[IWL_UCODE_WOWLAN].num_sec && |
8ca151b5 JB |
685 | mvm->trans->ops->d3_suspend && |
686 | mvm->trans->ops->d3_resume && | |
687 | device_can_wakeup(mvm->trans->dev)) { | |
91742449 EP |
688 | mvm->wowlan.flags |= WIPHY_WOWLAN_MAGIC_PKT | |
689 | WIPHY_WOWLAN_DISCONNECT | | |
690 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | | |
691 | WIPHY_WOWLAN_RFKILL_RELEASE | | |
692 | WIPHY_WOWLAN_NET_DETECT; | |
3b37f4c9 | 693 | if (!iwlwifi_mod_params.swcrypto) |
964dc9e2 JB |
694 | mvm->wowlan.flags |= WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
695 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | | |
696 | WIPHY_WOWLAN_4WAY_HANDSHAKE; | |
697 | ||
698 | mvm->wowlan.n_patterns = IWL_WOWLAN_MAX_PATTERNS; | |
699 | mvm->wowlan.pattern_min_len = IWL_WOWLAN_MIN_PATTERN_LEN; | |
700 | mvm->wowlan.pattern_max_len = IWL_WOWLAN_MAX_PATTERN_LEN; | |
c55385f5 | 701 | mvm->wowlan.max_nd_match_sets = IWL_SCAN_MAX_PROFILES; |
964dc9e2 | 702 | hw->wiphy->wowlan = &mvm->wowlan; |
8ca151b5 JB |
703 | } |
704 | #endif | |
705 | ||
77736923 EP |
706 | #ifdef CONFIG_IWLWIFI_BCAST_FILTERING |
707 | /* assign default bcast filtering configuration */ | |
708 | mvm->bcast_filters = iwl_mvm_default_bcast_filters; | |
709 | #endif | |
710 | ||
8ca151b5 JB |
711 | ret = iwl_mvm_leds_init(mvm); |
712 | if (ret) | |
713 | return ret; | |
714 | ||
859d914c JB |
715 | if (fw_has_capa(&mvm->fw->ucode_capa, |
716 | IWL_UCODE_TLV_CAPA_TDLS_SUPPORT)) { | |
d8f1c515 AN |
717 | IWL_DEBUG_TDLS(mvm, "TDLS supported\n"); |
718 | hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS; | |
7c4f0843 | 719 | ieee80211_hw_set(hw, TDLS_WIDER_BW); |
d8f1c515 AN |
720 | } |
721 | ||
859d914c JB |
722 | if (fw_has_capa(&mvm->fw->ucode_capa, |
723 | IWL_UCODE_TLV_CAPA_TDLS_CHANNEL_SWITCH)) { | |
1d3c3f63 AN |
724 | IWL_DEBUG_TDLS(mvm, "TDLS channel switch supported\n"); |
725 | hw->wiphy->features |= NL80211_FEATURE_TDLS_CHANNEL_SWITCH; | |
726 | } | |
727 | ||
93190fb0 | 728 | hw->netdev_features |= mvm->cfg->features; |
5e6a98dc SS |
729 | if (!iwl_mvm_is_csum_supported(mvm)) { |
730 | hw->netdev_features &= ~(IWL_TX_CSUM_NETIF_FLAGS | | |
731 | NETIF_F_RXCSUM); | |
732 | /* We may support SW TX CSUM */ | |
733 | if (IWL_MVM_SW_TX_CSUM_OFFLOAD) | |
734 | hw->netdev_features |= IWL_TX_CSUM_NETIF_FLAGS; | |
735 | } | |
41837ca9 | 736 | |
b7327d89 EG |
737 | ret = ieee80211_register_hw(mvm->hw); |
738 | if (ret) | |
739 | iwl_mvm_leds_exit(mvm); | |
de8ba41b | 740 | mvm->init_status |= IWL_MVM_INIT_STATUS_REG_HW_INIT_COMPLETE; |
b7327d89 | 741 | |
91b08c2d AE |
742 | if (mvm->cfg->vht_mu_mimo_supported) |
743 | wiphy_ext_feature_set(hw->wiphy, | |
744 | NL80211_EXT_FEATURE_MU_MIMO_AIR_SNIFFER); | |
745 | ||
b7327d89 | 746 | return ret; |
8ca151b5 JB |
747 | } |
748 | ||
b2492501 AN |
749 | static bool iwl_mvm_defer_tx(struct iwl_mvm *mvm, |
750 | struct ieee80211_sta *sta, | |
751 | struct sk_buff *skb) | |
752 | { | |
753 | struct iwl_mvm_sta *mvmsta; | |
754 | bool defer = false; | |
755 | ||
756 | /* | |
757 | * double check the IN_D0I3 flag both before and after | |
758 | * taking the spinlock, in order to prevent taking | |
759 | * the spinlock when not needed. | |
760 | */ | |
761 | if (likely(!test_bit(IWL_MVM_STATUS_IN_D0I3, &mvm->status))) | |
762 | return false; | |
763 | ||
764 | spin_lock(&mvm->d0i3_tx_lock); | |
765 | /* | |
766 | * testing the flag again ensures the skb dequeue | |
767 | * loop (on d0i3 exit) hasn't run yet. | |
768 | */ | |
769 | if (!test_bit(IWL_MVM_STATUS_IN_D0I3, &mvm->status)) | |
770 | goto out; | |
771 | ||
772 | mvmsta = iwl_mvm_sta_from_mac80211(sta); | |
0ae98812 | 773 | if (mvmsta->sta_id == IWL_MVM_INVALID_STA || |
b2492501 AN |
774 | mvmsta->sta_id != mvm->d0i3_ap_sta_id) |
775 | goto out; | |
776 | ||
777 | __skb_queue_tail(&mvm->d0i3_tx, skb); | |
778 | ieee80211_stop_queues(mvm->hw); | |
779 | ||
780 | /* trigger wakeup */ | |
781 | iwl_mvm_ref(mvm, IWL_MVM_REF_TX); | |
782 | iwl_mvm_unref(mvm, IWL_MVM_REF_TX); | |
783 | ||
784 | defer = true; | |
785 | out: | |
786 | spin_unlock(&mvm->d0i3_tx_lock); | |
787 | return defer; | |
788 | } | |
789 | ||
8ca151b5 JB |
790 | static void iwl_mvm_mac_tx(struct ieee80211_hw *hw, |
791 | struct ieee80211_tx_control *control, | |
792 | struct sk_buff *skb) | |
793 | { | |
794 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
3e56eadf JB |
795 | struct ieee80211_sta *sta = control->sta; |
796 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | |
797 | struct ieee80211_hdr *hdr = (void *)skb->data; | |
8ca151b5 | 798 | |
9ee718aa EL |
799 | if (iwl_mvm_is_radio_killed(mvm)) { |
800 | IWL_DEBUG_DROP(mvm, "Dropping - RF/CT KILL\n"); | |
8ca151b5 JB |
801 | goto drop; |
802 | } | |
803 | ||
d20e30af | 804 | if (info->hw_queue == IWL_MVM_OFFCHANNEL_QUEUE && |
a6cc5163 MG |
805 | !test_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status) && |
806 | !test_bit(IWL_MVM_STATUS_ROC_AUX_RUNNING, &mvm->status)) | |
8ca151b5 JB |
807 | goto drop; |
808 | ||
eb045e6e DS |
809 | /* treat non-bufferable MMPDUs on AP interfaces as broadcast */ |
810 | if ((info->control.vif->type == NL80211_IFTYPE_AP || | |
811 | info->control.vif->type == NL80211_IFTYPE_ADHOC) && | |
812 | ieee80211_is_mgmt(hdr->frame_control) && | |
813 | !ieee80211_is_bufferable_mmpdu(hdr->frame_control)) | |
3e56eadf JB |
814 | sta = NULL; |
815 | ||
816 | if (sta) { | |
b2492501 AN |
817 | if (iwl_mvm_defer_tx(mvm, sta, skb)) |
818 | return; | |
3e56eadf | 819 | if (iwl_mvm_tx_skb(mvm, skb, sta)) |
8ca151b5 JB |
820 | goto drop; |
821 | return; | |
822 | } | |
823 | ||
824 | if (iwl_mvm_tx_skb_non_sta(mvm, skb)) | |
825 | goto drop; | |
826 | return; | |
827 | drop: | |
828 | ieee80211_free_txskb(hw, skb); | |
829 | } | |
830 | ||
205e2210 EG |
831 | static inline bool iwl_enable_rx_ampdu(const struct iwl_cfg *cfg) |
832 | { | |
833 | if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_RXAGG) | |
834 | return false; | |
835 | return true; | |
836 | } | |
837 | ||
838 | static inline bool iwl_enable_tx_ampdu(const struct iwl_cfg *cfg) | |
839 | { | |
840 | if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_TXAGG) | |
841 | return false; | |
842 | if (iwlwifi_mod_params.disable_11n & IWL_ENABLE_HT_TXAGG) | |
843 | return true; | |
844 | ||
845 | /* enabled by default */ | |
846 | return true; | |
847 | } | |
848 | ||
7174beb6 JB |
849 | #define CHECK_BA_TRIGGER(_mvm, _trig, _tid_bm, _tid, _fmt...) \ |
850 | do { \ | |
851 | if (!(le16_to_cpu(_tid_bm) & BIT(_tid))) \ | |
852 | break; \ | |
853 | iwl_fw_dbg_collect_trig(&(_mvm)->fwrt, _trig, _fmt); \ | |
4203263d EG |
854 | } while (0) |
855 | ||
856 | static void | |
857 | iwl_mvm_ampdu_check_trigger(struct iwl_mvm *mvm, struct ieee80211_vif *vif, | |
858 | struct ieee80211_sta *sta, u16 tid, u16 rx_ba_ssn, | |
859 | enum ieee80211_ampdu_mlme_action action) | |
860 | { | |
861 | struct iwl_fw_dbg_trigger_tlv *trig; | |
862 | struct iwl_fw_dbg_trigger_ba *ba_trig; | |
863 | ||
6c042d75 SS |
864 | trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif), |
865 | FW_DBG_TRIGGER_BA); | |
866 | if (!trig) | |
4203263d EG |
867 | return; |
868 | ||
4203263d EG |
869 | ba_trig = (void *)trig->data; |
870 | ||
4203263d EG |
871 | switch (action) { |
872 | case IEEE80211_AMPDU_TX_OPERATIONAL: { | |
873 | struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); | |
874 | struct iwl_mvm_tid_data *tid_data = &mvmsta->tid_data[tid]; | |
875 | ||
876 | CHECK_BA_TRIGGER(mvm, trig, ba_trig->tx_ba_start, tid, | |
877 | "TX AGG START: MAC %pM tid %d ssn %d\n", | |
878 | sta->addr, tid, tid_data->ssn); | |
879 | break; | |
880 | } | |
881 | case IEEE80211_AMPDU_TX_STOP_CONT: | |
882 | CHECK_BA_TRIGGER(mvm, trig, ba_trig->tx_ba_stop, tid, | |
883 | "TX AGG STOP: MAC %pM tid %d\n", | |
884 | sta->addr, tid); | |
885 | break; | |
886 | case IEEE80211_AMPDU_RX_START: | |
887 | CHECK_BA_TRIGGER(mvm, trig, ba_trig->rx_ba_start, tid, | |
888 | "RX AGG START: MAC %pM tid %d ssn %d\n", | |
889 | sta->addr, tid, rx_ba_ssn); | |
890 | break; | |
891 | case IEEE80211_AMPDU_RX_STOP: | |
892 | CHECK_BA_TRIGGER(mvm, trig, ba_trig->rx_ba_stop, tid, | |
893 | "RX AGG STOP: MAC %pM tid %d\n", | |
894 | sta->addr, tid); | |
895 | break; | |
896 | default: | |
897 | break; | |
898 | } | |
899 | } | |
900 | ||
8ca151b5 JB |
901 | static int iwl_mvm_mac_ampdu_action(struct ieee80211_hw *hw, |
902 | struct ieee80211_vif *vif, | |
50ea05ef | 903 | struct ieee80211_ampdu_params *params) |
8ca151b5 JB |
904 | { |
905 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
906 | int ret; | |
b2492501 | 907 | bool tx_agg_ref = false; |
50ea05ef SS |
908 | struct ieee80211_sta *sta = params->sta; |
909 | enum ieee80211_ampdu_mlme_action action = params->action; | |
910 | u16 tid = params->tid; | |
911 | u16 *ssn = ¶ms->ssn; | |
514c3069 | 912 | u16 buf_size = params->buf_size; |
bb81bb68 | 913 | bool amsdu = params->amsdu; |
10b2b201 | 914 | u16 timeout = params->timeout; |
8ca151b5 JB |
915 | |
916 | IWL_DEBUG_HT(mvm, "A-MPDU action on addr %pM tid %d: action %d\n", | |
917 | sta->addr, tid, action); | |
918 | ||
919 | if (!(mvm->nvm_data->sku_cap_11n_enable)) | |
920 | return -EACCES; | |
921 | ||
b2492501 | 922 | /* return from D0i3 before starting a new Tx aggregation */ |
9256c205 EP |
923 | switch (action) { |
924 | case IEEE80211_AMPDU_TX_START: | |
925 | case IEEE80211_AMPDU_TX_STOP_CONT: | |
926 | case IEEE80211_AMPDU_TX_STOP_FLUSH: | |
927 | case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT: | |
928 | case IEEE80211_AMPDU_TX_OPERATIONAL: | |
b2492501 | 929 | /* |
9256c205 EP |
930 | * for tx start, wait synchronously until D0i3 exit to |
931 | * get the correct sequence number for the tid. | |
932 | * additionally, some other ampdu actions use direct | |
933 | * target access, which is not handled automatically | |
934 | * by the trans layer (unlike commands), so wait for | |
935 | * d0i3 exit in these cases as well. | |
b2492501 | 936 | */ |
d40fc489 GG |
937 | ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_TX_AGG); |
938 | if (ret) | |
939 | return ret; | |
940 | ||
941 | tx_agg_ref = true; | |
9256c205 EP |
942 | break; |
943 | default: | |
944 | break; | |
b2492501 AN |
945 | } |
946 | ||
8ca151b5 JB |
947 | mutex_lock(&mvm->mutex); |
948 | ||
949 | switch (action) { | |
950 | case IEEE80211_AMPDU_RX_START: | |
b0ffe455 JB |
951 | if (iwl_mvm_vif_from_mac80211(vif)->ap_sta_id == |
952 | iwl_mvm_sta_from_mac80211(sta)->sta_id) { | |
953 | struct iwl_mvm_vif *mvmvif; | |
954 | u16 macid = iwl_mvm_vif_from_mac80211(vif)->id; | |
955 | struct iwl_mvm_tcm_mac *mdata = &mvm->tcm.data[macid]; | |
956 | ||
957 | mdata->opened_rx_ba_sessions = true; | |
958 | mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
959 | cancel_delayed_work(&mvmvif->uapsd_nonagg_detected_wk); | |
960 | } | |
205e2210 | 961 | if (!iwl_enable_rx_ampdu(mvm->cfg)) { |
8ca151b5 JB |
962 | ret = -EINVAL; |
963 | break; | |
964 | } | |
10b2b201 SS |
965 | ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, *ssn, true, buf_size, |
966 | timeout); | |
8ca151b5 JB |
967 | break; |
968 | case IEEE80211_AMPDU_RX_STOP: | |
10b2b201 SS |
969 | ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, 0, false, buf_size, |
970 | timeout); | |
8ca151b5 JB |
971 | break; |
972 | case IEEE80211_AMPDU_TX_START: | |
205e2210 | 973 | if (!iwl_enable_tx_ampdu(mvm->cfg)) { |
5d158efa EG |
974 | ret = -EINVAL; |
975 | break; | |
976 | } | |
8ca151b5 JB |
977 | ret = iwl_mvm_sta_tx_agg_start(mvm, vif, sta, tid, ssn); |
978 | break; | |
979 | case IEEE80211_AMPDU_TX_STOP_CONT: | |
e3d9e7ce EG |
980 | ret = iwl_mvm_sta_tx_agg_stop(mvm, vif, sta, tid); |
981 | break; | |
8ca151b5 JB |
982 | case IEEE80211_AMPDU_TX_STOP_FLUSH: |
983 | case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT: | |
e3d9e7ce | 984 | ret = iwl_mvm_sta_tx_agg_flush(mvm, vif, sta, tid); |
8ca151b5 JB |
985 | break; |
986 | case IEEE80211_AMPDU_TX_OPERATIONAL: | |
bb81bb68 EG |
987 | ret = iwl_mvm_sta_tx_agg_oper(mvm, vif, sta, tid, |
988 | buf_size, amsdu); | |
8ca151b5 JB |
989 | break; |
990 | default: | |
991 | WARN_ON_ONCE(1); | |
992 | ret = -EINVAL; | |
993 | break; | |
994 | } | |
4203263d EG |
995 | |
996 | if (!ret) { | |
997 | u16 rx_ba_ssn = 0; | |
998 | ||
999 | if (action == IEEE80211_AMPDU_RX_START) | |
1000 | rx_ba_ssn = *ssn; | |
1001 | ||
1002 | iwl_mvm_ampdu_check_trigger(mvm, vif, sta, tid, | |
1003 | rx_ba_ssn, action); | |
1004 | } | |
8ca151b5 JB |
1005 | mutex_unlock(&mvm->mutex); |
1006 | ||
b2492501 AN |
1007 | /* |
1008 | * If the tid is marked as started, we won't use it for offloaded | |
1009 | * traffic on the next D0i3 entry. It's safe to unref. | |
1010 | */ | |
1011 | if (tx_agg_ref) | |
1012 | iwl_mvm_unref(mvm, IWL_MVM_REF_TX_AGG); | |
1013 | ||
8ca151b5 JB |
1014 | return ret; |
1015 | } | |
1016 | ||
1017 | static void iwl_mvm_cleanup_iterator(void *data, u8 *mac, | |
1018 | struct ieee80211_vif *vif) | |
1019 | { | |
1020 | struct iwl_mvm *mvm = data; | |
1021 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
1022 | ||
1023 | mvmvif->uploaded = false; | |
0ae98812 | 1024 | mvmvif->ap_sta_id = IWL_MVM_INVALID_STA; |
8ca151b5 | 1025 | |
8ca151b5 JB |
1026 | spin_lock_bh(&mvm->time_event_lock); |
1027 | iwl_mvm_te_clear_data(mvm, &mvmvif->time_event_data); | |
1028 | spin_unlock_bh(&mvm->time_event_lock); | |
1029 | ||
fe0f2de3 | 1030 | mvmvif->phy_ctxt = NULL; |
8a275bad | 1031 | memset(&mvmvif->bf_data, 0, sizeof(mvmvif->bf_data)); |
86e177d8 | 1032 | memset(&mvmvif->probe_resp_data, 0, sizeof(mvmvif->probe_resp_data)); |
8ca151b5 JB |
1033 | } |
1034 | ||
1035 | static void iwl_mvm_restart_cleanup(struct iwl_mvm *mvm) | |
1036 | { | |
58629d9d JB |
1037 | /* clear the D3 reconfig, we only need it to avoid dumping a |
1038 | * firmware coredump on reconfiguration, we shouldn't do that | |
1039 | * on D3->D0 transition | |
1040 | */ | |
b6eaa45a | 1041 | if (!test_and_clear_bit(IWL_MVM_STATUS_D3_RECONFIG, &mvm->status)) { |
7174beb6 JB |
1042 | mvm->fwrt.dump.desc = &iwl_dump_desc_assert; |
1043 | iwl_fw_error_dump(&mvm->fwrt); | |
b6eaa45a | 1044 | } |
1bd3cbc1 | 1045 | |
744cb695 EP |
1046 | /* cleanup all stale references (scan, roc), but keep the |
1047 | * ucode_down ref until reconfig is complete | |
1048 | */ | |
1049 | iwl_mvm_unref_all_except(mvm, IWL_MVM_REF_UCODE_DOWN); | |
1050 | ||
fcb6b92a | 1051 | iwl_mvm_stop_device(mvm); |
8ca151b5 | 1052 | |
9af91f46 | 1053 | mvm->scan_status = 0; |
b1873300 | 1054 | mvm->ps_disabled = false; |
31b8b343 | 1055 | mvm->calibrating = false; |
8ca151b5 JB |
1056 | |
1057 | /* just in case one was running */ | |
305d236e | 1058 | iwl_mvm_cleanup_roc_te(mvm); |
8ca151b5 JB |
1059 | ieee80211_remain_on_channel_expired(mvm->hw); |
1060 | ||
737719fe AN |
1061 | /* |
1062 | * cleanup all interfaces, even inactive ones, as some might have | |
1063 | * gone down during the HW restart | |
1064 | */ | |
1065 | ieee80211_iterate_interfaces(mvm->hw, 0, iwl_mvm_cleanup_iterator, mvm); | |
8ca151b5 | 1066 | |
fe0f2de3 | 1067 | mvm->p2p_device_vif = NULL; |
0ae98812 | 1068 | mvm->d0i3_ap_sta_id = IWL_MVM_INVALID_STA; |
fe0f2de3 IP |
1069 | |
1070 | iwl_mvm_reset_phy_ctxts(mvm); | |
9c3deeb5 | 1071 | memset(mvm->fw_key_table, 0, sizeof(mvm->fw_key_table)); |
24afba76 | 1072 | memset(mvm->sta_deferred_frames, 0, sizeof(mvm->sta_deferred_frames)); |
8a275bad | 1073 | memset(&mvm->last_bt_notif, 0, sizeof(mvm->last_bt_notif)); |
8a275bad | 1074 | memset(&mvm->last_bt_ci_cmd, 0, sizeof(mvm->last_bt_ci_cmd)); |
8ca151b5 JB |
1075 | |
1076 | ieee80211_wake_queues(mvm->hw); | |
1077 | ||
228670b2 EP |
1078 | /* clear any stale d0i3 state */ |
1079 | clear_bit(IWL_MVM_STATUS_IN_D0I3, &mvm->status); | |
1080 | ||
8ca151b5 | 1081 | mvm->vif_count = 0; |
113a0447 | 1082 | mvm->rx_ba_sessions = 0; |
7174beb6 | 1083 | mvm->fwrt.dump.conf = FW_DBG_INVALID; |
baf41bc3 | 1084 | mvm->monitor_on = false; |
91a8bcde JB |
1085 | |
1086 | /* keep statistics ticking */ | |
1087 | iwl_mvm_accu_radio_stats(mvm); | |
8ca151b5 JB |
1088 | } |
1089 | ||
a0a09243 | 1090 | int __iwl_mvm_mac_start(struct iwl_mvm *mvm) |
8ca151b5 | 1091 | { |
8ca151b5 JB |
1092 | int ret; |
1093 | ||
a0a09243 | 1094 | lockdep_assert_held(&mvm->mutex); |
8ca151b5 | 1095 | |
bf8b286f JB |
1096 | if (test_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, &mvm->status)) { |
1097 | /* | |
1098 | * Now convert the HW_RESTART_REQUESTED flag to IN_HW_RESTART | |
1099 | * so later code will - from now on - see that we're doing it. | |
1100 | */ | |
1101 | set_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status); | |
1102 | clear_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, &mvm->status); | |
a42b2af3 | 1103 | /* Clean up some internal and mac80211 state on restart */ |
8ca151b5 | 1104 | iwl_mvm_restart_cleanup(mvm); |
a42b2af3 LC |
1105 | } else { |
1106 | /* Hold the reference to prevent runtime suspend while | |
1107 | * the start procedure runs. It's a bit confusing | |
1108 | * that the UCODE_DOWN reference is taken, but it just | |
1109 | * means "UCODE is not UP yet". ( TODO: rename this | |
1110 | * reference). | |
1111 | */ | |
1112 | iwl_mvm_ref(mvm, IWL_MVM_REF_UCODE_DOWN); | |
1113 | } | |
8ca151b5 | 1114 | ret = iwl_mvm_up(mvm); |
c47af22a JB |
1115 | |
1116 | if (ret && test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) { | |
1117 | /* Something went wrong - we need to finish some cleanup | |
1118 | * that normally iwl_mvm_mac_restart_complete() below | |
1119 | * would do. | |
1120 | */ | |
1121 | clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status); | |
a75b9b33 | 1122 | #ifdef CONFIG_PM |
c47af22a | 1123 | iwl_mvm_d0i3_enable_tx(mvm, NULL); |
a75b9b33 | 1124 | #endif |
c47af22a JB |
1125 | } |
1126 | ||
a0a09243 LC |
1127 | return ret; |
1128 | } | |
1129 | ||
1130 | static int iwl_mvm_mac_start(struct ieee80211_hw *hw) | |
1131 | { | |
1132 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1133 | int ret; | |
1134 | ||
37948fcf EP |
1135 | /* Some hw restart cleanups must not hold the mutex */ |
1136 | if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) { | |
1137 | /* | |
1138 | * Make sure we are out of d0i3. This is needed | |
1139 | * to make sure the reference accounting is correct | |
1140 | * (and there is no stale d0i3_exit_work). | |
1141 | */ | |
1142 | wait_event_timeout(mvm->d0i3_exit_waitq, | |
1143 | !test_bit(IWL_MVM_STATUS_IN_D0I3, | |
1144 | &mvm->status), | |
1145 | HZ); | |
1146 | } | |
1147 | ||
a0a09243 LC |
1148 | mutex_lock(&mvm->mutex); |
1149 | ret = __iwl_mvm_mac_start(mvm); | |
8ca151b5 JB |
1150 | mutex_unlock(&mvm->mutex); |
1151 | ||
1152 | return ret; | |
1153 | } | |
1154 | ||
cf2c92d8 | 1155 | static void iwl_mvm_restart_complete(struct iwl_mvm *mvm) |
8ca151b5 | 1156 | { |
8ca151b5 JB |
1157 | int ret; |
1158 | ||
1159 | mutex_lock(&mvm->mutex); | |
1160 | ||
1161 | clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status); | |
a75b9b33 | 1162 | #ifdef CONFIG_PM |
b2492501 | 1163 | iwl_mvm_d0i3_enable_tx(mvm, NULL); |
a75b9b33 | 1164 | #endif |
e7afe89f | 1165 | ret = iwl_mvm_update_quotas(mvm, true, NULL); |
8ca151b5 JB |
1166 | if (ret) |
1167 | IWL_ERR(mvm, "Failed to update quotas after restart (%d)\n", | |
1168 | ret); | |
1169 | ||
7498cf4c EP |
1170 | /* allow transport/FW low power modes */ |
1171 | iwl_mvm_unref(mvm, IWL_MVM_REF_UCODE_DOWN); | |
1172 | ||
cbd2ae2d AN |
1173 | /* |
1174 | * If we have TDLS peers, remove them. We don't know the last seqno/PN | |
1175 | * of packets the FW sent out, so we must reconnect. | |
1176 | */ | |
1177 | iwl_mvm_teardown_tdls_peers(mvm); | |
1178 | ||
8ca151b5 JB |
1179 | mutex_unlock(&mvm->mutex); |
1180 | } | |
1181 | ||
088070a2 EP |
1182 | static void iwl_mvm_resume_complete(struct iwl_mvm *mvm) |
1183 | { | |
b7282643 LC |
1184 | if (iwl_mvm_is_d0i3_supported(mvm) && |
1185 | iwl_mvm_enter_d0i3_on_suspend(mvm)) | |
1186 | WARN_ONCE(!wait_event_timeout(mvm->d0i3_exit_waitq, | |
1187 | !test_bit(IWL_MVM_STATUS_IN_D0I3, | |
1188 | &mvm->status), | |
1189 | HZ), | |
1190 | "D0i3 exit on resume timed out\n"); | |
088070a2 EP |
1191 | } |
1192 | ||
cf2c92d8 EP |
1193 | static void |
1194 | iwl_mvm_mac_reconfig_complete(struct ieee80211_hw *hw, | |
1195 | enum ieee80211_reconfig_type reconfig_type) | |
1196 | { | |
1197 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1198 | ||
1199 | switch (reconfig_type) { | |
1200 | case IEEE80211_RECONFIG_TYPE_RESTART: | |
1201 | iwl_mvm_restart_complete(mvm); | |
1202 | break; | |
1203 | case IEEE80211_RECONFIG_TYPE_SUSPEND: | |
088070a2 | 1204 | iwl_mvm_resume_complete(mvm); |
cf2c92d8 EP |
1205 | break; |
1206 | } | |
1207 | } | |
1208 | ||
a0a09243 | 1209 | void __iwl_mvm_mac_stop(struct iwl_mvm *mvm) |
8ca151b5 | 1210 | { |
a0a09243 | 1211 | lockdep_assert_held(&mvm->mutex); |
7498cf4c | 1212 | |
91a8bcde JB |
1213 | /* firmware counters are obviously reset now, but we shouldn't |
1214 | * partially track so also clear the fw_reset_accu counters. | |
1215 | */ | |
1216 | memset(&mvm->accu_radio_stats, 0, sizeof(mvm->accu_radio_stats)); | |
1217 | ||
8ca151b5 JB |
1218 | /* async_handlers_wk is now blocked */ |
1219 | ||
1220 | /* | |
1221 | * The work item could be running or queued if the | |
1222 | * ROC time event stops just as we get here. | |
1223 | */ | |
c779273b | 1224 | flush_work(&mvm->roc_done_wk); |
8ca151b5 | 1225 | |
fcb6b92a | 1226 | iwl_mvm_stop_device(mvm); |
8ca151b5 JB |
1227 | |
1228 | iwl_mvm_async_handlers_purge(mvm); | |
1229 | /* async_handlers_list is empty and will stay empty: HW is stopped */ | |
1230 | ||
1231 | /* the fw is stopped, the aux sta is dead: clean up driver state */ | |
712b24ad | 1232 | iwl_mvm_del_aux_sta(mvm); |
8ca151b5 | 1233 | |
0a79a0c0 | 1234 | /* |
155f7e04 EG |
1235 | * Clear IN_HW_RESTART and HW_RESTART_REQUESTED flag when stopping the |
1236 | * hw (as restart_complete() won't be called in this case) and mac80211 | |
1237 | * won't execute the restart. | |
8b2b9fbf AN |
1238 | * But make sure to cleanup interfaces that have gone down before/during |
1239 | * HW restart was requested. | |
0a79a0c0 | 1240 | */ |
155f7e04 EG |
1241 | if (test_and_clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) || |
1242 | test_and_clear_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, | |
1243 | &mvm->status)) | |
8b2b9fbf AN |
1244 | ieee80211_iterate_interfaces(mvm->hw, 0, |
1245 | iwl_mvm_cleanup_iterator, mvm); | |
0a79a0c0 | 1246 | |
963221be AB |
1247 | /* We shouldn't have any UIDs still set. Loop over all the UIDs to |
1248 | * make sure there's nothing left there and warn if any is found. | |
1249 | */ | |
859d914c | 1250 | if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN)) { |
963221be AB |
1251 | int i; |
1252 | ||
507e4cda | 1253 | for (i = 0; i < mvm->max_scans; i++) { |
6185af2a LC |
1254 | if (WARN_ONCE(mvm->scan_uid_status[i], |
1255 | "UMAC scan UID %d status was not cleaned\n", | |
1256 | i)) | |
1257 | mvm->scan_uid_status[i] = 0; | |
963221be AB |
1258 | } |
1259 | } | |
a0a09243 | 1260 | } |
bc44886d | 1261 | |
a0a09243 LC |
1262 | static void iwl_mvm_mac_stop(struct ieee80211_hw *hw) |
1263 | { | |
1264 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1265 | ||
1266 | flush_work(&mvm->d0i3_exit_work); | |
1267 | flush_work(&mvm->async_handlers_wk); | |
24afba76 | 1268 | flush_work(&mvm->add_stream_wk); |
771147b0 JB |
1269 | |
1270 | /* | |
1271 | * Lock and clear the firmware running bit here already, so that | |
1272 | * new commands coming in elsewhere, e.g. from debugfs, will not | |
1273 | * be able to proceed. This is important here because one of those | |
7174beb6 | 1274 | * debugfs files causes the firmware dump to be triggered, and if we |
771147b0 JB |
1275 | * don't stop debugfs accesses before canceling that it could be |
1276 | * retriggered after we flush it but before we've cleared the bit. | |
1277 | */ | |
1278 | clear_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, &mvm->status); | |
1279 | ||
7174beb6 | 1280 | iwl_fw_cancel_dump(&mvm->fwrt); |
d3a108a4 | 1281 | cancel_delayed_work_sync(&mvm->cs_tx_unblock_dwork); |
69e04642 | 1282 | cancel_delayed_work_sync(&mvm->scan_timeout_dwork); |
7174beb6 | 1283 | iwl_fw_free_dump_desc(&mvm->fwrt); |
a0a09243 LC |
1284 | |
1285 | mutex_lock(&mvm->mutex); | |
1286 | __iwl_mvm_mac_stop(mvm); | |
8ca151b5 JB |
1287 | mutex_unlock(&mvm->mutex); |
1288 | ||
1289 | /* | |
1290 | * The worker might have been waiting for the mutex, let it run and | |
1291 | * discover that its list is now empty. | |
1292 | */ | |
1293 | cancel_work_sync(&mvm->async_handlers_wk); | |
1294 | } | |
1295 | ||
fe0f2de3 IP |
1296 | static struct iwl_mvm_phy_ctxt *iwl_mvm_get_free_phy_ctxt(struct iwl_mvm *mvm) |
1297 | { | |
1298 | u16 i; | |
1299 | ||
1300 | lockdep_assert_held(&mvm->mutex); | |
1301 | ||
1302 | for (i = 0; i < NUM_PHY_CTX; i++) | |
1303 | if (!mvm->phy_ctxts[i].ref) | |
1304 | return &mvm->phy_ctxts[i]; | |
1305 | ||
1306 | IWL_ERR(mvm, "No available PHY context\n"); | |
1307 | return NULL; | |
1308 | } | |
1309 | ||
d44c3fe6 AA |
1310 | static int iwl_mvm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif, |
1311 | s16 tx_power) | |
1312 | { | |
0791c2fc HD |
1313 | int len; |
1314 | union { | |
1315 | struct iwl_dev_tx_power_cmd v5; | |
1316 | struct iwl_dev_tx_power_cmd_v4 v4; | |
1317 | } cmd = { | |
1318 | .v5.v3.set_mode = cpu_to_le32(IWL_TX_POWER_MODE_SET_MAC), | |
1319 | .v5.v3.mac_context_id = | |
d44c3fe6 | 1320 | cpu_to_le32(iwl_mvm_vif_from_mac80211(vif)->id), |
0791c2fc | 1321 | .v5.v3.pwr_restriction = cpu_to_le16(8 * tx_power), |
d44c3fe6 AA |
1322 | }; |
1323 | ||
d44c3fe6 | 1324 | if (tx_power == IWL_DEFAULT_MAX_TX_POWER) |
0791c2fc | 1325 | cmd.v5.v3.pwr_restriction = cpu_to_le16(IWL_DEV_MAX_TX_POWER); |
d44c3fe6 | 1326 | |
0791c2fc HD |
1327 | if (fw_has_api(&mvm->fw->ucode_capa, |
1328 | IWL_UCODE_TLV_API_REDUCE_TX_POWER)) | |
1329 | len = sizeof(cmd.v5); | |
1330 | else if (fw_has_capa(&mvm->fw->ucode_capa, | |
1331 | IWL_UCODE_TLV_CAPA_TX_POWER_ACK)) | |
1332 | len = sizeof(cmd.v4); | |
1333 | else | |
1334 | len = sizeof(cmd.v4.v3); | |
da03f029 JB |
1335 | |
1336 | return iwl_mvm_send_cmd_pdu(mvm, REDUCE_TX_POWER_CMD, 0, len, &cmd); | |
d44c3fe6 AA |
1337 | } |
1338 | ||
8ca151b5 JB |
1339 | static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw, |
1340 | struct ieee80211_vif *vif) | |
1341 | { | |
1342 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1343 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
1344 | int ret; | |
1345 | ||
aa5e1832 | 1346 | mvmvif->mvm = mvm; |
86e177d8 | 1347 | RCU_INIT_POINTER(mvmvif->probe_resp_data, NULL); |
aa5e1832 | 1348 | |
d40fc489 GG |
1349 | /* |
1350 | * make sure D0i3 exit is completed, otherwise a target access | |
1351 | * during tx queue configuration could be done when still in | |
1352 | * D0i3 state. | |
1353 | */ | |
1354 | ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_ADD_IF); | |
1355 | if (ret) | |
1356 | return ret; | |
1357 | ||
8ca151b5 JB |
1358 | /* |
1359 | * Not much to do here. The stack will not allow interface | |
1360 | * types or combinations that we didn't advertise, so we | |
1361 | * don't really have to check the types. | |
1362 | */ | |
1363 | ||
1364 | mutex_lock(&mvm->mutex); | |
1365 | ||
33cef925 JB |
1366 | /* make sure that beacon statistics don't go backwards with FW reset */ |
1367 | if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) | |
1368 | mvmvif->beacon_stats.accu_num_beacons += | |
1369 | mvmvif->beacon_stats.num_beacons; | |
1370 | ||
e89044d7 | 1371 | /* Allocate resources for the MAC context, and add it to the fw */ |
8ca151b5 JB |
1372 | ret = iwl_mvm_mac_ctxt_init(mvm, vif); |
1373 | if (ret) | |
1374 | goto out_unlock; | |
1375 | ||
1c2abf72 | 1376 | /* Counting number of interfaces is needed for legacy PM */ |
ea183d02 IP |
1377 | if (vif->type != NL80211_IFTYPE_P2P_DEVICE) |
1378 | mvm->vif_count++; | |
ea183d02 | 1379 | |
8ca151b5 JB |
1380 | /* |
1381 | * The AP binding flow can be done only after the beacon | |
1382 | * template is configured (which happens only in the mac80211 | |
1383 | * start_ap() flow), and adding the broadcast station can happen | |
1384 | * only after the binding. | |
1385 | * In addition, since modifying the MAC before adding a bcast | |
1386 | * station is not allowed by the FW, delay the adding of MAC context to | |
1387 | * the point where we can also add the bcast station. | |
1388 | * In short: there's not much we can do at this point, other than | |
1389 | * allocating resources :) | |
1390 | */ | |
5023d966 JB |
1391 | if (vif->type == NL80211_IFTYPE_AP || |
1392 | vif->type == NL80211_IFTYPE_ADHOC) { | |
013290aa | 1393 | ret = iwl_mvm_alloc_bcast_sta(mvm, vif); |
8ca151b5 JB |
1394 | if (ret) { |
1395 | IWL_ERR(mvm, "Failed to allocate bcast sta\n"); | |
1396 | goto out_release; | |
1397 | } | |
1398 | ||
c8f54701 JB |
1399 | /* |
1400 | * Only queue for this station is the mcast queue, | |
1401 | * which shouldn't be in TFD mask anyway | |
1402 | */ | |
1403 | ret = iwl_mvm_allocate_int_sta(mvm, &mvmvif->mcast_sta, | |
1404 | 0, vif->type, | |
1405 | IWL_STA_MULTICAST); | |
1406 | if (ret) | |
1407 | goto out_release; | |
26d6c16b | 1408 | |
77740cb4 | 1409 | iwl_mvm_vif_dbgfs_register(mvm, vif); |
8ca151b5 JB |
1410 | goto out_unlock; |
1411 | } | |
1412 | ||
93190fb0 AA |
1413 | mvmvif->features |= hw->netdev_features; |
1414 | ||
8ca151b5 JB |
1415 | ret = iwl_mvm_mac_ctxt_add(mvm, vif); |
1416 | if (ret) | |
1417 | goto out_release; | |
1418 | ||
999609f1 | 1419 | ret = iwl_mvm_power_update_mac(mvm); |
e5e7aa8e | 1420 | if (ret) |
fd66fc1c | 1421 | goto out_remove_mac; |
8ca151b5 | 1422 | |
7df15b1e | 1423 | /* beacon filtering */ |
a1022927 | 1424 | ret = iwl_mvm_disable_beacon_filter(mvm, vif, 0); |
bd3351ba EP |
1425 | if (ret) |
1426 | goto out_remove_mac; | |
1427 | ||
7df15b1e | 1428 | if (!mvm->bf_allowed_vif && |
73e5f2c5 | 1429 | vif->type == NL80211_IFTYPE_STATION && !vif->p2p) { |
7df15b1e | 1430 | mvm->bf_allowed_vif = mvmvif; |
a20fd398 AO |
1431 | vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER | |
1432 | IEEE80211_VIF_SUPPORTS_CQM_RSSI; | |
7df15b1e HG |
1433 | } |
1434 | ||
8ca151b5 JB |
1435 | /* |
1436 | * P2P_DEVICE interface does not have a channel context assigned to it, | |
1437 | * so a dedicated PHY context is allocated to it and the corresponding | |
1438 | * MAC context is bound to it at this stage. | |
1439 | */ | |
1440 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { | |
8ca151b5 | 1441 | |
fe0f2de3 IP |
1442 | mvmvif->phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm); |
1443 | if (!mvmvif->phy_ctxt) { | |
1444 | ret = -ENOSPC; | |
bd3351ba | 1445 | goto out_free_bf; |
fe0f2de3 | 1446 | } |
8ca151b5 | 1447 | |
53a9d61e | 1448 | iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt); |
8ca151b5 JB |
1449 | ret = iwl_mvm_binding_add_vif(mvm, vif); |
1450 | if (ret) | |
53a9d61e | 1451 | goto out_unref_phy; |
8ca151b5 | 1452 | |
d197358b | 1453 | ret = iwl_mvm_add_p2p_bcast_sta(mvm, vif); |
8ca151b5 JB |
1454 | if (ret) |
1455 | goto out_unbind; | |
1456 | ||
1457 | /* Save a pointer to p2p device vif, so it can later be used to | |
1458 | * update the p2p device MAC when a GO is started/stopped */ | |
1459 | mvm->p2p_device_vif = vif; | |
1460 | } | |
1461 | ||
b0ffe455 JB |
1462 | iwl_mvm_tcm_add_vif(mvm, vif); |
1463 | ||
baf41bc3 ST |
1464 | if (vif->type == NL80211_IFTYPE_MONITOR) |
1465 | mvm->monitor_on = true; | |
1466 | ||
63494374 | 1467 | iwl_mvm_vif_dbgfs_register(mvm, vif); |
8ca151b5 JB |
1468 | goto out_unlock; |
1469 | ||
1470 | out_unbind: | |
1471 | iwl_mvm_binding_remove_vif(mvm, vif); | |
53a9d61e | 1472 | out_unref_phy: |
fe0f2de3 | 1473 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); |
bd3351ba EP |
1474 | out_free_bf: |
1475 | if (mvm->bf_allowed_vif == mvmvif) { | |
1476 | mvm->bf_allowed_vif = NULL; | |
a20fd398 AO |
1477 | vif->driver_flags &= ~(IEEE80211_VIF_BEACON_FILTER | |
1478 | IEEE80211_VIF_SUPPORTS_CQM_RSSI); | |
bd3351ba | 1479 | } |
8ca151b5 JB |
1480 | out_remove_mac: |
1481 | mvmvif->phy_ctxt = NULL; | |
1482 | iwl_mvm_mac_ctxt_remove(mvm, vif); | |
1483 | out_release: | |
5ee2b215 AB |
1484 | if (vif->type != NL80211_IFTYPE_P2P_DEVICE) |
1485 | mvm->vif_count--; | |
8ca151b5 JB |
1486 | out_unlock: |
1487 | mutex_unlock(&mvm->mutex); | |
1488 | ||
d40fc489 GG |
1489 | iwl_mvm_unref(mvm, IWL_MVM_REF_ADD_IF); |
1490 | ||
8ca151b5 JB |
1491 | return ret; |
1492 | } | |
1493 | ||
38a12b5b JB |
1494 | static void iwl_mvm_prepare_mac_removal(struct iwl_mvm *mvm, |
1495 | struct ieee80211_vif *vif) | |
8ca151b5 | 1496 | { |
8ca151b5 JB |
1497 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { |
1498 | /* | |
1499 | * Flush the ROC worker which will flush the OFFCHANNEL queue. | |
1500 | * We assume here that all the packets sent to the OFFCHANNEL | |
1501 | * queue are sent in ROC session. | |
1502 | */ | |
1503 | flush_work(&mvm->roc_done_wk); | |
8ca151b5 | 1504 | } |
38a12b5b JB |
1505 | } |
1506 | ||
1507 | static void iwl_mvm_mac_remove_interface(struct ieee80211_hw *hw, | |
1508 | struct ieee80211_vif *vif) | |
1509 | { | |
1510 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1511 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
86e177d8 | 1512 | struct iwl_probe_resp_data *probe_data; |
38a12b5b JB |
1513 | |
1514 | iwl_mvm_prepare_mac_removal(mvm, vif); | |
8ca151b5 | 1515 | |
b0ffe455 JB |
1516 | if (!(vif->type == NL80211_IFTYPE_AP || |
1517 | vif->type == NL80211_IFTYPE_ADHOC)) | |
1518 | iwl_mvm_tcm_rm_vif(mvm, vif); | |
1519 | ||
8ca151b5 JB |
1520 | mutex_lock(&mvm->mutex); |
1521 | ||
86e177d8 GG |
1522 | probe_data = rcu_dereference_protected(mvmvif->probe_resp_data, |
1523 | lockdep_is_held(&mvm->mutex)); | |
1524 | RCU_INIT_POINTER(mvmvif->probe_resp_data, NULL); | |
1525 | if (probe_data) | |
1526 | kfree_rcu(probe_data, rcu_head); | |
1527 | ||
7df15b1e HG |
1528 | if (mvm->bf_allowed_vif == mvmvif) { |
1529 | mvm->bf_allowed_vif = NULL; | |
a20fd398 AO |
1530 | vif->driver_flags &= ~(IEEE80211_VIF_BEACON_FILTER | |
1531 | IEEE80211_VIF_SUPPORTS_CQM_RSSI); | |
7df15b1e HG |
1532 | } |
1533 | ||
63494374 JB |
1534 | iwl_mvm_vif_dbgfs_clean(mvm, vif); |
1535 | ||
8ca151b5 JB |
1536 | /* |
1537 | * For AP/GO interface, the tear down of the resources allocated to the | |
38a12b5b | 1538 | * interface is be handled as part of the stop_ap flow. |
8ca151b5 | 1539 | */ |
5023d966 JB |
1540 | if (vif->type == NL80211_IFTYPE_AP || |
1541 | vif->type == NL80211_IFTYPE_ADHOC) { | |
507cadf2 DS |
1542 | #ifdef CONFIG_NL80211_TESTMODE |
1543 | if (vif == mvm->noa_vif) { | |
1544 | mvm->noa_vif = NULL; | |
1545 | mvm->noa_duration = 0; | |
1546 | } | |
1547 | #endif | |
26d6c16b | 1548 | iwl_mvm_dealloc_int_sta(mvm, &mvmvif->mcast_sta); |
013290aa | 1549 | iwl_mvm_dealloc_bcast_sta(mvm, vif); |
8ca151b5 JB |
1550 | goto out_release; |
1551 | } | |
1552 | ||
1553 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { | |
1554 | mvm->p2p_device_vif = NULL; | |
d197358b | 1555 | iwl_mvm_rm_p2p_bcast_sta(mvm, vif); |
8ca151b5 | 1556 | iwl_mvm_binding_remove_vif(mvm, vif); |
fe0f2de3 | 1557 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); |
8ca151b5 JB |
1558 | mvmvif->phy_ctxt = NULL; |
1559 | } | |
1560 | ||
5ee2b215 | 1561 | if (mvm->vif_count && vif->type != NL80211_IFTYPE_P2P_DEVICE) |
8ca151b5 | 1562 | mvm->vif_count--; |
1c2abf72 | 1563 | |
999609f1 | 1564 | iwl_mvm_power_update_mac(mvm); |
8ca151b5 JB |
1565 | iwl_mvm_mac_ctxt_remove(mvm, vif); |
1566 | ||
baf41bc3 ST |
1567 | if (vif->type == NL80211_IFTYPE_MONITOR) |
1568 | mvm->monitor_on = false; | |
1569 | ||
8ca151b5 | 1570 | out_release: |
8ca151b5 JB |
1571 | mutex_unlock(&mvm->mutex); |
1572 | } | |
1573 | ||
1574 | static int iwl_mvm_mac_config(struct ieee80211_hw *hw, u32 changed) | |
88f2fd73 | 1575 | { |
8ca151b5 JB |
1576 | return 0; |
1577 | } | |
1578 | ||
e59647ea EP |
1579 | struct iwl_mvm_mc_iter_data { |
1580 | struct iwl_mvm *mvm; | |
1581 | int port_id; | |
1582 | }; | |
1583 | ||
1584 | static void iwl_mvm_mc_iface_iterator(void *_data, u8 *mac, | |
1585 | struct ieee80211_vif *vif) | |
1586 | { | |
1587 | struct iwl_mvm_mc_iter_data *data = _data; | |
1588 | struct iwl_mvm *mvm = data->mvm; | |
1589 | struct iwl_mcast_filter_cmd *cmd = mvm->mcast_filter_cmd; | |
97bce57b LC |
1590 | struct iwl_host_cmd hcmd = { |
1591 | .id = MCAST_FILTER_CMD, | |
1592 | .flags = CMD_ASYNC, | |
1593 | .dataflags[0] = IWL_HCMD_DFL_NOCOPY, | |
1594 | }; | |
e59647ea EP |
1595 | int ret, len; |
1596 | ||
1597 | /* if we don't have free ports, mcast frames will be dropped */ | |
1598 | if (WARN_ON_ONCE(data->port_id >= MAX_PORT_ID_NUM)) | |
1599 | return; | |
1600 | ||
1601 | if (vif->type != NL80211_IFTYPE_STATION || | |
1602 | !vif->bss_conf.assoc) | |
1603 | return; | |
1604 | ||
1605 | cmd->port_id = data->port_id++; | |
1606 | memcpy(cmd->bssid, vif->bss_conf.bssid, ETH_ALEN); | |
1607 | len = roundup(sizeof(*cmd) + cmd->count * ETH_ALEN, 4); | |
1608 | ||
97bce57b LC |
1609 | hcmd.len[0] = len; |
1610 | hcmd.data[0] = cmd; | |
1611 | ||
1612 | ret = iwl_mvm_send_cmd(mvm, &hcmd); | |
e59647ea EP |
1613 | if (ret) |
1614 | IWL_ERR(mvm, "mcast filter cmd error. ret=%d\n", ret); | |
1615 | } | |
1616 | ||
1617 | static void iwl_mvm_recalc_multicast(struct iwl_mvm *mvm) | |
1618 | { | |
1619 | struct iwl_mvm_mc_iter_data iter_data = { | |
1620 | .mvm = mvm, | |
88f2fd73 MG |
1621 | }; |
1622 | ||
e59647ea EP |
1623 | lockdep_assert_held(&mvm->mutex); |
1624 | ||
1625 | if (WARN_ON_ONCE(!mvm->mcast_filter_cmd)) | |
1626 | return; | |
1627 | ||
1c4abec0 | 1628 | ieee80211_iterate_active_interfaces_atomic( |
e59647ea EP |
1629 | mvm->hw, IEEE80211_IFACE_ITER_NORMAL, |
1630 | iwl_mvm_mc_iface_iterator, &iter_data); | |
88f2fd73 MG |
1631 | } |
1632 | ||
e59647ea EP |
1633 | static u64 iwl_mvm_prepare_multicast(struct ieee80211_hw *hw, |
1634 | struct netdev_hw_addr_list *mc_list) | |
8ca151b5 | 1635 | { |
e59647ea EP |
1636 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
1637 | struct iwl_mcast_filter_cmd *cmd; | |
1638 | struct netdev_hw_addr *addr; | |
f3bd58f4 MS |
1639 | int addr_count; |
1640 | bool pass_all; | |
e59647ea EP |
1641 | int len; |
1642 | ||
f3bd58f4 MS |
1643 | addr_count = netdev_hw_addr_list_count(mc_list); |
1644 | pass_all = addr_count > MAX_MCAST_FILTERING_ADDRESSES || | |
1645 | IWL_MVM_FW_MCAST_FILTER_PASS_ALL; | |
1646 | if (pass_all) | |
e59647ea | 1647 | addr_count = 0; |
e59647ea EP |
1648 | |
1649 | len = roundup(sizeof(*cmd) + addr_count * ETH_ALEN, 4); | |
1650 | cmd = kzalloc(len, GFP_ATOMIC); | |
1651 | if (!cmd) | |
1652 | return 0; | |
1653 | ||
1654 | if (pass_all) { | |
1655 | cmd->pass_all = 1; | |
1656 | return (u64)(unsigned long)cmd; | |
1657 | } | |
1658 | ||
1659 | netdev_hw_addr_list_for_each(addr, mc_list) { | |
1660 | IWL_DEBUG_MAC80211(mvm, "mcast addr (%d): %pM\n", | |
1661 | cmd->count, addr->addr); | |
1662 | memcpy(&cmd->addr_list[cmd->count * ETH_ALEN], | |
1663 | addr->addr, ETH_ALEN); | |
1664 | cmd->count++; | |
1665 | } | |
1666 | ||
1667 | return (u64)(unsigned long)cmd; | |
8ca151b5 JB |
1668 | } |
1669 | ||
1670 | static void iwl_mvm_configure_filter(struct ieee80211_hw *hw, | |
1671 | unsigned int changed_flags, | |
1672 | unsigned int *total_flags, | |
1673 | u64 multicast) | |
1674 | { | |
e59647ea EP |
1675 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
1676 | struct iwl_mcast_filter_cmd *cmd = (void *)(unsigned long)multicast; | |
8ca151b5 | 1677 | |
e59647ea | 1678 | mutex_lock(&mvm->mutex); |
51b6b9e0 | 1679 | |
e59647ea EP |
1680 | /* replace previous configuration */ |
1681 | kfree(mvm->mcast_filter_cmd); | |
1682 | mvm->mcast_filter_cmd = cmd; | |
51b6b9e0 | 1683 | |
e59647ea EP |
1684 | if (!cmd) |
1685 | goto out; | |
51b6b9e0 | 1686 | |
61e7d91b LC |
1687 | if (changed_flags & FIF_ALLMULTI) |
1688 | cmd->pass_all = !!(*total_flags & FIF_ALLMULTI); | |
1689 | ||
1690 | if (cmd->pass_all) | |
1691 | cmd->count = 0; | |
1692 | ||
e59647ea EP |
1693 | iwl_mvm_recalc_multicast(mvm); |
1694 | out: | |
1695 | mutex_unlock(&mvm->mutex); | |
1696 | *total_flags = 0; | |
51b6b9e0 EG |
1697 | } |
1698 | ||
effd1929 AO |
1699 | static void iwl_mvm_config_iface_filter(struct ieee80211_hw *hw, |
1700 | struct ieee80211_vif *vif, | |
1701 | unsigned int filter_flags, | |
1702 | unsigned int changed_flags) | |
1703 | { | |
1704 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1705 | ||
1706 | /* We support only filter for probe requests */ | |
1707 | if (!(changed_flags & FIF_PROBE_REQ)) | |
1708 | return; | |
1709 | ||
1710 | /* Supported only for p2p client interfaces */ | |
1711 | if (vif->type != NL80211_IFTYPE_STATION || !vif->bss_conf.assoc || | |
1712 | !vif->p2p) | |
1713 | return; | |
1714 | ||
1715 | mutex_lock(&mvm->mutex); | |
1716 | iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL); | |
1717 | mutex_unlock(&mvm->mutex); | |
1718 | } | |
1719 | ||
c87163b9 EP |
1720 | #ifdef CONFIG_IWLWIFI_BCAST_FILTERING |
1721 | struct iwl_bcast_iter_data { | |
1722 | struct iwl_mvm *mvm; | |
1723 | struct iwl_bcast_filter_cmd *cmd; | |
1724 | u8 current_filter; | |
1725 | }; | |
1726 | ||
1727 | static void | |
1728 | iwl_mvm_set_bcast_filter(struct ieee80211_vif *vif, | |
1729 | const struct iwl_fw_bcast_filter *in_filter, | |
1730 | struct iwl_fw_bcast_filter *out_filter) | |
1731 | { | |
1732 | struct iwl_fw_bcast_filter_attr *attr; | |
1733 | int i; | |
1734 | ||
1735 | memcpy(out_filter, in_filter, sizeof(*out_filter)); | |
1736 | ||
1737 | for (i = 0; i < ARRAY_SIZE(out_filter->attrs); i++) { | |
1738 | attr = &out_filter->attrs[i]; | |
1739 | ||
1740 | if (!attr->mask) | |
1741 | break; | |
1742 | ||
2ee8f021 EP |
1743 | switch (attr->reserved1) { |
1744 | case cpu_to_le16(BC_FILTER_MAGIC_IP): | |
1745 | if (vif->bss_conf.arp_addr_cnt != 1) { | |
1746 | attr->mask = 0; | |
1747 | continue; | |
1748 | } | |
1749 | ||
1750 | attr->val = vif->bss_conf.arp_addr_list[0]; | |
1751 | break; | |
1752 | case cpu_to_le16(BC_FILTER_MAGIC_MAC): | |
1753 | attr->val = *(__be32 *)&vif->addr[2]; | |
1754 | break; | |
1755 | default: | |
1756 | break; | |
1757 | } | |
1758 | attr->reserved1 = 0; | |
c87163b9 EP |
1759 | out_filter->num_attrs++; |
1760 | } | |
1761 | } | |
1762 | ||
1763 | static void iwl_mvm_bcast_filter_iterator(void *_data, u8 *mac, | |
1764 | struct ieee80211_vif *vif) | |
1765 | { | |
1766 | struct iwl_bcast_iter_data *data = _data; | |
1767 | struct iwl_mvm *mvm = data->mvm; | |
1768 | struct iwl_bcast_filter_cmd *cmd = data->cmd; | |
1769 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
1770 | struct iwl_fw_bcast_mac *bcast_mac; | |
1771 | int i; | |
1772 | ||
1773 | if (WARN_ON(mvmvif->id >= ARRAY_SIZE(cmd->macs))) | |
1774 | return; | |
1775 | ||
1776 | bcast_mac = &cmd->macs[mvmvif->id]; | |
1777 | ||
e48393e8 IP |
1778 | /* |
1779 | * enable filtering only for associated stations, but not for P2P | |
1780 | * Clients | |
1781 | */ | |
1782 | if (vif->type != NL80211_IFTYPE_STATION || vif->p2p || | |
1783 | !vif->bss_conf.assoc) | |
c87163b9 EP |
1784 | return; |
1785 | ||
1786 | bcast_mac->default_discard = 1; | |
1787 | ||
1788 | /* copy all configured filters */ | |
1789 | for (i = 0; mvm->bcast_filters[i].attrs[0].mask; i++) { | |
1790 | /* | |
1791 | * Make sure we don't exceed our filters limit. | |
1792 | * if there is still a valid filter to be configured, | |
1793 | * be on the safe side and just allow bcast for this mac. | |
1794 | */ | |
1795 | if (WARN_ON_ONCE(data->current_filter >= | |
1796 | ARRAY_SIZE(cmd->filters))) { | |
1797 | bcast_mac->default_discard = 0; | |
1798 | bcast_mac->attached_filters = 0; | |
1799 | break; | |
1800 | } | |
1801 | ||
1802 | iwl_mvm_set_bcast_filter(vif, | |
1803 | &mvm->bcast_filters[i], | |
1804 | &cmd->filters[data->current_filter]); | |
1805 | ||
1806 | /* skip current filter if it contains no attributes */ | |
1807 | if (!cmd->filters[data->current_filter].num_attrs) | |
1808 | continue; | |
1809 | ||
1810 | /* attach the filter to current mac */ | |
1811 | bcast_mac->attached_filters |= | |
1812 | cpu_to_le16(BIT(data->current_filter)); | |
1813 | ||
1814 | data->current_filter++; | |
1815 | } | |
1816 | } | |
1817 | ||
de06a59e EP |
1818 | bool iwl_mvm_bcast_filter_build_cmd(struct iwl_mvm *mvm, |
1819 | struct iwl_bcast_filter_cmd *cmd) | |
c87163b9 | 1820 | { |
c87163b9 EP |
1821 | struct iwl_bcast_iter_data iter_data = { |
1822 | .mvm = mvm, | |
de06a59e | 1823 | .cmd = cmd, |
c87163b9 EP |
1824 | }; |
1825 | ||
3b8983b1 MS |
1826 | if (IWL_MVM_FW_BCAST_FILTER_PASS_ALL) |
1827 | return false; | |
1828 | ||
de06a59e EP |
1829 | memset(cmd, 0, sizeof(*cmd)); |
1830 | cmd->max_bcast_filters = ARRAY_SIZE(cmd->filters); | |
1831 | cmd->max_macs = ARRAY_SIZE(cmd->macs); | |
1832 | ||
1833 | #ifdef CONFIG_IWLWIFI_DEBUGFS | |
1834 | /* use debugfs filters/macs if override is configured */ | |
1835 | if (mvm->dbgfs_bcast_filtering.override) { | |
1836 | memcpy(cmd->filters, &mvm->dbgfs_bcast_filtering.cmd.filters, | |
1837 | sizeof(cmd->filters)); | |
1838 | memcpy(cmd->macs, &mvm->dbgfs_bcast_filtering.cmd.macs, | |
1839 | sizeof(cmd->macs)); | |
1840 | return true; | |
1841 | } | |
1842 | #endif | |
c87163b9 EP |
1843 | |
1844 | /* if no filters are configured, do nothing */ | |
1845 | if (!mvm->bcast_filters) | |
de06a59e | 1846 | return false; |
c87163b9 EP |
1847 | |
1848 | /* configure and attach these filters for each associated sta vif */ | |
1849 | ieee80211_iterate_active_interfaces( | |
1850 | mvm->hw, IEEE80211_IFACE_ITER_NORMAL, | |
1851 | iwl_mvm_bcast_filter_iterator, &iter_data); | |
1852 | ||
de06a59e EP |
1853 | return true; |
1854 | } | |
34672bb3 EP |
1855 | |
1856 | static int iwl_mvm_configure_bcast_filter(struct iwl_mvm *mvm) | |
de06a59e EP |
1857 | { |
1858 | struct iwl_bcast_filter_cmd cmd; | |
1859 | ||
1860 | if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BCAST_FILTERING)) | |
1861 | return 0; | |
1862 | ||
1863 | if (!iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) | |
1864 | return 0; | |
1865 | ||
a1022927 | 1866 | return iwl_mvm_send_cmd_pdu(mvm, BCAST_FILTER_CMD, 0, |
c87163b9 EP |
1867 | sizeof(cmd), &cmd); |
1868 | } | |
1869 | #else | |
34672bb3 | 1870 | static inline int iwl_mvm_configure_bcast_filter(struct iwl_mvm *mvm) |
c87163b9 EP |
1871 | { |
1872 | return 0; | |
1873 | } | |
1874 | #endif | |
1875 | ||
a07a8f37 SS |
1876 | static int iwl_mvm_update_mu_groups(struct iwl_mvm *mvm, |
1877 | struct ieee80211_vif *vif) | |
1878 | { | |
1879 | struct iwl_mu_group_mgmt_cmd cmd = {}; | |
1880 | ||
1881 | memcpy(cmd.membership_status, vif->bss_conf.mu_group.membership, | |
1882 | WLAN_MEMBERSHIP_LEN); | |
1883 | memcpy(cmd.user_position, vif->bss_conf.mu_group.position, | |
1884 | WLAN_USER_POSITION_LEN); | |
1885 | ||
1886 | return iwl_mvm_send_cmd_pdu(mvm, | |
1887 | WIDE_ID(DATA_PATH_GROUP, | |
1888 | UPDATE_MU_GROUPS_CMD), | |
1889 | 0, sizeof(cmd), &cmd); | |
1890 | } | |
1891 | ||
f92659a1 SS |
1892 | static void iwl_mvm_mu_mimo_iface_iterator(void *_data, u8 *mac, |
1893 | struct ieee80211_vif *vif) | |
1894 | { | |
1895 | if (vif->mu_mimo_owner) { | |
1896 | struct iwl_mu_group_mgmt_notif *notif = _data; | |
1897 | ||
1898 | /* | |
1899 | * MU-MIMO Group Id action frame is little endian. We treat | |
1900 | * the data received from firmware as if it came from the | |
1901 | * action frame, so no conversion is needed. | |
1902 | */ | |
1903 | ieee80211_update_mu_groups(vif, | |
1904 | (u8 *)¬if->membership_status, | |
1905 | (u8 *)¬if->user_position); | |
1906 | } | |
1907 | } | |
1908 | ||
1909 | void iwl_mvm_mu_mimo_grp_notif(struct iwl_mvm *mvm, | |
1910 | struct iwl_rx_cmd_buffer *rxb) | |
1911 | { | |
1912 | struct iwl_rx_packet *pkt = rxb_addr(rxb); | |
1913 | struct iwl_mu_group_mgmt_notif *notif = (void *)pkt->data; | |
1914 | ||
1915 | ieee80211_iterate_active_interfaces_atomic( | |
1916 | mvm->hw, IEEE80211_IFACE_ITER_NORMAL, | |
1917 | iwl_mvm_mu_mimo_iface_iterator, notif); | |
1918 | } | |
1919 | ||
514c3069 LC |
1920 | static u8 iwl_mvm_he_get_ppe_val(u8 *ppe, u8 ppe_pos_bit) |
1921 | { | |
1922 | u8 byte_num = ppe_pos_bit / 8; | |
1923 | u8 bit_num = ppe_pos_bit % 8; | |
1924 | u8 residue_bits; | |
1925 | u8 res; | |
1926 | ||
1927 | if (bit_num <= 5) | |
1928 | return (ppe[byte_num] >> bit_num) & | |
1929 | (BIT(IEEE80211_PPE_THRES_INFO_PPET_SIZE) - 1); | |
1930 | ||
1931 | /* | |
1932 | * If bit_num > 5, we have to combine bits with next byte. | |
1933 | * Calculate how many bits we need to take from current byte (called | |
1934 | * here "residue_bits"), and add them to bits from next byte. | |
1935 | */ | |
1936 | ||
1937 | residue_bits = 8 - bit_num; | |
1938 | ||
1939 | res = (ppe[byte_num + 1] & | |
1940 | (BIT(IEEE80211_PPE_THRES_INFO_PPET_SIZE - residue_bits) - 1)) << | |
1941 | residue_bits; | |
1942 | res += (ppe[byte_num] >> bit_num) & (BIT(residue_bits) - 1); | |
1943 | ||
1944 | return res; | |
1945 | } | |
1946 | ||
1947 | static void iwl_mvm_cfg_he_sta(struct iwl_mvm *mvm, | |
1948 | struct ieee80211_vif *vif, u8 sta_id) | |
1949 | { | |
1950 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
1951 | struct iwl_he_sta_context_cmd sta_ctxt_cmd = { | |
1952 | .sta_id = sta_id, | |
1953 | .tid_limit = IWL_MAX_TID_COUNT, | |
1954 | .bss_color = vif->bss_conf.bss_color, | |
1955 | .htc_trig_based_pkt_ext = vif->bss_conf.htc_trig_based_pkt_ext, | |
1956 | .frame_time_rts_th = | |
1957 | cpu_to_le16(vif->bss_conf.frame_time_rts_th), | |
1958 | }; | |
1959 | struct ieee80211_sta *sta; | |
1960 | u32 flags; | |
1961 | int i; | |
1962 | ||
1963 | rcu_read_lock(); | |
1964 | ||
1965 | sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_ctxt_cmd.sta_id]); | |
1966 | if (IS_ERR(sta)) { | |
1967 | rcu_read_unlock(); | |
1968 | WARN(1, "Can't find STA to configure HE\n"); | |
1969 | return; | |
1970 | } | |
1971 | ||
1972 | if (!sta->he_cap.has_he) { | |
1973 | rcu_read_unlock(); | |
1974 | return; | |
1975 | } | |
1976 | ||
1977 | flags = 0; | |
1978 | ||
1979 | /* HTC flags */ | |
1980 | if (sta->he_cap.he_cap_elem.mac_cap_info[0] & | |
1981 | IEEE80211_HE_MAC_CAP0_HTC_HE) | |
1982 | sta_ctxt_cmd.htc_flags |= cpu_to_le32(IWL_HE_HTC_SUPPORT); | |
1983 | if ((sta->he_cap.he_cap_elem.mac_cap_info[1] & | |
1984 | IEEE80211_HE_MAC_CAP1_LINK_ADAPTATION) || | |
1985 | (sta->he_cap.he_cap_elem.mac_cap_info[2] & | |
1986 | IEEE80211_HE_MAC_CAP2_LINK_ADAPTATION)) { | |
1987 | u8 link_adap = | |
1988 | ((sta->he_cap.he_cap_elem.mac_cap_info[2] & | |
1989 | IEEE80211_HE_MAC_CAP2_LINK_ADAPTATION) << 1) + | |
1990 | (sta->he_cap.he_cap_elem.mac_cap_info[1] & | |
1991 | IEEE80211_HE_MAC_CAP1_LINK_ADAPTATION); | |
1992 | ||
1993 | if (link_adap == 2) | |
1994 | sta_ctxt_cmd.htc_flags |= | |
1995 | cpu_to_le32(IWL_HE_HTC_LINK_ADAP_UNSOLICITED); | |
1996 | else if (link_adap == 3) | |
1997 | sta_ctxt_cmd.htc_flags |= | |
1998 | cpu_to_le32(IWL_HE_HTC_LINK_ADAP_BOTH); | |
1999 | } | |
514c3069 LC |
2000 | if (sta->he_cap.he_cap_elem.mac_cap_info[2] & IEEE80211_HE_MAC_CAP2_BSR) |
2001 | sta_ctxt_cmd.htc_flags |= cpu_to_le32(IWL_HE_HTC_BSR_SUPP); | |
2002 | if (sta->he_cap.he_cap_elem.mac_cap_info[3] & | |
2003 | IEEE80211_HE_MAC_CAP3_OMI_CONTROL) | |
2004 | sta_ctxt_cmd.htc_flags |= cpu_to_le32(IWL_HE_HTC_OMI_SUPP); | |
2005 | if (sta->he_cap.he_cap_elem.mac_cap_info[4] & IEEE80211_HE_MAC_CAP4_BQR) | |
2006 | sta_ctxt_cmd.htc_flags |= cpu_to_le32(IWL_HE_HTC_BQR_SUPP); | |
2007 | ||
2008 | /* If PPE Thresholds exist, parse them into a FW-familiar format */ | |
2009 | if (sta->he_cap.he_cap_elem.phy_cap_info[6] & | |
2010 | IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT) { | |
2011 | u8 nss = (sta->he_cap.ppe_thres[0] & | |
2012 | IEEE80211_PPE_THRES_NSS_MASK) + 1; | |
2013 | u8 ru_index_bitmap = | |
2014 | (sta->he_cap.ppe_thres[0] & | |
2015 | IEEE80211_PPE_THRES_RU_INDEX_BITMASK_MASK) >> | |
2016 | IEEE80211_PPE_THRES_RU_INDEX_BITMASK_POS; | |
2017 | u8 *ppe = &sta->he_cap.ppe_thres[0]; | |
2018 | u8 ppe_pos_bit = 7; /* Starting after PPE header */ | |
2019 | ||
2020 | /* | |
2021 | * FW currently supports only nss == MAX_HE_SUPP_NSS | |
2022 | * | |
2023 | * If nss > MAX: we can ignore values we don't support | |
2024 | * If nss < MAX: we can set zeros in other streams | |
2025 | */ | |
2026 | if (nss > MAX_HE_SUPP_NSS) { | |
2027 | IWL_INFO(mvm, "Got NSS = %d - trimming to %d\n", nss, | |
2028 | MAX_HE_SUPP_NSS); | |
2029 | nss = MAX_HE_SUPP_NSS; | |
2030 | } | |
2031 | ||
2032 | for (i = 0; i < nss; i++) { | |
2033 | u8 ru_index_tmp = ru_index_bitmap << 1; | |
2034 | u8 bw; | |
2035 | ||
2036 | for (bw = 0; bw < MAX_HE_CHANNEL_BW_INDX; bw++) { | |
2037 | ru_index_tmp >>= 1; | |
2038 | if (!(ru_index_tmp & 1)) | |
2039 | continue; | |
2040 | ||
2041 | sta_ctxt_cmd.pkt_ext.pkt_ext_qam_th[i][bw][1] = | |
2042 | iwl_mvm_he_get_ppe_val(ppe, | |
2043 | ppe_pos_bit); | |
2044 | ppe_pos_bit += | |
2045 | IEEE80211_PPE_THRES_INFO_PPET_SIZE; | |
2046 | sta_ctxt_cmd.pkt_ext.pkt_ext_qam_th[i][bw][0] = | |
2047 | iwl_mvm_he_get_ppe_val(ppe, | |
2048 | ppe_pos_bit); | |
2049 | ppe_pos_bit += | |
2050 | IEEE80211_PPE_THRES_INFO_PPET_SIZE; | |
2051 | } | |
2052 | } | |
2053 | ||
2054 | flags |= STA_CTXT_HE_PACKET_EXT; | |
2055 | } | |
2056 | rcu_read_unlock(); | |
2057 | ||
2058 | /* Mark MU EDCA as enabled, unless none detected on some AC */ | |
2059 | flags |= STA_CTXT_HE_MU_EDCA_CW; | |
2060 | for (i = 0; i < AC_NUM; i++) { | |
2061 | struct ieee80211_he_mu_edca_param_ac_rec *mu_edca = | |
2062 | &mvmvif->queue_params[i].mu_edca_param_rec; | |
2063 | ||
2064 | if (!mvmvif->queue_params[i].mu_edca) { | |
2065 | flags &= ~STA_CTXT_HE_MU_EDCA_CW; | |
2066 | break; | |
2067 | } | |
2068 | ||
2069 | sta_ctxt_cmd.trig_based_txf[i].cwmin = | |
2070 | cpu_to_le16(mu_edca->ecw_min_max & 0xf); | |
2071 | sta_ctxt_cmd.trig_based_txf[i].cwmax = | |
2072 | cpu_to_le16((mu_edca->ecw_min_max & 0xf0) >> 4); | |
2073 | sta_ctxt_cmd.trig_based_txf[i].aifsn = | |
2074 | cpu_to_le16(mu_edca->aifsn); | |
2075 | sta_ctxt_cmd.trig_based_txf[i].mu_time = | |
2076 | cpu_to_le16(mu_edca->mu_edca_timer); | |
2077 | } | |
2078 | ||
2079 | if (vif->bss_conf.multi_sta_back_32bit) | |
2080 | flags |= STA_CTXT_HE_32BIT_BA_BITMAP; | |
2081 | ||
2082 | if (vif->bss_conf.ack_enabled) | |
2083 | flags |= STA_CTXT_HE_ACK_ENABLED; | |
2084 | ||
2085 | if (vif->bss_conf.uora_exists) { | |
2086 | flags |= STA_CTXT_HE_TRIG_RND_ALLOC; | |
2087 | ||
2088 | sta_ctxt_cmd.rand_alloc_ecwmin = | |
2089 | vif->bss_conf.uora_ocw_range & 0x7; | |
2090 | sta_ctxt_cmd.rand_alloc_ecwmax = | |
2091 | (vif->bss_conf.uora_ocw_range >> 3) & 0x7; | |
2092 | } | |
2093 | ||
2094 | /* TODO: support Multi BSSID IE */ | |
2095 | ||
2096 | sta_ctxt_cmd.flags = cpu_to_le32(flags); | |
2097 | ||
2098 | if (iwl_mvm_send_cmd_pdu(mvm, iwl_cmd_id(STA_HE_CTXT_CMD, | |
2099 | DATA_PATH_GROUP, 0), | |
2100 | 0, sizeof(sta_ctxt_cmd), &sta_ctxt_cmd)) | |
2101 | IWL_ERR(mvm, "Failed to config FW to work HE!\n"); | |
2102 | } | |
2103 | ||
8ca151b5 JB |
2104 | static void iwl_mvm_bss_info_changed_station(struct iwl_mvm *mvm, |
2105 | struct ieee80211_vif *vif, | |
2106 | struct ieee80211_bss_conf *bss_conf, | |
2107 | u32 changes) | |
2108 | { | |
2109 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
2110 | int ret; | |
2111 | ||
6e97b0d2 IP |
2112 | /* |
2113 | * Re-calculate the tsf id, as the master-slave relations depend on the | |
2114 | * beacon interval, which was not known when the station interface was | |
2115 | * added. | |
2116 | */ | |
514c3069 | 2117 | if (changes & BSS_CHANGED_ASSOC && bss_conf->assoc) { |
230ba6c5 LC |
2118 | if (vif->bss_conf.he_support && |
2119 | !iwlwifi_mod_params.disable_11ax) | |
514c3069 LC |
2120 | iwl_mvm_cfg_he_sta(mvm, vif, mvmvif->ap_sta_id); |
2121 | ||
6e97b0d2 | 2122 | iwl_mvm_mac_ctxt_recalc_tsf_id(mvm, vif); |
514c3069 | 2123 | } |
6e97b0d2 | 2124 | |
3dfd3a97 JB |
2125 | /* |
2126 | * If we're not associated yet, take the (new) BSSID before associating | |
2127 | * so the firmware knows. If we're already associated, then use the old | |
2128 | * BSSID here, and we'll send a cleared one later in the CHANGED_ASSOC | |
2129 | * branch for disassociation below. | |
2130 | */ | |
2131 | if (changes & BSS_CHANGED_BSSID && !mvmvif->associated) | |
2132 | memcpy(mvmvif->bssid, bss_conf->bssid, ETH_ALEN); | |
2133 | ||
2134 | ret = iwl_mvm_mac_ctxt_changed(mvm, vif, false, mvmvif->bssid); | |
8ca151b5 JB |
2135 | if (ret) |
2136 | IWL_ERR(mvm, "failed to update MAC %pM\n", vif->addr); | |
2137 | ||
3dfd3a97 JB |
2138 | /* after sending it once, adopt mac80211 data */ |
2139 | memcpy(mvmvif->bssid, bss_conf->bssid, ETH_ALEN); | |
2140 | mvmvif->associated = bss_conf->assoc; | |
2141 | ||
8ca151b5 JB |
2142 | if (changes & BSS_CHANGED_ASSOC) { |
2143 | if (bss_conf->assoc) { | |
33cef925 JB |
2144 | /* clear statistics to get clean beacon counter */ |
2145 | iwl_mvm_request_statistics(mvm, true); | |
2146 | memset(&mvmvif->beacon_stats, 0, | |
2147 | sizeof(mvmvif->beacon_stats)); | |
2148 | ||
8ca151b5 | 2149 | /* add quota for this interface */ |
7754ae79 | 2150 | ret = iwl_mvm_update_quotas(mvm, true, NULL); |
8ca151b5 JB |
2151 | if (ret) { |
2152 | IWL_ERR(mvm, "failed to update quotas\n"); | |
2153 | return; | |
2154 | } | |
016d27e1 JB |
2155 | |
2156 | if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, | |
2157 | &mvm->status)) { | |
2158 | /* | |
2159 | * If we're restarting then the firmware will | |
2160 | * obviously have lost synchronisation with | |
2161 | * the AP. It will attempt to synchronise by | |
2162 | * itself, but we can make it more reliable by | |
2163 | * scheduling a session protection time event. | |
2164 | * | |
2165 | * The firmware needs to receive a beacon to | |
2166 | * catch up with synchronisation, use 110% of | |
2167 | * the beacon interval. | |
2168 | * | |
2169 | * Set a large maximum delay to allow for more | |
2170 | * than a single interface. | |
2171 | */ | |
2172 | u32 dur = (11 * vif->bss_conf.beacon_int) / 10; | |
2173 | iwl_mvm_protect_session(mvm, vif, dur, dur, | |
d20d37bc | 2174 | 5 * dur, false); |
016d27e1 | 2175 | } |
1f3b0ff8 LE |
2176 | |
2177 | iwl_mvm_sf_update(mvm, vif, false); | |
175a70b7 | 2178 | iwl_mvm_power_vif_assoc(mvm, vif); |
697162a1 | 2179 | if (vif->p2p) { |
29a90a49 | 2180 | iwl_mvm_ref(mvm, IWL_MVM_REF_P2P_CLIENT); |
697162a1 EG |
2181 | iwl_mvm_update_smps(mvm, vif, |
2182 | IWL_MVM_SMPS_REQ_PROT, | |
2183 | IEEE80211_SMPS_DYNAMIC); | |
2184 | } | |
0ae98812 | 2185 | } else if (mvmvif->ap_sta_id != IWL_MVM_INVALID_STA) { |
1f3b0ff8 LE |
2186 | /* |
2187 | * If update fails - SF might be running in associated | |
2188 | * mode while disassociated - which is forbidden. | |
2189 | */ | |
2190 | WARN_ONCE(iwl_mvm_sf_update(mvm, vif, false), | |
2191 | "Failed to update SF upon disassociation\n"); | |
2192 | ||
6b28f978 EG |
2193 | /* |
2194 | * If we get an assert during the connection (after the | |
2195 | * station has been added, but before the vif is set | |
2196 | * to associated), mac80211 will re-add the station and | |
2197 | * then configure the vif. Since the vif is not | |
2198 | * associated, we would remove the station here and | |
2199 | * this would fail the recovery. | |
2200 | */ | |
2201 | if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, | |
2202 | &mvm->status)) { | |
2203 | /* | |
2204 | * Remove AP station now that | |
2205 | * the MAC is unassoc | |
2206 | */ | |
2207 | ret = iwl_mvm_rm_sta_id(mvm, vif, | |
2208 | mvmvif->ap_sta_id); | |
2209 | if (ret) | |
2210 | IWL_ERR(mvm, | |
2211 | "failed to remove AP station\n"); | |
2212 | ||
2213 | if (mvm->d0i3_ap_sta_id == mvmvif->ap_sta_id) | |
2214 | mvm->d0i3_ap_sta_id = | |
2215 | IWL_MVM_INVALID_STA; | |
2216 | mvmvif->ap_sta_id = IWL_MVM_INVALID_STA; | |
2217 | } | |
37577fe2 | 2218 | |
8ca151b5 | 2219 | /* remove quota for this interface */ |
7754ae79 | 2220 | ret = iwl_mvm_update_quotas(mvm, false, NULL); |
8ca151b5 JB |
2221 | if (ret) |
2222 | IWL_ERR(mvm, "failed to update quotas\n"); | |
29a90a49 EP |
2223 | |
2224 | if (vif->p2p) | |
2225 | iwl_mvm_unref(mvm, IWL_MVM_REF_P2P_CLIENT); | |
3dfd3a97 JB |
2226 | |
2227 | /* this will take the cleared BSSID from bss_conf */ | |
2228 | ret = iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL); | |
2229 | if (ret) | |
2230 | IWL_ERR(mvm, | |
2231 | "failed to update MAC %pM (clear after unassoc)\n", | |
2232 | vif->addr); | |
8ca151b5 | 2233 | } |
a20fd398 | 2234 | |
a07a8f37 SS |
2235 | /* |
2236 | * The firmware tracks the MU-MIMO group on its own. | |
f92659a1 | 2237 | * However, on HW restart we should restore this data. |
a07a8f37 SS |
2238 | */ |
2239 | if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) && | |
f92659a1 | 2240 | (changes & BSS_CHANGED_MU_GROUPS) && vif->mu_mimo_owner) { |
a07a8f37 SS |
2241 | ret = iwl_mvm_update_mu_groups(mvm, vif); |
2242 | if (ret) | |
2243 | IWL_ERR(mvm, | |
2244 | "failed to update VHT MU_MIMO groups\n"); | |
2245 | } | |
2246 | ||
e59647ea | 2247 | iwl_mvm_recalc_multicast(mvm); |
34672bb3 | 2248 | iwl_mvm_configure_bcast_filter(mvm); |
e59647ea | 2249 | |
a20fd398 AO |
2250 | /* reset rssi values */ |
2251 | mvmvif->bf_data.ave_beacon_signal = 0; | |
2252 | ||
8e484f0b | 2253 | iwl_mvm_bt_coex_vif_change(mvm); |
f94045ed EG |
2254 | iwl_mvm_update_smps(mvm, vif, IWL_MVM_SMPS_REQ_TT, |
2255 | IEEE80211_SMPS_AUTOMATIC); | |
355346ba AS |
2256 | if (fw_has_capa(&mvm->fw->ucode_capa, |
2257 | IWL_UCODE_TLV_CAPA_UMAC_SCAN)) | |
2258 | iwl_mvm_config_scan(mvm); | |
b45242c9 AS |
2259 | } |
2260 | ||
2261 | if (changes & BSS_CHANGED_BEACON_INFO) { | |
210a544e | 2262 | /* |
b45242c9 | 2263 | * We received a beacon from the associated AP so |
210a544e JB |
2264 | * remove the session protection. |
2265 | */ | |
3edfb5f4 | 2266 | iwl_mvm_stop_session_protection(mvm, vif); |
cc87d322 | 2267 | |
cc87d322 EH |
2268 | iwl_mvm_sf_update(mvm, vif, false); |
2269 | WARN_ON(iwl_mvm_enable_beacon_filter(mvm, vif, 0)); | |
2270 | } | |
2271 | ||
283115fb AA |
2272 | if (changes & (BSS_CHANGED_PS | BSS_CHANGED_P2P_PS | BSS_CHANGED_QOS | |
2273 | /* | |
2274 | * Send power command on every beacon change, | |
2275 | * because we may have not enabled beacon abort yet. | |
2276 | */ | |
2277 | BSS_CHANGED_BEACON_INFO)) { | |
1bc10d3b JB |
2278 | ret = iwl_mvm_power_update_mac(mvm); |
2279 | if (ret) | |
2280 | IWL_ERR(mvm, "failed to update power mode\n"); | |
2281 | } | |
2282 | ||
88f2fd73 MG |
2283 | if (changes & BSS_CHANGED_TXPOWER) { |
2284 | IWL_DEBUG_CALIB(mvm, "Changing TX Power to %d\n", | |
2285 | bss_conf->txpower); | |
2286 | iwl_mvm_set_tx_power(mvm, vif, bss_conf->txpower); | |
2287 | } | |
a20fd398 AO |
2288 | |
2289 | if (changes & BSS_CHANGED_CQM) { | |
3c6acb61 | 2290 | IWL_DEBUG_MAC80211(mvm, "cqm info_changed\n"); |
a20fd398 AO |
2291 | /* reset cqm events tracking */ |
2292 | mvmvif->bf_data.last_cqm_event = 0; | |
fa7b2e7f AA |
2293 | if (mvmvif->bf_data.bf_enabled) { |
2294 | ret = iwl_mvm_enable_beacon_filter(mvm, vif, 0); | |
2295 | if (ret) | |
2296 | IWL_ERR(mvm, | |
2297 | "failed to update CQM thresholds\n"); | |
2298 | } | |
a20fd398 | 2299 | } |
2ee8f021 EP |
2300 | |
2301 | if (changes & BSS_CHANGED_ARP_FILTER) { | |
3c6acb61 | 2302 | IWL_DEBUG_MAC80211(mvm, "arp filter changed\n"); |
34672bb3 | 2303 | iwl_mvm_configure_bcast_filter(mvm); |
2ee8f021 | 2304 | } |
8ca151b5 JB |
2305 | } |
2306 | ||
5023d966 JB |
2307 | static int iwl_mvm_start_ap_ibss(struct ieee80211_hw *hw, |
2308 | struct ieee80211_vif *vif) | |
8ca151b5 JB |
2309 | { |
2310 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
2311 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
2312 | int ret; | |
2313 | ||
576eeee9 EP |
2314 | /* |
2315 | * iwl_mvm_mac_ctxt_add() might read directly from the device | |
2316 | * (the system time), so make sure it is available. | |
2317 | */ | |
2318 | ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_START_AP); | |
2319 | if (ret) | |
2320 | return ret; | |
2321 | ||
8ca151b5 JB |
2322 | mutex_lock(&mvm->mutex); |
2323 | ||
2324 | /* Send the beacon template */ | |
2325 | ret = iwl_mvm_mac_ctxt_beacon_changed(mvm, vif); | |
2326 | if (ret) | |
2327 | goto out_unlock; | |
2328 | ||
6e97b0d2 IP |
2329 | /* |
2330 | * Re-calculate the tsf id, as the master-slave relations depend on the | |
2331 | * beacon interval, which was not known when the AP interface was added. | |
2332 | */ | |
2333 | if (vif->type == NL80211_IFTYPE_AP) | |
2334 | iwl_mvm_mac_ctxt_recalc_tsf_id(mvm, vif); | |
2335 | ||
94939080 GG |
2336 | mvmvif->ap_assoc_sta_count = 0; |
2337 | ||
8ca151b5 JB |
2338 | /* Add the mac context */ |
2339 | ret = iwl_mvm_mac_ctxt_add(mvm, vif); | |
2340 | if (ret) | |
2341 | goto out_unlock; | |
2342 | ||
2343 | /* Perform the binding */ | |
2344 | ret = iwl_mvm_binding_add_vif(mvm, vif); | |
2345 | if (ret) | |
2346 | goto out_remove; | |
2347 | ||
63dd5d02 SS |
2348 | /* |
2349 | * This is not very nice, but the simplest: | |
2350 | * For older FWs adding the mcast sta before the bcast station may | |
2351 | * cause assert 0x2b00. | |
2352 | * This is fixed in later FW so make the order of removal depend on | |
2353 | * the TLV | |
2354 | */ | |
2355 | if (fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_STA_TYPE)) { | |
2356 | ret = iwl_mvm_add_mcast_sta(mvm, vif); | |
2357 | if (ret) | |
2358 | goto out_unbind; | |
2359 | /* | |
2360 | * Send the bcast station. At this stage the TBTT and DTIM time | |
2361 | * events are added and applied to the scheduler | |
2362 | */ | |
2363 | ret = iwl_mvm_send_add_bcast_sta(mvm, vif); | |
2364 | if (ret) { | |
2365 | iwl_mvm_rm_mcast_sta(mvm, vif); | |
2366 | goto out_unbind; | |
2367 | } | |
2368 | } else { | |
2369 | /* | |
2370 | * Send the bcast station. At this stage the TBTT and DTIM time | |
2371 | * events are added and applied to the scheduler | |
2372 | */ | |
75fd4fec | 2373 | ret = iwl_mvm_send_add_bcast_sta(mvm, vif); |
63dd5d02 SS |
2374 | if (ret) |
2375 | goto out_unbind; | |
75fd4fec | 2376 | ret = iwl_mvm_add_mcast_sta(mvm, vif); |
63dd5d02 SS |
2377 | if (ret) { |
2378 | iwl_mvm_send_rm_bcast_sta(mvm, vif); | |
2379 | goto out_unbind; | |
2380 | } | |
2381 | } | |
26d6c16b | 2382 | |
5691e218 IP |
2383 | /* must be set before quota calculations */ |
2384 | mvmvif->ap_ibss_active = true; | |
2385 | ||
a11e144e | 2386 | /* power updated needs to be done before quotas */ |
999609f1 | 2387 | iwl_mvm_power_update_mac(mvm); |
a11e144e | 2388 | |
7754ae79 | 2389 | ret = iwl_mvm_update_quotas(mvm, false, NULL); |
8ca151b5 | 2390 | if (ret) |
a11e144e | 2391 | goto out_quota_failed; |
8ca151b5 | 2392 | |
5023d966 | 2393 | /* Need to update the P2P Device MAC (only GO, IBSS is single vif) */ |
8ca151b5 | 2394 | if (vif->p2p && mvm->p2p_device_vif) |
3dfd3a97 | 2395 | iwl_mvm_mac_ctxt_changed(mvm, mvm->p2p_device_vif, false, NULL); |
8ca151b5 | 2396 | |
29a90a49 EP |
2397 | iwl_mvm_ref(mvm, IWL_MVM_REF_AP_IBSS); |
2398 | ||
8e484f0b | 2399 | iwl_mvm_bt_coex_vif_change(mvm); |
dac94da8 | 2400 | |
f697267f AN |
2401 | /* we don't support TDLS during DCM */ |
2402 | if (iwl_mvm_phy_ctx_count(mvm) > 1) | |
2403 | iwl_mvm_teardown_tdls_peers(mvm); | |
2404 | ||
939e4904 | 2405 | goto out_unlock; |
8ca151b5 | 2406 | |
a11e144e | 2407 | out_quota_failed: |
999609f1 | 2408 | iwl_mvm_power_update_mac(mvm); |
5691e218 | 2409 | mvmvif->ap_ibss_active = false; |
013290aa | 2410 | iwl_mvm_send_rm_bcast_sta(mvm, vif); |
ced19f26 | 2411 | iwl_mvm_rm_mcast_sta(mvm, vif); |
8ca151b5 JB |
2412 | out_unbind: |
2413 | iwl_mvm_binding_remove_vif(mvm, vif); | |
2414 | out_remove: | |
2415 | iwl_mvm_mac_ctxt_remove(mvm, vif); | |
2416 | out_unlock: | |
2417 | mutex_unlock(&mvm->mutex); | |
576eeee9 | 2418 | iwl_mvm_unref(mvm, IWL_MVM_REF_START_AP); |
8ca151b5 JB |
2419 | return ret; |
2420 | } | |
2421 | ||
5023d966 JB |
2422 | static void iwl_mvm_stop_ap_ibss(struct ieee80211_hw *hw, |
2423 | struct ieee80211_vif *vif) | |
8ca151b5 JB |
2424 | { |
2425 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
2426 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
2427 | ||
38a12b5b JB |
2428 | iwl_mvm_prepare_mac_removal(mvm, vif); |
2429 | ||
8ca151b5 JB |
2430 | mutex_lock(&mvm->mutex); |
2431 | ||
664322fa | 2432 | /* Handle AP stop while in CSA */ |
7f0a7c67 AO |
2433 | if (rcu_access_pointer(mvm->csa_vif) == vif) { |
2434 | iwl_mvm_remove_time_event(mvm, mvmvif, | |
2435 | &mvmvif->time_event_data); | |
664322fa | 2436 | RCU_INIT_POINTER(mvm->csa_vif, NULL); |
e9cb0327 | 2437 | mvmvif->csa_countdown = false; |
7f0a7c67 | 2438 | } |
664322fa | 2439 | |
003e5236 AO |
2440 | if (rcu_access_pointer(mvm->csa_tx_blocked_vif) == vif) { |
2441 | RCU_INIT_POINTER(mvm->csa_tx_blocked_vif, NULL); | |
2442 | mvm->csa_tx_block_bcn_timeout = 0; | |
2443 | } | |
2444 | ||
5023d966 | 2445 | mvmvif->ap_ibss_active = false; |
1c87bbad | 2446 | mvm->ap_last_beacon_gp2 = 0; |
8ca151b5 | 2447 | |
8e484f0b | 2448 | iwl_mvm_bt_coex_vif_change(mvm); |
dac94da8 | 2449 | |
29a90a49 EP |
2450 | iwl_mvm_unref(mvm, IWL_MVM_REF_AP_IBSS); |
2451 | ||
5023d966 | 2452 | /* Need to update the P2P Device MAC (only GO, IBSS is single vif) */ |
8ca151b5 | 2453 | if (vif->p2p && mvm->p2p_device_vif) |
3dfd3a97 | 2454 | iwl_mvm_mac_ctxt_changed(mvm, mvm->p2p_device_vif, false, NULL); |
8ca151b5 | 2455 | |
7754ae79 | 2456 | iwl_mvm_update_quotas(mvm, false, NULL); |
ced19f26 SS |
2457 | |
2458 | /* | |
2459 | * This is not very nice, but the simplest: | |
2460 | * For older FWs removing the mcast sta before the bcast station may | |
2461 | * cause assert 0x2b00. | |
2462 | * This is fixed in later FW (which will stop beaconing when removing | |
2463 | * bcast station). | |
2464 | * So make the order of removal depend on the TLV | |
2465 | */ | |
2466 | if (!fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_STA_TYPE)) | |
2467 | iwl_mvm_rm_mcast_sta(mvm, vif); | |
013290aa | 2468 | iwl_mvm_send_rm_bcast_sta(mvm, vif); |
ced19f26 SS |
2469 | if (fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_STA_TYPE)) |
2470 | iwl_mvm_rm_mcast_sta(mvm, vif); | |
8ca151b5 | 2471 | iwl_mvm_binding_remove_vif(mvm, vif); |
a11e144e | 2472 | |
999609f1 | 2473 | iwl_mvm_power_update_mac(mvm); |
a11e144e | 2474 | |
8ca151b5 JB |
2475 | iwl_mvm_mac_ctxt_remove(mvm, vif); |
2476 | ||
337bfc98 AS |
2477 | kfree(mvmvif->ap_wep_key); |
2478 | mvmvif->ap_wep_key = NULL; | |
2479 | ||
8ca151b5 JB |
2480 | mutex_unlock(&mvm->mutex); |
2481 | } | |
2482 | ||
5023d966 JB |
2483 | static void |
2484 | iwl_mvm_bss_info_changed_ap_ibss(struct iwl_mvm *mvm, | |
2485 | struct ieee80211_vif *vif, | |
2486 | struct ieee80211_bss_conf *bss_conf, | |
2487 | u32 changes) | |
8ca151b5 | 2488 | { |
be2056fc | 2489 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
8a5e3660 | 2490 | |
be2056fc IP |
2491 | /* Changes will be applied when the AP/IBSS is started */ |
2492 | if (!mvmvif->ap_ibss_active) | |
2493 | return; | |
2494 | ||
863230da | 2495 | if (changes & (BSS_CHANGED_ERP_CTS_PROT | BSS_CHANGED_HT | |
f7d8b702 | 2496 | BSS_CHANGED_BANDWIDTH | BSS_CHANGED_QOS) && |
3dfd3a97 | 2497 | iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL)) |
863230da | 2498 | IWL_ERR(mvm, "failed to update MAC %pM\n", vif->addr); |
8a5e3660 | 2499 | |
8ca151b5 | 2500 | /* Need to send a new beacon template to the FW */ |
863230da JB |
2501 | if (changes & BSS_CHANGED_BEACON && |
2502 | iwl_mvm_mac_ctxt_beacon_changed(mvm, vif)) | |
2503 | IWL_WARN(mvm, "Failed updating beacon data\n"); | |
79b7a69d HD |
2504 | |
2505 | if (changes & BSS_CHANGED_TXPOWER) { | |
2506 | IWL_DEBUG_CALIB(mvm, "Changing TX Power to %d\n", | |
2507 | bss_conf->txpower); | |
2508 | iwl_mvm_set_tx_power(mvm, vif, bss_conf->txpower); | |
2509 | } | |
8ca151b5 JB |
2510 | } |
2511 | ||
2512 | static void iwl_mvm_bss_info_changed(struct ieee80211_hw *hw, | |
2513 | struct ieee80211_vif *vif, | |
2514 | struct ieee80211_bss_conf *bss_conf, | |
2515 | u32 changes) | |
2516 | { | |
2517 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
2518 | ||
576eeee9 EP |
2519 | /* |
2520 | * iwl_mvm_bss_info_changed_station() might call | |
2521 | * iwl_mvm_protect_session(), which reads directly from | |
2522 | * the device (the system time), so make sure it is available. | |
2523 | */ | |
2524 | if (iwl_mvm_ref_sync(mvm, IWL_MVM_REF_BSS_CHANGED)) | |
2525 | return; | |
2526 | ||
8ca151b5 JB |
2527 | mutex_lock(&mvm->mutex); |
2528 | ||
723f02ed | 2529 | if (changes & BSS_CHANGED_IDLE && !bss_conf->idle) |
c7d42480 | 2530 | iwl_mvm_scan_stop(mvm, IWL_MVM_SCAN_SCHED, true); |
723f02ed | 2531 | |
8ca151b5 JB |
2532 | switch (vif->type) { |
2533 | case NL80211_IFTYPE_STATION: | |
2534 | iwl_mvm_bss_info_changed_station(mvm, vif, bss_conf, changes); | |
2535 | break; | |
2536 | case NL80211_IFTYPE_AP: | |
5023d966 JB |
2537 | case NL80211_IFTYPE_ADHOC: |
2538 | iwl_mvm_bss_info_changed_ap_ibss(mvm, vif, bss_conf, changes); | |
8ca151b5 | 2539 | break; |
91b08c2d AE |
2540 | case NL80211_IFTYPE_MONITOR: |
2541 | if (changes & BSS_CHANGED_MU_GROUPS) | |
2542 | iwl_mvm_update_mu_groups(mvm, vif); | |
2543 | break; | |
8ca151b5 JB |
2544 | default: |
2545 | /* shouldn't happen */ | |
2546 | WARN_ON_ONCE(1); | |
2547 | } | |
2548 | ||
2549 | mutex_unlock(&mvm->mutex); | |
576eeee9 | 2550 | iwl_mvm_unref(mvm, IWL_MVM_REF_BSS_CHANGED); |
8ca151b5 JB |
2551 | } |
2552 | ||
2553 | static int iwl_mvm_mac_hw_scan(struct ieee80211_hw *hw, | |
2554 | struct ieee80211_vif *vif, | |
c56ef672 | 2555 | struct ieee80211_scan_request *hw_req) |
8ca151b5 JB |
2556 | { |
2557 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
2558 | int ret; | |
2559 | ||
6749dd80 LC |
2560 | if (hw_req->req.n_channels == 0 || |
2561 | hw_req->req.n_channels > mvm->fw->ucode_capa.n_scan_channels) | |
8ca151b5 JB |
2562 | return -EINVAL; |
2563 | ||
2564 | mutex_lock(&mvm->mutex); | |
6749dd80 | 2565 | ret = iwl_mvm_reg_scan_start(mvm, vif, &hw_req->req, &hw_req->ies); |
8ca151b5 | 2566 | mutex_unlock(&mvm->mutex); |
6749dd80 | 2567 | |
8ca151b5 JB |
2568 | return ret; |
2569 | } | |
2570 | ||
2571 | static void iwl_mvm_mac_cancel_hw_scan(struct ieee80211_hw *hw, | |
2572 | struct ieee80211_vif *vif) | |
2573 | { | |
2574 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
2575 | ||
2576 | mutex_lock(&mvm->mutex); | |
2577 | ||
e7d3abab LC |
2578 | /* Due to a race condition, it's possible that mac80211 asks |
2579 | * us to stop a hw_scan when it's already stopped. This can | |
2580 | * happen, for instance, if we stopped the scan ourselves, | |
2581 | * called ieee80211_scan_completed() and the userspace called | |
2582 | * cancel scan scan before ieee80211_scan_work() could run. | |
2583 | * To handle that, simply return if the scan is not running. | |
2584 | */ | |
262888fc | 2585 | if (mvm->scan_status & IWL_MVM_SCAN_REGULAR) |
c7d42480 | 2586 | iwl_mvm_scan_stop(mvm, IWL_MVM_SCAN_REGULAR, true); |
8ca151b5 JB |
2587 | |
2588 | mutex_unlock(&mvm->mutex); | |
2589 | } | |
2590 | ||
2591 | static void | |
2592 | iwl_mvm_mac_allow_buffered_frames(struct ieee80211_hw *hw, | |
3e56eadf | 2593 | struct ieee80211_sta *sta, u16 tids, |
8ca151b5 JB |
2594 | int num_frames, |
2595 | enum ieee80211_frame_release_type reason, | |
2596 | bool more_data) | |
2597 | { | |
2598 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
8ca151b5 | 2599 | |
3e56eadf | 2600 | /* Called when we need to transmit (a) frame(s) from mac80211 */ |
8ca151b5 | 2601 | |
3e56eadf JB |
2602 | iwl_mvm_sta_modify_sleep_tx_count(mvm, sta, reason, num_frames, |
2603 | tids, more_data, false); | |
2604 | } | |
2605 | ||
2606 | static void | |
2607 | iwl_mvm_mac_release_buffered_frames(struct ieee80211_hw *hw, | |
2608 | struct ieee80211_sta *sta, u16 tids, | |
2609 | int num_frames, | |
2610 | enum ieee80211_frame_release_type reason, | |
2611 | bool more_data) | |
2612 | { | |
2613 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
2614 | ||
9a3fcf91 | 2615 | /* Called when we need to transmit (a) frame(s) from agg or dqa queue */ |
3e56eadf JB |
2616 | |
2617 | iwl_mvm_sta_modify_sleep_tx_count(mvm, sta, reason, num_frames, | |
2618 | tids, more_data, true); | |
8ca151b5 JB |
2619 | } |
2620 | ||
65e25482 JB |
2621 | static void __iwl_mvm_mac_sta_notify(struct ieee80211_hw *hw, |
2622 | enum sta_notify_cmd cmd, | |
2623 | struct ieee80211_sta *sta) | |
8ca151b5 JB |
2624 | { |
2625 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
5b577a90 | 2626 | struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); |
c22b0ff5 | 2627 | unsigned long txqs = 0, tids = 0; |
3e56eadf | 2628 | int tid; |
8ca151b5 | 2629 | |
960f864b JB |
2630 | /* |
2631 | * If we have TVQM then we get too high queue numbers - luckily | |
2632 | * we really shouldn't get here with that because such hardware | |
2633 | * should have firmware supporting buffer station offload. | |
2634 | */ | |
2635 | if (WARN_ON(iwl_mvm_has_new_tx_api(mvm))) | |
2636 | return; | |
2637 | ||
c22b0ff5 EG |
2638 | spin_lock_bh(&mvmsta->lock); |
2639 | for (tid = 0; tid < IWL_MAX_TID_COUNT; tid++) { | |
2640 | struct iwl_mvm_tid_data *tid_data = &mvmsta->tid_data[tid]; | |
2641 | ||
6862fcee | 2642 | if (tid_data->txq_id == IWL_MVM_INVALID_QUEUE) |
1c17627b SS |
2643 | continue; |
2644 | ||
c22b0ff5 EG |
2645 | __set_bit(tid_data->txq_id, &txqs); |
2646 | ||
dd32162d | 2647 | if (iwl_mvm_tid_queued(mvm, tid_data) == 0) |
c22b0ff5 EG |
2648 | continue; |
2649 | ||
2650 | __set_bit(tid, &tids); | |
2651 | } | |
2652 | ||
8ca151b5 JB |
2653 | switch (cmd) { |
2654 | case STA_NOTIFY_SLEEP: | |
c22b0ff5 | 2655 | for_each_set_bit(tid, &tids, IWL_MAX_TID_COUNT) |
3e56eadf | 2656 | ieee80211_sta_set_buffered(sta, tid, true); |
c22b0ff5 EG |
2657 | |
2658 | if (txqs) | |
2659 | iwl_trans_freeze_txq_timer(mvm->trans, txqs, true); | |
8ca151b5 JB |
2660 | /* |
2661 | * The fw updates the STA to be asleep. Tx packets on the Tx | |
2662 | * queues to this station will not be transmitted. The fw will | |
2663 | * send a Tx response with TX_STATUS_FAIL_DEST_PS. | |
2664 | */ | |
2665 | break; | |
2666 | case STA_NOTIFY_AWAKE: | |
0ae98812 | 2667 | if (WARN_ON(mvmsta->sta_id == IWL_MVM_INVALID_STA)) |
8ca151b5 | 2668 | break; |
c22b0ff5 EG |
2669 | |
2670 | if (txqs) | |
2671 | iwl_trans_freeze_txq_timer(mvm->trans, txqs, false); | |
9cc40712 | 2672 | iwl_mvm_sta_modify_ps_wake(mvm, sta); |
8ca151b5 JB |
2673 | break; |
2674 | default: | |
2675 | break; | |
2676 | } | |
c22b0ff5 | 2677 | spin_unlock_bh(&mvmsta->lock); |
8ca151b5 JB |
2678 | } |
2679 | ||
65e25482 JB |
2680 | static void iwl_mvm_mac_sta_notify(struct ieee80211_hw *hw, |
2681 | struct ieee80211_vif *vif, | |
2682 | enum sta_notify_cmd cmd, | |
2683 | struct ieee80211_sta *sta) | |
2684 | { | |
2685 | __iwl_mvm_mac_sta_notify(hw, cmd, sta); | |
2686 | } | |
2687 | ||
2688 | void iwl_mvm_sta_pm_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb) | |
2689 | { | |
2690 | struct iwl_rx_packet *pkt = rxb_addr(rxb); | |
2691 | struct iwl_mvm_pm_state_notification *notif = (void *)pkt->data; | |
2692 | struct ieee80211_sta *sta; | |
2693 | struct iwl_mvm_sta *mvmsta; | |
2694 | bool sleeping = (notif->type != IWL_MVM_PM_EVENT_AWAKE); | |
2695 | ||
2696 | if (WARN_ON(notif->sta_id >= ARRAY_SIZE(mvm->fw_id_to_mac_id))) | |
2697 | return; | |
2698 | ||
2699 | rcu_read_lock(); | |
a9560029 | 2700 | sta = rcu_dereference(mvm->fw_id_to_mac_id[notif->sta_id]); |
65e25482 JB |
2701 | if (WARN_ON(IS_ERR_OR_NULL(sta))) { |
2702 | rcu_read_unlock(); | |
2703 | return; | |
2704 | } | |
2705 | ||
2706 | mvmsta = iwl_mvm_sta_from_mac80211(sta); | |
2707 | ||
2708 | if (!mvmsta->vif || | |
2709 | mvmsta->vif->type != NL80211_IFTYPE_AP) { | |
2710 | rcu_read_unlock(); | |
2711 | return; | |
2712 | } | |
2713 | ||
2714 | if (mvmsta->sleeping != sleeping) { | |
2715 | mvmsta->sleeping = sleeping; | |
2716 | __iwl_mvm_mac_sta_notify(mvm->hw, | |
2717 | sleeping ? STA_NOTIFY_SLEEP : STA_NOTIFY_AWAKE, | |
2718 | sta); | |
2719 | ieee80211_sta_ps_transition(sta, sleeping); | |
2720 | } | |
2721 | ||
2722 | if (sleeping) { | |
2723 | switch (notif->type) { | |
2724 | case IWL_MVM_PM_EVENT_AWAKE: | |
2725 | case IWL_MVM_PM_EVENT_ASLEEP: | |
2726 | break; | |
2727 | case IWL_MVM_PM_EVENT_UAPSD: | |
2728 | ieee80211_sta_uapsd_trigger(sta, IEEE80211_NUM_TIDS); | |
2729 | break; | |
2730 | case IWL_MVM_PM_EVENT_PS_POLL: | |
2731 | ieee80211_sta_pspoll(sta); | |
2732 | break; | |
2733 | default: | |
2734 | break; | |
2735 | } | |
2736 | } | |
2737 | ||
2738 | rcu_read_unlock(); | |
2739 | } | |
2740 | ||
1ddbbb0c JB |
2741 | static void iwl_mvm_sta_pre_rcu_remove(struct ieee80211_hw *hw, |
2742 | struct ieee80211_vif *vif, | |
2743 | struct ieee80211_sta *sta) | |
2744 | { | |
2745 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
9d8ce6af | 2746 | struct iwl_mvm_sta *mvm_sta = iwl_mvm_sta_from_mac80211(sta); |
1ddbbb0c JB |
2747 | |
2748 | /* | |
2749 | * This is called before mac80211 does RCU synchronisation, | |
2750 | * so here we already invalidate our internal RCU-protected | |
2751 | * station pointer. The rest of the code will thus no longer | |
2752 | * be able to find the station this way, and we don't rely | |
2753 | * on further RCU synchronisation after the sta_state() | |
2754 | * callback deleted the station. | |
2755 | */ | |
2756 | mutex_lock(&mvm->mutex); | |
2757 | if (sta == rcu_access_pointer(mvm->fw_id_to_mac_id[mvm_sta->sta_id])) | |
2758 | rcu_assign_pointer(mvm->fw_id_to_mac_id[mvm_sta->sta_id], | |
2759 | ERR_PTR(-ENOENT)); | |
94939080 | 2760 | |
1ddbbb0c JB |
2761 | mutex_unlock(&mvm->mutex); |
2762 | } | |
2763 | ||
bd1ba664 JB |
2764 | static void iwl_mvm_check_uapsd(struct iwl_mvm *mvm, struct ieee80211_vif *vif, |
2765 | const u8 *bssid) | |
2766 | { | |
b0ffe455 JB |
2767 | int i; |
2768 | ||
2769 | if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) { | |
2770 | struct iwl_mvm_tcm_mac *mdata; | |
2771 | ||
2772 | mdata = &mvm->tcm.data[iwl_mvm_vif_from_mac80211(vif)->id]; | |
2773 | ewma_rate_init(&mdata->uapsd_nonagg_detect.rate); | |
2774 | mdata->opened_rx_ba_sessions = false; | |
2775 | } | |
2776 | ||
bd1ba664 JB |
2777 | if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_UAPSD_SUPPORT)) |
2778 | return; | |
2779 | ||
c5241b0c | 2780 | if (vif->p2p && !iwl_mvm_is_p2p_scm_uapsd_supported(mvm)) { |
cee5a882 AA |
2781 | vif->driver_flags &= ~IEEE80211_VIF_SUPPORTS_UAPSD; |
2782 | return; | |
2783 | } | |
2784 | ||
11dee0b4 EG |
2785 | if (!vif->p2p && |
2786 | (iwlwifi_mod_params.uapsd_disable & IWL_DISABLE_UAPSD_BSS)) { | |
bd1ba664 JB |
2787 | vif->driver_flags &= ~IEEE80211_VIF_SUPPORTS_UAPSD; |
2788 | return; | |
2789 | } | |
2790 | ||
b0ffe455 JB |
2791 | for (i = 0; i < IWL_MVM_UAPSD_NOAGG_LIST_LEN; i++) { |
2792 | if (ether_addr_equal(mvm->uapsd_noagg_bssids[i].addr, bssid)) { | |
2793 | vif->driver_flags &= ~IEEE80211_VIF_SUPPORTS_UAPSD; | |
2794 | return; | |
2795 | } | |
2796 | } | |
2797 | ||
bd1ba664 JB |
2798 | vif->driver_flags |= IEEE80211_VIF_SUPPORTS_UAPSD; |
2799 | } | |
2800 | ||
1e8f1329 GBA |
2801 | static void |
2802 | iwl_mvm_tdls_check_trigger(struct iwl_mvm *mvm, | |
2803 | struct ieee80211_vif *vif, u8 *peer_addr, | |
2804 | enum nl80211_tdls_operation action) | |
2805 | { | |
2806 | struct iwl_fw_dbg_trigger_tlv *trig; | |
2807 | struct iwl_fw_dbg_trigger_tdls *tdls_trig; | |
2808 | ||
6c042d75 SS |
2809 | trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif), |
2810 | FW_DBG_TRIGGER_TDLS); | |
2811 | if (!trig) | |
1e8f1329 GBA |
2812 | return; |
2813 | ||
1e8f1329 | 2814 | tdls_trig = (void *)trig->data; |
1e8f1329 GBA |
2815 | |
2816 | if (!(tdls_trig->action_bitmap & BIT(action))) | |
2817 | return; | |
2818 | ||
2819 | if (tdls_trig->peer_mode && | |
2820 | memcmp(tdls_trig->peer, peer_addr, ETH_ALEN) != 0) | |
2821 | return; | |
2822 | ||
7174beb6 JB |
2823 | iwl_fw_dbg_collect_trig(&mvm->fwrt, trig, |
2824 | "TDLS event occurred, peer %pM, action %d", | |
2825 | peer_addr, action); | |
1e8f1329 GBA |
2826 | } |
2827 | ||
24afba76 LK |
2828 | static void iwl_mvm_purge_deferred_tx_frames(struct iwl_mvm *mvm, |
2829 | struct iwl_mvm_sta *mvm_sta) | |
2830 | { | |
2831 | struct iwl_mvm_tid_data *tid_data; | |
2832 | struct sk_buff *skb; | |
2833 | int i; | |
2834 | ||
2835 | spin_lock_bh(&mvm_sta->lock); | |
2836 | for (i = 0; i <= IWL_MAX_TID_COUNT; i++) { | |
2837 | tid_data = &mvm_sta->tid_data[i]; | |
7e39a00d AS |
2838 | |
2839 | while ((skb = __skb_dequeue(&tid_data->deferred_tx_frames))) { | |
2840 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | |
2841 | ||
2842 | /* | |
2843 | * The first deferred frame should've stopped the MAC | |
2844 | * queues, so we should never get a second deferred | |
2845 | * frame for the RA/TID. | |
2846 | */ | |
8458e48a | 2847 | iwl_mvm_start_mac_queues(mvm, BIT(info->hw_queue)); |
24afba76 | 2848 | ieee80211_free_txskb(mvm->hw, skb); |
7e39a00d | 2849 | } |
24afba76 LK |
2850 | } |
2851 | spin_unlock_bh(&mvm_sta->lock); | |
2852 | } | |
2853 | ||
8ca151b5 JB |
2854 | static int iwl_mvm_mac_sta_state(struct ieee80211_hw *hw, |
2855 | struct ieee80211_vif *vif, | |
2856 | struct ieee80211_sta *sta, | |
2857 | enum ieee80211_sta_state old_state, | |
2858 | enum ieee80211_sta_state new_state) | |
2859 | { | |
2860 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
2861 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
6ea29ce5 | 2862 | struct iwl_mvm_sta *mvm_sta = iwl_mvm_sta_from_mac80211(sta); |
8ca151b5 JB |
2863 | int ret; |
2864 | ||
2865 | IWL_DEBUG_MAC80211(mvm, "station %pM state change %d->%d\n", | |
2866 | sta->addr, old_state, new_state); | |
2867 | ||
2868 | /* this would be a mac80211 bug ... but don't crash */ | |
2869 | if (WARN_ON_ONCE(!mvmvif->phy_ctxt)) | |
2870 | return -EINVAL; | |
2871 | ||
24afba76 LK |
2872 | /* |
2873 | * If we are in a STA removal flow and in DQA mode: | |
2874 | * | |
2875 | * This is after the sync_rcu part, so the queues have already been | |
2876 | * flushed. No more TXs on their way in mac80211's path, and no more in | |
2877 | * the queues. | |
2878 | * Also, we won't be getting any new TX frames for this station. | |
2879 | * What we might have are deferred TX frames that need to be taken care | |
2880 | * of. | |
2881 | * | |
2882 | * Drop any still-queued deferred-frame before removing the STA, and | |
2883 | * make sure the worker is no longer handling frames for this STA. | |
2884 | */ | |
2885 | if (old_state == IEEE80211_STA_NONE && | |
c8f54701 | 2886 | new_state == IEEE80211_STA_NOTEXIST) { |
24afba76 LK |
2887 | iwl_mvm_purge_deferred_tx_frames(mvm, mvm_sta); |
2888 | flush_work(&mvm->add_stream_wk); | |
2889 | ||
2890 | /* | |
2891 | * No need to make sure deferred TX indication is off since the | |
2892 | * worker will already remove it if it was on | |
2893 | */ | |
2894 | } | |
2895 | ||
8ca151b5 | 2896 | mutex_lock(&mvm->mutex); |
6ea29ce5 | 2897 | /* track whether or not the station is associated */ |
d94c5a82 | 2898 | mvm_sta->sta_state = new_state; |
6ea29ce5 | 2899 | |
8ca151b5 JB |
2900 | if (old_state == IEEE80211_STA_NOTEXIST && |
2901 | new_state == IEEE80211_STA_NONE) { | |
48bc1307 JB |
2902 | /* |
2903 | * Firmware bug - it'll crash if the beacon interval is less | |
2904 | * than 16. We can't avoid connecting at all, so refuse the | |
2905 | * station state change, this will cause mac80211 to abandon | |
2906 | * attempts to connect to this AP, and eventually wpa_s will | |
2907 | * blacklist the AP... | |
2908 | */ | |
2909 | if (vif->type == NL80211_IFTYPE_STATION && | |
2910 | vif->bss_conf.beacon_int < 16) { | |
2911 | IWL_ERR(mvm, | |
2912 | "AP %pM beacon interval is %d, refusing due to firmware bug!\n", | |
2913 | sta->addr, vif->bss_conf.beacon_int); | |
2914 | ret = -EINVAL; | |
2915 | goto out_unlock; | |
2916 | } | |
cf7b491d AN |
2917 | |
2918 | if (sta->tdls && | |
2919 | (vif->p2p || | |
fa3d07e4 AN |
2920 | iwl_mvm_tdls_sta_count(mvm, NULL) == |
2921 | IWL_MVM_TDLS_STA_COUNT || | |
cf7b491d AN |
2922 | iwl_mvm_phy_ctx_count(mvm) > 1)) { |
2923 | IWL_DEBUG_MAC80211(mvm, "refusing TDLS sta\n"); | |
2924 | ret = -EBUSY; | |
2925 | goto out_unlock; | |
2926 | } | |
2927 | ||
8ca151b5 | 2928 | ret = iwl_mvm_add_sta(mvm, vif, sta); |
1e8f1329 | 2929 | if (sta->tdls && ret == 0) { |
fa3d07e4 | 2930 | iwl_mvm_recalc_tdls_state(mvm, vif, true); |
1e8f1329 GBA |
2931 | iwl_mvm_tdls_check_trigger(mvm, vif, sta->addr, |
2932 | NL80211_TDLS_SETUP); | |
2933 | } | |
8ca151b5 JB |
2934 | } else if (old_state == IEEE80211_STA_NONE && |
2935 | new_state == IEEE80211_STA_AUTH) { | |
e820c2da HD |
2936 | /* |
2937 | * EBS may be disabled due to previous failures reported by FW. | |
2938 | * Reset EBS status here assuming environment has been changed. | |
2939 | */ | |
2940 | mvm->last_ebs_successful = true; | |
bd1ba664 | 2941 | iwl_mvm_check_uapsd(mvm, vif, sta->addr); |
8ca151b5 JB |
2942 | ret = 0; |
2943 | } else if (old_state == IEEE80211_STA_AUTH && | |
2944 | new_state == IEEE80211_STA_ASSOC) { | |
8be30c13 AB |
2945 | if (vif->type == NL80211_IFTYPE_AP) { |
2946 | mvmvif->ap_assoc_sta_count++; | |
2947 | iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL); | |
2948 | } | |
735a0045 | 2949 | |
3baf7528 AS |
2950 | iwl_mvm_rs_rate_init(mvm, sta, mvmvif->phy_ctxt->channel->band, |
2951 | false); | |
7a453973 | 2952 | ret = iwl_mvm_update_sta(mvm, vif, sta); |
8ca151b5 JB |
2953 | } else if (old_state == IEEE80211_STA_ASSOC && |
2954 | new_state == IEEE80211_STA_AUTHORIZED) { | |
f59e0e3c AN |
2955 | |
2956 | /* we don't support TDLS during DCM */ | |
2957 | if (iwl_mvm_phy_ctx_count(mvm) > 1) | |
2958 | iwl_mvm_teardown_tdls_peers(mvm); | |
2959 | ||
1e8f1329 GBA |
2960 | if (sta->tdls) |
2961 | iwl_mvm_tdls_check_trigger(mvm, vif, sta->addr, | |
2962 | NL80211_TDLS_ENABLE_LINK); | |
2963 | ||
7df15b1e | 2964 | /* enable beacon filtering */ |
fa7b2e7f | 2965 | WARN_ON(iwl_mvm_enable_beacon_filter(mvm, vif, 0)); |
6b7a5aea | 2966 | |
3baf7528 AS |
2967 | iwl_mvm_rs_rate_init(mvm, sta, mvmvif->phy_ctxt->channel->band, |
2968 | true); | |
6b7a5aea | 2969 | |
337bfc98 AS |
2970 | /* if wep is used, need to set the key for the station now */ |
2971 | if (vif->type == NL80211_IFTYPE_AP && mvmvif->ap_wep_key) | |
2972 | ret = iwl_mvm_set_sta_key(mvm, vif, sta, | |
2973 | mvmvif->ap_wep_key, | |
2974 | STA_KEY_IDX_INVALID); | |
2975 | else | |
2976 | ret = 0; | |
8ca151b5 JB |
2977 | } else if (old_state == IEEE80211_STA_AUTHORIZED && |
2978 | new_state == IEEE80211_STA_ASSOC) { | |
7df15b1e | 2979 | /* disable beacon filtering */ |
a1022927 | 2980 | WARN_ON(iwl_mvm_disable_beacon_filter(mvm, vif, 0)); |
8ca151b5 JB |
2981 | ret = 0; |
2982 | } else if (old_state == IEEE80211_STA_ASSOC && | |
2983 | new_state == IEEE80211_STA_AUTH) { | |
8be30c13 AB |
2984 | if (vif->type == NL80211_IFTYPE_AP) { |
2985 | mvmvif->ap_assoc_sta_count--; | |
2986 | iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL); | |
2987 | } | |
8ca151b5 JB |
2988 | ret = 0; |
2989 | } else if (old_state == IEEE80211_STA_AUTH && | |
2990 | new_state == IEEE80211_STA_NONE) { | |
2991 | ret = 0; | |
2992 | } else if (old_state == IEEE80211_STA_NONE && | |
2993 | new_state == IEEE80211_STA_NOTEXIST) { | |
2994 | ret = iwl_mvm_rm_sta(mvm, vif, sta); | |
1e8f1329 | 2995 | if (sta->tdls) { |
fa3d07e4 | 2996 | iwl_mvm_recalc_tdls_state(mvm, vif, false); |
1e8f1329 GBA |
2997 | iwl_mvm_tdls_check_trigger(mvm, vif, sta->addr, |
2998 | NL80211_TDLS_DISABLE_LINK); | |
2999 | } | |
8ca151b5 JB |
3000 | } else { |
3001 | ret = -EIO; | |
3002 | } | |
48bc1307 | 3003 | out_unlock: |
8ca151b5 JB |
3004 | mutex_unlock(&mvm->mutex); |
3005 | ||
9c126cd6 LK |
3006 | if (sta->tdls && ret == 0) { |
3007 | if (old_state == IEEE80211_STA_NOTEXIST && | |
3008 | new_state == IEEE80211_STA_NONE) | |
3009 | ieee80211_reserve_tid(sta, IWL_MVM_TDLS_FW_TID); | |
3010 | else if (old_state == IEEE80211_STA_NONE && | |
3011 | new_state == IEEE80211_STA_NOTEXIST) | |
3012 | ieee80211_unreserve_tid(sta, IWL_MVM_TDLS_FW_TID); | |
3013 | } | |
3014 | ||
8ca151b5 JB |
3015 | return ret; |
3016 | } | |
3017 | ||
3018 | static int iwl_mvm_mac_set_rts_threshold(struct ieee80211_hw *hw, u32 value) | |
3019 | { | |
3020 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
3021 | ||
3022 | mvm->rts_threshold = value; | |
3023 | ||
3024 | return 0; | |
3025 | } | |
3026 | ||
1f3b0ff8 LE |
3027 | static void iwl_mvm_sta_rc_update(struct ieee80211_hw *hw, |
3028 | struct ieee80211_vif *vif, | |
3029 | struct ieee80211_sta *sta, u32 changed) | |
3030 | { | |
3031 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
3032 | ||
3033 | if (vif->type == NL80211_IFTYPE_STATION && | |
3034 | changed & IEEE80211_RC_NSS_CHANGED) | |
3035 | iwl_mvm_sf_update(mvm, vif, false); | |
3036 | } | |
3037 | ||
8ca151b5 JB |
3038 | static int iwl_mvm_mac_conf_tx(struct ieee80211_hw *hw, |
3039 | struct ieee80211_vif *vif, u16 ac, | |
3040 | const struct ieee80211_tx_queue_params *params) | |
3041 | { | |
3042 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
3043 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
3044 | ||
3045 | mvmvif->queue_params[ac] = *params; | |
3046 | ||
3047 | /* | |
3048 | * No need to update right away, we'll get BSS_CHANGED_QOS | |
3049 | * The exception is P2P_DEVICE interface which needs immediate update. | |
3050 | */ | |
3051 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { | |
3052 | int ret; | |
3053 | ||
3054 | mutex_lock(&mvm->mutex); | |
3dfd3a97 | 3055 | ret = iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL); |
8ca151b5 JB |
3056 | mutex_unlock(&mvm->mutex); |
3057 | return ret; | |
3058 | } | |
3059 | return 0; | |
3060 | } | |
3061 | ||
3062 | static void iwl_mvm_mac_mgd_prepare_tx(struct ieee80211_hw *hw, | |
d4e36e55 IP |
3063 | struct ieee80211_vif *vif, |
3064 | u16 req_duration) | |
8ca151b5 JB |
3065 | { |
3066 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
7c70fee5 SS |
3067 | u32 duration = IWL_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS; |
3068 | u32 min_duration = IWL_MVM_TE_SESSION_PROTECTION_MIN_TIME_MS; | |
8ca151b5 | 3069 | |
576eeee9 EP |
3070 | /* |
3071 | * iwl_mvm_protect_session() reads directly from the device | |
3072 | * (the system time), so make sure it is available. | |
3073 | */ | |
3074 | if (iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PREPARE_TX)) | |
3075 | return; | |
3076 | ||
d4e36e55 IP |
3077 | if (req_duration > duration) |
3078 | duration = req_duration; | |
3079 | ||
8ca151b5 JB |
3080 | mutex_lock(&mvm->mutex); |
3081 | /* Try really hard to protect the session and hear a beacon */ | |
d20d37bc | 3082 | iwl_mvm_protect_session(mvm, vif, duration, min_duration, 500, false); |
8ca151b5 | 3083 | mutex_unlock(&mvm->mutex); |
576eeee9 EP |
3084 | |
3085 | iwl_mvm_unref(mvm, IWL_MVM_REF_PREPARE_TX); | |
8ca151b5 JB |
3086 | } |
3087 | ||
35a000b7 DS |
3088 | static int iwl_mvm_mac_sched_scan_start(struct ieee80211_hw *hw, |
3089 | struct ieee80211_vif *vif, | |
3090 | struct cfg80211_sched_scan_request *req, | |
633e2713 | 3091 | struct ieee80211_scan_ies *ies) |
35a000b7 DS |
3092 | { |
3093 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
35a000b7 | 3094 | |
35a000b7 | 3095 | int ret; |
4660dfbb | 3096 | |
35a000b7 DS |
3097 | mutex_lock(&mvm->mutex); |
3098 | ||
1f940386 | 3099 | if (!vif->bss_conf.idle) { |
bd5e4744 DS |
3100 | ret = -EBUSY; |
3101 | goto out; | |
3102 | } | |
3103 | ||
19945dfb | 3104 | ret = iwl_mvm_sched_scan_start(mvm, vif, req, ies, IWL_MVM_SCAN_SCHED); |
d2496221 | 3105 | |
35a000b7 DS |
3106 | out: |
3107 | mutex_unlock(&mvm->mutex); | |
3108 | return ret; | |
3109 | } | |
3110 | ||
37e3308c JB |
3111 | static int iwl_mvm_mac_sched_scan_stop(struct ieee80211_hw *hw, |
3112 | struct ieee80211_vif *vif) | |
35a000b7 DS |
3113 | { |
3114 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
33ea27f6 | 3115 | int ret; |
35a000b7 DS |
3116 | |
3117 | mutex_lock(&mvm->mutex); | |
e7d3abab LC |
3118 | |
3119 | /* Due to a race condition, it's possible that mac80211 asks | |
3120 | * us to stop a sched_scan when it's already stopped. This | |
3121 | * can happen, for instance, if we stopped the scan ourselves, | |
3122 | * called ieee80211_sched_scan_stopped() and the userspace called | |
3123 | * stop sched scan scan before ieee80211_sched_scan_stopped_work() | |
3124 | * could run. To handle this, simply return if the scan is | |
3125 | * not running. | |
3126 | */ | |
262888fc | 3127 | if (!(mvm->scan_status & IWL_MVM_SCAN_SCHED)) { |
e7d3abab LC |
3128 | mutex_unlock(&mvm->mutex); |
3129 | return 0; | |
3130 | } | |
3131 | ||
c7d42480 | 3132 | ret = iwl_mvm_scan_stop(mvm, IWL_MVM_SCAN_SCHED, false); |
35a000b7 | 3133 | mutex_unlock(&mvm->mutex); |
33ea27f6 | 3134 | iwl_mvm_wait_for_async_handlers(mvm); |
37e3308c | 3135 | |
33ea27f6 | 3136 | return ret; |
35a000b7 DS |
3137 | } |
3138 | ||
8ca151b5 JB |
3139 | static int iwl_mvm_mac_set_key(struct ieee80211_hw *hw, |
3140 | enum set_key_cmd cmd, | |
3141 | struct ieee80211_vif *vif, | |
3142 | struct ieee80211_sta *sta, | |
3143 | struct ieee80211_key_conf *key) | |
3144 | { | |
3145 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
f5e28eac JB |
3146 | struct iwl_mvm_sta *mvmsta; |
3147 | struct iwl_mvm_key_pn *ptk_pn; | |
3148 | int keyidx = key->keyidx; | |
8ca151b5 | 3149 | int ret; |
d6ee54a9 | 3150 | u8 key_offset; |
8ca151b5 | 3151 | |
3b37f4c9 | 3152 | if (iwlwifi_mod_params.swcrypto) { |
8ca151b5 JB |
3153 | IWL_DEBUG_MAC80211(mvm, "leave - hwcrypto disabled\n"); |
3154 | return -EOPNOTSUPP; | |
3155 | } | |
3156 | ||
3157 | switch (key->cipher) { | |
3158 | case WLAN_CIPHER_SUITE_TKIP: | |
7f768ad5 DS |
3159 | if (!mvm->trans->cfg->gen2) { |
3160 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; | |
3161 | key->flags |= IEEE80211_KEY_FLAG_PUT_IV_SPACE; | |
3162 | } else if (vif->type == NL80211_IFTYPE_STATION) { | |
3163 | key->flags |= IEEE80211_KEY_FLAG_PUT_MIC_SPACE; | |
3164 | } else { | |
3165 | IWL_DEBUG_MAC80211(mvm, "Use SW encryption for TKIP\n"); | |
3166 | return -EOPNOTSUPP; | |
3167 | } | |
8ca151b5 | 3168 | break; |
ca8c0f4b | 3169 | case WLAN_CIPHER_SUITE_CCMP: |
2a53d166 AB |
3170 | case WLAN_CIPHER_SUITE_GCMP: |
3171 | case WLAN_CIPHER_SUITE_GCMP_256: | |
85aeb58c DS |
3172 | if (!iwl_mvm_has_new_tx_api(mvm)) |
3173 | key->flags |= IEEE80211_KEY_FLAG_PUT_IV_SPACE; | |
ca8c0f4b | 3174 | break; |
8ca151b5 | 3175 | case WLAN_CIPHER_SUITE_AES_CMAC: |
8e160ab8 AB |
3176 | case WLAN_CIPHER_SUITE_BIP_GMAC_128: |
3177 | case WLAN_CIPHER_SUITE_BIP_GMAC_256: | |
30686bf7 | 3178 | WARN_ON_ONCE(!ieee80211_hw_check(hw, MFP_CAPABLE)); |
8ca151b5 JB |
3179 | break; |
3180 | case WLAN_CIPHER_SUITE_WEP40: | |
3181 | case WLAN_CIPHER_SUITE_WEP104: | |
337bfc98 AS |
3182 | if (vif->type == NL80211_IFTYPE_AP) { |
3183 | struct iwl_mvm_vif *mvmvif = | |
3184 | iwl_mvm_vif_from_mac80211(vif); | |
3185 | ||
3186 | mvmvif->ap_wep_key = kmemdup(key, | |
3187 | sizeof(*key) + key->keylen, | |
3188 | GFP_KERNEL); | |
3189 | if (!mvmvif->ap_wep_key) | |
3190 | return -ENOMEM; | |
3191 | } | |
3192 | ||
ba3943b0 JB |
3193 | if (vif->type != NL80211_IFTYPE_STATION) |
3194 | return 0; | |
3195 | break; | |
8ca151b5 | 3196 | default: |
e36e5433 MS |
3197 | /* currently FW supports only one optional cipher scheme */ |
3198 | if (hw->n_cipher_schemes && | |
3199 | hw->cipher_schemes->cipher == key->cipher) | |
3200 | key->flags |= IEEE80211_KEY_FLAG_PUT_IV_SPACE; | |
3201 | else | |
3202 | return -EOPNOTSUPP; | |
8ca151b5 JB |
3203 | } |
3204 | ||
3205 | mutex_lock(&mvm->mutex); | |
3206 | ||
3207 | switch (cmd) { | |
3208 | case SET_KEY: | |
5023d966 JB |
3209 | if ((vif->type == NL80211_IFTYPE_ADHOC || |
3210 | vif->type == NL80211_IFTYPE_AP) && !sta) { | |
3211 | /* | |
3212 | * GTK on AP interface is a TX-only key, return 0; | |
3213 | * on IBSS they're per-station and because we're lazy | |
3214 | * we don't support them for RX, so do the same. | |
8e160ab8 | 3215 | * CMAC/GMAC in AP/IBSS modes must be done in software. |
5023d966 | 3216 | */ |
8e160ab8 AB |
3217 | if (key->cipher == WLAN_CIPHER_SUITE_AES_CMAC || |
3218 | key->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_128 || | |
3219 | key->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_256) | |
81279c49 JB |
3220 | ret = -EOPNOTSUPP; |
3221 | else | |
3222 | ret = 0; | |
85aeb58c DS |
3223 | |
3224 | if (key->cipher != WLAN_CIPHER_SUITE_GCMP && | |
3225 | key->cipher != WLAN_CIPHER_SUITE_GCMP_256 && | |
3226 | !iwl_mvm_has_new_tx_api(mvm)) { | |
3227 | key->hw_key_idx = STA_KEY_IDX_INVALID; | |
3228 | break; | |
3229 | } | |
6caffd4f JB |
3230 | } |
3231 | ||
b546dcd6 JB |
3232 | /* During FW restart, in order to restore the state as it was, |
3233 | * don't try to reprogram keys we previously failed for. | |
3234 | */ | |
3235 | if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) && | |
3236 | key->hw_key_idx == STA_KEY_IDX_INVALID) { | |
3237 | IWL_DEBUG_MAC80211(mvm, | |
3238 | "skip invalid idx key programming during restart\n"); | |
3239 | ret = 0; | |
3240 | break; | |
3241 | } | |
3242 | ||
f5e28eac JB |
3243 | if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) && |
3244 | sta && iwl_mvm_has_new_rx_api(mvm) && | |
3245 | key->flags & IEEE80211_KEY_FLAG_PAIRWISE && | |
3246 | (key->cipher == WLAN_CIPHER_SUITE_CCMP || | |
2a53d166 AB |
3247 | key->cipher == WLAN_CIPHER_SUITE_GCMP || |
3248 | key->cipher == WLAN_CIPHER_SUITE_GCMP_256)) { | |
f5e28eac JB |
3249 | struct ieee80211_key_seq seq; |
3250 | int tid, q; | |
3251 | ||
3252 | mvmsta = iwl_mvm_sta_from_mac80211(sta); | |
3253 | WARN_ON(rcu_access_pointer(mvmsta->ptk_pn[keyidx])); | |
acafe7e3 KC |
3254 | ptk_pn = kzalloc(struct_size(ptk_pn, q, |
3255 | mvm->trans->num_rx_queues), | |
f5e28eac JB |
3256 | GFP_KERNEL); |
3257 | if (!ptk_pn) { | |
3258 | ret = -ENOMEM; | |
3259 | break; | |
3260 | } | |
3261 | ||
3262 | for (tid = 0; tid < IWL_MAX_TID_COUNT; tid++) { | |
3263 | ieee80211_get_key_rx_seq(key, tid, &seq); | |
3264 | for (q = 0; q < mvm->trans->num_rx_queues; q++) | |
3265 | memcpy(ptk_pn->q[q].pn[tid], | |
3266 | seq.ccmp.pn, | |
3267 | IEEE80211_CCMP_PN_LEN); | |
3268 | } | |
3269 | ||
3270 | rcu_assign_pointer(mvmsta->ptk_pn[keyidx], ptk_pn); | |
3271 | } | |
3272 | ||
d6ee54a9 LC |
3273 | /* in HW restart reuse the index, otherwise request a new one */ |
3274 | if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) | |
3275 | key_offset = key->hw_key_idx; | |
3276 | else | |
3277 | key_offset = STA_KEY_IDX_INVALID; | |
3278 | ||
8ca151b5 | 3279 | IWL_DEBUG_MAC80211(mvm, "set hwcrypto key\n"); |
d6ee54a9 | 3280 | ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, key_offset); |
8ca151b5 JB |
3281 | if (ret) { |
3282 | IWL_WARN(mvm, "set key failed\n"); | |
3283 | /* | |
3284 | * can't add key for RX, but we don't need it | |
3285 | * in the device for TX so still return 0 | |
3286 | */ | |
6caffd4f | 3287 | key->hw_key_idx = STA_KEY_IDX_INVALID; |
8ca151b5 JB |
3288 | ret = 0; |
3289 | } | |
3290 | ||
3291 | break; | |
3292 | case DISABLE_KEY: | |
6caffd4f JB |
3293 | if (key->hw_key_idx == STA_KEY_IDX_INVALID) { |
3294 | ret = 0; | |
3295 | break; | |
3296 | } | |
3297 | ||
f5e28eac JB |
3298 | if (sta && iwl_mvm_has_new_rx_api(mvm) && |
3299 | key->flags & IEEE80211_KEY_FLAG_PAIRWISE && | |
3300 | (key->cipher == WLAN_CIPHER_SUITE_CCMP || | |
2a53d166 AB |
3301 | key->cipher == WLAN_CIPHER_SUITE_GCMP || |
3302 | key->cipher == WLAN_CIPHER_SUITE_GCMP_256)) { | |
f5e28eac JB |
3303 | mvmsta = iwl_mvm_sta_from_mac80211(sta); |
3304 | ptk_pn = rcu_dereference_protected( | |
3305 | mvmsta->ptk_pn[keyidx], | |
3306 | lockdep_is_held(&mvm->mutex)); | |
3307 | RCU_INIT_POINTER(mvmsta->ptk_pn[keyidx], NULL); | |
3308 | if (ptk_pn) | |
3309 | kfree_rcu(ptk_pn, rcu_head); | |
3310 | } | |
3311 | ||
8ca151b5 JB |
3312 | IWL_DEBUG_MAC80211(mvm, "disable hwcrypto key\n"); |
3313 | ret = iwl_mvm_remove_sta_key(mvm, vif, sta, key); | |
3314 | break; | |
3315 | default: | |
3316 | ret = -EINVAL; | |
3317 | } | |
3318 | ||
3319 | mutex_unlock(&mvm->mutex); | |
3320 | return ret; | |
3321 | } | |
3322 | ||
3323 | static void iwl_mvm_mac_update_tkip_key(struct ieee80211_hw *hw, | |
3324 | struct ieee80211_vif *vif, | |
3325 | struct ieee80211_key_conf *keyconf, | |
3326 | struct ieee80211_sta *sta, | |
3327 | u32 iv32, u16 *phase1key) | |
3328 | { | |
3329 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
3330 | ||
5023d966 JB |
3331 | if (keyconf->hw_key_idx == STA_KEY_IDX_INVALID) |
3332 | return; | |
3333 | ||
8ca151b5 JB |
3334 | iwl_mvm_update_tkip_key(mvm, vif, keyconf, sta, iv32, phase1key); |
3335 | } | |
3336 | ||
3337 | ||
b112889c AM |
3338 | static bool iwl_mvm_rx_aux_roc(struct iwl_notif_wait_data *notif_wait, |
3339 | struct iwl_rx_packet *pkt, void *data) | |
3340 | { | |
3341 | struct iwl_mvm *mvm = | |
3342 | container_of(notif_wait, struct iwl_mvm, notif_wait); | |
3343 | struct iwl_hs20_roc_res *resp; | |
3344 | int resp_len = iwl_rx_packet_payload_len(pkt); | |
3345 | struct iwl_mvm_time_event_data *te_data = data; | |
3346 | ||
3347 | if (WARN_ON(pkt->hdr.cmd != HOT_SPOT_CMD)) | |
3348 | return true; | |
3349 | ||
3350 | if (WARN_ON_ONCE(resp_len != sizeof(*resp))) { | |
3351 | IWL_ERR(mvm, "Invalid HOT_SPOT_CMD response\n"); | |
3352 | return true; | |
3353 | } | |
3354 | ||
3355 | resp = (void *)pkt->data; | |
3356 | ||
3357 | IWL_DEBUG_TE(mvm, | |
3358 | "Aux ROC: Recieved response from ucode: status=%d uid=%d\n", | |
3359 | resp->status, resp->event_unique_id); | |
3360 | ||
3361 | te_data->uid = le32_to_cpu(resp->event_unique_id); | |
3362 | IWL_DEBUG_TE(mvm, "TIME_EVENT_CMD response - UID = 0x%x\n", | |
3363 | te_data->uid); | |
3364 | ||
3365 | spin_lock_bh(&mvm->time_event_lock); | |
3366 | list_add_tail(&te_data->list, &mvm->aux_roc_te_list); | |
3367 | spin_unlock_bh(&mvm->time_event_lock); | |
3368 | ||
3369 | return true; | |
3370 | } | |
3371 | ||
dc28e12f MG |
3372 | #define AUX_ROC_MIN_DURATION MSEC_TO_TU(100) |
3373 | #define AUX_ROC_MIN_DELAY MSEC_TO_TU(200) | |
3374 | #define AUX_ROC_MAX_DELAY MSEC_TO_TU(600) | |
3375 | #define AUX_ROC_SAFETY_BUFFER MSEC_TO_TU(20) | |
3376 | #define AUX_ROC_MIN_SAFETY_BUFFER MSEC_TO_TU(10) | |
b112889c AM |
3377 | static int iwl_mvm_send_aux_roc_cmd(struct iwl_mvm *mvm, |
3378 | struct ieee80211_channel *channel, | |
3379 | struct ieee80211_vif *vif, | |
3380 | int duration) | |
3381 | { | |
3382 | int res, time_reg = DEVICE_SYSTEM_TIME_REG; | |
3383 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
3384 | struct iwl_mvm_time_event_data *te_data = &mvmvif->hs_time_event_data; | |
6eb031d2 | 3385 | static const u16 time_event_response[] = { HOT_SPOT_CMD }; |
b112889c | 3386 | struct iwl_notification_wait wait_time_event; |
dc28e12f MG |
3387 | u32 dtim_interval = vif->bss_conf.dtim_period * |
3388 | vif->bss_conf.beacon_int; | |
3389 | u32 req_dur, delay; | |
b112889c AM |
3390 | struct iwl_hs20_roc_req aux_roc_req = { |
3391 | .action = cpu_to_le32(FW_CTXT_ACTION_ADD), | |
3392 | .id_and_color = | |
3393 | cpu_to_le32(FW_CMD_ID_AND_COLOR(MAC_INDEX_AUX, 0)), | |
3394 | .sta_id_and_color = cpu_to_le32(mvm->aux_sta.sta_id), | |
3395 | /* Set the channel info data */ | |
57fbcce3 | 3396 | .channel_info.band = (channel->band == NL80211_BAND_2GHZ) ? |
b112889c AM |
3397 | PHY_BAND_24 : PHY_BAND_5, |
3398 | .channel_info.channel = channel->hw_value, | |
3399 | .channel_info.width = PHY_VHT_CHANNEL_MODE20, | |
3400 | /* Set the time and duration */ | |
3401 | .apply_time = cpu_to_le32(iwl_read_prph(mvm->trans, time_reg)), | |
b112889c AM |
3402 | }; |
3403 | ||
dc28e12f MG |
3404 | delay = AUX_ROC_MIN_DELAY; |
3405 | req_dur = MSEC_TO_TU(duration); | |
3406 | ||
3407 | /* | |
3408 | * If we are associated we want the delay time to be at least one | |
3409 | * dtim interval so that the FW can wait until after the DTIM and | |
3410 | * then start the time event, this will potentially allow us to | |
3411 | * remain off-channel for the max duration. | |
3412 | * Since we want to use almost a whole dtim interval we would also | |
3413 | * like the delay to be for 2-3 dtim intervals, in case there are | |
3414 | * other time events with higher priority. | |
3415 | */ | |
3416 | if (vif->bss_conf.assoc) { | |
3417 | delay = min_t(u32, dtim_interval * 3, AUX_ROC_MAX_DELAY); | |
3418 | /* We cannot remain off-channel longer than the DTIM interval */ | |
3419 | if (dtim_interval <= req_dur) { | |
3420 | req_dur = dtim_interval - AUX_ROC_SAFETY_BUFFER; | |
3421 | if (req_dur <= AUX_ROC_MIN_DURATION) | |
3422 | req_dur = dtim_interval - | |
3423 | AUX_ROC_MIN_SAFETY_BUFFER; | |
3424 | } | |
3425 | } | |
3426 | ||
3427 | aux_roc_req.duration = cpu_to_le32(req_dur); | |
3428 | aux_roc_req.apply_time_max_delay = cpu_to_le32(delay); | |
3429 | ||
3430 | IWL_DEBUG_TE(mvm, | |
3431 | "ROC: Requesting to remain on channel %u for %ums (requested = %ums, max_delay = %ums, dtim_interval = %ums)\n", | |
3432 | channel->hw_value, req_dur, duration, delay, | |
3433 | dtim_interval); | |
b112889c AM |
3434 | /* Set the node address */ |
3435 | memcpy(aux_roc_req.node_addr, vif->addr, ETH_ALEN); | |
3436 | ||
a6cc5163 MG |
3437 | lockdep_assert_held(&mvm->mutex); |
3438 | ||
3439 | spin_lock_bh(&mvm->time_event_lock); | |
3440 | ||
3441 | if (WARN_ON(te_data->id == HOT_SPOT_CMD)) { | |
3442 | spin_unlock_bh(&mvm->time_event_lock); | |
3443 | return -EIO; | |
3444 | } | |
3445 | ||
b112889c AM |
3446 | te_data->vif = vif; |
3447 | te_data->duration = duration; | |
3448 | te_data->id = HOT_SPOT_CMD; | |
3449 | ||
b112889c AM |
3450 | spin_unlock_bh(&mvm->time_event_lock); |
3451 | ||
3452 | /* | |
3453 | * Use a notification wait, which really just processes the | |
3454 | * command response and doesn't wait for anything, in order | |
3455 | * to be able to process the response and get the UID inside | |
3456 | * the RX path. Using CMD_WANT_SKB doesn't work because it | |
3457 | * stores the buffer and then wakes up this thread, by which | |
3458 | * time another notification (that the time event started) | |
3459 | * might already be processed unsuccessfully. | |
3460 | */ | |
3461 | iwl_init_notification_wait(&mvm->notif_wait, &wait_time_event, | |
3462 | time_event_response, | |
3463 | ARRAY_SIZE(time_event_response), | |
3464 | iwl_mvm_rx_aux_roc, te_data); | |
3465 | ||
3466 | res = iwl_mvm_send_cmd_pdu(mvm, HOT_SPOT_CMD, 0, sizeof(aux_roc_req), | |
3467 | &aux_roc_req); | |
3468 | ||
3469 | if (res) { | |
3470 | IWL_ERR(mvm, "Couldn't send HOT_SPOT_CMD: %d\n", res); | |
3471 | iwl_remove_notification(&mvm->notif_wait, &wait_time_event); | |
3472 | goto out_clear_te; | |
3473 | } | |
3474 | ||
3475 | /* No need to wait for anything, so just pass 1 (0 isn't valid) */ | |
3476 | res = iwl_wait_notification(&mvm->notif_wait, &wait_time_event, 1); | |
3477 | /* should never fail */ | |
3478 | WARN_ON_ONCE(res); | |
3479 | ||
3480 | if (res) { | |
3481 | out_clear_te: | |
3482 | spin_lock_bh(&mvm->time_event_lock); | |
3483 | iwl_mvm_te_clear_data(mvm, te_data); | |
3484 | spin_unlock_bh(&mvm->time_event_lock); | |
3485 | } | |
3486 | ||
3487 | return res; | |
3488 | } | |
3489 | ||
8ca151b5 JB |
3490 | static int iwl_mvm_roc(struct ieee80211_hw *hw, |
3491 | struct ieee80211_vif *vif, | |
3492 | struct ieee80211_channel *channel, | |
d339d5ca IP |
3493 | int duration, |
3494 | enum ieee80211_roc_type type) | |
8ca151b5 JB |
3495 | { |
3496 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
fe0f2de3 | 3497 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
8ca151b5 | 3498 | struct cfg80211_chan_def chandef; |
31d385ae IP |
3499 | struct iwl_mvm_phy_ctxt *phy_ctxt; |
3500 | int ret, i; | |
3501 | ||
3502 | IWL_DEBUG_MAC80211(mvm, "enter (%d, %d, %d)\n", channel->hw_value, | |
3503 | duration, type); | |
8ca151b5 | 3504 | |
9834781c JB |
3505 | /* |
3506 | * Flush the done work, just in case it's still pending, so that | |
3507 | * the work it does can complete and we can accept new frames. | |
3508 | */ | |
6ed13164 MG |
3509 | flush_work(&mvm->roc_done_wk); |
3510 | ||
a6cc5163 MG |
3511 | mutex_lock(&mvm->mutex); |
3512 | ||
b112889c AM |
3513 | switch (vif->type) { |
3514 | case NL80211_IFTYPE_STATION: | |
859d914c JB |
3515 | if (fw_has_capa(&mvm->fw->ucode_capa, |
3516 | IWL_UCODE_TLV_CAPA_HOTSPOT_SUPPORT)) { | |
5ac6c72e LC |
3517 | /* Use aux roc framework (HS20) */ |
3518 | ret = iwl_mvm_send_aux_roc_cmd(mvm, channel, | |
3519 | vif, duration); | |
3520 | goto out_unlock; | |
3521 | } | |
3522 | IWL_ERR(mvm, "hotspot not supported\n"); | |
3523 | ret = -EINVAL; | |
a6cc5163 | 3524 | goto out_unlock; |
b112889c AM |
3525 | case NL80211_IFTYPE_P2P_DEVICE: |
3526 | /* handle below */ | |
3527 | break; | |
3528 | default: | |
3529 | IWL_ERR(mvm, "vif isn't P2P_DEVICE: %d\n", vif->type); | |
a6cc5163 MG |
3530 | ret = -EINVAL; |
3531 | goto out_unlock; | |
8ca151b5 JB |
3532 | } |
3533 | ||
31d385ae IP |
3534 | for (i = 0; i < NUM_PHY_CTX; i++) { |
3535 | phy_ctxt = &mvm->phy_ctxts[i]; | |
3536 | if (phy_ctxt->ref == 0 || mvmvif->phy_ctxt == phy_ctxt) | |
3537 | continue; | |
3538 | ||
3539 | if (phy_ctxt->ref && channel == phy_ctxt->channel) { | |
3540 | /* | |
3541 | * Unbind the P2P_DEVICE from the current PHY context, | |
3542 | * and if the PHY context is not used remove it. | |
3543 | */ | |
3544 | ret = iwl_mvm_binding_remove_vif(mvm, vif); | |
3545 | if (WARN(ret, "Failed unbinding P2P_DEVICE\n")) | |
3546 | goto out_unlock; | |
3547 | ||
3548 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); | |
3549 | ||
3550 | /* Bind the P2P_DEVICE to the current PHY Context */ | |
3551 | mvmvif->phy_ctxt = phy_ctxt; | |
3552 | ||
3553 | ret = iwl_mvm_binding_add_vif(mvm, vif); | |
3554 | if (WARN(ret, "Failed binding P2P_DEVICE\n")) | |
3555 | goto out_unlock; | |
3556 | ||
3557 | iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt); | |
3558 | goto schedule_time_event; | |
3559 | } | |
3560 | } | |
3561 | ||
3562 | /* Need to update the PHY context only if the ROC channel changed */ | |
3563 | if (channel == mvmvif->phy_ctxt->channel) | |
3564 | goto schedule_time_event; | |
3565 | ||
8ca151b5 | 3566 | cfg80211_chandef_create(&chandef, channel, NL80211_CHAN_NO_HT); |
8ca151b5 | 3567 | |
31d385ae IP |
3568 | /* |
3569 | * Change the PHY context configuration as it is currently referenced | |
3570 | * only by the P2P Device MAC | |
3571 | */ | |
3572 | if (mvmvif->phy_ctxt->ref == 1) { | |
3573 | ret = iwl_mvm_phy_ctxt_changed(mvm, mvmvif->phy_ctxt, | |
3574 | &chandef, 1, 1); | |
3575 | if (ret) | |
3576 | goto out_unlock; | |
3577 | } else { | |
3578 | /* | |
3579 | * The PHY context is shared with other MACs. Need to remove the | |
3580 | * P2P Device from the binding, allocate an new PHY context and | |
3581 | * create a new binding | |
3582 | */ | |
3583 | phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm); | |
3584 | if (!phy_ctxt) { | |
3585 | ret = -ENOSPC; | |
3586 | goto out_unlock; | |
3587 | } | |
3588 | ||
3589 | ret = iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &chandef, | |
3590 | 1, 1); | |
3591 | if (ret) { | |
3592 | IWL_ERR(mvm, "Failed to change PHY context\n"); | |
3593 | goto out_unlock; | |
3594 | } | |
3595 | ||
3596 | /* Unbind the P2P_DEVICE from the current PHY context */ | |
3597 | ret = iwl_mvm_binding_remove_vif(mvm, vif); | |
3598 | if (WARN(ret, "Failed unbinding P2P_DEVICE\n")) | |
3599 | goto out_unlock; | |
3600 | ||
3601 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); | |
3602 | ||
3603 | /* Bind the P2P_DEVICE to the new allocated PHY context */ | |
3604 | mvmvif->phy_ctxt = phy_ctxt; | |
3605 | ||
3606 | ret = iwl_mvm_binding_add_vif(mvm, vif); | |
3607 | if (WARN(ret, "Failed binding P2P_DEVICE\n")) | |
3608 | goto out_unlock; | |
3609 | ||
3610 | iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt); | |
3611 | } | |
3612 | ||
3613 | schedule_time_event: | |
8ca151b5 | 3614 | /* Schedule the time events */ |
e635c797 | 3615 | ret = iwl_mvm_start_p2p_roc(mvm, vif, duration, type); |
8ca151b5 | 3616 | |
31d385ae | 3617 | out_unlock: |
8ca151b5 JB |
3618 | mutex_unlock(&mvm->mutex); |
3619 | IWL_DEBUG_MAC80211(mvm, "leave\n"); | |
8ca151b5 JB |
3620 | return ret; |
3621 | } | |
3622 | ||
3623 | static int iwl_mvm_cancel_roc(struct ieee80211_hw *hw) | |
3624 | { | |
3625 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
3626 | ||
3627 | IWL_DEBUG_MAC80211(mvm, "enter\n"); | |
3628 | ||
3629 | mutex_lock(&mvm->mutex); | |
bf5da87f | 3630 | iwl_mvm_stop_roc(mvm); |
8ca151b5 JB |
3631 | mutex_unlock(&mvm->mutex); |
3632 | ||
3633 | IWL_DEBUG_MAC80211(mvm, "leave\n"); | |
3634 | return 0; | |
3635 | } | |
3636 | ||
b08c1d97 LC |
3637 | static int __iwl_mvm_add_chanctx(struct iwl_mvm *mvm, |
3638 | struct ieee80211_chanctx_conf *ctx) | |
8ca151b5 | 3639 | { |
fe0f2de3 IP |
3640 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
3641 | struct iwl_mvm_phy_ctxt *phy_ctxt; | |
8ca151b5 JB |
3642 | int ret; |
3643 | ||
b08c1d97 LC |
3644 | lockdep_assert_held(&mvm->mutex); |
3645 | ||
53a9d61e | 3646 | IWL_DEBUG_MAC80211(mvm, "Add channel context\n"); |
fe0f2de3 | 3647 | |
fe0f2de3 IP |
3648 | phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm); |
3649 | if (!phy_ctxt) { | |
3650 | ret = -ENOSPC; | |
3651 | goto out; | |
3652 | } | |
8ca151b5 | 3653 | |
dcbc3e1a | 3654 | ret = iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &ctx->min_def, |
53a9d61e IP |
3655 | ctx->rx_chains_static, |
3656 | ctx->rx_chains_dynamic); | |
fe0f2de3 IP |
3657 | if (ret) { |
3658 | IWL_ERR(mvm, "Failed to add PHY context\n"); | |
3659 | goto out; | |
3660 | } | |
3661 | ||
53a9d61e | 3662 | iwl_mvm_phy_ctxt_ref(mvm, phy_ctxt); |
fe0f2de3 IP |
3663 | *phy_ctxt_id = phy_ctxt->id; |
3664 | out: | |
b08c1d97 LC |
3665 | return ret; |
3666 | } | |
3667 | ||
3668 | static int iwl_mvm_add_chanctx(struct ieee80211_hw *hw, | |
3669 | struct ieee80211_chanctx_conf *ctx) | |
3670 | { | |
3671 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
3672 | int ret; | |
3673 | ||
3674 | mutex_lock(&mvm->mutex); | |
3675 | ret = __iwl_mvm_add_chanctx(mvm, ctx); | |
8ca151b5 | 3676 | mutex_unlock(&mvm->mutex); |
b08c1d97 | 3677 | |
8ca151b5 JB |
3678 | return ret; |
3679 | } | |
3680 | ||
b08c1d97 LC |
3681 | static void __iwl_mvm_remove_chanctx(struct iwl_mvm *mvm, |
3682 | struct ieee80211_chanctx_conf *ctx) | |
3683 | { | |
3684 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; | |
3685 | struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id]; | |
3686 | ||
3687 | lockdep_assert_held(&mvm->mutex); | |
3688 | ||
3689 | iwl_mvm_phy_ctxt_unref(mvm, phy_ctxt); | |
3690 | } | |
3691 | ||
8ca151b5 JB |
3692 | static void iwl_mvm_remove_chanctx(struct ieee80211_hw *hw, |
3693 | struct ieee80211_chanctx_conf *ctx) | |
3694 | { | |
3695 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
8ca151b5 JB |
3696 | |
3697 | mutex_lock(&mvm->mutex); | |
b08c1d97 | 3698 | __iwl_mvm_remove_chanctx(mvm, ctx); |
8ca151b5 JB |
3699 | mutex_unlock(&mvm->mutex); |
3700 | } | |
3701 | ||
3702 | static void iwl_mvm_change_chanctx(struct ieee80211_hw *hw, | |
3703 | struct ieee80211_chanctx_conf *ctx, | |
3704 | u32 changed) | |
3705 | { | |
3706 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
fe0f2de3 IP |
3707 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
3708 | struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id]; | |
8ca151b5 | 3709 | |
31d385ae IP |
3710 | if (WARN_ONCE((phy_ctxt->ref > 1) && |
3711 | (changed & ~(IEEE80211_CHANCTX_CHANGE_WIDTH | | |
3712 | IEEE80211_CHANCTX_CHANGE_RX_CHAINS | | |
2dceedae AN |
3713 | IEEE80211_CHANCTX_CHANGE_RADAR | |
3714 | IEEE80211_CHANCTX_CHANGE_MIN_WIDTH)), | |
31d385ae IP |
3715 | "Cannot change PHY. Ref=%d, changed=0x%X\n", |
3716 | phy_ctxt->ref, changed)) | |
3717 | return; | |
3718 | ||
8ca151b5 | 3719 | mutex_lock(&mvm->mutex); |
7a20bcce EG |
3720 | |
3721 | /* we are only changing the min_width, may be a noop */ | |
3722 | if (changed == IEEE80211_CHANCTX_CHANGE_MIN_WIDTH) { | |
3723 | if (phy_ctxt->width == ctx->min_def.width) | |
3724 | goto out_unlock; | |
3725 | ||
3726 | /* we are just toggling between 20_NOHT and 20 */ | |
3727 | if (phy_ctxt->width <= NL80211_CHAN_WIDTH_20 && | |
3728 | ctx->min_def.width <= NL80211_CHAN_WIDTH_20) | |
3729 | goto out_unlock; | |
3730 | } | |
3731 | ||
4d66449a | 3732 | iwl_mvm_bt_coex_vif_change(mvm); |
dcbc3e1a | 3733 | iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &ctx->min_def, |
8ca151b5 JB |
3734 | ctx->rx_chains_static, |
3735 | ctx->rx_chains_dynamic); | |
7a20bcce EG |
3736 | |
3737 | out_unlock: | |
8ca151b5 JB |
3738 | mutex_unlock(&mvm->mutex); |
3739 | } | |
3740 | ||
b08c1d97 LC |
3741 | static int __iwl_mvm_assign_vif_chanctx(struct iwl_mvm *mvm, |
3742 | struct ieee80211_vif *vif, | |
f0c97783 LC |
3743 | struct ieee80211_chanctx_conf *ctx, |
3744 | bool switching_chanctx) | |
8ca151b5 | 3745 | { |
fe0f2de3 IP |
3746 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
3747 | struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id]; | |
8ca151b5 JB |
3748 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
3749 | int ret; | |
3750 | ||
b08c1d97 | 3751 | lockdep_assert_held(&mvm->mutex); |
8ca151b5 | 3752 | |
fe0f2de3 | 3753 | mvmvif->phy_ctxt = phy_ctxt; |
8ca151b5 JB |
3754 | |
3755 | switch (vif->type) { | |
3756 | case NL80211_IFTYPE_AP: | |
4741dd04 LC |
3757 | /* only needed if we're switching chanctx (i.e. during CSA) */ |
3758 | if (switching_chanctx) { | |
bd3398e2 AO |
3759 | mvmvif->ap_ibss_active = true; |
3760 | break; | |
3761 | } | |
5023d966 | 3762 | case NL80211_IFTYPE_ADHOC: |
8ca151b5 JB |
3763 | /* |
3764 | * The AP binding flow is handled as part of the start_ap flow | |
5023d966 | 3765 | * (in bss_info_changed), similarly for IBSS. |
8ca151b5 JB |
3766 | */ |
3767 | ret = 0; | |
b08c1d97 | 3768 | goto out; |
8ca151b5 | 3769 | case NL80211_IFTYPE_STATION: |
19125cb0 | 3770 | mvmvif->csa_bcn_pending = false; |
2533edce | 3771 | break; |
8ca151b5 | 3772 | case NL80211_IFTYPE_MONITOR: |
2533edce LC |
3773 | /* always disable PS when a monitor interface is active */ |
3774 | mvmvif->ps_disabled = true; | |
8ca151b5 JB |
3775 | break; |
3776 | default: | |
3777 | ret = -EINVAL; | |
b08c1d97 | 3778 | goto out; |
8ca151b5 JB |
3779 | } |
3780 | ||
3781 | ret = iwl_mvm_binding_add_vif(mvm, vif); | |
3782 | if (ret) | |
b08c1d97 | 3783 | goto out; |
8ca151b5 JB |
3784 | |
3785 | /* | |
92d85562 AB |
3786 | * Power state must be updated before quotas, |
3787 | * otherwise fw will complain. | |
3788 | */ | |
999609f1 | 3789 | iwl_mvm_power_update_mac(mvm); |
92d85562 AB |
3790 | |
3791 | /* Setting the quota at this stage is only required for monitor | |
8ca151b5 JB |
3792 | * interfaces. For the other types, the bss_info changed flow |
3793 | * will handle quota settings. | |
3794 | */ | |
3795 | if (vif->type == NL80211_IFTYPE_MONITOR) { | |
1e1391ca | 3796 | mvmvif->monitor_active = true; |
7754ae79 | 3797 | ret = iwl_mvm_update_quotas(mvm, false, NULL); |
8ca151b5 JB |
3798 | if (ret) |
3799 | goto out_remove_binding; | |
0e39eb03 CRI |
3800 | |
3801 | ret = iwl_mvm_add_snif_sta(mvm, vif); | |
3802 | if (ret) | |
3803 | goto out_remove_binding; | |
3804 | ||
8ca151b5 JB |
3805 | } |
3806 | ||
bd3398e2 | 3807 | /* Handle binding during CSA */ |
a57c688d | 3808 | if (vif->type == NL80211_IFTYPE_AP) { |
7754ae79 | 3809 | iwl_mvm_update_quotas(mvm, false, NULL); |
3dfd3a97 | 3810 | iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL); |
bd3398e2 AO |
3811 | } |
3812 | ||
4741dd04 | 3813 | if (switching_chanctx && vif->type == NL80211_IFTYPE_STATION) { |
19125cb0 | 3814 | u32 duration = 3 * vif->bss_conf.beacon_int; |
686e7fe1 LC |
3815 | |
3816 | /* iwl_mvm_protect_session() reads directly from the | |
3817 | * device (the system time), so make sure it is | |
3818 | * available. | |
3819 | */ | |
3820 | ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PROTECT_CSA); | |
3821 | if (ret) | |
3822 | goto out_remove_binding; | |
3823 | ||
3824 | /* Protect the session to make sure we hear the first | |
3825 | * beacon on the new channel. | |
3826 | */ | |
19125cb0 | 3827 | mvmvif->csa_bcn_pending = true; |
686e7fe1 LC |
3828 | iwl_mvm_protect_session(mvm, vif, duration, duration, |
3829 | vif->bss_conf.beacon_int / 2, | |
3830 | true); | |
3831 | ||
3832 | iwl_mvm_unref(mvm, IWL_MVM_REF_PROTECT_CSA); | |
3833 | ||
7754ae79 | 3834 | iwl_mvm_update_quotas(mvm, false, NULL); |
0ce04ce7 LC |
3835 | } |
3836 | ||
b08c1d97 | 3837 | goto out; |
8ca151b5 | 3838 | |
b08c1d97 | 3839 | out_remove_binding: |
8ca151b5 | 3840 | iwl_mvm_binding_remove_vif(mvm, vif); |
999609f1 | 3841 | iwl_mvm_power_update_mac(mvm); |
b08c1d97 | 3842 | out: |
8ca151b5 JB |
3843 | if (ret) |
3844 | mvmvif->phy_ctxt = NULL; | |
3845 | return ret; | |
3846 | } | |
b08c1d97 LC |
3847 | static int iwl_mvm_assign_vif_chanctx(struct ieee80211_hw *hw, |
3848 | struct ieee80211_vif *vif, | |
3849 | struct ieee80211_chanctx_conf *ctx) | |
8ca151b5 JB |
3850 | { |
3851 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
b08c1d97 | 3852 | int ret; |
8ca151b5 JB |
3853 | |
3854 | mutex_lock(&mvm->mutex); | |
f0c97783 | 3855 | ret = __iwl_mvm_assign_vif_chanctx(mvm, vif, ctx, false); |
b08c1d97 LC |
3856 | mutex_unlock(&mvm->mutex); |
3857 | ||
3858 | return ret; | |
3859 | } | |
3860 | ||
3861 | static void __iwl_mvm_unassign_vif_chanctx(struct iwl_mvm *mvm, | |
3862 | struct ieee80211_vif *vif, | |
f0c97783 LC |
3863 | struct ieee80211_chanctx_conf *ctx, |
3864 | bool switching_chanctx) | |
b08c1d97 LC |
3865 | { |
3866 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
f0c97783 | 3867 | struct ieee80211_vif *disabled_vif = NULL; |
b08c1d97 LC |
3868 | |
3869 | lockdep_assert_held(&mvm->mutex); | |
8ca151b5 JB |
3870 | |
3871 | iwl_mvm_remove_time_event(mvm, mvmvif, &mvmvif->time_event_data); | |
3872 | ||
8ca151b5 | 3873 | switch (vif->type) { |
5023d966 | 3874 | case NL80211_IFTYPE_ADHOC: |
b08c1d97 | 3875 | goto out; |
8ca151b5 | 3876 | case NL80211_IFTYPE_MONITOR: |
1e1391ca | 3877 | mvmvif->monitor_active = false; |
2533edce | 3878 | mvmvif->ps_disabled = false; |
0e39eb03 | 3879 | iwl_mvm_rm_snif_sta(mvm, vif); |
8ca151b5 | 3880 | break; |
bd3398e2 AO |
3881 | case NL80211_IFTYPE_AP: |
3882 | /* This part is triggered only during CSA */ | |
4741dd04 | 3883 | if (!switching_chanctx || !mvmvif->ap_ibss_active) |
b08c1d97 | 3884 | goto out; |
bd3398e2 | 3885 | |
7ef0aab6 AO |
3886 | mvmvif->csa_countdown = false; |
3887 | ||
003e5236 AO |
3888 | /* Set CS bit on all the stations */ |
3889 | iwl_mvm_modify_all_sta_disable_tx(mvm, mvmvif, true); | |
3890 | ||
3891 | /* Save blocked iface, the timeout is set on the next beacon */ | |
3892 | rcu_assign_pointer(mvm->csa_tx_blocked_vif, vif); | |
3893 | ||
bd3398e2 | 3894 | mvmvif->ap_ibss_active = false; |
f0c97783 LC |
3895 | break; |
3896 | case NL80211_IFTYPE_STATION: | |
3897 | if (!switching_chanctx) | |
3898 | break; | |
3899 | ||
3900 | disabled_vif = vif; | |
3901 | ||
3dfd3a97 | 3902 | iwl_mvm_mac_ctxt_changed(mvm, vif, true, NULL); |
f0c97783 | 3903 | break; |
8ca151b5 JB |
3904 | default: |
3905 | break; | |
3906 | } | |
3907 | ||
7754ae79 | 3908 | iwl_mvm_update_quotas(mvm, false, disabled_vif); |
1e1391ca | 3909 | iwl_mvm_binding_remove_vif(mvm, vif); |
1c2abf72 | 3910 | |
b08c1d97 | 3911 | out: |
a11e144e | 3912 | mvmvif->phy_ctxt = NULL; |
999609f1 | 3913 | iwl_mvm_power_update_mac(mvm); |
b08c1d97 LC |
3914 | } |
3915 | ||
3916 | static void iwl_mvm_unassign_vif_chanctx(struct ieee80211_hw *hw, | |
3917 | struct ieee80211_vif *vif, | |
3918 | struct ieee80211_chanctx_conf *ctx) | |
3919 | { | |
3920 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
3921 | ||
3922 | mutex_lock(&mvm->mutex); | |
f0c97783 | 3923 | __iwl_mvm_unassign_vif_chanctx(mvm, vif, ctx, false); |
8ca151b5 JB |
3924 | mutex_unlock(&mvm->mutex); |
3925 | } | |
3926 | ||
50cc9574 LC |
3927 | static int |
3928 | iwl_mvm_switch_vif_chanctx_swap(struct iwl_mvm *mvm, | |
3929 | struct ieee80211_vif_chanctx_switch *vifs) | |
b08c1d97 | 3930 | { |
b08c1d97 LC |
3931 | int ret; |
3932 | ||
b08c1d97 | 3933 | mutex_lock(&mvm->mutex); |
f0c97783 | 3934 | __iwl_mvm_unassign_vif_chanctx(mvm, vifs[0].vif, vifs[0].old_ctx, true); |
b08c1d97 LC |
3935 | __iwl_mvm_remove_chanctx(mvm, vifs[0].old_ctx); |
3936 | ||
3937 | ret = __iwl_mvm_add_chanctx(mvm, vifs[0].new_ctx); | |
3938 | if (ret) { | |
3939 | IWL_ERR(mvm, "failed to add new_ctx during channel switch\n"); | |
3940 | goto out_reassign; | |
3941 | } | |
3942 | ||
f0c97783 LC |
3943 | ret = __iwl_mvm_assign_vif_chanctx(mvm, vifs[0].vif, vifs[0].new_ctx, |
3944 | true); | |
b08c1d97 LC |
3945 | if (ret) { |
3946 | IWL_ERR(mvm, | |
3947 | "failed to assign new_ctx during channel switch\n"); | |
3948 | goto out_remove; | |
3949 | } | |
3950 | ||
f697267f AN |
3951 | /* we don't support TDLS during DCM - can be caused by channel switch */ |
3952 | if (iwl_mvm_phy_ctx_count(mvm) > 1) | |
3953 | iwl_mvm_teardown_tdls_peers(mvm); | |
3954 | ||
b08c1d97 LC |
3955 | goto out; |
3956 | ||
3957 | out_remove: | |
3958 | __iwl_mvm_remove_chanctx(mvm, vifs[0].new_ctx); | |
3959 | ||
3960 | out_reassign: | |
6fd1fb63 | 3961 | if (__iwl_mvm_add_chanctx(mvm, vifs[0].old_ctx)) { |
b08c1d97 LC |
3962 | IWL_ERR(mvm, "failed to add old_ctx back after failure.\n"); |
3963 | goto out_restart; | |
3964 | } | |
3965 | ||
6fd1fb63 LC |
3966 | if (__iwl_mvm_assign_vif_chanctx(mvm, vifs[0].vif, vifs[0].old_ctx, |
3967 | true)) { | |
b08c1d97 LC |
3968 | IWL_ERR(mvm, "failed to reassign old_ctx after failure.\n"); |
3969 | goto out_restart; | |
3970 | } | |
3971 | ||
3972 | goto out; | |
3973 | ||
3974 | out_restart: | |
3975 | /* things keep failing, better restart the hw */ | |
3976 | iwl_mvm_nic_restart(mvm, false); | |
3977 | ||
3978 | out: | |
3979 | mutex_unlock(&mvm->mutex); | |
50cc9574 LC |
3980 | |
3981 | return ret; | |
3982 | } | |
3983 | ||
48a256e8 LC |
3984 | static int |
3985 | iwl_mvm_switch_vif_chanctx_reassign(struct iwl_mvm *mvm, | |
3986 | struct ieee80211_vif_chanctx_switch *vifs) | |
3987 | { | |
3988 | int ret; | |
3989 | ||
3990 | mutex_lock(&mvm->mutex); | |
3991 | __iwl_mvm_unassign_vif_chanctx(mvm, vifs[0].vif, vifs[0].old_ctx, true); | |
3992 | ||
3993 | ret = __iwl_mvm_assign_vif_chanctx(mvm, vifs[0].vif, vifs[0].new_ctx, | |
3994 | true); | |
3995 | if (ret) { | |
3996 | IWL_ERR(mvm, | |
3997 | "failed to assign new_ctx during channel switch\n"); | |
3998 | goto out_reassign; | |
3999 | } | |
4000 | ||
4001 | goto out; | |
4002 | ||
4003 | out_reassign: | |
4004 | if (__iwl_mvm_assign_vif_chanctx(mvm, vifs[0].vif, vifs[0].old_ctx, | |
4005 | true)) { | |
4006 | IWL_ERR(mvm, "failed to reassign old_ctx after failure.\n"); | |
4007 | goto out_restart; | |
4008 | } | |
4009 | ||
4010 | goto out; | |
4011 | ||
4012 | out_restart: | |
4013 | /* things keep failing, better restart the hw */ | |
4014 | iwl_mvm_nic_restart(mvm, false); | |
4015 | ||
4016 | out: | |
4017 | mutex_unlock(&mvm->mutex); | |
4018 | ||
4019 | return ret; | |
4020 | } | |
4021 | ||
50cc9574 LC |
4022 | static int iwl_mvm_switch_vif_chanctx(struct ieee80211_hw *hw, |
4023 | struct ieee80211_vif_chanctx_switch *vifs, | |
4024 | int n_vifs, | |
4025 | enum ieee80211_chanctx_switch_mode mode) | |
4026 | { | |
4027 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
4028 | int ret; | |
4029 | ||
4030 | /* we only support a single-vif right now */ | |
4031 | if (n_vifs > 1) | |
4032 | return -EOPNOTSUPP; | |
4033 | ||
4034 | switch (mode) { | |
4035 | case CHANCTX_SWMODE_SWAP_CONTEXTS: | |
4036 | ret = iwl_mvm_switch_vif_chanctx_swap(mvm, vifs); | |
4037 | break; | |
4038 | case CHANCTX_SWMODE_REASSIGN_VIF: | |
48a256e8 | 4039 | ret = iwl_mvm_switch_vif_chanctx_reassign(mvm, vifs); |
50cc9574 LC |
4040 | break; |
4041 | default: | |
4042 | ret = -EOPNOTSUPP; | |
4043 | break; | |
4044 | } | |
4045 | ||
b08c1d97 LC |
4046 | return ret; |
4047 | } | |
4048 | ||
2f0282db JB |
4049 | static int iwl_mvm_tx_last_beacon(struct ieee80211_hw *hw) |
4050 | { | |
4051 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
4052 | ||
4053 | return mvm->ibss_manager; | |
4054 | } | |
4055 | ||
8ca151b5 JB |
4056 | static int iwl_mvm_set_tim(struct ieee80211_hw *hw, |
4057 | struct ieee80211_sta *sta, | |
4058 | bool set) | |
4059 | { | |
4060 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
9d8ce6af | 4061 | struct iwl_mvm_sta *mvm_sta = iwl_mvm_sta_from_mac80211(sta); |
8ca151b5 JB |
4062 | |
4063 | if (!mvm_sta || !mvm_sta->vif) { | |
4064 | IWL_ERR(mvm, "Station is not associated to a vif\n"); | |
4065 | return -EINVAL; | |
4066 | } | |
4067 | ||
4068 | return iwl_mvm_mac_ctxt_beacon_changed(mvm, mvm_sta->vif); | |
4069 | } | |
4070 | ||
507cadf2 DS |
4071 | #ifdef CONFIG_NL80211_TESTMODE |
4072 | static const struct nla_policy iwl_mvm_tm_policy[IWL_MVM_TM_ATTR_MAX + 1] = { | |
4073 | [IWL_MVM_TM_ATTR_CMD] = { .type = NLA_U32 }, | |
4074 | [IWL_MVM_TM_ATTR_NOA_DURATION] = { .type = NLA_U32 }, | |
f6c6ad42 | 4075 | [IWL_MVM_TM_ATTR_BEACON_FILTER_STATE] = { .type = NLA_U32 }, |
507cadf2 DS |
4076 | }; |
4077 | ||
4078 | static int __iwl_mvm_mac_testmode_cmd(struct iwl_mvm *mvm, | |
4079 | struct ieee80211_vif *vif, | |
4080 | void *data, int len) | |
4081 | { | |
4082 | struct nlattr *tb[IWL_MVM_TM_ATTR_MAX + 1]; | |
4083 | int err; | |
4084 | u32 noa_duration; | |
4085 | ||
fceb6435 JB |
4086 | err = nla_parse(tb, IWL_MVM_TM_ATTR_MAX, data, len, iwl_mvm_tm_policy, |
4087 | NULL); | |
507cadf2 DS |
4088 | if (err) |
4089 | return err; | |
4090 | ||
4091 | if (!tb[IWL_MVM_TM_ATTR_CMD]) | |
4092 | return -EINVAL; | |
4093 | ||
4094 | switch (nla_get_u32(tb[IWL_MVM_TM_ATTR_CMD])) { | |
4095 | case IWL_MVM_TM_CMD_SET_NOA: | |
4096 | if (!vif || vif->type != NL80211_IFTYPE_AP || !vif->p2p || | |
4097 | !vif->bss_conf.enable_beacon || | |
4098 | !tb[IWL_MVM_TM_ATTR_NOA_DURATION]) | |
4099 | return -EINVAL; | |
4100 | ||
4101 | noa_duration = nla_get_u32(tb[IWL_MVM_TM_ATTR_NOA_DURATION]); | |
4102 | if (noa_duration >= vif->bss_conf.beacon_int) | |
4103 | return -EINVAL; | |
4104 | ||
4105 | mvm->noa_duration = noa_duration; | |
4106 | mvm->noa_vif = vif; | |
4107 | ||
22b21041 | 4108 | return iwl_mvm_update_quotas(mvm, true, NULL); |
f6c6ad42 JB |
4109 | case IWL_MVM_TM_CMD_SET_BEACON_FILTER: |
4110 | /* must be associated client vif - ignore authorized */ | |
4111 | if (!vif || vif->type != NL80211_IFTYPE_STATION || | |
4112 | !vif->bss_conf.assoc || !vif->bss_conf.dtim_period || | |
4113 | !tb[IWL_MVM_TM_ATTR_BEACON_FILTER_STATE]) | |
4114 | return -EINVAL; | |
4115 | ||
4116 | if (nla_get_u32(tb[IWL_MVM_TM_ATTR_BEACON_FILTER_STATE])) | |
a1022927 EG |
4117 | return iwl_mvm_enable_beacon_filter(mvm, vif, 0); |
4118 | return iwl_mvm_disable_beacon_filter(mvm, vif, 0); | |
507cadf2 DS |
4119 | } |
4120 | ||
4121 | return -EOPNOTSUPP; | |
4122 | } | |
4123 | ||
4124 | static int iwl_mvm_mac_testmode_cmd(struct ieee80211_hw *hw, | |
4125 | struct ieee80211_vif *vif, | |
4126 | void *data, int len) | |
4127 | { | |
4128 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
4129 | int err; | |
4130 | ||
4131 | mutex_lock(&mvm->mutex); | |
4132 | err = __iwl_mvm_mac_testmode_cmd(mvm, vif, data, len); | |
4133 | mutex_unlock(&mvm->mutex); | |
4134 | ||
4135 | return err; | |
4136 | } | |
4137 | #endif | |
4138 | ||
622e3f9b LC |
4139 | static void iwl_mvm_channel_switch(struct ieee80211_hw *hw, |
4140 | struct ieee80211_vif *vif, | |
4141 | struct ieee80211_channel_switch *chsw) | |
4142 | { | |
4143 | /* By implementing this operation, we prevent mac80211 from | |
4144 | * starting its own channel switch timer, so that we can call | |
4145 | * ieee80211_chswitch_done() ourselves at the right time | |
4146 | * (which is when the absence time event starts). | |
4147 | */ | |
4148 | ||
4149 | IWL_DEBUG_MAC80211(IWL_MAC80211_GET_MVM(hw), | |
4150 | "dummy channel switch op\n"); | |
4151 | } | |
4152 | ||
f028905c LC |
4153 | static int iwl_mvm_pre_channel_switch(struct ieee80211_hw *hw, |
4154 | struct ieee80211_vif *vif, | |
4155 | struct ieee80211_channel_switch *chsw) | |
bd3398e2 AO |
4156 | { |
4157 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
664322fa | 4158 | struct ieee80211_vif *csa_vif; |
f6c34820 | 4159 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
dc88b4ba | 4160 | u32 apply_time; |
f028905c | 4161 | int ret; |
bd3398e2 AO |
4162 | |
4163 | mutex_lock(&mvm->mutex); | |
664322fa | 4164 | |
81d62d5a JB |
4165 | mvmvif->csa_failed = false; |
4166 | ||
6b20d774 | 4167 | IWL_DEBUG_MAC80211(mvm, "pre CSA to freq %d\n", |
f028905c | 4168 | chsw->chandef.center_freq1); |
6b20d774 | 4169 | |
7174beb6 JB |
4170 | iwl_fw_dbg_trigger_simple_stop(&mvm->fwrt, |
4171 | ieee80211_vif_to_wdev(vif), | |
4172 | FW_DBG_TRIGGER_CHANNEL_SWITCH); | |
f35d9c55 | 4173 | |
6b20d774 LC |
4174 | switch (vif->type) { |
4175 | case NL80211_IFTYPE_AP: | |
4176 | csa_vif = | |
4177 | rcu_dereference_protected(mvm->csa_vif, | |
4178 | lockdep_is_held(&mvm->mutex)); | |
4179 | if (WARN_ONCE(csa_vif && csa_vif->csa_active, | |
4180 | "Another CSA is already in progress")) { | |
4181 | ret = -EBUSY; | |
4182 | goto out_unlock; | |
4183 | } | |
4184 | ||
d3a108a4 AO |
4185 | /* we still didn't unblock tx. prevent new CS meanwhile */ |
4186 | if (rcu_dereference_protected(mvm->csa_tx_blocked_vif, | |
4187 | lockdep_is_held(&mvm->mutex))) { | |
4188 | ret = -EBUSY; | |
4189 | goto out_unlock; | |
4190 | } | |
4191 | ||
6b20d774 | 4192 | rcu_assign_pointer(mvm->csa_vif, vif); |
7ef0aab6 | 4193 | |
7ef0aab6 AO |
4194 | if (WARN_ONCE(mvmvif->csa_countdown, |
4195 | "Previous CSA countdown didn't complete")) { | |
4196 | ret = -EBUSY; | |
4197 | goto out_unlock; | |
4198 | } | |
4199 | ||
d3a108a4 AO |
4200 | mvmvif->csa_target_freq = chsw->chandef.chan->center_freq; |
4201 | ||
6b20d774 | 4202 | break; |
dc88b4ba | 4203 | case NL80211_IFTYPE_STATION: |
4500e133 LC |
4204 | /* Schedule the time event to a bit before beacon 1, |
4205 | * to make sure we're in the new channel when the | |
f5d8f50f IP |
4206 | * GO/AP arrives. In case count <= 1 immediately schedule the |
4207 | * TE (this might result with some packet loss or connection | |
4208 | * loss). | |
4500e133 | 4209 | */ |
f5d8f50f IP |
4210 | if (chsw->count <= 1) |
4211 | apply_time = 0; | |
4212 | else | |
4213 | apply_time = chsw->device_timestamp + | |
4214 | ((vif->bss_conf.beacon_int * (chsw->count - 1) - | |
4215 | IWL_MVM_CHANNEL_SWITCH_TIME_CLIENT) * 1024); | |
dc88b4ba LC |
4216 | |
4217 | if (chsw->block_tx) | |
4218 | iwl_mvm_csa_client_absent(mvm, vif); | |
4219 | ||
4500e133 | 4220 | iwl_mvm_schedule_csa_period(mvm, vif, vif->bss_conf.beacon_int, |
dc88b4ba | 4221 | apply_time); |
c6e0a3e0 LC |
4222 | if (mvmvif->bf_data.bf_enabled) { |
4223 | ret = iwl_mvm_disable_beacon_filter(mvm, vif, 0); | |
4224 | if (ret) | |
4225 | goto out_unlock; | |
4226 | } | |
4227 | ||
dc88b4ba | 4228 | break; |
6b20d774 LC |
4229 | default: |
4230 | break; | |
4231 | } | |
bd3398e2 | 4232 | |
f6c34820 LC |
4233 | mvmvif->ps_disabled = true; |
4234 | ||
4235 | ret = iwl_mvm_power_update_ps(mvm); | |
4236 | if (ret) | |
4237 | goto out_unlock; | |
f028905c | 4238 | |
e198f5e7 AN |
4239 | /* we won't be on this channel any longer */ |
4240 | iwl_mvm_teardown_tdls_peers(mvm); | |
4241 | ||
bd3398e2 AO |
4242 | out_unlock: |
4243 | mutex_unlock(&mvm->mutex); | |
f028905c LC |
4244 | |
4245 | return ret; | |
bd3398e2 AO |
4246 | } |
4247 | ||
f6c34820 LC |
4248 | static int iwl_mvm_post_channel_switch(struct ieee80211_hw *hw, |
4249 | struct ieee80211_vif *vif) | |
4250 | { | |
4251 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
4252 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
4253 | int ret; | |
4254 | ||
4255 | mutex_lock(&mvm->mutex); | |
4256 | ||
81d62d5a JB |
4257 | if (mvmvif->csa_failed) { |
4258 | mvmvif->csa_failed = false; | |
4259 | ret = -EIO; | |
4260 | goto out_unlock; | |
4261 | } | |
4262 | ||
a57c688d LC |
4263 | if (vif->type == NL80211_IFTYPE_STATION) { |
4264 | struct iwl_mvm_sta *mvmsta; | |
4265 | ||
19125cb0 | 4266 | mvmvif->csa_bcn_pending = false; |
a57c688d LC |
4267 | mvmsta = iwl_mvm_sta_from_staid_protected(mvm, |
4268 | mvmvif->ap_sta_id); | |
4269 | ||
4270 | if (WARN_ON(!mvmsta)) { | |
4271 | ret = -EIO; | |
4272 | goto out_unlock; | |
4273 | } | |
4274 | ||
4275 | iwl_mvm_sta_modify_disable_tx(mvm, mvmsta, false); | |
4276 | ||
4277 | iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL); | |
c6e0a3e0 LC |
4278 | |
4279 | ret = iwl_mvm_enable_beacon_filter(mvm, vif, 0); | |
4280 | if (ret) | |
4281 | goto out_unlock; | |
686e7fe1 LC |
4282 | |
4283 | iwl_mvm_stop_session_protection(mvm, vif); | |
a57c688d LC |
4284 | } |
4285 | ||
f6c34820 LC |
4286 | mvmvif->ps_disabled = false; |
4287 | ||
4288 | ret = iwl_mvm_power_update_ps(mvm); | |
4289 | ||
a57c688d | 4290 | out_unlock: |
f6c34820 LC |
4291 | mutex_unlock(&mvm->mutex); |
4292 | ||
4293 | return ret; | |
4294 | } | |
4295 | ||
6110d9e5 DS |
4296 | static void iwl_mvm_flush_no_vif(struct iwl_mvm *mvm, u32 queues, bool drop) |
4297 | { | |
435d0827 SS |
4298 | int i; |
4299 | ||
06195639 | 4300 | if (!iwl_mvm_has_new_tx_api(mvm)) { |
309c4848 LC |
4301 | if (drop) { |
4302 | mutex_lock(&mvm->mutex); | |
6110d9e5 | 4303 | iwl_mvm_flush_tx_path(mvm, |
435d0827 | 4304 | iwl_mvm_flushable_queues(mvm) & queues, 0); |
309c4848 LC |
4305 | mutex_unlock(&mvm->mutex); |
4306 | } else { | |
06195639 | 4307 | iwl_trans_wait_tx_queues_empty(mvm->trans, queues); |
309c4848 | 4308 | } |
435d0827 SS |
4309 | return; |
4310 | } | |
6110d9e5 | 4311 | |
435d0827 SS |
4312 | mutex_lock(&mvm->mutex); |
4313 | for (i = 0; i < ARRAY_SIZE(mvm->fw_id_to_mac_id); i++) { | |
4314 | struct ieee80211_sta *sta; | |
6110d9e5 | 4315 | |
435d0827 SS |
4316 | sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i], |
4317 | lockdep_is_held(&mvm->mutex)); | |
4318 | if (IS_ERR_OR_NULL(sta)) | |
4319 | continue; | |
6110d9e5 | 4320 | |
06195639 SS |
4321 | if (drop) |
4322 | iwl_mvm_flush_sta_tids(mvm, i, 0xFF, 0); | |
4323 | else | |
4324 | iwl_mvm_wait_sta_queues_empty(mvm, | |
4325 | iwl_mvm_sta_from_mac80211(sta)); | |
6110d9e5 | 4326 | } |
435d0827 | 4327 | mutex_unlock(&mvm->mutex); |
6110d9e5 DS |
4328 | } |
4329 | ||
c5b0e7c0 EG |
4330 | static void iwl_mvm_mac_flush(struct ieee80211_hw *hw, |
4331 | struct ieee80211_vif *vif, u32 queues, bool drop) | |
4332 | { | |
4333 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
4334 | struct iwl_mvm_vif *mvmvif; | |
4335 | struct iwl_mvm_sta *mvmsta; | |
a0f6bf2a AN |
4336 | struct ieee80211_sta *sta; |
4337 | int i; | |
4338 | u32 msk = 0; | |
c5b0e7c0 | 4339 | |
6110d9e5 DS |
4340 | if (!vif) { |
4341 | iwl_mvm_flush_no_vif(mvm, queues, drop); | |
4342 | return; | |
4343 | } | |
4344 | ||
4345 | if (vif->type != NL80211_IFTYPE_STATION) | |
c5b0e7c0 EG |
4346 | return; |
4347 | ||
24afba76 | 4348 | /* Make sure we're done with the deferred traffic before flushing */ |
c8f54701 | 4349 | flush_work(&mvm->add_stream_wk); |
24afba76 | 4350 | |
c5b0e7c0 EG |
4351 | mutex_lock(&mvm->mutex); |
4352 | mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
c5b0e7c0 | 4353 | |
a0f6bf2a | 4354 | /* flush the AP-station and all TDLS peers */ |
0ae98812 | 4355 | for (i = 0; i < ARRAY_SIZE(mvm->fw_id_to_mac_id); i++) { |
a0f6bf2a AN |
4356 | sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i], |
4357 | lockdep_is_held(&mvm->mutex)); | |
4358 | if (IS_ERR_OR_NULL(sta)) | |
4359 | continue; | |
4360 | ||
4361 | mvmsta = iwl_mvm_sta_from_mac80211(sta); | |
4362 | if (mvmsta->vif != vif) | |
4363 | continue; | |
4364 | ||
4365 | /* make sure only TDLS peers or the AP are flushed */ | |
4366 | WARN_ON(i != mvmvif->ap_sta_id && !sta->tdls); | |
4367 | ||
d49394a1 SS |
4368 | if (drop) { |
4369 | if (iwl_mvm_flush_sta(mvm, mvmsta, false, 0)) | |
4370 | IWL_ERR(mvm, "flush request fail\n"); | |
4371 | } else { | |
4372 | msk |= mvmsta->tfd_queue_msk; | |
d6d517b7 SS |
4373 | if (iwl_mvm_has_new_tx_api(mvm)) |
4374 | iwl_mvm_wait_sta_queues_empty(mvm, mvmsta); | |
d49394a1 | 4375 | } |
480acbce | 4376 | } |
c5b0e7c0 | 4377 | |
d49394a1 | 4378 | mutex_unlock(&mvm->mutex); |
4e6c48e0 | 4379 | |
d49394a1 SS |
4380 | /* this can take a while, and we may need/want other operations |
4381 | * to succeed while doing this, so do it without the mutex held | |
4382 | */ | |
d6d517b7 | 4383 | if (!drop && !iwl_mvm_has_new_tx_api(mvm)) |
a1a57877 | 4384 | iwl_trans_wait_tx_queues_empty(mvm->trans, msk); |
c5b0e7c0 EG |
4385 | } |
4386 | ||
91a8bcde JB |
4387 | static int iwl_mvm_mac_get_survey(struct ieee80211_hw *hw, int idx, |
4388 | struct survey_info *survey) | |
4389 | { | |
4390 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
4391 | int ret; | |
4392 | ||
4393 | memset(survey, 0, sizeof(*survey)); | |
4394 | ||
4395 | /* only support global statistics right now */ | |
4396 | if (idx != 0) | |
4397 | return -ENOENT; | |
4398 | ||
280a3efa JB |
4399 | if (!fw_has_capa(&mvm->fw->ucode_capa, |
4400 | IWL_UCODE_TLV_CAPA_RADIO_BEACON_STATS)) | |
91a8bcde JB |
4401 | return -ENOENT; |
4402 | ||
4403 | mutex_lock(&mvm->mutex); | |
4404 | ||
aab6930d | 4405 | if (iwl_mvm_firmware_running(mvm)) { |
33cef925 | 4406 | ret = iwl_mvm_request_statistics(mvm, false); |
91a8bcde JB |
4407 | if (ret) |
4408 | goto out; | |
4409 | } | |
4410 | ||
4411 | survey->filled = SURVEY_INFO_TIME | | |
4412 | SURVEY_INFO_TIME_RX | | |
4413 | SURVEY_INFO_TIME_TX | | |
4414 | SURVEY_INFO_TIME_SCAN; | |
4415 | survey->time = mvm->accu_radio_stats.on_time_rf + | |
4416 | mvm->radio_stats.on_time_rf; | |
4417 | do_div(survey->time, USEC_PER_MSEC); | |
4418 | ||
4419 | survey->time_rx = mvm->accu_radio_stats.rx_time + | |
4420 | mvm->radio_stats.rx_time; | |
4421 | do_div(survey->time_rx, USEC_PER_MSEC); | |
4422 | ||
4423 | survey->time_tx = mvm->accu_radio_stats.tx_time + | |
4424 | mvm->radio_stats.tx_time; | |
4425 | do_div(survey->time_tx, USEC_PER_MSEC); | |
4426 | ||
4427 | survey->time_scan = mvm->accu_radio_stats.on_time_scan + | |
4428 | mvm->radio_stats.on_time_scan; | |
4429 | do_div(survey->time_scan, USEC_PER_MSEC); | |
4430 | ||
10a7c028 | 4431 | ret = 0; |
91a8bcde JB |
4432 | out: |
4433 | mutex_unlock(&mvm->mutex); | |
4434 | return ret; | |
4435 | } | |
4436 | ||
33cef925 JB |
4437 | static void iwl_mvm_mac_sta_statistics(struct ieee80211_hw *hw, |
4438 | struct ieee80211_vif *vif, | |
4439 | struct ieee80211_sta *sta, | |
4440 | struct station_info *sinfo) | |
4441 | { | |
4442 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
4443 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
4444 | struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); | |
4445 | ||
988b5968 SS |
4446 | if (mvmsta->avg_energy) { |
4447 | sinfo->signal_avg = mvmsta->avg_energy; | |
22d0d2fa | 4448 | sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG); |
988b5968 SS |
4449 | } |
4450 | ||
33cef925 JB |
4451 | /* if beacon filtering isn't on mac80211 does it anyway */ |
4452 | if (!(vif->driver_flags & IEEE80211_VIF_BEACON_FILTER)) | |
4453 | return; | |
4454 | ||
4455 | if (!vif->bss_conf.assoc) | |
4456 | return; | |
4457 | ||
4458 | mutex_lock(&mvm->mutex); | |
4459 | ||
4460 | if (mvmvif->ap_sta_id != mvmsta->sta_id) | |
4461 | goto unlock; | |
4462 | ||
4463 | if (iwl_mvm_request_statistics(mvm, false)) | |
4464 | goto unlock; | |
4465 | ||
4466 | sinfo->rx_beacon = mvmvif->beacon_stats.num_beacons + | |
4467 | mvmvif->beacon_stats.accu_num_beacons; | |
22d0d2fa | 4468 | sinfo->filled |= BIT_ULL(NL80211_STA_INFO_BEACON_RX); |
33cef925 JB |
4469 | if (mvmvif->beacon_stats.avg_signal) { |
4470 | /* firmware only reports a value after RXing a few beacons */ | |
4471 | sinfo->rx_beacon_signal_avg = mvmvif->beacon_stats.avg_signal; | |
22d0d2fa | 4472 | sinfo->filled |= BIT_ULL(NL80211_STA_INFO_BEACON_SIGNAL_AVG); |
33cef925 JB |
4473 | } |
4474 | unlock: | |
4475 | mutex_unlock(&mvm->mutex); | |
4476 | } | |
4477 | ||
4203263d EG |
4478 | static void iwl_mvm_event_mlme_callback(struct iwl_mvm *mvm, |
4479 | struct ieee80211_vif *vif, | |
4480 | const struct ieee80211_event *event) | |
d42f5350 | 4481 | { |
7174beb6 JB |
4482 | #define CHECK_MLME_TRIGGER(_cnt, _fmt...) \ |
4483 | do { \ | |
4484 | if ((trig_mlme->_cnt) && --(trig_mlme->_cnt)) \ | |
4485 | break; \ | |
4486 | iwl_fw_dbg_collect_trig(&(mvm)->fwrt, trig, _fmt); \ | |
d42f5350 EG |
4487 | } while (0) |
4488 | ||
d42f5350 EG |
4489 | struct iwl_fw_dbg_trigger_tlv *trig; |
4490 | struct iwl_fw_dbg_trigger_mlme *trig_mlme; | |
d42f5350 | 4491 | |
6c042d75 SS |
4492 | trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif), |
4493 | FW_DBG_TRIGGER_MLME); | |
4494 | if (!trig) | |
d42f5350 EG |
4495 | return; |
4496 | ||
d42f5350 | 4497 | trig_mlme = (void *)trig->data; |
d42f5350 | 4498 | |
d42f5350 EG |
4499 | if (event->u.mlme.data == ASSOC_EVENT) { |
4500 | if (event->u.mlme.status == MLME_DENIED) | |
4c324a51 | 4501 | CHECK_MLME_TRIGGER(stop_assoc_denied, |
d42f5350 EG |
4502 | "DENIED ASSOC: reason %d", |
4503 | event->u.mlme.reason); | |
4504 | else if (event->u.mlme.status == MLME_TIMEOUT) | |
4c324a51 | 4505 | CHECK_MLME_TRIGGER(stop_assoc_timeout, |
d42f5350 EG |
4506 | "ASSOC TIMEOUT"); |
4507 | } else if (event->u.mlme.data == AUTH_EVENT) { | |
4508 | if (event->u.mlme.status == MLME_DENIED) | |
4c324a51 | 4509 | CHECK_MLME_TRIGGER(stop_auth_denied, |
d42f5350 EG |
4510 | "DENIED AUTH: reason %d", |
4511 | event->u.mlme.reason); | |
4512 | else if (event->u.mlme.status == MLME_TIMEOUT) | |
4c324a51 | 4513 | CHECK_MLME_TRIGGER(stop_auth_timeout, |
d42f5350 EG |
4514 | "AUTH TIMEOUT"); |
4515 | } else if (event->u.mlme.data == DEAUTH_RX_EVENT) { | |
4c324a51 | 4516 | CHECK_MLME_TRIGGER(stop_rx_deauth, |
d42f5350 EG |
4517 | "DEAUTH RX %d", event->u.mlme.reason); |
4518 | } else if (event->u.mlme.data == DEAUTH_TX_EVENT) { | |
4c324a51 | 4519 | CHECK_MLME_TRIGGER(stop_tx_deauth, |
d42f5350 EG |
4520 | "DEAUTH TX %d", event->u.mlme.reason); |
4521 | } | |
4522 | #undef CHECK_MLME_TRIGGER | |
4523 | } | |
4524 | ||
4203263d EG |
4525 | static void iwl_mvm_event_bar_rx_callback(struct iwl_mvm *mvm, |
4526 | struct ieee80211_vif *vif, | |
4527 | const struct ieee80211_event *event) | |
4528 | { | |
4529 | struct iwl_fw_dbg_trigger_tlv *trig; | |
4530 | struct iwl_fw_dbg_trigger_ba *ba_trig; | |
4531 | ||
6c042d75 SS |
4532 | trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif), |
4533 | FW_DBG_TRIGGER_BA); | |
4534 | if (!trig) | |
4203263d EG |
4535 | return; |
4536 | ||
4203263d | 4537 | ba_trig = (void *)trig->data; |
4203263d EG |
4538 | |
4539 | if (!(le16_to_cpu(ba_trig->rx_bar) & BIT(event->u.ba.tid))) | |
4540 | return; | |
4541 | ||
7174beb6 JB |
4542 | iwl_fw_dbg_collect_trig(&mvm->fwrt, trig, |
4543 | "BAR received from %pM, tid %d, ssn %d", | |
4544 | event->u.ba.sta->addr, event->u.ba.tid, | |
4545 | event->u.ba.ssn); | |
4203263d EG |
4546 | } |
4547 | ||
4203263d EG |
4548 | static void iwl_mvm_mac_event_callback(struct ieee80211_hw *hw, |
4549 | struct ieee80211_vif *vif, | |
4550 | const struct ieee80211_event *event) | |
4551 | { | |
4552 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
4553 | ||
4554 | switch (event->type) { | |
4555 | case MLME_EVENT: | |
4556 | iwl_mvm_event_mlme_callback(mvm, vif, event); | |
4557 | break; | |
4558 | case BAR_RX_EVENT: | |
4559 | iwl_mvm_event_bar_rx_callback(mvm, vif, event); | |
4560 | break; | |
4561 | case BA_FRAME_TIMEOUT: | |
528a542a EG |
4562 | iwl_mvm_event_frame_timeout_callback(mvm, vif, event->u.ba.sta, |
4563 | event->u.ba.tid); | |
4203263d EG |
4564 | break; |
4565 | default: | |
4566 | break; | |
4567 | } | |
4568 | } | |
4569 | ||
d0ff5d22 SS |
4570 | void iwl_mvm_sync_rx_queues_internal(struct iwl_mvm *mvm, |
4571 | struct iwl_mvm_internal_rxq_notif *notif, | |
4572 | u32 size) | |
0636b938 | 4573 | { |
0636b938 SS |
4574 | u32 qmask = BIT(mvm->trans->num_rx_queues) - 1; |
4575 | int ret; | |
4576 | ||
4577 | lockdep_assert_held(&mvm->mutex); | |
4578 | ||
cb8550e1 | 4579 | if (!iwl_mvm_has_new_rx_api(mvm)) |
0636b938 SS |
4580 | return; |
4581 | ||
d0ff5d22 SS |
4582 | notif->cookie = mvm->queue_sync_cookie; |
4583 | ||
4584 | if (notif->sync) | |
4585 | atomic_set(&mvm->queue_sync_counter, | |
4586 | mvm->trans->num_rx_queues); | |
0636b938 | 4587 | |
d0ff5d22 | 4588 | ret = iwl_mvm_notify_rx_queue(mvm, qmask, (u8 *)notif, size); |
0636b938 SS |
4589 | if (ret) { |
4590 | IWL_ERR(mvm, "Failed to trigger RX queues sync (%d)\n", ret); | |
4591 | goto out; | |
4592 | } | |
d0ff5d22 | 4593 | |
6ad04359 | 4594 | if (notif->sync) { |
3a732c65 | 4595 | ret = wait_event_timeout(mvm->rx_sync_waitq, |
6ad04359 JB |
4596 | atomic_read(&mvm->queue_sync_counter) == 0 || |
4597 | iwl_mvm_is_radio_killed(mvm), | |
d0ff5d22 | 4598 | HZ); |
6ad04359 JB |
4599 | WARN_ON_ONCE(!ret && !iwl_mvm_is_radio_killed(mvm)); |
4600 | } | |
0636b938 SS |
4601 | |
4602 | out: | |
4603 | atomic_set(&mvm->queue_sync_counter, 0); | |
4604 | mvm->queue_sync_cookie++; | |
4605 | } | |
4606 | ||
4607 | static void iwl_mvm_sync_rx_queues(struct ieee80211_hw *hw) | |
4608 | { | |
4609 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
d0ff5d22 SS |
4610 | struct iwl_mvm_internal_rxq_notif data = { |
4611 | .type = IWL_MVM_RXQ_EMPTY, | |
4612 | .sync = 1, | |
4613 | }; | |
0636b938 SS |
4614 | |
4615 | mutex_lock(&mvm->mutex); | |
d0ff5d22 | 4616 | iwl_mvm_sync_rx_queues_internal(mvm, &data, sizeof(data)); |
0636b938 SS |
4617 | mutex_unlock(&mvm->mutex); |
4618 | } | |
4619 | ||
e5209263 | 4620 | const struct ieee80211_ops iwl_mvm_hw_ops = { |
8ca151b5 JB |
4621 | .tx = iwl_mvm_mac_tx, |
4622 | .ampdu_action = iwl_mvm_mac_ampdu_action, | |
4623 | .start = iwl_mvm_mac_start, | |
cf2c92d8 | 4624 | .reconfig_complete = iwl_mvm_mac_reconfig_complete, |
8ca151b5 JB |
4625 | .stop = iwl_mvm_mac_stop, |
4626 | .add_interface = iwl_mvm_mac_add_interface, | |
4627 | .remove_interface = iwl_mvm_mac_remove_interface, | |
4628 | .config = iwl_mvm_mac_config, | |
e59647ea | 4629 | .prepare_multicast = iwl_mvm_prepare_multicast, |
8ca151b5 | 4630 | .configure_filter = iwl_mvm_configure_filter, |
effd1929 | 4631 | .config_iface_filter = iwl_mvm_config_iface_filter, |
8ca151b5 JB |
4632 | .bss_info_changed = iwl_mvm_bss_info_changed, |
4633 | .hw_scan = iwl_mvm_mac_hw_scan, | |
4634 | .cancel_hw_scan = iwl_mvm_mac_cancel_hw_scan, | |
1ddbbb0c | 4635 | .sta_pre_rcu_remove = iwl_mvm_sta_pre_rcu_remove, |
8ca151b5 JB |
4636 | .sta_state = iwl_mvm_mac_sta_state, |
4637 | .sta_notify = iwl_mvm_mac_sta_notify, | |
4638 | .allow_buffered_frames = iwl_mvm_mac_allow_buffered_frames, | |
3e56eadf | 4639 | .release_buffered_frames = iwl_mvm_mac_release_buffered_frames, |
8ca151b5 | 4640 | .set_rts_threshold = iwl_mvm_mac_set_rts_threshold, |
1f3b0ff8 | 4641 | .sta_rc_update = iwl_mvm_sta_rc_update, |
8ca151b5 JB |
4642 | .conf_tx = iwl_mvm_mac_conf_tx, |
4643 | .mgd_prepare_tx = iwl_mvm_mac_mgd_prepare_tx, | |
07ecd897 | 4644 | .mgd_protect_tdls_discover = iwl_mvm_mac_mgd_protect_tdls_discover, |
c5b0e7c0 | 4645 | .flush = iwl_mvm_mac_flush, |
35a000b7 DS |
4646 | .sched_scan_start = iwl_mvm_mac_sched_scan_start, |
4647 | .sched_scan_stop = iwl_mvm_mac_sched_scan_stop, | |
8ca151b5 JB |
4648 | .set_key = iwl_mvm_mac_set_key, |
4649 | .update_tkip_key = iwl_mvm_mac_update_tkip_key, | |
4650 | .remain_on_channel = iwl_mvm_roc, | |
4651 | .cancel_remain_on_channel = iwl_mvm_cancel_roc, | |
8ca151b5 JB |
4652 | .add_chanctx = iwl_mvm_add_chanctx, |
4653 | .remove_chanctx = iwl_mvm_remove_chanctx, | |
4654 | .change_chanctx = iwl_mvm_change_chanctx, | |
4655 | .assign_vif_chanctx = iwl_mvm_assign_vif_chanctx, | |
4656 | .unassign_vif_chanctx = iwl_mvm_unassign_vif_chanctx, | |
b08c1d97 | 4657 | .switch_vif_chanctx = iwl_mvm_switch_vif_chanctx, |
8ca151b5 | 4658 | |
5023d966 JB |
4659 | .start_ap = iwl_mvm_start_ap_ibss, |
4660 | .stop_ap = iwl_mvm_stop_ap_ibss, | |
4661 | .join_ibss = iwl_mvm_start_ap_ibss, | |
4662 | .leave_ibss = iwl_mvm_stop_ap_ibss, | |
8ca151b5 | 4663 | |
2f0282db JB |
4664 | .tx_last_beacon = iwl_mvm_tx_last_beacon, |
4665 | ||
8ca151b5 JB |
4666 | .set_tim = iwl_mvm_set_tim, |
4667 | ||
622e3f9b | 4668 | .channel_switch = iwl_mvm_channel_switch, |
f028905c | 4669 | .pre_channel_switch = iwl_mvm_pre_channel_switch, |
f6c34820 | 4670 | .post_channel_switch = iwl_mvm_post_channel_switch, |
bd3398e2 | 4671 | |
1d3c3f63 AN |
4672 | .tdls_channel_switch = iwl_mvm_tdls_channel_switch, |
4673 | .tdls_cancel_channel_switch = iwl_mvm_tdls_cancel_channel_switch, | |
4674 | .tdls_recv_channel_switch = iwl_mvm_tdls_recv_channel_switch, | |
4675 | ||
d42f5350 EG |
4676 | .event_callback = iwl_mvm_mac_event_callback, |
4677 | ||
0636b938 SS |
4678 | .sync_rx_queues = iwl_mvm_sync_rx_queues, |
4679 | ||
507cadf2 DS |
4680 | CFG80211_TESTMODE_CMD(iwl_mvm_mac_testmode_cmd) |
4681 | ||
8ca151b5 JB |
4682 | #ifdef CONFIG_PM_SLEEP |
4683 | /* look at d3.c */ | |
4684 | .suspend = iwl_mvm_suspend, | |
4685 | .resume = iwl_mvm_resume, | |
4686 | .set_wakeup = iwl_mvm_set_wakeup, | |
4687 | .set_rekey_data = iwl_mvm_set_rekey_data, | |
4688 | #if IS_ENABLED(CONFIG_IPV6) | |
4689 | .ipv6_addr_change = iwl_mvm_ipv6_addr_change, | |
4690 | #endif | |
4691 | .set_default_unicast_key = iwl_mvm_set_default_unicast_key, | |
4692 | #endif | |
91a8bcde | 4693 | .get_survey = iwl_mvm_mac_get_survey, |
33cef925 | 4694 | .sta_statistics = iwl_mvm_mac_sta_statistics, |
177a11cf GG |
4695 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
4696 | .sta_add_debugfs = iwl_mvm_sta_add_debugfs, | |
4697 | #endif | |
8ca151b5 | 4698 | }; |