tools/perf/util/cs-etm.h

Source file repositories/reference/linux-study-clean/tools/perf/util/cs-etm.h

File Facts

System
Linux kernel
Corpus path
tools/perf/util/cs-etm.h
Extension
.h
Size
8006 bytes
Lines
283
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct cs_etm_packet {
	enum cs_etm_sample_type sample_type;
	enum cs_etm_isa isa;
	u64 start_addr;
	u64 end_addr;
	u32 instr_count;
	u32 last_instr_type;
	u32 last_instr_subtype;
	u32 flags;
	u32 exception_number;
	bool last_instr_cond;
	bool last_instr_taken_branch;
	u8 last_instr_size;
	u8 trace_chan_id;
	int cpu;
};

#define CS_ETM_PACKET_MAX_BUFFER 1024

/*
 * When working with per-thread scenarios the process under trace can
 * be scheduled on any CPU and as such, more than one traceID may be
 * associated with the same process.  Since a traceID of '0' is illegal
 * as per the CoreSight architecture, use that specific value to
 * identify the queue where all packets (with any traceID) are
 * aggregated.
 */
#define CS_ETM_PER_THREAD_TRACEID 0

struct cs_etm_packet_queue {
	u32 packet_count;
	u32 head;
	u32 tail;
	u32 instr_count;
	u64 cs_timestamp; /* Timestamp from trace data, converted to ns if possible */
	u64 next_cs_timestamp;
	struct cs_etm_packet packet_buffer[CS_ETM_PACKET_MAX_BUFFER];
};

#define KiB(x) ((x) * 1024)
#define MiB(x) ((x) * 1024 * 1024)

#define CS_ETM_INVAL_ADDR 0xdeadbeefdeadbeefUL

#define BMVAL(val, lsb, msb)	((val & GENMASK(msb, lsb)) >> lsb)

#define CS_ETM_HEADER_SIZE (CS_HEADER_VERSION_MAX * sizeof(u64))

#define __perf_cs_etmv3_magic 0x3030303030303030ULL
#define __perf_cs_etmv4_magic 0x4040404040404040ULL
#define __perf_cs_ete_magic   0x5050505050505050ULL
#define CS_ETMV3_PRIV_SIZE (CS_ETM_PRIV_MAX * sizeof(u64))
#define CS_ETMV4_PRIV_SIZE (CS_ETMV4_PRIV_MAX * sizeof(u64))
#define CS_ETE_PRIV_SIZE (CS_ETE_PRIV_MAX * sizeof(u64))

#define INFO_HEADER_SIZE (sizeof(((struct perf_record_auxtrace_info *)0)->type) + \
			  sizeof(((struct perf_record_auxtrace_info *)0)->reserved__))

/* CoreSight trace ID is currently the bottom 7 bits of the value */
#define CORESIGHT_TRACE_ID_VAL_MASK	GENMASK(6, 0)

/* ETMv4 CONFIGR register bits */
#define TRCCONFIGR_BB		BIT(3)
#define TRCCONFIGR_CCI		BIT(4)
#define TRCCONFIGR_CID		BIT(6)
#define TRCCONFIGR_VMID		BIT(7)
#define TRCCONFIGR_TS		BIT(11)
#define TRCCONFIGR_RS		BIT(12)
#define TRCCONFIGR_VMIDOPT	BIT(15)

/* ETMv3 ETMCR register bits */
#define ETMCR_CYC_ACC		BIT(12)
#define ETMCR_CTXTID		BIT(14)
#define ETMCR_TIMESTAMP_EN	BIT(28)
#define ETMCR_RETURN_STACK	BIT(29)

int cs_etm__process_auxtrace_info(union perf_event *event,
				  struct perf_session *session);
void cs_etm_get_default_config(const struct perf_pmu *pmu, struct perf_event_attr *attr);

enum cs_etm_pid_fmt {
	CS_ETM_PIDFMT_NONE,
	CS_ETM_PIDFMT_CTXTID,
	CS_ETM_PIDFMT_CTXTID2
};

#ifdef HAVE_CSTRACE_SUPPORT
#include <opencsd/ocsd_if_types.h>
int cs_etm__get_cpu(struct cs_etm_queue *etmq, u8 trace_chan_id, int *cpu);
enum cs_etm_pid_fmt cs_etm__get_pid_fmt(struct cs_etm_queue *etmq);

Annotation

Implementation Notes