sha1_mb_mgr_datastruct.S 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. /*
  2. * Header file for multi buffer SHA1 algorithm data structure
  3. *
  4. * This file is provided under a dual BSD/GPLv2 license. When using or
  5. * redistributing this file, you may do so under either license.
  6. *
  7. * GPL LICENSE SUMMARY
  8. *
  9. * Copyright(c) 2014 Intel Corporation.
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of version 2 of the GNU General Public License as
  13. * published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful, but
  16. * WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * General Public License for more details.
  19. *
  20. * Contact Information:
  21. * James Guilford <james.guilford@intel.com>
  22. * Tim Chen <tim.c.chen@linux.intel.com>
  23. *
  24. * BSD LICENSE
  25. *
  26. * Copyright(c) 2014 Intel Corporation.
  27. *
  28. * Redistribution and use in source and binary forms, with or without
  29. * modification, are permitted provided that the following conditions
  30. * are met:
  31. *
  32. * * Redistributions of source code must retain the above copyright
  33. * notice, this list of conditions and the following disclaimer.
  34. * * Redistributions in binary form must reproduce the above copyright
  35. * notice, this list of conditions and the following disclaimer in
  36. * the documentation and/or other materials provided with the
  37. * distribution.
  38. * * Neither the name of Intel Corporation nor the names of its
  39. * contributors may be used to endorse or promote products derived
  40. * from this software without specific prior written permission.
  41. *
  42. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  43. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  44. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  45. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  46. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  47. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  48. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  49. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  50. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  51. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  52. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  53. */
  54. # Macros for defining data structures
  55. # Usage example
  56. #START_FIELDS # JOB_AES
  57. ### name size align
  58. #FIELD _plaintext, 8, 8 # pointer to plaintext
  59. #FIELD _ciphertext, 8, 8 # pointer to ciphertext
  60. #FIELD _IV, 16, 8 # IV
  61. #FIELD _keys, 8, 8 # pointer to keys
  62. #FIELD _len, 4, 4 # length in bytes
  63. #FIELD _status, 4, 4 # status enumeration
  64. #FIELD _user_data, 8, 8 # pointer to user data
  65. #UNION _union, size1, align1, \
  66. # size2, align2, \
  67. # size3, align3, \
  68. # ...
  69. #END_FIELDS
  70. #%assign _JOB_AES_size _FIELD_OFFSET
  71. #%assign _JOB_AES_align _STRUCT_ALIGN
  72. #########################################################################
  73. # Alternate "struc-like" syntax:
  74. # STRUCT job_aes2
  75. # RES_Q .plaintext, 1
  76. # RES_Q .ciphertext, 1
  77. # RES_DQ .IV, 1
  78. # RES_B .nested, _JOB_AES_SIZE, _JOB_AES_ALIGN
  79. # RES_U .union, size1, align1, \
  80. # size2, align2, \
  81. # ...
  82. # ENDSTRUCT
  83. # # Following only needed if nesting
  84. # %assign job_aes2_size _FIELD_OFFSET
  85. # %assign job_aes2_align _STRUCT_ALIGN
  86. #
  87. # RES_* macros take a name, a count and an optional alignment.
  88. # The count in in terms of the base size of the macro, and the
  89. # default alignment is the base size.
  90. # The macros are:
  91. # Macro Base size
  92. # RES_B 1
  93. # RES_W 2
  94. # RES_D 4
  95. # RES_Q 8
  96. # RES_DQ 16
  97. # RES_Y 32
  98. # RES_Z 64
  99. #
  100. # RES_U defines a union. It's arguments are a name and two or more
  101. # pairs of "size, alignment"
  102. #
  103. # The two assigns are only needed if this structure is being nested
  104. # within another. Even if the assigns are not done, one can still use
  105. # STRUCT_NAME_size as the size of the structure.
  106. #
  107. # Note that for nesting, you still need to assign to STRUCT_NAME_size.
  108. #
  109. # The differences between this and using "struc" directly are that each
  110. # type is implicitly aligned to its natural length (although this can be
  111. # over-ridden with an explicit third parameter), and that the structure
  112. # is padded at the end to its overall alignment.
  113. #
  114. #########################################################################
  115. #ifndef _SHA1_MB_MGR_DATASTRUCT_ASM_
  116. #define _SHA1_MB_MGR_DATASTRUCT_ASM_
  117. ## START_FIELDS
  118. .macro START_FIELDS
  119. _FIELD_OFFSET = 0
  120. _STRUCT_ALIGN = 0
  121. .endm
  122. ## FIELD name size align
  123. .macro FIELD name size align
  124. _FIELD_OFFSET = (_FIELD_OFFSET + (\align) - 1) & (~ ((\align)-1))
  125. \name = _FIELD_OFFSET
  126. _FIELD_OFFSET = _FIELD_OFFSET + (\size)
  127. .if (\align > _STRUCT_ALIGN)
  128. _STRUCT_ALIGN = \align
  129. .endif
  130. .endm
  131. ## END_FIELDS
  132. .macro END_FIELDS
  133. _FIELD_OFFSET = (_FIELD_OFFSET + _STRUCT_ALIGN-1) & (~ (_STRUCT_ALIGN-1))
  134. .endm
  135. ########################################################################
  136. .macro STRUCT p1
  137. START_FIELDS
  138. .struc \p1
  139. .endm
  140. .macro ENDSTRUCT
  141. tmp = _FIELD_OFFSET
  142. END_FIELDS
  143. tmp = (_FIELD_OFFSET - %%tmp)
  144. .if (tmp > 0)
  145. .lcomm tmp
  146. .endif
  147. .endstruc
  148. .endm
  149. ## RES_int name size align
  150. .macro RES_int p1 p2 p3
  151. name = \p1
  152. size = \p2
  153. align = .\p3
  154. _FIELD_OFFSET = (_FIELD_OFFSET + (align) - 1) & (~ ((align)-1))
  155. .align align
  156. .lcomm name size
  157. _FIELD_OFFSET = _FIELD_OFFSET + (size)
  158. .if (align > _STRUCT_ALIGN)
  159. _STRUCT_ALIGN = align
  160. .endif
  161. .endm
  162. # macro RES_B name, size [, align]
  163. .macro RES_B _name, _size, _align=1
  164. RES_int _name _size _align
  165. .endm
  166. # macro RES_W name, size [, align]
  167. .macro RES_W _name, _size, _align=2
  168. RES_int _name 2*(_size) _align
  169. .endm
  170. # macro RES_D name, size [, align]
  171. .macro RES_D _name, _size, _align=4
  172. RES_int _name 4*(_size) _align
  173. .endm
  174. # macro RES_Q name, size [, align]
  175. .macro RES_Q _name, _size, _align=8
  176. RES_int _name 8*(_size) _align
  177. .endm
  178. # macro RES_DQ name, size [, align]
  179. .macro RES_DQ _name, _size, _align=16
  180. RES_int _name 16*(_size) _align
  181. .endm
  182. # macro RES_Y name, size [, align]
  183. .macro RES_Y _name, _size, _align=32
  184. RES_int _name 32*(_size) _align
  185. .endm
  186. # macro RES_Z name, size [, align]
  187. .macro RES_Z _name, _size, _align=64
  188. RES_int _name 64*(_size) _align
  189. .endm
  190. #endif
  191. ########################################################################
  192. #### Define constants
  193. ########################################################################
  194. ########################################################################
  195. #### Define SHA1 Out Of Order Data Structures
  196. ########################################################################
  197. START_FIELDS # LANE_DATA
  198. ### name size align
  199. FIELD _job_in_lane, 8, 8 # pointer to job object
  200. END_FIELDS
  201. _LANE_DATA_size = _FIELD_OFFSET
  202. _LANE_DATA_align = _STRUCT_ALIGN
  203. ########################################################################
  204. START_FIELDS # SHA1_ARGS_X8
  205. ### name size align
  206. FIELD _digest, 4*5*8, 16 # transposed digest
  207. FIELD _data_ptr, 8*8, 8 # array of pointers to data
  208. END_FIELDS
  209. _SHA1_ARGS_X4_size = _FIELD_OFFSET
  210. _SHA1_ARGS_X4_align = _STRUCT_ALIGN
  211. _SHA1_ARGS_X8_size = _FIELD_OFFSET
  212. _SHA1_ARGS_X8_align = _STRUCT_ALIGN
  213. ########################################################################
  214. START_FIELDS # MB_MGR
  215. ### name size align
  216. FIELD _args, _SHA1_ARGS_X4_size, _SHA1_ARGS_X4_align
  217. FIELD _lens, 4*8, 8
  218. FIELD _unused_lanes, 8, 8
  219. FIELD _ldata, _LANE_DATA_size*8, _LANE_DATA_align
  220. END_FIELDS
  221. _MB_MGR_size = _FIELD_OFFSET
  222. _MB_MGR_align = _STRUCT_ALIGN
  223. _args_digest = _args + _digest
  224. _args_data_ptr = _args + _data_ptr
  225. ########################################################################
  226. #### Define constants
  227. ########################################################################
  228. #define STS_UNKNOWN 0
  229. #define STS_BEING_PROCESSED 1
  230. #define STS_COMPLETED 2
  231. ########################################################################
  232. #### Define JOB_SHA1 structure
  233. ########################################################################
  234. START_FIELDS # JOB_SHA1
  235. ### name size align
  236. FIELD _buffer, 8, 8 # pointer to buffer
  237. FIELD _len, 4, 4 # length in bytes
  238. FIELD _result_digest, 5*4, 32 # Digest (output)
  239. FIELD _status, 4, 4
  240. FIELD _user_data, 8, 8
  241. END_FIELDS
  242. _JOB_SHA1_size = _FIELD_OFFSET
  243. _JOB_SHA1_align = _STRUCT_ALIGN