virtio: basic packed virtqueue support
This patch implements basic support for the packed virtqueue. Compare the split virtqueue which has three rings, packed virtqueue only have one which is supposed to have better cache utilization and more hardware friendly. Please refer virtio specification for more information. Signed-off-by: Wei Xu <wexu@redhat.com> Signed-off-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Eugenio Pérez <eperezma@redhat.com> Message-Id: <20191025083527.30803-6-eperezma@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
522bbb191c
commit
86044b24e8
@ -1052,7 +1052,7 @@ static void virtio_blk_save_device(VirtIODevice *vdev, QEMUFile *f)
|
||||
qemu_put_be32(f, virtio_get_queue_index(req->vq));
|
||||
}
|
||||
|
||||
qemu_put_virtqueue_element(f, &req->elem);
|
||||
qemu_put_virtqueue_element(vdev, f, &req->elem);
|
||||
req = req->next;
|
||||
}
|
||||
qemu_put_sbyte(f, 0);
|
||||
|
@ -708,7 +708,7 @@ static void virtio_serial_save_device(VirtIODevice *vdev, QEMUFile *f)
|
||||
if (elem_popped) {
|
||||
qemu_put_be32s(f, &port->iov_idx);
|
||||
qemu_put_be64s(f, &port->iov_offset);
|
||||
qemu_put_virtqueue_element(f, port->elem);
|
||||
qemu_put_virtqueue_element(vdev, f, port->elem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -190,11 +190,12 @@ static void virtio_scsi_save_request(QEMUFile *f, SCSIRequest *sreq)
|
||||
{
|
||||
VirtIOSCSIReq *req = sreq->hba_private;
|
||||
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(req->dev);
|
||||
VirtIODevice *vdev = VIRTIO_DEVICE(req->dev);
|
||||
uint32_t n = virtio_get_queue_index(req->vq) - 2;
|
||||
|
||||
assert(n < vs->conf.num_queues);
|
||||
qemu_put_be32s(f, &n);
|
||||
qemu_put_virtqueue_element(f, &req->elem);
|
||||
qemu_put_virtqueue_element(vdev, f, &req->elem);
|
||||
}
|
||||
|
||||
static void *virtio_scsi_load_request(QEMUFile *f, SCSIRequest *sreq)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -59,6 +59,8 @@ typedef struct VirtQueue VirtQueue;
|
||||
typedef struct VirtQueueElement
|
||||
{
|
||||
unsigned int index;
|
||||
unsigned int len;
|
||||
unsigned int ndescs;
|
||||
unsigned int out_num;
|
||||
unsigned int in_num;
|
||||
hwaddr *in_addr;
|
||||
@ -196,7 +198,8 @@ void virtqueue_map(VirtIODevice *vdev, VirtQueueElement *elem);
|
||||
void *virtqueue_pop(VirtQueue *vq, size_t sz);
|
||||
unsigned int virtqueue_drop_all(VirtQueue *vq);
|
||||
void *qemu_get_virtqueue_element(VirtIODevice *vdev, QEMUFile *f, size_t sz);
|
||||
void qemu_put_virtqueue_element(QEMUFile *f, VirtQueueElement *elem);
|
||||
void qemu_put_virtqueue_element(VirtIODevice *vdev, QEMUFile *f,
|
||||
VirtQueueElement *elem);
|
||||
int virtqueue_avail_bytes(VirtQueue *vq, unsigned int in_bytes,
|
||||
unsigned int out_bytes);
|
||||
void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes,
|
||||
@ -291,8 +294,9 @@ hwaddr virtio_queue_get_used_addr(VirtIODevice *vdev, int n);
|
||||
hwaddr virtio_queue_get_desc_size(VirtIODevice *vdev, int n);
|
||||
hwaddr virtio_queue_get_avail_size(VirtIODevice *vdev, int n);
|
||||
hwaddr virtio_queue_get_used_size(VirtIODevice *vdev, int n);
|
||||
uint16_t virtio_queue_get_last_avail_idx(VirtIODevice *vdev, int n);
|
||||
void virtio_queue_set_last_avail_idx(VirtIODevice *vdev, int n, uint16_t idx);
|
||||
unsigned int virtio_queue_get_last_avail_idx(VirtIODevice *vdev, int n);
|
||||
void virtio_queue_set_last_avail_idx(VirtIODevice *vdev, int n,
|
||||
unsigned int idx);
|
||||
void virtio_queue_restore_last_avail_idx(VirtIODevice *vdev, int n);
|
||||
void virtio_queue_invalidate_signalled_used(VirtIODevice *vdev, int n);
|
||||
void virtio_queue_update_used_idx(VirtIODevice *vdev, int n);
|
||||
|
Loading…
Reference in New Issue
Block a user