aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/virtio_net.c13
-rw-r--r--drivers/virtio/virtio_ring.c10
-rw-r--r--include/linux/virtio.h5
3 files changed, 28 insertions, 0 deletions
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 765ab9ac9d17..91039ab16728 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -877,8 +877,21 @@ static void virtnet_vlan_rx_kill_vid(struct net_device *dev, u16 vid)
877 dev_warn(&dev->dev, "Failed to kill VLAN ID %d.\n", vid); 877 dev_warn(&dev->dev, "Failed to kill VLAN ID %d.\n", vid);
878} 878}
879 879
880static void virtnet_get_ringparam(struct net_device *dev,
881 struct ethtool_ringparam *ring)
882{
883 struct virtnet_info *vi = netdev_priv(dev);
884
885 ring->rx_max_pending = virtqueue_get_vring_size(vi->rvq);
886 ring->tx_max_pending = virtqueue_get_vring_size(vi->svq);
887 ring->rx_pending = ring->rx_max_pending;
888 ring->tx_pending = ring->tx_max_pending;
889
890}
891
880static const struct ethtool_ops virtnet_ethtool_ops = { 892static const struct ethtool_ops virtnet_ethtool_ops = {
881 .get_link = ethtool_op_get_link, 893 .get_link = ethtool_op_get_link,
894 .get_ringparam = virtnet_get_ringparam,
882}; 895};
883 896
884#define MIN_MTU 68 897#define MIN_MTU 68
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 68b9136847af..4acf88884f9b 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)
529} 529}
530EXPORT_SYMBOL_GPL(vring_transport_features); 530EXPORT_SYMBOL_GPL(vring_transport_features);
531 531
532/* return the size of the vring within the virtqueue */
533unsigned int virtqueue_get_vring_size(struct virtqueue *_vq)
534{
535
536 struct vring_virtqueue *vq = to_vvq(_vq);
537
538 return vq->vring.num;
539}
540EXPORT_SYMBOL_GPL(virtqueue_get_vring_size);
541
532MODULE_LICENSE("GPL"); 542MODULE_LICENSE("GPL");
diff --git a/include/linux/virtio.h b/include/linux/virtio.h
index 710885749605..851ebf1a4476 100644
--- a/include/linux/virtio.h
+++ b/include/linux/virtio.h
@@ -61,6 +61,9 @@ struct virtqueue {
61 * virtqueue_detach_unused_buf: detach first unused buffer 61 * virtqueue_detach_unused_buf: detach first unused buffer
62 * vq: the struct virtqueue we're talking about. 62 * vq: the struct virtqueue we're talking about.
63 * Returns NULL or the "data" token handed to add_buf 63 * Returns NULL or the "data" token handed to add_buf
64 * virtqueue_get_vring_size: return the size of the virtqueue's vring
65 * vq: the struct virtqueue containing the vring of interest.
66 * Returns the size of the vring.
64 * 67 *
65 * Locking rules are straightforward: the driver is responsible for 68 * Locking rules are straightforward: the driver is responsible for
66 * locking. No two operations may be invoked simultaneously, with the exception 69 * locking. No two operations may be invoked simultaneously, with the exception
@@ -97,6 +100,8 @@ bool virtqueue_enable_cb_delayed(struct virtqueue *vq);
97 100
98void *virtqueue_detach_unused_buf(struct virtqueue *vq); 101void *virtqueue_detach_unused_buf(struct virtqueue *vq);
99 102
103unsigned int virtqueue_get_vring_size(struct virtqueue *vq);
104
100/** 105/**
101 * virtio_device - representation of a device using virtio 106 * virtio_device - representation of a device using virtio
102 * @index: unique position on the virtio bus 107 * @index: unique position on the virtio bus