From owner-freebsd-current@FreeBSD.ORG Wed Jul 11 21:07:08 2007 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id EF26F16A480; Wed, 11 Jul 2007 21:07:08 +0000 (UTC) (envelope-from dillon@apollo.backplane.com) Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by mx1.freebsd.org (Postfix) with ESMTP id D6DB313C480; Wed, 11 Jul 2007 21:07:08 +0000 (UTC) (envelope-from dillon@apollo.backplane.com) Received: from apollo.backplane.com (localhost [127.0.0.1]) by apollo.backplane.com (8.13.8/8.13.7) with ESMTP id l6BL78A0061859; Wed, 11 Jul 2007 14:07:08 -0700 (PDT) Received: (from dillon@localhost) by apollo.backplane.com (8.13.8/8.13.4/Submit) id l6BL77Gj061858; Wed, 11 Jul 2007 14:07:07 -0700 (PDT) Date: Wed, 11 Jul 2007 14:07:07 -0700 (PDT) From: Matthew Dillon Message-Id: <200707112107.l6BL77Gj061858@apollo.backplane.com> To: Zhouyi Zhou References: <20070709105547.71827eb8.zhouzhouyi@FreeBSD.org> <20070709115637.sapzl5uq3osw4gc4@webmail.leidinger.net> <00d901c7c222$109cb310$f100a8c0@iosdf17a8152bc> Cc: Alexander Leidinger , freebsd-current@freebsd.org, freebsd-hackers@freebsd.org Subject: Re: rewrite src/sys/i386/i386/in_cksum.c X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 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: Wed, 11 Jul 2007 21:07:09 -0000 Here's a reference to the DragonFly code: http://www.dragonflybsd.org/cvsweb/src/sys/cpu/i386/misc/in_cksum2.s http://www.dragonflybsd.org/cvsweb/src/sys/netinet/in_cksum.c It's pretty simple. The core 1's complement checksum is now written in machine-dependant assembly and ONLY handles multiples of 32 bit words. In otherwords, no special cases. The mbuf wrapper is written in machine-independant C, calls the assembly for the bulk of the work, and handles all the edge cases. The rewrite is much cleaner and the code documentation is actually understandable. Plus only a very simple core needs to be written in assembly and the C wrapper is machine independant, instead of embedding the assembly with the C and praying the compiler doesn't blow things up. -Matt Matthew Dillon