blob: ad5ef2eb72d9c00b6829404f77c77a9192836b65 [file] [log] [blame]
developer43a264f2024-03-26 14:09:54 +08001From 23681abf649eaf1eda27dcfd3d17b80e1edeb951 Mon Sep 17 00:00:00 2001
developerd243af02023-12-21 14:49:33 +08002From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
3Date: Thu, 19 Oct 2023 09:59:24 +0800
developer43a264f2024-03-26 14:09:54 +08004Subject: [PATCH 3/3] backports: Revert cfg80211: allow grace period for DFS
developerd243af02023-12-21 14:49:33 +08005 available after beacon shutdown
6
7revert 320-cfg80211-allow-grace-period-for-DFS-available-after-.patch
8This patch will lead to channel switch fail when background radar is
9enabled.
10When AP channel switch to USABLE DFS channel,
111. AP will restart, and the DFS state of the previously operated DFS channel
12 will not be cleared immediately if this patch is applied.
132. Background radar will perform CAC on the specified DFS channel for AP.
143. AP will choose an AVAILABLE channel to operate on.
15Therefore, AP might select those DFS channels whose DFS state would be
16cleared after the grace period, resulting in channel switch failure.
17
18Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
19---
20 include/net/cfg80211.h | 3 ---
21 net/wireless/ap.c | 6 +++---
22 net/wireless/chan.c | 45 ------------------------------------------
23 net/wireless/core.h | 2 --
24 net/wireless/mlme.c | 7 +++----
25 5 files changed, 6 insertions(+), 57 deletions(-)
26
27diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
developer43a264f2024-03-26 14:09:54 +080028index a77e8a5..0a825af 100644
developerd243af02023-12-21 14:49:33 +080029--- a/include/net/cfg80211.h
30+++ b/include/net/cfg80211.h
31@@ -175,8 +175,6 @@ enum ieee80211_channel_flags {
32 * @dfs_state: current state of this channel. Only relevant if radar is required
33 * on this channel.
34 * @dfs_state_entered: timestamp (jiffies) when the dfs state was entered.
35- * @dfs_state_last_available: timestamp (jiffies) of the last time when the
36- * channel was available.
37 * @dfs_cac_ms: DFS CAC time in milliseconds, this is valid for DFS channels.
38 */
39 struct ieee80211_channel {
40@@ -193,7 +191,6 @@ struct ieee80211_channel {
41 int orig_mag, orig_mpwr;
42 enum nl80211_dfs_state dfs_state;
43 unsigned long dfs_state_entered;
44- unsigned long dfs_state_last_available;
45 unsigned int dfs_cac_ms;
46 };
47
48diff --git a/net/wireless/ap.c b/net/wireless/ap.c
49index 63641aa..0962770 100644
50--- a/net/wireless/ap.c
51+++ b/net/wireless/ap.c
52@@ -30,9 +30,6 @@ static int ___cfg80211_stop_ap(struct cfg80211_registered_device *rdev,
53 if (!wdev->links[link_id].ap.beacon_interval)
54 return -ENOENT;
55
56- cfg80211_update_last_available(wdev->wiphy,
57- &wdev->links[link_id].ap.chandef);
58-
59 err = rdev_stop_ap(rdev, dev, link_id);
60 if (!err) {
61 wdev->conn_owner_nlportid = 0;
62@@ -44,6 +41,9 @@ static int ___cfg80211_stop_ap(struct cfg80211_registered_device *rdev,
63 if (notify)
64 nl80211_send_ap_stopped(wdev, link_id);
65
66+ /* Should we apply the grace period during beaconing interface
67+ * shutdown also?
68+ */
69 cfg80211_sched_dfs_chan_update(rdev);
70 }
71
72diff --git a/net/wireless/chan.c b/net/wireless/chan.c
developer43a264f2024-03-26 14:09:54 +080073index f8348bc..510079f 100644
developerd243af02023-12-21 14:49:33 +080074--- a/net/wireless/chan.c
75+++ b/net/wireless/chan.c
76@@ -461,8 +461,6 @@ static void cfg80211_set_chans_dfs_state(struct wiphy *wiphy, u32 center_freq,
77
78 c->dfs_state = dfs_state;
79 c->dfs_state_entered = jiffies;
80- if (dfs_state == NL80211_DFS_AVAILABLE)
81- c->dfs_state_last_available = jiffies;
82 }
83 }
84
developer43a264f2024-03-26 14:09:54 +080085@@ -876,49 +874,6 @@ static bool cfg80211_get_chans_dfs_available(struct wiphy *wiphy,
developerd243af02023-12-21 14:49:33 +080086 return true;
87 }
88
89-static void
90-__cfg80211_update_last_available(struct wiphy *wiphy,
91- u32 center_freq,
92- u32 bandwidth)
93-{
94- struct ieee80211_channel *c;
95- u32 freq, start_freq, end_freq;
96-
97- start_freq = cfg80211_get_start_freq(center_freq, bandwidth);
98- end_freq = cfg80211_get_end_freq(center_freq, bandwidth);
99-
100- /*
101- * Check entire range of channels for the bandwidth.
102- * If any channel in between is disabled or has not
103- * had gone through CAC return false
104- */
105- for (freq = start_freq; freq <= end_freq; freq += MHZ_TO_KHZ(20)) {
106- c = ieee80211_get_channel_khz(wiphy, freq);
107- if (!c)
108- return;
109-
110- c->dfs_state_last_available = jiffies;
111- }
112-}
113-
114-void cfg80211_update_last_available(struct wiphy *wiphy,
115- const struct cfg80211_chan_def *chandef)
116-{
117- int width;
118-
119- width = cfg80211_chandef_get_width(chandef);
120- if (width < 0)
121- return;
122-
123- __cfg80211_update_last_available(wiphy, MHZ_TO_KHZ(chandef->center_freq1),
124- width);
125- if (chandef->width != NL80211_CHAN_WIDTH_80P80)
126- return;
127-
128- __cfg80211_update_last_available(wiphy, MHZ_TO_KHZ(chandef->center_freq2),
129- width);
130-}
131-
132 static bool cfg80211_chandef_dfs_available(struct wiphy *wiphy,
133 const struct cfg80211_chan_def *chandef)
134 {
135diff --git a/net/wireless/core.h b/net/wireless/core.h
developer43a264f2024-03-26 14:09:54 +0800136index 9aef18e..46aa2a0 100644
developerd243af02023-12-21 14:49:33 +0800137--- a/net/wireless/core.h
138+++ b/net/wireless/core.h
developer43a264f2024-03-26 14:09:54 +0800139@@ -481,8 +481,6 @@ void cfg80211_set_dfs_state(struct wiphy *wiphy,
developerd243af02023-12-21 14:49:33 +0800140 enum nl80211_dfs_state dfs_state);
141
142 void cfg80211_dfs_channels_update_work(struct work_struct *work);
143-void cfg80211_update_last_available(struct wiphy *wiphy,
144- const struct cfg80211_chan_def *chandef);
145
developer43a264f2024-03-26 14:09:54 +0800146 void cfg80211_sched_dfs_chan_update(struct cfg80211_registered_device *rdev);
147
developerd243af02023-12-21 14:49:33 +0800148diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c
developer43a264f2024-03-26 14:09:54 +0800149index 0002464..3cdfbd2 100644
developerd243af02023-12-21 14:49:33 +0800150--- a/net/wireless/mlme.c
151+++ b/net/wireless/mlme.c
developer43a264f2024-03-26 14:09:54 +0800152@@ -930,8 +930,6 @@ void cfg80211_dfs_channels_update_work(struct work_struct *work)
developerd243af02023-12-21 14:49:33 +0800153 if (c->dfs_state == NL80211_DFS_UNAVAILABLE) {
154 time_dfs_update = IEEE80211_DFS_MIN_NOP_TIME_MS;
155 radar_event = NL80211_RADAR_NOP_FINISHED;
156- timeout = c->dfs_state_entered +
157- msecs_to_jiffies(time_dfs_update);
158 } else {
159 if (regulatory_pre_cac_allowed(wiphy) ||
160 cfg80211_any_wiphy_oper_chan(wiphy, c))
developer43a264f2024-03-26 14:09:54 +0800161@@ -939,10 +937,11 @@ void cfg80211_dfs_channels_update_work(struct work_struct *work)
developerd243af02023-12-21 14:49:33 +0800162
163 time_dfs_update = REG_PRE_CAC_EXPIRY_GRACE_MS;
164 radar_event = NL80211_RADAR_PRE_CAC_EXPIRED;
165- timeout = c->dfs_state_last_available +
166- msecs_to_jiffies(time_dfs_update);
167 }
168
169+ timeout = c->dfs_state_entered +
170+ msecs_to_jiffies(time_dfs_update);
171+
172 if (time_after_eq(jiffies, timeout)) {
173 c->dfs_state = NL80211_DFS_USABLE;
174 c->dfs_state_entered = jiffies;
175--
1762.18.0
177