2 * Copyright(c) 2012-2018 Intel Corporation
3 * SPDX-License-Identifier: BSD-3-Clause-Clear
6 #ifndef __OCF_TRACE_H__
7 #define __OCF_TRACE_H__
10 #include "ocf_types.h"
12 typedef uint64_t log_sid_t
;
14 #define OCF_EVENT_VERSION 1
15 #define OCF_TRACING_STOP 1
18 * @brief OCF trace (event) type
21 /** IO trace description, this event is pushed first to indicate version
22 * of traces, number of cores and provides details about cache */
23 ocf_event_type_cache_desc
,
25 /** Event describing ocf core */
26 ocf_event_type_core_desc
,
32 ocf_event_type_io_cmpl
,
34 /** IO in file domain */
35 ocf_event_type_io_file
,
39 * @brief Generic OCF trace event
41 struct ocf_event_hdr
{
42 /** Event sequence ID */
48 /** Trace event type */
51 /** Size of this event */
56 * @brief Cache trace description
58 struct ocf_event_cache_desc
{
60 struct ocf_event_hdr hdr
;
65 /** Cache line size */
66 ocf_cache_line_size_t cache_line_size
;
69 ocf_cache_mode_t cache_mode
;
71 /** Cache size in bytes*/
74 /** Number of cores */
82 * @brief Core trace description
84 struct ocf_event_core_desc
{
86 struct ocf_event_hdr hdr
;
91 /** Core size in bytes */
95 /** @brief IO operation */
98 ocf_event_operation_rd
= 'R',
101 ocf_event_operation_wr
= 'W',
104 ocf_event_operation_flush
= 'F',
107 ocf_event_operation_discard
= 'D',
108 } ocf_event_operation_t
;
111 * @brief IO trace event
113 struct ocf_event_io
{
114 /** Trace event header */
115 struct ocf_event_hdr hdr
;
117 /** Address of IO in bytes */
120 /** Size of IO in bytes */
123 /** IO class of IO */
127 ocf_core_id_t core_id
;
129 /** Operation type: read, write, trim or flush **/
130 ocf_event_operation_t operation
;
134 * @brief IO completion event
136 struct ocf_event_io_cmpl
{
137 /** Trace event header */
138 struct ocf_event_hdr hdr
;
140 /** Reference event sequence ID */
143 /** Was IO a cache hit or miss */
148 /** @brief Push log callback.
150 * @param[in] cache OCF cache
151 * @param[in] trace_ctx Tracing context
152 * @param[in] queue Queue handle
153 * @param[out] trace Event log
154 * @param[out] size Size of event log
156 * @return 0 If pushing trace succeeded
157 * @return Non-zero error
159 typedef void (*ocf_trace_callback_t
)(ocf_cache_t cache
, void *trace_ctx
,
160 ocf_queue_t queue
, const void* trace
, const uint32_t size
);
163 * @brief Start tracing
165 * @param[in] cache OCF cache
166 * @param[in] trace_ctx Tracing context
167 * @param[in] trace_callback Callback used for pushing logs
169 * @retval 0 Tracing started successfully
170 * @retval Non-zero Error
172 int ocf_mngt_start_trace(ocf_cache_t cache
, void *trace_ctx
,
173 ocf_trace_callback_t trace_callback
);
176 * @brief Stop tracing
178 * @param[in] cache OCF cache
180 * @retval 0 Tracing stopped successfully
181 * @retval Non-zero Error
183 int ocf_mngt_stop_trace(ocf_cache_t cache
);
185 #endif /* __OCF_TRACE_H__ */