nfp_asm.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. /*
  2. * Copyright (C) 2016 Netronome Systems, Inc.
  3. *
  4. * This software is dual licensed under the GNU General License Version 2,
  5. * June 1991 as shown in the file COPYING in the top-level directory of this
  6. * source tree or the BSD 2-Clause License provided below. You have the
  7. * option to license this software under the complete terms of either license.
  8. *
  9. * The BSD 2-Clause License:
  10. *
  11. * Redistribution and use in source and binary forms, with or
  12. * without modification, are permitted provided that the following
  13. * conditions are met:
  14. *
  15. * 1. Redistributions of source code must retain the above
  16. * copyright notice, this list of conditions and the following
  17. * disclaimer.
  18. *
  19. * 2. Redistributions in binary form must reproduce the above
  20. * copyright notice, this list of conditions and the following
  21. * disclaimer in the documentation and/or other materials
  22. * provided with the distribution.
  23. *
  24. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  25. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  26. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  27. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  28. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  29. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  30. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  31. * SOFTWARE.
  32. */
  33. #ifndef __NFP_ASM_H__
  34. #define __NFP_ASM_H__ 1
  35. #include "nfp_bpf.h"
  36. #define REG_NONE 0
  37. #define RE_REG_NO_DST 0x020
  38. #define RE_REG_IMM 0x020
  39. #define RE_REG_IMM_encode(x) \
  40. (RE_REG_IMM | ((x) & 0x1f) | (((x) & 0x60) << 1))
  41. #define RE_REG_IMM_MAX 0x07fULL
  42. #define RE_REG_XFR 0x080
  43. #define UR_REG_XFR 0x180
  44. #define UR_REG_NN 0x280
  45. #define UR_REG_NO_DST 0x300
  46. #define UR_REG_IMM UR_REG_NO_DST
  47. #define UR_REG_IMM_encode(x) (UR_REG_IMM | (x))
  48. #define UR_REG_IMM_MAX 0x0ffULL
  49. #define OP_BR_BASE 0x0d800000020ULL
  50. #define OP_BR_BASE_MASK 0x0f8000c3ce0ULL
  51. #define OP_BR_MASK 0x0000000001fULL
  52. #define OP_BR_EV_PIP 0x00000000300ULL
  53. #define OP_BR_CSS 0x0000003c000ULL
  54. #define OP_BR_DEFBR 0x00000300000ULL
  55. #define OP_BR_ADDR_LO 0x007ffc00000ULL
  56. #define OP_BR_ADDR_HI 0x10000000000ULL
  57. #define nfp_is_br(_insn) \
  58. (((_insn) & OP_BR_BASE_MASK) == OP_BR_BASE)
  59. enum br_mask {
  60. BR_BEQ = 0x00,
  61. BR_BNE = 0x01,
  62. BR_BHS = 0x04,
  63. BR_BLO = 0x05,
  64. BR_BGE = 0x08,
  65. BR_UNC = 0x18,
  66. };
  67. enum br_ev_pip {
  68. BR_EV_PIP_UNCOND = 0,
  69. BR_EV_PIP_COND = 1,
  70. };
  71. enum br_ctx_signal_state {
  72. BR_CSS_NONE = 2,
  73. };
  74. #define OP_BBYTE_BASE 0x0c800000000ULL
  75. #define OP_BB_A_SRC 0x000000000ffULL
  76. #define OP_BB_BYTE 0x00000000300ULL
  77. #define OP_BB_B_SRC 0x0000003fc00ULL
  78. #define OP_BB_I8 0x00000040000ULL
  79. #define OP_BB_EQ 0x00000080000ULL
  80. #define OP_BB_DEFBR 0x00000300000ULL
  81. #define OP_BB_ADDR_LO 0x007ffc00000ULL
  82. #define OP_BB_ADDR_HI 0x10000000000ULL
  83. #define OP_BALU_BASE 0x0e800000000ULL
  84. #define OP_BA_A_SRC 0x000000003ffULL
  85. #define OP_BA_B_SRC 0x000000ffc00ULL
  86. #define OP_BA_DEFBR 0x00000300000ULL
  87. #define OP_BA_ADDR_HI 0x0007fc00000ULL
  88. #define OP_IMMED_A_SRC 0x000000003ffULL
  89. #define OP_IMMED_B_SRC 0x000000ffc00ULL
  90. #define OP_IMMED_IMM 0x0000ff00000ULL
  91. #define OP_IMMED_WIDTH 0x00060000000ULL
  92. #define OP_IMMED_INV 0x00080000000ULL
  93. #define OP_IMMED_SHIFT 0x00600000000ULL
  94. #define OP_IMMED_BASE 0x0f000000000ULL
  95. #define OP_IMMED_WR_AB 0x20000000000ULL
  96. enum immed_width {
  97. IMMED_WIDTH_ALL = 0,
  98. IMMED_WIDTH_BYTE = 1,
  99. IMMED_WIDTH_WORD = 2,
  100. };
  101. enum immed_shift {
  102. IMMED_SHIFT_0B = 0,
  103. IMMED_SHIFT_1B = 1,
  104. IMMED_SHIFT_2B = 2,
  105. };
  106. #define OP_SHF_BASE 0x08000000000ULL
  107. #define OP_SHF_A_SRC 0x000000000ffULL
  108. #define OP_SHF_SC 0x00000000300ULL
  109. #define OP_SHF_B_SRC 0x0000003fc00ULL
  110. #define OP_SHF_I8 0x00000040000ULL
  111. #define OP_SHF_SW 0x00000080000ULL
  112. #define OP_SHF_DST 0x0000ff00000ULL
  113. #define OP_SHF_SHIFT 0x001f0000000ULL
  114. #define OP_SHF_OP 0x00e00000000ULL
  115. #define OP_SHF_DST_AB 0x01000000000ULL
  116. #define OP_SHF_WR_AB 0x20000000000ULL
  117. enum shf_op {
  118. SHF_OP_NONE = 0,
  119. SHF_OP_AND = 2,
  120. SHF_OP_OR = 5,
  121. };
  122. enum shf_sc {
  123. SHF_SC_R_ROT = 0,
  124. SHF_SC_R_SHF = 1,
  125. SHF_SC_L_SHF = 2,
  126. SHF_SC_R_DSHF = 3,
  127. };
  128. #define OP_ALU_A_SRC 0x000000003ffULL
  129. #define OP_ALU_B_SRC 0x000000ffc00ULL
  130. #define OP_ALU_DST 0x0003ff00000ULL
  131. #define OP_ALU_SW 0x00040000000ULL
  132. #define OP_ALU_OP 0x00f80000000ULL
  133. #define OP_ALU_DST_AB 0x01000000000ULL
  134. #define OP_ALU_BASE 0x0a000000000ULL
  135. #define OP_ALU_WR_AB 0x20000000000ULL
  136. enum alu_op {
  137. ALU_OP_NONE = 0x00,
  138. ALU_OP_ADD = 0x01,
  139. ALU_OP_NEG = 0x04,
  140. ALU_OP_AND = 0x08,
  141. ALU_OP_SUB_C = 0x0d,
  142. ALU_OP_ADD_C = 0x11,
  143. ALU_OP_OR = 0x14,
  144. ALU_OP_SUB = 0x15,
  145. ALU_OP_XOR = 0x18,
  146. };
  147. enum alu_dst_ab {
  148. ALU_DST_A = 0,
  149. ALU_DST_B = 1,
  150. };
  151. #define OP_LDF_BASE 0x0c000000000ULL
  152. #define OP_LDF_A_SRC 0x000000000ffULL
  153. #define OP_LDF_SC 0x00000000300ULL
  154. #define OP_LDF_B_SRC 0x0000003fc00ULL
  155. #define OP_LDF_I8 0x00000040000ULL
  156. #define OP_LDF_SW 0x00000080000ULL
  157. #define OP_LDF_ZF 0x00000100000ULL
  158. #define OP_LDF_BMASK 0x0000f000000ULL
  159. #define OP_LDF_SHF 0x001f0000000ULL
  160. #define OP_LDF_WR_AB 0x20000000000ULL
  161. #define OP_CMD_A_SRC 0x000000000ffULL
  162. #define OP_CMD_CTX 0x00000000300ULL
  163. #define OP_CMD_B_SRC 0x0000003fc00ULL
  164. #define OP_CMD_TOKEN 0x000000c0000ULL
  165. #define OP_CMD_XFER 0x00001f00000ULL
  166. #define OP_CMD_CNT 0x0000e000000ULL
  167. #define OP_CMD_SIG 0x000f0000000ULL
  168. #define OP_CMD_TGT_CMD 0x07f00000000ULL
  169. #define OP_CMD_MODE 0x1c0000000000ULL
  170. struct cmd_tgt_act {
  171. u8 token;
  172. u8 tgt_cmd;
  173. };
  174. enum cmd_tgt_map {
  175. CMD_TGT_READ8,
  176. CMD_TGT_WRITE8,
  177. CMD_TGT_READ_LE,
  178. CMD_TGT_READ_SWAP_LE,
  179. __CMD_TGT_MAP_SIZE,
  180. };
  181. enum cmd_mode {
  182. CMD_MODE_40b_AB = 0,
  183. CMD_MODE_40b_BA = 1,
  184. CMD_MODE_32b = 4,
  185. };
  186. enum cmd_ctx_swap {
  187. CMD_CTX_SWAP = 0,
  188. CMD_CTX_NO_SWAP = 3,
  189. };
  190. #define OP_LCSR_BASE 0x0fc00000000ULL
  191. #define OP_LCSR_A_SRC 0x000000003ffULL
  192. #define OP_LCSR_B_SRC 0x000000ffc00ULL
  193. #define OP_LCSR_WRITE 0x00000200000ULL
  194. #define OP_LCSR_ADDR 0x001ffc00000ULL
  195. enum lcsr_wr_src {
  196. LCSR_WR_AREG,
  197. LCSR_WR_BREG,
  198. LCSR_WR_IMM,
  199. };
  200. #define OP_CARB_BASE 0x0e000000000ULL
  201. #define OP_CARB_OR 0x00000010000ULL
  202. #endif