iwlwifi: mvm: refactor the way fw_key_table is handled
[deliverable/linux.git] / drivers / net / wireless / intel / iwlwifi / mvm / d3.c
CommitLineData
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.
65ff556b 9 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
8ca151b5
JB
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of version 2 of the GNU General Public License as
13 * published by the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
23 * USA
24 *
25 * The full GNU General Public License is included in this distribution
410dc5aa 26 * in the file called COPYING.
8ca151b5
JB
27 *
28 * Contact Information:
cb2f8277 29 * Intel Linux Wireless <linuxwifi@intel.com>
8ca151b5
JB
30 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
31 *
32 * BSD LICENSE
33 *
51368bf7 34 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
65ff556b 35 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
8ca151b5
JB
36 * All rights reserved.
37 *
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
40 * are met:
41 *
42 * * Redistributions of source code must retain the above copyright
43 * notice, this list of conditions and the following disclaimer.
44 * * Redistributions in binary form must reproduce the above copyright
45 * notice, this list of conditions and the following disclaimer in
46 * the documentation and/or other materials provided with the
47 * distribution.
48 * * Neither the name Intel Corporation nor the names of its
49 * contributors may be used to endorse or promote products derived
50 * from this software without specific prior written permission.
51 *
52 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
53 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
54 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
55 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
56 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
57 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
58 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
59 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
60 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
61 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
62 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
63 *
64 *****************************************************************************/
65
f444eb10 66#include <linux/etherdevice.h>
f0c2646a 67#include <linux/ip.h>
debff618 68#include <linux/fs.h>
8ca151b5
JB
69#include <net/cfg80211.h>
70#include <net/ipv6.h>
f0c2646a 71#include <net/tcp.h>
f7fc5989 72#include <net/addrconf.h>
8ca151b5
JB
73#include "iwl-modparams.h"
74#include "fw-api.h"
75#include "mvm.h"
76
77void iwl_mvm_set_rekey_data(struct ieee80211_hw *hw,
78 struct ieee80211_vif *vif,
79 struct cfg80211_gtk_rekey_data *data)
80{
81 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
82 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
83
84 if (iwlwifi_mod_params.sw_crypto)
85 return;
86
87 mutex_lock(&mvm->mutex);
88
89 memcpy(mvmvif->rekey_data.kek, data->kek, NL80211_KEK_LEN);
90 memcpy(mvmvif->rekey_data.kck, data->kck, NL80211_KCK_LEN);
91 mvmvif->rekey_data.replay_ctr =
92 cpu_to_le64(be64_to_cpup((__be64 *)&data->replay_ctr));
93 mvmvif->rekey_data.valid = true;
94
95 mutex_unlock(&mvm->mutex);
96}
97
98#if IS_ENABLED(CONFIG_IPV6)
99void iwl_mvm_ipv6_addr_change(struct ieee80211_hw *hw,
100 struct ieee80211_vif *vif,
101 struct inet6_dev *idev)
102{
103 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
104 struct inet6_ifaddr *ifa;
105 int idx = 0;
106
c97dab40
SS
107 memset(mvmvif->tentative_addrs, 0, sizeof(mvmvif->tentative_addrs));
108
a3777e0f 109 read_lock_bh(&idev->lock);
8ca151b5
JB
110 list_for_each_entry(ifa, &idev->addr_list, if_list) {
111 mvmvif->target_ipv6_addrs[idx] = ifa->addr;
c97dab40
SS
112 if (ifa->flags & IFA_F_TENTATIVE)
113 __set_bit(idx, mvmvif->tentative_addrs);
8ca151b5 114 idx++;
5369d6c1 115 if (idx >= IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX)
8ca151b5
JB
116 break;
117 }
a3777e0f 118 read_unlock_bh(&idev->lock);
8ca151b5
JB
119
120 mvmvif->num_target_ipv6_addrs = idx;
121}
122#endif
123
124void iwl_mvm_set_default_unicast_key(struct ieee80211_hw *hw,
125 struct ieee80211_vif *vif, int idx)
126{
127 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
128
129 mvmvif->tx_key_idx = idx;
130}
131
132static void iwl_mvm_convert_p1k(u16 *p1k, __le16 *out)
133{
134 int i;
135
136 for (i = 0; i < IWL_P1K_SIZE; i++)
137 out[i] = cpu_to_le16(p1k[i]);
138}
139
140struct wowlan_key_data {
141 struct iwl_wowlan_rsc_tsc_params_cmd *rsc_tsc;
142 struct iwl_wowlan_tkip_params_cmd *tkip;
ac8ef0ce 143 bool error, use_rsc_tsc, use_tkip, configure_keys;
5312e54d 144 int wep_key_idx;
8ca151b5
JB
145};
146
147static void iwl_mvm_wowlan_program_keys(struct ieee80211_hw *hw,
148 struct ieee80211_vif *vif,
149 struct ieee80211_sta *sta,
150 struct ieee80211_key_conf *key,
151 void *_data)
152{
153 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
154 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
155 struct wowlan_key_data *data = _data;
156 struct aes_sc *aes_sc, *aes_tx_sc = NULL;
157 struct tkip_sc *tkip_sc, *tkip_tx_sc = NULL;
158 struct iwl_p1k_cache *rx_p1ks;
159 u8 *rx_mic_key;
160 struct ieee80211_key_seq seq;
161 u32 cur_rx_iv32 = 0;
162 u16 p1k[IWL_P1K_SIZE];
163 int ret, i;
164
8ca151b5
JB
165 switch (key->cipher) {
166 case WLAN_CIPHER_SUITE_WEP40:
167 case WLAN_CIPHER_SUITE_WEP104: { /* hack it for now */
168 struct {
169 struct iwl_mvm_wep_key_cmd wep_key_cmd;
170 struct iwl_mvm_wep_key wep_key;
171 } __packed wkc = {
172 .wep_key_cmd.mac_id_n_color =
173 cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id,
174 mvmvif->color)),
175 .wep_key_cmd.num_keys = 1,
176 /* firmware sets STA_KEY_FLG_WEP_13BYTES */
177 .wep_key_cmd.decryption_type = STA_KEY_FLG_WEP,
178 .wep_key.key_index = key->keyidx,
179 .wep_key.key_size = key->keylen,
180 };
181
182 /*
183 * This will fail -- the key functions don't set support
184 * pairwise WEP keys. However, that's better than silently
185 * failing WoWLAN. Or maybe not?
186 */
187 if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE)
188 break;
189
190 memcpy(&wkc.wep_key.key[3], key->key, key->keylen);
191 if (key->keyidx == mvmvif->tx_key_idx) {
192 /* TX key must be at offset 0 */
193 wkc.wep_key.key_offset = 0;
194 } else {
195 /* others start at 1 */
5312e54d
JB
196 data->wep_key_idx++;
197 wkc.wep_key.key_offset = data->wep_key_idx;
8ca151b5
JB
198 }
199
ac8ef0ce
EP
200 if (data->configure_keys) {
201 mutex_lock(&mvm->mutex);
202 ret = iwl_mvm_send_cmd_pdu(mvm, WEP_KEY, 0,
203 sizeof(wkc), &wkc);
204 data->error = ret != 0;
205
206 mvm->ptk_ivlen = key->iv_len;
207 mvm->ptk_icvlen = key->icv_len;
208 mvm->gtk_ivlen = key->iv_len;
209 mvm->gtk_icvlen = key->icv_len;
210 mutex_unlock(&mvm->mutex);
211 }
f444eb10 212
8ca151b5 213 /* don't upload key again */
ac8ef0ce 214 return;
8ca151b5
JB
215 }
216 default:
217 data->error = true;
ac8ef0ce 218 return;
8ca151b5
JB
219 case WLAN_CIPHER_SUITE_AES_CMAC:
220 /*
221 * Ignore CMAC keys -- the WoWLAN firmware doesn't support them
222 * but we also shouldn't abort suspend due to that. It does have
223 * support for the IGTK key renewal, but doesn't really use the
224 * IGTK for anything. This means we could spuriously wake up or
225 * be deauthenticated, but that was considered acceptable.
226 */
ac8ef0ce 227 return;
8ca151b5
JB
228 case WLAN_CIPHER_SUITE_TKIP:
229 if (sta) {
230 tkip_sc = data->rsc_tsc->all_tsc_rsc.tkip.unicast_rsc;
231 tkip_tx_sc = &data->rsc_tsc->all_tsc_rsc.tkip.tsc;
232
233 rx_p1ks = data->tkip->rx_uni;
234
235 ieee80211_get_key_tx_seq(key, &seq);
236 tkip_tx_sc->iv16 = cpu_to_le16(seq.tkip.iv16);
237 tkip_tx_sc->iv32 = cpu_to_le32(seq.tkip.iv32);
238
239 ieee80211_get_tkip_p1k_iv(key, seq.tkip.iv32, p1k);
240 iwl_mvm_convert_p1k(p1k, data->tkip->tx.p1k);
241
242 memcpy(data->tkip->mic_keys.tx,
243 &key->key[NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY],
244 IWL_MIC_KEY_SIZE);
245
246 rx_mic_key = data->tkip->mic_keys.rx_unicast;
247 } else {
248 tkip_sc =
249 data->rsc_tsc->all_tsc_rsc.tkip.multicast_rsc;
250 rx_p1ks = data->tkip->rx_multi;
251 rx_mic_key = data->tkip->mic_keys.rx_mcast;
252 }
253
254 /*
255 * For non-QoS this relies on the fact that both the uCode and
256 * mac80211 use TID 0 (as they need to to avoid replay attacks)
257 * for checking the IV in the frames.
258 */
259 for (i = 0; i < IWL_NUM_RSC; i++) {
260 ieee80211_get_key_rx_seq(key, i, &seq);
261 tkip_sc[i].iv16 = cpu_to_le16(seq.tkip.iv16);
262 tkip_sc[i].iv32 = cpu_to_le32(seq.tkip.iv32);
263 /* wrapping isn't allowed, AP must rekey */
264 if (seq.tkip.iv32 > cur_rx_iv32)
265 cur_rx_iv32 = seq.tkip.iv32;
266 }
267
268 ieee80211_get_tkip_rx_p1k(key, vif->bss_conf.bssid,
269 cur_rx_iv32, p1k);
270 iwl_mvm_convert_p1k(p1k, rx_p1ks[0].p1k);
271 ieee80211_get_tkip_rx_p1k(key, vif->bss_conf.bssid,
272 cur_rx_iv32 + 1, p1k);
273 iwl_mvm_convert_p1k(p1k, rx_p1ks[1].p1k);
274
275 memcpy(rx_mic_key,
276 &key->key[NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY],
277 IWL_MIC_KEY_SIZE);
278
279 data->use_tkip = true;
280 data->use_rsc_tsc = true;
281 break;
282 case WLAN_CIPHER_SUITE_CCMP:
283 if (sta) {
6645d5e4 284 u64 pn64;
8ca151b5
JB
285
286 aes_sc = data->rsc_tsc->all_tsc_rsc.aes.unicast_rsc;
287 aes_tx_sc = &data->rsc_tsc->all_tsc_rsc.aes.tsc;
288
6645d5e4
JB
289 pn64 = atomic64_read(&key->tx_pn);
290 aes_tx_sc->pn = cpu_to_le64(pn64);
8ca151b5
JB
291 } else {
292 aes_sc = data->rsc_tsc->all_tsc_rsc.aes.multicast_rsc;
293 }
294
295 /*
296 * For non-QoS this relies on the fact that both the uCode and
297 * mac80211 use TID 0 for checking the IV in the frames.
298 */
299 for (i = 0; i < IWL_NUM_RSC; i++) {
300 u8 *pn = seq.ccmp.pn;
301
302 ieee80211_get_key_rx_seq(key, i, &seq);
2cf5eb3a
JB
303 aes_sc[i].pn = cpu_to_le64((u64)pn[5] |
304 ((u64)pn[4] << 8) |
305 ((u64)pn[3] << 16) |
306 ((u64)pn[2] << 24) |
307 ((u64)pn[1] << 32) |
308 ((u64)pn[0] << 40));
8ca151b5
JB
309 }
310 data->use_rsc_tsc = true;
311 break;
312 }
313
ac8ef0ce
EP
314 if (data->configure_keys) {
315 mutex_lock(&mvm->mutex);
5312e54d 316 /*
ac8ef0ce
EP
317 * The D3 firmware hardcodes the key offset 0 as the key it
318 * uses to transmit packets to the AP, i.e. the PTK.
5312e54d 319 */
ac8ef0ce
EP
320 if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) {
321 mvm->ptk_ivlen = key->iv_len;
322 mvm->ptk_icvlen = key->icv_len;
323 ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, 0);
324 } else {
325 /*
326 * firmware only supports TSC/RSC for a single key,
327 * so if there are multiple keep overwriting them
328 * with new ones -- this relies on mac80211 doing
329 * list_add_tail().
330 */
331 mvm->gtk_ivlen = key->iv_len;
332 mvm->gtk_icvlen = key->icv_len;
333 ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, 1);
334 }
335 mutex_unlock(&mvm->mutex);
336 data->error = ret != 0;
8ca151b5 337 }
8ca151b5
JB
338}
339
340static int iwl_mvm_send_patterns(struct iwl_mvm *mvm,
341 struct cfg80211_wowlan *wowlan)
342{
343 struct iwl_wowlan_patterns_cmd *pattern_cmd;
344 struct iwl_host_cmd cmd = {
345 .id = WOWLAN_PATTERNS,
346 .dataflags[0] = IWL_HCMD_DFL_NOCOPY,
8ca151b5
JB
347 };
348 int i, err;
349
350 if (!wowlan->n_patterns)
351 return 0;
352
353 cmd.len[0] = sizeof(*pattern_cmd) +
354 wowlan->n_patterns * sizeof(struct iwl_wowlan_pattern);
355
356 pattern_cmd = kmalloc(cmd.len[0], GFP_KERNEL);
357 if (!pattern_cmd)
358 return -ENOMEM;
359
360 pattern_cmd->n_patterns = cpu_to_le32(wowlan->n_patterns);
361
362 for (i = 0; i < wowlan->n_patterns; i++) {
363 int mask_len = DIV_ROUND_UP(wowlan->patterns[i].pattern_len, 8);
364
365 memcpy(&pattern_cmd->patterns[i].mask,
366 wowlan->patterns[i].mask, mask_len);
367 memcpy(&pattern_cmd->patterns[i].pattern,
368 wowlan->patterns[i].pattern,
369 wowlan->patterns[i].pattern_len);
370 pattern_cmd->patterns[i].mask_size = mask_len;
371 pattern_cmd->patterns[i].pattern_size =
372 wowlan->patterns[i].pattern_len;
373 }
374
375 cmd.data[0] = pattern_cmd;
376 err = iwl_mvm_send_cmd(mvm, &cmd);
377 kfree(pattern_cmd);
378 return err;
379}
380
f0c2646a
JB
381enum iwl_mvm_tcp_packet_type {
382 MVM_TCP_TX_SYN,
383 MVM_TCP_RX_SYNACK,
384 MVM_TCP_TX_DATA,
385 MVM_TCP_RX_ACK,
386 MVM_TCP_RX_WAKE,
387 MVM_TCP_TX_FIN,
388};
389
390static __le16 pseudo_hdr_check(int len, __be32 saddr, __be32 daddr)
391{
392 __sum16 check = tcp_v4_check(len, saddr, daddr, 0);
393 return cpu_to_le16(be16_to_cpu((__force __be16)check));
394}
395
b002c7e1 396static void iwl_mvm_build_tcp_packet(struct ieee80211_vif *vif,
f0c2646a
JB
397 struct cfg80211_wowlan_tcp *tcp,
398 void *_pkt, u8 *mask,
399 __le16 *pseudo_hdr_csum,
400 enum iwl_mvm_tcp_packet_type ptype)
401{
402 struct {
403 struct ethhdr eth;
404 struct iphdr ip;
405 struct tcphdr tcp;
406 u8 data[];
407 } __packed *pkt = _pkt;
408 u16 ip_tot_len = sizeof(struct iphdr) + sizeof(struct tcphdr);
409 int i;
410
411 pkt->eth.h_proto = cpu_to_be16(ETH_P_IP),
412 pkt->ip.version = 4;
413 pkt->ip.ihl = 5;
414 pkt->ip.protocol = IPPROTO_TCP;
415
416 switch (ptype) {
417 case MVM_TCP_TX_SYN:
418 case MVM_TCP_TX_DATA:
419 case MVM_TCP_TX_FIN:
420 memcpy(pkt->eth.h_dest, tcp->dst_mac, ETH_ALEN);
421 memcpy(pkt->eth.h_source, vif->addr, ETH_ALEN);
422 pkt->ip.ttl = 128;
423 pkt->ip.saddr = tcp->src;
424 pkt->ip.daddr = tcp->dst;
425 pkt->tcp.source = cpu_to_be16(tcp->src_port);
426 pkt->tcp.dest = cpu_to_be16(tcp->dst_port);
427 /* overwritten for TX SYN later */
428 pkt->tcp.doff = sizeof(struct tcphdr) / 4;
429 pkt->tcp.window = cpu_to_be16(65000);
430 break;
431 case MVM_TCP_RX_SYNACK:
432 case MVM_TCP_RX_ACK:
433 case MVM_TCP_RX_WAKE:
434 memcpy(pkt->eth.h_dest, vif->addr, ETH_ALEN);
435 memcpy(pkt->eth.h_source, tcp->dst_mac, ETH_ALEN);
436 pkt->ip.saddr = tcp->dst;
437 pkt->ip.daddr = tcp->src;
438 pkt->tcp.source = cpu_to_be16(tcp->dst_port);
439 pkt->tcp.dest = cpu_to_be16(tcp->src_port);
440 break;
441 default:
442 WARN_ON(1);
443 return;
444 }
445
446 switch (ptype) {
447 case MVM_TCP_TX_SYN:
448 /* firmware assumes 8 option bytes - 8 NOPs for now */
449 memset(pkt->data, 0x01, 8);
450 ip_tot_len += 8;
451 pkt->tcp.doff = (sizeof(struct tcphdr) + 8) / 4;
452 pkt->tcp.syn = 1;
453 break;
454 case MVM_TCP_TX_DATA:
455 ip_tot_len += tcp->payload_len;
456 memcpy(pkt->data, tcp->payload, tcp->payload_len);
457 pkt->tcp.psh = 1;
458 pkt->tcp.ack = 1;
459 break;
460 case MVM_TCP_TX_FIN:
461 pkt->tcp.fin = 1;
462 pkt->tcp.ack = 1;
463 break;
464 case MVM_TCP_RX_SYNACK:
465 pkt->tcp.syn = 1;
466 pkt->tcp.ack = 1;
467 break;
468 case MVM_TCP_RX_ACK:
469 pkt->tcp.ack = 1;
470 break;
471 case MVM_TCP_RX_WAKE:
472 ip_tot_len += tcp->wake_len;
473 pkt->tcp.psh = 1;
474 pkt->tcp.ack = 1;
475 memcpy(pkt->data, tcp->wake_data, tcp->wake_len);
476 break;
477 }
478
479 switch (ptype) {
480 case MVM_TCP_TX_SYN:
481 case MVM_TCP_TX_DATA:
482 case MVM_TCP_TX_FIN:
483 pkt->ip.tot_len = cpu_to_be16(ip_tot_len);
484 pkt->ip.check = ip_fast_csum(&pkt->ip, pkt->ip.ihl);
485 break;
486 case MVM_TCP_RX_WAKE:
487 for (i = 0; i < DIV_ROUND_UP(tcp->wake_len, 8); i++) {
488 u8 tmp = tcp->wake_mask[i];
489 mask[i + 6] |= tmp << 6;
490 if (i + 1 < DIV_ROUND_UP(tcp->wake_len, 8))
491 mask[i + 7] = tmp >> 2;
492 }
493 /* fall through for ethernet/IP/TCP headers mask */
494 case MVM_TCP_RX_SYNACK:
495 case MVM_TCP_RX_ACK:
496 mask[0] = 0xff; /* match ethernet */
497 /*
498 * match ethernet, ip.version, ip.ihl
499 * the ip.ihl half byte is really masked out by firmware
500 */
501 mask[1] = 0x7f;
502 mask[2] = 0x80; /* match ip.protocol */
503 mask[3] = 0xfc; /* match ip.saddr, ip.daddr */
504 mask[4] = 0x3f; /* match ip.daddr, tcp.source, tcp.dest */
505 mask[5] = 0x80; /* match tcp flags */
506 /* leave rest (0 or set for MVM_TCP_RX_WAKE) */
507 break;
508 };
509
510 *pseudo_hdr_csum = pseudo_hdr_check(ip_tot_len - sizeof(struct iphdr),
511 pkt->ip.saddr, pkt->ip.daddr);
512}
513
514static int iwl_mvm_send_remote_wake_cfg(struct iwl_mvm *mvm,
515 struct ieee80211_vif *vif,
516 struct cfg80211_wowlan_tcp *tcp)
517{
518 struct iwl_wowlan_remote_wake_config *cfg;
519 struct iwl_host_cmd cmd = {
520 .id = REMOTE_WAKE_CONFIG_CMD,
521 .len = { sizeof(*cfg), },
522 .dataflags = { IWL_HCMD_DFL_NOCOPY, },
f0c2646a
JB
523 };
524 int ret;
525
526 if (!tcp)
527 return 0;
528
529 cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
530 if (!cfg)
531 return -ENOMEM;
532 cmd.data[0] = cfg;
533
534 cfg->max_syn_retries = 10;
535 cfg->max_data_retries = 10;
536 cfg->tcp_syn_ack_timeout = 1; /* seconds */
537 cfg->tcp_ack_timeout = 1; /* seconds */
538
539 /* SYN (TX) */
540 iwl_mvm_build_tcp_packet(
b002c7e1 541 vif, tcp, cfg->syn_tx.data, NULL,
f0c2646a
JB
542 &cfg->syn_tx.info.tcp_pseudo_header_checksum,
543 MVM_TCP_TX_SYN);
544 cfg->syn_tx.info.tcp_payload_length = 0;
545
546 /* SYN/ACK (RX) */
547 iwl_mvm_build_tcp_packet(
b002c7e1 548 vif, tcp, cfg->synack_rx.data, cfg->synack_rx.rx_mask,
f0c2646a
JB
549 &cfg->synack_rx.info.tcp_pseudo_header_checksum,
550 MVM_TCP_RX_SYNACK);
551 cfg->synack_rx.info.tcp_payload_length = 0;
552
553 /* KEEPALIVE/ACK (TX) */
554 iwl_mvm_build_tcp_packet(
b002c7e1 555 vif, tcp, cfg->keepalive_tx.data, NULL,
f0c2646a
JB
556 &cfg->keepalive_tx.info.tcp_pseudo_header_checksum,
557 MVM_TCP_TX_DATA);
558 cfg->keepalive_tx.info.tcp_payload_length =
559 cpu_to_le16(tcp->payload_len);
560 cfg->sequence_number_offset = tcp->payload_seq.offset;
561 /* length must be 0..4, the field is little endian */
562 cfg->sequence_number_length = tcp->payload_seq.len;
563 cfg->initial_sequence_number = cpu_to_le32(tcp->payload_seq.start);
564 cfg->keepalive_interval = cpu_to_le16(tcp->data_interval);
565 if (tcp->payload_tok.len) {
566 cfg->token_offset = tcp->payload_tok.offset;
567 cfg->token_length = tcp->payload_tok.len;
568 cfg->num_tokens =
569 cpu_to_le16(tcp->tokens_size % tcp->payload_tok.len);
570 memcpy(cfg->tokens, tcp->payload_tok.token_stream,
571 tcp->tokens_size);
572 } else {
573 /* set tokens to max value to almost never run out */
574 cfg->num_tokens = cpu_to_le16(65535);
575 }
576
577 /* ACK (RX) */
578 iwl_mvm_build_tcp_packet(
b002c7e1 579 vif, tcp, cfg->keepalive_ack_rx.data,
f0c2646a
JB
580 cfg->keepalive_ack_rx.rx_mask,
581 &cfg->keepalive_ack_rx.info.tcp_pseudo_header_checksum,
582 MVM_TCP_RX_ACK);
583 cfg->keepalive_ack_rx.info.tcp_payload_length = 0;
584
585 /* WAKEUP (RX) */
586 iwl_mvm_build_tcp_packet(
b002c7e1 587 vif, tcp, cfg->wake_rx.data, cfg->wake_rx.rx_mask,
f0c2646a
JB
588 &cfg->wake_rx.info.tcp_pseudo_header_checksum,
589 MVM_TCP_RX_WAKE);
590 cfg->wake_rx.info.tcp_payload_length =
591 cpu_to_le16(tcp->wake_len);
592
593 /* FIN */
594 iwl_mvm_build_tcp_packet(
b002c7e1 595 vif, tcp, cfg->fin_tx.data, NULL,
f0c2646a
JB
596 &cfg->fin_tx.info.tcp_pseudo_header_checksum,
597 MVM_TCP_TX_FIN);
598 cfg->fin_tx.info.tcp_payload_length = 0;
599
600 ret = iwl_mvm_send_cmd(mvm, &cmd);
601 kfree(cfg);
602
603 return ret;
604}
605
8ca151b5
JB
606static int iwl_mvm_d3_reprogram(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
607 struct ieee80211_sta *ap_sta)
608{
609 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
610 struct ieee80211_chanctx_conf *ctx;
611 u8 chains_static, chains_dynamic;
612 struct cfg80211_chan_def chandef;
613 int ret, i;
614 struct iwl_binding_cmd binding_cmd = {};
615 struct iwl_time_quota_cmd quota_cmd = {};
616 u32 status;
617
618 /* add back the PHY */
619 if (WARN_ON(!mvmvif->phy_ctxt))
620 return -EINVAL;
621
622 rcu_read_lock();
623 ctx = rcu_dereference(vif->chanctx_conf);
624 if (WARN_ON(!ctx)) {
625 rcu_read_unlock();
626 return -EINVAL;
627 }
628 chandef = ctx->def;
629 chains_static = ctx->rx_chains_static;
630 chains_dynamic = ctx->rx_chains_dynamic;
631 rcu_read_unlock();
632
633 ret = iwl_mvm_phy_ctxt_add(mvm, mvmvif->phy_ctxt, &chandef,
634 chains_static, chains_dynamic);
635 if (ret)
636 return ret;
637
638 /* add back the MAC */
639 mvmvif->uploaded = false;
640
641 if (WARN_ON(!vif->bss_conf.assoc))
642 return -EINVAL;
bca49d9a 643
8ca151b5 644 ret = iwl_mvm_mac_ctxt_add(mvm, vif);
8ca151b5
JB
645 if (ret)
646 return ret;
647
648 /* add back binding - XXX refactor? */
649 binding_cmd.id_and_color =
650 cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->phy_ctxt->id,
651 mvmvif->phy_ctxt->color));
652 binding_cmd.action = cpu_to_le32(FW_CTXT_ACTION_ADD);
653 binding_cmd.phy =
654 cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->phy_ctxt->id,
655 mvmvif->phy_ctxt->color));
656 binding_cmd.macs[0] = cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id,
657 mvmvif->color));
658 for (i = 1; i < MAX_MACS_IN_BINDING; i++)
659 binding_cmd.macs[i] = cpu_to_le32(FW_CTXT_INVALID);
660
661 status = 0;
662 ret = iwl_mvm_send_cmd_pdu_status(mvm, BINDING_CONTEXT_CMD,
663 sizeof(binding_cmd), &binding_cmd,
664 &status);
665 if (ret) {
666 IWL_ERR(mvm, "Failed to add binding: %d\n", ret);
667 return ret;
668 }
669
670 if (status) {
671 IWL_ERR(mvm, "Binding command failed: %u\n", status);
672 return -EIO;
673 }
674
7a453973 675 ret = iwl_mvm_sta_send_to_fw(mvm, ap_sta, false);
8ca151b5
JB
676 if (ret)
677 return ret;
678 rcu_assign_pointer(mvm->fw_id_to_mac_id[mvmvif->ap_sta_id], ap_sta);
679
3dfd3a97 680 ret = iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL);
8ca151b5
JB
681 if (ret)
682 return ret;
683
684 /* and some quota */
685 quota_cmd.quotas[0].id_and_color =
686 cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->phy_ctxt->id,
687 mvmvif->phy_ctxt->color));
9a3daf82
EG
688 quota_cmd.quotas[0].quota = cpu_to_le32(IWL_MVM_MAX_QUOTA);
689 quota_cmd.quotas[0].max_duration = cpu_to_le32(IWL_MVM_MAX_QUOTA);
8ca151b5
JB
690
691 for (i = 1; i < MAX_BINDINGS; i++)
692 quota_cmd.quotas[i].id_and_color = cpu_to_le32(FW_CTXT_INVALID);
693
a1022927 694 ret = iwl_mvm_send_cmd_pdu(mvm, TIME_QUOTA_CMD, 0,
8ca151b5
JB
695 sizeof(quota_cmd), &quota_cmd);
696 if (ret)
697 IWL_ERR(mvm, "Failed to send quota: %d\n", ret);
698
47c8b154
JD
699 if (iwl_mvm_is_lar_supported(mvm) && iwl_mvm_init_fw_regd(mvm))
700 IWL_ERR(mvm, "Failed to initialize D3 LAR information\n");
701
8ca151b5
JB
702 return 0;
703}
704
4ac6cb59
JB
705static int iwl_mvm_get_last_nonqos_seq(struct iwl_mvm *mvm,
706 struct ieee80211_vif *vif)
707{
6d9d32b8
JB
708 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
709 struct iwl_nonqos_seq_query_cmd query_cmd = {
710 .get_set_flag = cpu_to_le32(IWL_NONQOS_SEQ_GET),
711 .mac_id_n_color =
712 cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id,
713 mvmvif->color)),
714 };
4ac6cb59
JB
715 struct iwl_host_cmd cmd = {
716 .id = NON_QOS_TX_COUNTER_CMD,
a1022927 717 .flags = CMD_WANT_SKB,
4ac6cb59
JB
718 };
719 int err;
720 u32 size;
721
3afec639
EG
722 cmd.data[0] = &query_cmd;
723 cmd.len[0] = sizeof(query_cmd);
6d9d32b8 724
4ac6cb59
JB
725 err = iwl_mvm_send_cmd(mvm, &cmd);
726 if (err)
727 return err;
728
65b30348 729 size = iwl_rx_packet_payload_len(cmd.resp_pkt);
6d9d32b8 730 if (size < sizeof(__le16)) {
4ac6cb59 731 err = -EINVAL;
6d9d32b8
JB
732 } else {
733 err = le16_to_cpup((__le16 *)cmd.resp_pkt->data);
3afec639
EG
734 /* firmware returns next, not last-used seqno */
735 err = (u16) (err - 0x10);
6d9d32b8 736 }
4ac6cb59
JB
737
738 iwl_free_resp(&cmd);
739 return err;
740}
741
6d9d32b8
JB
742void iwl_mvm_set_last_nonqos_seq(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
743{
744 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
745 struct iwl_nonqos_seq_query_cmd query_cmd = {
746 .get_set_flag = cpu_to_le32(IWL_NONQOS_SEQ_SET),
747 .mac_id_n_color =
748 cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id,
749 mvmvif->color)),
750 .value = cpu_to_le16(mvmvif->seqno),
751 };
752
753 /* return if called during restart, not resume from D3 */
754 if (!mvmvif->seqno_valid)
755 return;
756
757 mvmvif->seqno_valid = false;
758
a1022927 759 if (iwl_mvm_send_cmd_pdu(mvm, NON_QOS_TX_COUNTER_CMD, 0,
6d9d32b8
JB
760 sizeof(query_cmd), &query_cmd))
761 IWL_ERR(mvm, "failed to set non-QoS seqno\n");
762}
763
671b5820
LC
764static int iwl_mvm_switch_to_d3(struct iwl_mvm *mvm)
765{
c7d42480 766 iwl_mvm_scan_stop(mvm, IWL_MVM_SCAN_REGULAR, true);
671b5820
LC
767
768 iwl_trans_stop_device(mvm->trans);
769
770 /*
771 * Set the HW restart bit -- this is mostly true as we're
772 * going to load new firmware and reprogram that, though
773 * the reprogramming is going to be manual to avoid adding
774 * all the MACs that aren't support.
775 * We don't have to clear up everything though because the
776 * reprogramming is manual. When we resume, we'll actually
777 * go through a proper restart sequence again to switch
778 * back to the runtime firmware image.
779 */
780 set_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status);
781
9c3deeb5
LC
782 /* the fw is reset, so all the keys are cleared */
783 memset(mvm->fw_key_table, 0, sizeof(mvm->fw_key_table));
784
671b5820
LC
785 mvm->ptk_ivlen = 0;
786 mvm->ptk_icvlen = 0;
787 mvm->ptk_ivlen = 0;
788 mvm->ptk_icvlen = 0;
789
790 return iwl_mvm_load_d3_fw(mvm);
791}
792
671b5820
LC
793static int
794iwl_mvm_get_wowlan_config(struct iwl_mvm *mvm,
795 struct cfg80211_wowlan *wowlan,
c8b06a99 796 struct iwl_wowlan_config_cmd *wowlan_config_cmd,
671b5820
LC
797 struct ieee80211_vif *vif, struct iwl_mvm_vif *mvmvif,
798 struct ieee80211_sta *ap_sta)
8ca151b5 799{
1a95c8df 800 int ret;
9d8ce6af 801 struct iwl_mvm_sta *mvm_ap_sta = iwl_mvm_sta_from_mac80211(ap_sta);
8ca151b5 802
c8b06a99 803 /* TODO: wowlan_config_cmd->wowlan_ba_teardown_tids */
8ca151b5 804
c8b06a99 805 wowlan_config_cmd->is_11n_connection =
1a95c8df 806 ap_sta->ht_cap.ht_supported;
8ca151b5 807
4ac6cb59
JB
808 /* Query the last used seqno and set it */
809 ret = iwl_mvm_get_last_nonqos_seq(mvm, vif);
810 if (ret < 0)
671b5820 811 return ret;
8ca151b5 812
c8b06a99 813 wowlan_config_cmd->non_qos_seq = cpu_to_le16(ret);
671b5820 814
c8b06a99 815 iwl_mvm_set_wowlan_qos_seq(mvm_ap_sta, wowlan_config_cmd);
8ca151b5
JB
816
817 if (wowlan->disconnect)
c8b06a99 818 wowlan_config_cmd->wakeup_filter |=
8ca151b5
JB
819 cpu_to_le32(IWL_WOWLAN_WAKEUP_BEACON_MISS |
820 IWL_WOWLAN_WAKEUP_LINK_CHANGE);
821 if (wowlan->magic_pkt)
c8b06a99 822 wowlan_config_cmd->wakeup_filter |=
8ca151b5
JB
823 cpu_to_le32(IWL_WOWLAN_WAKEUP_MAGIC_PACKET);
824 if (wowlan->gtk_rekey_failure)
c8b06a99 825 wowlan_config_cmd->wakeup_filter |=
8ca151b5
JB
826 cpu_to_le32(IWL_WOWLAN_WAKEUP_GTK_REKEY_FAIL);
827 if (wowlan->eap_identity_req)
c8b06a99 828 wowlan_config_cmd->wakeup_filter |=
8ca151b5
JB
829 cpu_to_le32(IWL_WOWLAN_WAKEUP_EAP_IDENT_REQ);
830 if (wowlan->four_way_handshake)
c8b06a99 831 wowlan_config_cmd->wakeup_filter |=
8ca151b5
JB
832 cpu_to_le32(IWL_WOWLAN_WAKEUP_4WAY_HANDSHAKE);
833 if (wowlan->n_patterns)
c8b06a99 834 wowlan_config_cmd->wakeup_filter |=
8ca151b5
JB
835 cpu_to_le32(IWL_WOWLAN_WAKEUP_PATTERN_MATCH);
836
837 if (wowlan->rfkill_release)
c8b06a99 838 wowlan_config_cmd->wakeup_filter |=
8ca151b5
JB
839 cpu_to_le32(IWL_WOWLAN_WAKEUP_RF_KILL_DEASSERT);
840
f0c2646a
JB
841 if (wowlan->tcp) {
842 /*
6039f3e1
JB
843 * Set the "link change" (really "link lost") flag as well
844 * since that implies losing the TCP connection.
f0c2646a 845 */
c8b06a99 846 wowlan_config_cmd->wakeup_filter |=
f0c2646a
JB
847 cpu_to_le32(IWL_WOWLAN_WAKEUP_REMOTE_LINK_LOSS |
848 IWL_WOWLAN_WAKEUP_REMOTE_SIGNATURE_TABLE |
849 IWL_WOWLAN_WAKEUP_REMOTE_WAKEUP_PACKET |
850 IWL_WOWLAN_WAKEUP_LINK_CHANGE);
851 }
852
671b5820
LC
853 return 0;
854}
f444eb10 855
ac8ef0ce
EP
856int iwl_mvm_wowlan_config_key_params(struct iwl_mvm *mvm,
857 struct ieee80211_vif *vif,
858 bool configure_keys,
859 u32 cmd_flags)
671b5820
LC
860{
861 struct iwl_wowlan_kek_kck_material_cmd kek_kck_cmd = {};
862 struct iwl_wowlan_tkip_params_cmd tkip_cmd = {};
863 struct wowlan_key_data key_data = {
ac8ef0ce 864 .configure_keys = configure_keys,
671b5820
LC
865 .use_rsc_tsc = false,
866 .tkip = &tkip_cmd,
867 .use_tkip = false,
868 };
ac8ef0ce
EP
869 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
870 int ret;
871
872 key_data.rsc_tsc = kzalloc(sizeof(*key_data.rsc_tsc), GFP_KERNEL);
873 if (!key_data.rsc_tsc)
874 return -ENOMEM;
875
876 /*
877 * Note that currently we don't propagate cmd_flags
878 * to the iterator. In case of key_data.configure_keys,
879 * all the configured commands are SYNC, and
880 * iwl_mvm_wowlan_program_keys() will take care of
881 * locking/unlocking mvm->mutex.
882 */
883 ieee80211_iter_keys(mvm->hw, vif,
884 iwl_mvm_wowlan_program_keys,
885 &key_data);
886
887 if (key_data.error) {
888 ret = -EIO;
889 goto out;
890 }
891
892 if (key_data.use_rsc_tsc) {
893 ret = iwl_mvm_send_cmd_pdu(mvm,
894 WOWLAN_TSC_RSC_PARAM, cmd_flags,
895 sizeof(*key_data.rsc_tsc),
896 key_data.rsc_tsc);
897 if (ret)
898 goto out;
899 }
900
901 if (key_data.use_tkip) {
902 ret = iwl_mvm_send_cmd_pdu(mvm,
903 WOWLAN_TKIP_PARAM,
904 cmd_flags, sizeof(tkip_cmd),
905 &tkip_cmd);
906 if (ret)
907 goto out;
908 }
909
910 if (mvmvif->rekey_data.valid) {
911 memset(&kek_kck_cmd, 0, sizeof(kek_kck_cmd));
912 memcpy(kek_kck_cmd.kck, mvmvif->rekey_data.kck,
913 NL80211_KCK_LEN);
914 kek_kck_cmd.kck_len = cpu_to_le16(NL80211_KCK_LEN);
915 memcpy(kek_kck_cmd.kek, mvmvif->rekey_data.kek,
916 NL80211_KEK_LEN);
917 kek_kck_cmd.kek_len = cpu_to_le16(NL80211_KEK_LEN);
918 kek_kck_cmd.replay_ctr = mvmvif->rekey_data.replay_ctr;
919
920 ret = iwl_mvm_send_cmd_pdu(mvm,
921 WOWLAN_KEK_KCK_MATERIAL, cmd_flags,
922 sizeof(kek_kck_cmd),
923 &kek_kck_cmd);
924 if (ret)
925 goto out;
926 }
3f50a690 927 ret = 0;
ac8ef0ce
EP
928out:
929 kfree(key_data.rsc_tsc);
930 return ret;
931}
932
933static int
934iwl_mvm_wowlan_config(struct iwl_mvm *mvm,
935 struct cfg80211_wowlan *wowlan,
936 struct iwl_wowlan_config_cmd *wowlan_config_cmd,
937 struct ieee80211_vif *vif, struct iwl_mvm_vif *mvmvif,
938 struct ieee80211_sta *ap_sta)
939{
671b5820 940 int ret;
8ca151b5 941
3acc952b
LC
942 ret = iwl_mvm_switch_to_d3(mvm);
943 if (ret)
944 return ret;
945
8ca151b5
JB
946 ret = iwl_mvm_d3_reprogram(mvm, vif, ap_sta);
947 if (ret)
671b5820
LC
948 return ret;
949
8ca151b5
JB
950 if (!iwlwifi_mod_params.sw_crypto) {
951 /*
952 * This needs to be unlocked due to lock ordering
953 * constraints. Since we're in the suspend path
954 * that isn't really a problem though.
955 */
956 mutex_unlock(&mvm->mutex);
3f50a690
EP
957 ret = iwl_mvm_wowlan_config_key_params(mvm, vif, true,
958 CMD_ASYNC);
8ca151b5 959 mutex_lock(&mvm->mutex);
3f50a690
EP
960 if (ret)
961 return ret;
8ca151b5
JB
962 }
963
c8b06a99
EG
964 ret = iwl_mvm_send_cmd_pdu(mvm, WOWLAN_CONFIGURATION, 0,
965 sizeof(*wowlan_config_cmd),
966 wowlan_config_cmd);
8ca151b5 967 if (ret)
ac8ef0ce 968 return ret;
8ca151b5
JB
969
970 ret = iwl_mvm_send_patterns(mvm, wowlan);
971 if (ret)
ac8ef0ce 972 return ret;
8ca151b5 973
c97dab40 974 ret = iwl_mvm_send_proto_offload(mvm, vif, false, true, 0);
8ca151b5 975 if (ret)
ac8ef0ce 976 return ret;
8ca151b5 977
f0c2646a 978 ret = iwl_mvm_send_remote_wake_cfg(mvm, vif, wowlan->tcp);
671b5820
LC
979 return ret;
980}
981
3acc952b
LC
982static int
983iwl_mvm_netdetect_config(struct iwl_mvm *mvm,
984 struct cfg80211_wowlan *wowlan,
985 struct cfg80211_sched_scan_request *nd_config,
986 struct ieee80211_vif *vif)
987{
c8b06a99 988 struct iwl_wowlan_config_cmd wowlan_config_cmd = {};
3acc952b
LC
989 int ret;
990
991 ret = iwl_mvm_switch_to_d3(mvm);
992 if (ret)
993 return ret;
994
995 /* rfkill release can be either for wowlan or netdetect */
996 if (wowlan->rfkill_release)
c8b06a99 997 wowlan_config_cmd.wakeup_filter |=
3acc952b
LC
998 cpu_to_le32(IWL_WOWLAN_WAKEUP_RF_KILL_DEASSERT);
999
c8b06a99
EG
1000 ret = iwl_mvm_send_cmd_pdu(mvm, WOWLAN_CONFIGURATION, 0,
1001 sizeof(wowlan_config_cmd),
1002 &wowlan_config_cmd);
3acc952b
LC
1003 if (ret)
1004 return ret;
1005
19945dfb
LC
1006 ret = iwl_mvm_sched_scan_start(mvm, vif, nd_config, &mvm->nd_ies,
1007 IWL_MVM_SCAN_NETDETECT);
d9718da8
LC
1008 if (ret)
1009 return ret;
3acc952b 1010
8ed4e659 1011 if (WARN_ON(mvm->nd_match_sets || mvm->nd_channels))
d9718da8
LC
1012 return -EBUSY;
1013
8ed4e659 1014 /* save the sched scan matchsets... */
d9718da8
LC
1015 if (nd_config->n_match_sets) {
1016 mvm->nd_match_sets = kmemdup(nd_config->match_sets,
1017 sizeof(*nd_config->match_sets) *
1018 nd_config->n_match_sets,
1019 GFP_KERNEL);
1020 if (mvm->nd_match_sets)
1021 mvm->n_nd_match_sets = nd_config->n_match_sets;
1022 }
1023
8ed4e659
LC
1024 /* ...and the sched scan channels for later reporting */
1025 mvm->nd_channels = kmemdup(nd_config->channels,
1026 sizeof(*nd_config->channels) *
1027 nd_config->n_channels,
1028 GFP_KERNEL);
1029 if (mvm->nd_channels)
1030 mvm->n_nd_channels = nd_config->n_channels;
1031
d9718da8
LC
1032 return 0;
1033}
1034
1035static void iwl_mvm_free_nd(struct iwl_mvm *mvm)
1036{
1037 kfree(mvm->nd_match_sets);
1038 mvm->nd_match_sets = NULL;
1039 mvm->n_nd_match_sets = 0;
8ed4e659
LC
1040 kfree(mvm->nd_channels);
1041 mvm->nd_channels = NULL;
1042 mvm->n_nd_channels = 0;
3acc952b
LC
1043}
1044
671b5820
LC
1045static int __iwl_mvm_suspend(struct ieee80211_hw *hw,
1046 struct cfg80211_wowlan *wowlan,
1047 bool test)
1048{
1049 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
671b5820
LC
1050 struct ieee80211_vif *vif = NULL;
1051 struct iwl_mvm_vif *mvmvif = NULL;
1052 struct ieee80211_sta *ap_sta = NULL;
671b5820
LC
1053 struct iwl_d3_manager_config d3_cfg_cmd_data = {
1054 /*
1055 * Program the minimum sleep time to 10 seconds, as many
1056 * platforms have issues processing a wakeup signal while
1057 * still being in the process of suspending.
1058 */
1059 .min_sleep_time = cpu_to_le32(10 * 1000 * 1000),
1060 };
1061 struct iwl_host_cmd d3_cfg_cmd = {
1062 .id = D3_CONFIG_CMD,
1063 .flags = CMD_WANT_SKB,
1064 .data[0] = &d3_cfg_cmd_data,
1065 .len[0] = sizeof(d3_cfg_cmd_data),
1066 };
1067 int ret;
1068 int len __maybe_unused;
1069
1070 if (!wowlan) {
1071 /*
1072 * mac80211 shouldn't get here, but for D3 test
1073 * it doesn't warrant a warning
1074 */
1075 WARN_ON(!test);
1076 return -EINVAL;
1077 }
1078
1079 mutex_lock(&mvm->mutex);
1080
7f549e2c
LC
1081 vif = iwl_mvm_get_bss_vif(mvm);
1082 if (IS_ERR_OR_NULL(vif)) {
671b5820
LC
1083 ret = 1;
1084 goto out_noreset;
1085 }
1086
671b5820
LC
1087 mvmvif = iwl_mvm_vif_from_mac80211(vif);
1088
3acc952b
LC
1089 if (mvmvif->ap_sta_id == IWL_MVM_STATION_COUNT) {
1090 /* if we're not associated, this must be netdetect */
566f165d 1091 if (!wowlan->nd_config) {
3acc952b
LC
1092 ret = 1;
1093 goto out_noreset;
1094 }
1095
1096 ret = iwl_mvm_netdetect_config(
566f165d 1097 mvm, wowlan, wowlan->nd_config, vif);
3acc952b
LC
1098 if (ret)
1099 goto out;
2021a89d
LC
1100
1101 mvm->net_detect = true;
3acc952b 1102 } else {
c8b06a99 1103 struct iwl_wowlan_config_cmd wowlan_config_cmd = {};
3acc952b 1104
1e4d19ca
LC
1105 ap_sta = rcu_dereference_protected(
1106 mvm->fw_id_to_mac_id[mvmvif->ap_sta_id],
1107 lockdep_is_held(&mvm->mutex));
1108 if (IS_ERR_OR_NULL(ap_sta)) {
1109 ret = -EINVAL;
1110 goto out_noreset;
1111 }
671b5820 1112
1e4d19ca
LC
1113 ret = iwl_mvm_get_wowlan_config(mvm, wowlan, &wowlan_config_cmd,
1114 vif, mvmvif, ap_sta);
1115 if (ret)
1116 goto out_noreset;
1e4d19ca
LC
1117 ret = iwl_mvm_wowlan_config(mvm, wowlan, &wowlan_config_cmd,
1118 vif, mvmvif, ap_sta);
1119 if (ret)
3c2f3b20 1120 goto out;
2021a89d
LC
1121
1122 mvm->net_detect = false;
1e4d19ca 1123 }
f0c2646a 1124
c1cb92fc 1125 ret = iwl_mvm_power_update_device(mvm);
64b928c4
AB
1126 if (ret)
1127 goto out;
1128
999609f1 1129 ret = iwl_mvm_power_update_mac(mvm);
ee1e8422
AB
1130 if (ret)
1131 goto out;
1132
b0114714
JB
1133#ifdef CONFIG_IWLWIFI_DEBUGFS
1134 if (mvm->d3_wake_sysassert)
1135 d3_cfg_cmd_data.wakeup_flags |=
1136 cpu_to_le32(IWL_WAKEUP_D3_CONFIG_FW_ERROR);
1137#endif
1138
8ca151b5 1139 /* must be last -- this switches firmware state */
debff618 1140 ret = iwl_mvm_send_cmd(mvm, &d3_cfg_cmd);
8ca151b5
JB
1141 if (ret)
1142 goto out;
debff618 1143#ifdef CONFIG_IWLWIFI_DEBUGFS
65b30348
JB
1144 len = iwl_rx_packet_payload_len(d3_cfg_cmd.resp_pkt);
1145 if (len >= sizeof(u32)) {
debff618
JB
1146 mvm->d3_test_pme_ptr =
1147 le32_to_cpup((__le32 *)d3_cfg_cmd.resp_pkt->data);
debff618
JB
1148 }
1149#endif
1150 iwl_free_resp(&d3_cfg_cmd);
8ca151b5
JB
1151
1152 clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status);
1153
debff618 1154 iwl_trans_d3_suspend(mvm->trans, test);
8ca151b5 1155 out:
d9718da8 1156 if (ret < 0) {
48e67751 1157 iwl_mvm_ref(mvm, IWL_MVM_REF_UCODE_DOWN);
8ca151b5 1158 ieee80211_restart_hw(mvm->hw);
d9718da8
LC
1159 iwl_mvm_free_nd(mvm);
1160 }
b70ab727 1161 out_noreset:
8ca151b5
JB
1162 mutex_unlock(&mvm->mutex);
1163
1164 return ret;
1165}
1166
6735943f
EP
1167static int iwl_mvm_enter_d0i3_sync(struct iwl_mvm *mvm)
1168{
1169 struct iwl_notification_wait wait_d3;
6eb031d2 1170 static const u16 d3_notif[] = { D3_CONFIG_CMD };
6735943f
EP
1171 int ret;
1172
1173 iwl_init_notification_wait(&mvm->notif_wait, &wait_d3,
1174 d3_notif, ARRAY_SIZE(d3_notif),
1175 NULL, NULL);
1176
1177 ret = iwl_mvm_enter_d0i3(mvm->hw->priv);
1178 if (ret)
1179 goto remove_notif;
1180
1181 ret = iwl_wait_notification(&mvm->notif_wait, &wait_d3, HZ);
1182 WARN_ON_ONCE(ret);
1183 return ret;
1184
1185remove_notif:
1186 iwl_remove_notification(&mvm->notif_wait, &wait_d3);
1187 return ret;
1188}
1189
debff618
JB
1190int iwl_mvm_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
1191{
d15a747f 1192 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
b7282643 1193 struct iwl_trans *trans = mvm->trans;
c43fe907
EP
1194 int ret;
1195
cf8c3cff
LC
1196 /* make sure the d0i3 exit work is not pending */
1197 flush_work(&mvm->d0i3_exit_work);
1198
b7282643 1199 ret = iwl_trans_suspend(trans);
c43fe907
EP
1200 if (ret)
1201 return ret;
d15a747f 1202
b7282643
LC
1203 if (wowlan->any) {
1204 trans->system_pm_mode = IWL_PLAT_PM_MODE_D0I3;
1205
1206 if (iwl_mvm_enter_d0i3_on_suspend(mvm)) {
c43fe907 1207 ret = iwl_mvm_enter_d0i3_sync(mvm);
6735943f
EP
1208
1209 if (ret)
1210 return ret;
1211 }
1212
d15a747f
EP
1213 mutex_lock(&mvm->d0i3_suspend_mutex);
1214 __set_bit(D0I3_DEFER_WAKEUP, &mvm->d0i3_suspend_flags);
1215 mutex_unlock(&mvm->d0i3_suspend_mutex);
6dfb36c8 1216
b7282643 1217 iwl_trans_d3_suspend(trans, false);
6dfb36c8 1218
d15a747f
EP
1219 return 0;
1220 }
1221
b7282643
LC
1222 trans->system_pm_mode = IWL_PLAT_PM_MODE_D3;
1223
debff618
JB
1224 return __iwl_mvm_suspend(hw, wowlan, false);
1225}
1226
6d9d32b8
JB
1227/* converted data from the different status responses */
1228struct iwl_wowlan_status_data {
1229 u16 pattern_number;
1230 u16 qos_seq_ctr[8];
1231 u32 wakeup_reasons;
1232 u32 wake_packet_length;
1233 u32 wake_packet_bufsize;
1234 const u8 *wake_packet;
1235};
1236
7abc4632
JB
1237static void iwl_mvm_report_wakeup_reasons(struct iwl_mvm *mvm,
1238 struct ieee80211_vif *vif,
6d9d32b8 1239 struct iwl_wowlan_status_data *status)
9b26b500 1240{
7abc4632 1241 struct sk_buff *pkt = NULL;
9b26b500
JB
1242 struct cfg80211_wowlan_wakeup wakeup = {
1243 .pattern_idx = -1,
1244 };
1245 struct cfg80211_wowlan_wakeup *wakeup_report = &wakeup;
6d9d32b8 1246 u32 reasons = status->wakeup_reasons;
9b26b500
JB
1247
1248 if (reasons == IWL_WOWLAN_WAKEUP_BY_NON_WIRELESS) {
1249 wakeup_report = NULL;
1250 goto report;
1251 }
1252
06ae2ad4
DB
1253 pm_wakeup_event(mvm->dev, 0);
1254
f444eb10 1255 if (reasons & IWL_WOWLAN_WAKEUP_BY_MAGIC_PACKET)
9b26b500 1256 wakeup.magic_pkt = true;
9b26b500 1257
f444eb10 1258 if (reasons & IWL_WOWLAN_WAKEUP_BY_PATTERN)
9b26b500 1259 wakeup.pattern_idx =
6d9d32b8 1260 status->pattern_number;
9b26b500
JB
1261
1262 if (reasons & (IWL_WOWLAN_WAKEUP_BY_DISCONNECTION_ON_MISSED_BEACON |
1263 IWL_WOWLAN_WAKEUP_BY_DISCONNECTION_ON_DEAUTH))
1264 wakeup.disconnect = true;
1265
f444eb10 1266 if (reasons & IWL_WOWLAN_WAKEUP_BY_GTK_REKEY_FAILURE)
9b26b500 1267 wakeup.gtk_rekey_failure = true;
9b26b500 1268
f444eb10 1269 if (reasons & IWL_WOWLAN_WAKEUP_BY_RFKILL_DEASSERTED)
9b26b500 1270 wakeup.rfkill_release = true;
9b26b500 1271
f444eb10 1272 if (reasons & IWL_WOWLAN_WAKEUP_BY_EAPOL_REQUEST)
9b26b500 1273 wakeup.eap_identity_req = true;
9b26b500 1274
f444eb10 1275 if (reasons & IWL_WOWLAN_WAKEUP_BY_FOUR_WAY_HANDSHAKE)
9b26b500 1276 wakeup.four_way_handshake = true;
9b26b500 1277
f0c2646a
JB
1278 if (reasons & IWL_WOWLAN_WAKEUP_BY_REM_WAKE_LINK_LOSS)
1279 wakeup.tcp_connlost = true;
1280
1281 if (reasons & IWL_WOWLAN_WAKEUP_BY_REM_WAKE_SIGNATURE_TABLE)
1282 wakeup.tcp_nomoretokens = true;
1283
1284 if (reasons & IWL_WOWLAN_WAKEUP_BY_REM_WAKE_WAKEUP_PACKET)
1285 wakeup.tcp_match = true;
1286
9b26b500 1287 if (status->wake_packet_bufsize) {
6d9d32b8
JB
1288 int pktsize = status->wake_packet_bufsize;
1289 int pktlen = status->wake_packet_length;
f444eb10
JB
1290 const u8 *pktdata = status->wake_packet;
1291 struct ieee80211_hdr *hdr = (void *)pktdata;
1292 int truncated = pktlen - pktsize;
1293
1294 /* this would be a firmware bug */
1295 if (WARN_ON_ONCE(truncated < 0))
1296 truncated = 0;
1297
1298 if (ieee80211_is_data(hdr->frame_control)) {
1299 int hdrlen = ieee80211_hdrlen(hdr->frame_control);
1300 int ivlen = 0, icvlen = 4; /* also FCS */
9b26b500 1301
9b26b500
JB
1302 pkt = alloc_skb(pktsize, GFP_KERNEL);
1303 if (!pkt)
1304 goto report;
f444eb10
JB
1305
1306 memcpy(skb_put(pkt, hdrlen), pktdata, hdrlen);
1307 pktdata += hdrlen;
1308 pktsize -= hdrlen;
1309
1310 if (ieee80211_has_protected(hdr->frame_control)) {
7abc4632
JB
1311 /*
1312 * This is unlocked and using gtk_i(c)vlen,
1313 * but since everything is under RTNL still
1314 * that's not really a problem - changing
1315 * it would be difficult.
1316 */
f444eb10
JB
1317 if (is_multicast_ether_addr(hdr->addr1)) {
1318 ivlen = mvm->gtk_ivlen;
1319 icvlen += mvm->gtk_icvlen;
1320 } else {
1321 ivlen = mvm->ptk_ivlen;
1322 icvlen += mvm->ptk_icvlen;
1323 }
1324 }
1325
1326 /* if truncated, FCS/ICV is (partially) gone */
1327 if (truncated >= icvlen) {
1328 icvlen = 0;
1329 truncated -= icvlen;
1330 } else {
1331 icvlen -= truncated;
1332 truncated = 0;
1333 }
1334
1335 pktsize -= ivlen + icvlen;
1336 pktdata += ivlen;
1337
1338 memcpy(skb_put(pkt, pktsize), pktdata, pktsize);
1339
9b26b500
JB
1340 if (ieee80211_data_to_8023(pkt, vif->addr, vif->type))
1341 goto report;
1342 wakeup.packet = pkt->data;
1343 wakeup.packet_present_len = pkt->len;
f444eb10 1344 wakeup.packet_len = pkt->len - truncated;
9b26b500
JB
1345 wakeup.packet_80211 = false;
1346 } else {
f444eb10
JB
1347 int fcslen = 4;
1348
1349 if (truncated >= 4) {
1350 truncated -= 4;
1351 fcslen = 0;
1352 } else {
1353 fcslen -= truncated;
1354 truncated = 0;
1355 }
1356 pktsize -= fcslen;
9b26b500
JB
1357 wakeup.packet = status->wake_packet;
1358 wakeup.packet_present_len = pktsize;
f444eb10 1359 wakeup.packet_len = pktlen - truncated;
9b26b500
JB
1360 wakeup.packet_80211 = true;
1361 }
1362 }
1363
1364 report:
1365 ieee80211_report_wowlan_wakeup(vif, wakeup_report, GFP_KERNEL);
1366 kfree_skb(pkt);
7abc4632 1367}
9b26b500 1368
6d9d32b8
JB
1369static void iwl_mvm_aes_sc_to_seq(struct aes_sc *sc,
1370 struct ieee80211_key_seq *seq)
1371{
1372 u64 pn;
1373
1374 pn = le64_to_cpu(sc->pn);
1375 seq->ccmp.pn[0] = pn >> 40;
1376 seq->ccmp.pn[1] = pn >> 32;
1377 seq->ccmp.pn[2] = pn >> 24;
1378 seq->ccmp.pn[3] = pn >> 16;
1379 seq->ccmp.pn[4] = pn >> 8;
1380 seq->ccmp.pn[5] = pn;
1381}
1382
1383static void iwl_mvm_tkip_sc_to_seq(struct tkip_sc *sc,
1384 struct ieee80211_key_seq *seq)
1385{
1386 seq->tkip.iv32 = le32_to_cpu(sc->iv32);
1387 seq->tkip.iv16 = le16_to_cpu(sc->iv16);
1388}
1389
1390static void iwl_mvm_set_aes_rx_seq(struct aes_sc *scs,
1391 struct ieee80211_key_conf *key)
1392{
1393 int tid;
1394
1395 BUILD_BUG_ON(IWL_NUM_RSC != IEEE80211_NUM_TIDS);
1396
1397 for (tid = 0; tid < IWL_NUM_RSC; tid++) {
1398 struct ieee80211_key_seq seq = {};
1399
1400 iwl_mvm_aes_sc_to_seq(&scs[tid], &seq);
1401 ieee80211_set_key_rx_seq(key, tid, &seq);
1402 }
1403}
1404
1405static void iwl_mvm_set_tkip_rx_seq(struct tkip_sc *scs,
1406 struct ieee80211_key_conf *key)
1407{
1408 int tid;
1409
1410 BUILD_BUG_ON(IWL_NUM_RSC != IEEE80211_NUM_TIDS);
1411
1412 for (tid = 0; tid < IWL_NUM_RSC; tid++) {
1413 struct ieee80211_key_seq seq = {};
1414
1415 iwl_mvm_tkip_sc_to_seq(&scs[tid], &seq);
1416 ieee80211_set_key_rx_seq(key, tid, &seq);
1417 }
1418}
1419
1420static void iwl_mvm_set_key_rx_seq(struct ieee80211_key_conf *key,
3afec639 1421 struct iwl_wowlan_status *status)
6d9d32b8
JB
1422{
1423 union iwl_all_tsc_rsc *rsc = &status->gtk.rsc.all_tsc_rsc;
1424
1425 switch (key->cipher) {
1426 case WLAN_CIPHER_SUITE_CCMP:
1427 iwl_mvm_set_aes_rx_seq(rsc->aes.multicast_rsc, key);
1428 break;
1429 case WLAN_CIPHER_SUITE_TKIP:
1430 iwl_mvm_set_tkip_rx_seq(rsc->tkip.multicast_rsc, key);
1431 break;
1432 default:
1433 WARN_ON(1);
1434 }
1435}
1436
1437struct iwl_mvm_d3_gtk_iter_data {
3afec639 1438 struct iwl_wowlan_status *status;
6d9d32b8
JB
1439 void *last_gtk;
1440 u32 cipher;
1441 bool find_phase, unhandled_cipher;
1442 int num_keys;
1443};
1444
59fd4bf6 1445static void iwl_mvm_d3_update_keys(struct ieee80211_hw *hw,
6d9d32b8
JB
1446 struct ieee80211_vif *vif,
1447 struct ieee80211_sta *sta,
1448 struct ieee80211_key_conf *key,
1449 void *_data)
1450{
1451 struct iwl_mvm_d3_gtk_iter_data *data = _data;
1452
1453 if (data->unhandled_cipher)
1454 return;
1455
1456 switch (key->cipher) {
1457 case WLAN_CIPHER_SUITE_WEP40:
1458 case WLAN_CIPHER_SUITE_WEP104:
1459 /* ignore WEP completely, nothing to do */
1460 return;
1461 case WLAN_CIPHER_SUITE_CCMP:
1462 case WLAN_CIPHER_SUITE_TKIP:
1463 /* we support these */
1464 break;
1465 default:
1466 /* everything else (even CMAC for MFP) - disconnect from AP */
1467 data->unhandled_cipher = true;
1468 return;
1469 }
1470
1471 data->num_keys++;
1472
1473 /*
1474 * pairwise key - update sequence counters only;
1475 * note that this assumes no TDLS sessions are active
1476 */
1477 if (sta) {
1478 struct ieee80211_key_seq seq = {};
1479 union iwl_all_tsc_rsc *sc = &data->status->gtk.rsc.all_tsc_rsc;
1480
1481 if (data->find_phase)
1482 return;
1483
1484 switch (key->cipher) {
1485 case WLAN_CIPHER_SUITE_CCMP:
6d9d32b8 1486 iwl_mvm_set_aes_rx_seq(sc->aes.unicast_rsc, key);
6645d5e4 1487 atomic64_set(&key->tx_pn, le64_to_cpu(sc->aes.tsc.pn));
6d9d32b8
JB
1488 break;
1489 case WLAN_CIPHER_SUITE_TKIP:
1490 iwl_mvm_tkip_sc_to_seq(&sc->tkip.tsc, &seq);
1491 iwl_mvm_set_tkip_rx_seq(sc->tkip.unicast_rsc, key);
6645d5e4 1492 ieee80211_set_key_tx_seq(key, &seq);
6d9d32b8
JB
1493 break;
1494 }
6d9d32b8
JB
1495
1496 /* that's it for this key */
1497 return;
1498 }
1499
1500 if (data->find_phase) {
1501 data->last_gtk = key;
1502 data->cipher = key->cipher;
1503 return;
1504 }
1505
1506 if (data->status->num_of_gtk_rekeys)
1507 ieee80211_remove_key(key);
1508 else if (data->last_gtk == key)
1509 iwl_mvm_set_key_rx_seq(key, data->status);
1510}
1511
1512static bool iwl_mvm_setup_connection_keep(struct iwl_mvm *mvm,
1513 struct ieee80211_vif *vif,
3afec639 1514 struct iwl_wowlan_status *status)
6d9d32b8
JB
1515{
1516 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1517 struct iwl_mvm_d3_gtk_iter_data gtkdata = {
1518 .status = status,
1519 };
431591cc
EP
1520 u32 disconnection_reasons =
1521 IWL_WOWLAN_WAKEUP_BY_DISCONNECTION_ON_MISSED_BEACON |
1522 IWL_WOWLAN_WAKEUP_BY_DISCONNECTION_ON_DEAUTH;
6d9d32b8
JB
1523
1524 if (!status || !vif->bss_conf.bssid)
1525 return false;
1526
431591cc
EP
1527 if (le32_to_cpu(status->wakeup_reasons) & disconnection_reasons)
1528 return false;
1529
6d9d32b8
JB
1530 /* find last GTK that we used initially, if any */
1531 gtkdata.find_phase = true;
1532 ieee80211_iter_keys(mvm->hw, vif,
59fd4bf6 1533 iwl_mvm_d3_update_keys, &gtkdata);
6d9d32b8
JB
1534 /* not trying to keep connections with MFP/unhandled ciphers */
1535 if (gtkdata.unhandled_cipher)
1536 return false;
1537 if (!gtkdata.num_keys)
cfa88893 1538 goto out;
6d9d32b8
JB
1539 if (!gtkdata.last_gtk)
1540 return false;
1541
1542 /*
1543 * invalidate all other GTKs that might still exist and update
1544 * the one that we used
1545 */
1546 gtkdata.find_phase = false;
1547 ieee80211_iter_keys(mvm->hw, vif,
59fd4bf6 1548 iwl_mvm_d3_update_keys, &gtkdata);
6d9d32b8
JB
1549
1550 if (status->num_of_gtk_rekeys) {
1551 struct ieee80211_key_conf *key;
1552 struct {
1553 struct ieee80211_key_conf conf;
1554 u8 key[32];
1555 } conf = {
1556 .conf.cipher = gtkdata.cipher,
1557 .conf.keyidx = status->gtk.key_index,
1558 };
1559
1560 switch (gtkdata.cipher) {
1561 case WLAN_CIPHER_SUITE_CCMP:
1562 conf.conf.keylen = WLAN_KEY_LEN_CCMP;
1563 memcpy(conf.conf.key, status->gtk.decrypt_key,
1564 WLAN_KEY_LEN_CCMP);
1565 break;
1566 case WLAN_CIPHER_SUITE_TKIP:
1567 conf.conf.keylen = WLAN_KEY_LEN_TKIP;
1568 memcpy(conf.conf.key, status->gtk.decrypt_key, 16);
1569 /* leave TX MIC key zeroed, we don't use it anyway */
1570 memcpy(conf.conf.key +
1571 NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY,
1572 status->gtk.tkip_mic_key, 8);
1573 break;
1574 }
1575
1576 key = ieee80211_gtk_rekey_add(vif, &conf.conf);
1577 if (IS_ERR(key))
1578 return false;
1579 iwl_mvm_set_key_rx_seq(key, status);
1580 }
1581
1582 if (status->num_of_gtk_rekeys) {
1583 __be64 replay_ctr =
1584 cpu_to_be64(le64_to_cpu(status->replay_ctr));
1585 ieee80211_gtk_rekey_notify(vif, vif->bss_conf.bssid,
1586 (void *)&replay_ctr, GFP_KERNEL);
1587 }
1588
cfa88893 1589out:
6d9d32b8
JB
1590 mvmvif->seqno_valid = true;
1591 /* +0x10 because the set API expects next-to-use, not last-used */
1592 mvmvif->seqno = le16_to_cpu(status->non_qos_seq_ctr) + 0x10;
1593
1594 return true;
1595}
1596
ec12f457
LC
1597static struct iwl_wowlan_status *
1598iwl_mvm_get_wakeup_status(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
7abc4632
JB
1599{
1600 u32 base = mvm->error_event_table;
1601 struct error_table_start {
1602 /* cf. struct iwl_error_event_table */
1603 u32 valid;
1604 u32 error_id;
1605 } err_info;
1606 struct iwl_host_cmd cmd = {
1607 .id = WOWLAN_GET_STATUSES,
a1022927 1608 .flags = CMD_WANT_SKB,
7abc4632 1609 };
ec12f457
LC
1610 struct iwl_wowlan_status *status, *fw_status;
1611 int ret, len, status_size;
7abc4632
JB
1612
1613 iwl_trans_read_mem_bytes(mvm->trans, base,
1614 &err_info, sizeof(err_info));
1615
1616 if (err_info.valid) {
ec12f457
LC
1617 IWL_INFO(mvm, "error table is valid (%d) with error (%d)\n",
1618 err_info.valid, err_info.error_id);
7abc4632
JB
1619 if (err_info.error_id == RF_KILL_INDICATOR_FOR_WOWLAN) {
1620 struct cfg80211_wowlan_wakeup wakeup = {
1621 .rfkill_release = true,
1622 };
1623 ieee80211_report_wowlan_wakeup(vif, &wakeup,
1624 GFP_KERNEL);
1625 }
ec12f457 1626 return ERR_PTR(-EIO);
7abc4632
JB
1627 }
1628
1629 /* only for tracing for now */
a1022927 1630 ret = iwl_mvm_send_cmd_pdu(mvm, OFFLOADS_QUERY_CMD, 0, 0, NULL);
7abc4632
JB
1631 if (ret)
1632 IWL_ERR(mvm, "failed to query offload statistics (%d)\n", ret);
1633
1634 ret = iwl_mvm_send_cmd(mvm, &cmd);
1635 if (ret) {
1636 IWL_ERR(mvm, "failed to query status (%d)\n", ret);
ec12f457 1637 return ERR_PTR(ret);
7abc4632
JB
1638 }
1639
1640 /* RF-kill already asserted again... */
ec12f457 1641 if (!cmd.resp_pkt) {
e111e968 1642 fw_status = ERR_PTR(-ERFKILL);
ec12f457
LC
1643 goto out_free_resp;
1644 }
7abc4632 1645
3afec639 1646 status_size = sizeof(*fw_status);
6d9d32b8 1647
65b30348
JB
1648 len = iwl_rx_packet_payload_len(cmd.resp_pkt);
1649 if (len < status_size) {
7abc4632 1650 IWL_ERR(mvm, "Invalid WoWLAN status response!\n");
e111e968 1651 fw_status = ERR_PTR(-EIO);
ec12f457
LC
1652 goto out_free_resp;
1653 }
1654
1655 status = (void *)cmd.resp_pkt->data;
1656 if (len != (status_size +
1657 ALIGN(le32_to_cpu(status->wake_packet_bufsize), 4))) {
1658 IWL_ERR(mvm, "Invalid WoWLAN status response!\n");
e111e968 1659 fw_status = ERR_PTR(-EIO);
7abc4632
JB
1660 goto out_free_resp;
1661 }
1662
ec12f457
LC
1663 fw_status = kmemdup(status, len, GFP_KERNEL);
1664
1665out_free_resp:
1666 iwl_free_resp(&cmd);
e111e968 1667 return fw_status;
ec12f457
LC
1668}
1669
1670/* releases the MVM mutex */
1671static bool iwl_mvm_query_wakeup_reasons(struct iwl_mvm *mvm,
1672 struct ieee80211_vif *vif)
1673{
1674 struct iwl_wowlan_status_data status;
1675 struct iwl_wowlan_status *fw_status;
1676 int i;
1677 bool keep;
1678 struct ieee80211_sta *ap_sta;
1679 struct iwl_mvm_sta *mvm_ap_sta;
1680
1681 fw_status = iwl_mvm_get_wakeup_status(mvm, vif);
1682 if (IS_ERR_OR_NULL(fw_status))
1683 goto out_unlock;
3afec639
EG
1684
1685 status.pattern_number = le16_to_cpu(fw_status->pattern_number);
1686 for (i = 0; i < 8; i++)
1687 status.qos_seq_ctr[i] =
1688 le16_to_cpu(fw_status->qos_seq_ctr[i]);
1689 status.wakeup_reasons = le32_to_cpu(fw_status->wakeup_reasons);
1690 status.wake_packet_length =
1691 le32_to_cpu(fw_status->wake_packet_length);
1692 status.wake_packet_bufsize =
1693 le32_to_cpu(fw_status->wake_packet_bufsize);
1694 status.wake_packet = fw_status->wake_packet;
7abc4632 1695
6d9d32b8
JB
1696 /* still at hard-coded place 0 for D3 image */
1697 ap_sta = rcu_dereference_protected(
1698 mvm->fw_id_to_mac_id[0],
1699 lockdep_is_held(&mvm->mutex));
1700 if (IS_ERR_OR_NULL(ap_sta))
ec12f457 1701 goto out_free;
6d9d32b8 1702
9d8ce6af 1703 mvm_ap_sta = iwl_mvm_sta_from_mac80211(ap_sta);
6d9d32b8
JB
1704 for (i = 0; i < IWL_MAX_TID_COUNT; i++) {
1705 u16 seq = status.qos_seq_ctr[i];
1706 /* firmware stores last-used value, we store next value */
1707 seq += 0x10;
1708 mvm_ap_sta->tid_data[i].seq_number = seq;
1709 }
1710
7abc4632
JB
1711 /* now we have all the data we need, unlock to avoid mac80211 issues */
1712 mutex_unlock(&mvm->mutex);
1713
6d9d32b8
JB
1714 iwl_mvm_report_wakeup_reasons(mvm, vif, &status);
1715
3afec639 1716 keep = iwl_mvm_setup_connection_keep(mvm, vif, fw_status);
6d9d32b8 1717
ec12f457 1718 kfree(fw_status);
6d9d32b8 1719 return keep;
7abc4632 1720
ec12f457
LC
1721out_free:
1722 kfree(fw_status);
1723out_unlock:
7abc4632 1724 mutex_unlock(&mvm->mutex);
6d9d32b8 1725 return false;
9b26b500
JB
1726}
1727
8ed4e659
LC
1728struct iwl_mvm_nd_query_results {
1729 u32 matched_profiles;
1730 struct iwl_scan_offload_profile_match matches[IWL_SCAN_MAX_PROFILES];
1731};
1732
1733static int
1734iwl_mvm_netdetect_query_results(struct iwl_mvm *mvm,
1735 struct iwl_mvm_nd_query_results *results)
b04998f3
LC
1736{
1737 struct iwl_scan_offload_profiles_query *query;
1738 struct iwl_host_cmd cmd = {
1739 .id = SCAN_OFFLOAD_PROFILES_QUERY_CMD,
1740 .flags = CMD_WANT_SKB,
1741 };
1742 int ret, len;
1743
1744 ret = iwl_mvm_send_cmd(mvm, &cmd);
1745 if (ret) {
1746 IWL_ERR(mvm, "failed to query matched profiles (%d)\n", ret);
8ed4e659 1747 return ret;
b04998f3
LC
1748 }
1749
1750 /* RF-kill already asserted again... */
8ed4e659
LC
1751 if (!cmd.resp_pkt) {
1752 ret = -ERFKILL;
b04998f3 1753 goto out_free_resp;
8ed4e659 1754 }
b04998f3
LC
1755
1756 len = iwl_rx_packet_payload_len(cmd.resp_pkt);
1757 if (len < sizeof(*query)) {
1758 IWL_ERR(mvm, "Invalid scan offload profiles query response!\n");
8ed4e659 1759 ret = -EIO;
b04998f3
LC
1760 goto out_free_resp;
1761 }
1762
1763 query = (void *)cmd.resp_pkt->data;
1764
8ed4e659
LC
1765 results->matched_profiles = le32_to_cpu(query->matched_profiles);
1766 memcpy(results->matches, query->matches, sizeof(results->matches));
b04998f3 1767
6bbd5521 1768#ifdef CONFIG_IWLWIFI_DEBUGFS
484b3d13
LC
1769 mvm->last_netdetect_scans = le32_to_cpu(query->n_scans_done);
1770#endif
1771
b04998f3
LC
1772out_free_resp:
1773 iwl_free_resp(&cmd);
1774 return ret;
1775}
1776
2021a89d
LC
1777static void iwl_mvm_query_netdetect_reasons(struct iwl_mvm *mvm,
1778 struct ieee80211_vif *vif)
1779{
d9718da8 1780 struct cfg80211_wowlan_nd_info *net_detect = NULL;
2021a89d
LC
1781 struct cfg80211_wowlan_wakeup wakeup = {
1782 .pattern_idx = -1,
1783 };
1784 struct cfg80211_wowlan_wakeup *wakeup_report = &wakeup;
8ed4e659 1785 struct iwl_mvm_nd_query_results query;
2021a89d 1786 struct iwl_wowlan_status *fw_status;
d9718da8 1787 unsigned long matched_profiles;
2021a89d 1788 u32 reasons = 0;
8ed4e659 1789 int i, j, n_matches, ret;
2021a89d
LC
1790
1791 fw_status = iwl_mvm_get_wakeup_status(mvm, vif);
2fc863a5 1792 if (!IS_ERR_OR_NULL(fw_status)) {
2021a89d 1793 reasons = le32_to_cpu(fw_status->wakeup_reasons);
2fc863a5
HD
1794 kfree(fw_status);
1795 }
2021a89d
LC
1796
1797 if (reasons & IWL_WOWLAN_WAKEUP_BY_RFKILL_DEASSERTED)
1798 wakeup.rfkill_release = true;
1799
b04998f3
LC
1800 if (reasons != IWL_WOWLAN_WAKEUP_BY_NON_WIRELESS)
1801 goto out;
1802
8ed4e659
LC
1803 ret = iwl_mvm_netdetect_query_results(mvm, &query);
1804 if (ret || !query.matched_profiles) {
2021a89d 1805 wakeup_report = NULL;
b04998f3 1806 goto out;
2021a89d
LC
1807 }
1808
8ed4e659 1809 matched_profiles = query.matched_profiles;
d9718da8
LC
1810 if (mvm->n_nd_match_sets) {
1811 n_matches = hweight_long(matched_profiles);
1812 } else {
1813 IWL_ERR(mvm, "no net detect match information available\n");
1814 n_matches = 0;
1815 }
1816
1817 net_detect = kzalloc(sizeof(*net_detect) +
1818 (n_matches * sizeof(net_detect->matches[0])),
1819 GFP_KERNEL);
1820 if (!net_detect || !n_matches)
1821 goto out_report_nd;
1822
1823 for_each_set_bit(i, &matched_profiles, mvm->n_nd_match_sets) {
8ed4e659 1824 struct iwl_scan_offload_profile_match *fw_match;
d9718da8 1825 struct cfg80211_wowlan_nd_match *match;
ae90c2e5 1826 int idx, n_channels = 0;
8ed4e659
LC
1827
1828 fw_match = &query.matches[i];
1829
1830 for (j = 0; j < SCAN_OFFLOAD_MATCHING_CHANNELS_LEN; j++)
1831 n_channels += hweight8(fw_match->matching_channels[j]);
d9718da8 1832
8ed4e659
LC
1833 match = kzalloc(sizeof(*match) +
1834 (n_channels * sizeof(*match->channels)),
1835 GFP_KERNEL);
d9718da8
LC
1836 if (!match)
1837 goto out_report_nd;
1838
8ed4e659
LC
1839 net_detect->matches[net_detect->n_matches++] = match;
1840
ae90c2e5
LC
1841 /* We inverted the order of the SSIDs in the scan
1842 * request, so invert the index here.
1843 */
1844 idx = mvm->n_nd_match_sets - i - 1;
1845 match->ssid.ssid_len = mvm->nd_match_sets[idx].ssid.ssid_len;
1846 memcpy(match->ssid.ssid, mvm->nd_match_sets[idx].ssid.ssid,
d9718da8
LC
1847 match->ssid.ssid_len);
1848
8ed4e659
LC
1849 if (mvm->n_nd_channels < n_channels)
1850 continue;
1851
1852 for (j = 0; j < SCAN_OFFLOAD_MATCHING_CHANNELS_LEN * 8; j++)
1853 if (fw_match->matching_channels[j / 8] & (BIT(j % 8)))
1854 match->channels[match->n_channels++] =
1855 mvm->nd_channels[j]->center_freq;
d9718da8
LC
1856 }
1857
1858out_report_nd:
1859 wakeup.net_detect = net_detect;
b04998f3 1860out:
d9718da8
LC
1861 iwl_mvm_free_nd(mvm);
1862
2021a89d
LC
1863 mutex_unlock(&mvm->mutex);
1864 ieee80211_report_wowlan_wakeup(vif, wakeup_report, GFP_KERNEL);
d9718da8
LC
1865
1866 if (net_detect) {
1867 for (i = 0; i < net_detect->n_matches; i++)
1868 kfree(net_detect->matches[i]);
1869 kfree(net_detect);
1870 }
2021a89d
LC
1871}
1872
afc66bb7
JB
1873static void iwl_mvm_read_d3_sram(struct iwl_mvm *mvm)
1874{
1875#ifdef CONFIG_IWLWIFI_DEBUGFS
1876 const struct fw_img *img = &mvm->fw->img[IWL_UCODE_WOWLAN];
1877 u32 len = img->sec[IWL_UCODE_SECTION_DATA].len;
1878 u32 offs = img->sec[IWL_UCODE_SECTION_DATA].offset;
1879
1880 if (!mvm->store_d3_resume_sram)
1881 return;
1882
1883 if (!mvm->d3_resume_sram) {
1884 mvm->d3_resume_sram = kzalloc(len, GFP_KERNEL);
1885 if (!mvm->d3_resume_sram)
1886 return;
1887 }
1888
1889 iwl_trans_read_mem_bytes(mvm->trans, offs, mvm->d3_resume_sram, len);
1890#endif
1891}
1892
6d9d32b8
JB
1893static void iwl_mvm_d3_disconnect_iter(void *data, u8 *mac,
1894 struct ieee80211_vif *vif)
1895{
1896 /* skip the one we keep connection on */
1897 if (data == vif)
1898 return;
1899
1900 if (vif->type == NL80211_IFTYPE_STATION)
1901 ieee80211_resume_disconnect(vif);
1902}
1903
debff618 1904static int __iwl_mvm_resume(struct iwl_mvm *mvm, bool test)
8ca151b5 1905{
8ca151b5 1906 struct ieee80211_vif *vif = NULL;
8ca151b5
JB
1907 int ret;
1908 enum iwl_d3_status d3_status;
6d9d32b8 1909 bool keep = false;
8ca151b5
JB
1910
1911 mutex_lock(&mvm->mutex);
1912
1913 /* get the BSS vif pointer again */
7f549e2c
LC
1914 vif = iwl_mvm_get_bss_vif(mvm);
1915 if (IS_ERR_OR_NULL(vif))
a500e469 1916 goto err;
8ca151b5 1917
debff618 1918 ret = iwl_trans_d3_resume(mvm->trans, &d3_status, test);
8ca151b5 1919 if (ret)
a500e469 1920 goto err;
8ca151b5
JB
1921
1922 if (d3_status != IWL_D3_STATUS_ALIVE) {
1923 IWL_INFO(mvm, "Device was reset during suspend\n");
a500e469 1924 goto err;
8ca151b5
JB
1925 }
1926
afc66bb7
JB
1927 /* query SRAM first in case we want event logging */
1928 iwl_mvm_read_d3_sram(mvm);
1929
47c8b154
JD
1930 /*
1931 * Query the current location and source from the D3 firmware so we
1932 * can play it back when we re-intiailize the D0 firmware
1933 */
1934 iwl_mvm_update_changed_regdom(mvm);
1935
2021a89d
LC
1936 if (mvm->net_detect) {
1937 iwl_mvm_query_netdetect_reasons(mvm, vif);
e0ede177
LC
1938 /* has unlocked the mutex, so skip that */
1939 goto out;
2021a89d
LC
1940 } else {
1941 keep = iwl_mvm_query_wakeup_reasons(mvm, vif);
78c9df66 1942#ifdef CONFIG_IWLWIFI_DEBUGFS
2021a89d
LC
1943 if (keep)
1944 mvm->keep_vif = vif;
0c2ae049 1945#endif
e0ede177
LC
1946 /* has unlocked the mutex, so skip that */
1947 goto out_iterate;
2021a89d 1948 }
8ca151b5 1949
a500e469
LC
1950err:
1951 iwl_mvm_free_nd(mvm);
8ca151b5
JB
1952 mutex_unlock(&mvm->mutex);
1953
e0ede177 1954out_iterate:
6d9d32b8
JB
1955 if (!test)
1956 ieee80211_iterate_active_interfaces_rtnl(mvm->hw,
1957 IEEE80211_IFACE_ITER_NORMAL,
1958 iwl_mvm_d3_disconnect_iter, keep ? vif : NULL);
8ca151b5 1959
e0ede177 1960out:
8ca151b5
JB
1961 /* return 1 to reconfigure the device */
1962 set_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status);
58629d9d 1963 set_bit(IWL_MVM_STATUS_D3_RECONFIG, &mvm->status);
dcfc7fb1
LC
1964
1965 /* We always return 1, which causes mac80211 to do a reconfig
1966 * with IEEE80211_RECONFIG_TYPE_RESTART. This type of
1967 * reconfig calls iwl_mvm_restart_complete(), where we unref
1968 * the IWL_MVM_REF_UCODE_DOWN, so we need to take the
1969 * reference here.
1970 */
1971 iwl_mvm_ref(mvm, IWL_MVM_REF_UCODE_DOWN);
8ca151b5
JB
1972 return 1;
1973}
1974
2d42801b 1975static int iwl_mvm_resume_d3(struct iwl_mvm *mvm)
debff618 1976{
2d42801b
EP
1977 iwl_trans_resume(mvm->trans);
1978
1979 return __iwl_mvm_resume(mvm, false);
1980}
1981
1982static int iwl_mvm_resume_d0i3(struct iwl_mvm *mvm)
1983{
1984 bool exit_now;
6dfb36c8 1985 enum iwl_d3_status d3_status;
b7282643 1986 struct iwl_trans *trans = mvm->trans;
6dfb36c8 1987
b7282643 1988 iwl_trans_d3_resume(trans, &d3_status, false);
2d42801b
EP
1989
1990 /*
1991 * make sure to clear D0I3_DEFER_WAKEUP before
1992 * calling iwl_trans_resume(), which might wait
1993 * for d0i3 exit completion.
1994 */
1995 mutex_lock(&mvm->d0i3_suspend_mutex);
1996 __clear_bit(D0I3_DEFER_WAKEUP, &mvm->d0i3_suspend_flags);
1997 exit_now = __test_and_clear_bit(D0I3_PENDING_WAKEUP,
1998 &mvm->d0i3_suspend_flags);
1999 mutex_unlock(&mvm->d0i3_suspend_mutex);
2000 if (exit_now) {
2001 IWL_DEBUG_RPM(mvm, "Run deferred d0i3 exit\n");
2002 _iwl_mvm_exit_d0i3(mvm);
2003 }
debff618 2004
b7282643 2005 iwl_trans_resume(trans);
465921c8 2006
b7282643 2007 if (iwl_mvm_enter_d0i3_on_suspend(mvm)) {
2d42801b 2008 int ret = iwl_mvm_exit_d0i3(mvm->hw->priv);
6735943f 2009
2d42801b
EP
2010 if (ret)
2011 return ret;
2012 /*
2013 * d0i3 exit will be deferred until reconfig_complete.
2014 * make sure there we are out of d0i3.
2015 */
91742449 2016 }
2d42801b
EP
2017 return 0;
2018}
d15a747f 2019
2d42801b
EP
2020int iwl_mvm_resume(struct ieee80211_hw *hw)
2021{
2022 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
b7282643 2023 int ret;
2d42801b 2024
b7282643
LC
2025 if (mvm->trans->system_pm_mode == IWL_PLAT_PM_MODE_D0I3)
2026 ret = iwl_mvm_resume_d0i3(mvm);
2d42801b 2027 else
b7282643
LC
2028 ret = iwl_mvm_resume_d3(mvm);
2029
2030 mvm->trans->system_pm_mode = IWL_PLAT_PM_MODE_DISABLED;
2031
2032 return ret;
debff618
JB
2033}
2034
8ca151b5
JB
2035void iwl_mvm_set_wakeup(struct ieee80211_hw *hw, bool enabled)
2036{
2037 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
2038
2039 device_set_wakeup_enable(mvm->trans->dev, enabled);
2040}
debff618
JB
2041
2042#ifdef CONFIG_IWLWIFI_DEBUGFS
2043static int iwl_mvm_d3_test_open(struct inode *inode, struct file *file)
2044{
2045 struct iwl_mvm *mvm = inode->i_private;
2046 int err;
2047
2048 if (mvm->d3_test_active)
2049 return -EBUSY;
2050
2051 file->private_data = inode->i_private;
2052
2053 ieee80211_stop_queues(mvm->hw);
2054 synchronize_net();
2055
b7282643
LC
2056 mvm->trans->system_pm_mode = IWL_PLAT_PM_MODE_D3;
2057
debff618
JB
2058 /* start pseudo D3 */
2059 rtnl_lock();
2060 err = __iwl_mvm_suspend(mvm->hw, mvm->hw->wiphy->wowlan_config, true);
2061 rtnl_unlock();
2062 if (err > 0)
2063 err = -EINVAL;
2064 if (err) {
2065 ieee80211_wake_queues(mvm->hw);
2066 return err;
2067 }
2068 mvm->d3_test_active = true;
78c9df66 2069 mvm->keep_vif = NULL;
debff618
JB
2070 return 0;
2071}
2072
2073static ssize_t iwl_mvm_d3_test_read(struct file *file, char __user *user_buf,
2074 size_t count, loff_t *ppos)
2075{
2076 struct iwl_mvm *mvm = file->private_data;
2077 u32 pme_asserted;
2078
2079 while (true) {
4ed80a86
EP
2080 /* read pme_ptr if available */
2081 if (mvm->d3_test_pme_ptr) {
2082 pme_asserted = iwl_trans_read_mem32(mvm->trans,
2083 mvm->d3_test_pme_ptr);
2084 if (pme_asserted)
2085 break;
2086 }
2087
debff618
JB
2088 if (msleep_interruptible(100))
2089 break;
2090 }
2091
2092 return 0;
2093}
2094
2095static void iwl_mvm_d3_test_disconn_work_iter(void *_data, u8 *mac,
2096 struct ieee80211_vif *vif)
2097{
78c9df66
EP
2098 /* skip the one we keep connection on */
2099 if (_data == vif)
2100 return;
2101
debff618
JB
2102 if (vif->type == NL80211_IFTYPE_STATION)
2103 ieee80211_connection_loss(vif);
2104}
2105
2106static int iwl_mvm_d3_test_release(struct inode *inode, struct file *file)
2107{
2108 struct iwl_mvm *mvm = inode->i_private;
2109 int remaining_time = 10;
2110
2111 mvm->d3_test_active = false;
b7282643 2112
31ca09dd 2113 rtnl_lock();
debff618 2114 __iwl_mvm_resume(mvm, true);
31ca09dd 2115 rtnl_unlock();
b7282643
LC
2116
2117 mvm->trans->system_pm_mode = IWL_PLAT_PM_MODE_DISABLED;
2118
debff618
JB
2119 iwl_abort_notification_waits(&mvm->notif_wait);
2120 ieee80211_restart_hw(mvm->hw);
2121
2122 /* wait for restart and disconnect all interfaces */
2123 while (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) &&
2124 remaining_time > 0) {
2125 remaining_time--;
2126 msleep(1000);
2127 }
2128
2129 if (remaining_time == 0)
2130 IWL_ERR(mvm, "Timed out waiting for HW restart to finish!\n");
2131
2132 ieee80211_iterate_active_interfaces_atomic(
2133 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
78c9df66 2134 iwl_mvm_d3_test_disconn_work_iter, mvm->keep_vif);
debff618
JB
2135
2136 ieee80211_wake_queues(mvm->hw);
2137
2138 return 0;
2139}
2140
2141const struct file_operations iwl_dbgfs_d3_test_ops = {
2142 .llseek = no_llseek,
2143 .open = iwl_mvm_d3_test_open,
2144 .read = iwl_mvm_d3_test_read,
2145 .release = iwl_mvm_d3_test_release,
2146};
2147#endif
This page took 0.291527 seconds and 5 git commands to generate.