2 * Header file for multi buffer SHA1 algorithm data structure
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.
9 * Copyright(c) 2014 Intel Corporation.
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.
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.
20 * Contact Information:
21 * James Guilford <james.guilford@intel.com>
22 * Tim Chen <tim.c.chen@linux.intel.com>
26 * Copyright(c) 2014 Intel Corporation.
28 * Redistribution and use in source and binary forms, with or without
29 * modification, are permitted provided that the following conditions
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
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.
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.
55 # Macros for defining data structures
59 #START_FIELDS # JOB_AES
61 #FIELD _plaintext, 8, 8 # pointer to plaintext
62 #FIELD _ciphertext, 8, 8 # pointer to ciphertext
63 #FIELD _IV, 16, 8 # IV
64 #FIELD _keys, 8, 8 # pointer to keys
65 #FIELD _len, 4, 4 # length in bytes
66 #FIELD _status, 4, 4 # status enumeration
67 #FIELD _user_data, 8, 8 # pointer to user data
68 #UNION _union, size1, align1, \
73 #%assign _JOB_AES_size _FIELD_OFFSET
74 #%assign _JOB_AES_align _STRUCT_ALIGN
76 #########################################################################
78 # Alternate "struc-like" syntax:
81 # RES_Q .ciphertext, 1
83 # RES_B .nested, _JOB_AES_SIZE, _JOB_AES_ALIGN
84 # RES_U .union, size1, align1, \
88 # # Following only needed if nesting
89 # %assign job_aes2_size _FIELD_OFFSET
90 # %assign job_aes2_align _STRUCT_ALIGN
92 # RES_* macros take a name, a count and an optional alignment.
93 # The count in in terms of the base size of the macro, and the
94 # default alignment is the base size.
105 # RES_U defines a union. It's arguments are a name and two or more
106 # pairs of "size, alignment"
108 # The two assigns are only needed if this structure is being nested
109 # within another. Even if the assigns are not done, one can still use
110 # STRUCT_NAME_size as the size of the structure.
112 # Note that for nesting, you still need to assign to STRUCT_NAME_size.
114 # The differences between this and using "struc" directly are that each
115 # type is implicitly aligned to its natural length (although this can be
116 # over-ridden with an explicit third parameter), and that the structure
117 # is padded at the end to its overall alignment.
120 #########################################################################
122 #ifndef _SHA1_MB_MGR_DATASTRUCT_ASM_
123 #define _SHA1_MB_MGR_DATASTRUCT_ASM_
131 ## FIELD name size align
132 .macro FIELD name size align
133 _FIELD_OFFSET = (_FIELD_OFFSET + (\align) - 1) & (~ ((\align)-1))
134 \name = _FIELD_OFFSET
135 _FIELD_OFFSET = _FIELD_OFFSET + (\size)
136 .if (\align > _STRUCT_ALIGN)
137 _STRUCT_ALIGN = \align
143 _FIELD_OFFSET = (_FIELD_OFFSET + _STRUCT_ALIGN-1) & (~ (_STRUCT_ALIGN-1))
146 ########################################################################
156 tmp = (_FIELD_OFFSET - %%tmp)
163 ## RES_int name size align
164 .macro RES_int p1 p2 p3
169 _FIELD_OFFSET = (_FIELD_OFFSET + (align) - 1) & (~ ((align)-1))
172 _FIELD_OFFSET = _FIELD_OFFSET + (size)
173 .if (align > _STRUCT_ALIGN)
174 _STRUCT_ALIGN = align
180 # macro RES_B name, size [, align]
181 .macro RES_B _name, _size, _align=1
182 RES_int _name _size _align
185 # macro RES_W name, size [, align]
186 .macro RES_W _name, _size, _align=2
187 RES_int _name 2*(_size) _align
190 # macro RES_D name, size [, align]
191 .macro RES_D _name, _size, _align=4
192 RES_int _name 4*(_size) _align
195 # macro RES_Q name, size [, align]
196 .macro RES_Q _name, _size, _align=8
197 RES_int _name 8*(_size) _align
200 # macro RES_DQ name, size [, align]
201 .macro RES_DQ _name, _size, _align=16
202 RES_int _name 16*(_size) _align
205 # macro RES_Y name, size [, align]
206 .macro RES_Y _name, _size, _align=32
207 RES_int _name 32*(_size) _align
210 # macro RES_Z name, size [, align]
211 .macro RES_Z _name, _size, _align=64
212 RES_int _name 64*(_size) _align
218 ########################################################################
219 #### Define constants
220 ########################################################################
222 ########################################################################
223 #### Define SHA1 Out Of Order Data Structures
224 ########################################################################
226 START_FIELDS # LANE_DATA
228 FIELD _job_in_lane, 8, 8 # pointer to job object
231 _LANE_DATA_size = _FIELD_OFFSET
232 _LANE_DATA_align = _STRUCT_ALIGN
234 ########################################################################
236 START_FIELDS # SHA1_ARGS_X8
238 FIELD _digest, 4*5*8, 16 # transposed digest
239 FIELD _data_ptr, 8*8, 8 # array of pointers to data
242 _SHA1_ARGS_X4_size = _FIELD_OFFSET
243 _SHA1_ARGS_X4_align = _STRUCT_ALIGN
244 _SHA1_ARGS_X8_size = _FIELD_OFFSET
245 _SHA1_ARGS_X8_align = _STRUCT_ALIGN
247 ########################################################################
249 START_FIELDS # MB_MGR
251 FIELD _args, _SHA1_ARGS_X4_size, _SHA1_ARGS_X4_align
253 FIELD _unused_lanes, 8, 8
254 FIELD _ldata, _LANE_DATA_size*8, _LANE_DATA_align
257 _MB_MGR_size = _FIELD_OFFSET
258 _MB_MGR_align = _STRUCT_ALIGN
260 _args_digest = _args + _digest
261 _args_data_ptr = _args + _data_ptr
264 ########################################################################
265 #### Define constants
266 ########################################################################
268 #define STS_UNKNOWN 0
269 #define STS_BEING_PROCESSED 1
270 #define STS_COMPLETED 2
272 ########################################################################
273 #### Define JOB_SHA1 structure
274 ########################################################################
276 START_FIELDS # JOB_SHA1
279 FIELD _buffer, 8, 8 # pointer to buffer
280 FIELD _len, 4, 4 # length in bytes
281 FIELD _result_digest, 5*4, 32 # Digest (output)
283 FIELD _user_data, 8, 8
286 _JOB_SHA1_size = _FIELD_OFFSET
287 _JOB_SHA1_align = _STRUCT_ALIGN