1 /* SPDX-License-Identifier: GPL-2.0 */
3 * arch/alpha/lib/csum_ipv6_magic.S
4 * Contributed by Richard Henderson <rth@tamu.edu>
6 * unsigned short csum_ipv6_magic(struct in6_addr *saddr,
7 * struct in6_addr *daddr,
9 * unsigned short proto,
12 * Misalignment handling (which costs 16 instructions / 8 cycles)
13 * added by Ivan Kokshaysky <ink@jurassic.park.msu.ru>
16 #include <asm/export.h>
17 .globl csum_ipv6_magic
24 ldq_u $0,0($16) # e0 : load src & dst addr words
25 zapnot $20,15,$20 # .. e1 : zero extend incoming csum
26 extqh $18,1,$4 # e0 : byte swap len & proto while we wait
27 ldq_u $21,7($16) # .. e1 : handle misalignment
30 ldq_u $1,8($16) # .. e1 :
32 ldq_u $22,15($16) # .. e1 :
34 extbl $18,3,$18 # e0 :
35 ldq_u $2,0($17) # .. e1 :
37 ldq_u $23,7($17) # .. e1 :
39 extql $0,$16,$0 # e0 :
40 ldq_u $3,8($17) # .. e1 :
41 extqh $21,$16,$21 # e0 :
42 ldq_u $24,15($17) # .. e1 :
45 or $0,$21,$0 # .. e1 : 1st src word complete
46 extql $1,$16,$1 # e0 :
47 addq $20,$0,$20 # .. e1 : begin summing the words
49 extqh $22,$16,$22 # e0 :
50 cmpult $20,$0,$0 # .. e1 :
52 or $1,$22,$1 # .. e1 : 2nd src word complete
54 extql $2,$17,$2 # e0 :
55 or $4,$18,$18 # .. e1 :
56 extqh $23,$17,$23 # e0 :
59 extql $3,$17,$3 # e0 :
60 or $2,$23,$2 # .. e1 : 1st dst word complete
61 extqh $24,$17,$24 # e0 :
62 or $18,$5,$18 # .. e1 : len complete
65 or $3,$24,$3 # .. e1 : 2nd dst word complete
66 extbl $19,1,$19 # e0 :
67 addq $20,$1,$20 # .. e1 :
70 cmpult $20,$1,$1 # .. e1 :
74 sra $19,32,$19 # e0 : proto complete
75 addq $20,$2,$20 # .. e1 :
76 cmpult $20,$2,$2 # e0 :
77 addq $20,$3,$20 # .. e1 :
79 cmpult $20,$3,$3 # e0 :
80 addq $20,$18,$20 # .. e1 :
81 cmpult $20,$18,$18 # e0 :
82 addq $20,$19,$20 # .. e1 :
84 cmpult $20,$19,$19 # e0 :
85 addq $0,$1,$0 # .. e1 : merge the carries back into the csum
87 addq $18,$19,$18 # .. e1 :
90 addq $20,$18,$20 # .. e1 :
94 extwl $0,2,$2 # e0 : begin folding the 64-bit value
95 zapnot $0,3,$3 # .. e1 :
97 addq $2,$3,$3 # .. e1 :
100 addq $3,$1,$3 # .. e1 :
104 extwl $0,2,$1 # e0 : fold 18-bit value
105 zapnot $0,3,$0 # .. e1 :
109 extwl $0,2,$1 # e0 : fold 17-bit value
110 zapnot $0,3,$0 # .. e1 :
112 not $0,$0 # .. e1 : and complement.
114 zapnot $0,3,$0 # e0 :
118 EXPORT_SYMBOL(csum_ipv6_magic)