1 /*******************************************************************************
2 Copyright (C) Marvell International Ltd. and its affiliates
4 This software file (the "File") is owned and distributed by Marvell
5 International Ltd. and/or its affiliates ("Marvell") under the following
6 alternative licensing terms. Once you have made an election to distribute the
7 File under one of the following license alternatives, please (i) delete this
8 introductory statement regarding license alternatives, (ii) delete the two
9 license alternatives that you have not elected to use and (iii) preserve the
10 Marvell copyright notice above.
13 ********************************************************************************
14 Marvell GPL License Option
16 If you received this File from Marvell, you may opt to use, redistribute and/or
17 modify this File in accordance with the terms and conditions of the General
18 Public License Version 2, June 1991 (the "GPL License"), a copy of which is
19 available along with the File in the license.txt file or by writing to the Free
20 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or
21 on the worldwide web at http://www.gnu.org/licenses/gpl.txt.
23 THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED
24 WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY
25 DISCLAIMED. The GPL License provides additional details about this warranty
27 *******************************************************************************/
28 #ifndef __mvCpuL2Cntrs_h__
29 #define __mvCpuL2Cntrs_h__
35 #define MV_CPU_L2_CNTRS_NUM 2
39 MV_CPU_L2_CNTRS_ENABLE = 0,
40 MV_CPU_L2_CNTRS_DATA_REQ,
41 MV_CPU_L2_CNTRS_DATA_MISS_REQ,
42 MV_CPU_L2_CNTRS_INST_REQ,
43 MV_CPU_L2_CNTRS_INST_MISS_REQ,
44 MV_CPU_L2_CNTRS_DATA_READ_REQ,
45 MV_CPU_L2_CNTRS_DATA_READ_MISS_REQ,
46 MV_CPU_L2_CNTRS_DATA_WRITE_REQ,
47 MV_CPU_L2_CNTRS_DATA_WRITE_MISS_REQ,
48 MV_CPU_L2_CNTRS_RESERVED,
49 MV_CPU_L2_CNTRS_DIRTY_EVICT_REQ,
50 MV_CPU_L2_CNTRS_EVICT_BUFF_STALL,
51 MV_CPU_L2_CNTRS_ACTIVE_CYCLES,
53 } MV_CPU_L2_CNTRS_OPS;
58 MV_CPU_L2_CNTRS_OPS operation;
62 } MV_CPU_L2_CNTRS_ENTRY;
68 MV_U32 num_of_measurements;
69 MV_U32 avg_sample_count;
70 MV_U64 counters_before[MV_CPU_L2_CNTRS_NUM];
71 MV_U64 counters_after[MV_CPU_L2_CNTRS_NUM];
72 MV_U64 counters_sum[MV_CPU_L2_CNTRS_NUM];
74 } MV_CPU_L2_CNTRS_EVENT;
77 MV_STATUS mvCpuL2CntrsProgram(int counter, MV_CPU_L2_CNTRS_OPS op,
78 char* name, MV_U32 overhead);
79 void mvCpuL2CntrsInit(void);
80 MV_CPU_L2_CNTRS_EVENT* mvCpuL2CntrsEventCreate(char* name, MV_U32 print_threshold);
81 void mvCpuL2CntrsEventDelete(MV_CPU_L2_CNTRS_EVENT* event);
82 void mvCpuL2CntrsReset(void);
83 void mvCpuL2CntrsShow(MV_CPU_L2_CNTRS_EVENT* pEvent);
84 void mvCpuL2CntrsEventClear(MV_CPU_L2_CNTRS_EVENT* pEvent);
86 static INLINE MV_U64 mvCpuL2CntrsRead(const int counter)
88 MV_U32 low = 0, high = 0;
93 MV_ASM ("mrc p15, 6, %0, c15, c13, 0" : "=r" (low));
94 MV_ASM ("mrc p15, 6, %0, c15, c13, 1" : "=r" (high));
98 MV_ASM ("mrc p15, 6, %0, c15, c13, 2" : "=r" (low));
99 MV_ASM ("mrc p15, 6, %0, c15, c13, 3" : "=r" (high));
103 mvOsPrintf("mvCpuL2CntrsRead: bad counter number (%d)\n", counter);
105 return (((MV_U64)high << 32 ) | low);
109 static INLINE void mvCpuL2CntrsReadBefore(MV_CPU_L2_CNTRS_EVENT* pEvent)
113 for(i=0; i<MV_CPU_L2_CNTRS_NUM; i++)
114 pEvent->counters_before[i] = mvCpuL2CntrsRead(i);
117 static INLINE void mvCpuL2CntrsReadAfter(MV_CPU_L2_CNTRS_EVENT* pEvent)
121 for(i=0; i<MV_CPU_L2_CNTRS_NUM; i++)
123 pEvent->counters_after[i] = mvCpuL2CntrsRead(i);
124 pEvent->counters_sum[i] += (pEvent->counters_after[i] - pEvent->counters_before[i]);
126 pEvent->num_of_measurements++;
130 #ifdef CONFIG_MV_CPU_L2_PERF_CNTRS
132 #define MV_CPU_L2_CNTRS_READ(counter) mvCpuL2CntrsRead(counter)
134 #define MV_CPU_L2_CNTRS_START(event) mvCpuL2CntrsReadBefore(event)
136 #define MV_CPU_L2_CNTRS_STOP(event) mvCpuL2CntrsReadAfter(event)
138 #define MV_CPU_L2_CNTRS_SHOW(event) mvCpuL2CntrsShow(event)
142 #define MV_CPU_L2_CNTRS_READ(counter)
143 #define MV_CPU_L2_CNTRS_START(event)
144 #define MV_CPU_L2_CNTRS_STOP(event)
145 #define MV_CPU_L2_CNTRS_SHOW(event)
147 #endif /* CONFIG_MV_CPU_L2_PERF_CNTRS */
150 #endif /* __mvCpuL2Cntrs_h__ */