Skip to content

wifi: apple: centauri: t6050: report station statistics and use a wake's warm reset once - #3946

Open
tully-8888 wants to merge 6 commits into
aurora-silicon:mainfrom
tully-8888:feat/t6050-wifi-station-stats
Open

tully-8888 wants to merge 6 commits into
aurora-silicon:mainfrom
tully-8888:feat/t6050-wifi-station-stats

Conversation

@tully-8888

@tully-8888 tully-8888 commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

What: Report station rates and counters from the firmware's statistics reports (command 0xb0001), as the shared transport driver does since #3458, so iw station dump on t6050 shows TX and RX bitrate, MCS, NSS, GI, retries, failures, beacons and per-chain signal. The survey reports channel noise only, because the CCA report's busy and TX times do not add up. A second recovery in one wake now cycles the port instead of reusing that wake's host warm reset on firmware that was never reset.
Tested: J714s (MacBook Pro 14-inch, M5 Pro) at 0f62a44 (the driver code at the head 80ab0c0 is the same; that commit only updates the host tests in tools/asahi), loaded as a module on a local 7.3 kernel: station dump with TX 720.6 to 864.8 Mbit/s at 80 MHz HE-MCS 7 to 8 NSS 2, RX 1201.0 Mbit/s, TX retries, TX failed 0, beacon RX and per-chain signal; survey with noise only (-90 dBm); gateway ping p50 3.60 / p99 8.60 ms, 0% loss; LAN TCP throughput and latency under load unchanged with station dumps running.
Risk: two-way door · Macs that bind apple_centauri_t6050 (M5 Pro, M5 Max)
Not yet: on J714s, a sleep/wake with Wi-Fi recovery, and a module reload in the same wake. The reload shows only that Wi-Fi comes back after a reload in that wake: the removal cycles the port itself, so the new probe starts from the ROM. The new owner's record of the used host reset (0f62a44) and a second recovery by the same owner inside one wake (3611b3f) are covered by the host tests only; there is no user-space trigger for them on J714s.

Details

Statistics: on a station read, the driver asks for the chip counters (TX retries, failures, rates), the TX report (MCS, width, NSS, GI), the frame counters (beacons) and the PHY dump (per-chain signal). Each query runs at most once per second. The reports are optional: a refused query is cached per slice and not sent again, and one the firmware consumes without a reply ends the queries after 500 ms instead of faulting the interface. A query the firmware still holds gets the full 1.5 s command deadline. Reply status is recorded only for the sequence being waited for, so a late reply to an abandoned query cannot complete the next command. Every TLV is bounds checked, and a missing report leaves its fields unset. The firmware version comes from the reply to command 0. Beacon loss events are not reported, because the firmware counts missed beacons, not loss events.

Survey: in one second with power save on, the CCA report's primary TX time grew by 30.9 ms and its summed busy time by 40.0 ms, while the awake time grew by 5.0 ms. No time base in the report gives a valid busy or TX time, so the survey keeps only the noise and the CCA report is no longer queried.

Warm reset: the PCI host sets its warm reset flag when it resets the N1 in a wake's noirq resume and clears it only at the next suspend prepare. A later recovery in the same wake (a Bluetooth unbind that cannot fence its DMA, a probe failure) read the stale flag, skipped the port cycle and enumerated the functions again on firmware that was never reset. The driver now records that the wake's reset was used and cycles the port for every later recovery; a PM notifier clears the record at suspend prepare. A recovery owner created mid-wake, for example after a module reload, starts with the reset taken as used. This builds on the recovery from #3346. #2191 also changes the t6050 recovery path, for a different case.

Evidence

At 0f62a44 on the J714s, module built against the running kernel and swapped in live:

Check Result
iw dev wlan0 station dump, 3 times at 2 s TX bitrate 720.6, 720.6, 864.8 Mbit/s 80MHz HE-MCS 7 / 7 / 8 HE-NSS 2; RX bitrate 1201.0 Mbit/s; TX retries 11 / 13 / 13; TX failed 0; beacon RX 22 / 41 / 56; signal -39 [-43, -45] and -40 [-44, -45] dBm
iw dev wlan0 survey dump noise -90 dBm, no busy or TX time
Gateway ping, 1000 x 20 ms, p50 / p99 / max 3.60 / 8.60 / 21.7 ms, 0% loss
Same ping with a station dump every second avg 3.67 ms, max 8.9 ms, 0% loss

LAN load, 4 TCP streams in each direction to a wired host for 60 s, gateway ping under load, median of 3 runs:

Station dumps Mbit/s, both directions Retransmits Ping p50 / p99
none 510.8 + 323.2 0 35.0 / 66.5 ms
405 in 60 s 540.3 + 410.8 0 36.3 / 62.1 ms

