Skip to contentSkip to conversation

vmxnet3: Implement ethtool's get_channels command

PATCH Applied Andrey Turkin 2 participants 2 messages Jul 19, 2022 – Jul 20, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 vmxnet3: Implement ethtool's get_channels command

Some tools (e.g. libxdp) use that information.

---

Notes:
v2:
- Replaced #ifdef with IS_ENABLED
- Fixed a compilation warning
v3:
- Removed explicit 0 assignments of unused fields.

 drivers/net/vmxnet3/vmxnet3_ethtool.c | 29 +++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
drivers/net/vmxnet3/vmxnet3_ethtool.c +29 -0
index 3172d46c0335..f2cbf502b76b 100644
@@ -1188,6 +1188,34 @@ static int vmxnet3_set_coalesce(struct net_device *netdev,
 	return 0;
 }
 
+static void vmxnet3_get_channels(struct net_device *netdev,
+				 struct ethtool_channels *ec)
+{
+	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
+
+	if (IS_ENABLED(CONFIG_PCI_MSI) && adapter->intr.type == VMXNET3_IT_MSIX) {
+		if (adapter->share_intr == VMXNET3_INTR_BUDDYSHARE) {
+			ec->combined_count = adapter->num_tx_queues;
+		} else {
+			ec->rx_count = adapter->num_rx_queues;
+			ec->tx_count =
+				adapter->share_intr == VMXNET3_INTR_TXSHARE ?
+					       1 : adapter->num_tx_queues;
+		}
+	} else {
+		ec->combined_count = 1;
+	}
+
+	ec->other_count = 1;
+
+	/* Number of interrupts cannot be changed on the fly */
+	/* Just set maximums to actual values */
+	ec->max_rx = ec->rx_count;
+	ec->max_tx = ec->tx_count;
+	ec->max_combined = ec->combined_count;
+	ec->max_other = ec->other_count;
+}
+
 static const struct ethtool_ops vmxnet3_ethtool_ops = {
 	.supported_coalesce_params = ETHTOOL_COALESCE_RX_USECS |
 				     ETHTOOL_COALESCE_MAX_FRAMES |
@@ -1213,6 +1241,7 @@ static const struct ethtool_ops vmxnet3_ethtool_ops = {
 	.set_rxfh          = vmxnet3_set_rss,
 #endif
 	.get_link_ksettings = vmxnet3_get_link_ksettings,
+	.get_channels      = vmxnet3_get_channels,
 };
 
 void vmxnet3_set_ethtool_ops(struct net_device *netdev)

base-commit: ca85855bdcae8f84f1512e88b4c75009ea17ea2f

Signature · 1 line
2.25.1
#1 lore raw
This patch was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:

Quoted 5 lines · On Tue, 19 Jul 2022 04:29:55 +0000 you wrote:

Some tools (e.g. libxdp) use that information.

---

Quoted 8 lines

Notes:
v2:
- Replaced #ifdef with IS_ENABLED
- Fixed a compilation warning
v3:
- Removed explicit 0 assignments of unused fields.

[...]

Here is the summary with links:
- [v3] vmxnet3: Implement ethtool's get_channels command

    https://git.kernel.org/netdev/net-next/c/ffcdd1197da6

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html