blob: 03c1612d173cb30897f0211bb843adb8cd41fa51 [file] [log] [blame]
Lu Baolu56283172018-07-14 15:46:54 +08001/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * intel-pasid.h - PASID idr, table and entry header
4 *
5 * Copyright (C) 2018 Intel Corporation
6 *
7 * Author: Lu Baolu <baolu.lu@linux.intel.com>
8 */
9
10#ifndef __INTEL_PASID_H
11#define __INTEL_PASID_H
12
13#define PASID_MIN 0x1
Lu Baolu0bbeb012018-12-10 09:58:56 +080014#define PASID_MAX 0x100000
15#define PASID_PTE_MASK 0x3F
16#define PASID_PTE_PRESENT 1
17#define PDE_PFN_MASK PAGE_MASK
18#define PASID_PDE_SHIFT 6
19
Lu Baolu3b33d4a2018-12-10 09:58:59 +080020/*
21 * Domain ID reserved for pasid entries programmed for first-level
22 * only and pass-through transfer modes.
23 */
24#define FLPT_DEFAULT_DID 1
25
Lu Baolu0bbeb012018-12-10 09:58:56 +080026struct pasid_dir_entry {
27 u64 val;
28};
Lu Baolu56283172018-07-14 15:46:54 +080029
Lu Baolucc580e42018-07-14 15:46:59 +080030struct pasid_entry {
Lu Baolu0bbeb012018-12-10 09:58:56 +080031 u64 val[8];
Lu Baolucc580e42018-07-14 15:46:59 +080032};
33
34/* The representative of a PASID table */
35struct pasid_table {
36 void *table; /* pasid table pointer */
37 int order; /* page order of pasid table */
38 int max_pasid; /* max pasid */
39 struct list_head dev; /* device list */
40};
41
Lu Baolu56283172018-07-14 15:46:54 +080042extern u32 intel_pasid_max_id;
43int intel_pasid_alloc_id(void *ptr, int start, int end, gfp_t gfp);
44void intel_pasid_free_id(int pasid);
45void *intel_pasid_lookup_id(int pasid);
Lu Baolucc580e42018-07-14 15:46:59 +080046int intel_pasid_alloc_table(struct device *dev);
47void intel_pasid_free_table(struct device *dev);
48struct pasid_table *intel_pasid_get_table(struct device *dev);
49int intel_pasid_get_dev_max_id(struct device *dev);
50struct pasid_entry *intel_pasid_get_entry(struct device *dev, int pasid);
51void intel_pasid_clear_entry(struct device *dev, int pasid);
Lu Baolu56283172018-07-14 15:46:54 +080052
53#endif /* __INTEL_PASID_H */