drivers/thunderbolt/trace.h

Source file repositories/reference/linux-study-clean/drivers/thunderbolt/trace.h

File Facts

System
Linux kernel
Corpus path
drivers/thunderbolt/trace.h
Extension
.h
Size
5081 bytes
Lines
198
Domain
Driver Families
Bucket
drivers/thunderbolt
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

#undef TRACE_SYSTEM
#define TRACE_SYSTEM thunderbolt

#if !defined(TB_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
#define TB_TRACE_H_

#include <linux/trace_seq.h>
#include <linux/tracepoint.h>

#include "tb_msgs.h"

#define tb_cfg_type_name(type)		{ type, #type }
#define show_type_name(val)					\
	__print_symbolic(val,					\
		tb_cfg_type_name(TB_CFG_PKG_READ),		\
		tb_cfg_type_name(TB_CFG_PKG_WRITE),		\
		tb_cfg_type_name(TB_CFG_PKG_ERROR),		\
		tb_cfg_type_name(TB_CFG_PKG_NOTIFY_ACK),	\
		tb_cfg_type_name(TB_CFG_PKG_EVENT),		\
		tb_cfg_type_name(TB_CFG_PKG_XDOMAIN_REQ),	\
		tb_cfg_type_name(TB_CFG_PKG_XDOMAIN_RESP),	\
		tb_cfg_type_name(TB_CFG_PKG_OVERRIDE),		\
		tb_cfg_type_name(TB_CFG_PKG_RESET),		\
		tb_cfg_type_name(TB_CFG_PKG_ICM_EVENT),		\
		tb_cfg_type_name(TB_CFG_PKG_ICM_CMD),		\
		tb_cfg_type_name(TB_CFG_PKG_ICM_RESP))

#ifndef TB_TRACE_HELPERS
#define TB_TRACE_HELPERS
static inline const char *show_data_read_write(struct trace_seq *p,
					       const u32 *data)
{
	const struct cfg_read_pkg *msg = (const struct cfg_read_pkg *)data;
	const char *ret = trace_seq_buffer_ptr(p);

	trace_seq_printf(p, "offset=%#x, len=%u, port=%d, config=%#x, seq=%d, ",
			 msg->addr.offset, msg->addr.length, msg->addr.port,
			 msg->addr.space, msg->addr.seq);

	return ret;
}

static inline const char *show_data_error(struct trace_seq *p, const u32 *data)
{
	const struct cfg_error_pkg *msg = (const struct cfg_error_pkg *)data;
	const char *ret = trace_seq_buffer_ptr(p);

	trace_seq_printf(p, "error=%#x, port=%d, plug=%#x, ", msg->error,
			 msg->port, msg->pg);

	return ret;
}

static inline const char *show_data_event(struct trace_seq *p, const u32 *data)
{
	const struct cfg_event_pkg *msg = (const struct cfg_event_pkg *)data;
	const char *ret = trace_seq_buffer_ptr(p);

	trace_seq_printf(p, "port=%d, unplug=%#x, ", msg->port, msg->unplug);

	return ret;
}

static inline const char *show_route(struct trace_seq *p, const u32 *data)
{
	const struct tb_cfg_header *header = (const struct tb_cfg_header *)data;
	const char *ret = trace_seq_buffer_ptr(p);

	trace_seq_printf(p, "route=%llx, ", tb_cfg_get_route(header));

	return ret;
}

static inline const char *show_data(struct trace_seq *p, u8 type,
				    const u32 *data, u32 length)
{
	const char *ret = trace_seq_buffer_ptr(p);
	const char *prefix = "";
	int i;

	switch (type) {
	case TB_CFG_PKG_READ:
	case TB_CFG_PKG_WRITE:
		show_route(p, data);
		show_data_read_write(p, data);
		break;

	case TB_CFG_PKG_ERROR:
		show_route(p, data);
		show_data_error(p, data);

Annotation

Implementation Notes