1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * Copyright (C) 2001-2003 Hewlett-Packard Co 4*4882a593Smuzhiyun * Stephane Eranian <eranian@hpl.hp.com> 5*4882a593Smuzhiyun */ 6*4882a593Smuzhiyun #ifndef _ASM_IA64_PERFMON_H 7*4882a593Smuzhiyun #define _ASM_IA64_PERFMON_H 8*4882a593Smuzhiyun 9*4882a593Smuzhiyun #include <uapi/asm/perfmon.h> 10*4882a593Smuzhiyun 11*4882a593Smuzhiyun 12*4882a593Smuzhiyun extern long perfmonctl(int fd, int cmd, void *arg, int narg); 13*4882a593Smuzhiyun 14*4882a593Smuzhiyun typedef struct { 15*4882a593Smuzhiyun void (*handler)(int irq, void *arg, struct pt_regs *regs); 16*4882a593Smuzhiyun } pfm_intr_handler_desc_t; 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun extern void pfm_save_regs (struct task_struct *); 19*4882a593Smuzhiyun extern void pfm_load_regs (struct task_struct *); 20*4882a593Smuzhiyun 21*4882a593Smuzhiyun extern void pfm_exit_thread(struct task_struct *); 22*4882a593Smuzhiyun extern int pfm_use_debug_registers(struct task_struct *); 23*4882a593Smuzhiyun extern int pfm_release_debug_registers(struct task_struct *); 24*4882a593Smuzhiyun extern void pfm_syst_wide_update_task(struct task_struct *, unsigned long info, int is_ctxswin); 25*4882a593Smuzhiyun extern void pfm_inherit(struct task_struct *task, struct pt_regs *regs); 26*4882a593Smuzhiyun extern void pfm_init_percpu(void); 27*4882a593Smuzhiyun extern void pfm_handle_work(void); 28*4882a593Smuzhiyun extern int pfm_install_alt_pmu_interrupt(pfm_intr_handler_desc_t *h); 29*4882a593Smuzhiyun extern int pfm_remove_alt_pmu_interrupt(pfm_intr_handler_desc_t *h); 30*4882a593Smuzhiyun 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun 33*4882a593Smuzhiyun /* 34*4882a593Smuzhiyun * Reset PMD register flags 35*4882a593Smuzhiyun */ 36*4882a593Smuzhiyun #define PFM_PMD_SHORT_RESET 0 37*4882a593Smuzhiyun #define PFM_PMD_LONG_RESET 1 38*4882a593Smuzhiyun 39*4882a593Smuzhiyun typedef union { 40*4882a593Smuzhiyun unsigned int val; 41*4882a593Smuzhiyun struct { 42*4882a593Smuzhiyun unsigned int notify_user:1; /* notify user program of overflow */ 43*4882a593Smuzhiyun unsigned int reset_ovfl_pmds:1; /* reset overflowed PMDs */ 44*4882a593Smuzhiyun unsigned int block_task:1; /* block monitored task on kernel exit */ 45*4882a593Smuzhiyun unsigned int mask_monitoring:1; /* mask monitors via PMCx.plm */ 46*4882a593Smuzhiyun unsigned int reserved:28; /* for future use */ 47*4882a593Smuzhiyun } bits; 48*4882a593Smuzhiyun } pfm_ovfl_ctrl_t; 49*4882a593Smuzhiyun 50*4882a593Smuzhiyun typedef struct { 51*4882a593Smuzhiyun unsigned char ovfl_pmd; /* index of overflowed PMD */ 52*4882a593Smuzhiyun unsigned char ovfl_notify; /* =1 if monitor requested overflow notification */ 53*4882a593Smuzhiyun unsigned short active_set; /* event set active at the time of the overflow */ 54*4882a593Smuzhiyun pfm_ovfl_ctrl_t ovfl_ctrl; /* return: perfmon controls to set by handler */ 55*4882a593Smuzhiyun 56*4882a593Smuzhiyun unsigned long pmd_last_reset; /* last reset value of of the PMD */ 57*4882a593Smuzhiyun unsigned long smpl_pmds[4]; /* bitmask of other PMD of interest on overflow */ 58*4882a593Smuzhiyun unsigned long smpl_pmds_values[PMU_MAX_PMDS]; /* values for the other PMDs of interest */ 59*4882a593Smuzhiyun unsigned long pmd_value; /* current 64-bit value of the PMD */ 60*4882a593Smuzhiyun unsigned long pmd_eventid; /* eventid associated with PMD */ 61*4882a593Smuzhiyun } pfm_ovfl_arg_t; 62*4882a593Smuzhiyun 63*4882a593Smuzhiyun 64*4882a593Smuzhiyun typedef struct { 65*4882a593Smuzhiyun char *fmt_name; 66*4882a593Smuzhiyun pfm_uuid_t fmt_uuid; 67*4882a593Smuzhiyun size_t fmt_arg_size; 68*4882a593Smuzhiyun unsigned long fmt_flags; 69*4882a593Smuzhiyun 70*4882a593Smuzhiyun int (*fmt_validate)(struct task_struct *task, unsigned int flags, int cpu, void *arg); 71*4882a593Smuzhiyun int (*fmt_getsize)(struct task_struct *task, unsigned int flags, int cpu, void *arg, unsigned long *size); 72*4882a593Smuzhiyun int (*fmt_init)(struct task_struct *task, void *buf, unsigned int flags, int cpu, void *arg); 73*4882a593Smuzhiyun int (*fmt_handler)(struct task_struct *task, void *buf, pfm_ovfl_arg_t *arg, struct pt_regs *regs, unsigned long stamp); 74*4882a593Smuzhiyun int (*fmt_restart)(struct task_struct *task, pfm_ovfl_ctrl_t *ctrl, void *buf, struct pt_regs *regs); 75*4882a593Smuzhiyun int (*fmt_restart_active)(struct task_struct *task, pfm_ovfl_ctrl_t *ctrl, void *buf, struct pt_regs *regs); 76*4882a593Smuzhiyun int (*fmt_exit)(struct task_struct *task, void *buf, struct pt_regs *regs); 77*4882a593Smuzhiyun 78*4882a593Smuzhiyun struct list_head fmt_list; 79*4882a593Smuzhiyun } pfm_buffer_fmt_t; 80*4882a593Smuzhiyun 81*4882a593Smuzhiyun extern int pfm_register_buffer_fmt(pfm_buffer_fmt_t *fmt); 82*4882a593Smuzhiyun extern int pfm_unregister_buffer_fmt(pfm_uuid_t uuid); 83*4882a593Smuzhiyun 84*4882a593Smuzhiyun /* 85*4882a593Smuzhiyun * perfmon interface exported to modules 86*4882a593Smuzhiyun */ 87*4882a593Smuzhiyun extern int pfm_mod_read_pmds(struct task_struct *, void *req, unsigned int nreq, struct pt_regs *regs); 88*4882a593Smuzhiyun extern int pfm_mod_write_pmcs(struct task_struct *, void *req, unsigned int nreq, struct pt_regs *regs); 89*4882a593Smuzhiyun extern int pfm_mod_write_ibrs(struct task_struct *task, void *req, unsigned int nreq, struct pt_regs *regs); 90*4882a593Smuzhiyun extern int pfm_mod_write_dbrs(struct task_struct *task, void *req, unsigned int nreq, struct pt_regs *regs); 91*4882a593Smuzhiyun 92*4882a593Smuzhiyun /* 93*4882a593Smuzhiyun * describe the content of the local_cpu_date->pfm_syst_info field 94*4882a593Smuzhiyun */ 95*4882a593Smuzhiyun #define PFM_CPUINFO_SYST_WIDE 0x1 /* if set a system wide session exists */ 96*4882a593Smuzhiyun #define PFM_CPUINFO_DCR_PP 0x2 /* if set the system wide session has started */ 97*4882a593Smuzhiyun #define PFM_CPUINFO_EXCL_IDLE 0x4 /* the system wide session excludes the idle task */ 98*4882a593Smuzhiyun 99*4882a593Smuzhiyun /* 100*4882a593Smuzhiyun * sysctl control structure. visible to sampling formats 101*4882a593Smuzhiyun */ 102*4882a593Smuzhiyun typedef struct { 103*4882a593Smuzhiyun int debug; /* turn on/off debugging via syslog */ 104*4882a593Smuzhiyun int debug_ovfl; /* turn on/off debug printk in overflow handler */ 105*4882a593Smuzhiyun int fastctxsw; /* turn on/off fast (unsecure) ctxsw */ 106*4882a593Smuzhiyun int expert_mode; /* turn on/off value checking */ 107*4882a593Smuzhiyun } pfm_sysctl_t; 108*4882a593Smuzhiyun extern pfm_sysctl_t pfm_sysctl; 109*4882a593Smuzhiyun 110*4882a593Smuzhiyun 111*4882a593Smuzhiyun #endif /* _ASM_IA64_PERFMON_H */ 112