1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Gasket common interrupt module. Defines functions for enabling 4 * eventfd-triggered interrupts between a Gasket device and a host process. 5 * 6 * Copyright (C) 2018 Google, Inc. 7 */ 8 #ifndef __GASKET_INTERRUPT_H__ 9 #define __GASKET_INTERRUPT_H__ 10 11 #include <linux/eventfd.h> 12 #include <linux/pci.h> 13 14 #include "gasket_core.h" 15 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. 19 */ 20 21 /* Opaque type used to hold interrupt subsystem data. */ 22 struct gasket_interrupt_data; 23 24 /* 25 * Initialize the interrupt module. 26 * @gasket_dev: The Gasket device structure for the device to be initted. 27 */ 28 int gasket_interrupt_init(struct gasket_dev *gasket_dev); 29 30 /* 31 * Clean up a device's interrupt structure. 32 * @gasket_dev: The Gasket information structure for this device. 33 * 34 * Cleans up the device's interrupts and deallocates data. 35 */ 36 void gasket_interrupt_cleanup(struct gasket_dev *gasket_dev); 37 38 /* 39 * Clean up and re-initialize the MSI-x subsystem. 40 * @gasket_dev: The Gasket information structure for this device. 41 * 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 44 * on error. 45 */ 46 int gasket_interrupt_reinit(struct gasket_dev *gasket_dev); 47 48 /* 49 * Reset the counts stored in the interrupt subsystem. 50 * @gasket_dev: The Gasket information structure for this device. 51 * 52 * Sets the counts of all interrupts in the subsystem to 0. 53 */ 54 int gasket_interrupt_reset_counts(struct gasket_dev *gasket_dev); 55 56 /* 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. 61 * 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. 65 * 66 * Returns 0 on success, a negative error code otherwise. 67 */ 68 int gasket_interrupt_set_eventfd(struct gasket_interrupt_data *interrupt_data, 69 int interrupt, int event_fd); 70 71 /* 72 * Removes an interrupt-eventfd association. 73 * @data: Pointer to device interrupt data. 74 * @interrupt: The device interrupt to de-associate. 75 * 76 * Removes any eventfd associated with the specified interrupt, if any. 77 */ 78 int gasket_interrupt_clear_eventfd(struct gasket_interrupt_data *interrupt_data, 79 int interrupt); 80 81 /* 82 * The below functions exist for backwards compatibility. 83 * No new uses should be written. 84 */ 85 /* 86 * Get the health of the interrupt subsystem. 87 * @gasket_dev: The Gasket device struct. 88 * 89 * Returns DEAD if not set up, LAMED if initialization failed, and ALIVE 90 * otherwise. 91 */ 92 93 int gasket_interrupt_system_status(struct gasket_dev *gasket_dev); 94 95 #endif 96