DPDK  22.07.0
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 
19 #include <rte_common.h>
20 #include <rte_mbuf.h>
21 #include <bpf_def.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
33  RTE_BPF_ARG_PTR = 0x10,
36 };
37 
41 struct rte_bpf_arg {
42  enum rte_bpf_arg_type type;
47  size_t size;
48  size_t buf_size;
50 };
51 
55 #define RTE_BPF_ARG_PTR_TYPE(x) ((x) & RTE_BPF_ARG_PTR)
56 
63 };
64 
68 struct rte_bpf_xsym {
69  const char *name;
70  enum rte_bpf_xtype type;
71  union {
72  struct {
73  uint64_t (*val)(uint64_t, uint64_t, uint64_t,
74  uint64_t, uint64_t);
75  uint32_t nb_args;
76  struct rte_bpf_arg args[EBPF_FUNC_MAX_ARGS];
78  struct rte_bpf_arg ret;
79  } func;
80  struct {
81  void *val;
82  struct rte_bpf_arg desc;
83  } var;
84  };
85 };
86 
90 struct rte_bpf_prm {
91  const struct ebpf_insn *ins;
92  uint32_t nb_ins;
93  const struct rte_bpf_xsym *xsym;
95  uint32_t nb_xsym;
96  struct rte_bpf_arg prog_arg;
97 };
98 
102 struct rte_bpf_jit {
103  uint64_t (*func)(void *);
104  size_t sz;
105 };
106 
107 struct rte_bpf;
108 
115 void
116 rte_bpf_destroy(struct rte_bpf *bpf);
117 
130 struct rte_bpf *
131 rte_bpf_load(const struct rte_bpf_prm *prm);
132 
153 struct rte_bpf *
154 rte_bpf_elf_load(const struct rte_bpf_prm *prm, const char *fname,
155  const char *sname);
166 uint64_t
167 rte_bpf_exec(const struct rte_bpf *bpf, void *ctx);
168 
183 uint32_t
184 rte_bpf_exec_burst(const struct rte_bpf *bpf, void *ctx[], uint64_t rc[],
185  uint32_t num);
186 
198 int
199 rte_bpf_get_jit(const struct rte_bpf *bpf, struct rte_bpf_jit *jit);
200 
211 __rte_experimental
212 void
213 rte_bpf_dump(FILE *f, const struct ebpf_insn *buf, uint32_t len);
214 
215 struct bpf_program;
216 
231 __rte_experimental
232 struct rte_bpf_prm *
233 rte_bpf_convert(const struct bpf_program *prog);
234 
235 #ifdef __cplusplus
236 }
237 #endif
238 
239 #endif /* _RTE_BPF_H_ */
size_t buf_size
Definition: rte_bpf.h:48
rte_bpf_arg_type
Definition: rte_bpf.h:30
uint32_t nb_ins
Definition: rte_bpf.h:92
rte_bpf_xtype
Definition: rte_bpf.h:60
uint64_t rte_bpf_exec(const struct rte_bpf *bpf, void *ctx)
struct rte_bpf * rte_bpf_load(const struct rte_bpf_prm *prm)
const struct ebpf_insn * ins
Definition: rte_bpf.h:91
int rte_bpf_get_jit(const struct rte_bpf *bpf, struct rte_bpf_jit *jit)
size_t sz
Definition: rte_bpf.h:104
const char * name
Definition: rte_bpf.h:69
size_t size
Definition: rte_bpf.h:47
struct rte_bpf * rte_bpf_elf_load(const struct rte_bpf_prm *prm, const char *fname, const char *sname)
uint32_t nb_xsym
Definition: rte_bpf.h:95
uint32_t rte_bpf_exec_burst(const struct rte_bpf *bpf, void *ctx[], uint64_t rc[], uint32_t num)
__rte_experimental struct rte_bpf_prm * rte_bpf_convert(const struct bpf_program *prog)
__rte_experimental void rte_bpf_dump(FILE *f, const struct ebpf_insn *buf, uint32_t len)
void rte_bpf_destroy(struct rte_bpf *bpf)
const struct rte_bpf_xsym * xsym
Definition: rte_bpf.h:93
void * val
Definition: rte_bpf.h:81