DPDK  20.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_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;
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;
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 
201 #ifdef __cplusplus
202 }
203 #endif
204 
205 #endif /* _RTE_BPF_H_ */
rte_bpf_jit
Definition: rte_bpf.h:102
rte_bpf_exec_burst
uint32_t rte_bpf_exec_burst(const struct rte_bpf *bpf, void *ctx[], uint64_t rc[], uint32_t num)
rte_bpf_prm::ins
const struct ebpf_insn * ins
Definition: rte_bpf.h:91
rte_bpf_xtype
rte_bpf_xtype
Definition: rte_bpf.h:60
rte_bpf_jit::sz
size_t sz
Definition: rte_bpf.h:104
RTE_BPF_ARG_UNDEF
@ RTE_BPF_ARG_UNDEF
Definition: rte_bpf.h:31
rte_bpf_xsym::args
struct rte_bpf_arg args[EBPF_FUNC_MAX_ARGS]
Definition: rte_bpf.h:76
rte_bpf_prm::xsym
const struct rte_bpf_xsym * xsym
Definition: rte_bpf.h:93
rte_bpf_xsym::val
void * val
Definition: rte_bpf.h:81
rte_bpf_prm
Definition: rte_bpf.h:90
rte_bpf_xsym::ret
struct rte_bpf_arg ret
Definition: rte_bpf.h:78
rte_bpf_exec
uint64_t rte_bpf_exec(const struct rte_bpf *bpf, void *ctx)
RTE_BPF_XTYPE_FUNC
@ RTE_BPF_XTYPE_FUNC
Definition: rte_bpf.h:61
rte_bpf_arg
Definition: rte_bpf.h:41
RTE_BPF_ARG_PTR_MBUF
@ RTE_BPF_ARG_PTR_MBUF
Definition: rte_bpf.h:34
rte_bpf_load
struct rte_bpf * rte_bpf_load(const struct rte_bpf_prm *prm)
rte_bpf_prm::nb_ins
uint32_t nb_ins
Definition: rte_bpf.h:92
rte_bpf_get_jit
int rte_bpf_get_jit(const struct rte_bpf *bpf, struct rte_bpf_jit *jit)
rte_common.h
rte_bpf_xsym::name
const char * name
Definition: rte_bpf.h:69
rte_bpf_arg_type
rte_bpf_arg_type
Definition: rte_bpf.h:30
rte_bpf_arg::buf_size
size_t buf_size
Definition: rte_bpf.h:48
RTE_BPF_ARG_RAW
@ RTE_BPF_ARG_RAW
Definition: rte_bpf.h:32
rte_bpf_xsym
Definition: rte_bpf.h:68
rte_bpf_prm::prog_arg
struct rte_bpf_arg prog_arg
Definition: rte_bpf.h:96
rte_mbuf.h
rte_bpf_jit::func
uint64_t(* func)(void *)
Definition: rte_bpf.h:103
rte_bpf_xsym::var
struct rte_bpf_xsym::@79::@82 var
RTE_BPF_ARG_RESERVED
@ RTE_BPF_ARG_RESERVED
Definition: rte_bpf.h:35
rte_bpf_xsym::desc
struct rte_bpf_arg desc
Definition: rte_bpf.h:82
rte_bpf_prm::nb_xsym
uint32_t nb_xsym
Definition: rte_bpf.h:95
RTE_BPF_ARG_PTR
@ RTE_BPF_ARG_PTR
Definition: rte_bpf.h:33
rte_bpf_xsym::type
enum rte_bpf_xtype type
Definition: rte_bpf.h:70
rte_bpf_destroy
void rte_bpf_destroy(struct rte_bpf *bpf)
rte_bpf_elf_load
struct rte_bpf * rte_bpf_elf_load(const struct rte_bpf_prm *prm, const char *fname, const char *sname)
RTE_BPF_XTYPE_VAR
@ RTE_BPF_XTYPE_VAR
Definition: rte_bpf.h:62
rte_bpf_arg::size
size_t size
Definition: rte_bpf.h:47