1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Gasket common interrupt module. Defines functions for enabling
4 * eventfd-triggered interrupts between a Gasket device and a host process.
6 * Copyright (C) 2018 Google, Inc.
8 #ifndef __GASKET_INTERRUPT_H__
9 #define __GASKET_INTERRUPT_H__
11 #include <linux/eventfd.h>
12 #include <linux/pci.h>
14 #include "gasket_core.h"
16 /* Note that this currently assumes that device interrupts are a dense set,
17 * numbered from 0 - (num_interrupts - 1). Should this have to change, these
18 * APIs will have to be updated.
21 /* Opaque type used to hold interrupt subsystem data. */
22 struct gasket_interrupt_data;
25 * Initialize the interrupt module.
26 * @gasket_dev: The Gasket device structure for the device to be initted.
28 int gasket_interrupt_init(struct gasket_dev *gasket_dev);
31 * Clean up a device's interrupt structure.
32 * @gasket_dev: The Gasket information structure for this device.
34 * Cleans up the device's interrupts and deallocates data.
36 void gasket_interrupt_cleanup(struct gasket_dev *gasket_dev);
39 * Clean up and re-initialize the MSI-x subsystem.
40 * @gasket_dev: The Gasket information structure for this device.
42 * Performs a teardown of the MSI-x subsystem and re-initializes it. Does not
43 * free the underlying data structures. Returns 0 on success and an error code
46 int gasket_interrupt_reinit(struct gasket_dev *gasket_dev);
49 * Reset the counts stored in the interrupt subsystem.
50 * @gasket_dev: The Gasket information structure for this device.
52 * Sets the counts of all interrupts in the subsystem to 0.
54 int gasket_interrupt_reset_counts(struct gasket_dev *gasket_dev);
57 * Associates an eventfd with a device interrupt.
58 * @data: Pointer to device interrupt data.
59 * @interrupt: The device interrupt to configure.
60 * @event_fd: The eventfd to associate with the interrupt.
62 * Prepares the host to receive notification of device interrupts by associating
63 * event_fd with interrupt. Upon receipt of a device interrupt, event_fd will be
64 * signaled, after successful configuration.
66 * Returns 0 on success, a negative error code otherwise.
68 int gasket_interrupt_set_eventfd(struct gasket_interrupt_data *interrupt_data,
69 int interrupt, int event_fd);
72 * Removes an interrupt-eventfd association.
73 * @data: Pointer to device interrupt data.
74 * @interrupt: The device interrupt to de-associate.
76 * Removes any eventfd associated with the specified interrupt, if any.
78 int gasket_interrupt_clear_eventfd(struct gasket_interrupt_data *interrupt_data,
82 * The below functions exist for backwards compatibility.
83 * No new uses should be written.
86 * Get the health of the interrupt subsystem.
87 * @gasket_dev: The Gasket device struct.
89 * Returns DEAD if not set up, LAMED if initialization failed, and ALIVE
93 int gasket_interrupt_system_status(struct gasket_dev *gasket_dev);