1 /*
2  * Copyright © 2014 Advanced Micro Devices, Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person
5  * obtaining a copy of this software and associated documentation
6  * files (the "Software"), to deal in the Software without
7  * restriction, including without limitation the rights to use, copy,
8  * modify, merge, publish, distribute, sublicense, and/or sell copies
9  * of the Software, and to permit persons to whom the Software is
10  * furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice (including
13  * the next paragraph) shall be included in all copies or substantial
14  * portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23  * DEALINGS IN THE SOFTWARE.
24  */
25 
26 #ifndef PMC_TABLE_H
27 #define PMC_TABLE_H
28 
29 #include "libhsakmt.h"
30 
31 enum perf_block_id {
32 	PERFCOUNTER_BLOCKID__FIRST = 0,
33 	/* non-privileged */
34 	PERFCOUNTER_BLOCKID__CB = PERFCOUNTER_BLOCKID__FIRST,
35 	PERFCOUNTER_BLOCKID__CPC,
36 	PERFCOUNTER_BLOCKID__CPF,
37 	PERFCOUNTER_BLOCKID__CPG,
38 	PERFCOUNTER_BLOCKID__DB,
39 	PERFCOUNTER_BLOCKID__GDS,
40 	PERFCOUNTER_BLOCKID__GRBM,
41 	PERFCOUNTER_BLOCKID__GRBMSE,
42 	PERFCOUNTER_BLOCKID__IA,
43 	PERFCOUNTER_BLOCKID__MC,
44 	PERFCOUNTER_BLOCKID__PASC,
45 	PERFCOUNTER_BLOCKID__PASU,
46 	PERFCOUNTER_BLOCKID__SPI,
47 	PERFCOUNTER_BLOCKID__SRBM,
48 	PERFCOUNTER_BLOCKID__SQ,
49 	PERFCOUNTER_BLOCKID__SX,
50 	PERFCOUNTER_BLOCKID__TA,
51 	PERFCOUNTER_BLOCKID__TCA,
52 	PERFCOUNTER_BLOCKID__TCC,
53 	PERFCOUNTER_BLOCKID__TCP,
54 	PERFCOUNTER_BLOCKID__TCS,
55 	PERFCOUNTER_BLOCKID__TD,
56 	PERFCOUNTER_BLOCKID__VGT,
57 	PERFCOUNTER_BLOCKID__WD,
58 	/* privileged */
59 	PERFCOUNTER_BLOCKID__IOMMUV2,
60 	PERFCOUNTER_BLOCKID__MAX
61 };
62 
63 struct perf_counter_block {
64 	uint32_t    num_of_slots;
65 	uint32_t    num_of_counters;
66 	uint32_t    *counter_ids;
67 	uint32_t    counter_size_in_bits;
68 	uint64_t    counter_mask;
69 };
70 
71 HSAKMT_STATUS alloc_pmc_blocks(void);
72 void free_pmc_blocks(void);
73 uint32_t pmc_table_get_max_concurrent(int block_id);
74 
75 HSAKMT_STATUS get_block_properties(uint32_t node_id,
76 				   enum perf_block_id block_id,
77 				   struct perf_counter_block *block);
78 
79 #endif // PMC_TABLE_H
80