blob: 58e73b106e61c33238dfbb1c2c5c56c27a837bce [file] [log] [blame]
developerec567112022-10-11 11:02:55 +08001From d9361b85b289804c9a69f4ca3d2747ca17aaf6d5 Mon Sep 17 00:00:00 2001
2From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
3Date: Fri, 7 Oct 2022 10:46:29 +0800
4Subject: [PATCH] Add DFS disable channel switch when receive radar
5
6Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
7---
8 hostapd/config_file.c | 4 ++++
9 hostapd/ctrl_iface.c | 20 ++++++++++++++++++++
10 src/ap/ap_config.h | 13 +++++++++++++
11 src/ap/dfs.c | 10 ++++++++++
12 4 files changed, 47 insertions(+)
13
14diff --git a/hostapd/config_file.c b/hostapd/config_file.c
15index 310f97d..a2ee418 100644
16--- a/hostapd/config_file.c
17+++ b/hostapd/config_file.c
18@@ -4807,6 +4807,10 @@ static int hostapd_config_fill(struct hostapd_config *conf,
19 return 1;
20 }
21 conf->amsdu = val;
22+ } else if (os_strcmp(buf, "dfs_detect_mode") == 0) { /*bypass channel switch*/
23+ u8 en = strtol(pos, NULL, 10);
24+
25+ conf->dfs_detect_mode = en;
26 } else {
27 wpa_printf(MSG_ERROR,
28 "Line %d: unknown configuration item '%s'",
29diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
30index 0c40175..cc440fd 100644
31--- a/hostapd/ctrl_iface.c
32+++ b/hostapd/ctrl_iface.c
33@@ -3537,6 +3537,26 @@ hostapd_ctrl_iface_get_aggregation(struct hostapd_data *hapd, char *buf,
34 }
35
36
37+static int
38+hostapd_ctrl_iface_set_dfs_detect_mode(struct hostapd_data *hapd, char *value,
39+ char *buf, size_t buflen)
40+{
41+ u8 dfs_detect_mode;
42+
43+ if (!value)
44+ return -1;
45+
46+ dfs_detect_mode = strtol(value, NULL, 10);
47+ if (dfs_detect_mode > DFS_DETECT_MODE_MAX) {
48+ wpa_printf(MSG_ERROR, "Invalid value for dfs detect mode");
49+ return -1;
50+ }
51+ hapd->iconf->dfs_detect_mode = dfs_detect_mode;
52+
53+ return 0;
54+}
55+
56+
57 static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd,
58 char *buf, char *reply,
59 int reply_size,
60diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
61index 01b051d..f567c37 100644
62--- a/src/ap/ap_config.h
63+++ b/src/ap/ap_config.h
64@@ -1160,6 +1160,7 @@ struct hostapd_config {
65 u8 ibf_enable;
66 u8 ampdu;
67 u8 amsdu;
68+ u8 dfs_detect_mode;
69 };
70
71 enum three_wire_mode {
72@@ -1174,6 +1175,18 @@ enum three_wire_mode {
73 NUM_THREE_WIRE_MODE - 1
74 };
75
76+enum dfs_mode {
77+ DFS_DETECT_MODE_DISABLE,
78+ DFS_DETECT_MODE_AP_ENABLE,
79+ DFS_DETECT_MODE_BACKGROUND_ENABLE,
80+ DFS_DETECT_MODE_ALL_ENABLE,
81+
82+ /* keep last */
83+ NUM_DFS_DETECT_MODE,
84+ DFS_DETECT_MODE_MAX =
85+ NUM_DFS_DETECT_MODE - 1
86+};
87+
88 enum edcca_mode {
89 EDCCA_MODE_FORCE_DISABLE = 0,
90 EDCCA_MODE_AUTO = 1,
91diff --git a/src/ap/dfs.c b/src/ap/dfs.c
92index b5d105d..5cb7799 100644
93--- a/src/ap/dfs.c
94+++ b/src/ap/dfs.c
95@@ -1317,6 +1317,11 @@ hostapd_dfs_background_start_channel_switch(struct hostapd_iface *iface,
96 __func__, iface->radar_background.cac_started ? "yes" : "no",
97 hostapd_csa_in_progress(iface) ? "yes" : "no");
98
99+ /* Skip channel switch when background dfs detect mode is on */
100+ if (iface->conf->dfs_detect_mode == DFS_DETECT_MODE_BACKGROUND_ENABLE ||
101+ iface->conf->dfs_detect_mode == DFS_DETECT_MODE_ALL_ENABLE)
102+ return 0;
103+
104 /* Check if CSA in progress */
105 if (hostapd_csa_in_progress(iface))
106 return 0;
107@@ -1365,6 +1370,11 @@ static int hostapd_dfs_start_channel_switch(struct hostapd_iface *iface)
108 __func__, iface->cac_started ? "yes" : "no",
109 hostapd_csa_in_progress(iface) ? "yes" : "no");
110
111+ /* Skip channel switch when dfs detect mode is on */
112+ if (iface->conf->dfs_detect_mode == DFS_DETECT_MODE_AP_ENABLE ||
113+ iface->conf->dfs_detect_mode == DFS_DETECT_MODE_ALL_ENABLE)
114+ return 0;
115+
116 /* Check if CSA in progress */
117 if (hostapd_csa_in_progress(iface))
118 return 0;
119--
1202.18.0
121