Repository navigation
Conversation
Android puts the WiFi driver into suspend mode at screen off, and MediaTek's puts the AP's BSS in with the phone's own, where the firmware drops what clients multicast: Router Solicitations, DHCPv6, mDNS. Clients joining with the screen off got no IPv6 until it came back on. With -a 1 (WIFI_AWAKE, the default) the monitor sends DRIVER SETSUSPENDMODE 0 to the supplicant on the WiFi interface at its start and on every beat, the way Android sets suspend mode; the vendor's library packs it the way that driver reads it, and a repeat is a no-op there. WPA_CTRL_DIR moves to radio/internal.h, shared with DRIVER COUNTRY. Signed-off-by: poqdavid <poq-david@live.com>
Under Start access point at boot, on by default, saved to ap.conf as WIFI_AWAKE so a boot start honours it too. The engine reads it at the start, so it is locked while the access point runs. Signed-off-by: poqdavid <poq-david@live.com>
How-It-Works says what WIFI_AWAKE does and why, and how the monitor reaches the driver through the supplicant. Signed-off-by: poqdavid <poq-david@live.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Clients that join the hotspot while the phone's screen is off get no IPv6 (no SLAAC, no DHCPv6) until the screen comes back on. IPv4 keeps working.
The cause is the Wi-Fi driver's suspend mode. At screen off, Android sends the driver
SETSUSPENDMODE 1. MediaTek's gen4m driver then puts the AP's BSS into firmware suspend mode along with the phone's own, and the firmware drops the multicast that clients send: Router Solicitations (ff02::2), DHCPv6 (ff02::1:2), mDNS. DHCPv4 is broadcast, so it isn't affected.This PR adds
WIFI_AWAKE(-a, on by default). While the AP runs, the monitor sendsDRIVER SETSUSPENDMODE 0to wpa_supplicant on the Wi-Fi interface, once at its start and then on its existing 3 s beat.How it was found
vaplan0in the managed-mode OpenWrt container: with the screen locked, the client's Router Solicitations never arrived. Right after unlocking, one arrived and odhcpd answered it within 0.6 ms.wifi_suspend_optimizations_enabled,cmd wifi force-hi-perf-mode), none of which changed anything.priv_driver_set_suspend_mode()callsp2pSetSuspendMode(), which callswlanNotifyFwSuspend()on the AP's BSS (the hotspot is a P2P role there). For the phone's own interface the driver keeps33:33:00:00:00:01allowed while suspended; nothing is kept for the AP.SETSUSPENDMODE 0by hand made the Router Solicitations arrive with the screen locked.Why through wpa_supplicant
DRIVERcommands to the vendor's own library, which packs them the way that driver reads them: gen4m takes the text inline, AOSP and Broadcom take a pointer. The engine doesn't need to know any of that.DRIVER COUNTRY, fire and forget, since replies don't come back on Samsung's firmware.Tested by hand on the phone. After forcing suspend mode on, sending the command through the supplicant gave:
and the laptop's Router Solicitation got through again.
Changes
-a/WIFI_AWAKE(default1).wifi_awake()inradio/driver.c; the monitor calls it at its start and on every beat, in both modes.WPA_CTRL_DIRmoves fromchannel.ctoradio/internal.h, shared withDRIVER COUNTRY.ap.conf, so a boot start honours it too. Locked while the AP runs, like the main screen's settings.Cost
DRIVERcommand every 3 s through the supplicant. The driver skips it when it's already out of suspend mode, and it rides the existing beat, so it adds no wakeups.SETSUSPENDMODE 1again at the next screen off.Testing
make checkwith new tests: the option's default and parsing, the command reaching a fake supplicant socket, and -1 when there's no supplicant. Passes on glibc and musl. clang-format clean; static musl build with-Werror.ap.logshows "Keeping the WiFi driver out of suspend mode while the AP runs", phone locked, client reconnected and got IPv6 within a few seconds>Notes
"spobcWgdwHAMKmGuT6a"and both blocks at the end oftest_opts().