1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#include <linux/errno.h>
18#include <linux/linkage.h>
19#include <variant/core.h>
20#include <asm/asmmacro.h>
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37#define ONES_ADD(sum, val) \
38 add sum, sum, val ; \
39 bgeu sum, val, 99f ; \
40 addi sum, sum, 1 ; \
4199: ;
42
43.text
44ENTRY(csum_partial)
45
46
47
48
49
50 entry sp, 32
51 extui a5, a2, 0, 2
52 bnez a5, 8f
53
541:
55 srli a5, a3, 5
56
57 loopgtz a5, 2f
58#else
59 beqz a5, 2f
60 slli a5, a5, 5
61 add a5, a5, a2
62.Loop1:
63#endif
64 l32i a6, a2, 0
65 l32i a7, a2, 4
66 ONES_ADD(a4, a6)
67 ONES_ADD(a4, a7)
68 l32i a6, a2, 8
69 l32i a7, a2, 12
70 ONES_ADD(a4, a6)
71 ONES_ADD(a4, a7)
72 l32i a6, a2, 16
73 l32i a7, a2, 20
74 ONES_ADD(a4, a6)
75 ONES_ADD(a4, a7)
76 l32i a6, a2, 24
77 l32i a7, a2, 28
78 ONES_ADD(a4, a6)
79 ONES_ADD(a4, a7)
80 addi a2, a2, 4*8
81
82 blt a2, a5, .Loop1
83#endif
842:
85 extui a5, a3, 2, 3
86
87 loopgtz a5, 3f
88#else
89 beqz a5, 3f
90 slli a5, a5, 2
91 add a5, a5, a2
92.Loop2:
93#endif
94 l32i a6, a2, 0
95 ONES_ADD(a4, a6)
96 addi a2, a2, 4
97
98 blt a2, a5, .Loop2
99#endif
1003:
101 _bbci.l a3, 1, 5f
102 l16ui a6, a2, 0
103 ONES_ADD(a4, a6)
104 addi a2, a2, 2
1055:
106 _bbci.l a3, 0, 7f
1076: l8ui a6, a2, 0
108#ifdef __XTENSA_EB__
109 slli a6, a6, 8
110#endif
111 ONES_ADD(a4, a6)
1127:
113 mov a2, a4
114 retw
115
116
1178:
118 beqz a3, 7b
119 beqi a3, 1, 6b
120
121 extui a5, a2, 0, 1
122 bnez a5, 8f
123
124 l16ui a6, a2, 0
125 ONES_ADD(a4, a6)
126 addi a2, a2, 2
127 addi a3, a3, -2
128 j 1b
129
130
131
132
133
1348:
135 srli a5, a3, 2
136
137 loopgtz a5, 2f
138#else
139 beqz a5, 2f
140 slli a5, a5, 2
141 add a5, a5, a2
142.Loop3:
143#endif
144 l8ui a6, a2, 0
145 l16ui a7, a2, 1
146 l8ui a8, a2, 3
147#ifdef __XTENSA_EB__
148 slli a6, a6, 24
149#else
150 slli a8, a8, 24
151#endif
152 slli a7, a7, 8
153 or a7, a7, a6
154 or a7, a7, a8
155 ONES_ADD(a4, a7)
156 addi a2, a2, 4
157
158 blt a2, a5, .Loop3
159#endif
1602:
161 _bbci.l a3, 1, 3f
162 l8ui a6, a2, 0
163 l8ui a7, a2, 1
164#ifdef __XTENSA_EB__
165 slli a6, a6, 8
166#else
167 slli a7, a7, 8
168#endif
169 or a7, a7, a6
170 ONES_ADD(a4, a7)
171 addi a2, a2, 2
1723:
173 j 5b
174
175ENDPROC(csum_partial)
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200ENTRY(csum_partial_copy_generic)
201
202 entry sp, 32
203 mov a12, a3
204 mov a11, a4
205 or a10, a2, a3
206
207
208
209
210
211
212
213
214 extui a9, a10, 0, 2
215 beqz a9, 1f
216 bbsi.l a10, 0, 5f
217 j 3f
218
219
220
221
2221:
223
224 srli a10, a4, 5
225
226 loopgtz a10, 2f
227#else
228 beqz a10, 2f
229 slli a10, a10, 5
230 add a10, a10, a2
231.Loop5:
232#endif
233EX(10f) l32i a9, a2, 0
234EX(10f) l32i a8, a2, 4
235EX(11f) s32i a9, a3, 0
236EX(11f) s32i a8, a3, 4
237 ONES_ADD(a5, a9)
238 ONES_ADD(a5, a8)
239EX(10f) l32i a9, a2, 8
240EX(10f) l32i a8, a2, 12
241EX(11f) s32i a9, a3, 8
242EX(11f) s32i a8, a3, 12
243 ONES_ADD(a5, a9)
244 ONES_ADD(a5, a8)
245EX(10f) l32i a9, a2, 16
246EX(10f) l32i a8, a2, 20
247EX(11f) s32i a9, a3, 16
248EX(11f) s32i a8, a3, 20
249 ONES_ADD(a5, a9)
250 ONES_ADD(a5, a8)
251EX(10f) l32i a9, a2, 24
252EX(10f) l32i a8, a2, 28
253EX(11f) s32i a9, a3, 24
254EX(11f) s32i a8, a3, 28
255 ONES_ADD(a5, a9)
256 ONES_ADD(a5, a8)
257 addi a2, a2, 32
258 addi a3, a3, 32
259
260 blt a2, a10, .Loop5
261#endif
2622:
263 extui a10, a4, 2, 3
264 extui a4, a4, 0, 2
265
266 loopgtz a10, 3f
267#else
268 beqz a10, 3f
269 slli a10, a10, 2
270 add a10, a10, a2
271.Loop6:
272#endif
273EX(10f) l32i a9, a2, 0
274EX(11f) s32i a9, a3, 0
275 ONES_ADD(a5, a9)
276 addi a2, a2, 4
277 addi a3, a3, 4
278
279 blt a2, a10, .Loop6
280#endif
2813:
282
283
284
285
286
287
288
289
290
291
292
293
294
295 srli a10, a4, 1
296
297 loopgtz a10, 4f
298#else
299 beqz a10, 4f
300 slli a10, a10, 1
301 add a10, a10, a2
302.Loop7:
303#endif
304EX(10f) l16ui a9, a2, 0
305EX(11f) s16i a9, a3, 0
306 ONES_ADD(a5, a9)
307 addi a2, a2, 2
308 addi a3, a3, 2
309
310 blt a2, a10, .Loop7
311#endif
3124:
313
314 _bbci.l a4, 0, 8f
315EX(10f) l8ui a9, a2, 0
316EX(11f) s8i a9, a3, 0
317#ifdef __XTENSA_EB__
318 slli a9, a9, 8
319#endif
320 ONES_ADD(a5, a9)
3218:
322 mov a2, a5
323 retw
324
3255:
326
327
328
329
330 srli a10, a4, 1
331
332 loopgtz a10, 6f
333#else
334 beqz a10, 6f
335 slli a10, a10, 1
336 add a10, a10, a2
337.Loop8:
338#endif
339EX(10f) l8ui a9, a2, 0
340EX(10f) l8ui a8, a2, 1
341EX(11f) s8i a9, a3, 0
342EX(11f) s8i a8, a3, 1
343#ifdef __XTENSA_EB__
344 slli a9, a9, 8
345#else
346 slli a8, a8, 8
347#endif
348 or a9, a9, a8
349 ONES_ADD(a5, a9)
350 addi a2, a2, 2
351 addi a3, a3, 2
352
353 blt a2, a10, .Loop8
354#endif
3556:
356 j 4b
357
358ENDPROC(csum_partial_copy_generic)
359
360
361
362.section .fixup, "ax"
363
364
365
366
367
368
369
37010:
371 _movi a2, -EFAULT
372 s32i a2, a6, 0
373
374
375
376 movi a2, 0
377
378 loopgtz a11, 2f
379#else
380 beqz a11, 2f
381 add a11, a11, a12
382.Leloop:
383#endif
384 s8i a2, a12, 0
385 addi a12, a12, 1
386
387 blt a12, a11, .Leloop
388#endif
3892:
390 retw
391
39211:
393 movi a2, -EFAULT
394 s32i a2, a7, 0
395 movi a2, 0
396 retw
397
398.previous
399