DPDK  19.08.2
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,
35  RTE_BPF_ARG_PTR_STACK,
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  RTE_BPF_XTYPE_NUM
64 };
65 
69 struct rte_bpf_xsym {
70  const char *name;
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;
98 };
99 
103 struct rte_bpf_jit {
104  uint64_t (*func)(void *);
105  size_t sz;
106 };
107 
108 struct rte_bpf;
109 
116 __rte_experimental
117 void
118 rte_bpf_destroy(struct rte_bpf *bpf);
119 
132 __rte_experimental
133 struct rte_bpf *
134 rte_bpf_load(const struct rte_bpf_prm *prm);
135 
156 __rte_experimental
157 struct rte_bpf *
158 rte_bpf_elf_load(const struct rte_bpf_prm *prm, const char *fname,
159  const char *sname);
170 __rte_experimental
171 uint64_t
172 rte_bpf_exec(const struct rte_bpf *bpf, void *ctx);
173 
188 __rte_experimental
189 uint32_t
190 rte_bpf_exec_burst(const struct rte_bpf *bpf, void *ctx[], uint64_t rc[],
191  uint32_t num);
192 
204 __rte_experimental
205 int
206 rte_bpf_get_jit(const struct rte_bpf *bpf, struct rte_bpf_jit *jit);
207 
208 #ifdef __cplusplus
209 }
210 #endif
211 
212 #endif /* _RTE_BPF_H_ */
size_t buf_size
Definition: rte_bpf.h:48
struct rte_bpf_arg desc
Definition: rte_bpf.h:83
rte_bpf_arg_type
Definition: rte_bpf.h:30
uint32_t nb_ins
Definition: rte_bpf.h:93
rte_bpf_xtype
Definition: rte_bpf.h:60
struct rte_bpf_arg args[EBPF_FUNC_MAX_ARGS]
Definition: rte_bpf.h:77
__rte_experimental uint64_t rte_bpf_exec(const struct rte_bpf *bpf, void *ctx)
const struct ebpf_insn * ins
Definition: rte_bpf.h:92
__rte_experimental uint32_t rte_bpf_exec_burst(const struct rte_bpf *bpf, void *ctx[], uint64_t rc[], uint32_t num)
struct rte_bpf_xsym::@59::@62 var
__rte_experimental int rte_bpf_get_jit(const struct rte_bpf *bpf, struct rte_bpf_jit *jit)
size_t sz
Definition: rte_bpf.h:105
struct rte_bpf_arg ret
Definition: rte_bpf.h:79
const char * name
Definition: rte_bpf.h:70
__rte_experimental struct rte_bpf * rte_bpf_load(const struct rte_bpf_prm *prm)
size_t size
Definition: rte_bpf.h:47
__rte_experimental struct rte_bpf * rte_bpf_elf_load(const struct rte_bpf_prm *prm, const char *fname, const char *sname)
enum rte_bpf_xtype type
Definition: rte_bpf.h:71
uint32_t nb_xsym
Definition: rte_bpf.h:96
uint64_t(* func)(void *)
Definition: rte_bpf.h:104
__rte_experimental void rte_bpf_destroy(struct rte_bpf *bpf)
struct rte_bpf_arg prog_arg
Definition: rte_bpf.h:97
const struct rte_bpf_xsym * xsym
Definition: rte_bpf.h:94
void * val
Definition: rte_bpf.h:82