developer | 2fd555a | 2023-07-25 05:48:15 +0800 | [diff] [blame] | 1 | From 041170e5089b0ec71074ebb0474ac2972e8a2323 Mon Sep 17 00:00:00 2001 |
developer | 9a3c8b3 | 2023-02-20 17:37:56 +0800 | [diff] [blame] | 2 | From: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 3 | Date: Mon, 20 Feb 2023 10:51:47 +0800 |
developer | 2fd555a | 2023-07-25 05:48:15 +0800 | [diff] [blame] | 4 | Subject: [PATCH 18/35] hostapd: mtk: Add sta-assisted DFS state update |
developer | 9a3c8b3 | 2023-02-20 17:37:56 +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 |
| 19 | index 307a4e1..d082fe0 100644 |
| 20 | --- a/src/ap/dfs.c |
| 21 | +++ b/src/ap/dfs.c |
| 22 | @@ -1503,6 +1503,26 @@ int hostapd_dfs_nop_finished(struct hostapd_iface *iface, int freq, |
| 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 |
| 50 | index c2556d2..25ba29c 100644 |
| 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 |
| 64 | index 09783cb..275f6b3 100644 |
| 65 | --- a/src/ap/drv_callbacks.c |
| 66 | +++ b/src/ap/drv_callbacks.c |
| 67 | @@ -1790,6 +1790,24 @@ static void hostapd_event_dfs_cac_started(struct hostapd_data *hapd, |
| 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 | |
| 92 | @@ -2064,6 +2082,16 @@ void hostapd_wpa_event(void *ctx, enum wpa_event_type event, |
| 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 |
| 110 | index 3435084..79c8a82 100644 |
| 111 | --- a/src/common/wpa_ctrl.h |
| 112 | +++ b/src/common/wpa_ctrl.h |
| 113 | @@ -360,6 +360,7 @@ extern "C" { |
| 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 | 81939a5 | 2023-03-25 15:31:11 +0800 | [diff] [blame] | 122 | index 3e034d7..82daef0 100644 |
developer | 9a3c8b3 | 2023-02-20 17:37:56 +0800 | [diff] [blame] | 123 | --- a/src/drivers/driver.h |
| 124 | +++ b/src/drivers/driver.h |
| 125 | @@ -5317,6 +5317,20 @@ enum wpa_event_type { |
| 126 | * EVENT_CCA_NOTIFY - Notification that CCA has completed |
| 127 | */ |
| 128 | EVENT_CCA_NOTIFY, |
| 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 |
| 147 | index 73bb7a4..ee922ac 100644 |
| 148 | --- a/src/drivers/driver_nl80211_event.c |
| 149 | +++ b/src/drivers/driver_nl80211_event.c |
| 150 | @@ -1854,6 +1854,12 @@ static void nl80211_radar_event(struct wpa_driver_nl80211_data *drv, |
| 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 |
| 164 | index c4bf3ad..0937752 100644 |
| 165 | --- a/src/drivers/nl80211_copy.h |
| 166 | +++ b/src/drivers/nl80211_copy.h |
| 167 | @@ -6431,6 +6431,10 @@ enum nl80211_smps_mode { |
| 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, |
| 178 | @@ -6439,6 +6443,8 @@ enum nl80211_radar_event { |
| 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 | -- |
| 188 | 2.18.0 |
| 189 | |