]>
Commit | Line | Data |
---|---|---|
857a2622 XG |
1 | /* SPDX-License-Identifier: GPL-2.0 */ |
2 | /* | |
3 | * Header file for FPGA Accelerated Function Unit (AFU) Driver | |
4 | * | |
5 | * Copyright (C) 2017-2018 Intel Corporation, Inc. | |
6 | * | |
7 | * Authors: | |
8 | * Wu Hao <[email protected]> | |
9 | * Xiao Guangrong <[email protected]> | |
10 | * Joseph Grecco <[email protected]> | |
11 | * Enno Luebbers <[email protected]> | |
12 | * Tim Whisonant <[email protected]> | |
13 | * Ananda Ravuri <[email protected]> | |
14 | * Henry Mitchel <[email protected]> | |
15 | */ | |
16 | ||
17 | #ifndef __DFL_AFU_H | |
18 | #define __DFL_AFU_H | |
19 | ||
20 | #include <linux/mm.h> | |
21 | ||
22 | #include "dfl.h" | |
23 | ||
24 | /** | |
25 | * struct dfl_afu_mmio_region - afu mmio region data structure | |
26 | * | |
27 | * @index: region index. | |
28 | * @flags: region flags (access permission). | |
29 | * @size: region size. | |
30 | * @offset: region offset from start of the device fd. | |
31 | * @phys: region's physical address. | |
32 | * @node: node to add to afu feature dev's region list. | |
33 | */ | |
34 | struct dfl_afu_mmio_region { | |
35 | u32 index; | |
36 | u32 flags; | |
37 | u64 size; | |
38 | u64 offset; | |
39 | u64 phys; | |
40 | struct list_head node; | |
41 | }; | |
42 | ||
fa8dda1e | 43 | /** |
a73c125b | 44 | * struct dfl_afu_dma_region - afu DMA region data structure |
fa8dda1e WH |
45 | * |
46 | * @user_addr: region userspace virtual address. | |
47 | * @length: region length. | |
48 | * @iova: region IO virtual address. | |
49 | * @pages: ptr to pages of this region. | |
50 | * @node: rb tree node. | |
51 | * @in_use: flag to indicate if this region is in_use. | |
52 | */ | |
53 | struct dfl_afu_dma_region { | |
54 | u64 user_addr; | |
55 | u64 length; | |
56 | u64 iova; | |
57 | struct page **pages; | |
58 | struct rb_node node; | |
59 | bool in_use; | |
60 | }; | |
61 | ||
857a2622 XG |
62 | /** |
63 | * struct dfl_afu - afu device data structure | |
64 | * | |
65 | * @region_cur_offset: current region offset from start to the device fd. | |
66 | * @num_regions: num of mmio regions. | |
67 | * @regions: the mmio region linked list of this afu feature device. | |
fa8dda1e | 68 | * @dma_regions: root of dma regions rb tree. |
857a2622 | 69 | * @num_umsgs: num of umsgs. |
857a2622 XG |
70 | */ |
71 | struct dfl_afu { | |
72 | u64 region_cur_offset; | |
73 | int num_regions; | |
74 | u8 num_umsgs; | |
75 | struct list_head regions; | |
fa8dda1e | 76 | struct rb_root dma_regions; |
857a2622 XG |
77 | }; |
78 | ||
af394071 PC |
79 | /* hold fdata->lock when call __afu_port_enable/disable */ |
80 | int __afu_port_enable(struct dfl_feature_dev_data *fdata); | |
81 | int __afu_port_disable(struct dfl_feature_dev_data *fdata); | |
95844372 | 82 | |
af394071 PC |
83 | void afu_mmio_region_init(struct dfl_feature_dev_data *fdata); |
84 | int afu_mmio_region_add(struct dfl_feature_dev_data *fdata, | |
857a2622 | 85 | u32 region_index, u64 region_size, u64 phys, u32 flags); |
af394071 PC |
86 | void afu_mmio_region_destroy(struct dfl_feature_dev_data *fdata); |
87 | int afu_mmio_region_get_by_index(struct dfl_feature_dev_data *fdata, | |
857a2622 XG |
88 | u32 region_index, |
89 | struct dfl_afu_mmio_region *pregion); | |
af394071 | 90 | int afu_mmio_region_get_by_offset(struct dfl_feature_dev_data *fdata, |
857a2622 XG |
91 | u64 offset, u64 size, |
92 | struct dfl_afu_mmio_region *pregion); | |
af394071 PC |
93 | void afu_dma_region_init(struct dfl_feature_dev_data *fdata); |
94 | void afu_dma_region_destroy(struct dfl_feature_dev_data *fdata); | |
95 | int afu_dma_map_region(struct dfl_feature_dev_data *fdata, | |
fa8dda1e | 96 | u64 user_addr, u64 length, u64 *iova); |
af394071 | 97 | int afu_dma_unmap_region(struct dfl_feature_dev_data *fdata, u64 iova); |
fa8dda1e | 98 | struct dfl_afu_dma_region * |
af394071 | 99 | afu_dma_region_find(struct dfl_feature_dev_data *fdata, |
fa8dda1e | 100 | u64 iova, u64 size); |
44d24753 WH |
101 | |
102 | extern const struct dfl_feature_ops port_err_ops; | |
103 | extern const struct dfl_feature_id port_err_id_table[]; | |
104 | extern const struct attribute_group port_err_group; | |
105 | ||
fa8dda1e | 106 | #endif /* __DFL_AFU_H */ |