summaryrefslogtreecommitdiff
path: root/net/ethtool/common.c
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2025-09-18 07:07:41 -0700
committerJakub Kicinski <kuba@kernel.org>2025-09-18 07:07:42 -0700
commit1d9770838dcbe25151a319c1eae0c9879385b49f (patch)
treeadd56f8011569b3c9fa580f1f8c10a1e33d297a9 /net/ethtool/common.c
parent672beab06656f2f1bda4708cda2b9af61c58a7ea (diff)
parent483446690a625c325149c6d14283b9782aaefffe (diff)
Merge branch 'net-ethtool-add-dedicated-grxrings-driver-callbacks'
Breno Leitao says: ==================== net: ethtool: add dedicated GRXRINGS driver callbacks This patchset introduces a new dedicated ethtool_ops callback, .get_rx_ring_count, which enables drivers to provide the number of RX rings directly, improving efficiency and clarity in RX ring queries and RSS configuration. Number of drivers implements .get_rxnfc callback just to report the ring count, so, having a proper callback makes sense and simplify .get_rxnfc (in some cases remove it completely). This has been suggested by Jakub, and follow the same idea as RXFH driver callbacks [1]. This also port virtio_net to this new callback. Once there is consensus on this approach, I can start moving the drivers to this new callback. Link: https://lore.kernel.org/all/20250611145949.2674086-1-kuba@kernel.org/ [1] v3: https://lore.kernel.org/20250915-gxrings-v3-0-bfd717dbcaad@debian.org v2: https://lore.kernel.org/20250912-gxrings-v2-0-3c7a60bbeebf@debian.org v1: https://lore.kernel.org/20250909-gxrings-v1-0-634282f06a54@debian.org RFC: https://lore.kernel.org/20250905-gxrings-v1-0-984fc471f28f@debian.org ==================== Link: https://patch.msgid.link/20250917-gxrings-v4-0-dae520e2e1cb@debian.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/ethtool/common.c')
-rw-r--r--net/ethtool/common.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/net/ethtool/common.c b/net/ethtool/common.c
index 4f58648a27ad..10460ea3717c 100644
--- a/net/ethtool/common.c
+++ b/net/ethtool/common.c
@@ -577,6 +577,26 @@ int __ethtool_get_link(struct net_device *dev)
return netif_running(dev) && dev->ethtool_ops->get_link(dev);
}
+int ethtool_get_rx_ring_count(struct net_device *dev)
+{
+ const struct ethtool_ops *ops = dev->ethtool_ops;
+ struct ethtool_rxnfc rx_rings = {};
+ int ret;
+
+ if (ops->get_rx_ring_count)
+ return ops->get_rx_ring_count(dev);
+
+ if (!ops->get_rxnfc)
+ return -EOPNOTSUPP;
+
+ rx_rings.cmd = ETHTOOL_GRXRINGS;
+ ret = ops->get_rxnfc(dev, &rx_rings, NULL);
+ if (ret < 0)
+ return ret;
+
+ return rx_rings.data;
+}
+
static int ethtool_get_rxnfc_rule_count(struct net_device *dev)
{
const struct ethtool_ops *ops = dev->ethtool_ops;