-
Notifications
You must be signed in to change notification settings - Fork 84
/
adapter.h
239 lines (173 loc) · 8.21 KB
/
adapter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
// Copyright(c) 2018-2021, Intel Corporation
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of Intel Corporation nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
#ifndef __OPAE_ADAPTER_H__
#define __OPAE_ADAPTER_H__
#include <stdbool.h>
#include <opae/types.h>
typedef struct _opae_plugin {
char *path; // location on file system
void *dl_handle; // handle to the loaded library instance
} opae_plugin;
typedef struct _opae_api_adapter_table {
struct _opae_api_adapter_table *next;
opae_plugin plugin;
fpga_result (*fpgaOpen)(fpga_token token, fpga_handle *handle,
int flags);
fpga_result (*fpgaClose)(fpga_handle handle);
fpga_result (*fpgaReset)(fpga_handle handle);
fpga_result (*fpgaGetPropertiesFromHandle)(fpga_handle handle,
fpga_properties *prop);
fpga_result (*fpgaGetProperties)(fpga_token token,
fpga_properties *prop);
fpga_result (*fpgaUpdateProperties)(fpga_token token,
fpga_properties prop);
fpga_result (*fpgaWriteMMIO64)(fpga_handle handle, uint32_t mmio_num,
uint64_t offset, uint64_t value);
fpga_result (*fpgaReadMMIO64)(fpga_handle handle, uint32_t mmio_num,
uint64_t offset, uint64_t *value);
fpga_result (*fpgaWriteMMIO32)(fpga_handle handle, uint32_t mmio_num,
uint64_t offset, uint32_t value);
fpga_result (*fpgaReadMMIO32)(fpga_handle handle, uint32_t mmio_num,
uint64_t offset, uint32_t *value);
fpga_result (*fpgaWriteMMIO512)(fpga_handle handle, uint32_t mmio_num,
uint64_t offset, const void *value);
fpga_result (*fpgaMapMMIO)(fpga_handle handle, uint32_t mmio_num,
uint64_t **mmio_ptr);
fpga_result (*fpgaUnmapMMIO)(fpga_handle handle, uint32_t mmio_num);
fpga_result (*fpgaEnumerate)(const fpga_properties *filters,
uint32_t num_filters, fpga_token *tokens,
uint32_t max_tokens,
uint32_t *num_matches);
fpga_result (*fpgaCloneToken)(fpga_token src, fpga_token *dst);
fpga_result (*fpgaDestroyToken)(fpga_token *token);
fpga_result (*fpgaGetNumUmsg)(fpga_handle handle, uint64_t *value);
fpga_result (*fpgaSetUmsgAttributes)(fpga_handle handle,
uint64_t value);
fpga_result (*fpgaTriggerUmsg)(fpga_handle handle, uint64_t value);
fpga_result (*fpgaGetUmsgPtr)(fpga_handle handle, uint64_t **umsg_ptr);
fpga_result (*fpgaPrepareBuffer)(fpga_handle handle, uint64_t len,
void **buf_addr, uint64_t *wsid,
int flags);
fpga_result (*fpgaReleaseBuffer)(fpga_handle handle, uint64_t wsid);
fpga_result (*fpgaGetIOAddress)(fpga_handle handle, uint64_t wsid,
uint64_t *ioaddr);
fpga_result (*fpgaBindSVA)(fpga_handle handle, uint32_t *pasid);
// Internal methods between shell and plugin to pin/unpin an existing
// buffer at a specific ioaddr. Used when managing the same address
// space on parent and child AFU ports, all opened by the same process.
fpga_result (*fpgaPinBuffer)(fpga_handle handle, void *buf_addr,
uint64_t len, uint64_t ioaddr);
fpga_result (*fpgaUnpinBuffer)(fpga_handle handle, void *buf_addr,
uint64_t len, uint64_t ioaddr);
// Internal method to extract details of a workspace.
fpga_result (*fpgaGetWSInfo)(fpga_handle handle, uint64_t wsid,
uint64_t *ioaddr,
void **buf_addr, uint64_t *len);
/*
** fpga_result (*fpgaGetOPAECVersion)(fpga_version *version);
**
** fpga_result (*fpgaGetOPAECVersionString)(char *version_str,
** size_t len);
**
** fpga_result (*fpgaGetOPAECBuildString)(char *build_str, size_t
** len);
*/
fpga_result (*fpgaReadError)(fpga_token token, uint32_t error_num,
uint64_t *value);
fpga_result (*fpgaClearError)(fpga_token token, uint32_t error_num);
fpga_result (*fpgaClearAllErrors)(fpga_token token);
fpga_result (*fpgaGetErrorInfo)(fpga_token token, uint32_t error_num,
struct fpga_error_info *error_info);
/*
** const char *(*fpgaErrStr)(fpga_result e);
*/
fpga_result (*fpgaCreateEventHandle)(fpga_event_handle *event_handle);
fpga_result (*fpgaDestroyEventHandle)(fpga_event_handle *event_handle);
fpga_result (*fpgaGetOSObjectFromEventHandle)(
const fpga_event_handle eh, int *fd);
fpga_result (*fpgaRegisterEvent)(fpga_handle handle,
fpga_event_type event_type,
fpga_event_handle event_handle,
uint32_t flags);
fpga_result (*fpgaUnregisterEvent)(fpga_handle handle,
fpga_event_type event_type,
fpga_event_handle event_handle);
fpga_result (*fpgaAssignPortToInterface)(fpga_handle fpga,
uint32_t interface_num,
uint32_t slot_num, int flags);
fpga_result (*fpgaAssignToInterface)(fpga_handle fpga,
fpga_token accelerator,
uint32_t host_interface,
int flags);
fpga_result (*fpgaReleaseFromInterface)(fpga_handle fpga,
fpga_token accelerator);
fpga_result (*fpgaReconfigureSlot)(fpga_handle fpga, uint32_t slot,
const uint8_t *bitstream,
size_t bitstream_len, int flags);
fpga_result (*fpgaTokenGetObject)(fpga_token token, const char *name,
fpga_object *object, int flags);
fpga_result (*fpgaHandleGetObject)(fpga_handle handle, const char *name,
fpga_object *object, int flags);
fpga_result (*fpgaObjectGetObject)(fpga_object parent, const char *name,
fpga_object *object, int flags);
fpga_result (*fpgaObjectGetObjectAt)(fpga_object parent, size_t index,
fpga_object *object);
fpga_result (*fpgaDestroyObject)(fpga_object *obj);
fpga_result (*fpgaObjectRead)(fpga_object obj, uint8_t *buffer,
size_t offset, size_t len, int flags);
fpga_result (*fpgaObjectRead64)(fpga_object obj, uint64_t *value,
int flags);
fpga_result (*fpgaObjectGetSize)(fpga_object obj, uint64_t *value,
int flags);
fpga_result (*fpgaObjectGetType)(fpga_object obj,
enum fpga_sysobject_type *type);
fpga_result (*fpgaObjectWrite64)(fpga_object obj, uint64_t value,
int flags);
fpga_result (*fpgaSetUserClock)(fpga_handle handle, uint64_t high_clk,
uint64_t low_clk, int flags);
fpga_result (*fpgaGetUserClock)(fpga_handle handle, uint64_t *high_clk,
uint64_t *low_clk, int flags);
fpga_result (*fpgaGetNumMetrics)(fpga_handle handle, uint64_t *num_metrics);
fpga_result (*fpgaGetMetricsInfo)(fpga_handle handle,
fpga_metric_info *metric_info,
uint64_t *num_metrics);
fpga_result (*fpgaGetMetricsByIndex)(fpga_handle handle,
uint64_t *metric_num,
uint64_t num_metric_indexes,
fpga_metric *metrics);
fpga_result(*fpgaGetMetricsByName)(fpga_handle handle,
char **metrics_names,
uint64_t num_metric_names,
fpga_metric *metrics);
fpga_result(*fpgaGetMetricsThresholdInfo)(fpga_handle handle,
metric_threshold *metric_thresholds,
uint32_t *num_thresholds);
// configuration functions
int (*initialize)(void);
int (*finalize)(void);
} opae_api_adapter_table;
int opae_plugin_mgr_register_plugin(const char *name, const char *cfg);
#endif /* __OPAE_ADAPTER_H__ */