The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "David Härdeman" <david@hardeman.nu>
To: Luka Gejak <luka.gejak@linux.dev>
Cc: Ping-Ke Shih <pkshih@realtek.com>,
	"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Leonard Lausen <leonard@lausen.nl>,
	Alastair D'Silva <alastair@d-silva.org>,
	Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Bitterblue Smith <rtl8821cerfe2@gmail.com>
Subject: Re: [PATCH rtw-next 0/5] wifi: rtw88: sdio: faster and fairer TX for the 88xx chips
Date: Wed, 18 Nov 2026 11:54:12 +0100	[thread overview]
Message-ID: <av2D1PomsLbjVaWo@hardeman.nu> (raw)
In-Reply-To: <03BBDDF6-2ACB-4B06-827D-69811DF5664A@linux.dev>

On Tue, Nov 17, 2026 at 04:27:28PM +0100, Luka Gejak wrote:
>I think the closer capture would still help, with the data frames and BA
>bitmap for the same TID around a scan. The client trace shows what its
>firmware passed up, and the per MACID failure count does not identify
>which MPDU failed. Matching those to the air capture would help check
>what happened to the particular hole.

(Full disclosure: mostly LLM-generated content here, I tried to edit it
down to a reasonable length, but I'm not 100% sure which parts to keep
and not, sorry about the wall of text).

Thanks, the capture helped a lot. Short version: when a client is
off-channel for longer than the chip's retry chain lasts, the chip
discards the MPDU, nobody learns about it (rtw88 reports SDIO frames
as acked), no BAR is sent, and the client's BA window stays at the
hole. How long the chain lasts depends on the BE contention window:
with hostapd's default for the AP's own BE queue (CWmax 63), the 32
retries are over after about 85 ms, shorter than a scan dwell here
(110-150 ms). With CWmax 1023, which is what rtw8822c.c initialises
before mac80211 configures the queues and what Realtek's vendor
driver keeps using, the retries outlast the dwell and the holes
mostly go away. Details below.

Setup: an MT7915 (mt76) sniffer 1 m from the AP, an iwlwifi client 2 m
away, a TCP download through the AP, a client scan forced every 20 s,
60 s per run. The sniffer passes up only part of the A-MPDU subframes,
but practically all BlockAcks. On the client I logged the frames
iwlwifi drops at its PN check (a kprobe), which gives the hole's SN
for each loss burst; clocks were synced to within a few ms.

1. What happens to a hole. Example, SN 2971 (TID 0, seconds into the
   run):

     22.0063  last BA before the scan: everything up to 2970 acked
     22.0065  client sends a QoS Null with PM=1 and leaves the channel
     22.0092  A-MPDU starting with SN 2971, no BA
              ... 2971 at the head of the A-MPDU 31 more times, about
              2.5 ms apart (rate falling to 6 Mbit/s), never a BA
     22.0926  last transmission of 2971; it is never sent again
     22.1205  client back (PM=0), 28 ms too late
     22.1607  first BA: SSN 2939, 2971 missing, 2972..3002 received
     22.1652  the AP sends SN 3035 (= 2971 + 64)
     22.1853  BA SSN 2990: the client's window has moved past 2971
     22.196   iwlwifi drops 63 frames (the bug I sent fixes for)

   This is the common case: in two runs where I matched every loss
   burst to the capture (18 holes, stock driver), 14 looked like this
   (1 + 32 transmissions during the dwell), 2 weren't in the capture,
   and no run had a single BAR.

2. It isn't the series and it isn't the client. The stock rtw-next
   driver shows the same pattern (the series has about half as many
   holes: 3.5 vs. 6.7 per run over 11 runs each). With an mt7915 client
   instead of iwlwifi, the AP's firmware TX statistics count failed
   MPDUs only during forced scans (9 in 9 scans, 0 without).

