1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
3 * Header File for FPGA DFL User API
5 * Copyright (C) 2017-2018 Intel Corporation, Inc.
14 #ifndef _UAPI_LINUX_FPGA_DFL_H
15 #define _UAPI_LINUX_FPGA_DFL_H
17 #include <linux/types.h>
18 #include <linux/ioctl.h>
20 #define DFL_FPGA_API_VERSION 0
23 * The IOCTL interface for DFL based FPGA is designed for extensibility by
24 * embedding the structure length (argsz) and flags into structures passed
25 * between kernel and userspace. This design referenced the VFIO IOCTL
26 * interface (include/uapi/linux/vfio.h).
29 #define DFL_FPGA_MAGIC 0xB6
31 #define DFL_FPGA_BASE 0
32 #define DFL_PORT_BASE 0x40
33 #define DFL_FME_BASE 0x80
35 /* Common IOCTLs for both FME and AFU file descriptor */
38 * DFL_FPGA_GET_API_VERSION - _IO(DFL_FPGA_MAGIC, DFL_FPGA_BASE + 0)
40 * Report the version of the driver API.
41 * Return: Driver API Version.
44 #define DFL_FPGA_GET_API_VERSION _IO(DFL_FPGA_MAGIC, DFL_FPGA_BASE + 0)
47 * DFL_FPGA_CHECK_EXTENSION - _IO(DFL_FPGA_MAGIC, DFL_FPGA_BASE + 1)
49 * Check whether an extension is supported.
50 * Return: 0 if not supported, otherwise the extension is supported.
53 #define DFL_FPGA_CHECK_EXTENSION _IO(DFL_FPGA_MAGIC, DFL_FPGA_BASE + 1)
55 /* IOCTLs for AFU file descriptor */
58 * DFL_FPGA_PORT_RESET - _IO(DFL_FPGA_MAGIC, DFL_PORT_BASE + 0)
60 * Reset the FPGA Port and its AFU. No parameters are supported.
61 * Userspace can do Port reset at any time, e.g. during DMA or PR. But
62 * it should never cause any system level issue, only functional failure
63 * (e.g. DMA or PR operation failure) and be recoverable from the failure.
64 * Return: 0 on success, -errno of failure
67 #define DFL_FPGA_PORT_RESET _IO(DFL_FPGA_MAGIC, DFL_PORT_BASE + 0)
70 * DFL_FPGA_PORT_GET_INFO - _IOR(DFL_FPGA_MAGIC, DFL_PORT_BASE + 1,
71 * struct dfl_fpga_port_info)
73 * Retrieve information about the fpga port.
74 * Driver fills the info in provided struct dfl_fpga_port_info.
75 * Return: 0 on success, -errno on failure.
77 struct dfl_fpga_port_info {
79 __u32 argsz; /* Structure length */
81 __u32 flags; /* Zero for now */
82 __u32 num_regions; /* The number of supported regions */
83 __u32 num_umsgs; /* The number of allocated umsgs */
86 #define DFL_FPGA_PORT_GET_INFO _IO(DFL_FPGA_MAGIC, DFL_PORT_BASE + 1)
89 * FPGA_PORT_GET_REGION_INFO - _IOWR(FPGA_MAGIC, PORT_BASE + 2,
90 * struct dfl_fpga_port_region_info)
92 * Retrieve information about a device memory region.
93 * Caller provides struct dfl_fpga_port_region_info with index value set.
94 * Driver returns the region info in other fields.
95 * Return: 0 on success, -errno on failure.
97 struct dfl_fpga_port_region_info {
99 __u32 argsz; /* Structure length */
101 __u32 flags; /* Access permission */
102 #define DFL_PORT_REGION_READ (1 << 0) /* Region is readable */
103 #define DFL_PORT_REGION_WRITE (1 << 1) /* Region is writable */
104 #define DFL_PORT_REGION_MMAP (1 << 2) /* Can be mmaped to userspace */
106 __u32 index; /* Region index */
107 #define DFL_PORT_REGION_INDEX_AFU 0 /* AFU */
108 #define DFL_PORT_REGION_INDEX_STP 1 /* Signal Tap */
111 __u64 size; /* Region size (bytes) */
112 __u64 offset; /* Region offset from start of device fd */
115 #define DFL_FPGA_PORT_GET_REGION_INFO _IO(DFL_FPGA_MAGIC, DFL_PORT_BASE + 2)
118 * DFL_FPGA_PORT_DMA_MAP - _IOWR(DFL_FPGA_MAGIC, DFL_PORT_BASE + 3,
119 * struct dfl_fpga_port_dma_map)
121 * Map the dma memory per user_addr and length which are provided by caller.
122 * Driver fills the iova in provided struct afu_port_dma_map.
123 * This interface only accepts page-size aligned user memory for dma mapping.
124 * Return: 0 on success, -errno on failure.
126 struct dfl_fpga_port_dma_map {
128 __u32 argsz; /* Structure length */
129 __u32 flags; /* Zero for now */
130 __u64 user_addr; /* Process virtual address */
131 __u64 length; /* Length of mapping (bytes)*/
133 __u64 iova; /* IO virtual address */
136 #define DFL_FPGA_PORT_DMA_MAP _IO(DFL_FPGA_MAGIC, DFL_PORT_BASE + 3)
139 * DFL_FPGA_PORT_DMA_UNMAP - _IOW(FPGA_MAGIC, PORT_BASE + 4,
140 * struct dfl_fpga_port_dma_unmap)
142 * Unmap the dma memory per iova provided by caller.
143 * Return: 0 on success, -errno on failure.
145 struct dfl_fpga_port_dma_unmap {
147 __u32 argsz; /* Structure length */
148 __u32 flags; /* Zero for now */
149 __u64 iova; /* IO virtual address */
152 #define DFL_FPGA_PORT_DMA_UNMAP _IO(DFL_FPGA_MAGIC, DFL_PORT_BASE + 4)
154 /* IOCTLs for FME file descriptor */
157 * DFL_FPGA_FME_PORT_PR - _IOW(DFL_FPGA_MAGIC, DFL_FME_BASE + 0,
158 * struct dfl_fpga_fme_port_pr)
160 * Driver does Partial Reconfiguration based on Port ID and Buffer (Image)
161 * provided by caller.
162 * Return: 0 on success, -errno on failure.
163 * If DFL_FPGA_FME_PORT_PR returns -EIO, that indicates the HW has detected
164 * some errors during PR, under this case, the user can fetch HW error info
165 * from the status of FME's fpga manager.
168 struct dfl_fpga_fme_port_pr {
170 __u32 argsz; /* Structure length */
171 __u32 flags; /* Zero for now */
174 __u64 buffer_address; /* Userspace address to the buffer for PR */
177 #define DFL_FPGA_FME_PORT_PR _IO(DFL_FPGA_MAGIC, DFL_FME_BASE + 0)
179 #endif /* _UAPI_LINUX_FPGA_DFL_H */