examples/fips_validation: support self-test only
[dpdk.git] / lib / librte_vhost / socket.c
index 49267ce..73e1dca 100644 (file)
@@ -42,6 +42,7 @@ struct vhost_user_socket {
        bool use_builtin_virtio_net;
        bool extbuf;
        bool linearbuf;
+       bool async_copy;
 
        /*
         * The "supported_features" indicates the feature bits the
@@ -205,6 +206,7 @@ vhost_user_add_connection(int fd, struct vhost_user_socket *vsocket)
        size_t size;
        struct vhost_user_connection *conn;
        int ret;
+       struct virtio_net *dev;
 
        if (vsocket == NULL)
                return;
@@ -236,6 +238,13 @@ vhost_user_add_connection(int fd, struct vhost_user_socket *vsocket)
        if (vsocket->linearbuf)
                vhost_enable_linearbuf(vid);
 
+       if (vsocket->async_copy) {
+               dev = get_device(vid);
+
+               if (dev)
+                       dev->async_copy = 1;
+       }
+
        VHOST_LOG_CONFIG(INFO, "new device, handle is %d\n", vid);
 
        if (vsocket->notify_ops->new_connection) {
@@ -701,7 +710,7 @@ rte_vhost_driver_get_features(const char *path, uint64_t *features)
        }
 
        vdpa_dev = vsocket->vdpa_dev;
-       if (!vdpa_dev || !vdpa_dev->ops->get_features) {
+       if (!vdpa_dev) {
                *features = vsocket->features;
                goto unlock_exit;
        }
@@ -754,7 +763,7 @@ rte_vhost_driver_get_protocol_features(const char *path,
        }
 
        vdpa_dev = vsocket->vdpa_dev;
-       if (!vdpa_dev || !vdpa_dev->ops->get_protocol_features) {
+       if (!vdpa_dev) {
                *protocol_features = vsocket->protocol_features;
                goto unlock_exit;
        }
@@ -794,7 +803,7 @@ rte_vhost_driver_get_queue_num(const char *path, uint32_t *queue_num)
        }
 
        vdpa_dev = vsocket->vdpa_dev;
-       if (!vdpa_dev || !vdpa_dev->ops->get_queue_num) {
+       if (!vdpa_dev) {
                *queue_num = VHOST_MAX_QUEUE_PAIRS;
                goto unlock_exit;
        }
@@ -881,6 +890,17 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
                goto out_mutex;
        }
 
+       vsocket->async_copy = flags & RTE_VHOST_USER_ASYNC_COPY;
+
+       if (vsocket->async_copy &&
+               (flags & (RTE_VHOST_USER_IOMMU_SUPPORT |
+               RTE_VHOST_USER_POSTCOPY_SUPPORT))) {
+               VHOST_LOG_CONFIG(ERR, "error: enabling async copy and IOMMU "
+                       "or post-copy feature simultaneously is not "
+                       "supported\n");
+               goto out_mutex;
+       }
+
        /*
         * Set the supported features correctly for the builtin vhost-user
         * net driver.
@@ -931,6 +951,13 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
                        ~(1ULL << VHOST_USER_PROTOCOL_F_PAGEFAULT);
        }
 
+       if (vsocket->async_copy) {
+               vsocket->supported_features &= ~(1ULL << VHOST_F_LOG_ALL);
+               vsocket->features &= ~(1ULL << VHOST_F_LOG_ALL);
+               VHOST_LOG_CONFIG(INFO,
+                       "Logging feature is disabled in async copy mode\n");
+       }
+
        /*
         * We'll not be able to receive a buffer from guest in linear mode
         * without external buffer if it will not fit in a single mbuf, which is