Lines Matching +full:switch +full:- +full:mode +full:- +full:frequency

2  * DFS - Dynamic Frequency Selection
3 * Copyright (c) 2002-2013, Jouni Malinen <j@w1.fi>
4 * Copyright (c) 2013-2017, Qualcomm Atheros, Inc.
25 DFS_AVAILABLE, /* non-radar or radar-available */
26 DFS_NO_CAC_YET, /* radar-not-yet-available */
38 return (iface->drv_flags2 & WPA_DRIVER_FLAGS2_RADAR_BACKGROUND) &&
39 iface->conf->enable_background_radar;
49 if (iface->conf->ieee80211n && iface->conf->secondary_channel)
52 if (iface->conf->ieee80211ac || iface->conf->ieee80211ax) {
53 switch (hostapd_get_oper_chwidth(iface->conf)) {
83 if ((chan->flag & HOSTAPD_CHAN_RADAR) &&
84 (chan->flag & HOSTAPD_CHAN_DFS_MASK) ==
95 if (type == DFS_AVAILABLE && (chan->flag & HOSTAPD_CHAN_RADAR) &&
96 ((chan->flag & HOSTAPD_CHAN_DFS_MASK) !=
100 if (chan->flag & HOSTAPD_CHAN_DISABLED)
102 if ((chan->flag & HOSTAPD_CHAN_RADAR) &&
103 ((chan->flag & HOSTAPD_CHAN_DFS_MASK) ==
119 * VHT80, valid channels based on center frequency:
124 * VHT160 valid channels based on center frequency:
131 switch (n_chans) {
150 if (chan->chan == allowed[i])
159 dfs_get_chan_data(struct hostapd_hw_modes *mode, int freq, int first_chan_idx)
163 for (i = first_chan_idx; i < mode->num_channels; i++) {
164 if (mode->channels[i].freq == freq)
165 return &mode->channels[i];
172 static int dfs_chan_range_available(struct hostapd_hw_modes *mode,
180 if (first_chan_idx + num_chans > mode->num_channels) {
186 first_chan = &mode->channels[first_chan_idx];
197 chan = dfs_get_chan_data(mode, first_chan->freq + i * 20,
201 first_chan->freq + i * 20);
209 first_chan->freq + i * 20);
215 first_chan->freq + i * 20);
227 if (!iface->conf->acs_ch_list.num)
230 return freq_range_list_includes(&iface->conf->acs_ch_list, chan->chan);
237 * - hapd->secondary_channel
238 * - hapd->vht/he_oper_centr_freq_seg0_idx
239 * - hapd->vht/he_oper_centr_freq_seg1_idx
245 struct hostapd_hw_modes *mode;
249 mode = iface->current_mode;
253 for (i = 0; i < mode->num_channels; i++) {
254 chan = &mode->channels[i];
257 if (iface->conf->ieee80211n &&
258 iface->conf->secondary_channel &&
260 !(chan->allowed_bw & HOSTAPD_CHAN_WIDTH_40P))) {
263 chan->freq, chan->chan);
268 if (!dfs_chan_range_available(mode, i, n_chans, type)) {
271 chan->freq, chan->chan);
278 chan->freq, chan->chan);
282 if (chan->max_tx_power < iface->conf->min_tx_power)
285 if ((chan->flag & HOSTAPD_CHAN_INDOOR_ONLY) &&
286 iface->conf->country[2] == 0x4f)
291 chan->freq, chan->chan);
296 chan->freq, chan->chan);
310 if (!iface->conf->ieee80211ac && !iface->conf->ieee80211ax)
318 switch (hostapd_get_oper_chwidth(iface->conf)) {
321 *oper_centr_freq_seg0_idx = chan->chan + 2;
322 else if (secondary_channel == -1)
323 *oper_centr_freq_seg0_idx = chan->chan - 2;
325 *oper_centr_freq_seg0_idx = chan->chan;
328 *oper_centr_freq_seg0_idx = chan->chan + 6;
331 *oper_centr_freq_seg0_idx = chan->chan + 14;
334 *oper_centr_freq_seg0_idx = chan->chan + 6;
345 wpa_printf(MSG_DEBUG, "DFS adjusting VHT center frequency: %d, %d",
351 /* Return start channel idx we will use for mode->channels[idx] */
354 struct hostapd_hw_modes *mode;
356 int channel_no = iface->conf->channel;
357 int res = -1, i;
358 int chan_seg1 = -1;
360 *seg1_start = -1;
362 /* HT40- */
363 if (iface->conf->ieee80211n && iface->conf->secondary_channel == -1)
364 channel_no -= 4;
367 if (iface->conf->ieee80211ac || iface->conf->ieee80211ax ||
368 iface->conf->ieee80211be) {
369 switch (hostapd_get_oper_chwidth(iface->conf)) {
374 iface->conf) - 6;
378 iface->conf) - 14;
382 iface->conf) - 6;
384 iface->conf) - 6;
388 iface->conf) - 30;
393 channel_no = -1;
399 mode = iface->current_mode;
400 for (i = 0; i < mode->num_channels; i++) {
401 chan = &mode->channels[i];
402 if (chan->chan == channel_no) {
408 if (res != -1 && chan_seg1 > -1) {
412 mode = iface->current_mode;
413 for (i = 0; i < mode->num_channels; i++) {
414 chan = &mode->channels[i];
415 if (chan->chan == chan_seg1) {
422 res = -1;
425 if (res == -1) {
427 "DFS chan_idx seems wrong; num-ch: %d ch-no: %d conf-ch-no: %d 11n: %d sec-ch: %d vht-oper-width: %d",
428 mode->num_channels, channel_no, iface->conf->channel,
429 iface->conf->ieee80211n,
430 iface->conf->secondary_channel,
431 hostapd_get_oper_chwidth(iface->conf));
433 for (i = 0; i < mode->num_channels; i++) {
435 mode->channels[i].chan);
448 struct hostapd_hw_modes *mode;
451 mode = iface->current_mode;
454 if (start_chan_idx + i >= mode->num_channels)
456 channel = &mode->channels[start_chan_idx + i];
457 if (channel->flag & HOSTAPD_CHAN_RADAR)
470 struct hostapd_hw_modes *mode;
473 mode = iface->current_mode;
476 channel = &mode->channels[start_chan_idx + i];
478 if (channel->flag & HOSTAPD_CHAN_DISABLED)
481 if (!(channel->flag & HOSTAPD_CHAN_RADAR))
484 if ((channel->flag & HOSTAPD_CHAN_DFS_MASK) !=
499 struct hostapd_hw_modes *mode;
502 mode = iface->current_mode;
505 channel = &mode->channels[start_chan_idx + i];
506 if (channel->flag & HOSTAPD_CHAN_DISABLED)
508 if ((channel->flag & HOSTAPD_CHAN_DFS_MASK) ==
524 struct hostapd_hw_modes *mode;
529 int sec_chan_idx_80p80 = -1;
538 if (iface->current_mode == NULL)
541 mode = iface->current_mode;
542 if (mode->mode != HOSTAPD_MODE_IEEE80211A)
563 chan->freq, chan->chan);
566 if (iface->conf->secondary_channel)
572 if (hostapd_get_oper_chwidth(iface->conf) ==
584 for (i = 0; i < num_available_chandefs - 1; i++) {
585 /* start from chan_idx + 1, end when chan_idx - 1 */
588 if (chan2 && abs(chan2->chan - chan->chan) > 12) {
590 sec_chan_idx_80p80 = chan2->chan;
593 chan2->freq, chan2->chan);
601 if (sec_chan_idx_80p80 == -1) {
629 return -1;
632 iface->freq = channel->freq;
633 iface->conf->channel = channel->chan;
634 iface->conf->secondary_channel = sec;
635 hostapd_set_oper_centr_freq_seg0_idx(iface->conf, cf1);
636 hostapd_set_oper_centr_freq_seg1_idx(iface->conf, cf2);
644 struct hostapd_hw_modes *mode;
648 mode = iface->current_mode;
649 if (mode == NULL)
653 for (i = 0; i < iface->current_mode->num_channels; i++) {
654 chan = &iface->current_mode->channels[i];
655 if (chan->freq == freq) {
656 if (chan->flag & HOSTAPD_CHAN_RADAR) {
657 chan->flag &= ~HOSTAPD_CHAN_DFS_MASK;
658 chan->flag |= state;
673 struct hostapd_hw_modes *mode;
674 int frequency = freq;
678 mode = iface->current_mode;
679 if (mode == NULL)
682 if (mode->mode != HOSTAPD_MODE_IEEE80211A) {
688 switch (chan_width) {
692 if (frequency == 0)
693 frequency = cf1;
697 frequency = cf1 - 10;
701 frequency = cf1 - 30;
705 frequency = cf1 - 30;
706 frequency2 = cf2 - 30;
710 frequency = cf1 - 70;
718 wpa_printf(MSG_DEBUG, "DFS freq: %dMHz, n_chans: %d", frequency,
721 ret += set_dfs_state_freq(iface, frequency, state);
722 frequency = frequency + 20;
738 struct hostapd_hw_modes *mode;
740 int n_chans, n_chans1, i, j, frequency = freq, radar_n_chans = 1;
745 mode = iface->current_mode;
754 switch (chan_width) {
758 if (frequency == 0)
759 frequency = cf1;
763 frequency = cf1 - 10;
767 frequency = cf1 - 30;
771 frequency = cf1 - 70;
779 ieee80211_freq_to_chan(frequency, &radar_chan);
782 chan = &mode->channels[start_chan_idx + i];
783 if (!(chan->flag & HOSTAPD_CHAN_RADAR))
787 chan->chan, radar_chan + j * 4);
788 if (chan->chan == radar_chan + j * 4)
803 struct hostapd_hw_modes *mode;
807 mode = iface->current_mode;
810 if (start_chan_idx + i >= mode->num_channels)
812 channel = &mode->channels[start_chan_idx + i];
813 if (!(channel->flag & HOSTAPD_CHAN_RADAR))
815 if (channel->dfs_cac_ms > cac_time_ms)
816 cac_time_ms = channel->dfs_cac_ms;
825 * 1 - continue channel/ap setup
826 * 0 - channel/ap setup will be continued after CAC
827 * -1 - hit critical error
834 if (is_6ghz_freq(iface->freq))
837 if (!iface->current_mode) {
839 * This can happen with drivers that do not provide mode
843 "DFS: No current_mode information - assume no need to perform DFS operations by hostapd");
847 iface->cac_started = 0;
853 if (start_chan_idx == -1)
854 return -1;
860 iface->dfs_cac_ms = dfs_get_cac_time(iface, start_chan_idx,
882 wpa_printf(MSG_DEBUG, "DFS %d chans unavailable - choose other channel: %s",
894 wpa_printf(MSG_DEBUG, "DFS start CAC on %d MHz%s", iface->freq,
896 wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_CAC_START
898 iface->freq,
899 iface->conf->channel, iface->conf->secondary_channel,
900 hostapd_get_oper_chwidth(iface->conf),
901 hostapd_get_oper_centr_freq_seg0_idx(iface->conf),
902 hostapd_get_oper_centr_freq_seg1_idx(iface->conf),
903 iface->dfs_cac_ms / 1000);
906 iface, iface->conf->hw_mode, iface->freq, iface->conf->channel,
907 iface->conf->ieee80211n, iface->conf->ieee80211ac,
908 iface->conf->ieee80211ax, iface->conf->ieee80211be,
909 iface->conf->secondary_channel,
910 hostapd_get_oper_chwidth(iface->conf),
911 hostapd_get_oper_centr_freq_seg0_idx(iface->conf),
912 hostapd_get_oper_centr_freq_seg1_idx(iface->conf),
917 return -1;
922 iface->radar_background.channel = iface->conf->channel;
923 iface->radar_background.secondary_channel =
924 iface->conf->secondary_channel;
925 iface->radar_background.freq = iface->freq;
926 iface->radar_background.centr_freq_seg0_idx =
927 hostapd_get_oper_centr_freq_seg0_idx(iface->conf);
928 iface->radar_background.centr_freq_seg1_idx =
929 hostapd_get_oper_centr_freq_seg1_idx(iface->conf);
939 iface->radar_background.temp_ch = 1;
971 struct hostapd_hw_modes *cmode = iface->current_mode;
978 wpa_printf(MSG_DEBUG, "DFS will switch to a new channel %d", channel);
979 wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_NEW_CHANNEL
983 new_vht_oper_chwidth = hostapd_get_oper_chwidth(iface->conf);
984 hostapd_set_oper_chwidth(iface->conf, current_vht_oper_chwidth);
990 csa_settings.link_id = -1;
992 if (iface->bss[0]->conf->mld_ap)
993 csa_settings.link_id = iface->bss[0]->mld_link_id;
996 if (iface->mconf)
1000 iface->conf->hw_mode,
1002 iface->conf->enable_edmg,
1003 iface->conf->edmg_channel,
1004 iface->conf->ieee80211n,
1005 iface->conf->ieee80211ac,
1006 iface->conf->ieee80211ax,
1007 iface->conf->ieee80211be,
1012 cmode->vht_capab,
1013 &cmode->he_capab[ieee80211_mode],
1014 &cmode->eht_capab[ieee80211_mode],
1015 hostapd_get_punct_bitmap(iface->bss[0]));
1024 for (i = 0; i < iface->num_bss; i++) {
1025 err = hostapd_switch_channel(iface->bss[i], &csa_settings);
1030 if (num_err == iface->num_bss) {
1032 "DFS failed to schedule CSA (%d) - trying fallback",
1034 iface->freq = freq;
1035 iface->conf->channel = channel;
1036 iface->conf->secondary_channel = secondary_channel;
1037 hostapd_set_oper_chwidth(iface->conf, new_vht_oper_chwidth);
1038 hostapd_set_oper_centr_freq_seg0_idx(iface->conf,
1040 hostapd_set_oper_centr_freq_seg1_idx(iface->conf,
1051 wpa_printf(MSG_DEBUG, "DFS waiting channel switch event");
1069 if (iface->dfs_domain == HOSTAPD_DFS_REGION_ETSI)
1076 channel->chan == iface->conf->channel ||
1077 channel->chan == iface->radar_background.channel)
1083 hostapd_start_dfs_cac(iface, iface->conf->hw_mode,
1084 channel->freq, channel->chan,
1085 iface->conf->ieee80211n,
1086 iface->conf->ieee80211ac,
1087 iface->conf->ieee80211ax,
1088 iface->conf->ieee80211be,
1089 sec, hostapd_get_oper_chwidth(iface->conf),
1093 iface->radar_background.channel = -1;
1097 iface->radar_background.channel = channel->chan;
1098 iface->radar_background.freq = channel->freq;
1099 iface->radar_background.secondary_channel = sec;
1100 iface->radar_background.centr_freq_seg0_idx = oper_centr_freq_seg0_idx;
1101 iface->radar_background.centr_freq_seg1_idx = oper_centr_freq_seg1_idx;
1105 __func__, channel->chan, channel->freq);
1113 iface->radar_background.channel != -1 &&
1114 iface->radar_background.freq == freq;
1121 u8 current_vht_oper_chwidth = hostapd_get_oper_chwidth(iface->conf);
1123 iface->conf->channel = iface->radar_background.channel;
1124 iface->freq = iface->radar_background.freq;
1125 iface->conf->secondary_channel =
1126 iface->radar_background.secondary_channel;
1128 iface->conf, iface->radar_background.centr_freq_seg0_idx);
1130 iface->conf, iface->radar_background.centr_freq_seg1_idx);
1135 iface, iface->conf->channel, iface->freq,
1136 iface->conf->secondary_channel, current_vht_oper_chwidth,
1137 hostapd_get_oper_centr_freq_seg0_idx(iface->conf),
1138 hostapd_get_oper_centr_freq_seg1_idx(iface->conf));
1146 wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_CAC_COMPLETED
1149 iface->radar_detected);
1153 if (iface->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD) {
1158 * non-DFS channel
1162 if (iface->state != HAPD_IFACE_ENABLED &&
1163 !iface->radar_detected)
1166 iface->cac_started = 0;
1179 iface->radar_background.cac_started = 0;
1180 if (!iface->radar_background.temp_ch)
1183 iface->radar_background.temp_ch = 0;
1192 * received during non-HAPD_IFACE_ENABLED state, make
1197 if (iface->state != HAPD_IFACE_ENABLED &&
1200 iface->cac_started = 0;
1204 iface->radar_background.cac_started = 0;
1208 iface->radar_detected = false;
1217 wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_PRE_CAC_EXPIRED
1222 if (iface->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD)
1247 channel->chan);
1256 oper_chwidth = hostapd_get_oper_chwidth(iface->conf);
1260 hostapd_set_oper_chwidth(iface->conf, oper_chwidth - 1);
1281 iface->cac_started = 0;
1298 wpa_printf(MSG_DEBUG, "DFS will switch to a new channel %d",
1299 channel->chan);
1300 wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_NEW_CHANNEL
1301 "freq=%d chan=%d sec_chan=%d", channel->freq,
1302 channel->chan, secondary_channel);
1304 iface->freq = channel->freq;
1305 iface->conf->channel = channel->chan;
1306 iface->conf->secondary_channel = secondary_channel;
1307 hostapd_set_oper_centr_freq_seg0_idx(iface->conf,
1309 hostapd_set_oper_centr_freq_seg1_idx(iface->conf,
1323 return -1; /* Background radar chain not supported. */
1327 __func__, iface->radar_background.cac_started ? "yes" : "no",
1346 * monitored by the background chain is available switch to it without
1349 if (iface->radar_background.channel == -1)
1350 return -1; /* Background radar chain not available. */
1352 if (iface->radar_background.cac_started) {
1357 iface->radar_background.temp_ch = 1;
1358 return -1;
1372 u8 current_vht_oper_chwidth = hostapd_get_oper_chwidth(iface->conf);
1375 __func__, iface->cac_started ? "yes" : "no",
1383 if (iface->cac_started)
1390 if (iface->dfs_domain == HOSTAPD_DFS_REGION_ETSI)
1393 /* Perform channel switch/CSA */
1401 * If there is no channel to switch immediately to, check if
1402 * there is another channel where we can switch even if it
1421 iface->freq = channel->freq;
1422 iface->conf->channel = channel->chan;
1423 iface->conf->secondary_channel = secondary_channel;
1425 iface->conf, oper_centr_freq_seg0_idx);
1427 iface->conf, oper_centr_freq_seg1_idx);
1435 return hostapd_dfs_request_channel_switch(iface, channel->chan,
1436 channel->freq,
1448 wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_RADAR_DETECTED
1452 iface->radar_detected = true;
1455 if (iface->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD)
1458 if (!iface->conf->ieee80211h)
1461 /* mark radar frequency as invalid */
1474 /* Radar detected while operating, switch the channel. */
1486 wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_NOP_FINISHED
1491 if (iface->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD)
1498 if (iface->state == HAPD_IFACE_DFS && !iface->cac_started) {
1502 iface->radar_background.channel == -1) {
1515 if ((!(iface->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD) &&
1516 !iface->conf->ieee80211h) ||
1517 !iface->current_mode ||
1518 iface->current_mode->mode != HOSTAPD_MODE_IEEE80211A)
1523 if (start_chan_idx == -1)
1524 return -1;
1544 iface->radar_background.cac_started = 1;
1550 iface->cac_started = 1;
1553 * frequency. Also remove disabled link's information in RNR
1555 iface->radar_detected = false;
1556 if (iface->interfaces && iface->interfaces->count > 1)
1560 iface->dfs_cac_ms = 60000;
1561 wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_CAC_START
1564 freq, (freq - 5000) / 5, chan_offset, chan_width, cf1, cf2,
1565 iface->dfs_cac_ms / 1000,
1569 os_get_reltime(&iface->dfs_cac_start);
1576 * 2 - continue channel/AP setup for non-DFS channel
1577 * 1 - continue channel/AP setup for DFS channel
1578 * 0 - channel/AP setup will be continued after CAC
1579 * -1 - hit critical error
1585 wpa_printf(MSG_DEBUG, "%s: iface->cac_started: %d",
1586 __func__, iface->cac_started);
1593 if (iface->cac_started) {
1594 wpa_printf(MSG_DEBUG, "%s: iface->cac_started: %d",
1595 __func__, iface->cac_started);
1596 iface->cac_started = 0;
1604 __func__, iface->freq, dfs_res);
1610 __func__, iface->freq);
1619 struct hostapd_hw_modes *mode = iface->current_mode;
1624 if (!iface->conf->ieee80211h || !mode ||
1625 mode->mode != HOSTAPD_MODE_IEEE80211A)
1628 switch (width) {
1649 for (i = 0; i < mode->num_channels; i++) {
1650 chan = &mode->channels[i];
1652 if (!(chan->flag & HOSTAPD_CHAN_RADAR))
1655 if ((chan->flag & HOSTAPD_CHAN_DFS_MASK) ==
1659 if (center_freq - chan->freq < half_width &&
1660 chan->freq - center_freq < half_width)
1665 center_freq - half_width, center_freq + half_width,