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_host_device,
161 TP_PROTO(struct gb_host_device *hd),
167 __field(u8, num_cports)
168 __field(size_t, buffer_size_max)
172 __entry->bus_id = hd->bus_id;
173 __entry->num_cports = hd->num_cports;
174 __entry->buffer_size_max = hd->buffer_size_max;
177 TP_printk("greybus: bus_id=%d num_cports=%hu mtu=%zu",
178 __entry->bus_id, __entry->num_cports,
179 __entry->buffer_size_max)
182 #define DEFINE_HD_EVENT(name) \
183 DEFINE_EVENT(gb_host_device, name, \
184 TP_PROTO(struct gb_host_device *hd), \
188 * Occurs after a new host device is successfully created, before
189 * its SVC has been set up.
191 DEFINE_HD_EVENT(gb_hd_create);
194 * Occurs after the last reference to a host device has been
197 DEFINE_HD_EVENT(gb_hd_release);
200 * Occurs after a new host device has been added, after the
201 * connection to its SVC has * been enabled.
203 DEFINE_HD_EVENT(gb_hd_add);
206 * Occurs when a host device is being disconnected from the AP USB
209 DEFINE_HD_EVENT(gb_hd_del);
211 #undef DEFINE_HD_EVENT
213 #endif /* _TRACE_GREYBUS_H */
215 /* This part must be outside protection */
216 #undef TRACE_INCLUDE_PATH
217 #define TRACE_INCLUDE_PATH .
220 * TRACE_INCLUDE_FILE is not needed if the filename and TRACE_SYSTEM are equal
222 #undef TRACE_INCLUDE_FILE
223 #define TRACE_INCLUDE_FILE greybus_trace
224 #include <trace/define_trace.h>