blob: a0f9de1a2d7955a0353f0ab5cc4a1b465e028dfd [file] [log] [blame]
From 8ee7b5e713067c29aab2f7a4389cc806b545c5d8 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/54] mtk: hostapd: 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 f8560a721..50e299303 100644
--- a/hostapd/config_file.c
+++ b/hostapd/config_file.c
@@ -4859,6 +4859,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 cf7cc3923..327533f80 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -3573,6 +3573,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,
@@ -4139,6 +4159,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 ffbc4fb4f..6576d791d 100644
--- a/src/ap/ap_config.h
+++ b/src/ap/ap_config.h
@@ -1200,6 +1200,7 @@ struct hostapd_config {
int *edcca_threshold;
u8 three_wire_enable;
u8 ibf_enable;
+ u8 dfs_detect_mode;
};
enum three_wire_mode {
@@ -1214,6 +1215,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 29d268351..2e138e225 100644
--- a/src/ap/dfs.c
+++ b/src/ap/dfs.c
@@ -1327,6 +1327,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;
@@ -1375,6 +1380,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