netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] Add ethtool -g support to virtio_net
@ 2011-10-19 18:10 Rick Jones
  2011-10-20  7:55 ` Rusty Russell
  0 siblings, 1 reply; 6+ messages in thread
From: Rick Jones @ 2011-10-19 18:10 UTC (permalink / raw)
  To: netdev, rusty, mst, virtualization

From: Rick Jones <rick.jones2@hp.com>

Add support for reporting ring sizes via ethtool -g to the virtio_net
driver.

Signed-off-by: Rick Jones <rick.jones2@hp.com>

---

Tested briefly in a single guest:

raj@raj-ubuntu-guest:~$ ethtool -g eth0
Ring parameters for eth0:
Pre-set maximums:
RX:		256
RX Mini:	0
RX Jumbo:	0
TX:		256
Current hardware settings:
RX:		256
RX Mini:	0
RX Jumbo:	0
TX:		256


diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index b8225f3..3e642a4 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -880,8 +880,21 @@ static void virtnet_vlan_rx_kill_vid(struct net_device *dev, u16 vid)
 		dev_warn(&dev->dev, "Failed to kill VLAN ID %d.\n", vid);
 }
 
+static void virtnet_get_ringparam(struct net_device *dev,
+				struct ethtool_ringparam *ring)
+{
+	struct virtnet_info *vi = netdev_priv(dev);
+
+	ring->rx_max_pending = virtqueue_get_vring_size(vi->rvq);
+	ring->tx_max_pending = virtqueue_get_vring_size(vi->svq);
+	ring->rx_pending = ring->rx_max_pending;
+	ring->tx_pending = ring->tx_max_pending;
+
+}
+
 static const struct ethtool_ops virtnet_ethtool_ops = {
 	.get_link = ethtool_op_get_link,
+	.get_ringparam = virtnet_get_ringparam,
 };
 
 #define MIN_MTU 68
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 68b9136..4acf888 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -529,4 +529,14 @@ void vring_transport_features(struct virtio_device *vdev)
 }
 EXPORT_SYMBOL_GPL(vring_transport_features);
 
+/* return the size of the vring within the virtqueue */
+unsigned int virtqueue_get_vring_size(struct virtqueue *_vq)
+{
+
+	struct vring_virtqueue *vq = to_vvq(_vq);
+
+	return vq->vring.num;
+}
+EXPORT_SYMBOL_GPL(virtqueue_get_vring_size);
+
 MODULE_LICENSE("GPL");
diff --git a/include/linux/virtio.h b/include/linux/virtio.h
index 7108857..851ebf1 100644
--- a/include/linux/virtio.h
+++ b/include/linux/virtio.h
@@ -61,6 +61,9 @@ struct virtqueue {
  * virtqueue_detach_unused_buf: detach first unused buffer
  * 	vq: the struct virtqueue we're talking about.
  * 	Returns NULL or the "data" token handed to add_buf
+ * virtqueue_get_vring_size: return the size of the virtqueue's vring
+ *	vq: the struct virtqueue containing the vring of interest.
+ *	Returns the size of the vring.
  *
  * Locking rules are straightforward: the driver is responsible for
  * locking.  No two operations may be invoked simultaneously, with the exception
@@ -97,6 +100,8 @@ bool virtqueue_enable_cb_delayed(struct virtqueue *vq);
 
 void *virtqueue_detach_unused_buf(struct virtqueue *vq);
 
+unsigned int virtqueue_get_vring_size(struct virtqueue *vq);
+
 /**
  * virtio_device - representation of a device using virtio
  * @index: unique position on the virtio bus

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

* Re: [PATCH net-next] Add ethtool -g support to virtio_net
  2011-10-19 18:10 [PATCH net-next] Add ethtool -g support to virtio_net Rick Jones
@ 2011-10-20  7:55 ` Rusty Russell
  2011-10-24  3:26   ` David Miller
  0 siblings, 1 reply; 6+ messages in thread
From: Rusty Russell @ 2011-10-20  7:55 UTC (permalink / raw)
  To: Rick Jones, netdev, mst, virtualization

On Wed, 19 Oct 2011 11:10:59 -0700 (PDT), raj@tardy.cup.hp.com (Rick Jones) wrote:
> From: Rick Jones <rick.jones2@hp.com>
> 
> Add support for reporting ring sizes via ethtool -g to the virtio_net
> driver.
> 
> Signed-off-by: Rick Jones <rick.jones2@hp.com>

Acked-by: Rusty Russell <rusty@rustcorp.com.au>

MST, want me to take this, or do you?

Cheers,
Rusty.

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

* Re: [PATCH net-next] Add ethtool -g support to virtio_net
  2011-10-20  7:55 ` Rusty Russell
