2 * Copyright(c) 2012-2018 Intel Corporation
3 * SPDX-License-Identifier: BSD-3-Clause-Clear
6 #ifndef UTILS_CLEANER_H_
7 #define UTILS_CLEANER_H_
9 #include "../ocf_request.h"
12 * @brief Getter for next cache line to be cleaned
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
21 typedef int (*ocf_cleaner_get_item
)(struct ocf_cache
*cache
,
22 void *getter_context
, uint32_t item
, ocf_cache_line_t
*line
);
25 * @brief Cleaning attributes for clean request
27 struct ocf_cleaner_attribs
{
28 uint8_t cache_line_lock
: 1; /*!< Clean under cache line lock */
30 uint8_t do_sort
: 1; /*!< Sort cache lines which will be cleaned */
32 uint32_t count
; /*!< max number of cache lines to be cleaned */
34 void *cmpl_context
; /*!< Completion context of cleaning requester */
35 void (*cmpl_fn
)(void *priv
, int error
); /*!< Completion function of requester */
37 ocf_cleaner_get_item getter
;
38 /*!< Getter for collecting cache lines which will be cleaned */
40 /*!< Context for getting cache lines */
42 /*!< Additional variable that can be used by cleaner caller
43 * to iterate over items
50 * @brief Flush table entry structure
55 ocf_core_id_t core_id
;
58 typedef void (*ocf_flush_containter_coplete_t
)(void *ctx
);
61 * @brief Flush table container
63 struct flush_container
{
64 ocf_core_id_t core_id
;
65 struct flush_data
*flush_data
;
69 struct ocf_cleaner_attribs attribs
;
72 struct ocf_request
*req
;
74 uint64_t flush_portion
;
78 ocf_flush_containter_coplete_t end
;
79 struct ocf_mngt_cache_flush_context
*context
;
83 * @brief Run cleaning procedure
85 * @param cache - Cache instance
86 * @param attribs - Cleaning attributes
88 void ocf_cleaner_fire(struct ocf_cache
*cache
,
89 const struct ocf_cleaner_attribs
*attribs
);
92 * @brief Perform cleaning procedure for specified flush data. Only dirty
93 * cache lines will be cleaned.
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
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
);
106 * @brief Sort flush data by core sector
108 * @param tbl Flush data to sort
109 * @param num Number of entries in tbl
111 void ocf_cleaner_sort_sectors(struct flush_data
*tbl
, uint32_t num
);
114 * @brief Sort flush data in all flush containters
116 * @param tbl Flush containers to sort
117 * @param num Number of entries in fctbl
119 void ocf_cleaner_sort_flush_containers(struct flush_container
*fctbl
,
122 #endif /* UTILS_CLEANER_H_ */