pci: make MSI(-X) enable and disable methods of the PCI bus
Make the functions pci_disable_msi, pci_enable_msi and pci_enable_msix methods of the newbus PCI bus. This code should not include any functional change. Sponsored by: Citrix Systems R&D Reviewed by: imp, jhb Differential Revision: https://reviews.freebsd.org/D354 dev/pci/pci.c: - Convert the mentioned functions to newbus methods. - Fix the callers of the converted functions. sys/dev/pci/pci_private.h: dev/pci/pci_if.m: - Declare the new methods. dev/pci/pcivar.h: - Add helpers to call the newbus methods. ofed/include/linux/pci.h: - Add define to prevent the ofed version of pci_enable_msix from clashing with the FreeBSD native version.
This commit is contained in:
parent
5e8c3d974e
commit
073bf9dd70
@ -110,11 +110,6 @@ static int pci_write_vpd_reg(device_t pcib, pcicfgregs *cfg,
|
||||
int reg, uint32_t data);
|
||||
#endif
|
||||
static void pci_read_vpd(device_t pcib, pcicfgregs *cfg);
|
||||
static void pci_disable_msi(device_t dev);
|
||||
static void pci_enable_msi(device_t dev, uint64_t address,
|
||||
uint16_t data);
|
||||
static void pci_enable_msix(device_t dev, u_int index,
|
||||
uint64_t address, uint32_t data);
|
||||
static void pci_mask_msix(device_t dev, u_int index);
|
||||
static void pci_unmask_msix(device_t dev, u_int index);
|
||||
static int pci_msi_blacklisted(void);
|
||||
@ -180,6 +175,9 @@ static device_method_t pci_methods[] = {
|
||||
DEVMETHOD(pci_find_htcap, pci_find_htcap_method),
|
||||
DEVMETHOD(pci_alloc_msi, pci_alloc_msi_method),
|
||||
DEVMETHOD(pci_alloc_msix, pci_alloc_msix_method),
|
||||
DEVMETHOD(pci_enable_msi, pci_enable_msi_method),
|
||||
DEVMETHOD(pci_enable_msix, pci_enable_msix_method),
|
||||
DEVMETHOD(pci_disable_msi, pci_disable_msi_method),
|
||||
DEVMETHOD(pci_remap_msix, pci_remap_msix_method),
|
||||
DEVMETHOD(pci_release_msi, pci_release_msi_method),
|
||||
DEVMETHOD(pci_msi_count, pci_msi_count_method),
|
||||
@ -1343,9 +1341,10 @@ pci_find_extcap_method(device_t dev, device_t child, int capability,
|
||||
* Support for MSI-X message interrupts.
|
||||
*/
|
||||
void
|
||||
pci_enable_msix(device_t dev, u_int index, uint64_t address, uint32_t data)
|
||||
pci_enable_msix_method(device_t dev, device_t child, u_int index,
|
||||
uint64_t address, uint32_t data)
|
||||
{
|
||||
struct pci_devinfo *dinfo = device_get_ivars(dev);
|
||||
struct pci_devinfo *dinfo = device_get_ivars(child);
|
||||
struct pcicfg_msix *msix = &dinfo->cfg.msix;
|
||||
uint32_t offset;
|
||||
|
||||
@ -1356,7 +1355,7 @@ pci_enable_msix(device_t dev, u_int index, uint64_t address, uint32_t data)
|
||||
bus_write_4(msix->msix_table_res, offset + 8, data);
|
||||
|
||||
/* Enable MSI -> HT mapping. */
|
||||
pci_ht_map_msi(dev, address);
|
||||
pci_ht_map_msi(child, address);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1868,45 +1867,46 @@ pci_set_max_read_req(device_t dev, int size)
|
||||
* Support for MSI message signalled interrupts.
|
||||
*/
|
||||
void
|
||||
pci_enable_msi(device_t dev, uint64_t address, uint16_t data)
|
||||
pci_enable_msi_method(device_t dev, device_t child, uint64_t address,
|
||||
uint16_t data)
|
||||
{
|
||||
struct pci_devinfo *dinfo = device_get_ivars(dev);
|
||||
struct pci_devinfo *dinfo = device_get_ivars(child);
|
||||
struct pcicfg_msi *msi = &dinfo->cfg.msi;
|
||||
|
||||
/* Write data and address values. */
|
||||
pci_write_config(dev, msi->msi_location + PCIR_MSI_ADDR,
|
||||
pci_write_config(child, msi->msi_location + PCIR_MSI_ADDR,
|
||||
address & 0xffffffff, 4);
|
||||
if (msi->msi_ctrl & PCIM_MSICTRL_64BIT) {
|
||||
pci_write_config(dev, msi->msi_location + PCIR_MSI_ADDR_HIGH,
|
||||
pci_write_config(child, msi->msi_location + PCIR_MSI_ADDR_HIGH,
|
||||
address >> 32, 4);
|
||||
pci_write_config(dev, msi->msi_location + PCIR_MSI_DATA_64BIT,
|
||||
pci_write_config(child, msi->msi_location + PCIR_MSI_DATA_64BIT,
|
||||
data, 2);
|
||||
} else
|
||||
pci_write_config(dev, msi->msi_location + PCIR_MSI_DATA, data,
|
||||
pci_write_config(child, msi->msi_location + PCIR_MSI_DATA, data,
|
||||
2);
|
||||
|
||||
/* Enable MSI in the control register. */
|
||||
msi->msi_ctrl |= PCIM_MSICTRL_MSI_ENABLE;
|
||||
pci_write_config(dev, msi->msi_location + PCIR_MSI_CTRL, msi->msi_ctrl,
|
||||
2);
|
||||
pci_write_config(child, msi->msi_location + PCIR_MSI_CTRL,
|
||||
msi->msi_ctrl, 2);
|
||||
|
||||
/* Enable MSI -> HT mapping. */
|
||||
pci_ht_map_msi(dev, address);
|
||||
pci_ht_map_msi(child, address);
|
||||
}
|
||||
|
||||
void
|
||||
pci_disable_msi(device_t dev)
|
||||
pci_disable_msi_method(device_t dev, device_t child)
|
||||
{
|
||||
struct pci_devinfo *dinfo = device_get_ivars(dev);
|
||||
struct pci_devinfo *dinfo = device_get_ivars(child);
|
||||
struct pcicfg_msi *msi = &dinfo->cfg.msi;
|
||||
|
||||
/* Disable MSI -> HT mapping. */
|
||||
pci_ht_map_msi(dev, 0);
|
||||
pci_ht_map_msi(child, 0);
|
||||
|
||||
/* Disable MSI in the control register. */
|
||||
msi->msi_ctrl &= ~PCIM_MSICTRL_MSI_ENABLE;
|
||||
pci_write_config(dev, msi->msi_location + PCIR_MSI_CTRL, msi->msi_ctrl,
|
||||
2);
|
||||
pci_write_config(child, msi->msi_location + PCIR_MSI_CTRL,
|
||||
msi->msi_ctrl, 2);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -138,6 +138,26 @@ METHOD int alloc_msix {
|
||||
int *count;
|
||||
};
|
||||
|
||||
METHOD void enable_msi {
|
||||
device_t dev;
|
||||
device_t child;
|
||||
uint64_t address;
|
||||
uint16_t data;
|
||||
};
|
||||
|
||||
METHOD void enable_msix {
|
||||
device_t dev;
|
||||
device_t child;
|
||||
u_int index;
|
||||
uint64_t address;
|
||||
uint32_t data;
|
||||
};
|
||||
|
||||
METHOD void disable_msi {
|
||||
device_t dev;
|
||||
device_t child;
|
||||
};
|
||||
|
||||
METHOD int remap_msix {
|
||||
device_t dev;
|
||||
device_t child;
|
||||
|
@ -90,6 +90,11 @@ int pci_find_htcap_method(device_t dev, device_t child,
|
||||
int capability, int *capreg);
|
||||
int pci_alloc_msi_method(device_t dev, device_t child, int *count);
|
||||
int pci_alloc_msix_method(device_t dev, device_t child, int *count);
|
||||
void pci_enable_msi_method(device_t dev, device_t child,
|
||||
uint64_t address, uint16_t data);
|
||||
void pci_enable_msix_method(device_t dev, device_t child,
|
||||
u_int index, uint64_t address, uint32_t data);
|
||||
void pci_disable_msi_method(device_t dev, device_t child);
|
||||
int pci_remap_msix_method(device_t dev, device_t child,
|
||||
int count, const u_int *vectors);
|
||||
int pci_release_msi_method(device_t dev, device_t child);
|
||||
|
@ -458,6 +458,24 @@ pci_alloc_msix(device_t dev, int *count)
|
||||
return (PCI_ALLOC_MSIX(device_get_parent(dev), dev, count));
|
||||
}
|
||||
|
||||
static __inline void
|
||||
pci_enable_msi(device_t dev, uint64_t address, uint16_t data)
|
||||
{
|
||||
PCI_ENABLE_MSI(device_get_parent(dev), dev, address, data);
|
||||
}
|
||||
|
||||
static __inline void
|
||||
pci_enable_msix(device_t dev, u_int index, uint64_t address, uint32_t data)
|
||||
{
|
||||
PCI_ENABLE_MSIX(device_get_parent(dev), dev, index, address, data);
|
||||
}
|
||||
|
||||
static __inline void
|
||||
pci_disable_msi(device_t dev)
|
||||
{
|
||||
PCI_DISABLE_MSI(device_get_parent(dev), dev);
|
||||
}
|
||||
|
||||
static __inline int
|
||||
pci_remap_msix(device_t dev, int count, const u_int *vectors)
|
||||
{
|
||||
|
@ -534,7 +534,11 @@ struct msix_entry {
|
||||
/*
|
||||
* Enable msix, positive errors indicate actual number of available
|
||||
* vectors. Negative errors are failures.
|
||||
*
|
||||
* NB: define added to prevent this definition of pci_enable_msix from
|
||||
* clashing with the native FreeBSD version.
|
||||
*/
|
||||
#define pci_enable_msix linux_pci_enable_msix
|
||||
static inline int
|
||||
pci_enable_msix(struct pci_dev *pdev, struct msix_entry *entries, int nreq)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user