Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * arm_spe_decoder.h: Arm Statistical Profiling Extensions support
0004  * Copyright (c) 2019-2020, Arm Ltd.
0005  */
0006 
0007 #ifndef INCLUDE__ARM_SPE_DECODER_H__
0008 #define INCLUDE__ARM_SPE_DECODER_H__
0009 
0010 #include <stdbool.h>
0011 #include <stddef.h>
0012 #include <stdint.h>
0013 
0014 #include "arm-spe-pkt-decoder.h"
0015 
0016 enum arm_spe_sample_type {
0017     ARM_SPE_L1D_ACCESS  = 1 << 0,
0018     ARM_SPE_L1D_MISS    = 1 << 1,
0019     ARM_SPE_LLC_ACCESS  = 1 << 2,
0020     ARM_SPE_LLC_MISS    = 1 << 3,
0021     ARM_SPE_TLB_ACCESS  = 1 << 4,
0022     ARM_SPE_TLB_MISS    = 1 << 5,
0023     ARM_SPE_BRANCH_MISS = 1 << 6,
0024     ARM_SPE_REMOTE_ACCESS   = 1 << 7,
0025 };
0026 
0027 enum arm_spe_op_type {
0028     ARM_SPE_LD      = 1 << 0,
0029     ARM_SPE_ST      = 1 << 1,
0030 };
0031 
0032 enum arm_spe_neoverse_data_source {
0033     ARM_SPE_NV_L1D       = 0x0,
0034     ARM_SPE_NV_L2        = 0x8,
0035     ARM_SPE_NV_PEER_CORE     = 0x9,
0036     ARM_SPE_NV_LOCAL_CLUSTER = 0xa,
0037     ARM_SPE_NV_SYS_CACHE     = 0xb,
0038     ARM_SPE_NV_PEER_CLUSTER  = 0xc,
0039     ARM_SPE_NV_REMOTE    = 0xd,
0040     ARM_SPE_NV_DRAM      = 0xe,
0041 };
0042 
0043 struct arm_spe_record {
0044     enum arm_spe_sample_type type;
0045     int err;
0046     u32 op;
0047     u32 latency;
0048     u64 from_ip;
0049     u64 to_ip;
0050     u64 timestamp;
0051     u64 virt_addr;
0052     u64 phys_addr;
0053     u64 context_id;
0054     u16 source;
0055 };
0056 
0057 struct arm_spe_insn;
0058 
0059 struct arm_spe_buffer {
0060     const unsigned char *buf;
0061     size_t len;
0062     u64 offset;
0063     u64 trace_nr;
0064 };
0065 
0066 struct arm_spe_params {
0067     int (*get_trace)(struct arm_spe_buffer *buffer, void *data);
0068     void *data;
0069 };
0070 
0071 struct arm_spe_decoder {
0072     int (*get_trace)(struct arm_spe_buffer *buffer, void *data);
0073     void *data;
0074     struct arm_spe_record record;
0075 
0076     const unsigned char *buf;
0077     size_t len;
0078 
0079     struct arm_spe_pkt packet;
0080 };
0081 
0082 struct arm_spe_decoder *arm_spe_decoder_new(struct arm_spe_params *params);
0083 void arm_spe_decoder_free(struct arm_spe_decoder *decoder);
0084 
0085 int arm_spe_decode(struct arm_spe_decoder *decoder);
0086 
0087 #endif