[PATCH] DFS: for DFS_OFFLOAD case refresh channel state before CHAN_SWITCH
Anjan Chanda
acx.devel at gmail.com
Thu Nov 19 02:00:16 PST 2026
When DFS is offloaded to the driver, hostapd reads the channel DFS
state only once, from hostapd_get_hw_features() during interface
setup. All DFS event handlers return early under
WPA_DRIVER_FLAGS_DFS_OFFLOAD, so the cached state goes stale.
CHAN_SWITCH uses this cached state in hostapd_is_dfs_overlap() to
decide between a CSA and the disable/enable fallback. With stale data
it may restart the interface for a channel the driver already reports
as available, or attempt a CSA to a channel that is not available.
Add hostapd_sync_chan_dfs_state() to refresh only the DFS state bits
and CAC time of the current mode's radar channels from the driver.
Signed-off-by: Anjan Chanda <acx.devel at gmail.com>
---
hostapd/ctrl_iface.c | 10 ++++++++
src/ap/dfs.c | 60 ++++++++++++++++++++++++++++++++++++++++++++
src/ap/dfs.h | 1 +
3 files changed, 71 insertions(+)
diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
index 12a9bc934..5e450c20f 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -2641,6 +2641,16 @@ static int hostapd_ctrl_iface_chan_switch(struct hostapd_iface *iface,
settings.link_id = iface->bss[0]->mld_link_id;
#endif /* CONFIG_IEEE80211BE */
+ /*
+ * In DFS offload case, sync dfs state of the channels
+ * once here so that the fallback path is taken appropriately
+ * for the DFS uncleared channels.
+ */
+ if ((iface->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD) &&
+ hostapd_sync_chan_dfs_state(iface) < 0)
+ wpa_printf(MSG_INFO,
+ "chan_switch: failed to sync channel DFS state");
+
switch (settings.freq_params.bandwidth) {
case 40:
bandwidth = CHAN_WIDTH_40;
diff --git a/src/ap/dfs.c b/src/ap/dfs.c
index 8b85a2555..f93d7949a 100644
--- a/src/ap/dfs.c
+++ b/src/ap/dfs.c
@@ -19,6 +19,7 @@
#include "ap_drv_ops.h"
#include "drivers/driver.h"
#include "dfs.h"
+#include "ap/hw_features.h"
enum dfs_channel_type {
@@ -1765,3 +1766,62 @@ int hostapd_is_dfs_overlap(struct hostapd_iface *iface, enum chan_width width,
return res;
}
+
+/*
+ * Refresh DFS state of the current mode's channels from the driver.
+ */
+int hostapd_sync_chan_dfs_state(struct hostapd_iface *iface)
+{
+ struct hostapd_hw_modes *modes, *cur = iface->current_mode;
+ struct hostapd_data *hapd = iface->bss[0];
+ int i, j, k, updated = 0;
+ u16 num_modes, flags;
+ u8 dfs_domain;
+
+ if (!cur || hostapd_drv_none(hapd))
+ return -1;
+
+ modes = hostapd_get_hw_feature_data(hapd, &num_modes, &flags,
+ &dfs_domain);
+ if (!modes)
+ return -1;
+
+ for (i = 0; i < num_modes; i++) {
+ if (modes[i].mode != cur->mode)
+ continue;
+
+ for (j = 0; j < cur->num_channels; j++) {
+ struct hostapd_channel_data *chan = &cur->channels[j];
+
+ if (!(chan->flag & HOSTAPD_CHAN_RADAR))
+ continue;
+
+ for (k = 0; k < modes[i].num_channels; k++) {
+ struct hostapd_channel_data *drv_chan =
+ &modes[i].channels[k];
+
+ if (drv_chan->freq != chan->freq)
+ continue;
+
+ if ((chan->flag & HOSTAPD_CHAN_DFS_MASK) !=
+ (drv_chan->flag & HOSTAPD_CHAN_DFS_MASK)) {
+ wpa_printf(MSG_DEBUG,
+ "DFS state sync: freq=%d MHz dfs_state 0x%x -> 0x%x",
+ chan->freq,
+ chan->flag & HOSTAPD_CHAN_DFS_MASK,
+ drv_chan->flag & HOSTAPD_CHAN_DFS_MASK);
+ updated++;
+ }
+
+ chan->flag &= ~HOSTAPD_CHAN_DFS_MASK;
+ chan->flag |= drv_chan->flag & HOSTAPD_CHAN_DFS_MASK;
+ chan->dfs_cac_ms = drv_chan->dfs_cac_ms;
+ break;
+ }
+ }
+ }
+
+ hostapd_free_hw_features(modes, num_modes);
+
+ return updated;
+}
diff --git a/src/ap/dfs.h b/src/ap/dfs.h
index a3cb13cd8..d6a02fbca 100644
--- a/src/ap/dfs.h
+++ b/src/ap/dfs.h
@@ -33,4 +33,5 @@ int hostapd_handle_dfs_offload(struct hostapd_iface *iface);
int hostapd_is_dfs_overlap(struct hostapd_iface *iface, enum chan_width width,
int center_freq);
+int hostapd_sync_chan_dfs_state(struct hostapd_iface *iface);
#endif /* DFS_H */
--
2.43.0
More information about the Hostap
mailing list