Lu Baolu | 5628317 | 2018-07-14 15:46:54 +0800 | [diff] [blame] | 1 | /* 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 Baolu | 0bbeb01 | 2018-12-10 09:58:56 +0800 | [diff] [blame] | 14 | #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 Baolu | 3b33d4a | 2018-12-10 09:58:59 +0800 | [diff] [blame^] | 20 | /* |
| 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 Baolu | 0bbeb01 | 2018-12-10 09:58:56 +0800 | [diff] [blame] | 26 | struct pasid_dir_entry { |
| 27 | u64 val; |
| 28 | }; |
Lu Baolu | 5628317 | 2018-07-14 15:46:54 +0800 | [diff] [blame] | 29 | |
Lu Baolu | cc580e4 | 2018-07-14 15:46:59 +0800 | [diff] [blame] | 30 | struct pasid_entry { |
Lu Baolu | 0bbeb01 | 2018-12-10 09:58:56 +0800 | [diff] [blame] | 31 | u64 val[8]; |
Lu Baolu | cc580e4 | 2018-07-14 15:46:59 +0800 | [diff] [blame] | 32 | }; |
| 33 | |
| 34 | /* The representative of a PASID table */ |
| 35 | struct 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 Baolu | 5628317 | 2018-07-14 15:46:54 +0800 | [diff] [blame] | 42 | extern u32 intel_pasid_max_id; |
| 43 | int intel_pasid_alloc_id(void *ptr, int start, int end, gfp_t gfp); |
| 44 | void intel_pasid_free_id(int pasid); |
| 45 | void *intel_pasid_lookup_id(int pasid); |
Lu Baolu | cc580e4 | 2018-07-14 15:46:59 +0800 | [diff] [blame] | 46 | int intel_pasid_alloc_table(struct device *dev); |
| 47 | void intel_pasid_free_table(struct device *dev); |
| 48 | struct pasid_table *intel_pasid_get_table(struct device *dev); |
| 49 | int intel_pasid_get_dev_max_id(struct device *dev); |
| 50 | struct pasid_entry *intel_pasid_get_entry(struct device *dev, int pasid); |
| 51 | void intel_pasid_clear_entry(struct device *dev, int pasid); |
Lu Baolu | 5628317 | 2018-07-14 15:46:54 +0800 | [diff] [blame] | 52 | |
| 53 | #endif /* __INTEL_PASID_H */ |