Skip to contentSkip to conversation

wifi: rtw88: usb: don't report the aggregation buffer as a frame

PATCH Superseded Ho Jie Feng 3 participants 5 messages Oct 30 – Nov 2 Realtek wireless driver (rtw88)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 wifi: rtw88: usb: don't report the aggregation buffer as a frame

When rtw_usb_tx_agg_skb() has more than one frame queued, it copies them into a new buffer. That buffer was also handed to mac80211, as one additional TX completion.

Report TX status only for the original frames, and free the aggregate buffer without passing it to mac80211.

Fixes a82dfd33d123 ("wifi: rtw88: Add common USB chip support")

---
Changes in v3:
- Change to dev_consume_skb_any from a suggestion by Luka Gejak Changes in v2:
- Remove unused drv_frame members in structs

 drivers/net/wireless/realtek/rtw88/usb.c | 9 +++++++++
 drivers/net/wireless/realtek/rtw88/usb.h | 1 +
 2 files changed, 10 insertions(+)
drivers/net/wireless/realtek/rtw88/usb.c +9 -0
index 715a2ce342d92..10f6d3bea0dfd 100644
@@ -342,6 +342,11 @@ static void rtw_usb_write_port_tx_complete(struct urb *urb)
 
 		skb_pull(skb, rtwdev->chip->tx_pkt_desc_sz);
 
