1 /*
2  * Copyright (C) 2012 Advanced Micro Devices, Inc.
3  * Author: Joerg Roedel <joerg.roedel@amd.com>
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 as published
7  * by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17  *
18  * This header file contains the interface of the interrupt remapping code to
19  * the x86 interrupt management code.
20  */
21 
22 #ifndef __X86_IRQ_REMAPPING_H
23 #define __X86_IRQ_REMAPPING_H
24 
25 #include <linux/irqdomain.h>
26 #include <asm/hw_irq.h>
27 #include <asm/io_apic.h>
28 
29 struct IO_APIC_route_entry;
30 struct io_apic_irq_attr;
31 struct irq_chip;
32 struct msi_msg;
33 struct pci_dev;
34 struct irq_cfg;
35 struct irq_alloc_info;
36 
37 #ifdef CONFIG_IRQ_REMAP
38 
39 extern void set_irq_remapping_broken(void);
40 extern int irq_remapping_prepare(void);
41 extern int irq_remapping_enable(void);
42 extern void irq_remapping_disable(void);
43 extern int irq_remapping_reenable(int);
44 extern int irq_remap_enable_fault_handling(void);
45 extern int setup_ioapic_remapped_entry(int irq,
46 				       struct IO_APIC_route_entry *entry,
47 				       unsigned int destination,
48 				       int vector,
49 				       struct io_apic_irq_attr *attr);
50 extern void free_remapped_irq(int irq);
51 extern void panic_if_irq_remap(const char *msg);
52 extern bool setup_remapped_irq(int irq,
53 			       struct irq_cfg *cfg,
54 			       struct irq_chip *chip);
55 
56 void irq_remap_modify_chip_defaults(struct irq_chip *chip);
57 
58 extern struct irq_domain *
59 irq_remapping_get_ir_irq_domain(struct irq_alloc_info *info);
60 extern struct irq_domain *
61 irq_remapping_get_irq_domain(struct irq_alloc_info *info);
62 extern void irq_remapping_print_chip(struct irq_data *data, struct seq_file *p);
63 
64 /* Create PCI MSI/MSIx irqdomain, use @parent as the parent irqdomain. */
65 extern struct irq_domain *arch_create_msi_irq_domain(struct irq_domain *parent);
66 
67 /* Get parent irqdomain for interrupt remapping irqdomain */
68 static inline struct irq_domain *arch_get_ir_parent_domain(void)
69 {
70 	return x86_vector_domain;
71 }
72 
73 #else  /* CONFIG_IRQ_REMAP */
74 
75 static inline void set_irq_remapping_broken(void) { }
76 static inline int irq_remapping_prepare(void) { return -ENODEV; }
77 static inline int irq_remapping_enable(void) { return -ENODEV; }
78 static inline void irq_remapping_disable(void) { }
79 static inline int irq_remapping_reenable(int eim) { return -ENODEV; }
80 static inline int irq_remap_enable_fault_handling(void) { return -ENODEV; }
81 static inline int setup_ioapic_remapped_entry(int irq,
82 					      struct IO_APIC_route_entry *entry,
83 					      unsigned int destination,
84 					      int vector,
85 					      struct io_apic_irq_attr *attr)
86 {
87 	return -ENODEV;
88 }
89 static inline void free_remapped_irq(int irq) { }
90 
91 static inline void panic_if_irq_remap(const char *msg)
92 {
93 }
94 
95 static inline void irq_remap_modify_chip_defaults(struct irq_chip *chip)
96 {
97 }
98 
99 static inline bool setup_remapped_irq(int irq,
100 				      struct irq_cfg *cfg,
101 				      struct irq_chip *chip)
102 {
103 	return false;
104 }
105 
106 static inline struct irq_domain *
107 irq_remapping_get_ir_irq_domain(struct irq_alloc_info *info)
108 {
109 	return NULL;
110 }
111 
112 static inline struct irq_domain *
113 irq_remapping_get_irq_domain(struct irq_alloc_info *info)
114 {
115 	return NULL;
116 }
117 
118 #define	irq_remapping_print_chip	NULL
119 #endif /* CONFIG_IRQ_REMAP */
120 #endif /* __X86_IRQ_REMAPPING_H */
121