Networking Forums

Networking Forums > Computer Networking > Linux Networking > Checksum code in linux kernel

Reply
Thread Tools Display Modes

Checksum code in linux kernel

 
 
Perianayagam Somasundaram
Guest
Posts: n/a

 
      10-27-2005, 04:44 AM
Hi,

I was just looking at the csum_partial in
arch/i386/lib/checksum.S.

For sake of simplicity, I am going to paste code
where I have
some have some questions.

139 csum_partial:
140 pushl %esi
141 pushl %ebx
142 movl 20(%esp),%eax #
Function arg: unsigned int sum
143 movl 16(%esp),%ecx #
Function arg: int len
144 movl 12(%esp),%esi #
Function arg: const unsigned char *buf
145
146 testl $3, %esi
147 jnz 25f
148 10:
149 movl %ecx, %edx
150 movl %ecx, %ebx
151 andl $0x7c, %ebx
152 shrl $7, %ecx
153 addl %ebx,%esi
154 shrl $2, %ebx
155 negl %ebx
156 lea 45f(%ebx,%ebx,2), %ebx
157 testl %esi, %esi
158 jmp *%ebx
...
...
...
194 addl -128(%esi), %eax
195 adcl -124(%esi), %eax
...
198 adcl -112(%esi), %eax
...
223 adcl -12(%esi), %eax
224 adcl -8(%esi), %eax
225 adcl -4(%esi), %eax
226 45:
227 lea 128(%esi), %esi
228 adcl $0, %eax
229 dec %ecx
230 jge 40b

So I do understand the loop unrolling part for
performance based
optimizations. My questions is in pretext to
calculation of the
address using ebx register in line <156>. The
routine cannot make
any assumptions about the len being passed. But it
uses it in the
calculation of ebx, which then is translated into
a offset. Now
this offset is added to the address of "45f" and
stored into ebx
and then the indirect jmp.

I also have noticed that the offset varies by an
amount of 3
bytes. Coincidentally, that also happens to be the
length of
"adcl x(%esi), %eax". Is there an implicit
assumption of the
instruction length in bytes of "adcl x(%esi),
%eax"? That is what
I infer from all the groundwork I have done.

On the other hand, given my inference is wrong,
then this code
can throw a panic if the instruction length of
"adcl x(%esi),
%eax" changes ( which it may not ).

cheers
Somu
************************************************** ***********************
"I've never understood how God could expect his
creatures
to pick the one true religion by faith - it
strikes me as a
sloppy way to run a universe."
Robert A. Heinlein
STRANGER IN A STRANGE LAND
************************************************** ***********************
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
profiling kernel routing code. how to do it? Azeem Linux Networking 0 09-20-2007 04:03 AM
Port winsock code to linux Matthew Clark Linux Networking 2 08-12-2006 12:14 AM
Is there any Linux Distri available to run several instances of Linux Kernel?. GS Linux Networking 5 05-20-2005 11:18 AM
How to handle TCP checksum, if adapter support TCP checksum offloading? Rajesh Gupta Windows Networking 0 08-02-2004 11:20 PM
netif_rx kernel networking code question Webmaster Linux Networking 0 05-21-2004 12:21 PM



1 2 3 4 5 6 7 8 9 10 11