0001
0002 #ifndef _LINUX_VHOST_IOTLB_H
0003 #define _LINUX_VHOST_IOTLB_H
0004
0005 #include <linux/interval_tree_generic.h>
0006
0007 struct vhost_iotlb_map {
0008 struct rb_node rb;
0009 struct list_head link;
0010 u64 start;
0011 u64 last;
0012 u64 size;
0013 u64 addr;
0014 #define VHOST_MAP_RO 0x1
0015 #define VHOST_MAP_WO 0x2
0016 #define VHOST_MAP_RW 0x3
0017 u32 perm;
0018 u32 flags_padding;
0019 u64 __subtree_last;
0020 void *opaque;
0021 };
0022
0023 #define VHOST_IOTLB_FLAG_RETIRE 0x1
0024
0025 struct vhost_iotlb {
0026 struct rb_root_cached root;
0027 struct list_head list;
0028 unsigned int limit;
0029 unsigned int nmaps;
0030 unsigned int flags;
0031 };
0032
0033 int vhost_iotlb_add_range_ctx(struct vhost_iotlb *iotlb, u64 start, u64 last,
0034 u64 addr, unsigned int perm, void *opaque);
0035 int vhost_iotlb_add_range(struct vhost_iotlb *iotlb, u64 start, u64 last,
0036 u64 addr, unsigned int perm);
0037 void vhost_iotlb_del_range(struct vhost_iotlb *iotlb, u64 start, u64 last);
0038
0039 void vhost_iotlb_init(struct vhost_iotlb *iotlb, unsigned int limit,
0040 unsigned int flags);
0041 struct vhost_iotlb *vhost_iotlb_alloc(unsigned int limit, unsigned int flags);
0042 void vhost_iotlb_free(struct vhost_iotlb *iotlb);
0043 void vhost_iotlb_reset(struct vhost_iotlb *iotlb);
0044
0045 struct vhost_iotlb_map *
0046 vhost_iotlb_itree_first(struct vhost_iotlb *iotlb, u64 start, u64 last);
0047 struct vhost_iotlb_map *
0048 vhost_iotlb_itree_next(struct vhost_iotlb_map *map, u64 start, u64 last);
0049
0050 void vhost_iotlb_map_free(struct vhost_iotlb *iotlb,
0051 struct vhost_iotlb_map *map);
0052 #endif