All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Thomas Huth <thuth@redhat.com>
Cc: Laurent Vivier <lvivier@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	qemu-devel@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH v2 7/7] libqos: add VIRTIO PCI 1.0 support
Date: Thu, 17 Oct 2019 17:07:35 +0100	[thread overview]
Message-ID: <20191017160735.GB1266@stefanha-x1.localdomain> (raw)
In-Reply-To: <e7821640-de44-5e65-b9c1-2534dc676690@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2580 bytes --]

On Thu, Oct 17, 2019 at 04:52:54PM +0200, Thomas Huth wrote:
> On 11/10/2019 10.56, Stefan Hajnoczi wrote:
> > Implement the VIRTIO 1.0 virtio-pci interface.  The main change here is
> > that the register layout is no longer a fixed layout in BAR 0.  Instead
> > we have to iterate of PCI Capabilities to find descriptions of where
> > various registers are located.  The vring registers are also more
> > fine-grained, allowing for more flexible vring layouts, but we don't
> > take advantage of that.
> > 
> > Note that test cases do not negotiate VIRTIO_F_VERSION_1 yet and are
> > therefore not running in VIRTIO 1.0 mode.
> > 
> > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> > ---
> >  tests/Makefile.include           |   1 +
> >  tests/libqos/virtio-pci-modern.h |  17 ++
> >  tests/libqos/virtio-pci.h        |  10 +
> >  tests/libqos/virtio-pci-modern.c | 412 +++++++++++++++++++++++++++++++
> >  tests/libqos/virtio-pci.c        |   6 +-
> >  5 files changed, 445 insertions(+), 1 deletion(-)
> >  create mode 100644 tests/libqos/virtio-pci-modern.h
> >  create mode 100644 tests/libqos/virtio-pci-modern.c
> [...]
> > +static bool probe_device_type(QVirtioPCIDevice *dev)
> > +{
> > +    uint16_t vendor_id;
> > +    uint16_t device_id;
> > +
> > +    /* "Drivers MUST match devices with the PCI Vendor ID 0x1AF4" */
> > +    vendor_id = qpci_config_readw(dev->pdev, PCI_VENDOR_ID);
> > +    if (vendor_id != 0x1af4) {
> > +        return false;
> > +    }
> > +
> > +    /*
> > +     * "Any PCI device with ... PCI Device ID 0x1000 through 0x107F inclusive
> > +     * is a virtio device"
> > +     */
> > +    device_id = qpci_config_readw(dev->pdev, PCI_DEVICE_ID);
> > +    if (device_id < 0x1000 || device_id > 0x107f) {
> > +        return false;
> > +    }
> > +
> > +    /*
> > +     * "Devices MAY utilize a Transitional PCI Device ID range, 0x1000 to
> > +     * 0x103F depending on the device type"
> > +     */
> > +    if (device_id < 0x1040) {
> > +        /*
> > +         * "Transitional devices MUST have the PCI Subsystem Device ID matching
> > +         * the Virtio Device ID"
> > +         */
> > +        dev->vdev.device_type = qpci_config_readw(dev->pdev, PCI_SUBSYSTEM_ID);
> 
> Shouldn't you return "false" here in case the device_type is 0 ? Which
> likely means that it is a legacy or broken device ...?

The real decision whether to use this PCI device or not happens in
probe_device_layout().  If it's broken or a legacy device then that
function will fail.

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2019-10-17 16:57 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-11  8:56 [PATCH v2 0/7] libqos: add VIRTIO PCI 1.0 support Stefan Hajnoczi
2019-10-11  8:56 ` [PATCH v2 1/7] libqos: extract Legacy virtio-pci.c code Stefan Hajnoczi
2019-10-11 12:20   ` Sergio Lopez
2019-10-16 12:04   ` Thomas Huth
2019-10-11  8:56 ` [PATCH v2 2/7] libqos: add iteration support to qpci_find_capability() Stefan Hajnoczi
2019-10-11 12:22   ` Sergio Lopez
2019-10-16 12:12   ` Thomas Huth
2019-10-11  8:56 ` [PATCH v2 3/7] libqos: pass full QVirtQueue to set_queue_address() Stefan Hajnoczi
2019-10-11 12:22   ` Sergio Lopez
2019-10-16 12:15   ` Thomas Huth
2019-10-11  8:56 ` [PATCH v2 4/7] libqos: add MSI-X callbacks to QVirtioPCIDevice Stefan Hajnoczi
2019-10-11 12:23   ` Sergio Lopez
2019-10-17 13:25   ` Thomas Huth
2019-10-11  8:56 ` [PATCH v2 5/7] libqos: expose common virtqueue setup/cleanup functions Stefan Hajnoczi
2019-10-11 12:23   ` Sergio Lopez
2019-10-17 14:13   ` Thomas Huth
2019-10-11  8:56 ` [PATCH v2 6/7] libqos: make the virtio-pci BAR index configurable Stefan Hajnoczi
2019-10-11 12:06   ` Sergio Lopez
2019-10-14  9:52     ` Stefan Hajnoczi
2019-10-14 10:46       ` Sergio Lopez
2019-10-17 14:27   ` Thomas Huth
2019-10-11  8:56 ` [PATCH v2 7/7] libqos: add VIRTIO PCI 1.0 support Stefan Hajnoczi
2019-10-11 12:24   ` Sergio Lopez
2019-10-17 14:52   ` Thomas Huth
2019-10-17 16:07     ` Stefan Hajnoczi [this message]
2019-10-17 16:18       ` Thomas Huth
2019-10-18  6:48         ` Thomas Huth
2019-10-18  6:51           ` Thomas Huth
2019-10-18 10:05           ` Stefan Hajnoczi

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=20191017160735.GB1266@stefanha-x1.localdomain \
    --to=stefanha@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /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.