Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Greybus driver and device API
0004  *
0005  * Copyright 2015 Google Inc.
0006  * Copyright 2015 Linaro Ltd.
0007  */
0008 #undef TRACE_SYSTEM
0009 #define TRACE_SYSTEM greybus
0010 
0011 #if !defined(_TRACE_GREYBUS_H) || defined(TRACE_HEADER_MULTI_READ)
0012 #define _TRACE_GREYBUS_H
0013 
0014 #include <linux/tracepoint.h>
0015 
0016 struct gb_message;
0017 struct gb_operation;
0018 struct gb_connection;
0019 struct gb_bundle;
0020 struct gb_host_device;
0021 
0022 DECLARE_EVENT_CLASS(gb_message,
0023 
0024     TP_PROTO(struct gb_message *message),
0025 
0026     TP_ARGS(message),
0027 
0028     TP_STRUCT__entry(
0029         __field(u16, size)
0030         __field(u16, operation_id)
0031         __field(u8, type)
0032         __field(u8, result)
0033     ),
0034 
0035     TP_fast_assign(
0036         __entry->size = le16_to_cpu(message->header->size);
0037         __entry->operation_id =
0038             le16_to_cpu(message->header->operation_id);
0039         __entry->type = message->header->type;
0040         __entry->result = message->header->result;
0041     ),
0042 
0043     TP_printk("size=%u operation_id=0x%04x type=0x%02x result=0x%02x",
0044           __entry->size, __entry->operation_id,
0045           __entry->type, __entry->result)
0046 );
0047 
0048 #define DEFINE_MESSAGE_EVENT(name)                  \
0049         DEFINE_EVENT(gb_message, name,              \
0050                 TP_PROTO(struct gb_message *message),   \
0051                 TP_ARGS(message))
0052 
0053 /*
0054  * Occurs immediately before calling a host device's message_send()
0055  * method.
0056  */
0057 DEFINE_MESSAGE_EVENT(gb_message_send);
0058 
0059 /*
0060  * Occurs after an incoming request message has been received
0061  */
0062 DEFINE_MESSAGE_EVENT(gb_message_recv_request);
0063 
0064 /*
0065  * Occurs after an incoming response message has been received,
0066  * after its matching request has been found.
0067  */
0068 DEFINE_MESSAGE_EVENT(gb_message_recv_response);
0069 
0070 /*
0071  * Occurs after an operation has been canceled, possibly before the
0072  * cancellation is complete.
0073  */
0074 DEFINE_MESSAGE_EVENT(gb_message_cancel_outgoing);
0075 
0076 /*
0077  * Occurs when an incoming request is cancelled; if the response has
0078  * been queued for sending, this occurs after it is sent.
0079  */
0080 DEFINE_MESSAGE_EVENT(gb_message_cancel_incoming);
0081 
0082 /*
0083  * Occurs in the host driver message_send() function just prior to
0084  * handing off the data to be processed by hardware.
0085  */
0086 DEFINE_MESSAGE_EVENT(gb_message_submit);
0087 
0088 #undef DEFINE_MESSAGE_EVENT
0089 
0090 DECLARE_EVENT_CLASS(gb_operation,
0091 
0092     TP_PROTO(struct gb_operation *operation),
0093 
0094     TP_ARGS(operation),
0095 
0096     TP_STRUCT__entry(
0097         __field(u16, cport_id)  /* CPort of HD side of connection */
0098         __field(u16, id)    /* Operation ID */
0099         __field(u8, type)
0100         __field(unsigned long, flags)
0101         __field(int, active)
0102         __field(int, waiters)
0103         __field(int, errno)
0104     ),
0105 
0106     TP_fast_assign(
0107         __entry->cport_id = operation->connection->hd_cport_id;
0108         __entry->id = operation->id;
0109         __entry->type = operation->type;
0110         __entry->flags = operation->flags;
0111         __entry->active = operation->active;
0112         __entry->waiters = atomic_read(&operation->waiters);
0113         __entry->errno = operation->errno;
0114     ),
0115 
0116     TP_printk("id=%04x type=0x%02x cport_id=%04x flags=0x%lx active=%d waiters=%d errno=%d",
0117           __entry->id, __entry->cport_id, __entry->type, __entry->flags,
0118           __entry->active, __entry->waiters, __entry->errno)
0119 );
0120 
0121 #define DEFINE_OPERATION_EVENT(name)                    \
0122         DEFINE_EVENT(gb_operation, name,            \
0123                 TP_PROTO(struct gb_operation *operation), \
0124                 TP_ARGS(operation))
0125 
0126 /*
0127  * Occurs after a new operation is created for an outgoing request
0128  * has been successfully created.
0129  */
0130 DEFINE_OPERATION_EVENT(gb_operation_create);
0131 
0132 /*
0133  * Occurs after a new core operation has been created.
0134  */
0135 DEFINE_OPERATION_EVENT(gb_operation_create_core);
0136 
0137 /*
0138  * Occurs after a new operation has been created for an incoming
0139  * request has been successfully created and initialized.
0140  */
0141 DEFINE_OPERATION_EVENT(gb_operation_create_incoming);
0142 
0143 /*
0144  * Occurs when the last reference to an operation has been dropped,
0145  * prior to freeing resources.
0146  */
0147 DEFINE_OPERATION_EVENT(gb_operation_destroy);
0148 
0149 /*
0150  * Occurs when an operation has been marked active, after updating
0151  * its active count.
0152  */
0153 DEFINE_OPERATION_EVENT(gb_operation_get_active);
0154 
0155 /*
0156  * Occurs when an operation has been marked active, before updating
0157  * its active count.
0158  */
0159 DEFINE_OPERATION_EVENT(gb_operation_put_active);
0160 
0161 #undef DEFINE_OPERATION_EVENT
0162 
0163 DECLARE_EVENT_CLASS(gb_connection,
0164 
0165     TP_PROTO(struct gb_connection *connection),
0166 
0167     TP_ARGS(connection),
0168 
0169     TP_STRUCT__entry(
0170         __field(int, hd_bus_id)
0171         __field(u8, bundle_id)
0172         /* name contains "hd_cport_id/intf_id:cport_id" */
0173         __dynamic_array(char, name, sizeof(connection->name))
0174         __field(enum gb_connection_state, state)
0175         __field(unsigned long, flags)
0176     ),
0177 
0178     TP_fast_assign(
0179         __entry->hd_bus_id = connection->hd->bus_id;
0180         __entry->bundle_id = connection->bundle ?
0181                 connection->bundle->id : BUNDLE_ID_NONE;
0182         memcpy(__get_str(name), connection->name,
0183                     sizeof(connection->name));
0184         __entry->state = connection->state;
0185         __entry->flags = connection->flags;
0186     ),
0187 
0188     TP_printk("hd_bus_id=%d bundle_id=0x%02x name=\"%s\" state=%u flags=0x%lx",
0189           __entry->hd_bus_id, __entry->bundle_id, __get_str(name),
0190           (unsigned int)__entry->state, __entry->flags)
0191 );
0192 
0193 #define DEFINE_CONNECTION_EVENT(name)                   \
0194         DEFINE_EVENT(gb_connection, name,           \
0195                 TP_PROTO(struct gb_connection *connection), \
0196                 TP_ARGS(connection))
0197 
0198 /*
0199  * Occurs after a new connection is successfully created.
0200  */
0201 DEFINE_CONNECTION_EVENT(gb_connection_create);
0202 
0203 /*
0204  * Occurs when the last reference to a connection has been dropped,
0205  * before its resources are freed.
0206  */
0207 DEFINE_CONNECTION_EVENT(gb_connection_release);
0208 
0209 /*
0210  * Occurs when a new reference to connection is added, currently
0211  * only when a message over the connection is received.
0212  */
0213 DEFINE_CONNECTION_EVENT(gb_connection_get);
0214 
0215 /*
0216  * Occurs when a new reference to connection is dropped, after a
0217  * a received message is handled, or when the connection is
0218  * destroyed.
0219  */
0220 DEFINE_CONNECTION_EVENT(gb_connection_put);
0221 
0222 /*
0223  * Occurs when a request to enable a connection is made, either for
0224  * transmit only, or for both transmit and receive.
0225  */
0226 DEFINE_CONNECTION_EVENT(gb_connection_enable);
0227 
0228 /*
0229  * Occurs when a request to disable a connection is made, either for
0230  * receive only, or for both transmit and receive.  Also occurs when
0231  * a request to forcefully disable a connection is made.
0232  */
0233 DEFINE_CONNECTION_EVENT(gb_connection_disable);
0234 
0235 #undef DEFINE_CONNECTION_EVENT
0236 
0237 DECLARE_EVENT_CLASS(gb_bundle,
0238 
0239     TP_PROTO(struct gb_bundle *bundle),
0240 
0241     TP_ARGS(bundle),
0242 
0243     TP_STRUCT__entry(
0244         __field(u8, intf_id)
0245         __field(u8, id)
0246         __field(u8, class)
0247         __field(size_t, num_cports)
0248     ),
0249 
0250     TP_fast_assign(
0251         __entry->intf_id = bundle->intf->interface_id;
0252         __entry->id = bundle->id;
0253         __entry->class = bundle->class;
0254         __entry->num_cports = bundle->num_cports;
0255     ),
0256 
0257     TP_printk("intf_id=0x%02x id=%02x class=0x%02x num_cports=%zu",
0258           __entry->intf_id, __entry->id, __entry->class,
0259           __entry->num_cports)
0260 );
0261 
0262 #define DEFINE_BUNDLE_EVENT(name)                   \
0263         DEFINE_EVENT(gb_bundle, name,           \
0264                 TP_PROTO(struct gb_bundle *bundle), \
0265                 TP_ARGS(bundle))
0266 
0267 /*
0268  * Occurs after a new bundle is successfully created.
0269  */
0270 DEFINE_BUNDLE_EVENT(gb_bundle_create);
0271 
0272 /*
0273  * Occurs when the last reference to a bundle has been dropped,
0274  * before its resources are freed.
0275  */
0276 DEFINE_BUNDLE_EVENT(gb_bundle_release);
0277 
0278 /*
0279  * Occurs when a bundle is added to an interface when the interface
0280  * is enabled.
0281  */
0282 DEFINE_BUNDLE_EVENT(gb_bundle_add);
0283 
0284 /*
0285  * Occurs when a registered bundle gets destroyed, normally at the
0286  * time an interface is disabled.
0287  */
0288 DEFINE_BUNDLE_EVENT(gb_bundle_destroy);
0289 
0290 #undef DEFINE_BUNDLE_EVENT
0291 
0292 DECLARE_EVENT_CLASS(gb_interface,
0293 
0294     TP_PROTO(struct gb_interface *intf),
0295 
0296     TP_ARGS(intf),
0297 
0298     TP_STRUCT__entry(
0299         __field(u8, module_id)
0300         __field(u8, id)     /* Interface id */
0301         __field(u8, device_id)
0302         __field(int, disconnected)  /* bool */
0303         __field(int, ejected)       /* bool */
0304         __field(int, active)        /* bool */
0305         __field(int, enabled)       /* bool */
0306         __field(int, mode_switch)   /* bool */
0307     ),
0308 
0309     TP_fast_assign(
0310         __entry->module_id = intf->module->module_id;
0311         __entry->id = intf->interface_id;
0312         __entry->device_id = intf->device_id;
0313         __entry->disconnected = intf->disconnected;
0314         __entry->ejected = intf->ejected;
0315         __entry->active = intf->active;
0316         __entry->enabled = intf->enabled;
0317         __entry->mode_switch = intf->mode_switch;
0318     ),
0319 
0320     TP_printk("intf_id=%u device_id=%u module_id=%u D=%d J=%d A=%d E=%d M=%d",
0321         __entry->id, __entry->device_id, __entry->module_id,
0322         __entry->disconnected, __entry->ejected, __entry->active,
0323         __entry->enabled, __entry->mode_switch)
0324 );
0325 
0326 #define DEFINE_INTERFACE_EVENT(name)                    \
0327         DEFINE_EVENT(gb_interface, name,            \
0328                 TP_PROTO(struct gb_interface *intf),    \
0329                 TP_ARGS(intf))
0330 
0331 /*
0332  * Occurs after a new interface is successfully created.
0333  */
0334 DEFINE_INTERFACE_EVENT(gb_interface_create);
0335 
0336 /*
0337  * Occurs after the last reference to an interface has been dropped.
0338  */
0339 DEFINE_INTERFACE_EVENT(gb_interface_release);
0340 
0341 /*
0342  * Occurs after an interface been registerd.
0343  */
0344 DEFINE_INTERFACE_EVENT(gb_interface_add);
0345 
0346 /*
0347  * Occurs when a registered interface gets deregisterd.
0348  */
0349 DEFINE_INTERFACE_EVENT(gb_interface_del);
0350 
0351 /*
0352  * Occurs when a registered interface has been successfully
0353  * activated.
0354  */
0355 DEFINE_INTERFACE_EVENT(gb_interface_activate);
0356 
0357 /*
0358  * Occurs when an activated interface is being deactivated.
0359  */
0360 DEFINE_INTERFACE_EVENT(gb_interface_deactivate);
0361 
0362 /*
0363  * Occurs when an interface has been successfully enabled.
0364  */
0365 DEFINE_INTERFACE_EVENT(gb_interface_enable);
0366 
0367 /*
0368  * Occurs when an enabled interface is being disabled.
0369  */
0370 DEFINE_INTERFACE_EVENT(gb_interface_disable);
0371 
0372 #undef DEFINE_INTERFACE_EVENT
0373 
0374 DECLARE_EVENT_CLASS(gb_module,
0375 
0376     TP_PROTO(struct gb_module *module),
0377 
0378     TP_ARGS(module),
0379 
0380     TP_STRUCT__entry(
0381         __field(int, hd_bus_id)
0382         __field(u8, module_id)
0383         __field(size_t, num_interfaces)
0384         __field(int, disconnected)  /* bool */
0385     ),
0386 
0387     TP_fast_assign(
0388         __entry->hd_bus_id = module->hd->bus_id;
0389         __entry->module_id = module->module_id;
0390         __entry->num_interfaces = module->num_interfaces;
0391         __entry->disconnected = module->disconnected;
0392     ),
0393 
0394     TP_printk("hd_bus_id=%d module_id=%u num_interfaces=%zu disconnected=%d",
0395         __entry->hd_bus_id, __entry->module_id,
0396         __entry->num_interfaces, __entry->disconnected)
0397 );
0398 
0399 #define DEFINE_MODULE_EVENT(name)                   \
0400         DEFINE_EVENT(gb_module, name,               \
0401                 TP_PROTO(struct gb_module *module), \
0402                 TP_ARGS(module))
0403 
0404 /*
0405  * Occurs after a new module is successfully created, before
0406  * creating any of its interfaces.
0407  */
0408 DEFINE_MODULE_EVENT(gb_module_create);
0409 
0410 /*
0411  * Occurs after the last reference to a module has been dropped.
0412  */
0413 DEFINE_MODULE_EVENT(gb_module_release);
0414 
0415 /*
0416  * Occurs after a module is successfully created, before registering
0417  * any of its interfaces.
0418  */
0419 DEFINE_MODULE_EVENT(gb_module_add);
0420 
0421 /*
0422  * Occurs when a module is deleted, before deregistering its
0423  * interfaces.
0424  */
0425 DEFINE_MODULE_EVENT(gb_module_del);
0426 
0427 #undef DEFINE_MODULE_EVENT
0428 
0429 DECLARE_EVENT_CLASS(gb_host_device,
0430 
0431     TP_PROTO(struct gb_host_device *hd),
0432 
0433     TP_ARGS(hd),
0434 
0435     TP_STRUCT__entry(
0436         __field(int, bus_id)
0437         __field(size_t, num_cports)
0438         __field(size_t, buffer_size_max)
0439     ),
0440 
0441     TP_fast_assign(
0442         __entry->bus_id = hd->bus_id;
0443         __entry->num_cports = hd->num_cports;
0444         __entry->buffer_size_max = hd->buffer_size_max;
0445     ),
0446 
0447     TP_printk("bus_id=%d num_cports=%zu mtu=%zu",
0448         __entry->bus_id, __entry->num_cports,
0449         __entry->buffer_size_max)
0450 );
0451 
0452 #define DEFINE_HD_EVENT(name)                       \
0453         DEFINE_EVENT(gb_host_device, name,          \
0454                 TP_PROTO(struct gb_host_device *hd),    \
0455                 TP_ARGS(hd))
0456 
0457 /*
0458  * Occurs after a new host device is successfully created, before
0459  * its SVC has been set up.
0460  */
0461 DEFINE_HD_EVENT(gb_hd_create);
0462 
0463 /*
0464  * Occurs after the last reference to a host device has been
0465  * dropped.
0466  */
0467 DEFINE_HD_EVENT(gb_hd_release);
0468 
0469 /*
0470  * Occurs after a new host device has been added, after the
0471  * connection to its SVC has been enabled.
0472  */
0473 DEFINE_HD_EVENT(gb_hd_add);
0474 
0475 /*
0476  * Occurs when a host device is being disconnected from the AP USB
0477  * host controller.
0478  */
0479 DEFINE_HD_EVENT(gb_hd_del);
0480 
0481 /*
0482  * Occurs when a host device has passed received data to the Greybus
0483  * core, after it has been determined it is destined for a valid
0484  * CPort.
0485  */
0486 DEFINE_HD_EVENT(gb_hd_in);
0487 
0488 #undef DEFINE_HD_EVENT
0489 
0490 #endif /* _TRACE_GREYBUS_H */
0491 
0492 /* This part must be outside protection */
0493 #undef TRACE_INCLUDE_PATH
0494 #define TRACE_INCLUDE_PATH .
0495 
0496 /*
0497  * TRACE_INCLUDE_FILE is not needed if the filename and TRACE_SYSTEM are equal
0498  */
0499 #undef TRACE_INCLUDE_FILE
0500 #define TRACE_INCLUDE_FILE greybus_trace
0501 #include <trace/define_trace.h>
0502