Lines Matching refs:iface
75 int hostapd_get_hw_features(struct hostapd_iface *iface) in hostapd_get_hw_features() argument
77 struct hostapd_data *hapd = iface->bss[0]; in hostapd_get_hw_features()
95 iface->hw_flags = flags; in hostapd_get_hw_features()
96 iface->dfs_domain = dfs_domain; in hostapd_get_hw_features()
98 hostapd_free_hw_features(iface->hw_features, iface->num_hw_features); in hostapd_get_hw_features()
99 iface->hw_features = modes; in hostapd_get_hw_features()
100 iface->num_hw_features = num_modes; in hostapd_get_hw_features()
105 (iface->drv_flags & WPA_DRIVER_FLAGS_RADAR); in hostapd_get_hw_features()
123 !(iface->drv_flags & in hostapd_get_hw_features()
148 int hostapd_prepare_rates(struct hostapd_iface *iface, in hostapd_prepare_rates() argument
157 if (iface->conf->basic_rates) in hostapd_prepare_rates()
158 basic_rates = iface->conf->basic_rates; in hostapd_prepare_rates()
180 os_free(iface->basic_rates); in hostapd_prepare_rates()
181 iface->basic_rates = os_malloc(i * sizeof(int)); in hostapd_prepare_rates()
182 if (iface->basic_rates) in hostapd_prepare_rates()
183 os_memcpy(iface->basic_rates, basic_rates, i * sizeof(int)); in hostapd_prepare_rates()
185 os_free(iface->current_rates); in hostapd_prepare_rates()
186 iface->num_rates = 0; in hostapd_prepare_rates()
188 iface->current_rates = in hostapd_prepare_rates()
190 if (!iface->current_rates) { in hostapd_prepare_rates()
199 if (iface->conf->supported_rates && in hostapd_prepare_rates()
200 !hostapd_rate_found(iface->conf->supported_rates, in hostapd_prepare_rates()
204 rate = &iface->current_rates[iface->num_rates]; in hostapd_prepare_rates()
211 iface->num_rates, rate->rate, rate->flags); in hostapd_prepare_rates()
212 iface->num_rates++; in hostapd_prepare_rates()
215 if ((iface->num_rates == 0 || num_basic_rates == 0) && in hostapd_prepare_rates()
216 (!iface->conf->ieee80211n || !iface->conf->require_ht)) { in hostapd_prepare_rates()
219 iface->num_rates, num_basic_rates); in hostapd_prepare_rates()
228 static int ieee80211n_allowed_ht40_channel_pair(struct hostapd_iface *iface) in ieee80211n_allowed_ht40_channel_pair() argument
232 pri_chan = iface->conf->channel; in ieee80211n_allowed_ht40_channel_pair()
233 sec_chan = pri_chan + iface->conf->secondary_channel * 4; in ieee80211n_allowed_ht40_channel_pair()
235 return allowed_ht40_channel_pair(iface->current_mode, pri_chan, in ieee80211n_allowed_ht40_channel_pair()
240 static void ieee80211n_switch_pri_sec(struct hostapd_iface *iface) in ieee80211n_switch_pri_sec() argument
242 if (iface->conf->secondary_channel > 0) { in ieee80211n_switch_pri_sec()
243 iface->conf->channel += 4; in ieee80211n_switch_pri_sec()
244 iface->conf->secondary_channel = -1; in ieee80211n_switch_pri_sec()
246 iface->conf->channel -= 4; in ieee80211n_switch_pri_sec()
247 iface->conf->secondary_channel = 1; in ieee80211n_switch_pri_sec()
252 static int ieee80211n_check_40mhz_5g(struct hostapd_iface *iface, in ieee80211n_check_40mhz_5g() argument
258 pri_chan = iface->conf->channel; in ieee80211n_check_40mhz_5g()
259 sec_chan = pri_chan + iface->conf->secondary_channel * 4; in ieee80211n_check_40mhz_5g()
261 res = check_40mhz_5g(iface->current_mode, scan_res, pri_chan, sec_chan); in ieee80211n_check_40mhz_5g()
264 if (iface->conf->no_pri_sec_switch) { in ieee80211n_check_40mhz_5g()
268 ieee80211n_switch_pri_sec(iface); in ieee80211n_check_40mhz_5g()
276 static int ieee80211n_check_40mhz_2g4(struct hostapd_iface *iface, in ieee80211n_check_40mhz_2g4() argument
281 pri_chan = iface->conf->channel; in ieee80211n_check_40mhz_2g4()
282 sec_chan = pri_chan + iface->conf->secondary_channel * 4; in ieee80211n_check_40mhz_2g4()
284 return check_40mhz_2g4(iface->current_mode, scan_res, pri_chan, in ieee80211n_check_40mhz_2g4()
289 static void ieee80211n_check_scan(struct hostapd_iface *iface) in ieee80211n_check_scan() argument
298 iface->scan_cb = NULL; in ieee80211n_check_scan()
300 scan_res = hostapd_driver_get_scan_results(iface->bss[0]); in ieee80211n_check_scan()
302 hostapd_setup_interface_complete(iface, 1); in ieee80211n_check_scan()
306 if (iface->current_mode->mode == HOSTAPD_MODE_IEEE80211A) in ieee80211n_check_scan()
307 oper40 = ieee80211n_check_40mhz_5g(iface, scan_res); in ieee80211n_check_scan()
309 oper40 = ieee80211n_check_40mhz_2g4(iface, scan_res); in ieee80211n_check_scan()
312 iface->secondary_ch = iface->conf->secondary_channel; in ieee80211n_check_scan()
316 iface->conf->channel, in ieee80211n_check_scan()
317 iface->conf->channel + in ieee80211n_check_scan()
318 iface->conf->secondary_channel * 4); in ieee80211n_check_scan()
319 iface->conf->secondary_channel = 0; in ieee80211n_check_scan()
320 if (iface->drv_flags & WPA_DRIVER_FLAGS_HT_2040_COEX) { in ieee80211n_check_scan()
329 res = ieee80211n_allowed_ht40_channel_pair(iface); in ieee80211n_check_scan()
331 iface->conf->secondary_channel = 0; in ieee80211n_check_scan()
332 iface->conf->vht_oper_centr_freq_seg0_idx = 0; in ieee80211n_check_scan()
333 iface->conf->vht_oper_centr_freq_seg1_idx = 0; in ieee80211n_check_scan()
334 iface->conf->vht_oper_chwidth = VHT_CHANWIDTH_USE_HT; in ieee80211n_check_scan()
339 hostapd_setup_interface_complete(iface, !res); in ieee80211n_check_scan()
343 static void ieee80211n_scan_channels_2g4(struct hostapd_iface *iface, in ieee80211n_scan_channels_2g4() argument
352 if (iface->current_mode == NULL) in ieee80211n_scan_channels_2g4()
355 pri_freq = hostapd_hw_get_freq(iface->bss[0], iface->conf->channel); in ieee80211n_scan_channels_2g4()
356 if (iface->conf->secondary_channel > 0) in ieee80211n_scan_channels_2g4()
370 mode = iface->current_mode; in ieee80211n_scan_channels_2g4()
388 static void ieee80211n_scan_channels_5g(struct hostapd_iface *iface, in ieee80211n_scan_channels_5g() argument
397 if (iface->current_mode == NULL) in ieee80211n_scan_channels_5g()
400 pri_freq = hostapd_hw_get_freq(iface->bss[0], iface->conf->channel); in ieee80211n_scan_channels_5g()
401 if (iface->conf->secondary_channel > 0) { in ieee80211n_scan_channels_5g()
411 mode = iface->current_mode; in ieee80211n_scan_channels_5g()
432 struct hostapd_iface *iface = eloop_data; in ap_ht40_scan_retry() local
437 if (iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G) in ap_ht40_scan_retry()
438 ieee80211n_scan_channels_2g4(iface, ¶ms); in ap_ht40_scan_retry()
440 ieee80211n_scan_channels_5g(iface, ¶ms); in ap_ht40_scan_retry()
442 ret = hostapd_driver_scan(iface->bss[0], ¶ms); in ap_ht40_scan_retry()
443 iface->num_ht40_scan_tries++; in ap_ht40_scan_retry()
447 iface->num_ht40_scan_tries < HT2040_COEX_SCAN_RETRY) { in ap_ht40_scan_retry()
450 ret, strerror(-ret), iface->num_ht40_scan_tries); in ap_ht40_scan_retry()
451 eloop_register_timeout(1, 0, ap_ht40_scan_retry, iface, NULL); in ap_ht40_scan_retry()
456 iface->scan_cb = ieee80211n_check_scan; in ap_ht40_scan_retry()
462 iface->conf->secondary_channel = 0; in ap_ht40_scan_retry()
463 iface->conf->ht_capab &= ~HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET; in ap_ht40_scan_retry()
464 hostapd_setup_interface_complete(iface, 0); in ap_ht40_scan_retry()
468 void hostapd_stop_setup_timers(struct hostapd_iface *iface) in hostapd_stop_setup_timers() argument
470 eloop_cancel_timeout(ap_ht40_scan_retry, iface, NULL); in hostapd_stop_setup_timers()
474 static int ieee80211n_check_40mhz(struct hostapd_iface *iface) in ieee80211n_check_40mhz() argument
480 if (!iface->conf->secondary_channel || iface->conf->no_pri_sec_switch) in ieee80211n_check_40mhz()
483 hostapd_set_state(iface, HAPD_IFACE_HT_SCAN); in ieee80211n_check_40mhz()
487 if (iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G) in ieee80211n_check_40mhz()
488 ieee80211n_scan_channels_2g4(iface, ¶ms); in ieee80211n_check_40mhz()
490 ieee80211n_scan_channels_5g(iface, ¶ms); in ieee80211n_check_40mhz()
492 ret = hostapd_driver_scan(iface->bss[0], ¶ms); in ieee80211n_check_40mhz()
499 iface->num_ht40_scan_tries = 1; in ieee80211n_check_40mhz()
500 eloop_cancel_timeout(ap_ht40_scan_retry, iface, NULL); in ieee80211n_check_40mhz()
501 eloop_register_timeout(1, 0, ap_ht40_scan_retry, iface, NULL); in ieee80211n_check_40mhz()
512 iface->scan_cb = ieee80211n_check_scan; in ieee80211n_check_40mhz()
517 static int ieee80211n_supported_ht_capab(struct hostapd_iface *iface) in ieee80211n_supported_ht_capab() argument
519 u16 hw = iface->current_mode->ht_capab; in ieee80211n_supported_ht_capab()
520 u16 conf = iface->conf->ht_capab; in ieee80211n_supported_ht_capab()
533 if (!iface->conf->acs && (conf & HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET) && in ieee80211n_supported_ht_capab()
542 if (!(iface->smps_modes & WPA_DRIVER_SMPS_MODE_STATIC)) { in ieee80211n_supported_ht_capab()
549 if (!(iface->smps_modes & WPA_DRIVER_SMPS_MODE_DYNAMIC)) { in ieee80211n_supported_ht_capab()
627 static int ieee80211ac_supported_vht_capab(struct hostapd_iface *iface) in ieee80211ac_supported_vht_capab() argument
629 struct hostapd_hw_modes *mode = iface->current_mode; in ieee80211ac_supported_vht_capab()
631 u32 conf = iface->conf->vht_capab; in ieee80211ac_supported_vht_capab()
637 iface->conf->bss[0]->vendor_vht && in ieee80211ac_supported_vht_capab()
638 mode->vht_capab == 0 && iface->hw_features) { in ieee80211ac_supported_vht_capab()
641 for (i = 0; i < iface->num_hw_features; i++) { in ieee80211ac_supported_vht_capab()
642 if (iface->hw_features[i].mode == in ieee80211ac_supported_vht_capab()
644 mode = &iface->hw_features[i]; in ieee80211ac_supported_vht_capab()
661 int hostapd_check_ht_capab(struct hostapd_iface *iface) in hostapd_check_ht_capab() argument
665 if (!iface->conf->ieee80211n) in hostapd_check_ht_capab()
668 if (iface->current_mode->mode != HOSTAPD_MODE_IEEE80211B && in hostapd_check_ht_capab()
669 iface->current_mode->mode != HOSTAPD_MODE_IEEE80211G && in hostapd_check_ht_capab()
670 (iface->conf->ht_capab & HT_CAP_INFO_DSSS_CCK40MHZ)) { in hostapd_check_ht_capab()
673 iface->conf->ht_capab &= ~HT_CAP_INFO_DSSS_CCK40MHZ; in hostapd_check_ht_capab()
676 if (!ieee80211n_supported_ht_capab(iface)) in hostapd_check_ht_capab()
679 if (iface->conf->ieee80211ac && in hostapd_check_ht_capab()
680 !ieee80211ac_supported_vht_capab(iface)) in hostapd_check_ht_capab()
683 ret = ieee80211n_check_40mhz(iface); in hostapd_check_ht_capab()
686 if (!ieee80211n_allowed_ht40_channel_pair(iface)) in hostapd_check_ht_capab()
694 static int hostapd_is_usable_chan(struct hostapd_iface *iface, in hostapd_is_usable_chan() argument
699 if (!iface->current_mode) in hostapd_is_usable_chan()
702 chan = hw_get_channel_chan(iface->current_mode, channel, NULL); in hostapd_is_usable_chan()
720 static int hostapd_is_usable_chans(struct hostapd_iface *iface) in hostapd_is_usable_chans() argument
725 pri_chan = hw_get_channel_chan(iface->current_mode, in hostapd_is_usable_chans()
726 iface->conf->channel, NULL); in hostapd_is_usable_chans()
730 if (!hostapd_is_usable_chan(iface, iface->conf->channel, 1)) in hostapd_is_usable_chans()
733 if (!iface->conf->secondary_channel) in hostapd_is_usable_chans()
736 if (!iface->conf->ht40_plus_minus_allowed) in hostapd_is_usable_chans()
738 iface, iface->conf->channel + in hostapd_is_usable_chans()
739 iface->conf->secondary_channel * 4, 0); in hostapd_is_usable_chans()
742 secondary_chan = iface->conf->channel + 4; in hostapd_is_usable_chans()
743 if (hostapd_is_usable_chan(iface, secondary_chan, 0) && in hostapd_is_usable_chans()
745 iface->conf->secondary_channel = 1; in hostapd_is_usable_chans()
749 secondary_chan = iface->conf->channel - 4; in hostapd_is_usable_chans()
750 if (hostapd_is_usable_chan(iface, secondary_chan, 0) && in hostapd_is_usable_chans()
752 iface->conf->secondary_channel = -1; in hostapd_is_usable_chans()
761 hostapd_check_chans(struct hostapd_iface *iface) in hostapd_check_chans() argument
763 if (iface->conf->channel) { in hostapd_check_chans()
764 if (hostapd_is_usable_chans(iface)) in hostapd_check_chans()
775 switch (acs_init(iface)) { in hostapd_check_chans()
786 static void hostapd_notify_bad_chans(struct hostapd_iface *iface) in hostapd_notify_bad_chans() argument
788 if (!iface->current_mode) { in hostapd_notify_bad_chans()
789 hostapd_logger(iface->bss[0], NULL, HOSTAPD_MODULE_IEEE80211, in hostapd_notify_bad_chans()
794 hostapd_logger(iface->bss[0], NULL, in hostapd_notify_bad_chans()
799 iface->conf->channel, in hostapd_notify_bad_chans()
800 iface->current_mode->mode, in hostapd_notify_bad_chans()
801 hostapd_hw_mode_txt(iface->current_mode->mode)); in hostapd_notify_bad_chans()
802 hostapd_logger(iface->bss[0], NULL, HOSTAPD_MODULE_IEEE80211, in hostapd_notify_bad_chans()
808 int hostapd_acs_completed(struct hostapd_iface *iface, int err) in hostapd_acs_completed() argument
815 switch (hostapd_check_chans(iface)) { in hostapd_acs_completed()
817 wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, in hostapd_acs_completed()
819 hostapd_hw_get_freq(iface->bss[0], in hostapd_acs_completed()
820 iface->conf->channel), in hostapd_acs_completed()
821 iface->conf->channel); in hostapd_acs_completed()
825 wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, ACS_EVENT_FAILED); in hostapd_acs_completed()
826 hostapd_notify_bad_chans(iface); in hostapd_acs_completed()
831 wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, ACS_EVENT_FAILED); in hostapd_acs_completed()
832 hostapd_notify_bad_chans(iface); in hostapd_acs_completed()
836 ret = hostapd_check_ht_capab(iface); in hostapd_acs_completed()
846 return hostapd_setup_interface_complete(iface, ret); in hostapd_acs_completed()
858 int hostapd_select_hw_mode(struct hostapd_iface *iface) in hostapd_select_hw_mode() argument
862 if (iface->num_hw_features < 1) in hostapd_select_hw_mode()
865 if ((iface->conf->hw_mode == HOSTAPD_MODE_IEEE80211G || in hostapd_select_hw_mode()
866 iface->conf->ieee80211n || iface->conf->ieee80211ac) && in hostapd_select_hw_mode()
867 iface->conf->channel == 14) { in hostapd_select_hw_mode()
869 iface->conf->hw_mode = HOSTAPD_MODE_IEEE80211B; in hostapd_select_hw_mode()
870 iface->conf->ieee80211n = 0; in hostapd_select_hw_mode()
871 iface->conf->ieee80211ac = 0; in hostapd_select_hw_mode()
874 iface->current_mode = NULL; in hostapd_select_hw_mode()
875 for (i = 0; i < iface->num_hw_features; i++) { in hostapd_select_hw_mode()
876 struct hostapd_hw_modes *mode = &iface->hw_features[i]; in hostapd_select_hw_mode()
877 if (mode->mode == iface->conf->hw_mode) { in hostapd_select_hw_mode()
878 iface->current_mode = mode; in hostapd_select_hw_mode()
883 if (iface->current_mode == NULL) { in hostapd_select_hw_mode()
884 if (!(iface->drv_flags & WPA_DRIVER_FLAGS_ACS_OFFLOAD) || in hostapd_select_hw_mode()
885 !(iface->drv_flags & WPA_DRIVER_FLAGS_SUPPORT_HW_MODE_ANY)) in hostapd_select_hw_mode()
889 hostapd_logger(iface->bss[0], NULL, in hostapd_select_hw_mode()
893 (int) iface->conf->hw_mode); in hostapd_select_hw_mode()
898 switch (hostapd_check_chans(iface)) { in hostapd_select_hw_mode()
905 hostapd_notify_bad_chans(iface); in hostapd_select_hw_mode()
930 return hw_get_freq(hapd->iface->current_mode, chan); in hostapd_hw_get_freq()
939 if (hapd->iface->current_mode) { in hostapd_hw_get_channel()
940 channel = hw_get_chan(hapd->iface->current_mode, freq); in hostapd_hw_get_channel()
947 if (!hapd->iface->hw_features) in hostapd_hw_get_channel()
949 for (i = 0; i < hapd->iface->num_hw_features; i++) { in hostapd_hw_get_channel()
950 mode = &hapd->iface->hw_features[i]; in hostapd_hw_get_channel()