1 /* I2C and SMBUS message transfer tracepoints
3 * Copyright (C) 2013 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
12 #define TRACE_SYSTEM i2c
14 #if !defined(_TRACE_I2C_H) || defined(TRACE_HEADER_MULTI_READ)
17 #include <linux/i2c.h>
18 #include <linux/tracepoint.h>
21 * drivers/i2c/i2c-core.c
23 extern void i2c_transfer_trace_reg(void);
24 extern void i2c_transfer_trace_unreg(void);
27 * __i2c_transfer() write request
29 TRACE_EVENT_FN(i2c_write
,
30 TP_PROTO(const struct i2c_adapter
*adap
, const struct i2c_msg
*msg
,
32 TP_ARGS(adap
, msg
, num
),
34 __field(int, adapter_nr
)
35 __field(__u16
, msg_nr
)
37 __field(__u16
, flags
)
39 __dynamic_array(__u8
, buf
, msg
->len
) ),
41 __entry
->adapter_nr
= adap
->nr
;
42 __entry
->msg_nr
= num
;
43 __entry
->addr
= msg
->addr
;
44 __entry
->flags
= msg
->flags
;
45 __entry
->len
= msg
->len
;
46 memcpy(__get_dynamic_array(buf
), msg
->buf
, msg
->len
);
48 TP_printk("i2c-%d #%u a=%03x f=%04x l=%u [%*phD]",
54 __entry
->len
, __get_dynamic_array(buf
)
56 i2c_transfer_trace_reg
,
57 i2c_transfer_trace_unreg
);
60 * __i2c_transfer() read request
62 TRACE_EVENT_FN(i2c_read
,
63 TP_PROTO(const struct i2c_adapter
*adap
, const struct i2c_msg
*msg
,
65 TP_ARGS(adap
, msg
, num
),
67 __field(int, adapter_nr
)
68 __field(__u16
, msg_nr
)
70 __field(__u16
, flags
)
74 __entry
->adapter_nr
= adap
->nr
;
75 __entry
->msg_nr
= num
;
76 __entry
->addr
= msg
->addr
;
77 __entry
->flags
= msg
->flags
;
78 __entry
->len
= msg
->len
;
80 TP_printk("i2c-%d #%u a=%03x f=%04x l=%u",
87 i2c_transfer_trace_reg
,
88 i2c_transfer_trace_unreg
);
91 * __i2c_transfer() read reply
93 TRACE_EVENT_FN(i2c_reply
,
94 TP_PROTO(const struct i2c_adapter
*adap
, const struct i2c_msg
*msg
,
96 TP_ARGS(adap
, msg
, num
),
98 __field(int, adapter_nr
)
99 __field(__u16
, msg_nr
)
100 __field(__u16
, addr
)
101 __field(__u16
, flags
)
103 __dynamic_array(__u8
, buf
, msg
->len
) ),
105 __entry
->adapter_nr
= adap
->nr
;
106 __entry
->msg_nr
= num
;
107 __entry
->addr
= msg
->addr
;
108 __entry
->flags
= msg
->flags
;
109 __entry
->len
= msg
->len
;
110 memcpy(__get_dynamic_array(buf
), msg
->buf
, msg
->len
);
112 TP_printk("i2c-%d #%u a=%03x f=%04x l=%u [%*phD]",
118 __entry
->len
, __get_dynamic_array(buf
)
120 i2c_transfer_trace_reg
,
121 i2c_transfer_trace_unreg
);
124 * __i2c_transfer() result
126 TRACE_EVENT_FN(i2c_result
,
127 TP_PROTO(const struct i2c_adapter
*adap
, int num
, int ret
),
128 TP_ARGS(adap
, num
, ret
),
130 __field(int, adapter_nr
)
131 __field(__u16
, nr_msgs
)
135 __entry
->adapter_nr
= adap
->nr
;
136 __entry
->nr_msgs
= num
;
139 TP_printk("i2c-%d n=%u ret=%d",
144 i2c_transfer_trace_reg
,
145 i2c_transfer_trace_unreg
);
148 * i2c_smbus_xfer() write data or procedure call request
150 TRACE_EVENT_CONDITION(smbus_write
,
151 TP_PROTO(const struct i2c_adapter
*adap
,
152 u16 addr
, unsigned short flags
,
153 char read_write
, u8 command
, int protocol
,
154 const union i2c_smbus_data
*data
),
155 TP_ARGS(adap
, addr
, flags
, read_write
, command
, protocol
, data
),
156 TP_CONDITION(read_write
== I2C_SMBUS_WRITE
||
157 protocol
== I2C_SMBUS_PROC_CALL
||
158 protocol
== I2C_SMBUS_BLOCK_PROC_CALL
),
160 __field(int, adapter_nr
)
161 __field(__u16
, addr
)
162 __field(__u16
, flags
)
163 __field(__u8
, command
)
165 __field(__u32
, protocol
)
166 __array(__u8
, buf
, I2C_SMBUS_BLOCK_MAX
+ 2) ),
168 __entry
->adapter_nr
= adap
->nr
;
169 __entry
->addr
= addr
;
170 __entry
->flags
= flags
;
171 __entry
->command
= command
;
172 __entry
->protocol
= protocol
;
175 case I2C_SMBUS_BYTE_DATA
:
178 case I2C_SMBUS_WORD_DATA
:
179 case I2C_SMBUS_PROC_CALL
:
182 case I2C_SMBUS_BLOCK_DATA
:
183 case I2C_SMBUS_BLOCK_PROC_CALL
:
184 case I2C_SMBUS_I2C_BLOCK_DATA
:
185 __entry
->len
= data
->block
[0] + 1;
187 memcpy(__entry
->buf
, data
->block
, __entry
->len
);
189 case I2C_SMBUS_QUICK
:
191 case I2C_SMBUS_I2C_BLOCK_BROKEN
:
196 TP_printk("i2c-%d a=%03x f=%04x c=%x %s l=%u [%*phD]",
201 __print_symbolic(__entry
->protocol
,
202 { I2C_SMBUS_QUICK
, "QUICK" },
203 { I2C_SMBUS_BYTE
, "BYTE" },
204 { I2C_SMBUS_BYTE_DATA
, "BYTE_DATA" },
205 { I2C_SMBUS_WORD_DATA
, "WORD_DATA" },
206 { I2C_SMBUS_PROC_CALL
, "PROC_CALL" },
207 { I2C_SMBUS_BLOCK_DATA
, "BLOCK_DATA" },
208 { I2C_SMBUS_I2C_BLOCK_BROKEN
, "I2C_BLOCK_BROKEN" },
209 { I2C_SMBUS_BLOCK_PROC_CALL
, "BLOCK_PROC_CALL" },
210 { I2C_SMBUS_I2C_BLOCK_DATA
, "I2C_BLOCK_DATA" }),
212 __entry
->len
, __entry
->buf
216 * i2c_smbus_xfer() read data request
218 TRACE_EVENT_CONDITION(smbus_read
,
219 TP_PROTO(const struct i2c_adapter
*adap
,
220 u16 addr
, unsigned short flags
,
221 char read_write
, u8 command
, int protocol
),
222 TP_ARGS(adap
, addr
, flags
, read_write
, command
, protocol
),
223 TP_CONDITION(!(read_write
== I2C_SMBUS_WRITE
||
224 protocol
== I2C_SMBUS_PROC_CALL
||
225 protocol
== I2C_SMBUS_BLOCK_PROC_CALL
)),
227 __field(int, adapter_nr
)
228 __field(__u16
, flags
)
229 __field(__u16
, addr
)
230 __field(__u8
, command
)
231 __field(__u32
, protocol
)
232 __array(__u8
, buf
, I2C_SMBUS_BLOCK_MAX
+ 2) ),
234 __entry
->adapter_nr
= adap
->nr
;
235 __entry
->addr
= addr
;
236 __entry
->flags
= flags
;
237 __entry
->command
= command
;
238 __entry
->protocol
= protocol
;
240 TP_printk("i2c-%d a=%03x f=%04x c=%x %s",
245 __print_symbolic(__entry
->protocol
,
246 { I2C_SMBUS_QUICK
, "QUICK" },
247 { I2C_SMBUS_BYTE
, "BYTE" },
248 { I2C_SMBUS_BYTE_DATA
, "BYTE_DATA" },
249 { I2C_SMBUS_WORD_DATA
, "WORD_DATA" },
250 { I2C_SMBUS_PROC_CALL
, "PROC_CALL" },
251 { I2C_SMBUS_BLOCK_DATA
, "BLOCK_DATA" },
252 { I2C_SMBUS_I2C_BLOCK_BROKEN
, "I2C_BLOCK_BROKEN" },
253 { I2C_SMBUS_BLOCK_PROC_CALL
, "BLOCK_PROC_CALL" },
254 { I2C_SMBUS_I2C_BLOCK_DATA
, "I2C_BLOCK_DATA" })
258 * i2c_smbus_xfer() read data or procedure call reply
260 TRACE_EVENT_CONDITION(smbus_reply
,
261 TP_PROTO(const struct i2c_adapter
*adap
,
262 u16 addr
, unsigned short flags
,
263 char read_write
, u8 command
, int protocol
,
264 const union i2c_smbus_data
*data
),
265 TP_ARGS(adap
, addr
, flags
, read_write
, command
, protocol
, data
),
266 TP_CONDITION(read_write
== I2C_SMBUS_READ
),
268 __field(int, adapter_nr
)
269 __field(__u16
, addr
)
270 __field(__u16
, flags
)
271 __field(__u8
, command
)
273 __field(__u32
, protocol
)
274 __array(__u8
, buf
, I2C_SMBUS_BLOCK_MAX
+ 2) ),
276 __entry
->adapter_nr
= adap
->nr
;
277 __entry
->addr
= addr
;
278 __entry
->flags
= flags
;
279 __entry
->command
= command
;
280 __entry
->protocol
= protocol
;
284 case I2C_SMBUS_BYTE_DATA
:
287 case I2C_SMBUS_WORD_DATA
:
288 case I2C_SMBUS_PROC_CALL
:
291 case I2C_SMBUS_BLOCK_DATA
:
292 case I2C_SMBUS_BLOCK_PROC_CALL
:
293 case I2C_SMBUS_I2C_BLOCK_DATA
:
294 __entry
->len
= data
->block
[0] + 1;
296 memcpy(__entry
->buf
, data
->block
, __entry
->len
);
298 case I2C_SMBUS_QUICK
:
299 case I2C_SMBUS_I2C_BLOCK_BROKEN
:
304 TP_printk("i2c-%d a=%03x f=%04x c=%x %s l=%u [%*phD]",
309 __print_symbolic(__entry
->protocol
,
310 { I2C_SMBUS_QUICK
, "QUICK" },
311 { I2C_SMBUS_BYTE
, "BYTE" },
312 { I2C_SMBUS_BYTE_DATA
, "BYTE_DATA" },
313 { I2C_SMBUS_WORD_DATA
, "WORD_DATA" },
314 { I2C_SMBUS_PROC_CALL
, "PROC_CALL" },
315 { I2C_SMBUS_BLOCK_DATA
, "BLOCK_DATA" },
316 { I2C_SMBUS_I2C_BLOCK_BROKEN
, "I2C_BLOCK_BROKEN" },
317 { I2C_SMBUS_BLOCK_PROC_CALL
, "BLOCK_PROC_CALL" },
318 { I2C_SMBUS_I2C_BLOCK_DATA
, "I2C_BLOCK_DATA" }),
320 __entry
->len
, __entry
->buf
324 * i2c_smbus_xfer() result
326 TRACE_EVENT(smbus_result
,
327 TP_PROTO(const struct i2c_adapter
*adap
,
328 u16 addr
, unsigned short flags
,
329 char read_write
, u8 command
, int protocol
,
331 TP_ARGS(adap
, addr
, flags
, read_write
, command
, protocol
, res
),
333 __field(int, adapter_nr
)
334 __field(__u16
, addr
)
335 __field(__u16
, flags
)
336 __field(__u8
, read_write
)
337 __field(__u8
, command
)
339 __field(__u32
, protocol
)
342 __entry
->adapter_nr
= adap
->nr
;
343 __entry
->addr
= addr
;
344 __entry
->flags
= flags
;
345 __entry
->read_write
= read_write
;
346 __entry
->command
= command
;
347 __entry
->protocol
= protocol
;
350 TP_printk("i2c-%d a=%03x f=%04x c=%x %s %s res=%d",
355 __print_symbolic(__entry
->protocol
,
356 { I2C_SMBUS_QUICK
, "QUICK" },
357 { I2C_SMBUS_BYTE
, "BYTE" },
358 { I2C_SMBUS_BYTE_DATA
, "BYTE_DATA" },
359 { I2C_SMBUS_WORD_DATA
, "WORD_DATA" },
360 { I2C_SMBUS_PROC_CALL
, "PROC_CALL" },
361 { I2C_SMBUS_BLOCK_DATA
, "BLOCK_DATA" },
362 { I2C_SMBUS_I2C_BLOCK_BROKEN
, "I2C_BLOCK_BROKEN" },
363 { I2C_SMBUS_BLOCK_PROC_CALL
, "BLOCK_PROC_CALL" },
364 { I2C_SMBUS_I2C_BLOCK_DATA
, "I2C_BLOCK_DATA" }),
365 __entry
->read_write
== I2C_SMBUS_WRITE
? "wr" : "rd",
369 #endif /* _TRACE_I2C_H */
371 /* This part must be outside protection */
372 #include <trace/define_trace.h>