From b18d95759375834b6ca6f864c898f27d161b14ca Mon Sep 17 00:00:00 2001 From: Sunil Ravi Date: Mon, 3 Oct 2022 00:53:41 +0000 Subject: [PATCH] P2P: Disable pri/sec channel switch for GO with forced frequency When wpa_supplicant receives a request to start a P2P group owner on a fixed frequency with bandwidth wider than 20 MHz, wpa_supplicant scans for neighboring BSSs prior to starting the GO. This is done to switch the primary/secondary channels if there are any other networks which are operating on the same secondary channel. Though this logic is defined for 20/40 MHz coexistence and might improve throughput, there are P2P use cases where this logic causes problem: 1. The file transfer use case takes time to start the file transfer or even fails when the 20/40 coex scan repeatedly fails due to an ongoing externally triggered scan happening in the system. 2. wpa_supplicant overrides the channel which is selected by the application based on the best channel it derived by looking into the channel conditions. This degrades the expected throughput. 3. Latency sensitive applications experience long time to start the group owner which gives a bad user experience. So do not allow 40 MHz co-ex PRI/SEC switch to force a change to Autonomous GO PRI channel when the P2P group add is called with a forced frequency. Test: Tested autonomous GO and confirmed from the logs that P2P GO is not triggering 20/40 coex scan. Signed-off-by: Sunil Ravi --- wpa_supplicant/ap.c | 4 +++- wpa_supplicant/p2p_supplicant.c | 11 ++++++++--- wpa_supplicant/wpa_supplicant_i.h | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c index 2d30ce409..ffe98fa8d 100644 --- a/wpa_supplicant/ap.c +++ b/wpa_supplicant/ap.c @@ -440,7 +440,9 @@ int wpa_supplicant_conf_ap_ht(struct wpa_supplicant *wpa_s, } } - if (conf->secondary_channel) { + if (wpa_s->p2p_go_no_pri_sec_switch) { + conf->no_pri_sec_switch = 1; + } else if (conf->secondary_channel) { struct wpa_supplicant *iface; for (iface = wpa_s->global->ifaces; iface; iface = iface->next) diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index 0904d60ef..f8e903362 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -6895,6 +6895,7 @@ int wpas_p2p_group_add(struct wpa_supplicant *wpa_s, int persistent_group, bool allow_6ghz) { struct p2p_go_neg_results params; + int selected_freq = 0; if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) return -1; @@ -6909,12 +6910,13 @@ int wpas_p2p_group_add(struct wpa_supplicant *wpa_s, int persistent_group, wpas_p2p_stop_find_oper(wpa_s); if (!wpa_s->p2p_go_do_acs) { - freq = wpas_p2p_select_go_freq(wpa_s, freq); - if (freq < 0) + selected_freq = wpas_p2p_select_go_freq(wpa_s, freq); + if (selected_freq < 0) return -1; } - if (wpas_p2p_init_go_params(wpa_s, ¶ms, freq, vht_center_freq2, + if (wpas_p2p_init_go_params(wpa_s, ¶ms, selected_freq, + vht_center_freq2, ht40, vht, max_oper_chwidth, he, edmg, NULL)) return -1; @@ -6925,6 +6927,8 @@ int wpas_p2p_group_add(struct wpa_supplicant *wpa_s, int persistent_group, wpa_s = wpas_p2p_get_group_iface(wpa_s, 0, 1); if (wpa_s == NULL) return -1; + if (freq > 0) + wpa_s->p2p_go_no_pri_sec_switch = 1; wpas_start_wps_go(wpa_s, ¶ms, 0); return 0; @@ -7084,6 +7088,7 @@ int wpas_p2p_group_add_persistent(struct wpa_supplicant *wpa_s, freq = wpas_p2p_select_go_freq(wpa_s, force_freq); if (freq < 0) return -1; + wpa_s->p2p_go_no_pri_sec_switch = 1; } else { freq = wpas_p2p_select_go_freq(wpa_s, neg_freq); if (freq < 0 || diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 6cacfe485..c169dce67 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -1156,6 +1156,7 @@ struct wpa_supplicant { unsigned int user_initiated_pd:1; unsigned int p2p_go_group_formation_completed:1; unsigned int group_formation_reported:1; + unsigned int p2p_go_no_pri_sec_switch:1; unsigned int waiting_presence_resp; int p2p_first_connection_timeout; unsigned int p2p_nfc_tag_enabled:1;