summaryrefslogtreecommitdiff
path: root/include/soc/qcom/tracer_pkt.h
blob: 2657b79b1ed6f16c5371b6ce41bc1ebb449dd4d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
#ifndef _TRACER_PKT_H_
#define _TRACER_PKT_H_

#include <linux/err.h>
#include <linux/types.h>

#ifdef CONFIG_TRACER_PKT

/**
 * tracer_pkt_init() - initialize the tracer packet
 * @data:		Pointer to the buffer to be initialized with a tracer
 *			packet.
 * @data_len:		Length of the buffer.
 * @client_event_cfg:	Client-specific event configuration mask.
 * @glink_event_cfg:	G-Link-specific event configuration mask.
 * @pkt_priv:		Private/Cookie information to be added to the tracer
 *			packet.
 * @pkt_priv_len:	Length of the private data.
 *
 * This function is used to initialize a buffer with the tracer packet header.
 * The tracer packet header includes the data as passed by the elements in the
 * parameters.
 *
 * Return: 0 on success, standard Linux error codes on failure.
 */
int tracer_pkt_init(void *data, size_t data_len,
		    uint16_t client_event_cfg, uint32_t glink_event_cfg,
		    void *pkt_priv, size_t pkt_priv_len);

/**
 * tracer_pkt_set_event_cfg() - set the event configuration mask in the tracer
 *				packet
 * @data:		Pointer to the buffer to be initialized with event
 *			configuration mask.
 * @client_event_cfg:	Client-specific event configuration mask.
 * @glink_event_cfg:	G-Link-specific event configuration mask.
 *
 * This function is used to initialize a buffer with the event configuration
 * mask as passed by the elements in the parameters.
 *
 * Return: 0 on success, standard Linux error codes on failure.
 */
int tracer_pkt_set_event_cfg(void *data, uint16_t client_event_cfg,
			     uint32_t glink_event_cfg);

/**
 * tracer_pkt_log_event() - log an event specific to the tracer packet
 * @data:	Pointer to the buffer containing tracer packet.
 * @event_id:	Event ID to be logged.
 *
 * This function is used to log an event specific to the tracer packet.
 * The event is logged either into the tracer packet itself or a different
 * tracing mechanism as configured.
 *
 * Return: 0 on success, standard Linux error codes on failure.
 */
int tracer_pkt_log_event(void *data, uint32_t event_id);

/**
 * tracer_pkt_calc_hex_dump_size() - calculate the hex dump size of a tracer
 *				     packet
 * @data:	Pointer to the buffer containing tracer packet.
 * @data_len:	Length of the tracer packet buffer.
 *
 * This function is used to calculate the length of the buffer required to
 * hold the hex dump of the tracer packet.
 *
 * Return: 0 on success, standard Linux error codes on failure.
 */
size_t tracer_pkt_calc_hex_dump_size(void *data, size_t data_len);

/**
 * tracer_pkt_hex_dump() - hex dump the tracer packet into a buffer
 * @buf:	Buffer to contain the hex dump of the tracer packet.
 * @buf_len:	Length of the hex dump buffer.
 * @data:	Buffer containing the tracer packet.
 * @data_len:	Length of the buffer containing the tracer packet.
 *
 * This function is used to dump the contents of the tracer packet into
 * a buffer in a specific hexadecimal format. The hex dump buffer can then
 * be dumped through debugfs.
 *
 * Return: 0 on success, standard Linux error codes on failure.
 */
int tracer_pkt_hex_dump(void *buf, size_t buf_len, void *data, size_t data_len);

#else

static inline int tracer_pkt_init(void *data, size_t data_len,
		    uint16_t client_event_cfg, uint32_t glink_event_cfg,
		    void *pkt_priv, size_t pkt_priv_len)
{
	return -EOPNOTSUPP;
}

static inline int tracer_pkt_set_event_cfg(uint16_t client_event_cfg,
					   uint32_t glink_event_cfg)
{
	return -EOPNOTSUPP;
}

static inline int tracer_pkt_log_event(void *data, uint32_t event_id)
{
	return -EOPNOTSUPP;
}

static inline size_t tracer_pkt_calc_hex_dump_size(void *data, size_t data_len)
{
	return -EOPNOTSUPP;
}

static inline int tracer_pkt_hex_dump(void *buf, size_t buf_len, void *data,
				      size_t data_len)
{
	return -EOPNOTSUPP;
}

#endif /* CONFIG_TRACER_PKT */
#endif /* _TRACER_PKT_H_ */