blob: 615400391e5780e38459666683177961cbc9732d [file] [log] [blame]
Alexei Starovoitov67234742021-05-13 17:36:16 -07001/* 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
6struct ksym_relo_desc {
7 const char *name;
8 int kind;
9 int insn_idx;
10};
11
12struct bpf_gen {
13 struct gen_loader_opts *opts;
14 void *data_start;
15 void *data_cur;
16 void *insn_start;
17 void *insn_cur;
Alexei Starovoitov30f51ae2021-05-13 17:36:17 -070018 ssize_t cleanup_label;
Alexei Starovoitov67234742021-05-13 17:36:16 -070019 __u32 nr_progs;
20 __u32 nr_maps;
21 int log_level;
22 int error;
23 struct ksym_relo_desc *relos;
24 int relo_cnt;
25 char attach_target[128];
26 int attach_kind;
27};
28
29void bpf_gen__init(struct bpf_gen *gen, int log_level);
30int bpf_gen__finish(struct bpf_gen *gen);
31void bpf_gen__free(struct bpf_gen *gen);
32void bpf_gen__load_btf(struct bpf_gen *gen, const void *raw_data, __u32 raw_size);
33void bpf_gen__map_create(struct bpf_gen *gen, struct bpf_create_map_attr *map_attr, int map_idx);
34struct bpf_prog_load_params;
35void bpf_gen__prog_load(struct bpf_gen *gen, struct bpf_prog_load_params *load_attr, int prog_idx);
36void bpf_gen__map_update_elem(struct bpf_gen *gen, int map_idx, void *value, __u32 value_size);
37void bpf_gen__map_freeze(struct bpf_gen *gen, int map_idx);
38void bpf_gen__record_attach_target(struct bpf_gen *gen, const char *name, enum bpf_attach_type type);
39void bpf_gen__record_extern(struct bpf_gen *gen, const char *name, int kind, int insn_idx);
40
41#endif