diff options
author | Nikunj A. Dadhania <nikunj@linux.vnet.ibm.com> | 2013-01-04 11:39:26 +0530 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2013-05-21 15:13:45 +1000 |
commit | a35e44f0e667fdc7428d8ec2d29d3c4c11b978d1 (patch) | |
tree | aa8f96ec82b314bd7bd4428c561626956cd99fd0 /lib | |
parent | 0a389ba95d50863785063efd9d7d0ca680487f0e (diff) | |
download | SLOF-a35e44f0e667fdc7428d8ec2d29d3c4c11b978d1.zip SLOF-a35e44f0e667fdc7428d8ec2d29d3c4c11b978d1.tar.gz SLOF-a35e44f0e667fdc7428d8ec2d29d3c4c11b978d1.tar.bz2 |
virtio: Add a virtio-set-qaddr helper
A simple function that can be used from forth code for setting
virtqueue address. virito-scsi has multiple virtqueues(atleast 3) and
need to use set queue address for all the 3 queues.
Signed-off-by: Nikunj A. Dadhania <nikunj@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libvirtio/virtio.c | 15 | ||||
-rw-r--r-- | lib/libvirtio/virtio.code | 8 | ||||
-rw-r--r-- | lib/libvirtio/virtio.h | 1 | ||||
-rw-r--r-- | lib/libvirtio/virtio.in | 1 |
4 files changed, 25 insertions, 0 deletions
diff --git a/lib/libvirtio/virtio.c b/lib/libvirtio/virtio.c index 29d5dd3..249f803 100644 --- a/lib/libvirtio/virtio.c +++ b/lib/libvirtio/virtio.c @@ -128,6 +128,21 @@ void virtio_queue_notify(struct virtio_device *dev, int queue) } } +/** + * Set queue address + */ +void virtio_set_qaddr(struct virtio_device *dev, int queue, unsigned int qaddr) +{ + if (dev->type == VIRTIO_TYPE_PCI) { + uint32_t val = qaddr; + val = val >> 12; + ci_write_16(dev->base+VIRTIOHDR_QUEUE_SELECT, + cpu_to_le16(queue)); + eieio(); + ci_write_32(dev->base+VIRTIOHDR_QUEUE_ADDRESS, + cpu_to_le32(val)); + } +} /** * Set device status bits diff --git a/lib/libvirtio/virtio.code b/lib/libvirtio/virtio.code index 65e1d8a..100cc96 100644 --- a/lib/libvirtio/virtio.code +++ b/lib/libvirtio/virtio.code @@ -34,6 +34,14 @@ PRIM(virtio_X2d_get_X2d_config) TOS.u = virtio_get_config(TOS.a, offset, size); MIRP +// : virtio-set-qaddr ( dev queue qaddr -- ) +PRIM(virtio_X2d_set_X2d_qaddr) + unsigned int qaddr = TOS.u; POP; + int queue = TOS.u; POP; + void *dev = TOS.a; POP; + virtio_set_qaddr(dev, queue, qaddr); +MIRP + /******** virtio-blk ********/ // : virtio-blk-init ( dev -- ) diff --git a/lib/libvirtio/virtio.h b/lib/libvirtio/virtio.h index 37d4eb3..bb86d8d 100644 --- a/lib/libvirtio/virtio.h +++ b/lib/libvirtio/virtio.h @@ -77,6 +77,7 @@ extern struct vring_used *virtio_get_vring_used(struct virtio_device *dev, int q extern void virtio_reset_device(struct virtio_device *dev); extern void virtio_queue_notify(struct virtio_device *dev, int queue); extern void virtio_set_status(struct virtio_device *dev, int status); +extern void virtio_set_qaddr(struct virtio_device *dev, int queue, unsigned int qaddr); extern void virtio_set_guest_features(struct virtio_device *dev, int features); extern uint64_t virtio_get_config(struct virtio_device *dev, int offset, int size); extern int __virtio_read_config(struct virtio_device *dev, void *dst, diff --git a/lib/libvirtio/virtio.in b/lib/libvirtio/virtio.in index 205bb13..a702779 100644 --- a/lib/libvirtio/virtio.in +++ b/lib/libvirtio/virtio.in @@ -13,6 +13,7 @@ cod(virtio-vring-size) cod(virtio-get-qsize) cod(virtio-get-config) +cod(virtio-set-qaddr) cod(virtio-blk-init) cod(virtio-blk-shutdown) |