Skip to content

Commit

Permalink
iwlwifi: mvm: support random MAC address for scanning
Browse files Browse the repository at this point in the history
For background and scheduled scan, using the new unified scan API,
support random MAC address scanning.

Unfortunately, the firmware right now doesn't support randomising
itself, so for now do it on the host - we'll change this once the
firmware supports randomising the address for each scan iteration
using the address/mask.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
  • Loading branch information
jmberg-intel authored and egrumbach committed Nov 23, 2014
1 parent b975e55 commit effd05a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
6 changes: 5 additions & 1 deletion drivers/net/wireless/iwlwifi/mvm/mac80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,12 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm)
}

if (mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_LMAC_SCAN ||
mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN)
mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) {
hw->flags |= IEEE80211_SINGLE_HW_SCAN_ON_ALL_BANDS;
hw->wiphy->features |=
NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR |
NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR;
}

hw->sta_data_size = sizeof(struct iwl_mvm_sta);
hw->vif_data_size = sizeof(struct iwl_mvm_vif);
Expand Down
35 changes: 29 additions & 6 deletions drivers/net/wireless/iwlwifi/mvm/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1224,14 +1224,25 @@ static u8 *iwl_mvm_copy_and_insert_ds_elem(struct iwl_mvm *mvm, const u8 *ies,
static void
iwl_mvm_build_unified_scan_probe(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
struct ieee80211_scan_ies *ies,
struct iwl_scan_probe_req *preq)
struct iwl_scan_probe_req *preq,
const u8 *mac_addr, const u8 *mac_addr_mask)
{
struct ieee80211_mgmt *frame = (struct ieee80211_mgmt *)preq->buf;
u8 *pos, *newpos;

/*
* Unfortunately, right now the offload scan doesn't support randomising
* within the firmware, so until the firmware API is ready we implement
* it in the driver. This means that the scan iterations won't really be
* random, only when it's restarted, but at least that helps a bit.
*/
if (mac_addr)
get_random_mask_addr(frame->sa, mac_addr, mac_addr_mask);
else
memcpy(frame->sa, vif->addr, ETH_ALEN);

frame->frame_control = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ);
eth_broadcast_addr(frame->da);
memcpy(frame->sa, vif->addr, ETH_ALEN);
eth_broadcast_addr(frame->bssid);
frame->seq_ctrl = 0;

Expand Down Expand Up @@ -1375,7 +1386,10 @@ int iwl_mvm_unified_scan_lmac(struct iwl_mvm *mvm,
preq = (void *)(cmd->data + sizeof(struct iwl_scan_channel_cfg_lmac) *
mvm->fw->ucode_capa.n_scan_channels);

iwl_mvm_build_unified_scan_probe(mvm, vif, &req->ies, preq);
iwl_mvm_build_unified_scan_probe(mvm, vif, &req->ies, preq,
req->req.flags & NL80211_SCAN_FLAG_RANDOM_ADDR ?
req->req.mac_addr : NULL,
req->req.mac_addr_mask);

ret = iwl_mvm_send_cmd(mvm, &hcmd);
if (!ret) {
Expand Down Expand Up @@ -1466,7 +1480,10 @@ int iwl_mvm_unified_sched_scan_lmac(struct iwl_mvm *mvm,
preq = (void *)(cmd->data + sizeof(struct iwl_scan_channel_cfg_lmac) *
mvm->fw->ucode_capa.n_scan_channels);

iwl_mvm_build_unified_scan_probe(mvm, vif, ies, preq);
iwl_mvm_build_unified_scan_probe(mvm, vif, ies, preq,
req->flags & NL80211_SCAN_FLAG_RANDOM_ADDR ?
req->mac_addr : NULL,
req->mac_addr_mask);

ret = iwl_mvm_send_cmd(mvm, &hcmd);
if (!ret) {
Expand Down Expand Up @@ -1796,7 +1813,10 @@ int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
sec_part->schedule[0].iter_count = 1;
sec_part->delay = 0;

iwl_mvm_build_unified_scan_probe(mvm, vif, &req->ies, &sec_part->preq);
iwl_mvm_build_unified_scan_probe(mvm, vif, &req->ies, &sec_part->preq,
req->req.flags & NL80211_SCAN_FLAG_RANDOM_ADDR ?
req->req.mac_addr : NULL,
req->req.mac_addr_mask);

iwl_mvm_scan_fill_ssids(sec_part->direct_scan, req->req.ssids,
req->req.n_ssids, 0);
Expand Down Expand Up @@ -1901,7 +1921,10 @@ int iwl_mvm_sched_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif,

sec_part->delay = 0;

iwl_mvm_build_unified_scan_probe(mvm, vif, ies, &sec_part->preq);
iwl_mvm_build_unified_scan_probe(mvm, vif, ies, &sec_part->preq,
req->flags & NL80211_SCAN_FLAG_RANDOM_ADDR ?
req->mac_addr : NULL,
req->mac_addr_mask);

ret = iwl_mvm_send_cmd(mvm, &hcmd);
if (!ret) {
Expand Down

0 comments on commit effd05a

Please sign in to comment.