Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH rtw-next 0/2] wifi: rtl8xxxu: fix two retry count overflows
@ 2026-11-27 18:53 Ahmet Zeren via B4 Relay
  2026-11-27 18:53 ` [PATCH rtw-next 1/2] wifi: rtl8xxxu: limit max_rate_tries to what mac80211 can pass Ahmet Zeren via B4 Relay
  2026-11-27 18:53 ` [PATCH rtw-next 2/2] wifi: rtl8xxxu: limit the retry count in the TX report Ahmet Zeren via B4 Relay
  0 siblings, 2 replies; 5+ messages in thread
From: Ahmet Zeren via B4 Relay @ 2026-11-27 18:53 UTC (permalink / raw)
  To: Ping-Ke Shih, Jes Sorensen; +Cc: linux-wireless, Luka Gejak, Ahmet Zeren

The retry count in mac80211's struct ieee80211_tx_rate is only 5 bits
wide, and rtl8xxxu overflows it in two places: max_rate_tries is set to
64, and the TX report passes up to 64 tries. I found these while porting
the injection changes to rtw88, as mentioned in the rtw88 thread.

Tested on RTL8192CU (0bda:8178) on 2.4 GHz, with injected frames to an
absent station and the retry count from the TX report:

                         before   after
  31 requested retries     16       30
  40 requested retries      8       30
  default limit (48)       16       30

(before, 31 retries fell back to the default limit, which the TX report
showed as 16.) checkpatch --strict, W=1 and sparse are clean.

AI tool use (Documentation/process/generated-content.rst): the patches
were written with help from Claude Code (Claude Opus 5.5). It was asked
to fix the overflow found in review and test the boundary values on
the RTL8192CU; that test showed the second one. I have reviewed and
tested the changes and take responsibility for them.

---
Ahmet Zeren (2):
      wifi: rtl8xxxu: limit max_rate_tries to what mac80211 can pass
      wifi: rtl8xxxu: limit the retry count in the TX report

 drivers/net/wireless/realtek/rtl8xxxu/core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
---
base-commit: ae6b9e98b9045e47f609ec2a8197a3f3109627cb
change-id: 20261127-b4-rtl8xxxu-retry-b98ae3a5e5ad

Best regards,
--  
Ahmet Zeren <niko3x@proton.me>



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH rtw-next 1/2] wifi: rtl8xxxu: limit max_rate_tries to what mac80211 can pass
  2026-11-27 18:53 [PATCH rtw-next 0/2] wifi: rtl8xxxu: fix two retry count overflows Ahmet Zeren via B4 Relay
@ 2026-11-27 18:53 ` Ahmet Zeren via B4 Relay
  2026-11-30  2:11   ` Ping-Ke Shih
  2026-11-27 18:53 ` [PATCH rtw-next 2/2] wifi: rtl8xxxu: limit the retry count in the TX report Ahmet Zeren via B4 Relay
  1 sibling, 1 reply; 5+ messages in thread
From: Ahmet Zeren via B4 Relay @ 2026-11-27 18:53 UTC (permalink / raw)
  To: Ping-Ke Shih, Jes Sorensen; +Cc: linux-wireless, Luka Gejak, Ahmet Zeren

From: Ahmet Zeren <niko3x@proton.me>

The retry count of a rate is a 5-bit field in mac80211, so it cannot
hold the 64 tries set as max_rate_tries. Radiotap retry counts above 30
wrap around: 31 retries fall back to the default retry limit and 40
retries become 8.

Limit max_rate_tries by IEEE80211_MAX_TX_RETRY as well.

Tested on RTL8192CU (0bda:8178) with injected frames to an absent
station, reading the retry count from the TX report: 31 and 40
requested retries are now capped at 30.

Fixes: b2ccb6a04761 ("wifi: rtl8xxxu: honour the retry count of injected frames on gen1 chips")
Signed-off-by: Ahmet Zeren <niko3x@proton.me>
---
 drivers/net/wireless/realtek/rtl8xxxu/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/core.c b/drivers/net/wireless/realtek/rtl8xxxu/core.c
index f10397294a5..c42bb3666c8 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/core.c
@@ -8131,7 +8131,7 @@ static int rtl8xxxu_probe(struct usb_interface *interface,
 	SET_IEEE80211_PERM_ADDR(hw, priv->mac_addr);
 
 	hw->extra_tx_headroom = priv->fops->tx_desc_size;
-	hw->max_rate_tries = TXDESC32_RETRY_LIMIT_MAX + 1;
+	hw->max_rate_tries = min(TXDESC32_RETRY_LIMIT_MAX + 1, IEEE80211_MAX_TX_RETRY);
 	ieee80211_hw_set(hw, SIGNAL_DBM);
 
 	/*

-- 
2.56.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH rtw-next 2/2] wifi: rtl8xxxu: limit the retry count in the TX report
  2026-11-27 18:53 [PATCH rtw-next 0/2] wifi: rtl8xxxu: fix two retry count overflows Ahmet Zeren via B4 Relay
  2026-11-27 18:53 ` [PATCH rtw-next 1/2] wifi: rtl8xxxu: limit max_rate_tries to what mac80211 can pass Ahmet Zeren via B4 Relay
@ 2026-11-27 18:53 ` Ahmet Zeren via B4 Relay
  2026-11-30  2:14   ` Ping-Ke Shih
  1 sibling, 1 reply; 5+ messages in thread
