vhost_iotlb.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _LINUX_VHOST_IOTLB_H
  3. #define _LINUX_VHOST_IOTLB_H
  4. #include <linux/interval_tree_generic.h>
  5. struct vhost_iotlb_map {
  6. struct rb_node rb;
  7. struct list_head link;
  8. u64 start;
  9. u64 last;
  10. u64 size;
  11. u64 addr;
  12. #define VHOST_MAP_RO 0x1
  13. #define VHOST_MAP_WO 0x2
  14. #define VHOST_MAP_RW 0x3
  15. u32 perm;
  16. u32 flags_padding;
  17. u64 __subtree_last;
  18. void *opaque;
  19. };
  20. #define VHOST_IOTLB_FLAG_RETIRE 0x1
  21. struct vhost_iotlb {
  22. struct rb_root_cached root;
  23. struct list_head list;
  24. unsigned int limit;
  25. unsigned int nmaps;
  26. unsigned int flags;
  27. };
  28. int vhost_iotlb_add_range_ctx(struct vhost_iotlb *iotlb, u64 start, u64 last,
  29. u64 addr, unsigned int perm, void *opaque);
  30. int vhost_iotlb_add_range(struct vhost_iotlb *iotlb, u64 start, u64 last,
  31. u64 addr, unsigned int perm);
  32. void vhost_iotlb_del_range(struct vhost_iotlb *iotlb, u64 start, u64 last);
  33. void vhost_iotlb_init(struct vhost_iotlb *iotlb, unsigned int limit,
  34. unsigned int flags);
  35. struct vhost_iotlb *vhost_iotlb_alloc(unsigned int limit, unsigned int flags);
  36. void vhost_iotlb_free(struct vhost_iotlb *iotlb);
  37. void vhost_iotlb_reset(struct vhost_iotlb *iotlb);
  38. struct vhost_iotlb_map *
  39. vhost_iotlb_itree_first(struct vhost_iotlb *iotlb, u64 start, u64 last);
  40. struct vhost_iotlb_map *
  41. vhost_iotlb_itree_next(struct vhost_iotlb_map *map, u64 start, u64 last);
  42. void vhost_iotlb_map_free(struct vhost_iotlb *iotlb,
  43. struct vhost_iotlb_map *map);
  44. #endif