Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5392418rwl; Mon, 3 Apr 2023 20:06:50 -0700 (PDT) X-Google-Smtp-Source: AKy350bMfCyYzXFdeRK/bO+CmQ6LvV117H7JEW9RL36duKDc/OM/3ygJ3s+/F0sJ/cbCXl2wDryp X-Received: by 2002:a05:6402:48a:b0:502:3ff1:2fcc with SMTP id k10-20020a056402048a00b005023ff12fccmr1096263edv.35.1680577610349; Mon, 03 Apr 2023 20:06:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680577610; cv=none; d=google.com; s=arc-20160816; b=emoqWHzF0P/ahOj8FGww8purmfenU+lP4gQvertJ5vU9uIDFxcIdq4VFEgbmoJ0GD7 HUTSuduSXPIYt93vRX+0Vo+ooIRqovKEncSAyZxMVXEuBYwkUvqXAflLe+P1S9cPpzKc /2t4s0/NbkHIMBwguBFRTCNO4oncLD/gdZ8NOGgvaJZSrQl2utGaHs/rGSSMJEzdtSC2 ZHrLKMvPKHvke+w2MOWsfJSBOCWJI5I36IX1LFxW+HaBiOu8Wq8sEnQt2aEBbIj0hMfw q3/39jHwLOs733l4xrYLz8au7nqcPKs4Czxkc3CSgymmGUhQRh9Hx+f7WkCqQK5itdbv KtIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :authenticated-by; bh=JxHYw41rip3sVOZrCpxEOuZm+H8kn0JZbpUDbCyZiEA=; b=FKNcwcqVh6Jxv8Wf01ltyD8ebdNOWhUI6kiB6DeCpUgZPVfkSalucg1AIdYuElUsZa mHfkb62jhbhpeiwAZvA9OIa7INJTnZgw9oqT0zTe5tQcqF1tTCctGaJDEOtA2kIcmMAk V0kW2/7CC7DteErOdq6xPOVFD74kPIiHKmhaUjuqNqGElVlmQ1vhJG3Z62STNkjyzy/f QXlJMSiBR31cADVmPwWCLAAkzwSxmxwL9M6O7+RB5T4jPPE6Y9cL3iK2H02JGrdxmhSY 2oMA6zJOpvwt39heREBQw/nRT8T2acCF1/zrfIhKssPBsleDR7G/AccomgFf4dCiDsVp Ipfg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j5-20020aa7ca45000000b004fd206c9fe7si8407508edt.145.2023.04.03.20.06.35; Mon, 03 Apr 2023 20:06:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232923AbjDDCyh (ORCPT + 60 others); Mon, 3 Apr 2023 22:54:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232896AbjDDCyf (ORCPT ); Mon, 3 Apr 2023 22:54:35 -0400 Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF61D19BF for ; Mon, 3 Apr 2023 19:54:33 -0700 (PDT) Authenticated-By: X-SpamFilter-By: ArmorX SpamTrap 5.77 with qID 3342s9enD014613, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexh36506.realtek.com.tw[172.21.6.27]) by rtits2.realtek.com.tw (8.15.2/2.81/5.90) with ESMTPS id 3342s9enD014613 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=OK); Tue, 4 Apr 2023 10:54:09 +0800 Received: from RTEXMBS04.realtek.com.tw (172.21.6.97) by RTEXH36506.realtek.com.tw (172.21.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.17; Tue, 4 Apr 2023 10:54:28 +0800 Received: from localhost (172.16.18.209) by RTEXMBS04.realtek.com.tw (172.21.6.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Tue, 4 Apr 2023 10:54:27 +0800 From: Ping-Ke Shih To: CC: , Subject: [PATCH v5 5/5] wifi: rtw89: fix authentication fail during scan Date: Tue, 4 Apr 2023 10:52:59 +0800 Message-ID: <20230404025259.15503-6-pkshih@realtek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230404025259.15503-1-pkshih@realtek.com> References: <20230404025259.15503-1-pkshih@realtek.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [172.16.18.209] X-ClientProxiedBy: RTEXMBS02.realtek.com.tw (172.21.6.95) To RTEXMBS04.realtek.com.tw (172.21.6.97) X-KSE-ServerInfo: RTEXMBS04.realtek.com.tw, 9 X-KSE-AntiSpam-Interceptor-Info: fallback X-KSE-Antivirus-Interceptor-Info: fallback X-KSE-AntiSpam-Interceptor-Info: fallback X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Po-Hao Huang We used to store operating channel info after associated. However, scan might happen before that. Without switching back to operating channel, authentication or association might fail. Therefore, we switch back to operating channel when the scanning vif's BSSID is non-zero, which implies connected or during attempt to connect. Signed-off-by: Po-Hao Huang Signed-off-by: Ping-Ke Shih --- v5: no change --- drivers/net/wireless/realtek/rtw89/fw.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw89/fw.c b/drivers/net/wireless/realtek/rtw89/fw.c index 032afbaeb71d6..d3348f9bcc2a7 100644 --- a/drivers/net/wireless/realtek/rtw89/fw.c +++ b/drivers/net/wireless/realtek/rtw89/fw.c @@ -3199,7 +3199,7 @@ static void rtw89_hw_scan_add_chan(struct rtw89_dev *rtwdev, int chan_type, } static int rtw89_hw_scan_add_chan_list(struct rtw89_dev *rtwdev, - struct rtw89_vif *rtwvif) + struct rtw89_vif *rtwvif, bool connected) { struct cfg80211_scan_request *req = rtwvif->scan_req; struct rtw89_mac_chinfo *ch_info, *tmp; @@ -3243,7 +3243,7 @@ static int rtw89_hw_scan_add_chan_list(struct rtw89_dev *rtwdev, type = RTW89_CHAN_ACTIVE; rtw89_hw_scan_add_chan(rtwdev, type, req->n_ssids, ch_info); - if (rtwvif->net_type != RTW89_NET_TYPE_NO_LINK && + if (connected && off_chan_time + ch_info->period > RTW89_OFF_CHAN_TIME) { tmp = kzalloc(sizeof(*tmp), GFP_KERNEL); if (!tmp) { @@ -3276,7 +3276,7 @@ static int rtw89_hw_scan_add_chan_list(struct rtw89_dev *rtwdev, } static int rtw89_hw_scan_prehandle(struct rtw89_dev *rtwdev, - struct rtw89_vif *rtwvif) + struct rtw89_vif *rtwvif, bool connected) { int ret; @@ -3285,7 +3285,7 @@ static int rtw89_hw_scan_prehandle(struct rtw89_dev *rtwdev, rtw89_err(rtwdev, "Update probe request failed\n"); goto out; } - ret = rtw89_hw_scan_add_chan_list(rtwdev, rtwvif); + ret = rtw89_hw_scan_add_chan_list(rtwdev, rtwvif, connected); out: return ret; } @@ -3363,16 +3363,19 @@ int rtw89_hw_scan_offload(struct rtw89_dev *rtwdev, struct ieee80211_vif *vif, { struct rtw89_scan_option opt = {0}; struct rtw89_vif *rtwvif; + bool connected; int ret = 0; rtwvif = vif ? (struct rtw89_vif *)vif->drv_priv : NULL; if (!rtwvif) return -EINVAL; + /* This variable implies connected or during attempt to connect */ + connected = !is_zero_ether_addr(rtwvif->bssid); opt.enable = enable; - opt.target_ch_mode = rtwvif->net_type != RTW89_NET_TYPE_NO_LINK; + opt.target_ch_mode = connected; if (enable) { - ret = rtw89_hw_scan_prehandle(rtwdev, rtwvif); + ret = rtw89_hw_scan_prehandle(rtwdev, rtwvif, connected); if (ret) goto out; } -- 2.25.1