2 * Copyright(c) 2012-2018 Intel Corporation
3 * SPDX-License-Identifier: BSD-3-Clause-Clear
8 * @brief OCF API for collecting statistics
10 * This file contains routines pertaining to retrieval and
11 * manipulation of OCF IO statistics.
14 #ifndef __OCF_STATS_BUILDER_H__
15 #define __OCF_STATS_BUILDER_H__
18 * Entire row of statistcs
28 * @brief Usage statistics in 4 KiB unit
30 * An example of presenting statistics:
32 * ╔══════════════════╤══════════╤═══════╤═════════════╗
33 * ║ Usage statistics │ Count │ % │ Units ║
34 * ╠══════════════════╪══════════╪═══════╪═════════════╣
35 * ║ Occupancy │ 20 │ 50.0 │ 4KiB blocks ║
36 * ║ Free │ 20 │ 50.0 │ 4KiB blocks ║
37 * ║ Clean │ 15 │ 75.0 │ 4KiB blocks ║
38 * ║ Dirty │ 5 │ 25.0 │ 4KiB blocks ║
39 * ╚══════════════════╧══════════╧═══════╧═════════════╝
42 struct ocf_stats_usage
{
43 struct ocf_stat occupancy
;
45 struct ocf_stat clean
;
46 struct ocf_stat dirty
;
50 * @brief Requests statistcs
52 * An example of presenting statistics:
54 * ╔══════════════════════╤═══════╤═══════╤══════════╗
55 * ║ Request statistics │ Count │ % │ Units ║
56 * ╠══════════════════════╪═══════╪═══════╪══════════╣
57 * ║ Read hits │ 10 │ 4.5 │ Requests ║
58 * ║ Read partial misses │ 1 │ 0.5 │ Requests ║
59 * ║ Read full misses │ 211 │ 95.0 │ Requests ║
60 * ║ Read total │ 222 │ 100.0 │ Requests ║
61 * ╟──────────────────────┼───────┼───────┼──────────╢
62 * ║ Write hits │ 0 │ 0.0 │ Requests ║
63 * ║ Write partial misses │ 0 │ 0.0 │ Requests ║
64 * ║ Write full misses │ 0 │ 0.0 │ Requests ║
65 * ║ Write total │ 0 │ 0.0 │ Requests ║
66 * ╟──────────────────────┼───────┼───────┼──────────╢
67 * ║ Pass-Through reads │ 0 │ 0.0 │ Requests ║
68 * ║ Pass-Through writes │ 0 │ 0.0 │ Requests ║
69 * ║ Serviced requests │ 222 │ 100.0 │ Requests ║
70 * ╟──────────────────────┼───────┼───────┼──────────╢
71 * ║ Total requests │ 222 │ 100.0 │ Requests ║
72 * ╚══════════════════════╧═══════╧═══════╧══════════╝
75 struct ocf_stats_requests
{
76 struct ocf_stat rd_hits
;
77 struct ocf_stat rd_partial_misses
;
78 struct ocf_stat rd_full_misses
;
79 struct ocf_stat rd_total
;
80 struct ocf_stat wr_hits
;
81 struct ocf_stat wr_partial_misses
;
82 struct ocf_stat wr_full_misses
;
83 struct ocf_stat wr_total
;
84 struct ocf_stat rd_pt
;
85 struct ocf_stat wr_pt
;
86 struct ocf_stat serviced
;
87 struct ocf_stat total
;
91 * @brief Block statistics
93 * An example of presenting statistics:
95 * ╔════════════════════════════════════╤═══════╤═══════╤═════════════╗
96 * ║ Block statistics │ Count │ % │ Units ║
97 * ╠════════════════════════════════════╪═══════╪═══════╪═════════════╣
98 * ║ Reads from core volume(s) │ 426 │ 100.0 │ 4KiB blocks ║
99 * ║ Writes to core volume(s) │ 0 │ 0.0 │ 4KiB blocks ║
100 * ║ Total to/from core volume (s) │ 426 │ 100.0 │ 4KiB blocks ║
101 * ╟────────────────────────────────────┼───────┼───────┼─────────────╢
102 * ║ Reads from cache volume │ 13 │ 3.0 │ 4KiB blocks ║
103 * ║ Writes to cache volume │ 426 │ 97.0 │ 4KiB blocks ║
104 * ║ Total to/from cache volume │ 439 │ 100.0 │ 4KiB blocks ║
105 * ╟────────────────────────────────────┼───────┼───────┼─────────────╢
106 * ║ Reads from core(s) │ 439 │ 100.0 │ 4KiB blocks ║
107 * ║ Writes to core(s) │ 0 │ 0.0 │ 4KiB blocks ║
108 * ║ Total to/from core(s) │ 439 │ 100.0 │ 4KiB blocks ║
109 * ╚════════════════════════════════════╧═══════╧═══════╧═════════════╝
112 struct ocf_stats_blocks
{
113 struct ocf_stat core_volume_rd
;
114 struct ocf_stat core_volume_wr
;
115 struct ocf_stat core_volume_total
;
116 struct ocf_stat cache_volume_rd
;
117 struct ocf_stat cache_volume_wr
;
118 struct ocf_stat cache_volume_total
;
119 struct ocf_stat volume_rd
;
120 struct ocf_stat volume_wr
;
121 struct ocf_stat volume_total
;
125 * @brief Errors statistics
127 * An example of presenting statistics:
129 * ╔════════════════════╤═══════╤═════╤══════════╗
130 * ║ Error statistics │ Count │ % │ Units ║
131 * ╠════════════════════╪═══════╪═════╪══════════╣
132 * ║ Cache read errors │ 0 │ 0.0 │ Requests ║
133 * ║ Cache write errors │ 0 │ 0.0 │ Requests ║
134 * ║ Cache total errors │ 0 │ 0.0 │ Requests ║
135 * ╟────────────────────┼───────┼─────┼──────────╢
136 * ║ Core read errors │ 0 │ 0.0 │ Requests ║
137 * ║ Core write errors │ 0 │ 0.0 │ Requests ║
138 * ║ Core total errors │ 0 │ 0.0 │ Requests ║
139 * ╟────────────────────┼───────┼─────┼──────────╢
140 * ║ Total errors │ 0 │ 0.0 │ Requests ║
141 * ╚════════════════════╧═══════╧═════╧══════════╝
144 struct ocf_stats_errors
{
145 struct ocf_stat core_volume_rd
;
146 struct ocf_stat core_volume_wr
;
147 struct ocf_stat core_volume_total
;
148 struct ocf_stat cache_volume_rd
;
149 struct ocf_stat cache_volume_wr
;
150 struct ocf_stat cache_volume_total
;
151 struct ocf_stat total
;
155 * @param Collect statistics for given cache
157 * @param cache Cache instance for each statistics will be collected
158 * @param usage Usage statistics
159 * @param req Request statistics
160 * @param blocks Blocks statistics
161 * @param errors Errors statistics
164 * @retval Non-zero Error
166 int ocf_stats_collect_cache(ocf_cache_t cache
,
167 struct ocf_stats_usage
*usage
,
168 struct ocf_stats_requests
*req
,
169 struct ocf_stats_blocks
*blocks
,
170 struct ocf_stats_errors
*errors
);
173 * @param Collect statistics for given core
175 * @param cache Core for each statistics will be collected
176 * @param usage Usage statistics
177 * @param req Request statistics
178 * @param blocks Blocks statistics
179 * @param errors Errors statistics
182 * @retval Non-zero Error
184 int ocf_stats_collect_core(ocf_core_t core
,
185 struct ocf_stats_usage
*usage
,
186 struct ocf_stats_requests
*req
,
187 struct ocf_stats_blocks
*blocks
,
188 struct ocf_stats_errors
*errors
);
190 #endif /* __OCF_STATS_BUILDER_H__ */