[PATCH] P2P: Include only 6GHz PSC channels in full scan
Ilan Peer
ilan.peer at intel.com
Wed May 11 02:40:36 PDT 2022
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 PSC channels.
When performing a full scan for P2P discovery, include
only the 6GHz PSC channels (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
60GHz channels in P2P full scan.
Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
wpa_supplicant/p2p_supplicant.c | 44 ++++++++++++++++++++-------
wpa_supplicant/scan.c | 53 +++++++++++++++------------------
wpa_supplicant/scan.h | 2 +-
3 files changed, 58 insertions(+), 41 deletions(-)
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index a996b436b4..19bdb286c5 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -358,14 +358,22 @@ 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");
+ if (!params->freqs) {
wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211G, params,
- 0);
+ false, false);
wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211A, params,
- 0);
+ false, false);
+ wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211AD,
+ params, false, false);
+
+ /* include only PSC channels for P2P scan */
+ if (params->p2p_include_6ghz)
+ wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211A,
+ params, true, true);
+ else
+ wpa_printf(MSG_DEBUG, "P2P: Exclude 6 GHz channels");
}
+
ret = wpa_drv_scan(wpa_s, params);
if (ret == 0)
wpa_s->curr_scan_cookie = params->scan_cookie;
@@ -444,6 +452,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 that 6GHz channels are requested as part of the P2P scan,
+ * only the PSC channels 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) {
@@ -5499,14 +5514,21 @@ 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");
+ } else {
wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211G, ¶ms,
- 0);
+ false, false);
wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211A, ¶ms,
- 0);
+ false, false);
+ wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211AD,
+ ¶ms, false, false);
+
+ /* include only PSC channels for P2P scan */
+ if (!wpa_s->conf->p2p_6ghz_disable &&
+ is_p2p_allow_6ghz(wpa_s->global->p2p))
+ wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211A,
+ ¶ms, true, true);
+ else
+ wpa_printf(MSG_DEBUG, "P2P: 6 GHz disabled");
}
ielen = p2p_scan_ie_buf_len(wpa_s->global->p2p);
diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c
index 102c544d4f..2d52bad474 100644
--- a/wpa_supplicant/scan.c
+++ b/wpa_supplicant/scan.c
@@ -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;
@@ -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);
}
@@ -1368,31 +1374,20 @@ 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);
- }
+ (wpa_s->p2p_in_invitation || wpa_s->p2p_in_provisioning)) {
+ wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211A,
+ ¶ms, false, false);
+ wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211G,
+ ¶ms, false, false);
+ wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211AD,
+ ¶ms, false, false);
+
+ if (is_p2p_allow_6ghz(wpa_s->global->p2p) &&
+ is_6ghz_supported(wpa_s))
+ wpa_add_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211A,
+ & params, true, true);
+ else
+ wpa_printf(MSG_DEBUG, "P2P: 6 GHz disabled");
}
#endif /* CONFIG_P2P */
diff --git a/wpa_supplicant/scan.h b/wpa_supplicant/scan.h
index d1780eb099..ad57064a88 100644
--- a/wpa_supplicant/scan.h
+++ b/wpa_supplicant/scan.h
@@ -91,6 +91,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 */
--
2.25.1
More information about the Hostap
mailing list