From: Mario Smarduch <m.smarduch@samsung.com>
To: "Peter Maydell" <peter.maydell@linaro.org>,
qemu-devel <qemu-devel@nongnu.org>,
"Patch Tracking" <patches@linaro.org>,
"Anthony Liguori" <aliguori@amazon.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"KONRAD Frédéric" <fred.konrad@greensocs.com>
Subject: Re: [Qemu-devel] [PATCH] virtio: set virtio-mmio transport features for various backends
Date: Thu, 27 Feb 2014 16:37:18 -0800 [thread overview]
Message-ID: <530FDA3E.3060002@samsung.com> (raw)
In-Reply-To: <530E9360.6070609@samsung.com>
Anthony, Michael, KONRAD -
I would really appreciate if you (or someone else I should include)
can look over this patch. Currently as things are independent transport and
backend interoperability is broken, since the 'proxy' 'host_features' and
for other transport/backend combinations additional fields are not set
to anything, like they are for legacy combined transport/backend.
With this patch the approach is for every transport to have associated
backend properties defined and use the backend type as index into
its properties and apply them to the transport. Only virtio-mmio
transport is addressed in this patch with few backends to see if
this is acceptable by virtio maintainers.
One issue on applying properties this late is they can't be added to the
object - none of property accessor functions work at this point. This
is something I'm not sure how to handle.
Thanks,
Mario
On 02/26/2014 05:22 PM, Mario Smarduch wrote:
> virtio: set virtio-mmio transport features for various backends
>
> Hi Peter, i.e others -
>
> This is a second attempt at setting transport backend features, for
> back-ends that are instantiated separately from transport and dynamically
> plugged in. virtio-mmio transport is addressed by this patch for virtio-net
> and virtio-blk back-ends.
>
> This patch declares features for all back-ends in the transport file,
> and based on the type of back-end applies the back-end features. A hook
> is added in VirtioBusClass that each transport can override
> to apply specific features for a back-end. The hook is called with the
> back-end device when it's plugged in.
>
> Thanks,
> Mario.
>
> Signed-off-by: Mario Smarduch <m.smarduch@samsung.com>
> ---
> hw/virtio/virtio-bus.c | 5 +++++
> hw/virtio/virtio-mmio.c | 46 ++++++++++++++++++++++++++++++++++++++++
> include/hw/virtio/virtio-bus.h | 4 ++++
> 3 files changed, 55 insertions(+)
>
> diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c
> index eb77019..5eb9ba1 100644
> --- a/hw/virtio/virtio-bus.c
> +++ b/hw/virtio/virtio-bus.c
> @@ -44,8 +44,13 @@ int virtio_bus_device_plugged(VirtIODevice *vdev)
> BusState *qbus = BUS(qdev_get_parent_bus(qdev));
> VirtioBusState *bus = VIRTIO_BUS(qbus);
> VirtioBusClass *klass = VIRTIO_BUS_GET_CLASS(bus);
> + DeviceState *proxy = DEVICE(qbus->parent);
> DPRINTF("%s: plug device.\n", qbus->name);
>
> + if (klass->set_transport_features != NULL) {
> + klass->set_transport_features(proxy);
> + }
> +
> if (klass->device_plugged != NULL) {
> klass->device_plugged(qbus->parent);
> }
> diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c
> index 8829eb0..f4e67a2 100644
> --- a/hw/virtio/virtio-mmio.c
> +++ b/hw/virtio/virtio-mmio.c
> @@ -23,6 +23,8 @@
> #include "hw/virtio/virtio.h"
> #include "qemu/host-utils.h"
> #include "hw/virtio/virtio-bus.h"
> +#include "hw/virtio/virtio-net.h"
> +#include "hw/virtio/virtio-blk.h"
>
> /* #define DEBUG_VIRTIO_MMIO */
>
> @@ -89,6 +91,49 @@ typedef struct {
> VirtioBusState bus;
> } VirtIOMMIOProxy;
>
> +/* supported features for virtio-net backend */
> +static Property virtio_net_transport_properties[] = {
> + DEFINE_VIRTIO_NET_FEATURES(VirtIOMMIOProxy, host_features),
> + DEFINE_PROP_END_OF_LIST(),
> +};
> +
> +/* supported features for virtio-blk backend */
> +static Property virtio_blk_transport_properties[] = {
> + DEFINE_VIRTIO_BLK_FEATURES(VirtIOMMIOProxy, host_features),
> + DEFINE_PROP_END_OF_LIST(),
> +};
> +
> +static struct {
> + const char *backend_name;
> + const Property *props;
> +} mmio_transport_backends[] = {
> + { TYPE_VIRTIO_NET, virtio_net_transport_properties },
> + { TYPE_VIRTIO_BLK, virtio_blk_transport_properties },
> + { NULL, NULL },
> +};
> +
> +
> +static void virtio_mmio_set_transport_features(DeviceState *d)
> +{
> + VirtIOMMIOProxy *proxy = VIRTIO_MMIO(d);
> + VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
> + int i;
> +
> + for (i = 0; mmio_transport_backends[i].backend_name != NULL; i++) {
> + if (object_dynamic_cast(OBJECT(vdev),
> + mmio_transport_backends[i].backend_name)) {
> + const Property *props = mmio_transport_backends[i].props;
> + for (; props->qtype == QTYPE_QBOOL && props->qtype != QTYPE_NONE;
> + props++) {
> + if (props->defval == true) {
> + proxy->host_features |= (1 << props->bitnr);
> + } else {
> + proxy->host_features &= ~(1 << props->bitnr);
> + }
> + }
> + }
> + }
> +}
> static void virtio_mmio_bus_new(VirtioBusState *bus, size_t bus_size,
> VirtIOMMIOProxy *dev);
>
> @@ -408,6 +453,7 @@ static void virtio_mmio_bus_class_init(ObjectClass *klass, void *data)
> k->load_config = virtio_mmio_load_config;
> k->get_features = virtio_mmio_get_features;
> k->device_plugged = virtio_mmio_device_plugged;
> + k->set_transport_features = virtio_mmio_set_transport_features;
> k->has_variable_vring_alignment = true;
> bus_class->max_dev = 1;
> }
> diff --git a/include/hw/virtio/virtio-bus.h b/include/hw/virtio/virtio-bus.h
> index 0756545..3136fc6 100644
> --- a/include/hw/virtio/virtio-bus.h
> +++ b/include/hw/virtio/virtio-bus.h
> @@ -62,6 +62,10 @@ typedef struct VirtioBusClass {
> * This is called by virtio-bus just before the device is unplugged.
> */
> void (*device_unplugged)(DeviceState *d);
> + /* Call before plugging a backend into transport to set features supported
> + * by the backend.
> + */
> + void (*set_transport_features)(DeviceState *d);
> /*
> * Does the transport have variable vring alignment?
> * (ie can it ever call virtio_queue_set_align()?)
>
next prev parent reply other threads:[~2014-02-28 0:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <530E8A15.7010407@samsung.com>
2014-02-27 1:22 ` [Qemu-devel] [PATCH] virtio: set virtio-mmio transport features for various backends Mario Smarduch
2014-02-28 0:37 ` Mario Smarduch [this message]
2014-03-10 16:42 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=530FDA3E.3060002@samsung.com \
--to=m.smarduch@samsung.com \
--cc=aliguori@amazon.com \
--cc=fred.konrad@greensocs.com \
--cc=mst@redhat.com \
--cc=patches@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.