1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_VHOST_IOTLB_H
3 #define _LINUX_VHOST_IOTLB_H
5 #include <linux/interval_tree_generic.h>
7 struct vhost_iotlb_map {
14 #define VHOST_MAP_RO 0x1
15 #define VHOST_MAP_WO 0x2
16 #define VHOST_MAP_RW 0x3
22 #define VHOST_IOTLB_FLAG_RETIRE 0x1
25 struct rb_root_cached root;
26 struct list_head list;
32 int vhost_iotlb_add_range(struct vhost_iotlb *iotlb, u64 start, u64 last,
33 u64 addr, unsigned int perm);
34 void vhost_iotlb_del_range(struct vhost_iotlb *iotlb, u64 start, u64 last);
36 struct vhost_iotlb *vhost_iotlb_alloc(unsigned int limit, unsigned int flags);
37 void vhost_iotlb_free(struct vhost_iotlb *iotlb);
38 void vhost_iotlb_reset(struct vhost_iotlb *iotlb);
40 struct vhost_iotlb_map *
41 vhost_iotlb_itree_first(struct vhost_iotlb *iotlb, u64 start, u64 last);
42 struct vhost_iotlb_map *
43 vhost_iotlb_itree_next(struct vhost_iotlb_map *map, u64 start, u64 last);
45 void vhost_iotlb_map_free(struct vhost_iotlb *iotlb,
46 struct vhost_iotlb_map *map);