Skip to content

Commit 64d0988

Browse files
committed
virtio/tools: add delayed interupt mode
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1 parent e4ae004 commit 64d0988

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

‎tools/virtio/linux/virtio.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ void *virtqueue_get_buf(struct virtqueue *vq, unsigned int *len);
203203
void virtqueue_disable_cb(struct virtqueue *vq);
204204

205205
bool virtqueue_enable_cb(struct virtqueue *vq);
206+
bool virtqueue_enable_cb_delayed(struct virtqueue *vq);
206207

207208
void *virtqueue_detach_unused_buf(struct virtqueue *vq);
208209
struct virtqueue *vring_new_virtqueue(unsigned int num,

‎tools/virtio/virtio_test.c‎

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ static void wait_for_interrupt(struct vdev_info *dev)
144144
}
145145
}
146146

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)
148149
{
149150
struct scatterlist sl;
150151
long started = 0, completed = 0;
@@ -183,8 +184,12 @@ static void run_test(struct vdev_info *dev, struct vq_info *vq, int bufs)
183184
assert(started <= bufs);
184185
if (completed == bufs)
185186
break;
186-
if (virtqueue_enable_cb(vq->vq)) {
187-
wait_for_interrupt(dev);
187+
if (delayed) {
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);
188193
}
189194
}
190195
test = 0;
@@ -215,6 +220,14 @@ const struct option longopts[] = {
215220
.name = "no-indirect",
216221
.val = 'i',
217222
},
223+
{
224+
.name = "delayed-interrupt",
225+
.val = 'D',
226+
},
227+
{
228+
.name = "no-delayed-interrupt",
229+
.val = 'd',
230+
},
218231
{
219232
}
220233
};
@@ -224,6 +237,7 @@ static void help()
224237
fprintf(stderr, "Usage: virtio_test [--help]"
225238
" [--no-indirect]"
226239
" [--no-event-idx]"
240+
" [--delayed-interrupt]"
227241
"\n");
228242
}
229243

@@ -233,6 +247,7 @@ int main(int argc, char **argv)
233247
unsigned long long features = (1ULL << VIRTIO_RING_F_INDIRECT_DESC) |
234248
(1ULL << VIRTIO_RING_F_EVENT_IDX);
235249
int o;
250+
bool delayed = false;
236251

237252
for (;;) {
238253
o = getopt_long(argc, argv, optstring, longopts, NULL);
@@ -251,6 +266,9 @@ int main(int argc, char **argv)
251266
case 'i':
252267
features &= ~(1ULL << VIRTIO_RING_F_INDIRECT_DESC);
253268
break;
269+
case 'D':
270+
delayed = true;
271+
break;
254272
default:
255273
assert(0);
256274
break;
@@ -260,6 +278,6 @@ int main(int argc, char **argv)
260278
done:
261279
vdev_info_init(&dev, features);
262280
vq_info_add(&dev, 256);
263-
run_test(&dev, &dev.vqs[0], 0x100000);
281+
run_test(&dev, &dev.vqs[0], delayed, 0x100000);
264282
return 0;
265283
}

0 commit comments

Comments
 (0)