mirror of
https://github.com/torvalds/linux.git
synced 2024-10-26 06:54:41 +00:00
PCI/MSI: Introduce pci_msix_table_size()
Introduce new function pci_msix_table_size() returning the size of the MSI-X table of given PCI device or 0 if the device doesn't support MSI-X. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Reviewed-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
This commit is contained in:
parent
a447b77282
commit
a52e2e3513
|
@ -674,6 +674,23 @@ static int msi_free_irqs(struct pci_dev* dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pci_msix_table_size - return the number of device's MSI-X table entries
|
||||||
|
* @dev: pointer to the pci_dev data structure of MSI-X device function
|
||||||
|
*/
|
||||||
|
int pci_msix_table_size(struct pci_dev *dev)
|
||||||
|
{
|
||||||
|
int pos;
|
||||||
|
u16 control;
|
||||||
|
|
||||||
|
pos = pci_find_capability(dev, PCI_CAP_ID_MSIX);
|
||||||
|
if (!pos)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
pci_read_config_word(dev, msi_control_reg(pos), &control);
|
||||||
|
return multi_msix_capable(control);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pci_enable_msix - configure device's MSI-X capability structure
|
* pci_enable_msix - configure device's MSI-X capability structure
|
||||||
* @dev: pointer to the pci_dev data structure of MSI-X device function
|
* @dev: pointer to the pci_dev data structure of MSI-X device function
|
||||||
|
@ -691,9 +708,8 @@ static int msi_free_irqs(struct pci_dev* dev)
|
||||||
**/
|
**/
|
||||||
int pci_enable_msix(struct pci_dev* dev, struct msix_entry *entries, int nvec)
|
int pci_enable_msix(struct pci_dev* dev, struct msix_entry *entries, int nvec)
|
||||||
{
|
{
|
||||||
int status, pos, nr_entries;
|
int status, nr_entries;
|
||||||
int i, j;
|
int i, j;
|
||||||
u16 control;
|
|
||||||
|
|
||||||
if (!entries)
|
if (!entries)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -702,9 +718,7 @@ int pci_enable_msix(struct pci_dev* dev, struct msix_entry *entries, int nvec)
|
||||||
if (status)
|
if (status)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
pos = pci_find_capability(dev, PCI_CAP_ID_MSIX);
|
nr_entries = pci_msix_table_size(dev);
|
||||||
pci_read_config_word(dev, msi_control_reg(pos), &control);
|
|
||||||
nr_entries = multi_msix_capable(control);
|
|
||||||
if (nvec > nr_entries)
|
if (nvec > nr_entries)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
|
|
@ -799,6 +799,10 @@ static inline void pci_msi_shutdown(struct pci_dev *dev)
|
||||||
static inline void pci_disable_msi(struct pci_dev *dev)
|
static inline void pci_disable_msi(struct pci_dev *dev)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
static inline int pci_msix_table_size(struct pci_dev *dev)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
static inline int pci_enable_msix(struct pci_dev *dev,
|
static inline int pci_enable_msix(struct pci_dev *dev,
|
||||||
struct msix_entry *entries, int nvec)
|
struct msix_entry *entries, int nvec)
|
||||||
{
|
{
|
||||||
|
@ -823,6 +827,7 @@ static inline int pci_msi_enabled(void)
|
||||||
extern int pci_enable_msi(struct pci_dev *dev);
|
extern int pci_enable_msi(struct pci_dev *dev);
|
||||||
extern void pci_msi_shutdown(struct pci_dev *dev);
|
extern void pci_msi_shutdown(struct pci_dev *dev);
|
||||||
extern void pci_disable_msi(struct pci_dev *dev);
|
extern void pci_disable_msi(struct pci_dev *dev);
|
||||||
|
extern int pci_msix_table_size(struct pci_dev *dev);
|
||||||
extern int pci_enable_msix(struct pci_dev *dev,
|
extern int pci_enable_msix(struct pci_dev *dev,
|
||||||
struct msix_entry *entries, int nvec);
|
struct msix_entry *entries, int nvec);
|
||||||
extern void pci_msix_shutdown(struct pci_dev *dev);
|
extern void pci_msix_shutdown(struct pci_dev *dev);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user