csum_ipv6_magic.S 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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);
  10. *
  11. * Misalignment handling (which costs 16 instructions / 8 cycles)
  12. * added by Ivan Kokshaysky <ink@jurassic.park.msu.ru>
  13. */
  14. #include <asm/export.h>
  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. ldq_u $0,0($16) # e0 : load src & dst addr words
  22. zapnot $20,15,$20 # .. e1 : zero extend incoming csum
  23. extqh $18,1,$4 # e0 : byte swap len & proto while we wait
  24. ldq_u $21,7($16) # .. e1 : handle misalignment
  25. extbl $18,1,$5 # e0 :
  26. ldq_u $1,8($16) # .. e1 :
  27. extbl $18,2,$6 # e0 :
  28. ldq_u $22,15($16) # .. e1 :
  29. extbl $18,3,$18 # e0 :
  30. ldq_u $2,0($17) # .. e1 :
  31. sra $4,32,$4 # e0 :
  32. ldq_u $23,7($17) # .. e1 :
  33. extql $0,$16,$0 # e0 :
  34. ldq_u $3,8($17) # .. e1 :
  35. extqh $21,$16,$21 # e0 :
  36. ldq_u $24,15($17) # .. e1 :
  37. sll $5,16,$5 # e0 :
  38. or $0,$21,$0 # .. e1 : 1st src word complete
  39. extql $1,$16,$1 # e0 :
  40. addq $20,$0,$20 # .. e1 : begin summing the words
  41. extqh $22,$16,$22 # e0 :
  42. cmpult $20,$0,$0 # .. e1 :
  43. sll $6,8,$6 # e0 :
  44. or $1,$22,$1 # .. e1 : 2nd src word complete
  45. extql $2,$17,$2 # e0 :
  46. or $4,$18,$18 # .. e1 :
  47. extqh $23,$17,$23 # e0 :
  48. or $5,$6,$5 # .. e1 :
  49. extql $3,$17,$3 # e0 :
  50. or $2,$23,$2 # .. e1 : 1st dst word complete
  51. extqh $24,$17,$24 # e0 :
  52. or $18,$5,$18 # .. e1 : len complete
  53. extwh $19,7,$7 # e0 :
  54. or $3,$24,$3 # .. e1 : 2nd dst word complete
  55. extbl $19,1,$19 # e0 :
  56. addq $20,$1,$20 # .. e1 :
  57. or $19,$7,$19 # e0 :
  58. cmpult $20,$1,$1 # .. e1 :
  59. sll $19,48,$19 # e0 :
  60. nop # .. e0 :
  61. sra $19,32,$19 # e0 : proto complete
  62. addq $20,$2,$20 # .. e1 :
  63. cmpult $20,$2,$2 # e0 :
  64. addq $20,$3,$20 # .. e1 :
  65. cmpult $20,$3,$3 # e0 :
  66. addq $20,$18,$20 # .. e1 :
  67. cmpult $20,$18,$18 # e0 :
  68. addq $20,$19,$20 # .. e1 :
  69. cmpult $20,$19,$19 # e0 :
  70. addq $0,$1,$0 # .. e1 : merge the carries back into the csum
  71. addq $2,$3,$2 # e0 :
  72. addq $18,$19,$18 # .. e1 :
  73. addq $0,$2,$0 # e0 :
  74. addq $20,$18,$20 # .. e1 :
  75. addq $0,$20,$0 # e0 :
  76. unop # :
  77. extwl $0,2,$2 # e0 : begin folding the 64-bit value
  78. zapnot $0,3,$3 # .. e1 :
  79. extwl $0,4,$1 # e0 :
  80. addq $2,$3,$3 # .. e1 :
  81. extwl $0,6,$0 # e0 :
  82. addq $3,$1,$3 # .. e1 :
  83. addq $0,$3,$0 # e0 :
  84. unop # :
  85. extwl $0,2,$1 # e0 : fold 18-bit value
  86. zapnot $0,3,$0 # .. e1 :
  87. addq $0,$1,$0 # e0 :
  88. unop # :
  89. extwl $0,2,$1 # e0 : fold 17-bit value
  90. zapnot $0,3,$0 # .. e1 :
  91. addq $0,$1,$0 # e0 :
  92. not $0,$0 # .. e1 : and complement.
  93. zapnot $0,3,$0 # e0 :
  94. ret # .. e1 :
  95. .end csum_ipv6_magic
  96. EXPORT_SYMBOL(csum_ipv6_magic)