Skip to content

Commit

Permalink
iwlwifi: mvm: combine parts of UMAC and LMAC sched scans
Browse files Browse the repository at this point in the history
Similarly to the regular scan patch, a lot of the UMAC and LMAC sched
scan code is also almost identical.  Grab the low hanging fruits by
combining the obvious parts.

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 3db7c6e commit 8df3e68
Showing 1 changed file with 47 additions and 74 deletions.
121 changes: 47 additions & 74 deletions drivers/net/wireless/iwlwifi/mvm/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -894,32 +894,16 @@ static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
static int iwl_mvm_sched_scan_lmac(struct iwl_mvm *mvm,
struct ieee80211_vif *vif,
struct cfg80211_sched_scan_request *req,
struct ieee80211_scan_ies *ies)
struct ieee80211_scan_ies *ies,
struct iwl_mvm_scan_params *params)
{
struct iwl_host_cmd hcmd = {
.id = SCAN_OFFLOAD_REQUEST_CMD,
.len = { iwl_mvm_scan_size(mvm), },
.data = { mvm->scan_cmd, },
.dataflags = { IWL_HCMD_DFL_NOCOPY, },
};
struct iwl_scan_req_lmac *cmd = mvm->scan_cmd;
struct iwl_scan_probe_req *preq;
struct iwl_mvm_scan_params params = {};
int ret;
u32 flags = 0, ssid_bitmap = 0;

lockdep_assert_held(&mvm->mutex);

/* we should have failed registration if scan_cmd was NULL */
if (WARN_ON(mvm->scan_cmd == NULL))
return -ENOMEM;

if (!iwl_mvm_scan_fits(mvm, req->n_ssids, ies, req->n_channels))
return -ENOBUFS;

iwl_mvm_scan_calc_params(mvm, vif, req->n_ssids, 0, &params);

iwl_mvm_build_generic_scan_cmd(mvm, cmd, &params);
iwl_mvm_build_generic_scan_cmd(mvm, cmd, params);

cmd->n_channels = (u8)req->n_channels;

Expand All @@ -933,7 +917,7 @@ static int iwl_mvm_sched_scan_lmac(struct iwl_mvm *mvm,
if (req->n_ssids == 1 && req->ssids[0].ssid_len != 0)
flags |= IWL_MVM_LMAC_SCAN_FLAG_PRE_CONNECTION;

if (params.passive_fragmented)
if (params->passive_fragmented)
flags |= IWL_MVM_LMAC_SCAN_FLAG_FRAGMENTED;

if (req->n_ssids == 0)
Expand Down Expand Up @@ -987,21 +971,7 @@ static int iwl_mvm_sched_scan_lmac(struct iwl_mvm *mvm,
req->mac_addr : NULL,
req->mac_addr_mask);

ret = iwl_mvm_send_cmd(mvm, &hcmd);
if (!ret) {
IWL_DEBUG_SCAN(mvm,
"Sched scan request was sent successfully\n");
} else {
/*
* If the scan failed, it usually means that the FW was unable
* to allocate the time events. Warn on it, but maybe we
* should try to send the command again with different params.
*/
IWL_ERR(mvm, "Sched scan failed! ret %d\n", ret);
mvm->scan_status &= ~IWL_MVM_SCAN_SCHED;
ret = -EIO;
}
return ret;
return 0;
}


Expand Down Expand Up @@ -1325,41 +1295,24 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
static int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm,
struct ieee80211_vif *vif,
struct cfg80211_sched_scan_request *req,
struct ieee80211_scan_ies *ies)
struct ieee80211_scan_ies *ies,
struct iwl_mvm_scan_params *params)
{

struct iwl_host_cmd hcmd = {
.id = SCAN_REQ_UMAC,
.len = { iwl_mvm_scan_size(mvm), },
.data = { mvm->scan_cmd, },
.dataflags = { IWL_HCMD_DFL_NOCOPY, },
};
struct iwl_scan_req_umac *cmd = mvm->scan_cmd;
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;
struct iwl_mvm_scan_params params = {};
u32 uid, flags;
u32 ssid_bitmap = 0;
int ret, uid_idx;
int uid_idx;

lockdep_assert_held(&mvm->mutex);

uid_idx = iwl_mvm_find_free_scan_uid(mvm);
if (uid_idx >= mvm->max_scans)
return -EBUSY;

/* we should have failed registration if scan_cmd was NULL */
if (WARN_ON(mvm->scan_cmd == NULL))
return -ENOMEM;

if (!iwl_mvm_scan_fits(mvm, req->n_ssids, ies, req->n_channels))
return -ENOBUFS;

iwl_mvm_scan_calc_params(mvm, vif, req->n_ssids, req->flags,
&params);

iwl_mvm_build_generic_umac_scan_cmd(mvm, cmd, &params);
iwl_mvm_build_generic_umac_scan_cmd(mvm, cmd, params);

cmd->flags = cpu_to_le32(IWL_UMAC_SCAN_FLAG_PREEMPTIVE);

Expand All @@ -1370,7 +1323,7 @@ static int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm,
cmd->ooc_priority = cpu_to_le32(IWL_SCAN_PRIORITY_LOW);

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

flags |= IWL_UMAC_SCAN_GEN_FLAGS_PERIODIC;

Expand Down Expand Up @@ -1415,19 +1368,7 @@ static int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm,
req->mac_addr : NULL,
req->mac_addr_mask);

