raw/ifpga: add FPGA RSU APIs
[dpdk.git] / drivers / raw / ifpga / rte_pmd_ifpga.h
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 /**
22  * @warning
23  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
24  *
25  * Get raw device ID from PCI address string like 'Domain:Bus:Dev.Func'
26  *
27  * @param pci_addr
28  *    The PCI address of specified Intel FPGA device.
29  * @param dev_id
30  *    The buffer to output device ID.
31  * @return
32  *   - (0) if successful.
33  *   - (-EINVAL) if bad parameter.
34  *   - (-ENODEV) if FPGA is not probed by ifpga driver.
35  */
36 __rte_experimental
37 int
38 rte_pmd_ifpga_get_dev_id(const char *pci_addr, uint16_t *dev_id);
39
40 /**
41  * @warning
42  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
43  *
44  * Update image flash of specified Intel FPGA device
45  *
46  * @param dev_id
47  *   The raw device ID of specified Intel FPGA device.
48  * @param image
49  *   The image file name string.
50  * @param status
51  *   The detailed update status for debug.
52  * @return
53  *   - (0) if successful.
54  *   - (-ENODEV) if dev_id is invalid.
55  *   - (-EINVAL) if bad parameter or staging area is not initialized.
56  *   - (-EBUSY) if FPGA is updating or rebooting.
57  *   - (-EIO) if failed to open image file.
58  */
59 __rte_experimental
60 int
61 rte_pmd_ifpga_update_flash(uint16_t dev_id, const char *image,
62         uint64_t *status);
63
64 /**
65  * @warning
66  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
67  *
68  * Stop flash update of specified Intel FPGA device
69  *
70  * @param dev_id
71  *   The raw device ID of specified Intel FPGA device.
72  * @param force
73  *   Abort the update process by writing register if set non-zero.
74  * @return
75  *   - (0) if successful.
76  *   - (-ENODEV) if dev_id is invalid.
77  *   - (-EINVAL) if bad parameter.
78  *   - (-EAGAIN) if failed with force.
79  */
80 __rte_experimental
81 int
82 rte_pmd_ifpga_stop_update(uint16_t dev_id, int force);
83
84 /**
85  * @warning
86  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
87  *
88  * Check current Intel FPGA status and change it to reboot status if it is idle
89  *
90  * @param dev_id
91  *    The raw device ID of specified Intel FPGA device.
92  * @return
93  *   - (0) if FPGA is ready to reboot.
94  *   - (-ENODEV) if dev_id is invalid.
95  *   - (-ENOMEM) if share data is not initialized.
96  *   - (-EBUSY) if FPGA is updating or rebooting.
97  */
98 __rte_experimental
99 int
100 rte_pmd_ifpga_reboot_try(uint16_t dev_id);
101
102 /**
103  * @warning
104  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
105  *
106  * Trigger full reconfiguration of specified Intel FPGA device
107  *
108  * @param dev_id
109  *    The raw device ID of specified Intel FPGA device.
110  * @param type
111  *    Select reconfiguration type.
112  *    0 - reconfigure FPGA only.
113  *    1 - reboot the whole card including FPGA.
114  * @param page
115  *    Select image from which flash partition.
116  *    0 - factory partition.
117  *    1 - user partition.
118  * @return
119  *   - (0) if successful.
120  *   - (-ENODEV) if dev_id is invalid.
121  *   - (-EINVAL) if bad parameter.
122  *   - (-EBUSY) if failed to access BMC register.
123  */
124 __rte_experimental
125 int
126 rte_pmd_ifpga_reload(uint16_t dev_id, int type, int page);
127
128 #ifdef __cplusplus
129 }
130 #endif
131
132 #endif /* _RTE_PMD_IFPGA_H_ */