Commit 16ec82d3 authored by Avraham Stern's avatar Avraham Stern Committed by Johannes Berg

wifi: iwlwifi: mvm: initiator: move setting the sta_id into a function

Move setting the target's sta_id (and related flags) into a function
to support different 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.18e3a6a6f1cb.I85e3ee607b3947448532bc16730f8898a11c92b8@changeidSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 94df6cbd
......@@ -431,9 +431,6 @@ iwl_mvm_ftm_put_target_v2(struct iwl_mvm *mvm,
return 0;
}
#define FTM_PUT_FLAG(flag) (target->initiator_ap_flags |= \
cpu_to_le32(IWL_INITIATOR_AP_FLAGS_##flag))
#define FTM_SET_FLAG(flag) (*flags |= \
cpu_to_le32(IWL_INITIATOR_AP_FLAGS_##flag))
......@@ -525,21 +522,10 @@ iwl_mvm_ftm_put_target_v4(struct iwl_mvm *mvm,
return 0;
}
static int
iwl_mvm_ftm_put_target(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
struct cfg80211_pmsr_request_peer *peer,
struct iwl_tof_range_req_ap_entry_v6 *target)
static int iwl_mvm_ftm_set_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
struct cfg80211_pmsr_request_peer *peer,
u8 *sta_id, __le32 *flags)
{
int ret;
ret = iwl_mvm_ftm_target_chandef_v2(mvm, peer, &target->channel_num,
&target->format_bw,
&target->ctrl_ch_position);
if (ret)
return ret;
iwl_mvm_ftm_put_target_common(mvm, peer, target);
if (vif->cfg.assoc) {
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
struct ieee80211_sta *sta;
......@@ -551,8 +537,8 @@ iwl_mvm_ftm_put_target(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
if (memcmp(peer->addr, link_conf->bssid, ETH_ALEN))
continue;
target->sta_id = mvmvif->link[link_id]->ap_sta_id;
sta = rcu_dereference(mvm->fw_id_to_mac_id[target->sta_id]);
*sta_id = mvmvif->link[link_id]->ap_sta_id;
sta = rcu_dereference(mvm->fw_id_to_mac_id[*sta_id]);
if (WARN_ON_ONCE(IS_ERR_OR_NULL(sta))) {
rcu_read_unlock();
return PTR_ERR_OR_ZERO(sta);
......@@ -560,23 +546,42 @@ iwl_mvm_ftm_put_target(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
if (sta->mfp && (peer->ftm.trigger_based ||
peer->ftm.non_trigger_based))
FTM_PUT_FLAG(PMF);
FTM_SET_FLAG(PMF);
break;
}
rcu_read_unlock();
#ifdef CONFIG_IWLWIFI_DEBUGFS
if (mvmvif->ftm_unprotected) {
target->sta_id = IWL_MVM_INVALID_STA;
target->initiator_ap_flags &=
~cpu_to_le32(IWL_INITIATOR_AP_FLAGS_PMF);
*sta_id = IWL_MVM_INVALID_STA;
*flags &= ~cpu_to_le32(IWL_INITIATOR_AP_FLAGS_PMF);
}
#endif
} else {
target->sta_id = IWL_MVM_INVALID_STA;
*sta_id = IWL_MVM_INVALID_STA;
}
return 0;
}
static int
iwl_mvm_ftm_put_target(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
struct cfg80211_pmsr_request_peer *peer,
struct iwl_tof_range_req_ap_entry_v6 *target)
{
int ret;
ret = iwl_mvm_ftm_target_chandef_v2(mvm, peer, &target->channel_num,
&target->format_bw,
&target->ctrl_ch_position);
if (ret)
return ret;
iwl_mvm_ftm_put_target_common(mvm, peer, target);
iwl_mvm_ftm_set_sta(mvm, vif, peer, &target->sta_id,
&target->initiator_ap_flags);
/*
* TODO: Beacon interval is currently unknown, so use the common value
* of 100 TUs.
......
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