Skip to contentSkip to conversation

wifi: rtw88: usb: Simplify rtw_usb_write_data

PATCH In review Bitterblue Smith 3 participants 3 messages May 3, 2024 – May 9, 2024 Realtek wireless driver (rtw88)

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 wifi: rtw88: usb: Simplify rtw_usb_write_data

The skb created in this function always has the same headroom, the chip's TX descriptor size. (pkt_info->offset is set by rtw_usb_write_data_rsvd_page() to chip->tx_pkt_desc_sz.) Use chip->tx_pkt_desc_sz directly.

---
v2:
- Don't touch rtw_usb_write_data_rsvd_page(). It needs to set pkt_info.offset after all, otherwise RTL8822BU and RTL8821CU fail to upload the firmware:

---
 drivers/net/wireless/realtek/rtw88/usb.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/net/wireless/realtek/rtw88/usb.c +5 -7
index 1dfe7c6ae4ba..a28f35a03b26 100644
@@ -440,23 +440,21 @@ static int rtw_usb_write_data(struct rtw_dev *rtwdev,
 {
 	const struct rtw_chip_info *chip = rtwdev->chip;
 	struct sk_buff *skb;
-	unsigned int desclen, headsize, size;
+	unsigned int size;
 	u8 qsel;
 	int ret = 0;
 
 	size = pkt_info->tx_pkt_size;
 	qsel = pkt_info->qsel;
-	desclen = chip->tx_pkt_desc_sz;
-	headsize = pkt_info->offset ? pkt_info->offset : desclen;
 
-	skb = dev_alloc_skb(headsize + size);
+	skb = dev_alloc_skb(chip->tx_pkt_desc_sz + size);
 	if (unlikely(!skb))
 		return -ENOMEM;
 
-	skb_reserve(skb, headsize);
+	skb_reserve(skb, chip->tx_pkt_desc_sz);
 	skb_put_data(skb, buf, size);
-	skb_push(skb, headsize);
-	memset(skb->data, 0, headsize);
+	skb_push(skb, chip->tx_pkt_desc_sz);
+	memset(skb->data, 0, chip->tx_pkt_desc_sz);
 	rtw_tx_fill_tx_desc(pkt_info, skb);
 	rtw_tx_fill_txdesc_checksum(rtwdev, pkt_info, skb->data);
 
Signature · 1 line
2.44.0
Tested-by on v2 1/1
#1 lore raw
Quoted 39 lines · Bitterblue Smith

The skb created in this function always has the same headroom, the chip's TX descriptor size. (pkt_info->offset is set by rtw_usb_write_data_rsvd_page() to chip->tx_pkt_desc_sz.) Use chip->tx_pkt_desc_sz directly.

---
v2:
- Don't touch rtw_usb_write_data_rsvd_page(). It needs to set pkt_info.offset after all, otherwise RTL8822BU and RTL8821CU fail to upload the firmware:

---
  drivers/net/wireless/realtek/rtw88/usb.c | 12 +++++-------
  1 file changed, 5 insertions(+), 7 deletions(-)
drivers/net/wireless/realtek/rtw88/usb.c +2 -4
index 1dfe7c6ae4ba..a28f35a03b26 100644
@@ -440,23 +440,21 @@ static int rtw_usb_write_data(struct rtw_dev *rtwdev,
  {
  	const struct rtw_chip_info *chip = rtwdev->chip;
  	struct sk_buff *skb;
-	unsigned int desclen, headsize, size;
+	unsigned int size;
  	u8 qsel;
  	int ret = 0;
 
  	size = pkt_info->tx_pkt_size;
  	qsel = pkt_info->qsel;
-	desclen = chip->tx_pkt_desc_sz;
-	headsize = pkt_info->offset ? pkt_info->offset : desclen;
 
-	skb = dev_alloc_skb(headsize + size);
+	skb = dev_alloc_skb(chip->tx_pkt_desc_sz + size);
  	if (unlikely(!skb))
  		return -ENOMEM;
 

drivers/net/wireless/realtek/rtw88/usb.c static int rtw_usb_write_data(struct rtw_dev *rtwdev, · line 460

Quoted 10 lines
drivers/net/wireless/realtek/rtw88/usb.c +3 -3
-	skb_reserve(skb, headsize);
+	skb_reserve(skb, chip->tx_pkt_desc_sz);
  	skb_put_data(skb, buf, size);
-	skb_push(skb, headsize);
-	memset(skb->data, 0, headsize);
+	skb_push(skb, chip->tx_pkt_desc_sz);
+	memset(skb->data, 0, chip->tx_pkt_desc_sz);
  	rtw_tx_fill_tx_desc(pkt_info, skb);
  	rtw_tx_fill_txdesc_checksum(rtwdev, pkt_info, skb->data);
 

This one works with the 8822bu.

Thanks,

Larry

maintainer
#2 lore raw
In reply to Bitterblue Smith
Quoted 7 lines · Bitterblue Smith

The skb created in this function always has the same headroom, the chip's TX descriptor size. (pkt_info->offset is set by rtw_usb_write_data_rsvd_page() to chip->tx_pkt_desc_sz.) Use chip->tx_pkt_desc_sz directly.

1 patch(es) applied to rtw-next branch of rtw.git, thanks.

a892f6ffbec7 wifi: rtw88: usb: Simplify rtw_usb_write_data

---
https://github.com/pkshih/rtw.git