Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* 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
16enum arm_spe_events {
17 EV_EXCEPTION_GEN = 0,
18 EV_RETIRED = 1,
19 EV_L1D_ACCESS = 2,
20 EV_L1D_REFILL = 3,
21 EV_TLB_ACCESS = 4,
22 EV_TLB_WALK = 5,
23 EV_NOT_TAKEN = 6,
24 EV_MISPRED = 7,
25 EV_LLC_ACCESS = 8,
26 EV_LLC_MISS = 9,
27 EV_REMOTE_ACCESS = 10,
28 EV_ALIGNMENT = 11,
29 EV_PARTIAL_PREDICATE = 17,
30 EV_EMPTY_PREDICATE = 18,
31};
32
33enum arm_spe_sample_type {
34 ARM_SPE_L1D_ACCESS = 1 << 0,
35 ARM_SPE_L1D_MISS = 1 << 1,
36 ARM_SPE_LLC_ACCESS = 1 << 2,
37 ARM_SPE_LLC_MISS = 1 << 3,
38 ARM_SPE_TLB_ACCESS = 1 << 4,
39 ARM_SPE_TLB_MISS = 1 << 5,
40 ARM_SPE_BRANCH_MISS = 1 << 6,
41 ARM_SPE_REMOTE_ACCESS = 1 << 7,
42};
43
44struct arm_spe_record {
45 enum arm_spe_sample_type type;
46 int err;
47 u64 from_ip;
48 u64 to_ip;
49 u64 timestamp;
50};
51
52struct arm_spe_insn;
53
54struct arm_spe_buffer {
55 const unsigned char *buf;
56 size_t len;
57 u64 offset;
58 u64 trace_nr;
59};
60
61struct arm_spe_params {
62 int (*get_trace)(struct arm_spe_buffer *buffer, void *data);
63 void *data;
64};
65
66struct arm_spe_decoder {
67 int (*get_trace)(struct arm_spe_buffer *buffer, void *data);
68 void *data;
69 struct arm_spe_record record;
70
71 const unsigned char *buf;
72 size_t len;
73
74 struct arm_spe_pkt packet;
75};
76
77struct arm_spe_decoder *arm_spe_decoder_new(struct arm_spe_params *params);
78void arm_spe_decoder_free(struct arm_spe_decoder *decoder);
79
80int arm_spe_decode(struct arm_spe_decoder *decoder);
81
82#endif