vdpa/mlx5: add task ring for multi-thread management
[dpdk.git] / lib / vhost / vhost.c
index 42e4b8a..b14521e 100644 (file)
@@ -45,6 +45,8 @@ static const struct vhost_vq_stats_name_off vhost_vq_stat_strings[] = {
        {"guest_notifications",    offsetof(struct vhost_virtqueue, stats.guest_notifications)},
        {"iotlb_hits",             offsetof(struct vhost_virtqueue, stats.iotlb_hits)},
        {"iotlb_misses",           offsetof(struct vhost_virtqueue, stats.iotlb_misses)},
+       {"inflight_submitted",     offsetof(struct vhost_virtqueue, stats.inflight_submitted)},
+       {"inflight_completed",     offsetof(struct vhost_virtqueue, stats.inflight_completed)},
 };
 
 #define VHOST_NB_VQ_STATS RTE_DIM(vhost_vq_stat_strings)
@@ -1767,6 +1769,12 @@ rte_vhost_async_channel_register_thread_unsafe(int vid, uint16_t queue_id)
        if (unlikely(vq == NULL || !dev->async_copy))
                return -1;
 
+       if (unlikely(!rte_spinlock_is_locked(&vq->access_lock))) {
+               VHOST_LOG_CONFIG(ERR, "(%s) %s() called without access lock taken.\n",
+                               dev->ifname, __func__);
+               return -1;
+       }
+
        return async_channel_register(vid, queue_id);
 }
 
@@ -1827,6 +1835,12 @@ rte_vhost_async_channel_unregister_thread_unsafe(int vid, uint16_t queue_id)
        if (vq == NULL)
                return -1;
 
+       if (unlikely(!rte_spinlock_is_locked(&vq->access_lock))) {
+               VHOST_LOG_CONFIG(ERR, "(%s) %s() called without access lock taken.\n",
+                               dev->ifname, __func__);
+               return -1;
+       }
+
        if (!vq->async)
                return 0;
 
@@ -1955,6 +1969,12 @@ rte_vhost_async_get_inflight_thread_unsafe(int vid, uint16_t queue_id)
        if (vq == NULL)
                return ret;
 
+       if (unlikely(!rte_spinlock_is_locked(&vq->access_lock))) {
+               VHOST_LOG_CONFIG(ERR, "(%s) %s() called without access lock taken.\n",
+                               dev->ifname, __func__);
+               return -1;
+       }
+
        if (!vq->async)
                return ret;