From: Tom Evans <tom@ceos.com.au>
To: u-boot@lists.denx.de
Subject: [U-Boot] ARM: net.c: UDP Checksum code failing every packet
Date: Tue, 19 Aug 2008 11:25:45 +1000 [thread overview]
Message-ID: <48AA2119.30509@ceos.com.au> (raw)
In-Reply-To: <mailman.195.1218828565.2783.u-boot@lists.denx.de>
UDP Checksumming is enabled with the configuration variable
CONFIG_UDP_CHECKSUM. This is only enabled in 7 out of 437
include/configs/*.h files. Enabling UDP checksumming can be useful, as
it allows any errors (in downloading via TFTP) to be retried rather than
resulting in an image CRC error when the whole download has finished.
The download isn't meant to fail, but I'm seeing intermittent corrupted
downloads currently.
If CONFIG_UDP_CHECKSUM is enabled on an ARM core, and the CPU is prior
to ARM Core Version 6, all packets are reported as having checksum errors.
This is due to the ARM's 32-bit alignment requirements and the following
four lines of code in net/net.c::NetReceive()
xsum += (ntohl(ip->ip_src) >> 16) & 0x0000ffff;
xsum += (ntohl(ip->ip_src) >> 0) & 0x0000ffff;
xsum += (ntohl(ip->ip_dst) >> 16) & 0x0000ffff;
xsum += (ntohl(ip->ip_dst) >> 0) & 0x0000ffff;
The original Ethernet packet is (usually, this is not controlled) 32-bit
aligned, the Ethernet header is 14 bytes long, so by design the aligned
fields in the IP (and other) headers are all misaligned, at least with
the NE2000 driver we're using.
ARM (prior to V6) "silently corrupts" misaligned reads. For 32-bit reads
offset by 16 bits it reads 32-bits from the aligned address two bytes
below that requested, and then swaps the words.
If the above lines are changed to match other related ARM-related
modifications as follows, then the UDP checksum code works:
tmp = NetReadIP(&ip->ip_src);
xsum += (ntohl(tmp) >> 16) & 0x0000ffff;
xsum += (ntohl(tmp) >> 0) & 0x0000ffff;
tmp = NetReadIP(&ip->ip_dst);
xsum += (ntohl(tmp) >> 16) & 0x0000ffff;
xsum += (ntohl(tmp) >> 0) & 0x0000ffff;
I'm afraid I can't generate a patch to do this. Could someone else
please incorporate this change if required?
----
Tom Evans
next parent reply other threads:[~2008-08-19 1:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.195.1218828565.2783.u-boot@lists.denx.de>
2008-08-19 1:25 ` Tom Evans [this message]
2008-08-19 2:57 ` [U-Boot] ARM: net.c: UDP Checksum code failing every packet Ben Warren
[not found] ` <48AA45B9.7000501@ceos.com.au>
2008-08-19 4:27 ` Ben Warren
[not found] ` <48AA4D6A.1090309@ceos.com.au>
2008-08-19 4:41 ` Ben Warren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48AA2119.30509@ceos.com.au \
--to=tom@ceos.com.au \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox