Alexei Starovoitov | 6723474 | 2021-05-13 17:36:16 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ |
| 2 | /* Copyright (c) 2021 Facebook */ |
| 3 | #ifndef __BPF_GEN_INTERNAL_H |
| 4 | #define __BPF_GEN_INTERNAL_H |
| 5 | |
| 6 | struct ksym_relo_desc { |
| 7 | const char *name; |
| 8 | int kind; |
| 9 | int insn_idx; |
Kumar Kartikeya Dwivedi | 18f4fcc | 2021-10-02 06:47:56 +0530 | [diff] [blame] | 10 | bool is_weak; |
| 11 | }; |
| 12 | |
| 13 | struct ksym_desc { |
| 14 | const char *name; |
| 15 | int ref; |
| 16 | int kind; |
| 17 | int off; |
| 18 | int insn; |
Alexei Starovoitov | 6723474 | 2021-05-13 17:36:16 -0700 | [diff] [blame] | 19 | }; |
| 20 | |
| 21 | struct bpf_gen { |
| 22 | struct gen_loader_opts *opts; |
| 23 | void *data_start; |
| 24 | void *data_cur; |
| 25 | void *insn_start; |
| 26 | void *insn_cur; |
Alexei Starovoitov | 30f51ae | 2021-05-13 17:36:17 -0700 | [diff] [blame] | 27 | ssize_t cleanup_label; |
Alexei Starovoitov | 6723474 | 2021-05-13 17:36:16 -0700 | [diff] [blame] | 28 | __u32 nr_progs; |
| 29 | __u32 nr_maps; |
| 30 | int log_level; |
| 31 | int error; |
| 32 | struct ksym_relo_desc *relos; |
| 33 | int relo_cnt; |
| 34 | char attach_target[128]; |
| 35 | int attach_kind; |
Kumar Kartikeya Dwivedi | 18f4fcc | 2021-10-02 06:47:56 +0530 | [diff] [blame] | 36 | struct ksym_desc *ksyms; |
| 37 | __u32 nr_ksyms; |
| 38 | int fd_array; |
| 39 | int nr_fd_array; |
Alexei Starovoitov | 6723474 | 2021-05-13 17:36:16 -0700 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | void bpf_gen__init(struct bpf_gen *gen, int log_level); |
| 43 | int bpf_gen__finish(struct bpf_gen *gen); |
| 44 | void bpf_gen__free(struct bpf_gen *gen); |
| 45 | void bpf_gen__load_btf(struct bpf_gen *gen, const void *raw_data, __u32 raw_size); |
| 46 | void bpf_gen__map_create(struct bpf_gen *gen, struct bpf_create_map_attr *map_attr, int map_idx); |
| 47 | struct bpf_prog_load_params; |
| 48 | void bpf_gen__prog_load(struct bpf_gen *gen, struct bpf_prog_load_params *load_attr, int prog_idx); |
| 49 | void bpf_gen__map_update_elem(struct bpf_gen *gen, int map_idx, void *value, __u32 value_size); |
| 50 | void bpf_gen__map_freeze(struct bpf_gen *gen, int map_idx); |
| 51 | void bpf_gen__record_attach_target(struct bpf_gen *gen, const char *name, enum bpf_attach_type type); |
Kumar Kartikeya Dwivedi | 18f4fcc | 2021-10-02 06:47:56 +0530 | [diff] [blame] | 52 | void bpf_gen__record_extern(struct bpf_gen *gen, const char *name, bool is_weak, int kind, |
| 53 | int insn_idx); |
Alexei Starovoitov | 6723474 | 2021-05-13 17:36:16 -0700 | [diff] [blame] | 54 | |
| 55 | #endif |