The goal here is to support booting from modern and transitional virtio-net devices using the new virtio 1.0 protocol. The code strives to comply with the virtio 1.0 spec and is heavily inspired by the Linux kernel implementation.
Changes from v3: * reverted the device initialization change, adjust_pci_device is called unconditionally again Changes from v2: * adjust_pci_device is called only if we actually use a bar, otherwise the device is left uninitialized * vpm_reset now waits for the device to report status == 0 * added an explicit "case VIRTIO_PCI_REGION_PCI_CONFIG" and "default: assert(0)" to read/write functions (assert seems to be appropriate here, I haven't found a true crash or fail-fast function) * now checking for a valid Ethernet MAC address as part of initialization - that includes the case where the device does not support VIRTIO_NET_F_MAC * virtnet_open_modern fails if VIRTIO_F_VERSION_1 is not offered * added a check for device ID < 0x1040 before falling back to the legacy probe * new virtio_version field is used instead of ioaddr to tell if we're talking to the device using virtio 1.0 * comments and minor code changes * rebased to latest master Changes from v1: * removed the packed attribute from virtio structures * notification cap is now always mapped per queue - results in one more ioremap call but eliminates special case code * only sizeof(struct virtio_net_config) instead of PAGE_SIZE of the device cap is mapped * the config cap is now looked for and required * vpm_ioread* and vpm_iowrite* support memory, port I/O, and PCI config space access through the config cap as a fallback, and are not declared inline anymore * extra parameter is now used by virtnet_probe_modern instead of specific error code to indicate that a 1.0 device was found * device initialization follows the spec - note that reset, ACKNOWLEDGE, and DRIVER happen in virtnet_probe_modern and the rest in virtnet_open_modern * nits, comments, and typos here and there src/drivers/bus/pciextra.c | 54 +++++-- src/drivers/bus/virtio-pci.c | 353 ++++++++++++++++++++++++++++++++++++++++- src/drivers/bus/virtio-ring.c | 17 +- src/drivers/net/virtio-net.c | 265 +++++++++++++++++++++++++++++-- src/drivers/net/virtio-net.h | 16 ++ src/include/ipxe/errfile.h | 1 + src/include/ipxe/pci.h | 2 + src/include/ipxe/virtio-pci.h | 207 ++++++++++++++++++++++++ src/include/ipxe/virtio-ring.h | 14 +- 9 files changed, 894 insertions(+), 35 deletions(-) _______________________________________________ ipxe-devel mailing list ipxe-devel@lists.ipxe.org https://lists.ipxe.org/mailman/listinfo.cgi/ipxe-devel