No kernel line during the LAN runs. The only kernel warnings in the run are the ones every module reload prints, the stock module included: probe error -108 while the chip resets, and a first join that times out with firmware status 306 before the retry joins.

Earlier, station statistics, first two commits loaded as a module on a local 7.3 kernel (iw dev wlan0 station dump 3 times at 2 s, gateway ping 1000 x 20 ms with a station dump every second):

Check Before With the change
Station dump fields bytes, packets, signal, connected time adds TX bitrate 720.6 to 1080.6 Mbit/s 80 MHz HE-MCS 7 to 10 NSS 2, RX bitrate 1080.9 Mbit/s, TX retries, TX failed 0, beacon RX (+10 per second), per-chain signal
Statistics query timeouts n/a 0
Gateway ping p50 / p99 3.49 / 6.41 ms 3.55 / 6.93 ms, 0% loss
Kernel warnings 0 0

The five driver commits booted (with the data path change noted above): station dump TX 960.7 Mbit/s 80 MHz HE-MCS 9 HE-NSS 2, RX 1201.0 Mbit/s, TX retries and beacon RX counting; iw dev wlan0 survey dump shows noise -90 dBm and no busy or TX time; 0 driver warnings since boot.

At 0f62a44: make LLVM=1 W=1 M=drivers/net/wireless/apple/centauri modules builds with 0 warnings; checkpatch.pl --strict on the five driver commits: 0 errors, 0 warnings. 80ab0c0 updates the host tests for the statistics and warm reset changes.

…firmware

Ask the firmware for its statistics reports (command 0xb0001, TLV 363)
when cfg80211 reads the station, as the shared transport driver does:
chip counters for TX retries, failures and rates, the TX report for the
MCS, width, NSS and GI, frame counters for beacons and the PHY dump for
per-chain signal. Add a survey of the operating channel with its noise
and CCA load, and take the firmware version from the reply to command 0.

The reports are optional. A query the firmware refuses is not sent
again, and one it consumes without a reply stops them all after 500 ms
instead of faulting the interface. Every TLV is bounds checked, and a
missing report leaves its station fields unset.

Signed-off-by: vlad <tulituvlad@gmail.com>
…he link

A statistics query the firmware still holds after 500 ms now gets the
full 1.5 s command deadline; only one it consumed without a reply ends
early. Record reply status and command only for the sequence being
waited for, so a late reply to an abandoned query cannot hide the
completion of the next command.

Cache a refused statistics report per slice and still try slice 1 after
a refused slice 2. Prefer the CCA slot that matches the link's primary
channel position, count only awake time as survey time, and stop
reporting missed beacons as beacon loss events.

Signed-off-by: vlad <tulituvlad@gmail.com>
The CCA report's per-read deltas are inconsistent with each other: in
one second with power save on, the primary tx time grew by 30.9 ms and
the summed busy time by 40.0 ms, while the awake time grew by 5.0 ms.
No time base the report carries is known to give a valid busy or tx
time, so report only the channel noise and stop querying the CCA
report.

Signed-off-by: vlad <tulituvlad@gmail.com>
The host sets its warm-reset flag when it resets the N1 in a wake's noirq
resume and clears it only at the next suspend prepare. A port cycle for
recovery leaves it set too. Any later recovery in the same wake, such as a
Bluetooth unbind that cannot fence its DMA or a probe failure, then reads
the old flag, skips the port cycle and enumerates the functions again on
firmware that was never reset.

Record that the wake's reset went to an enumeration and cycle the port for
every later recovery. A PM notifier clears the record at suspend prepare,
where the host clears its flag.

Signed-off-by: vlad <tulituvlad@gmail.com>
A recovery owner allocated in the middle of a wake, after a module
reload, started with host_reset_used false while the PCI host still
reported this wake's warm reset as done, so the next recovery could
skip the port cycle on firmware that was never reset. Start a new
owner with the reset taken as used; the suspend-prepare notifier clears
it for the first sleep the owner sees.

Signed-off-by: vlad <tulituvlad@gmail.com>
@tully-8888
tully-8888 marked this pull request as ready for review December 2, 2026 17:12
@tully-8888
tully-8888 requested review from a team as code owners December 2, 2026 17:12
@github-actions github-actions Bot added blast:m5 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Merge readiness at 80ab0c0f: not ready yet

Check Detail
CI at head ok 4 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at 80ab0c0f
Conflicts ok none
PR text ok Risk: two-way · Macs that bind applecentaurit6050 (M5 Pro, M5 Max)

Areas: area:gpu

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@github-actions github-actions Bot added the ci-failing A check failed at the PR head (bot) label Dec 2, 2026

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks right to me at 0f62a44. The TLV reads are bounds-checked, a refused or unanswered query stops that query instead of faulting the link, and every command sets reply_capture, so the stricter reply match in drain() is safe.