From: Ahmet Zeren via B4 Relay @ 2026-11-27 18:53 UTC (permalink / raw)
  To: Ping-Ke Shih, Jes Sorensen; +Cc: linux-wireless, Luka Gejak, Ahmet Zeren

From: Ahmet Zeren <niko3x@proton.me>

The CCX TX report has a 6-bit retry count, but the count passed to
mac80211 is only 5 bits wide. A frame sent with the default retry limit
of 48 is reported with 16 retries.

Limit the reported count to IEEE80211_MAX_TX_RETRY.

Tested on RTL8192CU (0bda:8178): a frame to an absent station sent with
the default retry limit is now reported with 30 retries instead of 16.

Fixes: 8b29fd95e2d3 ("wifi: rtl8xxxu: report real TX status on RTL8188CU/RTL8192CU")
Signed-off-by: Ahmet Zeren <niko3x@proton.me>
---
 drivers/net/wireless/realtek/rtl8xxxu/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/core.c b/drivers/net/wireless/realtek/rtl8xxxu/core.c
index c42bb3666c8..f923983bd44 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/core.c
@@ -5240,7 +5240,8 @@ static void rtl8xxxu_tx_report_poll_work(struct work_struct *work)
 	ieee80211_tx_info_clear_status(tx_info);
 	if (!(tx_info->flags & IEEE80211_TX_CTL_INJECTED))
 		tx_info->status.rates[0].idx = -1;
-	tx_info->status.rates[0].count = (retry & CCX_RETRY_CNT_MASK) + 1;
+	tx_info->status.rates[0].count = min((retry & CCX_RETRY_CNT_MASK) + 1,
+					     IEEE80211_MAX_TX_RETRY);
 	if (status & CCX_PKT_OK)
 		tx_info->flags |= IEEE80211_TX_STAT_ACK;
 

-- 
2.56.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: [PATCH rtw-next 1/2] wifi: rtl8xxxu: limit max_rate_tries to what mac80211 can pass
  2026-11-27 18:53 ` [PATCH rtw-next 1/2] wifi: rtl8xxxu: limit max_rate_tries to what mac80211 can pass Ahmet Zeren via B4 Relay
@ 2026-11-30  2:11   ` Ping-Ke Shih
  0 siblings, 0 replies; 5+ messages in thread
From: Ping-Ke Shih @ 2026-11-30  2:11 UTC (permalink / raw)
  To: niko3x@proton.me, Jes Sorensen; +Cc: linux-wireless@vger.kernel.org, Luka Gejak

Ahmet Zeren via B4 Relay <devnull+niko3x.proton.me@kernel.org> wrote:
> From: Ahmet Zeren <niko3x@proton.me>
> 
> The retry count of a rate is a 5-bit field in mac80211, so it cannot
> hold the 64 tries set as max_rate_tries. Radiotap retry counts above 30
> wrap around: 31 retries fall back to the default retry limit and 40
> retries become 8.
> 
> Limit max_rate_tries by IEEE80211_MAX_TX_RETRY as well.
> 
> Tested on RTL8192CU (0bda:8178) with injected frames to an absent
> station, reading the retry count from the TX report: 31 and 40
> requested retries are now capped at 30.
> 
> Fixes: b2ccb6a04761 ("wifi: rtl8xxxu: honour the retry count of injected frames on gen1 chips")
> Signed-off-by: Ahmet Zeren <niko3x@proton.me>

Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH rtw-next 2/2] wifi: rtl8xxxu: limit the retry count in the TX report
  2026-11-27 18:53 ` [PATCH rtw-next 2/2] wifi: rtl8xxxu: limit the retry count in the TX report Ahmet Zeren via B4 Relay
@ 2026-11-30  2:14   ` Ping-Ke Shih
  0 siblings, 0 replies; 5+ messages in thread
From: Ping-Ke Shih @ 2026-11-30  2:14 UTC (permalink / raw)
  To: niko3x@proton.me, Jes Sorensen; +Cc: linux-wireless@vger.kernel.org, Luka Gejak

Ahmet Zeren via B4 Relay <devnull+niko3x.proton.me@kernel.org> wrote:
> From: Ahmet Zeren <niko3x@proton.me>
> 
> The CCX TX report has a 6-bit retry count, but the count passed to
> mac80211 is only 5 bits wide. A frame sent with the default retry limit
> of 48 is reported with 16 retries.
> 
> Limit the reported count to IEEE80211_MAX_TX_RETRY.
> 
> Tested on RTL8192CU (0bda:8178): a frame to an absent station sent with
> the default retry limit is now reported with 30 retries instead of 16.
> 
> Fixes: 8b29fd95e2d3 ("wifi: rtl8xxxu: report real TX status on RTL8188CU/RTL8192CU")
> Signed-off-by: Ahmet Zeren <niko3x@proton.me>

Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-30  2:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 18:53 [PATCH rtw-next 0/2] wifi: rtl8xxxu: fix two retry count overflows Ahmet Zeren via B4 Relay
2026-11-27 18:53 ` [PATCH rtw-next 1/2] wifi: rtl8xxxu: limit max_rate_tries to what mac80211 can pass Ahmet Zeren via B4 Relay
2026-11-30  2:11   ` Ping-Ke Shih
2026-11-27 18:53 ` [PATCH rtw-next 2/2] wifi: rtl8xxxu: limit the retry count in the TX report Ahmet Zeren via B4 Relay
2026-11-30  2:14   ` 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