| 1842 | } |
| 1843 | |
| 1844 | int |
| 1845 | rte_vhost_async_channel_register(int vid, uint16_t queue_id) |
| 1846 | { |
| 1847 | struct vhost_virtqueue *vq; |
| 1848 | struct virtio_net *dev = get_device(vid); |
| 1849 | int ret; |
| 1850 | |
| 1851 | if (dev == NULL) |
| 1852 | return -1; |
| 1853 | |
| 1854 | if (queue_id >= VHOST_MAX_VRING) |
| 1855 | return -1; |
| 1856 | |
| 1857 | vq = dev->virtqueue[queue_id]; |
| 1858 | |
| 1859 | if (unlikely(vq == NULL || !dev->async_copy || dev->vdpa_dev != NULL)) |
| 1860 | return -1; |
| 1861 | |
| 1862 | rte_rwlock_write_lock(&vq->access_lock); |
| 1863 | |
| 1864 | if (unlikely(!vq->access_ok)) { |
| 1865 | ret = -1; |
| 1866 | goto out_unlock; |
| 1867 | } |
| 1868 | |
| 1869 | ret = async_channel_register(dev, vq); |
| 1870 | |
| 1871 | out_unlock: |
| 1872 | rte_rwlock_write_unlock(&vq->access_lock); |
| 1873 | |
| 1874 | return ret; |
| 1875 | } |
| 1876 | |
| 1877 | int |
| 1878 | rte_vhost_async_channel_register_thread_unsafe(int vid, uint16_t queue_id) |
no test coverage detected