Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tg3: extract GRXRINGS from .get_rxnfc

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>

authored by

Breno Leitao and committed by
Jakub Kicinski
c04956cc 380e6f3c

+6 -18
+6 -18
drivers/net/ethernet/broadcom/tg3.c
··· 12719 12719 } 12720 12720 } 12721 12721 12722 - static int tg3_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info, 12723 - u32 *rules __always_unused) 12722 + static u32 tg3_get_rx_ring_count(struct net_device *dev) 12724 12723 { 12725 12724 struct tg3 *tp = netdev_priv(dev); 12726 12725 12727 12726 if (!tg3_flag(tp, SUPPORT_MSIX)) 12728 - return -EOPNOTSUPP; 12727 + return 1; 12729 12728 12730 - switch (info->cmd) { 12731 - case ETHTOOL_GRXRINGS: 12732 - if (netif_running(tp->dev)) 12733 - info->data = tp->rxq_cnt; 12734 - else { 12735 - info->data = num_online_cpus(); 12736 - if (info->data > TG3_RSS_MAX_NUM_QS) 12737 - info->data = TG3_RSS_MAX_NUM_QS; 12738 - } 12729 + if (netif_running(tp->dev)) 12730 + return tp->rxq_cnt; 12739 12731 12740 - return 0; 12741 - 12742 - default: 12743 - return -EOPNOTSUPP; 12744 - } 12732 + return min(num_online_cpus(), TG3_RSS_MAX_NUM_QS); 12745 12733 } 12746 12734 12747 12735 static u32 tg3_get_rxfh_indir_size(struct net_device *dev) ··· 14256 14268 .get_coalesce = tg3_get_coalesce, 14257 14269 .set_coalesce = tg3_set_coalesce, 14258 14270 .get_sset_count = tg3_get_sset_count, 14259 - .get_rxnfc = tg3_get_rxnfc, 14271 + .get_rx_ring_count = tg3_get_rx_ring_count, 14260 14272 .get_rxfh_indir_size = tg3_get_rxfh_indir_size, 14261 14273 .get_rxfh = tg3_get_rxfh, 14262 14274 .set_rxfh = tg3_set_rxfh,