/include/linux/iova.h

https://gitlab.com/simplified-mandatory-access-control-kernel/ossecus-simplified-mandatory-access-control-kernel · C Header · 51 lines · 32 code · 7 blank · 12 comment · 0 complexity · 3bd346b010bf151c8a75e37d8eb78348 MD5 · raw file

  1. /*
  2. * Copyright (c) 2006, Intel Corporation.
  3. *
  4. * This file is released under the GPLv2.
  5. *
  6. * Copyright (C) 2006-2008 Intel Corporation
  7. * Author: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
  8. *
  9. */
  10. #ifndef _IOVA_H_
  11. #define _IOVA_H_
  12. #include <linux/types.h>
  13. #include <linux/kernel.h>
  14. #include <linux/rbtree.h>
  15. #include <linux/dma-mapping.h>
  16. /* IO virtual address start page frame number */
  17. #define IOVA_START_PFN (1)
  18. /* iova structure */
  19. struct iova {
  20. struct rb_node node;
  21. unsigned long pfn_hi; /* IOMMU dish out addr hi */
  22. unsigned long pfn_lo; /* IOMMU dish out addr lo */
  23. };
  24. /* holds all the iova translations for a domain */
  25. struct iova_domain {
  26. spinlock_t iova_rbtree_lock; /* Lock to protect update of rbtree */
  27. struct rb_root rbroot; /* iova domain rbtree root */
  28. struct rb_node *cached32_node; /* Save last alloced node */
  29. unsigned long dma_32bit_pfn;
  30. };
  31. struct iova *alloc_iova_mem(void);
  32. void free_iova_mem(struct iova *iova);
  33. void free_iova(struct iova_domain *iovad, unsigned long pfn);
  34. void __free_iova(struct iova_domain *iovad, struct iova *iova);
  35. struct iova *alloc_iova(struct iova_domain *iovad, unsigned long size,
  36. unsigned long limit_pfn,
  37. bool size_aligned);
  38. struct iova *reserve_iova(struct iova_domain *iovad, unsigned long pfn_lo,
  39. unsigned long pfn_hi);
  40. void copy_reserved_iova(struct iova_domain *from, struct iova_domain *to);
  41. void init_iova_domain(struct iova_domain *iovad, unsigned long pfn_32bit);
  42. struct iova *find_iova(struct iova_domain *iovad, unsigned long pfn);
  43. void put_iova_domain(struct iova_domain *iovad);
  44. #endif