]>
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. |
8ca151b5 JB |
9 | * |
10 | * This program is free software; you can redistribute it and/or modify | |
11 | * it under the terms of version 2 of the GNU General Public License as | |
12 | * published by the Free Software Foundation. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, but | |
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | * General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, | |
22 | * USA | |
23 | * | |
24 | * The full GNU General Public License is included in this distribution | |
410dc5aa | 25 | * in the file called COPYING. |
8ca151b5 JB |
26 | * |
27 | * Contact Information: | |
28 | * Intel Linux Wireless <ilw@linux.intel.com> | |
29 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 | |
30 | * | |
31 | * BSD LICENSE | |
32 | * | |
51368bf7 | 33 | * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. |
8ca151b5 JB |
34 | * All rights reserved. |
35 | * | |
36 | * Redistribution and use in source and binary forms, with or without | |
37 | * modification, are permitted provided that the following conditions | |
38 | * are met: | |
39 | * | |
40 | * * Redistributions of source code must retain the above copyright | |
41 | * notice, this list of conditions and the following disclaimer. | |
42 | * * Redistributions in binary form must reproduce the above copyright | |
43 | * notice, this list of conditions and the following disclaimer in | |
44 | * the documentation and/or other materials provided with the | |
45 | * distribution. | |
46 | * * Neither the name Intel Corporation nor the names of its | |
47 | * contributors may be used to endorse or promote products derived | |
48 | * from this software without specific prior written permission. | |
49 | * | |
50 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
51 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
52 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
53 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
54 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
55 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
56 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
57 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
58 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
59 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
60 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
61 | * | |
62 | *****************************************************************************/ | |
63 | #include <linux/kernel.h> | |
64 | #include <linux/slab.h> | |
65 | #include <linux/skbuff.h> | |
66 | #include <linux/netdevice.h> | |
67 | #include <linux/etherdevice.h> | |
f0c2646a | 68 | #include <linux/ip.h> |
2ee8f021 | 69 | #include <linux/if_arp.h> |
8ca151b5 | 70 | #include <net/mac80211.h> |
7b1dd048 | 71 | #include <net/ieee80211_radiotap.h> |
f0c2646a | 72 | #include <net/tcp.h> |
8ca151b5 JB |
73 | |
74 | #include "iwl-op-mode.h" | |
75 | #include "iwl-io.h" | |
76 | #include "mvm.h" | |
77 | #include "sta.h" | |
78 | #include "time-event.h" | |
79 | #include "iwl-eeprom-parse.h" | |
80 | #include "fw-api-scan.h" | |
81 | #include "iwl-phy-db.h" | |
507cadf2 | 82 | #include "testmode.h" |
655e6d6d EG |
83 | #include "iwl-fw-error-dump.h" |
84 | #include "iwl-prph.h" | |
8ca151b5 JB |
85 | |
86 | static const struct ieee80211_iface_limit iwl_mvm_limits[] = { | |
87 | { | |
88 | .max = 1, | |
8eb38710 | 89 | .types = BIT(NL80211_IFTYPE_STATION), |
8ca151b5 | 90 | }, |
3c15a0fb JB |
91 | { |
92 | .max = 1, | |
8eb38710 IP |
93 | .types = BIT(NL80211_IFTYPE_AP) | |
94 | BIT(NL80211_IFTYPE_P2P_CLIENT) | | |
3c15a0fb JB |
95 | BIT(NL80211_IFTYPE_P2P_GO), |
96 | }, | |
97 | { | |
98 | .max = 1, | |
99 | .types = BIT(NL80211_IFTYPE_P2P_DEVICE), | |
100 | }, | |
8ca151b5 JB |
101 | }; |
102 | ||
103 | static const struct ieee80211_iface_combination iwl_mvm_iface_combinations[] = { | |
104 | { | |
105 | .num_different_channels = 1, | |
106 | .max_interfaces = 3, | |
107 | .limits = iwl_mvm_limits, | |
108 | .n_limits = ARRAY_SIZE(iwl_mvm_limits), | |
109 | }, | |
110 | }; | |
111 | ||
f0c2646a JB |
112 | #ifdef CONFIG_PM_SLEEP |
113 | static const struct nl80211_wowlan_tcp_data_token_feature | |
114 | iwl_mvm_wowlan_tcp_token_feature = { | |
115 | .min_len = 0, | |
116 | .max_len = 255, | |
117 | .bufsize = IWL_WOWLAN_REMOTE_WAKE_MAX_TOKENS, | |
118 | }; | |
119 | ||
120 | static const struct wiphy_wowlan_tcp_support iwl_mvm_wowlan_tcp_support = { | |
121 | .tok = &iwl_mvm_wowlan_tcp_token_feature, | |
122 | .data_payload_max = IWL_WOWLAN_TCP_MAX_PACKET_LEN - | |
123 | sizeof(struct ethhdr) - | |
124 | sizeof(struct iphdr) - | |
125 | sizeof(struct tcphdr), | |
126 | .data_interval_max = 65535, /* __le16 in API */ | |
127 | .wake_payload_max = IWL_WOWLAN_REMOTE_WAKE_MAX_PACKET_LEN - | |
128 | sizeof(struct ethhdr) - | |
129 | sizeof(struct iphdr) - | |
130 | sizeof(struct tcphdr), | |
131 | .seq = true, | |
132 | }; | |
133 | #endif | |
134 | ||
77736923 | 135 | #ifdef CONFIG_IWLWIFI_BCAST_FILTERING |
2ee8f021 EP |
136 | /* |
137 | * Use the reserved field to indicate magic values. | |
138 | * these values will only be used internally by the driver, | |
139 | * and won't make it to the fw (reserved will be 0). | |
140 | * BC_FILTER_MAGIC_IP - configure the val of this attribute to | |
141 | * be the vif's ip address. in case there is not a single | |
142 | * ip address (0, or more than 1), this attribute will | |
143 | * be skipped. | |
144 | * BC_FILTER_MAGIC_MAC - set the val of this attribute to | |
145 | * the LSB bytes of the vif's mac address | |
146 | */ | |
147 | enum { | |
148 | BC_FILTER_MAGIC_NONE = 0, | |
149 | BC_FILTER_MAGIC_IP, | |
150 | BC_FILTER_MAGIC_MAC, | |
151 | }; | |
152 | ||
77736923 EP |
153 | static const struct iwl_fw_bcast_filter iwl_mvm_default_bcast_filters[] = { |
154 | { | |
155 | /* arp */ | |
156 | .discard = 0, | |
157 | .frame_type = BCAST_FILTER_FRAME_TYPE_ALL, | |
158 | .attrs = { | |
159 | { | |
160 | /* frame type - arp, hw type - ethernet */ | |
161 | .offset_type = | |
162 | BCAST_FILTER_OFFSET_PAYLOAD_START, | |
163 | .offset = sizeof(rfc1042_header), | |
164 | .val = cpu_to_be32(0x08060001), | |
165 | .mask = cpu_to_be32(0xffffffff), | |
166 | }, | |
2ee8f021 EP |
167 | { |
168 | /* arp dest ip */ | |
169 | .offset_type = | |
170 | BCAST_FILTER_OFFSET_PAYLOAD_START, | |
171 | .offset = sizeof(rfc1042_header) + 2 + | |
172 | sizeof(struct arphdr) + | |
173 | ETH_ALEN + sizeof(__be32) + | |
174 | ETH_ALEN, | |
175 | .mask = cpu_to_be32(0xffffffff), | |
176 | /* mark it as special field */ | |
177 | .reserved1 = cpu_to_le16(BC_FILTER_MAGIC_IP), | |
178 | }, | |
179 | }, | |
180 | }, | |
181 | { | |
182 | /* dhcp offer bcast */ | |
183 | .discard = 0, | |
184 | .frame_type = BCAST_FILTER_FRAME_TYPE_IPV4, | |
185 | .attrs = { | |
186 | { | |
187 | /* udp dest port - 68 (bootp client)*/ | |
188 | .offset_type = BCAST_FILTER_OFFSET_IP_END, | |
189 | .offset = offsetof(struct udphdr, dest), | |
190 | .val = cpu_to_be32(0x00440000), | |
191 | .mask = cpu_to_be32(0xffff0000), | |
192 | }, | |
193 | { | |
194 | /* dhcp - lsb bytes of client hw address */ | |
195 | .offset_type = BCAST_FILTER_OFFSET_IP_END, | |
196 | .offset = 38, | |
197 | .mask = cpu_to_be32(0xffffffff), | |
198 | /* mark it as special field */ | |
199 | .reserved1 = cpu_to_le16(BC_FILTER_MAGIC_MAC), | |
200 | }, | |
77736923 EP |
201 | }, |
202 | }, | |
203 | /* last filter must be empty */ | |
204 | {}, | |
205 | }; | |
206 | #endif | |
207 | ||
7498cf4c EP |
208 | void iwl_mvm_ref(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type) |
209 | { | |
7bb426ea | 210 | if (!iwl_mvm_is_d0i3_supported(mvm)) |
7498cf4c EP |
211 | return; |
212 | ||
213 | IWL_DEBUG_RPM(mvm, "Take mvm reference - type %d\n", ref_type); | |
576eeee9 EP |
214 | spin_lock_bh(&mvm->refs_lock); |
215 | mvm->refs[ref_type]++; | |
216 | spin_unlock_bh(&mvm->refs_lock); | |
7498cf4c EP |
217 | iwl_trans_ref(mvm->trans); |
218 | } | |
219 | ||
220 | void iwl_mvm_unref(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type) | |
221 | { | |
7bb426ea | 222 | if (!iwl_mvm_is_d0i3_supported(mvm)) |
7498cf4c EP |
223 | return; |
224 | ||
225 | IWL_DEBUG_RPM(mvm, "Leave mvm reference - type %d\n", ref_type); | |
576eeee9 EP |
226 | spin_lock_bh(&mvm->refs_lock); |
227 | WARN_ON(!mvm->refs[ref_type]--); | |
228 | spin_unlock_bh(&mvm->refs_lock); | |
7498cf4c EP |
229 | iwl_trans_unref(mvm->trans); |
230 | } | |
231 | ||
576eeee9 EP |
232 | static void iwl_mvm_unref_all_except(struct iwl_mvm *mvm, |
233 | enum iwl_mvm_ref_type except_ref) | |
7498cf4c | 234 | { |
576eeee9 | 235 | int i, j; |
7498cf4c | 236 | |
7bb426ea | 237 | if (!iwl_mvm_is_d0i3_supported(mvm)) |
7498cf4c EP |
238 | return; |
239 | ||
576eeee9 EP |
240 | spin_lock_bh(&mvm->refs_lock); |
241 | for (i = 0; i < IWL_MVM_REF_COUNT; i++) { | |
242 | if (except_ref == i || !mvm->refs[i]) | |
7498cf4c EP |
243 | continue; |
244 | ||
576eeee9 EP |
245 | IWL_DEBUG_RPM(mvm, "Cleanup: remove mvm ref type %d (%d)\n", |
246 | i, mvm->refs[i]); | |
247 | for (j = 0; j < mvm->refs[i]; j++) | |
248 | iwl_trans_unref(mvm->trans); | |
249 | mvm->refs[i] = 0; | |
7498cf4c | 250 | } |
576eeee9 | 251 | spin_unlock_bh(&mvm->refs_lock); |
7498cf4c EP |
252 | } |
253 | ||
576eeee9 | 254 | int iwl_mvm_ref_sync(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type) |
d40fc489 GG |
255 | { |
256 | iwl_mvm_ref(mvm, ref_type); | |
257 | ||
258 | if (!wait_event_timeout(mvm->d0i3_exit_waitq, | |
259 | !test_bit(IWL_MVM_STATUS_IN_D0I3, &mvm->status), | |
260 | HZ)) { | |
261 | WARN_ON_ONCE(1); | |
262 | iwl_mvm_unref(mvm, ref_type); | |
263 | return -EIO; | |
264 | } | |
265 | ||
266 | return 0; | |
267 | } | |
268 | ||
fe0f2de3 IP |
269 | static void iwl_mvm_reset_phy_ctxts(struct iwl_mvm *mvm) |
270 | { | |
271 | int i; | |
272 | ||
273 | memset(mvm->phy_ctxts, 0, sizeof(mvm->phy_ctxts)); | |
274 | for (i = 0; i < NUM_PHY_CTX; i++) { | |
275 | mvm->phy_ctxts[i].id = i; | |
276 | mvm->phy_ctxts[i].ref = 0; | |
277 | } | |
278 | } | |
279 | ||
20f1a5de DS |
280 | static int iwl_mvm_max_scan_ie_len(struct iwl_mvm *mvm) |
281 | { | |
282 | /* we create the 802.11 header and SSID element */ | |
283 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_NO_BASIC_SSID) | |
284 | return mvm->fw->ucode_capa.max_probe_length - 24 - 2; | |
285 | return mvm->fw->ucode_capa.max_probe_length - 24 - 34; | |
286 | } | |
287 | ||
8ca151b5 JB |
288 | int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm) |
289 | { | |
290 | struct ieee80211_hw *hw = mvm->hw; | |
831e85f3 | 291 | int num_mac, ret, i; |
8ca151b5 JB |
292 | |
293 | /* Tell mac80211 our characteristics */ | |
294 | hw->flags = IEEE80211_HW_SIGNAL_DBM | | |
295 | IEEE80211_HW_SPECTRUM_MGMT | | |
296 | IEEE80211_HW_REPORTS_TX_ACK_STATUS | | |
297 | IEEE80211_HW_QUEUE_CONTROL | | |
298 | IEEE80211_HW_WANT_MONITOR_VIF | | |
8ca151b5 JB |
299 | IEEE80211_HW_SUPPORTS_PS | |
300 | IEEE80211_HW_SUPPORTS_DYNAMIC_PS | | |
d2931bbd | 301 | IEEE80211_HW_AMPDU_AGGREGATION | |
d64048ed | 302 | IEEE80211_HW_TIMING_BEACON_ONLY | |
147fc9be | 303 | IEEE80211_HW_CONNECTION_MONITOR | |
f0c97783 | 304 | IEEE80211_HW_CHANCTX_STA_CSA | |
147fc9be | 305 | IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | |
e8e626ad | 306 | IEEE80211_HW_SUPPORTS_STATIC_SMPS; |
8ca151b5 | 307 | |
19e737c9 | 308 | hw->queues = mvm->first_agg_queue; |
398e8c6c | 309 | hw->offchannel_tx_hw_queue = IWL_MVM_OFFCHANNEL_QUEUE; |
7b1dd048 EG |
310 | hw->radiotap_mcs_details |= IEEE80211_RADIOTAP_MCS_HAVE_FEC | |
311 | IEEE80211_RADIOTAP_MCS_HAVE_STBC; | |
312 | hw->radiotap_vht_details |= IEEE80211_RADIOTAP_VHT_KNOWN_STBC; | |
8ca151b5 JB |
313 | hw->rate_control_algorithm = "iwl-mvm-rs"; |
314 | ||
315 | /* | |
316 | * Enable 11w if advertised by firmware and software crypto | |
317 | * is not enabled (as the firmware will interpret some mgmt | |
318 | * packets, so enabling it with software crypto isn't safe) | |
319 | */ | |
320 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_MFP && | |
321 | !iwlwifi_mod_params.sw_crypto) | |
322 | hw->flags |= IEEE80211_HW_MFP_CAPABLE; | |
323 | ||
1504f48d MC |
324 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_UAPSD_SUPPORT && |
325 | IWL_UCODE_API(mvm->fw->ucode_ver) >= 9 && | |
326 | !iwlwifi_mod_params.uapsd_disable) { | |
327 | hw->flags |= IEEE80211_HW_SUPPORTS_UAPSD; | |
328 | hw->uapsd_queues = IWL_UAPSD_AC_INFO; | |
329 | hw->uapsd_max_sp_len = IWL_UAPSD_MAX_SP; | |
330 | } | |
e8e626ad | 331 | |
fb98be5e DS |
332 | if (mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_LMAC_SCAN) |
333 | hw->flags |= IEEE80211_SINGLE_HW_SCAN_ON_ALL_BANDS; | |
334 | ||
8ca151b5 JB |
335 | hw->sta_data_size = sizeof(struct iwl_mvm_sta); |
336 | hw->vif_data_size = sizeof(struct iwl_mvm_vif); | |
fe0f2de3 | 337 | hw->chanctx_data_size = sizeof(u16); |
8ca151b5 JB |
338 | |
339 | hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | | |
3c15a0fb JB |
340 | BIT(NL80211_IFTYPE_P2P_CLIENT) | |
341 | BIT(NL80211_IFTYPE_AP) | | |
342 | BIT(NL80211_IFTYPE_P2P_GO) | | |
c13b1725 EG |
343 | BIT(NL80211_IFTYPE_P2P_DEVICE) | |
344 | BIT(NL80211_IFTYPE_ADHOC); | |
5023d966 | 345 | |
a2f73b6c LR |
346 | hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; |
347 | hw->wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG | | |
348 | REGULATORY_DISABLE_BEACON_HINTS; | |
8ca151b5 | 349 | |
3e56eadf JB |
350 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_GO_UAPSD) |
351 | hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD; | |
352 | ||
bd3398e2 AO |
353 | if (mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_CSA_FLOW) |
354 | hw->wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH; | |
355 | ||
8ca151b5 JB |
356 | hw->wiphy->iface_combinations = iwl_mvm_iface_combinations; |
357 | hw->wiphy->n_iface_combinations = | |
358 | ARRAY_SIZE(iwl_mvm_iface_combinations); | |
359 | ||
c451e6d4 | 360 | hw->wiphy->max_remain_on_channel_duration = 10000; |
8ca151b5 JB |
361 | hw->max_listen_interval = IWL_CONN_MAX_LISTEN_INTERVAL; |
362 | ||
363 | /* Extract MAC address */ | |
364 | memcpy(mvm->addresses[0].addr, mvm->nvm_data->hw_addr, ETH_ALEN); | |
365 | hw->wiphy->addresses = mvm->addresses; | |
366 | hw->wiphy->n_addresses = 1; | |
831e85f3 IP |
367 | |
368 | /* Extract additional MAC addresses if available */ | |
369 | num_mac = (mvm->nvm_data->n_hw_addrs > 1) ? | |
370 | min(IWL_MVM_MAX_ADDRESSES, mvm->nvm_data->n_hw_addrs) : 1; | |
371 | ||
372 | for (i = 1; i < num_mac; i++) { | |
373 | memcpy(mvm->addresses[i].addr, mvm->addresses[i-1].addr, | |
8ca151b5 | 374 | ETH_ALEN); |
831e85f3 | 375 | mvm->addresses[i].addr[5]++; |
8ca151b5 JB |
376 | hw->wiphy->n_addresses++; |
377 | } | |
378 | ||
fe0f2de3 IP |
379 | iwl_mvm_reset_phy_ctxts(mvm); |
380 | ||
20f1a5de DS |
381 | hw->wiphy->max_scan_ie_len = iwl_mvm_max_scan_ie_len(mvm); |
382 | ||
8ca151b5 JB |
383 | hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX; |
384 | ||
385 | if (mvm->nvm_data->bands[IEEE80211_BAND_2GHZ].n_channels) | |
386 | hw->wiphy->bands[IEEE80211_BAND_2GHZ] = | |
387 | &mvm->nvm_data->bands[IEEE80211_BAND_2GHZ]; | |
388 | if (mvm->nvm_data->bands[IEEE80211_BAND_5GHZ].n_channels) | |
389 | hw->wiphy->bands[IEEE80211_BAND_5GHZ] = | |
390 | &mvm->nvm_data->bands[IEEE80211_BAND_5GHZ]; | |
391 | ||
392 | hw->wiphy->hw_version = mvm->trans->hw_id; | |
393 | ||
ade50652 | 394 | if (iwlmvm_mod_params.power_scheme != IWL_POWER_SCHEME_CAM) |
8ca151b5 JB |
395 | hw->wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT; |
396 | else | |
397 | hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; | |
398 | ||
77b2f286 EG |
399 | /* TODO: enable that only for firmwares that don't crash */ |
400 | /* hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN; */ | |
536a3eee EG |
401 | hw->wiphy->max_sched_scan_ssids = PROBE_OPTION_MAX; |
402 | hw->wiphy->max_match_sets = IWL_SCAN_MAX_PROFILES; | |
403 | /* we create the 802.11 header and zero length SSID IE. */ | |
404 | hw->wiphy->max_sched_scan_ie_len = SCAN_OFFLOAD_PROBE_REQ_SIZE - 24 - 2; | |
35a000b7 | 405 | |
8ca151b5 | 406 | hw->wiphy->features |= NL80211_FEATURE_P2P_GO_CTWIN | |
ab480030 | 407 | NL80211_FEATURE_LOW_PRIORITY_SCAN | |
8a110d9b | 408 | NL80211_FEATURE_P2P_GO_OPPPS; |
8ca151b5 JB |
409 | |
410 | mvm->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD; | |
411 | ||
e36e5433 | 412 | /* currently FW API supports only one optional cipher scheme */ |
9ddca860 | 413 | if (mvm->fw->cs[0].cipher) { |
e36e5433 | 414 | mvm->hw->n_cipher_schemes = 1; |
9ddca860 | 415 | mvm->hw->cipher_schemes = &mvm->fw->cs[0]; |
e36e5433 MS |
416 | } |
417 | ||
8ca151b5 | 418 | #ifdef CONFIG_PM_SLEEP |
d15a747f EP |
419 | if (iwl_mvm_is_d0i3_supported(mvm) && |
420 | device_can_wakeup(mvm->trans->dev)) { | |
421 | mvm->wowlan.flags = WIPHY_WOWLAN_ANY; | |
422 | hw->wiphy->wowlan = &mvm->wowlan; | |
423 | } else if (mvm->fw->img[IWL_UCODE_WOWLAN].sec[0].len && | |
8ca151b5 JB |
424 | mvm->trans->ops->d3_suspend && |
425 | mvm->trans->ops->d3_resume && | |
426 | device_can_wakeup(mvm->trans->dev)) { | |
964dc9e2 JB |
427 | mvm->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT | |
428 | WIPHY_WOWLAN_DISCONNECT | | |
429 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | | |
430 | WIPHY_WOWLAN_RFKILL_RELEASE; | |
8ca151b5 | 431 | if (!iwlwifi_mod_params.sw_crypto) |
964dc9e2 JB |
432 | mvm->wowlan.flags |= WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
433 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | | |
434 | WIPHY_WOWLAN_4WAY_HANDSHAKE; | |
435 | ||
436 | mvm->wowlan.n_patterns = IWL_WOWLAN_MAX_PATTERNS; | |
437 | mvm->wowlan.pattern_min_len = IWL_WOWLAN_MIN_PATTERN_LEN; | |
438 | mvm->wowlan.pattern_max_len = IWL_WOWLAN_MAX_PATTERN_LEN; | |
439 | mvm->wowlan.tcp = &iwl_mvm_wowlan_tcp_support; | |
440 | hw->wiphy->wowlan = &mvm->wowlan; | |
8ca151b5 JB |
441 | } |
442 | #endif | |
443 | ||
77736923 EP |
444 | #ifdef CONFIG_IWLWIFI_BCAST_FILTERING |
445 | /* assign default bcast filtering configuration */ | |
446 | mvm->bcast_filters = iwl_mvm_default_bcast_filters; | |
447 | #endif | |
448 | ||
8ca151b5 JB |
449 | ret = iwl_mvm_leds_init(mvm); |
450 | if (ret) | |
451 | return ret; | |
452 | ||
b7327d89 EG |
453 | ret = ieee80211_register_hw(mvm->hw); |
454 | if (ret) | |
455 | iwl_mvm_leds_exit(mvm); | |
456 | ||
457 | return ret; | |
8ca151b5 JB |
458 | } |
459 | ||
b2492501 AN |
460 | static bool iwl_mvm_defer_tx(struct iwl_mvm *mvm, |
461 | struct ieee80211_sta *sta, | |
462 | struct sk_buff *skb) | |
463 | { | |
464 | struct iwl_mvm_sta *mvmsta; | |
465 | bool defer = false; | |
466 | ||
467 | /* | |
468 | * double check the IN_D0I3 flag both before and after | |
469 | * taking the spinlock, in order to prevent taking | |
470 | * the spinlock when not needed. | |
471 | */ | |
472 | if (likely(!test_bit(IWL_MVM_STATUS_IN_D0I3, &mvm->status))) | |
473 | return false; | |
474 | ||
475 | spin_lock(&mvm->d0i3_tx_lock); | |
476 | /* | |
477 | * testing the flag again ensures the skb dequeue | |
478 | * loop (on d0i3 exit) hasn't run yet. | |
479 | */ | |
480 | if (!test_bit(IWL_MVM_STATUS_IN_D0I3, &mvm->status)) | |
481 | goto out; | |
482 | ||
483 | mvmsta = iwl_mvm_sta_from_mac80211(sta); | |
484 | if (mvmsta->sta_id == IWL_MVM_STATION_COUNT || | |
485 | mvmsta->sta_id != mvm->d0i3_ap_sta_id) | |
486 | goto out; | |
487 | ||
488 | __skb_queue_tail(&mvm->d0i3_tx, skb); | |
489 | ieee80211_stop_queues(mvm->hw); | |
490 | ||
491 | /* trigger wakeup */ | |
492 | iwl_mvm_ref(mvm, IWL_MVM_REF_TX); | |
493 | iwl_mvm_unref(mvm, IWL_MVM_REF_TX); | |
494 | ||
495 | defer = true; | |
496 | out: | |
497 | spin_unlock(&mvm->d0i3_tx_lock); | |
498 | return defer; | |
499 | } | |
500 | ||
8ca151b5 JB |
501 | static void iwl_mvm_mac_tx(struct ieee80211_hw *hw, |
502 | struct ieee80211_tx_control *control, | |
503 | struct sk_buff *skb) | |
504 | { | |
505 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
3e56eadf JB |
506 | struct ieee80211_sta *sta = control->sta; |
507 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | |
508 | struct ieee80211_hdr *hdr = (void *)skb->data; | |
8ca151b5 | 509 | |
9ee718aa EL |
510 | if (iwl_mvm_is_radio_killed(mvm)) { |
511 | IWL_DEBUG_DROP(mvm, "Dropping - RF/CT KILL\n"); | |
8ca151b5 JB |
512 | goto drop; |
513 | } | |
514 | ||
398e8c6c | 515 | if (IEEE80211_SKB_CB(skb)->hw_queue == IWL_MVM_OFFCHANNEL_QUEUE && |
8ca151b5 JB |
516 | !test_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status)) |
517 | goto drop; | |
518 | ||
3e56eadf JB |
519 | /* treat non-bufferable MMPDUs as broadcast if sta is sleeping */ |
520 | if (unlikely(info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER && | |
521 | ieee80211_is_mgmt(hdr->frame_control) && | |
522 | !ieee80211_is_deauth(hdr->frame_control) && | |
523 | !ieee80211_is_disassoc(hdr->frame_control) && | |
524 | !ieee80211_is_action(hdr->frame_control))) | |
525 | sta = NULL; | |
526 | ||
527 | if (sta) { | |
b2492501 AN |
528 | if (iwl_mvm_defer_tx(mvm, sta, skb)) |
529 | return; | |
3e56eadf | 530 | if (iwl_mvm_tx_skb(mvm, skb, sta)) |
8ca151b5 JB |
531 | goto drop; |
532 | return; | |
533 | } | |
534 | ||
535 | if (iwl_mvm_tx_skb_non_sta(mvm, skb)) | |
536 | goto drop; | |
537 | return; | |
538 | drop: | |
539 | ieee80211_free_txskb(hw, skb); | |
540 | } | |
541 | ||
205e2210 EG |
542 | static inline bool iwl_enable_rx_ampdu(const struct iwl_cfg *cfg) |
543 | { | |
544 | if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_RXAGG) | |
545 | return false; | |
546 | return true; | |
547 | } | |
548 | ||
549 | static inline bool iwl_enable_tx_ampdu(const struct iwl_cfg *cfg) | |
550 | { | |
551 | if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_TXAGG) | |
552 | return false; | |
553 | if (iwlwifi_mod_params.disable_11n & IWL_ENABLE_HT_TXAGG) | |
554 | return true; | |
555 | ||
556 | /* enabled by default */ | |
557 | return true; | |
558 | } | |
559 | ||
8ca151b5 JB |
560 | static int iwl_mvm_mac_ampdu_action(struct ieee80211_hw *hw, |
561 | struct ieee80211_vif *vif, | |
562 | enum ieee80211_ampdu_mlme_action action, | |
563 | struct ieee80211_sta *sta, u16 tid, | |
564 | u16 *ssn, u8 buf_size) | |
565 | { | |
566 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
567 | int ret; | |
b2492501 | 568 | bool tx_agg_ref = false; |
8ca151b5 JB |
569 | |
570 | IWL_DEBUG_HT(mvm, "A-MPDU action on addr %pM tid %d: action %d\n", | |
571 | sta->addr, tid, action); | |
572 | ||
573 | if (!(mvm->nvm_data->sku_cap_11n_enable)) | |
574 | return -EACCES; | |
575 | ||
b2492501 | 576 | /* return from D0i3 before starting a new Tx aggregation */ |
9256c205 EP |
577 | switch (action) { |
578 | case IEEE80211_AMPDU_TX_START: | |
579 | case IEEE80211_AMPDU_TX_STOP_CONT: | |
580 | case IEEE80211_AMPDU_TX_STOP_FLUSH: | |
581 | case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT: | |
582 | case IEEE80211_AMPDU_TX_OPERATIONAL: | |
b2492501 | 583 | /* |
9256c205 EP |
584 | * for tx start, wait synchronously until D0i3 exit to |
585 | * get the correct sequence number for the tid. | |
586 | * additionally, some other ampdu actions use direct | |
587 | * target access, which is not handled automatically | |
588 | * by the trans layer (unlike commands), so wait for | |
589 | * d0i3 exit in these cases as well. | |
b2492501 | 590 | */ |
d40fc489 GG |
591 | ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_TX_AGG); |
592 | if (ret) | |
593 | return ret; | |
594 | ||
595 | tx_agg_ref = true; | |
9256c205 EP |
596 | break; |
597 | default: | |
598 | break; | |
b2492501 AN |
599 | } |
600 | ||
8ca151b5 JB |
601 | mutex_lock(&mvm->mutex); |
602 | ||
603 | switch (action) { | |
604 | case IEEE80211_AMPDU_RX_START: | |
205e2210 | 605 | if (!iwl_enable_rx_ampdu(mvm->cfg)) { |
8ca151b5 JB |
606 | ret = -EINVAL; |
607 | break; | |
608 | } | |
609 | ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, *ssn, true); | |
610 | break; | |
611 | case IEEE80211_AMPDU_RX_STOP: | |
612 | ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, 0, false); | |
613 | break; | |
614 | case IEEE80211_AMPDU_TX_START: | |
205e2210 | 615 | if (!iwl_enable_tx_ampdu(mvm->cfg)) { |
5d158efa EG |
616 | ret = -EINVAL; |
617 | break; | |
618 | } | |
8ca151b5 JB |
619 | ret = iwl_mvm_sta_tx_agg_start(mvm, vif, sta, tid, ssn); |
620 | break; | |
621 | case IEEE80211_AMPDU_TX_STOP_CONT: | |
e3d9e7ce EG |
622 | ret = iwl_mvm_sta_tx_agg_stop(mvm, vif, sta, tid); |
623 | break; | |
8ca151b5 JB |
624 | case IEEE80211_AMPDU_TX_STOP_FLUSH: |
625 | case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT: | |
e3d9e7ce | 626 | ret = iwl_mvm_sta_tx_agg_flush(mvm, vif, sta, tid); |
8ca151b5 JB |
627 | break; |
628 | case IEEE80211_AMPDU_TX_OPERATIONAL: | |
629 | ret = iwl_mvm_sta_tx_agg_oper(mvm, vif, sta, tid, buf_size); | |
630 | break; | |
631 | default: | |
632 | WARN_ON_ONCE(1); | |
633 | ret = -EINVAL; | |
634 | break; | |
635 | } | |
636 | mutex_unlock(&mvm->mutex); | |
637 | ||
b2492501 AN |
638 | /* |
639 | * If the tid is marked as started, we won't use it for offloaded | |
640 | * traffic on the next D0i3 entry. It's safe to unref. | |
641 | */ | |
642 | if (tx_agg_ref) | |
643 | iwl_mvm_unref(mvm, IWL_MVM_REF_TX_AGG); | |
644 | ||
8ca151b5 JB |
645 | return ret; |
646 | } | |
647 | ||
648 | static void iwl_mvm_cleanup_iterator(void *data, u8 *mac, | |
649 | struct ieee80211_vif *vif) | |
650 | { | |
651 | struct iwl_mvm *mvm = data; | |
652 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
653 | ||
654 | mvmvif->uploaded = false; | |
655 | mvmvif->ap_sta_id = IWL_MVM_STATION_COUNT; | |
656 | ||
657 | /* does this make sense at all? */ | |
658 | mvmvif->color++; | |
659 | ||
660 | spin_lock_bh(&mvm->time_event_lock); | |
661 | iwl_mvm_te_clear_data(mvm, &mvmvif->time_event_data); | |
662 | spin_unlock_bh(&mvm->time_event_lock); | |
663 | ||
fe0f2de3 | 664 | mvmvif->phy_ctxt = NULL; |
8a275bad | 665 | memset(&mvmvif->bf_data, 0, sizeof(mvmvif->bf_data)); |
8ca151b5 JB |
666 | } |
667 | ||
655e6d6d EG |
668 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
669 | static void iwl_mvm_fw_error_dump(struct iwl_mvm *mvm) | |
670 | { | |
671 | struct iwl_fw_error_dump_file *dump_file; | |
672 | struct iwl_fw_error_dump_data *dump_data; | |
673 | struct iwl_fw_error_dump_info *dump_info; | |
48eb7b34 | 674 | struct iwl_mvm_dump_ptrs *fw_error_dump; |
655e6d6d EG |
675 | const struct fw_img *img; |
676 | u32 sram_len, sram_ofs; | |
677 | u32 file_len, rxf_len; | |
678 | unsigned long flags; | |
655e6d6d EG |
679 | int reg_val; |
680 | ||
681 | lockdep_assert_held(&mvm->mutex); | |
682 | ||
683 | if (mvm->fw_error_dump) | |
684 | return; | |
685 | ||
48eb7b34 EG |
686 | fw_error_dump = kzalloc(sizeof(*mvm->fw_error_dump), GFP_KERNEL); |
687 | if (!fw_error_dump) | |
688 | return; | |
689 | ||
655e6d6d EG |
690 | img = &mvm->fw->img[mvm->cur_ucode]; |
691 | sram_ofs = img->sec[IWL_UCODE_SECTION_DATA].offset; | |
692 | sram_len = img->sec[IWL_UCODE_SECTION_DATA].len; | |
693 | ||
694 | /* reading buffer size */ | |
695 | reg_val = iwl_trans_read_prph(mvm->trans, RXF_SIZE_ADDR); | |
696 | rxf_len = (reg_val & RXF_SIZE_BYTE_CNT_MSK) >> RXF_SIZE_BYTE_CND_POS; | |
697 | ||
698 | /* the register holds the value divided by 128 */ | |
699 | rxf_len = rxf_len << 7; | |
700 | ||
701 | file_len = sizeof(*dump_file) + | |
702 | sizeof(*dump_data) * 3 + | |
703 | sram_len + | |
704 | rxf_len + | |
705 | sizeof(*dump_info); | |
706 | ||
5bfe6f53 | 707 | dump_file = vzalloc(file_len); |
48eb7b34 EG |
708 | if (!dump_file) { |
709 | kfree(fw_error_dump); | |
655e6d6d | 710 | return; |
48eb7b34 | 711 | } |
655e6d6d | 712 | |
48eb7b34 | 713 | fw_error_dump->op_mode_ptr = dump_file; |
655e6d6d EG |
714 | |
715 | dump_file->barker = cpu_to_le32(IWL_FW_ERROR_DUMP_BARKER); | |
655e6d6d EG |
716 | dump_data = (void *)dump_file->data; |
717 | ||
718 | dump_data->type = cpu_to_le32(IWL_FW_ERROR_DUMP_DEV_FW_INFO); | |
719 | dump_data->len = cpu_to_le32(sizeof(*dump_info)); | |
720 | dump_info = (void *) dump_data->data; | |
721 | dump_info->device_family = | |
722 | mvm->cfg->device_family == IWL_DEVICE_FAMILY_7000 ? | |
723 | cpu_to_le32(IWL_FW_ERROR_DUMP_FAMILY_7) : | |
724 | cpu_to_le32(IWL_FW_ERROR_DUMP_FAMILY_8); | |
725 | memcpy(dump_info->fw_human_readable, mvm->fw->human_readable, | |
726 | sizeof(dump_info->fw_human_readable)); | |
727 | strncpy(dump_info->dev_human_readable, mvm->cfg->name, | |
728 | sizeof(dump_info->dev_human_readable)); | |
729 | strncpy(dump_info->bus_human_readable, mvm->dev->bus->name, | |
730 | sizeof(dump_info->bus_human_readable)); | |
731 | ||
732 | dump_data = iwl_fw_error_next_data(dump_data); | |
733 | dump_data->type = cpu_to_le32(IWL_FW_ERROR_DUMP_RXF); | |
734 | dump_data->len = cpu_to_le32(rxf_len); | |
735 | ||
736 | if (iwl_trans_grab_nic_access(mvm->trans, false, &flags)) { | |
737 | u32 *rxf = (void *)dump_data->data; | |
738 | int i; | |
739 | ||
740 | for (i = 0; i < (rxf_len / sizeof(u32)); i++) { | |
741 | iwl_trans_write_prph(mvm->trans, | |
742 | RXF_LD_FENCE_OFFSET_ADDR, | |
743 | i * sizeof(u32)); | |
744 | rxf[i] = iwl_trans_read_prph(mvm->trans, | |
745 | RXF_FIFO_RD_FENCE_ADDR); | |
746 | } | |
747 | iwl_trans_release_nic_access(mvm->trans, &flags); | |
748 | } | |
749 | ||
750 | dump_data = iwl_fw_error_next_data(dump_data); | |
751 | dump_data->type = cpu_to_le32(IWL_FW_ERROR_DUMP_SRAM); | |
752 | dump_data->len = cpu_to_le32(sram_len); | |
753 | iwl_trans_read_mem_bytes(mvm->trans, sram_ofs, dump_data->data, | |
754 | sram_len); | |
755 | ||
48eb7b34 EG |
756 | fw_error_dump->trans_ptr = iwl_trans_dump_data(mvm->trans); |
757 | fw_error_dump->op_mode_len = file_len; | |
758 | if (fw_error_dump->trans_ptr) | |
759 | file_len += fw_error_dump->trans_ptr->len; | |
760 | dump_file->file_len = cpu_to_le32(file_len); | |
761 | mvm->fw_error_dump = fw_error_dump; | |
655e6d6d EG |
762 | } |
763 | #endif | |
764 | ||
8ca151b5 JB |
765 | static void iwl_mvm_restart_cleanup(struct iwl_mvm *mvm) |
766 | { | |
1bd3cbc1 EG |
767 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
768 | static char *env[] = { "DRIVER=iwlwifi", "EVENT=error_dump", NULL }; | |
769 | ||
770 | iwl_mvm_fw_error_dump(mvm); | |
771 | ||
772 | /* notify the userspace about the error we had */ | |
773 | kobject_uevent_env(&mvm->hw->wiphy->dev.kobj, KOBJ_CHANGE, env); | |
774 | #endif | |
775 | ||
8ca151b5 | 776 | iwl_trans_stop_device(mvm->trans); |
8ca151b5 JB |
777 | |
778 | mvm->scan_status = IWL_MVM_SCAN_NONE; | |
b1873300 | 779 | mvm->ps_disabled = false; |
8ca151b5 JB |
780 | |
781 | /* just in case one was running */ | |
782 | ieee80211_remain_on_channel_expired(mvm->hw); | |
783 | ||
784 | ieee80211_iterate_active_interfaces_atomic( | |
785 | mvm->hw, IEEE80211_IFACE_ITER_RESUME_ALL, | |
786 | iwl_mvm_cleanup_iterator, mvm); | |
787 | ||
fe0f2de3 | 788 | mvm->p2p_device_vif = NULL; |
37577fe2 | 789 | mvm->d0i3_ap_sta_id = IWL_MVM_STATION_COUNT; |
fe0f2de3 IP |
790 | |
791 | iwl_mvm_reset_phy_ctxts(mvm); | |
8ca151b5 JB |
792 | memset(mvm->fw_key_table, 0, sizeof(mvm->fw_key_table)); |
793 | memset(mvm->sta_drained, 0, sizeof(mvm->sta_drained)); | |
8a275bad EG |
794 | memset(&mvm->last_bt_notif, 0, sizeof(mvm->last_bt_notif)); |
795 | memset(&mvm->last_bt_notif_old, 0, sizeof(mvm->last_bt_notif_old)); | |
796 | memset(&mvm->last_bt_ci_cmd, 0, sizeof(mvm->last_bt_ci_cmd)); | |
797 | memset(&mvm->last_bt_ci_cmd_old, 0, sizeof(mvm->last_bt_ci_cmd_old)); | |
798 | memset(&mvm->bt_ack_kill_msk, 0, sizeof(mvm->bt_ack_kill_msk)); | |
799 | memset(&mvm->bt_cts_kill_msk, 0, sizeof(mvm->bt_cts_kill_msk)); | |
8ca151b5 JB |
800 | |
801 | ieee80211_wake_queues(mvm->hw); | |
802 | ||
7498cf4c EP |
803 | /* cleanup all stale references (scan, roc), but keep the |
804 | * ucode_down ref until reconfig is complete */ | |
805 | iwl_mvm_unref_all_except(mvm, IWL_MVM_REF_UCODE_DOWN); | |
806 | ||
228670b2 EP |
807 | /* clear any stale d0i3 state */ |
808 | clear_bit(IWL_MVM_STATUS_IN_D0I3, &mvm->status); | |
809 | ||
8ca151b5 | 810 | mvm->vif_count = 0; |
113a0447 | 811 | mvm->rx_ba_sessions = 0; |
8ca151b5 JB |
812 | } |
813 | ||
814 | static int iwl_mvm_mac_start(struct ieee80211_hw *hw) | |
815 | { | |
816 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
817 | int ret; | |
818 | ||
819 | mutex_lock(&mvm->mutex); | |
820 | ||
821 | /* Clean up some internal and mac80211 state on restart */ | |
822 | if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) | |
823 | iwl_mvm_restart_cleanup(mvm); | |
824 | ||
825 | ret = iwl_mvm_up(mvm); | |
c47af22a JB |
826 | |
827 | if (ret && test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) { | |
828 | /* Something went wrong - we need to finish some cleanup | |
829 | * that normally iwl_mvm_mac_restart_complete() below | |
830 | * would do. | |
831 | */ | |
832 | clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status); | |
833 | iwl_mvm_d0i3_enable_tx(mvm, NULL); | |
834 | } | |
835 | ||
8ca151b5 JB |
836 | mutex_unlock(&mvm->mutex); |
837 | ||
838 | return ret; | |
839 | } | |
840 | ||
841 | static void iwl_mvm_mac_restart_complete(struct ieee80211_hw *hw) | |
842 | { | |
843 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
844 | int ret; | |
845 | ||
846 | mutex_lock(&mvm->mutex); | |
847 | ||
848 | clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status); | |
b2492501 | 849 | iwl_mvm_d0i3_enable_tx(mvm, NULL); |
0166230c | 850 | ret = iwl_mvm_update_quotas(mvm, NULL); |
8ca151b5 JB |
851 | if (ret) |
852 | IWL_ERR(mvm, "Failed to update quotas after restart (%d)\n", | |
853 | ret); | |
854 | ||
7498cf4c EP |
855 | /* allow transport/FW low power modes */ |
856 | iwl_mvm_unref(mvm, IWL_MVM_REF_UCODE_DOWN); | |
857 | ||
8ca151b5 JB |
858 | mutex_unlock(&mvm->mutex); |
859 | } | |
860 | ||
861 | static void iwl_mvm_mac_stop(struct ieee80211_hw *hw) | |
862 | { | |
863 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
864 | ||
37577fe2 | 865 | flush_work(&mvm->d0i3_exit_work); |
8ca151b5 JB |
866 | flush_work(&mvm->async_handlers_wk); |
867 | ||
868 | mutex_lock(&mvm->mutex); | |
7498cf4c EP |
869 | |
870 | /* disallow low power states when the FW is down */ | |
871 | iwl_mvm_ref(mvm, IWL_MVM_REF_UCODE_DOWN); | |
872 | ||
8ca151b5 JB |
873 | /* async_handlers_wk is now blocked */ |
874 | ||
875 | /* | |
876 | * The work item could be running or queued if the | |
877 | * ROC time event stops just as we get here. | |
878 | */ | |
879 | cancel_work_sync(&mvm->roc_done_wk); | |
880 | ||
881 | iwl_trans_stop_device(mvm->trans); | |
8ca151b5 JB |
882 | |
883 | iwl_mvm_async_handlers_purge(mvm); | |
884 | /* async_handlers_list is empty and will stay empty: HW is stopped */ | |
885 | ||
886 | /* the fw is stopped, the aux sta is dead: clean up driver state */ | |
887 | iwl_mvm_dealloc_int_sta(mvm, &mvm->aux_sta); | |
888 | ||
889 | mutex_unlock(&mvm->mutex); | |
890 | ||
891 | /* | |
892 | * The worker might have been waiting for the mutex, let it run and | |
893 | * discover that its list is now empty. | |
894 | */ | |
895 | cancel_work_sync(&mvm->async_handlers_wk); | |
896 | } | |
897 | ||
fe0f2de3 IP |
898 | static struct iwl_mvm_phy_ctxt *iwl_mvm_get_free_phy_ctxt(struct iwl_mvm *mvm) |
899 | { | |
900 | u16 i; | |
901 | ||
902 | lockdep_assert_held(&mvm->mutex); | |
903 | ||
904 | for (i = 0; i < NUM_PHY_CTX; i++) | |
905 | if (!mvm->phy_ctxts[i].ref) | |
906 | return &mvm->phy_ctxts[i]; | |
907 | ||
908 | IWL_ERR(mvm, "No available PHY context\n"); | |
909 | return NULL; | |
910 | } | |
911 | ||
ee9c6cb0 EG |
912 | static int iwl_mvm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif, |
913 | s8 tx_power) | |
914 | { | |
915 | /* FW is in charge of regulatory enforcement */ | |
916 | struct iwl_reduce_tx_power_cmd reduce_txpwr_cmd = { | |
917 | .mac_context_id = iwl_mvm_vif_from_mac80211(vif)->id, | |
918 | .pwr_restriction = cpu_to_le16(tx_power), | |
919 | }; | |
920 | ||
a1022927 | 921 | return iwl_mvm_send_cmd_pdu(mvm, REDUCE_TX_POWER_CMD, 0, |
ee9c6cb0 EG |
922 | sizeof(reduce_txpwr_cmd), |
923 | &reduce_txpwr_cmd); | |
924 | } | |
925 | ||
8ca151b5 JB |
926 | static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw, |
927 | struct ieee80211_vif *vif) | |
928 | { | |
929 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
930 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
931 | int ret; | |
932 | ||
d40fc489 GG |
933 | /* |
934 | * make sure D0i3 exit is completed, otherwise a target access | |
935 | * during tx queue configuration could be done when still in | |
936 | * D0i3 state. | |
937 | */ | |
938 | ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_ADD_IF); | |
939 | if (ret) | |
940 | return ret; | |
941 | ||
8ca151b5 JB |
942 | /* |
943 | * Not much to do here. The stack will not allow interface | |
944 | * types or combinations that we didn't advertise, so we | |
945 | * don't really have to check the types. | |
946 | */ | |
947 | ||
948 | mutex_lock(&mvm->mutex); | |
949 | ||
e89044d7 | 950 | /* Allocate resources for the MAC context, and add it to the fw */ |
8ca151b5 JB |
951 | ret = iwl_mvm_mac_ctxt_init(mvm, vif); |
952 | if (ret) | |
953 | goto out_unlock; | |
954 | ||
1c2abf72 | 955 | /* Counting number of interfaces is needed for legacy PM */ |
ea183d02 IP |
956 | if (vif->type != NL80211_IFTYPE_P2P_DEVICE) |
957 | mvm->vif_count++; | |
ea183d02 | 958 | |
8ca151b5 JB |
959 | /* |
960 | * The AP binding flow can be done only after the beacon | |
961 | * template is configured (which happens only in the mac80211 | |
962 | * start_ap() flow), and adding the broadcast station can happen | |
963 | * only after the binding. | |
964 | * In addition, since modifying the MAC before adding a bcast | |
965 | * station is not allowed by the FW, delay the adding of MAC context to | |
966 | * the point where we can also add the bcast station. | |
967 | * In short: there's not much we can do at this point, other than | |
968 | * allocating resources :) | |
969 | */ | |
5023d966 JB |
970 | if (vif->type == NL80211_IFTYPE_AP || |
971 | vif->type == NL80211_IFTYPE_ADHOC) { | |
8ca151b5 JB |
972 | u32 qmask = iwl_mvm_mac_get_queues_mask(mvm, vif); |
973 | ret = iwl_mvm_allocate_int_sta(mvm, &mvmvif->bcast_sta, | |
b92e661b EP |
974 | qmask, |
975 | ieee80211_vif_type_p2p(vif)); | |
8ca151b5 JB |
976 | if (ret) { |
977 | IWL_ERR(mvm, "Failed to allocate bcast sta\n"); | |
978 | goto out_release; | |
979 | } | |
980 | ||
77740cb4 | 981 | iwl_mvm_vif_dbgfs_register(mvm, vif); |
8ca151b5 JB |
982 | goto out_unlock; |
983 | } | |
984 | ||
8ca151b5 JB |
985 | ret = iwl_mvm_mac_ctxt_add(mvm, vif); |
986 | if (ret) | |
987 | goto out_release; | |
988 | ||
999609f1 | 989 | ret = iwl_mvm_power_update_mac(mvm); |
e5e7aa8e EG |
990 | if (ret) |
991 | goto out_release; | |
8ca151b5 | 992 | |
7df15b1e | 993 | /* beacon filtering */ |
a1022927 | 994 | ret = iwl_mvm_disable_beacon_filter(mvm, vif, 0); |
bd3351ba EP |
995 | if (ret) |
996 | goto out_remove_mac; | |
997 | ||
7df15b1e | 998 | if (!mvm->bf_allowed_vif && |
73e5f2c5 | 999 | vif->type == NL80211_IFTYPE_STATION && !vif->p2p) { |
7df15b1e | 1000 | mvm->bf_allowed_vif = mvmvif; |
a20fd398 AO |
1001 | vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER | |
1002 | IEEE80211_VIF_SUPPORTS_CQM_RSSI; | |
7df15b1e HG |
1003 | } |
1004 | ||
8ca151b5 JB |
1005 | /* |
1006 | * P2P_DEVICE interface does not have a channel context assigned to it, | |
1007 | * so a dedicated PHY context is allocated to it and the corresponding | |
1008 | * MAC context is bound to it at this stage. | |
1009 | */ | |
1010 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { | |
8ca151b5 | 1011 | |
fe0f2de3 IP |
1012 | mvmvif->phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm); |
1013 | if (!mvmvif->phy_ctxt) { | |
1014 | ret = -ENOSPC; | |
bd3351ba | 1015 | goto out_free_bf; |
fe0f2de3 | 1016 | } |
8ca151b5 | 1017 | |
53a9d61e | 1018 | iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt); |
8ca151b5 JB |
1019 | ret = iwl_mvm_binding_add_vif(mvm, vif); |
1020 | if (ret) | |
53a9d61e | 1021 | goto out_unref_phy; |
8ca151b5 JB |
1022 | |
1023 | ret = iwl_mvm_add_bcast_sta(mvm, vif, &mvmvif->bcast_sta); | |
1024 | if (ret) | |
1025 | goto out_unbind; | |
1026 | ||
1027 | /* Save a pointer to p2p device vif, so it can later be used to | |
1028 | * update the p2p device MAC when a GO is started/stopped */ | |
1029 | mvm->p2p_device_vif = vif; | |
1030 | } | |
1031 | ||
63494374 | 1032 | iwl_mvm_vif_dbgfs_register(mvm, vif); |
8ca151b5 JB |
1033 | goto out_unlock; |
1034 | ||
1035 | out_unbind: | |
1036 | iwl_mvm_binding_remove_vif(mvm, vif); | |
53a9d61e | 1037 | out_unref_phy: |
fe0f2de3 | 1038 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); |
bd3351ba EP |
1039 | out_free_bf: |
1040 | if (mvm->bf_allowed_vif == mvmvif) { | |
1041 | mvm->bf_allowed_vif = NULL; | |
a20fd398 AO |
1042 | vif->driver_flags &= ~(IEEE80211_VIF_BEACON_FILTER | |
1043 | IEEE80211_VIF_SUPPORTS_CQM_RSSI); | |
bd3351ba | 1044 | } |
8ca151b5 JB |
1045 | out_remove_mac: |
1046 | mvmvif->phy_ctxt = NULL; | |
1047 | iwl_mvm_mac_ctxt_remove(mvm, vif); | |
1048 | out_release: | |
5ee2b215 AB |
1049 | if (vif->type != NL80211_IFTYPE_P2P_DEVICE) |
1050 | mvm->vif_count--; | |
1c2abf72 | 1051 | |
8ca151b5 JB |
1052 | iwl_mvm_mac_ctxt_release(mvm, vif); |
1053 | out_unlock: | |
1054 | mutex_unlock(&mvm->mutex); | |
1055 | ||
d40fc489 GG |
1056 | iwl_mvm_unref(mvm, IWL_MVM_REF_ADD_IF); |
1057 | ||
8ca151b5 JB |
1058 | return ret; |
1059 | } | |
1060 | ||
38a12b5b JB |
1061 | static void iwl_mvm_prepare_mac_removal(struct iwl_mvm *mvm, |
1062 | struct ieee80211_vif *vif) | |
8ca151b5 | 1063 | { |
8ca151b5 JB |
1064 | u32 tfd_msk = 0, ac; |
1065 | ||
1066 | for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) | |
1067 | if (vif->hw_queue[ac] != IEEE80211_INVAL_HW_QUEUE) | |
1068 | tfd_msk |= BIT(vif->hw_queue[ac]); | |
1069 | ||
1070 | if (vif->cab_queue != IEEE80211_INVAL_HW_QUEUE) | |
1071 | tfd_msk |= BIT(vif->cab_queue); | |
1072 | ||
1073 | if (tfd_msk) { | |
1074 | mutex_lock(&mvm->mutex); | |
1075 | iwl_mvm_flush_tx_path(mvm, tfd_msk, true); | |
1076 | mutex_unlock(&mvm->mutex); | |
1077 | } | |
1078 | ||
1079 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { | |
1080 | /* | |
1081 | * Flush the ROC worker which will flush the OFFCHANNEL queue. | |
1082 | * We assume here that all the packets sent to the OFFCHANNEL | |
1083 | * queue are sent in ROC session. | |
1084 | */ | |
1085 | flush_work(&mvm->roc_done_wk); | |
1086 | } else { | |
1087 | /* | |
1088 | * By now, all the AC queues are empty. The AGG queues are | |
1089 | * empty too. We already got all the Tx responses for all the | |
1090 | * packets in the queues. The drain work can have been | |
0742a75a | 1091 | * triggered. Flush it. |
8ca151b5 JB |
1092 | */ |
1093 | flush_work(&mvm->sta_drained_wk); | |
1094 | } | |
38a12b5b JB |
1095 | } |
1096 | ||
1097 | static void iwl_mvm_mac_remove_interface(struct ieee80211_hw *hw, | |
1098 | struct ieee80211_vif *vif) | |
1099 | { | |
1100 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1101 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
1102 | ||
1103 | iwl_mvm_prepare_mac_removal(mvm, vif); | |
8ca151b5 JB |
1104 | |
1105 | mutex_lock(&mvm->mutex); | |
1106 | ||
7df15b1e HG |
1107 | if (mvm->bf_allowed_vif == mvmvif) { |
1108 | mvm->bf_allowed_vif = NULL; | |
a20fd398 AO |
1109 | vif->driver_flags &= ~(IEEE80211_VIF_BEACON_FILTER | |
1110 | IEEE80211_VIF_SUPPORTS_CQM_RSSI); | |
7df15b1e HG |
1111 | } |
1112 | ||
63494374 JB |
1113 | iwl_mvm_vif_dbgfs_clean(mvm, vif); |
1114 | ||
8ca151b5 JB |
1115 | /* |
1116 | * For AP/GO interface, the tear down of the resources allocated to the | |
38a12b5b | 1117 | * interface is be handled as part of the stop_ap flow. |
8ca151b5 | 1118 | */ |
5023d966 JB |
1119 | if (vif->type == NL80211_IFTYPE_AP || |
1120 | vif->type == NL80211_IFTYPE_ADHOC) { | |
507cadf2 DS |
1121 | #ifdef CONFIG_NL80211_TESTMODE |
1122 | if (vif == mvm->noa_vif) { | |
1123 | mvm->noa_vif = NULL; | |
1124 | mvm->noa_duration = 0; | |
1125 | } | |
1126 | #endif | |
8ca151b5 JB |
1127 | iwl_mvm_dealloc_int_sta(mvm, &mvmvif->bcast_sta); |
1128 | goto out_release; | |
1129 | } | |
1130 | ||
1131 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { | |
1132 | mvm->p2p_device_vif = NULL; | |
1133 | iwl_mvm_rm_bcast_sta(mvm, &mvmvif->bcast_sta); | |
1134 | iwl_mvm_binding_remove_vif(mvm, vif); | |
fe0f2de3 | 1135 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); |
8ca151b5 JB |
1136 | mvmvif->phy_ctxt = NULL; |
1137 | } | |
1138 | ||
5ee2b215 | 1139 | if (mvm->vif_count && vif->type != NL80211_IFTYPE_P2P_DEVICE) |
8ca151b5 | 1140 | mvm->vif_count--; |
1c2abf72 | 1141 | |
999609f1 | 1142 | iwl_mvm_power_update_mac(mvm); |
8ca151b5 JB |
1143 | iwl_mvm_mac_ctxt_remove(mvm, vif); |
1144 | ||
1145 | out_release: | |
1146 | iwl_mvm_mac_ctxt_release(mvm, vif); | |
1147 | mutex_unlock(&mvm->mutex); | |
1148 | } | |
1149 | ||
1150 | static int iwl_mvm_mac_config(struct ieee80211_hw *hw, u32 changed) | |
88f2fd73 | 1151 | { |
8ca151b5 JB |
1152 | return 0; |
1153 | } | |
1154 | ||
e59647ea EP |
1155 | struct iwl_mvm_mc_iter_data { |
1156 | struct iwl_mvm *mvm; | |
1157 | int port_id; | |
1158 | }; | |
1159 | ||
1160 | static void iwl_mvm_mc_iface_iterator(void *_data, u8 *mac, | |
1161 | struct ieee80211_vif *vif) | |
1162 | { | |
1163 | struct iwl_mvm_mc_iter_data *data = _data; | |
1164 | struct iwl_mvm *mvm = data->mvm; | |
1165 | struct iwl_mcast_filter_cmd *cmd = mvm->mcast_filter_cmd; | |
1166 | int ret, len; | |
1167 | ||
1168 | /* if we don't have free ports, mcast frames will be dropped */ | |
1169 | if (WARN_ON_ONCE(data->port_id >= MAX_PORT_ID_NUM)) | |
1170 | return; | |
1171 | ||
1172 | if (vif->type != NL80211_IFTYPE_STATION || | |
1173 | !vif->bss_conf.assoc) | |
1174 | return; | |
1175 | ||
1176 | cmd->port_id = data->port_id++; | |
1177 | memcpy(cmd->bssid, vif->bss_conf.bssid, ETH_ALEN); | |
1178 | len = roundup(sizeof(*cmd) + cmd->count * ETH_ALEN, 4); | |
1179 | ||
1c4abec0 | 1180 | ret = iwl_mvm_send_cmd_pdu(mvm, MCAST_FILTER_CMD, CMD_ASYNC, len, cmd); |
e59647ea EP |
1181 | if (ret) |
1182 | IWL_ERR(mvm, "mcast filter cmd error. ret=%d\n", ret); | |
1183 | } | |
1184 | ||
1185 | static void iwl_mvm_recalc_multicast(struct iwl_mvm *mvm) | |
1186 | { | |
1187 | struct iwl_mvm_mc_iter_data iter_data = { | |
1188 | .mvm = mvm, | |
88f2fd73 MG |
1189 | }; |
1190 | ||
e59647ea EP |
1191 | lockdep_assert_held(&mvm->mutex); |
1192 | ||
1193 | if (WARN_ON_ONCE(!mvm->mcast_filter_cmd)) | |
1194 | return; | |
1195 | ||
1c4abec0 | 1196 | ieee80211_iterate_active_interfaces_atomic( |
e59647ea EP |
1197 | mvm->hw, IEEE80211_IFACE_ITER_NORMAL, |
1198 | iwl_mvm_mc_iface_iterator, &iter_data); | |
88f2fd73 MG |
1199 | } |
1200 | ||
e59647ea EP |
1201 | static u64 iwl_mvm_prepare_multicast(struct ieee80211_hw *hw, |
1202 | struct netdev_hw_addr_list *mc_list) | |
8ca151b5 | 1203 | { |
e59647ea EP |
1204 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
1205 | struct iwl_mcast_filter_cmd *cmd; | |
1206 | struct netdev_hw_addr *addr; | |
1207 | int addr_count = netdev_hw_addr_list_count(mc_list); | |
1208 | bool pass_all = false; | |
1209 | int len; | |
1210 | ||
1211 | if (addr_count > MAX_MCAST_FILTERING_ADDRESSES) { | |
1212 | pass_all = true; | |
1213 | addr_count = 0; | |
1214 | } | |
1215 | ||
1216 | len = roundup(sizeof(*cmd) + addr_count * ETH_ALEN, 4); | |
1217 | cmd = kzalloc(len, GFP_ATOMIC); | |
1218 | if (!cmd) | |
1219 | return 0; | |
1220 | ||
1221 | if (pass_all) { | |
1222 | cmd->pass_all = 1; | |
1223 | return (u64)(unsigned long)cmd; | |
1224 | } | |
1225 | ||
1226 | netdev_hw_addr_list_for_each(addr, mc_list) { | |
1227 | IWL_DEBUG_MAC80211(mvm, "mcast addr (%d): %pM\n", | |
1228 | cmd->count, addr->addr); | |
1229 | memcpy(&cmd->addr_list[cmd->count * ETH_ALEN], | |
1230 | addr->addr, ETH_ALEN); | |
1231 | cmd->count++; | |
1232 | } | |
1233 | ||
1234 | return (u64)(unsigned long)cmd; | |
8ca151b5 JB |
1235 | } |
1236 | ||
1237 | static void iwl_mvm_configure_filter(struct ieee80211_hw *hw, | |
1238 | unsigned int changed_flags, | |
1239 | unsigned int *total_flags, | |
1240 | u64 multicast) | |
1241 | { | |
e59647ea EP |
1242 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
1243 | struct iwl_mcast_filter_cmd *cmd = (void *)(unsigned long)multicast; | |
8ca151b5 | 1244 | |
e59647ea | 1245 | mutex_lock(&mvm->mutex); |
51b6b9e0 | 1246 | |
e59647ea EP |
1247 | /* replace previous configuration */ |
1248 | kfree(mvm->mcast_filter_cmd); | |
1249 | mvm->mcast_filter_cmd = cmd; | |
51b6b9e0 | 1250 | |
e59647ea EP |
1251 | if (!cmd) |
1252 | goto out; | |
51b6b9e0 | 1253 | |
e59647ea EP |
1254 | iwl_mvm_recalc_multicast(mvm); |
1255 | out: | |
1256 | mutex_unlock(&mvm->mutex); | |
1257 | *total_flags = 0; | |
51b6b9e0 EG |
1258 | } |
1259 | ||
c87163b9 EP |
1260 | #ifdef CONFIG_IWLWIFI_BCAST_FILTERING |
1261 | struct iwl_bcast_iter_data { | |
1262 | struct iwl_mvm *mvm; | |
1263 | struct iwl_bcast_filter_cmd *cmd; | |
1264 | u8 current_filter; | |
1265 | }; | |
1266 | ||
1267 | static void | |
1268 | iwl_mvm_set_bcast_filter(struct ieee80211_vif *vif, | |
1269 | const struct iwl_fw_bcast_filter *in_filter, | |
1270 | struct iwl_fw_bcast_filter *out_filter) | |
1271 | { | |
1272 | struct iwl_fw_bcast_filter_attr *attr; | |
1273 | int i; | |
1274 | ||
1275 | memcpy(out_filter, in_filter, sizeof(*out_filter)); | |
1276 | ||
1277 | for (i = 0; i < ARRAY_SIZE(out_filter->attrs); i++) { | |
1278 | attr = &out_filter->attrs[i]; | |
1279 | ||
1280 | if (!attr->mask) | |
1281 | break; | |
1282 | ||
2ee8f021 EP |
1283 | switch (attr->reserved1) { |
1284 | case cpu_to_le16(BC_FILTER_MAGIC_IP): | |
1285 | if (vif->bss_conf.arp_addr_cnt != 1) { | |
1286 | attr->mask = 0; | |
1287 | continue; | |
1288 | } | |
1289 | ||
1290 | attr->val = vif->bss_conf.arp_addr_list[0]; | |
1291 | break; | |
1292 | case cpu_to_le16(BC_FILTER_MAGIC_MAC): | |
1293 | attr->val = *(__be32 *)&vif->addr[2]; | |
1294 | break; | |
1295 | default: | |
1296 | break; | |
1297 | } | |
1298 | attr->reserved1 = 0; | |
c87163b9 EP |
1299 | out_filter->num_attrs++; |
1300 | } | |
1301 | } | |
1302 | ||
1303 | static void iwl_mvm_bcast_filter_iterator(void *_data, u8 *mac, | |
1304 | struct ieee80211_vif *vif) | |
1305 | { | |
1306 | struct iwl_bcast_iter_data *data = _data; | |
1307 | struct iwl_mvm *mvm = data->mvm; | |
1308 | struct iwl_bcast_filter_cmd *cmd = data->cmd; | |
1309 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
1310 | struct iwl_fw_bcast_mac *bcast_mac; | |
1311 | int i; | |
1312 | ||
1313 | if (WARN_ON(mvmvif->id >= ARRAY_SIZE(cmd->macs))) | |
1314 | return; | |
1315 | ||
1316 | bcast_mac = &cmd->macs[mvmvif->id]; | |
1317 | ||
e48393e8 IP |
1318 | /* |
1319 | * enable filtering only for associated stations, but not for P2P | |
1320 | * Clients | |
1321 | */ | |
1322 | if (vif->type != NL80211_IFTYPE_STATION || vif->p2p || | |
1323 | !vif->bss_conf.assoc) | |
c87163b9 EP |
1324 | return; |
1325 | ||
1326 | bcast_mac->default_discard = 1; | |
1327 | ||
1328 | /* copy all configured filters */ | |
1329 | for (i = 0; mvm->bcast_filters[i].attrs[0].mask; i++) { | |
1330 | /* | |
1331 | * Make sure we don't exceed our filters limit. | |
1332 | * if there is still a valid filter to be configured, | |
1333 | * be on the safe side and just allow bcast for this mac. | |
1334 | */ | |
1335 | if (WARN_ON_ONCE(data->current_filter >= | |
1336 | ARRAY_SIZE(cmd->filters))) { | |
1337 | bcast_mac->default_discard = 0; | |
1338 | bcast_mac->attached_filters = 0; | |
1339 | break; | |
1340 | } | |
1341 | ||
1342 | iwl_mvm_set_bcast_filter(vif, | |
1343 | &mvm->bcast_filters[i], | |
1344 | &cmd->filters[data->current_filter]); | |
1345 | ||
1346 | /* skip current filter if it contains no attributes */ | |
1347 | if (!cmd->filters[data->current_filter].num_attrs) | |
1348 | continue; | |
1349 | ||
1350 | /* attach the filter to current mac */ | |
1351 | bcast_mac->attached_filters |= | |
1352 | cpu_to_le16(BIT(data->current_filter)); | |
1353 | ||
1354 | data->current_filter++; | |
1355 | } | |
1356 | } | |
1357 | ||
de06a59e EP |
1358 | bool iwl_mvm_bcast_filter_build_cmd(struct iwl_mvm *mvm, |
1359 | struct iwl_bcast_filter_cmd *cmd) | |
c87163b9 | 1360 | { |
c87163b9 EP |
1361 | struct iwl_bcast_iter_data iter_data = { |
1362 | .mvm = mvm, | |
de06a59e | 1363 | .cmd = cmd, |
c87163b9 EP |
1364 | }; |
1365 | ||
de06a59e EP |
1366 | memset(cmd, 0, sizeof(*cmd)); |
1367 | cmd->max_bcast_filters = ARRAY_SIZE(cmd->filters); | |
1368 | cmd->max_macs = ARRAY_SIZE(cmd->macs); | |
1369 | ||
1370 | #ifdef CONFIG_IWLWIFI_DEBUGFS | |
1371 | /* use debugfs filters/macs if override is configured */ | |
1372 | if (mvm->dbgfs_bcast_filtering.override) { | |
1373 | memcpy(cmd->filters, &mvm->dbgfs_bcast_filtering.cmd.filters, | |
1374 | sizeof(cmd->filters)); | |
1375 | memcpy(cmd->macs, &mvm->dbgfs_bcast_filtering.cmd.macs, | |
1376 | sizeof(cmd->macs)); | |
1377 | return true; | |
1378 | } | |
1379 | #endif | |
c87163b9 EP |
1380 | |
1381 | /* if no filters are configured, do nothing */ | |
1382 | if (!mvm->bcast_filters) | |
de06a59e | 1383 | return false; |
c87163b9 EP |
1384 | |
1385 | /* configure and attach these filters for each associated sta vif */ | |
1386 | ieee80211_iterate_active_interfaces( | |
1387 | mvm->hw, IEEE80211_IFACE_ITER_NORMAL, | |
1388 | iwl_mvm_bcast_filter_iterator, &iter_data); | |
1389 | ||
de06a59e EP |
1390 | return true; |
1391 | } | |
1392 | static int iwl_mvm_configure_bcast_filter(struct iwl_mvm *mvm, | |
1393 | struct ieee80211_vif *vif) | |
1394 | { | |
1395 | struct iwl_bcast_filter_cmd cmd; | |
1396 | ||
1397 | if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BCAST_FILTERING)) | |
1398 | return 0; | |
1399 | ||
1400 | if (!iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) | |
1401 | return 0; | |
1402 | ||
a1022927 | 1403 | return iwl_mvm_send_cmd_pdu(mvm, BCAST_FILTER_CMD, 0, |
c87163b9 EP |
1404 | sizeof(cmd), &cmd); |
1405 | } | |
1406 | #else | |
1407 | static inline int iwl_mvm_configure_bcast_filter(struct iwl_mvm *mvm, | |
1408 | struct ieee80211_vif *vif) | |
1409 | { | |
1410 | return 0; | |
1411 | } | |
1412 | #endif | |
1413 | ||
f697267f AN |
1414 | static void iwl_mvm_teardown_tdls_peers(struct iwl_mvm *mvm) |
1415 | { | |
1416 | struct ieee80211_sta *sta; | |
1417 | struct iwl_mvm_sta *mvmsta; | |
1418 | int i; | |
1419 | ||
1420 | lockdep_assert_held(&mvm->mutex); | |
1421 | ||
1422 | for (i = 0; i < IWL_MVM_STATION_COUNT; i++) { | |
1423 | sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i], | |
1424 | lockdep_is_held(&mvm->mutex)); | |
1425 | if (!sta || IS_ERR(sta) || !sta->tdls) | |
1426 | continue; | |
1427 | ||
1428 | mvmsta = iwl_mvm_sta_from_mac80211(sta); | |
1429 | ieee80211_tdls_oper_request(mvmsta->vif, sta->addr, | |
1430 | NL80211_TDLS_TEARDOWN, | |
1431 | WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED, | |
1432 | GFP_KERNEL); | |
1433 | } | |
1434 | } | |
1435 | ||
8ca151b5 JB |
1436 | static void iwl_mvm_bss_info_changed_station(struct iwl_mvm *mvm, |
1437 | struct ieee80211_vif *vif, | |
1438 | struct ieee80211_bss_conf *bss_conf, | |
1439 | u32 changes) | |
1440 | { | |
1441 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
1442 | int ret; | |
1443 | ||
6e97b0d2 IP |
1444 | /* |
1445 | * Re-calculate the tsf id, as the master-slave relations depend on the | |
1446 | * beacon interval, which was not known when the station interface was | |
1447 | * added. | |
1448 | */ | |
1449 | if (changes & BSS_CHANGED_ASSOC && bss_conf->assoc) | |
1450 | iwl_mvm_mac_ctxt_recalc_tsf_id(mvm, vif); | |
1451 | ||
bca49d9a | 1452 | ret = iwl_mvm_mac_ctxt_changed(mvm, vif, false); |
8ca151b5 JB |
1453 | if (ret) |
1454 | IWL_ERR(mvm, "failed to update MAC %pM\n", vif->addr); | |
1455 | ||
1456 | if (changes & BSS_CHANGED_ASSOC) { | |
1457 | if (bss_conf->assoc) { | |
1458 | /* add quota for this interface */ | |
0166230c | 1459 | ret = iwl_mvm_update_quotas(mvm, NULL); |
8ca151b5 JB |
1460 | if (ret) { |
1461 | IWL_ERR(mvm, "failed to update quotas\n"); | |
1462 | return; | |
1463 | } | |
016d27e1 JB |
1464 | |
1465 | if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, | |
1466 | &mvm->status)) { | |
1467 | /* | |
1468 | * If we're restarting then the firmware will | |
1469 | * obviously have lost synchronisation with | |
1470 | * the AP. It will attempt to synchronise by | |
1471 | * itself, but we can make it more reliable by | |
1472 | * scheduling a session protection time event. | |
1473 | * | |
1474 | * The firmware needs to receive a beacon to | |
1475 | * catch up with synchronisation, use 110% of | |
1476 | * the beacon interval. | |
1477 | * | |
1478 | * Set a large maximum delay to allow for more | |
1479 | * than a single interface. | |
1480 | */ | |
1481 | u32 dur = (11 * vif->bss_conf.beacon_int) / 10; | |
1482 | iwl_mvm_protect_session(mvm, vif, dur, dur, | |
1483 | 5 * dur); | |
1484 | } | |
1f3b0ff8 LE |
1485 | |
1486 | iwl_mvm_sf_update(mvm, vif, false); | |
175a70b7 | 1487 | iwl_mvm_power_vif_assoc(mvm, vif); |
697162a1 | 1488 | if (vif->p2p) { |
29a90a49 | 1489 | iwl_mvm_ref(mvm, IWL_MVM_REF_P2P_CLIENT); |
697162a1 EG |
1490 | iwl_mvm_update_smps(mvm, vif, |
1491 | IWL_MVM_SMPS_REQ_PROT, | |
1492 | IEEE80211_SMPS_DYNAMIC); | |
1493 | } | |
8ca151b5 | 1494 | } else if (mvmvif->ap_sta_id != IWL_MVM_STATION_COUNT) { |
1f3b0ff8 LE |
1495 | /* |
1496 | * If update fails - SF might be running in associated | |
1497 | * mode while disassociated - which is forbidden. | |
1498 | */ | |
1499 | WARN_ONCE(iwl_mvm_sf_update(mvm, vif, false), | |
1500 | "Failed to update SF upon disassociation\n"); | |
1501 | ||
8ca151b5 JB |
1502 | /* remove AP station now that the MAC is unassoc */ |
1503 | ret = iwl_mvm_rm_sta_id(mvm, vif, mvmvif->ap_sta_id); | |
1504 | if (ret) | |
1505 | IWL_ERR(mvm, "failed to remove AP station\n"); | |
37577fe2 EP |
1506 | |
1507 | if (mvm->d0i3_ap_sta_id == mvmvif->ap_sta_id) | |
1508 | mvm->d0i3_ap_sta_id = IWL_MVM_STATION_COUNT; | |
8ca151b5 JB |
1509 | mvmvif->ap_sta_id = IWL_MVM_STATION_COUNT; |
1510 | /* remove quota for this interface */ | |
0166230c | 1511 | ret = iwl_mvm_update_quotas(mvm, NULL); |
8ca151b5 JB |
1512 | if (ret) |
1513 | IWL_ERR(mvm, "failed to update quotas\n"); | |
29a90a49 EP |
1514 | |
1515 | if (vif->p2p) | |
1516 | iwl_mvm_unref(mvm, IWL_MVM_REF_P2P_CLIENT); | |
8ca151b5 | 1517 | } |
a20fd398 | 1518 | |
e59647ea | 1519 | iwl_mvm_recalc_multicast(mvm); |
c87163b9 | 1520 | iwl_mvm_configure_bcast_filter(mvm, vif); |
e59647ea | 1521 | |
a20fd398 AO |
1522 | /* reset rssi values */ |
1523 | mvmvif->bf_data.ave_beacon_signal = 0; | |
1524 | ||
8e484f0b | 1525 | iwl_mvm_bt_coex_vif_change(mvm); |
f94045ed EG |
1526 | iwl_mvm_update_smps(mvm, vif, IWL_MVM_SMPS_REQ_TT, |
1527 | IEEE80211_SMPS_AUTOMATIC); | |
989c6505 | 1528 | } else if (changes & BSS_CHANGED_BEACON_INFO) { |
210a544e JB |
1529 | /* |
1530 | * We received a beacon _after_ association so | |
1531 | * remove the session protection. | |
1532 | */ | |
1533 | iwl_mvm_remove_time_event(mvm, mvmvif, | |
1534 | &mvmvif->time_event_data); | |
51498cf6 AB |
1535 | } else if (changes & (BSS_CHANGED_PS | BSS_CHANGED_P2P_PS | |
1536 | BSS_CHANGED_QOS)) { | |
999609f1 | 1537 | ret = iwl_mvm_power_update_mac(mvm); |
4bf881f5 AB |
1538 | if (ret) |
1539 | IWL_ERR(mvm, "failed to update power mode\n"); | |
8ca151b5 | 1540 | } |
cc87d322 EH |
1541 | |
1542 | if (changes & BSS_CHANGED_BEACON_INFO) { | |
1543 | iwl_mvm_sf_update(mvm, vif, false); | |
1544 | WARN_ON(iwl_mvm_enable_beacon_filter(mvm, vif, 0)); | |
1545 | } | |
1546 | ||
88f2fd73 MG |
1547 | if (changes & BSS_CHANGED_TXPOWER) { |
1548 | IWL_DEBUG_CALIB(mvm, "Changing TX Power to %d\n", | |
1549 | bss_conf->txpower); | |
1550 | iwl_mvm_set_tx_power(mvm, vif, bss_conf->txpower); | |
1551 | } | |
a20fd398 AO |
1552 | |
1553 | if (changes & BSS_CHANGED_CQM) { | |
3c6acb61 | 1554 | IWL_DEBUG_MAC80211(mvm, "cqm info_changed\n"); |
a20fd398 AO |
1555 | /* reset cqm events tracking */ |
1556 | mvmvif->bf_data.last_cqm_event = 0; | |
fa7b2e7f AA |
1557 | if (mvmvif->bf_data.bf_enabled) { |
1558 | ret = iwl_mvm_enable_beacon_filter(mvm, vif, 0); | |
1559 | if (ret) | |
1560 | IWL_ERR(mvm, | |
1561 | "failed to update CQM thresholds\n"); | |
1562 | } | |
a20fd398 | 1563 | } |
2ee8f021 EP |
1564 | |
1565 | if (changes & BSS_CHANGED_ARP_FILTER) { | |
3c6acb61 | 1566 | IWL_DEBUG_MAC80211(mvm, "arp filter changed\n"); |
2ee8f021 EP |
1567 | iwl_mvm_configure_bcast_filter(mvm, vif); |
1568 | } | |
8ca151b5 JB |
1569 | } |
1570 | ||
5023d966 JB |
1571 | static int iwl_mvm_start_ap_ibss(struct ieee80211_hw *hw, |
1572 | struct ieee80211_vif *vif) | |
8ca151b5 JB |
1573 | { |
1574 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1575 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
1576 | int ret; | |
1577 | ||
576eeee9 EP |
1578 | /* |
1579 | * iwl_mvm_mac_ctxt_add() might read directly from the device | |
1580 | * (the system time), so make sure it is available. | |
1581 | */ | |
1582 | ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_START_AP); | |
1583 | if (ret) | |
1584 | return ret; | |
1585 | ||
8ca151b5 JB |
1586 | mutex_lock(&mvm->mutex); |
1587 | ||
1588 | /* Send the beacon template */ | |
1589 | ret = iwl_mvm_mac_ctxt_beacon_changed(mvm, vif); | |
1590 | if (ret) | |
1591 | goto out_unlock; | |
1592 | ||
6e97b0d2 IP |
1593 | /* |
1594 | * Re-calculate the tsf id, as the master-slave relations depend on the | |
1595 | * beacon interval, which was not known when the AP interface was added. | |
1596 | */ | |
1597 | if (vif->type == NL80211_IFTYPE_AP) | |
1598 | iwl_mvm_mac_ctxt_recalc_tsf_id(mvm, vif); | |
1599 | ||
8ca151b5 JB |
1600 | /* Add the mac context */ |
1601 | ret = iwl_mvm_mac_ctxt_add(mvm, vif); | |
1602 | if (ret) | |
1603 | goto out_unlock; | |
1604 | ||
1605 | /* Perform the binding */ | |
1606 | ret = iwl_mvm_binding_add_vif(mvm, vif); | |
1607 | if (ret) | |
1608 | goto out_remove; | |
1609 | ||
8ca151b5 JB |
1610 | /* Send the bcast station. At this stage the TBTT and DTIM time events |
1611 | * are added and applied to the scheduler */ | |
1612 | ret = iwl_mvm_send_bcast_sta(mvm, vif, &mvmvif->bcast_sta); | |
1613 | if (ret) | |
1614 | goto out_unbind; | |
1615 | ||
5691e218 IP |
1616 | /* must be set before quota calculations */ |
1617 | mvmvif->ap_ibss_active = true; | |
1618 | ||
a11e144e | 1619 | /* power updated needs to be done before quotas */ |
999609f1 | 1620 | iwl_mvm_power_update_mac(mvm); |
a11e144e | 1621 | |
0166230c | 1622 | ret = iwl_mvm_update_quotas(mvm, NULL); |
8ca151b5 | 1623 | if (ret) |
a11e144e | 1624 | goto out_quota_failed; |
8ca151b5 | 1625 | |
5023d966 | 1626 | /* Need to update the P2P Device MAC (only GO, IBSS is single vif) */ |
8ca151b5 | 1627 | if (vif->p2p && mvm->p2p_device_vif) |
bca49d9a | 1628 | iwl_mvm_mac_ctxt_changed(mvm, mvm->p2p_device_vif, false); |
8ca151b5 | 1629 | |
29a90a49 EP |
1630 | iwl_mvm_ref(mvm, IWL_MVM_REF_AP_IBSS); |
1631 | ||
8e484f0b | 1632 | iwl_mvm_bt_coex_vif_change(mvm); |
dac94da8 | 1633 | |
f697267f AN |
1634 | /* we don't support TDLS during DCM */ |
1635 | if (iwl_mvm_phy_ctx_count(mvm) > 1) | |
1636 | iwl_mvm_teardown_tdls_peers(mvm); | |
1637 | ||
8ca151b5 JB |
1638 | mutex_unlock(&mvm->mutex); |
1639 | return 0; | |
1640 | ||
a11e144e | 1641 | out_quota_failed: |
999609f1 | 1642 | iwl_mvm_power_update_mac(mvm); |
5691e218 | 1643 | mvmvif->ap_ibss_active = false; |
8ca151b5 JB |
1644 | iwl_mvm_send_rm_bcast_sta(mvm, &mvmvif->bcast_sta); |
1645 | out_unbind: | |
1646 | iwl_mvm_binding_remove_vif(mvm, vif); | |
1647 | out_remove: | |
1648 | iwl_mvm_mac_ctxt_remove(mvm, vif); | |
1649 | out_unlock: | |
1650 | mutex_unlock(&mvm->mutex); | |
576eeee9 | 1651 | iwl_mvm_unref(mvm, IWL_MVM_REF_START_AP); |
8ca151b5 JB |
1652 | return ret; |
1653 | } | |
1654 | ||
5023d966 JB |
1655 | static void iwl_mvm_stop_ap_ibss(struct ieee80211_hw *hw, |
1656 | struct ieee80211_vif *vif) | |
8ca151b5 JB |
1657 | { |
1658 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1659 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
1660 | ||
38a12b5b JB |
1661 | iwl_mvm_prepare_mac_removal(mvm, vif); |
1662 | ||
8ca151b5 JB |
1663 | mutex_lock(&mvm->mutex); |
1664 | ||
664322fa | 1665 | /* Handle AP stop while in CSA */ |
7f0a7c67 AO |
1666 | if (rcu_access_pointer(mvm->csa_vif) == vif) { |
1667 | iwl_mvm_remove_time_event(mvm, mvmvif, | |
1668 | &mvmvif->time_event_data); | |
664322fa | 1669 | RCU_INIT_POINTER(mvm->csa_vif, NULL); |
7f0a7c67 | 1670 | } |
664322fa | 1671 | |
003e5236 AO |
1672 | if (rcu_access_pointer(mvm->csa_tx_blocked_vif) == vif) { |
1673 | RCU_INIT_POINTER(mvm->csa_tx_blocked_vif, NULL); | |
1674 | mvm->csa_tx_block_bcn_timeout = 0; | |
1675 | } | |
1676 | ||
5023d966 | 1677 | mvmvif->ap_ibss_active = false; |
1c87bbad | 1678 | mvm->ap_last_beacon_gp2 = 0; |
8ca151b5 | 1679 | |
8e484f0b | 1680 | iwl_mvm_bt_coex_vif_change(mvm); |
dac94da8 | 1681 | |
29a90a49 EP |
1682 | iwl_mvm_unref(mvm, IWL_MVM_REF_AP_IBSS); |
1683 | ||
5023d966 | 1684 | /* Need to update the P2P Device MAC (only GO, IBSS is single vif) */ |
8ca151b5 | 1685 | if (vif->p2p && mvm->p2p_device_vif) |
bca49d9a | 1686 | iwl_mvm_mac_ctxt_changed(mvm, mvm->p2p_device_vif, false); |
8ca151b5 | 1687 | |
0166230c | 1688 | iwl_mvm_update_quotas(mvm, NULL); |
8ca151b5 JB |
1689 | iwl_mvm_send_rm_bcast_sta(mvm, &mvmvif->bcast_sta); |
1690 | iwl_mvm_binding_remove_vif(mvm, vif); | |
a11e144e | 1691 | |
999609f1 | 1692 | iwl_mvm_power_update_mac(mvm); |
a11e144e | 1693 | |
8ca151b5 JB |
1694 | iwl_mvm_mac_ctxt_remove(mvm, vif); |
1695 | ||
1696 | mutex_unlock(&mvm->mutex); | |
1697 | } | |
1698 | ||
5023d966 JB |
1699 | static void |
1700 | iwl_mvm_bss_info_changed_ap_ibss(struct iwl_mvm *mvm, | |
1701 | struct ieee80211_vif *vif, | |
1702 | struct ieee80211_bss_conf *bss_conf, | |
1703 | u32 changes) | |
8ca151b5 | 1704 | { |
be2056fc | 1705 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
8a5e3660 | 1706 | |
be2056fc IP |
1707 | /* Changes will be applied when the AP/IBSS is started */ |
1708 | if (!mvmvif->ap_ibss_active) | |
1709 | return; | |
1710 | ||
863230da JB |
1711 | if (changes & (BSS_CHANGED_ERP_CTS_PROT | BSS_CHANGED_HT | |
1712 | BSS_CHANGED_BANDWIDTH) && | |
bca49d9a | 1713 | iwl_mvm_mac_ctxt_changed(mvm, vif, false)) |
863230da | 1714 | IWL_ERR(mvm, "failed to update MAC %pM\n", vif->addr); |
8a5e3660 | 1715 | |
8ca151b5 | 1716 | /* Need to send a new beacon template to the FW */ |
863230da JB |
1717 | if (changes & BSS_CHANGED_BEACON && |
1718 | iwl_mvm_mac_ctxt_beacon_changed(mvm, vif)) | |
1719 | IWL_WARN(mvm, "Failed updating beacon data\n"); | |
8ca151b5 JB |
1720 | } |
1721 | ||
1722 | static void iwl_mvm_bss_info_changed(struct ieee80211_hw *hw, | |
1723 | struct ieee80211_vif *vif, | |
1724 | struct ieee80211_bss_conf *bss_conf, | |
1725 | u32 changes) | |
1726 | { | |
1727 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1728 | ||
576eeee9 EP |
1729 | /* |
1730 | * iwl_mvm_bss_info_changed_station() might call | |
1731 | * iwl_mvm_protect_session(), which reads directly from | |
1732 | * the device (the system time), so make sure it is available. | |
1733 | */ | |
1734 | if (iwl_mvm_ref_sync(mvm, IWL_MVM_REF_BSS_CHANGED)) | |
1735 | return; | |
1736 | ||
8ca151b5 JB |
1737 | mutex_lock(&mvm->mutex); |
1738 | ||
723f02ed | 1739 | if (changes & BSS_CHANGED_IDLE && !bss_conf->idle) |
fb98be5e | 1740 | iwl_mvm_scan_offload_stop(mvm, true); |
723f02ed | 1741 | |
8ca151b5 JB |
1742 | switch (vif->type) { |
1743 | case NL80211_IFTYPE_STATION: | |
1744 | iwl_mvm_bss_info_changed_station(mvm, vif, bss_conf, changes); | |
1745 | break; | |
1746 | case NL80211_IFTYPE_AP: | |
5023d966 JB |
1747 | case NL80211_IFTYPE_ADHOC: |
1748 | iwl_mvm_bss_info_changed_ap_ibss(mvm, vif, bss_conf, changes); | |
8ca151b5 JB |
1749 | break; |
1750 | default: | |
1751 | /* shouldn't happen */ | |
1752 | WARN_ON_ONCE(1); | |
1753 | } | |
1754 | ||
1755 | mutex_unlock(&mvm->mutex); | |
576eeee9 | 1756 | iwl_mvm_unref(mvm, IWL_MVM_REF_BSS_CHANGED); |
8ca151b5 JB |
1757 | } |
1758 | ||
4660dfbb EP |
1759 | static int iwl_mvm_cancel_scan_wait_notif(struct iwl_mvm *mvm, |
1760 | enum iwl_scan_status scan_type) | |
1761 | { | |
1762 | int ret; | |
1763 | bool wait_for_handlers = false; | |
1764 | ||
1765 | mutex_lock(&mvm->mutex); | |
1766 | ||
1767 | if (mvm->scan_status != scan_type) { | |
1768 | ret = 0; | |
1769 | /* make sure there are no pending notifications */ | |
1770 | wait_for_handlers = true; | |
1771 | goto out; | |
1772 | } | |
1773 | ||
1774 | switch (scan_type) { | |
1775 | case IWL_MVM_SCAN_SCHED: | |
1776 | ret = iwl_mvm_scan_offload_stop(mvm, true); | |
1777 | break; | |
1778 | case IWL_MVM_SCAN_OS: | |
1779 | ret = iwl_mvm_cancel_scan(mvm); | |
1780 | break; | |
1781 | case IWL_MVM_SCAN_NONE: | |
1782 | default: | |
1783 | WARN_ON_ONCE(1); | |
1784 | ret = -EINVAL; | |
1785 | break; | |
1786 | } | |
1787 | if (ret) | |
1788 | goto out; | |
1789 | ||
1790 | wait_for_handlers = true; | |
1791 | out: | |
1792 | mutex_unlock(&mvm->mutex); | |
1793 | ||
1794 | /* make sure we consume the completion notification */ | |
1795 | if (wait_for_handlers) | |
1796 | iwl_mvm_wait_for_async_handlers(mvm); | |
1797 | ||
1798 | return ret; | |
1799 | } | |
8ca151b5 JB |
1800 | static int iwl_mvm_mac_hw_scan(struct ieee80211_hw *hw, |
1801 | struct ieee80211_vif *vif, | |
c56ef672 | 1802 | struct ieee80211_scan_request *hw_req) |
8ca151b5 JB |
1803 | { |
1804 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
c56ef672 | 1805 | struct cfg80211_scan_request *req = &hw_req->req; |
8ca151b5 JB |
1806 | int ret; |
1807 | ||
762533ba DS |
1808 | if (req->n_channels == 0 || |
1809 | req->n_channels > mvm->fw->ucode_capa.n_scan_channels) | |
8ca151b5 JB |
1810 | return -EINVAL; |
1811 | ||
4660dfbb EP |
1812 | ret = iwl_mvm_cancel_scan_wait_notif(mvm, IWL_MVM_SCAN_SCHED); |
1813 | if (ret) | |
1814 | return ret; | |
1815 | ||
8ca151b5 JB |
1816 | mutex_lock(&mvm->mutex); |
1817 | ||
4660dfbb | 1818 | if (mvm->scan_status != IWL_MVM_SCAN_NONE) { |
8ca151b5 | 1819 | ret = -EBUSY; |
519e2026 AN |
1820 | goto out; |
1821 | } | |
8ca151b5 | 1822 | |
519e2026 AN |
1823 | iwl_mvm_ref(mvm, IWL_MVM_REF_SCAN); |
1824 | ||
fb98be5e DS |
1825 | if (mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_LMAC_SCAN) |
1826 | ret = iwl_mvm_unified_scan_lmac(mvm, vif, hw_req); | |
1827 | else | |
1828 | ret = iwl_mvm_scan_request(mvm, vif, req); | |
1829 | ||
519e2026 AN |
1830 | if (ret) |
1831 | iwl_mvm_unref(mvm, IWL_MVM_REF_SCAN); | |
1832 | out: | |
8ca151b5 | 1833 | mutex_unlock(&mvm->mutex); |
8ca151b5 JB |
1834 | return ret; |
1835 | } | |
1836 | ||
1837 | static void iwl_mvm_mac_cancel_hw_scan(struct ieee80211_hw *hw, | |
1838 | struct ieee80211_vif *vif) | |
1839 | { | |
1840 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1841 | ||
1842 | mutex_lock(&mvm->mutex); | |
1843 | ||
1844 | iwl_mvm_cancel_scan(mvm); | |
1845 | ||
1846 | mutex_unlock(&mvm->mutex); | |
1847 | } | |
1848 | ||
1849 | static void | |
1850 | iwl_mvm_mac_allow_buffered_frames(struct ieee80211_hw *hw, | |
3e56eadf | 1851 | struct ieee80211_sta *sta, u16 tids, |
8ca151b5 JB |
1852 | int num_frames, |
1853 | enum ieee80211_frame_release_type reason, | |
1854 | bool more_data) | |
1855 | { | |
1856 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
8ca151b5 | 1857 | |
3e56eadf | 1858 | /* Called when we need to transmit (a) frame(s) from mac80211 */ |
8ca151b5 | 1859 | |
3e56eadf JB |
1860 | iwl_mvm_sta_modify_sleep_tx_count(mvm, sta, reason, num_frames, |
1861 | tids, more_data, false); | |
1862 | } | |
1863 | ||
1864 | static void | |
1865 | iwl_mvm_mac_release_buffered_frames(struct ieee80211_hw *hw, | |
1866 | struct ieee80211_sta *sta, u16 tids, | |
1867 | int num_frames, | |
1868 | enum ieee80211_frame_release_type reason, | |
1869 | bool more_data) | |
1870 | { | |
1871 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1872 | ||
1873 | /* Called when we need to transmit (a) frame(s) from agg queue */ | |
1874 | ||
1875 | iwl_mvm_sta_modify_sleep_tx_count(mvm, sta, reason, num_frames, | |
1876 | tids, more_data, true); | |
8ca151b5 JB |
1877 | } |
1878 | ||
1879 | static void iwl_mvm_mac_sta_notify(struct ieee80211_hw *hw, | |
1880 | struct ieee80211_vif *vif, | |
1881 | enum sta_notify_cmd cmd, | |
1882 | struct ieee80211_sta *sta) | |
1883 | { | |
1884 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
5b577a90 | 1885 | struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); |
3e56eadf | 1886 | int tid; |
8ca151b5 JB |
1887 | |
1888 | switch (cmd) { | |
1889 | case STA_NOTIFY_SLEEP: | |
e3d4bc8c | 1890 | if (atomic_read(&mvm->pending_frames[mvmsta->sta_id]) > 0) |
8ca151b5 | 1891 | ieee80211_sta_block_awake(hw, sta, true); |
3e56eadf JB |
1892 | spin_lock_bh(&mvmsta->lock); |
1893 | for (tid = 0; tid < IWL_MAX_TID_COUNT; tid++) { | |
1894 | struct iwl_mvm_tid_data *tid_data; | |
1895 | ||
1896 | tid_data = &mvmsta->tid_data[tid]; | |
1897 | if (tid_data->state != IWL_AGG_ON && | |
1898 | tid_data->state != IWL_EMPTYING_HW_QUEUE_DELBA) | |
1899 | continue; | |
1900 | if (iwl_mvm_tid_queued(tid_data) == 0) | |
1901 | continue; | |
1902 | ieee80211_sta_set_buffered(sta, tid, true); | |
1903 | } | |
1904 | spin_unlock_bh(&mvmsta->lock); | |
8ca151b5 JB |
1905 | /* |
1906 | * The fw updates the STA to be asleep. Tx packets on the Tx | |
1907 | * queues to this station will not be transmitted. The fw will | |
1908 | * send a Tx response with TX_STATUS_FAIL_DEST_PS. | |
1909 | */ | |
1910 | break; | |
1911 | case STA_NOTIFY_AWAKE: | |
881acd89 | 1912 | if (WARN_ON(mvmsta->sta_id == IWL_MVM_STATION_COUNT)) |
8ca151b5 | 1913 | break; |
9cc40712 | 1914 | iwl_mvm_sta_modify_ps_wake(mvm, sta); |
8ca151b5 JB |
1915 | break; |
1916 | default: | |
1917 | break; | |
1918 | } | |
1919 | } | |
1920 | ||
1ddbbb0c JB |
1921 | static void iwl_mvm_sta_pre_rcu_remove(struct ieee80211_hw *hw, |
1922 | struct ieee80211_vif *vif, | |
1923 | struct ieee80211_sta *sta) | |
1924 | { | |
1925 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1926 | struct iwl_mvm_sta *mvm_sta = (void *)sta->drv_priv; | |
1927 | ||
1928 | /* | |
1929 | * This is called before mac80211 does RCU synchronisation, | |
1930 | * so here we already invalidate our internal RCU-protected | |
1931 | * station pointer. The rest of the code will thus no longer | |
1932 | * be able to find the station this way, and we don't rely | |
1933 | * on further RCU synchronisation after the sta_state() | |
1934 | * callback deleted the station. | |
1935 | */ | |
1936 | mutex_lock(&mvm->mutex); | |
1937 | if (sta == rcu_access_pointer(mvm->fw_id_to_mac_id[mvm_sta->sta_id])) | |
1938 | rcu_assign_pointer(mvm->fw_id_to_mac_id[mvm_sta->sta_id], | |
1939 | ERR_PTR(-ENOENT)); | |
1940 | mutex_unlock(&mvm->mutex); | |
1941 | } | |
1942 | ||
fa3d07e4 | 1943 | int iwl_mvm_tdls_sta_count(struct iwl_mvm *mvm, struct ieee80211_vif *vif) |
cf7b491d AN |
1944 | { |
1945 | struct ieee80211_sta *sta; | |
fa3d07e4 | 1946 | struct iwl_mvm_sta *mvmsta; |
cf7b491d AN |
1947 | int count = 0; |
1948 | int i; | |
1949 | ||
1950 | lockdep_assert_held(&mvm->mutex); | |
1951 | ||
1952 | for (i = 0; i < IWL_MVM_STATION_COUNT; i++) { | |
1953 | sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i], | |
1954 | lockdep_is_held(&mvm->mutex)); | |
1955 | if (!sta || IS_ERR(sta) || !sta->tdls) | |
1956 | continue; | |
1957 | ||
fa3d07e4 AN |
1958 | if (vif) { |
1959 | mvmsta = iwl_mvm_sta_from_mac80211(sta); | |
1960 | if (mvmsta->vif != vif) | |
1961 | continue; | |
1962 | } | |
1963 | ||
cf7b491d AN |
1964 | count++; |
1965 | } | |
1966 | ||
1967 | return count; | |
1968 | } | |
1969 | ||
fa3d07e4 AN |
1970 | static void iwl_mvm_recalc_tdls_state(struct iwl_mvm *mvm, |
1971 | struct ieee80211_vif *vif, | |
1972 | bool sta_added) | |
1973 | { | |
1974 | int tdls_sta_cnt = iwl_mvm_tdls_sta_count(mvm, vif); | |
1975 | ||
1976 | /* | |
1977 | * Disable ps when the first TDLS sta is added and re-enable it | |
1978 | * when the last TDLS sta is removed | |
1979 | */ | |
1980 | if ((tdls_sta_cnt == 1 && sta_added) || | |
1981 | (tdls_sta_cnt == 0 && !sta_added)) | |
1982 | iwl_mvm_power_update_mac(mvm); | |
1983 | } | |
1984 | ||
8ca151b5 JB |
1985 | static int iwl_mvm_mac_sta_state(struct ieee80211_hw *hw, |
1986 | struct ieee80211_vif *vif, | |
1987 | struct ieee80211_sta *sta, | |
1988 | enum ieee80211_sta_state old_state, | |
1989 | enum ieee80211_sta_state new_state) | |
1990 | { | |
1991 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1992 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
1993 | int ret; | |
1994 | ||
1995 | IWL_DEBUG_MAC80211(mvm, "station %pM state change %d->%d\n", | |
1996 | sta->addr, old_state, new_state); | |
1997 | ||
1998 | /* this would be a mac80211 bug ... but don't crash */ | |
1999 | if (WARN_ON_ONCE(!mvmvif->phy_ctxt)) | |
2000 | return -EINVAL; | |
2001 | ||
2002 | /* if a STA is being removed, reuse its ID */ | |
2003 | flush_work(&mvm->sta_drained_wk); | |
2004 | ||
2005 | mutex_lock(&mvm->mutex); | |
2006 | if (old_state == IEEE80211_STA_NOTEXIST && | |
2007 | new_state == IEEE80211_STA_NONE) { | |
48bc1307 JB |
2008 | /* |
2009 | * Firmware bug - it'll crash if the beacon interval is less | |
2010 | * than 16. We can't avoid connecting at all, so refuse the | |
2011 | * station state change, this will cause mac80211 to abandon | |
2012 | * attempts to connect to this AP, and eventually wpa_s will | |
2013 | * blacklist the AP... | |
2014 | */ | |
2015 | if (vif->type == NL80211_IFTYPE_STATION && | |
2016 | vif->bss_conf.beacon_int < 16) { | |
2017 | IWL_ERR(mvm, | |
2018 | "AP %pM beacon interval is %d, refusing due to firmware bug!\n", | |
2019 | sta->addr, vif->bss_conf.beacon_int); | |
2020 | ret = -EINVAL; | |
2021 | goto out_unlock; | |
2022 | } | |
cf7b491d AN |
2023 | |
2024 | if (sta->tdls && | |
2025 | (vif->p2p || | |
fa3d07e4 AN |
2026 | iwl_mvm_tdls_sta_count(mvm, NULL) == |
2027 | IWL_MVM_TDLS_STA_COUNT || | |
cf7b491d AN |
2028 | iwl_mvm_phy_ctx_count(mvm) > 1)) { |
2029 | IWL_DEBUG_MAC80211(mvm, "refusing TDLS sta\n"); | |
2030 | ret = -EBUSY; | |
2031 | goto out_unlock; | |
2032 | } | |
2033 | ||
8ca151b5 | 2034 | ret = iwl_mvm_add_sta(mvm, vif, sta); |
fa3d07e4 AN |
2035 | if (sta->tdls && ret == 0) |
2036 | iwl_mvm_recalc_tdls_state(mvm, vif, true); | |
8ca151b5 JB |
2037 | } else if (old_state == IEEE80211_STA_NONE && |
2038 | new_state == IEEE80211_STA_AUTH) { | |
e820c2da HD |
2039 | /* |
2040 | * EBS may be disabled due to previous failures reported by FW. | |
2041 | * Reset EBS status here assuming environment has been changed. | |
2042 | */ | |
2043 | mvm->last_ebs_successful = true; | |
8ca151b5 JB |
2044 | ret = 0; |
2045 | } else if (old_state == IEEE80211_STA_AUTH && | |
2046 | new_state == IEEE80211_STA_ASSOC) { | |
7a453973 JB |
2047 | ret = iwl_mvm_update_sta(mvm, vif, sta); |
2048 | if (ret == 0) | |
2049 | iwl_mvm_rs_rate_init(mvm, sta, | |
b87c2179 ES |
2050 | mvmvif->phy_ctxt->channel->band, |
2051 | true); | |
8ca151b5 JB |
2052 | } else if (old_state == IEEE80211_STA_ASSOC && |
2053 | new_state == IEEE80211_STA_AUTHORIZED) { | |
f59e0e3c AN |
2054 | |
2055 | /* we don't support TDLS during DCM */ | |
2056 | if (iwl_mvm_phy_ctx_count(mvm) > 1) | |
2057 | iwl_mvm_teardown_tdls_peers(mvm); | |
2058 | ||
7df15b1e | 2059 | /* enable beacon filtering */ |
fa7b2e7f | 2060 | WARN_ON(iwl_mvm_enable_beacon_filter(mvm, vif, 0)); |
8ca151b5 JB |
2061 | ret = 0; |
2062 | } else if (old_state == IEEE80211_STA_AUTHORIZED && | |
2063 | new_state == IEEE80211_STA_ASSOC) { | |
7df15b1e | 2064 | /* disable beacon filtering */ |
a1022927 | 2065 | WARN_ON(iwl_mvm_disable_beacon_filter(mvm, vif, 0)); |
8ca151b5 JB |
2066 | ret = 0; |
2067 | } else if (old_state == IEEE80211_STA_ASSOC && | |
2068 | new_state == IEEE80211_STA_AUTH) { | |
2069 | ret = 0; | |
2070 | } else if (old_state == IEEE80211_STA_AUTH && | |
2071 | new_state == IEEE80211_STA_NONE) { | |
2072 | ret = 0; | |
2073 | } else if (old_state == IEEE80211_STA_NONE && | |
2074 | new_state == IEEE80211_STA_NOTEXIST) { | |
2075 | ret = iwl_mvm_rm_sta(mvm, vif, sta); | |
fa3d07e4 AN |
2076 | if (sta->tdls) |
2077 | iwl_mvm_recalc_tdls_state(mvm, vif, false); | |
8ca151b5 JB |
2078 | } else { |
2079 | ret = -EIO; | |
2080 | } | |
48bc1307 | 2081 | out_unlock: |
8ca151b5 JB |
2082 | mutex_unlock(&mvm->mutex); |
2083 | ||
2084 | return ret; | |
2085 | } | |
2086 | ||
2087 | static int iwl_mvm_mac_set_rts_threshold(struct ieee80211_hw *hw, u32 value) | |
2088 | { | |
2089 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
2090 | ||
2091 | mvm->rts_threshold = value; | |
2092 | ||
2093 | return 0; | |
2094 | } | |
2095 | ||
1f3b0ff8 LE |
2096 | static void iwl_mvm_sta_rc_update(struct ieee80211_hw *hw, |
2097 | struct ieee80211_vif *vif, | |
2098 | struct ieee80211_sta *sta, u32 changed) | |
2099 | { | |
2100 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
2101 | ||
2102 | if (vif->type == NL80211_IFTYPE_STATION && | |
2103 | changed & IEEE80211_RC_NSS_CHANGED) | |
2104 | iwl_mvm_sf_update(mvm, vif, false); | |
2105 | } | |
2106 | ||
8ca151b5 JB |
2107 | static int iwl_mvm_mac_conf_tx(struct ieee80211_hw *hw, |
2108 | struct ieee80211_vif *vif, u16 ac, | |
2109 | const struct ieee80211_tx_queue_params *params) | |
2110 | { | |
2111 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
2112 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
2113 | ||
2114 | mvmvif->queue_params[ac] = *params; | |
2115 | ||
2116 | /* | |
2117 | * No need to update right away, we'll get BSS_CHANGED_QOS | |
2118 | * The exception is P2P_DEVICE interface which needs immediate update. | |
2119 | */ | |
2120 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { | |
2121 | int ret; | |
2122 | ||
2123 | mutex_lock(&mvm->mutex); | |
bca49d9a | 2124 | ret = iwl_mvm_mac_ctxt_changed(mvm, vif, false); |
8ca151b5 JB |
2125 | mutex_unlock(&mvm->mutex); |
2126 | return ret; | |
2127 | } | |
2128 | return 0; | |
2129 | } | |
2130 | ||
2131 | static void iwl_mvm_mac_mgd_prepare_tx(struct ieee80211_hw *hw, | |
2132 | struct ieee80211_vif *vif) | |
2133 | { | |
2134 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
2135 | u32 duration = min(IWL_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS, | |
2136 | 200 + vif->bss_conf.beacon_int); | |
2137 | u32 min_duration = min(IWL_MVM_TE_SESSION_PROTECTION_MIN_TIME_MS, | |
2138 | 100 + vif->bss_conf.beacon_int); | |
2139 | ||
2140 | if (WARN_ON_ONCE(vif->bss_conf.assoc)) | |
2141 | return; | |
2142 | ||
576eeee9 EP |
2143 | /* |
2144 | * iwl_mvm_protect_session() reads directly from the device | |
2145 | * (the system time), so make sure it is available. | |
2146 | */ | |
2147 | if (iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PREPARE_TX)) | |
2148 | return; | |
2149 | ||
8ca151b5 JB |
2150 | mutex_lock(&mvm->mutex); |
2151 | /* Try really hard to protect the session and hear a beacon */ | |
016d27e1 | 2152 | iwl_mvm_protect_session(mvm, vif, duration, min_duration, 500); |
8ca151b5 | 2153 | mutex_unlock(&mvm->mutex); |
576eeee9 EP |
2154 | |
2155 | iwl_mvm_unref(mvm, IWL_MVM_REF_PREPARE_TX); | |
8ca151b5 JB |
2156 | } |
2157 | ||
07ecd897 AN |
2158 | static void iwl_mvm_mac_mgd_protect_tdls_discover(struct ieee80211_hw *hw, |
2159 | struct ieee80211_vif *vif) | |
2160 | { | |
2161 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
2162 | u32 duration = 2 * vif->bss_conf.dtim_period * vif->bss_conf.beacon_int; | |
2163 | ||
576eeee9 EP |
2164 | /* |
2165 | * iwl_mvm_protect_session() reads directly from the device | |
2166 | * (the system time), so make sure it is available. | |
2167 | */ | |
2168 | if (iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PROTECT_TDLS)) | |
2169 | return; | |
2170 | ||
07ecd897 AN |
2171 | mutex_lock(&mvm->mutex); |
2172 | /* Protect the session to hear the TDLS setup response on the channel */ | |
2173 | iwl_mvm_protect_session(mvm, vif, duration, duration, 100); | |
2174 | mutex_unlock(&mvm->mutex); | |
576eeee9 EP |
2175 | |
2176 | iwl_mvm_unref(mvm, IWL_MVM_REF_PROTECT_TDLS); | |
07ecd897 AN |
2177 | } |
2178 | ||
35a000b7 DS |
2179 | static int iwl_mvm_mac_sched_scan_start(struct ieee80211_hw *hw, |
2180 | struct ieee80211_vif *vif, | |
2181 | struct cfg80211_sched_scan_request *req, | |
633e2713 | 2182 | struct ieee80211_scan_ies *ies) |
35a000b7 DS |
2183 | { |
2184 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
2185 | int ret; | |
2186 | ||
4660dfbb EP |
2187 | ret = iwl_mvm_cancel_scan_wait_notif(mvm, IWL_MVM_SCAN_OS); |
2188 | if (ret) | |
2189 | return ret; | |
2190 | ||
35a000b7 DS |
2191 | mutex_lock(&mvm->mutex); |
2192 | ||
b538b8ce | 2193 | if (!iwl_mvm_is_idle(mvm)) { |
bd5e4744 DS |
2194 | ret = -EBUSY; |
2195 | goto out; | |
2196 | } | |
2197 | ||
4660dfbb | 2198 | if (mvm->scan_status != IWL_MVM_SCAN_NONE) { |
35a000b7 DS |
2199 | ret = -EBUSY; |
2200 | goto out; | |
2201 | } | |
2202 | ||
2203 | mvm->scan_status = IWL_MVM_SCAN_SCHED; | |
2204 | ||
fb98be5e DS |
2205 | if (!(mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_LMAC_SCAN)) { |
2206 | ret = iwl_mvm_config_sched_scan(mvm, vif, req, ies); | |
2207 | if (ret) | |
2208 | goto err; | |
2209 | } | |
35a000b7 DS |
2210 | |
2211 | ret = iwl_mvm_config_sched_scan_profiles(mvm, req); | |
2212 | if (ret) | |
2213 | goto err; | |
2214 | ||
fb98be5e DS |
2215 | if (mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_LMAC_SCAN) |
2216 | ret = iwl_mvm_unified_sched_scan_lmac(mvm, vif, req, ies); | |
2217 | else | |
2218 | ret = iwl_mvm_sched_scan_start(mvm, req); | |
2219 | ||
35a000b7 DS |
2220 | if (!ret) |
2221 | goto out; | |
2222 | err: | |
2223 | mvm->scan_status = IWL_MVM_SCAN_NONE; | |
2224 | out: | |
2225 | mutex_unlock(&mvm->mutex); | |
2226 | return ret; | |
2227 | } | |
2228 | ||
37e3308c JB |
2229 | static int iwl_mvm_mac_sched_scan_stop(struct ieee80211_hw *hw, |
2230 | struct ieee80211_vif *vif) | |
35a000b7 DS |
2231 | { |
2232 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
33ea27f6 | 2233 | int ret; |
35a000b7 DS |
2234 | |
2235 | mutex_lock(&mvm->mutex); | |
fb98be5e | 2236 | ret = iwl_mvm_scan_offload_stop(mvm, false); |
35a000b7 | 2237 | mutex_unlock(&mvm->mutex); |
33ea27f6 | 2238 | iwl_mvm_wait_for_async_handlers(mvm); |
37e3308c | 2239 | |
33ea27f6 | 2240 | return ret; |
35a000b7 DS |
2241 | } |
2242 | ||
8ca151b5 JB |
2243 | static int iwl_mvm_mac_set_key(struct ieee80211_hw *hw, |
2244 | enum set_key_cmd cmd, | |
2245 | struct ieee80211_vif *vif, | |
2246 | struct ieee80211_sta *sta, | |
2247 | struct ieee80211_key_conf *key) | |
2248 | { | |
2249 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
2250 | int ret; | |
2251 | ||
2252 | if (iwlwifi_mod_params.sw_crypto) { | |
2253 | IWL_DEBUG_MAC80211(mvm, "leave - hwcrypto disabled\n"); | |
2254 | return -EOPNOTSUPP; | |
2255 | } | |
2256 | ||
2257 | switch (key->cipher) { | |
2258 | case WLAN_CIPHER_SUITE_TKIP: | |
2259 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; | |
2260 | /* fall-through */ | |
2261 | case WLAN_CIPHER_SUITE_CCMP: | |
2262 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; | |
2263 | break; | |
2264 | case WLAN_CIPHER_SUITE_AES_CMAC: | |
2265 | WARN_ON_ONCE(!(hw->flags & IEEE80211_HW_MFP_CAPABLE)); | |
2266 | break; | |
2267 | case WLAN_CIPHER_SUITE_WEP40: | |
2268 | case WLAN_CIPHER_SUITE_WEP104: | |
2269 | /* | |
2270 | * Support for TX only, at least for now, so accept | |
2271 | * the key and do nothing else. Then mac80211 will | |
2272 | * pass it for TX but we don't have to use it for RX. | |
2273 | */ | |
2274 | return 0; | |
2275 | default: | |
e36e5433 MS |
2276 | /* currently FW supports only one optional cipher scheme */ |
2277 | if (hw->n_cipher_schemes && | |
2278 | hw->cipher_schemes->cipher == key->cipher) | |
2279 | key->flags |= IEEE80211_KEY_FLAG_PUT_IV_SPACE; | |
2280 | else | |
2281 | return -EOPNOTSUPP; | |
8ca151b5 JB |
2282 | } |
2283 | ||
2284 | mutex_lock(&mvm->mutex); | |
2285 | ||
2286 | switch (cmd) { | |
2287 | case SET_KEY: | |
5023d966 JB |
2288 | if ((vif->type == NL80211_IFTYPE_ADHOC || |
2289 | vif->type == NL80211_IFTYPE_AP) && !sta) { | |
2290 | /* | |
2291 | * GTK on AP interface is a TX-only key, return 0; | |
2292 | * on IBSS they're per-station and because we're lazy | |
2293 | * we don't support them for RX, so do the same. | |
2294 | */ | |
6caffd4f JB |
2295 | ret = 0; |
2296 | key->hw_key_idx = STA_KEY_IDX_INVALID; | |
2297 | break; | |
2298 | } | |
2299 | ||
8ca151b5 JB |
2300 | IWL_DEBUG_MAC80211(mvm, "set hwcrypto key\n"); |
2301 | ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, false); | |
2302 | if (ret) { | |
2303 | IWL_WARN(mvm, "set key failed\n"); | |
2304 | /* | |
2305 | * can't add key for RX, but we don't need it | |
2306 | * in the device for TX so still return 0 | |
2307 | */ | |
6caffd4f | 2308 | key->hw_key_idx = STA_KEY_IDX_INVALID; |
8ca151b5 JB |
2309 | ret = 0; |
2310 | } | |
2311 | ||
2312 | break; | |
2313 | case DISABLE_KEY: | |
6caffd4f JB |
2314 | if (key->hw_key_idx == STA_KEY_IDX_INVALID) { |
2315 | ret = 0; | |
2316 | break; | |
2317 | } | |
2318 | ||
8ca151b5 JB |
2319 | IWL_DEBUG_MAC80211(mvm, "disable hwcrypto key\n"); |
2320 | ret = iwl_mvm_remove_sta_key(mvm, vif, sta, key); | |
2321 | break; | |
2322 | default: | |
2323 | ret = -EINVAL; | |
2324 | } | |
2325 | ||
2326 | mutex_unlock(&mvm->mutex); | |
2327 | return ret; | |
2328 | } | |
2329 | ||
2330 | static void iwl_mvm_mac_update_tkip_key(struct ieee80211_hw *hw, | |
2331 | struct ieee80211_vif *vif, | |
2332 | struct ieee80211_key_conf *keyconf, | |
2333 | struct ieee80211_sta *sta, | |
2334 | u32 iv32, u16 *phase1key) | |
2335 | { | |
2336 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
2337 | ||
5023d966 JB |
2338 | if (keyconf->hw_key_idx == STA_KEY_IDX_INVALID) |
2339 | return; | |
2340 | ||
8ca151b5 JB |
2341 | iwl_mvm_update_tkip_key(mvm, vif, keyconf, sta, iv32, phase1key); |
2342 | } | |
2343 | ||
2344 | ||
b112889c AM |
2345 | static bool iwl_mvm_rx_aux_roc(struct iwl_notif_wait_data *notif_wait, |
2346 | struct iwl_rx_packet *pkt, void *data) | |
2347 | { | |
2348 | struct iwl_mvm *mvm = | |
2349 | container_of(notif_wait, struct iwl_mvm, notif_wait); | |
2350 | struct iwl_hs20_roc_res *resp; | |
2351 | int resp_len = iwl_rx_packet_payload_len(pkt); | |
2352 | struct iwl_mvm_time_event_data *te_data = data; | |
2353 | ||
2354 | if (WARN_ON(pkt->hdr.cmd != HOT_SPOT_CMD)) | |
2355 | return true; | |
2356 | ||
2357 | if (WARN_ON_ONCE(resp_len != sizeof(*resp))) { | |
2358 | IWL_ERR(mvm, "Invalid HOT_SPOT_CMD response\n"); | |
2359 | return true; | |
2360 | } | |
2361 | ||
2362 | resp = (void *)pkt->data; | |
2363 | ||
2364 | IWL_DEBUG_TE(mvm, | |
2365 | "Aux ROC: Recieved response from ucode: status=%d uid=%d\n", | |
2366 | resp->status, resp->event_unique_id); | |
2367 | ||
2368 | te_data->uid = le32_to_cpu(resp->event_unique_id); | |
2369 | IWL_DEBUG_TE(mvm, "TIME_EVENT_CMD response - UID = 0x%x\n", | |
2370 | te_data->uid); | |
2371 | ||
2372 | spin_lock_bh(&mvm->time_event_lock); | |
2373 | list_add_tail(&te_data->list, &mvm->aux_roc_te_list); | |
2374 | spin_unlock_bh(&mvm->time_event_lock); | |
2375 | ||
2376 | return true; | |
2377 | } | |
2378 | ||
2379 | #define AUX_ROC_MAX_DELAY_ON_CHANNEL 5000 | |
2380 | static int iwl_mvm_send_aux_roc_cmd(struct iwl_mvm *mvm, | |
2381 | struct ieee80211_channel *channel, | |
2382 | struct ieee80211_vif *vif, | |
2383 | int duration) | |
2384 | { | |
2385 | int res, time_reg = DEVICE_SYSTEM_TIME_REG; | |
2386 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
2387 | struct iwl_mvm_time_event_data *te_data = &mvmvif->hs_time_event_data; | |
2388 | static const u8 time_event_response[] = { HOT_SPOT_CMD }; | |
2389 | struct iwl_notification_wait wait_time_event; | |
2390 | struct iwl_hs20_roc_req aux_roc_req = { | |
2391 | .action = cpu_to_le32(FW_CTXT_ACTION_ADD), | |
2392 | .id_and_color = | |
2393 | cpu_to_le32(FW_CMD_ID_AND_COLOR(MAC_INDEX_AUX, 0)), | |
2394 | .sta_id_and_color = cpu_to_le32(mvm->aux_sta.sta_id), | |
2395 | /* Set the channel info data */ | |
2396 | .channel_info.band = (channel->band == IEEE80211_BAND_2GHZ) ? | |
2397 | PHY_BAND_24 : PHY_BAND_5, | |
2398 | .channel_info.channel = channel->hw_value, | |
2399 | .channel_info.width = PHY_VHT_CHANNEL_MODE20, | |
2400 | /* Set the time and duration */ | |
2401 | .apply_time = cpu_to_le32(iwl_read_prph(mvm->trans, time_reg)), | |
2402 | .apply_time_max_delay = | |
2403 | cpu_to_le32(MSEC_TO_TU(AUX_ROC_MAX_DELAY_ON_CHANNEL)), | |
2404 | .duration = cpu_to_le32(MSEC_TO_TU(duration)), | |
2405 | }; | |
2406 | ||
2407 | /* Set the node address */ | |
2408 | memcpy(aux_roc_req.node_addr, vif->addr, ETH_ALEN); | |
2409 | ||
2410 | te_data->vif = vif; | |
2411 | te_data->duration = duration; | |
2412 | te_data->id = HOT_SPOT_CMD; | |
2413 | ||
2414 | lockdep_assert_held(&mvm->mutex); | |
2415 | ||
2416 | spin_lock_bh(&mvm->time_event_lock); | |
2417 | list_add_tail(&te_data->list, &mvm->time_event_list); | |
2418 | spin_unlock_bh(&mvm->time_event_lock); | |
2419 | ||
2420 | /* | |
2421 | * Use a notification wait, which really just processes the | |
2422 | * command response and doesn't wait for anything, in order | |
2423 | * to be able to process the response and get the UID inside | |
2424 | * the RX path. Using CMD_WANT_SKB doesn't work because it | |
2425 | * stores the buffer and then wakes up this thread, by which | |
2426 | * time another notification (that the time event started) | |
2427 | * might already be processed unsuccessfully. | |
2428 | */ | |
2429 | iwl_init_notification_wait(&mvm->notif_wait, &wait_time_event, | |
2430 | time_event_response, | |
2431 | ARRAY_SIZE(time_event_response), | |
2432 | iwl_mvm_rx_aux_roc, te_data); | |
2433 | ||
2434 | res = iwl_mvm_send_cmd_pdu(mvm, HOT_SPOT_CMD, 0, sizeof(aux_roc_req), | |
2435 | &aux_roc_req); | |
2436 | ||
2437 | if (res) { | |
2438 | IWL_ERR(mvm, "Couldn't send HOT_SPOT_CMD: %d\n", res); | |
2439 | iwl_remove_notification(&mvm->notif_wait, &wait_time_event); | |
2440 | goto out_clear_te; | |
2441 | } | |
2442 | ||
2443 | /* No need to wait for anything, so just pass 1 (0 isn't valid) */ | |
2444 | res = iwl_wait_notification(&mvm->notif_wait, &wait_time_event, 1); | |
2445 | /* should never fail */ | |
2446 | WARN_ON_ONCE(res); | |
2447 | ||
2448 | if (res) { | |
2449 | out_clear_te: | |
2450 | spin_lock_bh(&mvm->time_event_lock); | |
2451 | iwl_mvm_te_clear_data(mvm, te_data); | |
2452 | spin_unlock_bh(&mvm->time_event_lock); | |
2453 | } | |
2454 | ||
2455 | return res; | |
2456 | } | |
2457 | ||
8ca151b5 JB |
2458 | static int iwl_mvm_roc(struct ieee80211_hw *hw, |
2459 | struct ieee80211_vif *vif, | |
2460 | struct ieee80211_channel *channel, | |
d339d5ca IP |
2461 | int duration, |
2462 | enum ieee80211_roc_type type) | |
8ca151b5 JB |
2463 | { |
2464 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
fe0f2de3 | 2465 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
8ca151b5 | 2466 | struct cfg80211_chan_def chandef; |
31d385ae IP |
2467 | struct iwl_mvm_phy_ctxt *phy_ctxt; |
2468 | int ret, i; | |
2469 | ||
2470 | IWL_DEBUG_MAC80211(mvm, "enter (%d, %d, %d)\n", channel->hw_value, | |
2471 | duration, type); | |
8ca151b5 | 2472 | |
b112889c AM |
2473 | switch (vif->type) { |
2474 | case NL80211_IFTYPE_STATION: | |
2475 | /* Use aux roc framework (HS20) */ | |
2476 | ret = iwl_mvm_send_aux_roc_cmd(mvm, channel, | |
2477 | vif, duration); | |
2478 | return ret; | |
2479 | case NL80211_IFTYPE_P2P_DEVICE: | |
2480 | /* handle below */ | |
2481 | break; | |
2482 | default: | |
2483 | IWL_ERR(mvm, "vif isn't P2P_DEVICE: %d\n", vif->type); | |
8ca151b5 JB |
2484 | return -EINVAL; |
2485 | } | |
2486 | ||
8ca151b5 JB |
2487 | mutex_lock(&mvm->mutex); |
2488 | ||
31d385ae IP |
2489 | for (i = 0; i < NUM_PHY_CTX; i++) { |
2490 | phy_ctxt = &mvm->phy_ctxts[i]; | |
2491 | if (phy_ctxt->ref == 0 || mvmvif->phy_ctxt == phy_ctxt) | |
2492 | continue; | |
2493 | ||
2494 | if (phy_ctxt->ref && channel == phy_ctxt->channel) { | |
2495 | /* | |
2496 | * Unbind the P2P_DEVICE from the current PHY context, | |
2497 | * and if the PHY context is not used remove it. | |
2498 | */ | |
2499 | ret = iwl_mvm_binding_remove_vif(mvm, vif); | |
2500 | if (WARN(ret, "Failed unbinding P2P_DEVICE\n")) | |
2501 | goto out_unlock; | |
2502 | ||
2503 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); | |
2504 | ||
2505 | /* Bind the P2P_DEVICE to the current PHY Context */ | |
2506 | mvmvif->phy_ctxt = phy_ctxt; | |
2507 | ||
2508 | ret = iwl_mvm_binding_add_vif(mvm, vif); | |
2509 | if (WARN(ret, "Failed binding P2P_DEVICE\n")) | |
2510 | goto out_unlock; | |
2511 | ||
2512 | iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt); | |
2513 | goto schedule_time_event; | |
2514 | } | |
2515 | } | |
2516 | ||
2517 | /* Need to update the PHY context only if the ROC channel changed */ | |
2518 | if (channel == mvmvif->phy_ctxt->channel) | |
2519 | goto schedule_time_event; | |
2520 | ||
8ca151b5 | 2521 | cfg80211_chandef_create(&chandef, channel, NL80211_CHAN_NO_HT); |
8ca151b5 | 2522 | |
31d385ae IP |
2523 | /* |
2524 | * Change the PHY context configuration as it is currently referenced | |
2525 | * only by the P2P Device MAC | |
2526 | */ | |
2527 | if (mvmvif->phy_ctxt->ref == 1) { | |
2528 | ret = iwl_mvm_phy_ctxt_changed(mvm, mvmvif->phy_ctxt, | |
2529 | &chandef, 1, 1); | |
2530 | if (ret) | |
2531 | goto out_unlock; | |
2532 | } else { | |
2533 | /* | |
2534 | * The PHY context is shared with other MACs. Need to remove the | |
2535 | * P2P Device from the binding, allocate an new PHY context and | |
2536 | * create a new binding | |
2537 | */ | |
2538 | phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm); | |
2539 | if (!phy_ctxt) { | |
2540 | ret = -ENOSPC; | |
2541 | goto out_unlock; | |
2542 | } | |
2543 | ||
2544 | ret = iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &chandef, | |
2545 | 1, 1); | |
2546 | if (ret) { | |
2547 | IWL_ERR(mvm, "Failed to change PHY context\n"); | |
2548 | goto out_unlock; | |
2549 | } | |
2550 | ||
2551 | /* Unbind the P2P_DEVICE from the current PHY context */ | |
2552 | ret = iwl_mvm_binding_remove_vif(mvm, vif); | |
2553 | if (WARN(ret, "Failed unbinding P2P_DEVICE\n")) | |
2554 | goto out_unlock; | |
2555 | ||
2556 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); | |
2557 | ||
2558 | /* Bind the P2P_DEVICE to the new allocated PHY context */ | |
2559 | mvmvif->phy_ctxt = phy_ctxt; | |
2560 | ||
2561 | ret = iwl_mvm_binding_add_vif(mvm, vif); | |
2562 | if (WARN(ret, "Failed binding P2P_DEVICE\n")) | |
2563 | goto out_unlock; | |
2564 | ||
2565 | iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt); | |
2566 | } | |
2567 | ||
2568 | schedule_time_event: | |
8ca151b5 | 2569 | /* Schedule the time events */ |
e635c797 | 2570 | ret = iwl_mvm_start_p2p_roc(mvm, vif, duration, type); |
8ca151b5 | 2571 | |
31d385ae | 2572 | out_unlock: |
8ca151b5 JB |
2573 | mutex_unlock(&mvm->mutex); |
2574 | IWL_DEBUG_MAC80211(mvm, "leave\n"); | |
8ca151b5 JB |
2575 | return ret; |
2576 | } | |
2577 | ||
2578 | static int iwl_mvm_cancel_roc(struct ieee80211_hw *hw) | |
2579 | { | |
2580 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
2581 | ||
2582 | IWL_DEBUG_MAC80211(mvm, "enter\n"); | |
2583 | ||
2584 | mutex_lock(&mvm->mutex); | |
2585 | iwl_mvm_stop_p2p_roc(mvm); | |
2586 | mutex_unlock(&mvm->mutex); | |
2587 | ||
2588 | IWL_DEBUG_MAC80211(mvm, "leave\n"); | |
2589 | return 0; | |
2590 | } | |
2591 | ||
b08c1d97 LC |
2592 | static int __iwl_mvm_add_chanctx(struct iwl_mvm *mvm, |
2593 | struct ieee80211_chanctx_conf *ctx) | |
8ca151b5 | 2594 | { |
fe0f2de3 IP |
2595 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
2596 | struct iwl_mvm_phy_ctxt *phy_ctxt; | |
8ca151b5 JB |
2597 | int ret; |
2598 | ||
b08c1d97 LC |
2599 | lockdep_assert_held(&mvm->mutex); |
2600 | ||
53a9d61e | 2601 | IWL_DEBUG_MAC80211(mvm, "Add channel context\n"); |
fe0f2de3 | 2602 | |
fe0f2de3 IP |
2603 | phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm); |
2604 | if (!phy_ctxt) { | |
2605 | ret = -ENOSPC; | |
2606 | goto out; | |
2607 | } | |
8ca151b5 | 2608 | |
dcbc3e1a | 2609 | ret = iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &ctx->min_def, |
53a9d61e IP |
2610 | ctx->rx_chains_static, |
2611 | ctx->rx_chains_dynamic); | |
fe0f2de3 IP |
2612 | if (ret) { |
2613 | IWL_ERR(mvm, "Failed to add PHY context\n"); | |
2614 | goto out; | |
2615 | } | |
2616 | ||
53a9d61e | 2617 | iwl_mvm_phy_ctxt_ref(mvm, phy_ctxt); |
fe0f2de3 IP |
2618 | *phy_ctxt_id = phy_ctxt->id; |
2619 | out: | |
b08c1d97 LC |
2620 | return ret; |
2621 | } | |
2622 | ||
2623 | static int iwl_mvm_add_chanctx(struct ieee80211_hw *hw, | |
2624 | struct ieee80211_chanctx_conf *ctx) | |
2625 | { | |
2626 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
2627 | int ret; | |
2628 | ||
2629 | mutex_lock(&mvm->mutex); | |
2630 | ret = __iwl_mvm_add_chanctx(mvm, ctx); | |
8ca151b5 | 2631 | mutex_unlock(&mvm->mutex); |
b08c1d97 | 2632 | |
8ca151b5 JB |
2633 | return ret; |
2634 | } | |
2635 | ||
b08c1d97 LC |
2636 | static void __iwl_mvm_remove_chanctx(struct iwl_mvm *mvm, |
2637 | struct ieee80211_chanctx_conf *ctx) | |
2638 | { | |
2639 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; | |
2640 | struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id]; | |
2641 | ||
2642 | lockdep_assert_held(&mvm->mutex); | |
2643 | ||
2644 | iwl_mvm_phy_ctxt_unref(mvm, phy_ctxt); | |
2645 | } | |
2646 | ||
8ca151b5 JB |
2647 | static void iwl_mvm_remove_chanctx(struct ieee80211_hw *hw, |
2648 | struct ieee80211_chanctx_conf *ctx) | |
2649 | { | |
2650 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
8ca151b5 JB |
2651 | |
2652 | mutex_lock(&mvm->mutex); | |
b08c1d97 | 2653 | __iwl_mvm_remove_chanctx(mvm, ctx); |
8ca151b5 JB |
2654 | mutex_unlock(&mvm->mutex); |
2655 | } | |
2656 | ||
2657 | static void iwl_mvm_change_chanctx(struct ieee80211_hw *hw, | |
2658 | struct ieee80211_chanctx_conf *ctx, | |
2659 | u32 changed) | |
2660 | { | |
2661 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
fe0f2de3 IP |
2662 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
2663 | struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id]; | |
8ca151b5 | 2664 | |
31d385ae IP |
2665 | if (WARN_ONCE((phy_ctxt->ref > 1) && |
2666 | (changed & ~(IEEE80211_CHANCTX_CHANGE_WIDTH | | |
2667 | IEEE80211_CHANCTX_CHANGE_RX_CHAINS | | |
2dceedae AN |
2668 | IEEE80211_CHANCTX_CHANGE_RADAR | |
2669 | IEEE80211_CHANCTX_CHANGE_MIN_WIDTH)), | |
31d385ae IP |
2670 | "Cannot change PHY. Ref=%d, changed=0x%X\n", |
2671 | phy_ctxt->ref, changed)) | |
2672 | return; | |
2673 | ||
8ca151b5 | 2674 | mutex_lock(&mvm->mutex); |
4d66449a | 2675 | iwl_mvm_bt_coex_vif_change(mvm); |
dcbc3e1a | 2676 | iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &ctx->min_def, |
8ca151b5 JB |
2677 | ctx->rx_chains_static, |
2678 | ctx->rx_chains_dynamic); | |
2679 | mutex_unlock(&mvm->mutex); | |
2680 | } | |
2681 | ||
b08c1d97 LC |
2682 | static int __iwl_mvm_assign_vif_chanctx(struct iwl_mvm *mvm, |
2683 | struct ieee80211_vif *vif, | |
f0c97783 LC |
2684 | struct ieee80211_chanctx_conf *ctx, |
2685 | bool switching_chanctx) | |
8ca151b5 | 2686 | { |
fe0f2de3 IP |
2687 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
2688 | struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id]; | |
8ca151b5 JB |
2689 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
2690 | int ret; | |
2691 | ||
b08c1d97 | 2692 | lockdep_assert_held(&mvm->mutex); |
8ca151b5 | 2693 | |
fe0f2de3 | 2694 | mvmvif->phy_ctxt = phy_ctxt; |
8ca151b5 JB |
2695 | |
2696 | switch (vif->type) { | |
2697 | case NL80211_IFTYPE_AP: | |
bd3398e2 AO |
2698 | /* Unless it's a CSA flow we have nothing to do here */ |
2699 | if (vif->csa_active) { | |
2700 | mvmvif->ap_ibss_active = true; | |
2701 | break; | |
2702 | } | |
5023d966 | 2703 | case NL80211_IFTYPE_ADHOC: |
8ca151b5 JB |
2704 | /* |
2705 | * The AP binding flow is handled as part of the start_ap flow | |
5023d966 | 2706 | * (in bss_info_changed), similarly for IBSS. |
8ca151b5 JB |
2707 | */ |
2708 | ret = 0; | |
b08c1d97 | 2709 | goto out; |
8ca151b5 | 2710 | case NL80211_IFTYPE_STATION: |
8ca151b5 JB |
2711 | case NL80211_IFTYPE_MONITOR: |
2712 | break; | |
2713 | default: | |
2714 | ret = -EINVAL; | |
b08c1d97 | 2715 | goto out; |
8ca151b5 JB |
2716 | } |
2717 | ||
2718 | ret = iwl_mvm_binding_add_vif(mvm, vif); | |
2719 | if (ret) | |
b08c1d97 | 2720 | goto out; |
8ca151b5 JB |
2721 | |
2722 | /* | |
92d85562 AB |
2723 | * Power state must be updated before quotas, |
2724 | * otherwise fw will complain. | |
2725 | */ | |
999609f1 | 2726 | iwl_mvm_power_update_mac(mvm); |
92d85562 AB |
2727 | |
2728 | /* Setting the quota at this stage is only required for monitor | |
8ca151b5 JB |
2729 | * interfaces. For the other types, the bss_info changed flow |
2730 | * will handle quota settings. | |
2731 | */ | |
2732 | if (vif->type == NL80211_IFTYPE_MONITOR) { | |
1e1391ca | 2733 | mvmvif->monitor_active = true; |
0166230c | 2734 | ret = iwl_mvm_update_quotas(mvm, NULL); |
8ca151b5 JB |
2735 | if (ret) |
2736 | goto out_remove_binding; | |
2737 | } | |
2738 | ||
bd3398e2 | 2739 | /* Handle binding during CSA */ |
f0c97783 LC |
2740 | if ((vif->type == NL80211_IFTYPE_AP) || |
2741 | (switching_chanctx && (vif->type == NL80211_IFTYPE_STATION))) { | |
0166230c | 2742 | iwl_mvm_update_quotas(mvm, NULL); |
bca49d9a | 2743 | iwl_mvm_mac_ctxt_changed(mvm, vif, false); |
bd3398e2 AO |
2744 | } |
2745 | ||
b08c1d97 | 2746 | goto out; |
8ca151b5 | 2747 | |
b08c1d97 | 2748 | out_remove_binding: |
8ca151b5 | 2749 | iwl_mvm_binding_remove_vif(mvm, vif); |
999609f1 | 2750 | iwl_mvm_power_update_mac(mvm); |
b08c1d97 | 2751 | out: |
8ca151b5 JB |
2752 | if (ret) |
2753 | mvmvif->phy_ctxt = NULL; | |
2754 | return ret; | |
2755 | } | |
b08c1d97 LC |
2756 | static int iwl_mvm_assign_vif_chanctx(struct ieee80211_hw *hw, |
2757 | struct ieee80211_vif *vif, | |
2758 | struct ieee80211_chanctx_conf *ctx) | |
8ca151b5 JB |
2759 | { |
2760 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
b08c1d97 | 2761 | int ret; |
8ca151b5 JB |
2762 | |
2763 | mutex_lock(&mvm->mutex); | |
f0c97783 | 2764 | ret = __iwl_mvm_assign_vif_chanctx(mvm, vif, ctx, false); |
b08c1d97 LC |
2765 | mutex_unlock(&mvm->mutex); |
2766 | ||
2767 | return ret; | |
2768 | } | |
2769 | ||
2770 | static void __iwl_mvm_unassign_vif_chanctx(struct iwl_mvm *mvm, | |
2771 | struct ieee80211_vif *vif, | |
f0c97783 LC |
2772 | struct ieee80211_chanctx_conf *ctx, |
2773 | bool switching_chanctx) | |
b08c1d97 LC |
2774 | { |
2775 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
f0c97783 | 2776 | struct ieee80211_vif *disabled_vif = NULL; |
b08c1d97 LC |
2777 | |
2778 | lockdep_assert_held(&mvm->mutex); | |
8ca151b5 JB |
2779 | |
2780 | iwl_mvm_remove_time_event(mvm, mvmvif, &mvmvif->time_event_data); | |
2781 | ||
8ca151b5 | 2782 | switch (vif->type) { |
5023d966 | 2783 | case NL80211_IFTYPE_ADHOC: |
b08c1d97 | 2784 | goto out; |
8ca151b5 | 2785 | case NL80211_IFTYPE_MONITOR: |
1e1391ca | 2786 | mvmvif->monitor_active = false; |
8ca151b5 | 2787 | break; |
bd3398e2 AO |
2788 | case NL80211_IFTYPE_AP: |
2789 | /* This part is triggered only during CSA */ | |
2790 | if (!vif->csa_active || !mvmvif->ap_ibss_active) | |
b08c1d97 | 2791 | goto out; |
bd3398e2 | 2792 | |
003e5236 AO |
2793 | /* Set CS bit on all the stations */ |
2794 | iwl_mvm_modify_all_sta_disable_tx(mvm, mvmvif, true); | |
2795 | ||
2796 | /* Save blocked iface, the timeout is set on the next beacon */ | |
2797 | rcu_assign_pointer(mvm->csa_tx_blocked_vif, vif); | |
2798 | ||
bd3398e2 | 2799 | mvmvif->ap_ibss_active = false; |
f0c97783 LC |
2800 | break; |
2801 | case NL80211_IFTYPE_STATION: | |
2802 | if (!switching_chanctx) | |
2803 | break; | |
2804 | ||
2805 | disabled_vif = vif; | |
2806 | ||
2807 | iwl_mvm_mac_ctxt_changed(mvm, vif, true); | |
2808 | break; | |
8ca151b5 JB |
2809 | default: |
2810 | break; | |
2811 | } | |
2812 | ||
f0c97783 | 2813 | iwl_mvm_update_quotas(mvm, disabled_vif); |
1e1391ca | 2814 | iwl_mvm_binding_remove_vif(mvm, vif); |
1c2abf72 | 2815 | |
b08c1d97 | 2816 | out: |
a11e144e | 2817 | mvmvif->phy_ctxt = NULL; |
999609f1 | 2818 | iwl_mvm_power_update_mac(mvm); |
b08c1d97 LC |
2819 | } |
2820 | ||
2821 | static void iwl_mvm_unassign_vif_chanctx(struct ieee80211_hw *hw, | |
2822 | struct ieee80211_vif *vif, | |
2823 | struct ieee80211_chanctx_conf *ctx) | |
2824 | { | |
2825 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
2826 | ||
2827 | mutex_lock(&mvm->mutex); | |
f0c97783 | 2828 | __iwl_mvm_unassign_vif_chanctx(mvm, vif, ctx, false); |
8ca151b5 JB |
2829 | mutex_unlock(&mvm->mutex); |
2830 | } | |
2831 | ||
b08c1d97 LC |
2832 | static int iwl_mvm_switch_vif_chanctx(struct ieee80211_hw *hw, |
2833 | struct ieee80211_vif_chanctx_switch *vifs, | |
2834 | int n_vifs, | |
2835 | enum ieee80211_chanctx_switch_mode mode) | |
2836 | { | |
2837 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
2838 | int ret; | |
2839 | ||
2840 | /* we only support SWAP_CONTEXTS and with a single-vif right now */ | |
2841 | if (mode != CHANCTX_SWMODE_SWAP_CONTEXTS || n_vifs > 1) | |
2842 | return -EOPNOTSUPP; | |
2843 | ||
2844 | mutex_lock(&mvm->mutex); | |
f0c97783 | 2845 | __iwl_mvm_unassign_vif_chanctx(mvm, vifs[0].vif, vifs[0].old_ctx, true); |
b08c1d97 LC |
2846 | __iwl_mvm_remove_chanctx(mvm, vifs[0].old_ctx); |
2847 | ||
2848 | ret = __iwl_mvm_add_chanctx(mvm, vifs[0].new_ctx); | |
2849 | if (ret) { | |
2850 | IWL_ERR(mvm, "failed to add new_ctx during channel switch\n"); | |
2851 | goto out_reassign; | |
2852 | } | |
2853 | ||
f0c97783 LC |
2854 | ret = __iwl_mvm_assign_vif_chanctx(mvm, vifs[0].vif, vifs[0].new_ctx, |
2855 | true); | |
b08c1d97 LC |
2856 | if (ret) { |
2857 | IWL_ERR(mvm, | |
2858 | "failed to assign new_ctx during channel switch\n"); | |
2859 | goto out_remove; | |
2860 | } | |
2861 | ||
f697267f AN |
2862 | /* we don't support TDLS during DCM - can be caused by channel switch */ |
2863 | if (iwl_mvm_phy_ctx_count(mvm) > 1) | |
2864 | iwl_mvm_teardown_tdls_peers(mvm); | |
2865 | ||
b08c1d97 LC |
2866 | goto out; |
2867 | ||
2868 | out_remove: | |
2869 | __iwl_mvm_remove_chanctx(mvm, vifs[0].new_ctx); | |
2870 | ||
2871 | out_reassign: | |
2872 | ret = __iwl_mvm_add_chanctx(mvm, vifs[0].old_ctx); | |
2873 | if (ret) { | |
2874 | IWL_ERR(mvm, "failed to add old_ctx back after failure.\n"); | |
2875 | goto out_restart; | |
2876 | } | |
2877 | ||
f0c97783 LC |
2878 | ret = __iwl_mvm_assign_vif_chanctx(mvm, vifs[0].vif, vifs[0].old_ctx, |
2879 | true); | |
b08c1d97 LC |
2880 | if (ret) { |
2881 | IWL_ERR(mvm, "failed to reassign old_ctx after failure.\n"); | |
2882 | goto out_restart; | |
2883 | } | |
2884 | ||
2885 | goto out; | |
2886 | ||
2887 | out_restart: | |
2888 | /* things keep failing, better restart the hw */ | |
2889 | iwl_mvm_nic_restart(mvm, false); | |
2890 | ||
2891 | out: | |
2892 | mutex_unlock(&mvm->mutex); | |
2893 | return ret; | |
2894 | } | |
2895 | ||
8ca151b5 JB |
2896 | static int iwl_mvm_set_tim(struct ieee80211_hw *hw, |
2897 | struct ieee80211_sta *sta, | |
2898 | bool set) | |
2899 | { | |
2900 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
2901 | struct iwl_mvm_sta *mvm_sta = (void *)sta->drv_priv; | |
2902 | ||
2903 | if (!mvm_sta || !mvm_sta->vif) { | |
2904 | IWL_ERR(mvm, "Station is not associated to a vif\n"); | |
2905 | return -EINVAL; | |
2906 | } | |
2907 | ||
2908 | return iwl_mvm_mac_ctxt_beacon_changed(mvm, mvm_sta->vif); | |
2909 | } | |
2910 | ||
507cadf2 DS |
2911 | #ifdef CONFIG_NL80211_TESTMODE |
2912 | static const struct nla_policy iwl_mvm_tm_policy[IWL_MVM_TM_ATTR_MAX + 1] = { | |
2913 | [IWL_MVM_TM_ATTR_CMD] = { .type = NLA_U32 }, | |
2914 | [IWL_MVM_TM_ATTR_NOA_DURATION] = { .type = NLA_U32 }, | |
f6c6ad42 | 2915 | [IWL_MVM_TM_ATTR_BEACON_FILTER_STATE] = { .type = NLA_U32 }, |
507cadf2 DS |
2916 | }; |
2917 | ||
2918 | static int __iwl_mvm_mac_testmode_cmd(struct iwl_mvm *mvm, | |
2919 | struct ieee80211_vif *vif, | |
2920 | void *data, int len) | |
2921 | { | |
2922 | struct nlattr *tb[IWL_MVM_TM_ATTR_MAX + 1]; | |
2923 | int err; | |
2924 | u32 noa_duration; | |
2925 | ||
2926 | err = nla_parse(tb, IWL_MVM_TM_ATTR_MAX, data, len, iwl_mvm_tm_policy); | |
2927 | if (err) | |
2928 | return err; | |
2929 | ||
2930 | if (!tb[IWL_MVM_TM_ATTR_CMD]) | |
2931 | return -EINVAL; | |
2932 | ||
2933 | switch (nla_get_u32(tb[IWL_MVM_TM_ATTR_CMD])) { | |
2934 | case IWL_MVM_TM_CMD_SET_NOA: | |
2935 | if (!vif || vif->type != NL80211_IFTYPE_AP || !vif->p2p || | |
2936 | !vif->bss_conf.enable_beacon || | |
2937 | !tb[IWL_MVM_TM_ATTR_NOA_DURATION]) | |
2938 | return -EINVAL; | |
2939 | ||
2940 | noa_duration = nla_get_u32(tb[IWL_MVM_TM_ATTR_NOA_DURATION]); | |
2941 | if (noa_duration >= vif->bss_conf.beacon_int) | |
2942 | return -EINVAL; | |
2943 | ||
2944 | mvm->noa_duration = noa_duration; | |
2945 | mvm->noa_vif = vif; | |
2946 | ||
0166230c | 2947 | return iwl_mvm_update_quotas(mvm, NULL); |
f6c6ad42 JB |
2948 | case IWL_MVM_TM_CMD_SET_BEACON_FILTER: |
2949 | /* must be associated client vif - ignore authorized */ | |
2950 | if (!vif || vif->type != NL80211_IFTYPE_STATION || | |
2951 | !vif->bss_conf.assoc || !vif->bss_conf.dtim_period || | |
2952 | !tb[IWL_MVM_TM_ATTR_BEACON_FILTER_STATE]) | |
2953 | return -EINVAL; | |
2954 | ||
2955 | if (nla_get_u32(tb[IWL_MVM_TM_ATTR_BEACON_FILTER_STATE])) | |
a1022927 EG |
2956 | return iwl_mvm_enable_beacon_filter(mvm, vif, 0); |
2957 | return iwl_mvm_disable_beacon_filter(mvm, vif, 0); | |
507cadf2 DS |
2958 | } |
2959 | ||
2960 | return -EOPNOTSUPP; | |
2961 | } | |
2962 | ||
2963 | static int iwl_mvm_mac_testmode_cmd(struct ieee80211_hw *hw, | |
2964 | struct ieee80211_vif *vif, | |
2965 | void *data, int len) | |
2966 | { | |
2967 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
2968 | int err; | |
2969 | ||
2970 | mutex_lock(&mvm->mutex); | |
2971 | err = __iwl_mvm_mac_testmode_cmd(mvm, vif, data, len); | |
2972 | mutex_unlock(&mvm->mutex); | |
2973 | ||
2974 | return err; | |
2975 | } | |
2976 | #endif | |
2977 | ||
bd3398e2 AO |
2978 | static void iwl_mvm_channel_switch_beacon(struct ieee80211_hw *hw, |
2979 | struct ieee80211_vif *vif, | |
2980 | struct cfg80211_chan_def *chandef) | |
2981 | { | |
2982 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
664322fa | 2983 | struct ieee80211_vif *csa_vif; |
bd3398e2 AO |
2984 | |
2985 | mutex_lock(&mvm->mutex); | |
664322fa AO |
2986 | |
2987 | csa_vif = rcu_dereference_protected(mvm->csa_vif, | |
2988 | lockdep_is_held(&mvm->mutex)); | |
2989 | if (WARN(csa_vif && csa_vif->csa_active, | |
bd3398e2 AO |
2990 | "Another CSA is already in progress")) |
2991 | goto out_unlock; | |
2992 | ||
2993 | IWL_DEBUG_MAC80211(mvm, "CSA started to freq %d\n", | |
2994 | chandef->center_freq1); | |
664322fa | 2995 | rcu_assign_pointer(mvm->csa_vif, vif); |
bd3398e2 AO |
2996 | |
2997 | out_unlock: | |
2998 | mutex_unlock(&mvm->mutex); | |
2999 | } | |
3000 | ||
c5b0e7c0 EG |
3001 | static void iwl_mvm_mac_flush(struct ieee80211_hw *hw, |
3002 | struct ieee80211_vif *vif, u32 queues, bool drop) | |
3003 | { | |
3004 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
3005 | struct iwl_mvm_vif *mvmvif; | |
3006 | struct iwl_mvm_sta *mvmsta; | |
3007 | ||
3008 | if (!vif || vif->type != NL80211_IFTYPE_STATION) | |
3009 | return; | |
3010 | ||
3011 | mutex_lock(&mvm->mutex); | |
3012 | mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
3013 | mvmsta = iwl_mvm_sta_from_staid_protected(mvm, mvmvif->ap_sta_id); | |
3014 | ||
3015 | if (WARN_ON_ONCE(!mvmsta)) | |
3016 | goto done; | |
3017 | ||
3018 | if (drop) { | |
3019 | if (iwl_mvm_flush_tx_path(mvm, mvmsta->tfd_queue_msk, true)) | |
3020 | IWL_ERR(mvm, "flush request fail\n"); | |
3021 | } else { | |
3022 | iwl_trans_wait_tx_queue_empty(mvm->trans, | |
3023 | mvmsta->tfd_queue_msk); | |
3024 | } | |
3025 | done: | |
3026 | mutex_unlock(&mvm->mutex); | |
3027 | } | |
3028 | ||
e5209263 | 3029 | const struct ieee80211_ops iwl_mvm_hw_ops = { |
8ca151b5 JB |
3030 | .tx = iwl_mvm_mac_tx, |
3031 | .ampdu_action = iwl_mvm_mac_ampdu_action, | |
3032 | .start = iwl_mvm_mac_start, | |
3033 | .restart_complete = iwl_mvm_mac_restart_complete, | |
3034 | .stop = iwl_mvm_mac_stop, | |
3035 | .add_interface = iwl_mvm_mac_add_interface, | |
3036 | .remove_interface = iwl_mvm_mac_remove_interface, | |
3037 | .config = iwl_mvm_mac_config, | |
e59647ea | 3038 | .prepare_multicast = iwl_mvm_prepare_multicast, |
8ca151b5 JB |
3039 | .configure_filter = iwl_mvm_configure_filter, |
3040 | .bss_info_changed = iwl_mvm_bss_info_changed, | |
3041 | .hw_scan = iwl_mvm_mac_hw_scan, | |
3042 | .cancel_hw_scan = iwl_mvm_mac_cancel_hw_scan, | |
1ddbbb0c | 3043 | .sta_pre_rcu_remove = iwl_mvm_sta_pre_rcu_remove, |
8ca151b5 JB |
3044 | .sta_state = iwl_mvm_mac_sta_state, |
3045 | .sta_notify = iwl_mvm_mac_sta_notify, | |
3046 | .allow_buffered_frames = iwl_mvm_mac_allow_buffered_frames, | |
3e56eadf | 3047 | .release_buffered_frames = iwl_mvm_mac_release_buffered_frames, |
8ca151b5 | 3048 | .set_rts_threshold = iwl_mvm_mac_set_rts_threshold, |
1f3b0ff8 | 3049 | .sta_rc_update = iwl_mvm_sta_rc_update, |
8ca151b5 JB |
3050 | .conf_tx = iwl_mvm_mac_conf_tx, |
3051 | .mgd_prepare_tx = iwl_mvm_mac_mgd_prepare_tx, | |
07ecd897 | 3052 | .mgd_protect_tdls_discover = iwl_mvm_mac_mgd_protect_tdls_discover, |
c5b0e7c0 | 3053 | .flush = iwl_mvm_mac_flush, |
35a000b7 DS |
3054 | .sched_scan_start = iwl_mvm_mac_sched_scan_start, |
3055 | .sched_scan_stop = iwl_mvm_mac_sched_scan_stop, | |
8ca151b5 JB |
3056 | .set_key = iwl_mvm_mac_set_key, |
3057 | .update_tkip_key = iwl_mvm_mac_update_tkip_key, | |
3058 | .remain_on_channel = iwl_mvm_roc, | |
3059 | .cancel_remain_on_channel = iwl_mvm_cancel_roc, | |
8ca151b5 JB |
3060 | .add_chanctx = iwl_mvm_add_chanctx, |
3061 | .remove_chanctx = iwl_mvm_remove_chanctx, | |
3062 | .change_chanctx = iwl_mvm_change_chanctx, | |
3063 | .assign_vif_chanctx = iwl_mvm_assign_vif_chanctx, | |
3064 | .unassign_vif_chanctx = iwl_mvm_unassign_vif_chanctx, | |
b08c1d97 | 3065 | .switch_vif_chanctx = iwl_mvm_switch_vif_chanctx, |
8ca151b5 | 3066 | |
5023d966 JB |
3067 | .start_ap = iwl_mvm_start_ap_ibss, |
3068 | .stop_ap = iwl_mvm_stop_ap_ibss, | |
3069 | .join_ibss = iwl_mvm_start_ap_ibss, | |
3070 | .leave_ibss = iwl_mvm_stop_ap_ibss, | |
8ca151b5 JB |
3071 | |
3072 | .set_tim = iwl_mvm_set_tim, | |
3073 | ||
bd3398e2 AO |
3074 | .channel_switch_beacon = iwl_mvm_channel_switch_beacon, |
3075 | ||
507cadf2 DS |
3076 | CFG80211_TESTMODE_CMD(iwl_mvm_mac_testmode_cmd) |
3077 | ||
8ca151b5 JB |
3078 | #ifdef CONFIG_PM_SLEEP |
3079 | /* look at d3.c */ | |
3080 | .suspend = iwl_mvm_suspend, | |
3081 | .resume = iwl_mvm_resume, | |
3082 | .set_wakeup = iwl_mvm_set_wakeup, | |
3083 | .set_rekey_data = iwl_mvm_set_rekey_data, | |
3084 | #if IS_ENABLED(CONFIG_IPV6) | |
3085 | .ipv6_addr_change = iwl_mvm_ipv6_addr_change, | |
3086 | #endif | |
3087 | .set_default_unicast_key = iwl_mvm_set_default_unicast_key, | |
3088 | #endif | |
3089 | }; |