Lines Matching +full:switch +full:- +full:mode +full:- +full:frequency
3 * Copyright 2002-2003, Instant802 Networks, Inc.
4 * Copyright 2005-2006, Devicescape Software, Inc.
5 * Copyright (c) 2008-2012, Jouni Malinen <j@w1.fi>
51 switch (chan->flag & HOSTAPD_CHAN_DFS_MASK) {
68 info[sizeof(info) - 1] = '\0';
77 struct hostapd_data *hapd = iface->bss[0];
82 enum hostapd_hw_mode mode = HOSTAPD_MODE_IEEE80211ANY;
87 return -1;
95 return -1;
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
105 * the mode instance will be replaced with a new instance and
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;
119 int dfs_enabled = hapd->iconf->ieee80211h &&
120 (iface->drv_flags & WPA_DRIVER_FLAGS_RADAR);
122 /* Restore orignal mode if possible */
123 if (orig_mode_valid && feature->mode == mode &&
124 feature->num_channels > 0 &&
125 is_6ghz == is_6ghz_freq(feature->channels[0].freq))
126 iface->current_mode = feature;
130 for (j = 0; j < feature->num_channels; j++) {
139 if ((feature->channels[j].flag &
142 } else if (((feature->channels[j].flag &
144 !(iface->drv_flags &
146 (feature->channels[j].flag &
148 feature->channels[j].flag |=
152 if (feature->channels[j].flag & HOSTAPD_CHAN_DISABLED)
155 wpa_printf(MSG_MSGDUMP, "Allowed channel: mode=%d "
157 feature->mode,
158 feature->channels[j].chan,
159 feature->channels[j].freq,
160 feature->channels[j].max_tx_power,
161 dfs ? dfs_info(&feature->channels[j]) : "");
165 if (orig_mode_valid && !iface->current_mode) {
167 "%s: Could not update iface->current_mode",
176 struct hostapd_hw_modes *mode)
179 int basic_rates_a[] = { 60, 120, 240, -1 };
180 int basic_rates_b[] = { 10, 20, -1 };
181 int basic_rates_g[] = { 10, 20, 55, 110, -1 };
184 if (iface->conf->basic_rates)
185 basic_rates = iface->conf->basic_rates;
186 else switch (mode->mode) {
199 return -1;
206 i++; /* -1 termination */
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 =
216 os_calloc(mode->num_rates, sizeof(struct hostapd_rate_data));
217 if (!iface->current_rates) {
220 return -1;
223 for (i = 0; i < mode->num_rates; i++) {
226 if (iface->conf->supported_rates &&
227 !hostapd_rate_found(iface->conf->supported_rates,
228 mode->rates[i]))
231 rate = &iface->current_rates[iface->num_rates];
232 rate->rate = mode->rates[i];
233 if (hostapd_rate_found(basic_rates, rate->rate)) {
234 rate->flags |= HOSTAPD_RATE_BASIC;
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);
247 return -1;
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,
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;
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) {
316 "Cannot switch PRI/SEC channels due to local constraint");
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,
346 * allowed per IEEE Std 802.11-2012, 10.15.3.2 */
348 iface->scan_cb = NULL;
350 scan_res = hostapd_driver_get_scan_results(iface->bss[0]);
356 if (iface->current_mode->mode == HOSTAPD_MODE_IEEE80211A)
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];
386 if (!(he_cap->phy_cap[HE_PHYCAP_CHANNEL_WIDTH_SET_IDX] &
390 iface->conf->secondary_channel = 0;
395 if (iface->conf->secondary_channel)
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);
413 /* Scan only the affected frequency range */
417 struct hostapd_hw_modes *mode;
419 if (iface->current_mode == NULL)
422 pri_freq = iface->freq;
423 if (iface->conf->secondary_channel > 0)
426 sec_freq = pri_freq - 20;
430 * scanning coverage here to be 40 MHz from the center frequency.
432 affected_start = (pri_freq + sec_freq) / 2 - 40;
437 mode = iface->current_mode;
438 params->freqs = os_calloc(mode->num_channels + 1, sizeof(int));
439 if (params->freqs == NULL)
443 for (i = 0; i < mode->num_channels; i++) {
444 struct hostapd_channel_data *chan = &mode->channels[i];
445 if (chan->flag & HOSTAPD_CHAN_DISABLED)
447 if (chan->freq < affected_start ||
448 chan->freq > affected_end)
450 params->freqs[pos++] = chan->freq;
458 /* Scan only the affected frequency range */
462 struct hostapd_hw_modes *mode;
464 if (iface->current_mode == NULL)
467 pri_freq = iface->freq;
468 if (iface->conf->secondary_channel > 0) {
469 affected_start = pri_freq - 10;
472 affected_start = pri_freq - 30;
478 mode = iface->current_mode;
479 params->freqs = os_calloc(mode->num_channels + 1, sizeof(int));
480 if (params->freqs == NULL)
484 for (i = 0; i < mode->num_channels; i++) {
485 struct hostapd_channel_data *chan = &mode->channels[i];
486 if (chan->flag & HOSTAPD_CHAN_DISABLED)
488 if (chan->freq < affected_start ||
489 chan->freq > affected_end)
491 params->freqs[pos++] = chan->freq;
504 if (iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G)
509 params.link_id = -1;
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], ¶ms);
516 iface->num_ht40_scan_tries++;
519 if (ret == -EBUSY &&
520 iface->num_ht40_scan_tries < HT2040_COEX_SCAN_RETRY) {
522 "Failed to request a scan of neighboring BSSes ret=%d (%s) - try to scan again (attempt %d)",
523 ret, strerror(-ret), iface->num_ht40_scan_tries);
529 iface->scan_cb = ieee80211n_check_scan;
530 iface->bss[0]->scan_cookie = params.scan_cookie;
535 "Failed to request a scan in device, bringing up in HT20 mode");
536 iface->conf->secondary_channel = 0;
537 iface->conf->ht_capab &= ~HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET;
553 /* Check that HT40 is used and PRI / SEC switch is allowed */
554 if (!iface->conf->secondary_channel || iface->conf->no_pri_sec_switch)
561 if (iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G)
566 params.link_id = -1;
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], ¶ms);
574 if (ret == -EBUSY) {
576 "Failed to request a scan of neighboring BSSes ret=%d (%s) - try to scan again",
577 ret, strerror(-ret));
578 iface->num_ht40_scan_tries = 1;
587 ret, strerror(-ret));
588 return -1;
591 iface->scan_cb = ieee80211n_check_scan;
592 iface->bss[0]->scan_cookie = params.scan_cookie;
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) &&
630 "HT capability [SHORT-GI-20]");
637 "HT capability [SHORT-GI-40]");
643 "HT capability [TX-STBC]");
650 "HT capability [RX-STBC*]");
657 "HT capability [DELAYED-BA]");
664 "HT capability [MAX-AMSDU-7935]");
671 "HT capability [DSSS_CCK-40]");
678 "HT capability [LSIG-TXOP-PROT]");
689 struct hostapd_hw_modes *mode = iface->current_mode;
690 u32 hw = mode->vht_capab;
691 u32 conf = iface->conf->vht_capab;
696 if (mode->mode == HOSTAPD_MODE_IEEE80211G &&
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];
705 hw = mode->vht_capab;
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)) {
740 "Disable HT capability [DSSS_CCK-40] on 5 GHz band");
741 iface->conf->ht_capab &= ~HT_CAP_INFO_DSSS_CCK40MHZ;
745 return -1;
747 if (iface->conf->ieee80211ax &&
749 return -1;
752 if (iface->conf->ieee80211ac &&
754 return -1;
760 return -1;
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,
779 if (mode->edmg.channels && ieee802_edmg_is_allowed(mode->edmg, edmg))
784 mode->edmg.channels, mode->edmg.bw_config);
788 return -1;
798 if (!iface->current_mode || !is_6ghz_freq(iface->freq))
801 he_cap = &iface->current_mode->he_capab[IEEE80211_MODE_AP];
802 hw = he_cap->he_6ghz_capa;
803 if (iface->conf->he_6ghz_max_mpdu >
808 return -1;
811 if (iface->conf->he_6ghz_max_ampdu_len_exp >
816 return -1;
819 if (iface->conf->he_6ghz_rx_ant_pat &&
823 return -1;
826 if (iface->conf->he_6ghz_tx_ant_pat &&
830 return -1;
840 * -1 = not currently usable due to 6 GHz NO-IR
843 int frequency, int primary)
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);
856 (!primary && !(chan->flag & HOSTAPD_CHAN_DISABLED)))
860 "Frequency %d (%s) not allowed for AP mode, flags: 0x%x%s%s",
861 frequency, primary ? "primary" : "secondary",
862 chan->flag,
863 chan->flag & HOSTAPD_CHAN_NO_IR ? " NO-IR" : "",
864 chan->flag & HOSTAPD_CHAN_RADAR ? " RADAR" : "");
866 if (is_6ghz_freq(chan->freq) && (chan->flag & HOSTAPD_CHAN_NO_IR))
867 return -1;
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,
895 pri_chan->chan,
897 if (!(edmg.channels & BIT(pri_chan->chan - 1)))
930 switch (edmg.bw_config) {
950 struct hostapd_config *conf = iface->conf;
954 if (!conf->punct_bitmap)
957 if (!conf->ieee80211be) {
963 if (iface->freq >= 2412 && iface->freq <= 2484) {
973 if (conf->op_class == 137) {
975 start_chan = conf->eht_oper_centr_freq_seg0_idx - 30;
977 switch (conf->eht_oper_chwidth) {
984 start_chan = conf->eht_oper_centr_freq_seg0_idx - 6;
988 start_chan = conf->eht_oper_centr_freq_seg0_idx - 14;
995 if (!is_punct_bitmap_valid(bw, (conf->channel - start_chan) / 4,
996 conf->punct_bitmap)) {
1009 * -1 = not currently usable due to 6 GHz NO-IR
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);
1024 wpa_printf(MSG_ERROR, "Primary frequency not present");
1028 err = hostapd_is_usable_chan(iface, pri_chan->freq, 1);
1030 wpa_printf(MSG_ERROR, "Primary frequency not allowed");
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 &&
1047 (pri_chan->allowed_bw & HOSTAPD_CHAN_WIDTH_40P))
1049 if (iface->conf->secondary_channel == -1 &&
1050 (pri_chan->allowed_bw & HOSTAPD_CHAN_WIDTH_40M))
1053 if (!iface->conf->ht40_plus_minus_allowed)
1056 /* Both HT40+ and HT40- are set, pick a valid secondary channel */
1057 secondary_freq = iface->freq + 20;
1059 if (err2 > 0 && (pri_chan->allowed_bw & HOSTAPD_CHAN_WIDTH_40P)) {
1060 iface->conf->secondary_channel = 1;
1064 secondary_freq = iface->freq - 20;
1066 if (err2 > 0 && (pri_chan->allowed_bw & HOSTAPD_CHAN_WIDTH_40M)) {
1067 iface->conf->secondary_channel = -1;
1076 struct hostapd_hw_modes *mode)
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 &&
1084 !mode->is_6ghz)
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++) {
1108 struct hostapd_hw_modes *mode;
1110 mode = &iface->hw_features[i];
1111 if (mode->mode == target_mode) {
1112 if (skip_mode(iface, mode))
1115 iface->current_mode = mode;
1116 iface->conf->hw_mode = mode->mode;
1121 if (!iface->current_mode) {
1122 wpa_printf(MSG_ERROR, "ACS/CSA: Cannot decide mode");
1123 return -1;
1132 if (iface->freq) {
1151 switch (acs_init(iface)) {
1166 if (!iface->current_mode) {
1167 hostapd_logger(iface->bss[0], NULL, HOSTAPD_MODULE_IEEE80211,
1169 "Hardware does not support configured mode");
1172 hostapd_logger(iface->bss[0], NULL,
1175 "Configured channel (%d) or frequency (%d) (secondary_channel=%d) not found from the channel list of the current mode (%d) %s",
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,
1188 int ret = -1;
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);
1201 wpa_printf(MSG_ERROR, "ACS error - reported complete, but no result available");
1202 wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, ACS_EVENT_FAILED);
1206 iface->is_no_ir = true;
1211 wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, ACS_EVENT_FAILED);
1231 * hostapd_csa_update_hwmode - Update hardware mode
1235 * Update hardware mode when the operating channel changed because of CSA.
1239 if (!iface || !iface->conf)
1240 return -1;
1242 iface->current_mode = NULL;
1243 iface->conf->hw_mode = HOSTAPD_MODE_IEEE80211ANY;
1250 * hostapd_select_hw_mode - Select the hardware mode
1254 * Sets up the hardware mode, channel, rates, and passive scanning
1261 if (iface->num_hw_features < 1)
1262 return -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) {
1300 "Hardware does not support configured mode");
1301 hostapd_logger(iface->bss[0], NULL,
1304 "Hardware does not support configured mode (%d) (hw_mode in hostapd.conf)",
1305 (int) iface->conf->hw_mode);
1306 return -2;
1310 switch (hostapd_check_chans(iface)) {
1312 iface->is_no_ir = false;
1317 iface->is_no_ir = true;
1322 return -3;
1327 const char * hostapd_hw_mode_txt(int mode)
1329 switch (mode) {
1346 return hw_get_freq(hapd->iface->current_mode, chan);
1353 struct hostapd_hw_modes *mode;
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);
1364 * mode did not include the specified frequency. */
1365 if (!hapd->iface->hw_features)
1367 for (i = 0; i < hapd->iface->num_hw_features; i++) {
1368 mode = &hapd->iface->hw_features[i];
1369 channel = hw_get_chan(mode->mode, freq,
1370 hapd->iface->hw_features,
1371 hapd->iface->num_hw_features);
1380 struct hostapd_hw_modes *mode)
1384 if (iface->current_mode)
1385 return mode != iface->current_mode;
1386 if (mode->mode != HOSTAPD_MODE_IEEE80211B)
1388 for (i = 0; i < iface->num_hw_features; i++) {
1389 if (iface->hw_features[i].mode == HOSTAPD_MODE_IEEE80211G)