191c87ff37adc550b0a696b64d9194004c1f065b
[openwrt/openwrt.git] /
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
5
6 This is needed in order to make USB RX aggregation work with RTL8811CU
7 (and presumably RTL8822BU and RTL8822CU also).
8
9 I don't know what BIT_DMA_BURST_CNT, BIT_DMA_MODE, and BIT_DROP_DATA_EN
10 are doing.
11
12 Tested with RTL8822CU, RTL8811CU, and RTL8723DU.
13
14 The RX speed is unchanged in my tests.
15
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
20 ---
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(-)
24
25 --- a/drivers/net/wireless/realtek/rtw88/reg.h
26 +++ b/drivers/net/wireless/realtek/rtw88/reg.h
27 @@ -322,6 +322,12 @@
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
36 +
37 #define REG_RXPKTNUM 0x02B0
38
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 */
44 }
45
46 +static void rtw_usb_init_burst_pkt_len(struct rtw_dev *rtwdev)
47 +{
48 + struct rtw_usb *rtwusb = rtw_get_usb_priv(rtwdev);
49 + enum usb_device_speed speed = rtwusb->udev->speed;
50 + u8 rxdma, burst_size;
51 +
52 + rxdma = BIT_DMA_BURST_CNT | BIT_DMA_MODE;
53 +
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;
58 + else
59 + burst_size = BIT_DMA_BURST_SIZE_64;
60 +
61 + u8p_replace_bits(&rxdma, burst_size, BIT_DMA_BURST_SIZE);
62 +
63 + rtw_write8(rtwdev, REG_RXDMA_MODE, rxdma);
64 + rtw_write16_set(rtwdev, REG_TXDMA_OFFSET_CHK, BIT_DROP_DATA_EN);
65 +}
66 +
67 static void rtw_usb_interface_cfg(struct rtw_dev *rtwdev)
68 {
69 - /* empty function for rtw_hci_ops */
70 + rtw_usb_init_burst_pkt_len(rtwdev);
71 }
72
73 static struct rtw_hci_ops rtw_usb_ops = {