All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] vmxnet3: Implement ethtool's get_channels command
@ 2022-07-18  4:51 Andrey Turkin
  2022-07-18 21:57 ` Andrew Lunn
  2022-07-18 22:07 ` Jakub Kicinski
  0 siblings, 2 replies; 3+ messages in thread
From: Andrey Turkin @ 2022-07-18  4:51 UTC (permalink / raw)
  To: netdev; +Cc: Ronak Doshi, VMware PV-Drivers Reviewers, Andrey Turkin

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

Signed-off-by: Andrey Turkin <andrey.turkin@gmail.com>
---
 drivers/net/vmxnet3/vmxnet3_ethtool.c | 34 +++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/drivers/net/vmxnet3/vmxnet3_ethtool.c b/drivers/net/vmxnet3/vmxnet3_ethtool.c
index 3172d46c0335..cb1caff93367 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethtool.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethtool.c
@@ -1188,6 +1188,39 @@ 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;
+			ec->rx_count = 0;
+			ec->tx_count = 0;
+		} else {
+			ec->combined_count = 0;
+			ec->rx_count = adapter->num_rx_queues;
+			ec->tx_count =
+				adapter->share_intr == VMXNET3_INTR_TXSHARE ?
+					       1 : adapter->num_tx_queues;
+		}
+	} else {
+		ec->rx_count = 0;
+		ec->tx_count = 0;
+		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 +1246,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: ff6992735ade75aae3e35d16b17da1008d753d28
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] vmxnet3: Implement ethtool's get_channels command
  2022-07-18  4:51 [PATCH v2] vmxnet3: Implement ethtool's get_channels command Andrey Turkin
@ 2022-07-18 21:57 ` Andrew Lunn
  2022-07-18 22:07 ` Jakub Kicinski
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2022-07-18 21:57 UTC (permalink / raw)
  To: Andrey Turkin; +Cc: netdev, Ronak Doshi, VMware PV-Drivers Reviewers

On Mon, Jul 18, 2022 at 04:51:10AM +0000, Andrey Turkin wrote:
> Some tools (e.g. libxdp) use that information.
> 
> Signed-off-by: Andrey Turkin <andrey.turkin@gmail.com>

This looks nice. For code style:

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] vmxnet3: Implement ethtool's get_channels command
  2022-07-18  4:51 [PATCH v2] vmxnet3: Implement ethtool's get_channels command Andrey Turkin
  2022-07-18 21:57 ` Andrew Lunn
@ 2022-07-18 22:07 ` Jakub Kicinski
  1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2022-07-18 22:07 UTC (permalink / raw)
  To: Andrey Turkin; +Cc: netdev, Ronak Doshi, VMware PV-Drivers Reviewers

On Mon, 18 Jul 2022 04:51:10 +0000 Andrey Turkin wrote:
> +	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;
> +			ec->rx_count = 0;
> +			ec->tx_count = 0;
> +		} else {
> +			ec->combined_count = 0;
> +			ec->rx_count = adapter->num_rx_queues;
> +			ec->tx_count =
> +				adapter->share_intr == VMXNET3_INTR_TXSHARE ?
> +					       1 : adapter->num_tx_queues;
> +		}
> +	} else {
> +		ec->rx_count = 0;
> +		ec->tx_count = 0;
> +		ec->combined_count = 1;

No need to set the unused counts to 0.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-07-18 22:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-18  4:51 [PATCH v2] vmxnet3: Implement ethtool's get_channels command Andrey Turkin
2022-07-18 21:57 ` Andrew Lunn
2022-07-18 22:07 ` Jakub Kicinski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.