wifi: rtw89: fix authentication fail during scan
authorPo-Hao Huang <phhuang@realtek.com>
Tue, 11 Apr 2023 12:48:32 +0000 (20:48 +0800)
committerKalle Valo <kvalo@kernel.org>
Fri, 14 Apr 2023 12:11:23 +0000 (15:11 +0300)
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 <phhuang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230411124832.14965-6-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/fw.c

index 032afbaeb71d6e162c95e13234598ab54c0f42e6..d3348f9bcc2a77e6f7edb4a3f12c8a781f8c8d16 100644 (file)
@@ -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 @@ out:
 }
 
 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;
        }