mac80211: ath11k: sync with ath-next
[openwrt/staging/jow.git] / package / kernel / mac80211 / patches / ath11k / 0049-wifi-ath11k-Optimize-6-GHz-scan-time.patch
1 From 8b4d2f080afbd4280ecca0f4b3ceea943a7a86d0 Mon Sep 17 00:00:00 2001
2 From: Manikanta Pubbisetty <quic_mpubbise@quicinc.com>
3 Date: Thu, 23 Mar 2023 11:39:13 +0530
4 Subject: [PATCH] wifi: ath11k: Optimize 6 GHz scan time
5
6 Currently, time taken to scan all supported channels on WCN6750
7 is ~8 seconds and connection time is almost 10 seconds. WCN6750
8 supports three Wi-Fi bands (i.e., 2.4/5/6 GHz) and the numbers of
9 channels for scan come around ~100 channels (default case).
10 Since the chip doesn't have support for DBS (Dual Band Simultaneous),
11 scans cannot be parallelized resulting in longer scan times.
12
13 Among the 100 odd channels, ~60 channels are in 6 GHz band. Therefore,
14 optimizing the scan for 6 GHz channels will bring down the overall
15 scan time.
16
17 WCN6750 firmware has support to scan a 6 GHz channel based on co-located
18 AP information i.e., RNR IE which is found in the legacy 2.4/5 GHz scan
19 results. When a scan request with all supported channel list is enqueued
20 to the firmware, then based on WMI_SCAN_CHAN_FLAG_SCAN_ONLY_IF_RNR_FOUND
21 scan channel flag, firmware will scan only those 6 GHz channels for which
22 RNR IEs are found in the legacy scan results.
23
24 In the proposed design, based on NL80211_SCAN_FLAG_COLOCATED_6GHZ scan
25 flag, driver will set the WMI_SCAN_CHAN_FLAG_SCAN_ONLY_IF_RNR_FOUND flag
26 for non-PSC channels. Since there is high probability to find 6 GHz APs
27 on PSC channels, these channels are always scanned. Only non-PSC channels
28 are selectively scanned based on cached RNR information from the legacy
29 scan results.
30
31 If NL80211_SCAN_FLAG_COLOCATED_6GHZ is not set in the scan flags,
32 then scan will happen on all supported channels (default behavior).
33
34 With these optimizations, scan time is improved by 1.5-1.8 seconds on
35 WCN6750. Similar savings have been observed on WCN6855.
36
37 Tested-on: WCN6750 hw1.0 AHB WLAN.MSL.1.0.1-00887-QCAMSLSWPLZ-1
38 Tested-on: WCN6855 hw2.1 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.16
39
40 Signed-off-by: Manikanta Pubbisetty <quic_mpubbise@quicinc.com>
41 Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
42 Link: https://lore.kernel.org/r/20230323060913.10097-1-quic_mpubbise@quicinc.com
43 ---
44 drivers/net/wireless/ath/ath11k/mac.c | 25 +++++++++++++++++++++++--
45 drivers/net/wireless/ath/ath11k/wmi.h | 4 ++++
46 2 files changed, 27 insertions(+), 2 deletions(-)
47
48 --- a/drivers/net/wireless/ath/ath11k/mac.c
49 +++ b/drivers/net/wireless/ath/ath11k/mac.c
50 @@ -3819,8 +3819,29 @@ static int ath11k_mac_op_hw_scan(struct
51 goto exit;
52 }
53
54 - for (i = 0; i < arg->num_chan; i++)
55 - arg->chan_list[i] = req->channels[i]->center_freq;
56 + for (i = 0; i < arg->num_chan; i++) {
57 + if (test_bit(WMI_TLV_SERVICE_SCAN_CONFIG_PER_CHANNEL,
58 + ar->ab->wmi_ab.svc_map)) {
59 + arg->chan_list[i] =
60 + u32_encode_bits(req->channels[i]->center_freq,
61 + WMI_SCAN_CONFIG_PER_CHANNEL_MASK);
62 +
63 + /* If NL80211_SCAN_FLAG_COLOCATED_6GHZ is set in scan
64 + * flags, then scan all PSC channels in 6 GHz band and
65 + * those non-PSC channels where RNR IE is found during
66 + * the legacy 2.4/5 GHz scan.
67 + * If NL80211_SCAN_FLAG_COLOCATED_6GHZ is not set,
68 + * then all channels in 6 GHz will be scanned.
69 + */
70 + if (req->channels[i]->band == NL80211_BAND_6GHZ &&
71 + req->flags & NL80211_SCAN_FLAG_COLOCATED_6GHZ &&
72 + !cfg80211_channel_is_psc(req->channels[i]))
73 + arg->chan_list[i] |=
74 + WMI_SCAN_CH_FLAG_SCAN_ONLY_IF_RNR_FOUND;
75 + } else {
76 + arg->chan_list[i] = req->channels[i]->center_freq;
77 + }
78 + }
79 }
80
81 if (req->flags & NL80211_SCAN_FLAG_RANDOM_ADDR) {
82 --- a/drivers/net/wireless/ath/ath11k/wmi.h
83 +++ b/drivers/net/wireless/ath/ath11k/wmi.h
84 @@ -2100,6 +2100,7 @@ enum wmi_tlv_service {
85
86 /* The second 128 bits */
87 WMI_MAX_EXT_SERVICE = 256,
88 + WMI_TLV_SERVICE_SCAN_CONFIG_PER_CHANNEL = 265,
89 WMI_TLV_SERVICE_REG_CC_EXT_EVENT_SUPPORT = 281,
90 WMI_TLV_SERVICE_BIOS_SAR_SUPPORT = 326,
91
92 @@ -3249,6 +3250,9 @@ struct wmi_start_scan_cmd {
93 #define WMI_SCAN_DWELL_MODE_SHIFT 21
94 #define WMI_SCAN_FLAG_EXT_PASSIVE_SCAN_START_TIME_ENHANCE 0x00000800
95
96 +#define WMI_SCAN_CONFIG_PER_CHANNEL_MASK GENMASK(19, 0)
97 +#define WMI_SCAN_CH_FLAG_SCAN_ONLY_IF_RNR_FOUND BIT(20)
98 +
99 enum {
100 WMI_SCAN_DWELL_MODE_DEFAULT = 0,
101 WMI_SCAN_DWELL_MODE_CONSERVATIVE = 1,