xref: /linux/include/linux/msi_api.h (revision 06bff9e347271566e8dd79e7c3eb971660209a00)
16b6941f6SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0 */
26b6941f6SThomas Gleixner #ifndef LINUX_MSI_API_H
36b6941f6SThomas Gleixner #define LINUX_MSI_API_H
46b6941f6SThomas Gleixner 
56b6941f6SThomas Gleixner /*
66b6941f6SThomas Gleixner  * APIs which are relevant for device driver code for allocating and
76b6941f6SThomas Gleixner  * freeing MSI interrupts and querying the associations between
86b6941f6SThomas Gleixner  * hardware/software MSI indices and the Linux interrupt number.
96b6941f6SThomas Gleixner  */
106b6941f6SThomas Gleixner 
116b6941f6SThomas Gleixner struct device;
126b6941f6SThomas Gleixner 
13f1139f90SThomas Gleixner /*
14f1139f90SThomas Gleixner  * Per device interrupt domain related constants.
15f1139f90SThomas Gleixner  */
16f1139f90SThomas Gleixner enum msi_domain_ids {
17f1139f90SThomas Gleixner 	MSI_DEFAULT_DOMAIN,
18f1139f90SThomas Gleixner 	MSI_MAX_DEVICE_IRQDOMAINS,
19f1139f90SThomas Gleixner };
20f1139f90SThomas Gleixner 
21*06bff9e3SThomas Gleixner /**
22*06bff9e3SThomas Gleixner  * msi_map - Mapping between MSI index and Linux interrupt number
23*06bff9e3SThomas Gleixner  * @index:	The MSI index, e.g. slot in the MSI-X table or
24*06bff9e3SThomas Gleixner  *		a software managed index if >= 0. If negative
25*06bff9e3SThomas Gleixner  *		the allocation function failed and it contains
26*06bff9e3SThomas Gleixner  *		the error code.
27*06bff9e3SThomas Gleixner  * @virq:	The associated Linux interrupt number
28*06bff9e3SThomas Gleixner  */
29*06bff9e3SThomas Gleixner struct msi_map {
30*06bff9e3SThomas Gleixner 	int	index;
31*06bff9e3SThomas Gleixner 	int	virq;
32*06bff9e3SThomas Gleixner };
33*06bff9e3SThomas Gleixner 
3498043704SAhmed S. Darwish unsigned int msi_domain_get_virq(struct device *dev, unsigned int domid, unsigned int index);
3598043704SAhmed S. Darwish 
3698043704SAhmed S. Darwish /**
3798043704SAhmed S. Darwish  * msi_get_virq - Lookup the Linux interrupt number for a MSI index on the default interrupt domain
3898043704SAhmed S. Darwish  * @dev:	Device for which the lookup happens
3998043704SAhmed S. Darwish  * @index:	The MSI index to lookup
4098043704SAhmed S. Darwish  *
4198043704SAhmed S. Darwish  * Return: The Linux interrupt number on success (> 0), 0 if not found
4298043704SAhmed S. Darwish  */
4398043704SAhmed S. Darwish static inline unsigned int msi_get_virq(struct device *dev, unsigned int index)
4498043704SAhmed S. Darwish {
4598043704SAhmed S. Darwish 	return msi_domain_get_virq(dev, MSI_DEFAULT_DOMAIN, index);
4698043704SAhmed S. Darwish }
476b6941f6SThomas Gleixner 
486b6941f6SThomas Gleixner #endif
49