From: Heiner Kallweit <hkallweit1@gmail.com>
To: javen <javen_xu@realsil.com.cn>,
nic_swsd@realtek.com, andrew+netdev@lunn.ch, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
horms@kernel.org
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [Patch net-next v3 7/7] r8169: add support for ethtool
Date: Sun, 17 May 2026 00:07:30 +0200 [thread overview]
Message-ID: <172ed6a7-4e20-4fcf-a192-b8d3116b7d9b@gmail.com> (raw)
In-Reply-To: <20260513115543.1730-8-javen_xu@realsil.com.cn>
On 13.05.2026 13:55, javen wrote:
> From: Javen Xu <javen_xu@realsil.com.cn>
>
> This patch add support for changing rx queues by ethtool. We can set rx
> 1, 2, 4, 8 by ethtool -L eth1 rx num.
>
> Signed-off-by: Javen Xu <javen_xu@realsil.com.cn>
> ---
> Changes in v2:
> - no changes
>
> Changes in v3:
> - no changes
> ---
> drivers/net/ethernet/realtek/r8169_main.c | 126 ++++++++++++++++++++++
> 1 file changed, 126 insertions(+)
>
> diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
> index f654e98e47be..ae64955e47d4 100644
> --- a/drivers/net/ethernet/realtek/r8169_main.c
> +++ b/drivers/net/ethernet/realtek/r8169_main.c
> @@ -6269,6 +6269,130 @@ static void r8169_init_napi(struct rtl8169_private *tp)
> }
> }
>
> +static void rtl8169_get_channels(struct net_device *dev,
> + struct ethtool_channels *ch)
> +{
> + struct rtl8169_private *tp = netdev_priv(dev);
> +
> + ch->max_rx = tp->hw_supp_num_rx_queues;
> + ch->max_tx = 1;
> + ch->max_other = 0;
> + ch->max_combined = 0;
The struct comes zero-initialized, so explicitly setting zero
values shouldn't be needed.
> +
> + ch->rx_count = tp->num_rx_rings;
> + ch->tx_count = 1;
> + ch->other_count = 0;
> + ch->combined_count = 0;
> +}
> +
> +static int rtl8169_realloc_rx(struct rtl8169_private *tp,
> + struct rtl8169_rx_ring *new_rx,
> + int new_count)
> +{
> + int i, ret;
> +
> + for (i = 0; i < new_count; i++) {
> + struct rtl8169_rx_ring *ring = &new_rx[i];
> +
> + ring->rx_desc_array = dma_alloc_coherent(&tp->pci_dev->dev,
> + R8169_RX_RING_BYTES,
> + &ring->rx_phy_addr,
> + GFP_KERNEL);
> + if (!ring->rx_desc_array) {
> + ret = -ENOMEM;
> + goto err_free;
> + }
> +
> + memset(ring->rx_databuff, 0, sizeof(ring->rx_databuff));
> + ret = rtl8169_rx_fill(tp, ring);
> + if (ret) {
> + dma_free_coherent(&tp->pci_dev->dev, R8169_RX_RING_BYTES,
> + ring->rx_desc_array, ring->rx_phy_addr);
> + goto err_free;
> + }
> + }
> + return 0;
> +
> +err_free:
> + while (--i >= 0) {
> + rtl8169_rx_clear(tp, &new_rx[i]);
> + dma_free_coherent(&tp->pci_dev->dev, R8169_RX_RING_BYTES,
> + new_rx[i].rx_desc_array, new_rx[i].rx_phy_addr);
> + }
> + return ret;
> +}
> +
> +static int rtl8169_set_channels(struct net_device *dev,
> + struct ethtool_channels *ch)
> +{
> + struct rtl8169_private *tp = netdev_priv(dev);
> + bool if_running = netif_running(dev);
> + struct rtl8169_rx_ring *new_rx;
> + u8 old_tx_desc_type = tp->init_rx_desc_type;
> + u8 new_desc_type;
> + bool new_rss_enable;
> + int i, ret;
> +
> + if (!tp->rss_support && (ch->rx_count > 1 || ch->tx_count > 1)) {
> + netdev_warn(dev, "This chip does not support multiple channels/RSS.\n");
> + return -EOPNOTSUPP;
> + }
> +
> + if (!(tp->features & RTL_VEC_MAP_ENABLE))
> + return -EINVAL;
> +
> + new_rss_enable = (ch->rx_count > 1 && tp->rss_support);
> + new_desc_type = new_rss_enable ? RX_DESC_RING_TYPE_RSS : RX_DESC_RING_TYPE_DEFAULT;
> + tp->init_rx_desc_type = new_desc_type;
> +
> + if (!if_running) {
> + tp->num_rx_rings = ch->rx_count;
> + tp->rss_enable = new_rss_enable;
> + return 0;
> + }
> +
> + new_rx = kcalloc(R8169_MAX_RX_QUEUES, sizeof(*new_rx), GFP_KERNEL);
Better use the new _obj allocators, like kzalloc_objs here.
> + if (!new_rx)
> + return -ENOMEM;
> +
> + ret = rtl8169_realloc_rx(tp, new_rx, ch->rx_count);
> + if (ret) {
> + kfree(new_rx);
> + tp->init_rx_desc_type = old_tx_desc_type;
> + return ret;
> + }
> +
> + netif_stop_queue(dev);
> + rtl8169_down(tp);
> +
> + for (i = 0; i < tp->num_rx_rings; i++)
> + rtl8169_rx_clear(tp, &tp->rx_ring[i]);
> + rtl8169_free_rx_desc(tp);
> +
> + tp->num_rx_rings = ch->rx_count;
> + tp->rss_enable = new_rss_enable;
> +
> + memset(tp->rx_ring, 0, sizeof(tp->rx_ring));
> + memcpy(tp->rx_ring, new_rx, sizeof(*new_rx) * ch->rx_count);
> +
> + for (i = 0; i < tp->rss_data->hw_supp_indir_tbl_entries; i++) {
> + if (tp->rss_enable)
> + tp->rss_data->rss_indir_tbl[i] =
> + ethtool_rxfh_indir_default(i, tp->num_rx_rings);
> + else
> + tp->rss_data->rss_indir_tbl[i] = 0;
> + }
> +
> + rtl_set_irq_mask(tp);
> +
> + rtl8169_up(tp);
> + netif_start_queue(dev);
> +
> + kfree(new_rx);
> +
> + return 0;
> +}
> +
> static const struct ethtool_ops rtl8169_ethtool_ops = {
> .supported_coalesce_params = ETHTOOL_COALESCE_USECS |
> ETHTOOL_COALESCE_MAX_FRAMES,
> @@ -6287,6 +6411,8 @@ static const struct ethtool_ops rtl8169_ethtool_ops = {
> .nway_reset = phy_ethtool_nway_reset,
> .get_eee = rtl8169_get_eee,
> .set_eee = rtl8169_set_eee,
> + .get_channels = rtl8169_get_channels,
> + .set_channels = rtl8169_set_channels,
> .get_link_ksettings = phy_ethtool_get_link_ksettings,
> .set_link_ksettings = rtl8169_set_link_ksettings,
> .get_ringparam = rtl8169_get_ringparam,
prev parent reply other threads:[~2026-05-16 22:07 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-13 11:55 [Patch net-next v3 0/7] r8169: add RSS support for RTL8127 javen
2026-05-13 11:55 ` [Patch net-next v3 1/7] r8169: add support for multi irqs javen
2026-05-16 22:07 ` Heiner Kallweit
2026-05-13 11:55 ` [Patch net-next v3 2/7] r8169: add support for multi rx queues javen
2026-05-16 22:07 ` Heiner Kallweit
2026-05-18 7:47 ` Javen
2026-05-13 11:55 ` [Patch net-next v3 3/7] r8169: add support for new interrupt mapping javen
2026-05-16 22:07 ` Heiner Kallweit
2026-05-18 8:21 ` Javen
2026-05-13 11:55 ` [Patch net-next v3 4/7] r8169: enable " javen
2026-05-13 11:55 ` [Patch net-next v3 5/7] r8169: add support and enable rss javen
2026-05-15 0:21 ` Jakub Kicinski
2026-05-16 22:07 ` Heiner Kallweit
2026-05-18 11:17 ` Javen
2026-05-13 11:55 ` [Patch net-next v3 6/7] r8169: move struct ethtool_ops javen
2026-05-13 11:55 ` [Patch net-next v3 7/7] r8169: add support for ethtool javen
2026-05-16 22:07 ` Heiner Kallweit [this message]
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=172ed6a7-4e20-4fcf-a192-b8d3116b7d9b@gmail.com \
--to=hkallweit1@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=javen_xu@realsil.com.cn \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nic_swsd@realtek.com \
--cc=pabeni@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox