DPDK  18.11.11
rte_bpf.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2018 Intel Corporation
3  */
4 
5 #ifndef _RTE_BPF_H_
6 #define _RTE_BPF_H_
7 
23 #include <rte_common.h>
24 #include <rte_mbuf.h>
25 #include <bpf_def.h>
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
37  RTE_BPF_ARG_PTR = 0x10,
39  RTE_BPF_ARG_PTR_STACK,
40 };
41 
45 struct rte_bpf_arg {
46  enum rte_bpf_arg_type type;
51  size_t size;
52  size_t buf_size;
54 };
55 
59 #define RTE_BPF_ARG_PTR_TYPE(x) ((x) & RTE_BPF_ARG_PTR)
60 
67  RTE_BPF_XTYPE_NUM
68 };
69 
73 struct rte_bpf_xsym {
74  const char *name;
76  union {
77  struct {
78  uint64_t (*val)(uint64_t, uint64_t, uint64_t,
79  uint64_t, uint64_t);
80  uint32_t nb_args;
81  struct rte_bpf_arg args[EBPF_FUNC_MAX_ARGS];
83  struct rte_bpf_arg ret;
84  } func;
85  struct {
86  void *val;
87  struct rte_bpf_arg desc;
88  } var;
89  };
90 };
91 
95 struct rte_bpf_prm {
96  const struct ebpf_insn *ins;
97  uint32_t nb_ins;
98  const struct rte_bpf_xsym *xsym;
100  uint32_t nb_xsym;
102 };
103 
107 struct rte_bpf_jit {
108  uint64_t (*func)(void *);
109  size_t sz;
110 };
111 
112 struct rte_bpf;
113 
120 void __rte_experimental
121 rte_bpf_destroy(struct rte_bpf *bpf);
122 
135 struct rte_bpf * __rte_experimental
136 rte_bpf_load(const struct rte_bpf_prm *prm);
137 
158 struct rte_bpf * __rte_experimental
159 rte_bpf_elf_load(const struct rte_bpf_prm *prm, const char *fname,
160  const char *sname);
171 uint64_t __rte_experimental
172 rte_bpf_exec(const struct rte_bpf *bpf, void *ctx);
173 
188 uint32_t __rte_experimental
189 rte_bpf_exec_burst(const struct rte_bpf *bpf, void *ctx[], uint64_t rc[],
190  uint32_t num);
191 
203 int __rte_experimental
204 rte_bpf_get_jit(const struct rte_bpf *bpf, struct rte_bpf_jit *jit);
205 
206 #ifdef __cplusplus
207 }
208 #endif
209 
210 #endif /* _RTE_BPF_H_ */
size_t buf_size
Definition: rte_bpf.h:52
struct rte_bpf_arg desc
Definition: rte_bpf.h:87
rte_bpf_arg_type
Definition: rte_bpf.h:34
void __rte_experimental rte_bpf_destroy(struct rte_bpf *bpf)
struct rte_bpf *__rte_experimental rte_bpf_load(const struct rte_bpf_prm *prm)
uint32_t nb_ins
Definition: rte_bpf.h:97
rte_bpf_xtype
Definition: rte_bpf.h:64
int __rte_experimental rte_bpf_get_jit(const struct rte_bpf *bpf, struct rte_bpf_jit *jit)
struct rte_bpf_arg args[EBPF_FUNC_MAX_ARGS]
Definition: rte_bpf.h:81
const struct ebpf_insn * ins
Definition: rte_bpf.h:96
struct rte_bpf *__rte_experimental rte_bpf_elf_load(const struct rte_bpf_prm *prm, const char *fname, const char *sname)
size_t sz
Definition: rte_bpf.h:109
struct rte_bpf_arg ret
Definition: rte_bpf.h:83
const char * name
Definition: rte_bpf.h:74
uint64_t __rte_experimental rte_bpf_exec(const struct rte_bpf *bpf, void *ctx)
size_t size
Definition: rte_bpf.h:51
struct rte_bpf_xsym::@50::@53 var
enum rte_bpf_xtype type
Definition: rte_bpf.h:75
uint32_t __rte_experimental rte_bpf_exec_burst(const struct rte_bpf *bpf, void *ctx[], uint64_t rc[], uint32_t num)
uint32_t nb_xsym
Definition: rte_bpf.h:100
uint64_t(* func)(void *)
Definition: rte_bpf.h:108
struct rte_bpf_arg prog_arg
Definition: rte_bpf.h:101
const struct rte_bpf_xsym * xsym
Definition: rte_bpf.h:98
void * val
Definition: rte_bpf.h:86