Virtio drivers (virtio-net)

Tim Bisson bissont at mac.com
Sun Jan 23 02:59:36 PST 2011


Hi All,

There's been some activity in the FreeBSD mailing lists about the virtio 
drivers. A couple of people presented their drivers:
http://lists.freebsd.org/pipermail/freebsd-current/2011-January/022036.html
http://lists.freebsd.org/pipermail/freebsd-current/2011-January/022045.html

We took a look at these drivers and found that the first link seemed to 
be a really clean implementation of the virtio infrastructure and 
virtio-net driver. We decided to stop the porting effort of the 
NetBSD-based virtio drivers and instead use the FreeBSD ones. We 
successfully ported the FreeBSD virtio infrastructure and virtio-net 
driver, which now works and is ready for more testers.

In order to port this driver, we had to make some changes to the kernel: 
essentially add kern/subr_sglist.c from FreeBSD and make a probe 
interface public. The patch file is in the top-level directory of the 
git tree and was diff'd from master this morning. The file name is:
0001-kern-changes-for-freeebsd-virtio-driver-port.patch

Regarding the original virtio-blk driver we ported from NetBSD. I will 
probably port this to the new virtio-infrastructure, unless the FreeBSD 
virtio-blk driver is posted on the FreeBSD mailing list in the near future.

Here's a link to the code:
http://gitorious.org/dbd-virtio-drivers-freebsd-port
and some notes:
http://gitorious.org/dbd-virtio-drivers-freebsd-port/pages/Home
Regarding performance, I don't have a good explanation yet, but 
emulation with the re driver is actually faster than virtio on a simle 
scp test:

re driver
$ time scp 192.168.122.140:200m .
200m                       100%  200MB  15.4MB/s   00:13
virtio driver
$ time scp 192.168.123.8:200m .
200m                       100%  200MB  11.8MB/s   00:17
ifconfig from dbsd vm for above test
$ ifconfig
re0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    options=1b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING>
    inet6 fe80::5054:ff:fe03:9900%re0 prefixlen 64 scopeid 0x1
    inet 192.168.122.140 netmask 0xffffff00 broadcast 192.168.122.255
    ether 52:54:00:03:99:00
    media: Ethernet autoselect (100baseTX <full-duplex>)
    status: active
faith0: flags=8002<BROADCAST,MULTICAST> mtu 1500
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
    options=3<RXCSUM,TXCSUM>
    inet 127.0.0.1 netmask 0xff000000
    inet6 ::1 prefixlen 128
    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
ppp0: flags=8010<POINTOPOINT,MULTICAST> mtu 1500
sl0: flags=c010<POINTOPOINT,LINK2,MULTICAST> mtu 552
vtnet0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    options=28<VLAN_MTU,JUMBO_MTU>
    inet6 fe80::5054:ff:fe33:3bd3%vtnet0 prefixlen 64 scopeid 0x6
    inet 192.168.123.8 netmask 0xffffff00 broadcast 192.168.123.255
    ether 52:54:00:33:3b:d3
Comments and suggestions are always welcome.
Tim




More information about the Kernel mailing list