blob: 331afec1c90da9226b0ff235f4acec8075d533bb [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 */
Guojun Jin3deae8c2016-08-23 15:51:21 -070082 uint8_t nc_sts_tselA; /* thr 1 statistics requst to FW */
83 uint8_t nc_sts_tselB; /* thr 2 requst to FW */
84 uint8_t spare1B;
85 uint8_t sample_stack_words; /* number of stack words in the sample */
Sundarajan Srinivasan1b03fe22014-12-02 13:20:56 -080086 uint32_t seq_num; /* to detect dropped profiler packets */
87 uint32_t profile_instructions; /* instructions executed by profiler mainline */
88
89 uint32_t unused_overlay; // untouched fields below in Linux -- to reduce memcpy
90 uint32_t cpu_id; /* CHIP_ID register contents */
91 uint32_t clock_freq; /* clock frequency (Hz) of system being analyzed */
92 uint32_t ddr_freq; /* DDR clock frequency */
93};
94
95struct profile_header { // in network byte order !
96 struct profile_pkg_header pph;
97 struct profile_ext_header exh;
98};
99
100struct profile_header_counters {
101 uint16_t magic;
102 uint16_t ultra_count; // how many ultra counters follow this
103 uint32_t ultra_sample_time; // in chip clocks
104 uint32_t linux_count; // how many linux counters follow this
105 uint32_t linux_sample_time;
106};
107
108/*
109 * send memory maps from linux to profiler tool
110 */
111
112struct profile_header_maps {
113 uint16_t magic; /* magic number and last packet bit */
114 uint16_t count;
115 uint32_t page_shift;
116};
117
118#define PROFILE_MAP_NUM_TYPES 16
119
120/* size field is pages. True size in bytes is (1 << PAGE_SHIFT) * size */
121#define PROFILE_MAP_TYPE_FREE 0
122#define PROFILE_MAP_TYPE_SMALL 1
123#define PROFILE_MAP_TYPE_FS 2
124#define PROFILE_MAP_TYPE_UNKNOWN_USED 4
125#define PROFILE_MAP_TYPE_TEXT 5
126#define PROFILE_MAP_TYPE_STACK 6
127#define PROFILE_MAP_TYPE_APP_DATA 7
128#define PROFILE_MAP_TYPE_ASHMEM 8
129#define PROFILE_MAP_TYPE_READ_SHARED 9
130#define PROFILE_MAP_TYPE_CACHE 10
131#define PROFILE_MAP_TYPE_VMA_WASTE 11
132#define PROFILE_MAP_RESERVED 15
133
134#define PROFILE_MAP_TYPE_SHIFT 12
135#define PROFILE_MAP_SIZE_MASK 0xfff
136
137struct profile_map {
138 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) */
139 uint16_t type_size; /* type (4 bits) of the segment and size (12 bits) in pages. A size of 0 means 4K pages */
140};
141
142#define PROFILE_MAX_MAPS (PROFILE_MAX_PACKET_SIZE - sizeof(struct profile_header_maps)) / sizeof(struct profile_map)