Chris Lew | fa6135e | 2016-08-01 13:29:46 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2015, The Linux Foundation. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | #ifndef _TRACER_PKT_H_ |
| 13 | #define _TRACER_PKT_H_ |
| 14 | |
| 15 | #include <linux/err.h> |
| 16 | #include <linux/types.h> |
| 17 | |
| 18 | #ifdef CONFIG_TRACER_PKT |
| 19 | |
| 20 | /** |
| 21 | * tracer_pkt_init() - initialize the tracer packet |
| 22 | * @data: Pointer to the buffer to be initialized with a tracer |
| 23 | * packet. |
| 24 | * @data_len: Length of the buffer. |
| 25 | * @client_event_cfg: Client-specific event configuration mask. |
| 26 | * @glink_event_cfg: G-Link-specific event configuration mask. |
| 27 | * @pkt_priv: Private/Cookie information to be added to the tracer |
| 28 | * packet. |
| 29 | * @pkt_priv_len: Length of the private data. |
| 30 | * |
| 31 | * This function is used to initialize a buffer with the tracer packet header. |
| 32 | * The tracer packet header includes the data as passed by the elements in the |
| 33 | * parameters. |
| 34 | * |
| 35 | * Return: 0 on success, standard Linux error codes on failure. |
| 36 | */ |
| 37 | int tracer_pkt_init(void *data, size_t data_len, |
| 38 | uint16_t client_event_cfg, uint32_t glink_event_cfg, |
| 39 | void *pkt_priv, size_t pkt_priv_len); |
| 40 | |
| 41 | /** |
| 42 | * tracer_pkt_set_event_cfg() - set the event configuration mask in the tracer |
| 43 | * packet |
| 44 | * @data: Pointer to the buffer to be initialized with event |
| 45 | * configuration mask. |
| 46 | * @client_event_cfg: Client-specific event configuration mask. |
| 47 | * @glink_event_cfg: G-Link-specific event configuration mask. |
| 48 | * |
| 49 | * This function is used to initialize a buffer with the event configuration |
| 50 | * mask as passed by the elements in the parameters. |
| 51 | * |
| 52 | * Return: 0 on success, standard Linux error codes on failure. |
| 53 | */ |
| 54 | int tracer_pkt_set_event_cfg(void *data, uint16_t client_event_cfg, |
| 55 | uint32_t glink_event_cfg); |
| 56 | |
| 57 | /** |
| 58 | * tracer_pkt_log_event() - log an event specific to the tracer packet |
| 59 | * @data: Pointer to the buffer containing tracer packet. |
| 60 | * @event_id: Event ID to be logged. |
| 61 | * |
| 62 | * This function is used to log an event specific to the tracer packet. |
| 63 | * The event is logged either into the tracer packet itself or a different |
| 64 | * tracing mechanism as configured. |
| 65 | * |
| 66 | * Return: 0 on success, standard Linux error codes on failure. |
| 67 | */ |
| 68 | int tracer_pkt_log_event(void *data, uint32_t event_id); |
| 69 | |
| 70 | /** |
| 71 | * tracer_pkt_calc_hex_dump_size() - calculate the hex dump size of a tracer |
| 72 | * packet |
| 73 | * @data: Pointer to the buffer containing tracer packet. |
| 74 | * @data_len: Length of the tracer packet buffer. |
| 75 | * |
| 76 | * This function is used to calculate the length of the buffer required to |
| 77 | * hold the hex dump of the tracer packet. |
| 78 | * |
| 79 | * Return: 0 on success, standard Linux error codes on failure. |
| 80 | */ |
| 81 | size_t tracer_pkt_calc_hex_dump_size(void *data, size_t data_len); |
| 82 | |
| 83 | /** |
| 84 | * tracer_pkt_hex_dump() - hex dump the tracer packet into a buffer |
| 85 | * @buf: Buffer to contain the hex dump of the tracer packet. |
| 86 | * @buf_len: Length of the hex dump buffer. |
| 87 | * @data: Buffer containing the tracer packet. |
| 88 | * @data_len: Length of the buffer containing the tracer packet. |
| 89 | * |
| 90 | * This function is used to dump the contents of the tracer packet into |
| 91 | * a buffer in a specific hexadecimal format. The hex dump buffer can then |
| 92 | * be dumped through debugfs. |
| 93 | * |
| 94 | * Return: 0 on success, standard Linux error codes on failure. |
| 95 | */ |
| 96 | int tracer_pkt_hex_dump(void *buf, size_t buf_len, void *data, size_t data_len); |
| 97 | |
| 98 | #else |
| 99 | |
| 100 | static inline int tracer_pkt_init(void *data, size_t data_len, |
| 101 | uint16_t client_event_cfg, uint32_t glink_event_cfg, |
| 102 | void *pkt_priv, size_t pkt_priv_len) |
| 103 | { |
| 104 | return -EOPNOTSUPP; |
| 105 | } |
| 106 | |
| 107 | static inline int tracer_pkt_set_event_cfg(uint16_t client_event_cfg, |
| 108 | uint32_t glink_event_cfg) |
| 109 | { |
| 110 | return -EOPNOTSUPP; |
| 111 | } |
| 112 | |
| 113 | static inline int tracer_pkt_log_event(void *data, uint32_t event_id) |
| 114 | { |
| 115 | return -EOPNOTSUPP; |
| 116 | } |
| 117 | |
| 118 | static inline size_t tracer_pkt_calc_hex_dump_size(void *data, size_t data_len) |
| 119 | { |
| 120 | return -EOPNOTSUPP; |
| 121 | } |
| 122 | |
| 123 | static inline int tracer_pkt_hex_dump(void *buf, size_t buf_len, void *data, |
| 124 | size_t data_len) |
| 125 | { |
| 126 | return -EOPNOTSUPP; |
| 127 | } |
| 128 | |
| 129 | #endif /* CONFIG_TRACER_PKT */ |
| 130 | #endif /* _TRACER_PKT_H_ */ |