Skip to content

Commit

Permalink
iwlwifi: mvm: move all UMAC scan flags setting into the relevant func…
Browse files Browse the repository at this point in the history
…tion

Clean the code a little by moving all the flags into the right
function.  Additionally, rename the function, since "common" is now
irrelevant.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
  • Loading branch information
Luciano Coelho authored and Emmanuel Grumbach committed Apr 29, 2015
1 parent 7ea76dc commit 6f4dcc7
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions drivers/net/wireless/iwlwifi/mvm/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,11 @@ static inline bool iwl_mvm_scan_use_ebs(struct iwl_mvm *mvm, int n_iterations)
(capa->api[0] & IWL_UCODE_TLV_API_SINGLE_SCAN_EBS)));
}

static int iwl_mvm_scan_total_iterations(struct iwl_mvm_scan_params *params)
{
return params->schedule[0].iterations + params->schedule[1].iterations;
}

static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
struct iwl_mvm_scan_params *params)
{
Expand All @@ -839,8 +844,7 @@ static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
(void *)(cmd->data + sizeof(struct iwl_scan_channel_cfg_lmac) *
mvm->fw->ucode_capa.n_scan_channels);
u32 flags = 0, ssid_bitmap = 0;
int n_iterations = params->schedule[0].iterations +
params->schedule[1].iterations;
int n_iterations = iwl_mvm_scan_total_iterations(params);

lockdep_assert_held(&mvm->mutex);

Expand Down Expand Up @@ -1143,24 +1147,31 @@ iwl_mvm_umac_scan_cfg_channels(struct iwl_mvm *mvm,
}
}

static u32 iwl_mvm_scan_umac_common_flags(struct iwl_mvm *mvm, int n_ssids,
struct cfg80211_ssid *ssids,
int fragmented)
static u32 iwl_mvm_scan_umac_flags(struct iwl_mvm *mvm,
struct iwl_mvm_scan_params *params)
{
int flags = 0;

if (n_ssids == 0)
if (params->n_ssids == 0)
flags = IWL_UMAC_SCAN_GEN_FLAGS_PASSIVE;

if (n_ssids == 1 && ssids[0].ssid_len != 0)
if (params->n_ssids == 1 && params->ssids[0].ssid_len != 0)
flags |= IWL_UMAC_SCAN_GEN_FLAGS_PRE_CONNECT;

if (fragmented)
if (params->passive_fragmented)
flags |= IWL_UMAC_SCAN_GEN_FLAGS_FRAGMENTED;

if (iwl_mvm_rrm_scan_needed(mvm))
flags |= IWL_UMAC_SCAN_GEN_FLAGS_RRM_ENABLED;

if (params->pass_all)
flags |= IWL_UMAC_SCAN_GEN_FLAGS_PASS_ALL;
else
flags |= IWL_UMAC_SCAN_GEN_FLAGS_MATCH;

if (iwl_mvm_scan_total_iterations(params) > 1)
flags |= IWL_UMAC_SCAN_GEN_FLAGS_PERIODIC;

return flags;
}

Expand All @@ -1171,10 +1182,9 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
struct iwl_scan_req_umac_tail *sec_part = (void *)&cmd->data +
sizeof(struct iwl_scan_channel_cfg_umac) *
mvm->fw->ucode_capa.n_scan_channels;
u32 uid, flags;
u32 uid;
u32 ssid_bitmap = 0;
int n_iterations = params->schedule[0].iterations +
params->schedule[1].iterations;
int n_iterations = iwl_mvm_scan_total_iterations(params);
int uid_idx;

lockdep_assert_held(&mvm->mutex);
Expand All @@ -1185,28 +1195,18 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,

iwl_mvm_build_generic_umac_scan_cmd(mvm, cmd, params);

flags = iwl_mvm_scan_umac_common_flags(mvm, params->n_ssids,
params->ssids,
params->passive_fragmented);

if (n_iterations == 1) {
cmd->ooc_priority = cpu_to_le32(IWL_SCAN_PRIORITY_HIGH);
uid = iwl_generate_scan_uid(mvm, IWL_UMAC_SCAN_UID_REG_SCAN);
} else {
cmd->ooc_priority = cpu_to_le32(IWL_SCAN_PRIORITY_LOW);
uid = iwl_generate_scan_uid(mvm, IWL_UMAC_SCAN_UID_SCHED_SCAN);
flags |= IWL_UMAC_SCAN_GEN_FLAGS_PERIODIC;
}

mvm->scan_uid[uid_idx] = uid;
cmd->uid = cpu_to_le32(uid);

if (params->pass_all)
flags |= IWL_UMAC_SCAN_GEN_FLAGS_PASS_ALL;
else
flags |= IWL_UMAC_SCAN_GEN_FLAGS_MATCH;

cmd->general_flags = cpu_to_le32(flags);
cmd->general_flags = cpu_to_le32(iwl_mvm_scan_umac_flags(mvm, params));

if (iwl_mvm_scan_use_ebs(mvm, n_iterations))
cmd->channel_flags = IWL_SCAN_CHANNEL_FLAG_EBS |
Expand Down

0 comments on commit 6f4dcc7

Please sign in to comment.