vhost: disable reply-ack feature if IOMMU disabled
authorMaxime Coquelin <maxime.coquelin@redhat.com>
Mon, 6 Nov 2017 20:38:10 +0000 (21:38 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 7 Nov 2017 13:13:47 +0000 (14:13 +0100)
If the application has disabled VIRTIO_F_IOMMU_PLATFORM, disable
VHOST_USER_PROTOCOL_F_REPLY_ACK protocol feature that is only
mandatory with IOMMU for now.

This is done to provide a way for the application to support
multiqueue with old Qemu versions (v2.7.0 to v2.9.0) that have
reply-ack feature broken.

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Acked-by: Yuanhan Liu <yliu@fridaylinux.org>
Tested-by: Mark Kavanagh <mark.b.kavanagh@intel.com>
Acked-by: Mark Kavanagh <mark.b.kavanagh@intel.com>
lib/librte_vhost/vhost_user.c

index 6fbdac5..f4c7ce4 100644 (file)
@@ -860,6 +860,27 @@ vhost_user_set_vring_enable(struct virtio_net *dev,
        return 0;
 }
 
+static void
+vhost_user_get_protocol_features(struct virtio_net *dev,
+                                struct VhostUserMsg *msg)
+{
+       uint64_t features, protocol_features = VHOST_USER_PROTOCOL_FEATURES;
+
+       rte_vhost_driver_get_features(dev->ifname, &features);
+
+       /*
+        * REPLY_ACK protocol feature is only mandatory for now
+        * for IOMMU feature. If IOMMU is explicitly disabled by the
+        * application, disable also REPLY_ACK feature for older buggy
+        * Qemu versions (from v2.7.0 to v2.9.0).
+        */
+       if (!(features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)))
+               protocol_features &= ~(1ULL << VHOST_USER_PROTOCOL_F_REPLY_ACK);
+
+       msg->payload.u64 = protocol_features;
+       msg->size = sizeof(msg->payload.u64);
+}
+
 static void
 vhost_user_set_protocol_features(struct virtio_net *dev,
                                 uint64_t protocol_features)
@@ -1231,8 +1252,7 @@ vhost_user_msg_handler(int vid, int fd)
                break;
 
        case VHOST_USER_GET_PROTOCOL_FEATURES:
-               msg.payload.u64 = VHOST_USER_PROTOCOL_FEATURES;
-               msg.size = sizeof(msg.payload.u64);
+               vhost_user_get_protocol_features(dev, &msg);
                send_vhost_reply(fd, &msg);
                break;
        case VHOST_USER_SET_PROTOCOL_FEATURES: