From: David van Moolenbroek Date: Mon, 1 Dec 2014 17:30:45 +0000 (+0000) Subject: libvirtio: expose result size on packet dequeue X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zpipe.c?a=commitdiff_plain;h=d1db724f47546f27b96ba07a2046ee438e6df526;p=minix.git libvirtio: expose result size on packet dequeue Change-Id: I49304678895779849abc2528a9f78730f968e712 --- diff --git a/minix/drivers/net/virtio_net/virtio_net.c b/minix/drivers/net/virtio_net/virtio_net.c index e7daa1a6e..2cb381a02 100644 --- a/minix/drivers/net/virtio_net/virtio_net.c +++ b/minix/drivers/net/virtio_net/virtio_net.c @@ -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); diff --git a/minix/drivers/storage/virtio_blk/virtio_blk.c b/minix/drivers/storage/virtio_blk/virtio_blk.c index 4583101c7..d7a3c7338 100644 --- a/minix/drivers/storage/virtio_blk/virtio_blk.c +++ b/minix/drivers/storage/virtio_blk/virtio_blk.c @@ -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); } diff --git a/minix/include/minix/virtio.h b/minix/include/minix/virtio.h index aec6d4b89..aee338e1c 100644 --- a/minix/include/minix/virtio.h +++ b/minix/include/minix/virtio.h @@ -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); diff --git a/minix/lib/libvirtio/virtio.c b/minix/lib/libvirtio/virtio.c index 1ff715a04..95c64cbe0 100644 --- a/minix/lib/libvirtio/virtio.c +++ b/minix/lib/libvirtio/virtio.c @@ -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; }