blob: 70eccbffefb193fd5bc7e09ae0019d5c718a8b28 [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;
Kumar Kartikeya Dwivedi18f4fcc2021-10-02 06:47:56 +053010 bool is_weak;
11};
12
13struct ksym_desc {
14 const char *name;
15 int ref;
16 int kind;
17 int off;
18 int insn;
Alexei Starovoitov67234742021-05-13 17:36:16 -070019};
20
21struct 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 Starovoitov30f51ae2021-05-13 17:36:17 -070027 ssize_t cleanup_label;
Alexei Starovoitov67234742021-05-13 17:36:16 -070028 __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 Dwivedi18f4fcc2021-10-02 06:47:56 +053036 struct ksym_desc *ksyms;
37 __u32 nr_ksyms;
38 int fd_array;
39 int nr_fd_array;
Alexei Starovoitov67234742021-05-13 17:36:16 -070040};
41
42void bpf_gen__init(struct bpf_gen *gen, int log_level);
43int bpf_gen__finish(struct bpf_gen *gen);
44void bpf_gen__free(struct bpf_gen *gen);
45void bpf_gen__load_btf(struct bpf_gen *gen, const void *raw_data, __u32 raw_size);
46void bpf_gen__map_create(struct bpf_gen *gen, struct bpf_create_map_attr *map_attr, int map_idx);
47struct bpf_prog_load_params;
48void bpf_gen__prog_load(struct bpf_gen *gen, struct bpf_prog_load_params *load_attr, int prog_idx);
49void bpf_gen__map_update_elem(struct bpf_gen *gen, int map_idx, void *value, __u32 value_size);
50void bpf_gen__map_freeze(struct bpf_gen *gen, int map_idx);
51void bpf_gen__record_attach_target(struct bpf_gen *gen, const char *name, enum bpf_attach_type type);
Kumar Kartikeya Dwivedi18f4fcc2021-10-02 06:47:56 +053052void bpf_gen__record_extern(struct bpf_gen *gen, const char *name, bool is_weak, int kind,
53 int insn_idx);
Alexei Starovoitov67234742021-05-13 17:36:16 -070054
55#endif