ia64/xen-unstable

view xen/drivers/passthrough/vtd/dmar.h @ 19402:f02a528d2e56

Xen: use proper device ID to search VT-d unit for ARI and SR-IOV device

PCIe Alternative Routing-ID Interpretation (ARI) ECN defines the Extended
Function -- a function whose function number is greater than 7 within an
ARI Device. Intel VT-d spec 1.2 section 8.3.2 specifies that the Extended
Function is under the scope of the same remapping unit as the traditional
function. The hypervisor needs to know if a function is Extended
Function so it can find proper DMAR for it.

And section 8.3.3 specifies that the SR-IOV Virtual Function is under the
scope of the same remapping unit as the Physical Function. The hypervisor
also needs to know if a function is the Virtual Function and which
Physical Function it's associated with for same reason.

Signed-off-by: Yu Zhao <yu.zhao@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Mar 19 10:20:11 2009 +0000 (2009-03-19)
parents 1975e33b79f1
children a69daf23602a
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 };
73 #define for_each_drhd_unit(drhd) \
74 list_for_each_entry(drhd, &acpi_drhd_units, list)
76 #define for_each_rmrr_device(rmrr, bdf, idx) \
77 list_for_each_entry(rmrr, &acpi_rmrr_units, list) \
78 /* assume there never is a bdf == 0 */ \
79 for (idx = 0; (bdf = rmrr->scope.devices[idx]) && \
80 idx < rmrr->scope.devices_cnt; idx++)
82 struct acpi_drhd_unit * acpi_find_matched_drhd_unit(struct pci_dev *pdev);
83 struct acpi_atsr_unit * acpi_find_matched_atsr_unit(u8 bus, u8 devfn);
84 void dmar_scope_add_buses(struct dmar_scope *scope, u16 sec, u16 sub);
85 void dmar_scope_remove_buses(struct dmar_scope *scope, u16 sec, u16 sub);
87 #define DMAR_TYPE 1
88 #define RMRR_TYPE 2
89 #define ATSR_TYPE 3
91 #define DMAR_OPERATION_TIMEOUT MILLISECS(1000)
93 int vtd_hw_check(void);
94 void disable_pmr(struct iommu *iommu);
95 int is_usb_device(u8 bus, u8 devfn);
97 #endif /* _DMAR_H_ */