From: Johannes Berg Request getting the STA pointer for the AP for GTKs installed in client mode, and remove the code that was necessary to work around not having them while the firmware requires the station entry. Signed-off-by: Johannes Berg Signed-off-by: Miri Korenblit --- drivers/net/wireless/intel/iwlwifi/mld/d3.c | 8 ++-- drivers/net/wireless/intel/iwlwifi/mld/key.c | 46 +------------------ drivers/net/wireless/intel/iwlwifi/mld/key.h | 6 +-- .../net/wireless/intel/iwlwifi/mld/mac80211.c | 13 +----- drivers/net/wireless/intel/iwlwifi/mld/sta.c | 7 --- 5 files changed, 8 insertions(+), 72 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mld/d3.c b/drivers/net/wireless/intel/iwlwifi/mld/d3.c index 77e485034e3b..c2c75db40749 100644 --- a/drivers/net/wireless/intel/iwlwifi/mld/d3.c +++ b/drivers/net/wireless/intel/iwlwifi/mld/d3.c @@ -71,8 +71,8 @@ iwl_mld_wake_pkt_key_iter(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta, struct ieee80211_key_conf *key, void *_data) { + bool is_group_key = !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE); struct iwl_mld_wake_pkt_iter_data *data = _data; - bool is_group_key = !sta; /* ignore anything that is not a PTK / GTK */ if (key->keyidx > 3) @@ -1060,7 +1060,7 @@ iwl_mld_resume_keys_iter(struct ieee80211_hw *hw, if (rsc_notif_ver == IWL_FW_CMD_VER_UNKNOWN && key->keyidx >= 0 && key->keyidx <= 3) { /* PTK */ - if (sta) { + if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) { iwl_mld_update_ptk_rx_seq(data->mld, wowlan_status, sta, key, key->cipher == @@ -1100,7 +1100,7 @@ iwl_mld_rsc_update_key_iter(struct ieee80211_hw *hw, if (key->keyidx > 3) return; - if (sta) { + if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) { /* PTK */ BUILD_BUG_ON(ARRAY_SIZE(data->notif->ucast_rsc) != IWL_MAX_TID_COUNT); @@ -1827,7 +1827,7 @@ iwl_mld_suspend_key_data_iter(struct ieee80211_hw *hw, case WLAN_CIPHER_SUITE_TKIP: if (!cipher) cipher = cpu_to_le32(STA_KEY_FLG_TKIP); - if (sta) { + if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) { key_rsc = data->rsc->ucast_rsc; if (key->cipher == WLAN_CIPHER_SUITE_TKIP) iwl_mld_suspend_convert_tkip_ipn(key, key_rsc); diff --git a/drivers/net/wireless/intel/iwlwifi/mld/key.c b/drivers/net/wireless/intel/iwlwifi/mld/key.c index 74b483783de8..5ee5e0ed0350 100644 --- a/drivers/net/wireless/intel/iwlwifi/mld/key.c +++ b/drivers/net/wireless/intel/iwlwifi/mld/key.c @@ -346,49 +346,6 @@ int iwl_mld_add_key(struct iwl_mld *mld, return 0; } -struct remove_ap_keys_iter_data { - u8 link_id; - struct ieee80211_sta *sta; -}; - -static void iwl_mld_remove_ap_keys_iter(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta, - struct ieee80211_key_conf *key, - void *_data) -{ - struct iwl_mld *mld = IWL_MAC80211_GET_MLD(hw); - struct remove_ap_keys_iter_data *data = _data; - - if (key->hw_key_idx == STA_KEY_IDX_INVALID) - return; - - /* All the pairwise keys should have been removed by now */ - if (WARN_ON(sta)) - return; - - if (key->link_id >= 0 && key->link_id != data->link_id) - return; - - iwl_mld_remove_key(mld, vif, data->sta, key); -} - -void iwl_mld_remove_ap_keys(struct iwl_mld *mld, struct ieee80211_vif *vif, - struct ieee80211_sta *sta, unsigned int link_id) -{ - struct remove_ap_keys_iter_data iter_data = { - .link_id = link_id, - .sta = sta, - }; - - if (WARN_ON_ONCE(vif->type != NL80211_IFTYPE_STATION)) - return; - - ieee80211_iter_keys(mld->hw, vif, - iwl_mld_remove_ap_keys_iter, - &iter_data); -} - struct iwl_mvm_sta_key_update_data { struct ieee80211_sta *sta; u32 old_sta_mask; @@ -414,8 +371,7 @@ static void iwl_mld_update_sta_key_iter(struct ieee80211_hw *hw, }; int err; - /* only need to do this for pairwise keys (link_id == -1) */ - if (sta != data->sta || key->link_id >= 0) + if (sta != data->sta || !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) return; err = iwl_mld_send_cmd_pdu(mld, WIDE_ID(DATA_PATH_GROUP, SEC_KEY_CMD), diff --git a/drivers/net/wireless/intel/iwlwifi/mld/key.h b/drivers/net/wireless/intel/iwlwifi/mld/key.h index 5a9efdaa3b03..ddd1e7b52e4b 100644 --- a/drivers/net/wireless/intel/iwlwifi/mld/key.h +++ b/drivers/net/wireless/intel/iwlwifi/mld/key.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ /* - * Copyright (C) 2024 Intel Corporation + * Copyright (C) 2024. 2026 Intel Corporation */ #ifndef __iwl_mld_key_h__ #define __iwl_mld_key_h__ @@ -17,10 +17,6 @@ int iwl_mld_add_key(struct iwl_mld *mld, struct ieee80211_vif *vif, struct ieee80211_sta *sta, struct ieee80211_key_conf *key); -void iwl_mld_remove_ap_keys(struct iwl_mld *mld, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta, - unsigned int link_id); int iwl_mld_update_sta_keys(struct iwl_mld *mld, struct ieee80211_vif *vif, diff --git a/drivers/net/wireless/intel/iwlwifi/mld/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mld/mac80211.c index 821cd2d2a73b..728863d818fd 100644 --- a/drivers/net/wireless/intel/iwlwifi/mld/mac80211.c +++ b/drivers/net/wireless/intel/iwlwifi/mld/mac80211.c @@ -263,6 +263,7 @@ static void iwl_mac_hw_set_flags(struct iwl_mld *mld) ieee80211_hw_set(hw, SINGLE_SCAN_ON_ALL_BANDS); ieee80211_hw_set(hw, SUPPORTS_AMSDU_IN_AMPDU); ieee80211_hw_set(hw, TDLS_WIDER_BW); + ieee80211_hw_set(hw, PER_STA_AP_GTK); } static void iwl_mld_hw_set_nan(struct iwl_mld *mld) @@ -2355,20 +2356,9 @@ static int iwl_mld_mac80211_set_key(struct ieee80211_hw *hw, struct ieee80211_sta *sta, struct ieee80211_key_conf *key) { - struct iwl_mld_vif *mld_vif = iwl_mld_vif_from_mac80211(vif); struct iwl_mld *mld = IWL_MAC80211_GET_MLD(hw); int ret; - /* - * FW always needs the AP STA for client mode. - * Note that during removal this could already - * be NULL (mac80211 removes keys after STAs) - * but then we'll already have removed the key - * and set hw_key_idx = STA_KEY_IDX_INVALID. - */ - if (!sta && vif->type == NL80211_IFTYPE_STATION) - sta = mld_vif->ap_sta; - switch (cmd) { case SET_KEY: ret = iwl_mld_set_key_add(mld, vif, sta, key); @@ -2595,6 +2585,7 @@ static void iwl_mld_sta_pre_rcu_remove(struct ieee80211_hw *hw, * on further RCU synchronisation after the sta_state() * callback deleted the station. */ + for_each_mld_link_sta(mld_sta, mld_link_sta, link_id) RCU_INIT_POINTER(mld->fw_id_to_link_sta[mld_link_sta->fw_id], NULL); diff --git a/drivers/net/wireless/intel/iwlwifi/mld/sta.c b/drivers/net/wireless/intel/iwlwifi/mld/sta.c index cfdf7c1baaaf..d66b1164b8e2 100644 --- a/drivers/net/wireless/intel/iwlwifi/mld/sta.c +++ b/drivers/net/wireless/intel/iwlwifi/mld/sta.c @@ -920,13 +920,6 @@ void iwl_mld_remove_sta(struct iwl_mld *mld, struct ieee80211_sta *sta) iwl_mld_remove_txq(mld, sta->txq[i]); for_each_sta_active_link(sta, link_sta, link_id) { - /* Mac8011 will remove the groupwise keys after the sta is - * removed, but FW expects all the keys to be removed before - * the STA is, so remove them all here. - */ - if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls) - iwl_mld_remove_ap_keys(mld, vif, sta, link_id); - /* Remove the link_sta */ iwl_mld_remove_link_sta(mld, link_sta); } -- 2.34.1