Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'net-mlx-migrate-to-new-get_rx_ring_count-ethtool-api'

Breno Leitao says:

====================
net: mlx: migrate to new get_rx_ring_count ethtool API

This series migrates the mlx4 and mlx5 drivers to use the new
.get_rx_ring_count() callback introduced in commit 84eaf4359c36 ("net:
ethtool: add get_rx_ring_count callback to optimize RX ring queries").

Previously, these drivers handled ETHTOOL_GRXRINGS within the
.get_rxnfc() callback. With the dedicated .get_rx_ring_count() API, this
handling can be extracted and simplified.

For mlx5, this affects both the ethernet and IPoIB drivers. The
ETHTOOL_GRXRINGS handling was previously kept in .get_rxnfc() to support
"ethtool -x" when CONFIG_MLX5_EN_RXNFC=n, but this is no longer
necessary with the new dedicated callback.

Note: The mlx4 changes are compile-tested only, while mlx5 changes were
properly tested.
====================

Link: https://patch.msgid.link/20251113-mlx_grxrings-v1-0-0017f2af7dd0@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+24 -23
+8 -3
drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
··· 1727 1727 1728 1728 } 1729 1729 1730 + static u32 mlx4_en_get_rx_ring_count(struct net_device *dev) 1731 + { 1732 + struct mlx4_en_priv *priv = netdev_priv(dev); 1733 + 1734 + return priv->rx_ring_num; 1735 + } 1736 + 1730 1737 static int mlx4_en_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd, 1731 1738 u32 *rule_locs) 1732 1739 { ··· 1750 1743 return -EINVAL; 1751 1744 1752 1745 switch (cmd->cmd) { 1753 - case ETHTOOL_GRXRINGS: 1754 - cmd->data = priv->rx_ring_num; 1755 - break; 1756 1746 case ETHTOOL_GRXCLSRLCNT: 1757 1747 cmd->rule_cnt = mlx4_en_get_num_flows(priv); 1758 1748 break; ··· 2158 2154 .set_ringparam = mlx4_en_set_ringparam, 2159 2155 .get_rxnfc = mlx4_en_get_rxnfc, 2160 2156 .set_rxnfc = mlx4_en_set_rxnfc, 2157 + .get_rx_ring_count = mlx4_en_get_rx_ring_count, 2161 2158 .get_rxfh_indir_size = mlx4_en_get_rxfh_indir_size, 2162 2159 .get_rxfh_key_size = mlx4_en_get_rxfh_key_size, 2163 2160 .get_rxfh = mlx4_en_get_rxfh,
+8 -10
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
··· 2492 2492 return mlx5e_ethtool_set_rxfh_fields(priv, cmd, extack); 2493 2493 } 2494 2494 2495 + static u32 mlx5e_get_rx_ring_count(struct net_device *dev) 2496 + { 2497 + struct mlx5e_priv *priv = netdev_priv(dev); 2498 + 2499 + return priv->channels.params.num_channels; 2500 + } 2501 + 2495 2502 static int mlx5e_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info, 2496 2503 u32 *rule_locs) 2497 2504 { 2498 2505 struct mlx5e_priv *priv = netdev_priv(dev); 2499 - 2500 - /* ETHTOOL_GRXRINGS is needed by ethtool -x which is not part 2501 - * of rxnfc. We keep this logic out of mlx5e_ethtool_get_rxnfc, 2502 - * to avoid breaking "ethtool -x" when mlx5e_ethtool_get_rxnfc 2503 - * is compiled out via CONFIG_MLX5_EN_RXNFC=n. 2504 - */ 2505 - if (info->cmd == ETHTOOL_GRXRINGS) { 2506 - info->data = priv->channels.params.num_channels; 2507 - return 0; 2508 - } 2509 2506 2510 2507 return mlx5e_ethtool_get_rxnfc(priv, info, rule_locs); 2511 2508 } ··· 2763 2766 .remove_rxfh_context = mlx5e_remove_rxfh_context, 2764 2767 .get_rxnfc = mlx5e_get_rxnfc, 2765 2768 .set_rxnfc = mlx5e_set_rxnfc, 2769 + .get_rx_ring_count = mlx5e_get_rx_ring_count, 2766 2770 .get_tunable = mlx5e_get_tunable, 2767 2771 .set_tunable = mlx5e_set_tunable, 2768 2772 .get_pause_stats = mlx5e_get_pause_stats,
+8 -10
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ethtool.c
··· 266 266 return mlx5e_ethtool_set_rxnfc(priv, cmd); 267 267 } 268 268 269 + static u32 mlx5i_get_rx_ring_count(struct net_device *dev) 270 + { 271 + struct mlx5e_priv *priv = mlx5i_epriv(dev); 272 + 273 + return priv->channels.params.num_channels; 274 + } 275 + 269 276 static int mlx5i_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info, 270 277 u32 *rule_locs) 271 278 { 272 279 struct mlx5e_priv *priv = mlx5i_epriv(dev); 273 - 274 - /* ETHTOOL_GRXRINGS is needed by ethtool -x which is not part 275 - * of rxnfc. We keep this logic out of mlx5e_ethtool_get_rxnfc, 276 - * to avoid breaking "ethtool -x" when mlx5e_ethtool_get_rxnfc 277 - * is compiled out via CONFIG_MLX5_EN_RXNFC=n. 278 - */ 279 - if (info->cmd == ETHTOOL_GRXRINGS) { 280 - info->data = priv->channels.params.num_channels; 281 - return 0; 282 - } 283 280 284 281 return mlx5e_ethtool_get_rxnfc(priv, info, rule_locs); 285 282 } ··· 301 304 .set_rxfh_fields = mlx5i_set_rxfh_fields, 302 305 .get_rxnfc = mlx5i_get_rxnfc, 303 306 .set_rxnfc = mlx5i_set_rxnfc, 307 + .get_rx_ring_count = mlx5i_get_rx_ring_count, 304 308 .get_link_ksettings = mlx5i_get_link_ksettings, 305 309 .get_link = ethtool_op_get_link, 306 310 };