Rework the in4_cksum() code a bit.

This commit is contained in:
mycroft 2001-03-06 19:14:37 +00:00
parent f208d4f546
commit f7a6910822
1 changed files with 28 additions and 31 deletions

View File

@ -1,7 +1,7 @@
/* $NetBSD: in_cksum.s,v 1.10 2001/03/06 14:55:14 fvdl Exp $ */ /* $NetBSD: in_cksum.s,v 1.11 2001/03/06 19:14:37 mycroft Exp $ */
/*- /*-
* Copyright (c) 1998 The NetBSD Foundation, Inc. * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
* *
* This code is derived from software contributed to The NetBSD Foundation * This code is derived from software contributed to The NetBSD Foundation
@ -125,46 +125,43 @@ ENTRY(in4_cksum)
pushl %esi pushl %esi
movl 16(%esp), %ebp movl 16(%esp), %ebp
movzbl 20(%esp), %eax movzbl 20(%esp), %eax /* sum = nxt */
shl $8, %eax /* sum = w[0] (== nxt << 8) */ movl 28(%esp), %esi
movzwl 28(%esp), %ebx
rorw $8, %bx
addl %ebx, %eax /* sum += htons(len) */
movl M_DATA(%ebp), %ebx movl M_DATA(%ebp), %ebx
ADC(IP_SRC) /* sum += mtod(m,struct ip *)->ip_src */ addl %esi, %eax /* sum += len */
ADC(IP_DST) movl 24(%esp), %edx /* %edx = off */
shll $8, %eax /* sum = htons(sum) */
ADD(IP_SRC) /* sum += ip->ip_src */
ADC(IP_DST) /* sum += ip->ip_dst */
MOP MOP
movl 24(%esp), %esi
mbuf_loop_0: mbuf_loop_0:
testl %ebp, %ebp testl %ebp, %ebp
jz skip_done jz out_of_mbufs
cmpl $0, %esi movl M_LEN(%ebp), %ecx /* %ecx = m_len */
jae skip_done subl %ecx, %edx /* %edx = off - m_len */
movl M_LEN(%ebp), %edx jb skip_done
cmpl %edx, %esi
ja skip_done
subl %edx, %esi
movl M_NEXT(%ebp), %ebp movl M_NEXT(%ebp), %ebp
jmp mbuf_loop_0 jmp mbuf_loop_0
skip_done:
testl %ebp, %ebp
jz out_of_mbufs
movl M_DATA(%ebp), %ebx skip_done:
movl M_LEN(%ebp), %edx movl M_DATA(%ebp), %ebx /* %ebx = m_data */
addl %esi, %ebx movl M_NEXT(%ebp), %ebp
subl %esi, %edx addl %edx, %ebx /* %ebx = m_data + off - m_len */
negl %edx /* %edx = m_len - off */
addl %ecx, %ebx /* %ebx = m_data + off */
xorb %cl, %cl xorb %cl, %cl
movl 28(%esp), %esi /*
* The len == 0 case is handled really inefficiently, by going through
testl %esi, %esi * the whole short_mbuf path once to get back to mbuf_loop_1 -- but
jz done * this case never happens in practice, so it's sufficient that it
* doesn't explode.
*/
jmp in4_entry jmp in4_entry
ENTRY(in_cksum) ENTRY(in_cksum)
pushl %ebp pushl %ebp
pushl %ebx pushl %ebx
@ -185,9 +182,9 @@ mbuf_loop_2:
movl M_DATA(%ebp), %ebx movl M_DATA(%ebp), %ebx
movl M_LEN(%ebp), %edx movl M_LEN(%ebp), %edx
in4_entry:
movl M_NEXT(%ebp), %ebp movl M_NEXT(%ebp), %ebp
in4_entry:
cmpl %esi, %edx cmpl %esi, %edx
jbe 1f jbe 1f
movl %esi, %edx movl %esi, %edx