Commit 122ac16b authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

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 84eaf435 ("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: default avatarJakub Kicinski <kuba@kernel.org>
parents c9dfb92d 94549966
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -1727,6 +1727,13 @@ static int mlx4_en_get_num_flows(struct mlx4_en_priv *priv)

}

static u32 mlx4_en_get_rx_ring_count(struct net_device *dev)
{
	struct mlx4_en_priv *priv = netdev_priv(dev);

	return priv->rx_ring_num;
}

static int mlx4_en_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd,
			     u32 *rule_locs)
{
@@ -1743,9 +1750,6 @@ static int mlx4_en_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd,
		return -EINVAL;

	switch (cmd->cmd) {
	case ETHTOOL_GRXRINGS:
		cmd->data = priv->rx_ring_num;
		break;
	case ETHTOOL_GRXCLSRLCNT:
		cmd->rule_cnt = mlx4_en_get_num_flows(priv);
		break;
@@ -2154,6 +2158,7 @@ const struct ethtool_ops mlx4_en_ethtool_ops = {
	.set_ringparam = mlx4_en_set_ringparam,
	.get_rxnfc = mlx4_en_get_rxnfc,
	.set_rxnfc = mlx4_en_set_rxnfc,
	.get_rx_ring_count = mlx4_en_get_rx_ring_count,
	.get_rxfh_indir_size = mlx4_en_get_rxfh_indir_size,
	.get_rxfh_key_size = mlx4_en_get_rxfh_key_size,
	.get_rxfh = mlx4_en_get_rxfh,
+8 −10
Original line number Diff line number Diff line
@@ -2492,21 +2492,18 @@ static int mlx5e_set_rxfh_fields(struct net_device *dev,
	return mlx5e_ethtool_set_rxfh_fields(priv, cmd, extack);
}

static int mlx5e_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info,
			   u32 *rule_locs)
static u32 mlx5e_get_rx_ring_count(struct net_device *dev)
{
	struct mlx5e_priv *priv = netdev_priv(dev);

	/* ETHTOOL_GRXRINGS is needed by ethtool -x which is not part
	 * of rxnfc. We keep this logic out of mlx5e_ethtool_get_rxnfc,
	 * to avoid breaking "ethtool -x" when mlx5e_ethtool_get_rxnfc
	 * is compiled out via CONFIG_MLX5_EN_RXNFC=n.
	 */
	if (info->cmd == ETHTOOL_GRXRINGS) {
		info->data = priv->channels.params.num_channels;
		return 0;
	return priv->channels.params.num_channels;
}

static int mlx5e_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info,
			   u32 *rule_locs)
{
	struct mlx5e_priv *priv = netdev_priv(dev);

	return mlx5e_ethtool_get_rxnfc(priv, info, rule_locs);
}

@@ -2766,6 +2763,7 @@ const struct ethtool_ops mlx5e_ethtool_ops = {
	.remove_rxfh_context	= mlx5e_remove_rxfh_context,
	.get_rxnfc         = mlx5e_get_rxnfc,
	.set_rxnfc         = mlx5e_set_rxnfc,
	.get_rx_ring_count = mlx5e_get_rx_ring_count,
	.get_tunable       = mlx5e_get_tunable,
	.set_tunable       = mlx5e_set_tunable,
	.get_pause_stats   = mlx5e_get_pause_stats,
+8 −10
Original line number Diff line number Diff line
@@ -266,21 +266,18 @@ static int mlx5i_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd)
	return mlx5e_ethtool_set_rxnfc(priv, cmd);
}

static int mlx5i_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info,
			   u32 *rule_locs)
static u32 mlx5i_get_rx_ring_count(struct net_device *dev)
{
	struct mlx5e_priv *priv = mlx5i_epriv(dev);

	/* ETHTOOL_GRXRINGS is needed by ethtool -x which is not part
	 * of rxnfc. We keep this logic out of mlx5e_ethtool_get_rxnfc,
	 * to avoid breaking "ethtool -x" when mlx5e_ethtool_get_rxnfc
	 * is compiled out via CONFIG_MLX5_EN_RXNFC=n.
	 */
	if (info->cmd == ETHTOOL_GRXRINGS) {
		info->data = priv->channels.params.num_channels;
		return 0;
	return priv->channels.params.num_channels;
}

static int mlx5i_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info,
			   u32 *rule_locs)
{
	struct mlx5e_priv *priv = mlx5i_epriv(dev);

	return mlx5e_ethtool_get_rxnfc(priv, info, rule_locs);
}

@@ -304,6 +301,7 @@ const struct ethtool_ops mlx5i_ethtool_ops = {
	.set_rxfh_fields    = mlx5i_set_rxfh_fields,
	.get_rxnfc          = mlx5i_get_rxnfc,
	.set_rxnfc          = mlx5i_set_rxnfc,
	.get_rx_ring_count  = mlx5i_get_rx_ring_count,
	.get_link_ksettings = mlx5i_get_link_ksettings,
	.get_link           = ethtool_op_get_link,
};