diff options
author | Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> | 2016-02-01 11:18:04 +0530 |
---|---|---|
committer | Alexey Kardashevskiy <aik@ozlabs.ru> | 2016-02-08 16:40:39 +1100 |
commit | 5ed17500f03913f3f125ecde14aa041c6235ba08 (patch) | |
tree | d97248719d0bef3a2bcd4e347764acf378d53540 | |
parent | aa9566d2ed5c4fdcaa385759475c75bb0d0801d4 (diff) | |
download | SLOF-5ed17500f03913f3f125ecde14aa041c6235ba08.zip SLOF-5ed17500f03913f3f125ecde14aa041c6235ba08.tar.gz SLOF-5ed17500f03913f3f125ecde14aa041c6235ba08.tar.bz2 |
virtio: get rid of type variable in virtio_device
virtio device structure carries a type variable indicating whether
virtio is over PCI or VIO. While VIO is not there and no plan to
introduce other transport, there is no purpose of having this variable
around and checking for PCI.
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
-rw-r--r-- | board-qemu/slof/virtio.fs | 16 | ||||
-rw-r--r-- | lib/libvirtio/virtio-net.c | 1 | ||||
-rw-r--r-- | lib/libvirtio/virtio.c | 64 | ||||
-rw-r--r-- | lib/libvirtio/virtio.h | 2 |
4 files changed, 25 insertions, 58 deletions
diff --git a/board-qemu/slof/virtio.fs b/board-qemu/slof/virtio.fs index 818c132..1bf2e76 100644 --- a/board-qemu/slof/virtio.fs +++ b/board-qemu/slof/virtio.fs @@ -13,23 +13,15 @@ \ This struct must match "struct virtio_device" in virtio.h! STRUCT /n FIELD vd>base - /l FIELD vd>type CONSTANT /vd-len \ Initialize virtiodev structure for the current node +\ This routine gets called from pci device files : virtio-setup-vd ( vdstruct -- ) >r - \ Does it have a "class-code" property? If yes, assume we're a PCI device - s" class-code" get-node get-property 0= IF - \ Set up for PCI device interface - 2drop - s" 10 config-l@ translate-my-address 3 not AND" evaluate - ( io-base ) r@ vd>base ! - 0 r@ vd>type l! - ELSE - ." unsupported virtio interface!" cr - 1 r@ vd>type l! - THEN + \ Set up for PCI device interface + s" 10 config-l@ translate-my-address 3 not AND" evaluate + ( io-base ) r@ vd>base ! r> drop ; diff --git a/lib/libvirtio/virtio-net.c b/lib/libvirtio/virtio-net.c index f8b8cec..6eeb076 100644 --- a/lib/libvirtio/virtio-net.c +++ b/lib/libvirtio/virtio-net.c @@ -69,7 +69,6 @@ static int virtionet_init_pci(struct virtio_device *dev) return -1; virtiodev.base = dev->base; - virtiodev.type = dev->type; /* Reset device */ virtio_reset_device(&virtiodev); diff --git a/lib/libvirtio/virtio.c b/lib/libvirtio/virtio.c index 4ea8278..edb6258 100644 --- a/lib/libvirtio/virtio.c +++ b/lib/libvirtio/virtio.c @@ -54,12 +54,10 @@ int virtio_get_qsize(struct virtio_device *dev, int queue) { int size = 0; - if (dev->type == VIRTIO_TYPE_PCI) { - ci_write_16(dev->base+VIRTIOHDR_QUEUE_SELECT, - cpu_to_le16(queue)); - eieio(); - size = le16_to_cpu(ci_read_16(dev->base+VIRTIOHDR_QUEUE_SIZE)); - } + ci_write_16(dev->base+VIRTIOHDR_QUEUE_SELECT, + cpu_to_le16(queue)); + eieio(); + size = le16_to_cpu(ci_read_16(dev->base+VIRTIOHDR_QUEUE_SIZE)); return size; } @@ -75,13 +73,11 @@ struct vring_desc *virtio_get_vring_desc(struct virtio_device *dev, int queue) { struct vring_desc *desc = 0; - if (dev->type == VIRTIO_TYPE_PCI) { - ci_write_16(dev->base+VIRTIOHDR_QUEUE_SELECT, - cpu_to_le16(queue)); - eieio(); - desc = (void*)(4096L * - le32_to_cpu(ci_read_32(dev->base+VIRTIOHDR_QUEUE_ADDRESS))); - } + ci_write_16(dev->base+VIRTIOHDR_QUEUE_SELECT, + cpu_to_le16(queue)); + eieio(); + desc = (void*)(4096L * + le32_to_cpu(ci_read_32(dev->base+VIRTIOHDR_QUEUE_ADDRESS))); return desc; } @@ -138,9 +134,7 @@ void virtio_fill_desc(struct vring_desc *desc, bool is_modern, */ void virtio_reset_device(struct virtio_device *dev) { - if (dev->type == VIRTIO_TYPE_PCI) { - ci_write_8(dev->base+VIRTIOHDR_DEVICE_STATUS, 0); - } + ci_write_8(dev->base+VIRTIOHDR_DEVICE_STATUS, 0); } @@ -149,9 +143,7 @@ void virtio_reset_device(struct virtio_device *dev) */ void virtio_queue_notify(struct virtio_device *dev, int queue) { - if (dev->type == VIRTIO_TYPE_PCI) { - ci_write_16(dev->base+VIRTIOHDR_QUEUE_NOTIFY, cpu_to_le16(queue)); - } + ci_write_16(dev->base+VIRTIOHDR_QUEUE_NOTIFY, cpu_to_le16(queue)); } /** @@ -159,15 +151,13 @@ void virtio_queue_notify(struct virtio_device *dev, int queue) */ void virtio_set_qaddr(struct virtio_device *dev, int queue, unsigned long 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)); - } + 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)); } int virtio_queue_init_vq(struct virtio_device *dev, struct vqs *vq, unsigned int id) @@ -191,9 +181,7 @@ int virtio_queue_init_vq(struct virtio_device *dev, struct vqs *vq, unsigned int */ void virtio_set_status(struct virtio_device *dev, int status) { - if (dev->type == VIRTIO_TYPE_PCI) { - ci_write_8(dev->base+VIRTIOHDR_DEVICE_STATUS, status); - } + ci_write_8(dev->base+VIRTIOHDR_DEVICE_STATUS, status); } @@ -203,9 +191,7 @@ void virtio_set_status(struct virtio_device *dev, int status) void virtio_set_guest_features(struct virtio_device *dev, int features) { - if (dev->type == VIRTIO_TYPE_PCI) { - ci_write_32(dev->base+VIRTIOHDR_GUEST_FEATURES, bswap_32(features)); - } + ci_write_32(dev->base+VIRTIOHDR_GUEST_FEATURES, bswap_32(features)); } /** @@ -214,9 +200,7 @@ void virtio_set_guest_features(struct virtio_device *dev, int features) void virtio_get_host_features(struct virtio_device *dev, int *features) { - if (dev->type == VIRTIO_TYPE_PCI && features) { - *features = bswap_32(ci_read_32(dev->base+VIRTIOHDR_DEVICE_FEATURES)); - } + *features = bswap_32(ci_read_32(dev->base+VIRTIOHDR_DEVICE_FEATURES)); } @@ -228,9 +212,6 @@ uint64_t virtio_get_config(struct virtio_device *dev, int offset, int size) uint64_t val = ~0ULL; void *confbase; - if (dev->type != VIRTIO_TYPE_PCI) - return val; - confbase = dev->base + VIRTIOHDR_DEVICE_CONFIG; switch (size) { case 1: @@ -265,9 +246,6 @@ int __virtio_read_config(struct virtio_device *dev, void *dst, unsigned char *buf = dst; int i; - if (dev->type != VIRTIO_TYPE_PCI) - return 0; - confbase = dev->base + VIRTIOHDR_DEVICE_CONFIG; for (i = 0; i < len; i++) buf[i] = ci_read_8(confbase + offset + i); diff --git a/lib/libvirtio/virtio.h b/lib/libvirtio/virtio.h index c26282f..75de5ec 100644 --- a/lib/libvirtio/virtio.h +++ b/lib/libvirtio/virtio.h @@ -61,10 +61,8 @@ struct vring_used { struct vring_used_elem ring[]; }; -#define VIRTIO_TYPE_PCI 0 /* For virtio-pci interface */ struct virtio_device { void *base; /* base address */ - int type; /* VIRTIO_TYPE_PCI or VIRTIO_TYPE_VIO */ }; struct vqs { |