Commit 53fbb17b authored by Jean-Philippe Brucker's avatar Jean-Philippe Brucker Committed by Will Deacon
Browse files

virtio: Add get_vq() callback



To ease future changes to the core, replace get_pfn_vq() with get_vq().
This way adding new generic operation on virtqueues won't require
modifying every virtio device.
Signed-off-by: default avatarJean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: default avatarJulien Thierry <julien.thierry@arm.com>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
parent b98ac591
...@@ -188,7 +188,7 @@ struct virtio_ops { ...@@ -188,7 +188,7 @@ struct virtio_ops {
int (*init_vq)(struct kvm *kvm, void *dev, u32 vq, u32 page_size, int (*init_vq)(struct kvm *kvm, void *dev, u32 vq, u32 page_size,
u32 align, u32 pfn); u32 align, u32 pfn);
int (*notify_vq)(struct kvm *kvm, void *dev, u32 vq); int (*notify_vq)(struct kvm *kvm, void *dev, u32 vq);
int (*get_pfn_vq)(struct kvm *kvm, void *dev, u32 vq); struct virt_queue *(*get_vq)(struct kvm *kvm, void *dev, u32 vq);
int (*get_size_vq)(struct kvm *kvm, void *dev, u32 vq); int (*get_size_vq)(struct kvm *kvm, void *dev, u32 vq);
int (*set_size_vq)(struct kvm *kvm, void *dev, u32 vq, int size); int (*set_size_vq)(struct kvm *kvm, void *dev, u32 vq, int size);
void (*notify_vq_gsi)(struct kvm *kvm, void *dev, u32 vq, u32 gsi); void (*notify_vq_gsi)(struct kvm *kvm, void *dev, u32 vq, u32 gsi);
......
...@@ -1422,11 +1422,11 @@ static int notify_vq(struct kvm *kvm, void *dev, u32 vq) ...@@ -1422,11 +1422,11 @@ static int notify_vq(struct kvm *kvm, void *dev, u32 vq)
return 0; return 0;
} }
static int get_pfn_vq(struct kvm *kvm, void *dev, u32 vq) static struct virt_queue *get_vq(struct kvm *kvm, void *dev, u32 vq)
{ {
struct p9_dev *p9dev = dev; struct p9_dev *p9dev = dev;
return p9dev->vqs[vq].pfn; return &p9dev->vqs[vq];
} }
static int get_size_vq(struct kvm *kvm, void *dev, u32 vq) static int get_size_vq(struct kvm *kvm, void *dev, u32 vq)
...@@ -1452,7 +1452,7 @@ struct virtio_ops p9_dev_virtio_ops = { ...@@ -1452,7 +1452,7 @@ struct virtio_ops p9_dev_virtio_ops = {
.init_vq = init_vq, .init_vq = init_vq,
.notify_status = notify_status, .notify_status = notify_status,
.notify_vq = notify_vq, .notify_vq = notify_vq,
.get_pfn_vq = get_pfn_vq, .get_vq = get_vq,
.get_size_vq = get_size_vq, .get_size_vq = get_size_vq,
.set_size_vq = set_size_vq, .set_size_vq = set_size_vq,
.get_vq_count = get_vq_count, .get_vq_count = get_vq_count,
......
...@@ -225,11 +225,11 @@ static int notify_vq(struct kvm *kvm, void *dev, u32 vq) ...@@ -225,11 +225,11 @@ static int notify_vq(struct kvm *kvm, void *dev, u32 vq)
return 0; return 0;
} }
static int get_pfn_vq(struct kvm *kvm, void *dev, u32 vq) static struct virt_queue *get_vq(struct kvm *kvm, void *dev, u32 vq)
{ {
struct bln_dev *bdev = dev; struct bln_dev *bdev = dev;
return bdev->vqs[vq].pfn; return &bdev->vqs[vq];
} }
static int get_size_vq(struct kvm *kvm, void *dev, u32 vq) static int get_size_vq(struct kvm *kvm, void *dev, u32 vq)
...@@ -255,7 +255,7 @@ struct virtio_ops bln_dev_virtio_ops = { ...@@ -255,7 +255,7 @@ struct virtio_ops bln_dev_virtio_ops = {
.init_vq = init_vq, .init_vq = init_vq,
.notify_status = notify_status, .notify_status = notify_status,
.notify_vq = notify_vq, .notify_vq = notify_vq,
.get_pfn_vq = get_pfn_vq, .get_vq = get_vq,
.get_size_vq = get_size_vq, .get_size_vq = get_size_vq,
.set_size_vq = set_size_vq, .set_size_vq = set_size_vq,
.get_vq_count = get_vq_count, .get_vq_count = get_vq_count,
......
...@@ -229,11 +229,11 @@ static int notify_vq(struct kvm *kvm, void *dev, u32 vq) ...@@ -229,11 +229,11 @@ static int notify_vq(struct kvm *kvm, void *dev, u32 vq)
return 0; return 0;
} }
static int get_pfn_vq(struct kvm *kvm, void *dev, u32 vq) static struct virt_queue *get_vq(struct kvm *kvm, void *dev, u32 vq)
{ {
struct blk_dev *bdev = dev; struct blk_dev *bdev = dev;
return bdev->vqs[vq].pfn; return &bdev->vqs[vq];
} }
static int get_size_vq(struct kvm *kvm, void *dev, u32 vq) static int get_size_vq(struct kvm *kvm, void *dev, u32 vq)
...@@ -261,7 +261,7 @@ static struct virtio_ops blk_dev_virtio_ops = { ...@@ -261,7 +261,7 @@ static struct virtio_ops blk_dev_virtio_ops = {
.init_vq = init_vq, .init_vq = init_vq,
.notify_status = notify_status, .notify_status = notify_status,
.notify_vq = notify_vq, .notify_vq = notify_vq,
.get_pfn_vq = get_pfn_vq, .get_vq = get_vq,
.get_size_vq = get_size_vq, .get_size_vq = get_size_vq,
.set_size_vq = set_size_vq, .set_size_vq = set_size_vq,
}; };
......
...@@ -184,11 +184,11 @@ static int notify_vq(struct kvm *kvm, void *dev, u32 vq) ...@@ -184,11 +184,11 @@ static int notify_vq(struct kvm *kvm, void *dev, u32 vq)
return 0; return 0;
} }
static int get_pfn_vq(struct kvm *kvm, void *dev, u32 vq) static struct virt_queue *get_vq(struct kvm *kvm, void *dev, u32 vq)
{ {
struct con_dev *cdev = dev; struct con_dev *cdev = dev;
return cdev->vqs[vq].pfn; return &cdev->vqs[vq];
} }
static int get_size_vq(struct kvm *kvm, void *dev, u32 vq) static int get_size_vq(struct kvm *kvm, void *dev, u32 vq)
...@@ -215,7 +215,7 @@ static struct virtio_ops con_dev_virtio_ops = { ...@@ -215,7 +215,7 @@ static struct virtio_ops con_dev_virtio_ops = {
.init_vq = init_vq, .init_vq = init_vq,
.notify_status = notify_status, .notify_status = notify_status,
.notify_vq = notify_vq, .notify_vq = notify_vq,
.get_pfn_vq = get_pfn_vq, .get_vq = get_vq,
.get_size_vq = get_size_vq, .get_size_vq = get_size_vq,
.set_size_vq = set_size_vq, .set_size_vq = set_size_vq,
}; };
......
...@@ -111,6 +111,7 @@ static void virtio_mmio_config_in(struct kvm_cpu *vcpu, ...@@ -111,6 +111,7 @@ static void virtio_mmio_config_in(struct kvm_cpu *vcpu,
struct virtio_device *vdev) struct virtio_device *vdev)
{ {
struct virtio_mmio *vmmio = vdev->virtio; struct virtio_mmio *vmmio = vdev->virtio;
struct virt_queue *vq;
u32 val = 0; u32 val = 0;
switch (addr) { switch (addr) {
...@@ -129,9 +130,9 @@ static void virtio_mmio_config_in(struct kvm_cpu *vcpu, ...@@ -129,9 +130,9 @@ static void virtio_mmio_config_in(struct kvm_cpu *vcpu,
ioport__write32(data, val); ioport__write32(data, val);
break; break;
case VIRTIO_MMIO_QUEUE_PFN: case VIRTIO_MMIO_QUEUE_PFN:
val = vdev->ops->get_pfn_vq(vmmio->kvm, vmmio->dev, vq = vdev->ops->get_vq(vmmio->kvm, vmmio->dev,
vmmio->hdr.queue_sel); vmmio->hdr.queue_sel);
ioport__write32(data, val); ioport__write32(data, vq->pfn);
break; break;
case VIRTIO_MMIO_QUEUE_NUM_MAX: case VIRTIO_MMIO_QUEUE_NUM_MAX:
val = vdev->ops->get_size_vq(vmmio->kvm, vmmio->dev, val = vdev->ops->get_size_vq(vmmio->kvm, vmmio->dev,
......
...@@ -662,11 +662,11 @@ static int notify_vq(struct kvm *kvm, void *dev, u32 vq) ...@@ -662,11 +662,11 @@ static int notify_vq(struct kvm *kvm, void *dev, u32 vq)
return 0; return 0;
} }
static int get_pfn_vq(struct kvm *kvm, void *dev, u32 vq) static struct virt_queue *get_vq(struct kvm *kvm, void *dev, u32 vq)
{ {
struct net_dev *ndev = dev; struct net_dev *ndev = dev;
return ndev->vqs[vq].pfn; return &ndev->vqs[vq];
} }
static int get_size_vq(struct kvm *kvm, void *dev, u32 vq) static int get_size_vq(struct kvm *kvm, void *dev, u32 vq)
...@@ -694,7 +694,7 @@ static struct virtio_ops net_dev_virtio_ops = { ...@@ -694,7 +694,7 @@ static struct virtio_ops net_dev_virtio_ops = {
.set_guest_features = set_guest_features, .set_guest_features = set_guest_features,
.get_vq_count = get_vq_count, .get_vq_count = get_vq_count,
.init_vq = init_vq, .init_vq = init_vq,
.get_pfn_vq = get_pfn_vq, .get_vq = get_vq,
.get_size_vq = get_size_vq, .get_size_vq = get_size_vq,
.set_size_vq = set_size_vq, .set_size_vq = set_size_vq,
.notify_vq = notify_vq, .notify_vq = notify_vq,
......
...@@ -113,6 +113,7 @@ static bool virtio_pci__io_in(struct ioport *ioport, struct kvm_cpu *vcpu, u16 p ...@@ -113,6 +113,7 @@ static bool virtio_pci__io_in(struct ioport *ioport, struct kvm_cpu *vcpu, u16 p
bool ret = true; bool ret = true;
struct virtio_device *vdev; struct virtio_device *vdev;
struct virtio_pci *vpci; struct virtio_pci *vpci;
struct virt_queue *vq;
struct kvm *kvm; struct kvm *kvm;
u32 val; u32 val;
...@@ -127,8 +128,8 @@ static bool virtio_pci__io_in(struct ioport *ioport, struct kvm_cpu *vcpu, u16 p ...@@ -127,8 +128,8 @@ static bool virtio_pci__io_in(struct ioport *ioport, struct kvm_cpu *vcpu, u16 p
ioport__write32(data, val); ioport__write32(data, val);
break; break;
case VIRTIO_PCI_QUEUE_PFN: case VIRTIO_PCI_QUEUE_PFN:
val = vdev->ops->get_pfn_vq(kvm, vpci->dev, vpci->queue_selector); vq = vdev->ops->get_vq(kvm, vpci->dev, vpci->queue_selector);
ioport__write32(data, val); ioport__write32(data, vq->pfn);
break; break;
case VIRTIO_PCI_QUEUE_NUM: case VIRTIO_PCI_QUEUE_NUM:
val = vdev->ops->get_size_vq(kvm, vpci->dev, vpci->queue_selector); val = vdev->ops->get_size_vq(kvm, vpci->dev, vpci->queue_selector);
......
...@@ -123,11 +123,11 @@ static int notify_vq(struct kvm *kvm, void *dev, u32 vq) ...@@ -123,11 +123,11 @@ static int notify_vq(struct kvm *kvm, void *dev, u32 vq)
return 0; return 0;
} }
static int get_pfn_vq(struct kvm *kvm, void *dev, u32 vq) static struct virt_queue *get_vq(struct kvm *kvm, void *dev, u32 vq)
{ {
struct rng_dev *rdev = dev; struct rng_dev *rdev = dev;
return rdev->vqs[vq].pfn; return &rdev->vqs[vq];
} }
static int get_size_vq(struct kvm *kvm, void *dev, u32 vq) static int get_size_vq(struct kvm *kvm, void *dev, u32 vq)
...@@ -152,7 +152,7 @@ static struct virtio_ops rng_dev_virtio_ops = { ...@@ -152,7 +152,7 @@ static struct virtio_ops rng_dev_virtio_ops = {
.set_guest_features = set_guest_features, .set_guest_features = set_guest_features,
.init_vq = init_vq, .init_vq = init_vq,
.notify_vq = notify_vq, .notify_vq = notify_vq,
.get_pfn_vq = get_pfn_vq, .get_vq = get_vq,
.get_size_vq = get_size_vq, .get_size_vq = get_size_vq,
.set_size_vq = set_size_vq, .set_size_vq = set_size_vq,
.get_vq_count = get_vq_count, .get_vq_count = get_vq_count,
......
...@@ -150,11 +150,11 @@ static int notify_vq(struct kvm *kvm, void *dev, u32 vq) ...@@ -150,11 +150,11 @@ static int notify_vq(struct kvm *kvm, void *dev, u32 vq)
return 0; return 0;
} }
static int get_pfn_vq(struct kvm *kvm, void *dev, u32 vq) static struct virt_queue *get_vq(struct kvm *kvm, void *dev, u32 vq)
{ {
struct scsi_dev *sdev = dev; struct scsi_dev *sdev = dev;
return sdev->vqs[vq].pfn; return &sdev->vqs[vq];
} }
static int get_size_vq(struct kvm *kvm, void *dev, u32 vq) static int get_size_vq(struct kvm *kvm, void *dev, u32 vq)
...@@ -177,7 +177,7 @@ static struct virtio_ops scsi_dev_virtio_ops = { ...@@ -177,7 +177,7 @@ static struct virtio_ops scsi_dev_virtio_ops = {
.get_host_features = get_host_features, .get_host_features = get_host_features,
.set_guest_features = set_guest_features, .set_guest_features = set_guest_features,
.init_vq = init_vq, .init_vq = init_vq,
.get_pfn_vq = get_pfn_vq, .get_vq = get_vq,
.get_size_vq = get_size_vq, .get_size_vq = get_size_vq,
.set_size_vq = set_size_vq, .set_size_vq = set_size_vq,
.notify_status = notify_status, .notify_status = notify_status,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment