* [PATCH rtw-next v2 0/2] wifi: rtl8xxxu: report real TX status on RTL8188CU/RTL8192CU
@ 2026-11-22 6:00 Ahmet Zeren via B4 Relay
2026-11-22 6:00 ` [PATCH rtw-next v2 1/2] wifi: rtl8xxxu: don't report frames sent without ACK as acked Ahmet Zeren via B4 Relay
2026-11-22 6:00 ` [PATCH rtw-next v2 2/2] wifi: rtl8xxxu: report real TX status on RTL8188CU/RTL8192CU Ahmet Zeren via B4 Relay
0 siblings, 2 replies; 3+ messages in thread
From: Ahmet Zeren via B4 Relay @ 2026-11-22 6:00 UTC (permalink / raw)
To: Jes Sorensen; +Cc: linux-wireless, linux-kernel, Ping-Ke Shih, Ahmet Zeren
rtl8xxxu reports every frame as acked as soon as its USB transfer
completes, so mac80211 and userspace never learn that a frame was lost.
Patch 1 stops reporting frames sent with IEEE80211_TX_CTL_NO_ACK as
acked.
Patch 2 uses the CCX TX report of the RTL8188CU/RTL8192CU firmware to
report the real ACK status and retry count. These chips post C2H events
in the REG_C2HEVT_MSG_NORMAL mailbox, which has to be polled, and the
report does not identify the frame, so only one frame at a time requests
a report. Other frames are reported as before. The vendor driver uses
the same report (C2H_CCX_TX_RPT, struct txrpt_ccx_8192c); the firmware
in linux-firmware (v88.2) sends it.
Gen2 chips and the RTL8188EU have their own report formats and are not
covered here.
Testing on RTL8192CU (0bda:8178), by injecting unicast frames and reading
the TX status mac80211 hands back to a monitor interface: frames to a
present station are reported acked, with the retries that happened;
frames to an absent station are reported failed with the hardware's
retry count, including when the retries take seconds; frames sent right
after are not confused with an earlier report. Interface down/up and
module removal with a report pending were also tested. checkpatch --strict,
W=1 and sparse are clean for each patch.
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 research how these chips report TX status (vendor driver, rtlwifi,
rtw88), confirm the report format on the hardware, write the patches
and run the tests above. I have reviewed and tested the changes and take
responsibility for them.
---
Changes in v2:
- Patch 2: move the C2H event defines to regs.h under REG_C2HEVT_CLEAR
and REG_C2HEVT_MSG_NORMAL; name the report fields as offsets from the
mailbox and as masks.
- Patch 2: rename the work to rtl8xxxu_tx_report_poll_work().
- Patch 2: group the new priv fields, order .has_c2hevt_tx_report as in
struct rtl8xxxu_fileops, fix declaration order.
- Collect Reviewed-by from Ping-Ke.
- Link to v1: https://patch.msgid.link/20261120-b4-tx-status-v1-0-abdab21c77fe@proton.me
---
Ahmet Zeren (2):
wifi: rtl8xxxu: don't report frames sent without ACK as acked
wifi: rtl8xxxu: report real TX status on RTL8188CU/RTL8192CU
drivers/net/wireless/realtek/rtl8xxxu/8192c.c | 1 +
drivers/net/wireless/realtek/rtl8xxxu/core.c | 128 ++++++++++++++++++++++-
drivers/net/wireless/realtek/rtl8xxxu/regs.h | 9 ++
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 6 ++
4 files changed, 142 insertions(+), 2 deletions(-)
---
base-commit: 0bdc579dbfc251a6b6838ee9459b6771b948c617
change-id: 20261120-b4-tx-status-df4722e9679a
Best regards,
--
Ahmet Zeren <niko3x@proton.me>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH rtw-next v2 1/2] wifi: rtl8xxxu: don't report frames sent without ACK as acked
2026-11-22 6:00 [PATCH rtw-next v2 0/2] wifi: rtl8xxxu: report real TX status on RTL8188CU/RTL8192CU Ahmet Zeren via B4 Relay
@ 2026-11-22 6:00 ` Ahmet Zeren via B4 Relay
2026-11-22 6:00 ` [PATCH rtw-next v2 2/2] wifi: rtl8xxxu: report real TX status on RTL8188CU/RTL8192CU Ahmet Zeren via B4 Relay
1 sibling, 0 replies; 3+ messages in thread
From: Ahmet Zeren via B4 Relay @ 2026-11-22 6:00 UTC (permalink / raw)
To: Jes Sorensen; +Cc: linux-wireless, linux-kernel, Ping-Ke Shih, Ahmet Zeren
From: Ahmet Zeren <niko3x@proton.me>
Every frame whose USB transfer succeeded is reported as acked, including
those sent with IEEE80211_TX_CTL_NO_ACK. Report these as
IEEE80211_TX_STAT_NOACK_TRANSMITTED instead.
Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Ahmet Zeren <niko3x@proton.me>
---
drivers/net/wireless/realtek/rtl8xxxu/core.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/core.c b/drivers/net/wireless/realtek/rtl8xxxu/core.c
index 604bb1e5b05..ab2818986cc 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/core.c
@@ -5167,8 +5167,12 @@ static void rtl8xxxu_tx_complete(struct urb *urb)
tx_info->status.rates[0].idx = -1;
tx_info->status.rates[0].count = 0;
- if (!urb->status)
- tx_info->flags |= IEEE80211_TX_STAT_ACK;
+ if (!urb->status) {
+ if (tx_info->flags & IEEE80211_TX_CTL_NO_ACK)
+ tx_info->flags |= IEEE80211_TX_STAT_NOACK_TRANSMITTED;
+ else
+ tx_info->flags |= IEEE80211_TX_STAT_ACK;
+ }
ieee80211_tx_status_irqsafe(hw, skb);
--
2.56.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH rtw-next v2 2/2] wifi: rtl8xxxu: report real TX status on RTL8188CU/RTL8192CU
2026-11-22 6:00 [PATCH rtw-next v2 0/2] wifi: rtl8xxxu: report real TX status on RTL8188CU/RTL8192CU Ahmet Zeren via B4 Relay
2026-11-22 6:00 ` [PATCH rtw-next v2 1/2] wifi: rtl8xxxu: don't report frames sent without ACK as acked Ahmet Zeren via B4 Relay
@ 2026-11-22 6:00 ` Ahmet Zeren via B4 Relay
1 sibling, 0 replies; 3+ messages in thread
From: Ahmet Zeren via B4 Relay @ 2026-11-22 6:00 UTC (permalink / raw)
To: Jes Sorensen; +Cc: linux-wireless, linux-kernel, Ping-Ke Shih, Ahmet Zeren
From: Ahmet Zeren <niko3x@proton.me>
The driver reports every frame as acked once its USB transfer is done.
The firmware of these chips can send a CCX TX report with the ACK status
and retry count of a frame through the C2H event mailbox. The report
does not say which frame it is for, so request it for only one frame at
a time, poll the mailbox after the frame was sent and report its status
from there. Frames that request status while another one is pending are
reported as before.
Tested on RTL8192CU (0bda:8178) with unicast frames: frames to a present
station are reported acked, frames to an absent station are reported
failed with the retry count the hardware used, also when that takes
seconds.
Signed-off-by: Ahmet Zeren <niko3x@proton.me>
---
drivers/net/wireless/realtek/rtl8xxxu/8192c.c | 1 +
drivers/net/wireless/realtek/rtl8xxxu/core.c | 120 +++++++++++++++++++++++
drivers/net/wireless/realtek/rtl8xxxu/regs.h | 9 ++
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 6 ++
4 files changed, 136 insertions(+)
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/8192c.c b/drivers/net/wireless/realtek/rtl8xxxu/8192c.c
index 508322a8f31..e31bf16d0ee 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/8192c.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/8192c.c
@@ -722,6 +722,7 @@ struct rtl8xxxu_fileops rtl8192cu_fops = {
.rx_agg_buf_size = 16000,
.tx_desc_size = sizeof(struct rtl8xxxu_txdesc32),
.rx_desc_size = sizeof(struct rtl8xxxu_rxdesc16),
+ .has_c2hevt_tx_report = 1,
.supports_ap = 1,
.hw_feature_report = 0,
.max_macid_num = 32,
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/core.c b/drivers/net/wireless/realtek/rtl8xxxu/core.c
index ab2818986cc..bbe6cae8cb8 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/core.c
@@ -5148,6 +5148,105 @@ static void rtl8xxxu_free_tx_urb(struct rtl8xxxu_priv *priv,
spin_unlock_irqrestore(&priv->tx_urb_lock, flags);
}
+/*
+ * Gen1 chips can report the ACK status of a frame through the C2H event
+ * mailbox. There is no way to tell which frame a report belongs to, so
+ * only one frame at a time asks for one, until its report arrives. The
+ * report comes when the frame is done, which can take seconds with many
+ * retries, so wait for it rather than risk taking it for the next frame.
+ */
+#define RTL8XXXU_TX_REPORT_TIMEOUT msecs_to_jiffies(10000)
+
+static bool rtl8xxxu_tx_report_claim(struct rtl8xxxu_priv *priv,
+ struct sk_buff *skb)
+{
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+ struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
+ bool claimed = false;
+ unsigned long flags;
+
+ if (!priv->fops->has_c2hevt_tx_report ||
+ !(tx_info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS) ||
+ (tx_info->flags & IEEE80211_TX_CTL_NO_ACK) ||
+ is_multicast_ether_addr(hdr->addr1))
+ return false;
+
+ spin_lock_irqsave(&priv->tx_report_lock, flags);
+ if (!priv->tx_report_skb) {
+ priv->tx_report_skb = skb;
+ claimed = true;
+ }
+ spin_unlock_irqrestore(&priv->tx_report_lock, flags);
+
+ return claimed;
+}
+
+static bool rtl8xxxu_tx_report_release(struct rtl8xxxu_priv *priv,
+ struct sk_buff *skb)
+{
+ unsigned long flags;
+ bool claimed;
+
+ spin_lock_irqsave(&priv->tx_report_lock, flags);
+ claimed = priv->tx_report_skb == skb;
+ if (claimed)
+ priv->tx_report_skb = NULL;
+ spin_unlock_irqrestore(&priv->tx_report_lock, flags);
+
+ return claimed;
+}
+
+static void rtl8xxxu_tx_report_poll_work(struct work_struct *work)
+{
+ struct rtl8xxxu_priv *priv = container_of(work, struct rtl8xxxu_priv,
+ tx_report_poll_work.work);
+ struct ieee80211_tx_info *tx_info;
+ unsigned long flags, elapsed;
+ u8 retry = 0, status = 0;
+ bool reported = false;
+ struct sk_buff *skb;
+
+ if (rtl8xxxu_read8(priv, REG_C2HEVT_CLEAR) == C2H_EVT_FW_CLOSE) {
+ u8 id = rtl8xxxu_read8(priv, REG_C2HEVT_MSG_NORMAL);
+
+ if ((id & C2H_EVT_ID_MASK) == C2H_EVT_CCX_TX_RPT) {
+ retry = rtl8xxxu_read8(priv, REG_C2HEVT_MSG_NORMAL +
+ C2H_EVT_CCX_RETRY_OFFSET);
+ status = rtl8xxxu_read8(priv, REG_C2HEVT_MSG_NORMAL +
+ C2H_EVT_CCX_STATUS_OFFSET);
+ reported = true;
+ }
+ rtl8xxxu_write8(priv, REG_C2HEVT_CLEAR, C2H_EVT_HOST_CLOSE);
+ }
+
+ elapsed = jiffies - priv->tx_report_start;
+ if (!reported && elapsed < RTL8XXXU_TX_REPORT_TIMEOUT) {
+ /* Most frames are done within a few ms, poll often at first */
+ ieee80211_queue_delayed_work(priv->hw, &priv->tx_report_poll_work,
+ elapsed < msecs_to_jiffies(20) ?
+ 1 : msecs_to_jiffies(10));
+ return;
+ }
+
+ spin_lock_irqsave(&priv->tx_report_lock, flags);
+ skb = priv->tx_report_skb;
+ priv->tx_report_skb = NULL;
+ spin_unlock_irqrestore(&priv->tx_report_lock, flags);
+
+ if (!skb)
+ return;
+
+ tx_info = IEEE80211_SKB_CB(skb);
+ 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;
+ if (status & CCX_PKT_OK)
+ tx_info->flags |= IEEE80211_TX_STAT_ACK;
+
+ ieee80211_tx_status_irqsafe(priv->hw, skb);
+}
+
static void rtl8xxxu_tx_complete(struct urb *urb)
{
struct sk_buff *skb = (struct sk_buff *)urb->context;
@@ -5163,6 +5262,16 @@ static void rtl8xxxu_tx_complete(struct urb *urb)
skb_pull(skb, priv->fops->tx_desc_size);
+ if (READ_ONCE(priv->tx_report_skb) == skb) {
+ if (!urb->status) {
+ priv->tx_report_start = jiffies;
+ ieee80211_queue_delayed_work(hw, &priv->tx_report_poll_work, 0);
+ rtl8xxxu_free_tx_urb(priv, tx_urb);
+ return;
+ }
+ rtl8xxxu_tx_report_release(priv, skb);
+ }
+
ieee80211_tx_info_clear_status(tx_info);
tx_info->status.rates[0].idx = -1;
tx_info->status.rates[0].count = 0;
@@ -5592,6 +5701,9 @@ static void rtl8xxxu_tx(struct ieee80211_hw *hw,
priv->fops->fill_txdesc(hw, hdr, tx_info, tx_desc, sgi, short_preamble,
ampdu_enable, rts_rate, macid);
+ if (rtl8xxxu_tx_report_claim(priv, skb))
+ tx_desc->txdw2 |= cpu_to_le32(TXDESC32_ACK_REPORT);
+
rtl8xxxu_calc_tx_desc_csum(tx_desc);
/* avoid zero checksum make tx hang */
@@ -5606,6 +5718,7 @@ static void rtl8xxxu_tx(struct ieee80211_hw *hw,
if (ret) {
usb_unanchor_urb(&tx_urb->urb);
rtl8xxxu_free_tx_urb(priv, tx_urb);
+ rtl8xxxu_tx_report_release(priv, skb);
goto error;
}
return;
@@ -7539,6 +7652,11 @@ static void rtl8xxxu_stop(struct ieee80211_hw *hw, bool suspend)
usb_kill_anchored_urbs(&priv->rx_anchor);
usb_kill_anchored_urbs(&priv->tx_anchor);
+ cancel_delayed_work_sync(&priv->tx_report_poll_work);
+ if (priv->tx_report_skb) {
+ ieee80211_free_txskb(hw, priv->tx_report_skb);
+ priv->tx_report_skb = NULL;
+ }
if (priv->usb_interrupts)
usb_kill_anchored_urbs(&priv->int_anchor);
@@ -7851,6 +7969,8 @@ static int rtl8xxxu_probe(struct usb_interface *interface,
INIT_DELAYED_WORK(&priv->rx_urb_wq, rtl8xxxu_rx_urb_work);
INIT_DELAYED_WORK(&priv->ra_watchdog, rtl8xxxu_watchdog_callback);
INIT_DELAYED_WORK(&priv->update_beacon_work, rtl8xxxu_update_beacon_work_callback);
+ spin_lock_init(&priv->tx_report_lock);
+ INIT_DELAYED_WORK(&priv->tx_report_poll_work, rtl8xxxu_tx_report_poll_work);
skb_queue_head_init(&priv->c2hcmd_queue);
usb_set_intfdata(interface, hw);
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/regs.h b/drivers/net/wireless/realtek/rtl8xxxu/regs.h
index 2131d07c580..508f1b042b1 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/regs.h
+++ b/drivers/net/wireless/realtek/rtl8xxxu/regs.h
@@ -447,11 +447,20 @@
/* 8188EU */
#define REG_32K_CTRL 0x0194
#define REG_C2HEVT_MSG_NORMAL 0x01a0
+#define C2H_EVT_ID_MASK GENMASK(3, 0)
+#define C2H_EVT_CCX_TX_RPT 3
+#define C2H_EVT_PAYLOAD_OFFSET 2
+#define C2H_EVT_CCX_RETRY_OFFSET (C2H_EVT_PAYLOAD_OFFSET + 0)
+#define CCX_RETRY_CNT_MASK GENMASK(5, 0)
+#define C2H_EVT_CCX_STATUS_OFFSET (C2H_EVT_PAYLOAD_OFFSET + 7)
+#define CCX_PKT_OK BIT(6)
#define C2H_HW_FEATURE_REPORT 0x19
#define C2H_HW_FEATURE_DUMP 0xfd
/* 8192EU/8723BU/8812 */
#define REG_C2HEVT_CMD_ID_8723B 0x01ae
#define REG_C2HEVT_CLEAR 0x01af
+#define C2H_EVT_HOST_CLOSE 0x00
+#define C2H_EVT_FW_CLOSE 0xff
#define REG_C2HEVT_MSG_TEST 0x01b8
#define REG_MCUTST_1 0x01c0
#define REG_FMTHR 0x01c8
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
index 8cbadcf7190..1e20cece59e 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
@@ -1811,6 +1811,11 @@ struct rtl8xxxu_priv {
bool shutdown;
struct delayed_work rx_urb_wq;
+ spinlock_t tx_report_lock; /* protects tx_report_skb */
+ struct sk_buff *tx_report_skb;
+ unsigned long tx_report_start;
+ struct delayed_work tx_report_poll_work;
+
u8 mac_addr[ETH_ALEN];
char chip_name[8];
char chip_vendor[8];
@@ -2009,6 +2014,7 @@ struct rtl8xxxu_fileops {
char rx_desc_size;
u8 has_s0s1:1;
u8 has_tx_report:1;
+ u8 has_c2hevt_tx_report:1;
u8 gen2_thermal_meter:1;
u8 needs_full_init:1;
u8 init_reg_rxfltmap:1;
--
2.56.1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-22 6:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-22 6:00 [PATCH rtw-next v2 0/2] wifi: rtl8xxxu: report real TX status on RTL8188CU/RTL8192CU Ahmet Zeren via B4 Relay
2026-11-22 6:00 ` [PATCH rtw-next v2 1/2] wifi: rtl8xxxu: don't report frames sent without ACK as acked Ahmet Zeren via B4 Relay
2026-11-22 6:00 ` [PATCH rtw-next v2 2/2] wifi: rtl8xxxu: report real TX status on RTL8188CU/RTL8192CU Ahmet Zeren via B4 Relay
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®