+		if (tx_data->drv_frame) {
+			dev_consume_skb_any(skb);
+			continue;
+		}
+
 		/* enqueue to wait for tx report */
 		if (info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS) {
 			rtw_tx_report_enqueue(rtwdev, skb, tx_data->sn);
@@ -431,6 +436,9 @@ static bool rtw_usb_tx_agg_skb(struct rtw_usb *rtwusb, struct sk_buff_head *list
 		goto queue;
 	}
 
+	/* report TX status only for the original frames */
+	rtw_usb_get_tx_data(skb_head)->drv_frame = true;
+
 	while (skb_iter) {
 		unsigned long flags;
 
@@ -655,6 +663,7 @@ static int rtw_usb_tx_write(struct rtw_dev *rtwdev,
 	rtw_tx_fill_txdesc_checksum(rtwdev, pkt_info, skb->data);
 	tx_data = rtw_usb_get_tx_data(skb);
 	tx_data->sn = pkt_info->sn;
+	tx_data->drv_frame = false;
 
 	skb_queue_tail(&rtwusb->tx_queue[ep], skb);
 
drivers/net/wireless/realtek/rtw88/usb.h +1 -0
index 94ff21dd08463..e861e9a66ab22 100644
@@ -59,6 +59,7 @@ struct rx_usb_ctrl_block {
 
 struct rtw_usb_tx_data {
 	u8 sn;
+	bool drv_frame;
 };
 
 struct rtw_usb {

base-commit: 9b0be45d4d52fd223994e151f169743a97abd290

Signature · 1 line
2.55.0
Reviewed-by on v3 1/1
#1 lore raw
Quoted 11 lines · Ho Jie Feng

When rtw_usb_tx_agg_skb() has more than one frame queued, it copies them into a new buffer. That buffer was also handed to mac80211, as one additional TX completion.

Report TX status only for the original frames, and free the aggregate buffer without passing it to mac80211.

Fixes a82dfd33d123 ("wifi: rtw88: Add common USB chip support")

---

Looks good to me,

Best regards,
Luka Gejak

maintainer
#2 lore raw
In reply to Ho Jie Feng
Quoted 6 lines · Ho Jie Feng

When rtw_usb_tx_agg_skb() has more than one frame queued, it copies them into a new buffer. That buffer was also handed to mac80211, as one additional TX completion.

Report TX status only for the original frames, and free the aggregate buffer without passing it to mac80211.

The rtw_usb_write_port() might be failed and call ieee80211_purge_tx_queue() to purge txcb->tx_ack_queue list. Should we check if the tail skb of txcb->tx_ack_queue (or just check skb_head) is drv_frame=true?

drivers/net/wireless/realtek/rtw88/usb.c static bool rtw_usb_tx_agg_skb(struct rtw_usb *rtwusb, struct sk_buff_head *list · line 440

Quoted 6 lines
drivers/net/wireless/realtek/rtw88/usb.c +2 -0
@@ -431,6 +436,9 @@ static bool rtw_usb_tx_agg_skb(struct rtw_usb *rtwusb, struct sk_buff_head *list
                goto queue;
        }
 
+       /* report TX status only for the original frames */
+       rtw_usb_get_tx_data(skb_head)->drv_frame = true;

If we can just check drv_frame by skb_head, just declare a local
struct rtw_usb_tx_data *skb_head_tx_data.

Quoted 4 lines
drivers/net/wireless/realtek/rtw88/usb.c +1 -0
+
        while (skb_iter) {
                unsigned long flags;
 
author
#3 lore raw
Quoted 6 lines · Ping-Ke Shih
Quoted 4 lines · Ho Jie Feng

When rtw_usb_tx_agg_skb() has more than one frame queued, it copies them into a new buffer. That buffer was also handed to mac80211, as one additional TX completion.

Quoted 6 lines
Quoted 2 lines

Report TX status only for the original frames, and free the aggregate buffer without passing it to mac80211.

The rtw_usb_write_port() might be failed and call ieee80211_purge_tx_queue() to purge txcb->tx_ack_queue list. Should we check if the tail skb of txcb->tx_ack_queue (or just check skb_head) is drv_frame=true?

I traced ieee80211_purge_tx_queue to ieee80211_report_used_skb, and based on the code here:
https://elixir.bootlin.com/linux/v7.3/source/net/mac80211/status.c#L759

I don't think it fulfills any of the conditions, so drv_frame=true entries should just go through a normal skb free path.

Quoted 9 lines

drivers/net/wireless/realtek/rtw88/usb.c static bool rtw_usb_tx_agg_skb(struct rtw_usb *rtwusb, struct sk_buff_head *list · line 440

Quoted 6 lines
drivers/net/wireless/realtek/rtw88/usb.c +2 -0
@@ -431,6 +436,9 @@ static bool rtw_usb_tx_agg_skb(struct rtw_usb *rtwusb, struct sk_buff_head *list
                goto queue;
        }
 
+       /* report TX status only for the original frames */
+       rtw_usb_get_tx_data(skb_head)->drv_frame = true;

If we can just check drv_frame by skb_head, just declare a local
struct rtw_usb_tx_data *skb_head_tx_data.

Is this still needed if ieee80211_purge_tx_queue works?

Quoted 6 lines
Quoted 4 lines
drivers/net/wireless/realtek/rtw88/usb.c +1 -0
+
        while (skb_iter) {
                unsigned long flags;
 
maintainer
#4 lore raw
Quoted 13 lines · Jie Feng
Quoted 6 lines · Ping-Ke Shih
Quoted 4 lines · Ho Jie Feng

When rtw_usb_tx_agg_skb() has more than one frame queued, it copies them into a new buffer. That buffer was also handed to mac80211, as one additional TX completion.

Quoted 6 lines
Quoted 2 lines

Report TX status only for the original frames, and free the aggregate buffer without passing it to mac80211.

The rtw_usb_write_port() might be failed and call ieee80211_purge_tx_queue() to purge txcb->tx_ack_queue list. Should we check if the tail skb of txcb->tx_ack_queue (or just check skb_head) is drv_frame=true?

Quoted 6 lines

I traced ieee80211_purge_tx_queue to ieee80211_report_used_skb, and based on the code here:
https://elixir.bootlin.com/linux/v7.3/source/net/mac80211/status.c#L759

I don't think it fulfills any of the conditions, so drv_frame=true entries should just go through a normal skb free path.

Can you add a description in commit message about this?

Quoted 11 lines
Quoted 10 lines

drivers/net/wireless/realtek/rtw88/usb.c static bool rtw_usb_tx_agg_skb(struct rtw_usb *rtwusb, struct sk_buff_head *list · line 440

Quoted 7 lines
drivers/net/wireless/realtek/rtw88/usb.c +2 -0
@@ -431,6 +436,9 @@ static bool rtw_usb_tx_agg_skb(struct rtw_usb *rtwusb, struct sk_buff_head *list
                goto queue;
        }
 
+       /* report TX status only for the original frames */
+       rtw_usb_get_tx_data(skb_head)->drv_frame = true;

If we can just check drv_frame by skb_head, just declare a local
struct rtw_usb_tx_data *skb_head_tx_data.

Is this still needed if ieee80211_purge_tx_queue works?

no need.