]>
Commit | Line | Data |
---|---|---|
0de1b425 WT |
1 | /* |
2 | * Copyright (c) 2018, 2019 Nicira, Inc. | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at: | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | ||
17 | #ifndef XDPSOCK_H | |
18 | #define XDPSOCK_H 1 | |
19 | ||
20 | #ifdef HAVE_AF_XDP | |
21 | ||
22 | #include <bpf/xsk.h> | |
23 | #include <errno.h> | |
24 | #include <stdbool.h> | |
25 | ||
26 | #include "openvswitch/thread.h" | |
27 | #include "ovs-atomic.h" | |
28 | ||
29 | /* LIFO ptr_array. */ | |
30 | struct umem_pool { | |
31 | int index; /* Point to top. */ | |
32 | unsigned int size; | |
33 | struct ovs_spin lock; | |
34 | void **array; /* A pointer array pointing to umem buf. */ | |
35 | }; | |
36 | ||
37 | /* Array-based dp_packet_afxdp. */ | |
38 | struct xpacket_pool { | |
39 | unsigned int size; | |
40 | struct dp_packet_afxdp *array; | |
41 | }; | |
42 | ||
43 | void umem_elem_push(struct umem_pool *umemp, void *addr); | |
44 | void umem_elem_push_n(struct umem_pool *umemp, int n, void **addrs); | |
45 | ||
46 | void *umem_elem_pop(struct umem_pool *umemp); | |
47 | int umem_elem_pop_n(struct umem_pool *umemp, int n, void **addrs); | |
48 | ||
49 | int umem_pool_init(struct umem_pool *umemp, unsigned int size); | |
50 | void umem_pool_cleanup(struct umem_pool *umemp); | |
51 | unsigned int umem_pool_count(struct umem_pool *umemp); | |
52 | int xpacket_pool_init(struct xpacket_pool *xp, unsigned int size); | |
53 | void xpacket_pool_cleanup(struct xpacket_pool *xp); | |
54 | ||
55 | #endif | |
56 | #endif |