]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/ocf/inc/ocf_trace.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / spdk / ocf / inc / ocf_trace.h
1 /*
2 * Copyright(c) 2012-2018 Intel Corporation
3 * SPDX-License-Identifier: BSD-3-Clause-Clear
4 */
5
6 #ifndef __OCF_TRACE_H__
7 #define __OCF_TRACE_H__
8
9 #include "ocf_def.h"
10 #include "ocf_types.h"
11
12 typedef uint64_t log_sid_t;
13
14 #define OCF_EVENT_VERSION 1
15 #define OCF_TRACING_STOP 1
16
17 /**
18 * @brief OCF trace (event) type
19 */
20 typedef enum {
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,
24
25 /** Event describing ocf core */
26 ocf_event_type_core_desc,
27
28 /** IO */
29 ocf_event_type_io,
30
31 /** IO completion */
32 ocf_event_type_io_cmpl,
33
34 /** IO in file domain */
35 ocf_event_type_io_file,
36 } ocf_event_type;
37
38 /**
39 * @brief Generic OCF trace event
40 */
41 struct ocf_event_hdr {
42 /** Event sequence ID */
43 log_sid_t sid;
44
45 /** Time stamp */
46 uint64_t timestamp;
47
48 /** Trace event type */
49 ocf_event_type type;
50
51 /** Size of this event */
52 uint32_t size;
53 };
54
55 /**
56 * @brief Cache trace description
57 */
58 struct ocf_event_cache_desc {
59 /** Event header */
60 struct ocf_event_hdr hdr;
61
62 /** Cache Id */
63 ocf_cache_id_t id;
64
65 /** Cache line size */
66 ocf_cache_line_size_t cache_line_size;
67
68 /** Cache mode */
69 ocf_cache_mode_t cache_mode;
70
71 /** Cache size in bytes*/
72 uint64_t cache_size;
73
74 /** Number of cores */
75 uint32_t cores_no;
76
77 /** Trace version */
78 uint32_t version;
79 };
80
81 /**
82 * @brief Core trace description
83 */
84 struct ocf_event_core_desc {
85 /** Event header */
86 struct ocf_event_hdr hdr;
87
88 /** Core Id */
89 ocf_core_id_t id;
90
91 /** Core size in bytes */
92 uint64_t core_size;
93 };
94
95 /** @brief IO operation */
96 typedef enum {
97 /** Read */
98 ocf_event_operation_rd = 'R',
99
100 /** Write */
101 ocf_event_operation_wr = 'W',
102
103 /** Flush */
104 ocf_event_operation_flush = 'F',
105
106 /** Discard */
107 ocf_event_operation_discard = 'D',
108 } ocf_event_operation_t;
109
110 /**
111 * @brief IO trace event
112 */
113 struct ocf_event_io {
114 /** Trace event header */
115 struct ocf_event_hdr hdr;
116
117 /** Address of IO in bytes */
118 uint64_t addr;
119
120 /** Size of IO in bytes */
121 uint32_t len;
122
123 /** IO class of IO */
124 uint32_t io_class;
125
126 /** Core ID */
127 ocf_core_id_t core_id;
128
129 /** Operation type: read, write, trim or flush **/
130 ocf_event_operation_t operation;
131 };
132
133 /**
134 * @brief IO completion event
135 */
136 struct ocf_event_io_cmpl {
137 /** Trace event header */
138 struct ocf_event_hdr hdr;
139
140 /** Reference event sequence ID */
141 log_sid_t rsid;
142
143 /** Was IO a cache hit or miss */
144 bool is_hit;
145 };
146
147
148 /** @brief Push log callback.
149 *
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
155 *
156 * @return 0 If pushing trace succeeded
157 * @return Non-zero error
158 */
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);
161
162 /**
163 * @brief Start tracing
164 *
165 * @param[in] cache OCF cache
166 * @param[in] trace_ctx Tracing context
167 * @param[in] trace_callback Callback used for pushing logs
168 *
169 * @retval 0 Tracing started successfully
170 * @retval Non-zero Error
171 */
172 int ocf_mngt_start_trace(ocf_cache_t cache, void *trace_ctx,
173 ocf_trace_callback_t trace_callback);
174
175 /**
176 * @brief Stop tracing
177 *
178 * @param[in] cache OCF cache
179 *
180 * @retval 0 Tracing stopped successfully
181 * @retval Non-zero Error
182 */
183 int ocf_mngt_stop_trace(ocf_cache_t cache);
184
185 #endif /* __OCF_TRACE_H__ */