blob: 47897d65e799b31e812ac3bf02ad0584756c823d [file] [log] [blame]
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001// SPDX-License-Identifier: GPL-2.0
2#ifndef _PERF_BPF_H
3#define _PERF_BPF_H
4
5#include <uapi/linux/bpf.h>
6
7/*
8 * A helper structure used by eBPF C program to describe map attributes to
9 * elf_bpf loader, taken from tools/testing/selftests/bpf/bpf_helpers.h:
10 */
11struct bpf_map {
12 unsigned int type;
13 unsigned int key_size;
14 unsigned int value_size;
15 unsigned int max_entries;
16 unsigned int map_flags;
17 unsigned int inner_map_idx;
18 unsigned int numa_node;
19};
20
21#define SEC(NAME) __attribute__((section(NAME), used))
22
23#define probe(function, vars) \
24 SEC(#function "=" #function " " #vars) function
25
26#define syscall_enter(name) \
27 SEC("syscalls:sys_enter_" #name) syscall_enter_ ## name
28
29#define license(name) \
30char _license[] SEC("license") = #name; \
31int _version SEC("version") = LINUX_VERSION_CODE;
32
33static int (*probe_read)(void *dst, int size, const void *unsafe_addr) = (void *)BPF_FUNC_probe_read;
34static int (*probe_read_str)(void *dst, int size, const void *unsafe_addr) = (void *)BPF_FUNC_probe_read_str;
35
36#endif /* _PERF_BPF_H */