[Midnightbsd-cvs] src [8317] trunk/usr.sbin/pciconf/cap.c: print current and max link speed
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sat Sep 17 18:37:40 EDT 2016
Revision: 8317
http://svnweb.midnightbsd.org/src/?rev=8317
Author: laffer1
Date: 2016-09-17 18:37:39 -0400 (Sat, 17 Sep 2016)
Log Message:
-----------
print current and max link speed
Modified Paths:
--------------
trunk/usr.sbin/pciconf/cap.c
Modified: trunk/usr.sbin/pciconf/cap.c
===================================================================
--- trunk/usr.sbin/pciconf/cap.c 2016-09-17 22:35:21 UTC (rev 8316)
+++ trunk/usr.sbin/pciconf/cap.c 2016-09-17 22:37:39 UTC (rev 8317)
@@ -363,6 +363,22 @@
#define MAX_PAYLOAD(field) (128 << (field))
+static const char *
+link_speed_string(uint8_t speed)
+{
+
+ switch (speed) {
+ case 1:
+ return ("2.5");
+ case 2:
+ return ("5.0");
+ case 3:
+ return ("8.0");
+ default:
+ return ("undef");
+ }
+}
+
static void
cap_express(int fd, struct pci_conf *p, uint8_t ptr)
{
@@ -416,6 +432,16 @@
flags = read_config(fd, &p->pc_sel, ptr+ PCIER_LINK_STA, 2);
printf(" link x%d(x%d)", (flags & PCIEM_LINK_STA_WIDTH) >> 4,
(val & PCIEM_LINK_CAP_MAX_WIDTH) >> 4);
+ /*
+ * Only print link speed info if the link's max width is
+ * greater than 0.
+ */
+ if ((val & PCIEM_LINK_CAP_MAX_WIDTH) != 0) {
+ printf("\n speed");
+ printf(" %s(%s)", (flags & PCIEM_LINK_STA_WIDTH) == 0 ?
+ "0.0" : link_speed_string(flags & PCIEM_LINK_STA_SPEED),
+ link_speed_string(val & PCIEM_LINK_CAP_MAX_SPEED));
+ }
}
static void
More information about the Midnightbsd-cvs
mailing list