]> git.droids-corp.org - dpdk.git/commitdiff
vhost: add statistics for guest notification
authorMaxime Coquelin <maxime.coquelin@redhat.com>
Tue, 10 May 2022 20:17:18 +0000 (22:17 +0200)
committerMaxime Coquelin <maxime.coquelin@redhat.com>
Wed, 1 Jun 2022 09:50:09 +0000 (11:50 +0200)
This patch adds a new virtqueue statistic for guest
notifications. It is useful to deduce from hypervisor side
whether the corresponding guest Virtio device is using
Kernel Virtio-net driver or DPDK Virtio PMD.

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
lib/vhost/vhost.c
lib/vhost/vhost.h

index f8aa6194d1aaace1cf6b7c308db3c4a2a176529b..1814599aafccd81e6f3bffb8445d8e2eb058fab2 100644 (file)
@@ -42,6 +42,7 @@ static const struct vhost_vq_stats_name_off vhost_vq_stat_strings[] = {
        {"size_512_1023_packets",  offsetof(struct vhost_virtqueue, stats.size_bins[5])},
        {"size_1024_1518_packets", offsetof(struct vhost_virtqueue, stats.size_bins[6])},
        {"size_1519_max_packets",  offsetof(struct vhost_virtqueue, stats.size_bins[7])},
+       {"guest_notifications",    offsetof(struct vhost_virtqueue, stats.guest_notifications)},
 };
 
 #define VHOST_NB_VQ_STATS RTE_DIM(vhost_vq_stat_strings)
index 01b97011aa46387c038a2832392700d6991f7203..13c5c2266defcdc86d20f6754f77fd5fee728477 100644 (file)
@@ -133,6 +133,7 @@ struct virtqueue_stats {
        uint64_t broadcast;
        /* Size bins in array as RFC 2819, undersized [0], 64 [1], etc */
        uint64_t size_bins[8];
+       uint64_t guest_notifications;
 };
 
 /**
@@ -871,6 +872,8 @@ vhost_vring_call_split(struct virtio_net *dev, struct vhost_virtqueue *vq)
                                        (vq->callfd >= 0)) ||
                                unlikely(!signalled_used_valid)) {
                        eventfd_write(vq->callfd, (eventfd_t) 1);
+                       if (dev->flags & VIRTIO_DEV_STATS_ENABLED)
+                               vq->stats.guest_notifications++;
                        if (dev->notify_ops->guest_notified)
                                dev->notify_ops->guest_notified(dev->vid);
                }
@@ -879,6 +882,8 @@ vhost_vring_call_split(struct virtio_net *dev, struct vhost_virtqueue *vq)
                if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT)
                                && (vq->callfd >= 0)) {
                        eventfd_write(vq->callfd, (eventfd_t)1);
+                       if (dev->flags & VIRTIO_DEV_STATS_ENABLED)
+                               vq->stats.guest_notifications++;
                        if (dev->notify_ops->guest_notified)
                                dev->notify_ops->guest_notified(dev->vid);
                }