Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * arch/alpha/lib/csum_ipv6_magic.S |
| 3 | * Contributed by Richard Henderson <rth@tamu.edu> |
| 4 | * |
| 5 | * unsigned short csum_ipv6_magic(struct in6_addr *saddr, |
| 6 | * struct in6_addr *daddr, |
| 7 | * __u32 len, |
| 8 | * unsigned short proto, |
| 9 | * unsigned int csum); |
Ivan Kokshaysky | 58ed2f9 | 2007-06-23 17:16:35 -0700 | [diff] [blame] | 10 | * |
| 11 | * Misalignment handling (which costs 16 instructions / 8 cycles) |
| 12 | * added by Ivan Kokshaysky <ink@jurassic.park.msu.ru> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | */ |
| 14 | |
| 15 | .globl csum_ipv6_magic |
| 16 | .align 4 |
| 17 | .ent csum_ipv6_magic |
| 18 | .frame $30,0,$26,0 |
| 19 | csum_ipv6_magic: |
| 20 | .prologue 0 |
| 21 | |
Ivan Kokshaysky | 58ed2f9 | 2007-06-23 17:16:35 -0700 | [diff] [blame] | 22 | ldq_u $0,0($16) # e0 : load src & dst addr words |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | zapnot $20,15,$20 # .. e1 : zero extend incoming csum |
| 24 | extqh $18,1,$4 # e0 : byte swap len & proto while we wait |
Ivan Kokshaysky | 58ed2f9 | 2007-06-23 17:16:35 -0700 | [diff] [blame] | 25 | ldq_u $21,7($16) # .. e1 : handle misalignment |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | |
| 27 | extbl $18,1,$5 # e0 : |
Ivan Kokshaysky | 58ed2f9 | 2007-06-23 17:16:35 -0700 | [diff] [blame] | 28 | ldq_u $1,8($16) # .. e1 : |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | extbl $18,2,$6 # e0 : |
Ivan Kokshaysky | 58ed2f9 | 2007-06-23 17:16:35 -0700 | [diff] [blame] | 30 | ldq_u $22,15($16) # .. e1 : |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
| 32 | extbl $18,3,$18 # e0 : |
Ivan Kokshaysky | 58ed2f9 | 2007-06-23 17:16:35 -0700 | [diff] [blame] | 33 | ldq_u $2,0($17) # .. e1 : |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | sra $4,32,$4 # e0 : |
Ivan Kokshaysky | 58ed2f9 | 2007-06-23 17:16:35 -0700 | [diff] [blame] | 35 | ldq_u $23,7($17) # .. e1 : |
| 36 | |
| 37 | extql $0,$16,$0 # e0 : |
| 38 | ldq_u $3,8($17) # .. e1 : |
| 39 | extqh $21,$16,$21 # e0 : |
| 40 | ldq_u $24,15($17) # .. e1 : |
| 41 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | sll $5,16,$5 # e0 : |
Ivan Kokshaysky | 58ed2f9 | 2007-06-23 17:16:35 -0700 | [diff] [blame] | 43 | or $0,$21,$0 # .. e1 : 1st src word complete |
| 44 | extql $1,$16,$1 # e0 : |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | addq $20,$0,$20 # .. e1 : begin summing the words |
| 46 | |
Ivan Kokshaysky | 58ed2f9 | 2007-06-23 17:16:35 -0700 | [diff] [blame] | 47 | extqh $22,$16,$22 # e0 : |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | cmpult $20,$0,$0 # .. e1 : |
Ivan Kokshaysky | 58ed2f9 | 2007-06-23 17:16:35 -0700 | [diff] [blame] | 49 | sll $6,8,$6 # e0 : |
| 50 | or $1,$22,$1 # .. e1 : 2nd src word complete |
| 51 | |
| 52 | extql $2,$17,$2 # e0 : |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | or $4,$18,$18 # .. e1 : |
Ivan Kokshaysky | 58ed2f9 | 2007-06-23 17:16:35 -0700 | [diff] [blame] | 54 | extqh $23,$17,$23 # e0 : |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | or $5,$6,$5 # .. e1 : |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | |
Ivan Kokshaysky | 58ed2f9 | 2007-06-23 17:16:35 -0700 | [diff] [blame] | 57 | extql $3,$17,$3 # e0 : |
| 58 | or $2,$23,$2 # .. e1 : 1st dst word complete |
| 59 | extqh $24,$17,$24 # e0 : |
| 60 | or $18,$5,$18 # .. e1 : len complete |
| 61 | |
| 62 | extwh $19,7,$7 # e0 : |
| 63 | or $3,$24,$3 # .. e1 : 2nd dst word complete |
| 64 | extbl $19,1,$19 # e0 : |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | addq $20,$1,$20 # .. e1 : |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | |
Ivan Kokshaysky | 58ed2f9 | 2007-06-23 17:16:35 -0700 | [diff] [blame] | 67 | or $19,$7,$19 # e0 : |
| 68 | cmpult $20,$1,$1 # .. e1 : |
| 69 | sll $19,48,$19 # e0 : |
| 70 | nop # .. e0 : |
| 71 | |
| 72 | sra $19,32,$19 # e0 : proto complete |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | addq $20,$2,$20 # .. e1 : |
| 74 | cmpult $20,$2,$2 # e0 : |
| 75 | addq $20,$3,$20 # .. e1 : |
| 76 | |
| 77 | cmpult $20,$3,$3 # e0 : |
| 78 | addq $20,$18,$20 # .. e1 : |
| 79 | cmpult $20,$18,$18 # e0 : |
| 80 | addq $20,$19,$20 # .. e1 : |
| 81 | |
| 82 | cmpult $20,$19,$19 # e0 : |
| 83 | addq $0,$1,$0 # .. e1 : merge the carries back into the csum |
| 84 | addq $2,$3,$2 # e0 : |
| 85 | addq $18,$19,$18 # .. e1 : |
| 86 | |
| 87 | addq $0,$2,$0 # e0 : |
| 88 | addq $20,$18,$20 # .. e1 : |
| 89 | addq $0,$20,$0 # e0 : |
| 90 | unop # : |
| 91 | |
| 92 | extwl $0,2,$2 # e0 : begin folding the 64-bit value |
| 93 | zapnot $0,3,$3 # .. e1 : |
| 94 | extwl $0,4,$1 # e0 : |
| 95 | addq $2,$3,$3 # .. e1 : |
| 96 | |
| 97 | extwl $0,6,$0 # e0 : |
| 98 | addq $3,$1,$3 # .. e1 : |
| 99 | addq $0,$3,$0 # e0 : |
| 100 | unop # : |
| 101 | |
| 102 | extwl $0,2,$1 # e0 : fold 18-bit value |
| 103 | zapnot $0,3,$0 # .. e1 : |
| 104 | addq $0,$1,$0 # e0 : |
| 105 | unop # : |
| 106 | |
| 107 | extwl $0,2,$1 # e0 : fold 17-bit value |
| 108 | zapnot $0,3,$0 # .. e1 : |
| 109 | addq $0,$1,$0 # e0 : |
Ivan Kokshaysky | 58ed2f9 | 2007-06-23 17:16:35 -0700 | [diff] [blame] | 110 | not $0,$0 # .. e1 : and complement. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | |
| 112 | zapnot $0,3,$0 # e0 : |
| 113 | ret # .. e1 : |
| 114 | |
| 115 | .end csum_ipv6_magic |