Eric Auger | 166c977 | 2015-09-18 22:29:42 +0800 | [diff] [blame] | 1 | /* |
| 2 | * This program is free software; you can redistribute it and/or modify |
| 3 | * it under the terms of the GNU General Public License as published by |
| 4 | * the Free Software Foundation; either version 2 of the License. |
| 5 | * |
| 6 | * This program is distributed in the hope that it will be useful, |
| 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 9 | * GNU General Public License for more details. |
| 10 | * |
| 11 | * irqfd: Allows an fd to be used to inject an interrupt to the guest |
| 12 | * Credit goes to Avi Kivity for the original idea. |
| 13 | */ |
| 14 | |
| 15 | #ifndef __LINUX_KVM_IRQFD_H |
| 16 | #define __LINUX_KVM_IRQFD_H |
| 17 | |
| 18 | #include <linux/kvm_host.h> |
| 19 | #include <linux/poll.h> |
| 20 | |
| 21 | /* |
| 22 | * Resampling irqfds are a special variety of irqfds used to emulate |
| 23 | * level triggered interrupts. The interrupt is asserted on eventfd |
| 24 | * trigger. On acknowledgment through the irq ack notifier, the |
| 25 | * interrupt is de-asserted and userspace is notified through the |
| 26 | * resamplefd. All resamplers on the same gsi are de-asserted |
| 27 | * together, so we don't need to track the state of each individual |
| 28 | * user. We can also therefore share the same irq source ID. |
| 29 | */ |
| 30 | struct kvm_kernel_irqfd_resampler { |
| 31 | struct kvm *kvm; |
| 32 | /* |
| 33 | * List of resampling struct _irqfd objects sharing this gsi. |
| 34 | * RCU list modified under kvm->irqfds.resampler_lock |
| 35 | */ |
| 36 | struct list_head list; |
| 37 | struct kvm_irq_ack_notifier notifier; |
| 38 | /* |
| 39 | * Entry in list of kvm->irqfd.resampler_list. Use for sharing |
| 40 | * resamplers among irqfds on the same gsi. |
| 41 | * Accessed and modified under kvm->irqfds.resampler_lock |
| 42 | */ |
| 43 | struct list_head link; |
| 44 | }; |
| 45 | |
| 46 | struct kvm_kernel_irqfd { |
| 47 | /* Used for MSI fast-path */ |
| 48 | struct kvm *kvm; |
| 49 | wait_queue_t wait; |
| 50 | /* Update side is protected by irqfds.lock */ |
| 51 | struct kvm_kernel_irq_routing_entry irq_entry; |
| 52 | seqcount_t irq_entry_sc; |
| 53 | /* Used for level IRQ fast-path */ |
| 54 | int gsi; |
| 55 | struct work_struct inject; |
| 56 | /* The resampler used by this irqfd (resampler-only) */ |
| 57 | struct kvm_kernel_irqfd_resampler *resampler; |
| 58 | /* Eventfd notified on resample (resampler-only) */ |
| 59 | struct eventfd_ctx *resamplefd; |
| 60 | /* Entry in list of irqfds for a resampler (resampler-only) */ |
| 61 | struct list_head resampler_link; |
| 62 | /* Used for setup/shutdown */ |
| 63 | struct eventfd_ctx *eventfd; |
| 64 | struct list_head list; |
| 65 | poll_table pt; |
| 66 | struct work_struct shutdown; |
Eric Auger | 9016cfb | 2015-09-18 22:29:44 +0800 | [diff] [blame] | 67 | struct irq_bypass_consumer consumer; |
| 68 | struct irq_bypass_producer *producer; |
Eric Auger | 166c977 | 2015-09-18 22:29:42 +0800 | [diff] [blame] | 69 | }; |
| 70 | |
| 71 | #endif /* __LINUX_KVM_IRQFD_H */ |