From 7dc7b88148de126454439dc8440777cd12ee6bac Mon Sep 17 00:00:00 2001 From: Sreeramya Soratkal Date: Tue, 28 Sep 2021 21:03:15 +0530 Subject: [PATCH] P2P: Remove 6 GHz channels from full scan if 6 GHz not enabled for P2P The channels included for the scan to connect to a P2P GO are optimized such that the P2P GO preferred channel and the common channels are included for the first few scans followed by a full scan in which all the channels supported by the local device are included. This results in P2P client including the 6 GHz channels for the full scan after GO Negotiation even when 6 GHz channels are not used for the P2P connection. Exclude the 6 GHz channels from the full scan if 6 GHz channels are supported but are not used for P2P connection. Signed-off-by: Sreeramya Soratkal --- wpa_supplicant/scan.c | 51 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c index 97a8d9a63..b8cba2ee9 100644 --- a/wpa_supplicant/scan.c +++ b/wpa_supplicant/scan.c @@ -392,6 +392,29 @@ wpa_supplicant_build_filter_ssids(struct wpa_config *conf, size_t *num_ssids) } +#ifdef CONFIG_P2P +static bool is_6ghz_supported(struct wpa_supplicant *wpa_s) +{ + struct hostapd_channel_data *chnl; + int i, j; + + for (i = 0; i < wpa_s->hw.num_modes; i++) { + if (wpa_s->hw.modes[i].mode == HOSTAPD_MODE_IEEE80211A) { + chnl = wpa_s->hw.modes[i].channels; + for (j = 0; j < wpa_s->hw.modes[i].num_channels; j++) { + if (chnl[j].flag & HOSTAPD_CHAN_DISABLED) + continue; + if (is_6ghz_freq(chnl[j].freq)) + return true; + } + } + } + + return false; +} +#endif /* CONFIG_P2P */ + + static void wpa_supplicant_optimize_freqs( struct wpa_supplicant *wpa_s, struct wpa_driver_scan_params *params) { @@ -1337,6 +1360,34 @@ scan: } } } + + if (!params.freqs && + (wpa_s->p2p_in_invitation || wpa_s->p2p_in_provisioning) && + !is_p2p_allow_6ghz(wpa_s->global->p2p) && + is_6ghz_supported(wpa_s)) { + int i; + + /* Exclude 5 GHz channels from the full scan for P2P connection + * since the 6 GHz band is disabled for P2P uses. */ + wpa_printf(MSG_DEBUG, + "P2P: 6 GHz disabled - update the scan frequency list"); + for (i = 0; i < wpa_s->hw.num_modes; i++) { + if (wpa_s->hw.modes[i].num_channels == 0) + continue; + if (wpa_s->hw.modes[i].mode == HOSTAPD_MODE_IEEE80211G) + wpa_add_scan_freqs_list( + wpa_s, HOSTAPD_MODE_IEEE80211G, + ¶ms, false); + if (wpa_s->hw.modes[i].mode == HOSTAPD_MODE_IEEE80211A) + wpa_add_scan_freqs_list( + wpa_s, HOSTAPD_MODE_IEEE80211A, + ¶ms, false); + if (wpa_s->hw.modes[i].mode == HOSTAPD_MODE_IEEE80211AD) + wpa_add_scan_freqs_list( + wpa_s, HOSTAPD_MODE_IEEE80211AD, + ¶ms, false); + } + } #endif /* CONFIG_P2P */ ret = wpa_supplicant_trigger_scan(wpa_s, scan_params);