diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2008-05-30 16:09:46 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2008-05-30 01:09:46 -0400 |
commit | 20887611523e749d99cc7d64ff6c97d27529fbae (patch) | |
tree | a0b74c524c23762133b8b3de8235753760b13071 /Documentation | |
parent | b4f68be6c5d507afdcd74f5be3df0b1209cda503 (diff) |
lguest: notify on empty
This is the lguest implementation of the VIRTIO_F_NOTIFY_ON_EMPTY feature.
It is currently only published for network devices, but it is turned on for
everyone.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/lguest/lguest.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Documentation/lguest/lguest.c b/Documentation/lguest/lguest.c index 3be8ab2a886a..82fafe0429fe 100644 --- a/Documentation/lguest/lguest.c +++ b/Documentation/lguest/lguest.c | |||
@@ -157,6 +157,9 @@ struct virtqueue | |||
157 | 157 | ||
158 | /* The routine to call when the Guest pings us. */ | 158 | /* The routine to call when the Guest pings us. */ |
159 | void (*handle_output)(int fd, struct virtqueue *me); | 159 | void (*handle_output)(int fd, struct virtqueue *me); |
160 | |||
161 | /* Outstanding buffers */ | ||
162 | unsigned int inflight; | ||
160 | }; | 163 | }; |
161 | 164 | ||
162 | /* Remember the arguments to the program so we can "reboot" */ | 165 | /* Remember the arguments to the program so we can "reboot" */ |
@@ -702,6 +705,7 @@ static unsigned get_vq_desc(struct virtqueue *vq, | |||
702 | errx(1, "Looped descriptor"); | 705 | errx(1, "Looped descriptor"); |
703 | } while ((i = next_desc(vq, i)) != vq->vring.num); | 706 | } while ((i = next_desc(vq, i)) != vq->vring.num); |
704 | 707 | ||
708 | vq->inflight++; | ||
705 | return head; | 709 | return head; |
706 | } | 710 | } |
707 | 711 | ||
@@ -719,6 +723,7 @@ static void add_used(struct virtqueue *vq, unsigned int head, int len) | |||
719 | /* Make sure buffer is written before we update index. */ | 723 | /* Make sure buffer is written before we update index. */ |
720 | wmb(); | 724 | wmb(); |
721 | vq->vring.used->idx++; | 725 | vq->vring.used->idx++; |
726 | vq->inflight--; | ||
722 | } | 727 | } |
723 | 728 | ||
724 | /* This actually sends the interrupt for this virtqueue */ | 729 | /* This actually sends the interrupt for this virtqueue */ |
@@ -726,8 +731,9 @@ static void trigger_irq(int fd, struct virtqueue *vq) | |||
726 | { | 731 | { |
727 | unsigned long buf[] = { LHREQ_IRQ, vq->config.irq }; | 732 | unsigned long buf[] = { LHREQ_IRQ, vq->config.irq }; |
728 | 733 | ||
729 | /* If they don't want an interrupt, don't send one. */ | 734 | /* If they don't want an interrupt, don't send one, unless empty. */ |
730 | if (vq->vring.avail->flags & VRING_AVAIL_F_NO_INTERRUPT) | 735 | if ((vq->vring.avail->flags & VRING_AVAIL_F_NO_INTERRUPT) |
736 | && vq->inflight) | ||
731 | return; | 737 | return; |
732 | 738 | ||
733 | /* Send the Guest an interrupt tell them we used something up. */ | 739 | /* Send the Guest an interrupt tell them we used something up. */ |
@@ -1107,6 +1113,7 @@ static void add_virtqueue(struct device *dev, unsigned int num_descs, | |||
1107 | vq->next = NULL; | 1113 | vq->next = NULL; |
1108 | vq->last_avail_idx = 0; | 1114 | vq->last_avail_idx = 0; |
1109 | vq->dev = dev; | 1115 | vq->dev = dev; |
1116 | vq->inflight = 0; | ||
1110 | 1117 | ||
1111 | /* Initialize the configuration. */ | 1118 | /* Initialize the configuration. */ |
1112 | vq->config.num = num_descs; | 1119 | vq->config.num = num_descs; |
@@ -1368,6 +1375,7 @@ static void setup_tun_net(const char *arg) | |||
1368 | 1375 | ||
1369 | /* Tell Guest what MAC address to use. */ | 1376 | /* Tell Guest what MAC address to use. */ |
1370 | add_feature(dev, VIRTIO_NET_F_MAC); | 1377 | add_feature(dev, VIRTIO_NET_F_MAC); |
1378 | add_feature(dev, VIRTIO_F_NOTIFY_ON_EMPTY); | ||
1371 | set_config(dev, sizeof(conf), &conf); | 1379 | set_config(dev, sizeof(conf), &conf); |
1372 | 1380 | ||
1373 | /* We don't need the socket any more; setup is done. */ | 1381 | /* We don't need the socket any more; setup is done. */ |