]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/ocf/src/utils/utils_cleaner.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / spdk / ocf / src / utils / utils_cleaner.h
1 /*
2 * Copyright(c) 2012-2018 Intel Corporation
3 * SPDX-License-Identifier: BSD-3-Clause-Clear
4 */
5
6 #ifndef UTILS_CLEANER_H_
7 #define UTILS_CLEANER_H_
8
9 #include "../ocf_request.h"
10
11 /**
12 * @brief Getter for next cache line to be cleaned
13 *
14 * @param cache[in] Cache instance
15 * @param getter_context[in] Context for cleaner caller
16 * @param item[in] Current iteration item when collection cache lines
17 * @param line[out] line to be cleaned
18 * @retval 0 When caller return zero it means take this cache line to clean
19 * @retval Non-zero Means skip this cache line and do not clean it
20 */
21 typedef int (*ocf_cleaner_get_item)(struct ocf_cache *cache,
22 void *getter_context, uint32_t item, ocf_cache_line_t *line);
23
24 /**
25 * @brief Cleaning attributes for clean request
26 */
27 struct ocf_cleaner_attribs {
28 uint8_t cache_line_lock : 1; /*!< Clean under cache line lock */
29
30 uint8_t do_sort : 1; /*!< Sort cache lines which will be cleaned */
31
32 uint32_t count; /*!< max number of cache lines to be cleaned */
33
34 void *cmpl_context; /*!< Completion context of cleaning requester */
35 void (*cmpl_fn)(void *priv, int error); /*!< Completion function of requester */
36
37 ocf_cleaner_get_item getter;
38 /*!< Getter for collecting cache lines which will be cleaned */
39 void *getter_context;
40 /*!< Context for getting cache lines */
41 uint32_t getter_item;
42 /*!< Additional variable that can be used by cleaner caller
43 * to iterate over items
44 */
45
46 ocf_queue_t io_queue;
47 };
48
49 /**
50 * @brief Flush table entry structure
51 */
52 struct flush_data {
53 uint64_t core_line;
54 uint32_t cache_line;
55 ocf_core_id_t core_id;
56 };
57
58 typedef void (*ocf_flush_containter_coplete_t)(void *ctx);
59
60 /**
61 * @brief Flush table container
62 */
63 struct flush_container {
64 ocf_core_id_t core_id;
65 struct flush_data *flush_data;
66 uint32_t count;
67 uint32_t iter;
68
69 struct ocf_cleaner_attribs attribs;
70 ocf_cache_t cache;
71
72 struct ocf_request *req;
73
74 uint64_t flush_portion;
75 uint64_t ticks1;
76 uint64_t ticks2;
77
78 ocf_flush_containter_coplete_t end;
79 struct ocf_mngt_cache_flush_context *context;
80 };
81
82 /**
83 * @brief Run cleaning procedure
84 *
85 * @param cache - Cache instance
86 * @param attribs - Cleaning attributes
87 */
88 void ocf_cleaner_fire(struct ocf_cache *cache,
89 const struct ocf_cleaner_attribs *attribs);
90
91 /**
92 * @brief Perform cleaning procedure for specified flush data. Only dirty
93 * cache lines will be cleaned.
94 *
95 * @param cache - Cache instance
96 * @param flush - flush data to be cleaned
97 * @param count - Count of cache lines to be cleaned
98 * @param attribs - Cleaning attributes
99 * @return - Cleaning result. 0 - no errors, non zero errors occurred
100 */
101 int ocf_cleaner_do_flush_data_async(struct ocf_cache *cache,
102 struct flush_data *flush, uint32_t count,
103 struct ocf_cleaner_attribs *attribs);
104
105 /**
106 * @brief Sort flush data by core sector
107 *
108 * @param tbl Flush data to sort
109 * @param num Number of entries in tbl
110 */
111 void ocf_cleaner_sort_sectors(struct flush_data *tbl, uint32_t num);
112
113 /**
114 * @brief Sort flush data in all flush containters
115 *
116 * @param tbl Flush containers to sort
117 * @param num Number of entries in fctbl
118 */
119 void ocf_cleaner_sort_flush_containers(struct flush_container *fctbl,
120 uint32_t num);
121
122 #endif /* UTILS_CLEANER_H_ */