unisocwifi: reconcile connect and roam state - #17
Open
YipKo wants to merge 4 commits into
Open
Conversation
Firmware may report SPRDWL_ROAM_SUCCESS while the host is still waiting for an initial connection. The old handler treats this as an error and can leave sm_state stuck in SPRDWL_CONNECTING, after which reconnect attempts fail until the module is reloaded. Choose the cfg80211 notification from the saved host state, restore DISCONNECTED after a failed initial connection, preserve a live association after a failed roam, and balance cfg80211 BSS references. Signed-off-by: YipKo <17290550+YipKo@users.noreply.github.com>
YipKo
marked this pull request as draft
August 21, 2026 20:11
Connection and roam notifications are asynchronous, so cfg80211 may no longer be able to resolve the target BSS by the time the event is processed. Validate and hold the exact BSS for both initial connection and roaming, falling back to an SSID/BSSID cache lookup without trusting the firmware channel. This avoids cfg80211 warnings and keeps driver and kernel connection state aligned. Signed-off-by: YipKo <17290550+YipKo@users.noreply.github.com>
Validate firmware response and event header lengths before using them. Decode little-endian IE lengths explicitly and reject truncated connect or disconnect events before their payload reaches cfg80211. Also reject malformed beacon frames before calculating IE offsets. Signed-off-by: YipKo <17290550+YipKo@users.noreply.github.com>
Firmware events may run before the thread waiting for a connect command response resumes. Publish SSID, BSSID, and connection state before sending the command, and restore the previous metadata only if the attempt is still pending when the command fails. Treat association and beacon IEs as optional, falling back to the BSS cache when beacon data cannot be used. Validate key bounds before copying, handle missing pairwise ciphers safely, and never print key material to the log. Signed-off-by: YipKo <17290550+YipKo@users.noreply.github.com>
|
This fixes roaming without issues so far, thanks! |
YipKo
marked this pull request as ready for review
August 24, 2026 06:52
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.
Related to orangepi-xunlong/linux-orangepi#98
When an AP sends an 802.11v BSS Transition Management request, the firmware may report
SPRDWL_ROAM_SUCCESSwhile the host is still inSPRDWL_CONNECTING.The existing handler only accepts
SPRDWL_CONNECT_SUCCESSin that state. It therefore enters the error path and may leavesm_statestuck inSPRDWL_CONNECTING. Subsequent association attempts then fail untilsprdwl_ngis reloaded.A later test also triggered
WARN_ON(bss_not_found)innet/wireless/sme.c. cfg80211 processes connection notifications asynchronously, and the BSS may no longer be present in the scan cache by the time the event is handled.This change selects the cfg80211 notification from the saved host state:
SPRDWL_ROAM_SUCCESSas connect success while an initial connection is pending.SPRDWL_DISCONNECTED.For successful connect and roam events, the driver now resolves and holds the target
cfg80211_bssinstead of leaving cfg80211 to look it up later. If the beacon data or firmware-provided channel cannot be used, it falls back to an SSID/BSSID lookup.The patch also publishes the pending SSID and BSSID before sending the firmware command, validates firmware event lengths before parsing them, fixes several key-validation checks, and removes a debug message that printed key material.
The driver builds successfully for ARM64 against Armbian Linux 6.12.23 and has been tested on an Orange Pi Zero 3 without any Wi-Fi disconnects.