17ec681f3Smrg/* 27ec681f3Smrg * Copyright © 2019 Intel Corporation 37ec681f3Smrg * 47ec681f3Smrg * Permission is hereby granted, free of charge, to any person obtaining a 57ec681f3Smrg * copy of this software and associated documentation files (the "Software"), 67ec681f3Smrg * to deal in the Software without restriction, including without limitation 77ec681f3Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 87ec681f3Smrg * and/or sell copies of the Software, and to permit persons to whom the 97ec681f3Smrg * Software is furnished to do so, subject to the following conditions: 107ec681f3Smrg * 117ec681f3Smrg * The above copyright notice and this permission notice (including the next 127ec681f3Smrg * paragraph) shall be included in all copies or substantial portions of the 137ec681f3Smrg * Software. 147ec681f3Smrg * 157ec681f3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 167ec681f3Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 177ec681f3Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 187ec681f3Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 197ec681f3Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 207ec681f3Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 217ec681f3Smrg * IN THE SOFTWARE. 227ec681f3Smrg */ 237ec681f3Smrg 247ec681f3Smrg#ifndef INTEL_PERF_PRIVATE_H 257ec681f3Smrg#define INTEL_PERF_PRIVATE_H 267ec681f3Smrg 277ec681f3Smrg#include "intel_perf.h" 287ec681f3Smrg 297ec681f3Smrgstatic inline uint64_t to_user_pointer(void *ptr) 307ec681f3Smrg{ 317ec681f3Smrg return (uintptr_t) ptr; 327ec681f3Smrg} 337ec681f3Smrg 347ec681f3Smrgstatic inline uint64_t to_const_user_pointer(const void *ptr) 357ec681f3Smrg{ 367ec681f3Smrg return (uintptr_t) ptr; 377ec681f3Smrg} 387ec681f3Smrg 397ec681f3Smrgstatic inline void 407ec681f3Smrgintel_perf_query_add_stat_reg(struct intel_perf_query_info *query, uint32_t reg, 417ec681f3Smrg uint32_t numerator, uint32_t denominator, 427ec681f3Smrg const char *name, const char *description) 437ec681f3Smrg{ 447ec681f3Smrg struct intel_perf_query_counter *counter; 457ec681f3Smrg 467ec681f3Smrg assert(query->n_counters < query->max_counters); 477ec681f3Smrg 487ec681f3Smrg counter = &query->counters[query->n_counters]; 497ec681f3Smrg counter->name = counter->symbol_name = name; 507ec681f3Smrg counter->desc = description; 517ec681f3Smrg counter->type = INTEL_PERF_COUNTER_TYPE_RAW; 527ec681f3Smrg counter->data_type = INTEL_PERF_COUNTER_DATA_TYPE_UINT64; 537ec681f3Smrg counter->offset = sizeof(uint64_t) * query->n_counters; 547ec681f3Smrg counter->pipeline_stat.reg = reg; 557ec681f3Smrg counter->pipeline_stat.numerator = numerator; 567ec681f3Smrg counter->pipeline_stat.denominator = denominator; 577ec681f3Smrg 587ec681f3Smrg query->n_counters++; 597ec681f3Smrg} 607ec681f3Smrg 617ec681f3Smrgstatic inline void 627ec681f3Smrgintel_perf_query_add_basic_stat_reg(struct intel_perf_query_info *query, 637ec681f3Smrg uint32_t reg, const char *name) 647ec681f3Smrg{ 657ec681f3Smrg intel_perf_query_add_stat_reg(query, reg, 1, 1, name, name); 667ec681f3Smrg} 677ec681f3Smrg 687ec681f3Smrgstatic inline struct intel_perf_query_info * 697ec681f3Smrgintel_perf_append_query_info(struct intel_perf_config *perf, int max_counters) 707ec681f3Smrg{ 717ec681f3Smrg struct intel_perf_query_info *query; 727ec681f3Smrg 737ec681f3Smrg perf->queries = reralloc(perf, perf->queries, 747ec681f3Smrg struct intel_perf_query_info, 757ec681f3Smrg ++perf->n_queries); 767ec681f3Smrg query = &perf->queries[perf->n_queries - 1]; 777ec681f3Smrg memset(query, 0, sizeof(*query)); 787ec681f3Smrg 797ec681f3Smrg query->perf = perf; 807ec681f3Smrg 817ec681f3Smrg if (max_counters > 0) { 827ec681f3Smrg query->max_counters = max_counters; 837ec681f3Smrg query->counters = 847ec681f3Smrg rzalloc_array(perf, struct intel_perf_query_counter, max_counters); 857ec681f3Smrg } 867ec681f3Smrg 877ec681f3Smrg return query; 887ec681f3Smrg} 897ec681f3Smrg 907ec681f3Smrgvoid intel_perf_register_mdapi_statistic_query(struct intel_perf_config *perf_cfg, 917ec681f3Smrg const struct intel_device_info *devinfo); 927ec681f3Smrgvoid intel_perf_register_mdapi_oa_query(struct intel_perf_config *perf, 937ec681f3Smrg const struct intel_device_info *devinfo); 947ec681f3Smrg 957ec681f3Smrg 967ec681f3Smrg#endif /* INTEL_PERF_PRIVATE_H */ 97