Skip to content

Commit af3aab9

Browse files
jmberg-intellucacoelho
authored andcommitted
iwlwifi: mvm: d3: make key reprogramming iteration optional
Now that only reprogramming is left in the initial key iteration, skip it entirely on unified firmware images instead of skipping only the command sending inside of it. Signed-off-by: Johannes Berg <[email protected]> Signed-off-by: Luca Coelho <[email protected]> Link: https://lore.kernel.org/r/iwlwifi.20210805130823.c6f77325c430.I798ce9d757492a9e3d223c1de5d4e62ebbc00b2c@changeid Signed-off-by: Luca Coelho <[email protected]>
1 parent be05fae commit af3aab9

File tree

1 file changed

+48
-54
lines changed
  • drivers/net/wireless/intel/iwlwifi/mvm

1 file changed

+48
-54
lines changed

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

Lines changed: 48 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ static const u8 *iwl_mvm_find_max_pn(struct ieee80211_key_conf *key,
101101
return ret;
102102
}
103103

104-
struct wowlan_key_data {
105-
bool error, configure_keys;
104+
struct wowlan_key_reprogram_data {
105+
bool error;
106106
int wep_key_idx;
107107
};
108108

@@ -114,7 +114,7 @@ static void iwl_mvm_wowlan_program_keys(struct ieee80211_hw *hw,
114114
{
115115
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
116116
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
117-
struct wowlan_key_data *data = _data;
117+
struct wowlan_key_reprogram_data *data = _data;
118118
int ret;
119119

120120
switch (key->cipher) {
@@ -152,18 +152,14 @@ static void iwl_mvm_wowlan_program_keys(struct ieee80211_hw *hw,
152152
wkc.wep_key.key_offset = data->wep_key_idx;
153153
}
154154

155-
if (data->configure_keys) {
156-
mutex_lock(&mvm->mutex);
157-
ret = iwl_mvm_send_cmd_pdu(mvm, WEP_KEY, 0,
158-
sizeof(wkc), &wkc);
159-
data->error = ret != 0;
160-
161-
mvm->ptk_ivlen = key->iv_len;
162-
mvm->ptk_icvlen = key->icv_len;
163-
mvm->gtk_ivlen = key->iv_len;
164-
mvm->gtk_icvlen = key->icv_len;
165-
mutex_unlock(&mvm->mutex);
166-
}
155+
mutex_lock(&mvm->mutex);
156+
ret = iwl_mvm_send_cmd_pdu(mvm, WEP_KEY, 0, sizeof(wkc), &wkc);
157+
data->error = ret != 0;
158+
159+
mvm->ptk_ivlen = key->iv_len;
160+
mvm->ptk_icvlen = key->icv_len;
161+
mvm->gtk_ivlen = key->iv_len;
162+
mvm->gtk_icvlen = key->icv_len;
167163

168164
/* don't upload key again */
169165
return;
@@ -190,30 +186,28 @@ static void iwl_mvm_wowlan_program_keys(struct ieee80211_hw *hw,
190186
break;
191187
}
192188

193-
if (data->configure_keys) {
194-
mutex_lock(&mvm->mutex);
189+
mutex_lock(&mvm->mutex);
190+
/*
191+
* The D3 firmware hardcodes the key offset 0 as the key it
192+
* uses to transmit packets to the AP, i.e. the PTK.
193+
*/
194+
if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) {
195+
mvm->ptk_ivlen = key->iv_len;
196+
mvm->ptk_icvlen = key->icv_len;
197+
ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, 0);
198+
} else {
195199
/*
196-
* The D3 firmware hardcodes the key offset 0 as the key it
197-
* uses to transmit packets to the AP, i.e. the PTK.
200+
* firmware only supports TSC/RSC for a single key,
201+
* so if there are multiple keep overwriting them
202+
* with new ones -- this relies on mac80211 doing
203+
* list_add_tail().
198204
*/
199-
if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) {
200-
mvm->ptk_ivlen = key->iv_len;
201-
mvm->ptk_icvlen = key->icv_len;
202-
ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, 0);
203-
} else {
204-
/*
205-
* firmware only supports TSC/RSC for a single key,
206-
* so if there are multiple keep overwriting them
207-
* with new ones -- this relies on mac80211 doing
208-
* list_add_tail().
209-
*/
210-
mvm->gtk_ivlen = key->iv_len;
211-
mvm->gtk_icvlen = key->icv_len;
212-
ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, 1);
213-
}
214-
mutex_unlock(&mvm->mutex);
215-
data->error = ret != 0;
205+
mvm->gtk_ivlen = key->iv_len;
206+
mvm->gtk_icvlen = key->icv_len;
207+
ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, 1);
216208
}
209+
mutex_unlock(&mvm->mutex);
210+
data->error = ret != 0;
217211
}
218212

219213
struct wowlan_key_rsc_tsc_data {
@@ -839,30 +833,30 @@ static int iwl_mvm_wowlan_config_key_params(struct iwl_mvm *mvm,
839833
{
840834
bool unified = fw_has_capa(&mvm->fw->ucode_capa,
841835
IWL_UCODE_TLV_CAPA_CNSLDTD_D3_D0_IMG);
842-
struct wowlan_key_data key_data = {
843-
.configure_keys = !unified,
844-
};
836+
struct wowlan_key_reprogram_data key_data = {};
845837
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
846838
int ret;
847839
u8 cmd_ver;
848840
size_t cmd_size;
849841

850-
/*
851-
* if we have to configure keys, call ieee80211_iter_keys(),
852-
* as we need non-atomic context in order to take the
853-
* required locks.
854-
*/
855-
/*
856-
* Note that currently we don't use CMD_ASYNC in the iterator.
857-
* In case of key_data.configure_keys, all the configured commands
858-
* are SYNC, and iwl_mvm_wowlan_program_keys() will take care of
859-
* locking/unlocking mvm->mutex.
860-
*/
861-
ieee80211_iter_keys(mvm->hw, vif, iwl_mvm_wowlan_program_keys,
862-
&key_data);
842+
if (!unified) {
843+
/*
844+
* if we have to configure keys, call ieee80211_iter_keys(),
845+
* as we need non-atomic context in order to take the
846+
* required locks.
847+
*/
848+
/*
849+
* Note that currently we don't use CMD_ASYNC in the iterator.
850+
* In case of key_data.configure_keys, all the configured
851+
* commands are SYNC, and iwl_mvm_wowlan_program_keys() will
852+
* take care of locking/unlocking mvm->mutex.
853+
*/
854+
ieee80211_iter_keys(mvm->hw, vif, iwl_mvm_wowlan_program_keys,
855+
&key_data);
863856

864-
if (key_data.error)
865-
return -EIO;
857+
if (key_data.error)
858+
return -EIO;
859+
}
866860

867861
ret = iwl_mvm_wowlan_config_rsc_tsc(mvm, vif);
868862
if (ret)

0 commit comments

Comments
 (0)