aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/bus
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@gmail.com>2010-07-02 19:15:47 +0100
committerMichael Brown <mcb30@ipxe.org>2010-07-17 17:07:14 +0100
commite4419ff97cdc6cf69c251ef1f768274f0a71c9d0 (patch)
treed079c3c2255de618df612a7c6841a3c3ae81e80f /src/drivers/bus
parent232c208882047210b0054d3d939ae5d45ab214f7 (diff)
downloadipxe-e4419ff97cdc6cf69c251ef1f768274f0a71c9d0.zip
ipxe-e4419ff97cdc6cf69c251ef1f768274f0a71c9d0.tar.gz
ipxe-e4419ff97cdc6cf69c251ef1f768274f0a71c9d0.tar.bz2
[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 <stefanha@gmail.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/drivers/bus')
-rw-r--r--src/drivers/bus/virtio-ring.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/drivers/bus/virtio-ring.c b/src/drivers/bus/virtio-ring.c
index 00b1081..987b319 100644
--- a/src/drivers/bus/virtio-ring.c
+++ b/src/drivers/bus/virtio-ring.c
@@ -57,12 +57,12 @@ 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)
{
struct vring *vr = &vq->vring;
struct vring_used_elem *elem;
u32 id;
- int ret;
+ void *opaque;
BUG_ON(!vring_more_used(vq));
@@ -72,19 +72,19 @@ int vring_get_buf(struct vring_virtqueue *vq, unsigned int *len)
if (len != NULL)
*len = elem->len;
- ret = vq->vdata[id];
+ opaque = vq->vdata[id];
vring_detach(vq, id);
vq->last_used_idx++;
- return ret;
+ return opaque;
}
void vring_add_buf(struct vring_virtqueue *vq,
struct vring_list list[],
unsigned int out, unsigned int in,
- int index, int num_added)
+ void *opaque, int num_added)
{
struct vring *vr = &vq->vring;
int i, avail, head, prev;
@@ -113,7 +113,7 @@ void vring_add_buf(struct vring_virtqueue *vq,
vq->free_head = i;
- vq->vdata[head] = index;
+ vq->vdata[head] = opaque;
avail = (vr->avail->idx + num_added) % vr->num;
vr->avail->ring[avail] = head;