In AP mode DFS channel state is changed to DFS_AVAILABLE
after successful CAC and remains as such until a radar
signal is detected during the In-Service Monitoring.
When AP is stopped it is no longer monitoring current channel
for radar signals. DFS channel state should be changed back
to DFS_USABLE. Starting AP again on that channel will start CAC
instead of starting radiation.
Signed-off-by: Marek Puzyniak <[email protected]>
---
net/wireless/ap.c | 3 +++
net/wireless/chan.c | 39 +++++++++++++++++++++++++++++++++++++++
net/wireless/core.h | 11 +++++++++++
3 files changed, 53 insertions(+)
diff --git a/net/wireless/ap.c b/net/wireless/ap.c
index 324e8d8..9349773 100644
--- a/net/wireless/ap.c
+++ b/net/wireless/ap.c
@@ -26,6 +26,9 @@ static int __cfg80211_stop_ap(struct cfg80211_registered_device *rdev,
err = rdev_stop_ap(rdev, dev);
if (!err) {
+ if (cfg80211_chandef_dfs_required(wdev->wiphy, &wdev->preset_chandef))
+ cfg80211_leave_dfs_chandef(wdev->wiphy, &wdev->preset_chandef);
+
wdev->beacon_interval = 0;
wdev->channel = NULL;
wdev->ssid_len = 0;
diff --git a/net/wireless/chan.c b/net/wireless/chan.c
index 78559b5..f0cf780 100644
--- a/net/wireless/chan.c
+++ b/net/wireless/chan.c
@@ -490,6 +490,45 @@ static bool cfg80211_chandef_dfs_available(struct wiphy *wiphy,
return r;
}
+static void cfg80211_leave_dfs_chans(struct wiphy *wiphy,
+ u32 center_freq,
+ u32 bandwidth)
+{
+ struct ieee80211_channel *c;
+ u32 freq, start_freq, end_freq;
+
+ start_freq = cfg80211_get_start_freq(center_freq, bandwidth);
+ end_freq = cfg80211_get_end_freq(center_freq, bandwidth);
+
+ for (freq = start_freq; freq <= end_freq; freq += 20) {
+ c = ieee80211_get_channel(wiphy, freq);
+ if (!c)
+ continue;
+ if (!(c->flags & IEEE80211_CHAN_RADAR))
+ continue;
+ if (c->dfs_state != NL80211_DFS_AVAILABLE)
+ continue;
+
+ cfg80211_set_chans_dfs_state(wiphy, freq, 20, NL80211_DFS_USABLE);
+ }
+}
+
+void cfg80211_leave_dfs_chandef(struct wiphy *wiphy,
+ struct cfg80211_chan_def *chandef)
+{
+ int width;
+
+ if (WARN_ON(!cfg80211_chandef_valid(chandef)))
+ return;
+
+ width = cfg80211_chandef_get_width(chandef);
+ cfg80211_leave_dfs_chans(wiphy, chandef->center_freq1, width);
+
+ if (!chandef->center_freq2)
+ return;
+
+ cfg80211_leave_dfs_chans(wiphy, chandef->center_freq2, width);
+}
static bool cfg80211_secondary_chans_ok(struct wiphy *wiphy,
u32 center_freq, u32 bandwidth,
diff --git a/net/wireless/core.h b/net/wireless/core.h
index 6716c5c..ca230a2 100644
--- a/net/wireless/core.h
+++ b/net/wireless/core.h
@@ -400,6 +400,17 @@ void cfg80211_set_dfs_state(struct wiphy *wiphy,
void cfg80211_dfs_channels_update_work(struct work_struct *work);
+/**
+ * cfg80211_leave_dfs_chandef - Leaving dfs chandef
+ * @wiphy: the wiphy
+ * @chandef: chandef for the current channel
+ *
+ * This function is called when dfs chandef is being not used for different
+ * reasons. Change channels DFS_AVAILABLE to DFS_USABLE again. Leave channels
+ * DFS_UNAVAILABLE untouched.
+ */
+void cfg80211_leave_dfs_chandef(struct wiphy *wiphy,
+ struct cfg80211_chan_def *chandef);
static inline int
cfg80211_can_change_interface(struct cfg80211_registered_device *rdev,
--
1.8.1.2
On Tue, 2013-12-03 at 13:24 +0100, Marek Puzyniak wrote:
> + if (cfg80211_chandef_dfs_required(wdev->wiphy, &wdev->preset_chandef))
> + cfg80211_leave_dfs_chandef(wdev->wiphy, &wdev->preset_chandef);
*far* too long lines. Read CodingStyle documentation please.
Also, any reason to not always call cfg80211_leave_dfs_chandef()?
> +static void cfg80211_leave_dfs_chans(struct wiphy *wiphy,
> + u32 center_freq,
> + u32 bandwidth)
> +{
> + struct ieee80211_channel *c;
> + u32 freq, start_freq, end_freq;
> +
> + start_freq = cfg80211_get_start_freq(center_freq, bandwidth);
> + end_freq = cfg80211_get_end_freq(center_freq, bandwidth);
> +
> + for (freq = start_freq; freq <= end_freq; freq += 20) {
> + c = ieee80211_get_channel(wiphy, freq);
> + if (!c)
> + continue;
> + if (!(c->flags & IEEE80211_CHAN_RADAR))
> + continue;
> + if (c->dfs_state != NL80211_DFS_AVAILABLE)
> + continue;
> +
> + cfg80211_set_chans_dfs_state(wiphy, freq, 20, NL80211_DFS_USABLE);
This seems to catch it anyway.
This also seems a bit wrong, if regulatory happens to change and say the
RADAR flag goes away, then this won't set it to USABLE, and then if the
RADAR flag later re-appears? I guess Luis should handle that in reg.c
though or so?
johannes
On 3 December 2013 15:18, Johannes Berg <[email protected]> wrote:
>> + if (cfg80211_chandef_dfs_required(wdev->wiphy, &wdev->preset_chandef))
>> + cfg80211_leave_dfs_chandef(wdev->wiphy, &wdev->preset_chandef);
>
> *far* too long lines. Read CodingStyle documentation please.
>
> Also, any reason to not always call cfg80211_leave_dfs_chandef()?
I had only cfg80211_leave_dfs_chandef() but then I added if() and
exceeded 80 lines.
So I will call always cfg80211_leave_dfs_chandef().
>> +static void cfg80211_leave_dfs_chans(struct wiphy *wiphy,
>> + u32 center_freq,
>> + u32 bandwidth)
>> +{
>> + struct ieee80211_channel *c;
>> + u32 freq, start_freq, end_freq;
>> +
>> + start_freq = cfg80211_get_start_freq(center_freq, bandwidth);
>> + end_freq = cfg80211_get_end_freq(center_freq, bandwidth);
>> +
>> + for (freq = start_freq; freq <= end_freq; freq += 20) {
>> + c = ieee80211_get_channel(wiphy, freq);
>> + if (!c)
>> + continue;
>> + if (!(c->flags & IEEE80211_CHAN_RADAR))
>> + continue;
>> + if (c->dfs_state != NL80211_DFS_AVAILABLE)
>> + continue;
>> +
>> + cfg80211_set_chans_dfs_state(wiphy, freq, 20, NL80211_DFS_USABLE);
>
> This seems to catch it anyway.
>
> This also seems a bit wrong, if regulatory happens to change and say the
> RADAR flag goes away, then this won't set it to USABLE, and then if the
> RADAR flag later re-appears? I guess Luis should handle that in reg.c
> though or so?
Yes, you are right. It does not matter if RADAR flag is set. When we
are leaving AP mode then none of channels should have dfs_state =
NL80211_DFS_AVAILABLE. So all DFS_AVAILABLE channel will be set to
DFS_USABLE.
I will send new version of this patch.
Concerning your question whether this patch is needed in 3.13. I think
this is rather important issue. Look at such situation:
*start AP on DFS channel,
*CAC pass - channel dfs_state changes to AVAILABLE, AP starts beaconing,
*stop AP by killing hostapd, channel dfs_state stays AVAILABLE,
*start AP again, it starts beaconig immediately, there is no CAC
beacuse channel dfs_state is AVAILABLE.
Purpose of this patch is to change channel dfs_state to USABLE when
leaving/stoping AP, so starting AP again will trigger first CAC and
after successful CAC starts beaconig.
> johannes
Marek