linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/4] wifi: rtw88: usb: Init RX burst length according to USB speed
@ 2024-08-02 21:31 Bitterblue Smith
  2024-08-02 21:33 ` [PATCH v2 2/4] wifi: rtw88: usb: Update the RX stats after every frame Bitterblue Smith
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Bitterblue Smith @ 2024-08-02 21:31 UTC (permalink / raw)
  To: linux-wireless@vger.kernel.org; +Cc: Ping-Ke Shih, Sascha Hauer

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 RTL8811CU and RTL8723DU.

The RX speed is unchanged in my tests.

Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
---
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(-)

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 = {
-- 
2.45.2



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-08-06  8:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-02 21:31 [PATCH v2 1/4] wifi: rtw88: usb: Init RX burst length according to USB speed Bitterblue Smith
2024-08-02 21:33 ` [PATCH v2 2/4] wifi: rtw88: usb: Update the RX stats after every frame Bitterblue Smith
2024-08-02 21:34 ` [PATCH v2 3/4] wifi: rtw88: usb: Support RX aggregation Bitterblue Smith
2024-08-05  7:23   ` Sascha Hauer
2024-08-06  8:37     ` Ping-Ke Shih
2024-08-02 21:35 ` [PATCH v2 4/4] wifi: rtw88: Enable USB RX aggregation for 8822c/8822b/8821c Bitterblue Smith
2024-08-05  7:27 ` [PATCH v2 1/4] wifi: rtw88: usb: Init RX burst length according to USB speed Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).