1 From fbbd8cb347e25b68d25c4f3871821afc495ee7a9 Mon Sep 17 00:00:00 2001
2 From: Bitterblue Smith <rtl8821cerfe2@gmail.com>
3 Date: Thu, 8 Aug 2024 01:19:36 +0300
4 Subject: [PATCH] wifi: rtw88: usb: Init RX burst length according to USB speed
6 This is needed in order to make USB RX aggregation work with RTL8811CU
7 (and presumably RTL8822BU and RTL8822CU also).
9 I don't know what BIT_DMA_BURST_CNT, BIT_DMA_MODE, and BIT_DROP_DATA_EN
12 Tested with RTL8822CU, RTL8811CU, and RTL8723DU.
14 The RX speed is unchanged in my tests.
16 Tested-by: Sascha Hauer <s.hauer@pengutronix.de>
17 Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
18 Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
19 Link: https://patch.msgid.link/ac569c6f-7129-4341-b523-901fe10cabff@gmail.com
21 drivers/net/wireless/realtek/rtw88/reg.h | 6 ++++++
22 drivers/net/wireless/realtek/rtw88/usb.c | 23 ++++++++++++++++++++++-
23 2 files changed, 28 insertions(+), 1 deletion(-)
25 --- a/drivers/net/wireless/realtek/rtw88/reg.h
26 +++ b/drivers/net/wireless/realtek/rtw88/reg.h
28 #define REG_RXDMA_DPR 0x028C
29 #define REG_RXDMA_MODE 0x0290
30 #define BIT_DMA_MODE BIT(1)
31 +#define BIT_DMA_BURST_CNT GENMASK(3, 2)
32 +#define BIT_DMA_BURST_SIZE GENMASK(5, 4)
33 +#define BIT_DMA_BURST_SIZE_64 2
34 +#define BIT_DMA_BURST_SIZE_512 1
35 +#define BIT_DMA_BURST_SIZE_1024 0
37 #define REG_RXPKTNUM 0x02B0
39 #define REG_INT_MIG 0x0304
40 --- a/drivers/net/wireless/realtek/rtw88/usb.c
41 +++ b/drivers/net/wireless/realtek/rtw88/usb.c
42 @@ -720,9 +720,30 @@ static void rtw_usb_link_ps(struct rtw_d
43 /* empty function for rtw_hci_ops */
46 +static void rtw_usb_init_burst_pkt_len(struct rtw_dev *rtwdev)
48 + struct rtw_usb *rtwusb = rtw_get_usb_priv(rtwdev);
49 + enum usb_device_speed speed = rtwusb->udev->speed;
50 + u8 rxdma, burst_size;
52 + rxdma = BIT_DMA_BURST_CNT | BIT_DMA_MODE;
54 + if (speed == USB_SPEED_SUPER)
55 + burst_size = BIT_DMA_BURST_SIZE_1024;
56 + else if (speed == USB_SPEED_HIGH)
57 + burst_size = BIT_DMA_BURST_SIZE_512;
59 + burst_size = BIT_DMA_BURST_SIZE_64;
61 + u8p_replace_bits(&rxdma, burst_size, BIT_DMA_BURST_SIZE);
63 + rtw_write8(rtwdev, REG_RXDMA_MODE, rxdma);
64 + rtw_write16_set(rtwdev, REG_TXDMA_OFFSET_CHK, BIT_DROP_DATA_EN);
67 static void rtw_usb_interface_cfg(struct rtw_dev *rtwdev)
69 - /* empty function for rtw_hci_ops */
70 + rtw_usb_init_burst_pkt_len(rtwdev);
73 static struct rtw_hci_ops rtw_usb_ops = {