DPDK  22.11.5
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_compat.h>
20 #include <rte_common.h>
21 #include <rte_mbuf.h>
22 #include <bpf_def.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
34  RTE_BPF_ARG_PTR = 0x10,
37 };
38 
42 struct rte_bpf_arg {
43  enum rte_bpf_arg_type type;
48  size_t size;
49  size_t buf_size;
51 };
52 
56 #define RTE_BPF_ARG_PTR_TYPE(x) ((x) & RTE_BPF_ARG_PTR)
57 
64 };
65 
69 struct rte_bpf_xsym {
70  const char *name;
71  enum rte_bpf_xtype type;
72  union {
73  struct {
74  uint64_t (*val)(uint64_t, uint64_t, uint64_t,
75  uint64_t, uint64_t);
76  uint32_t nb_args;
77  struct rte_bpf_arg args[EBPF_FUNC_MAX_ARGS];
79  struct rte_bpf_arg ret;
80  } func;
81  struct {
82  void *val;
83  struct rte_bpf_arg desc;
84  } var;
85  };
86 };
87 
91 struct rte_bpf_prm {
92  const struct ebpf_insn *ins;
93  uint32_t nb_ins;
94  const struct rte_bpf_xsym *xsym;
96  uint32_t nb_xsym;
97  struct rte_bpf_arg prog_arg;
98 };
99 
103 struct rte_bpf_jit {
104  uint64_t (*func)(void *);
105  size_t sz;
106 };
107 
108 struct rte_bpf;
109 
116 void
117 rte_bpf_destroy(struct rte_bpf *bpf);
118 
131 struct rte_bpf *
132 rte_bpf_load(const struct rte_bpf_prm *prm);
133 
154 struct rte_bpf *
155 rte_bpf_elf_load(const struct rte_bpf_prm *prm, const char *fname,
156  const char *sname);
167 uint64_t
168 rte_bpf_exec(const struct rte_bpf *bpf, void *ctx);
169 
184 uint32_t
185 rte_bpf_exec_burst(const struct rte_bpf *bpf, void *ctx[], uint64_t rc[],
186  uint32_t num);
187 
199 int
200 rte_bpf_get_jit(const struct rte_bpf *bpf, struct rte_bpf_jit *jit);
201 
212 __rte_experimental
213 void
214 rte_bpf_dump(FILE *f, const struct ebpf_insn *buf, uint32_t len);
215 
216 struct bpf_program;
217 
232 __rte_experimental
233 struct rte_bpf_prm *
234 rte_bpf_convert(const struct bpf_program *prog);
235 
236 #ifdef __cplusplus
237 }
238 #endif
239 
240 #endif /* _RTE_BPF_H_ */
size_t buf_size
Definition: rte_bpf.h:49
rte_bpf_arg_type
Definition: rte_bpf.h:31
uint32_t nb_ins
Definition: rte_bpf.h:93
rte_bpf_xtype
Definition: rte_bpf.h:61
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:92
int rte_bpf_get_jit(const struct rte_bpf *bpf, struct rte_bpf_jit *jit)
size_t sz
Definition: rte_bpf.h:105
const char * name
Definition: rte_bpf.h:70
size_t size
Definition: rte_bpf.h:48
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:96
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:94
void * val
Definition: rte_bpf.h:82