diff mbox series

[9/9] DFS: introduce radar_background parameter to config file

Message ID 3683c678668c4de0ee849974977cf56e64c7162c.1640014128.git.lorenzo@kernel.org
State Changes Requested
Headers show
Series introduce background radar detection support | expand

Commit Message

Lorenzo Bianconi Dec. 20, 2021, 3:48 p.m. UTC
Introduce radar_background parameter to configuration file
in order to enable/disable background radar/CAC detection.

Tested-by: Owen Peng <owen.peng@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@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(-)

Comments

Jouni Malinen March 3, 2022, 9:56 p.m. UTC | #1
On Mon, Dec 20, 2021 at 04:48:24PM +0100, Lorenzo Bianconi wrote:
> Introduce radar_background parameter to configuration file
> in order to enable/disable background radar/CAC detection.

What's the use case for this new parameter and the configuration having
to explicitly enable this functionality? Is there a reason for not doing
this in cases where the driver supports this capability? It looks like
patches 1..8 were enabling this functionality automatically and it is
only this final patch that makes it depend on a configuration parameter
(which is default by default).

> diff --git a/hostapd/hostapd.conf b/hostapd/hostapd.conf
> @@ -143,6 +143,13 @@ ssid=test
> +# 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

How would someone writing hostapd configuration know when to enable
this? Or maybe more importantly, when one should not enable this? Would
use of that dedicated background chain result in some other capabilities
getting reduced?

This is also a bit unclear on what happens if the driver does not
support this capability and radar_background=1 is explicitly set in the
configuration.
Lorenzo Bianconi March 4, 2022, 11:08 a.m. UTC | #2
On Mar 03, Jouni Malinen wrote:
> On Mon, Dec 20, 2021 at 04:48:24PM +0100, Lorenzo Bianconi wrote:
> > Introduce radar_background parameter to configuration file
> > in order to enable/disable background radar/CAC detection.
> 
> What's the use case for this new parameter and the configuration having
> to explicitly enable this functionality? Is there a reason for not doing
> this in cases where the driver supports this capability? It looks like
> patches 1..8 were enabling this functionality automatically and it is
> only this final patch that makes it depend on a configuration parameter
> (which is default by default).

I added this parameter just to add the capability to disable radar_background
even if the hw supports it (e.g. for testing/debugging). 

> 
> > diff --git a/hostapd/hostapd.conf b/hostapd/hostapd.conf
> > @@ -143,6 +143,13 @@ ssid=test
> > +# 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
> 
> How would someone writing hostapd configuration know when to enable
> this? Or maybe more importantly, when one should not enable this? Would
> use of that dedicated background chain result in some other capabilities
> getting reduced?

nope, the radar_chain is completely independent from the "data" ones.

> 
> This is also a bit unclear on what happens if the driver does not
> support this capability and radar_background=1 is explicitly set in the
> configuration.

it will not be enabled since we always check WPA_DRIVER_RADAR_BACKGROUND
capability.
Since it is not mandatory, I will drop this patch in the series and always
enable RADAR_BACKGROUND if supported by the hw.

Regards,
Lorenzo

> 
> -- 
> Jouni Malinen                                            PGP id EFC895FA
>
diff mbox series

Patch

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,