[PATCH 9/9] DFS: introduce radar_background parameter to config file
Lorenzo Bianconi
lorenzo at kernel.org
Mon Dec 20 07:48:24 PST 2021
Introduce radar_background parameter to configuration file
in order to enable/disable background radar/CAC detection.
Tested-by: Owen Peng <owen.peng at mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo at kernel.org>
---
hostapd/config_file.c | 2 ++
hostapd/hostapd.conf | 7 +++++++
src/ap/ap_config.h | 1 +
src/ap/dfs.c | 21 +++++++++++++--------
4 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/hostapd/config_file.c b/hostapd/config_file.c
index b14728d1b..3cba0b2c2 100644
--- a/hostapd/config_file.c
+++ b/hostapd/config_file.c
@@ -2475,6 +2475,8 @@ static int hostapd_config_fill(struct hostapd_config *conf,
conf->ieee80211d = atoi(pos);
} else if (os_strcmp(buf, "ieee80211h") == 0) {
conf->ieee80211h = atoi(pos);
+ } else if (os_strcmp(buf, "radar_background") == 0) {
+ conf->radar_background = atoi(pos);
} else if (os_strcmp(buf, "ieee8021x") == 0) {
bss->ieee802_1x = atoi(pos);
} else if (os_strcmp(buf, "eapol_version") == 0) {
diff --git a/hostapd/hostapd.conf b/hostapd/hostapd.conf
index 3c2019f73..373f44afb 100644
--- a/hostapd/hostapd.conf
+++ b/hostapd/hostapd.conf
@@ -143,6 +143,13 @@ ssid=test
# ieee80211d=1 and local_pwr_constraint configured.
#spectrum_mgmt_required=1
+# Enable radar/CAC detection through a dedicated background chain available on
+# some hw. The chain can't be used to transmits or receives frames.
+# This feature allows to avoid CAC downtime switching on a different channel
+# during CAC detection on the selected radar channel.
+# (default: 0 = disabled, 1 = enabled)
+#radar_background=0
+
# Operation mode (a = IEEE 802.11a (5 GHz), b = IEEE 802.11b (2.4 GHz),
# g = IEEE 802.11g (2.4 GHz), ad = IEEE 802.11ad (60 GHz); a/g options are used
# with IEEE 802.11n (HT), too, to specify band). For IEEE 802.11ac (VHT), this
diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
index 49cd3168a..f846437f5 100644
--- a/src/ap/ap_config.h
+++ b/src/ap/ap_config.h
@@ -990,6 +990,7 @@ struct hostapd_config {
int ieee80211d;
int ieee80211h; /* DFS */
+ int radar_background;
/*
* Local power constraint is an octet encoded as an unsigned integer in
diff --git a/src/ap/dfs.c b/src/ap/dfs.c
index 35d26e725..ba4c83b5f 100644
--- a/src/ap/dfs.c
+++ b/src/ap/dfs.c
@@ -798,6 +798,11 @@ static unsigned int dfs_get_cac_time(struct hostapd_iface *iface,
return cac_time_ms;
}
+static int hostapd_is_radar_background_enabled(struct hostapd_iface *iface)
+{
+ return (iface->drv_flags2 & WPA_DRIVER_RADAR_BACKGROUND) &&
+ iface->conf->radar_background;
+}
/*
* Main DFS handler
@@ -808,7 +813,7 @@ static unsigned int dfs_get_cac_time(struct hostapd_iface *iface,
int hostapd_handle_dfs(struct hostapd_iface *iface)
{
int res, n_chans, n_chans1, start_chan_idx, start_chan_idx1;
- int skip_radar = 0;
+ int skip_radar = 0, radar_background;
if (is_6ghz_freq(iface->freq))
return 1;
@@ -870,9 +875,9 @@ int hostapd_handle_dfs(struct hostapd_iface *iface)
/* Finally start CAC */
hostapd_set_state(iface, HAPD_IFACE_DFS);
+ radar_background = hostapd_is_radar_background_enabled(iface);
wpa_printf(MSG_DEBUG, "DFS start CAC on %d MHz background %d",
- iface->freq,
- !!(iface->drv_flags2 & WPA_DRIVER_RADAR_BACKGROUND));
+ iface->freq, radar_background);
wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_CAC_START
"freq=%d chan=%d sec_chan=%d, width=%d, seg0=%d, seg1=%d, cac_time=%ds",
iface->freq,
@@ -890,14 +895,14 @@ int hostapd_handle_dfs(struct hostapd_iface *iface)
hostapd_get_oper_chwidth(iface->conf),
hostapd_get_oper_centr_freq_seg0_idx(iface->conf),
hostapd_get_oper_centr_freq_seg1_idx(iface->conf),
- !!(iface->drv_flags2 & WPA_DRIVER_RADAR_BACKGROUND));
+ radar_background);
if (res) {
wpa_printf(MSG_ERROR, "DFS start_dfs_cac() failed, %d", res);
return -1;
}
- if (iface->drv_flags2 & WPA_DRIVER_RADAR_BACKGROUND) {
+ if (radar_background) {
/* Cache background radar parameters */
iface->radar_background.channel = iface->conf->channel;
iface->radar_background.secondary_channel =
@@ -1120,7 +1125,7 @@ int hostapd_dfs_complete_cac(struct hostapd_iface *iface, int success, int freq,
* channel and configure background chain to a new DFS
* channel
*/
- if ((iface->drv_flags2 & WPA_DRIVER_RADAR_BACKGROUND) &&
+ if (hostapd_is_radar_background_enabled(iface) &&
hostapd_dfs_is_background_event(iface, freq)) {
iface->radar_background.cac_started = 0;
if (!iface->radar_background.temp_ch)
@@ -1146,7 +1151,7 @@ int hostapd_dfs_complete_cac(struct hostapd_iface *iface, int success, int freq,
iface->cac_started = 0;
}
}
- } else if ((iface->drv_flags2 & WPA_DRIVER_RADAR_BACKGROUND) &&
+ } else if (hostapd_is_radar_background_enabled(iface) &&
hostapd_dfs_is_background_event(iface, freq)) {
iface->radar_background.cac_started = 0;
hostpad_dfs_update_background_chain(iface);
@@ -1263,7 +1268,7 @@ static int
hostapd_dfs_background_start_channel_switch(struct hostapd_iface *iface,
int freq)
{
- if (!(iface->drv_flags2 & WPA_DRIVER_RADAR_BACKGROUND))
+ if (!hostapd_is_radar_background_enabled(iface))
return -1; /* Background radar chain not supported */
wpa_printf(MSG_DEBUG,
--
2.33.1
More information about the Hostap
mailing list