blob: a1a47138214fe6b8affd82c70e5c436b33ff01a7 [file] [log] [blame]
From 0905060a7bfced9c8cad91a223991a7fa24c3d12 Mon Sep 17 00:00:00 2001
From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
Date: Fri, 7 Oct 2022 10:46:29 +0800
Subject: [PATCH 99919/99920] Add DFS disable channel switch when receive radar
Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
---
hostapd/config_file.c | 4 ++++
hostapd/ctrl_iface.c | 20 ++++++++++++++++++++
src/ap/ap_config.h | 13 +++++++++++++
src/ap/dfs.c | 10 ++++++++++
4 files changed, 47 insertions(+)
diff --git a/hostapd/config_file.c b/hostapd/config_file.c
index 310f97d..a2ee418 100644
--- a/hostapd/config_file.c
+++ b/hostapd/config_file.c
@@ -4807,6 +4807,10 @@ static int hostapd_config_fill(struct hostapd_config *conf,
return 1;
}
conf->amsdu = val;
+ } else if (os_strcmp(buf, "dfs_detect_mode") == 0) { /*bypass channel switch*/
+ u8 en = strtol(pos, NULL, 10);
+
+ conf->dfs_detect_mode = en;
} else {
wpa_printf(MSG_ERROR,
"Line %d: unknown configuration item '%s'",
diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
index 0c40175..cc440fd 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -3537,6 +3537,26 @@ hostapd_ctrl_iface_get_aggregation(struct hostapd_data *hapd, char *buf,
}
+static int
+hostapd_ctrl_iface_set_dfs_detect_mode(struct hostapd_data *hapd, char *value,
+ char *buf, size_t buflen)
+{
+ u8 dfs_detect_mode;
+
+ if (!value)
+ return -1;
+
+ dfs_detect_mode = strtol(value, NULL, 10);
+ if (dfs_detect_mode > DFS_DETECT_MODE_MAX) {
+ wpa_printf(MSG_ERROR, "Invalid value for dfs detect mode");
+ return -1;
+ }
+ hapd->iconf->dfs_detect_mode = dfs_detect_mode;
+
+ return 0;
+}
+
+
static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd,
char *buf, char *reply,
int reply_size,
diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
index 01b051d..f567c37 100644
--- a/src/ap/ap_config.h
+++ b/src/ap/ap_config.h
@@ -1160,6 +1160,7 @@ struct hostapd_config {
u8 ibf_enable;
u8 ampdu;
u8 amsdu;
+ u8 dfs_detect_mode;
};
enum three_wire_mode {
@@ -1174,6 +1175,18 @@ enum three_wire_mode {
NUM_THREE_WIRE_MODE - 1
};
+enum dfs_mode {
+ DFS_DETECT_MODE_DISABLE,
+ DFS_DETECT_MODE_AP_ENABLE,
+ DFS_DETECT_MODE_BACKGROUND_ENABLE,
+ DFS_DETECT_MODE_ALL_ENABLE,
+
+ /* keep last */
+ NUM_DFS_DETECT_MODE,
+ DFS_DETECT_MODE_MAX =
+ NUM_DFS_DETECT_MODE - 1
+};
+
enum edcca_mode {
EDCCA_MODE_FORCE_DISABLE = 0,
EDCCA_MODE_AUTO = 1,
diff --git a/src/ap/dfs.c b/src/ap/dfs.c
index b5d105d..5cb7799 100644
--- a/src/ap/dfs.c
+++ b/src/ap/dfs.c
@@ -1317,6 +1317,11 @@ hostapd_dfs_background_start_channel_switch(struct hostapd_iface *iface,
__func__, iface->radar_background.cac_started ? "yes" : "no",
hostapd_csa_in_progress(iface) ? "yes" : "no");
+ /* Skip channel switch when background dfs detect mode is on */
+ if (iface->conf->dfs_detect_mode == DFS_DETECT_MODE_BACKGROUND_ENABLE ||
+ iface->conf->dfs_detect_mode == DFS_DETECT_MODE_ALL_ENABLE)
+ return 0;
+
/* Check if CSA in progress */
if (hostapd_csa_in_progress(iface))
return 0;
@@ -1365,6 +1370,11 @@ static int hostapd_dfs_start_channel_switch(struct hostapd_iface *iface)
__func__, iface->cac_started ? "yes" : "no",
hostapd_csa_in_progress(iface) ? "yes" : "no");
+ /* Skip channel switch when dfs detect mode is on */
+ if (iface->conf->dfs_detect_mode == DFS_DETECT_MODE_AP_ENABLE ||
+ iface->conf->dfs_detect_mode == DFS_DETECT_MODE_ALL_ENABLE)
+ return 0;
+
/* Check if CSA in progress */
if (hostapd_csa_in_progress(iface))
return 0;
--
2.18.0