src/dpdk/drivers/net/bnx2x/bnx2x.c
static void bnx2x_probe_pci_caps(struct bnx2x_softc *sc)
{
	PMD_INIT_FUNC_TRACE(sc);

	struct bnx2x_pci_cap *caps;
	uint16_t link_status;
	int reg = 0;

	/* check if PCI Power Management is enabled */
	caps = pci_find_cap(sc, PCIY_PMG, BNX2X_PCI_CAP);
	if (NULL != caps) {
		PMD_DRV_LOG(DEBUG, sc, "Found PM capability: "
			    "id=0x%04X type=0x%04X addr=0x%08X",
			    caps->id, caps->type, caps->addr);

		sc->devinfo.pcie_cap_flags |= BNX2X_PM_CAPABLE_FLAG;
		sc->devinfo.pcie_pm_cap_reg = caps->addr;
	}

	link_status = bnx2x_pcie_capability_read(sc, PCIR_EXPRESS_LINK_STA);

	sc->devinfo.pcie_link_speed = (link_status & PCIM_LINK_STA_SPEED);
	sc->devinfo.pcie_link_width =
	    ((link_status & PCIM_LINK_STA_WIDTH) >> 4);

	PMD_DRV_LOG(DEBUG, sc, "PCIe link speed=%d width=%d",
		    sc->devinfo.pcie_link_speed, sc->devinfo.pcie_link_width);

	sc->devinfo.pcie_cap_flags |= BNX2X_PCIE_CAPABLE_FLAG;

	/* check if MSI capability is enabled */
	caps = pci_find_cap(sc, PCIY_MSI, BNX2X_PCI_CAP);
	if (NULL != caps) {
		PMD_DRV_LOG(DEBUG, sc, "Found MSI capability at 0x%04x", reg);

		sc->devinfo.pcie_cap_flags |= BNX2X_MSI_CAPABLE_FLAG;
		sc->devinfo.pcie_msi_cap_reg = caps->addr;
	}

	/* check if MSI-X capability is enabled */
	caps = pci_find_cap(sc, PCIY_MSIX, BNX2X_PCI_CAP);
	if (NULL != caps) {
		PMD_DRV_LOG(DEBUG, sc, "Found MSI-X capability at 0x%04x", reg);

		sc->devinfo.pcie_cap_flags |= BNX2X_MSIX_CAPABLE_FLAG;
		sc->devinfo.pcie_msix_cap_reg = caps->addr;
	}
}
/*
* 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 bnx2x_probe_pci_caps(struct bnx2x_softc *sc)
{
	PMD_INIT_FUNC_TRACE(sc);
	struct bnx2x_pci_cap *caps;
	uint16_t link_status;
	int reg = 0;
	caps = pci_find_cap(sc, PCIY_PMG, BNX2X_PCI_CAP);
	if (NULL != caps) {
		PMD_DRV_LOG(DEBUG, sc, "Found PM capability: "
			    "id=0x%04X type=0x%04X addr=0x%08X",
			    caps->id, caps->type, caps->addr);
		sc->devinfo.pcie_cap_flags |= BNX2X_PM_CAPABLE_FLAG;
		sc->devinfo.pcie_pm_cap_reg = caps->addr;
	}
	link_status = bnx2x_pcie_capability_read(sc, PCIR_EXPRESS_LINK_STA);
	sc->devinfo.pcie_link_speed = (link_status & PCIM_LINK_STA_SPEED);
	sc->devinfo.pcie_link_width =
	    ((link_status & PCIM_LINK_STA_WIDTH) >> 4);
	PMD_DRV_LOG(DEBUG, sc, "PCIe link speed=%d width=%d",
		    sc->devinfo.pcie_link_speed, sc->devinfo.pcie_link_width);
	sc->devinfo.pcie_cap_flags |= BNX2X_PCIE_CAPABLE_FLAG;
	caps = pci_find_cap(sc, PCIY_MSI, BNX2X_PCI_CAP);
	if (NULL != caps) {
		PMD_DRV_LOG(DEBUG, sc, "Found MSI capability at 0x%04x", reg);
		sc->devinfo.pcie_cap_flags |= BNX2X_MSI_CAPABLE_FLAG;
		sc->devinfo.pcie_msi_cap_reg = caps->addr;
	}
	caps = pci_find_cap(sc, PCIY_MSIX, BNX2X_PCI_CAP);
	if (NULL != caps) {
		PMD_DRV_LOG(DEBUG, sc, "Found MSI-X capability at 0x%04x", reg);
		sc->devinfo.pcie_cap_flags |= BNX2X_MSIX_CAPABLE_FLAG;
		sc->devinfo.pcie_msix_cap_reg = caps->addr;
	}
}
static void bnx2x_probe_pci_caps ( struct bnx2x_softc * sc ) { PMD_INIT_FUNC_TRACE ( sc ) ; struct bnx2x_pci_cap * caps ; uint16_t link_status ; int reg = 0 ; caps = pci_find_cap ( sc , PCIY_PMG , BNX2X_PCI_CAP ) ; if ( NULL != caps ) { PMD_DRV_LOG ( DEBUG , sc , " " " " , caps -> id , caps -> type , caps -> addr ) ; sc -> devinfo . pcie_cap_flags |= BNX2X_PM_CAPABLE_FLAG ; sc -> devinfo . pcie_pm_cap_reg = caps -> addr ; } link_status = bnx2x_pcie_capability_read ( sc , PCIR_EXPRESS_LINK_STA ) ; sc -> devinfo . pcie_link_speed = ( link_status & PCIM_LINK_STA_SPEED ) ; sc -> devinfo . pcie_link_width = ( ( link_status & PCIM_LINK_STA_WIDTH ) >> 4 ) ; PMD_DRV_LOG ( DEBUG , sc , " " , sc -> devinfo . pcie_link_speed , sc -> devinfo . pcie_link_width ) ; sc -> devinfo . pcie_cap_flags |= BNX2X_PCIE_CAPABLE_FLAG ; caps = pci_find_cap ( sc , PCIY_MSI , BNX2X_PCI_CAP ) ; if ( NULL != caps ) { PMD_DRV_LOG ( DEBUG , sc , " " , reg ) ; sc -> devinfo . pcie_cap_flags |= BNX2X_MSI_CAPABLE_FLAG ; sc -> devinfo . pcie_msi_cap_reg = caps -> addr ; } caps = pci_find_cap ( sc , PCIY_MSIX , BNX2X_PCI_CAP ) ; if ( NULL != caps ) { PMD_DRV_LOG ( DEBUG , sc , " " , reg ) ; sc -> devinfo . pcie_cap_flags |= BNX2X_MSIX_CAPABLE_FLAG ; sc -> devinfo . pcie_msix_cap_reg = caps -> addr ; } }
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 */ /* check if MSI capability is enabled */ /* check if MSI-X capability is enabled */