All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ping-Ke Shih <pkshih@realtek.com>
To: Bitterblue Smith <rtl8821cerfe2@gmail.com>,
	"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Cc: Sascha Hauer <sha@pengutronix.de>
Subject: RE: [PATCH 4/4] wifi: rtw88: Enable USB RX aggregation for 8822c/8822b/8821c
Date: Tue, 30 Jul 2024 05:47:35 +0000	[thread overview]
Message-ID: <a4e147a24d5d4165a336432d89773025@realtek.com> (raw)
In-Reply-To: <323190ee-5b88-4d37-bad0-b721cdfead1a@gmail.com>

Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
> 
> 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.

Please explicitly set .rx_aggregation = NULL to these two chips, so
we know these two chips don't have this feature.

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

{tx,rx}_unicast_mbps because 'shift' is to get Mbps.

> +
> +       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);
> +       }

Move this chunk to a function with arguments {tx,rx}_unicast_mbps.
The function name might be something like rtw_dynamic_usb_rx_aggregation().

> +
>         /* 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);
> +}
> +

All use the same settings. Move this to rtw_usb_rx_aggregation() called by
rtw_dynamic_usb_rx_aggregation().




  reply	other threads:[~2024-07-30  5:47 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-28 19:39 [PATCH 1/4] wifi: rtw88: Init RX burst length for 8822cu/8822bu/8821cu Bitterblue Smith
2024-07-28 19:41 ` [PATCH 2/4] wifi: rtw88: usb: Update the RX stats after every frame Bitterblue Smith
2024-07-30  3:59   ` Ping-Ke Shih
2024-07-28 19:42 ` [PATCH 3/4] wifi: rtw88: usb: Support RX aggregation Bitterblue Smith
2024-07-30  4:33   ` Ping-Ke Shih
2024-07-31 16:58     ` Bitterblue Smith
2024-07-30  6:39   ` Sascha Hauer
2024-07-31 16:58     ` Bitterblue Smith
2024-07-28 19:44 ` [PATCH 4/4] wifi: rtw88: Enable USB RX aggregation for 8822c/8822b/8821c Bitterblue Smith
2024-07-30  5:47   ` Ping-Ke Shih [this message]
2024-07-31 17:00     ` Bitterblue Smith
2024-08-01  2:08       ` Ping-Ke Shih
2024-07-30  3:57 ` [PATCH 1/4] wifi: rtw88: Init RX burst length for 8822cu/8822bu/8821cu Ping-Ke Shih
2024-07-31 16:57   ` Bitterblue Smith
2024-08-01  2:05     ` Ping-Ke Shih

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a4e147a24d5d4165a336432d89773025@realtek.com \
    --to=pkshih@realtek.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=rtl8821cerfe2@gmail.com \
    --cc=sha@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.