FreeBSD/sys/dev/bxe/bxe.c
/*
 * Walk the PCI capabiites list for the device to find what features are
 * supported. These capabilites may be enabled/disabled by firmware so it's
 * best to walk the list rather than make assumptions.
 */
Walk the PCI capabiites list for the device to find what features are
supported. These capabilites may be enabled/disabled by firmware so it's
best to walk the list rather than make assumptions.
Walk the PCI capabiites list for the device to find what features are supported . These capabilites may be enabled / disabled by firmware so it ' s best to walk the list rather than make assumptions .
static void
bxe_probe_pci_caps(struct bxe_softc *sc)
{
    uint16_t link_status;
    int reg;
    if (pci_find_cap(sc->dev, PCIY_PMG, &reg) == 0) {
        if (reg != 0) {
            BLOGD(sc, DBG_LOAD, "Found PM capability at 0x%04x\n", reg);
            sc->devinfo.pcie_cap_flags |= BXE_PM_CAPABLE_FLAG;
            sc->devinfo.pcie_pm_cap_reg = (uint16_t)reg;
        }
    }
    link_status = bxe_pcie_capability_read(sc, PCIR_EXPRESS_LINK_STA, 2);
    if (CHIP_IS_E1(sc)) {
        sc->devinfo.pcie_link_speed =
            (REG_RD(sc, 0x3d04) & (1 << 24)) ? 2 : 1;
        sc->devinfo.pcie_link_width =
            ((link_status & PCIM_LINK_STA_WIDTH) >> 4);
        if (sc->devinfo.pcie_link_speed > 1) {
            sc->devinfo.pcie_link_width =
                ((link_status & PCIM_LINK_STA_WIDTH) >> 4) >> 1;
        }
    } else {
        sc->devinfo.pcie_link_speed =
            (link_status & PCIM_LINK_STA_SPEED);
        sc->devinfo.pcie_link_width =
            ((link_status & PCIM_LINK_STA_WIDTH) >> 4);
    }
    BLOGD(sc, DBG_LOAD, "PCIe link speed=%d width=%d\n",
          sc->devinfo.pcie_link_speed, sc->devinfo.pcie_link_width);
    sc->devinfo.pcie_cap_flags |= BXE_PCIE_CAPABLE_FLAG;
    sc->devinfo.pcie_pcie_cap_reg = (uint16_t)reg;
    if (pci_find_cap(sc->dev, PCIY_MSI, &reg) == 0) {
        if (reg != 0) {
            BLOGD(sc, DBG_LOAD, "Found MSI capability at 0x%04x\n", reg);
            sc->devinfo.pcie_cap_flags |= BXE_MSI_CAPABLE_FLAG;
            sc->devinfo.pcie_msi_cap_reg = (uint16_t)reg;
        }
    }
    if (pci_find_cap(sc->dev, PCIY_MSIX, &reg) == 0) {
        if (reg != 0) {
            BLOGD(sc, DBG_LOAD, "Found MSI-X capability at 0x%04x\n", reg);
            sc->devinfo.pcie_cap_flags |= BXE_MSIX_CAPABLE_FLAG;
            sc->devinfo.pcie_msix_cap_reg = (uint16_t)reg;
        }
    }
}
static void bxe_probe_pci_caps ( struct bxe_softc * sc ) { uint16_t link_status ; int reg ; if ( pci_find_cap ( sc -> dev , PCIY_PMG , & reg ) == 0 ) { if ( reg != 0 ) { BLOGD ( sc , DBG_LOAD , " \n " , reg ) ; sc -> devinfo . pcie_cap_flags |= BXE_PM_CAPABLE_FLAG ; sc -> devinfo . pcie_pm_cap_reg = ( uint16_t ) reg ; } } link_status = bxe_pcie_capability_read ( sc , PCIR_EXPRESS_LINK_STA , 2 ) ; if ( CHIP_IS_E1 ( sc ) ) { sc -> devinfo . pcie_link_speed = ( REG_RD ( sc , 0x3d04 ) & ( 1 << 24 ) ) ? 2 : 1 ; sc -> devinfo . pcie_link_width = ( ( link_status & PCIM_LINK_STA_WIDTH ) >> 4 ) ; if ( sc -> devinfo . pcie_link_speed > 1 ) { sc -> devinfo . pcie_link_width = ( ( link_status & PCIM_LINK_STA_WIDTH ) >> 4 ) >> 1 ; } } else { sc -> devinfo . pcie_link_speed = ( link_status & PCIM_LINK_STA_SPEED ) ; sc -> devinfo . pcie_link_width = ( ( link_status & PCIM_LINK_STA_WIDTH ) >> 4 ) ; } BLOGD ( sc , DBG_LOAD , " \n " , sc -> devinfo . pcie_link_speed , sc -> devinfo . pcie_link_width ) ; sc -> devinfo . pcie_cap_flags |= BXE_PCIE_CAPABLE_FLAG ; sc -> devinfo . pcie_pcie_cap_reg = ( uint16_t ) reg ; if ( pci_find_cap ( sc -> dev , PCIY_MSI , & reg ) == 0 ) { if ( reg != 0 ) { BLOGD ( sc , DBG_LOAD , " \n " , reg ) ; sc -> devinfo . pcie_cap_flags |= BXE_MSI_CAPABLE_FLAG ; sc -> devinfo . pcie_msi_cap_reg = ( uint16_t ) reg ; } } if ( pci_find_cap ( sc -> dev , PCIY_MSIX , & reg ) == 0 ) { if ( reg != 0 ) { BLOGD ( sc , DBG_LOAD , " \n " , reg ) ; sc -> devinfo . pcie_cap_flags |= BXE_MSIX_CAPABLE_FLAG ; sc -> devinfo . pcie_msix_cap_reg = ( uint16_t ) reg ; } } }
Walk the PCI capabiites list for the device to find what features are
 supported.
Walk the PCI capabiites list for the device to find what features are supported .
/* check if PCI Power Management is enabled */ /* handle PCIe 2.0 workarounds for 57710 */ /* workaround for 57710 errata E4_57710_27462 */ /* workaround for 57710 errata E4_57710_27488 */ /* check if MSI capability is enabled */ /* check if MSI-X capability is enabled */