Commit 8811df1d authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'net-convert-drivers-to-get_rx_ring_count-last-part'

Breno Leitao says:

====================
net: convert drivers to .get_rx_ring_count (last part)

Commit 84eaf435 ("net: ethtool: add get_rx_ring_count callback to
optimize RX ring queries") added specific support for GRXRINGS callback,
simplifying .get_rxnfc.

Remove the handling of GRXRINGS in .get_rxnfc() by moving it to the new
.get_rx_ring_count().

This simplifies the RX ring count retrieval and aligns the following
drivers with the new ethtool API for querying RX ring parameters.

 * sfc
 * ionic
 * sfc/siena
 * sfc/ef100
 * fbnic
 * mana
 * nfp
 * atlantic
 * benet (this is v2 in fact, where v1 had some discussions that
   required a v2). See link [0]

Link: https://lore.kernel.org/all/20260119094514.5b12a097@kernel.org/ [0]

This is covering the last drivers, and as soon as this lands, I will
change the ethtool framework to avoid calling .get_rx_ring_count for
ETHTOOL_GRXRINGS, simplifying the ethtool core framework.
====================

Link: https://patch.msgid.link/20260122-grxring_big_v4-v2-0-94dbe4dcaa10@debian.org


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 1685e177 f584347c
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -500,20 +500,25 @@ static int aq_ethtool_set_rss(struct net_device *netdev,
	return err;
}

static u32 aq_ethtool_get_rx_ring_count(struct net_device *ndev)
{
	struct aq_nic_cfg_s *cfg;
	struct aq_nic_s *aq_nic;

	aq_nic = netdev_priv(ndev);
	cfg = aq_nic_get_cfg(aq_nic);

	return cfg->vecs;
}

static int aq_ethtool_get_rxnfc(struct net_device *ndev,
				struct ethtool_rxnfc *cmd,
				u32 *rule_locs)
{
	struct aq_nic_s *aq_nic = netdev_priv(ndev);
	struct aq_nic_cfg_s *cfg;
	int err = 0;

	cfg = aq_nic_get_cfg(aq_nic);

	switch (cmd->cmd) {
	case ETHTOOL_GRXRINGS:
		cmd->data = cfg->vecs;
		break;
	case ETHTOOL_GRXCLSRLCNT:
		cmd->rule_cnt = aq_get_rxnfc_count_all_rules(aq_nic);
		break;
@@ -1072,6 +1077,7 @@ const struct ethtool_ops aq_ethtool_ops = {
	.set_rxfh            = aq_ethtool_set_rss,
	.get_rxnfc           = aq_ethtool_get_rxnfc,
	.set_rxnfc           = aq_ethtool_set_rxnfc,
	.get_rx_ring_count   = aq_ethtool_get_rx_ring_count,
	.get_msglevel        = aq_get_msg_level,
	.set_msglevel        = aq_set_msg_level,
	.get_sset_count      = aq_ethtool_get_sset_count,
+14 −23
Original line number Diff line number Diff line
@@ -1073,6 +1073,13 @@ static void be_set_msg_level(struct net_device *netdev, u32 level)
	adapter->msg_enable = level;
}

static u32 be_get_rx_ring_count(struct net_device *netdev)
{
	struct be_adapter *adapter = netdev_priv(netdev);

	return adapter->num_rx_qs;
}

static int be_get_rxfh_fields(struct net_device *netdev,
			      struct ethtool_rxfh_fields *cmd)
{
@@ -1117,28 +1124,6 @@ static int be_get_rxfh_fields(struct net_device *netdev,
	return 0;
}

static int be_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,
			u32 *rule_locs)
{
	struct be_adapter *adapter = netdev_priv(netdev);

	if (!be_multi_rxq(adapter)) {
		dev_info(&adapter->pdev->dev,
			 "ethtool::get_rxnfc: RX flow hashing is disabled\n");
		return -EINVAL;
	}

	switch (cmd->cmd) {
	case ETHTOOL_GRXRINGS:
		cmd->data = adapter->num_rx_qs;
		break;
	default:
		return -EINVAL;
	}

	return 0;
}

static int be_set_rxfh_fields(struct net_device *netdev,
			      const struct ethtool_rxfh_fields *cmd,
			      struct netlink_ext_ack *extack)
@@ -1293,6 +1278,12 @@ static int be_set_rxfh(struct net_device *netdev,
	u8 *hkey = rxfh->key;
	u8 rsstable[RSS_INDIR_TABLE_LEN];

	if (!be_multi_rxq(adapter)) {
		dev_info(&adapter->pdev->dev,
			 "ethtool::set_rxfh: RX flow hashing is disabled\n");
		return -EINVAL;
	}

	/* We do not allow change in unsupported parameters */
	if (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE &&
	    rxfh->hfunc != ETH_RSS_HASH_TOP)
@@ -1441,7 +1432,7 @@ const struct ethtool_ops be_ethtool_ops = {
	.get_ethtool_stats = be_get_ethtool_stats,
	.flash_device = be_do_flash,
	.self_test = be_self_test,
	.get_rxnfc = be_get_rxnfc,
	.get_rx_ring_count = be_get_rx_ring_count,
	.get_rxfh_fields = be_get_rxfh_fields,
	.set_rxfh_fields = be_set_rxfh_fields,
	.get_rxfh_indir_size = be_get_rxfh_indir_size,
+8 −4
Original line number Diff line number Diff line
@@ -825,6 +825,13 @@ static int fbnic_get_cls_rule(struct fbnic_net *fbn, struct ethtool_rxnfc *cmd)
	return 0;
}

static u32 fbnic_get_rx_ring_count(struct net_device *netdev)
{
	struct fbnic_net *fbn = netdev_priv(netdev);

	return fbn->num_rx_queues;
}

static int fbnic_get_rxnfc(struct net_device *netdev,
			   struct ethtool_rxnfc *cmd, u32 *rule_locs)
{
@@ -833,10 +840,6 @@ static int fbnic_get_rxnfc(struct net_device *netdev,
	u32 special = 0;

	switch (cmd->cmd) {
	case ETHTOOL_GRXRINGS:
		cmd->data = fbn->num_rx_queues;
		ret = 0;
		break;
	case ETHTOOL_GRXCLSRULE:
		ret = fbnic_get_cls_rule(fbn, cmd);
		break;
@@ -1895,6 +1898,7 @@ static const struct ethtool_ops fbnic_ethtool_ops = {
	.get_sset_count			= fbnic_get_sset_count,
	.get_rxnfc			= fbnic_get_rxnfc,
	.set_rxnfc			= fbnic_set_rxnfc,
	.get_rx_ring_count		= fbnic_get_rx_ring_count,
	.get_rxfh_key_size		= fbnic_get_rxfh_key_size,
	.get_rxfh_indir_size		= fbnic_get_rxfh_indir_size,
	.get_rxfh			= fbnic_get_rxfh,
+3 −10
Original line number Diff line number Diff line
@@ -282,18 +282,11 @@ static void mana_get_ethtool_stats(struct net_device *ndev,
	}
}

static int mana_get_rxnfc(struct net_device *ndev, struct ethtool_rxnfc *cmd,
			  u32 *rules)
static u32 mana_get_rx_ring_count(struct net_device *ndev)
{
	struct mana_port_context *apc = netdev_priv(ndev);

	switch (cmd->cmd) {
	case ETHTOOL_GRXRINGS:
		cmd->data = apc->num_queues;
		return 0;
	}

	return -EOPNOTSUPP;
	return apc->num_queues;
}

static u32 mana_get_rxfh_key_size(struct net_device *ndev)
@@ -520,7 +513,7 @@ const struct ethtool_ops mana_ethtool_ops = {
	.get_ethtool_stats	= mana_get_ethtool_stats,
	.get_sset_count		= mana_get_sset_count,
	.get_strings		= mana_get_strings,
	.get_rxnfc		= mana_get_rxnfc,
	.get_rx_ring_count	= mana_get_rx_ring_count,
	.get_rxfh_key_size	= mana_get_rxfh_key_size,
	.get_rxfh_indir_size	= mana_rss_indir_size,
	.get_rxfh		= mana_get_rxfh,
+8 −3
Original line number Diff line number Diff line
@@ -1435,15 +1435,19 @@ static int nfp_net_get_fs_loc(struct nfp_net *nn, u32 *rule_locs)
	return 0;
}

static u32 nfp_net_get_rx_ring_count(struct net_device *netdev)
{
	struct nfp_net *nn = netdev_priv(netdev);

	return nn->dp.num_rx_rings;
}

static int nfp_net_get_rxnfc(struct net_device *netdev,
			     struct ethtool_rxnfc *cmd, u32 *rule_locs)
{
	struct nfp_net *nn = netdev_priv(netdev);

	switch (cmd->cmd) {
	case ETHTOOL_GRXRINGS:
		cmd->data = nn->dp.num_rx_rings;
		return 0;
	case ETHTOOL_GRXCLSRLCNT:
		cmd->rule_cnt = nn->fs.count;
		return 0;
@@ -2501,6 +2505,7 @@ static const struct ethtool_ops nfp_net_ethtool_ops = {
	.get_sset_count		= nfp_net_get_sset_count,
	.get_rxnfc		= nfp_net_get_rxnfc,
	.set_rxnfc		= nfp_net_set_rxnfc,
	.get_rx_ring_count	= nfp_net_get_rx_ring_count,
	.get_rxfh_indir_size	= nfp_net_get_rxfh_indir_size,
	.get_rxfh_key_size	= nfp_net_get_rxfh_key_size,
	.get_rxfh		= nfp_net_get_rxfh,
Loading