blob: 5f26962eff427d21294389fda52e3ab842f9aeae [file] [log] [blame]
Joerg Roedel736baef2012-03-30 11:47:00 -07001/*
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
Suresh Siddha8a8f4222012-03-30 11:47:08 -070022#ifndef __X86_IRQ_REMAPPING_H
23#define __X86_IRQ_REMAPPING_H
Joerg Roedel736baef2012-03-30 11:47:00 -070024
Jiang Liud746d1e2015-04-14 10:30:09 +080025#include <asm/irqdomain.h>
Jiang Liu947045a2015-04-13 14:11:30 +080026#include <asm/hw_irq.h>
Suresh Siddha399988e2012-05-08 00:08:52 -070027#include <asm/io_apic.h>
Joerg Roedel736baef2012-03-30 11:47:00 -070028
Joerg Roedel35d3d812013-04-19 20:34:55 +020029struct msi_msg;
Jiang Liu947045a2015-04-13 14:11:30 +080030struct irq_alloc_info;
Joerg Roedel35d3d812013-04-19 20:34:55 +020031
Feng Wu6f281922015-06-09 13:20:28 +080032enum irq_remap_cap {
33 IRQ_POSTING_CAP = 0,
34};
35
Suravee Suthikulpanit818b7582018-06-27 10:31:20 -050036enum {
37 IRQ_REMAP_XAPIC_MODE,
38 IRQ_REMAP_X2APIC_MODE,
39};
40
Paolo Bonzini18cd52c2015-09-18 18:04:17 +020041struct vcpu_data {
42 u64 pi_desc_addr; /* Physical address of PI Descriptor */
43 u32 vector; /* Guest vector of the interrupt */
44};
45
Suresh Siddha399988e2012-05-08 00:08:52 -070046#ifdef CONFIG_IRQ_REMAP
Joerg Roedel0c3f1732012-03-30 11:47:02 -070047
Feng Wu959c8702015-06-09 13:20:36 +080048extern bool irq_remapping_cap(enum irq_remap_cap cap);
Neil Horman03bbcb22013-04-16 16:38:32 -040049extern void set_irq_remapping_broken(void);
Suresh Siddha95a02e92012-03-30 11:47:07 -070050extern int irq_remapping_prepare(void);
51extern int irq_remapping_enable(void);
52extern void irq_remapping_disable(void);
53extern int irq_remapping_reenable(int);
54extern int irq_remap_enable_fault_handling(void);
Joerg Roedel6a9f5de2012-09-26 12:44:41 +020055extern void panic_if_irq_remap(const char *msg);
Joerg Roedel9b1b0e42012-09-26 12:44:45 +020056
Jiang Liu947045a2015-04-13 14:11:30 +080057extern struct irq_domain *
58irq_remapping_get_ir_irq_domain(struct irq_alloc_info *info);
59extern struct irq_domain *
60irq_remapping_get_irq_domain(struct irq_alloc_info *info);
Jiang Liu947045a2015-04-13 14:11:30 +080061
62/* Create PCI MSI/MSIx irqdomain, use @parent as the parent irqdomain. */
Thomas Gleixner667724c2017-06-20 01:37:10 +020063extern struct irq_domain *
64arch_create_remap_msi_irq_domain(struct irq_domain *par, const char *n, int id);
Jiang Liu947045a2015-04-13 14:11:30 +080065
66/* Get parent irqdomain for interrupt remapping irqdomain */
67static inline struct irq_domain *arch_get_ir_parent_domain(void)
68{
69 return x86_vector_domain;
70}
71
Joerg Roedel736baef2012-03-30 11:47:00 -070072#else /* CONFIG_IRQ_REMAP */
73
Feng Wu959c8702015-06-09 13:20:36 +080074static inline bool irq_remapping_cap(enum irq_remap_cap cap) { return 0; }
Neil Horman03bbcb22013-04-16 16:38:32 -040075static inline void set_irq_remapping_broken(void) { }
Suresh Siddha95a02e92012-03-30 11:47:07 -070076static inline int irq_remapping_prepare(void) { return -ENODEV; }
77static inline int irq_remapping_enable(void) { return -ENODEV; }
78static inline void irq_remapping_disable(void) { }
79static inline int irq_remapping_reenable(int eim) { return -ENODEV; }
80static inline int irq_remap_enable_fault_handling(void) { return -ENODEV; }
Joerg Roedel6a9f5de2012-09-26 12:44:41 +020081
82static inline void panic_if_irq_remap(const char *msg)
83{
84}
Joerg Roedel9b1b0e42012-09-26 12:44:45 +020085
Jiang Liu947045a2015-04-13 14:11:30 +080086static inline struct irq_domain *
87irq_remapping_get_ir_irq_domain(struct irq_alloc_info *info)
88{
89 return NULL;
90}
91
92static inline struct irq_domain *
93irq_remapping_get_irq_domain(struct irq_alloc_info *info)
94{
95 return NULL;
96}
97
Joerg Roedel736baef2012-03-30 11:47:00 -070098#endif /* CONFIG_IRQ_REMAP */
Suresh Siddha8a8f4222012-03-30 11:47:08 -070099#endif /* __X86_IRQ_REMAPPING_H */