Subject: Re: nfe(4) hardware checksum support
To: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
From: =?UTF-8?Q?C=C3=A9sar_Catri=C3=A1n_Carre=C3=B1o?= <ccatrian@eml.cc>
List: tech-kern
Date: 01/08/2007 13:38:19
--Signature=_Mon__8_Jan_2007_13_38_19_-0300_xc.CNCf=q8Bs0fLt
Content-Type: text/plain; charset=UTF-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit

On Sun, 7 Jan 2007 01:24:51 +0900
Izumi Tsutsui <tsutsui@ceres.dti.ne.jp> wrote:
>
> After some debugging, I notice that bit definitions of
> NFE_RX_UDP_CSUMOK and NFE_RX_TCP_CSUMOK in if_nfereg.h are
> swapped (FreeBSD doesn't seem to distinguish them in RX csum_flags).
> Updated patch is attached.
Applied.

Results obtained with iperf are shown below.
Couldn't init transfers with ttcp (tccp bug?).

> I'd like to see:
> - there is no negative side effect
It seems not by now, but I'll keep on looking.

> - any performance improvements on benchmarks like ttcp
>   (though I'm afraid we can't see it on 100baseTX with fast CPU)
> - 'vmstat -e' output on kernel with "options TCP_CSUM_COUNTERS"
>   and "options UDP_CSUM_COUNTERS"
> - packets which have bad checksum data are handled correctly
>   (I'm not sure how we can test it without special debugging programs)
> etc.
> ---
> Izumi Tsutsui

Pcap captures are available at ftp://mioficina.cjc.cl/pub/NetBSD

Regards

--
César Catrián Carreño

$ iperf -v
iperf version 2.0.2 (03 May 2005) pthreads
Server	: PII 400MHz with vr0
Client	: AMD 2800+ 1800MHz with nfe0 integrated on motherboard Asus K8N.
Both connected via crossover cable.


/* -------- SERVER OUTPUT -------- */

# uname -a
NetBSD  4.99.7 NetBSD 4.99.7 (GENERIC) #0: Thu Jan  4 20:34:00 CLST 2007  cetrox
@core.cjc.cl:/home/src/netbsd-current/src/sys/arch/i386/compile/obj/GENERIC i386


# ifconfig vr0
vr0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        address: 00:11:95:e2:18:ae
        media: Ethernet autoselect (100baseTX full-duplex)
        status: active
        inet 192.168.1.5 netmask 0xffffff00 broadcast 192.168.1.255
        inet6 fe80::211:95ff:fee2:18ae%vr0 prefixlen 64 scopeid 0x1


# iperf -s
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 32.0 KByte (default)
------------------------------------------------------------
[  4] local 192.168.1.5 port 5001 connected with 192.168.1.1 port 65475
[  4]  0.0-10.4 sec  3.68 MBytes  2.97 Mbits/sec


# iperf -s -u
------------------------------------------------------------
Server listening on UDP port 5001
Receiving 1470 byte datagrams
UDP buffer size: 40.6 KByte (default)
------------------------------------------------------------
[  3] local 192.168.1.5 port 5001 connected with 192.168.1.1 port 59906
[  3]  0.0- 0.6 sec    102 KBytes  1.39 Mbits/sec  19.596 ms  655/  726 (90%)
[  3]  0.0- 0.6 sec  1 datagrams received out-of-order

/* TCP and UDP tests with hardware checksum enabled */

# iperf -s
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 32.0 KByte (default)
------------------------------------------------------------
[  4] local 192.168.1.5 port 5001 connected with 192.168.1.1 port 65462
[  4]  0.0-10.3 sec  3.60 MBytes  2.93 Mbits/sec


# iperf -s -u
------------------------------------------------------------
Server listening on UDP port 5001
Receiving 1470 byte datagrams
UDP buffer size: 40.6 KByte (default)
------------------------------------------------------------
[  3] local 192.168.1.5 port 5001 connected with 192.168.1.1 port 56660
[  3]  0.0- 0.9 sec    189 KBytes  1.68 Mbits/sec  19.208 ms 1292/ 1424 (91%)
[  3]  0.0- 0.9 sec  1 datagrams received out-of-order


/* -------- CLIENT OUTPUT -------- */

$ uname -a
NetBSD core.cjc.cl 4.99.7 NetBSD 4.99.7 (Basado en GENERIC: 1.781) #0: Mon Jan
8 11:38:09 CLST 2007  cetrox@core.cjc.cl:/home/cetrox/src/netbsd-current/src/sys
/arch/i386/compile/SAT i386


$ ifconfig nfe0
nfe0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        capabilities=3f00<IP4CSUM_Rx,IP4CSUM_Tx,TCP4CSUM_Rx,TCP4CSUM_Tx,UDP4CSUM
_Rx,UDP4CSUM_Tx>
        enabled=0
        address: 00:15:f2:09:e2:da
        media: Ethernet autoselect (100baseTX full-duplex)
        status: active
        inet 192.168.1.1 netmask 0xffffff00 broadcast 192.168.1.255
        inet6 fe80::215:f2ff:fe09:e2da%nfe0 prefixlen 64 scopeid 0x1


$ iperf -c 192.168.1.5
------------------------------------------------------------
Client connecting to 192.168.1.5, TCP port 5001
TCP window size: 32.5 KByte (default)
------------------------------------------------------------
[  3] local 192.168.1.1 port 65475 connected with 192.168.1.5 port 5001
[  3]  0.0-10.1 sec  3.68 MBytes  3.06 Mbits/sec


$ iperf -c 192.168.1.5 -u -b 100M
------------------------------------------------------------
Client connecting to 192.168.1.5, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size: 9.00 KByte (default)
------------------------------------------------------------
[  3] local 192.168.1.1 port 62798 connected with 192.168.1.5 port 5001
[  3]  0.0-10.0 sec  1.25 MBytes  1.05 Mbits/sec
[  3] Sent 893 datagrams
[  3] Server Report:
[  3]  0.0-10.1 sec  1.25 MBytes  1.04 Mbits/sec  22.199 ms    0/  892 (0%)
[  3]  0.0-10.1 sec  1 datagrams received out-of-order


$ vmstat -e
event                                         total     rate type
tcp swcsum                                     4129        1 misc
udp swcsum                                     3912        1 misc


/* TCP and UDP tests with hardware checksum enabled */


root@core $ ifconfig nfe0 ip4csum tcp4csum udp4csum
root@core $ ifconfig nfe0
nfe0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        capabilities=3f00<IP4CSUM_Rx,IP4CSUM_Tx,TCP4CSUM_Rx,TCP4CSUM_Tx,UDP4CSUM
_Rx,UDP4CSUM_Tx>
        enabled=3f00<IP4CSUM_Rx,IP4CSUM_Tx,TCP4CSUM_Rx,TCP4CSUM_Tx,UDP4CSUM_Rx,U
DP4CSUM_Tx>
        address: 00:15:f2:09:e2:da
        media: Ethernet autoselect (100baseTX full-duplex)
        status: active
        inet 192.168.1.1 netmask 0xffffff00 broadcast 192.168.1.255
        inet6 fe80::215:f2ff:fe09:e2da%nfe0 prefixlen 64 scopeid 0x1


$ iperf -c 192.168.1.5
------------------------------------------------------------
Client connecting to 192.168.1.5, TCP port 5001
TCP window size: 32.5 KByte (default)
------------------------------------------------------------
[  3] local 192.168.1.1 port 65462 connected with 192.168.1.5 port 5001
[  3]  0.0-10.0 sec  3.60 MBytes  3.02 Mbits/sec


$ iperf -c 192.168.1.5 -u -b 100M
------------------------------------------------------------
Client connecting to 192.168.1.5, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size: 9.00 KByte (default)
------------------------------------------------------------
[  3] local 192.168.1.1 port 56660 connected with 192.168.1.5 port 5001
[  3]  0.0- 0.6 sec  2.14 MBytes  32.5 Mbits/sec
[  3] Sent 1528 datagrams
[  3] Server Report:
[  3]  0.0- 0.9 sec    189 KBytes  1.68 Mbits/sec  19.208 ms 1292/ 1424 (91%)
[  3]  0.0- 0.9 sec  1 datagrams received out-of-order
write2 failed: No buffer space available

/* event: ftp download of a ~500K package for use with sniffer. */

$ vmstat -e
event                                         total     rate type
tcp hwcsum ok                                  1957        0 misc
tcp swcsum                                     4478        1 misc
udp hwcsum ok                                     2        0 misc
udp swcsum                                     4040        1 misc

/* event: HC disabled and ftp download again. */
/* END */

--Signature=_Mon__8_Jan_2007_13_38_19_-0300_xc.CNCf=q8Bs0fLt
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (NetBSD)

iD8DBQFFonN+0CA0DpFTlnERAri/AKCSDtFogweTHNJQz17JGZdUL8IydwCaAsuP
ijI7QRtdnqzLXpeYOsr1FXU=
=I3UP
-----END PGP SIGNATURE-----

--Signature=_Mon__8_Jan_2007_13_38_19_-0300_xc.CNCf=q8Bs0fLt--