]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: iwlwifi: mvm: initiator: move setting the sta_id into a function
authorAvraham Stern <avraham.stern@intel.com>
Mon, 27 May 2024 16:06:04 +0000 (19:06 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 29 May 2024 08:33:44 +0000 (10:33 +0200)
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: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://msgid.link/20240527190228.18e3a6a6f1cb.I85e3ee607b3947448532bc16730f8898a11c92b8@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c

index 98b1bbfc84bccfac04048026c43f0297562f8527..8596e6f7d1dc0bbdcdfa2c464c050bab13ea7f59 100644 (file)
@@ -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.