]> mj.ucw.cz Git - pciutils.git/blob - ls-caps-vendor.c
CXL: Fix Flex Bus DVSEC cap
[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 int
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 0;
23   if (!config_fetch(d, where, length))
24     return 0;
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 1;
49
50   printf("\t\tBAR=%d offset=%08x size=%08x",
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     printf(" multiplier=%08x", get_conf_long(d, where+16));
57
58   printf("\n");
59   return 1;
60 }
61
62 static int
63 do_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         return show_vendor_caps_virtio(d, where, cap);
71       break;
72     }
73   return 0;
74 }
75
76 void
77 show_vendor_caps(struct device *d, int where, int cap)
78 {
79   printf("Vendor Specific Information: ");
80   if (!do_show_vendor_caps(d, where, cap))
81     printf("Len=%02x <?>\n", BITS(cap, 0, 8));
82 }