-/* $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>
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);
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)
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);