Commit 9cbd7fc9 authored by Carl Huang's avatar Carl Huang Committed by Kalle Valo
Browse files

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: default avatarCarl Huang <quic_cjhuang@quicinc.com>
Signed-off-by: default avatarKalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/1638948007-9609-1-git-send-email-quic_cjhuang@quicinc.com
parent 5341d57b
Loading
Loading
Loading
Loading
+19 −0
Original line number Original line Diff line number Diff line
@@ -3543,6 +3543,12 @@ static int ath11k_mac_op_hw_scan(struct ieee80211_hw *hw,
			arg.chan_list[i] = req->channels[i]->center_freq;
			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);
	ret = ath11k_start_scan(ar, &arg);
	if (ret) {
	if (ret) {
		ath11k_warn(ar->ab, "failed to start hw scan: %d\n", ret);
		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)
		goto err;
		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,
	ret = ath11k_wmi_pdev_set_param(ar, WMI_PDEV_PARAM_ARP_AC_OVERRIDE,
					0, pdev->pdev_id);
					0, pdev->pdev_id);
	if (ret) {
	if (ret) {
@@ -8183,6 +8197,11 @@ static int __ath11k_mac_register(struct ath11k *ar)


	ar->hw->wiphy->max_ap_assoc_sta = ar->max_num_stations;
	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->queues = ATH11K_HW_MAX_QUEUES;
	ar->hw->wiphy->tx_queue_len = ATH11K_QUEUE_LEN;
	ar->hw->wiphy->tx_queue_len = ATH11K_QUEUE_LEN;
	ar->hw->offchannel_tx_hw_queue = ATH11K_HW_MAX_QUEUES - 1;
	ar->hw->offchannel_tx_hw_queue = ATH11K_HW_MAX_QUEUES - 1;
+30 −0
Original line number Original line Diff line number Diff line
@@ -2181,6 +2181,8 @@ int ath11k_wmi_send_scan_start_cmd(struct ath11k *ar,
	cmd->num_ssids = params->num_ssids;
	cmd->num_ssids = params->num_ssids;
	cmd->ie_len = params->extraie.len;
	cmd->ie_len = params->extraie.len;
	cmd->n_probes = params->n_probes;
	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);
	ptr += sizeof(*cmd);


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


	return ath11k_wmi_cmd_send(ar->wmi, skb, WMI_WOW_ENABLE_CMDID);
	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);
}
+9 −1
Original line number Original line Diff line number Diff line
@@ -3313,6 +3313,8 @@ struct scan_req_params {
	u32 num_hint_bssid;
	u32 num_hint_bssid;
	struct hint_short_ssid hint_s_ssid[WLAN_SCAN_MAX_HINT_S_SSID];
	struct hint_short_ssid hint_s_ssid[WLAN_SCAN_MAX_HINT_S_SSID];
	struct hint_bssid hint_bssid[WLAN_SCAN_MAX_HINT_BSSID];
	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 {
struct wmi_ssid_arg {
@@ -3676,6 +3678,11 @@ struct wmi_scan_chan_list_cmd {
	u32 pdev_id;
	u32 pdev_id;
} __packed;
} __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_MGMT_SEND_DOWNLD_LEN	64


#define WMI_TX_PARAMS_DWORD0_POWER		GENMASK(7, 0)
#define WMI_TX_PARAMS_DWORD0_POWER		GENMASK(7, 0)
@@ -5530,5 +5537,6 @@ int ath11k_wmi_set_hw_mode(struct ath11k_base *ab,
			   enum wmi_host_hw_mode_config_type mode);
			   enum wmi_host_hw_mode_config_type mode);
int ath11k_wmi_wow_host_wakeup_ind(struct ath11k *ar);
int ath11k_wmi_wow_host_wakeup_ind(struct ath11k *ar);
int ath11k_wmi_wow_enable(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
#endif