Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Jun 2004 11:38:25 +0200
From:      Alexander Leidinger <Alexander@Leidinger.net>
To:        "M. Warner Losh" <imp@bsdimp.com>
Cc:        freebsd-arch@freebsd.org
Subject:   Re: ether_crc32_[bl]e()
Message-ID:  <20040601113825.54e5b57b@Magellan.Leidinger.net>
In-Reply-To: <20040531.112057.52958848.imp@bsdimp.com>
References:  <c9d9u3$o6k$1@kemoauc.mips.inka.de> <20040531164514.GA7776@green.homeunix.org> <20040531.112057.52958848.imp@bsdimp.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 31 May 2004 11:20:57 -0600 (MDT)
"M. Warner Losh" <imp@bsdimp.com> wrote:

> In message: <20040531164514.GA7776@green.homeunix.org>
>             Brian Feldman <green@freebsd.org> writes:
> : On Sun, May 30, 2004 at 06:42:11PM +0000, Christian Weisgerber wrote:
> : > NetBSD and OpenBSD have two helper functions in if_ethersubr.c
> : > 
> : > ether_crc32_le(const u_int8_t *buf, size_t len)
> : > ether_crc32_be(const u_int8_t *buf, size_t len)
> : > [...]
> : > The patch below adds the functions to if_ethersubr.c and, as an
> : > example, switches re(4) to make use of this.
> : > 
> : > 1. Do we want this?
> : 
> : Yeah :)
> 
> I think so too.  I had something like this on my list after I found a
> very badly implemented big endian crc routine whose provenance was in
> question.  So this is excellent timing.

Is someone interested in improving our IP checksum code too?

On i386 it uses assembly language which "works ok" with gcc 3.x (so
far), but it isn't guaranteed it will work with future versions of gcc.
Intels C compiler already has problems with it (and it's verified it's
because of bugs in the asm code), so in case of the use of icc a C
version is used.

All other architectures use a C version ("MD" code, even if it could be
made MI... at least it could be shared between the big and little endian
architectures).

Matthew Dillon rewrote the IP checksum code in dragonfly:
---snip---
  Modified files:
    sys/conf             files.i386 
    sys/i386/i386        in_cksum.c 
    sys/i386/include     in_cksum.h 
    sys/netinet          igmp.c in.h ip_icmp.c 
  Added files:
    sys/i386/i386        in_cksum2.s 
  Log:
  Rewrite the IP checksum code.  Get rid of all the inline assembly garbage,
  get rid of old APIs that are no longer used, and build a new 'core' checksum
  function in C capable of handling any alignment.  Add an assembly procedure
  (in its own file) for handling large blocks of 32-bit aligned data.
  
  This new code is better suited for modern cpus and should at least as good
  as the previous code, and it is far more portable.
  
  Note that in_cksum_hdr() still assumes 32 bit alignment.  This will be fixed
  soon.
  
  Revision  Changes    Path
  1.12      +1 -0      src/sys/conf/files.i386
  1.4       +142 -558  src/sys/i386/i386/in_cksum.c
  1.5       +33 -69    src/sys/i386/include/in_cksum.h
  1.5       +2 -0      src/sys/netinet/igmp.c
  1.6       +0 -1      src/sys/netinet/in.h
  1.6       +2 -0      src/sys/netinet/ip_icmp.c
---snip---

If someone wants to look at this I can forward additional commit logs
regarding this issue (e.g. moving in_cksum.h from MD to MI).

Bye,
Alexander.

-- 
           I'm available to get hired (preferred in .lu).

http://www.Leidinger.net                       Alexander @ Leidinger.net
  GPG fingerprint = C518 BC70 E67F 143F BE91  3365 79E2 9C60 B006 3FE7



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040601113825.54e5b57b>