1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Header file for FPGA Accelerated Function Unit (AFU) Driver
5 * Copyright (C) 2017-2018 Intel Corporation, Inc.
8 * Wu Hao <hao.wu@intel.com>
9 * Xiao Guangrong <guangrong.xiao@linux.intel.com>
10 * Joseph Grecco <joe.grecco@intel.com>
11 * Enno Luebbers <enno.luebbers@intel.com>
12 * Tim Whisonant <tim.whisonant@intel.com>
13 * Ananda Ravuri <ananda.ravuri@intel.com>
14 * Henry Mitchel <henry.mitchel@intel.com>
25 * struct dfl_afu_mmio_region - afu mmio region data structure
27 * @index: region index.
28 * @flags: region flags (access permission).
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.
34 struct dfl_afu_mmio_region {
40 struct list_head node;
44 * struct fpga_afu_dma_region - afu DMA region data structure
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.
53 struct dfl_afu_dma_region {
63 * struct dfl_afu - afu device data structure
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.
68 * @dma_regions: root of dma regions rb tree.
69 * @num_umsgs: num of umsgs.
70 * @pdata: afu platform device's pdata.
73 u64 region_cur_offset;
76 struct list_head regions;
77 struct rb_root dma_regions;
79 struct dfl_feature_platform_data *pdata;
82 /* hold pdata->lock when call __afu_port_enable/disable */
83 int __afu_port_enable(struct platform_device *pdev);
84 int __afu_port_disable(struct platform_device *pdev);
86 void afu_mmio_region_init(struct dfl_feature_platform_data *pdata);
87 int afu_mmio_region_add(struct dfl_feature_platform_data *pdata,
88 u32 region_index, u64 region_size, u64 phys, u32 flags);
89 void afu_mmio_region_destroy(struct dfl_feature_platform_data *pdata);
90 int afu_mmio_region_get_by_index(struct dfl_feature_platform_data *pdata,
92 struct dfl_afu_mmio_region *pregion);
93 int afu_mmio_region_get_by_offset(struct dfl_feature_platform_data *pdata,
95 struct dfl_afu_mmio_region *pregion);
96 void afu_dma_region_init(struct dfl_feature_platform_data *pdata);
97 void afu_dma_region_destroy(struct dfl_feature_platform_data *pdata);
98 int afu_dma_map_region(struct dfl_feature_platform_data *pdata,
99 u64 user_addr, u64 length, u64 *iova);
100 int afu_dma_unmap_region(struct dfl_feature_platform_data *pdata, u64 iova);
101 struct dfl_afu_dma_region *
102 afu_dma_region_find(struct dfl_feature_platform_data *pdata,
105 extern const struct dfl_feature_ops port_err_ops;
106 extern const struct dfl_feature_id port_err_id_table[];
107 extern const struct attribute_group port_err_group;
109 #endif /* __DFL_AFU_H */