The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH rtw-next 0/2] wifi: rtl8xxxu: report real TX status on RTL8188CU/RTL8192CU
@ 2026-11-19 22:12 Ahmet Zeren via B4 Relay
  2026-11-19 22:12 ` [PATCH rtw-next 1/2] wifi: rtl8xxxu: don't report frames sent without ACK as acked Ahmet Zeren via B4 Relay
  2026-11-19 22:12 ` [PATCH rtw-next 2/2] wifi: rtl8xxxu: report real TX status on RTL8188CU/RTL8192CU Ahmet Zeren via B4 Relay
  0 siblings, 2 replies; 5+ messages in thread
From: Ahmet Zeren via B4 Relay @ 2026-11-19 22:12 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.

---
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/rtl8xxxu.h |  17 +++
 3 files changed, 144 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] 5+ messages in thread

* [PATCH rtw-next 1/2] wifi: rtl8xxxu: don't report frames sent without ACK as acked
  2026-11-19 22:12 [PATCH rtw-next 0/2] wifi: rtl8xxxu: report real TX status on RTL8188CU/RTL8192CU Ahmet Zeren via B4 Relay
@ 2026-11-19 22:12 ` Ahmet Zeren via B4 Relay
  2026-11-22  2:15   ` Ping-Ke Shih
  2026-11-19 22:12 ` [PATCH rtw-next 2/2] wifi: rtl8xxxu: report real TX status on RTL8188CU/RTL8192CU Ahmet Zeren via B4 Relay
  1 sibling, 1 reply; 5+ messages in thread
From: Ahmet Zeren via B4 Relay @ 2026-11-19 22:12 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.

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 604bb1e5b0..ab2818986c 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 related	[flat|nested] 5+ messages in thread

* [PATCH rtw-next 2/2] wifi: rtl8xxxu: report real TX status on RTL8188CU/RTL8192CU
  2026-11-19 22:12 [PATCH rtw-next 0/2] wifi: rtl8xxxu: report real TX status on RTL8188CU/RTL8192CU Ahmet Zeren via B4 Relay
  2026-11-19 22:12 ` [PATCH rtw-next 1/2] wifi: rtl8xxxu: don't report frames sent without ACK as acked Ahmet Zeren via B4 Relay
@ 2026-11-19 22:12 ` Ahmet Zeren via B4 Relay
  2026-11-22  2:58   ` Ping-Ke Shih
  1 sibling, 1 reply; 5+ messages in thread
From: Ahmet Zeren via B4 Relay @ 2026-11-19 22:12 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/rtl8xxxu.h |  17 ++++
 3 files changed, 138 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/8192c.c b/drivers/net/wireless/realtek/rtl8xxxu/8192c.c
