blob: c745b791cf94db2ce461b302057f4a9540b7319a [file] [log] [blame]
From 17264416389efadfd5a7839f3a947abaabfb9acf Mon Sep 17 00:00:00 2001
From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
Date: Mon, 20 Feb 2023 14:55:49 +0800
Subject: [PATCH 10/25] hostapd: mtk: Add DFS detection mode
Add DFS detection mode for testing radar detection rate.
If DFS detection mode is on, AP will not switch channels when receiving
a radar signal.
This detection mode also supports background chain.
Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
---
hostapd/config_file.c | 4 ++++
hostapd/ctrl_iface.c | 23 +++++++++++++++++++++++
src/ap/ap_config.h | 13 +++++++++++++
src/ap/dfs.c | 10 ++++++++++
4 files changed, 50 insertions(+)
diff --git a/hostapd/config_file.c b/hostapd/config_file.c
index 579193f..8a61726 100644
--- a/hostapd/config_file.c
+++ b/hostapd/config_file.c
@@ -4803,6 +4803,10 @@ static int hostapd_config_fill(struct hostapd_config *conf,
} else if (os_strcmp(buf, "ibf_enable") == 0) { /*ibf setting is per device*/
int val = atoi(pos);
conf->ibf_enable = !!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 5590100..fcbc4ae 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -3522,6 +3522,26 @@ hostapd_ctrl_iface_get_ibf(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 os_snprintf(buf, buflen, "OK\n");
+}
+
+
static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd,
char *buf, char *reply,
int reply_size,
@@ -4081,6 +4101,9 @@ static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd,
reply_len = hostapd_ctrl_iface_get_mu(hapd, reply, reply_size);
} else if (os_strncmp(buf, "GET_IBF", 7) == 0) {
reply_len = hostapd_ctrl_iface_get_ibf(hapd, reply, reply_size);
+ } else if (os_strncmp(buf, "DFS_DETECT_MODE ", 16) == 0) {
+ reply_len = hostapd_ctrl_iface_set_dfs_detect_mode(hapd, buf + 16,
+ reply, reply_size);
} else {
os_memcpy(reply, "UNKNOWN COMMAND\n", 16);
reply_len = 16;
diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
index be30b51..d3a9fb0 100644
--- a/src/ap/ap_config.h
+++ b/src/ap/ap_config.h
@@ -1160,6 +1160,7 @@ struct hostapd_config {
int *edcca_threshold;
u8 three_wire_enable;
u8 ibf_enable;
+ 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