Two things before merge:

  1. host-tests fail because of this PR, in three harnesses that copy driver code. I reproduced all three with this diff applied to main 1da28cf, where they pass without it:
    • centauri-wifi-pm-tests: struct centauri_t6050_wifi has no command_probe, and time_after() and command_payload_consumed() are not declared.
    • centauri-scan-tests: fill_station_stats() is not declared.
    • centauri-physical-recovery-tests: struct centauri_t6050_rewake has no host_reset_used.
  2. The J714s row covers the statistics, but not the last two commits (the warm-reset bookkeeping). They need a sleep/wake with Wi-Fi recovery on J714s, plus the second recovery inside one wake that you list under Not yet.

Small note, not a blocker: station_bw_primary and station_bw_valid are set but nothing reads them yet.

Three host tests copy or model t6050 driver code that this series changed,
so they no longer built:

- centauri-wifi-pm-tests: command_reply() gives up an optional query the
  firmware consumed but did not answer. Model command_probe and extract
  command_payload_consumed(). Check that such a query ends with -ENODATA
  and no fault, that one the firmware still holds and any other command
  keep the full deadline and fault, and that the next command gets its
  own reply.
- centauri-scan-tests: fill_station() now reads the statistics. Run
  stats_query() from it and check that a station read during a scan sends
  no statistics command, like command 20.
- centauri-physical-recovery-tests: model host_reset_used and extract the
  PM notifier. Check that the host's warm reset serves one enumeration per
  wake, that a later recovery cycles the port, that the next suspend makes
  the reset usable again and that a refused recovery does not use it.

Add a negative control for each new check. The driver is unchanged.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@DjDeveloperr

Copy link
Copy Markdown
Contributor

I pushed 80ab0c0 on top of 0f62a44. It fixes the three host-test harnesses from my earlier review. Only tools/asahi changes and the driver is untouched. In all three the driver is right and the fixture was out of date:

Harness Why the driver is right Fixture change
centauri-wifi-pm-tests command_reply() gives up only a query marked optional that the firmware already consumed. Its payload slot is free then, and everything else keeps the 1.5 s deadline and the fault. Models command_probe and extracts command_payload_consumed(). Checks that such a query ends with -ENODATA and no fault, that a held query and an ordinary command still fault, and that the next command gets its own reply.
centauri-scan-tests stats_query() refuses while a scan runs, the same rule as command 20. Runs the real stats_query() from fill_station() and checks that a station read during a scan sends nothing. The report parsing is not modelled.
centauri-physical-recovery-tests The wake's reset is marked used only once the functions are removed, so a refused recovery keeps it. lock_system_sleep() keeps a recovery out of a suspend, so the notifier cannot race it. Models host_reset_used and extracts the PM notifier. Checks one enumeration per wake, a port cycle for a later recovery, and the reset becoming usable at the next suspend.

All existing negative controls still reject. There are six new ones, one for each new check: optional-query-held-payload, ordinary-command-given-up, station-stats-during-scan, host-reset-reused, host-reset-not-recorded and sleep-keeps-reset-used.

Results, in the host-tests.yml image (ubuntu 24.04 pins):

  • run-host-tests.py --only centauri at 80ab0c0: 25/25.
  • run-host-tests.py, full set, on 80ab0c0 merged with main 2c667a4 (tree 843d9b8d): 1029/1029. It still merges cleanly with main b902937.
  • make ARCH=arm64 LLVM=1 W=1 drivers/net/wireless/apple/centauri/ with the merged driver sources: 0 warnings.
  • checkpatch.pl --strict on the new commit: 0 errors, 1 warning and 2 checks, all in the fixture's mock macros and structs.

Still needed on J714s:

  • Sleep/wake with Wi-Fi recovery, and a second recovery inside one wake, for the last two driver commits (3611b3f and 0f62a44).
  • The statistics row at 0f62a44 measured the same driver code as this head, but the PR body still names 0f62a44.

@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) needs-hw-row No hardware row at the PR head (bot) and removed ci-failing A check failed at the PR head (bot) labels Dec 2, 2026

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at 80ab0c0

Checked: The current revision restores the earlier failing host fixtures. I ran the exact scan, Wi-Fi PM and physical-recovery suites. The optional query can exit early only after firmware consumes its specific payload, ordinary requests retain their deadline, and recovery can use the host's warm reset only once per wake. The driver's report processing bounds the TLV slices and leaves unavailable statistics unset.

Follow-ups: Please send the independent statistics and warm-reset changes separately in future revisions to make the production diff easier to review.

@RyanTheTide RyanTheTide closed this Dec 3, 2026
@RyanTheTide RyanTheTide reopened this Dec 3, 2026
@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Dec 3, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpu Area from CODEOWNERS (bot) blast:m5 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants