Lines Matching +full:keys +full:- +full:per +full:- +full:group
1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
3 * Copyright (C) 2022 - 2024 Intel Corporation
17 struct iwl_mvm_vif_link_info *link_info = &mvmvif->deflink; in iwl_mvm_get_sec_sta_mask()
19 lockdep_assert_held(&mvm->mutex); in iwl_mvm_get_sec_sta_mask()
21 if (keyconf->link_id >= 0) { in iwl_mvm_get_sec_sta_mask()
22 link_info = mvmvif->link[keyconf->link_id]; in iwl_mvm_get_sec_sta_mask()
27 /* AP group keys are per link and should be on the mcast/bcast STA */ in iwl_mvm_get_sec_sta_mask()
28 if (vif->type == NL80211_IFTYPE_AP && in iwl_mvm_get_sec_sta_mask()
29 !(keyconf->flags & IEEE80211_KEY_FLAG_PAIRWISE)) { in iwl_mvm_get_sec_sta_mask()
31 if (keyconf->keyidx >= 4) in iwl_mvm_get_sec_sta_mask()
32 return BIT(link_info->bcast_sta.sta_id); in iwl_mvm_get_sec_sta_mask()
34 return BIT(link_info->mcast_sta.sta_id); in iwl_mvm_get_sec_sta_mask()
37 /* for client mode use the AP STA also for group keys */ in iwl_mvm_get_sec_sta_mask()
38 if (!sta && vif->type == NL80211_IFTYPE_STATION) in iwl_mvm_get_sec_sta_mask()
39 sta = mvmvif->ap_sta; in iwl_mvm_get_sec_sta_mask()
41 /* During remove the STA was removed and the group keys come later in iwl_mvm_get_sec_sta_mask()
43 * group keys have no sta pointer), so we don't have a STA now. in iwl_mvm_get_sec_sta_mask()
44 * Since this happens for group keys only, just use the link_info as in iwl_mvm_get_sec_sta_mask()
45 * the group keys are per link; make sure that is the case by checking in iwl_mvm_get_sec_sta_mask()
48 * it during remove, since we don't have the mvmvif->ap_sta pointer. in iwl_mvm_get_sec_sta_mask()
50 if (!sta && (keyconf->link_id >= 0 || !ieee80211_vif_is_mld(vif))) in iwl_mvm_get_sec_sta_mask()
51 return BIT(link_info->ap_sta_id); in iwl_mvm_get_sec_sta_mask()
53 /* STA should be non-NULL now, but iwl_mvm_sta_fw_id_mask() checks */ in iwl_mvm_get_sec_sta_mask()
55 /* pass link_id to filter by it if not -1 (GTK on client) */ in iwl_mvm_get_sec_sta_mask()
56 return iwl_mvm_sta_fw_id_mask(mvm, sta, keyconf->link_id); in iwl_mvm_get_sec_sta_mask()
65 bool pairwise = keyconf->flags & IEEE80211_KEY_FLAG_PAIRWISE; in iwl_mvm_get_sec_flags()
66 bool igtk = keyconf->keyidx == 4 || keyconf->keyidx == 5; in iwl_mvm_get_sec_flags()
69 lockdep_assert_held(&mvm->mutex); in iwl_mvm_get_sec_flags()
74 switch (keyconf->cipher) { in iwl_mvm_get_sec_flags()
98 if (!sta && vif->type == NL80211_IFTYPE_STATION) in iwl_mvm_get_sec_flags()
99 sta = mvmvif->ap_sta; in iwl_mvm_get_sec_flags()
108 if ((!IS_ERR_OR_NULL(sta) && sta->mfp && pairwise) || igtk) in iwl_mvm_get_sec_flags()
111 if (keyconf->flags & IEEE80211_KEY_FLAG_SPP_AMSDU) in iwl_mvm_get_sec_flags()
135 .u.modify.old_sta_mask = cpu_to_le32(data->old_sta_mask), in iwl_mvm_mld_update_sta_key()
136 .u.modify.new_sta_mask = cpu_to_le32(data->new_sta_mask), in iwl_mvm_mld_update_sta_key()
137 .u.modify.key_id = cpu_to_le32(key->keyidx), in iwl_mvm_mld_update_sta_key()
143 /* only need to do this for pairwise keys (link_id == -1) */ in iwl_mvm_mld_update_sta_key()
144 if (sta != data->sta || key->link_id >= 0) in iwl_mvm_mld_update_sta_key()
150 data->err = err; in iwl_mvm_mld_update_sta_key()
165 ieee80211_iter_keys(mvm->hw, vif, iwl_mvm_mld_update_sta_key, in iwl_mvm_mld_update_sta_keys()
191 .u.add.key_id = cpu_to_le32(keyconf->keyidx), in iwl_mvm_mld_send_key()
193 .u.add.tx_seq = cpu_to_le64(atomic64_read(&keyconf->tx_pn)), in iwl_mvm_mld_send_key()
198 if (keyconf->cipher == WLAN_CIPHER_SUITE_WEP40 || in iwl_mvm_mld_send_key()
199 keyconf->cipher == WLAN_CIPHER_SUITE_WEP104) in iwl_mvm_mld_send_key()
200 max_key_len -= IWL_SEC_WEP_KEY_OFFSET; in iwl_mvm_mld_send_key()
202 if (WARN_ON(keyconf->keylen > max_key_len)) in iwl_mvm_mld_send_key()
203 return -EINVAL; in iwl_mvm_mld_send_key()
206 return -EINVAL; in iwl_mvm_mld_send_key()
208 if (keyconf->cipher == WLAN_CIPHER_SUITE_WEP40 || in iwl_mvm_mld_send_key()
209 keyconf->cipher == WLAN_CIPHER_SUITE_WEP104) in iwl_mvm_mld_send_key()
210 memcpy(cmd.u.add.key + IWL_SEC_WEP_KEY_OFFSET, keyconf->key, in iwl_mvm_mld_send_key()
211 keyconf->keylen); in iwl_mvm_mld_send_key()
213 memcpy(cmd.u.add.key, keyconf->key, keyconf->keylen); in iwl_mvm_mld_send_key()
215 if (keyconf->cipher == WLAN_CIPHER_SUITE_TKIP) { in iwl_mvm_mld_send_key()
217 keyconf->key + NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY, in iwl_mvm_mld_send_key()
220 keyconf->key + NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY, in iwl_mvm_mld_send_key()
232 if (keyconf->cipher == WLAN_CIPHER_SUITE_WEP40 || in iwl_mvm_mld_send_key()
233 keyconf->cipher == WLAN_CIPHER_SUITE_WEP104) { in iwl_mvm_mld_send_key()
238 keyconf->keyidx, 0); in iwl_mvm_mld_send_key()
255 if (keyconf->keyidx == 4 || keyconf->keyidx == 5) { in iwl_mvm_sec_key_add()
258 /* set to -1 for non-MLO right now */ in iwl_mvm_sec_key_add()
259 if (keyconf->link_id >= 0) in iwl_mvm_sec_key_add()
260 link_id = keyconf->link_id; in iwl_mvm_sec_key_add()
262 mvm_link = mvmvif->link[link_id]; in iwl_mvm_sec_key_add()
264 return -EINVAL; in iwl_mvm_sec_key_add()
266 if (mvm_link->igtk) { in iwl_mvm_sec_key_add()
268 mvm_link->igtk->keyidx); in iwl_mvm_sec_key_add()
270 mvm_link->igtk); in iwl_mvm_sec_key_add()
277 WARN_ON(mvm_link->igtk); in iwl_mvm_sec_key_add()
285 mvm_link->igtk = keyconf; in iwl_mvm_sec_key_add()
291 keyconf->hw_key_idx = 0; in iwl_mvm_sec_key_add()
308 return -EINVAL; in _iwl_mvm_sec_key_del()
310 if (keyconf->keyidx == 4 || keyconf->keyidx == 5) { in _iwl_mvm_sec_key_del()
314 /* set to -1 for non-MLO right now */ in _iwl_mvm_sec_key_del()
315 if (keyconf->link_id >= 0) in _iwl_mvm_sec_key_del()
316 link_id = keyconf->link_id; in _iwl_mvm_sec_key_del()
318 mvm_link = mvmvif->link[link_id]; in _iwl_mvm_sec_key_del()
320 return -EINVAL; in _iwl_mvm_sec_key_del()
322 if (mvm_link->igtk == keyconf) { in _iwl_mvm_sec_key_del()
323 /* no longer in HW - mark for later */ in _iwl_mvm_sec_key_del()
324 mvm_link->igtk->hw_key_idx = STA_KEY_IDX_INVALID; in _iwl_mvm_sec_key_del()
325 mvm_link->igtk = NULL; in _iwl_mvm_sec_key_del()
329 ret = __iwl_mvm_sec_key_del(mvm, sta_mask, key_flags, keyconf->keyidx, in _iwl_mvm_sec_key_del()
335 if (keyconf->cipher == WLAN_CIPHER_SUITE_WEP40 || in _iwl_mvm_sec_key_del()
336 keyconf->cipher == WLAN_CIPHER_SUITE_WEP104) { in _iwl_mvm_sec_key_del()
339 keyconf->keyidx, flags); in _iwl_mvm_sec_key_del()
354 return -EINVAL; in iwl_mvm_sec_key_del_pasn()
356 return __iwl_mvm_sec_key_del(mvm, sta_mask, key_flags, keyconf->keyidx, in iwl_mvm_sec_key_del_pasn()
377 if (key->hw_key_idx == STA_KEY_IDX_INVALID) in iwl_mvm_sec_key_remove_ap_iter()
383 if (key->link_id >= 0 && key->link_id != link_id) in iwl_mvm_sec_key_remove_ap_iter()
387 key->hw_key_idx = STA_KEY_IDX_INVALID; in iwl_mvm_sec_key_remove_ap_iter()
396 u8 sec_key_ver = iwl_fw_lookup_cmd_ver(mvm->fw, sec_key_id, 0); in iwl_mvm_sec_key_remove_ap()
398 if (WARN_ON_ONCE(vif->type != NL80211_IFTYPE_STATION || in iwl_mvm_sec_key_remove_ap()
399 link->ap_sta_id == IWL_MVM_INVALID_STA)) in iwl_mvm_sec_key_remove_ap()
405 ieee80211_iter_keys(mvm->hw, vif, in iwl_mvm_sec_key_remove_ap()