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

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

Breno Leitao says:

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

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.
  * hns3
  * hns
  * qede
  * niu
  * funeth
  * enic
  * hinic
  * octeontx2

PS: all of these change were compile-tested only.
====================

Link: https://patch.msgid.link/20260109-grxring_big_v1-v1-0-a0f77f732006@debian.org


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 959728f9 cf8c4e1f
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -573,6 +573,13 @@ static int enic_get_rx_flow_hash(struct net_device *dev,
	return 0;
}

static u32 enic_get_rx_ring_count(struct net_device *dev)
{
	struct enic *enic = netdev_priv(dev);

	return enic->rq_count;
}

static int enic_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd,
			  u32 *rule_locs)
{
@@ -580,9 +587,6 @@ static int enic_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd,
	int ret = 0;

	switch (cmd->cmd) {
	case ETHTOOL_GRXRINGS:
		cmd->data = enic->rq_count;
		break;
	case ETHTOOL_GRXCLSRLCNT:
		spin_lock_bh(&enic->rfs_h.lock);
		cmd->rule_cnt = enic->rfs_h.max - enic->rfs_h.free;
@@ -689,6 +693,7 @@ static const struct ethtool_ops enic_ethtool_ops = {
	.get_coalesce = enic_get_coalesce,
	.set_coalesce = enic_set_coalesce,
	.get_rxnfc = enic_get_rxnfc,
	.get_rx_ring_count = enic_get_rx_ring_count,
	.get_rxfh_key_size = enic_get_rxfh_key_size,
	.get_rxfh = enic_get_rxfh,
	.set_rxfh = enic_set_rxfh,
+3 −11
Original line number Diff line number Diff line
@@ -946,17 +946,9 @@ static void fun_get_fec_stats(struct net_device *netdev,
#undef TX_STAT
#undef FEC_STAT

static int fun_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,
			 u32 *rule_locs)
static u32 fun_get_rx_ring_count(struct net_device *netdev)
{
	switch (cmd->cmd) {
	case ETHTOOL_GRXRINGS:
		cmd->data = netdev->real_num_rx_queues;
		return 0;
	default:
		break;
	}
	return -EOPNOTSUPP;
	return netdev->real_num_rx_queues;
}

static int fun_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *info)
@@ -1169,8 +1161,8 @@ static const struct ethtool_ops fun_ethtool_ops = {
	.get_sset_count      = fun_get_sset_count,
	.get_strings         = fun_get_strings,
	.get_ethtool_stats   = fun_get_ethtool_stats,
	.get_rxnfc	     = fun_get_rxnfc,
	.set_rxnfc           = fun_set_rxnfc,
	.get_rx_ring_count   = fun_get_rx_ring_count,
	.get_rxfh_indir_size = fun_get_rxfh_indir_size,
	.get_rxfh_key_size   = fun_get_rxfh_key_size,
	.get_rxfh            = fun_get_rxfh,
+3 −13
Original line number Diff line number Diff line
@@ -1230,21 +1230,11 @@ hns_set_rss(struct net_device *netdev, struct ethtool_rxfh_param *rxfh,
			    rxfh->indir, rxfh->key, rxfh->hfunc);
}

static int hns_get_rxnfc(struct net_device *netdev,
			 struct ethtool_rxnfc *cmd,
			 u32 *rule_locs)
static u32 hns_get_rx_ring_count(struct net_device *netdev)
{
	struct hns_nic_priv *priv = netdev_priv(netdev);

	switch (cmd->cmd) {
	case ETHTOOL_GRXRINGS:
		cmd->data = priv->ae_handle->q_num;
		break;
	default:
		return -EOPNOTSUPP;
	}

	return 0;
	return priv->ae_handle->q_num;
}

static const struct ethtool_ops hns_ethtool_ops = {
@@ -1273,7 +1263,7 @@ static const struct ethtool_ops hns_ethtool_ops = {
	.get_rxfh_indir_size = hns_get_rss_indir_size,
	.get_rxfh = hns_get_rss,
	.set_rxfh = hns_set_rss,
	.get_rxnfc = hns_get_rxnfc,
	.get_rx_ring_count = hns_get_rx_ring_count,
	.get_link_ksettings  = hns_nic_get_link_ksettings,
	.set_link_ksettings  = hns_nic_set_link_ksettings,
};
+9 −3
Original line number Diff line number Diff line
@@ -988,6 +988,13 @@ static int hns3_get_rxfh_fields(struct net_device *netdev,
	return -EOPNOTSUPP;
}

static u32 hns3_get_rx_ring_count(struct net_device *netdev)
{
	struct hnae3_handle *h = hns3_get_handle(netdev);

	return h->kinfo.num_tqps;
}

static int hns3_get_rxnfc(struct net_device *netdev,
			  struct ethtool_rxnfc *cmd,
			  u32 *rule_locs)
@@ -995,9 +1002,6 @@ static int hns3_get_rxnfc(struct net_device *netdev,
	struct hnae3_handle *h = hns3_get_handle(netdev);

	switch (cmd->cmd) {
	case ETHTOOL_GRXRINGS:
		cmd->data = h->kinfo.num_tqps;
		return 0;
	case ETHTOOL_GRXCLSRLCNT:
		if (h->ae_algo->ops->get_fd_rule_cnt)
			return h->ae_algo->ops->get_fd_rule_cnt(h, cmd);
@@ -2148,6 +2152,7 @@ static const struct ethtool_ops hns3vf_ethtool_ops = {
	.get_sset_count = hns3_get_sset_count,
	.get_rxnfc = hns3_get_rxnfc,
	.set_rxnfc = hns3_set_rxnfc,
	.get_rx_ring_count = hns3_get_rx_ring_count,
	.get_rxfh_key_size = hns3_get_rss_key_size,
	.get_rxfh_indir_size = hns3_get_rss_indir_size,
	.get_rxfh = hns3_get_rss,
@@ -2187,6 +2192,7 @@ static const struct ethtool_ops hns3_ethtool_ops = {
	.get_sset_count = hns3_get_sset_count,
	.get_rxnfc = hns3_get_rxnfc,
	.set_rxnfc = hns3_set_rxnfc,
	.get_rx_ring_count = hns3_get_rx_ring_count,
	.get_rxfh_key_size = hns3_get_rss_key_size,
	.get_rxfh_indir_size = hns3_get_rss_indir_size,
	.get_rxfh = hns3_get_rss,
+4 −15
Original line number Diff line number Diff line
@@ -1101,22 +1101,11 @@ static int __set_rss_rxfh(struct net_device *netdev,
	return 0;
}

static int hinic_get_rxnfc(struct net_device *netdev,
			   struct ethtool_rxnfc *cmd, u32 *rule_locs)
static u32 hinic_get_rx_ring_count(struct net_device *netdev)
{
	struct hinic_dev *nic_dev = netdev_priv(netdev);
	int err = 0;

	switch (cmd->cmd) {
	case ETHTOOL_GRXRINGS:
		cmd->data = nic_dev->num_qps;
		break;
	default:
		err = -EOPNOTSUPP;
		break;
	}

	return err;
	return nic_dev->num_qps;
}

static int hinic_get_rxfh(struct net_device *netdev,
@@ -1779,7 +1768,7 @@ static const struct ethtool_ops hinic_ethtool_ops = {
	.set_pauseparam = hinic_set_pauseparam,
	.get_channels = hinic_get_channels,
	.set_channels = hinic_set_channels,
	.get_rxnfc = hinic_get_rxnfc,
	.get_rx_ring_count = hinic_get_rx_ring_count,
	.get_rxfh_key_size = hinic_get_rxfh_key_size,
	.get_rxfh_indir_size = hinic_get_rxfh_indir_size,
	.get_rxfh = hinic_get_rxfh,
@@ -1812,7 +1801,7 @@ static const struct ethtool_ops hinicvf_ethtool_ops = {
	.set_per_queue_coalesce = hinic_set_per_queue_coalesce,
	.get_channels = hinic_get_channels,
	.set_channels = hinic_set_channels,
	.get_rxnfc = hinic_get_rxnfc,
	.get_rx_ring_count = hinic_get_rx_ring_count,
	.get_rxfh_key_size = hinic_get_rxfh_key_size,
	.get_rxfh_indir_size = hinic_get_rxfh_indir_size,
	.get_rxfh = hinic_get_rxfh,
Loading