From: Ben Warren <biggerbadderben@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] ARM: net.c: UDP Checksum code failing every packet
Date: Mon, 18 Aug 2008 19:57:07 -0700 [thread overview]
Message-ID: <48AA3683.3020705@gmail.com> (raw)
In-Reply-To: <48AA2119.30509@ceos.com.au>
Hi Tom,
Tom Evans wrote:
> 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?
>
>
Everything seems logical until this point. Why can't you create a patch?
regards,
Ben
next prev parent reply other threads:[~2008-08-19 2:57 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 ` [U-Boot] ARM: net.c: UDP Checksum code failing every packet Tom Evans
2008-08-19 2:57 ` Ben Warren [this message]
[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=48AA3683.3020705@gmail.com \
--to=biggerbadderben@gmail.com \
--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