From 4bf78a79d0229488b5a02e30d736ff5665cf6c84 Mon Sep 17 00:00:00 2001 From: Vamsi Krishna Date: Tue, 24 Dec 2019 17:31:39 +0530 Subject: [PATCH] ACS: Populate channel config from external ACS per documented behavior Based on the now documented seg0/seg1 values from offloaded ACS, there is a mismatch between the driver interface and internal hostapd use. The value of segment0 field in ACS results is the index of the channel center frequency for 20 MHz, 40 MHz, and 80M Hz channels. The value is the center frequency index of the primary 80 MHz segment for 160 MHz and 80+80 MHz channels. The value of segment1 field in ACS results is zero for 20 MHz, 40 MHz, and 80 MHz channels. The value is the index of the channel center frequency for 160 MHz channels and the center frequency index of the secondary 80 MHz segment for 80+80 MHz channels. However, in struct hostapd_config, for 160 MHz channels, the value of the segment0 field is the index of the channel center frequency of 160 MHz channel and the value of the segment1 field is zero. Map the values from ACS event into hostapd_config fields accordingly. Signed-off-by: Jouni Malinen --- src/ap/drv_callbacks.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c index 8a4b0ef6a..fdd845573 100644 --- a/src/ap/drv_callbacks.c +++ b/src/ap/drv_callbacks.c @@ -1010,27 +1010,28 @@ void hostapd_acs_channel_selected(struct hostapd_data *hapd, hostapd_set_oper_centr_freq_seg1_idx(hapd->iconf, 0); hostapd_set_oper_centr_freq_seg0_idx(hapd->iconf, 0); hostapd_set_oper_chwidth(hapd->iconf, CHANWIDTH_USE_HT); - if (acs_res->ch_width == 80) { - hostapd_set_oper_centr_freq_seg0_idx( - hapd->iconf, acs_res->vht_seg0_center_ch); - hostapd_set_oper_chwidth(hapd->iconf, CHANWIDTH_80MHZ); - } else if (acs_res->ch_width == 160) { - if (acs_res->vht_seg1_center_ch == 0) { + if (acs_res->ch_width == 40) { + if (is_6ghz_freq(acs_res->pri_freq)) hostapd_set_oper_centr_freq_seg0_idx( hapd->iconf, acs_res->vht_seg0_center_ch); + } else if (acs_res->ch_width == 80) { + hostapd_set_oper_centr_freq_seg0_idx( + hapd->iconf, acs_res->vht_seg0_center_ch); + if (acs_res->vht_seg1_center_ch == 0) { hostapd_set_oper_chwidth(hapd->iconf, - CHANWIDTH_160MHZ); + CHANWIDTH_80MHZ); } else { - hostapd_set_oper_centr_freq_seg0_idx( - hapd->iconf, - acs_res->vht_seg0_center_ch); + hostapd_set_oper_chwidth(hapd->iconf, + CHANWIDTH_80P80MHZ); hostapd_set_oper_centr_freq_seg1_idx( hapd->iconf, acs_res->vht_seg1_center_ch); - hostapd_set_oper_chwidth(hapd->iconf, - CHANWIDTH_80P80MHZ); } + } else if (acs_res->ch_width == 160) { + hostapd_set_oper_chwidth(hapd->iconf, CHANWIDTH_160MHZ); + hostapd_set_oper_centr_freq_seg0_idx( + hapd->iconf, acs_res->vht_seg1_center_ch); } } -- 2.47.3