xref: /openbmc/linux/arch/s390/net/bpf_jit.h (revision 3d3337de)
1 /*
2  * BPF Jit compiler defines
3  *
4  * Copyright IBM Corp. 2012,2015
5  *
6  * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
7  *	      Michael Holzheu <holzheu@linux.vnet.ibm.com>
8  */
9 
10 #ifndef __ARCH_S390_NET_BPF_JIT_H
11 #define __ARCH_S390_NET_BPF_JIT_H
12 
13 #ifndef __ASSEMBLY__
14 
15 #include <linux/filter.h>
16 #include <linux/types.h>
17 
18 extern u8 sk_load_word_pos[], sk_load_half_pos[], sk_load_byte_pos[];
19 extern u8 sk_load_word[], sk_load_half[], sk_load_byte[];
20 
21 #endif /* __ASSEMBLY__ */
22 
23 /*
24  * Stackframe layout (packed stack):
25  *
26  *				    ^ high
27  *	      +---------------+     |
28  *	      | old backchain |     |
29  *	      +---------------+     |
30  *	      |   r15 - r6    |     |
31  * BFP	   -> +===============+     |
32  *	      |		      |     |
33  *	      |   BPF stack   |     |
34  *	      |		      |     |
35  *	      +---------------+     |
36  *	      | 8 byte hlen   |     |
37  * R15+168 -> +---------------+     |
38  *	      | 4 byte align  |     |
39  *	      +---------------+     |
40  *	      | 4 byte temp   |     |
41  *	      | for bpf_jit.S |     |
42  * R15+160 -> +---------------+     |
43  *	      | new backchain |     |
44  * R15+152 -> +---------------+     |
45  *	      | + 152 byte SA |     |
46  * R15	   -> +---------------+     + low
47  *
48  * We get 160 bytes stack space from calling function, but only use
49  * 11 * 8 byte (old backchain + r15 - r6) for storing registers.
50  */
51 #define STK_OFF (MAX_BPF_STACK + 8 + 4 + 4 + (160 - 11 * 8))
52 #define STK_OFF_TMP	160	/* Offset of tmp buffer on stack */
53 #define STK_OFF_HLEN	168	/* Offset of SKB header length on stack */
54 
55 /* Offset to skip condition code check */
56 #define OFF_OK		4
57 
58 #endif /* __ARCH_S390_NET_BPF_JIT_H */
59