| From 018d87d5b9b53b3e630032bf2cb7e6eaeae09d71 Mon Sep 17 00:00:00 2001 |
| From: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| Date: Wed, 15 Nov 2023 15:06:00 +0800 |
| Subject: [PATCH 47/49] hostapd: mtk: add support for channel switching to dfs |
| with csa sent |
| |
| Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| --- |
| hostapd/ctrl_iface.c | 26 ++------------------------ |
| src/ap/beacon.c | 5 +++++ |
| src/ap/dfs.c | 16 ++++++++++++---- |
| src/ap/ieee802_11.c | 5 +++++ |
| 4 files changed, 24 insertions(+), 28 deletions(-) |
| |
| diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c |
| index b521a08..0afa6a2 100644 |
| --- a/hostapd/ctrl_iface.c |
| +++ b/hostapd/ctrl_iface.c |
| @@ -2747,7 +2747,6 @@ static int hostapd_ctrl_iface_chan_switch(struct hostapd_iface *iface, |
| int dfs_range = 0; |
| unsigned int i; |
| int bandwidth; |
| - u8 chan; |
| |
| ret = hostapd_parse_csa_settings(pos, &settings); |
| if (ret) |
| @@ -2809,29 +2808,8 @@ static int hostapd_ctrl_iface_chan_switch(struct hostapd_iface *iface, |
| iface, bandwidth, settings.freq_params.center_freq2); |
| |
| if (dfs_range) { |
| - ret = ieee80211_freq_to_chan(settings.freq_params.freq, &chan); |
| - if (ret == NUM_HOSTAPD_MODES) { |
| - wpa_printf(MSG_ERROR, |
| - "Failed to get channel for (freq=%d, sec_channel_offset=%d, bw=%d)", |
| - settings.freq_params.freq, |
| - settings.freq_params.sec_channel_offset, |
| - settings.freq_params.bandwidth); |
| - return -1; |
| - } |
| - |
| - settings.freq_params.channel = chan; |
| - |
| - wpa_printf(MSG_DEBUG, |
| - "DFS/CAC to (channel=%u, freq=%d, sec_channel_offset=%d, bw=%d, center_freq1=%d)", |
| - settings.freq_params.channel, |
| - settings.freq_params.freq, |
| - settings.freq_params.sec_channel_offset, |
| - settings.freq_params.bandwidth, |
| - settings.freq_params.center_freq1); |
| - |
| - /* Perform CAC and switch channel */ |
| - hostapd_switch_channel_fallback(iface, &settings.freq_params); |
| - return 0; |
| + settings.cs_count = 5; |
| + settings.block_tx = 1; |
| } |
| |
| for (i = 0; i < iface->num_bss; i++) { |
| diff --git a/src/ap/beacon.c b/src/ap/beacon.c |
| index 02f4f87..f9c4924 100644 |
| --- a/src/ap/beacon.c |
| +++ b/src/ap/beacon.c |
| @@ -2027,6 +2027,11 @@ static int __ieee802_11_set_beacon(struct hostapd_data *hapd) |
| return -1; |
| } |
| |
| + if (iface->cac_started) { |
| + wpa_printf(MSG_DEBUG, "Ignore set beacons during CAC period"); |
| + return 0; |
| + } |
| + |
| hapd->beacon_set_done = 1; |
| |
| if (ieee802_11_build_ap_params(hapd, ¶ms) < 0) |
| diff --git a/src/ap/dfs.c b/src/ap/dfs.c |
| index 80d3605..012050c 100644 |
| --- a/src/ap/dfs.c |
| +++ b/src/ap/dfs.c |
| @@ -1255,10 +1255,10 @@ int hostapd_dfs_complete_cac(struct hostapd_iface *iface, int success, int freq, |
| * another radio. |
| */ |
| if (iface->state != HAPD_IFACE_ENABLED && |
| - hostapd_is_dfs_chan_available(iface)) { |
| + hostapd_is_dfs_chan_available(iface)) |
| hostapd_setup_interface_complete(iface, 0); |
| - iface->cac_started = 0; |
| - } |
| + |
| + iface->cac_started = 0; |
| |
| /* |
| * When background radar is enabled but the CAC completion |
| @@ -1272,6 +1272,13 @@ int hostapd_dfs_complete_cac(struct hostapd_iface *iface, int success, int freq, |
| } else if (hostapd_dfs_is_background_event(iface, freq)) { |
| iface->radar_background.cac_started = 0; |
| hostpad_dfs_update_background_chain(iface); |
| + } else { |
| + int i; |
| + |
| + iface->cac_started = 0; |
| + /* Clear all CSA flags once channel switch to DFS channel fails */ |
| + for (i = 0; i < iface->num_bss; i++) |
| + iface->bss[i]->csa_in_progress = 0; |
| } |
| |
| return 0; |
| @@ -1646,7 +1653,8 @@ int hostapd_dfs_start_cac(struct hostapd_iface *iface, int freq, |
| } else { |
| /* This is called when the driver indicates that an offloaded |
| * DFS has started CAC. */ |
| - hostapd_set_state(iface, HAPD_IFACE_DFS); |
| + if (iface->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD) |
| + hostapd_set_state(iface, HAPD_IFACE_DFS); |
| iface->cac_started = 1; |
| } |
| /* TODO: How to check CAC time for ETSI weather channels? */ |
| diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c |
| index 01ceb79..dd477fd 100644 |
| --- a/src/ap/ieee802_11.c |
| +++ b/src/ap/ieee802_11.c |
| @@ -6352,6 +6352,11 @@ int ieee802_11_mgmt(struct hostapd_data *hapd, const u8 *buf, size_t len, |
| return 1; |
| } |
| |
| + if (hapd->iface->cac_started) { |
| + wpa_printf(MSG_DEBUG, "MGMT: Ignore management frame during CAC"); |
| + return 1; |
| + } |
| + |
| if (stype == WLAN_FC_STYPE_PROBE_REQ) { |
| handle_probe_req(hapd, mgmt, len, ssi_signal); |
| return 1; |
| -- |
| 2.18.0 |
| |