Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

virtio/tools: add delayed interupt mode

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

+23 -4
+1
tools/virtio/linux/virtio.h
··· 203 203 void virtqueue_disable_cb(struct virtqueue *vq); 204 204 205 205 bool virtqueue_enable_cb(struct virtqueue *vq); 206 + bool virtqueue_enable_cb_delayed(struct virtqueue *vq); 206 207 207 208 void *virtqueue_detach_unused_buf(struct virtqueue *vq); 208 209 struct virtqueue *vring_new_virtqueue(unsigned int num,
+22 -4
tools/virtio/virtio_test.c
··· 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 150 struct scatterlist sl; 150 151 long started = 0, completed = 0; ··· 184 183 assert(started <= bufs); 185 184 if (completed == bufs) 186 185 break; 187 - if (virtqueue_enable_cb(vq->vq)) { 188 - wait_for_interrupt(dev); 186 + if (delayed) { 187 + if (virtqueue_enable_cb_delayed(vq->vq)) 188 + wait_for_interrupt(dev); 189 + } else { 190 + if (virtqueue_enable_cb(vq->vq)) 191 + wait_for_interrupt(dev); 189 192 } 190 193 } 191 194 test = 0; ··· 221 216 .val = 'i', 222 217 }, 223 218 { 219 + .name = "delayed-interrupt", 220 + .val = 'D', 221 + }, 222 + { 223 + .name = "no-delayed-interrupt", 224 + .val = 'd', 225 + }, 226 + { 224 227 } 225 228 }; 226 229 ··· 237 224 fprintf(stderr, "Usage: virtio_test [--help]" 238 225 " [--no-indirect]" 239 226 " [--no-event-idx]" 227 + " [--delayed-interrupt]" 240 228 "\n"); 241 229 } 242 230 ··· 247 233 unsigned long long features = (1ULL << VIRTIO_RING_F_INDIRECT_DESC) | 248 234 (1ULL << VIRTIO_RING_F_EVENT_IDX); 249 235 int o; 236 + bool delayed = false; 250 237 251 238 for (;;) { 252 239 o = getopt_long(argc, argv, optstring, longopts, NULL); ··· 266 251 case 'i': 267 252 features &= ~(1ULL << VIRTIO_RING_F_INDIRECT_DESC); 268 253 break; 254 + case 'D': 255 + delayed = true; 256 + break; 269 257 default: 270 258 assert(0); 271 259 break; ··· 278 260 done: 279 261 vdev_info_init(&dev, features); 280 262 vq_info_add(&dev, 256); 281 - run_test(&dev, &dev.vqs[0], 0x100000); 263 + run_test(&dev, &dev.vqs[0], delayed, 0x100000); 282 264 return 0; 283 265 }