qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC v3 PATCH 19/45] multi-process: Add LSI device prox


From: Gerd Hoffmann
Subject: Re: [Qemu-devel] [RFC v3 PATCH 19/45] multi-process: Add LSI device proxy object
Date: Thu, 5 Sep 2019 12:22:34 +0200
User-agent: NeoMutt/20180716

  Hi,

> +static uint64_t proxy_lsi_io_read(void *opaque, hwaddr addr, unsigned size)
> +{
> +    ProxyLSIState *s = opaque;
> +
> +    return proxy_default_bar_read(PCI_PROXY_DEV(s), &s->io_io, addr, size,
> +                                  false);
> +}
> +
> +static void proxy_lsi_io_write(void *opaque, hwaddr addr, uint64_t val,
> +                               unsigned size)
> +{
> +    ProxyLSIState *s = opaque;
> +
> +    proxy_default_bar_write(PCI_PROXY_DEV(s), &s->io_io, addr, val, size,
> +                            false);
> +}
> +
> +static const MemoryRegionOps proxy_lsi_io_ops = {
> +    .read = proxy_lsi_io_read,
> +    .write = proxy_lsi_io_write,
> +    .endianness = DEVICE_NATIVE_ENDIAN,
> +    .impl = {
> +        .min_access_size = 1,
> +        .max_access_size = 1,
> +    },
> +};

Hmm, as more devices get proxy support there will be alot of simliar
boilerplate.

I think it would be useful to have a

struct pci_device_description {
        u16 vendor_id,
        u16 device_id,
        [ ... ]
        struct {
                [ ... ]
        } bar[6];
};

> +    proxy_class->realize = proxy_lsi_realize;
> +    proxy_class->command = g_strdup("qemu-scsi-dev");

Hook that up here (proxy_class->description = &lsi_description),
then have the pci proxy realize function setup everything.  All pci
bar access is just forwarded to the proxy, that should be doable
without duplicating the code for each proxied pci device ...

At least parts of the pci_device_description can probably also used for
non-proxy device setup (should work for pci config space, probably
would not work for memory regions as they are very device specific).

cheers,
  Gerd




reply via email to

[Prev in Thread] Current Thread [Next in Thread]