From 9aaf3e1d138a2a3125d791b65c26793428cc9bf0 Mon Sep 17 00:00:00 2001 From: Sunil Ravi Date: Tue, 29 Jun 2021 11:18:20 -0700 Subject: [PATCH] P2P: Update GO operating frequency after interface setup is completed Once the GO/AP interface initialization is completed, check if the operating frequency set in the wpa_supplicant group interface structure is different than the one set in the hostapd interface structure associated with the group interface. If yes, update the frequency in the wpa_supplicant group interface and network configuration to the frequency set in the hostapd interface structure. The frequency set in the hostapd interface is the correct/final frequency wpa_supplicant configured in the kernel/driver. This is done because wpa_supplicant may switch the initially requested primary and secondary frequencies to get a secondary frequency with no beacons (to avoid interference or 20/40 MHz coex logic). And the updated frequency is informed by the driver only after the interface setup is completed through the channel switch event - EVENT_CH_SWITCH. But wpa_supplicant updates the frequency to applications through the P2P_GROUP_STARTED event which is triggered before the EVENT_CH_SWITCH event. To send the correct frequency to applications the frequency must be updated before sending the P2P_GROUP_STARTED event. Bug: 191272346 Test: Manual - Verified that GO frequency is updated and reported correctly to Nearby application. Signed-off-by: Sunil Ravi --- wpa_supplicant/ap.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c index ad2cf5f11..0559822cb 100644 --- a/wpa_supplicant/ap.c +++ b/wpa_supplicant/ap.c @@ -903,12 +903,18 @@ static void wpas_ap_configured_cb(void *ctx) return; } + if (wpa_s->current_ssid) { + int acs = 0; + #ifdef CONFIG_ACS - if (wpa_s->current_ssid && wpa_s->current_ssid->acs) { - wpa_s->assoc_freq = wpa_s->ap_iface->freq; - wpa_s->current_ssid->frequency = wpa_s->ap_iface->freq; - } + acs = wpa_s->current_ssid->acs; #endif /* CONFIG_ACS */ + if (acs || (wpa_s->assoc_freq && wpa_s->ap_iface->freq && + (int) wpa_s->assoc_freq != wpa_s->ap_iface->freq)) { + wpa_s->assoc_freq = wpa_s->ap_iface->freq; + wpa_s->current_ssid->frequency = wpa_s->ap_iface->freq; + } + } wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);