1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2021 Intel Corporation 3 */ 4 5 #ifndef _RTE_PMD_IFPGA_H_ 6 #define _RTE_PMD_IFPGA_H_ 7 8 /** 9 * @file rte_pmd_ifpga.h 10 * 11 * ifpga PMD specific functions. 12 * 13 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice 14 * 15 */ 16 17 #ifdef __cplusplus 18 extern "C" { 19 #endif 20 21 #include <stdint.h> 22 23 #define IFPGA_MAX_PORT_NUM 4 24 25 /** 26 * UUID data structure. 27 */ 28 typedef struct { 29 uint8_t b[16]; 30 } rte_pmd_ifpga_uuid; 31 32 /** 33 * FME property data structure. 34 */ 35 typedef struct { 36 uint32_t num_ports; 37 uint32_t boot_page; 38 uint64_t bitstream_id; 39 uint64_t bitstream_metadata; 40 rte_pmd_ifpga_uuid pr_id; 41 uint32_t bmc_version; 42 uint32_t bmc_nios_version; 43 } rte_pmd_ifpga_common_prop; 44 45 /** 46 * port property data structure. 47 */ 48 typedef struct { 49 rte_pmd_ifpga_uuid afu_id; 50 uint32_t type; /* AFU memory access control type */ 51 } rte_pmd_ifpga_port_prop; 52 53 /** 54 * FPGA property data structure. 55 */ 56 typedef struct { 57 rte_pmd_ifpga_common_prop common; 58 rte_pmd_ifpga_port_prop port[IFPGA_MAX_PORT_NUM]; 59 } rte_pmd_ifpga_prop; 60 61 /** 62 * PHY information data structure. 63 */ 64 typedef struct { 65 uint32_t num_retimers; 66 uint32_t link_speed; 67 uint32_t link_status; 68 } rte_pmd_ifpga_phy_info; 69 70 /** 71 * @warning 72 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice 73 * 74 * Get raw device ID from PCI address string like 'Domain:Bus:Dev.Func' 75 * 76 * @param pci_addr 77 * The PCI address of specified Intel FPGA device. 78 * @param dev_id 79 * The buffer to output device ID. 80 * @return 81 * - (0) if successful. 82 * - (-EINVAL) if bad parameter. 83 * - (-ENODEV) if FPGA is not probed by ifpga driver. 84 */ 85 __rte_experimental 86 int 87 rte_pmd_ifpga_get_dev_id(const char *pci_addr, uint16_t *dev_id); 88 89 /** 90 * @warning 91 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice 92 * 93 * Get current RSU status of the specified Intel FPGA device 94 * 95 * @param dev_id 96 * The raw device ID of specified Intel FPGA device. 97 * @param stat 98 * The buffer to output RSU status. 99 * @param prog 100 * The buffer to output RSU progress. 101 * @return 102 * - (0) if successful. 103 * - (-ENODEV) if dev_id is invalid. 104 * - (-ENOMEM) if share data is not initialized. 105 */ 106 __rte_experimental 107 int 108 rte_pmd_ifpga_get_rsu_status(uint16_t dev_id, uint32_t *stat, uint32_t *prog); 109 110 /** 111 * @warning 112 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice 113 * 114 * Set current RSU status of the specified Intel FPGA device 115 * 116 * @param dev_id 117 * The raw device ID of specified Intel FPGA device. 118 * @param stat 119 * The RSU status value to set. 120 * @param prog 121 * The RSU progress value to set. 122 * @return 123 * - (0) if successful. 124 * - (-ENODEV) if dev_id is invalid. 125 * - (-ENOMEM) if share data is not initialized. 126 */ 127 __rte_experimental 128 int 129 rte_pmd_ifpga_set_rsu_status(uint16_t dev_id, uint32_t stat, uint32_t prog); 130 131 /** 132 * @warning 133 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice 134 * 135 * Get FPGA property of specified Intel FPGA device 136 * 137 * @param dev_id 138 * The raw device ID of specified Intel FPGA device. 139 * @param prop 140 * The data pointer of FPGA property buffer. 141 * @return 142 * - (0) if successful. 143 * - (-ENODEV) if dev_id is invalid. 144 * - (-EBUSY) if FPGA is rebooting. 145 * - (-EIO) if failed to access hardware. 146 */ 147 __rte_experimental 148 int 149 rte_pmd_ifpga_get_property(uint16_t dev_id, rte_pmd_ifpga_prop *prop); 150 151 /** 152 * @warning 153 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice 154 * 155 * Get PHY information of specified Intel FPGA device 156 * 157 * @param dev_id 158 * The raw device ID of specified Intel FPGA device. 159 * @param info 160 * The data pointer of PHY information buffer. 161 * @return 162 * - (0) if successful. 163 * - (-ENODEV) if dev_id is invalid. 164 * - (-EBUSY) if FPGA is rebooting. 165 * - (-EIO) if failed to access hardware. 166 */ 167 __rte_experimental 168 int 169 rte_pmd_ifpga_get_phy_info(uint16_t dev_id, rte_pmd_ifpga_phy_info *info); 170 171 /** 172 * @warning 173 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice 174 * 175 * Update image flash of specified Intel FPGA device 176 * 177 * @param dev_id 178 * The raw device ID of specified Intel FPGA device. 179 * @param image 180 * The image file name string. 181 * @param status 182 * The detailed update status for debug. 183 * @return 184 * - (0) if successful. 185 * - (-ENODEV) if dev_id is invalid. 186 * - (-EINVAL) if bad parameter or staging area is not initialized. 187 * - (-EBUSY) if FPGA is updating or rebooting. 188 * - (-EIO) if failed to open image file. 189 */ 190 __rte_experimental 191 int 192 rte_pmd_ifpga_update_flash(uint16_t dev_id, const char *image, 193 uint64_t *status); 194 195 /** 196 * @warning 197 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice 198 * 199 * Stop flash update of specified Intel FPGA device 200 * 201 * @param dev_id 202 * The raw device ID of specified Intel FPGA device. 203 * @param force 204 * Abort the update process by writing register if set non-zero. 205 * @return 206 * - (0) if successful. 207 * - (-ENODEV) if dev_id is invalid. 208 * - (-EINVAL) if bad parameter. 209 * - (-EAGAIN) if failed with force. 210 */ 211 __rte_experimental 212 int 213 rte_pmd_ifpga_stop_update(uint16_t dev_id, int force); 214 215 /** 216 * @warning 217 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice 218 * 219 * Check current Intel FPGA status and change it to reboot status if it is idle 220 * 221 * @param dev_id 222 * The raw device ID of specified Intel FPGA device. 223 * @return 224 * - (0) if FPGA is ready to reboot. 225 * - (-ENODEV) if dev_id is invalid. 226 * - (-ENOMEM) if share data is not initialized. 227 * - (-EBUSY) if FPGA is updating or rebooting. 228 */ 229 __rte_experimental 230 int 231 rte_pmd_ifpga_reboot_try(uint16_t dev_id); 232 233 /** 234 * @warning 235 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice 236 * 237 * Trigger full reconfiguration of specified Intel FPGA device 238 * 239 * @param dev_id 240 * The raw device ID of specified Intel FPGA device. 241 * @param type 242 * Select reconfiguration type. 243 * 0 - reconfigure FPGA only. 244 * 1 - reboot the whole card including FPGA. 245 * @param page 246 * Select image from which flash partition. 247 * 0 - factory partition. 248 * 1 - user partition. 249 * @return 250 * - (0) if successful. 251 * - (-ENODEV) if dev_id is invalid. 252 * - (-EINVAL) if bad parameter. 253 * - (-EBUSY) if failed to access BMC register. 254 */ 255 __rte_experimental 256 int 257 rte_pmd_ifpga_reload(uint16_t dev_id, int type, int page); 258 259 /** 260 * @warning 261 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice 262 * 263 * Get PCI bus the Intel FPGA driver register to 264 * 265 * @return 266 * - (valid pointer) if successful. 267 * - (NULL) if the Intel FPGA driver is not registered to any PCI bus. 268 */ 269 __rte_experimental 270 const struct rte_pci_bus * 271 rte_pmd_ifpga_get_pci_bus(void); 272 273 /** 274 * @warning 275 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice 276 * 277 * Perform PR (partial reconfiguration) on specified Intel FPGA device 278 * 279 * @param dev_id 280 * The raw device ID of specified Intel FPGA device. 281 * @param port 282 * The port index of the partial reconfiguration area. 283 * @param file 284 * The GBS (Green BitStream) image file name string. 285 * @return 286 * - (0) if successful. 287 * - (-EINVAL) if bad parameter or operation failed. 288 * - (-ENOMEM) if failed to allocate memory. 289 */ 290 __rte_experimental 291 int 292 rte_pmd_ifpga_partial_reconfigure(uint16_t dev_id, int port, const char *file); 293 294 /** 295 * @warning 296 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice 297 * 298 * Free software resources allocated by Intel FPGA PMD 299 */ 300 __rte_experimental 301 void 302 rte_pmd_ifpga_cleanup(void); 303 304 #ifdef __cplusplus 305 } 306 #endif 307 308 #endif /* _RTE_PMD_IFPGA_H_ */ 309