Repository navigation
wifi: brcmfmac: wake on one magic packet during the associated sleep - #1679
Merged
Merged
Conversation
With WoWLAN armed for magic packets, the LPAS associated sleep in s2idle
wakes the host only on repeated magic packets. One broadcast packet woke
an M1 Pro 3 times in 17 and an M2 never in 26, and a unicast magic packet
never matched.
Two things were missing. With PM_MAX and the firmware's default listen
and broadcast-wait settings, most single broadcast frames never reach the
sleeping firmware. And on unicast frames only patterns near the headers
match: a filter on the destination IPv4 address matches, while the
102-byte magic pattern (at a fixed offset or found anywhere) never does.
Set the sleep the way macOS sets it on these chips:
- PM_FAST instead of PM_MAX, with bcn_li_dtim 1, bcn_li_bcn 0,
pm2_sleep_ret 15, pm2_bcn_sleep_ret 50, pm_bcmc_wait 65000 and
pm_bcmc_moredata_wait 30000. Each value is saved and restored, and a
firmware that does not know one keeps its own.
- Pattern-list (type 2) filters for unicast magic packets: UDP to each
IPv4 address and each IPv6 address of the interface whose payload
starts with six 0xff bytes and the station address, and the same start
after an EtherType 0x0842 header. Element offsets count from the IP
and UDP headers, which the firmware finds itself.
- ICMP echo offload for the IPv4 address, next to ARP and ND offload.
The broadcast magic filter stays as it was.
Tested on the M1 Pro (BCM4387), M2 (BCM4387) and M4 Pro J616s (BCM4388)
in s2idle, one packet per sleep, association kept, 0 AVC:
M1 Pro M2 J616s
one broadcast 12/13 13/13 11/13
one unicast 13/13 13/13 13/13
ping while asleep answered by the firmware, no wake
other UDP to us no wake
no packet slept to the RTC alarm
A missed broadcast never reached the host: broadcast frames are not
acknowledged on the air, and macOS on the M1 Pro missed 2 of 2 single
broadcasts in the same lab.
Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
RyanTheTide
marked this pull request as ready for review
November 12, 2026 12:09
This was referenced Nov 12, 2026
Closed
This was referenced Nov 20, 2026
Closed
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.
With WoWLAN armed for magic packets, one packet now wakes the Mac from s2idle. Before this, a single broadcast magic packet woke an M1 Pro 3 times in 17 and an M2 never in 26, and unicast magic packets never matched.
What changes in the associated sleep
wl_pkt_filter_pattern_listone.The broadcast magic filter, the event mask, LPAS and the MSI wake path from #1653 are unchanged. WoWLAN off is unchanged.
Results
s2idle with one magic packet per sleep, sent from a host on the same AP (5 GHz). A wake counts when the Mac's own UDP heartbeat comes back before the RTC alarm; ping can't be used because the sleeping firmware now answers it. Brcmfmac built from this branch's driver on the fleet kernel, swapped in at runtime.
The association was kept in every WoWLAN cycle (same BSSID, no disconnect event), and there were 0 AVC denials. All six sleep iovars and every new filter were accepted by the M1 Pro and M2 firmware (20.96.31.0.8.7.148) and the J616s firmware.
A missed broadcast never reached the host: no wake frame, and the frames flushed after the RTC wake don't include it. Broadcast frames aren't acknowledged on the air. macOS on the same M1 Pro and AP missed 2 of 2 single broadcasts. Running without LPAS didn't change the broadcast rate (M1 Pro 8/10, J616s 9/10), so LPAS stays on.
30-minute idle sleep with WoWLAN armed, re-suspending after any early wake: M1 Pro 1800 s, M2 1802 s and J616s 1802 s, each one sleep to the RTC alarm with 0 spurious wakes, association kept and Wi-Fi up afterwards. macOS in the same lab woke itself for Wi-Fi every few seconds in the first minutes after boot and on TCP keepalive offload traffic.
Tests
tools/asahi/run-host-tests.py --only brcmf: 35/35. Newbrcmf-wowl-filter-tests.pyruns the production filter builders against stubs, checks everypkt_filter_addbyte against the public layout, and checks that running out of firmware filter slots keeps the filters already installed. It kills 4 mutants (base enum order, mask/data order, totsize, tracking).🤖 Generated with Claude Code