blob: 9d5874e3bec9cea9434eb6bd65b77787481c8088 [file] [log] [blame]
Suresh Siddhae61d98d2008-07-10 11:16:35 -07001#ifndef _DMA_REMAPPING_H
2#define _DMA_REMAPPING_H
3
4/*
Fenghua Yu5b6985c2008-10-16 18:02:32 -07005 * VT-d hardware uses 4KiB page size regardless of host page size.
Suresh Siddhae61d98d2008-07-10 11:16:35 -07006 */
Fenghua Yu5b6985c2008-10-16 18:02:32 -07007#define VTD_PAGE_SHIFT (12)
8#define VTD_PAGE_SIZE (1UL << VTD_PAGE_SHIFT)
9#define VTD_PAGE_MASK (((u64)-1) << VTD_PAGE_SHIFT)
10#define VTD_PAGE_ALIGN(addr) (((addr) + VTD_PAGE_SIZE - 1) & VTD_PAGE_MASK)
Suresh Siddhae61d98d2008-07-10 11:16:35 -070011
Mark McLoughlin46b08e12008-11-20 15:49:44 +000012struct root_entry;
Suresh Siddhae61d98d2008-07-10 11:16:35 -070013
Suresh Siddhae61d98d2008-07-10 11:16:35 -070014#define DMA_PTE_READ (1)
15#define DMA_PTE_WRITE (2)
16
Suresh Siddhae61d98d2008-07-10 11:16:35 -070017struct intel_iommu;
18
19struct dmar_domain {
20 int id; /* domain id */
21 struct intel_iommu *iommu; /* back pointer to owning iommu */
22
23 struct list_head devices; /* all devices' list */
24 struct iova_domain iovad; /* iova's that belong to this domain */
25
26 struct dma_pte *pgd; /* virtual address */
27 spinlock_t mapping_lock; /* page table lock */
28 int gaw; /* max guest address width */
29
30 /* adjusted guest address width, 0 is level 2 30-bit */
31 int agaw;
32
33#define DOMAIN_FLAG_MULTIPLE_DEVICES 1
34 int flags;
35};
36
37/* PCI domain-device relationship */
38struct device_domain_info {
39 struct list_head link; /* link to domain siblings */
40 struct list_head global; /* link to global list */
41 u8 bus; /* PCI bus numer */
42 u8 devfn; /* PCI devfn number */
43 struct pci_dev *dev; /* it's NULL for PCIE-to-PCI bridge */
44 struct dmar_domain *domain; /* pointer to domain */
45};
46
Suresh Siddhae61d98d2008-07-10 11:16:35 -070047extern void free_dmar_iommu(struct intel_iommu *iommu);
48
Suresh Siddha2ae21012008-07-10 11:16:43 -070049extern int dmar_disabled;
50
Suresh Siddhae61d98d2008-07-10 11:16:35 -070051#ifndef CONFIG_DMAR_GFX_WA
52static inline void iommu_prepare_gfx_mapping(void)
53{
54 return;
55}
56#endif /* !CONFIG_DMAR_GFX_WA */
57
58#endif