1
2
3
4
5
6#ifndef _RTE_AVP_COMMON_H_
7#define _RTE_AVP_COMMON_H_
8
9#ifdef __KERNEL__
10#include <linux/if.h>
11#define RTE_STD_C11
12#else
13#include <stdint.h>
14#include <rte_common.h>
15#include <rte_config.h>
16#include <rte_memory.h>
17#include <rte_ether.h>
18#include <rte_atomic.h>
19#endif
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25
26
27
28#define RTE_AVP_NAMESIZE 32
29
30
31
32
33
34#define RTE_AVP_ALIASSIZE 128
35
36
37
38
39enum rte_avp_req_id {
40 RTE_AVP_REQ_UNKNOWN = 0,
41 RTE_AVP_REQ_CHANGE_MTU,
42 RTE_AVP_REQ_CFG_NETWORK_IF,
43 RTE_AVP_REQ_CFG_DEVICE,
44 RTE_AVP_REQ_SHUTDOWN_DEVICE,
45 RTE_AVP_REQ_MAX,
46};
47
48
49#define RTE_AVP_DRIVER_TYPE_UNKNOWN 0
50#define RTE_AVP_DRIVER_TYPE_DPDK 1
51#define RTE_AVP_DRIVER_TYPE_KERNEL 2
52#define RTE_AVP_DRIVER_TYPE_QEMU 3
53
54
55
56#define RTE_AVP_MODE_HOST 0
57#define RTE_AVP_MODE_GUEST 1
58#define RTE_AVP_MODE_TRACE 2
59
60
61
62
63
64struct rte_avp_device_config {
65 uint64_t device_id;
66 uint32_t driver_type;
67 uint32_t driver_version;
68 uint32_t features;
69 uint16_t num_tx_queues;
70 uint16_t num_rx_queues;
71 uint8_t if_up;
72} __rte_packed;
73
74
75
76
77struct rte_avp_request {
78 uint32_t req_id;
79 RTE_STD_C11
80 union {
81 uint32_t new_mtu;
82 uint8_t if_up;
83 struct rte_avp_device_config config;
84 };
85 int32_t result;
86} __rte_packed;
87
88
89
90
91
92
93struct rte_avp_fifo {
94 volatile unsigned int write;
95 volatile unsigned int read;
96 unsigned int len;
97 unsigned int elem_size;
98 void *volatile buffer[];
99};
100
101
102
103
104
105struct rte_avp_desc {
106 uint64_t pad0;
107 void *pkt_mbuf;
108 uint8_t pad1[14];
109 uint16_t ol_flags;
110 void *next;
111 void *data;
112 uint16_t data_len;
113 uint8_t nb_segs;
114 uint8_t pad2;
115 uint16_t pkt_len;
116 uint32_t pad3;
117 uint16_t vlan_tci;
118 uint32_t pad4;
119} __rte_packed __rte_cache_aligned;
120
121
122
123#define RTE_AVP_FEATURE_VLAN_OFFLOAD (1 << 0)
124
125
126
127
128#define RTE_AVP_TX_VLAN_PKT 0x0001
129#define RTE_AVP_RX_VLAN_PKT 0x0800
130
131
132
133
134#define RTE_AVP_PCI_VENDOR_ID 0x1af4
135#define RTE_AVP_PCI_DEVICE_ID 0x1110
136
137
138
139#define RTE_AVP_PCI_SUB_VENDOR_ID RTE_AVP_PCI_VENDOR_ID
140#define RTE_AVP_PCI_SUB_DEVICE_ID 0x1104
141
142
143
144#define RTE_AVP_PCI_MMIO_BAR 0
145#define RTE_AVP_PCI_MSIX_BAR 1
146#define RTE_AVP_PCI_MEMORY_BAR 2
147#define RTE_AVP_PCI_MEMMAP_BAR 4
148#define RTE_AVP_PCI_DEVICE_BAR 5
149#define RTE_AVP_PCI_MAX_BAR 6
150
151
152
153#define RTE_AVP_MMIO_BAR_NAME "avp-mmio"
154#define RTE_AVP_MSIX_BAR_NAME "avp-msix"
155#define RTE_AVP_MEMORY_BAR_NAME "avp-memory"
156#define RTE_AVP_MEMMAP_BAR_NAME "avp-memmap"
157#define RTE_AVP_DEVICE_BAR_NAME "avp-device"
158
159
160
161#define RTE_AVP_MIGRATION_MSIX_VECTOR 0
162#define RTE_AVP_MAX_MSIX_VECTORS 1
163
164
165
166#define RTE_AVP_MIGRATION_NONE 0
167#define RTE_AVP_MIGRATION_DETACHED 1
168#define RTE_AVP_MIGRATION_ATTACHED 2
169#define RTE_AVP_MIGRATION_ERROR 3
170
171
172
173#define RTE_AVP_REGISTER_BASE 0
174#define RTE_AVP_INTERRUPT_MASK_OFFSET (RTE_AVP_REGISTER_BASE + 0)
175#define RTE_AVP_INTERRUPT_STATUS_OFFSET (RTE_AVP_REGISTER_BASE + 4)
176#define RTE_AVP_MIGRATION_STATUS_OFFSET (RTE_AVP_REGISTER_BASE + 8)
177#define RTE_AVP_MIGRATION_ACK_OFFSET (RTE_AVP_REGISTER_BASE + 12)
178
179
180
181#define RTE_AVP_MIGRATION_INTERRUPT_MASK (1 << 1)
182#define RTE_AVP_APP_INTERRUPTS_MASK 0xFFFFFFFF
183#define RTE_AVP_NO_INTERRUPTS_MASK 0
184
185
186
187
188
189#define RTE_AVP_MAX_MAPS 2048
190
191
192
193
194struct rte_avp_memmap {
195 void *addr;
196 rte_iova_t phys_addr;
197 uint64_t length;
198};
199
200
201
202
203#define RTE_AVP_MEMMAP_MAGIC 0x20131969
204
205
206#define RTE_AVP_MEMMAP_VERSION_1 1
207#define RTE_AVP_MEMMAP_VERSION RTE_AVP_MEMMAP_VERSION_1
208
209
210
211
212
213struct rte_avp_memmap_info {
214 uint32_t magic;
215 uint32_t version;
216 uint32_t nb_maps;
217 struct rte_avp_memmap maps[RTE_AVP_MAX_MAPS];
218};
219
220
221
222
223#define RTE_AVP_DEVICE_MAGIC 0x20131975
224
225
226
227
228
229
230#define RTE_AVP_RELEASE_VERSION_1 1
231#define RTE_AVP_RELEASE_VERSION RTE_AVP_RELEASE_VERSION_1
232#define RTE_AVP_MAJOR_VERSION_0 0
233#define RTE_AVP_MAJOR_VERSION_1 1
234#define RTE_AVP_MAJOR_VERSION_2 2
235#define RTE_AVP_MAJOR_VERSION RTE_AVP_MAJOR_VERSION_2
236#define RTE_AVP_MINOR_VERSION_0 0
237#define RTE_AVP_MINOR_VERSION_1 1
238#define RTE_AVP_MINOR_VERSION_13 13
239#define RTE_AVP_MINOR_VERSION RTE_AVP_MINOR_VERSION_13
240
241
242
243
244
245
246
247#define RTE_AVP_MAKE_VERSION(_release, _major, _minor) \
248((((_release) & 0xffff) << 16) | (((_major) & 0xff) << 8) | ((_minor) & 0xff))
249
250
251
252
253
254
255
256
257
258#define RTE_AVP_CURRENT_HOST_VERSION \
259RTE_AVP_MAKE_VERSION(RTE_AVP_RELEASE_VERSION_1, \
260 RTE_AVP_MAJOR_VERSION_0, \
261 RTE_AVP_MINOR_VERSION_1)
262
263
264
265
266
267#define RTE_AVP_CURRENT_GUEST_VERSION \
268RTE_AVP_MAKE_VERSION(RTE_AVP_RELEASE_VERSION_1, \
269 RTE_AVP_MAJOR_VERSION_2, \
270 RTE_AVP_MINOR_VERSION_13)
271
272
273
274
275#define RTE_AVP_GET_RELEASE_VERSION(_version) (((_version) >> 16) & 0xffff)
276#define RTE_AVP_GET_MAJOR_VERSION(_version) (((_version) >> 8) & 0xff)
277#define RTE_AVP_GET_MINOR_VERSION(_version) ((_version) & 0xff)
278
279
280
281
282
283
284
285#define RTE_AVP_STRIP_MINOR_VERSION(_version) ((_version) >> 8)
286
287
288
289
290
291#define RTE_AVP_MAX_MEMPOOLS 8
292
293
294
295
296struct rte_avp_mempool_info {
297 void *addr;
298 rte_iova_t phys_addr;
299 uint64_t length;
300};
301
302
303
304
305
306struct rte_avp_device_info {
307 uint32_t magic;
308 uint32_t version;
309
310 char ifname[RTE_AVP_NAMESIZE];
311
312 rte_iova_t tx_phys;
313 rte_iova_t rx_phys;
314 rte_iova_t alloc_phys;
315 rte_iova_t free_phys;
316
317 uint32_t features;
318 uint8_t min_rx_queues;
319 uint8_t num_rx_queues;
320 uint8_t max_rx_queues;
321 uint8_t min_tx_queues;
322 uint8_t num_tx_queues;
323
324 uint8_t max_tx_queues;
325
326 uint32_t tx_size;
327 uint32_t rx_size;
328 uint32_t alloc_size;
329 uint32_t free_size;
330
331
332 rte_iova_t req_phys;
333 rte_iova_t resp_phys;
334 rte_iova_t sync_phys;
335 void *sync_va;
336
337
338 void *mbuf_va;
339 rte_iova_t mbuf_phys;
340
341
342 struct rte_avp_mempool_info pool[RTE_AVP_MAX_MEMPOOLS];
343
344#ifdef __KERNEL__
345
346 char ethaddr[ETH_ALEN];
347#else
348 char ethaddr[RTE_ETHER_ADDR_LEN];
349#endif
350
351 uint8_t mode;
352
353
354 unsigned int mbuf_size;
355
356
357
358
359
360
361 uint64_t device_id;
362
363 uint32_t max_rx_pkt_len;
364};
365
366#define RTE_AVP_MAX_QUEUES 8
367
368
369#define RTE_AVP_MAX_MBUF_SEGMENTS 5
370
371#define RTE_AVP_DEVICE "avp"
372
373#define RTE_AVP_IOCTL_TEST _IOWR(0, 1, int)
374#define RTE_AVP_IOCTL_CREATE _IOWR(0, 2, struct rte_avp_device_info)
375#define RTE_AVP_IOCTL_RELEASE _IOWR(0, 3, struct rte_avp_device_info)
376#define RTE_AVP_IOCTL_QUERY _IOWR(0, 4, struct rte_avp_device_config)
377
378#ifdef __cplusplus
379}
380#endif
381
382#endif
383