aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/virtio/linux/virtio.h7
-rw-r--r--tools/virtio/virtio_test.c6
-rw-r--r--tools/virtio/vringh_test.c22
3 files changed, 15 insertions, 20 deletions
diff --git a/tools/virtio/linux/virtio.h b/tools/virtio/linux/virtio.h
index 6df181a6bcc6..cd801838156f 100644
--- a/tools/virtio/linux/virtio.h
+++ b/tools/virtio/linux/virtio.h
@@ -49,13 +49,6 @@ struct virtqueue {
49 const char *__MODULE_LICENSE_name = __MODULE_LICENSE_value 49 const char *__MODULE_LICENSE_name = __MODULE_LICENSE_value
50 50
51/* Interfaces exported by virtio_ring. */ 51/* Interfaces exported by virtio_ring. */
52int virtqueue_add_buf(struct virtqueue *vq,
53 struct scatterlist sg[],
54 unsigned int out_num,
55 unsigned int in_num,
56 void *data,
57 gfp_t gfp);
58
59int virtqueue_add_sgs(struct virtqueue *vq, 52int virtqueue_add_sgs(struct virtqueue *vq,
60 struct scatterlist *sgs[], 53 struct scatterlist *sgs[],
61 unsigned int out_sgs, 54 unsigned int out_sgs,
diff --git a/tools/virtio/virtio_test.c b/tools/virtio/virtio_test.c
index 814ae803c878..da7a19558281 100644
--- a/tools/virtio/virtio_test.c
+++ b/tools/virtio/virtio_test.c
@@ -166,9 +166,9 @@ static void run_test(struct vdev_info *dev, struct vq_info *vq,
166 do { 166 do {
167 if (started < bufs) { 167 if (started < bufs) {
168 sg_init_one(&sl, dev->buf, dev->buf_size); 168 sg_init_one(&sl, dev->buf, dev->buf_size);
169 r = virtqueue_add_buf(vq->vq, &sl, 1, 0, 169 r = virtqueue_add_outbuf(vq->vq, &sl, 1,
170 dev->buf + started, 170 dev->buf + started,
171 GFP_ATOMIC); 171 GFP_ATOMIC);
172 if (likely(r == 0)) { 172 if (likely(r == 0)) {
173 ++started; 173 ++started;
174 virtqueue_kick(vq->vq); 174 virtqueue_kick(vq->vq);
diff --git a/tools/virtio/vringh_test.c b/tools/virtio/vringh_test.c
index bb0bd9403e9e..d053ea40c001 100644
--- a/tools/virtio/vringh_test.c
+++ b/tools/virtio/vringh_test.c
@@ -388,7 +388,7 @@ static int parallel_test(unsigned long features,
388 } 388 }
389 389
390 if (err) 390 if (err)
391 errx(1, "virtqueue_add_buf: %i", err); 391 errx(1, "virtqueue_add_in/outbuf: %i", err);
392 392
393 xfers++; 393 xfers++;
394 virtqueue_kick(vq); 394 virtqueue_kick(vq);
@@ -431,7 +431,7 @@ int main(int argc, char *argv[])
431 struct virtio_device vdev; 431 struct virtio_device vdev;
432 struct virtqueue *vq; 432 struct virtqueue *vq;
433 struct vringh vrh; 433 struct vringh vrh;
434 struct scatterlist guest_sg[RINGSIZE]; 434 struct scatterlist guest_sg[RINGSIZE], *sgs[2];
435 struct iovec host_riov[2], host_wiov[2]; 435 struct iovec host_riov[2], host_wiov[2];
436 struct vringh_iov riov, wiov; 436 struct vringh_iov riov, wiov;
437 struct vring_used_elem used[RINGSIZE]; 437 struct vring_used_elem used[RINGSIZE];
@@ -492,12 +492,14 @@ int main(int argc, char *argv[])
492 sg_set_buf(&guest_sg[0], __user_addr_max - 1, 1); 492 sg_set_buf(&guest_sg[0], __user_addr_max - 1, 1);
493 sg_init_table(guest_sg+1, 1); 493 sg_init_table(guest_sg+1, 1);
494 sg_set_buf(&guest_sg[1], __user_addr_max - 3, 2); 494 sg_set_buf(&guest_sg[1], __user_addr_max - 3, 2);
495 sgs[0] = &guest_sg[0];
496 sgs[1] = &guest_sg[1];
495 497
496 /* May allocate an indirect, so force it to allocate user addr */ 498 /* May allocate an indirect, so force it to allocate user addr */
497 __kmalloc_fake = __user_addr_min + vring_size(RINGSIZE, ALIGN); 499 __kmalloc_fake = __user_addr_min + vring_size(RINGSIZE, ALIGN);
498 err = virtqueue_add_buf(vq, guest_sg, 1, 1, &err, GFP_KERNEL); 500 err = virtqueue_add_sgs(vq, sgs, 1, 1, &err, GFP_KERNEL);
499 if (err) 501 if (err)
500 errx(1, "virtqueue_add_buf: %i", err); 502 errx(1, "virtqueue_add_sgs: %i", err);
501 __kmalloc_fake = NULL; 503 __kmalloc_fake = NULL;
502 504
503 /* Host retreives it. */ 505 /* Host retreives it. */
@@ -564,9 +566,9 @@ int main(int argc, char *argv[])
564 566
565 /* This will allocate an indirect, so force it to allocate user addr */ 567 /* This will allocate an indirect, so force it to allocate user addr */
566 __kmalloc_fake = __user_addr_min + vring_size(RINGSIZE, ALIGN); 568 __kmalloc_fake = __user_addr_min + vring_size(RINGSIZE, ALIGN);
567 err = virtqueue_add_buf(vq, guest_sg, RINGSIZE, 0, &err, GFP_KERNEL); 569 err = virtqueue_add_outbuf(vq, guest_sg, RINGSIZE, &err, GFP_KERNEL);
568 if (err) 570 if (err)
569 errx(1, "virtqueue_add_buf (large): %i", err); 571 errx(1, "virtqueue_add_outbuf (large): %i", err);
570 __kmalloc_fake = NULL; 572 __kmalloc_fake = NULL;
571 573
572 /* Host picks it up (allocates new iov). */ 574 /* Host picks it up (allocates new iov). */
@@ -616,9 +618,9 @@ int main(int argc, char *argv[])
616 sg_init_table(guest_sg, 1); 618 sg_init_table(guest_sg, 1);
617 sg_set_buf(&guest_sg[0], __user_addr_max - 1, 1); 619 sg_set_buf(&guest_sg[0], __user_addr_max - 1, 1);
618 for (i = 0; i < RINGSIZE; i++) { 620 for (i = 0; i < RINGSIZE; i++) {
619 err = virtqueue_add_buf(vq, guest_sg, 1, 0, &err, GFP_KERNEL); 621 err = virtqueue_add_outbuf(vq, guest_sg, 1, &err, GFP_KERNEL);
620 if (err) 622 if (err)
621 errx(1, "virtqueue_add_buf (multiple): %i", err); 623 errx(1, "virtqueue_add_outbuf (multiple): %i", err);
622 } 624 }
623 625
624 /* Now get many, and consume them all at once. */ 626 /* Now get many, and consume them all at once. */
@@ -664,9 +666,9 @@ int main(int argc, char *argv[])
664 sg_set_buf(&guest_sg[2], data + 6, 4); 666 sg_set_buf(&guest_sg[2], data + 6, 4);
665 sg_set_buf(&guest_sg[3], d + 3, sizeof(*d)*3); 667 sg_set_buf(&guest_sg[3], d + 3, sizeof(*d)*3);
666 668
667 err = virtqueue_add_buf(vq, guest_sg, 4, 0, &err, GFP_KERNEL); 669 err = virtqueue_add_outbuf(vq, guest_sg, 4, &err, GFP_KERNEL);
668 if (err) 670 if (err)
669 errx(1, "virtqueue_add_buf (indirect): %i", err); 671 errx(1, "virtqueue_add_outbuf (indirect): %i", err);
670 672
671 vring_init(&vring, RINGSIZE, __user_addr_min, ALIGN); 673 vring_init(&vring, RINGSIZE, __user_addr_min, ALIGN);
672 674