n2_core.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _N2_CORE_H
  3. #define _N2_CORE_H
  4. #ifndef __ASSEMBLY__
  5. struct ino_blob {
  6. u64 intr;
  7. u64 ino;
  8. };
  9. struct spu_mdesc_info {
  10. u64 cfg_handle;
  11. struct ino_blob *ino_table;
  12. int num_intrs;
  13. };
  14. struct n2_crypto {
  15. struct spu_mdesc_info cwq_info;
  16. struct list_head cwq_list;
  17. };
  18. struct n2_mau {
  19. struct spu_mdesc_info mau_info;
  20. struct list_head mau_list;
  21. };
  22. #define CWQ_ENTRY_SIZE 64
  23. #define CWQ_NUM_ENTRIES 64
  24. #define MAU_ENTRY_SIZE 64
  25. #define MAU_NUM_ENTRIES 64
  26. struct cwq_initial_entry {
  27. u64 control;
  28. u64 src_addr;
  29. u64 auth_key_addr;
  30. u64 auth_iv_addr;
  31. u64 final_auth_state_addr;
  32. u64 enc_key_addr;
  33. u64 enc_iv_addr;
  34. u64 dest_addr;
  35. };
  36. struct cwq_ext_entry {
  37. u64 len;
  38. u64 src_addr;
  39. u64 resv1;
  40. u64 resv2;
  41. u64 resv3;
  42. u64 resv4;
  43. u64 resv5;
  44. u64 resv6;
  45. };
  46. struct cwq_final_entry {
  47. u64 control;
  48. u64 src_addr;
  49. u64 resv1;
  50. u64 resv2;
  51. u64 resv3;
  52. u64 resv4;
  53. u64 resv5;
  54. u64 resv6;
  55. };
  56. #define CONTROL_LEN 0x000000000000ffffULL
  57. #define CONTROL_LEN_SHIFT 0
  58. #define CONTROL_HMAC_KEY_LEN 0x0000000000ff0000ULL
  59. #define CONTROL_HMAC_KEY_LEN_SHIFT 16
  60. #define CONTROL_ENC_TYPE 0x00000000ff000000ULL
  61. #define CONTROL_ENC_TYPE_SHIFT 24
  62. #define ENC_TYPE_ALG_RC4_STREAM 0x00ULL
  63. #define ENC_TYPE_ALG_RC4_NOSTREAM 0x04ULL
  64. #define ENC_TYPE_ALG_DES 0x08ULL
  65. #define ENC_TYPE_ALG_3DES 0x0cULL
  66. #define ENC_TYPE_ALG_AES128 0x10ULL
  67. #define ENC_TYPE_ALG_AES192 0x14ULL
  68. #define ENC_TYPE_ALG_AES256 0x18ULL
  69. #define ENC_TYPE_ALG_RESERVED 0x1cULL
  70. #define ENC_TYPE_ALG_MASK 0x1cULL
  71. #define ENC_TYPE_CHAINING_ECB 0x00ULL
  72. #define ENC_TYPE_CHAINING_CBC 0x01ULL
  73. #define ENC_TYPE_CHAINING_CFB 0x02ULL
  74. #define ENC_TYPE_CHAINING_COUNTER 0x03ULL
  75. #define ENC_TYPE_CHAINING_MASK 0x03ULL
  76. #define CONTROL_AUTH_TYPE 0x0000001f00000000ULL
  77. #define CONTROL_AUTH_TYPE_SHIFT 32
  78. #define AUTH_TYPE_RESERVED 0x00ULL
  79. #define AUTH_TYPE_MD5 0x01ULL
  80. #define AUTH_TYPE_SHA1 0x02ULL
  81. #define AUTH_TYPE_SHA256 0x03ULL
  82. #define AUTH_TYPE_CRC32 0x04ULL
  83. #define AUTH_TYPE_HMAC_MD5 0x05ULL
  84. #define AUTH_TYPE_HMAC_SHA1 0x06ULL
  85. #define AUTH_TYPE_HMAC_SHA256 0x07ULL
  86. #define AUTH_TYPE_TCP_CHECKSUM 0x08ULL
  87. #define AUTH_TYPE_SSL_HMAC_MD5 0x09ULL
  88. #define AUTH_TYPE_SSL_HMAC_SHA1 0x0aULL
  89. #define AUTH_TYPE_SSL_HMAC_SHA256 0x0bULL
  90. #define CONTROL_STRAND 0x000000e000000000ULL
  91. #define CONTROL_STRAND_SHIFT 37
  92. #define CONTROL_HASH_LEN 0x0000ff0000000000ULL
  93. #define CONTROL_HASH_LEN_SHIFT 40
  94. #define CONTROL_INTERRUPT 0x0001000000000000ULL
  95. #define CONTROL_STORE_FINAL_AUTH_STATE 0x0002000000000000ULL
  96. #define CONTROL_RESERVED 0x001c000000000000ULL
  97. #define CONTROL_HV_DONE 0x0004000000000000ULL
  98. #define CONTROL_HV_PROTOCOL_ERROR 0x0008000000000000ULL
  99. #define CONTROL_HV_HARDWARE_ERROR 0x0010000000000000ULL
  100. #define CONTROL_END_OF_BLOCK 0x0020000000000000ULL
  101. #define CONTROL_START_OF_BLOCK 0x0040000000000000ULL
  102. #define CONTROL_ENCRYPT 0x0080000000000000ULL
  103. #define CONTROL_OPCODE 0xff00000000000000ULL
  104. #define CONTROL_OPCODE_SHIFT 56
  105. #define OPCODE_INPLACE_BIT 0x80ULL
  106. #define OPCODE_SSL_KEYBLOCK 0x10ULL
  107. #define OPCODE_COPY 0x20ULL
  108. #define OPCODE_ENCRYPT 0x40ULL
  109. #define OPCODE_AUTH_MAC 0x41ULL
  110. #endif /* !(__ASSEMBLY__) */
  111. /* NCS v2.0 hypervisor interfaces */
  112. #define HV_NCS_QTYPE_MAU 0x01
  113. #define HV_NCS_QTYPE_CWQ 0x02
  114. /* ncs_qconf()
  115. * TRAP: HV_FAST_TRAP
  116. * FUNCTION: HV_FAST_NCS_QCONF
  117. * ARG0: Queue type (HV_NCS_QTYPE_{MAU,CWQ})
  118. * ARG1: Real address of queue, or handle for unconfigure
  119. * ARG2: Number of entries in queue, zero for unconfigure
  120. * RET0: status
  121. * RET1: queue handle
  122. *
  123. * Configure a queue in the stream processing unit.
  124. *
  125. * The real address given as the base must be 64-byte
  126. * aligned.
  127. *
  128. * The queue size can range from a minimum of 2 to a maximum
  129. * of 64. The queue size must be a power of two.
  130. *
  131. * To unconfigure a queue, specify a length of zero and place
  132. * the queue handle into ARG1.
  133. *
  134. * On configure success the hypervisor will set the FIRST, HEAD,
  135. * and TAIL registers to the address of the first entry in the
  136. * queue. The LAST register will be set to point to the last
  137. * entry in the queue.
  138. */
  139. #define HV_FAST_NCS_QCONF 0x111
  140. /* ncs_qinfo()
  141. * TRAP: HV_FAST_TRAP
  142. * FUNCTION: HV_FAST_NCS_QINFO
  143. * ARG0: Queue handle
  144. * RET0: status
  145. * RET1: Queue type (HV_NCS_QTYPE_{MAU,CWQ})
  146. * RET2: Queue base address
  147. * RET3: Number of entries
  148. */
  149. #define HV_FAST_NCS_QINFO 0x112
  150. /* ncs_gethead()
  151. * TRAP: HV_FAST_TRAP
  152. * FUNCTION: HV_FAST_NCS_GETHEAD
  153. * ARG0: Queue handle
  154. * RET0: status
  155. * RET1: queue head offset
  156. */
  157. #define HV_FAST_NCS_GETHEAD 0x113
  158. /* ncs_gettail()
  159. * TRAP: HV_FAST_TRAP
  160. * FUNCTION: HV_FAST_NCS_GETTAIL
  161. * ARG0: Queue handle
  162. * RET0: status
  163. * RET1: queue tail offset
  164. */
  165. #define HV_FAST_NCS_GETTAIL 0x114
  166. /* ncs_settail()
  167. * TRAP: HV_FAST_TRAP
  168. * FUNCTION: HV_FAST_NCS_SETTAIL
  169. * ARG0: Queue handle
  170. * ARG1: New tail offset
  171. * RET0: status
  172. */
  173. #define HV_FAST_NCS_SETTAIL 0x115
  174. /* ncs_qhandle_to_devino()
  175. * TRAP: HV_FAST_TRAP
  176. * FUNCTION: HV_FAST_NCS_QHANDLE_TO_DEVINO
  177. * ARG0: Queue handle
  178. * RET0: status
  179. * RET1: devino
  180. */
  181. #define HV_FAST_NCS_QHANDLE_TO_DEVINO 0x116
  182. /* ncs_sethead_marker()
  183. * TRAP: HV_FAST_TRAP
  184. * FUNCTION: HV_FAST_NCS_SETHEAD_MARKER
  185. * ARG0: Queue handle
  186. * ARG1: New head offset
  187. * RET0: status
  188. */
  189. #define HV_FAST_NCS_SETHEAD_MARKER 0x117
  190. #ifndef __ASSEMBLY__
  191. extern unsigned long sun4v_ncs_qconf(unsigned long queue_type,
  192. unsigned long queue_ra,
  193. unsigned long num_entries,
  194. unsigned long *qhandle);
  195. extern unsigned long sun4v_ncs_qinfo(unsigned long qhandle,
  196. unsigned long *queue_type,
  197. unsigned long *queue_ra,
  198. unsigned long *num_entries);
  199. extern unsigned long sun4v_ncs_gethead(unsigned long qhandle,
  200. unsigned long *head);
  201. extern unsigned long sun4v_ncs_gettail(unsigned long qhandle,
  202. unsigned long *tail);
  203. extern unsigned long sun4v_ncs_settail(unsigned long qhandle,
  204. unsigned long tail);
  205. extern unsigned long sun4v_ncs_qhandle_to_devino(unsigned long qhandle,
  206. unsigned long *devino);
  207. extern unsigned long sun4v_ncs_sethead_marker(unsigned long qhandle,
  208. unsigned long head);
  209. #endif /* !(__ASSEMBLY__) */
  210. #endif /* _N2_CORE_H */