Commit 626be4bf authored by Avraham Stern's avatar Avraham Stern Committed by Johannes Berg

wifi: iwlwifi: mvm: modify iwl_mvm_ftm_set_secured_ranging() parameters

Modify iwl_mvm_ftm_set_secured_ranging() parameters to support
multiple versions of the target struct.
This is done as preparation for moving to the new range request
version.
Signed-off-by: default avatarAvraham Stern <avraham.stern@intel.com>
Signed-off-by: default avatarMiri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://msgid.link/20240527190228.56d6aee320b3.I5a52fa93cd791d0229b392a20f076b7cebb110cd@changeidSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 16ec82d3
...@@ -40,6 +40,12 @@ struct iwl_mvm_ftm_pasn_entry { ...@@ -40,6 +40,12 @@ struct iwl_mvm_ftm_pasn_entry {
u32 flags; u32 flags;
}; };
struct iwl_mvm_ftm_iter_data {
u8 *cipher;
u8 *bssid;
u8 *tk;
};
int iwl_mvm_ftm_add_pasn_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif, int iwl_mvm_ftm_add_pasn_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
u8 *addr, u32 cipher, u8 *tk, u32 tk_len, u8 *addr, u32 cipher, u8 *tk, u32 tk_len,
u8 *hltk, u32 hltk_len) u8 *hltk, u32 hltk_len)
...@@ -719,7 +725,7 @@ static void iter(struct ieee80211_hw *hw, ...@@ -719,7 +725,7 @@ static void iter(struct ieee80211_hw *hw,
struct ieee80211_key_conf *key, struct ieee80211_key_conf *key,
void *data) void *data)
{ {
struct iwl_tof_range_req_ap_entry_v6 *target = data; struct iwl_mvm_ftm_iter_data *target = data;
if (!sta || memcmp(sta->addr, target->bssid, ETH_ALEN)) if (!sta || memcmp(sta->addr, target->bssid, ETH_ALEN))
return; return;
...@@ -730,16 +736,16 @@ static void iter(struct ieee80211_hw *hw, ...@@ -730,16 +736,16 @@ static void iter(struct ieee80211_hw *hw,
return; return;
memcpy(target->tk, key->key, key->keylen); memcpy(target->tk, key->key, key->keylen);
target->cipher = iwl_mvm_cipher_to_location_cipher(key->cipher); *target->cipher = iwl_mvm_cipher_to_location_cipher(key->cipher);
WARN_ON(target->cipher == IWL_LOCATION_CIPHER_INVALID); WARN_ON(*target->cipher == IWL_LOCATION_CIPHER_INVALID);
} }
static void static void
iwl_mvm_ftm_set_secured_ranging(struct iwl_mvm *mvm, struct ieee80211_vif *vif, iwl_mvm_ftm_set_secured_ranging(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
struct iwl_tof_range_req_ap_entry_v7 *target) u8 *bssid, u8 *cipher, u8 *hltk, u8 *tk,
u8 *rx_pn, u8 *tx_pn, __le32 *flags)
{ {
struct iwl_mvm_ftm_pasn_entry *entry; struct iwl_mvm_ftm_pasn_entry *entry;
u32 flags = le32_to_cpu(target->initiator_ap_flags);
#ifdef CONFIG_IWLWIFI_DEBUGFS #ifdef CONFIG_IWLWIFI_DEBUGFS
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
...@@ -747,35 +753,39 @@ iwl_mvm_ftm_set_secured_ranging(struct iwl_mvm *mvm, struct ieee80211_vif *vif, ...@@ -747,35 +753,39 @@ iwl_mvm_ftm_set_secured_ranging(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
return; return;
#endif #endif
if (!(flags & (IWL_INITIATOR_AP_FLAGS_NON_TB | if (!(le32_to_cpu(*flags) & (IWL_INITIATOR_AP_FLAGS_NON_TB |
IWL_INITIATOR_AP_FLAGS_TB))) IWL_INITIATOR_AP_FLAGS_TB)))
return; return;
lockdep_assert_held(&mvm->mutex); lockdep_assert_held(&mvm->mutex);
list_for_each_entry(entry, &mvm->ftm_initiator.pasn_list, list) { list_for_each_entry(entry, &mvm->ftm_initiator.pasn_list, list) {
if (memcmp(entry->addr, target->bssid, sizeof(entry->addr))) if (memcmp(entry->addr, bssid, sizeof(entry->addr)))
continue; continue;
target->cipher = entry->cipher; *cipher = entry->cipher;
if (entry->flags & IWL_MVM_PASN_FLAG_HAS_HLTK) if (entry->flags & IWL_MVM_PASN_FLAG_HAS_HLTK)
memcpy(target->hltk, entry->hltk, sizeof(target->hltk)); memcpy(hltk, entry->hltk, sizeof(entry->hltk));
else else
memset(target->hltk, 0, sizeof(target->hltk)); memset(hltk, 0, sizeof(entry->hltk));
if (vif->cfg.assoc && if (vif->cfg.assoc &&
!memcmp(vif->bss_conf.bssid, target->bssid, !memcmp(vif->bss_conf.bssid, bssid, ETH_ALEN)) {
sizeof(target->bssid))) struct iwl_mvm_ftm_iter_data target;
ieee80211_iter_keys(mvm->hw, vif, iter, target);
else target.cipher = cipher;
memcpy(target->tk, entry->tk, sizeof(target->tk)); target.bssid = bssid;
target.tk = tk;
ieee80211_iter_keys(mvm->hw, vif, iter, &target);
} else {
memcpy(tk, entry->tk, sizeof(entry->tk));
}
memcpy(target->rx_pn, entry->rx_pn, sizeof(target->rx_pn)); memcpy(rx_pn, entry->rx_pn, sizeof(entry->rx_pn));
memcpy(target->tx_pn, entry->tx_pn, sizeof(target->tx_pn)); memcpy(tx_pn, entry->tx_pn, sizeof(entry->tx_pn));
target->initiator_ap_flags |= FTM_SET_FLAG(SECURED);
cpu_to_le32(IWL_INITIATOR_AP_FLAGS_SECURED);
return; return;
} }
} }
...@@ -789,7 +799,11 @@ iwl_mvm_ftm_put_target_v7(struct iwl_mvm *mvm, struct ieee80211_vif *vif, ...@@ -789,7 +799,11 @@ iwl_mvm_ftm_put_target_v7(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
if (err) if (err)
return err; return err;
iwl_mvm_ftm_set_secured_ranging(mvm, vif, target); iwl_mvm_ftm_set_secured_ranging(mvm, vif, target->bssid,
&target->cipher, target->hltk,
target->tk, target->rx_pn,
target->tx_pn,
&target->initiator_ap_flags);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment