Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci - Print PCIe 2.0 or higher capability registers.



details:   https://anonhg.NetBSD.org/src/rev/3cb13a647bd8
branches:  trunk
changeset: 786249:3cb13a647bd8
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Sun Apr 21 23:54:44 2013 +0000

description:
- Print PCIe 2.0 or higher capability registers.
- Print Link related registers only if the device is PCI Express Endpoint,
  Legacy PCI Express Endpoint or Root Port of PCI Express Root Complex.
- Don't print Root related registers if the device is Root Complex
  Integrated Endpoint and print if the device is Root Complex Event Collector.
- Not Gb/s but GT/s.

diffstat:

 sys/dev/pci/pci_subr.c |  378 +++++++++++++++++++++++++++++++++++-------------
 1 files changed, 276 insertions(+), 102 deletions(-)

diffs (truncated from 462 to 300 lines):

diff -r c9ab9fedf82d -r 3cb13a647bd8 sys/dev/pci/pci_subr.c
--- a/sys/dev/pci/pci_subr.c    Sun Apr 21 23:46:06 2013 +0000
+++ b/sys/dev/pci/pci_subr.c    Sun Apr 21 23:54:44 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pci_subr.c,v 1.104 2013/04/21 23:46:06 msaitoh Exp $   */
+/*     $NetBSD: pci_subr.c,v 1.105 2013/04/21 23:54:44 msaitoh Exp $   */
 
 /*
  * Copyright (c) 1997 Zubin D. Dittia.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.104 2013/04/21 23:46:06 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.105 2013/04/21 23:54:44 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -857,32 +857,64 @@
 }
 
 static void
+pci_print_pcie_compl_timeout(uint32_t val)
+{
+
+       switch (val) {
+       case 0x0:
+               printf("50us to 50ms\n");
+               break;
+       case 0x5:
+               printf("16ms to 55ms\n");
+               break;
+       case 0x6:
+               printf("65ms to 210ms\n");
+               break;
+       case 0x9:
+               printf("260ms to 900ms\n");
+               break;
+       case 0xa:
+               printf("1s to 3.5s\n");
+               break;
+       default:
+               printf("unknown %u value\n", val);
+               break;
+       }
+}
+
+static void
 pci_conf_print_pcie_cap(const pcireg_t *regs, int capoff)
 {
        pcireg_t reg; /* for each register */
        pcireg_t val; /* for each bitfield */
+       bool check_link = false;
        bool check_slot = false;
        bool check_rootport = false;
+       unsigned int pciever;
        static const char * const linkspeeds[] = {"2.5", "5.0", "8.0"};
+       int i;
 
        printf("\n  PCI Express Capabilities Register\n");
        /* Capability Register */
        reg = regs[o2i(capoff)];
        printf("    Capability register: %04x\n", reg >> 16);
-       printf("      Capability version: %x\n",
-           (unsigned int)((reg & 0x000f0000) >> 16));
+       pciever = (unsigned int)((reg & 0x000f0000) >> 16);
+       printf("      Capability version: %u\n", pciever);
        printf("      Device type: ");
        switch ((reg & 0x00f00000) >> 20) {
        case 0x0:
                printf("PCI Express Endpoint device\n");
+               check_link = true;
                break;
        case 0x1:
                printf("Legacy PCI Express Endpoint device\n");
+               check_link = true;
                break;
        case 0x4:
                printf("Root Port of PCI Express Root Complex\n");
+               check_link = true;
                check_slot = true;
-               check_rootport = true; /* XXX right? */
+               check_rootport = true;
                break;
        case 0x5:
                printf("Upstream Port of PCI Express Switch\n");
@@ -890,7 +922,7 @@
        case 0x6:
                printf("Downstream Port of PCI Express Switch\n");
                check_slot = true;
-               check_rootport = true; /* XXX right? */
+               check_rootport = true;
                break;
        case 0x7:
                printf("PCI Express to PCI/PCI-X Bridge\n");
@@ -900,9 +932,9 @@
                break;
        case 0x9:
                printf("Root Complex Integrated Endpoint\n");
-               check_rootport = true; /* XXX right? */
                break;
        case 0xa:
+               check_rootport = true;
                printf("Root Complex Event Collector\n");
                break;
        default:
@@ -997,103 +1029,104 @@
        printf("      Transaction Pending: %s\n",
            (reg & PCIE_DCSR_TRANSACTION_PND) != 0 ? "on" : "off");
 
-       /* Link Capability Register */
-       reg = regs[o2i(capoff + PCIE_LCAP)];
-       printf("    Link Capabilities Register: 0x%08x\n", reg);
-       printf("      Maximum Link Speed: ");
-       val = reg & PCIE_LCAP_MAX_SPEED;
-       if (val < 1 || val > 3) {
-               printf("unknown %u value\n", val);
-       } else {
-               printf("%sGb/s\n", linkspeeds[val - 1]);
-       }
-       printf("      Maximum Link Width: x%u lanes\n",
-           (unsigned int)(reg & PCIE_LCAP_MAX_WIDTH) >> 4);
-       printf("      Active State PM Support: ");
-       val = (reg & PCIE_LCAP_ASPM) >> 10;
-       switch (val) {
-       case 0x1:
-               printf("L0s Entry supported\n");
-               break;
-       case 0x3:
-               printf("L0s and L1 supported\n");
-               break;
-       default:
-               printf("Reserved value\n");
-               break;
-       }
-       printf("      L0 Exit Latency: ");
-       pci_print_pcie_L0s_latency((reg & PCIE_LCAP_L0S_EXIT) >> 12);
-       printf("      L1 Exit Latency: ");
-       pci_print_pcie_L1_latency((reg & PCIE_LCAP_L1_EXIT) >> 15);
-       printf("      Port Number: %u\n", reg >> 24);
+       if (check_link) {
+               /* Link Capability Register */
+               reg = regs[o2i(capoff + PCIE_LCAP)];
+               printf("    Link Capabilities Register: 0x%08x\n", reg);
+               printf("      Maximum Link Speed: ");
+               val = reg & PCIE_LCAP_MAX_SPEED;
+               if (val < 1 || val > 3) {
+                       printf("unknown %u value\n", val);
+               } else {
+                       printf("%sGT/s\n", linkspeeds[val - 1]);
+               }
+               printf("      Maximum Link Width: x%u lanes\n",
+                   (unsigned int)(reg & PCIE_LCAP_MAX_WIDTH) >> 4);
+               printf("      Active State PM Support: ");
+               val = (reg & PCIE_LCAP_ASPM) >> 10;
+               switch (val) {
+               case 0x1:
+                       printf("L0s Entry supported\n");
+                       break;
+               case 0x3:
+                       printf("L0s and L1 supported\n");
+                       break;
+               default:
+                       printf("Reserved value\n");
+                       break;
+               }
+               printf("      L0 Exit Latency: ");
+               pci_print_pcie_L0s_latency((reg & PCIE_LCAP_L0S_EXIT) >> 12);
+               printf("      L1 Exit Latency: ");
+               pci_print_pcie_L1_latency((reg & PCIE_LCAP_L1_EXIT) >> 15);
+               printf("      Port Number: %u\n", reg >> 24);
 
-       /* Link Control Register */
-       reg = regs[o2i(capoff + PCIE_LCSR)];
-       printf("    Link Control Register: 0x%04x\n", reg & 0xffff);
-       printf("      Active State PM Control: ");
-       val = reg & (PCIE_LCSR_ASPM_L1 | PCIE_LCSR_ASPM_L0S);
-       switch (val) {
-       case 0:
-               printf("disabled\n");
-               break;
-       case 1:
-               printf("L0s Entry Enabled\n");
-               break;
-       case 2:
-               printf("L1 Entry Enabled\n");
-               break;
-       case 3:
-               printf("L0s and L1 Entry Enabled\n");
-               break;
+               /* Link Control Register */
+               reg = regs[o2i(capoff + PCIE_LCSR)];
+               printf("    Link Control Register: 0x%04x\n", reg & 0xffff);
+               printf("      Active State PM Control: ");
+               val = reg & (PCIE_LCSR_ASPM_L1 | PCIE_LCSR_ASPM_L0S);
+               switch (val) {
+               case 0:
+                       printf("disabled\n");
+                       break;
+               case 1:
+                       printf("L0s Entry Enabled\n");
+                       break;
+               case 2:
+                       printf("L1 Entry Enabled\n");
+                       break;
+               case 3:
+                       printf("L0s and L1 Entry Enabled\n");
+                       break;
+               }
+               printf("      Read Completion Boundary Control: %dbyte\n",
+                   (reg & PCIE_LCSR_RCB) != 0 ? 128 : 64);
+               printf("      Link Disable: %s\n",
+                   (reg & PCIE_LCSR_LINK_DIS) != 0 ? "on" : "off");
+               printf("      Retrain Link: %s\n",
+                   (reg & PCIE_LCSR_RETRAIN) != 0 ? "on" : "off");
+               printf("      Common Clock Configuration: %s\n",
+                   (reg & PCIE_LCSR_COMCLKCFG) != 0 ? "on" : "off");
+               printf("      Extended Synch: %s\n",
+                   (reg & PCIE_LCSR_EXTNDSYNC) != 0 ? "on" : "off");
+               printf("      Enable Clock Power Management: %s\n",
+                   (reg & PCIE_LCSR_ENCLKPM) != 0 ? "on" : "off");
+               printf("      Hardware Autonomous Width Disable: %s\n",
+                   (reg & PCIE_LCSR_HAWD) != 0 ? "on" : "off");
+               printf("      Link Bandwidth Management Interrupt Enable: %s\n",
+                   (reg & PCIE_LCSR_LBMIE) != 0 ? "on" : "off");
+               printf("      Link Autonomous Bandwidth Interrupt Enable: %s\n",
+                   (reg & PCIE_LCSR_LABIE) != 0 ? "on" : "off");
+
+               /* Link Status Register */
+               reg = regs[o2i(capoff + PCIE_LCSR)];
+               printf("    Link Status Register: 0x%04x\n", reg >> 16);
+               printf("      Negotiated Link Speed: ");
+               if (((reg >> 16) & 0x000f) < 1 ||
+                   ((reg >> 16) & 0x000f) > 3) {
+                       printf("unknown %u value\n",
+                           (unsigned int)(reg & PCIE_LCSR_LINKSPEED) >> 16);
+               } else {
+                       printf("%sGb/s\n",
+                           linkspeeds[((reg & PCIE_LCSR_LINKSPEED) >> 16) - 1]);
+               }
+               printf("      Negotiated Link Width: x%u lanes\n",
+                   (reg >> 20) & 0x003f);
+               printf("      Training Error: %s\n",
+                   (reg & PCIE_LCSR_LINKTRAIN_ERR) != 0 ? "on" : "off");
+               printf("      Link Training: %s\n",
+                   (reg & PCIE_LCSR_LINKTRAIN) != 0 ? "on" : "off");
+               printf("      Slot Clock Configuration: %s\n",
+                   (reg & PCIE_LCSR_SLOTCLKCFG) != 0 ? "on" : "off");
+               printf("      Data Link Layer Link Active: %s\n",
+                   (reg & PCIE_LCSR_DLACTIVE) != 0 ? "on" : "off");
+               printf("      Link Bandwidth Management Status: %s\n",
+                   (reg & PCIE_LCSR_LINK_BW_MGMT) != 0 ? "on" : "off");
+               printf("      Link Autonomous Bandwidth Status: %s\n",
+                   (reg & PCIE_LCSR_LINK_AUTO_BW) != 0 ? "on" : "off");
        }
-       printf("      Read Completion Boundary Control: %dbyte\n",
-           (reg & PCIE_LCSR_RCB) != 0 ? 128 : 64);
-       printf("      Link Disable: %s\n",
-           (reg & PCIE_LCSR_LINK_DIS) != 0 ? "on" : "off");
-       printf("      Retrain Link: %s\n",
-           (reg & PCIE_LCSR_RETRAIN) != 0 ? "on" : "off");
-       printf("      Common Clock Configuration: %s\n",
-           (reg & PCIE_LCSR_COMCLKCFG) != 0 ? "on" : "off");
-       printf("      Extended Synch: %s\n",
-           (reg & PCIE_LCSR_EXTNDSYNC) != 0 ? "on" : "off");
-       printf("      Enable Clock Power Management: %s\n",
-           (reg & PCIE_LCSR_ENCLKPM) != 0 ? "on" : "off");
-       printf("      Hardware Autonomous Width Disable: %s\n",
-           (reg & PCIE_LCSR_HAWD) != 0 ? "on" : "off");
-       printf("      Link Bandwidth Management Interrupt Enable: %s\n",
-           (reg & PCIE_LCSR_LBMIE) != 0 ? "on" : "off");
-       printf("      Link Autonomous Bandwidth Interrupt Enable: %s\n",
-           (reg & PCIE_LCSR_LABIE) != 0 ? "on" : "off");
 
-       /* Link Status Register */
-       reg = regs[o2i(capoff + PCIE_LCSR)];
-       printf("    Link Status Register: 0x%04x\n", reg >> 16);
-       printf("      Negotiated Link Speed: ");
-       if (((reg >> 16) & 0x000f) < 1 ||
-           ((reg >> 16) & 0x000f) > 3) {
-               printf("unknown %u value\n",
-                   (unsigned int)(reg & PCIE_LCSR_LINKSPEED) >> 16);
-       } else {
-               printf("%sGb/s\n",
-                   linkspeeds[((reg & PCIE_LCSR_LINKSPEED) >> 16) - 1]);
-       }
-       printf("      Negotiated Link Width: x%u lanes\n",
-           (reg >> 20) & 0x003f);
-       printf("      Training Error: %s\n",
-           (reg & PCIE_LCSR_LINKTRAIN_ERR) != 0 ? "on" : "off");
-       printf("      Link Training: %s\n",
-           (reg & PCIE_LCSR_LINKTRAIN) != 0 ? "on" : "off");
-       printf("      Slot Clock Configuration: %s\n",
-           (reg & PCIE_LCSR_SLOTCLKCFG) != 0 ? "on" : "off");
-       printf("      Data Link Layer Link Active: %s\n",
-           (reg & PCIE_LCSR_DLACTIVE) != 0 ? "on" : "off");
-       printf("      Link Bandwidth Management Status: %s\n",
-           (reg & PCIE_LCSR_LINK_BW_MGMT) != 0 ? "on" : "off");
-       printf("      Link Autonomous Bandwidth Status: %s\n",
-           (reg & PCIE_LCSR_LINK_AUTO_BW) != 0 ? "on" : "off");



Home | Main Index | Thread Index | Old Index