lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] lwip_standard_chksum()


From: Timmy Brolin
Subject: Re: [lwip-users] lwip_standard_chksum()
Date: Thu, 08 Dec 2005 22:52:41 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)

Yes, I think I might have a better idea.
This solution would even improve performance on machines which support unaligned memory accesses.

First test if the address is unaligned.
If aligned:
  Do a normal 16bit checksum.
else:
  Read first byte (and add to checksum).
  Then continue by doing a normal 16bit checksum.
At the end we need to byte-swap the result to compensate for the off-by-one-byte 16bit additions.

I think this should work, and significantly improve performance for all non 8-bit architectures since it prevents unaligned memory accesses. (unaligned memory accesses usually take about twice as long as aligned accesses)

I do not like the idea of putting a 8bit checksum computation in the standard code.

Regards,
Timmy Brolin

Christiaan Simons wrote:

Hi all,

It seems lwip_standard_chksum() from inet.c 1.22 and up
is disfunctional for the c16x and likely other 16 bit mcu's.

As far as I understand the problem is in that the source data
(void *dataptr ... ) can be at an odd (unaligned) address.

This was "solved" by a patch posted by Peter Jolasson
a few months ago and was partially committed by Leon.
(a crude/dubious runtime test for odd addresses was removed)

IMHO we need to change our reference implementation
to be correct for any architecture.

I've got some ideas:

* Add octets (byte-by-byte) instead of 16 bit words as shown in RFC1071 p5.
This will lower the performance for >8 bit architectures (a lot),
but will be alignment independant.

* Revert to the pre 1.22 routine, and enforce compile-time alignment by
changing
the function argument "void* dataptr" into "u16_t* dataptr" _and_ ensure
that  pbuf->payload pointers (all args passed to LWIP_CHKSUM) are aligned
to u16_t.

Anyone got another (better) idea?

Christiaan Simons

Hardware Engineer
Axon Digital Design

+31 (0)13 511 66 66
+31 (0)13 511 41 51

http://www.axon.tv



This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the system manager.
This message contains confidential information and is intended only for the
individual named.  If you are not the named addressee you should not
disseminate, distribute or copy this e-mail.



_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users







reply via email to

[Prev in Thread] Current Thread [Next in Thread]