From patchwork Wed Aug 7 22:19:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bitterblue Smith X-Patchwork-Id: 818033 Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (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 D2D09146A7A for ; Wed, 7 Aug 2024 22:19:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723069183; cv=none; b=Wk83NpUz53yXaEM95/rQiTq3IB0idWjTvrBa7USX4RUZG42MlOkkS+KTVlLPIr/heK+M28EloN9en/JrCGgd2DbzuqHp9WUIG0EyT/yQMFxi/tCRY0q62K4zQwUvh+3yg8tpaQtPUp9RHJvo+Sq09HomF/qC6JU+rIkxWjbWTxo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723069183; c=relaxed/simple; bh=9RaZLXyXmju0HkifB2luLpOJ/VCAdPA/SDtLvRODkHI=; h=Message-ID:Date:MIME-Version:From:Subject:To:Cc:Content-Type; b=DVbI87z8++VZwJWQcTLgiYy/oBlqjeH8TwJWMzstba+BsGPF6LhkEr5E1C/nos6PVV9pPcGczVZoUnf0GPNdQVo9EbSWE8VjXvEk7c7B8vYdfrC9htsw7rzUmqjsaBX/sYEl/4eOLoMN/M+50ihJSaMOw9F4Pvp/hBa1u20kJF8= 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=ZHcXIdR2; arc=none smtp.client-ip=209.85.218.44 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="ZHcXIdR2" Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a6265d3ba8fso30872966b.0 for ; Wed, 07 Aug 2024 15:19:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723069180; x=1723673980; darn=vger.kernel.org; h=content-transfer-encoding:content-language:cc:to:subject:from :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=vmDGTs8rq3T/++MCycT4WwVZ2D4e9REO/6u7dp24Dic=; b=ZHcXIdR2wwvfEyZeRC12sZVy2KQOHUgy1guC87vB5iDCSSqBz/qRCVRINgxx4juFDt S+dablPW5ZufDsSsk/Vpa6h/GyH8KyL27xrHd0Tn+MtvldGG2XwAlJ7m5cjwsOGJDc4F ZKzLD5rWNMw1v9IgCHcXLKujhU1n+yNBDeC96WtlmKkDtsCm7OMRNj4AXTf3WJcfs7L8 fM9SQY6zNIpbxDPOm4Qs2XFF8ON8H6+R1lOQ9dHI6R+6n4owNoTdKcWZvTksaHC/Viyw bVVqP7NWdrcr9r4Fn3BhCIWeNPhTuq5EsJdQjoKLb7EqD4/sO1SIq9WaW6si6K5hNl9H EfdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723069180; x=1723673980; h=content-transfer-encoding:content-language:cc:to:subject:from :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=vmDGTs8rq3T/++MCycT4WwVZ2D4e9REO/6u7dp24Dic=; b=osbcGoQSTYzx0h6xdBQ/bXZ4tSHf4f8wUoCr2JKWDIud4pZBpAEMhN/EMFTPGUYk24 XEUJqwfcsFD3+E0D8oaaOba2LC428DdyHXqR0wJtF7g51CKhKGdGaAX5LHQnBpZOXM6I cxHvz3w1jmk4b+DuhjWf14RShgSqnfRRhpyiCf8H24D5E/LD4hZEe3LDrQs47GdXVZpd QIa7YNR0t5GLFf9CIvKdZGA0UQ9uN5LB7ETbfRLhyFQMlOyiZ18VCTDhNvyfrpEYAZ+o Nkm4H66FNUr+PPxFnAIU2SheK81++vEDNzw+q7kxcozX47NsKHEfqbLzX1CGVku/nw8K yrxA== X-Gm-Message-State: AOJu0YylQFVSG4lG1TLtrqkUIYYnAUATy/rDKV2bAXO/rxHvDBiBl2In /arNsexjq04Il9W4EPrzViRtEHW9FMFlIrh4ygb6h+/QGvIf18A2HkHPPg== X-Google-Smtp-Source: AGHT+IF5p26tWRdWkeLITjIOz5+c9Cr2zjIPMpemEXp1Nam2I9zqVNdaC5Pjfyp/S4AhTjqI2bww6A== X-Received: by 2002:a17:907:7206:b0:a7a:9ca6:528 with SMTP id a640c23a62f3a-a7dc4dbadc4mr1109560766b.11.1723069179621; Wed, 07 Aug 2024 15:19:39 -0700 (PDT) Received: from [192.168.0.50] ([79.119.240.114]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7dc9bc3c9asm675376566b.37.2024.08.07.15.19.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 07 Aug 2024 15:19:39 -0700 (PDT) Message-ID: Date: Thu, 8 Aug 2024 01:19:36 +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 From: Bitterblue Smith Subject: [PATCH v4 1/4] wifi: rtw88: usb: Init RX burst length according to USB speed To: "linux-wireless@vger.kernel.org" Cc: Ping-Ke Shih , Sascha Hauer Content-Language: en-US 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 Signed-off-by: Bitterblue Smith --- v4: - Mention testing with RTL8822CU. v3: - Add Tested-by: Sascha Hauer 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 = { From patchwork Wed Aug 7 22:20:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bitterblue Smith X-Patchwork-Id: 817660 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (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 6EE7F12FF7B for ; Wed, 7 Aug 2024 22:20:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723069242; cv=none; b=eAkoaXixk3F9pz6o5rdPNPBYf9pFRyDmbdbWJoIs7z8sHlZG+tuVXMvGR695FGo6z7IXybektIf1+KBycgQ4PE9d8g4U4o3C/yCeb3xB/zCSafSZIxy3NYmBvf3yKegiH4YNsrPZW65yDWhpIWKDErjBshl2gHoudeHRLruKX+M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723069242; c=relaxed/simple; bh=8mqYTtW3gox2/aGZnKMSjTdE00CmM3stlXdyhG3lsKQ=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=PinOQtAUOMMk8yRG+sckFQF/eMGFk01Y4q7IoLMmrGtPbPowM+HDhpg3Hl/H3llX+H7Nr3j2QI39NWow8h6nrE1m/z3BiGDt5dVt8oFjoc7Vs/ui28Vbl6F5Si8P0pWpCjt41oNmeRAtVj7CCupm6rMjLqmnL7qYOQuQWvt0ofQ= 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=hRgU569f; arc=none smtp.client-ip=209.85.218.46 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="hRgU569f" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a7aa4ca9d72so35144966b.0 for ; Wed, 07 Aug 2024 15:20:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723069239; x=1723674039; 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=M6crcIQrQbAt+iJaI1484xTdIov/RSKa/6ANwXVUE48=; b=hRgU569fPmdlJmQ2NuKRps7ANHifBg7WCihOjlK9LrLiijicj2pGC3o7SlIr4juhmf KTd9Yvtm3oJ1XQ8OJPW9AKdovorIc+cFLlzoguaJPqBD9zOhmNAngT4hMS/TepROLAK+ 4Wworb4W8KjF4ihn/+fifxSpR4LlxxQI0eWAQ/2VjfN+vUc81GkReNja2nZLQq8ufuVS 9knDoVZiEsWwtT0ARDd6+knZQVFXyiB+DI6UfcI58czScvXCzmzq/cARnq+nJaMsC6Cs blXyDe701uBYVSqfIHhASxMpCB1q49ar/GjWTLD5X655+WA5SgVW5Y+is7GEtqfOeFr2 +S9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723069239; x=1723674039; 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=M6crcIQrQbAt+iJaI1484xTdIov/RSKa/6ANwXVUE48=; b=p4m4741R/nfhHGWQK+PivLTHgmlIqggGGk5gr9JutMYZkkK9xtiKfZS1TyGjO0FvzR S4s4cSN63w2+dYmaM8r2DYnGQTGw5R9QlHNrDFADxnPNzFtlTrV3inZJlHp1DJRirKgi VNEewBns3RBWjHzH6U4KYWXur/JSHB1GjavZPBfEGrte6A4GBOm095ZeN20cxqfo86UN YEiYKQtSt0koxrqoYoxSFSwV9Gg9dp/b7V27ruuAYe9Avto0/Pl4FYQOwlwea13H9II0 h2zw4UbDtIgPyP/T8e8tOiGBk/S0NmBOozNyY9+X/xLHKaPql6pTCUhY47jcKiCFG41v Tk9w== X-Gm-Message-State: AOJu0YyqGcYzQ7da7BVH44Y5km0KTjhPr2spWzpfJ0P/oyFrJdcX9Z/L 5/3hNW8bTYt+VPV+lU0cExixoFkKAMXsTgrbh7iiyGK+56OsX6j/TRYSbg== X-Google-Smtp-Source: AGHT+IHhav/14Vhc39m4sbeFLxP4P3rtW5voNC5t4K9nbcLBtZ/xN7JaZc6i4/pNXIOSxsKgi3YdMQ== X-Received: by 2002:a17:906:ee85:b0:a72:8762:1f5d with SMTP id a640c23a62f3a-a7dc507f309mr1359961066b.55.1723069238605; Wed, 07 Aug 2024 15:20:38 -0700 (PDT) Received: from [192.168.0.50] ([79.119.240.114]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7dc9ec7173sm670884166b.204.2024.08.07.15.20.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 07 Aug 2024 15:20:38 -0700 (PDT) Message-ID: <75a2ca52-8f01-45c5-926f-d3a68ae3b284@gmail.com> Date: Thu, 8 Aug 2024 01:20:36 +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 v4 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 RTL8822CU, RTL8811CU, and RTL8723DU. Tested-by: Sascha Hauer Signed-off-by: Bitterblue Smith --- v4: - Mention testing with RTL8822CU. v3: - Add Tested-by: Sascha Hauer v2: - Rebase on top of the latest rtw-next. --- 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 1c40d46a7eb4..10f1d724370e 100644 --- a/drivers/net/wireless/realtek/rtw88/usb.c +++ b/drivers/net/wireless/realtek/rtw88/usb.c @@ -581,6 +581,7 @@ static void rtw_usb_rx_handler(struct work_struct *work) skb_reserve(skb, pkt_offset); rtw_update_rx_freq_for_invalid(rtwdev, skb, &rx_status, &pkt_stat); + rtw_rx_stats(rtwdev, pkt_stat.vif, skb); memcpy(skb->cb, &rx_status, sizeof(rx_status)); ieee80211_rx_irqsafe(rtwdev->hw, skb); } From patchwork Wed Aug 7 22:21:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bitterblue Smith X-Patchwork-Id: 818032 Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (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 4615C250EC for ; Wed, 7 Aug 2024 22:21:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723069302; cv=none; b=CoNE8sTVcBTPLTDKJkDDY1n2pAlT4AMV1Uf53zktu/22r52UjmQcpQ2UHw6GA833fWlB1Hk4FbZcPesbzTdA8BIqefsTsFolE3255U/egpJjW6P4HRokJ9dbPi+6sPKhGIdWE8w5h0qEujqtIyLMn2LGTgAiVcP/NUz6QWhNDMU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723069302; c=relaxed/simple; bh=pe6imP2VCyfnUczdiPVEqzNmSJaqMa3x8rEL/jewclU=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=cU+4T2GSM/f4dqRWETlJaQR03k42ru89zOimX5rdpcRHVYvvNYC6+6RNJ7hES8VwzDZZuCt8+5MQhhR1W3cYtohaJ3uZF+pYDI4RviZ5KJJ68i0eCoYYPBOkwZm/nXVh8hFL37Y+wfYZcwTKIvHQLJKDedVjpDYskpNeCdFjeBs= 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=OWURHhzd; arc=none smtp.client-ip=209.85.218.52 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="OWURHhzd" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a7aada2358fso235037466b.0 for ; Wed, 07 Aug 2024 15:21:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723069298; x=1723674098; 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=lNYiS372C0zB0UDB3Hw6DFWhtABURfH2ZPnWnEEQDJA=; b=OWURHhzdwvNEVdrgjjFhl/sUzkBDOMEovpQ2sWRFrD8BylmukCpUaTqrFVcvTXsTC3 waFEA76WufFE7azEGKb55rbxJ7pRIwVQgIf7E29kvOHIvIhiAAtDf71MwVurxgPVla7x sOq8MsdIhBTN+oFMk8VwUfAqyrAC6B626i33U5jKyByfEKxyjXwHVeNWt90Ew5rouKwz Y69Hbwtviii8tu77+f07YNkMl6xElrhDYgJv1vF60gkiKaDFJzVDW7OWeBCWlldYnhb9 K9ysS6OR13O6bfKs4U2+NHQ3Xzg+VGJCJ03OXBLDiJcBDiIvbGUc3Fnb+Hw9TtGndWhF 16Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723069298; x=1723674098; 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=lNYiS372C0zB0UDB3Hw6DFWhtABURfH2ZPnWnEEQDJA=; b=o9QWflgzEDOuXOwR0bezLRtN7uwmoW6O/rMul1bFFeXwxvT2afzfNNoKY59KrhVKGt AyHK84wXgMEPbE04xA+XfwUApUiKWHB1t/vSJxTWa1+csRKJ6ssgxIOebnvbeFOlSshh wlsxUbO/6lx8Gg0sa0veFu3Ii6PKvbc7soWIl41/Yurarr6AoN2f+ZAPeoaTLqGAVgpU oeIIJpoyj99bj0jHaP6MjFigsTERAYhDig1UkW6a/h2BBpHiOL6eJcyc5zfmo+MacNAE ep87NMdGWRQz2SKAamejg2z1FR6ZutswvfBSpgDU6IiQtEzD3vON9TsIYpq32vWwxRgF Cv/g== X-Gm-Message-State: AOJu0Yyg3/g+A4xJhQiJfCyhIxkCbUQdLaaSIrd9WvyoMJke/V/E3dZU ydBioJtUORXtTy8AY97hnk5DDT3VLQnyvvJE3Bvzdi07ZBz0K2hsrCfvpA== X-Google-Smtp-Source: AGHT+IFd9CoAuV7PgznDBl1+zDWCP2go+nz6tnTVUdsgyTP9wsIBb+UiA9Bu1owrFPcnvMCCnOm7HA== X-Received: by 2002:a17:906:f58e:b0:a7d:c382:bcdf with SMTP id a640c23a62f3a-a807903616emr310294766b.10.1723069298154; Wed, 07 Aug 2024 15:21:38 -0700 (PDT) Received: from [192.168.0.50] ([79.119.240.114]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7dc9c0cc4fsm680506666b.77.2024.08.07.15.21.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 07 Aug 2024 15:21:37 -0700 (PDT) Message-ID: Date: Thu, 8 Aug 2024 01:21:36 +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 v4 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 of RTL8811CU on certain ARM systems, like the NanoPi NEO Core2. It also improves the RX speed of RTL8822CU on some x86_64 systems. Currently none of the chips are configured to aggregate frames. Tested with RTL8822CU, RTL8811CU, and RTL8723DU. Reviewed-by: Sascha Hauer Tested-by: Sascha Hauer Signed-off-by: Bitterblue Smith --- v4: - Mention testing with RTL8822CU and the effect on it. v3: - Don't initialise next_skb. - Add Tested-by and Reviewed-by: Sascha Hauer v2: - Simplify the code and make it more readable. - Rebase on top of latest rtw-next. --- drivers/net/wireless/realtek/rtw88/usb.c | 61 ++++++++++++++++-------- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/usb.c b/drivers/net/wireless/realtek/rtw88/usb.c index 10f1d724370e..64d68366812c 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; struct sk_buff *skb; - u32 pkt_desc_sz = chip->rx_pkt_desc_sz; - u32 pkt_offset; u8 *rx_desc; int limit; @@ -559,31 +560,48 @@ 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); + 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); + else + next_skb = NULL; + + 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_update_rx_freq_for_invalid(rtwdev, skb, + &rx_status, + &pkt_stat); + 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(skb, next_pkt); - rtw_update_rx_freq_for_invalid(rtwdev, skb, &rx_status, &pkt_stat); - rtw_rx_stats(rtwdev, pkt_stat.vif, skb); - memcpy(skb->cb, &rx_status, sizeof(rx_status)); - ieee80211_rx_irqsafe(rtwdev->hw, skb); + urb_len -= next_pkt; + } while (skb); } } @@ -627,6 +645,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 Wed Aug 7 22:23:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bitterblue Smith X-Patchwork-Id: 817659 Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (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 DBE6315099D for ; Wed, 7 Aug 2024 22:23:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723069393; cv=none; b=COme60OfMjPm+HGN+dZiPCdBSDxPOoKuS0ipr1q8nJQ0kRKexJsyLVd6SaJLvzwDKSXUe8uHtlKdrTCS8PrAbDVdBGvgkA2SdOjXJ+/f+8AtiPy8hFOv1pFNJPxS5c/Q7Zg5nrgsmLYJ0KnkpguyoDDlYhjXukLUzlJH3LssMOE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723069393; c=relaxed/simple; bh=Fh2RWqtm56i2+WTBmqxIWRaSapcjKz+iBHActXmf41U=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=nflKRZEU7MfDHbQnkRZmo2gVPIxebvYosEGueg9ab9TVYeIYqBaAUMVy5akBJwOMBlhcHMj04mT32Pb8xH1Big5+krWIqDZNYi14CHPoFkscVjhW5YXP7uKNYubnRDx+Jq44+GC5fRBaXO17NhxUnzLnrvaXsvmut4rG6damwQY= 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=NfpmWvWZ; arc=none smtp.client-ip=209.85.208.41 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="NfpmWvWZ" Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-5b8c2a61386so406065a12.2 for ; Wed, 07 Aug 2024 15:23:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723069390; x=1723674190; 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=ytRZqsYwgFuubJAxDI8mrUYLn6wZINR1ay3r2NNyESs=; b=NfpmWvWZaTFb55YgGSmPUvoYf+a8PbWxOllM2T8pKNuJiZ8zcRNbaSUnrZBBpqlFYQ 0V/nOv7Fc+O9l98RkZSt8bATVg1KDIvOmw0HaanHpdDq6p7YIpZy7pnFCcWWwPjMWsbm ra1vNVWN/FrcvxtjFOIs8++hB1G3yY5TfgaC8t5PPjkXYN79TsSdx5/CrdrFdr6woWbE kLpByO7Txy+LoKOGdWtVfzwuaBGN/ZLDWyYtI1XH69UnSyqIpma+RePPRVwQUDvM/YjL HQ35bfL9rEXYvkw3ip9a/Q7rt8NgO76z+QeE2lY/4xqRdy7DiznISCR8AnYujNGLB5qs 3N1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723069390; x=1723674190; 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=ytRZqsYwgFuubJAxDI8mrUYLn6wZINR1ay3r2NNyESs=; b=R4+S738u39ASkkn7WhVXLwtgxFTMc7rWUQL7sfkrdWJ+wV20xWMa+g77G02NN5zZSC yW9apn30goJwBk33Ye89GQ4CRILzM03mfAQuhf0o+hSObZ36nPCC3OoDLcTgwm+PZBqS DNTLryn0aLEpiSllLbVbF4dtblSxjXzG8CT32Qk2t1maEdk2gLPcvV2A4cjKyEZdN/wi k3unbtb2QGmIcGEfRQAEsNjWS7xqcaFp5l+vcAr1PjRyrAxGqaEed7bOTVGJMKckor4N +J5T3e8o96lX8rJVc/D6WBB6BkqlsLak91RSIDS4Vy3cqM51P7KgT6ITNeBMKfBR3O5n EYZg== X-Gm-Message-State: AOJu0YxkJI6WmJDBiq5pkJF8CmMRfBVmjtXrnN1bJyKnd3x7a28rUoG3 OUuiD38zLGlJSBBENK4NTcpcOz/DXQ1vafMRR9m9gGkC9JJLW3Ehs9dWhQ== X-Google-Smtp-Source: AGHT+IF4Zn5ELFIEzLixsjq6/D2djQGVL5iJIVepasoalTv4XUYHdfLR+6sgPz8686FSbc3d7SvDAA== X-Received: by 2002:a05:6402:5208:b0:5b8:f69b:65e8 with SMTP id 4fb4d7f45d1cf-5bbb1fa30cemr110579a12.0.1723069390001; Wed, 07 Aug 2024 15:23:10 -0700 (PDT) Received: from [192.168.0.50] ([79.119.240.114]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5bbb2d3473dsm1305a12.63.2024.08.07.15.23.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 07 Aug 2024 15:23:09 -0700 (PDT) Message-ID: Date: Thu, 8 Aug 2024 01:23:06 +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 v4 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 of RTL8811CU on certain ARM systems, like the NanoPi NEO Core2. Before: 28 Mbps, after: 231 Mbps. It also improves the RX speed of RTL8822CU on some x86_64 systems. Before: ~200 Mbps, after: ~300 Mbps. The official drivers for these chips use the same logic for SDIO, but for some reason the SDIO driver in rtw88 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. Tested-by: Sascha Hauer Signed-off-by: Bitterblue Smith --- v4: - Move call to rtw_hci_dynamic_rx_agg() after call to rtw_phy_dynamic_mechanism(). - Mention the effect on RTL8822CU. v3: - Add Tested-by: Sascha Hauer v2: - Rename {tx,rx}_unicast_shift to {tx,rx}_unicast_mbps. - Move the RX aggregation code from rtw8822c.c, rtw8822b.c, rtw8821c.c to usb.c. - Delete the rx_aggregation member from struct rtw_chip_ops and add dynamic_rx_agg member to struct rtw_hci_ops. - Rebase on top of the latest rtw-next. --- drivers/net/wireless/realtek/rtw88/hci.h | 7 ++++ drivers/net/wireless/realtek/rtw88/main.c | 13 +++++--- drivers/net/wireless/realtek/rtw88/pci.c | 1 + drivers/net/wireless/realtek/rtw88/sdio.c | 1 + drivers/net/wireless/realtek/rtw88/usb.c | 40 +++++++++++++++++++++++ 5 files changed, 58 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/hci.h b/drivers/net/wireless/realtek/rtw88/hci.h index 830d7532f2a3..96aeda26014e 100644 --- a/drivers/net/wireless/realtek/rtw88/hci.h +++ b/drivers/net/wireless/realtek/rtw88/hci.h @@ -18,6 +18,7 @@ struct rtw_hci_ops { void (*deep_ps)(struct rtw_dev *rtwdev, bool enter); void (*link_ps)(struct rtw_dev *rtwdev, bool enter); void (*interface_cfg)(struct rtw_dev *rtwdev); + void (*dynamic_rx_agg)(struct rtw_dev *rtwdev, bool enable); int (*write_data_rsvd_page)(struct rtw_dev *rtwdev, u8 *buf, u32 size); int (*write_data_h2c)(struct rtw_dev *rtwdev, u8 *buf, u32 size); @@ -72,6 +73,12 @@ static inline void rtw_hci_interface_cfg(struct rtw_dev *rtwdev) rtwdev->hci.ops->interface_cfg(rtwdev); } +static inline void rtw_hci_dynamic_rx_agg(struct rtw_dev *rtwdev, bool enable) +{ + if (rtwdev->hci.ops->dynamic_rx_agg) + rtwdev->hci.ops->dynamic_rx_agg(rtwdev, enable); +} + static inline int rtw_hci_write_data_rsvd_page(struct rtw_dev *rtwdev, u8 *buf, u32 size) { diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c index 9c58b7a41b95..b0c9b0ff7017 100644 --- a/drivers/net/wireless/realtek/rtw88/main.c +++ b/drivers/net/wireless/realtek/rtw88/main.c @@ -212,6 +212,7 @@ static void rtw_watch_dog_work(struct work_struct *work) struct rtw_traffic_stats *stats = &rtwdev->stats; struct rtw_watch_dog_iter_data data = {}; bool busy_traffic = test_bit(RTW_FLAG_BUSY_TRAFFIC, rtwdev->flags); + u32 tx_unicast_mbps, rx_unicast_mbps; bool ps_active; mutex_lock(&rtwdev->mutex); @@ -236,10 +237,11 @@ 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_mbps = stats->tx_unicast >> RTW_TP_SHIFT; + rx_unicast_mbps = stats->rx_unicast >> RTW_TP_SHIFT; + + ewma_tp_add(&stats->tx_ewma_tp, tx_unicast_mbps); + ewma_tp_add(&stats->rx_ewma_tp, rx_unicast_mbps); stats->tx_throughput = ewma_tp_read(&stats->tx_ewma_tp); stats->rx_throughput = ewma_tp_read(&stats->rx_ewma_tp); @@ -259,6 +261,9 @@ static void rtw_watch_dog_work(struct work_struct *work) rtw_phy_dynamic_mechanism(rtwdev); + rtw_hci_dynamic_rx_agg(rtwdev, + tx_unicast_mbps >= 1 || rx_unicast_mbps >= 1); + data.rtwdev = rtwdev; /* rtw_iterate_vifs internally uses an atomic iterator which is needed * to avoid taking local->iflist_mtx mutex diff --git a/drivers/net/wireless/realtek/rtw88/pci.c b/drivers/net/wireless/realtek/rtw88/pci.c index 5d0580da13fb..0b9b8807af2c 100644 --- a/drivers/net/wireless/realtek/rtw88/pci.c +++ b/drivers/net/wireless/realtek/rtw88/pci.c @@ -1601,6 +1601,7 @@ static struct rtw_hci_ops rtw_pci_ops = { .deep_ps = rtw_pci_deep_ps, .link_ps = rtw_pci_link_ps, .interface_cfg = rtw_pci_interface_cfg, + .dynamic_rx_agg = NULL, .read8 = rtw_pci_read8, .read16 = rtw_pci_read16, diff --git a/drivers/net/wireless/realtek/rtw88/sdio.c b/drivers/net/wireless/realtek/rtw88/sdio.c index 763aa8212a4b..21d0754dd7f6 100644 --- a/drivers/net/wireless/realtek/rtw88/sdio.c +++ b/drivers/net/wireless/realtek/rtw88/sdio.c @@ -1157,6 +1157,7 @@ static struct rtw_hci_ops rtw_sdio_ops = { .deep_ps = rtw_sdio_deep_ps, .link_ps = rtw_sdio_link_ps, .interface_cfg = rtw_sdio_interface_cfg, + .dynamic_rx_agg = NULL, .read8 = rtw_sdio_read8, .read16 = rtw_sdio_read16, diff --git a/drivers/net/wireless/realtek/rtw88/usb.c b/drivers/net/wireless/realtek/rtw88/usb.c index 64d68366812c..e83ab6fb83f5 100644 --- a/drivers/net/wireless/realtek/rtw88/usb.c +++ b/drivers/net/wireless/realtek/rtw88/usb.c @@ -766,6 +766,45 @@ static void rtw_usb_interface_cfg(struct rtw_dev *rtwdev) rtw_usb_init_burst_pkt_len(rtwdev); } +static void rtw_usb_dynamic_rx_agg_v1(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 void rtw_usb_dynamic_rx_agg(struct rtw_dev *rtwdev, bool enable) +{ + switch (rtwdev->chip->id) { + case RTW_CHIP_TYPE_8822C: + case RTW_CHIP_TYPE_8822B: + case RTW_CHIP_TYPE_8821C: + rtw_usb_dynamic_rx_agg_v1(rtwdev, enable); + break; + case RTW_CHIP_TYPE_8723D: + /* Doesn't like aggregation. */ + break; + case RTW_CHIP_TYPE_8703B: + /* Likely not found in USB devices. */ + break; + } +} + static struct rtw_hci_ops rtw_usb_ops = { .tx_write = rtw_usb_tx_write, .tx_kick_off = rtw_usb_tx_kick_off, @@ -775,6 +814,7 @@ static struct rtw_hci_ops rtw_usb_ops = { .deep_ps = rtw_usb_deep_ps, .link_ps = rtw_usb_link_ps, .interface_cfg = rtw_usb_interface_cfg, + .dynamic_rx_agg = rtw_usb_dynamic_rx_agg, .write8 = rtw_usb_write8, .write16 = rtw_usb_write16,