From owner-freebsd-current@FreeBSD.ORG Tue Apr 26 21:47:51 2005 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2282E16A4CF for ; Tue, 26 Apr 2005 21:47:51 +0000 (GMT) Received: from 62-15-211-171.inversas.jazztel.es (62-15-211-171.inversas.jazztel.es [62.15.211.171]) by mx1.FreeBSD.org (Postfix) with ESMTP id 996C643D48 for ; Tue, 26 Apr 2005 21:47:49 +0000 (GMT) (envelope-from josemi@freebsd.jazztel.es) Received: from redesjm.local (orion.redesjm.local [192.168.254.16]) j3QLlfVg022606; Tue, 26 Apr 2005 23:47:42 +0200 (CEST) (envelope-from josemi@redesjm.local) Received: from localhost (localhost [[UNIX: localhost]]) by redesjm.local (8.13.3/8.13.3/Submit) id j3QLle4i081349; Tue, 26 Apr 2005 23:47:40 +0200 (CEST) (envelope-from josemi@redesjm.local) From: Jose M Rodriguez To: Marcel Moolenaar Date: Tue, 26 Apr 2005 23:47:38 +0200 User-Agent: KMail/1.8 References: <200504261143.55195.josemi@redesjm.local> <200504262222.41463.josemi@redesjm.local> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200504262347.39919.josemi@redesjm.local> X-AntiVirus: checked by AntiVir Milter (version: 1.1.0-3; AVE: 6.30.0.7; VDF: 6.30.0.116; host: antares.redesjm.local) cc: freebsd-current@freebsd.org cc: Jose M Rodriguez Subject: Re: rigth crc32 implementation X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Apr 2005 21:47:51 -0000 El Martes, 26 de Abril de 2005 23:28, Marcel Moolenaar escribi=F3: > On Apr 26, 2005, at 1:22 PM, Jose M Rodriguez wrote: > > El Martes, 26 de Abril de 2005 21:42, Marcel Moolenaar escribi=F3: > >> On Tue, Apr 26, 2005 at 11:43:54AM +0200, Jose M Rodriguez wrote: > >>> My first think was use the libkern based one, but I found: > >>> sys/linkern/crc32.c > >>> > >>> - the code may not be endian safe. > >> > >> It operates on bytes, so it's endian-safe. Note that the uint32_t > >> that's returned is not subject to endianness issues: it's always > >> in the native byte order. The caller of crc32 needs to byteswap > >> if it needs to compare this integral with a CRC that's not in > >> the native byte order. > > > > Yes, but this code come from a previous reduction: calculate the > > table from a xor/shift bit oriented alg. > > True, but doesn't that imply that the reduction is > endian-independent? There's no big end and/or little end to a bit, so > to speak. The values in the table are the result of mathematical > calculations, which by definition do not depend on the endianness of > the machine that was used to compute them. Yes, the in-memory > representation of those values do differ but that's not the issue. > > Or am I missing something (possibly very obvious)? > > > Looking at sys/net/if_ethersubr.c ether_crc32_be() & > > ether_crc32_le(), I > > became to doubt if we need two tables, with bitesex based #ifs. > > I think those are =042 different algorithms altogether. As far as I can > tell, there's no need for it. A shift-right on a little-endian box > yields the same effect as a shift-right on a big-endian box. It > effectively divides the value by two. That you won't achieve if the > shift-right moves the bits towards the most-significant bit, right? > > So why does one do a shift-right when the other does a shift-left? > Why does one define the carry as the least-significant bit and the > other as the most-significant bit? > > Again: math has never been my strongest ability, so it's possible > that I simply have a mathematical cross-wire in my head preventing > me from thinking mathematically clearly :-) I think so. Also, I found no driver use both, and we have ether drivers=20 that works in all platforms. So this will cover diff between the=20 system and the chip. This make sense. So, what about add those 2/3 functions. I'll prefer this to carry=20 another private version of crc32. =2D- josemi