developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 1 | From cbb9327b27651e375f72783e9c2453a2474f3ad3 Mon Sep 17 00:00:00 2001 |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 2 | From: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 3 | Date: Thu, 22 Sep 2022 14:27:41 +0800 |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 06/21] cfg80211: mtk: implement DFS status show, cac and nop |
| 5 | skip command via debugfs |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 6 | |
| 7 | Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 8 | --- |
| 9 | include/net/cfg80211.h | 1 + |
developer | aa5b1b2 | 2022-12-13 17:05:25 +0800 | [diff] [blame] | 10 | net/mac80211/cfg.c | 20 +++ |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 11 | net/wireless/core.h | 3 + |
developer | 8b64f1a | 2023-05-02 10:31:58 +0800 | [diff] [blame] | 12 | net/wireless/debugfs.c | 311 +++++++++++++++++++++++++++++++++++++++- |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 13 | net/wireless/mlme.c | 6 + |
developer | 8b64f1a | 2023-05-02 10:31:58 +0800 | [diff] [blame] | 14 | net/wireless/rdev-ops.h | 14 ++ |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 15 | net/wireless/trace.h | 12 ++ |
developer | 8b64f1a | 2023-05-02 10:31:58 +0800 | [diff] [blame] | 16 | 7 files changed, 360 insertions(+), 7 deletions(-) |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 17 | |
| 18 | diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 19 | index 7ba5fe9..cd0ec8a 100644 |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 20 | --- a/include/net/cfg80211.h |
| 21 | +++ b/include/net/cfg80211.h |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 22 | @@ -4768,6 +4768,7 @@ struct cfg80211_ops { |
developer | aa5b1b2 | 2022-12-13 17:05:25 +0800 | [diff] [blame] | 23 | struct link_station_del_parameters *params); |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 24 | int (*set_hw_timestamp)(struct wiphy *wiphy, struct net_device *dev, |
| 25 | struct cfg80211_set_hw_timestamp *hwts); |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 26 | + void (*skip_cac)(struct wireless_dev *wdev); |
| 27 | }; |
| 28 | |
| 29 | /* |
| 30 | diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 31 | index a78ee52..8033b2f 100644 |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 32 | --- a/net/mac80211/cfg.c |
| 33 | +++ b/net/mac80211/cfg.c |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 34 | @@ -5049,6 +5049,25 @@ static int ieee80211_set_hw_timestamp(struct wiphy *wiphy, |
| 35 | return local->ops->set_hw_timestamp(&local->hw, &sdata->vif, hwts); |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | +static void |
| 39 | +ieee80211_skip_cac(struct wireless_dev *wdev) |
| 40 | +{ |
| 41 | + struct net_device *dev = wdev->netdev; |
| 42 | + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
developer | aa5b1b2 | 2022-12-13 17:05:25 +0800 | [diff] [blame] | 43 | + struct cfg80211_chan_def chandef = sdata->deflink.conf->chandef; |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 44 | + unsigned int cac_time_ms; |
| 45 | + |
developer | aa5b1b2 | 2022-12-13 17:05:25 +0800 | [diff] [blame] | 46 | + cancel_delayed_work(&sdata->deflink.dfs_cac_timer_work); |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 47 | + if (wdev->cac_started) { |
developer | aa5b1b2 | 2022-12-13 17:05:25 +0800 | [diff] [blame] | 48 | + ieee80211_link_release_channel(&sdata->deflink); |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 49 | + cac_time_ms = wdev->cac_time_ms; |
| 50 | + wdev->cac_start_time = jiffies - |
| 51 | + msecs_to_jiffies(cac_time_ms + 1); |
developer | aa5b1b2 | 2022-12-13 17:05:25 +0800 | [diff] [blame] | 52 | + cfg80211_cac_event(wdev->netdev, &chandef, |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 53 | + NL80211_RADAR_CAC_FINISHED, GFP_KERNEL); |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | const struct cfg80211_ops mac80211_config_ops = { |
| 58 | .add_virtual_intf = ieee80211_add_iface, |
| 59 | .del_virtual_intf = ieee80211_del_iface, |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 60 | @@ -5161,4 +5180,5 @@ const struct cfg80211_ops mac80211_config_ops = { |
developer | aa5b1b2 | 2022-12-13 17:05:25 +0800 | [diff] [blame] | 61 | .mod_link_station = ieee80211_mod_link_station, |
| 62 | .del_link_station = ieee80211_del_link_station, |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 63 | .set_hw_timestamp = ieee80211_set_hw_timestamp, |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 64 | + .skip_cac = ieee80211_skip_cac, |
| 65 | }; |
| 66 | diff --git a/net/wireless/core.h b/net/wireless/core.h |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 67 | index 70fc2e6..ea1b6ff 100644 |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 68 | --- a/net/wireless/core.h |
| 69 | +++ b/net/wireless/core.h |
| 70 | @@ -86,6 +86,9 @@ struct cfg80211_registered_device { |
| 71 | |
| 72 | struct wireless_dev *background_radar_wdev; |
| 73 | struct cfg80211_chan_def background_radar_chandef; |
| 74 | + bool background_cac_started; |
| 75 | + unsigned long background_cac_start_time; |
| 76 | + unsigned int background_cac_time_ms; |
| 77 | struct delayed_work background_cac_done_wk; |
| 78 | struct work_struct background_cac_abort_wk; |
| 79 | |
| 80 | diff --git a/net/wireless/debugfs.c b/net/wireless/debugfs.c |
developer | 8b64f1a | 2023-05-02 10:31:58 +0800 | [diff] [blame] | 81 | index 0878b16..a228a14 100644 |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 82 | --- a/net/wireless/debugfs.c |
| 83 | +++ b/net/wireless/debugfs.c |
| 84 | @@ -9,6 +9,7 @@ |
| 85 | #include <linux/slab.h> |
| 86 | #include "core.h" |
| 87 | #include "debugfs.h" |
| 88 | +#include "rdev-ops.h" |
| 89 | |
| 90 | #define DEBUGFS_READONLY_FILE(name, buflen, fmt, value...) \ |
| 91 | static ssize_t name## _read(struct file *file, char __user *userbuf, \ |
developer | 8b64f1a | 2023-05-02 10:31:58 +0800 | [diff] [blame] | 92 | @@ -96,16 +97,312 @@ static const struct file_operations ht40allow_map_ops = { |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 93 | .llseek = default_llseek, |
| 94 | }; |
| 95 | |
| 96 | -#define DEBUGFS_ADD(name) \ |
| 97 | - debugfs_create_file(#name, 0444, phyd, &rdev->wiphy, &name## _ops) |
| 98 | +static int dfs_print_chan(struct ieee80211_channel *chan, int remain_time, int wait_time, |
| 99 | + char *buf, int buf_size, int offset, bool is_background) |
| 100 | +{ |
| 101 | + if (WARN_ON(offset > buf_size)) |
| 102 | + return 0; |
| 103 | + |
| 104 | + if (chan->dfs_state == NL80211_DFS_UNAVAILABLE) { |
| 105 | + offset += scnprintf(buf + offset, buf_size - offset, |
| 106 | + " Channel = %d, DFS_state = Unavailable", |
| 107 | + chan->hw_value); |
| 108 | + if (remain_time > 0) |
| 109 | + offset += scnprintf(buf + offset, buf_size - offset, |
| 110 | + ", Non-occupancy Remain Time = %d / %d [sec]", |
| 111 | + remain_time, wait_time); |
| 112 | + else |
| 113 | + offset += scnprintf(buf + offset, buf_size - offset, |
| 114 | + ", Changing state..."); |
| 115 | + } else if (chan->dfs_state == NL80211_DFS_USABLE) { |
| 116 | + offset += scnprintf(buf + offset, buf_size - offset, |
| 117 | + " Channel = %d, DFS_state = Usable", |
| 118 | + chan->hw_value); |
| 119 | + if (remain_time > 0) |
| 120 | + offset += scnprintf(buf + offset, buf_size - offset, |
| 121 | + ", CAC Remain Time = %d / %d [sec]", |
| 122 | + remain_time, wait_time); |
| 123 | + } else if (chan->dfs_state == NL80211_DFS_AVAILABLE) { |
| 124 | + offset += scnprintf(buf + offset, buf_size - offset, |
| 125 | + " Channel = %d, DFS_state = Available", |
| 126 | + chan->hw_value); |
| 127 | + } else { |
| 128 | + offset += scnprintf(buf + offset, buf_size - offset, |
| 129 | + " Channel = %d, DFS_state = Unknown", |
| 130 | + chan->hw_value); |
| 131 | + } |
| 132 | + |
| 133 | + if (is_background) |
| 134 | + offset += scnprintf(buf + offset, buf_size - offset, |
| 135 | + " (background chain)"); |
| 136 | + offset += scnprintf(buf + offset, buf_size - offset, "\n"); |
| 137 | + |
| 138 | + return offset; |
| 139 | +} |
| 140 | + |
| 141 | +static int dfs_status_read_wdev(struct wiphy *wiphy, struct wireless_dev *wdev, char *buf, |
| 142 | + unsigned int buf_size, unsigned int offset) |
| 143 | +{ |
| 144 | + struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); |
developer | aa5b1b2 | 2022-12-13 17:05:25 +0800 | [diff] [blame] | 145 | + struct cfg80211_chan_def *chandef = &wdev->links[0].ap.chandef; |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 146 | + struct cfg80211_chan_def *background_chandef = &rdev->background_radar_chandef; |
| 147 | + enum nl80211_band band; |
| 148 | + struct ieee80211_supported_band *sband; |
| 149 | + struct ieee80211_channel *chan; |
| 150 | + unsigned long jiffies_passed; |
| 151 | + int i, remain_time = 0, wait_time_ms = 0; |
| 152 | + bool is_background; |
| 153 | + |
| 154 | + offset += scnprintf(buf + offset, buf_size - offset, "DFS Channel:\n"); |
| 155 | + |
| 156 | + for (band = 0; band < NUM_NL80211_BANDS; band++) { |
| 157 | + sband = wiphy->bands[band]; |
| 158 | + if (!sband) |
| 159 | + continue; |
| 160 | + for (i = 0; i < sband->n_channels; i++) { |
| 161 | + is_background = false; |
| 162 | + chan = &sband->channels[i]; |
| 163 | + |
| 164 | + if (!(chan->flags & IEEE80211_CHAN_RADAR)) |
| 165 | + continue; |
| 166 | + |
| 167 | + if (chan->dfs_state == NL80211_DFS_UNAVAILABLE) { |
| 168 | + jiffies_passed = jiffies - chan->dfs_state_entered; |
| 169 | + wait_time_ms = IEEE80211_DFS_MIN_NOP_TIME_MS; |
| 170 | + remain_time = (wait_time_ms - jiffies_to_msecs(jiffies_passed)); |
| 171 | + if (remain_time > wait_time_ms) |
| 172 | + remain_time = 0; |
| 173 | + } else if (chan->dfs_state == NL80211_DFS_USABLE) { |
developer | 7a520b5 | 2023-03-14 14:09:34 +0800 | [diff] [blame] | 174 | + if (wdev->cac_started && |
| 175 | + cfg80211_is_sub_chan(chandef, chan, false)) { |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 176 | + jiffies_passed = jiffies - wdev->cac_start_time; |
| 177 | + wait_time_ms = wdev->cac_time_ms; |
| 178 | + remain_time = (wait_time_ms - |
| 179 | + jiffies_to_msecs(jiffies_passed)); |
| 180 | + } |
| 181 | + |
| 182 | + if (rdev->background_radar_wdev == wdev && |
| 183 | + rdev->background_cac_started && |
developer | aa5b1b2 | 2022-12-13 17:05:25 +0800 | [diff] [blame] | 184 | + cfg80211_is_sub_chan(background_chandef, chan, false)) { |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 185 | + jiffies_passed = jiffies - rdev->background_cac_start_time; |
| 186 | + wait_time_ms = rdev->background_cac_time_ms; |
| 187 | + remain_time = (wait_time_ms - |
| 188 | + jiffies_to_msecs(jiffies_passed)); |
| 189 | + is_background = true; |
| 190 | + } |
| 191 | + |
| 192 | + if (remain_time > wait_time_ms) |
| 193 | + remain_time = 0; |
| 194 | + |
| 195 | + } else { |
| 196 | + if (rdev->background_radar_wdev == wdev && |
developer | aa5b1b2 | 2022-12-13 17:05:25 +0800 | [diff] [blame] | 197 | + cfg80211_is_sub_chan(background_chandef, chan, false)) |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 198 | + is_background = true; |
| 199 | + } |
| 200 | + |
| 201 | + offset = dfs_print_chan(chan, remain_time / 1000, wait_time_ms / 1000, |
| 202 | + buf, buf_size, offset, is_background); |
| 203 | + remain_time = 0; |
| 204 | + } |
| 205 | + } |
| 206 | + |
| 207 | + return offset; |
| 208 | +} |
| 209 | + |
| 210 | +static ssize_t dfs_status_read(struct file *file, char __user *user_buf, |
| 211 | + size_t count, loff_t *ppos) |
| 212 | +{ |
| 213 | + struct wiphy *wiphy = file->private_data; |
| 214 | + struct wireless_dev *wdev; |
| 215 | + char *buf; |
| 216 | + unsigned int offset = 0, buf_size = PAGE_SIZE, r; |
| 217 | + const char * const iftype_str[] = { |
| 218 | + [NL80211_IFTYPE_UNSPECIFIED] = "unspecified", |
| 219 | + [NL80211_IFTYPE_ADHOC] = "adhoc", |
| 220 | + [NL80211_IFTYPE_STATION] = "station", |
| 221 | + [NL80211_IFTYPE_AP] = "ap", |
| 222 | + [NL80211_IFTYPE_AP_VLAN] = "ap vlan", |
| 223 | + [NL80211_IFTYPE_WDS] = "wds", |
| 224 | + [NL80211_IFTYPE_MONITOR] = "monitor", |
| 225 | + [NL80211_IFTYPE_MESH_POINT] = "mesh point", |
| 226 | + [NL80211_IFTYPE_P2P_CLIENT] = "p2p client", |
| 227 | + [NL80211_IFTYPE_P2P_GO] = "p2p go", |
| 228 | + [NL80211_IFTYPE_P2P_DEVICE] = "p2p device", |
| 229 | + [NL80211_IFTYPE_OCB] = "ocb", |
| 230 | + [NL80211_IFTYPE_NAN] = "nan", |
| 231 | + }; |
| 232 | + |
| 233 | + buf = kzalloc(buf_size, GFP_KERNEL); |
| 234 | + if (!buf) |
| 235 | + return -ENOMEM; |
| 236 | + |
| 237 | + list_for_each_entry(wdev, &wiphy->wdev_list, list) { |
| 238 | + offset += scnprintf(buf + offset, buf_size - offset, |
| 239 | + "wdev 0x%x\n" |
| 240 | + "interface type %s\n", |
| 241 | + wdev->identifier, iftype_str[wdev->iftype]); |
| 242 | + offset = dfs_status_read_wdev(wiphy, wdev, buf, buf_size, offset); |
| 243 | + } |
| 244 | + |
| 245 | + r = simple_read_from_buffer(user_buf, count, ppos, buf, offset); |
| 246 | + |
| 247 | + kfree(buf); |
| 248 | + |
| 249 | + return r; |
| 250 | +} |
| 251 | + |
| 252 | +static const struct file_operations dfs_status_ops = { |
| 253 | + .read = dfs_status_read, |
| 254 | + .open = simple_open, |
| 255 | + .llseek = default_llseek, |
| 256 | +}; |
| 257 | + |
| 258 | +static int |
| 259 | +dfs_nop_skip(void *data, u64 val) |
| 260 | +{ |
| 261 | + struct wiphy *wiphy = data; |
| 262 | + struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); |
| 263 | + bool en = !!val; |
| 264 | + enum nl80211_band band; |
| 265 | + struct ieee80211_supported_band *sband; |
| 266 | + struct ieee80211_channel *chan; |
| 267 | + u32 nop_time = IEEE80211_DFS_MIN_NOP_TIME_MS; |
| 268 | + int i; |
| 269 | + |
| 270 | + if (!en) |
| 271 | + return 0; |
| 272 | + |
| 273 | + for (band = 0; band < NUM_NL80211_BANDS; band++) { |
| 274 | + sband = wiphy->bands[band]; |
| 275 | + if (!sband) |
| 276 | + continue; |
| 277 | + for (i = 0; i < sband->n_channels; i++) { |
| 278 | + chan = &sband->channels[i]; |
| 279 | + |
| 280 | + if (!(chan->flags & IEEE80211_CHAN_RADAR)) |
| 281 | + continue; |
| 282 | + |
| 283 | + if (chan->dfs_state == NL80211_DFS_UNAVAILABLE) { |
| 284 | + // Let current jiffies > dfs_state_entered_jiffies + NOP time |
| 285 | + chan->dfs_state_entered = jiffies - |
| 286 | + msecs_to_jiffies(nop_time + 1); |
| 287 | + } |
| 288 | + } |
| 289 | + } |
| 290 | + |
| 291 | + cfg80211_sched_dfs_chan_update(rdev); |
| 292 | + |
| 293 | + return 0; |
| 294 | +} |
| 295 | + |
| 296 | +DEFINE_DEBUGFS_ATTRIBUTE(dfs_skip_nop_ops, NULL, |
| 297 | + dfs_nop_skip, "0x%08llx\n"); |
| 298 | + |
| 299 | +static int |
| 300 | +dfs_cac_skip(void *data, u64 val) |
| 301 | +{ |
| 302 | +#define CAC_SKIP_MASK BIT(0) |
| 303 | +#define CAC_SKIP_BACKGROUND_MASK BIT(1) |
| 304 | + struct wiphy *wiphy = data; |
| 305 | + struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); |
| 306 | + struct wireless_dev *wdev; |
| 307 | + struct cfg80211_chan_def *chandef; |
| 308 | + unsigned int skip_mode = val; |
| 309 | + unsigned long cac_time; |
| 310 | + struct ieee80211_channel *chan; |
| 311 | + |
| 312 | + if (!skip_mode || skip_mode > (CAC_SKIP_MASK | CAC_SKIP_BACKGROUND_MASK)) |
| 313 | + return 0; |
| 314 | + |
| 315 | + list_for_each_entry(wdev, &wiphy->wdev_list, list) { |
developer | aa5b1b2 | 2022-12-13 17:05:25 +0800 | [diff] [blame] | 316 | + if ((skip_mode & CAC_SKIP_MASK) && wdev->links[0].ap.chandef.chan) { |
| 317 | + chandef = &wdev->links[0].ap.chandef; |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 318 | + chan = chandef->chan; |
| 319 | + |
developer | 7a520b5 | 2023-03-14 14:09:34 +0800 | [diff] [blame] | 320 | + if ((cfg80211_chandef_dfs_required(wiphy, chandef, wdev->iftype) > 0) && |
| 321 | + cfg80211_chandef_dfs_usable(wiphy, chandef) && wdev->cac_started) { |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 322 | + rdev_skip_cac(rdev, wdev); |
| 323 | + } |
| 324 | + } |
| 325 | + |
| 326 | + if ((skip_mode & CAC_SKIP_BACKGROUND_MASK) && |
| 327 | + rdev->background_radar_wdev == wdev && |
| 328 | + rdev->background_radar_chandef.chan) { |
| 329 | + chandef = &rdev->background_radar_chandef; |
| 330 | + chan = chandef->chan; |
| 331 | + |
developer | 7a520b5 | 2023-03-14 14:09:34 +0800 | [diff] [blame] | 332 | + if ((cfg80211_chandef_dfs_required(wiphy, chandef, wdev->iftype) > 0) && |
| 333 | + cfg80211_chandef_dfs_usable(wiphy, chandef) && |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 334 | + rdev->background_cac_started) { |
| 335 | + // Let current jiffies > dfs_state_entered_jiffies + CAC time |
| 336 | + cac_time = rdev->background_cac_time_ms; |
| 337 | + rdev->background_cac_start_time = jiffies - |
| 338 | + msecs_to_jiffies(cac_time + 1); |
| 339 | + cancel_delayed_work(&rdev->background_cac_done_wk); |
| 340 | + queue_delayed_work(cfg80211_wq, &rdev->background_cac_done_wk, 0); |
| 341 | + } |
| 342 | + } |
| 343 | + } |
| 344 | + |
| 345 | + return 0; |
| 346 | +} |
| 347 | + |
| 348 | +DEFINE_DEBUGFS_ATTRIBUTE(dfs_skip_cac_ops, NULL, |
| 349 | + dfs_cac_skip, "0x%08llx\n"); |
| 350 | + |
developer | 8b64f1a | 2023-05-02 10:31:58 +0800 | [diff] [blame] | 351 | +static int |
| 352 | +dfs_available_reset(void *data, u64 val) |
| 353 | +{ |
| 354 | + struct wiphy *wiphy = data; |
| 355 | + struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); |
| 356 | + bool en = !!val; |
| 357 | + enum nl80211_band band; |
| 358 | + struct ieee80211_supported_band *sband; |
| 359 | + struct ieee80211_channel *chan; |
| 360 | + int i; |
| 361 | + |
| 362 | + if (!en) |
| 363 | + return 0; |
| 364 | + |
| 365 | + for (band = 0; band < NUM_NL80211_BANDS; band++) { |
| 366 | + sband = wiphy->bands[band]; |
| 367 | + if (!sband) |
| 368 | + continue; |
| 369 | + for (i = 0; i < sband->n_channels; i++) { |
| 370 | + chan = &sband->channels[i]; |
| 371 | + |
| 372 | + if (!(chan->flags & IEEE80211_CHAN_RADAR)) |
| 373 | + continue; |
| 374 | + |
| 375 | + if (chan->dfs_state == NL80211_DFS_AVAILABLE) { |
| 376 | + chan->dfs_state = NL80211_DFS_USABLE; |
| 377 | + chan->dfs_state_entered = jiffies; |
| 378 | + } |
| 379 | + } |
| 380 | + } |
| 381 | + |
| 382 | + cfg80211_sched_dfs_chan_update(rdev); |
| 383 | + |
| 384 | + return 0; |
| 385 | +} |
| 386 | + |
| 387 | +DEFINE_DEBUGFS_ATTRIBUTE(dfs_available_reset_ops, NULL, |
| 388 | + dfs_available_reset, "0x%08llx\n"); |
| 389 | + |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 390 | +#define DEBUGFS_ADD(name, chmod) \ |
| 391 | + debugfs_create_file(#name, chmod, phyd, &rdev->wiphy, &name## _ops) |
| 392 | |
| 393 | void cfg80211_debugfs_rdev_add(struct cfg80211_registered_device *rdev) |
| 394 | { |
| 395 | struct dentry *phyd = rdev->wiphy.debugfsdir; |
| 396 | |
| 397 | - DEBUGFS_ADD(rts_threshold); |
| 398 | - DEBUGFS_ADD(fragmentation_threshold); |
| 399 | - DEBUGFS_ADD(short_retry_limit); |
| 400 | - DEBUGFS_ADD(long_retry_limit); |
| 401 | - DEBUGFS_ADD(ht40allow_map); |
| 402 | + DEBUGFS_ADD(rts_threshold, 0444); |
| 403 | + DEBUGFS_ADD(fragmentation_threshold, 0444); |
| 404 | + DEBUGFS_ADD(short_retry_limit, 0444); |
| 405 | + DEBUGFS_ADD(long_retry_limit, 0444); |
| 406 | + DEBUGFS_ADD(ht40allow_map, 0444); |
| 407 | + DEBUGFS_ADD(dfs_status, 0444); |
| 408 | + DEBUGFS_ADD(dfs_skip_nop, 0600); |
| 409 | + DEBUGFS_ADD(dfs_skip_cac, 0600); |
developer | 8b64f1a | 2023-05-02 10:31:58 +0800 | [diff] [blame] | 410 | + DEBUGFS_ADD(dfs_available_reset, 0600); |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 411 | } |
| 412 | diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 413 | index 8b87bc9..e3cbfc0 100644 |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 414 | --- a/net/wireless/mlme.c |
| 415 | +++ b/net/wireless/mlme.c |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 416 | @@ -1054,13 +1054,16 @@ __cfg80211_background_cac_event(struct cfg80211_registered_device *rdev, |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 417 | queue_work(cfg80211_wq, &rdev->propagate_cac_done_wk); |
| 418 | cfg80211_sched_dfs_chan_update(rdev); |
| 419 | wdev = rdev->background_radar_wdev; |
| 420 | + rdev->background_cac_started = false; |
| 421 | break; |
| 422 | case NL80211_RADAR_CAC_ABORTED: |
| 423 | if (!cancel_delayed_work(&rdev->background_cac_done_wk)) |
| 424 | return; |
| 425 | wdev = rdev->background_radar_wdev; |
| 426 | + rdev->background_cac_started = false; |
| 427 | break; |
| 428 | case NL80211_RADAR_CAC_STARTED: |
| 429 | + rdev->background_cac_started = true; |
| 430 | break; |
| 431 | default: |
| 432 | return; |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 433 | @@ -1080,6 +1083,7 @@ cfg80211_background_cac_event(struct cfg80211_registered_device *rdev, |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 434 | chandef, event); |
| 435 | wiphy_unlock(&rdev->wiphy); |
| 436 | } |
| 437 | +EXPORT_SYMBOL(cfg80211_background_cac_event); |
| 438 | |
| 439 | void cfg80211_background_cac_done_wk(struct work_struct *work) |
| 440 | { |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 441 | @@ -1141,8 +1145,10 @@ cfg80211_start_background_radar_detection(struct cfg80211_registered_device *rde |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 442 | if (!cac_time_ms) |
| 443 | cac_time_ms = IEEE80211_DFS_MIN_CAC_TIME_MS; |
| 444 | |
| 445 | + rdev->background_cac_time_ms = cac_time_ms; |
| 446 | rdev->background_radar_chandef = *chandef; |
| 447 | rdev->background_radar_wdev = wdev; /* Get offchain ownership */ |
| 448 | + rdev->background_cac_start_time = jiffies; |
| 449 | |
| 450 | __cfg80211_background_cac_event(rdev, wdev, chandef, |
| 451 | NL80211_RADAR_CAC_STARTED); |
| 452 | diff --git a/net/wireless/rdev-ops.h b/net/wireless/rdev-ops.h |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 453 | index 72c1282..5a4854c 100644 |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 454 | --- a/net/wireless/rdev-ops.h |
| 455 | +++ b/net/wireless/rdev-ops.h |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 456 | @@ -1524,4 +1524,18 @@ rdev_set_hw_timestamp(struct cfg80211_registered_device *rdev, |
| 457 | |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 458 | return ret; |
| 459 | } |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 460 | + |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 461 | +static inline int |
| 462 | +rdev_skip_cac(struct cfg80211_registered_device *rdev, |
| 463 | + struct wireless_dev *wdev) |
| 464 | +{ |
| 465 | + if (!rdev->ops->skip_cac) |
| 466 | + return -EOPNOTSUPP; |
| 467 | + |
| 468 | + trace_rdev_skip_cac(wdev); |
| 469 | + rdev->ops->skip_cac(wdev); |
| 470 | + trace_rdev_return_void(&rdev->wiphy); |
| 471 | + |
| 472 | + return 0; |
| 473 | +} |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 474 | #endif /* __CFG80211_RDEV_OPS */ |
| 475 | diff --git a/net/wireless/trace.h b/net/wireless/trace.h |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 476 | index fc955a9..01dcfd3 100644 |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 477 | --- a/net/wireless/trace.h |
| 478 | +++ b/net/wireless/trace.h |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 479 | @@ -3981,6 +3981,18 @@ TRACE_EVENT(cfg80211_links_removed, |
| 480 | __entry->link_mask) |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 481 | ); |
| 482 | |
| 483 | +TRACE_EVENT(rdev_skip_cac, |
| 484 | + TP_PROTO(struct wireless_dev *wdev), |
| 485 | + |
| 486 | + TP_ARGS(wdev), |
| 487 | + |
| 488 | + TP_STRUCT__entry(WDEV_ENTRY), |
| 489 | + |
| 490 | + TP_fast_assign(WDEV_ASSIGN;), |
| 491 | + |
| 492 | + TP_printk(WDEV_PR_FMT, WDEV_PR_ARG) |
| 493 | +); |
| 494 | + |
| 495 | #endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */ |
| 496 | |
| 497 | #undef TRACE_INCLUDE_PATH |
| 498 | -- |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 499 | 2.39.2 |
developer | e2cfb52 | 2022-12-08 18:09:45 +0800 | [diff] [blame] | 500 | |