3. The retry chain is too short for the dwell. With REG_RETRY_LIMIT at
   48/48 the hole's retries last about 112 ms and end a few ms before
   the client returns; at 60/60, chains of 36-48 transmissions (up to
   about 125 ms) were acked after the client came back and the holes
   went from 4.3 to 2.6 per run. (63/63 stalls the chip's TX, so
   that's not a fix.) Putting the MACID to sleep from sta_notify
   doesn't help either: the register write is done within about 1 ms,
   but the chip keeps retrying the A-MPDU it has started.

4. What the vendor driver does differently. Realtek's vendor driver
   (rtl88x2cs v5.14.0.2-0-g4c549b2.20210914, built from
   https://github.com/friendlyarm/rtl8822cs, branch nanopi-r2, which
   FriendlyElec ships for this board) on a second board of the same
   kind has about one hole per run. Neither its firmware (9.13.0; with
   rtw88's 9.9.15 patched into its module it behaves the same) nor its
   power save handling (it only moves queued frames to a sleep queue)
   explains that. What does is its turbo EDCA (rtw_hal_turbo_edca()
   in hal/hal_dm.c, run from the driver's 2 s watchdog): it overrides
   REG_EDCA_BE_PARAM with CWmax 1023 (0x005ea42b with mostly TX,
   0x0000a42b with mostly RX), while rtw88's __rtw_conf_tx() writes
   mac80211's value, 0x005e642b (CWmax 63) with hostapd's defaults.
   Swapping the value on both drivers, alternating runs:

     rtw88 + series, CWmax 1023 (hostapd
       tx_queue_data2_cwmax=1023)          4 holes in 32 scans
     rtw88 + series, CWmax 63 (default)   25 holes in 26 scans
     vendor driver, CWmax 1023 (default)   3 holes in 16 scans
     vendor driver, CWmax 63              83 holes in 17 scans

   Throughput was the same with both values on both drivers.

A smaller second pattern remains with either value: when several MPDUs
of an A-MPDU are outstanding, the chip retries them together about 7
times and then drops the older ones after about 8 transmissions,
independent of REG_RETRY_LIMIT (WLAN_RA_TRY_RATE_AGG_LIMIT?).

I don't think rtw88 is wrong to apply CWmax 63: it's the value
hostapd documents as the AP's own default for BE, and mac80211 passes
it on as it should. CWmax 1023 only makes the retry chain long enough
for typical scan dwells; a client that stays away longer would still
lose the MPDU. The real gap is that the discard isn't reported: if
mac80211 learned that the MPDU failed, it would send a BAR itself and
the client's window would move on right away.

Ping-Ke, can the chip or the firmware report MPDUs it discards after
the retry limit (or send a BAR itself), in a way rtw88 could use
without requesting a TX report for every frame? Until there is a
fix, tx_queue_data2_cwmax=1023 in hostapd is a workaround for users.

>I checked the mac80211 status path, and it does send a BAR with the next
>sequence number for that QoS status. The current rtw88 report helper does
>not set AMPDU_NO_BACK, so requesting the reports alone would not exercise
>that recovery path.

Right. My experiment had an option for the driver to call
ieee80211_send_bar() itself when a report said the frame had failed,
but with so few reports coming back, that wasn't a usable path.

>One detail that might affect this experiment is that the sn passed to
>rtw_tx_report_enqueue() is a report cookie, rather than the frame's
>802.11 sequence number. It has six usable bits:
>
>        pkt_info->sn = (atomic_inc_return(&tx_report->sn) << 2) & 0xfc;
>
>As far as I can see, it repeats after 64 requests, and
>rtw_tx_report_handle() takes the first skb with a matching cookie. If an
>older request is still pending when its cookie is reused, a report for
>the newer frame can complete the older skb.
>
>Was the 7% figure from raw C2H events or from completed skbs?

From raw C2H events. That experiment didn't use rtw_tx_report_enqueue():
it put the low six bits of the frame's 802.11 sequence number into the
report field instead of a cookie, and counted every TX report the
firmware sent, before any matching.

An earlier test, which requested a report for one in 16 QoS data frames,
did use the normal cookie path, and there you're right: at that rate
the cookies wrap after about 50 ms, so its numbers (3-9 % answered) may
well be off. They agree with the raw count, though.

>This would
>affect frame attribution, but would not explain a shortage of raw C2H
>events. Maybe a short run with one request outstanding at a time,
>logging the cookie, QoS TID and seq_ctrl, would help check that part.

I tried that: a debug build that requests a report through the normal
path for one unicast QoS data frame at a time, and only sends the next
request once the report has arrived, or after 500 ms without one. The
client was a phone streaming video, for three minutes per run:

                                  run 1   run 2
  requests                          337     808
  answered                          258     750
  given up (no answer >= 500 ms)     79      58
    of these, answered later          0       6
  reports with another cookie         3       8

All answers reported success; in the second run the median time to the
report was about 4 ms. So even with only one request outstanding, 7 to
23 % of the reports didn't arrive within 500 ms, and nearly all of those
never arrived. I couldn't tie the missing ones to periods of heavier
traffic.

-- 
David Härdeman

      reply	other threads:[~2026-11-18 10:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 19:01 [PATCH rtw-next 0/5] wifi: rtw88: sdio: faster and fairer TX for the 88xx chips David Härdeman
2026-11-16 19:01 ` [PATCH rtw-next 1/5] wifi: rtw88: sdio: cache the free TX page counts of " David Härdeman
2026-11-17  7:20   ` Luka Gejak
2026-11-17 12:50     ` David Härdeman
2026-11-16 19:01 ` [PATCH rtw-next 2/5] wifi: rtw88: sdio: aggregate TX frames " David Härdeman
2026-11-16 19:01 ` [PATCH rtw-next 3/5] wifi: rtw88: sdio: limit the TX queue length " David Härdeman
2026-11-17  7:21   ` Luka Gejak
2026-11-17 12:57     ` David Härdeman
2026-11-16 19:01 ` [PATCH rtw-next 4/5] wifi: rtw88: sdio: let TX in while receiving on " David Härdeman
2026-11-16 19:01 ` [PATCH rtw-next 5/5] wifi: rtw88: sdio: read neighbouring registers of the 88xx chips at once David Härdeman
2026-11-16 21:59 ` [PATCH rtw-next 0/5] wifi: rtw88: sdio: faster and fairer TX for the 88xx chips Luka Gejak
2026-11-17  7:46 ` Ping-Ke Shih
2026-11-17 14:44   ` David Härdeman
2026-11-17 15:27     ` Luka Gejak
2026-11-18 10:54       ` David Härdeman [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=av2D1PomsLbjVaWo@hardeman.nu \
    --to=david@hardeman.nu \
    --cc=alastair@d-silva.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=leonard@lausen.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=luka.gejak@linux.dev \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=pkshih@realtek.com \
    --cc=rtl8821cerfe2@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox