net/virtio: add missing backend features negotiation
[dpdk.git] / drivers / net / virtio / virtio_user / virtio_user_dev.c
index e1cbad0..39c5dfc 100644 (file)
@@ -440,11 +440,13 @@ virtio_user_dev_setup(struct virtio_user_dev *dev)
         1ULL << VIRTIO_F_RING_PACKED           |       \
         1ULL << VHOST_USER_F_PROTOCOL_FEATURES)
 
-#define VIRTIO_USER_SUPPORTED_PROTOCOL_FEATURES                \
+#define VHOST_USER_SUPPORTED_PROTOCOL_FEATURES         \
        (1ULL << VHOST_USER_PROTOCOL_F_MQ |             \
         1ULL << VHOST_USER_PROTOCOL_F_REPLY_ACK |      \
         1ULL << VHOST_USER_PROTOCOL_F_STATUS)
 
+#define VHOST_VDPA_SUPPORTED_PROTOCOL_FEATURES         \
+       (1ULL << VHOST_BACKEND_F_IOTLB_MSG_V2)
 int
 virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
                     int cq, int queue_size, const char *mac, char **ifname,
@@ -463,9 +465,13 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
        dev->mac_specified = 0;
        dev->frontend_features = 0;
        dev->unsupported_features = ~VIRTIO_USER_SUPPORTED_FEATURES;
-       dev->protocol_features = VIRTIO_USER_SUPPORTED_PROTOCOL_FEATURES;
        dev->backend_type = backend_type;
 
+       if (dev->backend_type == VIRTIO_USER_BACKEND_VHOST_USER)
+               dev->protocol_features = VHOST_USER_SUPPORTED_PROTOCOL_FEATURES;
+       else if (dev->backend_type == VIRTIO_USER_BACKEND_VHOST_VDPA)
+               dev->protocol_features = VHOST_VDPA_SUPPORTED_PROTOCOL_FEATURES;
+
        parse_mac(dev, mac);
 
        if (*ifname) {
@@ -498,8 +504,8 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
                }
 
 
-               if (dev->device_features &
-                               (1ULL << VHOST_USER_F_PROTOCOL_FEATURES)) {
+               if ((dev->device_features & (1ULL << VHOST_USER_F_PROTOCOL_FEATURES)) ||
+                               (dev->backend_type == VIRTIO_USER_BACKEND_VHOST_VDPA)) {
                        if (dev->ops->send_request(dev,
                                        VHOST_USER_GET_PROTOCOL_FEATURES,
                                        &protocol_features))