Lines Matching +full:num +full:- +full:macs
1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
3 * Copyright (C) 2012-2014, 2018-2024 Intel Corporation
4 * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
5 * Copyright (C) 2016-2017 Intel Deutschland GmbH
18 #include "iwl-modparams.h"
19 #include "fw-api.h"
30 mutex_lock(&mvm->mutex); in iwl_mvm_set_rekey_data()
32 mvmvif->rekey_data.kek_len = data->kek_len; in iwl_mvm_set_rekey_data()
33 mvmvif->rekey_data.kck_len = data->kck_len; in iwl_mvm_set_rekey_data()
34 memcpy(mvmvif->rekey_data.kek, data->kek, data->kek_len); in iwl_mvm_set_rekey_data()
35 memcpy(mvmvif->rekey_data.kck, data->kck, data->kck_len); in iwl_mvm_set_rekey_data()
36 mvmvif->rekey_data.akm = data->akm & 0xFF; in iwl_mvm_set_rekey_data()
37 mvmvif->rekey_data.replay_ctr = in iwl_mvm_set_rekey_data()
38 cpu_to_le64(be64_to_cpup((const __be64 *)data->replay_ctr)); in iwl_mvm_set_rekey_data()
39 mvmvif->rekey_data.valid = true; in iwl_mvm_set_rekey_data()
41 mutex_unlock(&mvm->mutex); in iwl_mvm_set_rekey_data()
53 memset(mvmvif->tentative_addrs, 0, sizeof(mvmvif->tentative_addrs)); in iwl_mvm_ipv6_addr_change()
55 read_lock_bh(&idev->lock); in iwl_mvm_ipv6_addr_change()
56 list_for_each_entry(ifa, &idev->addr_list, if_list) { in iwl_mvm_ipv6_addr_change()
57 mvmvif->target_ipv6_addrs[idx] = ifa->addr; in iwl_mvm_ipv6_addr_change()
58 if (ifa->flags & IFA_F_TENTATIVE) in iwl_mvm_ipv6_addr_change()
59 __set_bit(idx, mvmvif->tentative_addrs); in iwl_mvm_ipv6_addr_change()
64 read_unlock_bh(&idev->lock); in iwl_mvm_ipv6_addr_change()
66 mvmvif->num_target_ipv6_addrs = idx; in iwl_mvm_ipv6_addr_change()
75 mvmvif->tx_key_idx = idx; in iwl_mvm_set_default_unicast_key()
91 const u8 *ret = seq->ccmp.pn; in iwl_mvm_find_max_pn()
99 const u8 *tmp = ptk_pn->q[i].pn[tid]; in iwl_mvm_find_max_pn()
124 switch (key->cipher) { in iwl_mvm_wowlan_program_keys()
132 cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, in iwl_mvm_wowlan_program_keys()
133 mvmvif->color)), in iwl_mvm_wowlan_program_keys()
137 .wep_key.key_index = key->keyidx, in iwl_mvm_wowlan_program_keys()
138 .wep_key.key_size = key->keylen, in iwl_mvm_wowlan_program_keys()
142 * This will fail -- the key functions don't set support in iwl_mvm_wowlan_program_keys()
146 if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) in iwl_mvm_wowlan_program_keys()
149 memcpy(&wkc.wep_key.key[3], key->key, key->keylen); in iwl_mvm_wowlan_program_keys()
150 if (key->keyidx == mvmvif->tx_key_idx) { in iwl_mvm_wowlan_program_keys()
155 data->wep_key_idx++; in iwl_mvm_wowlan_program_keys()
156 wkc.wep_key.key_offset = data->wep_key_idx; in iwl_mvm_wowlan_program_keys()
159 mutex_lock(&mvm->mutex); in iwl_mvm_wowlan_program_keys()
161 data->error = ret != 0; in iwl_mvm_wowlan_program_keys()
163 mvm->ptk_ivlen = key->iv_len; in iwl_mvm_wowlan_program_keys()
164 mvm->ptk_icvlen = key->icv_len; in iwl_mvm_wowlan_program_keys()
165 mvm->gtk_ivlen = key->iv_len; in iwl_mvm_wowlan_program_keys()
166 mvm->gtk_icvlen = key->icv_len; in iwl_mvm_wowlan_program_keys()
167 mutex_unlock(&mvm->mutex); in iwl_mvm_wowlan_program_keys()
173 data->error = true; in iwl_mvm_wowlan_program_keys()
180 * Ignore CMAC keys -- the WoWLAN firmware doesn't support them in iwl_mvm_wowlan_program_keys()
194 mutex_lock(&mvm->mutex); in iwl_mvm_wowlan_program_keys()
199 if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) { in iwl_mvm_wowlan_program_keys()
200 mvm->ptk_ivlen = key->iv_len; in iwl_mvm_wowlan_program_keys()
201 mvm->ptk_icvlen = key->icv_len; in iwl_mvm_wowlan_program_keys()
207 * with new ones -- this relies on mac80211 doing in iwl_mvm_wowlan_program_keys()
210 mvm->gtk_ivlen = key->iv_len; in iwl_mvm_wowlan_program_keys()
211 mvm->gtk_icvlen = key->icv_len; in iwl_mvm_wowlan_program_keys()
214 mutex_unlock(&mvm->mutex); in iwl_mvm_wowlan_program_keys()
215 data->error = ret != 0; in iwl_mvm_wowlan_program_keys()
236 switch (key->cipher) { in iwl_mvm_wowlan_get_rsc_tsc_data()
244 data->rsc_tsc->params.all_tsc_rsc.tkip.unicast_rsc; in iwl_mvm_wowlan_get_rsc_tsc_data()
246 &data->rsc_tsc->params.all_tsc_rsc.tkip.tsc; in iwl_mvm_wowlan_get_rsc_tsc_data()
248 pn64 = atomic64_read(&key->tx_pn); in iwl_mvm_wowlan_get_rsc_tsc_data()
249 tkip_tx_sc->iv16 = cpu_to_le16(TKIP_PN_TO_IV16(pn64)); in iwl_mvm_wowlan_get_rsc_tsc_data()
250 tkip_tx_sc->iv32 = cpu_to_le32(TKIP_PN_TO_IV32(pn64)); in iwl_mvm_wowlan_get_rsc_tsc_data()
253 data->rsc_tsc->params.all_tsc_rsc.tkip.multicast_rsc; in iwl_mvm_wowlan_get_rsc_tsc_data()
257 * For non-QoS this relies on the fact that both the uCode and in iwl_mvm_wowlan_get_rsc_tsc_data()
267 data->have_rsc_tsc = true; in iwl_mvm_wowlan_get_rsc_tsc_data()
277 data->rsc_tsc->params.all_tsc_rsc.aes.unicast_rsc; in iwl_mvm_wowlan_get_rsc_tsc_data()
279 &data->rsc_tsc->params.all_tsc_rsc.aes.tsc; in iwl_mvm_wowlan_get_rsc_tsc_data()
281 pn64 = atomic64_read(&key->tx_pn); in iwl_mvm_wowlan_get_rsc_tsc_data()
282 aes_tx_sc->pn = cpu_to_le64(pn64); in iwl_mvm_wowlan_get_rsc_tsc_data()
285 data->rsc_tsc->params.all_tsc_rsc.aes.multicast_rsc; in iwl_mvm_wowlan_get_rsc_tsc_data()
289 * For non-QoS this relies on the fact that both the uCode and in iwl_mvm_wowlan_get_rsc_tsc_data()
299 ptk_pn = rcu_dereference(mvmsta->ptk_pn[key->keyidx]); in iwl_mvm_wowlan_get_rsc_tsc_data()
307 mvm->trans->num_rx_queues); in iwl_mvm_wowlan_get_rsc_tsc_data()
330 data->have_rsc_tsc = true; in iwl_mvm_wowlan_get_rsc_tsc_data()
355 switch (key->cipher) { in iwl_mvm_wowlan_get_rsc_v5_data()
366 rsc = data->rsc->ucast_rsc; in iwl_mvm_wowlan_get_rsc_v5_data()
368 if (WARN_ON(data->gtks >= ARRAY_SIZE(data->gtk_ids))) in iwl_mvm_wowlan_get_rsc_v5_data()
370 data->gtk_ids[data->gtks] = key->keyidx; in iwl_mvm_wowlan_get_rsc_v5_data()
371 rsc = data->rsc->mcast_rsc[data->gtks % 2]; in iwl_mvm_wowlan_get_rsc_v5_data()
372 if (WARN_ON(key->keyidx >= in iwl_mvm_wowlan_get_rsc_v5_data()
373 ARRAY_SIZE(data->rsc->mcast_key_id_map))) in iwl_mvm_wowlan_get_rsc_v5_data()
375 data->rsc->mcast_key_id_map[key->keyidx] = data->gtks % 2; in iwl_mvm_wowlan_get_rsc_v5_data()
376 if (data->gtks >= 2) { in iwl_mvm_wowlan_get_rsc_v5_data()
377 int prev = data->gtks - 2; in iwl_mvm_wowlan_get_rsc_v5_data()
378 int prev_idx = data->gtk_ids[prev]; in iwl_mvm_wowlan_get_rsc_v5_data()
380 data->rsc->mcast_key_id_map[prev_idx] = in iwl_mvm_wowlan_get_rsc_v5_data()
383 data->gtks++; in iwl_mvm_wowlan_get_rsc_v5_data()
386 switch (key->cipher) { in iwl_mvm_wowlan_get_rsc_v5_data()
393 * For non-QoS this relies on the fact that both the uCode and in iwl_mvm_wowlan_get_rsc_v5_data()
404 data->have_rsc = true; in iwl_mvm_wowlan_get_rsc_v5_data()
410 * For non-QoS this relies on the fact that both the uCode and in iwl_mvm_wowlan_get_rsc_v5_data()
420 ptk_pn = rcu_dereference(mvmsta->ptk_pn[key->keyidx]); in iwl_mvm_wowlan_get_rsc_v5_data()
428 mvm->trans->num_rx_queues); in iwl_mvm_wowlan_get_rsc_v5_data()
451 data->have_rsc = true; in iwl_mvm_wowlan_get_rsc_v5_data()
460 int ver = iwl_fw_lookup_cmd_ver(mvm->fw, WOWLAN_TSC_RSC_PARAM, in iwl_mvm_wowlan_config_rsc_tsc()
470 return -ENOMEM; in iwl_mvm_wowlan_config_rsc_tsc()
472 for (i = 0; i < ARRAY_SIZE(data.rsc->mcast_key_id_map); i++) in iwl_mvm_wowlan_config_rsc_tsc()
473 data.rsc->mcast_key_id_map[i] = in iwl_mvm_wowlan_config_rsc_tsc()
475 data.rsc->sta_id = cpu_to_le32(mvm_link->ap_sta_id); in iwl_mvm_wowlan_config_rsc_tsc()
477 ieee80211_iter_keys(mvm->hw, vif, in iwl_mvm_wowlan_config_rsc_tsc()
494 return -ENOMEM; in iwl_mvm_wowlan_config_rsc_tsc()
498 data.rsc_tsc->sta_id = in iwl_mvm_wowlan_config_rsc_tsc()
499 cpu_to_le32(mvm_link->ap_sta_id); in iwl_mvm_wowlan_config_rsc_tsc()
502 size = sizeof(data.rsc_tsc->params); in iwl_mvm_wowlan_config_rsc_tsc()
505 ieee80211_iter_keys(mvm->hw, vif, in iwl_mvm_wowlan_config_rsc_tsc()
543 switch (key->cipher) { in iwl_mvm_wowlan_get_tkip_data()
550 rx_p1ks = data->tkip.rx_uni; in iwl_mvm_wowlan_get_tkip_data()
552 pn64 = atomic64_read(&key->tx_pn); in iwl_mvm_wowlan_get_tkip_data()
556 iwl_mvm_convert_p1k(p1k, data->tkip.tx.p1k); in iwl_mvm_wowlan_get_tkip_data()
558 memcpy(data->tkip.mic_keys.tx, in iwl_mvm_wowlan_get_tkip_data()
559 &key->key[NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY], in iwl_mvm_wowlan_get_tkip_data()
562 rx_mic_key = data->tkip.mic_keys.rx_unicast; in iwl_mvm_wowlan_get_tkip_data()
564 rx_p1ks = data->tkip.rx_multi; in iwl_mvm_wowlan_get_tkip_data()
565 rx_mic_key = data->tkip.mic_keys.rx_mcast; in iwl_mvm_wowlan_get_tkip_data()
575 ieee80211_get_tkip_rx_p1k(key, vif->bss_conf.bssid, in iwl_mvm_wowlan_get_tkip_data()
578 ieee80211_get_tkip_rx_p1k(key, vif->bss_conf.bssid, in iwl_mvm_wowlan_get_tkip_data()
583 &key->key[NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY], in iwl_mvm_wowlan_get_tkip_data()
586 data->have_tkip_keys = true; in iwl_mvm_wowlan_get_tkip_data()
604 if (key->keyidx == 4 || key->keyidx == 5) in iwl_mvm_wowlan_gtk_type_iter()
605 cipher = &data->kek_kck_cmd->igtk_cipher; in iwl_mvm_wowlan_gtk_type_iter()
606 if (key->keyidx == 6 || key->keyidx == 7) in iwl_mvm_wowlan_gtk_type_iter()
607 cipher = &data->kek_kck_cmd->bigtk_cipher; in iwl_mvm_wowlan_gtk_type_iter()
609 switch (key->cipher) { in iwl_mvm_wowlan_gtk_type_iter()
614 data->kek_kck_cmd->gtk_cipher = in iwl_mvm_wowlan_gtk_type_iter()
629 data->kek_kck_cmd->gtk_cipher = in iwl_mvm_wowlan_gtk_type_iter()
635 data->kek_kck_cmd->gtk_cipher = in iwl_mvm_wowlan_gtk_type_iter()
651 if (!wowlan->n_patterns) in iwl_mvm_send_patterns_v1()
654 cmd.len[0] = struct_size(pattern_cmd, patterns, wowlan->n_patterns); in iwl_mvm_send_patterns_v1()
658 return -ENOMEM; in iwl_mvm_send_patterns_v1()
660 pattern_cmd->n_patterns = cpu_to_le32(wowlan->n_patterns); in iwl_mvm_send_patterns_v1()
662 for (i = 0; i < wowlan->n_patterns; i++) { in iwl_mvm_send_patterns_v1()
663 int mask_len = DIV_ROUND_UP(wowlan->patterns[i].pattern_len, 8); in iwl_mvm_send_patterns_v1()
665 memcpy(&pattern_cmd->patterns[i].mask, in iwl_mvm_send_patterns_v1()
666 wowlan->patterns[i].mask, mask_len); in iwl_mvm_send_patterns_v1()
667 memcpy(&pattern_cmd->patterns[i].pattern, in iwl_mvm_send_patterns_v1()
668 wowlan->patterns[i].pattern, in iwl_mvm_send_patterns_v1()
669 wowlan->patterns[i].pattern_len); in iwl_mvm_send_patterns_v1()
670 pattern_cmd->patterns[i].mask_size = mask_len; in iwl_mvm_send_patterns_v1()
671 pattern_cmd->patterns[i].pattern_size = in iwl_mvm_send_patterns_v1()
672 wowlan->patterns[i].pattern_len; in iwl_mvm_send_patterns_v1()
691 int ver = iwl_fw_lookup_cmd_ver(mvm->fw, cmd.id, in iwl_mvm_send_patterns()
694 if (!wowlan->n_patterns) in iwl_mvm_send_patterns()
698 wowlan->n_patterns * sizeof(struct iwl_wowlan_pattern_v2); in iwl_mvm_send_patterns()
702 return -ENOMEM; in iwl_mvm_send_patterns()
704 pattern_cmd->n_patterns = wowlan->n_patterns; in iwl_mvm_send_patterns()
706 pattern_cmd->sta_id = mvm_link->ap_sta_id; in iwl_mvm_send_patterns()
708 for (i = 0; i < wowlan->n_patterns; i++) { in iwl_mvm_send_patterns()
709 int mask_len = DIV_ROUND_UP(wowlan->patterns[i].pattern_len, 8); in iwl_mvm_send_patterns()
711 pattern_cmd->patterns[i].pattern_type = in iwl_mvm_send_patterns()
714 memcpy(&pattern_cmd->patterns[i].u.bitmask.mask, in iwl_mvm_send_patterns()
715 wowlan->patterns[i].mask, mask_len); in iwl_mvm_send_patterns()
716 memcpy(&pattern_cmd->patterns[i].u.bitmask.pattern, in iwl_mvm_send_patterns()
717 wowlan->patterns[i].pattern, in iwl_mvm_send_patterns()
718 wowlan->patterns[i].pattern_len); in iwl_mvm_send_patterns()
719 pattern_cmd->patterns[i].u.bitmask.mask_size = mask_len; in iwl_mvm_send_patterns()
720 pattern_cmd->patterns[i].u.bitmask.pattern_size = in iwl_mvm_send_patterns()
721 wowlan->patterns[i].pattern_len; in iwl_mvm_send_patterns()
745 return -EINVAL; in iwl_mvm_d3_reprogram()
748 if (WARN_ON(!mvmvif->deflink.phy_ctxt)) in iwl_mvm_d3_reprogram()
749 return -EINVAL; in iwl_mvm_d3_reprogram()
752 ctx = rcu_dereference(vif->bss_conf.chanctx_conf); in iwl_mvm_d3_reprogram()
755 return -EINVAL; in iwl_mvm_d3_reprogram()
757 chandef = ctx->def; in iwl_mvm_d3_reprogram()
758 ap_def = ctx->ap; in iwl_mvm_d3_reprogram()
759 chains_static = ctx->rx_chains_static; in iwl_mvm_d3_reprogram()
760 chains_dynamic = ctx->rx_chains_dynamic; in iwl_mvm_d3_reprogram()
763 ret = iwl_mvm_phy_ctxt_add(mvm, mvmvif->deflink.phy_ctxt, &chandef, in iwl_mvm_d3_reprogram()
769 mvmvif->uploaded = false; in iwl_mvm_d3_reprogram()
771 if (WARN_ON(!vif->cfg.assoc)) in iwl_mvm_d3_reprogram()
772 return -EINVAL; in iwl_mvm_d3_reprogram()
778 /* add back binding - XXX refactor? */ in iwl_mvm_d3_reprogram()
780 cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->deflink.phy_ctxt->id, in iwl_mvm_d3_reprogram()
781 mvmvif->deflink.phy_ctxt->color)); in iwl_mvm_d3_reprogram()
784 cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->deflink.phy_ctxt->id, in iwl_mvm_d3_reprogram()
785 mvmvif->deflink.phy_ctxt->color)); in iwl_mvm_d3_reprogram()
786 binding_cmd.macs[0] = cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, in iwl_mvm_d3_reprogram()
787 mvmvif->color)); in iwl_mvm_d3_reprogram()
789 binding_cmd.macs[i] = cpu_to_le32(FW_CTXT_INVALID); in iwl_mvm_d3_reprogram()
802 return -EIO; in iwl_mvm_d3_reprogram()
808 rcu_assign_pointer(mvm->fw_id_to_mac_id[mvmvif->deflink.ap_sta_id], in iwl_mvm_d3_reprogram()
817 quota->id_and_color = in iwl_mvm_d3_reprogram()
818 cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->deflink.phy_ctxt->id, in iwl_mvm_d3_reprogram()
819 mvmvif->deflink.phy_ctxt->color)); in iwl_mvm_d3_reprogram()
820 quota->quota = cpu_to_le32(IWL_MVM_MAX_QUOTA); in iwl_mvm_d3_reprogram()
821 quota->max_duration = cpu_to_le32(IWL_MVM_MAX_QUOTA); in iwl_mvm_d3_reprogram()
825 quota->id_and_color = cpu_to_le32(FW_CTXT_INVALID); in iwl_mvm_d3_reprogram()
846 cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, in iwl_mvm_get_last_nonqos_seq()
847 mvmvif->color)), in iwl_mvm_get_last_nonqos_seq()
865 err = -EINVAL; in iwl_mvm_get_last_nonqos_seq()
867 err = le16_to_cpup((__le16 *)cmd.resp_pkt->data); in iwl_mvm_get_last_nonqos_seq()
868 /* firmware returns next, not last-used seqno */ in iwl_mvm_get_last_nonqos_seq()
869 err = (u16) (err - 0x10); in iwl_mvm_get_last_nonqos_seq()
882 cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, in iwl_mvm_set_last_nonqos_seq()
883 mvmvif->color)), in iwl_mvm_set_last_nonqos_seq()
884 .value = cpu_to_le16(mvmvif->seqno), in iwl_mvm_set_last_nonqos_seq()
888 if (!mvmvif->seqno_valid) in iwl_mvm_set_last_nonqos_seq()
891 mvmvif->seqno_valid = false; in iwl_mvm_set_last_nonqos_seq()
895 IWL_ERR(mvm, "failed to set non-QoS seqno\n"); in iwl_mvm_set_last_nonqos_seq()
904 * Set the HW restart bit -- this is mostly true as we're in iwl_mvm_switch_to_d3()
907 * all the MACs that aren't support. in iwl_mvm_switch_to_d3()
913 set_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status); in iwl_mvm_switch_to_d3()
916 memset(mvm->fw_key_table, 0, sizeof(mvm->fw_key_table)); in iwl_mvm_switch_to_d3()
918 mvm->ptk_ivlen = 0; in iwl_mvm_switch_to_d3()
919 mvm->ptk_icvlen = 0; in iwl_mvm_switch_to_d3()
920 mvm->ptk_ivlen = 0; in iwl_mvm_switch_to_d3()
921 mvm->ptk_icvlen = 0; in iwl_mvm_switch_to_d3()
935 /* TODO: wowlan_config_cmd->wowlan_ba_teardown_tids */ in iwl_mvm_get_wowlan_config()
937 wowlan_config_cmd->is_11n_connection = in iwl_mvm_get_wowlan_config()
938 ap_sta->deflink.ht_cap.ht_supported; in iwl_mvm_get_wowlan_config()
939 wowlan_config_cmd->flags = ENABLE_L3_FILTERING | in iwl_mvm_get_wowlan_config()
942 if (ap_sta->mfp) in iwl_mvm_get_wowlan_config()
943 wowlan_config_cmd->flags |= IS_11W_ASSOC; in iwl_mvm_get_wowlan_config()
945 if (iwl_fw_lookup_cmd_ver(mvm->fw, WOWLAN_CONFIGURATION, 0) < 6) { in iwl_mvm_get_wowlan_config()
952 wowlan_config_cmd->non_qos_seq = cpu_to_le16(ret); in iwl_mvm_get_wowlan_config()
957 if (wowlan->disconnect) in iwl_mvm_get_wowlan_config()
958 wowlan_config_cmd->wakeup_filter |= in iwl_mvm_get_wowlan_config()
961 if (wowlan->magic_pkt) in iwl_mvm_get_wowlan_config()
962 wowlan_config_cmd->wakeup_filter |= in iwl_mvm_get_wowlan_config()
964 if (wowlan->gtk_rekey_failure) in iwl_mvm_get_wowlan_config()
965 wowlan_config_cmd->wakeup_filter |= in iwl_mvm_get_wowlan_config()
967 if (wowlan->eap_identity_req) in iwl_mvm_get_wowlan_config()
968 wowlan_config_cmd->wakeup_filter |= in iwl_mvm_get_wowlan_config()
970 if (wowlan->four_way_handshake) in iwl_mvm_get_wowlan_config()
971 wowlan_config_cmd->wakeup_filter |= in iwl_mvm_get_wowlan_config()
973 if (wowlan->n_patterns) in iwl_mvm_get_wowlan_config()
974 wowlan_config_cmd->wakeup_filter |= in iwl_mvm_get_wowlan_config()
977 if (wowlan->rfkill_release) in iwl_mvm_get_wowlan_config()
978 wowlan_config_cmd->wakeup_filter |= in iwl_mvm_get_wowlan_config()
981 if (wowlan->tcp) { in iwl_mvm_get_wowlan_config()
986 wowlan_config_cmd->wakeup_filter |= in iwl_mvm_get_wowlan_config()
993 if (wowlan->any) { in iwl_mvm_get_wowlan_config()
994 wowlan_config_cmd->wakeup_filter |= in iwl_mvm_get_wowlan_config()
1008 bool unified = fw_has_capa(&mvm->fw->ucode_capa, in iwl_mvm_wowlan_config_key_params()
1019 * as we need non-atomic context in order to take the in iwl_mvm_wowlan_config_key_params()
1026 * take care of locking/unlocking mvm->mutex. in iwl_mvm_wowlan_config_key_params()
1028 ieee80211_iter_keys(mvm->hw, vif, iwl_mvm_wowlan_program_keys, in iwl_mvm_wowlan_config_key_params()
1032 return -EIO; in iwl_mvm_wowlan_config_key_params()
1039 if (!fw_has_api(&mvm->fw->ucode_capa, in iwl_mvm_wowlan_config_key_params()
1041 int ver = iwl_fw_lookup_cmd_ver(mvm->fw, WOWLAN_TKIP_PARAM, in iwl_mvm_wowlan_config_key_params()
1049 cpu_to_le32(mvm_link->ap_sta_id); in iwl_mvm_wowlan_config_key_params()
1054 return -EINVAL; in iwl_mvm_wowlan_config_key_params()
1057 ieee80211_iter_keys(mvm->hw, vif, iwl_mvm_wowlan_get_tkip_data, in iwl_mvm_wowlan_config_key_params()
1072 if (mvmvif->rekey_data.valid) { in iwl_mvm_wowlan_config_key_params()
1080 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw, in iwl_mvm_wowlan_config_key_params()
1085 return -EINVAL; in iwl_mvm_wowlan_config_key_params()
1087 ieee80211_iter_keys(mvm->hw, vif, iwl_mvm_wowlan_gtk_type_iter, in iwl_mvm_wowlan_config_key_params()
1090 memcpy(kek_kck_cmd.kck, mvmvif->rekey_data.kck, in iwl_mvm_wowlan_config_key_params()
1091 mvmvif->rekey_data.kck_len); in iwl_mvm_wowlan_config_key_params()
1092 kek_kck_cmd.kck_len = cpu_to_le16(mvmvif->rekey_data.kck_len); in iwl_mvm_wowlan_config_key_params()
1093 memcpy(kek_kck_cmd.kek, mvmvif->rekey_data.kek, in iwl_mvm_wowlan_config_key_params()
1094 mvmvif->rekey_data.kek_len); in iwl_mvm_wowlan_config_key_params()
1095 kek_kck_cmd.kek_len = cpu_to_le16(mvmvif->rekey_data.kek_len); in iwl_mvm_wowlan_config_key_params()
1096 kek_kck_cmd.replay_ctr = mvmvif->rekey_data.replay_ctr; in iwl_mvm_wowlan_config_key_params()
1097 kek_kck_cmd.akm = cpu_to_le32(mvmvif->rekey_data.akm); in iwl_mvm_wowlan_config_key_params()
1098 kek_kck_cmd.sta_id = cpu_to_le32(mvm_link->ap_sta_id); in iwl_mvm_wowlan_config_key_params()
1115 mvmvif->rekey_data.akm); in iwl_mvm_wowlan_config_key_params()
1135 bool unified_image = fw_has_capa(&mvm->fw->ucode_capa, in iwl_mvm_wowlan_config()
1138 mvm->offload_tid = wowlan_config_cmd->offloading_tid; in iwl_mvm_wowlan_config()
1160 if (fw_has_api(&mvm->fw->ucode_capa, in iwl_mvm_wowlan_config()
1169 mvm_link->ap_sta_id); in iwl_mvm_wowlan_config()
1179 bool unified_image = fw_has_capa(&mvm->fw->ucode_capa, in iwl_mvm_netdetect_config()
1189 * net-detect). But in practice this doesn't seem to in iwl_mvm_netdetect_config()
1197 ret = iwl_mvm_sched_scan_start(mvm, vif, nd_config, &mvm->nd_ies, in iwl_mvm_netdetect_config()
1202 if (WARN_ON(mvm->nd_match_sets || mvm->nd_channels)) in iwl_mvm_netdetect_config()
1203 return -EBUSY; in iwl_mvm_netdetect_config()
1206 if (nd_config->n_match_sets) { in iwl_mvm_netdetect_config()
1207 mvm->nd_match_sets = kmemdup(nd_config->match_sets, in iwl_mvm_netdetect_config()
1208 sizeof(*nd_config->match_sets) * in iwl_mvm_netdetect_config()
1209 nd_config->n_match_sets, in iwl_mvm_netdetect_config()
1211 if (mvm->nd_match_sets) in iwl_mvm_netdetect_config()
1212 mvm->n_nd_match_sets = nd_config->n_match_sets; in iwl_mvm_netdetect_config()
1216 mvm->nd_channels = kmemdup(nd_config->channels, in iwl_mvm_netdetect_config()
1217 sizeof(*nd_config->channels) * in iwl_mvm_netdetect_config()
1218 nd_config->n_channels, in iwl_mvm_netdetect_config()
1220 if (mvm->nd_channels) in iwl_mvm_netdetect_config()
1221 mvm->n_nd_channels = nd_config->n_channels; in iwl_mvm_netdetect_config()
1228 kfree(mvm->nd_match_sets); in iwl_mvm_free_nd()
1229 mvm->nd_match_sets = NULL; in iwl_mvm_free_nd()
1230 mvm->n_nd_match_sets = 0; in iwl_mvm_free_nd()
1231 kfree(mvm->nd_channels); in iwl_mvm_free_nd()
1232 mvm->nd_channels = NULL; in iwl_mvm_free_nd()
1233 mvm->n_nd_channels = 0; in iwl_mvm_free_nd()
1261 bool unified_image = fw_has_capa(&mvm->fw->ucode_capa, in __iwl_mvm_suspend()
1270 return -EINVAL; in __iwl_mvm_suspend()
1281 mutex_lock(&mvm->mutex); in __iwl_mvm_suspend()
1283 set_bit(IWL_MVM_STATUS_IN_D3, &mvm->status); in __iwl_mvm_suspend()
1289 mvm_link = mvmvif->link[iwl_mvm_get_primary_link(vif)]; in __iwl_mvm_suspend()
1291 ret = -EINVAL; in __iwl_mvm_suspend()
1295 if (mvm_link->ap_sta_id == IWL_MVM_INVALID_STA) { in __iwl_mvm_suspend()
1297 if (!wowlan->nd_config) { in __iwl_mvm_suspend()
1303 mvm, wowlan, wowlan->nd_config, vif); in __iwl_mvm_suspend()
1307 mvm->net_detect = true; in __iwl_mvm_suspend()
1313 wowlan_config_cmd.sta_id = mvm_link->ap_sta_id; in __iwl_mvm_suspend()
1316 mvm->fw_id_to_mac_id[mvm_link->ap_sta_id], in __iwl_mvm_suspend()
1317 lockdep_is_held(&mvm->mutex)); in __iwl_mvm_suspend()
1319 ret = -EINVAL; in __iwl_mvm_suspend()
1324 mvm, ap_sta->txq[wowlan_config_cmd.offloading_tid]); in __iwl_mvm_suspend()
1337 mvm->net_detect = false; in __iwl_mvm_suspend()
1349 if (mvm->d3_wake_sysassert) in __iwl_mvm_suspend()
1359 if (mvm->trans->trans_cfg->device_family < IWL_DEVICE_FAMILY_9000) in __iwl_mvm_suspend()
1360 iwl_fw_dbg_stop_restart_recording(&mvm->fwrt, NULL, true); in __iwl_mvm_suspend()
1362 mvm->trans->system_pm_mode = IWL_PLAT_PM_MODE_D3; in __iwl_mvm_suspend()
1364 /* must be last -- this switches firmware state */ in __iwl_mvm_suspend()
1371 mvm->d3_test_pme_ptr = in __iwl_mvm_suspend()
1372 le32_to_cpup((__le32 *)d3_cfg_cmd.resp_pkt->data); in __iwl_mvm_suspend()
1377 clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status); in __iwl_mvm_suspend()
1379 ret = iwl_trans_d3_suspend(mvm->trans, test, !unified_image); in __iwl_mvm_suspend()
1385 if (mvm->fw_restart > 0) { in __iwl_mvm_suspend()
1386 mvm->fw_restart--; in __iwl_mvm_suspend()
1387 ieee80211_restart_hw(mvm->hw); in __iwl_mvm_suspend()
1391 clear_bit(IWL_MVM_STATUS_IN_D3, &mvm->status); in __iwl_mvm_suspend()
1394 mutex_unlock(&mvm->mutex); in __iwl_mvm_suspend()
1405 iwl_fw_runtime_suspend(&mvm->fwrt); in iwl_mvm_suspend()
1451 * We use -1 for when we have valid data but don't know
1482 .pattern_idx = -1, in iwl_mvm_report_wakeup_reasons()
1485 u32 reasons = status->wakeup_reasons; in iwl_mvm_report_wakeup_reasons()
1492 pm_wakeup_event(mvm->dev, 0); in iwl_mvm_report_wakeup_reasons()
1499 status->pattern_number; in iwl_mvm_report_wakeup_reasons()
1530 if (status->wake_packet) { in iwl_mvm_report_wakeup_reasons()
1531 int pktsize = status->wake_packet_bufsize; in iwl_mvm_report_wakeup_reasons()
1532 int pktlen = status->wake_packet_length; in iwl_mvm_report_wakeup_reasons()
1533 const u8 *pktdata = status->wake_packet; in iwl_mvm_report_wakeup_reasons()
1535 int truncated = pktlen - pktsize; in iwl_mvm_report_wakeup_reasons()
1541 if (ieee80211_is_data(hdr->frame_control)) { in iwl_mvm_report_wakeup_reasons()
1542 int hdrlen = ieee80211_hdrlen(hdr->frame_control); in iwl_mvm_report_wakeup_reasons()
1551 pktsize -= hdrlen; in iwl_mvm_report_wakeup_reasons()
1553 if (ieee80211_has_protected(hdr->frame_control)) { in iwl_mvm_report_wakeup_reasons()
1557 * that's not really a problem - changing in iwl_mvm_report_wakeup_reasons()
1560 if (is_multicast_ether_addr(hdr->addr1)) { in iwl_mvm_report_wakeup_reasons()
1561 ivlen = mvm->gtk_ivlen; in iwl_mvm_report_wakeup_reasons()
1562 icvlen += mvm->gtk_icvlen; in iwl_mvm_report_wakeup_reasons()
1564 ivlen = mvm->ptk_ivlen; in iwl_mvm_report_wakeup_reasons()
1565 icvlen += mvm->ptk_icvlen; in iwl_mvm_report_wakeup_reasons()
1572 truncated -= icvlen; in iwl_mvm_report_wakeup_reasons()
1574 icvlen -= truncated; in iwl_mvm_report_wakeup_reasons()
1578 pktsize -= ivlen + icvlen; in iwl_mvm_report_wakeup_reasons()
1583 if (ieee80211_data_to_8023(pkt, vif->addr, vif->type)) in iwl_mvm_report_wakeup_reasons()
1585 wakeup.packet = pkt->data; in iwl_mvm_report_wakeup_reasons()
1586 wakeup.packet_present_len = pkt->len; in iwl_mvm_report_wakeup_reasons()
1587 wakeup.packet_len = pkt->len - truncated; in iwl_mvm_report_wakeup_reasons()
1593 truncated -= 4; in iwl_mvm_report_wakeup_reasons()
1596 fcslen -= truncated; in iwl_mvm_report_wakeup_reasons()
1599 pktsize -= fcslen; in iwl_mvm_report_wakeup_reasons()
1600 wakeup.packet = status->wake_packet; in iwl_mvm_report_wakeup_reasons()
1602 wakeup.packet_len = pktlen - truncated; in iwl_mvm_report_wakeup_reasons()
1616 seq->ccmp.pn[0] = pn >> 40; in iwl_mvm_le64_to_aes_seq()
1617 seq->ccmp.pn[1] = pn >> 32; in iwl_mvm_le64_to_aes_seq()
1618 seq->ccmp.pn[2] = pn >> 24; in iwl_mvm_le64_to_aes_seq()
1619 seq->ccmp.pn[3] = pn >> 16; in iwl_mvm_le64_to_aes_seq()
1620 seq->ccmp.pn[4] = pn >> 8; in iwl_mvm_le64_to_aes_seq()
1621 seq->ccmp.pn[5] = pn; in iwl_mvm_le64_to_aes_seq()
1627 iwl_mvm_le64_to_aes_seq(sc->pn, seq); in iwl_mvm_aes_sc_to_seq()
1634 seq->tkip.iv16 = (u16)pn; in iwl_mvm_le64_to_tkip_seq()
1635 seq->tkip.iv32 = (u32)(pn >> 16); in iwl_mvm_le64_to_tkip_seq()
1641 seq->tkip.iv32 = le32_to_cpu(sc->iv32); in iwl_mvm_tkip_sc_to_seq()
1642 seq->tkip.iv16 = le16_to_cpu(sc->iv16); in iwl_mvm_tkip_sc_to_seq()
1663 iwl_mvm_set_key_rx_seq_tids(key, status->ptk.aes.seq); in iwl_mvm_set_aes_ptk_rx_seq()
1670 ptk_pn = rcu_dereference(mvmsta->ptk_pn[key->keyidx]); in iwl_mvm_set_aes_ptk_rx_seq()
1679 for (i = 1; i < mvm->trans->num_rx_queues; i++) in iwl_mvm_set_aes_ptk_rx_seq()
1680 memcpy(ptk_pn->q[i].pn[tid], in iwl_mvm_set_aes_ptk_rx_seq()
1681 status->ptk.aes.seq[tid].ccmp.pn, in iwl_mvm_set_aes_ptk_rx_seq()
1697 iwl_mvm_tkip_sc_to_seq(&sc->tkip.multicast_rsc[i], in iwl_mvm_convert_key_counters()
1698 &status->gtk_seq[0].tkip.seq[i]); in iwl_mvm_convert_key_counters()
1699 iwl_mvm_aes_sc_to_seq(&sc->aes.multicast_rsc[i], in iwl_mvm_convert_key_counters()
1700 &status->gtk_seq[0].aes.seq[i]); in iwl_mvm_convert_key_counters()
1702 status->gtk_seq[0].valid = true; in iwl_mvm_convert_key_counters()
1703 status->gtk_seq[0].key_id = -1; in iwl_mvm_convert_key_counters()
1706 status->ptk.tkip.tx_pn = (u64)le16_to_cpu(sc->tkip.tsc.iv16) | in iwl_mvm_convert_key_counters()
1707 ((u64)le32_to_cpu(sc->tkip.tsc.iv32) << 16); in iwl_mvm_convert_key_counters()
1708 status->ptk.aes.tx_pn = le64_to_cpu(sc->aes.tsc.pn); in iwl_mvm_convert_key_counters()
1712 iwl_mvm_tkip_sc_to_seq(&sc->tkip.unicast_rsc[i], in iwl_mvm_convert_key_counters()
1713 &status->ptk.tkip.seq[i]); in iwl_mvm_convert_key_counters()
1714 iwl_mvm_aes_sc_to_seq(&sc->aes.unicast_rsc[i], in iwl_mvm_convert_key_counters()
1715 &status->ptk.aes.seq[i]); in iwl_mvm_convert_key_counters()
1727 iwl_mvm_le64_to_tkip_seq(sc->mcast_rsc[idx][tid], in iwl_mvm_convert_key_counters_v5_gtk_seq()
1728 &status->gtk_seq[idx].tkip.seq[tid]); in iwl_mvm_convert_key_counters_v5_gtk_seq()
1729 iwl_mvm_le64_to_aes_seq(sc->mcast_rsc[idx][tid], in iwl_mvm_convert_key_counters_v5_gtk_seq()
1730 &status->gtk_seq[idx].aes.seq[tid]); in iwl_mvm_convert_key_counters_v5_gtk_seq()
1733 status->gtk_seq[idx].valid = true; in iwl_mvm_convert_key_counters_v5_gtk_seq()
1734 status->gtk_seq[idx].key_id = key_id; in iwl_mvm_convert_key_counters_v5_gtk_seq()
1745 BUILD_BUG_ON(ARRAY_SIZE(sc->mcast_rsc) != ARRAY_SIZE(status->gtk_seq)); in iwl_mvm_convert_key_counters_v5()
1748 for (i = 0; i < ARRAY_SIZE(sc->mcast_key_id_map); i++) { in iwl_mvm_convert_key_counters_v5()
1749 u8 entry = sc->mcast_key_id_map[i]; in iwl_mvm_convert_key_counters_v5()
1751 if (entry < ARRAY_SIZE(sc->mcast_rsc)) in iwl_mvm_convert_key_counters_v5()
1760 iwl_mvm_le64_to_tkip_seq(sc->ucast_rsc[tid], in iwl_mvm_convert_key_counters_v5()
1761 &status->ptk.tkip.seq[tid]); in iwl_mvm_convert_key_counters_v5()
1762 iwl_mvm_le64_to_aes_seq(sc->ucast_rsc[tid], in iwl_mvm_convert_key_counters_v5()
1763 &status->ptk.aes.seq[tid]); in iwl_mvm_convert_key_counters_v5()
1771 switch (key->cipher) { in iwl_mvm_set_key_rx_seq_idx()
1775 iwl_mvm_set_key_rx_seq_tids(key, status->gtk_seq[idx].aes.seq); in iwl_mvm_set_key_rx_seq_idx()
1778 iwl_mvm_set_key_rx_seq_tids(key, status->gtk_seq[idx].tkip.seq); in iwl_mvm_set_key_rx_seq_idx()
1791 for (i = 0; i < ARRAY_SIZE(status->gtk_seq); i++) { in iwl_mvm_set_key_rx_seq()
1792 if (!status->gtk_seq[i].valid) in iwl_mvm_set_key_rx_seq()
1796 if (status->gtk_seq[i].key_id == key->keyidx) { in iwl_mvm_set_key_rx_seq()
1797 s8 new_key_id = -1; in iwl_mvm_set_key_rx_seq()
1799 if (status->num_of_gtk_rekeys) in iwl_mvm_set_key_rx_seq()
1800 new_key_id = status->gtk[0].flags & in iwl_mvm_set_key_rx_seq()
1804 if (new_key_id != key->keyidx) in iwl_mvm_set_key_rx_seq()
1810 if (status->gtk_seq[i].key_id == -1 && in iwl_mvm_set_key_rx_seq()
1811 (!status->num_of_gtk_rekeys || installed)) in iwl_mvm_set_key_rx_seq()
1831 int link_id = vif->active_links ? __ffs(vif->active_links) : -1; in iwl_mvm_d3_find_last_keys()
1833 if (link_id >= 0 && key->link_id >= 0 && link_id != key->link_id) in iwl_mvm_d3_find_last_keys()
1836 if (data->unhandled_cipher) in iwl_mvm_d3_find_last_keys()
1839 switch (key->cipher) { in iwl_mvm_d3_find_last_keys()
1849 data->gtk_cipher = key->cipher; in iwl_mvm_d3_find_last_keys()
1856 if (data->igtk_support && in iwl_mvm_d3_find_last_keys()
1857 (key->keyidx == 4 || key->keyidx == 5)) { in iwl_mvm_d3_find_last_keys()
1858 data->igtk_cipher = key->cipher; in iwl_mvm_d3_find_last_keys()
1859 } else if (data->bigtk_support && in iwl_mvm_d3_find_last_keys()
1860 (key->keyidx == 6 || key->keyidx == 7)) { in iwl_mvm_d3_find_last_keys()
1861 data->bigtk_cipher = key->cipher; in iwl_mvm_d3_find_last_keys()
1863 data->unhandled_cipher = true; in iwl_mvm_d3_find_last_keys()
1868 /* everything else - disconnect from AP */ in iwl_mvm_d3_find_last_keys()
1869 data->unhandled_cipher = true; in iwl_mvm_d3_find_last_keys()
1873 data->num_keys++; in iwl_mvm_d3_find_last_keys()
1883 BUILD_BUG_ON(sizeof(seq->aes_gmac.pn) != sizeof(key->ipn)); in iwl_mvm_d3_set_igtk_bigtk_ipn()
1884 memcpy(seq->aes_gmac.pn, key->ipn, sizeof(seq->aes_gmac.pn)); in iwl_mvm_d3_set_igtk_bigtk_ipn()
1888 BUILD_BUG_ON(sizeof(seq->aes_cmac.pn) != sizeof(key->ipn)); in iwl_mvm_d3_set_igtk_bigtk_ipn()
1889 memcpy(seq->aes_cmac.pn, key->ipn, sizeof(seq->aes_cmac.pn)); in iwl_mvm_d3_set_igtk_bigtk_ipn()
1901 if (status->num_of_gtk_rekeys && key_data->len) { in iwl_mvm_d3_update_igtk_bigtk()
1909 key->cipher); in iwl_mvm_d3_update_igtk_bigtk()
1921 struct iwl_wowlan_status_data *status = data->status; in iwl_mvm_d3_update_keys()
1923 int link_id = vif->active_links ? __ffs(vif->active_links) : -1; in iwl_mvm_d3_update_keys()
1925 if (link_id >= 0 && key->link_id >= 0 && link_id != key->link_id) in iwl_mvm_d3_update_keys()
1928 if (data->unhandled_cipher) in iwl_mvm_d3_update_keys()
1931 switch (key->cipher) { in iwl_mvm_d3_update_keys()
1940 atomic64_set(&key->tx_pn, status->ptk.aes.tx_pn); in iwl_mvm_d3_update_keys()
1941 iwl_mvm_set_aes_ptk_rx_seq(data->mvm, status, sta, key); in iwl_mvm_d3_update_keys()
1947 atomic64_set(&key->tx_pn, status->ptk.tkip.tx_pn); in iwl_mvm_d3_update_keys()
1948 iwl_mvm_set_key_rx_seq_tids(key, status->ptk.tkip.seq); in iwl_mvm_d3_update_keys()
1951 keyidx = key->keyidx; in iwl_mvm_d3_update_keys()
1957 if (status->num_of_gtk_rekeys && in iwl_mvm_d3_update_keys()
1958 ((status->gtk[0].len && keyidx == status->gtk[0].id) || in iwl_mvm_d3_update_keys()
1959 (status->gtk[1].len && keyidx == status->gtk[1].id))) { in iwl_mvm_d3_update_keys()
1962 iwl_mvm_set_key_rx_seq(key, data->status, false); in iwl_mvm_d3_update_keys()
1969 if (key->keyidx == 4 || key->keyidx == 5) { in iwl_mvm_d3_update_keys()
1971 &status->igtk); in iwl_mvm_d3_update_keys()
1973 if (key->keyidx == 6 || key->keyidx == 7) { in iwl_mvm_d3_update_keys()
1974 u8 idx = key->keyidx == status->bigtk[1].id; in iwl_mvm_d3_update_keys()
1977 &status->bigtk[idx]); in iwl_mvm_d3_update_keys()
1996 if (key->link_id < 0) in iwl_mvm_mlo_key_ciphers()
1999 if (WARN_ON(key->link_id >= IEEE80211_MLD_MAX_NUM_LINKS || in iwl_mvm_mlo_key_ciphers()
2000 key->keyidx >= 8)) in iwl_mvm_mlo_key_ciphers()
2003 if (WARN_ON(old_keys->key[key->link_id][key->keyidx])) in iwl_mvm_mlo_key_ciphers()
2006 switch (key->cipher) { in iwl_mvm_mlo_key_ciphers()
2016 if (key->keyidx == 4 || key->keyidx == 5) { in iwl_mvm_mlo_key_ciphers()
2019 } else if (key->keyidx == 6 || key->keyidx == 7) { in iwl_mvm_mlo_key_ciphers()
2029 old_keys->cipher[key->link_id][key_type] = key->cipher; in iwl_mvm_mlo_key_ciphers()
2030 old_keys->key[key->link_id][key->keyidx] = key; in iwl_mvm_mlo_key_ciphers()
2041 IWL_DEBUG_WOWLAN(mvm, "Num of MLO Keys: %d\n", status->num_mlo_keys); in iwl_mvm_mlo_gtk_rekey()
2042 if (!status->num_mlo_keys) in iwl_mvm_mlo_gtk_rekey()
2050 ieee80211_iter_keys(mvm->hw, vif, iwl_mvm_mlo_key_ciphers, old_keys); in iwl_mvm_mlo_gtk_rekey()
2052 for (i = 0; i < status->num_mlo_keys; i++) { in iwl_mvm_mlo_gtk_rekey()
2053 struct iwl_wowlan_mlo_gtk *mlo_key = &status->mlo_keys[i]; in iwl_mvm_mlo_gtk_rekey()
2060 u16 flags = le16_to_cpu(mlo_key->flags); in iwl_mvm_mlo_gtk_rekey()
2068 if (!(vif->valid_links & BIT(link_id))) in iwl_mvm_mlo_gtk_rekey()
2076 conf.conf.cipher = old_keys->cipher[link_id][key_type]; in iwl_mvm_mlo_gtk_rekey()
2108 memcpy(conf.conf.key, mlo_key->key, conf.conf.keylen); in iwl_mvm_mlo_gtk_rekey()
2111 old_key = old_keys->key[link_id][key_id]; in iwl_mvm_mlo_gtk_rekey()
2128 * mac80211 expects the pn in big-endian in iwl_mvm_mlo_gtk_rekey()
2133 for (j = 5; j >= 0; j--) in iwl_mvm_mlo_gtk_rekey()
2134 seq.ccmp.pn[5 - j] = mlo_key->pn[j]; in iwl_mvm_mlo_gtk_rekey()
2136 /* group keys are non-QoS and use TID 0 */ in iwl_mvm_mlo_gtk_rekey()
2157 int link_id = vif->active_links ? __ffs(vif->active_links) : -1; in iwl_mvm_gtk_rekey()
2163 BUILD_BUG_ON(sizeof(conf.key) < sizeof(status->gtk[0].key)); in iwl_mvm_gtk_rekey()
2180 for (i = 0; i < ARRAY_SIZE(status->gtk); i++) { in iwl_mvm_gtk_rekey()
2181 if (!status->gtk[i].len) in iwl_mvm_gtk_rekey()
2184 conf.conf.keyidx = status->gtk[i].id; in iwl_mvm_gtk_rekey()
2188 memcpy(conf.conf.key, status->gtk[i].key, in iwl_mvm_gtk_rekey()
2189 sizeof(status->gtk[i].key)); in iwl_mvm_gtk_rekey()
2195 for (j = 0; j < ARRAY_SIZE(status->gtk_seq); j++) { in iwl_mvm_gtk_rekey()
2196 if (!status->gtk_seq[j].valid || in iwl_mvm_gtk_rekey()
2197 status->gtk_seq[j].key_id != key->keyidx) in iwl_mvm_gtk_rekey()
2202 WARN_ON(j == ARRAY_SIZE(status->gtk_seq)); in iwl_mvm_gtk_rekey()
2219 .conf.keyidx = key_data->id, in iwl_mvm_d3_igtk_bigtk_rekey_add()
2222 int link_id = vif->active_links ? __ffs(vif->active_links) : -1; in iwl_mvm_d3_igtk_bigtk_rekey_add()
2224 if (!key_data->len) in iwl_mvm_d3_igtk_bigtk_rekey_add()
2245 BUILD_BUG_ON(sizeof(conf.key) < sizeof(key_data->key)); in iwl_mvm_d3_igtk_bigtk_rekey_add()
2246 memcpy(conf.conf.key, key_data->key, conf.conf.keylen); in iwl_mvm_d3_igtk_bigtk_rekey_add()
2253 if (key_config->keyidx == 4 || key_config->keyidx == 5) { in iwl_mvm_d3_igtk_bigtk_rekey_add()
2258 mvm_link = mvmvif->link[link_id]; in iwl_mvm_d3_igtk_bigtk_rekey_add()
2259 mvm_link->igtk = key_config; in iwl_mvm_d3_igtk_bigtk_rekey_add()
2269 if (!fw_has_api(&mvm->fw->ucode_capa, in iwl_mvm_lookup_wowlan_status_ver()
2274 notif_ver = iwl_fw_lookup_notif_ver(mvm->fw, LONG_GROUP, in iwl_mvm_lookup_wowlan_status_ver()
2277 notif_ver = iwl_fw_lookup_notif_ver(mvm->fw, LEGACY_GROUP, in iwl_mvm_lookup_wowlan_status_ver()
2297 if (!status || !vif->bss_conf.bssid) in iwl_mvm_setup_connection_keep()
2301 iwl_fw_lookup_notif_ver(mvm->fw, PROT_OFFLOAD_GROUP, in iwl_mvm_setup_connection_keep()
2306 if (iwl_fw_lookup_notif_ver(mvm->fw, PROT_OFFLOAD_GROUP, in iwl_mvm_setup_connection_keep()
2312 ieee80211_iter_keys(mvm->hw, vif, in iwl_mvm_setup_connection_keep()
2324 ieee80211_iter_keys(mvm->hw, vif, in iwl_mvm_setup_connection_keep()
2327 if (status->num_of_gtk_rekeys) { in iwl_mvm_setup_connection_keep()
2328 __be64 replay_ctr = cpu_to_be64(status->replay_ctr); in iwl_mvm_setup_connection_keep()
2330 IWL_DEBUG_WOWLAN(mvm, "num of GTK rekeying %d\n", in iwl_mvm_setup_connection_keep()
2331 status->num_of_gtk_rekeys); in iwl_mvm_setup_connection_keep()
2338 &status->igtk)) in iwl_mvm_setup_connection_keep()
2341 for (i = 0; i < ARRAY_SIZE(status->bigtk); i++) { in iwl_mvm_setup_connection_keep()
2344 &status->bigtk[i])) in iwl_mvm_setup_connection_keep()
2351 ieee80211_gtk_rekey_notify(vif, vif->bss_conf.bssid, in iwl_mvm_setup_connection_keep()
2356 if (iwl_fw_lookup_notif_ver(mvm->fw, LONG_GROUP, in iwl_mvm_setup_connection_keep()
2359 mvmvif->seqno_valid = true; in iwl_mvm_setup_connection_keep()
2360 /* +0x10 because the set API expects next-to-use, not last-used */ in iwl_mvm_setup_connection_keep()
2361 mvmvif->seqno = status->non_qos_seq_ctr + 0x10; in iwl_mvm_setup_connection_keep()
2364 if (status->wakeup_reasons & disconnection_reasons) in iwl_mvm_setup_connection_keep()
2373 BUILD_BUG_ON(sizeof(status->gtk[0].key) < sizeof(data->key)); in iwl_mvm_convert_gtk_v2()
2375 sizeof(data->tkip_mic_key) > in iwl_mvm_convert_gtk_v2()
2376 sizeof(status->gtk[0].key)); in iwl_mvm_convert_gtk_v2()
2378 status->gtk[0].len = data->key_len; in iwl_mvm_convert_gtk_v2()
2379 status->gtk[0].flags = data->key_flags; in iwl_mvm_convert_gtk_v2()
2381 memcpy(status->gtk[0].key, data->key, sizeof(data->key)); in iwl_mvm_convert_gtk_v2()
2384 if (status->gtk[0].len == NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY) in iwl_mvm_convert_gtk_v2()
2385 memcpy(status->gtk[0].key + NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY, in iwl_mvm_convert_gtk_v2()
2386 data->tkip_mic_key, sizeof(data->tkip_mic_key)); in iwl_mvm_convert_gtk_v2()
2394 BUILD_BUG_ON(sizeof(status->gtk[0].key) < sizeof(data[0].key)); in iwl_mvm_convert_gtk_v3()
2397 sizeof(status->gtk[0].key)); in iwl_mvm_convert_gtk_v3()
2398 BUILD_BUG_ON(ARRAY_SIZE(status->gtk) < WOWLAN_GTK_KEYS_NUM); in iwl_mvm_convert_gtk_v3()
2399 for (data_idx = 0; data_idx < ARRAY_SIZE(status->gtk); data_idx++) { in iwl_mvm_convert_gtk_v3()
2402 status->gtk[status_idx].len = data[data_idx].key_len; in iwl_mvm_convert_gtk_v3()
2403 status->gtk[status_idx].flags = data[data_idx].key_flags; in iwl_mvm_convert_gtk_v3()
2404 status->gtk[status_idx].id = status->gtk[status_idx].flags & in iwl_mvm_convert_gtk_v3()
2407 memcpy(status->gtk[status_idx].key, data[data_idx].key, in iwl_mvm_convert_gtk_v3()
2411 if (status->gtk[status_idx].len == in iwl_mvm_convert_gtk_v3()
2413 memcpy(status->gtk[status_idx].key + in iwl_mvm_convert_gtk_v3()
2426 BUILD_BUG_ON(sizeof(status->igtk.key) < sizeof(data->key)); in iwl_mvm_convert_igtk()
2427 BUILD_BUG_ON(sizeof(status->igtk.ipn) != sizeof(data->ipn)); in iwl_mvm_convert_igtk()
2429 if (!data->key_len) in iwl_mvm_convert_igtk()
2432 status->igtk.len = data->key_len; in iwl_mvm_convert_igtk()
2433 status->igtk.flags = data->key_flags; in iwl_mvm_convert_igtk()
2434 status->igtk.id = u32_get_bits(data->key_flags, in iwl_mvm_convert_igtk()
2438 memcpy(status->igtk.key, data->key, sizeof(data->key)); in iwl_mvm_convert_igtk()
2441 for (i = 0; i < sizeof(data->ipn); i++) in iwl_mvm_convert_igtk()
2442 status->igtk.ipn[i] = data->ipn[sizeof(data->ipn) - i - 1]; in iwl_mvm_convert_igtk()
2450 BUILD_BUG_ON(ARRAY_SIZE(status->bigtk) < WOWLAN_BIGTK_KEYS_NUM); in iwl_mvm_convert_bigtk()
2456 status->bigtk[status_idx].len = data[data_idx].key_len; in iwl_mvm_convert_bigtk()
2457 status->bigtk[status_idx].flags = data[data_idx].key_flags; in iwl_mvm_convert_bigtk()
2458 status->bigtk[status_idx].id = in iwl_mvm_convert_bigtk()
2463 BUILD_BUG_ON(sizeof(status->bigtk[status_idx].key) < in iwl_mvm_convert_bigtk()
2465 BUILD_BUG_ON(sizeof(status->bigtk[status_idx].ipn) < in iwl_mvm_convert_bigtk()
2468 memcpy(status->bigtk[status_idx].key, data[data_idx].key, in iwl_mvm_convert_bigtk()
2470 memcpy(status->bigtk[status_idx].ipn, data[data_idx].ipn, in iwl_mvm_convert_bigtk()
2491 expected_len += (data->num_mlo_link_keys * in iwl_mvm_parse_wowlan_info_notif()
2492 sizeof(status->mlo_keys[0])); in iwl_mvm_parse_wowlan_info_notif()
2500 if (mvm->fast_resume) in iwl_mvm_parse_wowlan_info_notif()
2503 iwl_mvm_convert_key_counters_v5(status, &data->gtk[0].sc); in iwl_mvm_parse_wowlan_info_notif()
2504 iwl_mvm_convert_gtk_v3(status, data->gtk); in iwl_mvm_parse_wowlan_info_notif()
2505 iwl_mvm_convert_igtk(status, &data->igtk[0]); in iwl_mvm_parse_wowlan_info_notif()
2506 iwl_mvm_convert_bigtk(status, data->bigtk); in iwl_mvm_parse_wowlan_info_notif()
2507 status->replay_ctr = le64_to_cpu(data->replay_ctr); in iwl_mvm_parse_wowlan_info_notif()
2508 status->pattern_number = le16_to_cpu(data->pattern_number); in iwl_mvm_parse_wowlan_info_notif()
2510 status->qos_seq_ctr[i] = in iwl_mvm_parse_wowlan_info_notif()
2511 le16_to_cpu(data->qos_seq_ctr[i]); in iwl_mvm_parse_wowlan_info_notif()
2512 status->wakeup_reasons = le32_to_cpu(data->wakeup_reasons); in iwl_mvm_parse_wowlan_info_notif()
2513 status->num_of_gtk_rekeys = in iwl_mvm_parse_wowlan_info_notif()
2514 le32_to_cpu(data->num_of_gtk_rekeys); in iwl_mvm_parse_wowlan_info_notif()
2515 status->received_beacons = le32_to_cpu(data->received_beacons); in iwl_mvm_parse_wowlan_info_notif()
2516 status->tid_tear_down = data->tid_tear_down; in iwl_mvm_parse_wowlan_info_notif()
2518 if (has_mlo_keys && data->num_mlo_link_keys) { in iwl_mvm_parse_wowlan_info_notif()
2519 status->num_mlo_keys = data->num_mlo_link_keys; in iwl_mvm_parse_wowlan_info_notif()
2521 status->num_mlo_keys > WOWLAN_MAX_MLO_KEYS, in iwl_mvm_parse_wowlan_info_notif()
2523 status->num_mlo_keys, WOWLAN_MAX_MLO_KEYS)) in iwl_mvm_parse_wowlan_info_notif()
2524 status->num_mlo_keys = WOWLAN_MAX_MLO_KEYS; in iwl_mvm_parse_wowlan_info_notif()
2525 memcpy(status->mlo_keys, data->mlo_gtks, in iwl_mvm_parse_wowlan_info_notif()
2526 status->num_mlo_keys * sizeof(status->mlo_keys[0])); in iwl_mvm_parse_wowlan_info_notif()
2550 iwl_mvm_convert_key_counters_v5(status, &data->gtk[0].sc); in iwl_mvm_parse_wowlan_info_notif_v2()
2551 iwl_mvm_convert_gtk_v3(status, data->gtk); in iwl_mvm_parse_wowlan_info_notif_v2()
2552 iwl_mvm_convert_igtk(status, &data->igtk[0]); in iwl_mvm_parse_wowlan_info_notif_v2()
2553 status->replay_ctr = le64_to_cpu(data->replay_ctr); in iwl_mvm_parse_wowlan_info_notif_v2()
2554 status->pattern_number = le16_to_cpu(data->pattern_number); in iwl_mvm_parse_wowlan_info_notif_v2()
2556 status->qos_seq_ctr[i] = in iwl_mvm_parse_wowlan_info_notif_v2()
2557 le16_to_cpu(data->qos_seq_ctr[i]); in iwl_mvm_parse_wowlan_info_notif_v2()
2558 status->wakeup_reasons = le32_to_cpu(data->wakeup_reasons); in iwl_mvm_parse_wowlan_info_notif_v2()
2559 status->num_of_gtk_rekeys = in iwl_mvm_parse_wowlan_info_notif_v2()
2560 le32_to_cpu(data->num_of_gtk_rekeys); in iwl_mvm_parse_wowlan_info_notif_v2()
2561 status->received_beacons = le32_to_cpu(data->received_beacons); in iwl_mvm_parse_wowlan_info_notif_v2()
2562 status->tid_tear_down = data->tid_tear_down; in iwl_mvm_parse_wowlan_info_notif_v2()
2580 data_size = ALIGN(le32_to_cpu(data->wake_packet_bufsize), 4); \
2591 status->replay_ctr = le64_to_cpu(data->replay_ctr); \
2592 status->pattern_number = le16_to_cpu(data->pattern_number); \
2593 status->non_qos_seq_ctr = le16_to_cpu(data->non_qos_seq_ctr); \
2595 status->qos_seq_ctr[i] = \
2596 le16_to_cpu(data->qos_seq_ctr[i]); \
2597 status->wakeup_reasons = le32_to_cpu(data->wakeup_reasons); \
2598 status->num_of_gtk_rekeys = \
2599 le32_to_cpu(data->num_of_gtk_rekeys); \
2600 status->received_beacons = le32_to_cpu(data->received_beacons); \
2601 status->wake_packet_length = \
2602 le32_to_cpu(data->wake_packet_length); \
2603 status->wake_packet_bufsize = \
2604 le32_to_cpu(data->wake_packet_bufsize); \
2605 if (status->wake_packet_bufsize) { \
2606 status->wake_packet = \
2607 kmemdup(data->wake_packet, \
2608 status->wake_packet_bufsize, \
2610 if (!status->wake_packet) { \
2615 status->wake_packet = NULL; \
2641 u8 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw, cmd.id, in iwl_mvm_parse_wowlan_status_common()
2647 lockdep_assert_held(&mvm->mutex); in iwl_mvm_parse_wowlan_status_common()
2661 struct iwl_wowlan_status_v6 *v6 = (void *)cmd.resp_pkt->data; in iwl_mvm_parse_wowlan_status_common()
2667 BUILD_BUG_ON(sizeof(v6->gtk.decrypt_key) > in iwl_mvm_parse_wowlan_status_common()
2668 sizeof(status->gtk[0].key)); in iwl_mvm_parse_wowlan_status_common()
2670 sizeof(v6->gtk.tkip_mic_key) > in iwl_mvm_parse_wowlan_status_common()
2671 sizeof(status->gtk[0].key)); in iwl_mvm_parse_wowlan_status_common()
2674 memcpy(status->gtk[0].key, v6->gtk.decrypt_key, in iwl_mvm_parse_wowlan_status_common()
2675 sizeof(v6->gtk.decrypt_key)); in iwl_mvm_parse_wowlan_status_common()
2676 memcpy(status->gtk[0].key + NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY, in iwl_mvm_parse_wowlan_status_common()
2677 v6->gtk.tkip_mic_key, in iwl_mvm_parse_wowlan_status_common()
2678 sizeof(v6->gtk.tkip_mic_key)); in iwl_mvm_parse_wowlan_status_common()
2680 iwl_mvm_convert_key_counters(status, &v6->gtk.rsc.all_tsc_rsc); in iwl_mvm_parse_wowlan_status_common()
2683 status->gtk[0].len = 16; in iwl_mvm_parse_wowlan_status_common()
2690 status->gtk[0].flags = v6->gtk.key_index | BIT(7); in iwl_mvm_parse_wowlan_status_common()
2692 struct iwl_wowlan_status_v7 *v7 = (void *)cmd.resp_pkt->data; in iwl_mvm_parse_wowlan_status_common()
2698 iwl_mvm_convert_key_counters(status, &v7->gtk[0].rsc.all_tsc_rsc); in iwl_mvm_parse_wowlan_status_common()
2699 iwl_mvm_convert_gtk_v2(status, &v7->gtk[0]); in iwl_mvm_parse_wowlan_status_common()
2700 iwl_mvm_convert_igtk(status, &v7->igtk[0]); in iwl_mvm_parse_wowlan_status_common()
2702 struct iwl_wowlan_status_v9 *v9 = (void *)cmd.resp_pkt->data; in iwl_mvm_parse_wowlan_status_common()
2711 iwl_mvm_convert_key_counters(status, &v9->gtk[0].rsc.all_tsc_rsc); in iwl_mvm_parse_wowlan_status_common()
2712 iwl_mvm_convert_gtk_v2(status, &v9->gtk[0]); in iwl_mvm_parse_wowlan_status_common()
2713 iwl_mvm_convert_igtk(status, &v9->igtk[0]); in iwl_mvm_parse_wowlan_status_common()
2715 status->tid_tear_down = v9->tid_tear_down; in iwl_mvm_parse_wowlan_status_common()
2717 struct iwl_wowlan_status_v12 *v12 = (void *)cmd.resp_pkt->data; in iwl_mvm_parse_wowlan_status_common()
2723 iwl_mvm_convert_key_counters_v5(status, &v12->gtk[0].sc); in iwl_mvm_parse_wowlan_status_common()
2724 iwl_mvm_convert_gtk_v3(status, v12->gtk); in iwl_mvm_parse_wowlan_status_common()
2725 iwl_mvm_convert_igtk(status, &v12->igtk[0]); in iwl_mvm_parse_wowlan_status_common()
2727 status->tid_tear_down = v12->tid_tear_down; in iwl_mvm_parse_wowlan_status_common()
2749 int link_id = vif->active_links ? __ffs(vif->active_links) : 0; in iwl_mvm_query_wakeup_reasons()
2750 struct iwl_mvm_vif_link_info *mvm_link = mvmvif->link[link_id]; in iwl_mvm_query_wakeup_reasons()
2759 status->wakeup_reasons); in iwl_mvm_query_wakeup_reasons()
2761 mvm_ap_sta = iwl_mvm_sta_from_staid_protected(mvm, mvm_link->ap_sta_id); in iwl_mvm_query_wakeup_reasons()
2766 u16 seq = status->qos_seq_ctr[i]; in iwl_mvm_query_wakeup_reasons()
2767 /* firmware stores last-used value, we store next value */ in iwl_mvm_query_wakeup_reasons()
2769 mvm_ap_sta->tid_data[i].seq_number = seq; in iwl_mvm_query_wakeup_reasons()
2772 if (mvm->trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_22000) { in iwl_mvm_query_wakeup_reasons()
2773 i = mvm->offload_tid; in iwl_mvm_query_wakeup_reasons()
2774 iwl_trans_set_q_ptrs(mvm->trans, in iwl_mvm_query_wakeup_reasons()
2775 mvm_ap_sta->tid_data[i].txq_id, in iwl_mvm_query_wakeup_reasons()
2776 mvm_ap_sta->tid_data[i].seq_number >> 4); in iwl_mvm_query_wakeup_reasons()
2783 mutex_unlock(&mvm->mutex); in iwl_mvm_query_wakeup_reasons()
2806 int max_profiles = iwl_umac_scan_get_max_profiles(mvm->fw); in iwl_mvm_netdetect_query_results()
2814 if (fw_has_api(&mvm->fw->ucode_capa, in iwl_mvm_netdetect_query_results()
2828 ret = -EIO; in iwl_mvm_netdetect_query_results()
2832 query = (void *)cmd.resp_pkt->data; in iwl_mvm_netdetect_query_results()
2834 results->matched_profiles = le32_to_cpu(query->matched_profiles); in iwl_mvm_netdetect_query_results()
2835 memcpy(results->matches, query->matches, matches_len); in iwl_mvm_netdetect_query_results()
2838 mvm->last_netdetect_scans = le32_to_cpu(query->n_scans_done); in iwl_mvm_netdetect_query_results()
2852 if (fw_has_api(&mvm->fw->ucode_capa, in iwl_mvm_query_num_match_chans()
2855 (void *)results->matches; in iwl_mvm_query_num_match_chans()
2861 (void *)results->matches; in iwl_mvm_query_num_match_chans()
2877 if (fw_has_api(&mvm->fw->ucode_capa, in iwl_mvm_query_set_freqs()
2880 (void *)results->matches; in iwl_mvm_query_set_freqs()
2884 match->channels[match->n_channels++] = in iwl_mvm_query_set_freqs()
2885 mvm->nd_channels[i]->center_freq; in iwl_mvm_query_set_freqs()
2888 (void *)results->matches; in iwl_mvm_query_set_freqs()
2892 match->channels[match->n_channels++] = in iwl_mvm_query_set_freqs()
2893 mvm->nd_channels[i]->center_freq; in iwl_mvm_query_set_freqs()
2898 * enum iwl_d3_notif - d3 notifications
2918 u32 notif_expected; /* bitmap - see &enum iwl_d3_notif */
2919 u32 notif_received; /* bitmap - see &enum iwl_d3_notif */
2930 .pattern_idx = -1, in iwl_mvm_query_netdetect_reasons()
2937 if (WARN_ON(!d3_data || !d3_data->status)) in iwl_mvm_query_netdetect_reasons()
2940 reasons = d3_data->status->wakeup_reasons; in iwl_mvm_query_netdetect_reasons()
2948 if (!iwl_fw_lookup_notif_ver(mvm->fw, PROT_OFFLOAD_GROUP, in iwl_mvm_query_netdetect_reasons()
2951 ret = iwl_mvm_netdetect_query_results(mvm, d3_data->nd_results); in iwl_mvm_query_netdetect_reasons()
2955 ret = d3_data->nd_results_valid ? 0 : -1; in iwl_mvm_query_netdetect_reasons()
2958 if (ret || !d3_data->nd_results->matched_profiles) { in iwl_mvm_query_netdetect_reasons()
2963 matched_profiles = d3_data->nd_results->matched_profiles; in iwl_mvm_query_netdetect_reasons()
2964 if (mvm->n_nd_match_sets) { in iwl_mvm_query_netdetect_reasons()
2976 for_each_set_bit(i, &matched_profiles, mvm->n_nd_match_sets) { in iwl_mvm_query_netdetect_reasons()
2981 d3_data->nd_results, in iwl_mvm_query_netdetect_reasons()
2989 net_detect->matches[net_detect->n_matches++] = match; in iwl_mvm_query_netdetect_reasons()
2994 idx = mvm->n_nd_match_sets - i - 1; in iwl_mvm_query_netdetect_reasons()
2995 match->ssid.ssid_len = mvm->nd_match_sets[idx].ssid.ssid_len; in iwl_mvm_query_netdetect_reasons()
2996 memcpy(match->ssid.ssid, mvm->nd_match_sets[idx].ssid.ssid, in iwl_mvm_query_netdetect_reasons()
2997 match->ssid.ssid_len); in iwl_mvm_query_netdetect_reasons()
2999 if (mvm->n_nd_channels < n_channels) in iwl_mvm_query_netdetect_reasons()
3002 iwl_mvm_query_set_freqs(mvm, d3_data->nd_results, match, i); in iwl_mvm_query_netdetect_reasons()
3010 mutex_unlock(&mvm->mutex); in iwl_mvm_query_netdetect_reasons()
3014 for (i = 0; i < net_detect->n_matches; i++) in iwl_mvm_query_netdetect_reasons()
3015 kfree(net_detect->matches[i]); in iwl_mvm_query_netdetect_reasons()
3027 if (vif->type == NL80211_IFTYPE_STATION) in iwl_mvm_d3_disconnect_iter()
3056 if (iwl_mvm_rt_status(mvm->trans, in iwl_mvm_check_rt_status()
3057 mvm->trans->dbg.lmac_error_event_table[0], in iwl_mvm_check_rt_status()
3070 if (iwl_mvm_rt_status(mvm->trans, in iwl_mvm_check_rt_status()
3071 mvm->trans->dbg.lmac_error_event_table[1], NULL)) in iwl_mvm_check_rt_status()
3075 if (iwl_mvm_rt_status(mvm->trans, in iwl_mvm_check_rt_status()
3076 mvm->trans->dbg.umac_error_event_table, NULL)) in iwl_mvm_check_rt_status()
3092 lockdep_assert_held(&mvm->mutex); in iwl_mvm_choose_query_wakeup_reasons()
3095 if (!d3_data->status) { in iwl_mvm_choose_query_wakeup_reasons()
3097 u8 sta_id = mvm->net_detect ? IWL_MVM_INVALID_STA : in iwl_mvm_choose_query_wakeup_reasons()
3098 mvmvif->deflink.ap_sta_id; in iwl_mvm_choose_query_wakeup_reasons()
3100 /* bug - FW with MLO has status notification */ in iwl_mvm_choose_query_wakeup_reasons()
3103 d3_data->status = iwl_mvm_send_wowlan_get_status(mvm, sta_id); in iwl_mvm_choose_query_wakeup_reasons()
3106 if (mvm->net_detect) { in iwl_mvm_choose_query_wakeup_reasons()
3110 d3_data->status); in iwl_mvm_choose_query_wakeup_reasons()
3114 mvm->keep_vif = vif; in iwl_mvm_choose_query_wakeup_reasons()
3134 u32 data_size, packet_len = le32_to_cpu(notif->wake_packet_length); in iwl_mvm_wowlan_store_wake_pkt()
3138 return -EIO; in iwl_mvm_wowlan_store_wake_pkt()
3143 return -EIO; in iwl_mvm_wowlan_store_wake_pkt()
3146 if (WARN_ON(!(status->wakeup_reasons & in iwl_mvm_wowlan_store_wake_pkt()
3149 status->wakeup_reasons); in iwl_mvm_wowlan_store_wake_pkt()
3150 return -EIO; in iwl_mvm_wowlan_store_wake_pkt()
3153 data_size = len - offsetof(struct iwl_wowlan_wake_pkt_notif, wake_packet); in iwl_mvm_wowlan_store_wake_pkt()
3159 status->wake_packet = kmemdup(notif->wake_packet, data_size, in iwl_mvm_wowlan_store_wake_pkt()
3162 if (!status->wake_packet) in iwl_mvm_wowlan_store_wake_pkt()
3163 return -ENOMEM; in iwl_mvm_wowlan_store_wake_pkt()
3165 status->wake_packet_length = packet_len; in iwl_mvm_wowlan_store_wake_pkt()
3166 status->wake_packet_bufsize = data_size; in iwl_mvm_wowlan_store_wake_pkt()
3176 struct iwl_wowlan_status_data *status = d3_data->status; in iwl_mvm_nd_match_info_handler()
3178 struct iwl_mvm_nd_results *results = d3_data->nd_results; in iwl_mvm_nd_match_info_handler()
3180 iwl_umac_scan_get_max_profiles(mvm->fw); in iwl_mvm_nd_match_info_handler()
3190 if (!mvm->net_detect) { in iwl_mvm_nd_match_info_handler()
3195 if (!status || status->wakeup_reasons != IWL_WOWLAN_WAKEUP_BY_NON_WIRELESS) { in iwl_mvm_nd_match_info_handler()
3202 mvm->last_netdetect_scans = le32_to_cpu(notif->n_scans_done); in iwl_mvm_nd_match_info_handler()
3205 results->matched_profiles = le32_to_cpu(notif->matched_profiles); in iwl_mvm_nd_match_info_handler()
3207 results->matched_profiles); in iwl_mvm_nd_match_info_handler()
3209 if (results->matched_profiles) { in iwl_mvm_nd_match_info_handler()
3210 memcpy(results->matches, notif->matches, matches_len); in iwl_mvm_nd_match_info_handler()
3211 d3_data->nd_results_valid = true; in iwl_mvm_nd_match_info_handler()
3215 mvm->scan_status = 0; in iwl_mvm_nd_match_info_handler()
3216 for (i = 0; i < mvm->max_scans; i++) in iwl_mvm_nd_match_info_handler()
3217 mvm->scan_uid_status[i] = 0; in iwl_mvm_nd_match_info_handler()
3228 int wowlan_info_ver = iwl_fw_lookup_notif_ver(mvm->fw, in iwl_mvm_wait_d3_notif()
3234 switch (WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd)) { in iwl_mvm_wait_d3_notif()
3237 if (d3_data->notif_received & IWL_D3_NOTIF_WOWLAN_INFO) { in iwl_mvm_wait_d3_notif()
3246 (void *)pkt->data; in iwl_mvm_wait_d3_notif()
3254 notif_v2->tid_tear_down = notif_v1->tid_tear_down; in iwl_mvm_wait_d3_notif()
3255 notif_v2->station_id = notif_v1->station_id; in iwl_mvm_wait_d3_notif()
3258 d3_data->status, in iwl_mvm_wait_d3_notif()
3264 (void *)pkt->data; in iwl_mvm_wait_d3_notif()
3267 d3_data->status, in iwl_mvm_wait_d3_notif()
3271 (void *)pkt->data; in iwl_mvm_wait_d3_notif()
3274 d3_data->status, len, in iwl_mvm_wait_d3_notif()
3278 d3_data->notif_received |= IWL_D3_NOTIF_WOWLAN_INFO; in iwl_mvm_wait_d3_notif()
3280 if (d3_data->status && in iwl_mvm_wait_d3_notif()
3281 d3_data->status->wakeup_reasons & IWL_WOWLAN_WAKEUP_REASON_HAS_WAKEUP_PKT) in iwl_mvm_wait_d3_notif()
3283 d3_data->notif_expected |= IWL_D3_NOTIF_WOWLAN_WAKE_PKT; in iwl_mvm_wait_d3_notif()
3288 struct iwl_wowlan_wake_pkt_notif *notif = (void *)pkt->data; in iwl_mvm_wait_d3_notif()
3290 if (d3_data->notif_received & IWL_D3_NOTIF_WOWLAN_WAKE_PKT) { in iwl_mvm_wait_d3_notif()
3295 d3_data->notif_received |= IWL_D3_NOTIF_WOWLAN_WAKE_PKT; in iwl_mvm_wait_d3_notif()
3298 d3_data->status, in iwl_mvm_wait_d3_notif()
3308 struct iwl_scan_offload_match_info *notif = (void *)pkt->data; in iwl_mvm_wait_d3_notif()
3310 if (d3_data->notif_received & IWL_D3_ND_MATCH_INFO) { in iwl_mvm_wait_d3_notif()
3316 d3_data->notif_received |= IWL_D3_ND_MATCH_INFO; in iwl_mvm_wait_d3_notif()
3319 d3_data->notif_expected |= IWL_D3_ND_MATCH_INFO; in iwl_mvm_wait_d3_notif()
3326 struct iwl_mvm_d3_end_notif *notif = (void *)pkt->data; in iwl_mvm_wait_d3_notif()
3328 d3_data->d3_end_flags = __le32_to_cpu(notif->flags); in iwl_mvm_wait_d3_notif()
3329 d3_data->notif_received |= IWL_D3_NOTIF_D3_END_NOTIF; in iwl_mvm_wait_d3_notif()
3337 return d3_data->notif_received == d3_data->notif_expected; in iwl_mvm_wait_d3_notif()
3348 bool reset = fw_has_capa(&mvm->fw->ucode_capa, in iwl_mvm_resume_firmware()
3351 ret = iwl_trans_d3_resume(mvm->trans, &d3_status, test, !reset); in iwl_mvm_resume_firmware()
3357 return -ENOENT; in iwl_mvm_resume_firmware()
3365 if (mvm->trans->trans_cfg->device_family <= IWL_DEVICE_FAMILY_22000 && in iwl_mvm_resume_firmware()
3366 fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_D0I3_END_FIRST)) { in iwl_mvm_resume_firmware()
3393 if (mvm->fast_resume) in iwl_mvm_d3_notif_wait()
3394 iwl_init_notification_wait(&mvm->notif_wait, &wait_d3_notif, in iwl_mvm_d3_notif_wait()
3399 iwl_init_notification_wait(&mvm->notif_wait, &wait_d3_notif, in iwl_mvm_d3_notif_wait()
3404 ret = iwl_mvm_resume_firmware(mvm, d3_data->test); in iwl_mvm_d3_notif_wait()
3406 iwl_remove_notification(&mvm->notif_wait, &wait_d3_notif); in iwl_mvm_d3_notif_wait()
3410 return iwl_wait_notification(&mvm->notif_wait, &wait_d3_notif, in iwl_mvm_d3_notif_wait()
3416 return iwl_fw_lookup_notif_ver(mvm->fw, PROT_OFFLOAD_GROUP, in iwl_mvm_d3_resume_notif_based()
3418 iwl_fw_lookup_notif_ver(mvm->fw, PROT_OFFLOAD_GROUP, in iwl_mvm_d3_resume_notif_based()
3420 iwl_fw_lookup_notif_ver(mvm->fw, PROT_OFFLOAD_GROUP, in iwl_mvm_d3_resume_notif_based()
3437 bool unified_image = fw_has_capa(&mvm->fw->ucode_capa, in __iwl_mvm_resume()
3439 bool d0i3_first = fw_has_capa(&mvm->fw->ucode_capa, in __iwl_mvm_resume()
3444 mutex_lock(&mvm->mutex); in __iwl_mvm_resume()
3450 if (!test_bit(IWL_MVM_STATUS_IN_D3, &mvm->status)) { in __iwl_mvm_resume()
3456 mvm->last_reset_or_resume_time_jiffies = jiffies; in __iwl_mvm_resume()
3463 iwl_fw_dbg_read_d3_debug_data(&mvm->fwrt); in __iwl_mvm_resume()
3466 set_bit(STATUS_FW_ERROR, &mvm->trans->status); in __iwl_mvm_resume()
3468 iwl_dbg_tlv_time_point(&mvm->fwrt, in __iwl_mvm_resume()
3470 iwl_fw_dbg_collect_desc(&mvm->fwrt, &iwl_dump_desc_assert, in __iwl_mvm_resume()
3480 ret = -ENOMEM; in __iwl_mvm_resume()
3496 mvm->trans->system_pm_mode = IWL_PLAT_PM_MODE_DISABLED; in __iwl_mvm_resume()
3504 * can play it back when we re-intiailize the D0 firmware in __iwl_mvm_resume()
3508 /* Re-configure PPAG settings */ in __iwl_mvm_resume()
3512 /* Re-configure default SAR profile */ in __iwl_mvm_resume()
3515 if (mvm->net_detect && unified_image) { in __iwl_mvm_resume()
3516 /* If this is a non-unified image, we restart the FW, in __iwl_mvm_resume()
3518 * fails, continue and try to get the wake-up reasons, in __iwl_mvm_resume()
3532 mutex_unlock(&mvm->mutex); in __iwl_mvm_resume()
3535 kfree(d3_data.status->wake_packet); in __iwl_mvm_resume()
3539 if (!d3_data.test && !mvm->net_detect) in __iwl_mvm_resume()
3540 ieee80211_iterate_active_interfaces_mtx(mvm->hw, in __iwl_mvm_resume()
3545 clear_bit(IWL_MVM_STATUS_IN_D3, &mvm->status); in __iwl_mvm_resume()
3553 if (!iwl_fw_lookup_notif_ver(mvm->fw, PROT_OFFLOAD_GROUP, in __iwl_mvm_resume()
3568 set_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, &mvm->status); in __iwl_mvm_resume()
3571 mvm->trans->system_pm_mode = IWL_PLAT_PM_MODE_DISABLED; in __iwl_mvm_resume()
3585 iwl_fw_runtime_resume(&mvm->fwrt); in iwl_mvm_resume()
3594 device_set_wakeup_enable(mvm->trans->dev, enabled); in iwl_mvm_set_wakeup()
3602 lockdep_assert_held(&mvm->mutex); in iwl_mvm_fast_suspend()
3606 mvm->fast_resume = true; in iwl_mvm_fast_suspend()
3607 set_bit(IWL_MVM_STATUS_IN_D3, &mvm->status); in iwl_mvm_fast_suspend()
3610 mvm->trans->system_pm_mode = IWL_PLAT_PM_MODE_D3; in iwl_mvm_fast_suspend()
3619 ret = iwl_trans_d3_suspend(mvm->trans, false, false); in iwl_mvm_fast_suspend()
3632 lockdep_assert_held(&mvm->mutex); in iwl_mvm_fast_resume()
3636 mvm->last_reset_or_resume_time_jiffies = jiffies; in iwl_mvm_fast_resume()
3637 iwl_fw_dbg_read_d3_debug_data(&mvm->fwrt); in iwl_mvm_fast_resume()
3640 set_bit(STATUS_FW_ERROR, &mvm->trans->status); in iwl_mvm_fast_resume()
3642 iwl_dbg_tlv_time_point(&mvm->fwrt, in iwl_mvm_fast_resume()
3644 iwl_fw_dbg_collect_desc(&mvm->fwrt, &iwl_dump_desc_assert, in iwl_mvm_fast_resume()
3646 return -ENODEV; in iwl_mvm_fast_resume()
3649 clear_bit(IWL_MVM_STATUS_IN_D3, &mvm->status); in iwl_mvm_fast_resume()
3650 mvm->trans->system_pm_mode = IWL_PLAT_PM_MODE_DISABLED; in iwl_mvm_fast_resume()
3651 mvm->fast_resume = false; in iwl_mvm_fast_resume()
3662 struct iwl_mvm *mvm = inode->i_private; in iwl_mvm_d3_test_open()
3665 if (mvm->d3_test_active) in iwl_mvm_d3_test_open()
3666 return -EBUSY; in iwl_mvm_d3_test_open()
3668 file->private_data = inode->i_private; in iwl_mvm_d3_test_open()
3672 iwl_fw_runtime_suspend(&mvm->fwrt); in iwl_mvm_d3_test_open()
3676 wiphy_lock(mvm->hw->wiphy); in iwl_mvm_d3_test_open()
3677 err = __iwl_mvm_suspend(mvm->hw, mvm->hw->wiphy->wowlan_config, true); in iwl_mvm_d3_test_open()
3678 wiphy_unlock(mvm->hw->wiphy); in iwl_mvm_d3_test_open()
3681 err = -EINVAL; in iwl_mvm_d3_test_open()
3685 mvm->d3_test_active = true; in iwl_mvm_d3_test_open()
3686 mvm->keep_vif = NULL; in iwl_mvm_d3_test_open()
3693 struct iwl_mvm *mvm = file->private_data; in iwl_mvm_d3_test_read()
3699 if (mvm->d3_test_pme_ptr) { in iwl_mvm_d3_test_read()
3700 pme_asserted = iwl_trans_read_mem32(mvm->trans, in iwl_mvm_d3_test_read()
3701 mvm->d3_test_pme_ptr); in iwl_mvm_d3_test_read()
3715 "ending pseudo-D3 with timeout after ~60 seconds\n"); in iwl_mvm_d3_test_read()
3716 return -ETIMEDOUT; in iwl_mvm_d3_test_read()
3730 if (vif->type == NL80211_IFTYPE_STATION) in iwl_mvm_d3_test_disconn_work_iter()
3736 struct iwl_mvm *mvm = inode->i_private; in iwl_mvm_d3_test_release()
3737 bool unified_image = fw_has_capa(&mvm->fw->ucode_capa, in iwl_mvm_d3_test_release()
3740 mvm->d3_test_active = false; in iwl_mvm_d3_test_release()
3742 iwl_fw_dbg_read_d3_debug_data(&mvm->fwrt); in iwl_mvm_d3_test_release()
3745 wiphy_lock(mvm->hw->wiphy); in iwl_mvm_d3_test_release()
3747 wiphy_unlock(mvm->hw->wiphy); in iwl_mvm_d3_test_release()
3752 iwl_fw_runtime_resume(&mvm->fwrt); in iwl_mvm_d3_test_release()
3754 iwl_abort_notification_waits(&mvm->notif_wait); in iwl_mvm_d3_test_release()
3758 ieee80211_restart_hw(mvm->hw); in iwl_mvm_d3_test_release()
3761 while (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) && in iwl_mvm_d3_test_release()
3763 remaining_time--; in iwl_mvm_d3_test_release()
3776 mvm->hw, IEEE80211_IFACE_ITER_NORMAL, in iwl_mvm_d3_test_release()
3777 iwl_mvm_d3_test_disconn_work_iter, mvm->keep_vif); in iwl_mvm_d3_test_release()