]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - drivers/infiniband/hw/usnic/usnic_uiom.h
regulator: arizona: Add regulator specific device tree binding document
[mirror_ubuntu-zesty-kernel.git] / drivers / infiniband / hw / usnic / usnic_uiom.h
1 /*
2 * Copyright (c) 2013, Cisco Systems, Inc. All rights reserved.
3 *
4 * This program is free software; you may redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
9 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
11 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
12 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
13 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
14 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
15 * SOFTWARE.
16 *
17 */
18
19 #ifndef USNIC_UIOM_H_
20 #define USNIC_UIOM_H_
21
22 #include <linux/list.h>
23 #include <linux/scatterlist.h>
24
25 #include "usnic_uiom_interval_tree.h"
26
27 #define USNIC_UIOM_READ (1)
28 #define USNIC_UIOM_WRITE (2)
29
30 #define USNIC_UIOM_MAX_PD_CNT (1000)
31 #define USNIC_UIOM_MAX_MR_CNT (1000000)
32 #define USNIC_UIOM_MAX_MR_SIZE (~0UL)
33 #define USNIC_UIOM_PAGE_SIZE (PAGE_SIZE)
34
35 struct usnic_uiom_dev {
36 struct device *dev;
37 struct list_head link;
38 };
39
40 struct usnic_uiom_pd {
41 struct iommu_domain *domain;
42 spinlock_t lock;
43 struct rb_root rb_root;
44 struct list_head devs;
45 int dev_cnt;
46 };
47
48 struct usnic_uiom_reg {
49 struct usnic_uiom_pd *pd;
50 unsigned long va;
51 size_t length;
52 int offset;
53 int page_size;
54 int writable;
55 struct list_head chunk_list;
56 struct work_struct work;
57 struct mm_struct *mm;
58 unsigned long diff;
59 };
60
61 struct usnic_uiom_chunk {
62 struct list_head list;
63 int nents;
64 struct scatterlist page_list[0];
65 };
66
67 struct usnic_uiom_pd *usnic_uiom_alloc_pd(void);
68 void usnic_uiom_dealloc_pd(struct usnic_uiom_pd *pd);
69 int usnic_uiom_attach_dev_to_pd(struct usnic_uiom_pd *pd, struct device *dev);
70 void usnic_uiom_detach_dev_from_pd(struct usnic_uiom_pd *pd,
71 struct device *dev);
72 struct device **usnic_uiom_get_dev_list(struct usnic_uiom_pd *pd);
73 void usnic_uiom_free_dev_list(struct device **devs);
74 struct usnic_uiom_reg *usnic_uiom_reg_get(struct usnic_uiom_pd *pd,
75 unsigned long addr, size_t size,
76 int access, int dmasync);
77 void usnic_uiom_reg_release(struct usnic_uiom_reg *uiomr, int closing);
78 int usnic_uiom_init(char *drv_name);
79 void usnic_uiom_fini(void);
80 #endif /* USNIC_UIOM_H_ */