2002-04-11 15:04:32

by Abraham vd Merwe

[permalink] [raw]
Subject: CHECKSUM_HW not behaving as expected

Hi!

In Rubini's "Linux Device Drivers 2nd edition" he states in his networking
chapter that skb->ip_summed = CHECKSUM_HW means that the hardware already
performed a checksum and that the upper layers therefore don't need to do it
(He also states that CHECKSUM_NONE (default) means that it still needs to be
verified).

I'm currently writing a network driver for 2.4.17 and the chip automatically
performs checksums and you can tell it to exclude the CRC from the packet or
not before making it available for the host. Now, if I configure it to
exclude the CRC and use skb->ip_summed = CHECKSUM_HW I get:

root@frodo:/# ./ldm
Using /cs8900.o
CS8900A driver for 2d3D, SA-1110 Development Board.
eth0: CS8900A rev D detected
configuring network:.
root@frodo:/# icmp v4 hw csum failure
icmp v4 hw csum failure
icmp v4 hw csum failure
icmp v4 hw csum failure
icmp v4 hw csum failure
icmp v4 hw csum failure
icmp v4 hw csum failure
icmp v4 hw csum failure
icmp v4 hw csum failure
icmp v4 hw csum failure
icmp v4 hw csum failure
icmp v4 hw csum failure
NET: 3 messages suppressed.
icmp v4 hw csum failure

root@frodo:/#
------------< snip <------< snip <------< snip <------------

If I used CHECKSUM_NONE, it works fine which obviously means that the CRC is
not computed in software.

Is that a bug in the kernel or does Alessandro have it wrong?

--

Regards
Abraham

There is one difference between a tax collector and a taxidermist --
the taxidermist leaves the hide.
-- Mortimer Caplan

__________________________________________________________
Abraham vd Merwe - 2d3D, Inc.

Device Driver Development, Outsourcing, Embedded Systems

Cell: +27 82 565 4451 Snailmail:
Tel: +27 21 761 7549 Block C, Aintree Park
Fax: +27 21 761 7648 Doncaster Road
Email: [email protected] Kenilworth, 7700
Http: http://www.2d3d.com South Africa


Attachments:
(No filename) (1.85 kB)
(No filename) (232.00 B)
Download all attachments

2002-04-11 15:10:26

by David Miller

[permalink] [raw]
Subject: Re: CHECKSUM_HW not behaving as expected


Rubini's book is wrong, CHECKSUM_HW means the chip computed the pseudo
checksum of the packet and this computed value is in skb->csum

You want to set CHECKSUM_UNNECESSARY, see include/linux/skbuff.h which
documents all of these variables.

2002-04-11 15:30:45

by Richard B. Johnson

[permalink] [raw]
Subject: Re: CHECKSUM_HW not behaving as expected

On Thu, 11 Apr 2002, Abraham vd Merwe wrote:

> Hi!
>
> In Rubini's "Linux Device Drivers 2nd edition" he states in his networking
> chapter that skb->ip_summed = CHECKSUM_HW means that the hardware already
> performed a checksum and that the upper layers therefore don't need to do it
> (He also states that CHECKSUM_NONE (default) means that it still needs to be
> verified).
>
> I'm currently writing a network driver for 2.4.17 and the chip automatically
> performs checksums and you can tell it to exclude the CRC from the packet or
> not before making it available for the host. Now, if I configure it to
> exclude the CRC and use skb->ip_summed = CHECKSUM_HW I get:
>

CRC not!
The IP checksum is not the CRC. Some new network boards "know" about
the IP checksum and can compute it. The CRC is a hardware-computed CRC
that is appended to every Ethernet packet. The CRC must be received
intact or the packet is rejected (dropped). If it's possible to 'tell'
your board to exclude the CRC, this is not what you want.

