vhost_iotlb.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. };
  19. #define VHOST_IOTLB_FLAG_RETIRE 0x1
  20. struct vhost_iotlb {
  21. struct rb_root_cached root;
  22. struct list_head list;
  23. unsigned int limit;
  24. unsigned int nmaps;
  25. unsigned int flags;
  26. };
  27. int vhost_iotlb_add_range(struct vhost_iotlb *iotlb, u64 start, u64 last,
  28. u64 addr, unsigned int perm);
  29. void vhost_iotlb_del_range(struct vhost_iotlb *iotlb, u64 start, u64 last);
  30. struct vhost_iotlb *vhost_iotlb_alloc(unsigned int limit, unsigned int flags);
  31. void vhost_iotlb_free(struct vhost_iotlb *iotlb);
  32. void vhost_iotlb_reset(struct vhost_iotlb *iotlb);
  33. struct vhost_iotlb_map *
  34. vhost_iotlb_itree_first(struct vhost_iotlb *iotlb, u64 start, u64 last);
  35. struct vhost_iotlb_map *
  36. vhost_iotlb_itree_next(struct vhost_iotlb_map *map, u64 start, u64 last);
  37. void vhost_iotlb_map_free(struct vhost_iotlb *iotlb,
  38. struct vhost_iotlb_map *map);
  39. #endif