73 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2#ifndef LINUX_MSI_API_H3#define LINUX_MSI_API_H4 5/*6 * APIs which are relevant for device driver code for allocating and7 * freeing MSI interrupts and querying the associations between8 * hardware/software MSI indices and the Linux interrupt number.9 */10 11struct device;12 13/*14 * Per device interrupt domain related constants.15 */16enum msi_domain_ids {17 MSI_DEFAULT_DOMAIN,18 MSI_MAX_DEVICE_IRQDOMAINS,19};20 21/**22 * union msi_instance_cookie - MSI instance cookie23 * @value: u64 value store24 * @ptr: Pointer to usage site specific data25 *26 * This cookie is handed to the IMS allocation function and stored in the27 * MSI descriptor for the interrupt chip callbacks.28 *29 * The content of this cookie is MSI domain implementation defined. For30 * PCI/IMS implementations this could be a PASID or a pointer to queue31 * memory.32 */33union msi_instance_cookie {34 u64 value;35 void *ptr;36};37 38/**39 * msi_map - Mapping between MSI index and Linux interrupt number40 * @index: The MSI index, e.g. slot in the MSI-X table or41 * a software managed index if >= 0. If negative42 * the allocation function failed and it contains43 * the error code.44 * @virq: The associated Linux interrupt number45 */46struct msi_map {47 int index;48 int virq;49};50 51/*52 * Constant to be used for dynamic allocations when the allocation is any53 * free MSI index, which is either an entry in a hardware table or a54 * software managed index.55 */56#define MSI_ANY_INDEX UINT_MAX57 58unsigned int msi_domain_get_virq(struct device *dev, unsigned int domid, unsigned int index);59 60/**61 * msi_get_virq - Lookup the Linux interrupt number for a MSI index on the default interrupt domain62 * @dev: Device for which the lookup happens63 * @index: The MSI index to lookup64 *65 * Return: The Linux interrupt number on success (> 0), 0 if not found66 */67static inline unsigned int msi_get_virq(struct device *dev, unsigned int index)68{69 return msi_domain_get_virq(dev, MSI_DEFAULT_DOMAIN, index);70}71 72#endif73