Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 1 | /* |
| 2 | * ACS - Automatic Channel Selection module |
| 3 | * Copyright (c) 2011, Atheros Communications |
| 4 | * Copyright (c) 2013, Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * This software may be distributed under the terms of the BSD license. |
| 7 | * See README for more details. |
| 8 | */ |
| 9 | |
| 10 | #include "utils/includes.h" |
| 11 | #include <math.h> |
| 12 | |
| 13 | #include "utils/common.h" |
| 14 | #include "utils/list.h" |
| 15 | #include "common/ieee802_11_defs.h" |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 16 | #include "common/wpa_ctrl.h" |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 17 | #include "drivers/driver.h" |
| 18 | #include "hostapd.h" |
| 19 | #include "ap_drv_ops.h" |
| 20 | #include "ap_config.h" |
| 21 | #include "hw_features.h" |
| 22 | #include "acs.h" |
| 23 | |
| 24 | /* |
| 25 | * Automatic Channel Selection |
| 26 | * =========================== |
| 27 | * |
| 28 | * More info at |
| 29 | * ------------ |
| 30 | * http://wireless.kernel.org/en/users/Documentation/acs |
| 31 | * |
| 32 | * How to use |
| 33 | * ---------- |
| 34 | * - make sure you have CONFIG_ACS=y in hostapd's .config |
| 35 | * - use channel=0 or channel=acs to enable ACS |
| 36 | * |
| 37 | * How does it work |
| 38 | * ---------------- |
| 39 | * 1. passive scans are used to collect survey data |
| 40 | * (it is assumed that scan trigger collection of survey data in driver) |
| 41 | * 2. interference factor is calculated for each channel |
| 42 | * 3. ideal channel is picked depending on channel width by using adjacent |
| 43 | * channel interference factors |
| 44 | * |
| 45 | * Known limitations |
| 46 | * ----------------- |
| 47 | * - Current implementation depends heavily on the amount of time willing to |
| 48 | * spend gathering survey data during hostapd startup. Short traffic bursts |
| 49 | * may be missed and a suboptimal channel may be picked. |
| 50 | * - Ideal channel may end up overlapping a channel with 40 MHz intolerant BSS |
| 51 | * |
| 52 | * Todo / Ideas |
| 53 | * ------------ |
| 54 | * - implement other interference computation methods |
| 55 | * - BSS/RSSI based |
| 56 | * - spectral scan based |
| 57 | * (should be possibly to hook this up with current ACS scans) |
| 58 | * - add wpa_supplicant support (for P2P) |
| 59 | * - collect a histogram of interference over time allowing more educated |
| 60 | * guess about an ideal channel (perhaps CSA could be used to migrate AP to a |
| 61 | * new "better" channel while running) |
| 62 | * - include neighboring BSS scan to avoid conflicts with 40 MHz intolerant BSSs |
| 63 | * when choosing the ideal channel |
| 64 | * |
| 65 | * Survey interference factor implementation details |
| 66 | * ------------------------------------------------- |
| 67 | * Generic interference_factor in struct hostapd_channel_data is used. |
| 68 | * |
| 69 | * The survey interference factor is defined as the ratio of the |
| 70 | * observed busy time over the time we spent on the channel, |
| 71 | * this value is then amplified by the observed noise floor on |
| 72 | * the channel in comparison to the lowest noise floor observed |
| 73 | * on the entire band. |
| 74 | * |
| 75 | * This corresponds to: |
| 76 | * --- |
| 77 | * (busy time - tx time) / (active time - tx time) * 2^(chan_nf + band_min_nf) |
| 78 | * --- |
| 79 | * |
| 80 | * The coefficient of 2 reflects the way power in "far-field" |
| 81 | * radiation decreases as the square of distance from the antenna [1]. |
| 82 | * What this does is it decreases the observed busy time ratio if the |
| 83 | * noise observed was low but increases it if the noise was high, |
| 84 | * proportionally to the way "far field" radiation changes over |
| 85 | * distance. |
| 86 | * |
| 87 | * If channel busy time is not available the fallback is to use channel RX time. |
| 88 | * |
| 89 | * Since noise floor is in dBm it is necessary to convert it into Watts so that |
| 90 | * combined channel interference (e.g., HT40, which uses two channels) can be |
| 91 | * calculated easily. |
| 92 | * --- |
| 93 | * (busy time - tx time) / (active time - tx time) * |
| 94 | * 2^(10^(chan_nf/10) + 10^(band_min_nf/10)) |
| 95 | * --- |
| 96 | * |
| 97 | * However to account for cases where busy/rx time is 0 (channel load is then |
| 98 | * 0%) channel noise floor signal power is combined into the equation so a |
| 99 | * channel with lower noise floor is preferred. The equation becomes: |
| 100 | * --- |
| 101 | * 10^(chan_nf/5) + (busy time - tx time) / (active time - tx time) * |
| 102 | * 2^(10^(chan_nf/10) + 10^(band_min_nf/10)) |
| 103 | * --- |
| 104 | * |
| 105 | * All this "interference factor" is purely subjective and only time |
| 106 | * will tell how usable this is. By using the minimum noise floor we |
| 107 | * remove any possible issues due to card calibration. The computation |
| 108 | * of the interference factor then is dependent on what the card itself |
| 109 | * picks up as the minimum noise, not an actual real possible card |
| 110 | * noise value. |
| 111 | * |
| 112 | * Total interference computation details |
| 113 | * -------------------------------------- |
| 114 | * The above channel interference factor is calculated with no respect to |
| 115 | * target operational bandwidth. |
| 116 | * |
| 117 | * To find an ideal channel the above data is combined by taking into account |
| 118 | * the target operational bandwidth and selected band. E.g., on 2.4 GHz channels |
| 119 | * overlap with 20 MHz bandwidth, but there is no overlap for 20 MHz bandwidth |
| 120 | * on 5 GHz. |
| 121 | * |
| 122 | * Each valid and possible channel spec (i.e., channel + width) is taken and its |
| 123 | * interference factor is computed by summing up interferences of each channel |
| 124 | * it overlaps. The one with least total interference is picked up. |
| 125 | * |
| 126 | * Note: This implies base channel interference factor must be non-negative |
| 127 | * allowing easy summing up. |
| 128 | * |
| 129 | * Example ACS analysis printout |
| 130 | * ----------------------------- |
| 131 | * |
| 132 | * ACS: Trying survey-based ACS |
| 133 | * ACS: Survey analysis for channel 1 (2412 MHz) |
| 134 | * ACS: 1: min_nf=-113 interference_factor=0.0802469 nf=-113 time=162 busy=0 rx=13 |
| 135 | * ACS: 2: min_nf=-113 interference_factor=0.0745342 nf=-113 time=161 busy=0 rx=12 |
| 136 | * ACS: 3: min_nf=-113 interference_factor=0.0679012 nf=-113 time=162 busy=0 rx=11 |
| 137 | * ACS: 4: min_nf=-113 interference_factor=0.0310559 nf=-113 time=161 busy=0 rx=5 |
| 138 | * ACS: 5: min_nf=-113 interference_factor=0.0248447 nf=-113 time=161 busy=0 rx=4 |
| 139 | * ACS: * interference factor average: 0.0557166 |
| 140 | * ACS: Survey analysis for channel 2 (2417 MHz) |
| 141 | * ACS: 1: min_nf=-113 interference_factor=0.0185185 nf=-113 time=162 busy=0 rx=3 |
| 142 | * ACS: 2: min_nf=-113 interference_factor=0.0246914 nf=-113 time=162 busy=0 rx=4 |
| 143 | * ACS: 3: min_nf=-113 interference_factor=0.037037 nf=-113 time=162 busy=0 rx=6 |
| 144 | * ACS: 4: min_nf=-113 interference_factor=0.149068 nf=-113 time=161 busy=0 rx=24 |
| 145 | * ACS: 5: min_nf=-113 interference_factor=0.0248447 nf=-113 time=161 busy=0 rx=4 |
| 146 | * ACS: * interference factor average: 0.050832 |
| 147 | * ACS: Survey analysis for channel 3 (2422 MHz) |
| 148 | * ACS: 1: min_nf=-113 interference_factor=2.51189e-23 nf=-113 time=162 busy=0 rx=0 |
| 149 | * ACS: 2: min_nf=-113 interference_factor=0.0185185 nf=-113 time=162 busy=0 rx=3 |
| 150 | * ACS: 3: min_nf=-113 interference_factor=0.0186335 nf=-113 time=161 busy=0 rx=3 |
| 151 | * ACS: 4: min_nf=-113 interference_factor=0.0186335 nf=-113 time=161 busy=0 rx=3 |
| 152 | * ACS: 5: min_nf=-113 interference_factor=0.0186335 nf=-113 time=161 busy=0 rx=3 |
| 153 | * ACS: * interference factor average: 0.0148838 |
| 154 | * ACS: Survey analysis for channel 4 (2427 MHz) |
| 155 | * ACS: 1: min_nf=-114 interference_factor=1.58489e-23 nf=-114 time=162 busy=0 rx=0 |
| 156 | * ACS: 2: min_nf=-114 interference_factor=0.0555556 nf=-114 time=162 busy=0 rx=9 |
| 157 | * ACS: 3: min_nf=-114 interference_factor=1.58489e-23 nf=-114 time=161 busy=0 rx=0 |
| 158 | * ACS: 4: min_nf=-114 interference_factor=0.0186335 nf=-114 time=161 busy=0 rx=3 |
| 159 | * ACS: 5: min_nf=-114 interference_factor=0.00621118 nf=-114 time=161 busy=0 rx=1 |
| 160 | * ACS: * interference factor average: 0.0160801 |
| 161 | * ACS: Survey analysis for channel 5 (2432 MHz) |
| 162 | * ACS: 1: min_nf=-114 interference_factor=0.409938 nf=-113 time=161 busy=0 rx=66 |
| 163 | * ACS: 2: min_nf=-114 interference_factor=0.0432099 nf=-113 time=162 busy=0 rx=7 |
| 164 | * ACS: 3: min_nf=-114 interference_factor=0.0124224 nf=-113 time=161 busy=0 rx=2 |
| 165 | * ACS: 4: min_nf=-114 interference_factor=0.677019 nf=-113 time=161 busy=0 rx=109 |
| 166 | * ACS: 5: min_nf=-114 interference_factor=0.0186335 nf=-114 time=161 busy=0 rx=3 |
| 167 | * ACS: * interference factor average: 0.232244 |
| 168 | * ACS: Survey analysis for channel 6 (2437 MHz) |
| 169 | * ACS: 1: min_nf=-113 interference_factor=0.552795 nf=-113 time=161 busy=0 rx=89 |
| 170 | * ACS: 2: min_nf=-113 interference_factor=0.0807453 nf=-112 time=161 busy=0 rx=13 |
| 171 | * ACS: 3: min_nf=-113 interference_factor=0.0310559 nf=-113 time=161 busy=0 rx=5 |
| 172 | * ACS: 4: min_nf=-113 interference_factor=0.434783 nf=-112 time=161 busy=0 rx=70 |
| 173 | * ACS: 5: min_nf=-113 interference_factor=0.0621118 nf=-113 time=161 busy=0 rx=10 |
| 174 | * ACS: * interference factor average: 0.232298 |
| 175 | * ACS: Survey analysis for channel 7 (2442 MHz) |
| 176 | * ACS: 1: min_nf=-113 interference_factor=0.440994 nf=-112 time=161 busy=0 rx=71 |
| 177 | * ACS: 2: min_nf=-113 interference_factor=0.385093 nf=-113 time=161 busy=0 rx=62 |
| 178 | * ACS: 3: min_nf=-113 interference_factor=0.0372671 nf=-113 time=161 busy=0 rx=6 |
| 179 | * ACS: 4: min_nf=-113 interference_factor=0.0372671 nf=-113 time=161 busy=0 rx=6 |
| 180 | * ACS: 5: min_nf=-113 interference_factor=0.0745342 nf=-113 time=161 busy=0 rx=12 |
| 181 | * ACS: * interference factor average: 0.195031 |
| 182 | * ACS: Survey analysis for channel 8 (2447 MHz) |
| 183 | * ACS: 1: min_nf=-114 interference_factor=0.0496894 nf=-112 time=161 busy=0 rx=8 |
| 184 | * ACS: 2: min_nf=-114 interference_factor=0.0496894 nf=-114 time=161 busy=0 rx=8 |
| 185 | * ACS: 3: min_nf=-114 interference_factor=0.0372671 nf=-113 time=161 busy=0 rx=6 |
| 186 | * ACS: 4: min_nf=-114 interference_factor=0.12963 nf=-113 time=162 busy=0 rx=21 |
| 187 | * ACS: 5: min_nf=-114 interference_factor=0.166667 nf=-114 time=162 busy=0 rx=27 |
| 188 | * ACS: * interference factor average: 0.0865885 |
| 189 | * ACS: Survey analysis for channel 9 (2452 MHz) |
| 190 | * ACS: 1: min_nf=-114 interference_factor=0.0124224 nf=-114 time=161 busy=0 rx=2 |
| 191 | * ACS: 2: min_nf=-114 interference_factor=0.0310559 nf=-114 time=161 busy=0 rx=5 |
| 192 | * ACS: 3: min_nf=-114 interference_factor=1.58489e-23 nf=-114 time=161 busy=0 rx=0 |
| 193 | * ACS: 4: min_nf=-114 interference_factor=0.00617284 nf=-114 time=162 busy=0 rx=1 |
| 194 | * ACS: 5: min_nf=-114 interference_factor=1.58489e-23 nf=-114 time=162 busy=0 rx=0 |
| 195 | * ACS: * interference factor average: 0.00993022 |
| 196 | * ACS: Survey analysis for channel 10 (2457 MHz) |
| 197 | * ACS: 1: min_nf=-114 interference_factor=0.00621118 nf=-114 time=161 busy=0 rx=1 |
| 198 | * ACS: 2: min_nf=-114 interference_factor=0.00621118 nf=-114 time=161 busy=0 rx=1 |
| 199 | * ACS: 3: min_nf=-114 interference_factor=0.00621118 nf=-114 time=161 busy=0 rx=1 |
| 200 | * ACS: 4: min_nf=-114 interference_factor=0.0493827 nf=-114 time=162 busy=0 rx=8 |
| 201 | * ACS: 5: min_nf=-114 interference_factor=1.58489e-23 nf=-114 time=162 busy=0 rx=0 |
| 202 | * ACS: * interference factor average: 0.0136033 |
| 203 | * ACS: Survey analysis for channel 11 (2462 MHz) |
| 204 | * ACS: 1: min_nf=-114 interference_factor=1.58489e-23 nf=-114 time=161 busy=0 rx=0 |
| 205 | * ACS: 2: min_nf=-114 interference_factor=2.51189e-23 nf=-113 time=161 busy=0 rx=0 |
| 206 | * ACS: 3: min_nf=-114 interference_factor=2.51189e-23 nf=-113 time=161 busy=0 rx=0 |
| 207 | * ACS: 4: min_nf=-114 interference_factor=0.0432099 nf=-114 time=162 busy=0 rx=7 |
| 208 | * ACS: 5: min_nf=-114 interference_factor=0.0925926 nf=-114 time=162 busy=0 rx=15 |
| 209 | * ACS: * interference factor average: 0.0271605 |
| 210 | * ACS: Survey analysis for channel 12 (2467 MHz) |
| 211 | * ACS: 1: min_nf=-114 interference_factor=0.0621118 nf=-113 time=161 busy=0 rx=10 |
| 212 | * ACS: 2: min_nf=-114 interference_factor=0.00621118 nf=-114 time=161 busy=0 rx=1 |
| 213 | * ACS: 3: min_nf=-114 interference_factor=2.51189e-23 nf=-113 time=162 busy=0 rx=0 |
| 214 | * ACS: 4: min_nf=-114 interference_factor=2.51189e-23 nf=-113 time=162 busy=0 rx=0 |
| 215 | * ACS: 5: min_nf=-114 interference_factor=0.00617284 nf=-113 time=162 busy=0 rx=1 |
| 216 | * ACS: * interference factor average: 0.0148992 |
| 217 | * ACS: Survey analysis for channel 13 (2472 MHz) |
| 218 | * ACS: 1: min_nf=-114 interference_factor=0.0745342 nf=-114 time=161 busy=0 rx=12 |
| 219 | * ACS: 2: min_nf=-114 interference_factor=0.0555556 nf=-114 time=162 busy=0 rx=9 |
| 220 | * ACS: 3: min_nf=-114 interference_factor=1.58489e-23 nf=-114 time=162 busy=0 rx=0 |
| 221 | * ACS: 4: min_nf=-114 interference_factor=1.58489e-23 nf=-114 time=162 busy=0 rx=0 |
| 222 | * ACS: 5: min_nf=-114 interference_factor=1.58489e-23 nf=-114 time=162 busy=0 rx=0 |
| 223 | * ACS: * interference factor average: 0.0260179 |
| 224 | * ACS: Survey analysis for selected bandwidth 20MHz |
| 225 | * ACS: * channel 1: total interference = 0.121432 |
| 226 | * ACS: * channel 2: total interference = 0.137512 |
| 227 | * ACS: * channel 3: total interference = 0.369757 |
| 228 | * ACS: * channel 4: total interference = 0.546338 |
| 229 | * ACS: * channel 5: total interference = 0.690538 |
| 230 | * ACS: * channel 6: total interference = 0.762242 |
| 231 | * ACS: * channel 7: total interference = 0.756092 |
| 232 | * ACS: * channel 8: total interference = 0.537451 |
| 233 | * ACS: * channel 9: total interference = 0.332313 |
| 234 | * ACS: * channel 10: total interference = 0.152182 |
| 235 | * ACS: * channel 11: total interference = 0.0916111 |
| 236 | * ACS: * channel 12: total interference = 0.0816809 |
| 237 | * ACS: * channel 13: total interference = 0.0680776 |
| 238 | * ACS: Ideal channel is 13 (2472 MHz) with total interference factor of 0.0680776 |
| 239 | * |
| 240 | * [1] http://en.wikipedia.org/wiki/Near_and_far_field |
| 241 | */ |
| 242 | |
| 243 | |
| 244 | static int acs_request_scan(struct hostapd_iface *iface); |
| 245 | |
| 246 | |
| 247 | static void acs_clean_chan_surveys(struct hostapd_channel_data *chan) |
| 248 | { |
| 249 | struct freq_survey *survey, *tmp; |
| 250 | |
| 251 | if (dl_list_empty(&chan->survey_list)) |
| 252 | return; |
| 253 | |
| 254 | dl_list_for_each_safe(survey, tmp, &chan->survey_list, |
| 255 | struct freq_survey, list) { |
| 256 | dl_list_del(&survey->list); |
| 257 | os_free(survey); |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | |
| 262 | static void acs_cleanup(struct hostapd_iface *iface) |
| 263 | { |
| 264 | int i; |
| 265 | struct hostapd_channel_data *chan; |
| 266 | |
| 267 | for (i = 0; i < iface->current_mode->num_channels; i++) { |
| 268 | chan = &iface->current_mode->channels[i]; |
| 269 | |
| 270 | if (chan->flag & HOSTAPD_CHAN_SURVEY_LIST_INITIALIZED) |
| 271 | acs_clean_chan_surveys(chan); |
| 272 | |
| 273 | dl_list_init(&chan->survey_list); |
| 274 | chan->flag |= HOSTAPD_CHAN_SURVEY_LIST_INITIALIZED; |
| 275 | chan->min_nf = 0; |
| 276 | } |
| 277 | |
| 278 | iface->chans_surveyed = 0; |
| 279 | iface->acs_num_completed_scans = 0; |
| 280 | } |
| 281 | |
| 282 | |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 283 | static void acs_fail(struct hostapd_iface *iface) |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 284 | { |
| 285 | wpa_printf(MSG_ERROR, "ACS: Failed to start"); |
| 286 | acs_cleanup(iface); |
Dmitry Shmidt | 2ac5f60 | 2014-03-07 10:08:21 -0800 | [diff] [blame] | 287 | hostapd_disable_iface(iface); |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | |
| 291 | static long double |
| 292 | acs_survey_interference_factor(struct freq_survey *survey, s8 min_nf) |
| 293 | { |
| 294 | long double factor, busy, total; |
| 295 | |
| 296 | if (survey->filled & SURVEY_HAS_CHAN_TIME_BUSY) |
| 297 | busy = survey->channel_time_busy; |
| 298 | else if (survey->filled & SURVEY_HAS_CHAN_TIME_RX) |
| 299 | busy = survey->channel_time_rx; |
| 300 | else { |
| 301 | /* This shouldn't really happen as survey data is checked in |
| 302 | * acs_sanity_check() */ |
| 303 | wpa_printf(MSG_ERROR, "ACS: Survey data missing"); |
| 304 | return 0; |
| 305 | } |
| 306 | |
| 307 | total = survey->channel_time; |
| 308 | |
| 309 | if (survey->filled & SURVEY_HAS_CHAN_TIME_TX) { |
| 310 | busy -= survey->channel_time_tx; |
| 311 | total -= survey->channel_time_tx; |
| 312 | } |
| 313 | |
| 314 | /* TODO: figure out the best multiplier for noise floor base */ |
| 315 | factor = pow(10, survey->nf / 5.0L) + |
| 316 | (busy / total) * |
| 317 | pow(2, pow(10, (long double) survey->nf / 10.0L) - |
| 318 | pow(10, (long double) min_nf / 10.0L)); |
| 319 | |
| 320 | return factor; |
| 321 | } |
| 322 | |
| 323 | |
| 324 | static void |
| 325 | acs_survey_chan_interference_factor(struct hostapd_iface *iface, |
| 326 | struct hostapd_channel_data *chan) |
| 327 | { |
| 328 | struct freq_survey *survey; |
| 329 | unsigned int i = 0; |
| 330 | long double int_factor = 0; |
| 331 | |
| 332 | if (dl_list_empty(&chan->survey_list)) |
| 333 | return; |
| 334 | |
| 335 | if (chan->flag & HOSTAPD_CHAN_DISABLED) |
| 336 | return; |
| 337 | |
| 338 | chan->interference_factor = 0; |
| 339 | |
| 340 | dl_list_for_each(survey, &chan->survey_list, struct freq_survey, list) |
| 341 | { |
| 342 | int_factor = acs_survey_interference_factor(survey, |
| 343 | iface->lowest_nf); |
| 344 | chan->interference_factor += int_factor; |
| 345 | wpa_printf(MSG_DEBUG, "ACS: %d: min_nf=%d interference_factor=%Lg nf=%d time=%lu busy=%lu rx=%lu", |
| 346 | ++i, chan->min_nf, int_factor, |
| 347 | survey->nf, (unsigned long) survey->channel_time, |
| 348 | (unsigned long) survey->channel_time_busy, |
| 349 | (unsigned long) survey->channel_time_rx); |
| 350 | } |
| 351 | |
| 352 | chan->interference_factor = chan->interference_factor / |
| 353 | dl_list_len(&chan->survey_list); |
| 354 | } |
| 355 | |
| 356 | |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 357 | static int acs_usable_ht40_chan(struct hostapd_channel_data *chan) |
| 358 | { |
| 359 | const int allowed[] = { 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, |
| 360 | 157, 184, 192 }; |
| 361 | unsigned int i; |
| 362 | |
Dmitry Shmidt | 68d0e3e | 2013-10-28 17:59:21 -0700 | [diff] [blame] | 363 | for (i = 0; i < ARRAY_SIZE(allowed); i++) |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 364 | if (chan->chan == allowed[i]) |
| 365 | return 1; |
| 366 | |
| 367 | return 0; |
| 368 | } |
| 369 | |
| 370 | |
Dmitry Shmidt | a38abf9 | 2014-03-06 13:38:44 -0800 | [diff] [blame] | 371 | static int acs_usable_vht80_chan(struct hostapd_channel_data *chan) |
| 372 | { |
| 373 | const int allowed[] = { 36, 52, 100, 116, 132, 149 }; |
| 374 | unsigned int i; |
| 375 | |
| 376 | for (i = 0; i < ARRAY_SIZE(allowed); i++) |
| 377 | if (chan->chan == allowed[i]) |
| 378 | return 1; |
| 379 | |
| 380 | return 0; |
| 381 | } |
| 382 | |
| 383 | |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 384 | static int acs_survey_is_sufficient(struct freq_survey *survey) |
| 385 | { |
| 386 | if (!(survey->filled & SURVEY_HAS_NF)) { |
| 387 | wpa_printf(MSG_ERROR, "ACS: Survey is missing noise floor"); |
| 388 | return 0; |
| 389 | } |
| 390 | |
| 391 | if (!(survey->filled & SURVEY_HAS_CHAN_TIME)) { |
| 392 | wpa_printf(MSG_ERROR, "ACS: Survey is missing channel time"); |
| 393 | return 0; |
| 394 | } |
| 395 | |
| 396 | if (!(survey->filled & SURVEY_HAS_CHAN_TIME_BUSY) && |
| 397 | !(survey->filled & SURVEY_HAS_CHAN_TIME_RX)) { |
| 398 | wpa_printf(MSG_ERROR, "ACS: Survey is missing RX and busy time (at least one is required)"); |
| 399 | return 0; |
| 400 | } |
| 401 | |
| 402 | return 1; |
| 403 | } |
| 404 | |
| 405 | |
Dmitry Shmidt | 4ce9c87 | 2013-10-24 11:08:13 -0700 | [diff] [blame] | 406 | static int acs_survey_list_is_sufficient(struct hostapd_channel_data *chan) |
| 407 | { |
| 408 | struct freq_survey *survey; |
| 409 | |
| 410 | dl_list_for_each(survey, &chan->survey_list, struct freq_survey, list) |
| 411 | { |
| 412 | if (!acs_survey_is_sufficient(survey)) { |
| 413 | wpa_printf(MSG_ERROR, "ACS: Channel %d has insufficient survey data", |
| 414 | chan->chan); |
| 415 | return 0; |
| 416 | } |
| 417 | } |
| 418 | |
| 419 | return 1; |
| 420 | |
| 421 | } |
| 422 | |
| 423 | |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 424 | static int acs_surveys_are_sufficient(struct hostapd_iface *iface) |
| 425 | { |
| 426 | int i; |
| 427 | struct hostapd_channel_data *chan; |
Dmitry Shmidt | 4ce9c87 | 2013-10-24 11:08:13 -0700 | [diff] [blame] | 428 | int valid = 0; |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 429 | |
| 430 | for (i = 0; i < iface->current_mode->num_channels; i++) { |
| 431 | chan = &iface->current_mode->channels[i]; |
| 432 | if (chan->flag & HOSTAPD_CHAN_DISABLED) |
| 433 | continue; |
| 434 | |
Dmitry Shmidt | 4ce9c87 | 2013-10-24 11:08:13 -0700 | [diff] [blame] | 435 | if (!acs_survey_list_is_sufficient(chan)) |
| 436 | continue; |
| 437 | |
| 438 | valid++; |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 439 | } |
| 440 | |
Dmitry Shmidt | 4ce9c87 | 2013-10-24 11:08:13 -0700 | [diff] [blame] | 441 | /* We need at least survey data for one channel */ |
| 442 | return !!valid; |
| 443 | } |
| 444 | |
| 445 | |
| 446 | static int acs_usable_chan(struct hostapd_channel_data *chan) |
| 447 | { |
| 448 | if (dl_list_empty(&chan->survey_list)) |
| 449 | return 0; |
| 450 | if (chan->flag & HOSTAPD_CHAN_DISABLED) |
| 451 | return 0; |
| 452 | if (!acs_survey_list_is_sufficient(chan)) |
| 453 | return 0; |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 454 | return 1; |
| 455 | } |
| 456 | |
| 457 | |
| 458 | static void acs_survey_all_chans_intereference_factor( |
| 459 | struct hostapd_iface *iface) |
| 460 | { |
| 461 | int i; |
| 462 | struct hostapd_channel_data *chan; |
| 463 | |
| 464 | for (i = 0; i < iface->current_mode->num_channels; i++) { |
| 465 | chan = &iface->current_mode->channels[i]; |
| 466 | |
| 467 | if (!acs_usable_chan(chan)) |
| 468 | continue; |
| 469 | |
| 470 | wpa_printf(MSG_DEBUG, "ACS: Survey analysis for channel %d (%d MHz)", |
| 471 | chan->chan, chan->freq); |
| 472 | |
| 473 | acs_survey_chan_interference_factor(iface, chan); |
| 474 | |
| 475 | wpa_printf(MSG_DEBUG, "ACS: * interference factor average: %Lg", |
| 476 | chan->interference_factor); |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | |
| 481 | static struct hostapd_channel_data *acs_find_chan(struct hostapd_iface *iface, |
| 482 | int freq) |
| 483 | { |
| 484 | struct hostapd_channel_data *chan; |
| 485 | int i; |
| 486 | |
| 487 | for (i = 0; i < iface->current_mode->num_channels; i++) { |
| 488 | chan = &iface->current_mode->channels[i]; |
| 489 | |
Dmitry Shmidt | 4ce9c87 | 2013-10-24 11:08:13 -0700 | [diff] [blame] | 490 | if (chan->flag & HOSTAPD_CHAN_DISABLED) |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 491 | continue; |
| 492 | |
| 493 | if (chan->freq == freq) |
| 494 | return chan; |
| 495 | } |
| 496 | |
| 497 | return NULL; |
| 498 | } |
| 499 | |
| 500 | |
| 501 | /* |
| 502 | * At this point it's assumed chan->interface_factor has been computed. |
| 503 | * This function should be reusable regardless of interference computation |
| 504 | * option (survey, BSS, spectral, ...). chan->interference factor must be |
| 505 | * summable (i.e., must be always greater than zero). |
| 506 | */ |
| 507 | static struct hostapd_channel_data * |
| 508 | acs_find_ideal_chan(struct hostapd_iface *iface) |
| 509 | { |
Dmitry Shmidt | 4ce9c87 | 2013-10-24 11:08:13 -0700 | [diff] [blame] | 510 | struct hostapd_channel_data *chan, *adj_chan, *ideal_chan = NULL, |
| 511 | *rand_chan = NULL; |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 512 | long double factor, ideal_factor = 0; |
| 513 | int i, j; |
| 514 | int n_chans = 1; |
| 515 | |
| 516 | /* TODO: HT40- support */ |
| 517 | |
| 518 | if (iface->conf->ieee80211n && |
| 519 | iface->conf->secondary_channel == -1) { |
| 520 | wpa_printf(MSG_ERROR, "ACS: HT40- is not supported yet. Please try HT40+"); |
| 521 | return NULL; |
| 522 | } |
| 523 | |
| 524 | if (iface->conf->ieee80211n && |
| 525 | iface->conf->secondary_channel) |
| 526 | n_chans = 2; |
| 527 | |
| 528 | if (iface->conf->ieee80211ac && |
| 529 | iface->conf->vht_oper_chwidth == 1) |
| 530 | n_chans = 4; |
| 531 | |
| 532 | /* TODO: VHT80+80, VHT160. Update acs_adjust_vht_center_freq() too. */ |
| 533 | |
| 534 | wpa_printf(MSG_DEBUG, "ACS: Survey analysis for selected bandwidth %d MHz", |
| 535 | n_chans == 1 ? 20 : |
| 536 | n_chans == 2 ? 40 : |
| 537 | n_chans == 4 ? 80 : |
| 538 | -1); |
| 539 | |
| 540 | for (i = 0; i < iface->current_mode->num_channels; i++) { |
| 541 | chan = &iface->current_mode->channels[i]; |
| 542 | |
Dmitry Shmidt | 4ce9c87 | 2013-10-24 11:08:13 -0700 | [diff] [blame] | 543 | if (chan->flag & HOSTAPD_CHAN_DISABLED) |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 544 | continue; |
| 545 | |
Dmitry Shmidt | 4ce9c87 | 2013-10-24 11:08:13 -0700 | [diff] [blame] | 546 | |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 547 | /* HT40 on 5 GHz has a limited set of primary channels as per |
| 548 | * 11n Annex J */ |
| 549 | if (iface->current_mode->mode == HOSTAPD_MODE_IEEE80211A && |
| 550 | iface->conf->ieee80211n && |
| 551 | iface->conf->secondary_channel && |
| 552 | !acs_usable_ht40_chan(chan)) { |
| 553 | wpa_printf(MSG_DEBUG, "ACS: Channel %d: not allowed as primary channel for HT40", |
| 554 | chan->chan); |
| 555 | continue; |
| 556 | } |
| 557 | |
Dmitry Shmidt | a38abf9 | 2014-03-06 13:38:44 -0800 | [diff] [blame] | 558 | if (iface->current_mode->mode == HOSTAPD_MODE_IEEE80211A && |
| 559 | iface->conf->ieee80211ac && |
| 560 | iface->conf->vht_oper_chwidth == 1 && |
| 561 | !acs_usable_vht80_chan(chan)) { |
| 562 | wpa_printf(MSG_DEBUG, "ACS: Channel %d: not allowed as primary channel for VHT80", |
| 563 | chan->chan); |
| 564 | continue; |
| 565 | } |
| 566 | |
Dmitry Shmidt | 4ce9c87 | 2013-10-24 11:08:13 -0700 | [diff] [blame] | 567 | factor = 0; |
| 568 | if (acs_usable_chan(chan)) |
| 569 | factor = chan->interference_factor; |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 570 | |
| 571 | for (j = 1; j < n_chans; j++) { |
| 572 | adj_chan = acs_find_chan(iface, chan->freq + (j * 20)); |
| 573 | if (!adj_chan) |
| 574 | break; |
| 575 | |
Dmitry Shmidt | 4ce9c87 | 2013-10-24 11:08:13 -0700 | [diff] [blame] | 576 | if (acs_usable_chan(adj_chan)) |
| 577 | factor += adj_chan->interference_factor; |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 578 | } |
| 579 | |
| 580 | if (j != n_chans) { |
| 581 | wpa_printf(MSG_DEBUG, "ACS: Channel %d: not enough bandwidth", |
| 582 | chan->chan); |
| 583 | continue; |
| 584 | } |
| 585 | |
| 586 | /* 2.4 GHz has overlapping 20 MHz channels. Include adjacent |
| 587 | * channel interference factor. */ |
| 588 | if (iface->current_mode->mode == HOSTAPD_MODE_IEEE80211B || |
| 589 | iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G) { |
| 590 | for (j = 0; j < n_chans; j++) { |
| 591 | /* TODO: perhaps a multiplier should be used |
| 592 | * here? */ |
| 593 | |
| 594 | adj_chan = acs_find_chan(iface, chan->freq + |
| 595 | (j * 20) - 5); |
Dmitry Shmidt | 4ce9c87 | 2013-10-24 11:08:13 -0700 | [diff] [blame] | 596 | if (adj_chan && acs_usable_chan(adj_chan)) |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 597 | factor += adj_chan->interference_factor; |
| 598 | |
| 599 | adj_chan = acs_find_chan(iface, chan->freq + |
| 600 | (j * 20) - 10); |
Dmitry Shmidt | 4ce9c87 | 2013-10-24 11:08:13 -0700 | [diff] [blame] | 601 | if (adj_chan && acs_usable_chan(adj_chan)) |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 602 | factor += adj_chan->interference_factor; |
| 603 | |
| 604 | adj_chan = acs_find_chan(iface, chan->freq + |
| 605 | (j * 20) + 5); |
Dmitry Shmidt | 4ce9c87 | 2013-10-24 11:08:13 -0700 | [diff] [blame] | 606 | if (adj_chan && acs_usable_chan(adj_chan)) |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 607 | factor += adj_chan->interference_factor; |
| 608 | |
| 609 | adj_chan = acs_find_chan(iface, chan->freq + |
| 610 | (j * 20) + 10); |
Dmitry Shmidt | 4ce9c87 | 2013-10-24 11:08:13 -0700 | [diff] [blame] | 611 | if (adj_chan && acs_usable_chan(adj_chan)) |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 612 | factor += adj_chan->interference_factor; |
| 613 | } |
| 614 | } |
| 615 | |
| 616 | wpa_printf(MSG_DEBUG, "ACS: * channel %d: total interference = %Lg", |
| 617 | chan->chan, factor); |
| 618 | |
Dmitry Shmidt | 4ce9c87 | 2013-10-24 11:08:13 -0700 | [diff] [blame] | 619 | if (acs_usable_chan(chan) && |
| 620 | (!ideal_chan || factor < ideal_factor)) { |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 621 | ideal_factor = factor; |
| 622 | ideal_chan = chan; |
| 623 | } |
Dmitry Shmidt | 4ce9c87 | 2013-10-24 11:08:13 -0700 | [diff] [blame] | 624 | |
| 625 | /* This channel would at least be usable */ |
| 626 | if (!rand_chan) |
| 627 | rand_chan = chan; |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 628 | } |
| 629 | |
Dmitry Shmidt | 4ce9c87 | 2013-10-24 11:08:13 -0700 | [diff] [blame] | 630 | if (ideal_chan) { |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 631 | wpa_printf(MSG_DEBUG, "ACS: Ideal channel is %d (%d MHz) with total interference factor of %Lg", |
| 632 | ideal_chan->chan, ideal_chan->freq, ideal_factor); |
Dmitry Shmidt | 4ce9c87 | 2013-10-24 11:08:13 -0700 | [diff] [blame] | 633 | return ideal_chan; |
| 634 | } |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 635 | |
Dmitry Shmidt | 4ce9c87 | 2013-10-24 11:08:13 -0700 | [diff] [blame] | 636 | return rand_chan; |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 637 | } |
| 638 | |
| 639 | |
| 640 | static void acs_adjust_vht_center_freq(struct hostapd_iface *iface) |
| 641 | { |
| 642 | wpa_printf(MSG_DEBUG, "ACS: Adjusting VHT center frequency"); |
| 643 | |
| 644 | switch (iface->conf->vht_oper_chwidth) { |
| 645 | case VHT_CHANWIDTH_USE_HT: |
| 646 | iface->conf->vht_oper_centr_freq_seg0_idx = |
| 647 | iface->conf->channel + 2; |
| 648 | break; |
| 649 | case VHT_CHANWIDTH_80MHZ: |
| 650 | iface->conf->vht_oper_centr_freq_seg0_idx = |
| 651 | iface->conf->channel + 6; |
| 652 | break; |
| 653 | default: |
| 654 | /* TODO: How can this be calculated? Adjust |
| 655 | * acs_find_ideal_chan() */ |
| 656 | wpa_printf(MSG_INFO, "ACS: Only VHT20/40/80 is supported now"); |
| 657 | break; |
| 658 | } |
| 659 | } |
| 660 | |
| 661 | |
| 662 | static int acs_study_survey_based(struct hostapd_iface *iface) |
| 663 | { |
| 664 | wpa_printf(MSG_DEBUG, "ACS: Trying survey-based ACS"); |
| 665 | |
| 666 | if (!iface->chans_surveyed) { |
| 667 | wpa_printf(MSG_ERROR, "ACS: Unable to collect survey data"); |
| 668 | return -1; |
| 669 | } |
| 670 | |
| 671 | if (!acs_surveys_are_sufficient(iface)) { |
| 672 | wpa_printf(MSG_ERROR, "ACS: Surveys have insufficient data"); |
| 673 | return -1; |
| 674 | } |
| 675 | |
| 676 | acs_survey_all_chans_intereference_factor(iface); |
| 677 | return 0; |
| 678 | } |
| 679 | |
| 680 | |
| 681 | static int acs_study_options(struct hostapd_iface *iface) |
| 682 | { |
| 683 | int err; |
| 684 | |
| 685 | err = acs_study_survey_based(iface); |
| 686 | if (err == 0) |
| 687 | return 0; |
| 688 | |
| 689 | /* TODO: If no surveys are available/sufficient this is a good |
| 690 | * place to fallback to BSS-based ACS */ |
| 691 | |
| 692 | return -1; |
| 693 | } |
| 694 | |
| 695 | |
| 696 | static void acs_study(struct hostapd_iface *iface) |
| 697 | { |
| 698 | struct hostapd_channel_data *ideal_chan; |
| 699 | int err; |
| 700 | |
| 701 | err = acs_study_options(iface); |
| 702 | if (err < 0) { |
| 703 | wpa_printf(MSG_ERROR, "ACS: All study options have failed"); |
| 704 | goto fail; |
| 705 | } |
| 706 | |
| 707 | ideal_chan = acs_find_ideal_chan(iface); |
| 708 | if (!ideal_chan) { |
| 709 | wpa_printf(MSG_ERROR, "ACS: Failed to compute ideal channel"); |
Dmitry Shmidt | 4ce9c87 | 2013-10-24 11:08:13 -0700 | [diff] [blame] | 710 | err = -1; |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 711 | goto fail; |
| 712 | } |
| 713 | |
| 714 | iface->conf->channel = ideal_chan->chan; |
| 715 | |
| 716 | if (iface->conf->ieee80211ac) |
| 717 | acs_adjust_vht_center_freq(iface); |
| 718 | |
Dmitry Shmidt | 4ce9c87 | 2013-10-24 11:08:13 -0700 | [diff] [blame] | 719 | err = 0; |
| 720 | fail: |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 721 | /* |
| 722 | * hostapd_setup_interface_complete() will return -1 on failure, |
| 723 | * 0 on success and 0 is HOSTAPD_CHAN_VALID :) |
| 724 | */ |
Dmitry Shmidt | 4ce9c87 | 2013-10-24 11:08:13 -0700 | [diff] [blame] | 725 | if (hostapd_acs_completed(iface, err) == HOSTAPD_CHAN_VALID) { |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 726 | acs_cleanup(iface); |
| 727 | return; |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 728 | } |
| 729 | |
Dmitry Shmidt | 4ce9c87 | 2013-10-24 11:08:13 -0700 | [diff] [blame] | 730 | /* This can possibly happen if channel parameters (secondary |
| 731 | * channel, center frequencies) are misconfigured */ |
| 732 | wpa_printf(MSG_ERROR, "ACS: Possibly channel configuration is invalid, please report this along with your config file."); |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 733 | acs_fail(iface); |
| 734 | } |
| 735 | |
| 736 | |
| 737 | static void acs_scan_complete(struct hostapd_iface *iface) |
| 738 | { |
| 739 | int err; |
| 740 | |
| 741 | iface->scan_cb = NULL; |
| 742 | |
| 743 | wpa_printf(MSG_DEBUG, "ACS: Using survey based algorithm (acs_num_scans=%d)", |
| 744 | iface->conf->acs_num_scans); |
| 745 | |
| 746 | err = hostapd_drv_get_survey(iface->bss[0], 0); |
| 747 | if (err) { |
| 748 | wpa_printf(MSG_ERROR, "ACS: Failed to get survey data"); |
| 749 | acs_fail(iface); |
| 750 | } |
| 751 | |
| 752 | if (++iface->acs_num_completed_scans < iface->conf->acs_num_scans) { |
| 753 | err = acs_request_scan(iface); |
| 754 | if (err) { |
| 755 | wpa_printf(MSG_ERROR, "ACS: Failed to request scan"); |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 756 | goto fail; |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 757 | } |
| 758 | |
| 759 | return; |
| 760 | } |
| 761 | |
| 762 | acs_study(iface); |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 763 | return; |
| 764 | fail: |
| 765 | hostapd_acs_completed(iface, 1); |
| 766 | acs_fail(iface); |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 767 | } |
| 768 | |
| 769 | |
| 770 | static int acs_request_scan(struct hostapd_iface *iface) |
| 771 | { |
| 772 | struct wpa_driver_scan_params params; |
| 773 | struct hostapd_channel_data *chan; |
| 774 | int i, *freq; |
| 775 | |
| 776 | os_memset(¶ms, 0, sizeof(params)); |
| 777 | params.freqs = os_calloc(iface->current_mode->num_channels + 1, |
| 778 | sizeof(params.freqs[0])); |
| 779 | if (params.freqs == NULL) |
| 780 | return -1; |
| 781 | |
| 782 | freq = params.freqs; |
| 783 | for (i = 0; i < iface->current_mode->num_channels; i++) { |
| 784 | chan = &iface->current_mode->channels[i]; |
| 785 | if (chan->flag & HOSTAPD_CHAN_DISABLED) |
| 786 | continue; |
| 787 | |
| 788 | *freq++ = chan->freq; |
| 789 | } |
| 790 | *freq = 0; |
| 791 | |
| 792 | iface->scan_cb = acs_scan_complete; |
| 793 | |
| 794 | wpa_printf(MSG_DEBUG, "ACS: Scanning %d / %d", |
| 795 | iface->acs_num_completed_scans + 1, |
| 796 | iface->conf->acs_num_scans); |
| 797 | |
| 798 | if (hostapd_driver_scan(iface->bss[0], ¶ms) < 0) { |
| 799 | wpa_printf(MSG_ERROR, "ACS: Failed to request initial scan"); |
| 800 | acs_cleanup(iface); |
| 801 | return -1; |
| 802 | } |
| 803 | |
| 804 | os_free(params.freqs); |
| 805 | return 0; |
| 806 | } |
| 807 | |
| 808 | |
| 809 | enum hostapd_chan_status acs_init(struct hostapd_iface *iface) |
| 810 | { |
| 811 | int err; |
| 812 | |
| 813 | wpa_printf(MSG_INFO, "ACS: Automatic channel selection started, this may take a bit"); |
| 814 | |
| 815 | acs_cleanup(iface); |
| 816 | |
| 817 | err = acs_request_scan(iface); |
| 818 | if (err < 0) |
| 819 | return HOSTAPD_CHAN_INVALID; |
| 820 | |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 821 | hostapd_set_state(iface, HAPD_IFACE_ACS); |
| 822 | wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, ACS_EVENT_STARTED); |
| 823 | |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 824 | return HOSTAPD_CHAN_ACS; |
| 825 | } |