xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: Paul Durrant <paul.durrant@citrix.com>
Cc: xen-devel@lists.xen.org, Ian Jackson <ian.jackson@eu.citrix.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: Re: [PATCH v9 1/3] ioreq-server: add support for multiple servers
Date: Thu, 22 May 2014 10:17:53 +0100	[thread overview]
Message-ID: <537DDCE10200007800014D37@mail.emea.novell.com> (raw)
In-Reply-To: <1400602092-4957-2-git-send-email-paul.durrant@citrix.com>

>>> On 20.05.14 at 18:08, <paul.durrant@citrix.com> wrote:
> +static struct hvm_ioreq_server *hvm_select_ioreq_server(struct domain *d,
> +                                                        ioreq_t *p)
> +{
> +#define CF8_BDF(cf8)     (((cf8) & 0x00ffff00) >> 8)
> +#define CF8_ADDR_LO(cf8) ((cf8) & 0x000000fc)
> +#define CF8_ADDR_HI(cf8) (((cf8) & 0x0f000000) >> 16)
> +#define CF8_ENABLED(cf8) (!!((cf8) & 0x80000000))
> +
> +    struct hvm_ioreq_server *s;
> +    uint32_t cf8;
> +    uint8_t type;
> +    uint64_t addr;
> +
> +    if ( list_empty(&d->arch.hvm_domain.ioreq_server.list) )
> +        return NULL;
> +
> +    if ( list_is_singular(&d->arch.hvm_domain.ioreq_server.list) ||
> +         (p->type != IOREQ_TYPE_COPY && p->type != IOREQ_TYPE_PIO) )
> +        return d->arch.hvm_domain.default_ioreq_server;
> +
> +    cf8 = d->arch.hvm_domain.pci_cf8;
> +
> +    if ( p->type == IOREQ_TYPE_PIO &&
> +         (p->addr & ~3) == 0xcfc &&
> +         CF8_ENABLED(cf8) )
> +    {
> +        uint32_t sbdf;
> +
> +        /* PCI config data cycle */
> +
> +        sbdf = HVMOP_PCI_SBDF(0,
> +                              PCI_BUS(CF8_BDF(cf8)),
> +                              PCI_SLOT(CF8_BDF(cf8)),
> +                              PCI_FUNC(CF8_BDF(cf8)));
> +
> +        type = IOREQ_TYPE_PCI_CONFIG;
> +        addr = ((uint64_t)sbdf << 32) |
> +               CF8_ADDR_HI(cf8) |
> +               CF8_ADDR_LO(cf8) |
> +               (p->addr & 3);
> +    }
> +    else
> +    {
> +        type = p->type;
> +        addr = p->addr;
> +    }
> +
> +    list_for_each_entry ( s,
> +                          &d->arch.hvm_domain.ioreq_server.list,
> +                          list_entry )
> +    {
> +        struct rangeset *r;
> +
> +        if ( s == d->arch.hvm_domain.default_ioreq_server )
> +            continue;
> +
> +        BUILD_BUG_ON(IOREQ_TYPE_PIO != HVMOP_IO_RANGE_PORT);
> +        BUILD_BUG_ON(IOREQ_TYPE_COPY != HVMOP_IO_RANGE_MEMORY);
> +        BUILD_BUG_ON(IOREQ_TYPE_PCI_CONFIG != HVMOP_IO_RANGE_PCI);
> +        r = s->range[type];
> +
> +        switch ( type )
> +        {
> +        case IOREQ_TYPE_PIO: {
> +            unsigned long end = addr + p->size - 1;
> +
> +            if ( rangeset_contains_range(r, addr, end) )
> +                return s;
> +
> +            break;
> +        }
> +        case IOREQ_TYPE_COPY: {
> +            unsigned long end = addr + (p->size * p->count) - 1;
> +
> +            if ( rangeset_contains_range(r, addr, end) )
> +                return s;
> +
> +            break;
> +        }

I was about to say "coding style" again (due to the misplaced opening
braces), but then I started wondering whether both "end" variables
are warranted here in the first place. And if they are, I would think
you might better declare just one instance in the scope of the switch(),
avoiding the need for the braces.

> +struct xen_hvm_get_ioreq_server_info {
> +    domid_t domid;               /* IN - domain to be serviced */
> +    ioservid_t id;               /* IN - server id */
> +    evtchn_port_t bufioreq_port; /* OUT - buffered ioreq port */
> +    xen_pfn_t ioreq_pfn;         /* OUT - sync ioreq pfn */
> +    xen_pfn_t bufioreq_pfn;      /* OUT - buffered ioreq pfn */
> +};

I'm sorry for not having paid attention to this earlier, but HVM ops
should have all their interface structures laid out identically for
64- and 32-bit guests - see other uses of uint64_aligned_t in
this header.

Jan

  reply	other threads:[~2014-05-22  9:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-20 16:08 [PATCH v9 0/3] Support for running secondary emulators Paul Durrant
2014-05-20 16:08 ` [PATCH v9 1/3] ioreq-server: add support for multiple servers Paul Durrant
2014-05-22  9:17   ` Jan Beulich [this message]
2014-05-22 10:10     ` Paul Durrant
2014-05-20 16:08 ` [PATCH v9 2/3] ioreq-server: remove p2m entries when server is enabled Paul Durrant
2014-05-20 16:08 ` [PATCH v9 3/3] ioreq-server: make buffered ioreq handling optional Paul Durrant

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=537DDCE10200007800014D37@mail.emea.novell.com \
    --to=jbeulich@suse.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=paul.durrant@citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xen.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).