| 1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
| 2 |
#ifndef __BPF_LOAD_H |
| 3 |
#define __BPF_LOAD_H |
| 4 |
|
| 5 |
#define MAX_MAPS 32 |
| 6 |
#define MAX_PROGS 64 |
| 7 |
|
| 8 |
struct bpf_load_map_def { |
| 9 |
unsigned int type; |
| 10 |
unsigned int key_size; |
| 11 |
unsigned int value_size; |
| 12 |
unsigned int max_entries; |
| 13 |
unsigned int map_flags; |
| 14 |
unsigned int inner_map_idx; |
| 15 |
unsigned int numa_node; |
| 16 |
}; |
| 17 |
|
| 18 |
struct bpf_map_data { |
| 19 |
int fd; |
| 20 |
char *name; |
| 21 |
size_t elf_offset; |
| 22 |
struct bpf_load_map_def def; |
| 23 |
}; |
| 24 |
|
| 25 |
/* parses elf file compiled by llvm .c->.o |
| 26 |
* . parses 'maps' section and creates maps via BPF syscall |
| 27 |
* . parses 'license' section and passes it to syscall |
| 28 |
* . parses elf relocations for BPF maps and adjusts BPF_LD_IMM64 insns by |
| 29 |
* storing map_fd into insn->imm and marking such insns as BPF_PSEUDO_MAP_FD |
| 30 |
* . loads eBPF programs via BPF syscall |
| 31 |
* |
| 32 |
* One ELF file can contain multiple BPF programs which will be loaded |
| 33 |
* and their FDs stored stored in prog_fd array |
| 34 |
* |
| 35 |
* returns zero on success |
| 36 |
*/ |
| 37 |
int load_bpf_file(const char *path, int lirc_fd, struct protocol_param *param, struct raw_entry *raw); |
| 38 |
|
| 39 |
int bpf_param(struct protocol_param *param, const char *name, int *val); |
| 40 |
|
| 41 |
#endif |