add virtio vendor capability support
Subsystems (2)
PATCH 1/1 add virtio vendor capability support
virtio uses vendor-specific capabilities to specify the location of the virtio register ranges. The specification can be found here:
http://docs.oasis-open.org/virtio/virtio/v1.0/cs01/virtio-v1.0-cs01.html#x1-690004
This patch adds support for decoding these capabilities to lspci.
--- Makefile | 2 +- ls-caps-vendor.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ls-caps.c | 9 ++++++++- lspci.h | 4 ++++ 4 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 ls-caps-vendor.c
Makefile +1 -1
@@ -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)
ls-caps-vendor.c new file +59 -0
59 lines not on this page · raw message
ls-caps.c +8 -1
@@ -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);
lspci.h +4 -0
@@ -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);
Signature · 1 line
1.8.3.1
Hello!
Quoted 6 lines
virtio uses vendor-specific capabilities to specify the location of the virtio register ranges. The specification can be found here:
http://docs.oasis-open.org/virtio/virtio/v1.0/cs01/virtio-v1.0-cs01.html#x1-690004
This patch adds support for decoding these capabilities to lspci.
I like the patch, except for a couple of details:
(1) Please follow the coding style of the rest of pciutils.
(2) You assume that PCI_CAP_ID_VNDR of all Redhat devices contains virtio, but the comment nearby refers to a range of device IDs only.
(3) Moving code related to vendor-defined caps to a separate file sounds good, but I think we should push the boundary a bit further: let the main switch in ls-caps.c call a function from ls-caps-vendor.c as soon as it finds PCI_CAP_ID_VENDOR, leaving all decisions based on vendor/device ID to this function.
Could you please fix these and resubmit?
Have a nice fortnight
Signature · 3 lines
Martin `MJ' Mares <[email protected]> http://mj.ucw.cz/ Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth VI has two modes: the one in which it beeps and the one in which it doesn't.
Quoted 5 lines · Martin Mares
Hello!
Quoted 3 lines
virtio uses vendor-specific capabilities to specify the location of the virtio register ranges. The specification can be found here:
Quoted 7 lines
Quoted 3 lines
http://docs.oasis-open.org/virtio/virtio/v1.0/cs01/virtio-v1.0-cs01.html#x1-690004
This patch adds support for decoding these capabilities to lspci.
I like the patch, except for a couple of details:
(1) Please follow the coding style of the rest of pciutils.
I've tried. What specifically doesn't match?
Quoted 2 lines
(2) You assume that
PCI_CAP_ID_VNDRof all Redhat devices contains virtio, but the comment nearby refers to a range of device IDs only.
I'll add a check. Doesn't matter today, there are no other redhat devices with vendor caps, so I was a bit lazy. But who knows what happens in the future ...
Quoted 5 lines
(3) Moving code related to vendor-defined caps to a separate file sounds good, but I think we should push the boundary a bit further: let the main switch in
ls-caps.ccall a function fromls-caps-vendor.cas soon as it findsPCI_CAP_ID_VENDOR, leaving all decisions based on vendor/device ID to this function.
Makes sense indeed, will do.
cheers,
Gerd
Hi!
Quoted 3 lines
Quoted 1 line
(1) Please follow the coding style of the rest of pciutils.
I've tried. What specifically doesn't match?
Positions of braces (e.g., after switch). But if you fix the other things, I can re-indent the source myself.
Martin