xref: /dpdk/lib/vhost/iotlb.h (revision daa02b5cddbb8e11b31d41e2bf7bb1ae64dcae2f)
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 {
15 	rte_rwlock_read_lock(&vq->iotlb_lock);
16 }
17 
18 static __rte_always_inline void
19 vhost_user_iotlb_rd_unlock(struct vhost_virtqueue *vq)
20 {
21 	rte_rwlock_read_unlock(&vq->iotlb_lock);
22 }
23 
24 static __rte_always_inline void
25 vhost_user_iotlb_wr_lock(struct vhost_virtqueue *vq)
26 {
27 	rte_rwlock_write_lock(&vq->iotlb_lock);
28 }
29 
30 static __rte_always_inline void
31 vhost_user_iotlb_wr_unlock(struct vhost_virtqueue *vq)
32 {
33 	rte_rwlock_write_unlock(&vq->iotlb_lock);
34 }
35 
36 void vhost_user_iotlb_cache_insert(struct vhost_virtqueue *vq, uint64_t iova,
37 					uint64_t uaddr, uint64_t size,
38 					uint8_t perm);
39 void vhost_user_iotlb_cache_remove(struct vhost_virtqueue *vq,
40 					uint64_t iova, uint64_t size);
41 uint64_t vhost_user_iotlb_cache_find(struct vhost_virtqueue *vq, uint64_t iova,
42 					uint64_t *size, uint8_t perm);
43 bool vhost_user_iotlb_pending_miss(struct vhost_virtqueue *vq, uint64_t iova,
44 						uint8_t perm);
45 void vhost_user_iotlb_pending_insert(struct vhost_virtqueue *vq, uint64_t iova,
46 						uint8_t perm);
47 void vhost_user_iotlb_pending_remove(struct vhost_virtqueue *vq, uint64_t iova,
48 						uint64_t size, uint8_t perm);
49 void vhost_user_iotlb_flush_all(struct vhost_virtqueue *vq);
50 int vhost_user_iotlb_init(struct virtio_net *dev, int vq_index);
51 
52 #endif /* _VHOST_IOTLB_H_ */
53