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 Data Select and Data Scale in pci_conf_p...



details:   https://anonhg.NetBSD.org/src/rev/67082b42dc15
branches:  trunk
changeset: 821727:67082b42dc15
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Wed Feb 15 06:53:55 2017 +0000

description:
- Print Data Select and Data Scale in pci_conf_print_pcipm_cap().
- The Message Data register of MSI cap is not 32bit but 16bit.
- When the PCIE_LCAP_MAX_SPEED bitfiled is 0, it means it supports 2.5GT/s only.
- Print link de-emphasis value by "-X dB".
- Print Completion Timeout Ranges Supported filed with alphabets.
- Print TPH Completer Supported fileld's meaning.
- Print PCIE_DCAP2_MAX_EETLP correctly. 0 means 4 End-End TLP Prefixes.
- If the Supported Link Speed Vector is 0, the Link Capability 2 register is not
  implemented. Don't decode LCAP2 when the vector is 0.
- The ACS's Egress Control Vector is 32bit, so print with 0x%08x.
- Print SR-IOV's device ID.
- Use __SHIFTOUT() to avoid using magic number.
- Prefix "0x" for hexadecimal value.

diffstat:

 sys/dev/pci/pci_subr.c |  162 +++++++++++++++++++++++++++++++++---------------
 sys/dev/pci/pcireg.h   |    3 +-
 2 files changed, 113 insertions(+), 52 deletions(-)

diffs (truncated from 384 to 300 lines):

diff -r 2edd41edb85a -r 67082b42dc15 sys/dev/pci/pci_subr.c
--- a/sys/dev/pci/pci_subr.c    Wed Feb 15 02:55:53 2017 +0000
+++ b/sys/dev/pci/pci_subr.c    Wed Feb 15 06:53:55 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pci_subr.c,v 1.156 2016/12/28 06:57:27 msaitoh Exp $   */
+/*     $NetBSD: pci_subr.c,v 1.157 2017/02/15 06:53:55 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.156 2016/12/28 06:57:27 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.157 2017/02/15 06:53:55 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -1082,12 +1082,16 @@
        onoff("No soft reset", pmcsr, PCI_PMCSR_NO_SOFTRST);
        printf("      PME# assertion: %sabled\n",
            (pmcsr & PCI_PMCSR_PME_EN) ? "en" : "dis");
+       printf("      Data Select: %d\n",
+           __SHIFTOUT(pmcsr, PCI_PMCSR_DATASEL_MASK));
+       printf("      Data Scale: %d\n",
+           __SHIFTOUT(pmcsr, PCI_PMCSR_DATASCL_MASK));
        onoff("PME# status", pmcsr, PCI_PMCSR_PME_STS);
        printf("    Bridge Support Extensions register: 0x%02x\n",
            (reg >> 16) & 0xff);
        onoff("B2/B3 support", reg, PCI_PMCSR_B2B3_SUPPORT);
        onoff("Bus Power/Clock Control Enable", reg, PCI_PMCSR_BPCC_EN);
-       printf("    Data register: 0x%02x\n", (reg >> 24) & 0xff);
+       printf("    Data register: 0x%02x\n", __SHIFTOUT(reg, PCI_PMCSR_DATA));
        
 }
 
@@ -1122,7 +1126,8 @@
                printf("    Message Address %sregister: 0x%08x\n",
                    "(upper) ", *regs++);
        }
-       printf("    Message Data register: 0x%08x\n", *regs++);
+       printf("    Message Data register: 0x%04x\n", *regs & 0xffff);
+       regs++;
        if (ctl & PCI_MSI_CTL_PERVEC_MASK) {
                printf("    Vector Mask register: 0x%08x\n", *regs++);
                printf("    Vector Pending register: 0x%08x\n", *regs++);
@@ -1478,17 +1483,16 @@
        }
 }
 
-static const char * const pcie_linkspeeds[] = {"2.5", "5.0", "8.0"};
+static const char * const pcie_linkspeeds[] = {"2.5", "2.5", "5.0", "8.0"};
 
 static void
 pci_print_pcie_linkspeed(pcireg_t val)
 {
 
-       /* Start from 1 */
-       if (val < 1 || val > __arraycount(pcie_linkspeeds))
+       if (val > __arraycount(pcie_linkspeeds))
                printf("unknown value (%u)\n", val);
        else
-               printf("%sGT/s\n", pcie_linkspeeds[val - 1]);
+               printf("%sGT/s\n", pcie_linkspeeds[val]);
 }
 
 static void
@@ -1500,13 +1504,28 @@
        for (i = 0; i < 16; i++)
                if (((val >> i) & 0x01) != 0) {
                        if (i >= __arraycount(pcie_linkspeeds))
-                               printf(" unknown vector (%x)", 1 << i);
+                               printf(" unknown vector (0x%x)", 1 << i);
                        else
                                printf(" %sGT/s", pcie_linkspeeds[i]);
                }
 }
 
 static void
+pci_print_pcie_link_deemphasis(pcireg_t val)
+{
+       switch (val) {
+       case 0:
+               printf("-6dB");
+               break;
+       case 1:
+               printf("-3.5dB");
+               break;
+       default:
+               printf("(reserved value)");
+       }
+}
+
+static void
 pci_conf_print_pcie_cap(const pcireg_t *regs, int capoff)
 {
        pcireg_t reg; /* for each register */
@@ -1515,11 +1534,12 @@
        bool check_slot = false;
        bool check_rootport = false;
        unsigned int pciever;
+       unsigned int i;
 
        printf("\n  PCI Express Capabilities Register\n");
        /* Capability Register */
        reg = regs[o2i(capoff)];
-       printf("    Capability register: %04x\n", reg >> 16);
+       printf("    Capability register: 0x%04x\n", reg >> 16);
        pciever = (unsigned int)((reg & 0x000f0000) >> 16);
        printf("      Capability version: %u\n", pciever);
        printf("      Device type: ");
@@ -1564,7 +1584,7 @@
                break;
        }
        onoff("Slot implemented", reg, PCIE_XCAP_SI);
-       printf("      Interrupt Message Number: %x\n",
+       printf("      Interrupt Message Number: 0x%02x\n",
            (unsigned int)((reg & PCIE_XCAP_IRQ) >> 27));
 
        /* Device Capability Register */
@@ -1740,7 +1760,7 @@
        if (check_slot == true) {
                /* Slot Capability Register */
                reg = regs[o2i(capoff + PCIE_SLCAP)];
-               printf("    Slot Capability Register: %08x\n", reg);
+               printf("    Slot Capability Register: 0x%08x\n", reg);
                onoff("Attention Button Present", reg, PCIE_SLCAP_ABP);
                onoff("Power Controller Present", reg, PCIE_SLCAP_PCP);
                onoff("MRL Sensor Present", reg, PCIE_SLCAP_MSP);
@@ -1808,7 +1828,7 @@
                    PCIE_SLCSR_AUTOSPLDIS);
 
                /* Slot Status Register */
-               printf("    Slot Status Register: %04x\n", reg >> 16);
+               printf("    Slot Status Register: 0x%04x\n", reg >> 16);
                onoff("Attention Button Pressed", reg, PCIE_SLCSR_ABP);
                onoff("Power Fault Detected", reg, PCIE_SLCSR_PFD);
                onoff("MRL Sensor Changed", reg, PCIE_SLCSR_MSC);
@@ -1834,14 +1854,14 @@
                onoff("CRS Software Visibility Enable", reg, PCIE_RCR_CRS_SVE);
 
                /* Root Capability Register */
-               printf("    Root Capability Register: %04x\n",
+               printf("    Root Capability Register: 0x%04x\n",
                    reg >> 16);
                onoff("CRS Software Visibility", reg, PCIE_RCR_CRS_SV);
 
                /* Root Status Register */
                reg = regs[o2i(capoff + PCIE_RSR)];
-               printf("    Root Status Register: %08x\n", reg);
-               printf("      PME Requester ID: %04x\n",
+               printf("    Root Status Register: 0x%08x\n", reg);
+               printf("      PME Requester ID: 0x%04x\n",
                    (unsigned int)(reg & PCIE_RSR_PME_REQESTER));
                onoff("PME was asserted", reg, PCIE_RSR_PME_STAT);
                onoff("another PME is pending", reg, PCIE_RSR_PME_PEND);
@@ -1854,8 +1874,19 @@
        /* Device Capabilities 2 */
        reg = regs[o2i(capoff + PCIE_DCAP2)];
        printf("    Device Capabilities 2: 0x%08x\n", reg);
-       printf("      Completion Timeout Ranges Supported: %u \n",
-           (unsigned int)(reg & PCIE_DCAP2_COMPT_RANGE));
+       printf("      Completion Timeout Ranges Supported: ");
+       val = reg & PCIE_DCAP2_COMPT_RANGE;
+       switch (val) {
+       case 0:
+               printf("not supported\n");
+               break;
+       default:
+               for (i = 0; i <= 3; i++) {
+                       if (((val >> i) & 0x01) != 0)
+                               printf("%c", 'A' + i);
+               }
+               printf("\n");
+       }
        onoff("Completion Timeout Disable Supported", reg,
            PCIE_DCAP2_COMPT_DIS);
        onoff("ARI Forwarding Supported", reg, PCIE_DCAP2_ARI_FWD);
@@ -1865,8 +1896,22 @@
        onoff("128-bit CAS Completer Supported", reg, PCIE_DCAP2_128CAS);
        onoff("No RO-enabled PR-PR passing", reg, PCIE_DCAP2_NO_ROPR_PASS);
        onoff("LTR Mechanism Supported", reg, PCIE_DCAP2_LTR_MEC);
-       printf("      TPH Completer Supported: %u\n",
-           (unsigned int)(reg & PCIE_DCAP2_TPH_COMP) >> 12);
+       printf("      TPH Completer Supported: ");
+       switch (__SHIFTOUT(reg, PCIE_DCAP2_TPH_COMP)) {
+       case 0:
+               printf("Not supportted\n");
+               break;
+       case 1:
+               printf("TPH\n");
+               break;
+       case 3:
+               printf("TPH and Extended TPH\n");
+               break;
+       default:
+               printf("(reserved value)\n");
+               break;
+               
+       }
        printf("      LN System CLS: ");
        switch (__SHIFTOUT(reg, PCIE_DCAP2_LNSYSCLS)) {
        case 0x0:
@@ -1899,8 +1944,8 @@
        }
        onoff("Extended Fmt Field Supported", reg, PCIE_DCAP2_EXTFMT_FLD);
        onoff("End-End TLP Prefix Supported", reg, PCIE_DCAP2_EETLP_PREF);
-       printf("      Max End-End TLP Prefixes: %u\n",
-           (unsigned int)(reg & PCIE_DCAP2_MAX_EETLP) >> 22);
+       val = __SHIFTOUT(reg, PCIE_DCAP2_MAX_EETLP);
+       printf("      Max End-End TLP Prefixes: %u\n", (val == 0) ? 4 : val);
        printf("      Emergency Power Reduction Supported: ");
        switch (__SHIFTOUT(reg, PCIE_DCAP2_EMGPWRRED)) {
        case 0x0:
@@ -1952,26 +1997,31 @@
        onoff("End-End TLP Prefix Blocking on", reg, PCIE_DCSR2_EETLP);
 
        if (check_link) {
-               bool drs_supported;
+               bool drs_supported = false;
 
                /* Link Capability 2 */
                reg = regs[o2i(capoff + PCIE_LCAP2)];
-               printf("    Link Capabilities 2: 0x%08x\n", reg);
-               printf("      Supported Link Speed Vector:");
-               pci_print_pcie_linkspeedvector(
-                       __SHIFTOUT(reg, PCIE_LCAP2_SUP_LNKSV));
-               printf("\n");
-               onoff("Crosslink Supported", reg, PCIE_LCAP2_CROSSLNK);
-               printf("      Lower SKP OS Generation Supported Speed Vector:");
-               pci_print_pcie_linkspeedvector(
-                       __SHIFTOUT(reg, PCIE_LCAP2_LOWSKPOS_GENSUPPSV));
-               printf("\n");
-               printf("      Lower SKP OS Reception Supported Speed Vector:");
-               pci_print_pcie_linkspeedvector(
-                       __SHIFTOUT(reg, PCIE_LCAP2_LOWSKPOS_RECSUPPSV));
-               printf("\n");
-               onoff("DRS Supported", reg, PCIE_LCAP2_DRS);
-               drs_supported = (reg & PCIE_LCAP2_DRS) ? true : false;
+               /* If the vector is 0, LCAP2 is not implemented */
+               if ((reg & PCIE_LCAP2_SUP_LNKSV) != 0) {
+                       printf("    Link Capabilities 2: 0x%08x\n", reg);
+                       printf("      Supported Link Speeds Vector:");
+                       pci_print_pcie_linkspeedvector(
+                               __SHIFTOUT(reg, PCIE_LCAP2_SUP_LNKSV));
+                       printf("\n");
+                       onoff("Crosslink Supported", reg, PCIE_LCAP2_CROSSLNK);
+                       printf("      "
+                           "Lower SKP OS Generation Supported Speed Vector:");
+                       pci_print_pcie_linkspeedvector(
+                               __SHIFTOUT(reg, PCIE_LCAP2_LOWSKPOS_GENSUPPSV));
+                       printf("\n");
+                       printf("      "
+                           "Lower SKP OS Reception Supported Speed Vector:");
+                       pci_print_pcie_linkspeedvector(
+                               __SHIFTOUT(reg, PCIE_LCAP2_LOWSKPOS_RECSUPPSV));
+                       printf("\n");
+                       onoff("DRS Supported", reg, PCIE_LCAP2_DRS);
+                       drs_supported = (reg & PCIE_LCAP2_DRS) ? true : false;
+               }
 
                /* Link Control 2 */
                reg = regs[o2i(capoff + PCIE_LCSR2)];
@@ -1982,17 +2032,25 @@
                onoff("Enter Compliance Enabled", reg, PCIE_LCSR2_ENT_COMPL);
                onoff("HW Autonomous Speed Disabled", reg,
                    PCIE_LCSR2_HW_AS_DIS);
-               onoff("Selectable De-emphasis", reg, PCIE_LCSR2_SEL_DEEMP);
+               printf("      Selectable De-emphasis: ");
+               pci_print_pcie_link_deemphasis(
+                       __SHIFTOUT(reg, PCIE_LCSR2_SEL_DEEMP));
+               printf("\n");
                printf("      Transmit Margin: %u\n",
                    (unsigned int)(reg & PCIE_LCSR2_TX_MARGIN) >> 7);
                onoff("Enter Modified Compliance", reg, PCIE_LCSR2_EN_MCOMP);
                onoff("Compliance SOS", reg, PCIE_LCSR2_COMP_SOS);
-               printf("      Compliance Present/De-emphasis: %u\n",
-                   (unsigned int)(reg & PCIE_LCSR2_COMP_DEEMP) >> 12);
+               printf("      Compliance Present/De-emphasis: ");
+               pci_print_pcie_link_deemphasis(
+                       __SHIFTOUT(reg, PCIE_LCSR2_COMP_DEEMP));
+               printf("\n");
 
                /* Link Status 2 */
                printf("    Link Status 2: 0x%04x\n", (reg >> 16) & 0xffff);
-               onoff("Current De-emphasis Level", reg, PCIE_LCSR2_DEEMP_LVL);
+               printf("      Current De-emphasis Level: ");
+               pci_print_pcie_link_deemphasis(
+                       __SHIFTOUT(reg, PCIE_LCSR2_DEEMP_LVL));
+               printf("\n");
                onoff("Equalization Complete", reg, PCIE_LCSR2_EQ_COMPL);
                onoff("Equalization Phase 1 Successful", reg,
                    PCIE_LCSR2_EQP1_SUC);
@@ -2050,12 +2108,12 @@
        onoff("MSI-X Enable", reg, PCI_MSIX_CTL_ENABLE);
        reg = regs[o2i(capoff + PCI_MSIX_TBLOFFSET)];
        printf("    Table offset register: 0x%08x\n", reg);
-       printf("      Table offset: %08x\n",
+       printf("      Table offset: 0x%08x\n",
            (pcireg_t)(reg & PCI_MSIX_TBLOFFSET_MASK));



Home | Main Index | Thread Index | Old Index