mac80211: brcmfmac: backport 4.19 patches preparing monitor mode support
[openwrt/staging/wigyori.git] / package / kernel / mac80211 / patches / 380-0006-ath10k-add-support-to-configure-channel-dwell-time.patch
1 From be8cce96f14dc925ecfb702be0392a52cf78adb5 Mon Sep 17 00:00:00 2001
2 From: Pradeep Kumar Chitrapu <pradeepc@codeaurora.org>
3 Date: Wed, 23 May 2018 11:09:09 +0300
4 Subject: [PATCH] ath10k: add support to configure channel dwell time
5
6 Configure channel dwell time from duration of the scan request
7 received from mac80211 when the duration is non-zero. When the
8 scan request does not have duration value, use the default ones,
9 the current implementation.
10
11 Corresponding flag NL80211_EXT_FEATURE_SET_SCAN_DWELL is
12 advertized.
13
14 Supported Chipsets:
15 -QCA988X/QCA9887 PCI
16 -QCA99X0/QCA9984/QCA9888/QCA4019 PCI
17 -QCA6174/QCA9377 PCI/USB/SDIO
18 -WCN3990 SNOC
19
20 Tested on QCA9984 with firmware ver 10.4-3.6-0010
21
22 Signed-off-by: Pradeep Kumar Chitrapu <pradeepc@codeaurora.org>
23 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
24 ---
25 drivers/net/wireless/ath/ath10k/core.h | 1 +
26 drivers/net/wireless/ath/ath10k/mac.c | 23 ++++++++++++++++++++---
27 2 files changed, 21 insertions(+), 3 deletions(-)
28
29 --- a/drivers/net/wireless/ath/ath10k/core.h
30 +++ b/drivers/net/wireless/ath/ath10k/core.h
31 @@ -43,6 +43,7 @@
32 #define WO(_f) ((_f##_OFFSET) >> 2)
33
34 #define ATH10K_SCAN_ID 0
35 +#define ATH10K_SCAN_CHANNEL_SWITCH_WMI_EVT_OVERHEAD 10 /* msec */
36 #define WMI_READY_TIMEOUT (5 * HZ)
37 #define ATH10K_FLUSH_TIMEOUT_HZ (5 * HZ)
38 #define ATH10K_CONNECTION_LOSS_HZ (3 * HZ)
39 --- a/drivers/net/wireless/ath/ath10k/mac.c
40 +++ b/drivers/net/wireless/ath/ath10k/mac.c
41 @@ -5597,6 +5597,7 @@ static int ath10k_hw_scan(struct ieee802
42 struct wmi_start_scan_arg arg;
43 int ret = 0;
44 int i;
45 + u32 scan_timeout;
46
47 mutex_lock(&ar->conf_mutex);
48
49 @@ -5647,6 +5648,22 @@ static int ath10k_hw_scan(struct ieee802
50 arg.channels[i] = req->channels[i]->center_freq;
51 }
52
53 + /* if duration is set, default dwell times will be overwritten */
54 + if (req->duration) {
55 + arg.dwell_time_active = req->duration;
56 + arg.dwell_time_passive = req->duration;
57 + arg.burst_duration_ms = req->duration;
58 +
59 + scan_timeout = min_t(u32, arg.max_rest_time *
60 + (arg.n_channels - 1) + (req->duration +
61 + ATH10K_SCAN_CHANNEL_SWITCH_WMI_EVT_OVERHEAD) *
62 + arg.n_channels, arg.max_scan_time + 200);
63 +
64 + } else {
65 + /* Add a 200ms margin to account for event/command processing */
66 + scan_timeout = arg.max_scan_time + 200;
67 + }
68 +
69 ret = ath10k_start_scan(ar, &arg);
70 if (ret) {
71 ath10k_warn(ar, "failed to start hw scan: %d\n", ret);
72 @@ -5655,10 +5672,8 @@ static int ath10k_hw_scan(struct ieee802
73 spin_unlock_bh(&ar->data_lock);
74 }
75
76 - /* Add a 200ms margin to account for event/command processing */
77 ieee80211_queue_delayed_work(ar->hw, &ar->scan.timeout,
78 - msecs_to_jiffies(arg.max_scan_time +
79 - 200));
80 + msecs_to_jiffies(scan_timeout));
81
82 exit:
83 mutex_unlock(&ar->conf_mutex);
84 @@ -8267,6 +8282,8 @@ int ath10k_mac_register(struct ath10k *a
85 }
86
87 wiphy_ext_feature_set(ar->hw->wiphy, NL80211_EXT_FEATURE_VHT_IBSS);
88 + wiphy_ext_feature_set(ar->hw->wiphy,
89 + NL80211_EXT_FEATURE_SET_SCAN_DWELL);
90
91 /*
92 * on LL hardware queues are managed entirely by the FW