]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tg3: extract GRXRINGS from .get_rxnfc
authorBreno Leitao <leitao@debian.org>
Wed, 5 Nov 2025 18:01:12 +0000 (10:01 -0800)
committerJakub Kicinski <kuba@kernel.org>
Thu, 6 Nov 2025 22:26:35 +0000 (14:26 -0800)
Commit 84eaf4359c36 ("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().

Given that tg3_get_rxnfc() only handles ETHTOOL_GRXRINGS, then this
function becomes useless now, and it is removed.

This also fixes the behavior for devices without MSIX support.
Previously, the function would return -EOPNOTSUPP, but now it correctly
returns 1.

The functionality remains the same: return the current queue count
if the device is running, otherwise return the minimum of online
CPUs and TG3_RSS_MAX_NUM_QS.

Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Michael Chan <michael.chan@broadcom.com>
Link: https://patch.msgid.link/20251105-grxrings_v1-v1-1-54c2caafa1fd@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/broadcom/tg3.c

index d78cafdb20949cd18c8070d72f6c4c8f2e827c20..fa58c3ffceb06f68fe13030ced3a2c5f4be5df70 100644 (file)
@@ -12719,29 +12719,17 @@ static int tg3_get_sset_count(struct net_device *dev, int sset)
        }
 }
 
-static int tg3_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info,
-                        u32 *rules __always_unused)
+static u32 tg3_get_rx_ring_count(struct net_device *dev)
 {
        struct tg3 *tp = netdev_priv(dev);
 
        if (!tg3_flag(tp, SUPPORT_MSIX))
-               return -EOPNOTSUPP;
+               return 1;
 
-       switch (info->cmd) {
-       case ETHTOOL_GRXRINGS:
-               if (netif_running(tp->dev))
-                       info->data = tp->rxq_cnt;
-               else {
-                       info->data = num_online_cpus();
-                       if (info->data > TG3_RSS_MAX_NUM_QS)
-                               info->data = TG3_RSS_MAX_NUM_QS;
-               }
+       if (netif_running(tp->dev))
+               return tp->rxq_cnt;
 
-               return 0;
-
-       default:
-               return -EOPNOTSUPP;
-       }
+       return min(num_online_cpus(), TG3_RSS_MAX_NUM_QS);
 }
 
 static u32 tg3_get_rxfh_indir_size(struct net_device *dev)
@@ -14268,7 +14256,7 @@ static const struct ethtool_ops tg3_ethtool_ops = {
        .get_coalesce           = tg3_get_coalesce,
        .set_coalesce           = tg3_set_coalesce,
        .get_sset_count         = tg3_get_sset_count,
-       .get_rxnfc              = tg3_get_rxnfc,
+       .get_rx_ring_count      = tg3_get_rx_ring_count,
        .get_rxfh_indir_size    = tg3_get_rxfh_indir_size,
        .get_rxfh               = tg3_get_rxfh,
        .set_rxfh               = tg3_set_rxfh,