developer | a13d7b4 | 2022-09-23 12:17:51 +0800 | [diff] [blame^] | 1 | From a9c16aec415de2f4550c0bf25eb690e9025c5dbf Mon Sep 17 00:00:00 2001 |
| 2 | From: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 3 | Date: Thu, 22 Sep 2022 19:12:18 +0800 |
| 4 | Subject: [PATCH] Add DFS disable channel switch when receive radar |
| 5 | |
| 6 | Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 7 | --- |
| 8 | hostapd/config_file.c | 4 ++++ |
| 9 | hostapd/ctrl_iface.c | 22 ++++++++++++++++++++++ |
| 10 | src/ap/ap_config.h | 13 +++++++++++++ |
| 11 | src/ap/dfs.c | 10 ++++++++++ |
| 12 | 4 files changed, 49 insertions(+) |
| 13 | |
| 14 | diff --git a/hostapd/config_file.c b/hostapd/config_file.c |
| 15 | index 9b79be1..5fa0e37 100644 |
| 16 | --- a/hostapd/config_file.c |
| 17 | +++ b/hostapd/config_file.c |
| 18 | @@ -4789,6 +4789,10 @@ static int hostapd_config_fill(struct hostapd_config *conf, |
| 19 | } else if (os_strcmp(buf, "ibf_enable") == 0) { /*ibf setting is per device*/ |
| 20 | int val = atoi(pos); |
| 21 | conf->ibf_enable = !!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'", |
| 29 | diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c |
| 30 | index a010e7f..6ed8965 100644 |
| 31 | --- a/hostapd/ctrl_iface.c |
| 32 | +++ b/hostapd/ctrl_iface.c |
| 33 | @@ -3494,6 +3494,25 @@ hostapd_ctrl_iface_get_ibf(struct hostapd_data *hapd, char *buf, |
| 34 | return ret; |
| 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 | @@ -4055,6 +4074,9 @@ static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd, |
| 60 | reply_len = hostapd_ctrl_iface_get_hemu(hapd, reply, reply_size); |
| 61 | } else if (os_strncmp(buf, "GET_IBF", 7) == 0) { |
| 62 | reply_len = hostapd_ctrl_iface_get_ibf(hapd, reply, reply_size); |
| 63 | + } else if (os_strncmp(buf, "DFS_DETECT_MODE ", 16) == 0) { |
| 64 | + reply_len = hostapd_ctrl_iface_set_dfs_detect_mode(hapd, buf + 16, |
| 65 | + reply, reply_size); |
| 66 | } else { |
| 67 | os_memcpy(reply, "UNKNOWN COMMAND\n", 16); |
| 68 | reply_len = 16; |
| 69 | diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h |
| 70 | index 2a74e09..97f5e33 100644 |
| 71 | --- a/src/ap/ap_config.h |
| 72 | +++ b/src/ap/ap_config.h |
| 73 | @@ -1158,6 +1158,7 @@ struct hostapd_config { |
| 74 | s8 edcca_compensation; |
| 75 | u8 three_wire_enable; |
| 76 | u8 ibf_enable; |
| 77 | + u8 dfs_detect_mode; |
| 78 | }; |
| 79 | |
| 80 | enum three_wire_mode { |
| 81 | @@ -1172,6 +1173,18 @@ enum three_wire_mode { |
| 82 | NUM_THREE_WIRE_MODE - 1 |
| 83 | }; |
| 84 | |
| 85 | +enum dfs_mode { |
| 86 | + DFS_DETECT_MODE_DISABLE, |
| 87 | + DFS_DETECT_MODE_AP_ENABLE, |
| 88 | + DFS_DETECT_MODE_BACKGROUND_ENABLE, |
| 89 | + DFS_DETECT_MODE_ALL_ENABLE, |
| 90 | + |
| 91 | + /* keep last */ |
| 92 | + NUM_DFS_DETECT_MODE, |
| 93 | + DFS_DETECT_MODE_MAX = |
| 94 | + NUM_DFS_DETECT_MODE - 1 |
| 95 | +}; |
| 96 | + |
| 97 | enum edcca_mode { |
| 98 | EDCCA_MODE_FORCE_DISABLE = 0, |
| 99 | EDCCA_MODE_AUTO = 1, |
| 100 | diff --git a/src/ap/dfs.c b/src/ap/dfs.c |
| 101 | index b5d105d..5cb7799 100644 |
| 102 | --- a/src/ap/dfs.c |
| 103 | +++ b/src/ap/dfs.c |
| 104 | @@ -1317,6 +1317,11 @@ hostapd_dfs_background_start_channel_switch(struct hostapd_iface *iface, |
| 105 | __func__, iface->radar_background.cac_started ? "yes" : "no", |
| 106 | hostapd_csa_in_progress(iface) ? "yes" : "no"); |
| 107 | |
| 108 | + /* Skip channel switch when background dfs detect mode is on */ |
| 109 | + if (iface->conf->dfs_detect_mode == DFS_DETECT_MODE_BACKGROUND_ENABLE || |
| 110 | + iface->conf->dfs_detect_mode == DFS_DETECT_MODE_ALL_ENABLE) |
| 111 | + return 0; |
| 112 | + |
| 113 | /* Check if CSA in progress */ |
| 114 | if (hostapd_csa_in_progress(iface)) |
| 115 | return 0; |
| 116 | @@ -1365,6 +1370,11 @@ static int hostapd_dfs_start_channel_switch(struct hostapd_iface *iface) |
| 117 | __func__, iface->cac_started ? "yes" : "no", |
| 118 | hostapd_csa_in_progress(iface) ? "yes" : "no"); |
| 119 | |
| 120 | + /* Skip channel switch when dfs detect mode is on */ |
| 121 | + if (iface->conf->dfs_detect_mode == DFS_DETECT_MODE_AP_ENABLE || |
| 122 | + iface->conf->dfs_detect_mode == DFS_DETECT_MODE_ALL_ENABLE) |
| 123 | + return 0; |
| 124 | + |
| 125 | /* Check if CSA in progress */ |
| 126 | if (hostapd_csa_in_progress(iface)) |
| 127 | return 0; |
| 128 | -- |
| 129 | 2.18.0 |
| 130 | |