Skip to content

Commit 8f9f466

Browse files
Rick Jonesdavem330
authored andcommitted
Add ethtool -g support to virtio_net
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>
1 parent ca35a0e commit 8f9f466

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

drivers/net/virtio_net.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,8 +877,21 @@ static void virtnet_vlan_rx_kill_vid(struct net_device *dev, u16 vid)
877877
dev_warn(&dev->dev, "Failed to kill VLAN ID %d.\n", vid);
878878
}
879879

880+
static 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+
880892
static const struct ethtool_ops virtnet_ethtool_ops = {
881893
.get_link = ethtool_op_get_link,
894+
.get_ringparam = virtnet_get_ringparam,
882895
};
883896

884897
#define MIN_MTU 68

drivers/virtio/virtio_ring.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,4 +529,14 @@ void vring_transport_features(struct virtio_device *vdev)
529529
}
530530
EXPORT_SYMBOL_GPL(vring_transport_features);
531531

532+
/* return the size of the vring within the virtqueue */
533+
unsigned 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+
}
540+
EXPORT_SYMBOL_GPL(virtqueue_get_vring_size);
541+
532542
MODULE_LICENSE("GPL");

include/linux/virtio.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ struct virtqueue {
6161
* virtqueue_detach_unused_buf: detach first unused buffer
6262
* vq: the struct virtqueue we're talking about.
6363
* 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.
6467
*
6568
* Locking rules are straightforward: the driver is responsible for
6669
* locking. No two operations may be invoked simultaneously, with the exception
@@ -97,6 +100,8 @@ bool virtqueue_enable_cb_delayed(struct virtqueue *vq);
97100

98101
void *virtqueue_detach_unused_buf(struct virtqueue *vq);
99102

103+
unsigned int virtqueue_get_vring_size(struct virtqueue *vq);
104+
100105
/**
101106
* virtio_device - representation of a device using virtio
102107
* @index: unique position on the virtio bus

0 commit comments

Comments
 (0)