From owner-cvs-src@FreeBSD.ORG Tue Feb 7 00:36:10 2006 Return-Path: X-Original-To: cvs-src@freebsd.org Delivered-To: cvs-src@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9967A16A422 for ; Tue, 7 Feb 2006 00:36:10 +0000 (GMT) (envelope-from pyunyh@gmail.com) Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.198]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4979843D49 for ; Tue, 7 Feb 2006 00:36:08 +0000 (GMT) (envelope-from pyunyh@gmail.com) Received: by xproxy.gmail.com with SMTP id s9so855009wxc for ; Mon, 06 Feb 2006 16:36:07 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:date:from:to:cc:subject:message-id:reply-to:references:mime-version:content-type:content-disposition:in-reply-to:user-agent; b=bBOqGihtxPNUBSotC1H/aWbJKt6etgL0swKpnB6sP3rn5fpuDv6hv50D+wpw5bc1gZ3O1pZhiSLIVLe3O8CjMy22edoCD8Bj2EQXtEeqSz9wQARaMTaOT8bkTbROSX3LLQaVyL0zWxzaMATnnBFRgMmyf/W9+v6IGzQ7wPy2KNE= Received: by 10.70.92.1 with SMTP id p1mr6943711wxb; Mon, 06 Feb 2006 16:36:03 -0800 (PST) Received: from michelle.cdnetworks.co.kr ( [10.254.4.223]) by mx.gmail.com with ESMTP id h39sm5392940wxd.2006.02.06.16.36.01; Mon, 06 Feb 2006 16:36:03 -0800 (PST) Received: from michelle.cdnetworks.co.kr (localhost.cdnetworks.co.kr [127.0.0.1]) by michelle.cdnetworks.co.kr (8.13.5/8.13.5) with ESMTP id k170YD8B012005 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 7 Feb 2006 09:34:13 +0900 (KST) (envelope-from pyunyh@gmail.com) Received: (from yongari@localhost) by michelle.cdnetworks.co.kr (8.13.5/8.13.5/Submit) id k170YBlC012004; Tue, 7 Feb 2006 09:34:11 +0900 (KST) (envelope-from pyunyh@gmail.com) Date: Tue, 7 Feb 2006 09:34:11 +0900 From: Pyun YongHyeon To: Nate Lawson Message-ID: <20060207003411.GA11752@rndsoft.co.kr> References: <200602020958.k129wWtc066930@repoman.freebsd.org> <20060202100637.GB24350@lath.rinet.ru> <20060205235817.GQ5499@cs.rice.edu> <20060206221141.GA57775@lath.rinet.ru> <43E7CBD5.5090203@root.org> <20060206223436.GB57775@lath.rinet.ru> <43E7D662.6000608@root.org> <43E7DAC2.8060101@root.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <43E7DAC2.8060101@root.org> User-Agent: Mutt/1.4.2.1i Cc: Alan Cox , src-committers@FreeBSD.org, Oleg Bulyzhin , cvs-all@FreeBSD.org, cvs-src@FreeBSD.org Subject: Re: cvs commit: src/sys/dev/bge if_bge.c X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: pyunyh@gmail.com List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Feb 2006 00:36:10 -0000 On Mon, Feb 06, 2006 at 03:24:50PM -0800, Nate Lawson wrote: > Nate Lawson wrote: > >Oleg Bulyzhin wrote: > > > >>On Mon, Feb 06, 2006 at 02:21:09PM -0800, Nate Lawson wrote: > >> > >>>Oleg Bulyzhin wrote: > >>> > >>>> nq = q->m_nextpkt; > >>>> q->m_nextpkt = NULL; > >>>> m->m_pkthdr.csum_flags &= q->m_pkthdr.csum_flags; > >>>>- m->m_pkthdr.csum_data += q->m_pkthdr.csum_data; > >>>>+ sum = m->m_pkthdr.csum_data + q->m_pkthdr.csum_data; > >>>>+ m->m_pkthdr.csum_data = (sum & 0xffff) + (sum >> 16); > >>>> m_cat(m, q); > >>>> } > >>>>#ifdef MAC > >>> > >>> > >>>I'm not familiar with this code. So m->m_pkthdr.csum_data is 32 > >>>bits? Couldn't the same thing be achieved with making it 16 bits > >>>since the add will wrap normally? > >> > >> > >>It will not work cause it's not just a trivial sum it's so called > >>"1's complement sum" (refer rfc1071 for details). > > > > > >You're right, but aren't you missing the NOT step? > >1. 2's complement sum > >2. Add in carry > >3. 1's complement of result (not) > > Sam Leffler mentioned this comment from NetBSD would be helpful. Might > you add it to clear up misunderstandings like I had? > > sys/mbuf.h has useful comments not found in the freebsd file: > > /* > * record/packet header in first mbuf of chain; valid if M_PKTHDR set > * > * A note about csum_data: For the out-bound direction, the low 16 bits > * indicates the offset after the L4 header where the final L4 checksum > value > * is to be stored and the high 16 bits is the length of the L3 header (the > * start of the data to be checksumed). For the in-bound direction, it AFAIK FreeBSD doesn't embed the length of the L3 header in csum_data. If we do that it would help much for hardwares that lacks hardware pseudo checksum capability.(e.g. hme(4), sk(4) etc) ATM these drivers should find out L3 header length by traversing the mbuf chain. > is only > * valid if the M_CSUM_DATA flag is set. In this case, an L4 checksum > has been > * calculated by hardware, but it is up to software to perform final > * verification. > * > * Note for in-bound TCP/UDP checksums, we expect the csum_data to NOT > * be bit-wise inverted (the final step in the calculation of an IP > * checksum) -- this is so we can accumulate the checksum for fragmented > * packets during reassembly. > */ > > Thanks, > -- > Nate -- Regards, Pyun YongHyeon