@ 2011-10-24  3:26   ` David Miller
  2011-10-24  4:41     ` Rusty Russell
  2011-10-24  5:31     ` Michael S. Tsirkin
  0 siblings, 2 replies; 6+ messages in thread
From: David Miller @ 2011-10-24  3:26 UTC (permalink / raw)
  To: rusty; +Cc: raj, netdev, mst, virtualization

From: Rusty Russell <rusty@rustcorp.com.au>
Date: Thu, 20 Oct 2011 18:25:24 +1030

> On Wed, 19 Oct 2011 11:10:59 -0700 (PDT), raj@tardy.cup.hp.com (Rick Jones) wrote:
>> From: Rick Jones <rick.jones2@hp.com>
>> 
>> Add support for reporting ring sizes via ethtool -g to the virtio_net
>> driver.
>> 
>> Signed-off-by: Rick Jones <rick.jones2@hp.com>
> 
> Acked-by: Rusty Russell <rusty@rustcorp.com.au>
> 
> MST, want me to take this, or do you?

I can also take it directly, just let me know.

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

* Re: [PATCH net-next] Add ethtool -g support to virtio_net
  2011-10-24  3:26   ` David Miller
@ 2011-10-24  4:41     ` Rusty Russell
  2011-10-24  5:31     ` Michael S. Tsirkin
  1 sibling, 0 replies; 6+ messages in thread
From: Rusty Russell @ 2011-10-24  4:41 UTC (permalink / raw)
  To: David Miller; +Cc: raj, netdev, mst, virtualization

On Sun, 23 Oct 2011 23:26:04 -0400 (EDT), David Miller <davem@davemloft.net> wrote:
> From: Rusty Russell <rusty@rustcorp.com.au>
> Date: Thu, 20 Oct 2011 18:25:24 +1030
> 
> > On Wed, 19 Oct 2011 11:10:59 -0700 (PDT), raj@tardy.cup.hp.com (Rick Jones) wrote:
> >> From: Rick Jones <rick.jones2@hp.com>
> >> 
> >> Add support for reporting ring sizes via ethtool -g to the virtio_net
> >> driver.
> >> 
> >> Signed-off-by: Rick Jones <rick.jones2@hp.com>
> > 
> > Acked-by: Rusty Russell <rusty@rustcorp.com.au>
> > 
> > MST, want me to take this, or do you?
> 
> I can also take it directly, just let me know.

I'm happy with that.

Thanks,
Rusty.

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

* Re: [PATCH net-next] Add ethtool -g support to virtio_net
  2011-10-24  3:26   ` David Miller
  2011-10-24  4:41     ` Rusty Russell
@ 2011-10-24  5:31     ` Michael S. Tsirkin
  2011-10-24  6:15       ` David Miller
  1 sibling, 1 reply; 6+ messages in thread
From: Michael S. Tsirkin @ 2011-10-24  5:31 UTC (permalink / raw)
  To: David Miller; +Cc: rusty, raj, netdev, virtualization

On Sun, Oct 23, 2011 at 11:26:04PM -0400, David Miller wrote:
> From: Rusty Russell <rusty@rustcorp.com.au>
> Date: Thu, 20 Oct 2011 18:25:24 +1030
> 
> > On Wed, 19 Oct 2011 11:10:59 -0700 (PDT), raj@tardy.cup.hp.com (Rick Jones) wrote:
> >> From: Rick Jones <rick.jones2@hp.com>
> >> 
> >> Add support for reporting ring sizes via ethtool -g to the virtio_net
> >> driver.
> >> 
> >> Signed-off-by: Rick Jones <rick.jones2@hp.com>
> > 
> > Acked-by: Rusty Russell <rusty@rustcorp.com.au>
> > 
> > MST, want me to take this, or do you?
> 
> I can also take it directly, just let me know.

Please do, thanks very much.

Acked-by: Michael S. Tsirkin <mst@redhat.com>

-- 
MST

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

* Re: [PATCH net-next] Add ethtool -g support to virtio_net
  2011-10-24  5:31     ` Michael S. Tsirkin
@ 2011-10-24  6:15       ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2011-10-24  6:15 UTC (permalink / raw)
  To: mst; +Cc: rusty, raj, netdev, virtualization

From: "Michael S. Tsirkin" <mst@redhat.com>
Date: Mon, 24 Oct 2011 07:31:05 +0200

> On Sun, Oct 23, 2011 at 11:26:04PM -0400, David Miller wrote:
>> From: Rusty Russell <rusty@rustcorp.com.au>
>> Date: Thu, 20 Oct 2011 18:25:24 +1030
>> 
>> > On Wed, 19 Oct 2011 11:10:59 -0700 (PDT), raj@tardy.cup.hp.com (Rick Jones) wrote:
>> >> From: Rick Jones <rick.jones2@hp.com>
>> >> 
>> >> Add support for reporting ring sizes via ethtool -g to the virtio_net
>> >> driver.
>> >> 
>> >> Signed-off-by: Rick Jones <rick.jones2@hp.com>
>> > 
>> > Acked-by: Rusty Russell <rusty@rustcorp.com.au>
>> > 
>> > MST, want me to take this, or do you?
>> 
>> I can also take it directly, just let me know.
> 
> Please do, thanks very much.
> 
> Acked-by: Michael S. Tsirkin <mst@redhat.com>
> 

Done.

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

end of thread, other threads:[~2011-10-24  6:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-19 18:10 [PATCH net-next] Add ethtool -g support to virtio_net Rick Jones
2011-10-20  7:55 ` Rusty Russell
2011-10-24  3:26   ` David Miller
2011-10-24  4:41     ` Rusty Russell
2011-10-24  5:31     ` Michael S. Tsirkin
2011-10-24  6:15       ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).