summaryrefslogtreecommitdiffstats
path: root/ls-caps-vendor.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 18:30:56 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 18:30:56 +0000
commitd3114e0edc60508fc1e44e6cd2733fb2a97cdaca (patch)
tree82d66db664dea6ee75010455b98b04f47fcc4a90 /ls-caps-vendor.c
parentInitial commit. (diff)
downloadpciutils-d3114e0edc60508fc1e44e6cd2733fb2a97cdaca.tar.xz
pciutils-d3114e0edc60508fc1e44e6cd2733fb2a97cdaca.zip
Adding upstream version 1:3.11.1.upstream/1%3.11.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ls-caps-vendor.c')
-rw-r--r--ls-caps-vendor.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/ls-caps-vendor.c b/ls-caps-vendor.c
new file mode 100644
index 0000000..62ee586
--- /dev/null
+++ b/ls-caps-vendor.c
@@ -0,0 +1,84 @@
+/*
+ * The PCI Utilities -- Show Vendor-specific Capabilities
+ *
+ * Copyright (c) 2014 Gerd Hoffmann <kraxel@redhat.com>
+ *
+ * Can be freely distributed and used under the terms of the GNU GPL v2+.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include "lspci.h"
+
+static int
+show_vendor_caps_virtio(struct device *d, int where, int cap)
+{
+ int length = BITS(cap, 0, 8);
+ int type = BITS(cap, 8, 8);
+ char *tname;
+
+ if (length < 16)
+ return 0;
+ if (!config_fetch(d, where, length))
+ return 0;
+
+ switch (type)
+ {
+ case 1:
+ tname = "CommonCfg";
+ break;
+ case 2:
+ tname = "Notify";
+ break;
+ case 3:
+ tname = "ISR";
+ break;
+ case 4:
+ tname = "DeviceCfg";
+ break;
+ default:
+ tname = "<unknown>";
+ break;
+ }
+
+ printf("VirtIO: %s\n", tname);
+
+ if (verbose < 2)
+ return 1;
+
+ printf("\t\tBAR=%d offset=%08x size=%08x",
+ get_conf_byte(d, where + 4),
+ get_conf_long(d, where + 8),
+ get_conf_long(d, where + 12));
+
+ if (type == 2 && length >= 20)
+ printf(" multiplier=%08x", get_conf_long(d, where+16));
+
+ printf("\n");
+ return 1;
+}
+
+static int
+do_show_vendor_caps(struct device *d, int where, int cap)
+{
+ switch (d->dev->vendor_id)
+ {
+ case 0x1af4: /* Red Hat */
+ if (d->dev->device_id >= 0x1000 &&
+ d->dev->device_id <= 0x107f)
+ return show_vendor_caps_virtio(d, where, cap);
+ break;
+ }
+ return 0;
+}
+
+void
+show_vendor_caps(struct device *d, int where, int cap)
+{
+ printf("Vendor Specific Information: ");
+ if (!do_show_vendor_caps(d, where, cap))
+ printf("Len=%02x <?>\n", BITS(cap, 0, 8));
+}