mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mehmet Fide <mehmet.fide@gmail.com>
To: Ping-Ke Shih <pkshih@realtek.com>
Cc: Luka Gejak <luka.gejak@linux.dev>,
	linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
	mehmet.fide@screeningeagle.com
Subject: [PATCH RFC rtw-next] wifi: rtw88: raise the TBTT hold time while beaconing
Date: Thu, 19 Nov 2026 11:29:53 +0100	[thread overview]
Message-ID: <20261119102953.4035731-1-mehmet.fide@gmail.com> (raw)

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


                 reply	other threads:[~2026-11-19 10:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261119102953.4035731-1-mehmet.fide@gmail.com \
    --to=mehmet.fide@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=luka.gejak@linux.dev \
    --cc=mehmet.fide@screeningeagle.com \
    --cc=pkshih@realtek.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

all inboxes | Powered by JetHome®