index 508322a8f3..401cc1f6da 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/8192c.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/8192c.c
@@ -726,6 +726,7 @@ struct rtl8xxxu_fileops rtl8192cu_fops = {
 	.hw_feature_report = 0,
 	.max_macid_num = 32,
 	.max_sec_cam_num = 32,
+	.has_c2hevt_tx_report = 1,
 	.adda_1t_init = 0x0b1b25a0,
 	.adda_1t_path_on = 0x0bdb25a0,
 	.adda_2t_path_on_a = 0x04db25a4,
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/core.c b/drivers/net/wireless/realtek/rtl8xxxu/core.c
index ab2818986c..36f0a266af 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_tx_info *tx_info = IEEE80211_SKB_CB(skb);
+	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+	unsigned long flags;
+	bool claimed = false;
+
+	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_work(struct work_struct *work)
+{
+	struct rtl8xxxu_priv *priv = container_of(work, struct rtl8xxxu_priv,
+						  tx_report_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 + 2 +
+						     CCX_TX_RPT_RETRY);
+			status = rtl8xxxu_read8(priv, REG_C2HEVT_MSG_NORMAL + 2 +
+						      CCX_TX_RPT_STATUS);
+			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_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_TX_RPT_RETRY_CNT) + 1;
+	if (status & CCX_TX_RPT_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_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_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_work, rtl8xxxu_tx_report_work);
 	skb_queue_head_init(&priv->c2hcmd_queue);
 
 	usb_set_intfdata(interface, hw);
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
index 8cbadcf719..387ffdc970 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
@@ -1546,6 +1546,17 @@ enum c2h_evt_8723b {
 	C2H_8723B_FW_DEBUG = 0xff,
 };
 
+/* Gen1 C2H events are read from the REG_C2HEVT_MSG_NORMAL mailbox */
+#define C2H_EVT_HOST_CLOSE		0x00
+#define C2H_EVT_FW_CLOSE		0xff
+#define C2H_EVT_ID_MASK			GENMASK(3, 0)
+#define C2H_EVT_CCX_TX_RPT		3
+/* Offsets in the CCX TX report payload, after the 2 byte event header */
+#define CCX_TX_RPT_RETRY		0
+#define  CCX_TX_RPT_RETRY_CNT		GENMASK(5, 0)
+#define CCX_TX_RPT_STATUS		7
+#define  CCX_TX_RPT_PKT_OK		BIT(6)
+
 enum bt_info_src_8723b {
 	BT_INFO_SRC_8723B_WIFI_FW = 0x0,
         BT_INFO_SRC_8723B_BT_RSP = 0x1,
@@ -1919,6 +1930,11 @@ struct rtl8xxxu_priv {
 	struct work_struct c2hcmd_work;
 	struct sk_buff_head c2hcmd_queue;
 	struct delayed_work update_beacon_work;
+	/* Frame waiting for its TX report in the C2H event mailbox */
+	struct sk_buff *tx_report_skb;
+	spinlock_t tx_report_lock; /* protects tx_report_skb */
+	struct delayed_work tx_report_work;
+	unsigned long tx_report_start;
 	struct rtl8xxxu_btcoex bt_coex;
 	struct rtl8xxxu_ra_report ra_report;
 	struct rtl8xxxu_cfo_tracking cfo_tracking;
@@ -2009,6 +2025,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 related	[flat|nested] 5+ messages in thread

* RE: [PATCH rtw-next 1/2] wifi: rtl8xxxu: don't report frames sent without ACK as acked
  2026-11-19 22:12 ` [PATCH rtw-next 1/2] wifi: rtl8xxxu: don't report frames sent without ACK as acked Ahmet Zeren via B4 Relay
@ 2026-11-22  2:15   ` Ping-Ke Shih
  0 siblings, 0 replies; 5+ messages in thread
From: Ping-Ke Shih @ 2026-11-22  2:15 UTC (permalink / raw)
  To: niko3x@proton.me, Jes Sorensen
  Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org

Ahmet Zeren via B4 Relay <devnull+niko3x.proton.me@kernel.org> wrote:
> 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.
> 
> 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: report real TX status on RTL8188CU/RTL8192CU
  2026-11-19 22:12 ` [PATCH rtw-next 2/2] wifi: rtl8xxxu: report real TX status on RTL8188CU/RTL8192CU Ahmet Zeren via B4 Relay
@ 2026-11-22  2:58   ` Ping-Ke Shih
  0 siblings, 0 replies; 5+ messages in thread
From: Ping-Ke Shih @ 2026-11-22  2:58 UTC (permalink / raw)
  To: niko3x@proton.me, Jes Sorensen
  Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org

Ahmet Zeren via B4 Relay <devnull+niko3x.proton.me@kernel.org> wrote:

[...]

> diff --git a/drivers/net/wireless/realtek/rtl8xxxu/8192c.c
> b/drivers/net/wireless/realtek/rtl8xxxu/8192c.c
> index 508322a8f3..401cc1f6da 100644
> --- a/drivers/net/wireless/realtek/rtl8xxxu/8192c.c
> +++ b/drivers/net/wireless/realtek/rtl8xxxu/8192c.c
> @@ -726,6 +726,7 @@ struct rtl8xxxu_fileops rtl8192cu_fops = {

move .has_c2hevt_tx_report here to be almost the same order as
definition in struct rtl8xxxu_fileops.

>         .hw_feature_report = 0,
>         .max_macid_num = 32,
>         .max_sec_cam_num = 32,
> +       .has_c2hevt_tx_report = 1,
>         .adda_1t_init = 0x0b1b25a0,
>         .adda_1t_path_on = 0x0bdb25a0,
>         .adda_2t_path_on_a = 0x04db25a4,
> diff --git a/drivers/net/wireless/realtek/rtl8xxxu/core.c
> b/drivers/net/wireless/realtek/rtl8xxxu/core.c
> index ab2818986c..36f0a266af 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_tx_info *tx_info = IEEE80211_SKB_CB(skb);
> +       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
> +       unsigned long flags;
> +       bool claimed = false;

In reverse X'mas order.

> +
> +       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_work(struct work_struct *work)

I'd point out this is a polling work. How about naming rtl8xxxu_tx_report_poll_work()? 

> +{
> +       struct rtl8xxxu_priv *priv = container_of(work, struct rtl8xxxu_priv,
> +                                                 tx_report_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 + 2 +
> +                                                    CCX_TX_RPT_RETRY);
> +                       status = rtl8xxxu_read8(priv, REG_C2HEVT_MSG_NORMAL + 2 +
> +                                                     CCX_TX_RPT_STATUS);
> +                       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_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_TX_RPT_RETRY_CNT) + 1;
> +       if (status & CCX_TX_RPT_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;

[...]

> diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
> b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
> index 8cbadcf719..387ffdc970 100644
> --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
> +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
> @@ -1546,6 +1546,17 @@ enum c2h_evt_8723b {
>         C2H_8723B_FW_DEBUG = 0xff,
>  };
> 
> +/* Gen1 C2H events are read from the REG_C2HEVT_MSG_NORMAL mailbox */
> +#define C2H_EVT_HOST_CLOSE             0x00
> +#define C2H_EVT_FW_CLOSE               0xff

move these together with REG_C2HEVT_CLEAR

> +#define C2H_EVT_ID_MASK                        GENMASK(3, 0)
> +#define C2H_EVT_CCX_TX_RPT             3

move these together with REG_C2HEVT_MSG_NORMAL

> +/* Offsets in the CCX TX report payload, after the 2 byte event header */

Add a definition for 2 bytes?

> +#define CCX_TX_RPT_RETRY               0
> +#define  CCX_TX_RPT_RETRY_CNT          GENMASK(5, 0)
> +#define CCX_TX_RPT_STATUS              7
> +#define  CCX_TX_RPT_PKT_OK             BIT(6)

With hierarchy:

#define REG_C2HEVT_MSG_NORMAL		0x01a0
#define  C2H_EVT_ID_MASK			GENMASK(3, 0)
#define   C2H_EVT_CCX_TX_RPT		3
// the modified naming is still not good. Actually it is offset from 0x01a0
#define  C2HEVT_MSG_CCX_TX_RPT_RETRY		0
// the modified naming is also not good. Can you think of it a bit?
#define   CCX_TX_RPT_RETRY_CNT_MASK		GENMASK(5, 0)

> +
>  enum bt_info_src_8723b {
>         BT_INFO_SRC_8723B_WIFI_FW = 0x0,
>          BT_INFO_SRC_8723B_BT_RSP = 0x1,
> @@ -1919,6 +1930,11 @@ struct rtl8xxxu_priv {
>         struct work_struct c2hcmd_work;
>         struct sk_buff_head c2hcmd_queue;
>         struct delayed_work update_beacon_work;
> +       /* Frame waiting for its TX report in the C2H event mailbox */
> +       struct sk_buff *tx_report_skb;
> +       spinlock_t tx_report_lock; /* protects tx_report_skb */
> +       struct delayed_work tx_report_work;
> +       unsigned long tx_report_start;

Put in a small group like spinlock_t tx_urb_lock/rx_urb_lock.

>         struct rtl8xxxu_btcoex bt_coex;
>         struct rtl8xxxu_ra_report ra_report;
>         struct rtl8xxxu_cfo_tracking cfo_tracking;
> @@ -2009,6 +2025,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
> 

pw-bot: cr



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

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

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 22:12 [PATCH rtw-next 0/2] wifi: rtl8xxxu: report real TX status on RTL8188CU/RTL8192CU Ahmet Zeren via B4 Relay
2026-11-19 22:12 ` [PATCH rtw-next 1/2] wifi: rtl8xxxu: don't report frames sent without ACK as acked Ahmet Zeren via B4 Relay
2026-11-22  2:15   ` Ping-Ke Shih
2026-11-19 22:12 ` [PATCH rtw-next 2/2] wifi: rtl8xxxu: report real TX status on RTL8188CU/RTL8192CU Ahmet Zeren via B4 Relay
2026-11-22  2:58   ` 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