Skip to content

Commit

Permalink
[virtio] Replace virtio-net with native iPXE driver
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
stefanha authored and mcb30 committed Jul 17, 2010
1 parent 232c208 commit e4419ff
Show file tree
Hide file tree
Showing 5 changed files with 350 additions and 238 deletions.
12 changes: 6 additions & 6 deletions src/drivers/bus/virtio-ring.c
Expand Up @@ -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));

Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit e4419ff

Please sign in to comment.