mirror of
https://github.com/ipxe/ipxe
synced 2025-12-23 21:41:43 +03:00
[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>
This commit is contained in:
committed by
Michael Brown
parent
232c208882
commit
e4419ff97c
@@ -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 )
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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_ */
|
||||
|
||||
Reference in New Issue
Block a user