Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH rtw-next] wifi: rtw89: do RA association again when the station RSSI is known
@ 2026-11-08 13:17 acio
  2026-11-11  3:22 ` Ping-Ke Shih
  0 siblings, 1 reply; 3+ messages in thread
From: acio @ 2026-11-08 13:17 UTC (permalink / raw)
  To: Ping-Ke Shih; +Cc: linux-wireless, Vincent Schurink

From: Vincent Schurink <spam@acio.nl>

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 uses 20 MHz and
VHT-MCS 2 for the station. The firmware RA does not try a higher rate,
also when the PER is 0. On an 80 MHz AP, the TCP throughput to the
station stays at approximately 35 Mbit/s.

Set a flag when the RSSI is not known at the RA association. When the
RSSI is known, the periodic RA update does the RA association again.

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
-45 dBm.
Before: TX rate VHT-MCS 2 at 20 MHz, TCP 35 Mbit/s.
After: TX rate VHT-MCS 7 to 9 at 80 MHz, TCP 186 to 320 Mbit/s.

Signed-off-by: Vincent Schurink <spam@acio.nl>
---
 drivers/net/wireless/realtek/rtw89/core.h |  1 +
 drivers/net/wireless/realtek/rtw89/phy.c  | 14 ++++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtw89/core.h b/drivers/net/wireless/realtek/rtw89/core.h
index 0d893b992a4..ca5f2aced33 100644
--- a/drivers/net/wireless/realtek/rtw89/core.h
+++ b/drivers/net/wireless/realtek/rtw89/core.h
@@ -4711,6 +4711,7 @@ struct rtw89_sta_link {
 	struct rtw89_vif_link *rtwvif_link;
 	struct rtw89_ra_info ra;
 	struct rtw89_ra_report ra_report;
+	bool ra_rssi_unknown;
 	int max_agg_wait;
 	u8 prev_rssi;
 	struct ewma_rssi avg_rssi;
diff --git a/drivers/net/wireless/realtek/rtw89/phy.c b/drivers/net/wireless/realtek/rtw89/phy.c
index 795920b899d..96660b781a5 100644
--- a/drivers/net/wireless/realtek/rtw89/phy.c
+++ b/drivers/net/wireless/realtek/rtw89/phy.c
@@ -717,6 +717,19 @@ void rtw89_phy_rate_pattern_vif(struct rtw89_dev *rtwdev,
 static void rtw89_phy_ra_update_sta_iter(void *data, struct ieee80211_sta *sta)
 {
 	struct rtw89_dev *rtwdev = (struct rtw89_dev *)data;
+	struct rtw89_sta *rtwsta = sta_to_rtwsta(sta);
+	struct rtw89_sta_link *rtwsta_link;
+	unsigned int link_id;
+	u8 rssi;
+
+	rtw89_sta_for_each_link(rtwsta, rtwsta_link, link_id) {
+		if (!rtwsta_link->ra_rssi_unknown)
+			continue;
+
+		rssi = ewma_rssi_read(&rtwsta_link->avg_rssi) >> RSSI_FACTOR;
+		if (rssi > 1)
+			rtw89_phy_ra_assoc(rtwdev, rtwsta_link);
+	}
 
 	rtw89_phy_ra_update_sta(rtwdev, sta, IEEE80211_RC_SUPP_RATES_CHANGED);
 }
@@ -755,6 +768,7 @@ void rtw89_phy_ra_assoc(struct rtw89_dev *rtwdev, struct rtw89_sta_link *rtwsta_
 		ra->init_rate_lv = 3;
 	else
 		ra->init_rate_lv = 0;
+	rtwsta_link->ra_rssi_unknown = rssi <= 1;
 	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] 3+ messages in thread

* RE: [PATCH rtw-next] wifi: rtw89: do RA association again when the station RSSI is known
  2026-11-08 13:17 [PATCH rtw-next] wifi: rtw89: do RA association again when the station RSSI is known acio
@ 2026-11-11  3:22 ` Ping-Ke Shih
  2026-11-12  7:58   ` V. S.
  0 siblings, 1 reply; 3+ messages in thread
From: Ping-Ke Shih @ 2026-11-11  3:22 UTC (permalink / raw)
  To: acio; +Cc: linux-wireless@vger.kernel.org

acio <spam@acio.nl> wrote:
> From: Vincent Schurink <spam@acio.nl>
> 
> 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 uses 20 MHz and
> VHT-MCS 2 for the station. The firmware RA does not try a higher rate,
> also when the PER is 0. On an 80 MHz AP, the TCP throughput to the
> station stays at approximately 35 Mbit/s.
> 
> Set a flag when the RSSI is not known at the RA association. When the
> RSSI is known, the periodic RA update does the RA association again.
> 
> 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
> -45 dBm.
> Before: TX rate VHT-MCS 2 at 20 MHz, TCP 35 Mbit/s.
> After: TX rate VHT-MCS 7 to 9 at 80 MHz, TCP 186 to 320 Mbit/s.
> 
> Signed-off-by: Vincent Schurink <spam@acio.nl>
> ---
>  drivers/net/wireless/realtek/rtw89/core.h |  1 +
>  drivers/net/wireless/realtek/rtw89/phy.c  | 14 ++++++++++++++
>  2 files changed, 15 insertions(+)
> 
> diff --git a/drivers/net/wireless/realtek/rtw89/core.h b/drivers/net/wireless/realtek/rtw89/core.h
> index 0d893b992a4..ca5f2aced33 100644
> --- a/drivers/net/wireless/realtek/rtw89/core.h
> +++ b/drivers/net/wireless/realtek/rtw89/core.h
> @@ -4711,6 +4711,7 @@ struct rtw89_sta_link {
>         struct rtw89_vif_link *rtwvif_link;
>         struct rtw89_ra_info ra;
>         struct rtw89_ra_report ra_report;
> +       bool ra_rssi_unknown;
>         int max_agg_wait;
>         u8 prev_rssi;
>         struct ewma_rssi avg_rssi;
> diff --git a/drivers/net/wireless/realtek/rtw89/phy.c b/drivers/net/wireless/realtek/rtw89/phy.c
> index 795920b899d..96660b781a5 100644
> --- a/drivers/net/wireless/realtek/rtw89/phy.c
> +++ b/drivers/net/wireless/realtek/rtw89/phy.c
> @@ -717,6 +717,19 @@ void rtw89_phy_rate_pattern_vif(struct rtw89_dev *rtwdev,
>  static void rtw89_phy_ra_update_sta_iter(void *data, struct ieee80211_sta *sta)
>  {
>         struct rtw89_dev *rtwdev = (struct rtw89_dev *)data;
> +       struct rtw89_sta *rtwsta = sta_to_rtwsta(sta);
> +       struct rtw89_sta_link *rtwsta_link;
> +       unsigned int link_id;
> +       u8 rssi;
> +
> +       rtw89_sta_for_each_link(rtwsta, rtwsta_link, link_id) {
> +               if (!rtwsta_link->ra_rssi_unknown)
> +                       continue;
> +
> +               rssi = ewma_rssi_read(&rtwsta_link->avg_rssi) >> RSSI_FACTOR;
> +               if (rssi > 1)
> +                       rtw89_phy_ra_assoc(rtwdev, rtwsta_link);

Can we move rssi logic to an individual function and call it to update
ra->init_rate_lv?

	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;

The rtw89_phy_ra_update_sta() will call rtw89_fw_h2c_ra() to send H2C command.


> +       }
> 
>         rtw89_phy_ra_update_sta(rtwdev, sta, IEEE80211_RC_SUPP_RATES_CHANGED);
>  }
> @@ -755,6 +768,7 @@ void rtw89_phy_ra_assoc(struct rtw89_dev *rtwdev, struct rtw89_sta_link *rtwsta_
>                 ra->init_rate_lv = 3;
>         else
>                 ra->init_rate_lv = 0;
> +       rtwsta_link->ra_rssi_unknown = rssi <= 1;
>         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	[flat|nested] 3+ messages in thread

* Re: [PATCH rtw-next] wifi: rtw89: do RA association again when the station RSSI is known
  2026-11-11  3:22 ` Ping-Ke Shih
