blob: 46a8556a9e956a313cb81afbb1cc72c098f532ff [file] [log] [blame]
Tan Xiaojuna54ca192020-05-30 20:24:42 +08001/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * arm_spe_decoder.h: Arm Statistical Profiling Extensions support
4 * Copyright (c) 2019-2020, Arm Ltd.
5 */
6
7#ifndef INCLUDE__ARM_SPE_DECODER_H__
8#define INCLUDE__ARM_SPE_DECODER_H__
9
10#include <stdbool.h>
11#include <stddef.h>
12#include <stdint.h>
13
14#include "arm-spe-pkt-decoder.h"
15
Tan Xiaojuna54ca192020-05-30 20:24:42 +080016enum arm_spe_sample_type {
17 ARM_SPE_L1D_ACCESS = 1 << 0,
18 ARM_SPE_L1D_MISS = 1 << 1,
19 ARM_SPE_LLC_ACCESS = 1 << 2,
20 ARM_SPE_LLC_MISS = 1 << 3,
21 ARM_SPE_TLB_ACCESS = 1 << 4,
22 ARM_SPE_TLB_MISS = 1 << 5,
23 ARM_SPE_BRANCH_MISS = 1 << 6,
24 ARM_SPE_REMOTE_ACCESS = 1 << 7,
25};
26
Leo Yan97ae6662021-02-11 15:38:53 +020027enum arm_spe_op_type {
28 ARM_SPE_LD = 1 << 0,
29 ARM_SPE_ST = 1 << 1,
30};
31
Tan Xiaojuna54ca192020-05-30 20:24:42 +080032struct arm_spe_record {
33 enum arm_spe_sample_type type;
34 int err;
Leo Yan97ae6662021-02-11 15:38:53 +020035 u32 op;
Tan Xiaojuna54ca192020-05-30 20:24:42 +080036 u64 from_ip;
37 u64 to_ip;
38 u64 timestamp;
Leo Yan265cfb92021-02-11 15:38:52 +020039 u64 virt_addr;
40 u64 phys_addr;
German Gomez169de642021-11-11 13:36:24 +000041 u64 context_id;
Tan Xiaojuna54ca192020-05-30 20:24:42 +080042};
43
44struct arm_spe_insn;
45
46struct arm_spe_buffer {
47 const unsigned char *buf;
48 size_t len;
49 u64 offset;
50 u64 trace_nr;
51};
52
53struct arm_spe_params {
54 int (*get_trace)(struct arm_spe_buffer *buffer, void *data);
55 void *data;
56};
57
58struct arm_spe_decoder {
59 int (*get_trace)(struct arm_spe_buffer *buffer, void *data);
60 void *data;
61 struct arm_spe_record record;
62
63 const unsigned char *buf;
64 size_t len;
65
66 struct arm_spe_pkt packet;
67};
68
69struct arm_spe_decoder *arm_spe_decoder_new(struct arm_spe_params *params);
70void arm_spe_decoder_free(struct arm_spe_decoder *decoder);
71
72int arm_spe_decode(struct arm_spe_decoder *decoder);
73
74#endif