libvirtio: expose result size on packet dequeue

Change-Id: I49304678895779849abc2528a9f78730f968e712
This commit is contained in:
David van Moolenbroek 2014-12-01 17:30:45 +00:00
parent a810336026
commit d1db724f47
4 changed files with 13 additions and 8 deletions

View file

@ -268,7 +268,7 @@ virtio_net_check_queues(void)
struct packet *p;
/* Put the received packets into the recv list */
while (virtio_from_queue(net_dev, RX_Q, (void **)&p) == 0) {
while (virtio_from_queue(net_dev, RX_Q, (void **)&p, NULL) == 0) {
STAILQ_INSERT_TAIL(&recv_list, p, next);
in_rx--;
virtio_net_stats.ets_packetR++;
@ -277,7 +277,7 @@ virtio_net_check_queues(void)
/* Packets from the TX queue just indicated they are free to
* be reused now. inet already knows about them as being sent.
*/
while (virtio_from_queue(net_dev, TX_Q, (void **)&p) == 0) {
while (virtio_from_queue(net_dev, TX_Q, (void **)&p, NULL) == 0) {
memset(p->vhdr, 0, sizeof(*p->vhdr));
memset(p->vdata, 0, MAX_PACK_SIZE);
STAILQ_INSERT_HEAD(&free_list, p, next);

View file

@ -439,7 +439,7 @@ virtio_blk_device_intr(void)
thread_id_t *tid;
/* Multiple requests might have finished */
while (!virtio_from_queue(blk_dev, 0, (void**)&tid))
while (!virtio_from_queue(blk_dev, 0, (void**)&tid, NULL))
blockdriver_mt_wakeup(*tid);
}

View file

@ -98,11 +98,12 @@ int virtio_to_queue(struct virtio_device *dev, int qidx,
struct vumap_phys *bufs, size_t num, void *data);
/*
* If the host used a chain of descriptors, return 0 and set data
* as was given to virtio_to_queue(). If the host has not processed
* any element returns -1.
* If the host used a chain of descriptors, return 0, set data as was given to
* virtio_to_queue(), and if len is not NULL, set it to the resulting length.
* If the host has not processed any element, return -1.
*/
int virtio_from_queue(struct virtio_device *dev, int qidx, void **data);
int virtio_from_queue(struct virtio_device *dev, int qidx, void **data,
size_t *len);
/* IRQ related functions */
void virtio_irq_enable(struct virtio_device *dev);

View file

@ -639,7 +639,8 @@ virtio_to_queue(struct virtio_device *dev, int qidx, struct vumap_phys *bufs,
}
int
virtio_from_queue(struct virtio_device *dev, int qidx, void **data)
virtio_from_queue(struct virtio_device *dev, int qidx, void **data,
size_t *len)
{
struct virtio_queue *q;
struct vring *vring;
@ -718,6 +719,9 @@ virtio_from_queue(struct virtio_device *dev, int qidx, void **data)
*data = q->data[uel->id];
q->data[uel->id] = NULL;
if (len != NULL)
*len = uel->len;
return 0;
}