perf.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * perf.h - performance monitor header
  4. *
  5. * Copyright (C) 2021 Intel Corporation
  6. *
  7. * Author: Lu Baolu <baolu.lu@linux.intel.com>
  8. */
  9. enum latency_type {
  10. DMAR_LATENCY_INV_IOTLB = 0,
  11. DMAR_LATENCY_INV_DEVTLB,
  12. DMAR_LATENCY_INV_IEC,
  13. DMAR_LATENCY_NUM
  14. };
  15. enum latency_count {
  16. COUNTS_10e2 = 0, /* < 0.1us */
  17. COUNTS_10e3, /* 0.1us ~ 1us */
  18. COUNTS_10e4, /* 1us ~ 10us */
  19. COUNTS_10e5, /* 10us ~ 100us */
  20. COUNTS_10e6, /* 100us ~ 1ms */
  21. COUNTS_10e7, /* 1ms ~ 10ms */
  22. COUNTS_10e8_plus, /* 10ms and plus*/
  23. COUNTS_MIN,
  24. COUNTS_MAX,
  25. COUNTS_SUM,
  26. COUNTS_NUM
  27. };
  28. struct latency_statistic {
  29. bool enabled;
  30. u64 counter[COUNTS_NUM];
  31. u64 samples;
  32. };
  33. #ifdef CONFIG_DMAR_PERF
  34. int dmar_latency_enable(struct intel_iommu *iommu, enum latency_type type);
  35. void dmar_latency_disable(struct intel_iommu *iommu, enum latency_type type);
  36. bool dmar_latency_enabled(struct intel_iommu *iommu, enum latency_type type);
  37. void dmar_latency_update(struct intel_iommu *iommu, enum latency_type type,
  38. u64 latency);
  39. int dmar_latency_snapshot(struct intel_iommu *iommu, char *str, size_t size);
  40. #else
  41. static inline int
  42. dmar_latency_enable(struct intel_iommu *iommu, enum latency_type type)
  43. {
  44. return -EINVAL;
  45. }
  46. static inline void
  47. dmar_latency_disable(struct intel_iommu *iommu, enum latency_type type)
  48. {
  49. }
  50. static inline bool
  51. dmar_latency_enabled(struct intel_iommu *iommu, enum latency_type type)
  52. {
  53. return false;
  54. }
  55. static inline void
  56. dmar_latency_update(struct intel_iommu *iommu, enum latency_type type, u64 latency)
  57. {
  58. }
  59. static inline int
  60. dmar_latency_snapshot(struct intel_iommu *iommu, char *str, size_t size)
  61. {
  62. return 0;
  63. }
  64. #endif /* CONFIG_DMAR_PERF */