Skip to content

Commit 76422fd

Browse files
chejianjjren1
authored andcommitted
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 <jian.jun.chen@intel.com> Reviewed-by: Hao Li <hao.l.li@intel.com> Reviewed-by: Zhao Yakui <yakui.zhao@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent cfa591a commit 76422fd

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

devicemodel/hw/pci/virtio/virtio.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1340,7 +1340,31 @@ static void
13401340
virtio_notify_cfg_write(struct pci_vdev *dev, uint64_t offset, int size,
13411341
uint64_t value)
13421342
{
1343-
/* TODO: to be implemented */
1343+
struct virtio_base *base = dev->arg;
1344+
struct virtio_vq_info *vq;
1345+
struct virtio_ops *vops;
1346+
const char *name;
1347+
uint64_t idx;
1348+
1349+
idx = offset / VIRTIO_MODERN_NOTIFY_OFF_MULT;
1350+
vops = base->vops;
1351+
name = vops->name;
1352+
1353+
if (idx >= vops->nvq) {
1354+
fprintf(stderr,
1355+
"%s: queue %lu notify out of range\r\n", name, idx);
1356+
return;
1357+
}
1358+
1359+
vq = &base->queues[idx];
1360+
if (vq->notify)
1361+
(*vq->notify)(DEV_STRUCT(base), vq);
1362+
else if (vops->qnotify)
1363+
(*vops->qnotify)(DEV_STRUCT(base), vq);
1364+
else
1365+
fprintf(stderr,
1366+
"%s: qnotify queue %lu: missing vq/vops notify\r\n",
1367+
name, idx);
13441368
}
13451369

13461370
static uint32_t

0 commit comments

Comments
 (0)