d0b19fe59f58f95c4528b1a982adac3f1f822707
[openwrt/staging/blogic.git] /
1 From c362daa213cdeb0a9e7c2ed84849544c24505720 Mon Sep 17 00:00:00 2001
2 From: Manikanta Pubbisetty <quic_mpubbise@quicinc.com>
3 Date: Fri, 7 Oct 2022 10:41:30 +0530
4 Subject: [PATCH 8/9] wifi: ath11k: add support to configure channel dwell time
5
6 Add support to configure channel dwell time during scan.
7 Dwell time help to stay on the channel for a specified duration
8 during scan and aid userspace in finding WiFi networks. Very
9 useful in passive scans where longer dwell times are needed
10 to find the WiFi networks.
11
12 Configure channel dwell time from duration of the scan request
13 received from mac80211 when the duration is non-zero. When the
14 scan request does not have duration value, use the default ones,
15 the current implementation.
16
17 Advertise corresponding feature flag NL80211_EXT_FEATURE_SET_SCAN_DWELL
18 to enable the feature.
19
20 Change is applicable for all ath11k hardware.
21
22 Tested-on: WCN6750 hw1.0 AHB WLAN.MSL.1.0.1-00887-QCAMSLSWPLZ-1
23
24 Signed-off-by: Manikanta Pubbisetty <quic_mpubbise@quicinc.com>
25 Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>
26 Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
27 Link: https://lore.kernel.org/r/20221007051130.6067-1-quic_mpubbise@quicinc.com
28 ---
29 drivers/net/wireless/ath/ath11k/mac.c | 33 +++++++++++++++++++++++----
30 1 file changed, 29 insertions(+), 4 deletions(-)
31
32 --- a/drivers/net/wireless/ath/ath11k/mac.c
33 +++ b/drivers/net/wireless/ath/ath11k/mac.c
34 @@ -241,7 +241,10 @@ const struct htt_rx_ring_tlv_filter ath1
35 #define ath11k_a_rates (ath11k_legacy_rates + 4)
36 #define ath11k_a_rates_size (ARRAY_SIZE(ath11k_legacy_rates) - 4)
37
38 -#define ATH11K_MAC_SCAN_TIMEOUT_MSECS 200 /* in msecs */
39 +#define ATH11K_MAC_SCAN_CMD_EVT_OVERHEAD 200 /* in msecs */
40 +
41 +/* Overhead due to the processing of channel switch events from FW */
42 +#define ATH11K_SCAN_CHANNEL_SWITCH_WMI_EVT_OVERHEAD 10 /* in msecs */
43
44 static const u32 ath11k_smps_map[] = {
45 [WLAN_HT_CAP_SM_PS_STATIC] = WMI_PEER_SMPS_STATIC,
46 @@ -3612,6 +3615,7 @@ static int ath11k_mac_op_hw_scan(struct
47 struct scan_req_params arg;
48 int ret = 0;
49 int i;
50 + u32 scan_timeout;
51
52 mutex_lock(&ar->conf_mutex);
53
54 @@ -3681,6 +3685,26 @@ static int ath11k_mac_op_hw_scan(struct
55 ether_addr_copy(arg.mac_mask.addr, req->mac_addr_mask);
56 }
57
58 + /* if duration is set, default dwell times will be overwritten */
59 + if (req->duration) {
60 + arg.dwell_time_active = req->duration;
61 + arg.dwell_time_active_2g = req->duration;
62 + arg.dwell_time_active_6g = req->duration;
63 + arg.dwell_time_passive = req->duration;
64 + arg.dwell_time_passive_6g = req->duration;
65 + arg.burst_duration = req->duration;
66 +
67 + scan_timeout = min_t(u32, arg.max_rest_time *
68 + (arg.num_chan - 1) + (req->duration +
69 + ATH11K_SCAN_CHANNEL_SWITCH_WMI_EVT_OVERHEAD) *
70 + arg.num_chan, arg.max_scan_time);
71 + } else {
72 + scan_timeout = arg.max_scan_time;
73 + }
74 +
75 + /* Add a margin to account for event/command processing */
76 + scan_timeout += ATH11K_MAC_SCAN_CMD_EVT_OVERHEAD;
77 +
78 ret = ath11k_start_scan(ar, &arg);
79 if (ret) {
80 ath11k_warn(ar->ab, "failed to start hw scan: %d\n", ret);
81 @@ -3689,10 +3713,8 @@ static int ath11k_mac_op_hw_scan(struct
82 spin_unlock_bh(&ar->data_lock);
83 }
84
85 - /* Add a 200ms margin to account for event/command processing */
86 ieee80211_queue_delayed_work(ar->hw, &ar->scan.timeout,
87 - msecs_to_jiffies(arg.max_scan_time +
88 - ATH11K_MAC_SCAN_TIMEOUT_MSECS));
89 + msecs_to_jiffies(scan_timeout));
90
91 exit:
92 kfree(arg.chan_list);
93 @@ -9060,6 +9082,9 @@ static int __ath11k_mac_register(struct
94 NL80211_EXT_FEATURE_UNSOL_BCAST_PROBE_RESP);
95 }
96
97 + wiphy_ext_feature_set(ar->hw->wiphy,
98 + NL80211_EXT_FEATURE_SET_SCAN_DWELL);
99 +
100 ath11k_reg_init(ar);
101
102 if (!test_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags)) {