blob: 752af0692c700794eb8ac85961ff669062ca36b1 [file] [log] [blame]
Sundarajan Srinivasan1b03fe22014-12-02 13:20:56 -08001/*
2 **************************************************************************
3 * Copyright (c) 2014, The Linux Foundation. All rights reserved.
4 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all copies.
7 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
13 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14 **************************************************************************
15 */
16
17/*
18 * profpkt.h
19 * profile packet header to communicate with the profiler display tool
20 *
21 * IMPORTANT! There is a parallel verison of this file for both linux driver and profiler display tool
22 *
23 * Both this file and profilesample.h file must be placed
24 * in dirver/.../nss (for linux driver) and as well as in tools/profiler/include directories
25 * (for profilerd.c of profilerd and profile.cpp:1600::on_packet of profile tool).
26 *
27 * Ubi32 CPU Profiler packet formats for communication between the linux proc driver and the profiler display tool
28 */
29
30#include "profilesample.h" // common definitions
31
32#define PROFILE_PORT 51080
33#define PROFILE_CONTROL_PORT 51081
34#define PROFILE_POSIX_NAME_LENGTH 32
35
36/*
37 * profile UDP packet format for communicating between ip3k and host
38 *
39 * every packet starts with a header, followed by samples.
40 * samples are only taken for non-hrt threads that are
41 * active
42 */
43#define PROF_MAGIC 0x3ea0
44#define PROF_MAGIC_COUNTERS 0x9ea0
45#define PROF_MAGIC_MAPS 0xaea0
46
47/*
48 * Versions (31 max):
49 * 1 to 4 were before 6.0 release, development versions
50 * 5 was forward compatible version, shipped with 6.0 and 6.1
51 * 6 adds heap packets, and clock_freq to header, shipped with 6.2
52 * 7 adds a sequence numbers to check for dropped packets, shipped with 6.3.5
53 * 8 adds mqueue timing information, shipped with 6.3.5
54 * 9 adds sdram heap size information, shipped with 6.4
55 * 10 adds heapmem heap callers and long latency stack traces. shipped with 6.4
56 * 11 adds support for Mars (IP5K). shipped with 6.10
57 * 12 adds more support for Mars. Shipped with 7.0
58 * 13 adds per sample latency measurement. Shipped with 7.2
59 * 14 changes the heap format and adds a string packet. Shipped with 7.4
60 * 15 adds dsr stats and posix. shipped with 7.6
61 * 16 corrects maximum packet count for Ares. ships with 7.9
62 * 17 adds a5 register value to sample
63 * 18 adds counter support and removes unused header fields
64 * 19 adds PID support for MMU profiling
65 * 20 changes the protocol for transmitting map PID maps automatically
66 * 21 adds support for multiple possible parents, configurable
67 */
68
69#define PROFILE_VERSION 21
70
71
72/*
73 * Each packet starts with a profile_header, then sample_count samples;
74 * samples are gprof samples of pc, the return address, condition codes, and active threads.
75 * For performance concern, the field sequence may be reordered to match profilenode to reduce
76 * a memory copy.
77 */
78struct profile_pkg_header { // in network byte order !
79 uint16_t magic; /* magic number and version */
80 uint8_t header_size; /* number of bytes in profile header */
81 uint8_t sample_count; /* number of samples in the packet */
82 uint32_t sample_stack_words; /* number of stack words in the sample */
83 uint32_t seq_num; /* to detect dropped profiler packets */
84 uint32_t profile_instructions; /* instructions executed by profiler mainline */
85
86 uint32_t unused_overlay; // untouched fields below in Linux -- to reduce memcpy
87 uint32_t cpu_id; /* CHIP_ID register contents */
88 uint32_t clock_freq; /* clock frequency (Hz) of system being analyzed */
89 uint32_t ddr_freq; /* DDR clock frequency */
90};
91
92struct profile_header { // in network byte order !
93 struct profile_pkg_header pph;
94 struct profile_ext_header exh;
95};
96
97struct profile_header_counters {
98 uint16_t magic;
99 uint16_t ultra_count; // how many ultra counters follow this
100 uint32_t ultra_sample_time; // in chip clocks
101 uint32_t linux_count; // how many linux counters follow this
102 uint32_t linux_sample_time;
103};
104
105/*
106 * send memory maps from linux to profiler tool
107 */
108
109struct profile_header_maps {
110 uint16_t magic; /* magic number and last packet bit */
111 uint16_t count;
112 uint32_t page_shift;
113};
114
115#define PROFILE_MAP_NUM_TYPES 16
116
117/* size field is pages. True size in bytes is (1 << PAGE_SHIFT) * size */
118#define PROFILE_MAP_TYPE_FREE 0
119#define PROFILE_MAP_TYPE_SMALL 1
120#define PROFILE_MAP_TYPE_FS 2
121#define PROFILE_MAP_TYPE_UNKNOWN_USED 4
122#define PROFILE_MAP_TYPE_TEXT 5
123#define PROFILE_MAP_TYPE_STACK 6
124#define PROFILE_MAP_TYPE_APP_DATA 7
125#define PROFILE_MAP_TYPE_ASHMEM 8
126#define PROFILE_MAP_TYPE_READ_SHARED 9
127#define PROFILE_MAP_TYPE_CACHE 10
128#define PROFILE_MAP_TYPE_VMA_WASTE 11
129#define PROFILE_MAP_RESERVED 15
130
131#define PROFILE_MAP_TYPE_SHIFT 12
132#define PROFILE_MAP_SIZE_MASK 0xfff
133
134struct profile_map {
135 uint16_t start; /* start page number of segment, relative to start of OCM (Max 256 MB on IP7K or 1 GB on IP8K, plus 256 KB OCM) */
136 uint16_t type_size; /* type (4 bits) of the segment and size (12 bits) in pages. A size of 0 means 4K pages */
137};
138
139#define PROFILE_MAX_MAPS (PROFILE_MAX_PACKET_SIZE - sizeof(struct profile_header_maps)) / sizeof(struct profile_map)