2 * Greybus driver and device API
4 * Copyright 2015 Google Inc.
5 * Copyright 2015 Linaro Ltd.
7 * Released under the GPLv2 only.
10 #define TRACE_SYSTEM greybus
12 #if !defined(_TRACE_GREYBUS_H) || defined(TRACE_HEADER_MULTI_READ)
13 #define _TRACE_GREYBUS_H
15 #include <linux/tracepoint.h>
19 struct gb_host_device;
21 #define gb_bundle_name(message) \
22 (message->operation->connection->bundle ? \
23 dev_name(&message->operation->connection->bundle->dev) : \
24 dev_name(&message->operation->connection->hd->svc->dev))
26 DECLARE_EVENT_CLASS(gb_message,
28 TP_PROTO(struct gb_message *message),
33 __string(name, gb_bundle_name(message))
35 __field(u16, intf_cport_id)
36 __field(u16, hd_cport_id)
37 __field(size_t, payload_size)
41 __assign_str(name, gb_bundle_name(message))
42 __entry->op_id = message->operation->id;
43 __entry->intf_cport_id =
44 message->operation->connection->intf_cport_id;
45 __entry->hd_cport_id =
46 message->operation->connection->hd_cport_id;
47 __entry->payload_size = message->payload_size;
50 TP_printk("greybus:%s op=%04x if_id=%u hd_id=%u l=%zu",
51 __get_str(name), __entry->op_id, __entry->intf_cport_id,
52 __entry->hd_cport_id, __entry->payload_size)
55 #define DEFINE_MESSAGE_EVENT(name) \
56 DEFINE_EVENT(gb_message, name, \
57 TP_PROTO(struct gb_message *message), \
61 * Occurs immediately before calling a host device's message_send()
64 DEFINE_MESSAGE_EVENT(gb_message_send);
67 * Occurs after an incoming request message has been received
69 DEFINE_MESSAGE_EVENT(gb_message_recv_request);
72 * Occurs after an incoming response message has been received,
73 * after its matching request has been found.
75 DEFINE_MESSAGE_EVENT(gb_message_recv_response);
78 * Occurs after an operation has been canceled, possibly before the
79 * cancellation is complete.
81 DEFINE_MESSAGE_EVENT(gb_message_cancel_outgoing);
84 * Occurs when an incoming request is cancelled; if the response has
85 * been queued for sending, this occurs after it is sent.
87 DEFINE_MESSAGE_EVENT(gb_message_cancel_incoming);
89 #undef DEFINE_MESSAGE_EVENT
91 DECLARE_EVENT_CLASS(gb_operation,
93 TP_PROTO(struct gb_operation *operation),
98 __field(u16, cport_id) /* CPort of HD side of connection */
99 __field(u16, id) /* Operation ID */
101 __field(unsigned long, flags)
103 __field(int, waiters)
108 __entry->cport_id = operation->connection->hd_cport_id;
109 __entry->id = operation->id;
110 __entry->type = operation->type;
111 __entry->flags = operation->flags;
112 __entry->active = operation->active;
113 __entry->waiters = atomic_read(&operation->waiters);
114 __entry->errno = operation->errno;
117 TP_printk("id=%04x type=0x%02x cport_id=%04x flags=0x%lx active=%d waiters=%d errno=%d",
118 __entry->id, __entry->cport_id, __entry->type, __entry->flags,
119 __entry->active, __entry->waiters, __entry->errno)
122 #define DEFINE_OPERATION_EVENT(name) \
123 DEFINE_EVENT(gb_operation, name, \
124 TP_PROTO(struct gb_operation *operation), \
128 * Occurs after a new operation is created for an outgoing request
129 * has been successfully created.
131 DEFINE_OPERATION_EVENT(gb_operation_create);
134 * Occurs after a new operation has been created for an incoming
135 * request has been successfully created and initialized.
137 DEFINE_OPERATION_EVENT(gb_operation_create_incoming);
140 * Occurs when the last reference to an operation has been dropped,
141 * prior to freeing resources.
143 DEFINE_OPERATION_EVENT(gb_operation_destroy);
146 * Occurs when an operation has been marked active, after updating
149 DEFINE_OPERATION_EVENT(gb_operation_get_active);
152 * Occurs when an operation has been marked active, before updating
155 DEFINE_OPERATION_EVENT(gb_operation_put_active);
157 #undef DEFINE_OPERATION_EVENT
159 DECLARE_EVENT_CLASS(gb_module,
161 TP_PROTO(struct gb_module *module),
166 __field(int, hd_bus_id)
167 __field(u8, module_id)
168 __field(u8, num_interfaces)
169 __field(bool, disconnected)
173 __entry->hd_bus_id = module->hd->bus_id;
174 __entry->module_id = module->module_id;
175 __entry->disconnected = module->disconnected;
178 TP_printk("greybus: hd_bus_id=%d module_id=%hhu disconnected=%u",
179 __entry->hd_bus_id, __entry->module_id, __entry->disconnected)
182 #define DEFINE_MODULE_EVENT(name) \
183 DEFINE_EVENT(gb_module, name, \
184 TP_PROTO(struct gb_module *module), \
188 * Occurs after a new module is successfully created, before
189 * creating any of its interfaces.
191 DEFINE_MODULE_EVENT(gb_module_create);
194 * Occurs after the last reference to a module has been dropped.
196 DEFINE_MODULE_EVENT(gb_module_release);
199 * Occurs after a module is successfully created, before registering
200 * any of its interfaces.
202 DEFINE_MODULE_EVENT(gb_module_add);
205 * Occurs when a module is deleted, before deregistering its
208 DEFINE_MODULE_EVENT(gb_module_del);
210 #undef DEFINE_MODULE_EVENT
212 DECLARE_EVENT_CLASS(gb_interface,
214 TP_PROTO(struct gb_interface *intf),
219 __field(u8, id) /* Interface id */
220 __field(u8, module_id)
221 __field(u8, device_id)
222 __field(bool, disconnected)
223 __field(bool, ejected)
224 __field(bool, active)
225 __field(bool, enabled)
229 __entry->id = intf->interface_id;
230 __entry->module_id = intf->module->module_id;
231 __entry->device_id = intf->device_id;
232 __entry->disconnected = intf->disconnected;
233 __entry->ejected = intf->ejected;
234 __entry->active = intf->active;
235 __entry->enabled = intf->enabled;
238 TP_printk("greybus: intf_id=%hhu device_id=%hhu module_id=%hhu D=%u J=%u A=%u E=%u",
239 __entry->id, __entry->device_id, __entry->module_id,
240 __entry->disconnected, __entry->ejected, __entry->active,
244 #define DEFINE_INTERFACE_EVENT(name) \
245 DEFINE_EVENT(gb_interface, name, \
246 TP_PROTO(struct gb_interface *intf), \
250 * Occurs after a new interface is successfully created.
252 DEFINE_INTERFACE_EVENT(gb_interface_create);
255 * Occurs after the last reference to an interface has been dropped.
257 DEFINE_INTERFACE_EVENT(gb_interface_release);
260 * Occurs after an interface been registerd.
262 DEFINE_INTERFACE_EVENT(gb_interface_add);
265 * Occurs when a registered interface gets deregisterd.
267 DEFINE_INTERFACE_EVENT(gb_interface_del);
270 * Occurs when a registered interface has been successfully
273 DEFINE_INTERFACE_EVENT(gb_interface_activate);
276 * Occurs when an activated interface is being deactivated.
278 DEFINE_INTERFACE_EVENT(gb_interface_deactivate);
281 * Occurs when an interface has been successfully enabled.
283 DEFINE_INTERFACE_EVENT(gb_interface_enable);
286 * Occurs when an enabled interface is being disabled.
288 DEFINE_INTERFACE_EVENT(gb_interface_disable);
290 #undef DEFINE_INTERFACE_EVENT
292 DECLARE_EVENT_CLASS(gb_host_device,
294 TP_PROTO(struct gb_host_device *hd),
300 __field(u8, num_cports)
301 __field(size_t, buffer_size_max)
305 __entry->bus_id = hd->bus_id;
306 __entry->num_cports = hd->num_cports;
307 __entry->buffer_size_max = hd->buffer_size_max;
310 TP_printk("greybus: bus_id=%d num_cports=%hu mtu=%zu",
311 __entry->bus_id, __entry->num_cports,
312 __entry->buffer_size_max)
315 #define DEFINE_HD_EVENT(name) \
316 DEFINE_EVENT(gb_host_device, name, \
317 TP_PROTO(struct gb_host_device *hd), \
321 * Occurs after a new host device is successfully created, before
322 * its SVC has been set up.
324 DEFINE_HD_EVENT(gb_hd_create);
327 * Occurs after the last reference to a host device has been
330 DEFINE_HD_EVENT(gb_hd_release);
333 * Occurs after a new host device has been added, after the
334 * connection to its SVC has * been enabled.
336 DEFINE_HD_EVENT(gb_hd_add);
339 * Occurs when a host device is being disconnected from the AP USB
342 DEFINE_HD_EVENT(gb_hd_del);
344 #undef DEFINE_HD_EVENT
346 #endif /* _TRACE_GREYBUS_H */
348 /* This part must be outside protection */
349 #undef TRACE_INCLUDE_PATH
350 #define TRACE_INCLUDE_PATH .
353 * TRACE_INCLUDE_FILE is not needed if the filename and TRACE_SYSTEM are equal
355 #undef TRACE_INCLUDE_FILE
356 #define TRACE_INCLUDE_FILE greybus_trace
357 #include <trace/define_trace.h>