Commit a8080c2f authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'net-intel-migrate-to-get_rx_ring_count-ethtool-callback'

Breno Leitao says:

====================
net: intel: migrate to .get_rx_ring_count() ethtool callback

This series migrates Intel network drivers to use the new .get_rx_ring_count()
ethtool callback introduced in commit 84eaf435 ("net: ethtool: add
get_rx_ring_count callback to optimize RX ring queries").

The new callback simplifies the .get_rxnfc() implementation by removing
ETHTOOL_GRXRINGS handling and moving it to a dedicated callback. This provides
a cleaner separation of concerns and aligns these drivers with the modern
ethtool API.

The series updates the following Intel drivers:
  - idpf
  - igb
  - igc
  - ixgbevf
  - fm10k
====================

Link: https://patch.msgid.link/20251125-gxring_intel-v2-0-f55cd022d28b@debian.org


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 4585847f 73d834cd
Loading
Loading
Loading
Loading
+3 −14
Original line number Diff line number Diff line
@@ -734,22 +734,11 @@ static int fm10k_get_rssh_fields(struct net_device *dev,
	return 0;
}

static int fm10k_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd,
			   u32 __always_unused *rule_locs)
static u32 fm10k_get_rx_ring_count(struct net_device *dev)
{
	struct fm10k_intfc *interface = netdev_priv(dev);
	int ret = -EOPNOTSUPP;

	switch (cmd->cmd) {
	case ETHTOOL_GRXRINGS:
		cmd->data = interface->num_rx_queues;
		ret = 0;
		break;
	default:
		break;
	}

	return ret;
	return interface->num_rx_queues;
}

