diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2023-04-16 17:26:15 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2023-04-16 17:26:15 +0000 |
commit | c5f54d0b02dbfc5aff24ed35547292779679bb0a (patch) | |
tree | 3591ce73dc567d32b99bfed42951f41b52fe218e /usr.sbin/pcidump | |
parent | a59e102502086cdc43548233b2094441fbf894db (diff) |
Fix (and simplify) link speed reporting.
ok jsg@
Diffstat (limited to 'usr.sbin/pcidump')
-rw-r--r-- | usr.sbin/pcidump/pcidump.c | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/usr.sbin/pcidump/pcidump.c b/usr.sbin/pcidump/pcidump.c index 3148a8732ee..e5df1ef709f 100644 --- a/usr.sbin/pcidump/pcidump.c +++ b/usr.sbin/pcidump/pcidump.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pcidump.c,v 1.68 2021/10/25 19:54:29 kn Exp $ */ +/* $OpenBSD: pcidump.c,v 1.69 2023/04/16 17:26:14 kettenis Exp $ */ /* * Copyright (c) 2006, 2007 David Gwynne <loki@animata.net> @@ -528,11 +528,17 @@ pcie_dcsr_mrrs(uint32_t dcsr) void print_pcie_ls(uint8_t speed) { - if (speed & 4) + if (speed == 6) + printf("64.0"); + else if (speed == 5) + printf("32.0"); + else if (speed == 4) + printf("16.0"); + else if (speed == 3) printf("8.0"); - else if (speed & 2) + else if (speed == 2) printf("5.0"); - else if (speed & 1) + else if (speed == 1) printf("2.5"); else printf("unknown (%d)", speed); @@ -542,7 +548,7 @@ void dump_pcie_linkspeed(int bus, int dev, int func, uint8_t ptr) { u_int32_t dcap, dcsr; - u_int32_t lcap, sreg, lcap2 = 0, xcap; + u_int32_t lcap, lcsr; u_int8_t cwidth, cspeed, swidth, sspeed; if (pci_read(bus, dev, func, ptr + PCI_PCIE_DCAP, &dcap) != 0) @@ -556,31 +562,17 @@ dump_pcie_linkspeed(int bus, int dev, int func, uint8_t ptr) printf("\t\tMax Read Request Size: %u bytes\n", pcie_dcsr_mrrs(dcsr)); - 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; - + cspeed = lcap & 0x0f; cwidth = (lcap >> 4) & 0x3f; if (cwidth == 0) return; - swidth = (sreg >> 4) & 0x3f; - sspeed = sreg & 0x0f; + if (pci_read(bus, dev, func, ptr + PCI_PCIE_LCSR, &lcsr) != 0) + return; + sspeed = (lcsr >> 16) & 0x0f; + swidth = (lcsr >> 20) & 0x3f; printf("\t\tLink Speed: "); print_pcie_ls(sspeed); |