* [PATCH rtw-next v5] wifi: rtw89: set RA init rate level when the station RSSI is known
@ 2026-11-16 8:55 Vincent Schurink
2026-11-16 9:17 ` Ping-Ke Shih
0 siblings, 1 reply; 2+ messages in thread
From: Vincent Schurink @ 2026-11-16 8:55 UTC (permalink / raw)
To: Ping-Ke Shih; +Cc: linux-wireless, Vincent Schurink
When a station associates to an AP, the AP does not know the RSSI of
the station yet. Thus, rtw89_phy_ra_assoc() sends init_rate_lv 0 to the
firmware. With this value, the firmware RA of RTL8922A often uses 20 MHz
and VHT-MCS 2 for the station. It does not try a higher rate, also when
the PER is 0. On an 80 MHz AP, the TCP throughput to the station
then stays at approximately 36 Mbit/s for the full connection.
Move the mapping from RSSI to init_rate_lv to a function. In a test on
RTL8922A, the firmware used init_rate_lv only together with upd_all, and
upd_all resets the RA context. Thus, the RA association sets
rssi_unknown in the RA info when the RSSI is not known. When the RSSI is
known, the RA update sets init_rate_lv and upd_all one time. Other RA
updates still send init_rate_lv 0.
The flag is in a struct_group at the end of the RA info, and
rtw89_phy_ra_sta_update() clears the RA info only up to this group.
Thus, the flag stays until the RA update uses it.
Tested on RTL8912AU (RTL8922A, USB) in AP mode with hostapd 2.10 and
VHT 80 MHz. The client is an Intel Meteor Lake CNVi (iwlwifi) at -34 to
-40 dBm. Each test reconnects the client, then sends TCP from the AP for
60 s.
Before: 6 of 8 connections stay at VHT-MCS 2 and 20 MHz, 36 Mbit/s.
After: 8 of 8 connections use VHT-MCS 9 at 80 MHz, 671 to 683 Mbit/s.
Suggested-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Vincent Schurink <spam@acio.nl>
---
v5:
- Set ra->init_rate_lv in the RA update only when ra->rssi_unknown is
set, with a local variable, as suggested by Ping-Ke. Other RA updates
send init_rate_lv 0, as before this patch.
- Tested again with v5. The client is at -34 to -36 dBm, 60 s per
connection. 8 of 8 connections use VHT 2SS MCS 9 at 80 MHz, 671 to
683 Mbit/s. PMF still works: the client accepts a protected broadcast
deauthentication.
v4:
- Move the flag from struct rtw89_sta_link to the end of struct
rtw89_ra_info, in a struct_group with a comment, as suggested by
Ping-Ke.
- rtw89_phy_ra_sta_update() clears the RA info only up to this group,
with offsetof(), as suggested by Ping-Ke. rssi_unknown is a plain bool
and not a bit-field, because offsetof() cannot be used on a bit-field.
- checkpatch --strict reports "Alignment should match open parenthesis"
for the member in struct_group(). With alignment to the parenthesis,
checkpatch reports "Statements should start on a tabstop" instead.
v4: https://lore.kernel.org/linux-wireless/20261116081741.51039-1-spam@acio.nl/
v3: https://lore.kernel.org/linux-wireless/20261113080731.30155-1-spam@acio.nl/
v2: https://lore.kernel.org/linux-wireless/20261112075622.32785-1-spam@acio.nl/
v1: https://lore.kernel.org/linux-wireless/20261108131723.206533-1-spam@acio.nl/
drivers/net/wireless/realtek/rtw89/core.h | 5 ++++
drivers/net/wireless/realtek/rtw89/phy.c | 36 ++++++++++++++++-------
2 files changed, 31 insertions(+), 10 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw89/core.h b/drivers/net/wireless/realtek/rtw89/core.h
index 7f84ee59f82..df702f4420b 100644
--- a/drivers/net/wireless/realtek/rtw89/core.h
+++ b/drivers/net/wireless/realtek/rtw89/core.h
@@ -4626,6 +4626,11 @@ struct rtw89_ra_info {
u8 macid_msb:2;
u8 band:2; /* enum rtw89_band */
u8 is_new_dbgreg:1;
+
+ /* keep driver helpers below in group (not cleared by rtw89_phy_ra_sta_update()) */
+ struct_group(helpers,
+ bool rssi_unknown;
+ );
};
#define RTW89_PPDU_MAC_INFO_USR_SIZE 4
diff --git a/drivers/net/wireless/realtek/rtw89/phy.c b/drivers/net/wireless/realtek/rtw89/phy.c
index 795920b899d..365357752af 100644
--- a/drivers/net/wireless/realtek/rtw89/phy.c
+++ b/drivers/net/wireless/realtek/rtw89/phy.c
@@ -343,7 +343,7 @@ static void rtw89_phy_ra_sta_update(struct rtw89_dev *rtwdev,
bool sgi = false;
bool fix_giltf_en = false;
- memset(ra, 0, sizeof(*ra));
+ memset(ra, 0, offsetof(typeof(*ra), helpers));
/* Set the ra mask from sta's capability */
if (link_sta->eht_cap.has_eht) {
mode |= RTW89_RA_MODE_EHT;
@@ -502,6 +502,20 @@ static void rtw89_phy_ra_sta_update(struct rtw89_dev *rtwdev,
ra->csi_mode = csi_mode;
}
+static u8 rtw89_phy_ra_get_init_rate_lv(struct rtw89_sta_link *rtwsta_link)
+{
+ u8 rssi = ewma_rssi_read(&rtwsta_link->avg_rssi) >> RSSI_FACTOR;
+
+ if (rssi > 40)
+ return 1;
+ if (rssi > 20)
+ return 2;
+ if (rssi > 1)
+ return 3;
+
+ return 0;
+}
+
void rtw89_phy_ra_update_sta_link(struct rtw89_dev *rtwdev,
struct rtw89_sta_link *rtwsta_link,
u32 changed)
@@ -510,6 +524,7 @@ void rtw89_phy_ra_update_sta_link(struct rtw89_dev *rtwdev,
struct ieee80211_vif *vif = rtwvif_link_to_vif(rtwvif_link);
struct rtw89_ra_info *ra = &rtwsta_link->ra;
struct ieee80211_link_sta *link_sta;
+ u8 init_rate_lv;
rcu_read_lock();
@@ -519,6 +534,14 @@ void rtw89_phy_ra_update_sta_link(struct rtw89_dev *rtwdev,
rcu_read_unlock();
+ if (ra->rssi_unknown) {
+ init_rate_lv = rtw89_phy_ra_get_init_rate_lv(rtwsta_link);
+ if (init_rate_lv) {
+ ra->init_rate_lv = init_rate_lv;
+ ra->upd_all = 1;
+ ra->rssi_unknown = false;
+ }
+ }
if (changed & IEEE80211_RC_SUPP_RATES_CHANGED)
ra->upd_mask = 1;
if (changed & (IEEE80211_RC_BW_CHANGED | IEEE80211_RC_NSS_CHANGED))
@@ -733,7 +756,6 @@ void rtw89_phy_ra_assoc(struct rtw89_dev *rtwdev, struct rtw89_sta_link *rtwsta_
struct rtw89_vif_link *rtwvif_link = rtwsta_link->rtwvif_link;
struct ieee80211_vif *vif = rtwvif_link_to_vif(rtwvif_link);
struct rtw89_ra_info *ra = &rtwsta_link->ra;
- u8 rssi = ewma_rssi_read(&rtwsta_link->avg_rssi) >> RSSI_FACTOR;
struct ieee80211_link_sta *link_sta;
bool csi;
@@ -747,14 +769,8 @@ void rtw89_phy_ra_assoc(struct rtw89_dev *rtwdev, struct rtw89_sta_link *rtwsta_
rcu_read_unlock();
- if (rssi > 40)
- ra->init_rate_lv = 1;
- else if (rssi > 20)
- ra->init_rate_lv = 2;
- else if (rssi > 1)
- ra->init_rate_lv = 3;
- else
- ra->init_rate_lv = 0;
+ ra->init_rate_lv = rtw89_phy_ra_get_init_rate_lv(rtwsta_link);
+ ra->rssi_unknown = !ra->init_rate_lv;
ra->upd_all = 1;
rtw89_debug(rtwdev, RTW89_DBG_RA,
"ra assoc: macid = %d, mode = %d, bw = %d, nss = %d, lv = %d",
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* RE: [PATCH rtw-next v5] wifi: rtw89: set RA init rate level when the station RSSI is known
2026-11-16 8:55 [PATCH rtw-next v5] wifi: rtw89: set RA init rate level when the station RSSI is known Vincent Schurink
@ 2026-11-16 9:17 ` Ping-Ke Shih
0 siblings, 0 replies; 2+ messages in thread
From: Ping-Ke Shih @ 2026-11-16 9:17 UTC (permalink / raw)
To: Vincent Schurink; +Cc: linux-wireless@vger.kernel.org
Vincent Schurink <spam@acio.nl> wrote:
> When a station associates to an AP, the AP does not know the RSSI of
> the station yet. Thus, rtw89_phy_ra_assoc() sends init_rate_lv 0 to the
> firmware. With this value, the firmware RA of RTL8922A often uses 20 MHz
> and VHT-MCS 2 for the station. It does not try a higher rate, also when
> the PER is 0. On an 80 MHz AP, the TCP throughput to the station
> then stays at approximately 36 Mbit/s for the full connection.
>
> Move the mapping from RSSI to init_rate_lv to a function. In a test on
> RTL8922A, the firmware used init_rate_lv only together with upd_all, and
> upd_all resets the RA context. Thus, the RA association sets
> rssi_unknown in the RA info when the RSSI is not known. When the RSSI is
> known, the RA update sets init_rate_lv and upd_all one time. Other RA
> updates still send init_rate_lv 0.
> The flag is in a struct_group at the end of the RA info, and
> rtw89_phy_ra_sta_update() clears the RA info only up to this group.
> Thus, the flag stays until the RA update uses it.
>
> Tested on RTL8912AU (RTL8922A, USB) in AP mode with hostapd 2.10 and
> VHT 80 MHz. The client is an Intel Meteor Lake CNVi (iwlwifi) at -34 to
> -40 dBm. Each test reconnects the client, then sends TCP from the AP for
> 60 s.
> Before: 6 of 8 connections stay at VHT-MCS 2 and 20 MHz, 36 Mbit/s.
> After: 8 of 8 connections use VHT-MCS 9 at 80 MHz, 671 to 683 Mbit/s.
>
> Suggested-by: Ping-Ke Shih <pkshih@realtek.com>
> Signed-off-by: Vincent Schurink <spam@acio.nl>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-16 9:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-16 8:55 [PATCH rtw-next v5] wifi: rtw89: set RA init rate level when the station RSSI is known Vincent Schurink
2026-11-16 9:17 ` Ping-Ke Shih
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox