summaryrefslogtreecommitdiff
path: root/usr.sbin/pcidump
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2013-08-30 06:46:40 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2013-08-30 06:46:40 +0000
commit4ea8d55b8d205ebc0da9bff47f8ff3076bc6077a (patch)
tree8378605f66b068836690035141e5838c16cb4764 /usr.sbin/pcidump
parent9d7280b0d73818146fbb579a7e73fdbc2f3ca022 (diff)
use version two of the PCIe capability when displaying link speeds
ok mpi@
Diffstat (limited to 'usr.sbin/pcidump')
-rw-r--r--usr.sbin/pcidump/pcidump.c44
1 files changed, 25 insertions, 19 deletions
diff --git a/usr.sbin/pcidump/pcidump.c b/usr.sbin/pcidump/pcidump.c
index faa3a065292..9716227cafa 100644
--- a/usr.sbin/pcidump/pcidump.c
+++ b/usr.sbin/pcidump/pcidump.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pcidump.c,v 1.33 2013/06/15 19:45:03 kettenis Exp $ */
+/* $OpenBSD: pcidump.c,v 1.34 2013/08/30 06:46:39 jsg Exp $ */
/*
* Copyright (c) 2006, 2007 David Gwynne <loki@animata.net>
@@ -282,42 +282,48 @@ probe(int bus, int dev, int func)
void
print_pcie_ls(uint8_t speed)
{
- switch (speed) {
- case 1:
- printf("2.5");
- break;
- case 2:
- printf("5.0");
- break;
- case 3:
+ if (speed & 4)
printf("8.0");
- break;
- default:
+ else if (speed & 2)
+ printf("5.0");
+ else if (speed & 1)
+ printf("2.5");
+ else
printf("unknown (%d)", speed);
- }
}
void
dump_pcie_linkspeed(int bus, int dev, int func, uint8_t ptr)
{
- u_int32_t creg, sreg;
+ u_int32_t lcap, sreg, lcap2 = 0, xcap;
u_int8_t cap, cwidth, cspeed, swidth, sspeed;
- if (pci_read(bus, dev, func, ptr + PCI_PCIE_LCAP, &creg) != 0)
+ if (pci_read(bus, dev, func, ptr + PCI_PCIE_XCAP, &xcap) != 0)
return;
+ if (PCI_PCIE_XCAP_VER(xcap) >= 2) {
+ if (pci_read(bus, dev, func, ptr + PCI_PCIE_LCAP2, &lcap2) != 0)
+ lcap2 = 0;
+ else
+ cspeed = (lcap2 & 0x0e) >> 1;
+ }
+
+ if (pci_read(bus, dev, func, ptr + PCI_PCIE_LCAP, &lcap) != 0)
+ return;
+ if (lcap2 == 0)
+ cspeed = lcap & 0x0f;
+
if (pci_read(bus, dev, func, ptr + PCI_PCIE_LCSR, &sreg) != 0)
return;
sreg = sreg >> 16;
- cwidth = (creg >> 4) & 0x3f;
- swidth = (sreg >> 4) & 0x3f;
- cspeed = creg & 0x0f;
- sspeed = sreg & 0x0f;
-
+ cwidth = (lcap >> 4) & 0x3f;
if (cwidth == 0)
return;
+ swidth = (sreg >> 4) & 0x3f;
+ sspeed = sreg & 0x0f;
+
printf("\t Link Speed: ");
print_pcie_ls(sspeed);
printf(" / ");