[SLOF] [PATCH v3 13/22] virtio: add virtio 1.0 related struct and defines
Thomas Huth
thuth at redhat.com
Wed Jan 27 19:44:37 AEDT 2016
On 22.01.2016 11:54, Nikunj A Dadhania wrote:
> Traditionally, struct virtio_device is shared between SLOF and C code.
> This still remains shared with the addition of virtio_cap structure as
> well. Now both virtio_device and virtio_cap structures are shared.
>
> Signed-off-by: Nikunj A Dadhania <nikunj at linux.vnet.ibm.com>
> ---
> board-qemu/slof/virtio.fs | 17 +++++++++++++++++
> include/byteorder.h | 4 ++++
> lib/libvirtio/virtio.c | 19 +++++++++++++++++++
> lib/libvirtio/virtio.h | 29 ++++++++++++++++++++++++++++-
> 4 files changed, 68 insertions(+), 1 deletion(-)
...
> diff --git a/lib/libvirtio/virtio.h b/lib/libvirtio/virtio.h
> index c26282f..8c9daab 100644
> --- a/lib/libvirtio/virtio.h
> +++ b/lib/libvirtio/virtio.h
> @@ -20,8 +20,17 @@
> #define VIRTIO_STAT_ACKNOWLEDGE 1
> #define VIRTIO_STAT_DRIVER 2
> #define VIRTIO_STAT_DRIVER_OK 4
> +#define VIRTIO_STAT_FEATURES_OK 8
> +#define VIRTIO_STAT_NEEDS_RESET 64
> #define VIRTIO_STAT_FAILED 128
>
> +#define BIT(x) (1UL << (x))
> +
> +/* VIRTIO 1.0 Device independent feature bits */
> +#define VIRTIO_F_RING_INDIRECT_DESC BIT(28)
> +#define VIRTIO_F_RING_EVENT_IDX BIT(29)
> +#define VIRTIO_F_VERSION_1 BIT(32)
> +
> #define VIRTIO_TIMEOUT 5000 /* 5 sec timeout */
>
> /* Definitions for vring_desc.flags */
> @@ -62,10 +71,28 @@ struct vring_used {
> };
>
> #define VIRTIO_TYPE_PCI 0 /* For virtio-pci interface */
> +
> +/* Structure shared with SLOF and is 16bytes */
> +struct virtio_cap {
> + void *addr;
> + uint8_t bar;
> + uint8_t is_io;
> + uint8_t cap_id;
> + uint8_t pad[5];
> +} __attribute__ ((packed));
> +
> struct virtio_device {
> void *base; /* base address */
> int type; /* VIRTIO_TYPE_PCI or VIRTIO_TYPE_VIO */
> -};
> + uint32_t is_modern; /* Indicates whether to use virtio 1.0 */
I was just thinking about the "int type" field again which is pretty
much unused nowadays, since VIRTIO_TYPE_VIO is not supported anymore...
Maybe you could also simply use the "type" field instead of introducing
a "is_modern" flag ... then you'd simply have VIRTIO_TYPE_PCI_LEGACY
and VIRTIO_TYPE_PCI_MODERN there instead?
OTOH, if that's too cumbersome, you could also finally add a patch that
removes the type field completely from the code - but maintaining both
fields, "type" and "is_modern", does not make much sense in the long
run, I think.
Thomas
More information about the SLOF
mailing list