blob: 64ba734aba800e21dce13dcf608230bcd22f871e [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Arnaldo Carvalho de Melo971e8272016-07-11 16:38:05 -03002#ifndef _UAPI__LINUX_BPF_COMMON_H__
3#define _UAPI__LINUX_BPF_COMMON_H__
4
5/* Instruction classes */
6#define BPF_CLASS(code) ((code) & 0x07)
7#define BPF_LD 0x00
8#define BPF_LDX 0x01
9#define BPF_ST 0x02
10#define BPF_STX 0x03
11#define BPF_ALU 0x04
12#define BPF_JMP 0x05
13#define BPF_RET 0x06
14#define BPF_MISC 0x07
15
16/* ld/ldx fields */
17#define BPF_SIZE(code) ((code) & 0x18)
18#define BPF_W 0x00
19#define BPF_H 0x08
20#define BPF_B 0x10
21#define BPF_MODE(code) ((code) & 0xe0)
22#define BPF_IMM 0x00
23#define BPF_ABS 0x20
24#define BPF_IND 0x40
25#define BPF_MEM 0x60
26#define BPF_LEN 0x80
27#define BPF_MSH 0xa0
28
29/* alu/jmp fields */
30#define BPF_OP(code) ((code) & 0xf0)
31#define BPF_ADD 0x00
32#define BPF_SUB 0x10
33#define BPF_MUL 0x20
34#define BPF_DIV 0x30
35#define BPF_OR 0x40
36#define BPF_AND 0x50
37#define BPF_LSH 0x60
38#define BPF_RSH 0x70
39#define BPF_NEG 0x80
40#define BPF_MOD 0x90
41#define BPF_XOR 0xa0
42
43#define BPF_JA 0x00
44#define BPF_JEQ 0x10
45#define BPF_JGT 0x20
46#define BPF_JGE 0x30
47#define BPF_JSET 0x40
48#define BPF_SRC(code) ((code) & 0x08)
49#define BPF_K 0x00
50#define BPF_X 0x08
51
52#ifndef BPF_MAXINSNS
53#define BPF_MAXINSNS 4096
54#endif
55
56#endif /* _UAPI__LINUX_BPF_COMMON_H__ */