Path: blob/21.2-virgl/src/intel/perf/intel_perf_private.h
4547 views
/*1* Copyright © 2019 Intel Corporation2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS20* IN THE SOFTWARE.21*/2223#ifndef INTEL_PERF_PRIVATE_H24#define INTEL_PERF_PRIVATE_H2526#include "intel_perf.h"2728static inline uint64_t to_user_pointer(void *ptr)29{30return (uintptr_t) ptr;31}3233static inline uint64_t to_const_user_pointer(const void *ptr)34{35return (uintptr_t) ptr;36}3738static inline void39intel_perf_query_add_stat_reg(struct intel_perf_query_info *query, uint32_t reg,40uint32_t numerator, uint32_t denominator,41const char *name, const char *description)42{43struct intel_perf_query_counter *counter;4445assert(query->n_counters < query->max_counters);4647counter = &query->counters[query->n_counters];48counter->name = counter->symbol_name = name;49counter->desc = description;50counter->type = INTEL_PERF_COUNTER_TYPE_RAW;51counter->data_type = INTEL_PERF_COUNTER_DATA_TYPE_UINT64;52counter->offset = sizeof(uint64_t) * query->n_counters;53counter->pipeline_stat.reg = reg;54counter->pipeline_stat.numerator = numerator;55counter->pipeline_stat.denominator = denominator;5657query->n_counters++;58}5960static inline void61intel_perf_query_add_basic_stat_reg(struct intel_perf_query_info *query,62uint32_t reg, const char *name)63{64intel_perf_query_add_stat_reg(query, reg, 1, 1, name, name);65}6667static inline struct intel_perf_query_info *68intel_perf_append_query_info(struct intel_perf_config *perf, int max_counters)69{70struct intel_perf_query_info *query;7172perf->queries = reralloc(perf, perf->queries,73struct intel_perf_query_info,74++perf->n_queries);75query = &perf->queries[perf->n_queries - 1];76memset(query, 0, sizeof(*query));7778query->perf = perf;7980if (max_counters > 0) {81query->max_counters = max_counters;82query->counters =83rzalloc_array(perf, struct intel_perf_query_counter, max_counters);84}8586return query;87}8889void intel_perf_register_mdapi_statistic_query(struct intel_perf_config *perf_cfg,90const struct intel_device_info *devinfo);91void intel_perf_register_mdapi_oa_query(struct intel_perf_config *perf,92const struct intel_device_info *devinfo);939495#endif /* INTEL_PERF_PRIVATE_H */969798