DPDK  26.07.0
rte_bpf_validate_debug.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2025 Huawei Technologies Co., Ltd
3  */
4 
5 #ifndef _RTE_BPF_VALIDATE_DEBUG_H_
6 #define _RTE_BPF_VALIDATE_DEBUG_H_
7 
16 #include <bpf_def.h>
17 #include <rte_compat.h>
18 
19 #include <stdbool.h>
20 #include <stddef.h>
21 #include <stdint.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #define RTE_BPF_VALIDATE_DEBUG_MAY_BE_FALSE RTE_BIT32(0)
28 #define RTE_BPF_VALIDATE_DEBUG_MAY_BE_TRUE RTE_BIT32(1)
29 
36  /* Just before every instruction, at branch or validation end. */
37  RTE_BPF_VALIDATE_DEBUG_EVENT_STEP,
38  /* Validator has failed its internal self-checks. */
39  RTE_BPF_VALIDATE_DEBUG_EVENT_INVALID_STATE,
40  /* Start of validation. */
41  RTE_BPF_VALIDATE_DEBUG_EVENT_VALIDATION_START,
42  /* Successful finish of validation. */
43  RTE_BPF_VALIDATE_DEBUG_EVENT_VALIDATION_SUCCESS,
44  /* Finish of validation with error. */
45  RTE_BPF_VALIDATE_DEBUG_EVENT_VALIDATION_FAILURE,
46  /* Beginning of a branch just after the jump. */
47  RTE_BPF_VALIDATE_DEBUG_EVENT_BRANCH_ENTER,
48  /* Pruning branch as verified earlier. */
49  RTE_BPF_VALIDATE_DEBUG_EVENT_BRANCH_PRUNE,
50  /* End of branch verification, after the last verified instruction. */
51  RTE_BPF_VALIDATE_DEBUG_EVENT_BRANCH_RETURN,
52  /* Pruning branch as dynamically unreachable. */
53  RTE_BPF_VALIDATE_DEBUG_EVENT_BRANCH_UNREACHABLE,
54  /* Number of valid event values. */
55  RTE_BPF_VALIDATE_DEBUG_EVENT_END,
56 };
57 
58 struct rte_bpf_validate_debug;
59 struct rte_bpf_validate_debug_point;
60 
63  int (*fn)(struct rte_bpf_validate_debug *debug, void *ctx);
64  void *ctx;
65 };
66 
68 typedef int (*rte_bpf_validate_debug_point_process_t)(struct rte_bpf_validate_debug_point *point,
69  void *ctx);
70 
78 __rte_experimental
79 struct rte_bpf_validate_debug *
81 
90 __rte_experimental
91 void
92 rte_bpf_validate_debug_destroy(struct rte_bpf_validate_debug *debug);
93 
112 __rte_experimental
113 struct rte_bpf_validate_debug_point *
114 rte_bpf_validate_debug_break(struct rte_bpf_validate_debug *debug, uint32_t pc,
115  const struct rte_bpf_validate_debug_callback *callback);
116 
134 __rte_experimental
135 struct rte_bpf_validate_debug_point *
136 rte_bpf_validate_debug_catch(struct rte_bpf_validate_debug *debug,
137  enum rte_bpf_validate_debug_event event,
138  const struct rte_bpf_validate_debug_callback *callback);
139 
152 __rte_experimental
153 void
154 rte_bpf_validate_debug_point_destroy(struct rte_bpf_validate_debug_point *point);
155 
165 __rte_experimental
166 const struct rte_bpf_prm_ex *
167 rte_bpf_validate_debug_get_bpf_param(const struct rte_bpf_validate_debug *debug);
168 
181 __rte_experimental
182 int
183 rte_bpf_validate_debug_get_ins(const struct rte_bpf_validate_debug *debug,
184  const struct ebpf_insn **ins, uint32_t *nb_ins);
185 
201 __rte_experimental
202 struct rte_bpf_validate_debug_point *
203 rte_bpf_validate_debug_get_last_point(const struct rte_bpf_validate_debug *debug);
204 
214 __rte_experimental
215 uint32_t
216 rte_bpf_validate_debug_get_pc(const struct rte_bpf_validate_debug *debug);
217 
230 __rte_experimental
231 int
232 rte_bpf_validate_debug_get_validation_result(const struct rte_bpf_validate_debug *debug,
233  int *result);
234 
249 __rte_experimental
250 int
251 rte_bpf_validate_debug_can_access(const struct rte_bpf_validate_debug *debug,
252  const struct ebpf_insn *access, uint64_t off64);
253 
269 __rte_experimental
270 int
271 rte_bpf_validate_debug_may_jump(const struct rte_bpf_validate_debug *debug,
272  const struct ebpf_insn *jump, uint64_t imm64);
273 
290 __rte_experimental
291 int
292 rte_bpf_validate_debug_format_register_info(const struct rte_bpf_validate_debug *debug,
293  char *buffer, size_t bufsz, uint8_t reg);
294 
312 __rte_experimental
313 int
314 rte_bpf_validate_debug_format_frame_info(const struct rte_bpf_validate_debug *debug,
315  char *buffer, size_t bufsz, int32_t offset);
316 
325 __rte_experimental
326 int32_t
327 rte_bpf_validate_debug_get_frame_size(const struct rte_bpf_validate_debug *debug);
328 
345 __rte_experimental
346 int
347 rte_bpf_validate_debug_format_value(char *buffer, size_t bufsz, char format,
348  uint64_t value);
349 
368 __rte_experimental
369 int
370 rte_bpf_validate_debug_format_interval(char *buffer, size_t bufsz, char format,
371  uint64_t min, uint64_t max);
372 
373 #ifdef __cplusplus
374 }
375 #endif
376 
377 #endif /* _RTE_BPF_VALIDATE_DEBUG_H_ */
__rte_experimental int rte_bpf_validate_debug_can_access(const struct rte_bpf_validate_debug *debug, const struct ebpf_insn *access, uint64_t off64)
__rte_experimental int32_t rte_bpf_validate_debug_get_frame_size(const struct rte_bpf_validate_debug *debug)
__rte_experimental struct rte_bpf_validate_debug_point * rte_bpf_validate_debug_break(struct rte_bpf_validate_debug *debug, uint32_t pc, const struct rte_bpf_validate_debug_callback *callback)
__rte_experimental int rte_bpf_validate_debug_get_ins(const struct rte_bpf_validate_debug *debug, const struct ebpf_insn **ins, uint32_t *nb_ins)
__rte_experimental uint32_t rte_bpf_validate_debug_get_pc(const struct rte_bpf_validate_debug *debug)
__rte_experimental int rte_bpf_validate_debug_may_jump(const struct rte_bpf_validate_debug *debug, const struct ebpf_insn *jump, uint64_t imm64)
rte_bpf_validate_debug_event
__rte_experimental int rte_bpf_validate_debug_format_interval(char *buffer, size_t bufsz, char format, uint64_t min, uint64_t max)
__rte_experimental int rte_bpf_validate_debug_format_register_info(const struct rte_bpf_validate_debug *debug, char *buffer, size_t bufsz, uint8_t reg)
__rte_experimental int rte_bpf_validate_debug_format_frame_info(const struct rte_bpf_validate_debug *debug, char *buffer, size_t bufsz, int32_t offset)
const struct ebpf_insn * ins
Definition: rte_bpf.h:138
__rte_experimental const struct rte_bpf_prm_ex * rte_bpf_validate_debug_get_bpf_param(const struct rte_bpf_validate_debug *debug)
__rte_experimental void rte_bpf_validate_debug_destroy(struct rte_bpf_validate_debug *debug)
uint32_t nb_ins
Definition: rte_bpf.h:139
__rte_experimental struct rte_bpf_validate_debug_point * rte_bpf_validate_debug_get_last_point(const struct rte_bpf_validate_debug *debug)
__rte_experimental int rte_bpf_validate_debug_format_value(char *buffer, size_t bufsz, char format, uint64_t value)
__rte_experimental int rte_bpf_validate_debug_get_validation_result(const struct rte_bpf_validate_debug *debug, int *result)
__rte_experimental void rte_bpf_validate_debug_point_destroy(struct rte_bpf_validate_debug_point *point)
__rte_experimental struct rte_bpf_validate_debug * rte_bpf_validate_debug_create(void)
int(* rte_bpf_validate_debug_point_process_t)(struct rte_bpf_validate_debug_point *point, void *ctx)
__rte_experimental struct rte_bpf_validate_debug_point * rte_bpf_validate_debug_catch(struct rte_bpf_validate_debug *debug, enum rte_bpf_validate_debug_event event, const struct rte_bpf_validate_debug_callback *callback)