Loading tools/virtio/linux/virtio.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -203,6 +203,7 @@ void *virtqueue_get_buf(struct virtqueue *vq, unsigned int *len); void virtqueue_disable_cb(struct virtqueue *vq); void virtqueue_disable_cb(struct virtqueue *vq); bool virtqueue_enable_cb(struct virtqueue *vq); bool virtqueue_enable_cb(struct virtqueue *vq); bool virtqueue_enable_cb_delayed(struct virtqueue *vq); void *virtqueue_detach_unused_buf(struct virtqueue *vq); void *virtqueue_detach_unused_buf(struct virtqueue *vq); struct virtqueue *vring_new_virtqueue(unsigned int num, struct virtqueue *vring_new_virtqueue(unsigned int num, Loading tools/virtio/virtio_test.c +22 −4 Original line number Original line Diff line number Diff line Loading @@ -144,7 +144,8 @@ static void wait_for_interrupt(struct vdev_info *dev) } } } } static void run_test(struct vdev_info *dev, struct vq_info *vq, int bufs) static void run_test(struct vdev_info *dev, struct vq_info *vq, bool delayed, int bufs) { { struct scatterlist sl; struct scatterlist sl; long started = 0, completed = 0; long started = 0, completed = 0; Loading Loading @@ -183,7 +184,11 @@ static void run_test(struct vdev_info *dev, struct vq_info *vq, int bufs) assert(started <= bufs); assert(started <= bufs); if (completed == bufs) if (completed == bufs) break; break; if (virtqueue_enable_cb(vq->vq)) { if (delayed) { if (virtqueue_enable_cb_delayed(vq->vq)) wait_for_interrupt(dev); } else { if (virtqueue_enable_cb(vq->vq)) wait_for_interrupt(dev); wait_for_interrupt(dev); } } } } Loading Loading @@ -215,6 +220,14 @@ const struct option longopts[] = { .name = "no-indirect", .name = "no-indirect", .val = 'i', .val = 'i', }, }, { .name = "delayed-interrupt", .val = 'D', }, { .name = "no-delayed-interrupt", .val = 'd', }, { { } } }; }; Loading @@ -224,6 +237,7 @@ static void help() fprintf(stderr, "Usage: virtio_test [--help]" fprintf(stderr, "Usage: virtio_test [--help]" " [--no-indirect]" " [--no-indirect]" " [--no-event-idx]" " [--no-event-idx]" " [--delayed-interrupt]" "\n"); "\n"); } } Loading @@ -233,6 +247,7 @@ int main(int argc, char **argv) unsigned long long features = (1ULL << VIRTIO_RING_F_INDIRECT_DESC) | unsigned long long features = (1ULL << VIRTIO_RING_F_INDIRECT_DESC) | (1ULL << VIRTIO_RING_F_EVENT_IDX); (1ULL << VIRTIO_RING_F_EVENT_IDX); int o; int o; bool delayed = false; for (;;) { for (;;) { o = getopt_long(argc, argv, optstring, longopts, NULL); o = getopt_long(argc, argv, optstring, longopts, NULL); Loading @@ -251,6 +266,9 @@ int main(int argc, char **argv) case 'i': case 'i': features &= ~(1ULL << VIRTIO_RING_F_INDIRECT_DESC); features &= ~(1ULL << VIRTIO_RING_F_INDIRECT_DESC); break; break; case 'D': delayed = true; break; default: default: assert(0); assert(0); break; break; Loading @@ -260,6 +278,6 @@ int main(int argc, char **argv) done: done: vdev_info_init(&dev, features); vdev_info_init(&dev, features); vq_info_add(&dev, 256); vq_info_add(&dev, 256); run_test(&dev, &dev.vqs[0], 0x100000); run_test(&dev, &dev.vqs[0], delayed, 0x100000); return 0; return 0; } } Loading
tools/virtio/linux/virtio.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -203,6 +203,7 @@ void *virtqueue_get_buf(struct virtqueue *vq, unsigned int *len); void virtqueue_disable_cb(struct virtqueue *vq); void virtqueue_disable_cb(struct virtqueue *vq); bool virtqueue_enable_cb(struct virtqueue *vq); bool virtqueue_enable_cb(struct virtqueue *vq); bool virtqueue_enable_cb_delayed(struct virtqueue *vq); void *virtqueue_detach_unused_buf(struct virtqueue *vq); void *virtqueue_detach_unused_buf(struct virtqueue *vq); struct virtqueue *vring_new_virtqueue(unsigned int num, struct virtqueue *vring_new_virtqueue(unsigned int num, Loading
tools/virtio/virtio_test.c +22 −4 Original line number Original line Diff line number Diff line Loading @@ -144,7 +144,8 @@ static void wait_for_interrupt(struct vdev_info *dev) } } } } static void run_test(struct vdev_info *dev, struct vq_info *vq, int bufs) static void run_test(struct vdev_info *dev, struct vq_info *vq, bool delayed, int bufs) { { struct scatterlist sl; struct scatterlist sl; long started = 0, completed = 0; long started = 0, completed = 0; Loading Loading @@ -183,7 +184,11 @@ static void run_test(struct vdev_info *dev, struct vq_info *vq, int bufs) assert(started <= bufs); assert(started <= bufs); if (completed == bufs) if (completed == bufs) break; break; if (virtqueue_enable_cb(vq->vq)) { if (delayed) { if (virtqueue_enable_cb_delayed(vq->vq)) wait_for_interrupt(dev); } else { if (virtqueue_enable_cb(vq->vq)) wait_for_interrupt(dev); wait_for_interrupt(dev); } } } } Loading Loading @@ -215,6 +220,14 @@ const struct option longopts[] = { .name = "no-indirect", .name = "no-indirect", .val = 'i', .val = 'i', }, }, { .name = "delayed-interrupt", .val = 'D', }, { .name = "no-delayed-interrupt", .val = 'd', }, { { } } }; }; Loading @@ -224,6 +237,7 @@ static void help() fprintf(stderr, "Usage: virtio_test [--help]" fprintf(stderr, "Usage: virtio_test [--help]" " [--no-indirect]" " [--no-indirect]" " [--no-event-idx]" " [--no-event-idx]" " [--delayed-interrupt]" "\n"); "\n"); } } Loading @@ -233,6 +247,7 @@ int main(int argc, char **argv) unsigned long long features = (1ULL << VIRTIO_RING_F_INDIRECT_DESC) | unsigned long long features = (1ULL << VIRTIO_RING_F_INDIRECT_DESC) | (1ULL << VIRTIO_RING_F_EVENT_IDX); (1ULL << VIRTIO_RING_F_EVENT_IDX); int o; int o; bool delayed = false; for (;;) { for (;;) { o = getopt_long(argc, argv, optstring, longopts, NULL); o = getopt_long(argc, argv, optstring, longopts, NULL); Loading @@ -251,6 +266,9 @@ int main(int argc, char **argv) case 'i': case 'i': features &= ~(1ULL << VIRTIO_RING_F_INDIRECT_DESC); features &= ~(1ULL << VIRTIO_RING_F_INDIRECT_DESC); break; break; case 'D': delayed = true; break; default: default: assert(0); assert(0); break; break; Loading @@ -260,6 +278,6 @@ int main(int argc, char **argv) done: done: vdev_info_init(&dev, features); vdev_info_init(&dev, features); vq_info_add(&dev, 256); vq_info_add(&dev, 256); run_test(&dev, &dev.vqs[0], 0x100000); run_test(&dev, &dev.vqs[0], delayed, 0x100000); return 0; return 0; } }