Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
2#ifndef __BPF_HELPERS__
3#define __BPF_HELPERS__
4
5#include "bpf_helper_defs.h"
6
7#define __uint(name, val) int (*name)[val]
8#define __type(name, val) typeof(val) *name
9
10/* Helper macro to print out debug messages */
11#define bpf_printk(fmt, ...) \
12({ \
13 char ____fmt[] = fmt; \
14 bpf_trace_printk(____fmt, sizeof(____fmt), \
15 ##__VA_ARGS__); \
16})
17
18/*
19 * Helper macro to place programs, maps, license in
20 * different sections in elf_bpf file. Section names
21 * are interpreted by elf_bpf loader
22 */
23#define SEC(NAME) __attribute__((section(NAME), used))
24
25#ifndef __always_inline
26#define __always_inline __attribute__((always_inline))
27#endif
28#ifndef __weak
29#define __weak __attribute__((weak))
30#endif
31
32/*
33 * Helper structure used by eBPF C program
34 * to describe BPF map attributes to libbpf loader
35 */
36struct bpf_map_def {
37 unsigned int type;
38 unsigned int key_size;
39 unsigned int value_size;
40 unsigned int max_entries;
41 unsigned int map_flags;
42};
43
44enum libbpf_pin_type {
45 LIBBPF_PIN_NONE,
46 /* PIN_BY_NAME: pin maps by name (in /sys/fs/bpf by default) */
47 LIBBPF_PIN_BY_NAME,
48};
49
50enum libbpf_tristate {
51 TRI_NO = 0,
52 TRI_YES = 1,
53 TRI_MODULE = 2,
54};
55
56#define __kconfig __attribute__((section(".kconfig")))
57
58#endif