From 76422fd5f1108afac2221c6aee46ce8bceaee985 Mon Sep 17 00:00:00 2001 From: Jian Jun Chen Date: Thu, 29 Mar 2018 12:18:25 +0800 Subject: [PATCH] dm/VBS-U: implement write callback of notify cfg virtio_notify_cfg_write is called when guest driver performs virtqueue kick by writing the notificaiton register of the virtqueue. Signed-off-by: Jian Jun Chen Reviewed-by: Hao Li Reviewed-by: Zhao Yakui Acked-by: Eddie Dong --- devicemodel/hw/pci/virtio/virtio.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/devicemodel/hw/pci/virtio/virtio.c b/devicemodel/hw/pci/virtio/virtio.c index 9e93d5be7..a022cb63a 100644 --- a/devicemodel/hw/pci/virtio/virtio.c +++ b/devicemodel/hw/pci/virtio/virtio.c @@ -1340,7 +1340,31 @@ static void virtio_notify_cfg_write(struct pci_vdev *dev, uint64_t offset, int size, uint64_t value) { - /* TODO: to be implemented */ + struct virtio_base *base = dev->arg; + struct virtio_vq_info *vq; + struct virtio_ops *vops; + const char *name; + uint64_t idx; + + idx = offset / VIRTIO_MODERN_NOTIFY_OFF_MULT; + vops = base->vops; + name = vops->name; + + if (idx >= vops->nvq) { + fprintf(stderr, + "%s: queue %lu notify out of range\r\n", name, idx); + return; + } + + vq = &base->queues[idx]; + if (vq->notify) + (*vq->notify)(DEV_STRUCT(base), vq); + else if (vops->qnotify) + (*vops->qnotify)(DEV_STRUCT(base), vq); + else + fprintf(stderr, + "%s: qnotify queue %lu: missing vq/vops notify\r\n", + name, idx); } static uint32_t