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>
21 struct gb_host_device;
23 DECLARE_EVENT_CLASS(gb_message,
25 TP_PROTO(struct gb_message *message),
31 __field(u16, operation_id)
37 __entry->size = le16_to_cpu(message->header->size);
38 __entry->operation_id =
39 le16_to_cpu(message->header->operation_id);
40 __entry->type = message->header->type;
41 __entry->result = message->header->result;
44 TP_printk("size=%hu operation_id=0x%04x type=0x%02x result=0x%02x",
45 __entry->size, __entry->operation_id,
46 __entry->type, __entry->result)
49 #define DEFINE_MESSAGE_EVENT(name) \
50 DEFINE_EVENT(gb_message, name, \
51 TP_PROTO(struct gb_message *message), \
55 * Occurs immediately before calling a host device's message_send()
58 DEFINE_MESSAGE_EVENT(gb_message_send);
61 * Occurs after an incoming request message has been received
63 DEFINE_MESSAGE_EVENT(gb_message_recv_request);
66 * Occurs after an incoming response message has been received,
67 * after its matching request has been found.
69 DEFINE_MESSAGE_EVENT(gb_message_recv_response);
72 * Occurs after an operation has been canceled, possibly before the
73 * cancellation is complete.
75 DEFINE_MESSAGE_EVENT(gb_message_cancel_outgoing);
78 * Occurs when an incoming request is cancelled; if the response has
79 * been queued for sending, this occurs after it is sent.
81 DEFINE_MESSAGE_EVENT(gb_message_cancel_incoming);
84 * Occurs in the host driver message_send() function just prior to
85 * handing off the data to be processed by hardware.
87 DEFINE_MESSAGE_EVENT(gb_message_submit);
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 core operation has been created.
136 DEFINE_OPERATION_EVENT(gb_operation_create_core);
139 * Occurs after a new operation has been created for an incoming
140 * request has been successfully created and initialized.
142 DEFINE_OPERATION_EVENT(gb_operation_create_incoming);
145 * Occurs when the last reference to an operation has been dropped,
146 * prior to freeing resources.
148 DEFINE_OPERATION_EVENT(gb_operation_destroy);
151 * Occurs when an operation has been marked active, after updating
154 DEFINE_OPERATION_EVENT(gb_operation_get_active);
157 * Occurs when an operation has been marked active, before updating
160 DEFINE_OPERATION_EVENT(gb_operation_put_active);
162 #undef DEFINE_OPERATION_EVENT
164 DECLARE_EVENT_CLASS(gb_connection,
166 TP_PROTO(struct gb_connection *connection),
171 __field(int, hd_bus_id)
172 __field(u8, bundle_id)
173 /* name contains "hd_cport_id/intf_id:cport_id" */
174 __dynamic_array(char, name, sizeof(connection->name))
175 __field(enum gb_connection_state, state)
176 __field(unsigned long, flags)
180 __entry->hd_bus_id = connection->hd->bus_id;
181 __entry->bundle_id = connection->bundle ?
182 connection->bundle->id : BUNDLE_ID_NONE;
183 memcpy(__get_str(name), connection->name,
184 sizeof(connection->name));
185 __entry->state = connection->state;
186 __entry->flags = connection->flags;
189 TP_printk("hd_bus_id=%d bundle_id=0x%02x name=\"%s\" state=%u flags=0x%lx",
190 __entry->hd_bus_id, __entry->bundle_id, __get_str(name),
191 (unsigned int)__entry->state, __entry->flags)
194 #define DEFINE_CONNECTION_EVENT(name) \
195 DEFINE_EVENT(gb_connection, name, \
196 TP_PROTO(struct gb_connection *connection), \
200 * Occurs after a new connection is successfully created.
202 DEFINE_CONNECTION_EVENT(gb_connection_create);
205 * Occurs when the last reference to a connection has been dropped,
206 * before its resources are freed.
208 DEFINE_CONNECTION_EVENT(gb_connection_release);
211 * Occurs when a new reference to connection is added, currently
212 * only when a message over the connection is received.
214 DEFINE_CONNECTION_EVENT(gb_connection_get);
217 * Occurs when a new reference to connection is dropped, after a
218 * a received message is handled, or when the connection is
221 DEFINE_CONNECTION_EVENT(gb_connection_put);
224 * Occurs when a request to enable a connection is made, either for
225 * transmit only, or for both transmit and receive.
227 DEFINE_CONNECTION_EVENT(gb_connection_enable);
230 * Occurs when a request to disable a connection is made, either for
231 * receive only, or for both transmit and receive. Also occurs when
232 * a request to forcefully disable a connection is made.
234 DEFINE_CONNECTION_EVENT(gb_connection_disable);
236 #undef DEFINE_CONNECTION_EVENT
238 DECLARE_EVENT_CLASS(gb_bundle,
240 TP_PROTO(struct gb_bundle *bundle),
248 __field(size_t, num_cports)
252 __entry->intf_id = bundle->intf->interface_id;
253 __entry->id = bundle->id;
254 __entry->class = bundle->class;
255 __entry->num_cports = bundle->num_cports;
258 TP_printk("intf_id=0x%02x id=%02x class=0x%02x num_cports=%zu",
259 __entry->intf_id, __entry->id, __entry->class,
263 #define DEFINE_BUNDLE_EVENT(name) \
264 DEFINE_EVENT(gb_bundle, name, \
265 TP_PROTO(struct gb_bundle *bundle), \
269 * Occurs after a new bundle is successfully created.
271 DEFINE_BUNDLE_EVENT(gb_bundle_create);
274 * Occurs when the last reference to a bundle has been dropped,
275 * before its resources are freed.
277 DEFINE_BUNDLE_EVENT(gb_bundle_release);
280 * Occurs when a bundle is added to an interface when the interface
283 DEFINE_BUNDLE_EVENT(gb_bundle_add);
286 * Occurs when a registered bundle gets destroyed, normally at the
287 * time an interface is disabled.
289 DEFINE_BUNDLE_EVENT(gb_bundle_destroy);
291 #undef DEFINE_BUNDLE_EVENT
293 DECLARE_EVENT_CLASS(gb_interface,
295 TP_PROTO(struct gb_interface *intf),
300 __field(u8, module_id)
301 __field(u8, id) /* Interface id */
302 __field(u8, device_id)
303 __field(int, disconnected) /* bool */
304 __field(int, ejected) /* bool */
305 __field(int, active) /* bool */
306 __field(int, enabled) /* bool */
307 __field(int, mode_switch) /* bool */
311 __entry->module_id = intf->module->module_id;
312 __entry->id = intf->interface_id;
313 __entry->device_id = intf->device_id;
314 __entry->disconnected = intf->disconnected;
315 __entry->ejected = intf->ejected;
316 __entry->active = intf->active;
317 __entry->enabled = intf->enabled;
318 __entry->mode_switch = intf->mode_switch;
321 TP_printk("intf_id=%hhu device_id=%hhu module_id=%hhu D=%d J=%d A=%d E=%d M=%d",
322 __entry->id, __entry->device_id, __entry->module_id,
323 __entry->disconnected, __entry->ejected, __entry->active,
324 __entry->enabled, __entry->mode_switch)
327 #define DEFINE_INTERFACE_EVENT(name) \
328 DEFINE_EVENT(gb_interface, name, \
329 TP_PROTO(struct gb_interface *intf), \
333 * Occurs after a new interface is successfully created.
335 DEFINE_INTERFACE_EVENT(gb_interface_create);
338 * Occurs after the last reference to an interface has been dropped.
340 DEFINE_INTERFACE_EVENT(gb_interface_release);
343 * Occurs after an interface been registerd.
345 DEFINE_INTERFACE_EVENT(gb_interface_add);
348 * Occurs when a registered interface gets deregisterd.
350 DEFINE_INTERFACE_EVENT(gb_interface_del);
353 * Occurs when a registered interface has been successfully
356 DEFINE_INTERFACE_EVENT(gb_interface_activate);
359 * Occurs when an activated interface is being deactivated.
361 DEFINE_INTERFACE_EVENT(gb_interface_deactivate);
364 * Occurs when an interface has been successfully enabled.
366 DEFINE_INTERFACE_EVENT(gb_interface_enable);
369 * Occurs when an enabled interface is being disabled.
371 DEFINE_INTERFACE_EVENT(gb_interface_disable);
373 #undef DEFINE_INTERFACE_EVENT
375 DECLARE_EVENT_CLASS(gb_module,
377 TP_PROTO(struct gb_module *module),
382 __field(int, hd_bus_id)
383 __field(u8, module_id)
384 __field(size_t, num_interfaces)
385 __field(int, disconnected) /* bool */
389 __entry->hd_bus_id = module->hd->bus_id;
390 __entry->module_id = module->module_id;
391 __entry->num_interfaces = module->num_interfaces;
392 __entry->disconnected = module->disconnected;
395 TP_printk("hd_bus_id=%d module_id=%hhu num_interfaces=%zu disconnected=%d",
396 __entry->hd_bus_id, __entry->module_id,
397 __entry->num_interfaces, __entry->disconnected)
400 #define DEFINE_MODULE_EVENT(name) \
401 DEFINE_EVENT(gb_module, name, \
402 TP_PROTO(struct gb_module *module), \
406 * Occurs after a new module is successfully created, before
407 * creating any of its interfaces.
409 DEFINE_MODULE_EVENT(gb_module_create);
412 * Occurs after the last reference to a module has been dropped.
414 DEFINE_MODULE_EVENT(gb_module_release);
417 * Occurs after a module is successfully created, before registering
418 * any of its interfaces.
420 DEFINE_MODULE_EVENT(gb_module_add);
423 * Occurs when a module is deleted, before deregistering its
426 DEFINE_MODULE_EVENT(gb_module_del);
428 #undef DEFINE_MODULE_EVENT
430 DECLARE_EVENT_CLASS(gb_host_device,
432 TP_PROTO(struct gb_host_device *hd),
438 __field(size_t, num_cports)
439 __field(size_t, buffer_size_max)
443 __entry->bus_id = hd->bus_id;
444 __entry->num_cports = hd->num_cports;
445 __entry->buffer_size_max = hd->buffer_size_max;
448 TP_printk("bus_id=%d num_cports=%zu mtu=%zu",
449 __entry->bus_id, __entry->num_cports,
450 __entry->buffer_size_max)
453 #define DEFINE_HD_EVENT(name) \
454 DEFINE_EVENT(gb_host_device, name, \
455 TP_PROTO(struct gb_host_device *hd), \
459 * Occurs after a new host device is successfully created, before
460 * its SVC has been set up.
462 DEFINE_HD_EVENT(gb_hd_create);
465 * Occurs after the last reference to a host device has been
468 DEFINE_HD_EVENT(gb_hd_release);
471 * Occurs after a new host device has been added, after the
472 * connection to its SVC has been enabled.
474 DEFINE_HD_EVENT(gb_hd_add);
477 * Occurs when a host device is being disconnected from the AP USB
480 DEFINE_HD_EVENT(gb_hd_del);
483 * Occurs when a host device has passed received data to the Greybus
484 * core, after it has been determined it is destined for a valid
487 DEFINE_HD_EVENT(gb_hd_in);
489 #undef DEFINE_HD_EVENT
491 #endif /* _TRACE_GREYBUS_H */
493 /* This part must be outside protection */
494 #undef TRACE_INCLUDE_PATH
495 #define TRACE_INCLUDE_PATH .
498 * TRACE_INCLUDE_FILE is not needed if the filename and TRACE_SYSTEM are equal
500 #undef TRACE_INCLUDE_FILE
501 #define TRACE_INCLUDE_FILE greybus_trace
502 #include <trace/define_trace.h>