Commit | Line | Data |
---|---|---|
11617778 TC |
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 | ||
55 | # Macros for defining data structures | |
56 | ||
57 | # Usage example | |
58 | ||
59 | #START_FIELDS # JOB_AES | |
60 | ### name size align | |
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, \ | |
69 | # size2, align2, \ | |
70 | # size3, align3, \ | |
71 | # ... | |
72 | #END_FIELDS | |
73 | #%assign _JOB_AES_size _FIELD_OFFSET | |
74 | #%assign _JOB_AES_align _STRUCT_ALIGN | |
75 | ||
76 | ######################################################################### | |
77 | ||
78 | # Alternate "struc-like" syntax: | |
79 | # STRUCT job_aes2 | |
80 | # RES_Q .plaintext, 1 | |
81 | # RES_Q .ciphertext, 1 | |
82 | # RES_DQ .IV, 1 | |
83 | # RES_B .nested, _JOB_AES_SIZE, _JOB_AES_ALIGN | |
84 | # RES_U .union, size1, align1, \ | |
85 | # size2, align2, \ | |
86 | # ... | |
87 | # ENDSTRUCT | |
88 | # # Following only needed if nesting | |
89 | # %assign job_aes2_size _FIELD_OFFSET | |
90 | # %assign job_aes2_align _STRUCT_ALIGN | |
91 | # | |
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. | |
95 | # The macros are: | |
96 | # Macro Base size | |
97 | # RES_B 1 | |
98 | # RES_W 2 | |
99 | # RES_D 4 | |
100 | # RES_Q 8 | |
101 | # RES_DQ 16 | |
102 | # RES_Y 32 | |
103 | # RES_Z 64 | |
104 | # | |
105 | # RES_U defines a union. It's arguments are a name and two or more | |
106 | # pairs of "size, alignment" | |
107 | # | |
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. | |
111 | # | |
112 | # Note that for nesting, you still need to assign to STRUCT_NAME_size. | |
113 | # | |
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. | |
118 | # | |
119 | ||
120 | ######################################################################### | |
121 | ||
122 | #ifndef _SHA1_MB_MGR_DATASTRUCT_ASM_ | |
123 | #define _SHA1_MB_MGR_DATASTRUCT_ASM_ | |
124 | ||
125 | ## START_FIELDS | |
126 | .macro START_FIELDS | |
127 | _FIELD_OFFSET = 0 | |
128 | _STRUCT_ALIGN = 0 | |
129 | .endm | |
130 | ||
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 | |
138 | .endif | |
139 | .endm | |
140 | ||
141 | ## END_FIELDS | |
142 | .macro END_FIELDS | |
143 | _FIELD_OFFSET = (_FIELD_OFFSET + _STRUCT_ALIGN-1) & (~ (_STRUCT_ALIGN-1)) | |
144 | .endm | |
145 | ||
146 | ######################################################################## | |
147 | ||
148 | .macro STRUCT p1 | |
149 | START_FIELDS | |
150 | .struc \p1 | |
151 | .endm | |
152 | ||
153 | .macro ENDSTRUCT | |
154 | tmp = _FIELD_OFFSET | |
155 | END_FIELDS | |
156 | tmp = (_FIELD_OFFSET - %%tmp) | |
157 | .if (tmp > 0) | |
158 | .lcomm tmp | |
159 | .endif | |
160 | .endstruc | |
161 | .endm | |
162 | ||
163 | ## RES_int name size align | |
164 | .macro RES_int p1 p2 p3 | |
165 | name = \p1 | |
166 | size = \p2 | |
167 | align = .\p3 | |
168 | ||
169 | _FIELD_OFFSET = (_FIELD_OFFSET + (align) - 1) & (~ ((align)-1)) | |
170 | .align align | |
171 | .lcomm name size | |
172 | _FIELD_OFFSET = _FIELD_OFFSET + (size) | |
173 | .if (align > _STRUCT_ALIGN) | |
174 | _STRUCT_ALIGN = align | |
175 | .endif | |
176 | .endm | |
177 | ||
178 | ||
179 | ||
180 | # macro RES_B name, size [, align] | |
181 | .macro RES_B _name, _size, _align=1 | |
182 | RES_int _name _size _align | |
183 | .endm | |
184 | ||
185 | # macro RES_W name, size [, align] | |
186 | .macro RES_W _name, _size, _align=2 | |
187 | RES_int _name 2*(_size) _align | |
188 | .endm | |
189 | ||
190 | # macro RES_D name, size [, align] | |
191 | .macro RES_D _name, _size, _align=4 | |
192 | RES_int _name 4*(_size) _align | |
193 | .endm | |
194 | ||
195 | # macro RES_Q name, size [, align] | |
196 | .macro RES_Q _name, _size, _align=8 | |
197 | RES_int _name 8*(_size) _align | |
198 | .endm | |
199 | ||
200 | # macro RES_DQ name, size [, align] | |
201 | .macro RES_DQ _name, _size, _align=16 | |
202 | RES_int _name 16*(_size) _align | |
203 | .endm | |
204 | ||
205 | # macro RES_Y name, size [, align] | |
206 | .macro RES_Y _name, _size, _align=32 | |
207 | RES_int _name 32*(_size) _align | |
208 | .endm | |
209 | ||
210 | # macro RES_Z name, size [, align] | |
211 | .macro RES_Z _name, _size, _align=64 | |
212 | RES_int _name 64*(_size) _align | |
213 | .endm | |
214 | ||
215 | ||
216 | #endif | |
217 | ||
218 | ######################################################################## | |
219 | #### Define constants | |
220 | ######################################################################## | |
221 | ||
222 | ######################################################################## | |
223 | #### Define SHA1 Out Of Order Data Structures | |
224 | ######################################################################## | |
225 | ||
226 | START_FIELDS # LANE_DATA | |
227 | ### name size align | |
228 | FIELD _job_in_lane, 8, 8 # pointer to job object | |
229 | END_FIELDS | |
230 | ||
231 | _LANE_DATA_size = _FIELD_OFFSET | |
232 | _LANE_DATA_align = _STRUCT_ALIGN | |
233 | ||
234 | ######################################################################## | |
235 | ||
236 | START_FIELDS # SHA1_ARGS_X8 | |
237 | ### name size align | |
238 | FIELD _digest, 4*5*8, 16 # transposed digest | |
239 | FIELD _data_ptr, 8*8, 8 # array of pointers to data | |
240 | END_FIELDS | |
241 | ||
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 | |
246 | ||
247 | ######################################################################## | |
248 | ||
249 | START_FIELDS # MB_MGR | |
250 | ### name size align | |
251 | FIELD _args, _SHA1_ARGS_X4_size, _SHA1_ARGS_X4_align | |
252 | FIELD _lens, 4*8, 8 | |
253 | FIELD _unused_lanes, 8, 8 | |
254 | FIELD _ldata, _LANE_DATA_size*8, _LANE_DATA_align | |
255 | END_FIELDS | |
256 | ||
257 | _MB_MGR_size = _FIELD_OFFSET | |
258 | _MB_MGR_align = _STRUCT_ALIGN | |
259 | ||
260 | _args_digest = _args + _digest | |
261 | _args_data_ptr = _args + _data_ptr | |
262 | ||
263 | ||
264 | ######################################################################## | |
265 | #### Define constants | |
266 | ######################################################################## | |
267 | ||
268 | #define STS_UNKNOWN 0 | |
269 | #define STS_BEING_PROCESSED 1 | |
270 | #define STS_COMPLETED 2 | |
271 | ||
272 | ######################################################################## | |
273 | #### Define JOB_SHA1 structure | |
274 | ######################################################################## | |
275 | ||
276 | START_FIELDS # JOB_SHA1 | |
277 | ||
278 | ### name size align | |
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) | |
282 | FIELD _status, 4, 4 | |
283 | FIELD _user_data, 8, 8 | |
284 | END_FIELDS | |
285 | ||
286 | _JOB_SHA1_size = _FIELD_OFFSET | |
287 | _JOB_SHA1_align = _STRUCT_ALIGN |