developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 1 | From 28af790c74e862e0c23ced4e458e4149e69a1427 Mon Sep 17 00:00:00 2001 |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 2 | From: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 3 | Date: Mon, 20 Feb 2023 14:55:49 +0800 |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 4 | Subject: [PATCH 10/32] hostapd: mtk: Add DFS detection mode |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 5 | |
| 6 | Add DFS detection mode for testing radar detection rate. |
| 7 | If DFS detection mode is on, AP will not switch channels when receiving |
| 8 | a radar signal. |
| 9 | This detection mode also supports background chain. |
| 10 | |
| 11 | Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 12 | --- |
| 13 | hostapd/config_file.c | 4 ++++ |
| 14 | hostapd/ctrl_iface.c | 23 +++++++++++++++++++++++ |
| 15 | src/ap/ap_config.h | 13 +++++++++++++ |
| 16 | src/ap/dfs.c | 10 ++++++++++ |
| 17 | 4 files changed, 50 insertions(+) |
| 18 | |
| 19 | diff --git a/hostapd/config_file.c b/hostapd/config_file.c |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 20 | index 81bfe81d5..d4eed008c 100644 |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 21 | --- a/hostapd/config_file.c |
| 22 | +++ b/hostapd/config_file.c |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 23 | @@ -4855,6 +4855,10 @@ static int hostapd_config_fill(struct hostapd_config *conf, |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 24 | } else if (os_strcmp(buf, "ibf_enable") == 0) { /*ibf setting is per device*/ |
| 25 | int val = atoi(pos); |
| 26 | conf->ibf_enable = !!val; |
| 27 | + } else if (os_strcmp(buf, "dfs_detect_mode") == 0) { /*bypass channel switch*/ |
| 28 | + u8 en = strtol(pos, NULL, 10); |
| 29 | + |
| 30 | + conf->dfs_detect_mode = en; |
| 31 | } else { |
| 32 | wpa_printf(MSG_ERROR, |
| 33 | "Line %d: unknown configuration item '%s'", |
| 34 | diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 35 | index f2cb7af1e..0d978be7e 100644 |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 36 | --- a/hostapd/ctrl_iface.c |
| 37 | +++ b/hostapd/ctrl_iface.c |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 38 | @@ -3632,6 +3632,26 @@ hostapd_ctrl_iface_get_ibf(struct hostapd_data *hapd, char *buf, |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | |
| 42 | +static int |
| 43 | +hostapd_ctrl_iface_set_dfs_detect_mode(struct hostapd_data *hapd, char *value, |
| 44 | + char *buf, size_t buflen) |
| 45 | +{ |
| 46 | + u8 dfs_detect_mode; |
| 47 | + |
| 48 | + if (!value) |
| 49 | + return -1; |
| 50 | + |
| 51 | + dfs_detect_mode = strtol(value, NULL, 10); |
| 52 | + if (dfs_detect_mode > DFS_DETECT_MODE_MAX) { |
| 53 | + wpa_printf(MSG_ERROR, "Invalid value for dfs detect mode"); |
| 54 | + return -1; |
| 55 | + } |
| 56 | + hapd->iconf->dfs_detect_mode = dfs_detect_mode; |
| 57 | + |
| 58 | + return os_snprintf(buf, buflen, "OK\n"); |
| 59 | +} |
| 60 | + |
| 61 | + |
| 62 | static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd, |
| 63 | char *buf, char *reply, |
| 64 | int reply_size, |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 65 | @@ -4200,6 +4220,9 @@ static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd, |
developer | bb6ddff | 2023-03-08 17:22:32 +0800 | [diff] [blame] | 66 | reply_len = hostapd_ctrl_iface_get_mu(hapd, reply, reply_size); |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 67 | } else if (os_strncmp(buf, "GET_IBF", 7) == 0) { |
| 68 | reply_len = hostapd_ctrl_iface_get_ibf(hapd, reply, reply_size); |
| 69 | + } else if (os_strncmp(buf, "DFS_DETECT_MODE ", 16) == 0) { |
| 70 | + reply_len = hostapd_ctrl_iface_set_dfs_detect_mode(hapd, buf + 16, |
| 71 | + reply, reply_size); |
| 72 | } else { |
| 73 | os_memcpy(reply, "UNKNOWN COMMAND\n", 16); |
| 74 | reply_len = 16; |
| 75 | diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 76 | index 3a3d2b542..7b3e21f7b 100644 |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 77 | --- a/src/ap/ap_config.h |
| 78 | +++ b/src/ap/ap_config.h |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 79 | @@ -1198,6 +1198,7 @@ struct hostapd_config { |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 80 | int *edcca_threshold; |
| 81 | u8 three_wire_enable; |
| 82 | u8 ibf_enable; |
| 83 | + u8 dfs_detect_mode; |
| 84 | }; |
| 85 | |
| 86 | enum three_wire_mode { |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 87 | @@ -1212,6 +1213,18 @@ enum three_wire_mode { |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 88 | NUM_THREE_WIRE_MODE - 1 |
| 89 | }; |
| 90 | |
| 91 | +enum dfs_mode { |
| 92 | + DFS_DETECT_MODE_DISABLE, |
| 93 | + DFS_DETECT_MODE_AP_ENABLE, |
| 94 | + DFS_DETECT_MODE_BACKGROUND_ENABLE, |
| 95 | + DFS_DETECT_MODE_ALL_ENABLE, |
| 96 | + |
| 97 | + /* keep last */ |
| 98 | + NUM_DFS_DETECT_MODE, |
| 99 | + DFS_DETECT_MODE_MAX = |
| 100 | + NUM_DFS_DETECT_MODE - 1 |
| 101 | +}; |
| 102 | + |
| 103 | enum edcca_mode { |
| 104 | EDCCA_MODE_FORCE_DISABLE = 0, |
| 105 | EDCCA_MODE_AUTO = 1, |
| 106 | diff --git a/src/ap/dfs.c b/src/ap/dfs.c |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 107 | index a19afb03f..644a7eae7 100644 |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 108 | --- a/src/ap/dfs.c |
| 109 | +++ b/src/ap/dfs.c |
developer | 5e0a8d7 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 110 | @@ -1322,6 +1322,11 @@ hostapd_dfs_background_start_channel_switch(struct hostapd_iface *iface, |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 111 | __func__, iface->radar_background.cac_started ? "yes" : "no", |
| 112 | hostapd_csa_in_progress(iface) ? "yes" : "no"); |
| 113 | |
| 114 | + /* Skip channel switch when background dfs detect mode is on */ |
| 115 | + if (iface->conf->dfs_detect_mode == DFS_DETECT_MODE_BACKGROUND_ENABLE || |
| 116 | + iface->conf->dfs_detect_mode == DFS_DETECT_MODE_ALL_ENABLE) |
| 117 | + return 0; |
| 118 | + |
| 119 | /* Check if CSA in progress */ |
| 120 | if (hostapd_csa_in_progress(iface)) |
| 121 | return 0; |
developer | 5e0a8d7 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 122 | @@ -1370,6 +1375,11 @@ static int hostapd_dfs_start_channel_switch(struct hostapd_iface *iface) |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 123 | __func__, iface->cac_started ? "yes" : "no", |
| 124 | hostapd_csa_in_progress(iface) ? "yes" : "no"); |
| 125 | |
| 126 | + /* Skip channel switch when dfs detect mode is on */ |
| 127 | + if (iface->conf->dfs_detect_mode == DFS_DETECT_MODE_AP_ENABLE || |
| 128 | + iface->conf->dfs_detect_mode == DFS_DETECT_MODE_ALL_ENABLE) |
| 129 | + return 0; |
| 130 | + |
| 131 | /* Check if CSA in progress */ |
| 132 | if (hostapd_csa_in_progress(iface)) |
| 133 | return 0; |
| 134 | -- |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 135 | 2.39.2 |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 136 | |