12025cf9eSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 20db15b1eSAdrian Hunter /* 30db15b1eSAdrian Hunter * db-export.h: Support for exporting data suitable for import to a database 40db15b1eSAdrian Hunter * Copyright (c) 2014, Intel Corporation. 50db15b1eSAdrian Hunter */ 60db15b1eSAdrian Hunter 70db15b1eSAdrian Hunter #ifndef __PERF_DB_EXPORT_H 80db15b1eSAdrian Hunter #define __PERF_DB_EXPORT_H 90db15b1eSAdrian Hunter 100db15b1eSAdrian Hunter #include <linux/types.h> 11758008b2SAdrian Hunter #include <linux/list.h> 120db15b1eSAdrian Hunter 130db15b1eSAdrian Hunter struct perf_evsel; 140db15b1eSAdrian Hunter struct machine; 150db15b1eSAdrian Hunter struct thread; 160db15b1eSAdrian Hunter struct comm; 170db15b1eSAdrian Hunter struct dso; 180db15b1eSAdrian Hunter struct perf_sample; 190db15b1eSAdrian Hunter struct addr_location; 2088f50d60SAdrian Hunter struct call_return_processor; 210a3eba3aSChris Phlipot struct call_path_root; 2288f50d60SAdrian Hunter struct call_path; 2388f50d60SAdrian Hunter struct call_return; 240db15b1eSAdrian Hunter 250db15b1eSAdrian Hunter struct export_sample { 260db15b1eSAdrian Hunter union perf_event *event; 270db15b1eSAdrian Hunter struct perf_sample *sample; 280db15b1eSAdrian Hunter struct perf_evsel *evsel; 290db15b1eSAdrian Hunter struct addr_location *al; 300db15b1eSAdrian Hunter u64 db_id; 310db15b1eSAdrian Hunter u64 comm_db_id; 320db15b1eSAdrian Hunter u64 dso_db_id; 330db15b1eSAdrian Hunter u64 sym_db_id; 340db15b1eSAdrian Hunter u64 offset; /* ip offset from symbol start */ 350db15b1eSAdrian Hunter u64 addr_dso_db_id; 360db15b1eSAdrian Hunter u64 addr_sym_db_id; 370db15b1eSAdrian Hunter u64 addr_offset; /* addr offset from symbol start */ 38568850eaSChris Phlipot u64 call_path_id; 390db15b1eSAdrian Hunter }; 400db15b1eSAdrian Hunter 410db15b1eSAdrian Hunter struct db_export { 420db15b1eSAdrian Hunter int (*export_evsel)(struct db_export *dbe, struct perf_evsel *evsel); 430db15b1eSAdrian Hunter int (*export_machine)(struct db_export *dbe, struct machine *machine); 440db15b1eSAdrian Hunter int (*export_thread)(struct db_export *dbe, struct thread *thread, 450db15b1eSAdrian Hunter u64 main_thread_db_id, struct machine *machine); 468ebf5cc0SAdrian Hunter int (*export_comm)(struct db_export *dbe, struct comm *comm, 478ebf5cc0SAdrian Hunter struct thread *thread); 480db15b1eSAdrian Hunter int (*export_comm_thread)(struct db_export *dbe, u64 db_id, 490db15b1eSAdrian Hunter struct comm *comm, struct thread *thread); 500db15b1eSAdrian Hunter int (*export_dso)(struct db_export *dbe, struct dso *dso, 510db15b1eSAdrian Hunter struct machine *machine); 520db15b1eSAdrian Hunter int (*export_symbol)(struct db_export *dbe, struct symbol *sym, 530db15b1eSAdrian Hunter struct dso *dso); 54f2bff007SAdrian Hunter int (*export_branch_type)(struct db_export *dbe, u32 branch_type, 55f2bff007SAdrian Hunter const char *name); 560db15b1eSAdrian Hunter int (*export_sample)(struct db_export *dbe, struct export_sample *es); 5788f50d60SAdrian Hunter int (*export_call_path)(struct db_export *dbe, struct call_path *cp); 5888f50d60SAdrian Hunter int (*export_call_return)(struct db_export *dbe, 5988f50d60SAdrian Hunter struct call_return *cr); 60*abde8722SAdrian Hunter int (*export_context_switch)(struct db_export *dbe, u64 db_id, 61*abde8722SAdrian Hunter struct machine *machine, 62*abde8722SAdrian Hunter struct perf_sample *sample, 63*abde8722SAdrian Hunter u64 th_out_id, u64 comm_out_id, 64*abde8722SAdrian Hunter u64 th_in_id, u64 comm_in_id, int flags); 6588f50d60SAdrian Hunter struct call_return_processor *crp; 660a3eba3aSChris Phlipot struct call_path_root *cpr; 670db15b1eSAdrian Hunter u64 evsel_last_db_id; 680db15b1eSAdrian Hunter u64 machine_last_db_id; 690db15b1eSAdrian Hunter u64 thread_last_db_id; 700db15b1eSAdrian Hunter u64 comm_last_db_id; 710db15b1eSAdrian Hunter u64 comm_thread_last_db_id; 720db15b1eSAdrian Hunter u64 dso_last_db_id; 730db15b1eSAdrian Hunter u64 symbol_last_db_id; 740db15b1eSAdrian Hunter u64 sample_last_db_id; 7588f50d60SAdrian Hunter u64 call_path_last_db_id; 7688f50d60SAdrian Hunter u64 call_return_last_db_id; 77*abde8722SAdrian Hunter u64 context_switch_last_db_id; 780db15b1eSAdrian Hunter }; 790db15b1eSAdrian Hunter 800db15b1eSAdrian Hunter int db_export__init(struct db_export *dbe); 810db15b1eSAdrian Hunter void db_export__exit(struct db_export *dbe); 820db15b1eSAdrian Hunter int db_export__evsel(struct db_export *dbe, struct perf_evsel *evsel); 830db15b1eSAdrian Hunter int db_export__machine(struct db_export *dbe, struct machine *machine); 840db15b1eSAdrian Hunter int db_export__thread(struct db_export *dbe, struct thread *thread, 851ed11958SAdrian Hunter struct machine *machine, struct thread *main_thread); 8680859c94SAdrian Hunter int db_export__comm(struct db_export *dbe, struct comm *comm, 8780859c94SAdrian Hunter struct thread *thread); 88208032feSAdrian Hunter int db_export__exec_comm(struct db_export *dbe, struct comm *comm, 890db15b1eSAdrian Hunter struct thread *main_thread); 900db15b1eSAdrian Hunter int db_export__comm_thread(struct db_export *dbe, struct comm *comm, 910db15b1eSAdrian Hunter struct thread *thread); 920db15b1eSAdrian Hunter int db_export__dso(struct db_export *dbe, struct dso *dso, 930db15b1eSAdrian Hunter struct machine *machine); 940db15b1eSAdrian Hunter int db_export__symbol(struct db_export *dbe, struct symbol *sym, 950db15b1eSAdrian Hunter struct dso *dso); 96f2bff007SAdrian Hunter int db_export__branch_type(struct db_export *dbe, u32 branch_type, 97f2bff007SAdrian Hunter const char *name); 980db15b1eSAdrian Hunter int db_export__sample(struct db_export *dbe, union perf_event *event, 990db15b1eSAdrian Hunter struct perf_sample *sample, struct perf_evsel *evsel, 1007327259dSArnaldo Carvalho de Melo struct addr_location *al); 1010db15b1eSAdrian Hunter 102f2bff007SAdrian Hunter int db_export__branch_types(struct db_export *dbe); 103f2bff007SAdrian Hunter 10488f50d60SAdrian Hunter int db_export__call_path(struct db_export *dbe, struct call_path *cp); 105f435887eSAdrian Hunter int db_export__call_return(struct db_export *dbe, struct call_return *cr, 106f435887eSAdrian Hunter u64 *parent_db_id); 107*abde8722SAdrian Hunter int db_export__switch(struct db_export *dbe, union perf_event *event, 108*abde8722SAdrian Hunter struct perf_sample *sample, struct machine *machine); 10988f50d60SAdrian Hunter 1100db15b1eSAdrian Hunter #endif 111