]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
Add ethtool -g support to virtio_net
authorRick Jones <rick.jones2@hp.com>
Wed, 19 Oct 2011 08:10:59 +0000 (08:10 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 24 Oct 2011 06:07:21 +0000 (02:07 -0400)
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>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/virtio_net.c
drivers/virtio/virtio_ring.c
include/linux/virtio.h

index 765ab9ac9d1707ce1a34371c0220628a4480eb2a..91039ab1672825b17c0e1dbbba77a3ddd49e84d0 100644 (file)
@@ -877,8 +877,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
index 68b9136847afb65687a426a0c16e6cca6760caf8..4acf88884f9b2ee6517c70b619be7524ab026b06 100644 (file)
@@ -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");
index 7108857496055b1ed9f437ef22ae96c2ae9f0bf3..851ebf1a4476f557c28d605e52dab0cf8f27546a 100644 (file)
@@ -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