ia64/xen-unstable

annotate xen/include/xen/iommu.h @ 19800:78962f85c562

IOMMU: Add two generic functions to vendor neutral interface

Add 2 generic functions into the vendor neutral iommu interface, The
reason is that from changeset 19732, there is only one global flag
"iommu_enabled" that controls iommu enablement for both vtd and amd
systems, so we need different code paths for vtd and amd iommu systems
if this flag has been turned on. Also, the early checking of
"iommu_enabled" in iommu_setup() is removed to prevent iommu
functionalities from been disabled on amd systems.

Signed-off-by: Wei Wang <wei.wang2@amd.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jun 19 08:41:50 2009 +0100 (2009-06-19)
parents 4fb8a6c993e2
children
rev   line source
keir@17212 1 /*
keir@17212 2 * Copyright (c) 2006, Intel Corporation.
keir@17212 3 *
keir@17212 4 * This program is free software; you can redistribute it and/or modify it
keir@17212 5 * under the terms and conditions of the GNU General Public License,
keir@17212 6 * version 2, as published by the Free Software Foundation.
keir@17212 7 *
keir@17212 8 * This program is distributed in the hope it will be useful, but WITHOUT
keir@17212 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
keir@17212 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
keir@17212 11 * more details.
keir@17212 12 *
keir@17212 13 * You should have received a copy of the GNU General Public License along with
keir@17212 14 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
keir@17212 15 * Place - Suite 330, Boston, MA 02111-1307 USA.
keir@17212 16 *
keir@17212 17 * Copyright (C) Allen Kay <allen.m.kay@intel.com>
keir@17212 18 */
keir@17212 19
keir@17212 20 #ifndef _IOMMU_H_
keir@17212 21 #define _IOMMU_H_
keir@17212 22
keir@17212 23 #include <xen/init.h>
keir@17212 24 #include <xen/spinlock.h>
keir@17542 25 #include <xen/pci.h>
keir@17212 26 #include <public/hvm/ioreq.h>
keir@17212 27 #include <public/domctl.h>
keir@17212 28
keir@17487 29 extern int iommu_enabled;
keir@17726 30 extern int iommu_pv_enabled;
keir@18272 31 extern int force_iommu;
keir@18469 32 extern int iommu_passthrough;
keir@19080 33 extern int iommu_snoop;
keir@19385 34 extern int iommu_qinval;
keir@19385 35 extern int iommu_intremap;
keir@17212 36
keir@17212 37 #define domain_hvm_iommu(d) (&d->arch.hvm_domain.hvm_iommu)
keir@17212 38
keir@17212 39 #define MAX_IOMMUS 32
keir@17212 40
keir@17212 41 #define PAGE_SHIFT_4K (12)
keir@17212 42 #define PAGE_SIZE_4K (1UL << PAGE_SHIFT_4K)
keir@17212 43 #define PAGE_MASK_4K (((u64)-1) << PAGE_SHIFT_4K)
keir@17212 44 #define PAGE_ALIGN_4K(addr) (((addr) + PAGE_SIZE_4K - 1) & PAGE_MASK_4K)
keir@17212 45
keir@17212 46 struct iommu {
keir@17212 47 struct list_head list;
keir@17212 48 void __iomem *reg; /* Pointer to hardware regs, virtual addr */
keir@17730 49 u32 index; /* Sequence number of iommu */
keir@17759 50 u32 nr_pt_levels;
keir@17212 51 u64 cap;
keir@17212 52 u64 ecap;
keir@17212 53 spinlock_t lock; /* protect context, domain ids */
keir@17212 54 spinlock_t register_lock; /* protect iommu register handling */
keir@17432 55 u64 root_maddr; /* root entry machine address */
keir@19458 56 int vector;
keir@17212 57 struct intel_iommu *intel;
keir@17212 58 };
keir@17212 59
keir@17977 60 int iommu_add_device(struct pci_dev *pdev);
keir@17977 61 int iommu_remove_device(struct pci_dev *pdev);
keir@17212 62 int iommu_domain_init(struct domain *d);
keir@17212 63 void iommu_domain_destroy(struct domain *d);
keir@17212 64 int device_assigned(u8 bus, u8 devfn);
keir@17212 65 int assign_device(struct domain *d, u8 bus, u8 devfn);
keir@18916 66 int deassign_device(struct domain *d, u8 bus, u8 devfn);
keir@17751 67 int iommu_get_device_group(struct domain *d, u8 bus, u8 devfn,
keir@17751 68 XEN_GUEST_HANDLE_64(uint32) buf, int max_sdevs);
keir@17212 69 int iommu_map_page(struct domain *d, unsigned long gfn, unsigned long mfn);
keir@17212 70 int iommu_unmap_page(struct domain *d, unsigned long gfn);
keir@17212 71 void iommu_domain_teardown(struct domain *d);
keir@17212 72 int hvm_do_IRQ_dpci(struct domain *d, unsigned int irq);
keir@17212 73 int dpci_ioport_intercept(ioreq_t *p);
keir@17212 74 int pt_irq_create_bind_vtd(struct domain *d,
keir@17212 75 xen_domctl_bind_pt_irq_t *pt_irq_bind);
keir@17212 76 int pt_irq_destroy_bind_vtd(struct domain *d,
keir@17212 77 xen_domctl_bind_pt_irq_t *pt_irq_bind);
keir@17212 78 unsigned int io_apic_read_remap_rte(unsigned int apic, unsigned int reg);
keir@17212 79 void io_apic_write_remap_rte(unsigned int apic,
keir@17212 80 unsigned int reg, unsigned int value);
keir@17760 81
keir@17760 82 struct msi_desc;
keir@17760 83 struct msi_msg;
keir@17743 84 void msi_msg_read_remap_rte(struct msi_desc *msi_desc, struct msi_msg *msg);
keir@17743 85 void msi_msg_write_remap_rte(struct msi_desc *msi_desc, struct msi_msg *msg);
keir@17212 86 struct qi_ctrl *iommu_qi_ctrl(struct iommu *iommu);
keir@17212 87 struct ir_ctrl *iommu_ir_ctrl(struct iommu *iommu);
keir@17212 88 struct iommu_flush *iommu_get_flush(struct iommu *iommu);
keir@17431 89 void hvm_dpci_isairq_eoi(struct domain *d, unsigned int isairq);
keir@17431 90 struct hvm_irq_dpci *domain_get_irq_dpci(struct domain *domain);
keir@17431 91 int domain_set_irq_dpci(struct domain *domain, struct hvm_irq_dpci *dpci);
keir@19650 92 void free_hvm_irq_dpci(struct hvm_irq_dpci *dpci);
keir@17212 93
keir@17212 94 #define PT_IRQ_TIME_OUT MILLISECS(8)
keir@17212 95 #define VTDPREFIX "[VT-D]"
keir@17212 96
keir@17212 97 struct iommu_ops {
keir@17212 98 int (*init)(struct domain *d);
keir@17977 99 int (*add_device)(struct pci_dev *pdev);
keir@17977 100 int (*remove_device)(struct pci_dev *pdev);
keir@17212 101 int (*assign_device)(struct domain *d, u8 bus, u8 devfn);
keir@17212 102 void (*teardown)(struct domain *d);
keir@17212 103 int (*map_page)(struct domain *d, unsigned long gfn, unsigned long mfn);
keir@17212 104 int (*unmap_page)(struct domain *d, unsigned long gfn);
keir@17976 105 int (*reassign_device)(struct domain *s, struct domain *t,
keir@17976 106 u8 bus, u8 devfn);
keir@17751 107 int (*get_device_group_id)(u8 bus, u8 devfn);
keir@18038 108 void (*update_ire_from_apic)(unsigned int apic, unsigned int reg, unsigned int value);
keir@18038 109 void (*update_ire_from_msi)(struct msi_desc *msi_desc, struct msi_msg *msg);
keir@19800 110 void (*read_msi_from_ire)(struct msi_desc *msi_desc, struct msi_msg *msg);
keir@19800 111 unsigned int (*read_apic_from_ire)(unsigned int apic, unsigned int reg);
keir@17212 112 };
keir@17212 113
keir@18038 114 void iommu_update_ire_from_apic(unsigned int apic, unsigned int reg, unsigned int value);
keir@18038 115 void iommu_update_ire_from_msi(struct msi_desc *msi_desc, struct msi_msg *msg);
keir@19800 116 void iommu_read_msi_from_ire(struct msi_desc *msi_desc, struct msi_msg *msg);
keir@19800 117 unsigned int iommu_read_apic_from_ire(unsigned int apic, unsigned int reg);
keir@18418 118
keir@18784 119 void iommu_suspend(void);
keir@18784 120 void iommu_resume(void);
keir@18418 121
keir@19220 122 void iommu_set_dom0_mapping(struct domain *d);
keir@19220 123
keir@17212 124 #endif /* _IOMMU_H_ */