diff mbox series

[v4,1/4] wifi: rtw88: usb: Init RX burst length according to USB speed

Message ID ac569c6f-7129-4341-b523-901fe10cabff@gmail.com
State Superseded
Headers show
Series [v4,1/4] wifi: rtw88: usb: Init RX burst length according to USB speed | expand

Commit Message

Bitterblue Smith Aug. 7, 2024, 10:19 p.m. UTC
This is needed in order to make USB RX aggregation work with RTL8811CU
(and presumably RTL8822BU and RTL8822CU also).

I don't know what BIT_DMA_BURST_CNT, BIT_DMA_MODE, and BIT_DROP_DATA_EN
are doing.

Tested with RTL8822CU, RTL8811CU, and RTL8723DU.

The RX speed is unchanged in my tests.

Tested-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
---
v4:
 - Mention testing with RTL8822CU.

v3:
 - Add Tested-by: Sascha Hauer <s.hauer@pengutronix.de>

v2:
 - Move the code to rtw_usb_interface_cfg.
 - Let RTL8723DU and all other USB devices use it, not just RTL8822CU,
   RTL8822BU, and RTL8821CU.
 - Use the speed member of struct usb_device to determine the USB speed
   instead of reading hardware registers.
 - Update the subject line.
 - Add more information to the commit message.
 - Rebase on top of the latest rtw-next.
---
 drivers/net/wireless/realtek/rtw88/reg.h |  6 ++++++
 drivers/net/wireless/realtek/rtw88/usb.c | 23 ++++++++++++++++++++++-
 2 files changed, 28 insertions(+), 1 deletion(-)

Comments

Ping-Ke Shih Aug. 9, 2024, 1:19 a.m. UTC | #1
Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:

> This is needed in order to make USB RX aggregation work with RTL8811CU
> (and presumably RTL8822BU and RTL8822CU also).
> 
> I don't know what BIT_DMA_BURST_CNT, BIT_DMA_MODE, and BIT_DROP_DATA_EN
> are doing.
> 
> Tested with RTL8822CU, RTL8811CU, and RTL8723DU.
> 
> The RX speed is unchanged in my tests.
> 
> Tested-by: Sascha Hauer <s.hauer@pengutronix.de>
> Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>

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

fbbd8cb347e2 wifi: rtw88: usb: Init RX burst length according to USB speed
38ea04a79ad0 wifi: rtw88: usb: Update the RX stats after every frame
df3d8f463b1d wifi: rtw88: usb: Support RX aggregation
002a5db9a52a wifi: rtw88: Enable USB RX aggregation for 8822c/8822b/8821c

---
https://github.com/pkshih/rtw.git
diff mbox series

Patch

diff --git a/drivers/net/wireless/realtek/rtw88/reg.h b/drivers/net/wireless/realtek/rtw88/reg.h
index e7b24465f549..4d9b8668e8b0 100644
--- a/drivers/net/wireless/realtek/rtw88/reg.h
+++ b/drivers/net/wireless/realtek/rtw88/reg.h
@@ -322,6 +322,12 @@ 
 #define REG_RXDMA_DPR		0x028C
 #define REG_RXDMA_MODE		0x0290
 #define BIT_DMA_MODE		BIT(1)
+#define BIT_DMA_BURST_CNT	GENMASK(3, 2)
+#define BIT_DMA_BURST_SIZE	GENMASK(5, 4)
+#define BIT_DMA_BURST_SIZE_64	2
+#define BIT_DMA_BURST_SIZE_512	1
+#define BIT_DMA_BURST_SIZE_1024	0
+
 #define REG_RXPKTNUM		0x02B0
 
 #define REG_INT_MIG		0x0304
diff --git a/drivers/net/wireless/realtek/rtw88/usb.c b/drivers/net/wireless/realtek/rtw88/usb.c
index 9145c11a063e..1c40d46a7eb4 100644
--- a/drivers/net/wireless/realtek/rtw88/usb.c
+++ b/drivers/net/wireless/realtek/rtw88/usb.c
@@ -720,9 +720,30 @@  static void rtw_usb_link_ps(struct rtw_dev *rtwdev, bool enter)
 	/* empty function for rtw_hci_ops */
 }
 
+static void rtw_usb_init_burst_pkt_len(struct rtw_dev *rtwdev)
+{
+	struct rtw_usb *rtwusb = rtw_get_usb_priv(rtwdev);
+	enum usb_device_speed speed = rtwusb->udev->speed;
+	u8 rxdma, burst_size;
+
+	rxdma = BIT_DMA_BURST_CNT | BIT_DMA_MODE;
+
+	if (speed == USB_SPEED_SUPER)
+		burst_size = BIT_DMA_BURST_SIZE_1024;
+	else if (speed == USB_SPEED_HIGH)
+		burst_size = BIT_DMA_BURST_SIZE_512;
+	else
+		burst_size = BIT_DMA_BURST_SIZE_64;
+
+	u8p_replace_bits(&rxdma, burst_size, BIT_DMA_BURST_SIZE);
+
+	rtw_write8(rtwdev, REG_RXDMA_MODE, rxdma);
+	rtw_write16_set(rtwdev, REG_TXDMA_OFFSET_CHK, BIT_DROP_DATA_EN);
+}
+
 static void rtw_usb_interface_cfg(struct rtw_dev *rtwdev)
 {
-	/* empty function for rtw_hci_ops */
+	rtw_usb_init_burst_pkt_len(rtwdev);
 }
 
 static struct rtw_hci_ops rtw_usb_ops = {