blob: 123a44f031a79cde0fb9ae29db32cfc3394e86ff [file] [log] [blame]
Johannes Berg8ca151b2013-01-24 14:25:36 +01001/******************************************************************************
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 *
8 * Copyright(c) 2012 - 2013 Intel Corporation. All rights reserved.
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
Emmanuel Grumbach410dc5a2013-02-18 09:22:28 +020025 * in the file called COPYING.
Johannes Berg8ca151b2013-01-24 14:25:36 +010026 *
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 *
33 * Copyright(c) 2012 - 2013 Intel Corporation. All rights reserved.
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
Johannes Bergf444eb12013-02-26 12:04:18 +010064#include <linux/etherdevice.h>
Johannes Bergf0c26462013-01-22 20:41:58 +010065#include <linux/ip.h>
Johannes Bergdebff612013-05-14 13:53:45 +020066#include <linux/fs.h>
Johannes Berg8ca151b2013-01-24 14:25:36 +010067#include <net/cfg80211.h>
68#include <net/ipv6.h>
Johannes Bergf0c26462013-01-22 20:41:58 +010069#include <net/tcp.h>
Johannes Berg8ca151b2013-01-24 14:25:36 +010070#include "iwl-modparams.h"
71#include "fw-api.h"
72#include "mvm.h"
73
74void iwl_mvm_set_rekey_data(struct ieee80211_hw *hw,
75 struct ieee80211_vif *vif,
76 struct cfg80211_gtk_rekey_data *data)
77{
78 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
79 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
80
81 if (iwlwifi_mod_params.sw_crypto)
82 return;
83
84 mutex_lock(&mvm->mutex);
85
86 memcpy(mvmvif->rekey_data.kek, data->kek, NL80211_KEK_LEN);
87 memcpy(mvmvif->rekey_data.kck, data->kck, NL80211_KCK_LEN);
88 mvmvif->rekey_data.replay_ctr =
89 cpu_to_le64(be64_to_cpup((__be64 *)&data->replay_ctr));
90 mvmvif->rekey_data.valid = true;
91
92 mutex_unlock(&mvm->mutex);
93}
94
95#if IS_ENABLED(CONFIG_IPV6)
96void iwl_mvm_ipv6_addr_change(struct ieee80211_hw *hw,
97 struct ieee80211_vif *vif,
98 struct inet6_dev *idev)
99{
100 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
101 struct inet6_ifaddr *ifa;
102 int idx = 0;
103
Emmanuel Grumbacha3777e02013-02-10 13:07:08 +0200104 read_lock_bh(&idev->lock);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100105 list_for_each_entry(ifa, &idev->addr_list, if_list) {
106 mvmvif->target_ipv6_addrs[idx] = ifa->addr;
107 idx++;
Johannes Berg5369d6c2013-07-08 11:17:06 +0200108 if (idx >= IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX)
Johannes Berg8ca151b2013-01-24 14:25:36 +0100109 break;
110 }
Emmanuel Grumbacha3777e02013-02-10 13:07:08 +0200111 read_unlock_bh(&idev->lock);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100112
113 mvmvif->num_target_ipv6_addrs = idx;
114}
115#endif
116
117void iwl_mvm_set_default_unicast_key(struct ieee80211_hw *hw,
118 struct ieee80211_vif *vif, int idx)
119{
120 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
121
122 mvmvif->tx_key_idx = idx;
123}
124
125static void iwl_mvm_convert_p1k(u16 *p1k, __le16 *out)
126{
127 int i;
128
129 for (i = 0; i < IWL_P1K_SIZE; i++)
130 out[i] = cpu_to_le16(p1k[i]);
131}
132
133struct wowlan_key_data {
134 struct iwl_wowlan_rsc_tsc_params_cmd *rsc_tsc;
135 struct iwl_wowlan_tkip_params_cmd *tkip;
136 bool error, use_rsc_tsc, use_tkip;
Johannes Berg5312e542013-07-22 18:26:56 +0200137 int wep_key_idx;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100138};
139
140static void iwl_mvm_wowlan_program_keys(struct ieee80211_hw *hw,
141 struct ieee80211_vif *vif,
142 struct ieee80211_sta *sta,
143 struct ieee80211_key_conf *key,
144 void *_data)
145{
146 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
147 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
148 struct wowlan_key_data *data = _data;
149 struct aes_sc *aes_sc, *aes_tx_sc = NULL;
150 struct tkip_sc *tkip_sc, *tkip_tx_sc = NULL;
151 struct iwl_p1k_cache *rx_p1ks;
152 u8 *rx_mic_key;
153 struct ieee80211_key_seq seq;
154 u32 cur_rx_iv32 = 0;
155 u16 p1k[IWL_P1K_SIZE];
156 int ret, i;
157
158 mutex_lock(&mvm->mutex);
159
160 switch (key->cipher) {
161 case WLAN_CIPHER_SUITE_WEP40:
162 case WLAN_CIPHER_SUITE_WEP104: { /* hack it for now */
163 struct {
164 struct iwl_mvm_wep_key_cmd wep_key_cmd;
165 struct iwl_mvm_wep_key wep_key;
166 } __packed wkc = {
167 .wep_key_cmd.mac_id_n_color =
168 cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id,
169 mvmvif->color)),
170 .wep_key_cmd.num_keys = 1,
171 /* firmware sets STA_KEY_FLG_WEP_13BYTES */
172 .wep_key_cmd.decryption_type = STA_KEY_FLG_WEP,
173 .wep_key.key_index = key->keyidx,
174 .wep_key.key_size = key->keylen,
175 };
176
177 /*
178 * This will fail -- the key functions don't set support
179 * pairwise WEP keys. However, that's better than silently
180 * failing WoWLAN. Or maybe not?
181 */
182 if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE)
183 break;
184
185 memcpy(&wkc.wep_key.key[3], key->key, key->keylen);
186 if (key->keyidx == mvmvif->tx_key_idx) {
187 /* TX key must be at offset 0 */
188 wkc.wep_key.key_offset = 0;
189 } else {
190 /* others start at 1 */
Johannes Berg5312e542013-07-22 18:26:56 +0200191 data->wep_key_idx++;
192 wkc.wep_key.key_offset = data->wep_key_idx;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100193 }
194
195 ret = iwl_mvm_send_cmd_pdu(mvm, WEP_KEY, CMD_SYNC,
196 sizeof(wkc), &wkc);
197 data->error = ret != 0;
198
Johannes Bergf444eb12013-02-26 12:04:18 +0100199 mvm->ptk_ivlen = key->iv_len;
200 mvm->ptk_icvlen = key->icv_len;
201 mvm->gtk_ivlen = key->iv_len;
202 mvm->gtk_icvlen = key->icv_len;
203
Johannes Berg8ca151b2013-01-24 14:25:36 +0100204 /* don't upload key again */
205 goto out_unlock;
206 }
207 default:
208 data->error = true;
209 goto out_unlock;
210 case WLAN_CIPHER_SUITE_AES_CMAC:
211 /*
212 * Ignore CMAC keys -- the WoWLAN firmware doesn't support them
213 * but we also shouldn't abort suspend due to that. It does have
214 * support for the IGTK key renewal, but doesn't really use the
215 * IGTK for anything. This means we could spuriously wake up or
216 * be deauthenticated, but that was considered acceptable.
217 */
218 goto out_unlock;
219 case WLAN_CIPHER_SUITE_TKIP:
220 if (sta) {
221 tkip_sc = data->rsc_tsc->all_tsc_rsc.tkip.unicast_rsc;
222 tkip_tx_sc = &data->rsc_tsc->all_tsc_rsc.tkip.tsc;
223
224 rx_p1ks = data->tkip->rx_uni;
225
226 ieee80211_get_key_tx_seq(key, &seq);
227 tkip_tx_sc->iv16 = cpu_to_le16(seq.tkip.iv16);
228 tkip_tx_sc->iv32 = cpu_to_le32(seq.tkip.iv32);
229
230 ieee80211_get_tkip_p1k_iv(key, seq.tkip.iv32, p1k);
231 iwl_mvm_convert_p1k(p1k, data->tkip->tx.p1k);
232
233 memcpy(data->tkip->mic_keys.tx,
234 &key->key[NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY],
235 IWL_MIC_KEY_SIZE);
236
237 rx_mic_key = data->tkip->mic_keys.rx_unicast;
238 } else {
239 tkip_sc =
240 data->rsc_tsc->all_tsc_rsc.tkip.multicast_rsc;
241 rx_p1ks = data->tkip->rx_multi;
242 rx_mic_key = data->tkip->mic_keys.rx_mcast;
243 }
244
245 /*
246 * For non-QoS this relies on the fact that both the uCode and
247 * mac80211 use TID 0 (as they need to to avoid replay attacks)
248 * for checking the IV in the frames.
249 */
250 for (i = 0; i < IWL_NUM_RSC; i++) {
251 ieee80211_get_key_rx_seq(key, i, &seq);
252 tkip_sc[i].iv16 = cpu_to_le16(seq.tkip.iv16);
253 tkip_sc[i].iv32 = cpu_to_le32(seq.tkip.iv32);
254 /* wrapping isn't allowed, AP must rekey */
255 if (seq.tkip.iv32 > cur_rx_iv32)
256 cur_rx_iv32 = seq.tkip.iv32;
257 }
258
259 ieee80211_get_tkip_rx_p1k(key, vif->bss_conf.bssid,
260 cur_rx_iv32, p1k);
261 iwl_mvm_convert_p1k(p1k, rx_p1ks[0].p1k);
262 ieee80211_get_tkip_rx_p1k(key, vif->bss_conf.bssid,
263 cur_rx_iv32 + 1, p1k);
264 iwl_mvm_convert_p1k(p1k, rx_p1ks[1].p1k);
265
266 memcpy(rx_mic_key,
267 &key->key[NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY],
268 IWL_MIC_KEY_SIZE);
269
270 data->use_tkip = true;
271 data->use_rsc_tsc = true;
272 break;
273 case WLAN_CIPHER_SUITE_CCMP:
274 if (sta) {
275 u8 *pn = seq.ccmp.pn;
276
277 aes_sc = data->rsc_tsc->all_tsc_rsc.aes.unicast_rsc;
278 aes_tx_sc = &data->rsc_tsc->all_tsc_rsc.aes.tsc;
279
280 ieee80211_get_key_tx_seq(key, &seq);
281 aes_tx_sc->pn = cpu_to_le64((u64)pn[5] |
282 ((u64)pn[4] << 8) |
283 ((u64)pn[3] << 16) |
284 ((u64)pn[2] << 24) |
285 ((u64)pn[1] << 32) |
286 ((u64)pn[0] << 40));
287 } else {
288 aes_sc = data->rsc_tsc->all_tsc_rsc.aes.multicast_rsc;
289 }
290
291 /*
292 * For non-QoS this relies on the fact that both the uCode and
293 * mac80211 use TID 0 for checking the IV in the frames.
294 */
295 for (i = 0; i < IWL_NUM_RSC; i++) {
296 u8 *pn = seq.ccmp.pn;
297
298 ieee80211_get_key_rx_seq(key, i, &seq);
299 aes_sc->pn = cpu_to_le64((u64)pn[5] |
300 ((u64)pn[4] << 8) |
301 ((u64)pn[3] << 16) |
302 ((u64)pn[2] << 24) |
303 ((u64)pn[1] << 32) |
304 ((u64)pn[0] << 40));
305 }
306 data->use_rsc_tsc = true;
307 break;
308 }
309
310 /*
311 * The D3 firmware hardcodes the key offset 0 as the key it uses
312 * to transmit packets to the AP, i.e. the PTK.
313 */
314 if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) {
315 key->hw_key_idx = 0;
Johannes Bergf444eb12013-02-26 12:04:18 +0100316 mvm->ptk_ivlen = key->iv_len;
317 mvm->ptk_icvlen = key->icv_len;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100318 } else {
Johannes Berg5312e542013-07-22 18:26:56 +0200319 /*
320 * firmware only supports TSC/RSC for a single key,
321 * so if there are multiple keep overwriting them
322 * with new ones -- this relies on mac80211 doing
323 * list_add_tail().
324 */
325 key->hw_key_idx = 1;
Johannes Bergf444eb12013-02-26 12:04:18 +0100326 mvm->gtk_ivlen = key->iv_len;
327 mvm->gtk_icvlen = key->icv_len;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100328 }
329
330 ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, true);
331 data->error = ret != 0;
332out_unlock:
333 mutex_unlock(&mvm->mutex);
334}
335
336static int iwl_mvm_send_patterns(struct iwl_mvm *mvm,
337 struct cfg80211_wowlan *wowlan)
338{
339 struct iwl_wowlan_patterns_cmd *pattern_cmd;
340 struct iwl_host_cmd cmd = {
341 .id = WOWLAN_PATTERNS,
342 .dataflags[0] = IWL_HCMD_DFL_NOCOPY,
343 .flags = CMD_SYNC,
344 };
345 int i, err;
346
347 if (!wowlan->n_patterns)
348 return 0;
349
350 cmd.len[0] = sizeof(*pattern_cmd) +
351 wowlan->n_patterns * sizeof(struct iwl_wowlan_pattern);
352
353 pattern_cmd = kmalloc(cmd.len[0], GFP_KERNEL);
354 if (!pattern_cmd)
355 return -ENOMEM;
356
357 pattern_cmd->n_patterns = cpu_to_le32(wowlan->n_patterns);
358
359 for (i = 0; i < wowlan->n_patterns; i++) {
360 int mask_len = DIV_ROUND_UP(wowlan->patterns[i].pattern_len, 8);
361
362 memcpy(&pattern_cmd->patterns[i].mask,
363 wowlan->patterns[i].mask, mask_len);
364 memcpy(&pattern_cmd->patterns[i].pattern,
365 wowlan->patterns[i].pattern,
366 wowlan->patterns[i].pattern_len);
367 pattern_cmd->patterns[i].mask_size = mask_len;
368 pattern_cmd->patterns[i].pattern_size =
369 wowlan->patterns[i].pattern_len;
370 }
371
372 cmd.data[0] = pattern_cmd;
373 err = iwl_mvm_send_cmd(mvm, &cmd);
374 kfree(pattern_cmd);
375 return err;
376}
377
378static int iwl_mvm_send_proto_offload(struct iwl_mvm *mvm,
379 struct ieee80211_vif *vif)
380{
Johannes Berg5369d6c2013-07-08 11:17:06 +0200381 union {
382 struct iwl_proto_offload_cmd_v1 v1;
383 struct iwl_proto_offload_cmd_v2 v2;
384 } cmd = {};
385 struct iwl_proto_offload_cmd_common *common;
386 u32 enabled = 0, size;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100387#if IS_ENABLED(CONFIG_IPV6)
388 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
389 int i;
390
Johannes Berg5369d6c2013-07-08 11:17:06 +0200391 if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_D3_6_IPV6_ADDRS) {
392 if (mvmvif->num_target_ipv6_addrs) {
393 enabled |= IWL_D3_PROTO_OFFLOAD_NS;
394 memcpy(cmd.v2.ndp_mac_addr, vif->addr, ETH_ALEN);
395 }
396
397 BUILD_BUG_ON(sizeof(cmd.v2.target_ipv6_addr[0]) !=
398 sizeof(mvmvif->target_ipv6_addrs[0]));
399
400 for (i = 0; i < min(mvmvif->num_target_ipv6_addrs,
401 IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V2); i++)
402 memcpy(cmd.v2.target_ipv6_addr[i],
403 &mvmvif->target_ipv6_addrs[i],
404 sizeof(cmd.v2.target_ipv6_addr[i]));
405 } else {
406 if (mvmvif->num_target_ipv6_addrs) {
407 enabled |= IWL_D3_PROTO_OFFLOAD_NS;
408 memcpy(cmd.v1.ndp_mac_addr, vif->addr, ETH_ALEN);
409 }
410
411 BUILD_BUG_ON(sizeof(cmd.v1.target_ipv6_addr[0]) !=
412 sizeof(mvmvif->target_ipv6_addrs[0]));
413
414 for (i = 0; i < min(mvmvif->num_target_ipv6_addrs,
415 IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V1); i++)
416 memcpy(cmd.v1.target_ipv6_addr[i],
417 &mvmvif->target_ipv6_addrs[i],
418 sizeof(cmd.v1.target_ipv6_addr[i]));
Johannes Berg8ca151b2013-01-24 14:25:36 +0100419 }
Johannes Berg8ca151b2013-01-24 14:25:36 +0100420#endif
421
Johannes Berg5369d6c2013-07-08 11:17:06 +0200422 if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_D3_6_IPV6_ADDRS) {
423 common = &cmd.v2.common;
424 size = sizeof(cmd.v2);
425 } else {
426 common = &cmd.v1.common;
427 size = sizeof(cmd.v1);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100428 }
429
Johannes Berg5369d6c2013-07-08 11:17:06 +0200430 if (vif->bss_conf.arp_addr_cnt) {
431 enabled |= IWL_D3_PROTO_OFFLOAD_ARP;
432 common->host_ipv4_addr = vif->bss_conf.arp_addr_list[0];
433 memcpy(common->arp_mac_addr, vif->addr, ETH_ALEN);
434 }
435
436 if (!enabled)
Johannes Berg8ca151b2013-01-24 14:25:36 +0100437 return 0;
438
Johannes Berg5369d6c2013-07-08 11:17:06 +0200439 common->enabled = cpu_to_le32(enabled);
440
Johannes Berg8ca151b2013-01-24 14:25:36 +0100441 return iwl_mvm_send_cmd_pdu(mvm, PROT_OFFLOAD_CONFIG_CMD, CMD_SYNC,
Johannes Berg5369d6c2013-07-08 11:17:06 +0200442 size, &cmd);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100443}
444
Johannes Bergf0c26462013-01-22 20:41:58 +0100445enum iwl_mvm_tcp_packet_type {
446 MVM_TCP_TX_SYN,
447 MVM_TCP_RX_SYNACK,
448 MVM_TCP_TX_DATA,
449 MVM_TCP_RX_ACK,
450 MVM_TCP_RX_WAKE,
451 MVM_TCP_TX_FIN,
452};
453
454static __le16 pseudo_hdr_check(int len, __be32 saddr, __be32 daddr)
455{
456 __sum16 check = tcp_v4_check(len, saddr, daddr, 0);
457 return cpu_to_le16(be16_to_cpu((__force __be16)check));
458}
459
Oren Givonb002c7e2013-06-12 20:37:03 +0300460static void iwl_mvm_build_tcp_packet(struct ieee80211_vif *vif,
Johannes Bergf0c26462013-01-22 20:41:58 +0100461 struct cfg80211_wowlan_tcp *tcp,
462 void *_pkt, u8 *mask,
463 __le16 *pseudo_hdr_csum,
464 enum iwl_mvm_tcp_packet_type ptype)
465{
466 struct {
467 struct ethhdr eth;
468 struct iphdr ip;
469 struct tcphdr tcp;
470 u8 data[];
471 } __packed *pkt = _pkt;
472 u16 ip_tot_len = sizeof(struct iphdr) + sizeof(struct tcphdr);
473 int i;
474
475 pkt->eth.h_proto = cpu_to_be16(ETH_P_IP),
476 pkt->ip.version = 4;
477 pkt->ip.ihl = 5;
478 pkt->ip.protocol = IPPROTO_TCP;
479
480 switch (ptype) {
481 case MVM_TCP_TX_SYN:
482 case MVM_TCP_TX_DATA:
483 case MVM_TCP_TX_FIN:
484 memcpy(pkt->eth.h_dest, tcp->dst_mac, ETH_ALEN);
485 memcpy(pkt->eth.h_source, vif->addr, ETH_ALEN);
486 pkt->ip.ttl = 128;
487 pkt->ip.saddr = tcp->src;
488 pkt->ip.daddr = tcp->dst;
489 pkt->tcp.source = cpu_to_be16(tcp->src_port);
490 pkt->tcp.dest = cpu_to_be16(tcp->dst_port);
491 /* overwritten for TX SYN later */
492 pkt->tcp.doff = sizeof(struct tcphdr) / 4;
493 pkt->tcp.window = cpu_to_be16(65000);
494 break;
495 case MVM_TCP_RX_SYNACK:
496 case MVM_TCP_RX_ACK:
497 case MVM_TCP_RX_WAKE:
498 memcpy(pkt->eth.h_dest, vif->addr, ETH_ALEN);
499 memcpy(pkt->eth.h_source, tcp->dst_mac, ETH_ALEN);
500 pkt->ip.saddr = tcp->dst;
501 pkt->ip.daddr = tcp->src;
502 pkt->tcp.source = cpu_to_be16(tcp->dst_port);
503 pkt->tcp.dest = cpu_to_be16(tcp->src_port);
504 break;
505 default:
506 WARN_ON(1);
507 return;
508 }
509
510 switch (ptype) {
511 case MVM_TCP_TX_SYN:
512 /* firmware assumes 8 option bytes - 8 NOPs for now */
513 memset(pkt->data, 0x01, 8);
514 ip_tot_len += 8;
515 pkt->tcp.doff = (sizeof(struct tcphdr) + 8) / 4;
516 pkt->tcp.syn = 1;
517 break;
518 case MVM_TCP_TX_DATA:
519 ip_tot_len += tcp->payload_len;
520 memcpy(pkt->data, tcp->payload, tcp->payload_len);
521 pkt->tcp.psh = 1;
522 pkt->tcp.ack = 1;
523 break;
524 case MVM_TCP_TX_FIN:
525 pkt->tcp.fin = 1;
526 pkt->tcp.ack = 1;
527 break;
528 case MVM_TCP_RX_SYNACK:
529 pkt->tcp.syn = 1;
530 pkt->tcp.ack = 1;
531 break;
532 case MVM_TCP_RX_ACK:
533 pkt->tcp.ack = 1;
534 break;
535 case MVM_TCP_RX_WAKE:
536 ip_tot_len += tcp->wake_len;
537 pkt->tcp.psh = 1;
538 pkt->tcp.ack = 1;
539 memcpy(pkt->data, tcp->wake_data, tcp->wake_len);
540 break;
541 }
542
543 switch (ptype) {
544 case MVM_TCP_TX_SYN:
545 case MVM_TCP_TX_DATA:
546 case MVM_TCP_TX_FIN:
547 pkt->ip.tot_len = cpu_to_be16(ip_tot_len);
548 pkt->ip.check = ip_fast_csum(&pkt->ip, pkt->ip.ihl);
549 break;
550 case MVM_TCP_RX_WAKE:
551 for (i = 0; i < DIV_ROUND_UP(tcp->wake_len, 8); i++) {
552 u8 tmp = tcp->wake_mask[i];
553 mask[i + 6] |= tmp << 6;
554 if (i + 1 < DIV_ROUND_UP(tcp->wake_len, 8))
555 mask[i + 7] = tmp >> 2;
556 }
557 /* fall through for ethernet/IP/TCP headers mask */
558 case MVM_TCP_RX_SYNACK:
559 case MVM_TCP_RX_ACK:
560 mask[0] = 0xff; /* match ethernet */
561 /*
562 * match ethernet, ip.version, ip.ihl
563 * the ip.ihl half byte is really masked out by firmware
564 */
565 mask[1] = 0x7f;
566 mask[2] = 0x80; /* match ip.protocol */
567 mask[3] = 0xfc; /* match ip.saddr, ip.daddr */
568 mask[4] = 0x3f; /* match ip.daddr, tcp.source, tcp.dest */
569 mask[5] = 0x80; /* match tcp flags */
570 /* leave rest (0 or set for MVM_TCP_RX_WAKE) */
571 break;
572 };
573
574 *pseudo_hdr_csum = pseudo_hdr_check(ip_tot_len - sizeof(struct iphdr),
575 pkt->ip.saddr, pkt->ip.daddr);
576}
577
578static int iwl_mvm_send_remote_wake_cfg(struct iwl_mvm *mvm,
579 struct ieee80211_vif *vif,
580 struct cfg80211_wowlan_tcp *tcp)
581{
582 struct iwl_wowlan_remote_wake_config *cfg;
583 struct iwl_host_cmd cmd = {
584 .id = REMOTE_WAKE_CONFIG_CMD,
585 .len = { sizeof(*cfg), },
586 .dataflags = { IWL_HCMD_DFL_NOCOPY, },
587 .flags = CMD_SYNC,
588 };
589 int ret;
590
591 if (!tcp)
592 return 0;
593
594 cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
595 if (!cfg)
596 return -ENOMEM;
597 cmd.data[0] = cfg;
598
599 cfg->max_syn_retries = 10;
600 cfg->max_data_retries = 10;
601 cfg->tcp_syn_ack_timeout = 1; /* seconds */
602 cfg->tcp_ack_timeout = 1; /* seconds */
603
604 /* SYN (TX) */
605 iwl_mvm_build_tcp_packet(
Oren Givonb002c7e2013-06-12 20:37:03 +0300606 vif, tcp, cfg->syn_tx.data, NULL,
Johannes Bergf0c26462013-01-22 20:41:58 +0100607 &cfg->syn_tx.info.tcp_pseudo_header_checksum,
608 MVM_TCP_TX_SYN);
609 cfg->syn_tx.info.tcp_payload_length = 0;
610
611 /* SYN/ACK (RX) */
612 iwl_mvm_build_tcp_packet(
Oren Givonb002c7e2013-06-12 20:37:03 +0300613 vif, tcp, cfg->synack_rx.data, cfg->synack_rx.rx_mask,
Johannes Bergf0c26462013-01-22 20:41:58 +0100614 &cfg->synack_rx.info.tcp_pseudo_header_checksum,
615 MVM_TCP_RX_SYNACK);
616 cfg->synack_rx.info.tcp_payload_length = 0;
617
618 /* KEEPALIVE/ACK (TX) */
619 iwl_mvm_build_tcp_packet(
Oren Givonb002c7e2013-06-12 20:37:03 +0300620 vif, tcp, cfg->keepalive_tx.data, NULL,
Johannes Bergf0c26462013-01-22 20:41:58 +0100621 &cfg->keepalive_tx.info.tcp_pseudo_header_checksum,
622 MVM_TCP_TX_DATA);
623 cfg->keepalive_tx.info.tcp_payload_length =
624 cpu_to_le16(tcp->payload_len);
625 cfg->sequence_number_offset = tcp->payload_seq.offset;
626 /* length must be 0..4, the field is little endian */
627 cfg->sequence_number_length = tcp->payload_seq.len;
628 cfg->initial_sequence_number = cpu_to_le32(tcp->payload_seq.start);
629 cfg->keepalive_interval = cpu_to_le16(tcp->data_interval);
630 if (tcp->payload_tok.len) {
631 cfg->token_offset = tcp->payload_tok.offset;
632 cfg->token_length = tcp->payload_tok.len;
633 cfg->num_tokens =
634 cpu_to_le16(tcp->tokens_size % tcp->payload_tok.len);
635 memcpy(cfg->tokens, tcp->payload_tok.token_stream,
636 tcp->tokens_size);
637 } else {
638 /* set tokens to max value to almost never run out */
639 cfg->num_tokens = cpu_to_le16(65535);
640 }
641
642 /* ACK (RX) */
643 iwl_mvm_build_tcp_packet(
Oren Givonb002c7e2013-06-12 20:37:03 +0300644 vif, tcp, cfg->keepalive_ack_rx.data,
Johannes Bergf0c26462013-01-22 20:41:58 +0100645 cfg->keepalive_ack_rx.rx_mask,
646 &cfg->keepalive_ack_rx.info.tcp_pseudo_header_checksum,
647 MVM_TCP_RX_ACK);
648 cfg->keepalive_ack_rx.info.tcp_payload_length = 0;
649
650 /* WAKEUP (RX) */
651 iwl_mvm_build_tcp_packet(
Oren Givonb002c7e2013-06-12 20:37:03 +0300652 vif, tcp, cfg->wake_rx.data, cfg->wake_rx.rx_mask,
Johannes Bergf0c26462013-01-22 20:41:58 +0100653 &cfg->wake_rx.info.tcp_pseudo_header_checksum,
654 MVM_TCP_RX_WAKE);
655 cfg->wake_rx.info.tcp_payload_length =
656 cpu_to_le16(tcp->wake_len);
657
658 /* FIN */
659 iwl_mvm_build_tcp_packet(
Oren Givonb002c7e2013-06-12 20:37:03 +0300660 vif, tcp, cfg->fin_tx.data, NULL,
Johannes Bergf0c26462013-01-22 20:41:58 +0100661 &cfg->fin_tx.info.tcp_pseudo_header_checksum,
662 MVM_TCP_TX_FIN);
663 cfg->fin_tx.info.tcp_payload_length = 0;
664
665 ret = iwl_mvm_send_cmd(mvm, &cmd);
666 kfree(cfg);
667
668 return ret;
669}
670
Johannes Berg8ca151b2013-01-24 14:25:36 +0100671struct iwl_d3_iter_data {
672 struct iwl_mvm *mvm;
673 struct ieee80211_vif *vif;
674 bool error;
675};
676
677static void iwl_mvm_d3_iface_iterator(void *_data, u8 *mac,
678 struct ieee80211_vif *vif)
679{
680 struct iwl_d3_iter_data *data = _data;
681 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
682
683 if (vif->type != NL80211_IFTYPE_STATION || vif->p2p)
684 return;
685
686 if (mvmvif->ap_sta_id == IWL_MVM_STATION_COUNT)
687 return;
688
689 if (data->vif) {
690 IWL_ERR(data->mvm, "More than one managed interface active!\n");
691 data->error = true;
692 return;
693 }
694
695 data->vif = vif;
696}
697
698static int iwl_mvm_d3_reprogram(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
699 struct ieee80211_sta *ap_sta)
700{
701 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
702 struct ieee80211_chanctx_conf *ctx;
703 u8 chains_static, chains_dynamic;
704 struct cfg80211_chan_def chandef;
705 int ret, i;
706 struct iwl_binding_cmd binding_cmd = {};
707 struct iwl_time_quota_cmd quota_cmd = {};
708 u32 status;
709
710 /* add back the PHY */
711 if (WARN_ON(!mvmvif->phy_ctxt))
712 return -EINVAL;
713
714 rcu_read_lock();
715 ctx = rcu_dereference(vif->chanctx_conf);
716 if (WARN_ON(!ctx)) {
717 rcu_read_unlock();
718 return -EINVAL;
719 }
720 chandef = ctx->def;
721 chains_static = ctx->rx_chains_static;
722 chains_dynamic = ctx->rx_chains_dynamic;
723 rcu_read_unlock();
724
725 ret = iwl_mvm_phy_ctxt_add(mvm, mvmvif->phy_ctxt, &chandef,
726 chains_static, chains_dynamic);
727 if (ret)
728 return ret;
729
730 /* add back the MAC */
731 mvmvif->uploaded = false;
732
733 if (WARN_ON(!vif->bss_conf.assoc))
734 return -EINVAL;
735 /* hack */
736 vif->bss_conf.assoc = false;
737 ret = iwl_mvm_mac_ctxt_add(mvm, vif);
738 vif->bss_conf.assoc = true;
739 if (ret)
740 return ret;
741
742 /* add back binding - XXX refactor? */
743 binding_cmd.id_and_color =
744 cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->phy_ctxt->id,
745 mvmvif->phy_ctxt->color));
746 binding_cmd.action = cpu_to_le32(FW_CTXT_ACTION_ADD);
747 binding_cmd.phy =
748 cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->phy_ctxt->id,
749 mvmvif->phy_ctxt->color));
750 binding_cmd.macs[0] = cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id,
751 mvmvif->color));
752 for (i = 1; i < MAX_MACS_IN_BINDING; i++)
753 binding_cmd.macs[i] = cpu_to_le32(FW_CTXT_INVALID);
754
755 status = 0;
756 ret = iwl_mvm_send_cmd_pdu_status(mvm, BINDING_CONTEXT_CMD,
757 sizeof(binding_cmd), &binding_cmd,
758 &status);
759 if (ret) {
760 IWL_ERR(mvm, "Failed to add binding: %d\n", ret);
761 return ret;
762 }
763
764 if (status) {
765 IWL_ERR(mvm, "Binding command failed: %u\n", status);
766 return -EIO;
767 }
768
Johannes Berg7a453972013-02-12 13:10:44 +0100769 ret = iwl_mvm_sta_send_to_fw(mvm, ap_sta, false);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100770 if (ret)
771 return ret;
772 rcu_assign_pointer(mvm->fw_id_to_mac_id[mvmvif->ap_sta_id], ap_sta);
773
774 ret = iwl_mvm_mac_ctxt_changed(mvm, vif);
775 if (ret)
776 return ret;
777
778 /* and some quota */
779 quota_cmd.quotas[0].id_and_color =
780 cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->phy_ctxt->id,
781 mvmvif->phy_ctxt->color));
782 quota_cmd.quotas[0].quota = cpu_to_le32(100);
783 quota_cmd.quotas[0].max_duration = cpu_to_le32(1000);
784
785 for (i = 1; i < MAX_BINDINGS; i++)
786 quota_cmd.quotas[i].id_and_color = cpu_to_le32(FW_CTXT_INVALID);
787
788 ret = iwl_mvm_send_cmd_pdu(mvm, TIME_QUOTA_CMD, CMD_SYNC,
789 sizeof(quota_cmd), &quota_cmd);
790 if (ret)
791 IWL_ERR(mvm, "Failed to send quota: %d\n", ret);
792
793 return 0;
794}
795
Johannes Berg4ac6cb52013-08-08 09:30:13 +0200796static int iwl_mvm_get_last_nonqos_seq(struct iwl_mvm *mvm,
797 struct ieee80211_vif *vif)
798{
799 struct iwl_host_cmd cmd = {
800 .id = NON_QOS_TX_COUNTER_CMD,
801 .flags = CMD_SYNC | CMD_WANT_SKB,
802 };
803 int err;
804 u32 size;
805
806 err = iwl_mvm_send_cmd(mvm, &cmd);
807 if (err)
808 return err;
809
810 size = le32_to_cpu(cmd.resp_pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
811 size -= sizeof(cmd.resp_pkt->hdr);
812 if (size != sizeof(__le32))
813 err = -EINVAL;
814 else
815 err = le32_to_cpup((__le32 *)cmd.resp_pkt->data);
816
817 iwl_free_resp(&cmd);
818 return err;
819}
820
Johannes Bergdebff612013-05-14 13:53:45 +0200821static int __iwl_mvm_suspend(struct ieee80211_hw *hw,
822 struct cfg80211_wowlan *wowlan,
823 bool test)
Johannes Berg8ca151b2013-01-24 14:25:36 +0100824{
825 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
826 struct iwl_d3_iter_data suspend_iter_data = {
827 .mvm = mvm,
828 };
829 struct ieee80211_vif *vif;
830 struct iwl_mvm_vif *mvmvif;
831 struct ieee80211_sta *ap_sta;
832 struct iwl_mvm_sta *mvm_ap_sta;
833 struct iwl_wowlan_config_cmd wowlan_config_cmd = {};
834 struct iwl_wowlan_kek_kck_material_cmd kek_kck_cmd = {};
835 struct iwl_wowlan_tkip_params_cmd tkip_cmd = {};
Johannes Bergdebff612013-05-14 13:53:45 +0200836 struct iwl_d3_manager_config d3_cfg_cmd_data = {
Johannes Bergc9204872013-02-15 11:00:58 +0100837 /*
838 * Program the minimum sleep time to 10 seconds, as many
839 * platforms have issues processing a wakeup signal while
840 * still being in the process of suspending.
841 */
842 .min_sleep_time = cpu_to_le32(10 * 1000 * 1000),
843 };
Johannes Bergdebff612013-05-14 13:53:45 +0200844 struct iwl_host_cmd d3_cfg_cmd = {
845 .id = D3_CONFIG_CMD,
846 .flags = CMD_SYNC | CMD_WANT_SKB,
847 .data[0] = &d3_cfg_cmd_data,
848 .len[0] = sizeof(d3_cfg_cmd_data),
849 };
Johannes Berg8ca151b2013-01-24 14:25:36 +0100850 struct wowlan_key_data key_data = {
851 .use_rsc_tsc = false,
852 .tkip = &tkip_cmd,
853 .use_tkip = false,
854 };
855 int ret, i;
Johannes Bergdebff612013-05-14 13:53:45 +0200856 int len __maybe_unused;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100857 u8 old_aux_sta_id, old_ap_sta_id = IWL_MVM_STATION_COUNT;
858
Johannes Bergdebff612013-05-14 13:53:45 +0200859 if (!wowlan) {
860 /*
861 * mac80211 shouldn't get here, but for D3 test
862 * it doesn't warrant a warning
863 */
864 WARN_ON(!test);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100865 return -EINVAL;
Johannes Bergdebff612013-05-14 13:53:45 +0200866 }
Johannes Berg8ca151b2013-01-24 14:25:36 +0100867
868 key_data.rsc_tsc = kzalloc(sizeof(*key_data.rsc_tsc), GFP_KERNEL);
869 if (!key_data.rsc_tsc)
870 return -ENOMEM;
871
872 mutex_lock(&mvm->mutex);
873
874 old_aux_sta_id = mvm->aux_sta.sta_id;
875
876 /* see if there's only a single BSS vif and it's associated */
877 ieee80211_iterate_active_interfaces_atomic(
878 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
879 iwl_mvm_d3_iface_iterator, &suspend_iter_data);
880
881 if (suspend_iter_data.error || !suspend_iter_data.vif) {
882 ret = 1;
883 goto out_noreset;
884 }
885
886 vif = suspend_iter_data.vif;
887 mvmvif = iwl_mvm_vif_from_mac80211(vif);
888
889 ap_sta = rcu_dereference_protected(
890 mvm->fw_id_to_mac_id[mvmvif->ap_sta_id],
891 lockdep_is_held(&mvm->mutex));
892 if (IS_ERR_OR_NULL(ap_sta)) {
893 ret = -EINVAL;
894 goto out_noreset;
895 }
896
897 mvm_ap_sta = (struct iwl_mvm_sta *)ap_sta->drv_priv;
898
Johannes Berg8ca151b2013-01-24 14:25:36 +0100899 /* TODO: wowlan_config_cmd.wowlan_ba_teardown_tids */
900
901 wowlan_config_cmd.is_11n_connection = ap_sta->ht_cap.ht_supported;
902
Johannes Berg4ac6cb52013-08-08 09:30:13 +0200903 /* Query the last used seqno and set it */
904 ret = iwl_mvm_get_last_nonqos_seq(mvm, vif);
905 if (ret < 0)
906 goto out_noreset;
907 wowlan_config_cmd.non_qos_seq = cpu_to_le16(ret);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100908
909 /*
910 * For QoS counters, we store the one to use next, so subtract 0x10
911 * since the uCode will add 0x10 *before* using the value while we
912 * increment after using the value (i.e. store the next value to use).
913 */
914 for (i = 0; i < IWL_MAX_TID_COUNT; i++) {
Johannes Berg4ac6cb52013-08-08 09:30:13 +0200915 u16 seq = mvm_ap_sta->tid_data[i].seq_number;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100916 seq -= 0x10;
917 wowlan_config_cmd.qos_seq[i] = cpu_to_le16(seq);
918 }
919
920 if (wowlan->disconnect)
921 wowlan_config_cmd.wakeup_filter |=
922 cpu_to_le32(IWL_WOWLAN_WAKEUP_BEACON_MISS |
923 IWL_WOWLAN_WAKEUP_LINK_CHANGE);
924 if (wowlan->magic_pkt)
925 wowlan_config_cmd.wakeup_filter |=
926 cpu_to_le32(IWL_WOWLAN_WAKEUP_MAGIC_PACKET);
927 if (wowlan->gtk_rekey_failure)
928 wowlan_config_cmd.wakeup_filter |=
929 cpu_to_le32(IWL_WOWLAN_WAKEUP_GTK_REKEY_FAIL);
930 if (wowlan->eap_identity_req)
931 wowlan_config_cmd.wakeup_filter |=
932 cpu_to_le32(IWL_WOWLAN_WAKEUP_EAP_IDENT_REQ);
933 if (wowlan->four_way_handshake)
934 wowlan_config_cmd.wakeup_filter |=
935 cpu_to_le32(IWL_WOWLAN_WAKEUP_4WAY_HANDSHAKE);
936 if (wowlan->n_patterns)
937 wowlan_config_cmd.wakeup_filter |=
938 cpu_to_le32(IWL_WOWLAN_WAKEUP_PATTERN_MATCH);
939
940 if (wowlan->rfkill_release)
Johannes Berg6039f3e2013-03-20 10:40:05 +0100941 wowlan_config_cmd.wakeup_filter |=
Johannes Berg8ca151b2013-01-24 14:25:36 +0100942 cpu_to_le32(IWL_WOWLAN_WAKEUP_RF_KILL_DEASSERT);
943
Johannes Bergf0c26462013-01-22 20:41:58 +0100944 if (wowlan->tcp) {
945 /*
Johannes Berg6039f3e2013-03-20 10:40:05 +0100946 * Set the "link change" (really "link lost") flag as well
947 * since that implies losing the TCP connection.
Johannes Bergf0c26462013-01-22 20:41:58 +0100948 */
949 wowlan_config_cmd.wakeup_filter |=
950 cpu_to_le32(IWL_WOWLAN_WAKEUP_REMOTE_LINK_LOSS |
951 IWL_WOWLAN_WAKEUP_REMOTE_SIGNATURE_TABLE |
952 IWL_WOWLAN_WAKEUP_REMOTE_WAKEUP_PACKET |
953 IWL_WOWLAN_WAKEUP_LINK_CHANGE);
954 }
955
Johannes Berg8ca151b2013-01-24 14:25:36 +0100956 iwl_mvm_cancel_scan(mvm);
957
958 iwl_trans_stop_device(mvm->trans);
959
960 /*
Johannes Berg4ac6cb52013-08-08 09:30:13 +0200961 * The D3 firmware still hardcodes the AP station ID for the
962 * BSS we're associated with as 0. Store the real STA ID here
963 * and assign 0. When we leave this function, we'll restore
964 * the original value for the resume code.
965 */
966 old_ap_sta_id = mvm_ap_sta->sta_id;
967 mvm_ap_sta->sta_id = 0;
968 mvmvif->ap_sta_id = 0;
969
970 /*
Johannes Berg8ca151b2013-01-24 14:25:36 +0100971 * Set the HW restart bit -- this is mostly true as we're
972 * going to load new firmware and reprogram that, though
973 * the reprogramming is going to be manual to avoid adding
974 * all the MACs that aren't support.
975 * We don't have to clear up everything though because the
976 * reprogramming is manual. When we resume, we'll actually
977 * go through a proper restart sequence again to switch
978 * back to the runtime firmware image.
979 */
980 set_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status);
981
982 /* We reprogram keys and shouldn't allocate new key indices */
983 memset(mvm->fw_key_table, 0, sizeof(mvm->fw_key_table));
984
Johannes Bergf444eb12013-02-26 12:04:18 +0100985 mvm->ptk_ivlen = 0;
986 mvm->ptk_icvlen = 0;
987 mvm->ptk_ivlen = 0;
988 mvm->ptk_icvlen = 0;
989
Johannes Berg8ca151b2013-01-24 14:25:36 +0100990 /*
991 * The D3 firmware still hardcodes the AP station ID for the
992 * BSS we're associated with as 0. As a result, we have to move
993 * the auxiliary station to ID 1 so the ID 0 remains free for
994 * the AP station for later.
995 * We set the sta_id to 1 here, and reset it to its previous
996 * value (that we stored above) later.
997 */
998 mvm->aux_sta.sta_id = 1;
999
1000 ret = iwl_mvm_load_d3_fw(mvm);
1001 if (ret)
1002 goto out;
1003
1004 ret = iwl_mvm_d3_reprogram(mvm, vif, ap_sta);
1005 if (ret)
1006 goto out;
1007
1008 if (!iwlwifi_mod_params.sw_crypto) {
1009 /*
1010 * This needs to be unlocked due to lock ordering
1011 * constraints. Since we're in the suspend path
1012 * that isn't really a problem though.
1013 */
1014 mutex_unlock(&mvm->mutex);
1015 ieee80211_iter_keys(mvm->hw, vif,
1016 iwl_mvm_wowlan_program_keys,
1017 &key_data);
1018 mutex_lock(&mvm->mutex);
1019 if (key_data.error) {
1020 ret = -EIO;
1021 goto out;
1022 }
1023
1024 if (key_data.use_rsc_tsc) {
1025 struct iwl_host_cmd rsc_tsc_cmd = {
1026 .id = WOWLAN_TSC_RSC_PARAM,
1027 .flags = CMD_SYNC,
1028 .data[0] = key_data.rsc_tsc,
1029 .dataflags[0] = IWL_HCMD_DFL_NOCOPY,
1030 .len[0] = sizeof(*key_data.rsc_tsc),
1031 };
1032
1033 ret = iwl_mvm_send_cmd(mvm, &rsc_tsc_cmd);
1034 if (ret)
1035 goto out;
1036 }
1037
1038 if (key_data.use_tkip) {
1039 ret = iwl_mvm_send_cmd_pdu(mvm,
1040 WOWLAN_TKIP_PARAM,
1041 CMD_SYNC, sizeof(tkip_cmd),
1042 &tkip_cmd);
1043 if (ret)
1044 goto out;
1045 }
1046
1047 if (mvmvif->rekey_data.valid) {
1048 memset(&kek_kck_cmd, 0, sizeof(kek_kck_cmd));
1049 memcpy(kek_kck_cmd.kck, mvmvif->rekey_data.kck,
1050 NL80211_KCK_LEN);
1051 kek_kck_cmd.kck_len = cpu_to_le16(NL80211_KCK_LEN);
1052 memcpy(kek_kck_cmd.kek, mvmvif->rekey_data.kek,
1053 NL80211_KEK_LEN);
1054 kek_kck_cmd.kek_len = cpu_to_le16(NL80211_KEK_LEN);
1055 kek_kck_cmd.replay_ctr = mvmvif->rekey_data.replay_ctr;
1056
1057 ret = iwl_mvm_send_cmd_pdu(mvm,
1058 WOWLAN_KEK_KCK_MATERIAL,
1059 CMD_SYNC,
1060 sizeof(kek_kck_cmd),
1061 &kek_kck_cmd);
1062 if (ret)
1063 goto out;
1064 }
1065 }
1066
1067 ret = iwl_mvm_send_cmd_pdu(mvm, WOWLAN_CONFIGURATION,
1068 CMD_SYNC, sizeof(wowlan_config_cmd),
1069 &wowlan_config_cmd);
1070 if (ret)
1071 goto out;
1072
1073 ret = iwl_mvm_send_patterns(mvm, wowlan);
1074 if (ret)
1075 goto out;
1076
1077 ret = iwl_mvm_send_proto_offload(mvm, vif);
1078 if (ret)
1079 goto out;
1080
Johannes Bergf0c26462013-01-22 20:41:58 +01001081 ret = iwl_mvm_send_remote_wake_cfg(mvm, vif, wowlan->tcp);
1082 if (ret)
1083 goto out;
1084
Alexander Bondaree1e8422013-04-23 13:52:10 +03001085 ret = iwl_mvm_power_update_mode(mvm, vif);
1086 if (ret)
1087 goto out;
1088
Johannes Bergb0114712013-06-12 14:55:40 +02001089#ifdef CONFIG_IWLWIFI_DEBUGFS
1090 if (mvm->d3_wake_sysassert)
1091 d3_cfg_cmd_data.wakeup_flags |=
1092 cpu_to_le32(IWL_WAKEUP_D3_CONFIG_FW_ERROR);
1093#endif
1094
Johannes Berg8ca151b2013-01-24 14:25:36 +01001095 /* must be last -- this switches firmware state */
Johannes Bergdebff612013-05-14 13:53:45 +02001096 ret = iwl_mvm_send_cmd(mvm, &d3_cfg_cmd);
Johannes Berg8ca151b2013-01-24 14:25:36 +01001097 if (ret)
1098 goto out;
Johannes Bergdebff612013-05-14 13:53:45 +02001099#ifdef CONFIG_IWLWIFI_DEBUGFS
1100 len = le32_to_cpu(d3_cfg_cmd.resp_pkt->len_n_flags) &
1101 FH_RSCSR_FRAME_SIZE_MSK;
1102 if (len >= sizeof(u32) * 2) {
1103 mvm->d3_test_pme_ptr =
1104 le32_to_cpup((__le32 *)d3_cfg_cmd.resp_pkt->data);
1105 } else if (test) {
1106 /* in test mode we require the pointer */
1107 ret = -EIO;
1108 goto out;
1109 }
1110#endif
1111 iwl_free_resp(&d3_cfg_cmd);
Johannes Berg8ca151b2013-01-24 14:25:36 +01001112
1113 clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status);
1114
Johannes Bergdebff612013-05-14 13:53:45 +02001115 iwl_trans_d3_suspend(mvm->trans, test);
Johannes Berg8ca151b2013-01-24 14:25:36 +01001116 out:
1117 mvm->aux_sta.sta_id = old_aux_sta_id;
1118 mvm_ap_sta->sta_id = old_ap_sta_id;
1119 mvmvif->ap_sta_id = old_ap_sta_id;
1120 out_noreset:
1121 kfree(key_data.rsc_tsc);
1122 if (ret < 0)
1123 ieee80211_restart_hw(mvm->hw);
1124
1125 mutex_unlock(&mvm->mutex);
1126
1127 return ret;
1128}
1129
Johannes Bergdebff612013-05-14 13:53:45 +02001130int iwl_mvm_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
1131{
1132 return __iwl_mvm_suspend(hw, wowlan, false);
1133}
1134
Johannes Berg7abc4632013-08-06 18:28:26 +02001135static void iwl_mvm_report_wakeup_reasons(struct iwl_mvm *mvm,
1136 struct ieee80211_vif *vif,
1137 struct iwl_wowlan_status *status)
Johannes Berg9b26b502013-01-22 13:02:09 +01001138{
Johannes Berg7abc4632013-08-06 18:28:26 +02001139 struct sk_buff *pkt = NULL;
Johannes Berg9b26b502013-01-22 13:02:09 +01001140 struct cfg80211_wowlan_wakeup wakeup = {
1141 .pattern_idx = -1,
1142 };
1143 struct cfg80211_wowlan_wakeup *wakeup_report = &wakeup;
Johannes Berg7abc4632013-08-06 18:28:26 +02001144 u32 reasons = le32_to_cpu(status->wakeup_reasons);
Johannes Berg9b26b502013-01-22 13:02:09 +01001145
1146 if (reasons == IWL_WOWLAN_WAKEUP_BY_NON_WIRELESS) {
1147 wakeup_report = NULL;
1148 goto report;
1149 }
1150
Johannes Bergf444eb12013-02-26 12:04:18 +01001151 if (reasons & IWL_WOWLAN_WAKEUP_BY_MAGIC_PACKET)
Johannes Berg9b26b502013-01-22 13:02:09 +01001152 wakeup.magic_pkt = true;
Johannes Berg9b26b502013-01-22 13:02:09 +01001153
Johannes Bergf444eb12013-02-26 12:04:18 +01001154 if (reasons & IWL_WOWLAN_WAKEUP_BY_PATTERN)
Johannes Berg9b26b502013-01-22 13:02:09 +01001155 wakeup.pattern_idx =
1156 le16_to_cpu(status->pattern_number);
Johannes Berg9b26b502013-01-22 13:02:09 +01001157
1158 if (reasons & (IWL_WOWLAN_WAKEUP_BY_DISCONNECTION_ON_MISSED_BEACON |
1159 IWL_WOWLAN_WAKEUP_BY_DISCONNECTION_ON_DEAUTH))
1160 wakeup.disconnect = true;
1161
Johannes Bergf444eb12013-02-26 12:04:18 +01001162 if (reasons & IWL_WOWLAN_WAKEUP_BY_GTK_REKEY_FAILURE)
Johannes Berg9b26b502013-01-22 13:02:09 +01001163 wakeup.gtk_rekey_failure = true;
Johannes Berg9b26b502013-01-22 13:02:09 +01001164
Johannes Bergf444eb12013-02-26 12:04:18 +01001165 if (reasons & IWL_WOWLAN_WAKEUP_BY_RFKILL_DEASSERTED)
Johannes Berg9b26b502013-01-22 13:02:09 +01001166 wakeup.rfkill_release = true;
Johannes Berg9b26b502013-01-22 13:02:09 +01001167
Johannes Bergf444eb12013-02-26 12:04:18 +01001168 if (reasons & IWL_WOWLAN_WAKEUP_BY_EAPOL_REQUEST)
Johannes Berg9b26b502013-01-22 13:02:09 +01001169 wakeup.eap_identity_req = true;
Johannes Berg9b26b502013-01-22 13:02:09 +01001170
Johannes Bergf444eb12013-02-26 12:04:18 +01001171 if (reasons & IWL_WOWLAN_WAKEUP_BY_FOUR_WAY_HANDSHAKE)
Johannes Berg9b26b502013-01-22 13:02:09 +01001172 wakeup.four_way_handshake = true;
Johannes Berg9b26b502013-01-22 13:02:09 +01001173
Johannes Bergf0c26462013-01-22 20:41:58 +01001174 if (reasons & IWL_WOWLAN_WAKEUP_BY_REM_WAKE_LINK_LOSS)
1175 wakeup.tcp_connlost = true;
1176
1177 if (reasons & IWL_WOWLAN_WAKEUP_BY_REM_WAKE_SIGNATURE_TABLE)
1178 wakeup.tcp_nomoretokens = true;
1179
1180 if (reasons & IWL_WOWLAN_WAKEUP_BY_REM_WAKE_WAKEUP_PACKET)
1181 wakeup.tcp_match = true;
1182
Johannes Berg9b26b502013-01-22 13:02:09 +01001183 if (status->wake_packet_bufsize) {
Johannes Bergf444eb12013-02-26 12:04:18 +01001184 int pktsize = le32_to_cpu(status->wake_packet_bufsize);
1185 int pktlen = le32_to_cpu(status->wake_packet_length);
1186 const u8 *pktdata = status->wake_packet;
1187 struct ieee80211_hdr *hdr = (void *)pktdata;
1188 int truncated = pktlen - pktsize;
Johannes Berg9b26b502013-01-22 13:02:09 +01001189
Johannes Bergf444eb12013-02-26 12:04:18 +01001190 /* this would be a firmware bug */
1191 if (WARN_ON_ONCE(truncated < 0))
1192 truncated = 0;
1193
1194 if (ieee80211_is_data(hdr->frame_control)) {
1195 int hdrlen = ieee80211_hdrlen(hdr->frame_control);
1196 int ivlen = 0, icvlen = 4; /* also FCS */
1197
Johannes Berg9b26b502013-01-22 13:02:09 +01001198 pkt = alloc_skb(pktsize, GFP_KERNEL);
1199 if (!pkt)
1200 goto report;
Johannes Bergf444eb12013-02-26 12:04:18 +01001201
1202 memcpy(skb_put(pkt, hdrlen), pktdata, hdrlen);
1203 pktdata += hdrlen;
1204 pktsize -= hdrlen;
1205
1206 if (ieee80211_has_protected(hdr->frame_control)) {
Johannes Berg7abc4632013-08-06 18:28:26 +02001207 /*
1208 * This is unlocked and using gtk_i(c)vlen,
1209 * but since everything is under RTNL still
1210 * that's not really a problem - changing
1211 * it would be difficult.
1212 */
Johannes Bergf444eb12013-02-26 12:04:18 +01001213 if (is_multicast_ether_addr(hdr->addr1)) {
1214 ivlen = mvm->gtk_ivlen;
1215 icvlen += mvm->gtk_icvlen;
1216 } else {
1217 ivlen = mvm->ptk_ivlen;
1218 icvlen += mvm->ptk_icvlen;
1219 }
1220 }
1221
1222 /* if truncated, FCS/ICV is (partially) gone */
1223 if (truncated >= icvlen) {
1224 icvlen = 0;
1225 truncated -= icvlen;
1226 } else {
1227 icvlen -= truncated;
1228 truncated = 0;
1229 }
1230
1231 pktsize -= ivlen + icvlen;
1232 pktdata += ivlen;
1233
1234 memcpy(skb_put(pkt, pktsize), pktdata, pktsize);
1235
Johannes Berg9b26b502013-01-22 13:02:09 +01001236 if (ieee80211_data_to_8023(pkt, vif->addr, vif->type))
1237 goto report;
1238 wakeup.packet = pkt->data;
1239 wakeup.packet_present_len = pkt->len;
Johannes Bergf444eb12013-02-26 12:04:18 +01001240 wakeup.packet_len = pkt->len - truncated;
Johannes Berg9b26b502013-01-22 13:02:09 +01001241 wakeup.packet_80211 = false;
1242 } else {
Johannes Bergf444eb12013-02-26 12:04:18 +01001243 int fcslen = 4;
1244
1245 if (truncated >= 4) {
1246 truncated -= 4;
1247 fcslen = 0;
1248 } else {
1249 fcslen -= truncated;
1250 truncated = 0;
1251 }
1252 pktsize -= fcslen;
Johannes Berg9b26b502013-01-22 13:02:09 +01001253 wakeup.packet = status->wake_packet;
1254 wakeup.packet_present_len = pktsize;
Johannes Bergf444eb12013-02-26 12:04:18 +01001255 wakeup.packet_len = pktlen - truncated;
Johannes Berg9b26b502013-01-22 13:02:09 +01001256 wakeup.packet_80211 = true;
1257 }
1258 }
1259
1260 report:
1261 ieee80211_report_wowlan_wakeup(vif, wakeup_report, GFP_KERNEL);
1262 kfree_skb(pkt);
Johannes Berg7abc4632013-08-06 18:28:26 +02001263}
Johannes Berg9b26b502013-01-22 13:02:09 +01001264
Johannes Berg7abc4632013-08-06 18:28:26 +02001265/* releases the MVM mutex */
1266static void iwl_mvm_query_wakeup_reasons(struct iwl_mvm *mvm,
1267 struct ieee80211_vif *vif)
1268{
1269 u32 base = mvm->error_event_table;
1270 struct error_table_start {
1271 /* cf. struct iwl_error_event_table */
1272 u32 valid;
1273 u32 error_id;
1274 } err_info;
1275 struct iwl_host_cmd cmd = {
1276 .id = WOWLAN_GET_STATUSES,
1277 .flags = CMD_SYNC | CMD_WANT_SKB,
1278 };
1279 struct iwl_wowlan_status *status;
1280 int ret, len;
1281
1282 iwl_trans_read_mem_bytes(mvm->trans, base,
1283 &err_info, sizeof(err_info));
1284
1285 if (err_info.valid) {
1286 IWL_INFO(mvm, "error table is valid (%d)\n",
1287 err_info.valid);
1288 if (err_info.error_id == RF_KILL_INDICATOR_FOR_WOWLAN) {
1289 struct cfg80211_wowlan_wakeup wakeup = {
1290 .rfkill_release = true,
1291 };
1292 ieee80211_report_wowlan_wakeup(vif, &wakeup,
1293 GFP_KERNEL);
1294 }
1295 goto out_unlock;
1296 }
1297
1298 /* only for tracing for now */
1299 ret = iwl_mvm_send_cmd_pdu(mvm, OFFLOADS_QUERY_CMD, CMD_SYNC, 0, NULL);
1300 if (ret)
1301 IWL_ERR(mvm, "failed to query offload statistics (%d)\n", ret);
1302
1303 ret = iwl_mvm_send_cmd(mvm, &cmd);
1304 if (ret) {
1305 IWL_ERR(mvm, "failed to query status (%d)\n", ret);
1306 goto out_unlock;
1307 }
1308
1309 /* RF-kill already asserted again... */
1310 if (!cmd.resp_pkt)
1311 goto out_unlock;
1312
1313 len = le32_to_cpu(cmd.resp_pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
1314 if (len - sizeof(struct iwl_cmd_header) < sizeof(*status)) {
1315 IWL_ERR(mvm, "Invalid WoWLAN status response!\n");
1316 goto out_free_resp;
1317 }
1318
1319 status = (void *)cmd.resp_pkt->data;
1320
1321 if (len - sizeof(struct iwl_cmd_header) !=
1322 sizeof(*status) +
1323 ALIGN(le32_to_cpu(status->wake_packet_bufsize), 4)) {
1324 IWL_ERR(mvm, "Invalid WoWLAN status response!\n");
1325 goto out_free_resp;
1326 }
1327
1328 /* now we have all the data we need, unlock to avoid mac80211 issues */
1329 mutex_unlock(&mvm->mutex);
1330
1331 iwl_mvm_report_wakeup_reasons(mvm, vif, status);
Johannes Berg9b26b502013-01-22 13:02:09 +01001332 iwl_free_resp(&cmd);
Johannes Berg7abc4632013-08-06 18:28:26 +02001333 return;
1334
1335 out_free_resp:
1336 iwl_free_resp(&cmd);
1337 out_unlock:
1338 mutex_unlock(&mvm->mutex);
Johannes Berg9b26b502013-01-22 13:02:09 +01001339}
1340
Johannes Bergafc66bb2013-05-03 11:44:16 +02001341static void iwl_mvm_read_d3_sram(struct iwl_mvm *mvm)
1342{
1343#ifdef CONFIG_IWLWIFI_DEBUGFS
1344 const struct fw_img *img = &mvm->fw->img[IWL_UCODE_WOWLAN];
1345 u32 len = img->sec[IWL_UCODE_SECTION_DATA].len;
1346 u32 offs = img->sec[IWL_UCODE_SECTION_DATA].offset;
1347
1348 if (!mvm->store_d3_resume_sram)
1349 return;
1350
1351 if (!mvm->d3_resume_sram) {
1352 mvm->d3_resume_sram = kzalloc(len, GFP_KERNEL);
1353 if (!mvm->d3_resume_sram)
1354 return;
1355 }
1356
1357 iwl_trans_read_mem_bytes(mvm->trans, offs, mvm->d3_resume_sram, len);
1358#endif
1359}
1360
Johannes Bergdebff612013-05-14 13:53:45 +02001361static int __iwl_mvm_resume(struct iwl_mvm *mvm, bool test)
Johannes Berg8ca151b2013-01-24 14:25:36 +01001362{
Johannes Berg8ca151b2013-01-24 14:25:36 +01001363 struct iwl_d3_iter_data resume_iter_data = {
1364 .mvm = mvm,
1365 };
1366 struct ieee80211_vif *vif = NULL;
Johannes Berg8ca151b2013-01-24 14:25:36 +01001367 int ret;
1368 enum iwl_d3_status d3_status;
Johannes Berg8ca151b2013-01-24 14:25:36 +01001369
1370 mutex_lock(&mvm->mutex);
1371
1372 /* get the BSS vif pointer again */
1373 ieee80211_iterate_active_interfaces_atomic(
1374 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
1375 iwl_mvm_d3_iface_iterator, &resume_iter_data);
1376
1377 if (WARN_ON(resume_iter_data.error || !resume_iter_data.vif))
1378 goto out_unlock;
1379
1380 vif = resume_iter_data.vif;
1381
Johannes Bergdebff612013-05-14 13:53:45 +02001382 ret = iwl_trans_d3_resume(mvm->trans, &d3_status, test);
Johannes Berg8ca151b2013-01-24 14:25:36 +01001383 if (ret)
1384 goto out_unlock;
1385
1386 if (d3_status != IWL_D3_STATUS_ALIVE) {
1387 IWL_INFO(mvm, "Device was reset during suspend\n");
1388 goto out_unlock;
1389 }
1390
Johannes Bergafc66bb2013-05-03 11:44:16 +02001391 /* query SRAM first in case we want event logging */
1392 iwl_mvm_read_d3_sram(mvm);
1393
Johannes Berg9b26b502013-01-22 13:02:09 +01001394 iwl_mvm_query_wakeup_reasons(mvm, vif);
Johannes Berg7abc4632013-08-06 18:28:26 +02001395 /* has unlocked the mutex, so skip that */
1396 goto out;
Johannes Berg8ca151b2013-01-24 14:25:36 +01001397
1398 out_unlock:
1399 mutex_unlock(&mvm->mutex);
1400
Johannes Berg7abc4632013-08-06 18:28:26 +02001401 out:
Johannes Bergdebff612013-05-14 13:53:45 +02001402 if (!test && vif)
Johannes Berg8ca151b2013-01-24 14:25:36 +01001403 ieee80211_resume_disconnect(vif);
1404
1405 /* return 1 to reconfigure the device */
1406 set_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status);
1407 return 1;
1408}
1409
Johannes Bergdebff612013-05-14 13:53:45 +02001410int iwl_mvm_resume(struct ieee80211_hw *hw)
1411{
1412 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1413
1414 return __iwl_mvm_resume(mvm, false);
1415}
1416
Johannes Berg8ca151b2013-01-24 14:25:36 +01001417void iwl_mvm_set_wakeup(struct ieee80211_hw *hw, bool enabled)
1418{
1419 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1420
1421 device_set_wakeup_enable(mvm->trans->dev, enabled);
1422}
Johannes Bergdebff612013-05-14 13:53:45 +02001423
1424#ifdef CONFIG_IWLWIFI_DEBUGFS
1425static int iwl_mvm_d3_test_open(struct inode *inode, struct file *file)
1426{
1427 struct iwl_mvm *mvm = inode->i_private;
1428 int err;
1429
1430 if (mvm->d3_test_active)
1431 return -EBUSY;
1432
1433 file->private_data = inode->i_private;
1434
1435 ieee80211_stop_queues(mvm->hw);
1436 synchronize_net();
1437
1438 /* start pseudo D3 */
1439 rtnl_lock();
1440 err = __iwl_mvm_suspend(mvm->hw, mvm->hw->wiphy->wowlan_config, true);
1441 rtnl_unlock();
1442 if (err > 0)
1443 err = -EINVAL;
1444 if (err) {
1445 ieee80211_wake_queues(mvm->hw);
1446 return err;
1447 }
1448 mvm->d3_test_active = true;
1449 return 0;
1450}
1451
1452static ssize_t iwl_mvm_d3_test_read(struct file *file, char __user *user_buf,
1453 size_t count, loff_t *ppos)
1454{
1455 struct iwl_mvm *mvm = file->private_data;
1456 u32 pme_asserted;
1457
1458 while (true) {
1459 pme_asserted = iwl_trans_read_mem32(mvm->trans,
1460 mvm->d3_test_pme_ptr);
1461 if (pme_asserted)
1462 break;
1463 if (msleep_interruptible(100))
1464 break;
1465 }
1466
1467 return 0;
1468}
1469
1470static void iwl_mvm_d3_test_disconn_work_iter(void *_data, u8 *mac,
1471 struct ieee80211_vif *vif)
1472{
1473 if (vif->type == NL80211_IFTYPE_STATION)
1474 ieee80211_connection_loss(vif);
1475}
1476
1477static int iwl_mvm_d3_test_release(struct inode *inode, struct file *file)
1478{
1479 struct iwl_mvm *mvm = inode->i_private;
1480 int remaining_time = 10;
1481
1482 mvm->d3_test_active = false;
1483 __iwl_mvm_resume(mvm, true);
1484 iwl_abort_notification_waits(&mvm->notif_wait);
1485 ieee80211_restart_hw(mvm->hw);
1486
1487 /* wait for restart and disconnect all interfaces */
1488 while (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) &&
1489 remaining_time > 0) {
1490 remaining_time--;
1491 msleep(1000);
1492 }
1493
1494 if (remaining_time == 0)
1495 IWL_ERR(mvm, "Timed out waiting for HW restart to finish!\n");
1496
1497 ieee80211_iterate_active_interfaces_atomic(
1498 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
1499 iwl_mvm_d3_test_disconn_work_iter, NULL);
1500
1501 ieee80211_wake_queues(mvm->hw);
1502
1503 return 0;
1504}
1505
1506const struct file_operations iwl_dbgfs_d3_test_ops = {
1507 .llseek = no_llseek,
1508 .open = iwl_mvm_d3_test_open,
1509 .read = iwl_mvm_d3_test_read,
1510 .release = iwl_mvm_d3_test_release,
1511};
1512#endif