Path: blob/21.2-virgl/src/freedreno/perfcntrs/freedreno_perfcntr.h
4565 views
/*1* Copyright (C) 2018 Rob Clark <[email protected]>2*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, ARISING FROM,19* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE20* SOFTWARE.21*22* Authors:23* Rob Clark <[email protected]>24*/2526#ifndef FREEDRENO_PERFCNTR_H_27#define FREEDRENO_PERFCNTR_H_2829#include "util/macros.h"3031#ifdef __cplusplus32extern "C" {33#endif3435/*36* Mapping very closely to the AMD_performance_monitor extension, adreno has37* groups of performance counters where each group has N counters, which can38* select from M different countables (things that can be counted), where39* generally M > N.40*/4142/* Describes a single counter: */43struct fd_perfcntr_counter {44/* offset of the select register to choose what to count: */45unsigned select_reg;46/* offset of the lo/hi 32b to read current counter value: */47unsigned counter_reg_lo;48unsigned counter_reg_hi;49/* Optional, most counters don't have enable/clear registers: */50unsigned enable;51unsigned clear;52};5354enum fd_perfcntr_type {55FD_PERFCNTR_TYPE_UINT64,56FD_PERFCNTR_TYPE_UINT,57FD_PERFCNTR_TYPE_FLOAT,58FD_PERFCNTR_TYPE_PERCENTAGE,59FD_PERFCNTR_TYPE_BYTES,60FD_PERFCNTR_TYPE_MICROSECONDS,61FD_PERFCNTR_TYPE_HZ,62FD_PERFCNTR_TYPE_DBM,63FD_PERFCNTR_TYPE_TEMPERATURE,64FD_PERFCNTR_TYPE_VOLTS,65FD_PERFCNTR_TYPE_AMPS,66FD_PERFCNTR_TYPE_WATTS,67};6869/* Whether an average value per frame or a cumulative value should be70* displayed.71*/72enum fd_perfcntr_result_type {73FD_PERFCNTR_RESULT_TYPE_AVERAGE,74FD_PERFCNTR_RESULT_TYPE_CUMULATIVE,75};7677/* Describes a single countable: */78struct fd_perfcntr_countable {79const char *name;80/* selector register enum value to select this countable: */81unsigned selector;8283/* description of the countable: */84enum fd_perfcntr_type query_type;85enum fd_perfcntr_result_type result_type;86};8788/* Describes an entire counter group: */89struct fd_perfcntr_group {90const char *name;91unsigned num_counters;92const struct fd_perfcntr_counter *counters;93unsigned num_countables;94const struct fd_perfcntr_countable *countables;95};9697const struct fd_perfcntr_group *fd_perfcntrs(unsigned gpu_id, unsigned *count);9899#define COUNTER(_sel, _lo, _hi) { \100.select_reg = REG(_sel), .counter_reg_lo = REG(_lo), \101.counter_reg_hi = REG(_hi), \102}103104#define COUNTER2(_sel, _lo, _hi, _en, _clr) { \105.select_reg = REG(_sel), .counter_reg_lo = REG(_lo), \106.counter_reg_hi = REG(_hi), .enable = REG(_en), .clear = REG(_clr), \107}108109#define COUNTABLE(_selector, _query_type, _result_type) { \110.name = #_selector, .selector = _selector, \111.query_type = FD_PERFCNTR_TYPE_##_query_type, \112.result_type = FD_PERFCNTR_RESULT_TYPE_##_result_type, \113}114115#define GROUP(_name, _counters, _countables) { \116.name = _name, .num_counters = ARRAY_SIZE(_counters), \117.counters = _counters, .num_countables = ARRAY_SIZE(_countables), \118.countables = _countables, \119}120121#ifdef __cplusplus122} /* end of extern "C" */123#endif124125#endif /* FREEDRENO_PERFCNTR_H_ */126127128