1 // SPDX-License-Identifier: GPL-2.0
2 #include "map_symbol.h"
3 #include "mem-events.h"
4 
5 #define E(t, n, s) { .tag = t, .name = n, .sysfs_name = s }
6 
7 static struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX] = {
8 	E("spe-load",	"arm_spe_0/ts_enable=1,pa_enable=1,load_filter=1,store_filter=0,min_latency=%u/",	"arm_spe_0"),
9 	E("spe-store",	"arm_spe_0/ts_enable=1,pa_enable=1,load_filter=0,store_filter=1/",			"arm_spe_0"),
10 	E("spe-ldst",	"arm_spe_0/ts_enable=1,pa_enable=1,load_filter=1,store_filter=1,min_latency=%u/",	"arm_spe_0"),
11 };
12 
13 static char mem_ev_name[100];
14 
15 struct perf_mem_event *perf_mem_events__ptr(int i)
16 {
17 	if (i >= PERF_MEM_EVENTS__MAX)
18 		return NULL;
19 
20 	return &perf_mem_events[i];
21 }
22 
23 const char *perf_mem_events__name(int i, const char *pmu_name __maybe_unused)
24 {
25 	struct perf_mem_event *e = perf_mem_events__ptr(i);
26 
27 	if (i >= PERF_MEM_EVENTS__MAX)
28 		return NULL;
29 
30 	if (i == PERF_MEM_EVENTS__LOAD || i == PERF_MEM_EVENTS__LOAD_STORE)
31 		scnprintf(mem_ev_name, sizeof(mem_ev_name),
32 			  e->name, perf_mem_events__loads_ldlat);
33 	else /* PERF_MEM_EVENTS__STORE */
34 		scnprintf(mem_ev_name, sizeof(mem_ev_name), e->name);
35 
36 	return mem_ev_name;
37 }
38