1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Arm Statistical Profiling Extensions (SPE) support
4  * Copyright (c) 2017-2018, Arm Ltd.
5  */
6 
7 #ifndef INCLUDE__ARM_SPE_PKT_DECODER_H__
8 #define INCLUDE__ARM_SPE_PKT_DECODER_H__
9 
10 #include <stddef.h>
11 #include <stdint.h>
12 
13 #define ARM_SPE_PKT_DESC_MAX		256
14 
15 #define ARM_SPE_NEED_MORE_BYTES		-1
16 #define ARM_SPE_BAD_PACKET		-2
17 
18 enum arm_spe_pkt_type {
19 	ARM_SPE_BAD,
20 	ARM_SPE_PAD,
21 	ARM_SPE_END,
22 	ARM_SPE_TIMESTAMP,
23 	ARM_SPE_ADDRESS,
24 	ARM_SPE_COUNTER,
25 	ARM_SPE_CONTEXT,
26 	ARM_SPE_OP_TYPE,
27 	ARM_SPE_EVENTS,
28 	ARM_SPE_DATA_SOURCE,
29 };
30 
31 struct arm_spe_pkt {
32 	enum arm_spe_pkt_type	type;
33 	unsigned char		index;
34 	uint64_t		payload;
35 };
36 
37 const char *arm_spe_pkt_name(enum arm_spe_pkt_type);
38 
39 int arm_spe_get_packet(const unsigned char *buf, size_t len,
40 		       struct arm_spe_pkt *packet);
41 
42 int arm_spe_pkt_desc(const struct arm_spe_pkt *packet, char *buf, size_t len);
43 #endif
44