From patchwork Thu Nov 14 15:46:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bitterblue Smith X-Patchwork-Id: 13875290 X-Patchwork-Delegate: pkshih@realtek.com Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 0BA8118D65F for ; Thu, 14 Nov 2024 15:46:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731599173; cv=none; b=ctxh7+2K8Mr9COHEyCmx1sa/0iVVtDOfYRm/5vcDHeuFyI50xJvPqpUQ+Lt2o8SqByGYvmDWjhi3ZxGWpHr2OnnDrwYh66qV6/1M74RPp32IUghQM0xsduxUR07jSykdKpJ1lMRuNLEe9SdaduTa6+MBTdVI234/evwIeGq5A5E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731599173; c=relaxed/simple; bh=XRQF06g2uM9T71fRMMCmTtLAcL05W+Vnohf7gqnaHx4=; h=Message-ID:Date:MIME-Version:To:Cc:From:Subject:Content-Type; b=l9yyfjNxpe6+DStuvIl4NsxpwL6U73G/2H1tlAYnQ4ndWGyLCKzASeJqzz9OB+Avt8Av9EGWLIQYGoxP4tYwh9bVVGN3/zJQmSkVLiiNxYNRNluNgVTxlni4g+QQ/NcDBJ/Mjo83jJbrYnDPIYKjw1XSKxzERtVwDFnBK9jDOi0= 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=fik7Avny; arc=none smtp.client-ip=209.85.128.49 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="fik7Avny" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4316cce103dso9105445e9.3 for ; Thu, 14 Nov 2024 07:46:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731599170; x=1732203970; 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=T8O9jE5CsUMWDUfZMCDR4R1JYcvS1RvyXqx7RJWZk9Q=; b=fik7Avny5JujlZ955+gPAtN50g4aCskiiG94LzKVg9GQlZHqz5Bv2xa47pwwn+oi0b 8TvNkvqcIu3Kknf48lYsLFMG59aiuWxz43l5rDfFD/+7Av/r79ZUqsd7fCbi3tvt9ucv kTXvOrh8mCbJ9CVIEdTfmgTMKwZoWUZIo0OXUeH+GjGhiapQHyE0UA9M2fAaZ90js14G 6HD8X+ozaoJwGXDXujzDx2rlc5kcVGae3T/KhogNecsnrkyKnBrRCq0djO/3H6JKFq63 mqm69Zq5x+NyQhyuuQ9MbtJ7arwdG+4TXjgGlWnVA4rFO04UbH6Hvtip/RiLbmtmns0T Au2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731599170; x=1732203970; 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=T8O9jE5CsUMWDUfZMCDR4R1JYcvS1RvyXqx7RJWZk9Q=; b=M20yvoF90jvifvr4fma2oQ9zW2mMvDLcLrawFblQKgWlxMF1B9Zl4A+5QL2VZ9G9oh 3mgNZ/r0RHDv8yn/d7Rsg2R/CwsBeEegk4rCpaMst20VyPiqaTmFKuE4ljcxyyDyBycn 1PqUQxtAiy9Z4B/DscqRlefrv6QwcHxLRb/zbsFf/hD2auaEyyR3yEZ9G1+Gzo4h4/TO z59dTCHc1OFq3L3EPxsb/hZhABxDRgLmsN6KAh6bbqZkKLvD8yKuvr/ojJbsy/9npTpu WWAtGweyrGMpuuNff/dy6Dwseg0lAg68gOBT30ib+wVrVHtgRC8/Q32U47Qn4YBib++7 WWGA== X-Gm-Message-State: AOJu0Yx276RMapgXXMpm+5hwyXBKXmgAlqSfa5h/o12faccOU9aj3xaQ guoc4UT1Nqt41WT2jDUzi+YKKbjD8pU7H6mNHfYDxc6f2oCDiplZM7NhXg== X-Google-Smtp-Source: AGHT+IGbKeZZkL2fGsBhjLs4ikwwp13GjAio/FtrekKg9q3Vol/8TAhj7ICh7J1fGcF3V5n/YU80pg== X-Received: by 2002:a05:600c:3d16:b0:431:5c7b:e939 with SMTP id 5b1f17b1804b1-432da790770mr28766015e9.18.1731599170006; Thu, 14 Nov 2024 07:46:10 -0800 (PST) Received: from [192.168.1.50] ([79.113.150.231]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432dab78783sm24535635e9.12.2024.11.14.07.46.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 Nov 2024 07:46:09 -0800 (PST) Message-ID: <19cda72b-f1f1-4b69-8369-0e4376b646bf@gmail.com> Date: Thu, 14 Nov 2024 17:46:08 +0200 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 From: Bitterblue Smith Subject: [PATCH v2 1/2] wifi: rtw88: usb: Support USB 3 with RTL8812AU Add the function to automatically switch the RTL8812AU into USB 3 mode. Signed-off-by: Bitterblue Smith --- v2: - Add functions to check if the chip is "old" or "new". --- drivers/net/wireless/realtek/rtw88/usb.c | 44 ++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/usb.c b/drivers/net/wireless/realtek/rtw88/usb.c index 6fa3c37205f5..6f64c3fd96ae 100644 --- a/drivers/net/wireless/realtek/rtw88/usb.c +++ b/drivers/net/wireless/realtek/rtw88/usb.c @@ -931,6 +931,32 @@ static void rtw_usb_intf_deinit(struct rtw_dev *rtwdev, usb_set_intfdata(intf, NULL); } +static int rtw_usb_switch_mode_old(struct rtw_dev *rtwdev) +{ + struct rtw_usb *rtwusb = rtw_get_usb_priv(rtwdev); + enum usb_device_speed cur_speed = rtwusb->udev->speed; + u8 hci_opt; + + if (cur_speed == USB_SPEED_HIGH) { + hci_opt = rtw_read8(rtwdev, REG_HCI_OPT_CTRL); + + if ((hci_opt & (BIT(2) | BIT(3))) != BIT(3)) { + rtw_write8(rtwdev, REG_HCI_OPT_CTRL, 0x8); + rtw_write8(rtwdev, REG_SYS_SDIO_CTRL, 0x2); + rtw_write8(rtwdev, REG_ACLK_MON, 0x1); + rtw_write8(rtwdev, 0x3d, 0x3); + /* usb disconnect */ + rtw_write8(rtwdev, REG_SYS_PW_CTRL + 1, 0x80); + return 1; + } + } else if (cur_speed == USB_SPEED_SUPER) { + rtw_write8_clr(rtwdev, REG_SYS_SDIO_CTRL, BIT(1)); + rtw_write8_clr(rtwdev, REG_ACLK_MON, BIT(0)); + } + + return 0; +} + static int rtw_usb_switch_mode_new(struct rtw_dev *rtwdev) { enum usb_device_speed cur_speed; @@ -980,11 +1006,22 @@ static int rtw_usb_switch_mode_new(struct rtw_dev *rtwdev) return 1; } +static bool rtw_usb3_chip_old(u8 chip_id) +{ + return chip_id == RTW_CHIP_TYPE_8812A; +} + +static bool rtw_usb3_chip_new(u8 chip_id) +{ + return chip_id == RTW_CHIP_TYPE_8822C || + chip_id == RTW_CHIP_TYPE_8822B; +} + static int rtw_usb_switch_mode(struct rtw_dev *rtwdev) { u8 id = rtwdev->chip->id; - if (id != RTW_CHIP_TYPE_8822C && id != RTW_CHIP_TYPE_8822B) + if (!rtw_usb3_chip_new(id) && !rtw_usb3_chip_old(id)) return 0; if (!rtwdev->efuse.usb_mode_switch) { @@ -999,7 +1036,10 @@ static int rtw_usb_switch_mode(struct rtw_dev *rtwdev) return 0; } - return rtw_usb_switch_mode_new(rtwdev); + if (rtw_usb3_chip_old(id)) + return rtw_usb_switch_mode_old(rtwdev); + else + return rtw_usb_switch_mode_new(rtwdev); } int rtw_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) From patchwork Thu Nov 14 15:48:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bitterblue Smith X-Patchwork-Id: 13875291 X-Patchwork-Delegate: pkshih@realtek.com 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 10B4A19AA5D for ; Thu, 14 Nov 2024 15:48:13 +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=1731599295; cv=none; b=l9Glcf1CYiiOZjHKIQVprfASuErdxQfwb3hNuk1HsbpRIsurvKg7hXogH4QinwnyX53o+5YMilXg6jhte5j/4GTJWt51aHcE98G/3X1FEplHAUiH2pdjcj67O2PAyOxQ51SMlCgI2c99ld13fiIP2KdASB0MwrUmKR8sLLMXiMU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731599295; c=relaxed/simple; bh=qjAq2C0ijk7unSydPcU8ULh0epulUToMshqXcqIg5gA=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=UPNWyBPgQjAPSXNXOk647gf69u/QEiWOeg7BFn/MS+KoAPJnW3fhHuFNLiwFegqVHJGvmtbOaqSEEdQU88H1LD3bO6NMaft+tObVBRm8OZvVxp09dftiz8cO1X5BcBIx8bbnZWtIu7gUNjKVRsB5JpE79tLZ9TllzBMXojTWRk4= 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=YcQP0cAV; 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="YcQP0cAV" Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-5cf84214e9bso450630a12.3 for ; Thu, 14 Nov 2024 07:48:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731599292; x=1732204092; 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=aCnknGYMtmfmU+0ndu85QSTgjvuszj35beaca2ITwbk=; b=YcQP0cAVP5Pq0keFSvgiRn3ogQ/YZTHQmcEG9MfPxnSvlDBdN+OUxS/+MdearFENeE Q0sxo7O/C72glTby+no2jtPt0at6vmivtl4UYEh+aN+vK3Of89D7YWlWWv0WRkmYHpwb NoxCzXmEh5A7g8tFPqh76Yz9QPWjirYKWSonnknnzTxu1hucmJqyZ0zKrxawb+5Tasxc oCHGkg1qHnfFwaES0PLbWIsv4zHyDPF1wsvrXmpVaXRVjB3PeP2kiE591Z9V22QNjZMq qLMkhhLvAK2P6yGIe2E2Cu4J8RpvspRIpyB69Xh7MjRCNv1bZzQx35xbcYfnDZsczebr 0P3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731599292; x=1732204092; 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=aCnknGYMtmfmU+0ndu85QSTgjvuszj35beaca2ITwbk=; b=eVAtTMU6TNKTq564POljxV7kU21l3xq2CkO4oIBftI8idZLGHLelu2zfVUtwKB9mxV PHbXM4jiCR6PMkVwOHiJmh512MJQPqKMkrx8gmuLfVGmD40eVIYB4SJTu92Doyjoxzlw dC50ivfUQexPWe32p/Vrkntn+FfRzV1L1UeKJnWnboVfizLRIxYOqPpLue0Wnzx1dNu3 /pU6XojgK2ALkYW6XNHBDVljVeJ36Cod+yMTEezUiQgqXM8yZC4ZAEkyqbzJ78qWuEGO 6UDbqzBymGBz1M6/C4klPfGoQcFENvwsm7ZUsNoRoYZOi8ZKVQ9CJEZlimVL2sCH1Zpf RPNg== X-Gm-Message-State: AOJu0YwXz3aDxjkqwUzZ1bLSn0eQdn3jqsL/ehFh74vuEDXbN2ZghNOT qVRgo6kHjFDEY6k4jflk9GVTW8qIVd4/tdq309+COh3aI6Pw2l4pmsrDZg== X-Google-Smtp-Source: AGHT+IE/1DqNd9HHgpplZdg4isFPkzg7eUaoCShEfiLFN1XyuPGjuG8G1P/9pbWuRfGCD8m48DlGTw== X-Received: by 2002:a17:907:3fa2:b0:a9a:7f91:8c76 with SMTP id a640c23a62f3a-a9eefcec58dmr2578999166b.0.1731599291745; Thu, 14 Nov 2024 07:48:11 -0800 (PST) Received: from [192.168.1.50] ([79.113.150.231]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa20e045390sm76033366b.154.2024.11.14.07.48.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 Nov 2024 07:48:11 -0800 (PST) Message-ID: <63012163-a425-4b15-b830-43f279c06b73@gmail.com> Date: Thu, 14 Nov 2024 17:48:09 +0200 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/2] wifi: rtw88: usb: Enable RX aggregation for 8821au/8812au From: Bitterblue Smith To: "linux-wireless@vger.kernel.org" Cc: Ping-Ke Shih References: <19cda72b-f1f1-4b69-8369-0e4376b646bf@gmail.com> Content-Language: en-US In-Reply-To: <19cda72b-f1f1-4b69-8369-0e4376b646bf@gmail.com> USB RX aggregation improves the RX speed on certain ARM systems, like the NanoPi NEO Core2. With RTL8811AU, before: 30 Mbps, after: 224 Mbps. The out-of-tree driver uses aggregation size of 7 in USB 3 mode, but that doesn't work here. rtw88 advertises support for receiving AMSDU in AMPDU, so the AP sends larger frames, up to ~5100 bytes. With a size of 7 RTL8812AU frequently tries to aggregate more frames than will fit in 32768 bytes. Use a size of 6 instead. Signed-off-by: Bitterblue Smith --- v2: - Check for !enable first. --- drivers/net/wireless/realtek/rtw88/usb.c | 28 ++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/net/wireless/realtek/rtw88/usb.c b/drivers/net/wireless/realtek/rtw88/usb.c index 6f64c3fd96ae..91360d1b7b68 100644 --- a/drivers/net/wireless/realtek/rtw88/usb.c +++ b/drivers/net/wireless/realtek/rtw88/usb.c @@ -790,6 +790,30 @@ static void rtw_usb_dynamic_rx_agg_v1(struct rtw_dev *rtwdev, bool enable) rtw_write16(rtwdev, REG_RXDMA_AGG_PG_TH, val16); } +static void rtw_usb_dynamic_rx_agg_v2(struct rtw_dev *rtwdev, bool enable) +{ + struct rtw_usb *rtwusb = rtw_get_usb_priv(rtwdev); + u8 size, timeout; + u16 val16; + + if (!enable) { + size = 0x0; + timeout = 0x1; + } else if (rtwusb->udev->speed == USB_SPEED_SUPER) { + size = 0x6; + timeout = 0x1a; + } else { + size = 0x5; + timeout = 0x20; + } + + 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); + rtw_write8_set(rtwdev, REG_TXDMA_PQ_MAP, BIT_RXDMA_AGG_EN); +} + static void rtw_usb_dynamic_rx_agg(struct rtw_dev *rtwdev, bool enable) { switch (rtwdev->chip->id) { @@ -798,6 +822,10 @@ static void rtw_usb_dynamic_rx_agg(struct rtw_dev *rtwdev, bool enable) case RTW_CHIP_TYPE_8821C: rtw_usb_dynamic_rx_agg_v1(rtwdev, enable); break; + case RTW_CHIP_TYPE_8821A: + case RTW_CHIP_TYPE_8812A: + rtw_usb_dynamic_rx_agg_v2(rtwdev, enable); + break; case RTW_CHIP_TYPE_8723D: /* Doesn't like aggregation. */ break;