Skip to content

Commit 9cbd7fc

Browse files
ygbluekvalo
authored andcommitted
ath11k: support MAC address randomization in scan
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]
1 parent 5341d57 commit 9cbd7fc

File tree

3 files changed

+58
-1
lines changed

3 files changed

+58
-1
lines changed

drivers/net/wireless/ath/ath11k/mac.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3543,6 +3543,12 @@ static int ath11k_mac_op_hw_scan(struct ieee80211_hw *hw,
35433543
arg.chan_list[i] = req->channels[i]->center_freq;
35443544
}
35453545

3546+
if (req->flags & NL80211_SCAN_FLAG_RANDOM_ADDR) {
3547+
arg.scan_f_add_spoofed_mac_in_probe = 1;
3548+
ether_addr_copy(arg.mac_addr.addr, req->mac_addr);
3549+
ether_addr_copy(arg.mac_mask.addr, req->mac_addr_mask);
3550+
}
3551+
35463552
ret = ath11k_start_scan(ar, &arg);
35473553
if (ret) {
35483554
ath11k_warn(ar->ab, "failed to start hw scan: %d\n", ret);
@@ -5587,6 +5593,14 @@ static int ath11k_mac_op_start(struct ieee80211_hw *hw)
55875593
goto err;
55885594
}
55895595

5596+
if (test_bit(WMI_TLV_SERVICE_SPOOF_MAC_SUPPORT, ar->wmi->wmi_ab->svc_map)) {
5597+
ret = ath11k_wmi_scan_prob_req_oui(ar, ar->mac_addr);
5598+
if (ret) {
5599+
ath11k_err(ab, "failed to set prob req oui: %i\n", ret);
5600+
goto err;
5601+
}
5602+
}
5603+
55905604
ret = ath11k_wmi_pdev_set_param(ar, WMI_PDEV_PARAM_ARP_AC_OVERRIDE,
55915605
0, pdev->pdev_id);
55925606
if (ret) {
@@ -8183,6 +8197,11 @@ static int __ath11k_mac_register(struct ath11k *ar)
81838197

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

8200+
if (test_bit(WMI_TLV_SERVICE_SPOOF_MAC_SUPPORT, ar->wmi->wmi_ab->svc_map)) {
8201+
ar->hw->wiphy->features |=
8202+
NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR;
8203+
}
8204+
81868205
ar->hw->queues = ATH11K_HW_MAX_QUEUES;
81878206
ar->hw->wiphy->tx_queue_len = ATH11K_QUEUE_LEN;
81888207
ar->hw->offchannel_tx_hw_queue = ATH11K_HW_MAX_QUEUES - 1;

drivers/net/wireless/ath/ath11k/wmi.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2181,6 +2181,8 @@ int ath11k_wmi_send_scan_start_cmd(struct ath11k *ar,
21812181
cmd->num_ssids = params->num_ssids;
21822182
cmd->ie_len = params->extraie.len;
21832183
cmd->n_probes = params->n_probes;
2184+
ether_addr_copy(cmd->mac_addr.addr, params->mac_addr.addr);
2185+
ether_addr_copy(cmd->mac_mask.addr, params->mac_mask.addr);
21842186

21852187
ptr += sizeof(*cmd);
21862188

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

77117713
return ath11k_wmi_cmd_send(ar->wmi, skb, WMI_WOW_ENABLE_CMDID);
77127714
}
7715+
7716+
int ath11k_wmi_scan_prob_req_oui(struct ath11k *ar,
7717+
const u8 mac_addr[ETH_ALEN])
7718+
{
7719+
struct sk_buff *skb;
7720+
struct wmi_scan_prob_req_oui_cmd *cmd;
7721+
u32 prob_req_oui;
7722+
int len;
7723+
7724+
prob_req_oui = (((u32)mac_addr[0]) << 16) |
7725+
(((u32)mac_addr[1]) << 8) | mac_addr[2];
7726+
7727+
len = sizeof(*cmd);
7728+
skb = ath11k_wmi_alloc_skb(ar->wmi->wmi_ab, len);
7729+
if (!skb)
7730+
return -ENOMEM;
7731+
7732+
cmd = (struct wmi_scan_prob_req_oui_cmd *)skb->data;
7733+
cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG,
7734+
WMI_TAG_SCAN_PROB_REQ_OUI_CMD) |
7735+
FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
7736+
cmd->prob_req_oui = prob_req_oui;
7737+
7738+
ath11k_dbg(ar->ab, ATH11K_DBG_WMI, "wmi scan prob req oui %d\n",
7739+
prob_req_oui);
7740+
7741+
return ath11k_wmi_cmd_send(ar->wmi, skb, WMI_SCAN_PROB_REQ_OUI_CMDID);
7742+
}

drivers/net/wireless/ath/ath11k/wmi.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3313,6 +3313,8 @@ struct scan_req_params {
33133313
u32 num_hint_bssid;
33143314
struct hint_short_ssid hint_s_ssid[WLAN_SCAN_MAX_HINT_S_SSID];
33153315
struct hint_bssid hint_bssid[WLAN_SCAN_MAX_HINT_BSSID];
3316+
struct wmi_mac_addr mac_addr;
3317+
struct wmi_mac_addr mac_mask;
33163318
};
33173319

33183320
struct wmi_ssid_arg {
@@ -3676,6 +3678,11 @@ struct wmi_scan_chan_list_cmd {
36763678
u32 pdev_id;
36773679
} __packed;
36783680

3681+
struct wmi_scan_prob_req_oui_cmd {
3682+
u32 tlv_header;
3683+
u32 prob_req_oui;
3684+
} __packed;
3685+
36793686
#define WMI_MGMT_SEND_DOWNLD_LEN 64
36803687

36813688
#define WMI_TX_PARAMS_DWORD0_POWER GENMASK(7, 0)
@@ -5530,5 +5537,6 @@ int ath11k_wmi_set_hw_mode(struct ath11k_base *ab,
55305537
enum wmi_host_hw_mode_config_type mode);
55315538
int ath11k_wmi_wow_host_wakeup_ind(struct ath11k *ar);
55325539
int ath11k_wmi_wow_enable(struct ath11k *ar);
5533-
5540+
int ath11k_wmi_scan_prob_req_oui(struct ath11k *ar,
5541+
const u8 mac_addr[ETH_ALEN]);
55345542
#endif

0 commit comments

Comments
 (0)