ebb.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright 2014, Michael Ellerman, IBM Corp.
  3. * Licensed under GPLv2.
  4. */
  5. #ifndef _SELFTESTS_POWERPC_PMU_EBB_EBB_H
  6. #define _SELFTESTS_POWERPC_PMU_EBB_EBB_H
  7. #include "../event.h"
  8. #include "../lib.h"
  9. #include "trace.h"
  10. #include "reg.h"
  11. #define PMC_INDEX(pmc) ((pmc)-1)
  12. #define NUM_PMC_VALUES 128
  13. struct ebb_state
  14. {
  15. struct {
  16. u64 pmc_count[6];
  17. volatile int ebb_count;
  18. int spurious;
  19. int negative;
  20. int no_overflow;
  21. } stats;
  22. bool pmc_enable[6];
  23. struct trace_buffer *trace;
  24. };
  25. extern struct ebb_state ebb_state;
  26. #define COUNTER_OVERFLOW 0x80000000ull
  27. static inline uint32_t pmc_sample_period(uint32_t value)
  28. {
  29. return COUNTER_OVERFLOW - value;
  30. }
  31. static inline void ebb_enable_pmc_counting(int pmc)
  32. {
  33. ebb_state.pmc_enable[PMC_INDEX(pmc)] = true;
  34. }
  35. bool ebb_check_count(int pmc, u64 sample_period, int fudge);
  36. void event_leader_ebb_init(struct event *e);
  37. void event_ebb_init(struct event *e);
  38. void event_bhrb_init(struct event *e, unsigned ifm);
  39. void setup_ebb_handler(void (*callee)(void));
  40. void standard_ebb_callee(void);
  41. int ebb_event_enable(struct event *e);
  42. void ebb_global_enable(void);
  43. void ebb_global_disable(void);
  44. void ebb_freeze_pmcs(void);
  45. void ebb_unfreeze_pmcs(void);
  46. void event_ebb_init(struct event *e);
  47. void event_leader_ebb_init(struct event *e);
  48. int count_pmc(int pmc, uint32_t sample_period);
  49. void dump_ebb_state(void);
  50. void dump_summary_ebb_state(void);
  51. void dump_ebb_hw_state(void);
  52. void clear_ebb_stats(void);
  53. void write_pmc(int pmc, u64 value);
  54. u64 read_pmc(int pmc);
  55. void reset_ebb_with_clear_mask(unsigned long mmcr0_clear_mask);
  56. void reset_ebb(void);
  57. int ebb_check_mmcr0(void);
  58. extern u64 sample_period;
  59. int core_busy_loop(void);
  60. int ebb_child(union pipe read_pipe, union pipe write_pipe);
  61. int catch_sigill(void (*func)(void));
  62. void write_pmc1(void);
  63. #endif /* _SELFTESTS_POWERPC_PMU_EBB_EBB_H */