From: "Michael S. Tsirkin" <mst@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org
Subject: Re: [PATCH v3 00/16] virtio-pci: towards virtio 1.0 guest support
Date: Tue, 20 Jan 2015 00:11:24 +0200 [thread overview]
Message-ID: <20150119221124.GA18301@redhat.com> (raw)
In-Reply-To: <1421665620.3610.13.camel@nilsson.home.kraxel.org>
On Mon, Jan 19, 2015 at 12:07:00PM +0100, Gerd Hoffmann wrote:
> Hi,
>
> > BTW: is there a tool (or pciutils patch) which can decode the virtio
> > capabilities?
>
> Searched for a patch today, and all google found me was this mail asking
> for one :-o
>
> So I went ahead and coded one up. Attached.
>
> While hacking it up I've noticed spec doesn't match reality. The
> "Virtio Structure PCI Capabilities" section here ...
>
> http://docs.oasis-open.org/virtio/virtio/v1.0/cs01/virtio-v1.0-cs01.html#x1-690004
>
> ... doesn't match what qemu is doing. Huh?
Wow! And I made the same bug in the guest too.
Good catch, will fix both up.
>
> Also note:
>
> [root@fedora ~]# ~kraxel/projects/pciutils/lspci -vvsa
> 00:0a.0 Communication controller: Red Hat, Inc Virtio console
> [ ... ]
> Capabilities: [64] VirtIO: Notify
> BAR=2 offset=00003000 size=00400000
> multiplier=00010000
> [ ... ]
>
> Why multiplier is 64k instead of 4k? Just a tyops?
>
>
> cheers,
> Gerd
>
Just in case :) I'll make it smaller, will address your concerns
about BAR size in a simple way.
> >From 0d5d99c20b079c986128c3d98c4bbaba51ebe65c Mon Sep 17 00:00:00 2001
> From: Gerd Hoffmann <kraxel@redhat.com>
> Date: Mon, 19 Jan 2015 11:46:37 +0100
> Subject: [PATCH] add virtio vendor caps
>
> ---
> Makefile | 2 +-
> ls-caps-vendor.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> ls-caps.c | 9 ++++++++-
> lspci.h | 4 ++++
> 4 files changed, 70 insertions(+), 2 deletions(-)
> create mode 100644 ls-caps-vendor.c
>
> diff --git a/Makefile b/Makefile
> index 8d49afa..39a07d1 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -69,7 +69,7 @@ force:
> lib/config.h lib/config.mk:
> cd lib && ./configure
>
> -lspci: lspci.o ls-vpd.o ls-caps.o ls-ecaps.o ls-kernel.o ls-tree.o ls-map.o common.o lib/$(PCILIB)
> +lspci: lspci.o ls-vpd.o ls-caps.o ls-caps-vendor.o ls-ecaps.o ls-kernel.o ls-tree.o ls-map.o common.o lib/$(PCILIB)
> setpci: setpci.o common.o lib/$(PCILIB)
>
> LSPCIINC=lspci.h pciutils.h $(PCIINC)
> diff --git a/ls-caps-vendor.c b/ls-caps-vendor.c
> new file mode 100644
> index 0000000..5f8b3e1
> --- /dev/null
> +++ b/ls-caps-vendor.c
> @@ -0,0 +1,57 @@
> +/*
> + * The PCI Utilities -- Show Vendor-specific Capabilities
> + *
> + * Copyright (c) 2014 Gerd Hoffmann <kraxel@redhat.com>
> + *
> + * Can be freely distributed and used under the terms of the GNU GPL.
> + */
> +
> +#include <stdio.h>
> +#include <string.h>
> +
> +#include "lspci.h"
> +
> +void
> +show_vendor_caps_virtio(struct device *d, int where, int cap)
> +{
> + int length = BITS(cap, 0, 8);
> + int type = BITS(cap, 8, 5);
> + int bar = BITS(cap, 13, 3);
> + char *tname;
> +
> + if (length < 12)
> + return;
> + if (!config_fetch(d, where, length))
> + return;
> +
> + switch (type) {
> + case 1:
> + tname = "CommonCfg";
> + break;
> + case 2:
> + tname = "Notify";
> + break;
> + case 3:
> + tname = "ISR";
> + break;
> + case 4:
> + tname = "DeviceCfg";
> + break;
> + default:
> + tname = "<unknown>";
> + break;
> + }
> +
> + printf("VirtIO: %s\n", tname);
> +
> + if (verbose < 2)
> + return;
> +
> + printf("\t\tBAR=%d offset=%08x size=%08x\n", bar,
> + get_conf_long(d, where+4),
> + get_conf_long(d, where+8));
> + if (type != 2 || length < 16)
> + return;
> + printf("\t\tmultiplier=%08x\n",
> + get_conf_long(d, where+12));
> +}
> diff --git a/ls-caps.c b/ls-caps.c
> index 7de55ef..438b580 100644
> --- a/ls-caps.c
> +++ b/ls-caps.c
> @@ -1315,7 +1315,14 @@ show_caps(struct device *d, int where)
> cap_ht(d, where, cap);
> break;
> case PCI_CAP_ID_VNDR:
> - printf("Vendor Specific Information: Len=%02x <?>\n", BITS(cap, 0, 8));
> + switch (get_conf_word(d, PCI_VENDOR_ID)) {
> + case 0x1af4: /* Red Hat, devices 0x1000 -> 0x107f are virtio */
> + show_vendor_caps_virtio(d, where, cap);
> + break;
> + default:
> + printf("Vendor Specific Information: Len=%02x <?>\n", BITS(cap, 0, 8));
> + break;
> + }
> break;
> case PCI_CAP_ID_DBG:
> cap_debug_port(cap);
> diff --git a/lspci.h b/lspci.h
> index 86429b2..5ca9899 100644
> --- a/lspci.h
> +++ b/lspci.h
> @@ -70,6 +70,10 @@ void show_caps(struct device *d, int where);
>
> void show_ext_caps(struct device *d);
>
> +/* ls-caps-vendor.c */
> +
> +void show_vendor_caps_virtio(struct device *d, int where, int cap);
> +
> /* ls-kernel.c */
>
> void show_kernel_machine(struct device *d UNUSED);
> --
> 1.8.3.1
>
next prev parent reply other threads:[~2015-01-19 22:11 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-14 17:27 [PATCH v3 00/16] virtio-pci: towards virtio 1.0 guest support Michael S. Tsirkin
2015-01-14 17:27 ` [PATCH v3 01/16] virtio_pci: drop virtio_config dependency Michael S. Tsirkin
2015-01-14 17:27 ` [PATCH v3 02/16] virtio/9p: verify device has config space Michael S. Tsirkin
2015-01-14 17:27 ` [PATCH v3 03/16] virtio/blk: " Michael S. Tsirkin
2015-01-14 17:27 ` [PATCH v3 04/16] virtio/console: " Michael S. Tsirkin
2015-01-20 10:40 ` Amit Shah
2015-01-20 11:09 ` Michael S. Tsirkin
2015-01-21 6:14 ` Amit Shah
2015-01-21 6:44 ` Michael S. Tsirkin
2015-01-14 17:27 ` [PATCH v3 05/16] virtio/net: " Michael S. Tsirkin
2015-01-14 17:27 ` [PATCH v3 06/16] virtio/scsi: " Michael S. Tsirkin
2015-01-14 17:27 ` [PATCH v3 07/16] virtio/balloon: " Michael S. Tsirkin
2015-01-14 17:27 ` [PATCH v3 08/16] mn10300: drop dead code Michael S. Tsirkin
2015-01-23 23:08 ` Bjorn Helgaas
2015-01-14 17:27 ` [PATCH v3 09/16] pci: add pci_iomap_range Michael S. Tsirkin
2015-01-23 23:08 ` Bjorn Helgaas
2015-01-14 17:27 ` [PATCH v3 10/16] s390: " Michael S. Tsirkin
2015-01-16 10:11 ` Sebastian Ott
2015-01-21 0:43 ` Rusty Russell
2015-01-14 17:28 ` [PATCH v3 11/16] virtio_pci: move probe/remove code to common Michael S. Tsirkin
2015-01-14 17:28 ` [PATCH v3 12/16] virtio-pci: define layout for virtio 1.0 Michael S. Tsirkin
2015-01-14 17:28 ` [PATCH v3 13/16] virtio_pci: modern driver Michael S. Tsirkin
2015-01-14 17:28 ` [PATCH v3 14/16] virtio_pci: macros for PCI layout offsets Michael S. Tsirkin
2015-01-14 17:28 ` [PATCH v3 15/16] virtio_pci_modern: reduce number of mappings Michael S. Tsirkin
2015-01-14 17:28 ` [PATCH v3 16/16] virtio_pci_modern: support devices with no config Michael S. Tsirkin
2015-01-15 21:18 ` [PATCH v3 00/16] virtio-pci: towards virtio 1.0 guest support Gerd Hoffmann
2015-01-15 21:32 ` Michael S. Tsirkin
2015-01-16 8:32 ` Gerd Hoffmann
2015-01-16 8:45 ` Michael S. Tsirkin
2015-01-16 13:27 ` Gerd Hoffmann
2015-01-19 10:54 ` Gerd Hoffmann
2015-01-20 16:38 ` Michael S. Tsirkin
2015-01-19 11:07 ` Gerd Hoffmann
2015-01-19 22:11 ` Michael S. Tsirkin [this message]
2015-01-20 16:32 ` Michael S. Tsirkin
2015-01-21 11:31 ` Gerd Hoffmann
2015-01-21 11:36 ` Michael S. Tsirkin
2015-01-21 13:43 ` Gerd Hoffmann
2015-01-21 14:19 ` Michael S. Tsirkin
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=20150119221124.GA18301@redhat.com \
--to=mst@redhat.com \
--cc=kraxel@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.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).