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
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.
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.
14 Enable scan in mac80211 in these cases.
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>
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(-)
26 --- a/include/net/cfg80211.h
27 +++ b/include/net/cfg80211.h
28 @@ -5554,6 +5554,14 @@ const struct ieee80211_reg_rule *freq_re
29 const char *reg_initiator_name(enum nl80211_reg_initiator initiator);
32 + * regulatory_pre_cac_allowed - check if pre-CAC allowed in the current regdom
33 + * @wiphy: wiphy for which pre-CAC capability is checked.
35 + * Pre-CAC is allowed only in some regdomains (notable ETSI).
37 +bool regulatory_pre_cac_allowed(struct wiphy *wiphy);
40 * DOC: Internal regulatory db functions
43 --- a/net/mac80211/scan.c
44 +++ b/net/mac80211/scan.c
45 @@ -520,10 +520,33 @@ static int ieee80211_start_sw_scan(struc
49 +static bool __ieee80211_can_leave_ch(struct ieee80211_sub_if_data *sdata)
51 + struct ieee80211_local *local = sdata->local;
52 + struct ieee80211_sub_if_data *sdata_iter;
54 + if (!ieee80211_is_radar_required(local))
57 + if (!regulatory_pre_cac_allowed(local->hw.wiphy))
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);
67 + mutex_unlock(&local->iflist_mtx);
72 static bool ieee80211_can_scan(struct ieee80211_local *local,
73 struct ieee80211_sub_if_data *sdata)
75 - if (ieee80211_is_radar_required(local))
76 + if (!__ieee80211_can_leave_ch(sdata))
79 if (!list_empty(&local->roc_list))
80 @@ -630,7 +653,10 @@ static int __ieee80211_start_scan(struct
82 lockdep_assert_held(&local->mtx);
84 - if (local->scan_req || ieee80211_is_radar_required(local))
85 + if (local->scan_req)
88 + if (!__ieee80211_can_leave_ch(sdata))
91 if (!ieee80211_can_scan(local, sdata)) {
92 --- a/net/wireless/reg.c
93 +++ b/net/wireless/reg.c
94 @@ -3883,6 +3883,7 @@ bool regulatory_pre_cac_allowed(struct w
96 return pre_cac_allowed;
98 +EXPORT_SYMBOL(regulatory_pre_cac_allowed);
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
108 - * regulatory_pre_cac_allowed - if pre-CAC allowed in the current dfs domain
109 - * @wiphy: wiphy for which pre-CAC capability is checked.
111 - * Pre-CAC is allowed only in ETSI domain.
113 -bool regulatory_pre_cac_allowed(struct wiphy *wiphy);
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