Revert "Extract BSS coex 40 MHz check into a separate function"

This reverts commit 3af78a4e04.

This commit prepares a refactor for another patch, which is being
reverted.

Signed-off-by: Matthew Wang <matthewmwang@chromium.org>
This commit is contained in:
Matthew Wang 2021-12-10 09:59:23 -08:00 committed by Jouni Malinen
parent e480321f8c
commit 7db757aac4
2 changed files with 62 additions and 80 deletions

View file

@ -293,30 +293,37 @@ static int check_20mhz_bss(struct wpa_scan_res *bss, int pri_freq, int start,
} }
/* int check_40mhz_2g4(struct hostapd_hw_modes *mode,
* Returns: struct wpa_scan_results *scan_res, int pri_chan,
* 0: no impact int sec_chan)
* 1: overlapping BSS
* 2: overlapping BSS with 40 MHz intolerant advertisement
*/
int check_bss_coex_40mhz(struct wpa_scan_res *bss, int pri_freq, int sec_freq)
{ {
int pri_freq, sec_freq;
int affected_start, affected_end; int affected_start, affected_end;
struct ieee802_11_elems elems; size_t i;
int pri_chan, sec_chan;
int pri = bss->freq;
int sec = pri;
if (pri_freq == sec_freq) if (!mode || !scan_res || !pri_chan || !sec_chan ||
return 1; pri_chan == sec_chan)
return 0;
pri_freq = hw_get_freq(mode, pri_chan);
sec_freq = hw_get_freq(mode, sec_chan);
affected_start = (pri_freq + sec_freq) / 2 - 25; affected_start = (pri_freq + sec_freq) / 2 - 25;
affected_end = (pri_freq + sec_freq) / 2 + 25; affected_end = (pri_freq + sec_freq) / 2 + 25;
wpa_printf(MSG_DEBUG, "40 MHz affected channel range: [%d,%d] MHz",
affected_start, affected_end);
for (i = 0; i < scan_res->num; i++) {
struct wpa_scan_res *bss = scan_res->res[i];
int pri = bss->freq;
int sec = pri;
struct ieee802_11_elems elems;
/* Check for overlapping 20 MHz BSS */ /* Check for overlapping 20 MHz BSS */
if (check_20mhz_bss(bss, pri_freq, affected_start, affected_end)) { if (check_20mhz_bss(bss, pri_freq, affected_start,
wpa_printf(MSG_DEBUG, "Overlapping 20 MHz BSS is found"); affected_end)) {
return 1; wpa_printf(MSG_DEBUG,
"Overlapping 20 MHz BSS is found");
return 0;
} }
get_pri_sec_chan(bss, &pri_chan, &sec_chan); get_pri_sec_chan(bss, &pri_chan, &sec_chan);
@ -330,7 +337,7 @@ int check_bss_coex_40mhz(struct wpa_scan_res *bss, int pri_freq, int sec_freq)
if ((pri < affected_start || pri > affected_end) && if ((pri < affected_start || pri > affected_end) &&
(sec < affected_start || sec > affected_end)) (sec < affected_start || sec > affected_end))
return 0; /* not within affected channel range */ continue; /* not within affected channel range */
wpa_printf(MSG_DEBUG, "Neighboring BSS: " MACSTR wpa_printf(MSG_DEBUG, "Neighboring BSS: " MACSTR
" freq=%d pri=%d sec=%d", " freq=%d pri=%d sec=%d",
@ -346,11 +353,12 @@ int check_bss_coex_40mhz(struct wpa_scan_res *bss, int pri_freq, int sec_freq)
pri, sec, pri_chan, pri, sec, pri_chan,
sec > pri ? '+' : '-', sec > pri ? '+' : '-',
pri_freq, sec_freq); pri_freq, sec_freq);
return 1; return 0;
} }
} }
ieee802_11_parse_elems((u8 *) (bss + 1), bss->ie_len, &elems, 0); ieee802_11_parse_elems((u8 *) (bss + 1), bss->ie_len, &elems,
0);
if (elems.ht_capabilities) { if (elems.ht_capabilities) {
struct ieee80211_ht_capabilities *ht_cap = struct ieee80211_ht_capabilities *ht_cap =
(struct ieee80211_ht_capabilities *) (struct ieee80211_ht_capabilities *)
@ -361,34 +369,9 @@ int check_bss_coex_40mhz(struct wpa_scan_res *bss, int pri_freq, int sec_freq)
wpa_printf(MSG_DEBUG, wpa_printf(MSG_DEBUG,
"40 MHz Intolerant is set on channel %d in BSS " "40 MHz Intolerant is set on channel %d in BSS "
MACSTR, pri, MAC2STR(bss->bssid)); MACSTR, pri, MAC2STR(bss->bssid));
return 2; return 0;
} }
} }
return 0;
}
int check_40mhz_2g4(struct hostapd_hw_modes *mode,
struct wpa_scan_results *scan_res, int pri_chan,
int sec_chan)
{
int pri_freq, sec_freq;
size_t i;
if (!mode || !scan_res || !pri_chan || !sec_chan ||
pri_chan == sec_chan)
return 0;
pri_freq = hw_get_freq(mode, pri_chan);
sec_freq = hw_get_freq(mode, sec_chan);
wpa_printf(MSG_DEBUG, "40 MHz affected channel range: [%d,%d] MHz",
(pri_freq + sec_freq) / 2 - 25,
(pri_freq + sec_freq) / 2 + 25);
for (i = 0; i < scan_res->num; i++) {
if (check_bss_coex_40mhz(scan_res->res[i], pri_freq, sec_freq))
return 0;
} }
return 1; return 1;

View file

@ -32,7 +32,6 @@ void get_pri_sec_chan(struct wpa_scan_res *bss, int *pri_chan, int *sec_chan);
int check_40mhz_5g(struct wpa_scan_results *scan_res, int check_40mhz_5g(struct wpa_scan_results *scan_res,
struct hostapd_channel_data *pri_chan, struct hostapd_channel_data *pri_chan,
struct hostapd_channel_data *sec_chan); struct hostapd_channel_data *sec_chan);
int check_bss_coex_40mhz(struct wpa_scan_res *bss, int pri_freq, int sec_freq);
int check_40mhz_2g4(struct hostapd_hw_modes *mode, int check_40mhz_2g4(struct hostapd_hw_modes *mode,
struct wpa_scan_results *scan_res, int pri_chan, struct wpa_scan_results *scan_res, int pri_chan,
int sec_chan); int sec_chan);