root/arch/mips/net/bpf_jit.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /* SPDX-License-Identifier: GPL-2.0-only */
   2 /*
   3  * Just-In-Time compiler for BPF filters on MIPS
   4  *
   5  * Copyright (c) 2014 Imagination Technologies Ltd.
   6  * Author: Markos Chandras <markos.chandras@imgtec.com>
   7  */
   8 
   9 #ifndef BPF_JIT_MIPS_OP_H
  10 #define BPF_JIT_MIPS_OP_H
  11 
  12 /* Registers used by JIT */
  13 #define MIPS_R_ZERO     0
  14 #define MIPS_R_V0       2
  15 #define MIPS_R_A0       4
  16 #define MIPS_R_A1       5
  17 #define MIPS_R_T4       12
  18 #define MIPS_R_T5       13
  19 #define MIPS_R_T6       14
  20 #define MIPS_R_T7       15
  21 #define MIPS_R_S0       16
  22 #define MIPS_R_S1       17
  23 #define MIPS_R_S2       18
  24 #define MIPS_R_S3       19
  25 #define MIPS_R_S4       20
  26 #define MIPS_R_S5       21
  27 #define MIPS_R_S6       22
  28 #define MIPS_R_S7       23
  29 #define MIPS_R_SP       29
  30 #define MIPS_R_RA       31
  31 
  32 /* Conditional codes */
  33 #define MIPS_COND_EQ    0x1
  34 #define MIPS_COND_GE    (0x1 << 1)
  35 #define MIPS_COND_GT    (0x1 << 2)
  36 #define MIPS_COND_NE    (0x1 << 3)
  37 #define MIPS_COND_ALL   (0x1 << 4)
  38 /* Conditionals on X register or K immediate */
  39 #define MIPS_COND_X     (0x1 << 5)
  40 #define MIPS_COND_K     (0x1 << 6)
  41 
  42 #define r_ret   MIPS_R_V0
  43 
  44 /*
  45  * Use 2 scratch registers to avoid pipeline interlocks.
  46  * There is no overhead during epilogue and prologue since
  47  * any of the $s0-$s6 registers will only be preserved if
  48  * they are going to actually be used.
  49  */
  50 #define r_skb_hl        MIPS_R_S0 /* skb header length */
  51 #define r_skb_data      MIPS_R_S1 /* skb actual data */
  52 #define r_off           MIPS_R_S2
  53 #define r_A             MIPS_R_S3
  54 #define r_X             MIPS_R_S4
  55 #define r_skb           MIPS_R_S5
  56 #define r_M             MIPS_R_S6
  57 #define r_skb_len       MIPS_R_S7
  58 #define r_s0            MIPS_R_T4 /* scratch reg 1 */
  59 #define r_s1            MIPS_R_T5 /* scratch reg 2 */
  60 #define r_tmp_imm       MIPS_R_T6 /* No need to preserve this */
  61 #define r_tmp           MIPS_R_T7 /* No need to preserve this */
  62 #define r_zero          MIPS_R_ZERO
  63 #define r_sp            MIPS_R_SP
  64 #define r_ra            MIPS_R_RA
  65 
  66 #ifndef __ASSEMBLY__
  67 
  68 /* Declare ASM helpers */
  69 
  70 #define DECLARE_LOAD_FUNC(func) \
  71         extern u8 func(unsigned long *skb, int offset); \
  72         extern u8 func##_negative(unsigned long *skb, int offset); \
  73         extern u8 func##_positive(unsigned long *skb, int offset)
  74 
  75 DECLARE_LOAD_FUNC(sk_load_word);
  76 DECLARE_LOAD_FUNC(sk_load_half);
  77 DECLARE_LOAD_FUNC(sk_load_byte);
  78 
  79 #endif
  80 
  81 #endif /* BPF_JIT_MIPS_OP_H */

/* [<][>][^][v][top][bottom][index][help] */