From b1474acf2f20eaf65129b28977f12580a229076e Mon Sep 17 00:00:00 2001 From: Marek Kwaczynski Date: Thu, 11 Apr 2024 08:20:05 +0200 Subject: [PATCH] hostapd: ubus: add DFS channels support during CSA Add options to trigger CSA with DFS channels, without this patch ubus request was rejected: ubus call hostapd.wlan0 switch_chan '{"freq":5260,"bcn_count":10}' Command failed: Operation not supported Fixes: WIFI-13385 Signed-off-by: Marek Kwaczynski --- .../s00-005-ubus-csa-add-dfs-support.patch | 50 +++++++++++++++++++ .../x-0006-ubus-csa-add-dfs-support.patch | 50 +++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 feeds/ipq807x_v5.4/hostapd/patches/s00-005-ubus-csa-add-dfs-support.patch create mode 100644 feeds/wifi-ax/hostapd/patches/x-0006-ubus-csa-add-dfs-support.patch diff --git a/feeds/ipq807x_v5.4/hostapd/patches/s00-005-ubus-csa-add-dfs-support.patch b/feeds/ipq807x_v5.4/hostapd/patches/s00-005-ubus-csa-add-dfs-support.patch new file mode 100644 index 000000000..9860d689e --- /dev/null +++ b/feeds/ipq807x_v5.4/hostapd/patches/s00-005-ubus-csa-add-dfs-support.patch @@ -0,0 +1,50 @@ +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 +@@ -25,2 +25,3 @@ + #include "airtime_policy.h" ++#include "dfs.h" + #include "hw_features.h" +@@ -857,6 +858,7 @@ hostapd_switch_chan(struct ubus_context + u8 seg0 = 0, seg1 = 0; + int ret = UBUS_STATUS_OK; + int i; ++ int dfs_range = 0; + + blobmsg_parse(csa_policy, __CSA_MAX, tb, blob_data(msg), blob_len(msg)); + +@@ -912,6 +914,17 @@ hostapd_switch_chan(struct ubus_context + break; + } + ++ if (css.freq_params.center_freq1) ++ dfs_range += hostapd_is_dfs_overlap( ++ hapd->iface, chwidth, css.freq_params.center_freq1); ++ else ++ dfs_range += hostapd_is_dfs_overlap( ++ hapd->iface, chwidth, css.freq_params.freq); ++ ++ if (css.freq_params.center_freq2) ++ dfs_range += hostapd_is_dfs_overlap( ++ hapd->iface, chwidth, css.freq_params.center_freq2); ++ + hostapd_set_freq_params(&css.freq_params, iconf->hw_mode, + css.freq_params.freq, + css.freq_params.channel, iconf->enable_edmg, +@@ -925,6 +938,15 @@ hostapd_switch_chan(struct ubus_context + mode ? &mode->he_capab[IEEE80211_MODE_AP] : + NULL); + ++ if (dfs_range) { ++ /* Perform CAC and switch channel */ ++ freq_params = malloc(sizeof(*freq_params)); ++ memcpy(freq_params, &css.freq_params, sizeof(*freq_params)); ++ eloop_register_timeout(0, 1, switch_chan_fallback_cb, ++ hapd->iface, freq_params); ++ return 0; ++ } ++ + for (i = 0; i < hapd->iface->num_bss; i++) { + struct hostapd_data *bss = hapd->iface->bss[i]; + diff --git a/feeds/wifi-ax/hostapd/patches/x-0006-ubus-csa-add-dfs-support.patch b/feeds/wifi-ax/hostapd/patches/x-0006-ubus-csa-add-dfs-support.patch new file mode 100644 index 000000000..9860d689e --- /dev/null +++ b/feeds/wifi-ax/hostapd/patches/x-0006-ubus-csa-add-dfs-support.patch @@ -0,0 +1,50 @@ +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 +@@ -25,2 +25,3 @@ + #include "airtime_policy.h" ++#include "dfs.h" + #include "hw_features.h" +@@ -857,6 +858,7 @@ hostapd_switch_chan(struct ubus_context + u8 seg0 = 0, seg1 = 0; + int ret = UBUS_STATUS_OK; + int i; ++ int dfs_range = 0; + + blobmsg_parse(csa_policy, __CSA_MAX, tb, blob_data(msg), blob_len(msg)); + +@@ -912,6 +914,17 @@ hostapd_switch_chan(struct ubus_context + break; + } + ++ if (css.freq_params.center_freq1) ++ dfs_range += hostapd_is_dfs_overlap( ++ hapd->iface, chwidth, css.freq_params.center_freq1); ++ else ++ dfs_range += hostapd_is_dfs_overlap( ++ hapd->iface, chwidth, css.freq_params.freq); ++ ++ if (css.freq_params.center_freq2) ++ dfs_range += hostapd_is_dfs_overlap( ++ hapd->iface, chwidth, css.freq_params.center_freq2); ++ + hostapd_set_freq_params(&css.freq_params, iconf->hw_mode, + css.freq_params.freq, + css.freq_params.channel, iconf->enable_edmg, +@@ -925,6 +938,15 @@ hostapd_switch_chan(struct ubus_context + mode ? &mode->he_capab[IEEE80211_MODE_AP] : + NULL); + ++ if (dfs_range) { ++ /* Perform CAC and switch channel */ ++ freq_params = malloc(sizeof(*freq_params)); ++ memcpy(freq_params, &css.freq_params, sizeof(*freq_params)); ++ eloop_register_timeout(0, 1, switch_chan_fallback_cb, ++ hapd->iface, freq_params); ++ return 0; ++ } ++ + for (i = 0; i < hapd->iface->num_bss; i++) { + struct hostapd_data *bss = hapd->iface->bss[i]; +