From patchwork Sun Jul 28 19:39:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bitterblue Smith X-Patchwork-Id: 815645 Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 95DBDB669 for ; Sun, 28 Jul 2024 19:39:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722195593; cv=none; b=olZ0GL5JAHsfL8s3H6MjTVal9Vp/PxoZdVGgYBlXBBaqcIVqUNiroPGzvXazn0KxYAOw3xgsxVOScWEkD1OVYwmOd8UUi4cWGv2r+jMfAg06kJwdCzx6Hb1MW/q7MjU/n7j0oSznu/W+vTGsOEO9Yguqpfn1fmY3r0PlRJfH32c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722195593; c=relaxed/simple; bh=+JAFv01CnjZn5AkUsRdWkvzkrIYqK8bqd8QDBE0c4JM=; h=Message-ID:Date:MIME-Version:To:Cc:From:Subject:Content-Type; b=uo+G6pj2z4+DlJZUKp3HWaXwXJd3oJx4UQ/yJvA6XftwmbOVw4g3SKU47jB/LJ4NsDM1WR8btdkcmuGpYnQlbdwf65lQ7zDF5Y2eK2AW3BdVtWCbAKGK/h7wHnGsjRxNR4nwuozzReCmy7U1YEtxJCASmSLRmiqYR7SXREEVIrU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ghG35QM0; arc=none smtp.client-ip=209.85.208.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ghG35QM0" Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-5ab2baf13d9so4480769a12.2 for ; Sun, 28 Jul 2024 12:39:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722195590; x=1722800390; darn=vger.kernel.org; h=content-transfer-encoding:subject:from:cc:to:content-language :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=19gGTBP79wxMQ5kqQy6/0Rfl7hAFwTK3bj09bHEpIOY=; b=ghG35QM0LbzgscMJf/X1VMtgAn5MD5VzYjzgexcrhOPh0/OmKLDHeGAEj/6D8bsI6r 1K0BIggVbgBK5tE4m+yrKP+SUwIISqXdbCHBFhOHdis7OyhnIOc7qXj19JHbCaogDF29 bfdj6KIxWYwBMp8vyU4U0ZdtzKcSrpD6dhG1rb9bCEQdtAvoHJ5/311kctnlUX+RJlw1 zgw0adVcI+SE9Kf3ZCrirh6KTavDU047qgU7mpkcXCRHuh9mkPf1YPilVpXQ858RnmIC InbG0dxdP0YqgvRVYEblp3nCsmDFG0y4oTy4r6TsorEfEekh6onL6DoC/6xanuYBoExC Ti8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722195590; x=1722800390; h=content-transfer-encoding:subject:from:cc:to:content-language :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=19gGTBP79wxMQ5kqQy6/0Rfl7hAFwTK3bj09bHEpIOY=; b=Avo54yp0SzA++Jgrhz0p+S7okaIhZuchUnNtU6vBcrWQAcQfMujcsKhCD61h3hQeNA wZoWjJaI2N87zH89kYaxn/1SjsxskVcc5wNsihEF09bA9JM4QVWzjwb0BrKVwLzCZBx2 va1ea4e6alfMglcte+U2LQ2+USXIARNBxVc3zAd8lWWkumH8gwqCiIlaj4fhwRO104gh k2NPkQtgINTdWB88ITEasLdDaiObHo0KODw4tXsFrJCsAVnw57mQJ+24TM4Ti+fCWVdK L4JfUMixXbv+EfyMWAACW12B+dZ+XpocttUXIAeC2VC1/r1r3PeBdb5q9lb+mxvy7EDZ tZwg== X-Gm-Message-State: AOJu0YxgRjdMd1UDYxAHtEbqXr9RNzd6dkHpTy8U6UOsU6OimXzgNilh kq9y0gK9XiPomlVDv4DD8XGxMFuZw7lDPHsGNNAsevh4KGjNlcQsTsbyFA== X-Google-Smtp-Source: AGHT+IFRAgRhynVLBBcZcxGL1m2IdSmXHM9hflZ1tPtX/n4pAXlIRovL6Dw7Fg7hp3HyqtXs2ihjVg== X-Received: by 2002:a50:d7d4:0:b0:5a1:a7cb:8f86 with SMTP id 4fb4d7f45d1cf-5b01d56798dmr3916960a12.0.1722195589383; Sun, 28 Jul 2024 12:39:49 -0700 (PDT) Received: from [192.168.0.50] ([79.119.240.114]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5ac64eb3ab8sm4713752a12.71.2024.07.28.12.39.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 28 Jul 2024 12:39:49 -0700 (PDT) Message-ID: Date: Sun, 28 Jul 2024 22:39:47 +0300 Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: "linux-wireless@vger.kernel.org" Cc: Ping-Ke Shih , Sascha Hauer From: Bitterblue Smith Subject: [PATCH 1/4] wifi: rtw88: Init RX burst length for 8822cu/8822bu/8821cu Init RX burst length according to the USB speed. This is needed in order to make USB RX aggregation work. Tested with RTL8811CU. Signed-off-by: Bitterblue Smith --- I would mention in the commit message what BIT_DMA_BURST_CNT, BIT_DMA_MODE, and BIT_DROP_DATA_EN are doing, but I don't know. --- drivers/net/wireless/realtek/rtw88/reg.h | 8 +++++++ drivers/net/wireless/realtek/rtw88/rtw8821c.c | 22 +++++++++++++++++++ drivers/net/wireless/realtek/rtw88/rtw8822b.c | 22 +++++++++++++++++++ drivers/net/wireless/realtek/rtw88/rtw8822c.c | 22 +++++++++++++++++++ 4 files changed, 74 insertions(+) diff --git a/drivers/net/wireless/realtek/rtw88/reg.h b/drivers/net/wireless/realtek/rtw88/reg.h index e7b24465f549..788e450d30d2 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 @@ -703,6 +709,8 @@ #define REG_IGN_GNTBT4 0x4160 +#define REG_USB_USBSTAT 0xFE11 + #define RF_MODE 0x00 #define RF_MODOPT 0x01 #define RF_WLINT 0x01 diff --git a/drivers/net/wireless/realtek/rtw88/rtw8821c.c b/drivers/net/wireless/realtek/rtw88/rtw8821c.c index 526e8de77b3e..55b6fe874710 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8821c.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8821c.c @@ -204,6 +204,25 @@ static void rtw8821c_phy_set_param(struct rtw_dev *rtwdev) rtw8821c_phy_bf_init(rtwdev); } +static void rtw8821cu_init_burst_pkt_len(struct rtw_dev *rtwdev) +{ + u8 rxdma, burst_size; + + rxdma = BIT_DMA_BURST_CNT | BIT_DMA_MODE; + + if (rtw_read8(rtwdev, REG_SYS_CFG2 + 3) == 0x20) + burst_size = BIT_DMA_BURST_SIZE_1024; + else if ((rtw_read8(rtwdev, REG_USB_USBSTAT) & 0x3) == 0x1) + 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 int rtw8821c_mac_init(struct rtw_dev *rtwdev) { u32 value32; @@ -261,6 +280,9 @@ static int rtw8821c_mac_init(struct rtw_dev *rtwdev) rtw_write32(rtwdev, REG_WMAC_OPTION_FUNCTION + 8, WLAN_MAC_OPT_FUNC2); rtw_write8(rtwdev, REG_WMAC_OPTION_FUNCTION + 4, WLAN_MAC_OPT_NORM_FUNC1); + if (rtw_hci_type(rtwdev) == RTW_HCI_TYPE_USB) + rtw8821cu_init_burst_pkt_len(rtwdev); + return 0; } diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822b.c b/drivers/net/wireless/realtek/rtw88/rtw8822b.c index 6edb17aea90e..0949eaa2b6c1 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8822b.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8822b.c @@ -237,6 +237,25 @@ static void rtw8822b_phy_set_param(struct rtw_dev *rtwdev) #define WLAN_NAV_CFG (WLAN_RDG_NAV | (WLAN_TXOP_NAV << 16)) #define WLAN_RX_TSF_CFG (WLAN_CCK_RX_TSF | (WLAN_OFDM_RX_TSF) << 8) +static void rtw8822bu_init_burst_pkt_len(struct rtw_dev *rtwdev) +{ + u8 rxdma, burst_size; + + rxdma = BIT_DMA_BURST_CNT | BIT_DMA_MODE; + + if (rtw_read8(rtwdev, REG_SYS_CFG2 + 3) == 0x20) + burst_size = BIT_DMA_BURST_SIZE_1024; + else if ((rtw_read8(rtwdev, REG_USB_USBSTAT) & 0x3) == 0x1) + 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 int rtw8822b_mac_init(struct rtw_dev *rtwdev) { u32 value32; @@ -284,6 +303,9 @@ static int rtw8822b_mac_init(struct rtw_dev *rtwdev) rtw_write8_set(rtwdev, REG_SND_PTCL_CTRL, BIT_DIS_CHK_VHTSIGB_CRC); + if (rtw_hci_type(rtwdev) == RTW_HCI_TYPE_USB) + rtw8822bu_init_burst_pkt_len(rtwdev); + return 0; } diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822c.c b/drivers/net/wireless/realtek/rtw88/rtw8822c.c index e265a35184ab..2a90a879196b 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8822c.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8822c.c @@ -2001,6 +2001,25 @@ static void rtw8822c_phy_set_param(struct rtw_dev *rtwdev) #define MAC_CLK_SPEED 80 /* 80M */ #define EFUSE_PCB_INFO_OFFSET 0xCA +static void rtw8822cu_init_burst_pkt_len(struct rtw_dev *rtwdev) +{ + u8 rxdma, burst_size; + + rxdma = BIT_DMA_BURST_CNT | BIT_DMA_MODE; + + if (rtw_read8(rtwdev, REG_SYS_CFG2 + 3) == 0x20) + burst_size = BIT_DMA_BURST_SIZE_1024; + else if ((rtw_read8(rtwdev, REG_USB_USBSTAT) & 0x3) == 0x1) + 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 int rtw8822c_mac_init(struct rtw_dev *rtwdev) { u8 value8; @@ -2127,6 +2146,9 @@ static int rtw8822c_mac_init(struct rtw_dev *rtwdev) /* Interrupt migration configuration */ rtw_write32(rtwdev, REG_INT_MIG, WLAN_MAC_INT_MIG_CFG); + if (rtw_hci_type(rtwdev) == RTW_HCI_TYPE_USB) + rtw8822cu_init_burst_pkt_len(rtwdev); + return 0; } From patchwork Sun Jul 28 19:41:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bitterblue Smith X-Patchwork-Id: 815006 Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A68848C06 for ; Sun, 28 Jul 2024 19:41:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722195680; cv=none; b=r4VfBaCbsKhE39r+bX9arl0cF9YSJpoWvitoyoW8PIhdE/kPtwBTIh0Fp1CiuKzJfcbae3RzAU/EfTjttCnRERjm1zSReDRxydYF51/iyCzLfy34h55JXna5p2gbwJD4TwzKfm7494+SGvBLp3mxdAAqyPf+p2QbY7wulXRH8RA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722195680; c=relaxed/simple; bh=bT02QokMQ88ULwFLpOxrfE76ODww4/Lu3O4eJwDi32Y=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=aRysMyptFHMNi2GiViQacstOCRMSz6mobDWK5DF0J7gOsOH0zZNMYWgIvIWVOyKrsYRR6syqhOM8fhIxc/hAGnCzjyH8kFlJxpFkahyp5/J+/u356pie0Mz33ntJLlI3qJUM8yi0bunNehz1XtjUkO8P4QkrMyFGDoWWDaLt2Ak= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gHUUV8Vi; arc=none smtp.client-ip=209.85.208.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gHUUV8Vi" Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-5a10835487fso4689871a12.1 for ; Sun, 28 Jul 2024 12:41:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722195677; x=1722800477; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:date:message-id:from:to :cc:subject:date:message-id:reply-to; bh=Sjrkjs/+cwpe0x7RH4BvRMc4pac2tBvtqybWn+Umeec=; b=gHUUV8Vi7QWTXrjwaeGIAl19qxbwSZC9C8GlMT7miUo+8YyKyPGBgHAXPRJHbahtcY XbXIs0WiLvkRQ8mztRulHDmFyXj+y4/9rNbyG/d/erDm47acwbbcTRo+xUambreWcpMY 2QCzQcT2y5y2ZNF5BtbSn9Bu1swlrS9/7J3MQzUCiuQe4ydd78T9XQFB+7zJwzEcXm0e MA97RijWHkcSkpJ1EkLtQ0ksH26VDdHW0/PDcDopZJDRo7SPtPLpONOy9jZpTfMgVDwn PC/rrGQ3A478u0/ypfwxVGrvzHg60ZcWl+bP2aATt4CXjhCF2gG2yCm0C2p27jfQey7E ddAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722195677; x=1722800477; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Sjrkjs/+cwpe0x7RH4BvRMc4pac2tBvtqybWn+Umeec=; b=vgzpHWqRyZYNxMyZq7Bp06IMzsvuUw/kc1SK+V0dMsi9WsJYF2q6fBOeq7awyzgUMa UVbV9Zy1P025p3Ce2YJNLK7H6bG5XQJm2Et4ojA5DyN3L8T+kP1WmAqB8NKGIQ+er1fY 4aZjMTvnWssjOFvY6iEAxyTBJcSRZKpJ2wWdI6lwC5zdQ+W3lpAunckEMFc84v1gtq7W 7512ApqMEoAPRaSN4KxkyGHIx5vUcPAvf+2waN2C6lhqXOwfe2RVsW2GaUJjvswRqZal d82jBqDJE6yQPl9J3ayb1qnTZcOk7tVg1kwpH/Wl2MNw1r/XgXq/ae/1XuXtkvetrdhg Rx8g== X-Gm-Message-State: AOJu0YyNo7IMelRlFax69kTT70VDcdej9eIVS1CFHYTUrxU/XWfSGq3g bSr/K5yWJ+GYnvXUC656YtYuoteeNNK1T2xK1MF4HAYSIauqYCspR0oMfw== X-Google-Smtp-Source: AGHT+IEo253fYZ/60SeJNNAuSlBUjXJuzDLDDk8hATChUPHlvPkeLPouAo8vY6C76mmNEv+98TBx9g== X-Received: by 2002:a50:cd9d:0:b0:5a2:fc48:db12 with SMTP id 4fb4d7f45d1cf-5b020cb9a13mr3303572a12.19.1722195676668; Sun, 28 Jul 2024 12:41:16 -0700 (PDT) Received: from [192.168.0.50] ([79.119.240.114]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5ac63b59aa5sm4744906a12.43.2024.07.28.12.41.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 28 Jul 2024 12:41:16 -0700 (PDT) Message-ID: <47a89cd7-7767-4b41-abf4-7197e977b7c4@gmail.com> Date: Sun, 28 Jul 2024 22:41:14 +0300 Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 2/4] wifi: rtw88: usb: Update the RX stats after every frame From: Bitterblue Smith To: "linux-wireless@vger.kernel.org" Cc: Ping-Ke Shih , Sascha Hauer References: Content-Language: en-US In-Reply-To: Update the number of received unicast data frames and bytes every time a frame is received. This is what the PCI and SDIO drivers do. This has an influence on the power saving, bluetooth coexistence, and (in a future patch) the use of RX aggregation. Tested with RTL8811CU and RTL8723DU. Signed-off-by: Bitterblue Smith Acked-by: Ping-Ke Shih --- drivers/net/wireless/realtek/rtw88/usb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/realtek/rtw88/usb.c b/drivers/net/wireless/realtek/rtw88/usb.c index 251a5726f3ee..73948078068f 100644 --- a/drivers/net/wireless/realtek/rtw88/usb.c +++ b/drivers/net/wireless/realtek/rtw88/usb.c @@ -579,6 +579,7 @@ static void rtw_usb_rx_handler(struct work_struct *work) skb_put(skb, pkt_stat.pkt_len); skb_reserve(skb, pkt_offset); + rtw_rx_stats(rtwdev, pkt_stat.vif, skb); memcpy(skb->cb, &rx_status, sizeof(rx_status)); ieee80211_rx_irqsafe(rtwdev->hw, skb); } From patchwork Sun Jul 28 19:42:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bitterblue Smith X-Patchwork-Id: 815644 Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89BA38C06 for ; Sun, 28 Jul 2024 19:42:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722195758; cv=none; b=U78x+CS39Y2++nVrbx+9N1eUycps5GgBg89MtSZBT4+unya4vRY7U6UejbxQWUwllHfU2fWWfSWTR/6UHV/J/IZe3kxsMc7hYO75ZXL+OGryiDgKD5zl7dNS6R/Lp+p0xnGhaxoj5Sw3AKmOgK2nSmEOGEpaO1TtJ88wWxzSEhw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722195758; c=relaxed/simple; bh=6zOTC0cmn+UnzQ/wHkDqJnGeuxUEn5PyfeUKWouydX4=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=G6yB4plHsbgGeY1QxobCWL6XylOWgP7aUSmyQOgT9BRF943vXC2F1BP80iVkFG+QpFqmNvwrXPqoe9ua7LHPBGHsTJPc4eXS+sLNfBHB8A/GIQ2uuUVcNm224Zfm0wMXguOVfLap/2neZZEVzG4uaXJcCMX3VW+Xbx4QXSEvnXU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=k7mH8g84; arc=none smtp.client-ip=209.85.208.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="k7mH8g84" Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-5a156557026so4313065a12.2 for ; Sun, 28 Jul 2024 12:42:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722195755; x=1722800555; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:date:message-id:from:to :cc:subject:date:message-id:reply-to; bh=L2rGEQ1q8wDYD248t6Z/UJo8GkMRvxVZQZMJvH6xmo0=; b=k7mH8g84+IAUoDJ+WiySI/9fYR12qDjVlgySy5YAbQJHj1ViMp4CWl4n5mk/UdsJIP BU2yEmdbr1V74tfWWaFLchkBTfzxCIAYUk7S1AGpzjyaYStnFFwYzPeswOAbnMIy09Et TZi6/SRlUSruH4L++IMi4VP3t1v/vpmYcujiTDJulanXjdCx5XYTFr8bQEimIoQJB2He hpR6Iii8UMIVYDYnFVDYPtG91yJknUreSVCoQduvKoJWmbqXpHdr1ap8CT7gFgLImwPo DUfvZAGzXdzF2yUjRldaB0487xjK3gJeJVmrE3udycIwuhImgvvzsXBKGfIXua4SudfV H7Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722195755; x=1722800555; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=L2rGEQ1q8wDYD248t6Z/UJo8GkMRvxVZQZMJvH6xmo0=; b=OtMGRDc1wEd8VYat+MGXiznm3Key7eEIYvrJd6bs4vPLV3yHTM0K4JzMkoBxArKKiW QKilr0E5pLG+nmtLvB/SDpbsaxWkP750TyK0hJWLDQquhGJQ+pQ4kT40AznBNoTm6BlT sAfD/KE3jPx5Yjv150EE5WMf/4F8claPWFFOkjl/ZpSRFy/BPkEq84VMxPgJiMpdXgH/ 4ZNF+ID/E3l+Jd+9zCaDT2o7lgF9sW0OUW258Cn8NzEn2lhUTVmQpQk+JEOH1EwWE9a5 G+ZphvKlzYs2qKHiLGCIBbc+2BrH3Qu32TbrCIi+IT5EvfBUq4F0HsSXMbbmZEeSHfL6 WcYg== X-Gm-Message-State: AOJu0YwNmGwgihjbdk4GmHFQ64apV/aGJdBYFcfwzYSG0iT1XdvwP7sx NyIeA8wUvPyUXccgBwsuXL/ABGb/7xkIL93gdR7FFuM/0kN5iFjIuyoFwg== X-Google-Smtp-Source: AGHT+IFdbDVr4MEFulQST5R269frxBCg7Om7qmWSGVadKAdVOeGVY9WjnjS9dP9xDDS9JJsVVbPaAg== X-Received: by 2002:a17:907:86a7:b0:a72:af8e:15af with SMTP id a640c23a62f3a-a7d400d71e4mr449136366b.49.1722195754430; Sun, 28 Jul 2024 12:42:34 -0700 (PDT) Received: from [192.168.0.50] ([79.119.240.114]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7acad9068esm414781766b.153.2024.07.28.12.42.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 28 Jul 2024 12:42:34 -0700 (PDT) Message-ID: Date: Sun, 28 Jul 2024 22:42:32 +0300 Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 3/4] wifi: rtw88: usb: Support RX aggregation From: Bitterblue Smith To: "linux-wireless@vger.kernel.org" Cc: Ping-Ke Shih , Sascha Hauer References: Content-Language: en-US In-Reply-To: The chips can be configured to aggregate several frames into a single USB transfer. Modify rtw_usb_rx_handler() to support this case. RX aggregation improves the RX speed on certain ARM systems, like the NanoPi NEO Core2. Currently none of the chips are configured to aggregate frames. Tested with RTL8811CU and RTL8723DU. Signed-off-by: Bitterblue Smith --- drivers/net/wireless/realtek/rtw88/usb.c | 57 +++++++++++++++--------- 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/usb.c b/drivers/net/wireless/realtek/rtw88/usb.c index 73948078068f..d61be1029a7b 100644 --- a/drivers/net/wireless/realtek/rtw88/usb.c +++ b/drivers/net/wireless/realtek/rtw88/usb.c @@ -546,11 +546,12 @@ static void rtw_usb_rx_handler(struct work_struct *work) struct rtw_usb *rtwusb = container_of(work, struct rtw_usb, rx_work); struct rtw_dev *rtwdev = rtwusb->rtwdev; const struct rtw_chip_info *chip = rtwdev->chip; - struct rtw_rx_pkt_stat pkt_stat; + u32 pkt_desc_sz = chip->rx_pkt_desc_sz; struct ieee80211_rx_status rx_status; + u32 pkt_offset, next_pkt, urb_len; + struct rtw_rx_pkt_stat pkt_stat; + struct sk_buff *next_skb = NULL; struct sk_buff *skb; - u32 pkt_desc_sz = chip->rx_pkt_desc_sz; - u32 pkt_offset; u8 *rx_desc; int limit; @@ -559,29 +560,44 @@ static void rtw_usb_rx_handler(struct work_struct *work) if (!skb) break; - rx_desc = skb->data; - chip->ops->query_rx_desc(rtwdev, rx_desc, &pkt_stat, - &rx_status); - pkt_offset = pkt_desc_sz + pkt_stat.drv_info_sz + - pkt_stat.shift; - - if (pkt_stat.is_c2h) { - skb_put(skb, pkt_stat.pkt_len + pkt_offset); - rtw_fw_c2h_cmd_rx_irqsafe(rtwdev, pkt_offset, skb); - continue; - } - if (skb_queue_len(&rtwusb->rx_queue) >= RTW_USB_MAX_RXQ_LEN) { dev_dbg_ratelimited(rtwdev->dev, "failed to get rx_queue, overflow\n"); dev_kfree_skb_any(skb); continue; } - skb_put(skb, pkt_stat.pkt_len); - skb_reserve(skb, pkt_offset); - rtw_rx_stats(rtwdev, pkt_stat.vif, skb); - memcpy(skb->cb, &rx_status, sizeof(rx_status)); - ieee80211_rx_irqsafe(rtwdev->hw, skb); + urb_len = skb->len; + + do { + rx_desc = skb->data; + chip->ops->query_rx_desc(rtwdev, rx_desc, &pkt_stat, + &rx_status); + pkt_offset = pkt_desc_sz + pkt_stat.drv_info_sz + + pkt_stat.shift; + + next_pkt = round_up(pkt_stat.pkt_len + pkt_offset, 8); + + if (urb_len >= next_pkt + pkt_desc_sz) + next_skb = skb_clone(skb, GFP_KERNEL); + + if (pkt_stat.is_c2h) { + skb_trim(skb, pkt_stat.pkt_len + pkt_offset); + rtw_fw_c2h_cmd_rx_irqsafe(rtwdev, pkt_offset, skb); + } else { + skb_pull(skb, pkt_offset); + skb_trim(skb, pkt_stat.pkt_len); + rtw_rx_stats(rtwdev, pkt_stat.vif, skb); + memcpy(skb->cb, &rx_status, sizeof(rx_status)); + ieee80211_rx_irqsafe(rtwdev->hw, skb); + } + + skb = next_skb; + if (skb) + skb_pull(next_skb, next_pkt); + + urb_len -= next_pkt; + next_skb = NULL; + } while (skb && urb_len >= pkt_desc_sz); } } @@ -625,6 +641,7 @@ static void rtw_usb_read_port_complete(struct urb *urb) if (skb) dev_kfree_skb_any(skb); } else { + skb_put(skb, urb->actual_length); skb_queue_tail(&rtwusb->rx_queue, skb); queue_work(rtwusb->rxwq, &rtwusb->rx_work); } From patchwork Sun Jul 28 19:44:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bitterblue Smith X-Patchwork-Id: 815005 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4782F8C06 for ; Sun, 28 Jul 2024 19:44:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722195883; cv=none; b=f+KfxidUc7ha/PgmgdUXa9rhaF42VlxHys3dhwkhqcZEJry3JKOxafaSWZMbLRzT2fLAiofcgTMQKiodSjaOip4XcIKhBn8RjajbB1VCU0/yZ6L2X79y4YpX3P+CzePLi/+WkD3uM9U0KyLAZdpnELD3w72nwbhxZgpc/Fd4Rr8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722195883; c=relaxed/simple; bh=5NwSAFfOvYVZqJz+3m0prpxcrJb+ZXQmcYlQ3CsrucE=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=OuFIchKznkAqug8nIYaDGjfYfFPJ9fdXYMP9c+CLKxfII1viac1q8s3iUd9Ttoghf1OKgc2t0udjjevdVyQSnu3ydGrzNPIG9K29bi9N8QtRobT1e7fNfpG62lvV/hiK4HunrVk74xinOvhicSwOyYhLNvAUtaK1gX8dQ0nI2SY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ak5cV043; arc=none smtp.client-ip=209.85.218.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ak5cV043" Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a7aada2358fso536950366b.0 for ; Sun, 28 Jul 2024 12:44:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722195879; x=1722800679; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:date:message-id:from:to :cc:subject:date:message-id:reply-to; bh=E7xcrHU0Szu9UHcNAjXMt+V1H9/ISPInQp2II3fpdd0=; b=ak5cV043+8FDSVSbvLP+Zj2ZVFCfD277LtsVnypnGqsrIyfGIOyECdKYaTCbvvmeeU izqctn18r5sCOOQmXxFO78H7GDBBDsifoB8jUtbGxZ5lG6ar4I1DtHiMo8yXnGv6X5ze uVGOiwUWSMKq3Rcizk7tvlHC5QuG9hzX94IvPLnRaYzWktTbnQhWt4nZscBFkFcjWSKI 50r8dL/bM8Ti0Ck5HkLEwD9izt1YoLNKI3umnrW/qFiy/DGNlQCDKZp/iBcDErkQlloS IOCGR6E+lu4D029VGHFzCisxac3HVLg/En14szeHe9b8MTKhbXGWSy55y0xa6rXDbJnu RXww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722195879; x=1722800679; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=E7xcrHU0Szu9UHcNAjXMt+V1H9/ISPInQp2II3fpdd0=; b=DzAYSThrj/HGs3Le3RkI/WvLeFakRnwkfuo//07vsbV2OFkcFXsIueeoAAwJ9Vrj4y 02+cPpptzAgfJnCxGxl4Pto5mPoLsvGxpv7PfeuZPpdM+4rPozs/x1kS7P/lr2BXwnA7 TEzRTbT6PHy6j/jBpGe0jBoetRxsy3ogLwiuJCUcIJR4moGjU+zHGM9XLdi0kYSDYyiO dq2SRPCqLpvDhRqWMMoSot+I462AISdfLaUASk43XZiJYROA4edCZqxOB676vOqKrmfJ gYOamTETgpR+51Za3sPz/vWZp+icnRF4tSXxRgX5kAWAm3Rww8s9A9KkXeD3NbEK40JB EjtA== X-Gm-Message-State: AOJu0YzP67tIj0yLnHtT9tTwf7OPXYBXVCt5U1zFu6M00dt2KBMMpplZ PBRb7Dif4QjQyrLUL7MkrG8HI9rg2zk5hyvrzNTLTO1CO0kbeDsQzihEsA== X-Google-Smtp-Source: AGHT+IEBOZq5bZRtAsktyesNPhkabQ299a/Hy0SzCAgyPVWb3A9UOaM/WhmFZKTUQWuCwYpevRq9bQ== X-Received: by 2002:a17:907:72d1:b0:a72:5967:b34 with SMTP id a640c23a62f3a-a7d3fa3f215mr487886266b.22.1722195878974; Sun, 28 Jul 2024 12:44:38 -0700 (PDT) Received: from [192.168.0.50] ([79.119.240.114]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7aca51eea0sm420098766b.0.2024.07.28.12.44.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 28 Jul 2024 12:44:38 -0700 (PDT) Message-ID: <323190ee-5b88-4d37-bad0-b721cdfead1a@gmail.com> Date: Sun, 28 Jul 2024 22:44:35 +0300 Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 4/4] wifi: rtw88: Enable USB RX aggregation for 8822c/8822b/8821c From: Bitterblue Smith To: "linux-wireless@vger.kernel.org" Cc: Ping-Ke Shih , Sascha Hauer References: Content-Language: en-US In-Reply-To: Enable USB RX aggregation when there is at least 1 Mbps RX or TX traffic, otherwise disable it. USB RX aggregation improves the RX speed on certain ARM systems, like the NanoPi NEO Core2. With RTL8811CU, before: 28 Mbps, after: 231 Mbps. The official drivers for these chips use the same logic for SDIO, but for some reason rtw88_sdio always enables RX aggregation, so this patch only toggles aggregation for USB devices. RTL8703B is likely not found in USB devices, and RTL8723DU doesn't like aggregation. Signed-off-by: Bitterblue Smith --- drivers/net/wireless/realtek/rtw88/main.c | 18 +++++++++++---- drivers/net/wireless/realtek/rtw88/main.h | 1 + drivers/net/wireless/realtek/rtw88/rtw8821c.c | 23 +++++++++++++++++++ drivers/net/wireless/realtek/rtw88/rtw8822b.c | 23 +++++++++++++++++++ drivers/net/wireless/realtek/rtw88/rtw8822c.c | 23 +++++++++++++++++++ 5 files changed, 84 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c index 9d9d33a4a503..b3a089b4f707 100644 --- a/drivers/net/wireless/realtek/rtw88/main.c +++ b/drivers/net/wireless/realtek/rtw88/main.c @@ -210,8 +210,10 @@ static void rtw_watch_dog_work(struct work_struct *work) struct rtw_dev *rtwdev = container_of(work, struct rtw_dev, watch_dog_work.work); struct rtw_traffic_stats *stats = &rtwdev->stats; + const struct rtw_chip_info *chip = rtwdev->chip; struct rtw_watch_dog_iter_data data = {}; bool busy_traffic = test_bit(RTW_FLAG_BUSY_TRAFFIC, rtwdev->flags); + u32 tx_unicast_shift, rx_unicast_shift; bool ps_active; mutex_lock(&rtwdev->mutex); @@ -236,13 +238,21 @@ static void rtw_watch_dog_work(struct work_struct *work) else ps_active = false; - ewma_tp_add(&stats->tx_ewma_tp, - (u32)(stats->tx_unicast >> RTW_TP_SHIFT)); - ewma_tp_add(&stats->rx_ewma_tp, - (u32)(stats->rx_unicast >> RTW_TP_SHIFT)); + tx_unicast_shift = stats->tx_unicast >> RTW_TP_SHIFT; + rx_unicast_shift = stats->rx_unicast >> RTW_TP_SHIFT; + + ewma_tp_add(&stats->tx_ewma_tp, tx_unicast_shift); + ewma_tp_add(&stats->rx_ewma_tp, rx_unicast_shift); stats->tx_throughput = ewma_tp_read(&stats->tx_ewma_tp); stats->rx_throughput = ewma_tp_read(&stats->rx_ewma_tp); + if (rtw_hci_type(rtwdev) == RTW_HCI_TYPE_USB && chip->ops->rx_aggregation) { + if (tx_unicast_shift < 1 && rx_unicast_shift < 1) + chip->ops->rx_aggregation(rtwdev, false); + else + chip->ops->rx_aggregation(rtwdev, true); + } + /* reset tx/rx statictics */ stats->tx_unicast = 0; stats->rx_unicast = 0; diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h index 9d21637cf5d5..65bedd1668cc 100644 --- a/drivers/net/wireless/realtek/rtw88/main.h +++ b/drivers/net/wireless/realtek/rtw88/main.h @@ -888,6 +888,7 @@ struct rtw_chip_ops { void (*fill_txdesc_checksum)(struct rtw_dev *rtwdev, struct rtw_tx_pkt_info *pkt_info, u8 *txdesc); + void (*rx_aggregation)(struct rtw_dev *rtwdev, bool enable); /* for coex */ void (*coex_set_init)(struct rtw_dev *rtwdev); diff --git a/drivers/net/wireless/realtek/rtw88/rtw8821c.c b/drivers/net/wireless/realtek/rtw88/rtw8821c.c index 55b6fe874710..3efdb41f22c5 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8821c.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8821c.c @@ -1276,6 +1276,28 @@ static void rtw8821c_fill_txdesc_checksum(struct rtw_dev *rtwdev, fill_txdesc_checksum_common(txdesc, 16); } +static void rtw8821c_rx_aggregation(struct rtw_dev *rtwdev, bool enable) +{ + u8 size, timeout; + u16 val16; + + rtw_write32_set(rtwdev, REG_RXDMA_AGG_PG_TH, BIT_EN_PRE_CALC); + rtw_write8_set(rtwdev, REG_TXDMA_PQ_MAP, BIT_RXDMA_AGG_EN); + rtw_write8_clr(rtwdev, REG_RXDMA_AGG_PG_TH + 3, BIT(7)); + + if (enable) { + size = 0x5; + timeout = 0x20; + } else { + size = 0x0; + timeout = 0x1; + } + val16 = u16_encode_bits(size, BIT_RXDMA_AGG_PG_TH) | + u16_encode_bits(timeout, BIT_DMA_AGG_TO_V1); + + rtw_write16(rtwdev, REG_RXDMA_AGG_PG_TH, val16); +} + static struct rtw_pwr_seq_cmd trans_carddis_to_cardemu_8821c[] = { {0x0086, RTW_PWR_CUT_ALL_MSK, @@ -1724,6 +1746,7 @@ static struct rtw_chip_ops rtw8821c_ops = { .set_gid_table = rtw_bf_set_gid_table, .cfg_csi_rate = rtw_bf_cfg_csi_rate, .fill_txdesc_checksum = rtw8821c_fill_txdesc_checksum, + .rx_aggregation = rtw8821c_rx_aggregation, .coex_set_init = rtw8821c_coex_cfg_init, .coex_set_ant_switch = rtw8821c_coex_cfg_ant_switch, diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822b.c b/drivers/net/wireless/realtek/rtw88/rtw8822b.c index 0949eaa2b6c1..52bcdf3cf043 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8822b.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8822b.c @@ -1638,6 +1638,28 @@ static void rtw8822b_fill_txdesc_checksum(struct rtw_dev *rtwdev, fill_txdesc_checksum_common(txdesc, words); } +static void rtw8822b_rx_aggregation(struct rtw_dev *rtwdev, bool enable) +{ + u8 size, timeout; + u16 val16; + + rtw_write32_set(rtwdev, REG_RXDMA_AGG_PG_TH, BIT_EN_PRE_CALC); + rtw_write8_set(rtwdev, REG_TXDMA_PQ_MAP, BIT_RXDMA_AGG_EN); + rtw_write8_clr(rtwdev, REG_RXDMA_AGG_PG_TH + 3, BIT(7)); + + if (enable) { + size = 0x5; + timeout = 0x20; + } else { + size = 0x0; + timeout = 0x1; + } + val16 = u16_encode_bits(size, BIT_RXDMA_AGG_PG_TH) | + u16_encode_bits(timeout, BIT_DMA_AGG_TO_V1); + + rtw_write16(rtwdev, REG_RXDMA_AGG_PG_TH, val16); +} + static const struct rtw_pwr_seq_cmd trans_carddis_to_cardemu_8822b[] = { {0x0086, RTW_PWR_CUT_ALL_MSK, @@ -2214,6 +2236,7 @@ static struct rtw_chip_ops rtw8822b_ops = { .adaptivity_init = rtw8822b_adaptivity_init, .adaptivity = rtw8822b_adaptivity, .fill_txdesc_checksum = rtw8822b_fill_txdesc_checksum, + .rx_aggregation = rtw8822b_rx_aggregation, .coex_set_init = rtw8822b_coex_cfg_init, .coex_set_ant_switch = rtw8822b_coex_cfg_ant_switch, diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822c.c b/drivers/net/wireless/realtek/rtw88/rtw8822c.c index 2a90a879196b..9d3ed8992133 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8822c.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8822c.c @@ -4612,6 +4612,28 @@ static void rtw8822c_fill_txdesc_checksum(struct rtw_dev *rtwdev, fill_txdesc_checksum_common(txdesc, words); } +static void rtw8822c_rx_aggregation(struct rtw_dev *rtwdev, bool enable) +{ + u8 size, timeout; + u16 val16; + + rtw_write32_set(rtwdev, REG_RXDMA_AGG_PG_TH, BIT_EN_PRE_CALC); + rtw_write8_set(rtwdev, REG_TXDMA_PQ_MAP, BIT_RXDMA_AGG_EN); + rtw_write8_clr(rtwdev, REG_RXDMA_AGG_PG_TH + 3, BIT(7)); + + if (enable) { + size = 0x5; + timeout = 0x20; + } else { + size = 0x0; + timeout = 0x1; + } + val16 = u16_encode_bits(size, BIT_RXDMA_AGG_PG_TH) | + u16_encode_bits(timeout, BIT_DMA_AGG_TO_V1); + + rtw_write16(rtwdev, REG_RXDMA_AGG_PG_TH, val16); +} + static const struct rtw_pwr_seq_cmd trans_carddis_to_cardemu_8822c[] = { {0x0086, RTW_PWR_CUT_ALL_MSK, @@ -5036,6 +5058,7 @@ static struct rtw_chip_ops rtw8822c_ops = { .config_tx_path = rtw8822c_config_tx_path, .config_txrx_mode = rtw8822c_config_trx_mode, .fill_txdesc_checksum = rtw8822c_fill_txdesc_checksum, + .rx_aggregation = rtw8822c_rx_aggregation, .coex_set_init = rtw8822c_coex_cfg_init, .coex_set_ant_switch = NULL,