From e4419ff97cdc6cf69c251ef1f768274f0a71c9d0 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Fri, 2 Jul 2010 19:15:47 +0100 Subject: [virtio] Replace virtio-net with native iPXE driver This patch adds a native iPXE virtio-net driver and removes the legacy Etherboot virtio-net driver. The main reasons for doing this are: 1. Multiple virtio-net NICs are now supported by iPXE. The legacy driver kept global state and caused issues in virtual machines with more than one virtio-net device. 2. Faster downloads. The native iPXE driver downloads 100 MB over HTTP in 12s, the legacy Etherboot driver in 37s. This simple benchmark uses KVM with tap networking and the Python SimpleHTTPServer both running on the same host. Changes to core virtio code reduce vring descriptors to 256 (QEMU uses 128 for virtio-blk and 256 for virtio-net) and change the opaque token from u16 to void*. Lowering the descriptor count reduces memory consumption. The void* opaque token change makes driver code simpler. Signed-off-by: Stefan Hajnoczi Signed-off-by: Michael Brown --- src/include/ipxe/errfile.h | 1 + src/include/ipxe/virtio-pci.h | 4 ++++ src/include/ipxe/virtio-ring.h | 8 ++++---- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src/include/ipxe') diff --git a/src/include/ipxe/errfile.h b/src/include/ipxe/errfile.h index 861fee245..ec0703396 100644 --- a/src/include/ipxe/errfile.h +++ b/src/include/ipxe/errfile.h @@ -126,6 +126,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #define ERRFILE_snpnet ( ERRFILE_DRIVER | 0x00590000 ) #define ERRFILE_snponly ( ERRFILE_DRIVER | 0x005a0000 ) #define ERRFILE_jme ( ERRFILE_DRIVER | 0x005b0000 ) +#define ERRFILE_virtio_net ( ERRFILE_DRIVER | 0x005c0000 ) #define ERRFILE_scsi ( ERRFILE_DRIVER | 0x00700000 ) #define ERRFILE_arbel ( ERRFILE_DRIVER | 0x00710000 ) diff --git a/src/include/ipxe/virtio-pci.h b/src/include/ipxe/virtio-pci.h index f0c17e8d2..a09c46316 100644 --- a/src/include/ipxe/virtio-pci.h +++ b/src/include/ipxe/virtio-pci.h @@ -69,6 +69,10 @@ static inline void vp_set_status(unsigned int ioaddr, u8 status) outb(status, ioaddr + VIRTIO_PCI_STATUS); } +static inline u8 vp_get_isr(unsigned int ioaddr) +{ + return inb(ioaddr + VIRTIO_PCI_ISR); +} static inline void vp_reset(unsigned int ioaddr) { diff --git a/src/include/ipxe/virtio-ring.h b/src/include/ipxe/virtio-ring.h index e96dd371d..0afe8bab7 100644 --- a/src/include/ipxe/virtio-ring.h +++ b/src/include/ipxe/virtio-ring.h @@ -14,7 +14,7 @@ /* We've given up on this device. */ #define VIRTIO_CONFIG_S_FAILED 0x80 -#define MAX_QUEUE_NUM (512) +#define MAX_QUEUE_NUM (256) #define VRING_DESC_F_NEXT 1 #define VRING_DESC_F_WRITE 2 @@ -71,7 +71,7 @@ struct vring_virtqueue { struct vring vring; u16 free_head; u16 last_used_idx; - u16 vdata[MAX_QUEUE_NUM]; + void *vdata[MAX_QUEUE_NUM]; /* PCI */ int queue_index; }; @@ -133,10 +133,10 @@ static inline int vring_more_used(struct vring_virtqueue *vq) } void vring_detach(struct vring_virtqueue *vq, unsigned int head); -int vring_get_buf(struct vring_virtqueue *vq, unsigned int *len); +void *vring_get_buf(struct vring_virtqueue *vq, unsigned int *len); void vring_add_buf(struct vring_virtqueue *vq, struct vring_list list[], unsigned int out, unsigned int in, - int index, int num_added); + void *index, int num_added); void vring_kick(unsigned int ioaddr, struct vring_virtqueue *vq, int num_added); #endif /* _VIRTIO_RING_H_ */ -- cgit v1.2.3-55-g7522