1 #ifndef KVM__IRQ_H 2 #define KVM__IRQ_H 3 4 #include <stdbool.h> 5 #include <linux/types.h> 6 #include <linux/rbtree.h> 7 #include <linux/list.h> 8 #include <linux/kvm.h> 9 10 #include "kvm/kvm-arch.h" 11 #include "kvm/msi.h" 12 13 struct kvm; 14 15 struct msi_routing_ops { 16 int (*update_route)(struct kvm *kvm, struct kvm_irq_routing_entry *); 17 bool (*can_signal_msi)(struct kvm *kvm); 18 int (*signal_msi)(struct kvm *kvm, struct kvm_msi *msi); 19 int (*translate_gsi)(struct kvm *kvm, u32 gsi); 20 }; 21 22 extern struct msi_routing_ops *msi_routing_ops; 23 extern struct kvm_irq_routing *irq_routing; 24 extern int next_gsi; 25 26 int irq__alloc_line(void); 27 int irq__get_nr_allocated_lines(void); 28 29 int irq__init(struct kvm *kvm); 30 int irq__exit(struct kvm *kvm); 31 32 int irq__allocate_routing_entry(void); 33 int irq__add_msix_route(struct kvm *kvm, struct msi_msg *msg, u32 device_id); 34 void irq__update_msix_route(struct kvm *kvm, u32 gsi, struct msi_msg *msg); 35 36 bool irq__can_signal_msi(struct kvm *kvm); 37 int irq__signal_msi(struct kvm *kvm, struct kvm_msi *msi); 38 39 /* 40 * The function takes two eventfd arguments, trigger_fd and resample_fd. If 41 * resample_fd is <= 0, resampling is disabled and the IRQ is edge-triggered 42 */ 43 int irq__common_add_irqfd(struct kvm *kvm, unsigned int gsi, int trigger_fd, 44 int resample_fd); 45 void irq__common_del_irqfd(struct kvm *kvm, unsigned int gsi, int trigger_fd); 46 47 #ifndef irq__add_irqfd 48 #define irq__add_irqfd irq__common_add_irqfd 49 #endif 50 51 #ifndef irq__del_irqfd 52 #define irq__del_irqfd irq__common_del_irqfd 53 #endif 54 55 #endif 56