Lines Matching +full:switch +full:- +full:freq +full:- +full:select
2 * ACS - Automatic Channel Selection module
31 * ------------
35 * ----------
36 * - make sure you have CONFIG_ACS=y in hostapd's .config
37 * - use channel=0 or channel=acs to enable ACS
40 * ----------------
48 * -----------------
49 * - Current implementation depends heavily on the amount of time willing to
52 * - Ideal channel may end up overlapping a channel with 40 MHz intolerant BSS
55 * ------------
56 * - implement other interference computation methods
57 * - BSS/RSSI based
58 * - spectral scan based
60 * - add wpa_supplicant support (for P2P)
61 * - collect a histogram of interference over time allowing more educated
64 * - include neighboring BSS scan to avoid conflicts with 40 MHz intolerant BSSs
68 * -------------------------------------------------
78 * ---
79 * (busy time - tx time) / (active time - tx time) * 2^(chan_nf - band_min_nf)
80 * ---
82 * The coefficient of 2 reflects the way power in "far-field"
94 * ---
95 * (busy time - tx time) / (active time - tx time) *
96 * 2^(10^(chan_nf/10) - 10^(band_min_nf/10))
97 * ---
102 * ---
103 * 10^(chan_nf/5) + (busy time - tx time) / (active time - tx time) *
104 * 2^(10^(chan_nf/10) - 10^(band_min_nf/10))
105 * ---
115 * --------------------------------------
128 * Note: This implies base channel interference factor must be non-negative
132 * -----------------------------
134 * ACS: Trying survey-based ACS
136 * ACS: 1: min_nf=-113 interference_factor=0.0802469 nf=-113 time=162 busy=0 rx=13
137 * ACS: 2: min_nf=-113 interference_factor=0.0745342 nf=-113 time=161 busy=0 rx=12
138 * ACS: 3: min_nf=-113 interference_factor=0.0679012 nf=-113 time=162 busy=0 rx=11
139 * ACS: 4: min_nf=-113 interference_factor=0.0310559 nf=-113 time=161 busy=0 rx=5
140 * ACS: 5: min_nf=-113 interference_factor=0.0248447 nf=-113 time=161 busy=0 rx=4
143 * ACS: 1: min_nf=-113 interference_factor=0.0185185 nf=-113 time=162 busy=0 rx=3
144 * ACS: 2: min_nf=-113 interference_factor=0.0246914 nf=-113 time=162 busy=0 rx=4
145 * ACS: 3: min_nf=-113 interference_factor=0.037037 nf=-113 time=162 busy=0 rx=6
146 * ACS: 4: min_nf=-113 interference_factor=0.149068 nf=-113 time=161 busy=0 rx=24
147 * ACS: 5: min_nf=-113 interference_factor=0.0248447 nf=-113 time=161 busy=0 rx=4
150 * ACS: 1: min_nf=-113 interference_factor=2.51189e-23 nf=-113 time=162 busy=0 rx=0
151 * ACS: 2: min_nf=-113 interference_factor=0.0185185 nf=-113 time=162 busy=0 rx=3
152 * ACS: 3: min_nf=-113 interference_factor=0.0186335 nf=-113 time=161 busy=0 rx=3
153 * ACS: 4: min_nf=-113 interference_factor=0.0186335 nf=-113 time=161 busy=0 rx=3
154 * ACS: 5: min_nf=-113 interference_factor=0.0186335 nf=-113 time=161 busy=0 rx=3
157 * ACS: 1: min_nf=-114 interference_factor=1.58489e-23 nf=-114 time=162 busy=0 rx=0
158 * ACS: 2: min_nf=-114 interference_factor=0.0555556 nf=-114 time=162 busy=0 rx=9
159 * ACS: 3: min_nf=-114 interference_factor=1.58489e-23 nf=-114 time=161 busy=0 rx=0
160 * ACS: 4: min_nf=-114 interference_factor=0.0186335 nf=-114 time=161 busy=0 rx=3
161 * ACS: 5: min_nf=-114 interference_factor=0.00621118 nf=-114 time=161 busy=0 rx=1
164 * ACS: 1: min_nf=-114 interference_factor=0.409938 nf=-113 time=161 busy=0 rx=66
165 * ACS: 2: min_nf=-114 interference_factor=0.0432099 nf=-113 time=162 busy=0 rx=7
166 * ACS: 3: min_nf=-114 interference_factor=0.0124224 nf=-113 time=161 busy=0 rx=2
167 * ACS: 4: min_nf=-114 interference_factor=0.677019 nf=-113 time=161 busy=0 rx=109
168 * ACS: 5: min_nf=-114 interference_factor=0.0186335 nf=-114 time=161 busy=0 rx=3
171 * ACS: 1: min_nf=-113 interference_factor=0.552795 nf=-113 time=161 busy=0 rx=89
172 * ACS: 2: min_nf=-113 interference_factor=0.0807453 nf=-112 time=161 busy=0 rx=13
173 * ACS: 3: min_nf=-113 interference_factor=0.0310559 nf=-113 time=161 busy=0 rx=5
174 * ACS: 4: min_nf=-113 interference_factor=0.434783 nf=-112 time=161 busy=0 rx=70
175 * ACS: 5: min_nf=-113 interference_factor=0.0621118 nf=-113 time=161 busy=0 rx=10
178 * ACS: 1: min_nf=-113 interference_factor=0.440994 nf=-112 time=161 busy=0 rx=71
179 * ACS: 2: min_nf=-113 interference_factor=0.385093 nf=-113 time=161 busy=0 rx=62
180 * ACS: 3: min_nf=-113 interference_factor=0.0372671 nf=-113 time=161 busy=0 rx=6
181 * ACS: 4: min_nf=-113 interference_factor=0.0372671 nf=-113 time=161 busy=0 rx=6
182 * ACS: 5: min_nf=-113 interference_factor=0.0745342 nf=-113 time=161 busy=0 rx=12
185 * ACS: 1: min_nf=-114 interference_factor=0.0496894 nf=-112 time=161 busy=0 rx=8
186 * ACS: 2: min_nf=-114 interference_factor=0.0496894 nf=-114 time=161 busy=0 rx=8
187 * ACS: 3: min_nf=-114 interference_factor=0.0372671 nf=-113 time=161 busy=0 rx=6
188 * ACS: 4: min_nf=-114 interference_factor=0.12963 nf=-113 time=162 busy=0 rx=21
189 * ACS: 5: min_nf=-114 interference_factor=0.166667 nf=-114 time=162 busy=0 rx=27
192 * ACS: 1: min_nf=-114 interference_factor=0.0124224 nf=-114 time=161 busy=0 rx=2
193 * ACS: 2: min_nf=-114 interference_factor=0.0310559 nf=-114 time=161 busy=0 rx=5
194 * ACS: 3: min_nf=-114 interference_factor=1.58489e-23 nf=-114 time=161 busy=0 rx=0
195 * ACS: 4: min_nf=-114 interference_factor=0.00617284 nf=-114 time=162 busy=0 rx=1
196 * ACS: 5: min_nf=-114 interference_factor=1.58489e-23 nf=-114 time=162 busy=0 rx=0
199 * ACS: 1: min_nf=-114 interference_factor=0.00621118 nf=-114 time=161 busy=0 rx=1
200 * ACS: 2: min_nf=-114 interference_factor=0.00621118 nf=-114 time=161 busy=0 rx=1
201 * ACS: 3: min_nf=-114 interference_factor=0.00621118 nf=-114 time=161 busy=0 rx=1
202 * ACS: 4: min_nf=-114 interference_factor=0.0493827 nf=-114 time=162 busy=0 rx=8
203 * ACS: 5: min_nf=-114 interference_factor=1.58489e-23 nf=-114 time=162 busy=0 rx=0
206 * ACS: 1: min_nf=-114 interference_factor=1.58489e-23 nf=-114 time=161 busy=0 rx=0
207 * ACS: 2: min_nf=-114 interference_factor=2.51189e-23 nf=-113 time=161 busy=0 rx=0
208 * ACS: 3: min_nf=-114 interference_factor=2.51189e-23 nf=-113 time=161 busy=0 rx=0
209 * ACS: 4: min_nf=-114 interference_factor=0.0432099 nf=-114 time=162 busy=0 rx=7
210 * ACS: 5: min_nf=-114 interference_factor=0.0925926 nf=-114 time=162 busy=0 rx=15
213 * ACS: 1: min_nf=-114 interference_factor=0.0621118 nf=-113 time=161 busy=0 rx=10
214 * ACS: 2: min_nf=-114 interference_factor=0.00621118 nf=-114 time=161 busy=0 rx=1
215 * ACS: 3: min_nf=-114 interference_factor=2.51189e-23 nf=-113 time=162 busy=0 rx=0
216 * ACS: 4: min_nf=-114 interference_factor=2.51189e-23 nf=-113 time=162 busy=0 rx=0
217 * ACS: 5: min_nf=-114 interference_factor=0.00617284 nf=-113 time=162 busy=0 rx=1
220 * ACS: 1: min_nf=-114 interference_factor=0.0745342 nf=-114 time=161 busy=0 rx=12
221 * ACS: 2: min_nf=-114 interference_factor=0.0555556 nf=-114 time=162 busy=0 rx=9
222 * ACS: 3: min_nf=-114 interference_factor=1.58489e-23 nf=-114 time=162 busy=0 rx=0
223 * ACS: 4: min_nf=-114 interference_factor=1.58489e-23 nf=-114 time=162 busy=0 rx=0
224 * ACS: 5: min_nf=-114 interference_factor=1.58489e-23 nf=-114 time=162 busy=0 rx=0
274 { 7035, 7055, 219 }, { 7075, 7095, 227}, { -1, -1, -1 }
284 { 6915, 6975, 199 }, { 6995, 7055, 215 }, { -1, -1, -1 }
290 { 6755, 6895, 175 }, { 6915, 7055, 207 }, { -1, -1, -1 }
294 { -1, -1, -1 }
298 { -1, -1, -1 }
318 if (dl_list_empty(&chan->survey_list)) in acs_clean_chan_surveys()
321 dl_list_for_each_safe(survey, tmp, &chan->survey_list, in acs_clean_chan_surveys()
323 dl_list_del(&survey->list); in acs_clean_chan_surveys()
334 for (i = 0; i < mode->num_channels; i++) { in acs_cleanup_mode()
335 chan = &mode->channels[i]; in acs_cleanup_mode()
337 if (chan->flag & HOSTAPD_CHAN_SURVEY_LIST_INITIALIZED) in acs_cleanup_mode()
340 dl_list_init(&chan->survey_list); in acs_cleanup_mode()
341 chan->flag |= HOSTAPD_CHAN_SURVEY_LIST_INITIALIZED; in acs_cleanup_mode()
342 chan->min_nf = 0; in acs_cleanup_mode()
343 chan->punct_bitmap = 0; in acs_cleanup_mode()
352 for (i = 0; i < iface->num_hw_features; i++) in acs_cleanup()
353 acs_cleanup_mode(&iface->hw_features[i]); in acs_cleanup()
355 iface->chans_surveyed = 0; in acs_cleanup()
356 iface->acs_num_completed_scans = 0; in acs_cleanup()
357 iface->acs_num_retries = 0; in acs_cleanup()
375 if (survey->filled & SURVEY_HAS_CHAN_TIME_BUSY) in acs_survey_interference_factor()
376 busy = survey->channel_time_busy; in acs_survey_interference_factor()
377 else if (survey->filled & SURVEY_HAS_CHAN_TIME_RX) in acs_survey_interference_factor()
378 busy = survey->channel_time_rx; in acs_survey_interference_factor()
384 total = survey->channel_time; in acs_survey_interference_factor()
386 if (survey->filled & SURVEY_HAS_CHAN_TIME_TX) { in acs_survey_interference_factor()
387 busy -= survey->channel_time_tx; in acs_survey_interference_factor()
388 total -= survey->channel_time_tx; in acs_survey_interference_factor()
392 factor = pow(10, survey->nf / 5.0L) + in acs_survey_interference_factor()
394 pow(2, pow(10, (long double) survey->nf / 10.0L) - in acs_survey_interference_factor()
410 if (dl_list_empty(&chan->survey_list) || in acs_survey_chan_interference_factor()
411 (chan->flag & HOSTAPD_CHAN_DISABLED)) in acs_survey_chan_interference_factor()
414 chan->interference_factor = 0; in acs_survey_chan_interference_factor()
416 dl_list_for_each(survey, &chan->survey_list, struct freq_survey, list) in acs_survey_chan_interference_factor()
427 iface->lowest_nf); in acs_survey_chan_interference_factor()
428 chan->interference_factor += int_factor; in acs_survey_chan_interference_factor()
430 i, chan->min_nf, int_factor, in acs_survey_chan_interference_factor()
431 survey->nf, (unsigned long) survey->channel_time, in acs_survey_chan_interference_factor()
432 (unsigned long) survey->channel_time_busy, in acs_survey_chan_interference_factor()
433 (unsigned long) survey->channel_time_rx); in acs_survey_chan_interference_factor()
437 chan->interference_factor /= count; in acs_survey_chan_interference_factor()
446 while (bw_desc[bw][i].first != -1) { in acs_usable_bw_chan()
447 if (chan->freq == bw_desc[bw][i].first) in acs_usable_bw_chan()
456 static int acs_get_bw_center_chan(int freq, enum bw_type bw) in acs_get_bw_center_chan() argument
460 while (bw_desc[bw][i].first != -1) { in acs_get_bw_center_chan()
461 if (freq >= bw_desc[bw][i].first && in acs_get_bw_center_chan()
462 freq <= bw_desc[bw][i].last) in acs_get_bw_center_chan()
473 if (!(survey->filled & SURVEY_HAS_NF)) { in acs_survey_is_sufficient()
475 "ACS: Survey for freq %d is missing noise floor", in acs_survey_is_sufficient()
476 survey->freq); in acs_survey_is_sufficient()
480 if (!(survey->filled & SURVEY_HAS_CHAN_TIME)) { in acs_survey_is_sufficient()
482 "ACS: Survey for freq %d is missing channel time", in acs_survey_is_sufficient()
483 survey->freq); in acs_survey_is_sufficient()
487 if (!(survey->filled & SURVEY_HAS_CHAN_TIME_BUSY) && in acs_survey_is_sufficient()
488 !(survey->filled & SURVEY_HAS_CHAN_TIME_RX)) { in acs_survey_is_sufficient()
490 "ACS: Survey for freq %d is missing RX and busy time (at least one is required)", in acs_survey_is_sufficient()
491 survey->freq); in acs_survey_is_sufficient()
502 int ret = -1; in acs_survey_list_is_sufficient()
504 dl_list_for_each(survey, &chan->survey_list, struct freq_survey, list) in acs_survey_list_is_sufficient()
513 if (ret == -1) in acs_survey_list_is_sufficient()
519 chan->chan); in acs_survey_list_is_sufficient()
531 for (i = 0; i < mode->num_channels; i++) { in acs_surveys_are_sufficient_mode()
532 chan = &mode->channels[i]; in acs_surveys_are_sufficient_mode()
533 if (!(chan->flag & HOSTAPD_CHAN_DISABLED) && in acs_surveys_are_sufficient_mode()
547 for (i = 0; i < iface->num_hw_features; i++) { in acs_surveys_are_sufficient()
548 mode = &iface->hw_features[i]; in acs_surveys_are_sufficient()
560 return !dl_list_empty(&chan->survey_list) && in acs_usable_chan()
561 !(chan->flag & HOSTAPD_CHAN_DISABLED) && in acs_usable_chan()
569 if (!iface->conf->acs_ch_list.num) in is_in_chanlist()
572 return freq_range_list_includes(&iface->conf->acs_ch_list, chan->chan); in is_in_chanlist()
579 if (!iface->conf->acs_freq_list.num) in is_in_freqlist()
582 return freq_range_list_includes(&iface->conf->acs_freq_list, in is_in_freqlist()
583 chan->freq); in is_in_freqlist()
593 for (i = 0; i < mode->num_channels; i++) { in acs_survey_mode_interference_factor()
594 chan = &mode->channels[i]; in acs_survey_mode_interference_factor()
599 if ((chan->flag & HOSTAPD_CHAN_RADAR) && in acs_survey_mode_interference_factor()
600 iface->conf->acs_exclude_dfs) in acs_survey_mode_interference_factor()
609 if (chan->max_tx_power < iface->conf->min_tx_power) in acs_survey_mode_interference_factor()
612 if ((chan->flag & HOSTAPD_CHAN_INDOOR_ONLY) && in acs_survey_mode_interference_factor()
613 iface->conf->country[2] == 0x4f) in acs_survey_mode_interference_factor()
617 chan->chan, chan->freq); in acs_survey_mode_interference_factor()
622 chan->interference_factor); in acs_survey_mode_interference_factor()
633 for (i = 0; i < iface->num_hw_features; i++) { in acs_survey_all_chans_interference_factor()
634 mode = &iface->hw_features[i]; in acs_survey_all_chans_interference_factor()
642 acs_find_chan_mode(struct hostapd_hw_modes *mode, int freq) in acs_find_chan_mode() argument
647 for (i = 0; i < mode->num_channels; i++) { in acs_find_chan_mode()
648 chan = &mode->channels[i]; in acs_find_chan_mode()
650 if (chan->flag & HOSTAPD_CHAN_DISABLED) in acs_find_chan_mode()
653 if (chan->freq == freq) in acs_find_chan_mode()
662 acs_find_mode(struct hostapd_iface *iface, int freq) in acs_find_mode() argument
668 for (i = 0; i < iface->num_hw_features; i++) { in acs_find_mode()
669 mode = &iface->hw_features[i]; in acs_find_mode()
671 chan = acs_find_chan_mode(mode, freq); in acs_find_mode()
673 return mode->mode; in acs_find_mode()
682 acs_find_chan(struct hostapd_iface *iface, int freq) in acs_find_chan() argument
688 for (i = 0; i < iface->num_hw_features; i++) { in acs_find_chan()
689 mode = &iface->hw_features[i]; in acs_find_chan()
691 chan = acs_find_chan_mode(mode, freq); in acs_find_chan()
724 * Select commonly used channels 1, 6, 11 by default even if a neighboring
740 struct hostapd_config *conf = iface->conf; in acs_update_puncturing_bitmap()
749 if (!conf->punct_acs_threshold || conf->punct_bitmap) in acs_update_puncturing_bitmap()
752 if (is_24ghz_mode(mode->mode) || bw < 80) in acs_update_puncturing_bitmap()
755 threshold = factor * conf->punct_acs_threshold / 100; in acs_update_puncturing_bitmap()
763 adj_freq = chan->freq + (i - index_primary) * 20; in acs_update_puncturing_bitmap()
765 adj_freq = chan->freq - (index_primary - i) * 20; in acs_update_puncturing_bitmap()
769 chan->punct_bitmap = 0; in acs_update_puncturing_bitmap()
776 if (adj_chan->interference_factor > threshold) in acs_update_puncturing_bitmap()
777 chan->punct_bitmap |= BIT(i); in acs_update_puncturing_bitmap()
780 if (!is_punct_bitmap_valid(bw, (chan->freq - first_chan->freq) / 20, in acs_update_puncturing_bitmap()
781 chan->punct_bitmap)) in acs_update_puncturing_bitmap()
782 chan->punct_bitmap = 0; in acs_update_puncturing_bitmap()
791 const char *bw320_str[] = { "320 MHz", "320 MHz-1", "320 MHz-2" }; in acs_usable_bw320_chan()
792 int conf_bw320_offset = hostapd_get_bw320_offset(iface->conf); in acs_usable_bw320_chan()
795 switch (conf_bw320_offset) { in acs_usable_bw320_chan()
817 chan->chan, bw320_str[conf_bw320_offset]); in acs_usable_bw320_chan()
841 if (is_24ghz_mode(mode->mode)) in acs_find_ideal_chan_mode()
842 secondary_channel = iface->conf->secondary_channel; in acs_find_ideal_chan_mode()
844 for (i = 0; i < mode->num_channels; i++) { in acs_find_ideal_chan_mode()
848 chan = &mode->channels[i]; in acs_find_ideal_chan_mode()
863 if ((chan->flag & HOSTAPD_CHAN_RADAR) && in acs_find_ideal_chan_mode()
864 iface->conf->acs_exclude_dfs) in acs_find_ideal_chan_mode()
873 if (chan->max_tx_power < iface->conf->min_tx_power) in acs_find_ideal_chan_mode()
876 if ((chan->flag & HOSTAPD_CHAN_INDOOR_ONLY) && in acs_find_ideal_chan_mode()
877 iface->conf->country[2] == 0x4f) in acs_find_ideal_chan_mode()
880 if (!chan_bw_allowed(chan, bw, secondary_channel != -1, 1)) { in acs_find_ideal_chan_mode()
883 chan->chan, bw); in acs_find_ideal_chan_mode()
889 if (mode->mode == HOSTAPD_MODE_IEEE80211A && in acs_find_ideal_chan_mode()
890 ((iface->conf->ieee80211n && in acs_find_ideal_chan_mode()
891 iface->conf->secondary_channel) || in acs_find_ideal_chan_mode()
892 is_6ghz_freq(chan->freq)) && in acs_find_ideal_chan_mode()
896 chan->chan); in acs_find_ideal_chan_mode()
900 if (mode->mode == HOSTAPD_MODE_IEEE80211A && in acs_find_ideal_chan_mode()
901 (iface->conf->ieee80211ac || iface->conf->ieee80211ax || in acs_find_ideal_chan_mode()
902 iface->conf->ieee80211be)) { in acs_find_ideal_chan_mode()
903 if (hostapd_get_oper_chwidth(iface->conf) == in acs_find_ideal_chan_mode()
908 chan->chan); in acs_find_ideal_chan_mode()
912 if (hostapd_get_oper_chwidth(iface->conf) == in acs_find_ideal_chan_mode()
917 chan->chan); in acs_find_ideal_chan_mode()
922 if (mode->mode == HOSTAPD_MODE_IEEE80211A && in acs_find_ideal_chan_mode()
923 iface->conf->ieee80211be) { in acs_find_ideal_chan_mode()
924 if (hostapd_get_oper_chwidth(iface->conf) == in acs_find_ideal_chan_mode()
933 factor = chan->interference_factor; in acs_find_ideal_chan_mode()
939 adj_chan = acs_find_chan(iface, chan->freq + in acs_find_ideal_chan_mode()
947 chan->chan, adj_chan->chan, bw); in acs_find_ideal_chan_mode()
954 factor += adj_chan->interference_factor; in acs_find_ideal_chan_mode()
958 if (!best || adj_chan->interference_factor < in acs_find_ideal_chan_mode()
959 best->interference_factor) in acs_find_ideal_chan_mode()
965 chan->chan); in acs_find_ideal_chan_mode()
971 if (iface->current_mode && in acs_find_ideal_chan_mode()
972 iface->current_mode->mode == HOSTAPD_MODE_IEEE80211A && in acs_find_ideal_chan_mode()
976 best->chan, chan->chan, in acs_find_ideal_chan_mode()
977 chan->interference_factor, in acs_find_ideal_chan_mode()
978 best->interference_factor); in acs_find_ideal_chan_mode()
980 index_primary = (chan->freq - best->freq) / 20; in acs_find_ideal_chan_mode()
987 if (is_24ghz_mode(mode->mode)) { in acs_find_ideal_chan_mode()
990 adj_chan = acs_find_chan(iface, chan->freq + in acs_find_ideal_chan_mode()
991 freq_offset - 5); in acs_find_ideal_chan_mode()
994 adj_chan->interference_factor; in acs_find_ideal_chan_mode()
998 adj_chan = acs_find_chan(iface, chan->freq + in acs_find_ideal_chan_mode()
999 freq_offset - 10); in acs_find_ideal_chan_mode()
1002 adj_chan->interference_factor; in acs_find_ideal_chan_mode()
1006 adj_chan = acs_find_chan(iface, chan->freq + in acs_find_ideal_chan_mode()
1010 adj_chan->interference_factor; in acs_find_ideal_chan_mode()
1014 adj_chan = acs_find_chan(iface, chan->freq + in acs_find_ideal_chan_mode()
1018 adj_chan->interference_factor; in acs_find_ideal_chan_mode()
1030 if (iface->conf->acs_chan_bias) { in acs_find_ideal_chan_mode()
1031 for (k = 0; k < iface->conf->num_acs_chan_bias; k++) { in acs_find_ideal_chan_mode()
1032 bias = &iface->conf->acs_chan_bias[k]; in acs_find_ideal_chan_mode()
1033 if (bias->channel == chan->chan) in acs_find_ideal_chan_mode()
1037 } else if (is_24ghz_mode(mode->mode) && in acs_find_ideal_chan_mode()
1038 is_common_24ghz_chan(chan->chan)) { in acs_find_ideal_chan_mode()
1039 tmp_bias.channel = chan->chan; in acs_find_ideal_chan_mode()
1045 factor *= bias->bias; in acs_find_ideal_chan_mode()
1048 chan->chan, factor, bias->bias); in acs_find_ideal_chan_mode()
1052 chan->chan, factor); in acs_find_ideal_chan_mode()
1060 (*ideal_chan)->punct_bitmap = 0; in acs_find_ideal_chan_mode()
1067 if (iface->conf->ieee80211be) in acs_find_ideal_chan_mode()
1082 hostapd_set_and_check_bw320_offset(iface->conf, ideal_bw320_offset); in acs_find_ideal_chan_mode()
1087 * At this point it's assumed chan->interference_factor has been computed.
1089 * option (survey, BSS, spectral, ...). chan->interference factor must be
1103 if (is_6ghz_op_class(iface->conf->op_class)) { in acs_find_ideal_chan()
1104 bw = op_class_to_bandwidth(iface->conf->op_class); in acs_find_ideal_chan()
1109 if (iface->conf->ieee80211n && in acs_find_ideal_chan()
1110 iface->conf->secondary_channel) in acs_find_ideal_chan()
1113 if (iface->conf->ieee80211ac || iface->conf->ieee80211ax || in acs_find_ideal_chan()
1114 iface->conf->ieee80211be) { in acs_find_ideal_chan()
1115 switch (hostapd_get_oper_chwidth(iface->conf)) { in acs_find_ideal_chan()
1138 for (i = 0; i < iface->num_hw_features; i++) { in acs_find_ideal_chan()
1139 mode = &iface->hw_features[i]; in acs_find_ideal_chan()
1148 ideal_chan->chan, ideal_chan->freq, ideal_factor); in acs_find_ideal_chan()
1151 if (iface->conf->punct_acs_threshold) in acs_find_ideal_chan()
1153 ideal_chan->punct_bitmap); in acs_find_ideal_chan()
1170 if (!iface->conf->secondary_channel || in acs_adjust_secondary()
1171 acs_find_mode(iface, iface->freq) != HOSTAPD_MODE_IEEE80211A) in acs_adjust_secondary()
1177 for (i = 0; bw_desc[ACS_BW40][i].first != -1; i++) { in acs_adjust_secondary()
1178 if (iface->freq == bw_desc[ACS_BW40][i].first) in acs_adjust_secondary()
1179 iface->conf->secondary_channel = 1; in acs_adjust_secondary()
1180 else if (iface->freq == bw_desc[ACS_BW40][i].last) in acs_adjust_secondary()
1181 iface->conf->secondary_channel = -1; in acs_adjust_secondary()
1192 switch (hostapd_get_oper_chwidth(iface->conf)) { in acs_adjust_center_freq()
1194 if (iface->conf->secondary_channel && in acs_adjust_center_freq()
1195 iface->freq >= 2400 && iface->freq < 2500) in acs_adjust_center_freq()
1196 center = iface->conf->channel + in acs_adjust_center_freq()
1197 2 * iface->conf->secondary_channel; in acs_adjust_center_freq()
1198 else if (iface->conf->secondary_channel) in acs_adjust_center_freq()
1199 center = acs_get_bw_center_chan(iface->freq, ACS_BW40); in acs_adjust_center_freq()
1201 center = iface->conf->channel; in acs_adjust_center_freq()
1204 center = acs_get_bw_center_chan(iface->freq, ACS_BW80); in acs_adjust_center_freq()
1207 center = acs_get_bw_center_chan(iface->freq, ACS_BW160); in acs_adjust_center_freq()
1210 switch (hostapd_get_bw320_offset(iface->conf)) { in acs_adjust_center_freq()
1212 center = acs_get_bw_center_chan(iface->freq, in acs_adjust_center_freq()
1216 center = acs_get_bw_center_chan(iface->freq, in acs_adjust_center_freq()
1234 hostapd_set_oper_centr_freq_seg0_idx(iface->conf, center); in acs_adjust_center_freq()
1240 wpa_printf(MSG_DEBUG, "ACS: Trying survey-based ACS"); in acs_study_survey_based()
1242 if (!iface->chans_surveyed) { in acs_study_survey_based()
1244 return -1; in acs_study_survey_based()
1249 return -1; in acs_study_survey_based()
1263 * place to fallback to BSS-based ACS */ in acs_study_options()
1265 return -1; in acs_study_options()
1283 err = -1; in acs_study()
1287 iface->conf->channel = ideal_chan->chan; in acs_study()
1288 iface->freq = ideal_chan->freq; in acs_study()
1290 iface->conf->punct_bitmap = ideal_chan->punct_bitmap; in acs_study()
1293 if (iface->conf->ieee80211ac || iface->conf->ieee80211ax || in acs_study()
1294 iface->conf->ieee80211be) { in acs_study()
1302 "ACS: Could not (err: %d) select hw_mode for freq=%d channel=%d", in acs_study()
1303 err, iface->freq, iface->conf->channel); in acs_study()
1304 err = -1; in acs_study()
1311 * hostapd_setup_interface_complete() will return -1 on failure, in acs_study()
1330 iface->scan_cb = NULL; in acs_scan_complete()
1331 iface->acs_num_retries = 0; in acs_scan_complete()
1334 iface->conf->acs_num_scans); in acs_scan_complete()
1336 err = hostapd_drv_get_survey(iface->bss[0], 0); in acs_scan_complete()
1342 if (++iface->acs_num_completed_scans < iface->conf->acs_num_scans) { in acs_scan_complete()
1344 if (err && err != -EBUSY) { in acs_scan_complete()
1362 int *freq) in acs_request_scan_add_freqs() argument
1367 for (i = 0; i < mode->num_channels; i++) { in acs_request_scan_add_freqs()
1368 chan = &mode->channels[i]; in acs_request_scan_add_freqs()
1369 if ((chan->flag & HOSTAPD_CHAN_DISABLED) || in acs_request_scan_add_freqs()
1370 ((chan->flag & HOSTAPD_CHAN_RADAR) && in acs_request_scan_add_freqs()
1371 iface->conf->acs_exclude_dfs)) in acs_request_scan_add_freqs()
1380 if (chan->max_tx_power < iface->conf->min_tx_power) in acs_request_scan_add_freqs()
1383 if ((chan->flag & HOSTAPD_CHAN_INDOOR_ONLY) && in acs_request_scan_add_freqs()
1384 iface->conf->country[2] == 0x4f) in acs_request_scan_add_freqs()
1387 *freq++ = chan->freq; in acs_request_scan_add_freqs()
1390 return freq; in acs_request_scan_add_freqs()
1397 int i, *freq, ret; in acs_request_scan() local
1404 for (i = 0; i < iface->num_hw_features; i++) { in acs_request_scan()
1405 mode = &iface->hw_features[i]; in acs_request_scan()
1407 num_channels += mode->num_channels; in acs_request_scan()
1412 return -1; in acs_request_scan()
1414 freq = params.freqs; in acs_request_scan()
1416 for (i = 0; i < iface->num_hw_features; i++) { in acs_request_scan()
1417 mode = &iface->hw_features[i]; in acs_request_scan()
1419 freq = acs_request_scan_add_freqs(iface, mode, freq); in acs_request_scan()
1422 *freq = 0; in acs_request_scan()
1424 if (params.freqs == freq) { in acs_request_scan()
1427 return -1; in acs_request_scan()
1430 if (!iface->acs_num_retries) in acs_request_scan()
1432 iface->acs_num_completed_scans + 1, in acs_request_scan()
1433 iface->conf->acs_num_scans); in acs_request_scan()
1436 "ACS: Re-try scanning attempt %d (%d / %d)", in acs_request_scan()
1437 iface->acs_num_retries, in acs_request_scan()
1438 iface->acs_num_completed_scans + 1, in acs_request_scan()
1439 iface->conf->acs_num_scans); in acs_request_scan()
1441 ret = hostapd_driver_scan(iface->bss[0], ¶ms); in acs_request_scan()
1444 if (ret == -EBUSY) { in acs_request_scan()
1445 iface->acs_num_retries++; in acs_request_scan()
1446 if (iface->acs_num_retries >= ACS_SCAN_RETRY_MAX_COUNT) { in acs_request_scan()
1448 "ACS: Failed to request initial scan (all re-attempts failed)"); in acs_request_scan()
1450 return -1; in acs_request_scan()
1454 "Failed to request acs scan ret=%d (%s) - try to scan after %d seconds", in acs_request_scan()
1455 ret, strerror(-ret), ACS_SCAN_RETRY_INTERVAL); in acs_request_scan()
1465 return -1; in acs_request_scan()
1468 iface->scan_cb = acs_scan_complete; in acs_request_scan()
1480 "ACS: Failed to request re-try of initial scan"); in acs_scan_retry()
1492 if (iface->drv_flags & WPA_DRIVER_FLAGS_ACS_OFFLOAD) { in acs_init()
1495 err = hostapd_drv_do_acs(iface->bss[0]); in acs_init()
1505 if (!iface->current_mode && in acs_init()
1506 iface->conf->hw_mode != HOSTAPD_MODE_IEEE80211ANY) in acs_init()
1515 wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, ACS_EVENT_STARTED); in acs_init()