Skip to contentSkip to conversation

vhost: support virtqueue interrupt/notification suppression

PATCH Superseded [email protected] 2 participants 2 messages Nov 28, 2017

v2 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 vhost: support virtqueue interrupt/notification suppression

From: Junjie Chen <[email protected]>

The driver can suppress interrupt when VIRTIO_F_EVENT_IDX feature bit is negotiated. The driver set vring flags to 0, and MAY use used_event in available ring to advise device interrupt util reach an index specified by used_event. The device ignore the lower bit of vring flags, and send an interrupt when index reach used_event.

The device can suppress notification in a manner analogous to the ways driver suppress interrupt. The device manipulates flags or avail_event in the used ringin the same way the driver manipulates flags or used_event in available ring.

This patch is to enable this feature in vhost.

---
 lib/librte_vhost/Makefile     |  1 +
 lib/librte_vhost/vhost.h      |  9 ++++++-
 lib/librte_vhost/virtio_net.c | 56 +++++++++++++++++++++++++++++++------------
 3 files changed, 50 insertions(+), 16 deletions(-)
lib/librte_vhost/Makefile +1 -0
index be182798a..85695d443 100644
@@ -40,6 +40,7 @@ LIBABIVER := 4
 
 CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3 -D_FILE_OFFSET_BITS=64
 CFLAGS += -I vhost_user
+CFLAGS += -fno-strict-aliasing
 LDLIBS += -lpthread
 
 ifeq ($(CONFIG_RTE_LIBRTE_VHOST_NUMA),y)
lib/librte_vhost/vhost.h +8 -1
index 1cc81c17c..b0a955f64 100644
@@ -103,6 +103,8 @@ struct vhost_virtqueue {
 
 	uint16_t		last_avail_idx;
 	uint16_t		last_used_idx;
+	/* Last used index we notify to front end. */
+	uint16_t		signalled_used;
 #define VIRTIO_INVALID_EVENTFD		(-1)
 #define VIRTIO_UNINITIALIZED_EVENTFD	(-2)
 
@@ -195,6 +197,10 @@ struct vhost_msg {
 
 #define VHOST_USER_F_PROTOCOL_FEATURES	30
 
+#ifndef VIRTIO_F_EVENT_IDX
+ #define VIRTIO_F_EVENT_IDX 29
+#endif
+
 /* Features supported by this builtin vhost-user net driver. */
 #define VIRTIO_NET_SUPPORTED_FEATURES ((1ULL << VIRTIO_NET_F_MRG_RXBUF) | \
 				(1ULL << VIRTIO_NET_F_CTRL_VQ) | \
@@ -212,7 +218,8 @@ struct vhost_msg {
 				(1ULL << VIRTIO_NET_F_GUEST_TSO6) | \
 				(1ULL << VIRTIO_RING_F_INDIRECT_DESC) | \
 				(1ULL << VIRTIO_NET_F_MTU) | \
-				(1ULL << VIRTIO_F_IOMMU_PLATFORM))
+				(1ULL << VIRTIO_F_IOMMU_PLATFORM) | \
+				(1ULL << VIRTIO_F_EVENT_IDX))
 
 
 struct guest_page {
lib/librte_vhost/virtio_net.c +41 -15

86 lines not on this page · raw message

Signature · 1 line
2.15.0
#1 lore raw

Hi,

On Tue, Nov 28, 2017 at 04:48:26AM -0500, [email protected] wrote:
[...]

Quoted 12 lines
(quoted diff) +4 -0
@@ -195,6 +197,10 @@ struct vhost_msg {
 
 #define VHOST_USER_F_PROTOCOL_FEATURES	30
 
+#ifndef VIRTIO_F_EVENT_IDX
+ #define VIRTIO_F_EVENT_IDX 29
+#endif
+
 /* Features supported by this builtin vhost-user net driver. */
 #define VIRTIO_NET_SUPPORTED_FEATURES ((1ULL << VIRTIO_NET_F_MRG_RXBUF) | \
 				(1ULL << VIRTIO_NET_F_CTRL_VQ) | \

Review struct vhost_msg { · line 223

Quoted 7 lines
(quoted diff) +2 -1
@@ -212,7 +218,8 @@ struct vhost_msg {
 				(1ULL << VIRTIO_NET_F_GUEST_TSO6) | \
 				(1ULL << VIRTIO_RING_F_INDIRECT_DESC) | \
 				(1ULL << VIRTIO_NET_F_MTU) | \
-				(1ULL << VIRTIO_F_IOMMU_PLATFORM))
+				(1ULL << VIRTIO_F_IOMMU_PLATFORM) | \
+				(1ULL << VIRTIO_F_EVENT_IDX))
 

You can use VIRTIO_RING_F_EVENT_IDX directly. It has already been defined by Linux. And you can add this new feature bit after VIRTIO_RING_F_INDIRECT_DESC:

lib/librte_vhost/vhost.h +1 -0
index 2f36a034e..350ac3acc 100644
@@ -211,6 +211,7 @@ struct vhost_msg {
 				(1ULL << VIRTIO_NET_F_GUEST_TSO4) | \
 				(1ULL << VIRTIO_NET_F_GUEST_TSO6) | \
 				(1ULL << VIRTIO_RING_F_INDIRECT_DESC) | \
+				(1ULL << VIRTIO_RING_F_EVENT_IDX) | \
 				(1ULL << VIRTIO_NET_F_MTU) | \
 				(1ULL << VIRTIO_F_IOMMU_PLATFORM))
 

Best regards,
Tiwei