DPDK 26.11.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 <rte_bpf.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
43 /* Just before every evaluated instruction. */
44 RTE_BPF_VALIDATE_DEBUG_EVENT_STEP,
45 /* Validator has failed its internal self-checks. */
46 RTE_BPF_VALIDATE_DEBUG_EVENT_INVALID_STATE,
47 /* Start of validation (pc points to first instruction). */
48 RTE_BPF_VALIDATE_DEBUG_EVENT_VALIDATION_START,
49 /* Successful finish (pc undefined). */
50 RTE_BPF_VALIDATE_DEBUG_EVENT_VALIDATION_SUCCESS,
51 /* Finish of validation with error (pc points at error). */
52 RTE_BPF_VALIDATE_DEBUG_EVENT_VALIDATION_FAILURE,
53 /* Beginning of a branch evaluation (pc points to branch start). */
54 RTE_BPF_VALIDATE_DEBUG_EVENT_BRANCH_ENTER,
55 /* Pruning branch as verified earlier (pc points to branch start). */
56 RTE_BPF_VALIDATE_DEBUG_EVENT_BRANCH_PRUNE,
57 /* End of branch verification (pc points to jump instruction). */
58 RTE_BPF_VALIDATE_DEBUG_EVENT_BRANCH_RETURN,
59 /* Pruning branch as dynamically unreachable (pc points to branch start). */
60 RTE_BPF_VALIDATE_DEBUG_EVENT_BRANCH_UNREACHABLE,
61 /* Program counter points to a jump-always instruction. */
62 RTE_BPF_VALIDATE_DEBUG_EVENT_JUMP_ALWAYS,
63 /* Program counter points to a conditional jump instruction. */
64 RTE_BPF_VALIDATE_DEBUG_EVENT_JUMP_CONDITIONAL,
65 /* Number of valid event values. */
66 RTE_BPF_VALIDATE_DEBUG_EVENT_END,
67};
68
69struct rte_bpf_validate_debug;
70struct rte_bpf_validate_debug_point;
71
74 int (*fn)(struct rte_bpf_validate_debug *debug, void *ctx);
75 void *ctx;
76};
77
79typedef int (*rte_bpf_validate_debug_point_process_t)(struct rte_bpf_validate_debug_point *point,
80 void *ctx);
81
89__rte_experimental
90struct rte_bpf_validate_debug *
92
101__rte_experimental
102void
103rte_bpf_validate_debug_destroy(struct rte_bpf_validate_debug *debug);
104
123__rte_experimental
124struct rte_bpf_validate_debug_point *
125rte_bpf_validate_debug_break(struct rte_bpf_validate_debug *debug, uint32_t pc,
126 const struct rte_bpf_validate_debug_callback *callback);
127
145__rte_experimental
146struct rte_bpf_validate_debug_point *
147rte_bpf_validate_debug_catch(struct rte_bpf_validate_debug *debug,
149 const struct rte_bpf_validate_debug_callback *callback);
150
163__rte_experimental
164void
165rte_bpf_validate_debug_point_destroy(struct rte_bpf_validate_debug_point *point);
166
176__rte_experimental
177const struct rte_bpf_prm_ex *
178rte_bpf_validate_debug_get_bpf_param(const struct rte_bpf_validate_debug *debug);
179
192__rte_experimental
193int
194rte_bpf_validate_debug_get_ins(const struct rte_bpf_validate_debug *debug,
195 const struct rte_ebpf_insn **ins, uint32_t *nb_ins);
196
206__rte_experimental
208rte_bpf_validate_debug_get_event(const struct rte_bpf_validate_debug *debug);
209
225__rte_experimental
226struct rte_bpf_validate_debug_point *
227rte_bpf_validate_debug_get_last_point(const struct rte_bpf_validate_debug *debug);
228
238__rte_experimental
239uint32_t
240rte_bpf_validate_debug_get_pc(const struct rte_bpf_validate_debug *debug);
241
254__rte_experimental
255int
256rte_bpf_validate_debug_get_validation_result(const struct rte_bpf_validate_debug *debug,
257 int *result);
258
273__rte_experimental
274int
275rte_bpf_validate_debug_can_access(const struct rte_bpf_validate_debug *debug,
276 const struct rte_ebpf_insn *access, uint64_t off64);
277
293__rte_experimental
294int
295rte_bpf_validate_debug_may_jump(const struct rte_bpf_validate_debug *debug,
296 const struct rte_ebpf_insn *jump, uint64_t imm64);
297
314__rte_experimental
315int
316rte_bpf_validate_debug_format_register_info(const struct rte_bpf_validate_debug *debug,
317 char *buffer, size_t bufsz, uint8_t reg);
318
336__rte_experimental
337int
338rte_bpf_validate_debug_format_frame_info(const struct rte_bpf_validate_debug *debug,
339 char *buffer, size_t bufsz, int32_t offset);
340
349__rte_experimental
350int32_t
351rte_bpf_validate_debug_get_frame_size(const struct rte_bpf_validate_debug *debug);
352
369__rte_experimental
370int
371rte_bpf_validate_debug_format_value(char *buffer, size_t bufsz, char format,
372 uint64_t value);
373
392__rte_experimental
393int
394rte_bpf_validate_debug_format_interval(char *buffer, size_t bufsz, char format,
395 uint64_t min, uint64_t max);
396
397#ifdef __cplusplus
398}
399#endif
400
401#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 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 void rte_bpf_validate_debug_destroy(struct rte_bpf_validate_debug *debug)
__rte_experimental int rte_bpf_validate_debug_can_access(const struct rte_bpf_validate_debug *debug, const struct rte_ebpf_insn *access, uint64_t off64)
rte_bpf_validate_debug_event
__rte_experimental enum rte_bpf_validate_debug_event rte_bpf_validate_debug_get_event(const struct rte_bpf_validate_debug *debug)
__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 int rte_bpf_validate_debug_may_jump(const struct rte_bpf_validate_debug *debug, const struct rte_ebpf_insn *jump, uint64_t imm64)
__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 rte_ebpf_insn **ins, uint32_t *nb_ins)
__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)
const struct rte_ebpf_insn * ins
Definition: rte_bpf.h:153
uint32_t nb_ins
Definition: rte_bpf.h:154