From: Jakub Kicinski <kuba@kernel.org>
To: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Cc: netdev@vger.kernel.org, Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>, Wen Gu <guwen@linux.alibaba.com>,
Philo Lu <lulie@linux.alibaba.com>,
Lorenzo Bianconi <lorenzo@kernel.org>,
Vadim Fedorenko <vadim.fedorenko@linux.dev>,
Lukas Bulwahn <lukas.bulwahn@redhat.com>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Vivian Wang <wangruikang@iscas.ac.cn>,
Troy Mitchell <troy.mitchell@linux.spacemit.com>,
Dust Li <dust.li@linux.alibaba.com>, Andrew Lunn <andrew@lunn.ch>
Subject: Re: [PATCH net-next v8 5/5] eea: introduce ethtool support
Date: Mon, 27 Oct 2025 18:37:54 -0700 [thread overview]
Message-ID: <20251027183754.52fe2a2c@kernel.org> (raw)
In-Reply-To: <20251023055239.89991-6-xuanzhuo@linux.alibaba.com>
On Thu, 23 Oct 2025 13:52:39 +0800 Xuan Zhuo wrote:
> +static const struct eea_stat_desc eea_rx_stats_desc[] = {
> + EEA_RX_STAT(descs),
> + EEA_RX_STAT(drops),
> + EEA_RX_STAT(kicks),
> + EEA_RX_STAT(split_hdr_bytes),
> + EEA_RX_STAT(split_hdr_packets),
> +};
> +
> +static const struct eea_stat_desc eea_tx_stats_desc[] = {
> + EEA_TX_STAT(descs),
> + EEA_TX_STAT(drops),
> + EEA_TX_STAT(kicks),
> + EEA_TX_STAT(timeouts),
> +};
Please don't expose via ethtool -S what can be exposed via standard
stats (drop -> qstats). FWIW you can add the split_hdr_bytes / pkts
to qstat too, IIRC mlx5 maintains that too.
> +static int eea_set_ringparam(struct net_device *netdev,
> + struct ethtool_ringparam *ring,
> + struct kernel_ethtool_ringparam *kernel_ring,
> + struct netlink_ext_ack *extack)
> +{
> + struct eea_net *enet = netdev_priv(netdev);
> + struct eea_net_init_ctx ctx;
> + bool need_update = false;
> + struct eea_net_cfg *cfg;
> + bool sh;
> +
> + enet_init_ctx(enet, &ctx);
> +
> + cfg = &ctx.cfg;
> +
> + if (ring->rx_mini_pending || ring->rx_jumbo_pending) {
> + NL_SET_ERR_MSG_FMT_MOD(extack,
> + "not support rx_mini_pending/rx_jumbo_pending");
> + return -EINVAL;
> + }
> +
> + if (ring->rx_pending > enet->cfg_hw.rx_ring_depth) {
> + NL_SET_ERR_MSG_FMT_MOD(extack, "rx (%d) > max (%d)",
> + ring->rx_pending,
> + enet->cfg_hw.rx_ring_depth);
> + return -EINVAL;
> + }
> +
> + if (ring->tx_pending > enet->cfg_hw.tx_ring_depth) {
Core already validates against max, I think the 3 ifs above are
pointless.
> + NL_SET_ERR_MSG_FMT_MOD(extack, "tx (%d) > max (%d)",
> + ring->tx_pending,
> + enet->cfg_hw.tx_ring_depth);
> + return -EINVAL;
> + }
> +
> + if (ring->rx_pending != cfg->rx_ring_depth)
> + need_update = true;
> +
> + if (ring->tx_pending != cfg->tx_ring_depth)
> + need_update = true;
> +
> + sh = kernel_ring->tcp_data_split == ETHTOOL_TCP_DATA_SPLIT_ENABLED;
> + if (sh != !!(cfg->split_hdr))
> + need_update = true;
> +
> + if (!need_update)
> + return 0;
> +
> + cfg->rx_ring_depth = ring->rx_pending;
> + cfg->tx_ring_depth = ring->tx_pending;
> +
> + cfg->split_hdr = sh ? enet->cfg_hw.split_hdr : 0;
> +
> + return eea_reset_hw_resources(enet, &ctx);
> +}
> +
> +static int eea_set_channels(struct net_device *netdev,
> + struct ethtool_channels *channels)
> +{
> + struct eea_net *enet = netdev_priv(netdev);
> + u16 queue_pairs = channels->combined_count;
> + struct eea_net_init_ctx ctx;
> + struct eea_net_cfg *cfg;
> +
> + enet_init_ctx(enet, &ctx);
> +
> + cfg = &ctx.cfg;
> +
> + if (channels->rx_count || channels->tx_count || channels->other_count)
> + return -EINVAL;
ditto
> + if (queue_pairs > enet->cfg_hw.rx_ring_num || queue_pairs == 0)
> + return -EINVAL;
Pretty sure core checks that at least 1 queue is configured
> + if (queue_pairs == enet->cfg.rx_ring_num &&
> + queue_pairs == enet->cfg.tx_ring_num)
> + return 0;
And I think netlink will not call you without any updates either.
> + cfg->rx_ring_num = queue_pairs;
> + cfg->tx_ring_num = queue_pairs;
> +
> + return eea_reset_hw_resources(enet, &ctx);
> +}
> +
> +static void eea_get_channels(struct net_device *netdev,
> + struct ethtool_channels *channels)
> +{
> + struct eea_net *enet = netdev_priv(netdev);
> +
> + channels->combined_count = enet->cfg.rx_ring_num;
> + channels->max_combined = enet->cfg_hw.rx_ring_num;
> +}
> @@ -321,6 +341,10 @@ void eea_tx_timeout(struct net_device *netdev, unsigned int txqueue)
> struct eea_net *priv = netdev_priv(netdev);
> struct eea_net_tx *tx = &priv->tx[txqueue];
>
> + u64_stats_update_begin(&tx->stats.syncp);
> + u64_stats_inc(&tx->stats.timeouts);
> + u64_stats_update_end(&tx->stats.syncp);
> +
core maintains and reports timeouts already
--
pw-bot: cr
prev parent reply other threads:[~2025-10-28 1:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-23 5:52 [PATCH net-next v8 0/5] eea: Add basic driver framework for Alibaba Elastic Ethernet Adaptor Xuan Zhuo
2025-10-23 5:52 ` [PATCH net-next v8 1/5] eea: introduce PCI framework Xuan Zhuo
2025-10-23 5:52 ` [PATCH net-next v8 2/5] eea: introduce ring and descriptor structures Xuan Zhuo
2025-10-23 5:52 ` [PATCH net-next v8 3/5] eea: probe the netdevice and create adminq Xuan Zhuo
2025-10-23 5:52 ` [PATCH net-next v8 4/5] eea: create/destroy rx,tx queues for netdevice open and stop Xuan Zhuo
2025-10-23 5:52 ` [PATCH net-next v8 5/5] eea: introduce ethtool support Xuan Zhuo
2025-10-28 1:37 ` Jakub Kicinski [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=20251027183754.52fe2a2c@kernel.org \
--to=kuba@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=dust.li@linux.alibaba.com \
--cc=edumazet@google.com \
--cc=geert+renesas@glider.be \
--cc=guwen@linux.alibaba.com \
--cc=lorenzo@kernel.org \
--cc=lukas.bulwahn@redhat.com \
--cc=lulie@linux.alibaba.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=troy.mitchell@linux.spacemit.com \
--cc=vadim.fedorenko@linux.dev \
--cc=wangruikang@iscas.ac.cn \
--cc=xuanzhuo@linux.alibaba.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;
as well as URLs for NNTP newsgroup(s).