irq_remapping.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. #ifndef __X86_IRQ_REMAPPING_H
  22. #define __X86_IRQ_REMAPPING_H
  23. #include <asm/irqdomain.h>
  24. #include <asm/hw_irq.h>
  25. #include <asm/io_apic.h>
  26. struct msi_msg;
  27. struct irq_alloc_info;
  28. enum irq_remap_cap {
  29. IRQ_POSTING_CAP = 0,
  30. };
  31. enum {
  32. IRQ_REMAP_XAPIC_MODE,
  33. IRQ_REMAP_X2APIC_MODE,
  34. };
  35. struct vcpu_data {
  36. u64 pi_desc_addr; /* Physical address of PI Descriptor */
  37. u32 vector; /* Guest vector of the interrupt */
  38. };
  39. #ifdef CONFIG_IRQ_REMAP
  40. extern raw_spinlock_t irq_2_ir_lock;
  41. extern bool irq_remapping_cap(enum irq_remap_cap cap);
  42. extern void set_irq_remapping_broken(void);
  43. extern int irq_remapping_prepare(void);
  44. extern int irq_remapping_enable(void);
  45. extern void irq_remapping_disable(void);
  46. extern int irq_remapping_reenable(int);
  47. extern int irq_remap_enable_fault_handling(void);
  48. extern void panic_if_irq_remap(const char *msg);
  49. extern struct irq_domain *
  50. irq_remapping_get_ir_irq_domain(struct irq_alloc_info *info);
  51. extern struct irq_domain *
  52. irq_remapping_get_irq_domain(struct irq_alloc_info *info);
  53. /* Create PCI MSI/MSIx irqdomain, use @parent as the parent irqdomain. */
  54. extern struct irq_domain *
  55. arch_create_remap_msi_irq_domain(struct irq_domain *par, const char *n, int id);
  56. /* Get parent irqdomain for interrupt remapping irqdomain */
  57. static inline struct irq_domain *arch_get_ir_parent_domain(void)
  58. {
  59. return x86_vector_domain;
  60. }
  61. #else /* CONFIG_IRQ_REMAP */
  62. static inline bool irq_remapping_cap(enum irq_remap_cap cap) { return 0; }
  63. static inline void set_irq_remapping_broken(void) { }
  64. static inline int irq_remapping_prepare(void) { return -ENODEV; }
  65. static inline int irq_remapping_enable(void) { return -ENODEV; }
  66. static inline void irq_remapping_disable(void) { }
  67. static inline int irq_remapping_reenable(int eim) { return -ENODEV; }
  68. static inline int irq_remap_enable_fault_handling(void) { return -ENODEV; }
  69. static inline void panic_if_irq_remap(const char *msg)
  70. {
  71. }
  72. static inline struct irq_domain *
  73. irq_remapping_get_ir_irq_domain(struct irq_alloc_info *info)
  74. {
  75. return NULL;
  76. }
  77. static inline struct irq_domain *
  78. irq_remapping_get_irq_domain(struct irq_alloc_info *info)
  79. {
  80. return NULL;
  81. }
  82. #endif /* CONFIG_IRQ_REMAP */
  83. #endif /* __X86_IRQ_REMAPPING_H */