diff options
-rw-r--r-- | sys/dev/pci/pci_pci.c | 33 | ||||
-rw-r--r-- | sys/dev/pci/pcib_if.m | 25 | ||||
-rw-r--r-- | sys/dev/pci/pcib_private.h | 2 | ||||
-rw-r--r-- | sys/dev/pci/pcib_support.c | 10 | ||||
-rw-r--r-- | sys/dev/pci/pcireg.h | 4 |
5 files changed, 74 insertions, 0 deletions
diff --git a/sys/dev/pci/pci_pci.c b/sys/dev/pci/pci_pci.c index c7029f2..d0d8fb7 100644 --- a/sys/dev/pci/pci_pci.c +++ b/sys/dev/pci/pci_pci.c @@ -64,6 +64,9 @@ static void pcib_write_config(device_t dev, u_int b, u_int s, static int pcib_ari_maxslots(device_t dev); static int pcib_ari_maxfuncs(device_t dev); static int pcib_try_enable_ari(device_t pcib, device_t dev); +static int pcib_ari_enabled(device_t pcib); +static void pcib_ari_decode_rid(device_t pcib, uint16_t rid, + int *bus, int *slot, int *func); static device_method_t pcib_methods[] = { /* Device interface */ @@ -104,6 +107,8 @@ static device_method_t pcib_methods[] = { DEVMETHOD(pcib_power_for_sleep, pcib_power_for_sleep), DEVMETHOD(pcib_get_rid, pcib_ari_get_rid), DEVMETHOD(pcib_try_enable_ari, pcib_try_enable_ari), + DEVMETHOD(pcib_ari_enabled, pcib_ari_enabled), + DEVMETHOD(pcib_decode_rid, pcib_ari_decode_rid), DEVMETHOD_END }; @@ -1883,6 +1888,24 @@ pcib_ari_maxfuncs(device_t dev) return (PCI_FUNCMAX); } +static void +pcib_ari_decode_rid(device_t pcib, uint16_t rid, int *bus, int *slot, + int *func) +{ + struct pcib_softc *sc; + + sc = device_get_softc(pcib); + + *bus = PCI_RID2BUS(rid); + if (sc->flags & PCIB_ENABLE_ARI) { + *slot = PCIE_ARI_RID2SLOT(rid); + *func = PCIE_ARI_RID2FUNC(rid); + } else { + *slot = PCI_RID2SLOT(rid); + *func = PCI_RID2FUNC(rid); + } +} + /* * Since we are a child of a PCI bus, its parent must support the pcib interface. */ @@ -2014,6 +2037,16 @@ pcib_power_for_sleep(device_t pcib, device_t dev, int *pstate) return (PCIB_POWER_FOR_SLEEP(bus, dev, pstate)); } +static int +pcib_ari_enabled(device_t pcib) +{ + struct pcib_softc *sc; + + sc = device_get_softc(pcib); + + return ((sc->flags & PCIB_ENABLE_ARI) != 0); +} + static uint16_t pcib_ari_get_rid(device_t pcib, device_t dev) { diff --git a/sys/dev/pci/pcib_if.m b/sys/dev/pci/pcib_if.m index 0d7cf16..7c23ddc 100644 --- a/sys/dev/pci/pcib_if.m +++ b/sys/dev/pci/pcib_if.m @@ -39,6 +39,13 @@ CODE { { return (PCI_INVALID_IRQ); } + + static int + pcib_null_ari_enabled(device_t pcib) + { + + return (0); + } }; # @@ -182,3 +189,21 @@ METHOD int try_enable_ari { device_t dev; }; +# +# Return non-zero if PCI ARI is enabled, or zero otherwise +# +METHOD int ari_enabled { + device_t pcib; +} DEFAULT pcib_null_ari_enabled; + +# +# Decode a PCI Routing Identifier (RID) into PCI bus/slot/function +# +METHOD void decode_rid { + device_t pcib; + uint16_t rid; + int *bus; + int *slot; + int *func; +} DEFAULT pcib_decode_rid; + diff --git a/sys/dev/pci/pcib_private.h b/sys/dev/pci/pcib_private.h index cbc2b85..d8d82b6 100644 --- a/sys/dev/pci/pcib_private.h +++ b/sys/dev/pci/pcib_private.h @@ -170,5 +170,7 @@ int pcib_alloc_msix(device_t pcib, device_t dev, int *irq); int pcib_release_msix(device_t pcib, device_t dev, int irq); int pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr, uint32_t *data); uint16_t pcib_get_rid(device_t pcib, device_t dev); +void pcib_decode_rid(device_t pcib, uint16_t rid, int *bus, + int *slot, int *func); #endif diff --git a/sys/dev/pci/pcib_support.c b/sys/dev/pci/pcib_support.c index 647dd22..ef88a60 100644 --- a/sys/dev/pci/pcib_support.c +++ b/sys/dev/pci/pcib_support.c @@ -66,3 +66,13 @@ pcib_get_rid(device_t pcib, device_t dev) return (PCI_RID(bus, slot, func)); } +void +pcib_decode_rid(device_t pcib, uint16_t rid, int *bus, int *slot, + int *func) +{ + + *bus = PCI_RID2BUS(rid); + *slot = PCI_RID2SLOT(rid); + *func = PCI_RID2FUNC(rid); +} + diff --git a/sys/dev/pci/pcireg.h b/sys/dev/pci/pcireg.h index 73ce5e9..788e4e6 100644 --- a/sys/dev/pci/pcireg.h +++ b/sys/dev/pci/pcireg.h @@ -68,6 +68,10 @@ #define PCI_RID2SLOT(rid) (((rid) >> PCI_RID_SLOT_SHIFT) & PCI_SLOTMAX) #define PCI_RID2FUNC(rid) (((rid) >> PCI_RID_FUNC_SHIFT) & PCI_FUNCMAX) +#define PCIE_ARI_RID2SLOT(rid) (0) +#define PCIE_ARI_RID2FUNC(rid) \ + (((rid) >> PCI_RID_FUNC_SHIFT) & PCIE_ARI_FUNCMAX) + #define PCIE_ARI_SLOT(func) (((func) >> PCI_RID_SLOT_SHIFT) & PCI_SLOTMAX) #define PCIE_ARI_FUNC(func) (((func) >> PCI_RID_FUNC_SHIFT) & PCI_FUNCMAX) |