perf.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 <[email protected]>
  8. */
  9. enum latency_type {
  10. DMAR_LATENCY_INV_IOTLB = 0,
  11. DMAR_LATENCY_INV_DEVTLB,
  12. DMAR_LATENCY_INV_IEC,
  13. DMAR_LATENCY_PRQ,
  14. DMAR_LATENCY_NUM
  15. };
  16. enum latency_count {
  17. COUNTS_10e2 = 0, /* < 0.1us */
  18. COUNTS_10e3, /* 0.1us ~ 1us */
  19. COUNTS_10e4, /* 1us ~ 10us */
  20. COUNTS_10e5, /* 10us ~ 100us */
  21. COUNTS_10e6, /* 100us ~ 1ms */
  22. COUNTS_10e7, /* 1ms ~ 10ms */
  23. COUNTS_10e8_plus, /* 10ms and plus*/
  24. COUNTS_MIN,
  25. COUNTS_MAX,
  26. COUNTS_SUM,
  27. COUNTS_NUM
  28. };
  29. struct latency_statistic {
  30. bool enabled;
  31. u64 counter[COUNTS_NUM];
  32. u64 samples;
  33. };
  34. #ifdef CONFIG_DMAR_PERF
  35. int dmar_latency_enable(struct intel_iommu *iommu, enum latency_type type);
  36. void dmar_latency_disable(struct intel_iommu *iommu, enum latency_type type);
  37. bool dmar_latency_enabled(struct intel_iommu *iommu, enum latency_type type);
  38. void dmar_latency_update(struct intel_iommu *iommu, enum latency_type type,
  39. u64 latency);
  40. int dmar_latency_snapshot(struct intel_iommu *iommu, char *str, size_t size);
  41. #else
  42. static inline int
  43. dmar_latency_enable(struct intel_iommu *iommu, enum latency_type type)
  44. {
  45. return -EINVAL;
  46. }
  47. static inline void
  48. dmar_latency_disable(struct intel_iommu *iommu, enum latency_type type)
  49. {
  50. }
  51. static inline bool
  52. dmar_latency_enabled(struct intel_iommu *iommu, enum latency_type type)
  53. {
  54. return false;
  55. }
  56. static inline void
  57. dmar_latency_update(struct intel_iommu *iommu, enum latency_type type, u64 latency)
  58. {
  59. }
  60. static inline int
  61. dmar_latency_snapshot(struct intel_iommu *iommu, char *str, size_t size)
  62. {
  63. return 0;
  64. }
  65. #endif /* CONFIG_DMAR_PERF */