DPDK 26.07.0-rc2
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
24extern "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
58struct rte_bpf_validate_debug;
59struct rte_bpf_validate_debug_point;
60
63 int (*fn)(struct rte_bpf_validate_debug *debug, void *ctx);
64 void *ctx;
65};
66
68typedef int (*rte_bpf_validate_debug_point_process_t)(struct rte_bpf_validate_debug_point *point,
69 void *ctx);
70
78__rte_experimental
79struct rte_bpf_validate_debug *
81
90__rte_experimental
91void
92rte_bpf_validate_debug_destroy(struct rte_bpf_validate_debug *debug);
93
112__rte_experimental
113struct rte_bpf_validate_debug_point *
114rte_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
135struct rte_bpf_validate_debug_point *
136rte_bpf_validate_debug_catch(struct rte_bpf_validate_debug *debug,
138 const struct rte_bpf_validate_debug_callback *callback);
139
152__rte_experimental
153void
154rte_bpf_validate_debug_point_destroy(struct rte_bpf_validate_debug_point *point);
155
165__rte_experimental
166const struct rte_bpf_prm_ex *
167rte_bpf_validate_debug_get_bpf_param(const struct rte_bpf_validate_debug *debug);
168
181__rte_experimental
182int
183rte_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
202struct rte_bpf_validate_debug_point *
203rte_bpf_validate_debug_get_last_point(const struct rte_bpf_validate_debug *debug);
204
214__rte_experimental
215uint32_t
216rte_bpf_validate_debug_get_pc(const struct rte_bpf_validate_debug *debug);
217
230__rte_experimental
231int
232rte_bpf_validate_debug_get_validation_result(const struct rte_bpf_validate_debug *debug,
233 int *result);
234
249__rte_experimental
250int
251rte_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
270int
271rte_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
291int
292rte_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
313int
314rte_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
326int32_t
327rte_bpf_validate_debug_get_frame_size(const struct rte_bpf_validate_debug *debug);
328
345__rte_experimental
346int
347rte_bpf_validate_debug_format_value(char *buffer, size_t bufsz, char format,
348 uint64_t value);
349
368__rte_experimental
369int
370rte_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_format_frame_info(const struct rte_bpf_validate_debug *debug, char *buffer, size_t bufsz, int32_t offset)
__rte_experimental int rte_bpf_validate_debug_format_interval(char *buffer, size_t bufsz, char format, uint64_t min, uint64_t max)
int(* rte_bpf_validate_debug_point_process_t)(struct rte_bpf_validate_debug_point *point, void *ctx)
__rte_experimental const struct rte_bpf_prm_ex * rte_bpf_validate_debug_get_bpf_param(const struct rte_bpf_validate_debug *debug)
__rte_experimental int rte_bpf_validate_debug_get_validation_result(const struct rte_bpf_validate_debug *debug, int *result)
__rte_experimental uint32_t rte_bpf_validate_debug_get_pc(const struct rte_bpf_validate_debug *debug)
__rte_experimental int32_t rte_bpf_validate_debug_get_frame_size(const struct rte_bpf_validate_debug *debug)
__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 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)
__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_experimental void rte_bpf_validate_debug_destroy(struct rte_bpf_validate_debug *debug)
rte_bpf_validate_debug_event
__rte_experimental struct rte_bpf_validate_debug * rte_bpf_validate_debug_create(void)
__rte_experimental int rte_bpf_validate_debug_format_value(char *buffer, size_t bufsz, char format, uint64_t value)
__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 void rte_bpf_validate_debug_point_destroy(struct rte_bpf_validate_debug_point *point)
__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 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_get_ins(const struct rte_bpf_validate_debug *debug, const struct ebpf_insn **ins, uint32_t *nb_ins)
uint32_t nb_ins
Definition: rte_bpf.h:139
const struct ebpf_insn * ins
Definition: rte_bpf.h:138