If you already know this, then the possible problem is that the
packet length is wrong. The IP checksum is a 16-bit integer of
16-bit integers. This means that the packet length must be an even
number. Your driver may be returning the wrong length. Also, when
you transmit, if the hardware is going to do the checksum, what
does it expect at the checksum offset in the IP packet? Hardware
checksums usually don't 'skip' some offset so the checksum value
should probably be 0 when it goes to your hardware.

Cheers,
Dick Johnson

Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips).

Windows-2000/Professional isn't.

2002-04-11 15:36:41

by David Miller

[permalink] [raw]
Subject: Re: CHECKSUM_HW not behaving as expected


The CRC is not his problem, ipv4 will truncate it off it is
there. In any event, see my other email, he thinks CHECKSUM_HW is
CHECKSUM_UNNECESSARY due to a bug in Rubinni's book.

2002-04-11 15:36:54

by Abraham vd Merwe

[permalink] [raw]
Subject: Re: CHECKSUM_HW not behaving as expected

Hi Richard!

> > In Rubini's "Linux Device Drivers 2nd edition" he states in his networking
> > chapter that skb->ip_summed = CHECKSUM_HW means that the hardware already
> > performed a checksum and that the upper layers therefore don't need to do it
> > (He also states that CHECKSUM_NONE (default) means that it still needs to be
> > verified).
> >
> > I'm currently writing a network driver for 2.4.17 and the chip automatically
> > performs checksums and you can tell it to exclude the CRC from the packet or
> > not before making it available for the host. Now, if I configure it to
> > exclude the CRC and use skb->ip_summed = CHECKSUM_HW I get:
> >
>
> CRC not!
> The IP checksum is not the CRC. Some new network boards "know" about
> the IP checksum and can compute it. The CRC is a hardware-computed CRC
> that is appended to every Ethernet packet. The CRC must be received
> intact or the packet is rejected (dropped). If it's possible to 'tell'
> your board to exclude the CRC, this is not what you want.

No, you misunderstood. The card still verify the CRC. You can just instruct
it not to include it in the frame that you want to copy, e.g. say you
receive a 64-byte ethernet frame, then it can either tell you "copy from my
buffer 64 bytes" or if you're not interested in the CRC, "copy 60 bytes from
my buffer"

What I don't want is for the kernel to verify the CRC again since it's
already been done by the hardware (and I save 4 bytes on the copy (: )

> If you already know this, then the possible problem is that the
> packet length is wrong. The IP checksum is a 16-bit integer of
> 16-bit integers. This means that the packet length must be an even
> number. Your driver may be returning the wrong length. Also, when
> you transmit, if the hardware is going to do the checksum, what
> does it expect at the checksum offset in the IP packet? Hardware
> checksums usually don't 'skip' some offset so the checksum value
> should probably be 0 when it goes to your hardware.

Dope. Somehow I thought it was the "ethernet frame checksum" - not quite the
same thing :P

--

Regards
Abraham

You will pioneer the first Martian colony.

__________________________________________________________
Abraham vd Merwe - 2d3D, Inc.

Device Driver Development, Outsourcing, Embedded Systems

Cell: +27 82 565 4451 Snailmail:
Tel: +27 21 761 7549 Block C, Aintree Park
Fax: +27 21 761 7648 Doncaster Road
Email: [email protected] Kenilworth, 7700
Http: http://www.2d3d.com South Africa


Attachments:
(No filename) (2.50 kB)
(No filename) (232.00 B)
Download all attachments

2002-04-11 15:37:43

by Richard B. Johnson

[permalink] [raw]
Subject: Re: CHECKSUM_HW not behaving as expected

On Thu, 11 Apr 2002, David S. Miller wrote:

>
> The CRC is not his problem, ipv4 will truncate it off it is
> there. In any event, see my other email, he thinks CHECKSUM_HW is
> CHECKSUM_UNNECESSARY due to a bug in Rubinni's book.
>

Okay. Good.

Cheers,
Dick Johnson

Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips).

Windows-2000/Professional isn't.