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 | be9e659 | 2018-09-08 09:42:53 +0800 | [diff] [blame] | 14 | #define PASID_MAX 0x20000 |
Lu Baolu | 5628317 | 2018-07-14 15:46:54 +0800 | [diff] [blame] | 15 | |
Lu Baolu | cc580e4 | 2018-07-14 15:46:59 +0800 | [diff] [blame] | 16 | struct pasid_entry { |
| 17 | u64 val; |
| 18 | }; |
| 19 | |
| 20 | /* The representative of a PASID table */ |
| 21 | struct pasid_table { |
| 22 | void *table; /* pasid table pointer */ |
| 23 | int order; /* page order of pasid table */ |
| 24 | int max_pasid; /* max pasid */ |
| 25 | struct list_head dev; /* device list */ |
| 26 | }; |
| 27 | |
Lu Baolu | 5628317 | 2018-07-14 15:46:54 +0800 | [diff] [blame] | 28 | extern u32 intel_pasid_max_id; |
| 29 | int intel_pasid_alloc_id(void *ptr, int start, int end, gfp_t gfp); |
| 30 | void intel_pasid_free_id(int pasid); |
| 31 | void *intel_pasid_lookup_id(int pasid); |
Lu Baolu | cc580e4 | 2018-07-14 15:46:59 +0800 | [diff] [blame] | 32 | int intel_pasid_alloc_table(struct device *dev); |
| 33 | void intel_pasid_free_table(struct device *dev); |
| 34 | struct pasid_table *intel_pasid_get_table(struct device *dev); |
| 35 | int intel_pasid_get_dev_max_id(struct device *dev); |
| 36 | struct pasid_entry *intel_pasid_get_entry(struct device *dev, int pasid); |
| 37 | void intel_pasid_clear_entry(struct device *dev, int pasid); |
Lu Baolu | 5628317 | 2018-07-14 15:46:54 +0800 | [diff] [blame] | 38 | |
| 39 | #endif /* __INTEL_PASID_H */ |