@ 2026-11-12  7:58   ` V. S.
  0 siblings, 0 replies; 3+ messages in thread
From: V. S. @ 2026-11-12  7:58 UTC (permalink / raw)
  To: Ping-Ke Shih; +Cc: linux-wireless@vger.kernel.org

Thank you. I tested this on RTL8912AU in AP mode. With init_rate_lv in
the RA update only, the rate stays at VHT-MCS 2 and 20 MHz. The
firmware uses init_rate_lv only together with upd_all. Thus, v2 also
sets upd_all one time, when the level changes from 0 to a known level.
Then the rate goes to VHT-MCS 5 to 9 at 80 MHz.

v2: https://lore.kernel.org/linux-wireless/20261112075622.32785-1-spam@acio.nl/

On Wed, Nov 11, 2026 at 4:22 AM Ping-Ke Shih <pkshih@realtek.com> wrote:
>
> acio <spam@acio.nl> wrote:
> > From: Vincent Schurink <spam@acio.nl>
> >
> > 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 uses 20 MHz and
> > VHT-MCS 2 for the station. The firmware RA does not try a higher rate,
> > also when the PER is 0. On an 80 MHz AP, the TCP throughput to the
> > station stays at approximately 35 Mbit/s.
> >
> > Set a flag when the RSSI is not known at the RA association. When the
> > RSSI is known, the periodic RA update does the RA association again.
> >
> > 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
> > -45 dBm.
> > Before: TX rate VHT-MCS 2 at 20 MHz, TCP 35 Mbit/s.
> > After: TX rate VHT-MCS 7 to 9 at 80 MHz, TCP 186 to 320 Mbit/s.
> >
> > Signed-off-by: Vincent Schurink <spam@acio.nl>
> > ---
> >  drivers/net/wireless/realtek/rtw89/core.h |  1 +
> >  drivers/net/wireless/realtek/rtw89/phy.c  | 14 ++++++++++++++
> >  2 files changed, 15 insertions(+)
> >
> > diff --git a/drivers/net/wireless/realtek/rtw89/core.h b/drivers/net/wireless/realtek/rtw89/core.h
> > index 0d893b992a4..ca5f2aced33 100644
> > --- a/drivers/net/wireless/realtek/rtw89/core.h
> > +++ b/drivers/net/wireless/realtek/rtw89/core.h
> > @@ -4711,6 +4711,7 @@ struct rtw89_sta_link {
> >         struct rtw89_vif_link *rtwvif_link;
> >         struct rtw89_ra_info ra;
> >         struct rtw89_ra_report ra_report;
> > +       bool ra_rssi_unknown;
> >         int max_agg_wait;
> >         u8 prev_rssi;
> >         struct ewma_rssi avg_rssi;
> > diff --git a/drivers/net/wireless/realtek/rtw89/phy.c b/drivers/net/wireless/realtek/rtw89/phy.c
> > index 795920b899d..96660b781a5 100644
> > --- a/drivers/net/wireless/realtek/rtw89/phy.c
> > +++ b/drivers/net/wireless/realtek/rtw89/phy.c
> > @@ -717,6 +717,19 @@ void rtw89_phy_rate_pattern_vif(struct rtw89_dev *rtwdev,
> >  static void rtw89_phy_ra_update_sta_iter(void *data, struct ieee80211_sta *sta)
> >  {
> >         struct rtw89_dev *rtwdev = (struct rtw89_dev *)data;
> > +       struct rtw89_sta *rtwsta = sta_to_rtwsta(sta);
> > +       struct rtw89_sta_link *rtwsta_link;
> > +       unsigned int link_id;
> > +       u8 rssi;
> > +
> > +       rtw89_sta_for_each_link(rtwsta, rtwsta_link, link_id) {
> > +               if (!rtwsta_link->ra_rssi_unknown)
> > +                       continue;
> > +
> > +               rssi = ewma_rssi_read(&rtwsta_link->avg_rssi) >> RSSI_FACTOR;
> > +               if (rssi > 1)
> > +                       rtw89_phy_ra_assoc(rtwdev, rtwsta_link);
>
> Can we move rssi logic to an individual function and call it to update
> ra->init_rate_lv?
>
>         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;
>
> The rtw89_phy_ra_update_sta() will call rtw89_fw_h2c_ra() to send H2C command.
>
>
> > +       }
> >
> >         rtw89_phy_ra_update_sta(rtwdev, sta, IEEE80211_RC_SUPP_RATES_CHANGED);
> >  }
> > @@ -755,6 +768,7 @@ void rtw89_phy_ra_assoc(struct rtw89_dev *rtwdev, struct rtw89_sta_link *rtwsta_
> >                 ra->init_rate_lv = 3;
> >         else
> >                 ra->init_rate_lv = 0;
> > +       rtwsta_link->ra_rssi_unknown = rssi <= 1;
> >         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	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-12  7:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-08 13:17 [PATCH rtw-next] wifi: rtw89: do RA association again when the station RSSI is known acio
2026-11-11  3:22 ` Ping-Ke Shih
2026-11-12  7:58   ` V. S.

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox