DragonFly BSD
DragonFly kernel List (threaded) for 2010-10
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Driver Setup for Virtio driver


From: Tim Bisson <bissont@xxxxxxx>
Date: Sat, 23 Oct 2010 16:47:14 -0700

Hi,

I started porting the NetBSD virtio drivers from NetBSD to DragonFly. I'm currently working through the virtio-net attach routine and setting up the appropriate infrastructure.

I believe I'm creating the drivers incorrectly. To set some context, I'm developing with a networking virtio device on VirtualBox. When I start the dragonfly VM, there is a single PCI device that shows up, which is a virtio device:
00:08.0 Ethernet controller: Qumranet, Inc. Virtio network device


The way I currently have the drivers structured is there a virtiobus driver (pci child), which has all the infrastructure routines, and then there are child drivers: virtio-net, virtio-blk, etc, which will end up calling routines in the virtiobus driver to setup dma, etc.

When I load the virtiobus driver, probe and attach are successfull for that PCI device. Then when I load the virtio-net driver, probe isn't called because that device has already been satisfied. In order to get around that, I implemented the identify() routine in the virtio-net driver, which is called when I load the driver. If the device is of our type (networking, block, etc), then we add a new child device to the parent (virtiobus) of the appropriate type and force a probe. The pseudo code is below.

virtiobus.c:
virtio_probe(){
    if (is virtio device){ /*pci_get_device*()*/
        return 0;
    }
}

virtio-net.c:
netvirtio_identify(){
    if (is a virtio network subdevice){ /*pci_read_config(subdevice)*/
        dev = device_add_child();
        bus_generic_probe(dev);
    }
}
netvirtio_probe(){
    return 0; /*only called if identify succeeds*/
}
netvirtio_attach(){
    set stuff up;
}

I'm not sure if this was the right way to go about it, so any tips/suggestions are appreciated.
Tim


The code I'm currently working on is at:
http://gitorious.org/virtio-drivers




[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]