7bba7176cb6b08ec799dfd6f1899755cdf10c096
[openwrt/staging/svanheule.git] /
1 From dc0c18ed229cdcca283dd78fefa38273ec37a42c Mon Sep 17 00:00:00 2001
2 From: Aaron Komisar <aaron.komisar@tandemg.com>
3 Date: Wed, 2 Oct 2019 13:59:07 +0000
4 Subject: mac80211: fix scan when operating on DFS channels in ETSI domains
5
6 In non-ETSI regulatory domains scan is blocked when operating channel
7 is a DFS channel. For ETSI, however, once DFS channel is marked as
8 available after the CAC, this channel will remain available (for some
9 time) even after leaving this channel.
10
11 Therefore a scan can be done without any impact on the availability
12 of the DFS channel as no new CAC is required after the scan.
13
14 Enable scan in mac80211 in these cases.
15
16 Signed-off-by: Aaron Komisar <aaron.komisar@tandemg.com>
17 Link: https://lore.kernel.org/r/1570024728-17284-1-git-send-email-aaron.komisar@tandemg.com
18 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
19 ---
20 include/net/cfg80211.h | 8 ++++++++
21 net/mac80211/scan.c | 30 ++++++++++++++++++++++++++++--
22 net/wireless/reg.c | 1 +
23 net/wireless/reg.h | 8 --------
24 4 files changed, 37 insertions(+), 10 deletions(-)
25
26 --- a/include/net/cfg80211.h
27 +++ b/include/net/cfg80211.h
28 @@ -5451,6 +5451,14 @@ const struct ieee80211_reg_rule *freq_re
29 const char *reg_initiator_name(enum nl80211_reg_initiator initiator);
30
31 /**
32 + * regulatory_pre_cac_allowed - check if pre-CAC allowed in the current regdom
33 + * @wiphy: wiphy for which pre-CAC capability is checked.
34 + *
35 + * Pre-CAC is allowed only in some regdomains (notable ETSI).
36 + */
37 +bool regulatory_pre_cac_allowed(struct wiphy *wiphy);
38 +
39 +/**
40 * DOC: Internal regulatory db functions
41 *
42 */
43 --- a/net/mac80211/scan.c
44 +++ b/net/mac80211/scan.c
45 @@ -520,10 +520,33 @@ static int ieee80211_start_sw_scan(struc
46 return 0;
47 }
48
49 +static bool __ieee80211_can_leave_ch(struct ieee80211_sub_if_data *sdata)
50 +{
51 + struct ieee80211_local *local = sdata->local;
52 + struct ieee80211_sub_if_data *sdata_iter;
53 +
54 + if (!ieee80211_is_radar_required(local))
55 + return true;
56 +
57 + if (!regulatory_pre_cac_allowed(local->hw.wiphy))
58 + return false;
59 +
60 + mutex_lock(&local->iflist_mtx);
61 + list_for_each_entry(sdata_iter, &local->interfaces, list) {
62 + if (sdata_iter->wdev.cac_started) {
63 + mutex_unlock(&local->iflist_mtx);
64 + return false;
65 + }
66 + }
67 + mutex_unlock(&local->iflist_mtx);
68 +
69 + return true;
70 +}
71 +
72 static bool ieee80211_can_scan(struct ieee80211_local *local,
73 struct ieee80211_sub_if_data *sdata)
74 {
75 - if (ieee80211_is_radar_required(local))
76 + if (!__ieee80211_can_leave_ch(sdata))
77 return false;
78
79 if (!list_empty(&local->roc_list))
80 @@ -630,7 +653,10 @@ static int __ieee80211_start_scan(struct
81
82 lockdep_assert_held(&local->mtx);
83
84 - if (local->scan_req || ieee80211_is_radar_required(local))
85 + if (local->scan_req)
86 + return -EBUSY;
87 +
88 + if (!__ieee80211_can_leave_ch(sdata))
89 return -EBUSY;
90
91 if (!ieee80211_can_scan(local, sdata)) {
92 --- a/net/wireless/reg.c
93 +++ b/net/wireless/reg.c
94 @@ -3866,6 +3866,7 @@ bool regulatory_pre_cac_allowed(struct w
95
96 return pre_cac_allowed;
97 }
98 +EXPORT_SYMBOL(regulatory_pre_cac_allowed);
99
100 void regulatory_propagate_dfs_state(struct wiphy *wiphy,
101 struct cfg80211_chan_def *chandef,
102 --- a/net/wireless/reg.h
103 +++ b/net/wireless/reg.h
104 @@ -156,14 +156,6 @@ bool regulatory_indoor_allowed(void);
105 #define REG_PRE_CAC_EXPIRY_GRACE_MS 2000
106
107 /**
108 - * regulatory_pre_cac_allowed - if pre-CAC allowed in the current dfs domain
109 - * @wiphy: wiphy for which pre-CAC capability is checked.
110 -
111 - * Pre-CAC is allowed only in ETSI domain.
112 - */
113 -bool regulatory_pre_cac_allowed(struct wiphy *wiphy);
114 -
115 -/**
116 * regulatory_propagate_dfs_state - Propagate DFS channel state to other wiphys
117 * @wiphy - wiphy on which radar is detected and the event will be propagated
118 * to other available wiphys having the same DFS domain