iwlwifi: scan: create function for scan scheduling params

In the next patch, this code will be used from different places.
As preparation export this code into function.

Signed-off-by: Tova Mussai <tova.mussai@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
This commit is contained in:
Tova Mussai 2019-11-15 09:27:42 +02:00 committed by Kalle Valo
parent 4d75a9eba2
commit 508127b762

View File

@ -1509,6 +1509,39 @@ static u16 iwl_mvm_scan_umac_flags(struct iwl_mvm *mvm,
return flags;
}
static int
iwl_mvm_fill_scan_sched_params(struct iwl_mvm_scan_params *params,
struct iwl_scan_umac_schedule *schedule,
__le16 *delay)
{
int i;
if (WARN_ON(!params->n_scan_plans ||
params->n_scan_plans > IWL_MAX_SCHED_SCAN_PLANS))
return -EINVAL;
for (i = 0; i < params->n_scan_plans; i++) {
struct cfg80211_sched_scan_plan *scan_plan =
&params->scan_plans[i];
schedule[i].iter_count = scan_plan->iterations;
schedule[i].interval =
cpu_to_le16(scan_plan->interval);
}
/*
* If the number of iterations of the last scan plan is set to
* zero, it should run infinitely. However, this is not always the case.
* For example, when regular scan is requested the driver sets one scan
* plan with one iteration.
*/
if (!schedule[params->n_scan_plans - 1].iter_count)
schedule[params->n_scan_plans - 1].iter_count = 0xff;
*delay = cpu_to_le16(params->delay);
return 0;
}
static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
struct iwl_mvm_scan_params *params,
int type)
@ -1522,7 +1555,7 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
(struct iwl_scan_req_umac_tail_v2 *)sec_part;
struct iwl_scan_req_umac_tail_v1 *tail_v1;
struct iwl_ssid_ie *direct_scan;
int uid, i;
int uid, ret = 0;
u32 ssid_bitmap = 0;
u8 channel_flags = 0;
u16 gen_flags;
@ -1532,9 +1565,6 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
lockdep_assert_held(&mvm->mutex);
if (WARN_ON(params->n_scan_plans > IWL_MAX_SCHED_SCAN_PLANS))
return -EINVAL;
uid = iwl_mvm_scan_uid_by_status(mvm, 0);
if (uid < 0)
return uid;
@ -1583,25 +1613,10 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
chan_param->flags = channel_flags;
chan_param->count = params->n_channels;
for (i = 0; i < params->n_scan_plans; i++) {
struct cfg80211_sched_scan_plan *scan_plan =
&params->scan_plans[i];
tail_v2->schedule[i].iter_count = scan_plan->iterations;
tail_v2->schedule[i].interval =
cpu_to_le16(scan_plan->interval);
}
/*
* If the number of iterations of the last scan plan is set to
* zero, it should run infinitely. However, this is not always the case.
* For example, when regular scan is requested the driver sets one scan
* plan with one iteration.
*/
if (!tail_v2->schedule[i - 1].iter_count)
tail_v2->schedule[i - 1].iter_count = 0xff;
tail_v2->delay = cpu_to_le16(params->delay);
ret = iwl_mvm_fill_scan_sched_params(params, tail_v2->schedule,
&tail_v2->delay);
if (ret)
return ret;
if (iwl_mvm_is_scan_ext_chan_supported(mvm)) {
tail_v2->preq = params->preq;