tools/perf/util/hisi-ptt.c
Source file repositories/reference/linux-study-clean/tools/perf/util/hisi-ptt.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/hisi-ptt.c- Extension
.c- Size
- 4505 bytes
- Lines
- 191
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
byteswap.hendian.herrno.hinttypes.hlinux/bitops.hlinux/kernel.hlinux/log2.hlinux/types.hlinux/zalloc.hstdlib.hunistd.hauxtrace.hcolor.hdebug.hevsel.hhisi-ptt.hhisi-ptt-decoder/hisi-ptt-pkt-decoder.hmachine.hsession.htool.hinternal/lib.h
Detected Declarations
struct hisi_pttfunction hisi_ptt_check_packet_typefunction hisi_ptt_dumpfunction hisi_ptt_dump_eventfunction hisi_ptt_process_eventfunction hisi_ptt_process_auxtrace_eventfunction hisi_ptt_flushfunction hisi_ptt_free_eventsfunction hisi_ptt_evsel_is_auxtracefunction hisi_ptt_print_infofunction hisi_ptt_process_auxtrace_info
Annotated Snippet
struct hisi_ptt {
struct auxtrace auxtrace;
u32 auxtrace_type;
struct perf_session *session;
struct machine *machine;
u32 pmu_type;
};
static enum hisi_ptt_pkt_type hisi_ptt_check_packet_type(unsigned char *buf)
{
uint32_t head = *(uint32_t *)buf;
if ((HISI_PTT_8DW_CHECK_MASK & head) == HISI_PTT_IS_8DW_PKT)
return HISI_PTT_8DW_PKT;
return HISI_PTT_4DW_PKT;
}
static void hisi_ptt_dump(struct hisi_ptt *ptt __maybe_unused,
unsigned char *buf, size_t len)
{
const char *color = PERF_COLOR_BLUE;
enum hisi_ptt_pkt_type type;
size_t pos = 0;
int pkt_len;
type = hisi_ptt_check_packet_type(buf);
len = round_down(len, hisi_ptt_pkt_size[type]);
color_fprintf(stdout, color, ". ... HISI PTT data: size %zu bytes\n",
len);
while (len > 0) {
pkt_len = hisi_ptt_pkt_desc(buf, pos, type);
if (!pkt_len)
color_fprintf(stdout, color, " Bad packet!\n");
pos += pkt_len;
len -= pkt_len;
}
}
static void hisi_ptt_dump_event(struct hisi_ptt *ptt, unsigned char *buf,
size_t len)
{
printf(".\n");
hisi_ptt_dump(ptt, buf, len);
}
static int hisi_ptt_process_event(struct perf_session *session __maybe_unused,
union perf_event *event __maybe_unused,
struct perf_sample *sample __maybe_unused,
const struct perf_tool *tool __maybe_unused)
{
return 0;
}
static int hisi_ptt_process_auxtrace_event(struct perf_session *session,
union perf_event *event,
const struct perf_tool *tool __maybe_unused)
{
struct hisi_ptt *ptt = container_of(session->auxtrace, struct hisi_ptt,
auxtrace);
int fd = perf_data__fd(session->data);
int size = event->auxtrace.size;
void *data = malloc(size);
off_t data_offset;
int err;
if (!data)
return -errno;
if (perf_data__is_pipe(session->data)) {
data_offset = 0;
} else {
data_offset = lseek(fd, 0, SEEK_CUR);
if (data_offset == -1) {
free(data);
return -errno;
}
}
err = readn(fd, data, size);
if (err != (ssize_t)size) {
free(data);
return -errno;
}
if (dump_trace)
hisi_ptt_dump_event(ptt, data, size);
Annotation
- Immediate include surface: `byteswap.h`, `endian.h`, `errno.h`, `inttypes.h`, `linux/bitops.h`, `linux/kernel.h`, `linux/log2.h`, `linux/types.h`.
- Detected declarations: `struct hisi_ptt`, `function hisi_ptt_check_packet_type`, `function hisi_ptt_dump`, `function hisi_ptt_dump_event`, `function hisi_ptt_process_event`, `function hisi_ptt_process_auxtrace_event`, `function hisi_ptt_flush`, `function hisi_ptt_free_events`, `function hisi_ptt_evsel_is_auxtrace`, `function hisi_ptt_print_info`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.