Skip to content

Commit be05fae

Browse files
jmberg-intellucacoelho
authored andcommitted
iwlwifi: mvm: d3: add separate key iteration for GTK type
If we're sending the KEK/KCK data we also need the GTK and IGTK type, add a separate key iteration for that so we can make the configure_key iteration optional later. Signed-off-by: Johannes Berg <[email protected]> Signed-off-by: Luca Coelho <[email protected]> Link: https://lore.kernel.org/r/iwlwifi.20210805130823.c99f86423702.Icf7d4e93be77ea05a80235d01851ad0155593de9@changeid Signed-off-by: Luca Coelho <[email protected]>
1 parent 631ee51 commit be05fae

File tree

1 file changed

+46
-17
lines changed
  • drivers/net/wireless/intel/iwlwifi/mvm

1 file changed

+46
-17
lines changed

drivers/net/wireless/intel/iwlwifi/mvm/d3.c

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ static const u8 *iwl_mvm_find_max_pn(struct ieee80211_key_conf *key,
102102
}
103103

104104
struct wowlan_key_data {
105-
struct iwl_wowlan_kek_kck_material_cmd_v4 *kek_kck_cmd;
106105
bool error, configure_keys;
107106
int wep_key_idx;
108107
};
@@ -174,10 +173,8 @@ static void iwl_mvm_wowlan_program_keys(struct ieee80211_hw *hw,
174173
return;
175174
case WLAN_CIPHER_SUITE_BIP_GMAC_256:
176175
case WLAN_CIPHER_SUITE_BIP_GMAC_128:
177-
data->kek_kck_cmd->igtk_cipher = cpu_to_le32(STA_KEY_FLG_GCMP);
178176
return;
179177
case WLAN_CIPHER_SUITE_AES_CMAC:
180-
data->kek_kck_cmd->igtk_cipher = cpu_to_le32(STA_KEY_FLG_CCM);
181178
/*
182179
* Ignore CMAC keys -- the WoWLAN firmware doesn't support them
183180
* but we also shouldn't abort suspend due to that. It does have
@@ -187,23 +184,12 @@ static void iwl_mvm_wowlan_program_keys(struct ieee80211_hw *hw,
187184
*/
188185
return;
189186
case WLAN_CIPHER_SUITE_TKIP:
190-
if (!sta)
191-
data->kek_kck_cmd->gtk_cipher =
192-
cpu_to_le32(STA_KEY_FLG_TKIP);
193-
break;
194187
case WLAN_CIPHER_SUITE_CCMP:
195188
case WLAN_CIPHER_SUITE_GCMP:
196189
case WLAN_CIPHER_SUITE_GCMP_256:
197-
if (!sta)
198-
data->kek_kck_cmd->gtk_cipher =
199-
key->cipher == WLAN_CIPHER_SUITE_CCMP ?
200-
cpu_to_le32(STA_KEY_FLG_CCM) :
201-
cpu_to_le32(STA_KEY_FLG_GCMP);
202190
break;
203191
}
204192

205-
IWL_DEBUG_WOWLAN(mvm, "GTK cipher %d\n", data->kek_kck_cmd->gtk_cipher);
206-
207193
if (data->configure_keys) {
208194
mutex_lock(&mvm->mutex);
209195
/*
@@ -452,6 +438,42 @@ static void iwl_mvm_wowlan_get_tkip_data(struct ieee80211_hw *hw,
452438
}
453439
}
454440

441+
struct wowlan_key_gtk_type_iter {
442+
struct iwl_wowlan_kek_kck_material_cmd_v4 *kek_kck_cmd;
443+
};
444+
445+
static void iwl_mvm_wowlan_gtk_type_iter(struct ieee80211_hw *hw,
446+
struct ieee80211_vif *vif,
447+
struct ieee80211_sta *sta,
448+
struct ieee80211_key_conf *key,
449+
void *_data)
450+
{
451+
struct wowlan_key_gtk_type_iter *data = _data;
452+
453+
switch (key->cipher) {
454+
default:
455+
return;
456+
case WLAN_CIPHER_SUITE_BIP_GMAC_256:
457+
case WLAN_CIPHER_SUITE_BIP_GMAC_128:
458+
data->kek_kck_cmd->igtk_cipher = cpu_to_le32(STA_KEY_FLG_GCMP);
459+
return;
460+
case WLAN_CIPHER_SUITE_AES_CMAC:
461+
data->kek_kck_cmd->igtk_cipher = cpu_to_le32(STA_KEY_FLG_CCM);
462+
return;
463+
case WLAN_CIPHER_SUITE_CCMP:
464+
if (!sta)
465+
data->kek_kck_cmd->gtk_cipher =
466+
cpu_to_le32(STA_KEY_FLG_CCM);
467+
break;
468+
case WLAN_CIPHER_SUITE_GCMP:
469+
case WLAN_CIPHER_SUITE_GCMP_256:
470+
if (!sta)
471+
data->kek_kck_cmd->gtk_cipher =
472+
cpu_to_le32(STA_KEY_FLG_GCMP);
473+
break;
474+
}
475+
}
476+
455477
static int iwl_mvm_send_patterns_v1(struct iwl_mvm *mvm,
456478
struct cfg80211_wowlan *wowlan)
457479
{
@@ -815,13 +837,10 @@ iwl_mvm_get_wowlan_config(struct iwl_mvm *mvm,
815837
static int iwl_mvm_wowlan_config_key_params(struct iwl_mvm *mvm,
816838
struct ieee80211_vif *vif)
817839
{
818-
struct iwl_wowlan_kek_kck_material_cmd_v4 kek_kck_cmd = {};
819-
struct iwl_wowlan_kek_kck_material_cmd_v4 *_kek_kck_cmd = &kek_kck_cmd;
820840
bool unified = fw_has_capa(&mvm->fw->ucode_capa,
821841
IWL_UCODE_TLV_CAPA_CNSLDTD_D3_D0_IMG);
822842
struct wowlan_key_data key_data = {
823843
.configure_keys = !unified,
824-
.kek_kck_cmd = _kek_kck_cmd,
825844
};
826845
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
827846
int ret;
@@ -884,6 +903,13 @@ static int iwl_mvm_wowlan_config_key_params(struct iwl_mvm *mvm,
884903

885904
/* configure rekey data only if offloaded rekey is supported (d3) */
886905
if (mvmvif->rekey_data.valid) {
906+
struct iwl_wowlan_kek_kck_material_cmd_v4 kek_kck_cmd = {};
907+
struct iwl_wowlan_kek_kck_material_cmd_v4 *_kek_kck_cmd =
908+
&kek_kck_cmd;
909+
struct wowlan_key_gtk_type_iter gtk_type_data = {
910+
.kek_kck_cmd = _kek_kck_cmd,
911+
};
912+
887913
cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw,
888914
IWL_ALWAYS_LONG_GROUP,
889915
WOWLAN_KEK_KCK_MATERIAL,
@@ -892,6 +918,9 @@ static int iwl_mvm_wowlan_config_key_params(struct iwl_mvm *mvm,
892918
cmd_ver != IWL_FW_CMD_VER_UNKNOWN))
893919
return -EINVAL;
894920

921+
ieee80211_iter_keys(mvm->hw, vif, iwl_mvm_wowlan_gtk_type_iter,
922+
&gtk_type_data);
923+
895924
memcpy(kek_kck_cmd.kck, mvmvif->rekey_data.kck,
896925
mvmvif->rekey_data.kck_len);
897926
kek_kck_cmd.kck_len = cpu_to_le16(mvmvif->rekey_data.kck_len);

0 commit comments

Comments
 (0)