ia64/xen-unstable

view xen/drivers/passthrough/vtd/dmar.h @ 19810:aa472909b39c

vtd: IO NUMA support

This patch adds VT-d RHSA processing for IO NUMA support. The basic
idea is to parse ACPI RHSA structure to obtain VT-d HW to proximity
domain mapping. This mapping is then used when allocating pages for
Vt-d HW data structures.

Signed-off-by: Allen Kay <allen.m.kay@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Jun 23 11:14:24 2009 +0100 (2009-06-23)
parents a69daf23602a
children
line source
1 /*
2 * Copyright (c) 2006, Intel Corporation.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15 * Place - Suite 330, Boston, MA 02111-1307 USA.
16 *
17 * Copyright (C) Ashok Raj <ashok.raj@intel.com>
18 * Copyright (C) Shaohua Li <shaohua.li@intel.com>
19 */
21 #ifndef _DMAR_H_
22 #define _DMAR_H_
24 #include <xen/list.h>
25 #include <xen/iommu.h>
27 extern u8 dmar_host_address_width;
29 /* This one is for interrupt remapping */
30 struct acpi_ioapic_unit {
31 struct list_head list;
32 int apic_id;
33 union {
34 u16 info;
35 struct {
36 u16 func: 3,
37 dev: 5,
38 bus: 8;
39 }bdf;
40 }ioapic;
41 };
43 struct dmar_scope {
44 DECLARE_BITMAP(buses, 256); /* buses owned by this unit */
45 u16 *devices; /* devices owned by this unit */
46 int devices_cnt;
47 };
49 struct acpi_drhd_unit {
50 struct dmar_scope scope; /* must be first member of struct */
51 struct list_head list;
52 u64 address; /* register base address of the unit */
53 u8 include_all:1;
54 struct iommu *iommu;
55 struct list_head ioapic_list;
56 };
58 struct acpi_rmrr_unit {
59 struct dmar_scope scope; /* must be first member of struct */
60 struct list_head list;
61 u64 base_address;
62 u64 end_address;
63 u8 allow_all:1;
64 };
66 struct acpi_atsr_unit {
67 struct dmar_scope scope; /* must be first member of struct */
68 struct list_head list;
69 u8 all_ports:1;
70 };
72 struct acpi_rhsa_unit {
73 struct list_head list;
74 u64 address;
75 u32 domain;
76 };
78 #define for_each_drhd_unit(drhd) \
79 list_for_each_entry(drhd, &acpi_drhd_units, list)
81 #define for_each_rmrr_device(rmrr, bdf, idx) \
82 list_for_each_entry(rmrr, &acpi_rmrr_units, list) \
83 /* assume there never is a bdf == 0 */ \
84 for (idx = 0; (bdf = rmrr->scope.devices[idx]) && \
85 idx < rmrr->scope.devices_cnt; idx++)
87 struct acpi_drhd_unit * acpi_find_matched_drhd_unit(struct pci_dev *pdev);
88 struct acpi_atsr_unit * acpi_find_matched_atsr_unit(u8 bus, u8 devfn);
89 void dmar_scope_add_buses(struct dmar_scope *scope, u16 sec, u16 sub);
90 void dmar_scope_remove_buses(struct dmar_scope *scope, u16 sec, u16 sub);
92 #define DMAR_TYPE 1
93 #define RMRR_TYPE 2
94 #define ATSR_TYPE 3
96 #define DMAR_OPERATION_TIMEOUT MILLISECS(1000)
98 #define IOMMU_WAIT_OP(iommu, offset, op, cond, sts) \
99 do { \
100 s_time_t start_time = NOW(); \
101 while (1) { \
102 sts = op(iommu->reg, offset); \
103 if ( cond ) \
104 break; \
105 if ( NOW() > start_time + DMAR_OPERATION_TIMEOUT ) \
106 panic("%s:%d:%s: DMAR hardware is malfunctional\n", \
107 __FILE__, __LINE__, __func__); \
108 cpu_relax(); \
109 } \
110 } while (0)
112 int vtd_hw_check(void);
113 void disable_pmr(struct iommu *iommu);
114 int is_usb_device(u8 bus, u8 devfn);
116 #endif /* _DMAR_H_ */