aboutsummaryrefslogtreecommitdiffstats
path: root/include/xen
diff options
context:
space:
mode:
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2010-05-11 10:05:49 -0400
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2010-07-27 11:51:00 -0400
commitb097186fd29d5bc5a26d1ae87995821ffc27b66e (patch)
tree64aeb8bf4f6e0eea409d4ad5e12d9788a136732c /include/xen
parentd2cb214551de8180542a04ec8c86c0c9412c5124 (diff)
swiotlb-xen: SWIOTLB library for Xen PV guest with PCI passthrough.
This patchset: PV guests under Xen are running in an non-contiguous memory architecture. When PCI pass-through is utilized, this necessitates an IOMMU for translating bus (DMA) to virtual and vice-versa and also providing a mechanism to have contiguous pages for device drivers operations (say DMA operations). Specifically, under Xen the Linux idea of pages is an illusion. It assumes that pages start at zero and go up to the available memory. To help with that, the Linux Xen MMU provides a lookup mechanism to translate the page frame numbers (PFN) to machine frame numbers (MFN) and vice-versa. The MFN are the "real" frame numbers. Furthermore memory is not contiguous. Xen hypervisor stitches memory for guests from different pools, which means there is no guarantee that PFN==MFN and PFN+1==MFN+1. Lastly with Xen 4.0, pages (in debug mode) are allocated in descending order (high to low), meaning the guest might never get any MFN's under the 4GB mark. Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Acked-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Cc: Albert Herranz <albert_herranz@yahoo.es> Cc: Ian Campbell <Ian.Campbell@citrix.com>
Diffstat (limited to 'include/xen')
-rw-r--r--include/xen/swiotlb-xen.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/include/xen/swiotlb-xen.h b/include/xen/swiotlb-xen.h
new file mode 100644
index 000000000000..2ea2fdc79c16
--- /dev/null
+++ b/include/xen/swiotlb-xen.h
@@ -0,0 +1,65 @@
1#ifndef __LINUX_SWIOTLB_XEN_H
2#define __LINUX_SWIOTLB_XEN_H
3
4#include <linux/swiotlb.h>
5
6extern void xen_swiotlb_init(int verbose);
7
8extern void
9*xen_swiotlb_alloc_coherent(struct device *hwdev, size_t size,
10 dma_addr_t *dma_handle, gfp_t flags);
11
12extern void
13xen_swiotlb_free_coherent(struct device *hwdev, size_t size,
14 void *vaddr, dma_addr_t dma_handle);
15
16extern dma_addr_t xen_swiotlb_map_page(struct device *dev, struct page *page,
17 unsigned long offset, size_t size,
18 enum dma_data_direction dir,
19 struct dma_attrs *attrs);
20
21extern void xen_swiotlb_unmap_page(struct device *hwdev, dma_addr_t dev_addr,
22 size_t size, enum dma_data_direction dir,
23 struct dma_attrs *attrs);
24/*
25extern int
26xen_swiotlb_map_sg(struct device *hwdev, struct scatterlist *sg, int nents,
27 enum dma_data_direction dir);
28
29extern void
30xen_swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nents,
31 enum dma_data_direction dir);
32*/
33extern int
34xen_swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl,
35 int nelems, enum dma_data_direction dir,
36 struct dma_attrs *attrs);
37
38extern void
39xen_swiotlb_unmap_sg_attrs(struct device *hwdev, struct scatterlist *sgl,
40 int nelems, enum dma_data_direction dir,
41 struct dma_attrs *attrs);
42
43extern void
44xen_swiotlb_sync_single_for_cpu(struct device *hwdev, dma_addr_t dev_addr,
45 size_t size, enum dma_data_direction dir);
46
47extern void
48xen_swiotlb_sync_sg_for_cpu(struct device *hwdev, struct scatterlist *sg,
49 int nelems, enum dma_data_direction dir);
50
51extern void
52xen_swiotlb_sync_single_for_device(struct device *hwdev, dma_addr_t dev_addr,
53 size_t size, enum dma_data_direction dir);
54
55extern void
56xen_swiotlb_sync_sg_for_device(struct device *hwdev, struct scatterlist *sg,
57 int nelems, enum dma_data_direction dir);
58
59extern int
60xen_swiotlb_dma_mapping_error(struct device *hwdev, dma_addr_t dma_addr);
61
62extern int
63xen_swiotlb_dma_supported(struct device *hwdev, u64 mask);
64
65#endif /* __LINUX_SWIOTLB_XEN_H */