|
| 1 | +#undef TRACE_SYSTEM |
| 2 | +#define TRACE_SYSTEM pibridge |
| 3 | + |
| 4 | +#if !defined(_PIBRIDGE_TRACE_H) || defined(TRACE_HEADER_MULTI_READ) |
| 5 | +#define _PIBRIDGE_TRACE_H |
| 6 | + |
| 7 | +#include <linux/tracepoint.h> |
| 8 | +#include <linux/serdev.h> |
| 9 | +#include <linux/kfifo.h> |
| 10 | + |
| 11 | +#include "pibridge.h" |
| 12 | + |
| 13 | +#define PIBRIDGE_TRACE_MAX_FIFO_DUMP 128 |
| 14 | +#define PIBRIDGE_TRACE_MAX_PACKET_DATA_LEN 256 |
| 15 | + |
| 16 | +/* Header */ |
| 17 | +DECLARE_EVENT_CLASS(pibridge_gate_header_class, |
| 18 | + TP_PROTO(struct pibridge_pkthdr_gate *hdr), |
| 19 | + TP_ARGS(hdr), |
| 20 | + TP_STRUCT__entry( |
| 21 | + __field(u8, dst) |
| 22 | + __field(u8, src) |
| 23 | + __field(u16, cmd) |
| 24 | + __field(u16, seq) |
| 25 | + __field(u8, len) |
| 26 | + ), |
| 27 | + TP_fast_assign( |
| 28 | + __entry->dst = hdr->dst; |
| 29 | + __entry->src = hdr->src; |
| 30 | + __entry->cmd = hdr->cmd; |
| 31 | + __entry->seq = hdr->seq; |
| 32 | + __entry->len = hdr->len; |
| 33 | + ), |
| 34 | + TP_printk( |
| 35 | + "dst=%u src=%u cmd=%u seq=%u len=%u", |
| 36 | + __entry->dst, |
| 37 | + __entry->src, |
| 38 | + __entry->cmd, |
| 39 | + __entry->seq, |
| 40 | + __entry->len |
| 41 | + ) |
| 42 | +); |
| 43 | + |
| 44 | +DEFINE_EVENT(pibridge_gate_header_class, pibridge_send_gate_header, |
| 45 | + TP_PROTO(struct pibridge_pkthdr_gate *hdr), |
| 46 | + TP_ARGS(hdr) |
| 47 | +); |
| 48 | + |
| 49 | +DEFINE_EVENT(pibridge_gate_header_class, pibridge_receive_gate_header, |
| 50 | + TP_PROTO(struct pibridge_pkthdr_gate *hdr), |
| 51 | + TP_ARGS(hdr) |
| 52 | +); |
| 53 | + |
| 54 | +DECLARE_EVENT_CLASS(pibridge_io_header_class, |
| 55 | + TP_PROTO(struct pibridge_pkthdr_io *hdr), |
| 56 | + TP_ARGS(hdr), |
| 57 | + TP_STRUCT__entry( |
| 58 | + __field(u8, addr) |
| 59 | + __field(u8, type) |
| 60 | + __field(u8, rsp) |
| 61 | + __field(u8, len) |
| 62 | + __field(u8, cmd) |
| 63 | + ), |
| 64 | + TP_fast_assign( |
| 65 | + __entry->addr = hdr->addr; |
| 66 | + __entry->type = hdr->type; |
| 67 | + __entry->rsp = hdr->rsp; |
| 68 | + __entry->len = hdr->len; |
| 69 | + __entry->cmd = hdr->cmd; |
| 70 | + ), |
| 71 | + TP_printk( |
| 72 | + "addr=%u type=%u rsp=%u len=%u cmd=%u", |
| 73 | + __entry->addr, |
| 74 | + __entry->type, |
| 75 | + __entry->rsp, |
| 76 | + __entry->len, |
| 77 | + __entry->cmd) |
| 78 | +); |
| 79 | + |
| 80 | +DEFINE_EVENT(pibridge_io_header_class, pibridge_send_io_header, |
| 81 | + TP_PROTO(struct pibridge_pkthdr_io *hdr), |
| 82 | + TP_ARGS(hdr) |
| 83 | +); |
| 84 | + |
| 85 | +DEFINE_EVENT(pibridge_io_header_class, pibridge_receive_io_header, |
| 86 | + TP_PROTO(struct pibridge_pkthdr_io *hdr), |
| 87 | + TP_ARGS(hdr) |
| 88 | +); |
| 89 | + |
| 90 | +/* CRC */ |
| 91 | +DECLARE_EVENT_CLASS(pibridge_send_crc_class, |
| 92 | + TP_PROTO(u8 crc), |
| 93 | + TP_ARGS(crc), |
| 94 | + TP_STRUCT__entry( |
| 95 | + __field(u8, crc) |
| 96 | + ), |
| 97 | + TP_fast_assign( |
| 98 | + __entry->crc = crc; |
| 99 | + ), |
| 100 | + TP_printk( |
| 101 | + "crc=0x%02x", |
| 102 | + __entry->crc |
| 103 | + ) |
| 104 | +); |
| 105 | + |
| 106 | +DEFINE_EVENT(pibridge_send_crc_class, pibridge_send_io_crc, |
| 107 | + TP_PROTO(u8 crc), |
| 108 | + TP_ARGS(crc) |
| 109 | +); |
| 110 | + |
| 111 | +DEFINE_EVENT(pibridge_send_crc_class, pibridge_send_gate_crc, |
| 112 | + TP_PROTO(u8 crc), |
| 113 | + TP_ARGS(crc) |
| 114 | +); |
| 115 | + |
| 116 | +DECLARE_EVENT_CLASS(pibridge_receive_crc_class, |
| 117 | + TP_PROTO(u8 crc, u8 exp_crc), |
| 118 | + TP_ARGS(crc, exp_crc), |
| 119 | + TP_STRUCT__entry( |
| 120 | + __field(u8, crc) |
| 121 | + __field(u8, exp_crc) |
| 122 | + ), |
| 123 | + TP_fast_assign( |
| 124 | + __entry->crc = crc; |
| 125 | + __entry->exp_crc = exp_crc; |
| 126 | + ), |
| 127 | + TP_printk( |
| 128 | + "crc=0x%02x (exp=0x%02x)", |
| 129 | + __entry->crc, |
| 130 | + __entry->exp_crc |
| 131 | + ) |
| 132 | +); |
| 133 | + |
| 134 | +DEFINE_EVENT(pibridge_receive_crc_class, pibridge_receive_io_crc, |
| 135 | + TP_PROTO(u8 crc, u8 exp_crc), |
| 136 | + TP_ARGS(crc, exp_crc) |
| 137 | +); |
| 138 | + |
| 139 | +DEFINE_EVENT(pibridge_receive_crc_class, pibridge_receive_gate_crc, |
| 140 | + TP_PROTO(u8 crc, u8 exp_crc), |
| 141 | + TP_ARGS(crc, exp_crc) |
| 142 | +); |
| 143 | + |
| 144 | +/* packet data */ |
| 145 | +DECLARE_EVENT_CLASS(pibridge_buffer_data_class, |
| 146 | + TP_PROTO(const unsigned char *buffer, unsigned int len), |
| 147 | + TP_ARGS(buffer, len), |
| 148 | + TP_STRUCT__entry( |
| 149 | + __array(const unsigned char *, buffer, |
| 150 | + PIBRIDGE_TRACE_MAX_PACKET_DATA_LEN) |
| 151 | + __field(unsigned int, len) |
| 152 | + ), |
| 153 | + TP_fast_assign( |
| 154 | + memcpy(__entry->buffer, buffer, len); |
| 155 | + __entry->len= len; |
| 156 | + ), |
| 157 | + TP_printk( |
| 158 | + "datalen=%d data:%s", |
| 159 | + __entry->len, |
| 160 | + __print_array(__entry->buffer, __entry->len, |
| 161 | + sizeof(unsigned char)) |
| 162 | + ) |
| 163 | +); |
| 164 | + |
| 165 | +DEFINE_EVENT(pibridge_buffer_data_class, pibridge_receive_io_data, |
| 166 | + TP_PROTO(const unsigned char *buffer, unsigned int len), |
| 167 | + TP_ARGS(buffer, len) |
| 168 | +); |
| 169 | + |
| 170 | +DEFINE_EVENT(pibridge_buffer_data_class, pibridge_receive_gate_data, |
| 171 | + TP_PROTO(const unsigned char *buffer, unsigned int len), |
| 172 | + TP_ARGS(buffer, len) |
| 173 | +); |
| 174 | + |
| 175 | +DEFINE_EVENT(pibridge_buffer_data_class, pibridge_send_io_data, |
| 176 | + TP_PROTO(const unsigned char *buffer, unsigned int len), |
| 177 | + TP_ARGS(buffer, len) |
| 178 | +); |
| 179 | + |
| 180 | +DEFINE_EVENT(pibridge_buffer_data_class, pibridge_send_gate_data, |
| 181 | + TP_PROTO(const unsigned char *buffer, unsigned int len), |
| 182 | + TP_ARGS(buffer, len) |
| 183 | +); |
| 184 | + |
| 185 | +DEFINE_EVENT(pibridge_buffer_data_class, pibridge_send_begin, |
| 186 | + TP_PROTO(const unsigned char *buffer, unsigned int len), |
| 187 | + TP_ARGS(buffer, len) |
| 188 | +); |
| 189 | + |
| 190 | +DEFINE_EVENT(pibridge_buffer_data_class, pibridge_receive_end, |
| 191 | + TP_PROTO(const unsigned char *buffer, unsigned int len), |
| 192 | + TP_ARGS(buffer, len) |
| 193 | +); |
| 194 | + |
| 195 | +DEFINE_EVENT(pibridge_buffer_data_class, pibridge_wakeup_receive_buffer, |
| 196 | + TP_PROTO(const unsigned char *buffer, unsigned int len), |
| 197 | + TP_ARGS(buffer, len) |
| 198 | +); |
| 199 | + |
| 200 | +/* Timeout */ |
| 201 | +DECLARE_EVENT_CLASS(pibridge_timeout_class, |
| 202 | + TP_PROTO(unsigned int received, unsigned int expected, |
| 203 | + unsigned int timeout), |
| 204 | + TP_ARGS(received, expected, timeout), |
| 205 | + TP_STRUCT__entry( |
| 206 | + __field(unsigned int, received) |
| 207 | + __field(unsigned int, expected) |
| 208 | + __field(unsigned int, timeout) |
| 209 | + ), |
| 210 | + TP_fast_assign( |
| 211 | + __entry->received = received; |
| 212 | + __entry->expected = expected; |
| 213 | + __entry->timeout = timeout; |
| 214 | + ), |
| 215 | + TP_printk( |
| 216 | + "received: %u, expected: %u, timeout: %u", |
| 217 | + __entry->received, |
| 218 | + __entry->expected, |
| 219 | + __entry->timeout |
| 220 | + ) |
| 221 | +); |
| 222 | + |
| 223 | +DEFINE_EVENT(pibridge_timeout_class, pibridge_receive_timeout, |
| 224 | + TP_PROTO(unsigned int received, unsigned int expected, |
| 225 | + unsigned int timeout), |
| 226 | + TP_ARGS(received, expected, timeout) |
| 227 | +); |
| 228 | + |
| 229 | +DEFINE_EVENT(pibridge_timeout_class, pibridge_discard_timeout, |
| 230 | + TP_PROTO(unsigned int received, unsigned int expected, |
| 231 | + unsigned int timeout), |
| 232 | + TP_ARGS(received, expected, timeout) |
| 233 | +); |
| 234 | + |
| 235 | +/* Serdev name */ |
| 236 | +DECLARE_EVENT_CLASS(pibridge_serdev_name_class, |
| 237 | + TP_PROTO(struct serdev_device *serdev), |
| 238 | + TP_ARGS(serdev), |
| 239 | + TP_STRUCT__entry( |
| 240 | + __string(name, dev_name(&serdev->dev)) |
| 241 | + ), |
| 242 | + TP_fast_assign( |
| 243 | + __assign_str(name, dev_name(&serdev->dev)); |
| 244 | + ), |
| 245 | + TP_printk( |
| 246 | + "Serdev %s", |
| 247 | + __get_str(name) |
| 248 | + ) |
| 249 | +); |
| 250 | + |
| 251 | +DEFINE_EVENT(pibridge_serdev_name_class, pibridge_wakeup_write, |
| 252 | + TP_PROTO(struct serdev_device *serdev), |
| 253 | + TP_ARGS(serdev) |
| 254 | +); |
| 255 | + |
| 256 | +/* packet data len */ |
| 257 | +DECLARE_EVENT_CLASS(pibridge_data_len_class, |
| 258 | + TP_PROTO(unsigned int len), |
| 259 | + TP_ARGS(len), |
| 260 | + TP_STRUCT__entry( |
| 261 | + __field(unsigned int, len) |
| 262 | + ), |
| 263 | + TP_fast_assign( |
| 264 | + __entry->len = len; |
| 265 | + ), |
| 266 | + TP_printk( |
| 267 | + "datalen=%d", |
| 268 | + __entry->len |
| 269 | + ) |
| 270 | +); |
| 271 | + |
| 272 | +DEFINE_EVENT(pibridge_data_len_class, pibridge_send_end, |
| 273 | + TP_PROTO(unsigned int len), |
| 274 | + TP_ARGS(len) |
| 275 | +); |
| 276 | + |
| 277 | +DEFINE_EVENT(pibridge_data_len_class, pibridge_receive_begin, |
| 278 | + TP_PROTO(unsigned int len), |
| 279 | + TP_ARGS(len) |
| 280 | +); |
| 281 | + |
| 282 | + |
| 283 | +/* kfifo data */ |
| 284 | +DECLARE_EVENT_CLASS(pibridge_kfifo_data_class, |
| 285 | + TP_PROTO(struct kfifo *fifo), |
| 286 | + TP_ARGS(fifo), |
| 287 | + TP_STRUCT__entry( |
| 288 | + __field(unsigned int, len) |
| 289 | + __array(unsigned char *, buffer, PIBRIDGE_RECV_FIFO_SIZE) |
| 290 | + ), |
| 291 | + TP_fast_assign( |
| 292 | + __entry->len = kfifo_out_peek(fifo, __entry->buffer, |
| 293 | + PIBRIDGE_RECV_FIFO_SIZE) |
| 294 | + ), |
| 295 | + TP_printk( |
| 296 | + "fifo (len=%u) data=%s", |
| 297 | + __entry->len, |
| 298 | + __print_array(__entry->buffer, |
| 299 | + __entry->len > PIBRIDGE_RECV_FIFO_SIZE ? |
| 300 | + PIBRIDGE_RECV_FIFO_SIZE : __entry->len, |
| 301 | + sizeof(unsigned char)) |
| 302 | + ) |
| 303 | +); |
| 304 | + |
| 305 | +DEFINE_EVENT(pibridge_kfifo_data_class, pibridge_discard_data, |
| 306 | + TP_PROTO(struct kfifo *fifo), |
| 307 | + TP_ARGS(fifo) |
| 308 | +); |
| 309 | + |
| 310 | +#endif /* _PIBRIDGE_TRACE_H */ |
| 311 | + |
| 312 | +/* This part must be outside protection */ |
| 313 | +#undef TRACE_INCLUDE_PATH |
| 314 | +#define TRACE_INCLUDE_PATH . |
| 315 | +#undef TRACE_INCLUDE_FILE |
| 316 | +#define TRACE_INCLUDE_FILE pibridge_trace |
| 317 | +#include <trace/define_trace.h> |
0 commit comments