Subject: Re: about powerpc version of in{,4}_cksum
To: enami tsugutomo <enami@sm.sony.co.jp>
From: Bill Studenmund <wrstuden@netbsd.org>
List: port-powerpc
Date: 07/30/2002 10:10:21
On Tue, 30 Jul 2002, enami tsugutomo wrote:

> There is some bug and some possible improvement for current powerpc
> version of in{,4}_cksum (which is found in
> sys/arch/powerpc/powerpc/in_cksum.c).  Highlight is:
>
> 1) addze 7,7 or addze %1,%1 are used to clear carry bit, but they
>    aren't correct.  The former fails to clear if junk register r7
>    happen to contain 0xffffffff, and the latter may crobber non-junk
>    (i.e., necessary) register.
>
> 2) When adjusting to 4 byte boundary, just adding 16bit value to the
>    variable `sum' isn't enough, since the `sum' may have full 32bit
>    value there, depending on how a packet is divided into mbufs.  So,
>    we need to care carry bit.  This actually prevented my Mac
>    (g4-500dp) from netbooting.  (we can REDUCE instead but it results
>    longer instructions).
>
> 3) In asm statemnt, constraint letter "b" (base register) should be
>    used instead of "r" for pointer operand.
>
> 4) Load with update is slower than ordinary load (+ add) depending on
>    implementation (this is written in powerpc programming manual).
>    With appended changes below, in4_cksum for a paticular packet
>    (which is a nfs packet I've used to debug 2) above) runs about 15%
>    faster on my Mac.  I'm not sure how this affects other powerpc
>    variant though.
>
> Comments?

Heh. And posting on problems with this routine was on my schedule for
today. :-)

I've been working on the NFS bug reported by Erik Anggard
<erik.anggard@packetfront.com>, because I encountered a similar bug while
compiling X over an nfs mount.

> ***************
> *** 229,234 ****
> --- 236,242 ----
>   int
>   in_cksum(struct mbuf *m, int len)
>   {
> +
>   	return (in_cksum_internal(m, 0, len, 0));
>   }
>
>

This change is the only one I'm not sure about. :-)

Please commit it and request a pullup to 1.6.

Thanks!

Take care,

Bill