提交 45d1b12e 编写于 作者: L Luciano Coelho 提交者: Emmanuel Grumbach

iwlwifi: mvm: combine LMAC and UMAC preq generation

The probe request to be added to both LMAC and UMAC scan commands are
identical, so move the generation out of the LMAC/UMAC-specific code.
Signed-off-by: NLuciano Coelho <luciano.coelho@intel.com>
Signed-off-by: NEmmanuel Grumbach <emmanuel.grumbach@intel.com>
上级 4b817051
...@@ -91,6 +91,7 @@ struct iwl_mvm_scan_params { ...@@ -91,6 +91,7 @@ struct iwl_mvm_scan_params {
bool no_cck; bool no_cck;
bool pass_all; bool pass_all;
int n_match_sets; int n_match_sets;
struct iwl_scan_probe_req preq;
struct cfg80211_match_set *match_sets; struct cfg80211_match_set *match_sets;
struct _dwell { struct _dwell {
u16 passive; u16 passive;
...@@ -725,11 +726,12 @@ static u8 *iwl_mvm_copy_and_insert_ds_elem(struct iwl_mvm *mvm, const u8 *ies, ...@@ -725,11 +726,12 @@ static u8 *iwl_mvm_copy_and_insert_ds_elem(struct iwl_mvm *mvm, const u8 *ies,
static void static void
iwl_mvm_build_scan_probe(struct iwl_mvm *mvm, struct ieee80211_vif *vif, iwl_mvm_build_scan_probe(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
struct ieee80211_scan_ies *ies, struct ieee80211_scan_ies *ies,
struct iwl_scan_probe_req *preq, struct iwl_mvm_scan_params *params)
const u8 *mac_addr, const u8 *mac_addr_mask)
{ {
struct ieee80211_mgmt *frame = (struct ieee80211_mgmt *)preq->buf; struct ieee80211_mgmt *frame = (void *)params->preq.buf;
u8 *pos, *newpos; u8 *pos, *newpos;
const u8 *mac_addr = params->flags & NL80211_SCAN_FLAG_RANDOM_ADDR ?
params->mac_addr : NULL;
/* /*
* Unfortunately, right now the offload scan doesn't support randomising * Unfortunately, right now the offload scan doesn't support randomising
...@@ -738,7 +740,8 @@ iwl_mvm_build_scan_probe(struct iwl_mvm *mvm, struct ieee80211_vif *vif, ...@@ -738,7 +740,8 @@ iwl_mvm_build_scan_probe(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
* random, only when it's restarted, but at least that helps a bit. * random, only when it's restarted, but at least that helps a bit.
*/ */
if (mac_addr) if (mac_addr)
get_random_mask_addr(frame->sa, mac_addr, mac_addr_mask); get_random_mask_addr(frame->sa, mac_addr,
params->mac_addr_mask);
else else
memcpy(frame->sa, vif->addr, ETH_ALEN); memcpy(frame->sa, vif->addr, ETH_ALEN);
...@@ -751,27 +754,28 @@ iwl_mvm_build_scan_probe(struct iwl_mvm *mvm, struct ieee80211_vif *vif, ...@@ -751,27 +754,28 @@ iwl_mvm_build_scan_probe(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
*pos++ = WLAN_EID_SSID; *pos++ = WLAN_EID_SSID;
*pos++ = 0; *pos++ = 0;
preq->mac_header.offset = 0; params->preq.mac_header.offset = 0;
preq->mac_header.len = cpu_to_le16(24 + 2); params->preq.mac_header.len = cpu_to_le16(24 + 2);
/* Insert ds parameter set element on 2.4 GHz band */ /* Insert ds parameter set element on 2.4 GHz band */
newpos = iwl_mvm_copy_and_insert_ds_elem(mvm, newpos = iwl_mvm_copy_and_insert_ds_elem(mvm,
ies->ies[IEEE80211_BAND_2GHZ], ies->ies[IEEE80211_BAND_2GHZ],
ies->len[IEEE80211_BAND_2GHZ], ies->len[IEEE80211_BAND_2GHZ],
pos); pos);
preq->band_data[0].offset = cpu_to_le16(pos - preq->buf); params->preq.band_data[0].offset = cpu_to_le16(pos - params->preq.buf);
preq->band_data[0].len = cpu_to_le16(newpos - pos); params->preq.band_data[0].len = cpu_to_le16(newpos - pos);
pos = newpos; pos = newpos;
memcpy(pos, ies->ies[IEEE80211_BAND_5GHZ], memcpy(pos, ies->ies[IEEE80211_BAND_5GHZ],
ies->len[IEEE80211_BAND_5GHZ]); ies->len[IEEE80211_BAND_5GHZ]);
preq->band_data[1].offset = cpu_to_le16(pos - preq->buf); params->preq.band_data[1].offset = cpu_to_le16(pos - params->preq.buf);
preq->band_data[1].len = cpu_to_le16(ies->len[IEEE80211_BAND_5GHZ]); params->preq.band_data[1].len =
cpu_to_le16(ies->len[IEEE80211_BAND_5GHZ]);
pos += ies->len[IEEE80211_BAND_5GHZ]; pos += ies->len[IEEE80211_BAND_5GHZ];
memcpy(pos, ies->common_ies, ies->common_ie_len); memcpy(pos, ies->common_ies, ies->common_ie_len);
preq->common_data.offset = cpu_to_le16(pos - preq->buf); params->preq.common_data.offset = cpu_to_le16(pos - params->preq.buf);
preq->common_data.len = cpu_to_le16(ies->common_ie_len); params->preq.common_data.len = cpu_to_le16(ies->common_ie_len);
} }
static void static void
...@@ -809,11 +813,12 @@ static inline bool iwl_mvm_scan_fits(struct iwl_mvm *mvm, int n_ssids, ...@@ -809,11 +813,12 @@ static inline bool iwl_mvm_scan_fits(struct iwl_mvm *mvm, int n_ssids,
} }
static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif, static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
struct ieee80211_scan_ies *ies,
struct iwl_mvm_scan_params *params) struct iwl_mvm_scan_params *params)
{ {
struct iwl_scan_req_lmac *cmd = mvm->scan_cmd; struct iwl_scan_req_lmac *cmd = mvm->scan_cmd;
struct iwl_scan_probe_req *preq; struct iwl_scan_probe_req *preq =
(void *)(cmd->data + sizeof(struct iwl_scan_channel_cfg_lmac) *
mvm->fw->ucode_capa.n_scan_channels);
u32 flags = 0, ssid_bitmap = 0; u32 flags = 0, ssid_bitmap = 0;
lockdep_assert_held(&mvm->mutex); lockdep_assert_held(&mvm->mutex);
...@@ -881,24 +886,19 @@ static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif, ...@@ -881,24 +886,19 @@ static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
iwl_mvm_lmac_scan_cfg_channels(mvm, params->channels, iwl_mvm_lmac_scan_cfg_channels(mvm, params->channels,
params->n_channels, ssid_bitmap, cmd); params->n_channels, ssid_bitmap, cmd);
preq = (void *)(cmd->data + sizeof(struct iwl_scan_channel_cfg_lmac) * *preq = params->preq;
mvm->fw->ucode_capa.n_scan_channels);
iwl_mvm_build_scan_probe(mvm, vif, ies, preq,
params->flags & NL80211_SCAN_FLAG_RANDOM_ADDR ?
params->mac_addr : NULL,
params->mac_addr_mask);
return 0; return 0;
} }
static int static int
iwl_mvm_sched_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif, iwl_mvm_sched_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
struct ieee80211_scan_ies *ies, struct iwl_mvm_scan_params *params)
struct iwl_mvm_scan_params *params)
{ {
struct iwl_scan_req_lmac *cmd = mvm->scan_cmd; struct iwl_scan_req_lmac *cmd = mvm->scan_cmd;
struct iwl_scan_probe_req *preq; struct iwl_scan_probe_req *preq =
(void *)(cmd->data + sizeof(struct iwl_scan_channel_cfg_lmac) *
mvm->fw->ucode_capa.n_scan_channels);
u32 flags = 0, ssid_bitmap = 0; u32 flags = 0, ssid_bitmap = 0;
lockdep_assert_held(&mvm->mutex); lockdep_assert_held(&mvm->mutex);
...@@ -967,13 +967,7 @@ iwl_mvm_sched_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif, ...@@ -967,13 +967,7 @@ iwl_mvm_sched_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
iwl_mvm_lmac_scan_cfg_channels(mvm, params->channels, iwl_mvm_lmac_scan_cfg_channels(mvm, params->channels,
params->n_channels, ssid_bitmap, cmd); params->n_channels, ssid_bitmap, cmd);
preq = (void *)(cmd->data + sizeof(struct iwl_scan_channel_cfg_lmac) * *preq = params->preq;
mvm->fw->ucode_capa.n_scan_channels);
iwl_mvm_build_scan_probe(mvm, vif, ies, preq,
params->flags & NL80211_SCAN_FLAG_RANDOM_ADDR ?
params->mac_addr : NULL,
params->mac_addr_mask);
return 0; return 0;
} }
...@@ -1234,7 +1228,6 @@ static u32 iwl_mvm_scan_umac_common_flags(struct iwl_mvm *mvm, int n_ssids, ...@@ -1234,7 +1228,6 @@ static u32 iwl_mvm_scan_umac_common_flags(struct iwl_mvm *mvm, int n_ssids,
} }
static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif, static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
struct ieee80211_scan_ies *ies,
struct iwl_mvm_scan_params *params) struct iwl_mvm_scan_params *params)
{ {
struct iwl_scan_req_umac *cmd = mvm->scan_cmd; struct iwl_scan_req_umac *cmd = mvm->scan_cmd;
...@@ -1285,18 +1278,13 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif, ...@@ -1285,18 +1278,13 @@ static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
sec_part->schedule[0].iter_count = 1; sec_part->schedule[0].iter_count = 1;
sec_part->delay = 0; sec_part->delay = 0;
sec_part->preq = params->preq;
iwl_mvm_build_scan_probe(mvm, vif, ies, &sec_part->preq,
params->flags & NL80211_SCAN_FLAG_RANDOM_ADDR ?
params->mac_addr : NULL,
params->mac_addr_mask);
return 0; return 0;
} }
static int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm, static int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm,
struct ieee80211_vif *vif, struct ieee80211_vif *vif,
struct ieee80211_scan_ies *ies,
struct iwl_mvm_scan_params *params) struct iwl_mvm_scan_params *params)
{ {
struct iwl_scan_req_umac *cmd = mvm->scan_cmd; struct iwl_scan_req_umac *cmd = mvm->scan_cmd;
...@@ -1361,10 +1349,7 @@ static int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm, ...@@ -1361,10 +1349,7 @@ static int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm,
sec_part->delay = cpu_to_le16(params->delay); sec_part->delay = cpu_to_le16(params->delay);
} }
iwl_mvm_build_scan_probe(mvm, vif, ies, &sec_part->preq, sec_part->preq = params->preq;
params->flags & NL80211_SCAN_FLAG_RANDOM_ADDR ?
params->mac_addr : NULL,
params->mac_addr_mask);
return 0; return 0;
} }
...@@ -1464,12 +1449,14 @@ int iwl_mvm_reg_scan_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif, ...@@ -1464,12 +1449,14 @@ int iwl_mvm_reg_scan_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
iwl_mvm_scan_calc_dwell(mvm, vif, &params); iwl_mvm_scan_calc_dwell(mvm, vif, &params);
iwl_mvm_build_scan_probe(mvm, vif, ies, &params);
if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) { if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) {
hcmd.id = SCAN_REQ_UMAC; hcmd.id = SCAN_REQ_UMAC;
ret = iwl_mvm_scan_umac(mvm, vif, ies, &params); ret = iwl_mvm_scan_umac(mvm, vif, &params);
} else { } else {
hcmd.id = SCAN_OFFLOAD_REQUEST_CMD; hcmd.id = SCAN_OFFLOAD_REQUEST_CMD;
ret = iwl_mvm_scan_lmac(mvm, vif, ies, &params); ret = iwl_mvm_scan_lmac(mvm, vif, &params);
} }
if (ret) if (ret)
...@@ -1552,12 +1539,14 @@ int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm, ...@@ -1552,12 +1539,14 @@ int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
if (ret) if (ret)
return ret; return ret;
iwl_mvm_build_scan_probe(mvm, vif, ies, &params);
if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) { if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) {
hcmd.id = SCAN_REQ_UMAC; hcmd.id = SCAN_REQ_UMAC;
ret = iwl_mvm_sched_scan_umac(mvm, vif, ies, &params); ret = iwl_mvm_sched_scan_umac(mvm, vif, &params);
} else { } else {
hcmd.id = SCAN_OFFLOAD_REQUEST_CMD; hcmd.id = SCAN_OFFLOAD_REQUEST_CMD;
ret = iwl_mvm_sched_scan_lmac(mvm, vif, ies, &params); ret = iwl_mvm_sched_scan_lmac(mvm, vif, &params);
} }
if (ret) if (ret)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册