forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/arch/xtensa/lib/checksum.S
....@@ -1,3 +1,4 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 * INET An implementation of the TCP/IP protocol suite for the LINUX
34 * operating system. INET is implemented using the BSD Socket
....@@ -7,17 +8,12 @@
78 *
89 * Xtensa version: Copyright (C) 2001 Tensilica, Inc. by Kevin Chea
910 * Optimized by Joe Taylor
10
- *
11
- * This program is free software; you can redistribute it and/or
12
- * modify it under the terms of the GNU General Public License
13
- * as published by the Free Software Foundation; either version
14
- * 2 of the License, or (at your option) any later version.
1511 */
1612
1713 #include <linux/errno.h>
1814 #include <linux/linkage.h>
19
-#include <variant/core.h>
2015 #include <asm/asmmacro.h>
16
+#include <asm/core.h>
2117
2218 /*
2319 * computes a partial checksum, e.g. for TCP/UDP fragments
....@@ -47,7 +43,7 @@
4743 * Experiments with Ethernet and SLIP connections show that buf
4844 * is aligned on either a 2-byte or 4-byte boundary.
4945 */
50
- entry sp, 32
46
+ abi_entry_default
5147 extui a5, a2, 0, 2
5248 bnez a5, 8f /* branch if 2-byte aligned */
5349 /* Fall-through on common case, 4-byte alignment */
....@@ -111,7 +107,7 @@
111107 ONES_ADD(a4, a6)
112108 7:
113109 mov a2, a4
114
- retw
110
+ abi_ret_default
115111
116112 /* uncommon case, buf is 2-byte aligned */
117113 8:
....@@ -179,19 +175,14 @@
179175 */
180176
181177 /*
182
-unsigned int csum_partial_copy_generic (const char *src, char *dst, int len,
183
- int sum, int *src_err_ptr, int *dst_err_ptr)
178
+unsigned int csum_partial_copy_generic (const char *src, char *dst, int len)
184179 a2 = src
185180 a3 = dst
186181 a4 = len
187182 a5 = sum
188
- a6 = src_err_ptr
189
- a7 = dst_err_ptr
190183 a8 = temp
191184 a9 = temp
192185 a10 = temp
193
- a11 = original len for exception handling
194
- a12 = original dst for exception handling
195186
196187 This function is optimized for 4-byte aligned addresses. Other
197188 alignments work, but not nearly as efficiently.
....@@ -199,9 +190,8 @@
199190
200191 ENTRY(csum_partial_copy_generic)
201192
202
- entry sp, 32
203
- mov a12, a3
204
- mov a11, a4
193
+ abi_entry_default
194
+ movi a5, -1
205195 or a10, a2, a3
206196
207197 /* We optimize the following alignment tests for the 4-byte
....@@ -232,26 +222,26 @@
232222 #endif
233223 EX(10f) l32i a9, a2, 0
234224 EX(10f) l32i a8, a2, 4
235
-EX(11f) s32i a9, a3, 0
236
-EX(11f) s32i a8, a3, 4
225
+EX(10f) s32i a9, a3, 0
226
+EX(10f) s32i a8, a3, 4
237227 ONES_ADD(a5, a9)
238228 ONES_ADD(a5, a8)
239229 EX(10f) l32i a9, a2, 8
240230 EX(10f) l32i a8, a2, 12
241
-EX(11f) s32i a9, a3, 8
242
-EX(11f) s32i a8, a3, 12
231
+EX(10f) s32i a9, a3, 8
232
+EX(10f) s32i a8, a3, 12
243233 ONES_ADD(a5, a9)
244234 ONES_ADD(a5, a8)
245235 EX(10f) l32i a9, a2, 16
246236 EX(10f) l32i a8, a2, 20
247
-EX(11f) s32i a9, a3, 16
248
-EX(11f) s32i a8, a3, 20
237
+EX(10f) s32i a9, a3, 16
238
+EX(10f) s32i a8, a3, 20
249239 ONES_ADD(a5, a9)
250240 ONES_ADD(a5, a8)
251241 EX(10f) l32i a9, a2, 24
252242 EX(10f) l32i a8, a2, 28
253
-EX(11f) s32i a9, a3, 24
254
-EX(11f) s32i a8, a3, 28
243
+EX(10f) s32i a9, a3, 24
244
+EX(10f) s32i a8, a3, 28
255245 ONES_ADD(a5, a9)
256246 ONES_ADD(a5, a8)
257247 addi a2, a2, 32
....@@ -271,7 +261,7 @@
271261 .Loop6:
272262 #endif
273263 EX(10f) l32i a9, a2, 0
274
-EX(11f) s32i a9, a3, 0
264
+EX(10f) s32i a9, a3, 0
275265 ONES_ADD(a5, a9)
276266 addi a2, a2, 4
277267 addi a3, a3, 4
....@@ -302,7 +292,7 @@
302292 .Loop7:
303293 #endif
304294 EX(10f) l16ui a9, a2, 0
305
-EX(11f) s16i a9, a3, 0
295
+EX(10f) s16i a9, a3, 0
306296 ONES_ADD(a5, a9)
307297 addi a2, a2, 2
308298 addi a3, a3, 2
....@@ -313,14 +303,14 @@
313303 /* This section processes a possible trailing odd byte. */
314304 _bbci.l a4, 0, 8f /* 1-byte chunk */
315305 EX(10f) l8ui a9, a2, 0
316
-EX(11f) s8i a9, a3, 0
306
+EX(10f) s8i a9, a3, 0
317307 #ifdef __XTENSA_EB__
318308 slli a9, a9, 8 /* shift byte to bits 8..15 */
319309 #endif
320310 ONES_ADD(a5, a9)
321311 8:
322312 mov a2, a5
323
- retw
313
+ abi_ret_default
324314
325315 5:
326316 /* Control branch to here when either src or dst is odd. We
....@@ -338,8 +328,8 @@
338328 #endif
339329 EX(10f) l8ui a9, a2, 0
340330 EX(10f) l8ui a8, a2, 1
341
-EX(11f) s8i a9, a3, 0
342
-EX(11f) s8i a8, a3, 1
331
+EX(10f) s8i a9, a3, 0
332
+EX(10f) s8i a8, a3, 1
343333 #ifdef __XTENSA_EB__
344334 slli a9, a9, 8 /* combine into a single 16-bit value */
345335 #else /* for checksum computation */
....@@ -360,39 +350,8 @@
360350
361351 # Exception handler:
362352 .section .fixup, "ax"
363
-/*
364
- a6 = src_err_ptr
365
- a7 = dst_err_ptr
366
- a11 = original len for exception handling
367
- a12 = original dst for exception handling
368
-*/
369
-
370353 10:
371
- _movi a2, -EFAULT
372
- s32i a2, a6, 0 /* src_err_ptr */
373
-
374
- # clear the complete destination - computing the rest
375
- # is too much work
376354 movi a2, 0
377
-#if XCHAL_HAVE_LOOPS
378
- loopgtz a11, 2f
379
-#else
380
- beqz a11, 2f
381
- add a11, a11, a12 /* a11 = ending address */
382
-.Leloop:
383
-#endif
384
- s8i a2, a12, 0
385
- addi a12, a12, 1
386
-#if !XCHAL_HAVE_LOOPS
387
- blt a12, a11, .Leloop
388
-#endif
389
-2:
390
- retw
391
-
392
-11:
393
- movi a2, -EFAULT
394
- s32i a2, a7, 0 /* dst_err_ptr */
395
- movi a2, 0
396
- retw
355
+ abi_ret_default
397356
398357 .previous