]> git.ipfire.org Git - thirdparty/pciutils.git/blame - 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
CommitLineData
7ff8a323
GH
1/*
2 * The PCI Utilities -- Show Vendor-specific Capabilities
3 *
4 * Copyright (c) 2014 Gerd Hoffmann <kraxel@redhat.com>
5 *
61829219
MM
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
7ff8a323
GH
9 */
10
11#include <stdio.h>
12#include <string.h>
13
14#include "lspci.h"
15
6ebebbaa 16static int
7ff8a323
GH
17show_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)
6ebebbaa 24 return 0;
7ff8a323 25 if (!config_fetch(d, where, length))
6ebebbaa 26 return 0;
7ff8a323
GH
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)
6ebebbaa 50 return 1;
7ff8a323 51
6ebebbaa 52 printf("\t\tBAR=%d offset=%08x size=%08x",
7ff8a323
GH
53 get_conf_byte(d, where + 4),
54 get_conf_long(d, where + 8),
55 get_conf_long(d, where + 12));
56
6ebebbaa
MM
57 if (type == 2 && length >= 20)
58 printf(" multiplier=%08x", get_conf_long(d, where+16));
7ff8a323 59
6ebebbaa
MM
60 printf("\n");
61 return 1;
7ff8a323
GH
62}
63
6ebebbaa
MM
64static int
65do_show_vendor_caps(struct device *d, int where, int cap)
7ff8a323 66{
adf7de0e 67 switch (d->dev->vendor_id)
7ff8a323
GH
68 {
69 case 0x1af4: /* Red Hat */
adf7de0e
DE
70 if (d->dev->device_id >= 0x1000 &&
71 d->dev->device_id <= 0x107f)
6ebebbaa 72 return show_vendor_caps_virtio(d, where, cap);
7ff8a323
GH
73 break;
74 }
6ebebbaa
MM
75 return 0;
76}
77
78void
79show_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));
7ff8a323 84}