Lines Matching full:iface
30 dfs_downgrade_bandwidth(struct hostapd_iface *iface, int *secondary_channel,
36 static bool dfs_use_radar_background(struct hostapd_iface *iface)
38 return (iface->drv_flags2 & WPA_DRIVER_FLAGS2_RADAR_BACKGROUND) &&
39 iface->conf->enable_background_radar;
43 static int dfs_get_used_n_chans(struct hostapd_iface *iface, int *seg1)
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)) {
224 static int is_in_chanlist(struct hostapd_iface *iface,
227 if (!iface->conf->acs_ch_list.num)
230 return freq_range_list_includes(&iface->conf->acs_ch_list, chan->chan);
241 static int dfs_find_channel(struct hostapd_iface *iface,
249 mode = iface->current_mode;
250 n_chans = dfs_get_used_n_chans(iface, &n_chans1);
257 if (iface->conf->ieee80211n &&
258 iface->conf->secondary_channel &&
275 if (!is_in_chanlist(iface, chan)) {
282 if (chan->max_tx_power < iface->conf->min_tx_power)
286 iface->conf->country[2] == 0x4f)
303 static void dfs_adjust_center_freq(struct hostapd_iface *iface,
310 if (!iface->conf->ieee80211ac && !iface->conf->ieee80211ax)
318 switch (hostapd_get_oper_chwidth(iface->conf)) {
352 static int dfs_get_start_chan_idx(struct hostapd_iface *iface, int *seg1_start)
356 int channel_no = iface->conf->channel;
363 if (iface->conf->ieee80211n && iface->conf->secondary_channel == -1)
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;
399 mode = iface->current_mode;
412 mode = iface->current_mode;
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));
444 static int dfs_check_chans_radar(struct hostapd_iface *iface,
451 mode = iface->current_mode;
466 static int dfs_check_chans_available(struct hostapd_iface *iface,
473 mode = iface->current_mode;
494 static int dfs_check_chans_unavailable(struct hostapd_iface *iface,
502 mode = iface->current_mode;
518 dfs_get_valid_channel(struct hostapd_iface *iface,
538 if (iface->current_mode == NULL)
541 mode = iface->current_mode;
546 num_available_chandefs = dfs_find_channel(iface, NULL, 0, type);
557 dfs_find_channel(iface, &chan, chan_idx, type);
566 if (iface->conf->secondary_channel)
572 if (hostapd_get_oper_chwidth(iface->conf) ==
587 dfs_find_channel(iface, &chan2, chan_idx2, type);
608 dfs_adjust_center_freq(iface, chan,
618 static int dfs_set_valid_channel(struct hostapd_iface *iface, int skip_radar)
624 channel = dfs_get_valid_channel(iface, &sec, &cf1, &cf2,
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);
642 static int set_dfs_state_freq(struct hostapd_iface *iface, int freq, u32 state)
648 mode = iface->current_mode;
653 for (i = 0; i < iface->current_mode->num_channels; i++) {
654 chan = &iface->current_mode->channels[i];
668 static int set_dfs_state(struct hostapd_iface *iface, int freq, int ht_enabled,
678 mode = iface->current_mode;
721 ret += set_dfs_state_freq(iface, frequency, state);
725 ret += set_dfs_state_freq(iface, frequency2, state);
734 static int dfs_are_channels_overlapped(struct hostapd_iface *iface, int freq,
745 mode = iface->current_mode;
746 start_chan_idx = dfs_get_start_chan_idx(iface, &start_chan_idx1);
747 n_chans = dfs_get_used_n_chans(iface, &n_chans1);
750 if (!dfs_check_chans_radar(iface, start_chan_idx, n_chans))
799 static unsigned int dfs_get_cac_time(struct hostapd_iface *iface,
807 mode = iface->current_mode;
829 int hostapd_handle_dfs(struct hostapd_iface *iface)
834 if (is_6ghz_freq(iface->freq))
837 if (!iface->current_mode) {
847 iface->cac_started = 0;
851 start_chan_idx = dfs_get_start_chan_idx(iface,
857 n_chans = dfs_get_used_n_chans(iface, &n_chans1);
860 iface->dfs_cac_ms = dfs_get_cac_time(iface, start_chan_idx,
864 res = dfs_check_chans_radar(iface, start_chan_idx, n_chans);
872 res = dfs_check_chans_available(iface, start_chan_idx, n_chans);
880 res = dfs_check_chans_unavailable(iface, start_chan_idx,
885 if (dfs_set_valid_channel(iface, skip_radar) < 0) {
886 hostapd_set_state(iface, HAPD_IFACE_DFS);
893 hostapd_set_state(iface, HAPD_IFACE_DFS);
894 wpa_printf(MSG_DEBUG, "DFS start CAC on %d MHz%s", iface->freq,
895 dfs_use_radar_background(iface) ? " (background)" : "");
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),
913 dfs_use_radar_background(iface));
920 if (dfs_use_radar_background(iface)) {
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);
935 res = dfs_set_valid_channel(iface, 1);
939 iface->radar_background.temp_ch = 1;
947 int hostapd_is_dfs_chan_available(struct hostapd_iface *iface)
952 start_chan_idx = dfs_get_start_chan_idx(iface, &start_chan_idx1);
957 n_chans = dfs_get_used_n_chans(iface, &n_chans1);
960 return dfs_check_chans_available(iface, start_chan_idx, n_chans);
964 static int hostapd_dfs_request_channel_switch(struct hostapd_iface *iface,
971 struct hostapd_hw_modes *cmode = iface->current_mode;
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);
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,
1015 hostapd_get_punct_bitmap(iface->bss[0]));
1020 hostapd_disable_iface(iface);
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) {
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,
1043 hostapd_disable_iface(iface);
1044 hostapd_enable_iface(iface);
1057 static void hostapd_dfs_update_background_chain(struct hostapd_iface *iface)
1069 if (iface->dfs_domain == HOSTAPD_DFS_REGION_ETSI)
1072 channel = dfs_get_valid_channel(iface, &sec, &oper_centr_freq_seg0_idx,
1076 channel->chan == iface->conf->channel ||
1077 channel->chan == iface->radar_background.channel)
1078 channel = dfs_downgrade_bandwidth(iface, &sec,
1083 hostapd_start_dfs_cac(iface, iface->conf->hw_mode,
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;
1110 hostapd_dfs_is_background_event(struct hostapd_iface *iface, int freq)
1112 return dfs_use_radar_background(iface) &&
1113 iface->radar_background.channel != -1 &&
1114 iface->radar_background.freq == freq;
1119 hostapd_dfs_start_channel_switch_background(struct hostapd_iface *iface)
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);
1132 hostapd_dfs_update_background_chain(iface);
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));
1142 int hostapd_dfs_complete_cac(struct hostapd_iface *iface, int success, int freq,
1146 wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_CAC_COMPLETED
1149 iface->radar_detected);
1152 /* Complete iface/ap configuration */
1153 if (iface->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD) {
1162 if (iface->state != HAPD_IFACE_ENABLED &&
1163 !iface->radar_detected)
1164 hostapd_setup_interface_complete(iface, 0);
1166 iface->cac_started = 0;
1168 set_dfs_state(iface, freq, ht_enabled, chan_offset,
1178 if (hostapd_dfs_is_background_event(iface, freq)) {
1179 iface->radar_background.cac_started = 0;
1180 if (!iface->radar_background.temp_ch)
1183 iface->radar_background.temp_ch = 0;
1184 return hostapd_dfs_start_channel_switch_background(iface);
1197 if (iface->state != HAPD_IFACE_ENABLED &&
1198 hostapd_is_dfs_chan_available(iface)) {
1199 hostapd_setup_interface_complete(iface, 0);
1200 iface->cac_started = 0;
1203 } else if (hostapd_dfs_is_background_event(iface, freq)) {
1204 iface->radar_background.cac_started = 0;
1205 hostapd_dfs_update_background_chain(iface);
1208 iface->radar_detected = false;
1213 int hostapd_dfs_pre_cac_expired(struct hostapd_iface *iface, int freq,
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)
1225 set_dfs_state(iface, freq, ht_enabled, chan_offset, chan_width,
1233 dfs_downgrade_bandwidth(struct hostapd_iface *iface, int *secondary_channel,
1241 channel = dfs_get_valid_channel(iface, secondary_channel,
1256 oper_chwidth = hostapd_get_oper_chwidth(iface->conf);
1260 hostapd_set_oper_chwidth(iface->conf, oper_chwidth - 1);
1271 static int hostapd_dfs_start_channel_switch_cac(struct hostapd_iface *iface)
1281 iface->cac_started = 0;
1282 channel = dfs_get_valid_channel(iface, &secondary_channel,
1288 channel = dfs_downgrade_bandwidth(iface, &secondary_channel,
1300 wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_NEW_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,
1313 hostapd_setup_interface_complete(iface, err);
1319 hostapd_dfs_background_start_channel_switch(struct hostapd_iface *iface,
1322 if (!dfs_use_radar_background(iface))
1327 __func__, iface->radar_background.cac_started ? "yes" : "no",
1328 hostapd_csa_in_progress(iface) ? "yes" : "no");
1331 if (hostapd_csa_in_progress(iface))
1334 if (hostapd_dfs_is_background_event(iface, freq)) {
1340 hostapd_dfs_update_background_chain(iface);
1349 if (iface->radar_background.channel == -1)
1352 if (iface->radar_background.cac_started) {
1357 iface->radar_background.temp_ch = 1;
1361 return hostapd_dfs_start_channel_switch_background(iface);
1365 static int hostapd_dfs_start_channel_switch(struct hostapd_iface *iface)
1372 u8 current_vht_oper_chwidth = hostapd_get_oper_chwidth(iface->conf);
1375 __func__, iface->cac_started ? "yes" : "no",
1376 hostapd_csa_in_progress(iface) ? "yes" : "no");
1379 if (hostapd_csa_in_progress(iface))
1383 if (iface->cac_started)
1384 return hostapd_dfs_start_channel_switch_cac(iface);
1390 if (iface->dfs_domain == HOSTAPD_DFS_REGION_ETSI)
1394 channel = dfs_get_valid_channel(iface, &secondary_channel,
1406 channel = dfs_downgrade_bandwidth(iface, &secondary_channel,
1415 hostapd_disable_iface(iface);
1416 hostapd_enable_iface(iface);
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);
1429 hostapd_disable_iface(iface);
1430 hostapd_enable_iface(iface);
1435 return hostapd_dfs_request_channel_switch(iface, channel->chan,
1444 int hostapd_dfs_radar_detected(struct hostapd_iface *iface, int 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)
1462 if (!set_dfs_state(iface, freq, ht_enabled, chan_offset, chan_width,
1466 if (!hostapd_dfs_is_background_event(iface, freq)) {
1468 if (!dfs_are_channels_overlapped(iface, freq, chan_width,
1473 if (hostapd_dfs_background_start_channel_switch(iface, freq)) {
1475 return hostapd_dfs_start_channel_switch(iface);
1482 int hostapd_dfs_nop_finished(struct hostapd_iface *iface, int freq,
1486 wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_NOP_FINISHED
1491 if (iface->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD)
1495 set_dfs_state(iface, freq, ht_enabled, chan_offset, chan_width,
1498 if (iface->state == HAPD_IFACE_DFS && !iface->cac_started) {
1500 hostapd_handle_dfs(iface);
1501 } else if (dfs_use_radar_background(iface) &&
1502 iface->radar_background.channel == -1) {
1504 hostapd_dfs_update_background_chain(iface);
1511 int hostapd_is_dfs_required(struct hostapd_iface *iface)
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)
1522 start_chan_idx = dfs_get_start_chan_idx(iface, &start_chan_idx1);
1527 n_chans = dfs_get_used_n_chans(iface, &n_chans1);
1530 res = dfs_check_chans_radar(iface, start_chan_idx, n_chans);
1534 res = dfs_check_chans_radar(iface, start_chan_idx1, n_chans1);
1539 int hostapd_dfs_start_cac(struct hostapd_iface *iface, int freq,
1543 if (hostapd_dfs_is_background_event(iface, freq)) {
1544 iface->radar_background.cac_started = 1;
1549 hostapd_set_state(iface, HAPD_IFACE_DFS);
1550 iface->cac_started = 1;
1555 iface->radar_detected = false;
1556 if (iface->interfaces && iface->interfaces->count > 1)
1557 ieee802_11_set_beacons(iface);
1560 iface->dfs_cac_ms = 60000;
1561 wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_CAC_START
1565 iface->dfs_cac_ms / 1000,
1566 hostapd_dfs_is_background_event(iface, freq) ?
1569 os_get_reltime(&iface->dfs_cac_start);
1581 int hostapd_handle_dfs_offload(struct hostapd_iface *iface)
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;
1600 dfs_res = hostapd_is_dfs_required(iface);
1604 __func__, iface->freq, dfs_res);
1610 __func__, iface->freq);
1615 int hostapd_is_dfs_overlap(struct hostapd_iface *iface, enum chan_width width,
1619 struct hostapd_hw_modes *mode = iface->current_mode;
1624 if (!iface->conf->ieee80211h || !mode ||