diff options
author | Thomas Bushnell <thomas@gnu.org> | 1997-08-20 18:21:23 +0000 |
---|---|---|
committer | Thomas Bushnell <thomas@gnu.org> | 1997-08-20 18:21:23 +0000 |
commit | 3d04a206b0238f89930bb5084683e75477eadcb2 (patch) | |
tree | 982146d6248b18c3704b4136edfa295b016bdd30 /pfinet/linux-inet/udp.c | |
parent | f0bef0ae114a10d778bc367019d509e4df03f0bd (diff) | |
download | hurd-3d04a206b0238f89930bb5084683e75477eadcb2.tar.gz hurd-3d04a206b0238f89930bb5084683e75477eadcb2.tar.bz2 hurd-3d04a206b0238f89930bb5084683e75477eadcb2.zip |
Fri Aug 8 11:47:08 1997 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* linux-inet/tcp.c (tcp_check): Move to end of file so it isn't
inlined and can be profiled easily.
* linux-inet/udp.c (udp_check): Likewise.
Diffstat (limited to 'pfinet/linux-inet/udp.c')
-rw-r--r-- | pfinet/linux-inet/udp.c | 142 |
1 files changed, 71 insertions, 71 deletions
diff --git a/pfinet/linux-inet/udp.c b/pfinet/linux-inet/udp.c index be4cf928..420f24b3 100644 --- a/pfinet/linux-inet/udp.c +++ b/pfinet/linux-inet/udp.c @@ -152,77 +152,6 @@ void udp_err(int err, unsigned char *header, unsigned long daddr, } -static unsigned short udp_check(struct udphdr *uh, int len, unsigned long saddr, unsigned long daddr) -{ - unsigned long sum; - - __asm__( "\t addl %%ecx,%%ebx\n" - "\t adcl %%edx,%%ebx\n" - "\t adcl $0, %%ebx\n" - : "=b"(sum) - : "0"(daddr), "c"(saddr), "d"((ntohs(len) << 16) + IPPROTO_UDP*256) - : "cx","bx","dx" ); - - if (len > 3) - { - __asm__("\tclc\n" - "1:\n" - "\t lodsl\n" - "\t adcl %%eax, %%ebx\n" - "\t loop 1b\n" - "\t adcl $0, %%ebx\n" - : "=b"(sum) , "=S"(uh) - : "0"(sum), "c"(len/4) ,"1"(uh) - : "ax", "cx", "bx", "si" ); - } - - /* - * Convert from 32 bits to 16 bits. - */ - - __asm__("\t movl %%ebx, %%ecx\n" - "\t shrl $16,%%ecx\n" - "\t addw %%cx, %%bx\n" - "\t adcw $0, %%bx\n" - : "=b"(sum) - : "0"(sum) - : "bx", "cx"); - - /* - * Check for an extra word. - */ - - if ((len & 2) != 0) - { - __asm__("\t lodsw\n" - "\t addw %%ax,%%bx\n" - "\t adcw $0, %%bx\n" - : "=b"(sum), "=S"(uh) - : "0"(sum) ,"1"(uh) - : "si", "ax", "bx"); - } - - /* - * Now check for the extra byte. - */ - - if ((len & 1) != 0) - { - __asm__("\t lodsb\n" - "\t movb $0,%%ah\n" - "\t addw %%ax,%%bx\n" - "\t adcw $0, %%bx\n" - : "=b"(sum) - : "0"(sum) ,"S"(uh) - : "si", "ax", "bx"); - } - - /* - * We only want the bottom 16 bits, but we never cleared the top 16. - */ - - return((~sum) & 0xffff); -} /* * Generate UDP checksums. These may be disabled, eg for fast NFS over ethernet @@ -738,3 +667,74 @@ struct proto udp_prot = { 0, 0 }; +static unsigned short udp_check(struct udphdr *uh, int len, unsigned long saddr, unsigned long daddr) +{ + unsigned long sum; + + __asm__( "\t addl %%ecx,%%ebx\n" + "\t adcl %%edx,%%ebx\n" + "\t adcl $0, %%ebx\n" + : "=b"(sum) + : "0"(daddr), "c"(saddr), "d"((ntohs(len) << 16) + IPPROTO_UDP*256) + : "cx","bx","dx" ); + + if (len > 3) + { + __asm__("\tclc\n" + "1:\n" + "\t lodsl\n" + "\t adcl %%eax, %%ebx\n" + "\t loop 1b\n" + "\t adcl $0, %%ebx\n" + : "=b"(sum) , "=S"(uh) + : "0"(sum), "c"(len/4) ,"1"(uh) + : "ax", "cx", "bx", "si" ); + } + + /* + * Convert from 32 bits to 16 bits. + */ + + __asm__("\t movl %%ebx, %%ecx\n" + "\t shrl $16,%%ecx\n" + "\t addw %%cx, %%bx\n" + "\t adcw $0, %%bx\n" + : "=b"(sum) + : "0"(sum) + : "bx", "cx"); + + /* + * Check for an extra word. + */ + + if ((len & 2) != 0) + { + __asm__("\t lodsw\n" + "\t addw %%ax,%%bx\n" + "\t adcw $0, %%bx\n" + : "=b"(sum), "=S"(uh) + : "0"(sum) ,"1"(uh) + : "si", "ax", "bx"); + } + + /* + * Now check for the extra byte. + */ + + if ((len & 1) != 0) + { + __asm__("\t lodsb\n" + "\t movb $0,%%ah\n" + "\t addw %%ax,%%bx\n" + "\t adcw $0, %%bx\n" + : "=b"(sum) + : "0"(sum) ,"S"(uh) + : "si", "ax", "bx"); + } + + /* + * We only want the bottom 16 bits, but we never cleared the top 16. + */ + + return((~sum) & 0xffff); +} |