162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * db-export.h: Support for exporting data suitable for import to a database 462306a36Sopenharmony_ci * Copyright (c) 2014, Intel Corporation. 562306a36Sopenharmony_ci */ 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci#ifndef __PERF_DB_EXPORT_H 862306a36Sopenharmony_ci#define __PERF_DB_EXPORT_H 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#include <linux/types.h> 1162306a36Sopenharmony_ci#include <linux/list.h> 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_cistruct evsel; 1462306a36Sopenharmony_cistruct machine; 1562306a36Sopenharmony_cistruct thread; 1662306a36Sopenharmony_cistruct comm; 1762306a36Sopenharmony_cistruct dso; 1862306a36Sopenharmony_cistruct perf_sample; 1962306a36Sopenharmony_cistruct addr_location; 2062306a36Sopenharmony_cistruct call_return_processor; 2162306a36Sopenharmony_cistruct call_path_root; 2262306a36Sopenharmony_cistruct call_path; 2362306a36Sopenharmony_cistruct call_return; 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_cistruct export_sample { 2662306a36Sopenharmony_ci union perf_event *event; 2762306a36Sopenharmony_ci struct perf_sample *sample; 2862306a36Sopenharmony_ci struct evsel *evsel; 2962306a36Sopenharmony_ci struct addr_location *al; 3062306a36Sopenharmony_ci u64 db_id; 3162306a36Sopenharmony_ci u64 comm_db_id; 3262306a36Sopenharmony_ci u64 dso_db_id; 3362306a36Sopenharmony_ci u64 sym_db_id; 3462306a36Sopenharmony_ci u64 offset; /* ip offset from symbol start */ 3562306a36Sopenharmony_ci u64 addr_dso_db_id; 3662306a36Sopenharmony_ci u64 addr_sym_db_id; 3762306a36Sopenharmony_ci u64 addr_offset; /* addr offset from symbol start */ 3862306a36Sopenharmony_ci u64 call_path_id; 3962306a36Sopenharmony_ci}; 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_cistruct db_export { 4262306a36Sopenharmony_ci int (*export_evsel)(struct db_export *dbe, struct evsel *evsel); 4362306a36Sopenharmony_ci int (*export_machine)(struct db_export *dbe, struct machine *machine); 4462306a36Sopenharmony_ci int (*export_thread)(struct db_export *dbe, struct thread *thread, 4562306a36Sopenharmony_ci u64 main_thread_db_id, struct machine *machine); 4662306a36Sopenharmony_ci int (*export_comm)(struct db_export *dbe, struct comm *comm, 4762306a36Sopenharmony_ci struct thread *thread); 4862306a36Sopenharmony_ci int (*export_comm_thread)(struct db_export *dbe, u64 db_id, 4962306a36Sopenharmony_ci struct comm *comm, struct thread *thread); 5062306a36Sopenharmony_ci int (*export_dso)(struct db_export *dbe, struct dso *dso, 5162306a36Sopenharmony_ci struct machine *machine); 5262306a36Sopenharmony_ci int (*export_symbol)(struct db_export *dbe, struct symbol *sym, 5362306a36Sopenharmony_ci struct dso *dso); 5462306a36Sopenharmony_ci int (*export_branch_type)(struct db_export *dbe, u32 branch_type, 5562306a36Sopenharmony_ci const char *name); 5662306a36Sopenharmony_ci int (*export_sample)(struct db_export *dbe, struct export_sample *es); 5762306a36Sopenharmony_ci int (*export_call_path)(struct db_export *dbe, struct call_path *cp); 5862306a36Sopenharmony_ci int (*export_call_return)(struct db_export *dbe, 5962306a36Sopenharmony_ci struct call_return *cr); 6062306a36Sopenharmony_ci int (*export_context_switch)(struct db_export *dbe, u64 db_id, 6162306a36Sopenharmony_ci struct machine *machine, 6262306a36Sopenharmony_ci struct perf_sample *sample, 6362306a36Sopenharmony_ci u64 th_out_id, u64 comm_out_id, 6462306a36Sopenharmony_ci u64 th_in_id, u64 comm_in_id, int flags); 6562306a36Sopenharmony_ci struct call_return_processor *crp; 6662306a36Sopenharmony_ci struct call_path_root *cpr; 6762306a36Sopenharmony_ci u64 evsel_last_db_id; 6862306a36Sopenharmony_ci u64 machine_last_db_id; 6962306a36Sopenharmony_ci u64 thread_last_db_id; 7062306a36Sopenharmony_ci u64 comm_last_db_id; 7162306a36Sopenharmony_ci u64 comm_thread_last_db_id; 7262306a36Sopenharmony_ci u64 dso_last_db_id; 7362306a36Sopenharmony_ci u64 symbol_last_db_id; 7462306a36Sopenharmony_ci u64 sample_last_db_id; 7562306a36Sopenharmony_ci u64 call_path_last_db_id; 7662306a36Sopenharmony_ci u64 call_return_last_db_id; 7762306a36Sopenharmony_ci u64 context_switch_last_db_id; 7862306a36Sopenharmony_ci}; 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_ciint db_export__init(struct db_export *dbe); 8162306a36Sopenharmony_civoid db_export__exit(struct db_export *dbe); 8262306a36Sopenharmony_ciint db_export__evsel(struct db_export *dbe, struct evsel *evsel); 8362306a36Sopenharmony_ciint db_export__machine(struct db_export *dbe, struct machine *machine); 8462306a36Sopenharmony_ciint db_export__thread(struct db_export *dbe, struct thread *thread, 8562306a36Sopenharmony_ci struct machine *machine, struct thread *main_thread); 8662306a36Sopenharmony_ciint db_export__comm(struct db_export *dbe, struct comm *comm, 8762306a36Sopenharmony_ci struct thread *thread); 8862306a36Sopenharmony_ciint db_export__exec_comm(struct db_export *dbe, struct comm *comm, 8962306a36Sopenharmony_ci struct thread *main_thread); 9062306a36Sopenharmony_ciint db_export__comm_thread(struct db_export *dbe, struct comm *comm, 9162306a36Sopenharmony_ci struct thread *thread); 9262306a36Sopenharmony_ciint db_export__dso(struct db_export *dbe, struct dso *dso, 9362306a36Sopenharmony_ci struct machine *machine); 9462306a36Sopenharmony_ciint db_export__symbol(struct db_export *dbe, struct symbol *sym, 9562306a36Sopenharmony_ci struct dso *dso); 9662306a36Sopenharmony_ciint db_export__branch_type(struct db_export *dbe, u32 branch_type, 9762306a36Sopenharmony_ci const char *name); 9862306a36Sopenharmony_ciint db_export__sample(struct db_export *dbe, union perf_event *event, 9962306a36Sopenharmony_ci struct perf_sample *sample, struct evsel *evsel, 10062306a36Sopenharmony_ci struct addr_location *al, struct addr_location *addr_al); 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_ciint db_export__branch_types(struct db_export *dbe); 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_ciint db_export__call_path(struct db_export *dbe, struct call_path *cp); 10562306a36Sopenharmony_ciint db_export__call_return(struct db_export *dbe, struct call_return *cr, 10662306a36Sopenharmony_ci u64 *parent_db_id); 10762306a36Sopenharmony_ciint db_export__switch(struct db_export *dbe, union perf_event *event, 10862306a36Sopenharmony_ci struct perf_sample *sample, struct machine *machine); 10962306a36Sopenharmony_ci 11062306a36Sopenharmony_ci#endif 111