From patchwork Fri Aug 2 21:31:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bitterblue Smith X-Patchwork-Id: 818084 Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.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 46DCC1396 for ; Fri, 2 Aug 2024 21:32:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722634322; cv=none; b=tdup02dgaRadw6FuSkYLGH7WYzFkHuHd7WruS386Gs3LRuBzhSmkd23CXvZIb3+UY9uOKIyV5HqLQYgO4qiPtzGHT3gyJoI2a01GILV/EQf7lm0iBAG3wcucnNasLiOCf7vv8FgOsn7c934RvyrvPg0+0oZPBswmR5+pzbtKaho= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722634322; c=relaxed/simple; bh=HGx0O530dOwW5rZ+E8m7ukZZEOTOmkvWNaZiTvPZgUE=; h=Message-ID:Date:MIME-Version:From:Subject:To:Cc:Content-Type; b=fUxAcQx67gBjax7GHlwmDbuRKmGkkNQ1Ih3rl/QE+rsWITWnggBFBEuEwV/5szUhSC1Ss9jP7BxwqpH8L4U6yb31T5OQqR3xL8NbXV3Md5l3qjIF/7m2pjHU2H3GSwjmsx9dvcx/521CEW/3n+3hrDp/Ibc0Azv4NLi78PE/dNw= 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=gJKIkSUT; arc=none smtp.client-ip=209.85.208.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="gJKIkSUT" Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-5b01af9b0c9so7735230a12.3 for ; Fri, 02 Aug 2024 14:32:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722634319; x=1723239119; 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=Tz8UoTjHqnqY2V9WFS5GkOnrSV2Z/tdKX0vgvebcn3c=; b=gJKIkSUTPlSG5huXId560+55SygjU98S0mjpNuOsnveGedceSxmOVPh4zG1zB9FLbl TpNFyrd+MlvM2vsNWOZ8Mp7ITllrBH1gzDqZvw/NJIm4+5dgrXR50shiOdEwLpzKxFlR 2Hi/J9P2+1tcwRIhIsDfG2SIsL22ToVYexhUZNkicoaQqSlp+wG/OQhZ1eO1Cm0LaV90 YTWL0DYGvV+8Hbi1Dz9QxY6MCRPJQalKAAz/7Tv0NHFafBSGT515naL8nXE8/mkrFoP/ W/BndRNoPQ9B3pWM2JF/faArzLxU6fss5B0xUWdExOh4G5LaEwQW5Xs9AwyYV7wVaTiM TNXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722634319; x=1723239119; 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=Tz8UoTjHqnqY2V9WFS5GkOnrSV2Z/tdKX0vgvebcn3c=; b=ToHyiafgpYVDO5+Q7tYX/l40zxbqZXFWG5cmso5hpFGrlbRU/QuPBRDD5KaWwrjadc H+ZQec1fUYOuDrEJNSUDAleFakWpd8eLgMeQpeWFS00RCACRpFzvEQ697udZPNgrrJIU oYnHbcExw95hnTAQACOkkdSliVcFoP4eoV4WLNluQgh5JvtSscV08cxFC6ixTUJlQMxN RKBICpKYkUrzQKSxA6gzfKnjdDJkrn07Qw33A1JmJpIMAaKuh5slPAQXptJfd8ImSklX upPr1Inzg79u3IfIG5Y4o8bSXBFVn4OviIzUwI9gdVkYJhgMhlaP+ZwL5mX3zQS8Vm2s 0Vfw== X-Gm-Message-State: AOJu0YzQ1kBPAOYdnchbTJ8I+iaFmMEQr+YlHuBKsuTXN2kaEMRh8s0V dpnr+ynAJb4DBapE9gJhLXtEtcUzrs5LYheLu924jT0DEZYMOiQnf5n60A== X-Google-Smtp-Source: AGHT+IFN7kYlxmGFFTqfE/x+pAd+bNgOUok/II2Gj8Vyy2Ribk3/thUQEethbyapnFF6pT339AwCwg== X-Received: by 2002:a05:6402:457:b0:5a1:1:27a9 with SMTP id 4fb4d7f45d1cf-5b7f429466dmr3731516a12.18.1722634319277; Fri, 02 Aug 2024 14:31:59 -0700 (PDT) Received: from [192.168.0.50] ([79.119.240.114]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5b839b298desm1519122a12.22.2024.08.02.14.31.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 02 Aug 2024 14:31:58 -0700 (PDT) Message-ID: <60856bbc-8701-4aee-804c-3d8c00d4f5c5@gmail.com> Date: Sat, 3 Aug 2024 00:31:57 +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 v2 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 RTL8811CU and RTL8723DU. The RX speed is unchanged in my tests. Signed-off-by: Bitterblue Smith --- 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 Fri Aug 2 21:33:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bitterblue Smith X-Patchwork-Id: 816491 Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (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 184DB1396 for ; Fri, 2 Aug 2024 21:33:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722634386; cv=none; b=fhcd8rPPUzvMnTyM1HRSKZUVUvGYld2APDpoWsbRdsp6sAtHaneN9tFUz3wojEq8jxVYi6//zDFwacBdQiG0bF0yMb3WAZJNUj26R/mYLMG5r9ujXt9NyAhc01twvR4W1RsUO+57T7+YEc+9eUXERtQ62UQKezTP0b6SPaYAmj8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722634386; c=relaxed/simple; bh=dsM5T8buRWchqI60liVEUOPlWuhs71ryQ3cbcIudXBo=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=k/tO4kI0wEqJ6jJryY0p2bNEQw5XL0i/gTWrAR9jA6CnZ67h5ZP4I+oHLSmhWHX8Rm6ZzlwDFoA9/qVXqWukBQjLaJc5ZR6OzCbU0QbbulQNS32mtbuHRp1Dfpa1pVS/2R4uGcIuNlrw+xaL4uEsTU475XBAd6jDn1pRG4OIy2w= 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=LQbCa7YD; arc=none smtp.client-ip=209.85.218.53 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="LQbCa7YD" Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-a7d26c2297eso1082668566b.2 for ; Fri, 02 Aug 2024 14:33:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722634383; x=1723239183; 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=qWb/U6a1+cb2LkrJoqaGh9jGrIMelpBHol/y6TNP2z4=; b=LQbCa7YDSmZtwPz05EzNtNTdet9dKNC9ryE2QccnYHBGR5vKuhJkhHqNPmxORP+Fay 8mN63nCV4/ZGW48XfqZuDavAlZGipD/gNF2wFtFubaXgtLPYHdyPSXEYvCS+qrKV2TrH VIbNMjBeQuvICFWGPWha1nfLpKcB/Aq7A3GbeeBC/ivjYHaQ7InVhvrU0U3SakK3eeqq BQ9fliU0RjGL/LK3G6gYOVBfMqWekBrL9yfISHta78zXfj53JTZNBPjMNTm/sysoKFiu kcSRW1bml0w3TXJadVoMbskHtbUFoOu+PN4xPZaUE146EwE0cD0Ek4J1A5eqmZsN4/y/ tmfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722634383; x=1723239183; 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=qWb/U6a1+cb2LkrJoqaGh9jGrIMelpBHol/y6TNP2z4=; b=i64B9PMYvBvWwV9YW5KK25CTHp3HEkf8tZ/YMnZd8eZ6Wxc1W638OhlnwmTD/sI10u N2YE913UHq+4isGUCfG9RcT1qviTPvf07LIl+kz+EG4NKi8N0kaCVY+74LSZHswtDPjq 1E+3TBSVJ6tYtQOoNR8XDIm3vOQZC733WjlfnnuzGsbP5zV4ztsTToKTRapAUNPhZHgV qzgHBPIYFnNtMH90WhSIXSC8NVjlEWpAkhnd19L50y/LSvfT32zfj4n+1qmKsMQ81kaU Nml49773JBTq9RA8jKSuqYTEquS4yy1X2pZC90Wv+aGb3wS2ZuU3rSeHs3GOVmnsn6So Va2w== X-Gm-Message-State: AOJu0YzjxnA/Tml5rQ9Aqffcfcijm7L30D18on0sDTQQ9BwqVEIJtXKR DYyB4w7AsdK6r8zYyo/2GTC7CdFj3MW1Pn7ejwg2OHytHsFsJKbW/AhQpg== X-Google-Smtp-Source: AGHT+IF+tDQbuW46Ybq2JOZxuZIJP6DqQww0Has01pK4DAALoD3fPLcbao2M4wrT8XVLOfbdNWcG6A== X-Received: by 2002:a17:907:2d2c:b0:a77:eb34:3b49 with SMTP id a640c23a62f3a-a7dc4ff0b22mr373332066b.37.1722634383308; Fri, 02 Aug 2024 14:33:03 -0700 (PDT) Received: from [192.168.0.50] ([79.119.240.114]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7dc9d43777sm138047866b.136.2024.08.02.14.33.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 02 Aug 2024 14:33:03 -0700 (PDT) Message-ID: <3766e2fc-3970-4628-a660-98681450deb7@gmail.com> Date: Sat, 3 Aug 2024 00:33:02 +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 v2 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: <60856bbc-8701-4aee-804c-3d8c00d4f5c5@gmail.com> Content-Language: en-US In-Reply-To: <60856bbc-8701-4aee-804c-3d8c00d4f5c5@gmail.com> 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 --- 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 Fri Aug 2 21:34:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bitterblue Smith X-Patchwork-Id: 818083 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 34C681396 for ; Fri, 2 Aug 2024 21:34:23 +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=1722634464; cv=none; b=P4ORykDlbWEZf8NT33vw4ekqhWdjsJd2TCVPcSHGLDR1S7j5ofK2GXN1uElw/Wlh1AnqilQZhsMrBpcb4R7lBXimhYihhBCxJubUdWeMj5I0hwg1gJr7iQQ4kbo/jEWnrmXtICsVou7D7vB5PuhtTaOaMeX25rrOrBzIjAQqd1k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722634464; c=relaxed/simple; bh=XhbQEiol8HdUA4uf31CFHHLOjvpW4eppA9VS4mfoTI4=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=IH2p0V+ejkdHZAFPvuSqQWMqkuoasOG5KtjazLjOybD7YnHeTUB/6jOEhcy+1Anb4eQEqJTIoX/fMC4/8k4ypXbYgrY+rfYnS87bGog8vBNk0/1T/ZHv3ZSrhcY4ivJfA6NgddtWQ+JZKdVZkcoFV0rZGiGSWhoynP4vW1nYWHI= 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=GVP90H61; 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="GVP90H61" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a728f74c23dso1106254966b.1 for ; Fri, 02 Aug 2024 14:34:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722634461; x=1723239261; 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=JXGRikJbmkktOV29addA6aC5OBALJTXn+coH6SIDJaE=; b=GVP90H61N3GjSqfzmhAojGrqUnsJVZUIitxuhIkWNu5fo/4nGGopd0r+mJPIoxa3hz Qdo9Bcqtl/38oTNWgGfH8ZFdIZbUj5rx943EbH+Y3MZOxVQzfzsc41ipOcAOVytzWpWG DRxXWwq7mGbrZROsy50hzhk1hkybre5WaDyKlx9SRer0ueq5Fg/YR32Xkam+TXr0tAQh NUuUvnVHBu4BQ6W/oTKynV5mMRgTBppxxmQJZpeB4jzW3oXymIVyeTQHelFTYQN2uprl 2At/R9F19X8tgKyC0wh861N+UoKiXU6EgWAXTWzJ4CkGVtWNalBMNmm3pAnpBjTiPScv KFIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722634461; x=1723239261; 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=JXGRikJbmkktOV29addA6aC5OBALJTXn+coH6SIDJaE=; b=VvBh/luDSax1e4yQdaG+lR57KEsZ6rrNzVQI6Qy6uv36cidDgrHevEhXbQzzMfqCUb h4xML4hwJLS0kG/Hzn6oN6/EXt+hGfzrbxUiLAeI1EA2V84HjS5+ftDCUsdq0aIxD4tj GZRw6WoxdXxKzBP913PS6YVPXbbVEb5uOZ7ycv3fwkJGgyb2F98ny1UHiQd5kD1i/Rs2 ZSNDQiUR+7ZDRtUsKvviN79oBvFhVwCkI4F3kR9uMRdkx5UvnD1Bn9fIHmDuGbUOHtSc 8rBF4seO8zlB2sa4WDBNgOx3tShPwppia63DNRZjyATn6myh/mRozjMEjp1OF2Po9ezm 8rlw== X-Gm-Message-State: AOJu0YzIJOIJQWOo3rQaeBMt3Fyci6GNp8aB3pOKgvzxJ5QMBYLKk7EG I+St+xj3pJ0lB2FtKn9Bvl5fuFpI0vfZCpJo8wQ7ICIMRNT+UgxS2lCk/A== X-Google-Smtp-Source: AGHT+IFacnZcm6mnqTDyWmkHKUOKYoPmoqTj5Rx255QYIJaPzedCd+3u4LZR1TzteMDDpfkU4OhcdQ== X-Received: by 2002:a17:907:3207:b0:a77:e2e3:3554 with SMTP id a640c23a62f3a-a7dc4e0f5eemr280340666b.28.1722634461220; Fri, 02 Aug 2024 14:34:21 -0700 (PDT) Received: from [192.168.0.50] ([79.119.240.114]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7dc9d42825sm139293766b.123.2024.08.02.14.34.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 02 Aug 2024 14:34:20 -0700 (PDT) Message-ID: Date: Sat, 3 Aug 2024 00:34:20 +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 v2 3/4] wifi: rtw88: usb: Support RX aggregation From: Bitterblue Smith To: "linux-wireless@vger.kernel.org" Cc: Ping-Ke Shih , Sascha Hauer References: <60856bbc-8701-4aee-804c-3d8c00d4f5c5@gmail.com> Content-Language: en-US In-Reply-To: <60856bbc-8701-4aee-804c-3d8c00d4f5c5@gmail.com> 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 --- 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..4c7ba5c76a57 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,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 Fri Aug 2 21:35:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bitterblue Smith X-Patchwork-Id: 816490 Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.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 E57091396 for ; Fri, 2 Aug 2024 21:35:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722634523; cv=none; b=t4i11ThSVhaXQnq5QureS6w+BGkfo1oUGU0KZ6g21DhGcD23RkA//8xMCJCGDjxA1unaihsnCC7/JftZE+cS+t58jFDxtXcJLI0g9z+rDX9f7gFjV7AUzszHrwdIvtQG27oPNvtfQDTyW/jodQvyOCVTddCeEC3QwQV03IcGIZc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722634523; c=relaxed/simple; bh=i1vOswqw8rCACVrctqqZsOmTDYQTVApiVycBATHTRdk=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=oQLMr/bhRuU8I+zGXhv3POyFbFWLOXaNynKTW+FgZBJhYEn6+mPmhceqACqccMf3pjVxMuQSv1sjYvVkeCKPpwA5rsZdtaVo7kFA2Xz30RsrWjnaZv6VxJiZnJvJrAfqH25zM+KqYY8VDle4cqRSSTTMEg2PB3eniuiMISA25yk= 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=jurqyh6Z; arc=none smtp.client-ip=209.85.218.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="jurqyh6Z" Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a7a9a7af0d0so1118285066b.3 for ; Fri, 02 Aug 2024 14:35:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722634520; x=1723239320; 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=NvUvur/zldlLdvYsRY0dzKXYttpbaTGiBocMlMh5IeQ=; b=jurqyh6Zjh9FM2U0dFzMaHHTA0hBiqNtQjSsvTQ57Vddto+vTwjVDG3rSyEy17oBDK Xozp2kxPuBEWi7/mpoLTh3/9Cikg4Mf0QjeBvGQWDlYqYopyuL96f32OsOQB9KYw6lZY SaMGwlOu5JEhThjRW+/a39usVToRKM6pO5PGRP8PCYx4B+tZt1iNP2zfJiUDoU4R2PFv lwvIn42+in9nCNEJ0GWokIGlfaLp5eAFcr35ajjZNNH07Aym0QJ2myx+zTp8F+w4wC3m xYeWiZJnKfKNhEg4R3PGJ4FQVnrza7bLVpLVDIUr/9x7WN2L9hNygnjBLSQqkFE1mEA1 E0aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722634520; x=1723239320; 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=NvUvur/zldlLdvYsRY0dzKXYttpbaTGiBocMlMh5IeQ=; b=FjtmakQF0MLxikiytF/TR6cHrCZhdvcLWgQdTqFTjcY32hy5mLaCAoI5er4oGwU1xt yvG8VAIjBHY356MkLrO/gujOmXnTnuIaQkkKaU4uNEVISpAn+H3UIBHZJ5pwiONIfPw9 1xJJ1DZh8+zKAlotcsa3fB6Ju2MpW4ak/D9gsyUsWKlymoWmhvg6xqf8YyYsFz8YuIFR EN0T0nuuxrftWPzvU9iJ1MQ6XmPwNgpvVX1NZWYdwithY57RYo6f4HBRoZom5VKJI+VI 9HV4Gkz9WEtJUqtHo6y6Bw51UkWuWMAp+3tI6OWwviVTzkAsF0dxbp8Hevv/acq+Abyh 5fGQ== X-Gm-Message-State: AOJu0YzucKWBhEmxY6QQGc1f6uvs5x4PIPpOtY0T+sUtA/+arUxoc0E6 y6pTilT8rk0zc8CnAfLTZcPD8KFUZ3I4XnJzbPDeMYK8bdhS7GPfvgW9ow== X-Google-Smtp-Source: AGHT+IH6Dl65P5sVLdp6vCg+r+QyoAXw1c06d/K6VzQ9ecyJO+okljR5Rm321iNCZDWSRK7y9mwKhw== X-Received: by 2002:a17:907:7f17:b0:a7d:2bf7:5619 with SMTP id a640c23a62f3a-a7dc50fda98mr365316366b.58.1722634520001; Fri, 02 Aug 2024 14:35:20 -0700 (PDT) Received: from [192.168.0.50] ([79.119.240.114]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7dc9e80e49sm138673566b.180.2024.08.02.14.35.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 02 Aug 2024 14:35:19 -0700 (PDT) Message-ID: <5c04f7cf-25f2-42d1-acdb-f0e77baa527b@gmail.com> Date: Sat, 3 Aug 2024 00:35:18 +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 v2 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: <60856bbc-8701-4aee-804c-3d8c00d4f5c5@gmail.com> Content-Language: en-US In-Reply-To: <60856bbc-8701-4aee-804c-3d8c00d4f5c5@gmail.com> 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 RTL8821CU, before: 28 Mbps, after: 231 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. Signed-off-by: Bitterblue Smith --- 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..fd944248e6e7 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,13 +237,17 @@ 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); + rtw_hci_dynamic_rx_agg(rtwdev, + tx_unicast_mbps >= 1 || rx_unicast_mbps >= 1); + /* reset tx/rx statictics */ stats->tx_unicast = 0; stats->rx_unicast = 0; 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 4c7ba5c76a57..cbb5e17e65d1 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,