Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / drivers / iommu / intel / perf.h
blobdf9a36942d643562575888285a2ec6f6a9237f94
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * perf.h - performance monitor header
5 * Copyright (C) 2021 Intel Corporation
7 * Author: Lu Baolu <baolu.lu@linux.intel.com>
8 */
10 enum latency_type {
11 DMAR_LATENCY_INV_IOTLB = 0,
12 DMAR_LATENCY_INV_DEVTLB,
13 DMAR_LATENCY_INV_IEC,
14 DMAR_LATENCY_NUM
17 enum latency_count {
18 COUNTS_10e2 = 0, /* < 0.1us */
19 COUNTS_10e3, /* 0.1us ~ 1us */
20 COUNTS_10e4, /* 1us ~ 10us */
21 COUNTS_10e5, /* 10us ~ 100us */
22 COUNTS_10e6, /* 100us ~ 1ms */
23 COUNTS_10e7, /* 1ms ~ 10ms */
24 COUNTS_10e8_plus, /* 10ms and plus*/
25 COUNTS_MIN,
26 COUNTS_MAX,
27 COUNTS_SUM,
28 COUNTS_NUM
31 struct latency_statistic {
32 bool enabled;
33 u64 counter[COUNTS_NUM];
34 u64 samples;
37 #ifdef CONFIG_DMAR_PERF
38 int dmar_latency_enable(struct intel_iommu *iommu, enum latency_type type);
39 void dmar_latency_disable(struct intel_iommu *iommu, enum latency_type type);
40 bool dmar_latency_enabled(struct intel_iommu *iommu, enum latency_type type);
41 void dmar_latency_update(struct intel_iommu *iommu, enum latency_type type,
42 u64 latency);
43 int dmar_latency_snapshot(struct intel_iommu *iommu, char *str, size_t size);
44 #else
45 static inline int
46 dmar_latency_enable(struct intel_iommu *iommu, enum latency_type type)
48 return -EINVAL;
51 static inline void
52 dmar_latency_disable(struct intel_iommu *iommu, enum latency_type type)
56 static inline bool
57 dmar_latency_enabled(struct intel_iommu *iommu, enum latency_type type)
59 return false;
62 static inline void
63 dmar_latency_update(struct intel_iommu *iommu, enum latency_type type, u64 latency)
67 static inline int
68 dmar_latency_snapshot(struct intel_iommu *iommu, char *str, size_t size)
70 return 0;
72 #endif /* CONFIG_DMAR_PERF */