FreeBSD/sys/dev/pci/pci_pci.c
/*
 * Check that the downstream port (pcib) and the endpoint device (dev) both
 * support ARI.  If so, enable it and return 0, otherwise return an error.
 */
Check that the downstream port (pcib) and the endpoint device (dev) both
support ARI.  If so, enable it and return 0, otherwise return an error.
Check that the downstream port ( pcib ) and the endpoint device ( dev ) both support ARI . If so enable it and return 0 otherwise return an error .
static int
pcib_try_enable_ari(device_t pcib, device_t dev)
{
	struct pcib_softc *sc;
	int error;
	uint32_t cap2;
	int ari_cap_off;
	uint32_t ari_ver;
	uint32_t pcie_pos;
	sc = device_get_softc(pcib);
	error = pci_find_cap(pcib, PCIY_EXPRESS, &pcie_pos);
	if (error != 0)
		return (ENODEV);
	cap2 = pci_read_config(pcib, pcie_pos + PCIER_DEVICE_CAP2, 4);
	if (!(cap2 & PCIEM_CAP2_ARI))
		return (ENODEV);
	error = pci_find_extcap(dev, PCIZ_ARI, &ari_cap_off);
	if (error != 0)
		return (ENODEV);
	ari_ver = pci_read_config(dev, ari_cap_off, 4);
	if (PCI_EXTCAP_VER(ari_ver) != PCIB_SUPPORTED_ARI_VER) {
		if (bootverbose)
			device_printf(pcib,
			    "Unsupported version of ARI (%d) detected\n",
			    PCI_EXTCAP_VER(ari_ver));
		return (ENXIO);
	}
	pcib_enable_ari(sc, pcie_pos);
	return (0);
}
static int pcib_try_enable_ari ( device_t pcib , device_t dev ) { struct pcib_softc * sc ; int error ; uint32_t cap2 ; int ari_cap_off ; uint32_t ari_ver ; uint32_t pcie_pos ; sc = device_get_softc ( pcib ) ; error = pci_find_cap ( pcib , PCIY_EXPRESS , & pcie_pos ) ; if ( error != 0 ) return ( ENODEV ) ; cap2 = pci_read_config ( pcib , pcie_pos + PCIER_DEVICE_CAP2 , 4 ) ; if ( ! ( cap2 & PCIEM_CAP2_ARI ) ) return ( ENODEV ) ; error = pci_find_extcap ( dev , PCIZ_ARI , & ari_cap_off ) ; if ( error != 0 ) return ( ENODEV ) ; ari_ver = pci_read_config ( dev , ari_cap_off , 4 ) ; if ( PCI_EXTCAP_VER ( ari_ver ) != PCIB_SUPPORTED_ARI_VER ) { if ( bootverbose ) device_printf ( pcib , " \n " , PCI_EXTCAP_VER ( ari_ver ) ) ; return ( ENXIO ) ; } pcib_enable_ari ( sc , pcie_pos ) ; return ( 0 ) ; }
Check that the downstream port (pcib) and the endpoint device (dev) both
 support ARI.
Check that the downstream port ( pcib ) and the endpoint device ( dev ) both support ARI .
/*
	 * ARI is controlled in a register in the PCIe capability structure.
	 * If the downstream port does not have the PCIe capability structure
	 * then it does not support ARI.
	 */ /* Check that the PCIe port advertises ARI support. */ /*
	 * Check that the endpoint device advertises ARI support via the ARI
	 * extended capability structure.
	 */ /*
	 * Finally, check that the endpoint device supports the same version
	 * of ARI that we do.
	 */