2 * Optmized version of the ip_fast_csum() function
3 * Used for calculating IP header checksum
5 * Return: 16bit checksum, complemented
8 * in0: address of buffer to checksum (char *)
9 * in1: length of the buffer (int)
11 * Copyright (C) 2002 Intel Corp.
12 * Copyright (C) 2002 Ken Chen <kenneth.w.chen@intel.com>
15 #include <asm/asmmacro.h>
18 * Since we know that most likely this function is called with buf aligned
19 * on 4-byte boundary and 20 bytes in length, we can execution rather quickly
20 * versus calling generic version of do_csum, which has lots of overhead in
21 * handling various alignments and sizes. However, due to lack of constrains
22 * put on the function input argument, cases with alignment not on 4-byte or
23 * size not equal to 20 bytes will be handled by the generic do_csum function.
30 GLOBAL_ENTRY(ip_fast_csum)
33 cmp.ne p6,p7=5,in1 // size other than 20 byte?
34 and r14=3,in0 // is it aligned on 4-byte?
35 add r15=4,in0 // second source pointer
37 cmp.ne.or.andcm p6,p7=r14,r0
54 shr.u ret0=r20,16 // now need to add the carry
59 shr.u ret0=r20,16 // add carry again
70 .restore sp // reset frame state
77 alloc r35=ar.pfs,2,2,2,0
84 br.call.sptk.many b0=do_csum