blob: 1fb5e12b029ac717379ec74544c83254ea0c0259 [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 Baolube9e6592018-09-08 09:42:53 +080014#define PASID_MAX 0x20000
Lu Baolu56283172018-07-14 15:46:54 +080015
Lu Baolucc580e42018-07-14 15:46:59 +080016struct pasid_entry {
17 u64 val;
18};
19
20/* The representative of a PASID table */
21struct 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 Baolu56283172018-07-14 15:46:54 +080028extern u32 intel_pasid_max_id;
29int intel_pasid_alloc_id(void *ptr, int start, int end, gfp_t gfp);
30void intel_pasid_free_id(int pasid);
31void *intel_pasid_lookup_id(int pasid);
Lu Baolucc580e42018-07-14 15:46:59 +080032int intel_pasid_alloc_table(struct device *dev);
33void intel_pasid_free_table(struct device *dev);
34struct pasid_table *intel_pasid_get_table(struct device *dev);
35int intel_pasid_get_dev_max_id(struct device *dev);
36struct pasid_entry *intel_pasid_get_entry(struct device *dev, int pasid);
37void intel_pasid_clear_entry(struct device *dev, int pasid);
Lu Baolu56283172018-07-14 15:46:54 +080038
39#endif /* __INTEL_PASID_H */