Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright 2014, Michael Ellerman, IBM Corp.
0004  */
0005 
0006 #ifndef _SELFTESTS_POWERPC_PMU_EBB_EBB_H
0007 #define _SELFTESTS_POWERPC_PMU_EBB_EBB_H
0008 
0009 #include "../event.h"
0010 #include "../lib.h"
0011 #include "trace.h"
0012 #include "reg.h"
0013 
0014 #define PMC_INDEX(pmc)  ((pmc)-1)
0015 
0016 #define NUM_PMC_VALUES  128
0017 
0018 struct ebb_state
0019 {
0020     struct {
0021         u64 pmc_count[6];
0022         volatile int ebb_count;
0023         int spurious;
0024         int negative;
0025         int no_overflow;
0026     } stats;
0027 
0028     bool pmc_enable[6];
0029     struct trace_buffer *trace;
0030 };
0031 
0032 extern struct ebb_state ebb_state;
0033 
0034 #define COUNTER_OVERFLOW 0x80000000ull
0035 
0036 static inline uint32_t pmc_sample_period(uint32_t value)
0037 {
0038     return COUNTER_OVERFLOW - value;
0039 }
0040 
0041 static inline void ebb_enable_pmc_counting(int pmc)
0042 {
0043     ebb_state.pmc_enable[PMC_INDEX(pmc)] = true;
0044 }
0045 
0046 bool ebb_check_count(int pmc, u64 sample_period, int fudge);
0047 void event_leader_ebb_init(struct event *e);
0048 void event_ebb_init(struct event *e);
0049 void event_bhrb_init(struct event *e, unsigned ifm);
0050 void setup_ebb_handler(void (*callee)(void));
0051 void standard_ebb_callee(void);
0052 int ebb_event_enable(struct event *e);
0053 void ebb_global_enable(void);
0054 void ebb_global_disable(void);
0055 bool ebb_is_supported(void);
0056 void ebb_freeze_pmcs(void);
0057 void ebb_unfreeze_pmcs(void);
0058 int count_pmc(int pmc, uint32_t sample_period);
0059 void dump_ebb_state(void);
0060 void dump_summary_ebb_state(void);
0061 void dump_ebb_hw_state(void);
0062 void clear_ebb_stats(void);
0063 void write_pmc(int pmc, u64 value);
0064 u64 read_pmc(int pmc);
0065 void reset_ebb_with_clear_mask(unsigned long mmcr0_clear_mask);
0066 void reset_ebb(void);
0067 int ebb_check_mmcr0(void);
0068 
0069 extern u64 sample_period;
0070 
0071 int core_busy_loop(void);
0072 int ebb_child(union pipe read_pipe, union pipe write_pipe);
0073 int catch_sigill(void (*func)(void));
0074 void write_pmc1(void);
0075 
0076 #endif /* _SELFTESTS_POWERPC_PMU_EBB_EBB_H */