mirror of
https://github.com/opnsense/src.git
synced 2026-06-04 14:26:03 -04:00
Add some pcib methods to get ARI-related information
Differential Revision: https://reviews.freebsd.org/D72 Reviewed by: jhb MFC after: 1 month Sponsored by: Sandvine Inc.
This commit is contained in:
parent
5ce88dc6da
commit
2397d2d817
5 changed files with 74 additions and 0 deletions
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue