Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2321781pxb; Tue, 12 Oct 2021 04:16:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6sjmJ+Q2z4krJ8lvnAweB0gg8HplsXrScWJeXMYLBcT5TvbUR3jePYfLTMNY5Le6mFcUt X-Received: by 2002:aa7:9f46:0:b0:44c:7912:9b2e with SMTP id h6-20020aa79f46000000b0044c79129b2emr30165541pfr.11.1634037388668; Tue, 12 Oct 2021 04:16:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634037388; cv=none; d=google.com; s=arc-20160816; b=RpNF3ypgcfeigj7kfJ8x0FN7V1ToCT+YN7ODjnSbS9Ds6S/+AWjPL/cu5UEVlWwQo5 zcOtRHV7YkjlD86al4Hz7LSNyPWUp8UXhVJegE3ceCJyz46TRFni2rnAIOqjHcD5zV32 AmpXbn86bV9Ndl0bjTc3myQi/LwPSGq0aRr6lpKItXxzIiG88TKaWUn+69v38a3dM+3y CTihd5/krNIcPGBYtXxsjR99wFqCuNqcuO2l/icCpvcmUYIxT5LutI9MIDjJIBPDl70j S4YMgEBUvzlOKv3vgTF37bwJ20FO7Ix/E9Sg9ScSahC1okpK3fY4waBB+ARVb64QNZ/t zqXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from:dmarc-filter :sender:dkim-signature; bh=RLwtSyczHXrmwI41URsgeQHDCH2qk5zy2DPYlSlzIDI=; b=Lp58XsBUuI9Uj56Ega6zzPJ73iqWvXtVo1CvNbdgVXgcXF1o75GsDOQ/mfKf6tBWnP bdyIQsx792blTm2I8dq4pIK0qL2nRulkWiSyETxgp1hdwgfKxgiTXyK1O2rRkpn+BXzk NUtrL816TTqVJ9wiscDv27YhNmToI9J8b9foiRC1Y4UQKwLdo4riU8tH9338ScC67XT4 79pYbHhM6hBDI4t/PdiBtfTzA2Q1d2T1zG4yExWDQEgzDStYm+B/hauyoL5tIa9fW7C8 Z4ysmABh9JeHxag7v4FRIPhox8NUIJXgW7Cvo0917lwGkPyBNgmtoJSXpqIWGA90xIE2 soKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=pEixJMwz; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 22si3038174pju.30.2021.10.12.04.16.14; Tue, 12 Oct 2021 04:16:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=pEixJMwz; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236065AbhJLLSM (ORCPT + 63 others); Tue, 12 Oct 2021 07:18:12 -0400 Received: from so254-9.mailgun.net ([198.61.254.9]:19671 "EHLO so254-9.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232475AbhJLLSK (ORCPT ); Tue, 12 Oct 2021 07:18:10 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1634037368; h=Message-Id: Date: Subject: Cc: To: From: Sender; bh=RLwtSyczHXrmwI41URsgeQHDCH2qk5zy2DPYlSlzIDI=; b=pEixJMwzUJJqKfqwt2qUo+EAx4oj8lwIEcq1g5iNgnqHwREQZakVi2xyfbwWbuZlIQAZSnKj m10BtB6u9VTB5XGUTRw52vhZhWzQrqGi9lRfMAYjyaxKGBYVVDJz6Wdn2llFMR7Q88h2mesd fFjnUGfxzHcJB08lXgiL0NHqEsA= X-Mailgun-Sending-Ip: 198.61.254.9 X-Mailgun-Sid: WyI3YTAwOSIsICJsaW51eC13aXJlbGVzc0B2Z2VyLmtlcm5lbC5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n05.prod.us-west-2.postgun.com with SMTP id 61656e77f3e5b80f1fcc8044 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 12 Oct 2021 11:16:07 GMT Sender: cjhuang=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 85058C4360D; Tue, 12 Oct 2021 11:16:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_06_12,SPF_FAIL autolearn=no autolearn_force=no version=3.4.0 Received: from cjhuang-Inspiron-7590.qca.qualcomm.com (unknown [180.166.53.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: cjhuang) by smtp.codeaurora.org (Postfix) with ESMTPSA id 42DA3C4338F; Tue, 12 Oct 2021 11:16:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 smtp.codeaurora.org 42DA3C4338F Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=codeaurora.org From: Carl Huang To: ath11k@lists.infradead.org Cc: linux-wireless@vger.kernel.org Subject: [PATCH] ath11k: support MAC address randomization in scan Date: Tue, 12 Oct 2021 15:16:38 -0400 Message-Id: <20211012191638.8749-1-cjhuang@codeaurora.org> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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 --- drivers/net/wireless/ath/ath11k/mac.c | 19 +++++++++++++++++++ drivers/net/wireless/ath/ath11k/wmi.c | 30 ++++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath11k/wmi.h | 9 +++++++++ 3 files changed, 58 insertions(+) diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c index 797e45e..bb5d12f40 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -3048,6 +3048,12 @@ static int ath11k_mac_op_hw_scan(struct ieee80211_hw *hw, arg.scan_flags |= WMI_SCAN_FLAG_PASSIVE; } + 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); + } + if (req->n_channels) { arg.num_chan = req->n_channels; for (i = 0; i < arg.num_chan; i++) @@ -4992,6 +4998,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) { @@ -7888,6 +7902,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; + } + if (test_bit(WMI_TLV_SERVICE_NLO, ar->wmi->wmi_ab->svc_map)) { ar->hw->wiphy->max_sched_scan_ssids = WMI_PNO_MAX_SUPP_NETWORKS; ar->hw->wiphy->max_match_sets = WMI_PNO_MAX_SUPP_NETWORKS; diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c index 5b02e95..888c587 100644 --- a/drivers/net/wireless/ath/ath11k/wmi.c +++ b/drivers/net/wireless/ath/ath11k/wmi.c @@ -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); @@ -8983,3 +8985,31 @@ int ath11k_wmi_gtk_rekey_getinfo(struct ath11k *ar, arvif->vdev_id); return ath11k_wmi_cmd_send(ar->wmi, skb, WMI_GTK_OFFLOAD_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); +} diff --git a/drivers/net/wireless/ath/ath11k/wmi.h b/drivers/net/wireless/ath/ath11k/wmi.h index 61dc5ea..6848089 100644 --- a/drivers/net/wireless/ath/ath11k/wmi.h +++ b/drivers/net/wireless/ath/ath11k/wmi.h @@ -3369,6 +3369,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 { @@ -3749,6 +3751,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) @@ -6056,4 +6063,6 @@ int ath11k_wmi_gtk_rekey_offload(struct ath11k *ar, struct ath11k_vif *arvif, bool enable); int ath11k_wmi_gtk_rekey_getinfo(struct ath11k *ar, struct ath11k_vif *arvif); +int ath11k_wmi_scan_prob_req_oui(struct ath11k *ar, + const u8 mac_addr[ETH_ALEN]); #endif -- 2.7.4