| 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* |
| 3 | * Copyright (C) 2007-2010 Advanced Micro Devices, Inc. |
| 4 | * Author: Joerg Roedel <joerg.roedel@amd.com> |
| 5 | * Leo Duran <leo.duran@amd.com> |
| 6 | */ |
| 7 | |
| 8 | #ifndef _ASM_X86_AMD_IOMMU_H |
| 9 | #define _ASM_X86_AMD_IOMMU_H |
| 10 | |
| 11 | #include <linux/types.h> |
| 12 | |
| 13 | struct amd_iommu; |
| 14 | |
| 15 | #ifdef CONFIG_AMD_IOMMU |
| 16 | |
| 17 | struct task_struct; |
| 18 | struct pci_dev; |
| 19 | |
| 20 | extern void amd_iommu_detect(void); |
| 21 | |
| 22 | #else /* CONFIG_AMD_IOMMU */ |
| 23 | |
| 24 | static inline void amd_iommu_detect(void) { } |
| 25 | |
| 26 | #endif /* CONFIG_AMD_IOMMU */ |
| 27 | |
| 28 | #if defined(CONFIG_AMD_IOMMU) && defined(CONFIG_IRQ_REMAP) |
| 29 | |
| 30 | /* IOMMU AVIC Function */ |
| 31 | extern int amd_iommu_register_ga_log_notifier(int (*notifier)(u32)); |
| 32 | |
| 33 | extern int amd_iommu_update_ga(void *data, int cpu, bool ga_log_intr); |
| 34 | extern int amd_iommu_activate_guest_mode(void *data, int cpu, bool ga_log_intr); |
| 35 | extern int amd_iommu_deactivate_guest_mode(void *data); |
| 36 | |
| 37 | #else /* defined(CONFIG_AMD_IOMMU) && defined(CONFIG_IRQ_REMAP) */ |
| 38 | |
| 39 | static inline int |
| 40 | amd_iommu_register_ga_log_notifier(int (*notifier)(u32)) |
| 41 | { |
| 42 | return 0; |
| 43 | } |
| 44 | |
| 45 | static inline int amd_iommu_update_ga(void *data, int cpu, bool ga_log_intr) |
| 46 | { |
| 47 | return 0; |
| 48 | } |
| 49 | |
| 50 | static inline int amd_iommu_activate_guest_mode(void *data, int cpu, bool ga_log_intr) |
| 51 | { |
| 52 | return 0; |
| 53 | } |
| 54 | |
| 55 | static inline int amd_iommu_deactivate_guest_mode(void *data) |
| 56 | { |
| 57 | return 0; |
| 58 | } |
| 59 | #endif /* defined(CONFIG_AMD_IOMMU) && defined(CONFIG_IRQ_REMAP) */ |
| 60 | |
| 61 | int amd_iommu_get_num_iommus(void); |
| 62 | bool amd_iommu_pc_supported(void); |
| 63 | u8 amd_iommu_pc_get_max_banks(unsigned int idx); |
| 64 | u8 amd_iommu_pc_get_max_counters(unsigned int idx); |
| 65 | int amd_iommu_pc_set_reg(struct amd_iommu *iommu, u8 bank, u8 cntr, u8 fxn, |
| 66 | u64 *value); |
| 67 | int amd_iommu_pc_get_reg(struct amd_iommu *iommu, u8 bank, u8 cntr, u8 fxn, |
| 68 | u64 *value); |
| 69 | struct amd_iommu *get_amd_iommu(unsigned int idx); |
| 70 | |
| 71 | #ifdef CONFIG_KVM_AMD_SEV |
| 72 | int amd_iommu_snp_disable(void); |
| 73 | extern bool amd_iommu_sev_tio_supported(void); |
| 74 | #else |
| 75 | static inline int amd_iommu_snp_disable(void) { return 0; } |
| 76 | static inline bool amd_iommu_sev_tio_supported(void) { return false; } |
| 77 | #endif |
| 78 | |
| 79 | #endif /* _ASM_X86_AMD_IOMMU_H */ |
| 80 | |