perfmon.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. /*
  3. * Copyright (C) 2001-2003 Hewlett-Packard Co
  4. * Stephane Eranian <eranian@hpl.hp.com>
  5. */
  6. #ifndef _UAPI_ASM_IA64_PERFMON_H
  7. #define _UAPI_ASM_IA64_PERFMON_H
  8. /*
  9. * perfmon commands supported on all CPU models
  10. */
  11. #define PFM_WRITE_PMCS 0x01
  12. #define PFM_WRITE_PMDS 0x02
  13. #define PFM_READ_PMDS 0x03
  14. #define PFM_STOP 0x04
  15. #define PFM_START 0x05
  16. #define PFM_ENABLE 0x06 /* obsolete */
  17. #define PFM_DISABLE 0x07 /* obsolete */
  18. #define PFM_CREATE_CONTEXT 0x08
  19. #define PFM_DESTROY_CONTEXT 0x09 /* obsolete use close() */
  20. #define PFM_RESTART 0x0a
  21. #define PFM_PROTECT_CONTEXT 0x0b /* obsolete */
  22. #define PFM_GET_FEATURES 0x0c
  23. #define PFM_DEBUG 0x0d
  24. #define PFM_UNPROTECT_CONTEXT 0x0e /* obsolete */
  25. #define PFM_GET_PMC_RESET_VAL 0x0f
  26. #define PFM_LOAD_CONTEXT 0x10
  27. #define PFM_UNLOAD_CONTEXT 0x11
  28. /*
  29. * PMU model specific commands (may not be supported on all PMU models)
  30. */
  31. #define PFM_WRITE_IBRS 0x20
  32. #define PFM_WRITE_DBRS 0x21
  33. /*
  34. * context flags
  35. */
  36. #define PFM_FL_NOTIFY_BLOCK 0x01 /* block task on user level notifications */
  37. #define PFM_FL_SYSTEM_WIDE 0x02 /* create a system wide context */
  38. #define PFM_FL_OVFL_NO_MSG 0x80 /* do not post overflow/end messages for notification */
  39. /*
  40. * event set flags
  41. */
  42. #define PFM_SETFL_EXCL_IDLE 0x01 /* exclude idle task (syswide only) XXX: DO NOT USE YET */
  43. /*
  44. * PMC flags
  45. */
  46. #define PFM_REGFL_OVFL_NOTIFY 0x1 /* send notification on overflow */
  47. #define PFM_REGFL_RANDOM 0x2 /* randomize sampling interval */
  48. /*
  49. * PMD/PMC/IBR/DBR return flags (ignored on input)
  50. *
  51. * Those flags are used on output and must be checked in case EAGAIN is returned
  52. * by any of the calls using a pfarg_reg_t or pfarg_dbreg_t structure.
  53. */
  54. #define PFM_REG_RETFL_NOTAVAIL (1UL<<31) /* set if register is implemented but not available */
  55. #define PFM_REG_RETFL_EINVAL (1UL<<30) /* set if register entry is invalid */
  56. #define PFM_REG_RETFL_MASK (PFM_REG_RETFL_NOTAVAIL|PFM_REG_RETFL_EINVAL)
  57. #define PFM_REG_HAS_ERROR(flag) (((flag) & PFM_REG_RETFL_MASK) != 0)
  58. typedef unsigned char pfm_uuid_t[16]; /* custom sampling buffer identifier type */
  59. /*
  60. * Request structure used to define a context
  61. */
  62. typedef struct {
  63. pfm_uuid_t ctx_smpl_buf_id; /* which buffer format to use (if needed) */
  64. unsigned long ctx_flags; /* noblock/block */
  65. unsigned short ctx_nextra_sets; /* number of extra event sets (you always get 1) */
  66. unsigned short ctx_reserved1; /* for future use */
  67. int ctx_fd; /* return arg: unique identification for context */
  68. void *ctx_smpl_vaddr; /* return arg: virtual address of sampling buffer, is used */
  69. unsigned long ctx_reserved2[11];/* for future use */
  70. } pfarg_context_t;
  71. /*
  72. * Request structure used to write/read a PMC or PMD
  73. */
  74. typedef struct {
  75. unsigned int reg_num; /* which register */
  76. unsigned short reg_set; /* event set for this register */
  77. unsigned short reg_reserved1; /* for future use */
  78. unsigned long reg_value; /* initial pmc/pmd value */
  79. unsigned long reg_flags; /* input: pmc/pmd flags, return: reg error */
  80. unsigned long reg_long_reset; /* reset after buffer overflow notification */
  81. unsigned long reg_short_reset; /* reset after counter overflow */
  82. unsigned long reg_reset_pmds[4]; /* which other counters to reset on overflow */
  83. unsigned long reg_random_seed; /* seed value when randomization is used */
  84. unsigned long reg_random_mask; /* bitmask used to limit random value */
  85. unsigned long reg_last_reset_val;/* return: PMD last reset value */
  86. unsigned long reg_smpl_pmds[4]; /* which pmds are accessed when PMC overflows */
  87. unsigned long reg_smpl_eventid; /* opaque sampling event identifier */
  88. unsigned long reg_reserved2[3]; /* for future use */
  89. } pfarg_reg_t;
  90. typedef struct {
  91. unsigned int dbreg_num; /* which debug register */
  92. unsigned short dbreg_set; /* event set for this register */
  93. unsigned short dbreg_reserved1; /* for future use */
  94. unsigned long dbreg_value; /* value for debug register */
  95. unsigned long dbreg_flags; /* return: dbreg error */
  96. unsigned long dbreg_reserved2[1]; /* for future use */
  97. } pfarg_dbreg_t;
  98. typedef struct {
  99. unsigned int ft_version; /* perfmon: major [16-31], minor [0-15] */
  100. unsigned int ft_reserved; /* reserved for future use */
  101. unsigned long reserved[4]; /* for future use */
  102. } pfarg_features_t;
  103. typedef struct {
  104. pid_t load_pid; /* process to load the context into */
  105. unsigned short load_set; /* first event set to load */
  106. unsigned short load_reserved1; /* for future use */
  107. unsigned long load_reserved2[3]; /* for future use */
  108. } pfarg_load_t;
  109. typedef struct {
  110. int msg_type; /* generic message header */
  111. int msg_ctx_fd; /* generic message header */
  112. unsigned long msg_ovfl_pmds[4]; /* which PMDs overflowed */
  113. unsigned short msg_active_set; /* active set at the time of overflow */
  114. unsigned short msg_reserved1; /* for future use */
  115. unsigned int msg_reserved2; /* for future use */
  116. unsigned long msg_tstamp; /* for perf tuning/debug */
  117. } pfm_ovfl_msg_t;
  118. typedef struct {
  119. int msg_type; /* generic message header */
  120. int msg_ctx_fd; /* generic message header */
  121. unsigned long msg_tstamp; /* for perf tuning */
  122. } pfm_end_msg_t;
  123. typedef struct {
  124. int msg_type; /* type of the message */
  125. int msg_ctx_fd; /* unique identifier for the context */
  126. unsigned long msg_tstamp; /* for perf tuning */
  127. } pfm_gen_msg_t;
  128. #define PFM_MSG_OVFL 1 /* an overflow happened */
  129. #define PFM_MSG_END 2 /* task to which context was attached ended */
  130. typedef union {
  131. pfm_ovfl_msg_t pfm_ovfl_msg;
  132. pfm_end_msg_t pfm_end_msg;
  133. pfm_gen_msg_t pfm_gen_msg;
  134. } pfm_msg_t;
  135. /*
  136. * Define the version numbers for both perfmon as a whole and the sampling buffer format.
  137. */
  138. #define PFM_VERSION_MAJ 2U
  139. #define PFM_VERSION_MIN 0U
  140. #define PFM_VERSION (((PFM_VERSION_MAJ&0xffff)<<16)|(PFM_VERSION_MIN & 0xffff))
  141. #define PFM_VERSION_MAJOR(x) (((x)>>16) & 0xffff)
  142. #define PFM_VERSION_MINOR(x) ((x) & 0xffff)
  143. /*
  144. * miscellaneous architected definitions
  145. */
  146. #define PMU_FIRST_COUNTER 4 /* first counting monitor (PMC/PMD) */
  147. #define PMU_MAX_PMCS 256 /* maximum architected number of PMC registers */
  148. #define PMU_MAX_PMDS 256 /* maximum architected number of PMD registers */
  149. #endif /* _UAPI_ASM_IA64_PERFMON_H */