1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright (c) 2017 Red Hat, Inc. 3 */ 4 5 #ifndef _VHOST_IOTLB_H_ 6 #define _VHOST_IOTLB_H_ 7 8 #include <stdbool.h> 9 10 #include "vhost.h" 11 12 static __rte_always_inline void 13 vhost_user_iotlb_rd_lock(struct vhost_virtqueue *vq) 14 __rte_shared_lock_function(&vq->iotlb_lock) 15 { 16 rte_rwlock_read_lock(&vq->iotlb_lock); 17 } 18 19 static __rte_always_inline void 20 vhost_user_iotlb_rd_unlock(struct vhost_virtqueue *vq) 21 __rte_unlock_function(&vq->iotlb_lock) 22 { 23 rte_rwlock_read_unlock(&vq->iotlb_lock); 24 } 25 26 static __rte_always_inline void 27 vhost_user_iotlb_wr_lock(struct vhost_virtqueue *vq) 28 __rte_exclusive_lock_function(&vq->iotlb_lock) 29 { 30 rte_rwlock_write_lock(&vq->iotlb_lock); 31 } 32 33 static __rte_always_inline void 34 vhost_user_iotlb_wr_unlock(struct vhost_virtqueue *vq) 35 __rte_unlock_function(&vq->iotlb_lock) 36 { 37 rte_rwlock_write_unlock(&vq->iotlb_lock); 38 } 39 40 void vhost_user_iotlb_cache_insert(struct virtio_net *dev, struct vhost_virtqueue *vq, 41 uint64_t iova, uint64_t uaddr, 42 uint64_t size, uint8_t perm); 43 void vhost_user_iotlb_cache_remove(struct vhost_virtqueue *vq, 44 uint64_t iova, uint64_t size); 45 uint64_t vhost_user_iotlb_cache_find(struct vhost_virtqueue *vq, uint64_t iova, 46 uint64_t *size, uint8_t perm); 47 bool vhost_user_iotlb_pending_miss(struct vhost_virtqueue *vq, uint64_t iova, 48 uint8_t perm); 49 void vhost_user_iotlb_pending_insert(struct virtio_net *dev, struct vhost_virtqueue *vq, 50 uint64_t iova, uint8_t perm); 51 void vhost_user_iotlb_pending_remove(struct vhost_virtqueue *vq, uint64_t iova, 52 uint64_t size, uint8_t perm); 53 void vhost_user_iotlb_flush_all(struct vhost_virtqueue *vq); 54 int vhost_user_iotlb_init(struct virtio_net *dev, struct vhost_virtqueue *vq); 55 void vhost_user_iotlb_destroy(struct vhost_virtqueue *vq); 56 57 #endif /* _VHOST_IOTLB_H_ */ 58