diff options
| author | Michael S. Tsirkin <mst@redhat.com> | 2012-04-16 10:11:12 -0400 |
|---|---|---|
| committer | Michael S. Tsirkin <mst@redhat.com> | 2012-05-02 11:22:14 -0400 |
| commit | 64d098886e0ec01f88349fe757161c2e2e89086b (patch) | |
| tree | 88f3daa1187f1fa8e84c56859fc4e2adc81b0e95 /tools/virtio | |
| parent | e4ae004b84b315dd4b762e474f97403eac70f76a (diff) | |
virtio/tools: add delayed interupt mode
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'tools/virtio')
| -rw-r--r-- | tools/virtio/linux/virtio.h | 1 | ||||
| -rw-r--r-- | tools/virtio/virtio_test.c | 26 |
2 files changed, 23 insertions, 4 deletions
diff --git a/tools/virtio/linux/virtio.h b/tools/virtio/linux/virtio.h index 7579f19e61e0..81847dd08bd0 100644 --- a/tools/virtio/linux/virtio.h +++ b/tools/virtio/linux/virtio.h | |||
| @@ -203,6 +203,7 @@ void *virtqueue_get_buf(struct virtqueue *vq, unsigned int *len); | |||
| 203 | void virtqueue_disable_cb(struct virtqueue *vq); | 203 | void virtqueue_disable_cb(struct virtqueue *vq); |
| 204 | 204 | ||
| 205 | bool virtqueue_enable_cb(struct virtqueue *vq); | 205 | bool virtqueue_enable_cb(struct virtqueue *vq); |
| 206 | bool virtqueue_enable_cb_delayed(struct virtqueue *vq); | ||
| 206 | 207 | ||
| 207 | void *virtqueue_detach_unused_buf(struct virtqueue *vq); | 208 | void *virtqueue_detach_unused_buf(struct virtqueue *vq); |
| 208 | struct virtqueue *vring_new_virtqueue(unsigned int num, | 209 | struct virtqueue *vring_new_virtqueue(unsigned int num, |
diff --git a/tools/virtio/virtio_test.c b/tools/virtio/virtio_test.c index 6bf95f995364..e626fa553c5a 100644 --- a/tools/virtio/virtio_test.c +++ b/tools/virtio/virtio_test.c | |||
| @@ -144,7 +144,8 @@ static void wait_for_interrupt(struct vdev_info *dev) | |||
| 144 | } | 144 | } |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | static void run_test(struct vdev_info *dev, struct vq_info *vq, int bufs) | 147 | static void run_test(struct vdev_info *dev, struct vq_info *vq, |
| 148 | bool delayed, int bufs) | ||
| 148 | { | 149 | { |
| 149 | struct scatterlist sl; | 150 | struct scatterlist sl; |
| 150 | long started = 0, completed = 0; | 151 | long started = 0, completed = 0; |
| @@ -183,8 +184,12 @@ static void run_test(struct vdev_info *dev, struct vq_info *vq, int bufs) | |||
| 183 | assert(started <= bufs); | 184 | assert(started <= bufs); |
| 184 | if (completed == bufs) | 185 | if (completed == bufs) |
| 185 | break; | 186 | break; |
| 186 | if (virtqueue_enable_cb(vq->vq)) { | 187 | if (delayed) { |
| 187 | wait_for_interrupt(dev); | 188 | if (virtqueue_enable_cb_delayed(vq->vq)) |
| 189 | wait_for_interrupt(dev); | ||
| 190 | } else { | ||
| 191 | if (virtqueue_enable_cb(vq->vq)) | ||
| 192 | wait_for_interrupt(dev); | ||
| 188 | } | 193 | } |
| 189 | } | 194 | } |
| 190 | test = 0; | 195 | test = 0; |
| @@ -216,6 +221,14 @@ const struct option longopts[] = { | |||
| 216 | .val = 'i', | 221 | .val = 'i', |
| 217 | }, | 222 | }, |
| 218 | { | 223 | { |
| 224 | .name = "delayed-interrupt", | ||
| 225 | .val = 'D', | ||
| 226 | }, | ||
| 227 | { | ||
| 228 | .name = "no-delayed-interrupt", | ||
| 229 | .val = 'd', | ||
| 230 | }, | ||
| 231 | { | ||
| 219 | } | 232 | } |
| 220 | }; | 233 | }; |
| 221 | 234 | ||
| @@ -224,6 +237,7 @@ static void help() | |||
| 224 | fprintf(stderr, "Usage: virtio_test [--help]" | 237 | fprintf(stderr, "Usage: virtio_test [--help]" |
| 225 | " [--no-indirect]" | 238 | " [--no-indirect]" |
| 226 | " [--no-event-idx]" | 239 | " [--no-event-idx]" |
| 240 | " [--delayed-interrupt]" | ||
| 227 | "\n"); | 241 | "\n"); |
| 228 | } | 242 | } |
| 229 | 243 | ||
| @@ -233,6 +247,7 @@ int main(int argc, char **argv) | |||
| 233 | unsigned long long features = (1ULL << VIRTIO_RING_F_INDIRECT_DESC) | | 247 | unsigned long long features = (1ULL << VIRTIO_RING_F_INDIRECT_DESC) | |
| 234 | (1ULL << VIRTIO_RING_F_EVENT_IDX); | 248 | (1ULL << VIRTIO_RING_F_EVENT_IDX); |
| 235 | int o; | 249 | int o; |
| 250 | bool delayed = false; | ||
| 236 | 251 | ||
| 237 | for (;;) { | 252 | for (;;) { |
| 238 | o = getopt_long(argc, argv, optstring, longopts, NULL); | 253 | o = getopt_long(argc, argv, optstring, longopts, NULL); |
| @@ -251,6 +266,9 @@ int main(int argc, char **argv) | |||
| 251 | case 'i': | 266 | case 'i': |
| 252 | features &= ~(1ULL << VIRTIO_RING_F_INDIRECT_DESC); | 267 | features &= ~(1ULL << VIRTIO_RING_F_INDIRECT_DESC); |
| 253 | break; | 268 | break; |
| 269 | case 'D': | ||
| 270 | delayed = true; | ||
| 271 | break; | ||
| 254 | default: | 272 | default: |
| 255 | assert(0); | 273 | assert(0); |
| 256 | break; | 274 | break; |
| @@ -260,6 +278,6 @@ int main(int argc, char **argv) | |||
| 260 | done: | 278 | done: |
| 261 | vdev_info_init(&dev, features); | 279 | vdev_info_init(&dev, features); |
| 262 | vq_info_add(&dev, 256); | 280 | vq_info_add(&dev, 256); |
| 263 | run_test(&dev, &dev.vqs[0], 0x100000); | 281 | run_test(&dev, &dev.vqs[0], delayed, 0x100000); |
| 264 | return 0; | 282 | return 0; |
| 265 | } | 283 | } |
