Lines Matching defs:iface

75 int hostapd_get_hw_features(struct hostapd_iface *iface)
77 struct hostapd_data *hapd = iface->bss[0];
98 iface->hw_flags = flags;
99 iface->dfs_domain = dfs_domain;
101 if (iface->current_mode) {
104 * hw mode is valid. Clear iface->current_mode temporarily as
109 mode = iface->current_mode->mode;
110 is_6ghz = iface->current_mode->is_6ghz;
111 iface->current_mode = NULL;
113 hostapd_free_hw_features(iface->hw_features, iface->num_hw_features);
114 iface->hw_features = modes;
115 iface->num_hw_features = num_modes;
120 (iface->drv_flags & WPA_DRIVER_FLAGS_RADAR);
126 iface->current_mode = feature;
144 !(iface->drv_flags &
165 if (orig_mode_valid && !iface->current_mode) {
167 "%s: Could not update iface->current_mode",
175 int hostapd_prepare_rates(struct hostapd_iface *iface,
184 if (iface->conf->basic_rates)
185 basic_rates = iface->conf->basic_rates;
207 os_free(iface->basic_rates);
208 iface->basic_rates = os_malloc(i * sizeof(int));
209 if (iface->basic_rates)
210 os_memcpy(iface->basic_rates, basic_rates, i * sizeof(int));
212 os_free(iface->current_rates);
213 iface->num_rates = 0;
215 iface->current_rates =
217 if (!iface->current_rates) {
226 if (iface->conf->supported_rates &&
227 !hostapd_rate_found(iface->conf->supported_rates,
231 rate = &iface->current_rates[iface->num_rates];
238 iface->num_rates, rate->rate, rate->flags);
239 iface->num_rates++;
242 if ((iface->num_rates == 0 || num_basic_rates == 0) &&
243 (!iface->conf->ieee80211n || !iface->conf->require_ht)) {
246 iface->num_rates, num_basic_rates);
254 static int ieee80211n_allowed_ht40_channel_pair(struct hostapd_iface *iface)
259 pri_freq = iface->freq;
260 sec_freq = pri_freq + iface->conf->secondary_channel * 20;
262 if (!iface->current_mode)
265 p_chan = hw_get_channel_freq(iface->current_mode->mode, pri_freq, NULL,
266 iface->hw_features,
267 iface->num_hw_features);
269 s_chan = hw_get_channel_freq(iface->current_mode->mode, sec_freq, NULL,
270 iface->hw_features,
271 iface->num_hw_features);
273 return allowed_ht40_channel_pair(iface->current_mode->mode,
278 static void ieee80211n_switch_pri_sec(struct hostapd_iface *iface)
280 if (iface->conf->secondary_channel > 0) {
281 iface->conf->channel += 4;
282 iface->freq += 20;
283 iface->conf->secondary_channel = -1;
285 iface->conf->channel -= 4;
286 iface->freq -= 20;
287 iface->conf->secondary_channel = 1;
292 static int ieee80211n_check_40mhz_5g(struct hostapd_iface *iface,
299 pri_freq = iface->freq;
300 sec_freq = pri_freq + iface->conf->secondary_channel * 20;
302 if (!iface->current_mode)
304 pri_chan = hw_get_channel_freq(iface->current_mode->mode, pri_freq,
305 NULL, iface->hw_features,
306 iface->num_hw_features);
307 sec_chan = hw_get_channel_freq(iface->current_mode->mode, sec_freq,
308 NULL, iface->hw_features,
309 iface->num_hw_features);
314 if (iface->conf->no_pri_sec_switch) {
318 ieee80211n_switch_pri_sec(iface);
326 static int ieee80211n_check_40mhz_2g4(struct hostapd_iface *iface,
331 pri_chan = iface->conf->channel;
332 sec_chan = pri_chan + iface->conf->secondary_channel * 4;
334 return check_40mhz_2g4(iface->current_mode, scan_res, pri_chan,
339 static void ieee80211n_check_scan(struct hostapd_iface *iface)
348 iface->scan_cb = NULL;
350 scan_res = hostapd_driver_get_scan_results(iface->bss[0]);
352 hostapd_setup_interface_complete(iface, 1);
356 if (iface->current_mode->mode == HOSTAPD_MODE_IEEE80211A)
357 oper40 = ieee80211n_check_40mhz_5g(iface, scan_res);
359 oper40 = ieee80211n_check_40mhz_2g4(iface, scan_res);
362 iface->secondary_ch = iface->conf->secondary_channel;
366 iface->conf->channel,
367 iface->conf->channel +
368 iface->conf->secondary_channel * 4);
369 iface->conf->secondary_channel = 0;
370 if (iface->drv_flags & WPA_DRIVER_FLAGS_HT_2040_COEX) {
380 if (iface->conf->secondary_channel &&
381 iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G &&
382 iface->conf->ieee80211ax) {
385 he_cap = &iface->current_mode->he_capab[IEEE80211_MODE_AP];
390 iface->conf->secondary_channel = 0;
395 if (iface->conf->secondary_channel)
396 res = ieee80211n_allowed_ht40_channel_pair(iface);
398 iface->conf->secondary_channel = 0;
399 hostapd_set_oper_centr_freq_seg0_idx(iface->conf, 0);
400 hostapd_set_oper_centr_freq_seg1_idx(iface->conf, 0);
401 hostapd_set_oper_chwidth(iface->conf, CONF_OPER_CHWIDTH_USE_HT);
406 hostapd_setup_interface_complete(iface, !res);
410 static void ieee80211n_scan_channels_2g4(struct hostapd_iface *iface,
419 if (iface->current_mode == NULL)
422 pri_freq = iface->freq;
423 if (iface->conf->secondary_channel > 0)
437 mode = iface->current_mode;
455 static void ieee80211n_scan_channels_5g(struct hostapd_iface *iface,
464 if (iface->current_mode == NULL)
467 pri_freq = iface->freq;
468 if (iface->conf->secondary_channel > 0) {
478 mode = iface->current_mode;
499 struct hostapd_iface *iface = eloop_data;
504 if (iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G)
505 ieee80211n_scan_channels_2g4(iface, &params);
507 ieee80211n_scan_channels_5g(iface, &params);
511 if (iface->bss[0]->conf->mld_ap)
512 params.link_id = iface->bss[0]->mld_link_id;
515 ret = hostapd_driver_scan(iface->bss[0], &params);
516 iface->num_ht40_scan_tries++;
520 iface->num_ht40_scan_tries < HT2040_COEX_SCAN_RETRY) {
523 ret, strerror(-ret), iface->num_ht40_scan_tries);
524 eloop_register_timeout(1, 0, ap_ht40_scan_retry, iface, NULL);
529 iface->scan_cb = ieee80211n_check_scan;
530 iface->bss[0]->scan_cookie = params.scan_cookie;
536 iface->conf->secondary_channel = 0;
537 iface->conf->ht_capab &= ~HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET;
538 hostapd_setup_interface_complete(iface, 0);
542 void hostapd_stop_setup_timers(struct hostapd_iface *iface)
544 eloop_cancel_timeout(ap_ht40_scan_retry, iface, NULL);
548 static int ieee80211n_check_40mhz(struct hostapd_iface *iface)
554 if (!iface->conf->secondary_channel || iface->conf->no_pri_sec_switch)
557 hostapd_set_state(iface, HAPD_IFACE_HT_SCAN);
561 if (iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G)
562 ieee80211n_scan_channels_2g4(iface, &params);
564 ieee80211n_scan_channels_5g(iface, &params);
568 if (iface->bss[0]->conf->mld_ap)
569 params.link_id = iface->bss[0]->mld_link_id;
571 ret = hostapd_driver_scan(iface->bss[0], &params);
578 iface->num_ht40_scan_tries = 1;
579 eloop_cancel_timeout(ap_ht40_scan_retry, iface, NULL);
580 eloop_register_timeout(1, 0, ap_ht40_scan_retry, iface, NULL);
591 iface->scan_cb = ieee80211n_check_scan;
592 iface->bss[0]->scan_cookie = params.scan_cookie;
597 static int ieee80211n_supported_ht_capab(struct hostapd_iface *iface)
599 u16 hw = iface->current_mode->ht_capab;
600 u16 conf = iface->conf->ht_capab;
613 if (!iface->conf->acs && (conf & HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET) &&
687 static int ieee80211ac_supported_vht_capab(struct hostapd_iface *iface)
689 struct hostapd_hw_modes *mode = iface->current_mode;
691 u32 conf = iface->conf->vht_capab;
697 iface->conf->bss[0]->vendor_vht &&
698 mode->vht_capab == 0 && iface->hw_features) {
701 for (i = 0; i < iface->num_hw_features; i++) {
702 if (iface->hw_features[i].mode ==
704 mode = &iface->hw_features[i];
720 static int ieee80211ax_supported_he_capab(struct hostapd_iface *iface)
727 int hostapd_check_ht_capab(struct hostapd_iface *iface)
731 if (is_6ghz_freq(iface->freq))
733 if (!iface->conf->ieee80211n)
736 if (iface->current_mode->mode != HOSTAPD_MODE_IEEE80211B &&
737 iface->current_mode->mode != HOSTAPD_MODE_IEEE80211G &&
738 (iface->conf->ht_capab & HT_CAP_INFO_DSSS_CCK40MHZ)) {
741 iface->conf->ht_capab &= ~HT_CAP_INFO_DSSS_CCK40MHZ;
744 if (!ieee80211n_supported_ht_capab(iface))
747 if (iface->conf->ieee80211ax &&
748 !ieee80211ax_supported_he_capab(iface))
752 if (iface->conf->ieee80211ac &&
753 !ieee80211ac_supported_vht_capab(iface))
756 ret = ieee80211n_check_40mhz(iface);
759 if (!ieee80211n_allowed_ht40_channel_pair(iface))
766 int hostapd_check_edmg_capab(struct hostapd_iface *iface)
768 struct hostapd_hw_modes *mode = iface->hw_features;
771 if (!iface->conf->enable_edmg)
774 hostapd_encode_edmg_chan(iface->conf->enable_edmg,
775 iface->conf->edmg_channel,
776 iface->conf->channel,
792 int hostapd_check_he_6ghz_capab(struct hostapd_iface *iface)
798 if (!iface->current_mode || !is_6ghz_freq(iface->freq))
801 he_cap = &iface->current_mode->he_capab[IEEE80211_MODE_AP];
803 if (iface->conf->he_6ghz_max_mpdu >
811 if (iface->conf->he_6ghz_max_ampdu_len_exp >
819 if (iface->conf->he_6ghz_rx_ant_pat &&
826 if (iface->conf->he_6ghz_tx_ant_pat &&
842 static int hostapd_is_usable_chan(struct hostapd_iface *iface,
847 if (!iface->current_mode)
850 chan = hw_get_channel_freq(iface->current_mode->mode, frequency, NULL,
851 iface->hw_features, iface->num_hw_features);
873 static int hostapd_is_usable_edmg(struct hostapd_iface *iface)
882 if (!iface->conf->enable_edmg)
885 if (!iface->current_mode)
887 pri_chan = hw_get_channel_freq(iface->current_mode->mode,
888 iface->freq, NULL,
889 iface->hw_features,
890 iface->num_hw_features);
893 hostapd_encode_edmg_chan(iface->conf->enable_edmg,
894 iface->conf->edmg_channel,
918 err = hostapd_is_usable_chan(iface, freq, 1);
947 static bool hostapd_is_usable_punct_bitmap(struct hostapd_iface *iface)
950 struct hostapd_config *conf = iface->conf;
963 if (iface->freq >= 2412 && iface->freq <= 2484) {
1011 static int hostapd_is_usable_chans(struct hostapd_iface *iface)
1017 if (!iface->current_mode)
1019 pri_chan = hw_get_channel_freq(iface->current_mode->mode,
1020 iface->freq, NULL,
1021 iface->hw_features,
1022 iface->num_hw_features);
1028 err = hostapd_is_usable_chan(iface, pri_chan->freq, 1);
1033 err = hostapd_is_usable_edmg(iface);
1037 if (!hostapd_is_usable_punct_bitmap(iface))
1040 if (!iface->conf->secondary_channel)
1043 err = hostapd_is_usable_chan(iface, iface->freq +
1044 iface->conf->secondary_channel * 20, 0);
1046 if (iface->conf->secondary_channel == 1 &&
1049 if (iface->conf->secondary_channel == -1 &&
1053 if (!iface->conf->ht40_plus_minus_allowed)
1057 secondary_freq = iface->freq + 20;
1058 err2 = hostapd_is_usable_chan(iface, secondary_freq, 0);
1060 iface->conf->secondary_channel = 1;
1064 secondary_freq = iface->freq - 20;
1065 err2 = hostapd_is_usable_chan(iface, secondary_freq, 0);
1067 iface->conf->secondary_channel = -1;
1075 static bool skip_mode(struct hostapd_iface *iface,
1080 if (iface->freq > 0 && !hw_mode_get_channel(mode, iface->freq, &chan))
1083 if (is_6ghz_op_class(iface->conf->op_class) && iface->freq == 0 &&
1091 int hostapd_determine_mode(struct hostapd_iface *iface)
1096 if (iface->current_mode ||
1097 iface->conf->hw_mode != HOSTAPD_MODE_IEEE80211ANY)
1100 if (iface->freq < 4000)
1102 else if (iface->freq > 50000)
1107 for (i = 0; i < iface->num_hw_features; i++) {
1110 mode = &iface->hw_features[i];
1112 if (skip_mode(iface, mode))
1115 iface->current_mode = mode;
1116 iface->conf->hw_mode = mode->mode;
1121 if (!iface->current_mode) {
1130 hostapd_check_chans(struct hostapd_iface *iface)
1132 if (iface->freq) {
1135 hostapd_determine_mode(iface);
1137 err = hostapd_is_usable_chans(iface);
1151 switch (acs_init(iface)) {
1164 static void hostapd_notify_bad_chans(struct hostapd_iface *iface)
1166 if (!iface->current_mode) {
1167 hostapd_logger(iface->bss[0], NULL, HOSTAPD_MODULE_IEEE80211,
1172 hostapd_logger(iface->bss[0], NULL,
1176 iface->conf->channel,
1177 iface->freq, iface->conf->secondary_channel,
1178 iface->current_mode->mode,
1179 hostapd_hw_mode_txt(iface->current_mode->mode));
1180 hostapd_logger(iface->bss[0], NULL, HOSTAPD_MODULE_IEEE80211,
1186 int hostapd_acs_completed(struct hostapd_iface *iface, int err)
1193 switch (hostapd_check_chans(iface)) {
1195 iface->is_no_ir = false;
1196 wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO,
1198 iface->freq, iface->conf->channel);
1202 wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, ACS_EVENT_FAILED);
1203 hostapd_notify_bad_chans(iface);
1206 iface->is_no_ir = true;
1211 wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, ACS_EVENT_FAILED);
1212 hostapd_notify_bad_chans(iface);
1216 ret = hostapd_check_ht_capab(iface);
1226 return hostapd_setup_interface_complete(iface, ret);
1232 * @iface: Pointer to interface data.
1237 int hostapd_csa_update_hwmode(struct hostapd_iface *iface)
1239 if (!iface || !iface->conf)
1242 iface->current_mode = NULL;
1243 iface->conf->hw_mode = HOSTAPD_MODE_IEEE80211ANY;
1245 return hostapd_determine_mode(iface);
1251 * @iface: Pointer to interface data.
1257 int hostapd_select_hw_mode(struct hostapd_iface *iface)
1261 if (iface->num_hw_features < 1)
1264 if ((iface->conf->hw_mode == HOSTAPD_MODE_IEEE80211G ||
1265 iface->conf->ieee80211n || iface->conf->ieee80211ac ||
1266 iface->conf->ieee80211ax || iface->conf->ieee80211be) &&
1267 iface->conf->channel == 14) {
1269 iface->conf->hw_mode = HOSTAPD_MODE_IEEE80211B;
1270 iface->conf->ieee80211n = 0;
1271 iface->conf->ieee80211ac = 0;
1272 iface->conf->ieee80211ax = 0;
1273 iface->conf->ieee80211be = 0;
1276 iface->current_mode = NULL;
1277 for (i = 0; i < iface->num_hw_features; i++) {
1278 struct hostapd_hw_modes *mode = &iface->hw_features[i];
1280 if (mode->mode == iface->conf->hw_mode) {
1281 if (skip_mode(iface, mode))
1284 iface->current_mode = mode;
1289 if (iface->current_mode == NULL) {
1290 if ((iface->drv_flags & WPA_DRIVER_FLAGS_ACS_OFFLOAD) &&
1291 (iface->drv_flags & WPA_DRIVER_FLAGS_SUPPORT_HW_MODE_ANY)) {
1294 } else if (!(iface->drv_flags & WPA_DRIVER_FLAGS_ACS_OFFLOAD) &&
1295 iface->conf->hw_mode == HOSTAPD_MODE_IEEE80211ANY) {
1301 hostapd_logger(iface->bss[0], NULL,
1305 (int) iface->conf->hw_mode);
1310 switch (hostapd_check_chans(iface)) {
1312 iface->is_no_ir = false;
1317 iface->is_no_ir = true;
1321 hostapd_notify_bad_chans(iface);
1346 return hw_get_freq(hapd->iface->current_mode, chan);
1355 if (hapd->iface->current_mode) {
1356 channel = hw_get_chan(hapd->iface->current_mode->mode, freq,
1357 hapd->iface->hw_features,
1358 hapd->iface->num_hw_features);
1365 if (!hapd->iface->hw_features)
1367 for (i = 0; i < hapd->iface->num_hw_features; i++) {
1368 mode = &hapd->iface->hw_features[i];
1370 hapd->iface->hw_features,
1371 hapd->iface->num_hw_features);
1379 int hostapd_hw_skip_mode(struct hostapd_iface *iface,
1384 if (iface->current_mode)
1385 return mode != iface->current_mode;
1388 for (i = 0; i < iface->num_hw_features; i++) {
1389 if (iface->hw_features[i].mode == HOSTAPD_MODE_IEEE80211G)