Lines Matching +full:- +full:key
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright 2002-2005, Instant802 Networks, Inc.
4 * Copyright 2005-2006, Devicescape Software, Inc.
5 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
6 * Copyright 2007-2008 Johannes Berg <johannes@sipsolutions.net>
7 * Copyright 2013-2014 Intel Mobile Communications GmbH
8 * Copyright 2015-2017 Intel Deutschland GmbH
9 * Copyright 2018-2020, 2022-2025 Intel Corporation
23 #include "driver-ops.h"
32 * DOC: Key handling basics
34 * Key handling in mac80211 is done based on per-interface (sub_if_data)
35 * keys and per-station keys. Since each station belongs to an interface,
36 * each station key also belongs to that interface.
38 * Hardware acceleration is done on a best-effort basis for algorithms
39 * that are implemented in software, for each key the hardware is asked
40 * to enable that key for offloading but if it cannot do that the key is
43 * There is currently no way of knowing whether a key is handled in SW
46 * All key management is internally protected by a mutex. Within all
47 * other parts of mac80211, key references are, just as STA structure
49 * unprotected, namely the key->sta dereferences within the hardware
51 * remove the key which waits for an RCU grace period.
61 if (sdata->vif.type != NL80211_IFTYPE_AP) in update_vlan_tailroom_need_count()
65 lockdep_assert_wiphy(sdata->local->hw.wiphy); in update_vlan_tailroom_need_count()
69 list_for_each_entry_rcu(vlan, &sdata->u.ap.vlans, u.vlan.list) in update_vlan_tailroom_need_count()
70 vlan->crypto_tx_tailroom_needed_cnt += delta; in update_vlan_tailroom_need_count()
82 * 1. SKB resize was skipped because no key was added but just before in increment_tailroom_need_count()
83 * the xmit key is added and SW encryption kicks off. in increment_tailroom_need_count()
86 * just before xmit one of the key is deleted and SW encryption kicks in increment_tailroom_need_count()
96 lockdep_assert_wiphy(sdata->local->hw.wiphy); in increment_tailroom_need_count()
100 if (!sdata->crypto_tx_tailroom_needed_cnt++) { in increment_tailroom_need_count()
103 * encryption at all if the count transition is from 0 -> 1. in increment_tailroom_need_count()
112 lockdep_assert_wiphy(sdata->local->hw.wiphy); in decrease_tailroom_need_count()
114 WARN_ON_ONCE(sdata->crypto_tx_tailroom_needed_cnt < delta); in decrease_tailroom_need_count()
116 update_vlan_tailroom_need_count(sdata, -delta); in decrease_tailroom_need_count()
117 sdata->crypto_tx_tailroom_needed_cnt -= delta; in decrease_tailroom_need_count()
120 static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key) in ieee80211_key_enable_hw_accel() argument
122 struct ieee80211_sub_if_data *sdata = key->sdata; in ieee80211_key_enable_hw_accel()
124 int ret = -EOPNOTSUPP; in ieee80211_key_enable_hw_accel()
127 lockdep_assert_wiphy(key->local->hw.wiphy); in ieee80211_key_enable_hw_accel()
129 if (key->flags & KEY_FLAG_TAINTED) { in ieee80211_key_enable_hw_accel()
130 /* If we get here, it's during resume and the key is in ieee80211_key_enable_hw_accel()
137 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE && in ieee80211_key_enable_hw_accel()
138 !(key->conf.flags & (IEEE80211_KEY_FLAG_GENERATE_MMIC | in ieee80211_key_enable_hw_accel()
143 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE; in ieee80211_key_enable_hw_accel()
144 return -EINVAL; in ieee80211_key_enable_hw_accel()
147 if (!key->local->ops->set_key) in ieee80211_key_enable_hw_accel()
150 sta = key->sta; in ieee80211_key_enable_hw_accel()
153 * If this is a per-STA GTK, check if it in ieee80211_key_enable_hw_accel()
156 if (sta && !(key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE) && in ieee80211_key_enable_hw_accel()
157 !ieee80211_hw_check(&key->local->hw, SUPPORTS_PER_STA_GTK)) in ieee80211_key_enable_hw_accel()
160 if (sta && !sta->uploaded) in ieee80211_key_enable_hw_accel()
163 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in ieee80211_key_enable_hw_accel()
168 if (!(key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE)) { in ieee80211_key_enable_hw_accel()
174 if (key->conf.link_id >= 0 && sdata->vif.active_links && in ieee80211_key_enable_hw_accel()
175 !(sdata->vif.active_links & BIT(key->conf.link_id))) in ieee80211_key_enable_hw_accel()
178 ret = drv_set_key(key->local, SET_KEY, sdata, in ieee80211_key_enable_hw_accel()
179 sta ? &sta->sta : NULL, &key->conf); in ieee80211_key_enable_hw_accel()
182 key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE; in ieee80211_key_enable_hw_accel()
184 if (!(key->conf.flags & (IEEE80211_KEY_FLAG_GENERATE_MMIC | in ieee80211_key_enable_hw_accel()
189 WARN_ON((key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE) && in ieee80211_key_enable_hw_accel()
190 (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)); in ieee80211_key_enable_hw_accel()
192 WARN_ON((key->conf.flags & IEEE80211_KEY_FLAG_PUT_MIC_SPACE) && in ieee80211_key_enable_hw_accel()
193 (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC)); in ieee80211_key_enable_hw_accel()
198 if (ret != -ENOSPC && ret != -EOPNOTSUPP && ret != 1) in ieee80211_key_enable_hw_accel()
200 "failed to set key (%d, %pM) to hardware (%d)\n", in ieee80211_key_enable_hw_accel()
201 key->conf.keyidx, in ieee80211_key_enable_hw_accel()
202 sta ? sta->sta.addr : bcast_addr, ret); in ieee80211_key_enable_hw_accel()
205 switch (key->conf.cipher) { in ieee80211_key_enable_hw_accel()
217 /* all of these we can do in software - if driver can */ in ieee80211_key_enable_hw_accel()
220 if (ieee80211_hw_check(&key->local->hw, SW_CRYPTO_CONTROL)) in ieee80211_key_enable_hw_accel()
221 return -EINVAL; in ieee80211_key_enable_hw_accel()
224 return -EINVAL; in ieee80211_key_enable_hw_accel()
228 static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key) in ieee80211_key_disable_hw_accel() argument
236 if (!key || !key->local->ops->set_key) in ieee80211_key_disable_hw_accel()
239 if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) in ieee80211_key_disable_hw_accel()
242 sta = key->sta; in ieee80211_key_disable_hw_accel()
243 sdata = key->sdata; in ieee80211_key_disable_hw_accel()
245 lockdep_assert_wiphy(key->local->hw.wiphy); in ieee80211_key_disable_hw_accel()
247 if (key->conf.link_id >= 0 && sdata->vif.active_links && in ieee80211_key_disable_hw_accel()
248 !(sdata->vif.active_links & BIT(key->conf.link_id))) in ieee80211_key_disable_hw_accel()
251 if (!(key->conf.flags & (IEEE80211_KEY_FLAG_GENERATE_MMIC | in ieee80211_key_disable_hw_accel()
256 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE; in ieee80211_key_disable_hw_accel()
257 ret = drv_set_key(key->local, DISABLE_KEY, sdata, in ieee80211_key_disable_hw_accel()
258 sta ? &sta->sta : NULL, &key->conf); in ieee80211_key_disable_hw_accel()
262 "failed to remove key (%d, %pM) from hardware (%d)\n", in ieee80211_key_disable_hw_accel()
263 key->conf.keyidx, in ieee80211_key_disable_hw_accel()
264 sta ? sta->sta.addr : bcast_addr, ret); in ieee80211_key_disable_hw_accel()
267 static int _ieee80211_set_tx_key(struct ieee80211_key *key, bool force) in _ieee80211_set_tx_key() argument
269 struct sta_info *sta = key->sta; in _ieee80211_set_tx_key()
270 struct ieee80211_local *local = key->local; in _ieee80211_set_tx_key()
272 lockdep_assert_wiphy(local->hw.wiphy); in _ieee80211_set_tx_key()
276 sta->ptk_idx = key->conf.keyidx; in _ieee80211_set_tx_key()
278 if (force || !ieee80211_hw_check(&local->hw, AMPDU_KEYBORDER_SUPPORT)) in _ieee80211_set_tx_key()
285 int ieee80211_set_tx_key(struct ieee80211_key *key) in ieee80211_set_tx_key() argument
287 return _ieee80211_set_tx_key(key, false); in ieee80211_set_tx_key()
293 struct ieee80211_local *local = new->local; in ieee80211_pairwise_rekey()
294 struct sta_info *sta = new->sta; in ieee80211_pairwise_rekey()
297 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_pairwise_rekey()
299 if (new->conf.flags & IEEE80211_KEY_FLAG_NO_AUTO_TX) { in ieee80211_pairwise_rekey()
300 /* Extended Key ID key install, initial one or rekey */ in ieee80211_pairwise_rekey()
302 if (sta->ptk_idx != INVALID_PTK_KEYIDX && in ieee80211_pairwise_rekey()
303 !ieee80211_hw_check(&local->hw, AMPDU_KEYBORDER_SUPPORT)) { in ieee80211_pairwise_rekey()
304 /* Aggregation Sessions with Extended Key ID must not in ieee80211_pairwise_rekey()
305 * mix MPDUs with different keyIDs within one A-MPDU. in ieee80211_pairwise_rekey()
308 * ensure there are no A-MPDUs when the driver is not in ieee80211_pairwise_rekey()
309 * supporting A-MPDU key borders. (Blocking Tx only in ieee80211_pairwise_rekey()
319 /* Rekey without Extended Key ID. in ieee80211_pairwise_rekey()
324 if (!(old->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) in ieee80211_pairwise_rekey()
327 /* Stop Tx till we are on the new key */ in ieee80211_pairwise_rekey()
328 old->flags |= KEY_FLAG_TAINTED; in ieee80211_pairwise_rekey()
330 if (ieee80211_hw_check(&local->hw, AMPDU_AGGREGATION)) { in ieee80211_pairwise_rekey()
335 if (!wiphy_ext_feature_isset(local->hw.wiphy, in ieee80211_pairwise_rekey()
338 sta->sta.addr); in ieee80211_pairwise_rekey()
342 ieee80211_flush_queues(local, old->sdata, false); in ieee80211_pairwise_rekey()
350 struct ieee80211_sub_if_data *sdata = link->sdata; in __ieee80211_set_default_key()
351 struct ieee80211_key *key = NULL; in __ieee80211_set_default_key() local
353 lockdep_assert_wiphy(sdata->local->hw.wiphy); in __ieee80211_set_default_key()
356 key = wiphy_dereference(sdata->local->hw.wiphy, in __ieee80211_set_default_key()
357 sdata->keys[idx]); in __ieee80211_set_default_key()
358 if (!key) in __ieee80211_set_default_key()
359 key = wiphy_dereference(sdata->local->hw.wiphy, in __ieee80211_set_default_key()
360 link->gtk[idx]); in __ieee80211_set_default_key()
364 rcu_assign_pointer(sdata->default_unicast_key, key); in __ieee80211_set_default_key()
366 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN) in __ieee80211_set_default_key()
367 drv_set_default_unicast_key(sdata->local, sdata, idx); in __ieee80211_set_default_key()
371 rcu_assign_pointer(link->default_multicast_key, key); in __ieee80211_set_default_key()
379 lockdep_assert_wiphy(link->sdata->local->hw.wiphy); in ieee80211_set_default_key()
387 struct ieee80211_sub_if_data *sdata = link->sdata; in __ieee80211_set_default_mgmt_key()
388 struct ieee80211_key *key = NULL; in __ieee80211_set_default_mgmt_key() local
390 lockdep_assert_wiphy(sdata->local->hw.wiphy); in __ieee80211_set_default_mgmt_key()
394 key = wiphy_dereference(sdata->local->hw.wiphy, in __ieee80211_set_default_mgmt_key()
395 link->gtk[idx]); in __ieee80211_set_default_mgmt_key()
397 rcu_assign_pointer(link->default_mgmt_key, key); in __ieee80211_set_default_mgmt_key()
405 lockdep_assert_wiphy(link->sdata->local->hw.wiphy); in ieee80211_set_default_mgmt_key()
413 struct ieee80211_sub_if_data *sdata = link->sdata; in __ieee80211_set_default_beacon_key()
414 struct ieee80211_key *key = NULL; in __ieee80211_set_default_beacon_key() local
416 lockdep_assert_wiphy(sdata->local->hw.wiphy); in __ieee80211_set_default_beacon_key()
421 key = wiphy_dereference(sdata->local->hw.wiphy, in __ieee80211_set_default_beacon_key()
422 link->gtk[idx]); in __ieee80211_set_default_beacon_key()
424 rcu_assign_pointer(link->default_beacon_key, key); in __ieee80211_set_default_beacon_key()
432 lockdep_assert_wiphy(link->sdata->local->hw.wiphy); in ieee80211_set_default_beacon_key()
444 struct link_sta_info *link_sta = sta ? &sta->deflink : NULL; in ieee80211_key_replace()
451 lockdep_assert_wiphy(sdata->local->hw.wiphy); in ieee80211_key_replace()
458 idx = new->conf.keyidx; in ieee80211_key_replace()
459 is_wep = new->conf.cipher == WLAN_CIPHER_SUITE_WEP40 || in ieee80211_key_replace()
460 new->conf.cipher == WLAN_CIPHER_SUITE_WEP104; in ieee80211_key_replace()
461 link_id = new->conf.link_id; in ieee80211_key_replace()
463 idx = old->conf.keyidx; in ieee80211_key_replace()
464 is_wep = old->conf.cipher == WLAN_CIPHER_SUITE_WEP40 || in ieee80211_key_replace()
465 old->conf.cipher == WLAN_CIPHER_SUITE_WEP104; in ieee80211_key_replace()
466 link_id = old->conf.link_id; in ieee80211_key_replace()
469 if (WARN(old && old->conf.link_id != link_id, in ieee80211_key_replace()
471 old->conf.link_id, link_id)) in ieee80211_key_replace()
472 return -EINVAL; in ieee80211_key_replace()
476 link = sdata_dereference(sdata->link[link_id], sdata); in ieee80211_key_replace()
478 return -ENOLINK; in ieee80211_key_replace()
482 link_sta = rcu_dereference_protected(sta->link[link_id], in ieee80211_key_replace()
483 lockdep_is_held(&sta->local->hw.wiphy->mtx)); in ieee80211_key_replace()
485 return -ENOLINK; in ieee80211_key_replace()
488 link = &sdata->deflink; in ieee80211_key_replace()
492 return -EINVAL; in ieee80211_key_replace()
494 WARN_ON(new && old && new->conf.keyidx != old->conf.keyidx); in ieee80211_key_replace()
497 /* Unicast rekey needs special handling. With Extended Key ID in ieee80211_key_replace()
504 if (old->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) { in ieee80211_key_replace()
511 if (!new->local->wowlan) { in ieee80211_key_replace()
513 } else if (link_id < 0 || !sdata->vif.active_links || in ieee80211_key_replace()
514 BIT(link_id) & sdata->vif.active_links) { in ieee80211_key_replace()
515 new->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE; in ieee80211_key_replace()
516 if (!(new->conf.flags & (IEEE80211_KEY_FLAG_GENERATE_MMIC | in ieee80211_key_replace()
527 list_add_tail_rcu(&new->list, &sdata->key_list); in ieee80211_key_replace()
531 rcu_assign_pointer(sta->ptk[idx], new); in ieee80211_key_replace()
533 !(new->conf.flags & IEEE80211_KEY_FLAG_NO_AUTO_TX)) in ieee80211_key_replace()
536 rcu_assign_pointer(link_sta->gtk[idx], new); in ieee80211_key_replace()
538 /* Only needed for transition from no key -> key. in ieee80211_key_replace()
539 * Still triggers unnecessary when using Extended Key ID in ieee80211_key_replace()
540 * and installing the second key ID the first time. in ieee80211_key_replace()
546 old == wiphy_dereference(sdata->local->hw.wiphy, in ieee80211_key_replace()
547 sdata->default_unicast_key); in ieee80211_key_replace()
549 old == wiphy_dereference(sdata->local->hw.wiphy, in ieee80211_key_replace()
550 link->default_multicast_key); in ieee80211_key_replace()
552 old == wiphy_dereference(sdata->local->hw.wiphy, in ieee80211_key_replace()
553 link->default_mgmt_key); in ieee80211_key_replace()
555 old == wiphy_dereference(sdata->local->hw.wiphy, in ieee80211_key_replace()
556 link->default_beacon_key); in ieee80211_key_replace()
559 __ieee80211_set_default_key(link, -1, true, false); in ieee80211_key_replace()
561 __ieee80211_set_default_key(link, -1, false, true); in ieee80211_key_replace()
563 __ieee80211_set_default_mgmt_key(link, -1); in ieee80211_key_replace()
565 __ieee80211_set_default_beacon_key(link, -1); in ieee80211_key_replace()
568 rcu_assign_pointer(sdata->keys[idx], new); in ieee80211_key_replace()
570 rcu_assign_pointer(link->gtk[idx], new); in ieee80211_key_replace()
573 __ieee80211_set_default_key(link, new->conf.keyidx, in ieee80211_key_replace()
576 __ieee80211_set_default_key(link, new->conf.keyidx, in ieee80211_key_replace()
580 new->conf.keyidx); in ieee80211_key_replace()
583 new->conf.keyidx); in ieee80211_key_replace()
587 list_del_rcu(&old->list); in ieee80211_key_replace()
597 struct ieee80211_key *key; in ieee80211_key_alloc() local
603 return ERR_PTR(-EINVAL); in ieee80211_key_alloc()
605 key = kzalloc(sizeof(struct ieee80211_key) + key_len, GFP_KERNEL); in ieee80211_key_alloc()
606 if (!key) in ieee80211_key_alloc()
607 return ERR_PTR(-ENOMEM); in ieee80211_key_alloc()
611 * key to the hardware if possible. in ieee80211_key_alloc()
613 key->conf.flags = 0; in ieee80211_key_alloc()
614 key->flags = 0; in ieee80211_key_alloc()
616 key->conf.link_id = -1; in ieee80211_key_alloc()
617 key->conf.cipher = cipher; in ieee80211_key_alloc()
618 key->conf.keyidx = idx; in ieee80211_key_alloc()
619 key->conf.keylen = key_len; in ieee80211_key_alloc()
623 key->conf.iv_len = IEEE80211_WEP_IV_LEN; in ieee80211_key_alloc()
624 key->conf.icv_len = IEEE80211_WEP_ICV_LEN; in ieee80211_key_alloc()
627 key->conf.iv_len = IEEE80211_TKIP_IV_LEN; in ieee80211_key_alloc()
628 key->conf.icv_len = IEEE80211_TKIP_ICV_LEN; in ieee80211_key_alloc()
631 key->u.tkip.rx[i].iv32 = in ieee80211_key_alloc()
633 key->u.tkip.rx[i].iv16 = in ieee80211_key_alloc()
637 spin_lock_init(&key->u.tkip.txlock); in ieee80211_key_alloc()
640 key->conf.iv_len = IEEE80211_CCMP_HDR_LEN; in ieee80211_key_alloc()
641 key->conf.icv_len = IEEE80211_CCMP_MIC_LEN; in ieee80211_key_alloc()
645 key->u.ccmp.rx_pn[i][j] = in ieee80211_key_alloc()
646 seq[IEEE80211_CCMP_PN_LEN - j - 1]; in ieee80211_key_alloc()
649 * Initialize AES key state here as an optimization so that in ieee80211_key_alloc()
652 key->u.ccmp.tfm = ieee80211_aes_key_setup_encrypt( in ieee80211_key_alloc()
654 if (IS_ERR(key->u.ccmp.tfm)) { in ieee80211_key_alloc()
655 err = PTR_ERR(key->u.ccmp.tfm); in ieee80211_key_alloc()
656 kfree(key); in ieee80211_key_alloc()
661 key->conf.iv_len = IEEE80211_CCMP_256_HDR_LEN; in ieee80211_key_alloc()
662 key->conf.icv_len = IEEE80211_CCMP_256_MIC_LEN; in ieee80211_key_alloc()
665 key->u.ccmp.rx_pn[i][j] = in ieee80211_key_alloc()
666 seq[IEEE80211_CCMP_256_PN_LEN - j - 1]; in ieee80211_key_alloc()
667 /* Initialize AES key state here as an optimization so that in ieee80211_key_alloc()
670 key->u.ccmp.tfm = ieee80211_aes_key_setup_encrypt( in ieee80211_key_alloc()
672 if (IS_ERR(key->u.ccmp.tfm)) { in ieee80211_key_alloc()
673 err = PTR_ERR(key->u.ccmp.tfm); in ieee80211_key_alloc()
674 kfree(key); in ieee80211_key_alloc()
680 key->conf.iv_len = 0; in ieee80211_key_alloc()
682 key->conf.icv_len = sizeof(struct ieee80211_mmie); in ieee80211_key_alloc()
684 key->conf.icv_len = sizeof(struct ieee80211_mmie_16); in ieee80211_key_alloc()
687 key->u.aes_cmac.rx_pn[j] = in ieee80211_key_alloc()
688 seq[IEEE80211_CMAC_PN_LEN - j - 1]; in ieee80211_key_alloc()
690 * Initialize AES key state here as an optimization so that in ieee80211_key_alloc()
693 key->u.aes_cmac.tfm = in ieee80211_key_alloc()
695 if (IS_ERR(key->u.aes_cmac.tfm)) { in ieee80211_key_alloc()
696 err = PTR_ERR(key->u.aes_cmac.tfm); in ieee80211_key_alloc()
697 kfree(key); in ieee80211_key_alloc()
703 key->conf.iv_len = 0; in ieee80211_key_alloc()
704 key->conf.icv_len = sizeof(struct ieee80211_mmie_16); in ieee80211_key_alloc()
707 key->u.aes_gmac.rx_pn[j] = in ieee80211_key_alloc()
708 seq[IEEE80211_GMAC_PN_LEN - j - 1]; in ieee80211_key_alloc()
709 /* Initialize AES key state here as an optimization so that in ieee80211_key_alloc()
712 key->u.aes_gmac.tfm = in ieee80211_key_alloc()
714 if (IS_ERR(key->u.aes_gmac.tfm)) { in ieee80211_key_alloc()
715 err = PTR_ERR(key->u.aes_gmac.tfm); in ieee80211_key_alloc()
716 kfree(key); in ieee80211_key_alloc()
722 key->conf.iv_len = IEEE80211_GCMP_HDR_LEN; in ieee80211_key_alloc()
723 key->conf.icv_len = IEEE80211_GCMP_MIC_LEN; in ieee80211_key_alloc()
726 key->u.gcmp.rx_pn[i][j] = in ieee80211_key_alloc()
727 seq[IEEE80211_GCMP_PN_LEN - j - 1]; in ieee80211_key_alloc()
728 /* Initialize AES key state here as an optimization so that in ieee80211_key_alloc()
731 key->u.gcmp.tfm = ieee80211_aes_gcm_key_setup_encrypt(key_data, in ieee80211_key_alloc()
733 if (IS_ERR(key->u.gcmp.tfm)) { in ieee80211_key_alloc()
734 err = PTR_ERR(key->u.gcmp.tfm); in ieee80211_key_alloc()
735 kfree(key); in ieee80211_key_alloc()
740 memcpy(key->conf.key, key_data, key_len); in ieee80211_key_alloc()
741 INIT_LIST_HEAD(&key->list); in ieee80211_key_alloc()
743 return key; in ieee80211_key_alloc()
746 static void ieee80211_key_free_common(struct ieee80211_key *key) in ieee80211_key_free_common() argument
748 switch (key->conf.cipher) { in ieee80211_key_free_common()
751 ieee80211_aes_key_free(key->u.ccmp.tfm); in ieee80211_key_free_common()
755 ieee80211_aes_cmac_key_free(key->u.aes_cmac.tfm); in ieee80211_key_free_common()
759 ieee80211_aes_gmac_key_free(key->u.aes_gmac.tfm); in ieee80211_key_free_common()
763 ieee80211_aes_gcm_key_free(key->u.gcmp.tfm); in ieee80211_key_free_common()
766 kfree_sensitive(key); in ieee80211_key_free_common()
769 static void __ieee80211_key_destroy(struct ieee80211_key *key, in __ieee80211_key_destroy() argument
772 if (key->local) { in __ieee80211_key_destroy()
773 struct ieee80211_sub_if_data *sdata = key->sdata; in __ieee80211_key_destroy()
775 ieee80211_debugfs_key_remove(key); in __ieee80211_key_destroy()
779 sdata->crypto_tx_tailroom_pending_dec++; in __ieee80211_key_destroy()
780 wiphy_delayed_work_queue(sdata->local->hw.wiphy, in __ieee80211_key_destroy()
781 &sdata->dec_tailroom_needed_wk, in __ieee80211_key_destroy()
788 ieee80211_key_free_common(key); in __ieee80211_key_destroy()
791 static void ieee80211_key_destroy(struct ieee80211_key *key, in ieee80211_key_destroy() argument
794 if (!key) in ieee80211_key_destroy()
798 * Synchronize so the TX path and rcu key iterators in ieee80211_key_destroy()
799 * can no longer be using this key before we free/remove it. in ieee80211_key_destroy()
803 __ieee80211_key_destroy(key, delay_tailroom); in ieee80211_key_destroy()
806 void ieee80211_key_free_unused(struct ieee80211_key *key) in ieee80211_key_free_unused() argument
808 if (!key) in ieee80211_key_free_unused()
811 WARN_ON(key->sdata || key->local); in ieee80211_key_free_unused()
812 ieee80211_key_free_common(key); in ieee80211_key_free_unused()
822 if (!old || new->conf.keylen != old->conf.keylen) in ieee80211_key_identical()
825 tk_old = old->conf.key; in ieee80211_key_identical()
826 tk_new = new->conf.key; in ieee80211_key_identical()
829 * In station mode, don't compare the TX MIC key, as it's never used in ieee80211_key_identical()
833 if (sdata->vif.type == NL80211_IFTYPE_STATION && in ieee80211_key_identical()
834 new->conf.cipher == WLAN_CIPHER_SUITE_TKIP && in ieee80211_key_identical()
835 new->conf.keylen == WLAN_KEY_LEN_TKIP && in ieee80211_key_identical()
836 !(new->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE)) { in ieee80211_key_identical()
845 return !crypto_memneq(tk_old, tk_new, new->conf.keylen); in ieee80211_key_identical()
848 int ieee80211_key_link(struct ieee80211_key *key, in ieee80211_key_link() argument
852 struct ieee80211_sub_if_data *sdata = link->sdata; in ieee80211_key_link()
855 int idx = key->conf.keyidx; in ieee80211_key_link()
856 bool pairwise = key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE; in ieee80211_key_link()
858 * We want to delay tailroom updates only for station - in that in ieee80211_key_link()
862 bool delay_tailroom = sdata->vif.type == NL80211_IFTYPE_STATION; in ieee80211_key_link()
865 lockdep_assert_wiphy(sdata->local->hw.wiphy); in ieee80211_key_link()
870 old_key = wiphy_dereference(sdata->local->hw.wiphy, in ieee80211_key_link()
871 sta->ptk[idx]); in ieee80211_key_link()
872 alt_key = wiphy_dereference(sdata->local->hw.wiphy, in ieee80211_key_link()
873 sta->ptk[idx ^ 1]); in ieee80211_key_link()
875 /* The rekey code assumes that the old and new key are using in ieee80211_key_link()
878 if ((alt_key && alt_key->conf.cipher != key->conf.cipher) || in ieee80211_key_link()
879 (old_key && old_key->conf.cipher != key->conf.cipher)) { in ieee80211_key_link()
880 ret = -EOPNOTSUPP; in ieee80211_key_link()
884 struct link_sta_info *link_sta = &sta->deflink; in ieee80211_key_link()
885 int link_id = key->conf.link_id; in ieee80211_key_link()
888 link_sta = rcu_dereference_protected(sta->link[link_id], in ieee80211_key_link()
889 lockdep_is_held(&sta->local->hw.wiphy->mtx)); in ieee80211_key_link()
891 ret = -ENOLINK; in ieee80211_key_link()
896 old_key = wiphy_dereference(sdata->local->hw.wiphy, in ieee80211_key_link()
897 link_sta->gtk[idx]); in ieee80211_key_link()
900 old_key = wiphy_dereference(sdata->local->hw.wiphy, in ieee80211_key_link()
901 sdata->keys[idx]); in ieee80211_key_link()
903 old_key = wiphy_dereference(sdata->local->hw.wiphy, in ieee80211_key_link()
904 link->gtk[idx]); in ieee80211_key_link()
907 /* Non-pairwise keys must also not switch the cipher on rekey */ in ieee80211_key_link()
909 if (old_key && old_key->conf.cipher != key->conf.cipher) { in ieee80211_key_link()
910 ret = -EOPNOTSUPP; in ieee80211_key_link()
916 * Silently accept key re-installation without really installing the in ieee80211_key_link()
917 * new version of the key to avoid nonce reuse or replay issues. in ieee80211_key_link()
919 if (ieee80211_key_identical(sdata, old_key, key)) { in ieee80211_key_link()
920 ret = -EALREADY; in ieee80211_key_link()
924 key->local = sdata->local; in ieee80211_key_link()
925 key->sdata = sdata; in ieee80211_key_link()
926 key->sta = sta; in ieee80211_key_link()
929 * Assign a unique ID to every key so we can easily prevent mixed in ieee80211_key_link()
930 * key and fragment cache attacks. in ieee80211_key_link()
932 key->color = atomic_inc_return(&key_color); in ieee80211_key_link()
935 if (sta && sta->sta.spp_amsdu) in ieee80211_key_link()
936 key->conf.flags |= IEEE80211_KEY_FLAG_SPP_AMSDU; in ieee80211_key_link()
940 ret = ieee80211_key_replace(sdata, link, sta, pairwise, old_key, key); in ieee80211_key_link()
943 ieee80211_debugfs_key_add(key); in ieee80211_key_link()
946 ieee80211_key_free(key, delay_tailroom); in ieee80211_key_link()
949 key = NULL; in ieee80211_key_link()
952 ieee80211_key_free_unused(key); in ieee80211_key_link()
956 void ieee80211_key_free(struct ieee80211_key *key, bool delay_tailroom) in ieee80211_key_free() argument
958 if (!key) in ieee80211_key_free()
962 * Replace key with nothingness if it was ever used. in ieee80211_key_free()
964 if (key->sdata) in ieee80211_key_free()
965 ieee80211_key_replace(key->sdata, NULL, key->sta, in ieee80211_key_free()
966 key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE, in ieee80211_key_free()
967 key, NULL); in ieee80211_key_free()
968 ieee80211_key_destroy(key, delay_tailroom); in ieee80211_key_free()
973 struct ieee80211_key *key; in ieee80211_reenable_keys() local
976 lockdep_assert_wiphy(sdata->local->hw.wiphy); in ieee80211_reenable_keys()
978 sdata->crypto_tx_tailroom_needed_cnt = 0; in ieee80211_reenable_keys()
979 sdata->crypto_tx_tailroom_pending_dec = 0; in ieee80211_reenable_keys()
981 if (sdata->vif.type == NL80211_IFTYPE_AP) { in ieee80211_reenable_keys()
982 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) { in ieee80211_reenable_keys()
983 vlan->crypto_tx_tailroom_needed_cnt = 0; in ieee80211_reenable_keys()
984 vlan->crypto_tx_tailroom_pending_dec = 0; in ieee80211_reenable_keys()
989 list_for_each_entry(key, &sdata->key_list, list) { in ieee80211_reenable_keys()
991 ieee80211_key_enable_hw_accel(key); in ieee80211_reenable_keys()
999 struct ieee80211_key *key, in ieee80211_key_iter() argument
1003 struct ieee80211_key_conf *key, in ieee80211_key_iter() argument
1008 if (key->sta && key->sta->removed) in ieee80211_key_iter()
1010 if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) in ieee80211_key_iter()
1012 iter(hw, vif, key->sta ? &key->sta->sta : NULL, in ieee80211_key_iter()
1013 &key->conf, iter_data); in ieee80211_key_iter()
1021 struct ieee80211_key_conf *key, in ieee80211_iter_keys() argument
1026 struct ieee80211_key *key, *tmp; in ieee80211_iter_keys() local
1029 lockdep_assert_wiphy(hw->wiphy); in ieee80211_iter_keys()
1033 list_for_each_entry_safe(key, tmp, &sdata->key_list, list) in ieee80211_iter_keys()
1034 ieee80211_key_iter(hw, vif, key, iter, iter_data); in ieee80211_iter_keys()
1036 list_for_each_entry(sdata, &local->interfaces, list) in ieee80211_iter_keys()
1037 list_for_each_entry_safe(key, tmp, in ieee80211_iter_keys()
1038 &sdata->key_list, list) in ieee80211_iter_keys()
1039 ieee80211_key_iter(hw, &sdata->vif, key, in ieee80211_iter_keys()
1051 struct ieee80211_key_conf *key, in _ieee80211_iter_keys_rcu() argument
1055 struct ieee80211_key *key; in _ieee80211_iter_keys_rcu() local
1057 list_for_each_entry_rcu(key, &sdata->key_list, list) in _ieee80211_iter_keys_rcu()
1058 ieee80211_key_iter(hw, &sdata->vif, key, iter, iter_data); in _ieee80211_iter_keys_rcu()
1066 struct ieee80211_key_conf *key, in ieee80211_iter_keys_rcu() argument
1077 list_for_each_entry_rcu(sdata, &local->interfaces, list) in ieee80211_iter_keys_rcu()
1086 struct ieee80211_key *key, *tmp; in ieee80211_free_keys_iface() local
1089 sdata->crypto_tx_tailroom_pending_dec); in ieee80211_free_keys_iface()
1090 sdata->crypto_tx_tailroom_pending_dec = 0; in ieee80211_free_keys_iface()
1095 list_for_each_entry_safe(key, tmp, &sdata->key_list, list) { in ieee80211_free_keys_iface()
1096 ieee80211_key_replace(key->sdata, NULL, key->sta, in ieee80211_free_keys_iface()
1097 key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE, in ieee80211_free_keys_iface()
1098 key, NULL); in ieee80211_free_keys_iface()
1099 list_add_tail(&key->list, keys); in ieee80211_free_keys_iface()
1108 struct ieee80211_sub_if_data *sdata = link->sdata; in ieee80211_remove_link_keys()
1109 struct ieee80211_local *local = sdata->local; in ieee80211_remove_link_keys()
1110 struct ieee80211_key *key, *tmp; in ieee80211_remove_link_keys() local
1112 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_remove_link_keys()
1114 list_for_each_entry_safe(key, tmp, &sdata->key_list, list) { in ieee80211_remove_link_keys()
1115 if (key->conf.link_id != link->link_id) in ieee80211_remove_link_keys()
1117 ieee80211_key_replace(key->sdata, link, key->sta, in ieee80211_remove_link_keys()
1118 key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE, in ieee80211_remove_link_keys()
1119 key, NULL); in ieee80211_remove_link_keys()
1120 list_add_tail(&key->list, keys); in ieee80211_remove_link_keys()
1127 struct ieee80211_key *key, *tmp; in ieee80211_free_key_list() local
1129 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_free_key_list()
1131 list_for_each_entry_safe(key, tmp, keys, list) in ieee80211_free_key_list()
1132 __ieee80211_key_destroy(key, false); in ieee80211_free_key_list()
1138 struct ieee80211_local *local = sdata->local; in ieee80211_free_keys()
1141 struct ieee80211_key *key, *tmp; in ieee80211_free_keys() local
1144 wiphy_delayed_work_cancel(local->hw.wiphy, in ieee80211_free_keys()
1145 &sdata->dec_tailroom_needed_wk); in ieee80211_free_keys()
1147 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_free_keys()
1151 if (sdata->vif.type == NL80211_IFTYPE_AP) { in ieee80211_free_keys()
1152 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) in ieee80211_free_keys()
1158 list_for_each_entry_safe(key, tmp, &keys, list) in ieee80211_free_keys()
1159 __ieee80211_key_destroy(key, false); in ieee80211_free_keys()
1161 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in ieee80211_free_keys()
1162 if (sdata->bss) { in ieee80211_free_keys()
1163 master = container_of(sdata->bss, in ieee80211_free_keys()
1167 WARN_ON_ONCE(sdata->crypto_tx_tailroom_needed_cnt != in ieee80211_free_keys()
1168 master->crypto_tx_tailroom_needed_cnt); in ieee80211_free_keys()
1171 WARN_ON_ONCE(sdata->crypto_tx_tailroom_needed_cnt || in ieee80211_free_keys()
1172 sdata->crypto_tx_tailroom_pending_dec); in ieee80211_free_keys()
1175 if (sdata->vif.type == NL80211_IFTYPE_AP) { in ieee80211_free_keys()
1176 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) in ieee80211_free_keys()
1177 WARN_ON_ONCE(vlan->crypto_tx_tailroom_needed_cnt || in ieee80211_free_keys()
1178 vlan->crypto_tx_tailroom_pending_dec); in ieee80211_free_keys()
1185 struct ieee80211_key *key; in ieee80211_free_sta_keys() local
1188 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_free_sta_keys()
1190 for (i = 0; i < ARRAY_SIZE(sta->deflink.gtk); i++) { in ieee80211_free_sta_keys()
1191 key = wiphy_dereference(local->hw.wiphy, sta->deflink.gtk[i]); in ieee80211_free_sta_keys()
1192 if (!key) in ieee80211_free_sta_keys()
1194 ieee80211_key_replace(key->sdata, NULL, key->sta, in ieee80211_free_sta_keys()
1195 key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE, in ieee80211_free_sta_keys()
1196 key, NULL); in ieee80211_free_sta_keys()
1197 __ieee80211_key_destroy(key, key->sdata->vif.type == in ieee80211_free_sta_keys()
1202 key = wiphy_dereference(local->hw.wiphy, sta->ptk[i]); in ieee80211_free_sta_keys()
1203 if (!key) in ieee80211_free_sta_keys()
1205 ieee80211_key_replace(key->sdata, NULL, key->sta, in ieee80211_free_sta_keys()
1206 key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE, in ieee80211_free_sta_keys()
1207 key, NULL); in ieee80211_free_sta_keys()
1208 __ieee80211_key_destroy(key, key->sdata->vif.type == in ieee80211_free_sta_keys()
1224 * and then new keys are installed. The first new key causes the in ieee80211_delayed_tailroom_dec()
1228 * key removal for a while, so if we roam the value is larger than in ieee80211_delayed_tailroom_dec()
1229 * zero and no 0->1 transition happens. in ieee80211_delayed_tailroom_dec()
1238 sdata->crypto_tx_tailroom_pending_dec); in ieee80211_delayed_tailroom_dec()
1239 sdata->crypto_tx_tailroom_pending_dec = 0; in ieee80211_delayed_tailroom_dec()
1249 cfg80211_gtk_rekey_notify(sdata->dev, bssid, replay_ctr, gfp); in ieee80211_gtk_rekey_notify()
1256 struct ieee80211_key *key; in ieee80211_get_key_rx_seq() local
1259 key = container_of(keyconf, struct ieee80211_key, conf); in ieee80211_get_key_rx_seq()
1261 switch (key->conf.cipher) { in ieee80211_get_key_rx_seq()
1265 seq->tkip.iv32 = key->u.tkip.rx[tid].iv32; in ieee80211_get_key_rx_seq()
1266 seq->tkip.iv16 = key->u.tkip.rx[tid].iv16; in ieee80211_get_key_rx_seq()
1270 if (WARN_ON(tid < -1 || tid >= IEEE80211_NUM_TIDS)) in ieee80211_get_key_rx_seq()
1273 pn = key->u.ccmp.rx_pn[IEEE80211_NUM_TIDS]; in ieee80211_get_key_rx_seq()
1275 pn = key->u.ccmp.rx_pn[tid]; in ieee80211_get_key_rx_seq()
1276 memcpy(seq->ccmp.pn, pn, IEEE80211_CCMP_PN_LEN); in ieee80211_get_key_rx_seq()
1282 pn = key->u.aes_cmac.rx_pn; in ieee80211_get_key_rx_seq()
1283 memcpy(seq->aes_cmac.pn, pn, IEEE80211_CMAC_PN_LEN); in ieee80211_get_key_rx_seq()
1289 pn = key->u.aes_gmac.rx_pn; in ieee80211_get_key_rx_seq()
1290 memcpy(seq->aes_gmac.pn, pn, IEEE80211_GMAC_PN_LEN); in ieee80211_get_key_rx_seq()
1294 if (WARN_ON(tid < -1 || tid >= IEEE80211_NUM_TIDS)) in ieee80211_get_key_rx_seq()
1297 pn = key->u.gcmp.rx_pn[IEEE80211_NUM_TIDS]; in ieee80211_get_key_rx_seq()
1299 pn = key->u.gcmp.rx_pn[tid]; in ieee80211_get_key_rx_seq()
1300 memcpy(seq->gcmp.pn, pn, IEEE80211_GCMP_PN_LEN); in ieee80211_get_key_rx_seq()
1309 struct ieee80211_key *key; in ieee80211_set_key_rx_seq() local
1312 key = container_of(keyconf, struct ieee80211_key, conf); in ieee80211_set_key_rx_seq()
1314 switch (key->conf.cipher) { in ieee80211_set_key_rx_seq()
1318 key->u.tkip.rx[tid].iv32 = seq->tkip.iv32; in ieee80211_set_key_rx_seq()
1319 key->u.tkip.rx[tid].iv16 = seq->tkip.iv16; in ieee80211_set_key_rx_seq()
1323 if (WARN_ON(tid < -1 || tid >= IEEE80211_NUM_TIDS)) in ieee80211_set_key_rx_seq()
1326 pn = key->u.ccmp.rx_pn[IEEE80211_NUM_TIDS]; in ieee80211_set_key_rx_seq()
1328 pn = key->u.ccmp.rx_pn[tid]; in ieee80211_set_key_rx_seq()
1329 memcpy(pn, seq->ccmp.pn, IEEE80211_CCMP_PN_LEN); in ieee80211_set_key_rx_seq()
1335 pn = key->u.aes_cmac.rx_pn; in ieee80211_set_key_rx_seq()
1336 memcpy(pn, seq->aes_cmac.pn, IEEE80211_CMAC_PN_LEN); in ieee80211_set_key_rx_seq()
1342 pn = key->u.aes_gmac.rx_pn; in ieee80211_set_key_rx_seq()
1343 memcpy(pn, seq->aes_gmac.pn, IEEE80211_GMAC_PN_LEN); in ieee80211_set_key_rx_seq()
1347 if (WARN_ON(tid < -1 || tid >= IEEE80211_NUM_TIDS)) in ieee80211_set_key_rx_seq()
1350 pn = key->u.gcmp.rx_pn[IEEE80211_NUM_TIDS]; in ieee80211_set_key_rx_seq()
1352 pn = key->u.gcmp.rx_pn[tid]; in ieee80211_set_key_rx_seq()
1353 memcpy(pn, seq->gcmp.pn, IEEE80211_GCMP_PN_LEN); in ieee80211_set_key_rx_seq()
1368 struct ieee80211_local *local = sdata->local; in ieee80211_gtk_rekey_add()
1370 struct ieee80211_key *key; in ieee80211_gtk_rekey_add() local
1373 link_id < 0 ? &sdata->deflink : in ieee80211_gtk_rekey_add()
1374 sdata_dereference(sdata->link[link_id], sdata); in ieee80211_gtk_rekey_add()
1377 return ERR_PTR(-EINVAL); in ieee80211_gtk_rekey_add()
1379 if (WARN_ON(!local->wowlan)) in ieee80211_gtk_rekey_add()
1380 return ERR_PTR(-EINVAL); in ieee80211_gtk_rekey_add()
1382 if (WARN_ON(vif->type != NL80211_IFTYPE_STATION)) in ieee80211_gtk_rekey_add()
1383 return ERR_PTR(-EINVAL); in ieee80211_gtk_rekey_add()
1387 return ERR_PTR(-EINVAL); in ieee80211_gtk_rekey_add()
1389 prev_key = wiphy_dereference(local->hw.wiphy, in ieee80211_gtk_rekey_add()
1390 link_data->gtk[idx]); in ieee80211_gtk_rekey_add()
1396 prev_key = wiphy_dereference(local->hw.wiphy, in ieee80211_gtk_rekey_add()
1397 link_data->gtk[i]); in ieee80211_gtk_rekey_add()
1402 /* For IGTK we have 4 and 5 and for BIGTK - 6 and 7 */ in ieee80211_gtk_rekey_add()
1403 prev_key = wiphy_dereference(local->hw.wiphy, in ieee80211_gtk_rekey_add()
1404 link_data->gtk[idx ^ 1]); in ieee80211_gtk_rekey_add()
1409 return ERR_PTR(-EINVAL); in ieee80211_gtk_rekey_add()
1411 if (WARN_ON(key_len < prev_key->conf.keylen)) in ieee80211_gtk_rekey_add()
1412 return ERR_PTR(-EINVAL); in ieee80211_gtk_rekey_add()
1414 key = ieee80211_key_alloc(prev_key->conf.cipher, idx, in ieee80211_gtk_rekey_add()
1415 prev_key->conf.keylen, key_data, in ieee80211_gtk_rekey_add()
1417 if (IS_ERR(key)) in ieee80211_gtk_rekey_add()
1418 return ERR_CAST(key); in ieee80211_gtk_rekey_add()
1420 if (sdata->u.mgd.mfp != IEEE80211_MFP_DISABLED) in ieee80211_gtk_rekey_add()
1421 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT; in ieee80211_gtk_rekey_add()
1423 key->conf.link_id = link_data->link_id; in ieee80211_gtk_rekey_add()
1425 err = ieee80211_key_link(key, link_data, NULL); in ieee80211_gtk_rekey_add()
1429 return &key->conf; in ieee80211_gtk_rekey_add()
1435 struct ieee80211_key *key; in ieee80211_key_mic_failure() local
1437 key = container_of(keyconf, struct ieee80211_key, conf); in ieee80211_key_mic_failure()
1439 switch (key->conf.cipher) { in ieee80211_key_mic_failure()
1442 key->u.aes_cmac.icverrors++; in ieee80211_key_mic_failure()
1446 key->u.aes_gmac.icverrors++; in ieee80211_key_mic_failure()
1457 struct ieee80211_key *key; in ieee80211_key_replay() local
1459 key = container_of(keyconf, struct ieee80211_key, conf); in ieee80211_key_replay()
1461 switch (key->conf.cipher) { in ieee80211_key_replay()
1464 key->u.ccmp.replays++; in ieee80211_key_replay()
1468 key->u.aes_cmac.replays++; in ieee80211_key_replay()
1472 key->u.aes_gmac.replays++; in ieee80211_key_replay()
1476 key->u.gcmp.replays++; in ieee80211_key_replay()
1486 struct ieee80211_key *key; in ieee80211_key_switch_links() local
1489 list_for_each_entry(key, &sdata->key_list, list) { in ieee80211_key_switch_links()
1490 if (key->conf.link_id < 0 || in ieee80211_key_switch_links()
1491 !(del_links_mask & BIT(key->conf.link_id))) in ieee80211_key_switch_links()
1494 /* shouldn't happen for per-link keys */ in ieee80211_key_switch_links()
1495 WARN_ON(key->sta); in ieee80211_key_switch_links()
1497 ieee80211_key_disable_hw_accel(key); in ieee80211_key_switch_links()
1500 list_for_each_entry(key, &sdata->key_list, list) { in ieee80211_key_switch_links()
1501 if (key->conf.link_id < 0 || in ieee80211_key_switch_links()
1502 !(add_links_mask & BIT(key->conf.link_id))) in ieee80211_key_switch_links()
1505 /* shouldn't happen for per-link keys */ in ieee80211_key_switch_links()
1506 WARN_ON(key->sta); in ieee80211_key_switch_links()
1508 ret = ieee80211_key_enable_hw_accel(key); in ieee80211_key_switch_links()