summaryrefslogtreecommitdiffstats
path: root/src/spdk/ocf/inc/ocf_stats.h
blob: b326c7409872ba30938838a3b3811d9023f84bfc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
/*
 * Copyright(c) 2012-2018 Intel Corporation
 * SPDX-License-Identifier: BSD-3-Clause-Clear
 */

/**
 * @file
 * @brief OCF API for updating and reseting statistics
 *
 * This file contains routines pertaining to manipulation of OCF IO statistics.
 */

#ifndef __OCF_STATS_H__
#define __OCF_STATS_H__

/**
 * Entire row of statistcs
 */
struct ocf_stat {
	/** Value */
	uint64_t value;
	/** percent x100 */
	uint64_t fraction;
};

/**
 * @brief Usage statistics in 4 KiB unit
 *
 * An example of presenting statistics:
 * <pre>
 * ╔══════════════════╤══════════╤═══════╤═════════════╗
 * ║ Usage statistics │  Count   │   %   │   Units     ║
 * ╠══════════════════╪══════════╪═══════╪═════════════╣
 * ║ Occupancy        │       20 │  50.0 │ 4KiB blocks ║
 * ║ Free             │       20 │  50.0 │ 4KiB blocks ║
 * ║ Clean            │       15 │  75.0 │ 4KiB blocks ║
 * ║ Dirty            │        5 │  25.0 │ 4KiB blocks ║
 * ╚══════════════════╧══════════╧═══════╧═════════════╝
 * </pre>
 */
struct ocf_stats_usage {
	struct ocf_stat occupancy;
	struct ocf_stat free;
	struct ocf_stat clean;
	struct ocf_stat dirty;
};

/**
 * @brief Requests statistcs
 *
 * An example of presenting statistics:
 * <pre>
 * ╔══════════════════════╤═══════╤═══════╤══════════╗
 * ║ Request statistics   │ Count │   %   │ Units    ║
 * ╠══════════════════════╪═══════╪═══════╪══════════╣
 * ║ Read hits            │    10 │   4.5 │ Requests ║
 * ║ Read partial misses  │     1 │   0.5 │ Requests ║
 * ║ Read full misses     │   211 │  95.0 │ Requests ║
 * ║ Read total           │   222 │ 100.0 │ Requests ║
 * ╟──────────────────────┼───────┼───────┼──────────╢
 * ║ Write hits           │     0 │   0.0 │ Requests ║
 * ║ Write partial misses │     0 │   0.0 │ Requests ║
 * ║ Write full misses    │     0 │   0.0 │ Requests ║
 * ║ Write total          │     0 │   0.0 │ Requests ║
 * ╟──────────────────────┼───────┼───────┼──────────╢
 * ║ Pass-Through reads   │     0 │   0.0 │ Requests ║
 * ║ Pass-Through writes  │     0 │   0.0 │ Requests ║
 * ║ Serviced requests    │   222 │ 100.0 │ Requests ║
 * ╟──────────────────────┼───────┼───────┼──────────╢
 * ║ Total requests       │   222 │ 100.0 │ Requests ║
 * ╚══════════════════════╧═══════╧═══════╧══════════╝
 * </pre>
 */
struct ocf_stats_requests {
	struct ocf_stat rd_hits;
	struct ocf_stat rd_partial_misses;
	struct ocf_stat rd_full_misses;
	struct ocf_stat rd_total;
	struct ocf_stat wr_hits;
	struct ocf_stat wr_partial_misses;
	struct ocf_stat wr_full_misses;
	struct ocf_stat wr_total;
	struct ocf_stat rd_pt;
	struct ocf_stat wr_pt;
	struct ocf_stat serviced;
	struct ocf_stat total;
};

/**
 * @brief Block statistics
 *
 * An example of presenting statistics:
 * <pre>
 * ╔════════════════════════════════════╤═══════╤═══════╤═════════════╗
 * ║ Block statistics                   │ Count │   %   │   Units     ║
 * ╠════════════════════════════════════╪═══════╪═══════╪═════════════╣
 * ║ Reads from core volume(s)          │   426 │ 100.0 │ 4KiB blocks ║
 * ║ Writes to core volume(s)           │     0 │   0.0 │ 4KiB blocks ║
 * ║ Total to/from core volume (s)      │   426 │ 100.0 │ 4KiB blocks ║
 * ╟────────────────────────────────────┼───────┼───────┼─────────────╢
 * ║ Reads from cache volume            │    13 │   3.0 │ 4KiB blocks ║
 * ║ Writes to cache volume             │   426 │  97.0 │ 4KiB blocks ║
 * ║ Total to/from cache volume         │   439 │ 100.0 │ 4KiB blocks ║
 * ╟────────────────────────────────────┼───────┼───────┼─────────────╢
 * ║ Reads from core(s)                 │   439 │ 100.0 │ 4KiB blocks ║
 * ║ Writes to core(s)                  │     0 │   0.0 │ 4KiB blocks ║
 * ║ Total to/from core(s)              │   439 │ 100.0 │ 4KiB blocks ║
 * ╚════════════════════════════════════╧═══════╧═══════╧═════════════╝
 * </pre>
 */
