Commit 8f2a880d authored by Breno Leitao's avatar Breno Leitao Committed by Jakub Kicinski
Browse files

net: benet: convert to use .get_rx_ring_count



Use the newly introduced .get_rx_ring_count ethtool ops callback instead
of handling ETHTOOL_GRXRINGS directly in .get_rxnfc().

Since ETHTOOL_GRXRINGS was the only command handled by be_get_rxnfc(),
remove the function entirely.

Since the be_multi_rxq() check in be_get_rxnfc() previously blocked RSS
configuration on single-queue setups (via ethtool core validation), add
an equivalent check to be_set_rxfh() to preserve this behavior, as
suggested by Jakub.

Signed-off-by: default avatarBreno Leitao <leitao@debian.org>
Reviewed-by: default avatarBrett Creeley <brett.creeley@amd.com>
Link: https://patch.msgid.link/20260122-grxring_big_v4-v2-1-94dbe4dcaa10@debian.org


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 1685e177
Loading
Loading
Loading
Loading
+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,