Lines Matching +full:umac +full:- +full:reset

1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
3 * Copyright (C) 2012-2014, 2018-2025 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()
128 struct iwl_mvm_wep_key *wep_key = wkc->wep_key; in iwl_mvm_wowlan_program_keys()
130 wkc->mac_id_n_color = in iwl_mvm_wowlan_program_keys()
131 cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, in iwl_mvm_wowlan_program_keys()
132 mvmvif->color)); in iwl_mvm_wowlan_program_keys()
133 wkc->num_keys = 1; in iwl_mvm_wowlan_program_keys()
135 wkc->decryption_type = STA_KEY_FLG_WEP; in iwl_mvm_wowlan_program_keys()
136 wep_key->key_index = key->keyidx; in iwl_mvm_wowlan_program_keys()
137 wep_key->key_size = key->keylen; in iwl_mvm_wowlan_program_keys()
140 * This will fail -- the key functions don't set support in iwl_mvm_wowlan_program_keys()
144 if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) in iwl_mvm_wowlan_program_keys()
147 memcpy(&wep_key->key[3], key->key, key->keylen); in iwl_mvm_wowlan_program_keys()
148 if (key->keyidx == mvmvif->tx_key_idx) { in iwl_mvm_wowlan_program_keys()
150 wep_key->key_offset = 0; in iwl_mvm_wowlan_program_keys()
153 data->wep_key_idx++; in iwl_mvm_wowlan_program_keys()
154 wep_key->key_offset = data->wep_key_idx; in iwl_mvm_wowlan_program_keys()
157 mutex_lock(&mvm->mutex); in iwl_mvm_wowlan_program_keys()
160 data->error = ret != 0; in iwl_mvm_wowlan_program_keys()
162 mvm->ptk_ivlen = key->iv_len; in iwl_mvm_wowlan_program_keys()
163 mvm->ptk_icvlen = key->icv_len; in iwl_mvm_wowlan_program_keys()
164 mvm->gtk_ivlen = key->iv_len; in iwl_mvm_wowlan_program_keys()
165 mvm->gtk_icvlen = key->icv_len; in iwl_mvm_wowlan_program_keys()
166 mutex_unlock(&mvm->mutex); in iwl_mvm_wowlan_program_keys()
172 data->error = true; in iwl_mvm_wowlan_program_keys()
179 * Ignore CMAC keys -- the WoWLAN firmware doesn't support them in iwl_mvm_wowlan_program_keys()
193 mutex_lock(&mvm->mutex); in iwl_mvm_wowlan_program_keys()
198 if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) { in iwl_mvm_wowlan_program_keys()
199 mvm->ptk_ivlen = key->iv_len; in iwl_mvm_wowlan_program_keys()
200 mvm->ptk_icvlen = key->icv_len; in iwl_mvm_wowlan_program_keys()
206 * with new ones -- this relies on mac80211 doing in iwl_mvm_wowlan_program_keys()
209 mvm->gtk_ivlen = key->iv_len; in iwl_mvm_wowlan_program_keys()
210 mvm->gtk_icvlen = key->icv_len; in iwl_mvm_wowlan_program_keys()
213 mutex_unlock(&mvm->mutex); in iwl_mvm_wowlan_program_keys()
214 data->error = ret != 0; in iwl_mvm_wowlan_program_keys()
235 switch (key->cipher) { in iwl_mvm_wowlan_get_rsc_tsc_data()
243 data->rsc_tsc->all_tsc_rsc.tkip.unicast_rsc; in iwl_mvm_wowlan_get_rsc_tsc_data()
245 &data->rsc_tsc->all_tsc_rsc.tkip.tsc; in iwl_mvm_wowlan_get_rsc_tsc_data()
247 pn64 = atomic64_read(&key->tx_pn); in iwl_mvm_wowlan_get_rsc_tsc_data()
248 tkip_tx_sc->iv16 = cpu_to_le16(TKIP_PN_TO_IV16(pn64)); in iwl_mvm_wowlan_get_rsc_tsc_data()
249 tkip_tx_sc->iv32 = cpu_to_le32(TKIP_PN_TO_IV32(pn64)); in iwl_mvm_wowlan_get_rsc_tsc_data()
252 data->rsc_tsc->all_tsc_rsc.tkip.multicast_rsc; in iwl_mvm_wowlan_get_rsc_tsc_data()
256 * For non-QoS this relies on the fact that both the uCode and in iwl_mvm_wowlan_get_rsc_tsc_data()
266 data->have_rsc_tsc = true; in iwl_mvm_wowlan_get_rsc_tsc_data()
276 data->rsc_tsc->all_tsc_rsc.aes.unicast_rsc; in iwl_mvm_wowlan_get_rsc_tsc_data()
278 &data->rsc_tsc->all_tsc_rsc.aes.tsc; in iwl_mvm_wowlan_get_rsc_tsc_data()
280 pn64 = atomic64_read(&key->tx_pn); in iwl_mvm_wowlan_get_rsc_tsc_data()
281 aes_tx_sc->pn = cpu_to_le64(pn64); in iwl_mvm_wowlan_get_rsc_tsc_data()
284 data->rsc_tsc->all_tsc_rsc.aes.multicast_rsc; in iwl_mvm_wowlan_get_rsc_tsc_data()
288 * For non-QoS this relies on the fact that both the uCode and in iwl_mvm_wowlan_get_rsc_tsc_data()
298 ptk_pn = rcu_dereference(mvmsta->ptk_pn[key->keyidx]); in iwl_mvm_wowlan_get_rsc_tsc_data()
306 mvm->trans->info.num_rxqs); in iwl_mvm_wowlan_get_rsc_tsc_data()
329 data->have_rsc_tsc = true; in iwl_mvm_wowlan_get_rsc_tsc_data()
354 switch (key->cipher) { in iwl_mvm_wowlan_get_rsc_v5_data()
365 rsc = data->rsc->ucast_rsc; in iwl_mvm_wowlan_get_rsc_v5_data()
367 if (WARN_ON(data->gtks >= ARRAY_SIZE(data->gtk_ids))) in iwl_mvm_wowlan_get_rsc_v5_data()
369 data->gtk_ids[data->gtks] = key->keyidx; in iwl_mvm_wowlan_get_rsc_v5_data()
370 rsc = data->rsc->mcast_rsc[data->gtks % 2]; in iwl_mvm_wowlan_get_rsc_v5_data()
371 if (WARN_ON(key->keyidx >= in iwl_mvm_wowlan_get_rsc_v5_data()
372 ARRAY_SIZE(data->rsc->mcast_key_id_map))) in iwl_mvm_wowlan_get_rsc_v5_data()
374 data->rsc->mcast_key_id_map[key->keyidx] = data->gtks % 2; in iwl_mvm_wowlan_get_rsc_v5_data()
375 if (data->gtks >= 2) { in iwl_mvm_wowlan_get_rsc_v5_data()
376 int prev = data->gtks - 2; in iwl_mvm_wowlan_get_rsc_v5_data()
377 int prev_idx = data->gtk_ids[prev]; in iwl_mvm_wowlan_get_rsc_v5_data()
379 data->rsc->mcast_key_id_map[prev_idx] = in iwl_mvm_wowlan_get_rsc_v5_data()
382 data->gtks++; in iwl_mvm_wowlan_get_rsc_v5_data()
385 switch (key->cipher) { in iwl_mvm_wowlan_get_rsc_v5_data()
392 * For non-QoS this relies on the fact that both the uCode and in iwl_mvm_wowlan_get_rsc_v5_data()
403 data->have_rsc = true; in iwl_mvm_wowlan_get_rsc_v5_data()
409 * For non-QoS this relies on the fact that both the uCode and in iwl_mvm_wowlan_get_rsc_v5_data()
419 ptk_pn = rcu_dereference(mvmsta->ptk_pn[key->keyidx]); in iwl_mvm_wowlan_get_rsc_v5_data()
427 mvm->trans->info.num_rxqs); in iwl_mvm_wowlan_get_rsc_v5_data()
450 data->have_rsc = true; in iwl_mvm_wowlan_get_rsc_v5_data()
459 int ver = iwl_fw_lookup_cmd_ver(mvm->fw, WOWLAN_TSC_RSC_PARAM, in iwl_mvm_wowlan_config_rsc_tsc()
469 return -ENOMEM; in iwl_mvm_wowlan_config_rsc_tsc()
471 for (i = 0; i < ARRAY_SIZE(data.rsc->mcast_key_id_map); i++) in iwl_mvm_wowlan_config_rsc_tsc()
472 data.rsc->mcast_key_id_map[i] = in iwl_mvm_wowlan_config_rsc_tsc()
474 data.rsc->sta_id = cpu_to_le32(mvm_link->ap_sta_id); in iwl_mvm_wowlan_config_rsc_tsc()
476 ieee80211_iter_keys(mvm->hw, vif, in iwl_mvm_wowlan_config_rsc_tsc()
492 return -ENOMEM; in iwl_mvm_wowlan_config_rsc_tsc()
494 ieee80211_iter_keys(mvm->hw, vif, in iwl_mvm_wowlan_config_rsc_tsc()
533 switch (key->cipher) { in iwl_mvm_wowlan_get_tkip_data()
540 rx_p1ks = data->tkip.rx_uni; in iwl_mvm_wowlan_get_tkip_data()
542 pn64 = atomic64_read(&key->tx_pn); in iwl_mvm_wowlan_get_tkip_data()
546 iwl_mvm_convert_p1k(p1k, data->tkip.tx.p1k); in iwl_mvm_wowlan_get_tkip_data()
548 memcpy(data->tkip.mic_keys.tx, in iwl_mvm_wowlan_get_tkip_data()
549 &key->key[NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY], in iwl_mvm_wowlan_get_tkip_data()
552 rx_mic_key = data->tkip.mic_keys.rx_unicast; in iwl_mvm_wowlan_get_tkip_data()
554 rx_p1ks = data->tkip.rx_multi; in iwl_mvm_wowlan_get_tkip_data()
555 rx_mic_key = data->tkip.mic_keys.rx_mcast; in iwl_mvm_wowlan_get_tkip_data()
565 ieee80211_get_tkip_rx_p1k(key, vif->bss_conf.bssid, in iwl_mvm_wowlan_get_tkip_data()
568 ieee80211_get_tkip_rx_p1k(key, vif->bss_conf.bssid, in iwl_mvm_wowlan_get_tkip_data()
573 &key->key[NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY], in iwl_mvm_wowlan_get_tkip_data()
576 data->have_tkip_keys = true; in iwl_mvm_wowlan_get_tkip_data()
594 if (key->keyidx == 4 || key->keyidx == 5) in iwl_mvm_wowlan_gtk_type_iter()
595 cipher = &data->kek_kck_cmd->igtk_cipher; in iwl_mvm_wowlan_gtk_type_iter()
596 if (key->keyidx == 6 || key->keyidx == 7) in iwl_mvm_wowlan_gtk_type_iter()
597 cipher = &data->kek_kck_cmd->bigtk_cipher; in iwl_mvm_wowlan_gtk_type_iter()
599 switch (key->cipher) { in iwl_mvm_wowlan_gtk_type_iter()
604 data->kek_kck_cmd->gtk_cipher = in iwl_mvm_wowlan_gtk_type_iter()
619 data->kek_kck_cmd->gtk_cipher = in iwl_mvm_wowlan_gtk_type_iter()
625 data->kek_kck_cmd->gtk_cipher = in iwl_mvm_wowlan_gtk_type_iter()
641 if (!wowlan->n_patterns) in iwl_mvm_send_patterns_v1()
644 cmd.len[0] = struct_size(pattern_cmd, patterns, wowlan->n_patterns); in iwl_mvm_send_patterns_v1()
648 return -ENOMEM; in iwl_mvm_send_patterns_v1()
650 pattern_cmd->n_patterns = cpu_to_le32(wowlan->n_patterns); in iwl_mvm_send_patterns_v1()
652 for (i = 0; i < wowlan->n_patterns; i++) { in iwl_mvm_send_patterns_v1()
653 int mask_len = DIV_ROUND_UP(wowlan->patterns[i].pattern_len, 8); in iwl_mvm_send_patterns_v1()
655 memcpy(&pattern_cmd->patterns[i].mask, in iwl_mvm_send_patterns_v1()
656 wowlan->patterns[i].mask, mask_len); in iwl_mvm_send_patterns_v1()
657 memcpy(&pattern_cmd->patterns[i].pattern, in iwl_mvm_send_patterns_v1()
658 wowlan->patterns[i].pattern, in iwl_mvm_send_patterns_v1()
659 wowlan->patterns[i].pattern_len); in iwl_mvm_send_patterns_v1()
660 pattern_cmd->patterns[i].mask_size = mask_len; in iwl_mvm_send_patterns_v1()
661 pattern_cmd->patterns[i].pattern_size = in iwl_mvm_send_patterns_v1()
662 wowlan->patterns[i].pattern_len; in iwl_mvm_send_patterns_v1()
681 int ver = iwl_fw_lookup_cmd_ver(mvm->fw, cmd.id, in iwl_mvm_send_patterns()
684 if (!wowlan->n_patterns) in iwl_mvm_send_patterns()
688 wowlan->n_patterns * sizeof(struct iwl_wowlan_pattern_v2); in iwl_mvm_send_patterns()
692 return -ENOMEM; in iwl_mvm_send_patterns()
694 pattern_cmd->n_patterns = wowlan->n_patterns; in iwl_mvm_send_patterns()
696 pattern_cmd->sta_id = mvm_link->ap_sta_id; in iwl_mvm_send_patterns()
698 for (i = 0; i < wowlan->n_patterns; i++) { in iwl_mvm_send_patterns()
699 int mask_len = DIV_ROUND_UP(wowlan->patterns[i].pattern_len, 8); in iwl_mvm_send_patterns()
701 pattern_cmd->patterns[i].pattern_type = in iwl_mvm_send_patterns()
704 memcpy(&pattern_cmd->patterns[i].u.bitmask.mask, in iwl_mvm_send_patterns()
705 wowlan->patterns[i].mask, mask_len); in iwl_mvm_send_patterns()
706 memcpy(&pattern_cmd->patterns[i].u.bitmask.pattern, in iwl_mvm_send_patterns()
707 wowlan->patterns[i].pattern, in iwl_mvm_send_patterns()
708 wowlan->patterns[i].pattern_len); in iwl_mvm_send_patterns()
709 pattern_cmd->patterns[i].u.bitmask.mask_size = mask_len; in iwl_mvm_send_patterns()
710 pattern_cmd->patterns[i].u.bitmask.pattern_size = in iwl_mvm_send_patterns()
711 wowlan->patterns[i].pattern_len; in iwl_mvm_send_patterns()
735 return -EINVAL; in iwl_mvm_d3_reprogram()
738 if (WARN_ON(!mvmvif->deflink.phy_ctxt)) in iwl_mvm_d3_reprogram()
739 return -EINVAL; in iwl_mvm_d3_reprogram()
742 ctx = rcu_dereference(vif->bss_conf.chanctx_conf); in iwl_mvm_d3_reprogram()
745 return -EINVAL; in iwl_mvm_d3_reprogram()
747 chandef = ctx->def; in iwl_mvm_d3_reprogram()
748 ap_def = ctx->ap; in iwl_mvm_d3_reprogram()
749 chains_static = ctx->rx_chains_static; in iwl_mvm_d3_reprogram()
750 chains_dynamic = ctx->rx_chains_dynamic; in iwl_mvm_d3_reprogram()
753 ret = iwl_mvm_phy_ctxt_add(mvm, mvmvif->deflink.phy_ctxt, &chandef, in iwl_mvm_d3_reprogram()
759 mvmvif->uploaded = false; in iwl_mvm_d3_reprogram()
761 if (WARN_ON(!vif->cfg.assoc)) in iwl_mvm_d3_reprogram()
762 return -EINVAL; in iwl_mvm_d3_reprogram()
768 /* add back binding - XXX refactor? */ in iwl_mvm_d3_reprogram()
770 cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->deflink.phy_ctxt->id, in iwl_mvm_d3_reprogram()
771 mvmvif->deflink.phy_ctxt->color)); in iwl_mvm_d3_reprogram()
774 cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->deflink.phy_ctxt->id, in iwl_mvm_d3_reprogram()
775 mvmvif->deflink.phy_ctxt->color)); in iwl_mvm_d3_reprogram()
776 binding_cmd.macs[0] = cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, in iwl_mvm_d3_reprogram()
777 mvmvif->color)); in iwl_mvm_d3_reprogram()
792 return -EIO; in iwl_mvm_d3_reprogram()
798 rcu_assign_pointer(mvm->fw_id_to_mac_id[mvmvif->deflink.ap_sta_id], in iwl_mvm_d3_reprogram()
807 quota->id_and_color = in iwl_mvm_d3_reprogram()
808 cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->deflink.phy_ctxt->id, in iwl_mvm_d3_reprogram()
809 mvmvif->deflink.phy_ctxt->color)); in iwl_mvm_d3_reprogram()
810 quota->quota = cpu_to_le32(IWL_MVM_MAX_QUOTA); in iwl_mvm_d3_reprogram()
811 quota->max_duration = cpu_to_le32(IWL_MVM_MAX_QUOTA); in iwl_mvm_d3_reprogram()
815 quota->id_and_color = cpu_to_le32(FW_CTXT_INVALID); in iwl_mvm_d3_reprogram()
836 cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, in iwl_mvm_get_last_nonqos_seq()
837 mvmvif->color)), in iwl_mvm_get_last_nonqos_seq()
855 err = -EINVAL; in iwl_mvm_get_last_nonqos_seq()
857 err = le16_to_cpup((__le16 *)cmd.resp_pkt->data); in iwl_mvm_get_last_nonqos_seq()
858 /* firmware returns next, not last-used seqno */ in iwl_mvm_get_last_nonqos_seq()
859 err = (u16) (err - 0x10); in iwl_mvm_get_last_nonqos_seq()
872 cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, in iwl_mvm_set_last_nonqos_seq()
873 mvmvif->color)), in iwl_mvm_set_last_nonqos_seq()
874 .value = cpu_to_le16(mvmvif->seqno), in iwl_mvm_set_last_nonqos_seq()
878 if (!mvmvif->seqno_valid) in iwl_mvm_set_last_nonqos_seq()
881 mvmvif->seqno_valid = false; in iwl_mvm_set_last_nonqos_seq()
885 IWL_ERR(mvm, "failed to set non-QoS seqno\n"); in iwl_mvm_set_last_nonqos_seq()
894 * Set the HW restart bit -- this is mostly true as we're in iwl_mvm_switch_to_d3()
903 set_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status); in iwl_mvm_switch_to_d3()
905 /* the fw is reset, so all the keys are cleared */ in iwl_mvm_switch_to_d3()
906 memset(mvm->fw_key_table, 0, sizeof(mvm->fw_key_table)); in iwl_mvm_switch_to_d3()
908 mvm->ptk_ivlen = 0; in iwl_mvm_switch_to_d3()
909 mvm->ptk_icvlen = 0; in iwl_mvm_switch_to_d3()
910 mvm->ptk_ivlen = 0; in iwl_mvm_switch_to_d3()
911 mvm->ptk_icvlen = 0; in iwl_mvm_switch_to_d3()
925 /* TODO: wowlan_config_cmd->wowlan_ba_teardown_tids */ in iwl_mvm_get_wowlan_config()
927 wowlan_config_cmd->is_11n_connection = in iwl_mvm_get_wowlan_config()
928 ap_sta->deflink.ht_cap.ht_supported; in iwl_mvm_get_wowlan_config()
929 wowlan_config_cmd->flags = ENABLE_L3_FILTERING | in iwl_mvm_get_wowlan_config()
932 if (ap_sta->mfp) in iwl_mvm_get_wowlan_config()
933 wowlan_config_cmd->flags |= IS_11W_ASSOC; in iwl_mvm_get_wowlan_config()
935 if (iwl_fw_lookup_cmd_ver(mvm->fw, WOWLAN_CONFIGURATION, 0) < 6) { in iwl_mvm_get_wowlan_config()
942 wowlan_config_cmd->non_qos_seq = cpu_to_le16(ret); in iwl_mvm_get_wowlan_config()
945 if (iwl_fw_lookup_cmd_ver(mvm->fw, WOWLAN_CONFIGURATION, 0) < 7) in iwl_mvm_get_wowlan_config()
948 if (wowlan->disconnect) in iwl_mvm_get_wowlan_config()
949 wowlan_config_cmd->wakeup_filter |= in iwl_mvm_get_wowlan_config()
952 if (wowlan->magic_pkt) in iwl_mvm_get_wowlan_config()
953 wowlan_config_cmd->wakeup_filter |= in iwl_mvm_get_wowlan_config()
955 if (wowlan->gtk_rekey_failure) in iwl_mvm_get_wowlan_config()
956 wowlan_config_cmd->wakeup_filter |= in iwl_mvm_get_wowlan_config()
958 if (wowlan->eap_identity_req) in iwl_mvm_get_wowlan_config()
959 wowlan_config_cmd->wakeup_filter |= in iwl_mvm_get_wowlan_config()
961 if (wowlan->four_way_handshake) in iwl_mvm_get_wowlan_config()
962 wowlan_config_cmd->wakeup_filter |= in iwl_mvm_get_wowlan_config()
964 if (wowlan->n_patterns) in iwl_mvm_get_wowlan_config()
965 wowlan_config_cmd->wakeup_filter |= in iwl_mvm_get_wowlan_config()
968 if (wowlan->rfkill_release) in iwl_mvm_get_wowlan_config()
969 wowlan_config_cmd->wakeup_filter |= in iwl_mvm_get_wowlan_config()
972 if (wowlan->tcp) { in iwl_mvm_get_wowlan_config()
977 wowlan_config_cmd->wakeup_filter |= in iwl_mvm_get_wowlan_config()
984 if (wowlan->any) { in iwl_mvm_get_wowlan_config()
985 wowlan_config_cmd->wakeup_filter |= in iwl_mvm_get_wowlan_config()
999 bool unified = fw_has_capa(&mvm->fw->ucode_capa, in iwl_mvm_wowlan_config_key_params()
1010 * as we need non-atomic context in order to take the in iwl_mvm_wowlan_config_key_params()
1017 * take care of locking/unlocking mvm->mutex. in iwl_mvm_wowlan_config_key_params()
1019 ieee80211_iter_keys(mvm->hw, vif, iwl_mvm_wowlan_program_keys, in iwl_mvm_wowlan_config_key_params()
1023 return -EIO; in iwl_mvm_wowlan_config_key_params()
1030 if (!fw_has_api(&mvm->fw->ucode_capa, in iwl_mvm_wowlan_config_key_params()
1032 int ver = iwl_fw_lookup_cmd_ver(mvm->fw, WOWLAN_TKIP_PARAM, in iwl_mvm_wowlan_config_key_params()
1040 cpu_to_le32(mvm_link->ap_sta_id); in iwl_mvm_wowlan_config_key_params()
1045 return -EINVAL; in iwl_mvm_wowlan_config_key_params()
1048 ieee80211_iter_keys(mvm->hw, vif, iwl_mvm_wowlan_get_tkip_data, in iwl_mvm_wowlan_config_key_params()
1063 if (mvmvif->rekey_data.valid) { in iwl_mvm_wowlan_config_key_params()
1071 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw, in iwl_mvm_wowlan_config_key_params()
1076 return -EINVAL; in iwl_mvm_wowlan_config_key_params()
1078 ieee80211_iter_keys(mvm->hw, vif, iwl_mvm_wowlan_gtk_type_iter, in iwl_mvm_wowlan_config_key_params()
1081 memcpy(kek_kck_cmd.kck, mvmvif->rekey_data.kck, in iwl_mvm_wowlan_config_key_params()
1082 mvmvif->rekey_data.kck_len); in iwl_mvm_wowlan_config_key_params()
1083 kek_kck_cmd.kck_len = cpu_to_le16(mvmvif->rekey_data.kck_len); in iwl_mvm_wowlan_config_key_params()
1084 memcpy(kek_kck_cmd.kek, mvmvif->rekey_data.kek, in iwl_mvm_wowlan_config_key_params()
1085 mvmvif->rekey_data.kek_len); in iwl_mvm_wowlan_config_key_params()
1086 kek_kck_cmd.kek_len = cpu_to_le16(mvmvif->rekey_data.kek_len); in iwl_mvm_wowlan_config_key_params()
1087 kek_kck_cmd.replay_ctr = mvmvif->rekey_data.replay_ctr; in iwl_mvm_wowlan_config_key_params()
1088 kek_kck_cmd.akm = cpu_to_le32(mvmvif->rekey_data.akm); in iwl_mvm_wowlan_config_key_params()
1089 kek_kck_cmd.sta_id = cpu_to_le32(mvm_link->ap_sta_id); in iwl_mvm_wowlan_config_key_params()
1106 mvmvif->rekey_data.akm); in iwl_mvm_wowlan_config_key_params()
1126 bool unified_image = fw_has_capa(&mvm->fw->ucode_capa, in iwl_mvm_wowlan_config()
1129 mvm->offload_tid = wowlan_config_cmd_v6->offloading_tid; in iwl_mvm_wowlan_config()
1145 if (iwl_fw_lookup_cmd_ver(mvm->fw, WOWLAN_CONFIGURATION, 0) > 6) { in iwl_mvm_wowlan_config()
1147 .wakeup_filter = wowlan_config_cmd_v6->wakeup_filter, in iwl_mvm_wowlan_config()
1149 wowlan_config_cmd_v6->wowlan_ba_teardown_tids, in iwl_mvm_wowlan_config()
1151 wowlan_config_cmd_v6->is_11n_connection, in iwl_mvm_wowlan_config()
1152 .offloading_tid = wowlan_config_cmd_v6->offloading_tid, in iwl_mvm_wowlan_config()
1153 .flags = wowlan_config_cmd_v6->flags, in iwl_mvm_wowlan_config()
1154 .sta_id = wowlan_config_cmd_v6->sta_id, in iwl_mvm_wowlan_config()
1168 if (fw_has_api(&mvm->fw->ucode_capa, in iwl_mvm_wowlan_config()
1177 mvm_link->ap_sta_id); in iwl_mvm_wowlan_config()
1187 bool unified_image = fw_has_capa(&mvm->fw->ucode_capa, in iwl_mvm_netdetect_config()
1197 * net-detect). But in practice this doesn't seem to in iwl_mvm_netdetect_config()
1205 ret = iwl_mvm_sched_scan_start(mvm, vif, nd_config, &mvm->nd_ies, in iwl_mvm_netdetect_config()
1210 if (WARN_ON(mvm->nd_match_sets || mvm->nd_channels)) in iwl_mvm_netdetect_config()
1211 return -EBUSY; in iwl_mvm_netdetect_config()
1214 if (nd_config->n_match_sets) { in iwl_mvm_netdetect_config()
1215 mvm->nd_match_sets = kmemdup(nd_config->match_sets, in iwl_mvm_netdetect_config()
1216 sizeof(*nd_config->match_sets) * in iwl_mvm_netdetect_config()
1217 nd_config->n_match_sets, in iwl_mvm_netdetect_config()
1219 if (mvm->nd_match_sets) in iwl_mvm_netdetect_config()
1220 mvm->n_nd_match_sets = nd_config->n_match_sets; in iwl_mvm_netdetect_config()
1224 mvm->nd_channels = kmemdup(nd_config->channels, in iwl_mvm_netdetect_config()
1225 sizeof(*nd_config->channels) * in iwl_mvm_netdetect_config()
1226 nd_config->n_channels, in iwl_mvm_netdetect_config()
1228 if (mvm->nd_channels) in iwl_mvm_netdetect_config()
1229 mvm->n_nd_channels = nd_config->n_channels; in iwl_mvm_netdetect_config()
1236 kfree(mvm->nd_match_sets); in iwl_mvm_free_nd()
1237 mvm->nd_match_sets = NULL; in iwl_mvm_free_nd()
1238 mvm->n_nd_match_sets = 0; in iwl_mvm_free_nd()
1239 kfree(mvm->nd_channels); in iwl_mvm_free_nd()
1240 mvm->nd_channels = NULL; in iwl_mvm_free_nd()
1241 mvm->n_nd_channels = 0; in iwl_mvm_free_nd()
1269 bool unified_image = fw_has_capa(&mvm->fw->ucode_capa, in __iwl_mvm_suspend()
1278 return -EINVAL; in __iwl_mvm_suspend()
1289 mutex_lock(&mvm->mutex); in __iwl_mvm_suspend()
1291 set_bit(IWL_MVM_STATUS_IN_D3, &mvm->status); in __iwl_mvm_suspend()
1297 mvm_link = mvmvif->link[iwl_mvm_get_primary_link(vif)]; in __iwl_mvm_suspend()
1299 ret = -EINVAL; in __iwl_mvm_suspend()
1303 if (mvm_link->ap_sta_id == IWL_INVALID_STA) { in __iwl_mvm_suspend()
1305 if (!wowlan->nd_config) { in __iwl_mvm_suspend()
1311 mvm, wowlan, wowlan->nd_config, vif); in __iwl_mvm_suspend()
1315 mvm->net_detect = true; in __iwl_mvm_suspend()
1321 wowlan_config_cmd.sta_id = mvm_link->ap_sta_id; in __iwl_mvm_suspend()
1324 mvm->fw_id_to_mac_id[mvm_link->ap_sta_id], in __iwl_mvm_suspend()
1325 lockdep_is_held(&mvm->mutex)); in __iwl_mvm_suspend()
1327 ret = -EINVAL; in __iwl_mvm_suspend()
1332 mvm, ap_sta->txq[wowlan_config_cmd.offloading_tid]); in __iwl_mvm_suspend()
1345 mvm->net_detect = false; in __iwl_mvm_suspend()
1357 if (mvm->d3_wake_sysassert) in __iwl_mvm_suspend()
1367 if (mvm->trans->mac_cfg->device_family < IWL_DEVICE_FAMILY_9000) in __iwl_mvm_suspend()
1368 iwl_fw_dbg_stop_restart_recording(&mvm->fwrt, NULL, true); in __iwl_mvm_suspend()
1370 /* must be last -- this switches firmware state */ in __iwl_mvm_suspend()
1377 mvm->d3_test_pme_ptr = in __iwl_mvm_suspend()
1378 le32_to_cpup((__le32 *)d3_cfg_cmd.resp_pkt->data); in __iwl_mvm_suspend()
1383 clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status); in __iwl_mvm_suspend()
1385 ret = iwl_trans_d3_suspend(mvm->trans, test, !unified_image); in __iwl_mvm_suspend()
1390 clear_bit(IWL_MVM_STATUS_IN_D3, &mvm->status); in __iwl_mvm_suspend()
1393 mutex_unlock(&mvm->mutex); in __iwl_mvm_suspend()
1404 mutex_lock(&mvm->mutex); in iwl_mvm_suspend()
1405 iwl_fw_runtime_suspend(&mvm->fwrt); in iwl_mvm_suspend()
1406 mutex_unlock(&mvm->mutex); in iwl_mvm_suspend()
1453 * We use -1 for when we have valid data but don't know
1481 .pattern_idx = -1, in iwl_mvm_report_wakeup_reasons()
1484 u32 reasons = status->wakeup_reasons; in iwl_mvm_report_wakeup_reasons()
1491 pm_wakeup_event(mvm->dev, 0); in iwl_mvm_report_wakeup_reasons()
1498 status->pattern_number; in iwl_mvm_report_wakeup_reasons()
1529 if (status->wake_packet) { in iwl_mvm_report_wakeup_reasons()
1530 int pktsize = status->wake_packet_bufsize; in iwl_mvm_report_wakeup_reasons()
1531 int pktlen = status->wake_packet_length; in iwl_mvm_report_wakeup_reasons()
1532 const u8 *pktdata = status->wake_packet; in iwl_mvm_report_wakeup_reasons()
1534 int truncated = pktlen - pktsize; in iwl_mvm_report_wakeup_reasons()
1540 if (ieee80211_is_data(hdr->frame_control)) { in iwl_mvm_report_wakeup_reasons()
1541 int hdrlen = ieee80211_hdrlen(hdr->frame_control); in iwl_mvm_report_wakeup_reasons()
1550 pktsize -= hdrlen; in iwl_mvm_report_wakeup_reasons()
1552 if (ieee80211_has_protected(hdr->frame_control)) { in iwl_mvm_report_wakeup_reasons()
1556 * that's not really a problem - changing in iwl_mvm_report_wakeup_reasons()
1559 if (is_multicast_ether_addr(hdr->addr1)) { in iwl_mvm_report_wakeup_reasons()
1560 ivlen = mvm->gtk_ivlen; in iwl_mvm_report_wakeup_reasons()
1561 icvlen += mvm->gtk_icvlen; in iwl_mvm_report_wakeup_reasons()
1563 ivlen = mvm->ptk_ivlen; in iwl_mvm_report_wakeup_reasons()
1564 icvlen += mvm->ptk_icvlen; in iwl_mvm_report_wakeup_reasons()
1571 truncated -= icvlen; in iwl_mvm_report_wakeup_reasons()
1573 icvlen -= truncated; in iwl_mvm_report_wakeup_reasons()
1577 pktsize -= ivlen + icvlen; in iwl_mvm_report_wakeup_reasons()
1582 if (ieee80211_data_to_8023(pkt, vif->addr, vif->type)) in iwl_mvm_report_wakeup_reasons()
1584 wakeup.packet = pkt->data; in iwl_mvm_report_wakeup_reasons()
1585 wakeup.packet_present_len = pkt->len; in iwl_mvm_report_wakeup_reasons()
1586 wakeup.packet_len = pkt->len - truncated; in iwl_mvm_report_wakeup_reasons()
1592 truncated -= 4; in iwl_mvm_report_wakeup_reasons()
1595 fcslen -= truncated; in iwl_mvm_report_wakeup_reasons()
1598 pktsize -= fcslen; in iwl_mvm_report_wakeup_reasons()
1599 wakeup.packet = status->wake_packet; in iwl_mvm_report_wakeup_reasons()
1601 wakeup.packet_len = pktlen - truncated; in iwl_mvm_report_wakeup_reasons()
1615 seq->ccmp.pn[0] = pn >> 40; in iwl_mvm_le64_to_aes_seq()
1616 seq->ccmp.pn[1] = pn >> 32; in iwl_mvm_le64_to_aes_seq()
1617 seq->ccmp.pn[2] = pn >> 24; in iwl_mvm_le64_to_aes_seq()
1618 seq->ccmp.pn[3] = pn >> 16; in iwl_mvm_le64_to_aes_seq()
1619 seq->ccmp.pn[4] = pn >> 8; in iwl_mvm_le64_to_aes_seq()
1620 seq->ccmp.pn[5] = pn; in iwl_mvm_le64_to_aes_seq()
1626 iwl_mvm_le64_to_aes_seq(sc->pn, seq); in iwl_mvm_aes_sc_to_seq()
1633 seq->tkip.iv16 = (u16)pn; in iwl_mvm_le64_to_tkip_seq()
1634 seq->tkip.iv32 = (u32)(pn >> 16); in iwl_mvm_le64_to_tkip_seq()
1640 seq->tkip.iv32 = le32_to_cpu(sc->iv32); in iwl_mvm_tkip_sc_to_seq()
1641 seq->tkip.iv16 = le16_to_cpu(sc->iv16); in iwl_mvm_tkip_sc_to_seq()
1662 iwl_mvm_set_key_rx_seq_tids(key, status->ptk.aes.seq); in iwl_mvm_set_aes_ptk_rx_seq()
1669 ptk_pn = rcu_dereference(mvmsta->ptk_pn[key->keyidx]); in iwl_mvm_set_aes_ptk_rx_seq()
1678 for (i = 1; i < mvm->trans->info.num_rxqs; i++) in iwl_mvm_set_aes_ptk_rx_seq()
1679 memcpy(ptk_pn->q[i].pn[tid], in iwl_mvm_set_aes_ptk_rx_seq()
1680 status->ptk.aes.seq[tid].ccmp.pn, in iwl_mvm_set_aes_ptk_rx_seq()
1696 iwl_mvm_tkip_sc_to_seq(&sc->tkip.multicast_rsc[i], in iwl_mvm_convert_key_counters()
1697 &status->gtk_seq[0].tkip.seq[i]); in iwl_mvm_convert_key_counters()
1698 iwl_mvm_aes_sc_to_seq(&sc->aes.multicast_rsc[i], in iwl_mvm_convert_key_counters()
1699 &status->gtk_seq[0].aes.seq[i]); in iwl_mvm_convert_key_counters()
1701 status->gtk_seq[0].valid = true; in iwl_mvm_convert_key_counters()
1702 status->gtk_seq[0].key_id = key_idx; in iwl_mvm_convert_key_counters()
1705 status->ptk.tkip.tx_pn = (u64)le16_to_cpu(sc->tkip.tsc.iv16) | in iwl_mvm_convert_key_counters()
1706 ((u64)le32_to_cpu(sc->tkip.tsc.iv32) << 16); in iwl_mvm_convert_key_counters()
1707 status->ptk.aes.tx_pn = le64_to_cpu(sc->aes.tsc.pn); in iwl_mvm_convert_key_counters()
1711 iwl_mvm_tkip_sc_to_seq(&sc->tkip.unicast_rsc[i], in iwl_mvm_convert_key_counters()
1712 &status->ptk.tkip.seq[i]); in iwl_mvm_convert_key_counters()
1713 iwl_mvm_aes_sc_to_seq(&sc->aes.unicast_rsc[i], in iwl_mvm_convert_key_counters()
1714 &status->ptk.aes.seq[i]); in iwl_mvm_convert_key_counters()
1726 iwl_mvm_le64_to_tkip_seq(sc->mcast_rsc[idx][tid], in iwl_mvm_convert_key_counters_v5_gtk_seq()
1727 &status->gtk_seq[idx].tkip.seq[tid]); in iwl_mvm_convert_key_counters_v5_gtk_seq()
1728 iwl_mvm_le64_to_aes_seq(sc->mcast_rsc[idx][tid], in iwl_mvm_convert_key_counters_v5_gtk_seq()
1729 &status->gtk_seq[idx].aes.seq[tid]); in iwl_mvm_convert_key_counters_v5_gtk_seq()
1732 status->gtk_seq[idx].valid = true; in iwl_mvm_convert_key_counters_v5_gtk_seq()
1733 status->gtk_seq[idx].key_id = key_id; in iwl_mvm_convert_key_counters_v5_gtk_seq()
1744 BUILD_BUG_ON(ARRAY_SIZE(sc->mcast_rsc) != ARRAY_SIZE(status->gtk_seq)); in iwl_mvm_convert_key_counters_v5()
1747 for (i = 0; i < ARRAY_SIZE(sc->mcast_key_id_map); i++) { in iwl_mvm_convert_key_counters_v5()
1748 u8 entry = sc->mcast_key_id_map[i]; in iwl_mvm_convert_key_counters_v5()
1750 if (entry < ARRAY_SIZE(sc->mcast_rsc)) in iwl_mvm_convert_key_counters_v5()
1759 iwl_mvm_le64_to_tkip_seq(sc->ucast_rsc[tid], in iwl_mvm_convert_key_counters_v5()
1760 &status->ptk.tkip.seq[tid]); in iwl_mvm_convert_key_counters_v5()
1761 iwl_mvm_le64_to_aes_seq(sc->ucast_rsc[tid], in iwl_mvm_convert_key_counters_v5()
1762 &status->ptk.aes.seq[tid]); in iwl_mvm_convert_key_counters_v5()
1770 switch (key->cipher) { in iwl_mvm_set_key_rx_seq_idx()
1774 iwl_mvm_set_key_rx_seq_tids(key, status->gtk_seq[idx].aes.seq); in iwl_mvm_set_key_rx_seq_idx()
1777 iwl_mvm_set_key_rx_seq_tids(key, status->gtk_seq[idx].tkip.seq); in iwl_mvm_set_key_rx_seq_idx()
1789 for (i = 0; i < ARRAY_SIZE(status->gtk_seq); i++) { in iwl_mvm_set_key_rx_seq()
1790 if (!status->gtk_seq[i].valid) in iwl_mvm_set_key_rx_seq()
1793 if (status->gtk_seq[i].key_id == key->keyidx) in iwl_mvm_set_key_rx_seq()
1813 int link_id = vif->active_links ? __ffs(vif->active_links) : -1; in iwl_mvm_d3_find_last_keys()
1815 if (link_id >= 0 && key->link_id >= 0 && link_id != key->link_id) in iwl_mvm_d3_find_last_keys()
1818 if (data->unhandled_cipher) in iwl_mvm_d3_find_last_keys()
1821 switch (key->cipher) { in iwl_mvm_d3_find_last_keys()
1831 data->gtk_cipher = key->cipher; in iwl_mvm_d3_find_last_keys()
1838 if (data->igtk_support && in iwl_mvm_d3_find_last_keys()
1839 (key->keyidx == 4 || key->keyidx == 5)) { in iwl_mvm_d3_find_last_keys()
1840 data->igtk_cipher = key->cipher; in iwl_mvm_d3_find_last_keys()
1841 } else if (data->bigtk_support && in iwl_mvm_d3_find_last_keys()
1842 (key->keyidx == 6 || key->keyidx == 7)) { in iwl_mvm_d3_find_last_keys()
1843 data->bigtk_cipher = key->cipher; in iwl_mvm_d3_find_last_keys()
1845 data->unhandled_cipher = true; in iwl_mvm_d3_find_last_keys()
1850 /* everything else - disconnect from AP */ in iwl_mvm_d3_find_last_keys()
1851 data->unhandled_cipher = true; in iwl_mvm_d3_find_last_keys()
1855 data->num_keys++; in iwl_mvm_d3_find_last_keys()
1865 BUILD_BUG_ON(sizeof(seq->aes_gmac.pn) != sizeof(key->ipn)); in iwl_mvm_d3_set_igtk_bigtk_ipn()
1866 memcpy(seq->aes_gmac.pn, key->ipn, sizeof(seq->aes_gmac.pn)); in iwl_mvm_d3_set_igtk_bigtk_ipn()
1870 BUILD_BUG_ON(sizeof(seq->aes_cmac.pn) != sizeof(key->ipn)); in iwl_mvm_d3_set_igtk_bigtk_ipn()
1871 memcpy(seq->aes_cmac.pn, key->ipn, sizeof(seq->aes_cmac.pn)); in iwl_mvm_d3_set_igtk_bigtk_ipn()
1885 iwl_mvm_d3_set_igtk_bigtk_ipn(key_data, &seq, key->cipher); in iwl_mvm_d3_update_igtk_bigtk()
1896 struct iwl_wowlan_status_data *status = data->status; in iwl_mvm_d3_update_keys()
1898 int link_id = vif->active_links ? __ffs(vif->active_links) : -1; in iwl_mvm_d3_update_keys()
1900 if (link_id >= 0 && key->link_id >= 0 && link_id != key->link_id) in iwl_mvm_d3_update_keys()
1903 if (data->unhandled_cipher) in iwl_mvm_d3_update_keys()
1906 switch (key->cipher) { in iwl_mvm_d3_update_keys()
1915 atomic64_set(&key->tx_pn, status->ptk.aes.tx_pn); in iwl_mvm_d3_update_keys()
1916 iwl_mvm_set_aes_ptk_rx_seq(data->mvm, status, sta, key); in iwl_mvm_d3_update_keys()
1922 atomic64_set(&key->tx_pn, status->ptk.tkip.tx_pn); in iwl_mvm_d3_update_keys()
1923 iwl_mvm_set_key_rx_seq_tids(key, status->ptk.tkip.seq); in iwl_mvm_d3_update_keys()
1926 keyidx = key->keyidx; in iwl_mvm_d3_update_keys()
1931 if ((status->gtk[0].len && keyidx == status->gtk[0].id) || in iwl_mvm_d3_update_keys()
1932 (status->gtk[1].len && keyidx == status->gtk[1].id)) in iwl_mvm_d3_update_keys()
1939 if (key->keyidx == 4 || key->keyidx == 5) { in iwl_mvm_d3_update_keys()
1941 &status->igtk); in iwl_mvm_d3_update_keys()
1943 if (key->keyidx == 6 || key->keyidx == 7) { in iwl_mvm_d3_update_keys()
1944 u8 idx = key->keyidx == status->bigtk[1].id; in iwl_mvm_d3_update_keys()
1947 &status->bigtk[idx]); in iwl_mvm_d3_update_keys()
1960 int link_id = vif->active_links ? __ffs(vif->active_links) : -1; in iwl_mvm_gtk_rekey()
1963 conf->cipher = gtk_cipher; in iwl_mvm_gtk_rekey()
1969 BUILD_BUG_ON(WOWLAN_KEY_MAX_SIZE < sizeof(status->gtk[0].key)); in iwl_mvm_gtk_rekey()
1974 conf->keylen = WLAN_KEY_LEN_CCMP; in iwl_mvm_gtk_rekey()
1977 conf->keylen = WLAN_KEY_LEN_GCMP_256; in iwl_mvm_gtk_rekey()
1980 conf->keylen = WLAN_KEY_LEN_TKIP; in iwl_mvm_gtk_rekey()
1986 for (i = 0; i < ARRAY_SIZE(status->gtk); i++) { in iwl_mvm_gtk_rekey()
1987 if (!status->gtk[i].len) in iwl_mvm_gtk_rekey()
1990 conf->keyidx = status->gtk[i].id; in iwl_mvm_gtk_rekey()
1993 conf->cipher, conf->keyidx); in iwl_mvm_gtk_rekey()
1994 memcpy(conf->key, status->gtk[i].key, in iwl_mvm_gtk_rekey()
1995 sizeof(status->gtk[i].key)); in iwl_mvm_gtk_rekey()
1996 memcpy(key_data, status->gtk[i].key, sizeof(status->gtk[i].key)); in iwl_mvm_gtk_rekey()
1998 key = ieee80211_gtk_rekey_add(vif, status->gtk[i].id, key_data, in iwl_mvm_gtk_rekey()
2002 if (PTR_ERR(key) == -EALREADY) in iwl_mvm_gtk_rekey()
2007 for (j = 0; j < ARRAY_SIZE(status->gtk_seq); j++) { in iwl_mvm_gtk_rekey()
2008 if (!status->gtk_seq[j].valid || in iwl_mvm_gtk_rekey()
2009 status->gtk_seq[j].key_id != key->keyidx) in iwl_mvm_gtk_rekey()
2014 WARN_ON(j == ARRAY_SIZE(status->gtk_seq)); in iwl_mvm_gtk_rekey()
2030 int link_id = vif->active_links ? __ffs(vif->active_links) : -1; in iwl_mvm_d3_igtk_bigtk_rekey_add()
2032 s8 keyidx = key_data->id; in iwl_mvm_d3_igtk_bigtk_rekey_add()
2034 conf->cipher = cipher; in iwl_mvm_d3_igtk_bigtk_rekey_add()
2035 conf->keyidx = keyidx; in iwl_mvm_d3_igtk_bigtk_rekey_add()
2037 if (!key_data->len) in iwl_mvm_d3_igtk_bigtk_rekey_add()
2040 iwl_mvm_d3_set_igtk_bigtk_ipn(key_data, &seq, conf->cipher); in iwl_mvm_d3_igtk_bigtk_rekey_add()
2044 conf->keylen = WLAN_KEY_LEN_BIP_GMAC_128; in iwl_mvm_d3_igtk_bigtk_rekey_add()
2047 conf->keylen = WLAN_KEY_LEN_BIP_GMAC_256; in iwl_mvm_d3_igtk_bigtk_rekey_add()
2050 conf->keylen = WLAN_KEY_LEN_AES_CMAC; in iwl_mvm_d3_igtk_bigtk_rekey_add()
2053 conf->keylen = WLAN_KEY_LEN_BIP_CMAC_256; in iwl_mvm_d3_igtk_bigtk_rekey_add()
2058 BUILD_BUG_ON(WOWLAN_KEY_MAX_SIZE < sizeof(key_data->key)); in iwl_mvm_d3_igtk_bigtk_rekey_add()
2059 memcpy(conf->key, key_data->key, conf->keylen); in iwl_mvm_d3_igtk_bigtk_rekey_add()
2061 memcpy(key, key_data->key, sizeof(key_data->key)); in iwl_mvm_d3_igtk_bigtk_rekey_add()
2067 return PTR_ERR(key_config) == -EALREADY; in iwl_mvm_d3_igtk_bigtk_rekey_add()
2075 mvm_link = mvmvif->link[link_id]; in iwl_mvm_d3_igtk_bigtk_rekey_add()
2076 if (mvm_link->igtk) in iwl_mvm_d3_igtk_bigtk_rekey_add()
2077 mvm_link->igtk->hw_key_idx = STA_KEY_IDX_INVALID; in iwl_mvm_d3_igtk_bigtk_rekey_add()
2078 mvm_link->igtk = key_config; in iwl_mvm_d3_igtk_bigtk_rekey_add()
2081 if (vif->type == NL80211_IFTYPE_STATION && (keyidx == 6 || keyidx == 7)) in iwl_mvm_d3_igtk_bigtk_rekey_add()
2082 rcu_assign_pointer(mvmvif->bcn_prot.keys[keyidx - 6], in iwl_mvm_d3_igtk_bigtk_rekey_add()
2092 if (!fw_has_api(&mvm->fw->ucode_capa, in iwl_mvm_lookup_wowlan_status_ver()
2097 notif_ver = iwl_fw_lookup_notif_ver(mvm->fw, LONG_GROUP, in iwl_mvm_lookup_wowlan_status_ver()
2100 notif_ver = iwl_fw_lookup_notif_ver(mvm->fw, LEGACY_GROUP, in iwl_mvm_lookup_wowlan_status_ver()
2120 if (!status || !vif->bss_conf.bssid) in iwl_mvm_setup_connection_keep()
2124 iwl_fw_lookup_notif_ver(mvm->fw, PROT_OFFLOAD_GROUP, in iwl_mvm_setup_connection_keep()
2129 if (iwl_fw_lookup_notif_ver(mvm->fw, PROT_OFFLOAD_GROUP, in iwl_mvm_setup_connection_keep()
2135 ieee80211_iter_keys(mvm->hw, vif, in iwl_mvm_setup_connection_keep()
2147 ieee80211_iter_keys(mvm->hw, vif, in iwl_mvm_setup_connection_keep()
2150 if (status->num_of_gtk_rekeys) { in iwl_mvm_setup_connection_keep()
2151 __be64 replay_ctr = cpu_to_be64(status->replay_ctr); in iwl_mvm_setup_connection_keep()
2154 status->num_of_gtk_rekeys); in iwl_mvm_setup_connection_keep()
2161 &status->igtk)) in iwl_mvm_setup_connection_keep()
2164 for (i = 0; i < ARRAY_SIZE(status->bigtk); i++) { in iwl_mvm_setup_connection_keep()
2167 &status->bigtk[i])) in iwl_mvm_setup_connection_keep()
2171 ieee80211_gtk_rekey_notify(vif, vif->bss_conf.bssid, in iwl_mvm_setup_connection_keep()
2176 if (iwl_fw_lookup_notif_ver(mvm->fw, LONG_GROUP, in iwl_mvm_setup_connection_keep()
2179 mvmvif->seqno_valid = true; in iwl_mvm_setup_connection_keep()
2180 /* +0x10 because the set API expects next-to-use, not last-used */ in iwl_mvm_setup_connection_keep()
2181 mvmvif->seqno = status->non_qos_seq_ctr + 0x10; in iwl_mvm_setup_connection_keep()
2184 if (status->wakeup_reasons & disconnection_reasons) in iwl_mvm_setup_connection_keep()
2193 BUILD_BUG_ON(sizeof(status->gtk[0].key) < sizeof(data->key)); in iwl_mvm_convert_gtk_v2()
2195 sizeof(data->tkip_mic_key) > in iwl_mvm_convert_gtk_v2()
2196 sizeof(status->gtk[0].key)); in iwl_mvm_convert_gtk_v2()
2198 status->gtk[0].len = data->key_len; in iwl_mvm_convert_gtk_v2()
2199 status->gtk[0].flags = data->key_flags; in iwl_mvm_convert_gtk_v2()
2200 status->gtk[0].id = status->gtk[0].flags & IWL_WOWLAN_GTK_IDX_MASK; in iwl_mvm_convert_gtk_v2()
2202 memcpy(status->gtk[0].key, data->key, sizeof(data->key)); in iwl_mvm_convert_gtk_v2()
2205 if (status->gtk[0].len == NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY) in iwl_mvm_convert_gtk_v2()
2206 memcpy(status->gtk[0].key + NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY, in iwl_mvm_convert_gtk_v2()
2207 data->tkip_mic_key, sizeof(data->tkip_mic_key)); in iwl_mvm_convert_gtk_v2()
2215 BUILD_BUG_ON(sizeof(status->gtk[0].key) < sizeof(data[0].key)); in iwl_mvm_convert_gtk_v3()
2218 sizeof(status->gtk[0].key)); in iwl_mvm_convert_gtk_v3()
2219 BUILD_BUG_ON(ARRAY_SIZE(status->gtk) < WOWLAN_GTK_KEYS_NUM); in iwl_mvm_convert_gtk_v3()
2220 for (data_idx = 0; data_idx < ARRAY_SIZE(status->gtk); data_idx++) { in iwl_mvm_convert_gtk_v3()
2223 status->gtk[status_idx].len = data[data_idx].key_len; in iwl_mvm_convert_gtk_v3()
2224 status->gtk[status_idx].flags = data[data_idx].key_flags; in iwl_mvm_convert_gtk_v3()
2225 status->gtk[status_idx].id = status->gtk[status_idx].flags & in iwl_mvm_convert_gtk_v3()
2228 memcpy(status->gtk[status_idx].key, data[data_idx].key, in iwl_mvm_convert_gtk_v3()
2232 if (status->gtk[status_idx].len == in iwl_mvm_convert_gtk_v3()
2234 memcpy(status->gtk[status_idx].key + in iwl_mvm_convert_gtk_v3()
2247 BUILD_BUG_ON(sizeof(status->igtk.key) < sizeof(data->key)); in iwl_mvm_convert_igtk()
2248 BUILD_BUG_ON(sizeof(status->igtk.ipn) != sizeof(data->ipn)); in iwl_mvm_convert_igtk()
2250 if (!data->key_len) in iwl_mvm_convert_igtk()
2253 status->igtk.len = data->key_len; in iwl_mvm_convert_igtk()
2254 status->igtk.flags = data->key_flags; in iwl_mvm_convert_igtk()
2255 status->igtk.id = u32_get_bits(data->key_flags, in iwl_mvm_convert_igtk()
2259 memcpy(status->igtk.key, data->key, sizeof(data->key)); in iwl_mvm_convert_igtk()
2262 for (i = 0; i < sizeof(data->ipn); i++) in iwl_mvm_convert_igtk()
2263 status->igtk.ipn[i] = data->ipn[sizeof(data->ipn) - i - 1]; in iwl_mvm_convert_igtk()
2271 BUILD_BUG_ON(ARRAY_SIZE(status->bigtk) < WOWLAN_BIGTK_KEYS_NUM); in iwl_mvm_convert_bigtk()
2277 status->bigtk[status_idx].len = data[data_idx].key_len; in iwl_mvm_convert_bigtk()
2278 status->bigtk[status_idx].flags = data[data_idx].key_flags; in iwl_mvm_convert_bigtk()
2279 status->bigtk[status_idx].id = in iwl_mvm_convert_bigtk()
2284 BUILD_BUG_ON(sizeof(status->bigtk[status_idx].key) < in iwl_mvm_convert_bigtk()
2286 BUILD_BUG_ON(sizeof(status->bigtk[status_idx].ipn) < in iwl_mvm_convert_bigtk()
2289 memcpy(status->bigtk[status_idx].key, data[data_idx].key, in iwl_mvm_convert_bigtk()
2291 memcpy(status->bigtk[status_idx].ipn, data[data_idx].ipn, in iwl_mvm_convert_bigtk()
2302 if (IWL_FW_CHECK(mvm, data->num_mlo_link_keys, in iwl_mvm_parse_wowlan_info_notif()
2312 if (mvm->fast_resume) in iwl_mvm_parse_wowlan_info_notif()
2315 iwl_mvm_convert_key_counters_v5(status, &data->gtk[0].sc); in iwl_mvm_parse_wowlan_info_notif()
2316 iwl_mvm_convert_gtk_v3(status, data->gtk); in iwl_mvm_parse_wowlan_info_notif()
2317 iwl_mvm_convert_igtk(status, &data->igtk[0]); in iwl_mvm_parse_wowlan_info_notif()
2318 iwl_mvm_convert_bigtk(status, data->bigtk); in iwl_mvm_parse_wowlan_info_notif()
2319 status->replay_ctr = le64_to_cpu(data->replay_ctr); in iwl_mvm_parse_wowlan_info_notif()
2320 status->pattern_number = le16_to_cpu(data->pattern_number); in iwl_mvm_parse_wowlan_info_notif()
2321 status->tid_offloaded_tx = data->tid_offloaded_tx; in iwl_mvm_parse_wowlan_info_notif()
2323 data->tid_offloaded_tx >= in iwl_mvm_parse_wowlan_info_notif()
2324 ARRAY_SIZE(status->qos_seq_ctr), in iwl_mvm_parse_wowlan_info_notif()
2326 data->tid_offloaded_tx)) in iwl_mvm_parse_wowlan_info_notif()
2327 data->tid_offloaded_tx = 0; in iwl_mvm_parse_wowlan_info_notif()
2328 status->qos_seq_ctr[data->tid_offloaded_tx] = in iwl_mvm_parse_wowlan_info_notif()
2329 le16_to_cpu(data->qos_seq_ctr); in iwl_mvm_parse_wowlan_info_notif()
2330 status->wakeup_reasons = le32_to_cpu(data->wakeup_reasons); in iwl_mvm_parse_wowlan_info_notif()
2331 status->num_of_gtk_rekeys = in iwl_mvm_parse_wowlan_info_notif()
2332 le32_to_cpu(data->num_of_gtk_rekeys); in iwl_mvm_parse_wowlan_info_notif()
2333 status->received_beacons = le32_to_cpu(data->received_beacons); in iwl_mvm_parse_wowlan_info_notif()
2334 status->tid_tear_down = data->tid_tear_down; in iwl_mvm_parse_wowlan_info_notif()
2351 if (mvm->fast_resume) in iwl_mvm_parse_wowlan_info_notif_v3()
2354 iwl_mvm_convert_key_counters_v5(status, &data->gtk[0].sc); in iwl_mvm_parse_wowlan_info_notif_v3()
2355 iwl_mvm_convert_gtk_v3(status, data->gtk); in iwl_mvm_parse_wowlan_info_notif_v3()
2356 iwl_mvm_convert_igtk(status, &data->igtk[0]); in iwl_mvm_parse_wowlan_info_notif_v3()
2357 iwl_mvm_convert_bigtk(status, data->bigtk); in iwl_mvm_parse_wowlan_info_notif_v3()
2358 status->replay_ctr = le64_to_cpu(data->replay_ctr); in iwl_mvm_parse_wowlan_info_notif_v3()
2359 status->pattern_number = le16_to_cpu(data->pattern_number); in iwl_mvm_parse_wowlan_info_notif_v3()
2361 status->qos_seq_ctr[i] = in iwl_mvm_parse_wowlan_info_notif_v3()
2362 le16_to_cpu(data->qos_seq_ctr[i]); in iwl_mvm_parse_wowlan_info_notif_v3()
2363 status->wakeup_reasons = le32_to_cpu(data->wakeup_reasons); in iwl_mvm_parse_wowlan_info_notif_v3()
2364 status->num_of_gtk_rekeys = in iwl_mvm_parse_wowlan_info_notif_v3()
2365 le32_to_cpu(data->num_of_gtk_rekeys); in iwl_mvm_parse_wowlan_info_notif_v3()
2366 status->received_beacons = le32_to_cpu(data->received_beacons); in iwl_mvm_parse_wowlan_info_notif_v3()
2367 status->tid_tear_down = data->tid_tear_down; in iwl_mvm_parse_wowlan_info_notif_v3()
2384 iwl_mvm_convert_key_counters_v5(status, &data->gtk[0].sc); in iwl_mvm_parse_wowlan_info_notif_v1()
2385 iwl_mvm_convert_gtk_v3(status, data->gtk); in iwl_mvm_parse_wowlan_info_notif_v1()
2386 iwl_mvm_convert_igtk(status, &data->igtk[0]); in iwl_mvm_parse_wowlan_info_notif_v1()
2387 status->replay_ctr = le64_to_cpu(data->replay_ctr); in iwl_mvm_parse_wowlan_info_notif_v1()
2388 status->pattern_number = le16_to_cpu(data->pattern_number); in iwl_mvm_parse_wowlan_info_notif_v1()
2390 status->qos_seq_ctr[i] = in iwl_mvm_parse_wowlan_info_notif_v1()
2391 le16_to_cpu(data->qos_seq_ctr[i]); in iwl_mvm_parse_wowlan_info_notif_v1()
2392 status->wakeup_reasons = le32_to_cpu(data->wakeup_reasons); in iwl_mvm_parse_wowlan_info_notif_v1()
2393 status->num_of_gtk_rekeys = in iwl_mvm_parse_wowlan_info_notif_v1()
2394 le32_to_cpu(data->num_of_gtk_rekeys); in iwl_mvm_parse_wowlan_info_notif_v1()
2395 status->received_beacons = le32_to_cpu(data->received_beacons); in iwl_mvm_parse_wowlan_info_notif_v1()
2396 status->tid_tear_down = data->tid_tear_down; in iwl_mvm_parse_wowlan_info_notif_v1()
2414 data_size = ALIGN(le32_to_cpu(data->wake_packet_bufsize), 4); \
2425 status->replay_ctr = le64_to_cpu(data->replay_ctr); \
2426 status->pattern_number = le16_to_cpu(data->pattern_number); \
2427 status->non_qos_seq_ctr = le16_to_cpu(data->non_qos_seq_ctr); \
2429 status->qos_seq_ctr[i] = \
2430 le16_to_cpu(data->qos_seq_ctr[i]); \
2431 status->wakeup_reasons = le32_to_cpu(data->wakeup_reasons); \
2432 status->num_of_gtk_rekeys = \
2433 le32_to_cpu(data->num_of_gtk_rekeys); \
2434 status->received_beacons = le32_to_cpu(data->received_beacons); \
2435 status->wake_packet_length = \
2436 le32_to_cpu(data->wake_packet_length); \
2437 status->wake_packet_bufsize = \
2438 le32_to_cpu(data->wake_packet_bufsize); \
2439 if (status->wake_packet_bufsize) { \
2440 status->wake_packet = \
2441 kmemdup(data->wake_packet, \
2442 status->wake_packet_bufsize, \
2444 if (!status->wake_packet) { \
2449 status->wake_packet = NULL; \
2473 u8 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw, cmd.id, in iwl_mvm_parse_wowlan_status_common()
2479 lockdep_assert_held(&mvm->mutex); in iwl_mvm_parse_wowlan_status_common()
2493 struct iwl_wowlan_status_v6 *v6 = (void *)cmd.resp_pkt->data; in iwl_mvm_parse_wowlan_status_common()
2499 BUILD_BUG_ON(sizeof(v6->gtk.decrypt_key) > in iwl_mvm_parse_wowlan_status_common()
2500 sizeof(status->gtk[0].key)); in iwl_mvm_parse_wowlan_status_common()
2502 sizeof(v6->gtk.tkip_mic_key) > in iwl_mvm_parse_wowlan_status_common()
2503 sizeof(status->gtk[0].key)); in iwl_mvm_parse_wowlan_status_common()
2506 memcpy(status->gtk[0].key, v6->gtk.decrypt_key, in iwl_mvm_parse_wowlan_status_common()
2507 sizeof(v6->gtk.decrypt_key)); in iwl_mvm_parse_wowlan_status_common()
2508 memcpy(status->gtk[0].key + NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY, in iwl_mvm_parse_wowlan_status_common()
2509 v6->gtk.tkip_mic_key, in iwl_mvm_parse_wowlan_status_common()
2510 sizeof(v6->gtk.tkip_mic_key)); in iwl_mvm_parse_wowlan_status_common()
2512 iwl_mvm_convert_key_counters(status, &v6->gtk.rsc.all_tsc_rsc, in iwl_mvm_parse_wowlan_status_common()
2513 v6->gtk.key_index); in iwl_mvm_parse_wowlan_status_common()
2516 status->gtk[0].len = 16; in iwl_mvm_parse_wowlan_status_common()
2523 status->gtk[0].flags = v6->gtk.key_index | BIT(7); in iwl_mvm_parse_wowlan_status_common()
2524 status->gtk[0].id = v6->gtk.key_index; in iwl_mvm_parse_wowlan_status_common()
2526 struct iwl_wowlan_status_v7 *v7 = (void *)cmd.resp_pkt->data; in iwl_mvm_parse_wowlan_status_common()
2532 iwl_mvm_convert_key_counters(status, &v7->gtk[0].rsc.all_tsc_rsc, in iwl_mvm_parse_wowlan_status_common()
2533 v7->gtk[0].key_flags & IWL_WOWLAN_GTK_IDX_MASK); in iwl_mvm_parse_wowlan_status_common()
2534 iwl_mvm_convert_gtk_v2(status, &v7->gtk[0]); in iwl_mvm_parse_wowlan_status_common()
2535 iwl_mvm_convert_igtk(status, &v7->igtk[0]); in iwl_mvm_parse_wowlan_status_common()
2557 int link_id = vif->active_links ? __ffs(vif->active_links) : 0; in iwl_mvm_query_wakeup_reasons()
2558 struct iwl_mvm_vif_link_info *mvm_link = mvmvif->link[link_id]; in iwl_mvm_query_wakeup_reasons()
2559 int wowlan_info_ver = iwl_fw_lookup_notif_ver(mvm->fw, in iwl_mvm_query_wakeup_reasons()
2571 status->wakeup_reasons); in iwl_mvm_query_wakeup_reasons()
2573 mvm_ap_sta = iwl_mvm_sta_from_staid_protected(mvm, mvm_link->ap_sta_id); in iwl_mvm_query_wakeup_reasons()
2577 /* firmware stores last-used value, we store next value */ in iwl_mvm_query_wakeup_reasons()
2579 mvm_ap_sta->tid_data[status->tid_offloaded_tx].seq_number = in iwl_mvm_query_wakeup_reasons()
2580 status->qos_seq_ctr[status->tid_offloaded_tx] + 0x10; in iwl_mvm_query_wakeup_reasons()
2583 mvm_ap_sta->tid_data[i].seq_number = in iwl_mvm_query_wakeup_reasons()
2584 status->qos_seq_ctr[i] + 0x10; in iwl_mvm_query_wakeup_reasons()
2587 if (mvm->trans->mac_cfg->device_family >= IWL_DEVICE_FAMILY_22000) { in iwl_mvm_query_wakeup_reasons()
2588 i = mvm->offload_tid; in iwl_mvm_query_wakeup_reasons()
2589 iwl_trans_set_q_ptrs(mvm->trans, in iwl_mvm_query_wakeup_reasons()
2590 mvm_ap_sta->tid_data[i].txq_id, in iwl_mvm_query_wakeup_reasons()
2591 mvm_ap_sta->tid_data[i].seq_number >> 4); in iwl_mvm_query_wakeup_reasons()
2598 mutex_unlock(&mvm->mutex); in iwl_mvm_query_wakeup_reasons()
2621 int max_profiles = iwl_umac_scan_get_max_profiles(mvm->fw); in iwl_mvm_netdetect_query_results()
2629 if (fw_has_api(&mvm->fw->ucode_capa, in iwl_mvm_netdetect_query_results()
2643 ret = -EIO; in iwl_mvm_netdetect_query_results()
2647 query = (void *)cmd.resp_pkt->data; in iwl_mvm_netdetect_query_results()
2649 results->matched_profiles = le32_to_cpu(query->matched_profiles); in iwl_mvm_netdetect_query_results()
2650 memcpy(results->matches, query->matches, matches_len); in iwl_mvm_netdetect_query_results()
2653 mvm->last_netdetect_scans = le32_to_cpu(query->n_scans_done); in iwl_mvm_netdetect_query_results()
2667 if (fw_has_api(&mvm->fw->ucode_capa, in iwl_mvm_query_num_match_chans()
2670 (void *)results->matches; in iwl_mvm_query_num_match_chans()
2676 (void *)results->matches; in iwl_mvm_query_num_match_chans()
2693 if (fw_has_api(&mvm->fw->ucode_capa, in iwl_mvm_query_set_freqs()
2696 (void *)results->matches; in iwl_mvm_query_set_freqs()
2700 match->channels[n_channels++] = in iwl_mvm_query_set_freqs()
2701 mvm->nd_channels[i]->center_freq; in iwl_mvm_query_set_freqs()
2704 (void *)results->matches; in iwl_mvm_query_set_freqs()
2708 match->channels[n_channels++] = in iwl_mvm_query_set_freqs()
2709 mvm->nd_channels[i]->center_freq; in iwl_mvm_query_set_freqs()
2712 match->n_channels = n_channels; in iwl_mvm_query_set_freqs()
2716 * enum iwl_d3_notif - d3 notifications
2736 u32 notif_expected; /* bitmap - see &enum iwl_d3_notif */
2737 u32 notif_received; /* bitmap - see &enum iwl_d3_notif */
2748 .pattern_idx = -1, in iwl_mvm_query_netdetect_reasons()
2755 if (WARN_ON(!d3_data || !d3_data->status)) in iwl_mvm_query_netdetect_reasons()
2758 reasons = d3_data->status->wakeup_reasons; in iwl_mvm_query_netdetect_reasons()
2766 if (!iwl_fw_lookup_notif_ver(mvm->fw, PROT_OFFLOAD_GROUP, in iwl_mvm_query_netdetect_reasons()
2769 ret = iwl_mvm_netdetect_query_results(mvm, d3_data->nd_results); in iwl_mvm_query_netdetect_reasons()
2773 ret = d3_data->nd_results_valid ? 0 : -1; in iwl_mvm_query_netdetect_reasons()
2776 if (ret || !d3_data->nd_results->matched_profiles) { in iwl_mvm_query_netdetect_reasons()
2781 matched_profiles = d3_data->nd_results->matched_profiles; in iwl_mvm_query_netdetect_reasons()
2782 if (mvm->n_nd_match_sets) { in iwl_mvm_query_netdetect_reasons()
2793 net_detect->n_matches = n_matches; in iwl_mvm_query_netdetect_reasons()
2796 for_each_set_bit(i, &matched_profiles, mvm->n_nd_match_sets) { in iwl_mvm_query_netdetect_reasons()
2801 d3_data->nd_results, in iwl_mvm_query_netdetect_reasons()
2808 match->n_channels = n_channels; in iwl_mvm_query_netdetect_reasons()
2810 net_detect->matches[n_matches++] = match; in iwl_mvm_query_netdetect_reasons()
2815 idx = mvm->n_nd_match_sets - i - 1; in iwl_mvm_query_netdetect_reasons()
2816 match->ssid.ssid_len = mvm->nd_match_sets[idx].ssid.ssid_len; in iwl_mvm_query_netdetect_reasons()
2817 memcpy(match->ssid.ssid, mvm->nd_match_sets[idx].ssid.ssid, in iwl_mvm_query_netdetect_reasons()
2818 match->ssid.ssid_len); in iwl_mvm_query_netdetect_reasons()
2820 if (mvm->n_nd_channels < n_channels) in iwl_mvm_query_netdetect_reasons()
2823 iwl_mvm_query_set_freqs(mvm, d3_data->nd_results, match, i); in iwl_mvm_query_netdetect_reasons()
2826 net_detect->n_matches = n_matches; in iwl_mvm_query_netdetect_reasons()
2833 mutex_unlock(&mvm->mutex); in iwl_mvm_query_netdetect_reasons()
2837 for (i = 0; i < net_detect->n_matches; i++) in iwl_mvm_query_netdetect_reasons()
2838 kfree(net_detect->matches[i]); in iwl_mvm_query_netdetect_reasons()
2850 if (vif->type == NL80211_IFTYPE_STATION) in iwl_mvm_d3_disconnect_iter()
2866 if (iwl_fwrt_read_err_table(mvm->trans, in iwl_mvm_check_rt_status()
2867 mvm->trans->dbg.lmac_error_event_table[0], in iwl_mvm_check_rt_status()
2886 if (iwl_fwrt_read_err_table(mvm->trans, in iwl_mvm_check_rt_status()
2887 mvm->trans->dbg.lmac_error_event_table[1], in iwl_mvm_check_rt_status()
2891 /* check for umac error */ in iwl_mvm_check_rt_status()
2892 if (iwl_fwrt_read_err_table(mvm->trans, in iwl_mvm_check_rt_status()
2893 mvm->trans->dbg.umac_error_event_table, in iwl_mvm_check_rt_status()
2910 lockdep_assert_held(&mvm->mutex); in iwl_mvm_choose_query_wakeup_reasons()
2913 if (!d3_data->status) { in iwl_mvm_choose_query_wakeup_reasons()
2915 u8 sta_id = mvm->net_detect ? IWL_INVALID_STA : in iwl_mvm_choose_query_wakeup_reasons()
2916 mvmvif->deflink.ap_sta_id; in iwl_mvm_choose_query_wakeup_reasons()
2918 /* bug - FW with MLO has status notification */ in iwl_mvm_choose_query_wakeup_reasons()
2921 d3_data->status = iwl_mvm_send_wowlan_get_status(mvm, sta_id); in iwl_mvm_choose_query_wakeup_reasons()
2924 if (mvm->net_detect) { in iwl_mvm_choose_query_wakeup_reasons()
2928 d3_data->status); in iwl_mvm_choose_query_wakeup_reasons()
2932 mvm->keep_vif = vif; in iwl_mvm_choose_query_wakeup_reasons()
2952 u32 data_size, packet_len = le32_to_cpu(notif->wake_packet_length); in iwl_mvm_wowlan_store_wake_pkt()
2956 return -EIO; in iwl_mvm_wowlan_store_wake_pkt()
2961 return -EIO; in iwl_mvm_wowlan_store_wake_pkt()
2964 if (WARN_ON(!(status->wakeup_reasons & in iwl_mvm_wowlan_store_wake_pkt()
2967 status->wakeup_reasons); in iwl_mvm_wowlan_store_wake_pkt()
2968 return -EIO; in iwl_mvm_wowlan_store_wake_pkt()
2971 data_size = len - offsetof(struct iwl_wowlan_wake_pkt_notif, wake_packet); in iwl_mvm_wowlan_store_wake_pkt()
2977 status->wake_packet = kmemdup(notif->wake_packet, data_size, in iwl_mvm_wowlan_store_wake_pkt()
2980 if (!status->wake_packet) in iwl_mvm_wowlan_store_wake_pkt()
2981 return -ENOMEM; in iwl_mvm_wowlan_store_wake_pkt()
2983 status->wake_packet_length = packet_len; in iwl_mvm_wowlan_store_wake_pkt()
2984 status->wake_packet_bufsize = data_size; in iwl_mvm_wowlan_store_wake_pkt()
2994 struct iwl_wowlan_status_data *status = d3_data->status; in iwl_mvm_nd_match_info_handler()
2996 struct iwl_mvm_nd_results *results = d3_data->nd_results; in iwl_mvm_nd_match_info_handler()
2998 iwl_umac_scan_get_max_profiles(mvm->fw); in iwl_mvm_nd_match_info_handler()
3008 if (!mvm->net_detect) { in iwl_mvm_nd_match_info_handler()
3013 if (!status || status->wakeup_reasons != IWL_WOWLAN_WAKEUP_BY_NON_WIRELESS) { in iwl_mvm_nd_match_info_handler()
3020 mvm->last_netdetect_scans = le32_to_cpu(notif->n_scans_done); in iwl_mvm_nd_match_info_handler()
3023 results->matched_profiles = le32_to_cpu(notif->matched_profiles); in iwl_mvm_nd_match_info_handler()
3025 results->matched_profiles); in iwl_mvm_nd_match_info_handler()
3027 if (results->matched_profiles) { in iwl_mvm_nd_match_info_handler()
3028 memcpy(results->matches, notif->matches, matches_len); in iwl_mvm_nd_match_info_handler()
3029 d3_data->nd_results_valid = true; in iwl_mvm_nd_match_info_handler()
3033 mvm->scan_status = 0; in iwl_mvm_nd_match_info_handler()
3034 for (i = 0; i < mvm->max_scans; i++) in iwl_mvm_nd_match_info_handler()
3035 mvm->scan_uid_status[i] = 0; in iwl_mvm_nd_match_info_handler()
3046 int wowlan_info_ver = iwl_fw_lookup_notif_ver(mvm->fw, in iwl_mvm_wait_d3_notif()
3052 switch (WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd)) { in iwl_mvm_wait_d3_notif()
3055 if (d3_data->notif_received & IWL_D3_NOTIF_WOWLAN_INFO) { in iwl_mvm_wait_d3_notif()
3064 (void *)pkt->data; in iwl_mvm_wait_d3_notif()
3067 d3_data->status, in iwl_mvm_wait_d3_notif()
3071 (void *)pkt->data; in iwl_mvm_wait_d3_notif()
3074 d3_data->status, len); in iwl_mvm_wait_d3_notif()
3077 (void *)pkt->data; in iwl_mvm_wait_d3_notif()
3080 d3_data->status, len); in iwl_mvm_wait_d3_notif()
3088 d3_data->notif_received |= IWL_D3_NOTIF_WOWLAN_INFO; in iwl_mvm_wait_d3_notif()
3090 if (d3_data->status && in iwl_mvm_wait_d3_notif()
3091 d3_data->status->wakeup_reasons & IWL_WOWLAN_WAKEUP_REASON_HAS_WAKEUP_PKT) in iwl_mvm_wait_d3_notif()
3093 d3_data->notif_expected |= IWL_D3_NOTIF_WOWLAN_WAKE_PKT; in iwl_mvm_wait_d3_notif()
3098 struct iwl_wowlan_wake_pkt_notif *notif = (void *)pkt->data; in iwl_mvm_wait_d3_notif()
3100 if (d3_data->notif_received & IWL_D3_NOTIF_WOWLAN_WAKE_PKT) { in iwl_mvm_wait_d3_notif()
3105 d3_data->notif_received |= IWL_D3_NOTIF_WOWLAN_WAKE_PKT; in iwl_mvm_wait_d3_notif()
3108 d3_data->status, in iwl_mvm_wait_d3_notif()
3118 struct iwl_scan_offload_match_info *notif = (void *)pkt->data; in iwl_mvm_wait_d3_notif()
3120 if (d3_data->notif_received & IWL_D3_ND_MATCH_INFO) { in iwl_mvm_wait_d3_notif()
3126 d3_data->notif_received |= IWL_D3_ND_MATCH_INFO; in iwl_mvm_wait_d3_notif()
3129 d3_data->notif_expected |= IWL_D3_ND_MATCH_INFO; in iwl_mvm_wait_d3_notif()
3136 struct iwl_d3_end_notif *notif = (void *)pkt->data; in iwl_mvm_wait_d3_notif()
3138 d3_data->d3_end_flags = __le32_to_cpu(notif->flags); in iwl_mvm_wait_d3_notif()
3139 d3_data->notif_received |= IWL_D3_NOTIF_D3_END_NOTIF; in iwl_mvm_wait_d3_notif()
3147 return d3_data->notif_received == d3_data->notif_expected; in iwl_mvm_wait_d3_notif()
3158 bool reset = fw_has_capa(&mvm->fw->ucode_capa, in iwl_mvm_resume_firmware() local
3161 ret = iwl_trans_d3_resume(mvm->trans, &d3_status, test, !reset); in iwl_mvm_resume_firmware()
3166 IWL_INFO(mvm, "Device was reset during suspend\n"); in iwl_mvm_resume_firmware()
3167 return -ENOENT; in iwl_mvm_resume_firmware()
3175 if (mvm->trans->mac_cfg->device_family <= IWL_DEVICE_FAMILY_22000 && in iwl_mvm_resume_firmware()
3176 fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_D0I3_END_FIRST)) { in iwl_mvm_resume_firmware()
3203 if (mvm->fast_resume) in iwl_mvm_d3_notif_wait()
3204 iwl_init_notification_wait(&mvm->notif_wait, &wait_d3_notif, in iwl_mvm_d3_notif_wait()
3209 iwl_init_notification_wait(&mvm->notif_wait, &wait_d3_notif, in iwl_mvm_d3_notif_wait()
3214 ret = iwl_mvm_resume_firmware(mvm, d3_data->test); in iwl_mvm_d3_notif_wait()
3216 iwl_remove_notification(&mvm->notif_wait, &wait_d3_notif); in iwl_mvm_d3_notif_wait()
3220 return iwl_wait_notification(&mvm->notif_wait, &wait_d3_notif, in iwl_mvm_d3_notif_wait()
3226 return iwl_fw_lookup_notif_ver(mvm->fw, PROT_OFFLOAD_GROUP, in iwl_mvm_d3_resume_notif_based()
3228 iwl_fw_lookup_notif_ver(mvm->fw, PROT_OFFLOAD_GROUP, in iwl_mvm_d3_resume_notif_based()
3230 iwl_fw_lookup_notif_ver(mvm->fw, PROT_OFFLOAD_GROUP, in iwl_mvm_d3_resume_notif_based()
3247 bool unified_image = fw_has_capa(&mvm->fw->ucode_capa, in __iwl_mvm_resume()
3249 bool d0i3_first = fw_has_capa(&mvm->fw->ucode_capa, in __iwl_mvm_resume()
3255 mutex_lock(&mvm->mutex); in __iwl_mvm_resume()
3261 if (!test_bit(IWL_MVM_STATUS_IN_D3, &mvm->status)) { in __iwl_mvm_resume()
3267 mvm->last_reset_or_resume_time_jiffies = jiffies; in __iwl_mvm_resume()
3274 iwl_fw_dbg_read_d3_debug_data(&mvm->fwrt); in __iwl_mvm_resume()
3278 set_bit(STATUS_FW_ERROR, &mvm->trans->status); in __iwl_mvm_resume()
3282 iwl_dbg_tlv_time_point(&mvm->fwrt, in __iwl_mvm_resume()
3285 iwl_fw_dbg_collect_desc(&mvm->fwrt, in __iwl_mvm_resume()
3297 ret = -ENOMEM; in __iwl_mvm_resume()
3312 /* when reset is required we can't send these following commands */ in __iwl_mvm_resume()
3318 * can play it back when we re-intiailize the D0 firmware in __iwl_mvm_resume()
3322 /* Re-configure PPAG settings */ in __iwl_mvm_resume()
3326 /* Re-configure default SAR profile */ in __iwl_mvm_resume()
3329 if (mvm->net_detect && unified_image) { in __iwl_mvm_resume()
3330 /* If this is a non-unified image, we restart the FW, in __iwl_mvm_resume()
3332 * fails, continue and try to get the wake-up reasons, in __iwl_mvm_resume()
3346 mutex_unlock(&mvm->mutex); in __iwl_mvm_resume()
3349 kfree(d3_data.status->wake_packet); in __iwl_mvm_resume()
3353 if (!d3_data.test && !mvm->net_detect) in __iwl_mvm_resume()
3354 ieee80211_iterate_active_interfaces_mtx(mvm->hw, in __iwl_mvm_resume()
3359 clear_bit(IWL_MVM_STATUS_IN_D3, &mvm->status); in __iwl_mvm_resume()
3361 /* no need to reset the device in unified images, if successful */ in __iwl_mvm_resume()
3367 if (!iwl_fw_lookup_notif_ver(mvm->fw, PROT_OFFLOAD_GROUP, in __iwl_mvm_resume()
3382 set_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, &mvm->status); in __iwl_mvm_resume()
3396 iwl_fw_runtime_resume(&mvm->fwrt); in iwl_mvm_resume()
3405 device_set_wakeup_enable(mvm->trans->dev, enabled); in iwl_mvm_set_wakeup()
3413 lockdep_assert_held(&mvm->mutex); in iwl_mvm_fast_suspend()
3417 mvm->fast_resume = true; in iwl_mvm_fast_suspend()
3418 set_bit(IWL_MVM_STATUS_IN_D3, &mvm->status); in iwl_mvm_fast_suspend()
3427 ret = iwl_trans_d3_suspend(mvm->trans, false, false); in iwl_mvm_fast_suspend()
3441 lockdep_assert_held(&mvm->mutex); in iwl_mvm_fast_resume()
3445 mvm->last_reset_or_resume_time_jiffies = jiffies; in iwl_mvm_fast_resume()
3446 iwl_fw_dbg_read_d3_debug_data(&mvm->fwrt); in iwl_mvm_fast_resume()
3450 set_bit(STATUS_FW_ERROR, &mvm->trans->status); in iwl_mvm_fast_resume()
3455 iwl_dbg_tlv_time_point(&mvm->fwrt, in iwl_mvm_fast_resume()
3458 iwl_fw_dbg_collect_desc(&mvm->fwrt, in iwl_mvm_fast_resume()
3462 mvm->trans->state = IWL_TRANS_NO_FW; in iwl_mvm_fast_resume()
3463 ret = -ENODEV; in iwl_mvm_fast_resume()
3471 mvm->trans->state = IWL_TRANS_NO_FW; in iwl_mvm_fast_resume()
3475 clear_bit(IWL_MVM_STATUS_IN_D3, &mvm->status); in iwl_mvm_fast_resume()
3476 mvm->fast_resume = false; in iwl_mvm_fast_resume()
3484 struct iwl_mvm *mvm = inode->i_private; in iwl_mvm_d3_test_open()
3487 if (mvm->d3_test_active) in iwl_mvm_d3_test_open()
3488 return -EBUSY; in iwl_mvm_d3_test_open()
3490 file->private_data = inode->i_private; in iwl_mvm_d3_test_open()
3494 iwl_fw_runtime_suspend(&mvm->fwrt); in iwl_mvm_d3_test_open()
3498 wiphy_lock(mvm->hw->wiphy); in iwl_mvm_d3_test_open()
3499 err = __iwl_mvm_suspend(mvm->hw, mvm->hw->wiphy->wowlan_config, true); in iwl_mvm_d3_test_open()
3500 wiphy_unlock(mvm->hw->wiphy); in iwl_mvm_d3_test_open()
3503 err = -EINVAL; in iwl_mvm_d3_test_open()
3507 mvm->d3_test_active = true; in iwl_mvm_d3_test_open()
3508 mvm->keep_vif = NULL; in iwl_mvm_d3_test_open()
3515 struct iwl_mvm *mvm = file->private_data; in iwl_mvm_d3_test_read()
3521 if (mvm->d3_test_pme_ptr) { in iwl_mvm_d3_test_read()
3522 pme_asserted = iwl_trans_read_mem32(mvm->trans, in iwl_mvm_d3_test_read()
3523 mvm->d3_test_pme_ptr); in iwl_mvm_d3_test_read()
3537 "ending pseudo-D3 with timeout after ~60 seconds\n"); in iwl_mvm_d3_test_read()
3538 return -ETIMEDOUT; in iwl_mvm_d3_test_read()
3552 if (vif->type == NL80211_IFTYPE_STATION) in iwl_mvm_d3_test_disconn_work_iter()
3558 struct iwl_mvm *mvm = inode->i_private; in iwl_mvm_d3_test_release()
3559 bool unified_image = fw_has_capa(&mvm->fw->ucode_capa, in iwl_mvm_d3_test_release()
3562 mvm->d3_test_active = false; in iwl_mvm_d3_test_release()
3564 iwl_fw_dbg_read_d3_debug_data(&mvm->fwrt); in iwl_mvm_d3_test_release()
3567 wiphy_lock(mvm->hw->wiphy); in iwl_mvm_d3_test_release()
3569 wiphy_unlock(mvm->hw->wiphy); in iwl_mvm_d3_test_release()
3574 iwl_fw_runtime_resume(&mvm->fwrt); in iwl_mvm_d3_test_release()
3576 iwl_abort_notification_waits(&mvm->notif_wait); in iwl_mvm_d3_test_release()
3580 ieee80211_restart_hw(mvm->hw); in iwl_mvm_d3_test_release()
3583 while (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) && in iwl_mvm_d3_test_release()
3585 remaining_time--; in iwl_mvm_d3_test_release()
3598 mvm->hw, IEEE80211_IFACE_ITER_NORMAL, in iwl_mvm_d3_test_release()
3599 iwl_mvm_d3_test_disconn_work_iter, mvm->keep_vif); in iwl_mvm_d3_test_release()