developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 1 | From 7782f39aa86e067030ee8277c7942423c6e64389 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 10:51:47 +0800 |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 4 | Subject: [PATCH 17/54] mtk: hostapd: Add sta-assisted DFS state update |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 5 | mechanism |
| 6 | |
| 7 | Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 8 | --- |
| 9 | src/ap/dfs.c | 20 ++++++++++++++++++++ |
| 10 | src/ap/dfs.h | 3 +++ |
| 11 | src/ap/drv_callbacks.c | 28 ++++++++++++++++++++++++++++ |
| 12 | src/common/wpa_ctrl.h | 1 + |
| 13 | src/drivers/driver.h | 14 ++++++++++++++ |
| 14 | src/drivers/driver_nl80211_event.c | 6 ++++++ |
| 15 | src/drivers/nl80211_copy.h | 6 ++++++ |
| 16 | 7 files changed, 78 insertions(+) |
| 17 | |
| 18 | diff --git a/src/ap/dfs.c b/src/ap/dfs.c |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 19 | index cfc350879..9d002cfad 100644 |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 20 | --- a/src/ap/dfs.c |
| 21 | +++ b/src/ap/dfs.c |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 22 | @@ -1513,6 +1513,26 @@ int hostapd_dfs_nop_finished(struct hostapd_iface *iface, int freq, |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 23 | } |
| 24 | |
| 25 | |
| 26 | +int hostapd_dfs_sta_update_state(struct hostapd_iface *iface, int freq, |
| 27 | + int ht_enabled, int chan_offset, int chan_width, |
| 28 | + int cf1, int cf2, u32 state) |
| 29 | +{ |
| 30 | + wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_STA_UPDATE |
| 31 | + "freq=%d ht_enabled=%d chan_offset=%d chan_width=%d cf1=%d cf2=%d state=%s", |
| 32 | + freq, ht_enabled, chan_offset, chan_width, cf1, cf2, |
| 33 | + (state == HOSTAPD_CHAN_DFS_AVAILABLE) ? "available" : "usable"); |
| 34 | + |
| 35 | + /* Proceed only if DFS is not offloaded to the driver */ |
| 36 | + if (iface->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD) |
| 37 | + return 0; |
| 38 | + |
| 39 | + set_dfs_state(iface, freq, ht_enabled, chan_offset, chan_width, |
| 40 | + cf1, cf2, state); |
| 41 | + |
| 42 | + return 0; |
| 43 | +} |
| 44 | + |
| 45 | + |
| 46 | int hostapd_is_dfs_required(struct hostapd_iface *iface) |
| 47 | { |
| 48 | int n_chans, n_chans1, start_chan_idx, start_chan_idx1, res; |
| 49 | diff --git a/src/ap/dfs.h b/src/ap/dfs.h |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 50 | index c2556d2d9..25ba29ca1 100644 |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 51 | --- a/src/ap/dfs.h |
| 52 | +++ b/src/ap/dfs.h |
| 53 | @@ -30,6 +30,9 @@ int hostapd_dfs_radar_detected(struct hostapd_iface *iface, int freq, |
| 54 | int hostapd_dfs_nop_finished(struct hostapd_iface *iface, int freq, |
| 55 | int ht_enabled, |
| 56 | int chan_offset, int chan_width, int cf1, int cf2); |
| 57 | +int hostapd_dfs_sta_update_state(struct hostapd_iface *iface, int freq, |
| 58 | + int ht_enabled, int chan_offset, int chan_width, |
| 59 | + int cf1, int cf2, u32 state); |
| 60 | int hostapd_is_dfs_required(struct hostapd_iface *iface); |
| 61 | int hostapd_is_dfs_chan_available(struct hostapd_iface *iface); |
| 62 | int hostapd_dfs_start_cac(struct hostapd_iface *iface, int freq, |
| 63 | diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 64 | index f6093c11c..e7f1f19ce 100644 |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 65 | --- a/src/ap/drv_callbacks.c |
| 66 | +++ b/src/ap/drv_callbacks.c |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 67 | @@ -2086,6 +2086,24 @@ static void hostapd_event_dfs_cac_started(struct hostapd_data *hapd, |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 68 | radar->cf1, radar->cf2); |
| 69 | } |
| 70 | |
| 71 | +static void hostapd_event_dfs_sta_cac_skipped(struct hostapd_data *hapd, |
| 72 | + struct dfs_event *radar) |
| 73 | +{ |
| 74 | + wpa_printf(MSG_DEBUG, "DFS CAC skipped (by STA) on %d MHz", radar->freq); |
| 75 | + hostapd_dfs_sta_update_state(hapd->iface, radar->freq, radar->ht_enabled, |
| 76 | + radar->chan_offset, radar->chan_width, |
| 77 | + radar->cf1, radar->cf2, HOSTAPD_CHAN_DFS_AVAILABLE); |
| 78 | +} |
| 79 | + |
| 80 | +static void hostapd_event_dfs_sta_cac_expired(struct hostapd_data *hapd, |
| 81 | + struct dfs_event *radar) |
| 82 | +{ |
| 83 | + wpa_printf(MSG_DEBUG, "DFS CAC expired (by STA) on %d MHz", radar->freq); |
| 84 | + hostapd_dfs_sta_update_state(hapd->iface, radar->freq, radar->ht_enabled, |
| 85 | + radar->chan_offset, radar->chan_width, |
| 86 | + radar->cf1, radar->cf2, HOSTAPD_CHAN_DFS_USABLE); |
| 87 | +} |
| 88 | + |
| 89 | #endif /* NEED_AP_MLME */ |
| 90 | |
| 91 | |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 92 | @@ -2407,6 +2425,16 @@ void hostapd_wpa_event(void *ctx, enum wpa_event_type event, |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 93 | break; |
| 94 | hostapd_event_dfs_nop_finished(hapd, &data->dfs_event); |
| 95 | break; |
| 96 | + case EVENT_DFS_STA_CAC_SKIPPED: |
| 97 | + if (!data) |
| 98 | + break; |
| 99 | + hostapd_event_dfs_sta_cac_skipped(hapd, &data->dfs_event); |
| 100 | + break; |
| 101 | + case EVENT_DFS_STA_CAC_EXPIRED: |
| 102 | + if (!data) |
| 103 | + break; |
| 104 | + hostapd_event_dfs_sta_cac_expired(hapd, &data->dfs_event); |
| 105 | + break; |
| 106 | case EVENT_CHANNEL_LIST_CHANGED: |
| 107 | /* channel list changed (regulatory?), update channel list */ |
| 108 | /* TODO: check this. hostapd_get_hw_features() initializes |
| 109 | diff --git a/src/common/wpa_ctrl.h b/src/common/wpa_ctrl.h |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 110 | index 416e0d6a8..62f042e05 100644 |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 111 | --- a/src/common/wpa_ctrl.h |
| 112 | +++ b/src/common/wpa_ctrl.h |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 113 | @@ -374,6 +374,7 @@ extern "C" { |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 114 | #define DFS_EVENT_CAC_COMPLETED "DFS-CAC-COMPLETED " |
| 115 | #define DFS_EVENT_NOP_FINISHED "DFS-NOP-FINISHED " |
| 116 | #define DFS_EVENT_PRE_CAC_EXPIRED "DFS-PRE-CAC-EXPIRED " |
| 117 | +#define DFS_EVENT_STA_UPDATE "DFS-STA-UPDATE " |
| 118 | |
| 119 | #define AP_CSA_FINISHED "AP-CSA-FINISHED " |
| 120 | |
| 121 | diff --git a/src/drivers/driver.h b/src/drivers/driver.h |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 122 | index 577c34c07..24ab656fa 100644 |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 123 | --- a/src/drivers/driver.h |
| 124 | +++ b/src/drivers/driver.h |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 125 | @@ -5785,6 +5785,20 @@ enum wpa_event_type { |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 126 | * EVENT_LINK_RECONFIG - Notification that AP links removed |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 127 | */ |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 128 | EVENT_LINK_RECONFIG, |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 129 | + |
| 130 | + /** |
| 131 | + * EVENT_DFS_STA_CAC_SKIPPED - Notification that CAC has been skipped |
| 132 | + * |
| 133 | + * The channel in the notification is now marked as available. |
| 134 | + */ |
| 135 | + EVENT_DFS_STA_CAC_SKIPPED, |
| 136 | + |
| 137 | + /** |
| 138 | + * EVENT_DFS_STA_CAC_EXPIRED - Notification that CAC has expired |
| 139 | + * |
| 140 | + * The channel in the notification is now marked as usable. |
| 141 | + */ |
| 142 | + EVENT_DFS_STA_CAC_EXPIRED, |
| 143 | }; |
| 144 | |
| 145 | |
| 146 | diff --git a/src/drivers/driver_nl80211_event.c b/src/drivers/driver_nl80211_event.c |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 147 | index 701c32e7b..63d44017c 100644 |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 148 | --- a/src/drivers/driver_nl80211_event.c |
| 149 | +++ b/src/drivers/driver_nl80211_event.c |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 150 | @@ -2514,6 +2514,12 @@ static void nl80211_radar_event(struct wpa_driver_nl80211_data *drv, |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 151 | case NL80211_RADAR_CAC_STARTED: |
| 152 | wpa_supplicant_event(drv->ctx, EVENT_DFS_CAC_STARTED, &data); |
| 153 | break; |
| 154 | + case NL80211_RADAR_STA_CAC_SKIPPED: |
| 155 | + wpa_supplicant_event(drv->ctx, EVENT_DFS_STA_CAC_SKIPPED, &data); |
| 156 | + break; |
| 157 | + case NL80211_RADAR_STA_CAC_EXPIRED: |
| 158 | + wpa_supplicant_event(drv->ctx, EVENT_DFS_STA_CAC_EXPIRED, &data); |
| 159 | + break; |
| 160 | default: |
| 161 | wpa_printf(MSG_DEBUG, "nl80211: Unknown radar event %d " |
| 162 | "received", event_type); |
| 163 | diff --git a/src/drivers/nl80211_copy.h b/src/drivers/nl80211_copy.h |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame] | 164 | index 82860ae32..225864b94 100644 |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 165 | --- a/src/drivers/nl80211_copy.h |
| 166 | +++ b/src/drivers/nl80211_copy.h |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 167 | @@ -6643,6 +6643,10 @@ enum nl80211_smps_mode { |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 168 | * applicable for ETSI dfs domain where pre-CAC is valid for ever. |
| 169 | * @NL80211_RADAR_CAC_STARTED: Channel Availability Check has been started, |
| 170 | * should be generated by HW if NL80211_EXT_FEATURE_DFS_OFFLOAD is enabled. |
| 171 | + * @NL80211_RADAR_STA_CAC_SKIPPED: STA set the DFS state to available |
| 172 | + * when receiving CSA/assoc resp |
| 173 | + * @NL80211_RADAR_STA_CAC_EXPIRED: STA set the DFS state to usable |
| 174 | + * when STA is disconnected or leaving the channel |
| 175 | */ |
| 176 | enum nl80211_radar_event { |
| 177 | NL80211_RADAR_DETECTED, |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 178 | @@ -6651,6 +6655,8 @@ enum nl80211_radar_event { |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 179 | NL80211_RADAR_NOP_FINISHED, |
| 180 | NL80211_RADAR_PRE_CAC_EXPIRED, |
| 181 | NL80211_RADAR_CAC_STARTED, |
| 182 | + NL80211_RADAR_STA_CAC_SKIPPED, |
| 183 | + NL80211_RADAR_STA_CAC_EXPIRED, |
| 184 | }; |
| 185 | |
| 186 | /** |
| 187 | -- |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 188 | 2.18.0 |
developer | 6ce3b61 | 2023-03-02 20:22:29 +0800 | [diff] [blame] | 189 | |