1 | /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ |
---|---|
2 | /* |
3 | * Copyright(c) 2020 - Cornelis Networks, Inc. |
4 | * Copyright(c) 2015 - 2017 Intel Corporation. |
5 | */ |
6 | |
7 | #ifndef _HFI1_USER_EXP_RCV_H |
8 | #define _HFI1_USER_EXP_RCV_H |
9 | |
10 | #include "hfi.h" |
11 | #include "exp_rcv.h" |
12 | |
13 | struct tid_pageset { |
14 | u16 idx; |
15 | u16 count; |
16 | }; |
17 | |
18 | struct tid_user_buf { |
19 | struct mmu_interval_notifier notifier; |
20 | struct mutex cover_mutex; |
21 | unsigned long vaddr; |
22 | unsigned long length; |
23 | unsigned int npages; |
24 | struct page **pages; |
25 | struct tid_pageset *psets; |
26 | unsigned int n_psets; |
27 | }; |
28 | |
29 | struct tid_rb_node { |
30 | struct mmu_interval_notifier notifier; |
31 | struct hfi1_filedata *fdata; |
32 | struct mutex invalidate_mutex; /* covers hw removal */ |
33 | unsigned long phys; |
34 | struct tid_group *grp; |
35 | u32 rcventry; |
36 | dma_addr_t dma_addr; |
37 | bool freed; |
38 | unsigned int npages; |
39 | struct page *pages[] __counted_by(npages); |
40 | }; |
41 | |
42 | static inline int num_user_pages(unsigned long addr, |
43 | unsigned long len) |
44 | { |
45 | const unsigned long spage = addr & PAGE_MASK; |
46 | const unsigned long epage = (addr + len - 1) & PAGE_MASK; |
47 | |
48 | return 1 + ((epage - spage) >> PAGE_SHIFT); |
49 | } |
50 | |
51 | int hfi1_user_exp_rcv_init(struct hfi1_filedata *fd, |
52 | struct hfi1_ctxtdata *uctxt); |
53 | void hfi1_user_exp_rcv_free(struct hfi1_filedata *fd); |
54 | int hfi1_user_exp_rcv_setup(struct hfi1_filedata *fd, |
55 | struct hfi1_tid_info *tinfo); |
56 | int hfi1_user_exp_rcv_clear(struct hfi1_filedata *fd, |
57 | struct hfi1_tid_info *tinfo); |
58 | int hfi1_user_exp_rcv_invalid(struct hfi1_filedata *fd, |
59 | struct hfi1_tid_info *tinfo); |
60 | |
61 | static inline struct mm_struct *mm_from_tid_node(struct tid_rb_node *node) |
62 | { |
63 | return node->notifier.mm; |
64 | } |
65 | |
66 | #endif /* _HFI1_USER_EXP_RCV_H */ |
67 |