static int fm10k_set_rssh_fields(struct net_device *dev,
@@ -1160,7 +1149,7 @@ static const struct ethtool_ops fm10k_ethtool_ops = {
	.set_ringparam		= fm10k_set_ringparam,
	.get_coalesce		= fm10k_get_coalesce,
	.set_coalesce		= fm10k_set_coalesce,
	.get_rxnfc		= fm10k_get_rxnfc,
	.get_rx_ring_count	= fm10k_get_rx_ring_count,
	.get_regs               = fm10k_get_regs,
	.get_regs_len           = fm10k_get_regs_len,
	.self_test		= fm10k_self_test,
+15 −4
Original line number Diff line number Diff line
@@ -3521,6 +3521,20 @@ static int i40e_get_ethtool_fdir_entry(struct i40e_pf *pf,
	return 0;
}

/**
 * i40e_get_rx_ring_count - get RX ring count
 * @netdev: network interface device structure
 *
 * Return: number of RX rings.
 **/
static u32 i40e_get_rx_ring_count(struct net_device *netdev)
{
	struct i40e_netdev_priv *np = netdev_priv(netdev);
	struct i40e_vsi *vsi = np->vsi;

	return vsi->rss_size;
}

/**
 * i40e_get_rxnfc - command to get RX flow classification rules
 * @netdev: network interface device structure
@@ -3538,10 +3552,6 @@ static int i40e_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,
	int ret = -EOPNOTSUPP;

	switch (cmd->cmd) {
	case ETHTOOL_GRXRINGS:
		cmd->data = vsi->rss_size;
		ret = 0;
		break;
	case ETHTOOL_GRXCLSRLCNT:
		cmd->rule_cnt = pf->fdir_pf_active_filters;
		/* report total rule count */
@@ -5819,6 +5829,7 @@ static const struct ethtool_ops i40e_ethtool_ops = {
	.set_msglevel		= i40e_set_msglevel,
	.get_rxnfc		= i40e_get_rxnfc,
	.set_rxnfc		= i40e_set_rxnfc,
	.get_rx_ring_count	= i40e_get_rx_ring_count,
	.self_test		= i40e_diag_test,
	.get_strings		= i40e_get_strings,
	.get_eee		= i40e_get_eee,
+14 −4
Original line number Diff line number Diff line
@@ -1638,6 +1638,19 @@ static int iavf_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
	return ret;
}

/**
 * iavf_get_rx_ring_count - get RX ring count
 * @netdev: network interface device structure
 *
 * Return: number of RX rings.
 **/
static u32 iavf_get_rx_ring_count(struct net_device *netdev)
{
	struct iavf_adapter *adapter = netdev_priv(netdev);

	return adapter->num_active_queues;
}

/**
 * iavf_get_rxnfc - command to get RX flow classification rules
 * @netdev: network interface device structure
@@ -1653,10 +1666,6 @@ static int iavf_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,
	int ret = -EOPNOTSUPP;

	switch (cmd->cmd) {
	case ETHTOOL_GRXRINGS:
		cmd->data = adapter->num_active_queues;
		ret = 0;
		break;
	case ETHTOOL_GRXCLSRLCNT:
		if (!(adapter->flags & IAVF_FLAG_FDIR_ENABLED))
			break;
@@ -1866,6 +1875,7 @@ static const struct ethtool_ops iavf_ethtool_ops = {
	.set_per_queue_coalesce = iavf_set_per_queue_coalesce,
	.set_rxnfc		= iavf_set_rxnfc,
	.get_rxnfc		= iavf_get_rxnfc,
	.get_rx_ring_count	= iavf_get_rx_ring_count,
	.get_rxfh_indir_size	= iavf_get_rxfh_indir_size,
	.get_rxfh		= iavf_get_rxfh,
	.set_rxfh		= iavf_set_rxfh,
+15 −4
Original line number Diff line number Diff line
@@ -3083,6 +3083,20 @@ static int ice_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
	return -EOPNOTSUPP;
}

/**
 * ice_get_rx_ring_count - get RX ring count
 * @netdev: network interface device structure
 *
 * Return: number of RX rings.
 */
static u32 ice_get_rx_ring_count(struct net_device *netdev)
{
	struct ice_netdev_priv *np = netdev_priv(netdev);
	struct ice_vsi *vsi = np->vsi;

	return vsi->rss_size;
}

/**
 * ice_get_rxnfc - command to get Rx flow classification rules
 * @netdev: network interface device structure
@@ -3103,10 +3117,6 @@ ice_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,
	hw = &vsi->back->hw;

	switch (cmd->cmd) {
	case ETHTOOL_GRXRINGS:
		cmd->data = vsi->rss_size;
		ret = 0;
		break;
	case ETHTOOL_GRXCLSRLCNT:
		cmd->rule_cnt = hw->fdir_active_fltr;
		/* report total rule count */
@@ -4853,6 +4863,7 @@ static const struct ethtool_ops ice_ethtool_ops = {
	.get_sset_count		= ice_get_sset_count,
	.get_rxnfc		= ice_get_rxnfc,
	.set_rxnfc		= ice_set_rxnfc,
	.get_rx_ring_count	= ice_get_rx_ring_count,
	.get_ringparam		= ice_get_ringparam,
	.set_ringparam		= ice_set_ringparam,
	.nway_reset		= ice_nway_reset,
+20 −3
Original line number Diff line number Diff line
@@ -5,6 +5,25 @@
#include "idpf_ptp.h"
#include "idpf_virtchnl.h"

/**
 * idpf_get_rx_ring_count - get RX ring count
 * @netdev: network interface device structure
 *
 * Return: number of RX rings.
 */
static u32 idpf_get_rx_ring_count(struct net_device *netdev)
{
	struct idpf_vport *vport;
	u32 num_rxq;

	idpf_vport_ctrl_lock(netdev);
	vport = idpf_netdev_to_vport(netdev);
	num_rxq = vport->num_rxq;
	idpf_vport_ctrl_unlock(netdev);

	return num_rxq;
}

/**
 * idpf_get_rxnfc - command to get RX flow classification rules
 * @netdev: network interface device structure
@@ -28,9 +47,6 @@ static int idpf_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,
	user_config = &np->adapter->vport_config[np->vport_idx]->user_config;

	switch (cmd->cmd) {
	case ETHTOOL_GRXRINGS:
		cmd->data = vport->num_rxq;
		break;
	case ETHTOOL_GRXCLSRLCNT:
		cmd->rule_cnt = user_config->num_fsteer_fltrs;
		cmd->data = idpf_fsteer_max_rules(vport);
@@ -1757,6 +1773,7 @@ static const struct ethtool_ops idpf_ethtool_ops = {
	.get_channels		= idpf_get_channels,
	.get_rxnfc		= idpf_get_rxnfc,
	.set_rxnfc		= idpf_set_rxnfc,
	.get_rx_ring_count	= idpf_get_rx_ring_count,
	.get_rxfh_key_size	= idpf_get_rxfh_key_size,
	.get_rxfh_indir_size	= idpf_get_rxfh_indir_size,
	.get_rxfh		= idpf_get_rxfh,
Loading