[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH 07/12] plat/drivers: Enable/disable interrupts on virtio block queues
This patch introduces support for the user to enable/disable interrupts on queues. Signed-off-by: Roxana Nicolescu <nicolescu.roxana1996@xxxxxxxxx> --- plat/drivers/virtio/virtio_blk.c | 68 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/plat/drivers/virtio/virtio_blk.c b/plat/drivers/virtio/virtio_blk.c index 20dc1d65..fadca07a 100644 --- a/plat/drivers/virtio/virtio_blk.c +++ b/plat/drivers/virtio/virtio_blk.c @@ -35,6 +35,11 @@ #define DRIVER_NAME "virtio-blk" #define DEFAULT_SECTOR_SIZE 512 +#define VTBLK_INTR_EN (1 << 0) +#define VTBLK_INTR_EN_MASK (1) +#define VTBLK_INTR_USR_EN (1 << 1) +#define VTBLK_INTR_USR_EN_MASK (2) + #define to_virtioblkdev(bdev) \ __containerof(bdev, struct virtio_blk_device, blkdev) @@ -86,6 +91,8 @@ struct uk_blkdev_queue { uint16_t max_nb_desc; /* The nr. of descriptor user configured */ uint16_t nb_desc; + /* The flag to interrupt on the queue */ + uint8_t intr_enabled; /* Reference to virtio_blk_device */ struct virtio_blk_device *vbd; /* The scatter list and its associated fragments */ @@ -101,11 +108,70 @@ static int virtio_blkdev_recv_done(struct virtqueue *vq, void *priv) UK_ASSERT(vq && priv); queue = (struct uk_blkdev_queue *) priv; + + /* Disable the interrupt for the ring */ + virtqueue_intr_disable(vq); + queue->intr_enabled &= ~(VTBLK_INTR_EN); + uk_blkdev_drv_queue_event(&queue->vbd->blkdev, queue->lqueue_id); return 1; } +static int virtio_blkdev_queue_intr_enable(struct uk_blkdev *dev, + uint16_t queue_id) +{ + struct virtio_blk_device *d; + + int rc = 0; + struct uk_blkdev_queue *queue; + + UK_ASSERT(dev); + + d = to_virtioblkdev(dev); + if (unlikely(queue_id >= d->nb_queues)) { + uk_pr_err("Invalid queue_id %"__PRIu16"\n", queue_id); + return -EINVAL; + } + + queue = &d->qs[queue_id]; + /* If the interrupt is enabled */ + if (queue->intr_enabled & VTBLK_INTR_EN) + return 0; + + /** + * Enable the user configuration bit. This would cause the interrupt to + * be enabled automatically, if the interrupt could not be enabled now + * due to data in the queue. + */ + queue->intr_enabled = VTBLK_INTR_USR_EN; + rc = virtqueue_intr_enable(queue->vq); + if (!rc) + queue->intr_enabled |= VTBLK_INTR_EN; + + return rc; +} + +static int virtio_blkdev_queue_intr_disable(struct uk_blkdev *dev, + uint16_t queue_id) +{ + struct virtio_blk_device *vbdev; + struct uk_blkdev_queue *queue; + + UK_ASSERT(dev); + vbdev = to_virtioblkdev(dev); + if (unlikely(queue_id >= vbdev->nb_queues)) { + uk_pr_err("Invalid queue_id %"__PRIu16"\n", queue_id); + return -EINVAL; + } + + queue = &vbdev->qs[queue_id]; + virtqueue_intr_disable(queue->vq); + queue->intr_enabled &= ~(VTBLK_INTR_USR_EN | VTBLK_INTR_EN); + + return 0; +} + /** * This function setup the vring infrastructure. */ @@ -471,6 +537,8 @@ static const struct uk_blkdev_ops virtio_blkdev_ops = { .dev_configure = virtio_blkdev_configure, .queue_get_info = virtio_blkdev_queue_info_get, .queue_setup = virtio_blkdev_queue_setup, + .queue_intr_enable = virtio_blkdev_queue_intr_enable, + .queue_intr_disable = virtio_blkdev_queue_intr_disable, .queue_release = virtio_blkdev_queue_release, .dev_close = virtio_blkdev_close, }; -- 2.11.0 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |