DPDK  20.08.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 
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,
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 __rte_experimental
121 void
122 rte_bpf_destroy(struct rte_bpf *bpf);
123 
136 __rte_experimental
137 struct rte_bpf *
138 rte_bpf_load(const struct rte_bpf_prm *prm);
139 
160 __rte_experimental
161 struct rte_bpf *
162 rte_bpf_elf_load(const struct rte_bpf_prm *prm, const char *fname,
163  const char *sname);
174 __rte_experimental
175 uint64_t
176 rte_bpf_exec(const struct rte_bpf *bpf, void *ctx);
177 
192 __rte_experimental
193 uint32_t
194 rte_bpf_exec_burst(const struct rte_bpf *bpf, void *ctx[], uint64_t rc[],
195  uint32_t num);
196 
208 __rte_experimental
209 int
210 rte_bpf_get_jit(const struct rte_bpf *bpf, struct rte_bpf_jit *jit);
211 
212 #ifdef __cplusplus
213 }
214 #endif
215 
216 #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
uint32_t nb_ins
Definition: rte_bpf.h:97
rte_bpf_xtype
Definition: rte_bpf.h:64
struct rte_bpf_arg args[EBPF_FUNC_MAX_ARGS]
Definition: rte_bpf.h:81
__rte_experimental uint64_t rte_bpf_exec(const struct rte_bpf *bpf, void *ctx)
const struct ebpf_insn * ins
Definition: rte_bpf.h:96
__rte_experimental uint32_t rte_bpf_exec_burst(const struct rte_bpf *bpf, void *ctx[], uint64_t rc[], uint32_t num)
__rte_experimental int rte_bpf_get_jit(const struct rte_bpf *bpf, struct rte_bpf_jit *jit)
struct rte_bpf_xsym::@67::@70 var
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
__rte_experimental struct rte_bpf * rte_bpf_load(const struct rte_bpf_prm *prm)
size_t size
Definition: rte_bpf.h:51
__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:75
uint32_t nb_xsym
Definition: rte_bpf.h:100
uint64_t(* func)(void *)
Definition: rte_bpf.h:108
__rte_experimental void rte_bpf_destroy(struct rte_bpf *bpf)
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