Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / drivers / pci / iova.h
blob92eaf60b81e6122a79465b514787824f026658d8
1 /*
2 * Copyright (c) 2006, Intel Corporation.
4 * This file is released under the GPLv2.
6 <<<<<<< HEAD:drivers/pci/iova.h
7 * Copyright (C) 2006 Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
8 =======
9 * Copyright (C) 2006-2008 Intel Corporation
10 * Author: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
11 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/pci/iova.h
15 #ifndef _IOVA_H_
16 #define _IOVA_H_
18 #include <linux/types.h>
19 #include <linux/kernel.h>
20 #include <linux/rbtree.h>
21 #include <linux/dma-mapping.h>
23 /* IO virtual address start page frame number */
24 #define IOVA_START_PFN (1)
26 /* iova structure */
27 struct iova {
28 struct rb_node node;
29 unsigned long pfn_hi; /* IOMMU dish out addr hi */
30 unsigned long pfn_lo; /* IOMMU dish out addr lo */
33 /* holds all the iova translations for a domain */
34 struct iova_domain {
35 spinlock_t iova_alloc_lock;/* Lock to protect iova allocation */
36 spinlock_t iova_rbtree_lock; /* Lock to protect update of rbtree */
37 struct rb_root rbroot; /* iova domain rbtree root */
38 struct rb_node *cached32_node; /* Save last alloced node */
39 unsigned long dma_32bit_pfn;
42 struct iova *alloc_iova_mem(void);
43 void free_iova_mem(struct iova *iova);
44 void free_iova(struct iova_domain *iovad, unsigned long pfn);
45 void __free_iova(struct iova_domain *iovad, struct iova *iova);
46 struct iova *alloc_iova(struct iova_domain *iovad, unsigned long size,
47 unsigned long limit_pfn,
48 bool size_aligned);
49 struct iova *reserve_iova(struct iova_domain *iovad, unsigned long pfn_lo,
50 unsigned long pfn_hi);
51 void copy_reserved_iova(struct iova_domain *from, struct iova_domain *to);
52 void init_iova_domain(struct iova_domain *iovad, unsigned long pfn_32bit);
53 struct iova *find_iova(struct iova_domain *iovad, unsigned long pfn);
54 void put_iova_domain(struct iova_domain *iovad);
56 #endif