|
|
eb2664 |
From 039253166a57ee660dd2fbe92ca77fa65154751c Mon Sep 17 00:00:00 2001
|
|
|
eb2664 |
Message-Id: <039253166a57ee660dd2fbe92ca77fa65154751c.1577105865.git.echaudro@redhat.com>
|
|
|
eb2664 |
From: Eelco Chaudron <echaudro@redhat.com>
|
|
|
eb2664 |
Date: Wed, 28 Aug 2019 10:49:39 -0400
|
|
|
eb2664 |
Subject: [PATCH] vhost: add device op when notification to guest is sent
|
|
|
eb2664 |
|
|
|
eb2664 |
This patch adds an operation callback which gets called every time
|
|
|
eb2664 |
the library is waking up the guest trough an eventfd_write() call.
|
|
|
eb2664 |
|
|
|
eb2664 |
This can be used by 3rd party application, like OVS, to track the
|
|
|
eb2664 |
number of times interrupts where generated. This might be of
|
|
|
eb2664 |
interest to find out system-call were called in the fast path.
|
|
|
eb2664 |
|
|
|
eb2664 |
Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
|
|
|
eb2664 |
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
|
|
|
eb2664 |
---
|
|
|
eb2664 |
lib/librte_vhost/rte_vhost.h | 10 +++++++++-
|
|
|
eb2664 |
lib/librte_vhost/vhost.h | 15 ++++++++++++---
|
|
|
eb2664 |
2 files changed, 21 insertions(+), 4 deletions(-)
|
|
|
eb2664 |
|
|
|
eb2664 |
diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h
|
|
|
eb2664 |
index 7fb1729..878e339 100644
|
|
|
eb2664 |
--- a/lib/librte_vhost/rte_vhost.h
|
|
|
eb2664 |
+++ b/lib/librte_vhost/rte_vhost.h
|
|
|
eb2664 |
@@ -172,7 +172,15 @@ struct vhost_device_ops {
|
|
|
eb2664 |
int (*new_connection)(int vid);
|
|
|
eb2664 |
void (*destroy_connection)(int vid);
|
|
|
eb2664 |
|
|
|
eb2664 |
- void *reserved[2]; /**< Reserved for future extension */
|
|
|
eb2664 |
+ /**
|
|
|
eb2664 |
+ * This callback gets called each time a guest gets notified
|
|
|
eb2664 |
+ * about waiting packets. This is the interrupt handling trough
|
|
|
eb2664 |
+ * the eventfd_write(callfd), which can be used for counting these
|
|
|
eb2664 |
+ * "slow" syscalls.
|
|
|
eb2664 |
+ */
|
|
|
eb2664 |
+ void (*guest_notified)(int vid);
|
|
|
eb2664 |
+
|
|
|
eb2664 |
+ void *reserved[1]; /**< Reserved for future extension */
|
|
|
eb2664 |
};
|
|
|
eb2664 |
|
|
|
eb2664 |
/**
|
|
|
eb2664 |
diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
|
|
|
eb2664 |
index 884befa..5131a97 100644
|
|
|
eb2664 |
--- a/lib/librte_vhost/vhost.h
|
|
|
eb2664 |
+++ b/lib/librte_vhost/vhost.h
|
|
|
eb2664 |
@@ -543,13 +543,19 @@ void *vhost_alloc_copy_ind_table(struct virtio_net *dev,
|
|
|
eb2664 |
|
|
|
eb2664 |
if ((vhost_need_event(vhost_used_event(vq), new, old) &&
|
|
|
eb2664 |
(vq->callfd >= 0)) ||
|
|
|
eb2664 |
- unlikely(!signalled_used_valid))
|
|
|
eb2664 |
+ unlikely(!signalled_used_valid)) {
|
|
|
eb2664 |
eventfd_write(vq->callfd, (eventfd_t) 1);
|
|
|
eb2664 |
+ if (dev->notify_ops->guest_notified)
|
|
|
eb2664 |
+ dev->notify_ops->guest_notified(dev->vid);
|
|
|
eb2664 |
+ }
|
|
|
eb2664 |
} else {
|
|
|
eb2664 |
/* Kick the guest if necessary. */
|
|
|
eb2664 |
if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT)
|
|
|
eb2664 |
- && (vq->callfd >= 0))
|
|
|
eb2664 |
+ && (vq->callfd >= 0)) {
|
|
|
eb2664 |
eventfd_write(vq->callfd, (eventfd_t)1);
|
|
|
eb2664 |
+ if (dev->notify_ops->guest_notified)
|
|
|
eb2664 |
+ dev->notify_ops->guest_notified(dev->vid);
|
|
|
eb2664 |
+ }
|
|
|
eb2664 |
}
|
|
|
eb2664 |
}
|
|
|
eb2664 |
|
|
|
eb2664 |
@@ -600,8 +606,11 @@ void *vhost_alloc_copy_ind_table(struct virtio_net *dev,
|
|
|
eb2664 |
if (vhost_need_event(off, new, old))
|
|
|
eb2664 |
kick = true;
|
|
|
eb2664 |
kick:
|
|
|
eb2664 |
- if (kick)
|
|
|
eb2664 |
+ if (kick) {
|
|
|
eb2664 |
eventfd_write(vq->callfd, (eventfd_t)1);
|
|
|
eb2664 |
+ if (dev->notify_ops->guest_notified)
|
|
|
eb2664 |
+ dev->notify_ops->guest_notified(dev->vid);
|
|
|
eb2664 |
+ }
|
|
|
eb2664 |
}
|
|
|
eb2664 |
|
|
|
eb2664 |
static __rte_always_inline void
|
|
|
eb2664 |
--
|
|
|
eb2664 |
1.8.3.1
|
|
|
eb2664 |
|