ret = iwl_mvm_send_cmd(mvm, &hcmd);
if (!ret) {
IWL_DEBUG_SCAN(mvm,
"Sched scan request was sent successfully\n");
} else {
/*
* If the scan failed, it usually means that the FW was unable
* to allocate the time events. Warn on it, but maybe we
* should try to send the command again with different params.
*/
IWL_ERR(mvm, "Sched scan failed! ret %d\n", ret);
}
return ret;
return 0;
}

static int iwl_mvm_num_scans(struct iwl_mvm *mvm)
Expand Down Expand Up @@ -1547,6 +1488,12 @@ int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
struct ieee80211_scan_ies *ies,
int type)
{
struct iwl_host_cmd hcmd = {
.len = { iwl_mvm_scan_size(mvm), },
.data = { mvm->scan_cmd, },
.dataflags = { IWL_HCMD_DFL_NOCOPY, },
};
struct iwl_mvm_scan_params params = {};
int ret;

lockdep_assert_held(&mvm->mutex);
Expand All @@ -1560,16 +1507,42 @@ int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
if (ret)
return ret;

/* we should have failed registration if scan_cmd was NULL */
if (WARN_ON(!mvm->scan_cmd))
return -ENOMEM;

if (!iwl_mvm_scan_fits(mvm, req->n_ssids, ies, req->n_channels))
return -ENOBUFS;

iwl_mvm_scan_calc_params(mvm, vif, req->n_ssids, req->flags,
&params);

ret = iwl_mvm_config_sched_scan_profiles(mvm, req);
if (ret)
return ret;

if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) {
ret = iwl_mvm_sched_scan_umac(mvm, vif, req, ies);
hcmd.id = SCAN_REQ_UMAC;
ret = iwl_mvm_sched_scan_umac(mvm, vif, req, ies, &params);
} else {
ret = iwl_mvm_sched_scan_lmac(mvm, vif, req, ies);
if (!ret)
mvm->scan_status |= IWL_MVM_SCAN_SCHED;
hcmd.id = SCAN_OFFLOAD_REQUEST_CMD;
ret = iwl_mvm_sched_scan_lmac(mvm, vif, req, ies, &params);
}

if (ret)
return ret;

ret = iwl_mvm_send_cmd(mvm, &hcmd);
if (!ret) {
IWL_DEBUG_SCAN(mvm,
"Sched scan request was sent successfully\n");
mvm->scan_status |= type;
} else {
/* If the scan failed, it usually means that the FW was unable
* to allocate the time events. Warn on it, but maybe we
* should try to send the command again with different params.
*/
IWL_ERR(mvm, "Sched scan failed! ret %d\n", ret);
}

return ret;
Expand Down

0 comments on commit 8df3e68

Please sign in to comment.