Linux wireless drivers development
 help / color / mirror / Atom feed
From: Bitterblue Smith <rtl8821cerfe2@gmail.com>
To: luka.gejak@linux.dev, Ping-Ke Shih <pkshih@realtek.com>
Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
	Michael Straube <straube.linux@gmail.com>,
	Peter Robinson <pbrobinson@gmail.com>
Subject: Re: [PATCH 18/19] wifi: rtw88: match the RTL8723BS firmware connect and power save behaviour
Date: Sat, 25 Jul 2026 01:10:32 +0300	[thread overview]
Message-ID: <fe9a4df1-1ea9-44b6-8f98-10130d37e55c@gmail.com> (raw)
In-Reply-To: <20260724183314.197195-1-luka.gejak@linux.dev>

On 24/07/2026 21:33, luka.gejak@linux.dev wrote:
> From: Luka Gejak <luka.gejak@linux.dev>
> 
> The vendor firmware expects the connect media status report at
> association completion rather than when the station is added, so defer
> it until the station is actually associated and track whether it was
> sent, so the disconnect report is only sent to undo one that was.

Does the firmware really care? What happens if you don't do all that?

> 
> Leaving LPS also costs enough per-packet latency on this chip to
> throttle bursty traffic badly, and the stock check enters LPS after a
> single quiet two second window that an ordinary session hits
> constantly. Gate LPS on the smoothed throughput for this chip so it
> only sleeps after sustained idle. Other chips keep the existing
> behaviour.
> 
> Signed-off-by: Luka Gejak <luka.gejak@linux.dev>
> ---
>  drivers/net/wireless/realtek/rtw88/main.c | 47 ++++++++++++++++++++++-
>  1 file changed, 45 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c
> index a2ef4479f408..63d1fb4bc87e 100644
> --- a/drivers/net/wireless/realtek/rtw88/main.c
> +++ b/drivers/net/wireless/realtek/rtw88/main.c
> @@ -304,6 +304,25 @@ static void rtw_sw_beacon_loss_check(struct rtw_dev *rtwdev,
>  /* process TX/RX statistics periodically for hardware,
>   * the information helps hardware to enhance performance
>   */
> +static bool rtw8723bs_station_media_status(struct rtw_dev *rtwdev,
> +					   struct ieee80211_sta *sta,
> +					   struct ieee80211_vif *vif)
> +{
> +	return rtw_is_8723bs(rtwdev) &&
> +	       vif->type == NL80211_IFTYPE_STATION && !sta->tdls;
> +}
> +
> +/* 8723BS SDIO: defer the connect MEDIA_STATUS_RPT until the STA is actually
> + * associated (the vendor firmware sends it at assoc completion, not sta-add).
> + */
> +static bool rtw8723bs_defer_sta_media_status(struct rtw_dev *rtwdev,
> +					     struct ieee80211_sta *sta,
> +					     struct ieee80211_vif *vif)
> +{
> +	return rtw8723bs_station_media_status(rtwdev, sta, vif) &&
> +	       !vif->cfg.assoc;
> +}
> +
>  static void rtw_watch_dog_work(struct work_struct *work)
>  {
>  	struct rtw_dev *rtwdev = container_of(work, struct rtw_dev,
> @@ -382,6 +401,17 @@ static void rtw_watch_dog_work(struct work_struct *work)
>  	 * get that vif and check if device is having traffic more than the
>  	 * threshold.
>  	 */
> +	/* On 8723BS SDIO the firmware's per-packet wake latency out of LPS
> +	 * throttles bursty traffic hard. The stock check enters LPS after a
> +	 * single quiet 2s window, which a normal bursty session hits
> +	 * constantly. Gate LPS on the smoothed throughput instead so the chip
> +	 * only sleeps after sustained idle and stays awake through an active
> +	 * session. Other chips keep the normal behaviour.
> +	 */
> +	if (rtw_is_8723bs(rtwdev) &&
> +	    (stats->tx_throughput || stats->rx_throughput))
> +		ps_active = true;
> +
>  	if (rtwdev->ps_enabled && data.rtwvif && !ps_active &&
>  	    !rtwdev->beacon_loss && !rtwdev->ap_active)
>  		rtw_enter_lps(rtwdev, data.rtwvif->port);
> @@ -450,7 +480,13 @@ int rtw_sta_add(struct rtw_dev *rtwdev, struct ieee80211_sta *sta,
>  	INIT_WORK(&si->rc_work, rtw_sta_rc_work);
>  
>  	rtw_update_sta_info(rtwdev, si, true);
> -	rtw_fw_media_status_report(rtwdev, si->mac_id, true);
> +	if (rtw8723bs_defer_sta_media_status(rtwdev, sta, vif)) {
> +		rtwvif->fw_media_connected = false;
> +	} else {
> +		rtw_fw_media_status_report(rtwdev, si->mac_id, true);
> +		if (rtw8723bs_station_media_status(rtwdev, sta, vif))
> +			rtwvif->fw_media_connected = true;
> +	}
>  
>  	rtwdev->sta_cnt++;
>  	rtwdev->beacon_loss = false;
> @@ -465,14 +501,21 @@ void rtw_sta_remove(struct rtw_dev *rtwdev, struct ieee80211_sta *sta,
>  {
>  	struct rtw_sta_info *si = (struct rtw_sta_info *)sta->drv_priv;
>  	struct ieee80211_vif *vif = si->vif;
> +	struct rtw_vif *rtwvif = (struct rtw_vif *)vif->drv_priv;
>  	int i;
>  
>  	cancel_work_sync(&si->rc_work);
>  
>  	if (vif->type != NL80211_IFTYPE_STATION || sta->tdls)
>  		rtw_release_macid(rtwdev, si->mac_id);
> -	if (fw_exist)
> +	if (fw_exist && rtw8723bs_station_media_status(rtwdev, sta, vif) &&
> +	    !rtwvif->fw_media_connected) {
> +		/* connect status was deferred and never sent; nothing to undo */
> +	} else if (fw_exist) {
>  		rtw_fw_media_status_report(rtwdev, si->mac_id, false);
> +		if (rtw8723bs_station_media_status(rtwdev, sta, vif))
> +			rtwvif->fw_media_connected = false;
> +	}
>  
>  	for (i = 0; i < ARRAY_SIZE(sta->txq); i++)
>  		rtw_txq_cleanup(rtwdev, sta->txq[i]);


  reply	other threads:[~2026-07-24 22:10 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-24 18:18 [PATCH 00/19] wifi: rtw88: preparations for RTL8723B/RTL8723BS luka.gejak
2026-07-24 18:18 ` [PATCH 01/19] wifi: rtw88: add the RTL8723B chip type and SDIO helper luka.gejak
2026-07-24 18:18 ` [PATCH 02/19] wifi: rtw88: rx: mark zero length packets on RTL8723B luka.gejak
2026-07-24 22:34   ` Bitterblue Smith
2026-07-24 18:18 ` [PATCH 03/19] wifi: rtw88: tx: extend the TX report purge timeout to RTL8723BS luka.gejak
2026-07-24 18:18 ` [PATCH 04/19] wifi: rtw88: fw: handle the RTL8723BS management TX reports luka.gejak
2026-07-24 22:53   ` Bitterblue Smith
2026-07-24 18:18 ` [PATCH 05/19] wifi: rtw88: fw: send rate adaptation and RSSI info in the vendor layout luka.gejak
2026-07-24 23:46   ` Bitterblue Smith
2026-07-24 18:18 ` [PATCH 06/19] wifi: rtw88: fw: send the media status report " luka.gejak
2026-07-24 23:52   ` Bitterblue Smith
2026-07-24 18:18 ` [PATCH 07/19] wifi: rtw88: fw: add the vendor firmware commands used by RTL8723BS luka.gejak
2026-07-24 18:18 ` [PATCH 08/19] wifi: rtw88: fw: fix the reserved page upload on RTL8723BS luka.gejak
2026-07-24 18:18 ` [PATCH 09/19] wifi: rtw88: coex: add the RTL8723BS scan antenna workaround luka.gejak
2026-07-24 18:32 ` [PATCH 10/19] wifi: rtw88: coex: reassert the antenna path when associating luka.gejak
2026-07-24 18:32 ` [PATCH 11/19] wifi: rtw88: sdio: track free TX pages and OQT credits for RTL8723BS luka.gejak
2026-07-24 18:32 ` [PATCH 12/19] wifi: rtw88: sdio: handle the RTL8723BS management TX path luka.gejak
2026-07-24 18:32 ` [PATCH 13/19] wifi: rtw88: sdio: set up RX aggregation and interrupts for RTL8723BS luka.gejak
2026-07-24 18:32 ` [PATCH 14/19] wifi: rtw88: sdio: add TX back-pressure and retry on page starvation luka.gejak
2026-07-24 18:32 ` [PATCH 15/19] wifi: rtw88: record beacons from the target BSSID before authenticating luka.gejak
2026-07-24 18:32 ` [PATCH 16/19] wifi: rtw88: run the RTL8723BS association register sequence luka.gejak
2026-07-24 18:33 ` [PATCH 17/19] wifi: rtw88: calibrate and tune the PHY for RTL8723BS luka.gejak
2026-07-24 21:05   ` Bitterblue Smith
2026-07-24 18:33 ` [PATCH 18/19] wifi: rtw88: match the RTL8723BS firmware connect and power save behaviour luka.gejak
2026-07-24 22:10   ` Bitterblue Smith [this message]
2026-07-24 18:33 ` [PATCH 19/19] wifi: rtw88: advertise the correct receive capabilities on RTL8723BS luka.gejak
2026-07-24 22:29   ` Bitterblue Smith

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=fe9a4df1-1ea9-44b6-8f98-10130d37e55c@gmail.com \
    --to=rtl8821cerfe2@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=luka.gejak@linux.dev \
    --cc=pbrobinson@gmail.com \
    --cc=pkshih@realtek.com \
    --cc=straube.linux@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