18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _BPF_JIT_H
38c2ecf20Sopenharmony_ci#define _BPF_JIT_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci/* Conventions:
68c2ecf20Sopenharmony_ci *  %g1 : temporary
78c2ecf20Sopenharmony_ci *  %g2 : Secondary temporary used by SKB data helper stubs.
88c2ecf20Sopenharmony_ci *  %g3 : packet offset passed into SKB data helper stubs.
98c2ecf20Sopenharmony_ci *  %o0 : pointer to skb (first argument given to JIT function)
108c2ecf20Sopenharmony_ci *  %o1 : BPF A accumulator
118c2ecf20Sopenharmony_ci *  %o2 : BPF X accumulator
128c2ecf20Sopenharmony_ci *  %o3 : Holds saved %o7 so we can call helper functions without needing
138c2ecf20Sopenharmony_ci *        to allocate a register window.
148c2ecf20Sopenharmony_ci *  %o4 : skb->len - skb->data_len
158c2ecf20Sopenharmony_ci *  %o5 : skb->data
168c2ecf20Sopenharmony_ci */
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#ifndef __ASSEMBLER__
198c2ecf20Sopenharmony_ci#define G0		0x00
208c2ecf20Sopenharmony_ci#define G1		0x01
218c2ecf20Sopenharmony_ci#define G3		0x03
228c2ecf20Sopenharmony_ci#define G6		0x06
238c2ecf20Sopenharmony_ci#define O0		0x08
248c2ecf20Sopenharmony_ci#define O1		0x09
258c2ecf20Sopenharmony_ci#define O2		0x0a
268c2ecf20Sopenharmony_ci#define O3		0x0b
278c2ecf20Sopenharmony_ci#define O4		0x0c
288c2ecf20Sopenharmony_ci#define O5		0x0d
298c2ecf20Sopenharmony_ci#define SP		0x0e
308c2ecf20Sopenharmony_ci#define O7		0x0f
318c2ecf20Sopenharmony_ci#define FP		0x1e
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci#define r_SKB		O0
348c2ecf20Sopenharmony_ci#define r_A		O1
358c2ecf20Sopenharmony_ci#define r_X		O2
368c2ecf20Sopenharmony_ci#define r_saved_O7	O3
378c2ecf20Sopenharmony_ci#define r_HEADLEN	O4
388c2ecf20Sopenharmony_ci#define r_SKB_DATA	O5
398c2ecf20Sopenharmony_ci#define r_TMP		G1
408c2ecf20Sopenharmony_ci#define r_TMP2		G2
418c2ecf20Sopenharmony_ci#define r_OFF		G3
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci/* assembly code in arch/sparc/net/bpf_jit_asm_32.S */
448c2ecf20Sopenharmony_ciextern u32 bpf_jit_load_word[];
458c2ecf20Sopenharmony_ciextern u32 bpf_jit_load_half[];
468c2ecf20Sopenharmony_ciextern u32 bpf_jit_load_byte[];
478c2ecf20Sopenharmony_ciextern u32 bpf_jit_load_byte_msh[];
488c2ecf20Sopenharmony_ciextern u32 bpf_jit_load_word_positive_offset[];
498c2ecf20Sopenharmony_ciextern u32 bpf_jit_load_half_positive_offset[];
508c2ecf20Sopenharmony_ciextern u32 bpf_jit_load_byte_positive_offset[];
518c2ecf20Sopenharmony_ciextern u32 bpf_jit_load_byte_msh_positive_offset[];
528c2ecf20Sopenharmony_ciextern u32 bpf_jit_load_word_negative_offset[];
538c2ecf20Sopenharmony_ciextern u32 bpf_jit_load_half_negative_offset[];
548c2ecf20Sopenharmony_ciextern u32 bpf_jit_load_byte_negative_offset[];
558c2ecf20Sopenharmony_ciextern u32 bpf_jit_load_byte_msh_negative_offset[];
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci#else
588c2ecf20Sopenharmony_ci#define r_SKB		%o0
598c2ecf20Sopenharmony_ci#define r_A		%o1
608c2ecf20Sopenharmony_ci#define r_X		%o2
618c2ecf20Sopenharmony_ci#define r_saved_O7	%o3
628c2ecf20Sopenharmony_ci#define r_HEADLEN	%o4
638c2ecf20Sopenharmony_ci#define r_SKB_DATA	%o5
648c2ecf20Sopenharmony_ci#define r_TMP		%g1
658c2ecf20Sopenharmony_ci#define r_TMP2		%g2
668c2ecf20Sopenharmony_ci#define r_OFF		%g3
678c2ecf20Sopenharmony_ci#endif
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci#endif /* _BPF_JIT_H */
70