]> mj.ucw.cz Git - pciutils.git/blob - ls-caps-vendor.c
Add virtio vendor capability support
[pciutils.git] / ls-caps-vendor.c
1 /*
2  *      The PCI Utilities -- Show Vendor-specific Capabilities
3  *
4  *      Copyright (c) 2014 Gerd Hoffmann <kraxel@redhat.com>
5  *
6  *      Can be freely distributed and used under the terms of the GNU GPL.
7  */
8
9 #include <stdio.h>
10 #include <string.h>
11
12 #include "lspci.h"
13
14 static void
15 show_vendor_caps_virtio(struct device *d, int where, int cap)
16 {
17   int length = BITS(cap, 0, 8);
18   int type = BITS(cap, 8, 8);
19   char *tname;
20
21   if (length < 16)
22     return;
23   if (!config_fetch(d, where, length))
24     return;
25
26   switch (type)
27     {
28     case 1:
29       tname = "CommonCfg";
30       break;
31     case 2:
32       tname = "Notify";
33       break;
34     case 3:
35       tname = "ISR";
36       break;
37     case 4:
38       tname = "DeviceCfg";
39       break;
40     default:
41       tname = "<unknown>";
42       break;
43     }
44
45   printf("VirtIO: %s\n", tname);
46
47   if (verbose < 2)
48     return;
49
50   printf("\t\tBAR=%d offset=%08x size=%08x\n",
51          get_conf_byte(d, where +  4),
52          get_conf_long(d, where +  8),
53          get_conf_long(d, where + 12));
54
55   if (type != 2 || length < 20)
56     return;
57
58   printf("\t\tmultiplier=%08x\n",
59          get_conf_long(d, where+16));
60 }
61
62 void
63 show_vendor_caps(struct device *d, int where, int cap)
64 {
65   switch (get_conf_word(d, PCI_VENDOR_ID))
66     {
67     case 0x1af4: /* Red Hat */
68       if (get_conf_word(d, PCI_DEVICE_ID) >= 0x1000 &&
69           get_conf_word(d, PCI_DEVICE_ID) <= 0x107f)
70         show_vendor_caps_virtio(d, where, cap);
71       break;
72     default:
73       printf("Vendor Specific Information: Len=%02x <?>\n", BITS(cap, 0, 8));
74       break;
75     }
76 }