Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2741782pxj; Mon, 31 May 2021 09:34:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqU89dJ0+VmiEfocfiDpb3RTLobhM/X1occ2Pa7I1oszqFJrMwQKe+uZM2gxNb4pFKVjYs X-Received: by 2002:aa7:c913:: with SMTP id b19mr207231edt.323.1622478895632; Mon, 31 May 2021 09:34:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622478895; cv=none; d=google.com; s=arc-20160816; b=k9cTyUIi70JNJiyfTduTGjjZ5Xoioq/A83soOhZn3+T1EbGYa+L9ENuaNJ8LLH2yaw YISczjfPZVedohjW4Gx0hsLWXuX01bkFW02KJEdNN+bykHMNLGFW2XKbXVaZfM1eExrO mT/J0KFamqDClUmotKN/CFv2emkBxfbwM+7Qo4OrQXoNKcfk4sbZACYUwTNa1SajXdWt evK9Vgfz9noSfl/Vkm7TaZE7A8XvboDZ0162Nvlheyp5XL1UDLM8BF6dqMzo7+SwQQ6e QW4LyDanArftDFCr61A2662mdQM7ICp2KLJby/RzvNpwa3/wALzOTOXwLiMor8449BtL fQyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=QUWezePrlj0Gd02c4dXe4gnZoik1hHXsklo1yx9wtTk=; b=M7IMgrIK/x/hkjUuyEYeOQs31I7SQ/t00HlIRpCDZUWJeOojgLYTz0GiTW4ntoaQk2 fHp3/7wGhq2s6CXtB8IMXIbBC4L4AWek1TA7qFPH3f7gv3lU0P+11vvflAOABdQigj0G gD8RnOBrQumDzGeoRUp7zxRgK7Hj3PYztYETvppLgcAvQFkRa2q07mbn05MVXoL/Z9b0 99PsBKhvN2KIfXOot7d/nDrC7Kr5VNJ2uFTpgmLH8hvaY/eVCuZ3Akm1JZxuJtOMrQCi IjtINaMegWK6S5aRAfZ0Haah8qQc+I+cj0Rx7pMJ1nSkGZNbmXzmupe2Lic93Awmqpvj 5icA== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g18si13697468edt.478.2021.05.31.09.34.25; Mon, 31 May 2021 09:34:55 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234121AbhEaQcb (ORCPT + 99 others); Mon, 31 May 2021 12:32:31 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:58144 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S234746AbhEaQaV (ORCPT ); Mon, 31 May 2021 12:30:21 -0400 X-UUID: 80e9839df25f4914b62f51502a4959a7-20210601 X-UUID: 80e9839df25f4914b62f51502a4959a7-20210601 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 813919618; Tue, 01 Jun 2021 00:28:36 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs06n2.mediatek.inc (172.21.101.130) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 1 Jun 2021 00:28:35 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 1 Jun 2021 00:28:34 +0800 From: Deren Wu To: Felix Fietkau , Lorenzo Bianconi CC: Sean Wang , Soul Huang , YN Chen , Leon Yen , Eric-SY Chang , Deren Wu , KM Lin , Robin Chiu , CH Yeh , Posh Sun , Eric Liang , Stella Chang , , , linux-wireless , linux-mediatek , Deren Wu Subject: [PATCH] mt76: mt7921: enable random mac address during sched_scan Date: Tue, 1 Jun 2021 00:28:31 +0800 Message-ID: <14360a28083d56520a2cabc87841d9dee3d97a01.1622476643.git.deren.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Deren Wu Enable src address randomization during scheduled scanning Co-developed-by: Lorenzo Bianconi Signed-off-by: Deren Wu --- .../net/wireless/mediatek/mt76/mt76_connac_mcu.c | 14 ++++++++------ .../net/wireless/mediatek/mt76/mt76_connac_mcu.h | 4 +++- drivers/net/wireless/mediatek/mt76/mt7921/init.c | 3 ++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c index 73359defa176..b155e7b8d89d 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c @@ -1515,14 +1515,16 @@ int mt76_connac_mcu_sched_scan_req(struct mt76_phy *phy, req->version = 1; req->seq_num = mvif->scan_seq_num | ext_phy << 7; - if (is_mt7663(phy->dev) && - (sreq->flags & NL80211_SCAN_FLAG_RANDOM_ADDR)) { - get_random_mask_addr(req->mt7663.random_mac, sreq->mac_addr, - sreq->mac_addr_mask); + if (sreq->flags & NL80211_SCAN_FLAG_RANDOM_ADDR) { + u8 *addr = is_mt7663(phy->dev) ? req->mt7663.random_mac + : req->mt7921.random_mac; + req->scan_func = 1; - } else if (is_mt7921(phy->dev)) { - req->mt7921.bss_idx = mvif->idx; + get_random_mask_addr(addr, sreq->mac_addr, + sreq->mac_addr_mask); } + if (is_mt7921(phy->dev)) + req->mt7921.bss_idx = mvif->idx; req->ssids_num = sreq->n_ssids; for (i = 0; i < req->ssids_num; i++) { diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h index d64b8058b744..3076417ead5f 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h @@ -779,7 +779,9 @@ struct mt76_connac_sched_scan_req { } mt7663; struct { u8 bss_idx; - u8 pad2[63]; + u8 pad2[19]; + u8 random_mac[ETH_ALEN]; + u8 pad3[38]; } mt7921; }; } __packed; diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/init.c b/drivers/net/wireless/mediatek/mt76/mt7921/init.c index 59da29032645..19ce9ca72542 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/init.c @@ -76,7 +76,8 @@ mt7921_init_wiphy(struct ieee80211_hw *hw) wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH; wiphy->reg_notifier = mt7921_regd_notifier; - wiphy->features |= NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR; + wiphy->features |= NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR | + NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR; wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_SET_SCAN_DWELL); ieee80211_hw_set(hw, SINGLE_SCAN_ON_ALL_BANDS); -- 2.18.0