lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251027183754.52fe2a2c@kernel.org>
Date: Mon, 27 Oct 2025 18:37:54 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Xuan Zhuo <xuanzhuo@...ux.alibaba.com>
Cc: netdev@...r.kernel.org, Andrew Lunn <andrew+netdev@...n.ch>, "David S.
 Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>, Paolo
 Abeni <pabeni@...hat.com>, Wen Gu <guwen@...ux.alibaba.com>, Philo Lu
 <lulie@...ux.alibaba.com>, Lorenzo Bianconi <lorenzo@...nel.org>, Vadim
 Fedorenko <vadim.fedorenko@...ux.dev>, Lukas Bulwahn
 <lukas.bulwahn@...hat.com>, Geert Uytterhoeven <geert+renesas@...der.be>,
 Vivian Wang <wangruikang@...as.ac.cn>, Troy Mitchell
 <troy.mitchell@...ux.spacemit.com>, Dust Li <dust.li@...ux.alibaba.com>,
 Andrew Lunn <andrew@...n.ch>
Subject: Re: [PATCH net-next v8 5/5] eea: introduce ethtool support

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