mac80211: support bypass cac

This patch support calcel a running dfs cac opertaion.

Signed-off-by: Jianhui Zhao <jianhui.zhao@gl-inet.com>
This commit is contained in:
Jianhui Zhao 2023-03-22 10:01:15 +08:00
parent 71fc207717
commit e5aa81ce3d
4 changed files with 146 additions and 298 deletions

View File

@ -1,149 +0,0 @@
From 32f4a7b73b09964981bdbd672f7e0c982b87c99b Mon Sep 17 00:00:00 2001
From: Jianhui Zhao <jianhui.zhao@gl-inet.com>
Date: Thu, 3 Nov 2022 09:57:28 +0800
Subject: [PATCH] mac80211: support disable dfs cac dynamically
Signed-off-by: Jianhui Zhao <jianhui.zhao@gl-inet.com>
---
.../subsys/784-nl80211-radar-detect-hack.path | 40 +++++++++
...-support-disable-dfs-cac-dynamically.patch | 81 +++++++++++++++++++
2 files changed, 121 insertions(+)
create mode 100644 package/kernel/mac80211/patches/subsys/784-nl80211-radar-detect-hack.path
create mode 100644 package/network/services/hostapd/patches/800-support-disable-dfs-cac-dynamically.patch
diff --git a/package/kernel/mac80211/patches/subsys/784-nl80211-radar-detect-hack.path b/package/kernel/mac80211/patches/subsys/784-nl80211-radar-detect-hack.path
new file mode 100644
index 0000000000..7a5497f2ba
--- /dev/null
+++ b/package/kernel/mac80211/patches/subsys/784-nl80211-radar-detect-hack.path
@@ -0,0 +1,40 @@
+Index: backports-5.15.58-1/include/net/cfg80211.h
+===================================================================
+--- backports-5.15.58-1.orig/include/net/cfg80211.h
++++ backports-5.15.58-1/include/net/cfg80211.h
+@@ -5190,6 +5190,8 @@ struct wiphy {
+ u8 mbssid_max_interfaces;
+ u8 ema_max_profile_periodicity;
+
++ bool dfs_cac_disabled;
++
+ char priv[] __aligned(NETDEV_ALIGN);
+ };
+
+Index: backports-5.15.58-1/net/wireless/chan.c
+===================================================================
+--- backports-5.15.58-1.orig/net/wireless/chan.c
++++ backports-5.15.58-1/net/wireless/chan.c
+@@ -1218,6 +1218,11 @@ static bool _cfg80211_reg_can_beacon(str
+ prohibited_flags = IEEE80211_CHAN_DISABLED;
+ }
+
++ if (wiphy->dfs_cac_disabled) {
++ prohibited_flags = IEEE80211_CHAN_DISABLED;
++ cfg80211_set_dfs_state(wiphy, chandef, NL80211_DFS_AVAILABLE);
++ }
++
+ res = cfg80211_chandef_usable(wiphy, chandef, prohibited_flags);
+
+ trace_cfg80211_return_bool(res);
+Index: backports-5.15.58-1/net/wireless/debugfs.c
+===================================================================
+--- backports-5.15.58-1.orig/net/wireless/debugfs.c
++++ backports-5.15.58-1/net/wireless/debugfs.c
+@@ -107,4 +107,6 @@ void cfg80211_debugfs_rdev_add(struct cf
+ DEBUGFS_ADD(short_retry_limit);
+ DEBUGFS_ADD(long_retry_limit);
+ DEBUGFS_ADD(ht40allow_map);
++
++ debugfs_create_bool("dfs_cac_disabled", S_IRUSR | S_IWUSR, phyd, &rdev->wiphy.dfs_cac_disabled);
+ }
diff --git a/package/network/services/hostapd/patches/800-support-disable-dfs-cac-dynamically.patch b/package/network/services/hostapd/patches/800-support-disable-dfs-cac-dynamically.patch
new file mode 100644
index 0000000000..86227f1adc
--- /dev/null
+++ b/package/network/services/hostapd/patches/800-support-disable-dfs-cac-dynamically.patch
@@ -0,0 +1,81 @@
+Index: hostapd-2022-01-16-cff80b4f/src/ap/hostapd.c
+===================================================================
+--- hostapd-2022-01-16-cff80b4f.orig/src/ap/hostapd.c
++++ hostapd-2022-01-16-cff80b4f/src/ap/hostapd.c
+@@ -2099,6 +2099,9 @@ static int hostapd_setup_interface_compl
+ iface->conf->channel, iface->freq);
+
+ #ifdef NEED_AP_MLME
++ if (iface->interfaces->dfs_cac_disabled)
++ goto dfs_cac_disabled;
++
+ /* Handle DFS only if it is not offloaded to the driver */
+ if (!(iface->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD)) {
+ /* Check DFS */
+@@ -2126,6 +2129,7 @@ static int hostapd_setup_interface_compl
+ /* Otherwise fall through. */
+ }
+ }
++dfs_cac_disabled:
+ #endif /* NEED_AP_MLME */
+
+ #ifdef CONFIG_MESH
+Index: hostapd-2022-01-16-cff80b4f/src/ap/hostapd.h
+===================================================================
+--- hostapd-2022-01-16-cff80b4f.orig/src/ap/hostapd.h
++++ hostapd-2022-01-16-cff80b4f/src/ap/hostapd.h
+@@ -82,6 +82,7 @@ struct hapd_interfaces {
+ unsigned char ctrl_iface_cookie[CTRL_IFACE_COOKIE_LEN];
+ #endif /* CONFIG_CTRL_IFACE_UDP */
+ struct ubus_object ubus;
++ bool dfs_cac_disabled;
+ };
+
+ enum hostapd_chan_status {
+Index: hostapd-2022-01-16-cff80b4f/src/ap/ubus.c
+===================================================================
+--- hostapd-2022-01-16-cff80b4f.orig/src/ap/ubus.c
++++ hostapd-2022-01-16-cff80b4f/src/ap/ubus.c
+@@ -765,6 +765,34 @@ hostapd_config_remove(struct ubus_contex
+ return UBUS_STATUS_OK;
+ }
+
++enum {
++ DFS_CAC_DISABLE_VALUE,
++ __DFS_CAC_DISABLE_MAX
++};
++
++static const struct blobmsg_policy dfs_cac_disable_policy[__DFS_CAC_DISABLE_MAX] = {
++ [DFS_CAC_DISABLE_VALUE] = { "disabled", BLOBMSG_TYPE_BOOL },
++};
++
++static int
++hostapd_dfs_cac_disable(struct ubus_context *ctx, struct ubus_object *obj,
++ struct ubus_request_data *req, const char *method,
++ struct blob_attr *msg)
++{
++ struct hapd_interfaces *interfaces = get_hapd_interfaces_from_object(obj);
++ struct blob_attr *tb[__DFS_CAC_DISABLE_MAX];
++ char buf[128];
++
++ blobmsg_parse(dfs_cac_disable_policy, __DFS_CAC_DISABLE_MAX, tb, blob_data(msg), blob_len(msg));
++
++ if (!tb[DFS_CAC_DISABLE_VALUE])
++ return UBUS_STATUS_INVALID_ARGUMENT;
++
++ interfaces->dfs_cac_disabled = blobmsg_get_bool(tb[DFS_CAC_DISABLE_VALUE]);
++
++ return UBUS_STATUS_OK;
++}
++
+ enum {
+ CSA_FREQ,
+ CSA_BCN_COUNT,
+@@ -1802,6 +1830,7 @@ void hostapd_ubus_remove_vlan(struct hos
+ static const struct ubus_method daemon_methods[] = {
+ UBUS_METHOD("config_add", hostapd_config_add, config_add_policy),
+ UBUS_METHOD("config_remove", hostapd_config_remove, config_remove_policy),
++ UBUS_METHOD("dfs_cac_disable", hostapd_dfs_cac_disable, dfs_cac_disable_policy),
+ };
+
+ static struct ubus_object_type daemon_object_type =
--
2.25.1

View File

@ -0,0 +1,73 @@
From 762b65d5b4771b7582834e65a1718aaa933349e2 Mon Sep 17 00:00:00 2001
From: Jianhui Zhao <jianhui.zhao@gl-inet.com>
Date: Wed, 22 Mar 2023 09:42:24 +0800
Subject: [PATCH] mac80211: support bypass cac
Signed-off-by: Jianhui Zhao <jianhui.zhao@gl-inet.com>
---
.../subsys/786-support-bypass-cac.patch | 53 +++++++++++++++++++
1 file changed, 53 insertions(+)
create mode 100644 package/kernel/mac80211/patches/subsys/786-support-bypass-cac.patch
diff --git a/package/kernel/mac80211/patches/subsys/786-support-bypass-cac.patch b/package/kernel/mac80211/patches/subsys/786-support-bypass-cac.patch
new file mode 100644
index 0000000000..8e3850e1f7
--- /dev/null
+++ b/package/kernel/mac80211/patches/subsys/786-support-bypass-cac.patch
@@ -0,0 +1,53 @@
+Index: backports-5.15.58-1/net/mac80211/debugfs.c
+===================================================================
+--- backports-5.15.58-1.orig/net/mac80211/debugfs.c
++++ backports-5.15.58-1/net/mac80211/debugfs.c
+@@ -653,6 +653,42 @@ static const struct file_operations scan
+ .llseek = default_llseek,
+ };
+
++static ssize_t bypass_cac_write(struct file *file, const char __user *ptr,
++ size_t len, loff_t *off)
++{
++ struct ieee80211_local *local = file->private_data;
++ struct ieee80211_sub_if_data *sdata;
++
++ rtnl_lock();
++ wiphy_lock(local->hw.wiphy);
++ mutex_lock(&local->mtx);
++
++ list_for_each_entry(sdata, &local->interfaces, list) {
++ struct wireless_dev *wdev = &sdata->wdev;
++
++ cancel_delayed_work_sync(&sdata->dfs_cac_timer_work);
++
++ if (wdev->cac_started) {
++ pr_info("bypass cac for %s\n", sdata->name);
++ wdev->cac_time_ms = 0;
++ ieee80211_queue_delayed_work(&sdata->local->hw,
++ &sdata->dfs_cac_timer_work, 0);
++ }
++ }
++
++ mutex_unlock(&local->mtx);
++ wiphy_unlock(local->hw.wiphy);
++ rtnl_unlock();
++
++ return len;
++}
++
++static const struct file_operations bypass_cac_ops = {
++ .write = bypass_cac_write,
++ .open = simple_open,
++ .llseek = noop_llseek,
++};
++
+ void debugfs_hw_add(struct ieee80211_local *local)
+ {
+ struct dentry *phyd = local->hw.wiphy->debugfsdir;
+@@ -725,4 +761,5 @@ void debugfs_hw_add(struct ieee80211_loc
+ DEBUGFS_DEVSTATS_ADD(dot11RTSSuccessCount);
+
+ DEBUGFS_ADD(scanning);
++ DEBUGFS_ADD_MODE(bypass_cac, 0200);
+ }
--
2.34.1

View File

@ -1,149 +0,0 @@
From abf483261667b0b218c3641e4f0ff338739db7ba Mon Sep 17 00:00:00 2001
From: Jianhui Zhao <jianhui.zhao@gl-inet.com>
Date: Tue, 1 Nov 2022 11:31:30 +0800
Subject: [PATCH] mac80211: support disable dfs cac dynamically
Signed-off-by: Jianhui Zhao <jianhui.zhao@gl-inet.com>
---
...-support-disable-dfs-cac-dynamically.patch | 81 +++++++++++++++++++
.../300-nl80211-radar-detect-hack.path | 40 +++++++++
2 files changed, 121 insertions(+)
create mode 100644 feeds/wifi-ax/hostapd/patches/o00-000-support-disable-dfs-cac-dynamically.patch
create mode 100644 feeds/wifi-ax/mac80211/patches/pending/300-nl80211-radar-detect-hack.path
diff --git a/feeds/wifi-ax/hostapd/patches/o00-000-support-disable-dfs-cac-dynamically.patch b/feeds/wifi-ax/hostapd/patches/o00-000-support-disable-dfs-cac-dynamically.patch
new file mode 100644
index 00000000..474d4eab
--- /dev/null
+++ b/feeds/wifi-ax/hostapd/patches/o00-000-support-disable-dfs-cac-dynamically.patch
@@ -0,0 +1,81 @@
+Index: hostapd-2021-02-20-59e9794c/src/ap/hostapd.h
+===================================================================
+--- hostapd-2021-02-20-59e9794c.orig/src/ap/hostapd.h
++++ hostapd-2021-02-20-59e9794c/src/ap/hostapd.h
+@@ -82,6 +82,7 @@ struct hapd_interfaces {
+ unsigned char ctrl_iface_cookie[CTRL_IFACE_COOKIE_LEN];
+ #endif /* CONFIG_CTRL_IFACE_UDP */
+ struct ubus_object ubus;
++ bool dfs_cac_disabled;
+ };
+
+ enum hostapd_chan_status {
+Index: hostapd-2021-02-20-59e9794c/src/ap/ubus.c
+===================================================================
+--- hostapd-2021-02-20-59e9794c.orig/src/ap/ubus.c
++++ hostapd-2021-02-20-59e9794c/src/ap/ubus.c
+@@ -755,6 +755,34 @@ hostapd_config_remove(struct ubus_contex
+ return UBUS_STATUS_OK;
+ }
+
++enum {
++ DFS_CAC_DISABLE_VALUE,
++ __DFS_CAC_DISABLE_MAX
++};
++
++static const struct blobmsg_policy dfs_cac_disable_policy[__DFS_CAC_DISABLE_MAX] = {
++ [DFS_CAC_DISABLE_VALUE] = { "disabled", BLOBMSG_TYPE_BOOL },
++};
++
++static int
++hostapd_dfs_cac_disable(struct ubus_context *ctx, struct ubus_object *obj,
++ struct ubus_request_data *req, const char *method,
++ struct blob_attr *msg)
++{
++ struct hapd_interfaces *interfaces = get_hapd_interfaces_from_object(obj);
++ struct blob_attr *tb[__DFS_CAC_DISABLE_MAX];
++ char buf[128];
++
++ blobmsg_parse(dfs_cac_disable_policy, __DFS_CAC_DISABLE_MAX, tb, blob_data(msg), blob_len(msg));
++
++ if (!tb[DFS_CAC_DISABLE_VALUE])
++ return UBUS_STATUS_INVALID_ARGUMENT;
++
++ interfaces->dfs_cac_disabled = blobmsg_get_bool(tb[DFS_CAC_DISABLE_VALUE]);
++
++ return UBUS_STATUS_OK;
++}
++
+ enum {
+ CSA_FREQ,
+ CSA_BCN_COUNT,
+@@ -1689,6 +1717,7 @@ void hostapd_ubus_remove_vlan(struct hos
+ static const struct ubus_method daemon_methods[] = {
+ UBUS_METHOD("config_add", hostapd_config_add, config_add_policy),
+ UBUS_METHOD("config_remove", hostapd_config_remove, config_remove_policy),
++ UBUS_METHOD("dfs_cac_disable", hostapd_dfs_cac_disable, dfs_cac_disable_policy),
+ };
+
+ static struct ubus_object_type daemon_object_type =
+Index: hostapd-2021-02-20-59e9794c/src/ap/hostapd.c
+===================================================================
+--- hostapd-2021-02-20-59e9794c.orig/src/ap/hostapd.c
++++ hostapd-2021-02-20-59e9794c/src/ap/hostapd.c
+@@ -2138,6 +2138,9 @@ static int hostapd_setup_interface_compl
+ iface->conf->channel, iface->freq);
+
+ #ifdef NEED_AP_MLME
++ if (iface->interfaces->dfs_cac_disabled)
++ goto dfs_cac_disabled;
++
+ /* Handle DFS only if it is not offloaded to the driver */
+ if (!(iface->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD)) {
+ /* Check DFS */
+@@ -2165,6 +2168,7 @@ static int hostapd_setup_interface_compl
+ /* Otherwise fall through. */
+ }
+ }
++dfs_cac_disabled:
+ #endif /* NEED_AP_MLME */
+
+ #ifdef CONFIG_MESH
diff --git a/feeds/wifi-ax/mac80211/patches/pending/300-nl80211-radar-detect-hack.path b/feeds/wifi-ax/mac80211/patches/pending/300-nl80211-radar-detect-hack.path
new file mode 100644
index 00000000..48138cbd
--- /dev/null
+++ b/feeds/wifi-ax/mac80211/patches/pending/300-nl80211-radar-detect-hack.path
@@ -0,0 +1,40 @@
+Index: backports-20210222_001-4.4.60-b157d2276/include/net/cfg80211.h
+===================================================================
+--- backports-20210222_001-4.4.60-b157d2276.orig/include/net/cfg80211.h
++++ backports-20210222_001-4.4.60-b157d2276/include/net/cfg80211.h
+@@ -5177,6 +5177,8 @@ struct wiphy {
+
+ const struct cfg80211_sar_capa *sar_capa;
+
++ bool dfs_cac_disabled;
++
+ char priv[] __aligned(NETDEV_ALIGN);
+ };
+
+Index: backports-20210222_001-4.4.60-b157d2276/net/wireless/chan.c
+===================================================================
+--- backports-20210222_001-4.4.60-b157d2276.orig/net/wireless/chan.c
++++ backports-20210222_001-4.4.60-b157d2276/net/wireless/chan.c
+@@ -1198,6 +1198,11 @@ static bool _cfg80211_reg_can_beacon(str
+ prohibited_flags = IEEE80211_CHAN_DISABLED;
+ }
+
++ if (wiphy->dfs_cac_disabled) {
++ prohibited_flags = IEEE80211_CHAN_DISABLED;
++ cfg80211_set_dfs_state(wiphy, chandef, NL80211_DFS_AVAILABLE);
++ }
++
+ res = cfg80211_chandef_usable(wiphy, chandef, prohibited_flags);
+
+ trace_cfg80211_return_bool(res);
+Index: backports-20210222_001-4.4.60-b157d2276/net/wireless/debugfs.c
+===================================================================
+--- backports-20210222_001-4.4.60-b157d2276.orig/net/wireless/debugfs.c
++++ backports-20210222_001-4.4.60-b157d2276/net/wireless/debugfs.c
+@@ -107,4 +107,6 @@ void cfg80211_debugfs_rdev_add(struct cf
+ DEBUGFS_ADD(short_retry_limit);
+ DEBUGFS_ADD(long_retry_limit);
+ DEBUGFS_ADD(ht40allow_map);
++
++ debugfs_create_bool("dfs_cac_disabled", S_IRUSR | S_IWUSR, phyd, &rdev->wiphy.dfs_cac_disabled);
+ }
--
2.25.1

View File

@ -0,0 +1,73 @@
From e602938214b1c140a898c61959a6fa1c043d3dfb Mon Sep 17 00:00:00 2001
From: Jianhui Zhao <jianhui.zhao@gl-inet.com>
Date: Wed, 22 Mar 2023 09:51:49 +0800
Subject: [PATCH] mac80211: support bypass cac
Signed-off-by: Jianhui Zhao <jianhui.zhao@gl-inet.com>
---
.../pending/303-support-bypass-cac.patch | 53 +++++++++++++++++++
1 file changed, 53 insertions(+)
create mode 100644 feeds/wifi-ax/mac80211/patches/pending/303-support-bypass-cac.patch
diff --git a/feeds/wifi-ax/mac80211/patches/pending/303-support-bypass-cac.patch b/feeds/wifi-ax/mac80211/patches/pending/303-support-bypass-cac.patch
new file mode 100644
index 00000000..acc7815c
--- /dev/null
+++ b/feeds/wifi-ax/mac80211/patches/pending/303-support-bypass-cac.patch
@@ -0,0 +1,53 @@
+Index: backports-20210222_001-4.4.60-b157d2276/net/mac80211/debugfs.c
+===================================================================
+--- backports-20210222_001-4.4.60-b157d2276.orig/net/mac80211/debugfs.c
++++ backports-20210222_001-4.4.60-b157d2276/net/mac80211/debugfs.c
+@@ -605,6 +605,42 @@ static const struct file_operations scan
+ .llseek = default_llseek,
+ };
+
++static ssize_t bypass_cac_write(struct file *file, const char __user *ptr,
++ size_t len, loff_t *off)
++{
++ struct ieee80211_local *local = file->private_data;
++ struct ieee80211_sub_if_data *sdata;
++
++ rtnl_lock();
++ wiphy_lock(local->hw.wiphy);
++ mutex_lock(&local->mtx);
++
++ list_for_each_entry(sdata, &local->interfaces, list) {
++ struct wireless_dev *wdev = &sdata->wdev;
++
++ cancel_delayed_work_sync(&sdata->dfs_cac_timer_work);
++
++ if (wdev->cac_started) {
++ pr_info("bypass cac for %s\n", sdata->name);
++ wdev->cac_time_ms = 0;
++ ieee80211_queue_delayed_work(&sdata->local->hw,
++ &sdata->dfs_cac_timer_work, 0);
++ }
++ }
++
++ mutex_unlock(&local->mtx);
++ wiphy_unlock(local->hw.wiphy);
++ rtnl_unlock();
++
++ return len;
++}
++
++static const struct file_operations bypass_cac_ops = {
++ .write = bypass_cac_write,
++ .open = simple_open,
++ .llseek = noop_llseek,
++};
++
+ void debugfs_hw_add(struct ieee80211_local *local)
+ {
+ struct dentry *phyd = local->hw.wiphy->debugfsdir;
+@@ -678,4 +714,5 @@ void debugfs_hw_add(struct ieee80211_loc
+ DEBUGFS_DEVSTATS_ADD(dot11RTSSuccessCount);
+
+ DEBUGFS_ADD(scanning);
++ DEBUGFS_ADD_MODE(bypass_cac, 0200);
+ }
--
2.34.1