struct ocf_stats_blocks {
	struct ocf_stat core_volume_rd;
	struct ocf_stat core_volume_wr;
	struct ocf_stat core_volume_total;
	struct ocf_stat cache_volume_rd;
	struct ocf_stat cache_volume_wr;
	struct ocf_stat cache_volume_total;
	struct ocf_stat volume_rd;
	struct ocf_stat volume_wr;
	struct ocf_stat volume_total;
};

/**
 * @brief Errors statistics
 *
 * An example of presenting statistics:
 * <pre>
 * ╔════════════════════╤═══════╤═════╤══════════╗
 * ║ Error statistics   │ Count │  %  │ Units    ║
 * ╠════════════════════╪═══════╪═════╪══════════╣
 * ║ Cache read errors  │     0 │ 0.0 │ Requests ║
 * ║ Cache write errors │     0 │ 0.0 │ Requests ║
 * ║ Cache total errors │     0 │ 0.0 │ Requests ║
 * ╟────────────────────┼───────┼─────┼──────────╢
 * ║ Core read errors   │     0 │ 0.0 │ Requests ║
 * ║ Core write errors  │     0 │ 0.0 │ Requests ║
 * ║ Core total errors  │     0 │ 0.0 │ Requests ║
 * ╟────────────────────┼───────┼─────┼──────────╢
 * ║ Total errors       │     0 │ 0.0 │ Requests ║
 * ╚════════════════════╧═══════╧═════╧══════════╝
 * </pre>
 */
struct ocf_stats_errors {
	struct ocf_stat core_volume_rd;
	struct ocf_stat core_volume_wr;
	struct ocf_stat core_volume_total;
	struct ocf_stat cache_volume_rd;
	struct ocf_stat cache_volume_wr;
	struct ocf_stat cache_volume_total;
	struct ocf_stat total;
};

/**
 * @param Collect statistics for given cache
 *
 * @param cache Cache instance for which statistics will be collected
 * @param usage Usage statistics
 * @param req Request statistics
 * @param blocks Blocks statistics
 * @param errors Errors statistics
 *
 * @retval 0 Success
 * @retval Non-zero Error
 */
int ocf_stats_collect_cache(ocf_cache_t cache,
		struct ocf_stats_usage *usage,
		struct ocf_stats_requests *req,
		struct ocf_stats_blocks *blocks,
		struct ocf_stats_errors *errors);

/**
 * @param Collect statistics for given core
 *
 * @param core Core for which statistics will be collected
 * @param usage Usage statistics
 * @param req Request statistics
 * @param blocks Blocks statistics
 * @param errors Errors statistics
 *
 * @retval 0 Success
 * @retval Non-zero Error
 */
int ocf_stats_collect_core(ocf_core_t core,
		struct ocf_stats_usage *usage,
		struct ocf_stats_requests *req,
		struct ocf_stats_blocks *blocks,
		struct ocf_stats_errors *errors);

/**
 * @param Collect statistics for given ioclass
 *
 * @param core Core handle for which statistics will be collected
 * @param part_id Ioclass id for which statistics will be collected
 * @param usage Usage statistics
 * @param req Request statistics
 * @param blocks Blocks statistics
 *
 * @retval 0 Success
 * @retval Non-zero Error
 */
int ocf_stats_collect_part_core(ocf_core_t core, ocf_part_id_t part_id,
		struct ocf_stats_usage *usage, struct ocf_stats_requests *req,
		struct ocf_stats_blocks *blocks);

/**
 * @param Collect statistics for given ioclass
 *
 * @param cache Cache instance for which statistics will be collected
 * @param part_id Ioclass id for which statistics will be collected
 * @param usage Usage statistics
 * @param req Request statistics
 * @param blocks Blocks statistics
 *
 * @retval 0 Success
 * @retval Non-zero Error
 */
int ocf_stats_collect_part_cache(ocf_cache_t cache, ocf_part_id_t part_id,
		struct ocf_stats_usage *usage, struct ocf_stats_requests *req,
		struct ocf_stats_blocks *blocks);

/**
 * @brief Initialize or reset core statistics
 *
 * Initialize or reset counters used for statistics.
 *
 * @param[in] core Core handle
 */
void ocf_core_stats_initialize(ocf_core_t core);

/**
 * @brief Initialize or reset statistics of all cores in cache
 *
 * Initialize or reset counters used for statistics.
 *
 * @param[in] cache Cache handle
 */
void ocf_core_stats_initialize_all(ocf_cache_t cache);

#endif /* __OCF_STATS_H__ */