* [PATCH RFC rtw-next] wifi: rtw88: raise the TBTT hold time while beaconing
@ 2026-11-19 10:29 Mehmet Fide
2026-11-20 17:31 ` Luka Gejak
0 siblings, 1 reply; 2+ messages in thread
From: Mehmet Fide @ 2026-11-19 10:29 UTC (permalink / raw)
To: Ping-Ke Shih; +Cc: Luka Gejak, linux-wireless, linux-kernel, mehmet.fide
From: Mehmet Fide <mehmet.fide@screeningeagle.com>
rtw88 sets the hold time of REG_TBTT_PROHIBIT once at chip init, to
0x64 * 32 us = 3.2 ms, and keeps it while beaconing. A beacon that
cannot start within the hold time after TBTT is not sent: on the air
no beacon came later than 3.2 ms after its TBTT. On 2.4 GHz channel 6
a neighbour multi-BSS AP sends three beacons back to back, about 7.5 ms
of air time. Each time its beacon period drifts across our TBTT, every
~157 s here, an RTL8822BU AP sends only 0-2 of 10 beacons per second
for about 7 s.
The other Realtek drivers use a longer hold time while beaconing and
write the init value back when beaconing stops: the vendor driver and
rtl8xxxu 0x80 (4.1 ms), rtlwifi 0x1ff (16.4 ms). rtw8703b and rtw8723d
define 0x80 for this but never use it.
Set the hold time to 0xff (8.2 ms) when beaconing starts and back to
0x64 when it stops, which also covers the off-channel periods in which
mac80211 stops the beacon. In 330 s on channel 6 the RTL8822BU AP had
14 seconds with fewer than 6 of 10 beacons with 0x64 and none with
0xff; its beacons then went out up to 8.1 ms after TBTT.
Signed-off-by: Mehmet Fide <mehmet.fide@screeningeagle.com>
---
RFC because I would like your view on the hardware before this goes
further:
1. The captures suggest the MAC drops a beacon that cannot start
within the hold time. Is that how it works, and does a longer hold
time delay any other TX? iperf3 and ping through the AP were the
same with 0x064, 0x0ff and 0x400.
2. Which value do you recommend while beaconing: a fixed one, or one
derived from the beacon interval? With 0x0ff an RTL8821CU, a second
RTL8821CU and an RTL8822CU had no such seconds either, but an
RTL8822CE still had 6: its beacons were cut off at 8.2 ms.
3. The CSA series [1] downloads each countdown beacon 10 ms after TBTT,
so a hold time above about 9 ms needs a later download there. If
the reserved page is rewritten while a beacon still waits in the
hold window, which beacon goes out, the old or the new one?
With [1] and 0x0ff, an RTL8822BU AP with a station made 128 countdowns
of 5; the two that met the neighbour's beacons kept every count on the
air, count beacons up to 5.0 ms late. Without this patch the one that
did lost counts 2 and 1.
Tested on rtw-next with RTL8822BU, RTL8821CU and RTL8822CU (USB) and
RTL8822CE (PCIe) as AP, lockdep on.
[1] https://lore.kernel.org/linux-wireless/20261118231940.3950-1-mehmet.fide@gmail.com/
drivers/net/wireless/realtek/rtw88/mac80211.c | 11 +++++++++--
drivers/net/wireless/realtek/rtw88/reg.h | 3 +++
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw88/mac80211.c b/drivers/net/wireless/realtek/rtw88/mac80211.c
index 3029fbdb288a..cb1deeffef71 100644
--- a/drivers/net/wireless/realtek/rtw88/mac80211.c
+++ b/drivers/net/wireless/realtek/rtw88/mac80211.c
@@ -449,12 +449,19 @@ static void rtw_ops_bss_info_changed(struct ieee80211_hw *hw,
}
if (changed & BSS_CHANGED_BEACON_ENABLED) {
- if (conf->enable_beacon)
+ if (conf->enable_beacon) {
rtw_write32_set(rtwdev, REG_FWHW_TXQ_CTRL,
BIT_EN_BCNQ_DL);
- else
+ rtw_write32_mask(rtwdev, REG_TBTT_PROHIBIT,
+ BIT_MASK_TBTT_HOLD_TIME_AP,
+ TBTT_HOLD_TIME_BCN);
+ } else {
rtw_write32_clr(rtwdev, REG_FWHW_TXQ_CTRL,
BIT_EN_BCNQ_DL);
+ rtw_write32_mask(rtwdev, REG_TBTT_PROHIBIT,
+ BIT_MASK_TBTT_HOLD_TIME_AP,
+ TBTT_HOLD_TIME_STOP_BCN);
+ }
}
if (changed & BSS_CHANGED_CQM)
rtw_fw_beacon_filter_config(rtwdev, true, vif);
diff --git a/drivers/net/wireless/realtek/rtw88/reg.h b/drivers/net/wireless/realtek/rtw88/reg.h
index 877b82640e91..86cbe4e96b24 100644
--- a/drivers/net/wireless/realtek/rtw88/reg.h
+++ b/drivers/net/wireless/realtek/rtw88/reg.h
@@ -491,6 +491,9 @@
#define BIT_DIS_STBC_CFE BIT(8)
#define REG_TBTT_PROHIBIT 0x0540
#define BIT_SHIFT_TBTT_HOLD_TIME_AP 8
+#define BIT_MASK_TBTT_HOLD_TIME_AP GENMASK(19, 8)
+#define TBTT_HOLD_TIME_STOP_BCN 0x064
+#define TBTT_HOLD_TIME_BCN 0x0ff
#define REG_RD_NAV_NXT 0x0544
#define REG_NAV_PROT_LEN 0x0546
#define REG_BCN_CTRL 0x0550
base-commit: 0bdc579dbfc251a6b6838ee9459b6771b948c617
--
2.56.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH RFC rtw-next] wifi: rtw88: raise the TBTT hold time while beaconing
2026-11-19 10:29 [PATCH RFC rtw-next] wifi: rtw88: raise the TBTT hold time while beaconing Mehmet Fide
@ 2026-11-20 17:31 ` Luka Gejak
0 siblings, 0 replies; 2+ messages in thread
From: Luka Gejak @ 2026-11-20 17:31 UTC (permalink / raw)
To: Mehmet Fide, Ping-Ke Shih; +Cc: linux-wireless, linux-kernel, mehmet.fide
Hi Mehmet,
Thanks for looking into this. Below are my thoughts.
November 19, 2026 at 11:29 AM, "Mehmet Fide" <mehmet.fide@gmail.com> wrote:
[ ... ]
> 1. The captures suggest the MAC drops a beacon that cannot start
> within the hold time. Is that how it works, and does a longer hold
> time delay any other TX? iperf3 and ping through the AP were the
> same with 0x064, 0x0ff and 0x400.
Your captures fit a beacon transmit deadline. The RTL8822CU vendor
header says data queues can also wait during the hold, so I'd measure
latency around TBTT under load.
> 2. Which value do you recommend while beaconing: a fixed one, or one
> derived from the beacon interval? With 0x0ff an RTL8821CU, a second
> RTL8821CU and an RTL8822CU had no such seconds either, but an
> RTL8822CE still had 6: its beacons were cut off at 8.2 ms.
I'd start with 0x0ff and cap it for short beacon intervals. At 10 TU
that leaves 2.08 ms before the next TBTT. I'd measure beacon loss and
data latency before raising it on RTL8822CE.
> 3. The CSA series [1] downloads each countdown beacon 10 ms after TBTT,
> so a hold time above about 9 ms needs a later download there. If
> the reserved page is rewritten while a beacon still waits in the
> hold window, which beacon goes out, the old or the new one?
I'd expect the old template if the MAC has already fetched it and
still sends. Your v13 tests also saw missed beacons during a write.
At 100 TU a late CSA worker can pass rtw_fw_csa_hold() at 6 ms after
TBTT, inside the 8.16 ms window. Could the guard account for the hold
and beacon airtime before a rewrite or switch completion? It currently
skips intervals of 20 ms or less.
[ ... ]
> diff --git a/drivers/net/wireless/realtek/rtw88/mac80211.c b/drivers/net/wireless/realtek/rtw88/mac80211.c
> index 3029fbdb288a..cb1deeffef71 100644
> --- a/drivers/net/wireless/realtek/rtw88/mac80211.c
> +++ b/drivers/net/wireless/realtek/rtw88/mac80211.c
> @@ -449,12 +449,19 @@ static void rtw_ops_bss_info_changed(struct ieee80211_hw *hw,
> }
>
> if (changed & BSS_CHANGED_BEACON_ENABLED) {
> - if (conf->enable_beacon)
> + if (conf->enable_beacon) {
> rtw_write32_set(rtwdev, REG_FWHW_TXQ_CTRL,
> BIT_EN_BCNQ_DL);
> - else
> + rtw_write32_mask(rtwdev, REG_TBTT_PROHIBIT,
> + BIT_MASK_TBTT_HOLD_TIME_AP,
> + TBTT_HOLD_TIME_BCN);
> + } else {
> rtw_write32_clr(rtwdev, REG_FWHW_TXQ_CTRL,
> BIT_EN_BCNQ_DL);
> + rtw_write32_mask(rtwdev, REG_TBTT_PROHIBIT,
> + BIT_MASK_TBTT_HOLD_TIME_AP,
> + TBTT_HOLD_TIME_STOP_BCN);
> + }
> }
> if (changed & BSS_CHANGED_CQM)
> rtw_fw_beacon_filter_config(rtwdev, true, vif);
To me it looks like a station scan on RTL8822C can pause AP beacons
through rtw_hw_scan_chan_switch() and rtw_core_enable_beacon(), leaving
0xff programmed. The vendor driver restores 0x64 on scan pause. Could
we update the hold on scan pause and resume too?
Best regards,
Luka Gejak
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-20 17:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-19 10:29 [PATCH RFC rtw-next] wifi: rtw88: raise the TBTT hold time while beaconing Mehmet Fide
2026-11-20 17:31 ` Luka Gejak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®