blob: a1a47138214fe6b8affd82c70e5c436b33ff01a7 [file] [log] [blame]
developer5cebe562022-10-08 00:32:24 +08001From 0905060a7bfced9c8cad91a223991a7fa24c3d12 Mon Sep 17 00:00:00 2001
developera13d7b42022-09-23 12:17:51 +08002From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
developer9f764972022-10-06 18:59:51 +08003Date: Fri, 7 Oct 2022 10:46:29 +0800
developer5cebe562022-10-08 00:32:24 +08004Subject: [PATCH 99919/99920] Add DFS disable channel switch when receive radar
developera13d7b42022-09-23 12:17:51 +08005
6Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
7---
8 hostapd/config_file.c | 4 ++++
developer9f764972022-10-06 18:59:51 +08009 hostapd/ctrl_iface.c | 20 ++++++++++++++++++++
developera13d7b42022-09-23 12:17:51 +080010 src/ap/ap_config.h | 13 +++++++++++++
11 src/ap/dfs.c | 10 ++++++++++
developer9f764972022-10-06 18:59:51 +080012 4 files changed, 47 insertions(+)
developera13d7b42022-09-23 12:17:51 +080013
14diff --git a/hostapd/config_file.c b/hostapd/config_file.c
developer9f764972022-10-06 18:59:51 +080015index 310f97d..a2ee418 100644
developera13d7b42022-09-23 12:17:51 +080016--- a/hostapd/config_file.c
17+++ b/hostapd/config_file.c
developer9f764972022-10-06 18:59:51 +080018@@ -4807,6 +4807,10 @@ static int hostapd_config_fill(struct hostapd_config *conf,
19 return 1;
20 }
21 conf->amsdu = val;
developera13d7b42022-09-23 12:17:51 +080022+ } 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
developer9f764972022-10-06 18:59:51 +080030index 0c40175..cc440fd 100644
developera13d7b42022-09-23 12:17:51 +080031--- a/hostapd/ctrl_iface.c
32+++ b/hostapd/ctrl_iface.c
developer9f764972022-10-06 18:59:51 +080033@@ -3537,6 +3537,26 @@ hostapd_ctrl_iface_get_aggregation(struct hostapd_data *hapd, char *buf,
developera13d7b42022-09-23 12:17:51 +080034 }
35
developer9f764972022-10-06 18:59:51 +080036
developera13d7b42022-09-23 12:17:51 +080037+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+
developer9f764972022-10-06 18:59:51 +080056+
developera13d7b42022-09-23 12:17:51 +080057 static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd,
58 char *buf, char *reply,
developer9f764972022-10-06 18:59:51 +080059 int reply_size,
developera13d7b42022-09-23 12:17:51 +080060diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
developer9f764972022-10-06 18:59:51 +080061index 01b051d..f567c37 100644
developera13d7b42022-09-23 12:17:51 +080062--- a/src/ap/ap_config.h
63+++ b/src/ap/ap_config.h
developer9f764972022-10-06 18:59:51 +080064@@ -1160,6 +1160,7 @@ struct hostapd_config {
developera13d7b42022-09-23 12:17:51 +080065 u8 ibf_enable;
developer9f764972022-10-06 18:59:51 +080066 u8 ampdu;
67 u8 amsdu;
developera13d7b42022-09-23 12:17:51 +080068+ u8 dfs_detect_mode;
69 };
70
71 enum three_wire_mode {
developer9f764972022-10-06 18:59:51 +080072@@ -1174,6 +1175,18 @@ enum three_wire_mode {
developera13d7b42022-09-23 12:17:51 +080073 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