]> git.ipfire.org Git - thirdparty/pciutils.git/blob - ls-caps-vendor.c
ls-ecaps: extend decode support for more fields for AER CE and UE status
[thirdparty/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 v2+.
7 *
8 * SPDX-License-Identifier: GPL-2.0-or-later
9 */
10
11 #include <stdio.h>
12 #include <string.h>
13
14 #include "lspci.h"
15
16 static int
17 show_vendor_caps_virtio(struct device *d, int where, int cap)
18 {
19 int length = BITS(cap, 0, 8);
20 int type = BITS(cap, 8, 8);
21 char *tname;
22
23 if (length < 16)
24 return 0;
25 if (!config_fetch(d, where, length))
26 return 0;
27
28 switch (type)
29 {
30 case 1:
31 tname = "CommonCfg";
32 break;
33 case 2:
34 tname = "Notify";
35 break;
36 case 3:
37 tname = "ISR";
38 break;
39 case 4:
40 tname = "DeviceCfg";
41 break;
42 default:
43 tname = "<unknown>";
44 break;
45 }
46
47 printf("VirtIO: %s\n", tname);
48
49 if (verbose < 2)
50 return 1;
51
52 printf("\t\tBAR=%d offset=%08x size=%08x",
53 get_conf_byte(d, where + 4),
54 get_conf_long(d, where + 8),
55 get_conf_long(d, where + 12));
56
57 if (type == 2 && length >= 20)
58 printf(" multiplier=%08x", get_conf_long(d, where+16));
59
60 printf("\n");
61 return 1;
62 }
63
64 static int
65 do_show_vendor_caps(struct device *d, int where, int cap)
66 {
67 switch (d->dev->vendor_id)
68 {
69 case 0x1af4: /* Red Hat */
70 if (d->dev->device_id >= 0x1000 &&
71 d->dev->device_id <= 0x107f)
72 return show_vendor_caps_virtio(d, where, cap);
73 break;
74 }
75 return 0;
76 }
77
78 void
79 show_vendor_caps(struct device *d, int where, int cap)
80 {
81 printf("Vendor Specific Information: ");
82 if (!do_show_vendor_caps(d, where, cap))
83 printf("Len=%02x <?>\n", BITS(cap, 0, 8));
84 }