Skip to content

Commit

Permalink
ath11k: support MAC address randomization in scan
Browse files Browse the repository at this point in the history
The driver reports NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR capability
to upper layer based on the service bit firmware reported. Driver
sets the spoofed flag in scan_ctrl_flag to firmware if upper layer
has enabled this feature in scan request.

Tested-on: QCA6390 hw2.0 PCI WLAN.HST.1.0.1-01740-QCAHSTSWPLZ_V2_TO_X86-1

Signed-off-by: Carl Huang <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
ygblue authored and kvalo committed Dec 13, 2021
1 parent 5341d57 commit 9cbd7fc
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
19 changes: 19 additions & 0 deletions drivers/net/wireless/ath/ath11k/mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -3543,6 +3543,12 @@ static int ath11k_mac_op_hw_scan(struct ieee80211_hw *hw,
arg.chan_list[i] = req->channels[i]->center_freq;
}

if (req->flags & NL80211_SCAN_FLAG_RANDOM_ADDR) {
arg.scan_f_add_spoofed_mac_in_probe = 1;
ether_addr_copy(arg.mac_addr.addr, req->mac_addr);
ether_addr_copy(arg.mac_mask.addr, req->mac_addr_mask);
}

ret = ath11k_start_scan(ar, &arg);
if (ret) {
ath11k_warn(ar->ab, "failed to start hw scan: %d\n", ret);
Expand Down Expand Up @@ -5587,6 +5593,14 @@ static int ath11k_mac_op_start(struct ieee80211_hw *hw)
goto err;
}

if (test_bit(WMI_TLV_SERVICE_SPOOF_MAC_SUPPORT, ar->wmi->wmi_ab->svc_map)) {
ret = ath11k_wmi_scan_prob_req_oui(ar, ar->mac_addr);
if (ret) {
ath11k_err(ab, "failed to set prob req oui: %i\n", ret);
goto err;
}
}

ret = ath11k_wmi_pdev_set_param(ar, WMI_PDEV_PARAM_ARP_AC_OVERRIDE,
0, pdev->pdev_id);
if (ret) {
Expand Down Expand Up @@ -8183,6 +8197,11 @@ static int __ath11k_mac_register(struct ath11k *ar)

ar->hw->wiphy->max_ap_assoc_sta = ar->max_num_stations;

if (test_bit(WMI_TLV_SERVICE_SPOOF_MAC_SUPPORT, ar->wmi->wmi_ab->svc_map)) {
ar->hw->wiphy->features |=
NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR;
}

ar->hw->queues = ATH11K_HW_MAX_QUEUES;
ar->hw->wiphy->tx_queue_len = ATH11K_QUEUE_LEN;
ar->hw->offchannel_tx_hw_queue = ATH11K_HW_MAX_QUEUES - 1;
Expand Down
30 changes: 30 additions & 0 deletions drivers/net/wireless/ath/ath11k/wmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2181,6 +2181,8 @@ int ath11k_wmi_send_scan_start_cmd(struct ath11k *ar,
cmd->num_ssids = params->num_ssids;
cmd->ie_len = params->extraie.len;
cmd->n_probes = params->n_probes;
ether_addr_copy(cmd->mac_addr.addr, params->mac_addr.addr);
ether_addr_copy(cmd->mac_mask.addr, params->mac_mask.addr);

ptr += sizeof(*cmd);

Expand Down Expand Up @@ -7710,3 +7712,31 @@ int ath11k_wmi_wow_enable(struct ath11k *ar)

return ath11k_wmi_cmd_send(ar->wmi, skb, WMI_WOW_ENABLE_CMDID);
}

int ath11k_wmi_scan_prob_req_oui(struct ath11k *ar,
const u8 mac_addr[ETH_ALEN])
{
struct sk_buff *skb;
struct wmi_scan_prob_req_oui_cmd *cmd;
u32 prob_req_oui;
int len;

prob_req_oui = (((u32)mac_addr[0]) << 16) |
(((u32)mac_addr[1]) << 8) | mac_addr[2];

len = sizeof(*cmd);
skb = ath11k_wmi_alloc_skb(ar->wmi->wmi_ab, len);
if (!skb)
return -ENOMEM;

cmd = (struct wmi_scan_prob_req_oui_cmd *)skb->data;
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG,
WMI_TAG_SCAN_PROB_REQ_OUI_CMD) |
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
cmd->prob_req_oui = prob_req_oui;

ath11k_dbg(ar->ab, ATH11K_DBG_WMI, "wmi scan prob req oui %d\n",
prob_req_oui);

return ath11k_wmi_cmd_send(ar->wmi, skb, WMI_SCAN_PROB_REQ_OUI_CMDID);
}
10 changes: 9 additions & 1 deletion drivers/net/wireless/ath/ath11k/wmi.h
Original file line number Diff line number Diff line change
Expand Up @@ -3313,6 +3313,8 @@ struct scan_req_params {
u32 num_hint_bssid;
struct hint_short_ssid hint_s_ssid[WLAN_SCAN_MAX_HINT_S_SSID];
struct hint_bssid hint_bssid[WLAN_SCAN_MAX_HINT_BSSID];
struct wmi_mac_addr mac_addr;
struct wmi_mac_addr mac_mask;
};

struct wmi_ssid_arg {
Expand Down Expand Up @@ -3676,6 +3678,11 @@ struct wmi_scan_chan_list_cmd {
u32 pdev_id;
} __packed;

struct wmi_scan_prob_req_oui_cmd {
u32 tlv_header;
u32 prob_req_oui;
} __packed;

#define WMI_MGMT_SEND_DOWNLD_LEN 64

#define WMI_TX_PARAMS_DWORD0_POWER GENMASK(7, 0)
Expand Down Expand Up @@ -5530,5 +5537,6 @@ int ath11k_wmi_set_hw_mode(struct ath11k_base *ab,
enum wmi_host_hw_mode_config_type mode);
int ath11k_wmi_wow_host_wakeup_ind(struct ath11k *ar);
int ath11k_wmi_wow_enable(struct ath11k *ar);

int ath11k_wmi_scan_prob_req_oui(struct ath11k *ar,
const u8 mac_addr[ETH_ALEN]);
#endif

0 comments on commit 9cbd7fc

Please sign in to comment.