P2P: Include only 6 GHz PSCs in full scan

As P2P GOs are not expected to be collocated, i.e., they are not
expected to be announced in the RNR element of other APs, they can
operate only on preferred scanning channels (PSCs).

When performing a full scan for P2P discovery, include only the 6 GHz
PSCs (if supported) to avoid scanning channels on which P2P GOs are not
expected to reside.

While at it also fix couple of places that missed including 60 GHz
channels in P2P full scan.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
This commit is contained in:
Ilan Peer 2022-05-11 12:40:36 +03:00 committed by Jouni Malinen
parent ef11556242
commit 50a9b7d3d3
4 changed files with 47 additions and 51 deletions

View file

@ -337,6 +337,23 @@ static void wpas_p2p_scan_res_fail_handler(struct wpa_supplicant *wpa_s)
}
void wpas_p2p_scan_freqs(struct wpa_supplicant *wpa_s,
struct wpa_driver_scan_params *params,
bool include_6ghz)
{
wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211A,
params, false, false);
wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211G,
params, false, false);
wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211AD,
params, false, false);
if (!wpa_s->conf->p2p_6ghz_disable &&
is_p2p_allow_6ghz(wpa_s->global->p2p) && include_6ghz)
wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211A,
params, true, true);
}
static void wpas_p2p_trigger_scan_cb(struct wpa_radio_work *work, int deinit)
{
struct wpa_supplicant *wpa_s = work->wpa_s;
@ -359,14 +376,9 @@ static void wpas_p2p_trigger_scan_cb(struct wpa_radio_work *work, int deinit)
params->only_new_results = 1;
}
if (!params->p2p_include_6ghz && !params->freqs) {
wpa_printf(MSG_DEBUG,
"P2P: Exclude 6 GHz channels - update the scan frequency list");
wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211G, params,
0);
wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211A, params,
0);
}
if (!params->freqs)
wpas_p2p_scan_freqs(wpa_s, params, params->p2p_include_6ghz);
ret = wpa_drv_scan(wpa_s, params);
if (ret == 0)
wpa_s->curr_scan_cookie = params->scan_cookie;
@ -445,6 +457,13 @@ static int wpas_p2p_scan(void *ctx, enum p2p_scan_type type, int freq,
num_req_dev_types, req_dev_types);
if (wps_ie == NULL)
goto fail;
/*
* In case 6 GHz channels are requested as part of the P2P scan, only
* the PSCs would be included as P2P GOs are not expected to be
* collocated, i.e., they would not be announced in the RNR element of
* other APs.
*/
if (!wpa_s->conf->p2p_6ghz_disable)
params->p2p_include_6ghz = include_6ghz;
switch (type) {
@ -5512,14 +5531,8 @@ static void wpas_p2p_join_scan_req(struct wpa_supplicant *wpa_s, int freq,
if (freq > 0) {
freqs[0] = freq;
params.freqs = freqs;
} else if (wpa_s->conf->p2p_6ghz_disable ||
!is_p2p_allow_6ghz(wpa_s->global->p2p)) {
wpa_printf(MSG_DEBUG,
"P2P: 6 GHz disabled - update the scan frequency list");
wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211G, &params,
0);
wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211A, &params,
0);
} else {
wpas_p2p_scan_freqs(wpa_s, &params, true);
}
ielen = p2p_scan_ie_buf_len(wpa_s->global->p2p);

View file

@ -146,6 +146,9 @@ struct wpa_ssid * wpas_p2p_get_persistent(struct wpa_supplicant *wpa_s,
void wpas_p2p_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
const u8 *addr);
int wpas_p2p_scan_no_go_seen(struct wpa_supplicant *wpa_s);
void wpas_p2p_scan_freqs(struct wpa_supplicant *wpa_s,
struct wpa_driver_scan_params *params,
bool include_6ghz);
int wpas_p2p_get_sec_channel_offset_40mhz(struct wpa_supplicant *wpa_s,
struct hostapd_hw_modes *mode,
u8 channel);

View file

@ -709,7 +709,8 @@ static int non_p2p_network_enabled(struct wpa_supplicant *wpa_s)
int wpa_add_scan_freqs_list(struct wpa_supplicant *wpa_s,
enum hostapd_hw_mode band,
struct wpa_driver_scan_params *params, bool is_6ghz)
struct wpa_driver_scan_params *params,
bool is_6ghz, bool only_6ghz_psc)
{
/* Include only supported channels for the specified band */
struct hostapd_hw_modes *mode;
@ -717,7 +718,7 @@ int wpa_add_scan_freqs_list(struct wpa_supplicant *wpa_s,
int *freqs, i;
mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes, band, is_6ghz);
if (!mode)
if (!mode || !mode->num_channels)
return -1;
if (params->freqs) {
@ -734,6 +735,11 @@ int wpa_add_scan_freqs_list(struct wpa_supplicant *wpa_s,
for (i = 0; i < mode->num_channels; i++) {
if (mode->channels[i].flag & HOSTAPD_CHAN_DISABLED)
continue;
if (is_6ghz && only_6ghz_psc &&
!is_6ghz_psc_frequency(mode->channels[i].freq))
continue;
params->freqs[num_chans++] = mode->channels[i].freq;
}
params->freqs[num_chans] = 0;
@ -752,13 +758,13 @@ static void wpa_setband_scan_freqs(struct wpa_supplicant *wpa_s,
if (wpa_s->setband_mask & WPA_SETBAND_5G)
wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211A, params,
false);
false, false);
if (wpa_s->setband_mask & WPA_SETBAND_2G)
wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211G, params,
false);
false, false);
if (wpa_s->setband_mask & WPA_SETBAND_6G)
wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211A, params,
true);
true, false);
}
@ -1374,35 +1380,9 @@ 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 6 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 (is_6ghz_freq(wpa_s->hw.modes[i].channels[0].freq))
continue;
if (wpa_s->hw.modes[i].mode == HOSTAPD_MODE_IEEE80211G)
wpa_add_scan_freqs_list(
wpa_s, HOSTAPD_MODE_IEEE80211G,
&params, false);
if (wpa_s->hw.modes[i].mode == HOSTAPD_MODE_IEEE80211A)
wpa_add_scan_freqs_list(
wpa_s, HOSTAPD_MODE_IEEE80211A,
&params, false);
if (wpa_s->hw.modes[i].mode == HOSTAPD_MODE_IEEE80211AD)
wpa_add_scan_freqs_list(
wpa_s, HOSTAPD_MODE_IEEE80211AD,
&params, false);
}
}
if (!params.freqs && is_6ghz_supported(wpa_s) &&
(wpa_s->p2p_in_invitation || wpa_s->p2p_in_provisioning))
wpas_p2p_scan_freqs(wpa_s, &params, true);
#endif /* CONFIG_P2P */
ret = wpa_supplicant_trigger_scan(wpa_s, scan_params);

View file

@ -92,6 +92,6 @@ void wpa_supplicant_set_default_scan_ies(struct wpa_supplicant *wpa_s);
int wpa_add_scan_freqs_list(struct wpa_supplicant *wpa_s,
enum hostapd_hw_mode band,
struct wpa_driver_scan_params *params,
bool is_6ghz);
bool is_6ghz, bool only_6ghz_psc);
#endif /* SCAN_H */