mirror of
https://github.com/openbsd/src.git
synced 2024-12-22 16:42:56 -08:00
use version two of the PCIe capability when displaying link speeds
ok mpi@
This commit is contained in:
parent
6cb982a7b3
commit
e1b2e8d405
@ -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(" / ");
|
||||
|
Loading…
Reference in New Issue
Block a user